diff --git a/.circleci/config.yml b/.circleci/config.yml index 2eb1f4238cc..84ddcdf26ea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,24 +38,12 @@ aliases: name: BrowserStack End to end testing command: gulp e2e-test - # Download and run BrowserStack local - - &setup_browserstack - name : Download BrowserStack Local binary and start it. - command : | - # Download the browserstack binary file - wget "https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip" - # Unzip it - unzip BrowserStackLocal-linux-x64.zip - # Run the file with user's access key - ./BrowserStackLocal ${BROWSERSTACK_ACCESS_KEY} & - - &unit_test_steps - checkout - restore_cache: *restore_dep_cache - run: npm ci - save_cache: *save_dep_cache - run: *install - - run: *setup_browserstack - run: *run_unit_test - &endtoend_test_steps @@ -64,7 +52,6 @@ aliases: - run: npm install - save_cache: *save_dep_cache - run: *install - - run: *setup_browserstack - run: *run_endtoend_test version: 2 @@ -82,7 +69,9 @@ workflows: commit: jobs: - build - - e2etest + - e2etest: + requires: + - build experimental: pipelines: true diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cfb29ebdfa9..69e13850258 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,8 @@ ARG VARIANT="12" FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:${VARIANT} +RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/yarn-archive-keyring.gpg + # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0176b8317b3..d4c34929569 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,14 +9,17 @@ }, "postCreateCommand": "bash .devcontainer/postCreate.sh", - + // Make is-docker work again + "postStartCommand": "test -f /.dockerenv || sudo touch /.dockerenv", + // Set *default* container specific settings.json values on container create. "settings": {}, // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "nickdodd79.gulptasks" + "nickdodd79.gulptasks", + "dbaeumer.vscode-eslint" ], // 9999 is web server, 9876 is karma diff --git a/.eslintrc.js b/.eslintrc.js index d3379d70919..fc3ad3afe66 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,9 +19,9 @@ module.exports = { 'import' ], globals: { - '$$PREBID_GLOBAL$$': false, 'BROWSERSTACK_USERNAME': false, - 'BROWSERSTACK_KEY': false + 'BROWSERSTACK_KEY': false, + 'FEATURES': 'readonly', }, // use babel as parser for fancy syntax parser: '@babel/eslint-parser', @@ -45,12 +45,19 @@ module.exports = { 'no-throw-literal': 'off', 'no-undef': 2, 'no-useless-escape': 'off', - 'no-console': 'error' + 'no-console': 'error', }, overrides: Object.keys(allowedModules).map((key) => ({ files: key + '/**/*.js', rules: { - 'prebid/validate-imports': ['error', allowedModules[key]] + 'prebid/validate-imports': ['error', allowedModules[key]], + 'no-restricted-globals': [ + 'error', + { + name: 'require', + message: 'use import instead' + } + ] } })).concat([{ // code in other packages (such as plugins/eslint) is not "seen" by babel and its parser will complain. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9fdb04ba556..09ef5c445f2 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,15 @@ ## Type of change @@ -11,14 +21,16 @@ Thank you for your pull request. Please make sure this PR is scoped to one chang - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] CI related changes + - [ ] Does this change affect user-facing APIs or examples documented on http://prebid.org? - [ ] Other ## Description of change - -- test parameters for validating bids + -- A link to a PR on the docs repo at https://github.com/prebid/prebid.github.io/ ## Other information diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 00000000000..2e8465003e4 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +paths: + - src + - modules + - libraries diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..5ace4600a1f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000000..84c97376a3e --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,73 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master"] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master"] + schedule: + - cron: '22 11 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + config-file: ./.github/codeql/codeql-config.yml + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/issue_tracker.yml b/.github/workflows/issue_tracker.yml index 4397337b4c7..b5c59c85160 100644 --- a/.github/workflows/issue_tracker.yml +++ b/.github/workflows/issue_tracker.yml @@ -3,13 +3,18 @@ on: issues: types: - opened +permissions: + contents: read + jobs: track_issue: + permissions: + contents: none runs-on: ubuntu-latest steps: - name: Generate token id: generate_token - uses: tibdex/github-app-token@36464acb844fc53b9b8b2401da68844f6b05ebb0 + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a with: app_id: ${{ secrets.ISSUE_APP_ID }} private_key: ${{ secrets.ISSUE_APP_PEM }} @@ -24,21 +29,30 @@ jobs: gh api graphql -f query=' query($org: String!, $number: Int!) { organization(login: $org){ - projectNext(number: $number) { + projectV2(number: $number) { id fields(first:100) { nodes { - id - name - settings + ... on ProjectV2Field { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } } } } } }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json - echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV - echo 'DATE_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "'"$DATE_FIELD"'") | .id' project_data.json) >> $GITHUB_ENV + echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV + echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name=="'"$DATE_FIELD"'") | .id' project_data.json) >> $GITHUB_ENV - name: Add issue to project env: @@ -47,9 +61,9 @@ jobs: run: | gh api graphql -f query=' mutation($project:ID!, $issue:ID!) { - addProjectNextItem(input: {projectId: $project, contentId: $issue}) { - projectNextItem { - id, + addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) { + item { + id content { ... on Issue { createdAt @@ -62,8 +76,8 @@ jobs: } }' -f project=$PROJECT_ID -f issue=$ISSUE_ID > issue_data.json - echo 'ITEM_ID='$(jq '.data.addProjectNextItem.projectNextItem.id' issue_data.json) >> $GITHUB_ENV - echo 'ITEM_CREATION_DATE='$(jq '.data.addProjectNextItem.projectNextItem.content.createdAt' issue_data.json) >> $GITHUB_ENV + echo 'ITEM_ID='$(jq '.data.addProjectV2ItemById.item.id' issue_data.json) >> $GITHUB_ENV + echo 'ITEM_CREATION_DATE='$(jq '.data.addProjectV2ItemById.item.content.createdAt' issue_data.json | cut -c 2-11) >> $GITHUB_ENV - name: Set fields env: @@ -74,15 +88,17 @@ jobs: $project: ID! $item: ID! $date_field: ID! - $date_value: String! + $date_value: Date! ) { - set_creation_date: updateProjectNextItemField(input: { + set_creation_date: updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item fieldId: $date_field - value: $date_value + value: { + date: $date_value + } }) { - projectNextItem { + projectV2Item { id } } diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 8152b61275d..a13237f1290 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -6,8 +6,14 @@ on: branches: - master +permissions: + contents: read + jobs: update_release_draft: + permissions: + contents: write # for release-drafter/release-drafter to create a github release + pull-requests: write # for release-drafter/release-drafter to add label to PR runs-on: ubuntu-latest steps: # Drafts your next Release notes as Pull Requests are merged into "master" diff --git a/.gitignore b/.gitignore index c0452b7b3d0..e5f000dd4d5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ selenium*.log integrationExamples/gpt/gpt.html integrationExamples/gpt/*-test.html integrationExamples/implementations/ -src/adapters/analytics/libraries +libraries/analyticsAdapter/examples/libraries # Coverage reports build/coverage/ diff --git a/PR_REVIEW.md b/PR_REVIEW.md index 2934a30fb47..45ca30a7a3d 100644 --- a/PR_REVIEW.md +++ b/PR_REVIEW.md @@ -128,6 +128,10 @@ Follow steps above for general review process. In addition: - Consider whether the kind of data the module is obtaining could have privacy implications. If so, make sure they're utilizing the `consent` data passed to them. - Make sure there's a docs pull request +### Reviewing changes to the `debugging` module + +The debugging module cannot import from core in the same way that other modules can. See this [warning](https://github.com/prebid/Prebid.js/blob/master/modules/debugging/WARNING.md) for more details. + ## Ticket Coordinator Each week, Prebid Org assigns one person to keep an eye on incoming issues and PRs. Every Monday morning a reminder is sent to the prebid-js slack channel with a link to the spreadsheet. If you're on rotation, please check that list each Monday to see if you're on-duty. diff --git a/README.md b/README.md index 42d747b20b6..58007519b15 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ [![Build Status](https://circleci.com/gh/prebid/Prebid.js.svg?style=svg)](https://circleci.com/gh/prebid/Prebid.js) [![Percentage of issues still open](http://isitmaintained.com/badge/open/prebid/Prebid.js.svg)](http://isitmaintained.com/project/prebid/Prebid.js "Percentage of issues still open") -[![Code Climate](https://codeclimate.com/github/prebid/Prebid.js/badges/gpa.svg)](https://codeclimate.com/github/prebid/Prebid.js) [![Coverage Status](https://coveralls.io/repos/github/prebid/Prebid.js/badge.svg)](https://coveralls.io/github/prebid/Prebid.js) -[![devDependencies Status](https://david-dm.org/prebid/Prebid.js/dev-status.svg)](https://david-dm.org/prebid/Prebid.js?type=dev) -[![Total Alerts](https://img.shields.io/lgtm/alerts/g/prebid/Prebid.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/prebid/Prebid.js/alerts/) # Prebid.js @@ -91,7 +88,7 @@ Or for Babel 6: } ``` -Then you can use Prebid.js as any other npm depedendency +Then you can use Prebid.js as any other npm dependency ```javascript import pbjs from 'prebid.js'; @@ -111,6 +108,8 @@ pbjs.requestBids({ ## Install + + $ git clone https://github.com/prebid/Prebid.js.git $ cd Prebid.js $ npm ci @@ -193,8 +192,43 @@ Most likely your custom `prebid.js` will only change when there's: Having said that, you are probably safe to check your custom bundle into your project. You can also generate it in your build process. +**Build once, bundle multiple times** + +If you need to generate multiple distinct bundles from the same Prebid version, you can reuse a single build with: + +``` +gulp build +gulp bundle --tag one --modules=one.json +gulp bundle --tag two --modules=two.json +``` + +This generates slightly larger files, but has the advantage of being much faster to run (after the initial `gulp build`). It's also the method used by [the Prebid.org download page](https://docs.prebid.org/download.html). + +### Excluding particular features from the build + +Since version 7.2.0, you may instruct the build to exclude code for some features - for example, if you don't need support for native ads: + +``` +gulp build --disable NATIVE --modules=openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter # substitute your module list +``` + +Or, if you are consuming Prebid through npm, with the `disableFeatures` option in your Prebid rule: + +```javascript + { + test: /.js$/, + include: new RegExp(`\\${path.sep}prebid\\.js`), + use: { + loader: 'babel-loader', + options: require('prebid.js/babelConfig.js')({disableFeatures: ['NATIVE']}) + } + } +``` + +**Note**: this is still a work in progress - at the moment, `NATIVE` is the only feature that can be disabled this way, resulting in a minimal decrease in size (but you can expect that to improve over time). + ## Test locally To lint the code: @@ -326,3 +360,4 @@ Prebid.js is supported on IE11 and modern browsers until 5.x. 6.x+ transpiles to ### Governance Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md). +### END diff --git a/RELEASE_SCHEDULE.md b/RELEASE_SCHEDULE.md index b68495ed4ae..45f4e6c7dc5 100644 --- a/RELEASE_SCHEDULE.md +++ b/RELEASE_SCHEDULE.md @@ -12,7 +12,7 @@ We aim to push a new release of Prebid.js every week on Tuesday. While the releases will be available immediately for those using direct Git access, -it will be about a week before the Prebid Org [Download Page](http://prebid.org/download.html) will be updated. +it will be about a week before the Prebid Org [Download Page](https://docs.prebid.org/download.html) will be updated. You can determine what is in a given build using the [releases page](https://github.com/prebid/Prebid.js/releases) diff --git a/allowedModules.js b/allowedModules.js index be9a2dc2abf..3e6e3039fa2 100644 --- a/allowedModules.js +++ b/allowedModules.js @@ -15,5 +15,8 @@ module.exports = { 'just-clone', 'dlv', 'dset' + ], + 'libraries': [ + ...sharedWhiteList // empty for now, but keep it to enable linting ] }; diff --git a/babelConfig.js b/babelConfig.js index c1ddc11b689..a88491c0cae 100644 --- a/babelConfig.js +++ b/babelConfig.js @@ -9,7 +9,7 @@ function useLocal(module) { }) } -module.exports = function (test = false) { +module.exports = function (options = {}) { return { 'presets': [ [ @@ -18,13 +18,19 @@ module.exports = function (test = false) { 'useBuiltIns': 'entry', 'corejs': '3.13.0', // a lot of tests use sinon.stub & others that stopped working on ES6 modules with webpack 5 - 'modules': test ? 'commonjs' : 'auto', + 'modules': options.test ? 'commonjs' : 'auto', } ] ], - 'plugins': [ - path.resolve(__dirname, './plugins/pbjsGlobals.js'), - useLocal('babel-plugin-transform-object-assign'), - ], + 'plugins': (() => { + const plugins = [ + [path.resolve(__dirname, './plugins/pbjsGlobals.js'), options], + [useLocal('@babel/plugin-transform-runtime')], + ]; + if (options.codeCoverage) { + plugins.push([useLocal('babel-plugin-istanbul')]) + } + return plugins; + })(), } } diff --git a/bundle-template.txt b/bundle-template.txt new file mode 100644 index 00000000000..2f58aedfe81 --- /dev/null +++ b/bundle-template.txt @@ -0,0 +1,16 @@ +/* <%= prebid.name %> v<%= prebid.version %> +Updated: <%= (new Date()).toISOString().substring(0, 10) %> +Modules: <%= modules %> */ + +if (!window.<%= prebid.globalVarName %> || !window.<%= prebid.globalVarName %>.libLoaded) { + $$PREBID_SOURCE$$ + <% if(enable) {%> + <%= prebid.globalVarName %>.processQueue(); + <% } %> +} else { + try { + if(window.<%= prebid.globalVarName %>.getConfig('debug')) { + console.warn('Attempted to load a copy of Prebid.js that clashes with the existing \'<%= prebid.globalVarName %>\' instance. Load aborted.'); + } + } catch (e) {} +} diff --git a/features.json b/features.json new file mode 100644 index 00000000000..ccb2166a05f --- /dev/null +++ b/features.json @@ -0,0 +1,4 @@ +[ + "NATIVE", + "VIDEO" +] diff --git a/governance.md b/governance.md index 3d00f067194..b1446a22373 100644 --- a/governance.md +++ b/governance.md @@ -9,15 +9,9 @@ This document describes the governance model for the Prebid project. The Prebid ### Roles and Responsibilities: - **User:** Any individual who consumes / uses the Prebid.js library. -- **Contributor:** Any individual who contributes code that is subsequently merged to the project. Contributed code is governed by the Prebid.js [license](https://github.com/prebid/Prebid.js/blob/master/LICENSE). Contributors are required to sign a CLA before any code can be committed (CLA pending). -- **Core Team Member:** An individual contributor who has been appointed by the Tech Lead on the project to maintain it and further it’s stated goals. -- **Tech Lead:** The Tech Lead is responsible for overall technical direction of the project. The Tech Lead will work closely with Core Team members to facilitate development and further the project goals. +- **Contributor:** Any individual who contributes code that is subsequently merged to the project. Contributed code is governed by the Prebid.js [license](https://github.com/prebid/Prebid.js/blob/master/LICENSE). +- **Core & Review Team Member:** An individual contributor who has been appointed by the Tech Lead on the project to maintain it and further it’s stated goals. +- **Identity Team Member:** An individual contributor who has been appointed by the Identity PMC to review and maintain the identity modules and further the PMC stated goals. +- **Tech Lead:** The Tech Lead is responsible for overall technical direction of the project & serves as the PMC chair. The Tech Lead will work closely with Core Team members to facilitate development and further the project goals. -### Current Prebid.js Core Team -- @mkendall07 (Tech Lead) -- @jsnellbaker -- @matthewlane -- @jaiminpanchal27 -- @snapwich -- @harpere -- @mike-chowla +The Core team is currently visible at https://github.com/orgs/prebid/teams/core/members to project members. diff --git a/gulpHelpers.js b/gulpHelpers.js index c0946edf93d..1eec08b7a3e 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -6,7 +6,7 @@ const MANIFEST = 'package.json'; const through = require('through2'); const _ = require('lodash'); const gutil = require('gulp-util'); -const submodules = require('./modules/.submodules.json'); +const submodules = require('./modules/.submodules.json').parentModules; const MODULE_PATH = './modules'; const BUILD_PATH = './build/dist'; @@ -105,16 +105,20 @@ module.exports = { }, internalModules)); }), + getBuiltPath(dev, assetPath) { + return path.join(__dirname, dev ? DEV_PATH : BUILD_PATH, assetPath) + }, + getBuiltModules: function(dev, externalModules) { var modules = this.getModuleNames(externalModules); if (Array.isArray(externalModules)) { modules = _.intersection(modules, externalModules); } - return modules.map(name => path.join(__dirname, dev ? DEV_PATH : BUILD_PATH, name + '.js')); + return modules.map(name => this.getBuiltPath(dev, name + '.js')); }, getBuiltPrebidCoreFile: function(dev) { - return path.join(__dirname, dev ? DEV_PATH : BUILD_PATH, 'prebid-core' + '.js'); + return this.getBuiltPath(dev, 'prebid-core.js') }, getModulePaths: function(externalModules) { @@ -169,5 +173,11 @@ module.exports = { } return options; - } + }, + getDisabledFeatures() { + return (argv.disable || '') + .split(',') + .map((s) => s.trim()) + .filter((s) => s); + }, }; diff --git a/gulpfile.js b/gulpfile.js index ff49436384b..09de874e389 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,14 +9,10 @@ var connect = require('gulp-connect'); var webpack = require('webpack'); var webpackStream = require('webpack-stream'); var gulpClean = require('gulp-clean'); -var KarmaServer = require('karma').Server; -var karmaConfMaker = require('./karma.conf.maker.js'); var opens = require('opn'); var webpackConfig = require('./webpack.conf.js'); var helpers = require('./gulpHelpers.js'); var concat = require('gulp-concat'); -var header = require('gulp-header'); -var footer = require('gulp-footer'); var replace = require('gulp-replace'); var shell = require('gulp-shell'); var eslint = require('gulp-eslint'); @@ -27,14 +23,15 @@ var fs = require('fs'); var jsEscape = require('gulp-js-escape'); const path = require('path'); const execa = require('execa'); +const {minify} = require('terser'); +const Vinyl = require('vinyl'); var prebid = require('./package.json'); -var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10); -var banner = '/* <%= prebid.name %> v<%= prebid.version %>\n' + dateString + '*/\n'; var port = 9999; const INTEG_SERVER_HOST = argv.host ? argv.host : 'localhost'; const INTEG_SERVER_PORT = 4444; -const { spawn } = require('child_process'); +const { spawn, fork } = require('child_process'); +const TerserPlugin = require('terser-webpack-plugin'); // these modules must be explicitly listed in --modules to be included in the build, won't be part of "all" modules var explicitModules = [ @@ -73,6 +70,7 @@ function lint(done) { return gulp.src([ 'src/**/*.js', 'modules/**/*.js', + 'libraries/**/*.js', 'test/**/*.js', 'plugins/**/*.js', '!plugins/**/node_modules/**', @@ -120,6 +118,15 @@ function makeDevpackPkg() { devtool: 'source-map', mode: 'development' }) + + const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures(), prebidDistUrlBase: argv.distUrlBase || '/build/dev/'}); + + // update babel config to set local dist url + cloned.module.rules + .flatMap((rule) => rule.use) + .filter((use) => use.loader === 'babel-loader') + .forEach((use) => use.options = Object.assign({}, use.options, babelConfig)); + var externalModules = helpers.getArgModules(); const analyticsSources = helpers.getAnalyticsSources(); @@ -132,35 +139,31 @@ function makeDevpackPkg() { .pipe(connect.reload()); } -function makeWebpackPkg() { - var cloned = _.cloneDeep(webpackConfig); +function makeWebpackPkg(extraConfig = {}) { + var cloned = _.merge(_.cloneDeep(webpackConfig), extraConfig); if (!argv.sourceMaps) { delete cloned.devtool; } - var externalModules = helpers.getArgModules(); - - const analyticsSources = helpers.getAnalyticsSources(); - const moduleSources = helpers.getModulePaths(externalModules); - - return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js')) - .pipe(helpers.nameModules(externalModules)) - .pipe(webpackStream(cloned, webpack)) - .pipe(gulp.dest('build/dist')); -} + return function buildBundle() { + var externalModules = helpers.getArgModules(); -function addBanner() { - const sm = argv.sourceMaps; + const analyticsSources = helpers.getAnalyticsSources(); + const moduleSources = helpers.getModulePaths(externalModules); - return gulp.src(['build/dist/prebid-core.js']) - .pipe(gulpif(sm, sourcemaps.init({loadMaps: true}))) - .pipe(header(banner, {prebid})) - .pipe(gulpif(sm, sourcemaps.write('.'))) - .pipe(gulp.dest('build/dist')) + return gulp.src([].concat(moduleSources, analyticsSources, 'src/prebid.js')) + .pipe(helpers.nameModules(externalModules)) + .pipe(webpackStream(cloned, webpack)) + .pipe(gulp.dest('build/dist')); + } } function getModulesListToAddInBanner(modules) { - return (modules.length > 0) ? modules.join(', ') : 'All available modules in current version.'; + if (!modules || modules.length === helpers.getModuleNames().length) { + return 'All available modules for this version.' + } else { + return modules.join(', ') + } } function gulpBundle(dev) { @@ -180,6 +183,47 @@ function nodeBundle(modules, dev = false) { }); } +function wrapWithHeaderAndFooter(dev, modules) { + // NOTE: gulp-header, gulp-footer & gulp-wrap do not play nice with source maps. + // gulp-concat does; for that reason we are prepending and appending the source stream with "fake" header & footer files. + function memoryVinyl(name, contents) { + return new Vinyl({ + cwd: '', + base: 'generated', + path: name, + contents: Buffer.from(contents, 'utf-8') + }); + } + return function wrap(stream) { + const wrapped = through.obj(); + const placeholder = '$$PREBID_SOURCE$$'; + const tpl = _.template(fs.readFileSync('./bundle-template.txt'))({ + prebid, + modules: getModulesListToAddInBanner(modules), + enable: !argv.manualEnable + }); + (dev ? Promise.resolve(tpl) : minify(tpl, {format: {comments: true}}).then((res) => res.code)) + .then((tpl) => { + // wrap source placeholder in an IIFE to make it an expression (so that it works with minify output) + const parts = tpl.replace(placeholder, `(function(){$$${placeholder}$$})()`).split(placeholder); + if (parts.length !== 2) { + throw new Error(`Cannot parse bundle template; it must contain exactly one instance of '${placeholder}'`); + } + const [header, footer] = parts; + wrapped.push(memoryVinyl('prebid-header.js', header)); + stream.pipe(wrapped, {end: false}); + stream.on('end', () => { + wrapped.push(memoryVinyl('prebid-footer.js', footer)); + wrapped.push(null); + }); + }) + .catch((err) => { + wrapped.destroy(err); + }); + return wrapped; + } +} + function bundle(dev, moduleArr) { var modules = moduleArr || helpers.getArgModules(); var allModules = helpers.getModuleNames(modules); @@ -196,8 +240,15 @@ function bundle(dev, moduleArr) { }); } } + const coreFile = helpers.getBuiltPrebidCoreFile(dev); + const moduleFiles = helpers.getBuiltModules(dev, modules); + const depGraph = require(helpers.getBuiltPath(dev, 'dependencies.json')); + const dependencies = new Set(); + [coreFile].concat(moduleFiles).map(name => path.basename(name)).forEach((file) => { + (depGraph[file] || []).forEach((dep) => dependencies.add(helpers.getBuiltPath(dev, dep))); + }); - var entries = [helpers.getBuiltPrebidCoreFile(dev)].concat(helpers.getBuiltModules(dev, modules)); + const entries = [coreFile].concat(Array.from(dependencies), moduleFiles); var outputFileName = argv.bundleName ? argv.bundleName : 'prebid.js'; @@ -210,17 +261,10 @@ function bundle(dev, moduleArr) { gutil.log('Appending ' + prebid.globalVarName + '.processQueue();'); gutil.log('Generating bundle:', outputFileName); - return gulp.src( - entries - ) - // Need to uodate the "Modules: ..." section in comment with the current modules list - .pipe(replace(/(Modules: )(.*?)(\*\/)/, ('$1' + getModulesListToAddInBanner(helpers.getArgModules()) + ' $3'))) + const wrap = wrapWithHeaderAndFooter(dev, modules); + return wrap(gulp.src(entries)) .pipe(gulpif(sm, sourcemaps.init({ loadMaps: true }))) .pipe(concat(outputFileName)) - .pipe(gulpif(!argv.manualEnable, footer('\n<%= global %>.processQueue();', { - global: prebid.globalVarName - } - ))) .pipe(gulpif(sm, sourcemaps.write('.'))); } @@ -236,9 +280,11 @@ function bundle(dev, moduleArr) { function testTaskMaker(options = {}) { ['watch', 'e2e', 'file', 'browserstack', 'notest'].forEach(opt => { - options[opt] = options[opt] || argv[opt]; + options[opt] = options.hasOwnProperty(opt) ? options[opt] : argv[opt]; }) + options.disableFeatures = options.disableFeatures || helpers.getDisabledFeatures(); + return function test(done) { if (options.notest) { done(); @@ -259,14 +305,7 @@ function testTaskMaker(options = {}) { process.exit(1); }); } else { - var karmaConf = karmaConfMaker(false, options.browserstack, options.watch, options.file); - - var browserOverride = helpers.parseBrowserArgs(argv); - if (browserOverride.length > 0) { - karmaConf.browsers = browserOverride; - } - - new KarmaServer(karmaConf, newKarmaCallback(done)).start(); + runKarma(options, done) } } } @@ -293,25 +332,24 @@ function runWebdriver({file}) { return execa(wdioCmd, wdioOpts, { stdio: 'inherit' }); } -function newKarmaCallback(done) { - return function (exitCode) { +function runKarma(options, done) { + // the karma server appears to leak memory; starting it multiple times in a row will run out of heap + // here we run it in a separate process to bypass the problem + options = Object.assign({browsers: helpers.parseBrowserArgs(argv)}, options) + const child = fork('./karmaRunner.js'); + child.on('exit', (exitCode) => { if (exitCode) { done(new Error('Karma tests failed with exit code ' + exitCode)); - if (argv.browserstack) { - process.exit(exitCode); - } } else { done(); - if (argv.browserstack) { - process.exit(exitCode); - } } - } + }) + child.send(options); } // If --file "" is given, the task will only run tests in the specified file. function testCoverage(done) { - new KarmaServer(karmaConfMaker(true, false, false, argv.file), newKarmaCallback(done)).start(); + runKarma({coverage: true, browserstack: false, watch: false, file: argv.file}, done); } function coveralls() { // 2nd arg is a dependency: 'test' must be finished @@ -389,11 +427,30 @@ gulp.task(clean); gulp.task(escapePostbidConfig); gulp.task('build-bundle-dev', gulp.series(makeDevpackPkg, gulpBundle.bind(null, true))); -gulp.task('build-bundle-prod', gulp.series(makeWebpackPkg, addBanner, gulpBundle.bind(null, false))); +gulp.task('build-bundle-prod', gulp.series(makeWebpackPkg(), gulpBundle.bind(null, false))); +// build-bundle-verbose - prod bundle except names and comments are preserved. Use this to see the effects +// of dead code elimination. +gulp.task('build-bundle-verbose', gulp.series(makeWebpackPkg({ + optimization: { + minimizer: [ + new TerserPlugin({ + parallel: true, + terserOptions: { + mangle: false, + format: { + comments: 'all' + } + }, + extractComments: false, + }), + ], + } +}), gulpBundle.bind(null, false))); // public tasks (dependencies are needed for each task since they can be ran on their own) gulp.task('test-only', test); -gulp.task('test', gulp.series(clean, lint, 'test-only')); +gulp.task('test-all-features-disabled', testTaskMaker({disableFeatures: require('./features.json'), oneBrowser: 'chrome', watch: false})); +gulp.task('test', gulp.series(clean, lint, gulp.series('test-all-features-disabled', 'test-only'))); gulp.task('test-coverage', gulp.series(clean, testCoverage)); gulp.task(viewCoverage); @@ -405,13 +462,14 @@ gulp.task('build-postbid', gulp.series(escapePostbidConfig, buildPostbid)); gulp.task('serve', gulp.series(clean, lint, gulp.parallel('build-bundle-dev', watch, test))); gulp.task('serve-fast', gulp.series(clean, gulp.parallel('build-bundle-dev', watchFast))); +gulp.task('serve-prod', gulp.series(clean, gulp.parallel('build-bundle-prod', startLocalServer))); gulp.task('serve-and-test', gulp.series(clean, gulp.parallel('build-bundle-dev', watchFast, testTaskMaker({watch: true})))); -gulp.task('serve-e2e', gulp.series(clean, 'build-bundle-prod', gulp.parallel(() => startIntegServer(), startLocalServer))) -gulp.task('serve-e2e-dev', gulp.series(clean, 'build-bundle-dev', gulp.parallel(() => startIntegServer(true), startLocalServer))) +gulp.task('serve-e2e', gulp.series(clean, 'build-bundle-prod', gulp.parallel(() => startIntegServer(), startLocalServer))); +gulp.task('serve-e2e-dev', gulp.series(clean, 'build-bundle-dev', gulp.parallel(() => startIntegServer(true), startLocalServer))); gulp.task('default', gulp.series(clean, 'build-bundle-prod')); -gulp.task('e2e-test-only', () => runWebdriver({file: argv.file})) +gulp.task('e2e-test-only', () => runWebdriver({file: argv.file})); gulp.task('e2e-test', gulp.series(clean, 'build-bundle-prod', testTaskMaker({e2e: true}))); // other tasks gulp.task(bundleToStdout); diff --git a/integrationExamples/gpt/1plusXRtdProviderExample.html b/integrationExamples/gpt/1plusXRtdProviderExample.html new file mode 100644 index 00000000000..b2c7a0037ff --- /dev/null +++ b/integrationExamples/gpt/1plusXRtdProviderExample.html @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + +

1plusX RTD Module for Prebid

+ +
+ +
+ + + diff --git a/integrationExamples/gpt/adUnitFloors.html b/integrationExamples/gpt/adUnitFloors.html index bb48a20ef78..a80e1b2380b 100644 --- a/integrationExamples/gpt/adUnitFloors.html +++ b/integrationExamples/gpt/adUnitFloors.html @@ -109,4 +109,3 @@
Div-1
- diff --git a/integrationExamples/gpt/adloox.html b/integrationExamples/gpt/adloox.html index fd61267479d..78fba71f774 100644 --- a/integrationExamples/gpt/adloox.html +++ b/integrationExamples/gpt/adloox.html @@ -147,8 +147,13 @@ realTimeData: { auctionDelay: AUCTION_DELAY, dataProviders: [ + { + name: 'intersection', + waitForIt: true + }, { name: 'adloox', + waitForIt: true, params: { // optional, defaults shown thresholds: [ 50, 60, 70, 80, 90 ], slotinpath: false diff --git a/integrationExamples/gpt/adnuntius_example.html b/integrationExamples/gpt/adnuntius_example.html new file mode 100644 index 00000000000..b61c4e0674e --- /dev/null +++ b/integrationExamples/gpt/adnuntius_example.html @@ -0,0 +1,95 @@ + + + + + + + +

Adnuntius Prebid Adaptor Test

+
Ad Slot 1
+ + +
+ +
+ + + diff --git a/integrationExamples/gpt/airgridRtdProvider_example.html b/integrationExamples/gpt/airgridRtdProvider_example.html index a8fd989f682..657eae8f481 100644 --- a/integrationExamples/gpt/airgridRtdProvider_example.html +++ b/integrationExamples/gpt/airgridRtdProvider_example.html @@ -108,10 +108,7 @@ var gads = document.createElement("script"); gads.async = true; gads.type = "text/javascript"; - var useSSL = "https:" == document.location.protocol; - gads.src = - (useSSL ? "https:" : "http:") + - "//www.googletagservices.com/tag/js/gpt.js"; + gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName("script")[0]; node.parentNode.insertBefore(gads, node); })(); diff --git a/integrationExamples/gpt/akamaidap_email_example.html b/integrationExamples/gpt/akamaidap_email_example.html deleted file mode 100755 index 828b2add787..00000000000 --- a/integrationExamples/gpt/akamaidap_email_example.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - -

Prebid.js Test

-
Div-1
-
- -
-
User IDs Sent to Bidding Adapter
-
- - diff --git a/integrationExamples/gpt/akamaidap_segments_example.html b/integrationExamples/gpt/akamaidap_segments_example.html index e85ac8e1337..f44c60292ce 100644 --- a/integrationExamples/gpt/akamaidap_segments_example.html +++ b/integrationExamples/gpt/akamaidap_segments_example.html @@ -68,6 +68,7 @@ } }, realTimeData: { + auctionDelay: 2000, dataProviders: [ { name: "dap", @@ -76,9 +77,10 @@ apiHostname: "prebid.dap.akadns.net", apiVersion: "x1", domain: "prebid.org", - identityType: "dap-signature:1.0.0", - segtax: 503, - tokenTtl: 5, + identityType: "dap-signature:1.3.0", + segtax: 504, + dapEntropyUrl: 'https://dap-dist.akamaized.net/dapentropy.js', + dapEntropyTimeout: 1500 } } ] diff --git a/integrationExamples/gpt/akamaidap_signature_example.html b/integrationExamples/gpt/akamaidap_signature_example.html deleted file mode 100644 index e4c7c617653..00000000000 --- a/integrationExamples/gpt/akamaidap_signature_example.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - -

Prebid.js Test

-
Div-1
-
- -
-
User IDs Sent to Bidding Adapter
-
- - diff --git a/integrationExamples/gpt/akamaidap_x1_example.html b/integrationExamples/gpt/akamaidap_x1_example.html deleted file mode 100755 index b1f16acc560..00000000000 --- a/integrationExamples/gpt/akamaidap_x1_example.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - -

Prebid.js Test

-
Div-1
-
- -
-
User IDs Sent to Bidding Adapter
-
- - diff --git a/integrationExamples/gpt/amp/remote.html b/integrationExamples/gpt/amp/remote.html index 785d854766f..4ee2cdcb2f6 100644 --- a/integrationExamples/gpt/amp/remote.html +++ b/integrationExamples/gpt/amp/remote.html @@ -33,7 +33,7 @@ // load Prebid.js (function () { - var d = document, pbs = d.createElement("script"), pro = d.location.protocal; + var d = document, pbs = d.createElement("script"); pbs.type = "text/javascript"; pbs.src = prebidSrc; var target = document.getElementsByTagName("head")[0]; diff --git a/integrationExamples/gpt/blueconicRtdProvider_example.html b/integrationExamples/gpt/blueconicRtdProvider_example.html new file mode 100644 index 00000000000..598a7569d8e --- /dev/null +++ b/integrationExamples/gpt/blueconicRtdProvider_example.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + +

BlueConic RTD Prebid

+ +
+ +
+ + + +BlueConic Real-Time Data: +
+
+ + diff --git a/integrationExamples/gpt/fledge_example.html b/integrationExamples/gpt/fledge_example.html new file mode 100644 index 00000000000..5059e03daef --- /dev/null +++ b/integrationExamples/gpt/fledge_example.html @@ -0,0 +1,103 @@ + + + + + + + + + +

Prebid.js FLEDGE+GPT Example

+ +
Div-1
+
+ +
+ + diff --git a/integrationExamples/gpt/gdpr_hello_world.html b/integrationExamples/gpt/gdpr_hello_world.html index 2d70af8d34f..c62569cfc4f 100644 --- a/integrationExamples/gpt/gdpr_hello_world.html +++ b/integrationExamples/gpt/gdpr_hello_world.html @@ -1,83 +1,19 @@ - - + window._iub = window._iub || {}; + _iub.csConfiguration = { + cookiePolicyId: 417383, + siteId: 1, + logLevel: 'error', + lang: 'en', + enableTcf: true, + }; + + + + + - - - - - - - - - - -

Prebid.js Test

-
Div-1
-
- -
- - diff --git a/integrationExamples/gpt/gpp_us_hello_world.html b/integrationExamples/gpt/gpp_us_hello_world.html new file mode 100644 index 00000000000..28be86127fc --- /dev/null +++ b/integrationExamples/gpt/gpp_us_hello_world.html @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+ +
+ +
+ + + \ No newline at end of file diff --git a/integrationExamples/gpt/gpp_us_hello_world_iframe.html b/integrationExamples/gpt/gpp_us_hello_world_iframe.html new file mode 100644 index 00000000000..c0a62f9d72e --- /dev/null +++ b/integrationExamples/gpt/gpp_us_hello_world_iframe.html @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/integrationExamples/gpt/gpp_us_hello_world_iframe_subpage.html b/integrationExamples/gpt/gpp_us_hello_world_iframe_subpage.html new file mode 100644 index 00000000000..8c2096d614d --- /dev/null +++ b/integrationExamples/gpt/gpp_us_hello_world_iframe_subpage.html @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+ +
+ +
+ + + \ No newline at end of file diff --git a/integrationExamples/gpt/growthcode.html b/integrationExamples/gpt/growthcode.html new file mode 100644 index 00000000000..35de2b710ad --- /dev/null +++ b/integrationExamples/gpt/growthcode.html @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + +

Prebid.js Test

+
Div-1
+
+ +
+ + diff --git a/integrationExamples/gpt/hadronRtdProvider_example.html b/integrationExamples/gpt/hadronRtdProvider_example.html index 065c8379956..f90ce21921c 100644 --- a/integrationExamples/gpt/hadronRtdProvider_example.html +++ b/integrationExamples/gpt/hadronRtdProvider_example.html @@ -88,9 +88,7 @@ var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; - var useSSL = 'https:' == document.location.protocol; - gads.src = (useSSL ? 'https:' : 'http:') + - '//www.googletagservices.com/tag/js/gpt.js'; + gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html old mode 100755 new mode 100644 diff --git a/integrationExamples/gpt/inskin_example.html b/integrationExamples/gpt/inskin_example.html deleted file mode 100644 index 197a5b1ffe1..00000000000 --- a/integrationExamples/gpt/inskin_example.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - -

Prebid.js Test

-
Div-1
-
- -
- - diff --git a/integrationExamples/gpt/lemma_sample.html b/integrationExamples/gpt/lemma_sample.html new file mode 100755 index 00000000000..bdf72eeb484 --- /dev/null +++ b/integrationExamples/gpt/lemma_sample.html @@ -0,0 +1,129 @@ + + + + + + + + + + + + +
+ + +
+ + + \ No newline at end of file diff --git a/integrationExamples/gpt/mgidRtdProvider_example.html b/integrationExamples/gpt/mgidRtdProvider_example.html new file mode 100644 index 00000000000..e3e4f720586 --- /dev/null +++ b/integrationExamples/gpt/mgidRtdProvider_example.html @@ -0,0 +1,143 @@ + + + + + + + + + + +JS Bin + + + +

Basic Prebid.js Example

+
Div-1
+ +
+ +
+ + + diff --git a/integrationExamples/gpt/neuwoRtdProvider_example.html b/integrationExamples/gpt/neuwoRtdProvider_example.html new file mode 100644 index 00000000000..142a7c39613 --- /dev/null +++ b/integrationExamples/gpt/neuwoRtdProvider_example.html @@ -0,0 +1,201 @@ + + + + + + + + + + +

Basic Prebid.js Example using neuwoRtdProvider

+
+ Looks like you're not following the testing environment setup, try accessing http://localhost:9999/integrationExamples/gpt/neuwoRtdProvider_example.html + after running commands in the prebid.js source folder that includes libraries/modules/neuwoRtdProvider.js + + npm ci + npm i -g gulp-cli + gulp serve --modules=rtdModule,neuwoRtdProvider,appnexusBidAdapter + +
+
+

Add token and url to use for Neuwo extension configuration

+ + + + +
+ +
Div-1
+
+ Ad spot div-1: This content will be replaced by prebid.js and/or related components once you click "Update" +
+ +
+ +
Div-2
+
+ Ad spot div-2: Replaces this text as well, if everything goes to plan + + +
+ + + + \ No newline at end of file diff --git a/integrationExamples/gpt/pbjs_video_adUnit.html b/integrationExamples/gpt/pbjs_video_adUnit.html deleted file mode 100644 index 080ca9be142..00000000000 --- a/integrationExamples/gpt/pbjs_video_adUnit.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - Prebid.js video adUnit example - - - - - - - - - - - -
- -
- - - - - diff --git a/integrationExamples/gpt/permutiveRtdProvider_example.html b/integrationExamples/gpt/permutiveRtdProvider_example.html index dbb4d2af0d6..554f2081c6d 100644 --- a/integrationExamples/gpt/permutiveRtdProvider_example.html +++ b/integrationExamples/gpt/permutiveRtdProvider_example.html @@ -15,7 +15,8 @@ _papns: ['appnexus1', 'appnexus2'], _psegs: ['1234', '1000001', '1000002'], _ppam: ['ppam1', 'ppam2'], - _pcrprs: ['pcrprs1', 'pcrprs2'] + _pcrprs: ['pcrprs1', 'pcrprs2'], + _pssps: { ssps: ['appnexus', 'some other'], cohorts: ['abcd', 'efgh', 'ijkl'] }, } for (let key in data) { @@ -23,7 +24,7 @@ } } - setLocalStorageData() + setLocalStorageData(); var div_1_sizes = [ [300, 250], diff --git a/integrationExamples/gpt/prebidServer_example.html b/integrationExamples/gpt/prebidServer_example.html index 37902edd979..f23554369bc 100644 --- a/integrationExamples/gpt/prebidServer_example.html +++ b/integrationExamples/gpt/prebidServer_example.html @@ -12,9 +12,7 @@ var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; - var useSSL = 'https:' == document.location.protocol; - gads.src = (useSSL ? 'https:' : 'http:') + - '//www.googletagservices.com/tag/js/gpt.js'; + gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); diff --git a/integrationExamples/gpt/prebidServer_fledge_example.html b/integrationExamples/gpt/prebidServer_fledge_example.html new file mode 100644 index 00000000000..8523c0f2920 --- /dev/null +++ b/integrationExamples/gpt/prebidServer_fledge_example.html @@ -0,0 +1,111 @@ + + + + + + + + + +

Prebid.js FLEDGE+GPT Example

+ +
Div-1
+
+ +
+ + diff --git a/integrationExamples/gpt/prebidServer_native_example.html b/integrationExamples/gpt/prebidServer_native_example.html index 16c7d38a427..a5fb0ffa894 100644 --- a/integrationExamples/gpt/prebidServer_native_example.html +++ b/integrationExamples/gpt/prebidServer_native_example.html @@ -114,7 +114,7 @@ s2sConfig: { accountId: '1', enabled: true, //default value set to false - bidders: ['appnexus'], + bidders: ['appnexuspsp'], timeout: 1000, //default value is 1000 adapter: 'prebidServer', //if we have any other s2s adapter, default value is s2s endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction' @@ -133,8 +133,8 @@ + + + + + + +

Basic Prebid.js Example

+
Div-1
+
+ +
+ +
Div-2
+
+ +
+ + \ No newline at end of file diff --git a/integrationExamples/gpt/serverbidServer_example.html b/integrationExamples/gpt/serverbidServer_example.html index 3d76e963663..1bd9b39d999 100644 --- a/integrationExamples/gpt/serverbidServer_example.html +++ b/integrationExamples/gpt/serverbidServer_example.html @@ -13,9 +13,7 @@ var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; - var useSSL = 'https:' == document.location.protocol; - gads.src = (useSSL ? 'https:' : 'http:') + - '//www.googletagservices.com/tag/js/gpt.js'; + gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); diff --git a/integrationExamples/gpt/topics_frame.html b/integrationExamples/gpt/topics_frame.html new file mode 100644 index 00000000000..7a12b030a6a --- /dev/null +++ b/integrationExamples/gpt/topics_frame.html @@ -0,0 +1,43 @@ + + + + Topics demo + + + + + + + + + \ No newline at end of file diff --git a/integrationExamples/gpt/userId_example.html b/integrationExamples/gpt/userId_example.html index e11a0b626c9..fdde731247c 100644 --- a/integrationExamples/gpt/userId_example.html +++ b/integrationExamples/gpt/userId_example.html @@ -77,6 +77,7 @@ "301": true, // zeotapIdPlus "91": true, // criteo "737": true, // amxId + "58": true, // 33acrossId } } } @@ -128,6 +129,17 @@ "expires": 30 } }, + { + "name": "33acrossId", + "params": { + "pid": '0' + }, + "storage": { + "type": 'html5', + "name": '33acrossId', + "expires": 90 + } + }, { "name": "intentIqId", "params": { @@ -237,16 +249,33 @@ } }, { - "name": "uid2" - } - ,{ - name: "flocId", - params: { - // Default sharedid.org token : "A3dHTSoNUMjjERBLlrvJSelNnwWUCwVQhZ5tNQ+sll7y+LkPPVZXtB77u2y7CweRIxiYaGwGXNlW1/dFp8VMEgIAAAB+eyJvcmlnaW4iOiJodHRwczovL3NoYXJlZGlkLm9yZzo0NDMiLCJmZWF0dXJlIjoiSW50ZXJlc3RDb2hvcnRBUEkiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9" - // To get new token, register https://developer.chrome.com/origintrials/#/trials/active for Federated Learning of Cohorts - token: "A3dHTSoNUMjjERBLlrvJSelNnwWUCwVQhZ5tNQ+sll7y+LkPPVZXtB77u2y7CweRIxiYaGwGXNlW1/dFp8VMEgIAAAB+eyJvcmlnaW4iOiJodHRwczovL3NoYXJlZGlkLm9yZzo0NDMiLCJmZWF0dXJlIjoiSW50ZXJlc3RDb2hvcnRBUEkiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9" + "name": "uid2", + "params": { + "uid2ApiBase": "https://operator-integ.uidapi.com", // Omit this setting for production + "uid2Token": { + "advertising_token": "advertising token goes here", + "refresh_token": "refresh token goes here", + "identity_expires": Date.now() + 60*1000, // These timestamps should be from the token generate response + "refresh_from": Date.now() - 10*1000, + "refresh_expires": Date.now() + 12*60*60*1000, + "refresh_response_key": "refresh key goes here" } - }, + } + }, + { + "name": "euid", + "params": { + "euidApiBase": "https://integ.euid.eu", // Omit this setting for production + "euidToken": { + "advertising_token": "advertising token goes here", + "refresh_token": "refresh token goes here", + "identity_expires": Date.now() + 60*1000, // These timestamps should be from the token generate response + "refresh_from": Date.now() - 10*1000, + "refresh_expires": Date.now() + 12*60*60*1000, + "refresh_response_key": "refresh key goes here" + } + } + }, { "name": "imuid", "params": { @@ -255,6 +284,9 @@ }, { "name": "dacId" + }, + { + "name": "gravitompId" } ], "syncDelay": 5000, @@ -288,9 +320,7 @@ var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; - var useSSL = 'https:' == document.location.protocol; - gads.src = (useSSL ? 'https:' : 'http:') + - '//www.googletagservices.com/tag/js/gpt.js'; + gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); diff --git a/integrationExamples/gpt/weboramaRtdProvider_example.html b/integrationExamples/gpt/weboramaRtdProvider_example.html index b81ec52b2c4..7e75721103f 100644 --- a/integrationExamples/gpt/weboramaRtdProvider_example.html +++ b/integrationExamples/gpt/weboramaRtdProvider_example.html @@ -1,11 +1,9 @@ - - - - - - - + + + + + weborama rtd submodule example + @@ -26,31 +24,42 @@ params: { setPrebidTargeting: true, // optional sendToBidders: true, // optional - onData: function (data, site) { // optional - var kind = (site) ? 'site' : 'user'; - console.log('onData', kind, data); + onData: function (data, meta) { // optional + console.log('onData', data, meta); }, weboCtxConf: { token: "to-be-defined", // mandatory targetURL: "https://prebid.org", // default is document.URL + assetID: "token:identifier", // new parameter, overrides url setPrebidTargeting: true, // override param.setPrebidTargeting or default true sendToBidders: true, // override param.sendToBidders or default true defaultProfile: { // optional - webo_ctx: ['moon'], + webo_ctx: ["Rugby_Renault_c11495", "Sport_c11893"], webo_ds: ['bar'] }, - //, onData: function (data, ...) { ...} + baseURLProfileAPI: 'ctx-preprod.weborama.com', + // enabled: false, + //, onData: function (data,...) { ...} }, weboUserDataConf: { - accountId: 12345, // optional + enabled: false, + accountId: 12345, // recommended setPrebidTargeting: true, // override param.setPrebidTargeting or default true - sendToBidders: true, // override param.sendToBidders or default true + sendToBidders: ['smartadserver'], // specify the bidder to share data defaultProfile: { // optional - webo_cs: ['Red'], + webo_cs: ['red'], webo_audiences: ['bam'] }, localStorageProfileKey: 'webo_wam2gam_entry', // default + // enabled: false, //, onData: function (data,...) { ...} + }, + sfbxLiteDataConf: { + enabled: false, + defaultProfile: { // optional + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }, } } }] @@ -62,6 +71,9 @@ var div_1_sizes = [ [300, 300] ]; + var div_2_sizes = [ + [600, 100] + ]; var PREBID_TIMEOUT = 3000; var FAILSAFE_TIMEOUT = 5000; @@ -138,7 +150,6 @@ }); } - // in case PBJS doesn't load setTimeout(function () { initAdserver(); @@ -154,11 +165,12 @@

- test webo ctx using prebid.js + test webo rtd submodule with prebid.js

Basic Prebid.js Example

Div-1
+
+ diff --git a/integrationExamples/gpt/x-domain/creative.html b/integrationExamples/gpt/x-domain/creative.html index bea8b70b4fe..2216d0ed6ae 100644 --- a/integrationExamples/gpt/x-domain/creative.html +++ b/integrationExamples/gpt/x-domain/creative.html @@ -1,6 +1,6 @@ - - - - - - - - - - - - -
-

Note: for this example to work, you need access to a bid simulation tool from your MASS enabled Exchange partner.

-
- -
-
- - diff --git a/integrationExamples/noadserver/native_noadserver.html b/integrationExamples/noadserver/native_noadserver.html new file mode 100755 index 00000000000..81c71d2acfd --- /dev/null +++ b/integrationExamples/noadserver/native_noadserver.html @@ -0,0 +1,173 @@ + + + + + + + + + + + + + +

Prebid Native

+
+
+ +
+
+ + + + diff --git a/integrationExamples/postbid/oas/postbid-config.js b/integrationExamples/postbid/oas/postbid-config.js index f251938bc9c..7b574185288 100644 --- a/integrationExamples/postbid/oas/postbid-config.js +++ b/integrationExamples/postbid/oas/postbid-config.js @@ -3,10 +3,10 @@ var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; (function() { - var pbjsEl = document.createElement("script"); pbjsEl.type = "text/javascript"; - pbjsEl.async = true; var isHttps = 'https:' === document.location.protocol; - pbjsEl.src = (isHttps ? "https" : "http") + "://acdn.adnxs.com/prebid/not-for-prod/prebid.js"; - var pbjsTargetEl = document.getElementsByTagName("head")[0]; + var pbjsEl = document.createElement('script'); pbjsEl.type = 'text/javascript'; + pbjsEl.async = true; + pbjsEl.src = 'https://acdn.adnxs.com/prebid/not-for-prod/prebid.js' + var pbjsTargetEl = document.getElementsByTagName('head')[0]; pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild); })(); @@ -51,4 +51,4 @@ pbjs.que.push(function() { }); }); - \ No newline at end of file + diff --git a/integrationExamples/topics/topics-server.js b/integrationExamples/topics/topics-server.js new file mode 100644 index 00000000000..0d248e5557c --- /dev/null +++ b/integrationExamples/topics/topics-server.js @@ -0,0 +1,72 @@ +// This is an example of a server-side endpoint that is utilizing the Topics API header functionality. +// Note: This test endpoint requires the following to run: node.js, npm, express, cors, body-parser + +const bodyParser = require('body-parser'); +const cors = require('cors'); +const express = require('express'); + +const port = process.env.PORT || 3000; + +const app = express(); +app.use(cors()); +app.use( + bodyParser.urlencoded({ + extended: true, + }) +); +app.use(bodyParser.json()); +app.use(express.static('public')); +app.set('port', port); + +const listener = app.listen(port, () => { + const host = + listener.address().address === '::' + ? 'http://localhost' + : 'http://' + listener.address().address; + // eslint-disable-next-line no-console + console.log( + `${__filename} is listening on ${host}:${listener.address().port}\n` + ); +}); + +app.get('*', (req, res) => { + res.setHeader('Observe-Browsing-Topics', '?1'); + + const resData = { + segment: { + domain: req.hostname, + topics: generateTopicArrayFromHeader(req.headers['sec-browsing-topics']), + bidder: req.query['bidder'], + }, + date: Date.now(), + }; + + res.json(resData); +}); + +const generateTopicArrayFromHeader = (topicString) => { + const result = []; + const topicArray = topicString.split(', '); + if (topicArray.length > 1) { + topicArray.pop(); + topicArray.map((topic) => { + const topicId = topic.split(';')[0]; + const versionsString = topic.split(';')[1].split('=')[1]; + const [config, taxonomy, model] = versionsString.split(':'); + const numTopicsWithSameVersions = topicId + .substring(1, topicId.length - 1) + .split(' '); + + numTopicsWithSameVersions.map((tpId) => { + result.push({ + topic: tpId, + version: versionsString, + configVersion: config, + taxonomyVersion: taxonomy, + modelVersion: model, + }); + }); + }); + } + return result; +}; diff --git a/integrationExamples/videoModule/eventsUI/eventsUI.css b/integrationExamples/videoModule/eventsUI/eventsUI.css new file mode 100644 index 00000000000..ccfe17ca4c6 --- /dev/null +++ b/integrationExamples/videoModule/eventsUI/eventsUI.css @@ -0,0 +1,205 @@ +html { + width: 100%; +} +body { + background: #ccc; + margin: 20px 5px; + font: 42px/60px Helvetica, Arial, sans-serif; + min-width: 320px; + max-width: 1920px; +} +#player:first-child { + width: 100%; +} + +#player { + margin: auto; + background: rgba(0, 0, 20, 0.8); +} +#eventsLog.group-player-disabled .group-player, +#eventsLog.group-media-disabled .group-media, +#eventsLog.group-ads-disabled .group-ads, +#eventsLog.group-auction-disabled .group-auction, +#eventsLog.group-adRequest-disabled .group-adRequest, +#eventsLog.group-adBreak-disabled .group-adBreak, +#eventsLog.group-related-disabled .group-related, +#eventsLog.group-ping-disabled .group-ping, +#eventsLog.group-unknown-disabled .group-unknown, +#eventsLog.group-quickPeek-disabled .group-quickPeek, +#eventsLog.group-provider-disabled .group-provider, +#eventsLog.group-video-disabled .group-video { + display: none; +} +.input-field { + padding: 0 0.25em; + margin: 0 0 0 4px; + border: 0; + background-color: #232323; + color: #F8F8F8; +} +.input-field:invalid { + text-decoration: underline; + text-decoration-color: red; +} +#eventsLog .sequence > .pre.filter-not-matched { + display: none; + opacity: 0.2; +} +a.button { + -webkit-appearance: button; + cursor: pointer; + margin: 2px; + background: #ccc; + border-color: rgb(216, 216, 216) rgb(209, 209, 209) rgb(186, 186, 186); + border-style: solid; + border-width: 1px; + padding: 1px 7px 2px; + color: inherit; + text-decoration: inherit; + user-select: none; +} +.right { + float: right; +} +.disabled { + opacity: 0.5; +} +.nav.disabled { + user-select: none; + cursor: default; +} +.block { + margin: 5px; + background-color: #eee; +} +div.mode-player { + background: #acc; +} +div.mode-ads { + background: #fea; +} +div.sequence { + display: block; +} +.group-player { + background: #acc; +} +.group-media { + background: #fa6; +} +.group-ads { + background: #fcc; +} +.group-auction { + background: #228; + color: #eee; +} +pre { + margin: 0; +} +div.toggle-block pre { + margin: 1px 3px; +} +.events-block { + min-height: 1440px; +} +.events-block .pre, +.toggle-block pre { + display: inline-block; + padding: 0 5px; + margin: 1px 3px 1px 20px; + border-radius: 5px; + font-family: monospace; + white-space: pre; +} +.pre.group-ads, +.pre.group-media, +.pre.group-player, +.pre.group-auction, +.pre.event-ready { + display: inline-block; + padding: 0 5px; + margin: 1px 3px 1px 20px; + border-radius: 5px; + font-family: monospace; + white-space: pre; +} + +.list-events.events-block .pre.group-player, +.list-events.events-block .pre.group-media, +.list-events.events-block .pre.group-ads, +.list-events.events-block .pre.group-auction { + display: block; + margin: 0; + padding: 1px 10px; + border-radius: 0; +} + +.pre.event-playlistItem { + margin: 1px 3px 1px 10px; +} +.pre.event-adBreakStart, +.pre.event-adBreakEnd { + margin: 1px 3px 1px 20px; +} +.pre.event-adBreakStart, +.pre.event-ready, +.pre.event-adImpression, +.pre.event-adError, +.pre.event-adWarning { + font-weight: 800; +} +.pre pre { + display: inline; + margin: 0 0 0 20px; +} +.toggle { + cursor: pointer; + user-select: none; +} +button, +input, +optgroup, +select, +textarea { + color: inherit; + font: inherit; +} +button { + overflow: visible; + padding: 1px 7px 2px; +} +button, +select { + text-transform: none; +} +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; + cursor: pointer; + margin: 2px; +} +button[disabled], +html input[disabled] { + cursor: default; +} +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} +label { + display: inline-block; + max-width: 100%; + margin-bottom: 5px; + font-weight: bold; +} + +@media only screen and (min-device-width : 320px) and (max-device-width : 768px) { + body { + font-size: 2vw; + line-height: 3vw; + } +} diff --git a/integrationExamples/videoModule/eventsUI/eventsUI.js b/integrationExamples/videoModule/eventsUI/eventsUI.js new file mode 100644 index 00000000000..618a4774765 --- /dev/null +++ b/integrationExamples/videoModule/eventsUI/eventsUI.js @@ -0,0 +1,181 @@ +"use strict"; + +let sequenceCount = 0; +const eventLogGroups = {}; +const Uint8Array = window.Uint8Array; +const TimeRanges = window.TimeRanges; + +function stringify(value, replacer, space) { + try { + return truncate(JSON.stringify(value, replacer || stringifyReplacer(value), space), 100000); + } catch (error) { + return `[${error}]`; + } +} + +function truncate(str, length) { + return (str && str.length) > length ? (str.substr(0, length) + + '\n... Event truncated due to length (see console for complete output)') : str; +} + +function stringifyReplacer(parentValue) { + const references = []; + const safeResults = []; + let complexity = 0; + return function stringifyKeyValue(key, value) { + if (typeof value === 'object') { + if (value === null || value instanceof Date || value instanceof RegExp) { + return value; + } + if (!!Uint8Array && value instanceof Uint8Array) { + // Stub values of Arrays with more than 1000 items + let str = ('' + value); + str = (str.length > 40 ? (str.substr(0, 40) + '...(see console)') : str); + return `Uint8Array(${value.length}) [${str}]`; + } + if (!!TimeRanges && value instanceof TimeRanges) { + const ranges = []; + for (let i = 0; i < value.length; i++) { + ranges[i] = `start(${i}) = ${value.start(i)} end(${i}) = ${value.end(i)}`; + } + return `TimeRanges(${value.length}) [${ranges}]`; + } + if (value === parentValue && complexity > 0) { + return ''; + } + const referenceIndex = references.indexOf(value); + if (referenceIndex !== -1) { + // Duplicate reference found + const safe = safeResults[referenceIndex]; + if (safe) { + return safe; + } + try { + // Test for circular references + JSON.stringify(value); + } catch (error) { + return (safeResults[referenceIndex] = '<' + value + '...(see console)>'); + } + safeResults[referenceIndex] = value; + } + if (complexity++ > 10000) { + return ''; + } + references.push(value); + return value; + } + if (typeof value === 'function') { + return `${value}`; + } + return value; + }; +} + +function createEventSequenceElement(eventGroup) { + const element = document.createElement('div'); + element.classList.add('sequence', `mode-${eventGroup}`); + element.setAttribute('data-sequence', `${sequenceCount++}`); + return element; +} + +function appendSequenceElement(container, element) { + container.appendChild(element); +} + +function textContentGrouped(inEvent, group) { + if (group) { + return `${inEvent} (${group[inEvent]})`; + } + return inEvent; +} + +function appendEvent(container, currentEventType, currentEventGroup, data) { + const div = document.createElement('div'); + div.classList.add('group-' + currentEventGroup, 'event-' + currentEventType, 'pre'); + div.textContent = textContentGrouped(currentEventType); + div.setAttribute('title', `${currentEventGroup} event "${currentEventType}"`); + div.setAttribute('tabindex', '0'); + const theData = Object.assign({}, data); + div.onclick = div.onkeyup = function(e) { + if (e && e.keyCode && e.keyCode !== 13) { + return; + } + + console.log(theData); + div.textContent = ((div.expanded = !div.expanded)) ? + textContentExpanded(currentEventType, [theData]) : textContentGrouped(currentEventType); + if (e) { + e.preventDefault(); + } + return [theData]; + }; + container.appendChild(div); + return div; +} + +function textContentExpanded(inEvent, allData) { + return `${inEvent} (${allData.map((item, i) => + (allData.length > 1 ? `[${i}] = ` : '') + stringify(item, null, 4)).join('\n')})`; +} + +function incrementEvent(group, currentEventType, currentEventGroup, div, datum) { + group[currentEventType]++; + div.textContent = textContentGrouped(currentEventType, group); + const logPreviousEvents = div.onclick; + const scopedDatum = Object.assign({}, datum); + div.onclick = div.onkeyup = function(e) { + if (e && e.keyCode && e.keyCode !== 13) { + return; + } + + const allData = logPreviousEvents(); + allData.push(scopedDatum); + console.log(scopedDatum); + div.textContent = (div.expanded) ? textContentExpanded(currentEventType, allData) : textContentGrouped(currentEventType, group); + if (e) { + e.preventDefault(); + } + return allData; + }; +} + +function getGenericEventHandler() { + const logContainer = document.querySelector('#eventsLog'); + let currentEventGroup = ''; + let currentEventType = ''; + let lastEvent = ''; + let lastGroup; + const genericEventHandler = function(e, type, eventGroup) { + currentEventGroup = eventGroup; + currentEventType = type; + + let group = eventLogGroups[eventGroup]; + if (!group || group !== lastGroup) { + const beforeReadyElement = createEventSequenceElement(currentEventGroup); + appendSequenceElement(logContainer, beforeReadyElement); + group = eventLogGroups[currentEventGroup] = { + eventGroup: currentEventGroup, + event: currentEventType, + container: logContainer, + eventElement: beforeReadyElement + }; + lastGroup = lastGroup || group; + } + if (lastEvent === currentEventType && !(/^(?:meta|hlsBufferAppend)/).test(currentEventType)) { + incrementEvent(group, currentEventType, currentEventGroup, group.pre, e); + } else { + const eventElement = createEventSequenceElement(currentEventGroup); + group[currentEventType] = 1; + group.eventElement = eventElement; + group.lastEventGroup = currentEventGroup; + group.pre = appendEvent(eventElement, currentEventType, currentEventGroup, e); + appendSequenceElement(group.container, eventElement); + } + lastEvent = currentEventType; + lastGroup = group; + }; + + return genericEventHandler; +} + +window.getGenericEventHandler = getGenericEventHandler; diff --git a/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html b/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html new file mode 100644 index 00000000000..80ea81d09b6 --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/bidMarkedAsUsed.html @@ -0,0 +1,96 @@ + + + + + + + JW Player with Bid Marked As Used + + + + + + + +
+ + + diff --git a/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html b/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html new file mode 100644 index 00000000000..663765317b0 --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/bidRequestScheduling.html @@ -0,0 +1,89 @@ + + + + + + + JW Player with Bid Request Scheduling + + + + + + + +

JW Player with Bid Request Scheduling

+
Div-1: Player placeholder div
+
+ + + diff --git a/integrationExamples/videoModule/jwplayer/bidsBackHandlerOverride.html b/integrationExamples/videoModule/jwplayer/bidsBackHandlerOverride.html new file mode 100644 index 00000000000..66eaff26090 --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/bidsBackHandlerOverride.html @@ -0,0 +1,137 @@ + + + + + + + JW Player with Bids Back Handler override + + + + + +

JW Player with Bids Back Handler override

+
Div-1: Player placeholder div
+
+ + + diff --git a/integrationExamples/videoModule/jwplayer/eventListeners.html b/integrationExamples/videoModule/jwplayer/eventListeners.html new file mode 100644 index 00000000000..39acb086107 --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/eventListeners.html @@ -0,0 +1,249 @@ +- + + + + + + + + + + + +
+ + + diff --git a/integrationExamples/videoModule/jwplayer/eventsUI.html b/integrationExamples/videoModule/jwplayer/eventsUI.html new file mode 100644 index 00000000000..78d72a6153d --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/eventsUI.html @@ -0,0 +1,295 @@ + + + + + + + + + JW Player Event UI + + + + + + + +
+
+
+ +
+ + + + diff --git a/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html b/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html new file mode 100644 index 00000000000..018c8eba8b2 --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/gamAdServerMediation.html @@ -0,0 +1,120 @@ + + + + + + + JW Player with GAM Ad Server Mediation + + + + + + + +

JW Player with GAM Ad Server Mediation

+
Player placeholder div
+
+ + + diff --git a/integrationExamples/videoModule/jwplayer/mediaMetadata.html b/integrationExamples/videoModule/jwplayer/mediaMetadata.html new file mode 100644 index 00000000000..7581af571d3 --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/mediaMetadata.html @@ -0,0 +1,81 @@ + + + + + + + JW Player with Media Metadata + + + + + + + + +

JW Player with Media Metadata

+ +
+ + + diff --git a/integrationExamples/videoModule/jwplayer/playlist.html b/integrationExamples/videoModule/jwplayer/playlist.html new file mode 100644 index 00000000000..89efaea3d5c --- /dev/null +++ b/integrationExamples/videoModule/jwplayer/playlist.html @@ -0,0 +1,123 @@ + + + + + + + JW Player with Playlist + + + + + + + + +

JW Player with Playlist

+ +
Div-1: Player placeholder div
+
+ + + diff --git a/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html b/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html new file mode 100644 index 00000000000..d6656bc0c93 --- /dev/null +++ b/integrationExamples/videoModule/videojs/bidMarkedAsUsed.html @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + VideoJS with Bid Marked As Used + + + + + + + +

VideoJS with Bid Marked As Used

+
Div-1: Player placeholder div
+ + + + diff --git a/integrationExamples/videoModule/videojs/bidRequestScheduling.html b/integrationExamples/videoModule/videojs/bidRequestScheduling.html new file mode 100644 index 00000000000..eb10fda89a2 --- /dev/null +++ b/integrationExamples/videoModule/videojs/bidRequestScheduling.html @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + VideoJS with Bid Request Scheduling + + + + + + + +

VideoJS with Bid Request Scheduling

+
Div-1: Player placeholder div
+ + + + diff --git a/integrationExamples/videoModule/videojs/bidsBackHandlerOverride.html b/integrationExamples/videoModule/videojs/bidsBackHandlerOverride.html new file mode 100644 index 00000000000..ac8f4163e76 --- /dev/null +++ b/integrationExamples/videoModule/videojs/bidsBackHandlerOverride.html @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + VideoJS with Bids Back Handler override + + + + + +

VideoJS with Bids Back Handler override

+
Div-1: Player placeholder div
+ + + + + + diff --git a/integrationExamples/videoModule/videojs/eventListeners.html b/integrationExamples/videoModule/videojs/eventListeners.html new file mode 100644 index 00000000000..1966f134e02 --- /dev/null +++ b/integrationExamples/videoModule/videojs/eventListeners.html @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + VideoJS Event Listeners + + + + + + + + +

VideoJS Event Listeners

+ +
Div-1: Player placeholder div
+ + + + + diff --git a/integrationExamples/videoModule/videojs/eventsUI.html b/integrationExamples/videoModule/videojs/eventsUI.html new file mode 100644 index 00000000000..9eba09f7a52 --- /dev/null +++ b/integrationExamples/videoModule/videojs/eventsUI.html @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + Video.JS Event UI + + + + + + + +
+ + +
+ +
+ + + + diff --git a/integrationExamples/videoModule/videojs/gamAdServerMediation.html b/integrationExamples/videoModule/videojs/gamAdServerMediation.html new file mode 100644 index 00000000000..6ffc1a67c03 --- /dev/null +++ b/integrationExamples/videoModule/videojs/gamAdServerMediation.html @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + VideoJS with GAM Ad Server Mediation + + + + + + + +

VideoJS with GAM Ad Server Mediation

+
Div-1: Player placeholder div
+ + + + diff --git a/integrationExamples/videoModule/videojs/mediaMetadata.html b/integrationExamples/videoModule/videojs/mediaMetadata.html new file mode 100644 index 00000000000..ede076fd814 --- /dev/null +++ b/integrationExamples/videoModule/videojs/mediaMetadata.html @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + VideoJS with Media Metadata + + + + + + + + +

VideoJS with Media Metadata

+ +
Div-1: Player placeholder div
+ + + + diff --git a/integrationExamples/videoModule/videojs/playlist.html b/integrationExamples/videoModule/videojs/playlist.html new file mode 100644 index 00000000000..eb813f095f7 --- /dev/null +++ b/integrationExamples/videoModule/videojs/playlist.html @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + VideoJS with Playlist + + + + + + + + +

VideoJS with Playlist

+ +
Div-1: Player placeholder div
+ + + + + diff --git a/karma.conf.maker.js b/karma.conf.maker.js index b5c6b44e4fd..e05d5b08afd 100644 --- a/karma.conf.maker.js +++ b/karma.conf.maker.js @@ -7,7 +7,7 @@ var _ = require('lodash'); var webpackConf = require('./webpack.conf.js'); var karmaConstants = require('karma').constants; -function newWebpackConfig(codeCoverage) { +function newWebpackConfig(codeCoverage, disableFeatures) { // Make a clone here because we plan on mutating this object, and don't want parallel tasks to trample each other. var webpackConfig = _.cloneDeep(webpackConf); @@ -22,20 +22,9 @@ function newWebpackConfig(codeCoverage) { .flatMap((r) => r.use) .filter((use) => use.loader === 'babel-loader') .forEach((use) => { - use.options = babelConfig(true); + use.options = babelConfig({test: true, codeCoverage, disableFeatures}); }); - if (codeCoverage) { - webpackConfig.module.rules.push({ - enforce: 'post', - exclude: /(node_modules)|(test)|(integrationExamples)|(build)|polyfill.js|(src\/adapters\/analytics\/ga.js)/, - use: { - loader: '@jsdevtools/coverage-istanbul-loader', - options: { esModules: true } - }, - test: /\.js$/ - }) - } return webpackConfig; } @@ -117,11 +106,11 @@ function setBrowsers(karmaConf, browserstack) { } } -module.exports = function(codeCoverage, browserstack, watchMode, file) { - var webpackConfig = newWebpackConfig(codeCoverage); +module.exports = function(codeCoverage, browserstack, watchMode, file, disableFeatures) { + var webpackConfig = newWebpackConfig(codeCoverage, disableFeatures); var plugins = newPluginsArray(browserstack); - var files = file ? ['test/test_deps.js', file] : ['test/test_index.js']; + var files = file ? ['test/test_deps.js', file, 'test/helpers/hookSetup.js'].flatMap(f => f) : ['test/test_index.js']; // This file opens the /debug.html tab automatically. // It has no real value unless you're running --watch, and intend to do some debugging in the browser. if (watchMode) { @@ -164,6 +153,12 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) { reporters: ['mocha'], + client: { + mocha: { + timeout: 3000 + } + }, + mochaReporter: { showDiff: true, output: 'minimal' @@ -176,10 +171,10 @@ module.exports = function(codeCoverage, browserstack, watchMode, file) { browserNoActivityTimeout: 3e5, // default 10000 captureTimeout: 3e5, // default 60000, browserDisconnectTolerance: 3, - concurrency: 6, + concurrency: 5, // browserstack allows us 5 concurrent sessions plugins: plugins - } + }; // To ensure that, we are able to run single spec file // here we are adding preprocessors, when file is passed diff --git a/karmaRunner.js b/karmaRunner.js new file mode 100644 index 00000000000..96259069966 --- /dev/null +++ b/karmaRunner.js @@ -0,0 +1,23 @@ +const karma = require('karma'); +const process = require('process'); +const karmaConfMaker = require('./karma.conf.maker.js'); + +process.on('message', function(options) { + try { + let cfg = karmaConfMaker(options.coverage, options.browserstack, options.watch, options.file, options.disableFeatures); + if (options.browsers && options.browsers.length) { + cfg.browsers = options.browsers; + } + if (options.oneBrowser) { + cfg.browsers = [cfg.browsers.find((b) => b.toLowerCase().includes(options.oneBrowser.toLowerCase())) || cfg.browsers[0]] + } + cfg = karma.config.parseConfig(null, cfg); + new karma.Server(cfg, (exitCode) => { + process.exit(exitCode); + }).start(); + } catch (e) { + // eslint-disable-next-line + console.error(e); + process.exit(1); + } +}); diff --git a/libraries/LIBRARIES.md b/libraries/LIBRARIES.md new file mode 100644 index 00000000000..e4d8fcc4f98 --- /dev/null +++ b/libraries/LIBRARIES.md @@ -0,0 +1,5 @@ +## Cross-module libraries + +Each directory under this one is packaged into a "library" during the build. + +Modules may share code by simply importing from a common library file; if the module is included in the build, any libraries they import from will also be included. diff --git a/libraries/analyticsAdapter/AnalyticsAdapter.js b/libraries/analyticsAdapter/AnalyticsAdapter.js new file mode 100644 index 00000000000..e1933d215e4 --- /dev/null +++ b/libraries/analyticsAdapter/AnalyticsAdapter.js @@ -0,0 +1,161 @@ +import CONSTANTS from '../../src/constants.json'; +import {ajax} from '../../src/ajax.js'; +import {logError, logMessage} from '../../src/utils.js'; +import * as events from '../../src/events.js'; + +export const _internal = { + ajax +}; +const ENDPOINT = 'endpoint'; +const BUNDLE = 'bundle'; + +export const DEFAULT_INCLUDE_EVENTS = Object.values(CONSTANTS.EVENTS) + .filter(ev => ev !== CONSTANTS.EVENTS.AUCTION_DEBUG); + +let debounceDelay = 100; + +export function setDebounceDelay(delay) { + debounceDelay = delay; +} + +export default function AnalyticsAdapter({ url, analyticsType, global, handler }) { + const queue = []; + let handlers; + let enabled = false; + let sampled = true; + let provider; + + const emptyQueue = (() => { + let running = false; + let timer; + const clearQueue = () => { + if (!running) { + running = true; // needed to avoid recursive re-processing when analytics event handlers trigger other events + try { + let i = 0; + let notDecreasing = 0; + while (queue.length > 0) { + i++; + const len = queue.length; + queue.shift()(); + if (queue.length >= len) { + notDecreasing++; + } else { + notDecreasing = 0 + } + if (notDecreasing >= 10) { + logError('Detected probable infinite loop, discarding events', queue) + queue.length = 0; + return; + } + } + logMessage(`${provider} analytics: processed ${i} events`); + } finally { + running = false; + } + } + }; + return function () { + if (timer != null) { + clearTimeout(timer); + timer = null; + } + debounceDelay === 0 ? clearQueue() : timer = setTimeout(clearQueue, debounceDelay); + } + })(); + + return Object.defineProperties({ + track: _track, + enqueue: _enqueue, + enableAnalytics: _enable, + disableAnalytics: _disable, + getAdapterType: () => analyticsType, + getGlobal: () => global, + getHandler: () => handler, + getUrl: () => url + }, { + enabled: { + get: () => enabled + } + }); + + function _track({ eventType, args }) { + if (this.getAdapterType() === BUNDLE) { + window[global](handler, eventType, args); + } + + if (this.getAdapterType() === ENDPOINT) { + _callEndpoint(...arguments); + } + } + + function _callEndpoint({ eventType, args, callback }) { + _internal.ajax(url, callback, JSON.stringify({ eventType, args })); + } + + function _enqueue({eventType, args}) { + queue.push(() => { + this.track({eventType, args}); + }); + emptyQueue(); + } + + function _enable(config) { + provider = config?.provider; + var _this = this; + + if (typeof config === 'object' && typeof config.options === 'object') { + sampled = typeof config.options.sampling === 'undefined' || Math.random() < parseFloat(config.options.sampling); + } else { + sampled = true; + } + + if (sampled) { + const trackedEvents = (() => { + const {includeEvents = DEFAULT_INCLUDE_EVENTS, excludeEvents = []} = (config || {}); + return new Set( + Object.values(CONSTANTS.EVENTS) + .filter(ev => includeEvents.includes(ev)) + .filter(ev => !excludeEvents.includes(ev)) + ); + })(); + + // first send all events fired before enableAnalytics called + events.getEvents().forEach(event => { + if (!event || !trackedEvents.has(event.eventType)) { + return; + } + + const { eventType, args } = event; + _enqueue.call(_this, { eventType, args }); + }); + + // Next register event listeners to send data immediately + handlers = Object.fromEntries( + Array.from(trackedEvents) + .map((ev) => { + const handler = (args) => this.enqueue({eventType: ev, args}); + events.on(ev, handler); + return [ev, handler]; + }) + ) + } else { + logMessage(`Analytics adapter for "${global}" disabled by sampling`); + } + + // finally set this function to return log message, prevents multiple adapter listeners + this._oldEnable = this.enableAnalytics; + this.enableAnalytics = function _enable() { + return logMessage(`Analytics adapter for "${global}" already enabled, unnecessary call to \`enableAnalytics\`.`); + }; + enabled = true; + } + + function _disable() { + Object.entries(handlers || {}).forEach(([event, handler]) => { + events.off(event, handler); + }) + this.enableAnalytics = this._oldEnable ? this._oldEnable : _enable; + enabled = false; + } +} diff --git a/src/adapters/analytics/example.js b/libraries/analyticsAdapter/examples/example.js similarity index 85% rename from src/adapters/analytics/example.js rename to libraries/analyticsAdapter/examples/example.js index 1321612b688..c6907907b23 100644 --- a/src/adapters/analytics/example.js +++ b/libraries/analyticsAdapter/examples/example.js @@ -2,7 +2,7 @@ * example.js - analytics adapter for Example Analytics Library example */ -import adapter from '../../AnalyticsAdapter.js'; +import adapter from '../AnalyticsAdapter.js'; export default adapter( { diff --git a/src/adapters/analytics/example2.js b/libraries/analyticsAdapter/examples/example2.js similarity index 92% rename from src/adapters/analytics/example2.js rename to libraries/analyticsAdapter/examples/example2.js index eadf994ce36..d95a3f54283 100644 --- a/src/adapters/analytics/example2.js +++ b/libraries/analyticsAdapter/examples/example2.js @@ -5,7 +5,7 @@ import { ajax } from '../../../src/ajax.js'; * example2.js - analytics adapter for Example2 Analytics Endpoint example */ -import adapter from '../../AnalyticsAdapter.js'; +import adapter from '../AnalyticsAdapter.js'; const url = 'https://httpbin.org/post'; const analyticsType = 'endpoint'; diff --git a/src/adapters/analytics/libraries/example.js b/libraries/analyticsAdapter/examples/libraries/example.js similarity index 95% rename from src/adapters/analytics/libraries/example.js rename to libraries/analyticsAdapter/examples/libraries/example.js index 0d758fd5513..f2bfd612193 100644 --- a/src/adapters/analytics/libraries/example.js +++ b/libraries/analyticsAdapter/examples/libraries/example.js @@ -31,8 +31,8 @@ events.init(); // overwrite example object and handle 'on' callbacks window[window.ExampleAnalyticsGlobalObject] = example = utils.errorless(function() { if (arguments[0] && arguments[0] === 'on') { - var eventName = arguments[1] && arguments[1]; - var args = arguments[2] && arguments[2]; + var eventName = arguments[1]; + var args = arguments[2]; if (eventName && args) { if (eventName === 'bidAdjustment') { pbjsHandlers.onBidAdjustment.apply(this, [args]); diff --git a/src/adapters/analytics/libraries/example2.js b/libraries/analyticsAdapter/examples/libraries/example2.js similarity index 95% rename from src/adapters/analytics/libraries/example2.js rename to libraries/analyticsAdapter/examples/libraries/example2.js index 68e814b1417..9a7106a48e0 100644 --- a/src/adapters/analytics/libraries/example2.js +++ b/libraries/analyticsAdapter/examples/libraries/example2.js @@ -31,8 +31,8 @@ events.init(); // overwrite example object and handle 'on' callbacks window[window.ExampleAnalyticsGlobalObject2] = example = utils.errorless(function() { if (arguments[0] && arguments[0] === 'on') { - var eventName = arguments[1] && arguments[1]; - var args = arguments[2] && arguments[2]; + var eventName = arguments[1]; + var args = arguments[2]; if (eventName && args) { if (eventName === 'bidAdjustment') { pbjsHandlers.onBidAdjustment.apply(this, [args]); diff --git a/libraries/appnexusUtils/anKeywords.js b/libraries/appnexusUtils/anKeywords.js new file mode 100644 index 00000000000..d6714dacc21 --- /dev/null +++ b/libraries/appnexusUtils/anKeywords.js @@ -0,0 +1,153 @@ +import {_each, deepAccess, isArray, isNumber, isStr, mergeDeep, logWarn} from '../../src/utils.js'; +import {getAllOrtbKeywords} from '../keywords/keywords.js'; +import {CLIENT_SECTIONS} from '../../src/fpd/oneClient.js'; + +const ORTB_SEGTAX_KEY_MAP = { + 526: '1plusX', + 527: '1plusX', + 541: 'captify_segments', + 540: 'perid' +}; +const ORTB_SEG_PATHS = ['user.data'].concat( + CLIENT_SECTIONS.map((prefix) => `${prefix}.content.data`) +); + +function getValueString(param, val, defaultValue) { + if (val === undefined || val === null) { + return defaultValue; + } + if (isStr(val)) { + return val; + } + if (isNumber(val)) { + return val.toString(); + } + logWarn('Unsuported type for param: ' + param + ' required type: String'); +} + +/** + * Converts an object of arrays (either strings or numbers) into an array of objects containing key and value properties + * normally read from bidder params + * eg { foo: ['bar', 'baz'], fizz: ['buzz'] } + * becomes [{ key: 'foo', value: ['bar', 'baz']}, {key: 'fizz', value: ['buzz']}] + * @param {Object} keywords object of arrays representing keyvalue pairs + * @param {string} paramName name of parent object (eg 'keywords') containing keyword data, used in error handling + * @returns {Array<{key, value}>} + */ +export function transformBidderParamKeywords(keywords, paramName = 'keywords') { + const arrs = []; + + _each(keywords, (v, k) => { + if (isArray(v)) { + let values = []; + _each(v, (val) => { + val = getValueString(paramName + '.' + k, val); + if (val || val === '') { + values.push(val); + } + }); + v = values; + } else { + v = getValueString(paramName + '.' + k, v); + if (isStr(v)) { + v = [v]; + } else { + return; + } // unsuported types - don't send a key + } + v = v.filter(kw => kw !== '') + const entry = {key: k} + if (v.length > 0) { + entry.value = v; + } + arrs.push(entry); + }); + + return arrs; +} + +// converts a comma separated list of keywords into the standard keyword object format used in appnexus bid params +// 'genre=rock,genre=pop,pets=dog,music' goes to { 'genre': ['rock', 'pop'], 'pets': ['dog'], 'music': [''] } +export function convertKeywordStringToANMap(keyStr) { + if (isStr(keyStr) && keyStr !== '') { + // will split based on commas and will eat white space before/after the comma + return convertKeywordsToANMap(keyStr.split(/\s*(?:,)\s*/)); + } else { + return {} + } +} + +/** + * @param {Array} kwarray: keywords as an array of strings + * @return {{}} appnexus-style keyword map + */ +function convertKeywordsToANMap(kwarray) { + const result = {}; + kwarray.forEach(kw => { + // if = exists, then split + if (kw.indexOf('=') !== -1) { + let kwPair = kw.split('='); + let key = kwPair[0]; + let val = kwPair[1]; + + // then check for existing key in result > if so add value to the array > if not, add new key and create value array + if (result.hasOwnProperty(key)) { + result[key].push(val); + } else { + result[key] = [val]; + } + } else { + if (!result.hasOwnProperty(kw)) { + result[kw] = []; + } + } + }) + return result; +} + +/** + * @param ortb2 + * @return {{}} appnexus-style keyword map using all keywords contained in ortb2 + */ +export function getANMapFromOrtbKeywords(ortb2) { + return convertKeywordsToANMap(getAllOrtbKeywords(ortb2)); +} + +export function getANKewyordParamFromMaps(...anKeywordMaps) { + return transformBidderParamKeywords( + mergeDeep(...anKeywordMaps.map(kwMap => Object.fromEntries( + Object.entries(kwMap || {}) + .map(([k, v]) => [k, (isNumber(v) || isStr(v)) ? [v] : v]) + ))) + ) +} + +export function getANKeywordParam(ortb2, ...anKeywordsMaps) { + return getANKewyordParamFromMaps( + getANMapFromOrtbKeywords(ortb2), + getANMapFromOrtbSegments(ortb2), + ...anKeywordsMaps + ) +} + +export function getANMapFromOrtbSegments(ortb2) { + let ortbSegData = {}; + ORTB_SEG_PATHS.forEach(path => { + let ortbSegsArrObj = deepAccess(ortb2, path) || []; + ortbSegsArrObj.forEach(segObj => { + // only read segment data from known sources + const segtax = ORTB_SEGTAX_KEY_MAP[deepAccess(segObj, 'ext.segtax')]; + if (segtax) { + segObj.segment.forEach(seg => { + // if source was in multiple locations of ortb or had multiple segments in same area, stack them together into an array + if (ortbSegData[segtax]) { + ortbSegData[segtax].push(seg.id); + } else { + ortbSegData[segtax] = [seg.id] + } + }); + } + }); + }); + return ortbSegData; +} diff --git a/libraries/appnexusUtils/anUtils.js b/libraries/appnexusUtils/anUtils.js new file mode 100644 index 00000000000..9b55cd5c2a4 --- /dev/null +++ b/libraries/appnexusUtils/anUtils.js @@ -0,0 +1,25 @@ +/** + * Converts a string value in camel-case to underscore eg 'placementId' becomes 'placement_id' + * @param {string} value string value to convert + */ +import {deepClone, isPlainObject} from '../../src/utils.js'; + +export function convertCamelToUnderscore(value) { + return value.replace(/(?:^|\.?)([A-Z])/g, function (x, y) { + return '_' + y.toLowerCase(); + }).replace(/^_/, ''); +} + +/** + * Creates an array of n length and fills each item with the given value + */ +export function fill(value, length) { + let newArray = []; + + for (let i = 0; i < length; i++) { + let valueToPush = isPlainObject(value) ? deepClone(value) : value; + newArray.push(valueToPush); + } + + return newArray; +} diff --git a/libraries/categoryTranslationMapping/index.js b/libraries/categoryTranslationMapping/index.js new file mode 100644 index 00000000000..13b10423450 --- /dev/null +++ b/libraries/categoryTranslationMapping/index.js @@ -0,0 +1,100 @@ +/** + * Provides mapping objects used by bidders for categoryTranslation type logic for Adpod feature + */ +export const APPNEXUS_CATEGORY_MAPPING = { + '1': 'IAB20-3', + '2': 'IAB18-5', + '3': 'IAB10-1', + '4': 'IAB2-3', + '5': 'IAB19-8', + '6': 'IAB22-1', + '7': 'IAB18-1', + '8': 'IAB12-3', + '9': 'IAB5-1', + '10': 'IAB4-5', + '11': 'IAB13-4', + '12': 'IAB8-7', + '13': 'IAB9-7', + '14': 'IAB7-1', + '15': 'IAB20-18', + '16': 'IAB10-7', + '17': 'IAB19-18', + '18': 'IAB13-6', + '19': 'IAB18-4', + '20': 'IAB1-5', + '21': 'IAB1-6', + '22': 'IAB3-4', + '23': 'IAB19-13', + '24': 'IAB22-2', + '25': 'IAB3-9', + '26': 'IAB17-18', + '27': 'IAB19-6', + '28': 'IAB1-7', + '29': 'IAB9-30', + '30': 'IAB20-7', + '31': 'IAB20-17', + '32': 'IAB7-32', + '33': 'IAB16-5', + '34': 'IAB19-34', + '35': 'IAB11-5', + '36': 'IAB12-3', + '37': 'IAB11-4', + '38': 'IAB12-3', + '39': 'IAB9-30', + '41': 'IAB7-44', + '42': 'IAB7-1', + '43': 'IAB7-30', + '50': 'IAB19-30', + '51': 'IAB17-12', + '52': 'IAB19-30', + '53': 'IAB3-1', + '55': 'IAB13-2', + '56': 'IAB19-30', + '57': 'IAB19-30', + '58': 'IAB7-39', + '59': 'IAB22-1', + '60': 'IAB7-39', + '61': 'IAB21-3', + '62': 'IAB5-1', + '63': 'IAB12-3', + '64': 'IAB20-18', + '65': 'IAB11-2', + '66': 'IAB17-18', + '67': 'IAB9-9', + '68': 'IAB9-5', + '69': 'IAB7-44', + '71': 'IAB22-3', + '73': 'IAB19-30', + '74': 'IAB8-5', + '78': 'IAB22-1', + '85': 'IAB12-2', + '86': 'IAB22-3', + '87': 'IAB11-3', + '112': 'IAB7-32', + '113': 'IAB7-32', + '114': 'IAB7-32', + '115': 'IAB7-32', + '118': 'IAB9-5', + '119': 'IAB9-5', + '120': 'IAB9-5', + '121': 'IAB9-5', + '122': 'IAB9-5', + '123': 'IAB9-5', + '124': 'IAB9-5', + '125': 'IAB9-5', + '126': 'IAB9-5', + '127': 'IAB22-1', + '132': 'IAB1-2', + '133': 'IAB19-30', + '137': 'IAB3-9', + '138': 'IAB19-3', + '140': 'IAB2-3', + '141': 'IAB2-1', + '142': 'IAB2-3', + '143': 'IAB17-13', + '166': 'IAB11-4', + '175': 'IAB3-1', + '176': 'IAB13-4', + '182': 'IAB8-9', + '183': 'IAB3-5' +}; diff --git a/libraries/chunk/chunk.js b/libraries/chunk/chunk.js new file mode 100644 index 00000000000..57be7bd5016 --- /dev/null +++ b/libraries/chunk/chunk.js @@ -0,0 +1,19 @@ +/** + * http://npm.im/chunk + * Returns an array with *size* chunks from given array + * + * Example: + * ['a', 'b', 'c', 'd', 'e'] chunked by 2 => + * [['a', 'b'], ['c', 'd'], ['e']] + */ +export function chunk(array, size) { + let newArray = []; + + for (let i = 0; i < Math.ceil(array.length / size); i++) { + let start = i * size; + let end = start + size; + newArray.push(array.slice(start, end)); + } + + return newArray; +} diff --git a/libraries/cmp/cmpClient.js b/libraries/cmp/cmpClient.js new file mode 100644 index 00000000000..03a50c37bb3 --- /dev/null +++ b/libraries/cmp/cmpClient.js @@ -0,0 +1,169 @@ +import {GreedyPromise} from '../../src/utils/promise.js'; + +/** + * @typedef {function} CMPClient + * + * @param {{}} params CMP parameters. Currently this is a subset of {command, callback, parameter, version}. + * @param {bool} once if true, discard cross-frame event listeners once a reply message is received. + * @returns {Promise<*>} a promise to the API's "result" - see the `mode` argument to `cmpClient` on how that's determined. + * @property {boolean} isDirect true if the CMP is directly accessible (no postMessage required) + * @property {() => void} close close the client; currently, this just stops listening for cross-frame messages. + */ + +/** + * Returns a client function that can interface with a CMP regardless of where it's located. + * + * @param apiName name of the CMP api, e.g. "__gpp" + * @param apiVersion? CMP API version + * @param apiArgs? names of the arguments taken by the api function, in order. + * @param callbackArgs? names of the cross-frame response payload properties that should be passed as callback arguments, in order + * @param mode? controls the callbacks passed to the underlying API, and how the promises returned by the client are resolved. + * + * The client behaves differently when it's provided a `callback` argument vs when it's not - for short, let's name these + * cases "subscriptions" and "one-shot calls" respectively: + * + * With `mode: MODE_MIXED` (the default), promises returned on subscriptions are resolved to undefined when the callback + * is first run (that is, the promise resolves when the CMP replies, but what it replies with is discarded and + * left for the callback to deal with). For one-shot calls, the returned promise is resolved to the API's + * return value when it's directly accessible, or with the result from the first (and, presumably, the only) + * cross-frame reply when it's not; + * + * With `mode: MODE_RETURN`, the returned promise always resolves to the API's return value - which is taken to be undefined + * when cross-frame; + * + * With `mode: MODE_CALLBACK`, the underlying API is expected to never directly return anything significant; instead, + * it should always accept a callback and - for one-shot calls - invoke it only once with the result. The client will + * automatically generate an appropriate callback for one-shot calls and use the result it's given to resolve + * the returned promise. Subscriptions are treated in the same way as MODE_MIXED. + * + * @param win + * @returns {CMPClient} CMP invocation function (or null if no CMP was found). + */ + +export const MODE_MIXED = 0; +export const MODE_RETURN = 1; +export const MODE_CALLBACK = 2; + +export function cmpClient( + { + apiName, + apiVersion, + apiArgs = ['command', 'callback', 'parameter', 'version'], + callbackArgs = ['returnValue', 'success'], + mode = MODE_MIXED, + }, + win = window +) { + const cmpCallbacks = {}; + const callName = `${apiName}Call`; + const cmpDataPkgName = `${apiName}Return`; + + function handleMessage(event) { + const json = (typeof event.data === 'string' && event.data.includes(cmpDataPkgName)) ? JSON.parse(event.data) : event.data; + if (json?.[cmpDataPkgName]?.callId) { + const payload = json[cmpDataPkgName]; + + if (cmpCallbacks.hasOwnProperty(payload.callId)) { + cmpCallbacks[payload.callId](...callbackArgs.map(name => payload[name])); + } + } + } + + function findCMP() { + let f = win; + let cmpFrame; + let isDirect = false; + while (f != null) { + try { + if (typeof f[apiName] === 'function') { + cmpFrame = f; + isDirect = true; + break; + } + } catch (e) { + } + + // need separate try/catch blocks due to the exception errors thrown when trying to check for a frame that doesn't exist in 3rd party env + try { + if (f.frames[`${apiName}Locator`]) { + cmpFrame = f; + break; + } + } catch (e) { + } + + if (f === win.top) break; + f = f.parent; + } + + return [ + cmpFrame, + isDirect + ]; + } + + const [cmpFrame, isDirect] = findCMP(); + + if (!cmpFrame) { + return; + } + + function resolveParams(params) { + params = Object.assign({version: apiVersion}, params); + return apiArgs.map(arg => [arg, params[arg]]) + } + + function wrapCallback(callback, resolve, reject, preamble) { + const haveCb = typeof callback === 'function'; + + return function (result, success) { + preamble && preamble(); + if (mode !== MODE_RETURN) { + const resolver = success == null || success ? resolve : reject; + resolver(haveCb ? undefined : result); + } + haveCb && callback.apply(this, arguments); + } + } + + let client; + + if (isDirect) { + client = function invokeCMPDirect(params = {}) { + return new GreedyPromise((resolve, reject) => { + const ret = cmpFrame[apiName](...resolveParams({ + ...params, + callback: (params.callback || mode === MODE_CALLBACK) ? wrapCallback(params.callback, resolve, reject) : undefined, + }).map(([_, val]) => val)); + if (mode === MODE_RETURN || (params.callback == null && mode === MODE_MIXED)) { + resolve(ret); + } + }); + }; + } else { + win.addEventListener('message', handleMessage, false); + + client = function invokeCMPFrame(params, once = false) { + return new GreedyPromise((resolve, reject) => { + // call CMP via postMessage + const callId = Math.random().toString(); + const msg = { + [callName]: { + ...Object.fromEntries(resolveParams(params).filter(([param]) => param !== 'callback')), + callId: callId + } + }; + + cmpCallbacks[callId] = wrapCallback(params?.callback, resolve, reject, (once || params?.callback == null) && (() => { delete cmpCallbacks[callId] })); + cmpFrame.postMessage(msg, '*'); + if (mode === MODE_RETURN) resolve(); + }); + }; + } + return Object.assign(client, { + isDirect, + close() { + !isDirect && win.removeEventListener('message', handleMessage); + } + }) +} diff --git a/libraries/currencyUtils/currency.js b/libraries/currencyUtils/currency.js new file mode 100644 index 00000000000..924f8f200d8 --- /dev/null +++ b/libraries/currencyUtils/currency.js @@ -0,0 +1,31 @@ +import {getGlobal} from '../../src/prebidGlobal.js'; +import {keyCompare} from '../../src/utils/reducers.js'; + +/** + * Attempt to convert `amount` from the currency `fromCur` to the currency `toCur`. + * + * By default, when the conversion is not possible (currency module not present or + * throwing errors), the amount is returned unchanged. This behavior can be + * toggled off with bestEffort = false. + */ +export function convertCurrency(amount, fromCur, toCur, bestEffort = true) { + if (fromCur === toCur) return amount; + let result = amount; + try { + result = getGlobal().convertCurrency(amount, fromCur, toCur); + } catch (e) { + if (!bestEffort) throw e; + } + return result; +} + +export function currencyNormalizer(toCurrency = null, bestEffort = true, convert = convertCurrency) { + return function (amount, currency) { + if (toCurrency == null) toCurrency = currency; + return convert(amount, currency, toCurrency, bestEffort); + } +} + +export function currencyCompare(get = (obj) => [obj.cpm, obj.currency], normalize = currencyNormalizer()) { + return keyCompare(obj => normalize.apply(null, get(obj))) +} diff --git a/libraries/domainOverrideToRootDomain/index.js b/libraries/domainOverrideToRootDomain/index.js new file mode 100644 index 00000000000..95a334755d1 --- /dev/null +++ b/libraries/domainOverrideToRootDomain/index.js @@ -0,0 +1,39 @@ +/** + * Create a domainOverride callback for an ID module, closing over + * an instance of StorageManager. + * + * The domainOverride function, given document.domain, will return + * the topmost domain we are able to set a cookie on. For example, + * given subdomain.example.com, it would return example.com. + * + * @param {StorageManager} storage e.g. from getStorageManager() + * @param {string} moduleName the name of the module using this function + * @returns {function(): string} + */ +export function domainOverrideToRootDomain(storage, moduleName) { + return function() { + const domainElements = document.domain.split('.'); + const cookieName = `_gd${Date.now()}_${moduleName}`; + + for (let i = 0, topDomain, testCookie; i < domainElements.length; i++) { + const nextDomain = domainElements.slice(i).join('.'); + + // write test cookie + storage.setCookie(cookieName, '1', undefined, undefined, nextDomain); + + // read test cookie to verify domain was valid + testCookie = storage.getCookie(cookieName); + + // delete test cookie + storage.setCookie(cookieName, '', 'Thu, 01 Jan 1970 00:00:01 GMT', undefined, nextDomain); + + if (testCookie === '1') { + // cookie was written successfully using test domain so the topDomain is updated + topDomain = nextDomain; + } else { + // cookie failed to write using test domain so exit by returning the topDomain + return topDomain; + } + } + } +} diff --git a/libraries/getOrigin/index.js b/libraries/getOrigin/index.js new file mode 100644 index 00000000000..c37a913db07 --- /dev/null +++ b/libraries/getOrigin/index.js @@ -0,0 +1,11 @@ +/** + * Returns the origin + */ +export function getOrigin() { + // IE10 does not have this property. https://gist.github.com/hbogs/7908703 + if (!window.location.origin) { + return window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); + } else { + return window.location.origin; + } +} diff --git a/libraries/gptUtils/gptUtils.js b/libraries/gptUtils/gptUtils.js new file mode 100644 index 00000000000..950f28c618f --- /dev/null +++ b/libraries/gptUtils/gptUtils.js @@ -0,0 +1,37 @@ +import {find} from '../../src/polyfill.js'; +import {compareCodeAndSlot, isGptPubadsDefined} from '../../src/utils.js'; + +/** + * Returns filter function to match adUnitCode in slot + * @param {string} adUnitCode AdUnit code + * @return {function} filter function + */ +export function isSlotMatchingAdUnitCode(adUnitCode) { + return (slot) => compareCodeAndSlot(slot, adUnitCode); +} + +/** + * @summary Uses the adUnit's code in order to find a matching gpt slot object on the page + */ +export function getGptSlotForAdUnitCode(adUnitCode) { + let matchingSlot; + if (isGptPubadsDefined()) { + // find the first matching gpt slot on the page + matchingSlot = find(window.googletag.pubads().getSlots(), isSlotMatchingAdUnitCode(adUnitCode)); + } + return matchingSlot; +} + +/** + * @summary Uses the adUnit's code in order to find a matching gptSlot on the page + */ +export function getGptSlotInfoForAdUnitCode(adUnitCode) { + const matchingSlot = getGptSlotForAdUnitCode(adUnitCode); + if (matchingSlot) { + return { + gptSlot: matchingSlot.getAdUnitPath(), + divId: matchingSlot.getSlotElementId() + }; + } + return {}; +} diff --git a/libraries/htmlEscape/htmlEscape.js b/libraries/htmlEscape/htmlEscape.js new file mode 100644 index 00000000000..f0952c02e3c --- /dev/null +++ b/libraries/htmlEscape/htmlEscape.js @@ -0,0 +1,26 @@ +/** + * Encode a string for inclusion in HTML. + * See https://pragmaticwebsecurity.com/articles/spasecurity/json-stringify-xss.html and + * https://codeql.github.com/codeql-query-help/javascript/js-bad-code-sanitization/ + * @return {string} + */ +export const escapeUnsafeChars = (() => { + const escapes = { + '<': '\\u003C', + '>': '\\u003E', + '/': '\\u002F', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + }; + + return function (str) { + return str.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g, x => escapes[x]); + }; +})(); diff --git a/libraries/keywords/keywords.js b/libraries/keywords/keywords.js new file mode 100644 index 00000000000..645c9c8d38f --- /dev/null +++ b/libraries/keywords/keywords.js @@ -0,0 +1,31 @@ +import {CLIENT_SECTIONS} from '../../src/fpd/oneClient.js'; +import {deepAccess} from '../../src/utils.js'; + +const ORTB_KEYWORDS_PATHS = ['user.keywords'].concat( + CLIENT_SECTIONS.flatMap((prefix) => ['keywords', 'content.keywords'].map(suffix => `${prefix}.${suffix}`)) +); + +/** + * @param commaSeparatedKeywords: any number of either keyword arrays, or comma-separated keyword strings + * @returns an array with all unique keywords contained across all inputs + */ +export function mergeKeywords(...commaSeparatedKeywords) { + const keywords = new Set(); + commaSeparatedKeywords + .filter(kwds => kwds) + .flatMap(kwds => Array.isArray(kwds) ? kwds : kwds.split(',')) + .map(kw => kw.replace(/^\s*/, '').replace(/\s*$/, '')) + .filter(kw => kw) + .forEach(kw => keywords.add(kw)); + return Array.from(keywords.keys()); +} + +/** + * Get an array with all keywords contained in an ortb2 object. + */ +export function getAllOrtbKeywords(ortb2, ...extraCommaSeparatedKeywords) { + return mergeKeywords( + ...ORTB_KEYWORDS_PATHS.map(path => deepAccess(ortb2, path)), + ...extraCommaSeparatedKeywords + ) +} diff --git a/libraries/mspa/activityControls.js b/libraries/mspa/activityControls.js new file mode 100644 index 00000000000..eaf515e2385 --- /dev/null +++ b/libraries/mspa/activityControls.js @@ -0,0 +1,127 @@ +import {registerActivityControl} from '../../src/activities/rules.js'; +import { + ACTIVITY_ENRICH_EIDS, + ACTIVITY_ENRICH_UFPD, + ACTIVITY_SYNC_USER, + ACTIVITY_TRANSMIT_PRECISE_GEO +} from '../../src/activities/activities.js'; +import {gppDataHandler} from '../../src/adapterManager.js'; +import {logInfo} from '../../src/utils.js'; + +// default interpretation for MSPA consent(s): +// https://docs.prebid.org/features/mspa-usnat.html + +const SENSITIVE_DATA_GEO = 7; + +function isApplicable(val) { + return val != null && val !== 0 +} + +export function isBasicConsentDenied(cd) { + // service provider mode is always consent denied + return ['MspaServiceProviderMode', 'Gpc'].some(prop => cd[prop] === 1) || + // you cannot consent to what you were not notified of + cd.PersonalDataConsents === 2 || + // minors 13+ who have not given consent + cd.KnownChildSensitiveDataConsents[0] === 1 || + // minors under 13 cannot consent + isApplicable(cd.KnownChildSensitiveDataConsents[1]) || + // covered cannot be zero + cd.MspaCoveredTransaction === 0; +} + +export function sensitiveNoticeIs(cd, value) { + return ['SensitiveDataProcessingOptOutNotice', 'SensitiveDataLimitUseNotice'].some(prop => cd[prop] === value) +} + +export function isConsentDenied(cd) { + return isBasicConsentDenied(cd) || + ['Sale', 'Sharing', 'TargetedAdvertising'].some(scope => { + const oo = cd[`${scope}OptOut`]; + const notice = cd[`${scope}OptOutNotice`]; + // user opted out + return oo === 1 || + // opt-out notice was not given + notice === 2 || + // do not trust CMP if it signals opt-in but no opt-out notice was given + (oo === 2 && notice === 0); + }) || + // no sharing notice was given ... + cd.SharingNotice === 2 || + // ... or the CMP says it was not applicable, while also claiming it got consent + (cd.SharingOptOut === 2 && cd.SharingNotice === 0); +} + +export const isTransmitUfpdConsentDenied = (() => { + // deny anything that smells like: genetic, biometric, state/national ID, financial, union membership, + // or personal communication data + const cannotBeInScope = [6, 7, 9, 10, 12].map(el => --el); + // require consent for everything else (except geo, which is treated separately) + const allExceptGeo = Array.from(Array(12).keys()).filter((el) => el !== SENSITIVE_DATA_GEO) + const mustHaveConsent = allExceptGeo.filter(el => !cannotBeInScope.includes(el)); + + return function (cd) { + return isConsentDenied(cd) || + // no notice about sensitive data was given + sensitiveNoticeIs(cd, 2) || + // extra-sensitive data is applicable + cannotBeInScope.some(i => isApplicable(cd.SensitiveDataProcessing[i])) || + // user opted out for not-as-sensitive data + mustHaveConsent.some(i => cd.SensitiveDataProcessing[i] === 1) || + // CMP says it has consent, but did not give notice about it + (sensitiveNoticeIs(cd, 0) && allExceptGeo.some(i => cd.SensitiveDataProcessing[i] === 2)) + } +})(); + +export function isTransmitGeoConsentDenied(cd) { + const geoConsent = cd.SensitiveDataProcessing[SENSITIVE_DATA_GEO]; + return geoConsent === 1 || + isBasicConsentDenied(cd) || + // no sensitive data notice was given + sensitiveNoticeIs(cd, 2) || + // do not trust CMP if it says it has consent for geo but didn't show a sensitive data notice + (sensitiveNoticeIs(cd, 0) && geoConsent === 2) +} + +const CONSENT_RULES = { + [ACTIVITY_SYNC_USER]: isConsentDenied, + [ACTIVITY_ENRICH_EIDS]: isConsentDenied, + [ACTIVITY_ENRICH_UFPD]: isTransmitUfpdConsentDenied, + [ACTIVITY_TRANSMIT_PRECISE_GEO]: isTransmitGeoConsentDenied +}; + +export function mspaRule(sids, getConsent, denies, applicableSids = () => gppDataHandler.getConsentData()?.applicableSections) { + return function () { + if (applicableSids().some(sid => sids.includes(sid))) { + const consent = getConsent(); + if (consent == null) { + return {allow: false, reason: 'consent data not available'}; + } + if (denies(consent)) { + return {allow: false}; + } + } + }; +} + +function flatSection(subsections) { + if (subsections == null) return subsections; + return subsections.reduceRight((subsection, consent) => { + return Object.assign(consent, subsection); + }, {}); +} + +export function setupRules(api, sids, normalizeConsent = (c) => c, rules = CONSENT_RULES, registerRule = registerActivityControl, getConsentData = () => gppDataHandler.getConsentData()) { + const unreg = []; + const ruleName = `MSPA (GPP '${api}' for section${sids.length > 1 ? 's' : ''} ${sids.join(', ')})`; + logInfo(`Enabling activity controls for ${ruleName}`) + Object.entries(rules).forEach(([activity, denies]) => { + unreg.push(registerRule(activity, ruleName, mspaRule( + sids, + () => normalizeConsent(flatSection(getConsentData()?.parsedSections?.[api])), + denies, + () => getConsentData()?.applicableSections || [] + ))); + }); + return () => unreg.forEach(ur => ur()); +} diff --git a/libraries/objectGuard/objectGuard.js b/libraries/objectGuard/objectGuard.js new file mode 100644 index 00000000000..cf3d2f38256 --- /dev/null +++ b/libraries/objectGuard/objectGuard.js @@ -0,0 +1,99 @@ +import {isData, objectTransformer, sessionedApplies} from '../../src/activities/redactor.js'; +import {deepAccess, deepClone, deepEqual, deepSetValue} from '../../src/utils.js'; + +/** + * @typedef {Object} ObjectGuard + * @property {*} obj a view on the guarded object + * @property {function(): void} verify a function that checks for and rolls back disallowed changes to the guarded object + */ + +/** + * Create a factory function for object guards using the given rules. + * + * An object guard is a pair {obj, verify} where: + * - `obj` is a view on the guarded object that applies "redact" rules (the same rules used in activites/redactor.js) + * - `verify` is a function that, when called, will check that the guarded object was not modified + * in a way that violates any "write protect" rules, and rolls back any offending changes. + * + * This is meant to provide sandboxed version of a privacy-sensitive object, where reads + * are filtered through redaction rules and writes are checked against write protect rules. + * + * @param {Array[TransformationRule]} rules + * @return {function(*, ...[*]): ObjectGuard} + */ +export function objectGuard(rules) { + const root = {}; + const writeRules = []; + + rules.forEach(rule => { + if (rule.wp) writeRules.push(rule); + if (!rule.get) return; + rule.paths.forEach(path => { + let node = root; + path.split('.').forEach(el => { + node.children = node.children || {}; + node.children[el] = node.children[el] || {}; + node = node.children[el]; + }) + node.rule = rule; + }); + }); + + const wpTransformer = objectTransformer(writeRules); + + function mkGuard(obj, tree, applies) { + return new Proxy(obj, { + get(target, prop, receiver) { + const val = Reflect.get(target, prop, receiver); + if (tree.hasOwnProperty(prop)) { + const {children, rule} = tree[prop]; + if (children && val != null && typeof val === 'object') { + return mkGuard(val, children, applies); + } else if (rule && isData(val) && applies(rule)) { + return rule.get(val); + } + } + return val; + }, + }); + } + + function mkVerify(transformResult) { + return function () { + transformResult.forEach(fn => fn()); + } + } + + return function guard(obj, ...args) { + const session = {}; + return { + obj: mkGuard(obj, root.children || {}, sessionedApplies(session, ...args)), + verify: mkVerify(wpTransformer(session, obj, ...args)) + } + }; +} + +/** + * @param {TransformationRuleDef} ruleDef + * @return {TransformationRule} + */ +export function writeProtectRule(ruleDef) { + return Object.assign({ + wp: true, + run(root, path, object, property, applies) { + const origHasProp = object && object.hasOwnProperty(property); + const original = origHasProp ? object[property] : undefined; + const origCopy = origHasProp && original != null && typeof original === 'object' ? deepClone(original) : original; + return function () { + const object = path == null ? root : deepAccess(root, path); + const finalHasProp = object && isData(object[property]); + const finalValue = finalHasProp ? object[property] : undefined; + if (!origHasProp && finalHasProp && applies()) { + delete object[property]; + } else if ((origHasProp !== finalHasProp || finalValue !== original || !deepEqual(finalValue, origCopy)) && applies()) { + deepSetValue(root, (path == null ? [] : [path]).concat(property).join('.'), origCopy); + } + } + } + }, ruleDef) +} diff --git a/libraries/objectGuard/ortbGuard.js b/libraries/objectGuard/ortbGuard.js new file mode 100644 index 00000000000..7911b378c3d --- /dev/null +++ b/libraries/objectGuard/ortbGuard.js @@ -0,0 +1,88 @@ +import {isActivityAllowed} from '../../src/activities/rules.js'; +import {ACTIVITY_ENRICH_EIDS, ACTIVITY_ENRICH_UFPD} from '../../src/activities/activities.js'; +import { + appliesWhenActivityDenied, + ortb2TransmitRules, + ORTB_EIDS_PATHS, + ORTB_UFPD_PATHS +} from '../../src/activities/redactor.js'; +import {objectGuard, writeProtectRule} from './objectGuard.js'; +import {mergeDeep} from '../../src/utils.js'; + +function ortb2EnrichRules(isAllowed = isActivityAllowed) { + return [ + { + name: ACTIVITY_ENRICH_EIDS, + paths: ORTB_EIDS_PATHS, + applies: appliesWhenActivityDenied(ACTIVITY_ENRICH_EIDS, isAllowed) + }, + { + name: ACTIVITY_ENRICH_UFPD, + paths: ORTB_UFPD_PATHS, + applies: appliesWhenActivityDenied(ACTIVITY_ENRICH_UFPD, isAllowed) + } + ].map(writeProtectRule) +} + +export function ortb2GuardFactory(isAllowed = isActivityAllowed) { + return objectGuard(ortb2TransmitRules(isAllowed).concat(ortb2EnrichRules(isAllowed))); +} + +/** + * + * + * @typedef {Function} ortb2Guard + * @param {{}} ortb2 ORTB object to guard + * @param {{}} params activity params to use for activity checks + * @returns {ObjectGuard} + */ + +/* + * Get a guard for an ORTB object. Read access is restricted in the same way it'd be redacted (see activites/redactor.js); + * and writes are checked against the enrich* activites. + * + * @type ortb2Guard + */ +export const ortb2Guard = ortb2GuardFactory(); + +export function ortb2FragmentsGuardFactory(guardOrtb2 = ortb2Guard) { + return function guardOrtb2Fragments(fragments, params) { + fragments.global = fragments.global || {}; + fragments.bidder = fragments.bidder || {}; + const bidders = new Set(Object.keys(fragments.bidder)); + const verifiers = []; + + function makeGuard(ortb2) { + const guard = guardOrtb2(ortb2, params); + verifiers.push(guard.verify); + return guard.obj; + } + + const obj = { + global: makeGuard(fragments.global), + bidder: Object.fromEntries(Object.entries(fragments.bidder).map(([bidder, ortb2]) => [bidder, makeGuard(ortb2)])) + }; + + return { + obj, + verify() { + Object.entries(obj.bidder) + .filter(([bidder]) => !bidders.has(bidder)) + .forEach(([bidder, ortb2]) => { + const repl = {}; + const guard = guardOrtb2(repl, params); + mergeDeep(guard.obj, ortb2); + guard.verify(); + fragments.bidder[bidder] = repl; + }) + verifiers.forEach(fn => fn()); + } + } + } +} + +/** + * Get a guard for an ortb2Fragments object. + * @type {function(*, *): ObjectGuard} + */ +export const guardOrtb2Fragments = ortb2FragmentsGuardFactory(); diff --git a/libraries/ortb2.5StrictTranslator/dsl.js b/libraries/ortb2.5StrictTranslator/dsl.js new file mode 100644 index 00000000000..8f9fc79feeb --- /dev/null +++ b/libraries/ortb2.5StrictTranslator/dsl.js @@ -0,0 +1,54 @@ +export const ERR_TYPE = 0; // field has wrong type (only objects, enums, and arrays of objects or enums are checked) +export const ERR_UNKNOWN_FIELD = 1; // field is not defined in ORTB 2.5 spec +export const ERR_ENUM = 2; // field is an enum and its value is not one of those listed in the ORTB 2.5 spec + +// eslint-disable-next-line symbol-description +export const extend = Symbol(); + +export function Obj(primitiveFields, spec = {}) { + const scan = (path, parent, field, value, onError) => { + if (value == null || typeof value !== 'object') { + onError(ERR_TYPE, path, parent, field, value); + return; + } + Object.entries(value).forEach(([k, v]) => { + if (v == null) return; + const kpath = path == null ? k : `${path}.${k}`; + if (spec.hasOwnProperty(k)) { + spec[k](kpath, value, k, v, onError); + return; + } + if (k !== 'ext' && !primitiveFields.includes(k)) { + onError(ERR_UNKNOWN_FIELD, kpath, value, k, v); + } + }); + }; + scan[extend] = (extraPrimitives, specOverride = {}) => + Obj(primitiveFields.concat(extraPrimitives), Object.assign({}, spec, specOverride)); + return scan; +} + +export const ID = Obj(['id']); +export const Named = ID[extend](['name']); + +export function Arr(def) { + return (path, parent, field, value, onError) => { + if (!Array.isArray(value)) { + onError(ERR_TYPE, path, parent, field, value); + } else { + value.forEach((item, i) => def(`${path}.${i}`, value, i, item, onError)); + } + }; +} + +export function IntEnum(min, max) { + return (path, parent, field, value, onError) => { + const errno = (() => { + if (typeof value !== 'number') return ERR_TYPE; + if (isNaN(value) || value > max || value < min) return ERR_ENUM; + })(); + if (errno != null) { + onError(errno, path, parent, field, value); + } + }; +} diff --git a/libraries/ortb2.5StrictTranslator/spec.js b/libraries/ortb2.5StrictTranslator/spec.js new file mode 100644 index 00000000000..0ffb17a2e72 --- /dev/null +++ b/libraries/ortb2.5StrictTranslator/spec.js @@ -0,0 +1,81 @@ +import {Arr, extend, ID, IntEnum, Named, Obj} from './dsl.js'; + +const CatDomain = Named[extend](['cat', 'domain']); +const Segment = Named[extend](['value']); +const Data = Named[extend]([], { + segment: Arr(Segment) +}); +const Content = ID[extend](['episode', 'title', 'series', 'season', 'artist', 'genre', 'album', 'isrc', 'url', 'cat', 'contentrating', 'userrating', 'keywords', 'livestream', 'sourcerelationship', 'len', 'language', 'embeddable'], { + producer: CatDomain, + data: Arr(Data), + prodq: IntEnum(0, 3), + videoquality: IntEnum(0, 3), + context: IntEnum(1, 7), + qagmediarating: IntEnum(1, 3), +}); + +const Client = CatDomain[extend](['sectioncat', 'pagecat', 'privacypolicy', 'keywords'], { + publisher: CatDomain, content: Content, +}); +const Site = Client[extend](['page', 'ref', 'search', 'mobile']); +const App = Client[extend](['bundle', 'storeurl', 'ver', 'paid']); + +const Geo = Obj(['lat', 'lon', 'accuracy', 'lastfix', 'country', 'region', 'regionfips104', 'metro', 'city', 'zip', 'utcoffset'], { + type: IntEnum(1, 3), + ipservice: IntEnum(1, 4) +}); +const Device = Obj(['ua', 'dnt', 'lmt', 'ip', 'ipv6', 'make', 'model', 'os', 'osv', 'hwv', 'h', 'w', 'ppi', 'pxratio', 'js', 'geofetch', 'flashver', 'language', 'carrier', 'mccmnc', 'ifa', 'didsha1', 'didmd5', 'dpidsha1', 'dpidmd5', 'macsha1', 'macmd5'], { + geo: Geo, devicetype: IntEnum(1, 7), connectiontype: IntEnum(0, 6) +}); +const User = ID[extend](['buyeruid', 'yob', 'gender', 'keywords', 'customdata'], { + geo: Geo, data: Arr(Data), +}); + +const Floorable = ID[extend](['bidfloor', 'bidfloorcur']); +const Deal = Floorable[extend](['at', 'wseat', 'wadomain']); +const Pmp = Obj(['private_auction'], { + deals: Arr(Deal), +}); +const Format = Obj(['w', 'h', 'wratio', 'hratio', 'wmin']); +const MediaType = Obj(['mimes'], { + api: Arr(IntEnum(1, 6)), battr: Arr(IntEnum(1, 17)) +}); +const Banner = MediaType[extend](['id', 'w', 'h', 'wmax', 'hmax', 'hmin', 'wmin', 'topframe', 'vcm'], { + format: Arr(Format), btype: Arr(IntEnum(1, 4)), pos: IntEnum(0, 7), expdir: Arr(IntEnum(1, 5)) +}); +const Native = MediaType[extend](['request', 'ver']); +const RichMediaType = MediaType[extend](['minduration', 'maxduration', 'startdelay', 'sequence', 'maxextended', 'minbitrate', 'maxbitrate'], { + protocols: Arr(IntEnum(1, 10)), + delivery: Arr(IntEnum(1, 3)), + companionad: Arr(Banner), + companiontype: Arr(IntEnum(1, 3)), +}); +/* +const Audio = RichMediaType[extend](['maxseq', 'stitched'], { + feed: IntEnum(1, 3), nvol: IntEnum(0, 4), +}); + */ +const Video = RichMediaType[extend](['w', 'h', 'skip', 'skipmin', 'skipafter', 'boxingallowed'], { + pos: IntEnum(0, 7), + protocol: IntEnum(1, 10), + placement: IntEnum(1, 5), + linearity: IntEnum(1, 2), + playbackmethod: Arr(IntEnum(1, 6)), + playbackend: IntEnum(1, 3), +}); +const Metric = Obj(['type', 'value', 'vendor']); +const Imp = (() => { + const spec = { + metric: Arr(Metric), banner: Banner, video: Video, pmp: Pmp, + }; + if (FEATURES.NATIVE) { + spec.native = Native; + } + return Floorable[extend](['displaymanager', 'displaymanagerver', 'instl', 'tagid', 'clickbrowser', 'secure', 'iframebuster', 'exp'], spec); +})(); + +const Regs = Obj(['coppa']); +const Source = Obj(['fd', 'tid', 'pchain']); +export const BidRequest = ID[extend](['test', 'at', 'tmax', 'wseat', 'bseat', 'allimps', 'cur', 'wlang', 'bcat', 'badv', 'bapp'], { + imp: Arr(Imp), site: Site, app: App, device: Device, user: User, source: Source, regs: Regs +}); diff --git a/libraries/ortb2.5StrictTranslator/translator.js b/libraries/ortb2.5StrictTranslator/translator.js new file mode 100644 index 00000000000..c6f651e2476 --- /dev/null +++ b/libraries/ortb2.5StrictTranslator/translator.js @@ -0,0 +1,37 @@ +import {BidRequest} from './spec.js'; +import {logWarn} from '../../src/utils.js'; +import {toOrtb25} from '../ortb2.5Translator/translator.js'; + +function deleteField(errno, path, obj, field, value) { + logWarn(`${path} is not valid ORTB 2.5, field will be removed from request:`, value); + Array.isArray(obj) ? obj.splice(field, 1) : delete obj[field]; +} + +/** + * Translates an ortb request to 2.5, and removes from the result any field that is: + * - not defined in the 2.5 spec, or + * - defined as an enum, but has a value that is not listed in the 2.5 spec. + * + * `ortb2` is modified in place and returned. + * + * Note that using this utility will cause your adapter to pull in an additional ~3KB after minification. + * If possible, consider making your endpoint tolerant to unrecognized or invalid fields instead. + * + * + * @param ortb2 ORTB request + * @param translator translation function. The default moves 2.x fields that have a known standard location in 2.5. + * See the `ortb2.5Translator` library. + * @param onError a function invoked once for each field that is not valid according to the 2.5 spec; it takes + * (errno, path, obj, field, value), where: + * - errno is an error code (defined in dsl.js) + * - path is the JSON path of the offending field, for example `regs.gdpr` + * - obj is the object containing the offending field, for example `ortb2.regs` + * - field is the field name, for example `'gdpr'` + * - value is `obj[field]`. + * The default logs a warning and deletes the offending field. + */ +export function toOrtb25Strict(ortb2, translator = toOrtb25, onError = deleteField) { + ortb2 = translator(ortb2); + BidRequest(null, null, null, ortb2, onError); + return ortb2; +} diff --git a/libraries/ortb2.5Translator/translator.js b/libraries/ortb2.5Translator/translator.js new file mode 100644 index 00000000000..1afad516ef0 --- /dev/null +++ b/libraries/ortb2.5Translator/translator.js @@ -0,0 +1,82 @@ +import {deepAccess, deepSetValue, logError} from '../../src/utils.js'; + +export const EXT_PROMOTIONS = [ + 'source.schain', + 'regs.gdpr', + 'regs.us_privacy', + 'regs.gpp', + 'user.consent', + 'user.eids' +]; + +export function splitPath(path) { + const parts = path.split('.'); + const prefix = parts.slice(0, parts.length - 1).join('.'); + const field = parts[parts.length - 1]; + return [prefix, field]; +} + +/** + * @param sourcePath a JSON path such as `regs.us_privacy` + * @param dest {function(String, String): String} a function taking (prefix, field) and returning a destination path; + * for example, ('regs', 'us_privacy') => 'regs.ext.us_privacy' + * @return {(function({}): (function(): void|undefined))|*} a function that takes an object and, if it contains + * sourcePath, copies its contents to destinationPath, returning a function that deletes the original sourcePath. + */ +export function moveRule(sourcePath, dest = (prefix, field) => `${prefix}.ext.${field}`) { + const [prefix, field] = splitPath(sourcePath); + dest = dest(prefix, field); + return (ortb2) => { + const obj = deepAccess(ortb2, prefix); + if (obj?.[field] != null) { + deepSetValue(ortb2, dest, obj[field]); + return () => delete obj[field]; + } + }; +} + +function kwarrayRule(section) { + // move 2.6 `kwarray` into 2.5 comma-separated `keywords`. + return (ortb2) => { + const kwarray = ortb2[section]?.kwarray; + if (kwarray != null) { + let kw = (ortb2[section].keywords || '').split(','); + if (Array.isArray(kwarray)) kw.push(...kwarray); + ortb2[section].keywords = kw.join(','); + return () => delete ortb2[section].kwarray; + } + }; +} + +export const DEFAULT_RULES = Object.freeze([ + ...EXT_PROMOTIONS.map((f) => moveRule(f)), + ...['app', 'content', 'site', 'user'].map(kwarrayRule) +]); + +/** + * Factory for ORTB 2.5 translation functions. + * + * @param deleteFields if true, the translation function will remove fields that have been translated (transferred somewhere else within the request) + * @param rules translation rules; an array of functions of the type returned by `moveRule` + * @return {function({}): {}} a translation function that takes an ORTB object, modifies it in place, and returns it. + */ +export function ortb25Translator(deleteFields = true, rules = DEFAULT_RULES) { + return function (ortb2) { + rules.forEach(f => { + try { + const deleter = f(ortb2); + if (typeof deleter === 'function' && deleteFields) deleter(); + } catch (e) { + logError('Error translating request to ORTB 2.5', e); + } + }) + return ortb2; + } +} + +/** + * Translate an ortb request to version 2.5 by moving 2.6 (and later) fields that have a standardized 2.5 extension. + * + * The request is modified in place and returned. + */ +export const toOrtb25 = ortb25Translator(); diff --git a/libraries/ortbConverter/README.md b/libraries/ortbConverter/README.md new file mode 100644 index 00000000000..31f56b4c754 --- /dev/null +++ b/libraries/ortbConverter/README.md @@ -0,0 +1,378 @@ +# Prebid.js - ORTB conversion library + +This library provides methods to convert Prebid.js bid request objects to ORTB requests, +and ORTB responses to Prebid.js bid response objects. + +## Usage + +The simplest way to use this from an adapter is: + +```javascript +import {ortbConverter} from '../../libraries/ortbConverter/converter.js' + +const converter = ortbConverter({ + context: { + // `netRevenue` and `ttl` are required properties of bid responses - provide a default for them + netRevenue: true, // or false if your adapter should set bidResponse.netRevenue = false + ttl: 30 // default bidResponse.ttl (when not specified in ORTB response.seatbid[].bid[].exp) + } +}); + +registerBidder({ + // ... rest of your spec goes here ... + buildRequests(bidRequests, bidderRequest) { + const data = converter.toORTB({bidRequests, bidderRequest}) + // you may need to adjust `data` to suit your needs - see "customization" below + return [{ + method: METHOD, + url: ENDPOINT_URL, + data + }] + }, + interpretResponse(response, request) { + const bids = converter.fromORTB({response: response.body, request: request.data}).bids; + // likewise, you may need to adjust the bid response objects + return bids; + }, +}) +``` + +Without any customization, the library will generate complete ORTB requests, but ignores your [bid params](#params). +If your endpoint sets `response.seatbid[].bid[].mtype` (part of the ORTB 2.6 spec), it will also parse the response into complete bidResponse objects. See [setting response mediaTypes](#response-mediaTypes) if that is not the case. + +### Module-specific conversions + +Prebid.js features that require a module also require it for their corresponding ORTB conversion logic. For example, `imp.bidfloor` is only populated if the `priceFloors` module is active; `request.cur` needs the `currency` module, and so on. Notably, this means that to get those fields populated from your unit tests, you must import those modules first; see [this suite](https://github.com/prebid/Prebid.js/blob/master/test/spec/modules/openxOrtbBidAdapter_spec.js) for an example. + +## Customization + +### Modifying return values directly + +You are free to modify the objects returned by both `toORTB` and `fromORTB`: + +```javascript +const data = converter.toORTB({bidRequests, bidderRequest}); +deepSetValue(data.imp[0], 'ext.myCustomParam', bidRequests[0].params.myCustomParam); +``` + +However, there are two restrictions (to avoid them, use the [other customization options](#fine-customization)): + + - you may not change the `imp[].id` returned by `toORTB`; they ared used internally to match responses to their requests. + ```javascript + const data = converter.toORTB({bidRequests, bidderRequest}); + data.imp[0].id = 'custom-imp-id' // do not do this - it will cause an error later in `fromORTB` + ``` + See also [overriding `imp.id`](#imp-id). + - the `request` argument passed to `fromORTB` must be the same object returned by `toORTB`. + ```javascript + let data = converter.toORTB({bidRequests, bidderRequest}); + + data = mergeDeep( // the original object is lost + {ext: {myCustomParam: bidRequests[0].params.myCustomParam}}, // `fromORTB` will later throw an error + data + ); + + // do this instead: + mergeDeep( + data, + {ext: {myCustomParam: bidRequests[0].params.myCustomParam}}, + data + ) + ``` + + +### Fine grained customization - imp, request, bidResponse, response + +When invoked, `toORTB({bidRequests, bidderRequest})` first loops through each request in `bidRequests`, converting them into ORTB `imp` objects. +It then packages them into a single ORTB request, adding other parameters that are not imp-specific (such as for example `request.tmax`). + +Likewise, `fromORTB({request, response})` first loops through each `response.seatbid[].bid[]`, converting them into Prebid bidResponses; it then packages them into +a single return value. + +You can customize each of these steps using the `ortbConverter` arguments `imp`, `request`, `bidResponse` and `response`: + +### Customizing imps: `imp(buildImp, bidRequest, context)` + +Invoked once for each input `bidRequest`; should return the ORTB `imp` object to include in the request. +The arguments are: + +- `buildImp`: a function taking `(bidRequest, context)` and returning an ORTB `imp` object; +- `bidRequest`: the bid request object to convert; +- `context`: a [context object](#context) that contains at least: + - `bidderRequest`: the `bidderRequest` argument passed to `toORTB`. + +#### Example: attaching custom bid params + +```javascript +const converter = ortbConverter({ + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + deepSetValue(imp, 'ext.params', bidRequest.params); + return imp; + } +}) +``` + +#### Example: overriding imp.id + +```javascript +const converter = ortbConverter({ + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + imp.id = randomIdentifierStr(); + return imp; + } +}) +``` + +### Customizing the request: `request(buildRequest, imps, bidderRequest, context)` + +Invoked once after all bidRequests have been converted into `imp`s; should return the complete ORTB request. The return value +of this function is also the return value of `toORTB`. +The arguments are: + +- `buildRequest`: a function taking `(imps, bidderRequest, context)` and returning an ORTB request object; +- `imps` an array of ORTB `imp` objects that should be included in the request; +- `bidderRequest`: the `bidderRequest` argument passed to `toORTB`; +- `context`: a [context object](#context) that contains at least: + - `bidRequests`: the `bidRequests` argument passed to `toORTB`. + +#### Example: setting additional request properties + +```javascript +const converter = ortbConverter({ + request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + deepSetValue(request, 'ext.adapterVersion', '0.0.1'); + return request; + } +}) +``` + +### Customizing bid responses: `bidResponse(buildBidResponse, bid, context)` + +Invoked once for each `seatbid[].bid[]` in the response; should return the corresponding Prebid.js bid response object. +The arguments are: +- `buildBidResponse`: a function taking `(bid, context)` and returning a Prebid.js bid response object; +- `bid`: an ORTB `seatbid[].bid[]` object; +- `context`: a [context object](#context) that contains at least: + - `seatbid`: the ORTB `seatbid[]` object that encloses `bid`; + - `imp`: the ORTB request's `imp` object that matches `bid.impid`; + - `bidRequest`: the Prebid.js bid request object that was used to generate `context.imp`; + - `ortbRequest`: the `request` argument passed to `fromORTB`; + - `ortbResponse`: the `response` argument passed to `fromORTB`. + +#### Example: setting a custom outstream renderer + +```javascript +const converter = ortbConverter({ + bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); + const {bidRequest} = context; + if (bidResponse.mediaType === VIDEO && bidRequest.mediaTypes.video.context === 'outstream') { + bidResponse.renderer = Renderer.install({ + url: RENDERER_URL, + id: bidRequest.bidId, + adUnitCode: bidRequest.adUnitCode + }); + } + return bidResponse; + } +}) +``` + +#### Example: setting response mediaType + +In ORTB 2.5, bid responses do not specify their mediatype, which is something Prebid.js requires. You can provide it as +`context.mediaType`: + +```javascript +const converter = ortbConverter({ + bidResponse(buildBidResponse, bid, context) { + context.mediaType = deepAccess(bid, 'ext.mediaType'); + return buildBidResponse(bid, context) + } +}) +``` + +If you know that a particular ORTB request/response pair deals with exclusively one mediaType, you may also pass it directly in the [context parameter](#context). +Note that - compared to the above - this has additional effects, because `context.mediaType` is also considered during `imp` generation - see [special context properties](#special-context). + +```javascript +converter.toORTB({ + bidRequests: bidRequests.filter(isVideoBid), + bidderRequest, + context: {mediaType: 'video'} // make everything in this request/response deal with video only +}) +``` + +Note that this will _not_ work as intended: + +```javascript + +const converter = ortbConverter({ + bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); // this throws; buildBidResponse needs to know the + // mediaType to properly populate bidResponse.ad, + // bidResponse.native etc + bidResponse.mediaType = deepAccess(bid, 'ext.mediaType'); // too late, use context.mediaType + return bidResponse; + } +}); + +``` + +### Customizing the response: `response(buildResponse, bidResponses, ortbResponse, context)` + +Invoked once, after all `seatbid[].bid[]` objects have been converted to corresponding bid responses. The value returned +by this function is also the value returned by `fromORTB`. +The arguments are: + +- `buildResponse`: a function that takes `(bidResponses, ortbResponse, context)` and returns `{bids: bidResponses}`. In the future, this may contain additional response data not necessarily tied to any bid (for example fledge auction configuration). +- `bidResponses`: array of Prebid.js bid response objects +- `ortbResponse`: the `response` argument passed to `fromORTB` +- `context`: a [context object](#context) that contains at least: + - `ortbRequest`: the `request` argument passed to `fromORTB`; + - `bidderRequest`: the `bidderRequest` argument passed to `toORTB`; + - `bidRequests`: the `bidRequests` argument passed to `toORTB`. + +#### Example: logging server-side errors + +```javascript +const converter = ortbConverter({ + response(buildResponse, bidResponses, ortbResponse, context) { + (deepAccess(ortbResponse, 'ext.errors') || []).forEach((e) => logWarn('Server error', e)); + return buildResponse(bidResponses, ortbResponse, context); + } +}) +``` + +### Even finer grained customization - processor overrides + +Each of the four conversion steps described above - imp, request, bidResponse and response - is further broken down into +smaller units of work (called _processors_). For example, when the currency module is included, it adds a _request processor_ +that sets `request.cur`; the priceFloors module adds an _imp processor_ that sets `imp.bidfloor` and `imp.bidfloorcur`, and so on. + +Each processor can be overridden or disabled through the `overrides` argument: + +#### Example: disabling currency +```javascript +const converter = ortbConverter({ + overrides: { + request: { + currency: false + } + } +}) +``` + +The above is similar in effect to: + +```javascript +const converter = ortbConverter({ + request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + delete request.cur; + return request; + } +}) +``` + +With the main difference being that setting `currency: false` will disable currency logic entirely, while the `request` +version will still set `request.cur`, then delete it. If the currency processor is ever updated to deal with more than just `request.cur`, the `request` +function will also need to be updated accordingly. + +#### Example: taking video parameters from `bidRequest.params.video` + +Processors can also be overridden: + +```javascript +const converter = ortbConverter({ + overrides: { + imp: { + video(orig, imp, bidRequest, context) { + // `orig` is the video imp processor, which looks at bidRequest.mediaTypes[VIDEO] + // to populate imp.video + // alter its input `bidRequest` to also pick up parameters from `bidRequest.params` + let videoParams = bidRequest.mediaTypes[VIDEO]; + if (videoParams) { + videoParams = Object.assign({}, videoParams, bidRequest.params.video); + bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}} + } + orig(imp, bidRequest, context); + } + } + } +}); +``` + +#### Processor override functions + +Processor overrides are similar to the override options described above, except that they take the object to process as argument: + +- `imp` processor overrides take `(orig, imp, bidRequest, context)`, where: + - `orig` is the processor function being overridden, which itself takes `(imp, bidRequest, context)`; + - `imp` is the (partial) imp object to modify; + - `bidRequest` and `context` are the same arguments passed to [imp](#imp). +- `request` processor overrides take `(orig, ortbRequest, bidderRequest, context)`, where: + - `orig` is the processor function being overridden, and takes `(ortbRequest, bidderRequest, context)`; + - `ortbRequest` is the partial request to modify; + - `bidderRequest` and `context` are the same arguments passed to [request](#reuqest). +- `bidResponse` processor overrides take `(orig, bidResponse, bid, context)`, where: + - `orig` is the processor function being overridden, and takes `(bidResponse, bid, context)`; + - `bidResponse` is the partial bid response to modify; + - `bid` and `context` are the same arguments passed to [bidResponse](#bidResponse) +- `response` processor overrides take `(orig, response, ortbResponse, context)`, where: + - `orig` is the processor function being overriden, and takes `(response, ortbResponse, context)`; + - `response` is the partial response to modify; + - `ortbRespones` and `context` are the same arguments passed to [response](#response). + +### The `context` argument + +All customization functions take a `context` argument. This is a plain JS object that is shared between `request` and its corresponding `response`; and between `imp` and its corresponding `bidResponse`: + +```javascript +const converter = ortbConverter({ + imp(buildImp, bidRequest, context) { + // `context` here will be later passed to `bidResponse` (if one matches the imp generated here) + context.someData = somethingInterestingAbout(bidRequest); + return buildImp(bidRequest, context); + }, + bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); + doSomethingWith(context.someData); + return bidResponse; + } +}) +``` + +`ortbConverter` automatically populates `context` with some values of interest, such as `bidRequest`, `bidderRequest`, etc - as detailed above. In addition, you may pass additional context properties through: + +- the `context` argument of `ortbConverter`: e.g. `ortbConverter({context: {ttl: 30}})`. This will set `context.ttl = 30` globally for the converter. +- the `context` argument of `toORTB`: e.g. `converter.toORTB({bidRequests, bidderRequest, context: {ttl: 30}})`. This will set `context.ttl = 30` only for this request. + +### Special `context` properties + +For ease of use, the conversion logic gives special meaning to some context properties: + + - `currency`: a currency string (e.g. `'EUR'`). If specified, overrides the currency to use for computing price floors and `request.cur`. If omitted, both default to `getConfig('currency.adServerCurrency')`. + - `mediaType`: a bid mediaType (`'banner'`, `'video'`, or `'native'`). If specified: + - disables `imp` generation for other media types (i.e., if `context.mediaType === 'banner'`, only `imp.banner` will be populated; `imp.video` and `imp.native` will not, even if the bid request specifies them); + - is passed as the `mediaType` option to `bidRequest.getFloor` when computing price floors; + - sets `bidResponse.mediaType`. + - `nativeRequest`: a plain object that serves as the base value for `imp.native.request` (and is relevant only for native bid requests). + If not specified, the only property that is guaranteed to be populated is `assets`, since Prebid does not require anything else to define a native adUnit. You can use `context.nativeRequest` to provide other properties; for example, you may want to signal support for native impression trackers by setting it to `{eventtrackers: [{event: 1, methods: [1, 2]}]}` (see also the [ORTB Native spec](https://www.iab.com/wp-content/uploads/2018/03/OpenRTB-Native-Ads-Specification-Final-1.2.pdf)). + - `netRevenue`: the value to set as `bidResponse.netRevenue`. This is a required property of bid responses that does not have a clear ORTB counterpart. + - `ttl`: the default value to use for `bidResponse.ttl` (if the ORTB response does not provide one in `seatbid[].bid[].exp`). + +## Prebid Server extensions + +If your endpoint is a Prebid Server instance, you may take advantage of the `pbsExtension` companion library, which adds a number of processors that can populate and parse PBS-specific extensions (typically prefixed `ext.prebid`); these include bidder params (with `transformBidParams`), bidder aliases, targeting keys, and others. + +```javascript +import {pbsExtensions} from '../../libraries/pbsExtensions/pbsExtensions.js' + +const pbsConverter = ortbConverter({ + processors: pbsExtensions +}) +``` diff --git a/libraries/ortbConverter/converter.js b/libraries/ortbConverter/converter.js new file mode 100644 index 00000000000..c367aec268a --- /dev/null +++ b/libraries/ortbConverter/converter.js @@ -0,0 +1,136 @@ +import {compose} from './lib/composer.js'; +import {logError, memoize} from '../../src/utils.js'; +import {DEFAULT_PROCESSORS} from './processors/default.js'; +import {BID_RESPONSE, DEFAULT, getProcessors, IMP, REQUEST, RESPONSE} from '../../src/pbjsORTB.js'; +import {mergeProcessors} from './lib/mergeProcessors.js'; + +export function ortbConverter({ + context: defaultContext = {}, + processors = defaultProcessors, + overrides = {}, + imp, + request, + bidResponse, + response, +} = {}) { + const REQ_CTX = new WeakMap(); + + function builder(slot, wrapperFn, builderFn, errorHandler) { + let build; + return function () { + if (build == null) { + build = (function () { + let delegate = builderFn.bind(this, compose(processors()[slot] || {}, overrides[slot] || {})); + if (wrapperFn) { + delegate = wrapperFn.bind(this, delegate); + } + return function () { + try { + return delegate.apply(this, arguments); + } catch (e) { + errorHandler.call(this, e, ...arguments); + } + } + })(); + } + return build.apply(this, arguments); + } + } + + const buildImp = builder(IMP, imp, + function (process, bidRequest, context) { + const imp = {}; + process(imp, bidRequest, context); + return imp; + }, + function (error, bidRequest, context) { + logError('Error while converting bidRequest to ORTB imp; request skipped.', {error, bidRequest, context}); + } + ); + + const buildRequest = builder(REQUEST, request, + function (process, imps, bidderRequest, context) { + const ortbRequest = {imp: imps}; + process(ortbRequest, bidderRequest, context); + return ortbRequest; + }, + function (error, imps, bidderRequest, context) { + logError('Error while converting to ORTB request', {error, imps, bidderRequest, context}); + throw error; + } + ); + + const buildBidResponse = builder(BID_RESPONSE, bidResponse, + function (process, bid, context) { + const bidResponse = {}; + process(bidResponse, bid, context); + return bidResponse; + }, + function (error, bid, context) { + logError('Error while converting ORTB seatbid.bid to bidResponse; bid skipped.', {error, bid, context}); + } + ); + + const buildResponse = builder(RESPONSE, response, + function (process, bidResponses, ortbResponse, context) { + const response = {bids: bidResponses}; + process(response, ortbResponse, context); + return response; + }, + function (error, bidResponses, ortbResponse, context) { + logError('Error while converting from ORTB response', {error, bidResponses, ortbResponse, context}); + throw error; + } + ); + + return { + toORTB({bidderRequest, bidRequests, context = {}}) { + bidRequests = bidRequests || bidderRequest.bids; + const ctx = { + req: Object.assign({bidRequests}, defaultContext, context), + imp: {} + } + ctx.req.impContext = ctx.imp; + const imps = bidRequests.map(bidRequest => { + const impContext = Object.assign({bidderRequest, reqContext: ctx.req}, defaultContext, context); + const result = buildImp(bidRequest, impContext); + if (result != null) { + if (result.hasOwnProperty('id')) { + Object.assign(impContext, {bidRequest, imp: result}); + ctx.imp[result.id] = impContext; + return result; + } + logError('Converted ORTB imp does not specify an id, ignoring bid request', bidRequest, result); + } + }).filter(Boolean); + + const request = buildRequest(imps, bidderRequest, ctx.req); + ctx.req.bidderRequest = bidderRequest; + if (request != null) { + REQ_CTX.set(request, ctx); + } + return request; + }, + fromORTB({request, response}) { + const ctx = REQ_CTX.get(request); + if (ctx == null) { + throw new Error('ortbRequest passed to `fromORTB` must be the same object returned by `toORTB`') + } + function augmentContext(ctx, extraParams = {}) { + return Object.assign(ctx, {ortbRequest: request}, extraParams, ctx); + } + const impsById = Object.fromEntries((request.imp || []).map(imp => [imp.id, imp])); + const bidResponses = (response.seatbid || []).flatMap(seatbid => + (seatbid.bid || []).map((bid) => { + if (impsById.hasOwnProperty(bid.impid) && ctx.imp.hasOwnProperty(bid.impid)) { + return buildBidResponse(bid, augmentContext(ctx.imp[bid.impid], {imp: impsById[bid.impid], seatbid, ortbResponse: response})); + } + logError('ORTB response seatbid[].bid[].impid does not match any imp in request; ignoring bid', bid); + }) + ).filter(Boolean); + return buildResponse(bidResponses, response, augmentContext(ctx.req)); + } + } +} + +export const defaultProcessors = memoize(() => mergeProcessors(DEFAULT_PROCESSORS, getProcessors(DEFAULT))); diff --git a/libraries/ortbConverter/lib/composer.js b/libraries/ortbConverter/lib/composer.js new file mode 100644 index 00000000000..0ceff7f9edb --- /dev/null +++ b/libraries/ortbConverter/lib/composer.js @@ -0,0 +1,43 @@ +const SORTED = new WeakMap(); + +/** + * @typedef {Object} Component + * A component function, that can be composed with other compatible functions into one. + * Compatible functions take the same arguments; return values are ignored. + * + * @property {function} fn the component function; + * @property {number} priority determines the order in which this function will run when composed with others. + */ + +/** + * + * @param {Object[string, Component]} components to compose + * @param {Object[string, function|boolean]} overrides a map from component name, to a function that should override that component. + * Override functions are replacements, except that they get the original function they are overriding as their first argument. If the override + * is `false`, the component is disabled. + * + * @return a function that will run all components in order of priority, with functions from `overrides` taking + * precedence over components that match names + */ +export function compose(components, overrides = {}) { + if (!SORTED.has(components)) { + const sorted = Object.entries(components); + sorted.sort((a, b) => { + a = a[1].priority || 0; + b = b[1].priority || 0; + return a === b ? 0 : a > b ? -1 : 1 + }); + SORTED.set(components, sorted.map(([name, cmp]) => [name, cmp.fn])) + } + const fns = SORTED.get(components) + .filter(([name]) => !overrides.hasOwnProperty(name) || overrides[name]) + .map(function ([name, fn]) { + return overrides.hasOwnProperty(name) ? overrides[name].bind(this, fn) : fn; + }); + return function () { + const args = Array.from(arguments); + fns.forEach(fn => { + fn.apply(this, args); + }) + } +} diff --git a/libraries/ortbConverter/lib/mergeProcessors.js b/libraries/ortbConverter/lib/mergeProcessors.js new file mode 100644 index 00000000000..357cecd45aa --- /dev/null +++ b/libraries/ortbConverter/lib/mergeProcessors.js @@ -0,0 +1,9 @@ +import {PROCESSOR_TYPES} from '../../../src/pbjsORTB.js'; + +export function mergeProcessors(...processors) { + const left = processors.shift(); + const right = processors.length > 1 ? mergeProcessors(...processors) : processors[0]; + return Object.fromEntries( + PROCESSOR_TYPES.map(type => [type, Object.assign({}, left[type], right[type])]) + ) +} diff --git a/libraries/ortbConverter/lib/sizes.js b/libraries/ortbConverter/lib/sizes.js new file mode 100644 index 00000000000..16b75048203 --- /dev/null +++ b/libraries/ortbConverter/lib/sizes.js @@ -0,0 +1,14 @@ +import {parseSizesInput} from '../../../src/utils.js'; + +export function sizesToFormat(sizes) { + sizes = parseSizesInput(sizes); + + // get sizes in form [{ w: , h: }, ...] + return sizes.map(size => { + const [width, height] = size.split('x'); + return { + w: parseInt(width, 10), + h: parseInt(height, 10) + }; + }); +} diff --git a/libraries/ortbConverter/processors/banner.js b/libraries/ortbConverter/processors/banner.js new file mode 100644 index 00000000000..51c93b652ef --- /dev/null +++ b/libraries/ortbConverter/processors/banner.js @@ -0,0 +1,40 @@ +import {createTrackPixelHtml, deepAccess, inIframe, mergeDeep} from '../../../src/utils.js'; +import {BANNER} from '../../../src/mediaTypes.js'; +import {sizesToFormat} from '../lib/sizes.js'; + +/** + * fill in a request `imp` with banner parameters from `bidRequest`. + */ +export function fillBannerImp(imp, bidRequest, context) { + if (context.mediaType && context.mediaType !== BANNER) return; + + const bannerParams = deepAccess(bidRequest, 'mediaTypes.banner'); + if (bannerParams) { + const banner = { + topframe: inIframe() === true ? 0 : 1 + }; + if (bannerParams.sizes) { + banner.format = sizesToFormat(bannerParams.sizes); + } + if (bannerParams.hasOwnProperty('pos')) { + banner.pos = bannerParams.pos; + } + + imp.banner = mergeDeep(banner, imp.banner); + } +} + +export function bannerResponseProcessor({createPixel = (url) => createTrackPixelHtml(decodeURIComponent(url))} = {}) { + return function fillBannerResponse(bidResponse, bid) { + if (bidResponse.mediaType === BANNER) { + if (bid.adm && bid.nurl) { + bidResponse.ad = bid.adm; + bidResponse.ad += createPixel(bid.nurl); + } else if (bid.adm) { + bidResponse.ad = bid.adm; + } else if (bid.nurl) { + bidResponse.adUrl = bid.nurl; + } + } + }; +} diff --git a/libraries/ortbConverter/processors/default.js b/libraries/ortbConverter/processors/default.js new file mode 100644 index 00000000000..8db2c1c461e --- /dev/null +++ b/libraries/ortbConverter/processors/default.js @@ -0,0 +1,125 @@ +import {generateUUID, mergeDeep} from '../../../src/utils.js'; +import {bannerResponseProcessor, fillBannerImp} from './banner.js'; +import {fillVideoImp, fillVideoResponse} from './video.js'; +import {setResponseMediaType} from './mediaType.js'; +import {fillNativeImp, fillNativeResponse} from './native.js'; +import {BID_RESPONSE, IMP, REQUEST} from '../../../src/pbjsORTB.js'; +import {clientSectionChecker} from '../../../src/fpd/oneClient.js'; + +export const DEFAULT_PROCESSORS = { + [REQUEST]: { + fpd: { + // sets initial request to bidderRequest.ortb2 + priority: 99, + fn(ortbRequest, bidderRequest) { + mergeDeep(ortbRequest, bidderRequest.ortb2) + } + }, + onlyOneClient: { + // make sure only one of 'dooh', 'app', 'site' is set in request + priority: -99, + fn: clientSectionChecker('ORTB request') + }, + props: { + // sets request properties id, tmax, test + fn(ortbRequest, bidderRequest) { + Object.assign(ortbRequest, { + id: ortbRequest.id || generateUUID(), + test: ortbRequest.test || 0 + }); + const timeout = parseInt(bidderRequest.timeout, 10); + if (!isNaN(timeout)) { + ortbRequest.tmax = timeout; + } + } + } + }, + [IMP]: { + fpd: { + // sets initial imp to bidRequest.ortb2Imp + priority: 99, + fn(imp, bidRequest) { + mergeDeep(imp, bidRequest.ortb2Imp); + } + }, + id: { + // sets imp.id + fn(imp, bidRequest) { + imp.id = bidRequest.bidId; + } + }, + banner: { + // populates imp.banner + fn: fillBannerImp + }, + pbadslot: { + // removes imp.ext.data.pbaslot if it's not a string + // TODO: is this needed? + fn(imp) { + const pbadslot = imp.ext?.data?.pbadslot; + if (!pbadslot || typeof pbadslot !== 'string') { + delete imp.ext?.data?.pbadslot; + } + } + } + }, + [BID_RESPONSE]: { + mediaType: { + // sets bidResponse.mediaType from context.mediaType, falling back to seatbid.bid[].mtype + priority: 99, + fn: setResponseMediaType + }, + banner: { + // sets banner response attributes if bidResponse.mediaType === BANNER + fn: bannerResponseProcessor(), + }, + props: { + // sets base bidResponse properties common to all types of bids + fn(bidResponse, bid, context) { + Object.entries({ + requestId: context.bidRequest?.bidId, + seatBidId: bid.id, + cpm: bid.price, + currency: context.ortbResponse.cur || context.currency, + width: bid.w, + height: bid.h, + dealId: bid.dealid, + creative_id: bid.crid, + creativeId: bid.crid, + burl: bid.burl, + ttl: bid.exp || context.ttl, + netRevenue: context.netRevenue, + }).filter(([k, v]) => typeof v !== 'undefined') + .forEach(([k, v]) => bidResponse[k] = v); + if (!bidResponse.meta) { + bidResponse.meta = {}; + } + if (bid.adomain) { + bidResponse.meta.advertiserDomains = bid.adomain; + } + } + } + } +} + +if (FEATURES.NATIVE) { + DEFAULT_PROCESSORS[IMP].native = { + // populates imp.native + fn: fillNativeImp + } + DEFAULT_PROCESSORS[BID_RESPONSE].native = { + // populates bidResponse.native if bidResponse.mediaType === NATIVE + fn: fillNativeResponse + } +} + +if (FEATURES.VIDEO) { + DEFAULT_PROCESSORS[IMP].video = { + // populates imp.video + fn: fillVideoImp + } + DEFAULT_PROCESSORS[BID_RESPONSE].video = { + // sets video response attributes if bidResponse.mediaType === VIDEO + fn: fillVideoResponse + } +} diff --git a/libraries/ortbConverter/processors/mediaType.js b/libraries/ortbConverter/processors/mediaType.js new file mode 100644 index 00000000000..67232b3ca44 --- /dev/null +++ b/libraries/ortbConverter/processors/mediaType.js @@ -0,0 +1,21 @@ +import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js'; + +export const ORTB_MTYPES = { + 1: BANNER, + 2: VIDEO, + 4: NATIVE +} + +/** + * Sets response mediaType, using ORTB 2.6 `seatbid.bid[].mtype`. + * + * Note that this will throw away bids if there is no `mtype` in the response. + */ +export function setResponseMediaType(bidResponse, bid, context) { + if (bidResponse.mediaType) return; + const mediaType = context.mediaType; + if (!mediaType && !ORTB_MTYPES.hasOwnProperty(bid.mtype)) { + throw new Error('Cannot determine mediaType for response') + } + bidResponse.mediaType = mediaType || ORTB_MTYPES[bid.mtype]; +} diff --git a/libraries/ortbConverter/processors/native.js b/libraries/ortbConverter/processors/native.js new file mode 100644 index 00000000000..ff231ce2b55 --- /dev/null +++ b/libraries/ortbConverter/processors/native.js @@ -0,0 +1,37 @@ +import {isPlainObject, logWarn, mergeDeep} from '../../../src/utils.js'; +import {NATIVE} from '../../../src/mediaTypes.js'; + +export function fillNativeImp(imp, bidRequest, context) { + if (context.mediaType && context.mediaType !== NATIVE) return; + let nativeReq = bidRequest.nativeOrtbRequest; + if (nativeReq) { + nativeReq = Object.assign({}, context.nativeRequest, nativeReq); + if (nativeReq.assets?.length) { + imp.native = mergeDeep({}, { + request: JSON.stringify(nativeReq), + ver: nativeReq.ver + }, imp.native) + } else { + logWarn('mediaTypes.native is set, but no assets were specified. Native request skipped.', bidRequest) + } + } +} + +export function fillNativeResponse(bidResponse, bid) { + if (bidResponse.mediaType === NATIVE) { + let ortb; + if (typeof bid.adm === 'string') { + ortb = JSON.parse(bid.adm); + } else { + ortb = bid.adm; + } + + if (isPlainObject(ortb) && Array.isArray(ortb.assets)) { + bidResponse.native = { + ortb, + } + } else { + throw new Error('ORTB native response contained no assets'); + } + } +} diff --git a/libraries/ortbConverter/processors/video.js b/libraries/ortbConverter/processors/video.js new file mode 100644 index 00000000000..c38231d9002 --- /dev/null +++ b/libraries/ortbConverter/processors/video.js @@ -0,0 +1,67 @@ +import {deepAccess, isEmpty, logWarn, mergeDeep} from '../../../src/utils.js'; +import {VIDEO} from '../../../src/mediaTypes.js'; +import {sizesToFormat} from '../lib/sizes.js'; + +// parameters that share the same name & semantics between pbjs adUnits and imp.video +const ORTB_VIDEO_PARAMS = new Set([ + 'pos', + 'placement', + 'plcmt', + 'api', + 'mimes', + 'protocols', + 'playbackmethod', + 'minduration', + 'maxduration', + 'w', + 'h', + 'startdelay', + 'placement', + 'linearity', + 'skip', + 'skipmin', + 'skipafter', + 'minbitrate', + 'maxbitrate', + 'delivery', + 'playbackend' +]); + +const PLACEMENT = { + 'instream': 1, +} + +export function fillVideoImp(imp, bidRequest, context) { + if (context.mediaType && context.mediaType !== VIDEO) return; + + const videoParams = deepAccess(bidRequest, 'mediaTypes.video'); + if (!isEmpty(videoParams)) { + const video = Object.fromEntries( + Object.entries(videoParams) + .filter(([name]) => ORTB_VIDEO_PARAMS.has(name)) + ); + if (videoParams.playerSize) { + const format = sizesToFormat(videoParams.playerSize); + if (format.length > 1) { + logWarn('video request specifies more than one playerSize; all but the first will be ignored') + } + Object.assign(video, format[0]); + } + const placement = PLACEMENT[videoParams.context]; + if (placement != null) { + video.placement = placement; + } + imp.video = mergeDeep(video, imp.video); + } +} + +export function fillVideoResponse(bidResponse, seatbid, context) { + if (bidResponse.mediaType === VIDEO) { + if (deepAccess(context.imp, 'video.w') && deepAccess(context.imp, 'video.h')) { + [bidResponse.playerWidth, bidResponse.playerHeight] = [context.imp.video.w, context.imp.video.h]; + } + + if (seatbid.adm) { bidResponse.vastXml = seatbid.adm; } + if (seatbid.nurl) { bidResponse.vastUrl = seatbid.nurl; } + } +} diff --git a/libraries/pbsExtensions/pbsExtensions.js b/libraries/pbsExtensions/pbsExtensions.js new file mode 100644 index 00000000000..1efded6173f --- /dev/null +++ b/libraries/pbsExtensions/pbsExtensions.js @@ -0,0 +1,12 @@ +import {mergeProcessors} from '../ortbConverter/lib/mergeProcessors.js'; +import {PBS_PROCESSORS} from './processors/pbs.js'; +import {getProcessors, PBS} from '../../src/pbjsORTB.js'; +import {defaultProcessors} from '../ortbConverter/converter.js'; +import {memoize} from '../../src/utils.js'; + +/** + * ORTB converter processor set that understands Prebid Server extensions. + * + * Pass this as the `processors` option to `ortbConverter` if your backend is a PBS instance. + */ +export const pbsExtensions = memoize(() => mergeProcessors(defaultProcessors(), PBS_PROCESSORS, getProcessors(PBS))); diff --git a/libraries/pbsExtensions/processors/adUnitCode.js b/libraries/pbsExtensions/processors/adUnitCode.js new file mode 100644 index 00000000000..f936e0f662f --- /dev/null +++ b/libraries/pbsExtensions/processors/adUnitCode.js @@ -0,0 +1,13 @@ +import {deepSetValue} from '../../../src/utils.js'; + +export function setImpAdUnitCode(imp, bidRequest) { + const adUnitCode = bidRequest.adUnitCode; + + if (adUnitCode) { + deepSetValue( + imp, + `ext.prebid.adunitcode`, + adUnitCode + ); + } +} diff --git a/libraries/pbsExtensions/processors/aliases.js b/libraries/pbsExtensions/processors/aliases.js new file mode 100644 index 00000000000..3dcd2c4fd9b --- /dev/null +++ b/libraries/pbsExtensions/processors/aliases.js @@ -0,0 +1,17 @@ +import adapterManager from '../../../src/adapterManager.js'; +import {deepSetValue} from '../../../src/utils.js'; + +export function setRequestExtPrebidAliases(ortbRequest, bidderRequest, context, {am = adapterManager} = {}) { + if (am.aliasRegistry[bidderRequest.bidderCode]) { + const bidder = am.bidderRegistry[bidderRequest.bidderCode]; + // adding alias only if alias source bidder exists and alias isn't configured to be standalone + // pbs adapter + if (!bidder || !bidder.getSpec().skipPbsAliasing) { + deepSetValue( + ortbRequest, + `ext.prebid.aliases.${bidderRequest.bidderCode}`, + am.aliasRegistry[bidderRequest.bidderCode] + ); + } + } +} diff --git a/libraries/pbsExtensions/processors/mediaType.js b/libraries/pbsExtensions/processors/mediaType.js new file mode 100644 index 00000000000..cbcf9a013b1 --- /dev/null +++ b/libraries/pbsExtensions/processors/mediaType.js @@ -0,0 +1,23 @@ +import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js'; +import {ORTB_MTYPES} from '../../ortbConverter/processors/mediaType.js'; + +export const SUPPORTED_MEDIA_TYPES = { + // map from pbjs mediaType to its corresponding imp property + [BANNER]: 'banner', + [NATIVE]: 'native', + [VIDEO]: 'video' +} + +/** + * Sets bidResponse.mediaType, using ORTB 2.6 `seatbid.bid[].mtype`, falling back to `ext.prebid.type`, falling back to 'banner'. + */ +export function extPrebidMediaType(bidResponse, bid, context) { + let mediaType = context.mediaType; + if (!mediaType) { + mediaType = ORTB_MTYPES.hasOwnProperty(bid.mtype) ? ORTB_MTYPES[bid.mtype] : bid.ext?.prebid?.type + if (!SUPPORTED_MEDIA_TYPES.hasOwnProperty(mediaType)) { + mediaType = BANNER; + } + } + bidResponse.mediaType = mediaType; +} diff --git a/libraries/pbsExtensions/processors/params.js b/libraries/pbsExtensions/processors/params.js new file mode 100644 index 00000000000..010ffa5b372 --- /dev/null +++ b/libraries/pbsExtensions/processors/params.js @@ -0,0 +1,22 @@ +import {auctionManager} from '../../../src/auctionManager.js'; +import adapterManager from '../../../src/adapterManager.js'; +import {deepSetValue} from '../../../src/utils.js'; + +export function setImpBidParams( + imp, bidRequest, context, + {adUnit, bidderRequests, index = auctionManager.index, bidderRegistry = adapterManager.bidderRegistry} = {}) { + let params = bidRequest.params; + const adapter = bidderRegistry[bidRequest.bidder]; + if (adapter && adapter.getSpec().transformBidParams) { + adUnit = adUnit || index.getAdUnit(bidRequest); + bidderRequests = bidderRequests || [context.bidderRequest]; + params = adapter.getSpec().transformBidParams(params, true, adUnit, bidderRequests); + } + if (params) { + deepSetValue( + imp, + `ext.prebid.bidder.${bidRequest.bidder}`, + params + ); + } +} diff --git a/libraries/pbsExtensions/processors/pbs.js b/libraries/pbsExtensions/processors/pbs.js new file mode 100644 index 00000000000..0ed2d12fad8 --- /dev/null +++ b/libraries/pbsExtensions/processors/pbs.js @@ -0,0 +1,104 @@ +import {BID_RESPONSE, IMP, REQUEST, RESPONSE} from '../../../src/pbjsORTB.js'; +import {deepAccess, isPlainObject, isStr, mergeDeep} from '../../../src/utils.js'; +import {extPrebidMediaType} from './mediaType.js'; +import {setRequestExtPrebidAliases} from './aliases.js'; +import {setImpBidParams} from './params.js'; +import {setImpAdUnitCode} from './adUnitCode.js'; +import {setRequestExtPrebid, setRequestExtPrebidChannel} from './requestExtPrebid.js'; +import {setBidResponseVideoCache} from './video.js'; + +export const PBS_PROCESSORS = { + [REQUEST]: { + extPrebid: { + // set request.ext.prebid.auctiontimestamp, .debug and .targeting + fn: setRequestExtPrebid + }, + extPrebidChannel: { + // sets request.ext.prebid.channel + fn: setRequestExtPrebidChannel + }, + extPrebidAliases: { + // sets ext.prebid.aliases + fn: setRequestExtPrebidAliases + } + }, + [IMP]: { + params: { + // sets bid ext.prebid.bidder.[bidderCode] with bidRequest.params, passed through transformBidParams if necessary + fn: setImpBidParams + }, + adUnitCode: { + // sets bid ext.prebid.adunitcode + fn: setImpAdUnitCode + } + }, + [BID_RESPONSE]: { + mediaType: { + // sets bidResponse.mediaType according to context.mediaType, falling back to imp.ext.prebid.type + fn: extPrebidMediaType, + priority: 99, + }, + videoCache: { + // sets response video attributes; in addition, looks at ext.prebid.cache and .targeting to set video cache key and URL + fn: setBidResponseVideoCache, + priority: -10, // after 'video' + }, + bidderCode: { + // sets bidderCode from on seatbid.seat + fn(bidResponse, bid, context) { + bidResponse.bidderCode = context.seatbid.seat; + bidResponse.adapterCode = deepAccess(bid, 'ext.prebid.meta.adaptercode') || context.bidRequest?.bidder || bidResponse.bidderCode; + } + }, + pbsBidId: { + // sets bidResponse.pbsBidId from ext.prebid.bidid + fn(bidResponse, bid) { + const bidId = deepAccess(bid, 'ext.prebid.bidid'); + if (isStr(bidId)) { + bidResponse.pbsBidId = bidId; + } + } + }, + adserverTargeting: { + // sets bidResponse.adserverTargeting from ext.prebid.targeting + fn(bidResponse, bid) { + const targeting = deepAccess(bid, 'ext.prebid.targeting'); + if (isPlainObject(targeting)) { + bidResponse.adserverTargeting = targeting; + } + } + }, + extPrebidMeta: { + // sets bidResponse.meta from ext.prebid.meta + fn(bidResponse, bid) { + bidResponse.meta = mergeDeep({}, deepAccess(bid, 'ext.prebid.meta'), bidResponse.meta); + } + }, + pbsWurl: { + // sets bidResponse.pbsWurl from ext.prebid.events.win + fn(bidResponse, bid) { + const wurl = deepAccess(bid, 'ext.prebid.events.win'); + if (isStr(wurl)) { + bidResponse.pbsWurl = wurl; + } + } + }, + }, + [RESPONSE]: { + serverSideStats: { + // updates bidderRequest and bidRequests with serverErrors from ext.errors and serverResponseTimeMs from ext.responsetimemillis + fn(response, ortbResponse, context) { + Object.entries({ + errors: 'serverErrors', + responsetimemillis: 'serverResponseTimeMs' + }).forEach(([serverName, clientName]) => { + const value = deepAccess(ortbResponse, `ext.${serverName}.${context.bidderRequest.bidderCode}`); + if (value) { + context.bidderRequest[clientName] = value; + context.bidRequests.forEach(bid => bid[clientName] = value); + } + }) + } + }, + } +} diff --git a/libraries/pbsExtensions/processors/requestExtPrebid.js b/libraries/pbsExtensions/processors/requestExtPrebid.js new file mode 100644 index 00000000000..bbb6add45ce --- /dev/null +++ b/libraries/pbsExtensions/processors/requestExtPrebid.js @@ -0,0 +1,30 @@ +import {deepSetValue, mergeDeep} from '../../../src/utils.js'; +import {config} from '../../../src/config.js'; +import {getGlobal} from '../../../src/prebidGlobal.js'; + +export function setRequestExtPrebid(ortbRequest, bidderRequest) { + deepSetValue( + ortbRequest, + 'ext.prebid', + mergeDeep( + { + auctiontimestamp: bidderRequest.auctionStart, + targeting: { + includewinners: true, + includebidderkeys: false + } + }, + ortbRequest.ext?.prebid, + ) + ); + if (config.getConfig('debug')) { + ortbRequest.ext.prebid.debug = true; + } +} + +export function setRequestExtPrebidChannel(ortbRequest) { + deepSetValue(ortbRequest, 'ext.prebid.channel', Object.assign({ + name: 'pbjs', + version: getGlobal().version + }, ortbRequest.ext?.prebid?.channel)); +} diff --git a/libraries/pbsExtensions/processors/video.js b/libraries/pbsExtensions/processors/video.js new file mode 100644 index 00000000000..0a517fd0575 --- /dev/null +++ b/libraries/pbsExtensions/processors/video.js @@ -0,0 +1,23 @@ +import {VIDEO} from '../../../src/mediaTypes.js'; +import {deepAccess} from '../../../src/utils.js'; + +export function setBidResponseVideoCache(bidResponse, bid) { + if (bidResponse.mediaType === VIDEO) { + // try to get cache values from 'response.ext.prebid.cache' + // else try 'bid.ext.prebid.targeting' as fallback + let {cacheId: videoCacheKey, url: vastUrl} = deepAccess(bid, 'ext.prebid.cache.vastXml') || {}; + if (!videoCacheKey || !vastUrl) { + const {hb_uuid: uuid, hb_cache_host: cacheHost, hb_cache_path: cachePath} = deepAccess(bid, 'ext.prebid.targeting') || {}; + if (uuid && cacheHost && cachePath) { + videoCacheKey = uuid; + vastUrl = `https://${cacheHost}${cachePath}?uuid=${uuid}`; + } + } + if (videoCacheKey && vastUrl) { + Object.assign(bidResponse, { + videoCacheKey, + vastUrl + }) + } + } +} diff --git a/libraries/sizeUtils/sizeUtils.js b/libraries/sizeUtils/sizeUtils.js new file mode 100644 index 00000000000..41cdd71df89 --- /dev/null +++ b/libraries/sizeUtils/sizeUtils.js @@ -0,0 +1,29 @@ +/** + * Read an adUnit object and return the sizes used in an [[728, 90]] format (even if they had [728, 90] defined) + * Preference is given to the `adUnit.mediaTypes.banner.sizes` object over the `adUnit.sizes` + * @param {object} adUnit one adUnit object from the normal list of adUnits + * @returns {Array.} array of arrays containing numeric sizes + */ +export function getAdUnitSizes(adUnit) { + if (!adUnit) { + return; + } + + let sizes = []; + if (adUnit.mediaTypes && adUnit.mediaTypes.banner && Array.isArray(adUnit.mediaTypes.banner.sizes)) { + let bannerSizes = adUnit.mediaTypes.banner.sizes; + if (Array.isArray(bannerSizes[0])) { + sizes = bannerSizes; + } else { + sizes.push(bannerSizes); + } + // TODO - remove this else block when we're ready to deprecate adUnit.sizes for bidders + } else if (Array.isArray(adUnit.sizes)) { + if (Array.isArray(adUnit.sizes[0])) { + sizes = adUnit.sizes; + } else { + sizes.push(adUnit.sizes); + } + } + return sizes; +} diff --git a/libraries/transformParamsUtils/convertTypes.js b/libraries/transformParamsUtils/convertTypes.js new file mode 100644 index 00000000000..813d8e6e693 --- /dev/null +++ b/libraries/transformParamsUtils/convertTypes.js @@ -0,0 +1,36 @@ +import {isFn} from '../../src/utils.js'; + +/** + * Try to convert a value to a type. + * If it can't be done, the value will be returned. + * + * @param {string} typeToConvert The target type. e.g. "string", "number", etc. + * @param {*} value The value to be converted into typeToConvert. + */ +function tryConvertType(typeToConvert, value) { + if (typeToConvert === 'string') { + return value && value.toString(); + } else if (typeToConvert === 'number') { + return Number(value); + } else { + return value; + } +} + +export function convertTypes(types, params) { + Object.keys(types).forEach(key => { + if (params[key]) { + if (isFn(types[key])) { + params[key] = types[key](params[key]); + } else { + params[key] = tryConvertType(types[key], params[key]); + } + + // don't send invalid values + if (isNaN(params[key])) { + delete params.key; + } + } + }); + return params; +} diff --git a/libraries/urlUtils/urlUtils.js b/libraries/urlUtils/urlUtils.js new file mode 100644 index 00000000000..f0c5823aab1 --- /dev/null +++ b/libraries/urlUtils/urlUtils.js @@ -0,0 +1,7 @@ +export function tryAppendQueryString(existingUrl, key, value) { + if (value) { + return existingUrl + key + '=' + encodeURIComponent(value) + '&'; + } + + return existingUrl; +} diff --git a/libraries/video/constants/constants.js b/libraries/video/constants/constants.js new file mode 100644 index 00000000000..55e3785ccc2 --- /dev/null +++ b/libraries/video/constants/constants.js @@ -0,0 +1,7 @@ +export const videoKey = 'video'; + +export const PLAYBACK_MODE = { + VOD: 0, + LIVE: 1, + DVR: 2 +}; diff --git a/libraries/video/constants/events.js b/libraries/video/constants/events.js new file mode 100644 index 00000000000..b7932adf621 --- /dev/null +++ b/libraries/video/constants/events.js @@ -0,0 +1,98 @@ +// Life Cycle +export const SETUP_COMPLETE = 'setupComplete'; +export const SETUP_FAILED = 'setupFailed'; +export const DESTROYED = 'destroyed'; + +// Ads +export const AD_REQUEST = 'adRequest'; +export const AD_BREAK_START = 'adBreakStart'; +export const AD_LOADED = 'adLoaded'; +export const AD_STARTED = 'adStarted'; +export const AD_IMPRESSION = 'adImpression'; +export const AD_PLAY = 'adPlay'; +export const AD_TIME = 'adTime'; +export const AD_PAUSE = 'adPause'; +export const AD_CLICK = 'adClick'; +export const AD_SKIPPED = 'adSkipped'; +export const AD_ERROR = 'adError'; +export const AD_COMPLETE = 'adComplete'; +export const AD_BREAK_END = 'adBreakEnd'; + +// Media +export const PLAYLIST = 'playlist'; +export const PLAYBACK_REQUEST = 'playbackRequest'; +export const AUTOSTART_BLOCKED = 'autostartBlocked'; +export const PLAY_ATTEMPT_FAILED = 'playAttemptFailed'; +export const CONTENT_LOADED = 'contentLoaded'; +export const PLAY = 'play'; +export const PAUSE = 'pause'; +export const BUFFER = 'buffer'; +export const TIME = 'time'; +export const SEEK_START = 'seekStart'; +export const SEEK_END = 'seekEnd'; +export const MUTE = 'mute'; +export const VOLUME = 'volume'; +export const RENDITION_UPDATE = 'renditionUpdate'; +export const ERROR = 'error'; +export const COMPLETE = 'complete'; +export const PLAYLIST_COMPLETE = 'playlistComplete'; + +// Layout +export const FULLSCREEN = 'fullscreen'; +export const PLAYER_RESIZE = 'playerResize'; +export const VIEWABLE = 'viewable'; +export const CAST = 'cast'; + +export const allVideoEvents = [ + SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, + AD_IMPRESSION, AD_PLAY, AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, + PLAYBACK_REQUEST, AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, + SEEK_END, MUTE, VOLUME, RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, + CAST +]; + +export const AUCTION_AD_LOAD_ATTEMPT = 'auctionAdLoadAttempt'; +export const AUCTION_AD_LOAD_QUEUED = 'auctionAdLoadQueued'; +export const AUCTION_AD_LOAD_ABORT = 'auctionAdLoadAbort'; +export const BID_IMPRESSION = 'bidImpression'; +export const BID_ERROR = 'bidError'; + +export const videoEvents = { + SETUP_COMPLETE, + SETUP_FAILED, + DESTROYED, + AD_REQUEST, + AD_BREAK_START, + AD_LOADED, + AD_STARTED, + AD_IMPRESSION, + AD_PLAY, + AD_TIME, + AD_PAUSE, + AD_CLICK, + AD_SKIPPED, + AD_ERROR, + AD_COMPLETE, + AD_BREAK_END, + PLAYLIST, + PLAYBACK_REQUEST, + AUTOSTART_BLOCKED, + PLAY_ATTEMPT_FAILED, + CONTENT_LOADED, + PLAY, + PAUSE, + BUFFER, + TIME, + SEEK_START, + SEEK_END, + MUTE, + VOLUME, + RENDITION_UPDATE, + ERROR, + COMPLETE, + PLAYLIST_COMPLETE, + FULLSCREEN, + PLAYER_RESIZE, + VIEWABLE, + CAST, +}; diff --git a/libraries/video/constants/ortb.js b/libraries/video/constants/ortb.js new file mode 100644 index 00000000000..d67c8a5f393 --- /dev/null +++ b/libraries/video/constants/ortb.js @@ -0,0 +1,169 @@ +/** + * @typedef {Object} OrtbParams + * @property {OrtbVideoParamst} video + * @property {OrtbContentParams} content + */ + +/** + * @typedef OrtbVideoParams + * @property {[string]} mimes - Content MIME types supported (e.g., “video/x-ms-wmv”, “video/mp4”). + * @property {number|undefined} minduration - Minimum video ad duration in seconds. + * @property {number|undefined} maxduration - Maximum video ad duration in seconds. + * @property {[number]} protocols - Supported video protocols. At least one supported protocol must be specified. + * @property {number} w - Width of the video player in device independent pixels (DIPS). + * @property {number} h - Height of the video player in device independent pixels (DIPS). + * @property {number|undefined} startdelay - Indicates the offset of the ad placement. + * @property {number|undefined} placement - Placement type for the impression. + * @property {number|undefined} linearity - Indicates if the impression must be linear, nonlinear, etc. If omitted, assume all are allowed. + * @property {number} skip - Indicates if the player can allow the video to be skipped, where 0 is no, 1 is yes. + * @property {number|undefined} skipmin - Only ad creatives with a duration greater than this value can be skippable; only applicable if the ad is skippable. + * @property {number|undefined} skipafter - Number of seconds a video must play before skipping is enabled; only applicable if the ad is skippable. + * @property {number|undefined} sequence - If multiple ad impressions are offered in the same bid request, the sequence number will allow for the coordinated delivery of multiple creatives. + * @property {[number]|undefined} battr - Blocked creative attributes. Use this to indicate which creatives the player does not support. + * @property {number|undefined} maxextended - Maximum extended ad duration if extension is allowed. + * @property {number|undefined} minbitrate - Minimum bit rate in Kbps supported by the player. + * @property {number|undefined} maxbitrate - Maximum bit rate in Kbps supported by the player. + * @property {number|undefined} boxingallowed - Indicates if letter-boxing of 4:3 content into a 16:9 window is allowed. 0 is no, 1 is yes. + * @property {[number]|undefined} playbackmethod - Playback methods that may be in use. + * @property {number|undefined} playbackend - The scenario that causes playback to end. + * @property {[number]|undefined} delivery - Supported delivery methods (e.g., streaming, progressive). + * @property {number|undefined} pos - Ad position on screen. + * @property {[Object]|undefined} companionad - list of companion ads. Refer to Section 3.2.6 of the oRTB v2.5 spec for the interface of the companion ad object. + * @property {[number]|undefined} api - List of supported API frameworks for this impression. + * @property {[number]|undefined} companiontype - Supported VAST companion ad types. Refer to List 5.14 of the oRTB v2.5 spec for the interface. + * @property {Object|undefined} ext - Placeholder for exchange-specific extensions to OpenRTB. + */ + +/** + * @typedef OrtbContentParams + * @property {string} id - ID uniquely identifying the content. + * @property {string} url - URL of the content, for buy-side contextualization or review. + * @property {number|undefined} episode - Episode number. + * @property {string|undefined} title - Content title. + * @property {string|undefined} series - Content series i.e. “The Office” (television), “Star Wars” (movie). + * @property {string|undefined} season - Content season (e.g., “Season 3”). + * @property {string|undefined} artist - Artist credited with the content. + * @property {string|undefined} genre - Genre that best describes the content (e.g., rock, pop, etc). + * @property {string|undefined} album - Album to which the content belongs. Typically for audio. + * @property {string|undefined} isrc - International Standard Recording Code conforming to ISO3901. + * @property {Object|undefined} producer - Details about the content Producer. For Producer interface visit Section 3.2.17 of the oRTB v2.5 spec. + * @property {[string]|undefined} cat - List of IAB content categories that describe the content. Refer to List 5.1. of the oRTB v2.5 spec for the complete list. + * @property {number|undefined} prodq - Production quality. Refer to List 5.13 of the oRTB v2.5 spec. + * @property {number|undefined} context - Type of content (game, video, text, etc.). Refer to List 5.18 of the oRTB v2.5 spec. + * @property {string|undefined} contentrating - Content rating (e.g., MPAA). + * @property {string|undefined} userrating - User rating of the content (e.g., number of stars, likes, etc.). + * @property {number|undefined} qagmediarating - Media rating per IQG guidelines. Refer to List 5.19 of the oRTB v2.5 spec. + * @property {string|undefined} keywords - Comma separated list of keywords describing the content. + * @property {number|undefined} livestream - Whether the stream is live or not. 0 means not live (VOD), 1 means content is live streaming. + * @property {number|undefined} sourcerelationship - 0 means indirect, 1 means direct. + * @property {number} len - Duration of content in seconds. + * @property {string|undefined} language - Content language using ISO-639-1-alpha-2. + * @property {number|undefined} embeddable - Indicator of whether or not the content is embeddable (e.g., an embeddable video player). 0 means no, 1 means yes. + * @property {[Object]|undefined} data - Additional content data. Each Data object represents a different data source. See Section 3.2.21 of the oRTB v2.5 spec. + * @property {Object|undefined} ext - Placeholder for exchange-specific extensions to OpenRTB. + */ + +const VIDEO_PREFIX = 'video/'; +const APPLICATION_PREFIX = 'application/'; + +/** + * ORTB 2.5 section 3.2.7 - Video.mimes + * @enum OrtbVideoParams.mimes + */ +export const VIDEO_MIME_TYPE = { + MP4: VIDEO_PREFIX + 'mp4', + MPEG: VIDEO_PREFIX + 'mpeg', + OGG: VIDEO_PREFIX + 'ogg', + WEBM: VIDEO_PREFIX + 'webm', + AAC: VIDEO_PREFIX + 'aac', + HLS: APPLICATION_PREFIX + 'vnd.apple.mpegurl' +}; + +export const JS_APP_MIME_TYPE = APPLICATION_PREFIX + 'javascript'; +export const VPAID_MIME_TYPE = JS_APP_MIME_TYPE; + +/** + * ORTB 2.5 section 5.9 - Video Placement Types + * @enum OrtbVideoParams.placement + */ +export const PLACEMENT = { + INSTREAM: 1, + BANNER: 2, + ARTICLE: 3, + FEED: 4, + INTERSTITIAL: 5, + SLIDER: 5, + FLOATING: 5, + INTERSTITIAL_SLIDER_FLOATING: 5 +}; + +/** + * ORTB 2.5 section 5.4 - Ad Position + * @enum OrtbVideoParams.pos + */ +export const AD_POSITION = { + UNKNOWN: 0, + ABOVE_THE_FOLD: 1, + BELOW_THE_FOLD: 3, + HEADER: 4, + FOOTER: 5, + SIDEBAR: 6, + FULL_SCREEN: 7 +} + +/** + * ORTB 2.5 section 5.11 - Playback Cessation Modes + * @enum OrtbVideoParams.playbackend + */ +export const PLAYBACK_END = { + VIDEO_COMPLETION: 1, + VIEWPORT_LEAVE: 2, + FLOATING: 3 +} + +/** + * ORTB 2.5 section 5.10 - Playback Methods + * @enum OrtbVideoParams.playbackmethod + */ +export const PLAYBACK_METHODS = { + AUTOPLAY: 1, + AUTOPLAY_MUTED: 2, + CLICK_TO_PLAY: 3, + CLICK_TO_PLAY_MUTED: 4, + VIEWABLE: 5, + VIEWABLE_MUTED: 6 +}; + +/** + * ORTB 2.5 section 5.8 - Protocols + * @enum OrtbVideoParams.protocols + */ +export const PROTOCOLS = { + // VAST_1_0: 1, + VAST_2_0: 2, + VAST_3_0: 3, + // VAST_1_O_WRAPPER: 4, + VAST_2_0_WRAPPER: 5, + VAST_3_0_WRAPPER: 6, + VAST_4_0: 7, + VAST_4_0_WRAPPER: 8 +}; + +/** + * ORTB 2.5 section 5.6 - API Frameworks + * @enum OrtbVideoParams.api + */ +export const API_FRAMEWORKS = { + VPAID_1_0: 1, + VPAID_2_0: 2, + OMID_1_0: 7 +}; + +/** + * ORTB 2.5 section 5.18 - Content Context + * @enum OrtbContentParams.context + */ +export const CONTEXT = { + VIDEO: 1, + AUDIO: 3 +}; diff --git a/libraries/video/constants/vendorCodes.js b/libraries/video/constants/vendorCodes.js new file mode 100644 index 00000000000..370c151b997 --- /dev/null +++ b/libraries/video/constants/vendorCodes.js @@ -0,0 +1,6 @@ +// Video Vendors +export const JWPLAYER_VENDOR = 1; +export const VIDEO_JS_VENDOR = 2; + +// Ad Server Vendors +export const GAM_VENDOR = 'gam'; diff --git a/libraries/video/shared/eventHandler.js b/libraries/video/shared/eventHandler.js new file mode 100644 index 00000000000..ee0d6b2cbfb --- /dev/null +++ b/libraries/video/shared/eventHandler.js @@ -0,0 +1,18 @@ +/** + * Builds a standard event handler + * @param {String} type Event name + * @param {(function(String, Object): Object)} callback Callback defined by publisher to be executed when the event occurs + * @param {Object} payload Base payload defined when the event is registered + * @param {(function(*): Object)|null|undefined} getExtraPayload Parses the player's event payload to return a normalized payload + * @returns {(function(*): void)|*} event handler + */ +export function getEventHandler(type, callback, payload, getExtraPayload) { + return event => { + if (getExtraPayload) { + const extraPayload = getExtraPayload(event); + Object.assign(payload, extraPayload); + } + + callback(type, payload); + }; +} diff --git a/libraries/video/shared/helpers.js b/libraries/video/shared/helpers.js new file mode 100644 index 00000000000..e61fde6a331 --- /dev/null +++ b/libraries/video/shared/helpers.js @@ -0,0 +1,19 @@ +import { videoKey } from '../constants/constants.js' + +export function getExternalVideoEventName(eventName) { + if (!eventName) { + return ''; + } + return videoKey + eventName.replace(/^./, eventName[0].toUpperCase()); +} + +export function getExternalVideoEventPayload(eventName, payload) { + if (!payload) { + payload = {}; + } + + if (!payload.type) { + payload.type = eventName; + } + return payload; +} diff --git a/libraries/video/shared/parentModule.js b/libraries/video/shared/parentModule.js new file mode 100644 index 00000000000..06c71ebd75b --- /dev/null +++ b/libraries/video/shared/parentModule.js @@ -0,0 +1,81 @@ +/** + * @typedef {Object} ParentModule + * @summary abstraction for any module to store and reference its submodules + * @param {SubmoduleBuilder} submoduleBuilder_ + * @returns {ParentModule} + * @constructor + */ +export function ParentModule(submoduleBuilder_) { + const submoduleBuilder = submoduleBuilder_; + const submodules = {}; + + /** + * @function ParentModule#registerSubmodule + * @summary Stores a submodule + * @param {String} id - unique identifier of the submodule instance + * @param {String} vendorCode - identifier to the submodule type that must be built + * @param {Object} config - additional information necessary to instantiate the submodule + */ + function registerSubmodule(id, vendorCode, config) { + if (submodules[id]) { + return; + } + + let submodule; + try { + submodule = submoduleBuilder.build(vendorCode, config); + } catch (e) { + throw e; + } + submodules[id] = submodule; + } + + /** + * @function ParentModule#getSubmodule + * @summary Stores a submodule + * @param {String} id - unique identifier of the submodule instance + * @returns {Object} - a submodule instance + */ + function getSubmodule(id) { + return submodules[id]; + } + + return { + registerSubmodule, + getSubmodule + } +} + +/** + * @typedef {Object} SubmoduleBuilder + * @summary Instantiates submodules + * @param {vendorSubmoduleDirectory} submoduleDirectory_ + * @param {Object|null|undefined} sharedUtils_ + * @returns {SubmoduleBuilder} + * @constructor + */ +export function SubmoduleBuilder(submoduleDirectory_, sharedUtils_) { + const submoduleDirectory = submoduleDirectory_; + const sharedUtils = sharedUtils_; + + /** + * @function SubmoduleBuilder#build + * @param vendorCode - identifier to the submodule type that must be instantiated + * @param config - additional information necessary to instantiate the submodule + * @throws + * @returns {{init}|*} - a submodule instance + */ + function build(vendorCode, config) { + const submoduleFactory = submoduleDirectory[vendorCode]; + if (!submoduleFactory) { + throw new Error('Unrecognized submodule vendor code: ' + vendorCode); + } + + const submodule = submoduleFactory(config, sharedUtils); + return submodule; + } + + return { + build + }; +} diff --git a/libraries/video/shared/state.js b/libraries/video/shared/state.js new file mode 100644 index 00000000000..b84cff8f997 --- /dev/null +++ b/libraries/video/shared/state.js @@ -0,0 +1,47 @@ +/** + * @typedef {Object} State + * @summary simple state object. Can be subclassed + * @function updateState + * @function getState + * @function clearState + */ + +/** + * @summary factory to create a simple state object + * @returns {State} + */ +export default function stateFactory() { + let state = {}; + + /** + * @function State#updateState + * @summary updates the state + * @param {Object} stateUpdate + */ + function updateState(stateUpdate) { + Object.assign(state, stateUpdate); + } + + /** + * @function State#getState + * @summary provides the current state + * @returns {Object} the current state + */ + function getState() { + return state; + } + + /** + * @function State#clearState + * @summary erases the current state + */ + function clearState() { + state = {}; + } + + return { + updateState, + getState, + clearState + }; +} diff --git a/libraries/video/shared/vastXmlBuilder.js b/libraries/video/shared/vastXmlBuilder.js new file mode 100644 index 00000000000..35547acc479 --- /dev/null +++ b/libraries/video/shared/vastXmlBuilder.js @@ -0,0 +1,77 @@ +import { getGlobal } from '../../../src/prebidGlobal.js'; + +export function buildVastWrapper(adId, adTagUrl, impressionUrl, impressionId, errorUrl) { + let wrapperBody = getAdSystemNode('Prebid org', getGlobal().version); + + if (adTagUrl) { + wrapperBody += getAdTagUriNode(adTagUrl); + } + + if (impressionUrl) { + wrapperBody += getImpressionNode(impressionUrl, impressionId); + } + + if (errorUrl) { + wrapperBody += getErrorNode(errorUrl); + } + + return getVastNode(getAdNode(getWrapperNode(wrapperBody), adId), '4.2'); +} + +export function getVastNode(body, vastVersion) { + return getNode('VAST', body, { version: vastVersion }); +} + +export function getAdNode(body, adId) { + return getNode('Ad', body, { id: adId }); +} + +export function getWrapperNode(body) { + return getNode('Wrapper', body); +} + +export function getAdSystemNode(system, version) { + return getNode('AdSystem', system, { version }); +} + +export function getAdTagUriNode(adTagUrl) { + return getUrlNode('VASTAdTagURI', adTagUrl); +} + +export function getImpressionNode(pingUrl, id) { + return getUrlNode('Impression', pingUrl, { id }); +} + +export function getErrorNode(pingUrl) { + return getUrlNode('Error', pingUrl); +} + +// Helpers + +function getUrlNode(labelName, url, attributes) { + const body = ``; + return getNode(labelName, body, attributes); +} + +function getNode(labelName, body, attributes) { + const openingLabel = getOpeningLabel(labelName, attributes); + return `<${openingLabel}>${body}`; +} + +/* +attributes is a KVP Object. + */ +function getOpeningLabel(name, attributes) { + if (!attributes) { + return name; + } + + return Object.keys(attributes).reduce((label, key) => { + const value = attributes[key]; + if (!value) { + return label; + } + + return label + ` ${key}="${value}"`; + }, name); +} diff --git a/libraries/video/shared/vastXmlEditor.js b/libraries/video/shared/vastXmlEditor.js new file mode 100644 index 00000000000..b586e5b4c29 --- /dev/null +++ b/libraries/video/shared/vastXmlEditor.js @@ -0,0 +1,115 @@ +import { getErrorNode, getImpressionNode, buildVastWrapper } from './vastXmlBuilder.js'; + +export const XML_MIME_TYPE = 'application/xml'; + +export function VastXmlEditor(xmlUtil_) { + const xmlUtil = xmlUtil_; + + function getVastXmlWithTracking(vastXml, adId, impressionUrl, impressionId, errorUrl) { + const impressionDoc = getImpressionDoc(impressionUrl, impressionId); + const errorDoc = getErrorDoc(errorUrl); + if (!adId && !impressionDoc && !errorDoc) { + return vastXml; + } + + const vastXmlDoc = xmlUtil.parse(vastXml); + appendTrackingNodes(vastXmlDoc, impressionDoc, errorDoc); + replaceAdId(vastXmlDoc, adId); + return xmlUtil.serialize(vastXmlDoc); + } + + function appendTrackingNodes(vastXmlDoc, impressionDoc, errorDoc) { + const nodes = vastXmlDoc.querySelectorAll('InLine,Wrapper'); + const nodeCount = nodes.length; + for (let i = 0; i < nodeCount; i++) { + const node = nodes[i]; + // A copy of the child is required until we reach the last node. + const requiresCopy = i < nodeCount - 1; + appendChild(node, impressionDoc, requiresCopy); + appendChild(node, errorDoc, requiresCopy); + } + } + + function replaceAdId(vastXmlDoc, adId) { + if (!adId) { + return; + } + + const adNode = vastXmlDoc.querySelector('Ad'); + if (!adNode) { + return; + } + + adNode.id = adId; + } + + return { + getVastXmlWithTracking, + buildVastWrapper + } + + function getImpressionDoc(impressionUrl, impressionId) { + if (!impressionUrl) { + return; + } + + const impressionNode = getImpressionNode(impressionUrl, impressionId); + return xmlUtil.parse(impressionNode); + } + + function getErrorDoc(errorUrl) { + if (!errorUrl) { + return; + } + + const errorNode = getErrorNode(errorUrl); + return xmlUtil.parse(errorNode); + } + + function appendChild(node, child, copy) { + if (!child) { + return; + } + + const doc = copy ? child.cloneNode(true) : child; + node.appendChild(doc.documentElement); + } +} + +function XMLUtil() { + let parser; + let serializer; + + function getParser() { + if (!parser) { + // DOMParser instantiation is costly; instantiate only once throughout Prebid lifecycle. + parser = new DOMParser(); + } + return parser; + } + + function getSerializer() { + if (!serializer) { + // XMLSerializer instantiation is costly; instantiate only once throughout Prebid lifecycle. + serializer = new XMLSerializer(); + } + return serializer; + } + + function parse(xmlString) { + return getParser().parseFromString(xmlString, XML_MIME_TYPE); + } + + function serialize(xmlDoc) { + return getSerializer().serializeToString(xmlDoc); + } + + return { + parse, + serialize + }; +} + +export function vastXmlEditorFactory() { + return VastXmlEditor(XMLUtil()); +} diff --git a/modules/.submodules.json b/modules/.submodules.json index 85e4658cc61..fdc79c8b868 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,70 +1,93 @@ { - "userId": [ - "admixerIdSystem", - "adtelligentIdSystem", - "akamaiDAPIdSystem", - "amxIdSystem", - "britepoolIdSystem", - "connectIdSystem", - "criteoIdSystem", - "dacIdSystem", - "deepintentDpesIdSystem", - "dmdIdSystem", - "fabrickIdSystem", - "flocIdSystem", - "hadronIdSystem", - "haloIdSystem", - "id5IdSystem", - "ftrackIdSystem", - "identityLinkIdSystem", - "idxIdSystem", - "imuIdSystem", - "intentIqIdSystem", - "justIdSystem", - "kinessoIdSystem", - "liveIntentIdSystem", - "lotamePanoramaIdSystem", - "merkleIdSystem", - "mwOpenLinkIdSystem", - "naveggIdSystem", - "netIdSystem", - "nextrollIdSystem", - "novatiqIdSystem", - "parrableIdSystem", - "pubProvidedIdSystem", - "publinkIdSystem", - "quantcastIdSystem", - "sharedIdSystem", - "tapadIdSystem", - "trustpidSystem", - "uid2IdSystem", - "unifiedIdSystem", - "verizonMediaIdSystem", - "zeotapIdPlusIdSystem", - "adqueryIdSystem" - ], - "adpod": [ - "freeWheelAdserverVideo", - "dfpAdServerVideo" - ], - "rtdModule": [ - "browsiRtdProvider", - "dgkeywordRtdProvider", - "geoedgeRtdProvider", - "hadronRtdProvider", - "haloRtdProvider", - "iasRtdProvider", - "jwplayerRtdProvider", - "medianetRtdProvider", - "optimeraRtdProvider", - "permutiveRtdProvider", - "reconciliationRtdProvider", - "sirdataRtdProvider", - "timeoutRtdProvider", - "weboramaRtdProvider" - ], - "fpdModule": [ - "enrichmentFpdModule", - "validationFpdModule" - ] + "parentModules": { + "userId": [ + "33acrossIdSystem", + "admixerIdSystem", + "adtelligentIdSystem", + "amxIdSystem", + "britepoolIdSystem", + "connectIdSystem", + "czechAdIdSystem", + "criteoIdSystem", + "dacIdSystem", + "deepintentDpesIdSystem", + "dmdIdSystem", + "fabrickIdSystem", + "hadronIdSystem", + "id5IdSystem", + "ftrackIdSystem", + "identityLinkIdSystem", + "idxIdSystem", + "imuIdSystem", + "intentIqIdSystem", + "justIdSystem", + "kinessoIdSystem", + "liveIntentIdSystem", + "lotamePanoramaIdSystem", + "merkleIdSystem", + "mwOpenLinkIdSystem", + "naveggIdSystem", + "netIdSystem", + "novatiqIdSystem", + "oneKeyIdSystem", + "parrableIdSystem", + "pubProvidedIdSystem", + "publinkIdSystem", + "quantcastIdSystem", + "sharedIdSystem", + "tapadIdSystem", + "teadsIdSystem", + "tncIdSystem", + "utiqSystem", + "uid2IdSystem", + "euidIdSystem", + "unifiedIdSystem", + "verizonMediaIdSystem", + "zeotapIdPlusIdSystem", + "adqueryIdSystem", + "gravitoIdSystem", + "freepassIdSystem", + "operaadsIdSystem" + ], + "adpod": [ + "freeWheelAdserverVideo", + "dfpAdServerVideo" + ], + "rtdModule": [ + "1plusXRtdProvider", + "a1MediaRtdProvider", + "aaxBlockmeterRtdProvider", + "airgridRtdProvider", + "akamaiDapRtdProvider", + "arcspanRtdProvider", + "blueconicRtdProvider", + "browsiRtdProvider", + "captifyRtdProvider", + "confiantRtdProvider", + "dgkeywordRtdProvider", + "geoedgeRtdProvider", + "hadronRtdProvider", + "haloRtdProvider", + "iasRtdProvider", + "jwplayerRtdProvider", + "medianetRtdProvider", + "mgidRtdProvider", + "oneKeyRtdProvider", + "optimeraRtdProvider", + "permutiveRtdProvider", + "reconciliationRtdProvider", + "sirdataRtdProvider", + "timeoutRtdProvider", + "weboramaRtdProvider", + "zeusPrimeRtdProvider" + ], + "fpdModule": [ + "validationFpdModule", + "topicsFpdModule" + ], + "videoModule": [ + "jwplayerVideoProvider", + "videojsVideoProvider" + ] + } } diff --git a/modules/1plusXRtdProvider.js b/modules/1plusXRtdProvider.js new file mode 100644 index 00000000000..c5c4594ff22 --- /dev/null +++ b/modules/1plusXRtdProvider.js @@ -0,0 +1,259 @@ +import { submodule } from '../src/hook.js'; +import { ajax } from '../src/ajax.js'; +import { + logMessage, logError, + deepAccess, deepSetValue, mergeDeep, + isNumber, isArray, +} from '../src/utils.js'; + +// Constants +const REAL_TIME_MODULE = 'realTimeData'; +const MODULE_NAME = '1plusX'; +const ORTB2_NAME = '1plusX.com' +const PAPI_VERSION = 'v1.0'; +const LOG_PREFIX = '[1plusX RTD Module]: '; +const OPE_FPID = 'ope_fpid' +export const segtaxes = { + // cf. https://github.com/InteractiveAdvertisingBureau/openrtb/pull/108 + AUDIENCE: 526, + CONTENT: 527, +}; +// Functions +/** + * Extracts the parameters for 1plusX RTD module from the config object passed at instanciation + * @param {Object} moduleConfig Config object passed to the module + * @param {Object} reqBidsConfigObj Config object for the bidders; each adapter has its own entry + * @returns {Object} Extracted configuration parameters for the module + */ +export const extractConfig = (moduleConfig, reqBidsConfigObj) => { + // CustomerId + const customerId = deepAccess(moduleConfig, 'params.customerId'); + if (!customerId) { + throw new Error('Missing parameter customerId in moduleConfig'); + } + // Timeout + const tempTimeout = deepAccess(moduleConfig, 'params.timeout'); + const timeout = isNumber(tempTimeout) && tempTimeout > 300 ? tempTimeout : 1000; + + // Bidders + const biddersTemp = deepAccess(moduleConfig, 'params.bidders'); + if (!isArray(biddersTemp) || !biddersTemp.length) { + throw new Error('Missing parameter bidders in moduleConfig'); + } + + const adUnitBidders = reqBidsConfigObj.adUnits + .flatMap(({ bids }) => bids.map(({ bidder }) => bidder)) + .filter((e, i, a) => a.indexOf(e) === i); + if (!isArray(adUnitBidders) || !adUnitBidders.length) { + throw new Error('Missing parameter bidders in bidRequestConfig'); + } + + const bidders = biddersTemp.filter(bidder => adUnitBidders.includes(bidder)); + if (!bidders.length) { + throw new Error('No bidRequestConfig bidder found in moduleConfig bidders'); + } + + return { customerId, timeout, bidders }; +} + +/** + * Extracts consent from the prebid consent object and translates it + * into a 1plusX profile api query parameter parameter dict + * @param {object} prebid gdpr object + * @returns dictionary of papi gdpr query parameters + */ +export const extractConsent = ({ gdpr }) => { + if (!gdpr) { + return null + } + const { gdprApplies, consentString } = gdpr + if (!(gdprApplies == '0' || gdprApplies == '1')) { + throw 'TCF Consent: gdprApplies has wrong format' + } + if (consentString && typeof consentString != 'string') { + throw 'TCF Consent: consentString must be string if defined' + } + const result = { + 'gdpr_applies': gdprApplies, + 'consent_string': consentString + } + return result +} + +/** + * Extracts the OPE first party id field from local storage + * @returns fpid string if found, else null + */ +export const extractFpid = () => { + try { + const fpid = window.localStorage.getItem(OPE_FPID); + if (fpid) { + return fpid; + } + return null; + } catch (error) { + return null; + } +} +/** + * Gets the URL of Profile Api from which targeting data will be fetched + * @param {string} config.customerId + * @param {object} consent query params as dict + * @param {string} oneplusx first party id (nullable) + * @returns {string} URL to access 1plusX Profile API + */ +export const getPapiUrl = (customerId, consent, fpid) => { + // https://[yourClientId].profiles.tagger.opecloud.com/[VERSION]/targeting?url= + const currentUrl = encodeURIComponent(window.location.href); + var papiUrl = `https://${customerId}.profiles.tagger.opecloud.com/${PAPI_VERSION}/targeting?url=${currentUrl}`; + if (consent) { + Object.entries(consent).forEach(([key, value]) => { + papiUrl += `&${key}=${value}` + }) + } + if (fpid) { + papiUrl += `&fpid=${fpid}` + } + + return papiUrl; +} + +/** + * Fetches targeting data. It contains the audience segments & the contextual topics + * @param {string} papiUrl URL of profile API + * @returns {Promise} Promise object resolving with data fetched from Profile API + */ +const getTargetingDataFromPapi = (papiUrl) => { + return new Promise((resolve, reject) => { + const requestOptions = { + customHeaders: { + 'Accept': 'application/json' + } + } + const callbacks = { + success(responseText, response) { + resolve(JSON.parse(response.response)); + }, + error(error) { + reject(error); + } + }; + ajax(papiUrl, callbacks, null, requestOptions) + }) +} + +/** + * Prepares the update for the ORTB2 object + * @param {Object} targetingData Targeting data fetched from Profile API + * @param {string[]} segments Represents the audience segments of the user + * @param {string[]} topics Represents the topics of the page + * @returns {Object} Object describing the updates to make on bidder configs + */ +export const buildOrtb2Updates = ({ segments = [], topics = [] }) => { + const userData = { + name: ORTB2_NAME, + segment: segments.map((segmentId) => ({ id: segmentId })), + ext: { segtax: segtaxes.AUDIENCE } + }; + const siteContentData = { + name: ORTB2_NAME, + segment: topics.map((topicId) => ({ id: topicId })), + ext: { segtax: segtaxes.CONTENT } + } + return { userData, siteContentData }; +} + +/** + * Merges the targeting data with the existing config for bidder and updates + * @param {string} bidder Bidder for which to set config + * @param {Object} ortb2Updates Updates to be applied to bidder config + * @param {Object} biddersOrtb2 All current bidder configs + */ +export const updateBidderConfig = (bidder, ortb2Updates, biddersOrtb2) => { + const { siteContentData, userData } = ortb2Updates; + mergeDeep(biddersOrtb2, { [bidder]: {} }); + const bidderConfig = deepAccess(biddersOrtb2, bidder); + + { + const siteDataPath = 'site.content.data'; + const currentSiteContentData = deepAccess(bidderConfig, siteDataPath) || []; + const updatedSiteContentData = [ + ...currentSiteContentData.filter(({ name }) => name != siteContentData.name), + siteContentData + ]; + deepSetValue(bidderConfig, siteDataPath, updatedSiteContentData); + } + + { + const userDataPath = 'user.data'; + const currentUserData = deepAccess(bidderConfig, userDataPath) || []; + const updatedUserData = [ + ...currentUserData.filter(({ name }) => name != userData.name), + userData + ]; + deepSetValue(bidderConfig, userDataPath, updatedUserData); + } +}; + +/** + * Updates bidder configs with the targeting data retreived from Profile API + * @param {Object} papiResponse Response from Profile API + * @param {Object} config Module configuration + * @param {string[]} config.bidders Bidders specified in module's configuration + */ +export const setTargetingDataToConfig = (papiResponse, { bidders, biddersOrtb2 }) => { + const { s: segments, t: topics } = papiResponse; + + const ortb2Updates = buildOrtb2Updates({ segments, topics }); + for (const bidder of bidders) { + updateBidderConfig(bidder, ortb2Updates, biddersOrtb2); + } +} + +// Functions exported in submodule object +/** + * Init + * @param {Object} config Module configuration + * @param {boolean} userConsent + * @returns true + */ +const init = (config, userConsent) => { + return true; +} + +/** + * + * @param {Object} reqBidsConfigObj Bid request configuration object + * @param {Function} callback Called on completion + * @param {Object} moduleConfig Configuration for 1plusX RTD module + * @param {Object} userConsent + */ +const getBidRequestData = (reqBidsConfigObj, callback, moduleConfig, userConsent) => { + try { + // Get the required config + const { customerId, bidders } = extractConfig(moduleConfig, reqBidsConfigObj); + const { ortb2Fragments: { bidder: biddersOrtb2 } } = reqBidsConfigObj; + // Get PAPI URL + const papiUrl = getPapiUrl(customerId, extractConsent(userConsent) || {}, extractFpid()) + // Call PAPI + getTargetingDataFromPapi(papiUrl) + .then((papiResponse) => { + logMessage(LOG_PREFIX, 'Get targeting data request successful'); + setTargetingDataToConfig(papiResponse, { bidders, biddersOrtb2 }); + callback(); + }) + } catch (error) { + logError(LOG_PREFIX, error); + callback(); + } +} + +// The RTD submodule object to be exported +export const onePlusXSubmodule = { + name: MODULE_NAME, + init, + getBidRequestData +} + +// Register the onePlusXSubmodule as submodule of realTimeData +submodule(REAL_TIME_MODULE, onePlusXSubmodule); diff --git a/modules/1plusXRtdProvider.md b/modules/1plusXRtdProvider.md new file mode 100644 index 00000000000..6a6211b37cc --- /dev/null +++ b/modules/1plusXRtdProvider.md @@ -0,0 +1,65 @@ +# 1plusX Real-time Data Submodule + +## Overview + + Module Name: 1plusX Rtd Provider + Module Type: Rtd Provider + Maintainer: dc-team-1px@triplelift.com + +## Description + +The 1plusX RTD module appends User and Contextual segments to the bidding object. + +## Usage + +### Build +``` +gulp build --modules="rtdModule,1plusXRtdProvider,appnexusBidAdapter,..." +``` + +> Note that the global RTD module, `rtdModule`, is a prerequisite of the 1plusX RTD module. + +### Configuration + +Use `setConfig` to instruct Prebid.js to initilize the 1plusX RTD module, as specified below. + +This module is configured as part of the `realTimeData.dataProviders` + +```javascript +var TIMEOUT = 1000; +pbjs.setConfig({ + realTimeData: { + auctionDelay: TIMEOUT, + dataProviders: [{ + name: '1plusX', + waitForIt: true, + params: { + customerId: 'acme', + bidders: ['appnexus', 'rubicon'], + timeout: TIMEOUT + } + }] + } +}); +``` + +### Parameters + +| Name | Type | Description | Default | +| :---------------- | :------------ | :--------------------------------------------------------------- |:----------------- | +| name | String | Real time data module name | Always '1plusX' | +| waitForIt | Boolean | Should be `true` if there's an `auctionDelay` defined (optional) | `false` | +| params | Object | | | +| params.customerId | String | Your 1plusX customer id | | +| params.bidders | Array | List of bidders for which you would like data to be set | | +| params.timeout | Integer | timeout (ms) | 1000ms | + +## Testing + +To view an example of how the 1plusX RTD module works : + +`gulp serve --modules=rtdModule,1plusXRtdProvider,appnexusBidAdapter,rubiconBidAdapter` + +and then point your browser at: + +`http://localhost:9999/integrationExamples/gpt/1plusXRtdProvider_example.html` diff --git a/modules/33acrossBidAdapter.js b/modules/33acrossBidAdapter.js index 498e6cf8634..0e9beb22013 100644 --- a/modules/33acrossBidAdapter.js +++ b/modules/33acrossBidAdapter.js @@ -1,21 +1,23 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; import { deepAccess, - uniques, - isArray, + getWindowSelf, getWindowTop, + isArray, isGptPubadsDefined, - isSlotMatchingAdUnitCode, logInfo, logWarn, - getWindowSelf, mergeDeep, + pick, + uniques } from '../src/utils.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {isSlotMatchingAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; // **************************** UTILS *************************** // const BIDDER_CODE = '33across'; +const BIDDER_ALIASES = ['33across_mgni']; const END_POINT = 'https://ssc.33across.com/api/v1/hb'; const SYNC_ENDPOINT = 'https://ssc-cms.33across.com/ps/?m=xch&rt=html&ru=deb'; @@ -70,7 +72,9 @@ function isBidRequestValid(bid) { } function _validateBasic(bid) { - if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { + const invalidBidderName = bid.bidder !== BIDDER_CODE && !BIDDER_ALIASES.includes(bid.bidder); + + if (invalidBidderName || !bid.params) { return false; } @@ -163,7 +167,9 @@ function buildRequests(bidRequests, bidderRequest) { ttxSettings, gdprConsent, uspConsent, - pageUrl + gppConsent, + pageUrl, + referer } = _buildRequestParams(bidRequests, bidderRequest); const groupedRequests = _buildRequestGroups(ttxSettings, bidRequests); @@ -176,8 +182,11 @@ function buildRequests(bidRequests, bidderRequest) { bidRequests: groupedRequests[key], gdprConsent, uspConsent, + gppConsent, pageUrl, - ttxSettings + referer, + ttxSettings, + bidderRequest, }) ) } @@ -193,17 +202,15 @@ function _buildRequestParams(bidRequests, bidderRequest) { gdprApplies: false }, bidderRequest && bidderRequest.gdprConsent); - const uspConsent = bidderRequest && bidderRequest.uspConsent; - - const pageUrl = (bidderRequest && bidderRequest.refererInfo) ? (bidderRequest.refererInfo.referer) : (undefined); - adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(uniques); return { ttxSettings, gdprConsent, - uspConsent, - pageUrl + uspConsent: bidderRequest?.uspConsent, + gppConsent: bidderRequest?.gppConsent, + pageUrl: bidderRequest?.refererInfo?.page, + referer: bidderRequest?.refererInfo?.ref } } @@ -237,9 +244,11 @@ function _getMRAKey(bidRequest) { } // Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request -function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageUrl, ttxSettings }) { +function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, gppConsent = {}, pageUrl, referer, ttxSettings, bidderRequest }) { const ttxRequest = {}; - const { siteId, test } = bidRequests[0].params; + const firstBidRequest = bidRequests[0]; + const { siteId, test } = firstBidRequest.params; + const coppaValue = config.getConfig('coppa'); /* * Infer data for the request payload @@ -251,12 +260,17 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU }); ttxRequest.site = { id: siteId }; + ttxRequest.device = _buildDeviceORTB(firstBidRequest.ortb2?.device); if (pageUrl) { ttxRequest.site.page = pageUrl; } - ttxRequest.id = bidRequests[0].auctionId; + if (referer) { + ttxRequest.site.ref = referer; + } + + ttxRequest.id = bidderRequest?.bidderRequestId; if (gdprConsent.consentString) { ttxRequest.user = setExtensions(ttxRequest.user, { @@ -264,9 +278,9 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU }); } - if (Array.isArray(bidRequests[0].userIdAsEids) && bidRequests[0].userIdAsEids.length > 0) { + if (Array.isArray(firstBidRequest.userIdAsEids) && firstBidRequest.userIdAsEids.length > 0) { ttxRequest.user = setExtensions(ttxRequest.user, { - 'eids': bidRequests[0].userIdAsEids + 'eids': firstBidRequest.userIdAsEids }); } @@ -280,6 +294,17 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU }); } + if (gppConsent.gppString) { + Object.assign(ttxRequest.regs, { + 'gpp': gppConsent.gppString, + 'gpp_sid': gppConsent.applicableSections + }); + } + + if (coppaValue !== undefined) { + ttxRequest.regs.coppa = Number(!!coppaValue); + } + ttxRequest.ext = { ttx: { prebidStartedAt: Date.now(), @@ -290,9 +315,9 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU } }; - if (bidRequests[0].schain) { + if (firstBidRequest.schain) { ttxRequest.source = setExtensions(ttxRequest.source, { - 'schain': bidRequests[0].schain + 'schain': firstBidRequest.schain }); } @@ -318,7 +343,7 @@ function _createServerRequest({ bidRequests, gdprConsent = {}, uspConsent, pageU 'url': url, 'data': JSON.stringify(ttxRequest), 'options': options - } + }; } // BUILD REQUESTS: SET EXTENSIONS @@ -330,12 +355,15 @@ function setExtensions(obj = {}, extFields) { // BUILD REQUESTS: IMP function _buildImpORTB(bidRequest) { + const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid'); + const imp = { id: bidRequest.bidId, ext: { ttx: { prod: deepAccess(bidRequest, 'params.productId') - } + }, + ...(gpid ? { gpid } : {}) } }; @@ -431,7 +459,7 @@ function _buildBannerORTB(bidRequest) { return { format, ext - } + }; } // BUILD REQUESTS: VIDEO @@ -445,7 +473,7 @@ function _buildVideoORTB(bidRequest) { ...videoBidderParams // Bidder Specific overrides }; - const video = {} + const video = {}; const { w, h } = _getSize(videoParams.playerSize[0]); video.w = w; @@ -663,7 +691,6 @@ function _createBidResponse(bid, cur) { bid.adomain && bid.adomain.length; const bidResponse = { requestId: bid.impid, - bidderCode: BIDDER_CODE, cpm: bid.price, width: bid.w, height: bid.h, @@ -699,10 +726,10 @@ function _createBidResponse(bid, cur) { // Else no syncs // For logic on how we handle gdpr data see _createSyncs and module's unit tests // '33acrossBidAdapter#getUserSyncs' -function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) { +function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent, gppConsent) { const syncUrls = ( (syncOptions.iframeEnabled) - ? adapterState.uniqueSiteIds.map((siteId) => _createSync({ gdprConsent, uspConsent, siteId })) + ? adapterState.uniqueSiteIds.map((siteId) => _createSync({ gdprConsent, uspConsent, gppConsent, siteId })) : ([]) ); @@ -713,15 +740,16 @@ function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) { } // Sync object will always be of type iframe for TTX -function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConsent }) { +function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConsent, gppConsent = {} }) { const ttxSettings = config.getConfig('ttxSettings'); const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT; const { consentString, gdprApplies } = gdprConsent; + const { gppString = '', applicableSections = [] } = gppConsent; const sync = { type: 'iframe', - url: `${syncUrl}&id=${siteId}&gdpr_consent=${encodeURIComponent(consentString)}&us_privacy=${encodeURIComponent(uspConsent)}` + url: `${syncUrl}&id=${siteId}&gdpr_consent=${encodeURIComponent(consentString)}&us_privacy=${encodeURIComponent(uspConsent)}&gpp=${encodeURIComponent(gppString)}&gpp_sid=${encodeURIComponent(applicableSections.join(','))}` }; if (typeof gdprApplies === 'boolean') { @@ -731,10 +759,84 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse return sync; } +// BUILD REQUESTS: DEVICE +function _buildDeviceORTB(device = {}) { + const win = getWindowSelf(); + const deviceProps = { + ext: { + ttx: { + ...getScreenDimensions(), + pxr: win.devicePixelRatio, + vp: getViewportDimensions(), + ah: win.screen.availHeight, + mtp: win.navigator.maxTouchPoints + } + } + } + + if (device.sua) { + deviceProps.sua = pick(device.sua, [ 'browsers', 'platform', 'model', 'mobile' ]); + } + + return deviceProps; +} + +function getTopMostAccessibleWindow() { + let mostAccessibleWindow = getWindowSelf(); + + try { + while (mostAccessibleWindow.parent !== mostAccessibleWindow && + mostAccessibleWindow.parent.document) { + mostAccessibleWindow = mostAccessibleWindow.parent; + } + } catch (err) { + // Do not throw an exception if we can't access the topmost frame. + } + + return mostAccessibleWindow; +} + +function getViewportDimensions() { + const topWin = getTopMostAccessibleWindow(); + const documentElement = topWin.document.documentElement; + + return { + w: documentElement.clientWidth, + h: documentElement.clientHeight, + }; +} + +function getScreenDimensions() { + const { + innerWidth: windowWidth, + innerHeight: windowHeight, + screen + } = getWindowSelf(); + + const [biggerDimension, smallerDimension] = [ + Math.max(screen.width, screen.height), + Math.min(screen.width, screen.height), + ]; + + if (windowHeight > windowWidth) { // Portrait mode + return { + w: smallerDimension, + h: biggerDimension, + }; + } + + // Landscape mode + return { + w: biggerDimension, + h: smallerDimension, + }; +} + export const spec = { NON_MEASURABLE, code: BIDDER_CODE, + aliases: BIDDER_ALIASES, supportedMediaTypes: [ BANNER, VIDEO ], gvlid: GVLID, isBidRequestValid, diff --git a/modules/33acrossIdSystem.js b/modules/33acrossIdSystem.js new file mode 100644 index 00000000000..0f370237e21 --- /dev/null +++ b/modules/33acrossIdSystem.js @@ -0,0 +1,141 @@ +/** + * This module adds 33acrossId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/33acrossIdSystem + * @requires module:modules/userId + */ + +import { logMessage, logError } from '../src/utils.js'; +import { ajaxBuilder } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { uspDataHandler, coppaDataHandler, gppDataHandler } from '../src/adapterManager.js'; + +const MODULE_NAME = '33acrossId'; +const API_URL = 'https://lexicon.33across.com/v1/envelope'; +const AJAX_TIMEOUT = 10000; +const CALLER_NAME = 'pbjs'; + +function getEnvelope(response) { + if (!response.succeeded) { + if (response.error == 'Cookied User') { + logMessage(`${MODULE_NAME}: Unsuccessful response`.concat(' ', response.error)); + } else { + logError(`${MODULE_NAME}: Unsuccessful response`.concat(' ', response.error)); + } + return; + } + + if (!response.data.envelope) { + logMessage(`${MODULE_NAME}: No envelope was received`); + + return; + } + + return response.data.envelope; +} + +function calculateQueryStringParams(pid, gdprConsentData) { + const uspString = uspDataHandler.getConsentData(); + const gdprApplies = Boolean(gdprConsentData?.gdprApplies); + const coppaValue = coppaDataHandler.getCoppa(); + const gppConsent = gppDataHandler.getConsentData(); + + const params = { + pid, + gdpr: Number(gdprApplies), + src: CALLER_NAME, + ver: '$prebid.version$', + coppa: Number(coppaValue) + }; + + if (uspString) { + params.us_privacy = uspString; + } + + if (gppConsent) { + const { gppString = '', applicableSections = [] } = gppConsent; + + params.gpp = gppString; + params.gpp_sid = encodeURIComponent(applicableSections.join(',')) + } + + if (gdprConsentData?.consentString) { + params.gdpr_consent = gdprConsentData.consentString; + } + + return params; +} + +/** @type {Submodule} */ +export const thirthyThreeAcrossIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + + gvlid: 58, + + /** + * decode the stored id value for passing to bid requests + * @function + * @param {string} id + * @returns {{'33acrossId':{ envelope: string}}} + */ + decode(id) { + return { + [MODULE_NAME]: { + envelope: id + } + }; + }, + + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} [config] + * @returns {IdResponse|undefined} + */ + getId({ params = { } }, gdprConsentData) { + if (typeof params.pid !== 'string') { + logError(`${MODULE_NAME}: Submodule requires a partner ID to be defined`); + + return; + } + + const { pid, apiUrl = API_URL } = params; + + return { + callback(cb) { + ajaxBuilder(AJAX_TIMEOUT)(apiUrl, { + success(response) { + let envelope; + + try { + envelope = getEnvelope(JSON.parse(response)) + } catch (err) { + logError(`${MODULE_NAME}: ID reading error:`, err); + } + cb(envelope); + }, + error(err) { + logError(`${MODULE_NAME}: ID error response`, err); + + cb(); + } + }, calculateQueryStringParams(pid, gdprConsentData), { method: 'GET', withCredentials: true }); + } + }; + }, + eids: { + '33acrossId': { + source: '33across.com', + atype: 1, + getValue: function(data) { + return data.envelope; + } + }, + } +}; + +submodule('userId', thirthyThreeAcrossIdSubmodule); diff --git a/modules/33acrossIdSystem.md b/modules/33acrossIdSystem.md new file mode 100644 index 00000000000..1e4af89344f --- /dev/null +++ b/modules/33acrossIdSystem.md @@ -0,0 +1,53 @@ +# 33ACROSS ID + +For help adding this submodule, please contact [PrebidUIM@33across.com](PrebidUIM@33across.com). + +### Prebid Configuration + +You can configure this submodule in your `userSync.userIds[]` configuration: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [ + { + name: "33acrossId", + storage: { + name: "33acrossId", + type: "html5", + expires: 90, + refreshInSeconds: 8*3600 + }, + params: { + pid: "0010b00002GYU4eBAH", + }, + }, + ], + }, +}); +``` + +| Parameters under `userSync.userIds[]` | Scope | Type | Description | Example | +| ---| --- | --- | --- | --- | +| name | Required | String | Name for the 33Across ID submodule | `"33acrossId"` | | +| storage | Required | Object | Configures how to cache User IDs locally in the browser | See [storage settings](#storage-settings) | +| params | Required | Object | Parameters for 33Across ID submodule | See [params](#params) | + +### Storage Settings + +The following settings are available for the `storage` property in the `userSync.userIds[]` object: + +| Param name | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String| Name of the cookie or HTML5 local storage where the user ID will be stored | `"33acrossId"` | +| type | Required | String | `"html5"` (preferred) or `"cookie"` | `"html5"` | +| expires | Strongly Recommended | Number | How long (in days) the user ID information will be stored. 33Across recommends `90`. | `90` | +| refreshInSeconds | Strongly Recommended | Number | The interval (in seconds) for refreshing the user ID. 33Across recommends no more than 8 hours between refreshes. | `8*3600` | + +### Params + +The following settings are available in the `params` property in `userSync.userIds[]` object: + +| Param name | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| pid | Required | String | Partner ID provided by 33Across | `"0010b00002GYU4eBAH"` | diff --git a/modules/7xbidBidAdapter.md b/modules/7xbidBidAdapter.md deleted file mode 100644 index 692428332f0..00000000000 --- a/modules/7xbidBidAdapter.md +++ /dev/null @@ -1,59 +0,0 @@ -# Overview - -Module Name: 7xbid Bid Adapter - -Maintainer: 7xbid.com@gmail.com - -# Description - -Module that connects to 7xbid's demand sources - -# Test Parameters -```javascript - var adUnits = [ - { - code: 'test', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [ - { - bidder: '7xbid', - params: { - placementId: 1425292, - currency: 'USD' - } - } - ] - }, - { - code: 'test', - mediaTypes: { - native: { - title: { - required: true, - len: 80 - }, - image: { - required: true, - sizes: [150, 50] - }, - sponsoredBy: { - required: true - } - } - }, - bids: [ - { - bidder: '7xbid', - params: { - placementId: 1429695, - currency: 'USD' - } - }, - ], - } - ]; -``` \ No newline at end of file diff --git a/modules/a1MediaBidAdapter.js b/modules/a1MediaBidAdapter.js new file mode 100644 index 00000000000..6a137e621c5 --- /dev/null +++ b/modules/a1MediaBidAdapter.js @@ -0,0 +1,89 @@ +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'a1media'; +const END_POINT = 'https://d11.contentsfeed.com/dsp/breq/a1'; +const DEFAULT_CURRENCY = 'JPY'; + +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 30, + }, + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + if (!imp.bidfloor) { + imp.bidfloor = bidRequest.params.bidfloor || 0; + imp.bidfloorcur = bidRequest.params.currency || DEFAULT_CURRENCY; + } + if (bidRequest.params.battr) { + Object.keys(bidRequest.mediaTypes).forEach(mType => { + imp[mType].battr = bidRequest.params.battr; + }) + } + return imp; + }, + request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + const bid = context.bidRequests[0]; + if (!request.cur) { + request.cur = [bid.params.currency || DEFAULT_CURRENCY]; + } + if (bid.params.bcat) { + request.bcat = bid.params.bcat; + } + return request; + }, + bidResponse(buildBidResponse, bid, context) { + const { bidRequest } = context; + + let resMediaType; + const reqMediaTypes = Object.keys(bidRequest.mediaTypes); + if (reqMediaTypes.length === 1) { + resMediaType = reqMediaTypes[0]; + } else { + if (bid.adm.search(/^(<\?xml| ({id: x})) + }; + + const a1UserEid = { + source: 'a1mediagroup.com', + uids: [ + { + id: a1gid, + atype: 1 + } + ] + }; + + const a1Ortb2 = { + user: { + data: [ + a1UserSegData + ], + ext: { + eids: [ + a1UserEid + ] + } + } + }; + mergeDeep(reqBidsConfigObj.ortb2Fragments.global, a1Ortb2); + callback(); +} + +submodule(REAL_TIME_MODULE, subModuleObj); diff --git a/modules/a1MediaRtdProvider.md b/modules/a1MediaRtdProvider.md new file mode 100644 index 00000000000..ab2077ebbbb --- /dev/null +++ b/modules/a1MediaRtdProvider.md @@ -0,0 +1,46 @@ +# Overview + +Module Name: A1Media Rtd Provider +Module Type: Rtd Provider +Maintainer: dev@a1mediagroup.co.kr + +# Description + +This module loads external code using the passed parameter (params.tagId). + +The A1Media RTD module loads A1Media script for obtains user segments, and provides user segment data to bid-requests.
+to get user segments, you will need a1media script customized for site. + +To use this module, you’ll need to work with [A1MediaGroup](https://www.a1mediagroup.com/) to get an account and receive instructions on how to set up your pages and ad server. + +Contact dev@a1mediagroup.co.kr for information. + +### Integration + +1) Build the A1Media RTD Module into the Prebid.js package with: + +``` +gulp build --modules=a1MediaRtdProvider,... +``` + +2) Use `setConfig` to instruct Prebid.js to initilaize the A1Media RTD module, as specified below. + +### Configuration + +```javascript +pbjs.setConfig({ + realTimeData: { + auctionDelay: 1000, + dataProviders: [ + { + name: "a1Media", + waitForIt: true, + params: { + // 'tagId' is unique value for each account. + tagId: 'lb4test' + } + } + ] + } +}); +``` diff --git a/modules/a4gBidAdapter.js b/modules/a4gBidAdapter.js index 03f9d6fd726..f0c7a5f5af1 100644 --- a/modules/a4gBidAdapter.js +++ b/modules/a4gBidAdapter.js @@ -44,7 +44,7 @@ export const spec = { let data = { [IFRAME_PARAM_NAME]: 0, - [LOCATION_PARAM_NAME]: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : window.location.href, + [LOCATION_PARAM_NAME]: bidderRequest.refererInfo?.page, [SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR), [ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR), [ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR) diff --git a/modules/aardvarkBidAdapter.md b/modules/aardvarkBidAdapter.md deleted file mode 100644 index 9f7a128b6f3..00000000000 --- a/modules/aardvarkBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -**Module Name**: Aardvark Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: chris@rtk.io - -# Description - -Module that connects to a RTK.io Ad Units to fetch bids. - -# Test Parameters -``` - var adUnits = [{ - mediaTypes: { - banner: { - sizes: [[300, 250]], - } - }, - code: 'div-gpt-ad-1460505748561-0', - - bids: [{ - bidder: 'aardvark', - params: { - ai: '0000', - sc: '1234' - } - }] - - }]; -``` diff --git a/modules/aaxBlockmeterRtdProvider.js b/modules/aaxBlockmeterRtdProvider.js new file mode 100644 index 00000000000..a3b7b4812a7 --- /dev/null +++ b/modules/aaxBlockmeterRtdProvider.js @@ -0,0 +1,59 @@ +import {isEmptyStr, isStr, logError, isFn, logWarn} from '../src/utils.js'; +import {submodule} from '../src/hook.js'; +import { loadExternalScript } from '../src/adloader.js'; + +export const _config = { + MODULE: 'aaxBlockmeter', + ADSERVER_TARGETING_KEY: 'atk', + BLOCKMETER_URL: 'c.aaxads.com/aax.js', + VERSION: '1.2' +}; + +window.aax = window.aax || {}; + +function loadBlockmeter(_rtdConfig) { + if (!(_rtdConfig.params && _rtdConfig.params.pub) || !isStr(_rtdConfig.params && _rtdConfig.params.pub) || isEmptyStr(_rtdConfig.params && _rtdConfig.params.pub)) { + logError(`${_config.MODULE}: params.pub should be a string`); + return false; + } + + const params = []; + params.push(`pub=${_rtdConfig.params.pub}`); + params.push(`dn=${window.location.hostname}`); + + let url = _rtdConfig.params.url; + if (!url || isEmptyStr(url)) { + logWarn(`${_config.MODULE}: params.url is missing, using default url.`); + url = `${_config.BLOCKMETER_URL}?ver=${_config.VERSION}`; + } + + const scriptUrl = `https://${url}&${params.join('&')}`; + loadExternalScript(scriptUrl, _config.MODULE); + return true; +} + +function markAdBlockInventory(codes, _rtdConfig, _userConsent) { + return codes.reduce((targets, code) => { + targets[code] = targets[code] || {}; + const getAaxTargets = () => isFn(window.aax.getTargetingData) + ? window.aax.getTargetingData(code, _rtdConfig, _userConsent) + : {}; + targets[code] = { + [_config.ADSERVER_TARGETING_KEY]: code, + ...getAaxTargets() + }; + return targets; + }, {}); +} + +export const aaxBlockmeterRtdModule = { + name: _config.MODULE, + init: loadBlockmeter, + getTargetingData: markAdBlockInventory, +}; + +function registerSubModule() { + submodule('realTimeData', aaxBlockmeterRtdModule); +} + +registerSubModule(); diff --git a/modules/aaxBlockmeterRtdProvider.md b/modules/aaxBlockmeterRtdProvider.md new file mode 100644 index 00000000000..0a317f85b85 --- /dev/null +++ b/modules/aaxBlockmeterRtdProvider.md @@ -0,0 +1,48 @@ +## Overview + +Module Name: AAX Blockmeter Realtime Data Module +Module Type: Rtd Provider +Maintainer: product@aax.media + +## Description + +The module enables publishers to measure traffic coming from visitors using adblockers. + +AAX can also help publishers monetize this traffic by allowing them to serve [acceptable ads](https://acceptableads.com/about/) to these adblock visitors and recover their lost revenue. [Reach out to us](https://www.aax.media/try-blockmeter/) to know more. + +## Integration + +Build the AAX Blockmeter Realtime Data Module into the Prebid.js package with: + +``` +gulp build --modules=aaxBlockmeterRtdProvider,rtdModule +``` + +## Configuration + +This module is configured as part of the `realTimeData.dataProviders` object. + +| Name | Scope | Description | Example | Type | +|:----------:|:--------:|:-----------------------------|:---------------:|:------:| +| `name` | required | Real time data module name | `'aaxBlockmeter'` | `string` | +| `params` | required | | | `Object` | +| `params.pub` | required | AAX to share pub ID, [Reach out to us](https://www.aax.media/try-blockmeter/) to know more! | `'AAX00000'` | `string` | +| `params.url` | optional | AAX Blockmeter Script Url. Defaults to `'c.aaxads.com/aax.js?ver=1.2'` | `'c.aaxads.com/aax.js?ver=1.2'` | `string` | + +### Example + +```javascript +pbjs.setConfig({ + "realTimeData": { + "dataProviders": [ + { + "name": "aaxBlockmeter", + "params": { + "pub": "AAX00000", + "url": "c.aaxads.com/aax.js?ver=1.2", + } + } + ] + } +}) +``` diff --git a/modules/ablidaBidAdapter.js b/modules/ablidaBidAdapter.js index cb4f4ef2724..805a2020fb4 100644 --- a/modules/ablidaBidAdapter.js +++ b/modules/ablidaBidAdapter.js @@ -1,7 +1,7 @@ -import { triggerPixel } from '../src/utils.js'; -import {config} from '../src/config.js'; +import {triggerPixel} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; const BIDDER_CODE = 'ablida'; const ENDPOINT_URL = 'https://bidder.ablida.net/prebid'; @@ -28,6 +28,9 @@ export const spec = { * @param bidderRequest */ buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + if (validBidRequests.length === 0) { return []; } @@ -45,7 +48,8 @@ export const spec = { sizes: sizes, bidId: bidRequest.bidId, categories: bidRequest.params.categories, - referer: bidderRequest.refererInfo.referer, + // TODO: should referer be 'ref'? + referer: bidderRequest.refererInfo.page, jaySupported: jaySupported, device: device, adapterVersion: 5, @@ -72,7 +76,7 @@ export const spec = { const response = serverResponse.body; response.forEach(function(bid) { - bid.ttl = config.getConfig('_bidderTimeout'); + bid.ttl = 60 bidResponses.push(bid); }); return bidResponses; diff --git a/modules/acuityAdsBidAdapter.js b/modules/acuityAdsBidAdapter.js new file mode 100644 index 00000000000..b0bb132ddae --- /dev/null +++ b/modules/acuityAdsBidAdapter.js @@ -0,0 +1,207 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'acuityads'; +const AD_URL = 'https://prebid.admanmedia.com/pbjs'; +const SYNC_URL = 'https://cs.admanmedia.com'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + placement.placementId = placementId; + placement.type = 'publisher'; + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && params.placementId); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/acuityAdsBidAdapter.md b/modules/acuityAdsBidAdapter.md new file mode 100644 index 00000000000..a19e0a6b0ba --- /dev/null +++ b/modules/acuityAdsBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: AcuityAds Bidder Adapter +Module Type: AcuityAds Bidder Adapter +Maintainer: sa-support@brightcom.com +``` + +# Description + +Connects to AcuityAds exchange for bids. +AcuityAds bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'acuityads', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'acuityads', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'acuityads', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/adWMGAnalyticsAdapter.js b/modules/adWMGAnalyticsAdapter.js index 8183187eb73..dd0340071d1 100644 --- a/modules/adWMGAnalyticsAdapter.js +++ b/modules/adWMGAnalyticsAdapter.js @@ -1,4 +1,4 @@ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; import { ajax } from '../src/ajax.js'; diff --git a/modules/adWMGBidAdapter.js b/modules/adWMGBidAdapter.js index 7bf6c703a55..d268c4cafa8 100644 --- a/modules/adWMGBidAdapter.js +++ b/modules/adWMGBidAdapter.js @@ -1,9 +1,9 @@ 'use strict'; -import { tryAppendQueryString } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER } from '../src/mediaTypes.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; const BIDDER_CODE = 'adWMG'; const ENDPOINT = 'https://hb.adwmg.com/hb'; @@ -27,9 +27,10 @@ export const spec = { buildRequests: (validBidRequests, bidderRequest) => { const timeout = bidderRequest.timeout || 0; const debug = config.getConfig('debug') || false; - const referrer = bidderRequest.refererInfo.referer; + // TODO: is 'page' the right value here? + const referrer = bidderRequest.refererInfo.page; const locale = window.navigator.language && window.navigator.language.length > 0 ? window.navigator.language.substr(0, 2) : ''; - const domain = config.getConfig('publisherDomain') || (window.location && window.location.host ? window.location.host : ''); + const domain = bidderRequest.refererInfo.domain || ''; const ua = window.navigator.userAgent.toLowerCase(); const additional = spec.parseUserAgent(ua); @@ -58,11 +59,12 @@ export const spec = { } const request = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidRequest.auctionId, requestId: bidRequest.bidId, bidRequestsCount: bidRequest.bidRequestsCount, bidderRequestId: bidRequest.bidderRequestId, - transactionId: bidRequest.transactionId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, referrer: referrer, timeout: timeout, adUnit: adUnit, diff --git a/modules/adagioAnalyticsAdapter.js b/modules/adagioAnalyticsAdapter.js index f929f7e660b..f9b79639073 100644 --- a/modules/adagioAnalyticsAdapter.js +++ b/modules/adagioAnalyticsAdapter.js @@ -2,19 +2,38 @@ * Analytics Adapter for Adagio */ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import { getWindowTop } from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { getWindowTop, getWindowSelf, deepAccess, logInfo, logError } from '../src/utils.js'; +import { getGlobal } from '../src/prebidGlobal.js'; const emptyUrl = ''; const analyticsType = 'endpoint'; const events = Object.keys(CONSTANTS.EVENTS).map(key => CONSTANTS.EVENTS[key]); -const VERSION = '2.0.0'; +const ADAGIO_GVLID = 617; +const VERSION = '3.0.0'; +const PREBID_VERSION = '$prebid.version$'; +const ENDPOINT = 'https://c.4dex.io/pba.gif'; +const cache = { + auctions: {}, + getAuction: function(auctionId, adUnitCode) { + return this.auctions[auctionId][adUnitCode]; + }, + updateAuction: function(auctionId, adUnitCode, values) { + this.auctions[auctionId][adUnitCode] = { + ...this.auctions[auctionId][adUnitCode], + ...values + }; + } +}; +const enc = window.encodeURIComponent; -const adagioEnqueue = function adagioEnqueue(action, data) { - getWindowTop().ADAGIO.queue.push({ action, data, ts: Date.now() }); -} +/** +/* BEGIN ADAGIO.JS CODE +*/ function canAccessTopWindow() { try { @@ -24,12 +43,293 @@ function canAccessTopWindow() { } catch (error) { return false; } -} +}; + +function getCurrentWindow() { + return currentWindow; +}; + +let currentWindow; + +const adagioEnqueue = function adagioEnqueue(action, data) { + getCurrentWindow().ADAGIO.queue.push({ action, data, ts: Date.now() }); +}; + +/** +* END ADAGIO.JS CODE +*/ + +/** +* UTILS FUNCTIONS +*/ + +const guard = { + adagio: (value) => isAdagio(value), + bidTracked: (auctionId, adUnitCode) => deepAccess(cache, `auctions.${auctionId}.${adUnitCode}`, false) +}; + +function removeDuplicates(arr, getKey) { + const seen = {}; + return arr.filter(item => { + const key = getKey(item); + return seen.hasOwnProperty(key) ? false : (seen[key] = true); + }); +}; + +function getAdapterNameForAlias(aliasName) { + return adapterManager.aliasRegistry[aliasName] || aliasName; +}; + +function isAdagio(value) { + return value.toLowerCase().includes('adagio') || + getAdapterNameForAlias(value).toLowerCase().includes('adagio'); +}; + +function getMediaTypeAlias(mediaType) { + const mediaTypesMap = { + banner: 'ban', + outstream: 'vidout', + instream: 'vidin', + adpod: 'vidadpod', + native: 'nat' + }; + return mediaTypesMap[mediaType] || mediaType; +}; + +/** +* sendRequest to Adagio. It filter null values and encode each query param. +* @param {Object} qp +*/ +function sendRequest(qp) { + // Removing null values + qp = Object.keys(qp).reduce((acc, key) => { + if (qp[key] !== null) { + acc[key] = qp[key]; + } + return acc; + }, {}); + + const url = `${ENDPOINT}?${Object.keys(qp).map(key => `${key}=${enc(qp[key])}`).join('&')}`; + ajax(url, null, null, {method: 'GET'}); +}; + +/** + * Send a new beacon to Adagio. It increment the version of the beacon. + * @param {string} auctionId + * @param {string} adUnitCode + */ +function sendNewBeacon(auctionId, adUnitCode) { + cache.updateAuction(auctionId, adUnitCode, { + v: (cache.getAuction(auctionId, adUnitCode).v || 0) + 1 + }); + sendRequest(cache.getAuction(auctionId, adUnitCode)); +}; + +/** + * END UTILS FUNCTIONS +*/ + +/** + * HANDLERS + * - handlerAuctionInit + * - handlerBidResponse + * - handlerBidWon + * - handlerAdRender + * + * Each handler is called when the event is fired. +*/ + +function handlerAuctionInit(event) { + const w = getCurrentWindow(); + + const prebidAuctionId = event.auctionId; + const adUnitCodes = removeDuplicates(event.adUnitCodes, adUnitCode => adUnitCode); + + // Check if Adagio is on the bid requests. + // If not, we don't need to track the auction. + const adagioBidRequest = event.bidderRequests.find(bidRequest => isAdagio(bidRequest.bidderCode)); + if (!adagioBidRequest) { + logInfo(`Adagio is not on the bid requests for auction '${prebidAuctionId}'`) + return; + } + + cache.auctions[prebidAuctionId] = {}; + + adUnitCodes.forEach(adUnitCode => { + const adUnits = event.adUnits.filter(adUnit => adUnit.code === adUnitCode); + + // Get all bidders configures for the ad unit. + const bidders = removeDuplicates( + adUnits.map(adUnit => adUnit.bids.map(bid => ({bidder: bid.bidder, params: bid.params}))).flat(), + bidder => bidder.bidder + ); + + // Check if Adagio is configured for the ad unit. + // If not, we don't need to track the ad unit. + const adagioBidder = bidders.find(bidder => isAdagio(bidder.bidder)); + if (!adagioBidder) { + logInfo(`Adagio is not configured for ad unit '${adUnitCode}'`); + return; + } + + // Get all media types and banner sizes configured for the ad unit. + const mediaTypes = adUnits.map(adUnit => adUnit.mediaTypes); + const mediaTypesKeys = removeDuplicates( + mediaTypes.map(mediaTypeObj => Object.keys(mediaTypeObj)).flat(), + mediaTypeKey => mediaTypeKey + ).map(mediaType => getMediaTypeAlias(mediaType)).sort(); + const bannerSizes = removeDuplicates( + mediaTypes.filter(mediaType => mediaType.hasOwnProperty(BANNER)) + .map(mediaType => mediaType[BANNER].sizes.map(size => size.join('x'))) + .flat(), + bannerSize => bannerSize + ).sort(); + + // Get all Adagio bids for the ad unit from the bidRequest. + // If no bids, we don't need to track the ad unit. + const adagioAdUnitBids = adagioBidRequest.bids.filter(bid => bid.adUnitCode === adUnitCode); + if (deepAccess(adagioAdUnitBids, 'length', 0) <= 0) { + logInfo(`Adagio is not on the bid requests for ad unit '${adUnitCode}' and auction '${prebidAuctionId}'`) + return; + } + // Get Adagio params from the first bid. + // We assume that all Adagio bids for a same adunit have the same params. + const params = adagioAdUnitBids[0].params; + + // Get all media types requested for Adagio. + const adagioMediaTypes = removeDuplicates( + adagioAdUnitBids.map(bid => Object.keys(bid.mediaTypes)).flat(), + mediaTypeKey => mediaTypeKey + ).flat().map(mediaType => getMediaTypeAlias(mediaType)).sort(); + + const qp = { + v: 0, + pbjsv: PREBID_VERSION, + org_id: params.organizationId, + site: params.site, + pv_id: params.pageviewId, + auct_id: params.adagioAuctionId, + adu_code: adUnitCode, + url_dmn: w.location.hostname, + dvc: params.environment, + pgtyp: params.pagetype, + plcmt: params.placement, + tname: params.testName || null, + tvname: params.testVariationName || null, + mts: mediaTypesKeys.join(','), + ban_szs: bannerSizes.join(','), + bdrs: bidders.map(bidder => getAdapterNameForAlias(bidder.bidder)).sort().join(','), + adg_mts: adagioMediaTypes.join(',') + }; + + cache.auctions[prebidAuctionId][adUnitCode] = qp; + sendNewBeacon(prebidAuctionId, adUnitCode); + }); +}; + +/** + * handlerBidResponse allow to track the adagio bid response + * and to update the auction cache with the seat ID. + * No beacon is sent here. +*/ +function handlerBidResponse(event) { + if (!guard.adagio(event.bidder)) { + return; + } + + if (!guard.bidTracked(event.auctionId, event.adUnitCode)) { + return; + } + + cache.updateAuction(event.auctionId, event.adUnitCode, { + adg_sid: event.seatId || null + }); +}; + +function handlerBidWon(event) { + if (!guard.bidTracked(event.auctionId, event.adUnitCode)) { + return; + } + + let adsCurRateToUSD = (event.currency === 'USD') ? 1 : null; + let ogCurRateToUSD = (event.originalCurrency === 'USD') ? 1 : null; + try { + if (typeof getGlobal().convertCurrency === 'function') { + // Currency module is loaded, we can calculate the conversion rate. + + // Get the conversion rate from the original currency to USD. + ogCurRateToUSD = getGlobal().convertCurrency(1, event.originalCurrency, 'USD'); + // Get the conversion rate from the ad server currency to USD. + adsCurRateToUSD = getGlobal().convertCurrency(1, event.currency, 'USD'); + } + } catch (error) { + logError('Error on Adagio Analytics Adapter - handlerBidWon', error); + } + + cache.updateAuction(event.auctionId, event.adUnitCode, { + win_bdr: getAdapterNameForAlias(event.bidder), + win_mt: getMediaTypeAlias(event.mediaType), + win_ban_sz: event.mediaType === BANNER ? `${event.width}x${event.height}` : null, + + // ad server currency + win_cpm: event.cpm, + cur: event.currency, + cur_rate: adsCurRateToUSD, + + // original currency from bidder + og_cpm: event.originalCpm, + og_cur: event.originalCurrency, + og_cur_rate: ogCurRateToUSD, + }); + sendNewBeacon(event.auctionId, event.adUnitCode); +}; + +function handlerAdRender(event, isSuccess) { + const { auctionId, adUnitCode } = event.bid; + if (!guard.bidTracked(auctionId, adUnitCode)) { + return; + } + + cache.updateAuction(auctionId, adUnitCode, { + rndr: isSuccess ? 1 : 0 + }); + sendNewBeacon(auctionId, adUnitCode); +}; + +/** + * END HANDLERS +*/ let adagioAdapter = Object.assign(adapter({ emptyUrl, analyticsType }), { - track: function({ eventType, args }) { - if (typeof args !== 'undefined' && events.indexOf(eventType) !== -1) { - adagioEnqueue('pb-analytics-event', { eventName: eventType, args }); + track: function(event) { + const { eventType, args } = event; + + try { + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: + handlerAuctionInit(args); + break; + case CONSTANTS.EVENTS.BID_RESPONSE: + handlerBidResponse(args); + break; + case CONSTANTS.EVENTS.BID_WON: + handlerBidWon(args); + break; + case CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED: + case CONSTANTS.EVENTS.AD_RENDER_FAILED: + handlerAdRender(args, eventType === CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED); + break; + } + } catch (error) { + logError('Error on Adagio Analytics Adapter', error); + } + + try { + if (typeof args !== 'undefined' && events.indexOf(eventType) !== -1) { + adagioEnqueue('pb-analytics-event', { eventName: eventType, args }); + } + } catch (error) { + logError('Error on Adagio Analytics Adapter - adagio.js', error); } } }); @@ -37,11 +337,8 @@ let adagioAdapter = Object.assign(adapter({ emptyUrl, analyticsType }), { adagioAdapter.originEnableAnalytics = adagioAdapter.enableAnalytics; adagioAdapter.enableAnalytics = config => { - if (!canAccessTopWindow()) { - return; - } - - const w = getWindowTop(); + const w = (canAccessTopWindow()) ? getWindowTop() : getWindowSelf(); + currentWindow = w; w.ADAGIO = w.ADAGIO || {}; w.ADAGIO.queue = w.ADAGIO.queue || []; @@ -53,7 +350,8 @@ adagioAdapter.enableAnalytics = config => { adapterManager.registerAnalyticsAdapter({ adapter: adagioAdapter, - code: 'adagio' + code: 'adagio', + gvlid: ADAGIO_GVLID, }); export default adagioAdapter; diff --git a/modules/adagioAnalyticsAdapter.md b/modules/adagioAnalyticsAdapter.md index 312a26ea8da..9fc2cb0bb88 100644 --- a/modules/adagioAnalyticsAdapter.md +++ b/modules/adagioAnalyticsAdapter.md @@ -8,10 +8,10 @@ Maintainer: dev@adagio.io Analytics adapter for Adagio -# Test Parameters +# Settings -``` -{ - provider: 'adagio' -} +```js + pbjs.enableAnalytics({ + provider: 'adagio', + }); ``` diff --git a/modules/adagioBidAdapter.js b/modules/adagioBidAdapter.js index a24bc889411..3de584a1195 100644 --- a/modules/adagioBidAdapter.js +++ b/modules/adagioBidAdapter.js @@ -6,7 +6,6 @@ import { deepClone, generateUUID, getDNT, - getGptSlotInfoForAdUnitCode, getUniqueIdentifierStr, getWindowSelf, getWindowTop, @@ -15,22 +14,26 @@ import { isFn, isInteger, isNumber, + isArrayOfNums, logError, logInfo, logWarn, mergeDeep, - parseUrl + isStr, } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {loadExternalScript} from '../src/adloader.js'; import {verify} from 'criteo-direct-rsa-validate/build/verify.js'; import {getStorageManager} from '../src/storageManager.js'; -import {getRefererInfo} from '../src/refererDetection.js'; -import {createEidsArray} from './userId/eids.js'; +import {getRefererInfo, parseDomain} from '../src/refererDetection.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {Renderer} from '../src/Renderer.js'; import {OUTSTREAM} from '../src/video.js'; +import { getGlobal } from '../src/prebidGlobal.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { userSync } from '../src/userSync.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const BIDDER_CODE = 'adagio'; const LOG_PREFIX = 'Adagio:'; @@ -40,41 +43,43 @@ const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO]; const ADAGIO_TAG_URL = 'https://script.4dex.io/localstore.js'; const ADAGIO_LOCALSTORAGE_KEY = 'adagioScript'; const GVLID = 617; -export const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); -export const RENDERER_URL = 'https://script.4dex.io/outstream-player.js'; +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); + +const BB_PUBLICATION = 'adagio'; +const BB_RENDERER_DEFAULT = 'renderer'; +export const BB_RENDERER_URL = `https://${BB_PUBLICATION}.bbvms.com/r/$RENDERER.js`; + const MAX_SESS_DURATION = 30 * 60 * 1000; const ADAGIO_PUBKEY = 'AL16XT44Sfp+8SHVF1UdC7hydPSMVLMhsYknKDdwqq+0ToDSJrP0+Qh0ki9JJI2uYm/6VEYo8TJED9WfMkiJ4vf02CW3RvSWwc35bif2SK1L8Nn/GfFYr/2/GG/Rm0vUsv+vBHky6nuuYls20Og0HDhMgaOlXoQ/cxMuiy5QSktp'; const ADAGIO_PUBKEY_E = 65537; const CURRENCY = 'USD'; -const DEFAULT_FLOOR = 0.1; -// 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) => isInteger(value), + 'linearity': (value) => isInteger(value), + 'skip': (value) => [1, 0].includes(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; @@ -269,32 +274,12 @@ function getDevice() { }; function getSite(bidderRequest) { - let domain = ''; - let page = ''; - let referrer = ''; - const { refererInfo } = bidderRequest; - - if (canAccessTopWindow()) { - const wt = getWindowTop(); - domain = wt.location.hostname; - page = wt.location.href; - referrer = wt.document.referrer || ''; - } else if (refererInfo.reachedTop) { - const url = parseUrl(refererInfo.referer); - domain = url.hostname; - page = refererInfo.referer; - } else if (refererInfo.stack && refererInfo.stack.length && refererInfo.stack[0]) { - // important note check if refererInfo.stack[0] is 'thruly' because a `null` value - // will be considered as "localhost" by the parseUrl function. - const url = parseUrl(refererInfo.stack[0]); - domain = url.hostname; - } - return { - domain, - page, - referrer + domain: parseDomain(refererInfo.topmostLocation) || '', + page: refererInfo.topmostLocation || '', + referrer: refererInfo.ref || getWindowSelf().document.referrer || '', + top: refererInfo.reachedTop }; }; @@ -414,13 +399,24 @@ function _getUspConsent(bidderRequest) { return (deepAccess(bidderRequest, 'uspConsent')) ? { uspConsent: bidderRequest.uspConsent } : false; } +function _getGppConsent(bidderRequest) { + let gpp = deepAccess(bidderRequest, 'gppConsent.gppString') + let gppSid = deepAccess(bidderRequest, 'gppConsent.applicableSections') + + if (!gpp || !gppSid) { + gpp = deepAccess(bidderRequest, 'ortb2.regs.gpp', '') + gppSid = deepAccess(bidderRequest, 'ortb2.regs.gpp_sid', []) + } + return { gpp, gppSid } +} + function _getSchain(bidRequest) { return deepAccess(bidRequest, 'schain'); } function _getEids(bidRequest) { - if (deepAccess(bidRequest, 'userId')) { - return createEidsArray(bidRequest.userId); + if (deepAccess(bidRequest, 'userIdAsEids')) { + return bidRequest.userIdAsEids; } } @@ -462,16 +458,6 @@ function _buildVideoBidRequest(bidRequest) { }); } -function _renderer(bid) { - bid.renderer.push(() => { - if (typeof window.ADAGIO.outstreamPlayer === 'function') { - window.ADAGIO.outstreamPlayer(bid); - } else { - logError(`${LOG_PREFIX} Adagio outstream player is not defined`); - } - }); -} - function _parseNativeBidResponse(bid) { if (!bid.admNative || !Array.isArray(bid.admNative.assets)) { logError(`${LOG_PREFIX} Invalid native response`); @@ -552,7 +538,12 @@ function _parseNativeBidResponse(bid) { native.impressionTrackers.push(tracker.url); break; case 2: - native.javascriptTrackers = ``; + const script = ``; + if (!native.javascriptTrackers) { + native.javascriptTrackers = script; + } else { + native.javascriptTrackers += `\n${script}`; + } break; } }); @@ -589,13 +580,13 @@ function _getFloors(bidRequest) { const info = bidRequest.getFloor({ currency: CURRENCY, mediaType, - size: [] + size }); floors.push(cleanObj({ mt: mediaType, s: isArray(size) ? `${size[0]}x${size[1]}` : undefined, - f: (!isNaN(info.floor) && info.currency === CURRENCY) ? info.floor : DEFAULT_FLOOR + f: (!isNaN(info.floor) && info.currency === CURRENCY) ? info.floor : undefined })); } @@ -639,11 +630,20 @@ export function setExtraParam(bid, paramName) { } const adgGlobalConf = config.getConfig('adagio') || {}; - const ortb2Conf = config.getConfig('ortb2'); + const ortb2Conf = bid.ortb2; const detected = adgGlobalConf[paramName] || deepAccess(ortb2Conf, `site.ext.data.${paramName}`, null); if (detected) { - bid.params[paramName] = detected; + // First Party Data can be an array. + // As we consider that params detected from FPD are fallbacks, we just keep the 1st value. + if (Array.isArray(detected)) { + if (detected.length) { + bid.params[paramName] = detected[0].toString(); + } + return; + } + + bid.params[paramName] = detected.toString(); } } @@ -675,10 +675,8 @@ function autoFillParams(bid) { } // extra params - setExtraParam(bid, 'environment'); setExtraParam(bid, 'pagetype'); setExtraParam(bid, 'category'); - setExtraParam(bid, 'subcategory'); } function getPageDimensions() { @@ -767,45 +765,51 @@ function getSlotPosition(adUnitElementId) { position.x = Math.round(sfGeom.t); position.y = Math.round(sfGeom.l); } else if (canAccessTopWindow()) { - // window.top based computing - const wt = getWindowTop(); - const d = wt.document; - - let domElement; - - if (inIframe() === true) { - const ws = getWindowSelf(); - const currentElement = ws.document.getElementById(adUnitElementId); - domElement = internal.getElementFromTopWindow(currentElement, ws); - } else { - domElement = wt.document.getElementById(adUnitElementId); - } - - if (!domElement) { - return ''; - } + try { + // window.top based computing + const wt = getWindowTop(); + const d = wt.document; - let box = domElement.getBoundingClientRect(); + let domElement; - const docEl = d.documentElement; - const body = d.body; - const clientTop = d.clientTop || body.clientTop || 0; - const clientLeft = d.clientLeft || body.clientLeft || 0; - const scrollTop = wt.pageYOffset || docEl.scrollTop || body.scrollTop; - const scrollLeft = wt.pageXOffset || docEl.scrollLeft || body.scrollLeft; + if (inIframe() === true) { + const ws = getWindowSelf(); + const currentElement = ws.document.getElementById(adUnitElementId); + domElement = internal.getElementFromTopWindow(currentElement, ws); + } else { + domElement = wt.document.getElementById(adUnitElementId); + } - const elComputedStyle = wt.getComputedStyle(domElement, null); - const elComputedDisplay = elComputedStyle.display || 'block'; - const mustDisplayElement = elComputedDisplay === 'none'; + if (!domElement) { + return ''; + } - if (mustDisplayElement) { - domElement.style = domElement.style || {}; - domElement.style.display = 'block'; - box = domElement.getBoundingClientRect(); - domElement.style.display = elComputedDisplay; + let box = domElement.getBoundingClientRect(); + + const docEl = d.documentElement; + const body = d.body; + const clientTop = d.clientTop || body.clientTop || 0; + const clientLeft = d.clientLeft || body.clientLeft || 0; + const scrollTop = wt.pageYOffset || docEl.scrollTop || body.scrollTop; + const scrollLeft = wt.pageXOffset || docEl.scrollLeft || body.scrollLeft; + + const elComputedStyle = wt.getComputedStyle(domElement, null); + const elComputedDisplay = elComputedStyle.display || 'block'; + const mustDisplayElement = elComputedDisplay === 'none'; + + if (mustDisplayElement) { + domElement.style = domElement.style || {}; + const originalDisplay = domElement.style.display; + domElement.style.display = 'block'; + box = domElement.getBoundingClientRect(); + domElement.style.display = originalDisplay || null; + } + position.x = Math.round(box.left + scrollLeft - clientLeft); + position.y = Math.round(box.top + scrollTop - clientTop); + } catch (err) { + logError(LOG_PREFIX, err); + return ''; } - position.x = Math.round(box.left + scrollLeft - clientLeft); - position.y = Math.round(box.top + scrollTop - clientTop); } else { return ''; } @@ -867,19 +871,92 @@ function storeRequestInAdagioNS(bidRequest) { bidder: bidRequest.bidder, params: bidRequest.params // use the updated bid.params object with auto-detected params }], - auctionId: bidRequest.auctionId, + auctionId: bidRequest.auctionId, // this auctionId has been generated by adagioBidAdapter pageviewId: internal.getPageviewId(), - printNumber + printNumber, + localPbjs: '$$PREBID_GLOBAL$$', + localPbjsRef: getGlobal() }); // (legacy) Store internal adUnit information w.ADAGIO.adUnits[bidRequest.adUnitCode] = { - auctionId: bidRequest.auctionId, + auctionId: bidRequest.auctionId, // this auctionId has been generated by adagioBidAdapter pageviewId: internal.getPageviewId(), printNumber, }; } +// See https://support.bluebillywig.com/developers/vast-renderer/ +const OUTSTREAM_RENDERER = { + bootstrapPlayer: function(bid) { + const rendererCode = bid.outstreamRendererCode; + + const config = { + code: bid.adUnitCode, + }; + + if (bid.vastXml) { + config.vastXml = bid.vastXml; + } else if (bid.vastUrl) { + config.vastUrl = bid.vastUrl; + } + + if (!bid.vastXml && !bid.vastUrl) { + logError(`${LOG_PREFIX} no vastXml or vastUrl on bid`); + return; + } + + if (!window.bluebillywig || !window.bluebillywig.renderers || !window.bluebillywig.renderers.length) { + logError(`${LOG_PREFIX} no BlueBillywig renderers found!`); + return; + } + + const rendererId = this.getRendererId(BB_PUBLICATION, rendererCode); + + const override = {} + if (bid.skipOffset) { + override.skipOffset = bid.skipOffset.toString() + } + + const renderer = window.bluebillywig.renderers.find(bbr => bbr._id === rendererId); + if (!renderer) { + logError(`${LOG_PREFIX} couldn't find a renderer with ID ${rendererId}`); + return; + } + + const el = document.getElementById(bid.adUnitCode); + + renderer.bootstrap(config, el, override); + }, + newRenderer: function(adUnitCode, rendererCode) { + const rendererUrl = BB_RENDERER_URL.replace('$RENDERER', rendererCode); + + const renderer = Renderer.install({ + url: rendererUrl, + loaded: false, + adUnitCode + }); + + try { + renderer.setRender(this.outstreamRender); + } catch (err) { + logError(`${LOG_PREFIX} error trying to setRender`, err); + } + + return renderer; + }, + outstreamRender: function(bid) { + bid.renderer.push(() => { + OUTSTREAM_RENDERER.bootstrapPlayer(bid) + }); + }, + getRendererId: function(publication, renderer) { + // By convention, the RENDERER_ID is always the publication name (adagio) and the ad unit code (eg. renderer) + // joined together by a dash. It's used to identify the correct renderer instance on the page in case there's multiple. + return `${publication}-${renderer}`; + } +}; + export const spec = { code: BIDDER_CODE, gvlid: GVLID, @@ -900,6 +977,9 @@ export const spec = { }, buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const secure = (location.protocol === 'https:') ? 1 : 0; const device = internal.getDevice(); const site = internal.getSite(bidderRequest); @@ -907,10 +987,20 @@ export const spec = { const gdprConsent = _getGdprConsent(bidderRequest) || {}; const uspConsent = _getUspConsent(bidderRequest) || {}; const coppa = _getCoppa(); + const gppConsent = _getGppConsent(bidderRequest) const schain = _getSchain(validBidRequests[0]); const eids = _getEids(validBidRequests[0]) || []; + const syncEnabled = deepAccess(config.getConfig('userSync'), 'syncEnabled') + const usIfr = syncEnabled && userSync.canBidderRegisterSync('iframe', 'adagio') + + const aucId = generateUUID() + + const adUnits = _map(validBidRequests, (rawBidRequest) => { + const bidRequest = deepClone(rawBidRequest); + + // Fix https://github.com/prebid/Prebid.js/issues/9781 + bidRequest.auctionId = aucId - const adUnits = _map(validBidRequests, (bidRequest) => { const globalFeatures = GlobalExchange.getOrSetGlobalFeatures(); const features = { ...globalFeatures, @@ -918,6 +1008,46 @@ export const spec = { adunit_position: getSlotPosition(bidRequest.params.adUnitElementId) // adUnitElementId à déplacer ??? }; + // Force the Split Keyword to be a String + if (bidRequest.params.splitKeyword) { + if (isStr(bidRequest.params.splitKeyword) || isNumber(bidRequest.params.splitKeyword)) { + bidRequest.params.splitKeyword = bidRequest.params.splitKeyword.toString(); + } else { + delete bidRequest.params.splitKeyword; + + logWarn(LOG_PREFIX, 'The splitKeyword param have been removed because the type is invalid, accepted type: number or string.'); + } + } + + // Force the Data Layer key and value to be a String + if (bidRequest.params.dataLayer) { + if (isStr(bidRequest.params.dataLayer) || isNumber(bidRequest.params.dataLayer) || isArray(bidRequest.params.dataLayer) || isFn(bidRequest.params.dataLayer)) { + logWarn(LOG_PREFIX, 'The dataLayer param is invalid, only object is accepted as a type.'); + delete bidRequest.params.dataLayer; + } else { + let invalidDlParam = false; + + bidRequest.params.dl = bidRequest.params.dataLayer + // Remove the dataLayer from the BidRequest to send the `dl` instead of the `dataLayer` + delete bidRequest.params.dataLayer + + Object.keys(bidRequest.params.dl).forEach((key) => { + if (bidRequest.params.dl[key]) { + if (isStr(bidRequest.params.dl[key]) || isNumber(bidRequest.params.dl[key])) { + bidRequest.params.dl[key] = bidRequest.params.dl[key].toString(); + } else { + invalidDlParam = true; + delete bidRequest.params.dl[key]; + } + } + }); + + if (invalidDlParam) { + logWarn(LOG_PREFIX, 'Some parameters of the dataLayer property have been removed because the type is invalid, accepted type: number or string.'); + } + } + } + Object.keys(features).forEach((prop) => { if (features[prop] === '') { delete features[prop]; @@ -937,7 +1067,45 @@ export const spec = { }); // Handle priceFloors module - bidRequest.floors = _getFloors(bidRequest); + const computedFloors = _getFloors(bidRequest); + if (isArray(computedFloors) && computedFloors.length) { + bidRequest.floors = computedFloors + + if (deepAccess(bidRequest, 'mediaTypes.banner')) { + const bannerObj = bidRequest.mediaTypes.banner + + const computeNewSizeArray = (sizeArr = []) => { + const size = { size: sizeArr, floor: null } + const bannerFloors = bidRequest.floors.filter(floor => floor.mt === BANNER) + const BannerSizeFloor = bannerFloors.find(floor => floor.s === sizeArr.join('x')) + size.floor = (bannerFloors) ? (BannerSizeFloor) ? BannerSizeFloor.f : bannerFloors[0].f : null + return size + } + + // `bannerSizes`, internal property name + bidRequest.mediaTypes.banner.bannerSizes = (isArray(bannerObj.sizes[0])) + ? bannerObj.sizes.map(sizeArr => { + return computeNewSizeArray(sizeArr) + }) + : computeNewSizeArray(bannerObj.sizes) + } + + if (deepAccess(bidRequest, 'mediaTypes.video')) { + const videoObj = bidRequest.mediaTypes.video + const videoFloors = bidRequest.floors.filter(floor => floor.mt === VIDEO); + const playerSize = (videoObj.playerSize && isArray(videoObj.playerSize[0])) ? videoObj.playerSize[0] : videoObj.playerSize + const videoSizeFloor = (playerSize) ? videoFloors.find(floor => floor.s === playerSize.join('x')) : undefined + + bidRequest.mediaTypes.video.floor = (videoFloors) ? videoSizeFloor ? videoSizeFloor.f : videoFloors[0].f : null + } + + if (deepAccess(bidRequest, 'mediaTypes.native')) { + const nativeFloors = bidRequest.floors.filter(floor => floor.mt === NATIVE); + if (nativeFloors.length) { + bidRequest.mediaTypes.native.floor = nativeFloors[0].f + } + } + } if (deepAccess(bidRequest, 'mediaTypes.video')) { _buildVideoBidRequest(bidRequest); @@ -945,6 +1113,12 @@ export const spec = { storeRequestInAdagioNS(bidRequest); + // Remove these fields at the very end, so we can still use them before. + delete bidRequest.transactionId; + delete bidRequest.ortb2Imp; + delete bidRequest.ortb2; + delete bidRequest.sizes; + return bidRequest; }); @@ -956,6 +1130,8 @@ export const spec = { // remove useless props delete adUnitCopy.floorData; delete adUnitCopy.params.siteId; + delete adUnitCopy.userId; + delete adUnitCopy.userIdAsEids; groupedAdUnits[adUnitCopy.params.organizationId] = groupedAdUnits[adUnitCopy.params.organizationId] || []; groupedAdUnits[adUnitCopy.params.organizationId].push(adUnitCopy); @@ -963,13 +1139,20 @@ export const spec = { return groupedAdUnits; }, {}); + // Adding more params on the original bid object. + // Those params are not sent to the server. + // They are used for further operations on analytics adapter. + validBidRequests.forEach(rawBidRequest => { + rawBidRequest.params.adagioAuctionId = aucId + rawBidRequest.params.pageviewId = pageviewId + }); + // Build one request per organizationId const requests = _map(Object.keys(groupedAdUnits), organizationId => { return { method: 'POST', url: ENDPOINT, data: { - id: generateUUID(), organizationId: organizationId, secure: secure, device: device, @@ -980,14 +1163,18 @@ export const spec = { regs: { gdpr: gdprConsent, coppa: coppa, - ccpa: uspConsent + ccpa: uspConsent, + gpp: gppConsent.gpp, + gppSid: gppConsent.gppSid }, schain: schain, user: { eids: eids }, prebidVersion: '$prebid.version$', - featuresVersion: FEATURES_VERSION + featuresVersion: FEATURES_VERSION, + usIfr: usIfr, + adgjs: storage.localStorageIsEnabled() }, options: { contentType: 'text/plain' @@ -1023,21 +1210,18 @@ export const spec = { const mediaTypeContext = deepAccess(bidReq, 'mediaTypes.video.context'); // Adagio SSP returns a `vastXml` only. No `vastUrl` nor `videoCacheKey`. if (!bidObj.vastUrl && bidObj.vastXml) { - bidObj.vastUrl = 'data:text/xml;charset=utf-8;base64,' + btoa(bidObj.vastXml.replace(/\\"/g, '"')); + bidObj.vastUrl = 'data:text/xml;charset=utf-8;base64,' + window.btoa(bidObj.vastXml.replace(/\\"/g, '"')); } if (mediaTypeContext === OUTSTREAM) { - bidObj.renderer = Renderer.install({ - id: bidObj.requestId, - adUnitCode: bidObj.adUnitCode, - url: bidObj.urlRenderer || RENDERER_URL, - config: { - ...deepAccess(bidReq, 'mediaTypes.video'), - ...deepAccess(bidObj, 'outstream', {}) - } - }); - - bidObj.renderer.setRender(_renderer); + bidObj.outstreamRendererCode = deepAccess(bidReq, 'params.rendererCode', BB_RENDERER_DEFAULT) + + if (deepAccess(bidReq, 'mediaTypes.video.skip')) { + const skipOffset = deepAccess(bidReq, 'mediaTypes.video.skipafter', 5) // default 5s. + bidObj.skipOffset = skipOffset + } + + bidObj.renderer = OUTSTREAM_RENDERER.newRenderer(bidObj.adUnitCode, bidObj.outstreamRendererCode); } } @@ -1049,8 +1233,6 @@ export const spec = { bidObj.placement = bidReq.params.placement; bidObj.pagetype = bidReq.params.pagetype; bidObj.category = bidReq.params.category; - bidObj.subcategory = bidReq.params.subcategory; - bidObj.environment = bidReq.params.environment; } bidResponses.push(bidObj); }); @@ -1085,33 +1267,8 @@ export const spec = { * @returns {object} updated params */ transformBidParams(params, isOrtb, adUnit, bidRequests) { - const adagioBidderRequest = find(bidRequests, bidRequest => bidRequest.bidderCode === 'adagio'); - const adagioBid = find(adagioBidderRequest.bids, bid => bid.adUnitCode === adUnit.code); - - if (isOrtb) { - autoFillParams(adagioBid); - - adagioBid.params.auctionId = deepAccess(adagioBidderRequest, 'auctionId'); - - const globalFeatures = GlobalExchange.getOrSetGlobalFeatures(); - adagioBid.params.features = { - ...globalFeatures, - print_number: getPrintNumber(adagioBid.adUnitCode, adagioBidderRequest).toString(), - adunit_position: getSlotPosition(adagioBid.params.adUnitElementId) // adUnitElementId à déplacer ??? - } - - adagioBid.params.pageviewId = internal.getPageviewId(); - adagioBid.params.prebidVersion = '$prebid.version$'; - adagioBid.params.data = GlobalExchange.getExchangeData(); - - if (deepAccess(adagioBid, 'mediaTypes.video.context') === OUTSTREAM) { - adagioBid.params.playerName = setPlayerName(adagioBid); - } - - storeRequestInAdagioNS(adagioBid); - } - - return adagioBid.params; + // We do not have a prebid server adapter. So let's return unchanged params. + return params; } }; diff --git a/modules/adagioBidAdapter.md b/modules/adagioBidAdapter.md index 889822d9bd4..45f39fc6f2d 100644 --- a/modules/adagioBidAdapter.md +++ b/modules/adagioBidAdapter.md @@ -10,30 +10,65 @@ Connects to Adagio demand source to fetch bids. ## Configuration -Adagio require several params. These params must be set at Prebid.js global config level or at adUnit level. +### User Sync + +Add the following code to enable user sync. Adagio strongly recommends enabling user syncing through iframes. This functionality improves DSP user match rates and increases the bid rate and bid price. Be sure to call `pbjs.setConfig()` only once. + +```javascript +pbjs.setConfig({ + userSync: { + iframeEnabled: true, + filterSettings: { + iframe: { + bidders: ['adagio'], + filter: 'include' + } + } + } +}); +``` + +### Bidder Settings + +The Adagio bid adapter uses browser local storage. Since Prebid.js 7.x, the access to it must be explicitly set. + +```js +// https://docs.prebid.org/dev-docs/publisher-api-reference/bidderSettings.html +pbjs.bidderSettings = { + adagio: { + storageAllowed: true + } +} +``` + +### Params configuration + +Adagio require several params. These params must be set at Prebid.js BidderConfig config level or at adUnit level. Below, the list of Adagio params and where they can be set. -| Param name | Global config | AdUnit config | -| ---------- | ------------- | ------------- | -| siteId | x | -| organizationId (obsolete) | | x -| site (obsolete) | | x -| pagetype | x | x -| environment | x | x -| category | x | x -| subcategory | x | x -| useAdUnitCodeAsAdUnitElementId | x | x -| useAdUnitCodeAsPlacement | x | x -| placement | | x -| adUnitElementId | | x -| debug | | x -| video | | x -| native | | x - -### Global configuration - -The global configuration is used to store params once instead of duplicate them to each adUnit. The values will be used as "params" in the ad-request. +| Param name | Global config | AdUnit config | +| ------------------------------ | ------------- | ------------- | +| siteId | x | | +| organizationId * | | x | +| site * | | x | +| pagetype | x | x | +| category | x | x | +| useAdUnitCodeAsAdUnitElementId | x | x | +| useAdUnitCodeAsPlacement | x | x | +| placement | | x | +| adUnitElementId | | x | +| debug | | x | +| video | | x | +| native | | x | +| splitKeyword | | x | +| dataLayer | | x | + +_* These params are deprecated in favor the Global configuration setup, see below._ + +#### Global Adagio configuration + +The global Adagio configuration is used to store params once instead of duplicate them to each adUnit. The values will be used as "params" in the ad-request. Be sure to call `pbjs.setConfig()` only once. ```javascript pbjs.setConfig({ @@ -49,17 +84,14 @@ pbjs.setConfig({ // - underscores `_` // Also, each param can have at most 50 unique active values (case-insensitive). pagetype: 'article', // Highly recommended. The pagetype describes what kind of content will be present in the page. - environment: 'mobile', // Recommended. Environment where the page is displayed. category: 'sport', // Recommended. Category of the content displayed in the page. - subcategory: 'handball', // Optional. Subcategory of the content displayed in the page. useAdUnitCodeAsAdUnitElementId: false, // Optional. Use it by-pass adUnitElementId and use the adUnit code as value useAdUnitCodeAsPlacement: false, // Optional. Use it to by-pass placement and use the adUnit code as value - }, + } }); ``` -### adUnit configuration - +#### Ad-unit configuration ```javascript var adUnits = [ { @@ -75,20 +107,34 @@ 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. context: 1, plcmttype: 2 }, + splitKeyword: 'splitrule-one', + dl: { + placement: '1234' + } } }] } ]; ``` +#### Note on FPD support + +Adagio will use FPD data as fallback for the params below: +- pagetype +- category + +If the FPD value is an array, the 1st value of this array will be used. + ## Test Parameters ```javascript @@ -97,11 +143,17 @@ var adUnits = [ debug: true, adagio: { pagetype: 'article', - environment: 'mobile', category: 'sport', - subcategory: 'handball', useAdUnitCodeAsAdUnitElementId: false, useAdUnitCodeAsPlacement: false, + }, + userSync: { + filterSettings: { + iframe: { + bidders: ['adagio'], + filter: 'include' + } + } } }); @@ -198,12 +250,6 @@ var adUnits = [ return bidResponse.site; } }, - { - key: "environment", - val: function (bidResponse) { - return bidResponse.environment; - } - }, { key: "placement", val: function (bidResponse) { @@ -221,12 +267,6 @@ var adUnits = [ val: function (bidResponse) { return bidResponse.category; } - }, - { - key: "subcategory", - val: function (bidResponse) { - return bidResponse.subcategory; - } } ] } diff --git a/modules/adblender.md b/modules/adblender.md deleted file mode 100644 index e70b2a4a8ed..00000000000 --- a/modules/adblender.md +++ /dev/null @@ -1,36 +0,0 @@ -# Overview - -Module Name: AdBlender Bidder Adapter -Module Type: Bidder Adapter -Maintainer: contact@ad-blender.com - -# Description - -Connects to AdBlender demand source to fetch bids. -Banner and Video formats are supported. -Please use ```adblender``` as the bidder code. -#Bidder Config -You can set an alternate endpoint url `pbjs.setBidderConfig` for the bidder `adblender` -``` -pbjs.setBidderConfig({ - bidders: ["adblender"], - config: {"adblender": { "endpoint_url": "https://inv-nets.admixer.net/adblender.1.1.aspx"}} - }) -``` -# Ad Unit Example -``` - var adUnits = [ - { - code: 'desktop-banner-ad-div', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: "adblender", - params: { - zone: 'fb3d34d0-7a88-4a4a-a5c9-8088cd7845f4' - } - } - ] - } - ]; -``` diff --git a/modules/adbookpspBidAdapter.js b/modules/adbookpspBidAdapter.js index de8a3598be1..cb03f2ffc17 100644 --- a/modules/adbookpspBidAdapter.js +++ b/modules/adbookpspBidAdapter.js @@ -19,6 +19,7 @@ import { uniques } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; /** * CONSTANTS @@ -101,6 +102,9 @@ function isBidRequestValid(bidRequest) { } function buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const requests = []; if (validBidRequests.length > 0) { @@ -123,9 +127,9 @@ function buildRequest(validBidRequests, bidderRequest) { id: bidderRequest.bidderRequestId, tmax: bidderRequest.timeout, site: { - domain: window.location.hostname, - page: window.location.href, - ref: bidderRequest.refererInfo.referer, + domain: bidderRequest.refererInfo.domain, + page: bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.ref, }, source: buildSource(validBidRequests, bidderRequest), device: buildDevice(), @@ -199,7 +203,7 @@ function buildRegs(bidderRequest) { function buildSource(bidRequests, bidderRequest) { const source = { fd: 1, - tid: bidderRequest.auctionId, + tid: bidderRequest.ortb2.source.tid, }; const schain = deepAccess(bidRequests, '0.schain'); diff --git a/modules/adbutlerBidAdapter.md b/modules/adbutlerBidAdapter.md deleted file mode 100644 index 1921cc4046e..00000000000 --- a/modules/adbutlerBidAdapter.md +++ /dev/null @@ -1,34 +0,0 @@ -# Overview - -**Module Name**: AdButler Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: dan@sparklit.com - -# Description - -Module that connects to an AdButler zone to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'display-div', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: "adbutler", - params: { - accountID: '167283', - zoneID: '210093', - keyword: 'red', //optional - minCPM: '1.00', //optional - maxCPM: '5.00' //optional - extra: { // optional - foo: "bar" - } - } - } - ] - } - ]; -``` diff --git a/modules/addefendBidAdapter.js b/modules/addefendBidAdapter.js index dcc453ef35a..dbb186fdc86 100644 --- a/modules/addefendBidAdapter.js +++ b/modules/addefendBidAdapter.js @@ -1,4 +1,5 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getGlobal} from '../src/prebidGlobal.js'; const BIDDER_CODE = 'addefend'; @@ -16,18 +17,20 @@ export const spec = { }, buildRequests: function(validBidRequests, bidderRequest) { let bid = { - v: $$PREBID_GLOBAL$$.version, + v: getGlobal().version, auctionId: false, pageId: false, gdpr_applies: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? bidderRequest.gdprConsent.gdprApplies : 'true', gdpr_consent: bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString ? bidderRequest.gdprConsent.consentString : '', - referer: bidderRequest.refererInfo.referer, + // TODO: is 'page' the correct item here? + referer: bidderRequest.refererInfo.page, bids: [], }; for (var i = 0; i < validBidRequests.length; i++) { let vb = validBidRequests[i]; let o = vb.params; + // TODO: fix auctionId/transactionId leak: https://github.com/prebid/Prebid.js/issues/9781 bid.auctionId = vb.auctionId; o.bidId = vb.bidId; o.transactionId = vb.transactionId; diff --git a/modules/adfBidAdapter.js b/modules/adfBidAdapter.js index f0425a174ff..e5b40f66176 100644 --- a/modules/adfBidAdapter.js +++ b/modules/adfBidAdapter.js @@ -1,15 +1,11 @@ // jshint esversion: 6, es3: false, node: true 'use strict'; -import { - registerBidder -} from '../src/adapters/bidderFactory.js'; -import { - NATIVE, BANNER, VIDEO -} from '../src/mediaTypes.js'; -import { mergeDeep, _map, deepAccess, parseSizesInput, deepSetValue } from '../src/utils.js'; -import { config } from '../src/config.js'; -import { Renderer } from '../src/Renderer.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {deepAccess, deepClone, deepSetValue, mergeDeep, parseSizesInput} from '../src/utils.js'; +import {config} from '../src/config.js'; +import {Renderer} from '../src/Renderer.js'; const { getConfig } = config; @@ -19,38 +15,7 @@ const BIDDER_ALIAS = [ { code: 'adformOpenRTB', gvlid: GVLID }, { code: 'adform', gvlid: GVLID } ]; -const NATIVE_ASSET_IDS = { 0: 'title', 2: 'icon', 3: 'image', 5: 'sponsoredBy', 4: 'body', 1: 'cta' }; -const NATIVE_PARAMS = { - title: { - id: 0, - name: 'title' - }, - icon: { - id: 2, - type: 1, - name: 'img' - }, - image: { - id: 3, - type: 3, - name: 'img' - }, - sponsoredBy: { - id: 5, - name: 'data', - type: 1 - }, - body: { - id: 4, - name: 'data', - type: 2 - }, - cta: { - id: 1, - type: 12, - name: 'data' - } -}; + const OUTSTREAM_RENDERER_URL = 'https://s2.adform.net/banners/scripts/video/outstream/render.js'; export const spec = { @@ -66,7 +31,7 @@ export const spec = { buildRequests: (validBidRequests, bidderRequest) => { let app, site; - const commonFpd = getConfig('ortb2') || {}; + const commonFpd = bidderRequest.ortb2 || {}; let { user } = commonFpd; if (typeof getConfig('app') === 'object') { @@ -81,7 +46,7 @@ export const spec = { } if (!site.page) { - site.page = bidderRequest.refererInfo.referer; + site.page = bidderRequest.refererInfo.page; } } @@ -93,7 +58,7 @@ export const spec = { const adxDomain = setOnAny(validBidRequests, 'params.adxDomain') || 'adx.adform.net'; const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net'; - const tid = validBidRequests[0].transactionId; + const tid = bidderRequest.ortb2?.source?.tid; const test = setOnAny(validBidRequests, 'params.test'); const currency = getConfig('currency.adServerCurrency'); const cur = currency && [ currency ]; @@ -104,8 +69,11 @@ export const spec = { bid.netRevenue = pt; const floorInfo = bid.getFloor ? bid.getFloor({ - currency: currency || 'USD' + currency: currency || 'USD', + size: '*', + mediaType: '*' }) : {}; + const bidfloor = floorInfo.floor; const bidfloorcur = floorInfo.currency; const { mid, inv, mname } = bid.params; @@ -123,45 +91,28 @@ export const spec = { } }; - const assets = _map(bid.nativeParams, (bidParams, key) => { - const props = NATIVE_PARAMS[key]; - const asset = { - required: bidParams.required & 1, - }; - if (props) { - asset.id = props.id; - let wmin, hmin, w, h; - let aRatios = bidParams.aspect_ratios; - - if (aRatios && aRatios[0]) { - aRatios = aRatios[0]; - wmin = aRatios.min_width || 0; - hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0; - } - - if (bidParams.sizes) { - const sizes = flatten(bidParams.sizes); - w = sizes[0]; - h = sizes[1]; + if (bid.nativeOrtbRequest && bid.nativeOrtbRequest.assets) { + let assets = bid.nativeOrtbRequest.assets; + let requestAssets = []; + for (let i = 0; i < assets.length; i++) { + let asset = deepClone(assets[i]); + let img = asset.img; + if (img) { + let aspectratios = img.ext && img.ext.aspectratios; + + if (aspectratios) { + let ratioWidth = parseInt(aspectratios[0].split(':')[0], 10); + let ratioHeight = parseInt(aspectratios[0].split(':')[1], 10); + img.wmin = img.wmin || 0; + img.hmin = ratioHeight * img.wmin / ratioWidth | 0; + } } - - asset[props.name] = { - len: bidParams.len, - type: props.type, - wmin, - hmin, - w, - h - }; - - return asset; + requestAssets.push(asset); } - }).filter(Boolean); - if (assets.length) { imp.native = { request: { - assets + assets: requestAssets } }; } @@ -191,7 +142,7 @@ export const spec = { }); const request = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, site, app, user, @@ -206,6 +157,11 @@ export const spec = { request.is_debug = !!test; request.test = 1; } + + if (config.getConfig('coppa')) { + deepSetValue(request, 'regs.coppa', 1); + } + if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) { deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1); @@ -227,9 +183,6 @@ export const spec = { method: 'POST', url: 'https://' + adxDomain + '/adx/openrtb', data: JSON.stringify(request), - options: { - contentType: 'application/json' - }, bids: validBidRequests }; }, @@ -266,7 +219,9 @@ export const spec = { }; if (bidResponse.native) { - result.native = parseNative(bidResponse); + result.native = { + ortb: bidResponse.native + }; } else { result[ mediaType === VIDEO ? 'vastXml' : 'ad' ] = bidResponse.adm; } @@ -284,25 +239,6 @@ export const spec = { registerBidder(spec); -function parseNative(bid) { - const { assets, link, imptrackers, jstracker } = bid.native; - const result = { - clickUrl: link.url, - clickTrackers: link.clicktrackers || undefined, - impressionTrackers: imptrackers || undefined, - javascriptTrackers: jstracker ? [ jstracker ] : undefined - }; - assets.forEach(asset => { - const kind = NATIVE_ASSET_IDS[asset.id]; - const content = kind && asset[NATIVE_PARAMS[kind].name]; - if (content) { - result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h }; - } - }); - - return result; -} - function setOnAny(collection, key) { for (let i = 0, result; i < collection.length; i++) { result = deepAccess(collection[i], key); diff --git a/modules/adfinityBidAdapter.md b/modules/adfinityBidAdapter.md deleted file mode 100644 index f67d4fddfe7..00000000000 --- a/modules/adfinityBidAdapter.md +++ /dev/null @@ -1,67 +0,0 @@ -# Overview - -``` -Module Name: Adfinity Bidder Adapter -Module Type: Bidder Adapter -Maintainer: adfinity_prebid@i.ua -``` - -# Description - -Module that connects to Adfinity demand sources - -# Test Parameters -``` - var adUnits = [ - { - code: 'placementid_0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]] - } - }, - bids: [{ - bidder: 'adfinity', - params: { - placement_id: 0, - traffic: 'banner' - } - } - ] - }, - { - code: 'placementid_0', - mediaTypes: { - native: { - - } - }, - bids: [ - { - bidder: 'adfinity', - params: { - placement_id: 0, - traffic: 'native' - } - } - ] - }, - { - code: 'placementid_0', - mediaTypes: { - video: { - sizes: [[300, 250], [300,600]] - } - }, - bids: [ - { - bidder: 'adfinity', - params: { - placement_id: 0, - traffic: 'video' - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/adfusionBidAdapter.js b/modules/adfusionBidAdapter.js new file mode 100644 index 00000000000..b3638159c2a --- /dev/null +++ b/modules/adfusionBidAdapter.js @@ -0,0 +1,90 @@ +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; + +const adpterVersion = '1.0'; +export const REQUEST_URL = 'https://spicyrtb.com/auction/prebid'; + +export const spec = { + code: 'adfusion', + gvlid: 844, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid, + buildRequests, + interpretResponse, + isBannerBid, + isVideoBid, +}; + +registerBidder(spec); + +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 300, + }, + request(buildRequest, imps, bidderRequest, context) { + const req = buildRequest(imps, bidderRequest, context); + const bid = context.bidRequests[0]; + utils.mergeDeep(req, { + at: 1, + ext: { + prebid: { + accountid: bid.params.accountId, + adapterVersion: `${adpterVersion}`, + }, + }, + }); + return req; + }, + response(buildResponse, bidResponses, ortbResponse, context) { + const response = buildResponse(bidResponses, ortbResponse, context); + return response.bids; + }, +}); + +function isBidRequestValid(bidRequest) { + const isValid = bidRequest.params.accountId; + if (!isValid) { + utils.logError('AdFusion adapter bidRequest has no accountId'); + return false; + } + return true; +} + +function buildRequests(bids, bidderRequest) { + let videoBids = bids.filter((bid) => isVideoBid(bid)); + let bannerBids = bids.filter((bid) => isBannerBid(bid)); + let requests = bannerBids.length + ? [createRequest(bannerBids, bidderRequest, BANNER)] + : []; + videoBids.forEach((bid) => { + requests.push(createRequest([bid], bidderRequest, VIDEO)); + }); + return requests; +} + +function createRequest(bidRequests, bidderRequest, mediaType) { + return { + method: 'POST', + url: REQUEST_URL, + data: converter.toORTB({ + bidRequests, + bidderRequest, + context: { mediaType }, + }), + }; +} + +function isVideoBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.video'); +} + +function isBannerBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.banner'); +} + +function interpretResponse(resp, req) { + return converter.fromORTB({ request: req.data, response: resp.body }); +} diff --git a/modules/adfusionBidAdapter.md b/modules/adfusionBidAdapter.md new file mode 100644 index 00000000000..803a03ba1a1 --- /dev/null +++ b/modules/adfusionBidAdapter.md @@ -0,0 +1,61 @@ +# Overview + +``` +Module Name: AdFusion Bid Adapter +Module Type: Bidder Adapter +Maintainer: prebid@adfusion.pl +``` + +# Description + +Module that connects to AdFusion demand sources + +# Banner Test Parameters + +```js +var adUnits = [ + { + code: "test-banner", + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + [320, 480], + ], + }, + }, + bids: [ + { + bidder: "adfusion", + params: { + accountId: 1234, // required + }, + }, + ], + }, +]; +``` + +# Video Test Parameters + +```js +var videoAdUnit = { + code: "video1", + mediaTypes: { + video: { + context: "instream", + playerSize: [640, 480], + mimes: ["video/mp4"], + }, + }, + bids: [ + { + bidder: "adfusion", + params: { + accountId: 1234, // required + }, + }, + ], +}; +``` diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index e0d3a881cad..b40378c8e35 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -1,7 +1,10 @@ -import {tryAppendQueryString, getBidIdParameter} from '../src/utils.js'; +import {deepAccess, getBidIdParameter} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; +import {escapeUnsafeChars} from '../libraries/htmlEscape/htmlEscape.js'; const ADG_BIDDER_CODE = 'adgeneration'; @@ -20,18 +23,27 @@ export const spec = { }, /** * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids + * @param validBidRequests + * @param bidderRequest * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { - const ADGENE_PREBID_VERSION = '1.3.0'; + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const ADGENE_PREBID_VERSION = '1.6.2'; let serverRequests = []; for (let i = 0, len = validBidRequests.length; i < len; i++) { const validReq = validBidRequests[i]; const DEBUG_URL = 'https://api-test.scaleout.jp/adsv/v1'; const URL = 'https://d.socdm.com/adsv/v1'; const url = validReq.params.debug ? DEBUG_URL : URL; + const criteoId = getCriteoId(validReq); + const id5id = getId5Id(validReq); + const id5LinkType = getId5LinkType(validReq); + const imuid = deepAccess(validReq, 'userId.imuid'); + const gpid = deepAccess(validReq, 'ortb2Imp.ext.gpid'); + const sua = deepAccess(validReq, 'ortb2.device.sua'); + const uid2 = deepAccess(validReq, 'userId.uid2.id'); let data = ``; data = tryAppendQueryString(data, 'posall', 'SSPLOC'); const id = getBidIdParameter('id', validReq.params); @@ -39,17 +51,27 @@ export const spec = { data = tryAppendQueryString(data, 'sdktype', '0'); data = tryAppendQueryString(data, 'hb', 'true'); data = tryAppendQueryString(data, 't', 'json3'); - data = tryAppendQueryString(data, 'transactionid', validReq.transactionId); + data = tryAppendQueryString(data, 'transactionid', validReq.ortb2Imp?.ext?.tid); data = tryAppendQueryString(data, 'sizes', getSizes(validReq)); data = tryAppendQueryString(data, 'currency', getCurrencyType()); data = tryAppendQueryString(data, 'pbver', '$prebid.version$'); data = tryAppendQueryString(data, 'sdkname', 'prebidjs'); data = tryAppendQueryString(data, 'adapterver', ADGENE_PREBID_VERSION); + data = tryAppendQueryString(data, 'adgext_criteo_id', criteoId); + data = tryAppendQueryString(data, 'adgext_id5_id', id5id); + data = tryAppendQueryString(data, 'adgext_id5_id_link_type', id5LinkType); + data = tryAppendQueryString(data, 'adgext_imuid', imuid); + data = tryAppendQueryString(data, 'adgext_uid2', uid2); + data = tryAppendQueryString(data, 'gpid', gpid); + data = tryAppendQueryString(data, 'uach', sua ? JSON.stringify(sua) : null); + data = tryAppendQueryString(data, 'schain', validReq.schain ? JSON.stringify(validReq.schain) : null); + // native以外にvideo等の対応が入った場合は要修正 if (!validReq.mediaTypes || !validReq.mediaTypes.native) { data = tryAppendQueryString(data, 'imark', '1'); } - data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.referer); + + data = tryAppendQueryString(data, 'tp', bidderRequest.refererInfo.page); if (isIos()) { const hyperId = getHyperId(validReq); if (hyperId != null) { @@ -189,7 +211,7 @@ function createNativeAd(body) { native.clickTrackers = body.native_ad.link.clicktrackers || []; native.impressionTrackers = body.native_ad.imptrackers || []; if (body.beaconurl && body.beaconurl != '') { - native.impressionTrackers.push(body.beaconurl) + native.impressionTrackers.push(body.beaconurl); } } return native; @@ -199,35 +221,45 @@ function appendChildToBody(ad, data) { return ad.replace(/<\/\s?body>/, `${data}`); } +/** + * create APVTag + * @return {string} + */ function createAPVTag() { const APVURL = 'https://cdn.apvdr.com/js/VideoAd.min.js'; - let apvScript = document.createElement('script'); - apvScript.type = 'text/javascript'; - apvScript.id = 'apv'; - apvScript.src = APVURL; - return apvScript.outerHTML; + return `` } +/** + * create ADGBrowserMTag + * @return {string} + */ function createADGBrowserMTag() { const ADGBrowserMURL = 'https://i.socdm.com/sdk/js/adg-browser-m.js'; return ``; } +/** + * create APVTag & insertVast + * @param targetId + * @param vastXml + * @return {string} + */ function insertVASTMethodForAPV(targetId, vastXml) { let apvVideoAdParam = { s: targetId }; - let script = document.createElement(`script`); - script.type = 'text/javascript'; - script.innerHTML = `(function(){ new APV.VideoAd(${JSON.stringify(apvVideoAdParam)}).load('${vastXml.replace(/\r?\n/g, '')}'); })();`; - return script.outerHTML; + return `` } +/** + * create ADGBrowserMTag & insertVast + * @param vastXml + * @param marginTop + * @return {string} + */ function insertVASTMethodForADGBrowserM(vastXml, marginTop) { - const script = document.createElement(`script`); - script.type = 'text/javascript'; - script.innerHTML = `window.ADGBrowserM.init({vastXml: '${vastXml.replace(/\r?\n/g, '')}', marginTop: '${marginTop}'});`; - return script.outerHTML; + return `` } /** @@ -274,6 +306,22 @@ function getCurrencyType() { * @param validReq request * @return {null|string} */ +function getCriteoId(validReq) { + return (validReq.userId && validReq.userId.criteoId) ? validReq.userId.criteoId : null +} + +function getId5Id(validReq) { + return validId5(validReq) ? validReq.userId.id5id.uid : null +} + +function getId5LinkType(validReq) { + return validId5(validReq) ? validReq.userId.id5id.ext.linkType : null +} + +function validId5(validReq) { + return validReq.userId && validReq.userId.id5id && validReq.userId.id5id.uid && validReq.userId.id5id.ext.linkType +} + function getHyperId(validReq) { if (validReq.userId && validReq.userId.novatiq && validReq.userId.novatiq.snowflake.syncResponse === 1) { return validReq.userId.novatiq.snowflake.id; diff --git a/modules/adglareBidAdapter.md b/modules/adglareBidAdapter.md deleted file mode 100644 index 845564473c7..00000000000 --- a/modules/adglareBidAdapter.md +++ /dev/null @@ -1,36 +0,0 @@ -# Overview - -``` -Module Name: AdGlare Ad Server Adapter -Module Type: Bidder Adapter -Maintainer: prebid@adglare.com -``` - -# Description - -Adapter that connects to your AdGlare Ad Server. -Including support for your white label ad serving domain. - -# Test Parameters -``` - var adUnits = [ - { - code: 'your-div-id', - mediaTypes: { - banner: { - sizes: [[300,250], [728,90]], - } - }, - bids: [ - { - bidder: 'adglare', - params: { - domain: 'try.engine.adglare.net', - zID: '475579334', - type: 'banner' - } - } - ] - } - ]; -``` diff --git a/modules/adhashBidAdapter.js b/modules/adhashBidAdapter.js index 7f5af047993..96e93883de6 100644 --- a/modules/adhashBidAdapter.js +++ b/modules/adhashBidAdapter.js @@ -1,10 +1,12 @@ -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {includes} from '../src/polyfill.js'; -import {BANNER} from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { includes } from '../src/polyfill.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; -const VERSION = '1.0'; +const VERSION = '3.6'; const BAD_WORD_STEP = 0.1; const BAD_WORD_MIN = 0.2; +const ADHASH_BIDDER_CODE = 'adhash'; /** * Function that checks the page where the ads are being served for brand safety. @@ -17,6 +19,8 @@ const BAD_WORD_MIN = 0.2; * @returns boolean flag is the page safe */ function brandSafety(badWords, maxScore) { + const delimiter = '~'; + /** * Performs the ROT13 encoding on the string argument and returns the resulting string. * The Adhash bidder uses ROT13 so that the response is not blocked by: @@ -38,59 +42,128 @@ function brandSafety(badWords, maxScore) { /** * Calculates the scoring for each bad word with dimishing returns * @param {integer} points points that this word costs - * @param {integer} occurances number of occurances + * @param {integer} occurrences number of occurrences * @returns {float} final score */ - const scoreCalculator = (points, occurances) => { + const scoreCalculator = (points, occurrences) => { let positive = true; if (points < 0) { points *= -1; positive = false; } let result = 0; - for (let i = 0; i < occurances; i++) { + for (let i = 0; i < occurrences; i++) { result += Math.max(points - i * BAD_WORD_STEP, BAD_WORD_MIN); } return positive ? result : -result; }; + /** + * Checks what rule will match in the given array with words + * @param {string} rule rule type (full, partial, starts, ends, regexp) + * @param {string} decodedWord decoded word + * @param {string} wordsToMatch list of all words on the page separated by delimiters + * @returns {object|boolean} matched rule and occurances. If nothing is matched returns false + */ + const wordsMatchedWithRule = function (rule, decodedWord, wordsToMatch) { + if (!wordsToMatch) { + return false; + } + + let occurrences; + let adjustedWordToMatch; + decodedWord = decodedWord.split(' ').join(`${delimiter}${delimiter}`); + switch (rule) { + case 'full': + adjustedWordToMatch = `${delimiter}${decodedWord}${delimiter}`; + break; + case 'partial': + adjustedWordToMatch = decodedWord; + break; + case 'starts': + adjustedWordToMatch = `${delimiter}${decodedWord}`; + break; + case 'ends': + adjustedWordToMatch = `${decodedWord}${delimiter}`; + break; + case 'combo': + const allOccurrences = []; + const paddedWordsToMatch = `${delimiter}${wordsToMatch}${delimiter}`; + const decodedWordsSplit = decodedWord.split(`${delimiter}${delimiter}`); + for (const decodedWordPart of decodedWordsSplit) { + adjustedWordToMatch = `${delimiter}${decodedWordPart}${delimiter}`; + allOccurrences.push(paddedWordsToMatch.split(adjustedWordToMatch).length - 1); + } + occurrences = Math.min(...allOccurrences); + return occurrences > 0 ? { rule, occurrences } : false; + case 'regexp': + occurrences = [...wordsToMatch.matchAll(new RegExp(decodedWord, 'gi'))].length; + return occurrences > 0 ? { rule, occurrences } : false; + default: + return false; + } + + const paddedWordsToMatch = `${delimiter}${wordsToMatch}${delimiter}`; + occurrences = paddedWordsToMatch.split(adjustedWordToMatch).length - 1; + return occurrences > 0 ? { rule, occurrences } : false; + }; + // Default parameters if the bidder is unable to send some of them badWords = badWords || []; maxScore = parseInt(maxScore) || 10; try { let score = 0; + const decodedUrl = decodeURI(window.top.location.href.substring(window.top.location.origin.length)); + const wordsAndNumbersInUrl = decodedUrl + .replaceAll(/[-,\._/\?=&#%]/g, ' ') + .replaceAll(/\s\s+/g, ' ') + .toLowerCase() + .trim(); const content = window.top.document.body.innerText.toLowerCase(); - const words = content.trim().split(/\s+/).length; + // \p{L} matches a single unicode code point in the category 'letter'. Matches any kind of letter from any language. + const regexp = new RegExp('[\\p{L}]+', 'gu'); + const wordsMatched = content.match(regexp); + const words = wordsMatched.join(`${delimiter}${delimiter}`); + const wordsInUrl = wordsAndNumbersInUrl.match(regexp).join(`${delimiter}${delimiter}`); + for (const [word, rule, points] of badWords) { - if (rule === 'full' && new RegExp('\\b' + rot13(word) + '\\b', 'i').test(content)) { - const occurances = content.match(new RegExp('\\b' + rot13(word) + '\\b', 'g')).length; - score += scoreCalculator(points, occurances); - } else if (rule === 'partial' && content.indexOf(rot13(word.toLowerCase())) > -1) { - const occurances = content.match(new RegExp(rot13(word), 'g')).length; - score += scoreCalculator(points, occurances); + const decodedWord = rot13(word.toLowerCase()); + + // Checks the words in the url of the page only for negative words. Don't serve any ad when at least one match is found + if (points > 0) { + const matchedRuleInUrl = wordsMatchedWithRule(rule, decodedWord, wordsInUrl); + if (matchedRuleInUrl.rule) { + return false; + } + } + + // Check if site content's words match any of our brand safety rules + const matchedRule = wordsMatchedWithRule(rule, decodedWord, words); + if (matchedRule !== false) { + score += scoreCalculator(points, matchedRule.occurrences); } } - return score < maxScore * words / 500; + return score < (maxScore * wordsMatched.length) / 1000; } catch (e) { return true; } } export const spec = { - code: 'adhash', - url: 'https://bidder.adhash.com/rtb?version=' + VERSION + '&prebid=true', - supportedMediaTypes: [ BANNER ], + code: ADHASH_BIDDER_CODE, + supportedMediaTypes: [ BANNER, VIDEO ], isBidRequestValid: (bid) => { try { - const { publisherId, platformURL } = bid.params; + const { publisherId, platformURL, bidderURL } = bid.params; return ( - includes(Object.keys(bid.mediaTypes), BANNER) && + (includes(Object.keys(bid.mediaTypes), BANNER) || includes(Object.keys(bid.mediaTypes), VIDEO)) && typeof publisherId === 'string' && publisherId.length === 42 && typeof platformURL === 'string' && - platformURL.length >= 13 + platformURL.length >= 13 && + (!bidderURL || bidderURL.indexOf('https://') === 0) ); } catch (error) { return false; @@ -98,23 +171,58 @@ export const spec = { }, buildRequests: (validBidRequests, bidderRequest) => { + const storage = getStorageManager({ bidderCode: ADHASH_BIDDER_CODE }); const { gdprConsent } = bidderRequest; - const { url } = spec; const bidRequests = []; - let referrer = ''; - if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; - } - for (var i = 0; i < validBidRequests.length; i++) { - var index = Math.floor(Math.random() * validBidRequests[i].sizes.length); - var size = validBidRequests[i].sizes[index].join('x'); + const body = document.body; + const html = document.documentElement; + const pageHeight = Math.max( + body.scrollHeight, + body.offsetHeight, + html.clientHeight, + html.scrollHeight, + html.offsetHeight + ); + const pageWidth = Math.max(body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth); + + for (let i = 0; i < validBidRequests.length; i++) { + const bidderURL = validBidRequests[i].params.bidderURL || 'https://bidder.adhash.com'; + const url = `${bidderURL}/rtb?version=${VERSION}&prebid=true`; + const index = Math.floor(Math.random() * validBidRequests[i].sizes.length); + const size = validBidRequests[i].sizes[index].join('x'); + const creativeData = includes(Object.keys(validBidRequests[i].mediaTypes), VIDEO) ? { + size: 'preroll', + position: validBidRequests[i].adUnitCode, + playerSize: size + } : { + size: size, + position: validBidRequests[i].adUnitCode + }; + let recentAds = []; + if (storage.localStorageIsEnabled()) { + const prefix = validBidRequests[i].params.prefix || 'adHash'; + recentAds = JSON.parse(storage.getDataFromLocalStorage(prefix + 'recentAds') || '[]'); + } + + // Needed for the ad density calculation + const adHeight = validBidRequests[i].sizes[index][1]; + const adWidth = validBidRequests[i].sizes[index][0]; + if (!window.adsCount) { + window.adsCount = 0; + } + if (!window.adsTotalSurface) { + window.adsTotalSurface = 0; + } + window.adsTotalSurface += adHeight * adWidth; + window.adsCount++; + bidRequests.push({ method: 'POST', url: url + '&publisher=' + validBidRequests[i].params.publisherId, bidRequest: validBidRequests[i], data: { timezone: new Date().getTimezoneOffset() / 60, - location: referrer, + location: bidderRequest.refererInfo ? bidderRequest.refererInfo.topmostLocation : '', publisherId: validBidRequests[i].params.publisherId, size: { screenWidth: window.screen.width, @@ -125,15 +233,16 @@ export const spec = { language: window.navigator.language, userAgent: window.navigator.userAgent }, - creatives: [{ - size: size, - position: validBidRequests[i].adUnitCode - }], + creatives: [creativeData], blockedCreatives: [], - currentTimestamp: new Date().getTime(), - recentAds: [], + currentTimestamp: (new Date().getTime() / 1000) | 0, + recentAds: recentAds, GDPRApplies: gdprConsent ? gdprConsent.gdprApplies : null, - GDPR: gdprConsent ? gdprConsent.consentString : null + GDPR: gdprConsent ? gdprConsent.consentString : null, + servedAdsCount: window.adsCount, + adsTotalSurface: window.adsTotalSurface, + pageHeight: pageHeight, + pageWidth: pageWidth }, options: { withCredentials: false, @@ -146,7 +255,6 @@ export const spec = { interpretResponse: (serverResponse, request) => { const responseBody = serverResponse ? serverResponse.body : {}; - if ( !responseBody.creatives || responseBody.creatives.length === 0 || @@ -156,17 +264,14 @@ export const spec = { } const publisherURL = JSON.stringify(request.bidRequest.params.platformURL); + const bidderURL = request.bidRequest.params.bidderURL || 'https://bidder.adhash.com'; const oneTimeId = request.bidRequest.adUnitCode + Math.random().toFixed(16).replace('0.', '.'); const bidderResponse = JSON.stringify({ responseText: JSON.stringify(responseBody) }); const requestData = JSON.stringify(request.data); - return [{ + let response = { requestId: request.bidRequest.bidId, cpm: responseBody.creatives[0].costEUR, - ad: - `
- - `, width: request.bidRequest.sizes[0][0], height: request.bidRequest.sizes[0][1], creativeId: request.bidRequest.adUnitCode, @@ -176,7 +281,21 @@ export const spec = { meta: { advertiserDomains: responseBody.advertiserDomains ? [responseBody.advertiserDomains] : [] } - }]; + }; + if (typeof request == 'object' && typeof request.bidRequest == 'object' && typeof request.bidRequest.mediaTypes == 'object' && includes(Object.keys(request.bidRequest.mediaTypes), BANNER)) { + response = Object.assign({ + ad: + `
+ + ` + }, response); + } else if (includes(Object.keys(request.bidRequest.mediaTypes), VIDEO)) { + response = Object.assign({ + vastUrl: responseBody.creatives[0].vastURL, + mediaType: VIDEO + }, response); + } + return [response]; } }; diff --git a/modules/adhashBidAdapter.md b/modules/adhashBidAdapter.md index 4ee6ed3dc83..acca5a1e651 100644 --- a/modules/adhashBidAdapter.md +++ b/modules/adhashBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: AdHash Bidder Adapter Module Type: Bidder Adapter -Maintainer: damyan@adhash.org +Maintainer: damyan@adhash.com ``` # Description @@ -14,8 +14,6 @@ Here is what you need for Prebid integration with AdHash: 3. Use the Publisher ID and Platform URL as parameters in params. Please note that a number of AdHash functionalities are not supported in the Prebid.js integration: -* Cookie-less frequency and recency capping; -* Audience segments; * Price floors and passback tags, as they are not needed in the Prebid.js setup; * Reservation for direct deals only, as bids are evaluated based on their price. diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js index 145b5605bc2..2d1426a2cda 100644 --- a/modules/adheseBidAdapter.js +++ b/modules/adheseBidAdapter.js @@ -26,7 +26,8 @@ export const spec = { const adheseConfig = config.getConfig('adhese'); const gdprParams = (gdprConsent && gdprConsent.consentString) ? { xt: [gdprConsent.consentString] } : {}; - const refererParams = (refererInfo && refererInfo.referer) ? { xf: [base64urlEncode(refererInfo.referer)] } : {}; + // TODO: is 'page' the right value here? + const refererParams = (refererInfo && refererInfo.page) ? { xf: [base64urlEncode(refererInfo.page)] } : {}; const globalCustomParams = (adheseConfig && adheseConfig.globalTargets) ? cleanTargets(adheseConfig.globalTargets) : {}; const commonParams = { ...globalCustomParams, ...gdprParams, ...refererParams }; const vastContentAsUrl = !(adheseConfig && adheseConfig.vastContentAsUrl == false); diff --git a/modules/adkernelAdnAnalyticsAdapter.js b/modules/adkernelAdnAnalyticsAdapter.js index de5d59ca6f8..48897f8516b 100644 --- a/modules/adkernelAdnAnalyticsAdapter.js +++ b/modules/adkernelAdnAnalyticsAdapter.js @@ -1,16 +1,18 @@ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import { logError, parseUrl, _each } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; import {getStorageManager} from '../src/storageManager.js'; import {config} from '../src/config.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; +const MODULE_CODE = 'adkernelAdn'; const GVLID = 14; const ANALYTICS_VERSION = '1.0.2'; const DEFAULT_QUEUE_TIMEOUT = 4000; const DEFAULT_HOST = 'tag.adkernel.com'; -const storageObj = getStorageManager({gvlid: GVLID}); +const storageObj = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); const ADK_HB_EVENTS = { AUCTION_INIT: 'auctionInit', @@ -104,7 +106,7 @@ analyticsAdapter.enableAnalytics = (config) => { adapterManager.registerAnalyticsAdapter({ adapter: analyticsAdapter, - code: 'adkernelAdn', + code: MODULE_CODE, gvlid: GVLID }); @@ -381,6 +383,7 @@ export function ExpiringQueue(callback, ttl) { } } +// TODO: this should reuse logic from refererDetection function getNavigationInfo() { try { return getLocationAndReferrer(self.top); diff --git a/modules/adkernelAdnBidAdapter.js b/modules/adkernelAdnBidAdapter.js index 39f7b9fd2b2..81067a3efcf 100644 --- a/modules/adkernelAdnBidAdapter.js +++ b/modules/adkernelAdnBidAdapter.js @@ -1,4 +1,4 @@ -import { deepAccess, parseSizesInput, isArray, deepSetValue, parseUrl, isStr, isNumber, logInfo } from '../src/utils.js'; +import {deepAccess, deepSetValue, isArray, isNumber, isStr, logInfo, parseSizesInput} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; @@ -10,7 +10,7 @@ const DEFAULT_APIS = [1, 2]; const GVLID = 14; function isRtbDebugEnabled(refInfo) { - return refInfo.referer.indexOf('adk_debug=true') !== -1; + return refInfo.topmostLocation?.indexOf('adk_debug=true') !== -1; } function buildImp(bidRequest) { @@ -58,10 +58,11 @@ function canonicalizeSizesArray(sizes) { } function buildRequestParams(tags, bidderRequest) { - let {auctionId, gdprConsent, uspConsent, transactionId, refererInfo} = bidderRequest; + let {gdprConsent, uspConsent, refererInfo, ortb2} = bidderRequest; let req = { - id: auctionId, - tid: transactionId, + id: bidderRequest.bidderRequestId, + // TODO: root-level `tid` is not ORTB; is this intentional? + tid: ortb2?.source?.tid, site: buildSite(refererInfo), imp: tags }; @@ -83,13 +84,10 @@ function buildRequestParams(tags, bidderRequest) { } function buildSite(refInfo) { - let loc = parseUrl(refInfo.referer); - let result = { - page: `${loc.protocol}://${loc.hostname}${loc.pathname}`, - secure: ~~(loc.protocol === 'https') - }; - if (self === top && document.referrer) { - result.ref = document.referrer; + const result = { + page: refInfo.page, + secure: ~~(refInfo.page && refInfo.page.startsWith('https')), + ref: refInfo.ref } let keywords = document.getElementsByTagName('meta')['keywords']; if (keywords && keywords.content) { @@ -101,7 +99,6 @@ function buildSite(refInfo) { function buildBid(tag) { let bid = { requestId: tag.impid, - bidderCode: spec.code, cpm: tag.bid, creativeId: tag.crid, currency: 'USD', @@ -162,7 +159,7 @@ export const spec = { code: 'adkernelAdn', gvlid: GVLID, supportedMediaTypes: [BANNER, VIDEO], - aliases: ['engagesimply'], + aliases: ['engagesimply', 'adpluto_dsp'], isBidRequestValid: function(bidRequest) { return 'params' in bidRequest && diff --git a/modules/adkernelBidAdapter.js b/modules/adkernelBidAdapter.js index c2d6ca4d4dd..9d9da8cb0ab 100644 --- a/modules/adkernelBidAdapter.js +++ b/modules/adkernelBidAdapter.js @@ -5,9 +5,8 @@ import { createTrackPixelHtml, deepAccess, deepSetValue, - getAdUnitSizes, + getDefinedParams, getDNT, - inIframe, isArray, isArrayOfNums, isEmpty, @@ -15,13 +14,14 @@ import { isPlainObject, isStr, mergeDeep, - parseGPTSingleSizeArrayToRtbSize, - parseUrl + parseGPTSingleSizeArrayToRtbSize } from '../src/utils.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {find, includes} from '../src/polyfill.js'; +import {find} from '../src/polyfill.js'; import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; /* * In case you're AdKernel whitelable platform's client who needs branded adapter to @@ -29,17 +29,19 @@ import {config} from '../src/config.js'; * * Please contact prebid@adkernel.com and we'll add your adapter as an alias. */ - -const VIDEO_TARGETING = Object.freeze(['mimes', 'minduration', 'maxduration', 'protocols', - 'startdelay', 'linearity', 'boxingallowed', 'playbackmethod', 'delivery', - 'pos', 'api', 'ext']); +const VIDEO_PARAMS = ['pos', 'context', 'placement', 'plcmt', 'api', 'mimes', 'protocols', 'playbackmethod', 'minduration', 'maxduration', + 'startdelay', 'linearity', 'skip', 'skipmin', 'skipafter', 'minbitrate', 'maxbitrate', 'delivery', 'playbackend', 'boxingallowed']; +const VIDEO_FPD = ['battr', 'pos']; +const NATIVE_FPD = ['battr', 'api']; +const BANNER_PARAMS = ['pos']; +const BANNER_FPD = ['btype', 'battr', 'pos', 'api']; const VERSION = '1.6'; const SYNC_IFRAME = 1; const SYNC_IMAGE = 2; -const SYNC_TYPES = Object.freeze({ +const SYNC_TYPES = { 1: 'iframe', 2: 'image' -}); +}; const GVLID = 14; const NATIVE_MODEL = [ @@ -78,7 +80,6 @@ export const spec = { {code: 'audiencemedia'}, {code: 'waardex_ak'}, {code: 'roqoon'}, - {code: 'andbeyond'}, {code: 'adbite'}, {code: 'houseofpubs'}, {code: 'torchad'}, @@ -90,11 +91,18 @@ export const spec = { {code: 'denakop'}, {code: 'rtbanalytica'}, {code: 'unibots'}, - {code: 'catapultx'}, {code: 'ergadx'}, {code: 'turktelekom'}, {code: 'felixads'}, - {code: 'motionspots'} + {code: 'motionspots'}, + {code: 'sonic_twist'}, + {code: 'displayioads'}, + {code: 'rtbdemand_com'}, + {code: 'bidbuddy'}, + {code: 'didnadisplay'}, + {code: 'qortex'}, + {code: 'adpluto'}, + {code: 'headbidder'} ], supportedMediaTypes: [BANNER, VIDEO, NATIVE], @@ -120,6 +128,9 @@ export const spec = { * @returns {ServerRequest[]} */ buildRequests: function (bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + let impGroups = groupImpressionsByHostZone(bidRequests, bidderRequest.refererInfo); let requests = []; let schain = bidRequests[0].schain; @@ -226,7 +237,7 @@ registerBidder(spec); * @param refererInfo {refererInfo} */ function groupImpressionsByHostZone(bidRequests, refererInfo) { - let secure = (refererInfo && refererInfo.referer.indexOf('https:') === 0); + let secure = (refererInfo && refererInfo.page?.indexOf('https:') === 0); return Object.values( bidRequests.map(bidRequest => buildImp(bidRequest, secure)) .reduce((acc, curr, index) => { @@ -265,29 +276,34 @@ function buildImp(bidRequest, secure) { var mediaType; var sizes = []; - if (deepAccess(bidRequest, 'mediaTypes.banner')) { + if (bidRequest.mediaTypes?.banner) { sizes = getAdUnitSizes(bidRequest); + let pbBanner = bidRequest.mediaTypes.banner; imp.banner = { + ...getDefinedParamsOrEmpty(bidRequest.ortb2Imp, BANNER_FPD), + ...getDefinedParamsOrEmpty(pbBanner, BANNER_PARAMS), format: sizes.map(wh => parseGPTSingleSizeArrayToRtbSize(wh)), topframe: 0 }; mediaType = BANNER; - } else if (deepAccess(bidRequest, 'mediaTypes.video')) { - let video = deepAccess(bidRequest, 'mediaTypes.video'); - imp.video = {}; - if (video.playerSize) { - sizes = video.playerSize[0]; + } else if (bidRequest.mediaTypes?.video) { + let pbVideo = bidRequest.mediaTypes.video; + imp.video = { + ...getDefinedParamsOrEmpty(bidRequest.ortb2Imp, VIDEO_FPD), + ...getDefinedParamsOrEmpty(pbVideo, VIDEO_PARAMS) + }; + if (pbVideo.playerSize) { + sizes = pbVideo.playerSize[0]; imp.video = Object.assign(imp.video, parseGPTSingleSizeArrayToRtbSize(sizes) || {}); - } - if (bidRequest.params.video) { - Object.keys(bidRequest.params.video) - .filter(key => includes(VIDEO_TARGETING, key)) - .forEach(key => imp.video[key] = bidRequest.params.video[key]); + } else if (pbVideo.w && pbVideo.h) { + imp.video.w = pbVideo.w; + imp.video.h = pbVideo.h; } mediaType = VIDEO; - } else if (deepAccess(bidRequest, 'mediaTypes.native')) { + } else if (bidRequest.mediaTypes?.native) { let nativeRequest = buildNativeRequest(bidRequest.mediaTypes.native); imp.native = { + ...getDefinedParamsOrEmpty(bidRequest.ortb2Imp, NATIVE_FPD), ver: '1.1', request: JSON.stringify(nativeRequest) }; @@ -305,6 +321,13 @@ function buildImp(bidRequest, secure) { return imp; } +function getDefinedParamsOrEmpty(object, params) { + if (object === undefined) { + return {}; + } + return getDefinedParams(object, params); +} + /** * Builds native request from native adunit */ @@ -433,7 +456,9 @@ function makeUser(bidderRequest, fpd) { if (eids) { deepSetValue(user, 'ext.eids', eids); } - if (!isEmpty(user)) { return {user: user}; } + if (!isEmpty(user)) { + return {user: user}; + } } /** @@ -442,13 +467,17 @@ function makeUser(bidderRequest, fpd) { * @returns {{regs: Object} | undefined} */ function makeRegulations(bidderRequest) { - let {gdprConsent, uspConsent} = bidderRequest; + let {gdprConsent, uspConsent, gppConsent} = bidderRequest; let regs = {}; if (gdprConsent) { if (gdprConsent.gdprApplies !== undefined) { deepSetValue(regs, 'regs.ext.gdpr', ~~gdprConsent.gdprApplies); } } + if (gppConsent) { + deepSetValue(regs, 'regs.gpp', gppConsent.gppString); + deepSetValue(regs, 'regs.gpp_sid', gppConsent.applicableSections); + } if (uspConsent) { deepSetValue(regs, 'regs.ext.us_privacy', uspConsent); } @@ -468,9 +497,9 @@ function makeRegulations(bidderRequest) { * @returns */ function makeBaseRequest(bidderRequest, imps, fpd) { - let {auctionId, timeout} = bidderRequest; + let {timeout} = bidderRequest; let request = { - 'id': auctionId, + 'id': bidderRequest.bidderRequestId, 'imp': imps, 'at': 1, 'tmax': parseInt(timeout) @@ -506,7 +535,7 @@ function makeSyncInfo(bidderRequest) { * @return {Object} Complete rtb request */ function buildRtbRequest(imps, bidderRequest, schain) { - let fpd = config.getConfig('ortb2') || {}; + let fpd = bidderRequest.ortb2 || {}; let req = mergeDeep( makeBaseRequest(bidderRequest, imps, fpd), @@ -535,14 +564,13 @@ function getLanguage() { * Creates site description object */ function createSite(refInfo, fpd) { - let url = parseUrl(refInfo.referer); let site = { - 'domain': url.hostname, - 'page': `${url.protocol}://${url.hostname}${url.pathname}` + 'domain': refInfo.domain, + 'page': refInfo.page }; mergeDeep(site, fpd.site); - if (!inIframe() && document.referrer) { - site.ref = document.referrer; + if (refInfo.ref != null) { + site.ref = refInfo.ref; } else { delete site.ref; } diff --git a/modules/adliveBidAdapter.md b/modules/adliveBidAdapter.md deleted file mode 100644 index 4fc6a112e82..00000000000 --- a/modules/adliveBidAdapter.md +++ /dev/null @@ -1,28 +0,0 @@ -# Overview -``` -Module Name: Adlive Bid Adapter -Module Type: Bidder Adapter -Maintainer: traffic@adlive.io -``` - -# Description -Module that connects to Adlive's server for bids. -Currently module supports only banner mediaType. - -# Test Parameters -``` - var adUnits = [{ - code: '/test/div', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bids: [{ - bidder: 'adlive', - params: { - hashes: ['1e100887dd614b0909bf6c49ba7f69fdd1360437'] - } - }] - }]; -``` \ No newline at end of file diff --git a/modules/adlooxAnalyticsAdapter.js b/modules/adlooxAnalyticsAdapter.js index 1091b87a22d..9284d543298 100644 --- a/modules/adlooxAnalyticsAdapter.js +++ b/modules/adlooxAnalyticsAdapter.js @@ -5,7 +5,7 @@ */ import adapterManager from '../src/adapterManager.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import {loadExternalScript} from '../src/adloader.js'; import {auctionManager} from '../src/auctionManager.js'; import {AUCTION_COMPLETED} from '../src/auction.js'; @@ -14,7 +14,6 @@ import {find} from '../src/polyfill.js'; import {getRefererInfo} from '../src/refererDetection.js'; import { deepAccess, - getGptSlotInfoForAdUnitCode, getUniqueIdentifierStr, insertElement, isFn, @@ -28,6 +27,7 @@ import { mergeDeep, parseUrl } from '../src/utils.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const MODULE = 'adlooxAnalyticsAdapter'; @@ -61,17 +61,17 @@ MACRO['creatype'] = function(b, c) { }; MACRO['pageurl'] = function(b, c) { const refererInfo = getRefererInfo(); - return (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0]; + return (refererInfo.page || '').substr(0, 300).split(/[?#]/)[0]; }; -MACRO['pbadslot'] = function(b, c) { +MACRO['gpid'] = function(b, c) { const adUnit = find(auctionManager.getAdUnits(), a => b.adUnitCode === a.code); - return deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot') || getGptSlotInfoForAdUnitCode(b.adUnitCode).gptSlot || b.adUnitCode; + return deepAccess(adUnit, 'ortb2Imp.ext.gpid') || deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot') || getGptSlotInfoForAdUnitCode(b.adUnitCode).gptSlot || b.adUnitCode; }; -MACRO['pbAdSlot'] = MACRO['pbadslot']; // legacy +MACRO['pbAdSlot'] = MACRO['pbadslot'] = MACRO['gpid']; // legacy const PARAMS_DEFAULT = { 'id1': function(b) { return b.adUnitCode }, - 'id2': '%%pbadslot%%', + 'id2': '%%gpid%%', 'id3': function(b) { return b.bidder }, 'id4': function(b) { return b.adId }, 'id5': function(b) { return b.dealId }, @@ -138,7 +138,11 @@ analyticsAdapter.enableAnalytics = function(config) { toselector: config.options.toselector || function(bid) { let code = getGptSlotInfoForAdUnitCode(bid.adUnitCode).divId || bid.adUnitCode; // https://mathiasbynens.be/notes/css-escapes - code = code.replace(/^\d/, '\\3$& '); + try { + code = CSS.escape(code); + } catch (_) { + code = code.replace(/^\d/, '\\3$& '); + } return `#${code}` }, client: config.options.client, diff --git a/modules/adlooxAnalyticsAdapter.md b/modules/adlooxAnalyticsAdapter.md index e21261d0b8d..d77ee25ab5f 100644 --- a/modules/adlooxAnalyticsAdapter.md +++ b/modules/adlooxAnalyticsAdapter.md @@ -34,19 +34,21 @@ When tracking video you have two options: To view an [example of an Adloox integration](../integrationExamples/gpt/adloox.html): - gulp serve --nolint --notest --modules=gptPreAuction,categoryTranslation,dfpAdServerVideo,rtdModule,instreamTracking,rubiconBidAdapter,spotxBidAdapter,adlooxAnalyticsAdapter,adlooxAdServerVideo,adlooxRtdProvider + gulp serve --nolint --notest --modules=gptPreAuction,categoryTranslation,dfpAdServerVideo,intersectionRtdProvider,rtdModule,instreamTracking,rubiconBidAdapter,spotxBidAdapter,adlooxAnalyticsAdapter,adlooxAdServerVideo,adlooxRtdProvider **N.B.** `categoryTranslation` is required by `dfpAdServerVideo` that otherwise causes a JavaScript console warning +**N.B.** `intersectionRtdProvider` is used by `adlooxRtdProvider` to provide (above-the-fold) ATF measurement, if not enabled the `atf` segment will not be available + Now point your browser at: http://localhost:9999/integrationExamples/gpt/adloox.html?pbjs_debug=true ### Public Example -The example is published publically at: https://storage.googleapis.com/adloox-ads-js-test/prebid.html?pbjs_debug=true +The example is published publicly at: https://storage.googleapis.com/adloox-ads-js-test/prebid.html?pbjs_debug=true **N.B.** this will show a [CORS error](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors) for the request `https://p.adlooxtracking.com/q?...` that is safe to ignore on the public example page; it is related to the [RTD integration](./adlooxRtdProvider.md) which requires pre-registration of your sites -It is recommended you use [Google Chrome's 'Local Overrides' located in the Developer Tools panel](https://www.trysmudford.com/blog/chrome-local-overrides/) to explore the example without the inconvience of having to run your own web server. +It is recommended you use [Google Chrome's 'Local Overrides' located in the Developer Tools panel](https://www.trysmudford.com/blog/chrome-local-overrides/) to explore the example without the inconvenience of having to run your own web server. #### Pre-built `prebid.js` @@ -106,7 +108,7 @@ For example, you have a number of reporting breakdown slots available in the for tagid: 0, params: { id1: function(b) { return b.adUnitCode }, // do not change when using the Adloox RTD Provider - id2: '%%pbadslot%%', // do not change when using the Adloox RTD Provider + id2: '%%gpid%%', // do not change when using the Adloox RTD Provider id3: function(b) { return b.bidder }, id4: function(b) { return b.adId }, id5: function(b) { return b.dealId }, @@ -125,9 +127,9 @@ For example, you have a number of reporting breakdown slots available in the for The following macros are available - * `%%pbadslot%%`: [Prebid Ad Slot](https://docs.prebid.org/features/pbAdSlot.html) returns [`AdUnit.code`](https://docs.prebid.org/features/pbAdSlot.html) if set otherwise returns [`AdUnit.code`](https://docs.prebid.org/dev-docs/adunit-reference.html#adunit) + * **`%%gpid%%` (alias `%%pbadslot%%`**): [Prebid Ad Slot](https://docs.prebid.org/features/pbAdSlot.html) returns [`AdUnit.code`](https://docs.prebid.org/features/pbAdSlot.html) if set otherwise returns [`AdUnit.code`](https://docs.prebid.org/dev-docs/adunit-reference.html#adunit) * it is recommended you read the [Prebid Ad Slot section in the Adloox RTD Provider documentation](./adlooxRtdProvider.md#prebid-ad-slot) - * `%%pageurl%%`: [`canonicalUrl`](https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html#setConfig-Page-URL) from the [`refererInfo` object](https://docs.prebid.org/dev-docs/bidder-adaptor.html#referrers) otherwise uses `referer` + * **`%%pageurl%%`**: [`canonicalUrl`](https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html#setConfig-Page-URL) from the [`refererInfo` object](https://docs.prebid.org/dev-docs/bidder-adaptor.html#referrers) otherwise uses `referer` ### Functions diff --git a/modules/adlooxRtdProvider.js b/modules/adlooxRtdProvider.js index bb8334ec8fe..727dc84e399 100644 --- a/modules/adlooxRtdProvider.js +++ b/modules/adlooxRtdProvider.js @@ -6,155 +6,45 @@ * @module modules/adlooxRtdProvider * @requires module:modules/realTimeData * @requires module:modules/adlooxAnalyticsAdapter + * @optional module:modules/intersectionRtdProvider */ /* eslint standard/no-callback-literal: "off" */ /* eslint prebid/validate-imports: "off" */ +import {auctionManager} from '../src/auctionManager.js'; import {command as analyticsCommand, COMMAND} from './adlooxAnalyticsAdapter.js'; -import {config as _config} from '../src/config.js'; import {submodule} from '../src/hook.js'; import {ajax} from '../src/ajax.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {getRefererInfo} from '../src/refererDetection.js'; import { _each, + _map, + buildUrl, deepAccess, + deepClone, deepSetValue, - getAdUnitSizes, - getGptSlotInfoForAdUnitCode, isArray, isBoolean, isInteger, isPlainObject, - isStr, logError, logInfo, logWarn, - mergeDeep + mergeDeep, + parseUrl, + safeJSONParse } from '../src/utils.js'; -import {includes} from '../src/polyfill.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const MODULE_NAME = 'adloox'; const MODULE = `${MODULE_NAME}RtdProvider`; const API_ORIGIN = 'https://p.adlooxtracking.com'; const SEGMENT_HISTORIC = { 'a': 'aud', 'd': 'dis', 'v': 'vid' }; -const SEGMENT_HISTORIC_VALUES = Object.keys(SEGMENT_HISTORIC).map(k => SEGMENT_HISTORIC[k]); -const ADSERVER_TARGETING_PREFIX = 'adl_'; - -const CREATIVE_WIDTH_MIN = 20; -const CREATIVE_HEIGHT_MIN = 20; -const CREATIVE_AREA_MIN = CREATIVE_WIDTH_MIN * CREATIVE_HEIGHT_MIN; -// try to avoid using IntersectionObserver as it has unbounded (observed multi-second) latency -let intersectionObserver = window == top ? false : undefined; -const intersectionObserverElements = []; -// .map/.findIndex are safe here as they are only used for intersectionObserver -function atf(adUnit, cb) { - analyticsCommand(COMMAND.TOSELECTOR, { bid: { adUnitCode: adUnit.code } }, function(selector) { - const element = document.querySelector(selector); - if (!element) return cb(null); - - if (window.getComputedStyle(element)['display'] == 'none') return cb(NaN); - - try { - // short circuit for cross-origin - if (intersectionObserver) throw false; - - // Google's advice is to collapse slots on no fill but - // we have to cater to clients that grow slots on fill - const rect = (function(rect) { - const sizes = getAdUnitSizes(adUnit); - - if (sizes.length == 0) return false; - // interstitial (0x0, 1x1) - if (sizes.length == 1 && (sizes[0][0] * sizes[0][1]) <= 1) return true; - // try to catch premium slots (coord=0,0) as they will likely bounce into view - if (rect.top <= -window.pageYOffset && rect.left <= -window.pageXOffset && rect.top == rect.bottom) return true; - - // pick the smallest creative size as many publishers will just leave the element unbounded in the vertical - let width = Infinity; - let height = Infinity; - for (let i = 0; i < sizes.length; i++) { - const area = sizes[i][0] * sizes[i][1]; - if (area < CREATIVE_AREA_MIN) continue; - if (area < (width * height)) { - width = sizes[i][0]; - height = sizes[i][1]; - } - } - // we also scale the smallest size to the size of the slot as publishers resize units depending on viewport - const scale = Math.min(1, (rect.right - rect.left) / width); - - return { - left: rect.left, - right: rect.left + Math.max(CREATIVE_WIDTH_MIN, scale * width), - top: rect.top, - bottom: rect.top + Math.max(CREATIVE_HEIGHT_MIN, scale * height) - }; - })(element.getBoundingClientRect()); - - if (rect === false) return cb(NaN); - if (rect === true) return cb(1); - - const W = rect.right - rect.left; - const H = rect.bottom - rect.top; - - if (W * H < CREATIVE_AREA_MIN) return cb(NaN); - - let el; - let win = window; - while (1) { - // https://stackoverflow.com/a/8876069 - const vw = Math.max(win.document.documentElement.clientWidth || 0, win.innerWidth || 0); - const vh = Math.max(win.document.documentElement.clientHeight || 0, win.innerHeight || 0); - - // cut to viewport - rect.left = Math.min(Math.max(rect.left, 0), vw); - rect.right = Math.min(Math.max(rect.right, 0), vw); - rect.top = Math.min(Math.max(rect.top, 0), vh); - rect.bottom = Math.min(Math.max(rect.bottom, 0), vh); - - if (win == top) return cb(((rect.right - rect.left) * (rect.bottom - rect.top)) / (W * H)); - el = win.frameElement; - if (!el) throw false; // cross-origin - win = win.parent; - - // transpose to frame element - const frameElementRect = el.getBoundingClientRect(); - rect.left += frameElementRect.left; - rect.right = Math.min(rect.right + frameElementRect.left, frameElementRect.right); - rect.top += frameElementRect.top; - rect.bottom = Math.min(rect.bottom + frameElementRect.top, frameElementRect.bottom); - } - } catch (_) { - if (intersectionObserver === undefined) { - try { - intersectionObserver = new IntersectionObserver(function(entries) { - entries.forEach(entry => { - const ratio = entry.intersectionRect.width * entry.intersectionRect.height < CREATIVE_AREA_MIN ? NaN : entry.intersectionRatio; - const idx = intersectionObserverElements.findIndex(x => x.element == entry.target); - intersectionObserverElements[idx].cb.forEach(cb => cb(ratio)); - intersectionObserverElements.splice(idx, 1); - intersectionObserver.unobserve(entry.target); - }); - }); - } catch (_) { - intersectionObserver = false; - } - } - if (!intersectionObserver) return cb(null); - const idx = intersectionObserverElements.findIndex(x => x.element == element); - if (idx == -1) { - intersectionObserverElements.push({ element, cb: [ cb ] }); - intersectionObserver.observe(element); - } else { - intersectionObserverElements[idx].cb.push(cb); - } - } - }); -} +const ADSERVER_TARGETING_PREFIX = 'adl'; function init(config, userConsent) { logInfo(MODULE, 'init', config, userConsent); @@ -168,10 +58,6 @@ function init(config, userConsent) { logError(MODULE, 'invalid params'); return false; } - if (!(config.params.api_origin === undefined || isStr(config.params.api_origin))) { - logError(MODULE, 'invalid api_origin params value'); - return false; - } if (!(config.params.imps === undefined || (isInteger(config.params.imps) && config.params.imps > 0))) { logError(MODULE, 'invalid imps params value'); return false; @@ -214,194 +100,110 @@ function init(config, userConsent) { } function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) { - // gptPreAuction runs *after* RTD so pbadslot may not be populated... (╯°□°)╯ ┻━┻ - const adUnits = (reqBidsConfigObj.adUnits || getGlobal().adUnits).map(adUnit => { - let path = deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot'); - if (!path) path = getGptSlotInfoForAdUnitCode(adUnit.code).gptSlot; - return { - path: path, - unit: adUnit - }; - }).filter(adUnit => !!adUnit.path); - - let response = {}; - function setSegments() { - function val(v, k) { - if (!((SEGMENT_HISTORIC[k] || k == 'atf') && v >= 0)) return v; - return config.params.thresholds.filter(t => t <= v); - } - - const ortb2 = _config.getConfig('ortb2') || {}; - const dataSite = _config.getConfig('ortb2.site.ext.data') || {}; - const dataUser = _config.getConfig('ortb2.user.ext.data') || {}; - - _each(response, (v0, k0) => { - if (k0 == '_') return; - const k = SEGMENT_HISTORIC[k0] || k0; - const v = val(v0, k0); - deepSetValue(k == k0 ? dataUser : dataSite, `${MODULE_NAME}_rtd.${k}`, v); - }); - deepSetValue(dataSite, `${MODULE_NAME}_rtd.ok`, true); + const adUnits0 = reqBidsConfigObj.adUnits || getGlobal().adUnits; + // adUnits must be ordered according to adUnitCodes for stable 's' param usage and handling the response below + const adUnits = reqBidsConfigObj.adUnitCodes.map(code => adUnits0.find(unit => unit.code == code)); + + // buildUrl creates PHP style multi-parameters and includes undefined... (╯°□°)╯ ┻━┻ + const url = buildUrl(mergeDeep(parseUrl(`${API_ORIGIN}/q`), { search: { + 'v': `pbjs-${getGlobal().version}`, + 'c': config.params.clientid, + 'p': config.params.platformid, + 't': config.params.tagid, + 'imp': config.params.imps, + 'fc_ip': config.params.freqcap_ip, + 'fc_ipua': config.params.freqcap_ipua, + 'pn': (getRefererInfo().page || '').substr(0, 300).split(/[?#]/)[0], + 's': _map(adUnits, function(unit) { + // gptPreAuction runs *after* RTD so pbadslot may not be populated... (╯°□°)╯ ┻━┻ + const gpid = deepAccess(unit, 'ortb2Imp.ext.gpid') || + deepAccess(unit, 'ortb2Imp.ext.data.pbadslot') || + getGptSlotInfoForAdUnitCode(unit.code).gptSlot || + unit.code; + const ref = [ gpid ]; + if (!config.params.slotinpath) ref.push(unit.code); + return ref.join('\t'); + }) + } })).replace(/\[\]|[^?&]+=undefined/g, '').replace(/([?&])&+/g, '$1'); + + ajax(url, + function(responseText, q) { + function val(v, k) { + if (!(SEGMENT_HISTORIC[k] && v >= 0)) return v; + return config.params.thresholds.filter(t => t <= v); + } - deepSetValue(ortb2, 'site.ext.data', dataSite); - deepSetValue(ortb2, 'user.ext.data', dataUser); - _config.setConfig({ ortb2 }); + const response = safeJSONParse(responseText); + if (!response) { + logError(MODULE, 'unexpected response'); + return callback(); + } - adUnits.forEach((adUnit, i) => { - _each(response['_'][i], (v0, k0) => { + const { site: ortb2site, user: ortb2user } = reqBidsConfigObj.ortb2Fragments.global; + _each(response, function(v0, k0) { + if (k0 == '_') return; const k = SEGMENT_HISTORIC[k0] || k0; const v = val(v0, k0); - deepSetValue(adUnit.unit, `ortb2Imp.ext.data.${MODULE_NAME}_rtd.${k}`, v); + deepSetValue(k == k0 ? ortb2user : ortb2site, `ext.data.${MODULE_NAME}_rtd.${k}`, v); }); - }); - }; - - // mergeDeep does not handle merging deep arrays... (╯°□°)╯ ┻━┻ - function mergeDeep(target, ...sources) { - function emptyValue(v) { - if (isPlainObject(v)) { - return {}; - } else if (isArray(v)) { - return []; - } else { - return undefined; - } - } - if (!sources.length) return target; - const source = sources.shift(); - - if (isPlainObject(target) && isPlainObject(source)) { - Object.keys(source).forEach(key => { - if (!(key in target)) target[key] = emptyValue(source[key]); - target[key] = target[key] !== undefined ? mergeDeep(target[key], source[key]) : source[key]; - }); - } else if (isArray(target) && isArray(source)) { - source.forEach((v, i) => { - if (!(i in target)) target[i] = emptyValue(v); - target[i] = target[i] !== undefined ? mergeDeep(target[i], v) : v; + _each(response._, function(segments, i) { + _each(segments, function(v0, k0) { + const k = SEGMENT_HISTORIC[k0] || k0; + const v = val(v0, k0); + deepSetValue(adUnits[i], `ortb2Imp.ext.data.${MODULE_NAME}_rtd.${k}`, v); + }); }); - } else { - target = source; - } - return mergeDeep(target, ...sources); - } + deepSetValue(ortb2site, `ext.data.${MODULE_NAME}_rtd.ok`, true); - let semaphore = 1; - function semaphoreInc(inc) { - if (semaphore == 0) return; - semaphore += inc; - if (semaphore == 0) { - setSegments() callback(); } - } - - const refererInfo = getRefererInfo(); - const args = [ - [ 'v', `pbjs-${getGlobal().version}` ], - [ 'c', config.params.clientid ], - [ 'p', config.params.platformid ], - [ 't', config.params.tagid ], - [ 'imp', config.params.imps ], - [ 'fc_ip', config.params.freqcap_ip ], - [ 'fc_ipua', config.params.freqcap_ipua ], - [ 'pn', (refererInfo.canonicalUrl || refererInfo.referer || '').substr(0, 300).split(/[?#]/)[0] ] - ]; - - if (!adUnits.length) { - logWarn(MODULE, 'no suitable adUnits (missing pbadslot?)'); - } - const atfQueue = []; - adUnits.map((adUnit, i) => { - const ref = [ adUnit.path ]; - if (!config.params.slotinpath) ref.push(adUnit.unit.code); - args.push(['s', ref.join('\t')]); - - semaphoreInc(1); - atfQueue.push(function() { - atf(adUnit.unit, function(x) { - let viewable = document.visibilityState === undefined || document.visibilityState == 'visible'; - try { viewable = viewable && top.document.hasFocus() } catch (_) {} - logInfo(MODULE, `atf code=${adUnit.unit.code} has area=${x}, viewable=${viewable}`); - const atfList = []; atfList[i] = { atf: parseInt(x * 100) }; - response = mergeDeep(response, { _: atfList }); - semaphoreInc(-1); - }); - }); - }); - function atfCb() { - atfQueue.forEach(x => x()); - } - if (document.readyState == 'loading') { - document.addEventListener('DOMContentLoaded', atfCb, false); - } else { - atfCb(); - } - - analyticsCommand(COMMAND.URL, { - url: (config.params.api_origin || API_ORIGIN) + '/q?', - args: args - }, function(url) { - ajax(url, { - success: function(responseText, q) { - try { - if (q.getResponseHeader('content-type') == 'application/json') { - response = mergeDeep(response, JSON.parse(responseText)); - } else { - throw false; - } - } catch (_) { - logError(MODULE, 'unexpected response'); - } - semaphoreInc(-1); - }, - error: function(statusText, q) { - logError(MODULE, 'request failed'); - semaphoreInc(-1); - } - }); - }); + ); } -function getTargetingData(adUnitArray, config, userConsent) { - function targetingNormalise(v) { +function getTargetingData(adUnitArray, config, userConsent, auction) { + function val(v) { if (isArray(v) && v.length == 0) return undefined; if (isBoolean(v)) v = ~~v; if (!v) return undefined; // empty string and zero return v; } - const dataSite = _config.getConfig(`ortb2.site.ext.data.${MODULE_NAME}_rtd`) || {}; - if (!dataSite.ok) return {}; + const { site: ortb2site, user: ortb2user } = auctionManager.index.getAuction(auction).getFPD().global; - const dataUser = _config.getConfig(`ortb2.user.ext.data.${MODULE_NAME}_rtd`) || {}; - return getGlobal().adUnits.filter(adUnit => includes(adUnitArray, adUnit.code)).reduce((a, adUnit) => { - a[adUnit.code] = {}; + const ortb2base = {}; + _each(deepAccess(mergeDeep(ortb2site, ortb2user), `ext.data.${MODULE_NAME}_rtd`), function(v0, k) { + const v = val(v0); + if (v) ortb2base[`${ADSERVER_TARGETING_PREFIX}_${k}`] = v; + }); - _each(dataSite, (v0, k) => { - if (includes(SEGMENT_HISTORIC_VALUES, k)) return; // ignore site average viewability - const v = targetingNormalise(v0); - if (v) a[adUnit.code][ADSERVER_TARGETING_PREFIX + k] = v; - }); + const targeting = {}; + _each(auction.adUnits.filter(unit => adUnitArray.includes(unit.code)), function(unit) { + targeting[unit.code] = deepClone(ortb2base); - const adUnitSegments = deepAccess(adUnit, `ortb2Imp.ext.data.${MODULE_NAME}_rtd`, {}); - _each(Object.assign({}, dataUser, adUnitSegments), (v0, k) => { - const v = targetingNormalise(v0); - if (v) a[adUnit.code][ADSERVER_TARGETING_PREFIX + k] = v; + const ortb2imp = deepAccess(unit, `ortb2Imp.ext.data.${MODULE_NAME}_rtd`); + _each(ortb2imp, function(v0, k) { + const v = val(v0); + if (v) targeting[unit.code][`${ADSERVER_TARGETING_PREFIX}_${k}`] = v; }); - return a; - }, {}); + // ATF results shamelessly exfiltrated from intersectionRtdProvider + const bid = unit.bids.find(bid => !!bid.intersection); + if (bid) { + const v = val(config.params.thresholds.filter(t => t <= (bid.intersection.intersectionRatio * 100))); + if (v) targeting[unit.code][`${ADSERVER_TARGETING_PREFIX}_atf`] = v; + } + }); + + return targeting; } export const subModuleObj = { name: MODULE_NAME, init, getBidRequestData, - getTargetingData, - atf // used by adlooxRtdProvider_spec.js + getTargetingData }; submodule('realTimeData', subModuleObj); diff --git a/modules/adlooxRtdProvider.md b/modules/adlooxRtdProvider.md index 6c75fbc2d8b..9d6a20a01a7 100644 --- a/modules/adlooxRtdProvider.md +++ b/modules/adlooxRtdProvider.md @@ -19,12 +19,7 @@ This provider fetches segments and populates the [First Party Data](https://docs * AdUnit segments are placed into `AdUnit.ortb2Imp.ext.data.adloox_rtd`: * **`{dis,vid,aud}`:** an list of integers describing the likelihood the AdUnit will be visible * **`atf`:** an list of integers describing the percentage of pixels visible at auction - * measured only once at pre-auction - * usable when the publisher uses the strategy of collapsing ad slots on no-fill - * using the reverse strategy, growing ad slots on fill, invalidates the measurement the position of all content (including the slots) changes post-auction - * works best when your page loads your ad slots have their actual size rendered (ie. not zero height) - * uses the smallest ad unit (above a threshold area of 20x20) supplied by the [publisher to Prebid.js](https://docs.prebid.org/dev-docs/examples/basic-example.html) and measures viewability as if that size to be used - * when used in cross-origin (unfriendly) IFRAME environments the ad slot is directly measured as is (ignoring publisher provided sizes) due to limitations in using [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) + * measured at pre-auction time using the [Intersection Module](https://docs.prebid.org/dev-docs/modules/intersectionRtdProvider.html); if not enabled then this measurement is not available **N.B.** this provider does not offer or utilise any user orientated data @@ -57,8 +52,13 @@ To use this, you *must* also integrate the [Adloox Analytics Adapter](./adlooxAn realTimeData: { auctionDelay: 100, // see below for guidance dataProviders: [ + { + name: 'intersection', + waitForIt: true + }, { name: 'adloox', + waitForIt: true, params: { // optional, defaults shown thresholds: [ 50, 60, 70, 80, 90 ], slotinpath: false @@ -81,7 +81,7 @@ To use this, you *must* also integrate the [Adloox Analytics Adapter](./adlooxAn You may optionally pass a subsection `params` in the `params` block to the Adloox RTD Provider, these will be passed through to the segment handler as is and as described by the integration guidelines. -**N.B.** If you pass `params` to the Adloox Analytics Adapter, `id1` (`AdUnit.code`) and `id2` (`%%pbadslot%%`) *must* describe a stable identifier otherwise no usable segments will be served and so they *must not* be changed; if `id1` for your inventory could contain a non-stable random number please consult with us before continuing +**N.B.** If you pass `params` to the Adloox Analytics Adapter, `id1` (`AdUnit.code`) and `id2` (`%%gpid%%`) *must* describe a stable identifier otherwise no usable segments will be served and so they *must not* be changed; if `id1` for your inventory could contain a non-stable random number please consult with us before continuing Though our segment technology is fast (less than 10ms) the time it takes for the users device to connect to our service and fetch the segments may not be. For this reason we recommend setting `auctionDelay` no lower than 100ms and if possible you should explore using user-agent sourced information such as [NetworkInformation.{rtt,downlink,...}](https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation) to dynamically tune this for each user. @@ -94,7 +94,7 @@ You may use one of two ways to do achieve this: * for display inventory [using GPT](https://developers.google.com/publisher-tag/guides/get-started) you may configure Prebid.js to automatically use the [full ad unit path](https://developers.google.com/publisher-tag/reference#googletag.Slot_getAdUnitPath) 1. include the [`gptPreAuction` module](https://docs.prebid.org/dev-docs/modules/gpt-pre-auction.html) 1. wrap both `pbjs.setConfig({...})` and `pbjs.enableAnalytics({...})` with `googletag.cmd.push(function() { ... })` - * set `pbadslot` in the [first party data](https://docs.prebid.org/dev-docs/adunit-reference.html#first-party-data) variable `AdUnit.ortb2Imp.ext.data.pbadslot` for all your ad units + * set `gpid` (or `pbadslot`) in the [first party data](https://docs.prebid.org/dev-docs/adunit-reference.html#first-party-data) variable `AdUnit.ortb2Imp.ext.gpid` (or `AdUnit.ortb2Imp.ext.data.pbadslot`) for all your ad units ## Timeouts diff --git a/modules/admanBidAdapter.js b/modules/admanBidAdapter.js index 241864c50fc..2ee6ecfcb56 100644 --- a/modules/admanBidAdapter.js +++ b/modules/admanBidAdapter.js @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { isFn, deepAccess, logMessage } from '../src/utils.js'; import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'adman'; const AD_URL = 'https://pub.admanmedia.com/?c=o&m=multi'; @@ -63,10 +64,15 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const content = deepAccess(bidderRequest, 'ortb2.site.content', config.getAnyConfig('ortb2.site.content')); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page) winTop = window.top; } catch (e) { location = winTop.location; @@ -90,46 +96,63 @@ export const spec = { if (bidderRequest.gdprConsent) { request.gdpr = bidderRequest.gdprConsent } + if (content) { + request.content = content; + } } const len = validBidRequests.length; for (let i = 0; i < len; i++) { - let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER + const bid = validBidRequests[i]; + const { params, bidId, mediaTypes } = bid; + const placement = { - placementId: bid.params.placementId, - bidId: bid.bidId, - sizes: bid.mediaTypes && bid.mediaTypes[traff] && bid.mediaTypes[traff].sizes ? bid.mediaTypes[traff].sizes : [], - traffic: traff, + placementId: params.placementId, + bidId, eids: [], bidFloor: getBidFloor(bid) } + + if (bid.transactionId) { + placement.ext = placement.ext || {}; + placement.ext.tid = bid.transactionId; + } + if (bid.schain) { placement.schain = bid.schain; } + if (bid.userId) { getUserId(placement.eids, bid.userId.uid2 && bid.userId.uid2.id, 'uidapi.com'); getUserId(placement.eids, bid.userId.lotamePanoramaId, 'lotame.com'); + getUserId(placement.eids, bid.userId.idx, 'idx.lat'); } - if (traff === VIDEO) { - placement.playerSize = bid.mediaTypes[VIDEO].playerSize; - placement.minduration = bid.mediaTypes[VIDEO].minduration; - placement.maxduration = bid.mediaTypes[VIDEO].maxduration; - placement.mimes = bid.mediaTypes[VIDEO].mimes; - placement.protocols = bid.mediaTypes[VIDEO].protocols; - placement.startdelay = bid.mediaTypes[VIDEO].startdelay; - placement.placement = bid.mediaTypes[VIDEO].placement; - placement.skip = bid.mediaTypes[VIDEO].skip; - placement.skipafter = bid.mediaTypes[VIDEO].skipafter; - placement.minbitrate = bid.mediaTypes[VIDEO].minbitrate; - placement.maxbitrate = bid.mediaTypes[VIDEO].maxbitrate; - placement.delivery = bid.mediaTypes[VIDEO].delivery; - placement.playbackmethod = bid.mediaTypes[VIDEO].playbackmethod; - placement.api = bid.mediaTypes[VIDEO].api; - placement.linearity = bid.mediaTypes[VIDEO].linearity; + + if (mediaTypes?.[BANNER]) { + placement.traffic = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes?.[VIDEO]) { + placement.traffic = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; } + placements.push(placement); } + return { method: 'POST', url: AD_URL, diff --git a/modules/admaruBidAdapter.js b/modules/admaruBidAdapter.js index 65f62c77e26..f681a9a4191 100644 --- a/modules/admaruBidAdapter.js +++ b/modules/admaruBidAdapter.js @@ -5,6 +5,7 @@ const ADMARU_ENDPOINT = 'https://p1.admaru.net/AdCall'; const BIDDER_CODE = 'admaru'; const DEFAULT_BID_TTL = 360; +const SYNC_URL = 'https://p2.admaru.net/UserSync/sync' function parseBid(rawBid, currency) { const bid = {}; @@ -75,7 +76,24 @@ export const spec = { } return bidResponses; - } + }, + + getUserSyncs: function (syncOptions, responses) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: SYNC_URL + }]; + } + if (syncOptions.pixelEnabled) { + return [{ + type: 'image', + url: SYNC_URL + }]; + } + + return []; + }, } registerBidder(spec); diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js new file mode 100644 index 00000000000..52c06318ec0 --- /dev/null +++ b/modules/admaticBidAdapter.js @@ -0,0 +1,243 @@ +import {getValue, logError, isEmpty, deepAccess, isArray, getBidIdParameter} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +let SYNC_URL = ''; +const BIDDER_CODE = 'admatic'; +export const spec = { + code: BIDDER_CODE, + aliases: [ + {code: 'pixad'} + ], + supportedMediaTypes: [BANNER, VIDEO], + /** f + * @param {object} bid + * @return {boolean} + */ + isBidRequestValid: (bid) => { + let isValid = false; + if (bid?.params) { + const isValidNetworkId = _validateId(getValue(bid.params, 'networkId')); + const isValidHost = _validateString(getValue(bid.params, 'host')); + isValid = isValidNetworkId && isValidHost; + } + + if (!isValid) { + logError(`${bid.bidder} networkId and host parameters are required. Bid aborted.`); + } + return isValid; + }, + + /** + * @param {BidRequest[]} validBidRequests + * @return {ServerRequest} + */ + buildRequests: (validBidRequests, bidderRequest) => { + const bids = validBidRequests.map(buildRequestObject); + const blacklist = bidderRequest.ortb2; + const networkId = getValue(validBidRequests[0].params, 'networkId'); + const host = getValue(validBidRequests[0].params, 'host'); + const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; + const bidderName = validBidRequests[0].bidder; + + const payload = { + user: { + ua: navigator.userAgent + }, + blacklist: [], + site: { + page: location.href, + ref: location.origin, + publisher: { + name: location.hostname, + publisherId: networkId + } + }, + imp: bids, + ext: { + cur: currency, + bidder: bidderName + } + }; + + if (!isEmpty(blacklist.badv)) { + payload.blacklist = blacklist.badv; + }; + + if (payload) { + switch (bidderName) { + case 'pixad': + SYNC_URL = 'https://static.pixad.com.tr/sync.html'; + break; + default: + SYNC_URL = 'https://cdn.serve.admatic.com.tr/showad/sync.html'; + break; + } + + return { method: 'POST', url: `https://${host}/pb`, data: payload, options: { contentType: 'application/json' } }; + } + }, + + getUserSyncs: function (syncOptions, responses) { + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: SYNC_URL + }]; + } + }, + + /** + * @param {*} response + * @param {ServerRequest} request + * @return {Bid[]} + */ + interpretResponse: (response, request) => { + const body = response.body; + const bidResponses = []; + if (body && body?.data && isArray(body.data)) { + body.data.forEach(bid => { + const resbid = { + requestId: bid.id, + cpm: bid.price, + width: bid.width, + height: bid.height, + currency: body.cur || 'TRY', + netRevenue: true, + creativeId: bid.creative_id, + meta: { + advertiserDomains: bid && bid.adomain ? bid.adomain : [] + }, + bidder: bid.bidder, + mediaType: bid.type, + ttl: 60 + }; + + if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { + resbid.vastUrl = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === 'video') { + resbid.vastXml = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === 'banner') { + resbid.ad = bid.party_tag; + }; + + bidResponses.push(resbid); + }); + } + return bidResponses; + } +}; + +function isUrl(str) { + try { + URL(str); + return true; + } catch (error) { + return false; + } +}; + +function enrichSlotWithFloors(slot, bidRequest) { + try { + const slotFloors = {}; + + if (bidRequest.getFloor) { + if (bidRequest.mediaTypes?.banner) { + slotFloors.banner = {}; + const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) + bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = bidRequest.getFloor({ size: bannerSize, mediaType: BANNER })); + } + + if (bidRequest.mediaTypes?.video) { + slotFloors.video = {}; + const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) + videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = bidRequest.getFloor({ size: videoSize, mediaType: VIDEO })); + } + + if (Object.keys(slotFloors).length > 0) { + if (!slot) { + slot = {} + } + Object.assign(slot, { + floors: slotFloors + }); + } + } + } catch (e) { + logError('Could not parse floors from Prebid: ' + e); + } +} + +function parseSizes(sizes, parser = s => s) { + if (sizes == undefined) { + return []; + } + if (Array.isArray(sizes[0])) { // is there several sizes ? (ie. [[728,90],[200,300]]) + return sizes.map(size => parser(size)); + } + return [parser(sizes)]; // or a single one ? (ie. [728,90]) +} + +function parseSize(size) { + return size[0] + 'x' + size[1]; +} + +function buildRequestObject(bid) { + const reqObj = {}; + reqObj.size = getSizes(bid); + if (bid.mediaTypes?.banner) { + reqObj.type = 'banner'; + reqObj.mediatype = {}; + } + if (bid.mediaTypes?.video) { + reqObj.type = 'video'; + reqObj.mediatype = bid.mediaTypes.video; + } + + if (deepAccess(bid, 'ortb2Imp.ext')) { + reqObj.ext = bid.ortb2Imp.ext; + } + + reqObj.id = getBidIdParameter('bidId', bid); + + enrichSlotWithFloors(reqObj, bid); + + return reqObj; +} + +function getSizes(bid) { + return concatSizes(bid); +} + +function concatSizes(bid) { + let playerSize = deepAccess(bid, 'mediaTypes.video.playerSize'); + let videoSizes = deepAccess(bid, 'mediaTypes.video.sizes'); + let bannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes'); + + if (isArray(bannerSizes) || isArray(playerSize) || isArray(videoSizes)) { + let mediaTypesSizes = [bannerSizes, videoSizes, playerSize]; + return mediaTypesSizes + .reduce(function(acc, currSize) { + if (isArray(currSize)) { + if (isArray(currSize[0])) { + currSize.forEach(function (childSize) { + acc.push({ w: childSize[0], h: childSize[1] }); + }) + } + } + return acc; + }, []); + } +} + +function _validateId(id) { + return (parseInt(id) > 0); +} + +function _validateString(str) { + return (typeof str == 'string'); +} + +registerBidder(spec); diff --git a/modules/admaticBidAdapter.md b/modules/admaticBidAdapter.md index f6e822b9c06..2bf9afb3cdc 100644 --- a/modules/admaticBidAdapter.md +++ b/modules/admaticBidAdapter.md @@ -1,54 +1,48 @@ # Overview -``` -Module Name: AdMatic Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebid@admatic.com.tr -``` +**Module Name**: Admatic Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid@admatic.com.tr # Description -Module that connects to AdMatic demand sources +Use `admatic` as bidder. + +`networkId` is required and must be integer. + +## AdUnits configuration example +``` + var adUnits = [{ + code: 'your-slot_1-div', //use exactly the same code as your slot div id. + sizes: [[300, 250]], + bids: [{ + bidder: 'admatic', + params: { + networkId: 12345, + host: 'layer.serve.admatic.com.tr' + } + }] + },{ + code: 'your-slot_2-div', //use exactly the same code as your slot div id. + sizes: [[600, 800]], + bids: [{ + bidder: 'admatic', + params: { + networkId: 12345, + host: 'layer.serve.admatic.com.tr' + } + }] + }]; +``` + +## UserSync example -# Test Parameters ``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: "admatic", - params: { - pid: 193937152158, // publisher id without "adm-pub-" prefix - wid: 104276324971, // website id - priceType: 'gross', // default is net - url: window.location.href || window.top.location.href //page url from js - } - } - ] - },{ - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[320, 50]], // a mobile size - } - }, - bids: [ - { - bidder: "admatic", - params: { - pid: 193937152158, // publisher id without "adm-pub-" prefix - wid: 104276324971, // website id - priceType: 'gross', // default is net - url: window.location.href || window.top.location.href //page url from js - } - } - ] - } - ]; +pbjs.setConfig({ + userSync: { + iframeEnabled: true, + syncEnabled: true, + syncDelay: 1 + } +}); ``` diff --git a/modules/admediaBidAdapter.js b/modules/admediaBidAdapter.js new file mode 100644 index 00000000000..42593a36159 --- /dev/null +++ b/modules/admediaBidAdapter.js @@ -0,0 +1,98 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'admedia'; +const ENDPOINT_URL = 'https://prebid.admedia.com/bidder/'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return !!(bid.params.placementId); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @return Array Info describing the request to the server. + * @param validBidRequests + * @param bidderRequest + */ + buildRequests: function (validBidRequests, bidderRequest) { + if (validBidRequests.length === 0) { + return []; + } + return validBidRequests.map(bidRequest => { + let sizes = [] + if (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER] && bidRequest.mediaTypes[BANNER].sizes) { + sizes = bidRequest.mediaTypes[BANNER].sizes; + } + + var tagData = []; + for (var i = 0, j = sizes.length; i < j; i++) { + let tag = {}; + tag.sizes = []; + tag.id = bidRequest.params.placementId; + tag.aid = bidRequest.params.aid; + tag.sizes.push(sizes[i].toString().replace(',', 'x')); + tagData.push(tag); + } + + const payload = { + id: bidRequest.params.placementId, + aid: bidRequest.params.aid, + tags: tagData, + bidId: bidRequest.bidId, + referer: encodeURIComponent(bidderRequest.refererInfo.page) + }; + + return { + method: 'POST', + url: ENDPOINT_URL, + data: payload + }; + }); + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @param bidRequest + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequest) { + const requiredKeys = ['requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency', 'meta']; + const validBidResponses = []; + serverResponse = serverResponse.body.tags; + + if (serverResponse && (serverResponse.length > 0)) { + serverResponse.forEach((bid) => { + const bidResponse = {}; + for (const requiredKey of requiredKeys) { + if (!bid.hasOwnProperty(requiredKey)) { + return []; + } + bidResponse[requiredKey] = bid[requiredKey]; + } + if (!(typeof bid.meta.advertiserDomains !== 'undefined' && bid.meta.advertiserDomains.length > 0)) { + return []; + } + validBidResponses.push(bidResponse); + }); + } + return validBidResponses; + }, + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {}, + onTimeout: function(timeoutData) {}, + onBidWon: function (bid) {} +}; + +registerBidder(spec); diff --git a/modules/admediaBidAdapter.md b/modules/admediaBidAdapter.md index a03a7b49529..fe4378e9f61 100644 --- a/modules/admediaBidAdapter.md +++ b/modules/admediaBidAdapter.md @@ -1,42 +1,35 @@ # Overview -``` -Module Name: Admedia Bidder Adapter -Module Type: Bidder Adapter -Maintainer: developers@admedia.com -``` +**Module Name**: Admedia Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: developers@admedia.com # Description -Admedia Bidder Adapter for Prebid.js. -Only Banner format is supported. +Module that connects to Admedia's bidder for bids. # Test Parameters ``` - var adUnits = [ - { - code: 'test-div-0', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: 'admedia', - params: { - aid: 86858 - } - } - ] - }, - { - code: 'test-div-1', - sizes: [[300, 50]], // a mobile size - bids: [ - { - bidder: 'admedia', - params: { - aid: 86858 - } - } - ] - } - ]; -``` +var adUnits = [ + { + code: 'ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [{ + + bidder: 'admedia', + params: { + placementId: '782332', + aid: '86858', + }, + refererInfo: { + page: "http://addreferrerhere.com" + } + + }] + } +]; +``` \ No newline at end of file diff --git a/modules/admixerBidAdapter.js b/modules/admixerBidAdapter.js index dfb76a03804..6cbc36c1dcd 100644 --- a/modules/admixerBidAdapter.js +++ b/modules/admixerBidAdapter.js @@ -1,14 +1,23 @@ -import { logError } from '../src/utils.js'; +import {isStr, logError} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {BANNER, VIDEO, NATIVE} from '../src/mediaTypes.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {find} from '../src/polyfill.js'; const BIDDER_CODE = 'admixer'; -const ALIASES = ['go2net', 'adblender', 'adsyield', 'futureads']; const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.2.aspx'; +const ALIASES = [ + {code: 'go2net', endpoint: 'https://ads.go2net.com.ua/prebid.1.2.aspx'}, + 'adblender', + {code: 'adsyield', endpoint: 'https://ads.adsyield.com/prebid.1.2.aspx'}, + {code: 'futureads', endpoint: 'https://ads.futureads.io/prebid.1.2.aspx'}, + {code: 'smn', endpoint: 'https://ads.smn.rs/prebid.1.2.aspx'}, + {code: 'admixeradx', endpoint: 'https://inv-nets.admixer.net/adxprebid.1.2.aspx'}, +]; export const spec = { code: BIDDER_CODE, - aliases: ALIASES, + aliases: ALIASES.map(val => isStr(val) ? val : val.code), supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** * Determines whether or not the given bid request is valid. @@ -20,6 +29,9 @@ export const spec = { * Make a server request from the list of BidRequests. */ buildRequests: function (validRequest, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validRequest = convertOrtbRequestToProprietaryNative(validRequest); + let w; let docRef; do { @@ -32,35 +44,42 @@ export const spec = { } while (w !== window.top); const payload = { imps: [], - ortb2: config.getConfig('ortb2'), + ortb2: bidderRequest.ortb2, docReferrer: docRef, }; let endpointUrl; if (bidderRequest) { const {bidderCode} = bidderRequest; endpointUrl = config.getConfig(`${bidderCode}.endpoint_url`); - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - payload.referrer = encodeURIComponent(bidderRequest.refererInfo.referer); + // TODO: is 'page' the right value here? + if (bidderRequest.refererInfo?.page) { + payload.referrer = encodeURIComponent(bidderRequest.refererInfo.page); } if (bidderRequest.gdprConsent) { payload.gdprConsent = { consentString: bidderRequest.gdprConsent.consentString, // will check if the gdprApplies field was populated with a boolean value (ie from page config). If it's undefined, then default to true gdprApplies: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true - } + }; } if (bidderRequest.uspConsent) { payload.uspConsent = bidderRequest.uspConsent; } + let bidFloor = getBidFloor(bidderRequest); + if (bidFloor) { + payload.bidFloor = bidFloor; + } } validRequest.forEach((bid) => { let imp = {}; Object.keys(bid).forEach(key => imp[key] = bid[key]); + imp.ortb2 && delete imp.ortb2; payload.imps.push(imp); }); return { method: 'POST', - url: endpointUrl || ENDPOINT_URL, + url: + endpointUrl || getEndpointUrl(bidderRequest.bidderCode), data: payload, }; }, @@ -91,4 +110,19 @@ export const spec = { return pixels; } }; +function getEndpointUrl(code) { + return find(ALIASES, (val) => val.code === code)?.endpoint || ENDPOINT_URL; +} +function getBidFloor(bid) { + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0; + } +} registerBidder(spec); diff --git a/modules/admixerIdSystem.js b/modules/admixerIdSystem.js index 49ffe4f4680..0e3a56420a8 100644 --- a/modules/admixerIdSystem.js +++ b/modules/admixerIdSystem.js @@ -9,8 +9,10 @@ import { logError, logInfo } from '../src/utils.js' import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; -export const storage = getStorageManager(); +const NAME = 'admixerId'; +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: NAME}); /** @type {Submodule} */ export const admixerIdSubmodule = { @@ -18,7 +20,7 @@ export const admixerIdSubmodule = { * used to link submodule with config * @type {string} */ - name: 'admixerId', + name: NAME, /** * used to specify vendor id * @type {number} @@ -70,6 +72,12 @@ export const admixerIdSubmodule = { }; return { callback: resp }; + }, + eids: { + 'admixerId': { + source: 'admixer.net', + atype: 3 + }, } }; function retrieveVisitorId(url, callback) { diff --git a/modules/adnowBidAdapter.js b/modules/adnowBidAdapter.js index 472d0fdb2e1..f83dbf68a1f 100644 --- a/modules/adnowBidAdapter.js +++ b/modules/adnowBidAdapter.js @@ -2,6 +2,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {deepAccess, parseQueryStringParameters, parseSizesInput} from '../src/utils.js'; import {includes} from '../src/polyfill.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'adnow'; const ENDPOINT = 'https://n.ads3-adnow.com/a'; @@ -48,6 +49,9 @@ export const spec = { * @return {ServerRequest} */ buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + return validBidRequests.map(req => { const mediaType = this._isBannerRequest(req) ? BANNER : NATIVE; const codeId = parseInt(req.params.codeId, 10); @@ -63,7 +67,7 @@ export const spec = { if (mediaType === BANNER) { data.sizes = parseSizesInput( req.mediaTypes && req.mediaTypes.banner && req.mediaTypes.banner.sizes - ).join('|') + ).join('|'); } else { data.width = data.height = 200; diff --git a/modules/adnuntiusBidAdapter.js b/modules/adnuntiusBidAdapter.js index 9e05ea664d8..a2b695e55e0 100644 --- a/modules/adnuntiusBidAdapter.js +++ b/modules/adnuntiusBidAdapter.js @@ -1,12 +1,20 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { isStr, deepAccess } from '../src/utils.js'; import { config } from '../src/config.js'; import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'adnuntius'; +const BIDDER_CODE_DEAL_ALIAS_BASE = 'adndeal'; +const BIDDER_CODE_DEAL_ALIASES = [1, 2, 3, 4, 5].map(num => { + return BIDDER_CODE_DEAL_ALIAS_BASE + num; +}); const ENDPOINT_URL = 'https://ads.adnuntius.delivery/i'; +const ENDPOINT_URL_EUROPE = 'https://europe.delivery.adnuntius.com/i'; const GVLID = 855; +const DEFAULT_VAST_VERSION = 'vast4' +const MAXIMUM_DEALS_LIMIT = 5; +const VALID_BID_TYPES = ['netBid', 'grossBid']; const checkSegment = function (segment) { if (isStr(segment)) return segment; @@ -27,13 +35,12 @@ const getSegmentsFromOrtb = function (ortb2) { } const handleMeta = function () { - const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}) + const storage = getStorageManager({ bidderCode: BIDDER_CODE }) let adnMeta = null if (storage.localStorageIsEnabled()) { adnMeta = JSON.parse(storage.getDataFromLocalStorage('adn.metaData')) } - const meta = (adnMeta !== null) ? adnMeta.reduce((acc, cur) => { return { ...acc, [cur.key]: cur.value } }, {}) : {} - return meta + return (adnMeta !== null) ? adnMeta.reduce((acc, cur) => { return { ...acc, [cur.key]: cur.value } }, {}) : {} } const getUsi = function (meta, ortb2, bidderRequest) { @@ -42,12 +49,21 @@ const getUsi = function (meta, ortb2, bidderRequest) { return usi } +const validateBidType = function(bidTypeOption) { + return VALID_BID_TYPES.indexOf(bidTypeOption || '') > -1 ? bidTypeOption : 'bid'; +} + +const AU_ID_REGEX = new RegExp('^[0-9A-Fa-f]{1,20}$'); + export const spec = { code: BIDDER_CODE, + aliases: BIDDER_CODE_DEAL_ALIASES, gvlid: GVLID, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function (bid) { - return !!(bid.bidId || (bid.params.member && bid.params.invCode)); + // The auId MUST be a hexadecimal string + const validAuId = AU_ID_REGEX.test(bid.params.auId); + return !!(validAuId && (bid.bidId || (bid.params.member && bid.params.invCode))); }, buildRequests: function (validBidRequests, bidderRequest) { @@ -55,7 +71,7 @@ export const spec = { const bidRequests = {}; const requests = []; const request = []; - const ortb2 = config.getConfig('ortb2'); + const ortb2 = bidderRequest.ortb2 || {}; const bidderConfig = config.getConfig(); const adnMeta = handleMeta() @@ -67,31 +83,43 @@ export const spec = { request.push('tzo=' + tzo) request.push('format=json') + if (gdprApplies !== undefined) request.push('consentString=' + consentString); if (segments.length > 0) request.push('segments=' + segments.join(',')); if (usi) request.push('userId=' + usi); - if (bidderConfig.useCookie === false) request.push('noCookies=true') - for (var i = 0; i < validBidRequests.length; i++) { + if (bidderConfig.useCookie === false) request.push('noCookies=true'); + if (bidderConfig.maxDeals > 0) request.push('ds=' + Math.min(bidderConfig.maxDeals, MAXIMUM_DEALS_LIMIT)); + for (let i = 0; i < validBidRequests.length; i++) { const bid = validBidRequests[i] - const network = bid.params.network || 'network'; + let network = bid.params.network || 'network'; + const maxDeals = Math.max(0, Math.min(bid.params.maxDeals || 0, MAXIMUM_DEALS_LIMIT)); const targeting = bid.params.targeting || {}; + if (bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context !== 'outstream') { + network += '_video' + } + bidRequests[network] = bidRequests[network] || []; bidRequests[network].push(bid); networks[network] = networks[network] || {}; networks[network].adUnits = networks[network].adUnits || []; - if (bidderRequest && bidderRequest.refererInfo) networks[network].context = bidderRequest.refererInfo.referer; + if (bidderRequest && bidderRequest.refererInfo) networks[network].context = bidderRequest.refererInfo.page; if (adnMeta) networks[network].metaData = adnMeta; - networks[network].adUnits.push({ ...targeting, auId: bid.params.auId, targetId: bid.bidId }); + const adUnit = { ...targeting, auId: bid.params.auId, targetId: bid.bidId, maxDeals: maxDeals } + if (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) adUnit.dimensions = bid.mediaTypes.banner.sizes + networks[network].adUnits.push(adUnit); } const networkKeys = Object.keys(networks) - for (var j = 0; j < networkKeys.length; j++) { + for (let j = 0; j < networkKeys.length; j++) { const network = networkKeys[j]; + const networkRequest = [...request] + if (network.indexOf('_video') > -1) { networkRequest.push('tt=' + DEFAULT_VAST_VERSION) } + const requestURL = gdprApplies ? ENDPOINT_URL_EUROPE : ENDPOINT_URL requests.push({ method: 'POST', - url: ENDPOINT_URL + '?' + request.join('&'), + url: requestURL + '?' + networkRequest.join('&'), data: JSON.stringify(networks[network]), bid: bidRequests[network] }); @@ -102,39 +130,91 @@ export const spec = { interpretResponse: function (serverResponse, bidRequest) { const adUnits = serverResponse.body.adUnits; - const bidResponsesById = adUnits.reduce((response, adUnit) => { - if (adUnit.matchedAdCount >= 1) { - const ad = adUnit.ads[0]; - const effectiveCpm = (ad.bid) ? ad.bid.amount * 1000 : 0; - return { - ...response, - [adUnit.targetId]: { - requestId: adUnit.targetId, - cpm: effectiveCpm, - width: Number(ad.creativeWidth), - height: Number(ad.creativeHeight), - creativeId: ad.creativeId, - currency: (ad.bid) ? ad.bid.currency : 'EUR', - dealId: ad.dealId || '', - meta: { - advertiserDomains: (ad.destinationUrls.destination) ? [ad.destinationUrls.destination.split('/')[2]] : [] - - }, - netRevenue: false, - ttl: 360, - ad: adUnit.html - } + + let validatedBidType = validateBidType(config.getConfig().bidType); + if (bidRequest.bid) { + bidRequest.bid.forEach(b => { + if (b.params && b.params.bidType) { + validatedBidType = validateBidType(b.params.bidType); } - } else return response + }); + } + + function buildAdResponse(bidderCode, ad, adUnit, dealCount) { + const destinationUrls = ad.destinationUrls || {}; + const advertiserDomains = []; + for (const value of Object.values(destinationUrls)) { + advertiserDomains.push(value.split('/')[2]) + } + const adResponse = { + bidderCode: bidderCode, + requestId: adUnit.targetId, + cpm: ad[validatedBidType] ? ad[validatedBidType].amount * 1000 : 0, + width: Number(ad.creativeWidth), + height: Number(ad.creativeHeight), + creativeId: ad.creativeId, + currency: (ad.bid) ? ad.bid.currency : 'EUR', + dealId: ad.dealId || '', + dealCount: dealCount, + meta: { + advertiserDomains: advertiserDomains + }, + netRevenue: false, + ttl: 360, + }; + // Deal bids provide the rendered ad content along with the + // bid; whereas regular bids have it stored on the ad-unit. + const isDeal = dealCount > 0; + const renderSource = isDeal ? ad : adUnit; + if (renderSource.vastXml) { + adResponse.vastXml = renderSource.vastXml + adResponse.mediaType = VIDEO + } else { + adResponse.ad = renderSource.html + } + return adResponse; + } + + const bidsById = bidRequest.bid.reduce((response, bid) => { + return { + ...response, + [bid.bidId]: bid + }; }, {}); - const bidResponse = bidRequest.bid.map(bid => bid.bidId).reduce((request, adunitId) => { - if (bidResponsesById[adunitId]) { request.push(bidResponsesById[adunitId]) } - return request + const hasBidAdUnits = adUnits.filter((au) => { + const bid = bidsById[au.targetId]; + if (bid && bid.bidder && BIDDER_CODE_DEAL_ALIASES.indexOf(bid.bidder) < 0) { + return au.matchedAdCount > 0; + } else { + // We do NOT accept bids when using this adaptor via one of the + // "deals" aliases; those requests are for ONLY getting deals from Adnuntius + return false; + } + }); + const hasDealsAdUnits = adUnits.filter((au) => { + return au.deals && au.deals.length > 0; + }); + + const dealAdResponses = hasDealsAdUnits.reduce((response, au) => { + const bid = bidsById[au.targetId]; + if (bid) { + (au.deals || []).forEach((deal, i) => { + response.push(buildAdResponse(bid.bidder, deal, au, i + 1)); + }); + } + return response; }, []); - return bidResponse - }, + const bidAdResponses = hasBidAdUnits.reduce((response, au) => { + const bid = bidsById[au.targetId]; + if (bid) { + response.push(buildAdResponse(bid.bidder, au.ads[0], au, 0)); + } + return response; + }, []); + return [...dealAdResponses, ...bidAdResponses]; + } } registerBidder(spec); diff --git a/modules/adnuntiusBidAdapter.md b/modules/adnuntiusBidAdapter.md index aed12079856..d5ecf5d4ee3 100644 --- a/modules/adnuntiusBidAdapter.md +++ b/modules/adnuntiusBidAdapter.md @@ -9,7 +9,7 @@ Maintainer: info@adnuntius.com # Description Adnuntius Bidder Adapter for Prebid.js. -Only Banner format is supported. +Banner and Video formats are supported. # Test Parameters ``` @@ -27,6 +27,7 @@ Only Banner format is supported. params: { auId: "8b6bc", network: "adnuntius", + maxDeals: 0 } }, ] diff --git a/modules/adoceanBidAdapter.js b/modules/adoceanBidAdapter.js index 0c23f5e3d8a..d74a78270b2 100644 --- a/modules/adoceanBidAdapter.js +++ b/modules/adoceanBidAdapter.js @@ -2,11 +2,15 @@ import { _each, parseSizesInput, isStr, isArray } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'adocean'; +const URL_SAFE_FIELDS = { + schain: true, + slaves: true +}; function buildEndpointUrl(emiter, payloadMap) { const payload = []; _each(payloadMap, function(v, k) { - payload.push(k + '=' + encodeURIComponent(v)); + payload.push(k + '=' + (URL_SAFE_FIELDS[k] ? v : encodeURIComponent(v))); }); const randomizedPart = Math.random().toString().slice(2); @@ -17,15 +21,20 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) { let emiter; const payload = { id: masterId, - aosspsizes: [] + aosspsizes: [], + slaves: [] }; if (gdprConsent) { payload.gdpr_consent = gdprConsent.consentString || undefined; payload.gdpr = gdprConsent.gdprApplies ? 1 : 0; } + const anyKey = Object.keys(masterBidRequests)[0]; + if (masterBidRequests[anyKey].schain) { + payload.schain = serializeSupplyChain(masterBidRequests[anyKey].schain); + } const bidIdMap = {}; - + const uniquePartLength = 10; _each(masterBidRequests, function(bid, slaveId) { if (!emiter) { emiter = bid.params.emiter; @@ -34,11 +43,13 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) { const slaveSizes = parseSizesInput(bid.mediaTypes.banner.sizes).join('_'); const rawSlaveId = bid.params.slaveId.replace('adocean', ''); payload.aosspsizes.push(rawSlaveId + '~' + slaveSizes); + payload.slaves.push(rawSlaveId.slice(-uniquePartLength)); bidIdMap[slaveId] = bid.bidId; }); payload.aosspsizes = payload.aosspsizes.join('-'); + payload.slaves = payload.slaves.join(','); return { method: 'GET', @@ -48,6 +59,30 @@ function buildRequest(masterBidRequests, masterId, gdprConsent) { }; } +const SCHAIN_FIELDS = ['asi', 'sid', 'hp', 'rid', 'name', 'domain', 'ext']; +function serializeSupplyChain(schain) { + const header = `${schain.ver},${schain.complete}!`; + + const serializedNodes = []; + _each(schain.nodes, function(node) { + const serializedNode = SCHAIN_FIELDS + .map(fieldName => { + if (fieldName === 'ext') { + // do not serialize ext data, just mark if it was available + return ('ext' in node ? '1' : '0'); + } + if (fieldName in node) { + return encodeURIComponent(node[fieldName]).replace(/!/g, '%21'); + } + return ''; + }) + .join(','); + serializedNodes.push(serializedNode); + }); + + return header + serializedNodes.join('!'); +} + function assignToMaster(bidRequest, bidRequestsByMaster) { const masterId = bidRequest.params.masterId; const slaveId = bidRequest.params.slaveId; diff --git a/modules/adomikAnalyticsAdapter.js b/modules/adomikAnalyticsAdapter.js index 44c0c6868cf..27a6821d9f5 100644 --- a/modules/adomikAnalyticsAdapter.js +++ b/modules/adomikAnalyticsAdapter.js @@ -1,10 +1,10 @@ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import {logInfo} from '../src/utils.js'; import {find, findIndex} from '../src/polyfill.js'; -// Events used in adomik analytics adapter +// Events used in adomik analytics adapter. const auctionInit = CONSTANTS.EVENTS.AUCTION_INIT; const auctionEnd = CONSTANTS.EVENTS.AUCTION_END; const bidRequested = CONSTANTS.EVENTS.BID_REQUESTED; @@ -30,17 +30,13 @@ let adomikAdapter = Object.assign(adapter({}), break; case bidResponse: - adomikAdapter.bucketEvents.push({ - type: 'response', - event: adomikAdapter.buildBidResponse(args) - }); + adomikAdapter.saveBidResponse(args); break; case bidWon: - adomikAdapter.sendWonEvent({ - id: args.adId, - placementCode: args.adUnitCode - }); + args.id = args.adId; + args.placementCode = args.adUnitCode; + adomikAdapter.sendWonEvent(args); break; case bidRequested: @@ -69,16 +65,28 @@ adomikAdapter.initializeBucketEvents = function() { adomikAdapter.bucketEvents = []; } +adomikAdapter.saveBidResponse = function(args) { + let responseSaved = adomikAdapter.bucketEvents.find((bucketEvent) => + bucketEvent.type == 'response' && bucketEvent.event.id == args.id + ); + if (responseSaved) { return true; } + adomikAdapter.bucketEvents.push({ + type: 'response', + event: adomikAdapter.buildBidResponse(args) + }); +} + adomikAdapter.maxPartLength = function () { return (ua.includes(' MSIE ')) ? 1600 : 60000; }; adomikAdapter.sendTypedEvent = function() { + let [testId, testValue] = adomikAdapter.getKeyValues(); const groupedTypedEvents = adomikAdapter.buildTypedEvents(); const bulkEvents = { - testId: adomikAdapter.currentContext.testId, - testValue: adomikAdapter.currentContext.testValue, + testId: testId, + testValue: testValue, uid: adomikAdapter.currentContext.uid, ahbaid: adomikAdapter.currentContext.id, hostname: window.location.hostname, @@ -114,10 +122,8 @@ adomikAdapter.sendTypedEvent = function() { const stringBulkEvents = JSON.stringify(bulkEvents) logInfo('Events sent to adomik prebid analytic ' + stringBulkEvents); - // Encode object in base64 const encodedBuf = window.btoa(stringBulkEvents); - // Create final url and split it (+endpoint length) const encodedUri = encodeURIComponent(encodedBuf); const maxLength = adomikAdapter.maxPartLength(); const splittedUrl = encodedUri.match(new RegExp(`.{1,${maxLength}}`, 'g')); @@ -130,16 +136,18 @@ adomikAdapter.sendTypedEvent = function() { }; adomikAdapter.sendWonEvent = function (wonEvent) { - let keyValues = { testId: adomikAdapter.currentContext.testId, testValue: adomikAdapter.currentContext.testValue } - wonEvent = {...wonEvent, ...keyValues} - const stringWonEvent = JSON.stringify(wonEvent) + let [testId, testValue] = adomikAdapter.getKeyValues(); + let keyValues = { testId: testId, testValue: testValue }; + let samplingInfo = { sampling: adomikAdapter.currentContext.sampling }; + wonEvent = { ...adomikAdapter.buildBidResponse(wonEvent), ...keyValues, ...samplingInfo }; + + const stringWonEvent = JSON.stringify(wonEvent); logInfo('Won event sent to adomik prebid analytic ' + stringWonEvent); - // Encode object in base64 const encodedBuf = window.btoa(stringWonEvent); const encodedUri = encodeURIComponent(encodedBuf); const img = new Image(1, 1); - img.src = `https://${adomikAdapter.currentContext.url}/?q=${encodedUri}&id=${adomikAdapter.currentContext.id}&won=true` + img.src = `https://${adomikAdapter.currentContext.url}/?q=${encodedUri}&id=${adomikAdapter.currentContext.id}&won=true`; } adomikAdapter.buildBidResponse = function (bid) { @@ -201,33 +209,49 @@ adomikAdapter.buildTypedEvents = function () { return groupedTypedEvents; } -adomikAdapter.adapterEnableAnalytics = adomikAdapter.enableAnalytics; +adomikAdapter.getKeyValues = function () { + let preventTest = sessionStorage.getItem(window.location.hostname + '_NoAdomikTest') + let inScope = sessionStorage.getItem(window.location.hostname + '_AdomikTestInScope') + let keyValues = JSON.parse(sessionStorage.getItem(window.location.hostname + '_AdomikTest')) + let testId; + let testValue; + if (typeof (keyValues) === 'object' && keyValues != undefined && !preventTest && inScope) { + testId = keyValues.testId + testValue = keyValues.testOptionLabel + } + return [testId, testValue] +} -adomikAdapter.enableAnalytics = function (config) { - adomikAdapter.currentContext = {}; - const initOptions = config.options; - - _sampled = typeof config === 'undefined' || - typeof config.sampling === 'undefined' || - Math.random() < parseFloat(config.sampling); - - if (_sampled) { - if (initOptions) { - adomikAdapter.currentContext = { - uid: initOptions.id, - url: initOptions.url, - testId: initOptions.testId, - testValue: initOptions.testValue, - id: '', - timeouted: false, - sampling: config.sampling - } - logInfo('Adomik Analytics enabled with config', initOptions); - adomikAdapter.adapterEnableAnalytics(config); - } - } else { - logInfo('Adomik Analytics ignored for sampling', config.sampling); +adomikAdapter.enable = function(options) { + adomikAdapter.currentContext = { + uid: options.id, + url: options.url, + id: '', + timeouted: false, + sampling: options.sampling } + logInfo('Adomik Analytics enabled with config', options); + adomikAdapter.adapterEnableAnalytics(options); +}; + +adomikAdapter.checkOptions = function(options) { + if (typeof options !== 'undefined') { + if (options.id && options.url) { adomikAdapter.enable(options); } else { logInfo('Adomik Analytics disabled because id and/or url is missing from config', options); } + } else { logInfo('Adomik Analytics disabled because config is missing'); } +}; + +adomikAdapter.checkSampling = function(options) { + _sampled = typeof options === 'undefined' || + typeof options.sampling === 'undefined' || + (options.sampling > 0 && Math.random() < parseFloat(options.sampling)); + if (_sampled) { adomikAdapter.checkOptions(options) } else { logInfo('Adomik Analytics ignored for sampling', options.sampling); } +}; + +adomikAdapter.adapterEnableAnalytics = adomikAdapter.enableAnalytics; + +adomikAdapter.enableAnalytics = function ({ provider, options }) { + logInfo('Adomik Analytics enableAnalytics', provider); + adomikAdapter.checkSampling(options); }; adapterManager.registerAnalyticsAdapter({ diff --git a/modules/adotBidAdapter.js b/modules/adotBidAdapter.js index ac49f7ae32d..c34af4d3d17 100644 --- a/modules/adotBidAdapter.js +++ b/modules/adotBidAdapter.js @@ -4,14 +4,14 @@ import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {isArray, isBoolean, isFn, isPlainObject, isStr, logError, replaceAuctionPrice} from '../src/utils.js'; import {find} from '../src/polyfill.js'; import {config} from '../src/config.js'; -import { OUTSTREAM } from '../src/video.js'; +import {OUTSTREAM} from '../src/video.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'adot'; const ADAPTER_VERSION = 'v2.0.0'; const BID_METHOD = 'POST'; const BIDDER_URL = 'https://dsp.adotmob.com/headerbidding{PUBLISHER_PATH}/bidrequest'; const REQUIRED_VIDEO_PARAMS = ['mimes', 'protocols']; -const DOMAIN_REGEX = new RegExp('//([^/]*)'); const FIRST_PRICE = 1; const IMP_BUILDER = { banner: buildBanner, video: buildVideo, native: buildNative }; const NATIVE_PLACEMENTS = { @@ -43,19 +43,6 @@ function tryParse(data) { } } -/** - * Extract domain from given url - * - * @param {string} url - * @returns {string|null} Extracted domain - */ -function extractDomainFromURL(url) { - if (!url || !isStr(url)) return null; - const domain = url.match(DOMAIN_REGEX); - if (isArray(domain) && domain.length === 2) return domain[1]; - return null; -} - /** * Create and return site OpenRtb object from given bidderRequest * @@ -63,19 +50,22 @@ function extractDomainFromURL(url) { * @returns {Site|null} Formatted Site OpenRtb object or null */ function getOpenRTBSiteObject(bidderRequest) { - if (!bidderRequest || !bidderRequest.refererInfo) return null; + const refererInfo = (bidderRequest && bidderRequest.refererInfo) || null; - const domain = extractDomainFromURL(bidderRequest.refererInfo.referer); + const domain = refererInfo ? refererInfo.domain : window.location.hostname; const publisherId = config.getConfig('adot.publisherId'); if (!domain) return null; return { - page: bidderRequest.refererInfo.referer, + page: refererInfo ? refererInfo.page : window.location.href, domain: domain, name: domain, publisher: { id: publisherId + }, + ext: { + schain: bidderRequest.schain } }; } @@ -97,7 +87,13 @@ function getOpenRTBDeviceObject() { */ function getOpenRTBUserObject(bidderRequest) { if (!bidderRequest || !bidderRequest.gdprConsent || !isStr(bidderRequest.gdprConsent.consentString)) return null; - return { ext: { consent: bidderRequest.gdprConsent.consentString } }; + + return { + ext: { + consent: bidderRequest.gdprConsent.consentString, + pubProvidedId: bidderRequest.userId && bidderRequest.userId.pubProvidedId, + }, + }; } /** @@ -378,6 +374,8 @@ function splitAdUnits(validBidRequests) { * @returns {Array} */ function buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); const adUnits = splitAdUnits(validBidRequests); const publisherPathConfig = config.getConfig('adot.publisherPath'); const publisherPath = publisherPathConfig === undefined ? '' : '/' + publisherPathConfig; diff --git a/modules/adpartnerBidAdapter.js b/modules/adpartnerBidAdapter.js index e8d8a43aa1b..471a0bba64a 100644 --- a/modules/adpartnerBidAdapter.js +++ b/modules/adpartnerBidAdapter.js @@ -15,12 +15,8 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { - let referer = window.location.href; - try { - referer = typeof bidderRequest.refererInfo === 'undefined' - ? window.top.location.href - : bidderRequest.refererInfo.referer; - } catch (e) {} + // TODO does it make sense to fall back to window.location.href? + const referer = bidderRequest?.refererInfo?.page || window.location.href; let bidRequests = []; let beaconParams = { diff --git a/modules/adplusBidAdapter.js b/modules/adplusBidAdapter.js index 4707ca2ff5a..6fbe1fe1dde 100644 --- a/modules/adplusBidAdapter.js +++ b/modules/adplusBidAdapter.js @@ -127,6 +127,7 @@ function createBidRequest(bid) { screenWidth: screen.width, screenHeight: screen.height, language: window.navigator.language || 'en-US', + // TODO: these should probably look at refererInfo pageUrl: window.location.href, domain: window.location.hostname, referrer: window.location.referrer, diff --git a/modules/adpod.js b/modules/adpod.js index b7c459fd66f..d2fd817ee62 100644 --- a/modules/adpod.js +++ b/modules/adpod.js @@ -13,7 +13,6 @@ */ import { - compareOn, deepAccess, generateUUID, groupBy, @@ -28,14 +27,12 @@ import { import { addBidToAuction, AUCTION_IN_PROGRESS, - callPrebidCache, - doCallbacksIfTimedout, getPriceByGranularity, getPriceGranularity } from '../src/auction.js'; import {checkAdUnitSetup} from '../src/prebid.js'; import {checkVideoBidSetup} from '../src/video.js'; -import {module, setupBeforeHookFnOnce} from '../src/hook.js'; +import {getHook, module, setupBeforeHookFnOnce} from '../src/hook.js'; import {store} from '../src/videoCache.js'; import {config} from '../src/config.js'; import {ADPOD} from '../src/mediaTypes.js'; @@ -213,9 +210,6 @@ function firePrebidCacheCall(auctionInstance, bidList, afterBidAdded) { store(bidList, function (error, cacheIds) { if (error) { logWarn(`Failed to save to the video cache: ${error}. Video bid(s) must be discarded.`); - for (let i = 0; i < bidList.length; i++) { - doCallbacksIfTimedout(auctionInstance, bidList[i]); - } } else { for (let i = 0; i < cacheIds.length; i++) { // when uuid in response is empty string then the key already existed, so this bid wasn't cached @@ -243,7 +237,7 @@ export function callPrebidCacheHook(fn, auctionInstance, bidResponse, afterBidAd let brandCategoryExclusion = config.getConfig('adpod.brandCategoryExclusion'); let adServerCatId = deepAccess(bidResponse, 'meta.adServerCatId'); if (!adServerCatId && brandCategoryExclusion) { - logWarn('Detected a bid without meta.adServerCatId while setConfig({adpod.brandCategoryExclusion}) was enabled. This bid has been rejected:', bidResponse) + logWarn('Detected a bid without meta.adServerCatId while setConfig({adpod.brandCategoryExclusion}) was enabled. This bid has been rejected:', bidResponse); afterBidAdded(); } else { if (config.getConfig('adpod.deferCaching') === false) { @@ -424,7 +418,7 @@ config.getConfig('adpod', config => adpodSetConfig(config.adpod)); * This function initializes the adpod module's hooks. This is called by the corresponding adserver video module. */ function initAdpodHooks() { - setupBeforeHookFnOnce(callPrebidCache, callPrebidCacheHook); + setupBeforeHookFnOnce(getHook('callPrebidCache'), callPrebidCacheHook); setupBeforeHookFnOnce(checkAdUnitSetup, checkAdUnitSetupHook); setupBeforeHookFnOnce(checkVideoBidSetup, checkVideoBidSetupHook); } @@ -596,6 +590,23 @@ function getAdPodAdUnits(codes) { .filter((adUnit) => (codes.length > 0) ? codes.indexOf(adUnit.code) != -1 : true); } +/** + * This function will create compare function to sort on object property + * @param {string} property + * @returns {function} compare function to be used in sorting + */ +function compareOn(property) { + return function compare(a, b) { + if (a[property] < b[property]) { + return 1; + } + if (a[property] > b[property]) { + return -1; + } + return 0; + } +} + /** * This function removes bids of same category. It will be used when competitive exclusion is enabled. * @param {Array[Object]} bidsReceived diff --git a/modules/adprimeBidAdapter.js b/modules/adprimeBidAdapter.js index d64874c393e..55ee1f0900c 100644 --- a/modules/adprimeBidAdapter.js +++ b/modules/adprimeBidAdapter.js @@ -2,6 +2,8 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { isFn, deepAccess, logMessage } from '../src/utils.js'; import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; const BIDDER_CODE = 'adprime'; const AD_URL = 'https://delta.adprime.com/pbjs'; @@ -50,10 +52,14 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page) winTop = window.top; } catch (e) { location = winTop.location; @@ -123,7 +129,7 @@ export const spec = { wPlayer: sizes ? sizes[0] : 0, hPlayer: sizes ? sizes[1] : 0, schain: bid.schain || {}, - keywords: bid.params.keywords || [], + keywords: getAllOrtbKeywords(bidderRequest.ortb2, bid.params.keywords), audiences: bid.params.audiences || [], identeties, bidFloor: getBidFloor(bid) diff --git a/modules/adqueryBidAdapter.js b/modules/adqueryBidAdapter.js index 348bdc90808..0f445fdfd78 100644 --- a/modules/adqueryBidAdapter.js +++ b/modules/adqueryBidAdapter.js @@ -1,7 +1,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; -import { logInfo, buildUrl, triggerPixel } from '../src/utils.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {buildUrl, logInfo, parseSizesInput, triggerPixel} from '../src/utils.js'; const ADQUERY_GVLID = 902; const ADQUERY_BIDDER_CODE = 'adquery'; @@ -11,7 +10,6 @@ const ADQUERY_USER_SYNC_DOMAIN = ADQUERY_BIDDER_DOMAIN_PROTOCOL + '://' + ADQUER const ADQUERY_DEFAULT_CURRENCY = 'PLN'; const ADQUERY_NET_REVENUE = true; const ADQUERY_TTL = 360; -const storage = getStorageManager({gvlid: ADQUERY_GVLID, bidderCode: ADQUERY_BIDDER_CODE}); /** @type {BidderSpec} */ export const spec = { @@ -24,7 +22,7 @@ export const spec = { * @return {boolean} */ isBidRequestValid: (bid) => { - return !!(bid && bid.params && bid.params.placementId) + return !!(bid && bid.params && bid.params.placementId && bid.mediaTypes.banner.sizes) }, /** @@ -118,8 +116,12 @@ export const spec = { */ onBidWon: (bid) => { logInfo('onBidWon', bid); + const bidString = JSON.stringify(bid); - const encodedBuf = window.btoa(bidString); + let copyOfBid = JSON.parse(bidString); + delete copyOfBid.ad; + const shortBidString = JSON.stringify(bid); + const encodedBuf = window.btoa(shortBidString); let params = { q: encodedBuf, @@ -175,29 +177,48 @@ export const spec = { url: syncUrl }]; } - }; + function buildRequest(validBidRequests, bidderRequest) { - let qid = Math.random().toString(36).substring(2) + Date.now().toString(36); let bid = validBidRequests; + logInfo('buildRequest: ', bid); + + let userId = null; + if (window.qid) { + userId = window.qid; + } + + if (bid.userId && bid.userId.qid) { + userId = bid.userId.qid + } + + if (!userId) { + // onetime User ID + const ramdomValues = Array.from(window.crypto.getRandomValues(new Uint32Array(4))); + userId = ramdomValues.map(val => val.toString(36)).join('').substring(0, 20); + logInfo('generated onetime User ID: ', userId); + window.qid = userId; + } - if (storage.getDataFromLocalStorage('qid')) { - qid = storage.getDataFromLocalStorage('qid'); - } else { - storage.setDataInLocalStorage('qid', qid); + let pageUrl = ''; + if (bidderRequest && bidderRequest.refererInfo) { + pageUrl = bidderRequest.refererInfo.page || ''; } return { + v: '$prebid.version$', placementCode: bid.params.placementId, - auctionId: bid.auctionId, - qid: qid, + auctionId: null, type: bid.params.type, adUnitCode: bid.adUnitCode, + bidQid: userId, bidId: bid.bidId, bidder: bid.bidder, + bidPageUrl: pageUrl, bidderRequestId: bid.bidderRequestId, bidRequestsCount: bid.bidRequestsCount, bidderRequestsCount: bid.bidderRequestsCount, + sizes: parseSizesInput(bid.mediaTypes.banner.sizes).toString(), }; } diff --git a/modules/adqueryIdSystem.js b/modules/adqueryIdSystem.js index 85421bf588d..c5d01d7fbed 100644 --- a/modules/adqueryIdSystem.js +++ b/modules/adqueryIdSystem.js @@ -8,12 +8,13 @@ import {ajax} from '../src/ajax.js'; import {getStorageManager} from '../src/storageManager.js'; import {submodule} from '../src/hook.js'; -import * as utils from '../src/utils.js'; +import {isFn, isPlainObject, isStr, logError, logInfo} from '../src/utils.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'qid'; const AU_GVLID = 902; -export const storage = getStorageManager({gvlid: AU_GVLID, moduleName: 'qid'}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: 'qid'}); /** * Param or default. @@ -21,9 +22,9 @@ export const storage = getStorageManager({gvlid: AU_GVLID, moduleName: 'qid'}); * @param {String} defaultVal */ function paramOrDefault(param, defaultVal, arg) { - if (utils.isFn(param)) { + if (isFn(param)) { return param(arg); - } else if (utils.isStr(param)) { + } else if (isStr(param)) { return param; } return defaultVal; @@ -50,11 +51,7 @@ export const adqueryIdSubmodule = { * @returns {{qid:Object}} */ decode(value) { - let qid = storage.getDataFromLocalStorage('qid'); - if (utils.isStr(qid)) { - return {qid: qid}; - } - return (value && typeof value['qid'] === 'string') ? { 'qid': value['qid'] } : undefined; + return {qid: value} }, /** * performs action to obtain id and return a value in the callback's response argument @@ -63,40 +60,59 @@ export const adqueryIdSubmodule = { * @returns {IdResponse|undefined} */ getId(config) { - if (!utils.isPlainObject(config.params)) { + logInfo('adqueryIdSubmodule getId'); + if (!isPlainObject(config.params)) { config.params = {}; } - const url = paramOrDefault(config.params.url, + + const url = paramOrDefault( + config.params.url, `https://bidder.adquery.io/prebid/qid`, - config.params.urlArg); + config.params.urlArg + ); const resp = function (callback) { - let qid = storage.getDataFromLocalStorage('qid'); - if (utils.isStr(qid)) { - const responseObj = {qid: qid}; - callback(responseObj); - } else { - const callbacks = { - success: response => { - let responseObj; - if (response) { - try { - responseObj = JSON.parse(response); - } catch (error) { - utils.logError(error); - } + let qid = window.qid; + + if (!qid) { + const ramdomValues = Array.from(window.crypto.getRandomValues(new Uint32Array(4))); + qid = ramdomValues.map(val => val.toString(36)).join('').substring(0, 20); + + logInfo('adqueryIdSubmodule ID QID GENERTAED:', qid); + } + logInfo('adqueryIdSubmodule ID QID:', qid); + + const callbacks = { + success: response => { + let responseObj; + if (response) { + try { + responseObj = JSON.parse(response); + } catch (error) { + logError(error); } - callback(responseObj); - }, - error: error => { - utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error); - callback(); } - }; - ajax(url, callbacks, undefined, {method: 'GET'}); - } + if (responseObj.qid) { + let myQid = responseObj.qid; + storage.setDataInLocalStorage('qid', myQid); + return callback(myQid); + } + callback(); + }, + error: error => { + logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + callback(); + } + }; + ajax(url + '?qid=' + qid, callbacks, undefined, {method: 'GET'}); }; return {callback: resp}; + }, + eids: { + 'qid': { + source: 'adquery.io', + atype: 1 + }, } }; diff --git a/modules/adrelevantisBidAdapter.js b/modules/adrelevantisBidAdapter.js index 3d4de7c7b9d..3c9c661b09c 100644 --- a/modules/adrelevantisBidAdapter.js +++ b/modules/adrelevantisBidAdapter.js @@ -1,8 +1,5 @@ import {Renderer} from '../src/Renderer.js'; import { - chunk, - convertCamelToUnderscore, - convertTypes, createTrackPixelHtml, deepAccess, deepClone, @@ -13,14 +10,18 @@ import { isStr, logError, logMessage, - logWarn, - transformBidderParamKeywords + logWarn } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {find, includes} from '../src/polyfill.js'; import {INSTREAM, OUTSTREAM} from '../src/video.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import {getANKeywordParam, transformBidderParamKeywords} from '../libraries/appnexusUtils/anKeywords.js'; +import {convertCamelToUnderscore} from '../libraries/appnexusUtils/anUtils.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; +import {chunk} from '../libraries/chunk/chunk.js'; const BIDDER_CODE = 'adrelevantis'; const URL = 'https://ssp.adrelevantis.com/prebid'; @@ -71,6 +72,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + const tags = bidRequests.map(bidToTag); const userObjBid = find(bidRequests, hasUserInfo); let userObj; @@ -127,7 +131,8 @@ export const spec = { if (bidderRequest && bidderRequest.refererInfo) { let refererinfo = { - rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer), + // TODO: this sends everything it finds to the backend, except for canonicalUrl + rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation), rd_top: bidderRequest.refererInfo.reachedTop, rd_ifs: bidderRequest.refererInfo.numIframes, rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') @@ -135,13 +140,12 @@ export const spec = { payload.referrer_detection = refererinfo; } - let fpdcfg = config.getLegacyFpd(config.getConfig('ortb2')); - if (fpdcfg && fpdcfg.context) { - let fdata = { - keywords: fpdcfg.context.keywords || '', - category: fpdcfg.context.data.category || '' + const ortb2Site = bidderRequest.ortb2?.site; + if (ortb2Site) { + payload.fpd = { + keywords: ortb2Site.keywords || '', + category: deepAccess(ortb2Site, 'ext.data.category') || '' } - payload.fpd = fdata; } const request = formatRequest(payload, bidderRequest); @@ -190,10 +194,6 @@ export const spec = { params.use_pmt_rule = (typeof params.usePaymentRule === 'boolean') ? params.usePaymentRule : false; if (params.usePaymentRule) { delete params.usePaymentRule; } - if (isPopulatedArray(params.keywords)) { - params.keywords.forEach(deleteValues); - } - Object.keys(params).forEach(paramKey => { let convertedKey = convertCamelToUnderscore(paramKey); if (convertedKey !== paramKey) { @@ -205,17 +205,7 @@ export const spec = { return params; } -} - -function isPopulatedArray(arr) { - return !!(isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} +}; function formatRequest(payload, bidderRequest) { let request = []; @@ -440,11 +430,18 @@ function bidToTag(bid) { tag.cpm = bid.params.cpm; } tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false + tag.use_pmt_rule = bid.params.usePaymentRule || false; tag.prebid = true; tag.disable_psa = true; if (bid.params.position) { tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; + } else { + let mediaTypePos = deepAccess(bid, `mediaTypes.banner.pos`) || deepAccess(bid, `mediaTypes.video.pos`); + // only support unknown, atf, and btf values for position at this time + if (mediaTypePos === 0 || mediaTypePos === 1 || mediaTypePos === 3) { + // ortb spec treats btf === 3, but our system interprets btf === 2; so converting the ortb value here for consistency + tag.position = (mediaTypePos === 3) ? 2 : mediaTypePos; + } } if (bid.params.trafficSourceCode) { tag.traffic_source_code = bid.params.trafficSourceCode; @@ -464,14 +461,7 @@ function bidToTag(bid) { if (bid.params.externalImpId) { tag.external_imp_id = bid.params.externalImpId; } - if (!isEmpty(bid.params.keywords)) { - let keywords = transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - tag.keywords = keywords; - } + tag.keywords = getANKeywordParam(bid.ortb2, bid.params.keywords) if (bid.params.category) { tag.category = bid.params.category; } @@ -607,6 +597,8 @@ function parseMediaType(rtbBid) { const adType = rtbBid.ad_type; if (adType === VIDEO) { return VIDEO; + } else if (adType === NATIVE) { + return NATIVE; } else { return BANNER; } diff --git a/modules/adrinoBidAdapter.js b/modules/adrinoBidAdapter.js index 4520066c3e7..f5ae09934e3 100644 --- a/modules/adrinoBidAdapter.js +++ b/modules/adrinoBidAdapter.js @@ -1,6 +1,8 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {triggerPixel} from '../src/utils.js'; -import {NATIVE} from '../src/mediaTypes.js'; +import {NATIVE, BANNER} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'adrino'; const REQUEST_METHOD = 'POST'; @@ -10,7 +12,11 @@ const GVLID = 1072; export const spec = { code: BIDDER_CODE, gvlid: GVLID, - supportedMediaTypes: [NATIVE], + supportedMediaTypes: [NATIVE, BANNER], + + getBidderConfig: function (property) { + return config.getConfig(`${BIDDER_CODE}.${property}`); + }, isBidRequestValid: function (bid) { return !!(bid.bidId) && @@ -18,22 +24,33 @@ export const spec = { !!(bid.params.hash) && (typeof bid.params.hash === 'string') && !!(bid.mediaTypes) && - Object.keys(bid.mediaTypes).includes(NATIVE) && + (Object.keys(bid.mediaTypes).includes(NATIVE) || Object.keys(bid.mediaTypes).includes(BANNER)) && (bid.bidder === BIDDER_CODE); }, buildRequests: function (validBidRequests, bidderRequest) { - const bidRequests = []; + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let bids = []; for (let i = 0; i < validBidRequests.length; i++) { let requestData = { + adUnitCode: validBidRequests[i].adUnitCode, bidId: validBidRequests[i].bidId, - nativeParams: validBidRequests[i].nativeParams, placementHash: validBidRequests[i].params.hash, - referer: bidderRequest.refererInfo.referer, + userId: validBidRequests[i].userId, + referer: bidderRequest.refererInfo.page, userAgent: navigator.userAgent, } + if (validBidRequests[i].sizes != null && validBidRequests[i].sizes.length > 0) { + requestData.bannerParams = { sizes: validBidRequests[i].sizes }; + } + + if (validBidRequests[i].nativeParams != null) { + requestData.nativeParams = validBidRequests[i].nativeParams; + } + if (bidderRequest && bidderRequest.gdprConsent) { requestData.gdprConsent = { consentString: bidderRequest.gdprConsent.consentString, @@ -41,32 +58,43 @@ export const spec = { } } - bidRequests.push({ - method: REQUEST_METHOD, - url: BIDDER_HOST + '/bidder/bid/', - data: requestData, - options: { - contentType: 'application/json', - withCredentials: false, - } - }); + bids.push(requestData); } + let host = this.getBidderConfig('host') || BIDDER_HOST; + let bidRequests = []; + bidRequests.push({ + method: REQUEST_METHOD, + url: host + '/bidder/bids/', + data: bids, + options: { + contentType: 'application/json', + withCredentials: false, + } + }); + return bidRequests; }, interpretResponse: function (serverResponse, bidRequest) { const response = serverResponse.body; - const bidResponses = []; - if (!response.noAd) { - bidResponses.push(response); + const output = []; + + if (response.bidResponses) { + for (const bidResponse of response.bidResponses) { + if (!bidResponse.noAd) { + output.push(bidResponse); + } + } } - return bidResponses; + + return output; }, onBidWon: function (bid) { if (bid['requestId']) { - triggerPixel(BIDDER_HOST + '/bidder/won/' + bid['requestId']); + let host = this.getBidderConfig('host') || BIDDER_HOST; + triggerPixel(host + '/bidder/won/' + bid['requestId']); } } }; diff --git a/modules/adrinoBidAdapter.md b/modules/adrinoBidAdapter.md index 5ec63a72736..ab655f700fc 100644 --- a/modules/adrinoBidAdapter.md +++ b/modules/adrinoBidAdapter.md @@ -13,6 +13,12 @@ Module connects to Adrino bidder to fetch bids. Only native format is supported. # Test Parameters ``` +pbjs.setConfig({ + adrino: { + host: 'https://custom-domain.adrino.io' + } +}); + var adUnits = [ code: '/12345678/prebid_native_example_1', mediaTypes: { diff --git a/modules/adriverBidAdapter.js b/modules/adriverBidAdapter.js index 5ab417520e9..5bce315f572 100644 --- a/modules/adriverBidAdapter.js +++ b/modules/adriverBidAdapter.js @@ -1,6 +1,6 @@ // ADRIVER BID ADAPTER for Prebid 1.13 -import { logInfo, getWindowLocation, getBidIdParameter, _each } from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {logInfo, getWindowLocation, _each, getBidIdParameter} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'adriver'; @@ -22,8 +22,6 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { - logInfo('validBidRequests', validBidRequests); - let win = getWindowLocation(); let customID = Math.round(Math.random() * 999999999) + '-' + Math.round(new Date() / 1000) + '-1-46-'; let siteId = getBidIdParameter('siteid', validBidRequests[0].params) + ''; @@ -32,7 +30,7 @@ export const spec = { let timeout = null; if (bidderRequest) { - timeout = bidderRequest.timeout + timeout = bidderRequest.timeout; } const payload = { @@ -99,21 +97,16 @@ export const spec = { }); }); - let userid = validBidRequests[0].userId; - let adrcidCookie = storage.getDataFromLocalStorage('adrcid') || validBidRequests[0].userId.adrcid; - + let adrcidCookie = storage.getDataFromLocalStorage('adrcid') || validBidRequests[0].userId?.adrcid; if (adrcidCookie) { - payload.adrcid = adrcidCookie; - payload.id5 = userid.id5id; - payload.sharedid = userid.pubcid; - payload.unifiedid = userid.tdid; + payload.user.buyerid = adrcidCookie; } const payloadString = JSON.stringify(payload); return { method: 'POST', url: ADRIVER_BID_URL, - data: payloadString, + data: payloadString }; }, diff --git a/modules/adriverIdSystem.js b/modules/adriverIdSystem.js index 6a492fac508..c04ebf48028 100644 --- a/modules/adriverIdSystem.js +++ b/modules/adriverIdSystem.js @@ -8,11 +8,12 @@ import { logError, isPlainObject } from '../src/utils.js' import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'adriverId'; -export const storage = getStorageManager(); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); /** @type {Submodule} */ export const adriverIdSubmodule = { @@ -41,7 +42,7 @@ export const adriverIdSubmodule = { if (!isPlainObject(config.params)) { config.params = {}; } - const url = 'https://ad.adriver.ru/cgi-bin/json.cgi?sid=1&ad=719473&bt=55&pid=3198680&bid=7189165&bn=7189165&tuid=1'; + const url = 'https://ad.adriver.ru/cgi-bin/json.cgi?sid=1&ad=719473&bt=55&pid=3198680&bid=7189165&bn=7189165&tuid=1&cfa=1'; const resp = function (callback) { let creationDate = storage.getDataFromLocalStorage('adrcid_cd') || storage.getCookie('adrcid_cd'); let cookie = storage.getDataFromLocalStorage('adrcid') || storage.getCookie('adrcid'); @@ -73,7 +74,8 @@ export const adriverIdSubmodule = { callback(); } }; - ajax(url, callbacks, undefined, {method: 'GET'}); + let newUrl = url + '&cid=' + (storage.getDataFromLocalStorage('adrcid') || storage.getCookie('adrcid')); + ajax(newUrl, callbacks, undefined, {method: 'GET'}); } }; return {callback: resp}; diff --git a/modules/adsinteractiveBidAdapter.js b/modules/adsinteractiveBidAdapter.js new file mode 100644 index 00000000000..ad6bdfeb299 --- /dev/null +++ b/modules/adsinteractiveBidAdapter.js @@ -0,0 +1,146 @@ +import { + deepAccess, +} from '../src/utils.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; + +const ADSINTERACTIVE_CODE = 'adsinteractive'; +const USER_SYNC_URL_IMAGE = 'https://sync.adsinteractive.com/img'; +const USER_SYNC_URL_IFRAME = 'https://sync.adsinteractive.com/sync'; +const GVLID = 1212; + +export const spec = { + code: ADSINTERACTIVE_CODE, + supportedMediaTypes: [BANNER], + gvlid: GVLID, + + isBidRequestValid: (bid) => { + return ( + !!bid.params.adUnit && !!bid.bidId && bid.bidder === 'adsinteractive' + ); + }, + + buildRequests: (bidRequests, bidderRequest) => { + return bidRequests.map((bid) => { + var gdprConsent; + if (bidderRequest && bidderRequest.gdprConsent) { + gdprConsent = { + consent_string: bidderRequest.gdprConsent.consentString, + consent_required: bidderRequest.gdprConsent.gdprApplies, + }; + + if ( + bidderRequest.gdprConsent.addtlConsent && + bidderRequest.gdprConsent.addtlConsent.indexOf('~') !== -1 + ) { + let ac = bidderRequest.gdprConsent.addtlConsent; + let acStr = ac.substring(ac.indexOf('~') + 1); + gdprConsent.addtl_consent = acStr + .split('.') + .map((id) => parseInt(id, 10)); + } + } + + let url = 'https://pb.adsinteractive.com/prebid'; + const data = { + id: bid.bidId, + at: 1, + source: { fd: 0 }, + gdprConsent: gdprConsent, + site: { + page: bid.ortb2.site.page, + keywords: bid.ortb2.site.keywords, + domain: bid.ortb2.site.domain, + publisher: { + domain: bid.ortb2.site.domain, + }, + ext: { + amp: Number(bidderRequest.refererInfo.isAmp), + }, + }, + regs: bid.ortb2.regs, + device: bid.ortb2.device, + user: bid.ortb2.user, + imp: [ + { + id: bid.params.adUnit, + banner: { + format: bid.sizes.map((size) => ({ + w: size[0], + h: size[1], + })), + }, + ext: { + bidder: { + adUnit: bid.params.adUnit, + }, + }, + }, + ], + tmax: bidderRequest.timeout, + }; + const options = { + withCredentials: true, + }; + return { + method: 'POST', + url, + data, + options, + }; + }); + }, + + interpretResponse: (serverResponse, bidRequest) => { + let answer = []; + if (serverResponse && serverResponse.body && serverResponse.body.seatbid) { + serverResponse.body.seatbid.forEach((seatbid) => { + if (seatbid.bid.length) { + answer = [ + ...answer, + ...seatbid.bid + .filter((bid) => bid.price > 0) + .map((adsinteractiveBid) => { + const bid = { + id: adsinteractiveBid.id, + requestId: bidRequest.data.id, + cpm: adsinteractiveBid.price, + netRevenue: true, + ttl: 1000, + ad: adsinteractiveBid.adm, + meta: {advertiserDomains: adsinteractiveBid && adsinteractiveBid.adomain ? adsinteractiveBid.adomain : []}, + width: adsinteractiveBid.w, + height: adsinteractiveBid.h, + currency: serverResponse.body.cur || 'USD', + creativeId: adsinteractiveBid.crid || 0, + }; + return bid; + }), + ]; + } + }); + } + return answer; + }, + getUserSyncs: (syncOptions, serverResponse, gdprConsent, uspConsent) => { + if (syncOptions.iframeEnabled) { + const auid = serverResponse.filter(resp => deepAccess(resp, 'body.ext.auid')) + .map(resp => resp.body.ext.auid); + return [ + { + type: 'iframe', + url: USER_SYNC_URL_IFRAME + '?consent=' + gdprConsent.consentString + '&auid=' + auid, + }, + ]; + } else { + return [ + { + type: 'image', + url: USER_SYNC_URL_IMAGE, + }, + ]; + } + }, +}; +registerBidder(spec); diff --git a/modules/taphypeBidAdapter.md b/modules/adsinteractiveBidAdapter.md similarity index 50% rename from modules/taphypeBidAdapter.md rename to modules/adsinteractiveBidAdapter.md index c6ff40a42ba..81afcd18200 100644 --- a/modules/taphypeBidAdapter.md +++ b/modules/adsinteractiveBidAdapter.md @@ -1,32 +1,31 @@ # Overview -Module Name: TapHype Bidder Adapter +Module Name: AdsInteractive Bidder Adapter + Module Type: Bidder Adapter -Maintainer: admin@taphype.com + +Maintainer: it@adsinteractive.com # Description -You can use this adapter to get a bid from taphype.com. +You can use this adapter to get a bid from adsinteractive.com. + +About us : https://www.adsinteractive.com # Test Parameters ```javascript var adUnits = [ { - code: 'div-taphype-example', sizes: [[300, 250]], bids: [ { - bidder: "taphype", + bidder: "adsinteractive", params: { - placementId: 12345 + adUnit: "example_adunit_1" } } ] } ]; ``` - -Where: - -* placementId - TapHype Placement ID diff --git a/modules/adspendBidAdapter.md b/modules/adspendBidAdapter.md deleted file mode 100644 index dc3409b0057..00000000000 --- a/modules/adspendBidAdapter.md +++ /dev/null @@ -1,60 +0,0 @@ -# Overview - -``` -Module Name: AdSpend Bidder Adapter -Module Type: Bidder Adapter -Maintainer: gaffoonster@gmail.com -``` - -# Description - -Connects to AdSpend bidder. -AdSpend adapter supports only Banner at the moment. Video and Native will be add soon. - -# Test Parameters -``` -var adUnits = [ - // Banner - { - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - // You can choose one of them - sizes: [ - [300, 250], - [300, 600], - [240, 400], - [728, 90], - ] - } - }, - bids: [ - { - bidder: "adspend", - params: { - bidfloor: 1, - placement: 'test', - tagId: 'test-ad', - } - } - ] - } -]; - -pbjs.que.push(() => { - pbjs.setConfig({ - userSync: { - syncEnabled: true, - enabledBidders: ['adspend'], - pixelEnabled: true, - syncsPerBidder: 200, - syncDelay: 100, - }, - currency: { - adServerCurrency: 'RUB' // We work only with rubles for now - } - }); -}); -``` - -**It's a test banner, so you'll see some errors in console cause it will be trying to call our system's events.** diff --git a/modules/adspiritBidAdapter.md b/modules/adspiritBidAdapter.md deleted file mode 100644 index 688d0814882..00000000000 --- a/modules/adspiritBidAdapter.md +++ /dev/null @@ -1,28 +0,0 @@ -# Overview - -**Module Name**: AdSpirit Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: prebid@adspirit.de - -# Description - -Module that connects to an AdSpirit zone to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'display-div', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: "adspirit", - params: { - placementId: '5', - host: 'n1test.adspirit.de' - } - } - ] - } - ]; -``` diff --git a/modules/adtargetBidAdapter.js b/modules/adtargetBidAdapter.js index a07b0de0f67..a1dec5a420f 100644 --- a/modules/adtargetBidAdapter.js +++ b/modules/adtargetBidAdapter.js @@ -1,8 +1,9 @@ -import {_map, chunk, deepAccess, flatten, isArray, logError, parseSizesInput} from '../src/utils.js'; +import {_map, deepAccess, flatten, isArray, logError, parseSizesInput} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {find} from '../src/polyfill.js'; +import {chunk} from '../libraries/chunk/chunk.js'; const ENDPOINT = 'https://ghb.console.adtarget.com.tr/v2/auction/'; const BIDDER_CODE = 'adtarget'; @@ -117,7 +118,8 @@ function parseResponse(serverResponse, adapterRequest) { function bidToTag(bidRequests, adapterRequest) { const tag = { - Domain: deepAccess(adapterRequest, 'refererInfo.referer') + // TODO: is 'page' the right value here? + Domain: deepAccess(adapterRequest, 'refererInfo.page') }; if (config.getConfig('coppa') === true) { tag.Coppa = 1; @@ -136,7 +138,7 @@ function bidToTag(bidRequests, adapterRequest) { tag.UserIds = deepAccess(bidRequests[0], 'userId'); } - const bids = [] + const bids = []; for (let i = 0, length = bidRequests.length; i < length; i++) { const bid = prepareBidRequests(bidRequests[i]); diff --git a/modules/adtelligentBidAdapter.js b/modules/adtelligentBidAdapter.js index d8638c4da47..04bca21c60f 100644 --- a/modules/adtelligentBidAdapter.js +++ b/modules/adtelligentBidAdapter.js @@ -1,9 +1,11 @@ -import {_map, chunk, convertTypes, deepAccess, flatten, isArray, parseSizesInput} from '../src/utils.js'; +import {_map, deepAccess, flatten, isArray, parseSizesInput} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {ADPOD, BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {Renderer} from '../src/Renderer.js'; import {find} from '../src/polyfill.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; +import {chunk} from '../libraries/chunk/chunk.js'; const subdomainSuffixes = ['', 1, 2]; const AUCTION_PATH = '/v2/auction/'; @@ -15,12 +17,11 @@ const HOST_GETTERS = { return 'ghb' + subdomainSuffixes[num++ % subdomainSuffixes.length] + '.adtelligent.com'; } }()), - navelix: () => 'ghb.hb.navelix.com', - appaloosa: () => 'ghb.hb.appaloosa.media', - onefiftytwomedia: () => 'ghb.ads.152media.com', - bidsxchange: () => 'ghb.hbd.bidsxchange.com', streamkey: () => 'ghb.hb.streamkey.net', janet: () => 'ghb.bidder.jmgads.com', + ocm: () => 'ghb.cenarius.orangeclickmedia.com', + '9dotsmedia': () => 'ghb.platform.audiodots.com', + copper6: () => 'ghb.app.copper6.com' } const getUri = function (bidderCode) { let bidderWithoutSuffix = bidderCode.split('_')[0]; @@ -36,8 +37,13 @@ const syncsCache = {}; export const spec = { code: BIDDER_CODE, gvlid: 410, - aliases: ['onefiftytwomedia', 'selectmedia', 'appaloosa', 'bidsxchange', 'streamkey', 'janet', - { code: 'navelix', gvlid: 380 } + aliases: [ + 'streamkey', + 'janet', + { code: 'selectmedia', gvlid: 775 }, + { code: 'ocm', gvlid: 1148 }, + '9dotsmedia', + 'copper6', ], supportedMediaTypes: [VIDEO, BANNER], isBidRequestValid: function (bid) { @@ -158,7 +164,8 @@ function parseRTBResponse(serverResponse, adapterRequest) { function bidToTag(bidRequests, adapterRequest) { // start publisher env const tag = { - Domain: deepAccess(adapterRequest, 'refererInfo.referer') + // TODO: is 'page' the right value here? + Domain: deepAccess(adapterRequest, 'refererInfo.page') }; if (config.getConfig('coppa') === true) { tag.Coppa = 1; @@ -183,8 +190,16 @@ function bidToTag(bidRequests, adapterRequest) { tag.DMPId = window.adtDmp.getUID(); } + if (adapterRequest.gppConsent) { + tag.GPP = adapterRequest.gppConsent.gppString; + tag.GPPSid = adapterRequest.gppConsent.applicableSections?.toString(); + } else if (adapterRequest.ortb2?.regs?.gpp) { + tag.GPP = adapterRequest.ortb2.regs.gpp; + tag.GPPSid = adapterRequest.ortb2.regs.gpp_sid; + } + // end publisher env - const bids = [] + const bids = []; for (let i = 0, length = bidRequests.length; i < length; i++) { const bid = prepareBidRequests(bidRequests[i]); diff --git a/modules/adtelligentIdSystem.js b/modules/adtelligentIdSystem.js index fb3b5f6fe2a..440ed9ade75 100644 --- a/modules/adtelligentIdSystem.js +++ b/modules/adtelligentIdSystem.js @@ -85,6 +85,12 @@ export const adtelligentIdModule = { } } + }, + eids: { + 'adtelligentId': { + source: 'adtelligent.com', + atype: 3 + }, } }; diff --git a/modules/adtrgtmeBidAdapter.js b/modules/adtrgtmeBidAdapter.js new file mode 100644 index 00000000000..4dc95ce6bc1 --- /dev/null +++ b/modules/adtrgtmeBidAdapter.js @@ -0,0 +1,333 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { deepAccess, isFn, isStr, isNumber, isArray, isEmpty, isPlainObject, generateUUID, logWarn } from '../src/utils.js'; +import { config } from '../src/config.js'; +import { hasPurpose1Consent } from '../src/utils/gpdr.js'; + +const INTEGRATION_METHOD = 'prebid.js'; +const BIDDER_CODE = 'adtrgtme'; +const ENDPOINT = 'https://z.cdn.adtarget.market/ssp?prebid&s='; +const ADAPTER_VERSION = '1.0.0'; +const PREBID_VERSION = '$prebid.version$'; +const DEFAULT_BID_TTL = 300; +const DEFAULT_CURRENCY = 'USD'; + +function transformSizes(sizes) { + const getSize = (size) => { + return { + w: parseInt(size[0]), + h: parseInt(size[1]) + } + } + if (isArray(sizes) && sizes.length === 2 && !isArray(sizes[0])) { + return [ getSize(sizes) ]; + } + return sizes.map(getSize); +} + +function extractUserSyncUrls(syncOptions, pixels) { + let itemsRegExp = /(img|iframe)[\s\S]*?src\s*=\s*("|')(.*?)\2/gi; + let tagNameRegExp = /\w*(?=\s)/; + let srcRegExp = /src=("|')(.*?)\1/; + let userSyncObjects = []; + + if (pixels) { + let matchedItems = pixels.match(itemsRegExp); + if (matchedItems) { + matchedItems.forEach(item => { + let tagName = item.match(tagNameRegExp)[0]; + let url = item.match(srcRegExp)[2]; + if (tagName && url) { + let tagType = tagName.toLowerCase() === 'img' ? 'image' : 'iframe'; + if ((!syncOptions.iframeEnabled && tagType === 'iframe') || + (!syncOptions.pixelEnabled && tagType === 'image')) { + return; + } + userSyncObjects.push({ + type: tagType, + url: url + }); + } + }); + } + } + return userSyncObjects; +} + +function isSecure(bid) { + return deepAccess(bid, 'params.bidOverride.imp.secure') || (document.location.protocol === 'https:') ? 1 : 0; +}; + +function getMediaType(bid) { + return deepAccess(bid, 'mediaTypes.banner') ? BANNER : false; +} + +function validateAppendObject(validationFunction, allowedKeys, inputObject, appendToObject) { + const outputObject = { + ...appendToObject + }; + if (allowedKeys.length > 0 && typeof validationFunction === 'function') { + for (const objectKey in inputObject) { + if (allowedKeys.indexOf(objectKey) !== -1 && validationFunction(inputObject[objectKey])) { + outputObject[objectKey] = inputObject[objectKey] + } + } + } + return outputObject; +}; + +function getTtl(bidderRequest) { + const ttl = config.getConfig('adtrgtme.ttl'); + const validateTTL = (ttl) => { + return (isNumber(ttl) && ttl > 0 && ttl < 3600) ? ttl : DEFAULT_BID_TTL + }; + return ttl ? validateTTL(ttl) : validateTTL(deepAccess(bidderRequest, 'params.ttl')); +}; + +function getFloorModuleData(bid) { + const getFloorRequestObject = { + currency: deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY, + mediaType: BANNER, + size: '*' + }; + return (isFn(bid.getFloor)) ? bid.getFloor(getFloorRequestObject) : false; +}; + +function generateOpenRtbObject(bidderRequest, bid) { + if (bidderRequest) { + let outBoundBidRequest = { + id: generateUUID(), + cur: [getFloorModuleData(bidderRequest).currency || deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY], + imp: [], + site: { + page: deepAccess(bidderRequest, 'refererInfo.page') + }, + device: { + dnt: 0, + ua: navigator.userAgent, + ip: deepAccess(bid, 'params.bidOverride.device.ip') || deepAccess(bid, 'params.ext.ip') || undefined + }, + regs: { + ext: { + 'us_privacy': bidderRequest.uspConsent ? bidderRequest.uspConsent : '', + gdpr: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? 1 : 0 + } + }, + source: { + ext: { + hb: 1, + adapterver: ADAPTER_VERSION, + prebidver: PREBID_VERSION, + integration: { + name: INTEGRATION_METHOD, + ver: PREBID_VERSION + } + }, + fd: 1 + }, + user: { + ext: { + consent: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies + ? bidderRequest.gdprConsent.consentString : '' + } + } + }; + + outBoundBidRequest.site.id = bid.params.sid; + + if (bidderRequest.ortb2) { + outBoundBidRequest = appendFirstPartyData(outBoundBidRequest, bid); + }; + + if (deepAccess(bid, 'schain')) { + outBoundBidRequest.source.ext.schain = bid.schain; + outBoundBidRequest.source.ext.schain.nodes[0].rid = outBoundBidRequest.id; + }; + + return outBoundBidRequest; + }; +}; + +function appendImpObject(bid, openRtbObject) { + const mediaTypeMode = getMediaType(bid); + + if (openRtbObject && bid) { + const impObject = { + id: bid.bidId, + secure: isSecure(bid), + bidfloor: getFloorModuleData(bid).floor || deepAccess(bid, 'params.bidOverride.imp.bidfloor') || 0.000001 + }; + + if (mediaTypeMode === BANNER) { + impObject.banner = { + mimes: bid.mediaTypes.banner.mimes || ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], + format: transformSizes(bid.sizes) + }; + if (bid.mediaTypes.banner.pos) { + impObject.banner.pos = bid.mediaTypes.banner.pos; + }; + }; + + impObject.ext = { + dfp_ad_unit_code: bid.adUnitCode + }; + + if (deepAccess(bid, 'params.zid')) { + impObject.tagid = bid.params.zid; + } + + if (deepAccess(bid, 'ortb2Imp.ext.data') && isPlainObject(bid.ortb2Imp.ext.data)) { + impObject.ext.data = bid.ortb2Imp.ext.data; + }; + + if (deepAccess(bid, 'ortb2Imp.instl') && isNumber(bid.ortb2Imp.instl) && (bid.ortb2Imp.instl === 1)) { + impObject.instl = bid.ortb2Imp.instl; + }; + + openRtbObject.imp.push(impObject); + }; +}; + +function appendFirstPartyData(outBoundBidRequest, bid) { + const ortb2Object = bid.ortb2; + const siteObject = deepAccess(ortb2Object, 'site') || undefined; + const siteContentObject = deepAccess(siteObject, 'content') || undefined; + const userObject = deepAccess(ortb2Object, 'user') || undefined; + + if (siteObject && isPlainObject(siteObject)) { + const allowedSiteStringKeys = ['name', 'domain', 'page', 'ref', 'keywords']; + const allowedSiteArrayKeys = ['cat', 'sectioncat', 'pagecat']; + const allowedSiteObjectKeys = ['ext']; + outBoundBidRequest.site = validateAppendObject(isStr, allowedSiteStringKeys, siteObject, outBoundBidRequest.site); + outBoundBidRequest.site = validateAppendObject(isArray, allowedSiteArrayKeys, siteObject, outBoundBidRequest.site); + outBoundBidRequest.site = validateAppendObject(isPlainObject, allowedSiteObjectKeys, siteObject, outBoundBidRequest.site); + }; + + if (siteContentObject && isPlainObject(siteContentObject)) { + const allowedContentStringKeys = ['id', 'title', 'language']; + const allowedContentArrayKeys = ['cat']; + outBoundBidRequest.site.content = validateAppendObject(isStr, allowedContentStringKeys, siteContentObject, outBoundBidRequest.site.content); + outBoundBidRequest.site.content = validateAppendObject(isArray, allowedContentArrayKeys, siteContentObject, outBoundBidRequest.site.content); + }; + + if (userObject && isPlainObject(userObject)) { + const allowedUserStrings = ['id', 'buyeruid', 'gender', 'keywords', 'customdata']; + const allowedUserObjects = ['ext']; + outBoundBidRequest.user = validateAppendObject(isStr, allowedUserStrings, userObject, outBoundBidRequest.user); + outBoundBidRequest.user.ext = validateAppendObject(isPlainObject, allowedUserObjects, userObject, outBoundBidRequest.user.ext); + }; + + return outBoundBidRequest; +}; + +function generateServerRequest({payload, requestOptions, bidderRequest}) { + return { + url: (config.getConfig('adtrgtme.endpoint') || ENDPOINT) + (payload.site.id || ''), + method: 'POST', + data: payload, + options: requestOptions, + bidderRequest: bidderRequest + }; +}; + +export const spec = { + code: BIDDER_CODE, + aliases: [], + supportedMediaTypes: [BANNER], + + isBidRequestValid: function(bid) { + const params = bid.params; + if (isPlainObject(params) && isNumber(params.sid)) { + return true; + } else { + logWarn('Adtrgtme bidder params missing or incorrect'); + return false; + } + }, + + buildRequests: function(validBidRequests, bidderRequest) { + if (isEmpty(validBidRequests) || isEmpty(bidderRequest)) { + logWarn('Adtrgtme Adapter: buildRequests called with empty request'); + return undefined; + }; + + const requestOptions = { + contentType: 'application/json', + customHeaders: { + 'x-openrtb-version': '2.5' + } + }; + + requestOptions.withCredentials = hasPurpose1Consent(bidderRequest.gdprConsent); + + if (config.getConfig('adtrgtme.singleRequestMode') === true) { + const payload = generateOpenRtbObject(bidderRequest, validBidRequests[0]); + validBidRequests.forEach(bid => { + appendImpObject(bid, payload); + }); + + return generateServerRequest({payload, requestOptions, bidderRequest}); + } + + return validBidRequests.map(bid => { + const payloadClone = generateOpenRtbObject(bidderRequest, bid); + appendImpObject(bid, payloadClone); + + return generateServerRequest({payload: payloadClone, requestOptions, bidderRequest: bid}); + }); + }, + + interpretResponse: function(serverResponse, { data, bidderRequest }) { + const response = []; + if (!serverResponse.body || !Array.isArray(serverResponse.body.seatbid)) { + return response; + } + + let seatbids = serverResponse.body.seatbid; + seatbids.forEach(seatbid => { + let bid; + + try { + bid = seatbid.bid[0]; + } catch (e) { + return response; + } + + let cpm = bid.price; + + let bidResponse = { + adId: deepAccess(bid, 'adId') ? bid.adId : bid.impid || bid.crid, + ad: bid.adm, + adUnitCode: bidderRequest.adUnitCode, + requestId: bid.impid, + cpm: cpm, + width: bid.w, + height: bid.h, + creativeId: bid.crid || 0, + currency: bid.cur || DEFAULT_CURRENCY, + dealId: bid.dealid ? bid.dealid : null, + netRevenue: true, + ttl: getTtl(bidderRequest), + mediaType: BANNER, + meta: { + advertiserDomains: bid.adomain, + mediaType: BANNER, + } + }; + + response.push(bidResponse); + }); + + return response; + }, + + getUserSyncs: function(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '') { + const bidResponse = !isEmpty(serverResponses) && serverResponses[0].body; + if (bidResponse && bidResponse.ext && bidResponse.ext.pixels) { + return extractUserSyncUrls(syncOptions, bidResponse.ext.pixels); + } + return []; + } +}; + +registerBidder(spec); diff --git a/modules/adtrgtmeBidAdapter.md b/modules/adtrgtmeBidAdapter.md new file mode 100644 index 00000000000..d136b17067d --- /dev/null +++ b/modules/adtrgtmeBidAdapter.md @@ -0,0 +1,69 @@ +# Overview + +**Module Name**: adtrgtme Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: info@adtarget.me + +# Description +The Adtrgtme Bid Adapter is an OpenRTB interface that support display demand from Adtarget + +# Supported Features: +* Media Types: Banner +* Multi-format adUnits +* Price floors module +* Advertiser domains + +# Mandatory Bidder Parameters +The minimal requirements for the 'adtrgtme' bid adapter to generate an outbound bid-request to our Adtrgtme are: +1. At least 1 banner adUnit +2. Your Adtrgtme site id **bidder.params**.**sid** + +## Example: +```javascript +const adUnits = [{ + code: 'your-placement', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [ + { + bidder: 'adtrgtme', + params: { + sid: 1220291391, // Site/App ID provided from SSP + } + } + ] +}]; +``` + +# Optional: Price floors module & bidfloor +The adtargerme adapter supports the Prebid.org Price Floors module and will use it to define the outbound bidfloor and currency. +By default the adapter will always check the existance of Module price floor. +If a module price floor does not exist you can set a custom bid floor for your impression using "params.bidOverride.imp.bidfloor". + +```javascript +const adUnits = [{ + code: 'your-placement', + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + bids: [{ + bidder: 'adtrgtme', + params: { + sid: 1220291391, + bidOverride :{ + imp: { + bidfloor: 5.00 // bidOverride bidfloor + } + } + } + } + }] +}]; +``` \ No newline at end of file diff --git a/modules/adtrueBidAdapter.js b/modules/adtrueBidAdapter.js index 283e1273150..389986eb586 100644 --- a/modules/adtrueBidAdapter.js +++ b/modules/adtrueBidAdapter.js @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {getStorageManager} from '../src/storageManager.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'adtrue'; const storage = getStorageManager({bidderCode: BIDDER_CODE}); @@ -44,7 +45,7 @@ const VIDEO_CUSTOM_PARAMS = { 'placement': DATA_TYPES.NUMBER, 'minbitrate': DATA_TYPES.NUMBER, 'maxbitrate': DATA_TYPES.NUMBER -} +}; const NATIVE_ASSETS = { 'TITLE': {ID: 1, KEY: 'title', TYPE: 0}, @@ -133,8 +134,9 @@ function _parseAdSlot(bid) { function _initConf(refererInfo) { return { - pageURL: (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href, - refURL: window.document.referrer + // TODO: do the fallbacks make sense here? + pageURL: refererInfo?.page || window.location.href, + refURL: refererInfo?.ref || window.document.referrer }; } @@ -449,6 +451,9 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let refererInfo; if (bidderRequest && bidderRequest.refererInfo) { refererInfo = bidderRequest.refererInfo; @@ -464,7 +469,7 @@ export const spec = { conf.zoneId = conf.zoneId || bid.params.zoneId; conf.pubId = conf.pubId || bid.params.publisherId; - conf.transactionId = bid.transactionId; + conf.transactionId = bid.ortb2Imp?.ext?.tid; if (bidCurrency === '') { bidCurrency = bid.params.currency || UNDEFINED; } else if (bid.params.hasOwnProperty('currency') && bidCurrency !== bid.params.currency) { @@ -487,7 +492,7 @@ export const spec = { payload.ext.wrapper = {}; payload.ext.wrapper.transactionId = conf.transactionId; - payload.ext.wrapper.wiid = conf.wiid || bidderRequest.auctionId; + payload.ext.wrapper.wiid = conf.wiid || bidderRequest.ortb2?.ext?.tid; payload.ext.wrapper.wp = 'pbjs'; payload.user.geo = {}; diff --git a/modules/aduptechBidAdapter.js b/modules/aduptechBidAdapter.js index 1186e0410ab..49187da2fe2 100644 --- a/modules/aduptechBidAdapter.js +++ b/modules/aduptechBidAdapter.js @@ -1,9 +1,11 @@ -import { deepAccess, getWindowTop, getWindowSelf, getAdUnitSizes } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, NATIVE } from '../src/mediaTypes.js' +import {deepClone, isArray, isBoolean, isEmpty, isFn, isPlainObject} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; export const BIDDER_CODE = 'aduptech'; +export const GVLID = 647; export const ENDPOINT_URL_PUBLISHER_PLACEHOLDER = '{PUBLISHER}'; export const ENDPOINT_URL = 'https://rtb.d.adup-tech.com/prebid/' + ENDPOINT_URL_PUBLISHER_PLACEHOLDER + '_bid'; export const ENDPOINT_METHOD = 'POST'; @@ -20,14 +22,14 @@ export const internal = { * @returns {null|Object.} */ extractGdpr: (bidderRequest) => { - if (bidderRequest && bidderRequest.gdprConsent) { - return { - consentString: bidderRequest.gdprConsent.consentString, - consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true - }; + if (!bidderRequest?.gdprConsent) { + return null; } - return null; + return { + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: (isBoolean(bidderRequest.gdprConsent.gdprApplies)) ? bidderRequest.gdprConsent.gdprApplies : true + }; }, /** @@ -37,19 +39,8 @@ export const internal = { * @returns {string} */ extractPageUrl: (bidderRequest) => { - if (bidderRequest && deepAccess(bidderRequest, 'refererInfo.canonicalUrl')) { - return bidderRequest.refererInfo.canonicalUrl; - } - - if (config && config.getConfig('pageUrl')) { - return config.getConfig('pageUrl'); - } - - try { - return getWindowTop().location.href; - } catch (e) { - return getWindowSelf().location.href; - } + // TODO: does it make sense to fall back here? + return bidderRequest?.refererInfo?.page || window.location.href; }, /** @@ -59,15 +50,8 @@ export const internal = { * @returns {string} */ extractReferrer: (bidderRequest) => { - if (bidderRequest && deepAccess(bidderRequest, 'refererInfo.referer')) { - return bidderRequest.refererInfo.referer; - } - - try { - return getWindowTop().document.referrer; - } catch (e) { - return getWindowSelf().document.referrer; - } + // TODO: does it make sense to fall back here? + return bidderRequest?.refererInfo?.ref || window.document.referrer; }, /** @@ -77,12 +61,34 @@ export const internal = { * @returns {null|Object.} */ extractBannerConfig: (bidRequest) => { - const sizes = getAdUnitSizes(bidRequest); - if (Array.isArray(sizes) && sizes.length > 0) { - return { sizes: sizes }; + const adUnitSizes = getAdUnitSizes(bidRequest); + if (!isArray(adUnitSizes) || isEmpty(adUnitSizes)) { + return null; } - return null; + const banner = { sizes: [] }; + + adUnitSizes.forEach(adUnitSize => { + const size = deepClone(adUnitSize); + + // try to add floor for each banner size + const floor = internal.getFloor(bidRequest, { mediaType: BANNER, size: adUnitSize }); + if (floor) { + size.push(floor.floor); + size.push(floor.currency); + } + + banner.sizes.push(size); + }); + + // try to add default floor for banner + const floor = internal.getFloor(bidRequest, { mediaType: BANNER, size: '*' }); + if (floor) { + banner.floorPrice = floor.floor; + banner.floorCurrency = floor.currency; + } + + return banner; }, /** @@ -92,11 +98,20 @@ export const internal = { * @returns {null|Object.} */ extractNativeConfig: (bidRequest) => { - if (bidRequest && deepAccess(bidRequest, 'mediaTypes.native')) { - return bidRequest.mediaTypes.native; + if (!bidRequest?.mediaTypes?.native) { + return null; } - return null; + const native = deepClone(bidRequest.mediaTypes.native); + + // try to add default floor for native + const floor = internal.getFloor(bidRequest, { mediaType: NATIVE, size: '*' }); + if (floor) { + native.floorPrice = floor.floor; + native.floorCurrency = floor.currency; + } + + return native; }, /** @@ -106,10 +121,32 @@ export const internal = { * @returns {null|Object.} */ extractParams: (bidRequest) => { - if (bidRequest && bidRequest.params) { - return bidRequest.params + if (!bidRequest?.params) { + return null; + } + + return deepClone(bidRequest.params); + }, + + /** + * Try to get floor information via bidRequest.getFloor() + * + * @param {BidRequest} bidRequest + * @param {Object} options + * @returns {null|Object.} + */ + getFloor: (bidRequest, options) => { + if (!isFn(bidRequest?.getFloor)) { + return null; } + try { + const floor = bidRequest.getFloor(options); + if (isPlainObject(floor) && !isNaN(floor.floor)) { + return floor; + } + } catch {} + return null; }, @@ -122,11 +159,11 @@ export const internal = { groupBidRequestsByPublisher: (bidRequests) => { const groupedBidRequests = {}; - if (!bidRequests || bidRequests.length === 0) { + if (!bidRequests || isEmpty(bidRequests)) { return groupedBidRequests; } - bidRequests.forEach((bidRequest) => { + bidRequests.forEach(bidRequest => { const publisher = internal.extractParams(bidRequest).publisher; if (!publisher) { return; @@ -159,6 +196,7 @@ export const internal = { export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, NATIVE], + gvlid: GVLID, /** * Validate given bid request @@ -193,10 +231,13 @@ export const spec = { * @returns {Object[]} */ buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const requests = []; // stop here on invalid or empty data - if (!bidderRequest || !validBidRequests || validBidRequests.length === 0) { + if (!bidderRequest || !validBidRequests || isEmpty(validBidRequests)) { return requests; } @@ -215,6 +256,7 @@ export const spec = { url: internal.buildEndpointUrl(publisher), method: ENDPOINT_METHOD, data: { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: auctionId, pageUrl: pageUrl, referrer: referrer, @@ -228,10 +270,10 @@ export const spec = { } // handle multiple bids per request - groupedBidRequests[publisher].forEach((bidRequest) => { + groupedBidRequests[publisher].forEach(bidRequest => { const bid = { bidId: bidRequest.bidId, - transactionId: bidRequest.transactionId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, adUnitCode: bidRequest.adUnitCode, params: internal.extractParams(bidRequest) }; @@ -248,6 +290,13 @@ export const spec = { bid.native = nativeConfig; } + // try to add default floor + const floor = internal.getFloor(bidRequest, { mediaType: '*', size: '*' }); + if (floor) { + bid.floorPrice = floor.floor; + bid.floorCurrency = floor.currency; + } + request.data.imp.push(bid); }); @@ -267,12 +316,12 @@ export const spec = { const bidResponses = []; // stop here on invalid or empty data - if (!response || !deepAccess(response, 'body.bids') || response.body.bids.length === 0) { + if (!response?.body?.bids || isEmpty(response.body.bids)) { return bidResponses; } // parse multiple bids per response - response.body.bids.forEach((bid) => { + response.body.bids.forEach(bid => { if (!bid || !bid.bid || !bid.creative) { return; } diff --git a/modules/advangelistsBidAdapter.js b/modules/advangelistsBidAdapter.js index 605e19cfc66..8e5be83f166 100755 --- a/modules/advangelistsBidAdapter.js +++ b/modules/advangelistsBidAdapter.js @@ -1,5 +1,4 @@ import {deepAccess, generateUUID, isEmpty, isFn, parseSizesInput, parseUrl} from '../src/utils.js'; -import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {find, includes} from '../src/polyfill.js'; @@ -59,7 +58,6 @@ export const spec = { if (isVideoBid(bidRequest)) { let bidResponse = { requestId: response.id, - bidderCode: BIDDER_CODE, cpm: response.seatbid[0].bid[0].price, width: response.seatbid[0].bid[0].w, height: response.seatbid[0].bid[0].h, @@ -200,12 +198,8 @@ function getBannerSizes(bid) { return parseSizes(deepAccess(bid, 'mediaTypes.banner.sizes') || bid.sizes); } -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } +function getTopWindowReferrer(bidderRequest) { + return bidderRequest?.refererInfo?.ref || ''; } function getVideoTargetingParams(bid) { @@ -226,7 +220,7 @@ function getVideoTargetingParams(bid) { function createVideoRequestData(bid, bidderRequest) { let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); + let topReferrer = getTopWindowReferrer(bidderRequest); let sizes = getVideoSizes(bid); let firstSize = getFirstSize(sizes); @@ -309,13 +303,12 @@ function createVideoRequestData(bid, bidderRequest) { } function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); + return parseUrl(bidderRequest?.refererInfo?.page, {decodeSearchAsString: true}); } function createBannerRequestData(bid, bidderRequest) { let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); + let topReferrer = getTopWindowReferrer(bidderRequest); let sizes = getBannerSizes(bid); let bidfloor = (getBannerBidFloor(bid) == null || typeof getBannerBidFloor(bid) == 'undefined') ? 2 : getBannerBidFloor(bid); diff --git a/modules/advenueBidAdapter.md b/modules/advenueBidAdapter.md deleted file mode 100644 index ec5287330db..00000000000 --- a/modules/advenueBidAdapter.md +++ /dev/null @@ -1,27 +0,0 @@ -# Overview - -``` -Module Name: Advenue SSP Bidder Adapter -Module Type: Bidder Adapter -Maintainer: dev.advenue@gmail.com -``` - -# Description - -Module that connects to Advenue SSP demand sources - -# Test Parameters -``` - var adUnits = [{ - code: 'placementCode', - sizes: [[300, 250]], - bids: [{ - bidder: 'advenue', - params: { - placementId: 0, - traffic: 'banner' - } - }] - } - ]; -``` diff --git a/modules/advertlyBidAdapter.md b/modules/advertlyBidAdapter.md deleted file mode 100755 index b6cc3bfe71d..00000000000 --- a/modules/advertlyBidAdapter.md +++ /dev/null @@ -1,50 +0,0 @@ -# Overview - -``` -Module Name: Advertly Bid Adapter -Module Type: Bidder Adapter -Maintainer : support@advertly.com -``` - -# Description - -Connects to Advertly Ad Server for bids. - -advertly bid adapter supports Banner and Video. - -# Test Parameters -``` - var adUnits = [ - //bannner object - { - code: 'banner-ad-slot', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [{ - bidder: 'advertly', - params: { - publisherId: 2 - } - }] - - }, - //video object - { - code: 'video-ad-slot', - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480], - }, - }, - bids: [{ - bidder: "advertly", - params: { - publisherId: 2 - } - }] - }]; -``` diff --git a/modules/adxcgAnalyticsAdapter.js b/modules/adxcgAnalyticsAdapter.js index 5cd04ce13cd..21b6c1be783 100644 --- a/modules/adxcgAnalyticsAdapter.js +++ b/modules/adxcgAnalyticsAdapter.js @@ -1,8 +1,9 @@ import { parseSizesInput, uniques, buildUrl, logError } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; +import {getGlobal} from '../src/prebidGlobal.js'; /** * Analytics adapter from adxcg.com @@ -122,7 +123,7 @@ function send (data) { ats: adxcgAnalyticsAdapter.context.auctionTimestamp, aav: adxcgAnalyticsVersion, iob: intersectionObserverAvailable(window) ? '1' : '0', - pbv: $$PREBID_GLOBAL$$.version, + pbv: getGlobal().version, sz: window.screen.width + 'x' + window.screen.height } }); diff --git a/modules/adxcgBidAdapter.js b/modules/adxcgBidAdapter.js index 81872100cd1..5930f3adb67 100644 --- a/modules/adxcgBidAdapter.js +++ b/modules/adxcgBidAdapter.js @@ -2,21 +2,22 @@ 'use strict'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {NATIVE, BANNER, VIDEO} from '../src/mediaTypes.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import { - mergeDeep, _map, deepAccess, - getDNT, - parseSizesInput, deepSetValue, - isStr, + getDNT, isArray, isPlainObject, - parseUrl, - replaceAuctionPrice, triggerPixel + isStr, + mergeDeep, + parseSizesInput, + replaceAuctionPrice, + triggerPixel } from '../src/utils.js'; import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const { getConfig } = config; @@ -65,9 +66,12 @@ export const spec = { return !!(adzoneid); }, buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let app, site; - const commonFpd = getConfig('ortb2') || {}; + const commonFpd = bidderRequest.ortb2 || {}; let { user } = commonFpd; if (typeof getConfig('app') === 'object') { @@ -82,8 +86,8 @@ export const spec = { } if (!site.page) { - site.page = bidderRequest.refererInfo.referer; - site.domain = parseUrl(bidderRequest.refererInfo.referer).hostname; + site.page = bidderRequest.refererInfo.page; + site.domain = bidderRequest.refererInfo.domain; } } @@ -94,7 +98,7 @@ export const spec = { device.dnt = getDNT() ? 1 : 0; device.language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; - const tid = validBidRequests[0].transactionId; + const tid = bidderRequest.ortb2?.source?.tid; const test = setOnAny(validBidRequests, 'params.test'); const currency = getConfig('currency.adServerCurrency'); const cur = currency && [ currency ]; diff --git a/modules/adxpremiumAnalyticsAdapter.js b/modules/adxpremiumAnalyticsAdapter.js index 9066c26fb00..9161c6338f4 100644 --- a/modules/adxpremiumAnalyticsAdapter.js +++ b/modules/adxpremiumAnalyticsAdapter.js @@ -1,6 +1,6 @@ import {deepClone, logError, logInfo} from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; import {includes} from '../src/polyfill.js'; @@ -95,7 +95,8 @@ function auctionInit(args) { completeObject.auction_id = args.auctionId; completeObject.publisher_id = adxpremiumAnalyticsAdapter.initOptions.pubId; - try { completeObject.referer = encodeURI(args.bidderRequests[0].refererInfo.referer.split('?')[0]); } catch (e) { logError('AdxPremium Analytics - ' + e.message); } + // TODO: is 'page' the right value here? + try { completeObject.referer = encodeURI(args.bidderRequests[0].refererInfo.page.split('?')[0]); } catch (e) { logError('AdxPremium Analytics - ' + e.message); } if (args.adUnitCodes && args.adUnitCodes.length > 0) { elementIds = args.adUnitCodes; } @@ -232,6 +233,7 @@ function sendEventFallback() { } function sendEvent(completeObject) { + if (!adxpremiumAnalyticsAdapter.enabled) return; requestDelivered = true; try { let responseEvents = btoa(JSON.stringify(completeObject)); @@ -261,7 +263,7 @@ adxpremiumAnalyticsAdapter.enableAnalytics = function (config) { } adxpremiumAnalyticsAdapter.originEnableAnalytics(config); // call the base class function -} +}; adapterManager.registerAnalyticsAdapter({ adapter: adxpremiumAnalyticsAdapter, diff --git a/modules/adyoulikeBidAdapter.js b/modules/adyoulikeBidAdapter.js index 6710448f00e..8952c3ae2b9 100644 --- a/modules/adyoulikeBidAdapter.js +++ b/modules/adyoulikeBidAdapter.js @@ -1,9 +1,9 @@ import {buildUrl, deepAccess, parseSizesInput} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; -import {createEidsArray} from './userId/eids.js'; +import { config } from '../src/config.js'; import {find} from '../src/polyfill.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const VERSION = '1.0'; const BIDDER_CODE = 'adyoulike'; @@ -61,7 +61,10 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); let hasVideo = false; + let eids; const payload = { Version: VERSION, Bids: bidRequests.reduce((accumulator, bidReq) => { @@ -70,13 +73,19 @@ export const spec = { let size = getSize(sizesArray); accumulator[bidReq.bidId] = {}; accumulator[bidReq.bidId].PlacementID = bidReq.params.placement; - accumulator[bidReq.bidId].TransactionID = bidReq.transactionId; + accumulator[bidReq.bidId].TransactionID = bidReq.ortb2Imp?.ext?.tid; accumulator[bidReq.bidId].Width = size.width; accumulator[bidReq.bidId].Height = size.height; accumulator[bidReq.bidId].AvailableSizes = sizesArray.join(','); if (typeof bidReq.getFloor === 'function') { accumulator[bidReq.bidId].Pricing = getFloor(bidReq, size, mediatype); } + if (bidReq.schain) { + accumulator[bidReq.bidId].SChain = bidReq.schain; + } + if (!eids && bidReq.userIdAsEids && bidReq.userIdAsEids.length) { + eids = bidReq.userIdAsEids; + } if (mediatype === NATIVE) { let nativeReq = bidReq.mediaTypes.native; if (nativeReq.type === 'image') { @@ -113,10 +122,15 @@ export const spec = { payload.uspConsent = bidderRequest.uspConsent; } - if (deepAccess(bidderRequest, 'userId')) { - payload.userId = createEidsArray(bidderRequest.userId); + if (bidderRequest.ortb2) { + payload.ortb2 = bidderRequest.ortb2; + } + if (eids) { + payload.eids = eids; } + payload.pbjs_version = '$prebid.version$'; + const data = JSON.stringify(payload); const options = { withCredentials: true @@ -153,6 +167,50 @@ export const spec = { } }); return bidResponses; + }, + + /** + * List user sync endpoints. + * Legal information have to be added to the request. + * Only iframe syncs are supported. + * + * @param {*} syncOptions Publisher prebid configuration. + * @param {*} serverResponses A successful response from the server. + * @return {syncs[]} An array of syncs that should be executed. + */ + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { + if (!syncOptions.iframeEnabled) { + return []; + } + + let params = ''; + + // GDPR + if (gdprConsent) { + params += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + params += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + } + + // coppa compliance + if (config.getConfig('coppa') === true) { + params += '&coppa=1'; + } + + // CCPA + if (uspConsent) { + params += '&us_privacy=' + encodeURIComponent(uspConsent); + } + + // GPP + if (gppConsent?.gppString && gppConsent?.applicableSections?.length) { + params += '&gpp=' + encodeURIComponent(gppConsent.gppString); + params += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(',')); + } + + return [{ + type: 'iframe', + url: `https://visitor.omnitagjs.com/visitor/isync?uid=19340f4f097d16f41f34fc0274981ca4${params}` + }]; } } @@ -165,23 +223,6 @@ function getHostname(bidderRequest) { return ''; } -/* Get current page canonical url */ -function getCanonicalUrl() { - let link; - if (window.self !== window.top) { - try { - link = window.top.document.head.querySelector('link[rel="canonical"][href]'); - } catch (e) { } - } else { - link = document.head.querySelector('link[rel="canonical"][href]'); - } - - if (link) { - return link.href; - } - return ''; -} - /* Get mediatype from bidRequest */ function getMediatype(bidRequest) { if (deepAccess(bidRequest, 'mediaTypes.banner')) { @@ -233,27 +274,34 @@ function createEndpoint(bidRequests, bidderRequest, hasVideo) { /* Create endpoint query string */ function createEndpointQS(bidderRequest) { const qs = {}; - if (bidderRequest) { const ref = bidderRequest.refererInfo; if (ref) { - qs.RefererUrl = encodeURIComponent(ref.referer); - if (ref.numIframes > 0) { - qs.SafeFrame = true; + if (ref.location) { + // RefererUrl will be removed in a future version. + qs.RefererUrl = encodeURIComponent(ref.location); + if (!ref.reachedTop) { + qs.SafeFrame = true; + } } + + qs.PageUrl = encodeURIComponent(ref.topmostLocation); + qs.PageReferrer = encodeURIComponent(ref.location); + } + + // retreive info from ortb2 object if present (prebid7) + const siteInfo = bidderRequest.ortb2?.site; + if (siteInfo) { + qs.PageUrl = encodeURIComponent(siteInfo.page || ref?.topmostLocation); + qs.PageReferrer = encodeURIComponent(siteInfo.ref || ref?.location); } } - const can = getCanonicalUrl(); + const can = bidderRequest?.refererInfo?.canonicalUrl; if (can) { qs.CanonicalUrl = encodeURIComponent(can); } - const domain = config.getConfig('publisherDomain'); - if (domain) { - qs.PublisherDomain = encodeURIComponent(domain); - } - return qs; } @@ -350,14 +398,6 @@ function getTrackers(eventsArray, jsTrackers) { return result; } -function getVideoAd(response) { - var adJson = {}; - if (typeof response.Ad === 'string' && response.Ad.indexOf('\/\*PREBID\*\/') > 0) { - adJson = JSON.parse(response.Ad.match(/\/\*PREBID\*\/(.*)\/\*PREBID\*\//)[1]); - return deepAccess(adJson, 'Content.MainVideo.Vast'); - } -} - function getNativeAssets(response, nativeConfig) { if (typeof response.Native === 'object') { return response.Native; @@ -459,7 +499,7 @@ function getNativeAssets(response, nativeConfig) { /* Create bid from response */ function createBid(response, bidRequests) { if (!response || (!response.Ad && !response.Native && !response.Vast)) { - return + return; } const request = bidRequests && bidRequests[response.BidID]; @@ -486,7 +526,7 @@ function createBid(response, bidRequests) { }; // retreive video response if present - const vast64 = response.Vast || getVideoAd(response); + const vast64 = response.Vast; if (vast64) { bid.width = response.Width; bid.height = response.Height; diff --git a/modules/afpBidAdapter.js b/modules/afpBidAdapter.js index 6565942bcc8..cec61b29b82 100644 --- a/modules/afpBidAdapter.js +++ b/modules/afpBidAdapter.js @@ -7,6 +7,7 @@ export const IS_DEV = location.hostname === 'localhost' export const BIDDER_CODE = 'afp' export const SSP_ENDPOINT = 'https://ssp.afp.ai/api/prebid' export const REQUEST_METHOD = 'POST' +// TODO: test code should be kept in tests export const TEST_PAGE_URL = 'https://rtbinsight.ru/smiert-bolshikh-dannykh-kto-na-novienkogo/' const SDK_PATH = 'https://cdn.afp.ai/ssp/sdk.js?auto_initialization=false&deploy_to_parent_window=true' const TTL = 60 @@ -96,16 +97,16 @@ export const spec = { }, buildRequests(validBidRequests, {refererInfo, gdprConsent}) { const payload = { - pageUrl: IS_DEV ? TEST_PAGE_URL : refererInfo.referer, + pageUrl: IS_DEV ? TEST_PAGE_URL : refererInfo.page, gdprConsent: gdprConsent, bidRequests: validBidRequests.map(validBidRequest => { - const {bidId, transactionId, sizes, params: { + const {bidId, ortb2Imp, sizes, params: { placeId, placeType, imageUrl, imageWidth, imageHeight }} = validBidRequest bidRequestMap[bidId] = validBidRequest const bidRequest = { bidId, - transactionId, + transactionId: ortb2Imp?.ext?.tid, sizes, placeId, } diff --git a/modules/aidemBidAdapter.js b/modules/aidemBidAdapter.js new file mode 100644 index 00000000000..c6a5cd96fb6 --- /dev/null +++ b/modules/aidemBidAdapter.js @@ -0,0 +1,296 @@ +import {deepAccess, deepSetValue, isBoolean, isNumber, isStr, logError, logInfo} from '../src/utils.js'; +import {config} from '../src/config.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {ajax} from '../src/ajax.js'; +import {ortbConverter} from '../libraries/ortbConverter/converter.js'; + +const BIDDER_CODE = 'aidem'; +const BASE_URL = 'https://zero.aidemsrv.com'; +const LOCAL_BASE_URL = 'http://127.0.0.1:8787'; + +const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO]; +const REQUIRED_VIDEO_PARAMS = [ 'mimes', 'protocols', 'context' ]; + +export const ERROR_CODES = { + BID_SIZE_INVALID_FORMAT: 1, + BID_SIZE_NOT_INCLUDED: 2, + PROPERTY_NOT_INCLUDED: 3, + SITE_ID_INVALID_VALUE: 4, + MEDIA_TYPE_NOT_SUPPORTED: 5, + PUBLISHER_ID_INVALID_VALUE: 6, + INVALID_RATELIMIT: 7, + PLACEMENT_ID_INVALID_VALUE: 8, +}; + +const endpoints = { + request: `${BASE_URL}/prebidjs/ortb/v2.6/bid/request`, + // notice: { + // win: `${BASE_URL}/notice/win`, + // timeout: `${BASE_URL}/notice/timeout`, + // error: `${BASE_URL}/notice/error`, + // } +}; + +export function setEndPoints(env = null, path = '') { + switch (env) { + case 'local': + endpoints.request = `${LOCAL_BASE_URL}${path}/prebidjs/ortb/v2.6/bid/request`; + break; + case 'main': + endpoints.request = `${BASE_URL}${path}/prebidjs/ortb/v2.6/bid/request`; + break; + } + return endpoints; +} + +config.getConfig('aidem', function (config) { + if (config.aidem.env) { setEndPoints(config.aidem.env, config.aidem.path); } +}); + +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 30 + }, + request(buildRequest, imps, bidderRequest, context) { + logInfo('Building request'); + const request = buildRequest(imps, bidderRequest, context); + deepSetValue(request, 'at', 1); + setPrebidRequestEnvironment(request); + deepSetValue(request, 'regs', getRegs()); + deepSetValue(request, 'site.publisher.id', bidderRequest.bids[0].params.publisherId); + deepSetValue(request, 'site.id', bidderRequest.bids[0].params.siteId); + return request; + }, + imp(buildImp, bidRequest, context) { + logInfo('Building imp bidRequest', bidRequest); + const imp = buildImp(bidRequest, context); + deepSetValue(imp, 'tagId', bidRequest.params.placementId); + return imp; + }, + bidResponse(buildBidResponse, bid, context) { + const {bidRequest} = context; + const bidResponse = buildBidResponse(bid, context); + logInfo('Building bidResponse'); + logInfo('bid', bid); + logInfo('bidRequest', bidRequest); + logInfo('bidResponse', bidResponse); + if (bidResponse.mediaType === VIDEO) { + deepSetValue(bidResponse, 'vastUrl', bid.adm); + } + return bidResponse; + } +}); + +// AIDEM Custom FN +function recur(obj) { + var result = {}; var _tmp; + for (var i in obj) { + // enabledPlugin is too nested, also skip functions + if (!(i === 'enabledPlugin' || typeof obj[i] === 'function')) { + if (typeof obj[i] === 'object' && obj[i] !== null) { + // get props recursively + _tmp = recur(obj[i]); + // if object is not {} + if (Object.keys(_tmp).length) { + result[i] = _tmp; + } + } else { + // string, number or boolean + result[i] = obj[i]; + } + } + } + return result; +} + +function getRegs() { + let regs = {}; + const consentManagement = config.getConfig('consentManagement'); + const coppa = config.getConfig('coppa'); + if (consentManagement && !!(consentManagement.gdpr)) { + deepSetValue(regs, 'gdpr_applies', !!consentManagement.gdpr); + } else { + deepSetValue(regs, 'gdpr_applies', false); + } + if (consentManagement && deepAccess(consentManagement, 'usp.cmpApi') === 'static') { + deepSetValue(regs, 'usp_applies', !!deepAccess(consentManagement, 'usp')); + deepSetValue(regs, 'us_privacy', deepAccess(consentManagement, 'usp.consentData.getUSPData.uspString')); + } else { + deepSetValue(regs, 'usp_applies', false); + } + + if (isBoolean(coppa)) { + deepSetValue(regs, 'coppa_applies', !!coppa); + } else { + deepSetValue(regs, 'coppa_applies', false); + } + + return regs; +} + +function setPrebidRequestEnvironment(payload) { + const __navigator = JSON.parse(JSON.stringify(recur(navigator))); + delete __navigator.plugins; + deepSetValue(payload, 'environment.ri', getRefererInfo()); + deepSetValue(payload, 'environment.hl', window.history.length); + deepSetValue(payload, 'environment.nav', __navigator); + deepSetValue(payload, 'environment.inp.euc', window.encodeURIComponent.name === 'encodeURIComponent' && typeof window.encodeURIComponent.prototype === 'undefined'); + deepSetValue(payload, 'environment.inp.eu', window.encodeURI.name === 'encodeURI' && typeof window.encodeURI.prototype === 'undefined'); + deepSetValue(payload, 'environment.inp.js', window.JSON.stringify.name === 'stringify' && typeof window.JSON.stringify.prototype === 'undefined'); + deepSetValue(payload, 'environment.inp.jp', window.JSON.parse.name === 'parse' && typeof window.JSON.parse.prototype === 'undefined'); + deepSetValue(payload, 'environment.inp.ofe', window.Object.fromEntries.name === 'fromEntries' && typeof window.Object.fromEntries.prototype === 'undefined'); + deepSetValue(payload, 'environment.inp.oa', window.Object.assign.name === 'assign' && typeof window.Object.assign.prototype === 'undefined'); + deepSetValue(payload, 'environment.wpar.innerWidth', window.innerWidth); + deepSetValue(payload, 'environment.wpar.innerHeight', window.innerHeight); +} + +function hasValidMediaType(bidRequest) { + const supported = hasBannerMediaType(bidRequest) || hasVideoMediaType(bidRequest); + if (!supported) { + logError('AIDEM Bid Adapter: media type not supported', { bidder: BIDDER_CODE, code: ERROR_CODES.MEDIA_TYPE_NOT_SUPPORTED }); + } + return supported; +} + +function hasBannerMediaType(bidRequest) { + return !!deepAccess(bidRequest, 'mediaTypes.banner'); +} + +function hasVideoMediaType(bidRequest) { + return !!deepAccess(bidRequest, 'mediaTypes.video'); +} + +function hasValidBannerMediaType(bidRequest) { + const sizes = deepAccess(bidRequest, 'mediaTypes.banner.sizes'); + if (!sizes) { + logError('AIDEM Bid Adapter: media type sizes missing', { bidder: BIDDER_CODE, code: ERROR_CODES.PROPERTY_NOT_INCLUDED }); + return false; + } + return true; +} + +function hasValidVideoMediaType(bidRequest) { + const sizes = deepAccess(bidRequest, 'mediaTypes.video.playerSize'); + if (!sizes) { + logError('AIDEM Bid Adapter: media type playerSize missing', { bidder: BIDDER_CODE, code: ERROR_CODES.PROPERTY_NOT_INCLUDED }); + return false; + } + return true; +} + +function hasValidVideoParameters(bidRequest) { + let valid = true; + const adUnitsParameters = deepAccess(bidRequest, 'mediaTypes.video'); + const bidderParameter = deepAccess(bidRequest, 'params.video'); + for (let property of REQUIRED_VIDEO_PARAMS) { + const hasAdUnitParameter = adUnitsParameters.hasOwnProperty(property); + const hasBidderParameter = bidderParameter && bidderParameter.hasOwnProperty(property); + if (!hasAdUnitParameter && !hasBidderParameter) { + logError(`AIDEM Bid Adapter: ${property} is not included in either the adunit or params level`, { bidder: BIDDER_CODE, code: ERROR_CODES.PROPERTY_NOT_INCLUDED }); + valid = false; + } + } + + return valid; +} + +function passesRateLimit(bidRequest) { + const rateLimit = deepAccess(bidRequest, 'params.rateLimit', 1); + if (!isNumber(rateLimit) || rateLimit > 1 || rateLimit < 0) { + logError('AIDEM Bid Adapter: invalid rateLimit (must be a number between 0 and 1)', { bidder: BIDDER_CODE, code: ERROR_CODES.INVALID_RATELIMIT }); + return false; + } + if (rateLimit !== 1) { + const randomRateValue = Math.random(); + if (randomRateValue > rateLimit) { + return false; + } + } + return true; +} + +function hasValidParameters(bidRequest) { + // Assigned from AIDEM to a publisher website + const siteId = deepAccess(bidRequest, 'params.siteId'); + const publisherId = deepAccess(bidRequest, 'params.publisherId'); + + if (!isStr(siteId)) { + logError('AIDEM Bid Adapter: siteId must valid string', { bidder: BIDDER_CODE, code: ERROR_CODES.SITE_ID_INVALID_VALUE }); + return false; + } + + if (!isStr(publisherId)) { + logError('AIDEM Bid Adapter: publisherId must valid string', { bidder: BIDDER_CODE, code: ERROR_CODES.PUBLISHER_ID_INVALID_VALUE }); + return false; + } + + return true; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, + isBidRequestValid: function(bidRequest) { + logInfo('bid: ', bidRequest); + + // check if request has valid mediaTypes + if (!hasValidMediaType(bidRequest)) return false; + + // check if request has valid media type parameters at adUnit level + if (hasBannerMediaType(bidRequest) && !hasValidBannerMediaType(bidRequest)) { + return false; + } + + if (hasVideoMediaType(bidRequest) && !hasValidVideoMediaType(bidRequest)) { + return false; + } + + if (hasVideoMediaType(bidRequest) && !hasValidVideoParameters(bidRequest)) { + return false; + } + + if (!hasValidParameters(bidRequest)) { + return false; + } + + return passesRateLimit(bidRequest); + }, + + buildRequests: function(bidRequests, bidderRequest) { + logInfo('bidRequests: ', bidRequests); + logInfo('bidderRequest: ', bidderRequest); + const data = converter.toORTB({bidRequests, bidderRequest}); + logInfo('request payload', data); + return { + method: 'POST', + url: endpoints.request, + data, + options: { + withCredentials: true + } + }; + }, + + interpretResponse: function (serverResponse, request) { + logInfo('serverResponse body: ', serverResponse.body); + logInfo('request data: ', request.data); + const ortbBids = converter.fromORTB({response: serverResponse.body, request: request.data}).bids; + logInfo('ortbBids: ', ortbBids); + return ortbBids; + }, + + onBidWon: function(bid) { + // Bidder specific code + logInfo('onBidWon bid: ', bid); + ajax(bid.burl); + }, + + // onBidderError: function({ bidderRequest }) { + // const notice = buildErrorNotice(bidderRequest); + // ajax(endpoints.notice.error, null, JSON.stringify(notice), { method: 'POST', withCredentials: true }); + // }, +}; +registerBidder(spec); diff --git a/modules/aidemBidAdapter.md b/modules/aidemBidAdapter.md new file mode 100644 index 00000000000..b59014c76ed --- /dev/null +++ b/modules/aidemBidAdapter.md @@ -0,0 +1,191 @@ +# Overview + +``` +name: AIDEM Adapter +type: Bidder Adapter +support: prebid@aidem.com +biddercode: aidem +``` + +# Description +This module connects publishers to AIDEM demand. + +This module is GDPR and CCPA compliant, and no 3rd party userIds are allowed. + + +## Global Bid Params +| Name | Scope | Description | Example | Type | +|---------------|----------|-------------------------|------------|----------| +| `siteId` | required | Unique site ID | `'ABCDEF'` | `String` | +| `publisherId` | required | Unique publisher ID | `'ABCDEF'` | `String` | +| `placementId` | optional | Unique publisher tag ID | `'ABCDEF'` | `String` | +| `rateLimit` | optional | Limit the volume sent to AIDEM. Must be between 0 and 1 | `0.6` | `Number` | + + +### Banner Bid Params +| Name | Scope | Description | Example | Type | +|------------|----------|--------------------------|---------------------------|---------| +| `sizes` | required | List of the sizes wanted | `[[300, 250], [300,600]]` | `Array` | + + +### Video Bid Params +| Name | Scope | Description | Example | Type | +|---------------|----------|-----------------------------------------|-----------------|-----------| +| `context` | required | One of instream, outstream, adpod | `'instream'` | `String` | +| `playerSize` | required | Width and height of the player | `'[640, 480]'` | `Array` | +| `maxduration` | required | Maximum video ad duration, in seconds | `30` | `Integer` | +| `minduration` | required | Minimum video ad duration, in seconds | `5` | `Integer` | +| `mimes` | required | List of the content MIME types supported by the player | `["video/mp4"]` | `Array` | +| `protocols` | required | An array of supported video protocols. At least one supported protocol must be specified, where: `2` = VAST 2.0 `3` = VAST 3.0 `5` = VAST 2.0 wrapper `6` = VAST 3.0 wrapper | `2` | `Array` | + + +### Additional Config +| Name | Scope | Description | Example | Type | +|---------------------|----------|---------------------------------------------------------|---------|-----------| +| `coppa` | optional | Child Online Privacy Protection Act | `true` | `Boolean` | +| `consentManagement` | optional | [Consent Management Object](#consent-management-object) | `{}` | `Object` | + + +### Consent Management Object +| Name | Scope | Description | Example | Type | +|--------|----------|--------------------------------------------------------------------------------------------------|---------|----------| +| `gdpr` | optional | GDPR Object see [Prebid.js doc](https://docs.prebid.org/dev-docs/modules/consentManagement.html) | `{}` | `Object` | +| `usp` | optional | USP Object see [Prebid.js doc](https://docs.prebid.org/dev-docs/modules/consentManagementUsp.html) | `{}` | `Object` | + + +### Example Banner ad unit +```javascript +var adUnits = [{ + code: 'banner-prebid-test-site', + mediaTypes: { + banner: { + sizes: [ + [300, 600], + [300, 250] + ] + } + }, + bids: [{ + bidder: 'aidem', + params: { + siteId: 'prebid-test-siteId', + publisherId: 'prebid-test-publisherId', + }, + }] +}]; +``` + +### Example Video ad unit +```javascript +var adUnits = [{ + code: 'video-prebid-test-site', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + maxduration: 30, + minduration: 5, + mimes: ["video/mp4"], + protocols: 2 + } + }, + bids: [{ + bidder: 'aidem', + params: { + siteId: 'prebid-test-siteId', + publisherId: 'prebid-test-publisherId', + }, + }] +}]; +``` + +### Example GDPR Consent Management +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function (){ + pbjs.setConfig({ + consentManagement: { + gdpr:{ + cmpApi: 'iab' + } + } + }); +}) +``` + + +### Example USP Consent Management +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function (){ + pbjs.setConfig({ + consentManagement: { + usp:{ + cmpApi: 'static', + consentData:{ + getUSPData:{ + uspString: '1YYY' + } + } + } + } + }); +}) +``` + + +### Setting First Party Data (FPD) +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function (){ + pbjs.setConfig({ + ortb2: { + site: { + cat: ['IAB2'], + sectioncat: ['IAB2-2'], + keywords: 'power tools, drills' + }, + } + }); +}) +``` + +### Supported Media Types +| Type | Support | +|--------|--------------------------------------------------------------------| +| Banner | Support all [AIDEM Sizes](https://kb.aidem.com/ssp/lists/adsizes/) | +| Video | Support all [AIDEM Sizes](https://kb.aidem.com/ssp/lists/adsizes/) | + + +# Setup / Dev Guide +```shell +nvm use + +npm install + +gulp build --modules=aidemBidAdapter + +gulp serve --modules=aidemBidAdapter + +# Open a chrome browser with no ad blockers enabled, and paste in this URL. The `pbjs_debug=true` is needed if you want to enable `loggerInfo` output on the `console` tab of Chrome Developer Tools. +http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true +``` + +If you need to run the tests suite but do *not* want to have to build the full adapter and serve it, simply run: +```shell +gulp test --file "test/spec/modules/aidemBidAdapter_spec.js" +``` + + +For video: gulp serve --modules=aidemBidAdapter,dfpAdServerVideo + +# FAQs +### How do I view AIDEM bid request? +Navigate to a page where AIDEM is setup to bid. In the network tab, +search for requests to `zero.aidemsrv.com/bid/request`. diff --git a/modules/airgridRtdProvider.js b/modules/airgridRtdProvider.js index b2e78a7df78..7c6cf1f5de0 100644 --- a/modules/airgridRtdProvider.js +++ b/modules/airgridRtdProvider.js @@ -5,18 +5,26 @@ * @module modules/airgridRtdProvider * @requires module:modules/realTimeData */ -import {config} from '../src/config.js'; import {submodule} from '../src/hook.js'; -import {mergeDeep, isPlainObject, deepSetValue, deepAccess} from '../src/utils.js'; -import {getGlobal} from '../src/prebidGlobal.js'; +import {deepAccess, deepSetValue, mergeDeep} from '../src/utils.js'; import {getStorageManager} from '../src/storageManager.js'; +import {loadExternalScript} from '../src/adloader.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; const MODULE_NAME = 'realTimeData'; const SUBMODULE_NAME = 'airgrid'; const AG_TCF_ID = 782; -export const AG_AUDIENCE_IDS_KEY = 'edkt_matched_audience_ids' +export const AG_AUDIENCE_IDS_KEY = 'edkt_matched_audience_ids'; -export const storage = getStorageManager({gvlid: AG_TCF_ID, moduleName: SUBMODULE_NAME}); +export const storage = getStorageManager({ + moduleType: MODULE_TYPE_RTD, + moduleName: SUBMODULE_NAME, +}); + +function getModuleUrl(accountId) { + const path = accountId ?? 'sdk'; + return `https://cdn.edkt.io/${path}/edgekit.min.js`; +} /** * Attach script tag to DOM @@ -24,21 +32,14 @@ export const storage = getStorageManager({gvlid: AG_TCF_ID, moduleName: SUBMODUL * @return {void} */ export function attachScriptTagToDOM(rtdConfig) { - var edktInitializor = window.edktInitializor = window.edktInitializor || {}; + var edktInitializor = (window.edktInitializor = window.edktInitializor || {}); if (!edktInitializor.invoked) { - edktInitializor.invoked = true; edktInitializor.accountId = rtdConfig.params.accountId; edktInitializor.publisherId = rtdConfig.params.publisherId; edktInitializor.apiKey = rtdConfig.params.apiKey; - edktInitializor.load = function(e) { - var p = e || 'sdk'; - var n = document.createElement('script'); - n.type = 'module'; - n.async = true; - n.src = 'https://cdn.edkt.io/' + p + '/edgekit.min.js'; - document.getElementsByTagName('head')[0].appendChild(n); - }; - edktInitializor.load(edktInitializor.accountId); + edktInitializor.invoked = true; + const moduleSrc = getModuleUrl(rtdConfig.params.accountId); + loadExternalScript(moduleSrc, SUBMODULE_NAME); } } @@ -48,7 +49,7 @@ export function attachScriptTagToDOM(rtdConfig) { */ export function getMatchedAudiencesFromStorage() { const audiences = storage.getDataFromLocalStorage(AG_AUDIENCE_IDS_KEY); - if (!audiences) return [] + if (!audiences) return []; try { return JSON.parse(audiences); } catch (e) { @@ -56,45 +57,35 @@ export function getMatchedAudiencesFromStorage() { } } -/** - * Mutates the adUnits object - * @param {Object} adUnits - * @param {Array} audiences - * @return {void} - */ -function setAudiencesToAppNexusAdUnits(adUnits, audiences) { - adUnits.forEach((adUnit) => { - adUnit.bids.forEach((bid) => { - if (bid.bidder && bid.bidder === 'appnexus') { - deepSetValue(bid, 'params.keywords.perid', audiences || []); - } - }) - }) -} - /** * Pass audience data to configured bidders, using ORTB2 + * @param {Object} bidConfig * @param {Object} rtdConfig * @param {Array} audiences * @return {void} */ -export function setAudiencesUsingBidderOrtb2(rtdConfig, audiences) { +export function setAudiencesAsBidderOrtb2(bidConfig, rtdConfig, audiences) { const bidders = deepAccess(rtdConfig, 'params.bidders'); - if (!bidders || bidders.length === 0) return; - const allBiddersConfig = config.getBidderConfig(); - const agOrtb2 = {} - deepSetValue(agOrtb2, 'ortb2.user.ext.data.airgrid', audiences || []); + if (!bidders || bidders.length === 0 || !audiences || audiences.length === 0) return; - bidders.forEach((bidder) => { - let bidderConfig = {}; - if (isPlainObject(allBiddersConfig[bidder])) { - bidderConfig = allBiddersConfig[bidder]; + const agOrtb2 = {}; + + const agUserData = [ + { + id: String(AG_TCF_ID), + ext: { + segtax: 540, + }, + name: 'airgrid', + segment: audiences.map((id) => ({id})) } - config.setBidderConfig({ - bidders: [bidder], - config: mergeDeep(bidderConfig, agOrtb2) - }); - }); + ] + deepSetValue(agOrtb2, 'user.data', agUserData); + + const bidderConfig = Object.fromEntries( + bidders.map((bidder) => [bidder, agOrtb2]) + ) + mergeDeep(bidConfig?.ortb2Fragments?.bidder, bidderConfig) } /** @@ -116,23 +107,25 @@ function init(rtdConfig, userConsent) { * @param {Object} userConsent * @return {void} */ -export function passAudiencesToBidders(bidConfig, onDone, rtdConfig, userConsent) { - const adUnits = bidConfig.adUnits || getGlobal().adUnits; +export function passAudiencesToBidders( + bidConfig, + onDone, + rtdConfig, + userConsent +) { const audiences = getMatchedAudiencesFromStorage(); if (audiences.length > 0) { - setAudiencesUsingBidderOrtb2(rtdConfig, audiences); - if (adUnits) { - setAudiencesToAppNexusAdUnits(adUnits, audiences); - } + setAudiencesAsBidderOrtb2(bidConfig, rtdConfig, audiences) } onDone(); -}; +} /** @type {RtdSubmodule} */ export const airgridSubmodule = { name: SUBMODULE_NAME, init: init, - getBidRequestData: passAudiencesToBidders + getBidRequestData: passAudiencesToBidders, + gvlid: AG_TCF_ID }; submodule(MODULE_NAME, airgridSubmodule); diff --git a/modules/airgridRtdProvider.md b/modules/airgridRtdProvider.md index 7ee502b4c10..6251c63fce9 100644 --- a/modules/airgridRtdProvider.md +++ b/modules/airgridRtdProvider.md @@ -1,15 +1,17 @@ - --- - layout: page_v2 - title: AirGrid RTD SubModule - description: Client-side, cookieless and privacy-first audiences. - page_type: module - module_type: rtd - module_code : example - enable_download : true - sidebarType : 1 - --- - -# AirGrid +--- +layout: page_v2 +title: AirGrid RTD Provider +display_name: AirGrid RTD Provider +description: Client-side, cookieless and privacy-first audiences. +page_type: module +module_type: rtd +module_code : airgridRtdProvider +enable_download : true +vendor_specific: true +sidebarType : 1 +--- + +# AirGrid RTD Provider AirGrid is a privacy-first, cookie-less audience platform. Designed to help publishers increase inventory yield, whilst providing audience signal to buyers in the bid request, without exposing raw user level data to any party. @@ -17,13 +19,17 @@ whilst providing audience signal to buyers in the bid request, without exposing This real-time data module provides quality first-party data, contextual data, site-level data and more that is injected into bid request objects destined for different bidders in order to optimize targeting. +{:.no_toc} +* TOC +{:toc} + ## Usage -Compile the Halo RTD module into your Prebid build: +Compile the AirGrid RTD module (`airgridRtdProvider`) into your Prebid build, along with the parent RTD Module (`rtdModule`): `gulp build --modules=rtdModule,airgridRtdProvider,appnexusBidAdapter` -Add the AirGrid RTD provider to your Prebid config. In this example we will configure publisher 1234 to retrieve segments from Audigent. See the "Parameter Descriptions" below for more detailed information of the configuration parameters. +Next we configure the module, via `pbjs.setConfig`. See the **Parameter Descriptions** below for more detailed information of the configuration parameters. ```js pbjs.setConfig( @@ -50,6 +56,7 @@ pbjs.setConfig( ### Parameter Descriptions +{: .table .table-bordered .table-striped } | Name |Type | Description | Notes | | :------------ | :------------ | :------------ |:------------ | | name | `String` | RTD sub module name | Always 'airgrid' | @@ -61,7 +68,7 @@ pbjs.setConfig( _Note: Although the module supports passing segment data to any bidder using the ORTB2 spec, there is no way for this to be currently monetised. Please reach out to support, to discuss using bidders other than Xandr/AppNexus._ -If you do not have your own `apiKey`, `accountId` & `publisherId` please reach out to [support@airgrid.io](mailto:support@airgrid.io) +If you do not have your own `apiKey`, `accountId` & `publisherId` please reach out to [support@airgrid.io](mailto:support@airgrid.io) or you can sign up via the [AirGrid platform](https://app.airgrid.io). ## Testing @@ -89,7 +96,7 @@ If you require further assistance or are interested in discussing the module fun - [hello@airgrid.io](mailto:hello@airgrid.io) for general questions. - [support@airgrid.io](mailto:support@airgrid.io) for technical questions. -You are also able to find more examples and other integration routes on the [AirGrid docs site](docs.airgrid.io). +You are also able to find more examples and other integration routes on the [AirGrid docs site](https://docs.airgrid.io), or learn more on our [site](https://airgrid.io)! Happy Coding! 😊 The AirGrid Team. diff --git a/modules/ajaBidAdapter.js b/modules/ajaBidAdapter.js index a9364a7a05f..9049197e565 100644 --- a/modules/ajaBidAdapter.js +++ b/modules/ajaBidAdapter.js @@ -1,19 +1,30 @@ -import { getBidIdParameter, tryAppendQueryString, createTrackPixelHtml, logError, logWarn } from '../src/utils.js'; +import {createTrackPixelHtml, logError, logWarn, deepAccess, getBidIdParameter} from '../src/utils.js'; import { Renderer } from '../src/Renderer.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { VIDEO, BANNER, NATIVE } from '../src/mediaTypes.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; -const BIDDER_CODE = 'aja'; +const BidderCode = 'aja'; const URL = 'https://ad.as.amanad.adtdp.com/v2/prebid'; -const SDK_TYPE = 5; -const AD_TYPE = { - BANNER: 1, - NATIVE: 2, - VIDEO: 3, +const SDKType = 5; +const AdType = { + Banner: 1, + Native: 2, + Video: 3, }; +const BannerSizeMap = { + '970x250': 1, + '300x250': 2, + '320x50': 3, + '728x90': 4, + '320x100': 6, + '336x280': 31, + '300x600': 32, +} + export const spec = { - code: BIDDER_CODE, + code: BidderCode, supportedMediaTypes: [VIDEO, BANNER, NATIVE], /** @@ -36,7 +47,7 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const bidRequests = []; - const pageUrl = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || undefined; + const pageUrl = bidderRequest?.refererInfo?.page || undefined; for (let i = 0, len = validBidRequests.length; i < len; i++) { const bidRequest = validBidRequests[i]; @@ -44,8 +55,8 @@ export const spec = { const asi = getBidIdParameter('asi', bidRequest.params); queryString = tryAppendQueryString(queryString, 'asi', asi); - queryString = tryAppendQueryString(queryString, 'skt', SDK_TYPE); - queryString = tryAppendQueryString(queryString, 'tid', bidRequest.transactionId) + queryString = tryAppendQueryString(queryString, 'skt', SDKType); + queryString = tryAppendQueryString(queryString, 'tid', bidRequest.ortb2Imp?.ext?.tid) queryString = tryAppendQueryString(queryString, 'prebid_id', bidRequest.bidId); queryString = tryAppendQueryString(queryString, 'prebid_ver', '$prebid.version$'); @@ -53,11 +64,32 @@ export const spec = { queryString = tryAppendQueryString(queryString, 'page_url', pageUrl); } + const banner = deepAccess(bidRequest, `mediaTypes.${BANNER}`) + if (banner) { + const adFormatIDs = []; + for (const size of banner.sizes || []) { + if (size.length !== 2) { + continue + } + + const adFormatID = BannerSizeMap[`${size[0]}x${size[1]}`]; + if (adFormatID) { + adFormatIDs.push(adFormatID); + } + } + queryString = tryAppendQueryString(queryString, 'ad_format_ids', adFormatIDs.join(',')); + } + const eids = bidRequest.userIdAsEids; if (eids && eids.length) { queryString = tryAppendQueryString(queryString, 'eids', JSON.stringify({ 'eids': eids, - })) + })); + } + + const sua = deepAccess(bidRequest, 'ortb2.device.sua'); + if (sua) { + queryString = tryAppendQueryString(queryString, 'sua', JSON.stringify(sua)); } bidRequests.push({ @@ -92,7 +124,7 @@ export const spec = { }, } - if (AD_TYPE.VIDEO === ad.ad_type) { + if (AdType.Video === ad.ad_type) { const videoAd = bidderResponseBody.ad.video; Object.assign(bid, { vastXml: videoAd.vtag, @@ -104,7 +136,7 @@ export const spec = { }); Array.prototype.push.apply(bid.meta.advertiserDomains, videoAd.adomain) - } else if (AD_TYPE.BANNER === ad.ad_type) { + } else if (AdType.Banner === ad.ad_type) { const bannerAd = bidderResponseBody.ad.banner; Object.assign(bid, { width: bannerAd.w, @@ -122,7 +154,7 @@ export const spec = { } Array.prototype.push.apply(bid.meta.advertiserDomains, bannerAd.adomain) - } else if (AD_TYPE.NATIVE === ad.ad_type) { + } else if (AdType.Native === ad.ad_type) { const nativeAds = ad.native.template_and_ads.ads; if (nativeAds.length === 0) { return []; diff --git a/modules/akamaiDAPIdSystem.js b/modules/akamaiDAPIdSystem.js deleted file mode 100644 index 5e3a607d5fd..00000000000 --- a/modules/akamaiDAPIdSystem.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * This module adds DAP to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/akamaiDAPIdSubmodule - * @requires module:modules/userId - */ - -import { logMessage, logError } from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { uspDataHandler } from '../src/adapterManager.js'; - -const MODULE_NAME = 'akamaiDAPId'; -const STORAGE_KEY = 'akamai_dap_token'; - -export const storage = getStorageManager(); - -/** @type {Submodule} */ -export const akamaiDAPIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: MODULE_NAME, - /** - * decode the stored id value for passing to bid requests - * @function - * @returns {{dapId:string}} - */ - decode(value) { - logMessage('akamaiDAPId [decode] value=', value); - return { dapId: value }; - }, - - /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {ConsentData} [consentData] - * @param {SubmoduleConfig} [config] - * @returns {IdResponse|undefined} - */ - getId(config, consentData) { - const configParams = (config && config.params); - if (!configParams) { - logError('User ID - akamaiDAPId submodule requires a valid configParams'); - return; - } else if (typeof configParams.apiHostname !== 'string') { - logError('User ID - akamaiDAPId submodule requires a valid configParams.apiHostname'); - return; - } else if (typeof configParams.domain !== 'string') { - logError('User ID - akamaiDAPId submodule requires a valid configParams.domain'); - return; - } else if (typeof configParams.type !== 'string') { - logError('User ID - akamaiDAPId submodule requires a valid configParams.type'); - return; - } - const hasGdpr = (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) ? 1 : 0; - const gdprConsentString = hasGdpr ? consentData.consentString : ''; - const uspConsent = uspDataHandler.getConsentData(); - if (hasGdpr && (!gdprConsentString || gdprConsentString === '')) { - logError('User ID - akamaiDAPId submodule requires consent string to call API'); - return; - } - // XXX: retrieve first-party data here if needed - let url = ''; - let postData; - let tokenName = ''; - if (configParams.apiVersion === 'v1') { - if (configParams.type.indexOf('dap-signature:') == 0) { - let parts = configParams.type.split(':'); - let v = parts[1]; - url = `https://${configParams.apiHostname}/data-activation/v1/domain/${configParams.domain}/signature?v=${v}&gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; - tokenName = 'SigToken'; - } else { - url = `https://${configParams.apiHostname}/data-activation/v1/identity/tokenize?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; - postData = { - 'version': 1, - 'domain': configParams.domain, - 'identity': configParams.identity, - 'type': configParams.type - }; - tokenName = 'PubToken'; - } - } else { - url = `https://${configParams.apiHostname}/data-activation/x1/domain/${configParams.domain}/identity/tokenize?gdpr=${hasGdpr}&gdpr_consent=${gdprConsentString}&us_privacy=${uspConsent}`; - postData = { - 'version': configParams.apiVersion, - 'identity': configParams.identity, - 'type': configParams.type, - 'attributes': configParams.attributes - }; - tokenName = 'x1Token'; - } - - let cb = { - success: (response, request) => { - var token = (response === '') ? request.getResponseHeader('Akamai-DAP-Token') : response; - storage.setDataInLocalStorage(STORAGE_KEY, token); - }, - error: error => { - logError('akamaiDAPId [getId:ajax.error] failed to retrieve ' + tokenName, error); - } - }; - - ajax(url, cb, JSON.stringify(postData), { contentType: 'application/json' }); - - let token = storage.getDataFromLocalStorage(STORAGE_KEY); - logMessage('akamaiDAPId [getId] returning', token); - - return { id: token }; - } -}; - -submodule('userId', akamaiDAPIdSubmodule); diff --git a/modules/akamaiDAPIdSystem.md b/modules/akamaiDAPIdSystem.md deleted file mode 100644 index 9b35709c3f2..00000000000 --- a/modules/akamaiDAPIdSystem.md +++ /dev/null @@ -1,48 +0,0 @@ -# Akamai Data Activation Platform Audience Segment ID Targeting - -The Akamai Data Activation Platform (DAP) is a privacy-first system that protects end-user privacy by only allowing them to be targeted as part of a larger cohort. DAP views hiding individuals in large cohorts as the best mechanism to prevent unauthorized tracking. - -The integration of DAP into Prebid.JS consists of creating a UserID plugin that interacts with the DAP API. The UserID module tokenizes the end-user identity into an ephemeral, secure pseudonymization called a dapId. The dapId is then supplied to the bid-stream where the SSP partner looks up cohort membership for that token, and supplies the cohorts to the rest of the bid-stream. - -In this system, no end-user identifier is supplied to the bid-stream, only cohorts. This is a foundational privacy principle DAP is built upon. - -## Onboarding - -Please reach out to your Akamai account representative(Prebid@akamai.com) to get provisioned on the DAP platform. - -## DAP Configuration - -First, make sure to add the DAP submodule to your Prebid.js package with: - -``` -gulp build --modules=akamaiDAPIdSystem,userId -``` - -The following configuration parameters are available: - -```javascript -pbjs.setConfig({ - userSync: { - userIds: [{ - name: 'akamaiDAPId', - params: { - apiHostname: '', - domain: 'your-domain.com', - type: 'email' | 'mobile' | ... | 'dap-signature:1.0.0', - identity: ‘your@email.com’ | ‘6175551234' | ...', - apiVersion: 'v1' | 'x1', - attributes: '{ "cohorts": [ "3:14400", "5:14400", "7:0" ],"first_name": "...","last_name": "..." }' - }, - }], - auctionDelay: 50 // 50ms maximum auction delay, applies to all userId modules - } -}); -``` - -In order to make use of v1 APIs, "apiVersion" needs to explicitly mentioned as 'v1'. The "apiVersion" defaults to x1 if not specified. -"attributes" can be configured in x1 API only and not v1 APIs. Please ensure that the "attributes" value is in same format as shown above. - -Refer to the sample integration example present at below location -Prebid.js/integrationExamples/gpt/akamaidap_email_example.html -Prebid.js/integrationExamples/gpt/akamaidap_signature_example.html -Prebid.js/integrationExamples/gpt/akamaidap_x1_example.html diff --git a/modules/akamaiDapRtdProvider.js b/modules/akamaiDapRtdProvider.js index aca984d39c8..f0bb7eb3a6c 100644 --- a/modules/akamaiDapRtdProvider.js +++ b/modules/akamaiDapRtdProvider.js @@ -6,16 +6,26 @@ * @requires module:modules/realTimeData */ import {ajax} from '../src/ajax.js'; -import {config} from '../src/config.js'; import {getStorageManager} from '../src/storageManager.js'; import {submodule} from '../src/hook.js'; import {isPlainObject, mergeDeep, logMessage, logInfo, logError} from '../src/utils.js'; +import { loadExternalScript } from '../src/adloader.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; const MODULE_NAME = 'realTimeData'; const SUBMODULE_NAME = 'dap'; +const MODULE_CODE = 'akamaidap'; -export const SEGMENTS_STORAGE_KEY = 'akamaiDapSegments'; -export const storage = getStorageManager({gvlid: null, moduleName: SUBMODULE_NAME}); +export const DAP_TOKEN = 'async_dap_token'; +export const DAP_MEMBERSHIP = 'async_dap_membership'; +export const DAP_ENCRYPTED_MEMBERSHIP = 'encrypted_dap_membership'; +export const DAP_SS_ID = 'dap_ss_id'; +export const DAP_DEFAULT_TOKEN_TTL = 3600; // in seconds +export const DAP_MAX_RETRY_TOKENIZE = 1; +export const DAP_CLIENT_ENTROPY = 'dap_client_entropy' + +export const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: SUBMODULE_NAME}); +let dapRetryTokenize = 0; /** * Lazy merge objects. @@ -34,17 +44,16 @@ function mergeLazy(target, source) { /** * Add real-time data & merge segments. - * @param {Object} bidConfig + * @param {Object} ortb2 destionation object to merge RTD into * @param {Object} rtd * @param {Object} rtdConfig */ -export function addRealTimeData(rtd) { +export function addRealTimeData(ortb2, rtd) { logInfo('DEBUG(addRealTimeData) - ENTER'); if (isPlainObject(rtd.ortb2)) { - let ortb2 = config.getConfig('ortb2') || {}; logMessage('DEBUG(addRealTimeData): merging original: ', ortb2); logMessage('DEBUG(addRealTimeData): merging in: ', rtd.ortb2); - config.setConfig({ortb2: mergeLazy(ortb2, rtd.ortb2)}); + mergeLazy(ortb2, rtd.ortb2); } logInfo('DEBUG(addRealTimeData) - EXIT'); } @@ -53,61 +62,68 @@ export function addRealTimeData(rtd) { * Real-time data retrieval from Audigent * @param {Object} reqBidsConfigObj * @param {function} onDone - * @param {Object} rtdConfi + * @param {Object} rtdConfig * @param {Object} userConsent */ export function getRealTimeData(bidConfig, onDone, rtdConfig, userConsent) { - logInfo('DEBUG(getRealTimeData) - ENTER'); + let entropyDict = JSON.parse(storage.getDataFromLocalStorage(DAP_CLIENT_ENTROPY)); + let loadScriptPromise = new Promise((resolve, reject) => { + if (rtdConfig && rtdConfig.params && rtdConfig.params.dapEntropyTimeout && Number.isInteger(rtdConfig.params.dapEntropyTimeout)) { + setTimeout(reject, rtdConfig.params.dapEntropyTimeout, Error('DapEntropy script could not be loaded')); + } + if (entropyDict && entropyDict.expires_at > Math.round(Date.now() / 1000.0)) { + logMessage('Using cached entropy'); + resolve(); + } else { + if (typeof window.dapCalculateEntropy === 'function') { + window.dapCalculateEntropy(resolve, reject); + } else { + if (rtdConfig && rtdConfig.params && dapUtils.isValidHttpsUrl(rtdConfig.params.dapEntropyUrl)) { + loadExternalScript(rtdConfig.params.dapEntropyUrl, MODULE_CODE, () => { dapUtils.dapGetEntropy(resolve, reject) }); + } else { + reject(Error('Please check if dapEntropyUrl is specified and is valid under config.params')); + } + } + } + }); + loadScriptPromise + .catch((error) => { + logError('Entropy could not be calculated due to: ', error.message); + }) + .finally(() => { + generateRealTimeData(bidConfig, onDone, rtdConfig, userConsent); + }); +} + +export function generateRealTimeData(bidConfig, onDone, rtdConfig, userConsent) { + logInfo('DEBUG(generateRealTimeData) - ENTER'); logMessage(' - apiHostname: ' + rtdConfig.params.apiHostname); logMessage(' - apiVersion: ' + rtdConfig.params.apiVersion); - let jsonData = storage.getDataFromLocalStorage(SEGMENTS_STORAGE_KEY); - if (jsonData) { - let data = JSON.parse(jsonData); - if (data.rtd) { - addRealTimeData(data.rtd); - onDone(); - logInfo('DEBUG(getRealTimeData) - 1'); - // Don't return - ensure the data is always fresh. + dapRetryTokenize = 0; + var jsonData = null; + if (rtdConfig && isPlainObject(rtdConfig.params)) { + if (rtdConfig.params.segtax == 504) { + let encMembership = dapUtils.dapGetEncryptedMembershipFromLocalStorage(); + if (encMembership) { + jsonData = dapUtils.dapGetEncryptedRtdObj(encMembership, rtdConfig.params.segtax) + } + } else { + let membership = dapUtils.dapGetMembershipFromLocalStorage(); + if (membership) { + jsonData = dapUtils.dapGetRtdObj(membership, rtdConfig.params.segtax) + } } } - - if (rtdConfig && isPlainObject(rtdConfig.params)) { - let config = { - api_hostname: rtdConfig.params.apiHostname, - api_version: rtdConfig.params.apiVersion, - domain: rtdConfig.params.domain, - segtax: rtdConfig.params.segtax - }; - let identity = { - type: rtdConfig.params.identityType - }; - let token = dapUtils.dapGetToken(config, identity, rtdConfig.params.tokenTtl); - if (token !== null) { - let membership = dapUtils.dapGetMembership(config, token); - let udSegment = dapUtils.dapMembershipToRtbSegment(membership, config); - logMessage('DEBUG(getRealTimeData) - token: ' + token + ', user.data.segment: ', udSegment); - let data = { - rtd: { - ortb2: { - user: { - data: [ - udSegment - ] - }, - site: { - ext: { - data: { - dapSAID: membership.said - } - } - } - } - } - }; - storage.setDataInLocalStorage(SEGMENTS_STORAGE_KEY, JSON.stringify(data)); + if (jsonData) { + if (jsonData.rtd) { + addRealTimeData(bidConfig.ortb2Fragments?.global, jsonData.rtd); onDone(); + logInfo('DEBUG(generateRealTimeData) - 1'); + // Don't return - ensure the data is always fresh. } } + // Calling setTimeout to release the main thread so that the bid request could be sent. + setTimeout(dapUtils.callDapAPIs, 0, bidConfig, onDone, rtdConfig, userConsent); } /** @@ -117,6 +133,9 @@ export function getRealTimeData(bidConfig, onDone, rtdConfig, userConsent) { * @return {boolean} */ function init(provider, userConsent) { + if (dapUtils.checkConsent(userConsent) === false) { + return false; + } return true; } @@ -128,104 +147,216 @@ export const akamaiDapRtdSubmodule = { }; submodule(MODULE_NAME, akamaiDapRtdSubmodule); - export const dapUtils = { - dapGetToken: function(config, identity, ttl) { + callDapAPIs: function(bidConfig, onDone, rtdConfig, userConsent) { + if (rtdConfig && isPlainObject(rtdConfig.params)) { + let config = { + api_hostname: rtdConfig.params.apiHostname, + api_version: rtdConfig.params.apiVersion, + domain: rtdConfig.params.domain, + segtax: rtdConfig.params.segtax, + identity: {type: rtdConfig.params.identityType} + }; + let refreshMembership = true; + let token = dapUtils.dapGetTokenFromLocalStorage(); + const ortb2 = bidConfig.ortb2Fragments.global; + logMessage('token is: ', token); + if (token !== null) { // If token is not null then check the membership in storage and add the RTD object + if (config.segtax == 504) { // Follow the encrypted membership path + dapUtils.dapRefreshEncryptedMembership(ortb2, config, token, onDone) // Get the encrypted membership from server + refreshMembership = false; + } else { + dapUtils.dapRefreshMembership(ortb2, config, token, onDone) // Get the membership from server + refreshMembership = false; + } + } + dapUtils.dapRefreshToken(ortb2, config, refreshMembership, onDone) // Refresh Token and membership in all the cases + } + }, + dapGetEntropy: function(resolve, reject) { + if (typeof window.dapCalculateEntropy === 'function') { + window.dapCalculateEntropy(resolve, reject); + } else { + reject(Error('window.dapCalculateEntropy function is not defined')) + } + }, + + dapGetTokenFromLocalStorage: function(ttl) { let now = Math.round(Date.now() / 1000.0); // in seconds - let storageName = 'async_dap_token'; let token = null; - - if (ttl == 0) { - localStorage.removeItem(storageName); + let item = JSON.parse(storage.getDataFromLocalStorage(DAP_TOKEN)); + if (item) { + if (now < item.expires_at) { + token = item.token; + } } + return token; + }, - let item = JSON.parse(localStorage.getItem(storageName)); - if (item == null) { - item = { - expires_at: now - 1, - token: null - }; - } else { - token = item.token; - } - - if (now > item.expires_at) { - dapUtils.dapLog('Token missing or expired, fetching a new one...'); - // Trigger a refresh - let configAsync = {...config}; - dapUtils.dapTokenize(configAsync, identity, - function(token, status, xhr) { - item.expires_at = now + ttl; - item.token = token; - localStorage.setItem(storageName, JSON.stringify(item)); - dapUtils.dapLog('Successfully updated and stored token; expires in ' + ttl + ' seconds'); - let deviceId100 = xhr.getResponseHeader('Akamai-DAP-100'); - if (deviceId100 != null) { - localStorage.setItem('dap_deviceId100', deviceId100); - dapUtils.dapLog('Successfully stored DAP 100 Device ID: ' + deviceId100); + dapRefreshToken: function(ortb2, config, refreshMembership, onDone) { + dapUtils.dapLog('Token missing or expired, fetching a new one...'); + // Trigger a refresh + let now = Math.round(Date.now() / 1000.0); // in seconds + let item = {} + let configAsync = {...config}; + dapUtils.dapTokenize(configAsync, config.identity, onDone, + function(token, status, xhr, onDone) { + item.expires_at = now + DAP_DEFAULT_TOKEN_TTL; + let exp = dapUtils.dapExtractExpiryFromToken(token); + if (typeof exp == 'number') { + item.expires_at = exp - 10; + } + item.token = token; + storage.setDataInLocalStorage(DAP_TOKEN, JSON.stringify(item)); + dapUtils.dapLog('Successfully updated and stored token; expires at ' + item.expires_at); + let dapSSID = xhr.getResponseHeader('Akamai-DAP-SS-ID'); + if (dapSSID) { + storage.setDataInLocalStorage(DAP_SS_ID, JSON.stringify(dapSSID)); + } + let deviceId100 = xhr.getResponseHeader('Akamai-DAP-100'); + if (deviceId100 != null) { + storage.setDataInLocalStorage('dap_deviceId100', deviceId100); + dapUtils.dapLog('Successfully stored DAP 100 Device ID: ' + deviceId100); + } + if (refreshMembership) { + if (config.segtax == 504) { + dapUtils.dapRefreshEncryptedMembership(ortb2, config, token, onDone); + } else { + dapUtils.dapRefreshMembership(ortb2, config, token, onDone); } - }, - function(xhr, status, error) { - logError('ERROR(' + error + '): failed to retrieve token! ' + status); } - ); - } - - return token; + }, + function(xhr, status, error, onDone) { + logError('ERROR(' + error + '): failed to retrieve token! ' + status); + onDone() + } + ); }, - dapGetMembership: function(config, token) { + dapGetMembershipFromLocalStorage: function() { let now = Math.round(Date.now() / 1000.0); // in seconds - let storageName = 'async_dap_membership'; - let maxTtl = 3600; // if the cached membership is older than this, return null let membership = null; - let item = JSON.parse(localStorage.getItem(storageName)); - if (item == null || (now - item.expires_at) > maxTtl) { - item = { - expires_at: now - 1, - said: null, - cohorts: null, - attributes: null - }; - } else { - membership = { - said: item.said, - cohorts: item.cohorts, - attributes: null - }; + let item = JSON.parse(storage.getDataFromLocalStorage(DAP_MEMBERSHIP)); + if (item) { + if (now < item.expires_at) { + membership = { + said: item.said, + cohorts: item.cohorts, + attributes: null + }; + } } + return membership; + }, - // Always refresh the cached membership. + dapRefreshMembership: function(ortb2, config, token, onDone) { + let now = Math.round(Date.now() / 1000.0); // in seconds + let item = {} let configAsync = {...config}; - dapUtils.dapMembership(configAsync, token, - function(membership, status, xhr) { - item.expires_at = now + maxTtl; + dapUtils.dapMembership(configAsync, token, onDone, + function(membership, status, xhr, onDone) { + item.expires_at = now + DAP_DEFAULT_TOKEN_TTL; + let exp = dapUtils.dapExtractExpiryFromToken(membership.said) + if (typeof exp == 'number') { + item.expires_at = exp - 10; + } item.said = membership.said; item.cohorts = membership.cohorts; - localStorage.setItem(storageName, JSON.stringify(item)); + storage.setDataInLocalStorage(DAP_MEMBERSHIP, JSON.stringify(item)); dapUtils.dapLog('Successfully updated and stored membership:'); dapUtils.dapLog(item); + + let data = dapUtils.dapGetRtdObj(item, config.segtax) + dapUtils.checkAndAddRealtimeData(ortb2, data, config.segtax); + onDone(); }, - function(xhr, status, error) { + function(xhr, status, error, onDone) { logError('ERROR(' + error + '): failed to retrieve membership! ' + status); + if (status == 403 && dapRetryTokenize < DAP_MAX_RETRY_TOKENIZE) { + dapRetryTokenize++; + dapUtils.dapRefreshToken(ortb2, config, true, onDone); + } else { + onDone(); + } } ); + }, - return membership; + dapGetEncryptedMembershipFromLocalStorage: function() { + let now = Math.round(Date.now() / 1000.0); // in seconds + let encMembership = null; + let item = JSON.parse(storage.getDataFromLocalStorage(DAP_ENCRYPTED_MEMBERSHIP)); + if (item) { + if (now < item.expires_at) { + encMembership = { + encryptedSegments: item.encryptedSegments + }; + } + } + return encMembership; + }, + + dapRefreshEncryptedMembership: function(ortb2, config, token, onDone) { + let now = Math.round(Date.now() / 1000.0); // in seconds + let item = {}; + let configAsync = {...config}; + dapUtils.dapEncryptedMembership(configAsync, token, onDone, + function(encToken, status, xhr, onDone) { + item.expires_at = now + DAP_DEFAULT_TOKEN_TTL; + let exp = dapUtils.dapExtractExpiryFromToken(encToken); + if (typeof exp == 'number') { + item.expires_at = exp - 10; + } + item.encryptedSegments = encToken; + storage.setDataInLocalStorage(DAP_ENCRYPTED_MEMBERSHIP, JSON.stringify(item)); + dapUtils.dapLog('Successfully updated and stored encrypted membership:'); + dapUtils.dapLog(item); + + let encData = dapUtils.dapGetEncryptedRtdObj(item, config.segtax); + dapUtils.checkAndAddRealtimeData(ortb2, encData, config.segtax); + onDone(); + }, + function(xhr, status, error, onDone) { + logError('ERROR(' + error + '): failed to retrieve encrypted membership! ' + status); + if (status == 403 && dapRetryTokenize < DAP_MAX_RETRY_TOKENIZE) { + dapRetryTokenize++; + dapUtils.dapRefreshToken(ortb2, config, true, onDone); + } else { + onDone(); + } + } + ); + }, + + /** + * DESCRIPTION + * Extract expiry value from a token + */ + dapExtractExpiryFromToken: function(token) { + let exp = null; + if (token) { + const tokenArray = token.split('..'); + if (tokenArray && tokenArray.length > 0) { + let decode = atob(tokenArray[0]) + let header = JSON.parse(decode.replace(/"/g, '"')); + exp = header.exp; + } + } + return exp }, /** * DESCRIPTION * * Convert a DAP membership response to an OpenRTB2 segment object suitable - * for insertion into user.data.segment or site.data.segment. + * for insertion into user.data.segment or site.data.segment and add it to the rtd obj. */ - dapMembershipToRtbSegment: function(membership, config) { + dapGetRtdObj: function(membership, segtax) { let segment = { name: 'dap.akamai.com', ext: { - 'segtax': config.segtax + 'segtax': segtax }, segment: [] }; @@ -234,7 +365,82 @@ export const dapUtils = { segment.segment.push({ id: i }); } } - return segment; + let data = { + rtd: { + ortb2: { + user: { + data: [ + segment + ] + }, + site: { + ext: { + data: { + dapSAID: membership.said + } + } + } + } + } + }; + return data; + }, + + /** + * DESCRIPTION + * + * Convert a DAP membership response to an OpenRTB2 segment object suitable + * for insertion into user.data.segment or site.data.segment and add it to the rtd obj. + */ + dapGetEncryptedRtdObj: function(encToken, segtax) { + let segment = { + name: 'dap.akamai.com', + ext: { + 'segtax': segtax + }, + segment: [] + }; + if (encToken != null) { + segment.segment.push({ id: encToken.encryptedSegments }); + } + let encData = { + rtd: { + ortb2: { + user: { + data: [ + segment + ] + } + } + } + }; + return encData; + }, + + checkAndAddRealtimeData: function(ortb2, data, segtax) { + if (data.rtd) { + if (segtax == 504 && dapUtils.checkIfSegmentsAlreadyExist(ortb2, data.rtd, 504)) { + logMessage('DEBUG(handleInit): rtb Object already added'); + } else { + addRealTimeData(ortb2, data.rtd); + } + logInfo('DEBUG(checkAndAddRealtimeData) - 1'); + } + }, + + checkIfSegmentsAlreadyExist: function(ortb2, rtd, segtax) { + let segmentsExist = false + if (ortb2.user && ortb2.user.data && ortb2.user.data.length > 0) { + for (let i = 0; i < ortb2.user.data.length; i++) { + let element = ortb2.user.data[i] + if (element.ext && element.ext.segtax == segtax) { + segmentsExist = true + logMessage('DEBUG(checkIfSegmentsAlreadyExist): rtb Object already added: ', ortb2.user.data); + break; + } + } + } + return segmentsExist }, dapLog: function(args) { @@ -248,6 +454,35 @@ export const dapUtils = { logInfo('%cDAP Client', css, args); }, + isValidHttpsUrl: function(urlString) { + let url; + try { + url = new URL(urlString); + } catch (_) { + return false; + } + return url.protocol === 'https:'; + }, + + checkConsent: function(userConsent) { + let consent = true; + + if (userConsent && userConsent.gdpr && userConsent.gdpr.gdprApplies) { + const gdpr = userConsent.gdpr; + const hasGdpr = (gdpr && typeof gdpr.gdprApplies === 'boolean' && gdpr.gdprApplies) ? 1 : 0; + const gdprConsentString = hasGdpr ? gdpr.consentString : ''; + if (hasGdpr && (!gdprConsentString || gdprConsentString === '')) { + logError('akamaiDapRtd submodule requires consent string to call API'); + consent = false; + } + } else if (userConsent && userConsent.usp) { + const usp = userConsent.usp; + consent = usp[1] !== 'N' && usp[2] !== 'Y'; + } + + return consent; + }, + /******************************************************************************* * * V2 (And Beyond) API @@ -293,23 +528,23 @@ export const dapUtils = { * function( response, status, xhr } { token = response; }, * function( xhr, status, error ) { ; } // handle error */ - dapTokenize: function(config, identity, onSuccess = null, onError = null) { + dapTokenize: function(config, identity, onDone, onSuccess = null, onError = null) { if (onError == null) { - onError = function(xhr, status, error) {}; + onError = function(xhr, status, error, onDone) {}; } if (config == null || typeof (config) == typeof (undefined)) { - onError(null, 'Invalid config object', 'ClientError'); + onError(null, 'Invalid config object', 'ClientError', onDone); return; } if (typeof (config.domain) != 'string') { - onError(null, 'Invalid config.domain: must be a string', 'ClientError'); + onError(null, 'Invalid config.domain: must be a string', 'ClientError', onDone); return; } if (config.domain.length <= 0) { - onError(null, 'Invalid config.domain: must have non-zero length', 'ClientError'); + onError(null, 'Invalid config.domain: must have non-zero length', 'ClientError', onDone); return; } @@ -318,22 +553,22 @@ export const dapUtils = { } if (typeof (config.api_version) != 'string') { - onError(null, "Invalid api_version: must be a string like 'x1', etc.", 'ClientError'); + onError(null, "Invalid api_version: must be a string like 'x1', etc.", 'ClientError', onDone); return; } if (!(('api_hostname') in config) || typeof (config.api_hostname) != 'string' || config.api_hostname.length == 0) { - onError(null, 'Invalid api_hostname: must be a non-empty string', 'ClientError'); + onError(null, 'Invalid api_hostname: must be a non-empty string', 'ClientError', onDone); return; } if (identity == null || typeof (identity) == typeof (undefined)) { - onError(null, 'Invalid identity object', 'ClientError'); + onError(null, 'Invalid identity object', 'ClientError', onDone); return; } if (!('type' in identity) || typeof (identity.type) != 'string' || identity.type.length <= 0) { - onError(null, "Identity must contain a valid 'type' field", 'ClientError'); + onError(null, "Identity must contain a valid 'type' field", 'ClientError', onDone); return; } @@ -348,6 +583,11 @@ export const dapUtils = { apiParams.attributes = identity.attributes; } + let entropyDict = JSON.parse(storage.getDataFromLocalStorage(DAP_CLIENT_ENTROPY)); + if (entropyDict && entropyDict.entropy) { + apiParams.entropy = entropyDict.entropy; + } + let method; let body; let path; @@ -359,10 +599,16 @@ export const dapUtils = { body = JSON.stringify(apiParams); break; default: - onError(null, 'Invalid api_version: ' + config.api_version, 'ClientError'); + onError(null, 'Invalid api_version: ' + config.api_version, 'ClientError', onDone); return; } + let customHeaders = {'Content-Type': 'application/json'}; + let dapSSID = JSON.parse(storage.getDataFromLocalStorage(DAP_SS_ID)); + if (dapSSID) { + customHeaders['Akamai-DAP-SS-ID'] = dapSSID; + } + let url = 'https://' + config.api_hostname + path; let cb = { success: (response, request) => { @@ -373,19 +619,16 @@ export const dapUtils = { token = request.getResponseHeader('Akamai-DAP-Token'); break; } - onSuccess(token, request.status, request); + onSuccess(token, request.status, request, onDone); }, error: (request, error) => { - onError(request, request.statusText, error); + onError(request, request.statusText, error, onDone); } }; ajax(url, cb, body, { method: method, - customHeaders: { - 'Content-Type': 'application/json', - 'Pragma': 'akamai-x-cache-on' - } + customHeaders: customHeaders }); }, @@ -411,7 +654,7 @@ export const dapUtils = { * api_hostname: 'api.dap.akadns.net', * }; * - * // token from dap_x1_tokenize + * // token from dap_tokenize * * dapMembership( config, token, * function( membership, status, xhr ) { @@ -422,13 +665,13 @@ export const dapUtils = { * } ); * */ - dapMembership: function(config, token, onSuccess = null, onError = null) { + dapMembership: function(config, token, onDone, onSuccess = null, onError = null) { if (onError == null) { - onError = function(xhr, status, error) {}; + onError = function(xhr, status, error, onDone) {}; } if (config == null || typeof (config) == typeof (undefined)) { - onError(null, 'Invalid config object', 'ClientError'); + onError(null, 'Invalid config object', 'ClientError', onDone); return; } @@ -437,32 +680,32 @@ export const dapUtils = { } if (typeof (config.api_version) != 'string') { - onError(null, "Invalid api_version: must be a string like 'x1', etc.", 'ClientError'); + onError(null, "Invalid api_version: must be a string like 'x1', etc.", 'ClientError', onDone); return; } if (!(('api_hostname') in config) || typeof (config.api_hostname) != 'string' || config.api_hostname.length == 0) { - onError(null, 'Invalid api_hostname: must be a non-empty string', 'ClientError'); + onError(null, 'Invalid api_hostname: must be a non-empty string', 'ClientError', onDone); return; } if (token == null || typeof (token) != 'string') { - onError(null, 'Invalid token: must be a non-null string', 'ClientError'); + onError(null, 'Invalid token: must be a non-null string', 'ClientError', onDone); return; } let path = '/data-activation/' + - config.api_version + - '/token/' + token + - '/membership'; + config.api_version + + '/token/' + token + + '/membership'; let url = 'https://' + config.api_hostname + path; let cb = { success: (response, request) => { - onSuccess(JSON.parse(response), request.status, request); + onSuccess(JSON.parse(response), request.status, request, onDone); }, error: (error, request) => { - onError(request, request.status, error); + onError(request, request.status, error, onDone); } }; @@ -470,5 +713,91 @@ export const dapUtils = { method: 'GET', customHeaders: {} }); + }, + + /** + * SYNOPSIS + * + * dapEncryptedMembership( config, token, onSuccess, onError ); + * + * DESCRIPTION + * + * Return the audience segment membership along with a new Secure Advertising + * ID for this token in encrypted format. + * + * PARAMETERS + * + * config: an array of system configuration parameters + * + * token: the token previously returned from the tokenize API + * + * EXAMPLE + * + * config = { + * api_hostname: 'api.dap.akadns.net', + * }; + * + * // token from dap_tokenize + * + * dapEncryptedMembership( config, token, + * function( membership, status, xhr ) { + * // Run auction with membership.segments and membership.said after decryption + * }, + * function( xhr, status, error ) { + * // error + * } ); + * + */ + dapEncryptedMembership: function(config, token, onDone, onSuccess = null, onError = null) { + if (onError == null) { + onError = function(xhr, status, error, onDone) {}; + } + + if (config == null || typeof (config) == typeof (undefined)) { + onError(null, 'Invalid config object', 'ClientError', onDone); + return; + } + + if (!('api_version' in config) || (typeof (config.api_version) == 'string' && config.api_version.length == 0)) { + config.api_version = 'x1'; + } + + if (typeof (config.api_version) != 'string') { + onError(null, "Invalid api_version: must be a string like 'x1', etc.", 'ClientError', onDone); + return; + } + + if (!(('api_hostname') in config) || typeof (config.api_hostname) != 'string' || config.api_hostname.length == 0) { + onError(null, 'Invalid api_hostname: must be a non-empty string', 'ClientError', onDone); + return; + } + + if (token == null || typeof (token) != 'string') { + onError(null, 'Invalid token: must be a non-null string', 'ClientError', onDone); + return; + } + let path = '/data-activation/' + + config.api_version + + '/token/' + token + + '/membership/encrypt'; + + let url = 'https://' + config.api_hostname + path; + + let cb = { + success: (response, request) => { + let encToken = request.getResponseHeader('Akamai-DAP-Token'); + onSuccess(encToken, request.status, request, onDone); + }, + error: (error, request) => { + onError(request, request.status, error, onDone); + } + }; + ajax(url, cb, undefined, { + method: 'GET', + customHeaders: { + 'Content-Type': 'application/json', + 'Pragma': 'akamai-x-get-extracted-values' + } + }); } } diff --git a/modules/akamaiDapRtdProvider.md b/modules/akamaiDapRtdProvider.md index ade11b88602..efd93db3a51 100644 --- a/modules/akamaiDapRtdProvider.md +++ b/modules/akamaiDapRtdProvider.md @@ -17,6 +17,7 @@ ``` pbjs.setConfig({ realTimeData: { + auctionDelay: 2000, dataProviders: [ { name: "dap", @@ -25,9 +26,10 @@ apiHostname: '', apiVersion: "x1", domain: 'your-domain.com', - identityType: 'email' | 'mobile' | ... | 'dap-signature:1.0.0', - segtax: , - tokenTtl: 5, + identityType: 'email' | 'mobile' | ... | 'dap-signature:1.3.0', + segtax: 504, + dapEntropyUrl: 'https://dap-dist.akamaized.net/dapentropy.js', + dapEntropyTimeout: 1500 // Maximum time for dapentropy to run } } ] diff --git a/modules/alkimiBidAdapter.js b/modules/alkimiBidAdapter.js new file mode 100644 index 00000000000..81d993e9ac8 --- /dev/null +++ b/modules/alkimiBidAdapter.js @@ -0,0 +1,181 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {deepAccess, deepClone, getDNT, generateUUID} from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; +import {VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; + +const BIDDER_CODE = 'alkimi'; +const GVLID = 1169; +export const ENDPOINT = 'https://exchange.alkimi-onboarding.com/bid?prebid=true'; + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: ['banner', 'video'], + + isBidRequestValid: function (bid) { + return !!(bid.params && bid.params.token); + }, + + buildRequests: function (validBidRequests, bidderRequest) { + let bids = []; + let bidIds = []; + let eids; + validBidRequests.forEach(bidRequest => { + let formatTypes = getFormatType(bidRequest) + + if (bidRequest.userIdAsEids) { + eids = eids || bidRequest.userIdAsEids + } + + bids.push({ + token: bidRequest.params.token, + instl: bidRequest.params.instl, + exp: bidRequest.params.exp, + bidFloor: getBidFloor(bidRequest, formatTypes), + sizes: prepareSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')), + playerSizes: prepareSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')), + impMediaTypes: formatTypes, + adUnitCode: bidRequest.adUnitCode, + video: deepAccess(bidRequest, 'mediaTypes.video'), + banner: deepAccess(bidRequest, 'mediaTypes.banner') + }) + bidIds.push(bidRequest.bidId) + }) + + const alkimiConfig = config.getConfig('alkimi'); + + let payload = { + requestId: generateUUID(), + signRequest: {bids, randomUUID: alkimiConfig && alkimiConfig.randomUUID}, + bidIds, + referer: bidderRequest.refererInfo.page, + signature: alkimiConfig && alkimiConfig.signature, + schain: validBidRequests[0].schain, + cpp: config.getConfig('coppa') ? 1 : 0, + device: { + dnt: getDNT() ? 1 : 0, + w: screen.width, + h: screen.height + }, + ortb2: { + site: { + keywords: bidderRequest.ortb2?.site?.keywords + }, + at: bidderRequest.ortb2?.at, + bcat: bidderRequest.ortb2?.bcat, + wseat: bidderRequest.ortb2?.wseat + } + } + + if (bidderRequest && bidderRequest.gdprConsent) { + payload.gdprConsent = { + consentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : false, + consentString: bidderRequest.gdprConsent.consentString + } + } + + if (bidderRequest.uspConsent) { + payload.uspConsent = bidderRequest.uspConsent; + } + + if (eids) { + payload.eids = eids + } + + const options = { + contentType: 'application/json', + customHeaders: { + 'Rtb-Direct': true + } + } + + return { + method: 'POST', + url: ENDPOINT, + data: payload, + options + }; + }, + + interpretResponse: function (serverResponse, request) { + const serverBody = serverResponse.body; + if (!serverBody || typeof serverBody !== 'object') { + return []; + } + + const {prebidResponse} = serverBody; + if (!prebidResponse || typeof prebidResponse !== 'object') { + return []; + } + + let bids = []; + prebidResponse.forEach(bidResponse => { + let bid = deepClone(bidResponse); + bid.cpm = parseFloat(bidResponse.cpm); + + // banner or video + if (VIDEO === bid.mediaType) { + bid.vastXml = bid.ad; + } + + bid.meta = {}; + bid.meta.advertiserDomains = bid.adomain || []; + + bids.push(bid); + }) + + return bids; + }, + + onBidWon: function (bid) { + let winUrl; + if (bid.winUrl || bid.vastUrl) { + winUrl = bid.winUrl ? bid.winUrl : bid.vastUrl; + winUrl = winUrl.replace(/\$\{AUCTION_PRICE}/, bid.cpm); + } else if (bid.ad) { + let trackImg = bid.ad.match(/(?!^)/); + bid.ad = bid.ad.replace(trackImg[0], ''); + winUrl = trackImg[0].split('"')[1]; + winUrl = winUrl.replace(/\$%7BAUCTION_PRICE%7D/, bid.cpm); + } else { + return false; + } + + ajax(winUrl, null); + return true; + } +} + +function prepareSizes(sizes) { + return sizes ? sizes.map(size => ({width: size[0], height: size[1]})) : [] +} + +function prepareBidFloorSize(sizes) { + return sizes && sizes.length === 1 ? sizes : ['*']; +} + +function getBidFloor(bidRequest, formatTypes) { + let minFloor + if (typeof bidRequest.getFloor === 'function') { + const bidFloorSizes = prepareBidFloorSize(bidRequest.sizes) + formatTypes.forEach(formatType => { + bidFloorSizes.forEach(bidFloorSize => { + const floor = bidRequest.getFloor({currency: 'USD', mediaType: formatType.toLowerCase(), size: bidFloorSize}); + if (floor && !isNaN(floor.floor) && (floor.currency === 'USD')) { + minFloor = !minFloor || floor.floor < minFloor ? floor.floor : minFloor + } + }) + }) + } + return minFloor || bidRequest.params.bidFloor; +} + +const getFormatType = bidRequest => { + let formats = [] + if (deepAccess(bidRequest, 'mediaTypes.banner')) formats.push('Banner') + if (deepAccess(bidRequest, 'mediaTypes.video')) formats.push('Video') + return formats +} + +registerBidder(spec); diff --git a/modules/alkimiBidAdapter.md b/modules/alkimiBidAdapter.md new file mode 100644 index 00000000000..2d1fd42c70f --- /dev/null +++ b/modules/alkimiBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +``` +Module Name: Alkimi Bidder Adapter +Module Type: Bidder Adapter +Maintainer: kalidas@alkimiexchange.com +``` + +# Description + +Connects to Alkimi Bidder for bids. +Alkimi bid adapter supports Banner and Video ads. + +# Test Parameters +``` +const adUnits = [ + { + code: 'banner1', + mediaTypes: { + banner: { // Media Type can be banner or video or ... + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'alkimi', + params: { + bidFloor: 0.5, + token: 'a6b042a5-2d68-4170-a051-77fbaf00203a', // Publisher Token(Id) provided by Alkimi + } + } + ] + } +] +``` diff --git a/modules/allowActivities.js b/modules/allowActivities.js new file mode 100644 index 00000000000..6af7eb36a62 --- /dev/null +++ b/modules/allowActivities.js @@ -0,0 +1,74 @@ +import {config} from '../src/config.js'; +import {registerActivityControl} from '../src/activities/rules.js'; + +const CFG_NAME = 'allowActivities'; +const RULE_NAME = `${CFG_NAME} config`; +const DEFAULT_PRIORITY = 1; + +export function updateRulesFromConfig(registerRule) { + const activeRuleHandles = new Map(); + const defaultRuleHandles = new Map(); + const rulesByActivity = new Map(); + + function clearAllRules() { + rulesByActivity.clear(); + Array.from(activeRuleHandles.values()) + .flatMap(ruleset => Array.from(ruleset.values())) + .forEach(fn => fn()); + activeRuleHandles.clear(); + Array.from(defaultRuleHandles.values()).forEach(fn => fn()); + defaultRuleHandles.clear(); + } + + function cleanParams(params) { + // remove private parameters for publisher condition checks + return Object.fromEntries(Object.entries(params).filter(([k]) => !k.startsWith('_'))) + } + + function setupRule(activity, priority) { + if (!activeRuleHandles.has(activity)) { + activeRuleHandles.set(activity, new Map()) + } + const handles = activeRuleHandles.get(activity); + if (!handles.has(priority)) { + handles.set(priority, registerRule(activity, RULE_NAME, function (params) { + for (const rule of rulesByActivity.get(activity).get(priority)) { + if (!rule.condition || rule.condition(cleanParams(params))) { + return {allow: rule.allow, reason: rule} + } + } + }, priority)); + } + } + + function setupDefaultRule(activity) { + if (!defaultRuleHandles.has(activity)) { + defaultRuleHandles.set(activity, registerRule(activity, RULE_NAME, function () { + return {allow: false, reason: 'activity denied by default'} + }, Number.POSITIVE_INFINITY)) + } + } + + config.getConfig(CFG_NAME, (cfg) => { + clearAllRules(); + Object.entries(cfg[CFG_NAME]).forEach(([activity, activityCfg]) => { + if (activityCfg.default === false) { + setupDefaultRule(activity); + } + const rules = new Map(); + rulesByActivity.set(activity, rules); + + (activityCfg.rules || []).forEach(rule => { + const priority = rule.priority == null ? DEFAULT_PRIORITY : rule.priority; + if (!rules.has(priority)) { + rules.set(priority, []) + } + rules.get(priority).push(rule); + }); + + Array.from(rules.keys()).forEach(priority => setupRule(activity, priority)); + }); + }) +} + +updateRulesFromConfig(registerActivityControl); diff --git a/modules/amxBidAdapter.js b/modules/amxBidAdapter.js index d1754936d7f..a773ac70559 100644 --- a/modules/amxBidAdapter.js +++ b/modules/amxBidAdapter.js @@ -1,47 +1,48 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { parseUrl, deepAccess, _each, formatQS, getUniqueIdentifierStr, triggerPixel, isFn, logError } from '../src/utils.js'; +import { + _each, + deepAccess, + formatQS, + getUniqueIdentifierStr, + isArray, + isFn, + logError, + parseUrl, + triggerPixel, + generateUUID, +} from '../src/utils.js'; import { config } from '../src/config.js'; import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'amx'; -const storage = getStorageManager({gvlid: 737, bidderCode: BIDDER_CODE}); +const storage = getStorageManager({ bidderCode: BIDDER_CODE }); const SIMPLE_TLD_TEST = /\.com?\.\w{2,4}$/; const DEFAULT_ENDPOINT = 'https://prebid.a-mo.net/a/c'; -const VERSION = 'pba1.3.1'; +const VERSION = 'pba1.3.3'; const VAST_RXP = /^\s*<\??(?:vast|xml)/i; const TRACKING_ENDPOINT = 'https://1x1.a-mo.net/hbx/'; const AMUID_KEY = '__amuidpb'; -function getLocation (request) { - const refInfo = request.refererInfo; - if (refInfo == null) { - return parseUrl(location.href); - } - - if (refInfo.isAmp && refInfo.referer != null) { - return parseUrl(refInfo.referer) - } - - const topUrl = refInfo.numIframes > 0 && refInfo.stack[0] != null - ? refInfo.stack[0] : location.href; - return parseUrl(topUrl); -}; +function getLocation(request) { + return parseUrl(request.refererInfo?.topmostLocation || window.location.href); +} const largestSize = (sizes, mediaTypes) => { const allSizes = sizes .concat(deepAccess(mediaTypes, `${BANNER}.sizes`, []) || []) - .concat(deepAccess(mediaTypes, `${VIDEO}.sizes`, []) || []) + .concat(deepAccess(mediaTypes, `${VIDEO}.sizes`, []) || []); - return allSizes.sort((a, b) => (b[0] * b[1]) - (a[0] * a[1]))[0]; -} + return allSizes.sort((a, b) => b[0] * b[1] - a[0] * a[1])[0]; +}; function flatMap(input, mapFn) { if (input == null) { - return [] + return []; } - return input.map(mapFn) - .reduce((acc, item) => item != null && acc.concat(item), []) + return input + .map(mapFn) + .reduce((acc, item) => item != null && acc.concat(item), []); } const isVideoADM = (html) => html != null && VAST_RXP.test(html); @@ -54,14 +55,13 @@ function getMediaType(bid) { return BANNER; } -const nullOrType = (value, type) => - value == null || (typeof value) === type // eslint-disable-line valid-typeof +const nullOrType = (value, type) => value == null || typeof value === type; // eslint-disable-line valid-typeof function getID(loc) { const host = loc.hostname.split('.'); - const short = host.slice( - host.length - (SIMPLE_TLD_TEST.test(loc.hostname) ? 3 : 2) - ).join('.'); + const short = host + .slice(host.length - (SIMPLE_TLD_TEST.test(loc.hostname) ? 3 : 2)) + .join('.'); return btoa(short).replace(/=+$/, ''); } @@ -69,21 +69,21 @@ const enc = encodeURIComponent; function getUIDSafe() { try { - return storage.getDataFromLocalStorage(AMUID_KEY) + return storage.getDataFromLocalStorage(AMUID_KEY); } catch (e) { - return null + return null; } } function setUIDSafe(uid) { try { - storage.setDataInLocalStorage(AMUID_KEY, uid) + storage.setDataInLocalStorage(AMUID_KEY, uid); } catch (e) { // do nothing } } -function nestedQs (qsData) { +function nestedQs(qsData) { const out = []; Object.keys(qsData || {}).forEach((key) => { out.push(enc(key) + '=' + enc(String(qsData[key]))); @@ -95,23 +95,28 @@ function nestedQs (qsData) { function createBidMap(bids) { const out = {}; _each(bids, (bid) => { - out[bid.bidId] = convertRequest(bid) - }) + out[bid.bidId] = convertRequest(bid); + }); return out; } const trackEvent = (eventName, data) => - triggerPixel(`${TRACKING_ENDPOINT}g_${eventName}?${formatQS({ - ...data, - ts: Date.now(), - eid: getUniqueIdentifierStr(), - })}`); + triggerPixel( + `${TRACKING_ENDPOINT}g_${eventName}?${formatQS({ + ...data, + ts: Date.now(), + eid: getUniqueIdentifierStr(), + })}` + ); const DEFAULT_MIN_FLOOR = 0; function ensureFloor(floorValue) { - return typeof floorValue === 'number' && isFinite(floorValue) && floorValue > 0.0 - ? floorValue : DEFAULT_MIN_FLOOR; + return typeof floorValue === 'number' && + isFinite(floorValue) && + floorValue > 0.0 + ? floorValue + : DEFAULT_MIN_FLOOR; } function getFloor(bid) { @@ -124,7 +129,7 @@ function getFloor(bid) { currency: 'USD', mediaType: '*', size: '*', - bidRequest: bid + bidRequest: bid, }); return floor.floor; } catch (e) { @@ -133,14 +138,20 @@ function getFloor(bid) { } } +function refInfo(bidderRequest, subKey, defaultValue) { + return deepAccess(bidderRequest, 'refererInfo.' + subKey, defaultValue); +} + function convertRequest(bid) { const size = largestSize(bid.sizes, bid.mediaTypes) || [0, 0]; - const isVideoBid = bid.mediaType === VIDEO || VIDEO in bid.mediaTypes + const isVideoBid = bid.mediaType === VIDEO || VIDEO in bid.mediaTypes; const av = isVideoBid || size[1] > 100; - const tid = deepAccess(bid, 'params.tagId') + const tid = deepAccess(bid, 'params.tagId'); - const au = bid.params != null && typeof bid.params.adUnitId === 'string' - ? bid.params.adUnitId : bid.adUnitCode; + const au = + bid.params != null && typeof bid.params.adUnitId === 'string' && bid.params.adUnitId !== '' + ? bid.params.adUnitId + : bid.adUnitCode; const multiSizes = [ bid.sizes, @@ -160,7 +171,8 @@ function convertRequest(bid) { ah: size[1], tf: 0, sc: bid.schain || {}, - f: ensureFloor(getFloor(bid)) + f: ensureFloor(getFloor(bid)), + rtb: bid.ortb2Imp, }; if (typeof tid === 'string' && tid.length > 0) { @@ -169,15 +181,6 @@ function convertRequest(bid) { return params; } -function decorateADM(bid) { - const impressions = deepAccess(bid, 'ext.himp', []) - .concat(bid.nurl != null ? [bid.nurl] : []) - .filter((imp) => imp != null && imp.length > 0) - .map((src) => ``) - .join(''); - return bid.adm + impressions; -} - function resolveSize(bid, request, bidId) { if (bid.w != null && bid.w > 1 && bid.h != null && bid.h > 1) { return [bid.w, bid.h]; @@ -191,40 +194,117 @@ function resolveSize(bid, request, bidId) { return [bidRequest.aw, bidRequest.ah]; } +function isSyncEnabled(syncConfigP, syncType) { + if (syncConfigP == null) return false; + + const syncConfig = syncConfigP[syncType]; + if (syncConfig == null) { + return false; + } + + if (syncConfig.bidders === '*' || (isArray(syncConfig.bidders) && syncConfig.bidders.indexOf('amx') !== -1)) { + return syncConfig.filter == null || syncConfig.filter === 'include'; + } + + return false; +} + +const SYNC_IMAGE = 1; +const SYNC_IFRAME = 2; + +function getSyncSettings() { + const syncConfig = config.getConfig('userSync'); + if (syncConfig == null) { + return { + d: 0, + l: 0, + t: 0, + e: true + }; + } + + const settings = { d: syncConfig.syncDelay, l: syncConfig.syncsPerBidder, t: 0, e: syncConfig.syncEnabled } + const all = isSyncEnabled(syncConfig.filterSettings, 'all') + + if (all) { + settings.t = SYNC_IMAGE & SYNC_IFRAME; + return settings; + } + + if (isSyncEnabled(syncConfig.filterSettings, 'iframe')) { + settings.t |= SYNC_IFRAME; + } + if (isSyncEnabled(syncConfig.filterSettings, 'image')) { + settings.t |= SYNC_IMAGE; + } + + return settings; +} + function values(source) { if (Object.values != null) { - return Object.values(source) + return Object.values(source); } return Object.keys(source).map((key) => { - return source[key] + return source[key]; }); } +function getGpp(bidderRequest) { + if (bidderRequest?.gppConsent != null) { + return bidderRequest.gppConsent; + } + + return bidderRequest?.ortb2?.regs?.gpp ?? { gppString: '', applicableSections: '' }; +} + +function buildReferrerInfo(bidderRequest) { + if (bidderRequest.refererInfo == null) { + return { r: '', t: false, c: '', l: 0, s: [] } + } + + const re = bidderRequest.refererInfo; + + return { + r: re.topmostLocation, + t: re.reachedTop, + l: re.numIframes, + s: re.stack, + c: re.canonicalUrl, + } +} + const isTrue = (boolValue) => boolValue === true || boolValue === 1 || boolValue === 'true'; export const spec = { code: BIDDER_CODE, + gvlid: 737, supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid(bid) { - return nullOrType(deepAccess(bid, 'params.endpoint', null), 'string') && + return ( + nullOrType(deepAccess(bid, 'params.endpoint', null), 'string') && nullOrType(deepAccess(bid, 'params.tagId', null), 'string') + ); }, buildRequests(bidRequests, bidderRequest) { const loc = getLocation(bidderRequest); const tagId = deepAccess(bidRequests[0], 'params.tagId', null); const testMode = deepAccess(bidRequests[0], 'params.testMode', 0); - const fbid = bidRequests[0] != null ? bidRequests[0] : { - bidderRequestsCount: 0, - bidderWinsCount: 0, - bidRequestsCount: 0 - } + const fbid = + bidRequests[0] != null + ? bidRequests[0] + : { + bidderRequestsCount: 0, + bidderWinsCount: 0, + bidRequestsCount: 0, + }; const payload = { - a: bidderRequest.auctionId, + a: generateUUID(), B: 0, b: loc.host, brc: fbid.bidderRequestsCount || 0, @@ -233,7 +313,7 @@ export const spec = { tm: isTrue(testMode), V: '$prebid.version$', vg: '$$PREBID_GLOBAL$$', - i: (testMode && tagId != null) ? tagId : getID(loc), + i: testMode && tagId != null ? tagId : getID(loc), l: {}, f: 0.01, cv: VERSION, @@ -242,31 +322,37 @@ export const spec = { w: screen.width, gs: deepAccess(bidderRequest, 'gdprConsent.gdprApplies', ''), gc: deepAccess(bidderRequest, 'gdprConsent.consentString', ''), - u: deepAccess(bidderRequest, 'refererInfo.canonicalUrl', loc.href), - do: loc.hostname, - re: deepAccess(bidderRequest, 'refererInfo.referer'), + gpp: getGpp(bidderRequest), + u: refInfo(bidderRequest, 'page', loc.href), + do: refInfo(bidderRequest, 'site', loc.hostname), + re: refInfo(bidderRequest, 'ref'), am: getUIDSafe(), usp: bidderRequest.uspConsent || '1---', smt: 1, d: '', m: createBidMap(bidRequests), cpp: config.getConfig('coppa') ? 1 : 0, - fpd2: config.getConfig('ortb2'), - tmax: config.getConfig('bidderTimeout'), - eids: values(bidRequests.reduce((all, bid) => { - // we only want unique ones in here - if (bid == null || bid.userIdAsEids == null) { - return all - } - - _each(bid.userIdAsEids, (value) => { - if (value == null) { - return; + fpd2: bidderRequest.ortb2, + tmax: bidderRequest.timeout, + amp: refInfo(bidderRequest, 'isAmp', null), + ri: buildReferrerInfo(bidderRequest), + sync: getSyncSettings(), + eids: values( + bidRequests.reduce((all, bid) => { + // we only want unique ones in here + if (bid == null || bid.userIdAsEids == null) { + return all; } - all[value.source] = value - }); - return all; - }, {})), + + _each(bid.userIdAsEids, (value) => { + if (value == null) { + return; + } + all[value.source] = value; + }); + return all; + }, {}) + ), }; return { @@ -277,16 +363,38 @@ export const spec = { }; }, - getUserSyncs(syncOptions, serverResponses) { + getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { + const qp = { + gdpr_consent: enc(gdprConsent?.consentString || ''), + gdpr: enc(gdprConsent?.gdprApplies ? 1 : 0), + us_privacy: enc(uspConsent || ''), + gpp: enc(gppConsent?.gppString || ''), + gpp_sid: enc(gppConsent?.applicableSections || '') + }; + + const iframeSync = { + url: `https://prebid.a-mo.net/isyn?${formatQS(qp)}`, + type: 'iframe' + }; + if (serverResponses == null || serverResponses.length === 0) { - return [] + if (syncOptions.iframeEnabled) { + return [iframeSync] + } + + return []; } - const output = [] - _each(serverResponses, function ({ body: response }) { + + const output = []; + let hasFrame = false; + + _each(serverResponses, function({ body: response }) { if (response != null && response.p != null && response.p.hreq) { - _each(response.p.hreq, function (syncPixel) { - const pixelType = syncPixel.indexOf('__st=iframe') !== -1 ? 'iframe' : 'image'; + _each(response.p.hreq, function(syncPixel) { + const pixelType = + syncPixel.indexOf('__st=iframe') !== -1 ? 'iframe' : 'image'; if (syncOptions.iframeEnabled || pixelType === 'image') { + hasFrame = hasFrame || (pixelType === 'iframe') || (syncPixel.indexOf('cchain') !== -1) output.push({ url: syncPixel, type: pixelType, @@ -295,6 +403,11 @@ export const spec = { }); } }); + + if (!hasFrame && output.length < 2) { + output.push(iframeSync) + } + return output; }, @@ -312,7 +425,7 @@ export const spec = { return flatMap(response.r[bidID], (siteBid) => siteBid.b.map((bid) => { const mediaType = getMediaType(bid); - const ad = mediaType === BANNER ? decorateADM(bid) : bid.adm; + const ad = bid.adm; if (ad == null) { return null; @@ -321,7 +434,7 @@ export const spec = { const size = resolveSize(bid, request.data, bidID); const defaultExpiration = mediaType === BANNER ? 240 : 300; - return ({ + return { requestId: bidID, cpm: bid.price, width: size[0], @@ -336,8 +449,9 @@ export const spec = { }, mediaType, ttl: typeof bid.exp === 'number' ? bid.exp : defaultExpiration, - }); - })).filter((possibleBid) => possibleBid != null); + }; + }) + ).filter((possibleBid) => possibleBid != null); }); }, @@ -369,7 +483,6 @@ export const spec = { bid: timeoutData.bidId, a: timeoutData.adUnitCode, cn: timeoutData.timeout, - aud: timeoutData.auctionId, }); }, diff --git a/modules/amxIdSystem.js b/modules/amxIdSystem.js index 28323b01188..184eff76c34 100644 --- a/modules/amxIdSystem.js +++ b/modules/amxIdSystem.js @@ -5,33 +5,30 @@ * @module modules/amxIdSystem * @requires module:modules/userId */ -import { uspDataHandler } from '../src/adapterManager.js'; -import { ajaxBuilder } from '../src/ajax.js'; -import { submodule } from '../src/hook.js'; -import { getRefererInfo } from '../src/refererDetection.js'; -import { deepAccess, getWindowTop, logError } from '../src/utils.js'; +import {uspDataHandler} from '../src/adapterManager.js'; +import {ajaxBuilder} from '../src/ajax.js'; +import {submodule} from '../src/hook.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {deepAccess, logError} from '../src/utils.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import {domainOverrideToRootDomain} from '../libraries/domainOverrideToRootDomain/index.js'; const NAME = 'amxId'; const GVL_ID = 737; const ID_KEY = NAME; -const version = '1.0'; +const version = '2.0'; const SYNC_URL = 'https://id.a-mx.com/sync/'; const AJAX_TIMEOUT = 300; +const AJAX_OPTIONS = {method: 'GET', withCredentials: true, contentType: 'text/plain'}; -function validateConfig(config) { - if (config == null || config.storage == null) { - logError(`${NAME}: config.storage is required.`); - return false; - } - - if (config.storage.type !== 'html5') { - logError( - `${NAME} only supports storage.type "html5". ${config.storage.type} was provided` - ); - return false; - } +export const storage = getStorageManager({moduleName: NAME, moduleType: MODULE_TYPE_UID}); +const AMUID_KEY = '__amuidpb'; +const getBidAdapterID = () => storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(AMUID_KEY) : null; +function validateConfig(config) { if ( + config.storage != null && typeof config.storage.expires === 'number' && config.storage.expires > 30 ) { @@ -44,7 +41,7 @@ function validateConfig(config) { return true; } -function handleSyncResponse(client, response, callback) { +function handleSyncResponse(client, response, params, callback) { if (response.id != null && response.id.length > 0) { callback(response.id); return; @@ -72,7 +69,7 @@ function handleSyncResponse(client, response, callback) { logError(`${NAME} invalid value`, complete); callback(null); }, - }); + }, params, AJAX_OPTIONS); } export const amxIdSubmodule = { @@ -97,6 +94,8 @@ export const amxIdSubmodule = { ? { [ID_KEY]: value } : undefined, + domainOverride: domainOverrideToRootDomain(storage, NAME), + getId(config, consentData, _extant) { if (!validateConfig(config)) { return undefined; @@ -109,11 +108,18 @@ export const amxIdSubmodule = { const params = { tagId: deepAccess(config, 'params.tagId', ''), - ref: ref.referer, - u: ref.stack[0] || getWindowTop().location.href, + + ref: ref.ref, + u: ref.location, + tl: ref.topmostLocation, + nf: ref.numIframes, + rt: ref.reachedTop, + v: '$prebid.version$', + av: version, vg: '$$PREBID_GLOBAL$$', us_privacy: usp, + am: getBidAdapterID(), gdpr: consent.gdprApplies ? 1 : 0, gdpr_consent: consent.consentString, }; @@ -130,7 +136,7 @@ export const amxIdSubmodule = { if (responseText != null && responseText.length > 0) { try { const parsed = JSON.parse(responseText); - handleSyncResponse(client, parsed, done); + handleSyncResponse(client, parsed, params, done); return; } catch (e) { logError(`${NAME} invalid response`, responseText); @@ -141,13 +147,17 @@ export const amxIdSubmodule = { }, }, params, - { - method: 'GET' - } + AJAX_OPTIONS ); return { callback }; }, + eids: { + amxId: { + source: 'amxdt.net', + atype: 1, + }, + } }; submodule('userId', amxIdSubmodule); diff --git a/modules/amxIdSystem.md b/modules/amxIdSystem.md index 9de93c761a1..5d2b0c48478 100644 --- a/modules/amxIdSystem.md +++ b/modules/amxIdSystem.md @@ -1,6 +1,6 @@ -# AMX RTB ID +# AMX ID -For help adding this module, please contact [prebid@amxrtb.com](prebid@amxrtb.com). +For help adding this module, please contact [info@amxdt.net](info@amxdt.net). ### Prebid Configuration @@ -29,23 +29,15 @@ pbjs.setConfig({ | Param under `userSync.userIds[]` | Scope | Type | Description | Example | | -------------------------------- | -------- | ------ | --------------------------- | ----------------------------------------- | | name | Required | string | ID for the amxId module | `"amxId"` | -| storage | Required | Object | Settings for amxId storage | See [storage settings](#storage-settings) | +| storage | Optional | Object | Settings for amxId storage | See [storage settings](#storage-settings) | | params | Optional | Object | Parameters for amxId module | See [params](#params) | ### Storage Settings -The following settings are available for the `storage` property in the `userSync.userIds[]` object: +The following settings are suggested for the `storage` property in the `userSync.userIds[]` object: -| Param under `storage` | Scope | Type | Description | Example | -| --------------------- | -------- | ------------ | -------------------------------------------------------------------------------- | --------- | -| name | Required | String | Where the ID will be stored | `"amxId"` | -| type | Required | String | This must be `"html5"` | `"html5"` | -| expires | Required | Number <= 30 | number of days until the stored ID expires. **Must be less than or equal to 30** | `14` | - -### Params - -The following options are available in the `params` property in `userSync.userIds[]`: - -| Param under `params` | Scope | Type | Description | Example | -| -------------------- | -------- | ------ | ------------------------------------------------------------------------- | ---------------- | -| tagId | Optional | String | Your AMX tagId (optional) | `cHJlYmlkLm9yZw` | +| Param under `storage` | Type | Description | Example | +| --------------------- | ------------ | -------------------------------------------------------------------------------- | --------- | +| name | String | Where the ID will be stored | `"amxId"` | +| type | String | For best performance, this should be `"html5"` | `"html5"` | +| expires | Number <= 30 | number of days until the stored ID expires. **Must be less than or equal to 30** | `14` | diff --git a/modules/aniviewBidAdapter.js b/modules/aniviewBidAdapter.js index 7760aa2b47b..84552638421 100644 --- a/modules/aniviewBidAdapter.js +++ b/modules/aniviewBidAdapter.js @@ -106,11 +106,8 @@ function buildRequests(validBidRequests, bidderRequest) { if (s2sParams.AV_APPPKGNAME && !s2sParams.AV_URL) { s2sParams.AV_URL = s2sParams.AV_APPPKGNAME; } if (!s2sParams.AV_IDFA && !s2sParams.AV_URL) { - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - s2sParams.AV_URL = bidderRequest.refererInfo.referer; - } else { - s2sParams.AV_URL = window.location.href; - } + // TODO: does it make sense to fall back to window.location here? + s2sParams.AV_URL = bidderRequest?.refererInfo?.page || window.location.href; } if (s2sParams.AV_IDFA && !s2sParams.AV_AID) { s2sParams.AV_AID = s2sParams.AV_IDFA; } if (s2sParams.AV_AID && !s2sParams.AV_IDFA) { s2sParams.AV_IDFA = s2sParams.AV_AID; } @@ -206,7 +203,7 @@ function interpretResponse(serverResponse, bidRequest) { let xml = new window.DOMParser().parseFromString(xmlStr, 'text/xml'); if (xml && xml.getElementsByTagName('parsererror').length == 0) { let cpmData = getCpmData(xml); - if (cpmData && cpmData.cpm > 0) { + if (cpmData.cpm > 0) { bidResponse.requestId = bidRequest.data.bidId; bidResponse.ad = ''; bidResponse.cpm = cpmData.cpm; @@ -309,7 +306,7 @@ function getUserSyncs(syncOptions, serverResponses) { export const spec = { code: BIDDER_CODE, gvlid: GVLID, - aliases: ['avantisvideo', 'selectmediavideo', 'vidcrunch', 'openwebvideo', 'didnavideo', 'ottadvisors'], + aliases: ['avantisvideo', 'selectmediavideo', 'vidcrunch', 'openwebvideo', 'didnavideo', 'ottadvisors', 'pgammedia'], supportedMediaTypes: [VIDEO, BANNER], isBidRequestValid, buildRequests, diff --git a/modules/aolBidAdapter.js b/modules/aolBidAdapter.js deleted file mode 100644 index c9f64ab66b0..00000000000 --- a/modules/aolBidAdapter.js +++ /dev/null @@ -1,427 +0,0 @@ -import { isInteger, logError, isEmpty, logWarn, getUniqueIdentifierStr, _each, deepSetValue } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; - -const AOL_BIDDERS_CODES = { - AOL: 'aol', - VERIZON: 'verizon', - ONEMOBILE: 'onemobile', - ONEDISPLAY: 'onedisplay' -}; - -const AOL_ENDPOINTS = { - DISPLAY: { - GET: 'display-get' - }, - MOBILE: { - GET: 'mobile-get', - POST: 'mobile-post' - } -}; - -const SYNC_TYPES = { - IFRAME: { - TAG: 'iframe', - TYPE: 'iframe' - }, - IMAGE: { - TAG: 'img', - TYPE: 'image' - } -}; - -const SUPPORTED_USER_ID_SOURCES = [ - 'adserver.org', - 'criteo.com', - 'id5-sync.com', - 'intentiq.com', - 'liveintent.com', - 'quantcast.com', - 'verizonmedia.com', - 'liveramp.com', - 'yahoo.com' -]; - -const pubapiTemplate = template`${'host'}/pubapi/3.0/${'network'}/${'placement'}/${'pageid'}/${'sizeid'}/ADTECH;v=2;cmd=bid;cors=yes;alias=${'alias'};misc=${'misc'};${'dynamicParams'}`; -const nexageBaseApiTemplate = template`${'host'}/bidRequest?`; -const nexageGetApiTemplate = template`dcn=${'dcn'}&pos=${'pos'}&cmd=bid${'dynamicParams'}`; -const MP_SERVER_MAP = { - us: 'adserver-us.adtech.advertising.com', - eu: 'adserver-eu.adtech.advertising.com', - as: 'adserver-as.adtech.advertising.com' -}; -const NEXAGE_SERVER = 'c2shb.ssp.yahoo.com'; -const ONE_DISPLAY_TTL = 60; -const ONE_MOBILE_TTL = 3600; -const DEFAULT_PROTO = 'https'; - -const NUMERIC_VALUES = { - TRUE: 1, - FALSE: 0 -}; - -function template(strings, ...keys) { - return function (...values) { - let dict = values[values.length - 1] || {}; - let result = [strings[0]]; - keys.forEach(function (key, i) { - let value = isInteger(key) ? values[key] : dict[key]; - result.push(value, strings[i + 1]); - }); - return result.join(''); - }; -} - -function _isMarketplaceBidder(bidderCode) { - return bidderCode === AOL_BIDDERS_CODES.AOL || - bidderCode === AOL_BIDDERS_CODES.VERIZON || - bidderCode === AOL_BIDDERS_CODES.ONEDISPLAY; -} - -function _isOneMobileBidder(bidderCode) { - return bidderCode === AOL_BIDDERS_CODES.AOL || - bidderCode === AOL_BIDDERS_CODES.VERIZON || - bidderCode === AOL_BIDDERS_CODES.ONEMOBILE; -} - -function _isNexageRequestPost(bid) { - if (_isOneMobileBidder(bid.bidder) && bid.params.id && bid.params.imp && bid.params.imp[0]) { - let imp = bid.params.imp[0]; - return imp.id && imp.tagid && imp.banner && imp.banner.w && imp.banner.h; - } -} - -function _isNexageRequestGet(bid) { - return _isOneMobileBidder(bid.bidder) && bid.params.dcn && bid.params.pos; -} - -function isMarketplaceBid(bid) { - return _isMarketplaceBidder(bid.bidder) && bid.params.placement && bid.params.network; -} - -function isMobileBid(bid) { - return _isNexageRequestGet(bid) || _isNexageRequestPost(bid); -} - -function resolveEndpointCode(bid) { - if (_isNexageRequestGet(bid)) { - return AOL_ENDPOINTS.MOBILE.GET; - } else if (_isNexageRequestPost(bid)) { - return AOL_ENDPOINTS.MOBILE.POST; - } else if (isMarketplaceBid(bid)) { - return AOL_ENDPOINTS.DISPLAY.GET; - } -} - -function getSupportedEids(bid) { - return bid.userIdAsEids.filter(eid => { - return SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) !== -1 - }); -} - -export const spec = { - code: AOL_BIDDERS_CODES.AOL, - gvlid: 25, - aliases: [ - AOL_BIDDERS_CODES.ONEMOBILE, - AOL_BIDDERS_CODES.ONEDISPLAY, - AOL_BIDDERS_CODES.VERIZON - ], - supportedMediaTypes: [BANNER], - isBidRequestValid(bid) { - return isMarketplaceBid(bid) || isMobileBid(bid); - }, - buildRequests(bids, bidderRequest) { - const consentData = {}; - if (bidderRequest) { - consentData.gdpr = bidderRequest.gdprConsent; - consentData.uspConsent = bidderRequest.uspConsent; - } - - return bids.map(bid => { - const endpointCode = resolveEndpointCode(bid); - - if (endpointCode) { - return this.formatBidRequest(endpointCode, bid, consentData); - } - }); - }, - interpretResponse({ body }, bidRequest) { - if (!body) { - logError('Empty bid response', bidRequest.bidderCode, body); - } else { - let bid = this._parseBidResponse(body, bidRequest); - - if (bid) { - return bid; - } - } - }, - getUserSyncs(options, serverResponses) { - const bidResponse = !isEmpty(serverResponses) && serverResponses[0].body; - - if (bidResponse && bidResponse.ext && bidResponse.ext.pixels) { - return this.parsePixelItems(bidResponse.ext.pixels); - } - - return []; - }, - - formatBidRequest(endpointCode, bid, consentData) { - let bidRequest; - - switch (endpointCode) { - case AOL_ENDPOINTS.DISPLAY.GET: - bidRequest = { - url: this.buildMarketplaceUrl(bid, consentData), - method: 'GET', - ttl: ONE_DISPLAY_TTL - }; - break; - - case AOL_ENDPOINTS.MOBILE.GET: - bidRequest = { - url: this.buildOneMobileGetUrl(bid, consentData), - method: 'GET', - ttl: ONE_MOBILE_TTL - }; - break; - - case AOL_ENDPOINTS.MOBILE.POST: - bidRequest = { - url: this.buildOneMobileBaseUrl(bid), - method: 'POST', - ttl: ONE_MOBILE_TTL, - data: this.buildOpenRtbRequestData(bid, consentData), - options: { - contentType: 'application/json', - customHeaders: { - 'x-openrtb-version': '2.2' - } - } - }; - break; - } - - bidRequest.bidderCode = bid.bidder; - bidRequest.bidId = bid.bidId; - bidRequest.userSyncOn = bid.params.userSyncOn; - - return bidRequest; - }, - buildMarketplaceUrl(bid, consentData) { - const params = bid.params; - const serverParam = params.server; - let regionParam = params.region || 'us'; - let server; - - if (!MP_SERVER_MAP.hasOwnProperty(regionParam)) { - logWarn(`Unknown region '${regionParam}' for AOL bidder.`); - regionParam = 'us'; // Default region. - } - - if (serverParam) { - server = serverParam; - } else { - server = MP_SERVER_MAP[regionParam]; - } - - // Set region param, used by AOL analytics. - params.region = regionParam; - - return this.applyProtocol(pubapiTemplate({ - host: server, - network: params.network, - placement: parseInt(params.placement), - pageid: params.pageId || 0, - sizeid: params.sizeId || 0, - alias: params.alias || getUniqueIdentifierStr(), - misc: new Date().getTime(), // cache busting - dynamicParams: this.formatMarketplaceDynamicParams(params, consentData) - })); - }, - buildOneMobileGetUrl(bid, consentData) { - let { dcn, pos, ext } = bid.params; - if (typeof bid.userId === 'object') { - ext = ext || {}; - let eids = getSupportedEids(bid); - eids.forEach(eid => { - ext['eid' + eid.source] = eid.uids[0].id; - }); - } - let nexageApi = this.buildOneMobileBaseUrl(bid); - if (dcn && pos) { - let dynamicParams = this.formatOneMobileDynamicParams(ext, consentData); - nexageApi += nexageGetApiTemplate({ dcn, pos, dynamicParams }); - } - return nexageApi; - }, - buildOneMobileBaseUrl(bid) { - return this.applyProtocol(nexageBaseApiTemplate({ - host: bid.params.host || NEXAGE_SERVER - })); - }, - applyProtocol(url) { - if (/^https?:\/\//i.test(url)) { - return url; - } - return (url.indexOf('//') === 0) ? `${DEFAULT_PROTO}:${url}` : `${DEFAULT_PROTO}://${url}`; - }, - formatMarketplaceDynamicParams(params = {}, consentData = {}) { - let queryParams = {}; - - Object.assign(queryParams, this.formatKeyValues(params.keyValues)); - Object.assign(queryParams, this.formatConsentData(consentData)); - - let paramsFormatted = ''; - _each(queryParams, (value, key) => { - paramsFormatted += `${key}=${encodeURIComponent(value)};`; - }); - - return paramsFormatted; - }, - formatOneMobileDynamicParams(params = {}, consentData = {}) { - if (this.isSecureProtocol()) { - params.secure = NUMERIC_VALUES.TRUE; - } - - Object.assign(params, this.formatConsentData(consentData)); - - let paramsFormatted = ''; - _each(params, (value, key) => { - paramsFormatted += `&${key}=${encodeURIComponent(value)}`; - }); - - return paramsFormatted; - }, - buildOpenRtbRequestData(bid, consentData = {}) { - let openRtbObject = { - id: bid.params.id, - imp: bid.params.imp - }; - - if (this.isEUConsentRequired(consentData)) { - deepSetValue(openRtbObject, 'regs.ext.gdpr', NUMERIC_VALUES.TRUE); - if (consentData.gdpr.consentString) { - deepSetValue(openRtbObject, 'user.ext.consent', consentData.gdpr.consentString); - } - } - - if (consentData.uspConsent) { - deepSetValue(openRtbObject, 'regs.ext.us_privacy', consentData.uspConsent); - } - - if (typeof bid.userId === 'object') { - openRtbObject.user = openRtbObject.user || {}; - openRtbObject.user.ext = openRtbObject.user.ext || {}; - - let eids = getSupportedEids(bid); - if (eids.length > 0) { - openRtbObject.user.ext.eids = eids - } - } - - return openRtbObject; - }, - isEUConsentRequired(consentData) { - return !!(consentData && consentData.gdpr && consentData.gdpr.gdprApplies); - }, - formatKeyValues(keyValues) { - let keyValuesHash = {}; - - _each(keyValues, (value, key) => { - keyValuesHash[`kv${key}`] = value; - }); - - return keyValuesHash; - }, - formatConsentData(consentData) { - let params = {}; - - if (this.isEUConsentRequired(consentData)) { - params.gdpr = NUMERIC_VALUES.TRUE; - - if (consentData.gdpr.consentString) { - params.euconsent = consentData.gdpr.consentString; - } - } - - if (consentData.uspConsent) { - params.us_privacy = consentData.uspConsent; - } - - return params; - }, - parsePixelItems(pixels) { - let itemsRegExp = /(img|iframe)[\s\S]*?src\s*=\s*("|')(.*?)\2/gi; - let tagNameRegExp = /\w*(?=\s)/; - let srcRegExp = /src=("|')(.*?)\1/; - let pixelsItems = []; - - if (pixels) { - let matchedItems = pixels.match(itemsRegExp); - if (matchedItems) { - matchedItems.forEach(item => { - let tagName = item.match(tagNameRegExp)[0]; - let url = item.match(srcRegExp)[2]; - - if (tagName && url) { - pixelsItems.push({ - type: tagName === SYNC_TYPES.IMAGE.TAG ? SYNC_TYPES.IMAGE.TYPE : SYNC_TYPES.IFRAME.TYPE, - url: url - }); - } - }); - } - } - - return pixelsItems; - }, - - _parseBidResponse(response, bidRequest) { - let bidData; - - try { - bidData = response.seatbid[0].bid[0]; - } catch (e) { - return; - } - - let cpm; - - if (bidData.ext && bidData.ext.encp) { - cpm = bidData.ext.encp; - } else { - cpm = bidData.price; - - if (cpm === null || isNaN(cpm)) { - logError('Invalid price in bid response', AOL_BIDDERS_CODES.AOL, bidData); - return; - } - } - - return { - bidderCode: bidRequest.bidderCode, - requestId: bidRequest.bidId, - ad: bidData.adm, - cpm: cpm, - width: bidData.w, - height: bidData.h, - creativeId: bidData.crid || 0, - pubapiId: response.id, - currency: response.cur || 'USD', - dealId: bidData.dealid, - netRevenue: true, - meta: { - advertiserDomains: bidData && bidData.adomain ? bidData.adomain : [] - }, - ttl: bidRequest.ttl - }; - }, - isOneMobileBidder: _isOneMobileBidder, - isSecureProtocol() { - return document.location.protocol === 'https:'; - } -}; - -registerBidder(spec); diff --git a/modules/aolBidAdapter.md b/modules/aolBidAdapter.md deleted file mode 100644 index 8a9d1e3291d..00000000000 --- a/modules/aolBidAdapter.md +++ /dev/null @@ -1,46 +0,0 @@ -# Overview - -Module Name: AOL Bid Adapter - -Module Type: AOL Adapter - -Maintainer: hb-fe-tech@oath.com - -# Description - -Module that connects to AOL's demand sources - -# Test Parameters -```javascript - var adUnits = [ - { - code: 'test-ad', - sizes: [[300, 250]], - bids: [ - { - bidder: 'onedisplay', - params: { - placement: '3611253', - network: '9599.1', - keyValues: { - test: 'key' - } - } - } - ] - }, - { - code: 'test-mobile-ad', - sizes: [[300, 250]], - bids: [ - { - bidder: 'onemobile', - params: { - dcn: '2c9d2b50015a5aa95b70a9b0b5b10012', - pos: 'header' - } - } - ] - } - ]; -``` diff --git a/modules/apacdexBidAdapter.js b/modules/apacdexBidAdapter.js index 421eb99b4c1..834df134c2e 100644 --- a/modules/apacdexBidAdapter.js +++ b/modules/apacdexBidAdapter.js @@ -1,23 +1,12 @@ -import { deepAccess, isPlainObject, isArray, replaceAuctionPrice, isFn } from '../src/utils.js'; +import { deepAccess, isPlainObject, isArray, replaceAuctionPrice, isFn, logError } from '../src/utils.js'; import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {parseDomain} from '../src/refererDetection.js'; const BIDDER_CODE = 'apacdex'; -const CONFIG = { - 'apacdex': { - 'ENDPOINT': 'https://useast.quantumdex.io/auction/apacdex', - 'USERSYNC': 'https://sync.quantumdex.io/usersync/apacdex' - }, - 'quantumdex': { - 'ENDPOINT': 'https://useast.quantumdex.io/auction/quantumdex', - 'USERSYNC': 'https://sync.quantumdex.io/usersync/quantumdex' - }, - 'valueimpression': { - 'ENDPOINT': 'https://useast.quantumdex.io/auction/adapter', - 'USERSYNC': 'https://sync.quantumdex.io/usersync/adapter' - } -}; +const ENDPOINT = 'https://useast.quantumdex.io/auction/pbjs' +const USERSYNC = 'https://sync.quantumdex.io/usersync/pbjs' -var bidderConfig = CONFIG[BIDDER_CODE]; var bySlotTargetKey = {}; var bySlotSizesCount = {} @@ -56,8 +45,6 @@ export const spec = { let test; let bids = []; - bidderConfig = CONFIG[validBidRequests[0].bidder]; - test = config.getConfig('debug'); validBidRequests.forEach(bidReq => { @@ -109,16 +96,17 @@ export const spec = { payload.device = {}; payload.device.ua = navigator.userAgent; - payload.device.height = window.screen.width; - payload.device.width = window.screen.height; + payload.device.height = window.screen.height; + payload.device.width = window.screen.width; payload.device.dnt = _getDoNotTrack(); payload.device.language = navigator.language; var pageUrl = _extractTopWindowUrlFromBidderRequest(bidderRequest); payload.site = {}; - payload.site.page = pageUrl + payload.site.page = pageUrl; payload.site.referrer = _extractTopWindowReferrerFromBidderRequest(bidderRequest); - payload.site.hostname = getDomain(pageUrl); + // TODO: does it make sense to fall back to window.location for the domain? + payload.site.hostname = bidderRequest.refererInfo?.domain || parseDomain(pageUrl); // Apply GDPR parameters to request. if (bidderRequest && bidderRequest.gdprConsent) { @@ -136,33 +124,34 @@ export const spec = { // Apply schain. if (schain) { - payload.schain = schain + payload.schain = schain; } // Apply eids. if (eids) { - payload.eids = eids + payload.eids = eids; } // Apply geo if (geo) { - payload.geo = geo; + logError('apacdex adapter: Precise lat and long must be set on config; not on bidder parameters'); } payload.bids = bids.map(function (bid) { return { params: bid.params, mediaTypes: bid.mediaTypes, - transactionId: bid.transactionId, + transactionId: bid.ortb2Imp?.ext?.tid, sizes: bid.sizes, bidId: bid.bidId, + adUnitCode: bid.adUnitCode, bidFloor: bid.bidFloor } }); return { method: 'POST', - url: bidderConfig.ENDPOINT, + url: ENDPOINT, data: payload, withCredentials: true, bidderRequests: bids @@ -209,32 +198,47 @@ export const spec = { }); return bidResponses; }, - getUserSyncs: function (syncOptions, serverResponses) { + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - try { - if (syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: bidderConfig.USERSYNC - }); + if (hasPurpose1Consent(gdprConsent)) { + let params = ''; + if (gdprConsent && typeof gdprConsent.consentString === 'string') { + // add 'gdpr' only if 'gdprApplies' is defined + if (typeof gdprConsent.gdprApplies === 'boolean') { + params = `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + params = `?gdpr_consent=${gdprConsent.consentString}`; + } } - if (serverResponses.length > 0 && serverResponses[0].body && serverResponses[0].body.pixel) { - serverResponses[0].body.pixel.forEach(px => { - if (px.type === 'image' && syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: px.url - }); - } - if (px.type === 'iframe' && syncOptions.iframeEnabled) { - syncs.push({ - type: 'iframe', - url: px.url - }); - } - }); + if (uspConsent) { + params += `${params ? '&' : '?'}us_privacy=${encodeURIComponent(uspConsent)}`; } - } catch (e) { } + + try { + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: USERSYNC + params + }); + } + if (serverResponses.length > 0 && serverResponses[0].body && serverResponses[0].body.pixel) { + serverResponses[0].body.pixel.forEach(px => { + if (px.type === 'image' && syncOptions.pixelEnabled) { + syncs.push({ + type: 'image', + url: px.url + params + }); + } + if (px.type === 'iframe' && syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: px.url + params + }); + } + }); + } + } catch (e) { } + } return syncs; } }; @@ -282,18 +286,8 @@ function _getDoNotTrack() { * @returns {string} */ function _extractTopWindowUrlFromBidderRequest(bidderRequest) { - if (config.getConfig('pageUrl')) { - return config.getConfig('pageUrl'); - } - if (deepAccess(bidderRequest, 'refererInfo.referer')) { - return bidderRequest.refererInfo.referer; - } - - try { - return window.top.location.href; - } catch (e) { - return window.location.href; - } + // TODO: does it make sense to fall back to window.location? + return bidderRequest?.refererInfo?.page || window.location.href; } /** @@ -303,34 +297,8 @@ function _extractTopWindowUrlFromBidderRequest(bidderRequest) { * @returns {string} */ function _extractTopWindowReferrerFromBidderRequest(bidderRequest) { - if (bidderRequest && deepAccess(bidderRequest, 'refererInfo.referer')) { - return bidderRequest.refererInfo.referer; - } - - try { - return window.top.document.referrer; - } catch (e) { - return window.document.referrer; - } -} - -/** - * Extracts the domain from given page url - * - * @param {string} url - * @returns {string} - */ -export function getDomain(pageUrl) { - if (config.getConfig('publisherDomain')) { - var publisherDomain = config.getConfig('publisherDomain'); - return publisherDomain.replace('http://', '').replace('https://', '').replace('www.', '').split(/[/?#:]/)[0]; - } - - if (!pageUrl) { - return pageUrl; - } - - return pageUrl.replace('http://', '').replace('https://', '').replace('www.', '').split(/[/?#:]/)[0]; + // TODO: does it make sense to fall back to window.document.referrer? + return bidderRequest?.refererInfo?.ref || window.document.referrer; } /** diff --git a/modules/appierAnalyticsAdapter.js b/modules/appierAnalyticsAdapter.js index afcf63ef2c1..b4081feaf92 100644 --- a/modules/appierAnalyticsAdapter.js +++ b/modules/appierAnalyticsAdapter.js @@ -1,5 +1,5 @@ import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import {getGlobal} from '../src/prebidGlobal.js'; diff --git a/modules/appierBidAdapter.js b/modules/appierBidAdapter.js index 1940233a0b4..12346d15130 100644 --- a/modules/appierBidAdapter.js +++ b/modules/appierBidAdapter.js @@ -43,7 +43,8 @@ export const spec = { const bidderApiUrl = `//${server}${BIDDER_API_ENDPOINT}` const payload = { 'bids': bidRequests, - 'refererInfo': bidderRequest.refererInfo, + // TODO: please do not pass internal data structures over to the network + 'refererInfo': bidderRequest.refererInfo.legacy, 'version': ADAPTER_VERSION }; return [{ diff --git a/modules/appnexusAnalyticsAdapter.js b/modules/appnexusAnalyticsAdapter.js deleted file mode 100644 index 868b317d7d4..00000000000 --- a/modules/appnexusAnalyticsAdapter.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * appnexus.js - AppNexus Prebid Analytics Adapter - */ - -import adapter from '../src/AnalyticsAdapter.js'; -import adapterManager from '../src/adapterManager.js'; - -var appnexusAdapter = adapter({ - global: 'AppNexusPrebidAnalytics', - handler: 'on', - analyticsType: 'bundle' -}); - -adapterManager.registerAnalyticsAdapter({ - adapter: appnexusAdapter, - code: 'appnexus', - gvlid: 32 -}); - -export default appnexusAdapter; diff --git a/modules/appnexusBidAdapter.js b/modules/appnexusBidAdapter.js index 41fad3caba3..e6b3441b988 100644 --- a/modules/appnexusBidAdapter.js +++ b/modules/appnexusBidAdapter.js @@ -1,15 +1,10 @@ import { - chunk, - convertCamelToUnderscore, - convertTypes, createTrackPixelHtml, deepAccess, deepClone, - fill, getBidRequest, - getMaxValueFromArray, - getMinValueFromArray, getParameterByName, + getUniqueIdentifierStr, isArray, isArrayOfNums, isEmpty, @@ -20,29 +15,43 @@ import { logError, logInfo, logMessage, - logWarn, - transformBidderParamKeywords, - getWindowFromDocument + logWarn } from '../src/utils.js'; import {Renderer} from '../src/Renderer.js'; import {config} from '../src/config.js'; -import {getIabSubCategory, registerBidder} from '../src/adapters/bidderFactory.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; import {ADPOD, BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; -import {auctionManager} from '../src/auctionManager.js'; import {find, includes} from '../src/polyfill.js'; import {INSTREAM, OUTSTREAM} from '../src/video.js'; import {getStorageManager} from '../src/storageManager.js'; import {bidderSettings} from '../src/bidderSettings.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {APPNEXUS_CATEGORY_MAPPING} from '../libraries/categoryTranslationMapping/index.js'; +import { + convertKeywordStringToANMap, + getANKewyordParamFromMaps, + getANKeywordParam, + transformBidderParamKeywords +} from '../libraries/appnexusUtils/anKeywords.js'; +import {convertCamelToUnderscore, fill} from '../libraries/appnexusUtils/anUtils.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; +import {chunk} from '../libraries/chunk/chunk.js'; const BIDDER_CODE = 'appnexus'; const URL = 'https://ib.adnxs.com/ut/v3/prebid'; const URL_SIMPLE = 'https://ib.adnxs-simple.com/ut/v3/prebid'; const VIDEO_TARGETING = ['id', 'minduration', 'maxduration', 'skippable', 'playback_method', 'frameworks', 'context', 'skipoffset']; -const VIDEO_RTB_TARGETING = ['minduration', 'maxduration', 'skip', 'skipafter', 'playbackmethod', 'api']; -const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; +const VIDEO_RTB_TARGETING = ['minduration', 'maxduration', 'skip', 'skipafter', 'playbackmethod', 'api', 'startdelay']; +const USER_PARAMS = ['age', 'externalUid', 'external_uid', 'segments', 'gender', 'dnt', 'language']; const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately const DEBUG_PARAMS = ['enabled', 'dongle', 'member_id', 'debug_timeout']; +const DEBUG_QUERY_PARAM_MAP = { + 'apn_debug_dongle': 'dongle', + 'apn_debug_member_id': 'member_id', + 'apn_debug_timeout': 'debug_timeout' +}; const VIDEO_MAPPING = { playback_method: { 'unknown': 0, @@ -80,29 +89,27 @@ const NATIVE_MAPPING = { }; const SOURCE = 'pbjs'; const MAX_IMPS_PER_REQUEST = 15; -const mappingFileUrl = 'https://acdn.adnxs-simple.com/prebid/appnexus-mapping/mappings.json'; const SCRIPT_TAG_START = ' { + let qval = getParameterByName(qparam); + if (isStr(qval) && qval !== '') { + debugObj[DEBUG_QUERY_PARAM_MAP[qparam]] = qval; + debugObj.enabled = true; + } + }); + debugObj = convertTypes({ + 'member_id': 'number', + 'debug_timeout': 'number' + }, debugObj); + const debugBidRequest = find(bidRequests, hasDebug); if (debugBidRequest && debugBidRequest.debug) { debugObj = debugBidRequest.debug; @@ -212,7 +236,7 @@ export const spec = { payload['iab_support'] = { omidpn: 'Appnexus', omidpv: '$prebid.version$' - } + }; } if (member > 0) { @@ -220,21 +244,19 @@ export const spec = { } if (appDeviceObjBid) { - payload.device = appDeviceObj + payload.device = appDeviceObj; } if (appIdObjBid) { payload.app = appIdObj; } - let auctionKeywords = config.getConfig('appnexusAuctionKeywords'); - if (isPlainObject(auctionKeywords)) { - let aucKeywords = transformBidderParamKeywords(auctionKeywords); + // grab the ortb2 keyword data (if it exists) and convert from the comma list string format to object format + let ortb2 = deepClone(bidderRequest && bidderRequest.ortb2); - if (aucKeywords.length > 0) { - aucKeywords.forEach(deleteValues); - } - - payload.keywords = aucKeywords; + let anAuctionKeywords = deepClone(config.getConfig('appnexusAuctionKeywords')) || {}; + let auctionKeywords = getANKeywordParam(ortb2, anAuctionKeywords) + if (auctionKeywords.length > 0) { + payload.keywords = auctionKeywords; } if (config.getConfig('adpod.brandCategoryExclusion')) { @@ -262,50 +284,62 @@ export const spec = { } if (bidderRequest && bidderRequest.uspConsent) { - payload.us_privacy = bidderRequest.uspConsent + payload.us_privacy = bidderRequest.uspConsent; + } + + if (bidderRequest?.gppConsent) { + payload.privacy = { + gpp: bidderRequest.gppConsent.gppString, + gpp_sid: bidderRequest.gppConsent.applicableSections + } + } else if (bidderRequest?.ortb2?.regs?.gpp) { + payload.privacy = { + gpp: bidderRequest.ortb2.regs.gpp, + gpp_sid: bidderRequest.ortb2.regs.gpp_sid + } } if (bidderRequest && bidderRequest.refererInfo) { let refererinfo = { - rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer), + // TODO: are these the correct referer values? + rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation), rd_top: bidderRequest.refererInfo.reachedTop, rd_ifs: bidderRequest.refererInfo.numIframes, rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') - } - let pubPageUrl = config.getConfig('pageUrl'); + }; + let pubPageUrl = bidderRequest.refererInfo.canonicalUrl; if (isStr(pubPageUrl) && pubPageUrl !== '') { refererinfo.rd_can = pubPageUrl; } payload.referrer_detection = refererinfo; } - const hasAdPodBid = find(bidRequests, hasAdPod); - if (hasAdPodBid) { - bidRequests.filter(hasAdPod).forEach(adPodBid => { - const adPodTags = createAdPodRequest(tags, adPodBid); - // don't need the original adpod placement because it's in adPodTags - const nonPodTags = payload.tags.filter(tag => tag.uuid !== adPodBid.bidId); - payload.tags = [...nonPodTags, ...adPodTags]; - }); + if (FEATURES.VIDEO) { + const hasAdPodBid = find(bidRequests, hasAdPod); + if (hasAdPodBid) { + bidRequests.filter(hasAdPod).forEach(adPodBid => { + const adPodTags = createAdPodRequest(tags, adPodBid); + // don't need the original adpod placement because it's in adPodTags + const nonPodTags = payload.tags.filter(tag => tag.uuid !== adPodBid.bidId); + payload.tags = [...nonPodTags, ...adPodTags]; + }); + } } if (bidRequests[0].userId) { let eids = []; - - addUserId(eids, deepAccess(bidRequests[0], `userId.flocId.id`), 'chrome.com', null); - addUserId(eids, deepAccess(bidRequests[0], `userId.criteoId`), 'criteo.com', null); - addUserId(eids, deepAccess(bidRequests[0], `userId.netId`), 'netid.de', null); - addUserId(eids, deepAccess(bidRequests[0], `userId.idl_env`), 'liveramp.com', null); - addUserId(eids, deepAccess(bidRequests[0], `userId.tdid`), 'adserver.org', 'TDID'); - addUserId(eids, deepAccess(bidRequests[0], `userId.uid2.id`), 'uidapi.com', 'UID2'); - if (bidRequests[0].userId.pubProvidedId) { - bidRequests[0].userId.pubProvidedId.forEach(ppId => { - ppId.uids.forEach(uid => { - eids.push({ source: ppId.source, id: uid.id }); - }); + bidRequests[0].userIdAsEids.forEach(eid => { + if (!eid || !eid.uids || eid.uids.length < 1) { return; } + eid.uids.forEach(uid => { + let tmp = {'source': eid.source, 'id': uid.id}; + if (eid.source == 'adserver.org') { + tmp.rti_partner = 'TDID'; + } else if (eid.source == 'uidapi.com') { + tmp.rti_partner = 'UID2'; + } + eids.push(tmp); }); - } - + }); if (eids.length) { payload.eids = eids; } @@ -367,26 +401,17 @@ export const spec = { return bids; }, - /** - * @typedef {Object} mappingFileInfo - * @property {string} url mapping file json url - * @property {number} refreshInDays prebid stores mapping data in localstorage so you can return in how many days you want to update value stored in localstorage. - * @property {string} localStorageKey unique key to store your mapping json in localstorage - */ - - /** - * Returns mapping file info. This info will be used by bidderFactory to preload mapping file and store data in local storage - * @returns {mappingFileInfo} - */ - getMappingFileInfo: function () { - return { - url: mappingFileUrl, - refreshInDays: 2 + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) { + function checkGppStatus(gppConsent) { + // this is a temporary measure to supress usersync in US-based GPP regions + // this logic will be revised when proper signals (akin to purpose1 from TCF2) can be determined for US GPP + if (gppConsent && Array.isArray(gppConsent.applicableSections)) { + return gppConsent.applicableSections.every(sec => typeof sec === 'number' && sec <= 5); + } + return true; } - }, - getUserSyncs: function (syncOptions, responses, gdprConsent) { - if (syncOptions.iframeEnabled && hasPurpose1Consent({gdprConsent})) { + if (syncOptions.iframeEnabled && hasPurpose1Consent(gdprConsent) && checkGppStatus(gppConsent)) { return [{ type: 'iframe', url: 'https://acdn.adnxs.com/dmp/async_usersync.html' @@ -394,11 +419,22 @@ export const spec = { } }, - transformBidParams: function (params, isOpenRtb) { + transformBidParams: function (params, isOpenRtb, adUnit, bidRequests) { let conversionFn = transformBidderParamKeywords; if (isOpenRtb === true) { + let s2sEndpointUrl = null; let s2sConfig = config.getConfig('s2sConfig'); - let s2sEndpointUrl = deepAccess(s2sConfig, 'endpoint.p1Consent'); + + if (isPlainObject(s2sConfig)) { + s2sEndpointUrl = deepAccess(s2sConfig, 'endpoint.p1Consent'); + } else if (isArray(s2sConfig)) { + s2sConfig.forEach(s2sCfg => { + if (includes(s2sCfg.bidders, adUnit.bids[0].bidder)) { + s2sEndpointUrl = deepAccess(s2sCfg, 'endpoint.p1Consent'); + } + }); + } + if (s2sEndpointUrl && s2sEndpointUrl.match('/openrtb2/prebid')) { conversionFn = convertKeywordsToString; } @@ -413,13 +449,6 @@ export const spec = { }, params); if (isOpenRtb) { - params.use_pmt_rule = (typeof params.usePaymentRule === 'boolean') ? params.usePaymentRule : false; - if (params.usePaymentRule) { delete params.usePaymentRule; } - - if (isPopulatedArray(params.keywords)) { - params.keywords.forEach(deleteValues); - } - Object.keys(params).forEach(paramKey => { let convertedKey = convertCamelToUnderscore(paramKey); if (convertedKey !== paramKey) { @@ -427,84 +456,18 @@ export const spec = { delete params[paramKey]; } }); - } - - return params; - }, - /** - * Add element selector to javascript tracker to improve native viewability - * @param {Bid} bid - */ - onBidWon: function (bid) { - if (bid.native) { - reloadViewabilityScriptWithCorrectParameters(bid); + params.use_pmt_rule = (typeof params.use_payment_rule === 'boolean') ? params.use_payment_rule : false; + if (params.use_payment_rule) { delete params.use_payment_rule; } } - } -} - -function isPopulatedArray(arr) { - return !!(isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} - -function reloadViewabilityScriptWithCorrectParameters(bid) { - let viewJsPayload = getAppnexusViewabilityScriptFromJsTrackers(bid.native.javascriptTrackers); - - if (viewJsPayload) { - let prebidParams = 'pbjs_adid=' + bid.adId + ';pbjs_auc=' + bid.adUnitCode; - - let jsTrackerSrc = getViewabilityScriptUrlFromPayload(viewJsPayload) - - let newJsTrackerSrc = jsTrackerSrc.replace('dom_id=%native_dom_id%', prebidParams); - // find iframe containing script tag - let frameArray = document.getElementsByTagName('iframe'); - - // boolean var to modify only one script. That way if there are muliple scripts, - // they won't all point to the same creative. - let modifiedAScript = false; - - // first, loop on all ifames - for (let i = 0; i < frameArray.length && !modifiedAScript; i++) { - let currentFrame = frameArray[i]; - try { - // IE-compatible, see https://stackoverflow.com/a/3999191/2112089 - let nestedDoc = currentFrame.contentDocument || currentFrame.contentWindow.document; - - if (nestedDoc) { - // if the doc is present, we look for our jstracker - let scriptArray = nestedDoc.getElementsByTagName('script'); - for (let j = 0; j < scriptArray.length && !modifiedAScript; j++) { - let currentScript = scriptArray[j]; - if (currentScript.getAttribute('data-src') == jsTrackerSrc) { - currentScript.setAttribute('src', newJsTrackerSrc); - currentScript.setAttribute('data-src', ''); - if (currentScript.removeAttribute) { - currentScript.removeAttribute('data-src'); - } - modifiedAScript = true; - } - } - } - } catch (exception) { - // trying to access a cross-domain iframe raises a SecurityError - // this is expected and ignored - if (!(exception instanceof DOMException && exception.name === 'SecurityError')) { - // all other cases are raised again to be treated by the calling function - throw exception; - } - } - } + return params; } -} +}; function strIsAppnexusViewabilityScript(str) { + if (!str || str === '') return false; + let regexMatchUrlStart = str.match(VIEWABILITY_URL_START); let viewUrlStartInStr = regexMatchUrlStart != null && regexMatchUrlStart.length >= 1; @@ -514,40 +477,6 @@ function strIsAppnexusViewabilityScript(str) { return str.startsWith(SCRIPT_TAG_START) && fileNameInStr && viewUrlStartInStr; } -function getAppnexusViewabilityScriptFromJsTrackers(jsTrackerArray) { - let viewJsPayload; - if (isStr(jsTrackerArray) && strIsAppnexusViewabilityScript(jsTrackerArray)) { - viewJsPayload = jsTrackerArray; - } else if (isArray(jsTrackerArray)) { - for (let i = 0; i < jsTrackerArray.length; i++) { - let currentJsTracker = jsTrackerArray[i]; - if (strIsAppnexusViewabilityScript(currentJsTracker)) { - viewJsPayload = currentJsTracker; - } - } - } - return viewJsPayload; -} - -function getViewabilityScriptUrlFromPayload(viewJsPayload) { - // extracting the content of the src attribute - // -> substring between src=" and " - let indexOfFirstQuote = viewJsPayload.indexOf('src="') + 5; // offset of 5: the length of 'src=' + 1 - let indexOfSecondQuote = viewJsPayload.indexOf('"', indexOfFirstQuote); - let jsTrackerSrc = viewJsPayload.substring(indexOfFirstQuote, indexOfSecondQuote); - return jsTrackerSrc; -} - -function hasPurpose1Consent(bidderRequest) { - let result = true; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) { - result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} - function formatRequest(payload, bidderRequest) { let request = []; let options = { @@ -556,14 +485,14 @@ function formatRequest(payload, bidderRequest) { let endpointUrl = URL; - if (!hasPurpose1Consent(bidderRequest)) { + if (!hasPurpose1Consent(bidderRequest?.gdprConsent)) { endpointUrl = URL_SIMPLE; } if (getParameterByName('apn_test').toUpperCase() === 'TRUE' || config.getConfig('apn_test') === true) { options.customHeaders = { 'X-Is-Test': 1 - } + }; } if (payload.tags.length > MAX_IMPS_PER_REQUEST) { @@ -629,7 +558,9 @@ function newRenderer(adUnitCode, rtbBid, rendererOptions = {}) { */ function newBid(serverBid, rtbBid, bidderRequest) { const bidRequest = getBidRequest(serverBid.uuid, [bidderRequest]); + const adId = getUniqueIdentifierStr(); const bid = { + adId: adId, requestId: serverBid.uuid, cpm: rtbBid.cpm, creativeId: rtbBid.creative_id, @@ -645,9 +576,8 @@ function newBid(serverBid, rtbBid, bidderRequest) { } }; - // WE DON'T FULLY SUPPORT THIS ATM - future spot for adomain code; creating a stub for 5.0 compliance if (rtbBid.adomain) { - bid.meta = Object.assign({}, bid.meta, { advertiserDomains: [] }); + bid.meta = Object.assign({}, bid.meta, { advertiserDomains: [rtbBid.adomain] }); } if (rtbBid.advertiser_id) { @@ -674,7 +604,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { bid.meta = Object.assign({}, bid.meta, { brandId: rtbBid.brand_id }); } - if (rtbBid.rtb.video) { + if (FEATURES.VIDEO && rtbBid.rtb.video) { // shared video properties used for all 3 contexts Object.assign(bid, { width: rtbBid.rtb.video.player_width, @@ -686,7 +616,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context'); switch (videoContext) { case ADPOD: - const primaryCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); + const primaryCatId = (APPNEXUS_CATEGORY_MAPPING[rtbBid.brand_category_id]) ? APPNEXUS_CATEGORY_MAPPING[rtbBid.brand_category_id] : null; bid.meta = Object.assign({}, bid.meta, { primaryCatId }); const dealTier = rtbBid.deal_priority; bid.video = { @@ -715,22 +645,22 @@ function newBid(serverBid, rtbBid, bidderRequest) { bid.vastUrl = rtbBid.notify_url + '&redir=' + encodeURIComponent(rtbBid.rtb.video.asset_url); break; } - } else if (rtbBid.rtb[NATIVE]) { + } else if (FEATURES.NATIVE && rtbBid.rtb[NATIVE]) { const nativeAd = rtbBid.rtb[NATIVE]; + let viewScript; - // setting up the jsTracker: - // we put it as a data-src attribute so that the tracker isn't called - // until we have the adId (see onBidWon) - let jsTrackerDisarmed = rtbBid.viewability.config.replace('src=', 'data-src='); + if (strIsAppnexusViewabilityScript(rtbBid.viewability.config)) { + let prebidParams = 'pbjs_adid=' + adId + ';pbjs_auc=' + bidRequest.adUnitCode; + viewScript = rtbBid.viewability.config.replace('dom_id=%native_dom_id%', prebidParams); + } let jsTrackers = nativeAd.javascript_trackers; - if (jsTrackers == undefined) { - jsTrackers = jsTrackerDisarmed; + jsTrackers = viewScript; } else if (isStr(jsTrackers)) { - jsTrackers = [jsTrackers, jsTrackerDisarmed]; + jsTrackers = [jsTrackers, viewScript]; } else { - jsTrackers.push(jsTrackerDisarmed); + jsTrackers.push(viewScript); } bid[NATIVE] = { @@ -751,6 +681,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { displayUrl: nativeAd.displayurl, clickTrackers: nativeAd.link.click_trackers, impressionTrackers: nativeAd.impression_trackers, + video: nativeAd.video, javascriptTrackers: jsTrackers }; if (nativeAd.main_img) { @@ -791,17 +722,25 @@ function newBid(serverBid, rtbBid, bidderRequest) { function bidToTag(bid) { const tag = {}; + Object.keys(bid.params).forEach(paramKey => { + let convertedKey = convertCamelToUnderscore(paramKey); + if (convertedKey !== paramKey) { + bid.params[convertedKey] = bid.params[paramKey]; + delete bid.params[paramKey]; + } + }); tag.sizes = transformSizes(bid.sizes); tag.primary_size = tag.sizes[0]; tag.ad_types = []; tag.uuid = bid.bidId; - if (bid.params.placementId) { - tag.id = parseInt(bid.params.placementId, 10); + if (bid.params.placement_id) { + tag.id = parseInt(bid.params.placement_id, 10); } else { - tag.code = bid.params.invCode; + tag.code = bid.params.inv_code; } - tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false + tag.allow_smaller_sizes = bid.params.allow_smaller_sizes || false; + tag.use_pmt_rule = (typeof bid.params.use_payment_rule === 'boolean') ? bid.params.use_payment_rule + : (typeof bid.params.use_pmt_rule === 'boolean') ? bid.params.use_pmt_rule : false; tag.prebid = true; tag.disable_psa = true; let bidFloor = getBidFloor(bid); @@ -818,42 +757,39 @@ function bidToTag(bid) { tag.position = (mediaTypePos === 3) ? 2 : mediaTypePos; } } - if (bid.params.trafficSourceCode) { - tag.traffic_source_code = bid.params.trafficSourceCode; + if (bid.params.traffic_source_code) { + tag.traffic_source_code = bid.params.traffic_source_code; } - if (bid.params.privateSizes) { - tag.private_sizes = transformSizes(bid.params.privateSizes); + if (bid.params.private_sizes) { + tag.private_sizes = transformSizes(bid.params.private_sizes); } - if (bid.params.supplyType) { - tag.supply_type = bid.params.supplyType; + if (bid.params.supply_type) { + tag.supply_type = bid.params.supply_type; } - if (bid.params.pubClick) { - tag.pubclick = bid.params.pubClick; + if (bid.params.pub_click) { + tag.pubclick = bid.params.pub_click; } - if (bid.params.extInvCode) { - tag.ext_inv_code = bid.params.extInvCode; + if (bid.params.ext_inv_code) { + tag.ext_inv_code = bid.params.ext_inv_code; } - if (bid.params.publisherId) { - tag.publisher_id = parseInt(bid.params.publisherId, 10); + if (bid.params.publisher_id) { + tag.publisher_id = parseInt(bid.params.publisher_id, 10); } - if (bid.params.externalImpId) { - tag.external_imp_id = bid.params.externalImpId; + if (bid.params.external_imp_id) { + tag.external_imp_id = bid.params.external_imp_id; } - if (!isEmpty(bid.params.keywords)) { - let keywords = transformBidderParamKeywords(bid.params.keywords); - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - tag.keywords = keywords; + const auKeywords = getANKewyordParamFromMaps(convertKeywordStringToANMap(deepAccess(bid, 'ortb2Imp.ext.data.keywords')), bid.params?.keywords); + if (auKeywords.length > 0) { + tag.keywords = auKeywords; } - let gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); + let gpid = deepAccess(bid, 'ortb2Imp.ext.gpid') || deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); if (gpid) { tag.gpid = gpid; } - if (bid.mediaType === NATIVE || deepAccess(bid, `mediaTypes.${NATIVE}`)) { + if (FEATURES.NATIVE && (bid.mediaType === NATIVE || deepAccess(bid, `mediaTypes.${NATIVE}`))) { tag.ad_types.push(NATIVE); if (tag.sizes.length === 0) { tag.sizes = transformSizes([1, 1]); @@ -865,104 +801,118 @@ function bidToTag(bid) { } } - const videoMediaType = deepAccess(bid, `mediaTypes.${VIDEO}`); - const context = deepAccess(bid, 'mediaTypes.video.context'); + if (FEATURES.VIDEO) { + const videoMediaType = deepAccess(bid, `mediaTypes.${VIDEO}`); + const context = deepAccess(bid, 'mediaTypes.video.context'); - if (videoMediaType && context === 'adpod') { - tag.hb_source = 7; - } else { - tag.hb_source = 1; - } - if (bid.mediaType === VIDEO || videoMediaType) { - tag.ad_types.push(VIDEO); - } - - // instream gets vastUrl, outstream gets vastXml - if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { - tag.require_asset_url = true; - } - - if (bid.params.video) { - tag.video = {}; - // place any valid video params on the tag - Object.keys(bid.params.video) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => { - switch (param) { - case 'context': - case 'playback_method': - let type = bid.params.video[param]; - type = (isArray(type)) ? type[0] : type; - tag.video[param] = VIDEO_MAPPING[param][type]; - break; - // Deprecating tags[].video.frameworks in favor of tags[].video_frameworks - case 'frameworks': - break; - default: - tag.video[param] = bid.params.video[param]; - } - }); + if (videoMediaType && context === 'adpod') { + tag.hb_source = 7; + } else { + tag.hb_source = 1; + } + if (bid.mediaType === VIDEO || videoMediaType) { + tag.ad_types.push(VIDEO); + } - if (bid.params.video.frameworks && isArray(bid.params.video.frameworks)) { - tag['video_frameworks'] = bid.params.video.frameworks; + // instream gets vastUrl, outstream gets vastXml + if (bid.mediaType === VIDEO || (videoMediaType && context !== 'outstream')) { + tag.require_asset_url = true; } - } - // use IAB ORTB values if the corresponding values weren't already set by bid.params.video - if (videoMediaType) { - tag.video = tag.video || {}; - Object.keys(videoMediaType) - .filter(param => includes(VIDEO_RTB_TARGETING, param)) - .forEach(param => { - switch (param) { - case 'minduration': - case 'maxduration': - if (typeof tag.video[param] !== 'number') tag.video[param] = videoMediaType[param]; - break; - case 'skip': - if (typeof tag.video['skippable'] !== 'boolean') tag.video['skippable'] = (videoMediaType[param] === 1); - break; - case 'skipafter': - if (typeof tag.video['skipoffset'] !== 'number') tag.video['skippoffset'] = videoMediaType[param]; - break; - case 'playbackmethod': - if (typeof tag.video['playback_method'] !== 'number') { - let type = videoMediaType[param]; + if (bid.params.video) { + tag.video = {}; + // place any valid video params on the tag + Object.keys(bid.params.video) + .filter(param => includes(VIDEO_TARGETING, param)) + .forEach(param => { + switch (param) { + case 'context': + case 'playback_method': + let type = bid.params.video[param]; type = (isArray(type)) ? type[0] : type; + tag.video[param] = VIDEO_MAPPING[param][type]; + break; + // Deprecating tags[].video.frameworks in favor of tags[].video_frameworks + case 'frameworks': + break; + default: + tag.video[param] = bid.params.video[param]; + } + }); - // we only support iab's options 1-4 at this time. - if (type >= 1 && type <= 4) { - tag.video['playback_method'] = type; - } - } - break; - case 'api': - if (!tag['video_frameworks'] && isArray(videoMediaType[param])) { - // need to read thru array; remove 6 (we don't support it), swap 4 <> 5 if found (to match our adserver mapping for these specific values) - let apiTmp = videoMediaType[param].map(val => { - let v = (val === 4) ? 5 : (val === 5) ? 4 : val; - - if (v >= 1 && v <= 5) { - return v; + if (bid.params.video.frameworks && isArray(bid.params.video.frameworks)) { + tag['video_frameworks'] = bid.params.video.frameworks; + } + } + + // use IAB ORTB values if the corresponding values weren't already set by bid.params.video + if (videoMediaType) { + tag.video = tag.video || {}; + Object.keys(videoMediaType) + .filter(param => includes(VIDEO_RTB_TARGETING, param)) + .forEach(param => { + switch (param) { + case 'minduration': + case 'maxduration': + if (typeof tag.video[param] !== 'number') tag.video[param] = videoMediaType[param]; + break; + case 'skip': + if (typeof tag.video['skippable'] !== 'boolean') tag.video['skippable'] = (videoMediaType[param] === 1); + break; + case 'skipafter': + if (typeof tag.video['skipoffset'] !== 'number') tag.video['skippoffset'] = videoMediaType[param]; + break; + case 'playbackmethod': + if (typeof tag.video['playback_method'] !== 'number') { + let type = videoMediaType[param]; + type = (isArray(type)) ? type[0] : type; + + // we only support iab's options 1-4 at this time. + if (type >= 1 && type <= 4) { + tag.video['playback_method'] = type; } - }).filter(v => v); - tag['video_frameworks'] = apiTmp; - } - break; - } - }); - } + } + break; + case 'api': + if (!tag['video_frameworks'] && isArray(videoMediaType[param])) { + // need to read thru array; remove 6 (we don't support it), swap 4 <> 5 if found (to match our adserver mapping for these specific values) + let apiTmp = videoMediaType[param].map(val => { + let v = (val === 4) ? 5 : (val === 5) ? 4 : val; + + if (v >= 1 && v <= 5) { + return v; + } + }).filter(v => v); + tag['video_frameworks'] = apiTmp; + } + break; + + case 'startdelay': + case 'placement': + const contextKey = 'context'; + if (typeof tag.video[contextKey] !== 'number') { + const placement = videoMediaType['placement']; + const startdelay = videoMediaType['startdelay']; + const context = getContextFromPlacement(placement) || getContextFromStartDelay(startdelay); + tag.video[contextKey] = VIDEO_MAPPING[contextKey][context]; + } + break; + } + }); + } - if (bid.renderer) { - tag.video = Object.assign({}, tag.video, { custom_renderer_present: true }); + if (bid.renderer) { + tag.video = Object.assign({}, tag.video, { custom_renderer_present: true }); + } + } else { + tag.hb_source = 1; } if (bid.params.frameworks && isArray(bid.params.frameworks)) { tag['banner_frameworks'] = bid.params.frameworks; } - let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId); - if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) { + if (deepAccess(bid, `mediaTypes.${BANNER}`)) { tag.ad_types.push(BANNER); } @@ -996,6 +946,32 @@ function transformSizes(requestSizes) { return sizes; } +function getContextFromPlacement(ortbPlacement) { + if (!ortbPlacement) { + return; + } + + if (ortbPlacement === 2) { + return 'in-banner'; + } else if (ortbPlacement > 2) { + return 'outstream'; + } +} + +function getContextFromStartDelay(ortbStartDelay) { + if (!ortbStartDelay) { + return; + } + + if (ortbStartDelay === 0) { + return 'pre_roll'; + } else if (ortbStartDelay === -1) { + return 'mid_roll'; + } else if (ortbStartDelay === -2) { + return 'post_roll'; + } +} + function hasUserInfo(bid) { return !!bid.params.user; } @@ -1051,7 +1027,7 @@ function createAdPodRequest(tags, adPodBid) { const { durationRangeSec, requireExactDuration } = adPodBid.mediaTypes.video; const numberOfPlacements = getAdPodPlacementNumber(adPodBid.mediaTypes.video); - const maxDuration = getMaxValueFromArray(durationRangeSec); + const maxDuration = Math.max(...durationRangeSec); const tagToDuplicate = tags.filter(tag => tag.uuid === adPodBid.bidId); let request = fill(...tagToDuplicate, numberOfPlacements); @@ -1077,7 +1053,7 @@ function createAdPodRequest(tags, adPodBid) { function getAdPodPlacementNumber(videoParams) { const { adPodDurationSec, durationRangeSec, requireExactDuration } = videoParams; - const minAllowedDuration = getMinValueFromArray(durationRangeSec); + const minAllowedDuration = Math.min(...durationRangeSec); const numberOfPlacements = Math.floor(adPodDurationSec / minAllowedDuration); return requireExactDuration @@ -1162,7 +1138,7 @@ function outstreamRender(bid, doc) { hideSASIframe(bid.adUnitCode); // push to render queue because ANOutstreamVideo may not be loaded yet bid.renderer.push(() => { - const win = getWindowFromDocument(doc) || window; + const win = doc?.defaultView || window; win.ANOutstreamVideo.renderAd({ tagId: bid.adResponse.tag_id, sizes: [bid.getSize().split('x')], @@ -1189,17 +1165,6 @@ function parseMediaType(rtbBid) { } } -function addUserId(eids, id, source, rti) { - if (id) { - if (rti) { - eids.push({ source, id, rti_partner: rti }); - } else { - eids.push({ source, id }); - } - } - return eids; -} - function getBidFloor(bid) { if (!isFn(bid.getFloor)) { return (bid.params.reserve) ? bid.params.reserve : null; diff --git a/modules/appnexusBidAdapter.md b/modules/appnexusBidAdapter.md index 7ac70e67584..e8c57b782ec 100644 --- a/modules/appnexusBidAdapter.md +++ b/modules/appnexusBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: Appnexus Bid Adapter Module Type: Bidder Adapter -Maintainer: prebid-js@xandr.com +Maintainer: prebid@microsoft.com ``` # Description diff --git a/modules/appushBidAdapter.js b/modules/appushBidAdapter.js new file mode 100644 index 00000000000..97772b65e45 --- /dev/null +++ b/modules/appushBidAdapter.js @@ -0,0 +1,188 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'appush'; +const AD_URL = 'https://hb.appush.com/pbjs'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + } +}; + +registerBidder(spec); diff --git a/modules/appushBidAdapter.md b/modules/appushBidAdapter.md new file mode 100644 index 00000000000..7c04c3a6425 --- /dev/null +++ b/modules/appushBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: Appush Bidder Adapter +Module Type: Appush Bidder Adapter +Maintainer: support@appush.com +``` + +# Description + +Connects to Appush exchange for bids. +Appush bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'appush', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'appush', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'appush', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/apstreamBidAdapter.js b/modules/apstreamBidAdapter.js index b69fffb8b6b..2856fb02087 100644 --- a/modules/apstreamBidAdapter.js +++ b/modules/apstreamBidAdapter.js @@ -2,13 +2,14 @@ import { generateUUID, deepAccess, createTrackPixelHtml, getDNT } from '../src/u import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { getStorageManager } from '../src/storageManager.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const CONSTANTS = { DSU_KEY: 'apr_dsu', BIDDER_CODE: 'apstream', GVLID: 394 }; -const storage = getStorageManager({gvlid: CONSTANTS.GVLID, bidderCode: CONSTANTS.BIDDER_CODE}); +const storage = getStorageManager({bidderCode: CONSTANTS.BIDDER_CODE}); var dsuModule = (function() { 'use strict'; @@ -266,7 +267,7 @@ var dsuModule = (function() { return { readOrCreateDsu: readOrCreateDsu - } + }; })(); function serializeSizes(sizes) { @@ -342,7 +343,7 @@ function getBids(bids) { const bidId = bid.bidId; let mediaType = ''; - const mediaTypes = Object.keys(bid.mediaTypes) + const mediaTypes = Object.keys(bid.mediaTypes); switch (mediaTypes[0]) { case 'video': mediaType = 'v'; @@ -416,8 +417,11 @@ function isBidRequestValid(bid) { } function buildRequests(bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); const data = { med: encodeURIComponent(window.location.href), + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auid: bidderRequest.auctionId, ref: document.referrer, dnt: getDNT() ? 1 : 0, diff --git a/modules/arcspanRtdProvider.js b/modules/arcspanRtdProvider.js new file mode 100644 index 00000000000..a7ffa059279 --- /dev/null +++ b/modules/arcspanRtdProvider.js @@ -0,0 +1,73 @@ +import { submodule } from '../src/hook.js'; +import { mergeDeep } from '../src/utils.js'; +import {loadExternalScript} from '../src/adloader.js'; + +/** @type {string} */ +const MODULE_NAME = 'realTimeData'; +const SUBMODULE_NAME = 'arcspan'; + +/** @type {RtdSubmodule} */ +export const arcspanSubmodule = { + name: SUBMODULE_NAME, + init: init, + getBidRequestData: alterBidRequests, +}; + +function init(config, userConsent) { + if (typeof config.params.silo === 'undefined') { + return false; + } + if (typeof window.arcobj2 === 'undefined') { + var scriptUrl; + if (config.params.silo === 'test') { + scriptUrl = 'https://localhost:8080/as.js'; + } else { + scriptUrl = 'https://silo' + config.params.silo + '.p7cloud.net/as.js'; + } + loadExternalScript(scriptUrl, SUBMODULE_NAME); + } + return true; +} + +function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { + var _v1 = []; + var _v1s = []; + var _v2 = []; + var arcobj1 = window.arcobj1; + if (typeof arcobj1 != 'undefined') { + if (typeof arcobj1.page_iab_codes.text != 'undefined') { _v1 = _v1.concat(arcobj1.page_iab_codes.text); } + if (typeof arcobj1.page_iab_codes.images != 'undefined') { _v1 = _v1.concat(arcobj1.page_iab_codes.images); } + if (typeof arcobj1.page_iab.text != 'undefined') { _v1s = _v1s.concat(arcobj1.page_iab.text); } + if (typeof arcobj1.page_iab.images != 'undefined') { _v1s = _v1s.concat(arcobj1.page_iab.images); } + if (typeof arcobj1.page_iab_newcodes.text != 'undefined') { _v2 = [...new Set([..._v2, ...arcobj1.page_iab_newcodes.text])]; } + if (typeof arcobj1.page_iab_newcodes.images != 'undefined') { _v2 = [...new Set([..._v2, ...arcobj1.page_iab_newcodes.images])]; } + + var _content = {}; + _content.data = []; + var p = {}; + p.name = 'arcspan'; + p.segment = []; + p.ext = { segtax: 6 }; + _v2.forEach(function (e) { + p.segment = p.segment.concat({ id: e }); + }); + _content.data = _content.data.concat(p); + var _ortb2 = { + site: { + name: 'arcspan', + domain: new URL(location.href).hostname, + cat: _v1, + sectioncat: _v1, + pagecat: _v1, + page: location.href, + ref: document.referrer, + keywords: _v1s.toString(), + content: _content, + }, + }; + mergeDeep(reqBidsConfigObj.ortb2Fragments.global, _ortb2); + } + callback(); +} + +submodule(MODULE_NAME, arcspanSubmodule); diff --git a/modules/arcspanRtdProvider.md b/modules/arcspanRtdProvider.md new file mode 100644 index 00000000000..4aa1de02acf --- /dev/null +++ b/modules/arcspanRtdProvider.md @@ -0,0 +1,11 @@ +# Overview + +Module Name: ArcSpan Rtd Provider + +Module Type: Rtd Provider + +Maintainer: engineering@arcspan.com + +# Description + +RTD provider for ArcSpan Technologies. Contact jcabalugaz@arcspan.com for more information. diff --git a/modules/arteebeeBidAdapter.md b/modules/arteebeeBidAdapter.md deleted file mode 100644 index 4c178d722b1..00000000000 --- a/modules/arteebeeBidAdapter.md +++ /dev/null @@ -1,32 +0,0 @@ -# Overview - -``` -Module Name: Arteebee Bidder Adapter -Module Type: Bidder Adapter -Maintainer: jeffyecn@gmail.com -``` - -# Description - -Module that connects to Arteebee's demand source - -# Test Parameters -``` - var adUnits = [ - { - code: 'banner-ad-div', - sizes: [[300, 250]], - bids: [ - { - bidder: 'arteebee', - params: { - ssp: 'mock', - pub: 'prebidtest', - source: 'prebidtest', - test: true - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/asealBidAdapter.js b/modules/asealBidAdapter.js index 559afefa94b..abe0cf907ed 100644 --- a/modules/asealBidAdapter.js +++ b/modules/asealBidAdapter.js @@ -1,30 +1,78 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; +import { generateUUID, getWindowTop, getWindowSelf } from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; export const BIDDER_CODE = 'aseal'; -const SUPPORTED_AD_TYPES = [BANNER]; +export const SUPPORTED_AD_TYPES = [BANNER]; export const API_ENDPOINT = 'https://tkprebid.aotter.net/prebid/adapter'; -export const HEADER_AOTTER_VERSION = 'prebid_0.0.1'; +export const WEB_SESSION_ID_KEY = '__tkwsid'; +export const HEADER_AOTTER_VERSION = 'prebid_0.0.2'; + +export const storage = getStorageManager({ bidderCode: BIDDER_CODE }); + +const getTrekWebSessionId = () => { + let wsid = + storage.localStorageIsEnabled() && + storage.getDataFromLocalStorage(WEB_SESSION_ID_KEY); + + if (!wsid) { + wsid = generateUUID(); + setTrekWebSessionId(wsid); + } + + return wsid; +}; + +const setTrekWebSessionId = (wsid) => { + if (storage.localStorageIsEnabled()) { + storage.setDataInLocalStorage(WEB_SESSION_ID_KEY, wsid); + } +}; + +const canAccessTopWindow = () => { + try { + return !!getWindowTop().location.href; + } catch (errro) { + return false; + } +}; export const spec = { code: BIDDER_CODE, aliases: ['aotter', 'trek'], supportedMediaTypes: SUPPORTED_AD_TYPES, - - isBidRequestValid: (bid) => !!bid.params.placeUid && typeof bid.params.placeUid === 'string', - + isBidRequestValid: (bid) => + !!bid.params.placeUid && typeof bid.params.placeUid === 'string', buildRequests: (validBidRequests, bidderRequest) => { if (validBidRequests.length === 0) { return []; } - const clientId = - config.getConfig('aseal.clientId') || ''; + const clientId = config.getConfig('aseal.clientId') || ''; + + const windowTop = getWindowTop(); + const windowSelf = getWindowSelf(); + + const w = canAccessTopWindow() ? windowTop : windowSelf; const data = { bids: validBidRequests, - refererInfo: bidderRequest.refererInfo, + // TODO: please do not pass internal data structures over to the network + refererInfo: bidderRequest.refererInfo?.legacy, + device: { + webSessionId: getTrekWebSessionId(), + }, + payload: { + meta: { + dr: w.document.referrer, + drs: windowSelf.document.referrer, + drt: (canAccessTopWindow() && windowTop.document.referrer) || '', + dt: w.document.title, + dl: w.location.href, + }, + }, }; const options = { @@ -36,14 +84,15 @@ export const spec = { }, }; - return [{ - method: 'POST', - url: API_ENDPOINT, - data, - options, - }]; + return [ + { + method: 'POST', + url: API_ENDPOINT, + data, + options, + }, + ]; }, - interpretResponse: (serverResponse, bidRequest) => { if (!Array.isArray(serverResponse.body)) { return []; diff --git a/modules/asoBidAdapter.js b/modules/asoBidAdapter.js index bf45b9ee48f..704cffefb39 100644 --- a/modules/asoBidAdapter.js +++ b/modules/asoBidAdapter.js @@ -1,19 +1,36 @@ -import { _each, deepAccess, logWarn, tryAppendQueryString, inIframe, getWindowTop, parseUrl, parseSizesInput, isFn, getDNT, deepSetValue } from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {Renderer} from '../src/Renderer.js'; +import { + _each, + deepAccess, + deepSetValue, + getDNT, + inIframe, + isArray, + isFn, + logWarn, + parseSizesInput +} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { Renderer } from '../src/Renderer.js'; +import { parseDomain } from '../src/refererDetection.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; const BIDDER_CODE = 'aso'; const DEFAULT_SERVER_URL = 'https://srv.aso1.net'; const DEFAULT_SERVER_PATH = '/prebid/bidder'; const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; +const VERSION = '$prebid.version$_1.1'; const TTL = 300; export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], + aliases: [ + {code: 'bcmint'}, + {code: 'bidgency'} + ], isBidRequestValid: bid => { return !!bid.params && !!bid.params.zone; @@ -48,7 +65,7 @@ export const spec = { serverRequests.push({ method: 'POST', - url: getEnpoint(bidRequest), + url: getEndpoint(bidRequest), data: payload, options: { withCredentials: true, @@ -167,28 +184,13 @@ function createRenderer(bid, url) { } function getUrlsInfo(bidderRequest) { - let page = ''; - let referrer = ''; - - const {refererInfo} = bidderRequest; - - if (inIframe()) { - page = refererInfo.referer; - } else { - const w = getWindowTop(); - page = w.location.href; - referrer = w.document.referrer || ''; - } - - page = config.getConfig('pageUrl') || page; - const url = parseUrl(page); - const domain = url.hostname; - + const {page, domain, ref} = bidderRequest.refererInfo; return { - domain, - page, - referrer - }; + // TODO: do the fallbacks make sense here? + page: page || bidderRequest.refererInfo?.topmostLocation, + referrer: ref || '', + domain: domain || parseDomain(bidderRequest?.refererInfo?.topmostLocation) + } } function getSize(paramSizes) { @@ -276,11 +278,9 @@ function createVideoImp(bidRequest, videoParams) { return imp; } -function getEnpoint(bidRequest) { - const serverUrl = bidRequest.params.serverUrl || DEFAULT_SERVER_URL; - const serverPath = bidRequest.params.serverPath || DEFAULT_SERVER_PATH; - - return serverUrl + serverPath + '?zid=' + bidRequest.params.zone + '&pbjs=$prebid.version$'; +function getEndpoint(bidRequest) { + const serverUrl = bidRequest.params.server || DEFAULT_SERVER_URL; + return serverUrl + DEFAULT_SERVER_PATH + '?zid=' + bidRequest.params.zone + '&pbjs=' + VERSION; } function getConsentsIds(gdprConsent) { @@ -300,7 +300,7 @@ function createBasePayload(bidRequest, bidderRequest) { const urlsInfo = getUrlsInfo(bidderRequest); const payload = { - id: bidRequest.auctionId + '_' + bidRequest.bidId, + id: bidRequest.bidId, at: 1, tmax: bidderRequest.timeout, site: { @@ -345,6 +345,11 @@ function createBasePayload(bidRequest, bidderRequest) { deepSetValue(payload, 'user.ext.eids', eids); } + const schainData = deepAccess(bidRequest, 'schain.nodes'); + if (isArray(schainData) && schainData.length > 0) { + deepSetValue(payload, 'source.ext.schain', bidRequest.schain); + } + return payload; } diff --git a/modules/asoBidAdapter.md b/modules/asoBidAdapter.md index 32f4ebf5cef..f187389c5b5 100644 --- a/modules/asoBidAdapter.md +++ b/modules/asoBidAdapter.md @@ -14,12 +14,11 @@ For more information, please visit [Adserver.Online](https://adserver.online). # Parameters -| Name | Scope | Description | Example | Type | -|---------------|----------|-------------------------|-----------|-----------| -| `zone` | required | Zone ID | `73815` | `Integer` | -| `attr` | optional | Custom targeting params | `{keywords: ["a", "b"]}` | `Object` | - - +| Name | Scope | Description | Example | Type | +|-----------|----------|-------------------------|------------------------|------------| +| `zone` | required | Zone ID | `73815` | `Integer` | +| `attr` | optional | Custom targeting params | `{foo: ["a", "b"]}` | `Object` | +| `server` | optional | Custom bidder endpoint | `https://endpoint.url` | `String` | # Test parameters for banner ```js diff --git a/modules/astraoneBidAdapter.js b/modules/astraoneBidAdapter.js index c233e665499..d7f92bb5fac 100644 --- a/modules/astraoneBidAdapter.js +++ b/modules/astraoneBidAdapter.js @@ -11,7 +11,7 @@ function buildBidRequests(validBidRequests) { const params = validBidRequest.params; const bidRequest = { bidId: validBidRequest.bidId, - transactionId: validBidRequest.transactionId, + transactionId: validBidRequest.ortb2Imp?.ext?.tid, sizes: validBidRequest.sizes, placement: params.placement, placeId: params.placeId, @@ -99,7 +99,7 @@ export const spec = { */ buildRequests(validBidRequests, bidderRequest) { const payload = { - url: bidderRequest.refererInfo.referer, + url: bidderRequest.refererInfo.page, cmp: !!bidderRequest.gdprConsent, bidRequests: buildBidRequests(validBidRequests) }; diff --git a/modules/atomxBidAdapter.md b/modules/atomxBidAdapter.md deleted file mode 100644 index 7f32b12fdfe..00000000000 --- a/modules/atomxBidAdapter.md +++ /dev/null @@ -1,25 +0,0 @@ -# Overview -Module Name: Atomx Bidder Adapter Module -Type: Bidder Adapter -Maintainer: erik@atomx.com - -# Description -Atomx Bidder Adapter for Prebid.js. - -# Test Parameters -``` -var adUnits = [ -{ - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: 'atomx', - params: { - id: 4025860, - } - } - ] -} -]; -``` diff --git a/modules/atsAnalyticsAdapter.js b/modules/atsAnalyticsAdapter.js index f45d2e80055..8e92146694f 100644 --- a/modules/atsAnalyticsAdapter.js +++ b/modules/atsAnalyticsAdapter.js @@ -1,11 +1,14 @@ import { logError, logInfo } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adaptermanager from '../src/adapterManager.js'; import {ajax} from '../src/ajax.js'; import {getStorageManager} from '../src/storageManager.js'; +import {getGlobal} from '../src/prebidGlobal.js'; -export const storage = getStorageManager(); +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; +const MODULE_CODE = 'atsAnalytics'; +export const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); /** * Analytics adapter for - https://liveramp.com @@ -267,7 +270,7 @@ function sendDataToAnalytic (events) { } // preflight request, to check did publisher have permission to send data to analytics endpoint -function preflightRequest (envelopeSourceCookieValue, events) { +function preflightRequest (events) { logInfo('ATS Analytics - preflight request!'); ajax(preflightUrl + atsAnalyticsAdapter.context.pid, { @@ -277,7 +280,7 @@ function preflightRequest (envelopeSourceCookieValue, events) { let samplingRate = samplingRateObject.samplingRate; atsAnalyticsAdapter.setSamplingCookie(samplingRate); let samplingRateNumber = Number(samplingRate); - if (data && samplingRate && atsAnalyticsAdapter.shouldFireRequest(samplingRateNumber) && envelopeSourceCookieValue != null) { + if (data && samplingRate && atsAnalyticsAdapter.shouldFireRequest(samplingRateNumber)) { logInfo('ATS Analytics - events to send: ', events); sendDataToAnalytic(events); } @@ -352,7 +355,7 @@ atsAnalyticsAdapter.callHandler = function (evtype, args) { let bidWonTimeout = atsAnalyticsAdapter.context.bidWonTimeout ? atsAnalyticsAdapter.context.bidWonTimeout : 2000; let events = []; setTimeout(() => { - let winningBids = $$PREBID_GLOBAL$$.getAllWinningBids(); + let winningBids = getGlobal().getAllWinningBids(); logInfo('ATS Analytics - winning bids: ', winningBids) // prepare format data for sending to analytics endpoint if (handlerRequest.length) { @@ -377,12 +380,11 @@ atsAnalyticsAdapter.callHandler = function (evtype, args) { } // check should we send data to analytics or not, check first cookie value _lr_sampling_rate try { - let envelopeSourceCookieValue = storage.getCookie('_lr_env_src_ats'); let samplingRateCookie = storage.getCookie('_lr_sampling_rate'); if (!samplingRateCookie) { - preflightRequest(envelopeSourceCookieValue, events); + preflightRequest(events); } else { - if (atsAnalyticsAdapter.shouldFireRequest(parseInt(samplingRateCookie)) && envelopeSourceCookieValue != null) { + if (atsAnalyticsAdapter.shouldFireRequest(parseInt(samplingRateCookie))) { logInfo('ATS Analytics - events to send: ', events); sendDataToAnalytic(events); } @@ -399,7 +401,7 @@ atsAnalyticsAdapter.callHandler = function (evtype, args) { adaptermanager.registerAnalyticsAdapter({ adapter: atsAnalyticsAdapter, - code: 'atsAnalytics', + code: MODULE_CODE, gvlid: 97 }); diff --git a/modules/audiencerunBidAdapter.js b/modules/audiencerunBidAdapter.js index 2744e38e820..e716fe94c8b 100644 --- a/modules/audiencerunBidAdapter.js +++ b/modules/audiencerunBidAdapter.js @@ -1,18 +1,16 @@ import { + _each, deepAccess, - isFn, - logError, + formatQS, getBidIdParameter, getValue, - getBidIdParameter, - _each, isArray, + isFn, + logError, triggerPixel, - formatQS, } from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { createEidsArray } from './userId/eids.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'audiencerun'; const BASE_URL = 'https://d.audiencerun.com'; @@ -71,12 +69,7 @@ function getPageReferer() { * @return {string} */ function getPageUrl(bidderRequest) { - return ( - config.getConfig('pageUrl') || - deepAccess(bidderRequest, 'refererInfo.referer') || - getPageReferer() || - null - ); + return bidderRequest?.refererInfo?.page } export const spec = { @@ -120,17 +113,20 @@ export const spec = { bidId: bid.bidId, bidderRequestId: getBidIdParameter('bidderRequestId', bid), adUnitCode: getBidIdParameter('adUnitCode', bid), + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: getBidIdParameter('auctionId', bid), - transactionId: getBidIdParameter('transactionId', bid), + transactionId: bid.ortb2Imp?.ext?.tid || '', }; }); const payload = { libVersion: this.version, - pageUrl: config.getConfig('pageUrl'), + pageUrl: bidderRequest?.refererInfo?.page, + // TODO: does it make sense to find a half-way referer? what should these parameters pick pageReferer: getPageReferer(), - referer: deepAccess(bidderRequest, 'refererInfo.referer'), - refererInfo: deepAccess(bidderRequest, 'refererInfo'), + referer: deepAccess(bidderRequest, 'refererInfo.topmostLocation'), + // TODO: please do not send internal data structures over the network + refererInfo: deepAccess(bidderRequest, 'refererInfo.legacy'), currencyCode: config.getConfig('currency.adServerCurrency'), timeout: config.getConfig('bidderTimeout'), bids, @@ -138,7 +134,7 @@ export const spec = { payload.uspConsent = deepAccess(bidderRequest, 'uspConsent'); payload.schain = deepAccess(bidRequests, '0.schain'); - payload.userId = deepAccess(bidRequests, '0.userId') ? createEidsArray(bidRequests[0].userId) : []; + payload.userId = deepAccess(bidRequests, '0.userIdAsEids') || [] if (bidderRequest && bidderRequest.gdprConsent) { payload.gdpr = { diff --git a/modules/automatadAnalyticsAdapter.js b/modules/automatadAnalyticsAdapter.js new file mode 100644 index 00000000000..7d7bd8cb34c --- /dev/null +++ b/modules/automatadAnalyticsAdapter.js @@ -0,0 +1,325 @@ +import { + logError, + logInfo, + logMessage +} from '../src/utils.js'; + +import CONSTANTS from '../src/constants.json'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import { config } from '../src/config.js' + +/** Prebid Event Handlers */ + +const ADAPTER_CODE = 'automatadAnalytics' +const trialCountMilsMapping = [1500, 3000, 5000, 10000]; + +var isLoggingEnabled; var queuePointer = 0; var retryCount = 0; var timer = null; var __atmtdAnalyticsQueue = []; + +const prettyLog = (level, text, isGroup = false, cb = () => {}) => { + if (self.isLoggingEnabled === undefined) { + if (window.localStorage.getItem('__aggLoggingEnabled')) { + self.isLoggingEnabled = true + } else { + const queryParams = new URLSearchParams(new URL(window.location.href).search) + self.isLoggingEnabled = queryParams.has('aggLoggingEnabled') + } + } + + if (self.isLoggingEnabled) { + if (isGroup) { + logInfo(`ATD Analytics Adapter: ${level.toUpperCase()}: ${text} --- Group Start ---`) + try { + cb(); + } catch (error) { + logError(`ATD Analytics Adapter: ERROR: ${'Error during cb function in prettyLog'}`) + } + logInfo(`ATD Analytics Adapter: ${level.toUpperCase()}: ${text} --- Group End ---`) + } else { + logInfo(`ATD Analytics Adapter: ${level.toUpperCase()}: ${text}`) + } + } +} + +const processEvents = () => { + if (self.retryCount === trialCountMilsMapping.length) { + self.prettyLog('error', `Aggregator still hasn't loaded. Processing que stopped`, trialCountMilsMapping, self.retryCount) + return; + } + + self.prettyLog('status', `Que has been inactive for a while. Adapter starting to process que now... Trial Count = ${self.retryCount + 1}`) + + let shouldTryAgain = false + + while (self.queuePointer < self.__atmtdAnalyticsQueue.length) { + const eventType = self.__atmtdAnalyticsQueue[self.queuePointer][0] + const args = self.__atmtdAnalyticsQueue[self.queuePointer][1] + + try { + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: + if (window.atmtdAnalytics && window.atmtdAnalytics.auctionInitHandler) { + window.atmtdAnalytics.auctionInitHandler(args); + } else { + shouldTryAgain = true + } + break; + case CONSTANTS.EVENTS.BID_REQUESTED: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidRequestedHandler) { + window.atmtdAnalytics.bidRequestedHandler(args); + } + break; + case CONSTANTS.EVENTS.BID_RESPONSE: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidResponseHandler) { + window.atmtdAnalytics.bidResponseHandler(args); + } + break; + case CONSTANTS.EVENTS.BID_REJECTED: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidRejectedHandler) { + window.atmtdAnalytics.bidRejectedHandler(args); + } + break; + case CONSTANTS.EVENTS.BIDDER_DONE: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidderDoneHandler) { + window.atmtdAnalytics.bidderDoneHandler(args); + } + break; + case CONSTANTS.EVENTS.BID_WON: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidWonHandler) { + window.atmtdAnalytics.bidWonHandler(args); + } + break; + case CONSTANTS.EVENTS.NO_BID: + if (window.atmtdAnalytics && window.atmtdAnalytics.noBidHandler) { + window.atmtdAnalytics.noBidHandler(args); + } + break; + case CONSTANTS.EVENTS.BID_TIMEOUT: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidderTimeoutHandler) { + window.atmtdAnalytics.bidderTimeoutHandler(args); + } + break; + case CONSTANTS.EVENTS.AUCTION_DEBUG: + if (window.atmtdAnalytics && window.atmtdAnalytics.auctionDebugHandler) { + window.atmtdAnalytics.auctionDebugHandler(args); + } + break; + case 'slotRenderEnded': + if (window.atmtdAnalytics && window.atmtdAnalytics.slotRenderEndedGPTHandler) { + window.atmtdAnalytics.slotRenderEndedGPTHandler(args); + } else { + shouldTryAgain = true + } + break; + case 'impressionViewable': + if (window.atmtdAnalytics && window.atmtdAnalytics.impressionViewableHandler) { + window.atmtdAnalytics.impressionViewableHandler(args); + } else { + shouldTryAgain = true + } + break; + } + + if (shouldTryAgain) break; + } catch (error) { + self.prettyLog('error', `Unhandled Error while processing ${eventType} of ${self.queuePointer}th index in the que. Will not be retrying this raw event ...`, true, () => { + logError(`The error is `, error) + }) + } + + self.queuePointer = self.queuePointer + 1 + } + + if (shouldTryAgain) { + if (trialCountMilsMapping[self.retryCount]) self.prettyLog('warn', `Adapter failed to process event as aggregator has not loaded. Retrying in ${trialCountMilsMapping[self.retryCount]}ms ...`); + setTimeout(self.processEvents, trialCountMilsMapping[self.retryCount]) + self.retryCount = self.retryCount + 1 + } +} + +const addGPTHandlers = () => { + const googletag = window.googletag || {} + googletag.cmd = googletag.cmd || [] + googletag.cmd.push(() => { + googletag.pubads().addEventListener('slotRenderEnded', (event) => { + if (window.atmtdAnalytics && window.atmtdAnalytics.slotRenderEndedGPTHandler) { + if (window.__atmtdAggregatorFirstAuctionInitialized === true) { + window.atmtdAnalytics.slotRenderEndedGPTHandler(event) + return; + } + } + self.__atmtdAnalyticsQueue.push(['slotRenderEnded', event]) + self.prettyLog(`warn`, `Aggregator not initialised at auctionInit, exiting slotRenderEnded handler and pushing to que instead`) + }) + + googletag.pubads().addEventListener('impressionViewable', (event) => { + if (window.atmtdAnalytics && window.atmtdAnalytics.impressionViewableHandler) { + if (window.__atmtdAggregatorFirstAuctionInitialized === true) { + window.atmtdAnalytics.impressionViewableHandler(event) + return; + } + } + self.__atmtdAnalyticsQueue.push(['impressionViewable', event]) + self.prettyLog(`warn`, `Aggregator not initialised at auctionInit, exiting impressionViewable handler and pushing to que instead`) + }) + }) +} + +const initializeQueue = () => { + self.__atmtdAnalyticsQueue.push = (args) => { + Array.prototype.push.apply(self.__atmtdAnalyticsQueue, [args]); + if (timer) { + clearTimeout(timer); + timer = null; + } + + if (args[0] === CONSTANTS.EVENTS.AUCTION_INIT) { + const timeout = parseInt(config.getConfig('bidderTimeout')) + 1500 + timer = setTimeout(() => { + self.processEvents() + }, timeout); + } else { + timer = setTimeout(() => { + self.processEvents() + }, 1500); + } + }; +} + +// ANALYTICS ADAPTER + +let baseAdapter = adapter({analyticsType: 'bundle'}); +let atmtdAdapter = Object.assign({}, baseAdapter, { + + disableAnalytics() { + baseAdapter.disableAnalytics.apply(this, arguments); + }, + + track({eventType, args}) { + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: + if (window.atmtdAnalytics && window.atmtdAnalytics.auctionInitHandler) { + self.prettyLog('status', 'Aggregator loaded, initialising auction through handlers'); + window.atmtdAnalytics.auctionInitHandler(args); + } else { + self.prettyLog('warn', 'Aggregator not loaded, initialising auction through que ...'); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.BID_REQUESTED: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidRequestedHandler) { + window.atmtdAnalytics.bidRequestedHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.BID_REJECTED: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidRejectedHandler) { + window.atmtdAnalytics.bidRejectedHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.BID_RESPONSE: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidResponseHandler) { + window.atmtdAnalytics.bidResponseHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.BIDDER_DONE: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidderDoneHandler) { + window.atmtdAnalytics.bidderDoneHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.BID_WON: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidWonHandler) { + window.atmtdAnalytics.bidWonHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.NO_BID: + if (window.atmtdAnalytics && window.atmtdAnalytics.noBidHandler) { + window.atmtdAnalytics.noBidHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.AUCTION_DEBUG: + if (window.atmtdAnalytics && window.atmtdAnalytics.auctionDebugHandler) { + window.atmtdAnalytics.auctionDebugHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + case CONSTANTS.EVENTS.BID_TIMEOUT: + if (window.atmtdAnalytics && window.atmtdAnalytics.bidderTimeoutHandler) { + window.atmtdAnalytics.bidderTimeoutHandler(args); + } else { + self.prettyLog('warn', `Aggregator not loaded, pushing ${eventType} to que instead ...`); + self.__atmtdAnalyticsQueue.push([eventType, args]) + } + break; + } + } +}); + +atmtdAdapter.originEnableAnalytics = atmtdAdapter.enableAnalytics + +atmtdAdapter.enableAnalytics = function (configuration) { + if ((configuration === undefined && typeof configuration !== 'object') || configuration.options === undefined) { + logError('A valid configuration must be passed to the Atmtd Analytics Adapter.'); + return; + } + + const conf = configuration.options + + if (conf === undefined || typeof conf !== 'object' || conf.siteID === undefined || conf.publisherID === undefined) { + logError('A valid publisher ID and siteID must be passed to the Atmtd Analytics Adapter.'); + return; + } + + self.initializeQueue() + self.addGPTHandlers() + + window.__atmtdSDKConfig = { + publisherID: conf.publisherID, + siteID: conf.siteID, + collectDebugMessages: conf.logDebug ? conf.logDebug : false + } + + logMessage(`Automatad Analytics Adapter enabled with sdk config`, window.__atmtdSDKConfig) + + // eslint-disable-next-line + atmtdAdapter.originEnableAnalytics(configuration) +}; + +/// /////////// ADAPTER REGISTRATION ////////////// + +adapterManager.registerAnalyticsAdapter({ + adapter: atmtdAdapter, + code: ADAPTER_CODE +}); + +export var self = { + __atmtdAnalyticsQueue, + processEvents, + initializeQueue, + addGPTHandlers, + prettyLog, + queuePointer, + retryCount, + isLoggingEnabled +} + +export default atmtdAdapter; diff --git a/modules/automatadAnalyticsAdapter.md b/modules/automatadAnalyticsAdapter.md new file mode 100644 index 00000000000..2be1af87f20 --- /dev/null +++ b/modules/automatadAnalyticsAdapter.md @@ -0,0 +1,23 @@ + +# Overview + +Module Name: Automatad Analytics Adapter +Module Type: Analytics Adapter +Maintainer: tech@automatad.com + +# Description + +Analytics adapter for automatad.com. Contact tech@automatad.com for information. + +# Test Parameters + +``` +{ + provider: 'automatadAnalytics', + options: { + publisherID: 'N8vZLx', + siteID: 'PXfvBq' + } +} + +``` \ No newline at end of file diff --git a/modules/automatadBidAdapter.js b/modules/automatadBidAdapter.js index 726bbef9bd6..bea2a9df5b2 100644 --- a/modules/automatadBidAdapter.js +++ b/modules/automatadBidAdapter.js @@ -1,7 +1,7 @@ -import { logInfo } from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js' -import {BANNER} from '../src/mediaTypes.js' -import {ajax} from '../src/ajax.js' +import {logInfo} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {ajax} from '../src/ajax.js'; const BIDDER = 'automatad' @@ -18,7 +18,7 @@ export const spec = { isBidRequestValid: function (bid) { // will receive request bid. check if have necessary params for bidding - return (bid && bid.hasOwnProperty('params') && bid.params.hasOwnProperty('siteId') && bid.params.hasOwnProperty('placementId') && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty('banner')) + return (bid && bid.hasOwnProperty('params') && bid.params.hasOwnProperty('siteId') && bid.params.siteId != null && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty('banner') && typeof bid.mediaTypes.banner == 'object') }, buildRequests: function (validBidRequests, bidderRequest) { @@ -29,28 +29,41 @@ export const spec = { const siteId = validBidRequests[0].params.siteId const impressions = validBidRequests.map(bidRequest => { - return { - id: bidRequest.bidId, - adUnitCode: bidRequest.adUnitCode, - placement: bidRequest.params.placementId, - banner: { - format: bidRequest.sizes.map(sizeArr => ({ - w: sizeArr[0], - h: sizeArr[1], - })) - }, + if (bidRequest.params.hasOwnProperty('placementId')) { + return { + id: bidRequest.bidId, + adUnitCode: bidRequest.adUnitCode, + placement: bidRequest.params.placementId, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1], + })) + }, + } + } else { + return { + id: bidRequest.bidId, + adUnitCode: bidRequest.adUnitCode, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1], + })) + }, + } } }) // params from bid request const openrtbRequest = { - id: validBidRequests[0].auctionId, + id: bidderRequest.bidderRequestId, imp: impressions, site: { id: siteId, - domain: window.location.hostname, - page: window.location.href, - ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null, + domain: bidderRequest.refererInfo?.domain, + page: bidderRequest.refererInfo?.page, + ref: bidderRequest.refererInfo?.ref }, } @@ -61,7 +74,7 @@ export const spec = { data: payloadString, options: { contentType: 'application/json', - withCredentials: false, + withCredentials: true, crossOrigin: true, }, } @@ -101,7 +114,7 @@ export const spec = { }, onTimeout: function(timeoutData) { const timeoutUrl = ENDPOINT_URL + '/timeout' - ajax(timeoutUrl, null, JSON.stringify(timeoutData)) + spec.ajaxCall(timeoutUrl, null, JSON.stringify(timeoutData), {method: 'POST', withCredentials: true}) }, onBidWon: function(bid) { if (!bid.nurl) { return } @@ -123,11 +136,15 @@ export const spec = { /\$\{AUCTION_ID\}/, bid.auctionId ) - spec.ajaxCall(winUrl, null) + spec.ajaxCall(winUrl, null, null, {method: 'GET', withCredentials: true}) return true }, - ajaxCall: function(endpoint, data) { - ajax(endpoint, data) + + ajaxCall: function(endpoint, callback, data, options = {}) { + if (data) { + options.contentType = 'application/json' + } + ajax(endpoint, callback, data, options) }, } diff --git a/modules/automatadBidAdapter.md b/modules/automatadBidAdapter.md index 56a4b53c067..94bc707c75b 100644 --- a/modules/automatadBidAdapter.md +++ b/modules/automatadBidAdapter.md @@ -25,8 +25,8 @@ var adUnits = [ bids: [{ bidder: 'automatad', params: { - siteId: 'someValue', - placementId: 'someValue' + siteId: 'someValue', // required + placementId: 'someValue' // optional } }] } diff --git a/modules/avocetBidAdapter.md b/modules/avocetBidAdapter.md deleted file mode 100644 index 95cb29303f2..00000000000 --- a/modules/avocetBidAdapter.md +++ /dev/null @@ -1,40 +0,0 @@ -# Overview - -``` -Module Name: Avocet Bidder Adapter -Module Type: Bidder Adapter -Maintainer: developers@avocet.io -``` - -# Description - -Module that connects to the Avocet advertising platform. - -# Parameters - -| Name | Scope | Description | Example | -| :------------ | :------- | :---------------------------------- | :------------------------- | -| `placement` | required | A Placement ID from Avocet. | "5ebd27607781b9af3ccc3332" | - - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: "avct", - params: { - placement: "5ebd27607781b9af3ccc3332" - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/axisBidAdapter.js b/modules/axisBidAdapter.js new file mode 100644 index 00000000000..8d7f2dd04fd --- /dev/null +++ b/modules/axisBidAdapter.js @@ -0,0 +1,210 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'axis'; +const AD_URL = 'https://prebid.axis-marketplace.com/pbjs'; +const SYNC_URL = 'https://cs.axis-marketplace.com'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { integration, token } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + integration, + token, + bidId, + schain, + bidfloor + }; + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.pos = mediaTypes[BANNER].pos; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.pos = mediaTypes[VIDEO].pos; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + placement.context = mediaTypes[VIDEO].context; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (e) { + logError(e); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && params.integration && params.token); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + iabCat: deepAccess(bidderRequest, 'ortb2.site.cat'), + coppa: deepAccess(bidderRequest, 'ortb2.regs.coppa') ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout || 3000, + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/axisBidAdapter.md b/modules/axisBidAdapter.md new file mode 100644 index 00000000000..d1625a56176 --- /dev/null +++ b/modules/axisBidAdapter.md @@ -0,0 +1,83 @@ +# Overview + +``` +Module Name: Axis Bidder Adapter +Module Type: Axis Bidder Adapter +Maintainer: help@axis-marketplace.com +``` + +# Description + +Connects to Axis exchange for bids. +Axis bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + pos: 1 + } + }, + bids: [ + { + bidder: 'axis', + params: { + integration: '000000', + token: '000000' + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + minduration: 5, + maxduration: 60, + pos: 1 + } + }, + bids: [ + { + bidder: 'axis', + params: { + integration: '000000', + token: '000000' + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'axis', + params: { + integration: '000000', + token: '000000' + } + } + ] + } + ]; +``` diff --git a/modules/axonixBidAdapter.js b/modules/axonixBidAdapter.js index a790a89a0c1..87c3aff444a 100644 --- a/modules/axonixBidAdapter.js +++ b/modules/axonixBidAdapter.js @@ -1,8 +1,8 @@ -import { isArray, logError, deepAccess, isEmpty, triggerPixel, replaceAuctionPrice } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; -import { ajax } from '../src/ajax.js'; +import {deepAccess, isArray, isEmpty, logError, replaceAuctionPrice, triggerPixel} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import {ajax} from '../src/ajax.js'; const BIDDER_CODE = 'axonix'; const BIDDER_VERSION = '1.0.2'; @@ -25,12 +25,11 @@ function getBidFloor(bidRequest) { } function getPageUrl(bidRequest, bidderRequest) { - let pageUrl = config.getConfig('pageUrl'); - + let pageUrl; if (bidRequest.params.referrer) { pageUrl = bidRequest.params.referrer; - } else if (!pageUrl) { - pageUrl = bidderRequest.refererInfo.referer; + } else { + pageUrl = bidderRequest.refererInfo.page; } return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl; @@ -151,7 +150,7 @@ export const spec = { for (const resp of response) { if (resp.requestId) { responses.push(Object.assign(resp, { - ttl: config.getConfig('_bidderTimeout') + ttl: 60 })); } } diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 1c341e4dc51..658fc30b43b 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -7,15 +7,15 @@ import { isFn, logWarn, parseSizesInput, - parseUrl + parseUrl, + formatQS } from '../src/utils.js'; -import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {Renderer} from '../src/Renderer.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {find, includes} from '../src/polyfill.js'; -const ADAPTER_VERSION = '1.19'; +const ADAPTER_VERSION = '1.20'; const ADAPTER_NAME = 'BFIO_PREBID'; const OUTSTREAM = 'outstream'; const CURRENCY = 'USD'; @@ -23,6 +23,8 @@ const CURRENCY = 'USD'; export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id='; export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display'; export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; +export const SYNC_IFRAME_ENDPOINT = 'https://sync.bfmio.com/sync_iframe'; +export const SYNC_IMAGE_ENDPOINT = 'https://sync.bfmio.com/syncb'; export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement', 'skip', 'skipmin', 'skipafter']; export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; @@ -31,7 +33,7 @@ export const SUPPORTED_USER_IDS = [ { key: 'tdid', source: 'adserver.org', rtiPartner: 'TDID', queryParam: 'tdid' }, { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' }, { key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' }, - { key: 'haloId', source: 'audigent.com', atype: 1, queryParam: 'haloid' } + { key: 'hadronId', source: 'audigent.com', atype: 1, queryParam: 'hadronid' } ]; let appId = ''; @@ -104,7 +106,6 @@ export const spec = { let responseMeta = Object.assign({ mediaType: VIDEO, advertiserDomains: [] }, response.meta); let bidResponse = { requestId: bidRequest.bidId, - bidderCode: spec.code, cpm: response.bidPrice, width: firstSize.w, height: firstSize.h, @@ -154,11 +155,22 @@ export const spec = { } }, - getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '') { - let syncs = []; + getUserSyncs(syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = {}) { let { gdprApplies, consentString = '' } = gdprConsent; + let { gppString = '', applicableSections = [] } = gppConsent; let bannerResponse = find(serverResponses, (res) => isArray(res.body)); + let syncs = []; + let params = { + id: appId, + gdpr: gdprApplies ? 1 : 0, + gc: consentString, + gce: 1, + us_privacy: uspConsent, + gpp: gppString, + gpp_sid: Array.isArray(applicableSections) ? applicableSections.join(',') : '' + }; + if (bannerResponse) { if (syncOptions.iframeEnabled) { bannerResponse.body @@ -173,12 +185,12 @@ export const spec = { } else if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: `https://sync.bfmio.com/sync_iframe?ifg=1&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString}&gce=1&us_privacy=${uspConsent}` + url: `${SYNC_IFRAME_ENDPOINT}?ifg=1&${formatQS(params)}` }); } else if (syncOptions.pixelEnabled) { syncs.push({ type: 'image', - url: `https://sync.bfmio.com/syncb?pid=144&id=${appId}&gdpr=${gdprApplies ? 1 : 0}&gc=${consentString}&gce=1&us_privacy=${uspConsent}` + url: `${SYNC_IMAGE_ENDPOINT}?pid=144&${formatQS(params)}` }); } @@ -305,16 +317,7 @@ function isBannerBidValid(bid) { } function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); -} - -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } + return parseUrl(bidderRequest?.refererInfo?.page, { decodeSearchAsString: true }); } function getEids(bid) { @@ -369,7 +372,7 @@ function createVideoRequestData(bid, bidderRequest) { let tagid = getVideoBidParam(bid, 'tagid'); let topLocation = getTopWindowLocation(bidderRequest); let eids = getEids(bid); - let ortb2 = deepClone(config.getConfig('ortb2')); + let ortb2 = deepClone(bidderRequest.ortb2); let payload = { isPrebid: true, appId: appId, @@ -415,6 +418,12 @@ function createVideoRequestData(bid, bidderRequest) { deepSetValue(payload, 'user.ext.consent', consentString); } + if (bidderRequest && bidderRequest.gppConsent) { + let { gppString, applicableSections } = bidderRequest.gppConsent; + deepSetValue(payload, 'regs.gpp', gppString); + deepSetValue(payload, 'regs.gpp_sid', applicableSections); + } + if (bid.schain) { deepSetValue(payload, 'source.ext.schain', bid.schain); } @@ -433,7 +442,7 @@ function createVideoRequestData(bid, bidderRequest) { function createBannerRequestData(bids, bidderRequest) { let topLocation = getTopWindowLocation(bidderRequest); - let topReferrer = getTopWindowReferrer(); + let topReferrer = bidderRequest.refererInfo?.ref; let slots = bids.map(bid => { return { slot: bid.adUnitCode, @@ -443,7 +452,7 @@ function createBannerRequestData(bids, bidderRequest) { sizes: getBannerSizes(bid) }; }); - let ortb2 = deepClone(config.getConfig('ortb2')); + let ortb2 = deepClone(bidderRequest.ortb2); let payload = { slots: slots, ortb2: ortb2, @@ -470,6 +479,12 @@ function createBannerRequestData(bids, bidderRequest) { payload.gdprConsent = consentString; } + if (bidderRequest && bidderRequest.gppConsent) { + let { gppString, applicableSections } = bidderRequest.gppConsent; + payload.gpp = gppString; + payload.gppSid = applicableSections; + } + if (bids[0] && bids[0].schain) { payload.schain = bids[0].schain; } diff --git a/modules/bedigitechBidAdapter.js b/modules/bedigitechBidAdapter.js new file mode 100644 index 00000000000..9e59a2509a6 --- /dev/null +++ b/modules/bedigitechBidAdapter.js @@ -0,0 +1,70 @@ +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {_each, isArray} from '../src/utils.js'; + +const BEDIGITECH_CODE = 'bedigitech'; +const BEDIGITECH_ENDPOINT = 'https://bid.bedigitech.com/bid/pub_bid.php'; +const BEDIGITECH_REQUEST_METHOD = 'GET'; +const BEDIGITECH_CURRENCY = 'USD'; +let requestId = ''; +function interpretResponse(placementResponse, bids) { + const bid = { + id: placementResponse.id, + requestId: requestId || placementResponse.id, + bidderCode: 'bedigitech', + cpm: placementResponse.cpm, + ad: decodeURIComponent(placementResponse.ad), + width: placementResponse.width || 0, + height: placementResponse.height || 0, + currency: placementResponse.currency || BEDIGITECH_CURRENCY, + ttl: placementResponse.ttl || 300, + creativeId: placementResponse.crid, + requestTimestamp: placementResponse.requestTime, + timeToRespond: placementResponse.timeToRespond || 300, + netRevenue: placementResponse.netRevenue, + meta: { + mediaType: BANNER, + }, + }; + bids.push(bid); +} + +export const spec = { + code: BEDIGITECH_CODE, + supportedMediaTypes: [BANNER, NATIVE], + isBidRequestValid: bid => { + requestId = ''; + requestId = bid.bidId + return !!bid.params.placementId && !!bid.bidId && bid.bidder === 'bedigitech' + }, + + buildRequests: (bidRequests) => { + return bidRequests.map(bid => { + let url = BEDIGITECH_ENDPOINT; + const data = {'pid': bid.params.placementId}; + return { + method: BEDIGITECH_REQUEST_METHOD, + url, + data, + options: { + contentType: 'application/json', + withCredentials: false, + crossOrigin: true, + }, + }; + }); + }, + + interpretResponse: function(serverResponse) { + let bids = []; + if (isArray(serverResponse.body)) { + _each(serverResponse.body, function(placementResponse) { + interpretResponse(placementResponse, bids); + }); + } + return bids; + }, + +}; + +registerBidder(spec); diff --git a/modules/bedigitechBidAdapter.md b/modules/bedigitechBidAdapter.md new file mode 100644 index 00000000000..3baa12aeb74 --- /dev/null +++ b/modules/bedigitechBidAdapter.md @@ -0,0 +1,32 @@ +# Overview + +Module Name: Bedigitech Bidder Adapter + +Module Type: Bidder Adapter + +Maintainer: prebid@bedigitech.com + +# Description + +You can use this adapter to get a bid from bedigitech.com. + +About us : https://www.bedigitech.com/ + + +# Test Parameters +```javascript + var adUnits = [ + { + code: 'div-bedigitech-example', + sizes: [[300, 250]], + bids: [ + { + bidder: "bedigitech", + params: { + placementId: 309 + } + } + ] + } + ]; +``` diff --git a/modules/beopBidAdapter.js b/modules/beopBidAdapter.js index 2e74170fcaf..b6b6107ddd0 100644 --- a/modules/beopBidAdapter.js +++ b/modules/beopBidAdapter.js @@ -1,6 +1,17 @@ -import { deepAccess, isArray, logWarn, triggerPixel, buildUrl, logInfo, getValue, getBidIdParameter } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; +import { + buildUrl, + deepAccess, getBidIdParameter, + getValue, + isArray, + logInfo, + logWarn, + triggerPixel +} from '../src/utils.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; + const BIDDER_CODE = 'beop'; const ENDPOINT_URL = 'https://hb.beop.io/bid'; const TCF_VENDOR_ID = 666; @@ -36,23 +47,33 @@ export const spec = { */ buildRequests: function(validBidRequests, bidderRequest) { const slots = validBidRequests.map(beOpRequestSlotsMaker); - let pageUrl = deepAccess(window, 'location.href') || deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl'); - let fpd = config.getLegacyFpd(config.getConfig('ortb2')); - let gdpr = bidderRequest.gdprConsent; - let firstSlot = slots[0]; - let payloadObject = { + const firstPartyData = bidderRequest.ortb2 || {}; + const psegs = firstPartyData.user?.ext?.permutive || firstPartyData.user?.ext?.data?.permutive || []; + const userBpSegs = firstPartyData.user?.ext?.bpsegs || firstPartyData.user?.ext?.data?.bpsegs || []; + const siteBpSegs = firstPartyData.site?.ext?.bpsegs || firstPartyData.site?.ext?.data?.bpsegs || []; + const pageUrl = getPageUrl(bidderRequest.refererInfo, window); + const gdpr = bidderRequest.gdprConsent; + const firstSlot = slots[0]; + const kwdsFromRequest = firstSlot.kwds; + let keywords = getAllOrtbKeywords(bidderRequest.ortb2, kwdsFromRequest); + + const payloadObject = { at: new Date().toString(), nid: firstSlot.nid, nptnid: firstSlot.nptnid, pid: firstSlot.pid, + psegs: psegs, + bpsegs: (userBpSegs.concat(siteBpSegs)).map(item => item.toString()), url: pageUrl, lang: (window.navigator.language || window.navigator.languages[0]), - kwds: (fpd && fpd.site && fpd.site.keywords) || [], + kwds: keywords, dbg: false, slts: slots, is_amp: deepAccess(bidderRequest, 'referrerInfo.isAmp'), + gdpr_applies: gdpr ? gdpr.gdprApplies : false, tc_string: (gdpr && gdpr.gdprApplies) ? gdpr.consentString : null, }; + const payloadString = JSON.stringify(payloadObject); return { method: 'POST', @@ -99,18 +120,18 @@ export const spec = { } function buildTrackingParams(data, info, value) { - const accountId = data.params.accountId; + let params = Array.isArray(data.params) ? data.params[0] : data.params; + const pageUrl = getPageUrl(null, window); return { - pid: accountId === undefined ? data.ad.match(/account: \“([a-f\d]{24})\“/)[1] : accountId, - nid: data.params.networkId, - nptnid: data.params.networkPartnerId, + pid: params.accountId === undefined ? data.ad.match(/account: \“([a-f\d]{24})\“/)[1] : params.accountId, + nid: params.networkId, + nptnid: params.networkPartnerId, bid: data.bidId || data.requestId, sl_n: data.adUnitCode, - aid: data.auctionId, se_ca: 'bid', se_ac: info, se_va: value, - url: window.location.href + url: pageUrl }; } @@ -128,17 +149,60 @@ function beOpRequestSlotsMaker(bid) { sizes: isArray(bannerSizes) ? bannerSizes : bid.sizes, flr: floor, pid: getValue(bid.params, 'accountId'), + kwds: getValue(bid.params, 'keywords'), nid: getValue(bid.params, 'networkId'), nptnid: getValue(bid.params, 'networkPartnerId'), bid: getBidIdParameter('bidId', bid), brid: getBidIdParameter('bidderRequestId', bid), name: getBidIdParameter('adUnitCode', bid), - aid: getBidIdParameter('auctionId', bid), - tid: getBidIdParameter('transactionId', bid), + tid: bid.ortb2Imp?.ext?.tid || '', brc: getBidIdParameter('bidRequestsCount', bid), bdrc: getBidIdParameter('bidderRequestCount', bid), bwc: getBidIdParameter('bidderWinsCount', bid), } } +const protocolRelativeRegExp = /^\/\// +function isProtocolRelativeUrl(url) { + return url && url.match(protocolRelativeRegExp) != null; +} + +const withProtocolRegExp = /[a-z]{1,}:\/\// +function isNoProtocolUrl(url) { + return url && url.match(withProtocolRegExp) == null; +} + +function ensureProtocolInUrl(url, defaultProtocol) { + if (isProtocolRelativeUrl(url)) { + return `${defaultProtocol}${url}`; + } else if (isNoProtocolUrl(url)) { + return `${defaultProtocol}//${url}`; + } + return url; +} + +/** + * sometimes trying to access a field (protected?) triggers an exception + * Ex deepAccess(window, 'top.location.href') might throw if it crosses origins + * so here is a lenient version + */ +function safeDeepAccess(obj, path) { + try { + return deepAccess(obj, path) + } catch (_e) { + return null; + } +} + +function getPageUrl(refererInfo, window) { + refererInfo = refererInfo || getRefererInfo(); + let pageUrl = refererInfo.canonicalUrl || safeDeepAccess(window, 'top.location.href') || deepAccess(window, 'location.href'); + // Ensure the protocol is present (looks like sometimes the extracted pageUrl misses it) + if (pageUrl != null) { + const defaultProtocol = safeDeepAccess(window, 'top.location.protocol') || deepAccess(window, 'location.protocol'); + pageUrl = ensureProtocolInUrl(pageUrl, defaultProtocol); + } + return pageUrl; +} + registerBidder(spec); diff --git a/modules/beopBidAdapter.md b/modules/beopBidAdapter.md index c0e88cb1ceb..53d2542b69c 100644 --- a/modules/beopBidAdapter.md +++ b/modules/beopBidAdapter.md @@ -9,13 +9,14 @@ Module that connects to BeOp's demand sources # Test Parameters + ``` var adUnits = [ { code: 'in-article', mediaTypes: { banner: { - sizes: [[1,1]], + sizes: [[1,1]], } }, bids: [ @@ -31,3 +32,36 @@ Module that connects to BeOp's demand sources ]; ``` +# Custom Bidder data + +If you want to pass your first party data to BeOp, you can set your bidder `config.ortb2` object with + +```json +{ + "site": { + "ext": { + "bpsegs": ["Your", 1, "ST", "party", "data"], + "data": { + "bpsegs": ["Your", 1, "ST", "party", "data"] + } + } + }, + "user": { + "ext": { + "bpsegs": ["Your", 1, "ST", "party", "data"], + "data": { + "bpsegs": ["Your", 1, "ST", "party", "data"] + } + } + } +} +``` + +You can choose the location between: + +- `site.ext` +- `site.ext.data` +- `user.ext` +- `user.ext.data` + +and our BidAdapter will be able to find them diff --git a/modules/betweenBidAdapter.js b/modules/betweenBidAdapter.js index acf574a3fe2..6883b7cce2c 100644 --- a/modules/betweenBidAdapter.js +++ b/modules/betweenBidAdapter.js @@ -1,7 +1,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { getAdUnitSizes, parseSizesInput } from '../src/utils.js'; -import { getRefererInfo } from '../src/refererDetection.js'; -import {includes} from '../src/polyfill.js' +import {parseSizesInput} from '../src/utils.js'; +import {includes} from '../src/polyfill.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; const BIDDER_CODE = 'between'; let ENDPOINT = 'https://ads.betweendigital.com/adjson?t=prebid'; @@ -29,7 +29,7 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { let requests = []; const gdprConsent = bidderRequest && bidderRequest.gdprConsent; - const refInfo = getRefererInfo(); + const refInfo = bidderRequest?.refererInfo; validBidRequests.forEach((i) => { const video = i.mediaTypes && i.mediaTypes.video; @@ -44,7 +44,8 @@ export const spec = { rr: getRr(), s: i.params && i.params.s, bidid: i.bidId, - transactionid: i.transactionId, + transactionid: i.ortb2Imp?.ext?.tid, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionid: i.auctionId }; @@ -53,16 +54,16 @@ export const spec = { params.maxd = video.maxd; params.mind = video.mind; params.pos = 'atf'; - ENDPOINT += '&jst=pvc'; + params.jst = 'pvc'; params.codeType = includes(CODE_TYPES, video.codeType) ? video.codeType : 'inpage'; } if (i.params.itu !== undefined) { params.itu = i.params.itu; } - if (i.params.cur !== undefined) { - params.cur = i.params.cur; - } + + params.cur = i.params.cur || 'USD'; + if (i.params.subid !== undefined) { params.subid = i.params.subid; } @@ -79,7 +80,8 @@ export const spec = { params.schain = encodeToBase64WebSafe(JSON.stringify(i.schain)); } - if (refInfo && refInfo.referer) params.ref = refInfo.referer; + // TODO: is 'page' the right value here? + if (refInfo && refInfo.page) params.ref = refInfo.page; if (gdprConsent) { if (typeof gdprConsent.gdprApplies !== 'undefined') { @@ -90,7 +92,7 @@ export const spec = { } } - requests.push({data: params}) + requests.push({data: params}); }) return { method: 'POST', diff --git a/modules/beyondmediaBidAdapter.js b/modules/beyondmediaBidAdapter.js new file mode 100644 index 00000000000..bbcd972470c --- /dev/null +++ b/modules/beyondmediaBidAdapter.js @@ -0,0 +1,202 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'beyondmedia'; +const AD_URL = 'https://backend.andbeyond.media/pbjs'; +const SYNC_URL = 'https://cookies.andbeyond.media'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + placement.placementId = placementId; + placement.type = 'publisher'; + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && params.placementId); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } + + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/beyondmediaBidAdapter.md b/modules/beyondmediaBidAdapter.md new file mode 100644 index 00000000000..e828bdfd808 --- /dev/null +++ b/modules/beyondmediaBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: AndBeyond.Media Bidder Adapter +Module Type: AndBeyond.Media Bidder Adapter +Maintainer: sysengg@andbeyond.media +``` + +# Description + +Connects to AndBeyond.Media exchange for bids. +AndBeyond.Media bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'beyondmedia', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'beyondmedia', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'beyondmedia', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/bidViewability.js b/modules/bidViewability.js index 837eccd00c1..be18095e369 100644 --- a/modules/bidViewability.js +++ b/modules/bidViewability.js @@ -7,7 +7,7 @@ import * as events from '../src/events.js'; import CONSTANTS from '../src/constants.json'; import {isFn, logWarn, triggerPixel} from '../src/utils.js'; import {getGlobal} from '../src/prebidGlobal.js'; -import adapterManager, {gdprDataHandler, uspDataHandler} from '../src/adapterManager.js'; +import adapterManager, {gdprDataHandler, uspDataHandler, gppDataHandler} from '../src/adapterManager.js'; import {find} from '../src/polyfill.js'; const MODULE_NAME = 'bidViewability'; @@ -44,6 +44,11 @@ export let fireViewabilityPixels = (globalModuleConfig, bid) => { const uspConsent = uspDataHandler.getConsentData(); if (uspConsent) { queryParams.us_privacy = uspConsent; } + const gppConsent = gppDataHandler.getConsentData(); + if (gppConsent) { + // TODO - need to know what to set here for queryParams... + } + bid[BID_VURL_ARRAY].forEach(url => { // add '?' if not present in URL if (Object.keys(queryParams).length > 0 && url.indexOf('?') === -1) { @@ -62,13 +67,20 @@ export let logWinningBidNotFound = (slot) => { export let impressionViewableHandler = (globalModuleConfig, slot, event) => { let respectiveBid = getMatchingWinningBidForGPTSlot(globalModuleConfig, slot); + let respectiveDeferredAdUnit = getGlobal().adUnits.find(adUnit => adUnit.deferBilling && respectiveBid.adUnitCode === adUnit.code); + if (respectiveBid === null) { logWinningBidNotFound(slot); } else { // if config is enabled AND VURL array is present then execute each pixel fireViewabilityPixels(globalModuleConfig, respectiveBid); // trigger respective bidder's onBidViewable handler - adapterManager.callBidViewableBidder(respectiveBid.bidder, respectiveBid); + adapterManager.callBidViewableBidder(respectiveBid.adapterCode || respectiveBid.bidder, respectiveBid); + + if (respectiveDeferredAdUnit) { + adapterManager.callBidBillableBidder(respectiveBid); + } + // emit the BID_VIEWABLE event with bid details, this event can be consumed by bidders and analytics pixels events.emit(CONSTANTS.EVENTS.BID_VIEWABLE, respectiveBid); } diff --git a/modules/bidViewability.md b/modules/bidViewability.md index 78a1539fb1a..922a4a9def4 100644 --- a/modules/bidViewability.md +++ b/modules/bidViewability.md @@ -2,19 +2,20 @@ Module Name: bidViewability -Purpose: Track when a bid is viewable +Purpose: Track when a bid is viewable (and also ready for billing) Maintainer: harshad.mane@pubmatic.com # Description -- This module, when included, will trigger a BID_VIEWABLE event which can be consumed by Analytics adapters, bidders will need to implement `onBidViewable` method to capture this event -- Bidderes can check if this module is part of the final build and whether it is enabled or not by accessing ```pbjs.getConfig('bidViewability')``` +- This module, when included, will trigger a BID_VIEWABLE event which can be consumed by Analytics adapters, bidders will need to implement the `onBidViewable` method to capture this event +- Bidders can check if this module is part of the final build and whether it is enabled or not by accessing ```pbjs.getConfig('bidViewability')``` - GPT API is used to find when a bid is viewable, https://developers.google.com/publisher-tag/reference#googletag.events.impressionviewableevent . This event is fired when an impression becomes viewable, according to the Active View criteria. Refer: https://support.google.com/admanager/answer/4524488 -- The module does not work with adserver other than GAM with GPT integration +- This module does not work with any adserver's other than GAM with GPT integration - Logic used to find a matching pbjs-bid for a GPT slot is ``` (slot.getAdUnitPath() === bid.adUnitCode || slot.getSlotElementId() === bid.adUnitCode) ``` this logic can be changed by using param ```customMatchFunction``` -- When a rendered PBJS bid is viewable the module will trigger BID_VIEWABLE event, which can be consumed by bidders and analytics adapters -- For the viewable bid if ```bid.vurls type array``` param is and module config ``` firePixels: true ``` is set then the URLs mentioned in bid.vurls will be executed. Please note that GDPR and USP related parameters will be added to the given URLs +- When a rendered PBJS bid is viewable the module will trigger a BID_VIEWABLE event, which can be consumed by bidders and analytics adapters +- If the viewable bid contains a ```vurls``` param containing URL's and the Bid Viewability module is configured with ``` firePixels: true ``` then the URLs mentioned in bid.vurls will be called. Please note that GDPR and USP related parameters will be added to the given URLs +- This module is also compatible with Prebid core's billing deferral logic, this means that bids linked to an ad unit marked with `deferBilling: true` will trigger a bid adapter's `onBidBillable` function (if present) indicating an ad slot was viewed and also billing ready (if it were deferred). # Params - enabled [required] [type: boolean, default: false], when set to true, the module will emit BID_VIEWABLE when applicable @@ -44,6 +45,6 @@ Refer: https://support.google.com/admanager/answer/4524488 ``` # Please Note: -- Doesn't seems to work with Instream Video, https://docs.prebid.org/dev-docs/examples/instream-banner-mix.html as GPT's impressionViewable event is not triggered for instream-video-creative -- Works with Banner, Outsteam, Native creatives +- This module doesn't seem to work with Instream Video, https://docs.prebid.org/dev-docs/examples/instream-banner-mix.html as GPT's impressionViewable event is not triggered for instream-video-creative +- Works with Banner, Outsteam and Native creatives diff --git a/modules/bidfluenceBidAdapter.md b/modules/bidfluenceBidAdapter.md deleted file mode 100644 index 34dbb3d3a1c..00000000000 --- a/modules/bidfluenceBidAdapter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Overview - -``` -Module Name: Bidfluence Adapter -Module Type: Bidder Adapter -Maintainer: integrations@bidfluence.com -prebid_1_0_supported : true -gdpr_supported: true -``` - -# Description - -Bidfluence adapter for prebid. - -# Test Parameters - -``` -var adUnits = [ - { - code: 'test-prebid', - sizes: [[300, 250]], - bids: [{ - bidder: 'bidfluence', - params: { - placementId: '1000', - publisherId: '1000' - } - }] - } -] -``` diff --git a/modules/bidglassBidAdapter.js b/modules/bidglassBidAdapter.js index 3184372881b..a29976cfcb7 100644 --- a/modules/bidglassBidAdapter.js +++ b/modules/bidglassBidAdapter.js @@ -1,4 +1,4 @@ -import { _each, isArray, getBidIdParameter, deepClone, getUniqueIdentifierStr } from '../src/utils.js'; +import {_each, isArray, deepClone, getUniqueIdentifierStr, getBidIdParameter} from '../src/utils.js'; // import {config} from 'src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; diff --git a/modules/bidlabBidAdapter.md b/modules/bidlabBidAdapter.md deleted file mode 100644 index 3e5fe3128ed..00000000000 --- a/modules/bidlabBidAdapter.md +++ /dev/null @@ -1,53 +0,0 @@ -# Overview - -``` -Module Name: bidlab Bidder Adapter -Module Type: bidlab Bidder Adapter -``` - -# Description - -Module that connects to bidlab demand sources - -# Test Parameters -``` - var adUnits = [ - // Will return static test banner - { - code: 'placementId_0', - mediaTypes: { - banner: { - sizes: [[300, 250]], - } - }, - bids: [ - { - bidder: 'bidlab', - params: { - placementId: 0, - traffic: 'banner' - } - } - ] - }, - // Will return test vast xml. All video params are stored under placement in publishers UI - { - code: 'placementId_0', - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'instream' - } - }, - bids: [ - { - bidder: 'bidlab', - params: { - placementId: 0, - traffic: 'video' - } - } - ] - } - ]; -``` diff --git a/modules/bidphysicsBidAdapter.md b/modules/bidphysicsBidAdapter.md deleted file mode 100644 index d7d8b355027..00000000000 --- a/modules/bidphysicsBidAdapter.md +++ /dev/null @@ -1,33 +0,0 @@ -# Overview - -``` -Module Name: BidPhysics Bid Adapter -Module Type: Bidder Adapter -Maintainer: info@bidphysics.com -``` - -# Description - -Connects to BidPhysics exchange for bids. - -BidPhysics bid adapter supports Banner ads. - -# Test Parameters -``` -var adUnits = [ - { - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]] - } - }, - bids: [{ - bidder: 'bidphysics', - params: { - unitId: 'bidphysics-test' - } - }] - } -]; -``` diff --git a/modules/bidscubeBidAdapter.js b/modules/bidscubeBidAdapter.js index 951bd97d255..6cdbba61c75 100644 --- a/modules/bidscubeBidAdapter.js +++ b/modules/bidscubeBidAdapter.js @@ -1,6 +1,7 @@ import { logMessage, getWindowLocation } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js' import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js' +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'bidscube' const URL = 'https://supply.bidscube.com/?c=o&m=multi' @@ -15,6 +16,9 @@ export const spec = { }, buildRequests: function (validBidRequests) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + validBidRequests = validBidRequests || [] let winTop = window try { diff --git a/modules/bidwatchAnalyticsAdapter.js b/modules/bidwatchAnalyticsAdapter.js new file mode 100644 index 00000000000..289e607686f --- /dev/null +++ b/modules/bidwatchAnalyticsAdapter.js @@ -0,0 +1,240 @@ +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import CONSTANTS from '../src/constants.json'; +import { ajax } from '../src/ajax.js'; +import { getRefererInfo } from '../src/refererDetection.js'; + +const analyticsType = 'endpoint'; +const url = 'URL_TO_SERVER_ENDPOINT'; + +const { + EVENTS: { + AUCTION_END, + BID_WON, + BID_RESPONSE, + BID_REQUESTED, + BID_TIMEOUT, + } +} = CONSTANTS; + +let saveEvents = {} +let allEvents = {} +let auctionEnd = {} +let initOptions = {} +let endpoint = 'https://default' +let requestsAttributes = ['adUnitCode', 'auctionId', 'bidder', 'bidderCode', 'bidId', 'cpm', 'creativeId', 'currency', 'width', 'height', 'mediaType', 'netRevenue', 'originalCpm', 'originalCurrency', 'requestId', 'size', 'source', 'status', 'timeToRespond', 'transactionId', 'ttl', 'sizes', 'mediaTypes', 'src', 'params', 'userId', 'labelAny', 'bids', 'adId']; + +function getAdapterNameForAlias(aliasName) { + return adapterManager.aliasRegistry[aliasName] || aliasName; +} + +function filterAttributes(arg, removead) { + let response = {}; + if (typeof arg == 'object') { + if (typeof arg['bidderCode'] == 'string') { + response['originalBidder'] = getAdapterNameForAlias(arg['bidderCode']); + } else if (typeof arg['bidder'] == 'string') { + response['originalBidder'] = getAdapterNameForAlias(arg['bidder']); + } + if (!removead && typeof arg['ad'] != 'undefined') { + response['ad'] = arg['ad']; + } + if (typeof arg['gdprConsent'] != 'undefined') { + response['gdprConsent'] = {}; + if (typeof arg['gdprConsent']['consentString'] != 'undefined') { response['gdprConsent']['consentString'] = arg['gdprConsent']['consentString']; } + } + if (typeof arg['meta'] == 'object' && typeof arg['meta']['advertiserDomains'] != 'undefined') { + response['meta'] = {'advertiserDomains': arg['meta']['advertiserDomains']}; + } + requestsAttributes.forEach((attr) => { + if (typeof arg[attr] != 'undefined') { response[attr] = arg[attr]; } + }); + if (typeof response['creativeId'] == 'number') { response['creativeId'] = response['creativeId'].toString(); } + } + return response; +} + +function cleanAuctionEnd(args) { + let response = {}; + let filteredObj; + let objects = ['bidderRequests', 'bidsReceived', 'noBids', 'adUnits']; + objects.forEach((attr) => { + if (Array.isArray(args[attr])) { + response[attr] = []; + args[attr].forEach((obj) => { + filteredObj = filterAttributes(obj, true); + if (typeof obj['bids'] == 'object') { + filteredObj['bids'] = []; + obj['bids'].forEach((bid) => { + filteredObj['bids'].push(filterAttributes(bid, true)); + }); + } + response[attr].push(filteredObj); + }); + } + }); + return response; +} + +function cleanCreatives(args) { + let stringArgs = JSON.parse(dereferenceWithoutRenderer(args)); + return filterAttributes(stringArgs, false); +} + +function enhanceMediaType(arg) { + saveEvents['bidRequested'].forEach((bidRequested) => { + if (bidRequested['auctionId'] == arg['auctionId'] && Array.isArray(bidRequested['bids'])) { + bidRequested['bids'].forEach((bid) => { + if (bid['transactionId'] == arg['transactionId'] && bid['bidId'] == arg['requestId']) { arg['mediaTypes'] = bid['mediaTypes']; } + }); + } + }); + return arg; +} + +function addBidResponse(args) { + let eventType = BID_RESPONSE; + let argsCleaned = cleanCreatives(args); ; + if (allEvents[eventType] == undefined) { allEvents[eventType] = [] } + allEvents[eventType].push(argsCleaned); +} + +function addBidRequested(args) { + let eventType = BID_REQUESTED; + let argsCleaned = filterAttributes(args, true); + if (saveEvents[eventType] == undefined) { saveEvents[eventType] = [] } + saveEvents[eventType].push(argsCleaned); +} + +function addTimeout(args) { + let eventType = BID_TIMEOUT; + if (saveEvents[eventType] == undefined) { saveEvents[eventType] = [] } + saveEvents[eventType].push(args); + let argsCleaned = []; + let argsDereferenced = {} + let stringArgs = JSON.parse(dereferenceWithoutRenderer(args)); + argsDereferenced = stringArgs; + argsDereferenced.forEach((attr) => { + argsCleaned.push(filterAttributes(JSON.parse(JSON.stringify(attr)), false)); + }); + if (auctionEnd[eventType] == undefined) { auctionEnd[eventType] = [] } + auctionEnd[eventType].push(argsCleaned); +} + +export const dereferenceWithoutRenderer = function(args) { + if (args.renderer) { + let tmp = args.renderer; + delete args.renderer; + let stringified = JSON.stringify(args); + args['renderer'] = tmp; + return stringified; + } + if (args.bidsReceived) { + let tmp = {} + for (let key in args.bidsReceived) { + if (args.bidsReceived[key].renderer) { + tmp[key] = args.bidsReceived[key].renderer; + delete args.bidsReceived[key].renderer; + } + } + let stringified = JSON.stringify(args); + for (let key in tmp) { + args.bidsReceived[key].renderer = tmp[key]; + } + return stringified; + } + return JSON.stringify(args); +} + +function addAuctionEnd(args) { + let eventType = AUCTION_END; + if (saveEvents[eventType] == undefined) { saveEvents[eventType] = [] } + saveEvents[eventType].push(args); + let argsCleaned = cleanAuctionEnd(JSON.parse(dereferenceWithoutRenderer(args))); + if (auctionEnd[eventType] == undefined) { auctionEnd[eventType] = [] } + auctionEnd[eventType].push(argsCleaned); +} + +function handleBidWon(args) { + args = enhanceMediaType(filterAttributes(JSON.parse(dereferenceWithoutRenderer(args)), true)); + let increment = args['cpm']; + if (typeof saveEvents['auctionEnd'] == 'object') { + saveEvents['auctionEnd'].forEach((auction) => { + if (auction['auctionId'] == args['auctionId'] && typeof auction['bidsReceived'] == 'object') { + auction['bidsReceived'].forEach((bid) => { + if (bid['transactionId'] == args['transactionId'] && bid['adId'] != args['adId']) { + if (args['cpm'] < bid['cpm']) { + increment = 0; + } else if (increment > args['cpm'] - bid['cpm']) { + increment = args['cpm'] - bid['cpm']; + } + } + }); + } + }); + } + args['cpmIncrement'] = increment; + args['referer'] = encodeURIComponent(getRefererInfo().page || getRefererInfo().topmostLocation); + if (typeof saveEvents.bidRequested == 'object' && saveEvents.bidRequested.length > 0 && saveEvents.bidRequested[0].gdprConsent) { args.gdpr = saveEvents.bidRequested[0].gdprConsent; } + ajax(endpoint + '.bidwatch.io/analytics/bid_won', null, JSON.stringify(args), {method: 'POST', withCredentials: true}); +} + +function handleAuctionEnd() { + ajax(endpoint + '.bidwatch.io/analytics/auctions', function (data) { + let list = JSON.parse(data); + if (Array.isArray(list) && typeof allEvents['bidResponse'] != 'undefined') { + let alreadyCalled = []; + allEvents['bidResponse'].forEach((bidResponse) => { + let tmpId = bidResponse['originalBidder'] + '_' + bidResponse['creativeId']; + if (list.includes(tmpId) && !alreadyCalled.includes(tmpId)) { + alreadyCalled.push(tmpId); + ajax(endpoint + '.bidwatch.io/analytics/creatives', null, JSON.stringify(bidResponse), {method: 'POST', withCredentials: true}); + } + }); + } + allEvents = {}; + }, JSON.stringify(auctionEnd), {method: 'POST', withCredentials: true}); + auctionEnd = {}; +} + +let bidwatchAnalytics = Object.assign(adapter({url, analyticsType}), { + track({ + eventType, + args + }) { + switch (eventType) { + case AUCTION_END: + addAuctionEnd(args); + handleAuctionEnd(); + break; + case BID_WON: + handleBidWon(args); + break; + case BID_RESPONSE: + addBidResponse(args); + break; + case BID_REQUESTED: + addBidRequested(args); + break; + case BID_TIMEOUT: + addTimeout(args); + break; + } + }}); + +// save the base class function +bidwatchAnalytics.originEnableAnalytics = bidwatchAnalytics.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +bidwatchAnalytics.enableAnalytics = function (config) { + bidwatchAnalytics.originEnableAnalytics(config); // call the base class function + initOptions = config.options; + if (initOptions.domain) { endpoint = 'https://' + initOptions.domain; } +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: bidwatchAnalytics, + code: 'bidwatch' +}); + +export default bidwatchAnalytics; diff --git a/modules/bidwatchAnalyticsAdapter.md b/modules/bidwatchAnalyticsAdapter.md new file mode 100644 index 00000000000..bfa453640b8 --- /dev/null +++ b/modules/bidwatchAnalyticsAdapter.md @@ -0,0 +1,21 @@ +# Overview +Module Name: bidwatch Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: tech@bidwatch.io + +# Description + +Analytics adapter for bidwatch.io. + +# Test Parameters + +``` +{ + provider: 'bidwatch', + options : { + domain: 'test.endpoint' + } +} +``` diff --git a/modules/big-richmediaBidAdapter.js b/modules/big-richmediaBidAdapter.js index cd8b2462eb8..8a03aac1ace 100644 --- a/modules/big-richmediaBidAdapter.js +++ b/modules/big-richmediaBidAdapter.js @@ -8,7 +8,7 @@ const BIDDER_CODE = 'big-richmedia'; const metadataByRequestId = {}; export const spec = { - version: '1.4.0', + version: '1.5.1', code: BIDDER_CODE, gvlid: baseAdapter.GVLID, // use base adapter gvlid supportedMediaTypes: [ BANNER, VIDEO ], @@ -78,6 +78,14 @@ export const spec = { customSelector, isReplayable }; + + // This is a workaround needed for the rendering step (so that the adserver iframe does not get resized to 1800x1000 + // when there is skin demand + if (format === 'skin') { + bid.width = 1 + bid.height = 1 + } + const encoded = window.btoa(JSON.stringify(renderParams)); bid.ad = ` `; diff --git a/modules/bizzclickBidAdapter.js b/modules/bizzclickBidAdapter.js index 6223626834d..dc7731231ab 100644 --- a/modules/bizzclickBidAdapter.js +++ b/modules/bizzclickBidAdapter.js @@ -1,7 +1,9 @@ -import { logMessage, getDNT, deepSetValue, deepAccess, _map, logWarn } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import {_map, deepAccess, deepSetValue, getDNT, logMessage, logWarn} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; + const BIDDER_CODE = 'bizzclick'; const ACCOUNTID_MACROS = '[account_id]'; const URL_ENDPOINT = `https://us-e-node1.bizzclick.com/bid?rtb_seat_id=prebidjs&secret_key=${ACCOUNTID_MACROS}`; @@ -57,13 +59,16 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + if (validBidRequests && validBidRequests.length === 0) return [] let accuontId = validBidRequests[0].params.accountId; const endpointURL = URL_ENDPOINT.replace(ACCOUNTID_MACROS, accuontId); let winTop = window; let location; try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page) winTop = window.top; } catch (e) { location = winTop.location; @@ -88,13 +93,14 @@ export const spec = { host: location.host }, source: { - tid: bidRequest.transactionId, + tid: bidRequest.ortb2Imp?.ext?.tid, ext: { schain: {} } }, regs: { coppa: config.getConfig('coppa') === true ? 1 : 0, + ext: {} }, user: { ext: {} @@ -106,25 +112,15 @@ export const spec = { imp: [impObject], }; - if (bidderRequest && bidderRequest.uspConsent) { - data.regs.ext.us_privacy = bidderRequest.uspConsent; - } - - if (bidderRequest && bidderRequest.gdprConsent) { - let { gdprApplies, consentString } = bidderRequest.gdprConsent; - data.regs.ext.gdpr = gdprApplies ? 1 : 0; - data.user.ext.consent = consentString; - } - - if (bidRequest.schain) { - deepSetValue(data, 'source.ext.schain', bidRequest.schain); - } - let connection = navigator.connection || navigator.webkitConnection; if (connection && connection.effectiveType) { data.device.connectiontype = connection.effectiveType; } if (bidRequest) { + if (bidRequest.schain) { + deepSetValue(data, 'source.ext.schain', bidRequest.schain); + } + if (bidRequest.gdprConsent && bidRequest.gdprConsent.gdprApplies) { deepSetValue(data, 'regs.ext.gdpr', bidRequest.gdprConsent.gdprApplies ? 1 : 0); deepSetValue(data, 'user.ext.consent', bidRequest.gdprConsent.consentString); @@ -239,7 +235,9 @@ const prepareImpObject = (bidRequest) => { }; const addNativeParameters = bidRequest => { let impObject = { - id: bidRequest.transactionId, + // TODO: top-level ID is not in ORTB native 1.2, is this intentional? + // (despite the name, this appears to be an ORTB native request - not an imp - object) + id: bidRequest.bidId, ver: NATIVE_VERSION, }; const assets = _map(bidRequest.mediaTypes.native, (bidParams, key) => { @@ -261,7 +259,7 @@ const addNativeParameters = bidRequest => { wmin = sizes[0]; hmin = sizes[1]; } - asset[props.name] = {} + asset[props.name] = {}; if (bidParams.len) asset[props.name]['len'] = bidParams.len; if (props.type) asset[props.name]['type'] = props.type; if (wmin) asset[props.name]['wmin'] = wmin; diff --git a/modules/bliinkBidAdapter.js b/modules/bliinkBidAdapter.js index 45b6c46c2df..6f3f5e21cb8 100644 --- a/modules/bliinkBidAdapter.js +++ b/modules/bliinkBidAdapter.js @@ -1,19 +1,59 @@ // eslint-disable-next-line prebid/validate-imports // eslint-disable-next-line prebid/validate-imports -import {registerBidder} from '../src/adapters/bidderFactory.js' +import { registerBidder } from '../src/adapters/bidderFactory.js' +import { config } from '../src/config.js' +import {_each, deepAccess, deepSetValue} from '../src/utils.js' export const BIDDER_CODE = 'bliink' -export const BLIINK_ENDPOINT_ENGINE = 'https://engine.bliink.io/delivery' -export const BLIINK_ENDPOINT_ENGINE_VAST = 'https://engine.bliink.io/vast' -export const BLIINK_ENDPOINT_COOKIE_SYNC = 'https://cookiesync.api.bliink.io' +export const BLIINK_ENDPOINT_ENGINE = 'https://engine.bliink.io/prebid' + +export const BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME = 'https://tag.bliink.io/usersync.html' export const META_KEYWORDS = 'keywords' export const META_DESCRIPTION = 'description' const VIDEO = 'video' const BANNER = 'banner' - +window.bliinkBid = window.bliinkBid || {}; const supportedMediaTypes = [BANNER, VIDEO] const aliasBidderCode = ['bk'] +/** + * @description get coppa value from config + */ +function getCoppa() { + return config.getConfig('coppa') === true ? 1 : 0; +} + +/** + * Retrieves the effective connection type from the browser's Navigator API. + * @returns {string} The effective connection type or 'unsupported' if unavailable. + */ +export function getEffectiveConnectionType() { + /** + * The effective connection type obtained from the browser's Navigator API. + * @type {string|undefined} + */ + const navigatorEffectiveType = navigator?.connection?.effectiveType; + + if (navigatorEffectiveType) { + return navigatorEffectiveType; + } + + return 'unsupported'; +} + +/** + * Retrieves the user IDs as EIDs from the first valid bid request. + * + * @param {Array} validBidRequests - Array of valid bid requests + * @returns {Array|undefined} - Array of user IDs as EIDs, or undefined if not found + */ +export function getUserIds(validBidRequests) { + /** @type {Object} */ + const firstBidRequest = validBidRequests?.[0] + if (firstBidRequest?.userIds) { + return firstBidRequest.userIds + } +} export function getMetaList(name) { if (!name || name.length === 0) return [] @@ -52,7 +92,7 @@ export function getOneMetaValue(query) { return metaEl.content } - return null + return null; } export function getMetaValue(name) { @@ -75,79 +115,51 @@ export function getKeywords() { ] if (keywords && keywords.length > 0) { - return keywords - .filter((value) => value) - .map((value) => value.trim()) + return keywords.filter((value) => value).map((value) => value.trim()); } } - return [] -} - -export const parseXML = (content) => { - if (typeof content !== 'string' || content.length === 0) return null - - const parser = new DOMParser() - let xml; - - try { - xml = parser.parseFromString(content, 'text/xml') - } catch (e) {} - - if (xml && - xml.getElementsByTagName('VAST')[0] && - xml.getElementsByTagName('VAST')[0].tagName === 'VAST') { - return xml - } - - return null + return []; } /** * @param bidRequest - * @param bliinkCreative - * @return {{cpm, netRevenue: boolean, requestId, width: (*|number), currency, ttl: number, creativeId, height: (*|number)} & {mediaType: string, vastXml}} + * @return {({cpm, netRevenue: boolean, requestId, width: number, currency, ttl: number, creativeId, height: number}&{mediaType: string, vastXml})|null} */ -export const buildBid = (bidRequest, bliinkCreative) => { - if (!bidRequest && !bliinkCreative) return null - - const body = { - requestId: bidRequest.bidId, - currency: bliinkCreative.currency, - cpm: bliinkCreative.price, - creativeId: bliinkCreative.creativeId, - width: (bidRequest.sizes && bidRequest.sizes[0][0]) || 1, - height: (bidRequest.sizes && bidRequest.sizes[0][1]) || 1, - netRevenue: false, - ttl: 3600, - } - - // eslint-disable-next-line no-mixed-operators - if ((bliinkCreative) && bidRequest && - // eslint-disable-next-line no-mixed-operators - !bidRequest.bidId || - !bidRequest.sizes || - !bidRequest.params || - !(bidRequest.params.placement) - ) return null - - delete bidRequest['bids'] +export const buildBid = (bidResponse) => { + const mediaType = deepAccess(bidResponse, 'creative.media_type'); + if (!mediaType) return null; - switch (bliinkCreative.media_type) { + let bid; + switch (mediaType) { case VIDEO: - return Object.assign(body, { - mediaType: VIDEO, - vastXml: bliinkCreative.content, - }) + const vastXml = deepAccess(bidResponse, 'creative.video.content'); + bid = { + vastXml, + mediaType: 'video', + vastUrl: 'data:text/xml;charset=utf-8;base64,' + btoa(vastXml.replace(/\\"/g, '"')) + }; + break; case BANNER: - return Object.assign(body, { - mediaType: BANNER, - ad: (bliinkCreative && bliinkCreative.content && bliinkCreative.content.creative && bliinkCreative.content.creative.adm) || '', - }) - default: + bid = { + ad: deepAccess(bidResponse, 'creative.banner.adm'), + mediaType: 'banner', + }; break; + default: + return null; } -} + return Object.assign(bid, { + cpm: bidResponse.price, + currency: bidResponse.currency || 'EUR', + creativeId: deepAccess(bidResponse, 'extras.deal_id'), + requestId: deepAccess(bidResponse, 'extras.transaction_id'), + width: deepAccess(bidResponse, `creative.${bid.mediaType}.width`) || 1, + height: deepAccess(bidResponse, `creative.${bid.mediaType}.height`) || 1, + ttl: 300, + netRevenue: true, + }); +}; /** * @description Verify the the AdUnits.bids, respond with true (valid) or false (invalid). @@ -156,60 +168,67 @@ export const buildBid = (bidRequest, bliinkCreative) => { * @return boolean */ export const isBidRequestValid = (bid) => { - return !(!bid || !bid.params || !bid.params.placement || !bid.params.tagId) -} + return !!deepAccess(bid, 'params.tagId'); +}; /** * @description Takes an array of valid bid requests, all of which are guaranteed to have passed the isBidRequestValid() test. * - * @param _[] + * @param validBidRequests * @param bidderRequest - * @return {{ method: string, url: string } | null} + * @returns {null|{method: string, data: {gdprConsent: string, keywords: string, pageTitle: string, pageDescription: (*|string), pageUrl, gdpr: boolean, tags: *}, url: string}} */ -export const buildRequests = (_, bidderRequest) => { - if (!bidderRequest) return null +export const buildRequests = (validBidRequests, bidderRequest) => { + if (!validBidRequests || !bidderRequest || !bidderRequest.bids) return null - let data = { - pageUrl: bidderRequest.refererInfo.referer, + const tags = bidderRequest.bids.map((bid) => { + const id = bid.params.tagId + return { + sizes: bid.sizes.map((size) => ({ w: size[0], h: size[1] })), + id, + // TODO: bidId is globally unique, is it a good choice for transaction ID (vs ortb2Imp.ext.tid)? + transactionId: bid.bidId, + mediaTypes: Object.keys(bid.mediaTypes), + imageUrl: deepAccess(bid, 'params.imageUrl', ''), + videoUrl: deepAccess(bid, 'params.videoUrl', ''), + refresh: (window.bliinkBid[id] = (window.bliinkBid[id] ?? -1) + 1) || undefined, + }; + }); + + let request = { + tags, + pageTitle: document.title, + pageUrl: deepAccess(bidderRequest, 'refererInfo.page'), pageDescription: getMetaValue(META_DESCRIPTION), keywords: getKeywords().join(','), - gdpr: false, - gdpr_consent: '', - pageTitle: document.title, - } - - const endPoint = bidderRequest.bids[0].params.placement === VIDEO ? BLIINK_ENDPOINT_ENGINE_VAST : BLIINK_ENDPOINT_ENGINE + ect: getEffectiveConnectionType(), + }; - const params = { - bidderRequestId: bidderRequest.bidderRequestId, - bidderCode: bidderRequest.bidderCode, - bids: bidderRequest.bids, - refererInfo: bidderRequest.refererInfo, + const schain = deepAccess(validBidRequests[0], 'schain') + const userIds = getUserIds(validBidRequests) + if (schain) { + request.schain = schain } - - if (bidderRequest.gdprConsent) { - data = Object.assign(data, { - gdpr: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies, - gdpr_consent: bidderRequest.gdprConsent.consentString - }) + if (userIds) { + request.userIds = userIds } - - if (bidderRequest.bids && bidderRequest.bids.length > 0 && bidderRequest.bids[0].sizes && bidderRequest.bids[0].sizes[0]) { - data = Object.assign(data, { - width: bidderRequest.bids[0].sizes[0][0], - height: bidderRequest.bids[0].sizes[0][1] - }) - - return { - method: 'GET', - url: `${endPoint}/${bidderRequest.bids[0].params.tagId}`, - data: data, - params: params, - } + const gdprConsent = deepAccess(bidderRequest, 'gdprConsent'); + if (!!gdprConsent && gdprConsent.gdprApplies) { + request.gdpr = true + deepSetValue(request, 'gdprConsent', gdprConsent.consentString); } - - return null -} + if (config.getConfig('coppa')) { + request.coppa = 1 + } + if (bidderRequest.uspConsent) { + deepSetValue(request, 'uspConsent', bidderRequest.uspConsent); + } + return { + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, + data: request, + }; +}; /** * @description Parse the response (from buildRequests) and generate one or more bid objects. @@ -218,51 +237,15 @@ export const buildRequests = (_, bidderRequest) => { * @param request * @return */ -const interpretResponse = (serverResponse, request) => { - if ((serverResponse && serverResponse.mode === 'no-ad')) { - return [] - } - - const body = serverResponse.body - const serverBody = request.params - - const xml = parseXML(body) - - let creative; - - switch (serverBody.bids[0].params.placement) { - case xml && VIDEO: - const price = xml.getElementsByTagName('Price') && xml.getElementsByTagName('Price')[0] - const currency = xml.getElementsByTagName('Currency') && xml.getElementsByTagName('Currency')[0] - const creativeId = xml.getElementsByTagName('CreativeId') && xml.getElementsByTagName('CreativeId')[0] - - creative = { - content: body, - price: (price && price.textContent) || 0, - currency: (currency && currency.textContent) || 'EUR', - creativeId: creativeId || 0, - media_type: 'video', - } - - return buildBid(serverBody.bids[0], creative) - case BANNER: - if (body) { - creative = { - content: body, - price: body.price, - currency: body.currency, - creativeId: 0, - media_type: 'banner', - } - - return buildBid(serverBody.bids[0], creative) - } - - break - default: - break - } -} +const interpretResponse = (serverResponse) => { + const bodyResponse = deepAccess(serverResponse, 'body.bids') + if (!serverResponse.body || !bodyResponse) return [] + const bidResponses = []; + _each(bodyResponse, function (response) { + return bidResponses.push(buildBid(response)); + }); + return bidResponses.filter(bid => !!bid) +}; /** * @description If the publisher allows user-sync activity, the platform will call this function and the adapter may register pixels and/or iframe user syncs. For more information, see Registering User Syncs below @@ -271,54 +254,39 @@ const interpretResponse = (serverResponse, request) => { * @param gdprConsent * @return {[{type: string, url: string}]|*[]} */ -const getUserSyncs = (syncOptions, serverResponses, gdprConsent) => { - let syncs = [] - +const getUserSyncs = (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncs = []; if (syncOptions.pixelEnabled && serverResponses.length > 0) { + let gdprParams = '' + let uspConsentStr = '' + let apiVersion + let gdpr = false if (gdprConsent) { - const gdprParams = `consentString=${gdprConsent.consentString}` - const smartCallbackURL = encodeURIComponent(`${BLIINK_ENDPOINT_COOKIE_SYNC}/cookiesync?partner=smart&uid=[sas_uid]`) - const azerionCallbackURL = encodeURIComponent(`${BLIINK_ENDPOINT_COOKIE_SYNC}/cookiesync?partner=azerion&uid={PUB_USER_ID}`) - const appnexusCallbackURL = encodeURIComponent(`${BLIINK_ENDPOINT_COOKIE_SYNC}/cookiesync?partner=azerion&uid=$UID`) - return [ - { - type: 'script', - url: 'https://prg.smartadserver.com/ac?out=js&nwid=3392&siteid=305791&pgname=rg&fmtid=81127&tgt=[sas_target]&visit=m&tmstp=[timestamp]&clcturl=[countgo]' - }, - { - type: 'image', - url: `https://sync.smartadserver.com/getuid?nwid=3392&${gdprParams}&url=${smartCallbackURL}`, - }, - { - type: 'image', - url: `https://ad.360yield.com/server_match?partner_id=1531&${gdprParams}&r=${azerionCallbackURL}`, - }, - { - type: 'image', - url: `https://ads.stickyadstv.com/auto-user-sync?${gdprParams}`, - }, - { - type: 'image', - url: `https://cookiesync.api.bliink.io/getuid?url=https%3A%2F%2Fvisitor.omnitagjs.com%2Fvisitor%2Fsync%3Fuid%3D1625272249969090bb9d544bd6d8d645%26name%3DBLIINK%26visitor%3D%24UID%26external%3Dtrue&${gdprParams}`, - }, - { - type: 'image', - url: `https://cookiesync.api.bliink.io/getuid?url=https://pixel.advertising.com/ups/58444/sync?&gdpr=1&gdpr_consent=${gdprConsent.consentString}&redir=true&uid=$UID`, - }, - { - type: 'image', - url: `https://ups.analytics.yahoo.com/ups/58499/occ?gdpr=1&gdpr_consent=${gdprConsent.consentString}`, - }, + gdprParams = `&gdprConsent=${gdprConsent.consentString}`; + apiVersion = `&apiVersion=${gdprConsent.apiVersion}` + gdpr = Number( + gdprConsent.gdprApplies) + } + if (uspConsent) { + uspConsentStr = `&uspConsent=${uspConsent}`; + } + let sync; + if (syncOptions.iframeEnabled) { + sync = [ { - type: 'image', - url: `https://secure.adnxs.com/getuid?${appnexusCallbackURL}`, + type: 'iframe', + url: `${BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME}?gdpr=${gdpr}&coppa=${getCoppa()}${uspConsentStr}${gdprParams}${apiVersion}`, }, - ] + ]; + } else { + sync = deepAccess(serverResponses[0], 'body.userSyncs'); } + + return sync; } return syncs; -} +}; /** * @type {{interpretResponse: interpretResponse, code: string, aliases: string[], getUserSyncs: getUserSyncs, buildRequests: buildRequests, onTimeout: onTimeout, onSetTargeting: onSetTargeting, isBidRequestValid: isBidRequestValid, onBidWon: onBidWon}} @@ -331,6 +299,6 @@ export const spec = { buildRequests, interpretResponse, getUserSyncs, -} +}; -registerBidder(spec) +registerBidder(spec); diff --git a/modules/bliinkBidAdapter.md b/modules/bliinkBidAdapter.md index af7aee3a1ae..48b95a10ebb 100644 --- a/modules/bliinkBidAdapter.md +++ b/modules/bliinkBidAdapter.md @@ -3,10 +3,10 @@ ``` Module Name: BLIINK Bidder Adapter Module Type: Bidder Adapter -Maintainer: samuel@bliink.io | jonathan@bliink.io +Maintainer: samuel@bliink.io | ibrahima@bliink.io gdpr_supported: true tcf2_supported: true -media_types: banner, native, video +media_types: banner, video ``` # Description @@ -30,7 +30,6 @@ const adUnits = [ { bidder: 'bliink', params: { - placement: 'banner', tagId: '41' } } @@ -58,7 +57,6 @@ const adUnits = [ bidder: 'bliink', params: { tagId: '41', - placement: 'video', } } ] @@ -85,7 +83,6 @@ const adUnits = [ bidder: 'bliink', params: { tagId: '41', - placement: 'video', } } ] diff --git a/modules/bluebillywigBidAdapter.js b/modules/bluebillywigBidAdapter.js index d362dfa5fdb..d4bde9b3f2c 100644 --- a/modules/bluebillywigBidAdapter.js +++ b/modules/bluebillywigBidAdapter.js @@ -4,7 +4,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {Renderer} from '../src/Renderer.js'; -import {createEidsArray} from './userId/eids.js'; const DEV_MODE = window.location.search.match(/bbpbs_debug=true/); @@ -52,10 +51,9 @@ const BB_HELPERS = { else if (Array.isArray(adServerCur) && adServerCur.length) request.cur = [adServerCur[0]]; }, addUserIds: function(request, validBidRequests) { - const bidUserId = deepAccess(validBidRequests, '0.userId'); - const eids = createEidsArray(bidUserId); + const eids = deepAccess(validBidRequests, '0.userIdAsEids'); - if (eids.length) { + if (eids != null && eids.length) { deepSetValue(request, 'user.ext.eids', eids); } }, @@ -278,8 +276,8 @@ export const spec = { }); const request = { - id: bidderRequest.auctionId, - source: {tid: bidderRequest.auctionId}, + id: bidderRequest.bidderRequestId, + source: {tid: bidderRequest.ortb2?.source?.tid}, tmax: BB_CONSTANTS.DEFAULT_TIMEOUT, imp: imps, test: DEV_MODE ? 1 : 0, @@ -306,7 +304,7 @@ export const spec = { if (getConfig('coppa') == true) deepSetValue(request, 'regs.coppa', 1); // Enrich the request with any external data we may have - BB_HELPERS.addSiteAppDevice(request, bidderRequest.refererInfo && bidderRequest.refererInfo.referer); + BB_HELPERS.addSiteAppDevice(request, bidderRequest.refererInfo && bidderRequest.refererInfo.page); BB_HELPERS.addSchain(request, validBidRequests); BB_HELPERS.addCurrency(request); BB_HELPERS.addUserIds(request, validBidRequests); diff --git a/modules/blueconicRtdProvider.js b/modules/blueconicRtdProvider.js new file mode 100644 index 00000000000..b6eb9374671 --- /dev/null +++ b/modules/blueconicRtdProvider.js @@ -0,0 +1,95 @@ +/** + * This module adds the blueconic provider to the real time data module + * The {@link module:modules/realTimeData} module is required + * The module will fetch real-time data from Blueconic + * @module modules/blueconicRtdProvider + * @requires module:modules/realTimeData + */ + +import {getStorageManager} from '../src/storageManager.js'; +import {submodule} from '../src/hook.js'; +import {mergeDeep, isPlainObject, logMessage, logError} from '../src/utils.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; + +const MODULE_NAME = 'realTimeData'; +const SUBMODULE_NAME = 'blueconic'; + +export const RTD_LOCAL_NAME = 'bcPrebidData'; + +export const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: SUBMODULE_NAME}); + +/** +* Try parsing stringified array of data. +* @param {String} data +*/ +function parseJson(data) { + try { + return JSON.parse(data); + } catch (err) { + logError(`blueconicRtdProvider: failed to parse json:`, data); + return null; + } +} + +/** + * Add real-time data & merge segments. + * @param {Object} bidConfig + * @param {Object} rtd + * @param {Object} rtdConfig + */ +export function addRealTimeData(ortb2, rtd) { + if (isPlainObject(rtd.ortb2)) { + mergeDeep(ortb2, rtd.ortb2); + } +} + +/** + * Real-time data retrieval from BlueConic + * @param {Object} reqBidsConfigObj + * @param {function} onDone + * @param {Object} rtdConfig + * @param {Object} userConsent + */ +export function getRealTimeData(reqBidsConfigObj, onDone, rtdConfig, userConsent) { + if (rtdConfig && isPlainObject(rtdConfig.params)) { + const jsonData = storage.getDataFromLocalStorage(RTD_LOCAL_NAME); + if (jsonData) { + const parsedData = parseJson(jsonData); + if (!parsedData) { + return; + } + const userData = {name: 'blueconic', ...parsedData} + logMessage('blueconicRtdProvider: userData: ', userData); + const data = { + ortb2: { + user: { + data: [ + userData + ] + } + } + } + addRealTimeData(reqBidsConfigObj.ortb2Fragments?.global, data); + onDone(); + } + } +} + +/** + * Module init + * @param {Object} provider + * @param {Objkect} userConsent + * @return {boolean} + */ +function init(provider, userConsent) { + return true; +} + +/** @type {RtdSubmodule} */ +export const blueconicSubmodule = { + name: SUBMODULE_NAME, + getBidRequestData: getRealTimeData, + init: init +}; + +submodule(MODULE_NAME, blueconicSubmodule); diff --git a/modules/blueconicRtdProvider.md b/modules/blueconicRtdProvider.md new file mode 100644 index 00000000000..b28bc6468fb --- /dev/null +++ b/modules/blueconicRtdProvider.md @@ -0,0 +1,90 @@ +# Overview + +coppa_supported: true (COPPA support) + +Module Name: BlueConic Rtd Provider +Module Type: Rtd Provider +Maintainer: connectors@blueconic.com + + +## BlueConic Real-time Data Submodule + +The BlueConic real-time data module in Prebid has been built so that publishers +can maximize the power of their first-party audiences, user-level and contextual data. +This module provides both an integrated BlueConic identity with real-time +contextual and audience segmentation solution that seamlessly and easily +integrates into your existing Prebid deployment. + +BlueConic's Real-time Data Provider automatically obtains segmentation data and other user level data from the BlueConic script (via `localStorage`) and passes them to the bid-stream. Please reach out to BlueConic team(info@blueconic.com) or visit our [website](https://support.blueconic.com/hc/en-us) if you have any questions or need further help to integrate Prebid or blueconicRtdProvider. + +### Publisher Usage + +Compile the BlueConic RTD module into your Prebid build: + +`gulp build --modules=rtdModule,blueconicRtdProvider,appnexusBidAdapter` + +Add the BlueConic RTD provider to your Prebid config. In this example we will configure +publisher 1234 to retrieve segments, profile data from BlueConic. See the +"Parameter Descriptions" below for more detailed information of the +configuration parameters. Please work with your BlueConic Prebid support team +(info@blueconic.com) on which version of Prebid.js supports different bidder +and segment configurations. + +``` +pbjs.setConfig( + ... + realTimeData: { + auctionDelay: 1000, + dataProviders: [ + { + name: "blueconic", + waitForIt: true, + params: { + requestParams: { + publisherId: 1234, + coppa: true + } + } + } + ] + } + ... +} +``` + +### Parameter Descriptions for the Blueconic Configuration Section + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| name | String | Real time data module name | Always 'blueconic' | +| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | +| params | Object | | | +| params.requestParams | Object | Publisher partner specific configuration options, such as optional publisher id, coppa config and other segment query related metadata | Optional | + + +Please see the examples available in the blueconicRtdProvider_spec.js +tests and work with your Blueconic Prebid integration team (connectors@blueconic.com). + +#### COPPA support + +COPPA support can be enabled for all the visitors by changing the config value: + +```js +config.setConfig({ coppa: true }); +``` + +### Testing + +To run test suite for blueconic: + +`gulp test --modules=rtdModule,blueconicRtdProvider,appnexusBidAdapter` + +### Example + +To view an example of available segments: + +`gulp serve --modules=rtdModule,blueconicRtdProvider,appnexusBidAdapter` + +and then point your browser at: + +`http://localhost:9999/integrationExamples/gpt/blueconicRtdProvider_example.html` diff --git a/modules/boldwinBidAdapter.js b/modules/boldwinBidAdapter.js index fcff7134a92..4d97f830d33 100644 --- a/modules/boldwinBidAdapter.js +++ b/modules/boldwinBidAdapter.js @@ -1,6 +1,7 @@ import { isFn, deepAccess, logMessage } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'boldwin'; const AD_URL = 'https://ssp.videowalldirect.com/pbjs'; @@ -45,14 +46,18 @@ export const spec = { supportedMediaTypes: [BANNER, VIDEO, NATIVE], isBidRequestValid: (bid) => { - return Boolean(bid.bidId && bid.params && bid.params.placementId); + return Boolean(bid.bidId && bid.params && (bid.params.placementId || bid.params.endpointId)); }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page); winTop = window.top; } catch (e) { location = winTop.location; @@ -73,23 +78,32 @@ export const spec = { request.ccpa = bidderRequest.uspConsent; } if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent + request.gdpr = bidderRequest.gdprConsent; + } + + // Add GPP consent + if (bidderRequest.gppConsent) { + request.gpp = bidderRequest.gppConsent.gppString; + request.gpp_sid = bidderRequest.gppConsent.applicableSections; + } else if (bidderRequest.ortb2?.regs?.gpp) { + request.gpp = bidderRequest.ortb2.regs.gpp; + request.gpp_sid = bidderRequest.ortb2.regs.gpp_sid; } } const len = validBidRequests.length; for (let i = 0; i < len; i++) { let bid = validBidRequests[i]; - const { mediaTypes } = bid; + const { mediaTypes, params } = bid; const placement = {}; let sizes; if (mediaTypes) { if (mediaTypes[BANNER] && mediaTypes[BANNER].sizes) { placement.adFormat = BANNER; - sizes = mediaTypes[BANNER].sizes + sizes = mediaTypes[BANNER].sizes; } else if (mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize) { placement.adFormat = VIDEO; - sizes = mediaTypes[VIDEO].playerSize + sizes = mediaTypes[VIDEO].playerSize; placement.minduration = mediaTypes[VIDEO].minduration; placement.maxduration = mediaTypes[VIDEO].maxduration; placement.mimes = mediaTypes[VIDEO].mimes; @@ -109,9 +123,18 @@ export const spec = { placement.native = mediaTypes[NATIVE]; } } + + const { placementId, endpointId } = params; + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + placements.push({ ...placement, - placementId: bid.params.placementId, bidId: bid.bidId, sizes: sizes || [], wPlayer: sizes ? sizes[0] : 0, diff --git a/modules/boldwinBidAdapter.md b/modules/boldwinBidAdapter.md index 5e2a5b139b3..47f4b4ffe78 100644 --- a/modules/boldwinBidAdapter.md +++ b/modules/boldwinBidAdapter.md @@ -47,5 +47,22 @@ Module that connects to boldwin demand sources } ] } + // Will return static test banner + { + code: 'endpointId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'boldwin', + params: { + endpointId: 'testBanner', + } + } + ] + }, ]; ``` diff --git a/modules/brainyBidAdapter.md b/modules/brainyBidAdapter.md deleted file mode 100644 index 0f8308f6cc3..00000000000 --- a/modules/brainyBidAdapter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Overview - -``` -Module Name: brainy Bid Adapter -Module Type: Bidder Adapter -Maintainer: support@mg.brainy-inc.co.jp -``` - -# Description -This module connects to brainy's demand sources. It supports display, and rich media formats. -brainy will provide ``accountID`` and ``slotID`` that are specific to your ad type. -Please reach out to ``support@mg.brainy-inc.co.jp`` to set up an brainy account and above ids. -Use bidder code ```brainy``` for all brainy traffic. - - -# Test Parameters - -``` - var adUnits = [{ - code: 'test-div', - sizes: [[300, 250], - bids: [{ - bidder: 'brainy', - params: { - accountID: "3481", - slotID: "5569" - } - }] - } - ]; -``` diff --git a/modules/brandmetricsRtdProvider.js b/modules/brandmetricsRtdProvider.js index 60d3c98f15e..bd7a33ff037 100644 --- a/modules/brandmetricsRtdProvider.js +++ b/modules/brandmetricsRtdProvider.js @@ -5,24 +5,30 @@ * @module modules/brandmetricsRtdProvider * @requires module:modules/realTimeData */ -import { config } from '../src/config.js' -import { submodule } from '../src/hook.js' -import { deepSetValue, mergeDeep, logError, deepAccess } from '../src/utils.js' -import {loadExternalScript} from '../src/adloader.js' +import {submodule} from '../src/hook.js'; +import {deepAccess, deepSetValue, logError, mergeDeep, generateUUID} from '../src/utils.js'; +import {loadExternalScript} from '../src/adloader.js'; +import * as events from '../src/events.js'; +import CONSTANTS from '../src/constants.json'; + const MODULE_NAME = 'brandmetrics' const MODULE_CODE = MODULE_NAME const RECEIVED_EVENTS = [] const GVL_ID = 422 const TCF_PURPOSES = [1, 7] +let billableEventsInitialized = false + function init (config, userConsent) { const hasConsent = checkConsent(userConsent) + const initialize = hasConsent !== false - if (hasConsent) { + if (initialize) { const moduleConfig = getMergedConfig(config) initializeBrandmetrics(moduleConfig.params.scriptId) + initializeBillableEvents() } - return hasConsent + return initialize } /** @@ -31,33 +37,35 @@ function init (config, userConsent) { * @returns {boolean} */ function checkConsent (userConsent) { - let consent = false - - if (userConsent && userConsent.gdpr && userConsent.gdpr.gdprApplies) { - const gdpr = userConsent.gdpr - - if (gdpr.vendorData) { - const vendor = gdpr.vendorData.vendor - const purpose = gdpr.vendorData.purpose - - let vendorConsent = false - if (vendor.consents) { - vendorConsent = vendor.consents[GVL_ID] + let consent + + if (userConsent) { + if (userConsent.gdpr && userConsent.gdpr.gdprApplies) { + const gdpr = userConsent.gdpr + + if (gdpr.vendorData) { + const vendor = gdpr.vendorData.vendor + const purpose = gdpr.vendorData.purpose + + let vendorConsent = false + if (vendor.consents) { + vendorConsent = vendor.consents[GVL_ID] + } + + if (vendor.legitimateInterests) { + vendorConsent = vendorConsent || vendor.legitimateInterests[GVL_ID] + } + + const purposes = TCF_PURPOSES.map(id => { + return (purpose.consents && purpose.consents[id]) || (purpose.legitimateInterests && purpose.legitimateInterests[id]) + }) + const purposesValid = purposes.filter(p => p === true).length === TCF_PURPOSES.length + consent = vendorConsent && purposesValid } - - if (vendor.legitimateInterests) { - vendorConsent = vendorConsent || vendor.legitimateInterests[GVL_ID] - } - - const purposes = TCF_PURPOSES.map(id => { - return (purpose.consents && purpose.consents[id]) || (purpose.legitimateInterests && purpose.legitimateInterests[id]) - }) - const purposesValid = purposes.filter(p => p === true).length === TCF_PURPOSES.length - consent = vendorConsent && purposesValid + } else if (userConsent.usp) { + const usp = userConsent.usp + consent = usp[1] !== 'N' && usp[2] !== 'Y' } - } else if (userConsent.usp) { - const usp = userConsent.usp - consent = usp[1] !== 'N' && usp[2] !== 'Y' } return consent @@ -82,7 +90,6 @@ function processBrandmetricsEvents (reqBidsConfigObj, moduleConfig, callback) { if (RECEIVED_EVENTS.length > 0) { callBidTargeting(RECEIVED_EVENTS[RECEIVED_EVENTS.length - 1]) } else { - window._brandmetrics = window._brandmetrics || [] window._brandmetrics.push({ cmd: '_addeventlistener', val: { @@ -109,11 +116,8 @@ function processBrandmetricsEvents (reqBidsConfigObj, moduleConfig, callback) { function setBidderTargeting (reqBidsConfigObj, moduleConfig, key, val) { const bidders = deepAccess(moduleConfig, 'params.bidders') if (bidders && bidders.length > 0) { - const ortb2 = {} - deepSetValue(ortb2, 'ortb2.user.ext.data.' + key, val) - config.setBidderConfig({ - bidders: bidders, - config: ortb2 + bidders.forEach(bidder => { + deepSetValue(reqBidsConfigObj, `ortb2Fragments.bidder.${bidder}.user.ext.data.${key}`, val); }) } } @@ -123,6 +127,8 @@ function setBidderTargeting (reqBidsConfigObj, moduleConfig, key, val) { * @param {string} scriptId - The script- id provided by brandmetrics or brandmetrics partner */ function initializeBrandmetrics(scriptId) { + window._brandmetrics = window._brandmetrics || [] + if (scriptId) { const path = 'https://cdn.brandmetrics.com/survey/script/' const file = scriptId + '.js' @@ -132,6 +138,34 @@ function initializeBrandmetrics(scriptId) { } } +/** +* Hook in to brandmetrics creative_in_view- event and emit billable- event for creatives measured by brandmetrics. +*/ +function initializeBillableEvents() { + if (!billableEventsInitialized) { + window._brandmetrics.push({ + cmd: '_addeventlistener', + val: { + event: 'creative_in_view', + handler: (ev) => { + if (ev.source && ev.source.type === 'pbj') { + const bid = ev.source.data; + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + vendor: 'brandmetrics', + type: 'creative_in_view', + measurementId: ev.mid, + billingId: generateUUID(), + auctionId: bid.auctionId, + transactionId: bid.transactionId, + }); + } + }, + } + }) + billableEventsInitialized = true + } +} + /** * Merges a provided config with default values * @param {Object} customConfig diff --git a/modules/brandmetricsRtdProvider.md b/modules/brandmetricsRtdProvider.md index 89ee6bb75cf..d6304f9ae12 100644 --- a/modules/brandmetricsRtdProvider.md +++ b/modules/brandmetricsRtdProvider.md @@ -16,10 +16,10 @@ Enable the Brandmetrics RTD in your Prebid configuration, using the below format pbjs.setConfig({ ..., realTimeData: { - auctionDelay: 500, // auction delay + auctionDelay: 500, dataProviders: [{ name: 'brandmetrics', - waitForIt: true // should be true if there's an `auctionDelay`, + waitForIt: true, params: { scriptId: '00000000-0000-0000-0000-000000000000', bidders: ['ozone'] @@ -29,6 +29,7 @@ pbjs.setConfig({ ... }) ``` +The scriptId- parameter is provided by brandmetrics or a brandmetrics partner. ## Parameters | Name | Type | Description | Default | @@ -38,3 +39,17 @@ pbjs.setConfig({ | params | Object | | - | | params.bidders | String[] | An array of bidders which should receive targeting keys. | `[]` | | params.scriptId | String | A script- id GUID if the brandmetrics- script should be initialized. | `undefined` | + +## Billable events +The module emits a billable event for creatives that are measured by brandmetrics and are considered in- view. + +```javascript +{ + vendor: 'brandmetrics', + type: 'creative_in_view', + measurementId: string, // UUID, brandmetrics measurement id + billingId: string, // UUID, unique billing id + auctionId: string, // Prebid auction id + transactionId: string, //Prebid transaction id +} +``` \ No newline at end of file diff --git a/modules/braveBidAdapter.js b/modules/braveBidAdapter.js index 18bad6b0f75..d954522ae24 100644 --- a/modules/braveBidAdapter.js +++ b/modules/braveBidAdapter.js @@ -1,7 +1,8 @@ -import { parseUrl, isEmpty, isStr, triggerPixel } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; +import {isEmpty, isStr, parseUrl, triggerPixel} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; const BIDDER_CODE = 'brave'; const DEFAULT_CUR = 'USD'; @@ -38,6 +39,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + if (validBidRequests.length === 0 || !bidderRequest) return []; const endpointURL = ENDPOINT_URL.replace('hash', validBidRequests[0].params.placementId); @@ -54,7 +58,8 @@ export const spec = { impObject.video = createVideoRequest(br); } else if (br.mediaTypes.native) { impObject.native = { - id: br.transactionId, + // TODO: `id` is not part of the ORTB native spec, is this intentional? + id: br.bidId, ver: '1.2', request: createNativeRequest(br) }; @@ -62,23 +67,9 @@ export const spec = { return impObject; }); - let w = window; - let l = w.document.location.href; - let r = w.document.referrer; - - let loopChecker = 0; - while (w !== w.parent) { - if (++loopChecker == 10) break; - try { - w = w.parent; - l = w.location.href; - r = w.document.referrer; - } catch (e) { - break; - } - } - - let page = l || bidderRequest.refererInfo.referer; + // TODO: do these values make sense? + let page = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; + let r = bidderRequest.refererInfo.ref; let data = { id: bidderRequest.bidderRequestId, @@ -93,7 +84,7 @@ export const spec = { domain: parseUrl(page).hostname, page: page, }, - tmax: bidderRequest.timeout || config.getConfig('bidderTimeout') || 500, + tmax: bidderRequest.timeout, imp }; @@ -239,7 +230,8 @@ const createBannerRequest = br => { }; const createVideoRequest = br => { - let videoObj = {id: br.transactionId}; + // TODO: `id` is not part of imp.video in ORTB; is this intentional? + let videoObj = {id: br.bidId}; let supportParamsList = ['mimes', 'minduration', 'maxduration', 'protocols', 'startdelay', 'skip', 'minbitrate', 'maxbitrate', 'api', 'linearity']; for (let param of supportParamsList) { diff --git a/modules/bridBidAdapter.js b/modules/bridBidAdapter.js new file mode 100644 index 00000000000..8e7c2f166ef --- /dev/null +++ b/modules/bridBidAdapter.js @@ -0,0 +1,223 @@ +import {createTrackPixelHtml, _each, deepAccess, getDefinedParams, parseGPTSingleSizeArrayToRtbSize} from '../src/utils.js'; +import {VIDEO} from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getRefererInfo} from '../src/refererDetection.js'; + +const SOURCE = 'pbjs'; +const BIDDER_CODE = 'brid'; +const ENDPOINT_URL = 'https://pbs.prebrid.tv/openrtb2/auction'; +const GVLID = 934; +const TIME_TO_LIVE = 300; +const VIDEO_PARAMS = [ + 'api', 'linearity', 'maxduration', 'mimes', 'minduration', 'placement', + 'playbackmethod', 'protocols', 'startdelay' +]; + +export const spec = { + + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid && bid.params && bid.params.placementId); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @param {BidderRequest} bidderRequest bidder request object. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(bidRequests, bidderRequest) { + const requests = []; + + _each(bidRequests, function(bid) { + const placementId = bid.params.placementId; + const bidId = bid.bidId; + let sizes = bid.sizes; + if (sizes && !Array.isArray(sizes[0])) sizes = [sizes]; + + const site = getSiteObj(); + + const postBody = { + sdk: { + source: SOURCE, + version: '$prebid.version$' + }, + id: bidderRequest.bidderRequestId, + site, + imp: [] + }; + + const imp = { + ext: { + prebid: { + storedrequest: {'id': placementId} + } + } + }; + + const video = deepAccess(bid, 'mediaTypes.video'); + if (video) { + imp.video = getDefinedParams(video, VIDEO_PARAMS); + if (video.playerSize) { + imp.video = Object.assign( + imp.video, parseGPTSingleSizeArrayToRtbSize(video.playerSize[0]) || {} + ); + } else if (video.w && video.h) { + imp.video.w = video.w; + imp.video.h = video.h; + }; + }; + + postBody.imp.push(imp); + + const gdprConsent = bidderRequest && bidderRequest.gdprConsent; + const uspConsent = bidderRequest && bidderRequest.uspConsent; + + if (gdprConsent || uspConsent) { + postBody.regs = { ext: {} }; + + if (uspConsent) { + postBody.regs.ext.us_privacy = uspConsent; + }; + + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies !== 'undefined') { + postBody.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0; + }; + + if (typeof gdprConsent.consentString !== 'undefined') { + postBody.user = { + ext: { consent: gdprConsent.consentString } + }; + }; + }; + }; + + if (bidRequests[0].schain) { + postBody.schain = bidRequests[0].schain; + } + + const params = bid.params; + + requests.push({ + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(postBody), + options: { + withCredentials: true + }, + bidId, + params + }); + }); + + return requests; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + const response = serverResponse.body; + const bidResponses = []; + + _each(response.seatbid, (resp) => { + _each(resp.bid, (bid) => { + const requestId = bidRequest.bidId; + const params = bidRequest.params; + + const {ad, adUrl, vastUrl, vastXml} = getAd(bid); + + const bidResponse = { + requestId, + params, + cpm: bid.price, + width: bid.w, + height: bid.h, + creativeId: bid.adid, + currency: response.cur, + netRevenue: false, + ttl: TIME_TO_LIVE, + meta: { + advertiserDomains: bid.adomain || [] + } + }; + + if (vastUrl || vastXml) { + bidResponse.mediaType = VIDEO; + if (vastUrl) bidResponse.vastUrl = vastUrl; + if (vastXml) bidResponse.vastXml = vastXml; + } else { + bidResponse.ad = ad; + bidResponse.adUrl = adUrl; + }; + + bidResponses.push(bidResponse); + }); + }); + + return bidResponses; + }, + +} + +/** + * Helper function to get ad + * + * @param {object} bid The bid. + * @return {object} ad object. + */ +function getAd(bid) { + let ad, adUrl, vastXml, vastUrl; + + switch (deepAccess(bid, 'ext.prebid.type')) { + case VIDEO: + if (bid.adm.substr(0, 4) === 'http') { + vastUrl = bid.adm; + } else { + vastXml = bid.adm; + }; + break; + default: + if (bid.adm && bid.nurl) { + ad = bid.adm; + ad += createTrackPixelHtml(decodeURIComponent(bid.nurl)); + } else if (bid.adm) { + ad = bid.adm; + } else if (bid.nurl) { + adUrl = bid.nurl; + }; + } + + return {ad, adUrl, vastXml, vastUrl}; +} + +/** + * Helper function to get site object + * + * @return {object} siteObj. + */ +function getSiteObj() { + const refInfo = (getRefererInfo && getRefererInfo()) || {}; + + return { + page: refInfo.page, + ref: refInfo.ref, + domain: refInfo.domain + }; +} + +registerBidder(spec); diff --git a/modules/bridgewellBidAdapter.js b/modules/bridgewellBidAdapter.js index b141763af8e..6088cefaa55 100644 --- a/modules/bridgewellBidAdapter.js +++ b/modules/bridgewellBidAdapter.js @@ -2,6 +2,7 @@ import {_each, deepSetValue, inIframe} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {find} from '../src/polyfill.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'bridgewell'; const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb='; @@ -36,6 +37,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const adUnits = []; var bidderUrl = REQUEST_ENDPOINT + Math.random(); var userIds; @@ -72,7 +76,7 @@ export const spec = { let topUrl = ''; if (bidderRequest && bidderRequest.refererInfo) { - topUrl = bidderRequest.refererInfo.referer; + topUrl = bidderRequest.refererInfo.page; } return { @@ -85,9 +89,10 @@ export const spec = { }, inIframe: inIframe(), url: topUrl, - referrer: getTopWindowReferrer(), + referrer: bidderRequest.refererInfo.ref, adUnits: adUnits, - refererInfo: bidderRequest.refererInfo, + // TODO: please do not send internal data structures over the network + refererInfo: bidderRequest.refererInfo.legacy, }, validBidRequests: validBidRequests }; @@ -289,12 +294,4 @@ export const spec = { } }; -function getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return ''; - } -} - registerBidder(spec); diff --git a/modules/brightMountainMediaBidAdapter.js b/modules/brightMountainMediaBidAdapter.js index d3ae1d9cf43..6db06744c24 100644 --- a/modules/brightMountainMediaBidAdapter.js +++ b/modules/brightMountainMediaBidAdapter.js @@ -99,7 +99,7 @@ export const spec = { let response; try { - response = serverResponse.body + response = serverResponse.body; bid = response.seatbid[0].bid[0]; } catch (e) { response = null; @@ -149,6 +149,7 @@ export const spec = { registerBidder(spec); function buildSite(bidderRequest) { + // TODO: should name/domain be the domain? let site = { name: window.location.hostname, publisher: { @@ -160,12 +161,12 @@ function buildSite(bidderRequest) { deepSetValue( site, 'page', - bidderRequest.refererInfo.referer.href ? bidderRequest.refererInfo.referer.href : '', + bidderRequest.refererInfo.page ); deepSetValue( site, 'ref', - bidderRequest.refererInfo.referer ? bidderRequest.refererInfo.referer : '', + bidderRequest.refererInfo.ref ); } return site; diff --git a/modules/brightcomBidAdapter.js b/modules/brightcomBidAdapter.js index 4895f303973..1fa1dac4e95 100644 --- a/modules/brightcomBidAdapter.js +++ b/modules/brightcomBidAdapter.js @@ -1,4 +1,17 @@ -import { getBidIdParameter, _each, isArray, getWindowTop, getUniqueIdentifierStr, parseUrl, deepSetValue, logError, logWarn, createTrackPixelHtml, getWindowSelf, isFn, isPlainObject } from '../src/utils.js'; +import { + _each, + isArray, + getWindowTop, + getUniqueIdentifierStr, + deepSetValue, + logError, + logWarn, + createTrackPixelHtml, + getWindowSelf, + isFn, + isPlainObject, + getBidIdParameter +} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; @@ -9,6 +22,7 @@ const URL = 'https://brightcombid.marphezis.com/hb'; export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], + gvlid: 883, isBidRequestValid, buildRequests, interpretResponse, @@ -19,7 +33,7 @@ function buildRequests(bidReqs, bidderRequest) { try { let referrer = ''; if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; + referrer = bidderRequest.refererInfo.page; } const brightcomImps = []; const publisherId = getBidIdParameter('publisherId', bidReqs[0].params); @@ -56,7 +70,7 @@ function buildRequests(bidReqs, bidderRequest) { id: getUniqueIdentifierStr(), imp: brightcomImps, site: { - domain: parseUrl(referrer).host, + domain: bidderRequest?.refererInfo?.domain || '', page: referrer, publisher: { id: publisherId @@ -67,7 +81,7 @@ function buildRequests(bidReqs, bidderRequest) { w: screen.width, h: screen.height }, - tmax: config.getConfig('bidderTimeout') + tmax: bidderRequest?.timeout }; if (bidderRequest && bidderRequest.gdprConsent) { @@ -75,11 +89,30 @@ function buildRequests(bidReqs, bidderRequest) { deepSetValue(brightcomBidReq, 'user.ext.consent', bidderRequest.gdprConsent.consentString); } + if (bidderRequest && bidderRequest.uspConsent) { + deepSetValue(brightcomBidReq, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + + if (config.getConfig('coppa') === true) { + deepSetValue(brightcomBidReq, 'regs.coppa', 1); + } + + if (bidReqs[0] && bidReqs[0].schain) { + deepSetValue(brightcomBidReq, 'source.ext.schain', bidReqs[0].schain) + } + + if (bidReqs[0] && bidReqs[0].userIdAsEids) { + deepSetValue(brightcomBidReq, 'user.ext.eids', bidReqs[0].userIdAsEids || []) + } + + if (bidReqs[0] && bidReqs[0].userId) { + deepSetValue(brightcomBidReq, 'user.ext.ids', bidReqs[0].userId || []) + } + return { method: 'POST', url: URL, data: JSON.stringify(brightcomBidReq), - options: {contentType: 'text/plain', withCredentials: false} }; } catch (e) { logError(e, {bidReqs, bidderRequest}); @@ -103,7 +136,7 @@ function interpretResponse(serverResponse) { logWarn('Brightcom server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); return []; } - const { body: {id, seatbid} } = serverResponse; + const {body: {id, seatbid}} = serverResponse; try { const brightcomBidResponses = []; if (id && @@ -164,9 +197,9 @@ function _isViewabilityMeasurable(element) { return !_isIframe() && element !== null; } -function _getViewability(element, topWin, { w, h } = {}) { +function _getViewability(element, topWin, {w, h} = {}) { return getWindowTop().document.visibilityState === 'visible' - ? _getPercentInView(element, topWin, { w, h }) + ? _getPercentInView(element, topWin, {w, h}) : 0; } @@ -182,8 +215,8 @@ function _getMinSize(sizes) { return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min); } -function _getBoundingBox(element, { w, h } = {}) { - let { width, height, left, top, right, bottom } = element.getBoundingClientRect(); +function _getBoundingBox(element, {w, h} = {}) { + let {width, height, left, top, right, bottom} = element.getBoundingClientRect(); if ((width === 0 || height === 0) && w && h) { width = w; @@ -192,7 +225,7 @@ function _getBoundingBox(element, { w, h } = {}) { bottom = top + h; } - return { width, height, left, top, right, bottom }; + return {width, height, left, top, right, bottom}; } function _getIntersectionOfRects(rects) { @@ -225,16 +258,16 @@ function _getIntersectionOfRects(rects) { return bbox; } -function _getPercentInView(element, topWin, { w, h } = {}) { - const elementBoundingBox = _getBoundingBox(element, { w, h }); +function _getPercentInView(element, topWin, {w, h} = {}) { + const elementBoundingBox = _getBoundingBox(element, {w, h}); // Obtain the intersection of the element and the viewport - const elementInViewBoundingBox = _getIntersectionOfRects([ { + const elementInViewBoundingBox = _getIntersectionOfRects([{ left: 0, top: 0, right: topWin.innerWidth, bottom: topWin.innerHeight - }, elementBoundingBox ]); + }, elementBoundingBox]); let elementInViewArea, elementTotalArea; diff --git a/modules/brightcomSSPBidAdapter.js b/modules/brightcomSSPBidAdapter.js new file mode 100644 index 00000000000..4750881da40 --- /dev/null +++ b/modules/brightcomSSPBidAdapter.js @@ -0,0 +1,321 @@ +import { + isArray, + getWindowTop, + getUniqueIdentifierStr, + deepSetValue, + logError, + logWarn, + createTrackPixelHtml, + getWindowSelf, + isFn, + isPlainObject, getBidIdParameter, +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import {ajax} from '../src/ajax.js'; + +const BIDDER_CODE = 'bcmssp'; +const URL = 'https://rt.marphezis.com/hb'; +const TRACK_EVENT_URL = 'https://rt.marphezis.com/prebid' + +export const spec = { + code: BIDDER_CODE, + gvlid: 883, + supportedMediaTypes: [BANNER], + isBidRequestValid, + buildRequests, + interpretResponse, + onBidderError, + onTimeout, + onBidWon, + getUserSyncs, +}; + +function buildRequests(bidReqs, bidderRequest) { + try { + const impressions = bidReqs.map(bid => { + let bidSizes = bid?.mediaTypes?.banner?.sizes || bid.sizes; + bidSizes = ((isArray(bidSizes) && isArray(bidSizes[0])) ? bidSizes : [bidSizes]); + bidSizes = bidSizes.filter(size => isArray(size)); + const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)})); + + const element = document.getElementById(bid.adUnitCode); + const minSize = _getMinSize(processedSizes); + const viewabilityAmount = _isViewabilityMeasurable(element) ? _getViewability(element, getWindowTop(), minSize) : 'na'; + const viewabilityAmountRounded = isNaN(viewabilityAmount) ? viewabilityAmount : Math.round(viewabilityAmount); + + const imp = { + id: bid.bidId, + banner: { + format: processedSizes, + ext: { + viewability: viewabilityAmountRounded + } + }, + tagid: String(bid.adUnitCode) + }; + + const bidFloor = _getBidFloor(bid); + + if (bidFloor) { + imp.bidfloor = bidFloor; + } + + return imp; + }) + + const referrer = bidderRequest?.refererInfo?.page || ''; + const publisherId = getBidIdParameter('publisherId', bidReqs[0].params); + + const payload = { + id: getUniqueIdentifierStr(), + imp: impressions, + site: { + domain: bidderRequest?.refererInfo?.domain || '', + page: referrer, + publisher: { + id: publisherId + } + }, + device: { + devicetype: _getDeviceType(), + w: screen.width, + h: screen.height + }, + tmax: bidderRequest?.timeout + }; + + if (bidderRequest?.gdprConsent) { + deepSetValue(payload, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies); + deepSetValue(payload, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + } + + if (bidderRequest?.uspConsent) { + deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + + if (config.getConfig('coppa') === true) { + deepSetValue(payload, 'regs.coppa', 1); + } + + if (bidReqs?.[0]?.schain) { + deepSetValue(payload, 'source.ext.schain', bidReqs[0].schain) + } + + if (bidReqs?.[0]?.userIdAsEids) { + deepSetValue(payload, 'user.ext.eids', bidReqs[0].userIdAsEids || []) + } + + if (bidReqs?.[0].userId) { + deepSetValue(payload, 'user.ext.ids', bidReqs[0].userId || []) + } + + return { + method: 'POST', + url: URL, + data: JSON.stringify(payload), + }; + } catch (e) { + logError(e, {bidReqs, bidderRequest}); + } +} + +function isBidRequestValid(bid) { + if (bid.bidder !== BIDDER_CODE || !bid.params || !bid.params.publisherId) { + return false; + } + + return true; +} + +function interpretResponse(serverResponse) { + let response = []; + if (!serverResponse.body || typeof serverResponse.body != 'object') { + logWarn('Brightcom server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); + return response; + } + + const {body: {id, seatbid}} = serverResponse; + + try { + if (id && seatbid && seatbid.length > 0 && seatbid[0].bid && seatbid[0].bid.length > 0) { + response = seatbid[0].bid.map(bid => { + return { + requestId: bid.impid, + cpm: parseFloat(bid.price), + width: parseInt(bid.w), + height: parseInt(bid.h), + creativeId: bid.crid || bid.id, + currency: 'USD', + netRevenue: true, + mediaType: BANNER, + ad: _getAdMarkup(bid), + ttl: 60, + meta: { + advertiserDomains: bid?.adomain || [] + } + }; + }); + } + } catch (e) { + logError(e, {id, seatbid}); + } + + return response; +} + +// Don't do user sync for now +function getUserSyncs(syncOptions, responses, gdprConsent) { + return []; +} + +function onTimeout(timeoutData) { + if (timeoutData === null) { + return; + } + + _trackEvent('timeout', timeoutData); +} + +function onBidderError(errorData) { + if (errorData === null || !errorData.bidderRequest) { + return; + } + + _trackEvent('error', errorData.bidderRequest) +} + +function onBidWon(bid) { + if (bid === null) { + return; + } + + _trackEvent('bidwon', bid) +} + +function _trackEvent(endpoint, data) { + ajax(`${TRACK_EVENT_URL}/${endpoint}`, null, JSON.stringify(data), { + method: 'POST', + withCredentials: false + }); +} + +function _isMobile() { + return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); +} + +function _isConnectedTV() { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); +} + +function _getDeviceType() { + return _isMobile() ? 1 : _isConnectedTV() ? 3 : 2; +} + +function _getAdMarkup(bid) { + let adm = bid.adm; + if ('nurl' in bid) { + adm += createTrackPixelHtml(bid.nurl); + } + return adm; +} + +function _isViewabilityMeasurable(element) { + return !_isIframe() && element !== null; +} + +function _getViewability(element, topWin, {w, h} = {}) { + return getWindowTop().document.visibilityState === 'visible' ? _getPercentInView(element, topWin, {w, h}) : 0; +} + +function _isIframe() { + try { + return getWindowSelf() !== getWindowTop(); + } catch (e) { + return true; + } +} + +function _getMinSize(sizes) { + return sizes.reduce((min, size) => size.h * size.w < min.h * min.w ? size : min); +} + +function _getBoundingBox(element, {w, h} = {}) { + let {width, height, left, top, right, bottom} = element.getBoundingClientRect(); + + if ((width === 0 || height === 0) && w && h) { + width = w; + height = h; + right = left + w; + bottom = top + h; + } + + return {width, height, left, top, right, bottom}; +} + +function _getIntersectionOfRects(rects) { + const bbox = { + left: rects[0].left, right: rects[0].right, top: rects[0].top, bottom: rects[0].bottom + }; + + for (let i = 1; i < rects.length; ++i) { + bbox.left = Math.max(bbox.left, rects[i].left); + bbox.right = Math.min(bbox.right, rects[i].right); + + if (bbox.left >= bbox.right) { + return null; + } + + bbox.top = Math.max(bbox.top, rects[i].top); + bbox.bottom = Math.min(bbox.bottom, rects[i].bottom); + + if (bbox.top >= bbox.bottom) { + return null; + } + } + + bbox.width = bbox.right - bbox.left; + bbox.height = bbox.bottom - bbox.top; + + return bbox; +} + +function _getPercentInView(element, topWin, {w, h} = {}) { + const elementBoundingBox = _getBoundingBox(element, {w, h}); + + // Obtain the intersection of the element and the viewport + const elementInViewBoundingBox = _getIntersectionOfRects([{ + left: 0, top: 0, right: topWin.innerWidth, bottom: topWin.innerHeight + }, elementBoundingBox]); + + let elementInViewArea, elementTotalArea; + + if (elementInViewBoundingBox !== null) { + // Some or all of the element is in view + elementInViewArea = elementInViewBoundingBox.width * elementInViewBoundingBox.height; + elementTotalArea = elementBoundingBox.width * elementBoundingBox.height; + + return ((elementInViewArea / elementTotalArea) * 100); + } + + // No overlap between element and the viewport; therefore, the element + // lies completely out of view + return 0; +} + +function _getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return bid.params.bidFloor ? bid.params.bidFloor : null; + } + + let floor = bid.getFloor({ + currency: 'USD', mediaType: '*', size: '*' + }); + if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { + return floor.floor; + } + return null; +} + +registerBidder(spec); diff --git a/modules/brightcomSSPBidAdapter.md b/modules/brightcomSSPBidAdapter.md new file mode 100644 index 00000000000..8d0e4ec70dc --- /dev/null +++ b/modules/brightcomSSPBidAdapter.md @@ -0,0 +1,46 @@ +# Overview + +``` +Module Name: Brightcom SSP Bid Adapter +Module Type: Bidder Adapter +Maintainer: alexandruc@brightcom.com +``` + +# Description + +Brightcom's adapter integration to the Prebid library. + +# Test Parameters + +``` +var adUnits = [ + { + code: 'test-leaderboard', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + bids: [{ + bidder: 'bcmssp', + params: { + publisherId: 2141020, + bidFloor: 0.01 + } + }] + }, { + code: 'test-banner', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [{ + bidder: 'bcmssp', + params: { + publisherId: 2141020 + } + }] + } +] +``` diff --git a/modules/britepoolIdSystem.js b/modules/britepoolIdSystem.js index 2316fbb732d..b75fe9424b1 100644 --- a/modules/britepoolIdSystem.js +++ b/modules/britepoolIdSystem.js @@ -136,6 +136,12 @@ export const britepoolIdSubmodule = { } } return valueObj; + }, + eids: { + 'britepoolid': { + source: 'britepool.com', + atype: 3 + }, } }; diff --git a/modules/browsiBidAdapter.js b/modules/browsiBidAdapter.js new file mode 100644 index 00000000000..03b6b2a8f3d --- /dev/null +++ b/modules/browsiBidAdapter.js @@ -0,0 +1,171 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {VIDEO} from '../src/mediaTypes.js'; +import {logError, logInfo, isArray, isStr} from '../src/utils.js'; + +const BIDDER_CODE = 'browsi'; +const DATA = 'brwvidtag'; +const ADAPTER = '__bad'; +const USP_TO_REPLACE = '__USP__'; +const GDPR_STR_TO_REPLACE = '__GDPR_STR__'; +const GDPR_TO_REPLACE = '__GDPR__'; +export const ENDPOINT = 'https://rtb.avantisvideo.com/api/v2/auction/getbid'; + +export const spec = { + code: BIDDER_CODE, + gvlid: 329, + supportedMediaTypes: [VIDEO], + /** + * Determines whether or not the given bid request is valid. + * @param bid + * @returns {boolean} + */ + isBidRequestValid: function (bid) { + if (!bid.params) { + return false; + } + const {pubId, tagId} = bid.params + const {mediaTypes} = bid; + return !!(validateBrowsiIds(pubId, tagId) && mediaTypes?.[VIDEO]); + }, + /** + * Make a server request from the list of BidRequests + * @param validBidRequests + * @param bidderRequest + * @returns ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + const requests = []; + const {refererInfo, bidderRequestId, gdprConsent, uspConsent} = bidderRequest; + validBidRequests.forEach(bidRequest => { + const {bidId, adUnitCode, auctionId, ortb2Imp, schain, params} = bidRequest; + const video = getVideoMediaType(bidRequest); + + const request = { + method: 'POST', + url: params.endpoint || ENDPOINT, + data: { + requestId: bidderRequestId, + bidId: bidId, + timeout: getTimeout(bidderRequest), + baData: getData(), + referer: refererInfo.page || refererInfo, + gdpr: gdprConsent, + ccpa: uspConsent, + sizes: video.playerSize, + video: video, + aUCode: adUnitCode, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + aID: auctionId, + tID: ortb2Imp?.ext?.tid, + schain: schain, + params: params + } + }; + requests.push(request); + }) + return requests; + }, + /** + * Unpack the response from the server into a list of bids. + * @param serverResponse A successful response from the server. + * @param request + * @returns {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, request) { + const bidResponses = []; + const response = serverResponse?.body; + if (!response) { return bidResponses; } + const { + bidId, + w, + h, + vXml, + vUrl, + cpm, + cur, + ttl, + ...extraParams + } = response; + delete extraParams.userSyncs; + const bidResponse = { + requestId: request.data.bidId, + bidId, + vastXml: vXml, + vastUrl: vUrl, + cpm, + ttl, + mediaType: VIDEO, + width: w, + height: h, + currency: cur, + ...extraParams + }; + bidResponses.push(bidResponse); + return bidResponses; + }, + /** + * Extracts user-syncs information from server response + * @param syncOptions {SyncOptions} + * @param serverResponses {ServerResponse[]} + * @param gdprConsent + * @param uspConsent + * @returns {UserSync[]} + */ + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { + const serverResponse = isArray(serverResponses) ? serverResponses[0] : serverResponses; + const syncParams = serverResponse?.body?.userSyncs; + const userSyncs = []; + const allowedTypes = []; + syncOptions.iframeEnabled && allowedTypes.push('iframe'); + syncOptions.pixelEnabled && allowedTypes.push('image'); + if (syncParams && allowedTypes.length) { + syncParams.forEach(syncParam => { + let { url, type } = syncParam; + if (!allowedTypes.includes(type)) { return; } + url = getValidUrl(url, gdprConsent, uspConsent); + userSyncs.push({ + type, + url + }); + }) + } + return userSyncs; + }, + onTimeout(timeoutData) { + logInfo(`${BIDDER_CODE} bidder timed out`, timeoutData); + }, + onBidderError: function ({error}) { + logError(`${BIDDER_CODE} bidder error`, error); + } +} +/** + * Replaces GdprConsent and uspConsent params in url + * @param url {String} + * @param gdprConsent + * @param uspConsent + * @returns {string} + */ +const getValidUrl = function (url, gdprConsent, uspConsent) { + let validUrl = url.replace(GDPR_TO_REPLACE, gdprConsent?.gdprApplies || '') + .replace(GDPR_STR_TO_REPLACE, encodeURIComponent(gdprConsent?.consentString || '')) + .replace(USP_TO_REPLACE, encodeURIComponent(uspConsent?.consentString || '')); + if (validUrl.indexOf('http') < 0) { + validUrl = 'http://' + validUrl; + } + return validUrl; +} + +const validateBrowsiIds = function (pubId, tagId) { + return pubId && tagId && isStr(pubId) && isStr(tagId); +} +const getData = function () { + return window[DATA]?.[ADAPTER]; +} +const getTimeout = function (bidderRequest) { + return bidderRequest.timeout || config.getConfig('bidderTimeout'); +} +const getVideoMediaType = function (bidRequest) { + return bidRequest.mediaTypes?.[VIDEO]; +} +registerBidder(spec); diff --git a/modules/browsiBidAdapter.md b/modules/browsiBidAdapter.md new file mode 100644 index 00000000000..cd032393c8e --- /dev/null +++ b/modules/browsiBidAdapter.md @@ -0,0 +1,38 @@ +# Overview + +``` +Module Name: Browsi Bid Adapter +Module Type: Bidder Adapter +Maintainer: support@browsi.com +``` + +# Description + +Connects to Browsi Ad server for bids. + +Browsi bid adapter supports Video media type. + +**Note:** The bid adapter requires correct setup and approval, including an existing publisher account. + +For more information about [Browsi](https://www.browsi.com), please contact [support@browsi.com](support@browsi.com). + +# Sample Ad Unit: +```javascript +let videoAdUnit = [ +{ + code: 'videoAdUnit', + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream' + }, + }, + bids: [{ + bidder: 'browsi', + params: { + pubId: '117a476f-9791-4a82-80db-4c01c1683db0', // Publisher ID provided by Browsi + tagId: '1' // Tag ID provided by Browsi + } + }] +}]; +``` diff --git a/modules/browsiRtdProvider.js b/modules/browsiRtdProvider.js index 15f2d58010d..4a61f40600d 100644 --- a/modules/browsiRtdProvider.js +++ b/modules/browsiRtdProvider.js @@ -24,8 +24,10 @@ import {find, includes} from '../src/polyfill.js'; import {getGlobal} from '../src/prebidGlobal.js'; import * as events from '../src/events.js'; import CONSTANTS from '../src/constants.json'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; +const MODULE_NAME = 'browsi'; -const storage = getStorageManager(); +const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: MODULE_NAME}); /** @type {ModuleParams} */ let _moduleParams = {}; @@ -57,6 +59,18 @@ export function addBrowsiTag(data) { return script; } +export function sendPageviewEvent(eventType) { + if (eventType === 'PAGEVIEW') { + window.addEventListener('browsi_pageview', () => { + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + vendor: 'browsi', + type: 'pageview', + billingId: generateUUID() + }) + }) + } +} + /** * collect required data from page * send data to browsi server to get predictions @@ -93,7 +107,7 @@ export function collectData() { function waitForData(callback) { if (_browsiData) { _dataReadyCallback = null; - callback(_browsiData); + callback(); } else { _dataReadyCallback = callback; } @@ -102,7 +116,7 @@ function waitForData(callback) { export function setData(data) { _browsiData = data; if (isFn(_dataReadyCallback)) { - _dataReadyCallback(_browsiData); + _dataReadyCallback(); _dataReadyCallback = null; } } @@ -262,10 +276,11 @@ function getPredictionsFromServer(url) { try { const data = JSON.parse(response); if (data && data.p && data.kn) { - setData({p: data.p, kn: data.kn, pmd: data.pmd}); + setData({p: data.p, kn: data.kn, pmd: data.pmd, bet: data.bet}); } else { setData({}); } + sendPageviewEvent(data.bet); addBrowsiTag(data); } catch (err) { logError('unable to parse data'); @@ -323,7 +338,7 @@ export const browsiSubmodule = { * used to link submodule with realTimeData * @type {string} */ - name: 'browsi', + name: MODULE_NAME, /** * get data and send back to realTimeData module * @function @@ -336,19 +351,22 @@ export const browsiSubmodule = { function getTargetingData(uc, c, us, a) { const targetingData = getRTD(uc); - const auctionId = a.auctionId + const auctionId = a.auctionId; + const sendAdRequestEvent = (_browsiData && _browsiData['bet'] === 'AD_REQUEST'); uc.forEach(auc => { if (isNumber(_ic[auc])) { _ic[auc] = _ic[auc] + 1; } - const transactionId = a.adUnits.find(adUnit => adUnit.code === auc).transactionId; - events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { - vendor: 'browsi', - type: 'adRequest', - billingId: generateUUID(), - transactionId: transactionId, - auctionId: auctionId - }) + if (sendAdRequestEvent) { + const transactionId = a.adUnits.find(adUnit => adUnit.code === auc).transactionId; + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + vendor: 'browsi', + type: 'adRequest', + billingId: generateUUID(), + transactionId: transactionId, + auctionId: auctionId + }) + } }); logInfo('Browsi RTD provider returned targeting data', targetingData, 'for', uc) return targetingData; diff --git a/modules/bucksenseBidAdapter.js b/modules/bucksenseBidAdapter.js index fcf99179993..7b6c3911ea1 100644 --- a/modules/bucksenseBidAdapter.js +++ b/modules/bucksenseBidAdapter.js @@ -4,7 +4,7 @@ import { BANNER } from '../src/mediaTypes.js'; const WHO = 'BKSHBID-005'; const BIDDER_CODE = 'bucksense'; -const URL = 'https://prebid.bksn.se/prebidjs/'; +const URL = 'https://directo.prebidserving.com/prebidjs/'; export const spec = { code: BIDDER_CODE, diff --git a/modules/buzzoolaBidAdapter.js b/modules/buzzoolaBidAdapter.js index c6e27c94e04..b5ea6227f58 100644 --- a/modules/buzzoolaBidAdapter.js +++ b/modules/buzzoolaBidAdapter.js @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO, NATIVE} from '../src/mediaTypes.js'; import {Renderer} from '../src/Renderer.js'; import {OUTSTREAM} from '../src/video.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'buzzoola'; const ENDPOINT = 'https://exchange.buzzoola.com/ssp/prebidjs'; @@ -32,6 +33,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidderRequest.bids = convertOrtbRequestToProprietaryNative(bidderRequest.bids); + return { url: ENDPOINT, method: 'POST', diff --git a/modules/byDataAnalyticsAdapter.js b/modules/byDataAnalyticsAdapter.js index ef6e1a503ee..81fd4388c7d 100644 --- a/modules/byDataAnalyticsAdapter.js +++ b/modules/byDataAnalyticsAdapter.js @@ -2,41 +2,86 @@ import { deepClone, logInfo, logError } from '../src/utils.js'; import Base64 from 'crypto-js/enc-base64'; import hmacSHA512 from 'crypto-js/hmac-sha512'; import enc from 'crypto-js/enc-utf8'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import { auctionManager } from '../src/auctionManager.js'; import { ajax } from '../src/ajax.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; -const secretKey = 'bydata@123456'; -const { EVENTS: { NO_BID, BID_TIMEOUT, AUCTION_END } } = CONSTANTS; -const DEFAULT_EVENT_URL = 'https://pbjs-stream.bydata.com/topics/prebid'; -const analyticsType = 'endpoint'; -var payload = {}; -var bdNbTo = { 'to': [], 'nb': [] }; -let initOptions = {}; +const versionCode = '4.4.1' +const secretKey = 'bydata@123456' +const { EVENTS: { NO_BID, BID_TIMEOUT, AUCTION_END, AUCTION_INIT, BID_WON } } = CONSTANTS +const DEFAULT_EVENT_URL = 'https://pbjs-stream.bydata.com/topics/prebid' +const analyticsType = 'endpoint' +const isBydata = isKeyInUrl('bydata_debug') +const adunitsMap = {} +const MODULE_CODE = 'bydata'; +const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); +let initOptions = {} +var payload = {} +var winPayload = {} +var isDataSend = window.asc_data || false +var bdNbTo = { 'to': [], 'nb': [] } + +/* method used for testing parameters */ +function isKeyInUrl(name) { + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const param = urlParams.get(name) + return param +} + +/* return ad unit full path wrt custom ad unit code */ +function getAdunitName(code) { + var name = code; + for (const [key, value] of Object.entries(adunitsMap)) { + if (key === code) { name = value; } + } + return name; +} + +/* EVENT: auction init */ +function onAuctionStart(t) { + /* map of ad unit code - ad unit full path */ + t.adUnits && t.adUnits.length && t.adUnits.forEach((adu) => { + const { code, adunit } = adu + adunitsMap[code] = adunit + }); +} + +/* EVENT: bid timeout */ function onBidTimeout(t) { if (payload['visitor_data'] && t && t.length > 0) { - bdNbTo['to'] = t; + bdNbTo['to'] = t } } +/* EVENT: no bid */ function onNoBidData(t) { if (payload['visitor_data'] && t) { - bdNbTo['nb'].push(t); + bdNbTo['nb'].push(t) + } +} + +/* EVENT: bid won */ +function onBidWon(t) { + const { isCorrectOption } = initOptions + if (isCorrectOption && (isDataSend || isBydata)) { + ascAdapter.getBidWonData(t) + ascAdapter.sendPayload(winPayload) } } +/* EVENT: auction end */ function onAuctionEnd(t) { - _logInfo('onAuctionEnd', t); - const {isCorrectOption, logFrequency} = initOptions; - var value = Math.floor(Math.random() * 10000 + 1); - _logInfo(' value - frequency ', (value + '-' + logFrequency)); + const { isCorrectOption } = initOptions; setTimeout(() => { - if (isCorrectOption && value < logFrequency) { + if (isCorrectOption && (isDataSend || isBydata)) { ascAdapter.dataProcess(t); - addKeyForPrebidWinningAndWinningsBids(); - ascAdapter.sendPayload(); + ascAdapter.sendPayload(payload); } }, 500); } @@ -44,6 +89,9 @@ function onAuctionEnd(t) { const ascAdapter = Object.assign(adapter({ url: DEFAULT_EVENT_URL, analyticsType: analyticsType }), { track({ eventType, args }) { switch (eventType) { + case AUCTION_INIT: + onAuctionStart(args); + break; case NO_BID: onNoBidData(args); break; @@ -53,6 +101,9 @@ const ascAdapter = Object.assign(adapter({ url: DEFAULT_EVENT_URL, analyticsType case AUCTION_END: onAuctionEnd(args); break; + case BID_WON: + onBidWon(args); + break; default: break; } @@ -62,9 +113,8 @@ const ascAdapter = Object.assign(adapter({ url: DEFAULT_EVENT_URL, analyticsType // save the base class function ascAdapter.originEnableAnalytics = ascAdapter.enableAnalytics; // override enableAnalytics so we can get access to the config passed in from the page -ascAdapter.enableAnalytics = function(config) { +ascAdapter.enableAnalytics = function (config) { if (this.initConfig(config)) { - _logInfo('initiated:', initOptions); initOptions.isCorrectOption && ascAdapter.getVisitorData(); ascAdapter.originEnableAnalytics(config); } @@ -73,7 +123,7 @@ ascAdapter.enableAnalytics = function(config) { ascAdapter.initConfig = function (config) { let isCorrectOption = true; initOptions = {}; - _logInfo('initConfig', config); + var rndNum = Math.floor(Math.random() * 10000 + 1); initOptions.options = deepClone(config.options); initOptions.clientId = initOptions.options.clientId || null; initOptions.logFrequency = initOptions.options.logFrequency; @@ -81,13 +131,41 @@ ascAdapter.initConfig = function (config) { _logError('"options.clientId" should not empty!!'); isCorrectOption = false; } + if (rndNum <= initOptions.logFrequency) { window.asc_data = isDataSend = true; } initOptions.isCorrectOption = isCorrectOption; this.initOptions = initOptions; return isCorrectOption; }; -ascAdapter.getVisitorData = function(data = {}) { - var ua = data.userId ? data : {}; +ascAdapter.getBidWonData = function(t) { + const { auctionId, adUnitCode, size, requestId, bidder, timeToRespond, currency, mediaType, cpm } = t + const aun = getAdunitName(adUnitCode) + winPayload['aid'] = auctionId + winPayload['as'] = ''; + winPayload['auctionData'] = []; + var data = {} + data['au'] = aun + data['auc'] = adUnitCode + data['aus'] = size + data['bid'] = requestId + data['bidadv'] = bidder + data['br_pb_mg'] = cpm + data['br_tr'] = timeToRespond + data['bradv'] = bidder + data['brid'] = requestId + data['brs'] = size + data['cur'] = currency + data['inb'] = 0 + data['ito'] = 0 + data['ipwb'] = 1 + data['iwb'] = 1 + data['mt'] = mediaType + winPayload['auctionData'].push(data) + return winPayload +} + +ascAdapter.getVisitorData = function (data = {}) { + var ua = data.uid ? data : {}; var module = { options: [], header: [window.navigator.platform, window.navigator.userAgent, window.navigator.appVersion, window.navigator.vendor, window.opera], @@ -152,7 +230,7 @@ ascAdapter.getVisitorData = function(data = {}) { crypto.getRandomValues(buffer); buffer[6] = (buffer[6] & ~176) | 64; buffer[8] = (buffer[8] & ~64) | 128; - var hex = Array.prototype.map.call(new Uint8Array(buffer), function(x) { + var hex = Array.prototype.map.call(new Uint8Array(buffer), function (x) { return ('00' + x.toString(16)).slice(-2); }).join(''); return hex.slice(0, 5) + '-' + hex.slice(5, 9) + '-' + hex.slice(9, 13) + '-' + hex.slice(13, 18); @@ -182,34 +260,46 @@ ascAdapter.getVisitorData = function(data = {}) { var signedToken = token + '.' + signature; return signedToken; } - const {clientId} = initOptions; - var userId = window.localStorage.getItem('userId'); + function detectWidth() { + return window.screen.width || (window.innerWidth && document.documentElement.clientWidth) ? Math.min(window.innerWidth, document.documentElement.clientWidth) : window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth; + } + function giveDeviceTypeOnScreenSize() { + var _dWidth = detectWidth(); + return _dWidth > 1024 ? 'Desktop' : (_dWidth <= 1024 && _dWidth >= 768) ? 'Tablet' : 'Mobile'; + } + + const { clientId } = initOptions; + var userId = storage.getDataFromLocalStorage('userId'); if (!userId) { userId = generateUid(); - window.localStorage.setItem('userId', userId); + storage.setDataInLocalStorage('userId', userId); } - var screenSize = {width: window.screen.width, height: window.screen.height}; - var deviceType = window.navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) ? 'Mobile' : 'Desktop'; + var screenSize = { width: window.screen.width, height: window.screen.height }; + var deviceType = giveDeviceTypeOnScreenSize(); var e = module.init(); - if (!ua['userId']) { - ua['userId'] = userId; - ua['client_id'] = clientId; - ua['plateform_name'] = e.os.name; - ua['os_version'] = e.os.version; - ua['browser_name'] = e.browser.name; - ua['browser_version'] = e.browser.version; - ua['screen_size'] = screenSize; - ua['device_type'] = deviceType; - ua['time_zone'] = window.Intl.DateTimeFormat().resolvedOptions().timeZone; + if (!ua['uid']) { + ua['uid'] = userId; + ua['cid'] = clientId; + ua['pid'] = window.location.hostname; + ua['os'] = e.os.name; + ua['osv'] = e.os.version; + ua['br'] = e.browser.name; + ua['brv'] = e.browser.version; + ua['ss'] = screenSize; + ua['de'] = deviceType; + ua['tz'] = window.Intl.DateTimeFormat().resolvedOptions().timeZone; } var signedToken = getJWToken(ua); payload['visitor_data'] = signedToken; + winPayload['visitor_data'] = signedToken; return signedToken; } -ascAdapter.dataProcess = function(t) { - payload['auction_id'] = t.auctionId; - payload['auction_start'] = t.timestamp; +ascAdapter.dataProcess = function (t) { + if (isBydata) { payload['bydata_debug'] = 'true'; } + _logInfo('fulldata - ', t); + payload['aid'] = t.auctionId; + payload['as'] = t.timestamp; payload['auctionData'] = []; var bidderRequestsData = []; var bidsReceivedData = []; t.bidderRequests && t.bidderRequests.forEach(bidReq => { @@ -228,72 +318,83 @@ ascAdapter.dataProcess = function(t) { bidderRequestsData.push(pObj); }); t.bidsReceived && t.bidsReceived.forEach(bid => { - const {requestId, bidder, width, height, cpm, currency, timeToRespond, adUnitCode} = bid; - bidsReceivedData.push({requestId, bidder, width, height, cpm, currency, timeToRespond, adUnitCode}); + const { requestId, bidder, width, height, cpm, currency, timeToRespond, adUnitCode } = bid; + bidsReceivedData.push({ requestId, bidder, width, height, cpm, currency, timeToRespond, adUnitCode }); }); bidderRequestsData.length > 0 && bidderRequestsData.forEach(bdObj => { var bdsArray = bdObj['bids']; bdsArray.forEach(bid => { - const {adUnitCode, sizes, bidder, bidId, mediaTypes} = bid; + const { adUnitCode, sizes, bidder, bidId, mediaTypes } = bid; sizes.forEach(size => { var sstr = size[0] + 'x' + size[1] - payload['auctionData'].push({adUnit: adUnitCode, size: sstr, media_type: mediaTypes[0], bids_bidder: bidder, bids_bid_id: bidId}); + payload['auctionData'].push({ au: getAdunitName(adUnitCode), auc: adUnitCode, aus: sstr, mt: mediaTypes[0], bidadv: bidder, bid: bidId, inb: 0, ito: 0, ipwb: 0, iwb: 0 }); }); }); }); + bidsReceivedData.length > 0 && bidsReceivedData.forEach(bdRecived => { - const {requestId, bidder, width, height, cpm, currency, timeToRespond} = bdRecived; + const { requestId, bidder, width, height, cpm, currency, timeToRespond } = bdRecived; payload['auctionData'].forEach(rwData => { - if (rwData['bids_bid_id'] === requestId && rwData['size'] === width + 'x' + height) { - rwData['br_request_id'] = requestId; rwData['br_bidder'] = bidder; rwData['br_pb_mg'] = cpm; - rwData['br_currency'] = currency; rwData['br_time_to_respond'] = timeToRespond; rwData['br_size'] = width + 'x' + height; + if (rwData['bid'] === requestId && rwData['aus'] === width + 'x' + height) { + rwData['brid'] = requestId; rwData['bradv'] = bidder; rwData['br_pb_mg'] = cpm; + rwData['cur'] = currency; rwData['br_tr'] = timeToRespond; rwData['brs'] = width + 'x' + height; } }) }); + + var prebidWinningBids = auctionManager.getBidsReceived().filter(bid => bid.status === CONSTANTS.BID_STATUS.BID_TARGETING_SET); + prebidWinningBids && prebidWinningBids.length > 0 && prebidWinningBids.forEach(pbbid => { + payload['auctionData'] && payload['auctionData'].forEach(rwData => { + if (rwData['bid'] === pbbid.requestId && rwData['brs'] === pbbid.size) { + rwData['ipwb'] = 1; + } + }); + }) + + var winningBids = auctionManager.getAllWinningBids(); + winningBids && winningBids.length > 0 && winningBids.forEach(wBid => { + payload['auctionData'] && payload['auctionData'].forEach(rwData => { + if (rwData['bid'] === wBid.requestId && rwData['brs'] === wBid.size) { + rwData['iwb'] = 1; + } + }); + }) + payload['auctionData'] && payload['auctionData'].length > 0 && payload['auctionData'].forEach(u => { bdNbTo['to'].forEach(i => { - if (u.bids_bid_id === i.bidId) u.is_timeout = 1; + if (u.bid === i.bidId) u.ito = 1; }); bdNbTo['nb'].forEach(i => { - if (u.adUnit === i.adUnitCode && u.bids_bidder === i.bidder && u.bids_bid_id === i.bidId) { u.is_nobid = 1; } + if (u.bidadv === i.bidder && u.bid === i.bidId) { u.inb = 1; } }) }); return payload; } -ascAdapter.sendPayload = function () { - var obj = { 'records': [ { 'value': payload } ] }; +ascAdapter.sendPayload = function (data) { + var obj = { 'records': [{ 'value': data }] }; let strJSON = JSON.stringify(obj); - _logInfo(' sendPayload ', JSON.stringify(obj)); - ajax(DEFAULT_EVENT_URL, undefined, strJSON, { + sendDataOnKf(strJSON); +} + +function sendDataOnKf(dataObj) { + ajax(DEFAULT_EVENT_URL, { + success: function () { + _logInfo('send data success'); + }, + error: function (e) { + _logInfo('send data error', e); + } + }, dataObj, { contentType: 'application/vnd.kafka.json.v2+json', method: 'POST', withCredentials: true }); } -function addKeyForPrebidWinningAndWinningsBids() { - var prebidWinningBids = $$PREBID_GLOBAL$$.getAllPrebidWinningBids(); - var winningBids = $$PREBID_GLOBAL$$.getAllWinningBids(); - prebidWinningBids && prebidWinningBids.length > 0 && prebidWinningBids.forEach(pbbid => { - payload['auctionData'] && payload['auctionData'].forEach(rwData => { - if (rwData['bids_bid_id'] === pbbid.requestId && rwData['br_size'] === pbbid.size) { - rwData['is_prebid_winning_bid'] = 1; - } - }); - }) - winningBids && winningBids.length > 0 && winningBids.forEach(wBid => { - payload['auctionData'] && payload['auctionData'].forEach(rwData => { - if (rwData['bids_bid_id'] === wBid.requestId && rwData['br_size'] === wBid.size) { - rwData['is_winning_bid'] = 1; - } - }); - }) -} - adapterManager.registerAnalyticsAdapter({ adapter: ascAdapter, - code: 'bydata' + code: MODULE_CODE, }); function _logInfo(message, meta) { @@ -305,7 +406,7 @@ function _logError(message) { } function buildLogMessage(message) { - return 'Bydata Prebid Analytics: ' + message; + return 'Bydata Prebid Analytics ' + versionCode + ':' + message; } export default ascAdapter; diff --git a/modules/byDataAnalyticsAdapter.md b/modules/byDataAnalyticsAdapter.md index 84207d8b3a1..a0780ecb514 100644 --- a/modules/byDataAnalyticsAdapter.md +++ b/modules/byDataAnalyticsAdapter.md @@ -1,7 +1,7 @@ # Overview layout: Analytics Adapter -title: Ascendeum Pvt Ltd. (https://ascendeum.com/) +title: byData. (https://bydata.com/) description: Bydata Analytics Adapter modulecode: byDataAnalyticsAdapter gdpr_supported: false (EU GDPR support) @@ -13,11 +13,12 @@ enable_download: false (in case you don't want users of the website to dow Module Name: Bydata Analytics Adapter Module Type: Analytics Adapter -Maintainer: Ascendeum +Maintainer: byData # Description -Analytics adapter for https://ascendeum.com/. Contact engineering@ascendeum.com for information. +Analytics adapter for https://bydata.com/. Contact admin@byData.com for information. + # Test Parameters @@ -25,10 +26,8 @@ Analytics adapter for https://ascendeum.com/. Contact engineering@ascendeum.com { provider: 'bydata', options : { - clientId: "ASCENDEUM_PROVIDED_CLIENT_ID", + clientId: "please contact byData team to get a clientId", logFrequency : 100, // Sample Rate Default - 1% } } ``` - - diff --git a/modules/byplayBidAdapter.md b/modules/byplayBidAdapter.md deleted file mode 100644 index 67fb9c40d35..00000000000 --- a/modules/byplayBidAdapter.md +++ /dev/null @@ -1,37 +0,0 @@ -# Overview - -``` -Module Name: ByPlay Bidder Adapter -Module Type: Bidder Adapter -Maintainer: byplayers@tsumikiinc.com -``` - -# Description - -Connects to ByPlay exchange for bids. - -ByPlay bid adapter supports Video. - -# Test Parameters -``` - const adUnits = [ - { - code: 'byplay-ad', - mediaTypes: { - video: { - playerSize: [400, 225], - context: 'outstream' - } - }, - bids: [ - { - bidder: 'byplay', - params: { - sectionId: '7986', - env: 'dev' - } - } - ] - } - ]; -``` diff --git a/modules/c1xBidAdapter.js b/modules/c1xBidAdapter.js new file mode 100644 index 00000000000..8c9407825ba --- /dev/null +++ b/modules/c1xBidAdapter.js @@ -0,0 +1,209 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { logInfo, logError } from '../src/utils.js'; +import { BANNER } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'c1x'; +const URL = 'https://hb-stg.c1exchange.com/ht'; +// const PIXEL_ENDPOINT = '//px.c1exchange.com/pubpixel/'; +const LOG_MSG = { + invalidBid: 'C1X: [ERROR] bidder returns an invalid bid', + noSite: 'C1X: [ERROR] no site id supplied', + noBid: 'C1X: [INFO] creating a NO bid for Adunit: ', + bidWin: 'C1X: [INFO] creating a bid for Adunit: ' +}; + +/** + * Adapter for requesting bids from C1X header tag server. + * v3.1 (c) C1X Inc., 2018 + */ + +export const c1xAdapter = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + // check the bids sent to c1x bidder + isBidRequestValid: function (bid) { + if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { + return false; + } + if (typeof bid.params.placementId === 'undefined') { + return false; + } + return true; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests A non-empty list of valid bid requests that should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + let payload = {}; + let tagObj = {}; + let bidRequest = []; + const adunits = validBidRequests.length; + const rnd = new Date().getTime(); + const c1xTags = validBidRequests.map(bidToTag); + const bidIdTags = validBidRequests.map(bidToShortTag); // include only adUnitCode and bidId from request obj + + // flattened tags in a tag object + tagObj = c1xTags.reduce((current, next) => Object.assign(current, next)); + + payload = { + adunits: adunits.toString(), + rnd: rnd.toString(), + response: 'json', + compress: 'gzip' + }; + + // for GDPR support + if (bidderRequest && bidderRequest.gdprConsent) { + payload['consent_string'] = bidderRequest.gdprConsent.consentString; + payload['consent_required'] = (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies.toString() : 'true' + ; + } + + Object.assign(payload, tagObj); + let payloadString = stringifyPayload(payload); + // ServerRequest object + bidRequest.push({ + method: 'GET', + url: URL, + data: payloadString, + bids: bidIdTags + }); + return bidRequest; + }, + + interpretResponse: function (serverResponse, requests) { + serverResponse = serverResponse.body; + requests = requests.bids || []; + const currency = 'USD'; + const bidResponses = []; + let netRevenue = false; + + if (!serverResponse || serverResponse.error) { + let errorMessage = serverResponse.error; + logError(LOG_MSG.invalidBid + errorMessage); + return bidResponses; + } else { + serverResponse.forEach(bid => { + logInfo(bid) + if (bid.bid) { + if (bid.bidType === 'NET_BID') { + netRevenue = !netRevenue; + } + const curBid = { + requestId: bid.bidId, + width: bid.width, + height: bid.height, + cpm: bid.cpm, + ad: bid.ad, + creativeId: bid.crid, + currency: currency, + ttl: 300, + netRevenue: netRevenue + }; + + if (bid.dealId) { + curBid['dealId'] = bid.dealId + } + + for (let i = 0; i < requests.length; i++) { + if (bid.adId === requests[i].adUnitCode) { + curBid.requestId = requests[i].bidId; + } + } + logInfo(LOG_MSG.bidWin + bid.adId + ' size: ' + curBid.width + 'x' + curBid.height); + bidResponses.push(curBid); + } else { + // no bid + logInfo(LOG_MSG.noBid + bid.adId); + } + }); + } + + return bidResponses; + } + +} + +function bidToTag(bid, index) { + const tag = {}; + const adIndex = 'a' + (index + 1).toString(); // ad unit id for c1x + const sizeKey = adIndex + 's'; + const priceKey = adIndex + 'p'; + const dealKey = adIndex + 'd'; + // TODO: Multiple Floor Prices + + const sizesArr = bid.sizes; + const floorPriceMap = getBidFloor(bid); + + const dealId = bid.params.dealId || ''; + + if (dealId) { + tag[dealKey] = dealId; + } + + tag[adIndex] = bid.adUnitCode; + tag[sizeKey] = sizesArr.reduce((prev, current) => prev + (prev === '' ? '' : ',') + current.join('x'), ''); + const newSizeArr = tag[sizeKey].split(','); + if (floorPriceMap) { + newSizeArr.forEach(size => { + if (size in floorPriceMap) { + tag[priceKey] = floorPriceMap[size].toString(); + } // we only accept one cpm price in floorPriceMap + }); + } + if (bid.params.pageurl) { + tag['pageurl'] = bid.params.pageurl; + } + + return tag; +} + +function getBidFloor(bidRequest) { + let floorInfo = {}; + + if (typeof bidRequest.getFloor === 'function') { + floorInfo = bidRequest.getFloor({ + currency: 'USD', + mediaType: 'banner', + size: '*', + }); + } + + let floor = + floorInfo.floor || + bidRequest.params.bidfloor || + bidRequest.params.floorPriceMap || + 0; + + return floor; +} + +function bidToShortTag(bid) { + const tag = {}; + tag.adUnitCode = bid.adUnitCode; + tag.bidId = bid.bidId; + return tag; +} + +function stringifyPayload(payload) { + let payloadString = []; + for (var key in payload) { + if (payload.hasOwnProperty(key)) { + payloadString.push(key + '=' + payload[key]); + } + } + return payloadString.join('&'); +} + +registerBidder(c1xAdapter); diff --git a/modules/c1xBidAdapter.md b/modules/c1xBidAdapter.md index 83a4ff1ea81..9a7cef486d2 100644 --- a/modules/c1xBidAdapter.md +++ b/modules/c1xBidAdapter.md @@ -2,7 +2,7 @@ Module Name: C1X Bidder Adapter Module Type: Bidder Adapter -Maintainer: cathy@c1exchange.com +Maintainer: vishnu@c1exchange.com # Description @@ -10,23 +10,61 @@ Module that connects to C1X's demand sources # Test Parameters ``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 600], [300, 250]], - bids: [ - { - bidder: 'c1x', - params: { - siteId: '9999', - pixelId: '12345', - floorPriceMap: { - '300x250': 0.20, - '300x600': 0.30 - }, //optional - } - } - ] - }, - ]; + var adUnits = [{ + code: 'test-div-1', + mediaTypes: { + banner: { + sizes: [[750, 200]], + } + }, + bids: [{ + bidder: 'c1x', + params: { + placementId: 'div-gpt-ad-1654594619717-0', + 'floorPriceMap': { + '300x250': 4.35 + } + } + }] + }, { + code: 'test-div-2', + mediaTypes: { + banner: { + sizes: [[300, 250], [750, 200]], + } + }, + bids: [{ + bidder: 'c1x', + params: { + placementId: 'div-gpt-ad-1654940683355-0', + 'floorPriceMap': { + '300x250': 4.35 + } + dealId: '1233' // optional parameter + } + }] + }]; + + + pbjs.bidderSettings = { + c1x: { + siteId: 999, + adserverTargeting: [{ + key: "hb_bidder", + val: function(bidResponse) { + return bidResponse.bidderCode; + } + }, { + key: "hb_adid", + val: function(bidResponse) { + return bidResponse.adId; + } + }, { + key: "hb_pb", + val: function(bidResponse) { + return bidResponse.pbLg; + } + }] + } + } ``` \ No newline at end of file diff --git a/modules/emx_digitalBidAdapter.js b/modules/cadentApertureMXBidAdapter.js similarity index 66% rename from modules/emx_digitalBidAdapter.js rename to modules/cadentApertureMXBidAdapter.js index 66fd2eb2ac1..e73564dacdb 100644 --- a/modules/emx_digitalBidAdapter.js +++ b/modules/cadentApertureMXBidAdapter.js @@ -1,32 +1,35 @@ import { _each, - deepAccess, - getBidIdParameter, + deepAccess, getBidIdParameter, isArray, isFn, isPlainObject, isStr, logError, - logWarn, - parseUrl + logWarn } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {Renderer} from '../src/Renderer.js'; import {find, includes} from '../src/polyfill.js'; +import {parseDomain} from '../src/refererDetection.js'; -const BIDDER_CODE = 'emx_digital'; +const BIDDER_CODE = 'cadent_aperture_mx'; const ENDPOINT = 'hb.emxdgt.com'; const RENDERER_URL = 'https://js.brealtime.com/outstream/1.30.0/bundle.js'; const ADAPTER_VERSION = '1.5.1'; const DEFAULT_CUR = 'USD'; +const ALIASES = [ + { code: 'emx_digital', gvlid: 183 }, + { code: 'cadent', gvlid: 183 }, +]; const EIDS_SUPPORTED = [ { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' }, { key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' } ]; -export const emxAdapter = { +export const cadentAdapter = { validateSizes: (sizes) => { if (!isArray(sizes) || typeof sizes[0] === 'undefined') { logWarn(BIDDER_CODE + ': Sizes should be an array'); @@ -40,7 +43,7 @@ export const emxAdapter = { buildBanner: (bid) => { let sizes = []; bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; - if (!emxAdapter.validateSizes(sizes)) { + if (!cadentAdapter.validateSizes(sizes)) { logWarn(BIDDER_CODE + ': could not detect mediaType banner sizes. Assigning to bid sizes instead'); sizes = bid.sizes } @@ -55,13 +58,13 @@ export const emxAdapter = { h: sizes[0][1] }; }, - formatVideoResponse: (bidResponse, emxBid, bidRequest) => { - bidResponse.vastXml = emxBid.adm; + formatVideoResponse: (bidResponse, cadentBid, bidRequest) => { + bidResponse.vastXml = cadentBid.adm; if (bidRequest.bidderRequest && bidRequest.bidderRequest.bids && bidRequest.bidderRequest.bids.length > 0) { const matchingBid = find(bidRequest.bidderRequest.bids, bid => bidResponse.requestId && bid.bidId && bidResponse.requestId === bid.bidId && bid.mediaTypes && bid.mediaTypes.video && bid.mediaTypes.video.context === 'outstream'); if (matchingBid) { - bidResponse.renderer = emxAdapter.createRenderer(bidResponse, { - id: emxBid.id, + bidResponse.renderer = cadentAdapter.createRenderer(bidResponse, { + id: cadentBid.id, url: RENDERER_URL }); } @@ -81,7 +84,7 @@ export const emxAdapter = { dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, h: screen.height, w: screen.width, - devicetype: emxAdapter.isMobile() ? 1 : emxAdapter.isConnectedTV() ? 3 : 2, + devicetype: cadentAdapter.isMobile() ? 1 : cadentAdapter.isConnectedTV() ? 3 : 2, language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), }; }, @@ -114,7 +117,7 @@ export const emxAdapter = { loaded: false }); try { - renderer.setRender(emxAdapter.outstreamRender); + renderer.setRender(cadentAdapter.outstreamRender); } catch (err) { logWarn('Prebid Error calling setRender on renderer', err); } @@ -131,69 +134,78 @@ export const emxAdapter = { videoObj['w'] = bid.mediaTypes.video.playerSize[0]; videoObj['h'] = bid.mediaTypes.video.playerSize[1]; } - return emxAdapter.cleanProtocols(videoObj); + return cadentAdapter.cleanProtocols(videoObj); }, parseResponse: (bidResponseAdm) => { try { return decodeURIComponent(bidResponseAdm.replace(/%(?![0-9][0-9a-fA-F]+)/g, '%25')); } catch (err) { - logError('emx_digitalBidAdapter', 'error', err); - } - }, - getReferrer: () => { - try { - return window.top.document.referrer; - } catch (err) { - return document.referrer; + logError('cadent_aperture_mxBidAdapter', 'error', err); } }, getSite: (refInfo) => { - let url = parseUrl(refInfo.referer); + // TODO: do the fallbacks make sense? return { - domain: url.hostname, - page: refInfo.referer, - ref: emxAdapter.getReferrer() + domain: refInfo.domain || parseDomain(refInfo.topmostLocation), + page: refInfo.page || refInfo.topmostLocation, + ref: refInfo.ref || window.document.referrer } }, - getGdpr: (bidRequests, emxData) => { + getGdpr: (bidRequests, cadentData) => { if (bidRequests.gdprConsent) { - emxData.regs = { + cadentData.regs = { ext: { gdpr: bidRequests.gdprConsent.gdprApplies === true ? 1 : 0 } }; } if (bidRequests.gdprConsent && bidRequests.gdprConsent.gdprApplies) { - emxData.user = { + cadentData.user = { ext: { consent: bidRequests.gdprConsent.consentString } }; } - return emxData; + return cadentData; }, - getSupplyChain: (bidderRequest, emxData) => { + + getGpp: (bidRequest, cadentData) => { + if (bidRequest.gppConsent) { + const {gppString: gpp, applicableSections: gppSid} = bidRequest.gppConsent; + if (cadentData.regs) { + cadentData.regs.gpp = gpp; + cadentData.regs.gpp_sid = gppSid; + } else { + cadentData.regs = { + gpp: gpp, + gpp_sid: gppSid + } + } + } + return cadentData; + }, + getSupplyChain: (bidderRequest, cadentData) => { if (bidderRequest.bids[0] && bidderRequest.bids[0].schain) { - emxData.source = { + cadentData.source = { ext: { schain: bidderRequest.bids[0].schain } }; } - return emxData; + return cadentData; }, // supporting eids getEids(bidRequests) { return EIDS_SUPPORTED - .map(emxAdapter.getUserId(bidRequests)) + .map(cadentAdapter.getUserId(bidRequests)) .filter(x => x); }, getUserId(bidRequests) { return ({ key, source, rtiPartner }) => { let id = deepAccess(bidRequests, `userId.${key}`); - return id ? emxAdapter.formatEid(id, source, rtiPartner) : null; + return id ? cadentAdapter.formatEid(id, source, rtiPartner) : null; }; }, formatEid(id, source, rtiPartner) { @@ -210,6 +222,7 @@ export const emxAdapter = { export const spec = { code: BIDDER_CODE, gvlid: 183, + alias: ALIASES, supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function (bid) { if (!bid || !bid.params) { @@ -218,7 +231,7 @@ export const spec = { } if (bid.bidder !== BIDDER_CODE) { - logWarn(BIDDER_CODE + ': Must use "emx_digital" as bidder code.'); + logWarn(BIDDER_CODE + ': Must use "cadent_aperture_mx" as bidder code.'); return false; } @@ -230,12 +243,12 @@ export const spec = { if (bid.mediaTypes && bid.mediaTypes.banner) { let sizes; bid.mediaTypes.banner.sizes ? sizes = bid.mediaTypes.banner.sizes : sizes = bid.sizes; - if (!emxAdapter.validateSizes(sizes)) { + if (!cadentAdapter.validateSizes(sizes)) { logWarn(BIDDER_CODE + ': Missing sizes in bid'); return false; } } else if (bid.mediaTypes && bid.mediaTypes.video) { - if (!emxAdapter.checkVideoContext(bid)) { + if (!cadentAdapter.checkVideoContext(bid)) { logWarn(BIDDER_CODE + ': Missing video context: instream or outstream'); return false; } @@ -249,13 +262,13 @@ export const spec = { return true; }, buildRequests: function (validBidRequests, bidderRequest) { - const emxImps = []; + const cadentImps = []; const timeout = bidderRequest.timeout || ''; const timestamp = Date.now(); const url = 'https://' + ENDPOINT + ('?t=' + timeout + '&ts=' + timestamp + '&src=pbjs'); const secure = location.protocol.indexOf('https') > -1 ? 1 : 0; - const device = emxAdapter.getDevice(); - const site = emxAdapter.getSite(bidderRequest.refererInfo); + const device = cadentAdapter.getDevice(); + const site = cadentAdapter.getSite(bidderRequest.refererInfo); _each(validBidRequests, function (bid) { let tagid = getBidIdParameter('tagid', bid.params); @@ -263,7 +276,7 @@ export const spec = { let isVideo = !!bid.mediaTypes.video; let data = { id: bid.bidId, - tid: bid.transactionId, + tid: bid.ortb2Imp?.ext?.tid, tagid, secure }; @@ -276,35 +289,36 @@ export const spec = { if (gpid) { data.ext = {gpid: gpid.toString()}; } - let typeSpecifics = isVideo ? { video: emxAdapter.buildVideo(bid) } : { banner: emxAdapter.buildBanner(bid) }; + let typeSpecifics = isVideo ? { video: cadentAdapter.buildVideo(bid) } : { banner: cadentAdapter.buildBanner(bid) }; let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {}; - let emxBid = Object.assign(data, typeSpecifics, bidfloorObj); - emxImps.push(emxBid); + let cadentBid = Object.assign(data, typeSpecifics, bidfloorObj); + cadentImps.push(cadentBid); }); - let emxData = { - id: bidderRequest.auctionId, - imp: emxImps, + let cadentData = { + id: bidderRequest.auctionId ?? bidderRequest.bidderRequestId, + imp: cadentImps, device, site, cur: DEFAULT_CUR, version: ADAPTER_VERSION }; - emxData = emxAdapter.getGdpr(bidderRequest, Object.assign({}, emxData)); - emxData = emxAdapter.getSupplyChain(bidderRequest, Object.assign({}, emxData)); + cadentData = cadentAdapter.getGdpr(bidderRequest, Object.assign({}, cadentData)); + cadentData = cadentAdapter.getGpp(bidderRequest, Object.assign({}, cadentData)); + cadentData = cadentAdapter.getSupplyChain(bidderRequest, Object.assign({}, cadentData)); if (bidderRequest && bidderRequest.uspConsent) { - emxData.us_privacy = bidderRequest.uspConsent + cadentData.us_privacy = bidderRequest.uspConsent; } // adding eid support if (bidderRequest.userId) { - let eids = emxAdapter.getEids(bidderRequest); + let eids = cadentAdapter.getEids(bidderRequest); if (eids.length > 0) { - if (emxData.user && emxData.user.ext) { - emxData.user.ext.eids = eids; + if (cadentData.user && cadentData.user.ext) { + cadentData.user.ext.eids = eids; } else { - emxData.user = { + cadentData.user = { ext: {eids} }; } @@ -314,7 +328,7 @@ export const spec = { return { method: 'POST', url, - data: JSON.stringify(emxData), + data: JSON.stringify(cadentData), options: { withCredentials: true }, @@ -322,55 +336,70 @@ export const spec = { }; }, interpretResponse: function (serverResponse, bidRequest) { - let emxBidResponses = []; + let cadentBidResponses = []; let response = serverResponse.body || {}; if (response.seatbid && response.seatbid.length > 0 && response.seatbid[0].bid) { - response.seatbid.forEach(function (emxBid) { - emxBid = emxBid.bid[0]; + response.seatbid.forEach(function (cadentBid) { + cadentBid = cadentBid.bid[0]; let isVideo = false; - let adm = emxAdapter.parseResponse(emxBid.adm) || ''; + let adm = cadentAdapter.parseResponse(cadentBid.adm) || ''; let bidResponse = { - requestId: emxBid.id, - cpm: emxBid.price, - width: emxBid.w, - height: emxBid.h, - creativeId: emxBid.crid || emxBid.id, - dealId: emxBid.dealid || null, + requestId: cadentBid.id, + cpm: cadentBid.price, + width: cadentBid.w, + height: cadentBid.h, + creativeId: cadentBid.crid || cadentBid.id, + dealId: cadentBid.dealid || null, currency: 'USD', netRevenue: true, - ttl: emxBid.ttl, + ttl: cadentBid.ttl, ad: adm }; - if (emxBid.adm && emxBid.adm.indexOf(' -1) { + if (cadentBid.adm && cadentBid.adm.indexOf(' -1) { isVideo = true; - bidResponse = emxAdapter.formatVideoResponse(bidResponse, Object.assign({}, emxBid), bidRequest); + bidResponse = cadentAdapter.formatVideoResponse(bidResponse, Object.assign({}, cadentBid), bidRequest); } bidResponse.mediaType = (isVideo ? VIDEO : BANNER); // support for adomain in prebid 5.0 - if (emxBid.adomain && emxBid.adomain.length) { + if (cadentBid.adomain && cadentBid.adomain.length) { bidResponse.meta = { - advertiserDomains: emxBid.adomain + advertiserDomains: cadentBid.adomain }; } - emxBidResponses.push(bidResponse); + cadentBidResponses.push(bidResponse); }); } - return emxBidResponses; + return cadentBidResponses; }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) { const syncs = []; + const consentParams = []; if (syncOptions.iframeEnabled) { let url = 'https://biddr.brealtime.com/check.html'; if (gdprConsent && typeof gdprConsent.consentString === 'string') { // add 'gdpr' only if 'gdprApplies' is defined if (typeof gdprConsent.gdprApplies === 'boolean') { - url += `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + consentParams.push(`gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`); } else { - url += `?gdpr_consent=${gdprConsent.consentString}`; + consentParams.push(`?gdpr_consent=${gdprConsent.consentString}`); } } + if (uspConsent && typeof uspConsent.consentString === 'string') { + consentParams.push(`usp=${uspConsent.consentString}`); + } + if (gppConsent && typeof gppConsent === 'object') { + if (gppConsent.gppString && typeof gppConsent.gppString === 'string') { + consentParams.push(`gpp=${gppConsent.gppString}`); + } + if (gppConsent.applicableSections && typeof gppConsent.applicableSections === 'object') { + consentParams.push(`gpp_sid=${gppConsent.applicableSections}`); + } + } + if (consentParams.length > 0) { + url = url + '?' + consentParams.join('&'); + } syncs.push({ type: 'iframe', url: url diff --git a/modules/emx_digitalBidAdapter.md b/modules/cadentApertureMXBidAdapter.md similarity index 55% rename from modules/emx_digitalBidAdapter.md rename to modules/cadentApertureMXBidAdapter.md index 03ba554c5ad..d924f904be4 100644 --- a/modules/emx_digitalBidAdapter.md +++ b/modules/cadentApertureMXBidAdapter.md @@ -1,18 +1,18 @@ # Overview ``` -Module Name: EMX Digital Adapter +Module Name: Cadent Aperture MX Adapter Module Type: Bidder Adapter -Maintainer: git@emxdigital.com +Maintainer: contactaperturemx@cadent.tv ``` # Description -The EMX Digital adapter provides publishers with access to the EMX Marketplace. The adapter is GDPR compliant. Please note that the adapter supports Banner and Video (Instream & Outstream) media types. +The Cadent Aperture MX adapter provides publishers with access to the Cadent Aperture MX SSP. The adapter is GDPR compliant. Please note that the adapter supports Banner and Video (Instream & Outstream) media types. -Note: The EMX Digital adapter requires approval and implementation guidelines from the EMX team, including existing publishers that work with EMX Digital. Please reach out to your account manager or prebid@emxdigital.com for more information. +Note: The Cadent Aperture MX adapter requires approval and implementation guidelines from the Cadent team, including existing publishers that work with Cadent. Please reach out to your account manager or contactaperturemx@cadent.tv for more information. -The bidder code should be ```emx_digital``` +The bidder code should be ```cadent_aperture_mx``` The params used by the bidder are : ```tagid``` - string (mandatory) ```bidfloor``` - string (optional) @@ -29,7 +29,7 @@ var adUnits = [{ }, bids: [ { - bidder: 'emx_digital', + bidder: 'cadent_aperture_mx', params: { tagid: '25251', } @@ -49,7 +49,7 @@ var adUnits = [{ }, bids: [ { - bidder: 'emx_digital', + bidder: 'cadent_aperture_mx', params: { tagid: '25251', video: { diff --git a/modules/carodaBidAdapter.js b/modules/carodaBidAdapter.js new file mode 100644 index 00000000000..cb7b5fbe7c5 --- /dev/null +++ b/modules/carodaBidAdapter.js @@ -0,0 +1,218 @@ +// jshint esversion: 6, es3: false, node: true +'use strict' + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { + deepAccess, + deepSetValue, + logError, + mergeDeep, + parseSizesInput +} from '../src/utils.js'; +import { config } from '../src/config.js'; + +const { getConfig } = config; + +const BIDDER_CODE = 'caroda'; +const GVLID = 954; + +// some state info is required to synchronize with Caroda ad server +const topUsableWindow = getTopUsableWindow(); + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid: bid => { + const params = bid.params || {}; + const { ctok, placementId, priceType } = params; + return typeof ctok === 'string' && ( + typeof placementId === 'string' || + typeof placementId === 'undefined' + ) && ( + typeof priceType === 'undefined' || + priceType === 'gross' || + priceType === 'net' + ); + }, + buildRequests: (validBidRequests, bidderRequest) => { + topUsableWindow.carodaPageViewId = topUsableWindow.carodaPageViewId || Math.floor(Math.random() * 1e9); + const pageViewId = topUsableWindow.carodaPageViewId; + const ortbCommon = getORTBCommon(bidderRequest); + const priceType = + getFirstWithKey(validBidRequests, 'params.priceType') || + 'net'; + const test = getFirstWithKey(validBidRequests, 'params.test'); + const currency = getConfig('currency.adServerCurrency'); + const eids = getFirstWithKey(validBidRequests, 'userIdAsEids'); + const schain = getFirstWithKey(validBidRequests, 'schain'); + const request = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + auctionId: bidderRequest.auctionId, + currency, + hb_version: '$prebid.version$', + ...ortbCommon, + price_type: priceType + }; + if (test) { + request.test = 1; + } + if (schain) { + request.schain = schain; + } + if (config.getConfig('coppa')) { + deepSetValue(request, 'privacy.coppa', 1); + } + if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) { + deepSetValue( + request, + 'privacy.gdpr_consent', + bidderRequest.gdprConsent.consentString + ); + deepSetValue( + request, + 'privacy.gdpr', + bidderRequest.gdprConsent.gdprApplies & 1 + ); + } + if (bidderRequest.uspConsent) { + deepSetValue(request, 'privacy.us_privacy', bidderRequest.uspConsent); + } + if (eids) { + deepSetValue(request, 'user.eids', eids); + } + return getImps(validBidRequests, request).map(imp => ({ + method: 'POST', + url: 'https://prebid.caroda.io/api/hb?entry_id=' + pageViewId, + data: JSON.stringify(imp) + })); + }, + interpretResponse: (serverResponse) => { + if (!serverResponse.body) { + return; + } + const { ok, error } = serverResponse.body + if (error) { + logError(BIDDER_CODE, ': server caught', error.message); + return; + } + try { + return JSON.parse(ok.value) + .map((bid) => { + const ret = { + requestId: bid.bid_id, + cpm: bid.cpm, + creativeId: bid.creative_id, + ttl: 300, + netRevenue: true, + currency: bid.currency, + width: bid.w, + height: bid.h, + meta: { + advertiserDomains: bid.adomain || [] + }, + ad: bid.ad, + placementId: bid.placement_id + } + if (bid.adserver_targeting) { + ret.adserverTargeting = bid.adserver_targeting + } + return ret + }) + .filter(Boolean); + } catch (e) { + logError(BIDDER_CODE, ': caught', e); + } + } +} + +registerBidder(spec) + +function getFirstWithKey (collection, key) { + for (let i = 0, result; i < collection.length; i++) { + result = deepAccess(collection[i], key); + if (result) { + return result; + } + } +} + +function getTopUsableWindow () { + let res = window; + try { + while (window.top !== res && res.parent.location.href.length) { + res = res.parent; + } + } catch (e) {} + return res; +} + +function getORTBCommon (bidderRequest) { + let app, site; + const commonFpd = bidderRequest.ortb2 || {}; + let { user } = commonFpd; + if (typeof getConfig('app') === 'object') { + app = getConfig('app') || {} + if (commonFpd.app) { + mergeDeep(app, commonFpd.app); + } + } else { + site = getConfig('site') || {}; + if (commonFpd.site) { + mergeDeep(site, commonFpd.site); + } + if (!site.page) { + site.page = bidderRequest.refererInfo.page; + } + } + const device = getConfig('device') || {}; + device.w = device.w || window.innerWidth; + device.h = device.h || window.innerHeight; + device.ua = device.ua || navigator.userAgent; + return { + app, + site, + user, + device + }; +} + +function getImps (validBidRequests, common) { + return validBidRequests.map((bid) => { + const floorInfo = bid.getFloor + ? bid.getFloor({ currency: common.currency || 'EUR' }) + : {}; + const bidfloor = floorInfo.floor; + const bidfloorcur = floorInfo.currency; + const { ctok, placementId } = bid.params; + const imp = { + bid_id: bid.bidId, + ctok, + bidfloor, + bidfloorcur, + ...common + }; + const bannerParams = deepAccess(bid, 'mediaTypes.banner'); + if (bannerParams && bannerParams.sizes) { + const sizes = parseSizesInput(bannerParams.sizes); + const format = sizes.map(size => { + const [width, height] = size.split('x'); + const w = parseInt(width, 10); + const h = parseInt(height, 10); + return { w, h }; + }); + imp.banner = { + format + }; + } + if (placementId) { + imp.placement_id = placementId; + } + const videoParams = deepAccess(bid, 'mediaTypes.video'); + if (videoParams) { + imp.video = videoParams; + } + return imp; + }) +} diff --git a/modules/carodaBidAdapter.md b/modules/carodaBidAdapter.md new file mode 100644 index 00000000000..35785525038 --- /dev/null +++ b/modules/carodaBidAdapter.md @@ -0,0 +1,43 @@ +# Overview + +Module Name: Caroda Adapter +Module Type: Bidder Adapter +Maintainer: dev@caroda.io + +# Description + +Module that connects to Caroda demand sources to fetch bids. +Banner and video formats are supported. +Use `caroda` as bidder. + +# Test Parameters +``` + var adUnits = [{ + code: '/19968336/prebid_banner_example_1', + mediaTypes: { + banner: { + sizes: [[ 300, 250 ]] + } + } + bids: [{ + bidder: 'caroda', + params: { + ctok: '230ce9490c5434354' + } + }] + }, { + code: '/19968336/prebid_video_example_1', + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + } + } + bids: [{ + bidder: 'caroda', + params: { + ctok: '230ce9490c5434354' + } + }] + }]; +``` diff --git a/modules/categoryTranslation.js b/modules/categoryTranslation.js index 9a9289fcd73..eb6cb83730a 100644 --- a/modules/categoryTranslation.js +++ b/modules/categoryTranslation.js @@ -11,12 +11,13 @@ * If publisher has not defined translation file than prebid will use default prebid translation file provided here //cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json */ -import { config } from '../src/config.js'; -import { setupBeforeHookFnOnce, hook } from '../src/hook.js'; -import { ajax } from '../src/ajax.js'; -import { timestamp, logError } from '../src/utils.js'; -import { addBidResponse } from '../src/auction.js'; -import { getCoreStorageManager } from '../src/storageManager.js'; +import {config} from '../src/config.js'; +import {hook, setupBeforeHookFnOnce, ready} from '../src/hook.js'; +import {ajax} from '../src/ajax.js'; +import {logError, timestamp} from '../src/utils.js'; +import {addBidResponse} from '../src/auction.js'; +import {getCoreStorageManager} from '../src/storageManager.js'; +import {timedBidResponseHook} from '../src/utils/perfMetrics.js'; export const storage = getCoreStorageManager('categoryTranslation'); const DEFAULT_TRANSLATION_FILE_URL = 'https://cdn.jsdelivr.net/gh/prebid/category-mapping-file@1/freewheel-mapping.json'; @@ -31,15 +32,16 @@ export const registerAdserver = hook('async', function(adServer) { initTranslation(url, DEFAULT_IAB_TO_FW_MAPPING_KEY); } }, 'registerAdserver'); -registerAdserver(); -export function getAdserverCategoryHook(fn, adUnitCode, bid) { +ready.then(() => registerAdserver()); + +export const getAdserverCategoryHook = timedBidResponseHook('categoryTranslation', function getAdserverCategoryHook(fn, adUnitCode, bid, reject) { if (!bid) { - return fn.call(this, adUnitCode); // if no bid, call original and let it display warnings + return fn.call(this, adUnitCode, bid, reject); // if no bid, call original and let it display warnings } if (!config.getConfig('adpod.brandCategoryExclusion')) { - return fn.call(this, adUnitCode, bid); + return fn.call(this, adUnitCode, bid, reject); } let localStorageKey = (config.getConfig('brandCategoryTranslation.translationFile')) ? DEFAULT_IAB_TO_FW_MAPPING_KEY_PUB : DEFAULT_IAB_TO_FW_MAPPING_KEY; @@ -62,8 +64,8 @@ export function getAdserverCategoryHook(fn, adUnitCode, bid) { logError('Translation mapping data not found in local storage'); } } - fn.call(this, adUnitCode, bid); -} + fn.call(this, adUnitCode, bid, reject); +}); export function initTranslation(url, localStorageKey) { setupBeforeHookFnOnce(addBidResponse, getAdserverCategoryHook, 50); diff --git a/modules/ccxBidAdapter.js b/modules/ccxBidAdapter.js index 65d1ced30e2..b1fcb29e3d0 100644 --- a/modules/ccxBidAdapter.js +++ b/modules/ccxBidAdapter.js @@ -1,11 +1,11 @@ -import { deepAccess, isArray, _each, logWarn, isEmpty } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js' -import { config } from '../src/config.js' -import { getStorageManager } from '../src/storageManager.js'; +import {_each, deepAccess, isArray, isEmpty, logWarn} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getStorageManager} from '../src/storageManager.js'; const BIDDER_CODE = 'ccx' const storage = getStorageManager({bidderCode: BIDDER_CODE}); const BID_URL = 'https://delivery.clickonometrics.pl/ortb/prebid/bid' +const GVLID = 773; const SUPPORTED_VIDEO_PROTOCOLS = [2, 3, 5, 6] const SUPPORTED_VIDEO_MIMES = ['video/mp4', 'video/x-flv'] const SUPPORTED_VIDEO_PLAYBACK_METHODS = [1, 2, 3, 4] @@ -20,7 +20,7 @@ function _getDeviceObj () { function _getSiteObj (bidderRequest) { let site = {} - let url = config.getConfig('pageUrl') || deepAccess(window, 'location.href'); + let url = bidderRequest?.refererInfo?.page || '' if (url.length > 0) { url = url.split('?')[0] } @@ -140,6 +140,7 @@ function _buildResponse (bid, currency, ttl) { export const spec = { code: BIDDER_CODE, + gvlid: GVLID, supportedMediaTypes: ['banner', 'video'], isBidRequestValid: function (bid) { @@ -177,7 +178,7 @@ export const spec = { requestBody.imp = [] requestBody.site = _getSiteObj(bidderRequest) requestBody.device = _getDeviceObj() - requestBody.id = bidderRequest.bids[0].auctionId + requestBody.id = bidderRequest.bidderRequestId; requestBody.ext = {'ce': (storage.cookiesAreEnabled() ? 1 : 0)} // Attaching GDPR Consent Params diff --git a/modules/cedatoBidAdapter.md b/modules/cedatoBidAdapter.md deleted file mode 100644 index 088f8a4baef..00000000000 --- a/modules/cedatoBidAdapter.md +++ /dev/null @@ -1,53 +0,0 @@ -# Overview - -``` -Module Name: Cedato Bidder Adapter -Module Type: Bidder Adapter -Maintainer: alexk@cedato.com -``` - -# Description - -Connects to Cedato Bidder. -Player ID must be replaced. You can approach your Cedato account manager to get one. - -# Test Parameters -``` -var adUnits = [ - // Banner - { - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - // You can choose one of them - sizes: [ - [300, 250], - [300, 600], - [240, 400], - [728, 90], - ] - } - }, - bids: [ - { - bidder: "cedato", - params: { - player_id: 1450133326, - } - } - ] - } -]; - -pbjs.que.push(() => { - pbjs.setConfig({ - userSync: { - syncEnabled: true, - enabledBidders: ['cedato'], - pixelEnabled: true, - syncsPerBidder: 200, - syncDelay: 100, - }, - }); -}); -``` diff --git a/modules/chtnwBidAdapter.js b/modules/chtnwBidAdapter.js new file mode 100644 index 00000000000..5f77cec018a --- /dev/null +++ b/modules/chtnwBidAdapter.js @@ -0,0 +1,110 @@ +import { + generateUUID, + getDNT, + _each, +} from '../src/utils.js'; +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { ajax } from '../src/ajax.js'; +import {BANNER, VIDEO, NATIVE} from '../src/mediaTypes.js'; +const ENDPOINT_URL = 'https://prebid.cht.hinet.net/api/v1'; +const BIDDER_CODE = 'chtnw'; +const COOKIE_NAME = '__htid'; +const storage = getStorageManager({bidderCode: BIDDER_CODE}); + +const { getConfig } = config; + +function _isMobile() { + return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + isBidRequestValid: function(bid = {}) { + return !!(bid && bid.params); + }, + buildRequests: function(validBidRequests = [], bidderRequest = {}) { + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const chtnwId = (storage.getCookie(COOKIE_NAME) != undefined) ? storage.getCookie(COOKIE_NAME) : generateUUID(); + if (storage.cookiesAreEnabled()) { + storage.setCookie(COOKIE_NAME, chtnwId); + } + const device = getConfig('device') || {}; + device.w = device.w || window.innerWidth; + device.h = device.h || window.innerHeight; + device.ua = device.ua || navigator.userAgent; + device.dnt = getDNT() ? 1 : 0; + device.language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const bidParams = []; + _each(validBidRequests, function(bid) { + bidParams.push({ + bidId: bid.bidId, + placement: bid.params.placementId, + sizes: bid.sizes, + adSlot: bid.adUnitCode + }); + }); + return { + method: 'POST', + url: ENDPOINT_URL + '/request/prebid.json', + data: { + bids: bidParams, + uuid: chtnwId, + device: device, + version: { + prebid: '$prebid.version$', + adapter: '1.0.0', + }, + site: { + numIframes: bidderRequest.refererInfo?.numIframes || 0, + isAmp: bidderRequest.refererInfo?.isAmp || false, + pageUrl: bidderRequest.refererInfo?.page || '', + ref: bidderRequest.refererInfo?.ref || '', + }, + }, + bids: validBidRequests + }; + }, + interpretResponse: function(serverResponse) { + const bidResponses = [] + _each(serverResponse.body, function(response, i) { + bidResponses.push({ + ...response + }); + }); + return bidResponses; + }, + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + const syncs = []; + if (syncOptions.pixelEnabled) { + const chtnwId = generateUUID() + const uuid = chtnwId + const type = (_isMobile()) ? 'dot' : 'pixel'; + syncs.push({ + type: 'image', + url: `https://t.ssp.hinet.net/${type}?bd=${uuid}&t=chtnw` + }) + } + return syncs + }, + onTimeout: function(timeoutData) { + if (timeoutData === null) { + return; + } + ajax(ENDPOINT_URL + '/trace/timeout/bid', null, JSON.stringify(timeoutData), { + method: 'POST', + withCredentials: false + }); + }, + onBidWon: function(bid) { + if (bid.nurl) { + ajax(bid.nurl, null); + } + }, + onSetTargeting: function(bid) { + }, +} +registerBidder(spec); diff --git a/modules/chtnwBidAdapter.md b/modules/chtnwBidAdapter.md new file mode 100644 index 00000000000..08e634d577d --- /dev/null +++ b/modules/chtnwBidAdapter.md @@ -0,0 +1,31 @@ +# Overview + +``` +Module Name: CHT Bidder Adapter +Module Type: Bidder Adapter +Maintainer: chtdsp@cht.com.tw +``` + +# Description + +Module that connects to CHT's demand sources + +# Test Parameters +``` +var adUnits = [ + { + code: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [{ + bidder: 'chtnw', + params: { + placementId: '38EL412LO82XR9O6' + } + }] + } +]; +``` diff --git a/modules/cleanioRtdProvider.js b/modules/cleanioRtdProvider.js index b9fdcef768e..7d0f461108b 100644 --- a/modules/cleanioRtdProvider.js +++ b/modules/cleanioRtdProvider.js @@ -7,7 +7,10 @@ */ import { submodule } from '../src/hook.js'; +import { loadExternalScript } from '../src/adloader.js'; import { logError, generateUUID, insertElement } from '../src/utils.js'; +import * as events from '../src/events.js'; +import CONSTANTS from '../src/constants.json'; // ============================ MODULE STATE =============================== @@ -50,10 +53,7 @@ function pageInitStepPreloadScript(scriptURL) { * @param {string} scriptURL The script URL to add to the page for protection */ function pageInitStepProtectPage(scriptURL) { - const scriptElement = document.createElement('script'); - scriptElement.type = 'text/javascript'; - scriptElement.src = scriptURL; - insertElement(scriptElement); + loadExternalScript(scriptURL, 'clean.io'); } /** @@ -147,6 +147,25 @@ function readConfig(config) { } } +/** + * The function to be called upon module init + * Defined as a variable to be able to reset it naturally + */ +let startBillableEvents = function() { + // Upon clean.io submodule initialization, every winner bid is considered to be protected + // and therefore, subjected to billing + events.on(CONSTANTS.EVENTS.BID_WON, winnerBidResponse => { + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + vendor: 'clean.io', + billingId: generateUUID(), + type: 'impression', + auctionId: winnerBidResponse.auctionId, + transactionId: winnerBidResponse.transactionId, + bidId: winnerBidResponse.requestId, + }); + }); +} + // ============================ MODULE REGISTRATION =============================== /** @@ -160,6 +179,13 @@ function beforeInit() { try { readConfig(config); onModuleInit(); + + // Subscribing once to ensure no duplicate events + // in case module initialization code runs multiple times + // This should have been a part of submodule definition, but well... + // The assumption here is that in production init() will be called exactly once + startBillableEvents(); + startBillableEvents = () => {}; return true; } catch (err) { if (err instanceof ConfigError) { diff --git a/modules/cleanmedianetBidAdapter.js b/modules/cleanmedianetBidAdapter.js index 3fda9917715..601a237baa8 100644 --- a/modules/cleanmedianetBidAdapter.js +++ b/modules/cleanmedianetBidAdapter.js @@ -1,14 +1,34 @@ -import {deepAccess, getDNT, inIframe, isArray, isNumber, logError, logWarn} from '../src/utils.js'; +import { + deepAccess, + deepSetValue, + getDNT, + inIframe, + isArray, + isFn, + isNumber, + isPlainObject, + isStr, + logError, + logWarn +} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; import {Renderer} from '../src/Renderer.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {includes} from '../src/polyfill.js'; +const ENDPOINTS = { + 'cleanmedianet': 'https://bidder.cleanmediaads.com' +}; + +const DEFAULT_TTL = 360; + export const helper = { - getTopWindowDomain: function (url) { - const domainStart = url.indexOf('://') + '://'.length; - return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart)); + getTopFrame: function () { + try { + return window.top === window ? 1 : 0; + } catch (e) { + } + return 0; }, startsWith: function (str, search) { return str.substr(0, search.length) === search; @@ -24,55 +44,51 @@ export const helper = { } } return BANNER; + }, + getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return bid.params.bidfloor ? bid.params.bidfloor : null; + } + + let bidFloor = bid.getFloor({ + mediaType: '*', + size: '*', + currency: 'USD' + }); + + if (isPlainObject(bidFloor) && !isNaN(bidFloor.floor) && bidFloor.currency === 'USD') { + return bidFloor.floor; + } + + return null; } }; export const spec = { code: 'cleanmedianet', aliases: [], - supportedMediaTypes: [BANNER, VIDEO], + supportedMediaTypes: ['banner', 'video'], isBidRequestValid: function (bid) { - return ( - !!bid.params.supplyPartnerId && - typeof bid.params.supplyPartnerId === 'string' && - (typeof bid.params.bidfloor === 'undefined' || - typeof bid.params.bidfloor === 'number') && - (typeof bid.params['adpos'] === 'undefined' || - typeof bid.params['adpos'] === 'number') && - (typeof bid.params['protocols'] === 'undefined' || - Array.isArray(bid.params['protocols'])) && - (typeof bid.params.instl === 'undefined' || - bid.params.instl === 0 || - bid.params.instl === 1) - ); + return !!bid.params.supplyPartnerId && isStr(bid.params.supplyPartnerId) && + (!bid.params['rtbEndpoint'] || isStr(bid.params['rtbEndpoint'])) && + (!bid.params.bidfloor || isNumber(bid.params.bidfloor)) && + (!bid.params['adpos'] || isNumber(bid.params['adpos'])) && + (!bid.params['protocols'] || Array.isArray(bid.params['protocols'])) && + (!bid.params.instl || bid.params.instl === 0 || bid.params.instl === 1); }, buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { - const { - adUnitCode, - auctionId, - mediaTypes, - params, - sizes, - transactionId - } = bidRequest; - const baseEndpoint = 'https://bidder.cleanmediaads.com'; - const rtbEndpoint = - `${baseEndpoint}/r/${ - params.supplyPartnerId - }/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + - (params.query ? '&' + params.query : ''); - let url = - config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; - + const {adUnitCode, bidId, mediaTypes, params, sizes} = bidRequest; + const baseEndpoint = (params['rtbEndpoint'] || ENDPOINTS['cleanmedianet']).replace(/^http:/, 'https:'); + const rtbEndpoint = `${baseEndpoint}/r/${params.supplyPartnerId}/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + (params.query ? '&' + params.query : ''); const rtbBidRequest = { - id: auctionId, + id: bidId, site: { - domain: helper.getTopWindowDomain(url), - page: url, - ref: bidderRequest.refererInfo.referer + domain: bidderRequest.refererInfo.domain, + page: bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.ref }, device: { ua: navigator.userAgent, @@ -83,44 +99,35 @@ export const spec = { }, imp: [], ext: {}, - user: { - ext: {} - } + user: {ext: {}}, + source: {ext: {}}, + regs: {ext: {}} }; - if ( - bidderRequest.gdprConsent && - bidderRequest.gdprConsent.consentString && - bidderRequest.gdprConsent.gdprApplies - ) { - rtbBidRequest.ext.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - rtbBidRequest.regs = { - ext: { - gdpr: bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0 - } - }; - rtbBidRequest.user = { - ext: { - consent: bidderRequest.gdprConsent.consentString - } - } + const gdprConsent = getGdprConsent(bidderRequest); + rtbBidRequest.ext.gdpr_consent = gdprConsent; + deepSetValue(rtbBidRequest, 'regs.ext.gdpr', gdprConsent.consent_required === true ? 1 : 0); + deepSetValue(rtbBidRequest, 'user.ext.consent', gdprConsent.consent_string); + + if (validBidRequests[0].schain) { + deepSetValue(rtbBidRequest, 'source.ext.schain', validBidRequests[0].schain); + } + + if (bidderRequest && bidderRequest.uspConsent) { + deepSetValue(rtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); } const imp = { - id: transactionId, - instl: params.instl === 1 ? 1 : 0, + id: bidId, + instl: deepAccess(bidderRequest.ortb2Imp, 'instl') === 1 || params.instl === 1 ? 1 : 0, tagid: adUnitCode, - bidfloor: 0, + bidfloor: helper.getBidFloor(bidRequest) || 0, bidfloorcur: 'USD', secure: 1 }; const hasFavoredMediaType = - params.favoredMediaType && - includes(this.supportedMediaTypes, params.favoredMediaType); + params.favoredMediaType && includes(this.supportedMediaTypes, params.favoredMediaType); if (!mediaTypes || mediaTypes.banner) { if (!hasFavoredMediaType || params.favoredMediaType === BANNER) { @@ -128,7 +135,7 @@ export const spec = { banner: { w: sizes.length ? sizes[0][0] : 300, h: sizes.length ? sizes[0][1] : 250, - pos: params.pos || 0, + pos: deepAccess(bidderRequest, 'mediaTypes.banner.pos') || params.pos || 0, topframe: inIframe() ? 0 : 1 } }); @@ -138,15 +145,25 @@ export const spec = { if (mediaTypes && mediaTypes.video) { if (!hasFavoredMediaType || params.favoredMediaType === VIDEO) { - let videoImp = { + const playerSize = mediaTypes.video.playerSize || sizes; + const videoImp = Object.assign({}, imp, { video: { - protocols: params.protocols || [1, 2, 3, 4, 5, 6], - pos: params.pos || 0, - ext: {context: mediaTypes.video.context} + protocols: bidRequest.mediaTypes.video.protocols || params.protocols || [1, 2, 3, 4, 5, 6], + pos: deepAccess(bidRequest, 'mediaTypes.video.pos') || params.pos || 0, + ext: { + context: mediaTypes.video.context + }, + mimes: bidRequest.mediaTypes.video.mimes, + maxduration: bidRequest.mediaTypes.video.maxduration, + api: bidRequest.mediaTypes.video.api, + skip: bidRequest.mediaTypes.video.skip || bidRequest.params.video.skip, + placement: bidRequest.mediaTypes.video.placement || bidRequest.params.video.placement, + minduration: bidRequest.mediaTypes.video.minduration || bidRequest.params.video.minduration, + playbackmethod: bidRequest.mediaTypes.video.playbackmethod || bidRequest.params.video.playbackmethod, + startdelay: bidRequest.mediaTypes.video.startdelay || bidRequest.params.video.startdelay } - }; + }); - let playerSize = mediaTypes.video.playerSize || sizes; if (isArray(playerSize[0])) { videoImp.video.w = playerSize[0][0]; videoImp.video.h = playerSize[0][1]; @@ -158,11 +175,20 @@ export const spec = { videoImp.video.h = 250; } - videoImp = Object.assign({}, imp, videoImp); rtbBidRequest.imp.push(videoImp); } } + let eids = []; + if (bidRequest && bidRequest.userId) { + addExternalUserId(eids, deepAccess(bidRequest, `userId.id5id.uid`), 'id5-sync.com', 'ID5ID'); + addExternalUserId(eids, deepAccess(bidRequest, `userId.tdid`), 'adserver.org', 'TDID'); + addExternalUserId(eids, deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 'idl'); + } + if (eids.length > 0) { + rtbBidRequest.user.ext.eids = eids; + } + if (rtbBidRequest.imp.length === 0) { return; } @@ -183,10 +209,7 @@ export const spec = { return []; } - const bids = response.seatbid.reduce( - (acc, seatBid) => acc.concat(seatBid.bid), - [] - ); + const bids = response.seatbid.reduce((acc, seatBid) => acc.concat(seatBid.bid), []); let outBids = []; bids.forEach(bid => { @@ -195,75 +218,81 @@ export const spec = { cpm: bid.price, width: bid.w, height: bid.h, - ttl: 360, + ttl: DEFAULT_TTL, creativeId: bid.crid || bid.adid, netRevenue: true, currency: bid.cur || response.cur, - mediaType: helper.getMediaType(bid) + mediaType: helper.getMediaType(bid), }; - if ( - deepAccess( - bidRequest.bidRequest, - 'mediaTypes.' + outBid.mediaType - ) - ) { + if (bid.adomain && bid.adomain.length) { + outBid.meta = { + advertiserDomains: bid.adomain + } + } + + if (deepAccess(bidRequest.bidRequest, 'mediaTypes.' + outBid.mediaType)) { if (outBid.mediaType === BANNER) { outBids.push(Object.assign({}, outBid, {ad: bid.adm})); } else if (outBid.mediaType === VIDEO) { - const context = deepAccess( - bidRequest.bidRequest, - 'mediaTypes.video.context' - ); - outBids.push( - Object.assign({}, outBid, { - vastUrl: bid.ext.vast_url, - vastXml: bid.adm, - renderer: - context === 'outstream' - ? newRenderer(bidRequest.bidRequest, bid) - : undefined - }) - ); + const context = deepAccess(bidRequest.bidRequest, 'mediaTypes.video.context'); + outBids.push(Object.assign({}, outBid, { + vastUrl: bid.ext.vast_url, + vastXml: bid.adm, + renderer: context === 'outstream' ? newRenderer(bidRequest.bidRequest, bid) : undefined + })); } } }); return outBids; }, - getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; - const gdprApplies = - gdprConsent && typeof gdprConsent.gdprApplies === 'boolean' - ? gdprConsent.gdprApplies - : false; - const suffix = gdprApplies - ? 'gc=' + encodeURIComponent(gdprConsent.consentString) - : 'gc=missing'; + let gdprApplies = false; + let consentString = ''; + let uspConsentString = ''; + + if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { + gdprApplies = gdprConsent.gdprApplies; + } + let gdpr = gdprApplies ? 1 : 0; + + if (gdprApplies && gdprConsent.consentString) { + consentString = encodeURIComponent(gdprConsent.consentString); + } + + if (uspConsent) { + uspConsentString = encodeURIComponent(uspConsent); + } + + const macroValues = { + gdpr: gdpr, + consent: consentString, + uspConsent: uspConsentString + }; + serverResponses.forEach(resp => { if (resp.body) { const bidResponse = resp.body; if (bidResponse.ext && Array.isArray(bidResponse.ext['utrk'])) { - bidResponse.ext['utrk'].forEach(pixel => { - const url = - pixel.url + - (pixel.url.indexOf('?') > 0 ? '&' + suffix : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); + bidResponse.ext['utrk'] + .forEach(pixel => { + const url = replaceMacros(pixel.url, macroValues); + syncs.push({type: pixel.type, url}); + }); } + if (Array.isArray(bidResponse.seatbid)) { bidResponse.seatbid.forEach(seatBid => { if (Array.isArray(seatBid.bid)) { seatBid.bid.forEach(bid => { if (bid.ext && Array.isArray(bid.ext['utrk'])) { - bid.ext['utrk'].forEach(pixel => { - const url = - pixel.url + - (pixel.url.indexOf('?') > 0 - ? '&' + suffix - : '?' + suffix); - return syncs.push({type: pixel.type, url}); - }); + bid.ext['utrk'] + .forEach(pixel => { + const url = replaceMacros(pixel.url, macroValues); + syncs.push({type: pixel.type, url}); + }); } }); } @@ -271,18 +300,16 @@ export const spec = { } } }); + return syncs; } }; function newRenderer(bidRequest, bid, rendererOptions = {}) { const renderer = Renderer.install({ - url: - (bidRequest.params && bidRequest.params.rendererUrl) || - (bid.ext && bid.ext.renderer_url) || - 'https://s.wlplayer.com/video/latest/renderer.js', + url: (bidRequest.params && bidRequest.params.rendererUrl) || (bid.ext && bid.ext.renderer_url) || 'https://s.gamoshi.io/video/latest/renderer.js', config: rendererOptions, - loaded: false + loaded: false, }); try { renderer.setRender(renderOutstream); @@ -302,10 +329,9 @@ function renderOutstream(bid) { width: bid.width, height: bid.height, events: { - ALL_ADS_COMPLETED: () => - window.setTimeout(() => { - window['GamoshiPlayer'].removeAd(unitId); - }, 300) + ALL_ADS_COMPLETED: () => window.setTimeout(() => { + window['GamoshiPlayer'].removeAd(unitId); + }, 300) }, vastUrl: bid.vastUrl, vastXml: bid.vastXml @@ -313,4 +339,41 @@ function renderOutstream(bid) { }); } +function addExternalUserId(eids, value, source, rtiPartner) { + if (isStr(value)) { + eids.push({ + source, + uids: [{ + id: value, + ext: { + rtiPartner + } + }] + }); + } +} + +function replaceMacros(url, macros) { + return url + .replace('[GDPR]', macros.gdpr) + .replace('[CONSENT]', macros.consent) + .replace('[US_PRIVACY]', macros.uspConsent); +} + +function getGdprConsent(bidderRequest) { + const gdprConsent = bidderRequest.gdprConsent; + + if (gdprConsent && gdprConsent.consentString && gdprConsent.gdprApplies) { + return { + consent_string: gdprConsent.consentString, + consent_required: gdprConsent.gdprApplies + }; + } + + return { + consent_required: false, + consent_string: '', + }; +} + registerBidder(spec); diff --git a/modules/cleanmedianetBidAdapter.md b/modules/cleanmedianetBidAdapter.md index f2bc8feb0f0..ee4e049e8d6 100644 --- a/modules/cleanmedianetBidAdapter.md +++ b/modules/cleanmedianetBidAdapter.md @@ -1,45 +1,49 @@ # Overview ``` -Module Name: Clean Media Net Adapter +Module Name: CleanMedia Bid Adapter Module Type: Bidder Adapter -Maintainer: dev@cleanmedia.net +Maintainer: dev@CleanMedia.net ``` # Description -Connects to Clean Media Net's Programmatic advertising platform as a service. +Connects to CleanMedia's Programmatic advertising platform as a service. -Clean Media bid adapter supports Banner & Video (Instream and Outstream). -The *only* required parameter (in the `params` section) is the `supplyPartnerId` parameter. +CleanMedia bid adapter supports Banner & Outstream Video. The *only* required parameter (in the `params` section) is the `supplyPartnerId` parameter. # Test Parameters ``` var adUnits = [ - // Banner adUnit + + // Banner adUnit { code: 'banner-div', sizes: [[300, 250]], bids: [{ bidder: 'cleanmedianet', params: { - // ID of the supply partner you created in the Clean Media Net dashboard + + // ID of the supply partner you created in the CleanMedia dashboard supplyPartnerId: '1253', - // OPTIONAL: custom bid floor + + // OPTIONAL: custom bid floor bidfloor: 0.01, - // OPTIONAL: if you know the ad position on the page, specify it here + + // OPTIONAL: if you know the ad position on the page, specify it here // (this corresponds to "Ad Position" in OpenRTB 2.3, section 5.4) //adpos: 1, - // OPTIONAL: whether this is an interstitial placement (0 or 1) + + // OPTIONAL: whether this is an interstitial placement (0 or 1) // (see "instl" property in "Imp" object in the OpenRTB 2.3, section 3.2.2) //instl: 0 } }] }, - // Video outstream adUnit + + // Video outstream adUnit { code: 'video-outstream', - sizes: [[300, 250]], mediaTypes: { video: { context: 'outstream', @@ -47,20 +51,62 @@ var adUnits = [ } }, bids: [ { - bidder: 'cleanmedianet', + bidder: 'CleanMedia', params: { - // ID of the supply partner you created in the dashboard + + // ID of the supply partner you created in the dashboard supplyPartnerId: '1254', - // OPTIONAL: custom bid floor + + // OPTIONAL: custom bid floor bidfloor: 0.01, - // OPTIONAL: if you know the ad position on the page, specify it here + + // OPTIONAL: if you know the ad position on the page, specify it here // (this corresponds to "Ad Position" in OpenRTB 2.3, section 5.4) //adpos: 1, - // OPTIONAL: whether this is an interstitial placement (0 or 1) + + // OPTIONAL: whether this is an interstitial placement (0 or 1) // (see "instl" property in "Imp" object in the OpenRTB 2.3, section 3.2.2) //instl: 0 } }] - } + }, + + // Multi-Format adUnit + { + code: 'banner-div', + mediaTypes: { + video: { + context: 'outstream', + playerSize: [300, 250] + }, + banner: { + sizes: [[300, 250]] + } + }, + bids: [{ + bidder: 'CleanMedia', + params: { + + // ID of the supply partner you created in the CleanMedia dashboard + supplyPartnerId: '1253', + + // OPTIONAL: custom bid floor + bidfloor: 0.01, + + // OPTIONAL: if you know the ad position on the page, specify it here + // (this corresponds to "Ad Position" in OpenRTB 2.3, section 5.4) + //adpos: 1, + + // OPTIONAL: whether this is an interstitial placement (0 or 1) + // (see "instl" property in "Imp" object in the OpenRTB 2.3, section 3.2.2) + //instl: 0, + + // OPTIONAL: enable enforcement bids of a specific media type (video, banner) + // in this ad placement + // query: 'key1=value1&k2=value2', + // favoredMediaType: 'video', + } + }] + }, ]; ``` diff --git a/modules/clickforceBidAdapter.js b/modules/clickforceBidAdapter.js index eceb4934b04..92bc9b1bad2 100644 --- a/modules/clickforceBidAdapter.js +++ b/modules/clickforceBidAdapter.js @@ -1,6 +1,7 @@ import { _each } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'clickforce'; const ENDPOINT_URL = 'https://ad.holmesmind.com/adserver/prebid.json?cb=' + new Date().getTime() + '&hb=1&ver=1.21'; @@ -24,6 +25,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const bidParams = []; _each(validBidRequests, function(bid) { bidParams.push({ diff --git a/modules/clicktripzBidAdapter.md b/modules/clicktripzBidAdapter.md deleted file mode 100644 index 1de1e26f37a..00000000000 --- a/modules/clicktripzBidAdapter.md +++ /dev/null @@ -1,35 +0,0 @@ -# Overview - -``` -Module Name: Clicktripz Bidder Adapter -Module Type: Bidder Adapter -Maintainer: integration-support@clicktripz.com -``` - -# Description -Our module makes it easy to integrate Clicktripz demand sources into your website. - -Supported Ad Fortmats: -* Banner - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [ - { - bidder: "clicktripz", - params: { - placementId: '4312c63f', - siteId: 'prebid', - } - } - ] - } - ]; diff --git a/modules/codefuelBidAdapter.js b/modules/codefuelBidAdapter.js index b9da86ac24e..2548b20189b 100644 --- a/modules/codefuelBidAdapter.js +++ b/modules/codefuelBidAdapter.js @@ -1,6 +1,7 @@ -import { deepAccess, isArray } from '../src/utils.js'; +import {deepAccess, isArray} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; +import {BANNER} from '../src/mediaTypes.js'; + const BIDDER_CODE = 'codefuel'; const CURRENCY = 'USD'; @@ -27,8 +28,8 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { - const page = bidderRequest.refererInfo.referer; - const domain = getDomainFromURL(page) + const page = bidderRequest.refererInfo.page; + const domain = bidderRequest.refererInfo.domain; const ua = navigator.userAgent; const devicetype = getDeviceType() const publisher = setOnAny(validBidRequests, 'params.publisher'); @@ -57,7 +58,7 @@ export const spec = { }); const request = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, site: { page, domain, publisher }, device: { ua, devicetype }, source: { fd: 1 }, @@ -128,12 +129,6 @@ export const spec = { } registerBidder(spec); -function getDomainFromURL(url) { - let anchor = document.createElement('a'); - anchor.href = url; - return anchor.hostname; -} - function getDeviceType() { if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase()))) { return 5; // 'tablet' diff --git a/modules/cointrafficBidAdapter.js b/modules/cointrafficBidAdapter.js index e3d3c65a4f0..380e1f5fc77 100644 --- a/modules/cointrafficBidAdapter.js +++ b/modules/cointrafficBidAdapter.js @@ -4,19 +4,20 @@ import { BANNER } from '../src/mediaTypes.js' import { config } from '../src/config.js' const BIDDER_CODE = 'cointraffic'; -const ENDPOINT_URL = 'https://appspb.cointraffic.io/pb/tmp'; +const ENDPOINT_URL = 'https://apps-pbd.ctraffic.io/pb/tmp'; const DEFAULT_CURRENCY = 'EUR'; const ALLOWED_CURRENCIES = [ 'EUR', 'USD', 'JPY', 'BGN', 'CZK', 'DKK', 'GBP', 'HUF', 'PLN', 'RON', 'SEK', 'CHF', 'ISK', 'NOK', 'HRK', 'RUB', 'TRY', 'AUD', 'BRL', 'CAD', 'CNY', 'HKD', 'IDR', 'ILS', 'INR', 'KRW', 'MXN', 'MYR', 'NZD', 'PHP', 'SGD', 'THB', 'ZAR', ]; +/** @type {BidderSpec} */ export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER], /** - * Determines whether or not the given bid request is valid. + * Determines whether the given bid request is valid. * * @param {BidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. @@ -50,7 +51,7 @@ export const spec = { currency: currency, sizes: sizes, bidId: bidRequest.bidId, - referer: bidderRequest.refererInfo.referer, + referer: bidderRequest.refererInfo.ref, }; return { diff --git a/modules/coinzillaBidAdapter.js b/modules/coinzillaBidAdapter.js index cd087daa8cb..c7d8fa5797c 100644 --- a/modules/coinzillaBidAdapter.js +++ b/modules/coinzillaBidAdapter.js @@ -1,5 +1,4 @@ import { parseSizesInput } from '../src/utils.js'; -import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'coinzilla'; @@ -39,7 +38,8 @@ export const spec = { width: width, height: height, bidId: bidRequest.bidId, - referer: bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + referer: bidderRequest.refererInfo.page, }; return { method: 'POST', @@ -77,7 +77,7 @@ export const spec = { dealId: dealId, currency: currency, netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), + ttl: response.timeout, referrer: referrer, ad: response.ad, mediaType: response.mediaType, diff --git a/modules/collectcentBidAdapter.md b/modules/collectcentBidAdapter.md deleted file mode 100644 index 938bdc420cd..00000000000 --- a/modules/collectcentBidAdapter.md +++ /dev/null @@ -1,27 +0,0 @@ -# Overview - -``` -Module Name: Collectcent SSP Bidder Adapter -Module Type: Bidder Adapter -Maintainer: dev.collectcent@gmail.com -``` - -# Description - -Module that connects to Collectcent SSP demand sources - -# Test Parameters -``` - var adUnits = [{ - code: 'placementCode', - sizes: [[300, 250]], - bids: [{ - bidder: 'collectcent', - params: { - placementId: 0, - traffic: 'banner' - } - }] - } - ]; -``` diff --git a/modules/colombiaBidAdapter.md b/modules/colombiaBidAdapter.md deleted file mode 100644 index c754e49771d..00000000000 --- a/modules/colombiaBidAdapter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Overview - -``` -Module Name: COLOMBIA Bidder Adapter -Module Type: Bidder Adapter -Maintainer: colombiaonline@timesinteret.in -``` - -# Description - -Connect to COLOMBIA for bids. - -COLOMBIA adapter requires setup and approval from the COLOMBIA team. Please reach out to your account team or colombiaonline@timesinteret.in for more information. - -# Test Parameters -``` - var adUnits = [{ - code: 'test-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250],[728,90],[320,50]] - } - }, - bids: [{ - bidder: 'colombia', - params: { - placementId: '307466' - } - }] - }]; -``` diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js index c1b6e31ff2e..b1ee8875422 100644 --- a/modules/colossussspBidAdapter.js +++ b/modules/colossussspBidAdapter.js @@ -3,6 +3,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { ajax } from '../src/ajax.js'; import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'colossusssp'; const G_URL = 'https://colossusssp.com/?c=o&m=multi'; @@ -61,6 +62,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let deviceWidth = 0; let deviceHeight = 0; let winLocation; @@ -75,7 +79,7 @@ export const spec = { winLocation = window.location; } - const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.referer; + const refferUrl = bidderRequest.refererInfo?.page; let refferLocation; try { refferLocation = refferUrl && new URL(refferUrl); @@ -83,6 +87,12 @@ export const spec = { logMessage(e); } + const firstPartyData = bidderRequest.ortb2 || {}; + const userObj = firstPartyData.user; + const siteObj = firstPartyData.site; + const appObj = firstPartyData.app; + + // TODO: does the fallback to window.location make sense? const location = refferLocation || winLocation; let placements = []; let request = { @@ -92,7 +102,10 @@ export const spec = { secure: location.protocol === 'https:' ? 1 : 0, host: location.host, page: location.pathname, - placements: placements, + userObj, + siteObj, + appObj, + placements: placements }; if (bidderRequest) { @@ -100,36 +113,32 @@ export const spec = { request.ccpa = bidderRequest.uspConsent; } if (bidderRequest.gdprConsent) { - request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL' - request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0 + request.gdpr_consent = bidderRequest.gdprConsent.consentString || 'ALL'; + request.gdpr_require = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + + // Add GPP consent + if (bidderRequest.gppConsent) { + request.gpp = bidderRequest.gppConsent.gppString; + request.gpp_sid = bidderRequest.gppConsent.applicableSections; + } else if (bidderRequest.ortb2?.regs?.gpp) { + request.gpp = bidderRequest.ortb2.regs.gpp; + request.gpp_sid = bidderRequest.ortb2.regs.gpp_sid; } } for (let i = 0; i < validBidRequests.length; i++) { let bid = validBidRequests[i]; - let traff = bid.params.traffic || BANNER + const { mediaTypes } = bid; let placement = { placementId: bid.params.placement_id, groupId: bid.params.group_id, bidId: bid.bidId, - sizes: bid.mediaTypes[traff].sizes, - traffic: traff, + tid: bid.ortb2Imp?.ext?.tid, eids: [], floor: {} }; - if (typeof bid.getFloor === 'function') { - let tmpFloor = {}; - for (let size of placement.sizes) { - tmpFloor = bid.getFloor({ - currency: 'USD', - mediaType: traff, - size: size - }); - if (tmpFloor) { - placement.floor[`${size[0]}x${size[1]}`] = tmpFloor.floor; - } - } - } + if (bid.schain) { placement.schain = bid.schain; } @@ -146,23 +155,47 @@ export const spec = { rtiPartner: 'TDID' }); } - if (traff === VIDEO) { - placement.playerSize = bid.mediaTypes[VIDEO].playerSize; - placement.minduration = bid.mediaTypes[VIDEO].minduration; - placement.maxduration = bid.mediaTypes[VIDEO].maxduration; - placement.mimes = bid.mediaTypes[VIDEO].mimes; - placement.protocols = bid.mediaTypes[VIDEO].protocols; - placement.startdelay = bid.mediaTypes[VIDEO].startdelay; - placement.placement = bid.mediaTypes[VIDEO].placement; - placement.skip = bid.mediaTypes[VIDEO].skip; - placement.skipafter = bid.mediaTypes[VIDEO].skipafter; - placement.minbitrate = bid.mediaTypes[VIDEO].minbitrate; - placement.maxbitrate = bid.mediaTypes[VIDEO].maxbitrate; - placement.delivery = bid.mediaTypes[VIDEO].delivery; - placement.playbackmethod = bid.mediaTypes[VIDEO].playbackmethod; - placement.api = bid.mediaTypes[VIDEO].api; - placement.linearity = bid.mediaTypes[VIDEO].linearity; + + if (mediaTypes && mediaTypes[BANNER]) { + placement.traffic = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.traffic = VIDEO; + placement.sizes = mediaTypes[VIDEO].playerSize; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.traffic = NATIVE; + placement.native = mediaTypes[NATIVE]; + } + + if (typeof bid.getFloor === 'function') { + let tmpFloor = {}; + for (let size of placement.sizes) { + tmpFloor = bid.getFloor({ + currency: 'USD', + mediaType: placement.traffic, + size: size + }); + if (tmpFloor) { + placement.floor[`${size[0]}x${size[1]}`] = tmpFloor.floor; + } + } } + placements.push(placement); } return { @@ -198,7 +231,7 @@ export const spec = { }, getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - let syncType = syncOptions.iframeEnabled ? 'html' : 'hms.gif'; + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; let syncUrl = G_URL_SYNC + `/${syncType}?pbjs=1`; if (gdprConsent && gdprConsent.consentString) { if (typeof gdprConsent.gdprApplies === 'boolean') { diff --git a/modules/colossussspBidAdapter.md b/modules/colossussspBidAdapter.md index 4187dfbf36e..45af89580c1 100644 --- a/modules/colossussspBidAdapter.md +++ b/modules/colossussspBidAdapter.md @@ -22,22 +22,45 @@ Module that connects to Colossus SSP demand sources bids: [{ bidder: 'colossusssp', params: { - placement_id: 0, - traffic: 'banner' + placement_id: 0 } }] }, { code: 'placementid_1', mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]] + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, } }, bids: [{ bidder: 'colossusssp', params: { - group_id: 0, - traffic: 'banner' + group_id: 0 + } + }] + }, { + code: 'placementid_2', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [{ + bidder: 'colossusssp', + params: { + placement_id: 0, } }] }]; diff --git a/modules/compassBidAdapter.js b/modules/compassBidAdapter.js index 77f918276bc..addcdfebb27 100644 --- a/modules/compassBidAdapter.js +++ b/modules/compassBidAdapter.js @@ -1,4 +1,5 @@ import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; @@ -112,6 +113,9 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let deviceWidth = 0; let deviceHeight = 0; @@ -126,14 +130,14 @@ export const spec = { winLocation = window.location; } - const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.referer; + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; let refferLocation; try { refferLocation = refferUrl && new URL(refferUrl); } catch (e) { logMessage(e); } - + // TODO: does the fallback make sense here? let location = refferLocation || winLocation; const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; const host = location.host; @@ -151,7 +155,7 @@ export const spec = { coppa: config.getConfig('coppa') === true ? 1 : 0, ccpa: bidderRequest.uspConsent || undefined, gdpr: bidderRequest.gdprConsent || undefined, - tmax: config.getConfig('bidderTimeout') + tmax: bidderRequest.timeout }; const len = validBidRequests.length; diff --git a/modules/conceptxBidAdapter.js b/modules/conceptxBidAdapter.js new file mode 100644 index 00000000000..127b049bc99 --- /dev/null +++ b/modules/conceptxBidAdapter.js @@ -0,0 +1,73 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +// import { logError, logInfo, logWarn, parseUrl } from '../src/utils.js'; + +const BIDDER_CODE = 'conceptx'; +let ENDPOINT_URL = 'https://conceptx.cncpt-central.com/openrtb'; +// const LOG_PREFIX = 'ConceptX: '; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + isBidRequestValid: function (bid) { + return !!(bid.bidId); + }, + + buildRequests: function (validBidRequests, bidderRequest) { + // logWarn(LOG_PREFIX + 'all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)'); + const requests = []; + + if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { + ENDPOINT_URL += '?gdpr_applies=' + bidderRequest.gdprConsent.gdprApplies; + ENDPOINT_URL += '&consentString=' + bidderRequest.gdprConsent.consentString; + } + for (var i = 0; i < validBidRequests.length; i++) { + const requestParent = { adUnits: [], meta: {} }; + const bid = validBidRequests[i] + const { adUnitCode, auctionId, bidId, bidder, bidderRequestId, ortb2 } = bid + requestParent.meta = { adUnitCode, auctionId, bidId, bidder, bidderRequestId, ortb2 } + + const { site, adunit } = bid.params + const adUnit = { site, adunit, targetId: bid.bidId } + if (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) adUnit.dimensions = bid.mediaTypes.banner.sizes + requestParent.adUnits.push(adUnit); + requests.push({ + method: 'POST', + url: ENDPOINT_URL, + options: { + withCredentials: false, + }, + data: JSON.stringify(requestParent), + }); + } + + return requests; + }, + + interpretResponse: function (serverResponse, bidRequest) { + const bidResponses = []; + const bidResponsesFromServer = serverResponse.body.bidResponses; + if (Array.isArray(bidResponsesFromServer) && bidResponsesFromServer.length === 0) { + return bidResponses + } + const firstBid = bidResponsesFromServer[0] + const firstSeat = firstBid.ads[0] + const bidResponse = { + requestId: firstSeat.requestId, + cpm: firstSeat.cpm, + width: firstSeat.width, + height: firstSeat.height, + creativeId: firstSeat.creativeId, + dealId: firstSeat.dealId, + currency: firstSeat.currency, + netRevenue: true, + ttl: firstSeat.ttl, + referrer: firstSeat.referrer, + ad: firstSeat.html + }; + bidResponses.push(bidResponse); + return bidResponses; + }, + +} +registerBidder(spec); diff --git a/modules/conceptxBidAdapter.md b/modules/conceptxBidAdapter.md new file mode 100644 index 00000000000..1464c04025a --- /dev/null +++ b/modules/conceptxBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: ConceptX Bidder Adapter +Module Type: Bidder Adapter +Maintainer: info@concept.dk +``` + +# Description + +ConceptX Bidder Adapter for Prebid.js. +Only Banner format is supported. + +# Test Parameters +``` + var adUnits = [ + { + code: "test-div", + mediaTypes: { + banner: { + sizes: [[980, 180]] + } + }, + bids: [ + { + bidder: "conceptx", + params: { + site: "example", + adunit: "some-id-3", + } + }, + ] + }, + + ]; +``` diff --git a/modules/concertAnalyticsAdapter.js b/modules/concertAnalyticsAdapter.js index cd52a2ffabf..210d1898338 100644 --- a/modules/concertAnalyticsAdapter.js +++ b/modules/concertAnalyticsAdapter.js @@ -1,6 +1,6 @@ import { logMessage } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; diff --git a/modules/concertBidAdapter.js b/modules/concertBidAdapter.js index 99e2492fb94..7042c895bfb 100644 --- a/modules/concertBidAdapter.js +++ b/modules/concertBidAdapter.js @@ -1,10 +1,10 @@ -import { logWarn, logMessage, debugTurnedOn, generateUUID } from '../src/utils.js'; +import { logWarn, logMessage, debugTurnedOn, generateUUID, deepAccess } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { getStorageManager } from '../src/storageManager.js' +import { getStorageManager } from '../src/storageManager.js'; +import { hasPurpose1Consent } from '../src/utils/gpdr.js'; const BIDDER_CODE = 'concert'; const CONCERT_ENDPOINT = 'https://bids.concert.io'; -const USER_SYNC_URL = 'https://cdn.concert.io/lib/bids/sync.html'; export const spec = { code: BIDDER_CODE, @@ -33,43 +33,63 @@ export const spec = { buildRequests: function(validBidRequests, bidderRequest) { logMessage(validBidRequests); logMessage(bidderRequest); + + const eids = []; + let payload = { meta: { prebidVersion: '$prebid.version$', - pageUrl: bidderRequest.refererInfo.referer, + pageUrl: bidderRequest.refererInfo.page, screen: [window.screen.width, window.screen.height].join('x'), + browserLanguage: window.navigator.language, debug: debugTurnedOn(), - uid: getUid(bidderRequest), + uid: getUid(bidderRequest, validBidRequests), optedOut: hasOptedOutOfPersonalization(), - adapterVersion: '1.1.1', + adapterVersion: '1.2.0', uspConsent: bidderRequest.uspConsent, - gdprConsent: bidderRequest.gdprConsent + gdprConsent: bidderRequest.gdprConsent, + gppConsent: bidderRequest.gppConsent, + } + }; + + if (!payload.meta.gppConsent && bidderRequest.ortb2?.regs?.gpp) { + payload.meta.gppConsent = { + gppString: bidderRequest.ortb2.regs.gpp, + applicableSections: bidderRequest.ortb2.regs.gpp_sid } } payload.slots = validBidRequests.map(bidRequest => { + collectEid(eids, bidRequest); + const adUnitElement = document.getElementById(bidRequest.adUnitCode) + const coordinates = getOffset(adUnitElement) + let slot = { name: bidRequest.adUnitCode, bidId: bidRequest.bidId, - transactionId: bidRequest.transactionId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, sizes: bidRequest.params.sizes || bidRequest.sizes, partnerId: bidRequest.params.partnerId, slotType: bidRequest.params.slotType, adSlot: bidRequest.params.slot || bidRequest.adUnitCode, placementId: bidRequest.params.placementId || '', - site: bidRequest.params.site || bidderRequest.refererInfo.referer + site: bidRequest.params.site || bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.ref, + offsetCoordinates: { x: coordinates?.left, y: coordinates?.top } } return slot; }); + payload.meta.eids = eids.filter(Boolean); + logMessage(payload); return { method: 'POST', url: `${CONCERT_ENDPOINT}/bids/prebid`, data: JSON.stringify(payload) - } + }; }, /** * Unpack the response from the server into a list of bids. @@ -101,7 +121,7 @@ export const spec = { creativeId: bid.creativeId, netRevenue: bid.netRevenue, currency: bid.currency - } + }; }); if (debugTurnedOn() && serverBody.debug) { @@ -112,38 +132,6 @@ export const spec = { return bidResponses; }, - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @param {gdprConsent} object GDPR consent object. - * @param {uspConsent} string US Privacy String. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { - const syncs = [] - if (syncOptions.iframeEnabled && !hasOptedOutOfPersonalization()) { - let params = []; - - if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { - params.push(`gdpr_applies=${gdprConsent.gdprApplies ? '1' : '0'}`); - } - if (gdprConsent && (typeof gdprConsent.consentString === 'string')) { - params.push(`gdpr_consent=${gdprConsent.consentString}`); - } - if (uspConsent && (typeof uspConsent === 'string')) { - params.push(`usp_consent=${uspConsent}`); - } - - syncs.push({ - type: 'iframe', - url: USER_SYNC_URL + (params.length > 0 ? `?${params.join('&')}` : '') - }); - } - return syncs; - }, - /** * Register bidder specific code, which will execute if bidder timed out after an auction * @param {data} Containing timeout specific data @@ -166,20 +154,41 @@ export const spec = { registerBidder(spec); -const storage = getStorageManager({bidderCode: BIDDER_CODE}); +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); /** * Check or generate a UID for the current user. */ -function getUid(bidderRequest) { +function getUid(bidderRequest, validBidRequests) { if (hasOptedOutOfPersonalization() || !consentAllowsPpid(bidderRequest)) { return false; } - const CONCERT_UID_KEY = 'c_uid'; + /** + * check for shareId or pubCommonId before generating a new one + * sharedId: @see https://docs.prebid.org/dev-docs/modules/userId.html + * pubCid (no longer supported): @see https://docs.prebid.org/dev-docs/modules/pubCommonId.html#adapter-integration + */ + const sharedId = + deepAccess(validBidRequests[0], 'userId.sharedid.id') || + deepAccess(validBidRequests[0], 'userId.pubcid') + const pubCid = deepAccess(validBidRequests[0], 'crumbs.pubcid'); + + if (sharedId) return sharedId; + if (pubCid) return pubCid; + + const LEGACY_CONCERT_UID_KEY = 'c_uid'; + const CONCERT_UID_KEY = 'vmconcert_uid'; + const legacyUid = storage.getDataFromLocalStorage(LEGACY_CONCERT_UID_KEY); let uid = storage.getDataFromLocalStorage(CONCERT_UID_KEY); + if (legacyUid) { + uid = legacyUid; + storage.setDataInLocalStorage(CONCERT_UID_KEY, uid); + storage.removeDataFromLocalStorage(LEGACY_CONCERT_UID_KEY); + } + if (!uid) { uid = generateUUID(); storage.setDataInLocalStorage(CONCERT_UID_KEY, uid); @@ -203,9 +212,54 @@ function hasOptedOutOfPersonalization() { * @param {BidderRequest} bidderRequest Object which contains any data consent signals */ function consentAllowsPpid(bidderRequest) { - /* NOTE: We cannot easily test GDPR consent, without the - * `consent-string` npm module; so will have to rely on that - * happening on the bid-server. */ - return !(bidderRequest.uspConsent === 'string' && - bidderRequest.uspConsent.toUpperCase().substring(0, 2) === '1YY') + let uspConsentAllows = true; + + // if a us privacy string was provided, but they explicitly opted out + if ( + typeof bidderRequest?.uspConsent === 'string' && + bidderRequest?.uspConsent[0] === '1' && + bidderRequest?.uspConsent[2].toUpperCase() === 'Y' // user has opted-out + ) { + uspConsentAllows = false; + } + + /* + * True if the gdprConsent is null-y; or GDPR does not apply; or if purpose 1 consent was given. + * Much more nuanced GDPR requirements are tested on the bid server using the @iabtcf/core npm module; + */ + const gdprConsentAllows = hasPurpose1Consent(bidderRequest?.gdprConsent); + + return (uspConsentAllows && gdprConsentAllows); +} + +function collectEid(eids, bid) { + if (bid.userId) { + const eid = getUserId(bid.userId.uid2 && bid.userId.uid2.id, 'uidapi.com', undefined, 3) + eids.push(eid) + } +} + +function getUserId(id, source, uidExt, atype) { + if (id) { + const uid = { id, atype }; + + if (uidExt) { + uid.ext = uidExt; + } + + return { + source, + uids: [ uid ] + }; + } +} + +function getOffset(el) { + if (el) { + const rect = el.getBoundingClientRect(); + return { + left: rect.left + window.scrollX, + top: rect.top + window.scrollY + }; + } } diff --git a/modules/confiantRtdProvider.js b/modules/confiantRtdProvider.js new file mode 100644 index 00000000000..6b1066a20f1 --- /dev/null +++ b/modules/confiantRtdProvider.js @@ -0,0 +1,131 @@ +/** + * This module provides comprehensive detection of security, quality, and privacy threats by Confiant Inc, + * the industry leader in real-time detecting and blocking of bad ads + * + * The {@link module:modules/realTimeData} module is required + * The module will inject a Confiant Inc. script into the page to monitor ad impressions + * @module modules/confiantRtdProvider + * @requires module:modules/realTimeData + */ + +import { submodule } from '../src/hook.js'; +import { logError, generateUUID } from '../src/utils.js'; +import { loadExternalScript } from '../src/adloader.js'; +import * as events from '../src/events.js'; +import CONSTANTS from '../src/constants.json'; + +/** + * Injects the Confiant Inc. configuration script into the page, based on proprtyId provided + * @param {string} propertyId + */ +function injectConfigScript(propertyId) { + const scriptSrc = `https://cdn.confiant-integrations.net/${propertyId}/gpt_and_prebid/config.js`; + + loadExternalScript(scriptSrc, 'confiant', () => {}); +} + +/** + * Set up page with Confiant integration + * @param {Object} config + */ +function setupPage(config) { + const propertyId = config?.params?.propertyId; + if (!propertyId) { + logError('Confiant pbjs module: no propertyId provided'); + return false; + } + + const confiant = window.confiant || Object.create(null); + confiant[propertyId] = confiant[propertyId] || Object.create(null); + confiant[propertyId].clientSettings = confiant[propertyId].clientSettings || Object.create(null); + confiant[propertyId].clientSettings.isMGBL = true; + confiant[propertyId].clientSettings.prebidExcludeBidders = config?.params?.prebidExcludeBidders; + confiant[propertyId].clientSettings.prebidNameSpace = config?.params?.prebidNameSpace; + + if (config?.params?.shouldEmitBillableEvent) { + if (window.frames['cnftComm']) { + subscribeToConfiantCommFrame(window, propertyId); + } else { + setUpMutationObserver(); + } + } + + injectConfigScript(propertyId); + return true; +} + +/** + * Subscribe to window's message events to report Billable events + * @param {Window} targetWindow window instance to subscribe to + */ +function subscribeToConfiantCommFrame(targetWindow, propertyId) { + targetWindow.addEventListener('message', getEventHandlerFunction(propertyId)); +} + +let mutationObserver; +/** + * Set up mutation observer to subscribe to Confiant's communication channel ASAP + */ +function setUpMutationObserver() { + mutationObserver = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + mutation.addedNodes.forEach((addedNode) => { + if (addedNode.nodeName === 'IFRAME' && addedNode.name === 'cnftComm' && !addedNode.pbjsModuleSubscribed) { + addedNode.pbjsModuleSubscribed = true; + mutationObserver.disconnect(); + mutationObserver = null; + const iframeWindow = addedNode.contentWindow; + subscribeToConfiantCommFrame(iframeWindow); + } + }); + }); + }); + mutationObserver.observe(document.head, { childList: true, subtree: true }); +} + +/** + * Emit billable event when Confiant integration reports that it has monitored an impression + */ +function getEventHandlerFunction(propertyId) { + return function reportBillableEvent(e) { + if (e.data.type.indexOf('cnft:reportBillableEvent:' + propertyId) > -1) { + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + auctionId: e.data.auctionId, + billingId: generateUUID(), + transactionId: e.data.transactionId, + type: 'impression', + vendor: 'confiant' + }); + } + } +} + +/** + * Confiant submodule registration + */ +function registerConfiantSubmodule() { + submodule('realTimeData', { + name: 'confiant', + init: (config) => { + try { + return setupPage(config); + } catch (err) { + logError(err.message); + if (mutationObserver) { + mutationObserver.disconnect(); + } + return false; + } + } + }); +} + +registerConfiantSubmodule(); + +export default { + injectConfigScript, + setupPage, + subscribeToConfiantCommFrame, + setUpMutationObserver, + registerConfiantSubmodule +}; diff --git a/modules/confiantRtdProvider.md b/modules/confiantRtdProvider.md new file mode 100644 index 00000000000..e92c0aabcba --- /dev/null +++ b/modules/confiantRtdProvider.md @@ -0,0 +1,45 @@ +# Overview + +``` +Module Name: Confiant Inc. Rtd provider +Module Type: Rtd Provider +Maintainer: +``` + +Confiant’s module provides comprehensive detection of security, quality, and privacy threats across your ad stack. +Confiant is the industry leader in real-time detecting and blocking of bad ads when it comes to protecting your users and brand reputation. + +To start using this module, please contact [Confiant](https://www.confiant.com/contact) to get an account and customer key. + + +# Integration + +1) Build Prebid bundle with Confiant module included: + + +``` +gulp build --modules=confiantRtdProvider,... +``` + +2) Include the resulting bundle on your page. + +# Configuration + +Configuration of Confiant module is plain simple: + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'confiant', + params: { + // so please get in touch with us so we could help you to set up the module with proper parameters + propertyId: '', // required, string param, obtained from Confiant Inc. + prebidExcludeBidders: '', // optional, comma separated list of bidders to exclude from Confiant's prebid.js integration + prebidNameSpace: '', // optional, string param, namespace for prebid.js integration + shouldEmitBillableEvent: false, // optional, boolean param, upon being set to true enables firing of the BillableEvent upon Confiant's impression scanning + } + }] + } +}); +``` diff --git a/modules/connatixBidAdapter.js b/modules/connatixBidAdapter.js new file mode 100644 index 00000000000..df56ad580bc --- /dev/null +++ b/modules/connatixBidAdapter.js @@ -0,0 +1,185 @@ +import { + registerBidder +} from '../src/adapters/bidderFactory.js'; + +import { + deepAccess, + isFn, + logError, + isArray, + formatQS +} from '../src/utils.js'; + +import { + BANNER, +} from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'connatix'; +const AD_URL = 'https://capi.connatix.com/rtb/hba'; +const DEFAULT_MAX_TTL = '3600'; +const DEFAULT_CURRENCY = 'USD'; + +/* + * Get the bid floor value from the bid object, either using the getFloor function or by accessing the 'params.bidfloor' property. + * If the bid floor cannot be determined, return 0 as a fallback value. + */ +export function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: DEFAULT_CURRENCY, + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + gvlid: 143, + supportedMediaTypes: [BANNER], + + /* + * Validate the bid request. + * If the request is valid, Connatix is trying to obtain at least one bid. + * Otherwise, the request to the Connatix server is not made + */ + isBidRequestValid: (bid = {}) => { + const bidId = deepAccess(bid, 'bidId'); + const mediaTypes = deepAccess(bid, 'mediaTypes', {}); + const params = deepAccess(bid, 'params', {}); + const bidder = deepAccess(bid, 'bidder'); + + const banner = deepAccess(mediaTypes, BANNER, {}); + + const hasBidId = Boolean(bidId); + const isValidBidder = (bidder === BIDDER_CODE); + const isValidSize = (Boolean(banner.sizes) && isArray(mediaTypes[BANNER].sizes) && mediaTypes[BANNER].sizes.length > 0); + const hasSizes = mediaTypes[BANNER] ? isValidSize : false; + const hasRequiredBidParams = Boolean(params.placementId); + + const isValid = isValidBidder && hasBidId && hasSizes && hasRequiredBidParams; + if (!isValid) { + logError(`Invalid bid request: isValidBidder: ${isValidBidder} hasBidId: ${hasBidId}, hasSizes: ${hasSizes}, hasRequiredBidParams: ${hasRequiredBidParams}`); + } + return isValid; + }, + + /* + * Build the request payload by processing valid bid requests and extracting the necessary information. + * Determine the host and page from the bidderRequest's refferUrl, and include ccpa and gdpr consents. + * Return an object containing the request method, url, and the constructed payload. + */ + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + const bidRequests = validBidRequests.map(bid => { + const { + bidId, + mediaTypes, + params, + sizes, + } = bid; + return { + bidId, + mediaTypes, + sizes, + placementId: params.placementId, + floor: getBidFloor(bid), + }; + }); + + const requestPayload = { + ortb2: bidderRequest.ortb2, + gdprConsent: bidderRequest.gdprConsent, + uspConsent: bidderRequest.uspConsent, + refererInfo: bidderRequest.refererInfo, + bidRequests, + }; + + return { + method: 'POST', + url: AD_URL, + data: requestPayload + }; + }, + + /* + * Interpret the server response and create an array of bid responses by extracting and formatting + * relevant information such as requestId, cpm, ttl, width, height, creativeId, referrer and ad + * Returns an array of bid responses by extracting and formatting the server response + */ + interpretResponse: (serverResponse) => { + const responseBody = serverResponse.body; + const bids = responseBody.Bids; + const playerId = responseBody.PlayerId; + const customerId = responseBody.CustomerId; + + if (!isArray(bids) || !playerId || !customerId) { + return []; + } + + return bids.map(bidResponse => ({ + requestId: bidResponse.RequestId, + cpm: bidResponse.Cpm, + ttl: bidResponse.Ttl || DEFAULT_MAX_TTL, + currency: 'USD', + mediaType: BANNER, + netRevenue: true, + width: bidResponse.Width, + height: bidResponse.Height, + creativeId: bidResponse.CreativeId, + referrer: bidResponse.Referrer, + ad: bidResponse.Ad, + })); + }, + + /* + * Determine the user sync type (either 'iframe' or 'image') based on syncOptions. + * Construct the sync URL by appending required query parameters such as gdpr, ccpa, and coppa consents. + * Return an array containing an object with the sync type and the constructed URL. + */ + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => { + if (!syncOptions.iframeEnabled) { + return []; + } + + if (!serverResponses || !serverResponses.length) { + return []; + } + + const params = {}; + + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params['gdpr'] = Number(gdprConsent.gdprApplies); + } else { + params['gdpr'] = 0; + } + + if (typeof gdprConsent.consentString === 'string') { + params['gdpr_consent'] = encodeURIComponent(gdprConsent.consentString); + } + } + + if (typeof uspConsent === 'string') { + params['us_privacy'] = encodeURIComponent(uspConsent); + } + + const syncUrl = serverResponses[0].body.UserSyncEndpoint; + const queryParams = Object.keys(params).length > 0 ? formatQS(params) : ''; + + const url = queryParams ? `${syncUrl}?${queryParams}` : syncUrl; + return [{ + type: 'iframe', + url + }]; + } +}; + +registerBidder(spec); diff --git a/modules/connatixBidAdapter.md b/modules/connatixBidAdapter.md new file mode 100644 index 00000000000..7ac04a64245 --- /dev/null +++ b/modules/connatixBidAdapter.md @@ -0,0 +1,37 @@ + +# Overview + +``` +Module Name: Connatix Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid_integration@connatix.com +``` + +# Description +Connects to Connatix demand source to fetch bids. +Please use ```connatix``` as the bidder code. + +# Test Parameters +``` +var adUnits = [ + { + code: '1', + mediaTypes: { + banner: { + sizes: [[640, 480], [320, 180]], + }, + }, + bids: [ + { + bidder: 'connatix', + params: { + placementId: 'e4984e88-9ff4-45a3-8b9d-33aabcad634e', // required + bidfloor: 2.5, // optional + }, + }, + // Add more bidders and their parameters as needed + ], + }, + // Define more ad units here if necessary +]; +``` \ No newline at end of file diff --git a/modules/connectIdSystem.js b/modules/connectIdSystem.js index 2da2eda4c77..e1c5b427264 100644 --- a/modules/connectIdSystem.js +++ b/modules/connectIdSystem.js @@ -7,16 +7,124 @@ import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js'; -import {formatQS, logError} from '../src/utils.js'; import {includes} from '../src/polyfill.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {formatQS, isPlainObject, logError, parseUrl} from '../src/utils.js'; +import {uspDataHandler, gppDataHandler} from '../src/adapterManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'connectId'; +const STORAGE_EXPIRY_DAYS = 365; +const STORAGE_DURATION = 60 * 60 * 24 * 1000 * STORAGE_EXPIRY_DAYS; +const ID_EXPIRY_DAYS = 14; +const VALID_ID_DURATION = 60 * 60 * 24 * 1000 * ID_EXPIRY_DAYS; +const PUID_EXPIRY_DAYS = 30; +const PUID_EXPIRY = 60 * 60 * 24 * 1000 * PUID_EXPIRY_DAYS; const VENDOR_ID = 25; const PLACEHOLDER = '__PIXEL_ID__'; const UPS_ENDPOINT = `https://ups.analytics.yahoo.com/ups/${PLACEHOLDER}/fed`; +const OVERRIDE_OPT_OUT_KEY = 'connectIdOptOut'; +const INPUT_PARAM_KEYS = ['pixelId', 'he', 'puid']; +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); -function isEUConsentRequired(consentData) { - return !!(consentData && consentData.gdpr && consentData.gdpr.gdprApplies); +/** + * @function + * @param {Object} obj + */ +function storeObject(obj) { + const expires = Date.now() + STORAGE_DURATION; + if (storage.cookiesAreEnabled()) { + setEtldPlusOneCookie(MODULE_NAME, JSON.stringify(obj), new Date(expires), getSiteHostname()); + } + if (storage.localStorageIsEnabled()) { + storage.setDataInLocalStorage(MODULE_NAME, JSON.stringify(obj)); + } +} + +/** + * Attempts to store a cookie on eTLD + 1 + * + * @function + * @param {String} key + * @param {String} value + * @param {Date} expirationDate + * @param {String} hostname + */ +function setEtldPlusOneCookie(key, value, expirationDate, hostname) { + const subDomains = hostname.split('.'); + for (let i = 0; i < subDomains.length; ++i) { + const domain = subDomains.slice(subDomains.length - i - 1, subDomains.length).join('.'); + try { + storage.setCookie(key, value, expirationDate.toUTCString(), null, '.' + domain); + const storedCookie = storage.getCookie(key); + if (storedCookie && storedCookie === value) { + break; + } + } catch (error) {} + } +} + +function getIdFromCookie() { + if (storage.cookiesAreEnabled()) { + try { + return JSON.parse(storage.getCookie(MODULE_NAME)); + } catch {} + } + return null; +} + +function getIdFromLocalStorage() { + if (storage.localStorageIsEnabled()) { + let storedIdData = storage.getDataFromLocalStorage(MODULE_NAME); + if (storedIdData) { + try { + storedIdData = JSON.parse(storedIdData); + } catch (e) { + logError(`${MODULE_NAME} module: error while reading the local storage data.`); + } + if (isPlainObject(storedIdData) && storedIdData.__expires && + storedIdData.__expires <= Date.now()) { + storage.removeDataFromLocalStorage(MODULE_NAME); + return null; + } + return storedIdData; + } + } + return null; +} + +function syncLocalStorageToCookie() { + if (!storage.cookiesAreEnabled()) { + return; + } + const value = getIdFromLocalStorage(); + const newCookieExpireTime = Date.now() + STORAGE_DURATION; + setEtldPlusOneCookie(MODULE_NAME, JSON.stringify(value), new Date(newCookieExpireTime), getSiteHostname()); +} + +function isStale(storedIdData) { + if (isPlainObject(storedIdData) && storedIdData.lastSynced && + (storedIdData.lastSynced + VALID_ID_DURATION) <= Date.now()) { + return true; + } + return false; +} + +function getStoredId() { + let storedId = getIdFromCookie(); + if (!storedId) { + storedId = getIdFromLocalStorage(); + if (storedId && !isStale(storedId)) { + syncLocalStorageToCookie(); + } + } + return storedId; +} + +function getSiteHostname() { + const pageInfo = parseUrl(getRefererInfo().page); + return pageInfo.hostname; } /** @type {Submodule} */ @@ -36,8 +144,11 @@ export const connectIdSubmodule = { * @returns {{connectId: string} | undefined} */ decode(value) { - return (typeof value === 'object' && value.connectid) - ? {connectId: value.connectid} : undefined; + if (connectIdSubmodule.userHasOptedOut()) { + return undefined; + } + return (isPlainObject(value) && (value.connectId || value.connectid)) + ? {connectId: value.connectId || value.connectid} : undefined; }, /** * Gets the Yahoo ConnectID @@ -47,23 +158,71 @@ export const connectIdSubmodule = { * @returns {IdResponse|undefined} */ getId(config, consentData) { + if (connectIdSubmodule.userHasOptedOut()) { + return; + } const params = config.params || {}; - if (!params || typeof params.he !== 'string' || - (typeof params.pixelId === 'undefined' && typeof params.endpoint === 'undefined')) { - logError('The connectId submodule requires the \'he\' and \'pixelId\' parameters to be defined.'); + if (!params || + (typeof params.pixelId === 'undefined' && typeof params.endpoint === 'undefined')) { + logError(`${MODULE_NAME} module: configuration requires the 'pixelId'.`); return; } + const storedId = getStoredId(); + + let shouldResync = isStale(storedId); + + if (storedId) { + if (isPlainObject(storedId) && storedId.puid && storedId.lastUsed && !params.puid && + (storedId.lastUsed + PUID_EXPIRY) <= Date.now()) { + delete storedId.puid; + shouldResync = true; + } + if ((params.he && params.he !== storedId.he) || + (params.puid && params.puid !== storedId.puid)) { + shouldResync = true; + } + if (!shouldResync) { + storedId.lastUsed = Date.now(); + storeObject(storedId); + return {id: storedId}; + } + } + + const uspString = uspDataHandler.getConsentData() || ''; const data = { + v: '1', '1p': includes([1, '1', true], params['1p']) ? '1' : '0', - he: params.he, - gdpr: isEUConsentRequired(consentData) ? '1' : '0', - gdpr_consent: isEUConsentRequired(consentData) ? consentData.gdpr.consentString : '', - us_privacy: consentData && consentData.uspConsent ? consentData.uspConsent : '' + gdpr: connectIdSubmodule.isEUConsentRequired(consentData) ? '1' : '0', + gdpr_consent: connectIdSubmodule.isEUConsentRequired(consentData) ? consentData.consentString : '', + us_privacy: uspString }; - if (params.pixelId) { - data.pixelId = params.pixelId + const gppConsent = gppDataHandler.getConsentData(); + if (gppConsent) { + data.gpp = `${gppConsent.gppString ? gppConsent.gppString : ''}`; + if (Array.isArray(gppConsent.applicableSections)) { + data.gpp_sid = gppConsent.applicableSections.join(','); + } + } + + let topmostLocation = getRefererInfo().topmostLocation; + if (typeof topmostLocation === 'string') { + data.url = topmostLocation.split('?')[0]; + } + + INPUT_PARAM_KEYS.forEach(key => { + if (typeof params[key] != 'undefined') { + data[key] = params[key]; + } + }); + + const hashedEmail = params.he || storedId?.he; + if (hashedEmail) { + data.he = hashedEmail; + } + if (!data.puid && storedId?.puid) { + data.puid = storedId.puid; } const resp = function (callback) { @@ -73,6 +232,16 @@ export const connectIdSubmodule = { if (response) { try { responseObj = JSON.parse(response); + if (isPlainObject(responseObj) && Object.keys(responseObj).length > 0 && + (!!responseObj.connectId || !!responseObj.connectid)) { + responseObj.he = params.he; + responseObj.puid = params.puid || responseObj.puid; + responseObj.lastSynced = Date.now(); + responseObj.lastUsed = Date.now(); + storeObject(responseObj); + } else { + logError(`${MODULE_NAME} module: UPS response returned an invalid payload ${response}`); + } } catch (error) { logError(error); } @@ -80,7 +249,7 @@ export const connectIdSubmodule = { callback(responseObj); }, error: error => { - logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + logError(`${MODULE_NAME} module: ID fetch encountered an error`, error); callback(); } }; @@ -88,7 +257,34 @@ export const connectIdSubmodule = { let url = `${params.endpoint || endpoint}?${formatQS(data)}`; connectIdSubmodule.getAjaxFn()(url, callbacks, null, {method: 'GET', withCredentials: true}); }; - return {callback: resp}; + const result = {callback: resp}; + if (shouldResync && storedId) { + result.id = storedId; + } + + return result; + }, + + /** + * Utility function that returns a boolean flag indicating if the opportunity + * is subject to GDPR + * @returns {Boolean} + */ + isEUConsentRequired(consentData) { + return !!(consentData?.gdprApplies); + }, + + /** + * Utility function that returns a boolean flag indicating if the user + * has opeted out via the Yahoo easy-opt-out mechanism. + * @returns {Boolean} + */ + userHasOptedOut() { + try { + return localStorage.getItem(OVERRIDE_OPT_OUT_KEY) === '1'; + } catch { + return false; + } }, /** @@ -98,6 +294,12 @@ export const connectIdSubmodule = { */ getAjaxFn() { return ajax; + }, + eids: { + 'connectId': { + source: 'yahoo.com', + atype: 3 + }, } }; diff --git a/modules/connectIdSystem.md b/modules/connectIdSystem.md index f2153e1b6cb..bf5ac8a0e8b 100644 --- a/modules/connectIdSystem.md +++ b/modules/connectIdSystem.md @@ -2,6 +2,8 @@ Yahoo ConnectID user ID Module. +*Note: The storage config should be ommited as the module handles the storage of the needed information. + ### Prebid Params ``` @@ -9,11 +11,6 @@ pbjs.setConfig({ userSync: { userIds: [{ name: 'connectId', - storage: { - name: 'connectId', - type: 'html5', - expires: 15 - }, params: { pixelId: 58776, he: '0bef996248d63cea1529cb86de31e9547a712d9f380146e98bbd39beec70355a' @@ -27,7 +24,9 @@ The below parameters apply only to the Yahoo ConnectID user ID Module. | Param under usersync.userIds[] | Scope | Type | Description | Example | | --- | --- | --- | --- | --- | -| name | Required | String | ID value for the Yahoo ConnectID module - `"connectId"` | `"connectId"` | -| params | Required | Object | Data for Yahoo ConnectID initialization. | | -| params.pixelId | Required | Number | The Yahoo supplied publisher specific pixel Id | `8976` | -| params.he | Required | String | The SHA-256 hashed user email address | `"529cb86de31e9547a712d9f380146e98bbd39beec"` | +| name | Required | String | The name of this module. | `"connectId"` | +| params | Required | Object | Container of all module params. || +| params.pixelId | Required | Number | +The Yahoo-supplied publisher-specific pixel ID. | `"0000"` | +| params.he | Optional | String | The SHA-256 hashed user email address which has been lowercased prior to hashing. |`"ed8ddbf5a171981db8ef938596ca297d5e3f84bcc280041c5880dba3baf9c1d4"`| +| params.puid | Optional | String | A domain-specific user identifier such as a first-party cookie. If not passed, a puid value will be auto-generated and stored in local and / or cookie storage. | `"ab9iibf5a231ii1db8ef911596ca297d5e3f84biii00041c5880dba3baf9c1da"` | diff --git a/modules/connectadBidAdapter.js b/modules/connectadBidAdapter.js index 711afd98d0f..b40ef30f6bc 100644 --- a/modules/connectadBidAdapter.js +++ b/modules/connectadBidAdapter.js @@ -1,9 +1,9 @@ -import { deepSetValue, convertTypes, tryAppendQueryString, logWarn } from '../src/utils.js'; +import { deepSetValue, logWarn } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js' import {config} from '../src/config.js'; -import {createEidsArray} from './userId/eids.js'; - +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; const BIDDER_CODE = 'connectad'; const BIDDER_CODE_ALIAS = 'connectadrealtime'; const ENDPOINT_URL = 'https://i.connectad.io/api/v2'; @@ -35,9 +35,11 @@ export const spec = { placements: [], time: Date.now(), user: {}, - url: (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) ? bidderRequest.refererInfo.referer : window.location.href, - referrer: window.document.referrer, - referrer_info: bidderRequest.refererInfo, + // TODO: does the fallback to window.location make sense? + url: bidderRequest.refererInfo?.page || window.location.href, + referrer: bidderRequest.refererInfo?.ref, + // TODO: please do not send internal data structures over the network + referrer_info: bidderRequest.refererInfo?.legacy, screensize: getScreenSize(), dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, language: navigator.language, @@ -71,12 +73,13 @@ export const spec = { } // EIDS Support - if (validBidRequests[0].userId) { - deepSetValue(data, 'user.ext.eids', createEidsArray(validBidRequests[0].userId)); + if (validBidRequests[0].userIdAsEids) { + deepSetValue(data, 'user.ext.eids', validBidRequests[0].userIdAsEids); } validBidRequests.map(bid => { const placement = Object.assign({ + // TODO: fix transactionId leak: https://github.com/prebid/Prebid.js/issues/9781 id: bid.transactionId, divName: bid.bidId, pisze: bid.mediaTypes.banner.sizes[0] || bid.sizes[0], diff --git a/modules/consentManagement.js b/modules/consentManagement.js index f0355749055..05447a890cb 100644 --- a/modules/consentManagement.js +++ b/modules/consentManagement.js @@ -4,25 +4,26 @@ * and make it available for any GDPR supported adapters to read/pass this information to * their system. */ -import {getAdUnitSizes, isFn, isNumber, isPlainObject, isStr, logError, logInfo, logWarn} from '../src/utils.js'; +import {deepSetValue, isNumber, isPlainObject, isStr, logError, logInfo, logWarn} from '../src/utils.js'; import {config} from '../src/config.js'; import {gdprDataHandler} from '../src/adapterManager.js'; import {includes} from '../src/polyfill.js'; +import {timedAuctionHook} from '../src/utils/perfMetrics.js'; +import {registerOrtbProcessor, REQUEST} from '../src/pbjsORTB.js'; +import {enrichFPD} from '../src/fpd/enrichment.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {cmpClient} from '../libraries/cmp/cmpClient.js'; const DEFAULT_CMP = 'iab'; const DEFAULT_CONSENT_TIMEOUT = 10000; -const DEFAULT_ALLOW_AUCTION_WO_CONSENT = true; +const CMP_VERSION = 2; -export const allowAuction = { - value: DEFAULT_ALLOW_AUCTION_WO_CONSENT, - definedInConfig: false -} export let userCMP; export let consentTimeout; export let gdprScope; export let staticConsentData; +let actionTimeout; -let cmpVersion = 0; let consentData; let addedConsentHook = false; @@ -36,8 +37,8 @@ const cmpCallMap = { * This function reads the consent string from the config to obtain the consent information of the user. * @param {function({})} onSuccess acts as a success callback when the value is read from config; pass along consentObject from CMP */ -function lookupStaticConsentData({onSuccess}) { - onSuccess(staticConsentData); +function lookupStaticConsentData({onSuccess, onError}) { + processCmpData(staticConsentData, {onSuccess, onError}) } /** @@ -46,58 +47,12 @@ function lookupStaticConsentData({onSuccess}) { * based on the appropriate result. * @param {function({})} onSuccess acts as a success callback when CMP returns a value; pass along consentObjectfrom CMP * @param {function(string, ...{}?)} cmpError acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging) - * @param width - * @param height size info passed to the SafeFrame API (used only for TCFv1 when Prebid is running within a safeframe) */ -function lookupIabConsent({onSuccess, onError, width, height}) { - function findCMP() { - let f = window; - let cmpFrame; - let cmpFunction; - while (!cmpFrame) { - try { - if (typeof f.__tcfapi === 'function' || typeof f.__cmp === 'function') { - if (typeof f.__tcfapi === 'function') { - cmpVersion = 2; - cmpFunction = f.__tcfapi; - } else { - cmpVersion = 1; - cmpFunction = f.__cmp; - } - cmpFrame = f; - break; - } - } catch (e) { } - - // need separate try/catch blocks due to the exception errors thrown when trying to check for a frame that doesn't exist in 3rd party env - try { - if (f.frames['__tcfapiLocator']) { - cmpVersion = 2; - cmpFrame = f; - break; - } - } catch (e) { } - - try { - if (f.frames['__cmpLocator']) { - cmpVersion = 1; - cmpFrame = f; - break; - } - } catch (e) { } - - if (f === window.top) break; - f = f.parent; - } - return { - cmpFrame, - cmpFunction - }; - } - - function v2CmpResponseCallback(tcfData, success) { +function lookupIabConsent({onSuccess, onError, onEvent}) { + function cmpResponseCallback(tcfData, success) { logInfo('Received a response from CMP', tcfData); if (success) { + onEvent(tcfData); if (tcfData.gdprApplies === false || tcfData.eventStatus === 'tcloaded' || tcfData.eventStatus === 'useractioncomplete') { processCmpData(tcfData, {onSuccess, onError}); } @@ -106,146 +61,25 @@ function lookupIabConsent({onSuccess, onError, width, height}) { } } - function handleV1CmpResponseCallbacks() { - const cmpResponse = {}; - - function afterEach() { - if (cmpResponse.getConsentData && cmpResponse.getVendorConsents) { - logInfo('Received all requested responses from CMP', cmpResponse); - processCmpData(cmpResponse, {onSuccess, onError}); - } - } - - return { - consentDataCallback: function (consentResponse) { - cmpResponse.getConsentData = consentResponse; - afterEach(); - }, - vendorConsentsCallback: function (consentResponse) { - cmpResponse.getVendorConsents = consentResponse; - afterEach(); - } - } - } - - let v1CallbackHandler = handleV1CmpResponseCallbacks(); - let cmpCallbacks = {}; - let { cmpFrame, cmpFunction } = findCMP(); + const cmp = cmpClient({ + apiName: '__tcfapi', + apiVersion: CMP_VERSION, + apiArgs: ['command', 'version', 'callback', 'parameter'], + }); - if (!cmpFrame) { - return onError('CMP not found.'); + if (!cmp) { + return onError('TCF2 CMP not found.'); } - // to collect the consent information from the user, we perform two calls to the CMP in parallel: - // first to collect the user's consent choices represented in an encoded string (via getConsentData) - // second to collect the user's full unparsed consent information (via getVendorConsents) - - // the following code also determines where the CMP is located and uses the proper workflow to communicate with it: - // check to see if CMP is found on the same window level as prebid and call it directly if so - // check to see if prebid is in a safeframe (with CMP support) - // else assume prebid may be inside an iframe and use the IAB CMP locator code to see if CMP's located in a higher parent window. this works in cross domain iframes - // if the CMP is not found, the iframe function will call the cmpError exit callback to abort the rest of the CMP workflow - - if (isFn(cmpFunction)) { + if (cmp.isDirect) { logInfo('Detected CMP API is directly accessible, calling it now...'); - if (cmpVersion === 1) { - cmpFunction('getConsentData', null, v1CallbackHandler.consentDataCallback); - cmpFunction('getVendorConsents', null, v1CallbackHandler.vendorConsentsCallback); - } else if (cmpVersion === 2) { - cmpFunction('addEventListener', cmpVersion, v2CmpResponseCallback); - } - } else if (cmpVersion === 1 && inASafeFrame() && typeof window.$sf.ext.cmp === 'function') { - // this safeframe workflow is only supported with TCF v1 spec; the v2 recommends to use the iframe postMessage route instead (even if you are in a safeframe). - logInfo('Detected Prebid.js is encased in a SafeFrame and CMP is registered, calling it now...'); - callCmpWhileInSafeFrame('getConsentData', v1CallbackHandler.consentDataCallback); - callCmpWhileInSafeFrame('getVendorConsents', v1CallbackHandler.vendorConsentsCallback); } else { logInfo('Detected CMP is outside the current iframe where Prebid.js is located, calling it now...'); - if (cmpVersion === 1) { - callCmpWhileInIframe('getConsentData', cmpFrame, v1CallbackHandler.consentDataCallback); - callCmpWhileInIframe('getVendorConsents', cmpFrame, v1CallbackHandler.vendorConsentsCallback); - } else if (cmpVersion === 2) { - callCmpWhileInIframe('addEventListener', cmpFrame, v2CmpResponseCallback); - } } - function inASafeFrame() { - return !!(window.$sf && window.$sf.ext); - } - - function callCmpWhileInSafeFrame(commandName, callback) { - function sfCallback(msgName, data) { - if (msgName === 'cmpReturn') { - let responseObj = (commandName === 'getConsentData') ? data.vendorConsentData : data.vendorConsents; - callback(responseObj); - } - } - - window.$sf.ext.register(width, height, sfCallback); - window.$sf.ext.cmp(commandName); - } - - function callCmpWhileInIframe(commandName, cmpFrame, moduleCallback) { - let apiName = (cmpVersion === 2) ? '__tcfapi' : '__cmp'; - - let callName = `${apiName}Call`; - - /* Setup up a __cmp function to do the postMessage and stash the callback. - This function behaves (from the caller's perspective identicially to the in-frame __cmp call */ - if (cmpVersion === 2) { - window[apiName] = function (cmd, cmpVersion, callback, arg) { - let callId = Math.random() + ''; - let msg = { - [callName]: { - command: cmd, - version: cmpVersion, - parameter: arg, - callId: callId - } - }; - - cmpCallbacks[callId] = callback; - cmpFrame.postMessage(msg, '*'); - } - - /** when we get the return message, call the stashed callback */ - window.addEventListener('message', readPostMessageResponse, false); - - // call CMP - window[apiName](commandName, cmpVersion, moduleCallback); - } else { - window[apiName] = function (cmd, arg, callback) { - let callId = Math.random() + ''; - let msg = { - [callName]: { - command: cmd, - parameter: arg, - callId: callId - } - }; - - cmpCallbacks[callId] = callback; - cmpFrame.postMessage(msg, '*'); - } - - /** when we get the return message, call the stashed callback */ - window.addEventListener('message', readPostMessageResponse, false); - - // call CMP - window[apiName](commandName, undefined, moduleCallback); - } - - function readPostMessageResponse(event) { - let cmpDataPkgName = `${apiName}Return`; - let json = (typeof event.data === 'string' && includes(event.data, cmpDataPkgName)) ? JSON.parse(event.data) : event.data; - if (json[cmpDataPkgName] && json[cmpDataPkgName].callId) { - let payload = json[cmpDataPkgName]; - // TODO - clean up this logic (move listeners?); we have duplicate messages responses because 2 eventlisteners are active from the 2 cmp requests running in parallel - if (typeof cmpCallbacks[payload.callId] !== 'undefined') { - cmpCallbacks[payload.callId](payload.returnValue, payload.success); - } - } - } - } + cmp({ + command: 'addEventListener', + callback: cmpResponseCallback + }) } /** @@ -253,21 +87,31 @@ function lookupIabConsent({onSuccess, onError, width, height}) { * * @param cb A callback that takes: a boolean that is true if the auction should be canceled; an error message and extra * error arguments that will be undefined if there's no error. - * @param width if we are running in an iframe, the TCFv1 spec requires us to use the SafeFrame API to find the CMP - which - * in turn requires width and height. - * @param height see width above */ -function loadConsentData(cb, width = 1, height = 1) { +function loadConsentData(cb) { let isDone = false; let timer = null; + let onTimeout, provisionalConsent; + let cmpLoaded = false; - function done(consentData, shouldCancelAuction, errMsg, ...extraArgs) { + function resetTimeout(timeout) { if (timer != null) { clearTimeout(timer); } + if (!isDone && timeout != null) { + if (timeout === 0) { + onTimeout() + } else { + timer = setTimeout(onTimeout, timeout); + } + } + } + + function done(consentData, shouldCancelAuction, errMsg, ...extraArgs) { + resetTimeout(null); isDone = true; gdprDataHandler.setConsentData(consentData); - if (cb != null) { + if (typeof cb === 'function') { cb(shouldCancelAuction, errMsg, ...extraArgs); } } @@ -280,35 +124,45 @@ function loadConsentData(cb, width = 1, height = 1) { const callbacks = { onSuccess: (data) => done(data, false), onError: function (msg, ...extraArgs) { - let consentData = null; - let shouldCancelAuction = true; - if (allowAuction.value && cmpVersion === 1) { - // still set the consentData to undefined when there is a problem as per config options - consentData = storeConsentData(undefined); - shouldCancelAuction = false; + done(null, true, msg, ...extraArgs); + }, + onEvent: function (consentData) { + provisionalConsent = consentData; + if (cmpLoaded) return; + cmpLoaded = true; + if (actionTimeout != null) { + resetTimeout(actionTimeout); } - done(consentData, shouldCancelAuction, msg, ...extraArgs); } } - cmpCallMap[userCMP]({ - width, - height, - ...callbacks - }); - if (!isDone) { - if (consentTimeout === 0) { - processCmpData(undefined, callbacks); - } else { - timer = setTimeout(function () { - if (cmpVersion === 2) { - // for TCFv2, we allow the auction to continue on timeout - done(storeConsentData(undefined), false, `No response from CMP, continuing auction...`) - } else { - callbacks.onError('CMP workflow exceeded timeout threshold.'); - } - }, consentTimeout); + onTimeout = () => { + const continueToAuction = (data) => { + done(data, false, `${cmpLoaded ? 'Timeout waiting for user action on CMP' : 'CMP did not load'}, continuing auction...`); } + processCmpData(provisionalConsent, { + onSuccess: continueToAuction, + onError: () => continueToAuction(storeConsentData(undefined)), + }) + } + + cmpCallMap[userCMP](callbacks); + if (!(actionTimeout != null && cmpLoaded)) { + resetTimeout(consentTimeout); + } +} + +/** + * Like `loadConsentData`, but cache and re-use previously loaded data. + * @param cb + */ +function loadIfMissing(cb) { + if (consentData) { + logInfo('User consent information already known. Pulling internally stored information...'); + // eslint-disable-next-line standard/no-callback-literal + cb(false); + } else { + loadConsentData(cb); } } @@ -320,37 +174,11 @@ function loadConsentData(cb, width = 1, height = 1) { * @param {object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. * @param {function} fn required; The next function in the chain, used by hook.js */ -export function requestBidsHook(fn, reqBidsConfigObj) { - const load = (() => { - if (consentData) { - logInfo('User consent information already known. Pulling internally stored information...'); - return function (cb) { - // eslint-disable-next-line standard/no-callback-literal - cb(false); - } - } else { - // find sizes from adUnits object - let adUnits = reqBidsConfigObj.adUnits || $$PREBID_GLOBAL$$.adUnits; - let width = 1; - let height = 1; - if (Array.isArray(adUnits) && adUnits.length > 0) { - let sizes = getAdUnitSizes(adUnits[0]); - width = sizes[0][0]; - height = sizes[0][1]; - } - - return function (cb) { - loadConsentData(cb, width, height); - } - } - })(); - - load(function (shouldCancelAuction, errMsg, ...extraArgs) { +export const requestBidsHook = timedAuctionHook('gdpr', function requestBidsHook(fn, reqBidsConfigObj) { + loadIfMissing(function (shouldCancelAuction, errMsg, ...extraArgs) { if (errMsg) { let log = logWarn; - if (cmpVersion === 1 && !shouldCancelAuction) { - errMsg = `${errMsg} 'allowAuctionWithoutConsent' activated.`; - } else if (shouldCancelAuction) { + if (shouldCancelAuction) { log = logError; errMsg = `${errMsg} Canceling auction as per consentManagement config.`; } @@ -358,6 +186,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) { } if (shouldCancelAuction) { + fn.stopTiming(); if (typeof reqBidsConfigObj.bidsBackHandler === 'function') { reqBidsConfigObj.bidsBackHandler(); } else { @@ -367,7 +196,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) { fn.call(this, reqBidsConfigObj); } }); -} +}); /** * This function checks the consent data provided by CMP to ensure it's in an expected state. @@ -375,49 +204,20 @@ export function requestBidsHook(fn, reqBidsConfigObj) { * If it's good, then we store the value and call `onSuccess` */ function processCmpData(consentObject, {onSuccess, onError}) { - function checkV1Data(consentObject) { - let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies; - return !!( - (typeof gdprApplies !== 'boolean') || - (gdprApplies === true && - !(isStr(consentObject.getConsentData.consentData) && - isPlainObject(consentObject.getVendorConsents) && - Object.keys(consentObject.getVendorConsents).length > 1 - ) - ) - ); - } - - function checkV2Data() { + function checkData() { // if CMP does not respond with a gdprApplies boolean, use defaultGdprScope (gdprScope) - let gdprApplies = consentObject && typeof consentObject.gdprApplies === 'boolean' ? consentObject.gdprApplies : gdprScope; - let tcString = consentObject && consentObject.tcString; + const gdprApplies = consentObject && typeof consentObject.gdprApplies === 'boolean' ? consentObject.gdprApplies : gdprScope; + const tcString = consentObject && consentObject.tcString; return !!( (typeof gdprApplies !== 'boolean') || - (gdprApplies === true && !isStr(tcString)) + (gdprApplies === true && (!tcString || !isStr(tcString))) ); } - // do extra things for static config - if (userCMP === 'static') { - cmpVersion = (consentObject.getConsentData) ? 1 : (consentObject.getTCData) ? 2 : 0; - // remove extra layer in static v2 data object so it matches normal v2 CMP object for processing step - if (cmpVersion === 2) { - consentObject = consentObject.getTCData; - } - } - - // determine which set of checks to run based on cmpVersion - let checkFn = (cmpVersion === 1) ? checkV1Data : (cmpVersion === 2) ? checkV2Data : null; - - if (isFn(checkFn)) { - if (checkFn(consentObject)) { - onError(`CMP returned unexpected value during lookup process.`, consentObject); - } else { - onSuccess(storeConsentData(consentObject)); - } + if (checkData()) { + onError(`CMP returned unexpected value during lookup process.`, consentObject); } else { - onError('Unable to derive CMP version to process data. Consent object does not conform to TCF v1 or v2 specs.', consentObject); + onSuccess(storeConsentData(consentObject)); } } @@ -426,23 +226,15 @@ function processCmpData(consentObject, {onSuccess, onError}) { * @param {object} cmpConsentObject required; an object representing user's consent choices (can be undefined in certain use-cases for this function only) */ function storeConsentData(cmpConsentObject) { - if (cmpVersion === 1) { - consentData = { - consentString: (cmpConsentObject) ? cmpConsentObject.getConsentData.consentData : undefined, - vendorData: (cmpConsentObject) ? cmpConsentObject.getVendorConsents : undefined, - gdprApplies: (cmpConsentObject) ? cmpConsentObject.getConsentData.gdprApplies : gdprScope - }; - } else { - consentData = { - consentString: (cmpConsentObject) ? cmpConsentObject.tcString : undefined, - vendorData: (cmpConsentObject) || undefined, - gdprApplies: cmpConsentObject && typeof cmpConsentObject.gdprApplies === 'boolean' ? cmpConsentObject.gdprApplies : gdprScope - }; - if (cmpConsentObject && cmpConsentObject.addtlConsent && isStr(cmpConsentObject.addtlConsent)) { - consentData.addtlConsent = cmpConsentObject.addtlConsent; - }; + consentData = { + consentString: (cmpConsentObject) ? cmpConsentObject.tcString : undefined, + vendorData: (cmpConsentObject) || undefined, + gdprApplies: cmpConsentObject && typeof cmpConsentObject.gdprApplies === 'boolean' ? cmpConsentObject.gdprApplies : gdprScope + }; + if (cmpConsentObject && cmpConsentObject.addtlConsent && isStr(cmpConsentObject.addtlConsent)) { + consentData.addtlConsent = cmpConsentObject.addtlConsent; } - consentData.apiVersion = cmpVersion; + consentData.apiVersion = CMP_VERSION; return consentData; } @@ -452,7 +244,7 @@ function storeConsentData(cmpConsentObject) { export function resetConsentData() { consentData = undefined; userCMP = undefined; - cmpVersion = 0; + consentTimeout = undefined; gdprDataHandler.reset(); } @@ -461,11 +253,11 @@ export function resetConsentData() { * @param {{cmp:string, timeout:number, allowAuctionWithoutConsent:boolean, defaultGdprScope:boolean}} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) */ export function setConsentConfig(config) { - // if `config.gdpr` or `config.usp` exist, assume new config format. + // if `config.gdpr`, `config.usp` or `config.gpp` exist, assume new config format. // else for backward compatability, just use `config` - config = config && (config.gdpr || config.usp ? config.gdpr : config); + config = config && (config.gdpr || config.usp || config.gpp ? config.gdpr : config); if (!config || typeof config !== 'object') { - logWarn('consentManagement config not defined, exiting consent manager'); + logWarn('consentManagement (gdpr) config not defined, exiting consent manager'); return; } if (isStr(config.cmpApi)) { @@ -482,10 +274,7 @@ export function setConsentConfig(config) { logInfo(`consentManagement config did not specify timeout. Using system default setting (${DEFAULT_CONSENT_TIMEOUT}).`); } - if (typeof config.allowAuctionWithoutConsent === 'boolean') { - allowAuction.value = config.allowAuctionWithoutConsent; - allowAuction.definedInConfig = true; - } + actionTimeout = isNumber(config.actionTimeout) ? config.actionTimeout : null; // if true, then gdprApplies should be set to true gdprScope = config.defaultGdprScope === true; @@ -495,23 +284,45 @@ export function setConsentConfig(config) { if (userCMP === 'static') { if (isPlainObject(config.consentData)) { staticConsentData = config.consentData; + if (staticConsentData?.getTCData != null) { + // accept static config with or without `getTCData` - see https://github.com/prebid/Prebid.js/issues/9581 + staticConsentData = staticConsentData.getTCData; + } consentTimeout = 0; } else { logError(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`); } } if (!addedConsentHook) { - $$PREBID_GLOBAL$$.requestBids.before(requestBidsHook, 50); + getGlobal().requestBids.before(requestBidsHook, 50); } addedConsentHook = true; gdprDataHandler.enable(); loadConsentData(); // immediately look up consent data to make it available without requiring an auction +} +config.getConfig('consentManagement', config => setConsentConfig(config.consentManagement)); + +export function enrichFPDHook(next, fpd) { + return next(fpd.then(ortb2 => { + const consent = gdprDataHandler.getConsentData(); + if (consent) { + if (typeof consent.gdprApplies === 'boolean') { + deepSetValue(ortb2, 'regs.ext.gdpr', consent.gdprApplies ? 1 : 0); + } + deepSetValue(ortb2, 'user.ext.consent', consent.consentString); + } + return ortb2; + })); +} + +enrichFPD.before(enrichFPDHook); - // Raise deprecation warning if 'allowAuctionWithoutConsent' is used with TCF 2. - if (allowAuction.definedInConfig && cmpVersion === 2) { - logWarn(`'allowAuctionWithoutConsent' ignored for TCF 2`); - } else if (!allowAuction.definedInConfig && cmpVersion === 1) { - logInfo(`'allowAuctionWithoutConsent' using system default: (${DEFAULT_ALLOW_AUCTION_WO_CONSENT}).`); +export function setOrtbAdditionalConsent(ortbRequest, bidderRequest) { + // this is not a standardized name for addtlConsent, so keep this as an ORTB library processor rather than an FPD enrichment + const addtl = bidderRequest.gdprConsent?.addtlConsent; + if (addtl && typeof addtl === 'string') { + deepSetValue(ortbRequest, 'user.ext.ConsentedProvidersSettings.consented_providers', addtl); } } -config.getConfig('consentManagement', config => setConsentConfig(config.consentManagement)); + +registerOrtbProcessor({type: REQUEST, name: 'gdprAddtlConsent', fn: setOrtbAdditionalConsent}) diff --git a/modules/consentManagementGpp.js b/modules/consentManagementGpp.js new file mode 100644 index 00000000000..8160ee2378c --- /dev/null +++ b/modules/consentManagementGpp.js @@ -0,0 +1,513 @@ +/** + * This module adds GPP consentManagement support to prebid.js. It interacts with + * supported CMPs (Consent Management Platforms) to grab the user's consent information + * and make it available for any GPP supported adapters to read/pass this information to + * their system and for various other features/modules in Prebid.js. + */ +import {deepSetValue, isEmpty, isNumber, isPlainObject, isStr, logError, logInfo, logWarn} from '../src/utils.js'; +import {config} from '../src/config.js'; +import {gppDataHandler} from '../src/adapterManager.js'; +import {timedAuctionHook} from '../src/utils/perfMetrics.js'; +import {enrichFPD} from '../src/fpd/enrichment.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {cmpClient, MODE_CALLBACK, MODE_MIXED, MODE_RETURN} from '../libraries/cmp/cmpClient.js'; +import {GreedyPromise} from '../src/utils/promise.js'; +import {buildActivityParams} from '../src/activities/params.js'; + +const DEFAULT_CMP = 'iab'; +const DEFAULT_CONSENT_TIMEOUT = 10000; + +export let userCMP; +export let consentTimeout; +let staticConsentData; + +let consentData; +let addedConsentHook = false; + +function pipeCallbacks(fn, {onSuccess, onError}) { + new GreedyPromise((resolve) => resolve(fn())).then(onSuccess, (err) => { + if (err instanceof GPPError) { + onError(err.message, ...err.args); + } else { + onError(`GPP error:`, err); + } + }); +} + +function lookupStaticConsentData(callbacks) { + return pipeCallbacks(() => processCmpData(staticConsentData), callbacks); +} + +const GPP_10 = '1.0'; +const GPP_11 = '1.1'; + +class GPPError { + constructor(message, arg) { + this.message = message; + this.args = arg == null ? [] : [arg]; + } +} + +export class GPPClient { + static CLIENTS = {}; + + static register(apiVersion, defaultVersion = false) { + this.apiVersion = apiVersion; + this.CLIENTS[apiVersion] = this; + if (defaultVersion) { + this.CLIENTS.default = this; + } + } + + static INST; + + /** + * Ping the CMP to set up an appropriate client for it, and initialize it. + * + * @param mkCmp + * @returns {Promise<[GPPClient,Promise<{}>]>} a promise to two objects: + * - a GPPClient that talks the best GPP dialect we know for the CMP's version; + * - a promise to GPP data. + */ + static init(mkCmp = cmpClient) { + if (this.INST == null) { + this.INST = this.ping(mkCmp).catch(e => { + this.INST = null; + throw e; + }); + } + return this.INST.then(([client, pingData]) => [ + client, + client.initialized ? client.refresh() : client.init(pingData) + ]); + } + + /** + * Ping the CMP to determine its version and set up a client appropriate for it. + * + * @param mkCmp + * @returns {Promise<[GPPClient, {}]>} a promise to two objects: + * - a GPPClient that talks the best GPP dialect we know for the CMP's version; + * - the result from pinging the CMP. + */ + static ping(mkCmp = cmpClient) { + const cmpOptions = { + apiName: '__gpp', + apiArgs: ['command', 'callback', 'parameter'], // do not pass version - not clear what it's for (or what we should use) + }; + + // in 1.0, 'ping' should return pingData but ignore callback; + // in 1.1 it should not return anything but run the callback + // the following looks for either - but once the version is known, produce a client that knows whether the + // rest of the interactions should pick return values or pass callbacks + + const probe = mkCmp({...cmpOptions, mode: MODE_RETURN}); + return new GreedyPromise((resolve, reject) => { + if (probe == null) { + reject(new GPPError('GPP CMP not found')); + return; + } + let done = false; // some CMPs do both return value and callbacks - avoid repeating log messages + const pong = (result, success) => { + if (done) return; + if (success != null && !success) { + reject(result); + return; + } + if (result == null) return; + done = true; + const cmpVersion = result?.gppVersion; + const Client = this.getClient(cmpVersion); + if (cmpVersion !== Client.apiVersion) { + logWarn(`Unrecognized GPP CMP version: ${cmpVersion}. Continuing using GPP API version ${Client}...`); + } else { + logInfo(`Using GPP version ${cmpVersion}`); + } + const mode = Client.apiVersion === GPP_10 ? MODE_MIXED : MODE_CALLBACK; + const client = new Client( + cmpVersion, + mkCmp({...cmpOptions, mode}) + ); + resolve([client, result]); + }; + + probe({ + command: 'ping', + callback: pong + }).then((res) => pong(res, true), reject); + }).finally(() => { + probe && probe.close(); + }); + } + + static getClient(cmpVersion) { + return this.CLIENTS.hasOwnProperty(cmpVersion) ? this.CLIENTS[cmpVersion] : this.CLIENTS.default; + } + + #resolve; + #reject; + #pending = []; + + initialized = false; + + constructor(cmpVersion, cmp) { + this.apiVersion = this.constructor.apiVersion; + this.cmpVersion = cmp; + this.cmp = cmp; + [this.#resolve, this.#reject] = [0, 1].map(slot => (result) => { + while (this.#pending.length) { + this.#pending.pop()[slot](result); + } + }); + } + + /** + * initialize this client - update consent data if already available, + * and set up event listeners to also update on CMP changes + * + * @param pingData + * @returns {Promise<{}>} a promise to GPP consent data + */ + init(pingData) { + const ready = this.updateWhenReady(pingData); + if (!this.initialized) { + this.initialized = true; + this.cmp({ + command: 'addEventListener', + callback: (event, success) => { + if (success != null && !success) { + this.#reject(new GPPError('Received error response from CMP', event)); + } else if (event?.pingData?.cmpStatus === 'error') { + this.#reject(new GPPError('CMP status is "error"; please check CMP setup', event)); + } else if (this.isCMPReady(event?.pingData || {}) && this.events.includes(event?.eventName)) { + this.#resolve(this.updateConsent(event.pingData)); + } + } + }); + } + return ready; + } + + refresh() { + return this.cmp({command: 'ping'}).then(this.updateWhenReady.bind(this)); + } + + /** + * Retrieve and store GPP consent data. + * + * @param pingData + * @returns {Promise<{}>} a promise to GPP consent data + */ + updateConsent(pingData) { + return this.getGPPData(pingData).then((data) => { + if (data == null || isEmpty(data)) { + throw new GPPError('Received empty response from CMP', data); + } + return processCmpData(data); + }).then((data) => { + logInfo('Retrieved GPP consent from CMP:', data); + return data; + }); + } + + /** + * Return a promise to GPP consent data, to be retrieved the next time the CMP signals it's ready. + * + * @returns {Promise<{}>} + */ + nextUpdate() { + return new GreedyPromise((resolve, reject) => { + this.#pending.push([resolve, reject]); + }); + } + + /** + * Return a promise to GPP consent data, to be retrieved immediately if the CMP is ready according to `pingData`, + * or as soon as it signals that it's ready otherwise. + * + * @param pingData + * @returns {Promise<{}>} + */ + updateWhenReady(pingData) { + return this.isCMPReady(pingData) ? this.updateConsent(pingData) : this.nextUpdate(); + } +} + +// eslint-disable-next-line no-unused-vars +class GPP10Client extends GPPClient { + static { + super.register(GPP_10); + } + + events = ['sectionChange', 'cmpStatus']; + + isCMPReady(pingData) { + return pingData.cmpStatus === 'loaded'; + } + + getGPPData(pingData) { + const parsedSections = GreedyPromise.all( + (pingData.supportedAPIs || pingData.apiSupport || []).map((api) => this.cmp({ + command: 'getSection', + parameter: api + }).catch(err => { + logWarn(`Could not retrieve GPP section '${api}'`, err); + }).then((section) => [api, section])) + ).then(sections => { + // parse single section object into [core, gpc] to uniformize with 1.1 parsedSections + return Object.fromEntries( + sections.filter(([_, val]) => val != null) + .map(([api, section]) => { + const subsections = [ + Object.fromEntries(Object.entries(section).filter(([k]) => k !== 'Gpc')) + ]; + if (section.Gpc != null) { + subsections.push({ + SubsectionType: 1, + Gpc: section.Gpc + }); + } + return [api, subsections]; + }) + ); + }); + return GreedyPromise.all([ + this.cmp({command: 'getGPPData'}), + parsedSections + ]).then(([gppData, parsedSections]) => Object.assign({}, gppData, {parsedSections})); + } +} + +// eslint-disable-next-line no-unused-vars +class GPP11Client extends GPPClient { + static { + super.register(GPP_11, true); + } + + events = ['sectionChange', 'signalStatus']; + + isCMPReady(pingData) { + return pingData.signalStatus === 'ready'; + } + + getGPPData(pingData) { + return GreedyPromise.resolve(pingData); + } +} + +/** + * This function handles interacting with an IAB compliant CMP to obtain the consent information of the user. + * Given the async nature of the CMP's API, we pass in acting success/error callback functions to exit this function + * based on the appropriate result. + * @param {function({})} onSuccess acts as a success callback when CMP returns a value; pass along consentObjectfrom CMP + * @param {function(string, ...{}?)} cmpError acts as an error callback while interacting with CMP; pass along an error message (string) and any extra error arguments (purely for logging) + */ +export function lookupIabConsent({onSuccess, onError}, mkCmp = cmpClient) { + pipeCallbacks(() => GPPClient.init(mkCmp).then(([client, gppDataPm]) => gppDataPm), {onSuccess, onError}); +} + +// add new CMPs here, with their dedicated lookup function +const cmpCallMap = { + 'iab': lookupIabConsent, + 'static': lookupStaticConsentData +}; + +/** + * Look up consent data and store it in the `consentData` global as well as `adapterManager.js`' gdprDataHandler. + * + * @param cb A callback that takes: a boolean that is true if the auction should be canceled; an error message and extra + * error arguments that will be undefined if there's no error. + */ +function loadConsentData(cb) { + let isDone = false; + let timer = null; + + function done(consentData, shouldCancelAuction, errMsg, ...extraArgs) { + if (timer != null) { + clearTimeout(timer); + } + isDone = true; + gppDataHandler.setConsentData(consentData); + if (typeof cb === 'function') { + cb(shouldCancelAuction, errMsg, ...extraArgs); + } + } + + if (!cmpCallMap.hasOwnProperty(userCMP)) { + done(null, false, `GPP CMP framework (${userCMP}) is not a supported framework. Aborting consentManagement module and resuming auction.`); + return; + } + + const callbacks = { + onSuccess: (data) => done(data, false), + onError: function (msg, ...extraArgs) { + done(null, true, msg, ...extraArgs); + } + }; + cmpCallMap[userCMP](callbacks); + + if (!isDone) { + const onTimeout = () => { + const continueToAuction = (data) => { + done(data, false, 'GPP CMP did not load, continuing auction...'); + }; + pipeCallbacks(() => processCmpData(consentData), { + onSuccess: continueToAuction, + onError: () => continueToAuction(storeConsentData()) + }); + }; + if (consentTimeout === 0) { + onTimeout(); + } else { + timer = setTimeout(onTimeout, consentTimeout); + } + } +} + +/** + * Like `loadConsentData`, but cache and re-use previously loaded data. + * @param cb + */ +function loadIfMissing(cb) { + if (consentData) { + logInfo('User consent information already known. Pulling internally stored information...'); + // eslint-disable-next-line standard/no-callback-literal + cb(false); + } else { + loadConsentData(cb); + } +} + +/** + * If consentManagement module is enabled (ie included in setConfig), this hook function will attempt to fetch the + * user's encoded consent string from the supported CMP. Once obtained, the module will store this + * data as part of a gppConsent object which gets transferred to adapterManager's gppDataHandler object. + * This information is later added into the bidRequest object for any supported adapters to read/pass along to their system. + * @param {object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. + * @param {function} fn required; The next function in the chain, used by hook.js + */ +export const requestBidsHook = timedAuctionHook('gpp', function requestBidsHook(fn, reqBidsConfigObj) { + loadIfMissing(function (shouldCancelAuction, errMsg, ...extraArgs) { + if (errMsg) { + let log = logWarn; + if (shouldCancelAuction) { + log = logError; + errMsg = `${errMsg} Canceling auction as per consentManagement config.`; + } + log(errMsg, ...extraArgs); + } + + if (shouldCancelAuction) { + fn.stopTiming(); + if (typeof reqBidsConfigObj.bidsBackHandler === 'function') { + reqBidsConfigObj.bidsBackHandler(); + } else { + logError('Error executing bidsBackHandler'); + } + } else { + fn.call(this, reqBidsConfigObj); + } + }); +}); + +function processCmpData(consentData) { + if ( + (consentData?.applicableSections != null && !Array.isArray(consentData.applicableSections)) || + (consentData?.gppString != null && !isStr(consentData.gppString)) || + (consentData?.parsedSections != null && !isPlainObject(consentData.parsedSections)) + ) { + throw new GPPError('CMP returned unexpected value during lookup process.', consentData); + } + return storeConsentData(consentData); +} + +/** + * Stores CMP data locally in module to make information available in adaptermanager.js for later in the auction + * @param {{}} gppData the result of calling a CMP's `getGPPData` (or equivalent) + * @param {{}} sectionData map from GPP section name to the result of calling a CMP's `getSection` (or equivalent) + */ +export function storeConsentData(gppData = {}) { + consentData = { + gppString: gppData?.gppString, + applicableSections: gppData?.applicableSections || [], + parsedSections: gppData?.parsedSections || {}, + gppData: gppData + }; + gppDataHandler.setConsentData(gppData); + return consentData; +} + +/** + * Simply resets the module's consentData variable back to undefined, mainly for testing purposes + */ +export function resetConsentData() { + consentData = undefined; + userCMP = undefined; + consentTimeout = undefined; + gppDataHandler.reset(); + GPPClient.INST = null; +} + +/** + * A configuration function that initializes some module variables, as well as add a hook into the requestBids function + * @param {{cmp:string, timeout:number, allowAuctionWithoutConsent:boolean, defaultGdprScope:boolean}} config required; consentManagement module config settings; cmp (string), timeout (int), allowAuctionWithoutConsent (boolean) + */ +export function setConsentConfig(config) { + config = config && config.gpp; + if (!config || typeof config !== 'object') { + logWarn('consentManagement.gpp config not defined, exiting consent manager module'); + return; + } + + if (isStr(config.cmpApi)) { + userCMP = config.cmpApi; + } else { + userCMP = DEFAULT_CMP; + logInfo(`consentManagement.gpp config did not specify cmp. Using system default setting (${DEFAULT_CMP}).`); + } + + if (isNumber(config.timeout)) { + consentTimeout = config.timeout; + } else { + consentTimeout = DEFAULT_CONSENT_TIMEOUT; + logInfo(`consentManagement.gpp config did not specify timeout. Using system default setting (${DEFAULT_CONSENT_TIMEOUT}).`); + } + + if (userCMP === 'static') { + if (isPlainObject(config.consentData)) { + staticConsentData = config.consentData; + consentTimeout = 0; + } else { + logError(`consentManagement.gpp config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`); + } + } + + logInfo('consentManagement.gpp module has been activated...'); + + if (!addedConsentHook) { + getGlobal().requestBids.before(requestBidsHook, 50); + buildActivityParams.before((next, params) => { + return next(Object.assign({gppConsent: gppDataHandler.getConsentData()}, params)); + }); + } + addedConsentHook = true; + gppDataHandler.enable(); + loadConsentData(); // immediately look up consent data to make it available without requiring an auction +} + +config.getConfig('consentManagement', config => setConsentConfig(config.consentManagement)); + +export function enrichFPDHook(next, fpd) { + return next(fpd.then(ortb2 => { + const consent = gppDataHandler.getConsentData(); + if (consent) { + if (Array.isArray(consent.applicableSections)) { + deepSetValue(ortb2, 'regs.gpp_sid', consent.applicableSections); + } + deepSetValue(ortb2, 'regs.gpp', consent.gppString); + } + return ortb2; + })); +} + +enrichFPD.before(enrichFPDHook); diff --git a/modules/consentManagementUsp.js b/modules/consentManagementUsp.js index e98b41d5c9e..fb65a76c87b 100644 --- a/modules/consentManagementUsp.js +++ b/modules/consentManagementUsp.js @@ -4,20 +4,24 @@ * information and make it available for any USP (CCPA) supported adapters to * read/pass this information to their system. */ -import { isFn, logInfo, logWarn, isStr, isNumber, isPlainObject, logError } from '../src/utils.js'; -import { config } from '../src/config.js'; -import { uspDataHandler } from '../src/adapterManager.js'; +import {deepSetValue, isNumber, isPlainObject, isStr, logError, logInfo, logWarn} from '../src/utils.js'; +import {config} from '../src/config.js'; +import adapterManager, {uspDataHandler} from '../src/adapterManager.js'; +import {timedAuctionHook} from '../src/utils/perfMetrics.js'; +import {getHook} from '../src/hook.js'; +import {enrichFPD} from '../src/fpd/enrichment.js'; +import {cmpClient} from '../libraries/cmp/cmpClient.js'; const DEFAULT_CONSENT_API = 'iab'; const DEFAULT_CONSENT_TIMEOUT = 50; const USPAPI_VERSION = 1; -export let consentAPI; -export let consentTimeout; +export let consentAPI = DEFAULT_CONSENT_API; +export let consentTimeout = DEFAULT_CONSENT_TIMEOUT; export let staticConsentData; let consentData; -let addedConsentHook = false; +let enabled = false; // consent APIs const uspCallMap = { @@ -28,8 +32,8 @@ const uspCallMap = { /** * This function reads the consent string from the config to obtain the consent information of the user. */ -function lookupStaticConsentData({onSuccess}) { - onSuccess(staticConsentData); +function lookupStaticConsentData({onSuccess, onError}) { + processUspData(staticConsentData, {onSuccess, onError}); } /** @@ -38,35 +42,6 @@ function lookupStaticConsentData({onSuccess}) { * based on the appropriate result. */ function lookupUspConsent({onSuccess, onError}) { - function findUsp() { - let f = window; - let uspapiFrame; - let uspapiFunction; - - while (!uspapiFrame) { - try { - if (typeof f.__uspapi === 'function') { - uspapiFunction = f.__uspapi; - uspapiFrame = f; - break; - } - } catch (e) {} - - try { - if (f.frames['__uspapiLocator']) { - uspapiFrame = f; - break; - } - } catch (e) {} - if (f === window.top) break; - f = f.parent; - } - return { - uspapiFrame, - uspapiFunction, - }; - } - function handleUspApiResponseCallbacks() { const uspResponse = {}; @@ -89,73 +64,36 @@ function lookupUspConsent({onSuccess, onError}) { } let callbackHandler = handleUspApiResponseCallbacks(); - let uspapiCallbacks = {}; - let { uspapiFrame, uspapiFunction } = findUsp(); + const cmp = cmpClient({ + apiName: '__uspapi', + apiVersion: USPAPI_VERSION, + apiArgs: ['command', 'version', 'callback'], + }); - if (!uspapiFrame) { + if (!cmp) { return onError('USP CMP not found.'); } - // to collect the consent information from the user, we perform a call to USPAPI - // to collect the user's consent choices represented as a string (via getUSPData) - - // the following code also determines where the USPAPI is located and uses the proper workflow to communicate with it: - // - use the USPAPI locator code to see if USP's located in the current window or an ancestor window. - // - else assume prebid is in an iframe, and use the locator to see if the CMP is located in a higher parent window. This works in cross domain iframes. - // - if USPAPI is not found, the iframe function will call the uspError exit callback to abort the rest of the USPAPI workflow - - if (isFn(uspapiFunction)) { + if (cmp.isDirect) { logInfo('Detected USP CMP is directly accessible, calling it now...'); - uspapiFunction( - 'getUSPData', - USPAPI_VERSION, - callbackHandler.consentDataCallback - ); } else { logInfo( 'Detected USP CMP is outside the current iframe where Prebid.js is located, calling it now...' ); - callUspApiWhileInIframe( - 'getUSPData', - uspapiFrame, - callbackHandler.consentDataCallback - ); } - function callUspApiWhileInIframe(commandName, uspapiFrame, moduleCallback) { - /* Setup up a __uspapi function to do the postMessage and stash the callback. - This function behaves, from the caller's perspective, identicially to the in-frame __uspapi call (although it is not synchronous) */ - window.__uspapi = function (cmd, ver, callback) { - let callId = Math.random() + ''; - let msg = { - __uspapiCall: { - command: cmd, - version: ver, - callId: callId, - }, - }; - - uspapiCallbacks[callId] = callback; - uspapiFrame.postMessage(msg, '*'); - }; - - /** when we get the return message, call the stashed callback */ - window.addEventListener('message', readPostMessageResponse, false); - - // call uspapi - window.__uspapi(commandName, USPAPI_VERSION, moduleCallback); + cmp({ + command: 'getUSPData', + callback: callbackHandler.consentDataCallback + }); - function readPostMessageResponse(event) { - const res = event && event.data && event.data.__uspapiReturn; - if (res && res.callId) { - if (typeof uspapiCallbacks[res.callId] !== 'undefined') { - uspapiCallbacks[res.callId](res.returnValue, res.success); - delete uspapiCallbacks[res.callId]; - } - } - } - } + cmp({ + command: 'registerDeletion', + callback: adapterManager.callDataDeletionRequest + }).catch(e => { + logError('Error invoking CMP `registerDeletion`:', e); + }); } /** @@ -210,14 +148,17 @@ function loadConsentData(cb) { * @param {object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. * @param {function} fn required; The next function in the chain, used by hook.js */ -export function requestBidsHook(fn, reqBidsConfigObj) { +export const requestBidsHook = timedAuctionHook('usp', function requestBidsHook(fn, reqBidsConfigObj) { + if (!enabled) { + enableConsentManagement(); + } loadConsentData((errMsg, ...extraArgs) => { if (errMsg != null) { logWarn(errMsg, ...extraArgs); } fn.call(this, reqBidsConfigObj); }); -} +}); /** * This function checks the consent data provided by USPAPI to ensure it's in an expected state. @@ -254,7 +195,9 @@ function storeUspConsentData(consentObject) { export function resetConsentData() { consentData = undefined; consentAPI = undefined; + consentTimeout = undefined; uspDataHandler.reset(); + enabled = false; } /** @@ -264,25 +207,21 @@ export function resetConsentData() { export function setConsentConfig(config) { config = config && config.usp; if (!config || typeof config !== 'object') { - logWarn('consentManagement.usp config not defined, exiting usp consent manager'); - return; + logWarn('consentManagement.usp config not defined, using defaults'); } - if (isStr(config.cmpApi)) { + if (config && isStr(config.cmpApi)) { consentAPI = config.cmpApi; } else { consentAPI = DEFAULT_CONSENT_API; logInfo(`consentManagement.usp config did not specify cmpApi. Using system default setting (${DEFAULT_CONSENT_API}).`); } - if (isNumber(config.timeout)) { + if (config && isNumber(config.timeout)) { consentTimeout = config.timeout; } else { consentTimeout = DEFAULT_CONSENT_TIMEOUT; logInfo(`consentManagement.usp config did not specify timeout. Using system default setting (${DEFAULT_CONSENT_TIMEOUT}).`); } - - logInfo('USPAPI consentManagement module has been activated...'); - if (consentAPI === 'static') { if (isPlainObject(config.consentData) && isPlainObject(config.consentData.getUSPData)) { if (config.consentData.getUSPData.uspString) staticConsentData = { usPrivacy: config.consentData.getUSPData.uspString }; @@ -291,11 +230,29 @@ export function setConsentConfig(config) { logError(`consentManagement config with cmpApi: 'static' did not specify consentData. No consents will be available to adapters.`); } } - if (!addedConsentHook) { - $$PREBID_GLOBAL$$.requestBids.before(requestBidsHook, 50); + enableConsentManagement(true); +} + +function enableConsentManagement(configFromUser = false) { + if (!enabled) { + logInfo(`USPAPI consentManagement module has been activated${configFromUser ? '' : ` using default values (api: '${consentAPI}', timeout: ${consentTimeout}ms)`}`); + enabled = true; + uspDataHandler.enable(); } - addedConsentHook = true; - uspDataHandler.enable(); loadConsentData(); // immediately look up consent data to make it available without requiring an auction } config.getConfig('consentManagement', config => setConsentConfig(config.consentManagement)); + +getHook('requestBids').before(requestBidsHook, 50); + +export function enrichFPDHook(next, fpd) { + return next(fpd.then(ortb2 => { + const consent = uspDataHandler.getConsentData(); + if (consent) { + deepSetValue(ortb2, 'regs.ext.us_privacy', consent) + } + return ortb2; + })) +} + +enrichFPD.before(enrichFPDHook); diff --git a/modules/consumableBidAdapter.js b/modules/consumableBidAdapter.js index de08fc8677a..c78ff7cdf51 100644 --- a/modules/consumableBidAdapter.js +++ b/modules/consumableBidAdapter.js @@ -1,15 +1,18 @@ -import { logWarn, createTrackPixelHtml } from '../src/utils.js'; +import { logWarn, deepAccess, isArray, deepSetValue, isFn, isPlainObject } from '../src/utils.js'; +import {config} from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; const BIDDER_CODE = 'consumable'; -const BASE_URI = 'https://e.serverbid.com/api/v2' +const BASE_URI = 'https://e.serverbid.com/api/v2'; let siteId = 0; let bidder = 'consumable'; export const spec = { code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], /** * Determines whether or not the given bid request is valid. @@ -47,8 +50,8 @@ export const spec = { const data = Object.assign({ placements: [], time: Date.now(), - url: bidderRequest.refererInfo.referer, - referrer: document.referrer, + url: bidderRequest.refererInfo.page, + referrer: bidderRequest.refererInfo.ref, source: [{ 'name': 'prebidjs', 'version': '$prebid.version$' @@ -62,10 +65,23 @@ export const spec = { }; } + if (bidderRequest && bidderRequest.gppConsent && bidderRequest.gppConsent.gppString) { + data.gpp = bidderRequest.gppConsent.gppString; + data.gpp_sid = bidderRequest.gppConsent.applicableSections; + } + if (bidderRequest && bidderRequest.uspConsent) { data.ccpa = bidderRequest.uspConsent; } + if (bidderRequest && bidderRequest.schain) { + data.schain = bidderRequest.schain; + } + + if (config.getConfig('coppa')) { + data.coppa = true; + } + validBidRequests.map(bid => { const sizes = (bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes) || bid.sizes || []; const placement = Object.assign({ @@ -73,11 +89,19 @@ export const spec = { adTypes: bid.adTypes || getSize(sizes) }, bid.params); + placement.bidfloor = getBidFloor(bid, sizes); + + if (bid.mediaTypes.video && bid.mediaTypes.video.playerSize) { + placement.video = bid.mediaTypes.video; + } + if (placement.networkId && placement.siteId && placement.unitId && placement.unitName) { data.placements.push(placement); } }); + handleEids(data, validBidRequests); + ret.data = JSON.stringify(data); ret.bidRequest = validBidRequests; ret.bidderRequest = bidderRequest; @@ -123,7 +147,7 @@ export const spec = { bid.creativeId = decision.adId; bid.ttl = 30; bid.netRevenue = true; - bid.referrer = bidRequest.bidderRequest.refererInfo.referer; + bid.referrer = bidRequest.bidderRequest.refererInfo.page; bid.meta = { advertiserDomains: decision.adomain || [] @@ -144,6 +168,13 @@ export const spec = { if (decision.mediaType) { bid.meta.mediaType = decision.mediaType; + + if (decision.mediaType === 'video') { + bid.mediaType = 'video'; + bid.vastUrl = decision.vastUrl || undefined; + bid.vastXml = decision.vastXml || undefined; + bid.videoCacheKey = decision.uuid || undefined; + } } bidResponses.push(bid); @@ -154,12 +185,29 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions, serverResponses) { + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { + let syncUrl = 'https://sync.serverbid.com/ss/' + siteId + '.html'; + if (syncOptions.iframeEnabled) { + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl = appendUrlParam(syncUrl, `gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`); + } else { + syncUrl = appendUrlParam(syncUrl, `gdpr=0&gdpr_consent=${gdprConsent.consentString}`); + } + } + if (gppConsent && gppConsent.gppString) { + syncUrl = appendUrlParam(syncUrl, `gpp=${gppConsent.gppString}&gpp_sid=${gppConsent.applicableSections}`); + } + + if (uspConsent && uspConsent.consentString) { + syncUrl = appendUrlParam(syncUrl, `us_privacy=${uspConsent.consentString}`); + } + if (!serverResponses || serverResponses.length === 0 || !serverResponses[0].body.bdr || serverResponses[0].body.bdr !== 'cx') { return [{ type: 'iframe', - url: 'https://sync.serverbid.com/ss/' + siteId + '.html' + url: syncUrl }]; } } @@ -229,9 +277,47 @@ function getSize(sizes) { } function retrieveAd(decision, unitId, unitName) { - let ad = decision.contents && decision.contents[0] && decision.contents[0].body + createTrackPixelHtml(decision.impressionUrl); - + let ad; + if (decision.contents && decision.contents[0]) { + ad = decision.contents[0].body; + } + if (decision.vastXml) { + ad = decision.vastXml; + } return ad; } +function handleEids(data, validBidRequests) { + let bidUserIdAsEids = deepAccess(validBidRequests, '0.userIdAsEids'); + if (isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) { + deepSetValue(data, 'user.eids', bidUserIdAsEids); + } else { + deepSetValue(data, 'user.eids', undefined); + } +} + +function getBidFloor(bid, sizes) { + if (!isFn(bid.getFloor)) { + return bid.params.bidFloor ? bid.params.bidFloor : null; + } + + let floor; + + let floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: bid.mediaTypes.video ? 'video' : 'banner', + size: sizes.length === 1 ? sizes[0] : '*' + }); + + if (isPlainObject(floorInfo) && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { + floor = parseFloat(floorInfo.floor); + } + + return floor; +} + +function appendUrlParam(url, queryString) { + return `${url}${url.indexOf('?') > -1 ? '&' : '?'}${queryString}`; +} + registerBidder(spec); diff --git a/modules/contentexchangeBidAdapter.js b/modules/contentexchangeBidAdapter.js index b3a5056f816..be5900407ea 100644 --- a/modules/contentexchangeBidAdapter.js +++ b/modules/contentexchangeBidAdapter.js @@ -2,6 +2,7 @@ import { isFn, deepAccess, logMessage } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'contentexchange'; const AD_URL = 'https://eu2.adnetwork.agency/pbjs'; @@ -113,6 +114,9 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let deviceWidth = 0; let deviceHeight = 0; @@ -127,7 +131,7 @@ export const spec = { winLocation = window.location; } - const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.referer; + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; let refferLocation; try { refferLocation = refferUrl && new URL(refferUrl); @@ -135,6 +139,7 @@ export const spec = { logMessage(e); } + // TODO: does the fallback to 'window.location' make sense? let location = refferLocation || winLocation; const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; const host = location.host; @@ -152,7 +157,7 @@ export const spec = { coppa: config.getConfig('coppa') === true ? 1 : 0, ccpa: bidderRequest.uspConsent || undefined, gdpr: bidderRequest.gdprConsent || undefined, - tmax: config.getConfig('bidderTimeout') + tmax: bidderRequest.timeout }; const len = validBidRequests.length; diff --git a/modules/contentigniteBidAdapter.md b/modules/contentigniteBidAdapter.md deleted file mode 100644 index 1f3a543b621..00000000000 --- a/modules/contentigniteBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -``` -Module Name: Content Ignite Bidder Adapter -Module Type: Bidder Adapter -Maintainer: jamie@contentignite.com -``` - -# Description - -Module that connects to Content Ignites bidder application. - -# Test Parameters - -``` - var adUnits = [{ - code: 'display-div', - sizes: [[728, 90]], // a display size - bids: [{ - bidder: "contentignite", - params: { - accountID: '168237', - zoneID: '299680', - keyword: 'business', //optional - minCPM: '0.10', //optional - maxCPM: '1.00' //optional - } - }] - }]; -``` diff --git a/modules/conversantAnalyticsAdapter.js b/modules/conversantAnalyticsAdapter.js new file mode 100644 index 00000000000..0c58402ca87 --- /dev/null +++ b/modules/conversantAnalyticsAdapter.js @@ -0,0 +1,702 @@ +import {ajax} from '../src/ajax.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import CONSTANTS from '../src/constants.json'; +import {getGlobal} from '../src/prebidGlobal.js'; +import adapterManager from '../src/adapterManager.js'; +import {logInfo, logWarn, logError, logMessage, deepAccess, isInteger} from '../src/utils.js'; +import {getRefererInfo} from '../src/refererDetection.js'; + +// Maintainer: mediapsr@epsilon.com + +const { + EVENTS: { AUCTION_END, AD_RENDER_FAILED, BID_TIMEOUT, BID_WON, BIDDER_ERROR } +} = CONSTANTS; +// STALE_RENDER, TCF2_ENFORCEMENT would need to add extra calls for these as they likely occur after AUCTION_END? +const GVLID = 24; +const ANALYTICS_TYPE = 'endpoint'; + +// for local testing set domain to 127.0.0.1:8290 +const DOMAIN = 'https://web.hb.ad.cpe.dotomi.com/'; +const ANALYTICS_URL = DOMAIN + 'cvx/event/prebidanalytics'; +const ERROR_URL = DOMAIN + 'cvx/event/prebidanalyticerrors'; +const ANALYTICS_CODE = 'conversant'; +const ANALYTICS_ALIASES = [ANALYTICS_CODE, 'epsilon', 'cnvr']; + +export const CNVR_CONSTANTS = { + LOG_PREFIX: 'Conversant analytics adapter: ', + ERROR_MISSING_DATA_PREFIX: 'Parsing method failed because of missing data: ', + // Maximum time to keep an item in the cache before it gets purged + MAX_MILLISECONDS_IN_CACHE: 30000, + // How often cache cleanup will run + CACHE_CLEANUP_TIME_IN_MILLIS: 30000, + // Should be float from 0-1, 0 is turned off, 1 is sample every instance + DEFAULT_SAMPLE_RATE: 1, + + // BID STATUS CODES + WIN: 10, + BID: 20, + NO_BID: 30, + TIMEOUT: 40, + RENDER_FAILED: 50 +}; + +// Saves passed in options from the bid adapter +const initOptions = {}; + +// Simple flag to help handle any tear down needed on disable +let conversantAnalyticsEnabled = false; + +export const cnvrHelper = { + // Turns on sampling for an instance of prebid analytics. + doSample: true, + doSendErrorData: false, + + /** + * Used to hold data for RENDER FAILED events so we can send a payload back that will match our original auction data. + * Contains the following key/value data: + * => { + * 'bidderCode': , + * 'adUnitCode': , + * 'auctionId': , + * 'timeReceived': Date.now() //For cache cleaning + * } + */ + adIdLookup: {}, + + /** + * Time out events happen before AUCTION END so we can save them in a cache and report them at the same time as the + * AUCTION END event. Has the following data and key is based off of auctionId, adUnitCode, bidderCode from + * keyStr = getLookupKey(auctionId, adUnitCode, bidderCode); + * => { + * timeReceived: Date.now() //so cache can be purged in case it doesn't get cleaned out at auctionEnd + * } + */ + timeoutCache: {}, + + /** + * Lookup of auction IDs to auction start timestamps + */ + auctionIdTimestampCache: {}, + + /** + * Capture any bidder errors and bundle them with AUCTION_END + */ + bidderErrorCache: {} +}; + +/** + * Cleanup timer for the adIdLookup and timeoutCache caches. If all works properly then the caches are self-cleaning + * but in case something goes sideways we poll periodically to cleanup old values to prevent a memory leak + */ +let cacheCleanupInterval; + +let conversantAnalytics = Object.assign( + adapter({URL: ANALYTICS_URL, ANALYTICS_TYPE}), + { + track({eventType, args}) { + try { + if (cnvrHelper.doSample) { + logMessage(CNVR_CONSTANTS.LOG_PREFIX + ' track(): ' + eventType, args); + switch (eventType) { + case AUCTION_END: + onAuctionEnd(args); + break; + case AD_RENDER_FAILED: + onAdRenderFailed(args); + break; + case BID_WON: + onBidWon(args); + break; + case BID_TIMEOUT: + onBidTimeout(args); + break; + case BIDDER_ERROR: + onBidderError(args) + } // END switch + } else { + logMessage(CNVR_CONSTANTS.LOG_PREFIX + ' - ' + eventType + ': skipped due to sampling'); + }// END IF(cnvrHelper.doSample) + } catch (e) { + // e = {stack:"...",message:"..."} + logError(CNVR_CONSTANTS.LOG_PREFIX + 'Caught error in handling ' + eventType + ' event: ' + e.message); + cnvrHelper.sendErrorData(eventType, e); + } + } // END track() + } +); + +// ================================================== EVENT HANDLERS =================================================== + +/** + * Handler for BIDDER_ERROR events, tries to capture as much data, save it in cache which is then picked up by + * AUCTION_END event and included in that payload. Was not able to see an easy way to get adUnitCode in this event + * so not including it for now. + * https://docs.prebid.org/dev-docs/bidder-adaptor.html#registering-on-bidder-error + * Trigger when the HTTP response status code is not between 200-299 and not equal to 304. + { + error: XMLHttpRequest, https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest + bidderRequest: { https://docs.prebid.org/dev-docs/bidder-adaptor.html#registering-on-bidder-error + { + auctionId: "b06c5141-fe8f-4cdf-9d7d-54415490a917", + auctionStart: 1579746300522, + bidderCode: "myBidderCode", + bidderRequestId: "15246a574e859f", + bids: [{...}], + gdprConsent: {consentString: "BOtmiBKOtmiBKABABAENAFAAAAACeAAA", vendorData: {...}, gdprApplies: true}, + refererInfo: { + canonicalUrl: null, + page: "http://mypage.org?pbjs_debug=true", + domain: "mypage.org", + ref: null, + numIframes: 0, + reachedTop: true, + isAmp: false, + stack: ["http://mypage.org?pbjs_debug=true"] + } + } + } +} + */ +function onBidderError(args) { + if (!cnvrHelper.doSendErrorData) { + logWarn(CNVR_CONSTANTS.LOG_PREFIX + 'Skipping bidder error parsing due to config disabling error logging, bidder error status = ' + args.error.status + ', Message = ' + args.error.statusText); + return; + } + + let error = args.error; + let bidRequest = args.bidderRequest; + let auctionId = bidRequest.auctionId; + let bidderCode = bidRequest.bidderCode; + logWarn(CNVR_CONSTANTS.LOG_PREFIX + 'onBidderError(): error received from bidder ' + bidderCode + '. Status = ' + error.status + ', Message = ' + error.statusText); + let errorObj = { + status: error.status, + message: error.statusText, + bidderCode: bidderCode, + url: cnvrHelper.getPageUrl(), + }; + if (cnvrHelper.bidderErrorCache[auctionId]) { + cnvrHelper.bidderErrorCache[auctionId]['errors'].push(errorObj); + } else { + cnvrHelper.bidderErrorCache[auctionId] = { + errors: [errorObj], + timeReceived: Date.now() + }; + } +} + +/** + * We get the list of timeouts before the endAution, cache them temporarily in a global cache and the endAuction event + * will pick them up. Uses getLookupKey() to create the key to the entry from auctionId, adUnitCode and bidderCode. + * Saves a single value of timeReceived so we can do cache purging periodically. + * + * Current assumption is that the timeout will always be an array even if it is just one object in the array. + * @param args [{ + "bidId": "80882409358b8a8", + "bidder": "conversant", + "adUnitCode": "MedRect", + "auctionId": "afbd6e0b-e45b-46ab-87bf-c0bac0cb8881" + }, { + "bidId": "9da4c107a6f24c8", + "bidder": "conversant", + "adUnitCode": "Leaderboard", + "auctionId": "afbd6e0b-e45b-46ab-87bf-c0bac0cb8881" + } + ] + */ +function onBidTimeout(args) { + args.forEach(timedOutBid => { + const timeoutCacheKey = cnvrHelper.getLookupKey(timedOutBid.auctionId, timedOutBid.adUnitCode, timedOutBid.bidder); + cnvrHelper.timeoutCache[timeoutCacheKey] = { + timeReceived: Date.now() + } + }); +} + +/** + * Bid won occurs after auctionEnd so we need to send this separately. We also save an entry in the adIdLookup cache + * so that if the render fails we can match up important data so we can send a valid RENDER FAILED event back. + * @param args bidWon args + */ +function onBidWon(args) { + const bidderCode = args.bidderCode; + const adUnitCode = args.adUnitCode; + const auctionId = args.auctionId; + let timestamp = args.requestTimestamp ? args.requestTimestamp : Date.now(); + + // Make sure we have all the data we need + if (!bidderCode || !adUnitCode || !auctionId) { + let errorReason = 'auction id'; + if (!bidderCode) { + errorReason = 'bidder code'; + } else if (!adUnitCode) { + errorReason = 'ad unit code' + } + throw new Error(CNVR_CONSTANTS.ERROR_MISSING_DATA_PREFIX + errorReason); + } + + if (cnvrHelper.auctionIdTimestampCache[auctionId]) { + timestamp = cnvrHelper.auctionIdTimestampCache[auctionId].timeReceived; // Don't delete, could be multiple winners/auction, allow cleanup to handle + } + + const bidWonPayload = cnvrHelper.createPayload('bid_won', auctionId, timestamp); + + const adUnitPayload = cnvrHelper.createAdUnit(); + bidWonPayload.adUnits[adUnitCode] = adUnitPayload; + + const bidPayload = cnvrHelper.createBid(CNVR_CONSTANTS.WIN, args.timeToRespond); + bidPayload.adSize = cnvrHelper.createAdSize(args.width, args.height); + bidPayload.cpm = args.cpm; + bidPayload.originalCpm = args.originalCpm; + bidPayload.currency = args.currency; + bidPayload.mediaType = args.mediaType; + adUnitPayload.bids[bidderCode] = [bidPayload]; + + if (!cnvrHelper.adIdLookup[args.adId]) { + cnvrHelper.adIdLookup[args.adId] = { + 'bidderCode': bidderCode, + 'adUnitCode': adUnitCode, + 'auctionId': auctionId, + 'timeReceived': Date.now() // For cache cleaning + }; + } + + sendData(bidWonPayload); +} + +/** + * RENDER FAILED occurs after AUCTION END and BID WON, the payload does not have all the data we need so we use + * adIdLookup to pull data from a BID WON event to populate our payload + * @param args = { + * reason: + * message: + * adId: --optional + * bid: {object?} --optional: unsure what this looks like but guessing it is {bidder: , params: {object}} + * } + */ +function onAdRenderFailed(args) { + const adId = args.adId; + // Make sure we have all the data we need, adId is optional so it's not guaranteed, without that we can't match it up + // to our adIdLookup data. + if (!adId || !cnvrHelper.adIdLookup[adId]) { + let errorMsg = 'ad id'; + if (adId) { + errorMsg = 'no lookup data for ad id'; + } + // Either no adId to match against a bidWon event, or no data saved from a bidWon event that matches the adId + throw new Error(CNVR_CONSTANTS.ERROR_MISSING_DATA_PREFIX + errorMsg); + } + const adIdObj = cnvrHelper.adIdLookup[adId]; + const adUnitCode = adIdObj['adUnitCode']; + const bidderCode = adIdObj['bidderCode']; + const auctionId = adIdObj['auctionId']; + delete cnvrHelper.adIdLookup[adId]; // cleanup our cache + + if (!bidderCode || !adUnitCode || !auctionId) { + let errorReason = 'auction id'; + if (!bidderCode) { + errorReason = 'bidder code'; + } else if (!adUnitCode) { + errorReason = 'ad unit code' + } + throw new Error(CNVR_CONSTANTS.ERROR_MISSING_DATA_PREFIX + errorReason); + } + + let timestamp = Date.now(); + if (cnvrHelper.auctionIdTimestampCache[auctionId]) { + timestamp = cnvrHelper.auctionIdTimestampCache[auctionId].timeReceived; // Don't delete, could be multiple winners/auction, allow cleanup to handle + } + + const renderFailedPayload = cnvrHelper.createPayload('render_failed', auctionId, timestamp); + const adUnitPayload = cnvrHelper.createAdUnit(); + adUnitPayload.bids[bidderCode] = [cnvrHelper.createBid(CNVR_CONSTANTS.RENDER_FAILED, 0)]; + adUnitPayload.bids[bidderCode][0].message = 'REASON: ' + args.reason + '. MESSAGE: ' + args.message; + renderFailedPayload.adUnits[adUnitCode] = adUnitPayload; + sendData(renderFailedPayload); +} + +/** + * AUCTION END contains bid and no bid info and all of the auction info we need. This sends the bulk of the information + * about the auction back to the servers. It will also check the timeoutCache for any matching bids, if any are found + * then they will be removed from the cache and send back with this payload. + * @param args AUCTION END payload, fairly large data structure, main objects are 'adUnits[]', 'bidderRequests[]', + * 'noBids[]', 'bidsReceived[]'... 'winningBids[]' seems to be always blank. + */ +function onAuctionEnd(args) { + const auctionId = args.auctionId; + if (!auctionId) { + throw new Error(CNVR_CONSTANTS.ERROR_MISSING_DATA_PREFIX + 'auction id'); + } + + const auctionTimestamp = args.timestamp ? args.timestamp : Date.now(); + cnvrHelper.auctionIdTimestampCache[auctionId] = { timeReceived: auctionTimestamp }; + + const auctionEndPayload = cnvrHelper.createPayload('auction_end', auctionId, auctionTimestamp); + // Get bid request information from adUnits + if (!Array.isArray(args.adUnits)) { + throw new Error(CNVR_CONSTANTS.ERROR_MISSING_DATA_PREFIX + 'no adUnits in event args'); + } + + // Write out any bid errors + if (cnvrHelper.bidderErrorCache[auctionId]) { + auctionEndPayload.bidderErrors = cnvrHelper.bidderErrorCache[auctionId].errors; + delete cnvrHelper.bidderErrorCache[auctionId]; + } + + args.adUnits.forEach(adUnit => { + const cnvrAdUnit = cnvrHelper.createAdUnit(); + // Initialize bids with bidderCode + adUnit.bids.forEach(bid => { + cnvrAdUnit.bids[bid.bidder] = []; // support multiple bids from a bidder for different sizes/media types //cnvrHelper.initializeBidDefaults(); + + // Check for cached timeout responses + const timeoutKey = cnvrHelper.getLookupKey(auctionId, adUnit.code, bid.bidder); + if (cnvrHelper.timeoutCache[timeoutKey]) { + cnvrAdUnit.bids[bid.bidder].push(cnvrHelper.createBid(CNVR_CONSTANTS.TIMEOUT, args.timeout)); + delete cnvrHelper.timeoutCache[timeoutKey]; + } + }); + + // Ad media types for the ad slot + if (cnvrHelper.keyExistsAndIsObject(adUnit, 'mediaTypes')) { + Object.entries(adUnit.mediaTypes).forEach(([mediaTypeName]) => { + cnvrAdUnit.mediaTypes.push(mediaTypeName); + }); + } + + // Ad sizes listed under the size key + if (Array.isArray(adUnit.sizes) && adUnit.sizes.length >= 1) { + adUnit.sizes.forEach(size => { + if (!Array.isArray(size) || size.length !== 2) { + logMessage(CNVR_CONSTANTS.LOG_PREFIX + 'Unknown object while retrieving adUnit sizes.', adUnit); + return; // skips to next item + } + cnvrAdUnit.sizes.push(cnvrHelper.createAdSize(size[0], size[1])); + }); + } + + // If the Ad Slot is not unique then ad sizes and media types merge them together + if (auctionEndPayload.adUnits[adUnit.code]) { + // Merge ad sizes + Array.prototype.push.apply(auctionEndPayload.adUnits[adUnit.code].sizes, cnvrAdUnit.sizes); + // Merge mediaTypes + Array.prototype.push.apply(auctionEndPayload.adUnits[adUnit.code].mediaTypes, cnvrAdUnit.mediaTypes); + } else { + auctionEndPayload.adUnits[adUnit.code] = cnvrAdUnit; + } + }); + + if (Array.isArray(args.noBids)) { + args.noBids.forEach(noBid => { + const bidPayloadArray = deepAccess(auctionEndPayload, 'adUnits.' + noBid.adUnitCode + '.bids.' + noBid.bidder); + + if (bidPayloadArray) { + bidPayloadArray.push(cnvrHelper.createBid(CNVR_CONSTANTS.NO_BID, 0)); // no time to respond info for this, would have to capture event and save it there + } else { + logMessage(CNVR_CONSTANTS.LOG_PREFIX + 'Unable to locate bid object via adUnitCode/bidderCode in payload for noBid reply in END_AUCTION', Object.assign({}, noBid)); + } + }); + } else { + logWarn(CNVR_CONSTANTS.LOG_PREFIX + 'onAuctionEnd(): noBids not defined in arguments.'); + } + + // Get bid data from bids sent + if (Array.isArray(args.bidsReceived)) { + args.bidsReceived.forEach(bid => { + const bidPayloadArray = deepAccess(auctionEndPayload, 'adUnits.' + bid.adUnitCode + '.bids.' + bid.bidderCode); + if (bidPayloadArray) { + const bidPayload = cnvrHelper.createBid(CNVR_CONSTANTS.BID, bid.timeToRespond); + bidPayload.originalCpm = bid.originalCpm; + bidPayload.cpm = bid.cpm; + bidPayload.currency = bid.currency; + bidPayload.mediaType = bid.mediaType; + bidPayload.adSize = { + 'w': bid.width, + 'h': bid.height + }; + bidPayloadArray.push(bidPayload); + } else { + logMessage(CNVR_CONSTANTS.LOG_PREFIX + 'Unable to locate bid object via adUnitCode/bidderCode in payload for bid reply in END_AUCTION', Object.assign({}, bid)); + } + }); + } else { + logWarn(CNVR_CONSTANTS.LOG_PREFIX + 'onAuctionEnd(): bidsReceived not defined in arguments.'); + } + // We need to remove any duplicate ad sizes from merging ad-slots or overlap in different media types and also + // media-types from merged ad-slots in twin bids. + Object.keys(auctionEndPayload.adUnits).forEach(function(adCode) { + auctionEndPayload.adUnits[adCode].sizes = cnvrHelper.deduplicateArray(auctionEndPayload.adUnits[adCode].sizes); + auctionEndPayload.adUnits[adCode].mediaTypes = cnvrHelper.deduplicateArray(auctionEndPayload.adUnits[adCode].mediaTypes); + }); + + sendData(auctionEndPayload); +} + +// =============================================== START OF HELPERS =================================================== + +/** + * Helper to verify a key exists and is a data type of Object (not a function, or array) + * @param parent The parent that we want to check the key for + * @param key The key which we want to check + * @returns {boolean} True if it's an object and exists, false otherwise (null, array, primitive, function) + */ +cnvrHelper.keyExistsAndIsObject = function (parent, key) { + if (!parent.hasOwnProperty(key)) { + return false; + } + return typeof parent[key] === 'object' && + !Array.isArray(parent[key]) && + parent[key] !== null; +} + +/** + * De-duplicate an array that could contain primitives or objects/associative arrays. + * A temporary array is used to store a string representation of each object that we look at. If an object matches + * one found in the temp array then it is ignored. + * @param array An array + * @returns {*} A de-duplicated array. + */ +cnvrHelper.deduplicateArray = function(array) { + if (!array || !Array.isArray(array)) { + return array; + } + + const tmpArray = []; + return array.filter(function (tmpObj) { + if (tmpArray.indexOf(JSON.stringify(tmpObj)) < 0) { + tmpArray.push(JSON.stringify(tmpObj)); + return tmpObj; + } + }); +}; + +/** + * Generic method to look at each key/value pair of a cache object and looks at the 'timeReceived' key, if more than + * the max wait time has passed then just delete the key. + * @param cacheObj one of our cache objects [adIdLookup or timeoutCache] + * @param currTime the current timestamp at the start of the most recent timer execution. + */ +cnvrHelper.cleanCache = function(cacheObj, currTime) { + Object.keys(cacheObj).forEach(key => { + const timeInCache = currTime - cacheObj[key].timeReceived; + if (timeInCache >= CNVR_CONSTANTS.MAX_MILLISECONDS_IN_CACHE) { + delete cacheObj[key]; + } + }); +}; + +/** + * Helper to create an object lookup key for our timeoutCache + * @param auctionId id of the auction + * @param adUnitCode ad unit code + * @param bidderCode bidder code + * @returns string concatenation of all the params into a string key for timeoutCache + */ +cnvrHelper.getLookupKey = function(auctionId, adUnitCode, bidderCode) { + return auctionId + '-' + adUnitCode + '-' + bidderCode; +}; + +/** + * Creates our root payload object that gets sent back to the server + * @param payloadType string type of payload (AUCTION_END, BID_WON, RENDER_FAILED) + * @param auctionId id for the auction + * @param timestamp timestamp in milliseconds of auction start time. + * @returns + * {{ + * requestType: *, + * adUnits: {}, + * auction: { + * auctionId: *, + * preBidVersion: *, + * sid: *} + * }} Basic structure of our object that we return to the server. + */ +cnvrHelper.createPayload = function(payloadType, auctionId, timestamp) { + return { + requestType: payloadType, + globalSampleRate: initOptions.global_sample_rate, + cnvrSampleRate: initOptions.cnvr_sample_rate, + auction: { + auctionId: auctionId, + preBidVersion: getGlobal().version, + sid: initOptions.site_id, + auctionTimestamp: timestamp + }, + adUnits: {}, + bidderErrors: [] + }; +}; + +/** + * Helper to create an adSize object, if the value passed in is not an int then set it to -1 + * @param width in pixels (must be an int) + * @param height in peixl (must be an int) + * @returns {{w: *, h: *}} a fully valid adSize object + */ +cnvrHelper.createAdSize = function(width, height) { + if (!isInteger(width)) { + width = -1; + } + if (!isInteger(height)) { + height = -1; + } + return { + 'w': width, + 'h': height + }; +}; + +/** + * Helper to create the basic structure of our adUnit payload + * @returns {{sizes: [], bids: {}}} Basic adUnit payload structure as follows + */ +cnvrHelper.createAdUnit = function() { + return { + sizes: [], + mediaTypes: [], + bids: {} + }; +}; + +/** + * Helper to create a basic bid payload object. + */ +cnvrHelper.createBid = function (eventCode, timeToRespond) { + return { + 'eventCodes': [eventCode], + 'timeToRespond': timeToRespond + }; +}; + +/** + * Helper to get the sampling rates from an object and validate the result. + * @param parentObj Parent object that has the sampling property + * @param propNm Name of the sampling property + * @param defaultSampleRate A default value to apply if there is a problem + * @returns {number} returns a float number from 0 (always off) to 1 (always on) + */ +cnvrHelper.getSampleRate = function(parentObj, propNm, defaultSampleRate) { + let sampleRate = defaultSampleRate; + if (parentObj && typeof parentObj[propNm] !== 'undefined') { + sampleRate = parseFloat(parentObj[propNm]); + if (Number.isNaN(sampleRate) || sampleRate > 1) { + sampleRate = defaultSampleRate; + } else if (sampleRate < 0) { + sampleRate = 0; + } + } + return sampleRate; +} + +/** + * Helper to encapsulate logic for getting best known page url. Small but helpful in debugging/testing and if we ever want + * to add more logic to this. + * + * From getRefererInfo(): page = the best candidate for the current page URL: `canonicalUrl`, falling back to `location` + * @returns {*} Best guess at top URL based on logic from RefererInfo. + */ +cnvrHelper.getPageUrl = function() { + return getRefererInfo().page; +} + +/** + * Packages up an error that occured in analytics handling and sends it back to our servers for logging + * @param eventType = original event that was fired + * @param exception = {stack:"...",message:"..."}, exception that was triggered + */ +cnvrHelper.sendErrorData = function(eventType, exception) { + if (!cnvrHelper.doSendErrorData) { + logWarn(CNVR_CONSTANTS.LOG_PREFIX + 'Skipping sending error data due to config disabling error logging, error thrown = ' + exception); + return; + } + + let error = { + event: eventType, + siteId: initOptions.site_id, + message: exception.message, + stack: exception.stack, + prebidVersion: '$$REPO_AND_VERSION$$', // testing val sample: prebid_prebid_7.27.0-pre' + userAgent: navigator.userAgent, + url: cnvrHelper.getPageUrl() + }; + + // eslint-disable-next-line no-undef + ajax(ERROR_URL, function () {}, JSON.stringify(error), {contentType: 'text/plain'}); +} + +/** + * Helper function to send data back to server. Need to make sure we don't trigger a CORS preflight by not adding + * extra header params. + * @param payload our JSON payload from either AUCTION END, BID WIN, RENDER FAILED + */ +function sendData(payload) { + ajax(ANALYTICS_URL, function () {}, JSON.stringify(payload), {contentType: 'text/plain'}); +} + +// =============================== BOILERPLATE FOR PRE-BID ANALYTICS SETUP ============================================ +// save the base class function +conversantAnalytics.originEnableAnalytics = conversantAnalytics.enableAnalytics; +conversantAnalytics.originDisableAnalytics = conversantAnalytics.disableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +conversantAnalytics.enableAnalytics = function (config) { + if (!config || !config.options || !config.options.site_id) { + logError(CNVR_CONSTANTS.LOG_PREFIX + 'siteId is required.'); + return; + } + + cacheCleanupInterval = setInterval( + function() { + const currTime = Date.now(); + cnvrHelper.cleanCache(cnvrHelper.adIdLookup, currTime); + cnvrHelper.cleanCache(cnvrHelper.timeoutCache, currTime); + cnvrHelper.cleanCache(cnvrHelper.auctionIdTimestampCache, currTime); + cnvrHelper.cleanCache(cnvrHelper.bidderErrorCache, currTime); + }, + CNVR_CONSTANTS.CACHE_CLEANUP_TIME_IN_MILLIS + ); + + Object.assign(initOptions, config.options); + + initOptions.global_sample_rate = cnvrHelper.getSampleRate(initOptions, 'sampling', 1); + initOptions.cnvr_sample_rate = cnvrHelper.getSampleRate(initOptions, 'cnvr_sampling', CNVR_CONSTANTS.DEFAULT_SAMPLE_RATE); + + logInfo(CNVR_CONSTANTS.LOG_PREFIX + 'Conversant sample rate set to ' + initOptions.cnvr_sample_rate); + logInfo(CNVR_CONSTANTS.LOG_PREFIX + 'Global sample rate set to ' + initOptions.global_sample_rate); + // Math.random() pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1) + cnvrHelper.doSample = Math.random() < initOptions.cnvr_sample_rate; + + if (initOptions.send_error_data !== undefined && initOptions.send_error_data !== null) { + cnvrHelper.doSendErrorData = !!initOptions.send_error_data; // Forces data into boolean type + } + + conversantAnalyticsEnabled = true; + conversantAnalytics.originEnableAnalytics(config); // call the base class function +}; + +/** + * Cleanup code for any timers and caches. + */ +conversantAnalytics.disableAnalytics = function () { + if (!conversantAnalyticsEnabled) { + return; + } + + // Cleanup our caches and disable our timer + clearInterval(cacheCleanupInterval); + cnvrHelper.timeoutCache = {}; + cnvrHelper.adIdLookup = {}; + cnvrHelper.auctionIdTimestampCache = {}; + cnvrHelper.bidderErrorCache = {}; + + conversantAnalyticsEnabled = false; + conversantAnalytics.originDisableAnalytics(); +}; +ANALYTICS_ALIASES.forEach(alias => { + adapterManager.registerAnalyticsAdapter({ + adapter: conversantAnalytics, + code: alias, + gvlid: GVLID + }); +}); + +export default conversantAnalytics; diff --git a/modules/conversantBidAdapter.js b/modules/conversantBidAdapter.js index 7ee8b1b7681..bef65a43616 100644 --- a/modules/conversantBidAdapter.js +++ b/modules/conversantBidAdapter.js @@ -1,8 +1,25 @@ -import { logWarn, isStr, deepAccess, isArray, getBidIdParameter, deepSetValue, isEmpty, _each, convertTypes, parseUrl, mergeDeep, buildUrl, _map, logError, isFn, isPlainObject } from '../src/utils.js'; +import { + logWarn, + isStr, + deepAccess, + isArray, + deepSetValue, + isEmpty, + _each, + parseUrl, + mergeDeep, + buildUrl, + _map, + logError, + isFn, + isPlainObject, getBidIdParameter, +} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {getStorageManager} from '../src/storageManager.js'; -import { config } from '../src/config.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; + +// Maintainer: mediapsr@epsilon.com const GVLID = 24; @@ -13,7 +30,7 @@ const URL = 'https://web.hb.ad.cpe.dotomi.com/cvx/client/hb/ortb/25'; export const spec = { code: BIDDER_CODE, gvlid: GVLID, - aliases: ['cnvr'], // short code + aliases: ['cnvr', 'epsilon'], // short code supportedMediaTypes: [BANNER, VIDEO], /** @@ -55,9 +72,8 @@ export const spec = { * @return {ServerRequest} Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { - const page = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : ''; + const page = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.page : ''; let siteId = ''; - let requestId = ''; let pubcid = null; let pubcidName = '_pubcid'; let bidurl = URL; @@ -68,8 +84,6 @@ export const spec = { siteId = getBidIdParameter('site_id', bid.params) || siteId; pubcidName = getBidIdParameter('pubcid_name', bid.params) || pubcidName; - requestId = bid.auctionId; - const imp = { id: bid.bidId, secure: 1, @@ -93,7 +107,7 @@ export const spec = { copyOptProperty(format[0].h, video, 'h'); } - copyOptProperty(bid.params.position, video, 'pos'); + copyOptProperty(bid.params.position || videoData.pos, video, 'pos'); copyOptProperty(bid.params.mimes || videoData.mimes, video, 'mimes'); copyOptProperty(bid.params.maxduration || videoData.maxduration, video, 'maxduration'); copyOptProperty(bid.params.protocols || videoData.protocols, video, 'protocols'); @@ -105,7 +119,7 @@ export const spec = { const format = convertSizes(bannerData.sizes || bid.sizes); const banner = {format: format}; - copyOptProperty(bid.params.position, banner, 'pos'); + copyOptProperty(bid.params.position || bannerData.pos, banner, 'pos'); imp.banner = banner; } @@ -123,8 +137,11 @@ export const spec = { }); const payload = { - id: requestId, + id: bidderRequest.bidderRequestId, imp: conversantImps, + source: { + tid: bidderRequest.ortb2?.source?.tid, + }, site: { id: siteId, mobile: document.querySelector('meta[name="viewport"][content*="width=device-width"]') !== null ? 1 : 0, @@ -143,6 +160,10 @@ export const spec = { } if (bidderRequest) { + if (bidderRequest.timeout) { + deepSetValue(payload, 'tmax', bidderRequest.timeout); + } + // Add GDPR flag and consent string if (bidderRequest.gdprConsent) { userExt.consent = bidderRequest.gdprConsent.consentString; @@ -177,7 +198,7 @@ export const spec = { payload.user = {ext: userExt}; } - const firstPartyData = config.getConfig('ortb2') || {}; + const firstPartyData = bidderRequest.ortb2 || {}; mergeDeep(payload, firstPartyData); return { diff --git a/modules/conversantBidAdapter.md b/modules/conversantBidAdapter.md deleted file mode 100644 index 07d9abf918b..00000000000 --- a/modules/conversantBidAdapter.md +++ /dev/null @@ -1,46 +0,0 @@ -# Overview - -- Module Name: Conversant Bidder Adapter -- Module Type: Bidder Adapter -- Maintainer: mediapsr@conversantmedia.com - -# Description - -Module that connects to Conversant's demand sources. Supports banners and videos. - -# Test Parameters -``` -var adUnits = [ - { - code: 'banner-test-div', - mediaTypes: { - banner: { - sizes: [[300, 250],[300,600]] - } - }, - bids: [{ - bidder: "conversant", - params: { - site_id: '108060' - } - }] - },{ - code: 'video-test-div', - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480], - api: [2], - protocols: [1, 2], - mimes: ['video/mp4'] - } - }, - bids: [{ - bidder: "conversant", - params: { - site_id: '108060', - white_label_url: 'https://web.hb.ad.cpe.dotomi.com/s2s/header/24' - } - }] - }]; -``` diff --git a/modules/cosmosBidAdapter.md b/modules/cosmosBidAdapter.md deleted file mode 100644 index 187a19ba17a..00000000000 --- a/modules/cosmosBidAdapter.md +++ /dev/null @@ -1,80 +0,0 @@ -# Overview - -``` -Module Name: Cosmos Bid Adapter -Module Type: Bidder Adapter -Maintainer: dev@cosmoshq.com -``` - -# Description - -Module that connects to Cosmos server for bids. -Supported Ad Fortmats: -* Banner -* Video - -# Configuration -## Following configuration required for enabling user sync. -```javascript -pbjs.setConfig({ - userSync: { - iframeEnabled: true, - enabledBidders: ['cosmos'], - syncDelay: 6000 - }}); -``` -## For Video ads, enable prebid cache -```javascript -pbjs.setConfig({ - cache: { - url: 'https://prebid.adnxs.com/pbc/v1/cache' - } -}); -``` - -# Test Parameters -``` - var adUnits = [ - // Banner adUnit - { - code: 'banner-div', - mediaTypes: { - banner: { //supported as per the openRTB spec - sizes: [[300, 250]] // required - } - }, - bids: [ - { - bidder: "cosmos", - params: { - publisherId: 1001, // required - tagId: 1 // optional - } - } - ] - }, - // Video adUnit - { - code: 'video-div', - mediaTypes: { - video: { // supported as per the openRTB spec - sizes: [[300, 50]], // required - mimes : ['video/mp4', 'application/javascript'], // required - context: 'instream' // optional - } - }, - bids: [ - { - bidder: "cosmos", - params: { - publisherId: 1001, // required - tagId: 1, // optional - video: { // supported as per the openRTB spec - - } - } - } - ] - } - ]; -``` diff --git a/modules/cpmstarBidAdapter.js b/modules/cpmstarBidAdapter.js index 75a7007ee36..e076fb4b0bb 100755 --- a/modules/cpmstarBidAdapter.js +++ b/modules/cpmstarBidAdapter.js @@ -1,7 +1,8 @@ -import { deepAccess, getBidIdParameter, logWarn, logError } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { VIDEO, BANNER } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import {getBidIdParameter} from '../src/utils.js'; const BIDDER_CODE = 'cpmstar'; @@ -25,11 +26,11 @@ export const spec = { getMediaType: function (bidRequest) { if (bidRequest == null) return BANNER; - return !deepAccess(bidRequest, 'mediaTypes.video') ? BANNER : VIDEO; + return !utils.deepAccess(bidRequest, 'mediaTypes.video') ? BANNER : VIDEO; }, getPlayerSize: function (bidRequest) { - var playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize'); + var playerSize = utils.deepAccess(bidRequest, 'mediaTypes.video.playerSize'); if (playerSize == null) return [640, 440]; if (playerSize[0] != null) playerSize = playerSize[0]; if (playerSize == null || playerSize[0] == null || playerSize[1] == null) return [640, 440]; @@ -46,7 +47,8 @@ export const spec = { for (var i = 0; i < validBidRequests.length; i++) { var bidRequest = validBidRequests[i]; - var referer = encodeURIComponent(bidderRequest.refererInfo.referer); + var referer = bidderRequest.refererInfo.page ? bidderRequest.refererInfo.page : bidderRequest.refererInfo.domain; + referer = encodeURIComponent(referer); var e = getBidIdParameter('endpoint', bidRequest.params); var ENDPOINT = e == 'dev' ? ENDPOINT_DEV : e == 'staging' ? ENDPOINT_STAGING : ENDPOINT_PRODUCTION; var mediaType = spec.getMediaType(bidRequest); @@ -72,7 +74,7 @@ export const spec = { fixedEncodeURIComponent(node.name || '') + ',' + fixedEncodeURIComponent(node.domain || ''); } - url += '&schain=' + schainString + url += '&schain=' + schainString; } if (bidderRequest.gdprConsent) { @@ -92,10 +94,20 @@ export const spec = { url += '&tfcd=' + (config.getConfig('coppa') ? 1 : 0); } + let body = {}; + let adUnitCode = bidRequest.adUnitCode; + if (adUnitCode) { + body.adUnitCode = adUnitCode; + } + if (mediaType == VIDEO) { + body.video = utils.deepAccess(bidRequest, 'mediaTypes.video'); + } + requests.push({ - method: 'GET', + method: 'POST', url: url, bidRequest: bidRequest, + data: body }); } @@ -116,13 +128,13 @@ export const spec = { var raw = serverResponse.body[i]; var rawBid = raw.creatives[0]; if (!rawBid) { - logWarn('cpmstarBidAdapter: server response failed check'); + utils.logWarn('cpmstarBidAdapter: server response failed check'); return; } var cpm = (parseFloat(rawBid.cpm) || 0); if (!cpm) { - logWarn('cpmstarBidAdapter: server response failed check. Missing cpm') + utils.logWarn('cpmstarBidAdapter: server response failed check. Missing cpm'); return; } @@ -141,7 +153,7 @@ export const spec = { }; if (rawBid.hasOwnProperty('dealId')) { - bidResponse.dealId = rawBid.dealId + bidResponse.dealId = rawBid.dealId; } if (mediaType == BANNER && rawBid.code) { @@ -155,7 +167,7 @@ export const spec = { bidResponse.mediaType = VIDEO; bidResponse.vastXml = rawBid.creativemacros.HTML5VID_VASTSTRING; } else { - return logError('bad response', rawBid); + return utils.logError('bad response', rawBid); } bidResponses.push(bidResponse); diff --git a/modules/craftBidAdapter.js b/modules/craftBidAdapter.js index 61ca4f929e7..a2a054d7659 100644 --- a/modules/craftBidAdapter.js +++ b/modules/craftBidAdapter.js @@ -1,19 +1,15 @@ -import { - convertCamelToUnderscore, - convertTypes, - deepAccess, - getBidRequest, - isArray, - isEmpty, - logError, - transformBidderParamKeywords -} from '../src/utils.js'; +import {getBidRequest, logError} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {auctionManager} from '../src/auctionManager.js'; import {find, includes} from '../src/polyfill.js'; import {getStorageManager} from '../src/storageManager.js'; import {ajax} from '../src/ajax.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {getANKeywordParam, transformBidderParamKeywords} from '../libraries/appnexusUtils/anKeywords.js'; +import {convertCamelToUnderscore} from '../libraries/appnexusUtils/anUtils.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; const BIDDER_CODE = 'craft'; const URL_BASE = 'https://gacraft.jp/prebid-v3'; @@ -30,8 +26,11 @@ export const spec = { }, buildRequests: function(bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + const bidRequest = bidRequests[0]; const tags = bidRequests.map(bidToTag); - const schain = bidRequests[0].schain; + const schain = bidRequest.schain; const payload = { tags: [...tags], ua: navigator.userAgent, @@ -40,25 +39,31 @@ export const spec = { }, schain: schain }; - if (bidderRequest && bidderRequest.gdprConsent) { - payload.gdpr_consent = { - consent_string: bidderRequest.gdprConsent.consentString, - consent_required: bidderRequest.gdprConsent.gdprApplies - }; - } - if (bidderRequest && bidderRequest.uspConsent) { - payload.us_privacy = bidderRequest.uspConsent; - } - if (bidderRequest && bidderRequest.refererInfo) { - let refererinfo = { - rd_ref: bidderRequest.refererInfo.referer, - rd_top: bidderRequest.refererInfo.reachedTop, - rd_ifs: bidderRequest.refererInfo.numIframes, - }; - if (bidderRequest.refererInfo.stack) { - refererinfo.rd_stk = bidderRequest.refererInfo.stack.join(','); + if (bidderRequest) { + if (bidderRequest.gdprConsent) { + payload.gdpr_consent = { + consent_string: bidderRequest.gdprConsent.consentString, + consent_required: bidderRequest.gdprConsent.gdprApplies + }; + } + if (bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } + if (bidderRequest.refererInfo) { + let refererinfo = { + // TODO: this collects everything it finds, except for the canonical URL + rd_ref: bidderRequest.refererInfo.topmostLocation, + rd_top: bidderRequest.refererInfo.reachedTop, + rd_ifs: bidderRequest.refererInfo.numIframes, + }; + if (bidderRequest.refererInfo.stack) { + refererinfo.rd_stk = bidderRequest.refererInfo.stack.join(','); + } + payload.referrer_detection = refererinfo; + } + if (bidRequest.userId) { + payload.userId = bidRequest.userId } - payload.referrer_detection = refererinfo; } const request = formatRequest(payload, bidderRequest); return request; @@ -101,12 +106,9 @@ export const spec = { params = convertTypes({ 'sitekey': 'string', 'placementId': 'string', - 'keywords': transformBidderParamKeywords + 'keywords': transformBidderParamKeywords, }, params); if (isOpenRtb) { - if (isPopulatedArray(params.keywords)) { - params.keywords.forEach(deleteValues); - } Object.keys(params).forEach(paramKey => { let convertedKey = convertCamelToUnderscore(paramKey); if (convertedKey !== paramKey) { @@ -126,38 +128,18 @@ export const spec = { } }; -function isPopulatedArray(arr) { - return !!(isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} - -function hasPurpose1Consent(bidderRequest) { - let result = true; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) { - result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} - function formatRequest(payload, bidderRequest) { let options = {}; - if (!hasPurpose1Consent(bidderRequest)) { + if (!hasPurpose1Consent(bidderRequest?.gdprConsent)) { options = { withCredentials: false }; } - + const baseUrl = payload.tags[0].url || URL_BASE; const payloadString = JSON.stringify(payload); return { method: 'POST', - url: `${URL_BASE}/${payload.tags[0].sitekey}`, + url: `${baseUrl}/${payload.tags[0].sitekey}`, data: payloadString, bidderRequest, options @@ -200,13 +182,11 @@ function bidToTag(bid) { tag.primary_size = tag.sizes[0]; tag.ad_types = []; tag.uuid = bid.bidId; - if (!isEmpty(bid.params.keywords)) { - let keywords = transformBidderParamKeywords(bid.params.keywords); - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } + const keywords = getANKeywordParam(bid.ortb2, bid.params.keywords); + if (keywords.length) { tag.keywords = keywords; } + // TODO: why does this need to iterate through every ad unit? let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId); if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) { tag.ad_types.push(BANNER); diff --git a/modules/criteoBidAdapter.js b/modules/criteoBidAdapter.js index 75d41d970a9..9ff6b540467 100644 --- a/modules/criteoBidAdapter.js +++ b/modules/criteoBidAdapter.js @@ -1,19 +1,23 @@ -import {deepAccess, getUniqueIdentifierStr, isArray, logError, logInfo, logWarn, parseUrl} from '../src/utils.js'; -import {loadExternalScript} from '../src/adloader.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; -import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; -import {find} from '../src/polyfill.js'; -import {verify} from 'criteo-direct-rsa-validate/build/verify.js'; // ref#2 -import {getStorageManager} from '../src/storageManager.js'; +import { deepAccess, generateUUID, isArray, logError, logInfo, logWarn, parseUrl } from '../src/utils.js'; +import { loadExternalScript } from '../src/adloader.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { verify } from 'criteo-direct-rsa-validate/build/verify.js'; // ref#2 +import { getStorageManager } from '../src/storageManager.js'; +import { getRefererInfo } from '../src/refererDetection.js'; +import { hasPurpose1Consent } from '../src/utils/gpdr.js'; +import { Renderer } from '../src/Renderer.js'; +import { OUTSTREAM } from '../src/video.js'; +import { ajax } from '../src/ajax.js'; const GVLID = 91; -export const ADAPTER_VERSION = 34; +export const ADAPTER_VERSION = 36; const BIDDER_CODE = 'criteo'; const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb'; const PROFILE_ID_INLINE = 207; export const PROFILE_ID_PUBLISHERTAG = 185; -const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); +export const storage = getStorageManager({ bidderCode: BIDDER_CODE }); const LOG_PREFIX = 'Criteo: '; /* @@ -24,18 +28,99 @@ const LOG_PREFIX = 'Criteo: '; Unminified source code can be found in the privately shared repo: https://github.com/Prebid-org/prebid-js-external-js-criteo/blob/master/dist/prod.js */ const FAST_BID_VERSION_PLACEHOLDER = '%FAST_BID_VERSION%'; -export const FAST_BID_VERSION_CURRENT = 117; +export const FAST_BID_VERSION_CURRENT = 139; const FAST_BID_VERSION_LATEST = 'latest'; const FAST_BID_VERSION_NONE = 'none'; const PUBLISHER_TAG_URL_TEMPLATE = 'https://static.criteo.net/js/ld/publishertag.prebid' + FAST_BID_VERSION_PLACEHOLDER + '.js'; +const PUBLISHER_TAG_OUTSTREAM_SRC = 'https://static.criteo.net/js/ld/publishertag.renderer.js' const FAST_BID_PUBKEY_E = 65537; const FAST_BID_PUBKEY_N = 'ztQYwCE5BU7T9CDM5he6rKoabstXRmkzx54zFPZkWbK530dwtLBDeaWBMxHBUT55CYyboR/EZ4efghPi3CoNGfGWezpjko9P6p2EwGArtHEeS4slhu/SpSIFMjG6fdrpRoNuIAMhq1Z+Pr/+HOd1pThFKeGFr2/NhtAg+TXAzaU='; +const OPTOUT_COOKIE_NAME = 'cto_optout'; +const BUNDLE_COOKIE_NAME = 'cto_bundle'; +const GUID_RETENTION_TIME_HOUR = 24 * 30 * 13; // 13 months +const OPTOUT_RETENTION_TIME_HOUR = 5 * 12 * 30 * 24; // 5 years + /** @type {BidderSpec} */ export const spec = { code: BIDDER_CODE, gvlid: GVLID, - supportedMediaTypes: [ BANNER, VIDEO, NATIVE ], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + getUserSyncs: function (syncOptions, _, gdprConsent, uspConsent) { + const fastBidVersion = config.getConfig('criteo.fastBidVersion'); + if (canFastBid(fastBidVersion)) { + return []; + } + + const refererInfo = getRefererInfo(); + const origin = 'criteoPrebidAdapter'; + + if (syncOptions.iframeEnabled && hasPurpose1Consent(gdprConsent)) { + const queryParams = []; + queryParams.push(`origin=${origin}`); + queryParams.push(`topUrl=${refererInfo.domain}`); + if (gdprConsent) { + if (gdprConsent.gdprApplies) { + queryParams.push(`gdpr=${gdprConsent.gdprApplies == true ? 1 : 0}`); + } + if (gdprConsent.consentString) { + queryParams.push(`gdpr_consent=${gdprConsent.consentString}`); + } + } + if (uspConsent) { + queryParams.push(`us_privacy=${uspConsent}`); + } + + const requestId = Math.random().toString(); + + const jsonHash = { + bundle: readFromAllStorages(BUNDLE_COOKIE_NAME), + cw: storage.cookiesAreEnabled(), + lsw: storage.localStorageIsEnabled(), + optoutCookie: readFromAllStorages(OPTOUT_COOKIE_NAME), + origin: origin, + requestId: requestId, + tld: refererInfo.domain, + topUrl: refererInfo.domain, + version: '$prebid.version$'.replace(/\./g, '_'), + }; + + window.addEventListener('message', function handler(event) { + if (!event.data || event.origin != 'https://gum.criteo.com') { + return; + } + + if (event.data.requestId !== requestId) { + return; + } + + this.removeEventListener('message', handler); + + event.stopImmediatePropagation(); + + const response = event.data; + + if (response.optout) { + deleteFromAllStorages(BUNDLE_COOKIE_NAME); + + saveOnAllStorages(OPTOUT_COOKIE_NAME, true, OPTOUT_RETENTION_TIME_HOUR); + } else { + if (response.bundle) { + saveOnAllStorages(BUNDLE_COOKIE_NAME, response.bundle, GUID_RETENTION_TIME_HOUR); + } + } + }, true); + + const jsonHashSerialized = JSON.stringify(jsonHash).replace(/"/g, '%22'); + + return [{ + type: 'iframe', + url: `https://gum.criteo.com/syncframe?${queryParams.join('&')}#${jsonHashSerialized}` + }]; + } + return []; + }, /** f * @param {object} bid @@ -65,12 +150,13 @@ export const spec = { buildRequests: (bidRequests, bidderRequest) => { let url; let data; - let fpd = config.getLegacyFpd(config.getConfig('ortb2')) || {}; + let fpd = bidderRequest.ortb2 || {}; Object.assign(bidderRequest, { - publisherExt: fpd.context, - userExt: fpd.user, - ceh: config.getConfig('criteo.ceh') + publisherExt: fpd.site?.ext, + userExt: fpd.user?.ext, + ceh: config.getConfig('criteo.ceh'), + coppa: config.getConfig('coppa') }); // If publisher tag not already loaded try to get it from fast bid @@ -91,7 +177,14 @@ export const spec = { if (publisherTagAvailable()) { // eslint-disable-next-line no-undef - const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$'); + const adapter = new Criteo.PubTag.Adapters.Prebid( + PROFILE_ID_PUBLISHERTAG, + ADAPTER_VERSION, + bidRequests, + bidderRequest, + '$prebid.version$', + { createOutstreamVideoRenderer: createOutstreamVideoRenderer } + ); url = adapter.buildCdbUrl(); data = adapter.buildCdbRequest(); } else { @@ -125,43 +218,58 @@ export const spec = { if (body && body.slots && isArray(body.slots)) { body.slots.forEach(slot => { - const bidRequest = find(request.bidRequests, b => b.adUnitCode === slot.impid && (!b.params.zoneId || parseInt(b.params.zoneId) === slot.zoneid)); - const bidId = bidRequest.bidId; - const bid = { - requestId: bidId, - adId: slot.bidId || getUniqueIdentifierStr(), - cpm: slot.cpm, - currency: slot.currency, - netRevenue: true, - ttl: slot.ttl || 60, - creativeId: slot.creativecode, - width: slot.width, - height: slot.height, - dealId: slot.dealCode, - }; - if (slot.adomain) { - bid.meta = Object.assign({}, bid.meta, { advertiserDomains: slot.adomain }); - } - if (slot.native) { - if (bidRequest.params.nativeCallback) { - bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + const bidRequest = getAssociatedBidRequest(request.bidRequests, slot); + if (bidRequest) { + const bidId = bidRequest.bidId; + const bid = { + requestId: bidId, + cpm: slot.cpm, + currency: slot.currency, + netRevenue: true, + ttl: slot.ttl || 60, + creativeId: slot.creativecode, + width: slot.width, + height: slot.height, + dealId: slot.deal, + }; + if (body.ext?.paf?.transmission && slot.ext?.paf?.content_id) { + const pafResponseMeta = { + content_id: slot.ext.paf.content_id, + transmission: response.ext.paf.transmission + }; + bid.meta = Object.assign({}, bid.meta, { paf: pafResponseMeta }); + } + if (slot.adomain) { + bid.meta = Object.assign({}, bid.meta, { advertiserDomains: [slot.adomain].flat() }); + } + if (slot.ext?.meta?.networkName) { + bid.meta = Object.assign({}, bid.meta, { networkName: slot.ext.meta.networkName }) + } + if (slot.native) { + if (bidRequest.params.nativeCallback) { + bid.ad = createNativeAd(bidId, slot.native, bidRequest.params.nativeCallback); + } else { + bid.native = createPrebidNativeAd(slot.native); + bid.mediaType = NATIVE; + } + } else if (slot.video) { + bid.vastUrl = slot.displayurl; + bid.mediaType = VIDEO; + const context = deepAccess(bidRequest, 'mediaTypes.video.context'); + // if outstream video, add a default render for it. + if (context === OUTSTREAM) { + bid.renderer = createOutstreamVideoRenderer(slot); + } } else { - bid.native = createPrebidNativeAd(slot.native); - bid.mediaType = NATIVE; + bid.ad = slot.creative; } - } else if (slot.video) { - bid.vastUrl = slot.displayurl; - bid.mediaType = VIDEO; - } else { - bid.ad = slot.creative; + bids.push(bid); } - bids.push(bid); }); } return bids; }, - /** * @param {TimedOutBid} timeoutData */ @@ -200,8 +308,46 @@ export const spec = { adapter.handleSetTargeting(bid); } }, + + /** + * @param {BidRequest[]} bidRequests + */ + onDataDeletionRequest: (bidRequests) => { + const id = readFromAllStorages(BUNDLE_COOKIE_NAME); + if (id) { + deleteFromAllStorages(BUNDLE_COOKIE_NAME); + ajax('https://privacy.criteo.com/api/privacy/datadeletionrequest', + null, + JSON.stringify({ publisherUserId: id }), + { + contentType: 'application/json', + method: 'POST' + }); + } + } }; +function readFromAllStorages(name) { + const fromCookie = storage.getCookie(name); + const fromLocalStorage = storage.getDataFromLocalStorage(name); + + return fromCookie || fromLocalStorage || undefined; +} + +function saveOnAllStorages(name, value, expirationTimeHours) { + const date = new Date(); + date.setTime(date.getTime() + (expirationTimeHours * 60 * 60 * 1000)); + const expires = `expires=${date.toUTCString()}`; + + storage.setCookie(name, value, expires); + storage.setDataInLocalStorage(name, value); +} + +function deleteFromAllStorages(name) { + storage.setCookie(name, '', 0); + storage.removeDataFromLocalStorage(name); +} + /** * @return {boolean} */ @@ -217,9 +363,9 @@ function publisherTagAvailable() { function buildContext(bidRequests, bidderRequest) { let referrer = ''; if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; + referrer = bidderRequest.refererInfo.page; } - const queryString = parseUrl(referrer).search; + const queryString = parseUrl(bidderRequest?.refererInfo?.topmostLocation).search; const context = { url: referrer, @@ -248,6 +394,12 @@ function buildCdbUrl(context) { url += '&wv=' + encodeURIComponent('$prebid.version$'); url += '&cb=' + String(Math.floor(Math.random() * 99999999999)); + if (storage.localStorageIsEnabled()) { + url += '&lsavail=1'; + } else { + url += '&lsavail=0'; + } + if (context.amp) { url += '&im=1'; } @@ -258,6 +410,16 @@ function buildCdbUrl(context) { url += '&nolog=1'; } + const bundle = readFromAllStorages(BUNDLE_COOKIE_NAME); + if (bundle) { + url += `&bundle=${bundle}`; + } + + const optout = readFromAllStorages(OPTOUT_COOKIE_NAME); + if (optout) { + url += `&optout=1`; + } + return url; } @@ -265,11 +427,11 @@ function checkNativeSendId(bidRequest) { return !(bidRequest.nativeParams && ( (bidRequest.nativeParams.image && ((bidRequest.nativeParams.image.sendId !== true || bidRequest.nativeParams.image.sendTargetingKeys === true))) || - (bidRequest.nativeParams.icon && ((bidRequest.nativeParams.icon.sendId !== true || bidRequest.nativeParams.icon.sendTargetingKeys === true))) || - (bidRequest.nativeParams.clickUrl && ((bidRequest.nativeParams.clickUrl.sendId !== true || bidRequest.nativeParams.clickUrl.sendTargetingKeys === true))) || - (bidRequest.nativeParams.displayUrl && ((bidRequest.nativeParams.displayUrl.sendId !== true || bidRequest.nativeParams.displayUrl.sendTargetingKeys === true))) || - (bidRequest.nativeParams.privacyLink && ((bidRequest.nativeParams.privacyLink.sendId !== true || bidRequest.nativeParams.privacyLink.sendTargetingKeys === true))) || - (bidRequest.nativeParams.privacyIcon && ((bidRequest.nativeParams.privacyIcon.sendId !== true || bidRequest.nativeParams.privacyIcon.sendTargetingKeys === true))) + (bidRequest.nativeParams.icon && ((bidRequest.nativeParams.icon.sendId !== true || bidRequest.nativeParams.icon.sendTargetingKeys === true))) || + (bidRequest.nativeParams.clickUrl && ((bidRequest.nativeParams.clickUrl.sendId !== true || bidRequest.nativeParams.clickUrl.sendTargetingKeys === true))) || + (bidRequest.nativeParams.displayUrl && ((bidRequest.nativeParams.displayUrl.sendId !== true || bidRequest.nativeParams.displayUrl.sendTargetingKeys === true))) || + (bidRequest.nativeParams.privacyLink && ((bidRequest.nativeParams.privacyLink.sendId !== true || bidRequest.nativeParams.privacyLink.sendTargetingKeys === true))) || + (bidRequest.nativeParams.privacyIcon && ((bidRequest.nativeParams.privacyIcon.sendId !== true || bidRequest.nativeParams.privacyIcon.sendTargetingKeys === true))) )); } @@ -282,18 +444,28 @@ function checkNativeSendId(bidRequest) { function buildCdbRequest(context, bidRequests, bidderRequest) { let networkId; let schain; + let userIdAsEids; const request = { + id: generateUUID(), publisher: { url: context.url, - ext: bidderRequest.publisherExt + ext: bidderRequest.publisherExt, + }, + regs: { + coppa: bidderRequest.coppa === true ? 1 : (bidderRequest.coppa === false ? 0 : undefined), + gpp: bidderRequest.ortb2?.regs?.gpp, + gpp_sid: bidderRequest.ortb2?.regs?.gpp_sid }, slots: bidRequests.map(bidRequest => { + if (!userIdAsEids) { + userIdAsEids = bidRequest.userIdAsEids; + } networkId = bidRequest.params.networkId || networkId; schain = bidRequest.schain || schain; const slot = { + slotid: bidRequest.bidId, impid: bidRequest.adUnitCode, - transactionid: bidRequest.transactionId, - auctionId: bidRequest.auctionId, + transactionid: bidRequest.ortb2Imp?.ext?.tid }; if (bidRequest.params.zoneId) { slot.zoneid = bidRequest.params.zoneId; @@ -301,21 +473,34 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (deepAccess(bidRequest, 'ortb2Imp.ext')) { slot.ext = bidRequest.ortb2Imp.ext; } + + if (deepAccess(bidRequest, 'ortb2Imp.rwdd')) { + slot.rwdd = bidRequest.ortb2Imp.rwdd; + } + if (bidRequest.params.ext) { slot.ext = Object.assign({}, slot.ext, bidRequest.params.ext); } + if (bidRequest.nativeOrtbRequest?.assets) { + slot.ext = Object.assign({}, slot.ext, { assets: bidRequest.nativeOrtbRequest.assets }); + } if (bidRequest.params.publisherSubId) { slot.publishersubid = bidRequest.params.publisherSubId; } - if (bidRequest.params.nativeCallback || deepAccess(bidRequest, `mediaTypes.${NATIVE}`)) { + + if (bidRequest.params.nativeCallback || hasNativeMediaType(bidRequest)) { slot.native = true; if (!checkNativeSendId(bidRequest)) { logWarn(LOG_PREFIX + 'all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)'); } - slot.sizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes'), parseNativeSize); - } else { + } + + if (hasBannerMediaType(bidRequest)) { slot.sizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes'), parseSize); + } else { + slot.sizes = []; } + if (hasVideoMediaType(bidRequest)) { const video = { playersizes: parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize'), parseSize), @@ -327,7 +512,8 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { placement: bidRequest.mediaTypes.video.placement, minduration: bidRequest.mediaTypes.video.minduration, playbackmethod: bidRequest.mediaTypes.video.playbackmethod, - startdelay: bidRequest.mediaTypes.video.startdelay + startdelay: bidRequest.mediaTypes.video.startdelay, + plcmt: bidRequest.mediaTypes.video.plcmt }; const paramsVideo = bidRequest.params.video; if (paramsVideo !== undefined) { @@ -340,22 +526,27 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { slot.video = video; } + + enrichSlotWithFloors(slot, bidRequest); + return slot; }), }; if (networkId) { request.publisher.networkid = networkId; } - if (schain) { - request.source = { - ext: { - schain: schain - } - } + + request.source = { + tid: bidderRequest.ortb2?.source?.tid }; - request.user = { - ext: bidderRequest.userExt + + if (schain) { + request.source.ext = { + schain: schain + }; }; + request.user = bidderRequest.ortb2?.user || {}; + request.site = bidderRequest.ortb2?.site || {}; if (bidderRequest && bidderRequest.ceh) { request.user.ceh = bidderRequest.ceh; } @@ -372,10 +563,27 @@ function buildCdbRequest(context, bidRequests, bidderRequest) { if (bidderRequest && bidderRequest.uspConsent) { request.user.uspIab = bidderRequest.uspConsent; } + if (bidderRequest && bidderRequest.ortb2?.device?.sua) { + request.user.ext = request.user.ext || {}; + request.user.ext.sua = bidderRequest.ortb2?.device?.sua || {}; + } + if (userIdAsEids) { + request.user.ext = request.user.ext || {}; + request.user.ext.eids = [...userIdAsEids]; + } + if (bidderRequest && bidderRequest.ortb2?.bcat) { + request.bcat = bidderRequest.ortb2.bcat; + } + if (bidderRequest && bidderRequest.ortb2?.badv) { + request.badv = bidderRequest.ortb2.badv; + } + if (bidderRequest && bidderRequest.ortb2?.bapp) { + request.bapp = bidderRequest.ortb2.bapp; + } return request; } -function parseSizes(sizes, parser) { +function parseSizes(sizes, parser = s => s) { if (sizes == undefined) { return []; } @@ -389,23 +597,24 @@ function parseSize(size) { return size[0] + 'x' + size[1]; } -function parseNativeSize(size) { - if (size[0] === undefined && size[1] === undefined) { - return '2x2'; - } - return size[0] + 'x' + size[1]; -} - function hasVideoMediaType(bidRequest) { return deepAccess(bidRequest, 'mediaTypes.video') !== undefined; } +function hasBannerMediaType(bidRequest) { + return deepAccess(bidRequest, 'mediaTypes.banner') !== undefined; +} + +function hasNativeMediaType(bidRequest) { + return deepAccess(bidRequest, 'mediaTypes.native') !== undefined; +} + function hasValidVideoMediaType(bidRequest) { let isValid = true; var requiredMediaTypesParams = ['mimes', 'playerSize', 'maxduration', 'protocols', 'api', 'skip', 'placement', 'playbackmethod']; - requiredMediaTypesParams.forEach(function(param) { + requiredMediaTypesParams.forEach(function (param) { if (deepAccess(bidRequest, 'mediaTypes.video.' + param) === undefined && deepAccess(bidRequest, 'params.video.' + param) === undefined) { isValid = false; logError('Criteo Bid Adapter: mediaTypes.video.' + param + ' is required'); @@ -473,6 +682,62 @@ for (var i = 0; i < 10; ++i) { `; } +function pickAvailableGetFloorFunc(bidRequest) { + if (bidRequest.getFloor) { + return bidRequest.getFloor; + } + if (bidRequest.params.bidFloor && bidRequest.params.bidFloorCur) { + try { + const floor = parseFloat(bidRequest.params.bidFloor); + return () => { + return { + currency: bidRequest.params.bidFloorCur, + floor: floor + }; + }; + } catch { } + } + return undefined; +} + +function enrichSlotWithFloors(slot, bidRequest) { + try { + const slotFloors = {}; + + const getFloor = pickAvailableGetFloorFunc(bidRequest); + + if (getFloor) { + if (bidRequest.mediaTypes?.banner) { + slotFloors.banner = {}; + const bannerSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.banner.sizes')) + bannerSizes.forEach(bannerSize => slotFloors.banner[parseSize(bannerSize).toString()] = getFloor.call(bidRequest, { size: bannerSize, mediaType: BANNER })); + } + + if (bidRequest.mediaTypes?.video) { + slotFloors.video = {}; + const videoSizes = parseSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) + videoSizes.forEach(videoSize => slotFloors.video[parseSize(videoSize).toString()] = getFloor.call(bidRequest, { size: videoSize, mediaType: VIDEO })); + } + + if (bidRequest.mediaTypes?.native) { + slotFloors.native = {}; + slotFloors.native['*'] = getFloor.call(bidRequest, { size: '*', mediaType: NATIVE }); + } + + if (Object.keys(slotFloors).length > 0) { + if (!slot.ext) { + slot.ext = {} + } + Object.assign(slot.ext, { + floors: slotFloors + }); + } + } + } catch (e) { + logError('Could not parse floors from Prebid: ' + e); + } +} + export function canFastBid(fastBidVersion) { return fastBidVersion !== FAST_BID_VERSION_NONE; } @@ -494,6 +759,56 @@ export function getFastBidUrl(fastBidVersion) { return PUBLISHER_TAG_URL_TEMPLATE.replace(FAST_BID_VERSION_PLACEHOLDER, version); } +function createOutstreamVideoRenderer(slot) { + if (slot.ext.videoPlayerConfig === undefined || slot.ext.videoPlayerType === undefined) { + return undefined; + } + + const config = { + documentResolver: (bid, sourceDocument, renderDocument) => { + return renderDocument ?? sourceDocument; + } + } + + const render = (bid, renderDocument) => { + let payload = { + slotid: slot.impid, + vastUrl: slot.displayurl, + vastXml: slot.creative, + documentContext: renderDocument, + }; + + let outstreamConfig = slot.ext.videoPlayerConfig; + + window.CriteoOutStream[slot.ext.videoPlayerType].play(payload, outstreamConfig) + }; + + const renderer = Renderer.install({ url: PUBLISHER_TAG_OUTSTREAM_SRC, config: config }); + renderer.setRender(render); + return renderer; +} + +function getAssociatedBidRequest(bidRequests, slot) { + for (const request of bidRequests) { + if (request.adUnitCode === slot.impid) { + if (request.params.zoneId && parseInt(request.params.zoneId) === slot.zoneid) { + return request; + } else if (slot.native) { + if (request.mediaTypes?.native || request.nativeParams) { + return request; + } + } else if (slot.video) { + if (request.mediaTypes?.video) { + return request; + } + } else if (request.mediaTypes?.banner || request.sizes) { + return request; + } + } + } + return undefined; +} + export function tryGetCriteoFastBid() { // begin ref#1 try { diff --git a/modules/criteoBidAdapter.md b/modules/criteoBidAdapter.md index 6a165978f3b..30ae3d97fac 100644 --- a/modules/criteoBidAdapter.md +++ b/modules/criteoBidAdapter.md @@ -27,12 +27,7 @@ Module that connects to Criteo's demand sources. ``` # Additional Config (Optional) -Set the "ceh" property to provides the user's hashed email if available -``` - pbjs.setConfig({ - criteo: { - ceh: 'hashed mail', - fastBidVersion: "none"|"latest"| - } - }); -``` + +Criteo Bid Adapter supports the collection of the user's hashed email, if available. + +Please consider passing it to the adapter, following [these guidelines](https://publisherdocs.criteotilt.com/prebid/#hashed-emails). diff --git a/modules/criteoIdSystem.js b/modules/criteoIdSystem.js index c73c4422a77..ee343d9b16a 100644 --- a/modules/criteoIdSystem.js +++ b/modules/criteoIdSystem.js @@ -10,20 +10,23 @@ import { ajax } from '../src/ajax.js'; import { getRefererInfo } from '../src/refererDetection.js'; import { submodule } from '../src/hook.js'; import { getStorageManager } from '../src/storageManager.js'; +import { MODULE_TYPE_UID } from '../src/activities/modules.js'; +import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../src/adapterManager.js'; const gvlid = 91; const bidderCode = 'criteo'; -export const storage = getStorageManager({gvlid: gvlid, moduleName: bidderCode}); +export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: bidderCode }); const bididStorageKey = 'cto_bidid'; const bundleStorageKey = 'cto_bundle'; +const dnaBundleStorageKey = 'cto_dna_bundle'; const cookiesMaxAge = 13 * 30 * 24 * 60 * 60 * 1000; const pastDateString = new Date(0).toString(); const expirationString = new Date(timestamp() + cookiesMaxAge).toString(); -function extractProtocolHost (url, returnOnlyHost = false) { - const parsedUrl = parseUrl(url, {noDecodeWholeURL: true}) +function extractProtocolHost(url, returnOnlyHost = false) { + const parsedUrl = parseUrl(url, { noDecodeWholeURL: true }) return returnOnlyHost ? `${parsedUrl.hostname}` : `${parsedUrl.protocol}://${parsedUrl.hostname}${parsedUrl.port ? ':' + parsedUrl.port : ''}/`; @@ -70,27 +73,71 @@ function deleteFromAllStorages(key, hostname) { function getCriteoDataFromAllStorages() { return { bundle: getFromAllStorages(bundleStorageKey), + dnaBundle: getFromAllStorages(dnaBundleStorageKey), bidId: getFromAllStorages(bididStorageKey), } } -function buildCriteoUsersyncUrl(topUrl, domain, bundle, areCookiesWriteable, isLocalStorageWritable, isPublishertagPresent, gdprString) { - const url = 'https://gum.criteo.com/sid/json?origin=prebid' + +function buildCriteoUsersyncUrl(topUrl, domain, bundle, dnaBundle, areCookiesWriteable, isLocalStorageWritable, isPublishertagPresent) { + let url = 'https://gum.criteo.com/sid/json?origin=prebid' + `${topUrl ? '&topUrl=' + encodeURIComponent(topUrl) : ''}` + `${domain ? '&domain=' + encodeURIComponent(domain) : ''}` + `${bundle ? '&bundle=' + encodeURIComponent(bundle) : ''}` + - `${gdprString ? '&gdprString=' + encodeURIComponent(gdprString) : ''}` + + `${dnaBundle ? '&info=' + encodeURIComponent(dnaBundle) : ''}` + `${areCookiesWriteable ? '&cw=1' : ''}` + `${isPublishertagPresent ? '&pbt=1' : ''}` + `${isLocalStorageWritable ? '&lsw=1' : ''}`; + const usPrivacyString = uspDataHandler.getConsentData(); + if (usPrivacyString) { + url = url + `&us_privacy=${encodeURIComponent(usPrivacyString)}`; + } + + const gdprConsent = gdprDataHandler.getConsentData() + if (gdprConsent) { + url = url + `${gdprConsent.consentString ? '&gdprString=' + encodeURIComponent(gdprConsent.consentString) : ''}`; + url = url + `&gdpr=${gdprConsent.gdprApplies === true ? 1 : 0}`; + } + + const gppConsent = gppDataHandler.getConsentData(); + if (gppConsent) { + url = url + `${gppConsent.gppString ? '&gpp=' + encodeURIComponent(gppConsent.gppString) : ''}`; + url = url + `${gppConsent.applicableSections ? '&gpp_sid=' + encodeURIComponent(gppConsent.applicableSections) : ''}`; + } + return url; } -function callCriteoUserSync(parsedCriteoData, gdprString, callback) { +function callSyncPixel(domain, pixel) { + if (pixel.writeBundleInStorage && pixel.bundlePropertyName && pixel.storageKeyName) { + ajax( + pixel.pixelUrl, + { + success: response => { + if (response) { + const jsonResponse = JSON.parse(response); + if (jsonResponse && jsonResponse[pixel.bundlePropertyName]) { + saveOnAllStorages(pixel.storageKeyName, jsonResponse[pixel.bundlePropertyName], domain); + } + } + }, + error: error => { + logError(`criteoIdSystem: unable to sync user id`, error); + } + }, + undefined, + { method: 'GET', withCredentials: true } + ); + } else { + triggerPixel(pixel.pixelUrl); + } +} + +function callCriteoUserSync(parsedCriteoData, callback) { const cw = storage.cookiesAreEnabled(); const lsw = storage.localStorageIsEnabled(); - const topUrl = extractProtocolHost(getRefererInfo().referer); + const topUrl = extractProtocolHost(getRefererInfo().page); + // TODO: should domain really be extracted from the current frame? const domain = extractProtocolHost(document.location.href, true); const isPublishertagPresent = typeof criteo_pubtag !== 'undefined'; // eslint-disable-line camelcase @@ -98,15 +145,20 @@ function callCriteoUserSync(parsedCriteoData, gdprString, callback) { topUrl, domain, parsedCriteoData.bundle, + parsedCriteoData.dnaBundle, cw, lsw, - isPublishertagPresent, - gdprString + isPublishertagPresent ); const callbacks = { success: response => { const jsonResponse = JSON.parse(response); + + if (jsonResponse.pixels) { + jsonResponse.pixels.forEach(pixel => callSyncPixel(domain, pixel)); + } + if (jsonResponse.acwsUrl) { const urlsToCall = typeof jsonResponse.acwsUrl === 'string' ? [jsonResponse.acwsUrl] : jsonResponse.acwsUrl; urlsToCall.forEach(url => triggerPixel(url)); @@ -155,18 +207,21 @@ export const criteoIdSubmodule = { * @param {ConsentData} [consentData] * @returns {{id: {criteoId: string} | undefined}}} */ - getId(config, consentData) { - const hasGdprData = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies; - const gdprConsentString = hasGdprData ? consentData.consentString : undefined; - + getId() { let localData = getCriteoDataFromAllStorages(); - const result = (callback) => callCriteoUserSync(localData, gdprConsentString, callback); + const result = (callback) => callCriteoUserSync(localData, callback); return { id: localData.bidId ? { criteoId: localData.bidId } : undefined, callback: result } + }, + eids: { + 'criteoId': { + source: 'criteo.com', + atype: 1 + }, } }; diff --git a/modules/currency.js b/modules/currency.js index 7f88c4b0aeb..3da0cfe73e8 100644 --- a/modules/currency.js +++ b/modules/currency.js @@ -1,10 +1,12 @@ -import { logInfo, logWarn, logError, logMessage } from '../src/utils.js'; -import { getGlobal } from '../src/prebidGlobal.js'; -import { createBid } from '../src/bidfactory.js'; +import {logError, logInfo, logMessage, logWarn} from '../src/utils.js'; +import {getGlobal} from '../src/prebidGlobal.js'; import CONSTANTS from '../src/constants.json'; -import { ajax } from '../src/ajax.js'; -import { config } from '../src/config.js'; -import { getHook } from '../src/hook.js'; +import {ajax} from '../src/ajax.js'; +import {config} from '../src/config.js'; +import {getHook} from '../src/hook.js'; +import {defer} from '../src/utils/promise.js'; +import {registerOrtbProcessor, REQUEST} from '../src/pbjsORTB.js'; +import {timedBidResponseHook} from '../src/utils/perfMetrics.js'; const DEFAULT_CURRENCY_RATE_URL = 'https://cdn.jsdelivr.net/gh/prebid/currency-file@1/latest.json?date=$$TODAY$$'; const CURRENCY_RATE_PRECISION = 4; @@ -21,22 +23,12 @@ var bidderCurrencyDefault = {}; var defaultRates; export const ready = (() => { - let isDone, resolver, promise; + let ctl; function reset() { - isDone = false; - resolver = null; - promise = new Promise((resolve) => { - resolver = resolve; - if (isDone) resolve(); - }) - } - function done() { - isDone = true; - if (resolver != null) { resolver() } + ctl = defer(); } reset(); - - return {done, reset, promise: () => promise} + return {done: () => ctl.resolve(), reset, promise: () => ctl.promise} })(); /** @@ -155,6 +147,7 @@ function initCurrency(url) { try { currencyRates = JSON.parse(response); logInfo('currencyRates set to ' + JSON.stringify(currencyRates)); + conversionCache = {}; currencyRatesLoaded = true; processBidResponseQueue(); ready.done(); @@ -188,9 +181,9 @@ function resetCurrency() { bidderCurrencyDefault = {}; } -export function addBidResponseHook(fn, adUnitCode, bid) { +export const addBidResponseHook = timedBidResponseHook('currency', function addBidResponseHook(fn, adUnitCode, bid, reject) { if (!bid) { - return fn.call(this, adUnitCode); // if no bid, call original and let it display warnings + return fn.call(this, adUnitCode, bid, reject); // if no bid, call original and let it display warnings } let bidder = bid.bidderCode || bid.bidder; @@ -216,16 +209,16 @@ export function addBidResponseHook(fn, adUnitCode, bid) { // execute immediately if the bid is already in the desired currency if (bid.currency === adServerCurrency) { - return fn.call(this, adUnitCode, bid); + return fn.call(this, adUnitCode, bid, reject); } - bidResponseQueue.push(wrapFunction(fn, this, [adUnitCode, bid])); + bidResponseQueue.push(wrapFunction(fn, this, [adUnitCode, bid, reject])); if (!currencySupportEnabled || currencyRatesLoaded) { processBidResponseQueue(); } else { - fn.bail(ready.promise()); + fn.untimed.bail(ready.promise()); } -} +}); function processBidResponseQueue() { while (bidResponseQueue.length > 0) { @@ -245,8 +238,9 @@ function wrapFunction(fn, context, params) { bid.currency = adServerCurrency; } } catch (e) { - logWarn('Returning NO_BID, getCurrencyConversion threw error: ', e); - params[1] = createBid(CONSTANTS.STATUS.NO_BID, bid.getIdentifiers()); + logWarn('getCurrencyConversion threw error: ', e); + params[2](CONSTANTS.REJECTION_REASON.CANNOT_CONVERT_CURRENCY); + return; } } return fn.apply(context, params); @@ -321,3 +315,11 @@ function roundFloat(num, dec) { } return Math.round(num * d) / d; } + +export function setOrtbCurrency(ortbRequest, bidderRequest, context) { + if (currencySupportEnabled) { + ortbRequest.cur = ortbRequest.cur || [context.currency || adServerCurrency]; + } +} + +registerOrtbProcessor({type: REQUEST, name: 'currency', fn: setOrtbCurrency}); diff --git a/modules/cwireBidAdapter.js b/modules/cwireBidAdapter.js index c0a24b49a3c..f158e16a64e 100644 --- a/modules/cwireBidAdapter.js +++ b/modules/cwireBidAdapter.js @@ -1,302 +1,253 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {getRefererInfo} from '../src/refererDetection.js'; import {getStorageManager} from '../src/storageManager.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {OUTSTREAM} from '../src/video.js'; -import { - deepAccess, - generateUUID, - getBidIdParameter, - getParameterByName, - getValue, - isArray, - isNumber, - logError, - logWarn, - parseSizesInput, -} from '../src/utils.js'; -import {Renderer} from '../src/Renderer.js'; -import {find} from '../src/polyfill.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {generateUUID, getParameterByName, isNumber, logError, logInfo} from '../src/utils.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; // ------------------------------------ const BIDDER_CODE = 'cwire'; -export const ENDPOINT_URL = 'https://embed.cwi.re/delivery/prebid'; -export const RENDERER_URL = 'https://cdn.cwi.re/prebid/renderer/LATEST/renderer.min.js'; -// ------------------------------------ -export const CW_PAGE_VIEW_ID = generateUUID(); -const LS_CWID_KEY = 'cw_cwid'; -const CW_GROUPS_QUERY = 'cwgroups'; -const CW_CREATIVE_QUERY = 'cwcreative'; +const CWID_KEY = 'cw_cwid'; -const storage = getStorageManager({bidderCode: BIDDER_CODE}); +export const BID_ENDPOINT = 'https://prebid.cwi.re/v1/bid'; +export const EVENT_ENDPOINT = 'https://prebid.cwi.re/v1/event'; /** - * ------------------------------------ - * ------------------------------------ - * @param bid - * @returns {Array} + * Allows limiting ad impressions per site render. Unique per prebid instance ID. */ -export function getSlotSizes(bid) { - return parseSizesInput(getAllMediaSizes(bid)); -} +export const pageViewId = generateUUID(); + +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); /** - * ------------------------------------ - * ------------------------------------ + * Retrieve dimensions and CSS max height/width from a given slot and attach the properties to the bidRequest. * @param bid - * @returns {*[]} + * @returns {*&{cwExt: {dimensions: {width: number, height: number}, style: {maxWidth: number, maxHeight: number}}}} */ -export function getAllMediaSizes(bid) { - let playerSizes = deepAccess(bid, 'mediaTypes.video.playerSize'); - let videoSizes = deepAccess(bid, 'mediaTypes.video.sizes'); - let bannerSizes = deepAccess(bid, 'mediaTypes.banner.sizes'); - - const sizes = []; - - if (isArray(playerSizes)) { - playerSizes.forEach((s) => { - sizes.push(s); - }) - } - - if (isArray(videoSizes)) { - videoSizes.forEach((s) => { - sizes.push(s); - }) +function slotDimensions(bid) { + let adUnitCode = bid.adUnitCode; + let slotEl = document.getElementById(adUnitCode); + + if (slotEl) { + logInfo(`Slot element found: ${adUnitCode}`) + const slotW = slotEl.offsetWidth + const slotH = slotEl.offsetHeight + const cssMaxW = slotEl.style?.maxWidth; + const cssMaxH = slotEl.style?.maxHeight; + logInfo(`Slot dimensions (w/h): ${slotW} / ${slotH}`) + logInfo(`Slot Styles (maxW/maxH): ${cssMaxW} / ${cssMaxH}`) + + bid = { + ...bid, + cwExt: { + dimensions: { + width: slotW, + height: slotH, + }, + style: { + ...(cssMaxW) && { + maxWidth: cssMaxW + }, + ...(cssMaxH) && { + maxHeight: cssMaxH + } + } + } + } } + return bid +} - if (isArray(bannerSizes)) { - bannerSizes.forEach((s) => { - sizes.push(s); - }) +/** + * Extracts feature flags from a comma-separated url parameter `cwfeatures`. + * + * @returns *[] + */ +function getFeatureFlags() { + let ffParam = getParameterByName('cwfeatures') + if (ffParam) { + return ffParam.split(',') } - return sizes; + return [] } -const getQueryVariable = (variable) => { - let value = getParameterByName(variable); - if (value === '') { - value = null; +function getRefGroups() { + const groups = getParameterByName('cwgroups') + if (groups) { + return groups.split(',') } - return value; -}; + return [] +} /** - * ------------------------------------ - * ------------------------------------ - * @param validBidRequests - * @returns {*[]} + * Reads the CWID from local storage. */ -export const mapSlotsData = function(validBidRequests) { - const slots = []; - validBidRequests.forEach(bid => { - const bidObj = {}; - // get testing / debug params - let cwcreative = getValue(bid.params, 'cwcreative'); - let refgroups = getValue(bid.params, 'refgroups'); - let cwapikey = getValue(bid.params, 'cwapikey'); +function getCwid() { + return storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(CWID_KEY) : null; +} - // get the pacement and page ids - let placementId = getValue(bid.params, 'placementId'); - let pageId = getValue(bid.params, 'pageId'); - // get the rest of the auction/bid/transaction info - bidObj.auctionId = getBidIdParameter('auctionId', bid); - bidObj.adUnitCode = getBidIdParameter('adUnitCode', bid); - bidObj.bidId = getBidIdParameter('bidId', bid); - bidObj.bidderRequestId = getBidIdParameter('bidderRequestId', bid); - bidObj.placementId = placementId; - bidObj.pageId = pageId; - bidObj.mediaTypes = getBidIdParameter('mediaTypes', bid); - bidObj.transactionId = getBidIdParameter('transactionId', bid); - bidObj.sizes = getSlotSizes(bid); - bidObj.cwcreative = cwcreative; - bidObj.refgroups = refgroups; - bidObj.cwapikey = cwapikey; - slots.push(bidObj); - }); +function hasCwid() { + return storage.localStorageIsEnabled() && storage.getDataFromLocalStorage(CWID_KEY); +} - return slots; -}; +/** + * Store the CWID to local storage. + */ +function updateCwid(cwid) { + if (storage.localStorageIsEnabled()) { + storage.setDataInLocalStorage(CWID_KEY, cwid) + } else { + logInfo(`Could not set CWID ${cwid} in localstorage`); + } +} + +/** + * Extract and collect cwire specific extensions. + */ +function getCwExtension() { + const cwId = getCwid(); + const cwCreative = getParameterByName('cwcreative') + const cwGroups = getRefGroups() + const cwFeatures = getFeatureFlags(); + // Enable debug flag by passing ?cwdebug=true as url parameter. + // Note: pbjs_debug=true enables it on prebid level + // More info: https://docs.prebid.org/troubleshooting/troubleshooting-guide.html#turn-on-prebidjs-debug-messages + const debug = getParameterByName('cwdebug'); + + return { + ...(cwId) && { + cwid: cwId + }, + ...(cwGroups.length > 0) && { + refgroups: cwGroups + }, + ...(cwFeatures.length > 0) && { + featureFlags: cwFeatures + }, + ...(cwCreative) && { + cwcreative: cwCreative + }, + ...(debug) && { + debug: true + } + }; +} export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], + supportedMediaTypes: [BANNER], + /** - * Determines whether or not the given bid request is valid. + * Determines whether the given bid request is valid. * * @param {BidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. */ - isBidRequestValid: function(bid) { - bid.params = bid.params || {}; - - if (!bid.params.placementId || !isNumber(bid.params.placementId)) { - logError('placementId not provided or invalid'); + isBidRequestValid: function (bid) { + if (!bid.params?.placementId || !isNumber(bid.params.placementId)) { + logError('placementId not provided or not a number'); return false; } - if (!bid.params.pageId || !isNumber(bid.params.pageId)) { - logError('pageId not provided'); + if (!bid.params?.pageId || !isNumber(bid.params.pageId)) { + logError('pageId not provided or not a number'); return false; } - return true; }, /** - * ------------------------------------ - * itterate trough slots array and try - * to extract first occurence of a given - * key, if not found - return null - * ------------------------------------ - */ - getFirstValueOrNull: function(slots, key) { - const found = slots.find((item) => { - return (typeof item[key] !== 'undefined'); - }); - - return (found) ? found[key] : null; - }, - - /** - * ------------------------------------ - * Make a server request from the - * list of BidRequests. - * ------------------------------------ - * @param {validBidRequests[]} - an array of bids + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} validBidRequests An array of bids. * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(validBidRequests, bidderRequest) { - let slots = []; - let referer; - try { - referer = getRefererInfo().referer; - slots = mapSlotsData(validBidRequests); - } catch (e) { - logWarn(e); - } + buildRequests: function (validBidRequests, bidderRequest) { + // There are more fields on the refererInfo object + let referrer = bidderRequest?.refererInfo?.page - let refgroups = []; - - const cwCreativeId = parseInt(getQueryVariable(CW_CREATIVE_QUERY), 10) || null; - const cwCreativeIdFromConfig = this.getFirstValueOrNull(slots, 'cwcreative'); - const refGroupsFromConfig = this.getFirstValueOrNull(slots, 'refgroups'); - const cwApiKeyFromConfig = this.getFirstValueOrNull(slots, 'cwapikey'); - const rgQuery = getQueryVariable(CW_GROUPS_QUERY); - - if (refGroupsFromConfig !== null) { - refgroups = refGroupsFromConfig.split(','); - } - - if (rgQuery !== null) { - // override if query param is present - refgroups = []; - refgroups = rgQuery.split(','); - } - - const localStorageCWID = storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(LS_CWID_KEY) : null; + // process bid requests + let processed = validBidRequests + .map(bid => slotDimensions(bid)) + // Flattens the pageId and placement Id for backwards compatibility. + .map((bid) => ({...bid, pageId: bid.params?.pageId, placementId: bid.params?.placementId})); + const extensions = getCwExtension(); const payload = { - cwid: localStorageCWID, - refgroups, - cwcreative: cwCreativeId || cwCreativeIdFromConfig, - slots: slots, - cwapikey: cwApiKeyFromConfig, - httpRef: referer || '', - pageViewId: CW_PAGE_VIEW_ID, + slots: processed, + httpRef: referrer, + // TODO: Verify whether the auctionId and the usage of pageViewId make sense. + pageViewId: pageViewId, + sdk: { + version: '$prebid.version$' + }, + ...extensions }; - + const payloadString = JSON.stringify(payload); return { method: 'POST', - url: ENDPOINT_URL, - data: payload + url: BID_ENDPOINT, + data: payloadString, }; }, - /** * Unpack the response from the server into a list of bids. * * @param {ServerResponse} serverResponse A successful response from the server. * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - - try { - if (typeof bidRequest.data === 'string') { - bidRequest.data = JSON.parse(bidRequest.data); + interpretResponse: function (serverResponse, bidRequest) { + if (!hasCwid()) { + const cwid = serverResponse.body?.cwid + if (cwid) { + updateCwid(cwid); } - const serverBody = serverResponse.body; - serverBody.bids.forEach((br) => { - const bidReq = find(bidRequest.data.slots, bid => bid.bidId === br.requestId); - - let mediaType = BANNER; - - const bidResponse = { - requestId: br.requestId, - cpm: br.cpm, - bidderCode: BIDDER_CODE, - width: br.dimensions[0], - height: br.dimensions[1], - creativeId: br.creativeId, - currency: br.currency, - netRevenue: br.netRevenue, - ttl: br.ttl, - meta: { - advertiserDomains: br.adomains ? br.advertiserDomains : [], - }, - - }; + } - // ------------------------------------ - // IF BANNER - // ------------------------------------ + // Rename `html` response property to `ad` as used by prebid. + const bids = serverResponse.body?.bids.map(({html, ...rest}) => ({...rest, ad: html})); + return bids || []; + }, - if (deepAccess(bidReq, 'mediaTypes.banner')) { - bidResponse.ad = br.html; - } - // ------------------------------------ - // IF VIDEO - // ------------------------------------ - if (deepAccess(bidReq, 'mediaTypes.video')) { - mediaType = VIDEO; - bidResponse.vastXml = br.vastXml; - bidResponse.videoScript = br.html; - const mediaTypeContext = deepAccess(bidReq, 'mediaTypes.video.context'); - if (mediaTypeContext === OUTSTREAM) { - const r = Renderer.install({ - id: bidResponse.requestId, - adUnitCode: bidReq.adUnitCode, - url: RENDERER_URL, - loaded: false, - config: { - ...deepAccess(bidReq, 'mediaTypes.video'), - ...deepAccess(br, 'outstream', {}) - } - }); + onBidWon: function (bid) { + logInfo(`Bid won.`) + const event = { + type: 'BID_WON', + payload: { + bid: bid + } + } + navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) + }, - // set renderer - try { - bidResponse.renderer = r; - bidResponse.renderer.setRender(function(bid) { - if (window.CWIRE && window.CWIRE.outstream) { - window.CWIRE.outstream.renderAd(bid); - } - }); - } catch (err) { - logWarn('Prebid Error calling setRender on newRenderer', err); - } - } - } + onBidderError: function (error, bidderRequest) { + logInfo(`Bidder error: ${error}`) + const event = { + type: 'BID_ERROR', + payload: { + error: error, + bidderRequest: bidderRequest + } + } + navigator.sendBeacon(EVENT_ENDPOINT, JSON.stringify(event)) + }, - bidResponse.mediaType = mediaType; - bidResponses.push(bidResponse); - }); - } catch (e) { - logWarn(e); + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + logInfo('Collecting user-syncs: ', JSON.stringify({syncOptions, gdprConsent, uspConsent, serverResponses})); + + const syncs = [] + if (hasPurpose1Consent(gdprConsent)) { + logInfo('GDPR purpose 1 consent was given, adding user-syncs') + let type = (syncOptions.pixelEnabled) ? 'image' : null ?? (syncOptions.iframeEnabled) ? 'iframe' : null + if (type) { + syncs.push({ + type: type, + url: 'https://ib.adnxs.com/getuid?https://prebid.cwi.re/v1/cookiesync?xandrId=$UID' + }) + } } + logInfo('Collected user-syncs: ', JSON.stringify({syncs})) + return syncs + } - return bidResponses; - }, -} +}; registerBidder(spec); diff --git a/modules/cwireBidAdapter.md b/modules/cwireBidAdapter.md index b42c7a02489..9804250b906 100644 --- a/modules/cwireBidAdapter.md +++ b/modules/cwireBidAdapter.md @@ -1,25 +1,27 @@ # Overview -Module Name: C-WIRE Bid Adapter -Module Type: Adagio Adapter -Maintainer: publishers@cwire.ch +``` +Module Name: C-WIRE Bid Adapter +Module Type: Bidder Adapter +Maintainer: devs@cwire.com +``` ## Description -Connects to C-WIRE demand source to fetch bids. +Prebid.js Adapter for C-Wire. ## Configuration - Below, the list of C-WIRE params and where they can be set. -| Param name | Global config | AdUnit config | Type | Required | -| ---------- | ------------- | ------------- | ---- | ---------| -| pageId | | x | number | YES | -| placementId | | x | number | YES | -| refgroups | | x | string | NO | -| cwcreative | | x | integer | NO | -| cwapikey | | x | string | NO | +| Param name | URL parameter | AdUnit config | Type | Required | +|-------------|:-------------:|:-------------:|:--------:|:-------------:| +| pageId | | x | number | YES | +| placementId | | x | number | YES | +| cwgroups | x | | string | NO | +| cwcreative | x | | string | NO | +| cwdebug | x | | boolean | NO | +| cwfeatures | x | | string | NO | ### adUnit configuration @@ -32,17 +34,22 @@ var adUnits = [ bidder: 'cwire', mediaTypes: { banner: { - sizes: [[1, 1]], + sizes: [[400, 600]], } }, params: { pageId: 1422, // required - number placementId: 2211521, // required - number - cwcreative: 42, // optional - id of creative to force - refgroups: 'test-user', // optional - name of group or coma separated list of groups to force - cwapikey: 'api_key_xyz', // optional - api key for integration testing } }] } ]; ``` + +### URL parameters + +For debugging and testing purposes url parameters can be set. + +**Example:** + +`https://www.some-site.com/article.html?cwdebug=true&cwfeatures=feature1,feature2&cwcreative=1234` diff --git a/modules/czechAdIdSystem.js b/modules/czechAdIdSystem.js new file mode 100644 index 00000000000..ae958aae198 --- /dev/null +++ b/modules/czechAdIdSystem.js @@ -0,0 +1,54 @@ +/** + * This module adds 'caid' to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/czechAdIdSystem + * @requires module:modules/userId + */ + +import { submodule } from '../src/hook.js' +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; + +// Returns StorageManager +export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: 'czechAdId' }) + +// Returns the id string from either cookie or localstorage +const readId = () => { return storage.getCookie('czaid') || storage.getDataFromLocalStorage('czaid') } + +/** @type {Submodule} */ +export const czechAdIdSubmodule = { + version: '0.1.0', + /** + * used to link submodule with config + * @type {string} + */ + name: 'czechAdId', + /** + * Vendor ID of Czech Publisher Exchange + * @type {Number} + */ + gvlid: 570, + /** + * decode the stored id value for passing to bid requests + * @function decode + * @returns {(Object|undefined)} + */ + decode () { return { czechAdId: readId() } }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @returns {IdResponse|undefined} + */ + getId () { + const id = readId() + return id ? { id: id } : undefined + }, + eids: { + 'czechAdId': { + source: 'czechadid.cz', + atype: 1 + }, + } +} + +submodule('userId', czechAdIdSubmodule) diff --git a/modules/czechAdIdSystem.md b/modules/czechAdIdSystem.md new file mode 100644 index 00000000000..5614016f524 --- /dev/null +++ b/modules/czechAdIdSystem.md @@ -0,0 +1,27 @@ +## CzechAdId User ID Submodule + +Czech Ad ID is a joint project of publishers of the [CPEx alliance](https://www.cpex.cz/) and [Seznam.cz](https://www.seznam.cz). It is a deterministic user ID that offers cross-domain and cross-device identification. For more information see [czechadid.cz](https://www.czechadid.cz)). + +## Building Prebid with CzechAdId Support + +First, make sure to add the czechAdId to your Prebid.js package with: + +``` +gulp build --modules=czechAdIdSystem +``` + +The following configuration parameters are available: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'czechAdId' + }] + } +}); +``` + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | The name of this module. | `"czechAdId"` | diff --git a/modules/dacIdSystem.js b/modules/dacIdSystem.js index 73b5c7420cf..ffdadef18e8 100644 --- a/modules/dacIdSystem.js +++ b/modules/dacIdSystem.js @@ -5,53 +5,178 @@ * @requires module:modules/userId */ -import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import { + logError, + logInfo, + logWarn +} from '../src/utils.js'; +import { + ajax +} from '../src/ajax.js' +import { + submodule +} from '../src/hook.js'; +import { + getStorageManager +} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +const MODULE_NAME = 'dacId'; +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); -export const storage = getStorageManager(); +export const FUUID_COOKIE_NAME = '_a1_f'; +export const AONEID_COOKIE_NAME = '_a1_d'; +export const API_URL = 'https://penta.a.one.impact-ad.jp/aud'; +const COOKIES_EXPIRES = 60 * 60 * 24 * 1000; // 24h +const LOG_PREFIX = 'User ID - dacId submodule: '; -export const cookieKey = '_a1_f'; +/** + * @returns {{fuuid: string, uid: string}} - + */ +function getCookieId() { + return { + fuuid: storage.getCookie(FUUID_COOKIE_NAME), + uid: storage.getCookie(AONEID_COOKIE_NAME) + }; +} + +/** + * set uid to cookie. + * @param {string} uid - + * @returns {void} - + */ +function setAoneidToCookie(uid) { + if (uid) { + const expires = new Date(Date.now() + COOKIES_EXPIRES).toUTCString(); + storage.setCookie( + AONEID_COOKIE_NAME, + uid, + expires, + 'none' + ); + } +} + +/** + * @param {string} oid - + * @param {string} fuuid - + * @returns {string} - + */ +function getApiUrl(oid, fuuid) { + return `${API_URL}?oid=${oid}&fu=${fuuid}`; +} + +/** + * @param {string} oid - + * @param {string} fuuid - + * @returns {{callback: function}} - + */ +function fetchAoneId(oid, fuuid) { + return { + callback: (callback) => { + const ret = { + fuuid, + uid: undefined + }; + const callbacks = { + success: (response) => { + if (response) { + try { + const responseObj = JSON.parse(response); + if (responseObj.error) { + logWarn(LOG_PREFIX + 'There is no permission to use API: ' + responseObj.error); + return callback(ret); + } + if (!responseObj.uid) { + logWarn(LOG_PREFIX + 'AoneId is null'); + return callback(ret); + } + ret.uid = responseObj.uid; + setAoneidToCookie(ret.uid); + } catch (error) { + logError(LOG_PREFIX + error); + } + } + callback(ret); + }, + error: (error) => { + logError(LOG_PREFIX + error); + callback(ret); + } + }; + const apiUrl = getApiUrl(oid, fuuid); + ajax(apiUrl, callbacks, undefined, { + method: 'GET', + withCredentials: true + }); + }, + }; +} export const dacIdSystemSubmodule = { /** * used to link submodule with config * @type {string} */ - name: 'dacId', + name: MODULE_NAME, /** - * performs action to obtain id - * @function - * @returns { {id: {dacId: string}} | undefined } + * decode the stored id value for passing to bid requests + * @param { {fuuid: string, uid: string} } id + * @returns { {dacId: {fuuid: string, dacId: string} } | undefined } */ - getId: function() { - const newId = storage.getCookie(cookieKey); - if (!newId) { - return undefined; - } - const result = { - dacId: newId + decode(id) { + if (id && typeof id === 'object') { + return { + dacId: { + fuuid: id.fuuid, + id: id.uid + } + } } - return {id: result}; }, /** - * decode the stored id value for passing to bid requests + * performs action to obtain id * @function - * @param { {dacId: string} } value - * @returns { {dacId: {id: string} } | undefined } + * @returns { {id: {fuuid: string, uid: string}} | undefined } */ - decode: function(value) { - if (value && typeof value === 'object') { - const result = {}; - if (value.dacId) { - result.id = value.dacId - } - return {dacId: result}; + getId(config) { + const cookie = getCookieId(); + + if (!cookie.fuuid) { + logInfo(LOG_PREFIX + 'There is no fuuid in cookie') + return undefined; } - return undefined; - }, -} + if (cookie.fuuid && cookie.uid) { + logInfo(LOG_PREFIX + 'There is fuuid and AoneId in cookie') + return { + id: { + fuuid: cookie.fuuid, + uid: cookie.uid + } + }; + } + + const configParams = (config && config.params) || {}; + if (!configParams || typeof configParams.oid !== 'string') { + logWarn(LOG_PREFIX + 'oid is not defined'); + return { + id: { + fuuid: cookie.fuuid, + uid: undefined + } + }; + } + + return fetchAoneId(configParams.oid, cookie.fuuid); + }, + eids: { + 'dacId': { + source: 'impact-ad.jp', + atype: 1 + }, + } +}; submodule('userId', dacIdSystemSubmodule); diff --git a/modules/dacIdSystem.md b/modules/dacIdSystem.md index b422d0a536d..c78b8ff2741 100644 --- a/modules/dacIdSystem.md +++ b/modules/dacIdSystem.md @@ -1,11 +1,11 @@ -## DAC User ID Submodule +## AudienceOne User ID Submodule -DAC ID, provided by [D.A.Consortium Inc.](https://www.dac.co.jp/), is ID for ad targeting by using 1st party cookie. -Please contact D.A.Consortium Inc. before using this ID. +AudienceOne ID, provided by [D.A.Consortium Inc.](https://www.dac.co.jp/), is ID for ad targeting by using 1st party cookie. +Please visit [https://solutions.dac.co.jp/audienceone](https://solutions.dac.co.jp/audienceone) and request your Owner ID to get started. -## Building Prebid with DAC ID Support +## Building Prebid with AudienceOne ID Support -First, make sure to add the DAC ID submodule to your Prebid.js package with: +First, make sure to add the AudienceOne ID submodule to your Prebid.js package with: ``` gulp build --modules=dacIdSystem @@ -17,7 +17,10 @@ The following configuration parameters are available: pbjs.setConfig({ userSync: { userIds: [{ - name: 'dacId' + name: 'dacId', + params: { + 'oid': '55h67qm4ck37vyz5' + } }] } }); @@ -26,3 +29,5 @@ pbjs.setConfig({ | Param under userSync.userIds[] | Scope | Type | Description | Example | | --- | --- | --- | --- | --- | | name | Required | String | The name of this module. | `"dacId"` | +| params | Required | Object | Details of module params. | | +| params.oid | Required | String | This is the Owner ID value obtained via D.A.Consortium Inc. | `"55h67qm4ck37vyz5"` | \ No newline at end of file diff --git a/modules/dailyhuntBidAdapter.js b/modules/dailyhuntBidAdapter.js index ffa84ff88fd..f96e07b71bf 100644 --- a/modules/dailyhuntBidAdapter.js +++ b/modules/dailyhuntBidAdapter.js @@ -4,6 +4,7 @@ import {_map, deepAccess, isEmpty} from '../src/utils.js'; import {ajax} from '../src/ajax.js'; import {find} from '../src/polyfill.js'; import {INSTREAM, OUTSTREAM} from '../src/video.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; const BIDDER_CODE = 'dailyhunt'; const BIDDER_ALIAS = 'dh'; @@ -96,9 +97,9 @@ const flatten = (arr) => { const createOrtbRequest = (validBidRequests, bidderRequest) => { let device = createOrtbDeviceObj(validBidRequests); let user = createOrtbUserObj(validBidRequests) - let site = createOrtbSiteObj(validBidRequests, bidderRequest.refererInfo.referer) + let site = createOrtbSiteObj(validBidRequests, bidderRequest.refererInfo.page) return { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: [], site, device, @@ -384,6 +385,9 @@ export const spec = { isBidRequestValid: bid => !!bid.params.placement_id && !!bid.params.publisher_id && !!bid.params.partner_name, buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let serverRequests = []; // ORTB Request. diff --git a/modules/danmarketBidAdapter.md b/modules/danmarketBidAdapter.md deleted file mode 100644 index 8ddc83d2cf6..00000000000 --- a/modules/danmarketBidAdapter.md +++ /dev/null @@ -1,40 +0,0 @@ -# Overview - -Module Name: Dentsu Aegis Network Marketplace Bidder Adapter -Module Type: Bidder Adapter -Maintainer: niels@baarsma.net - -# Description - -Module that connects to DAN Marketplace demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "danmarket", - params: { - uid: '4', - priceType: 'gross' // by default is 'net' - } - } - ] - },{ - code: 'test-div', - sizes: [[728, 90]], - bids: [ - { - bidder: "danmarket", - params: { - uid: 5, - priceType: 'gross' - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/dataControllerModule/index.js b/modules/dataControllerModule/index.js new file mode 100644 index 00000000000..b1866e3783f --- /dev/null +++ b/modules/dataControllerModule/index.js @@ -0,0 +1,196 @@ +/** + * This module validates the configuration and filters data accordingly + * @module modules/dataController + */ +import {config} from '../../src/config.js'; +import {getHook, module} from '../../src/hook.js'; +import {deepAccess, deepSetValue, prefixLog} from '../../src/utils.js'; +import {startAuction} from '../../src/prebid.js'; +import {timedAuctionHook} from '../../src/utils/perfMetrics.js'; + +const LOG_PRE_FIX = 'Data_Controller : '; +const ALL = '*'; +const MODULE_NAME = 'dataController'; +const GLOBAL = {}; +let _dataControllerConfig; + +const _logger = prefixLog(LOG_PRE_FIX); + +/** + * BidderRequests hook to intiate module and reset data object + */ +export const filterBidData = timedAuctionHook('dataController', function filterBidData(fn, req) { + if (_dataControllerConfig.filterEIDwhenSDA) { + filterEIDs(req.adUnits, req.ortb2Fragments); + } + + if (_dataControllerConfig.filterSDAwhenEID) { + filterSDA(req.adUnits, req.ortb2Fragments); + } + fn.call(this, req); + return req; +}); + +function containsConfiguredEIDS(eidSourcesMap, bidderCode) { + if (_dataControllerConfig.filterSDAwhenEID.includes(ALL)) { + return true; + } + let bidderEIDs = eidSourcesMap.get(bidderCode); + if (bidderEIDs == undefined) { + return false; + } + let containsEIDs = false; + _dataControllerConfig.filterSDAwhenEID.some(source => { + if (bidderEIDs.has(source)) { + containsEIDs = true; + } + }); + return containsEIDs; +} + +function containsConfiguredSDA(segementMap, bidderCode) { + if (_dataControllerConfig.filterEIDwhenSDA.includes(ALL)) { + return true; + } + return hasValue(segementMap.get(bidderCode)) || hasValue(segementMap.get(GLOBAL)) +} + +function hasValue(bidderSegement) { + let containsSDA = false; + if (bidderSegement == undefined) { + return false; + } + _dataControllerConfig.filterEIDwhenSDA.some(segment => { + if (bidderSegement.has(segment)) { + containsSDA = true; + } + }); + return containsSDA; +} + +function getSegmentConfig(ortb2Fragments) { + let bidderSDAMap = new Map(); + let globalObject = deepAccess(ortb2Fragments, 'global') || {}; + + collectSegments(bidderSDAMap, GLOBAL, globalObject); + if (ortb2Fragments.bidder) { + for (const [key, value] of Object.entries(ortb2Fragments.bidder)) { + collectSegments(bidderSDAMap, key, value); + } + } + return bidderSDAMap; +} + +function collectSegments(bidderSDAMap, key, data) { + let segmentSet = constructSegment(deepAccess(data, 'user.data') || []); + if (segmentSet && segmentSet.size > 0) bidderSDAMap.set(key, segmentSet); +} + +function constructSegment(userData) { + let segmentSet; + if (userData) { + segmentSet = new Set(); + for (let i = 0; i < userData.length; i++) { + let segments = userData[i].segment; + let segmentPrefix = ''; + if (userData[i].name) { + segmentPrefix = userData[i].name + ':'; + } + + if (userData[i].ext && userData[i].ext.segtax) { + segmentPrefix += userData[i].ext.segtax + ':'; + } + for (let j = 0; j < segments.length; j++) { + segmentSet.add(segmentPrefix + segments[j].id); + } + } + } + + return segmentSet; +} + +function getEIDsSource(adUnits) { + let bidderEIDSMap = new Map(); + adUnits.forEach(adUnit => { + (adUnit.bids || []).forEach(bid => { + let userEIDs = deepAccess(bid, 'userIdAsEids') || []; + + if (userEIDs) { + let sourceSet = new Set(); + for (let i = 0; i < userEIDs.length; i++) { + let source = userEIDs[i].source; + sourceSet.add(source); + } + bidderEIDSMap.set(bid.bidder, sourceSet); + } + }); + }); + + return bidderEIDSMap; +} + +function filterSDA(adUnits, ortb2Fragments) { + let bidderEIDSMap = getEIDsSource(adUnits); + let resetGlobal = false; + for (const [key, value] of Object.entries(ortb2Fragments.bidder)) { + let resetSDA = containsConfiguredEIDS(bidderEIDSMap, key); + if (resetSDA) { + deepSetValue(value, 'user.data', []); + resetGlobal = true; + } + } + if (resetGlobal) { + deepSetValue(ortb2Fragments, 'global.user.data', []) + } +} + +function filterEIDs(adUnits, ortb2Fragments) { + let segementMap = getSegmentConfig(ortb2Fragments); + let globalEidUpdate = false; + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + let resetEID = containsConfiguredSDA(segementMap, bid.bidder); + if (resetEID) { + globalEidUpdate = true; + bid.userIdAsEids = []; + bid.userId = {}; + if (ortb2Fragments.bidder) { + let bidderFragment = ortb2Fragments.bidder[bid.bidder]; + let userExt = deepAccess(bidderFragment, 'user.ext.eids') || []; + if (userExt) { + deepSetValue(bidderFragment, 'user.ext.eids', []) + } + } + } + }); + }); + + if (globalEidUpdate) { + deepSetValue(ortb2Fragments, 'global.user.ext.eids', []) + } + return adUnits; +} + +export function init() { + const confListener = config.getConfig(MODULE_NAME, dataControllerConfig => { + const dataController = dataControllerConfig && dataControllerConfig.dataController; + if (!dataController) { + _logger.logInfo(`Data Controller is not configured`); + startAuction.getHooks({hook: filterBidData}).remove(); + return; + } + + if (dataController.filterEIDwhenSDA && dataController.filterSDAwhenEID) { + _logger.logInfo(`Data Controller can be configured with either filterEIDwhenSDA or filterSDAwhenEID`); + startAuction.getHooks({hook: filterBidData}).remove(); + return; + } + confListener(); // unsubscribe config listener + _dataControllerConfig = dataController; + + getHook('startAuction').before(filterBidData); + }); +} + +init(); +module(MODULE_NAME, init); diff --git a/modules/dataControllerModule/index.md b/modules/dataControllerModule/index.md new file mode 100644 index 00000000000..8714b886b0e --- /dev/null +++ b/modules/dataControllerModule/index.md @@ -0,0 +1,29 @@ +# Overview + +``` +Module Name: Data Controller Module +``` + +# Description + +This module will filter EIDs and SDA based on the configurations. + +Sub module object with the following keys: + +| param name | type | Scope | Description | Params | +| :------------ | :------------ | :------ | :------ | :------ | +| filterEIDwhenSDA | function | optional | Filters user EIDs based on SDA | bidrequest | +| filterSDAwhenEID | function | optional | Filters SDA based on configured EIDs | bidrequest | + +# Module Control Configuration + +``` + +pbjs.setConfig({ + dataController: { + filterEIDwhenSDA: ['*'] + filterSDAwhenEID: ['id5-sync.com'] + } +}); + +``` diff --git a/modules/datablocksAnalyticsAdapter.js b/modules/datablocksAnalyticsAdapter.js index 5e977155284..61933cc45e9 100644 --- a/modules/datablocksAnalyticsAdapter.js +++ b/modules/datablocksAnalyticsAdapter.js @@ -2,7 +2,7 @@ * Analytics Adapter for Datablocks */ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; var datablocksAdapter = adapter({ diff --git a/modules/datablocksBidAdapter.js b/modules/datablocksBidAdapter.js index b240db1dd25..395706994fe 100644 --- a/modules/datablocksBidAdapter.js +++ b/modules/datablocksBidAdapter.js @@ -1,9 +1,12 @@ -import { getWindowTop, isGptPubadsDefined, deepAccess, getAdUnitSizes, isEmpty } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, NATIVE } from '../src/mediaTypes.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { ajax } from '../src/ajax.js'; +import {deepAccess, getWindowTop, isEmpty, isGptPubadsDefined} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {ajax} from '../src/ajax.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; + export const storage = getStorageManager({bidderCode: 'datablocks'}); const NATIVE_ID_MAP = {}; @@ -228,6 +231,7 @@ export const spec = { let scope = this; if (isGptPubadsDefined()) { if (typeof window['googletag'].pubads().addEventListener == 'function') { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 window['googletag'].pubads().addEventListener('impressionViewable', function(event) { scope.queue_metric({type: 'slot_view', source_id: scope.db_obj.source_id, auction_id: bid.auctionId, div_id: event.slot.getSlotElementId(), slot_id: event.slot.getSlotId().getAdUnitPath()}); }); @@ -252,6 +256,9 @@ export const spec = { // GENERATE THE RTB REQUEST buildRequests: function(validRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validRequests = convertOrtbRequestToProprietaryNative(validRequests); + // RETURN EMPTY IF THERE ARE NO VALID REQUESTS if (!validRequests.length) { return []; @@ -347,16 +354,17 @@ export const spec = { // GENERATE SITE OBJECT let site = { domain: window.location.host, - page: bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + page: bidderRequest.refererInfo.page, schain: validRequests[0].schain || {}, ext: { - p_domain: config.getConfig('publisherDomain'), + p_domain: bidderRequest.refererInfo.domain, rt: bidderRequest.refererInfo.reachedTop, frames: bidderRequest.refererInfo.numIframes, stack: bidderRequest.refererInfo.stack, timeout: config.getConfig('bidderTimeout') }, - } + }; // ADD REF URL IF FOUND if (self === top && document.referrer) { @@ -383,7 +391,7 @@ export const spec = { gdpr: bidderRequest.gdprConsent || {}, usp: bidderRequest.uspConsent || {}, client_info: this.get_client_info(), - ortb2: config.getConfig('ortb2') || {} + ortb2: bidderRequest.ortb2 || {} } }; @@ -395,7 +403,7 @@ export const spec = { method: 'POST', url: `https://${host}/openrtb/?sid=${sourceId}`, data: { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: imps, site: site, device: device diff --git a/modules/datawrkzBidAdapter.js b/modules/datawrkzBidAdapter.js new file mode 100644 index 00000000000..127e7893ec5 --- /dev/null +++ b/modules/datawrkzBidAdapter.js @@ -0,0 +1,655 @@ +import { + deepAccess, + isArray, + getUniqueIdentifierStr, + contains, + isFn, + isPlainObject, + getBidIdParameter +} from '../src/utils.js'; +import { config } from '../src/config.js'; +import { Renderer } from '../src/Renderer.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { createBid } from '../src/bidfactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import CONSTANTS from '../src/constants.json'; +import { OUTSTREAM, INSTREAM } from '../src/video.js'; + +const BIDDER_CODE = 'datawrkz'; +const ALIASES = []; +const ENDPOINT_URL = 'https://at.datawrkz.com/exchange/openrtb23/'; +const RENDERER_URL = 'https://js.datawrkz.com/prebid/osRenderer.min.js'; +const OUTSTREAM_TYPES = ['inline', 'slider_top_left', 'slider_top_right', 'slider_bottom_left', 'slider_bottom_right', 'interstitial_close', 'listicle'] +const OUTSTREAM_MIMES = ['video/mp4'] +const SUPPORTED_AD_TYPES = [BANNER, NATIVE, VIDEO]; + +export const spec = { + code: BIDDER_CODE, + aliases: ALIASES, + supportedMediaTypes: SUPPORTED_AD_TYPES, + /** + * Determines whether or not the given bid request is valid. + * + * @param {object} bid The bid to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params && bid.params.site_id && (deepAccess(bid, 'mediaTypes.video.context') != 'adpod')); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + let requests = []; + + if (validBidRequests.length > 0) { + validBidRequests.forEach(bidRequest => { + if (!bidRequest.mediaTypes) return; + if (bidRequest.mediaTypes.banner && ((bidRequest.mediaTypes.banner.sizes && bidRequest.mediaTypes.banner.sizes.length != 0) || + (bidRequest.sizes))) { + requests.push(buildBannerRequest(bidRequest, bidderRequest)); + } else if (bidRequest.mediaTypes.native) { + requests.push(buildNativeRequest(bidRequest, bidderRequest)); + } else if (bidRequest.mediaTypes.video) { + requests.push(buildVideoRequest(bidRequest, bidderRequest)); + } + }); + } + return requests; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, request) { + var bidResponses = []; + let bidRequest = request.bidRequest + let bidResponse = serverResponse.body; + + // valid object? + if ((!bidResponse || !bidResponse.id) || (!bidResponse.seatbid || bidResponse.seatbid.length === 0 || + !bidResponse.seatbid[0].bid || bidResponse.seatbid[0].bid.length === 0)) { + return []; + } + + if (getMediaTypeOfResponse(bidRequest) == BANNER) { + bidResponses = buildBannerResponse(bidRequest, bidResponse); + } else if (getMediaTypeOfResponse(bidRequest) == NATIVE) { + bidResponses = buildNativeResponse(bidRequest, bidResponse); + } else if (getMediaTypeOfResponse(bidRequest) == VIDEO) { + bidResponses = buildVideoResponse(bidRequest, bidResponse); + } + return bidResponses; + }, +} + +/* Generate bid request for banner adunit */ +function buildBannerRequest(bidRequest, bidderRequest) { + let bidFloor = getBidFloor(bidRequest); + + let adW = 0; + let adH = 0; + + let bannerSizes = deepAccess(bidRequest, 'mediaTypes.banner.sizes'); + let bidSizes = isArray(bannerSizes) ? bannerSizes : bidRequest.sizes; + if (isArray(bidSizes)) { + if (bidSizes.length === 2 && typeof bidSizes[0] === 'number' && typeof bidSizes[1] === 'number') { + adW = parseInt(bidSizes[0]); + adH = parseInt(bidSizes[1]); + } else { + adW = parseInt(bidSizes[0][0]); + adH = parseInt(bidSizes[0][1]); + } + } + + var deals = []; + if (bidRequest.params.deals && bidRequest.params.deals.length > 0) { + deals = bidRequest.params.deals; + } + + const imp = [{ + id: bidRequest.bidId, + banner: { + w: adW, + h: adH + }, + bidfloor: bidFloor, + pmp: { + deals: deals + } + }]; + + bidRequest.requestedMediaType = BANNER; + const scriptUrl = generateScriptUrl(bidRequest); + const payloadString = generatePayload(imp, bidderRequest); + + return { + method: 'POST', + url: scriptUrl, + data: payloadString, + bidRequest + }; +} + +/* Generate bid request for native adunit */ +function buildNativeRequest(bidRequest, bidderRequest) { + let counter = 0; + let assets = []; + + let bidFloor = getBidFloor(bidRequest); + + let title = deepAccess(bidRequest, 'mediaTypes.native.title'); + if (title && title.len) { + assets.push(generateNativeTitleObj(title, ++counter)); + } + let image = deepAccess(bidRequest, 'mediaTypes.native.image'); + if (image) { + assets.push(generateNativeImgObj(image, 'image', ++counter)); + } + let icon = deepAccess(bidRequest, 'mediaTypes.native.icon'); + if (icon) { + assets.push(generateNativeImgObj(icon, 'icon', ++counter)); + } + let sponsoredBy = deepAccess(bidRequest, 'mediaTypes.native.sponsoredBy'); + if (sponsoredBy) { + assets.push(generateNativeDataObj(sponsoredBy, 'sponsored', ++counter)); + } + let cta = deepAccess(bidRequest, 'mediaTypes.native.cta'); + if (cta) { + assets.push(generateNativeDataObj(cta, 'cta', ++counter)); + } + let body = deepAccess(bidRequest, 'mediaTypes.native.body'); + if (body) { + assets.push(generateNativeDataObj(body, 'desc', ++counter)); + } + + let request = JSON.stringify({assets: assets}); + const native = { + request: request + }; + + var deals = []; + if (bidRequest.params.deals && bidRequest.params.deals.length > 0) { + deals = bidRequest.params.deals; + } + + const imp = [{ + id: bidRequest.bidId, + native: native, + bidfloor: bidFloor, + pmp: { + deals: deals + } + }]; + + bidRequest.requestedMediaType = NATIVE; + bidRequest.assets = assets; + const scriptUrl = generateScriptUrl(bidRequest); + const payloadString = generatePayload(imp, bidderRequest); + + return { + method: 'POST', + url: scriptUrl, + data: payloadString, + bidRequest + }; +} + +/* Generate bid request for video adunit */ +function buildVideoRequest(bidRequest, bidderRequest) { + let bidFloor = getBidFloor(bidRequest); + + let sizeObj = getVideoAdUnitSize(bidRequest); + + const video = { + w: sizeObj.adW, + h: sizeObj.adH, + api: deepAccess(bidRequest, 'mediaTypes.video.api'), + mimes: deepAccess(bidRequest, 'mediaTypes.video.mimes'), + protocols: deepAccess(bidRequest, 'mediaTypes.video.protocols'), + playbackmethod: deepAccess(bidRequest, 'mediaTypes.video.playbackmethod'), + minduration: deepAccess(bidRequest, 'mediaTypes.video.minduration'), + maxduration: deepAccess(bidRequest, 'mediaTypes.video.maxduration'), + startdelay: deepAccess(bidRequest, 'mediaTypes.video.startdelay'), + minbitrate: deepAccess(bidRequest, 'mediaTypes.video.minbitrate'), + maxbitrate: deepAccess(bidRequest, 'mediaTypes.video.maxbitrate'), + delivery: deepAccess(bidRequest, 'mediaTypes.video.delivery'), + linearity: deepAccess(bidRequest, 'mediaTypes.video.linearity'), + placement: deepAccess(bidRequest, 'mediaTypes.video.placement'), + skip: deepAccess(bidRequest, 'mediaTypes.video.skip'), + skipafter: deepAccess(bidRequest, 'mediaTypes.video.skipafter') + }; + + let context = deepAccess(bidRequest, 'mediaTypes.video.context'); + if (context == 'outstream' && !bidRequest.renderer) video.mimes = OUTSTREAM_MIMES; + + var imp = []; + var deals = []; + if (bidRequest.params.deals && bidRequest.params.deals.length > 0) { + deals = bidRequest.params.deals; + } + + if (context != 'adpod') { + imp.push({ + id: bidRequest.bidId, + video: video, + bidfloor: bidFloor, + pmp: { + deals: deals + } + }); + } + bidRequest.requestedMediaType = VIDEO; + const scriptUrl = generateScriptUrl(bidRequest); + const payloadString = generatePayload(imp, bidderRequest); + + return { + method: 'POST', + url: scriptUrl, + data: payloadString, + bidRequest + }; +} + +/* Convert video player size to bid request compatible format */ +function getVideoAdUnitSize(bidRequest) { + var adH = 0; + var adW = 0; + let playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize'); + if (isArray(playerSize)) { + if (playerSize.length === 2 && typeof playerSize[0] === 'number' && typeof playerSize[1] === 'number') { + adW = parseInt(playerSize[0]); + adH = parseInt(playerSize[1]); + } else { + adW = parseInt(playerSize[0][0]); + adH = parseInt(playerSize[0][1]); + } + } + return {adH: adH, adW: adW} +} + +/* Get mediatype of the adunit from request */ +function getMediaTypeOfResponse(bidRequest) { + if (bidRequest.requestedMediaType == BANNER) return BANNER; + else if (bidRequest.requestedMediaType == NATIVE) return NATIVE; + else if (bidRequest.requestedMediaType == VIDEO) return VIDEO; + else return ''; +} + +/* Generate endpoint url */ +function generateScriptUrl(bidRequest) { + let queryParams = 'hb=1'; + let siteId = getBidIdParameter('site_id', bidRequest.params); + return ENDPOINT_URL + siteId + '?' + queryParams; +} + +/* Generate request payload for the adunit */ +function generatePayload(imp, bidderRequest) { + let domain = window.location.host; + let page = window.location.host + window.location.pathname + location.search + location.hash; + + const site = { + domain: domain, + page: page, + publisher: {} + }; + + let regs = {ext: {}}; + + if (bidderRequest.uspConsent) { + regs.ext.us_privacy = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent && typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? '1' : '0'; + } + + if (config.getConfig('coppa') === true) { + regs.coppa = '1'; + } + + const device = { + ua: window.navigator.userAgent + }; + + const payload = { + id: getUniqueIdentifierStr(), + imp: imp, + site: site, + device: device, + regs: regs + }; + + return JSON.stringify(payload); +} + +/* Generate image asset object */ +function generateNativeImgObj(obj, type, id) { + let adW = 0; + let adH = 0; + let bidSizes = obj.sizes; + + var typeId; + if (type == 'icon') typeId = 1; + else if (type == 'image') typeId = 3; + + if (isArray(bidSizes)) { + if (bidSizes.length === 2 && typeof bidSizes[0] === 'number' && typeof bidSizes[1] === 'number') { + adW = parseInt(bidSizes[0]); + adH = parseInt(bidSizes[1]); + } else { + adW = parseInt(bidSizes[0][0]); + adH = parseInt(bidSizes[0][1]); + } + } + + let required = obj.required ? 1 : 0; + let image = { + type: parseInt(typeId), + w: adW, + h: adH + }; + return { + id: id, + required: required, + img: image + }; +} + +/* Generate title asset object */ +function generateNativeTitleObj(obj, id) { + let required = obj.required ? 1 : 0; + let title = { + len: obj.len + }; + return { + id: id, + required: required, + title: title + }; +} + +/* Generate data asset object */ +function generateNativeDataObj(obj, type, id) { + var typeId; + switch (type) { + case 'sponsored': typeId = 1; + break; + case 'desc' : typeId = 2; + break; + case 'cta' : typeId = 12; + break; + } + + let required = obj.required ? 1 : 0; + let data = { + type: typeId + }; + if (typeId == 2 && obj.len) { + data.len = parseInt(obj.len); + } + return { + id: id, + required: required, + data: data + }; +} + +/* Convert banner bid response to compatible format */ +function buildBannerResponse(bidRequest, bidResponse) { + const bidResponses = []; + bidResponse.seatbid[0].bid.forEach(function (bidderBid) { + let responseCPM; + let placementCode = ''; + + if (bidRequest) { + let bidResponse = createBid(1); + placementCode = bidRequest.placementCode; + bidRequest.status = CONSTANTS.STATUS.GOOD; + responseCPM = parseFloat(bidderBid.price); + if (responseCPM === 0 || isNaN(responseCPM)) { + let bid = createBid(2); + bid.requestId = bidRequest.bidId; + bid.bidderCode = bidRequest.bidder; + bidResponses.push(bid); + return; + } + let bidSizes = (deepAccess(bidRequest, 'mediaTypes.banner.sizes')) ? deepAccess(bidRequest, 'mediaTypes.banner.sizes') : bidRequest.sizes; + bidResponse.requestId = bidRequest.bidId; + bidResponse.placementCode = placementCode; + bidResponse.cpm = responseCPM; + bidResponse.size = bidSizes; + bidResponse.width = parseInt(bidderBid.w); + bidResponse.height = parseInt(bidderBid.h); + let responseAd = bidderBid.adm; + let responseNurl = ''; + bidResponse.ad = decodeURIComponent(responseAd + responseNurl); + bidResponse.creativeId = bidderBid.id; + bidResponse.bidderCode = bidRequest.bidder; + bidResponse.ttl = 300; + bidResponse.netRevenue = true; + bidResponse.currency = 'USD'; + bidResponse.mediaType = BANNER; + bidResponses.push(bidResponse); + } + }); + return bidResponses; +} + +/* Convert native bid response to compatible format */ +function buildNativeResponse(bidRequest, response) { + const bidResponses = []; + response.seatbid[0].bid.forEach(function (bidderBid) { + let responseCPM; + let placementCode = ''; + + if (bidRequest) { + let bidResponse = createBid(1); + placementCode = bidRequest.placementCode; + bidRequest.status = CONSTANTS.STATUS.GOOD; + responseCPM = parseFloat(bidderBid.price); + if (responseCPM === 0 || isNaN(responseCPM)) { + let bid = createBid(2); + bid.requestId = bidRequest.bidId; + bid.bidderCode = bidRequest.bidder; + bidResponses.push(bid); + return; + } + bidResponse.requestId = bidRequest.bidId; + bidResponse.placementCode = placementCode; + bidResponse.cpm = responseCPM; + + let nativeResponse = JSON.parse(bidderBid.adm).native; + + const native = { + clickUrl: nativeResponse.link.url, + impressionTrackers: nativeResponse.imptrackers + }; + + nativeResponse.assets.forEach(function(asset) { + let keyVal = getNativeAssestObj(asset, bidRequest.assets); + native[keyVal.key] = keyVal.value; + }); + + bidResponse.creativeId = bidderBid.id; + bidResponse.bidderCode = bidRequest.bidder; + bidResponse.ttl = 300; + if (bidRequest.sizes) { bidResponse.size = bidRequest.sizes; } + bidResponse.netRevenue = true; + bidResponse.currency = 'USD'; + bidResponse.native = native; + bidResponse.mediaType = NATIVE; + bidResponses.push(bidResponse); + } + }); + return bidResponses; +} + +/* Convert video bid response to compatible format */ +function buildVideoResponse(bidRequest, response) { + const bidResponses = []; + response.seatbid[0].bid.forEach(function (bidderBid) { + let responseCPM; + let placementCode = ''; + + if (bidRequest) { + let bidResponse = createBid(1); + placementCode = bidRequest.placementCode; + bidRequest.status = CONSTANTS.STATUS.GOOD; + responseCPM = parseFloat(bidderBid.price); + if (responseCPM === 0 || isNaN(responseCPM)) { + let bid = createBid(2); + bid.requestId = bidRequest.bidId; + bid.bidderCode = bidRequest.bidder; + bidResponses.push(bid); + return; + } + let context = bidRequest.mediaTypes.video.context; + + bidResponse.requestId = bidRequest.bidId; + bidResponse.placementCode = placementCode; + bidResponse.cpm = responseCPM; + + let vastXml = decodeURIComponent(bidderBid.adm); + + bidResponse.creativeId = bidderBid.id; + bidResponse.bidderCode = bidRequest.bidder; + bidResponse.ttl = 300; + bidResponse.netRevenue = true; + bidResponse.currency = 'USD'; + var ext = bidderBid.ext; + var vastUrl = ''; + if (ext) { + vastUrl = ext.vast_url; + } + var adUnitCode = bidRequest.adUnitCode; + var sizeObj = getVideoAdUnitSize(bidRequest); + + bidResponse.height = sizeObj.adH; + bidResponse.width = sizeObj.adW; + + switch (context) { + case OUTSTREAM: + var outstreamType = contains(OUTSTREAM_TYPES, bidRequest.params.outstreamType) ? bidRequest.params.outstreamType : ''; + bidResponse.outstreamType = outstreamType; + bidResponse.ad = vastXml; + if (!bidRequest.renderer) { + const renderer = Renderer.install({ + id: bidderBid.id, + url: RENDERER_URL, + config: bidRequest.params.outstreamConfig || {}, + loaded: false, + adUnitCode + }); + renderer.setRender(outstreamRender); + bidResponse.renderer = renderer; + } else { bidResponse.adResponse = vastXml; } + break; + case INSTREAM: + bidResponse.vastUrl = vastUrl; + bidResponse.adserverTargeting = setTargeting(vastUrl); + break; + } + bidResponse.mediaType = VIDEO; + bidResponses.push(bidResponse); + } + }); + return bidResponses; +} + +/* Generate renderer for outstream ad unit */ +function outstreamRender(bid) { + bid.renderer.push(() => { + window.osRenderer({ + adResponse: bid.ad, + height: bid.height, + width: bid.width, + targetId: bid.adUnitCode, // target div id to render video + outstreamType: bid.outstreamType, + options: bid.renderer.getConfig(), + }); + }); +} + +/* Set targeting params used for instream video that is required to generate cache url */ +function setTargeting(query) { + var targeting = {}; + var hash; + var hashes = query.slice(query.indexOf('?') + 1).split('&'); + for (var i = 0; i < hashes.length; i++) { + hash = hashes[i].split('='); + targeting['hb_' + hash[0]] = hash[1]; + } + return targeting; +} + +/* Get image type with respect to the id */ +function getAssetImageType(id, assets) { + for (var i = 0; i < assets.length; i++) { + if (assets[i].id == id) { + if (assets[i].img.type == 1) { return 'icon'; } else if (assets[i].img.type == 3) { return 'image'; } + } + } + return ''; +} + +/* Get type of data asset with respect to the id */ +function getAssetDataType(id, assets) { + for (var i = 0; i < assets.length; i++) { + if (assets[i].id == id) { + if (assets[i].data.type == 1) { return 'sponsored'; } else if (assets[i].data.type == 2) { return 'desc'; } else if (assets[i].data.type == 12) { return 'cta'; } + } + } + return ''; +} + +/* Convert response assests to compatible format */ +function getNativeAssestObj(obj, assets) { + if (obj.title) { + return { + key: 'title', + value: obj.title.text + } + } + if (obj.data) { + return { + key: getAssetDataType(obj.id, assets), + value: obj.data.value + } + } + if (obj.img) { + return { + key: getAssetImageType(obj.id, assets), + value: { + url: obj.img.url, + height: obj.img.h, + width: obj.img.w + } + } + } +} + +// BUILD REQUESTS: BIDFLOORS +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return (bid.params.bidfloor) ? bid.params.bidfloor : null; + } + + let floor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { + return floor.floor; + } + return null; +} + +registerBidder(spec); diff --git a/modules/datawrkzBidAdapter.md b/modules/datawrkzBidAdapter.md new file mode 100644 index 00000000000..85ea43e6dd3 --- /dev/null +++ b/modules/datawrkzBidAdapter.md @@ -0,0 +1,160 @@ +# Overview + +``` +Module Name: Datawrkz Bid Adapter +Module Type: Bidder Adapter +Maintainer: pubops@datawrkz.com +``` + +# Description + +Module that connects to Datawrkz's demand sources. +Datawrkz bid adapter supports Banner, Video (instream and outstream) and Native ad units. + +# Bid Parameters + +| Name | Scope | Type | Description | Example +| ---- | ----- | ---- | ----------- | ------- +| `site_id` | required | String | Site id | "test_site_id" +| `deals` | optional | Array | Array of deal objects | `[{id: "deal_1"},{id: "deal_2"}]` +| `bidfloor` | optional | Float | Minimum bid for this impression expressed in CPM | `0.5` +| `outstreamType` | optional | String | Type of outstream video to the played. Available options: inline, slider_top_left, slider_top_right, slider_bottom_left, slider_bottom_right, interstitial_close, and listicle | "inline" +| `outstreamConfig` | optional | Object | Configuration settings for outstream ad unit | `{ad_unit_audio: 1, show_player_close_button_after: 5, hide_player_control: 0}` + +# Deal Object +| Name | Scope | Type | Description | Example +| ---- | ----- | ---- | ----------- | ------- +| `id` | required | String | Deal id | "test_deal_id" + +# outstreamConfig +| Name | Scope | Type | Description | Example +| ---- | ----- | ---- | ----------- | ------- +| `ad_unit_audio` | optional | Integer | Set default audio option for the player. 0 to play audio on hover and 2 to mute | `0` or `2` +| `show_player_close_button_after` | optional | Integer | Show player close button after specified seconds | `5` +| `hide_player_control` | optional | Integer | Show/hide player controls. 0 to show player controls and 1 to hide | `1` + +# Test Parameters +``` +var adUnits = [ + // Banner adUnit + { + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'datawrkz', + params: { + site_id: 'site_id', + bidfloor: 0.5 + } + }] + }, + // Native adUnit + { + code: 'native-div', + sizes: [[1, 1]], + mediaTypes: { + native: { + title: { + required: true, + len: 80 + }, + image: { + required: true, + sizes: [300, 250] + }, + icon: { + required: true, + sizes: [50, 50] + }, + body: { + required: true, + len: 800 + }, + sponsoredBy: { + required: true + }, + cta: { + required: true + } + } + }, + bids: [{ + bidder: 'datawrkz', + params: { + site_id: 'site_id', + bidfloor: 0.5 + } + }] + }, + // Video instream adUnit + { + code: 'video-instream', + sizes: [[640, 480]], + mediaTypes: { + video: { + playerSize: [[640, 480]], + context: 'instream', + api: [1, 2], + mimes: ["video/x-ms-wmv", "video/mp4"], + protocols: [1, 2, 3], + playbackmethod: [1, 2], + minduration: 20, + maxduration: 30, + startdelay: 5, + minbitrate: 300, + maxbitrate: 1500, + delivery: [2], + linearity: 1 + }, + }, + bids: [{ + bidder: 'datawrkz', + params: { + site_id: 'site_id', + bidfloor: 0.5 + } + }] + }, + // Video outstream adUnit + { + code: 'video-outstream', + sizes: [[300, 250]], + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream', + api: [1, 2], + mimes: ["video/mp4"], + protocols: [1, 2, 3], + playbackmethod: [1, 2], + minduration: 20, + maxduration: 30, + startdelay: 5, + minbitrate: 300, + maxbitrate: 1500, + delivery: [2], + linearity: 1 + } + }, + bids: [ + { + bidder: 'datawrkz', + params: { + site_id: 'site_id', + bidfloor: 0.5, + outstreamType: 'slider_top_left', //Supported types : inline, slider_top_left, slider_top_right, slider_bottom_left, slider_bottom_right, interstitial_close, listicle + outstreamConfig: { + ad_unit_audio: 1, // 0: audio on hover, 2: always muted + show_player_close_button_after: 5, // show close button after 5 seconds + hide_player_control: 0 // 0 to show/ 1 to hide + } + } + } + ] + } +]; +``` diff --git a/modules/dchain.js b/modules/dchain.js index fbe78fc5c86..7f84282b81e 100644 --- a/modules/dchain.js +++ b/modules/dchain.js @@ -1,7 +1,8 @@ import {includes} from '../src/polyfill.js'; import {config} from '../src/config.js'; import {getHook} from '../src/hook.js'; -import {_each, deepAccess, deepClone, hasOwn, isArray, isPlainObject, isStr, logError, logWarn} from '../src/utils.js'; +import {_each, deepAccess, deepClone, isArray, isPlainObject, isStr, logError, logWarn} from '../src/utils.js'; +import {timedBidResponseHook} from '../src/utils/perfMetrics.js'; const shouldBeAString = ' should be a string'; const shouldBeAnObject = ' should be an object'; @@ -48,7 +49,7 @@ export function checkDchainSyntax(bid, mode) { appendFailMsg(`dchain.ver` + shouldBeAString); } - if (hasOwn(dchainObj, 'ext')) { + if (dchainObj.hasOwnProperty('ext')) { if (!isPlainObject(dchainObj.ext)) { appendFailMsg(`dchain.ext` + shouldBeAnObject); } @@ -108,7 +109,7 @@ function isValidDchain(bid) { } } -export function addBidResponseHook(fn, adUnitCode, bid) { +export const addBidResponseHook = timedBidResponseHook('dchain', function addBidResponseHook(fn, adUnitCode, bid, reject) { const basicDchain = { ver: '1.0', complete: 0, @@ -139,8 +140,8 @@ export function addBidResponseHook(fn, adUnitCode, bid) { bid.meta.dchain = basicDchain; } - fn(adUnitCode, bid); -} + fn(adUnitCode, bid, reject); +}); export function init() { getHook('addBidResponse').before(addBidResponseHook, 35); diff --git a/modules/debugging/WARNING.md b/modules/debugging/WARNING.md new file mode 100644 index 00000000000..109d6db7704 --- /dev/null +++ b/modules/debugging/WARNING.md @@ -0,0 +1,9 @@ +## Warning + +This module is also packaged as a "standalone" .js file and loaded dynamically by prebid-core when debugging configuration is passed to `setConfig` or loaded from session storage. + +"Standalone" means that it does not have a compile-time dependency on `prebid-core.js` and can therefore work even if it was not built together with it (as would be the case when Prebid is pulled from npm). + +Because of this, **this module cannot freely import symbols from core**: anything that depends on Prebid global state (which includes, but is not limited to, `config`, `auctionManager`, `adapterManager`, etc) would *not* work as expected. + +Imports must be limited to logic that is stateless and free of side effects; symbols from `utils.js` are mostly OK, with the notable exception of logging functions (which have a dependency on `config`). diff --git a/modules/debugging/bidInterceptor.js b/modules/debugging/bidInterceptor.js index 2a179641424..775f8fc3da2 100644 --- a/modules/debugging/bidInterceptor.js +++ b/modules/debugging/bidInterceptor.js @@ -3,10 +3,8 @@ import { deepClone, deepEqual, delayExecution, - prefixLog, mergeDeep } from '../../src/utils.js'; -const { logMessage, logWarn, logError } = prefixLog('DEBUG:'); /** * @typedef {Number|String|boolean|null|undefined} Scalar @@ -14,6 +12,7 @@ const { logMessage, logWarn, logError } = prefixLog('DEBUG:'); export function BidInterceptor(opts = {}) { ({setTimeout: this.setTimeout = window.setTimeout.bind(window)} = opts); + this.logger = opts.logger; this.rules = []; } @@ -22,10 +21,10 @@ Object.assign(BidInterceptor.prototype, { delay: 0 }, serializeConfig(ruleDefs) { - function isSerializable(ruleDef, i) { + const isSerializable = (ruleDef, i) => { const serializable = deepEqual(ruleDef, JSON.parse(JSON.stringify(ruleDef)), {checkTypes: true}); if (!serializable && !deepAccess(ruleDef, 'options.suppressWarnings')) { - logWarn(`Bid interceptor rule definition #${i + 1} is not serializable and will be lost after a refresh. Rule definition: `, ruleDef); + this.logger.logWarn(`Bid interceptor rule definition #${i + 1} is not serializable and will be lost after a refresh. Rule definition: `, ruleDef); } return serializable; } @@ -79,7 +78,7 @@ Object.assign(BidInterceptor.prototype, { return matchDef; } if (typeof matchDef !== 'object') { - logError(`Invalid 'when' definition for debug bid interceptor (in rule #${ruleNo})`); + this.logger.logError(`Invalid 'when' definition for debug bid interceptor (in rule #${ruleNo})`); return () => false; } function matches(candidate, {ref = matchDef, args = []}) { @@ -119,15 +118,15 @@ Object.assign(BidInterceptor.prototype, { if (typeof replDef === 'function') { replFn = ({args}) => replDef(...args); } else if (typeof replDef !== 'object') { - logError(`Invalid 'then' definition for debug bid interceptor (in rule #${ruleNo})`); + this.logger.logError(`Invalid 'then' definition for debug bid interceptor (in rule #${ruleNo})`); replFn = () => ({}); } else { replFn = ({args, ref = replDef}) => { - const result = {}; + const result = Array.isArray(ref) ? [] : {}; Object.entries(ref).forEach(([key, val]) => { if (typeof val === 'function') { result[key] = val(...args); - } else if (typeof val === 'object') { + } else if (val != null && typeof val === 'object') { result[key] = replFn({args, ref: val}) } else { result[key] = val; @@ -139,7 +138,7 @@ Object.assign(BidInterceptor.prototype, { return (bid, ...args) => { const response = this.responseDefaults(bid); mergeDeep(response, replFn({args: [bid, ...args]})); - if (!response.ad) { + if (!response.hasOwnProperty('ad') && !response.hasOwnProperty('adUrl')) { response.ad = this.defaultAd(bid, response); } response.isDebug = true; @@ -213,7 +212,7 @@ Object.assign(BidInterceptor.prototype, { matches.forEach((match) => { const mockResponse = match.rule.replace(match.bid, bidRequest); const delay = match.rule.options.delay; - logMessage(`Intercepted bid request (matching rule #${match.rule.no}), mocking response in ${delay}ms. Request, response:`, match.bid, mockResponse) + this.logger.logMessage(`Intercepted bid request (matching rule #${match.rule.no}), mocking response in ${delay}ms. Request, response:`, match.bid, mockResponse) this.setTimeout(() => { addBid(mockResponse, match.bid); callDone(); diff --git a/modules/debugging/debugging.js b/modules/debugging/debugging.js new file mode 100644 index 00000000000..8a4ad7a9545 --- /dev/null +++ b/modules/debugging/debugging.js @@ -0,0 +1,117 @@ +import {deepClone, delayExecution} from '../../src/utils.js'; +import {BidInterceptor} from './bidInterceptor.js'; +import {makePbsInterceptor} from './pbsInterceptor.js'; +import {addHooks, removeHooks} from './legacy.js'; + +const interceptorHooks = []; +let bidInterceptor; +let enabled = false; + +function enableDebugging(debugConfig, {fromSession = false, config, hook, logger}) { + config.setConfig({debug: true}); + bidInterceptor.updateConfig(debugConfig); + resetHooks(true); + // also enable "legacy" overrides + removeHooks({hook}); + addHooks(debugConfig, {hook, logger}); + if (!enabled) { + enabled = true; + logger.logMessage(`Debug overrides enabled${fromSession ? ' from session' : ''}`); + } +} + +export function disableDebugging({hook, logger}) { + bidInterceptor.updateConfig(({})); + resetHooks(false); + // also disable "legacy" overrides + removeHooks({hook}); + if (enabled) { + enabled = false; + logger.logMessage('Debug overrides disabled'); + } +} + +function saveDebuggingConfig(debugConfig, {sessionStorage = window.sessionStorage, DEBUG_KEY} = {}) { + if (!debugConfig.enabled) { + try { + sessionStorage.removeItem(DEBUG_KEY); + } catch (e) { + } + } else { + if (debugConfig.intercept) { + debugConfig = deepClone(debugConfig); + debugConfig.intercept = bidInterceptor.serializeConfig(debugConfig.intercept); + } + try { + sessionStorage.setItem(DEBUG_KEY, JSON.stringify(debugConfig)); + } catch (e) { + } + } +} + +export function getConfig(debugging, {getStorage = () => window.sessionStorage, DEBUG_KEY, config, hook, logger} = {}) { + if (debugging == null) return; + let sessionStorage; + try { + sessionStorage = getStorage(); + } catch (e) { + logger.logError(`sessionStorage is not available: debugging configuration will not persist on page reload`, e); + } + if (sessionStorage != null) { + saveDebuggingConfig(debugging, {sessionStorage, DEBUG_KEY}); + } + if (!debugging.enabled) { + disableDebugging({hook, logger}); + } else { + enableDebugging(debugging, {config, hook, logger}); + } +} + +export function sessionLoader({DEBUG_KEY, storage, config, hook, logger}) { + let overrides; + try { + storage = storage || window.sessionStorage; + overrides = JSON.parse(storage.getItem(DEBUG_KEY)); + } catch (e) { + } + if (overrides) { + enableDebugging(overrides, {fromSession: true, config, hook, logger}); + } +} + +function resetHooks(enable) { + interceptorHooks.forEach(([getHookFn, interceptor]) => { + getHookFn().getHooks({hook: interceptor}).remove(); + }); + if (enable) { + interceptorHooks.forEach(([getHookFn, interceptor]) => { + getHookFn().before(interceptor); + }); + } +} + +function registerBidInterceptor(getHookFn, interceptor) { + const interceptBids = (...args) => bidInterceptor.intercept(...args); + interceptorHooks.push([getHookFn, function (next, ...args) { + interceptor(next, interceptBids, ...args); + }]); +} + +export function bidderBidInterceptor(next, interceptBids, spec, bids, bidRequest, ajax, wrapCallback, cbs) { + const done = delayExecution(cbs.onCompletion, 2); + ({bids, bidRequest} = interceptBids({bids, bidRequest, addBid: cbs.onBid, done})); + if (bids.length === 0) { + done(); + } else { + next(spec, bids, bidRequest, ajax, wrapCallback, {...cbs, onCompletion: done}); + } +} + +export function install({DEBUG_KEY, config, hook, createBid, logger}) { + bidInterceptor = new BidInterceptor({logger}); + const pbsBidInterceptor = makePbsInterceptor({createBid}); + registerBidInterceptor(() => hook.get('processBidderRequests'), bidderBidInterceptor); + registerBidInterceptor(() => hook.get('processPBSRequest'), pbsBidInterceptor); + sessionLoader({DEBUG_KEY, config, hook, logger}); + config.getConfig('debugging', ({debugging}) => getConfig(debugging, {DEBUG_KEY, config, hook, logger}), {init: true}); +} diff --git a/modules/debugging/index.js b/modules/debugging/index.js index 72692c3fc98..424200b2029 100644 --- a/modules/debugging/index.js +++ b/modules/debugging/index.js @@ -1,62 +1,8 @@ -import {deepClone, delayExecution} from '../../src/utils.js'; -import {processBidderRequests} from '../../src/adapters/bidderFactory.js'; -import {BidInterceptor} from './bidInterceptor.js'; +import {config} from '../../src/config.js'; import {hook} from '../../src/hook.js'; -import {pbsBidInterceptor} from './pbsInterceptor.js'; -import { - onDisableOverrides, - onEnableOverrides, - saveDebuggingConfig -} from '../../src/debugging.js'; +import {install} from './debugging.js'; +import {prefixLog} from '../../src/utils.js'; +import {createBid} from '../../src/bidfactory.js'; +import {DEBUG_KEY} from '../../src/debugging.js'; -const interceptorHooks = []; -const bidInterceptor = new BidInterceptor(); - -saveDebuggingConfig.before(function (next, debugConfig, ...args) { - if (debugConfig.intercept) { - debugConfig = deepClone(debugConfig); - debugConfig.intercept = bidInterceptor.serializeConfig(debugConfig.intercept); - } - next(debugConfig, ...args); -}); - -function resetHooks(enable) { - interceptorHooks.forEach(([getHookFn, interceptor]) => { - getHookFn().getHooks({hook: interceptor}).remove(); - }); - if (enable) { - interceptorHooks.forEach(([getHookFn, interceptor]) => { - getHookFn().before(interceptor); - }) - } -} - -onEnableOverrides.push((overrides) => { - bidInterceptor.updateConfig(overrides); - resetHooks(true); -}); - -onDisableOverrides.push(() => { - bidInterceptor.updateConfig({}); - resetHooks(false); -}) - -function registerBidInterceptor(getHookFn, interceptor) { - const interceptBids = (...args) => bidInterceptor.intercept(...args); - interceptorHooks.push([getHookFn, function (next, ...args) { - interceptor(next, interceptBids, ...args) - }]); -} - -export function bidderBidInterceptor(next, interceptBids, spec, bids, bidRequest, ajax, wrapCallback, cbs) { - const done = delayExecution(cbs.onCompletion, 2); - ({bids, bidRequest} = interceptBids({bids, bidRequest, addBid: cbs.onBid, done})); - if (bids.length === 0) { - done(); - } else { - next(spec, bids, bidRequest, ajax, wrapCallback, {...cbs, onCompletion: done}); - } -} - -registerBidInterceptor(() => processBidderRequests, bidderBidInterceptor); -registerBidInterceptor(() => hook.get('processPBSRequest'), pbsBidInterceptor); +install({DEBUG_KEY, config, hook, createBid, logger: prefixLog('DEBUG:')}); diff --git a/modules/debugging/legacy.js b/modules/debugging/legacy.js new file mode 100644 index 00000000000..e83b99c5194 --- /dev/null +++ b/modules/debugging/legacy.js @@ -0,0 +1,100 @@ +export let addBidResponseBound; +export let addBidderRequestsBound; + +export function addHooks(overrides, {hook, logger}) { + addBidResponseBound = addBidResponseHook.bind({overrides, logger}); + hook.get('addBidResponse').before(addBidResponseBound, 5); + + addBidderRequestsBound = addBidderRequestsHook.bind({overrides, logger}); + hook.get('addBidderRequests').before(addBidderRequestsBound, 5); +} + +export function removeHooks({hook}) { + hook.get('addBidResponse').getHooks({hook: addBidResponseBound}).remove(); + hook.get('addBidderRequests').getHooks({hook: addBidderRequestsBound}).remove(); +} + +/** + * @param {{bidder:string, adUnitCode:string}} overrideObj + * @param {string} bidderCode + * @param {string} adUnitCode + * @returns {boolean} + */ +export function bidExcluded(overrideObj, bidderCode, adUnitCode) { + if (overrideObj.bidder && overrideObj.bidder !== bidderCode) { + return true; + } + if (overrideObj.adUnitCode && overrideObj.adUnitCode !== adUnitCode) { + return true; + } + return false; +} + +/** + * @param {string[]} bidders + * @param {string} bidderCode + * @returns {boolean} + */ +export function bidderExcluded(bidders, bidderCode) { + return (Array.isArray(bidders) && bidders.indexOf(bidderCode) === -1); +} + +/** + * @param {Object} overrideObj + * @param {Object} bidObj + * @param {Object} bidType + * @returns {Object} bidObj with overridden properties + */ +export function applyBidOverrides(overrideObj, bidObj, bidType, logger) { + return Object.keys(overrideObj).filter(key => (['adUnitCode', 'bidder'].indexOf(key) === -1)).reduce(function(result, key) { + logger.logMessage(`bidder overrides changed '${result.adUnitCode}/${result.bidderCode}' ${bidType}.${key} from '${result[key]}.js' to '${overrideObj[key]}'`); + result[key] = overrideObj[key]; + result.isDebug = true; + return result; + }, bidObj); +} + +export function addBidResponseHook(next, adUnitCode, bid, reject) { + const {overrides, logger} = this; + + if (bidderExcluded(overrides.bidders, bid.bidderCode)) { + logger.logWarn(`bidder '${bid.bidderCode}' excluded from auction by bidder overrides`); + return; + } + + if (Array.isArray(overrides.bids)) { + overrides.bids.forEach(function(overrideBid) { + if (!bidExcluded(overrideBid, bid.bidderCode, adUnitCode)) { + applyBidOverrides(overrideBid, bid, 'bidder', logger); + } + }); + } + + next(adUnitCode, bid, reject); +} + +export function addBidderRequestsHook(next, bidderRequests) { + const {overrides, logger} = this; + + const includedBidderRequests = bidderRequests.filter(function (bidderRequest) { + if (bidderExcluded(overrides.bidders, bidderRequest.bidderCode)) { + logger.logWarn(`bidRequest '${bidderRequest.bidderCode}' excluded from auction by bidder overrides`); + return false; + } + return true; + }); + + if (Array.isArray(overrides.bidRequests)) { + includedBidderRequests.forEach(function(bidderRequest) { + overrides.bidRequests.forEach(function(overrideBid) { + bidderRequest.bids.forEach(function(bid) { + if (!bidExcluded(overrideBid, bidderRequest.bidderCode, bid.adUnitCode)) { + applyBidOverrides(overrideBid, bid, 'bidRequest', logger); + } + }); + }); + }); + } + + next(includedBidderRequests); +} diff --git a/modules/debugging/pbsInterceptor.js b/modules/debugging/pbsInterceptor.js index c8de1ed9753..1ca13eb4927 100644 --- a/modules/debugging/pbsInterceptor.js +++ b/modules/debugging/pbsInterceptor.js @@ -1,38 +1,39 @@ import {deepClone, delayExecution} from '../../src/utils.js'; -import {createBid} from '../../src/bidfactory.js'; -import {default as CONSTANTS} from '../../src/constants.json'; +import CONSTANTS from '../../src/constants.json'; -export function pbsBidInterceptor (next, interceptBids, s2sBidRequest, bidRequests, ajax, { - onResponse, - onError, - onBid -}) { - let responseArgs; - const done = delayExecution(() => onResponse(...responseArgs), bidRequests.length + 1) - function signalResponse(...args) { - responseArgs = args; - done(); - } - function addBid(bid, bidRequest) { - onBid({ - adUnit: bidRequest.adUnitCode, - bid: Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid) - }) - } - bidRequests = bidRequests - .map((req) => interceptBids({bidRequest: req, addBid, done}).bidRequest) - .filter((req) => req.bids.length > 0) +export function makePbsInterceptor({createBid}) { + return function pbsBidInterceptor(next, interceptBids, s2sBidRequest, bidRequests, ajax, { + onResponse, + onError, + onBid + }) { + let responseArgs; + const done = delayExecution(() => onResponse(...responseArgs), bidRequests.length + 1) + function signalResponse(...args) { + responseArgs = args; + done(); + } + function addBid(bid, bidRequest) { + onBid({ + adUnit: bidRequest.adUnitCode, + bid: Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid) + }) + } + bidRequests = bidRequests + .map((req) => interceptBids({bidRequest: req, addBid, done}).bidRequest) + .filter((req) => req.bids.length > 0) - if (bidRequests.length > 0) { - const bidIds = new Set(); - bidRequests.forEach((req) => req.bids.forEach((bid) => bidIds.add(bid.bidId))); - s2sBidRequest = deepClone(s2sBidRequest); - s2sBidRequest.ad_units.forEach((unit) => { - unit.bids = unit.bids.filter((bid) => bidIds.has(bid.bid_id)); - }) - s2sBidRequest.ad_units = s2sBidRequest.ad_units.filter((unit) => unit.bids.length > 0); - next(s2sBidRequest, bidRequests, ajax, {onResponse: signalResponse, onError, onBid}); - } else { - signalResponse(true, []); + if (bidRequests.length > 0) { + const bidIds = new Set(); + bidRequests.forEach((req) => req.bids.forEach((bid) => bidIds.add(bid.bidId))); + s2sBidRequest = deepClone(s2sBidRequest); + s2sBidRequest.ad_units.forEach((unit) => { + unit.bids = unit.bids.filter((bid) => bidIds.has(bid.bid_id)); + }) + s2sBidRequest.ad_units = s2sBidRequest.ad_units.filter((unit) => unit.bids.length > 0); + next(s2sBidRequest, bidRequests, ajax, {onResponse: signalResponse, onError, onBid}); + } else { + signalResponse(true, []); + } } } diff --git a/modules/debugging/standalone.js b/modules/debugging/standalone.js new file mode 100644 index 00000000000..b3b539f5aa2 --- /dev/null +++ b/modules/debugging/standalone.js @@ -0,0 +1,7 @@ +import {install} from './debugging.js'; + +window._pbjsGlobals.forEach((name) => { + if (window[name] && window[name]._installDebugging === true) { + window[name]._installDebugging = install; + } +}) diff --git a/modules/decenteradsBidAdapter.md b/modules/decenteradsBidAdapter.md deleted file mode 100644 index 04260a9da58..00000000000 --- a/modules/decenteradsBidAdapter.md +++ /dev/null @@ -1,27 +0,0 @@ -# Overview - -``` -Module Name: DecenterAds Bidder Adapter -Module Type: Bidder Adapter -Maintainer: publishers@decenterads.com -``` - -# Description - -Module that connects to DecenterAds' demand sources - -# Test Parameters -``` - var adUnits = [{ - code: 'placementId_0', - sizes: [[300, 250]], - bids: [{ - bidder: 'decenterads', - params: { - placementId: 0, - traffic: 'banner' - } - }] - } - ]; -``` diff --git a/modules/deepintentBidAdapter.js b/modules/deepintentBidAdapter.js index 94167b92bb0..e062686b320 100644 --- a/modules/deepintentBidAdapter.js +++ b/modules/deepintentBidAdapter.js @@ -262,21 +262,13 @@ function buildBanner(bid) { function buildSite(bidderRequest) { let site = {}; - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - site.page = bidderRequest.refererInfo.referer; - site.domain = getDomain(bidderRequest.refererInfo.referer); + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.page) { + site.page = bidderRequest.refererInfo.page; + site.domain = bidderRequest.refererInfo.domain; } return site; } -function getDomain(referer) { - if (referer) { - let domainA = document.createElement('a'); - domainA.href = referer; - return domainA.hostname; - } -} - function buildDevice() { return { ua: navigator.userAgent, diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js index 43c7af1b3cc..4d685592c04 100644 --- a/modules/deepintentDpesIdSystem.js +++ b/modules/deepintentDpesIdSystem.js @@ -6,10 +6,11 @@ */ import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'deepintentId'; -export const storage = getStorageManager({gvlid: null, moduleName: MODULE_NAME}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); /** @type {Submodule} */ export const deepintentDpesSubmodule = { @@ -38,8 +39,13 @@ export const deepintentDpesSubmodule = { */ getId(config, consentData, cacheIdObj) { return cacheIdObj; - } - + }, + eids: { + 'deepintentId': { + source: 'deepintent.com', + atype: 3 + }, + }, }; submodule('userId', deepintentDpesSubmodule); diff --git a/modules/deltaprojectsBidAdapter.js b/modules/deltaprojectsBidAdapter.js index 33df5bd252e..c66e381b8f1 100644 --- a/modules/deltaprojectsBidAdapter.js +++ b/modules/deltaprojectsBidAdapter.js @@ -1,7 +1,14 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; import { - _each, _map, isFn, isNumber, createTrackPixelHtml, deepAccess, parseUrl, logWarn, logError + _each, + _map, + createTrackPixelHtml, + deepAccess, + isFn, + isNumber, + logError, + logWarn } from '../src/utils.js'; import {config} from '../src/config.js'; @@ -29,17 +36,16 @@ function isBidRequestValid(bid) { function buildRequests(validBidRequests, bidderRequest) { /** == shared ==**/ // -- build id - const id = bidderRequest.auctionId; + const id = bidderRequest.bidderRequestId; // -- build site - const loc = parseUrl(bidderRequest.refererInfo.referer); const publisherId = setOnAny(validBidRequests, 'params.publisherId'); const siteId = setOnAny(validBidRequests, 'params.siteId'); const site = { id: siteId, - domain: loc.hostname, - page: loc.href, - ref: loc.href, + domain: bidderRequest.refererInfo.domain, + page: bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.ref, publisher: { id: publisherId }, }; @@ -93,7 +99,7 @@ function buildOpenRTBRequest(validBidRequest, id, site, device, user, tmax, regs // build source const source = { - tid: validBidRequest.transactionId, + tid: validBidRequest.auctionId, fd: 1, } diff --git a/modules/dfpAdServerVideo.js b/modules/dfpAdServerVideo.js index 7f8ad3351fa..3394fd8b3f4 100644 --- a/modules/dfpAdServerVideo.js +++ b/modules/dfpAdServerVideo.js @@ -8,9 +8,11 @@ import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, bui import { config } from '../src/config.js'; import { getHook, submodule } from '../src/hook.js'; import { auctionManager } from '../src/auctionManager.js'; -import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; +import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../src/adapterManager.js'; import * as events from '../src/events.js'; import CONSTANTS from '../src/constants.json'; +import {getPPID} from '../src/adserver.js'; +import {getRefererInfo} from '../src/refererDetection.js'; /** * @typedef {Object} DfpVideoParams @@ -51,6 +53,10 @@ const defaultParamConstants = { export const adpodUtils = {}; +export const dep = { + ri: getRefererInfo +} + /** * Merge all the bid data and publisher-supplied options into a single URL, and then return it. * @@ -90,7 +96,7 @@ export function buildDfpVideoUrl(options) { }; const urlSearchComponent = urlComponents.search; - const urlSzParam = urlSearchComponent && urlSearchComponent.sz + const urlSzParam = urlSearchComponent && urlSearchComponent.sz; if (urlSzParam) { derivedParams.sz = urlSzParam + '|' + derivedParams.sz; } @@ -118,6 +124,18 @@ export function buildDfpVideoUrl(options) { const uspConsent = uspDataHandler.getConsentData(); if (uspConsent) { queryParams.us_privacy = uspConsent; } + const gppConsent = gppDataHandler.getConsentData(); + if (gppConsent) { + // TODO - need to know what to set here for queryParams... + } + + if (!queryParams.ppid) { + const ppid = getPPID(); + if (ppid != null) { + queryParams.ppid = ppid; + } + } + return buildUrl(Object.assign({ protocol: 'https', host: 'securepubads.g.doubleclick.net', @@ -178,7 +196,7 @@ export function buildAdpodVideoUrl({code, params, callback} = {}) { let initialValue = { [adpodUtils.TARGETING_KEY_PB_CAT_DUR]: undefined, [adpodUtils.TARGETING_KEY_CACHE_ID]: undefined - } + }; let customParams = {}; if (targeting[code]) { customParams = targeting[code].reduce((acc, curValue) => { @@ -246,14 +264,7 @@ function buildUrlFromAdserverUrlComponents(components, bid, options) { * @return {string | undefined} The encoded vast url if it exists, or undefined */ function getDescriptionUrl(bid, components, prop) { - if (config.getConfig('cache.url')) { return; } - - if (!deepAccess(components, `${prop}.description_url`)) { - const vastUrl = bid && bid.vastUrl; - if (vastUrl) { return encodeURIComponent(vastUrl); } - } else { - logError(`input cannnot contain description_url`); - } + return deepAccess(components, `${prop}.description_url`) || dep.ri().page; } /** @@ -280,6 +291,8 @@ function getCustParams(bid, options, urlCustParams) { allTargetingData, adserverTargeting, ); + + // TODO: WTF is this? just firing random events, guessing at the argument, hoping noone notices? events.emit(CONSTANTS.EVENTS.SET_TARGETING, {[adUnit.code]: prebidTargetingSet}); // merge the prebid + publisher targeting sets diff --git a/modules/dgadsBidAdapter.md b/modules/dgadsBidAdapter.md deleted file mode 100644 index b1544007a43..00000000000 --- a/modules/dgadsBidAdapter.md +++ /dev/null @@ -1,65 +0,0 @@ -# Overview - -``` -Module Name: Digital Garage Ads Platform Bidder Adapter -Module Type: Bidder Adapter -Maintainer:dgads-support@garage.co.jp -``` - -# Description - -Connect to Digital Garage Ads Platform for bids. -This adapter supports Banner and Native. - -# Test Parameters -``` - var adUnits = [ - // Banner - { - code: 'banner-div', - sizes: [[300, 250]], - bids: [{ - bidder: 'dgads', - mediaTypes: 'banner', - params: { - location_id: '1', - site_id: '1' - } - }] - }, - // Native - { - code: 'native-div', - sizes: [[300, 250]], - mediaTypes: { - native: { - title: { - required: true, - len: 25 - }, - body: { - required: true, - len: 140 - }, - sponsoredBy: { - required: true, - len: 40 - }, - image: { - required: true - }, - clickUrl: { - required: true - }, - } - }, - bids: [{ - bidder: 'dgads', - params: { - location_id: '10', - site_id: '1' - } - }] - }, - ]; -``` diff --git a/modules/dgkeywordRtdProvider.js b/modules/dgkeywordRtdProvider.js index 26a8257077a..99df3b18a39 100644 --- a/modules/dgkeywordRtdProvider.js +++ b/modules/dgkeywordRtdProvider.js @@ -7,7 +7,7 @@ * @requires module:modules/realTimeData */ -import { logMessage, deepSetValue, logError, logInfo } from '../src/utils.js'; +import {logMessage, deepSetValue, logError, logInfo, mergeDeep} from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import { getGlobal } from '../src/prebidGlobal.js'; @@ -20,11 +20,18 @@ import { getGlobal } from '../src/prebidGlobal.js'; * @param {Object} userConsent */ export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, userConsent) { - const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1?url='; const PROFILE_TIMEOUT_MS = 1000; const timeout = (moduleConfig && moduleConfig.params && moduleConfig.params.timeout && Number(moduleConfig.params.timeout) > 0) ? Number(moduleConfig.params.timeout) : PROFILE_TIMEOUT_MS; - const url = (moduleConfig && moduleConfig.params && moduleConfig.params.url) ? moduleConfig.params.url : URL + encodeURIComponent(window.location.href); const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; + callback = (function(cb) { + let done = false; + return function () { + if (!done) { + done = true; + return cb.apply(this, arguments); + } + } + })(callback); let isFinish = false; logMessage('[dgkeyword sub module]', adUnits, timeout); let setKeywordTargetBidders = getTargetBidderOfDgKeywords(adUnits); @@ -34,7 +41,7 @@ export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, us } else { logMessage('[dgkeyword sub module] dgkeyword targets:', setKeywordTargetBidders); logMessage('[dgkeyword sub module] get targets from profile api start.'); - ajax(url, { + ajax(getProfileApiUrl(moduleConfig?.params?.url, moduleConfig?.params?.enableReadFpid), { success: function(response) { const res = JSON.parse(response); if (!isFinish) { @@ -48,7 +55,7 @@ export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, us keywords['opectx'] = res['t']; } if (Object.keys(keywords).length > 0) { - const targetBidKeys = {} + const targetBidKeys = {}; for (let bid of setKeywordTargetBidders) { // set keywords to params bid.params.keywords = keywords; @@ -62,8 +69,7 @@ export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, us let addOrtb2 = {}; deepSetValue(addOrtb2, 'site.keywords', keywords); deepSetValue(addOrtb2, 'user.keywords', keywords); - const ortb2 = {ortb2: addOrtb2}; - reqBidsConfigObj.setBidderConfig({ bidders: Object.keys(targetBidKeys), config: ortb2 }); + mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, Object.fromEntries(Object.keys(targetBidKeys).map(bidder => [bidder, addOrtb2]))); } } } @@ -90,6 +96,26 @@ export function getDgKeywordsAndSet(reqBidsConfigObj, callback, moduleConfig, us } } +export function getProfileApiUrl(customeUrl, enableReadFpid) { + const URL = 'https://mediaconsortium.profiles.tagger.opecloud.com/api/v1'; + const fpid = (enableReadFpid) ? readFpidFromLocalStrage() : ''; + let url = customeUrl || URL; + url = url + '?url=' + encodeURIComponent(window.location.href) + ((fpid) ? `&fpid=${fpid}` : ''); + return url; +} + +export function readFpidFromLocalStrage() { + try { + const fpid = window.localStorage.getItem('ope_fpid'); + if (fpid) { + return fpid; + } + return null; + } catch (error) { + return null; + } +} + /** * get all bidder which hava {dgkeyword: true} in params * @param {Object} adUnits diff --git a/modules/dianomiBidAdapter.js b/modules/dianomiBidAdapter.js new file mode 100644 index 00000000000..d4b2a4a5da5 --- /dev/null +++ b/modules/dianomiBidAdapter.js @@ -0,0 +1,375 @@ +// jshint esversion: 6, es3: false, node: true +'use strict'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { NATIVE, BANNER, VIDEO } from '../src/mediaTypes.js'; +import { + mergeDeep, + _map, + deepAccess, + parseSizesInput, + deepSetValue, + formatQS, +} from '../src/utils.js'; +import { config } from '../src/config.js'; +import { Renderer } from '../src/Renderer.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +const { getConfig } = config; + +const BIDDER_CODE = 'dianomi'; +const GVLID = 885; +const BIDDER_ALIAS = [{ code: 'dia', gvlid: GVLID }]; +const NATIVE_ASSET_IDS = { + 0: 'title', + 2: 'icon', + 3: 'image', + 5: 'sponsoredBy', + 4: 'body', + 1: 'cta', +}; +const NATIVE_PARAMS = { + title: { + id: 0, + name: 'title', + }, + icon: { + id: 2, + type: 1, + name: 'img', + }, + image: { + id: 3, + type: 3, + name: 'img', + }, + sponsoredBy: { + id: 5, + name: 'data', + type: 1, + }, + body: { + id: 4, + name: 'data', + type: 2, + }, + cta: { + id: 1, + type: 12, + name: 'data', + }, +}; +let endpoint = 'www-prebid.dianomi.com'; + +const OUTSTREAM_RENDERER_URL = (hostname) => `https://${hostname}/prebid/outstream/renderer.js`; + +export const spec = { + code: BIDDER_CODE, + aliases: BIDDER_ALIAS, + gvlid: GVLID, + supportedMediaTypes: [NATIVE, BANNER, VIDEO], + isBidRequestValid: (bid) => { + const params = bid.params || {}; + const { smartadId } = params; + return !!smartadId; + }, + buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let app, site; + + const commonFpd = bidderRequest.ortb2 || {}; + let { user } = commonFpd; + + if (typeof getConfig('app') === 'object') { + app = getConfig('app') || {}; + if (commonFpd.app) { + mergeDeep(app, commonFpd.app); + } + } else { + site = getConfig('site') || {}; + if (commonFpd.site) { + mergeDeep(site, commonFpd.site); + } + + if (!site.page) { + site.page = bidderRequest.refererInfo.page; + } + } + + const device = getConfig('device') || {}; + device.w = device.w || window.innerWidth; + device.h = device.h || window.innerHeight; + device.ua = device.ua || navigator.userAgent; + + const paramsEndpoint = setOnAny(validBidRequests, 'params.endpoint'); + + if (paramsEndpoint) { + endpoint = paramsEndpoint; + } + + const pt = + setOnAny(validBidRequests, 'params.pt') || + setOnAny(validBidRequests, 'params.priceType') || + 'net'; + const tid = bidderRequest.ortb2?.source?.tid; + const currency = getConfig('currency.adServerCurrency'); + const cur = currency && [currency]; + const eids = setOnAny(validBidRequests, 'userIdAsEids'); + const schain = setOnAny(validBidRequests, 'schain'); + + const imp = validBidRequests.map((bid, id) => { + bid.netRevenue = pt; + + const floorInfo = bid.getFloor + ? bid.getFloor({ + currency: currency || 'USD', + }) + : {}; + const bidfloor = floorInfo.floor; + const bidfloorcur = floorInfo.currency; + const { smartadId } = bid.params; + + const imp = { + id: id + 1, + tagid: smartadId, + bidfloor, + bidfloorcur, + ext: { + bidder: { + smartadId: smartadId, + }, + }, + }; + + const assets = _map(bid.nativeParams, (bidParams, key) => { + const props = NATIVE_PARAMS[key]; + const asset = { + required: bidParams.required & 1, + }; + if (props) { + asset.id = props.id; + let wmin, hmin, w, h; + let aRatios = bidParams.aspect_ratios; + + if (aRatios && aRatios[0]) { + aRatios = aRatios[0]; + wmin = aRatios.min_width || 0; + hmin = ((aRatios.ratio_height * wmin) / aRatios.ratio_width) | 0; + } + + if (bidParams.sizes) { + const sizes = flatten(bidParams.sizes); + w = sizes[0]; + h = sizes[1]; + } + + asset[props.name] = { + len: bidParams.len, + type: props.type, + wmin, + hmin, + w, + h, + }; + + return asset; + } + }).filter(Boolean); + + if (assets.length) { + imp.native = { + assets, + }; + } + + const bannerParams = deepAccess(bid, 'mediaTypes.banner'); + + if (bannerParams && bannerParams.sizes) { + const sizes = parseSizesInput(bannerParams.sizes); + const format = sizes.map((size) => { + const [width, height] = size.split('x'); + const w = parseInt(width, 10); + const h = parseInt(height, 10); + return { w, h }; + }); + + imp.banner = { + format, + }; + } + + const videoParams = deepAccess(bid, 'mediaTypes.video'); + if (videoParams) { + imp.video = videoParams; + } + + return imp; + }); + + const request = { + id: bidderRequest.auctionId, + site, + app, + user, + device, + source: { tid, fd: 1 }, + ext: { pt }, + cur, + imp, + }; + + if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies') !== undefined) { + deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent.gdprApplies & 1); + } + + if (bidderRequest.uspConsent) { + deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + + if (eids) { + deepSetValue(request, 'user.ext.eids', eids); + } + + if (schain) { + deepSetValue(request, 'source.ext.schain', schain); + } + + return { + method: 'POST', + url: 'https://' + endpoint + '/cgi-bin/smartads_prebid.pl', + data: JSON.stringify(request), + bids: validBidRequests, + }; + }, + interpretResponse: function (serverResponse, { bids }) { + if (!serverResponse.body || serverResponse?.body?.nbr) { + return; + } + const { seatbid, cur } = serverResponse.body; + + const bidResponses = flatten(seatbid.map((seat) => seat.bid)).reduce((result, bid) => { + result[bid.impid - 1] = bid; + return result; + }, []); + + return bids + .map((bid, id) => { + const bidResponse = bidResponses[id]; + if (bidResponse) { + const mediaType = deepAccess(bidResponse, 'ext.prebid.type'); + const result = { + requestId: bid.bidId, + cpm: bidResponse.price, + creativeId: bidResponse.crid, + ttl: 360, + netRevenue: bid.netRevenue === 'net', + currency: cur, + mediaType, + width: bidResponse.w, + height: bidResponse.h, + dealId: bidResponse.dealid, + meta: { + mediaType, + advertiserDomains: bidResponse.adomain, + }, + }; + + if (bidResponse.native) { + result.native = parseNative(bidResponse); + } else { + result[mediaType === VIDEO ? 'vastXml' : 'ad'] = bidResponse.adm; + } + + if ( + !bid.renderer && + mediaType === VIDEO && + deepAccess(bid, 'mediaTypes.video.context') === 'outstream' + ) { + result.renderer = Renderer.install({ + id: bid.bidId, + url: OUTSTREAM_RENDERER_URL(endpoint), + adUnitCode: bid.adUnitCode, + }); + result.renderer.setRender(renderer); + } + + return result; + } + }) + .filter(Boolean); + }, + getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { + const params = {}; + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params['gdpr'] = Number(gdprConsent.gdprApplies); + } + if (typeof gdprConsent.consentString === 'string') { + params['gdpr_consent'] = gdprConsent.consentString; + } + } + + if (uspConsent) { + params['us_privacy'] = encodeURIComponent(uspConsent); + } + if (syncOptions.iframeEnabled) { + // data is only assigned if params are available to pass to syncEndpoint + return { + type: 'iframe', + url: `https://${endpoint}/prebid/usersync/index.html?${formatQS(params)}`, + }; + } else if (syncOptions.pixelEnabled) { + return { + type: 'image', + url: `https://${endpoint.includes('dev') ? 'dev-' : ''}data.dianomi.com/frontend/usync?${formatQS(params)}`, + }; + } + }, +}; + +registerBidder(spec); + +function parseNative(bid) { + const { assets, link, imptrackers, jstracker } = bid.native; + const result = { + clickUrl: link.url, + clickTrackers: link.clicktrackers || undefined, + impressionTrackers: imptrackers || undefined, + javascriptTrackers: jstracker ? [jstracker] : undefined, + }; + assets.forEach((asset) => { + const kind = NATIVE_ASSET_IDS[asset.id]; + const content = kind && asset[NATIVE_PARAMS[kind].name]; + if (content) { + result[kind] = content.text || + content.value || { + url: content.url, + width: content.w, + height: content.h, + }; + } + }); + + return result; +} + +function setOnAny(collection, key) { + for (let i = 0, result; i < collection.length; i++) { + result = deepAccess(collection[i], key); + if (result) { + return result; + } + } +} + +function flatten(arr) { + return [].concat(...arr); +} + +function renderer(bid) { + bid.renderer.push(() => { + window.Dianomi.renderOutstream(bid); + }); +} diff --git a/modules/dianomiBidAdapter.md b/modules/dianomiBidAdapter.md new file mode 100644 index 00000000000..d530475ce65 --- /dev/null +++ b/modules/dianomiBidAdapter.md @@ -0,0 +1,73 @@ +# Overview + +``` +Module Name: Dianomi Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid-maintainer@dianomi.com +``` + +# Description + +Module that connects to Dianomi's demand sources. Both Native and Banner formats supported. Using oRTB standard. + +# Test Parameters + +```js + var adUnits = [ + { + code: 'test-div-1', + mediaTypes: { + native: { + rendererUrl: "https://dev.dianomi.com/chris/prebid/dianomiRenderer.js", + image: { + required: true, + sizes: [360, 360] + }, + title: { + required: true, + len: 800 + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + privacyLink: { + required: false + }, + body: { + required: false + }, + icon: { + required: false, + sizes: [75, 75] + }, + } + }, + bids: [ + { + bidder: "dianomi", + params: { + smartadId: 12345 // required, provided by Account Manager + } + } + ] + },{ + code: 'test-div-2', + mediaTypes: { + banner: { + sizes: [750, 650], // a below-article size + } + }, + bids: [ + { + bidder: "dianomi", + params: { + smartadId: 23456, // required provided by Account Manager + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/discoveryBidAdapter.js b/modules/discoveryBidAdapter.js new file mode 100644 index 00000000000..7ad75f64215 --- /dev/null +++ b/modules/discoveryBidAdapter.js @@ -0,0 +1,507 @@ +import * as utils from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'discovery'; +const ENDPOINT_URL = 'https://rtb-jp.mediago.io/api/bid?tn='; +const TIME_TO_LIVE = 500; +const storage = getStorageManager({bidderCode: BIDDER_CODE}); +let globals = {}; +let itemMaps = {}; +const MEDIATYPE = [BANNER, NATIVE]; + +/* ----- _ss_pp_id:start ------ */ +const COOKIE_KEY_SSPPID = '_ss_pp_id'; +const COOKIE_KEY_MGUID = '__mguid_'; + +const NATIVERET = { + id: 'id', + bidfloor: 0, + // TODO Dynamic parameters + native: { + ver: '1.2', + plcmtcnt: 1, + assets: [ + { + id: 1, + required: 1, + img: { + type: 3, + w: 300, + wmin: 300, + h: 174, + hmin: 174, + }, + }, + { + id: 2, + required: 1, + title: { + len: 75, + }, + }, + ], + plcmttype: 1, + privacy: 1, + eventtrackers: [ + { + event: 1, + methods: [1, 2], + }, + ], + }, + ext: {}, +}; + +/** + * 获取用户id + * @return {string} + */ +const getUserID = () => { + let idd = storage.getCookie(COOKIE_KEY_SSPPID); + let idm = storage.getCookie(COOKIE_KEY_MGUID); + + if (idd && !idm) { + idm = idd; + } else if (idm && !idd) { + idd = idm; + } else if (!idd && !idm) { + const uuid = utils.generateUUID(); + storage.setCookie(COOKIE_KEY_MGUID, uuid); + storage.setCookie(COOKIE_KEY_SSPPID, uuid); + return uuid; + } + return idd; +}; + +/* ----- _ss_pp_id:end ------ */ + +/** + * get object key -> value + * @param {Object} obj 对象 + * @param {...string} keys 键名 + * @return {any} + */ +function getKv(obj, ...keys) { + let o = obj; + + for (let key of keys) { + if (o && o[key]) { + o = o[key]; + } else { + return ''; + } + } + return o; +} + +/** + * get device + * @return {boolean} + */ +function getDevice() { + let check = false; + (function (a) { + let reg1 = new RegExp( + [ + '(android|bbd+|meego)', + '.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)', + '|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone', + '|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap', + '|windows ce|xda|xiino|android|ipad|playbook|silk', + ].join(''), + 'i' + ); + let reg2 = new RegExp( + [ + '1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)', + '|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )', + '|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell', + '|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)', + '|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene', + '|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c', + '|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom', + '|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)', + '|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)', + '|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]', + '|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)', + '|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio', + '|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms', + '|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al', + '|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)', + '|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|', + 'v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)', + '|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-', + '|your|zeto|zte-', + ].join(''), + 'i' + ); + if (reg1.test(a) || reg2.test(a.substr(0, 4))) { + check = true; + } + })(navigator.userAgent || navigator.vendor || window.opera); + return check; +} + +/** + * get BidFloor + * @param {*} bid + * @param {*} mediaType + * @param {*} sizes + * @returns + */ +function getBidFloor(bid) { + if (!utils.isFn(bid.getFloor)) { + return utils.deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0; + } +} + +/** + * get sizes for rtb + * @param {Array|Object} requestSizes + * @return {Object} + */ +function transformSizes(requestSizes) { + let sizes = []; + let sizeObj = {}; + + if ( + utils.isArray(requestSizes) && + requestSizes.length === 2 && + !utils.isArray(requestSizes[0]) + ) { + sizeObj.width = parseInt(requestSizes[0], 10); + sizeObj.height = parseInt(requestSizes[1], 10); + sizes.push(sizeObj); + } else if (typeof requestSizes === 'object') { + for (let i = 0; i < requestSizes.length; i++) { + let size = requestSizes[i]; + sizeObj = {}; + sizeObj.width = parseInt(size[0], 10); + sizeObj.height = parseInt(size[1], 10); + sizes.push(sizeObj); + } + } + + return sizes; +} + +// Support sizes +const popInAdSize = [ + { w: 300, h: 250 }, + { w: 300, h: 600 }, + { w: 728, h: 90 }, + { w: 970, h: 250 }, + { w: 320, h: 50 }, + { w: 160, h: 600 }, + { w: 320, h: 180 }, + { w: 320, h: 100 }, + { w: 336, h: 280 }, +]; + +/** + * get aditem setting + * @param {Array} validBidRequests an an array of bids + * @param {Object} bidderRequest The master bidRequest object + * @return {Object} + */ +function getItems(validBidRequests, bidderRequest) { + let items = []; + items = validBidRequests.map((req, i) => { + let ret = {}; + // eslint-disable-next-line no-debugger + let mediaTypes = getKv(req, 'mediaTypes'); + + const bidFloor = getBidFloor(req); + let id = '' + (i + 1); + + if (mediaTypes.native) { + ret = { ...NATIVERET, ...{ id, bidFloor } }; + } + // banner + if (mediaTypes.banner) { + let sizes = transformSizes(getKv(req, 'sizes')); + let matchSize; + + for (let size of sizes) { + matchSize = popInAdSize.find( + (item) => size.width === item.w && size.height === item.h + ); + if (matchSize) { + break; + } + } + if (!matchSize) { + matchSize = sizes[0] + ? { h: sizes[0].height || 0, w: sizes[0].width || 0 } + : { h: 0, w: 0 }; + } + ret = { + id: id, + bidfloor: bidFloor, + banner: { + h: matchSize.h, + w: matchSize.w, + pos: 1, + format: sizes, + }, + ext: {}, + tagid: req.params && req.params.tagid + }; + } + itemMaps[id] = { + req, + ret, + }; + return ret; + }); + return items; +} + +/** + * get rtb qequest params + * + * @param {Array} validBidRequests an an array of bids + * @param {Object} bidderRequest The master bidRequest object + * @return {Object} + */ +function getParam(validBidRequests, bidderRequest) { + const pubcid = utils.deepAccess(validBidRequests[0], 'crumbs.pubcid'); + const sharedid = + utils.deepAccess(validBidRequests[0], 'userId.sharedid.id') || + utils.deepAccess(validBidRequests[0], 'userId.pubcid'); + const eids = validBidRequests[0].userIdAsEids || validBidRequests[0].userId; + + let isMobile = getDevice() ? 1 : 0; + // input test status by Publisher. more frequently for test true req + let isTest = validBidRequests[0].params.test || 0; + let auctionId = getKv(bidderRequest, 'auctionId'); + let items = getItems(validBidRequests, bidderRequest); + + const timeout = bidderRequest.timeout || 2000; + + const domain = + utils.deepAccess(bidderRequest, 'refererInfo.domain') || document.domain; + const location = utils.deepAccess(bidderRequest, 'refererInfo.referer'); + const page = utils.deepAccess(bidderRequest, 'refererInfo.page'); + const referer = utils.deepAccess(bidderRequest, 'refererInfo.ref'); + const firstPartyData = bidderRequest.ortb2; + + if (items && items.length) { + let c = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + id: 'pp_hbjs_' + auctionId, + test: +isTest, + at: 1, + bcat: globals['bcat'], + badv: globals['adv'], + cur: ['USD'], + device: { + connectiontype: 0, + js: 1, + os: navigator.platform || '', + ua: navigator.userAgent, + language: /en/.test(navigator.language) ? 'en' : navigator.language, + }, + ext: { + eids, + firstPartyData, + }, + user: { + buyeruid: getUserID(), + id: sharedid || pubcid, + }, + eids, + tmax: timeout, + site: { + name: domain, + domain: domain, + page: page || location, + ref: referer, + mobile: isMobile, + cat: [], // todo + publisher: { + id: globals['publisher'], + // todo + // name: xxx + }, + }, + imp: items, + }; + return c; + } else { + return null; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: MEDIATYPE, + // aliases: ['ex'], // short code + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + if (bid.params.token) { + globals['token'] = bid.params.token; + } + if (bid.params.publisher) { + globals['publisher'] = bid.params.publisher; + } + if (bid.params.tagid) { + globals['tagid'] = bid.params.tagid; + } + if (bid.params.bcat) { + globals['bcat'] = Array.isArray(bid.params.bcat) ? bid.params.bcat : []; + } + if (bid.params.badv) { + globals['badv'] = Array.isArray(bid.params.badv) ? bid.params.badv : []; + } + return !!(bid.params.token && bid.params.publisher && bid.params.tagid); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {Array} validBidRequests an an array of bids + * @param {Object} bidderRequest The master bidRequest object + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + let payload = getParam(validBidRequests, bidderRequest); + + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: ENDPOINT_URL + globals['token'], + data: payloadString, + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequest) { + const bids = getKv(serverResponse, 'body', 'seatbid', 0, 'bid'); + const cur = getKv(serverResponse, 'body', 'cur'); + const bidResponses = []; + for (let bid of bids) { + let impid = getKv(bid, 'impid'); + if (itemMaps[impid]) { + let bidId = getKv(itemMaps[impid], 'req', 'bidId'); + const mediaType = getKv(bid, 'w') ? 'banner' : 'native'; + let bidResponse = { + requestId: bidId, + cpm: getKv(bid, 'price'), + creativeId: getKv(bid, 'cid'), + mediaType, + currency: cur, + netRevenue: true, + nurl: getKv(bid, 'nurl'), + ttl: TIME_TO_LIVE, + meta: { + advertiserDomains: getKv(bid, 'adomain') || [], + }, + }; + if (mediaType === 'native') { + const adm = getKv(bid, 'adm'); + const admObj = JSON.parse(adm); + var native = {}; + admObj.assets.forEach((asset) => { + if (asset.title) { + native.title = asset.title.text; + } else if (asset.data) { + native.data = asset.data.value; + } else if (asset.img) { + switch (asset.img.type) { + case 1: + native.icon = { + url: asset.img.url, + width: asset.img.w, + height: asset.img.h, + }; + break; + default: + native.image = { + url: asset.img.url, + width: asset.img.w, + height: asset.img.h, + }; + break; + } + } + }); + if (admObj.link) { + if (admObj.link.url) { + native.clickUrl = admObj.link.url; + } + } + if (Array.isArray(admObj.eventtrackers)) { + native.impressionTrackers = []; + admObj.eventtrackers.forEach((tracker) => { + if (tracker.event !== 1) { + return; + } + switch (tracker.method) { + case 1: + native.impressionTrackers.push(tracker.url); + break; + // case 2: + // native.javascriptTrackers = ``; + // break; + } + }); + } + if (admObj.purl) { + native.purl = admObj.purl; + } + bidResponse['native'] = native; + } else { + bidResponse['width'] = getKv(bid, 'w'); + bidResponse['height'] = getKv(bid, 'h'); + bidResponse['ad'] = getKv(bid, 'adm'); + } + bidResponses.push(bidResponse); + } + } + + return bidResponses; + }, + + /** + * Register bidder specific code, which will execute if bidder timed out after an auction + * @param {data} Containing timeout specific data + */ + onTimeout: function (data) { + utils.logError('DiscoveryDSP adapter timed out for the auction.'); + // TODO send request timeout to serve, the interface is not ready + }, + + /** + * Register bidder specific code, which will execute if a bid from this bidder won the auction + * @param {Bid} The bid that won the auction + */ + onBidWon: function (bid) { + if (bid['nurl']) { + utils.triggerPixel(bid['nurl']); + } + }, +}; +registerBidder(spec); diff --git a/modules/discoveryBidAdapter.md b/modules/discoveryBidAdapter.md new file mode 100644 index 00000000000..e951b0b7448 --- /dev/null +++ b/modules/discoveryBidAdapter.md @@ -0,0 +1,61 @@ +# Overview + +``` +Module Name: discovery Bid Adapter +Module Type: Bidder Adapter +``` + +# Description + +Module that connects to popIn's demand sources. + +The discovery Bidding adapter requires setup before beginning. Please contact us at + +# Test Parameters +``` + var adUnits = [ + // native + { + code: "test-div-1", + mediaTypes: { + native: { + title: { + required: true + }, + image: { + required: true + } + } + }, + bids: [ + { + bidder: "discovery", + params: { + token: "a1b067897e4ae093d1f94261e0ddc6c9", + tagid: 'test_tagid', + publisher: 'test_publisher' + }, + }, + ], + }, + // banner + { + code: "test-div-2", + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: "discovery", + params: { + token: "d0f4902b616cc5c38cbe0a08676d0ed9", + tagid: 'test_tagid', + publisher: 'test_publisher' + }, + }, + ], + }, + ]; +``` diff --git a/modules/displayioBidAdapter.js b/modules/displayioBidAdapter.js index 55a2f4a8604..3cdfd3a77cd 100644 --- a/modules/displayioBidAdapter.js +++ b/modules/displayioBidAdapter.js @@ -1,16 +1,19 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; +import {logWarn} from '../src/utils.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; -const BIDDER_VERSION = '1.0.0'; +const ADAPTER_VERSION = '1.1.0'; const BIDDER_CODE = 'displayio'; -const GVLID = 999; const BID_TTL = 300; const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const DEFAULT_CURRENCY = 'USD'; +const US_KEY = '_dio_us'; export const spec = { code: BIDDER_CODE, - gvlid: GVLID, supportedMediaTypes: SUPPORTED_AD_TYPES, isBidRequestValid: function(bid) { return !!(bid.params && bid.params.placementId && bid.params.siteId && @@ -20,7 +23,7 @@ export const spec = { return bidRequests.map(bid => { let url = '//' + bid.params.adsSrvDomain + '/srv?method=getPlacement&app=' + bid.params.siteId + '&placement=' + bid.params.placementId; - const data = this._getPayload(bid, bidderRequest); + const data = getPayload(bid, bidderRequest); return { method: 'POST', headers: {'Content-Type': 'application/json;charset=utf-8'}, @@ -42,116 +45,120 @@ export const spec = { height: adData.h, netRevenue: true, ttl: BID_TTL, - creativeId: adData.adId || 0, - currency: DEFAULT_CURRENCY, + creativeId: adData.adId || 1, + currency: adData.cur || DEFAULT_CURRENCY, referrer: data.data.ref, - mediaType: ads[0].ad.subtype, + mediaType: ads[0].ad.subtype === 'videoVast' ? VIDEO : BANNER, ad: adData.markup, - placement: data.placement, + adUnitCode: data.adUnitCode, + renderURL: data.renderURL, adData: adData }; - if (bidResponse.vastUrl === 'videoVast') { - bidResponse.vastUrl = adData.videos[0].url + + if (bidResponse.mediaType === VIDEO) { + bidResponse.vastUrl = adData.videos[0] && adData.videos[0].url + } + + if (bidResponse.renderURL) { + bidResponse.renderer = newRenderer(bidResponse); } bidResponses.push(bidResponse); } return bidResponses; - }, - _getPayload: function (bid, bidderRequest) { - const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; - const userSession = 'us_web_xxxxxxxxxxxx'.replace(/[x]/g, c => { - let r = Math.random() * 16 | 0; - let v = c === 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); - const { params } = bid; - const { siteId, placementId } = params; - const { refererInfo, uspConsent, gdprConsent } = bidderRequest; - const mediation = {consent: '-1', gdpr: '-1'}; - if (gdprConsent) { - if (gdprConsent.consentString !== undefined) { - mediation.consent = gdprConsent.consentString; - } - if (gdprConsent.gdprApplies !== undefined) { - mediation.gdpr = gdprConsent.gdprApplies ? '1' : '0'; - } + } +}; + +function getPayload (bid, bidderRequest) { + const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; + const storage = getStorageManager({bidderCode: BIDDER_CODE}); + const userSession = (() => { + let us = storage.getDataFromLocalStorage(US_KEY); + if (!us) { + us = 'us_web_xxxxxxxxxxxx'.replace(/[x]/g, c => { + let r = Math.random() * 16 | 0; + let v = c === 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + storage.setDataInLocalStorage(US_KEY, us); + } + return us + })(); + const { params, adUnitCode, bidId } = bid; + const { siteId, placementId, renderURL, pageCategory, keywords } = params; + const { refererInfo, uspConsent, gdprConsent } = bidderRequest; + const mediation = {gdprConsent: '', gdpr: '-1'}; + if (gdprConsent && 'gdprApplies' in gdprConsent) { + if (gdprConsent.consentString !== undefined) { + mediation.gdprConsent = gdprConsent.consentString; } - const payload = { - userSession, + if (gdprConsent.gdprApplies !== undefined) { + mediation.gdpr = gdprConsent.gdprApplies ? '1' : '0'; + } + } + return { + userSession, + data: { + id: bidId, + action: 'getPlacement', + app: siteId, + placement: placementId, + adUnitCode, + renderURL, data: { - id: bid.bidId, - action: 'getPlacement', - app: siteId, - placement: placementId, - data: { - pagecat: params.pageCategory ? params.pageCategory.split(',').map(k => k.trim()) : [], - keywords: params.keywords ? params.keywords.split(',').map(k => k.trim()) : [], - lang_content: document.documentElement.lang, - lang: window.navigator.language, - domain: window.location.hostname, - page: window.location.href, - ref: refererInfo.referer, - userids: _getUserIDs(), - geo: '', - }, - complianceData: { - child: '-1', - us_privacy: uspConsent, - dnt: window.navigator.doNotTrack, - iabConsent: {}, - mediation: { - consent: mediation.consent, - gdpr: mediation.gdpr, - } - }, - integration: 'JS', - omidpn: 'Displayio', - mediationPlatform: 0, - prebidVersion: BIDDER_VERSION, - device: { - w: window.screen.width, - h: window.screen.height, - connection_type: connection ? connection.effectiveType : '', + pagecat: pageCategory ? pageCategory.split(',').map(k => k.trim()) : [], + keywords: getAllOrtbKeywords(bidderRequest.ortb2, keywords), + lang_content: document.documentElement.lang, + lang: window.navigator.language, + domain: refererInfo.domain, + page: refererInfo.page, + ref: refererInfo.referer, + userids: bid.userIdAsEids || {}, + geo: '', + }, + complianceData: { + child: '-1', + us_privacy: uspConsent, + dnt: window.doNotTrack === '1' || window.navigator.doNotTrack === '1' || false, + iabConsent: {}, + mediation: { + gdprConsent: mediation.gdprConsent, + gdpr: mediation.gdpr, } + }, + integration: 'JS', + omidpn: 'Displayio', + mediationPlatform: 0, + prebidVersion: ADAPTER_VERSION, + device: { + w: window.screen.width, + h: window.screen.height, + connection_type: connection ? connection.effectiveType : '', } } - if (navigator.permissions) { - navigator.permissions.query({ name: 'geolocation' }) - .then((result) => { - if (result.state === 'granted') { - payload.data.data.geo = _getGeoData(); - } - }); - } - return payload } -}; +} + +function newRenderer(bid) { + const renderer = Renderer.install({ + id: bid.requestId, + url: bid.renderURL, + adUnitCode: bid.adUnitCode + }); -function _getUserIDs () { - let ids = {}; try { - ids = window.owpbjs.getUserIdsAsEids(); - } catch (e) {} - return ids; + renderer.setRender(webisRender); + } catch (err) { + logWarn('Prebid Error calling setRender on renderer', err); + } + + return renderer; } -async function _getGeoData () { - let geoData = null; - const getCurrentPosition = () => { - return new Promise((resolve, reject) => - navigator.geolocation.getCurrentPosition(resolve, reject) - ); - } - try { - const position = await getCurrentPosition(); - let {latitude, longitude, accuracy} = position.coords; - geoData = { - 'lat': latitude, - 'lng': longitude, - 'precision': accuracy - }; - } catch (e) {} - return geoData +function webisRender(bid, doc) { + bid.renderer.push(() => { + const win = doc?.defaultView || window; + win.webis.init(bid.adData, bid.adUnitCode, bid.params); + }) } registerBidder(spec); diff --git a/modules/districtmDMXBidAdapter.js b/modules/districtmDMXBidAdapter.js deleted file mode 100644 index f909a1f1329..00000000000 --- a/modules/districtmDMXBidAdapter.js +++ /dev/null @@ -1,433 +0,0 @@ -import { isArray, generateUUID, deepAccess, isStr } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'districtmDMX'; - -const DMXURI = 'https://dmx.districtm.io/b/v1'; - -const GVLID = 144; -const VIDEO_MAPPING = { - playback_method: { - 'auto_play_sound_on': 1, - 'auto_play_sound_off': 2, - 'click_to_play': 3, - 'mouse_over': 4, - 'viewport_sound_on': 5, - 'viewport_sound_off': 6 - } -}; -export const spec = { - code: BIDDER_CODE, - gvlid: GVLID, - aliases: ['dmx'], - supportedFormat: [BANNER, VIDEO], - supportedMediaTypes: [VIDEO, BANNER], - isBidRequestValid(bid) { - return !!(bid.params.memberid); - }, - interpretResponse(response, bidRequest) { - response = response.body || {}; - if (response.seatbid) { - if (isArray(response.seatbid)) { - const { seatbid } = response; - let winners = seatbid.reduce((bid, ads) => { - let ad = ads.bid.reduce(function (oBid, nBid) { - if (oBid.price < nBid.price) { - const bid = matchRequest(nBid.impid, bidRequest); - const { width, height } = defaultSize(bid); - nBid.cpm = parseFloat(nBid.price).toFixed(2); - nBid.bidId = nBid.impid; - nBid.requestId = nBid.impid; - nBid.width = nBid.w || width; - nBid.height = nBid.h || height; - nBid.ttl = 300; - nBid.mediaType = bid.mediaTypes && bid.mediaTypes.video ? 'video' : 'banner'; - if (nBid.mediaType === 'video') { - nBid.vastXml = cleanVast(nBid.adm, nBid.nurl); - nBid.ttl = 3600; - } - if (nBid.dealid) { - nBid.dealId = nBid.dealid; - } - nBid.uuid = nBid.bidId; - nBid.ad = nBid.adm; - nBid.netRevenue = true; - nBid.creativeId = nBid.crid; - nBid.currency = 'USD'; - nBid.meta = nBid.meta || {}; - if (nBid.adomain && nBid.adomain.length > 0) { - nBid.meta.advertiserDomains = nBid.adomain; - } - return nBid; - } else { - oBid.cpm = oBid.price; - return oBid; - } - }, { price: 0 }); - if (ad.adm) { - bid.push(ad) - } - return bid; - }, []) - let winnersClean = winners.filter(w => { - if (w.bidId) { - return true; - } - return false; - }); - return winnersClean; - } else { - return []; - } - } else { - return []; - } - }, - buildRequests(bidRequest, bidderRequest) { - let timeout = config.getConfig('bidderTimeout'); - let schain = null; - let dmxRequest = { - id: generateUUID(), - cur: ['USD'], - tmax: (timeout - 300), - test: this.test() || 0, - site: { - publisher: { id: String(bidRequest[0].params.memberid) || null } - } - } - - try { - let params = config.getConfig('dmx'); - dmxRequest.user = params.user || {}; - let site = params.site || {}; - dmxRequest.site = { ...dmxRequest.site, ...site } - } catch (e) { - - } - - let eids = []; - if (bidRequest[0] && bidRequest[0].userId) { - bindUserId(eids, deepAccess(bidRequest[0], `userId.idl_env`), 'liveramp.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.id5id.uid`), 'id5-sync.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.pubcid`), 'pubcid.org', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.tdid`), 'adserver.org', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.criteoId`), 'criteo.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.britepoolid`), 'britepool.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.lipb.lipbid`), 'liveintent.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.intentiqid`), 'intentiq.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.lotamePanoramaId`), 'lotame.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.parrableId`), 'parrable.com', 1); - bindUserId(eids, deepAccess(bidRequest[0], `userId.netId`), 'netid.de', 1); - dmxRequest.user = dmxRequest.user || {}; - dmxRequest.user.ext = dmxRequest.user.ext || {}; - dmxRequest.user.ext.eids = eids; - } - if (!dmxRequest.test) { - delete dmxRequest.test; - } - if (bidderRequest.gdprConsent) { - dmxRequest.regs = {}; - dmxRequest.regs.ext = {}; - dmxRequest.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0; - - if (bidderRequest.gdprConsent.gdprApplies === true) { - dmxRequest.user = {}; - dmxRequest.user.ext = {}; - dmxRequest.user.ext.consent = bidderRequest.gdprConsent.consentString; - } - } - dmxRequest.regs = dmxRequest.regs || {}; - dmxRequest.regs.coppa = config.getConfig('coppa') === true ? 1 : 0; - if (bidderRequest && bidderRequest.uspConsent) { - dmxRequest.regs = dmxRequest.regs || {}; - dmxRequest.regs.ext = dmxRequest.regs.ext || {}; - dmxRequest.regs.ext.us_privacy = bidderRequest.uspConsent; - } - try { - schain = bidRequest[0].schain; - dmxRequest.source = {}; - dmxRequest.source.ext = {}; - dmxRequest.source.ext.schain = schain || {} - } catch (e) { } - let tosendtags = bidRequest.map(dmx => { - var obj = {}; - obj.id = dmx.bidId; - obj.tagid = String(dmx.params.dmxid || dmx.adUnitCode); - obj.secure = 1; - obj.bidfloor = getFloor(dmx); - if (dmx.mediaTypes && dmx.mediaTypes.video) { - obj.video = { - topframe: 1, - skip: dmx.mediaTypes.video.skip || 0, - linearity: dmx.mediaTypes.video.linearity || 1, - minduration: dmx.mediaTypes.video.minduration || 5, - maxduration: dmx.mediaTypes.video.maxduration || 60, - playbackmethod: dmx.mediaTypes.video.playbackmethod || [2], - api: getApi(dmx.mediaTypes.video), - mimes: dmx.mediaTypes.video.mimes || ['video/mp4'], - protocols: getProtocols(dmx.mediaTypes.video), - h: dmx.mediaTypes.video.playerSize[0][1], - w: dmx.mediaTypes.video.playerSize[0][0] - }; - } else { - obj.banner = { - topframe: 1, - w: cleanSizes(dmx.sizes, 'w'), - h: cleanSizes(dmx.sizes, 'h'), - format: cleanSizes(dmx.sizes).map(s => { - return { w: s[0], h: s[1] }; - }).filter(obj => typeof obj.w === 'number' && typeof obj.h === 'number') - }; - } - return obj; - }); - - if (tosendtags.length <= 5) { - dmxRequest.imp = tosendtags; - return { - method: 'POST', - url: DMXURI, - data: JSON.stringify(dmxRequest), - bidderRequest - } - } else { - return upto5(tosendtags, dmxRequest, bidderRequest, DMXURI); - } - }, - test() { - return window.location.href.indexOf('dmTest=true') !== -1 ? 1 : 0; - }, - getUserSyncs(optionsType, serverResponses, gdprConsent, uspConsent) { - let query = []; - let url = 'https://cdn.districtm.io/ids/index.html' - if (gdprConsent && gdprConsent.gdprApplies && typeof gdprConsent.consentString === 'string') { - query.push(['gdpr', gdprConsent.consentString]) - } - if (uspConsent) { - query.push(['ccpa', uspConsent]) - } - if (query.length > 0) { - url += '?' + query.map(q => q.join('=')).join('&') - } - if (optionsType.iframeEnabled) { - return [{ - type: 'iframe', - url: url - }]; - } - } -} - -export function getFloor(bid) { - let floor = null; - if (typeof bid.getFloor === 'function') { - const floorInfo = bid.getFloor({ - currency: 'USD', - mediaType: bid.mediaTypes.video ? 'video' : 'banner', - size: bid.sizes.map(size => { - return { - w: size[0], - h: size[1] - } - }) - }); - if (typeof floorInfo === 'object' && - floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { - floor = parseFloat(floorInfo.floor); - } - } - return floor !== null ? floor : bid.params.floor; -} - -export function cleanSizes(sizes, value) { - const supportedSize = [ - { - size: [300, 250], - s: 100 - }, - { - size: [728, 90], - s: 95 - }, - { - size: [320, 50], - s: 90 - }, - { - size: [160, 600], - s: 88 - }, - { - size: [300, 600], - s: 85 - }, - { - size: [300, 50], - s: 80 - }, - { - size: [970, 250], - s: 75 - }, - { - size: [970, 90], - s: 60 - }, - ]; - let newArray = shuffle(sizes, supportedSize); - switch (value) { - case 'w': - return newArray[0][0] || 0; - case 'h': - return newArray[0][1] || 0; - case 'size': - return newArray; - default: - return newArray; - } -} - -export function shuffle(sizes, list) { - let removeSizes = sizes.filter(size => { - return list.map(l => `${l.size[0]}x${l.size[1]}`).indexOf(`${size[0]}x${size[1]}`) === -1 - }) - let reOrder = sizes.reduce((results, current) => { - if (results.length === 0) { - results.push(current); - return results; - } - results.push(current); - results = list.filter(l => results.map(r => `${r[0]}x${r[1]}`).indexOf(`${l.size[0]}x${l.size[1]}`) !== -1); - results = results.sort(function (a, b) { - return b.s - a.s; - }) - return results.map(r => r.size); - }, []) - return removeDuplicate([...reOrder, ...removeSizes]); -} - -export function removeDuplicate(arrayValue) { - return arrayValue.filter((elem, index) => { - return arrayValue.map(e => `${e[0]}x${e[1]}`).indexOf(`${elem[0]}x${elem[1]}`) === index - }) -} - -export function upto5(allimps, dmxRequest, bidderRequest, DMXURI) { - let start = 0; - let step = 5; - let req = []; - while (allimps.length !== 0) { - if (allimps.length >= 5) { - req.push(allimps.splice(start, step)) - } else { - req.push(allimps.splice(start, allimps.length)) - } - } - return req.map(r => { - dmxRequest.imp = r; - return { - method: 'POST', - url: DMXURI, - data: JSON.stringify(dmxRequest), - bidderRequest - } - }) -} - -/** - * Function matchRequest(id: string, BidRequest: object) - * @param id - * @type string - * @param bidRequest - * @type Object - * @returns Object - * - */ -export function matchRequest(id, bidRequest) { - const { bids } = bidRequest.bidderRequest; - const [returnValue] = bids.filter(bid => bid.bidId === id); - return returnValue; -} -export function checkDeepArray(Arr) { - if (Array.isArray(Arr)) { - if (Array.isArray(Arr[0])) { - return Arr[0]; - } else { - return Arr; - } - } else { - return Arr; - } -} -export function defaultSize(thebidObj) { - const { sizes } = thebidObj; - const returnObject = {}; - returnObject.width = checkDeepArray(sizes)[0]; - returnObject.height = checkDeepArray(sizes)[1]; - return returnObject; -} - -export function bindUserId(eids, value, source, atype) { - if (isStr(value) && Array.isArray(eids)) { - eids.push({ - source, - uids: [ - { - id: value, - atype - } - ] - }) - } -} - -export function getApi({ api }) { - let defaultValue = [2]; - if (api && Array.isArray(api) && api.length > 0) { - return api - } else { - return defaultValue; - } -} -export function getPlaybackmethod(playback) { - if (Array.isArray(playback) && playback.length > 0) { - return playback.map(label => { - return VIDEO_MAPPING.playback_method[label] - }) - } - return [2] -} - -export function getProtocols({ protocols }) { - let defaultValue = [2, 3, 5, 6, 7, 8]; - if (protocols && Array.isArray(protocols) && protocols.length > 0) { - return protocols; - } else { - return defaultValue; - } -} - -export function cleanVast(str, nurl) { - try { - const toberemove = /]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/ - const [img, url] = str.match(toberemove) - str = str.replace(toberemove, '') - if (img) { - if (url) { - const insrt = `` - str = str.replace('', `${insrt}`) - } - } - return str; - } catch (e) { - if (!nurl) { - return str - } - const insrt = `` - str = str.replace('', `${insrt}`) - return str - } -} -registerBidder(spec); diff --git a/modules/districtmDmxBidAdapter.md b/modules/districtmDmxBidAdapter.md deleted file mode 100644 index 5d5dd2affe6..00000000000 --- a/modules/districtmDmxBidAdapter.md +++ /dev/null @@ -1,203 +0,0 @@ -``` -Module Name: district m Bid Adapter -Module Type: Bidder Adapter -Maintainer: Steve Alliance (steve@districtm.net) -``` - -# Overview - -The `districtmDmxAdapter` module allows publishers to include DMX Exchange demand using Prebid 1.0+. - -## Attributes - -* Single Request -* Multi-Size Support -* GDPR Compliant -* CCPA Compliant -* COPPA Compliant -* Bids returned in **NET** - - ## Media Types - -* Banner -* Video -## Bidder Parameters - -| Key | Scope | Type | Description -| --- | --- | --- | --- -| `dmxid` | Mandatory | Integer | Unique identifier of the placement, dmxid can be obtained in the district m Boost platform. -| `memberid` | Mandatory | Integer | Unique identifier for your account, memberid can be obtained in the district m Boost platform. -| `floor` | Optional | float | Most placement can have floor set in our platform, but this can now be set on the request too. - -# Ad Unit Configuration Example - -```javascript - var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [{ - bidder: 'districtmDMX', - params: { - dmxid: 100001, - memberid: 100003 - } - }] - }]; -``` - -# Ad Unit Configuration Example for video request - -```javascript - var videoAdUnit = { - code: 'video1', - sizes: [640,480], - mediaTypes: { video: {context: 'instream', //or 'outstream' - playerSize: [[640, 480]], - skipppable: true, - minduration: 5, - maxduration: 45, - playback_method: ['auto_play_sound_off', 'viewport_sound_off'], - mimes: ["application/javascript", - "video/mp4"], - - } }, - bids: [ - { - bidder: 'districtmDMX', - params: { - dmxid: '100001', - memberid: '100003', - } - } - - ] - }; -``` - - -# Ad Unit Configuration when COPPA is needed - - -# Quick Start Guide - -###### 1. Including the `districtmDmxAdapter` in your build process. - -Add the adapter as an argument to gulp build. - -``` -gulp build --modules=districtmDmxAdapter,ixBidAdapter,appnexusBidAdapter -``` - -*Adding `"districtmDmxAdapter"` as an entry in a JSON file with your bidders is also acceptable.* - -``` -[ - "districtmDmxAdapter", - "ixBidAdapter", - "appnexusBidAdapter" -] -``` - -*Proceed to build with the JSON file.* - -``` -gulp build --modules=bidderModules.json -``` - -###### 2. Configure the ad unit object - -Once Prebid is ready you may use the below example to create the adUnits object and begin building the configuration. - -```javascript -var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600], [728, 90]], - } - }, - bids: [] - } -]; -``` - -###### 3. Add the bidder - -Our demand and adapter supports multiple sizes per placement, as such a single dmxid may be used for all sizes of a single domain. - -```javascript - var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600], [728, 90]], - } - }, - bids: [{ - bidder: 'districtmDMX', - params: { - dmxid: 100001, - memberid: 100003 - } - }] - }]; -``` - -Our bidder only supports instream context at the moment and we strongly like to put the media types and setting in the ad unit settings. -If no value is set the default value will be applied. - -```javascript - var videoAdUnit = { - code: 'video1', - sizes: [640,480], - mediaTypes: { video: {context: 'instream', //or 'outstream' - playerSize: [[640, 480]], - skipppable: true, - minduration: 5, - maxduration: 45, - playback_method: ['auto_play_sound_off', 'viewport_sound_off'], - mimes: ["application/javascript", - "video/mp4"], - - } }, - bids: [ - { - bidder: 'districtmDMX', - params: { - dmxid: '250258', - memberid: '100600', - } - } - ] - }; -``` - -###### 4. Implementation Checking - -Once the bidder is live in your Prebid configuration you may confirm it is making requests to our end point by looking for requests to `https://dmx.districtm.io/b/v1`. - - -###### 5. Setting first party data - -```code -pbjs.setConfig({ - dmx: { - user: { - 'gender': 'M', - 'yob': 1992, - // keywords example - 'keywords': 'automotive,dodge,engine,car' - - }, - site: { - cat: ['IAB-12'], - pagecat: ['IAB-14'], - sectioncat: ['IAB-24'] - } - } -}); -``` diff --git a/modules/distroscaleBidAdapter.js b/modules/distroscaleBidAdapter.js index 822bea3603a..7a2038ed3f0 100644 --- a/modules/distroscaleBidAdapter.js +++ b/modules/distroscaleBidAdapter.js @@ -129,7 +129,26 @@ export const spec = { }, buildRequests: (validBidRequests, bidderRequest) => { - var pageUrl = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || window.location.href; + // TODO: does the fallback to window.location make sense? + var pageUrl = bidderRequest?.refererInfo?.page || window.location.href; + + // check if dstag is already loaded in ancestry tree + var dsloaded = 0; + try { + var win = window; + while (true) { + if (win.vx.cs_loaded) { + dsloaded = 1; + } + if (win != win.parent) { + win = win.parent; + } else { + break; + } + } + } catch (error) { + // ignore exception + } var payload = { id: '' + (new Date()).getTime(), @@ -148,7 +167,9 @@ export const spec = { }, imp: [], user: {}, - ext: {} + ext: { + dsloaded: dsloaded + } }; validBidRequests.forEach(b => { @@ -197,7 +218,7 @@ export const spec = { } // First Party Data - const commonFpd = config.getConfig('ortb2') || {}; + const commonFpd = bidderRequest.ortb2 || {}; if (commonFpd.site) { mergeDeep(payload, {site: commonFpd.site}); } diff --git a/modules/divreachBidAdapter.md b/modules/divreachBidAdapter.md deleted file mode 100644 index 643845782b8..00000000000 --- a/modules/divreachBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -Module Name: DivReach Bidder Adapter -Module Type: Bidder Adapter -Maintainer: Zeke@divreach.com - -# Description - -Connects to DivReach demand source to fetch bids. -Please use ```divreach``` as the bidder code. - -# Test Parameters -``` - var adUnits = [ - { - code: 'desktop-banner-ad-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "divreach", - params: { - accountID: '167283', - zoneID: '335105', - domain: 'ad.divreach.com', - } - } - ] - }, - ]; -``` diff --git a/modules/djaxBidAdapter.md b/modules/djaxBidAdapter.md deleted file mode 100644 index d597eb59b58..00000000000 --- a/modules/djaxBidAdapter.md +++ /dev/null @@ -1,50 +0,0 @@ -# Overview - -``` -Module Name: djax Bid Adapter -Module Type: Bidder Adapter -Maintainer : support@djaxtech.com -``` - -# Description - -Connects to Djax Ad Server for bids. - -djax bid adapter supports Banner and Video. - -# Test Parameters -``` - var adUnits = [ - //bannner object - { - code: 'banner-ad-slot', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [{ - bidder: 'djax', - params: { - publisherId: 2 - } - }] - - }, - //video object - { - code: 'video-ad-slot', - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480], - }, - }, - bids: [{ - bidder: "djax", - params: { - publisherId: 2 - } - }] - }]; -``` \ No newline at end of file diff --git a/modules/dmdIdSystem.js b/modules/dmdIdSystem.js index b42315d66ee..2f910a8bd92 100644 --- a/modules/dmdIdSystem.js +++ b/modules/dmdIdSystem.js @@ -85,6 +85,12 @@ export const dmdIdSubmodule = { }; return { callback: resp }; } + }, + eids: { + 'dmdId': { + source: 'hcn.health', + atype: 3 + }, } }; diff --git a/modules/docereeBidAdapter.js b/modules/docereeBidAdapter.js index 737a9f707db..fa4446ede47 100644 --- a/modules/docereeBidAdapter.js +++ b/modules/docereeBidAdapter.js @@ -1,7 +1,7 @@ -import { tryAppendQueryString } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER } from '../src/mediaTypes.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; const BIDDER_CODE = 'doceree'; const END_POINT = 'https://bidder.doceree.com' @@ -24,6 +24,7 @@ export const spec = { buildRequests: (validBidRequests) => { const serverRequests = []; const { data } = config.getConfig('doceree.user') + // TODO: this should probably look at refererInfo const { page, domain, token } = config.getConfig('doceree.context') const encodedUserInfo = window.btoa(encodeURIComponent(JSON.stringify(data))) diff --git a/modules/dspxBidAdapter.js b/modules/dspxBidAdapter.js index da73fdd0177..b8e812f581a 100644 --- a/modules/dspxBidAdapter.js +++ b/modules/dspxBidAdapter.js @@ -1,12 +1,16 @@ -import { deepAccess } from '../src/utils.js'; -import {config} from '../src/config.js'; +import {deepAccess, getBidIdParameter, isFn, logError, logMessage, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; +import {includes} from '../src/polyfill.js'; const BIDDER_CODE = 'dspx'; const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/'; const GVLID = 602; +const VIDEO_ORTB_PARAMS = ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', 'placement', 'linearity', 'skip', 'skipmin', + 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', + 'api', 'companiontype', 'ext']; export const spec = { code: BIDDER_CODE, @@ -17,24 +21,35 @@ export const spec = { return !!(bid.params.placement); }, buildRequests: function(validBidRequests, bidderRequest) { + let payload = {}; return validBidRequests.map(bidRequest => { const params = bidRequest.params; - const placementId = params.placement; const rnd = Math.floor(Math.random() * 99999999999); - const referrer = bidderRequest.refererInfo.referer; + const referrer = bidderRequest.refererInfo.page; const bidId = bidRequest.bidId; - const isDev = params.devMode || false; const pbcode = bidRequest.adUnitCode || false; // div id + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 const auctionId = bidRequest.auctionId || false; + const isDev = params.devMode || false; let endpoint = isDev ? ENDPOINT_URL_DEV : ENDPOINT_URL; + let placementId = params.placement; + + // dev config + if (isDev && params.dev) { + endpoint = params.dev.endpoint || endpoint; + placementId = params.dev.placement || placementId; + if (params.dev.pfilter !== undefined) { + params.pfilter = params.dev.pfilter; + } + } let mediaTypesInfo = getMediaTypesInfo(bidRequest); let type = isBannerRequest(bidRequest) ? BANNER : VIDEO; let sizes = mediaTypesInfo[type]; - let payload = { + payload = { _f: 'auto', alternative: 'prebid_js', inventory_item_id: placementId, @@ -47,10 +62,6 @@ export const spec = { pbver: '$prebid.version$' }; - if (mediaTypesInfo[VIDEO] !== undefined && params.vastFormat !== undefined) { - payload.vf = params.vastFormat; - } - if (params.pfilter !== undefined) { payload.pfilter = params.pfilter; } @@ -70,7 +81,7 @@ export const spec = { } if (params.bcat !== undefined) { - payload.bcat = params.bcat; + payload.bcat = deepAccess(bidderRequest.ortb2Imp, 'bcat') || params.bcat; } if (params.dvt !== undefined) { payload.dvt = params.dvt; @@ -79,11 +90,49 @@ export const spec = { payload.prebidDevMode = 1; } - if (bidRequest.userId && bidRequest.userId.netId) { - payload.did_netid = bidRequest.userId.netId; + // fill userId params + if (bidRequest.userId) { + if (bidRequest.userId.netId) { + payload.did_netid = bidRequest.userId.netId; + } + if (bidRequest.userId.id5id) { + payload.did_id5 = bidRequest.userId.id5id.uid || '0'; + if (bidRequest.userId.id5id.ext.linkType !== undefined) { + payload.did_id5_linktype = bidRequest.userId.id5id.ext.linkType; + } + } + let uId2 = deepAccess(bidRequest, 'userId.uid2.id'); + if (uId2) { + payload.did_uid2 = uId2; + } + let sharedId = deepAccess(bidRequest, 'userId.sharedid.id'); + if (sharedId) { + payload.did_sharedid = sharedId; + } + let pubcId = deepAccess(bidRequest, 'userId.pubcid'); + if (pubcId) { + payload.did_pubcid = pubcId; + } + let crumbsPubcid = deepAccess(bidRequest, 'crumbs.pubcid'); + if (crumbsPubcid) { + payload.did_cpubcid = crumbsPubcid; + } + } + + if (bidRequest.schain) { + payload.schain = bidRequest.schain; } - if (bidRequest.userId && bidRequest.userId.uid2) { - payload.did_uid2 = bidRequest.userId.uid2; + + if (payload.pfilter === undefined || !payload.pfilter.floorprice) { + let bidFloor = getBidFloor(bidRequest); + if (bidFloor > 0) { + if (payload.pfilter !== undefined) { + payload.pfilter.floorprice = bidFloor; + } else { + payload.pfilter = { 'floorprice': bidFloor }; + } + // payload.bidFloor = bidFloor; + } } if (auctionId) { @@ -94,15 +143,28 @@ export const spec = { } payload.media_types = convertMediaInfoForRequest(mediaTypesInfo); + if (mediaTypesInfo[VIDEO] !== undefined) { + payload.vctx = getVideoContext(bidRequest); + if (params.vastFormat !== undefined) { + payload.vf = params.vastFormat; + } + payload.vpl = {}; + let videoParams = deepAccess(bidRequest, 'mediaTypes.video'); + Object.keys(videoParams) + .filter(key => includes(VIDEO_ORTB_PARAMS, key)) + .forEach(key => payload.vpl[key] = videoParams[key]); + } return { method: 'GET', url: endpoint, data: objectToQueryString(payload), - } + }; }); }, interpretResponse: function(serverResponse, bidRequest) { + logMessage('DSPx: serverResponse', serverResponse); + logMessage('DSPx: bidRequest', bidRequest); const bidResponses = []; const response = serverResponse.body; const crid = response.crid || 0; @@ -121,18 +183,38 @@ export const spec = { currency: currency, netRevenue: netRevenue, type: response.type, - ttl: config.getConfig('_bidderTimeout'), + ttl: 60, meta: { advertiserDomains: response.adomain || [] } }; + + if (response.vastUrl) { + bidResponse.vastUrl = response.vastUrl; + bidResponse.mediaType = 'video'; + } if (response.vastXml) { bidResponse.vastXml = response.vastXml; bidResponse.mediaType = 'video'; - } else { + } + if (response.renderer) { + bidResponse.renderer = newRenderer(bidRequest, response); + } + + if (response.videoCacheKey) { + bidResponse.videoCacheKey = response.videoCacheKey; + } + + if (response.adTag) { bidResponse.ad = response.adTag; } + if (response.bid_appendix) { + Object.keys(response.bid_appendix).forEach(fieldName => { + bidResponse[fieldName] = response.bid_appendix[fieldName]; + }); + } + bidResponses.push(bidResponse); } return bidResponses; @@ -217,12 +299,22 @@ function isVideoRequest(bid) { * Get video sizes * * @param {BidRequest} bid - Bid request generated from ad slots - * @returns {object} True if it's a video bid + * @returns {object} */ function getVideoSizes(bid) { return parseSizes(deepAccess(bid, 'mediaTypes.video.playerSize') || bid.sizes); } +/** + * Get video context + * + * @param {BidRequest} bid - Bid request generated from ad slots + * @returns {object} + */ +function getVideoContext(bid) { + return deepAccess(bid, 'mediaTypes.video.context') || 'unknown'; +} + /** * Get banner sizes * @@ -296,4 +388,120 @@ function getMediaTypesInfo(bid) { return mediaTypesInfo; } +/** + * Get Bid Floor + * @param bid + * @returns {number|*} + */ +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'EUR', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0 + } +} + +/** + * Create a new renderer + * + * @param bidRequest + * @param response + * @returns {Renderer} + */ +function newRenderer(bidRequest, response) { + logMessage('DSPx: newRenderer', bidRequest, response); + const renderer = Renderer.install({ + id: response.renderer.id || response.bid_id, + url: (bidRequest.params && bidRequest.params.rendererUrl) || response.renderer.url, + config: response.renderer.options || deepAccess(bidRequest, 'renderer.options'), + loaded: false + }); + + try { + renderer.setRender(outstreamRender); + } catch (err) { + logWarn('Prebid Error calling setRender on renderer', err); + } + return renderer; +} + +/** + * Outstream Render Function + * + * @param bid + */ +function outstreamRender(bid) { + logMessage('DSPx: outstreamRender bid:', bid); + const embedCode = createOutstreamEmbedCode(bid); + try { + const inIframe = getBidIdParameter('iframe', bid.renderer.config); + if (inIframe && window.document.getElementById(inIframe).nodeName === 'IFRAME') { + const iframe = window.document.getElementById(inIframe); + let framedoc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document); + framedoc.body.appendChild(embedCode); + if (typeof window.dspxRender === 'function') { + window.dspxRender(bid); + } else { + logError('[dspx][renderer] Error: dspxRender function is not found'); + } + return; + } + + const slot = getBidIdParameter('slot', bid.renderer.config) || bid.adUnitCode; + if (slot && window.document.getElementById(slot)) { + window.document.getElementById(slot).appendChild(embedCode); + if (typeof window.dspxRender === 'function') { + window.dspxRender(bid); + } else { + logError('[dspx][renderer] Error: dspxRender function is not found'); + } + } else if (slot) { + logError('[dspx][renderer] Error: slot not found'); + } + } catch (err) { + logError('[dspx][renderer] Error:' + err.message) + } +} + +/** + * create Outstream Embed Code Node + * + * @param bid + * @returns {DocumentFragment} + */ +function createOutstreamEmbedCode(bid) { + const fragment = window.document.createDocumentFragment(); + let div = window.document.createElement('div'); + div.innerHTML = deepAccess(bid, 'renderer.config.code', ''); + fragment.appendChild(div); + + // run scripts + var scripts = div.getElementsByTagName('script'); + var scriptsClone = []; + for (var idx = 0; idx < scripts.length; idx++) { + scriptsClone.push(scripts[idx]); + } + for (var i = 0; i < scriptsClone.length; i++) { + var currentScript = scriptsClone[i]; + var s = document.createElement('script'); + for (var j = 0; j < currentScript.attributes.length; j++) { + var a = currentScript.attributes[j]; + s.setAttribute(a.name, a.value); + } + s.appendChild(document.createTextNode(currentScript.innerHTML)); + currentScript.parentNode.replaceChild(s, currentScript); + } + + return fragment; +} + registerBidder(spec); diff --git a/modules/dxkultureBidAdapter.js b/modules/dxkultureBidAdapter.js new file mode 100644 index 00000000000..2e6f6c77b85 --- /dev/null +++ b/modules/dxkultureBidAdapter.js @@ -0,0 +1,472 @@ +import { + deepSetValue, + logInfo, + deepAccess, + logError, + isFn, + isPlainObject, + isStr, + isNumber, + isArray, logMessage +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'dxkulture'; +const DEFAULT_BID_TTL = 300; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_NET_REVENUE = true; +const DEFAULT_NETWORK_ID = 1; +const OPENRTB_VIDEO_PARAMS = [ + 'mimes', + 'minduration', + 'maxduration', + 'placement', + 'protocols', + 'startdelay', + 'skip', + 'skipafter', + 'minbitrate', + 'maxbitrate', + 'delivery', + 'playbackmethod', + 'api', + 'linearity' +]; + +export const spec = { + code: BIDDER_CODE, + VERSION: '1.0.0', + supportedMediaTypes: [BANNER, VIDEO], + ENDPOINT: 'https://ads.kulture.media/pbjs', + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bidRequest The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return ( + _validateParams(bid) && + _validateBanner(bid) && + _validateVideo(bid) + ); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests A non-empty list of bid requests which should be sent to the Server. + * @param {BidderRequest} bidderRequest bidder request object. + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + if (!validBidRequests || !bidderRequest) { + return; + } + + // We need to refactor this to support mixed content when there are both + // banner and video bid requests + let openrtbRequest; + if (hasBannerMediaType(validBidRequests[0])) { + openrtbRequest = buildBannerRequestData(validBidRequests, bidderRequest); + } else if (hasVideoMediaType(validBidRequests[0])) { + openrtbRequest = buildVideoRequestData(validBidRequests[0], bidderRequest); + } + + // adding schain object + if (validBidRequests[0].schain) { + deepSetValue(openrtbRequest, 'source.ext.schain', validBidRequests[0].schain); + } + + // Attaching GDPR Consent Params + if (bidderRequest.gdprConsent) { + deepSetValue(openrtbRequest, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + deepSetValue(openrtbRequest, 'regs.ext.gdpr', (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)); + } + + // CCPA + if (bidderRequest.uspConsent) { + deepSetValue(openrtbRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + + // EIDS + const eids = deepAccess(validBidRequests[0], 'userIdAsEids'); + if (Array.isArray(eids) && eids.length > 0) { + deepSetValue(openrtbRequest, 'user.ext.eids', eids); + } + + let publisherId = validBidRequests[0].params.publisherId; + let placementId = validBidRequests[0].params.placementId; + const networkId = validBidRequests[0].params.networkId || DEFAULT_NETWORK_ID; + + if (validBidRequests[0].params.e2etest) { + logMessage('E2E test mode enabled'); + publisherId = 'e2etest' + } + let baseEndpoint = spec.ENDPOINT + '?pid=' + publisherId; + + if (placementId) { + baseEndpoint += '&placementId=' + placementId + } + if (networkId) { + baseEndpoint += '&nId=' + networkId + } + + const payloadString = JSON.stringify(openrtbRequest); + return { + method: 'POST', + url: baseEndpoint, + data: payloadString, + }; + }, + + interpretResponse: function (serverResponse) { + const bidResponses = []; + const response = (serverResponse || {}).body; + // response is always one seat (exchange) with (optional) bids for each impression + if (response && response.seatbid && response.seatbid.length === 1 && response.seatbid[0].bid && response.seatbid[0].bid.length) { + response.seatbid[0].bid.forEach(bid => { + if (bid.adm && bid.price) { + bidResponses.push(_createBidResponse(bid)); + } + }) + } else { + logInfo('dxkulture.interpretResponse :: no valid responses to interpret'); + } + return bidResponses; + }, + + getUserSyncs: function (syncOptions, serverResponses) { + logInfo('dxkulture.getUserSyncs', 'syncOptions', syncOptions, 'serverResponses', serverResponses); + let syncs = []; + + if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) { + return syncs; + } + + serverResponses.forEach(resp => { + const userSync = deepAccess(resp, 'body.ext.usersync'); + if (userSync) { + let syncDetails = []; + Object.keys(userSync).forEach(key => { + const value = userSync[key]; + if (value.syncs && value.syncs.length) { + syncDetails = syncDetails.concat(value.syncs); + } + }); + syncDetails.forEach(syncDetails => { + syncs.push({ + type: syncDetails.type === 'iframe' ? 'iframe' : 'image', + url: syncDetails.url + }); + }); + + if (!syncOptions.iframeEnabled) { + syncs = syncs.filter(s => s.type !== 'iframe') + } + if (!syncOptions.pixelEnabled) { + syncs = syncs.filter(s => s.type !== 'image') + } + } + }); + logInfo('dxkulture.getUserSyncs result=%o', syncs); + return syncs; + }, + +}; + +/* ======================================= + * Util Functions + *======================================= */ + +/** + * @param {BidRequest} bidRequest bid request + */ +function hasBannerMediaType(bidRequest) { + return !!deepAccess(bidRequest, 'mediaTypes.banner'); +} + +/** + * @param {BidRequest} bidRequest bid request + */ +function hasVideoMediaType(bidRequest) { + return !!deepAccess(bidRequest, 'mediaTypes.video'); +} + +function _validateParams(bidRequest) { + if (!bidRequest.params) { + return false; + } + + if (bidRequest.params.e2etest) { + return true; + } + + if (!bidRequest.params.publisherId) { + logError('Validation failed: publisherId not declared'); + return false; + } + + if (!bidRequest.params.placementId) { + logError('Validation failed: placementId not declared'); + return false; + } + + const mediaTypesExists = hasVideoMediaType(bidRequest) || hasBannerMediaType(bidRequest); + if (!mediaTypesExists) { + return false; + } + + return true; +} + +/** + * Validates banner bid request. If it is not banner media type returns true. + * @param {object} bid, bid to validate + * @return boolean, true if valid, otherwise false + */ +function _validateBanner(bidRequest) { + // If there's no banner no need to validate + if (!hasBannerMediaType(bidRequest)) { + return true; + } + const banner = deepAccess(bidRequest, 'mediaTypes.banner'); + if (!Array.isArray(banner.sizes)) { + return false; + } + + return true; +} + +/** + * Validates video bid request. If it is not video media type returns true. + * @param {object} bid, bid to validate + * @return boolean, true if valid, otherwise false + */ +function _validateVideo(bidRequest) { + // If there's no video no need to validate + if (!hasVideoMediaType(bidRequest)) { + return true; + } + + const videoPlacement = deepAccess(bidRequest, 'mediaTypes.video', {}); + const videoBidderParams = deepAccess(bidRequest, 'params.video', {}); + const params = deepAccess(bidRequest, 'params', {}); + + if (params && params.e2etest) { + return true; + } + + const videoParams = { + ...videoPlacement, + ...videoBidderParams // Bidder Specific overrides + }; + + if (!Array.isArray(videoParams.mimes) || videoParams.mimes.length === 0) { + logError('Validation failed: mimes are invalid'); + return false; + } + + if (!Array.isArray(videoParams.protocols) || videoParams.protocols.length === 0) { + logError('Validation failed: protocols are invalid'); + return false; + } + + if (!videoParams.context) { + logError('Validation failed: context id not declared'); + return false; + } + + if (videoParams.context !== 'instream') { + logError('Validation failed: only context instream is supported '); + return false; + } + + if (typeof videoParams.playerSize === 'undefined' || !Array.isArray(videoParams.playerSize) || !Array.isArray(videoParams.playerSize[0])) { + logError('Validation failed: player size not declared or is not in format [[w,h]]'); + return false; + } + + return true; +} + +/** + * Prepares video request data. + * + * @param bidRequest + * @param bidderRequest + * @returns openrtbRequest + */ +function buildVideoRequestData(bidRequest, bidderRequest) { + const {params} = bidRequest; + + const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video', {}); + const videoBidderParams = deepAccess(bidRequest, 'params.video', {}); + + const videoParams = { + ...videoAdUnit, + ...videoBidderParams // Bidder Specific overrides + }; + + if (bidRequest.params && bidRequest.params.e2etest) { + videoParams.playerSize = [[640, 480]] + videoParams.conext = 'instream' + } + + const video = { + w: parseInt(videoParams.playerSize[0][0], 10), + h: parseInt(videoParams.playerSize[0][1], 10), + } + + // Obtain all ORTB params related video from Ad Unit + OPENRTB_VIDEO_PARAMS.forEach((param) => { + if (videoParams.hasOwnProperty(param)) { + video[param] = videoParams[param]; + } + }); + + // Placement Inference Rules: + // - If no placement is defined then default to 1 (In Stream) + video.placement = video.placement || 2; + + // - If product is instream (for instream context) then override placement to 1 + if (params.context === 'instream') { + video.startdelay = video.startdelay || 0; + video.placement = 1; + } + + // bid floor + const bidFloorRequest = { + currency: bidRequest.params.cur || 'USD', + mediaType: 'video', + size: '*' + }; + let floorData = bidRequest.params + if (isFn(bidRequest.getFloor)) { + floorData = bidRequest.getFloor(bidFloorRequest); + } else { + if (params.bidfloor) { + floorData = {floor: params.bidfloor, currency: params.currency || 'USD'}; + } + } + + const openrtbRequest = { + id: bidRequest.bidId, + imp: [ + { + id: '1', + video: video, + secure: isSecure() ? 1 : 0, + bidfloor: floorData.floor, + bidfloorcur: floorData.currency + } + ], + site: { + domain: bidderRequest.refererInfo.domain, + page: bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.ref, + }, + ext: { + hb: 1, + prebidver: '$prebid.version$', + adapterver: spec.VERSION, + }, + }; + + // content + if (videoParams.content && isPlainObject(videoParams.content)) { + openrtbRequest.site.content = {}; + const contentStringKeys = ['id', 'title', 'series', 'season', 'genre', 'contentrating', 'language', 'url']; + const contentNumberkeys = ['episode', 'prodq', 'context', 'livestream', 'len']; + const contentArrayKeys = ['cat']; + const contentObjectKeys = ['ext']; + for (const contentKey in videoBidderParams.content) { + if ( + (contentStringKeys.indexOf(contentKey) > -1 && isStr(videoParams.content[contentKey])) || + (contentNumberkeys.indexOf(contentKey) > -1 && isNumber(videoParams.content[contentKey])) || + (contentObjectKeys.indexOf(contentKey) > -1 && isPlainObject(videoParams.content[contentKey])) || + (contentArrayKeys.indexOf(contentKey) > -1 && isArray(videoParams.content[contentKey]) && + videoParams.content[contentKey].every(catStr => isStr(catStr)))) { + openrtbRequest.site.content[contentKey] = videoParams.content[contentKey]; + } else { + logMessage('DXKulture bid adapter validation error: ', contentKey, ' is either not supported is OpenRTB V2.5 or value is undefined'); + } + } + } + + return openrtbRequest; +} + +/** + * Prepares video request data. + * + * @param bidRequest + * @param bidderRequest + * @returns openrtbRequest + */ +function buildBannerRequestData(bidRequests, bidderRequest) { + const impr = bidRequests.map(bidRequest => ({ + id: bidRequest.bidId, + banner: { + format: bidRequest.mediaTypes.banner.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1] + })) + }, + ext: { + exchange: { + placementId: bidRequest.params.placementId + } + } + })); + + const openrtbRequest = { + id: bidderRequest.auctionId, + imp: impr, + site: { + domain: bidderRequest.refererInfo?.domain, + page: bidderRequest.refererInfo?.page, + ref: bidderRequest.refererInfo?.ref, + }, + ext: {} + }; + return openrtbRequest; +} + +function _createBidResponse(bid) { + const isADomainPresent = + bid.adomain && bid.adomain.length; + const bidResponse = { + requestId: bid.impid, + bidderCode: spec.code, + cpm: bid.price, + width: bid.w, + height: bid.h, + ad: bid.adm, + ttl: typeof bid.exp === 'number' ? bid.exp : DEFAULT_BID_TTL, + creativeId: bid.crid, + netRevenue: DEFAULT_NET_REVENUE, + currency: DEFAULT_CURRENCY, + mediaType: deepAccess(bid, 'ext.prebid.type', BANNER) + } + + if (isADomainPresent) { + bidResponse.meta = { + advertiserDomains: bid.adomain + }; + } + + if (bidResponse.mediaType === VIDEO) { + bidResponse.vastXml = bid.adm; + } + + return bidResponse; +} + +function isSecure() { + return document.location.protocol === 'https:'; +} + +registerBidder(spec); diff --git a/modules/dxkultureBidAdapter.md b/modules/dxkultureBidAdapter.md new file mode 100644 index 00000000000..e934aee3301 --- /dev/null +++ b/modules/dxkultureBidAdapter.md @@ -0,0 +1,142 @@ +# Overview + +``` +Module Name: DXKulture Bid Adapter +Module Type: Bidder Adapter +Maintainer: devops@kulture.media +``` + +# Description + +Module that connects to DXKulture's demand sources. +DXKulture bid adapter supports Banner and Video. + + +# Test Parameters + +## Banner + +``` +var adUnits = [ + { + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'dxkulture', + params: { + placementId: 'test', + publisherId: 'test', + networkId: '123' + } + }] + } +]; +``` + +## Video + +We support the following OpenRTB params that can be specified in `mediaTypes.video` or in `bids[].params.video` +- 'mimes', +- 'minduration', +- 'maxduration', +- 'placement', +- 'protocols', +- 'startdelay', +- 'skip', +- 'skipafter', +- 'minbitrate', +- 'maxbitrate', +- 'delivery', +- 'playbackmethod', +- 'api', +- 'linearity' + + +## Instream Video adUnit using mediaTypes.video +*Note:* By default, the adapter will read the mandatory parameters from mediaTypes.video. +*Note:* The Video SSP ad server will respond with an VAST XML to load into your defined player. +``` + var adUnits = [ + { + code: 'video1', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4', 'application/javascript'], + protocols: [2,5], + api: [2], + position: 1, + delivery: [2], + minduration: 10, + maxduration: 30, + placement: 1, + playbackmethod: [1,5], + } + }, + bids: [ + { + bidder: 'dxkulture', + params: { + bidfloor: 0.5, + publisherId: '12345', + placementId: '6789', + networkId" '123' + } + } + ] + } + ] +``` + +# End To End testing mode +By passing bid.params.e2etest = true you will be able to receive a test creative + +## Banner +``` +var adUnits = [ + { + code: 'banner-ad-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'dxkulture', + params: { + e2etest: true + } + }] + } +]; +``` + +## Video +``` +var adUnits = [ + { + code: 'video1', + mediaTypes: { + video: { + context: "instream", + playerSize: [[640, 480]], + mimes: ['video/mp4'], + protocols: [2,5], + } + }, + bids: [ + { + bidder: 'dxkulture', + params: { + e2etest: true + } + } + ] + } +] +``` diff --git a/modules/e_volutionBidAdapter.js b/modules/e_volutionBidAdapter.js index 884c4f0c067..5f1b46ff9eb 100644 --- a/modules/e_volutionBidAdapter.js +++ b/modules/e_volutionBidAdapter.js @@ -1,6 +1,7 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { isFn, deepAccess, logMessage } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'e_volution'; const AD_URL = 'https://service.e-volution.ai/?c=o&m=multi'; @@ -41,6 +42,19 @@ function getBidFloor(bid) { } } +function getUserId(eids, id, source, uidExt) { + if (id) { + var uid = { id }; + if (uidExt) { + uid.ext = uidExt; + } + eids.push({ + source, + uids: [ uid ] + }); + } +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO, NATIVE], @@ -51,10 +65,14 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page); winTop = window.top; } catch (e) { location = winTop.location; @@ -75,7 +93,7 @@ export const spec = { request.ccpa = bidderRequest.uspConsent; } if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent + request.gdpr = bidderRequest.gdprConsent; } } const len = validBidRequests.length; @@ -86,7 +104,12 @@ export const spec = { const placement = { placementId: bid.params.placementId, bidId: bid.bidId, - bidfloor: getBidFloor(bid) + bidfloor: getBidFloor(bid), + eids: [] + }; + + if (bid.userId) { + getUserId(placement.eids, bid.userId.id5id, 'id5-sync.com'); } if (bid.mediaTypes && bid.mediaTypes[BANNER] && bid.mediaTypes[BANNER].sizes) { diff --git a/modules/ebdrBidAdapter.js b/modules/ebdrBidAdapter.js index 62a3b171b74..e830f8a94f7 100644 --- a/modules/ebdrBidAdapter.js +++ b/modules/ebdrBidAdapter.js @@ -1,4 +1,4 @@ -import { logInfo, getBidIdParameter } from '../src/utils.js'; +import {getBidIdParameter, logInfo} from '../src/utils.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'ebdr'; @@ -31,13 +31,14 @@ export const spec = { h: whArr[1] }, bidfloor: bidFloor - }) + }); ebdrReq[bid.bidId] = {mediaTypes: _mediaTypes, w: whArr[0], h: whArr[1] }; - ebdrParams['latitude'] = getBidIdParameter('latitude', bid.params); - ebdrParams['longitude'] = getBidIdParameter('longitude', bid.params); + // TODO: fix lat and long to only come from request + ebdrParams['latitude'] = '0'; + ebdrParams['longitude'] = '0'; ebdrParams['ifa'] = (getBidIdParameter('IDFA', bid.params).length > getBidIdParameter('ADID', bid.params).length) ? getBidIdParameter('IDFA', bid.params) : getBidIdParameter('ADID', bid.params); }); let ebdrBidReq = { diff --git a/modules/edgequeryxBidAdapter.md b/modules/edgequeryxBidAdapter.md deleted file mode 100644 index 265120dfaba..00000000000 --- a/modules/edgequeryxBidAdapter.md +++ /dev/null @@ -1,39 +0,0 @@ -# Overview - -``` -Module Name: Edge Query X Bidder Adapter -Module Type: Bidder Adapter -Maintainer: contact@edgequery.com -``` - -# Description - -Connect to Edge Query X for bids. - -The Edge Query X adapter requires setup and approval from the Edge Query team. -Please reach out to your Technical account manager for more information. - -# Test Parameters - -## Web -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[1, 1]] - } - }, - bids: [ - { - bidder: "edgequeryx", - params: { - accountId: "test", - widgetId: "test" - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/emoteevBidAdapter.md b/modules/emoteevBidAdapter.md deleted file mode 100644 index 226a8374369..00000000000 --- a/modules/emoteevBidAdapter.md +++ /dev/null @@ -1,36 +0,0 @@ -# Overview - -``` -Module Name: Emoteev Bidder Adapter -Module Type: Bidder Adapter -Maintainer: engineering@emoteev.io -``` - -# Description - -Module that connects to Emoteev's demand sources - -# Test Parameters - -``` javascript - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[720, 90]], - } - }, - bids: [ - { - bidder: 'emoteev', - params: { - adSpaceId: 5084, - context: 'footer', - externalId: 42, - } - } - ] - } - ]; -``` diff --git a/modules/emtvBidAdapter.js b/modules/emtvBidAdapter.js new file mode 100644 index 00000000000..7a2fdae8adf --- /dev/null +++ b/modules/emtvBidAdapter.js @@ -0,0 +1,211 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'emtv'; +const AD_URL = 'https://us-east-ep.engagemedia.tv/pbjs'; +const SYNC_URL = 'https://cs.engagemedia.tv'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: config.getConfig('bidderTimeout') + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/emtvBidAdapter.md b/modules/emtvBidAdapter.md new file mode 100644 index 00000000000..ed58ca43294 --- /dev/null +++ b/modules/emtvBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: EMTV Bidder Adapter +Module Type: EMTV Bidder Adapter +Maintainer: support@engagemedia.tv +``` + +# Description + +Connects to EMTV exchange for bids. +EMTV bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'emtv', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'emtv', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'emtv', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/engageyaBidAdapter.js b/modules/engageyaBidAdapter.js index adf26c38dd5..a66e825e5df 100644 --- a/modules/engageyaBidAdapter.js +++ b/modules/engageyaBidAdapter.js @@ -1,9 +1,8 @@ import { BANNER, NATIVE } from '../src/mediaTypes.js'; import { createTrackPixelHtml } from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; -const { - registerBidder -} = require('../src/adapters/bidderFactory.js'); const BIDDER_CODE = 'engageya'; const ENDPOINT_URL = 'https://recs.engageya.com/rec-api/getrecs.json'; const ENDPOINT_METHOD = 'GET'; @@ -16,9 +15,10 @@ function getPageUrl(bidRequest, bidderRequest) { if (bidRequest.params.pageUrl && bidRequest.params.pageUrl != '[PAGE_URL]') { return bidRequest.params.pageUrl; } - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - return bidderRequest.refererInfo.referer; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.page) { + return bidderRequest.refererInfo.page; } + // TODO: does this fallback make sense? const pageUrl = (isInIframe() && document.referrer) ? document.referrer : window.location.href; @@ -128,6 +128,9 @@ export const spec = { }, buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + if (!validBidRequests) { return []; } diff --git a/modules/enrichmentFpdModule.js b/modules/enrichmentFpdModule.js index 9268c81c033..59d5d326109 100644 --- a/modules/enrichmentFpdModule.js +++ b/modules/enrichmentFpdModule.js @@ -1,167 +1,2 @@ - -/** - * This module sets default values and validates ortb2 first part data - * @module modules/firstPartyData - */ -import { timestamp, mergeDeep } from '../src/utils.js'; -import { submodule } from '../src/hook.js'; -import { getRefererInfo } from '../src/refererDetection.js'; -import { getCoreStorageManager } from '../src/storageManager.js'; - -let ortb2 = {}; -let win = (window === window.top) ? window : window.top; -export const coreStorage = getCoreStorageManager('enrichmentFpd'); - -/** - * Find the root domain - * @param {string|undefined} fullDomain - * @return {string} -*/ -export function findRootDomain(fullDomain = window.location.hostname) { - if (!coreStorage.cookiesAreEnabled()) { - return fullDomain; - } - - const domainParts = fullDomain.split('.'); - if (domainParts.length == 2) { - return fullDomain; - } - let rootDomain; - let continueSearching; - let startIndex = -2; - const TEST_COOKIE_NAME = `_rdc${Date.now()}`; - const TEST_COOKIE_VALUE = 'writeable'; - do { - rootDomain = domainParts.slice(startIndex).join('.'); - let expirationDate = new Date(timestamp() + 10 * 1000).toUTCString(); - - // Write a test cookie - coreStorage.setCookie( - TEST_COOKIE_NAME, - TEST_COOKIE_VALUE, - expirationDate, - 'Lax', - rootDomain, - undefined - ); - - // See if the write was successful - const value = coreStorage.getCookie(TEST_COOKIE_NAME, undefined); - if (value === TEST_COOKIE_VALUE) { - continueSearching = false; - // Delete our test cookie - coreStorage.setCookie( - TEST_COOKIE_NAME, - '', - 'Thu, 01 Jan 1970 00:00:01 GMT', - undefined, - rootDomain, - undefined - ); - } else { - startIndex += -1; - continueSearching = Math.abs(startIndex) <= domainParts.length; - } - } while (continueSearching); - return rootDomain; -} - -/** - * Checks for referer and if exists merges into ortb2 global data - */ -function setReferer() { - if (getRefererInfo().referer) mergeDeep(ortb2, { site: { ref: getRefererInfo().referer } }); -} - -/** - * Checks for canonical url and if exists merges into ortb2 global data - */ -function setPage() { - if (getRefererInfo().canonicalUrl) mergeDeep(ortb2, { site: { page: getRefererInfo().canonicalUrl } }); -} - -/** - * Checks for canonical url and if exists retrieves domain and merges into ortb2 global data - */ -function setDomain() { - let parseDomain = function(url) { - if (!url || typeof url !== 'string' || url.length === 0) return; - - var match = url.match(/^(?:https?:\/\/)?(?:www\.)?(.*?(?=(\?|\#|\/|$)))/i); - - return match && match[1]; - }; - - let domain = parseDomain(getRefererInfo().canonicalUrl) - - if (domain) { - mergeDeep(ortb2, { site: { domain: domain } }); - mergeDeep(ortb2, { site: { publisher: { domain: findRootDomain(domain) } } }); - }; -} - -/** - * Checks for screen/device width and height and sets dimensions - */ -function setDimensions() { - let width; - let height; - - try { - width = win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth; - height = win.innerHeight || win.document.documentElement.clientHeight || win.document.body.clientHeight; - } catch (e) { - width = window.innerWidth || window.document.documentElement.clientWidth || window.document.body.clientWidth; - height = window.innerHeight || window.document.documentElement.clientHeight || window.document.body.clientHeight; - } - - mergeDeep(ortb2, { device: { w: width, h: height } }); -} - -/** - * Scans page for meta keywords, and if exists, merges into site.keywords - */ -function setKeywords() { - let keywords; - - try { - keywords = win.document.querySelector("meta[name='keywords']"); - } catch (e) { - keywords = window.document.querySelector("meta[name='keywords']"); - } - - if (keywords && keywords.content) mergeDeep(ortb2, { site: { keywords: keywords.content.replace(/\s/g, '') } }); -} - -/** - * Resets modules global ortb2 data - */ -const resetOrtb2 = () => { ortb2 = {} }; - -function runEnrichments() { - setReferer(); - setPage(); - setDomain(); - setDimensions(); - setKeywords(); - - return ortb2; -} - -/** - * Sets default values to ortb2 if exists and adds currency and ortb2 setConfig callbacks on init - */ -export function initSubmodule(fpdConf, data) { - resetOrtb2(); - - return (!fpdConf.skipEnrichments) ? mergeDeep(runEnrichments(), data) : data; -} - -/** @type {firstPartyDataSubmodule} */ -export const enrichmentsSubmodule = { - name: 'enrichments', - queue: 2, - init: initSubmodule -} - -submodule('firstPartyData', enrichmentsSubmodule) +// Logic from this module was moved into core since approx. 7.27 +// TODO: remove this in v8 diff --git a/modules/envivoBidAdapter.md b/modules/envivoBidAdapter.md deleted file mode 100644 index 3ecc8a251f3..00000000000 --- a/modules/envivoBidAdapter.md +++ /dev/null @@ -1,50 +0,0 @@ -# Overview - -``` -Module Name: envivo Bid Adapter -Module Type: Bidder Adapter -Maintainer : adtech@nvivo.tv -``` - -# Description - -Connects to Envivo Ad Server for bids. - -envivo bid adapter supports Banner and Video. - -# Test Parameters -``` - var adUnits = [ - //bannner object - { - code: 'banner-ad-slot', - mediaTypes: { - banner: { - sizes: [[300, 250]], - } - }, - bids: [{ - bidder: 'envivo', - params: { - publisherId: 14 - } - }] - - }, - //video object - { - code: 'video-ad-slot', - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480], - }, - }, - bids: [{ - bidder: "envivo", - params: { - publisherId: 14 - } - }] - }]; -``` diff --git a/modules/eplanningAnalyticsAdapter.js b/modules/eplanningAnalyticsAdapter.js index fb77014400c..9eb701b8ecc 100644 --- a/modules/eplanningAnalyticsAdapter.js +++ b/modules/eplanningAnalyticsAdapter.js @@ -1,9 +1,8 @@ import { logError } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; - -const CONSTANTS = require('../src/constants.json'); +import CONSTANTS from '../src/constants.json'; const analyticsType = 'endpoint'; const EPL_HOST = 'https://ads.us.e-planning.net/hba/1/'; diff --git a/modules/eplanningBidAdapter.js b/modules/eplanningBidAdapter.js index 780531964ad..d57804c04e6 100644 --- a/modules/eplanningBidAdapter.js +++ b/modules/eplanningBidAdapter.js @@ -1,7 +1,9 @@ -import { isEmpty, getWindowSelf, parseSizesInput } from '../src/utils.js'; -import { getGlobal } from '../src/prebidGlobal.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getWindowSelf, isEmpty, parseSizesInput, isGptPubadsDefined} from '../src/utils.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {isSlotMatchingAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const BIDDER_CODE = 'eplanning'; export const storage = getStorageManager({bidderCode: BIDDER_CODE}); @@ -19,9 +21,15 @@ const STORAGE_VIEW_PREFIX = 'pbvi_'; const mobileUserAgent = isMobileUserAgent(); const PRIORITY_ORDER_FOR_MOBILE_SIZES_ASC = ['1x1', '300x50', '320x50', '300x250']; const PRIORITY_ORDER_FOR_DESKTOP_SIZES_ASC = ['1x1', '970x90', '970x250', '160x600', '300x600', '728x90', '300x250']; +const VAST_INSTREAM = 1; +const VAST_OUTSTREAM = 2; +const VAST_VERSION_DEFAULT = 3; +const DEFAULT_SIZE_VAST = '640x480'; +const MAX_LEN_URL = 255; export const spec = { code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function(bid) { return Boolean(bid.params.ci) || Boolean(bid.params.t); @@ -36,18 +44,16 @@ export const spec = { const urlConfig = getUrlConfig(bidRequests); const pcrs = getCharset(); const spaces = getSpaces(bidRequests, urlConfig.ml); - const pageUrl = bidderRequest.refererInfo.referer; - const getDomain = (url) => { - let anchor = document.createElement('a'); - anchor.href = url; - return anchor.hostname; - } + // TODO: do the fallbacks make sense here? + const pageUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; + const domain = bidderRequest.refererInfo.domain || window.location.host; if (urlConfig.t) { url = 'https://' + urlConfig.isv + '/layers/t_pbjs_2.json'; params = {}; } else { - url = 'https://' + (urlConfig.sv || DEFAULT_SV) + '/pbjs/1/' + urlConfig.ci + '/' + dfpClientId + '/' + getDomain(pageUrl) + '/' + sec; - const referrerUrl = bidderRequest.refererInfo.referer.reachedTop ? window.top.document.referrer : bidderRequest.refererInfo.referer; + url = 'https://' + (urlConfig.sv || DEFAULT_SV) + '/pbjs/1/' + urlConfig.ci + '/' + dfpClientId + '/' + domain + '/' + sec; + // TODO: does the fallback make sense here? + const referrerUrl = bidderRequest.refererInfo.ref || bidderRequest.refererInfo.topmostLocation; if (storage.hasLocalStorage()) { registerViewabilityAllBids(bidRequests); @@ -56,7 +62,7 @@ export const spec = { params = { rnd: rnd, e: spaces.str, - ur: pageUrl || FILE, + ur: cutUrl(pageUrl || FILE), pbv: '$prebid.version$', ncb: '1', vs: spaces.vs @@ -66,7 +72,7 @@ export const spec = { } if (referrerUrl) { - params.fr = referrerUrl; + params.fr = cutUrl(referrerUrl); } if (bidderRequest && bidderRequest.gdprConsent) { @@ -88,6 +94,10 @@ export const spec = { params['e_' + id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]); } } + if (spaces.impType) { + params.vctx = spaces.impType & VAST_INSTREAM ? VAST_INSTREAM : VAST_OUTSTREAM; + params.vv = VAST_VERSION_DEFAULT; + } } return { @@ -110,7 +120,6 @@ export const spec = { cpm: ad.pr, width: ad.w, height: ad.h, - ad: ad.adm, ttl: TTL, creativeId: ad.crid, netRevenue: NET_REVENUE, @@ -121,6 +130,13 @@ export const spec = { advertiserDomains: ad.adom }; } + if (request && request.data && request.data.vv) { + bidResponse.vastXml = ad.adm; + bidResponse.mediaType = VIDEO; + } else { + bidResponse.ad = ad.adm; + } + bidResponses.push(bidResponse); }); } @@ -152,7 +168,7 @@ export const spec = { return syncs; }, -} +}; function getUserAgent() { return window.navigator.userAgent; @@ -238,17 +254,57 @@ function getSpacesStruct(bids) { return e; } +function getFirstSizeVast(sizes) { + if (sizes == undefined || !Array.isArray(sizes)) { + return undefined; + } + + let size = Array.isArray(sizes[0]) ? sizes[0] : sizes; + + return (Array.isArray(size) && size.length == 2) ? size : undefined; +} + function cleanName(name) { return name.replace(/_|\.|-|\//g, '').replace(/\)\(|\(|\)|:/g, '_').replace(/^_+|_+$/g, ''); } +function getFloorStr(bid) { + if (typeof bid.getFloor === 'function') { + let bidFloor = bid.getFloor({ + currency: DOLLAR_CODE, + mediaType: '*', + size: '*' + }); + + if (bidFloor.floor) { + return '|' + encodeURIComponent(bidFloor.floor); + } + } + return ''; +} + function getSpaces(bidRequests, ml) { + let impType = bidRequests.reduce((previousBits, bid) => (bid.mediaTypes && bid.mediaTypes[VIDEO]) ? (bid.mediaTypes[VIDEO].context == 'outstream' ? (previousBits | 2) : (previousBits | 1)) : previousBits, 0); + // Only one type of auction is supported at a time + if (impType) { + bidRequests = bidRequests.filter((bid) => bid.mediaTypes && bid.mediaTypes[VIDEO] && (impType & VAST_INSTREAM ? (!bid.mediaTypes[VIDEO].context || bid.mediaTypes[VIDEO].context == 'instream') : (bid.mediaTypes[VIDEO].context == 'outstream'))); + } + let spacesStruct = getSpacesStruct(bidRequests); - let es = {str: '', vs: '', map: {}}; + let es = {str: '', vs: '', map: {}, impType: impType}; es.str = Object.keys(spacesStruct).map(size => spacesStruct[size].map((bid, i) => { es.vs += getVs(bid); let name; + + if (impType) { + let firstSize = getFirstSizeVast(bid.mediaTypes[VIDEO].playerSize); + let sizeVast = firstSize ? firstSize.join('x') : DEFAULT_SIZE_VAST; + name = 'video_' + sizeVast + '_' + i; + es.map[name] = bid.bidId; + return name + ':' + sizeVast + ';1' + getFloorStr(bid); + } + if (ml) { name = cleanName(bid.adUnitCode); } else { @@ -256,7 +312,7 @@ function getSpaces(bidRequests, ml) { } es.map[name] = bid.bidId; - return name + ':' + getSize(bid); + return name + ':' + getSize(bid) + getFloorStr(bid); }).join('+')).join('+'); return es; } @@ -293,13 +349,25 @@ function getCharset() { function waitForElementsPresent(elements) { const observer = new MutationObserver(function (mutationList, observer) { + let index; + let adView; if (mutationList && Array.isArray(mutationList)) { mutationList.forEach(mr => { if (mr && mr.addedNodes && Array.isArray(mr.addedNodes)) { mr.addedNodes.forEach(ad => { - let index = elements.indexOf(ad.id); + index = elements.indexOf(ad.id); + adView = ad; + if (index < 0) { + elements.forEach(code => { + let div = _getAdSlotHTMLElement(code); + if (div && div.contains(ad) && div.getBoundingClientRect().width > 0) { + index = elements.indexOf(div.id); + adView = div; + } + }); + } if (index >= 0) { - registerViewability(ad); + registerViewability(adView, elements[index]); elements.splice(index, 1); if (!elements.length) { observer.disconnect(); @@ -320,19 +388,41 @@ function waitForElementsPresent(elements) { }); } -function registerViewability(div) { +function registerViewability(div, name) { visibilityHandler({ - name: div.id, + name: name, div: div }); } +function _mapAdUnitPathToElementId(adUnitCode) { + if (isGptPubadsDefined()) { + // eslint-disable-next-line no-undef + const adSlots = googletag.pubads().getSlots(); + const isMatchingAdSlot = isSlotMatchingAdUnitCode(adUnitCode); + + for (let i = 0; i < adSlots.length; i++) { + if (isMatchingAdSlot(adSlots[i])) { + const id = adSlots[i].getSlotElementId(); + return id; + } + } + } + + return null; +} + +function _getAdSlotHTMLElement(adUnitCode) { + return document.getElementById(adUnitCode) || + document.getElementById(_mapAdUnitPathToElementId(adUnitCode)); +} + function registerViewabilityAllBids(bids) { let elementsNotPresent = []; bids.forEach(bid => { - let div = document.getElementById(bid.adUnitCode); + let div = _getAdSlotHTMLElement(bid.adUnitCode); if (div) { - registerViewability(div); + registerViewability(div, bid.adUnitCode); } else { elementsNotPresent.push(bid.adUnitCode); } @@ -347,114 +437,65 @@ function getViewabilityTracker() { let VIEWABILITY_TIME = 1000; let VIEWABILITY_MIN_RATIO = 0.5; let publicApi; - let context; - - function segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2) { - return p1 > visibleRangeEnd || p2 < 0; - } - - function segmentBeginsBeforeTheVisibleRange(p1) { - return p1 < 0; - } - - function segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) { - return p2 < visibleRangeEnd; - } - - function axialVisibilityRatio(visibleRangeEnd, p1, p2) { - let visibilityRatio = 0; - if (!segmentIsOutsideTheVisibleRange(visibleRangeEnd, p1, p2)) { - if (segmentBeginsBeforeTheVisibleRange(p1)) { - visibilityRatio = p2 / (p2 - p1); + let observer; + let visibilityAds = {}; + + function intersectionCallback(entries) { + entries.forEach(function(entry) { + var adBox = entry.target; + if (entry.isIntersecting) { + if (entry.intersectionRatio >= VIEWABILITY_MIN_RATIO && entry.boundingClientRect && entry.boundingClientRect.height > 0 && entry.boundingClientRect.width > 0) { + visibilityAds[adBox.id] = true; + } } else { - visibilityRatio = segmentEndsAfterTheVisibleRange(visibleRangeEnd, p2) ? 1 : (visibleRangeEnd - p1) / (p2 - p1); + visibilityAds[adBox.id] = false; } - } - return visibilityRatio; - } - - function isNotHiddenByNonFriendlyIframe() { - try { return (window === window.top) || window.frameElement; } catch (e) {} - } - - function defineContext(e) { - try { - context = e && window.document.body.contains(e) ? window : (window.top.document.body.contains(e) ? top : undefined); - } catch (err) {} - return context; - } - - function getContext(e) { - return context; - } - - function verticalVisibilityRatio(position) { - return axialVisibilityRatio(getContext().innerHeight, position.top, position.bottom); - } - - function horizontalVisibilityRatio(position) { - return axialVisibilityRatio(getContext().innerWidth, position.left, position.right); - } - - function itIsNotHiddenByBannerAreaPosition(e) { - let position = e.getBoundingClientRect(); - return (verticalVisibilityRatio(position) * horizontalVisibilityRatio(position)) > VIEWABILITY_MIN_RATIO; - } - - function itIsNotHiddenByDisplayStyleCascade(e) { - return e.offsetHeight > 0 && e.offsetWidth > 0; - } - - function itIsNotHiddenByOpacityStyleCascade(e) { - let s = e.style; - let p = e.parentNode; - return !(s && parseFloat(s.opacity) === 0) && (!p || itIsNotHiddenByOpacityStyleCascade(p)); - } - - function itIsNotHiddenByVisibilityStyleCascade(e) { - return getContext().getComputedStyle(e).visibility !== 'hidden'; - } - - function itIsNotHiddenByTabFocus() { - try { return getContext().top.document.hasFocus(); } catch (e) {} - } - - function isDefined(e) { - return (e !== null) && (typeof e !== 'undefined'); + }); } - function itIsNotHiddenByOrphanBranch() { - return isDefined(getContext()); + function observedElementIsVisible(element) { + return visibilityAds[element.id] && document.visibilityState && document.visibilityState === 'visible'; } - function isContextInAnIframe() { - return isDefined(getContext().frameElement); + function defineObserver() { + if (!observer) { + var observerConfig = { + root: null, + rootMargin: '0px', + threshold: [VIEWABILITY_MIN_RATIO] + }; + observer = new IntersectionObserver(intersectionCallback.bind(this), observerConfig); + } } - function processIntervalVisibilityStatus(elapsedVisibleIntervals, element, callback) { - let visibleIntervals = isVisible(element) ? (elapsedVisibleIntervals + 1) : 0; + let visibleIntervals = observedElementIsVisible(element) ? (elapsedVisibleIntervals + 1) : 0; if (visibleIntervals === TIME_PARTITIONS) { + stopObserveViewability(element) callback(); } else { setTimeout(processIntervalVisibilityStatus.bind(this, visibleIntervals, element, callback), VIEWABILITY_TIME / TIME_PARTITIONS); } } - function isVisible(element) { - defineContext(element); - return isNotHiddenByNonFriendlyIframe() && - itIsNotHiddenByOrphanBranch() && - itIsNotHiddenByTabFocus() && - itIsNotHiddenByDisplayStyleCascade(element) && - itIsNotHiddenByVisibilityStyleCascade(element) && - itIsNotHiddenByOpacityStyleCascade(element) && - itIsNotHiddenByBannerAreaPosition(element) && - (!isContextInAnIframe() || isVisible(getContext().frameElement)); + function stopObserveViewability(element) { + delete visibilityAds[element.id]; + observer.unobserve(element); + } + + function observeAds(element) { + observer.observe(element); + } + + function initAndVerifyVisibility(element, callback) { + if (element) { + defineObserver(); + observeAds(element); + processIntervalVisibilityStatus(0, element, callback); + } } publicApi = { - isVisible: isVisible, - onView: processIntervalVisibilityStatus.bind(this, 0) + onView: initAndVerifyVisibility.bind(this) }; return publicApi; @@ -467,6 +508,17 @@ function visibilityHandler(obj) { } } +function cutUrl (url) { + if (url.length > MAX_LEN_URL) { + url = url.split('?')[0]; + if (url.length > MAX_LEN_URL) { + url = url.slice(0, MAX_LEN_URL); + } + } + + return url; +} + function registerAuction(storageID) { let value; try { @@ -479,4 +531,5 @@ function registerAuction(storageID) { return true; } + registerBidder(spec); diff --git a/modules/eskimiBidAdapter.js b/modules/eskimiBidAdapter.js new file mode 100644 index 00000000000..81b8c5d8058 --- /dev/null +++ b/modules/eskimiBidAdapter.js @@ -0,0 +1,203 @@ +import {ortbConverter} from '../libraries/ortbConverter/converter.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import * as utils from '../src/utils.js'; +import {getBidIdParameter} from '../src/utils.js'; + +const BIDDER_CODE = 'eskimi'; +// const ENDPOINT = 'https://hb.eskimi.com/bids' +const ENDPOINT = 'https://sspback.eskimi.com/bid-request' + +const DEFAULT_BID_TTL = 30; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_NET_REVENUE = true; +const GVLID = 814; + +const VIDEO_ORTB_PARAMS = [ + 'mimes', + 'minduration', + 'maxduration', + 'placement', + 'protocols', + 'startdelay', + 'skip', + 'skipafter', + 'minbitrate', + 'maxbitrate', + 'delivery', + 'playbackmethod', + 'api', + 'linearity', + 'battr' +]; + +const BANNER_ORTB_PARAMS = [ + 'battr' +] + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid, + buildRequests, + interpretResponse, + /** + * Register bidder specific code, which will execute if a bid from this bidder won the auction + * @param {Bid} bid The bid that won the auction + */ + onBidWon: function (bid) { + if (bid.burl) { + utils.triggerPixel(bid.burl); + } + } +} + +registerBidder(spec); + +const CONVERTER = ortbConverter({ + context: { + netRevenue: DEFAULT_NET_REVENUE, + ttl: DEFAULT_BID_TTL, + currency: DEFAULT_CURRENCY + }, + imp(buildImp, bidRequest, context) { + let imp = buildImp(bidRequest, context); + imp.secure = Number(window.location.protocol === 'https:'); + if (!imp.bidfloor && bidRequest.params.bidFloor) { + imp.bidfloor = bidRequest.params.bidFloor; + imp.bidfloorcur = getBidIdParameter('bidFloorCur', bidRequest.params).toUpperCase() || 'USD' + } + + if (bidRequest.mediaTypes[VIDEO]) { + imp = buildVideoImp(bidRequest, imp); + } else if (bidRequest.mediaTypes[BANNER]) { + imp = buildBannerImp(bidRequest, imp); + } + + return imp; + } +}); + +function isBidRequestValid(bidRequest) { + return (isPlacementIdValid(bidRequest) && (isValidBannerRequest(bidRequest) || isValidVideoRequest(bidRequest))); +} + +function isPlacementIdValid(bidRequest) { + return utils.isNumber(bidRequest.params.placementId); +} + +function isValidBannerRequest(bidRequest) { + const bannerSizes = utils.deepAccess(bidRequest, `mediaTypes.${BANNER}.sizes`); + return utils.isArray(bannerSizes) && bannerSizes.length > 0 && bannerSizes.every(size => utils.isNumber(size[0]) && utils.isNumber(size[1])); +} + +function isValidVideoRequest(bidRequest) { + const videoSizes = utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}.playerSize`); + + return utils.isArray(videoSizes) && videoSizes.length > 0 && videoSizes.every(size => utils.isNumber(size[0]) && utils.isNumber(size[1])); +} + +function buildRequests(validBids, bidderRequest) { + let videoBids = validBids.filter(bid => isVideoBid(bid)); + let bannerBids = validBids.filter(bid => isBannerBid(bid)); + let requests = []; + + bannerBids.forEach(bid => { + requests.push(createRequest([bid], bidderRequest, BANNER)); + }); + + videoBids.forEach(bid => { + requests.push(createRequest([bid], bidderRequest, VIDEO)); + }); + + return requests; +} + +function interpretResponse(response, request) { + return CONVERTER.fromORTB({ request: request.data, response: response.body }).bids; +} + +function buildVideoImp(bidRequest, imp) { + const videoAdUnitParams = utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}`, {}); + const videoBidderParams = utils.deepAccess(bidRequest, `params.${VIDEO}`, {}); + + const videoParams = { ...videoAdUnitParams, ...videoBidderParams }; + + const videoSizes = (videoAdUnitParams && videoAdUnitParams.playerSize) || []; + + if (videoSizes && videoSizes.length > 0) { + utils.deepSetValue(imp, 'video.w', videoSizes[0][0]); + utils.deepSetValue(imp, 'video.h', videoSizes[0][1]); + } + + VIDEO_ORTB_PARAMS.forEach((param) => { + if (videoParams.hasOwnProperty(param)) { + utils.deepSetValue(imp, `video.${param}`, videoParams[param]); + } + }); + + if (imp.video && videoParams?.context === 'outstream') { + imp.video.placement = imp.video.placement || 4; + } + + return { ...imp }; +} + +function buildBannerImp(bidRequest, imp) { + const bannerAdUnitParams = utils.deepAccess(bidRequest, `mediaTypes.${BANNER}`, {}); + const bannerBidderParams = utils.deepAccess(bidRequest, `params.${BANNER}`, {}); + + const bannerParams = { ...bannerAdUnitParams, ...bannerBidderParams }; + + let sizes = bidRequest.mediaTypes.banner.sizes; + + if (sizes) { + utils.deepSetValue(imp, 'banner.w', sizes[0][0]); + utils.deepSetValue(imp, 'banner.h', sizes[0][1]); + } + + BANNER_ORTB_PARAMS.forEach((param) => { + if (bannerParams.hasOwnProperty(param)) { + utils.deepSetValue(imp, `banner.${param}`, bannerParams[param]); + } + }); + + return { ...imp }; +} + +function createRequest(bidRequests, bidderRequest, mediaType) { + const data = CONVERTER.toORTB({ bidRequests, bidderRequest, context: { mediaType } }) + + const bid = bidRequests.find((b) => b.params.placementId) + if (!data.site) data.site = {} + data.site.ext = { placementId: bid.params.placementId } + + if (bidderRequest.gdprConsent) { + if (!data.user) data.user = {}; + if (!data.user.ext) data.user.ext = {}; + if (!data.regs) data.regs = {}; + if (!data.regs.ext) data.regs.ext = {}; + data.user.ext.consent = bidderRequest.gdprConsent.consentString; + data.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + + if (bid.params.bcat) data.bcat = bid.params.bcat; + if (bid.params.badv) data.badv = bid.params.badv; + if (bid.params.bapp) data.bapp = bid.params.bapp; + + return { + method: 'POST', + url: ENDPOINT, + data: data, + options: { contentType: 'application/json;charset=UTF-8', withCredentials: false } + } +} + +function isVideoBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.video'); +} + +function isBannerBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid); +} diff --git a/modules/eskimiBidAdapter.md b/modules/eskimiBidAdapter.md new file mode 100644 index 00000000000..b3494a217eb --- /dev/null +++ b/modules/eskimiBidAdapter.md @@ -0,0 +1,53 @@ +# Overview + +Module Name: ESKIMI Bidder Adapter +Module Type: Bidder Adapter +Maintainer: tech@eskimi.com + +# Description + +Module that connects to Eskimi demand sources to fetch bids using OpenRTB standard. +Banner and video formats are supported. + +# Test Parameters +```javascript + var adUnits = [{ + code: '/19968336/prebid_banner_example_1', + mediaTypes: { + banner: { + sizes: [[ 300, 250 ]], + ... // battr + } + }, + bids: [{ + bidder: 'eskimi', + params: { + placementId: 612, + ... // bcat, badv, bapp + } + }] + }, { + code: '/19968336/prebid_video_example_1', + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'], + api: [1, 2, 4, 6], + ... // Aditional ORTB video params (including battr) + } + }, + bids: [{ + bidder: 'eskimi', + params: { + placementId: 612, + ... // bcat, badv, bapp + } + }] + }]; +``` + +Where: + +* placementId - Placement ID of the ad unit (required) +* bcat, badv, bapp, battr - ORTB blocking parameters as specified by OpenRTB 2.5 + diff --git a/modules/etargetBidAdapter.js b/modules/etargetBidAdapter.js index f7d552b1b09..cced180e061 100644 --- a/modules/etargetBidAdapter.js +++ b/modules/etargetBidAdapter.js @@ -1,5 +1,4 @@ import { deepSetValue, isFn, isPlainObject } from '../src/utils.js'; -import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; @@ -36,7 +35,7 @@ export const spec = { lastCountry = countryMap[bid.params.country]; } reqParams = bid.params; - reqParams.transactionId = bid.transactionId; + reqParams.transactionId = bid.ortb2Imp?.ext?.tid; request.push(formRequestUrl(reqParams)); floors[i] = getBidFloor(bid); } @@ -91,7 +90,7 @@ export const spec = { mts['title'] = [(document.getElementsByTagName('title')[0] || []).innerHTML]; mts['base'] = [(document.getElementsByTagName('base')[0] || {}).href]; mts['referer'] = [document.location.href]; - mts['ortb2'] = (config.getConfig('ortb2') || {}); + mts['ortb2'] = (bidderRequest.ortb2 || {}); } catch (e) { mts.error = e; } @@ -138,7 +137,6 @@ export const spec = { vastXml: data.vast_content, vastUrl: data.vast_link, mediaType: data.response, - transactionId: bid.transactionId }; if (bidRequest.gdpr) { bidObject.gdpr = bidRequest.gdpr.gdpr; diff --git a/modules/euidIdSystem.js b/modules/euidIdSystem.js new file mode 100644 index 00000000000..6a3a0869c0e --- /dev/null +++ b/modules/euidIdSystem.js @@ -0,0 +1,130 @@ +/** + * This module adds EUID ID support to the User ID module. It shares significant functionality with the UID2 module. + * The {@link module:modules/userId} module is required. + * @module modules/euidIdSystem + * @requires module:modules/userId + */ + +import { logInfo, logWarn, deepAccess } from '../src/utils.js'; +import {submodule} from '../src/hook.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; + +// RE below lint exception: UID2 and EUID are separate modules, but the protocol is the same and shared code makes sense here. +// eslint-disable-next-line prebid/validate-imports +import { Uid2GetId, Uid2CodeVersion } from './uid2IdSystem_shared.js'; + +const MODULE_NAME = 'euid'; +const MODULE_REVISION = Uid2CodeVersion; +const PREBID_VERSION = '$prebid.version$'; +const EUID_CLIENT_ID = `PrebidJS-${PREBID_VERSION}-EUIDModule-${MODULE_REVISION}`; +const GVLID_TTD = 21; // The Trade Desk +const LOG_PRE_FIX = 'EUID: '; +const ADVERTISING_COOKIE = '__euid_advertising_token'; + +// eslint-disable-next-line no-unused-vars +const EUID_TEST_URL = 'https://integ.euid.eu'; +const EUID_PROD_URL = 'https://prod.euid.eu'; +const EUID_BASE_URL = EUID_PROD_URL; + +function createLogger(logger, prefix) { + return function (...strings) { + logger(prefix + ' ', ...strings); + } +} +const _logInfo = createLogger(logInfo, LOG_PRE_FIX); +const _logWarn = createLogger(logWarn, LOG_PRE_FIX); + +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); + +function hasWriteToDeviceConsent(consentData) { + const gdprApplies = consentData?.gdprApplies === true; + const localStorageConsent = deepAccess(consentData, `vendorData.purpose.consents.1`) + const prebidVendorConsent = deepAccess(consentData, `vendorData.vendor.consents.${GVLID_TTD.toString()}`) + if (gdprApplies && (!localStorageConsent || !prebidVendorConsent)) { + return false; + } + return true; +} + +/** @type {Submodule} */ +export const euidIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + + /** + * Vendor id of The Trade Desk + * @type {Number} + */ + gvlid: GVLID_TTD, + /** + * decode the stored id value for passing to bid requests + * @function + * @param {string} value + * @returns {{euid:{ id: string } }} or undefined if value doesn't exists + */ + decode(value) { + const result = decodeImpl(value); + _logInfo('EUID decode returned', result); + return result; + }, + + /** + * performs action to obtain id and return a value. + * @function + * @param {SubmoduleConfig} [configparams] + * @param {ConsentData|undefined} consentData + * @returns {euidId} + */ + getId(config, consentData) { + if (consentData?.gdprApplies !== true) { + logWarn('EUID is intended for use within the EU. The module will not run when GDPR does not apply.'); + return; + } + if (!hasWriteToDeviceConsent(consentData)) { + // The module cannot operate without this permission. + _logWarn(`Unable to use EUID module due to insufficient consent. The EUID module requires storage permission.`) + return; + } + + const mappedConfig = { + apiBaseUrl: config?.params?.euidApiBase ?? EUID_BASE_URL, + paramToken: config?.params?.euidToken, + serverCookieName: config?.params?.euidCookie, + storage: config?.params?.storage ?? 'localStorage', + clientId: EUID_CLIENT_ID, + internalStorage: ADVERTISING_COOKIE + }; + + const result = Uid2GetId(mappedConfig, storage, _logInfo, _logWarn); + _logInfo(`EUID getId returned`, result); + return result; + }, + eids: { + 'euid': { + source: 'euid.eu', + atype: 3, + getValue: function(data) { + return data.id; + } + }, + }, +}; + +function decodeImpl(value) { + if (typeof value === 'string') { + _logInfo('Found server-only token. Refresh is unavailable for this token.'); + const result = { euid: { id: value } }; + return result; + } + if (Date.now() < value.latestToken.identity_expires) { + return { euid: { id: value.latestToken.advertising_token } }; + } + return null; +} + +// Register submodule for userId +submodule('userId', euidIdSubmodule); diff --git a/modules/euidIdSystem.md b/modules/euidIdSystem.md new file mode 100644 index 00000000000..e3e16bce89d --- /dev/null +++ b/modules/euidIdSystem.md @@ -0,0 +1,131 @@ +## EUID User ID Submodule + +EUID requires initial tokens to be generated server-side. The EUID module handles storing, providing, and optionally refreshing them. The module can operate in one of two different modes: *Client Refresh* mode or *Server Only* mode. + +*Server Only* mode was originally referred to as *legacy mode*, but it is a popular mode for new integrations where publishers prefer to handle token refresh server-side. + +## Client Refresh mode + +This is the recommended mode for most scenarios. In this mode, the full response body from the EUID Token Generate or Token Refresh endpoint must be provided to the module. As long as the refresh token remains valid, the module will refresh the advertising token as needed. + +To configure the module to use this mode, you must **either**: +1. Set `params.euidCookie` to the name of the cookie which contains the response body as a JSON string, **or** +2. Set `params.euidToken` to the response body as a JavaScript object. + +### Client refresh cookie example + +In this example, the cookie is called `euid_pub_cookie`. + +Cookie: +``` +euid_pub_cookie={"advertising_token":"...advertising token...","refresh_token":"...refresh token...","identity_expires":1684741472161,"refresh_from":1684741425653,"refresh_expires":1684784643668,"refresh_response_key":"...response key..."} +``` + +Configuration: +``` +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'euid', + params: { + euidCookie: 'euid_pub_cookie' + } + }] + } +}); +``` + +### Client refresh euidToken example + +Configuration: +``` +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'euid', + params: { + euidToken: { + 'advertising_token': '...advertising token...', + 'refresh_token': '...refresh token...', + // etc. - see the Sample Token below for contents of this object + } + } + }] + } +}); +``` + +## Server-Only Mode + +In this mode, only the advertising token is provided to the module. The module will not be able to refresh the token. The publisher is responsible for implementing some other way to refresh the token. + +To configure the module to use this mode, you must **either**: +1. Set a cookie named `__euid_advertising_token` to the advertising token, **or** +2. Set `value` to an ID block containing the advertising token. + +### Server only cookie example + +Cookie: +``` +__euid_advertising_token=...advertising token... +``` + +Configuration: +``` +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'euid' + }] + } +}); +``` + +### Server only value example + +Configuration: +``` +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'euid' + value: { + 'euid': { + 'id': '...advertising token...' + } + } + }] + } +}); +``` + +## Storage + +The module stores a number of internal values. By default, all values are stored in HTML5 local storage. You can switch to cookie storage by setting `params.storage` to `cookie`. The cookie size can be significant and this is not recommended, but is provided as an option if local storage is not an option. + +## Sample token + +`{`
  `"advertising_token": "...",`
  `"refresh_token": "...",`
  `"identity_expires": 1633643601000,`
  `"refresh_from": 1633643001000,`
  `"refresh_expires": 1636322000000,`
  `"refresh_response_key": "wR5t6HKMfJ2r4J7fEGX9Gw=="`
`}` + +### Notes + +If you are trying to limit the size of cookies, provide the token in configuration and use the default option of local storage. + +If you provide an expired identity and the module has a valid identity which was refreshed from the identity you provide, it will use the refreshed identity. The module stores the original token used for refreshing the token, and it will use the refreshed tokens as long as the original token matches the one supplied. + +If a new token is supplied which does not match the original token used to generate any refreshed tokens, all stored tokens will be discarded and the new token used instead (refreshed if necessary). + +You can set `params.euidApiBase` to `"https://integ.euid.eu"` during integration testing. Be aware that you must use the same environment (production or integration) here as you use for generating tokens. + +## Parameter Descriptions for the `usersync` Configuration Section + +The below parameters apply only to the EUID User ID Module integration. + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | ID value for the EUID module - `"euid"` | `"euid"` | +| value | Optional, Server only | Object | An object containing the value for the advertising token. | See the example above. | +| params.euidToken | Optional, Client refresh | Object | The initial EUID token. This should be `body` element of the decrypted response from a call to the `/token/generate` or `/token/refresh` endpoint. | See the sample token above. | +| params.euidCookie | Optional, Client refresh | String | The name of a cookie which holds the initial EUID token, set by the server. The cookie should contain JSON in the same format as the euidToken param. **If euidToken is supplied, this param is ignored.** | See the sample token above. | +| params.euidApiBase | Optional, Client refresh | String | Overrides the default EUID API endpoint. | `"https://prod.euid.eu"` _(default)_| +| params.storage | Optional, Client refresh | String | Specify whether to use `cookie` or `localStorage` for module-internal storage. It is recommended to not provide this and allow the module to use the default. | `localStorage` _(default)_ | diff --git a/modules/experianRtdProvider.js b/modules/experianRtdProvider.js new file mode 100644 index 00000000000..e18296342de --- /dev/null +++ b/modules/experianRtdProvider.js @@ -0,0 +1,135 @@ +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { MODULE_TYPE_RTD } from '../src/activities/modules.js'; +import { + deepAccess, + isArray, + isPlainObject, + isStr, + mergeDeep, + safeJSONParse, + timestamp +} from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; + +export const SUBMODULE_NAME = 'experian_rtid'; +export const EXPERIAN_RTID_DATA_KEY = 'experian_rtid_data'; +export const EXPERIAN_RTID_EXPIRATION_KEY = 'experian_rtid_expiration'; +export const EXPERIAN_RTID_STALE_KEY = 'experian_rtid_stale'; +export const EXPERIAN_RTID_NO_TRACK_KEY = 'experian_rtid_no_track'; +const EXPERIAN_RTID_URL = 'https://rtid.tapad.com' +const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: SUBMODULE_NAME }); + +export const experianRtdObj = { + /** + * @summary modify bid request data + * @param {Object} reqBidsConfigObj + * @param {function} done + * @param {SubmoduleConfig} config + * @param {UserConsentData} userConsent + */ + getBidRequestData(reqBidsConfigObj, done, config, userConsent) { + const dataEnvelope = storage.getDataFromLocalStorage(EXPERIAN_RTID_DATA_KEY, null); + const stale = storage.getDataFromLocalStorage(EXPERIAN_RTID_STALE_KEY, null); + const expired = storage.getDataFromLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, null); + const noTrack = storage.getDataFromLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, null); + const now = timestamp() + if (now > new Date(expired).getTime() || (noTrack == null && dataEnvelope == null)) { + // request data envelope and don't manipulate bids + experianRtdObj.requestDataEnvelope(config, userConsent) + done(); + return false; + } + if (now > new Date(stale).getTime()) { + // request data envelope and manipulate bids + experianRtdObj.requestDataEnvelope(config, userConsent); + } + if (noTrack != null) { + done(); + return false; + } + experianRtdObj.alterBids(reqBidsConfigObj, config); + done() + return true; + }, + + alterBids(reqBidsConfigObj, config) { + const dataEnvelope = safeJSONParse(storage.getDataFromLocalStorage(EXPERIAN_RTID_DATA_KEY, null)); + if (dataEnvelope == null) { + return; + } + deepAccess(config, 'params.bidders').forEach((bidderCode) => { + const bidderData = dataEnvelope.find(({ bidder }) => bidder === bidderCode) + if (bidderData != null) { + mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, { [bidderCode]: { experianRtidKey: bidderData.data.key, experianRtidData: bidderData.data.data } }) + } + }) + }, + requestDataEnvelope(config, userConsent) { + function storeDataEnvelopeResponse(response) { + const responseJson = safeJSONParse(response); + if (responseJson != null) { + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, responseJson.staleAt, null); + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, responseJson.expiresAt, null); + if (responseJson.status === 'no_track') { + storage.setDataInLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, 'no_track', null); + storage.removeDataFromLocalStorage(EXPERIAN_RTID_DATA_KEY, null); + } else { + storage.setDataInLocalStorage(EXPERIAN_RTID_DATA_KEY, JSON.stringify(responseJson.data), null); + storage.removeDataFromLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, null); + } + } + } + const queryString = experianRtdObj.extractConsentQueryString(config, userConsent) + const fullUrl = queryString == null ? `${EXPERIAN_RTID_URL}/acc/${deepAccess(config, 'params.accountId')}/ids` : `${EXPERIAN_RTID_URL}/acc/${deepAccess(config, 'params.accountId')}/ids${queryString}` + ajax(fullUrl, storeDataEnvelopeResponse, null, { withCredentials: true, contentType: 'application/json' }) + }, + extractConsentQueryString(config, userConsent) { + const queryObj = {}; + + if (userConsent != null) { + if (userConsent.gdpr != null) { + const { gdprApplies, consentString } = userConsent.gdpr; + mergeDeep(queryObj, {gdpr: gdprApplies, gdpr_consent: consentString}) + } + if (userConsent.uspConsent != null) { + mergeDeep(queryObj, {us_privacy: userConsent.uspConsent}) + } + } + const consentQueryString = Object.entries(queryObj).map(([key, val]) => `${key}=${val}`).join('&'); + + let idsString = ''; + if (deepAccess(config, 'params.ids') != null && isPlainObject(deepAccess(config, 'params.ids'))) { + idsString = Object.entries(deepAccess(config, 'params.ids')).map(([idType, val]) => { + if (isArray(val)) { + return val.map((singleVal) => `id.${idType}=${singleVal}`).join('&') + } else { + return `id.${idType}=${val}` + } + }).join('&') + } + + const combinedString = [consentQueryString, idsString].filter((string) => string !== '').join('&'); + return combinedString !== '' ? `?${combinedString}` : undefined; + }, + /** + * @function + * @summary init sub module + * @name RtdSubmodule#init + * @param {SubmoduleConfig} config + * @param {UserConsentData} userConsent + * @return {boolean} false to remove sub module + */ + init(config, userConsent) { + return isStr(deepAccess(config, 'params.accountId')); + } +} + +/** @type {RtdSubmodule} */ +export const experianRtdSubmodule = { + name: SUBMODULE_NAME, + getBidRequestData: experianRtdObj.getBidRequestData, + init: experianRtdObj.init +} + +submodule('realTimeData', experianRtdSubmodule); diff --git a/modules/experianRtdProvider.md b/modules/experianRtdProvider.md new file mode 100644 index 00000000000..ad46e0c3d55 --- /dev/null +++ b/modules/experianRtdProvider.md @@ -0,0 +1,52 @@ +# Experian Real-time Data Submodule + +## Overview + + Module Name: Experian Rtd Provider + Module Type: Rtd Provider + Maintainer: team-ui@tapad.com + +## Description + +The Experian RTD module adds encrypted identifier envelope to the bidding object. + +## Usage + +### Build +``` +gulp build --modules="rtdModule,experianRtdProvider,appnexusBidAdapter,..." +``` + +> Note that the global RTD module, `rtdModule`, is a prerequisite of the Experian RTD module. + +### Configuration + +Use `setConfig` to instruct Prebid.js to initialize the Experian RTD module, as specified below. + +This module is configured as part of the `realTimeData.dataProviders` + +```javascript +pbjs.setConfig({ + realTimeData: { + auctionDelay: 300, + dataProviders: [{ + name: 'experian_rtid', + waitForIt: true, + params: { + accountId: 'ZylatYg', + bidders: ['sovrn', 'pubmatic'], + ids: { maid: ['424', '2982'], hem: 'my-hem' } + } + }] + } +}) +``` + +### Parameters +| Name | Type | Description | Default | +|:-----------------|:----------------------------------------|:-----------------------------------------------------------------------------|:-----------------------| +| name | String | Real time data module name | Always 'experian_rtid' | +| waitForIt | Boolean | Set to true to maximize chance for bidder enrichment, used with auctionDelay | `false` | +| params.accountId | String | Your account id issued by Experian | | +| params.bidders | Array | List of bidders for which you would like data to be set | | +| params.ids | Record or string> | Additional identifiers to send to Experian RTID endpoint | | diff --git a/modules/express.js b/modules/express.js index 0b1780e3c26..a2998baed07 100644 --- a/modules/express.js +++ b/modules/express.js @@ -1,6 +1,8 @@ import { logMessage, logWarn, logError, logInfo } from '../src/utils.js'; +import {getGlobal} from '../src/prebidGlobal.js'; const MODULE_NAME = 'express'; +const pbjsInstance = getGlobal(); /** * Express Module @@ -12,7 +14,7 @@ const MODULE_NAME = 'express'; * * @param {Object[]} [adUnits = pbjs.adUnits] - an array of adUnits for express to operate on. */ -$$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { +pbjsInstance.express = function(adUnits = pbjsInstance.adUnits) { logMessage('loading ' + MODULE_NAME); if (adUnits.length === 0) { @@ -138,10 +140,10 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { } if (adUnits.length) { - $$PREBID_GLOBAL$$.requestBids({ + pbjsInstance.requestBids({ adUnits: adUnits, bidsBackHandler: function () { - $$PREBID_GLOBAL$$.setTargetingForGPTAsync(); + pbjsInstance.setTargetingForGPTAsync(); fGptRefresh.apply(pads(), [ adUnits.map(function (adUnit) { return gptSlotCache[adUnit.code]; @@ -168,10 +170,10 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) { } if (adUnits.length) { - $$PREBID_GLOBAL$$.requestBids({ + pbjsInstance.requestBids({ adUnits: adUnits, bidsBackHandler: function () { - $$PREBID_GLOBAL$$.setTargetingForGPTAsync(); + pbjsInstance.setTargetingForGPTAsync(); fGptRefresh.apply(pads(), [ adUnits.map(function (adUnit) { return gptSlotCache[adUnit.code]; diff --git a/modules/eywamediaBidAdapter.md b/modules/eywamediaBidAdapter.md deleted file mode 100644 index 76b9b032c1b..00000000000 --- a/modules/eywamediaBidAdapter.md +++ /dev/null @@ -1,37 +0,0 @@ -# Overview - -``` -Module Name: Eywamedia Bid Adapter -Module Type: Bidder Adapter -Maintainer: sharath@eywamedia.com -Note: Our ads will only render in mobile and desktop -``` - -# Description - -Connects to Eywamedia Ad Server for bids. - -Eywamedia bid adapter supports Banners. - -# Test Parameters -``` -var adUnits = [ - // Banner adUnit - { - code: 'div-gpt-ad-1460505748561-0', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'eywamedia', - params: { - publisherId: 'f63a2362-5aa4-4829-bbd2-2678ced8b63e', //Required - GUID (may include numbers and characters) - bidFloor: 0.50, // optional - cats: ["iab1-1","iab23-2"], // optional - keywords: ["sports", "cricket"], // optional - lat: 12.33333, // optional - lon: 77.32322, // optional - locn: "country$region$city$zip" // optional - } - }] - } -]; -``` diff --git a/modules/fabrickIdSystem.js b/modules/fabrickIdSystem.js index 08eb2d4f043..bc9c30cb479 100644 --- a/modules/fabrickIdSystem.js +++ b/modules/fabrickIdSystem.js @@ -70,10 +70,10 @@ export const fabrickIdSubmodule = { } } // pull off the trailing & - url = url.slice(0, -1) + url = url.slice(0, -1); const referer = _getRefererInfo(configParams); const refs = new Map(); - _setReferrer(refs, referer.referer); + _setReferrer(refs, referer.topmostLocation); if (referer.stack && referer.stack[0]) { _setReferrer(refs, referer.stack[0]); } @@ -117,6 +117,12 @@ export const fabrickIdSubmodule = { } catch (e) { logError(`fabrickIdSystem encountered an error`, e); } + }, + eids: { + 'fabrickId': { + source: 'neustar.biz', + atype: 1 + }, } }; @@ -174,7 +180,7 @@ export function appendUrl(url, paramName, s, configParams) { s = s.substring(0, thisMaxRefLen - 2); } } - return `${url}${s}` + return `${url}${s}`; } else { return url; } diff --git a/modules/fairtradeBidAdapter.md b/modules/fairtradeBidAdapter.md deleted file mode 100644 index 56abb84d15a..00000000000 --- a/modules/fairtradeBidAdapter.md +++ /dev/null @@ -1,28 +0,0 @@ -# Overview - -Module Name: FairTrade Bidder Adapter -Module Type: Bidder Adapter -Maintainer: Tammy.l@VaticDigital.com - -# Description - -Module that connects to FairTrade demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "fairtrade", - params: { - uid: '166', - priceType: 'gross' // by default is 'net' - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/feedadBidAdapter.js b/modules/feedadBidAdapter.js index 6fb39c49ec8..7b41f0fcc03 100644 --- a/modules/feedadBidAdapter.js +++ b/modules/feedadBidAdapter.js @@ -1,4 +1,4 @@ -import { deepAccess, logWarn } from '../src/utils.js'; +import {deepAccess, isArray, logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; import {ajax} from '../src/ajax.js'; @@ -7,7 +7,23 @@ import {ajax} from '../src/ajax.js'; * Version of the FeedAd bid adapter * @type {string} */ -const VERSION = '1.0.2'; +const VERSION = '1.0.6'; + +/** + * @typedef {object} FeedAdUserSync + * @inner + * + * @property {string} type + * @property {string} url + */ + +/** + * @typedef {object} FeedAdBidExtension + * @inner + * + * @property {FeedAdUserSync[]} pixels + * @property {FeedAdUserSync[]} iframes + */ /** * @typedef {object} FeedAdApiBidRequest @@ -16,7 +32,8 @@ const VERSION = '1.0.2'; * @property {number} ad_type * @property {string} client_token * @property {string} placement_id - * @property {string} sdk_version + * @property {string} prebid_adapter_version + * @property {string} prebid_sdk_version * @property {boolean} app_hybrid * * @property {string} [app_bundle_id] @@ -31,7 +48,7 @@ const VERSION = '1.0.2'; * @typedef {object} FeedAdApiBidResponse * @inner * - * @property {string} ad - Ad HTML payload + * @property {string} [ad] - Ad HTML payload * @property {number} cpm - number / float * @property {string} creativeId - ID of creative for tracking * @property {string} currency - 3-letter ISO 4217 currency-code @@ -40,6 +57,7 @@ const VERSION = '1.0.2'; * @property {string} requestId - bids[].bidId * @property {number} ttl - Time to live for this ad * @property {number} width - Width of creative returned in [].ad + * @property {FeedAdBidExtension} [ext] - an extension object */ /** @@ -61,6 +79,14 @@ const VERSION = '1.0.2'; * @property [device_platform] {1|2|3} 1 - Android | 2 - iOS | 3 - Windows */ +/** + * @typedef {object} FeedAdServerResponse + * @extends ServerResponse + * @inner + * + * @property {FeedAdApiBidResponse[]} body - the body of a FeedAd server response + */ + /** * The IAB TCF 2.0 vendor ID for the FeedAd GmbH */ @@ -180,7 +206,8 @@ function createApiBidRParams(request) { ad_type: 0, client_token: request.params.clientToken, placement_id: request.params.placementId, - sdk_version: `prebid_${VERSION}`, + prebid_adapter_version: VERSION, + prebid_sdk_version: '$prebid.version$', app_hybrid: false, }); } @@ -206,8 +233,8 @@ function buildRequests(validBidRequests, bidderRequest) { }) }); data.bids.forEach(bid => BID_METADATA[bid.bidId] = { - referer: data.refererInfo.referer, - transactionId: bid.transactionId + referer: data.refererInfo.page, + transactionId: bid.ortb2Imp?.ext?.tid, }); if (bidderRequest.gdprConsent) { data.consentIabTcf = bidderRequest.gdprConsent.consentString; @@ -225,15 +252,21 @@ function buildRequests(validBidRequests, bidderRequest) { /** * Adapts the FeedAd server response to Prebid format - * @param {ServerResponse} serverResponse - the FeedAd server response + * @param {FeedAdServerResponse} serverResponse - the FeedAd server response * @param {BidRequest} request - the initial bid request * @returns {Bid[]} the FeedAd bids */ function interpretResponse(serverResponse, request) { - /** - * @type FeedAdApiBidResponse[] - */ - return typeof serverResponse.body === 'string' ? JSON.parse(serverResponse.body) : serverResponse.body; + const response = typeof serverResponse.body === 'string' ? JSON.parse(serverResponse.body) : serverResponse.body; + if (!isArray(response)) { + return []; + } + return response.filter(bid => Object.prototype.hasOwnProperty.call(bid, 'ad')) + .map(bid => { + const copy = Object.assign({}, bid); + delete copy.ext; + return copy; + }); } /** @@ -258,7 +291,8 @@ function createTrackingParams(data, klass) { prebid_bid_id: bidId, prebid_transaction_id: transactionId, referer, - sdk_version: VERSION + prebid_adapter_version: VERSION, + prebid_sdk_version: '$prebid.version$', }; } @@ -283,6 +317,34 @@ function trackingHandlerFactory(klass) { } } +/** + * Reads the user syncs off the server responses and converts them into Prebid.JS format + * @param {SyncOptions} syncOptions + * @param {FeedAdServerResponse[]} serverResponses + * @param gdprConsent + * @param uspConsent + */ +function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { + return serverResponses.flatMap(response => { + // merge all response bodies into one + const body = response.body; + return isArray(body) ? body : []; + }) + .flatMap(/** @param {FeedAdApiBidResponse} bidResponse */ bidResponse => { + // extract user syncs from extension + const pixels = (syncOptions.pixelEnabled && bidResponse?.ext?.pixels) ? bidResponse.ext.pixels : []; + const iframes = (syncOptions.iframeEnabled && bidResponse?.ext?.iframes) ? bidResponse.ext.iframes : []; + return pixels.concat(...iframes); + }) + .reduce((syncs, sync) => { + // remove duplicates + if (!syncs.find(it => it.type === sync.type && it.url === sync.url)) { + syncs.push(sync); + } + return syncs; + }, []); +} + /** * @type {BidderSpec} */ @@ -294,7 +356,8 @@ export const spec = { buildRequests, interpretResponse, onTimeout: trackingHandlerFactory('prebid_bidTimeout'), - onBidWon: trackingHandlerFactory('prebid_bidWon') + onBidWon: trackingHandlerFactory('prebid_bidWon'), + getUserSyncs }; registerBidder(spec); diff --git a/modules/fidelityBidAdapter.md b/modules/fidelityBidAdapter.md deleted file mode 100644 index 0af75689bd6..00000000000 --- a/modules/fidelityBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview -​ -**Module Name**: Fidelity Media fmxSSP Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: on@fidelity-media.com -​ -# Description -​ -Connects to Fidelity Media fmxSSP demand source to fetch bids. -​ -# Test Parameters -``` - var adUnits = [{ - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], - } - }, - bids: [{ - bidder: 'fidelity', - params: { - zoneid: '27248', - floor: 0.005, - server: 'x.fidelity-media.com' - } - }] - }]; - -``` \ No newline at end of file diff --git a/modules/finativeBidAdapter.js b/modules/finativeBidAdapter.js new file mode 100644 index 00000000000..87580a209bb --- /dev/null +++ b/modules/finativeBidAdapter.js @@ -0,0 +1,238 @@ +// jshint esversion: 6, es3: false, node: true +'use strict'; + +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {NATIVE} from '../src/mediaTypes.js'; +import {_map, deepAccess, deepSetValue, isEmpty} from '../src/utils.js'; +import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; + +const BIDDER_CODE = 'finative'; +const DEFAULT_CUR = 'EUR'; +const ENDPOINT_URL = 'https://b.finative.cloud/cds/rtb/bid?format=openrtb2.5&ssp=pb'; + +const NATIVE_ASSET_IDS = {0: 'title', 1: 'body', 2: 'sponsoredBy', 3: 'image', 4: 'cta', 5: 'icon'}; + +const NATIVE_PARAMS = { + title: { + id: 0, + name: 'title' + }, + + body: { + id: 1, + name: 'data', + type: 2 + }, + + sponsoredBy: { + id: 2, + name: 'data', + type: 1 + }, + + image: { + id: 3, + type: 3, + name: 'img' + }, + + cta: { + id: 4, + type: 12, + name: 'data' + }, + + icon: { + id: 5, + type: 1, + name: 'img' + } +}; + +export const spec = { + code: BIDDER_CODE, + + supportedMediaTypes: [NATIVE], + + isBidRequestValid: function(bid) { + return !!bid.params.adUnitId; + }, + + buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net'; + const tid = bidderRequest.ortb2?.source?.tid; + const cur = [config.getConfig('currency.adServerCurrency') || DEFAULT_CUR]; + let url = bidderRequest.refererInfo.referer; + + const imp = validBidRequests.map((bid, id) => { + const assets = _map(bid.nativeParams, (bidParams, key) => { + const props = NATIVE_PARAMS[key]; + + const asset = { + required: bidParams.required & 1 + }; + + if (props) { + asset.id = props.id; + + let w, h; + + if (bidParams.sizes) { + w = bidParams.sizes[0]; + h = bidParams.sizes[1]; + } + + asset[props.name] = { + len: bidParams.len, + type: props.type, + w, + h + }; + + return asset; + } + }) + .filter(Boolean); + + if (bid.params.url) { + url = bid.params.url; + } + + return { + id: String(id + 1), + tagid: bid.params.adUnitId, + // TODO: `tid` is not under `imp` in ORTB, is this intentional? + tid: tid, + pt: pt, + native: { + request: { + assets + } + } + }; + }); + + const request = { + id: bidderRequest.bidderRequestId, + site: { + page: url + }, + device: { + ua: navigator.userAgent + }, + cur, + imp, + user: {}, + regs: { + ext: { + gdpr: 0, + pb_ver: '$prebid.version$' + } + } + }; + + if (bidderRequest && bidderRequest.gdprConsent) { + deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); + deepSetValue(request, 'regs.ext.gdpr', (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0); + } + + return { + method: 'POST', + url: ENDPOINT_URL, + data: JSON.stringify(request), + options: { + contentType: 'application/json' + }, + bids: validBidRequests + }; + }, + + interpretResponse: function(serverResponse, { bids }) { + if (isEmpty(serverResponse.body)) { + return []; + } + + const { seatbid, cur } = serverResponse.body; + + const bidResponses = (typeof seatbid != 'undefined') ? flatten(seatbid.map(seat => seat.bid)).reduce((result, bid) => { + result[bid.impid - 1] = bid; + return result; + }, []) : []; + + return bids + .map((bid, id) => { + const bidResponse = bidResponses[id]; + + if (bidResponse) { + return { + requestId: bid.bidId, + cpm: bidResponse.price, + creativeId: bidResponse.crid, + ttl: 1000, + netRevenue: (!bid.netRevenue || bid.netRevenue === 'net'), + currency: cur, + mediaType: NATIVE, + native: parseNative(bidResponse), + meta: { + advertiserDomains: bidResponse.adomain && bidResponse.adomain.length > 0 ? bidResponse.adomain : [] + } + }; + } + }) + .filter(Boolean); + } +}; + +registerBidder(spec); + +function parseNative(bid) { + const {assets, link, imptrackers} = bid.adm.native; + + let clickUrl = link.url.replace(/\$\{AUCTION_PRICE\}/g, bid.price); + + if (link.clicktrackers) { + link.clicktrackers.forEach(function (clicktracker, index) { + link.clicktrackers[index] = clicktracker.replace(/\$\{AUCTION_PRICE\}/g, bid.price); + }); + } + + if (imptrackers) { + imptrackers.forEach(function (imptracker, index) { + imptrackers[index] = imptracker.replace(/\$\{AUCTION_PRICE\}/g, bid.price); + }); + } + + const result = { + url: clickUrl, + clickUrl: clickUrl, + clickTrackers: link.clicktrackers || undefined, + impressionTrackers: imptrackers || undefined + }; + + assets.forEach(asset => { + const kind = NATIVE_ASSET_IDS[asset.id]; + const content = kind && asset[NATIVE_PARAMS[kind].name]; + + if (content) { + result[kind] = content.text || content.value || { url: content.url, width: content.w, height: content.h }; + } + }); + + return result; +} + +function setOnAny(collection, key) { + for (let i = 0, result; i < collection.length; i++) { + result = deepAccess(collection[i], key); + if (result) { + return result; + } + } +} + +function flatten(arr) { + return [].concat(...arr); +} diff --git a/modules/finativeBidAdapter.md b/modules/finativeBidAdapter.md new file mode 100644 index 00000000000..74479150fe4 --- /dev/null +++ b/modules/finativeBidAdapter.md @@ -0,0 +1,45 @@ +# Overview +Module Name: Finative Bidder Adapter +Type: Finative Adapter +Maintainer: tech@finative.cloud + +# Description +Finative Bidder Adapter for Prebid.js. + +# Test Parameters +``` +var adUnits = [{ + code: 'test-div', + + mediaTypes: { + native: { + title: { + required: true, + len: 50 + }, + body: { + required: true, + len: 350 + }, + url: { + required: true + }, + image: { + required: true, + sizes : [300, 175] + }, + sponsoredBy: { + required: true + } + } + }, + bids: [{ + bidder: 'finative', + params: { + url : "https://mockup.finative.cloud", + adUnitId: "1uyo" + } + }] +}]; +``` + diff --git a/modules/fintezaAnalyticsAdapter.js b/modules/fintezaAnalyticsAdapter.js index 12abd2d0efd..be661c96061 100644 --- a/modules/fintezaAnalyticsAdapter.js +++ b/modules/fintezaAnalyticsAdapter.js @@ -1,11 +1,13 @@ import { parseUrl, logError } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import CONSTANTS from '../src/constants.json'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; -const storage = getStorageManager(); -const CONSTANTS = require('../src/constants.json'); +const MODULE_CODE = 'finteza'; +const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); const ANALYTICS_TYPE = 'endpoint'; const FINTEZA_HOST = 'https://content.mql5.com/tr'; @@ -35,16 +37,8 @@ function getPageInfo() { } function getUniqId() { - let cookies; - - try { - cookies = parseCookies(document.cookie); - } catch (a) { - cookies = {}; - } - let isUniqFromLS; - let uniq = cookies[ UNIQ_ID_KEY ]; + let uniq = storage.getCookie(UNIQ_ID_KEY); if (!uniq) { try { if (storage.hasLocalStorage()) { @@ -189,7 +183,7 @@ function initSession() { !checkSessionByExpires() || !checkSessionByReferer() || !checkSessionByDay()) { - sessionId = '' + timestamp + getRandAsStr(SESSION_RAND_PART); + sessionId = '' + timestamp + getRandAsStr(SESSION_RAND_PART); // lgtm [js/insecure-randomness] begin = timestamp; isNew = true; @@ -447,7 +441,7 @@ fntzAnalyticsAdapter.enableAnalytics = function (config) { adapterManager.registerAnalyticsAdapter({ adapter: fntzAnalyticsAdapter, - code: 'finteza' + code: MODULE_CODE, }); export default fntzAnalyticsAdapter; diff --git a/modules/fledgeForGpt.js b/modules/fledgeForGpt.js new file mode 100644 index 00000000000..fd29c41210c --- /dev/null +++ b/modules/fledgeForGpt.js @@ -0,0 +1,167 @@ +/** + * Fledge modules is responsible for registering fledged auction configs into the GPT slot; + * GPT is resposible to run the fledge auction. + */ +import { config } from '../src/config.js'; +import { getHook } from '../src/hook.js'; +import {deepSetValue, logInfo, logWarn, mergeDeep} from '../src/utils.js'; +import {IMP, PBS, registerOrtbProcessor, RESPONSE} from '../src/pbjsORTB.js'; +import * as events from '../src/events.js' +import CONSTANTS from '../src/constants.json'; +import {currencyCompare} from '../libraries/currencyUtils/currency.js'; +import {maximum, minimum} from '../src/utils/reducers.js'; +import {getGptSlotForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; + +const MODULE = 'fledgeForGpt' +const PENDING = {}; + +export let isEnabled = false; + +config.getConfig('fledgeForGpt', config => init(config.fledgeForGpt)); + +/** + * Module init. + */ +export function init(cfg) { + if (cfg && cfg.enabled === true) { + if (!isEnabled) { + getHook('addComponentAuction').before(addComponentAuctionHook); + getHook('makeBidRequests').after(markForFledge); + events.on(CONSTANTS.EVENTS.AUCTION_INIT, onAuctionInit); + events.on(CONSTANTS.EVENTS.AUCTION_END, onAuctionEnd); + isEnabled = true; + } + logInfo(`${MODULE} enabled (browser ${isFledgeSupported() ? 'supports' : 'does NOT support'} fledge)`, cfg); + } else { + if (isEnabled) { + getHook('addComponentAuction').getHooks({hook: addComponentAuctionHook}).remove(); + getHook('makeBidRequests').getHooks({hook: markForFledge}).remove() + events.off(CONSTANTS.EVENTS.AUCTION_INIT, onAuctionInit); + events.off(CONSTANTS.EVENTS.AUCTION_END, onAuctionEnd); + isEnabled = false; + } + logInfo(`${MODULE} disabled`, cfg); + } +} + +function setComponentAuction(adUnitCode, auctionConfigs) { + const gptSlot = getGptSlotForAdUnitCode(adUnitCode); + if (gptSlot && gptSlot.setConfig) { + gptSlot.setConfig({ + componentAuction: auctionConfigs.map(cfg => ({ + configKey: cfg.seller, + auctionConfig: cfg + })) + }); + logInfo(MODULE, `register component auction configs for: ${adUnitCode}: ${gptSlot.getAdUnitPath()}`, auctionConfigs); + } else { + logWarn(MODULE, `unable to register component auction config for ${adUnitCode}`, auctionConfigs); + } +} + +function onAuctionInit({auctionId}) { + PENDING[auctionId] = {}; +} + +function getSlotSignals(bidsReceived = [], bidRequests = []) { + let bidfloor, bidfloorcur; + if (bidsReceived.length > 0) { + const bestBid = bidsReceived.reduce(maximum(currencyCompare(bid => [bid.cpm, bid.currency]))); + bidfloor = bestBid.cpm; + bidfloorcur = bestBid.currency; + } else { + const floors = bidRequests.map(bid => typeof bid.getFloor === 'function' && bid.getFloor()).filter(f => f); + const minFloor = floors.length && floors.reduce(minimum(currencyCompare(floor => [floor.floor, floor.currency]))) + bidfloor = minFloor?.floor; + bidfloorcur = minFloor?.currency; + } + const cfg = {}; + if (bidfloor) { + deepSetValue(cfg, 'auctionSignals.prebid.bidfloor', bidfloor); + bidfloorcur && deepSetValue(cfg, 'auctionSignals.prebid.bidfloorcur', bidfloorcur); + } + return cfg; +} + +function onAuctionEnd({auctionId, bidsReceived, bidderRequests}) { + try { + const allReqs = bidderRequests?.flatMap(br => br.bids); + Object.entries(PENDING[auctionId]).forEach(([adUnitCode, auctionConfigs]) => { + const forThisAdUnit = (bid) => bid.adUnitCode === adUnitCode; + const slotSignals = getSlotSignals(bidsReceived?.filter(forThisAdUnit), allReqs?.filter(forThisAdUnit)); + setComponentAuction(adUnitCode, auctionConfigs.map(cfg => mergeDeep({}, slotSignals, cfg))) + }) + } finally { + delete PENDING[auctionId]; + } +} + +export function addComponentAuctionHook(next, auctionId, adUnitCode, componentAuctionConfig) { + if (PENDING.hasOwnProperty(auctionId)) { + !PENDING[auctionId].hasOwnProperty(adUnitCode) && (PENDING[auctionId][adUnitCode] = []); + PENDING[auctionId][adUnitCode].push(componentAuctionConfig); + } else { + logWarn(MODULE, `Received component auction config for auction that has closed (auction '${auctionId}', adUnit '${adUnitCode}')`, componentAuctionConfig) + } + next(auctionId, adUnitCode, componentAuctionConfig); +} + +function isFledgeSupported() { + return 'runAdAuction' in navigator && 'joinAdInterestGroup' in navigator +} + +export function markForFledge(next, bidderRequests) { + if (isFledgeSupported()) { + const globalFledgeConfig = config.getConfig('fledgeForGpt'); + const bidders = globalFledgeConfig?.bidders ?? []; + bidderRequests.forEach((req) => { + const useGlobalConfig = globalFledgeConfig?.enabled && (bidders.length == 0 || bidders.includes(req.bidderCode)); + Object.assign(req, config.runWithBidder(req.bidderCode, () => { + return { + fledgeEnabled: config.getConfig('fledgeEnabled') ?? (useGlobalConfig ? globalFledgeConfig.enabled : undefined), + defaultForSlots: config.getConfig('defaultForSlots') ?? (useGlobalConfig ? globalFledgeConfig?.defaultForSlots : undefined) + } + })); + }); + } + next(bidderRequests); +} + +export function setImpExtAe(imp, bidRequest, context) { + if (context.bidderRequest.fledgeEnabled) { + imp.ext = Object.assign(imp.ext || {}, { + ae: imp.ext?.ae ?? context.bidderRequest.defaultForSlots + }) + } else { + delete imp.ext?.ae; + } +} +registerOrtbProcessor({type: IMP, name: 'impExtAe', fn: setImpExtAe}); + +// to make it easier to share code between the PBS adapter and adapters whose backend is PBS, break up +// fledge response processing in two steps: first aggregate all the auction configs by their imp... + +export function parseExtPrebidFledge(response, ortbResponse, context) { + (ortbResponse.ext?.prebid?.fledge?.auctionconfigs || []).forEach((cfg) => { + const impCtx = context.impContext[cfg.impid]; + if (!impCtx?.imp?.ext?.ae) { + logWarn('Received fledge auction configuration for an impression that was not in the request or did not ask for it', cfg, impCtx?.imp); + } else { + impCtx.fledgeConfigs = impCtx.fledgeConfigs || []; + impCtx.fledgeConfigs.push(cfg); + } + }) +} +registerOrtbProcessor({type: RESPONSE, name: 'extPrebidFledge', fn: parseExtPrebidFledge, dialects: [PBS]}); + +// ...then, make them available in the adapter's response. This is the client side version, for which the +// interpretResponse api is {fledgeAuctionConfigs: [{bidId, config}]} + +export function setResponseFledgeConfigs(response, ortbResponse, context) { + const configs = Object.values(context.impContext) + .flatMap((impCtx) => (impCtx.fledgeConfigs || []).map(cfg => ({bidId: impCtx.bidRequest.bidId, config: cfg.config}))); + if (configs.length > 0) { + response.fledgeAuctionConfigs = configs; + } +} +registerOrtbProcessor({type: RESPONSE, name: 'fledgeAuctionConfigs', priority: -1, fn: setResponseFledgeConfigs, dialects: [PBS]}) diff --git a/modules/fledgeForGpt.md b/modules/fledgeForGpt.md new file mode 100644 index 00000000000..28f44da6459 --- /dev/null +++ b/modules/fledgeForGpt.md @@ -0,0 +1,145 @@ +# Overview +This module allows Prebid.js to support FLEDGE by integrating it with GPT's [experimental FLEDGE +support](https://github.com/google/ads-privacy/tree/master/proposals/fledge-multiple-seller-testing). + +To learn more about FLEDGE in general, go [here](https://github.com/WICG/turtledove/blob/main/FLEDGE.md). + +This document covers the steps necessary for publishers to enable FLEDGE on their inventory. It also describes +the changes Bid Adapters need to implement in order to support FLEDGE. + +## Publisher Integration +Publishers wishing to enable FLEDGE support must do two things. First, they must compile Prebid.js with support for this module. +This is accomplished by adding the `fledgeForGpt` module to the list of modules they are already using: + +``` +gulp build --modules=fledgeForGpt,... +``` + +Second, they must enable FLEDGE in their Prebid.js configuration. +This is done through module level configuration, but to provide a high degree of flexiblity for testing, FLEDGE settings also exist at the bidder level and slot level. + +### Module Configuration +This module exposes the following settings: + +|Name |Type |Description |Notes | +| :------------ | :------------ | :------------ |:------------ | +|enabled | Boolean |Enable/disable the module |Defaults to `false` | +|bidders | Array[String] |Optional list of bidders |Defaults to all bidders | +|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1 | + +As noted above, FLEDGE support is disabled by default. To enable it, set the `enabled` value to `true` for this module and configure `defaultForSlots` to be `1` (meaning _Client-side auction_). +using the `setConfig` method of Prebid.js. Optionally, a list of +bidders to apply these settings to may be provided: + +```js +pbjs.que.push(function() { + pbjs.setConfig({ + fledgeForGpt: { + enabled: true, + bidders: ['openx', 'rtbhouse'], + defaultForSlots: 1 + } + }); +}); +``` + +### Bidder Configuration +This module adds the following setting for bidders: + +|Name |Type |Description |Notes | +| :------------ | :------------ | :------------ |:------------ | +| fledgeEnabled | Boolean | Enable/disable a bidder to participate in FLEDGE | Defaults to `false` | +|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1| + +Individual bidders may be further included or excluded here using the `setBidderConfig` method +of Prebid.js: + +```js +pbjs.setBidderConfig({ + bidders: ["openx"], + config: { + fledgeEnabled: true, + defaultForSlots: 1 + } +}); +``` + +### AdUnit Configuration +All adunits can be opted-in to FLEDGE in the global config via the `defaultForSlots` parameter. +If needed, adunits can be configured individually by setting an attribute of the `ortb2Imp` object for that +adunit. This attribute will take precedence over `defaultForSlots` setting. + +|Name |Type |Description |Notes | +| :------------ | :------------ | :------------ |:------------ | +| ortb2Imp.ext.ae | Integer | Auction Environment: 1 indicates FLEDGE eligible, 0 indicates it is not | Absence indicates this is not FLEDGE eligible | + +The `ae` field stands for Auction Environment and was chosen to be consistent with the field that GAM passes to bidders +in their Open Bidding and Exchange Bidding APIs. More details on that can be found +[here](https://github.com/google/ads-privacy/tree/master/proposals/fledge-rtb#bid-request-changes-indicating-interest-group-auction-support) +In practice, this looks as follows: + +```js +pbjs.addAdUnits({ + code: "my-adunit-div", + // other config here + ortb2Imp: { + ext: { + ae: 1 + } + } +}); +``` + +## Bid Adapter Integration +Chrome has enabled a two-tier auction in FLEDGE. This allows multiple sellers (frequently SSPs) to act on behalf of the publisher with +a single entity serving as the final decision maker. In their [current approach](https://github.com/google/ads-privacy/tree/master/proposals/fledge-multiple-seller-testing), +GPT has opted to run the final auction layer while allowing other SSPs/sellers to participate as +[Component Auctions](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction) which feed their +bids to the final layer. To learn more about Component Auctions, go [here](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#24-scoring-bids-in-component-auctions). + +The FLEDGE auction, including Component Auctions, are configured via an `AuctionConfig` object that defines the parameters of the auction for a given +seller. This module enables FLEDGE support by allowing bid adaptors to return `AuctionConfig` objects in addition to bids. If a bid adaptor returns an +`AuctionConfig` object, Prebid.js will register it with the appropriate GPT ad slot so the bidder can participate as a Component Auction in the overall +FLEDGE auction for that slot. More details on the GPT API can be found [here](https://developers.google.com/publisher-tag/reference#googletag.config.componentauctionconfig). + +Modifying a bid adapter to support FLEDGE is a straightforward process and consists of the following steps: +1. Detecting when a bid request is FLEDGE eligible +2. Responding with AuctionConfig + +FLEDGE eligibility is made available to bid adapters through the `bidderRequest.fledgeEnabled` field. +The [`bidderRequest`](https://docs.prebid.org/dev-docs/bidder-adaptor.html#bidderrequest-parameters) object is passed to +the [`buildRequests`](https://docs.prebid.org/dev-docs/bidder-adaptor.html#building-the-request) method of an adapter. Bid adapters +who wish to participate should read this flag and pass it to their server. FLEDGE eligibility depends on a number of parameters: + +1. Chrome enablement +2. Publisher participatipon in the [Origin Trial](https://developer.chrome.com/docs/privacy-sandbox/unified-origin-trial/#configure) +3. Publisher Prebid.js configuration (detailed above) + +When a bid request is FLEDGE enabled, a bid adapter can return a tuple consisting of bids and AuctionConfig objects rather than just a list of bids: + +```js +function interpretResponse(resp, req) { + // Load the bids from the response - this is adapter specific + const bids = parseBids(resp); + + // Load the auctionConfigs from the response - also adapter specific + const auctionConfigs = parseAuctionConfigs(resp); + + if (auctionConfigs) { + // Return a tuple of bids and auctionConfigs. It is possible that bids could be null. + return {bids, auctionConfigs}; + } else { + return bids; + } +} +``` + +An AuctionConfig must be associated with an adunit and auction, and this is accomplished using the value in the `bidId` field from the objects in the +`validBidRequests` array passed to the `buildRequests` function - see [here](https://docs.prebid.org/dev-docs/bidder-adaptor.html#ad-unit-params-in-the-validbidrequests-array) +for more details. This means that the AuctionConfig objects returned from `interpretResponse` must contain a `bidId` field whose value corresponds to +the request it should be associated with. This may raise the question: why isn't the AuctionConfig object returned as part of the bid? The +answer is that it's possible to participate in the FLEDGE auction without returning a contextual bid. + +An example of this can be seen in the OpenX OpenRTB bid adapter [here](https://github.com/prebid/Prebid.js/blob/master/modules/openxOrtbBidAdapter.js#L327). + +Other than the addition of the `bidId` field, the AuctionConfig object should adhere to the requirements set forth in FLEDGE. The details of creating an AuctionConfig object are beyond the scope of this document. diff --git a/modules/flippBidAdapter.js b/modules/flippBidAdapter.js new file mode 100644 index 00000000000..dfe8141170d --- /dev/null +++ b/modules/flippBidAdapter.js @@ -0,0 +1,183 @@ +import {isEmpty, parseUrl} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import {getStorageManager} from '../src/storageManager.js'; + +const NETWORK_ID = 11090; +const AD_TYPES = [4309, 641]; +const DTX_TYPES = [5061]; +const TARGET_NAME = 'inline'; +const BIDDER_CODE = 'flipp'; +const ENDPOINT = 'https://gateflipp.flippback.com/flyer-locator-service/client_bidding'; +const DEFAULT_TTL = 30; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_CREATIVE_TYPE = 'NativeX'; +const VALID_CREATIVE_TYPES = ['DTX', 'NativeX']; +const FLIPP_USER_KEY = 'flipp-uid'; +const COMPACT_DEFAULT_HEIGHT = 600; + +let userKey = null; +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); + +export function getUserKey(options = {}) { + if (userKey) { + return userKey; + } + + // If the partner provides the user key use it, otherwise fallback to cookies + if (options.userKey && isValidUserKey(options.userKey)) { + userKey = options.userKey; + return options.userKey; + } + // Grab from Cookie + const foundUserKey = storage.cookiesAreEnabled() && storage.getCookie(FLIPP_USER_KEY); + if (foundUserKey) { + return foundUserKey; + } + + // Generate if none found + userKey = generateUUID(); + + // Set cookie + if (storage.cookiesAreEnabled()) { + storage.setCookie(FLIPP_USER_KEY, userKey); + } + + return userKey; +} + +function isValidUserKey(userKey) { + return !userKey.startsWith('#'); +} + +const generateUUID = () => { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { + const r = (Math.random() * 16) | 0; + const v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +}; + +/** + * Determines if a creativeType is valid + * + * @param {string} creativeType The Creative Type to validate. + * @return string creativeType if this is a valid Creative Type, and 'NativeX' otherwise. + */ +const validateCreativeType = (creativeType) => { + if (creativeType && VALID_CREATIVE_TYPES.includes(creativeType)) { + return creativeType; + } else { + return DEFAULT_CREATIVE_TYPE; + } +}; + +const getAdTypes = (creativeType) => { + if (creativeType === 'DTX') { + return DTX_TYPES; + } + return AD_TYPES; +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.siteId) && !!(bid.params.publisherNameIdentifier); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {BidRequest[]} validBidRequests[] an array of bids + * @param {BidderRequest} bidderRequest master bidRequest object + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const urlParams = parseUrl(bidderRequest.refererInfo.page).search; + const contentCode = urlParams['flipp-content-code']; + const userKey = getUserKey(validBidRequests[0]?.params); + const placements = validBidRequests.map((bid, index) => { + const options = bid.params.options || {}; + if (!options.hasOwnProperty('startCompact')) { + options.startCompact = true; + } + return { + divName: TARGET_NAME, + networkId: NETWORK_ID, + siteId: bid.params.siteId, + adTypes: getAdTypes(bid.params.creativeType), + count: 1, + ...(!isEmpty(bid.params.zoneIds) && {zoneIds: bid.params.zoneIds}), + properties: { + ...(!isEmpty(contentCode) && {contentCode: contentCode.slice(0, 32)}), + }, + options, + prebid: { + requestId: bid.bidId, + publisherNameIdentifier: bid.params.publisherNameIdentifier, + height: bid.mediaTypes.banner.sizes[index][0], + width: bid.mediaTypes.banner.sizes[index][1], + creativeType: validateCreativeType(bid.params.creativeType), + } + } + }); + return { + method: 'POST', + url: ENDPOINT, + data: { + placements, + url: bidderRequest.refererInfo.page, + user: { + key: userKey, + }, + }, + } + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @param {BidRequest} bidRequest A bid request object + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + if (!serverResponse?.body) return []; + const placements = bidRequest.data.placements; + const res = serverResponse.body; + if (!isEmpty(res) && !isEmpty(res.decisions) && !isEmpty(res.decisions.inline)) { + return res.decisions.inline.map(decision => { + const placement = placements.find(p => p.prebid.requestId === decision.prebid?.requestId); + const height = placement.options?.startCompact ? COMPACT_DEFAULT_HEIGHT : decision.height; + return { + bidderCode: BIDDER_CODE, + requestId: decision.prebid?.requestId, + cpm: decision.prebid?.cpm, + width: decision.width, + height, + creativeId: decision.adId, + currency: DEFAULT_CURRENCY, + netRevenue: true, + ttl: DEFAULT_TTL, + ad: decision.prebid?.creative, + } + }); + } + return []; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: (syncOptions, serverResponses) => [], +} +registerBidder(spec); diff --git a/modules/flippBidAdapter.md b/modules/flippBidAdapter.md new file mode 100644 index 00000000000..810b883e3f9 --- /dev/null +++ b/modules/flippBidAdapter.md @@ -0,0 +1,44 @@ +# Overview + +``` +Module Name: Flipp Bid Adapter +Module Type: Bidder Adapter +Maintainer: prebid@flipp.com +``` + +# Description + +This module connects publishers to Flipp's Shopper Experience via Prebid.js. + + +# Test parameters + +```javascript +var adUnits = [ + { + code: 'flipp-scroll-ad-content', + mediaTypes: { + banner: { + sizes: [ + [300, 600] + ] + } + }, + bids: [ + { + bidder: 'flipp', + params: { + creativeType: 'NativeX', // Optional, can be one of 'NativeX' (default) or 'DTX' + publisherNameIdentifier: 'wishabi-test-publisher', // Required + siteId: 1192075, // Required + zoneIds: [260678], // Optional + userKey: "", // Optional + options: { + startCompact: true // Optional, default to true + } + } + } + ] + } +] +``` diff --git a/modules/flocIdSystem.js b/modules/flocIdSystem.js deleted file mode 100644 index 0cff7e86d73..00000000000 --- a/modules/flocIdSystem.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * This module adds flocId to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/flocId - * @requires module:modules/userId - */ - -import { logInfo, logError } from '../src/utils.js'; -import {submodule} from '../src/hook.js' - -const MODULE_NAME = 'flocId'; - -/** - * Add meta tag to support enabling of floc origin trial - * @function - * @param {string} token - configured token for origin-trial - */ -function enableOriginTrial(token) { - const tokenElement = document.createElement('meta'); - tokenElement.httpEquiv = 'origin-trial'; - tokenElement.content = token; - document.head.appendChild(tokenElement); -} - -/** - * Get the interest cohort. - * @param successCallback - * @param errorCallback - */ -function getFlocData(successCallback, errorCallback) { - document.interestCohort() - .then((data) => { - successCallback(data); - }).catch((error) => { - errorCallback(error); - }); -} - -/** - * Encode the id - * @param value - * @returns {string|*} - */ -function encodeId(value) { - const result = {}; - if (value) { - result.flocId = value; - logInfo('Decoded value ' + JSON.stringify(result)); - return result; - } - return undefined; -} - -/** @type {Submodule} */ -export const flocIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: MODULE_NAME, - - /** - * decode the stored id value for passing to bid requests - * @function - * @param {string} value - * @returns {{flocId:{ id: string }} or undefined if value doesn't exists - */ - decode(value) { - return (value) ? encodeId(value) : undefined; - }, - /** - * If chrome and cohort enabled performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleConfig} [config] - * @returns {IdResponse|undefined} - */ - getId(config) { - // Block usage of storage of cohort ID - const checkStorage = (config && config.storage); - if (checkStorage) { - logError('User ID - flocId submodule storage should not defined'); - return; - } - // Validate feature is enabled - const isFlocEnabled = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime) && !!document.featurePolicy && !!document.featurePolicy.features() && document.featurePolicy.features().includes('interest-cohort'); - - if (isFlocEnabled) { - const configParams = (config && config.params) || {}; - if (configParams && (typeof configParams.token === 'string')) { - // Insert meta-tag with token from configuration - enableOriginTrial(configParams.token); - } - // Example expected output { "id": "14159", "version": "chrome.1.0" } - let returnCallback = (cb) => { - getFlocData((data) => { - returnCallback = () => { return data; } - logInfo('Cohort id: ' + JSON.stringify(data)); - cb(data); - }, (err) => { - logInfo(err); - cb(undefined); - }); - }; - - return {callback: returnCallback}; - } - } -}; - -submodule('userId', flocIdSubmodule); diff --git a/modules/flocIdSystem.md b/modules/flocIdSystem.md deleted file mode 100644 index 07184700a14..00000000000 --- a/modules/flocIdSystem.md +++ /dev/null @@ -1,34 +0,0 @@ -## FloC ID User ID Submodule - -### Building Prebid with Floc Id Support -Your Prebid build must include the modules for both **userId** and **flocIdSystem** submodule. Follow the build instructions for Prebid as -explained in the top level README.md file of the Prebid source tree. - -ex: $ gulp build --modules=userId,flocIdSystem - -### Prebid Params - -Individual params may be set for the FloC ID User ID Submodule. -``` -pbjs.setConfig({ - userSync: { - userIds: [{ - name: 'flocId', - params: { - token: "Registered token or default sharedid.org token" - } - }] - } -}); -``` - -### Parameter Descriptions for the `userSync` Configuration Section -The below parameters apply only to the FloC ID User ID Module integration. - -| Params under usersync.userIds[]| Scope | Type | Description | Example | -| --- | --- | --- | --- | --- | -| name | Required | String | ID value for the Floc ID module - `"flocId"` | `"flocId"` | -| params | Optional | Object | Details for flocId syncing. | | -| params.token | Optional | Object | Publisher registered token.To get new token, register https://developer.chrome.com/origintrials/#/trials/active for Federated Learning of Cohorts. Default sharedid.org token: token: "A3dHTSoNUMjjERBLlrvJSelNnwWUCwVQhZ5tNQ+sll7y+LkPPVZXtB77u2y7CweRIxiYaGwGXNlW1/dFp8VMEgIAAAB+eyJvcmlnaW4iOiJodHRwczovL3NoYXJlZGlkLm9yZzo0NDMiLCJmZWF0dXJlIjoiSW50ZXJlc3RDb2hvcnRBUEkiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"| token: "A3dHTSoNUMjjERBLlrvJSelNnwWUCwVQhZ5tNQ+sll7y+LkPPVZXtB77u2y7CweRIxiYaGwGXNlW1/dFp8VMEgIAAAB+eyJvcmlnaW4iOiJodHRwczovL3NoYXJlZGlkLm9yZzo0NDMiLCJmZWF0dXJlIjoiSW50ZXJlc3RDb2hvcnRBUEkiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9" - | -| storage | Not Allowed | Object | Will ask browser for cohort everytime. Setting storage will fail id lookup || diff --git a/modules/fluctBidAdapter.js b/modules/fluctBidAdapter.js index 44b9f3bf217..b566769c00e 100644 --- a/modules/fluctBidAdapter.js +++ b/modules/fluctBidAdapter.js @@ -1,4 +1,5 @@ -import { _each, isEmpty } from '../src/utils.js'; +import { _each, deepSetValue, isEmpty } from '../src/utils.js'; +import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'fluct'; @@ -7,16 +8,6 @@ const VERSION = '1.2'; const NET_REVENUE = true; const TTL = 300; -/** - * See modules/userId/eids.js for supported sources - */ -const SUPPORTED_USER_ID_SOURCES = [ - 'adserver.org', - 'criteo.com', - 'intimatemerger.com', - 'liveramp.com', -]; - export const spec = { code: BIDDER_CODE, aliases: ['adingo'], @@ -35,23 +26,47 @@ export const spec = { * Make a server request from the list of BidRequests. * * @param {validBidRequests[]} - an array of bids. + * @param {bidderRequest} bidderRequest bidder request object. * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { const serverRequests = []; - const referer = bidderRequest.refererInfo.referer; + const page = bidderRequest.refererInfo.page; _each(validBidRequests, (request) => { + const impExt = request.ortb2Imp?.ext; const data = Object(); - data.referer = referer; + data.page = page; data.adUnitCode = request.adUnitCode; data.bidId = request.bidId; - data.transactionId = request.transactionId; data.user = { - eids: (request.userIdAsEids || []).filter((eid) => SUPPORTED_USER_ID_SOURCES.indexOf(eid.source) !== -1) + data: bidderRequest.ortb2?.user?.data ?? [], + eids: [ + ...(request.userIdAsEids ?? []), + ...(bidderRequest.ortb2?.user?.ext?.eids ?? []), + ], }; + if (impExt) { + data.transactionId = impExt.tid; + data.gpid = impExt.gpid ?? impExt.data?.pbadslot ?? impExt.data?.adserver?.adslot; + } + if (bidderRequest.gdprConsent) { + deepSetValue(data, 'regs.gdpr', { + consent: bidderRequest.gdprConsent.consentString, + gdprApplies: bidderRequest.gdprConsent.gdprApplies ? 1 : 0, + }); + } + if (bidderRequest.uspConsent) { + deepSetValue(data, 'regs.us_privacy', { + consent: bidderRequest.uspConsent, + }); + } + if (config.getConfig('coppa') === true) { + deepSetValue(data, 'regs.coppa', 1); + } + data.sizes = []; _each(request.sizes, (size) => { data.sizes.push({ @@ -61,6 +76,11 @@ export const spec = { }); data.params = request.params; + + if (request.schain) { + data.schain = request.schain; + } + const searchParams = new URLSearchParams({ dfpUnitCode: request.params.dfpUnitCode, tagId: request.params.tagId, @@ -104,7 +124,6 @@ export const spec = { `(function() { var img = new Image(); img.src = "${beaconUrl}"})()` + ``; let data = { - bidderCode: BIDDER_CODE, requestId: res.id, currency: res.cur, cpm: parseFloat(bid.price) || 0, @@ -135,8 +154,22 @@ export const spec = { * */ getUserSyncs: (syncOptions, serverResponses) => { - return []; - }, + // gdpr, us_privacy, and coppa params to be handled on the server end. + const usersyncs = serverResponses.reduce((acc, serverResponse) => [ + ...acc, + ...(serverResponse.body.usersyncs ?? []), + ], []); + const syncs = usersyncs.filter( + (sync) => ( + (sync['type'] === 'image' && syncOptions.pixelEnabled) || + (sync['type'] === 'iframe' && syncOptions.iframeEnabled) + ) + ).map((sync) => ({ + type: sync.type, + url: sync.url, + })); + return syncs; + } }; registerBidder(spec); diff --git a/modules/fpdModule/index.js b/modules/fpdModule/index.js index 427547a4e4d..0b0c0906f84 100644 --- a/modules/fpdModule/index.js +++ b/modules/fpdModule/index.js @@ -4,55 +4,50 @@ */ import { config } from '../../src/config.js'; import { module, getHook } from '../../src/hook.js'; -import { getGlobal } from '../../src/prebidGlobal.js'; -import { addBidderRequests } from '../../src/auction.js'; +import {logError} from '../../src/utils.js'; +import {GreedyPromise} from '../../src/utils/promise.js'; +import {timedAuctionHook} from '../../src/utils/perfMetrics.js'; let submodules = []; -/** - * enable submodule in User ID - * @param {RtdSubmodule} submodule - */ export function registerSubmodules(submodule) { submodules.push(submodule); } -export function init() { - let modConf = config.getConfig('firstPartyData') || {}; - let ortb2 = config.getConfig('ortb2') || {}; +export function reset() { + submodules.length = 0; +} +export function processFpd({global = {}, bidder = {}} = {}) { + let modConf = config.getConfig('firstPartyData') || {}; + let result = GreedyPromise.resolve({global, bidder}); submodules.sort((a, b) => { return ((a.queue || 1) - (b.queue || 1)); }).forEach(submodule => { - ortb2 = submodule.init(modConf, ortb2); + result = result.then( + ({global, bidder}) => GreedyPromise.resolve(submodule.processFpd(modConf, {global, bidder})) + .catch((err) => { + logError(`Error in FPD module ${submodule.name}`, err); + return {}; + }) + .then((result) => ({global: result.global || global, bidder: result.bidder || bidder})) + ); }); - - config.setConfig({ortb2}); + return result; } -/** - * BidderRequests hook to intiate module and reset modules ortb2 data object - */ -function addBidderRequestHook(fn, bidderRequests) { - init(); - fn.call(this, bidderRequests); - // Removes hook after run - addBidderRequests.getHooks({ hook: addBidderRequestHook }).remove(); -} +export const startAuctionHook = timedAuctionHook('fpd', function startAuctionHook(fn, req) { + processFpd(req.ortb2Fragments).then((ortb2Fragments) => { + Object.assign(req.ortb2Fragments, ortb2Fragments); + fn.call(this, req); + }) +}); -/** - * Sets bidderRequests hook - */ function setupHook() { - getHook('addBidderRequests').before(addBidderRequestHook); + getHook('startAuction').before(startAuctionHook, 10); } module('firstPartyData', registerSubmodules); // Runs setupHook on initial load setupHook(); - -/** - * Global function to reinitiate module - */ -(getGlobal()).refreshFpd = setupHook; diff --git a/modules/fpdModule/index.md b/modules/fpdModule/index.md index 638c966883a..238881db96b 100644 --- a/modules/fpdModule/index.md +++ b/modules/fpdModule/index.md @@ -16,9 +16,11 @@ Validation Submodule: - verify that certain OpenRTB attributes are not specified - optionally suppress user FPD based on the existence of _pubcid_optout +Topic Submodule: +- populate first party/third party topics data onto user.data in bid stream. 1. Module initializes on first load and set bidRequestHook -2. When hook runs, corresponding submodule init functions are run to perform enrichments/validations dependant on submodule +2. When hook runs, corresponding submodule init functions are run to perform enrichments/validations/topics dependant on submodule 3. After hook complete, it is disabled - meaning module only runs on first auction 4. To reinitiate the module, run pbjs.refreshFPD(), which allows module to rerun as if initial load @@ -43,4 +45,5 @@ pbjs.setConfig({ At least one of the submodules must be included in order to successfully run the corresponding above operations. enrichmentFpdModule -validationFpdModule \ No newline at end of file +validationFpdModule +topicsFpdModule \ No newline at end of file diff --git a/modules/freepassBidAdapter.js b/modules/freepassBidAdapter.js new file mode 100644 index 00000000000..cdcc3c6a4b0 --- /dev/null +++ b/modules/freepassBidAdapter.js @@ -0,0 +1,117 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {logMessage} from '../src/utils.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {ortbConverter} from '../libraries/ortbConverter/converter.js' + +const BIDDER_SERVICE_URL = 'https://bidding-dsp.ad-m.asia/dsp/api/bid/s/s/freepass'; + +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 30 + } +}); + +function prepareUserInfo(user, freepassId) { + let userInfo = user || {}; + let extendedUserInfo = userInfo.ext || {}; + + if (freepassId.userId) { + userInfo.id = freepassId.userId; + } + + if (freepassId.commonId) { + extendedUserInfo.fuid = freepassId.commonId; + } + userInfo.ext = extendedUserInfo; + + return userInfo; +} + +function prepareDeviceInfo(device, freepassId) { + let deviceInfo = device || {}; + let extendedDeviceInfo = deviceInfo.ext || {}; + + extendedDeviceInfo.is_accurate_ip = 0; + if (freepassId.userIp) { + deviceInfo.ip = freepassId.userIp; + extendedDeviceInfo.is_accurate_ip = 1; + } + deviceInfo.ext = extendedDeviceInfo; + + return deviceInfo; +} + +export const spec = { + code: 'freepass', + supportedMediaTypes: [BANNER], + + isBidRequestValid(bid) { + logMessage('Validating bid: ', bid); + return !(!bid.adUnitCode || !bid.params || !bid.params.publisherId); + }, + + buildRequests(validBidRequests, bidderRequest) { + if (validBidRequests.length === 0) { + logMessage('FreePass BidAdapter has no valid bid requests'); + return []; + } + + logMessage('FreePass BidAdapter is preparing bid request: ', validBidRequests); + logMessage('FreePass BidAdapter is using bidder request: ', bidderRequest); + + const data = converter.toORTB({ + bidderRequest: bidderRequest, + bidRequests: validBidRequests, + context: { mediaType: BANNER } + }); + logMessage('FreePass BidAdapter interpreted ORTB bid request as ', data); + + // Only freepassId is supported + let freepassId = (validBidRequests[0].userId && validBidRequests[0].userId.freepassId) || {}; + data.user = prepareUserInfo(data.user, freepassId); + data.device = prepareDeviceInfo(data.device, freepassId); + + // set site.page & site.publisher + data.site = data.site || {}; + data.site.publisher = data.site.publisher || {}; + // set site.publisher.id. from params.publisherId required + data.site.publisher.id = validBidRequests[0].params.publisherId; + // set site.publisher.domain from params.publisherUrl. optional + data.site.publisher.domain = validBidRequests[0].params?.publisherUrl; + + // set source + data.source = data.source || {}; + data.source.fd = 0; + data.source.tid = validBidRequests.ortb2?.source?.tid; + data.source.pchain = ''; + + // set imp.ext + validBidRequests.forEach((bidRequest, index) => { + data.imp[index].tagId = bidRequest.adUnitCode; + }); + + data.test = validBidRequests[0].test || 0; + + logMessage('FreePass BidAdapter augmented ORTB bid request user: ', data.user); + logMessage('FreePass BidAdapter augmented ORTB bid request device: ', data.device); + + return { + method: 'POST', + url: BIDDER_SERVICE_URL, + data, + options: { withCredentials: false } + }; + }, + + interpretResponse(serverResponse, bidRequest) { + logMessage('FreePass BidAdapter is interpreting server response: ', serverResponse); + logMessage('FreePass BidAdapter is using bid request: ', bidRequest); + const bids = converter.fromORTB({response: serverResponse.body, request: bidRequest.data}).bids; + logMessage('FreePass BidAdapter interpreted ORTB bids as ', bids); + + return bids; + }, +}; + +registerBidder(spec); diff --git a/modules/freepassBidAdapter.md b/modules/freepassBidAdapter.md new file mode 100644 index 00000000000..7b56a469583 --- /dev/null +++ b/modules/freepassBidAdapter.md @@ -0,0 +1,34 @@ +# Overview + +``` +Module Name: FreePass Bidder Adapter +Module Type: Bidder Adapter +Maintainer: fp-hbidding@freebit.net +``` + +# Description + +Connects to FreePass service for bids. Only BANNER is currently supported. + +This BidAdapter requires the FreePass IdSystem to be configured. Please contact FreePass for proper setup. + +# Test Parameters +```javascript + let adUnits = [ + { + code: 'ad-banner-1', // ad slot HTML element ID + mediaTypes: { + banner: { + sizes: [[1024, 1024]] + } + }, + bids: [{ + bidder: 'freepass', + params: { + publisherId: '12345' + } + }] + } + ]; +``` + diff --git a/modules/freepassIdSystem.js b/modules/freepassIdSystem.js new file mode 100644 index 00000000000..419aa9ec414 --- /dev/null +++ b/modules/freepassIdSystem.js @@ -0,0 +1,65 @@ +import { submodule } from '../src/hook.js'; +import { logMessage } from '../src/utils.js'; +import { getCoreStorageManager } from '../src/storageManager.js'; + +const MODULE_NAME = 'freepassId'; + +export const FREEPASS_COOKIE_KEY = '_f_UF8cCRlr'; +export const storage = getCoreStorageManager(MODULE_NAME); + +export const freepassIdSubmodule = { + name: MODULE_NAME, + decode: function (value, config) { + logMessage('Decoding FreePass ID: ', value); + + return { [MODULE_NAME]: value }; + }, + + getId: function (config, consent, cachedIdObject) { + logMessage('Getting FreePass ID using config: ' + JSON.stringify(config)); + + const freepassData = config.params !== undefined ? (config.params.freepassData || {}) : {} + const idObject = {}; + + const userId = storage.getCookie(FREEPASS_COOKIE_KEY); + if (userId !== null) { + idObject.userId = userId; + } + + if (freepassData.commonId !== undefined) { + idObject.commonId = config.params.freepassData.commonId; + } + + if (freepassData.userIp !== undefined) { + idObject.userIp = config.params.freepassData.userIp; + } + + return {id: idObject}; + }, + + extendId: function (config, consent, cachedIdObject) { + const freepassData = config.params.freepassData; + const hasFreepassData = freepassData !== undefined; + if (!hasFreepassData) { + logMessage('No Freepass Data. CachedIdObject will not be extended: ' + JSON.stringify(cachedIdObject)); + return { + id: cachedIdObject + }; + } + + const currentCookieId = storage.getCookie(FREEPASS_COOKIE_KEY); + + logMessage('Extending FreePass ID object: ' + JSON.stringify(cachedIdObject)); + logMessage('Extending FreePass ID using config: ' + JSON.stringify(config)); + + return { + id: { + commonId: freepassData.commonId, + userIp: freepassData.userIp, + userId: currentCookieId + } + }; + } +}; + +submodule('userId', freepassIdSubmodule); diff --git a/modules/freepassIdSystem.md b/modules/freepassIdSystem.md new file mode 100644 index 00000000000..d2b8ee236e1 --- /dev/null +++ b/modules/freepassIdSystem.md @@ -0,0 +1,47 @@ +## FreePass User ID Submodule + +[FreePass](https://freepass-login.com/introduction.html) is a common authentication service operated by Freebit Co., Ltd. Users with a FreePass account do not need to create a new account to use partner services. + +# General Information + +Please contact FreePass before using this ID. + +``` +Module Name: FreePass Id System +Module Type: User Id System +Maintainer: fp-hbidding@freebit.net +``` + +## Building Prebid with FreePass ID Support + +First, make sure to add the FreePass ID submodule to your Prebid.js package with: + +```shell +gulp build --modules=freepassIdSystem,userId +``` + +The following configuration parameters are available: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'freepassId', + params: { + freepassData: { + commonId: 'fpcommonid123', + userIp: '127.0.0.1' + } + } + }] + } +}); +``` + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +|--------------------------------|----------|--------|------------------------------------------------------|----------------| +| name | Required | String | The name of this module | `"freepassId"` | +| freepassData | Optional | Object | FreePass data | `{}` | +| freepassData.commonId | Optional | String | Common ID obtained from FreePass | `"abcd1234"` | +| freepassData.userIp | Optional | String | User IP obtained in cooperation with partner service | `"127.0.0.1"` | + diff --git a/modules/freewheel-sspBidAdapter.js b/modules/freewheel-sspBidAdapter.js index eca31dd5a95..cd4785cdc78 100644 --- a/modules/freewheel-sspBidAdapter.js +++ b/modules/freewheel-sspBidAdapter.js @@ -1,6 +1,7 @@ -import { logWarn, isArray } from '../src/utils.js'; +import { logWarn, isArray, isFn, deepAccess, formatQS } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'freewheel-ssp'; @@ -78,6 +79,39 @@ function getPricing(xmlNode) { return princingData; } +/* +* Read the StickyBrand extension with this format: +* +* +* +* +* +* +* @return {object} pricing data in format: {currency: "EUR", price:"1.000"} +*/ +function getAdvertiserDomain(xmlNode) { + var domain = []; + var brandExtNode; + var extensions = xmlNode.querySelectorAll('Extension'); + // Nodelist.forEach is not supported in IE and Edge + // Workaround given here https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10638731/ + Array.prototype.forEach.call(extensions, function(node) { + if (node.getAttribute('type') === 'StickyBrand') { + brandExtNode = node; + } + }); + + // Currently we only return one Domain + if (brandExtNode) { + var domainNode = brandExtNode.querySelector('Domain'); + domain.push(domainNode.textContent || domainNode.innerText); + } else { + logWarn('PREBID - ' + BIDDER_CODE + ': No bid received or missing StickyBrand extension.'); + } + + return domain; +} + function hashcode(inputString) { var hash = 0; var char; @@ -180,6 +214,27 @@ function getAPIName(componentId) { return componentId.replace('-', ''); } +function getBidFloor(bid, config) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: getFloorCurrency(config), + mediaType: typeof bid.mediaTypes['banner'] == 'object' ? 'banner' : 'video', + size: '*', + }); + return bidFloor.floor; + } catch (e) { + return -1; + } +} + +function getFloorCurrency(config) { + return config.getConfig('floors.data.currency') != null ? config.getConfig('floors.data.currency') : 'USD'; +} + function formatAdHTML(bid, size) { var integrationType = bid.params.format; @@ -189,7 +244,7 @@ function formatAdHTML(bid, size) { var libUrl = ''; if (integrationType && integrationType !== 'inbanner') { libUrl = PRIMETIME_URL + getComponentId(bid.params.format) + '.min.js'; - script = getOutstreamScript(bid, size); + script = getOutstreamScript(bid); } else { libUrl = MUSTANG_URL; script = getInBannerScript(bid, size); @@ -260,7 +315,7 @@ var getOutstreamScript = function(bid) { export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], - aliases: ['stickyadstv'], // former name for freewheel-ssp + aliases: ['stickyadstv', 'freewheelssp'], // aliases for freewheel-ssp /** * Determines whether or not the given bid request is valid. * @@ -284,13 +339,19 @@ export const spec = { var zone = currentBidRequest.params.zoneId; var timeInMillis = new Date().getTime(); var keyCode = hashcode(zone + '' + timeInMillis); + var bidfloor = getBidFloor(currentBidRequest, config); + var format = currentBidRequest.params.format; + var requestParams = { reqType: 'AdsSetup', - protocolVersion: '2.0', + protocolVersion: '4.2', zoneId: zone, componentId: 'prebid', componentSubId: getComponentId(currentBidRequest.params.format), timestamp: timeInMillis, + _fw_bidfloor: (bidfloor > 0) ? bidfloor : 0, + _fw_bidfloorcur: (bidfloor > 0) ? getFloorCurrency(config) : '', + pbjs_version: '$prebid.version$', pKey: keyCode }; @@ -312,10 +373,31 @@ export const spec = { requestParams._fw_us_privacy = bidderRequest.uspConsent; } + // Add GPP consent + if (bidderRequest && bidderRequest.gppConsent) { + requestParams.gpp = bidderRequest.gppConsent.gppString; + requestParams.gpp_sid = bidderRequest.gppConsent.applicableSections; + } else if (bidderRequest && bidderRequest.ortb2 && bidderRequest.ortb2.regs && bidderRequest.ortb2.regs.gpp) { + requestParams.gpp = bidderRequest.ortb2.regs.gpp; + requestParams.gpp_sid = bidderRequest.ortb2.regs.gpp_sid; + } + // Add schain object var schain = currentBidRequest.schain; if (schain) { - requestParams.schain = schain; + try { + requestParams.schain = JSON.stringify(schain); + } catch (error) { + logWarn('PREBID - ' + BIDDER_CODE + ': Unable to stringify the schain: ' + error); + } + } + + if (currentBidRequest.userIdAsEids && currentBidRequest.userIdAsEids.length > 0) { + try { + requestParams._fw_prebid_3p_UID = JSON.stringify(currentBidRequest.userIdAsEids); + } catch (error) { + logWarn('PREBID - ' + BIDDER_CODE + ': Unable to stringify the userIdAsEids: ' + error); + } } var vastParams = currentBidRequest.params.vastUrlParams; @@ -327,7 +409,7 @@ export const spec = { } } - var location = (bidderRequest && bidderRequest.refererInfo) ? bidderRequest.refererInfo.referer : getTopMostWindow().location.href; + var location = bidderRequest?.refererInfo?.page; if (isValidUrl(location)) { requestParams.loc = location; } @@ -352,6 +434,21 @@ export const spec = { requestParams.playerSize = playerSize[0] + 'x' + playerSize[1]; } + // Add video context and placement in requestParams + if (currentBidRequest.mediaTypes.video) { + var videoContext = currentBidRequest.mediaTypes.video.context ? currentBidRequest.mediaTypes.video.context : ''; + var videoPlacement = currentBidRequest.mediaTypes.video.placement ? currentBidRequest.mediaTypes.video.placement : null; + var videoPlcmt = currentBidRequest.mediaTypes.video.plcmt ? currentBidRequest.mediaTypes.video.plcmt : null; + + if (format == 'inbanner') { + videoPlacement = 2; + videoContext = 'In-Banner'; + } + requestParams.video_context = videoContext; + requestParams.video_placement = videoPlacement; + requestParams.video_plcmt = videoPlcmt; + } + return { method: 'GET', url: FREEWHEEL_ADSSETUP, @@ -409,6 +506,8 @@ export const spec = { const campaignId = getCampaignId(xmlDoc); const bannerId = getBannerId(xmlDoc); const topWin = getTopMostWindow(); + const advertiserDomains = getAdvertiserDomain(xmlDoc); + if (!topWin.freewheelssp_cache) { topWin.freewheelssp_cache = {}; } @@ -426,7 +525,7 @@ export const spec = { currency: princingData.currency, netRevenue: true, ttl: 360, - meta: { advertiserDomains: princingData.adomain && isArray(princingData.adomain) ? princingData.adomain : [] }, + meta: { advertiserDomains: advertiserDomains }, dealId: dealId, campaignId: campaignId, bannerId: bannerId @@ -444,24 +543,46 @@ export const spec = { return bidResponses; }, - getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy) { - var gdprParams = ''; + getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy, gppConsent) { + const params = {}; + if (gdprConsent) { if (typeof gdprConsent.gdprApplies === 'boolean') { - gdprParams = `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + params.gdpr = Number(gdprConsent.gdprApplies); + params.gdpr_consent = gdprConsent.consentString; } else { - gdprParams = `?gdpr_consent=${gdprConsent.consentString}`; + params.gdpr_consent = gdprConsent.consentString; } } + if (gppConsent) { + if (typeof gppConsent.gppString === 'string') { + params.gpp = gppConsent.gppString; + } + if (gppConsent.applicableSections) { + params.gpp_sid = gppConsent.applicableSections; + } + } + + var queryString = ''; + if (params) { + queryString = '?' + `${formatQS(params)}`; + } + + const syncs = []; if (syncOptions && syncOptions.pixelEnabled) { - return [{ + syncs.push({ type: 'image', - url: USER_SYNC_URL + gdprParams - }]; - } else { - return []; + url: USER_SYNC_URL + queryString + }); + } else if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: USER_SYNC_URL + queryString + }); } + + return syncs; }, }; diff --git a/modules/freewheel-sspBidAdapter.md b/modules/freewheel-sspBidAdapter.md index 0086aac6567..a445280f2b0 100644 --- a/modules/freewheel-sspBidAdapter.md +++ b/modules/freewheel-sspBidAdapter.md @@ -22,7 +22,7 @@ Module that connects to Freewheel ssp's demand sources bids: [ { - bidder: "freewheel-ssp", + bidder: "freewheelssp", // or use alias "freewheel-ssp" params: { zoneId : '277225' } diff --git a/modules/ftrackIdSystem.js b/modules/ftrackIdSystem.js index c570e69e1d3..809f1311c42 100644 --- a/modules/ftrackIdSystem.js +++ b/modules/ftrackIdSystem.js @@ -6,19 +6,19 @@ */ import * as utils from '../src/utils.js'; -import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { uspDataHandler } from '../src/adapterManager.js'; +import {submodule} from '../src/hook.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {uspDataHandler} from '../src/adapterManager.js'; +import {loadExternalScript} from '../src/adloader.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'ftrackId'; const LOG_PREFIX = 'FTRACK - '; const LOCAL_STORAGE_EXP_DAYS = 30; -const VENDOR_ID = null; const LOCAL_STORAGE = 'html5'; const FTRACK_STORAGE_NAME = 'ftrackId'; const FTRACK_PRIVACY_STORAGE_NAME = `${FTRACK_STORAGE_NAME}_privacy`; -const FTRACK_URL = 'https://d9.flashtalking.com/d9core'; -const storage = getStorageManager({gvlid: VENDOR_ID, moduleName: MODULE_NAME}); +const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); let consentInfo = { gdpr: { @@ -48,9 +48,39 @@ export const ftrackIdSubmodule = { * similar to the module name and ending in id or Id */ decode (value, config) { - return { - ftrackId: value + if (!value) { + return; }; + + const DECODE_RESPONSE = { + ftrackId: { + uid: '', + ext: {} + } + } + + // Loop over the value's properties: + // -- if string, assign value as is. + // -- if array, convert to string then assign value. + // -- If neither type, assign value as empty string + for (var key in value) { + let keyValue = value[key]; + if (Array.isArray(keyValue)) { + keyValue = keyValue.join('|'); + } else if (typeof value[key] !== 'string') { + // Unexpected value type, should be string or array + keyValue = ''; + } + + DECODE_RESPONSE.ftrackId.ext[key] = keyValue; + } + + // If we have DeviceId value, assign it to the uid property + if (DECODE_RESPONSE.ftrackId.ext.hasOwnProperty('DeviceID')) { + DECODE_RESPONSE.ftrackId.uid = DECODE_RESPONSE.ftrackId.ext.DeviceID; + } + + return DECODE_RESPONSE; }, /** @@ -60,21 +90,19 @@ export const ftrackIdSubmodule = { * @param {SubmoduleConfig} config * @param {ConsentData} consentData * @param {(Object|undefined)} cacheIdObj - * @returns {IdResponse|undefined} + * @returns {IdResponse|undefined} A response object that contains id and/or callback. */ getId (config, consentData, cacheIdObj) { if (this.isConfigOk(config) === false || this.isThereConsent(consentData) === false) return undefined; return { - callback: function () { + callback: function (cb) { window.D9v = { UserID: '99999999999999', CampID: '3175', CCampID: '148556' }; window.D9r = { - DeviceID: true, - SingleDeviceID: true, callback: function(response) { if (response) { storage.setDataInLocalStorage(`${FTRACK_STORAGE_NAME}_exp`, (new Date(Date.now() + (1000 * 60 * 60 * 24 * LOCAL_STORAGE_EXP_DAYS))).toUTCString()); @@ -84,15 +112,30 @@ export const ftrackIdSubmodule = { storage.setDataInLocalStorage(`${FTRACK_PRIVACY_STORAGE_NAME}`, JSON.stringify(consentInfo)); }; + if (typeof cb === 'function') cb(response); + return response; } }; - if (config.params && config.params.url && config.params.url === FTRACK_URL) { - var ftrackScript = document.createElement('script'); - ftrackScript.setAttribute('src', config.params.url); - window.document.body.appendChild(ftrackScript); + // If config.params.ids does not exist, set defaults + if (!config.params.hasOwnProperty('ids')) { + window.D9r.DeviceID = true; + window.D9r.SingleDeviceID = true; + } else { + if (config.params.ids.hasOwnProperty('device id') && config.params.ids['device id'] === true) { + window.D9r.DeviceID = true; + } + if (config.params.ids.hasOwnProperty('single device id') && config.params.ids['single device id'] === true) { + window.D9r.SingleDeviceID = true; + } + if (config.params.ids.hasOwnProperty('household id') && config.params.ids['household id'] === true) { + window.D9r.HHID = true; + } } + + // Creates an async script element and appends it to the document + loadExternalScript(config.params.url, MODULE_NAME); } }; }, @@ -132,8 +175,8 @@ export const ftrackIdSubmodule = { utils.logWarn(LOG_PREFIX + 'config.storage.name recommended to be "' + FTRACK_STORAGE_NAME + '".'); } - if (!config.hasOwnProperty('params') || !config.params.hasOwnProperty('url') || config.params.url !== FTRACK_URL) { - utils.logWarn(LOG_PREFIX + 'config.params.url is required for ftrack to run. Url should be "' + FTRACK_URL + '".'); + if (!config.hasOwnProperty('params') || !config.params.hasOwnProperty('url')) { + utils.logWarn(LOG_PREFIX + 'config.params.url is required for ftrack to run.'); return false; } @@ -178,6 +221,22 @@ export const ftrackIdSubmodule = { if (usPrivacyVersion == 1 && usPrivacyOptOutSale === 'Y') consentValue = false; return consentValue; + }, + eids: { + 'ftrackId': { + source: 'flashtalking.com', + atype: 1, + getValue: function(data) { + let value = ''; + if (data && data.ext && data.ext.DeviceID) { + value = data.ext.DeviceID; + } + return value; + }, + getUidExt: function(data) { + return data && data.ext; + } + }, } }; diff --git a/modules/ftrackIdSystem.md b/modules/ftrackIdSystem.md index c5f255c2fc2..24a8dbd08b6 100644 --- a/modules/ftrackIdSystem.md +++ b/modules/ftrackIdSystem.md @@ -30,7 +30,12 @@ pbjs.setConfig({ userIds: [{ name: 'FTrack', params: { - url: 'https://d9.flashtalking.com/d9core' // required, if not populated ftrack will not run + url: 'https://d9.flashtalking.com/d9core', // required, if not populated ftrack will not run + ids: { + 'device id': true, + 'single device id': true, + 'household id': true + } }, storage: { type: 'html5', // "html5" is the required storage type @@ -47,6 +52,12 @@ pbjs.setConfig({ | Param under userSync.userIds[] | Scope | Type | Description | Example | | :-- | :-- | :-- | :-- | :-- | | name | Required | String | The name of this module: `"FTrack"` | `"FTrack"` | +| params | Required | Object | The IDs available, if not populated then the defaults "Device ID" and "Single Device ID" will be returned | | +| params.url | Required | String | The URL for the ftrack library reference. If not populate, ftrack will not run. | 'https://d9.flashtalking.com/d9core' | +| params.ids | Optional | Object | The ftrack IDs available, if not populated then the defaults "Device ID" and "Single Device ID" will be returned | | +| params.ids['device id'] | Optional | Boolean | Should ftrack return "device id". Set to `true` to return it. If set to `undefined` or `false`, ftrack will not return "device id". Default is `false` | `true` | +| params.ids['single device id'] | Optional | Boolean | Should ftrack return "single device id". Set to `true` to return it. If set to `undefined` or `false`, ftrack will not return "single device id". Default is `false` | `true` | +| params.ids['household id'] | Optional; _Requires pairing with either "device id" or "single device id"_ | Boolean | __1.__ Should ftrack return "household id". Set to `true` to attempt to return it. If set to `undefined` or `false`, ftrack will not return "household id". Default is `false`. __2.__ _This will only return "household id" if value of this field is `true` **AND** "household id" is defined on the device._ __3.__ _"household id" requires either "device id" or "single device id" to be also set to `true`, otherwise ftrack will not return "household id"._ | `true` | | storage | Required | Object | Storage settings for how the User ID module will cache the FTrack ID locally | | | storage.type | Required | String | This is where the results of the user ID will be stored. FTrack **requires** `"html5"`. | `"html5"` | | storage.name | Required | String | The name of the local storage where the user ID will be stored. FTrack **requires** `"FTrackId"`. | `"FTrackId"` | @@ -69,4 +80,18 @@ You may request by emailing [mailto:privacy@flashtalking.com](privacy@flashtalki #### GDPR -In its current state, Flashtalking’s FTrack Identity Framework User ID Module does not create an ID if a user's consentData is "truthy" (true, 1). In other words, if GDPR applies in any way to a user, FTrack does not create an ID. \ No newline at end of file +In its current state, Flashtalking’s FTrack Identity Framework User ID Module does not create an ID if a user's consentData is "truthy" (true, 1). In other words, if GDPR applies in any way to a user, FTrack does not create an ID. + +--- + +### If you are using pbjs.getUserIdsAsEids(): + +Please note that the `uids` value is a stringified object of the IDs so publishers will need to `JSON.parse()` the value in order to use it: + +``` +{ + "HHID": [""], + "DeviceID": [""], + "SingleDeviceID": ["USERS SINGLE DEVICE ID"] +} +``` \ No newline at end of file diff --git a/modules/futureads.md b/modules/futureads.md deleted file mode 100644 index 7b1c1d55b7f..00000000000 --- a/modules/futureads.md +++ /dev/null @@ -1,48 +0,0 @@ -# Overview -Module Name: Future Ads Bidder Adapter -Module Type: Bidder Adapter -Maintainer: contact@futureads.io -# Description -Connects to Future Ads demand source to fetch bids. -Banner and Video formats are supported. -Please use ```futureads``` as the bidder code. -# Test Parameters -``` -var adUnits = [ - { - code: 'desktop-banner-ad-div', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: "futureads", - params: { - zone: '2eb6bd58-865c-47ce-af7f-a918108c3fd2' - } - } - ] - },{ - code: 'mobile-banner-ad-div', - sizes: [[300, 50]], // a mobile size - bids: [ - { - bidder: "futureads", - params: { - zone: '62211486-c50b-4356-9f0f-411778d31fcc' - } - } - ] - },{ - code: 'video-ad', - sizes: [[300, 50]], - mediaType: 'video', - bids: [ - { - bidder: "futureads", - params: { - zone: 'ebeb1e79-8cb4-4473-b2d0-2e24b7ff47fd' - } - } - ] - }, -]; -``` diff --git a/modules/fyberBidAdapter.md b/modules/fyberBidAdapter.md deleted file mode 100644 index c394addadfe..00000000000 --- a/modules/fyberBidAdapter.md +++ /dev/null @@ -1,56 +0,0 @@ -# Overview - -``` -Module Name: Fyber Bidder Adapter -Module Type: Bidder Adapter -Maintainer: uri@inner-active.com -``` - -# Description - -Module that connects to Fyber's demand sources - -# Test Parameters -``` -var adUnits = [ -{ -code: 'test-div', -mediaTypes: { -banner: { -sizes: [[300, 250]], // a display rectangle size -} -}, -bids: [ -{ -bidder: 'fyber', - params: { - APP_ID: 'MyCompany_MyApp', - spotType: 'rectangle', - customParams: { - portal: 7002 - } - } -} -] -},{ -code: 'test-div', -mediaTypes: { -banner: { -sizes: [[320, 50]], // a banner size -} -}, -bids: [ -{ -bidder: 'fyber', - params: { - APP_ID: 'MyCompany_MyApp', - spotType: 'banner', - customParams: { - portal: 7001 - } - } -} -] -} -]; -``` diff --git a/modules/gammaBidAdapter.js b/modules/gammaBidAdapter.js index 3e1298b7e23..279eb78812e 100644 --- a/modules/gammaBidAdapter.js +++ b/modules/gammaBidAdapter.js @@ -27,7 +27,7 @@ export const spec = { */ buildRequests: function(bidRequests, bidderRequest) { const serverRequests = []; - const bidderRequestReferer = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || ''; + const bidderRequestReferer = bidderRequest?.refererInfo?.page || ''; for (var i = 0, len = bidRequests.length; i < len; i++) { const gaxObjParams = bidRequests[i]; serverRequests.push({ diff --git a/modules/gamoshiBidAdapter.js b/modules/gamoshiBidAdapter.js index 22a70db0fab..1c279cdb9b8 100644 --- a/modules/gamoshiBidAdapter.js +++ b/modules/gamoshiBidAdapter.js @@ -12,7 +12,6 @@ import { logWarn } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; import {Renderer} from '../src/Renderer.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {includes} from '../src/polyfill.js'; @@ -34,11 +33,6 @@ export const helper = { startsWith: function (str, search) { return str.substr(0, search.length) === search; }, - getTopWindowDomain: function (url) { - const domainStart = url.indexOf('://') + '://'.length; - return url.substring(domainStart, url.indexOf('/', domainStart) < 0 ? url.length : url.indexOf('/', domainStart)); - }, - getMediaType: function (bid) { if (bid.ext) { if (bid.ext.media_type) { @@ -86,17 +80,15 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { - const {adUnitCode, auctionId, mediaTypes, params, sizes, transactionId} = bidRequest; + const {adUnitCode, mediaTypes, params, sizes, bidId} = bidRequest; const baseEndpoint = params['rtbEndpoint'] || ENDPOINTS['gamoshi']; const rtbEndpoint = `${baseEndpoint}/r/${params.supplyPartnerId}/bidr?rformat=open_rtb&reqformat=rtb_json&bidder=prebid` + (params.query ? '&' + params.query : ''); - let url = config.getConfig('pageUrl') || bidderRequest.refererInfo.referer; - const rtbBidRequest = { - id: auctionId, + id: bidderRequest.bidderRequestId, site: { - domain: helper.getTopWindowDomain(url), - page: url, - ref: bidderRequest.refererInfo.referer + domain: bidderRequest.refererInfo.domain, + page: bidderRequest.refererInfo.page, + ref: bidderRequest.refererInfo.ref }, device: { ua: navigator.userAgent, @@ -126,8 +118,8 @@ export const spec = { } const imp = { - id: transactionId, - instl: params.instl === 1 ? 1 : 0, + id: bidId, + instl: deepAccess(bidderRequest.ortb2Imp, 'instl') === 1 || params.instl === 1 ? 1 : 0, tagid: adUnitCode, bidfloor: helper.getBidFloor(bidRequest) || 0, bidfloorcur: 'USD', @@ -143,7 +135,7 @@ export const spec = { banner: { w: sizes.length ? sizes[0][0] : 300, h: sizes.length ? sizes[0][1] : 250, - pos: params.pos || 0, + pos: deepAccess(bidderRequest, 'mediaTypes.banner.pos') || params.pos || 0, topframe: inIframe() ? 0 : 1 } }); @@ -157,7 +149,7 @@ export const spec = { const videoImp = Object.assign({}, imp, { video: { protocols: bidRequest.mediaTypes.video.protocols || params.protocols || [1, 2, 3, 4, 5, 6], - pos: params.pos || 0, + pos: deepAccess(bidRequest, 'mediaTypes.video.pos') || params.pos || 0, ext: { context: mediaTypes.video.context }, @@ -267,7 +259,7 @@ export const spec = { let gdpr = gdprApplies ? 1 : 0; if (gdprApplies && gdprConsent.consentString) { - consentString = encodeURIComponent(gdprConsent.consentString) + consentString = encodeURIComponent(gdprConsent.consentString); } if (uspConsent) { diff --git a/modules/gdprEnforcement.js b/modules/gdprEnforcement.js index 161f530f202..4e600f71b90 100644 --- a/modules/gdprEnforcement.js +++ b/modules/gdprEnforcement.js @@ -2,118 +2,175 @@ * This module gives publishers extra set of features to enforce individual purposes of TCF v2 */ -import {deepAccess, hasDeviceAccess, isArray, logWarn} from '../src/utils.js'; +import {deepAccess, logError, logWarn} from '../src/utils.js'; import {config} from '../src/config.js'; import adapterManager, {gdprDataHandler} from '../src/adapterManager.js'; -import {find, includes} from '../src/polyfill.js'; -import {registerSyncInner} from '../src/adapters/bidderFactory.js'; -import {getHook} from '../src/hook.js'; -import {validateStorageEnforcement} from '../src/storageManager.js'; import * as events from '../src/events.js'; import CONSTANTS from '../src/constants.json'; +import {GDPR_GVLIDS, VENDORLESS_GVLID} from '../src/consentHandler.js'; +import { + MODULE_TYPE_ANALYTICS, + MODULE_TYPE_BIDDER, + MODULE_TYPE_PREBID, + MODULE_TYPE_RTD, + MODULE_TYPE_UID +} from '../src/activities/modules.js'; +import { + ACTIVITY_PARAM_ANL_CONFIG, + ACTIVITY_PARAM_COMPONENT_NAME, + ACTIVITY_PARAM_COMPONENT_TYPE +} from '../src/activities/params.js'; +import {registerActivityControl} from '../src/activities/rules.js'; +import { + ACTIVITY_ACCESS_DEVICE, + ACTIVITY_ENRICH_EIDS, ACTIVITY_ENRICH_UFPD, + ACTIVITY_FETCH_BIDS, + ACTIVITY_REPORT_ANALYTICS, + ACTIVITY_SYNC_USER, ACTIVITY_TRANSMIT_EIDS, ACTIVITY_TRANSMIT_PRECISE_GEO, ACTIVITY_TRANSMIT_UFPD +} from '../src/activities/activities.js'; + +export const STRICT_STORAGE_ENFORCEMENT = 'strictStorageEnforcement'; + +export const ACTIVE_RULES = { + purpose: {}, + feature: {} +}; -const TCF2 = { - 'purpose1': { id: 1, name: 'storage' }, - 'purpose2': { id: 2, name: 'basicAds' }, - 'purpose7': { id: 7, name: 'measurement' } -} +const CONSENT_PATHS = { + purpose: 'purpose.consents', + feature: 'specialFeatureOptins' +}; -/* - These rules would be used if `consentManagement.gdpr.rules` is undefined by the publisher. -*/ -const DEFAULT_RULES = [{ - purpose: 'storage', - enforcePurpose: true, - enforceVendor: true, - vendorExceptions: [] -}, { - purpose: 'basicAds', - enforcePurpose: true, - enforceVendor: true, - vendorExceptions: [] -}]; - -export let purpose1Rule; -export let purpose2Rule; -export let purpose7Rule; - -export let enforcementRules; - -const storageBlocked = []; -const biddersBlocked = []; -const analyticsBlocked = []; - -let addedDeviceAccessHook = false; - -// Helps in stubbing these functions in unit tests. -export const internal = { - getGvlidForBidAdapter, - getGvlidForUserIdModule, - getGvlidForAnalyticsAdapter +const CONFIGURABLE_RULES = { + storage: { + type: 'purpose', + default: { + purpose: 'storage', + enforcePurpose: true, + enforceVendor: true, + vendorExceptions: [] + }, + id: 1, + }, + basicAds: { + type: 'purpose', + id: 2, + default: { + purpose: 'basicAds', + enforcePurpose: true, + enforceVendor: true, + vendorExceptions: [] + } + }, + personalizedAds: { + type: 'purpose', + id: 4, + }, + measurement: { + type: 'purpose', + id: 7, + }, + transmitPreciseGeo: { + type: 'feature', + id: 1, + }, }; +const storageBlocked = new Set(); +const biddersBlocked = new Set(); +const analyticsBlocked = new Set(); +const ufpdBlocked = new Set(); +const eidsBlocked = new Set(); +const geoBlocked = new Set(); + +let hooksAdded = false; +let strictStorageEnforcement = false; + +const GVLID_LOOKUP_PRIORITY = [ + MODULE_TYPE_BIDDER, + MODULE_TYPE_UID, + MODULE_TYPE_ANALYTICS, + MODULE_TYPE_RTD +]; + +const RULE_NAME = 'TCF2'; +const RULE_HANDLES = []; + +// in JS we do not have access to the GVL; assume that everyone declares legitimate interest for basic ads +const LI_PURPOSES = [2]; + /** - * Returns GVL ID for a Bid adapter / an USERID submodule / an Analytics adapter. - * If modules of different types have the same moduleCode: For example, 'appnexus' is the code for both Bid adapter and Analytics adapter, - * then, we assume that their GVL IDs are same. This function first checks if GVL ID is defined for a Bid adapter, if not found, tries to find User ID - * submodule's GVL ID, if not found, tries to find Analytics adapter's GVL ID. In this process, as soon as it finds a GVL ID, it returns it - * without going to the next check. - * @param {{string|Object}} - module - * @return {number} - GVL ID + * Retrieve a module's GVL ID. */ -export function getGvlid(module) { - let gvlid = null; - if (module) { +export function getGvlid(moduleType, moduleName, fallbackFn) { + if (moduleName) { // Check user defined GVL Mapping in pbjs.setConfig() const gvlMapping = config.getConfig('gvlMapping'); - // For USER ID Module, we pass the submodule object itself as the "module" parameter, this check is required to grab the module code - const moduleCode = typeof module === 'string' ? module : module.name; - // Return GVL ID from user defined gvlMapping - if (gvlMapping && gvlMapping[moduleCode]) { - gvlid = gvlMapping[moduleCode]; - return gvlid; + if (gvlMapping && gvlMapping[moduleName]) { + return gvlMapping[moduleName]; + } else if (moduleType === MODULE_TYPE_PREBID) { + return VENDORLESS_GVLID; + } else { + let {gvlid, modules} = GDPR_GVLIDS.get(moduleName); + if (gvlid == null && Object.keys(modules).length > 0) { + // this behavior is for backwards compatibility; if multiple modules with the same + // name declare different GVL IDs, pick the bidder's first, then userId, then analytics + for (const type of GVLID_LOOKUP_PRIORITY) { + if (modules.hasOwnProperty(type)) { + gvlid = modules[type]; + if (type !== moduleType) { + logWarn(`Multiple GVL IDs found for module '${moduleName}'; using the ${type} module's ID (${gvlid}) instead of the ${moduleType}'s ID (${modules[moduleType]})`); + } + break; + } + } + } + if (gvlid == null && fallbackFn) { + gvlid = fallbackFn(); + } + return gvlid || null; } - - gvlid = internal.getGvlidForBidAdapter(moduleCode) || internal.getGvlidForUserIdModule(module) || internal.getGvlidForAnalyticsAdapter(moduleCode); } - return gvlid; + return null; } /** - * Returns GVL ID for a bid adapter. If the adapter does not have an associated GVL ID, it returns 'null'. - * @param {string=} bidderCode - The 'code' property of the Bidder spec. - * @return {number} GVL ID + * Retrieve GVL IDs that are dynamically set on analytics adapters. */ -function getGvlidForBidAdapter(bidderCode) { - let gvlid = null; - bidderCode = bidderCode || config.getCurrentBidder(); - if (bidderCode) { - const bidder = adapterManager.getBidAdapter(bidderCode); - if (bidder && bidder.getSpec) { - gvlid = bidder.getSpec().gvlid; +export function getGvlidFromAnalyticsAdapter(code, config) { + const adapter = adapterManager.getAnalyticsAdapter(code); + return ((gvlid) => { + if (typeof gvlid !== 'function') return gvlid; + try { + return gvlid.call(adapter.adapter, config); + } catch (e) { + logError(`Error invoking ${code} adapter.gvlid()`, e); } - } - return gvlid; + })(adapter?.adapter?.gvlid); } -/** - * Returns GVL ID for an userId submodule. If an userId submodules does not have an associated GVL ID, it returns 'null'. - * @param {Object} userIdModule - * @return {number} GVL ID - */ -function getGvlidForUserIdModule(userIdModule) { - return (typeof userIdModule === 'object' ? userIdModule.gvlid : null); +export function shouldEnforce(consentData, purpose, name) { + if (consentData == null && gdprDataHandler.enabled) { + // there is no consent data, but the GDPR module has been installed and configured + // NOTE: this check is not foolproof, as when Prebid first loads, enforcement hooks have not been attached yet + // This piece of code would not run at all, and `gdprDataHandler.enabled` would be false, until the first + // `setConfig({consentManagement})` + logWarn(`Attempting operation that requires purpose ${purpose} consent while consent data is not available${name ? ` (module: ${name})` : ''}. Assuming no consent was given.`); + return true; + } + return consentData && consentData.gdprApplies; } -/** - * Returns GVL ID for an analytics adapter. If an analytics adapter does not have an associated GVL ID, it returns 'null'. - * @param {string} code - 'provider' property on the analytics adapter config - * @return {number} GVL ID - */ -function getGvlidForAnalyticsAdapter(code) { - return adapterManager.getAnalyticsAdapter(code) && (adapterManager.getAnalyticsAdapter(code).gvlid || null); +function getConsent(consentData, type, id, gvlId) { + let purpose = !!deepAccess(consentData, `vendorData.${CONSENT_PATHS[type]}.${id}`); + let vendor = !!deepAccess(consentData, `vendorData.vendor.consents.${gvlId}`); + if (type === 'purpose' && LI_PURPOSES.includes(id)) { + purpose ||= !!deepAccess(consentData, `vendorData.purpose.legitimateInterests.${id}`); + vendor ||= !!deepAccess(consentData, `vendorData.vendor.legitimateInterests.${gvlId}`); + } + return {purpose, vendor}; } /** @@ -126,274 +183,157 @@ function getGvlidForAnalyticsAdapter(code) { * @returns {boolean} */ export function validateRules(rule, consentData, currentModule, gvlId) { - const purposeId = TCF2[Object.keys(TCF2).filter(purposeName => TCF2[purposeName].name === rule.purpose)[0]].id; + const ruleOptions = CONFIGURABLE_RULES[rule.purpose]; // return 'true' if vendor present in 'vendorExceptions' - if (includes(rule.vendorExceptions || [], currentModule)) { + if ((rule.vendorExceptions || []).includes(currentModule)) { return true; } - - // get data from the consent string - const purposeConsent = deepAccess(consentData, `vendorData.purpose.consents.${purposeId}`); - const vendorConsent = deepAccess(consentData, `vendorData.vendor.consents.${gvlId}`); - const liTransparency = deepAccess(consentData, `vendorData.purpose.legitimateInterests.${purposeId}`); - - /* - Since vendor exceptions have already been handled, the purpose as a whole is allowed if it's not being enforced - or the user has consented. Similar with vendors. - */ - const purposeAllowed = rule.enforcePurpose === false || purposeConsent === true; - const vendorAllowed = rule.enforceVendor === false || vendorConsent === true; - - /* - Few if any vendors should be declaring Legitimate Interest for Device Access (Purpose 1), but some are claiming - LI for Basic Ads (Purpose 2). Prebid.js can't check to see who's declaring what legal basis, so if LI has been - established for Purpose 2, allow the auction to take place and let the server sort out the legal basis calculation. - */ - if (purposeId === 2) { - return (purposeAllowed && vendorAllowed) || (liTransparency === true); - } - - return purposeAllowed && vendorAllowed; + const vendorConsentRequred = rule.enforceVendor && !((gvlId === VENDORLESS_GVLID || (rule.softVendorExceptions || []).includes(currentModule))); + const {purpose, vendor} = getConsent(consentData, ruleOptions.type, ruleOptions.id, gvlId); + return (!rule.enforcePurpose || purpose) && (!vendorConsentRequred || vendor); } -/** - * This hook checks whether module has permission to access device or not. Device access include cookie and local storage - * @param {Function} fn reference to original function (used by hook logic) - * @param {Number=} gvlid gvlid of the module - * @param {string=} moduleName name of the module - */ -export function deviceAccessHook(fn, gvlid, moduleName, result) { - result = Object.assign({}, { - hasEnforcementHook: true - }); - if (!hasDeviceAccess()) { - logWarn('Device access is disabled by Publisher'); - result.valid = false; - fn.call(this, gvlid, moduleName, result); - } else { +function gdprRule(purposeNo, checkConsent, blocked = null, gvlidFallback = () => null) { + return function (params) { const consentData = gdprDataHandler.getConsentData(); - if (consentData && consentData.gdprApplies) { - if (consentData.apiVersion === 2) { - const curBidder = config.getCurrentBidder(); - // Bidders have a copy of storage object with bidder code binded. Aliases will also pass the same bidder code when invoking storage functions and hence if alias tries to access device we will try to grab the gvl id for alias instead of original bidder - if (curBidder && (curBidder != moduleName) && adapterManager.aliasRegistry[curBidder] === moduleName) { - gvlid = getGvlid(curBidder); - } else { - gvlid = getGvlid(moduleName) || gvlid; - } - const curModule = moduleName || curBidder; - let isAllowed = validateRules(purpose1Rule, consentData, curModule, gvlid); - if (isAllowed) { - result.valid = true; - fn.call(this, gvlid, moduleName, result); - } else { - curModule && logWarn(`TCF2 denied device access for ${curModule}`); - result.valid = false; - storageBlocked.push(curModule); - fn.call(this, gvlid, moduleName, result); - } - } else { - // The module doesn't enforce TCF1.1 strings - result.valid = true; - fn.call(this, gvlid, moduleName, result); - } - } else { - result.valid = true; - fn.call(this, gvlid, moduleName, result); - } - } -} - -/** - * This hook checks if a bidder has consent for user sync or not - * @param {Function} fn reference to original function (used by hook logic) - * @param {...any} args args - */ -export function userSyncHook(fn, ...args) { - const consentData = gdprDataHandler.getConsentData(); - if (consentData && consentData.gdprApplies) { - if (consentData.apiVersion === 2) { - const curBidder = config.getCurrentBidder(); - const gvlid = getGvlid(curBidder); - let isAllowed = validateRules(purpose1Rule, consentData, curBidder, gvlid); - if (isAllowed) { - fn.call(this, ...args); - } else { - logWarn(`User sync not allowed for ${curBidder}`); - storageBlocked.push(curBidder); + const modName = params[ACTIVITY_PARAM_COMPONENT_NAME]; + if (shouldEnforce(consentData, purposeNo, modName)) { + const gvlid = getGvlid(params[ACTIVITY_PARAM_COMPONENT_TYPE], modName, gvlidFallback(params)); + let allow = !!checkConsent(consentData, modName, gvlid); + if (!allow) { + blocked && blocked.add(modName); + return {allow}; } - } else { - // The module doesn't enforce TCF1.1 strings - fn.call(this, ...args); } - } else { - fn.call(this, ...args); - } + }; } -/** - * This hook checks if user id module is given consent or not - * @param {Function} fn reference to original function (used by hook logic) - * @param {Submodule[]} submodules Array of user id submodules - * @param {Object} consentData GDPR consent data - */ -export function userIdHook(fn, submodules, consentData) { - if (consentData && consentData.gdprApplies) { - if (consentData.apiVersion === 2) { - let userIdModules = submodules.map((submodule) => { - const gvlid = getGvlid(submodule.submodule); - const moduleName = submodule.submodule.name; - let isAllowed = validateRules(purpose1Rule, consentData, moduleName, gvlid); - if (isAllowed) { - return submodule; - } else { - logWarn(`User denied permission to fetch user id for ${moduleName} User id module`); - storageBlocked.push(moduleName); - } - return undefined; - }).filter(module => module) - fn.call(this, userIdModules, { ...consentData, hasValidated: true }); - } else { - // The module doesn't enforce TCF1.1 strings - fn.call(this, submodules, consentData); - } - } else { - fn.call(this, submodules, consentData); - } +function singlePurposeGdprRule(purposeNo, blocked = null, gvlidFallback = () => null) { + return gdprRule(purposeNo, (cd, modName, gvlid) => !!validateRules(ACTIVE_RULES.purpose[purposeNo], cd, modName, gvlid), blocked, gvlidFallback); } -/** - * Checks if bidders are allowed in the auction. - * Enforces "purpose 2 (Basic Ads)" of TCF v2.0 spec - * @param {Function} fn - Function reference to the original function. - * @param {Array} adUnits - */ -export function makeBidRequestsHook(fn, adUnits, ...args) { - const consentData = gdprDataHandler.getConsentData(); - if (consentData && consentData.gdprApplies) { - if (consentData.apiVersion === 2) { - adUnits.forEach(adUnit => { - adUnit.bids = adUnit.bids.filter(bid => { - const currBidder = bid.bidder; - const gvlId = getGvlid(currBidder); - if (includes(biddersBlocked, currBidder)) return false; - const isAllowed = !!validateRules(purpose2Rule, consentData, currBidder, gvlId); - if (!isAllowed) { - logWarn(`TCF2 blocked auction for ${currBidder}`); - biddersBlocked.push(currBidder); - } - return isAllowed; - }); - }); - fn.call(this, adUnits, ...args); - } else { - // The module doesn't enforce TCF1.1 strings - fn.call(this, adUnits, ...args); +function exceptPrebidModules(ruleFn) { + return function (params) { + if (params[ACTIVITY_PARAM_COMPONENT_TYPE] === MODULE_TYPE_PREBID) { + // TODO: this special case is for the PBS adapter (componentType is 'prebid') + // we should check for generic purpose 2 consent & vendor consent based on the PBS vendor's GVL ID; + // that is, however, a breaking change and skipped for now + return; } - } else { - fn.call(this, adUnits, ...args); - } + return ruleFn(params); + }; } -/** - * Checks if Analytics adapters are allowed to send data to their servers for furhter processing. - * Enforces "purpose 7 (Measurement)" of TCF v2.0 spec - * @param {Function} fn - Function reference to the original function. - * @param {Array} config - Configuration object passed to pbjs.enableAnalytics() - */ -export function enableAnalyticsHook(fn, config) { - const consentData = gdprDataHandler.getConsentData(); - if (consentData && consentData.gdprApplies) { - if (consentData.apiVersion === 2) { - if (!isArray(config)) { - config = [config] +export const accessDeviceRule = ((rule) => { + return function (params) { + // for vendorless (core) storage, do not enforce rules unless strictStorageEnforcement is set + if (params[ACTIVITY_PARAM_COMPONENT_TYPE] === MODULE_TYPE_PREBID && !strictStorageEnforcement) return; + return rule(params); + }; +})(singlePurposeGdprRule(1, storageBlocked)); + +export const syncUserRule = singlePurposeGdprRule(1, storageBlocked); +export const enrichEidsRule = singlePurposeGdprRule(1, storageBlocked); +export const fetchBidsRule = exceptPrebidModules(singlePurposeGdprRule(2, biddersBlocked)); +export const reportAnalyticsRule = singlePurposeGdprRule(7, analyticsBlocked, (params) => getGvlidFromAnalyticsAdapter(params[ACTIVITY_PARAM_COMPONENT_NAME], params[ACTIVITY_PARAM_ANL_CONFIG])); +export const ufpdRule = singlePurposeGdprRule(4, ufpdBlocked); + +export const transmitEidsRule = exceptPrebidModules((() => { + // Transmit EID special case: + // by default, legal basis or vendor exceptions for any purpose between 2 and 10 + // (but disregarding enforcePurpose and enforceVendor config) is enough to allow EIDs through + function check2to10Consent(consentData, modName, gvlId) { + for (let pno = 2; pno <= 10; pno++) { + if (ACTIVE_RULES.purpose[pno]?.vendorExceptions?.includes(modName)) { + return true; + } + const {purpose, vendor} = getConsent(consentData, 'purpose', pno, gvlId); + if (purpose && (vendor || ACTIVE_RULES.purpose[pno]?.softVendorExceptions?.includes(modName))) { + return true; } - config = config.filter(conf => { - const analyticsAdapterCode = conf.provider; - const gvlid = getGvlid(analyticsAdapterCode); - const isAllowed = !!validateRules(purpose7Rule, consentData, analyticsAdapterCode, gvlid); - if (!isAllowed) { - analyticsBlocked.push(analyticsAdapterCode); - logWarn(`TCF2 blocked analytics adapter ${conf.provider}`); - } - return isAllowed; - }); - fn.call(this, config); - } else { - // This module doesn't enforce TCF1.1 strings - fn.call(this, config); } - } else { - fn.call(this, config); + return false; } -} + + const defaultBehavior = gdprRule('2-10', check2to10Consent, eidsBlocked); + const p4Behavior = singlePurposeGdprRule(4, eidsBlocked); + return function () { + const fn = ACTIVE_RULES.purpose[4]?.eidsRequireP4Consent ? p4Behavior : defaultBehavior; + return fn.apply(this, arguments); + }; +})()); + +export const transmitPreciseGeoRule = gdprRule('Special Feature 1', (cd, modName, gvlId) => validateRules(ACTIVE_RULES.feature[1], cd, modName, gvlId), geoBlocked); /** * Compiles the TCF2.0 enforcement results into an object, which is emitted as an event payload to "tcf2Enforcement" event. */ function emitTCF2FinalResults() { // remove null and duplicate values - const formatArray = function (arr) { - return arr.filter((i, k) => i !== null && arr.indexOf(i) === k); - } + const formatSet = function (st) { + return Array.from(st.keys()).filter(el => el != null); + }; const tcf2FinalResults = { - storageBlocked: formatArray(storageBlocked), - biddersBlocked: formatArray(biddersBlocked), - analyticsBlocked: formatArray(analyticsBlocked) + storageBlocked: formatSet(storageBlocked), + biddersBlocked: formatSet(biddersBlocked), + analyticsBlocked: formatSet(analyticsBlocked), + ufpdBlocked: formatSet(ufpdBlocked), + eidsBlocked: formatSet(eidsBlocked), + geoBlocked: formatSet(geoBlocked) }; events.emit(CONSTANTS.EVENTS.TCF2_ENFORCEMENT, tcf2FinalResults); + [storageBlocked, biddersBlocked, analyticsBlocked, ufpdBlocked, eidsBlocked, geoBlocked].forEach(el => el.clear()); } events.on(CONSTANTS.EVENTS.AUCTION_END, emitTCF2FinalResults); -/* - Set of callback functions used to detect presence of a TCF rule, passed as the second argument to find(). -*/ -const hasPurpose1 = (rule) => { return rule.purpose === TCF2.purpose1.name } -const hasPurpose2 = (rule) => { return rule.purpose === TCF2.purpose2.name } -const hasPurpose7 = (rule) => { return rule.purpose === TCF2.purpose7.name } - /** * A configuration function that initializes some module variables, as well as adds hooks * @param {Object} config - GDPR enforcement config object */ export function setEnforcementConfig(config) { - const rules = deepAccess(config, 'gdpr.rules'); + let rules = deepAccess(config, 'gdpr.rules'); if (!rules) { logWarn('TCF2: enforcing P1 and P2 by default'); - enforcementRules = DEFAULT_RULES; - } else { - enforcementRules = rules; - } - - purpose1Rule = find(enforcementRules, hasPurpose1); - purpose2Rule = find(enforcementRules, hasPurpose2); - purpose7Rule = find(enforcementRules, hasPurpose7); - - if (!purpose1Rule) { - purpose1Rule = DEFAULT_RULES[0]; } + rules = Object.fromEntries((rules || []).map(r => [r.purpose, r])); + strictStorageEnforcement = !!deepAccess(config, STRICT_STORAGE_ENFORCEMENT); - if (!purpose2Rule) { - purpose2Rule = DEFAULT_RULES[1]; - } + Object.entries(CONFIGURABLE_RULES).forEach(([name, opts]) => { + ACTIVE_RULES[opts.type][opts.id] = rules[name] ?? opts.default; + }); - if (purpose1Rule && !addedDeviceAccessHook) { - addedDeviceAccessHook = true; - validateStorageEnforcement.before(deviceAccessHook, 49); - registerSyncInner.before(userSyncHook, 48); - // Using getHook as user id and gdprEnforcement are both optional modules. Using import will auto include the file in build - getHook('validateGdprEnforcement').before(userIdHook, 47); - } - if (purpose2Rule) { - getHook('makeBidRequests').before(makeBidRequestsHook); + if (!hooksAdded) { + if (ACTIVE_RULES.purpose[1] != null) { + hooksAdded = true; + RULE_HANDLES.push(registerActivityControl(ACTIVITY_ACCESS_DEVICE, RULE_NAME, accessDeviceRule)); + RULE_HANDLES.push(registerActivityControl(ACTIVITY_SYNC_USER, RULE_NAME, syncUserRule)); + RULE_HANDLES.push(registerActivityControl(ACTIVITY_ENRICH_EIDS, RULE_NAME, enrichEidsRule)); + } + if (ACTIVE_RULES.purpose[2] != null) { + RULE_HANDLES.push(registerActivityControl(ACTIVITY_FETCH_BIDS, RULE_NAME, fetchBidsRule)); + } + if (ACTIVE_RULES.purpose[4] != null) { + RULE_HANDLES.push( + registerActivityControl(ACTIVITY_TRANSMIT_UFPD, RULE_NAME, ufpdRule), + registerActivityControl(ACTIVITY_ENRICH_UFPD, RULE_NAME, ufpdRule) + ); + } + if (ACTIVE_RULES.purpose[7] != null) { + RULE_HANDLES.push(registerActivityControl(ACTIVITY_REPORT_ANALYTICS, RULE_NAME, reportAnalyticsRule)); + } + if (ACTIVE_RULES.feature[1] != null) { + RULE_HANDLES.push(registerActivityControl(ACTIVITY_TRANSMIT_PRECISE_GEO, RULE_NAME, transmitPreciseGeoRule)); + } + RULE_HANDLES.push(registerActivityControl(ACTIVITY_TRANSMIT_EIDS, RULE_NAME, transmitEidsRule)); } +} - if (purpose7Rule) { - getHook('enableAnalyticsCb').before(enableAnalyticsHook); - } +export function uninstall() { + while (RULE_HANDLES.length) RULE_HANDLES.pop()(); + hooksAdded = false; } config.getConfig('consentManagement', config => setEnforcementConfig(config.consentManagement)); diff --git a/modules/genericAnalyticsAdapter.js b/modules/genericAnalyticsAdapter.js new file mode 100644 index 00000000000..b52cb7e5464 --- /dev/null +++ b/modules/genericAnalyticsAdapter.js @@ -0,0 +1,152 @@ +import AnalyticsAdapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import {prefixLog, isPlainObject} from '../src/utils.js'; +import * as CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager.js'; +import {ajaxBuilder} from '../src/ajax.js'; + +const DEFAULTS = { + batchSize: 1, + batchDelay: 100, + method: 'POST' +} + +const TYPES = { + handler: 'function', + batchSize: 'number', + batchDelay: 'number', + gvlid: 'number', +} + +const MAX_CALL_DEPTH = 20; + +export function GenericAnalytics() { + const parent = AnalyticsAdapter({analyticsType: 'endpoint'}); + const {logError, logWarn} = prefixLog('Generic analytics:'); + let batch = []; + let callDepth = 0; + let options, handler, timer, translate; + + function optionsAreValid(options) { + if (!options.url && !options.handler) { + logError('options must specify either `url` or `handler`') + return false; + } + if (options.hasOwnProperty('method') && !['GET', 'POST'].includes(options.method)) { + logError('options.method must be GET or POST'); + return false; + } + for (const [field, type] of Object.entries(TYPES)) { + // eslint-disable-next-line valid-typeof + if (options.hasOwnProperty(field) && typeof options[field] !== type) { + logError(`options.${field} must be a ${type}`); + return false; + } + } + if (options.hasOwnProperty('events')) { + if (!isPlainObject(options.events)) { + logError('options.events must be an object'); + return false; + } + for (const [event, handler] of Object.entries(options.events)) { + if (!CONSTANTS.EVENTS.hasOwnProperty(event)) { + logWarn(`options.events.${event} does not match any known Prebid event`); + if (typeof handler !== 'function') { + logError(`options.events.${event} must be a function`); + return false; + } + } + } + } + return true; + } + + function processBatch() { + const currentBatch = batch; + batch = []; + callDepth++; + try { + // the pub-provided handler may inadvertently cause an infinite chain of events; + // even just logging an exception from it may cause an AUCTION_DEBUG event, that + // gets back to the handler, that throws another exception etc. + // to avoid the issue, put a cap on recursion + if (callDepth === MAX_CALL_DEPTH) { + logError('detected probable infinite recursion, discarding events', currentBatch); + } + if (callDepth >= MAX_CALL_DEPTH) { + return; + } + try { + handler(currentBatch); + } catch (e) { + logError('error executing options.handler', e); + } + } finally { + callDepth--; + } + } + + function translator(eventHandlers) { + if (!eventHandlers) { + return (data) => data; + } + return function ({eventType, args}) { + if (eventHandlers.hasOwnProperty(eventType)) { + try { + return eventHandlers[eventType](args); + } catch (e) { + logError(`error executing options.events.${eventType}`, e); + } + } + } + } + + return Object.assign( + Object.create(parent), + { + gvlid(config) { + return config?.options?.gvlid + }, + enableAnalytics(config) { + if (optionsAreValid(config?.options || {})) { + options = Object.assign({}, DEFAULTS, config.options); + handler = options.handler || defaultHandler(options); + translate = translator(options.events); + parent.enableAnalytics.call(this, config); + } + }, + track(event) { + const datum = translate(event); + if (datum != null) { + batch.push(datum); + if (timer != null) { + clearTimeout(timer); + timer = null; + } + if (batch.length >= options.batchSize) { + processBatch(); + } else { + timer = setTimeout(processBatch, options.batchDelay); + } + } + } + } + ) +} + +export function defaultHandler({url, method, batchSize, ajax = ajaxBuilder()}) { + const callbacks = { + success() {}, + error() {} + } + const extract = batchSize > 1 ? (events) => events : (events) => events[0]; + const serialize = method === 'GET' ? (data) => ({data: JSON.stringify(data)}) : (data) => JSON.stringify(data); + + return function (events) { + ajax(url, callbacks, serialize(extract(events)), {method}) + } +} + +adapterManager.registerAnalyticsAdapter({ + adapter: GenericAnalytics(), + code: 'generic', +}); diff --git a/modules/geoedgeRtdProvider.js b/modules/geoedgeRtdProvider.js index 001ef67b66a..646d2f4e786 100644 --- a/modules/geoedgeRtdProvider.js +++ b/modules/geoedgeRtdProvider.js @@ -18,6 +18,10 @@ import { submodule } from '../src/hook.js'; import { ajax } from '../src/ajax.js'; import { generateUUID, insertElement, isEmpty, logError } from '../src/utils.js'; +import * as events from '../src/events.js'; +import CONSTANTS from '../src/constants.json'; +import { loadExternalScript } from '../src/adloader.js'; +import { auctionManager } from '../src/auctionManager.js'; /** @type {string} */ const SUBMODULE_NAME = 'geoedge'; @@ -31,9 +35,13 @@ const PV_ID = generateUUID(); /** @type {string} */ const HOST_NAME = 'https://rumcdn.geoedge.be'; /** @type {string} */ -const FILE_NAME = 'grumi.js'; +const FILE_NAME_CLIENT = 'grumi.js'; +/** @type {string} */ +const FILE_NAME_INPAGE = 'grumi-ip.js'; +/** @type {function} */ +export let getClientUrl = (key) => `${HOST_NAME}/${key}/${FILE_NAME_CLIENT}`; /** @type {function} */ -export let getClientUrl = (key) => `${HOST_NAME}/${key}/${FILE_NAME}`; +export let getInPageUrl = (key) => `${HOST_NAME}/${key}/${FILE_NAME_INPAGE}`; /** @type {string} */ export let wrapper /** @type {boolean} */; @@ -105,6 +113,7 @@ function getMacros(bid, key) { '%%PATTERN:hb_bidder%%': bid.bidderCode, '%_isHb!': true, '%_hbcid!': bid.creativeId || '', + '%_hbadomains': bid.meta && bid.meta.advertiserDomains, '%%PATTERN:hb_pb%%': bid.pbHg, '%%SITE%%': location.hostname, '%_pimp%': PV_ID @@ -174,7 +183,8 @@ function isSupportedBidder(bidder, paramsBidders) { function shouldWrap(bid, params) { let supportedBidder = isSupportedBidder(bid.bidderCode, params.bidders); let donePreload = params.wap ? preloaded : true; - return wrapperReady && supportedBidder && donePreload; + let isGPT = params.gpt; + return wrapperReady && supportedBidder && donePreload && !isGPT; } function conditionallyWrap(bidResponse, config, userConsent) { @@ -184,13 +194,56 @@ function conditionallyWrap(bidResponse, config, userConsent) { } } +function isBillingMessage(data, params) { + return data.key === params.key && data.impression; +} + +/** + * Fire billable events when our client sends a message + * Messages will be sent only when: + * a. applicable bids are wrapped + * b. our code laoded and executed sucesfully + */ +function fireBillableEventsForApplicableBids(params) { + window.addEventListener('message', function (message) { + let data = message.data; + if (isBillingMessage(data, params)) { + let winningBid = auctionManager.findBidByAdId(data.adId); + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + vendor: SUBMODULE_NAME, + billingId: data.impressionId, + type: winningBid ? 'impression' : data.type, + transactionId: winningBid?.transactionId || data.transactionId, + auctionId: winningBid?.auctionId || data.auctionId, + bidId: winningBid?.requestId || data.requestId + }); + } + }); +} + +/** + * Loads Geoedge in page script that monitors all ad slots created by GPT + * @param {Object} params + */ +function setupInPage(params) { + window.grumi = params; + window.grumi.fromPrebid = true; + loadExternalScript(getInPageUrl(params.key), SUBMODULE_NAME); +} + function init(config, userConsent) { let params = config.params; if (!params || !params.key) { logError('missing key for geoedge RTD module provider'); return false; } - preloadClient(params.key); + if (params.gpt) { + setupInPage(params); + } else { + fetchWrapper(setWrapper); + preloadClient(params.key); + } + fireBillableEventsForApplicableBids(params); return true; } @@ -205,9 +258,4 @@ export const geoedgeSubmodule = { onBidResponseEvent: conditionallyWrap }; -export function beforeInit() { - fetchWrapper(setWrapper); - submodule('realTimeData', geoedgeSubmodule); -} - -beforeInit(); +submodule('realTimeData', geoedgeSubmodule); diff --git a/modules/geoedgeRtdProvider.md b/modules/geoedgeRtdProvider.md index 5414606612c..cdf913b8893 100644 --- a/modules/geoedgeRtdProvider.md +++ b/modules/geoedgeRtdProvider.md @@ -5,7 +5,7 @@ Module Type: Rtd Provider Maintainer: guy.books@geoedge.com The Geoedge Realtime module lets publishers block bad ads such as automatic redirects, malware, offensive creatives and landing pages. -To use this module, you'll need to work with [Geoedge](https://www.geoedge.com/publishers-real-time-protection/) to get an account and cutomer key. +To use this module, you'll need to work with [Geoedge](https://www.geoedge.com/publishers-real-time-protection/) to get an account and customer key. ## Integration @@ -49,6 +49,7 @@ Parameters details: |params.key | String | Customer key |Required, contact Geoedge to get your key | |params.bidders | Object | Bidders to monitor |Optional, list of bidder to include / exclude from monitoring. Omitting this will monitor bids from all bidders. | |params.wap |Boolean |Wrap after preload |Optional, defaults to `false`. Set to `true` if you want to monitor only after the module has preloaded the monitoring client. | +|params.gpt |Boolean |Wrap all GPT ad slots |Optional, defaults to `false`. Set to `true` if you want to monitor all Google Publisher Tag ad slots, regaedless if the winning bid comes from Prebid or Google Ad Manager (Direct, Adx, Adesnse, Open Bidding, etc). | ## Example diff --git a/modules/geolocationRtdProvider.js b/modules/geolocationRtdProvider.js new file mode 100644 index 00000000000..b46a25e9246 --- /dev/null +++ b/modules/geolocationRtdProvider.js @@ -0,0 +1,63 @@ +import {submodule} from '../src/hook.js'; +import {isFn, logError, deepAccess, deepSetValue, logInfo, logWarn, timestamp} from '../src/utils.js'; +import { ACTIVITY_TRANSMIT_PRECISE_GEO } from '../src/activities/activities.js'; +import { MODULE_TYPE_RTD } from '../src/activities/modules.js'; +import { isActivityAllowed } from '../src/activities/rules.js'; +import { activityParams } from '../src/activities/activityParams.js'; + +let permissionsAvailable = true; +let geolocation; +function getGeolocationData(requestBidsObject, onDone, providerConfig, userConsent) { + let done = false; + if (!permissionsAvailable) { + logWarn('permission for geolocation receiving was denied'); + return complete() + }; + if (!isActivityAllowed(ACTIVITY_TRANSMIT_PRECISE_GEO, activityParams(MODULE_TYPE_RTD, 'geolocation'))) { + logWarn('permission for geolocation receiving was denied by CMP'); + return complete() + }; + const requestPermission = deepAccess(providerConfig, 'params.requestPermission') === true; + navigator.permissions.query({ + name: 'geolocation', + }).then(permission => { + if (permission.state !== 'granted' && !requestPermission) return complete(); + navigator.geolocation.getCurrentPosition(geo => { + geolocation = geo; + complete(); + }); + }); + function complete() { + if (done) return; + done = true; + if (geolocation) { + deepSetValue(requestBidsObject, 'ortb2Fragments.global.device.geo', { + lat: geolocation.coords.latitude, + lon: geolocation.coords.longitude, + lastfix: Math.round((timestamp() - geolocation.timestamp) / 1000), + type: 1 + }); + logInfo('geolocation was successfully received ', requestBidsObject.ortb2Fragments.global.device.geo) + } + onDone(); + } +} +function init(moduleConfig) { + geolocation = void 0; + if (!isFn(navigator?.permissions?.query) || !isFn(navigator?.geolocation?.getCurrentPosition || !navigator?.permissions?.query)) { + logError('geolocation is not defined'); + permissionsAvailable = false; + } else { + permissionsAvailable = true; + } + return permissionsAvailable; +} +export const geolocationSubmodule = { + name: 'geolocation', + getBidRequestData: getGeolocationData, + init: init, +}; +function registerSubModule() { + submodule('realTimeData', geolocationSubmodule); +} +registerSubModule(); diff --git a/modules/getintentBidAdapter.js b/modules/getintentBidAdapter.js index 98659cc25e2..2b6ea1c2c2a 100644 --- a/modules/getintentBidAdapter.js +++ b/modules/getintentBidAdapter.js @@ -1,4 +1,4 @@ -import { getBidIdParameter, isFn, isInteger } from '../src/utils.js'; +import {getBidIdParameter, isFn, isInteger} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'getintent'; @@ -97,7 +97,7 @@ export const spec = { return bids; } -} +}; function buildUrl(bid) { return 'https://' + BID_HOST + (bid.is_video ? BID_VIDEO_PATH : BID_BANNER_PATH); diff --git a/modules/giantsBidAdapter.md b/modules/giantsBidAdapter.md deleted file mode 100644 index 8d7cdd81184..00000000000 --- a/modules/giantsBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -``` -Module Name: Giants Bid Adapter -Module Type: Bidder Adapter -Maintainer: info@prebid.org -``` - -# Description - -Connects to Giants exchange for bids. - -Giants bid adapter supports Banner. - -# Test Parameters -``` -var adUnits = [ - // Banner adUnit - { - code: 'banner-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'giants', - params: { - zoneId: '584072408' - } - }] - } -]; -``` \ No newline at end of file diff --git a/modules/gjirafaBidAdapter.js b/modules/gjirafaBidAdapter.js index 48b2cd43c3b..91ed5c9b3fb 100644 --- a/modules/gjirafaBidAdapter.js +++ b/modules/gjirafaBidAdapter.js @@ -45,7 +45,7 @@ export const spec = { if (!propertyId) { propertyId = bidRequest.params.propertyId; } if (!pageViewGuid && bidRequest.params) { pageViewGuid = bidRequest.params.pageViewGuid || ''; } if (!bidderRequestId) { bidderRequestId = bidRequest.bidderRequestId; } - if (!url && bidderRequest) { url = bidderRequest.refererInfo.referer; } + if (!url && bidderRequest) { url = bidderRequest.refererInfo.page; } if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents; } if (Object.keys(data).length === 0 && bidRequest.params.data && Object.keys(bidRequest.params.data).length !== 0) { data = bidRequest.params.data; } @@ -74,7 +74,7 @@ export const spec = { placements: placements, contents: contents, data: data - } + }; return [{ method: 'POST', @@ -113,7 +113,7 @@ export const spec = { } return bidResponses; } -} +}; /** * Generate size param for bid request using sizes array diff --git a/modules/glimpseBidAdapter.js b/modules/glimpseBidAdapter.js deleted file mode 100644 index 35aaf56c604..00000000000 --- a/modules/glimpseBidAdapter.js +++ /dev/null @@ -1,201 +0,0 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { - isArray, - isEmpty, - isEmptyStr, - isStr, - isPlainObject, -} from '../src/utils.js'; - -const GVLID = 1012; -const BIDDER_CODE = 'glimpse'; -const storageManager = getStorageManager({ - gvlid: GVLID, - bidderCode: BIDDER_CODE, -}); -const ENDPOINT = 'https://market.glimpsevault.io/public/v1/prebid'; -const LOCAL_STORAGE_KEY = { - vault: { - jwt: 'gp_vault_jwt', - }, -}; - -export const spec = { - gvlid: GVLID, - code: BIDDER_CODE, - supportedMediaTypes: [BANNER], - - /** - * Determines if the bid request is valid - * @param bid {BidRequest} The bid to validate - * @return {boolean} - */ - isBidRequestValid: (bid) => { - const pid = bid?.params?.pid; - return isStr(pid) && !isEmptyStr(pid); - }, - - /** - * Builds the http request - * @param validBidRequests {BidRequest[]} - * @param bidderRequest {BidderRequest} - * @returns {ServerRequest} - */ - buildRequests: (validBidRequests, bidderRequest) => { - const url = buildQuery(bidderRequest); - const auth = getVaultJwt(); - const referer = getReferer(bidderRequest); - const imp = validBidRequests.map(processBidRequest); - const fpd = getFirstPartyData(); - - const data = { - auth, - data: { - referer, - imp, - fpd, - }, - }; - - return { - method: 'POST', - url, - data: JSON.stringify(data), - options: {}, - }; - }, - - /** - * Parse http response - * @param response {ServerResponse} - * @returns {Bid[]} - */ - interpretResponse: (response) => { - if (isValidResponse(response)) { - const { auth, data } = response.body; - setVaultJwt(auth); - const bids = data.bids.map(processBidResponse); - return bids; - } - return []; - }, -}; - -function setVaultJwt(auth) { - storageManager.setDataInLocalStorage(LOCAL_STORAGE_KEY.vault.jwt, auth); -} - -function getVaultJwt() { - return ( - storageManager.getDataFromLocalStorage(LOCAL_STORAGE_KEY.vault.jwt) || '' - ); -} - -function getReferer(bidderRequest) { - return bidderRequest?.refererInfo?.referer || ''; -} - -function buildQuery(bidderRequest) { - let url = appendQueryParam(ENDPOINT, 'ver', '$prebid.version$'); - - const timeout = config.getConfig('bidderTimeout'); - url = appendQueryParam(url, 'tmax', timeout); - - if (gdprApplies(bidderRequest)) { - const consentString = bidderRequest.gdprConsent.consentString; - url = appendQueryParam(url, 'gdpr', consentString); - } - - if (ccpaApplies(bidderRequest)) { - url = appendQueryParam(url, 'ccpa', bidderRequest.uspConsent); - } - - return url; -} - -function appendQueryParam(url, key, value) { - if (!value) { - return url; - } - const prefix = url.includes('?') ? '&' : '?'; - return `${url}${prefix}${key}=${encodeURIComponent(value)}`; -} - -function gdprApplies(bidderRequest) { - return Boolean(bidderRequest?.gdprConsent?.gdprApplies); -} - -function ccpaApplies(bidderRequest) { - return ( - isStr(bidderRequest.uspConsent) && - !isEmptyStr(bidderRequest.uspConsent) && - bidderRequest.uspConsent?.substr(1, 3) !== '---' - ); -} - -function processBidRequest(bid) { - const sizes = normalizeSizes(bid.sizes); - - return { - bid: bid.bidId, - pid: bid.params.pid, - sizes, - }; -} - -function normalizeSizes(sizes) { - const isSingleSize = - isArray(sizes) && - sizes.length === 2 && - !isArray(sizes[0]) && - !isArray(sizes[1]); - - if (isSingleSize) { - return [sizes]; - } - - return sizes; -} - -function getFirstPartyData() { - let fpd = config.getConfig('ortb2') || {}; - optimizeObject(fpd); - return fpd; -} - -function optimizeObject(obj) { - if (!isPlainObject(obj)) { - return; - } - for (const [key, value] of Object.entries(obj)) { - optimizeObject(value); - // only delete empty object, array, or string - if ( - (isPlainObject(value) || isArray(value) || isStr(value)) && - isEmpty(value) - ) { - delete obj[key]; - } - } -} - -function isValidResponse(bidResponse) { - const auth = bidResponse?.body?.auth; - const bids = bidResponse?.body?.data?.bids; - return isStr(auth) && isArray(bids) && !isEmpty(bids); -} - -function processBidResponse(bid) { - const meta = bid.meta || {}; - meta.advertiserDomains = bid.meta?.advertiserDomains || []; - - return { - ...bid, - meta, - }; -} - -registerBidder(spec); diff --git a/modules/glimpseBidAdapter.md b/modules/glimpseBidAdapter.md deleted file mode 100644 index e82c5d8f32e..00000000000 --- a/modules/glimpseBidAdapter.md +++ /dev/null @@ -1,37 +0,0 @@ -# Overview - -``` -Module Name: Glimpse Protocol Bid Adapter -Module Type: Bidder Adapter -Maintainer: publisher@glimpseprotocol.io -``` - -# Description - -This module connects publishers to Glimpse Protocol's demand sources via Prebid.js. Our innovative marketplace protects -consumer privacy while allowing precise targeting. It is compliant with GDPR, DPA and CCPA. - -The Glimpse Adapter supports banner formats. - -# Test Parameters - -```javascript -const adUnits = [ - { - code: 'banner-div-a', - mediaTypes: { - banner: { - sizes: [[300, 250]], - }, - }, - bids: [ - { - bidder: 'glimpse', - params: { - pid: 'e53a7f564f8f44cc913b', - }, - }, - ], - }, -]; -``` diff --git a/modules/globalsunBidAdapter.js b/modules/globalsunBidAdapter.js new file mode 100644 index 00000000000..5b5d97c2cac --- /dev/null +++ b/modules/globalsunBidAdapter.js @@ -0,0 +1,212 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'globalsun'; +const AD_URL = 'https://endpoint.globalsun.io/pbjs'; +const SYNC_URL = 'https://cs.globalsun.io'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/globalsunBidAdapter.md b/modules/globalsunBidAdapter.md new file mode 100644 index 00000000000..07c3ce32155 --- /dev/null +++ b/modules/globalsunBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: Globalsun Bidder Adapter +Module Type: Globalsun Bidder Adapter +Maintainer: prebid@globalsun.io +``` + +# Description + +Connects to Globalsun exchange for bids. +Globalsun bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'globalsun', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'globalsun', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'globalsun', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/glomexBidAdapter.js b/modules/glomexBidAdapter.js index 5cabd2515a9..10f5593940e 100644 --- a/modules/glomexBidAdapter.js +++ b/modules/glomexBidAdapter.js @@ -4,9 +4,11 @@ import {BANNER} from '../src/mediaTypes.js'; const ENDPOINT = 'https://prebid.mes.glomex.cloud/request-bid' const BIDDER_CODE = 'glomex' +const GVLID = 967 export const spec = { code: BIDDER_CODE, + gvlid: GVLID, supportedMediaTypes: [BANNER], isBidRequestValid: function (bid) { @@ -24,12 +26,14 @@ export const spec = { method: 'POST', url: `${ENDPOINT}`, data: { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidderRequest.auctionId, refererInfo: { + // TODO: this collects everything it finds, except for canonicalUrl isAmp: refererInfo.isAmp, numIframes: refererInfo.numIframes, reachedTop: refererInfo.reachedTop, - referer: refererInfo.referer + referer: refererInfo.topmostLocation, }, gdprConsent: { consentString: gdprConsent.consentString, diff --git a/modules/gmosspBidAdapter.js b/modules/gmosspBidAdapter.js index 087f74906fb..559f9f77aaf 100644 --- a/modules/gmosspBidAdapter.js +++ b/modules/gmosspBidAdapter.js @@ -1,7 +1,17 @@ -import { deepAccess, getDNT, getBidIdParameter, tryAppendQueryString, isEmpty, createTrackPixelHtml, logError, deepSetValue, getWindowTop, getWindowLocation } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER } from '../src/mediaTypes.js'; +import { + createTrackPixelHtml, + deepAccess, + deepSetValue, getBidIdParameter, + getDNT, + getWindowTop, + isEmpty, + logError +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; + const BIDDER_CODE = 'gmossp'; const ENDPOINT = 'https://sp.gmossp-sp.jp/hb/prebid/query.ad'; @@ -36,7 +46,7 @@ export const spec = { let queryString = ''; const request = validBidRequests[i]; - const tid = request.transactionId; + const tid = request.ortb2Imp?.ext?.tid; const bid = request.bidId; const imuid = deepAccess(request, 'userId.imuid'); const sharedId = deepAccess(request, 'userId.pubcid'); @@ -155,9 +165,10 @@ function getUrlInfo(refererInfo) { } return { - url: getUrl(refererInfo), canonicalLink: canonicalLink, - ref: getReferrer(), + // TODO: are these the right refererInfo values? + url: refererInfo.topmostLocation, + ref: refererInfo.ref || window.document.referrer, }; } @@ -169,24 +180,4 @@ function getMetaElements() { } } -function getUrl(refererInfo) { - if (refererInfo && refererInfo.referer) { - return refererInfo.referer; - } - - try { - return getWindowTop.location.href; - } catch (e) { - return getWindowLocation.href; - } -} - -function getReferrer() { - try { - return getWindowTop.document.referrer; - } catch (e) { - return document.referrer; - } -} - registerBidder(spec); diff --git a/modules/gnetBidAdapter.js b/modules/gnetBidAdapter.js index 274e8db2b50..38e96c183b9 100644 --- a/modules/gnetBidAdapter.js +++ b/modules/gnetBidAdapter.js @@ -4,10 +4,9 @@ import { BANNER } from '../src/mediaTypes.js'; import { getStorageManager } from '../src/storageManager.js'; import {ajax} from '../src/ajax.js'; -const storage = getStorageManager(); - const BIDDER_CODE = 'gnet'; const ENDPOINT = 'https://service.gnetrtb.com/api'; +const storage = getStorageManager({bidderCode: BIDDER_CODE}); export const spec = { code: BIDDER_CODE, @@ -31,7 +30,8 @@ export const spec = { */ buildRequests: function (validBidRequests, bidderRequest) { const bidRequests = []; - const referer = bidderRequest.refererInfo.referer; + // TODO: is 'page' the right value? + const referer = bidderRequest.refererInfo.page; _each(validBidRequests, (request) => { const data = {}; @@ -39,7 +39,7 @@ export const spec = { data.referer = referer; data.adUnitCode = request.adUnitCode; data.bidId = request.bidId; - data.transactionId = request.transactionId; + data.transactionId = request.ortb2Imp?.ext?.tid; data.gftuid = _getCookie(); data.sizes = parseSizesInput(request.sizes); diff --git a/modules/go2net.md b/modules/go2net.md deleted file mode 100644 index acea57b1c55..00000000000 --- a/modules/go2net.md +++ /dev/null @@ -1,29 +0,0 @@ -# Overview - -Module Name: Go2Net Bidder Adapter -Module Type: Bidder Adapter -Maintainer: vprytuzhalova@go2net.com.ua - -# Description - -Connects to Go2Net demand source to fetch bids. -Banner and Video formats are supported. -Please use ```go2net``` as the bidder code. - -# Ad Unit Example -``` - var adUnits = [ - { - code: 'desktop-banner-ad-div', - sizes: [[300, 250]], // a display size - bids: [ - { - bidder: "go2net", - params: { - zone: 'fb3d34d0-7a88-4a4a-a5c9-8088cd7845f4' - } - } - ] - } - ]; -``` diff --git a/modules/goldbachBidAdapter.js b/modules/goldbachBidAdapter.js index 46ae3054188..8892df130df 100644 --- a/modules/goldbachBidAdapter.js +++ b/modules/goldbachBidAdapter.js @@ -1,15 +1,9 @@ import {Renderer} from '../src/Renderer.js'; import { - chunk, - convertCamelToUnderscore, - convertTypes, createTrackPixelHtml, deepAccess, deepClone, - fill, getBidRequest, - getMaxValueFromArray, - getMinValueFromArray, getParameterByName, isArray, isArrayOfNums, @@ -20,15 +14,21 @@ import { isStr, logError, logInfo, - logMessage, - transformBidderParamKeywords + logMessage } from '../src/utils.js'; import {config} from '../src/config.js'; -import {getIabSubCategory, registerBidder} from '../src/adapters/bidderFactory.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; import {ADPOD, BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {auctionManager} from '../src/auctionManager.js'; import {find, includes} from '../src/polyfill.js'; import {INSTREAM, OUTSTREAM} from '../src/video.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {APPNEXUS_CATEGORY_MAPPING} from '../libraries/categoryTranslationMapping/index.js'; +import {getANKeywordParam, transformBidderParamKeywords} from '../libraries/appnexusUtils/anKeywords.js'; +import {convertCamelToUnderscore, fill} from '../libraries/appnexusUtils/anUtils.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; +import {chunk} from '../libraries/chunk/chunk.js'; const BIDDER_CODE = 'goldbach'; const URL = 'https://ib.adnxs.com/ut/v3/prebid'; @@ -84,7 +84,6 @@ const NATIVE_MAPPING = { }; const SOURCE = 'pbjs'; const MAX_IMPS_PER_REQUEST = 15; -const mappingFileUrl = 'https://acdn.adnxs-simple.com/prebid/appnexus-mapping/mappings.json'; const SCRIPT_TAG_START = ' { if (Array.isArray(bid.params.placementId)) { @@ -202,7 +204,7 @@ export const spec = { payload['iab_support'] = { omidpn: 'Appnexus', omidpv: '$prebid.version$' - } + }; } if (member > 0) { @@ -210,7 +212,7 @@ export const spec = { } if (appDeviceObjBid) { - payload.device = appDeviceObj + payload.device = appDeviceObj; } if (appIdObjBid) { payload.app = appIdObj; @@ -241,16 +243,17 @@ export const spec = { } if (bidderRequest && bidderRequest.uspConsent) { - payload.us_privacy = bidderRequest.uspConsent + payload.us_privacy = bidderRequest.uspConsent; } if (bidderRequest && bidderRequest.refererInfo) { let refererinfo = { - rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer), + // TODO: this collects everything it finds, except for topmostLocation + rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation), rd_top: bidderRequest.refererInfo.reachedTop, rd_ifs: bidderRequest.refererInfo.numIframes, rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') - } + }; payload.referrer_detection = refererinfo; } @@ -267,7 +270,6 @@ export const spec = { if (bidRequests[0].userId) { let eids = []; - addUserId(eids, deepAccess(bidRequests[0], `userId.flocId.id`), 'chrome.com', null); addUserId(eids, deepAccess(bidRequests[0], `userId.criteoId`), 'criteo.com', null); addUserId(eids, deepAccess(bidRequests[0], `userId.netId`), 'netid.de', null); addUserId(eids, deepAccess(bidRequests[0], `userId.idl_env`), 'liveramp.com', null); @@ -371,24 +373,6 @@ export const spec = { return bids; }, - /** - * @typedef {Object} mappingFileInfo - * @property {string} url mapping file json url - * @property {number} refreshInDays prebid stores mapping data in localstorage so you can return in how many days you want to update value stored in localstorage. - * @property {string} localStorageKey unique key to store your mapping json in localstorage - */ - - /** - * Returns mapping file info. This info will be used by bidderFactory to preload mapping file and store data in local storage - * @returns {mappingFileInfo} - */ - getMappingFileInfo: function () { - return { - url: mappingFileUrl, - refreshInDays: 2 - } - }, - getUserSyncs: function (syncOptions, responses, gdprConsent) { if (syncOptions.iframeEnabled && hasPurpose1Consent({gdprConsent})) { return [{ @@ -411,10 +395,6 @@ export const spec = { params.use_pmt_rule = (typeof params.usePaymentRule === 'boolean') ? params.usePaymentRule : false; if (params.usePaymentRule) { delete params.usePaymentRule; } - if (isPopulatedArray(params.keywords)) { - params.keywords.forEach(deleteValues); - } - Object.keys(params).forEach(paramKey => { let convertedKey = convertCamelToUnderscore(paramKey); if (convertedKey !== paramKey) { @@ -436,17 +416,7 @@ export const spec = { reloadViewabilityScriptWithCorrectParameters(bid); } } -} - -function isPopulatedArray(arr) { - return !!(isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} +}; function reloadViewabilityScriptWithCorrectParameters(bid) { let viewJsPayload = getAppnexusViewabilityScriptFromJsTrackers(bid.native.javascriptTrackers); @@ -454,7 +424,7 @@ function reloadViewabilityScriptWithCorrectParameters(bid) { if (viewJsPayload) { let prebidParams = 'pbjs_adid=' + bid.adId + ';pbjs_auc=' + bid.adUnitCode; - let jsTrackerSrc = getViewabilityScriptUrlFromPayload(viewJsPayload) + let jsTrackerSrc = getViewabilityScriptUrlFromPayload(viewJsPayload); let newJsTrackerSrc = jsTrackerSrc.replace('dom_id=%native_dom_id%', prebidParams); @@ -533,16 +503,6 @@ function getViewabilityScriptUrlFromPayload(viewJsPayload) { return jsTrackerSrc; } -function hasPurpose1Consent(bidderRequest) { - let result = true; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) { - result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} - function formatRequest(payload, bidderRequest) { let request = []; let options = { @@ -551,14 +511,14 @@ function formatRequest(payload, bidderRequest) { let endpointUrl = URL; - if (!hasPurpose1Consent(bidderRequest)) { + if (!hasPurpose1Consent(bidderRequest?.gdprConsent)) { endpointUrl = URL_SIMPLE; } if (getParameterByName('apn_test').toUpperCase() === 'TRUE' || config.getConfig('apn_test') === true) { options.customHeaders = { 'X-Is-Test': 1 - } + }; } if (payload.tags.length > MAX_IMPS_PER_REQUEST) { @@ -661,7 +621,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context'); switch (videoContext) { case ADPOD: - const primaryCatId = getIabSubCategory(bidRequest.bidder, rtbBid.brand_category_id); + const primaryCatId = (APPNEXUS_CATEGORY_MAPPING[rtbBid.brand_category_id]) ? APPNEXUS_CATEGORY_MAPPING[rtbBid.brand_category_id] : null; bid.meta = Object.assign({}, bid.meta, { primaryCatId }); const dealTier = rtbBid.deal_priority; bid.video = { @@ -771,7 +731,7 @@ function bidToTag(bid) { tag.code = bid.params.invCode; } tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false + tag.use_pmt_rule = bid.params.usePaymentRule || false; tag.prebid = true; tag.disable_psa = true; let bidFloor = getBidFloor(bid); @@ -802,14 +762,7 @@ function bidToTag(bid) { if (bid.params.externalImpId) { tag.external_imp_id = bid.params.externalImpId; } - if (!isEmpty(bid.params.keywords)) { - let keywords = transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - tag.keywords = keywords; - } + tag.keywords = getANKeywordParam(bid.ortb2, bid.params.keywords); let gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); if (gpid) { @@ -924,6 +877,7 @@ function bidToTag(bid) { tag['banner_frameworks'] = bid.params.frameworks; } + // TODO: why does this need to iterate through every ad unit? let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId); if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) { tag.ad_types.push(BANNER); @@ -1014,7 +968,7 @@ function createAdPodRequest(tags, adPodBid) { const { durationRangeSec, requireExactDuration } = adPodBid.mediaTypes.video; const numberOfPlacements = getAdPodPlacementNumber(adPodBid.mediaTypes.video); - const maxDuration = getMaxValueFromArray(durationRangeSec); + const maxDuration = Math.max(...durationRangeSec); const tagToDuplicate = tags.filter(tag => tag.uuid === adPodBid.bidId); let request = fill(...tagToDuplicate, numberOfPlacements); @@ -1040,7 +994,7 @@ function createAdPodRequest(tags, adPodBid) { function getAdPodPlacementNumber(videoParams) { const { adPodDurationSec, durationRangeSec, requireExactDuration } = videoParams; - const minAllowedDuration = getMinValueFromArray(durationRangeSec); + const minAllowedDuration = Math.min(...durationRangeSec); const numberOfPlacements = Math.floor(adPodDurationSec / minAllowedDuration); return requireExactDuration diff --git a/modules/googleAnalyticsAdapter.js b/modules/googleAnalyticsAdapter.js deleted file mode 100644 index b4c4c8c7009..00000000000 --- a/modules/googleAnalyticsAdapter.js +++ /dev/null @@ -1,298 +0,0 @@ -/** - * ga.js - analytics adapter for google analytics - */ - -import { _each, logMessage } from '../src/utils.js'; -var events = require('../src/events.js'); -var CONSTANTS = require('../src/constants.json'); -var adapterManager = require('../src/adapterManager.js').default; - -var BID_REQUESTED = CONSTANTS.EVENTS.BID_REQUESTED; -var BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT; -var BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE; -var BID_WON = CONSTANTS.EVENTS.BID_WON; - -var _disableInteraction = { nonInteraction: true }; -var _analyticsQueue = []; -var _gaGlobal = null; -var _enableCheck = true; -var _category = 'Prebid.js Bids'; -var _eventCount = 0; -var _enableDistribution = false; -var _cpmDistribution = null; -var _trackerSend = null; -var _sampled = true; -var _sendFloors = false; - -let adapter = {}; - -/** - * This will enable sending data to google analytics. Only call once, or duplicate data will be sent! - * @param {object} provider use to set GA global (if renamed); - * @param {object} options use to configure adapter; - * @return {[type]} [description] - */ -adapter.enableAnalytics = function ({ provider, options }) { - _gaGlobal = provider || 'ga'; - _trackerSend = options && options.trackerName ? options.trackerName + '.send' : 'send'; - _sampled = typeof options === 'undefined' || typeof options.sampling === 'undefined' || - Math.random() < parseFloat(options.sampling); - - if (options && typeof options.global !== 'undefined') { - _gaGlobal = options.global; - } - if (options && typeof options.enableDistribution !== 'undefined') { - _enableDistribution = options.enableDistribution; - } - if (options && typeof options.cpmDistribution === 'function') { - _cpmDistribution = options.cpmDistribution; - } - if (options && typeof options.sendFloors !== 'undefined') { - _sendFloors = options.sendFloors; - } - - var bid = null; - - if (_sampled) { - // first send all events fired before enableAnalytics called - - var existingEvents = events.getEvents(); - - _each(existingEvents, function (eventObj) { - if (typeof eventObj !== 'object') { - return; - } - var args = eventObj.args; - - if (eventObj.eventType === BID_REQUESTED) { - bid = args; - sendBidRequestToGa(bid); - } else if (eventObj.eventType === BID_RESPONSE) { - // bid is 2nd args - bid = args; - sendBidResponseToGa(bid); - } else if (eventObj.eventType === BID_TIMEOUT) { - const bidderArray = args; - sendBidTimeouts(bidderArray); - } else if (eventObj.eventType === BID_WON) { - bid = args; - sendBidWonToGa(bid); - } - }); - - // Next register event listeners to send data immediately - - // bidRequests - events.on(BID_REQUESTED, function (bidRequestObj) { - sendBidRequestToGa(bidRequestObj); - }); - - // bidResponses - events.on(BID_RESPONSE, function (bid) { - sendBidResponseToGa(bid); - }); - - // bidTimeouts - events.on(BID_TIMEOUT, function (bidderArray) { - sendBidTimeouts(bidderArray); - }); - - // wins - events.on(BID_WON, function (bid) { - sendBidWonToGa(bid); - }); - } else { - logMessage('Prebid.js google analytics disabled by sampling'); - } - - // finally set this function to return log message, prevents multiple adapter listeners - this.enableAnalytics = function _enable() { - return logMessage(`Analytics adapter already enabled, unnecessary call to \`enableAnalytics\`.`); - }; -}; - -adapter.getTrackerSend = function getTrackerSend() { - return _trackerSend; -}; - -/** - * Check if gaGlobal or window.ga is defined on page. If defined execute all the GA commands - */ -function checkAnalytics() { - if (_enableCheck && typeof window[_gaGlobal] === 'function') { - for (var i = 0; i < _analyticsQueue.length; i++) { - _analyticsQueue[i].call(); - } - - // override push to execute the command immediately from now on - _analyticsQueue.push = function (fn) { - fn.call(); - }; - - // turn check into NOOP - _enableCheck = false; - } - - logMessage('event count sent to GA: ' + _eventCount); -} - -function convertToCents(dollars) { - if (dollars) { - return Math.floor(dollars * 100); - } - - return 0; -} - -function getLoadTimeDistribution(time) { - var distribution; - if (time >= 0 && time < 200) { - distribution = '0-200ms'; - } else if (time >= 200 && time < 300) { - distribution = '0200-300ms'; - } else if (time >= 300 && time < 400) { - distribution = '0300-400ms'; - } else if (time >= 400 && time < 500) { - distribution = '0400-500ms'; - } else if (time >= 500 && time < 600) { - distribution = '0500-600ms'; - } else if (time >= 600 && time < 800) { - distribution = '0600-800ms'; - } else if (time >= 800 && time < 1000) { - distribution = '0800-1000ms'; - } else if (time >= 1000 && time < 1200) { - distribution = '1000-1200ms'; - } else if (time >= 1200 && time < 1500) { - distribution = '1200-1500ms'; - } else if (time >= 1500 && time < 2000) { - distribution = '1500-2000ms'; - } else if (time >= 2000) { - distribution = '2000ms above'; - } - - return distribution; -} - -function getCpmDistribution(cpm) { - if (_cpmDistribution) { - return _cpmDistribution(cpm); - } - var distribution; - if (cpm >= 0 && cpm < 0.5) { - distribution = '$0-0.5'; - } else if (cpm >= 0.5 && cpm < 1) { - distribution = '$0.5-1'; - } else if (cpm >= 1 && cpm < 1.5) { - distribution = '$1-1.5'; - } else if (cpm >= 1.5 && cpm < 2) { - distribution = '$1.5-2'; - } else if (cpm >= 2 && cpm < 2.5) { - distribution = '$2-2.5'; - } else if (cpm >= 2.5 && cpm < 3) { - distribution = '$2.5-3'; - } else if (cpm >= 3 && cpm < 4) { - distribution = '$3-4'; - } else if (cpm >= 4 && cpm < 6) { - distribution = '$4-6'; - } else if (cpm >= 6 && cpm < 8) { - distribution = '$6-8'; - } else if (cpm >= 8) { - distribution = '$8 above'; - } - - return distribution; -} - -function sendBidRequestToGa(bid) { - if (bid && bid.bidderCode) { - _analyticsQueue.push(function () { - _eventCount++; - if (_sendFloors) { - var floor = 'No Floor'; - if (bid.floorData) { - floor = bid.floorData.floorValue; - } else if (bid.bids.length) { - floor = bid.bids[0].getFloor().floor; - } - window[_gaGlobal](_trackerSend, 'event', _category, 'Requests by Floor=' + floor, bid.bidderCode, 1, _disableInteraction); - } else { - window[_gaGlobal](_trackerSend, 'event', _category, 'Requests', bid.bidderCode, 1, _disableInteraction); - } - }); - } - - // check the queue - checkAnalytics(); -} - -function sendBidResponseToGa(bid) { - if (bid && bid.bidderCode) { - _analyticsQueue.push(function () { - var cpmCents = convertToCents(bid.cpm); - var bidder = bid.bidderCode; - if (typeof bid.timeToRespond !== 'undefined' && _enableDistribution) { - _eventCount++; - var dis = getLoadTimeDistribution(bid.timeToRespond); - window[_gaGlobal](_trackerSend, 'event', 'Prebid.js Load Time Distribution', dis, bidder, 1, _disableInteraction); - } - - if (bid.cpm > 0) { - _eventCount = _eventCount + 2; - var cpmDis = getCpmDistribution(bid.cpm); - if (_enableDistribution) { - _eventCount++; - window[_gaGlobal](_trackerSend, 'event', 'Prebid.js CPM Distribution', cpmDis, bidder, 1, _disableInteraction); - } - if (_sendFloors) { - var floor = (bid.floorData) ? bid.floorData.floorValue : 'No Floor'; - window[_gaGlobal](_trackerSend, 'event', _category, 'Bids by Floor=' + floor, 'Size=' + bid.size + ',' + bidder, cpmCents, _disableInteraction); - } else { - window[_gaGlobal](_trackerSend, 'event', _category, 'Bids', bidder, cpmCents, _disableInteraction); - } - window[_gaGlobal](_trackerSend, 'event', _category, 'Bid Load Time', bidder, bid.timeToRespond, _disableInteraction); - } - }); - } - - // check the queue - checkAnalytics(); -} - -function sendBidTimeouts(timedOutBidders) { - _analyticsQueue.push(function () { - _each(timedOutBidders, function (bidderCode) { - _eventCount++; - var bidderName = bidderCode.bidder; - window[_gaGlobal](_trackerSend, 'event', _category, 'Timeouts', bidderName, _disableInteraction); - }); - }); - - checkAnalytics(); -} - -function sendBidWonToGa(bid) { - var cpmCents = convertToCents(bid.cpm); - _analyticsQueue.push(function () { - _eventCount++; - if (_sendFloors) { - var floor = (bid.floorData) ? bid.floorData.floorValue : 'No Floor'; - window[_gaGlobal](_trackerSend, 'event', _category, 'Wins by Floor=' + floor, 'Size=' + bid.size + ',' + bid.bidderCode, cpmCents, _disableInteraction); - } else { - window[_gaGlobal](_trackerSend, 'event', _category, 'Wins', bid.bidderCode, cpmCents, _disableInteraction); - } - }); - - checkAnalytics(); -} - -/** - * Exposed for testing purposes - */ -adapter.getCpmDistribution = getCpmDistribution; - -adapterManager.registerAnalyticsAdapter({ - adapter, - code: 'ga' -}); - -export default adapter; diff --git a/modules/googleAnalyticsAdapter.md b/modules/googleAnalyticsAdapter.md deleted file mode 100644 index 8c31b07b811..00000000000 --- a/modules/googleAnalyticsAdapter.md +++ /dev/null @@ -1,38 +0,0 @@ -# Google Analytics Adapter - -The google analytics adapter pushes prebid events into google analytics. - -## Usage - -The simplest way to enable the analytics adapter is this - -```javascript -pbjs.enableAnalytics([{ - provider: 'ga' -}]); -``` - -Defaults will be used and you should see events being pushed to analytics. - -You can customize the adapter with various `options` like this - -```javascript -pbjs.enableAnalytics([{ - provider: 'ga', - options: { ... } -}]); - -Here is a full list of settings available - -- `global` (string) - name of the global analytics object. Default is `ga` -- `trackerName` (string) - use another tracker for prebid events. Default is the default tracker -- `sampling` (number) - choose a value from `0` to `1`, where `0` means 0% and `1` means 100% tracked -- `enableDistribution` (boolean) - enables additional events that track load time and cpm distribution - by creating buckets for load time and cpm -- `cpmDistribution` (cpm: number => string) - customize the cpm buckets for the cpm distribution -- `sendFloors` (boolean) - if set, will include floor data in the eventCategory field and include ad unit code in eventAction field - - -## Additional resources - -- [Prebid GA Analytics](http://prebid.org/overview/ga-analytics.html) diff --git a/modules/gothamadsBidAdapter.js b/modules/gothamadsBidAdapter.js index 1993f0c9b64..9f44a54460f 100644 --- a/modules/gothamadsBidAdapter.js +++ b/modules/gothamadsBidAdapter.js @@ -2,6 +2,7 @@ import { logMessage, deepSetValue, deepAccess, _map, logWarn } from '../src/util import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'gothamads'; const ACCOUNTID_MACROS = '[account_id]'; @@ -68,14 +69,18 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + if (validBidRequests && validBidRequests.length === 0) return [] let accuontId = validBidRequests[0].params.accountId; const endpointURL = URL_ENDPOINT.replace(ACCOUNTID_MACROS, accuontId); let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page) winTop = window.top; } catch (e) { location = winTop.location; @@ -99,7 +104,7 @@ export const spec = { host: location.host }, source: { - tid: bidRequest.transactionId + tid: bidderRequest?.ortb2?.source?.tid, }, regs: { coppa: config.getConfig('coppa') === true ? 1 : 0, @@ -134,7 +139,7 @@ export const spec = { * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: (serverResponse) => { - if (!serverResponse || !serverResponse.body) return [] + if (!serverResponse || !serverResponse.body) return []; let GothamAdsResponse = serverResponse.body; let bids = []; @@ -219,7 +224,7 @@ const parseNative = admObject => { const prepareImpObject = (bidRequest) => { let impObject = { - id: bidRequest.transactionId, + id: bidRequest.bidId, secure: 1, ext: { placementId: bidRequest.params.placementId @@ -242,7 +247,8 @@ const prepareImpObject = (bidRequest) => { const addNativeParameters = bidRequest => { let impObject = { - id: bidRequest.transactionId, + // TODO: this is not an "impObject", and `id` is not part of the ORTB native spec + id: bidRequest.bidId, ver: NATIVE_VERSION, }; @@ -268,7 +274,7 @@ const addNativeParameters = bidRequest => { hmin = sizes[1]; } - asset[props.name] = {} + asset[props.name] = {}; if (bidParams.len) asset[props.name]['len'] = bidParams.len; if (props.type) asset[props.name]['type'] = props.type; diff --git a/modules/gppControl_usnat.js b/modules/gppControl_usnat.js new file mode 100644 index 00000000000..b38fc1a9d29 --- /dev/null +++ b/modules/gppControl_usnat.js @@ -0,0 +1,11 @@ +import {config} from '../src/config.js'; +import {setupRules} from '../libraries/mspa/activityControls.js'; + +let setupDone = false; + +config.getConfig('consentManagement', (cfg) => { + if (cfg?.consentManagement?.gpp != null && !setupDone) { + setupRules('usnat', [7]); + setupDone = true; + } +}) diff --git a/modules/gppControl_usstates.js b/modules/gppControl_usstates.js new file mode 100644 index 00000000000..bc2b434e085 --- /dev/null +++ b/modules/gppControl_usstates.js @@ -0,0 +1,176 @@ +import {config} from '../src/config.js'; +import {setupRules} from '../libraries/mspa/activityControls.js'; +import {deepSetValue, prefixLog} from '../src/utils.js'; + +const FIELDS = { + Version: 0, + Gpc: 0, + SharingNotice: 0, + SaleOptOutNotice: 0, + SharingOptOutNotice: 0, + TargetedAdvertisingOptOutNotice: 0, + SensitiveDataProcessingOptOutNotice: 0, + SensitiveDataLimitUseNotice: 0, + SaleOptOut: 0, + SharingOptOut: 0, + TargetedAdvertisingOptOut: 0, + SensitiveDataProcessing: 12, + KnownChildSensitiveDataConsents: 2, + PersonalDataConsents: 0, + MspaCoveredTransaction: 0, + MspaOptOutOptionMode: 0, + MspaServiceProviderMode: 0, +}; + +/** + * Generate a normalization function for converting US state strings to the usnat format. + * + * Scalar fields are copied over if they exist in the input (state) data, or set to null otherwise. + * List fields are also copied, but forced to the "correct" length (by truncating or padding with nulls); + * additionally, elements within them can be moved around using the `move` argument. + * + * @param {Array[String]} nullify? list of fields to force to null + * @param {{}} move? Map from list field name to an index remapping for elements within that field (using 1 as the first index). + * For example, {SensitiveDataProcessing: {1: 2, 2: [1, 3]}} means "rearrange SensitiveDataProcessing by moving + * the first element to the second position, and the second element to both the first and third position." + * @param {({}, {}) => void} fn? an optional function to run once all the processing described above is complete; + * it's passed two arguments, the original (state) data, and its normalized (usnat) version. + * @param fields + * @returns {function({}): {}} + */ +export function normalizer({nullify = [], move = {}, fn}, fields = FIELDS) { + move = Object.fromEntries(Object.entries(move).map(([k, map]) => [k, + Object.fromEntries(Object.entries(map) + .map(([k, v]) => [k, Array.isArray(v) ? v : [v]]) + .map(([k, v]) => [--k, v.map(el => --el)]) + )]) + ); + return function (cd) { + const norm = Object.fromEntries(Object.entries(fields) + .map(([field, len]) => { + let val = null; + if (len > 0) { + val = Array(len).fill(null); + if (Array.isArray(cd[field])) { + const remap = move[field] || {}; + const done = []; + cd[field].forEach((el, i) => { + const [dest, moved] = remap.hasOwnProperty(i) ? [remap[i], true] : [[i], false]; + dest.forEach(d => { + if (d < len && !done.includes(d)) { + val[d] = el; + moved && done.push(d); + } + }); + }); + } + } else if (cd[field] != null) { + val = Array.isArray(cd[field]) ? null : cd[field]; + } + return [field, val]; + })); + nullify.forEach(path => deepSetValue(norm, path, null)); + fn && fn(cd, norm); + return norm; + }; +} + +function scalarMinorsAreChildren(original, normalized) { + normalized.KnownChildSensitiveDataConsents = original.KnownChildSensitiveDataConsents === 0 ? [0, 0] : [1, 1]; +} + +export const NORMALIZATIONS = { + // normalization rules - convert state consent into usnat consent + // https://docs.prebid.org/features/mspa-usnat.html + 7: (consent) => consent, + 8: normalizer({ + move: { + SensitiveDataProcessing: { + 1: 9, + 2: 10, + 3: 8, + 4: [1, 2], + 5: 12, + 8: 3, + 9: 4, + } + }, + fn(original, normalized) { + if (original.KnownChildSensitiveDataConsents.some(el => el !== 0)) { + normalized.KnownChildSensitiveDataConsents = [1, 1]; + } + } + }), + 9: normalizer({fn: scalarMinorsAreChildren}), + 10: normalizer({fn: scalarMinorsAreChildren}), + 11: normalizer({ + move: { + SensitiveDataProcessing: { + 3: 4, + 4: 5, + 5: 3, + } + }, + fn: scalarMinorsAreChildren + }), + 12: normalizer({ + fn(original, normalized) { + const cc = original.KnownChildSensitiveDataConsents; + let repl; + if (!cc.some(el => el !== 0)) { + repl = [0, 0]; + } else if (cc[1] === 2 && cc[2] === 2) { + repl = [2, 1]; + } else { + repl = [1, 1]; + } + normalized.KnownChildSensitiveDataConsents = repl; + } + }) +}; + +export const DEFAULT_SID_MAPPING = { + 8: 'usca', + 9: 'usva', + 10: 'usco', + 11: 'usut', + 12: 'usct' +}; + +export const getSections = (() => { + const allSIDs = Object.keys(DEFAULT_SID_MAPPING).map(Number); + return function ({sections = {}, sids = allSIDs} = {}) { + return sids.map(sid => { + const logger = prefixLog(`Cannot set up MSPA controls for SID ${sid}:`); + const ov = sections[sid] || {}; + const normalizeAs = ov.normalizeAs || sid; + if (!NORMALIZATIONS.hasOwnProperty(normalizeAs)) { + logger.logError(`no normalization rules are known for SID ${normalizeAs}`) + return; + } + const api = ov.name || DEFAULT_SID_MAPPING[sid]; + if (typeof api !== 'string') { + logger.logError(`cannot determine GPP section name`) + return; + } + return [ + api, + [sid], + NORMALIZATIONS[normalizeAs] + ] + }).filter(el => el != null); + } +})(); + +const handles = []; + +config.getConfig('consentManagement', (cfg) => { + const gppConf = cfg.consentManagement?.gpp; + if (gppConf) { + while (handles.length) { + handles.pop()(); + } + getSections(gppConf?.mspa || {}) + .forEach(([api, sids, normalize]) => handles.push(setupRules(api, sids, normalize))); + } +}); diff --git a/modules/gptPreAuction.js b/modules/gptPreAuction.js index 71884235b38..bf5b4a55dbb 100644 --- a/modules/gptPreAuction.js +++ b/modules/gptPreAuction.js @@ -1,4 +1,11 @@ -import {deepAccess, isAdUnitCodeMatchingSlot, isGptPubadsDefined, logInfo, pick} from '../src/utils.js'; +import { + deepAccess, + isAdUnitCodeMatchingSlot, + isGptPubadsDefined, + logInfo, + pick, + deepSetValue +} from '../src/utils.js'; import {config} from '../src/config.js'; import {getHook} from '../src/hook.js'; import {find} from '../src/polyfill.js'; @@ -15,7 +22,8 @@ export const appendGptSlots = adUnits => { } const adUnitMap = adUnits.reduce((acc, adUnit) => { - acc[adUnit.code] = adUnit; + acc[adUnit.code] = acc[adUnit.code] || []; + acc[adUnit.code].push(adUnit); return acc; }, {}); @@ -25,15 +33,13 @@ export const appendGptSlots = adUnits => { : isAdUnitCodeMatchingSlot(slot)); if (matchingAdUnitCode) { - const adUnit = adUnitMap[matchingAdUnitCode]; - adUnit.ortb2Imp = adUnit.ortb2Imp || {}; - adUnit.ortb2Imp.ext = adUnit.ortb2Imp.ext || {}; - adUnit.ortb2Imp.ext.data = adUnit.ortb2Imp.ext.data || {}; - - const context = adUnit.ortb2Imp.ext.data; - context.adserver = context.adserver || {}; - context.adserver.name = 'gam'; - context.adserver.adslot = sanitizeSlotPath(slot.getAdUnitPath()); + const adserver = { + name: 'gam', + adslot: sanitizeSlotPath(slot.getAdUnitPath()) + }; + adUnitMap[matchingAdUnitCode].forEach((adUnit) => { + deepSetValue(adUnit, 'ortb2Imp.ext.data.adserver', Object.assign({}, adUnit.ortb2Imp?.ext?.data?.adserver, adserver)); + }); } }); }; diff --git a/modules/gravitoIdSystem.js b/modules/gravitoIdSystem.js new file mode 100644 index 00000000000..70031ebd06e --- /dev/null +++ b/modules/gravitoIdSystem.js @@ -0,0 +1,64 @@ +/** + * This module adds gravitompId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/gravitoIdSystem + * @requires module:modules/userId + */ + +import { submodule } from '../src/hook.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; + +const MODULE_NAME = 'gravitompId'; +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); + +export const cookieKey = 'gravitompId'; + +export const gravitoIdSystemSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + + /** + * performs action to obtain id + * @function + * @returns { {id: {gravitompId: string}} | undefined } + */ + getId: function() { + const newId = storage.getCookie(cookieKey); + if (!newId) { + return undefined; + } + const result = { + gravitompId: newId + } + return {id: result}; + }, + + /** + * decode the stored id value for passing to bid requests + * @function + * @param { {gravitompId: string} } value + * @returns { {gravitompId: {string} } | undefined } + */ + decode: function(value) { + if (value && typeof value === 'object') { + var result = {}; + if (value.gravitompId) { + result = value.gravitompId + } + return {gravitompId: result}; + } + return undefined; + }, + eids: { + 'gravitompId': { + source: 'gravito.net', + atype: 1 + }, + } +} + +submodule('userId', gravitoIdSystemSubmodule); diff --git a/modules/gravitoIdSystem.md b/modules/gravitoIdSystem.md new file mode 100644 index 00000000000..af4946779c5 --- /dev/null +++ b/modules/gravitoIdSystem.md @@ -0,0 +1,28 @@ +## Gravito User ID Submodule + +Gravito ID, provided by [Gravito Ltd.](https://gravito.net), is ID for ad targeting by using 1st party cookie. +Please contact Gravito Ltd. before using this ID. + +## Building Prebid with Gravito ID Support + +First, make sure to add the Gravito ID submodule to your Prebid.js package with: + +``` +gulp build --modules=gravitoIdSystem +``` + +The following configuration parameters are available: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'gravitompId' + }] + } +}); +``` + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | The name of this module. | `"gravitompId"` | diff --git a/modules/greenbidsAnalyticsAdapter.js b/modules/greenbidsAnalyticsAdapter.js new file mode 100644 index 00000000000..edc0c9c6c5c --- /dev/null +++ b/modules/greenbidsAnalyticsAdapter.js @@ -0,0 +1,175 @@ +import {ajax} from '../src/ajax.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager.js'; +import {deepClone, logError, logInfo} from '../src/utils.js'; + +const analyticsType = 'endpoint'; + +export const ANALYTICS_VERSION = '1.0.0'; + +const ANALYTICS_SERVER = 'https://a.greenbids.ai'; + +const { + EVENTS: { + AUCTION_END, + BID_TIMEOUT, + } +} = CONSTANTS; + +export const BIDDER_STATUS = { + BID: 'bid', + NO_BID: 'noBid', + TIMEOUT: 'timeout' +}; + +const analyticsOptions = {}; + +export const parseBidderCode = function (bid) { + let bidderCode = bid.bidderCode || bid.bidder; + return bidderCode.toLowerCase(); +}; + +export const greenbidsAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER, analyticsType}), { + + cachedAuctions: {}, + + initConfig(config) { + /** + * Required option: pbuid + * @type {boolean} + */ + analyticsOptions.options = deepClone(config.options); + if (typeof config.options.pbuid !== 'string' || config.options.pbuid.length < 1) { + logError('"options.pbuid" is required.'); + return false; + } + + analyticsOptions.pbuid = config.options.pbuid + analyticsOptions.server = ANALYTICS_SERVER; + return true; + }, + sendEventMessage(endPoint, data) { + logInfo(`AJAX: ${endPoint}: ` + JSON.stringify(data)); + + ajax(`${analyticsOptions.server}${endPoint}`, null, JSON.stringify(data), { + contentType: 'application/json' + }); + }, + createCommonMessage(auctionId) { + return { + version: ANALYTICS_VERSION, + auctionId: auctionId, + referrer: window.location.href, + sampling: analyticsOptions.options.sampling, + prebid: '$prebid.version$', + pbuid: analyticsOptions.pbuid, + adUnits: [], + }; + }, + serializeBidResponse(bid, status) { + return { + bidder: bid.bidder, + isTimeout: (status === BIDDER_STATUS.TIMEOUT), + hasBid: (status === BIDDER_STATUS.BID), + }; + }, + addBidResponseToMessage(message, bid, status) { + const adUnitCode = bid.adUnitCode.toLowerCase(); + const adUnitIndex = message.adUnits.findIndex((adUnit) => { + return adUnit.code === adUnitCode; + }); + if (adUnitIndex === -1) { + logError('Trying to add to non registered adunit'); + return; + } + const bidderIndex = message.adUnits[adUnitIndex].bidders.findIndex((bidder) => { + return bidder.bidder === bid.bidder; + }); + if (bidderIndex === -1) { + message.adUnits[adUnitIndex].bidders.push(this.serializeBidResponse(bid, status)); + } else { + if (status === BIDDER_STATUS.BID) { + message.adUnits[adUnitIndex].bidders[bidderIndex].hasBid = true; + } else if (status === BIDDER_STATUS.TIMEOUT) { + message.adUnits[adUnitIndex].bidders[bidderIndex].isTimeout = true; + } + } + }, + createBidMessage(auctionEndArgs, timeoutBids) { + logInfo(auctionEndArgs) + const {auctionId, timestamp, auctionEnd, adUnits, bidsReceived, noBids} = auctionEndArgs; + const message = this.createCommonMessage(auctionId); + + message.auctionElapsed = (auctionEnd - timestamp); + + adUnits.forEach((adUnit) => { + const adUnitCode = adUnit.code.toLowerCase(); + message.adUnits.push({ + code: adUnitCode, + mediaTypes: { + ...(adUnit.mediaTypes.banner !== undefined) && {banner: adUnit.mediaTypes.banner}, + ...(adUnit.mediaTypes.video !== undefined) && {video: adUnit.mediaTypes.video}, + ...(adUnit.mediaTypes.native !== undefined) && {native: adUnit.mediaTypes.native} + }, + bidders: [], + }); + }); + + // We enrich noBid then bids, then timeouts, because in case of a timeout, one response from a bidder + // Can be in the 3 arrays, and we want that case reflected in the call + noBids.forEach(bid => this.addBidResponseToMessage(message, bid, BIDDER_STATUS.NO_BID)); + + bidsReceived.forEach(bid => this.addBidResponseToMessage(message, bid, BIDDER_STATUS.BID)); + + timeoutBids.forEach(bid => this.addBidResponseToMessage(message, bid, BIDDER_STATUS.TIMEOUT)); + + return message; + }, + getCachedAuction(auctionId) { + this.cachedAuctions[auctionId] = this.cachedAuctions[auctionId] || { + timeoutBids: [], + }; + return this.cachedAuctions[auctionId]; + }, + handleAuctionEnd(auctionEndArgs) { + const cachedAuction = this.getCachedAuction(auctionEndArgs.auctionId); + this.sendEventMessage('/', + this.createBidMessage(auctionEndArgs, cachedAuction.timeoutBids) + ); + }, + handleBidTimeout(timeoutBids) { + timeoutBids.forEach((bid) => { + const cachedAuction = this.getCachedAuction(bid.auctionId); + cachedAuction.timeoutBids.push(bid); + }); + }, + track({eventType, args}) { + switch (eventType) { + case BID_TIMEOUT: + this.handleBidTimeout(args); + break; + case AUCTION_END: + this.handleAuctionEnd(args); + break; + } + }, + getAnalyticsOptions() { + return analyticsOptions; + }, +}); + +greenbidsAnalyticsAdapter.originEnableAnalytics = greenbidsAnalyticsAdapter.enableAnalytics; + +greenbidsAnalyticsAdapter.enableAnalytics = function(config) { + this.initConfig(config); + logInfo('loading greenbids analytics'); + greenbidsAnalyticsAdapter.originEnableAnalytics(config); +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: greenbidsAnalyticsAdapter, + code: 'greenbids' +}); + +export default greenbidsAnalyticsAdapter; diff --git a/modules/greenbidsAnalyticsAdapter.md b/modules/greenbidsAnalyticsAdapter.md new file mode 100644 index 00000000000..46e3af2c5e2 --- /dev/null +++ b/modules/greenbidsAnalyticsAdapter.md @@ -0,0 +1,23 @@ +# Overview + +``` +Module Name: Greenbids Analytics Adapter +Module Type: Analytics Adapter +Maintainer: jb@greenbids.ai +``` + +# Description + +Analytics adapter for Greenbids + +# Test Parameters + +``` +{ + provider: 'greenbids', + options: { + pbuid: "PBUID_FROM_GREENBIDS" + sampling: 1.0 + } +} +``` diff --git a/modules/greenbidsRtdProvider.js b/modules/greenbidsRtdProvider.js new file mode 100644 index 00000000000..b3d79f05996 --- /dev/null +++ b/modules/greenbidsRtdProvider.js @@ -0,0 +1,110 @@ +import { logError } from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; + +const MODULE_NAME = 'greenbidsRtdProvider'; +const MODULE_VERSION = '1.0.0'; +const ENDPOINT = 'https://t.greenbids.ai'; + +const auctionInfo = {}; +const rtdOptions = {}; + +function init(moduleConfig) { + let params = moduleConfig?.params; + if (!params?.pbuid) { + logError('Greenbids pbuid is not set!'); + return false; + } else { + rtdOptions.pbuid = params?.pbuid; + rtdOptions.targetTPR = params?.targetTPR || 0.99; + rtdOptions.timeout = params?.timeout || 200; + return true; + } +} + +function onAuctionInitEvent(auctionDetails) { + auctionInfo.auctionId = auctionDetails.auctionId; +} + +function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) { + let promise = createPromise(reqBidsConfigObj); + promise.then(callback); +} + +function createPromise(reqBidsConfigObj) { + return new Promise((resolve) => { + const timeoutId = setTimeout(() => { + resolve(reqBidsConfigObj); + }, rtdOptions.timeout); + ajax( + ENDPOINT, + { + success: (response) => { + processSuccessResponse(response, timeoutId, reqBidsConfigObj); + resolve(reqBidsConfigObj); + }, + error: () => { + clearTimeout(timeoutId); + resolve(reqBidsConfigObj); + }, + }, + createPayload(reqBidsConfigObj), + { contentType: 'application/json' } + ); + }); +} + +function processSuccessResponse(response, timeoutId, reqBidsConfigObj) { + clearTimeout(timeoutId); + const responseAdUnits = JSON.parse(response); + + updateAdUnitsBasedOnResponse(reqBidsConfigObj.adUnits, responseAdUnits); +} + +function updateAdUnitsBasedOnResponse(adUnits, responseAdUnits) { + adUnits.forEach((adUnit) => { + const matchingAdUnit = findMatchingAdUnit(responseAdUnits, adUnit.code); + if (matchingAdUnit) { + removeFalseBidders(adUnit, matchingAdUnit); + } + }); +} + +function findMatchingAdUnit(responseAdUnits, adUnitCode) { + return responseAdUnits.find((responseAdUnit) => responseAdUnit.code === adUnitCode); +} + +function removeFalseBidders(adUnit, matchingAdUnit) { + const falseBidders = getFalseBidders(matchingAdUnit.bidders); + adUnit.bids = adUnit.bids.filter((bidRequest) => !falseBidders.includes(bidRequest.bidder)); +} + +function getFalseBidders(bidders) { + return Object.entries(bidders) + .filter(([bidder, shouldKeep]) => !shouldKeep) + .map(([bidder]) => bidder); +} + +function createPayload(reqBidsConfigObj) { + return JSON.stringify({ + auctionId: auctionInfo.auctionId, + version: MODULE_VERSION, + referrer: window.location.href, + prebid: '$prebid.version$', + rtdOptions: rtdOptions, + adUnits: reqBidsConfigObj.adUnits, + }); +} + +export const greenbidsSubmodule = { + name: MODULE_NAME, + init: init, + onAuctionInitEvent: onAuctionInitEvent, + getBidRequestData: getBidRequestData, + updateAdUnitsBasedOnResponse: updateAdUnitsBasedOnResponse, + findMatchingAdUnit: findMatchingAdUnit, + removeFalseBidders: removeFalseBidders, + getFalseBidders: getFalseBidders, +}; + +submodule('realTimeData', greenbidsSubmodule); diff --git a/modules/greenbidsRtdProvider.md b/modules/greenbidsRtdProvider.md new file mode 100644 index 00000000000..85b8f5a7859 --- /dev/null +++ b/modules/greenbidsRtdProvider.md @@ -0,0 +1,65 @@ +# Overview + +``` +Module Name: Greenbids RTD Provider +Module Type: RTD Provider +Maintainer: jb@greenbids.ai +``` + +# Description + +The Greenbids RTD adapter allows to dynamically filter calls to SSP to reduce outgoing call to the programmatics chain, reducing ad serving carbon impact + +## Configuration + +This module is configured as part of the `realTimeData.dataProviders` object. + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +|------------|----------|----------------------------------------|---------------|----------| +| `name ` | required | Real time data module name | `'greenbidsRtdProvider'` | `string` | +| `waitForIt ` | required (mandatory true value) | Tells prebid auction to wait for the result of this module | `'true'` | `boolean` | +| `params` | required | | | `Object` | +| `params.pbuid` | required | The client site id provided by Greenbids. | `'TEST_FROM_GREENBIDS'` | `string` | +| `params.targetTPR` | optional (default 0.95) | Target True positive rate for the throttling model | `0.99` | `[0-1]` | +| `params.timeout` | optional (default 200) | Maximum amount of milliseconds allowed for module to finish working (has to be <= to the realTimeData.auctionDelay property) | `200` | `number` | + +#### Example + +```javascript +const greenbidsDataProvider = { + name: 'greenbidsRtdProvider', + waitForIt: true, + params: { + pbuid: 'TEST_FROM_GREENBIDS', + timeout: 200 + } +}; + +pbjs.setConfig({ + realTimeData: { + auctionDelay: 200, + dataProviders: [greenbidsDataProvider] + } +}); +``` + +## Integration +To install the module, follow these instructions: + +#### Step 1: Contact Greenbids to get a pbuid and account + +#### Step 2: Integrate the Greenbids Analytics Adapter + +Greenbids RTD module works hand in hand with Greenbids Analytics module +See prebid Analytics modules -> Greenbids Analytics module + +#### Step 3: Prepare the base Prebid file + +- Option 1: Use Prebid [Download](/download.html) page to build the prebid package. Ensure that you do check *Greenbids RTD Provider* module + +- Option 2: From the command line, run `gulp build --modules=greenbidsRtdProvider,...` + +#### Step 4: Set configuration + +Enable Greenbids Real Time Module using `pbjs.setConfig`. Example is provided in Configuration section. diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index e1090732071..aa00a84273c 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -1,4 +1,15 @@ -import { isEmpty, deepAccess, logError, parseGPTSingleSizeArrayToRtbSize, generateUUID, mergeDeep, logWarn } from '../src/utils.js'; +import { + isEmpty, + deepAccess, + logError, + parseGPTSingleSizeArrayToRtbSize, + generateUUID, + mergeDeep, + logWarn, + isNumber, + isStr +} from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { Renderer } from '../src/Renderer.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; @@ -7,17 +18,19 @@ import { getStorageManager } from '../src/storageManager.js'; const BIDDER_CODE = 'grid'; const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson'; +const USP_DELETE_DATA_HANDLER = 'https://media.grid.bidswitch.net/uspapi_delete' + const SYNC_URL = 'https://x.bidswitch.net/sync?ssp=themediagrid'; const TIME_TO_LIVE = 360; const USER_ID_KEY = 'tmguid'; const GVLID = 686; const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; -export const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); +export const storage = getStorageManager({ bidderCode: BIDDER_CODE }); + const LOG_ERROR_MESS = { - noAuid: 'Bid from response has no auid parameter - ', + noAdid: 'Bid from response has no adid parameter - ', noAdm: 'Bid from response has no adm parameter - ', noBid: 'Array of bid objects is empty', - noPlacementCode: 'Can\'t find in requested bids the bid with auid - ', emptyUids: 'Uids should be not empty', emptySeatbid: 'Seatbid array from response has empty item', emptyResponse: 'Response is empty', @@ -25,11 +38,27 @@ const LOG_ERROR_MESS = { hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' }; +const ALIAS_CONFIG = { + 'trustx': { + endpoint: 'https://grid.bidswitch.net/hbjson?sp=trustx', + syncurl: 'https://x.bidswitch.net/sync?ssp=themediagrid', + bidResponseExternal: { + netRevenue: false + } + }, + 'gridNM': { + defaultParams: { + multiRequest: true + } + }, +}; + let hasSynced = false; export const spec = { code: BIDDER_CODE, - aliases: ['playwire', 'adlivetech'], + gvlid: GVLID, + aliases: ['playwire', 'adlivetech', 'gridNM', { code: 'trustx', skipPbsAliasing: true }], supportedMediaTypes: [ BANNER, VIDEO ], /** * Determines whether or not the given bid request is valid. @@ -38,7 +67,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function(bid) { - return !!bid.params.uid; + return bid && Boolean(bid.params.uid || bid.params.secid); }, /** * Make a server request from the list of BidRequests. @@ -52,60 +81,65 @@ export const spec = { return null; } let pageKeywords = null; - let jwpseg = null; let content = null; let schain = null; let userIdAsEids = null; let user = null; let userExt = null; - let {bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo} = bidderRequest || {}; + let endpoint = null; + let forceBidderName = false; + let {bidderRequestId, gdprConsent, uspConsent, timeout, refererInfo, gppConsent} = bidderRequest || {}; - const referer = refererInfo ? encodeURIComponent(refererInfo.referer) : ''; + const referer = refererInfo ? encodeURIComponent(refererInfo.page) : ''; + const tmax = parseInt(timeout) || null; const imp = []; const bidsMap = {}; + const requests = []; + const sources = []; + const bidsArray = []; validBidRequests.forEach((bid) => { + const bidObject = { bid, savedPrebidBid: null }; + if (!bid.params.uid && !bid.params.secid) { + return; + } if (!bidderRequestId) { bidderRequestId = bid.bidderRequestId; } - if (!auctionId) { - auctionId = bid.auctionId; - } if (!schain) { schain = bid.schain; } if (!userIdAsEids) { userIdAsEids = bid.userIdAsEids; } - const {params: {uid, keywords}, mediaTypes, bidId, adUnitCode, rtd, ortb2Imp} = bid; - bidsMap[bidId] = bid; + if (!endpoint) { + endpoint = ALIAS_CONFIG[bid.bidder] && ALIAS_CONFIG[bid.bidder].endpoint; + } + const { params, mediaTypes, bidId, adUnitCode, rtd, ortb2Imp } = bid; + const { defaultParams } = ALIAS_CONFIG[bid.bidder] || {}; + const { secid, pubid, source, uid, keywords, forceBidder, multiRequest, content: bidParamsContent, video: videoParams } = { ...defaultParams, ...params }; const bidFloor = _getFloor(mediaTypes || {}, bid); const jwTargeting = rtd && rtd.jwplayer && rtd.jwplayer.targeting; - if (jwTargeting) { - if (!jwpseg && jwTargeting.segments) { - jwpseg = jwTargeting.segments; - } - if (!content && jwTargeting.content) { - content = jwTargeting.content; - } + if (jwTargeting && !content && jwTargeting.content) { + content = jwTargeting.content; } + let impObj = { id: bidId.toString(), - tagid: uid.toString(), + tagid: (secid || uid).toString(), ext: { divid: adUnitCode.toString() } }; if (ortb2Imp) { if (ortb2Imp.instl) { - impObj.instl = ortb2Imp.instl; + impObj.instl = parseInt(ortb2Imp.instl) || null; } - if (ortb2Imp.ext && ortb2Imp.ext.data) { - impObj.ext.data = ortb2Imp.ext.data; - if (impObj.ext.data.adserver && impObj.ext.data.adserver.adslot) { - impObj.ext.gpid = impObj.ext.data.adserver.adslot.toString(); - } else { - impObj.ext.gpid = ortb2Imp.ext.data.pbadslot && ortb2Imp.ext.data.pbadslot.toString(); + + if (ortb2Imp.ext) { + impObj.ext.gpid = ortb2Imp.ext.gpid?.toString() || ortb2Imp.ext.data?.pbadslot?.toString() || ortb2Imp.ext.data?.adserver?.adslot?.toString(); + if (ortb2Imp.ext.data) { + impObj.ext.data = ortb2Imp.ext.data; } } } @@ -127,19 +161,67 @@ export const spec = { } } if (mediaTypes && mediaTypes[VIDEO]) { - const video = createVideoRequest(bid, mediaTypes[VIDEO]); + const video = createVideoRequest(videoParams, mediaTypes[VIDEO], bid.sizes); if (video) { impObj.video = video; } } if (impObj.banner || impObj.video) { - imp.push(impObj); + if (multiRequest) { + const reqSource = { + tid: bidderRequest?.ortb2?.source?.tid?.toString?.(), + ext: { + wrapper: 'Prebid_js', + wrapper_version: '$prebid.version$' + } + }; + if (bid.schain) { + reqSource.ext.schain = bid.schain; + } + const request = { + id: bid.bidderRequestId && bid.bidderRequestId.toString(), + site: { + page: referer, + }, + tmax, + source: reqSource, + imp: [impObj] + }; + + if (pubid) { + request.site.publisher = { id: pubid }; + } + + const siteContent = bidParamsContent || (jwTargeting && jwTargeting.content); + + if (siteContent) { + request.site.content = siteContent; + } + + requests.push(request); + sources.push(source); + bidsArray.push(bidObject); + } else { + bidsMap[bidId] = bidObject; + imp.push(impObj); + } + } + + if (!forceBidderName && forceBidder && ALIAS_CONFIG[forceBidder]) { + forceBidderName = forceBidder; } }); - const source = { - tid: auctionId && auctionId.toString(), + forceBidderName = config.getConfig('forceBidderName') || forceBidderName; + + if (forceBidderName && ALIAS_CONFIG[forceBidderName]) { + endpoint = ALIAS_CONFIG[forceBidderName].endpoint; + this.forceBidderName = forceBidderName; + } + + const reqSource = { + tid: bidderRequest?.ortb2?.source?.tid?.toString?.(), ext: { wrapper: 'Prebid_js', wrapper_version: '$prebid.version$' @@ -147,161 +229,188 @@ export const spec = { }; if (schain) { - source.ext.schain = schain; + reqSource.ext.schain = schain; } - const bidderTimeout = config.getConfig('bidderTimeout') || timeout; - const tmax = timeout ? Math.min(bidderTimeout, timeout) : bidderTimeout; - - let request = { + const mainRequest = (imp.length || !requests.length) ? { id: bidderRequestId && bidderRequestId.toString(), site: { page: referer }, tmax, - source, + source: reqSource, imp - }; + } : null; if (content) { - request.site.content = content; + mainRequest.site.content = content; } - if (jwpseg && jwpseg.length) { - user = { - data: [{ - name: 'iow_labs_pub_data', - segment: segmentProcessing(jwpseg, 'jwpseg'), - }] - }; - } + [...requests, mainRequest].forEach((request) => { + if (!request) { + return; + } + + user = null; - const ortb2UserData = config.getConfig('ortb2.user.data'); - if (ortb2UserData && ortb2UserData.length) { - if (!user) { - user = { data: [] }; + const ortb2UserData = deepAccess(bidderRequest, 'ortb2.user.data'); + if (ortb2UserData && ortb2UserData.length) { + user = { data: [...ortb2UserData] }; } - user = mergeDeep(user, { - data: [...ortb2UserData] - }); - } - if (gdprConsent && gdprConsent.consentString) { - userExt = {consent: gdprConsent.consentString}; - } + if (gdprConsent && gdprConsent.consentString) { + userExt = {consent: gdprConsent.consentString}; + } - const ortb2UserExtDevice = config.getConfig('ortb2.user.ext.device'); - if (ortb2UserExtDevice) { - userExt = userExt || {}; - userExt.device = { ...ortb2UserExtDevice }; - } + const ortb2UserExtDevice = deepAccess(bidderRequest, 'ortb2.user.ext.device'); + if (ortb2UserExtDevice) { + userExt = userExt || {}; + userExt.device = { ...ortb2UserExtDevice }; + } - if (userIdAsEids && userIdAsEids.length) { - userExt = userExt || {}; - userExt.eids = [...userIdAsEids]; - } + if (userIdAsEids && userIdAsEids.length) { + userExt = userExt || {}; + userExt.eids = [...userIdAsEids]; + } - if (userExt && Object.keys(userExt).length) { - user = user || {}; - user.ext = userExt; - } + if (userExt && Object.keys(userExt).length) { + user = user || {}; + user.ext = userExt; + } - const fpdUserId = getUserIdFromFPDStorage(); + const fpdUserId = getUserIdFromFPDStorage(); - if (fpdUserId) { - user = user || {}; - user.id = fpdUserId.toString(); - } + if (fpdUserId) { + user = user || {}; + user.id = fpdUserId.toString(); + } - if (user) { - request.user = user; - } + if (user) { + request.user = user; + } - const userKeywords = deepAccess(config.getConfig('ortb2.user'), 'keywords') || null; - const siteKeywords = deepAccess(config.getConfig('ortb2.site'), 'keywords') || null; + const userKeywords = deepAccess(bidderRequest, 'ortb2.user.keywords') || null; + const siteKeywords = deepAccess(bidderRequest, 'ortb2.site.keywords') || null; - if (userKeywords) { - pageKeywords = pageKeywords || {}; - pageKeywords.user = pageKeywords.user || {}; - pageKeywords.user.ortb2 = [ - { - name: 'keywords', - keywords: userKeywords.split(','), - } - ]; - } - if (siteKeywords) { - pageKeywords = pageKeywords || {}; - pageKeywords.site = pageKeywords.site || {}; - pageKeywords.site.ortb2 = [ - { - name: 'keywords', - keywords: siteKeywords.split(','), - } - ]; - } + if (userKeywords) { + pageKeywords = pageKeywords || {}; + pageKeywords.user = pageKeywords.user || {}; + pageKeywords.user.ortb2 = [ + { + name: 'keywords', + keywords: userKeywords.split(','), + } + ]; + } + if (siteKeywords) { + pageKeywords = pageKeywords || {}; + pageKeywords.site = pageKeywords.site || {}; + pageKeywords.site.ortb2 = [ + { + name: 'keywords', + keywords: siteKeywords.split(','), + } + ]; + } - if (pageKeywords) { - pageKeywords = reformatKeywords(pageKeywords); if (pageKeywords) { - request.ext = { - keywords: pageKeywords + pageKeywords = reformatKeywords(pageKeywords); + if (pageKeywords) { + request.ext = { + keywords: pageKeywords + }; + } + } + + if (gdprConsent && gdprConsent.gdprApplies) { + request.regs = { + ext: { + gdpr: gdprConsent.gdprApplies ? 1 : 0 + } }; } - } + const ortb2Regs = deepAccess(bidderRequest, 'ortb2.regs') || {}; + if (gppConsent || ortb2Regs?.gpp) { + const gpp = { + gpp: gppConsent?.gppString ?? ortb2Regs?.gpp, + gpp_sid: gppConsent?.applicableSections ?? ortb2Regs?.gpp_sid + }; + request.regs = mergeDeep(request?.regs ?? {}, gpp); + } - if (gdprConsent && gdprConsent.gdprApplies) { - request.regs = { - ext: { - gdpr: gdprConsent.gdprApplies ? 1 : 0 + if (uspConsent) { + if (!request.regs) { + request.regs = {ext: {}}; + } + if (!request.regs.ext) { + request.regs.ext = {}; } + request.regs.ext.us_privacy = uspConsent; } - } - if (uspConsent) { - if (!request.regs) { - request.regs = {ext: {}}; + if (config.getConfig('coppa') === true) { + if (!request.regs) { + request.regs = {}; + } + request.regs.coppa = 1; } - request.regs.ext.us_privacy = uspConsent; - } - if (config.getConfig('coppa') === true) { - if (!request.regs) { - request.regs = {}; + const site = deepAccess(bidderRequest, 'ortb2.site'); + if (site) { + const pageCategory = [...(site.cat || []), ...(site.pagecat || [])].filter((category) => { + return category && typeof category === 'string' + }); + if (pageCategory.length) { + request.site.cat = pageCategory; + } + const genre = deepAccess(site, 'content.genre'); + if (genre && typeof genre === 'string') { + request.site.content = {...request.site.content, genre}; + } + const data = deepAccess(site, 'content.data'); + if (data && data.length) { + const siteContent = request.site.content || {}; + request.site.content = mergeDeep(siteContent, { data }); + } + const id = deepAccess(site, 'content.id'); + if (id) { + request.site.content = {...request.site.content, id}; + } } - request.regs.coppa = 1; - } + }); - const site = config.getConfig('ortb2.site'); - if (site) { - const pageCategory = [...(site.cat || []), ...(site.pagecat || [])].filter((category) => { - return category && typeof category === 'string' + return [...requests.map((req, i) => { + let sp; + const url = (endpoint || ENDPOINT_URL).replace(/[?&]sp=([^?&=]+)/, (i, found) => { + if (found) { + sp = found; + } + return ''; }); - if (pageCategory.length) { - request.site.cat = pageCategory; - } - const genre = deepAccess(site, 'content.genre'); - if (genre && typeof genre === 'string') { - request.site.content = {...request.site.content, genre}; - } - } - - return { + let currentSource = sources[i] || sp; + const urlWithParams = url + (url.indexOf('?') > -1 ? '&' : '?') + 'no_mapping=1' + (currentSource ? `&sp=${currentSource}` : ''); + return { + method: 'POST', + url: urlWithParams, + data: JSON.stringify(req), + bidObject: bidsArray[i], + }; + }), ...(mainRequest ? [{ method: 'POST', - url: ENDPOINT_URL, - data: JSON.stringify(request), - newFormat: true, + url: endpoint || ENDPOINT_URL, + data: JSON.stringify(mainRequest), bidsMap - }; + }] : [])]; }, /** * Unpack the response from the server into a list of bids. * * @param {*} serverResponse A successful response from the server. * @param {*} bidRequest + * @param {*} RendererConst * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse, bidRequest) { + interpretResponse: function (serverResponse, bidRequest, RendererConst = Renderer) { serverResponse = serverResponse && serverResponse.body; const bidResponses = []; @@ -312,15 +421,18 @@ export const spec = { errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; } + const bidderCode = this.forceBidderName || this.code; + if (!errorMessage && serverResponse.seatbid) { serverResponse.seatbid.forEach(respItem => { - _addBidResponse(_getBidFromResponse(respItem), bidRequest, bidResponses); + _addBidResponse(_getBidFromResponse(respItem), bidRequest, bidResponses, RendererConst, bidderCode); }); } if (errorMessage) logError(errorMessage); return bidResponses; }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { + getUserSyncs: function (...args) { + const [syncOptions,, gdprConsent, uspConsent] = args; if (!hasSynced && syncOptions.pixelEnabled) { let params = ''; @@ -336,12 +448,32 @@ export const spec = { params += `&us_privacy=${uspConsent}`; } + const bidderCode = this.forceBidderName || this.code; + const syncUrl = (ALIAS_CONFIG[bidderCode] && ALIAS_CONFIG[bidderCode].syncurl) || SYNC_URL; + hasSynced = true; return { type: 'image', - url: SYNC_URL + params + url: syncUrl + params }; } + }, + + ajaxCall: function(url, cb, data, options) { + return ajax(url, cb, data, options); + }, + + onDataDeletionRequest: function(data) { + const uids = []; + const aliases = [spec.code, ...spec.aliases.map((alias) => alias.code || alias)]; + data.forEach(({ bids }) => bids && bids.forEach(({ bidder, params }) => { + if (aliases.includes(bidder) && params && params.uid) { + uids.push(params.uid); + } + })); + if (uids.length) { + spec.ajaxCall(USP_DELETE_DATA_HANDLER, () => {}, JSON.stringify({ uids }), {contentType: 'application/json', method: 'POST'}); + } } }; @@ -353,7 +485,7 @@ export const spec = { */ function _getFloor (mediaTypes, bid) { const curMediaType = mediaTypes.video ? 'video' : 'banner'; - let floor = bid.params.bidFloor || 0; + let floor = parseFloat(bid.params.bidFloor || bid.params.floorcpm || 0) || null; if (typeof bid.getFloor === 'function') { const floorInfo = bid.getFloor({ @@ -383,20 +515,21 @@ function _getBidFromResponse(respItem) { return respItem && respItem.bid && respItem.bid[0]; } -function _addBidResponse(serverBid, bidRequest, bidResponses) { +function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst, bidderCode) { if (!serverBid) return; let errorMessage; - if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid); + if (!serverBid.adid) errorMessage = LOG_ERROR_MESS.noAdid + JSON.stringify(serverBid); if (!errorMessage && !serverBid.adm && !serverBid.nurl) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); else { - const bid = bidRequest.bidsMap[serverBid.impid]; - if (bid) { + const bidObject = bidRequest.bidsMap ? bidRequest.bidsMap[serverBid.impid] : bidRequest.bidObject; + const { bid, savedPrebidBid } = bidObject || {}; + if (bid && canPublishResponse(serverBid.price, savedPrebidBid && savedPrebidBid.cpm)) { const bidResponse = { requestId: bid.bidId, // bid.bidderRequestId cpm: serverBid.price, width: serverBid.w, height: serverBid.h, - creativeId: serverBid.auid, // bid.bidId + creativeId: serverBid.adid, currency: 'USD', netRevenue: true, ttl: TIME_TO_LIVE, @@ -406,6 +539,8 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) { dealId: serverBid.dealid }; + bidObject.savedPrebidBid = bidResponse; + if (serverBid.ext && serverBid.ext.bidder && serverBid.ext.bidder.grid && serverBid.ext.bidder.grid.demandSource) { bidResponse.adserverTargeting = { 'hb_ds': serverBid.ext.bidder.grid.demandSource }; bidResponse.meta.demandSource = serverBid.ext.bidder.grid.demandSource; @@ -425,13 +560,14 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) { bidResponse.renderer = createRenderer(bidResponse, { id: bid.bidId, url: RENDERER_URL - }); + }, RendererConst); } } else { bidResponse.ad = serverBid.adm; bidResponse.mediaType = BANNER; } - bidResponses.push(bidResponse); + const bidResponseExternal = (ALIAS_CONFIG[bidderCode] && ALIAS_CONFIG[bidderCode].bidResponseExternal) || {}; + bidResponses.push(mergeDeep(bidResponse, bidResponseExternal)); } } if (errorMessage) { @@ -439,27 +575,41 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) { } } -function createVideoRequest(bid, mediaType) { - const {playerSize, mimes, durationRangeSec, protocols} = mediaType; - const size = (playerSize || bid.sizes || [])[0]; - if (!size) return; +function createVideoRequest(videoParams, mediaType, bidSizes) { + const { mind, maxd, size, playerSize, protocols, durationRangeSec = [], ...videoData } = { ...mediaType, ...videoParams }; + if (size && isStr(size)) { + const sizeArray = size.split('x'); + if (sizeArray.length === 2 && parseInt(sizeArray[0]) && parseInt(sizeArray[1])) { + videoData.w = parseInt(sizeArray[0]); + videoData.h = parseInt(sizeArray[1]); + } + } + if (!videoData.w || !videoData.h) { + const pSizesString = (playerSize || bidSizes || []).toString(); + const pSizeString = (pSizesString.match(/^\d+,\d+/) || [])[0]; + const pSize = pSizeString && pSizeString.split(',').map((d) => parseInt(d)); + if (pSize && pSize.length === 2) { + Object.assign(videoData, parseGPTSingleSizeArrayToRtbSize(pSize)); + } + } + + if (!videoData.w || !videoData.h) return; - let result = parseGPTSingleSizeArrayToRtbSize(size); + const minDur = mind || durationRangeSec[0] || parseInt(videoData.minduration) || null; + const maxDur = maxd || durationRangeSec[1] || parseInt(videoData.maxduration) || null; - if (mimes) { - result.mimes = mimes; + if (minDur) { + videoData.minduration = minDur; } - - if (durationRangeSec && durationRangeSec.length === 2) { - result.minduration = durationRangeSec[0]; - result.maxduration = durationRangeSec[1]; + if (maxDur) { + videoData.maxduration = maxDur; } if (protocols && protocols.length) { - result.protocols = protocols; + videoData.protocols = protocols; } - return result; + return videoData; } function createBannerRequest(bid, mediaType) { @@ -489,22 +639,6 @@ function getUserIdFromFPDStorage() { return storage.getDataFromLocalStorage(USER_ID_KEY) || makeNewUserIdInFPDStorage(); } -function segmentProcessing(segment, forceSegName) { - return segment - .map((seg) => { - const value = seg && (seg.value || seg.id || seg); - if (typeof value === 'string' || typeof value === 'number') { - return { - value: value.toString(), - ...(forceSegName && { name: forceSegName }), - ...(seg.name && { name: seg.name }), - }; - } - return null; - }) - .filter((seg) => !!seg); -} - function reformatKeywords(pageKeywords) { const formatedPageKeywords = {}; Object.keys(pageKeywords).forEach((name) => { @@ -550,6 +684,13 @@ function reformatKeywords(pageKeywords) { return Object.keys(formatedPageKeywords).length && formatedPageKeywords; } +function canPublishResponse(price, savedPrice) { + if (isNumber(savedPrice)) { + return price > savedPrice || (price === savedPrice && Math.random() > 0.5); + } + return true; +} + function outstreamRender (bid) { bid.renderer.push(() => { window.ANOutstreamVideo.renderAd({ @@ -559,8 +700,8 @@ function outstreamRender (bid) { }); } -function createRenderer (bid, rendererParams) { - const renderer = Renderer.install({ +function createRenderer (bid, rendererParams, RendererConst) { + const renderer = RendererConst.install({ id: rendererParams.id, url: rendererParams.url, loaded: false diff --git a/modules/gridNMBidAdapter.js b/modules/gridNMBidAdapter.js deleted file mode 100644 index 3c46b25b8e1..00000000000 --- a/modules/gridNMBidAdapter.js +++ /dev/null @@ -1,411 +0,0 @@ -import { isStr, deepAccess, isArray, isNumber, logError, logWarn, parseGPTSingleSizeArrayToRtbSize } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { Renderer } from '../src/Renderer.js'; -import { VIDEO } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; - -const BIDDER_CODE = 'gridNM'; -const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson'; -const SYNC_URL = 'https://x.bidswitch.net/sync?ssp=themediagrid'; -const TIME_TO_LIVE = 360; -const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; - -let hasSynced = false; - -const LOG_ERROR_MESS = { - noAdm: 'Bid from response has no adm parameter - ', - noPrice: 'Bid from response has no price parameter - ', - wrongContentType: 'Bid from response has wrong content_type parameter - ', - noBid: 'Array of bid objects is empty', - noPlacementCode: 'Can\'t find in requested bids the bid with auid - ', - emptyUids: 'Uids should be not empty', - emptySeatbid: 'Seatbid array from response has empty item', - emptyResponse: 'Response is empty', - hasEmptySeatbidArray: 'Response has empty seatbid array', - hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - ' -}; - -const VIDEO_KEYS = ['mimes', 'protocols', 'startdelay', 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', 'api', 'companiontype']; - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [ VIDEO ], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - let invalid = - !bid.params.source || !isStr(bid.params.source) || - !bid.params.secid || !isStr(bid.params.secid) || - !bid.params.pubid || !isStr(bid.params.pubid); - - const video = deepAccess(bid, 'mediaTypes.video') || {}; - const { protocols = video.protocols, mimes = video.mimes } = deepAccess(bid, 'params.video') || {}; - if (!invalid) { - invalid = !protocols || !mimes; - } - if (!invalid) { - invalid = !isArray(mimes) || !mimes.length || mimes.filter((it) => !(it && isStr(it))).length; - if (!invalid) { - invalid = !isArray(protocols) || !protocols.length || protocols.filter((it) => !(isNumber(it) && it > 0 && !(it % 1))).length; - } - } - return !invalid; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {BidRequest[]} validBidRequests - an array of bids - * @param {bidderRequest} bidderRequest bidder request object - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests, bidderRequest) { - const bids = validBidRequests || []; - const requests = []; - let { bidderRequestId, auctionId, gdprConsent, uspConsent, timeout, refererInfo } = bidderRequest || {}; - - const referer = refererInfo ? encodeURIComponent(refererInfo.referer) : ''; - - bids.forEach(bid => { - let user; - let userExt; - - const schain = bid.schain; - const userIdAsEids = bid.userIdAsEids; - - if (!bidderRequestId) { - bidderRequestId = bid.bidderRequestId; - } - if (!auctionId) { - auctionId = bid.auctionId; - } - const { - params: { floorcpm, pubdata, source, secid, pubid, content, video }, - mediaTypes, bidId, adUnitCode, rtd, ortb2Imp, sizes - } = bid; - - const bidFloor = _getFloor(mediaTypes || {}, bid, isNumber(floorcpm) && floorcpm); - const jwTargeting = rtd && rtd.jwplayer && rtd.jwplayer.targeting; - const jwpseg = (pubdata && pubdata.jwpseg) || (jwTargeting && jwTargeting.segments); - - const siteContent = content || (jwTargeting && jwTargeting.content); - - const impObj = { - id: bidId.toString(), - tagid: secid.toString(), - video: createVideoForImp(video, sizes, mediaTypes && mediaTypes.video), - ext: { - divid: adUnitCode.toString() - } - }; - - if (ortb2Imp && ortb2Imp.ext && ortb2Imp.ext.data) { - impObj.ext.data = ortb2Imp.ext.data; - if (impObj.ext.data.adserver && impObj.ext.data.adserver.adslot) { - impObj.ext.gpid = impObj.ext.data.adserver.adslot.toString(); - } else { - impObj.ext.gpid = ortb2Imp.ext.data.pbadslot && ortb2Imp.ext.data.pbadslot.toString(); - } - } - - if (bidFloor) { - impObj.bidfloor = bidFloor; - } - - const imp = [impObj]; - - const reqSource = { - tid: auctionId && auctionId.toString(), - ext: { - wrapper: 'Prebid_js', - wrapper_version: '$prebid.version$' - } - }; - - if (schain) { - reqSource.ext.schain = schain; - } - - const bidderTimeout = config.getConfig('bidderTimeout') || timeout; - const tmax = timeout ? Math.min(bidderTimeout, timeout) : bidderTimeout; - - const request = { - id: bidderRequestId && bidderRequestId.toString(), - site: { - page: referer, - publisher: { - id: pubid, - }, - }, - source: reqSource, - tmax, - imp, - }; - - if (siteContent) { - request.site.content = siteContent; - } - - if (jwpseg && jwpseg.length) { - user = { - data: [{ - name: 'iow_labs_pub_data', - segment: jwpseg.map((seg) => { - return {name: 'jwpseg', value: seg}; - }) - }] - }; - } - - if (gdprConsent && gdprConsent.consentString) { - userExt = { consent: gdprConsent.consentString }; - } - - if (userIdAsEids && userIdAsEids.length) { - userExt = userExt || {}; - userExt.eids = [...userIdAsEids]; - } - - if (userExt && Object.keys(userExt).length) { - user = user || {}; - user.ext = userExt; - } - - if (user) { - request.user = user; - } - - if (gdprConsent && gdprConsent.gdprApplies) { - request.regs = { - ext: { - gdpr: gdprConsent.gdprApplies ? 1 : 0 - } - } - } - - if (uspConsent) { - if (!request.regs) { - request.regs = { ext: {} }; - } - request.regs.ext.us_privacy = uspConsent; - } - - if (config.getConfig('coppa') === true) { - if (!request.regs) { - request.regs = {}; - } - request.regs.coppa = 1; - } - - requests.push({ - method: 'POST', - url: ENDPOINT_URL + '?no_mapping=1&sp=' + source, - bid: bid, - data: request - }); - }); - - return requests; - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @param {*} bidRequest - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - serverResponse = serverResponse && serverResponse.body; - const bidResponses = []; - - let errorMessage; - - if (!serverResponse) errorMessage = LOG_ERROR_MESS.emptyResponse; - else if (serverResponse.seatbid && !serverResponse.seatbid.length) { - errorMessage = LOG_ERROR_MESS.hasEmptySeatbidArray; - } - - if (!errorMessage && serverResponse.seatbid) { - const serverBid = _getBidFromResponse(serverResponse.seatbid[0]); - if (serverBid) { - if (!serverBid.adm && !serverBid.nurl) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid); - else if (!serverBid.price) errorMessage = LOG_ERROR_MESS.noPrice + JSON.stringify(serverBid); - else if (serverBid.content_type !== 'video') errorMessage = LOG_ERROR_MESS.wrongContentType + serverBid.content_type; - if (!errorMessage) { - const bid = bidRequest.bid; - const bidResponse = { - requestId: bid.bidId, - cpm: serverBid.price, - width: serverBid.w, - height: serverBid.h, - creativeId: serverBid.auid || bid.bidderRequestId, - currency: 'USD', - netRevenue: true, - ttl: TIME_TO_LIVE, - dealId: serverBid.dealid, - mediaType: VIDEO, - meta: { - advertiserDomains: serverBid.adomain ? serverBid.adomain : [] - } - }; - - if (serverBid.adm) { - bidResponse.vastXml = serverBid.adm; - bidResponse.adResponse = { - content: bidResponse.vastXml - }; - } else if (serverBid.nurl) { - bidResponse.vastUrl = serverBid.nurl; - } - - if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) { - bidResponse.renderer = createRenderer(bidResponse, { - id: bid.bidId, - url: RENDERER_URL - }); - } - bidResponses.push(bidResponse); - } - } - } - if (errorMessage) logError(errorMessage); - return bidResponses; - }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { - if (!hasSynced && syncOptions.pixelEnabled) { - let params = ''; - - if (gdprConsent && typeof gdprConsent.consentString === 'string') { - if (typeof gdprConsent.gdprApplies === 'boolean') { - params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; - } else { - params += `&gdpr_consent=${gdprConsent.consentString}`; - } - } - if (uspConsent) { - params += `&us_privacy=${uspConsent}`; - } - - hasSynced = true; - return { - type: 'image', - url: SYNC_URL + params - }; - } - } -}; - -/** - * Gets bidfloor - * @param {Object} mediaTypes - * @param {Object} bid - * @param {Number} floor - * @returns {Number} floor - */ -function _getFloor (mediaTypes, bid, floor) { - const curMediaType = mediaTypes.video ? 'video' : 'banner'; - - if (typeof bid.getFloor === 'function') { - const floorInfo = bid.getFloor({ - currency: 'USD', - mediaType: curMediaType, - size: bid.sizes.map(([w, h]) => ({w, h})) - }); - - if (typeof floorInfo === 'object' && - floorInfo.currency === 'USD' && - !isNaN(parseFloat(floorInfo.floor))) { - floor = Math.max(floor, parseFloat(floorInfo.floor)); - } - } - - return floor; -} - -function _getBidFromResponse(respItem) { - if (!respItem) { - logError(LOG_ERROR_MESS.emptySeatbid); - } else if (!respItem.bid) { - logError(LOG_ERROR_MESS.hasNoArrayOfBids + JSON.stringify(respItem)); - } else if (!respItem.bid[0]) { - logError(LOG_ERROR_MESS.noBid); - } - return respItem && respItem.bid && respItem.bid[0]; -} - -function outstreamRender (bid) { - bid.renderer.push(() => { - window.ANOutstreamVideo.renderAd({ - targetId: bid.adUnitCode, - adResponse: bid.adResponse - }); - }); -} - -function createRenderer (bid, rendererParams) { - const renderer = Renderer.install({ - id: rendererParams.id, - url: rendererParams.url, - loaded: false - }); - - try { - renderer.setRender(outstreamRender); - } catch (err) { - logWarn('Prebid Error calling setRender on renderer', err); - } - - return renderer; -} - -function createVideoForImp({ mind, maxd, size, ...paramsVideo }, bidSizes, bidVideo = {}) { - VIDEO_KEYS.forEach((key) => { - if (!(key in paramsVideo) && key in bidVideo) { - paramsVideo[key] = bidVideo[key]; - } - }); - - if (size && isStr(size)) { - const sizeArray = size.split('x'); - if (sizeArray.length === 2 && parseInt(sizeArray[0]) && parseInt(sizeArray[1])) { - paramsVideo.w = parseInt(sizeArray[0]); - paramsVideo.h = parseInt(sizeArray[1]); - } - } - - if (!paramsVideo.w || !paramsVideo.h) { - const playerSizes = bidVideo.playerSize && bidVideo.playerSize.length === 2 ? bidVideo.playerSize : bidSizes; - if (playerSizes) { - const playerSize = playerSizes[0]; - if (playerSize) { - Object.assign(paramsVideo, parseGPTSingleSizeArrayToRtbSize(playerSize)); - } - } - } - - const durationRangeSec = bidVideo.durationRangeSec || []; - const minDur = mind || durationRangeSec[0] || bidVideo.minduration; - const maxDur = maxd || durationRangeSec[1] || bidVideo.maxduration; - - if (minDur) { - paramsVideo.minduration = minDur; - } - if (maxDur) { - paramsVideo.maxduration = maxDur; - } - - return paramsVideo; -} - -export function resetUserSync() { - hasSynced = false; -} - -export function getSyncUrl() { - return SYNC_URL; -} - -registerBidder(spec); diff --git a/modules/gridNMBidAdapter.md b/modules/gridNMBidAdapter.md deleted file mode 100644 index 6decdde7f4c..00000000000 --- a/modules/gridNMBidAdapter.md +++ /dev/null @@ -1,39 +0,0 @@ -# Overview - -Module Name: The Grid Media Bidder Adapter -Module Type: Bidder Adapter -Maintainer: grid-tech@themediagrid.com - -# Description - -Module that connects to Grid demand source to fetch bids. -Grid bid adapter supports Banner and Video (instream and outstream). - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - video: { - playerSize: [728, 90], - context: 'outstream' - } - }, - bids: [ - { - bidder: "gridNM", - params: { - source: 'jwp', - secid: '11', - pubid: '22', - video: { - mimes: ['video/mp4', 'video/x-ms-wmv'], - protocols: [1,2,3,4,5,6] - } - } - } - ] - } - ]; -``` diff --git a/modules/growadvertisingBidAdapter.js b/modules/growadvertisingBidAdapter.js index 286d27607c5..f6f7867f0fe 100644 --- a/modules/growadvertisingBidAdapter.js +++ b/modules/growadvertisingBidAdapter.js @@ -1,8 +1,9 @@ 'use strict'; -import { getBidIdParameter, deepAccess, _each, triggerPixel } from '../src/utils.js'; +import {deepAccess, _each, triggerPixel, getBidIdParameter} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'growads'; @@ -15,6 +16,9 @@ export const spec = { }, buildRequests: function (validBidRequests) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let zoneId; let domain; let requestURI; @@ -101,7 +105,8 @@ export const spec = { netRevenue: true, ttl: response.ttl, adUnitCode: request.adUnitCode, - referrer: deepAccess(request, 'refererInfo.referer') + // TODO: is 'page' the right value here? + referrer: deepAccess(request, 'refererInfo.page') }; if (response.hasOwnProperty(NATIVE)) { diff --git a/modules/growthCodeAnalyticsAdapter.js b/modules/growthCodeAnalyticsAdapter.js new file mode 100644 index 00000000000..5c7cc254f1d --- /dev/null +++ b/modules/growthCodeAnalyticsAdapter.js @@ -0,0 +1,185 @@ +/** + * growthCodeAnalyticsAdapter.js - GrowthCode Analytics Adapter + */ +import { ajax } from '../src/ajax.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import CONSTANTS from '../src/constants.json'; +import {getStorageManager} from '../src/storageManager.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {logError, logInfo} from '../src/utils.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; + +const MODULE_NAME = 'growthCodeAnalytics'; +const DEFAULT_PID = 'INVALID_PID' +const ENDPOINT_URL = 'https://analytics.gcprivacy.com/v3/pb/analytics' + +export const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_NAME}); + +let sessionId = utils.generateUUID(); + +let trackEvents = []; +let pid = DEFAULT_PID; +let url = ENDPOINT_URL; + +let eventQueue = []; + +let startAuction = 0; +let bidRequestTimeout = 0; +let analyticsType = 'endpoint'; + +let growthCodeAnalyticsAdapter = Object.assign(adapter({url: url, analyticsType}), { + track({eventType, args}) { + let eventData = args ? JSON.parse(JSON.stringify(args)) : {}; + let data = {}; + if (!trackEvents.includes(eventType)) return; + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: { + data = eventData; + startAuction = data.timestamp; + bidRequestTimeout = data.timeout; + break; + } + + case CONSTANTS.EVENTS.AUCTION_END: { + data = eventData; + data.start = startAuction; + data.end = Date.now(); + break; + } + + case CONSTANTS.EVENTS.BID_ADJUSTMENT: { + data.bidders = eventData; + break; + } + + case CONSTANTS.EVENTS.BID_TIMEOUT: { + data.bidders = eventData; + data.duration = bidRequestTimeout; + break; + } + + case CONSTANTS.EVENTS.BID_REQUESTED: { + data = eventData; + break; + } + + case CONSTANTS.EVENTS.BID_RESPONSE: { + data = eventData; + delete data.ad; + break; + } + + case CONSTANTS.EVENTS.BID_WON: { + data = eventData; + delete data.ad; + delete data.adUrl; + break; + } + + case CONSTANTS.EVENTS.BIDDER_DONE: { + data = eventData; + break; + } + + case CONSTANTS.EVENTS.SET_TARGETING: { + data.targetings = eventData; + break; + } + + case CONSTANTS.EVENTS.REQUEST_BIDS: { + data = eventData; + break; + } + + case CONSTANTS.EVENTS.ADD_AD_UNITS: { + data = eventData; + break; + } + + case CONSTANTS.EVENTS.NO_BID: { + data = eventData + break; + } + + default: + return; + } + + data.eventType = eventType; + data.timestamp = data.timestamp || Date.now(); + + sendEvent(data); + } +}); + +growthCodeAnalyticsAdapter.originEnableAnalytics = growthCodeAnalyticsAdapter.enableAnalytics; + +growthCodeAnalyticsAdapter.enableAnalytics = function(conf = {}) { + if (typeof conf.options === 'object') { + if (conf.options.pid) { + pid = conf.options.pid; + url = conf.options.url ? conf.options.url : ENDPOINT_URL; + } else { + logError(MODULE_NAME + ' Not a valid PartnerID') + return + } + if (conf.options.trackEvents) { + trackEvents = conf.options.trackEvents; + } + } else { + logError(MODULE_NAME + ' Invalid configuration'); + return; + } + + growthCodeAnalyticsAdapter.originEnableAnalytics(conf); +}; + +function logToServer() { + if (pid === DEFAULT_PID) return; + if (eventQueue.length >= 1) { + // Get the correct GCID + let gcid = localStorage.getItem('gcid') + + let data = { + session: sessionId, + pid: pid, + gcid: gcid, + timestamp: Date.now(), + url: getRefererInfo().page, + referer: document.referrer, + events: eventQueue + }; + + ajax(url, { + success: response => { + logInfo(MODULE_NAME + ' Send Data to Server') + }, + error: error => { + logInfo(MODULE_NAME + ' Problem Send Data to Server: ' + error) + } + }, JSON.stringify(data), {method: 'POST', withCredentials: true}) + + eventQueue = [ + ]; + } +} + +function sendEvent(event) { + eventQueue.push(event); + logInfo(MODULE_NAME + 'Analytics Event: ' + event); + + if ((event.eventType === CONSTANTS.EVENTS.AUCTION_END) || (event.eventType === CONSTANTS.EVENTS.BID_WON)) { + logToServer(); + } +} + +adapterManager.registerAnalyticsAdapter({ + adapter: growthCodeAnalyticsAdapter, + code: 'growthCodeAnalytics' +}); + +growthCodeAnalyticsAdapter.logToServer = logToServer; + +export default growthCodeAnalyticsAdapter; diff --git a/modules/growthCodeAnalyticsAdapter.md b/modules/growthCodeAnalyticsAdapter.md new file mode 100644 index 00000000000..6625d492ee6 --- /dev/null +++ b/modules/growthCodeAnalyticsAdapter.md @@ -0,0 +1,35 @@ +## GrowthCode Analytics Adapter + +[GrowthCode](https://growthcode.io) offers scaled infrastructure-as-a-service to +empower independent publishers to harness data and take control of identity and +audience while rapidly aligning to industry changes and margin pressure. + +## Building Prebid with GrowthCode Support + +First, make sure to add the GrowthCode submodule to your Prebid.js package with: + +``` +gulp build --modules=growthCodeIdSystem,growthCodeAnalyticsAdapter,userId +``` + +The following configuration parameters are available: + +```javascript +pbjs.enableAnalytics({ + provider: 'growthCodeAnalytics', + options: { + pid: '', + trackEvents: [ + 'auctionEnd', + 'bidWon'] + } +}); +``` + +| Param enableAnalytics | Scope | Type | Description | Example | +|-----------------------|----------|--------|-------------------------------------------------------------|--------------------------| +| provider | Required | String | The name of this Adapter. | `"growthCodeAnalytics"` | +| params | Required | Object | Details of module params. | | +| params.pid | Required | String | This is the Customer ID value obtained via Intimate Merger. | `""` | +| params.url | Optional | String | Custom URL for server | | +| params.trackEvents | Required | String | Name if the variable that holds your publisher ID | | diff --git a/modules/growthCodeIdSystem.js b/modules/growthCodeIdSystem.js new file mode 100644 index 00000000000..e50a4e73019 --- /dev/null +++ b/modules/growthCodeIdSystem.js @@ -0,0 +1,192 @@ +/** + * This module adds GrowthCodeId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/growthCodeIdSystem + * @requires module:modules/userId + */ + +import {logError, logInfo, pick} from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; +import { submodule } from '../src/hook.js' +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; + +const MODULE_NAME = 'growthCodeId'; +const GC_DATA_KEY = '_gc_data'; +const GCID_KEY = 'gcid'; +const ENDPOINT_URL = 'https://p2.gcprivacy.com/v1/pb?' + +export const storage = getStorageManager({ moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME }); + +/** + * Read GrowthCode data from cookie or local storage + * @param key + * @return {string} + */ +export function readData(key) { + try { + let payload + if (storage.cookiesAreEnabled(null)) { + payload = tryParse(storage.getCookie(key, null)) + } + if (storage.hasLocalStorage()) { + payload = tryParse(storage.getDataFromLocalStorage(key, null)) + } + if (payload !== undefined) { + if (payload.expire_at > (Date.now() / 1000)) { + return payload + } + } + } catch (error) { + logError(error); + } +} + +/** + * Store GrowthCode data in either cookie or local storage + * expiration date: 45 days + * @param key + * @param {string} value + */ +function storeData(key, value) { + try { + logInfo(MODULE_NAME + ': storing data: key=' + key + ' value=' + value); + + if (value) { + if (storage.hasLocalStorage(null)) { + storage.setDataInLocalStorage(key, value, null); + } + } + } catch (error) { + logError(error); + } +} + +/** + * Parse json if possible, else return null + * @param data + * @param {object|null} + */ +function tryParse(data) { + let payload; + try { + payload = JSON.parse(data); + if (payload == null) { + return undefined + } + return payload + } catch (err) { + return undefined; + } +} + +/** @type {Submodule} */ +export const growthCodeIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + /** + * decode the stored id value for passing to bid requests + * @function + * @param {{string}} value + * @returns {{growthCodeId: {string}}|undefined} + */ + decode(value) { + return value && value !== '' ? { 'growthCodeId': value } : undefined; + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} [config] + * @returns {IdResponse|undefined} + */ + getId(config, consentData) { + const configParams = (config && config.params) || {}; + if (!configParams || typeof configParams.pid !== 'string') { + logError('User ID - GrowthCodeID submodule requires a valid Partner ID to be defined'); + return; + } + + const gdpr = (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) ? 1 : 0; + const consentString = gdpr ? consentData.consentString : ''; + if (gdpr && !consentString) { + logInfo('Consent string is required to call GrowthCode id.'); + return; + } + + let publisherId = configParams.publisher_id ? configParams.publisher_id : '_sharedID'; + + let sharedId; + if (configParams.publisher_id_storage === 'html5') { + sharedId = storage.getDataFromLocalStorage(publisherId, null) ? (storage.getDataFromLocalStorage(publisherId, null)) : null; + } else { + sharedId = storage.getCookie(publisherId, null) ? (storage.getCookie(publisherId, null)) : null; + } + if (!sharedId) { + logError('User ID - Publisher ID is not correctly setup.'); + } + + const resp = function(callback) { + let gcData = readData(GC_DATA_KEY); + if (gcData) { + callback(gcData); + } else { + let segment = window.location.pathname.substr(1).replace(/\/+$/, ''); + if (segment === '') { + segment = 'home'; + } + + let url = configParams.url ? configParams.url : ENDPOINT_URL; + url = tryAppendQueryString(url, 'pid', configParams.pid); + url = tryAppendQueryString(url, 'uid', sharedId); + url = tryAppendQueryString(url, 'u', window.location.href); + url = tryAppendQueryString(url, 'h', window.location.hostname); + url = tryAppendQueryString(url, 's', segment); + url = tryAppendQueryString(url, 'r', document.referrer); + + ajax(url, { + success: response => { + let respJson = tryParse(response); + // If response is a valid json and should save is true + if (respJson) { + storeData(GC_DATA_KEY, JSON.stringify(respJson)) + storeData(GCID_KEY, respJson.gc_id); + callback(respJson); + } else { + callback(); + } + }, + error: error => { + logError(MODULE_NAME + ': ID fetch encountered an error', error); + callback(); + } + }, undefined, {method: 'GET', withCredentials: true}) + } + }; + return { callback: resp }; + }, + eids: { + 'growthCodeId': { + getValue: function(data) { + return data.gc_id + }, + source: 'growthcode.io', + atype: 1, + getUidExt: function(data) { + const extendedData = pick(data, [ + 'h1', + 'h2', + 'h3', + ]); + if (Object.keys(extendedData).length) { + return extendedData; + } + } + }, + } +}; + +submodule('userId', growthCodeIdSubmodule); diff --git a/modules/growthCodeIdSystem.md b/modules/growthCodeIdSystem.md new file mode 100644 index 00000000000..f804686a7a9 --- /dev/null +++ b/modules/growthCodeIdSystem.md @@ -0,0 +1,37 @@ +## GrowthCode User ID Submodule + +GrowthCode provides Id Enrichment for requests. + +## Building Prebid with GrowthCode Support + +First, make sure to add the GrowthCode submodule to your Prebid.js package with: + +``` +gulp build --modules=growthCodeIdSystem,userId +``` + +The following configuration parameters are available: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'growthCodeId', + params: { + pid: 'TEST01', // Set your Partner ID here for production (obtained from Growthcode) + publisher_id: '_sharedID', + publisher_id_storage: 'html5' + } + }] + } +}); +``` + +| Param under userSync.userIds[] | Scope | Type | Description | Example | +|--------------------------------|----------|--------| --- |-----------------| +| name | Required | String | The name of this module. | `"growthCodeId"` | +| params | Required | Object | Details of module params. | | +| params.pid | Required | String | This is the Parter ID value obtained from GrowthCode | `"TEST01"` | +| params.url | Optional | String | Custom URL for server | | +| params.publisher_id | Optional | String | Name if the variable that holds your publisher ID | `"_sharedID"` | +| params.publisher_id_storage | Optional | String | Publisher ID storage (cookie, html5) | `"html5"` | diff --git a/modules/growthCodeRtdProvider.js b/modules/growthCodeRtdProvider.js new file mode 100644 index 00000000000..ef5c7906ad7 --- /dev/null +++ b/modules/growthCodeRtdProvider.js @@ -0,0 +1,132 @@ +/** + * This module adds GrowthCode HEM and other Data to Bid Requests + * @module modules/growthCodeRtdProvider + */ +import { submodule } from '../src/hook.js' +import { getStorageManager } from '../src/storageManager.js'; +import { + logMessage, logError, mergeDeep +} from '../src/utils.js'; +import * as ajax from '../src/ajax.js'; +import { MODULE_TYPE_RTD } from '../src/activities/modules.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; + +const MODULE_NAME = 'growthCodeRtd'; +const LOG_PREFIX = 'GrowthCodeRtd: '; +const ENDPOINT_URL = 'https://p2.gcprivacy.com/v2/rtd?' +const RTD_EXPIRE_KEY = 'gc_rtd_expires_at' +const RTD_CACHE_KEY = 'gc_rtd_items' + +export const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: MODULE_NAME }); +let items + +export const growthCodeRtdProvider = { + name: MODULE_NAME, + init: init, + getBidRequestData: alterBidRequests, + addData: addData, + callServer: callServer +}; + +/** + * Parse json if possible, else return null + * @param data + * @returns {any|null} + */ +function tryParse(data) { + try { + return JSON.parse(data); + } catch (err) { + logError(err); + return null; + } +} + +/** + * Init The RTD Module + * @param config + * @param userConsent + * @returns {boolean} + */ +function init(config, userConsent) { + logMessage(LOG_PREFIX + 'Init RTB'); + + if (config == null) { + return false + } + + const configParams = (config && config.params) || {}; + let expiresAt = parseInt(storage.getDataFromLocalStorage(RTD_EXPIRE_KEY, null)); + + items = tryParse(storage.getDataFromLocalStorage(RTD_CACHE_KEY, null)); + + return callServer(configParams, items, expiresAt, userConsent); +} +function callServer(configParams, items, expiresAt, userConsent) { + // Expire Cache + let now = Math.trunc(Date.now() / 1000); + if ((!isNaN(expiresAt)) && (now > expiresAt)) { + expiresAt = NaN; + storage.removeDataFromLocalStorage(RTD_CACHE_KEY, null) + storage.removeDataFromLocalStorage(RTD_EXPIRE_KEY, null) + } + if ((items === null) && (isNaN(expiresAt))) { + let gcid = localStorage.getItem('gcid') + + let url = configParams.url ? configParams.url : ENDPOINT_URL; + url = tryAppendQueryString(url, 'pid', configParams.pid); + url = tryAppendQueryString(url, 'u', window.location.href); + url = tryAppendQueryString(url, 'gcid', gcid); + if ((userConsent !== null) && (userConsent.gdpr !== null) && (userConsent.gdpr.consentData.getTCData.tcString)) { + url = tryAppendQueryString(url, 'tcf', userConsent.gdpr.consentData.getTCData.tcString) + } + + ajax.ajaxBuilder()(url, { + success: response => { + let respJson = tryParse(response); + // If response is a valid json and should save is true + if (respJson && respJson.results >= 1) { + storage.setDataInLocalStorage(RTD_CACHE_KEY, JSON.stringify(respJson.items), null); + storage.setDataInLocalStorage(RTD_EXPIRE_KEY, respJson.expires_at, null) + } else { + storage.setDataInLocalStorage(RTD_EXPIRE_KEY, respJson.expires_at, null) + } + }, + error: error => { + logError(LOG_PREFIX + 'ID fetch encountered an error', error); + } + }, undefined, {method: 'GET', withCredentials: true}) + } + + return true; +} + +function addData(reqBidsConfigObj, items) { + let merge = false + + for (let j = 0; j < items.length; j++) { + let item = items[j] + let data = JSON.parse(item.parameters); + if (item['attachment_point'] === 'data') { + mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, data) + merge = true + } + } + return merge +} + +/** + * Alter the Bid Request for additional information such as HEM or 3rd Party Ids + * @param reqBidsConfigObj + * @param callback + * @param config + * @param userConsent + */ +function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { + if (items != null) { + addData(reqBidsConfigObj, items) + } + callback(); +} + +submodule('realTimeData', growthCodeRtdProvider); diff --git a/modules/growthCodeRtdProvider.md b/modules/growthCodeRtdProvider.md new file mode 100644 index 00000000000..274b94da7bc --- /dev/null +++ b/modules/growthCodeRtdProvider.md @@ -0,0 +1,55 @@ +## GrowthCode Real-time Data Submodule + +The [GrowthCode](https://growthcode.io) real-time data module in Prebid enables publishers to fully +leverage the potential of their first-party audiences and contextual data. +With an integrated cookieless GrowthCode identity, this module offers real-time +contextual and audience segmentation (IAB Taxonomy 2.2, cattax: 6) capabilities, and HEMs that can seamlessly +integrate into your existing Prebid deployment, making it easy to maximize +your advertising strategies. + +## Building Prebid with GrowthCode Support + +Compile the GrowthCode RTD module into your Prebid build: + +`gulp serve --modules=userId,rtdModule,appnexusBidAdapter,growthCodeRtdProvider,sharedIdSystem,criteoBidAdapter` + +Please visit https://growthcode.io/ for more information. + +``` +pbjs.setConfig( + ... + realTimeData: { + auctionDelay: 1000, + dataProviders: [ + { + name: 'growthCodeRtd', + waitForIt: true, + params: { + pid: 'TEST01', + } + } + ] + } + ... +} +``` + +### Parameter Descriptions for the GrowthCode Configuration Section + +| Name | Type | Description | Notes | +|:---------------------------------|:--------|:--------------------------------------------------------------------------|:----------------------------| +| name | String | Real time data module name | Always 'growthCodeRtd' | +| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | +| params | Object | | | +| params.pid | String | This is the Parter ID value obtained from GrowthCode | `TEST01` | +| params.url | String | Custom URL for server | Optional | + +## Testing + +To view an example of GrowthCode backends: + +`gulp serve --modules=userId,rtdModule,appnexusBidAdapter,growthCodeRtdProvider,sharedIdSystem,criteoBidAdapter` + +and then point your browser at: + +`http://localhost:9999/integrationExamples/gpt/growthcode.html` diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index f7662f54fae..d050af4ac8f 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -6,13 +6,13 @@ import {getStorageManager} from '../src/storageManager.js'; import {includes} from '../src/polyfill.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -const BIDDER_CODE = 'gumgum' +const BIDDER_CODE = 'gumgum'; const storage = getStorageManager({bidderCode: BIDDER_CODE}); -const ALIAS_BIDDER_CODE = ['gg'] -const BID_ENDPOINT = `https://g2.gumgum.com/hbid/imp` +const ALIAS_BIDDER_CODE = ['gg']; +const BID_ENDPOINT = `https://g2.gumgum.com/hbid/imp`; const JCSI = { t: 0, rq: 8, pbv: '$prebid.version$' } -const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO] -const TIME_TO_LIVE = 60 +const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO]; +const TIME_TO_LIVE = 60; const DELAY_REQUEST_TIME = 1800000; // setting to 30 mins let invalidRequestIds = {}; @@ -99,17 +99,6 @@ function getWrapperCode(wrapper, data) { return wrapper.replace('AD_JSON', window.btoa(JSON.stringify(data))) } -function _getDigiTrustQueryParams(userId) { - let digiTrustId = userId.digitrustid && userId.digitrustid.data; - // Verify there is an ID and this user has not opted out - if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) { - return {}; - } - return { - dt: digiTrustId.id - }; -} - /** * Serializes the supply chain object according to IAB standards * @see https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md @@ -264,7 +253,8 @@ function getEids(userId) { const idProperties = [ 'uid', 'eid', - 'lipbid' + 'lipbid', + 'envelope' ]; return Object.keys(userId).reduce(function (eids, provider) { @@ -293,15 +283,16 @@ function buildRequests(validBidRequests, bidderRequest) { const bids = []; const gdprConsent = bidderRequest && bidderRequest.gdprConsent; const uspConsent = bidderRequest && bidderRequest.uspConsent; - const timeout = config.getConfig('bidderTimeout'); - const topWindowUrl = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; + const gppConsent = bidderRequest && bidderRequest.gppConsent; + const timeout = bidderRequest && bidderRequest.timeout + const coppa = config.getConfig('coppa') === true ? 1 : 0; + const topWindowUrl = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.page; _each(validBidRequests, bidRequest => { const { bidId, mediaTypes = {}, params = {}, schain, - transactionId, userId = {}, ortb2Imp, adUnitCode = '' @@ -320,8 +311,13 @@ function buildRequests(validBidRequests, bidderRequest) { data.lt = lt; data.to = to; + // ADJS-1286 Read id5 id linktype field + if (userId && userId.id5id && userId.id5id.uid && userId.id5id.ext) { + data.id5Id = userId.id5id.uid || null + data.id5IdLinkType = userId.id5id.ext.linkType || null + } // ADTS-169 add adUnitCode to requests - if (adUnitCode) data.aun = adUnitCode + if (adUnitCode) data.aun = adUnitCode; // ADTS-134 Retrieve ID envelopes for (const eid in eids) data[eid] = eids[eid]; @@ -370,9 +366,11 @@ function buildRequests(validBidRequests, bidderRequest) { data.pi = 5; } else if (mediaTypes.video) { data.pi = mediaTypes.video.linearity === 2 ? 6 : 7; // invideo : video + } else if (params.product && params.product.toLowerCase() === 'skins') { + data.pi = 8; } } else { // legacy params - data = { ...data, ...handleLegacyParams(params, sizes) } + data = { ...data, ...handleLegacyParams(params, sizes) }; } if (gdprConsent) { @@ -384,6 +382,20 @@ function buildRequests(validBidRequests, bidderRequest) { if (uspConsent) { data.uspConsent = uspConsent; } + if (gppConsent) { + data.gppConsent = { + gppString: bidderRequest.gppConsent.gppString, + gpp_sid: bidderRequest.gppConsent.applicableSections + } + } else if (!gppConsent && bidderRequest?.ortb2?.regs?.gpp) { + data.gppConsent = { + gppString: bidderRequest.ortb2.regs.gpp, + gpp_sid: bidderRequest.ortb2.regs.gpp_sid + }; + } + if (coppa) { + data.coppa = coppa; + } if (schain && schain.nodes) { data.schain = _serializeSupplyChainObj(schain); } @@ -391,14 +403,14 @@ function buildRequests(validBidRequests, bidderRequest) { bids.push({ id: bidId, tmax: timeout, - tId: transactionId, + tId: ortb2Imp?.ext?.tid, pi: data.pi, selector: params.selector, sizes, url: BID_ENDPOINT, method: 'GET', - data: Object.assign(data, _getBrowserParams(topWindowUrl), _getDigiTrustQueryParams(userId)) - }) + data: Object.assign(data, _getBrowserParams(topWindowUrl)) + }); }); return bids; } @@ -577,6 +589,7 @@ function getUserSyncs(syncOptions, serverResponses) { export const spec = { code: BIDDER_CODE, + gvlid: 61, aliases: ALIAS_BIDDER_CODE, isBidRequestValid, buildRequests, diff --git a/modules/gumgumBidAdapter.md b/modules/gumgumBidAdapter.md index 57d56235d1c..88c9cd29f69 100644 --- a/modules/gumgumBidAdapter.md +++ b/modules/gumgumBidAdapter.md @@ -10,7 +10,7 @@ Maintainer: engineering@gumgum.com GumGum adapter for Prebid.js Please note that both video and in-video products require a mediaType of video. -In-screen and slot products should have a mediaType of banner. +In-screen, slot, and skins products should have a mediaType of banner. # Test Parameters ``` @@ -50,6 +50,24 @@ var adUnits = [ } } ] + },{ + code: 'skins-placement', + sizes: [[300, 50]], + mediaTypes: { + banner: { + sizes: [[1, 1]], + } + }, + bids: [ + { + bidder: 'gumgum', + params: { + zone: 'dc9d6be1', // GumGum Zone ID given to the client + product: 'skins', + bidfloor: 0.03 // CPM bid floor + } + } + ] },{ code: 'video-placement', sizes: [[300, 50]], diff --git a/modules/gxoneBidAdapter.md b/modules/gxoneBidAdapter.md deleted file mode 100644 index 3168d297da3..00000000000 --- a/modules/gxoneBidAdapter.md +++ /dev/null @@ -1,40 +0,0 @@ -# Overview - -Module Name: GXOne Bidder Adapter -Module Type: Bidder Adapter -Maintainer: olivier@geronimo.co - -# Description - -Module that connects to GXOne demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "gxone", - params: { - uid: '2', - priceType: 'gross' // by default is 'net' - } - } - ] - },{ - code: 'test-div', - sizes: [[728, 90]], - bids: [ - { - bidder: "gxone", - params: { - uid: 9, - priceType: 'gross' - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/h12mediaBidAdapter.js b/modules/h12mediaBidAdapter.js index 9a6244a9e82..7b1ba9ee286 100644 --- a/modules/h12mediaBidAdapter.js +++ b/modules/h12mediaBidAdapter.js @@ -41,7 +41,7 @@ export const spec = { const bidrequest = { bidId: bidRequest.bidId, - transactionId: bidRequest.transactionId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, adunitId: bidRequest.adUnitCode, pubid: bidderParams.pubid, placementid: bidderParams.placementid || '', @@ -70,8 +70,9 @@ export const spec = { gdpr_cs: deepAccess(bidderRequest, 'gdprConsent.consentString', ''), usp: !!deepAccess(bidderRequest, 'uspConsent', false), usp_cs: deepAccess(bidderRequest, 'uspConsent', ''), - topLevelUrl: deepAccess(bidderRequest, 'refererInfo.referer', ''), - refererUrl: windowTop.document.referrer, + topLevelUrl: deepAccess(bidderRequest, 'refererInfo.page', ''), + // TODO: does the fallback make sense here? + refererUrl: deepAccess(bidderRequest, 'refererInfo.ref', window.document.referrer), isiframe, version: '$prebid.version$', ExtUserIDs: bidRequest.userId, @@ -197,7 +198,7 @@ function getIsHidden(elem) { } catch (o) { return false; } - } while ((m < 250) && (lastElem != null) && (elemHidden === false)) + } while ((m < 250) && (lastElem != null) && (elemHidden === false)); return elemHidden; } diff --git a/modules/hadronAnalyticsAdapter.js b/modules/hadronAnalyticsAdapter.js new file mode 100644 index 00000000000..e4c09c5b6c9 --- /dev/null +++ b/modules/hadronAnalyticsAdapter.js @@ -0,0 +1,202 @@ +import { ajax } from '../src/ajax.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import * as utils from '../src/utils.js'; +import CONSTANTS from '../src/constants.json'; +import {getStorageManager} from '../src/storageManager.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; + +/** + * hadronAnalyticsAdapter.js - Audigent Hadron Analytics Adapter + */ + +const HADRON_ANALYTICS_URL = 'https://analytics.hadron.ad.gt/api/v1/analytics'; +const HADRONID_ANALYTICS_VER = 'pbadgt0'; +const DEFAULT_PARTNER_ID = 0; +const AU_GVLID = 561; +const MODULE_CODE = 'hadronAnalytics'; + +export const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); + +var viewId = utils.generateUUID(); + +var partnerId = DEFAULT_PARTNER_ID; +var eventsToTrack = []; + +var w = window; +var d = document; +var e = d.documentElement; +var g = d.getElementsByTagName('body')[0]; +var x = w.innerWidth || e.clientWidth || g.clientWidth; +var y = w.innerHeight || e.clientHeight || g.clientHeight; + +var pageView = { + eventType: 'pageView', + userAgent: window.navigator.userAgent, + timestamp: Date.now(), + timezoneOffset: new Date().getTimezoneOffset(), + language: window.navigator.language, + vendor: window.navigator.vendor, + pageUrl: getRefererInfo().page, + screenWidth: x, + screenHeight: y +}; + +var eventQueue = [ + pageView +]; + +var startAuction = 0; +var bidRequestTimeout = 0; +let analyticsType = 'endpoint'; + +let hadronAnalyticsAdapter = Object.assign(adapter({url: HADRON_ANALYTICS_URL, analyticsType}), { + track({eventType, args}) { + args = args ? JSON.parse(JSON.stringify(args)) : {}; + var data = {}; + if (!eventsToTrack.includes(eventType)) return; + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: { + data = args; + startAuction = data.timestamp; + bidRequestTimeout = data.timeout; + break; + } + + case CONSTANTS.EVENTS.AUCTION_END: { + data = args; + data.start = startAuction; + data.end = Date.now(); + break; + } + + case CONSTANTS.EVENTS.BID_ADJUSTMENT: { + data.bidders = args; + break; + } + + case CONSTANTS.EVENTS.BID_TIMEOUT: { + data.bidders = args; + data.duration = bidRequestTimeout; + break; + } + + case CONSTANTS.EVENTS.BID_REQUESTED: { + data = args; + break; + } + + case CONSTANTS.EVENTS.BID_RESPONSE: { + data = args; + delete data.ad; + break; + } + + case CONSTANTS.EVENTS.BID_WON: { + data = args; + delete data.ad; + delete data.adUrl; + break; + } + + case CONSTANTS.EVENTS.BIDDER_DONE: { + data = args; + break; + } + + case CONSTANTS.EVENTS.SET_TARGETING: { + data.targetings = args; + break; + } + + case CONSTANTS.EVENTS.REQUEST_BIDS: { + data = args; + break; + } + + case CONSTANTS.EVENTS.ADD_AD_UNITS: { + data = args; + break; + } + + case CONSTANTS.EVENTS.AD_RENDER_FAILED: { + data = args; + break; + } + + default: + return; + } + + data.eventType = eventType; + data.timestamp = data.timestamp || Date.now(); + + sendEvent(data); + } +}); + +hadronAnalyticsAdapter.originEnableAnalytics = hadronAnalyticsAdapter.enableAnalytics; + +hadronAnalyticsAdapter.enableAnalytics = function(conf = {}) { + if (typeof conf.options === 'object') { + if (conf.options.partnerId) { + partnerId = conf.options.partnerId; + } else { + partnerId = DEFAULT_PARTNER_ID; + } + if (conf.options.eventsToTrack) { + eventsToTrack = conf.options.eventsToTrack; + } + } else { + utils.logError('HADRON_ANALYTICS_NO_CONFIG_ERROR'); + return; + } + + hadronAnalyticsAdapter.originEnableAnalytics(conf); +}; + +function flush() { + // Don't send anything if no partner id was declared + if (partnerId === DEFAULT_PARTNER_ID) return; + if (eventQueue.length > 1) { + var data = { + pageViewId: viewId, + ver: HADRONID_ANALYTICS_VER, + partnerId: partnerId, + events: eventQueue + }; + + ajax(HADRON_ANALYTICS_URL, + () => utils.logInfo('HADRON_ANALYTICS_BATCH_SEND'), + JSON.stringify(data), + { + contentType: 'application/json', + method: 'POST' + } + ); + + eventQueue = [ + pageView + ]; + } +} + +function sendEvent(event) { + eventQueue.push(event); + utils.logInfo(`HADRON_ANALYTICS_EVENT ${event.eventType} `, event); + + if (event.eventType === CONSTANTS.EVENTS.AUCTION_END) { + flush(); + } +} + +adapterManager.registerAnalyticsAdapter({ + adapter: hadronAnalyticsAdapter, + code: MODULE_CODE, + gvlid: AU_GVLID +}); + +hadronAnalyticsAdapter.flush = flush; + +export default hadronAnalyticsAdapter; diff --git a/modules/hadronAnalyticsAdapter.md b/modules/hadronAnalyticsAdapter.md new file mode 100644 index 00000000000..8a41be8d36e --- /dev/null +++ b/modules/hadronAnalyticsAdapter.md @@ -0,0 +1,48 @@ +# Overview +Module Name: Hadron Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: [audigent.com](https://audigent.com) + +# Hadron ID + +The Hadron ID is a container that publishers and ad tech platforms can use to +recognise users' segments where 3rd party cookies are not available. +The Hadron ID is designed to respect users' privacy choices and publishers’ +preferences throughout the advertising value chain. +For more information about the Hadron ID and detailed integration docs, please visit +[our brochure](https://audigent.com/hadron-id). + +# Hadron Analytics Registration + +The Hadron Analytics Adapter is free to use for our customers. +Please visit [audigent/hadron-id](https://audigent.com/hadron-id) to request a demo or get more info. + +The partners' privacy policy is at [https://audigent.com/privacypolicy/#partners](https://audigent.com/privacypolicy/#partners). + +## Hadron Analytics Configuration + +First, make sure to add the Hadron Analytics submodule to your Prebid.js package with: + +``` +gulp build --modules=...,hadronAnalyticsAdapter +``` + +The following configuration parameters are available: + +```javascript +pbjs.enableAnalytics({ + provider: 'hadronAnalytics', + options: { + partnerId: 1234, // change to the Partner ID you got from Audigent + eventsToTrack: ['auctionEnd','bidWon'] + } +}); +``` + +| Parameter | Scope | Type | Description | Example | +|-----------------------|----------|------------------|---------------------------------------------------------|---------------------------| +| provider | Required | String | The name of this module: `hadronAnalytics` | `hadronAnalytics` | +| options.partnerId | Required | Number | This is the Audigent Partner ID obtained from Audigent. | `1234` | +| options.eventsToTrack | Optional | Array of strings | Overrides the set of tracked events | `['auctionEnd','bidWon']` | diff --git a/modules/hadronIdSystem.js b/modules/hadronIdSystem.js index db2620d2422..c60f0f812a4 100644 --- a/modules/hadronIdSystem.js +++ b/modules/hadronIdSystem.js @@ -8,17 +8,21 @@ import {ajax} from '../src/ajax.js'; import {getStorageManager} from '../src/storageManager.js'; import {submodule} from '../src/hook.js'; -import { isFn, isStr, isPlainObject, logError } from '../src/utils.js'; +import {isFn, isStr, isPlainObject, logError, logInfo} from '../src/utils.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +const HADRONID_LOCAL_NAME = 'auHadronId'; const MODULE_NAME = 'hadronId'; const AU_GVLID = 561; +const DEFAULT_HADRON_URL_ENDPOINT = 'https://id.hadron.ad.gt/api/v1/pbhid'; -export const storage = getStorageManager({gvlid: AU_GVLID, moduleName: 'hadron'}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: 'hadron'}); /** * Param or default. - * @param {String} param + * @param {String|function} param * @param {String} defaultVal + * @param arg */ function paramOrDefault(param, defaultVal, arg) { if (isFn(param)) { @@ -29,6 +33,15 @@ function paramOrDefault(param, defaultVal, arg) { return defaultVal; } +/** + * @param {string} url + * @param {string} params + * @returns {string} + */ +const urlAddParams = (url, params) => { + return url + (url.indexOf('?') > -1 ? '&' : '?') + params +} + /** @type {Submodule} */ export const hadronIdSubmodule = { /** @@ -36,18 +49,19 @@ export const hadronIdSubmodule = { * @type {string} */ name: MODULE_NAME, + gvlid: AU_GVLID, /** * decode the stored id value for passing to bid requests * @function - * @param {{value:string}} value - * @returns {{hadronId:Object}} + * @param {string} value + * @returns {Object} */ decode(value) { - let hadronId = storage.getDataFromLocalStorage('auHadronId'); + const hadronId = storage.getDataFromLocalStorage(HADRONID_LOCAL_NAME); if (isStr(hadronId)) { return {hadronId: hadronId}; } - return (value && typeof value['hadronId'] === 'string') ? { 'hadronId': value['hadronId'] } : undefined; + return (value && typeof value['hadronId'] === 'string') ? {'hadronId': value['hadronId']} : undefined; }, /** * performs action to obtain id and return a value in the callback's response argument @@ -59,37 +73,49 @@ export const hadronIdSubmodule = { if (!isPlainObject(config.params)) { config.params = {}; } - const url = paramOrDefault(config.params.url, - `https://id.hadron.ad.gt/api/v1/pbhid`, - config.params.urlArg); - + const partnerId = config.params.partnerId | 0; + let hadronId = storage.getDataFromLocalStorage(HADRONID_LOCAL_NAME); + if (isStr(hadronId)) { + return {id: {hadronId}}; + } const resp = function (callback) { - let hadronId = storage.getDataFromLocalStorage('auHadronId'); - if (isStr(hadronId)) { - const responseObj = {hadronId: hadronId}; - callback(responseObj); - } else { - const callbacks = { - success: response => { - let responseObj; - if (response) { - try { - responseObj = JSON.parse(response); - } catch (error) { - logError(error); - } + let responseObj = {}; + const callbacks = { + success: response => { + if (response) { + try { + responseObj = JSON.parse(response); + } catch (error) { + logError(error); } - callback(responseObj); - }, - error: error => { - logError(`${MODULE_NAME}: ID fetch encountered an error`, error); - callback(); + logInfo(`Response from backend is ${responseObj}`); + hadronId = responseObj['hadronId']; + storage.setDataInLocalStorage(HADRONID_LOCAL_NAME, hadronId); + responseObj = {id: {hadronId}}; } - }; - ajax(url, callbacks, undefined, {method: 'GET'}); - } + callback(responseObj); + }, + error: error => { + logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + callback(); + } + }; + logInfo('HadronId not found in storage, calling backend...'); + const url = urlAddParams( + // config.params.url and config.params.urlArg are not documented + // since their use is for debugging purposes only + paramOrDefault(config.params.url, DEFAULT_HADRON_URL_ENDPOINT, config.params.urlArg), + `partner_id=${partnerId}&_it=prebid` + ); + ajax(url, callbacks, undefined, {method: 'GET'}); }; return {callback: resp}; + }, + eids: { + 'hadronId': { + source: 'audigent.com', + atype: 1 + }, } }; diff --git a/modules/hadronIdSystem.md b/modules/hadronIdSystem.md index 26539676e17..212030cbcd9 100644 --- a/modules/hadronIdSystem.md +++ b/modules/hadronIdSystem.md @@ -11,6 +11,9 @@ pbjs.setConfig({ usersync: { userIds: [{ name: 'hadronId', + params: { + partnerId: 1234 // change it to the Partner ID you'll get from Audigent + }, storage: { name: 'hadronId', type: 'html5' @@ -22,14 +25,14 @@ pbjs.setConfig({ ## Parameter Descriptions for the `usersync` Configuration Section The below parameters apply only to the HadronID User ID Module integration. -| Param under usersync.userIds[] | Scope | Type | Description | Example | -| --- | --- | --- | --- | --- | -| name | Required | String | ID value for the HadronID module - `"hadronId"` | `"hadronId"` | -| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | | -| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` | -| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"hadronid"` | -| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. | `365` | -| value | Optional | Object | Used only if the page has a separate mechanism for storing the Hadron ID. The value is an object containing the values to be sent to the adapters. In this scenario, no URL is called and nothing is added to local storage | `{"hadronId": "eb33b0cb-8d35-4722-b9c0-1a31d4064888"}` | -| params | Optional | Object | Used to store params for the id system | -| params.url | Optional | String | Set an alternate GET url for HadronId with this parameter | -| params.urlArg | Optional | Object | Optional url parameter for params.url | +| Param under usersync.userIds[] | Scope | Type | Description | Example | +|--------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------| +| name | Required | String | ID value for the HadronID module - `"hadronId"` | `"hadronId"` | +| storage | Required | Object | The publisher must specify the local storage in which to store the results of the call to get the user ID. This can be either cookie or HTML5 storage. | | +| storage.type | Required | String | This is where the results of the user ID will be stored. The recommended method is `localStorage` by specifying `html5`. | `"html5"` | +| storage.name | Required | String | The name of the cookie or html5 local storage where the user ID will be stored. | `"hadronid"` | +| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. | `365` | +| value | Optional | Object | Used only if the page has a separate mechanism for storing the Hadron ID. The value is an object containing the values to be sent to the adapters. In this scenario, no URL is called and nothing is added to local storage | `{"hadronId": "eb33b0cb-8d35-4722-b9c0-1a31d4064888"}` | +| params | Optional | Object | Used to store params for the id system | +| params.partnerId | Required | Number | This is the Audigent Partner ID obtained from Audigent. | `1234` | + | diff --git a/modules/hadronRtdProvider.js b/modules/hadronRtdProvider.js index 0b1081f174a..6fb982815c1 100644 --- a/modules/hadronRtdProvider.js +++ b/modules/hadronRtdProvider.js @@ -10,15 +10,28 @@ import {config} from '../src/config.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {getStorageManager} from '../src/storageManager.js'; import {submodule} from '../src/hook.js'; -import {isFn, isStr, isArray, deepEqual, isPlainObject, logError} from '../src/utils.js'; +import {isFn, isStr, isArray, deepEqual, isPlainObject, logError, logInfo} from '../src/utils.js'; +import {loadExternalScript} from '../src/adloader.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; +const LOG_PREFIX = 'User ID - HadronRtdProvider submodule: '; const MODULE_NAME = 'realTimeData'; const SUBMODULE_NAME = 'hadron'; const AU_GVLID = 561; - +const HADRON_ID_DEFAULT_URL = 'https://id.hadron.ad.gt/api/v1/hadronid?_it=prebid'; +const HADRON_SEGMENT_URL = 'https://id.hadron.ad.gt/api/v1/rtd'; export const HALOID_LOCAL_NAME = 'auHadronId'; export const RTD_LOCAL_NAME = 'auHadronRtd'; -export const storage = getStorageManager({gvlid: AU_GVLID, moduleName: SUBMODULE_NAME}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: SUBMODULE_NAME}); + +/** + * @param {string} url + * @param {string} params + * @returns {string} + */ +const urlAddParams = (url, params) => { + return url + (url.indexOf('?') > -1 ? '&' : '?') + params +}; /** * Deep set an object unless value present. @@ -92,8 +105,9 @@ function mergeLazy(target, source) { /** * Param or default. - * @param {String} param + * @param {String|Function} param * @param {String} defaultVal + * @param {Object} arg */ function paramOrDefault(param, defaultVal, arg) { if (isFn(param)) { @@ -114,34 +128,20 @@ export function addRealTimeData(bidConfig, rtd, rtdConfig) { if (rtdConfig.params && rtdConfig.params.handleRtd) { rtdConfig.params.handleRtd(bidConfig, rtd, rtdConfig, config); } else { + // TODO: this and haloRtdProvider are a copy-paste of each other if (isPlainObject(rtd.ortb2)) { - let ortb2 = config.getConfig('ortb2') || {}; - config.setConfig({ortb2: mergeLazy(ortb2, rtd.ortb2)}); + mergeLazy(bidConfig.ortb2Fragments?.global, rtd.ortb2); } if (isPlainObject(rtd.ortb2b)) { - let bidderConfig = config.getBidderConfig(); - - Object.keys(rtd.ortb2b).forEach(bidder => { - let rtdOptions = rtd.ortb2b[bidder] || {}; - - let bidderOptions = {}; - if (isPlainObject(bidderConfig[bidder])) { - bidderOptions = bidderConfig[bidder]; - } - - config.setBidderConfig({ - bidders: [bidder], - config: mergeLazy(bidderOptions, rtdOptions) - }); - }); + mergeLazy(bidConfig.ortb2Fragments?.bidder, Object.fromEntries(Object.entries(rtd.ortb2b).map(([_, cfg]) => [_, cfg.ortb2]))); } } } /** * Real-time data retrieval from Audigent - * @param {Object} reqBidsConfigObj + * @param {Object} bidConfig * @param {function} onDone * @param {Object} rtdConfig * @param {Object} userConsent @@ -161,30 +161,35 @@ export function getRealTimeData(bidConfig, onDone, rtdConfig, userConsent) { } } - const userIds = (getGlobal()).getUserIds(); + const userIds = typeof getGlobal().getUserIds === 'function' ? (getGlobal()).getUserIds() : {}; let hadronId = storage.getDataFromLocalStorage(HALOID_LOCAL_NAME); if (isStr(hadronId)) { - (getGlobal()).refreshUserIds({submoduleNames: 'hadronId'}); + if (typeof getGlobal().refreshUserIds === 'function') { + (getGlobal()).refreshUserIds({submoduleNames: 'hadronId'}); + } userIds.hadronId = hadronId; getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, userIds); } else { - var script = document.createElement('script'); - script.type = 'text/javascript'; - window.pubHadronCb = (hadronId) => { userIds.hadronId = hadronId; getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, userIds); } - + const partnerId = rtdConfig.params.partnerId | 0; const hadronIdUrl = rtdConfig.params && rtdConfig.params.hadronIdUrl; - script.src = paramOrDefault(hadronIdUrl, 'https://id.hadron.ad.gt/api/v1/hadronid', userIds); - document.getElementsByTagName('head')[0].appendChild(script); + const scriptUrl = urlAddParams( + paramOrDefault(hadronIdUrl, HADRON_ID_DEFAULT_URL, userIds), + `partner_id=${partnerId}&_it=prebid` + ); + loadExternalScript(scriptUrl, 'hadron', () => { + logInfo(LOG_PREFIX, 'hadronIdTag loaded', scriptUrl); + }) } } /** * Async rtd retrieval from Audigent + * @param {Object} bidConfig * @param {function} onDone * @param {Object} rtdConfig * @param {Object} userConsent @@ -194,7 +199,7 @@ export function getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, let reqParams = {}; if (isPlainObject(rtdConfig)) { - set(rtdConfig, 'params.requestParams.ortb2', config.getConfig('ortb2')); + set(rtdConfig, 'params.requestParams.ortb2', bidConfig.ortb2Fragments.global); reqParams = rtdConfig.params.requestParams; } @@ -202,8 +207,7 @@ export function getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, reqParams.pubHadronPm = window.pubHadronPm; } - const url = `https://seg.hadron.ad.gt/api/v1/rtd`; - ajax(url, { + ajax(HADRON_SEGMENT_URL, { success: function (response, req) { if (req.status === 200) { try { @@ -237,7 +241,7 @@ export function getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, /** * Module init * @param {Object} provider - * @param {Objkect} userConsent + * @param {Object} userConsent * @return {boolean} */ function init(provider, userConsent) { @@ -248,7 +252,8 @@ function init(provider, userConsent) { export const hadronSubmodule = { name: SUBMODULE_NAME, getBidRequestData: getRealTimeData, - init: init + init: init, + gvlid: AU_GVLID, }; submodule(MODULE_NAME, hadronSubmodule); diff --git a/modules/hadronRtdProvider.md b/modules/hadronRtdProvider.md index 0dbe9666230..5064e75dde0 100644 --- a/modules/hadronRtdProvider.md +++ b/modules/hadronRtdProvider.md @@ -44,8 +44,9 @@ pbjs.setConfig( params: { segmentCache: false, requestParams: { - publisherId: 1234 - } + publisherId: 1234 // deprecated, use partnerId instead + }, + partnerId: 1234 } } ] @@ -56,15 +57,17 @@ pbjs.setConfig( ### Parameter Descriptions for the Hadron Configuration Section -| Name |Type | Description | Notes | -| :------------ | :------------ | :------------ |:------------ | -| name | String | Real time data module name | Always 'hadron' | -| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | -| params | Object | | | -| params.handleRtd | Function | A passable RTD handler that allows custom adunit and ortb2 logic to be configured. The function signature is (bidConfig, rtd, rtdConfig, pbConfig) => {}. | Optional | -| params.segmentCache | Boolean | This parameter tells the Hadron RTD module to attempt reading segments from a local storage cache instead of always requesting them from the Audigent server. | Optional. Defaults to false. | -| params.requestParams | Object | Publisher partner specific configuration options, such as optional publisher id and other segment query related metadata to be submitted to Audigent's backend with each request. Contact prebid@audigent.com for more information. | Optional | -| params.hadronIdUrl | String | Parameter to specify alternate hadronid endpoint url. | Optional | +| Name | Type | Description | Notes | +|:---------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------| +| name | String | Real time data module name | Always 'hadron' | +| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | +| params | Object | | | +| params.partnerId | Number | This is the Audigent Partner ID obtained from Audigent. | `1234` | +| params.handleRtd | Function | A passable RTD handler that allows custom adunit and ortb2 logic to be configured. The function signature is (bidConfig, rtd, rtdConfig, pbConfig) => {}. | Optional | +| params.segmentCache | Boolean | This parameter tells the Hadron RTD module to attempt reading segments from a local storage cache instead of always requesting them from the Audigent server. | Optional. Defaults to false. | +| params.requestParams | Object | Publisher partner specific configuration options, such as optional publisher id and other segment query related metadata to be submitted to Audigent's backend with each request. Contact prebid@audigent.com for more information. | Optional | +| params.requestParams.publisherId | Object | (deprecated) Publisher id and other segment query related metadata to be submitted to Audigent's backend with each request. Contact prebid@audigent.com for more information. | Optional | +| params.hadronIdUrl | String | Parameter to specify alternate hadronid endpoint url. | Optional | ### Publisher Customized RTD Handling As indicated above, it is possible to provide your own bid augmentation @@ -100,8 +103,9 @@ pbjs.setConfig( }, segmentCache: false, requestParams: { - publisherId: 1234 - } + publisherId: 1234 // deprecated, use partnerId instead + }, + partnerId: 1234 } } ] diff --git a/modules/haloIdSystem.js b/modules/haloIdSystem.js deleted file mode 100644 index 2ce18e1e740..00000000000 --- a/modules/haloIdSystem.js +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This module adds HaloID to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/haloIdSystem - * @requires module:modules/userId - */ - -import {ajax} from '../src/ajax.js'; -import {getStorageManager} from '../src/storageManager.js'; -import {submodule} from '../src/hook.js'; -import { isFn, isStr, isPlainObject, logError } from '../src/utils.js'; - -const MODULE_NAME = 'haloId'; -const AU_GVLID = 561; - -export const storage = getStorageManager({gvlid: AU_GVLID, moduleName: 'halo'}); - -/** - * Param or default. - * @param {String} param - * @param {String} defaultVal - */ -function paramOrDefault(param, defaultVal, arg) { - if (isFn(param)) { - return param(arg); - } else if (isStr(param)) { - return param; - } - return defaultVal; -} - -/** @type {Submodule} */ -export const haloIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: MODULE_NAME, - /** - * decode the stored id value for passing to bid requests - * @function - * @param {{value:string}} value - * @returns {{haloId:Object}} - */ - decode(value) { - let haloId = storage.getDataFromLocalStorage('auHaloId'); - if (isStr(haloId)) { - return {haloId: haloId}; - } - return (value && typeof value['haloId'] === 'string') ? { 'haloId': value['haloId'] } : undefined; - }, - /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleConfig} [config] - * @returns {IdResponse|undefined} - */ - getId(config) { - if (!isPlainObject(config.params)) { - config.params = {}; - } - const url = paramOrDefault(config.params.url, - `https://id.halo.ad.gt/api/v1/pbhid`, - config.params.urlArg); - - const resp = function (callback) { - let haloId = storage.getDataFromLocalStorage('auHaloId'); - if (isStr(haloId)) { - const responseObj = {haloId: haloId}; - callback(responseObj); - } else { - const callbacks = { - success: response => { - let responseObj; - if (response) { - try { - responseObj = JSON.parse(response); - } catch (error) { - logError(error); - } - } - callback(responseObj); - }, - error: error => { - logError(`${MODULE_NAME}: ID fetch encountered an error`, error); - callback(); - } - }; - ajax(url, callbacks, undefined, {method: 'GET'}); - } - }; - return {callback: resp}; - } -}; - -submodule('userId', haloIdSubmodule); diff --git a/modules/haloIdSystem.md b/modules/haloIdSystem.md deleted file mode 100644 index 7c58aea3ec6..00000000000 --- a/modules/haloIdSystem.md +++ /dev/null @@ -1,4 +0,0 @@ -## Audigent Halo has been rebranded as Hadron -## Use the Hadron Id Submodule -## The Halo modules will be removed from Prebid 7 -## Contact prebid@audigent.com for more info. diff --git a/modules/haloRtdProvider.js b/modules/haloRtdProvider.js deleted file mode 100644 index 1810bfb6f63..00000000000 --- a/modules/haloRtdProvider.js +++ /dev/null @@ -1,254 +0,0 @@ -/** - * This module adds the Audigent Halo provider to the real time data module - * The {@link module:modules/realTimeData} module is required - * The module will fetch real-time data from Audigent - * @module modules/haloRtdProvider - * @requires module:modules/realTimeData - */ -import {ajax} from '../src/ajax.js'; -import {config} from '../src/config.js'; -import {getGlobal} from '../src/prebidGlobal.js'; -import {getStorageManager} from '../src/storageManager.js'; -import {submodule} from '../src/hook.js'; -import {isFn, isStr, isArray, deepEqual, isPlainObject, logError} from '../src/utils.js'; - -const MODULE_NAME = 'realTimeData'; -const SUBMODULE_NAME = 'halo'; -const AU_GVLID = 561; - -export const HALOID_LOCAL_NAME = 'auHaloId'; -export const RTD_LOCAL_NAME = 'auHaloRtd'; -export const storage = getStorageManager({gvlid: AU_GVLID, moduleName: SUBMODULE_NAME}); - -/** - * Deep set an object unless value present. - * @param {Object} obj - * @param {String} path - * @param {Object} val - */ -function set(obj, path, val) { - const keys = path.split('.'); - const lastKey = keys.pop(); - const lastObj = keys.reduce((obj, key) => obj[key] = obj[key] || {}, obj); - lastObj[lastKey] = lastObj[lastKey] || val; -} - -/** - * Deep object merging with array deduplication. - * @param {Object} target - * @param {Object} sources - */ -function mergeDeep(target, ...sources) { - if (!sources.length) return target; - const source = sources.shift(); - - if (isPlainObject(target) && isPlainObject(source)) { - for (const key in source) { - if (isPlainObject(source[key])) { - if (!target[key]) Object.assign(target, { [key]: {} }); - mergeDeep(target[key], source[key]); - } else if (isArray(source[key])) { - if (!target[key]) { - Object.assign(target, { [key]: source[key] }); - } else if (isArray(target[key])) { - source[key].forEach(obj => { - let e = 1; - for (let i = 0; i < target[key].length; i++) { - if (deepEqual(target[key][i], obj)) { - e = 0; - break; - } - } - if (e) { - target[key].push(obj); - } - }); - } - } else { - Object.assign(target, { [key]: source[key] }); - } - } - } - - return mergeDeep(target, ...sources); -} - -/** - * Lazy merge objects. - * @param {Object} target - * @param {Object} source - */ -function mergeLazy(target, source) { - if (!isPlainObject(target)) { - target = {}; - } - - if (!isPlainObject(source)) { - source = {}; - } - - return mergeDeep(target, source); -} - -/** - * Param or default. - * @param {String} param - * @param {String} defaultVal - */ -function paramOrDefault(param, defaultVal, arg) { - if (isFn(param)) { - return param(arg); - } else if (isStr(param)) { - return param; - } - return defaultVal; -} - -/** - * Add real-time data & merge segments. - * @param {Object} bidConfig - * @param {Object} rtd - * @param {Object} rtdConfig - */ -export function addRealTimeData(bidConfig, rtd, rtdConfig) { - if (rtdConfig.params && rtdConfig.params.handleRtd) { - rtdConfig.params.handleRtd(bidConfig, rtd, rtdConfig, config); - } else { - if (isPlainObject(rtd.ortb2)) { - let ortb2 = config.getConfig('ortb2') || {}; - config.setConfig({ortb2: mergeLazy(ortb2, rtd.ortb2)}); - } - - if (isPlainObject(rtd.ortb2b)) { - let bidderConfig = config.getBidderConfig(); - - Object.keys(rtd.ortb2b).forEach(bidder => { - let rtdOptions = rtd.ortb2b[bidder] || {}; - - let bidderOptions = {}; - if (isPlainObject(bidderConfig[bidder])) { - bidderOptions = bidderConfig[bidder]; - } - - config.setBidderConfig({ - bidders: [bidder], - config: mergeLazy(bidderOptions, rtdOptions) - }); - }); - } - } -} - -/** - * Real-time data retrieval from Audigent - * @param {Object} reqBidsConfigObj - * @param {function} onDone - * @param {Object} rtdConfig - * @param {Object} userConsent - */ -export function getRealTimeData(bidConfig, onDone, rtdConfig, userConsent) { - if (rtdConfig && isPlainObject(rtdConfig.params) && rtdConfig.params.segmentCache) { - let jsonData = storage.getDataFromLocalStorage(RTD_LOCAL_NAME); - - if (jsonData) { - let data = JSON.parse(jsonData); - - if (data.rtd) { - addRealTimeData(bidConfig, data.rtd, rtdConfig); - onDone(); - return; - } - } - } - - const userIds = (getGlobal()).getUserIds(); - - let haloId = storage.getDataFromLocalStorage(HALOID_LOCAL_NAME); - if (isStr(haloId)) { - (getGlobal()).refreshUserIds({submoduleNames: 'haloId'}); - userIds.haloId = haloId; - getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, userIds); - } else { - var script = document.createElement('script'); - script.type = 'text/javascript'; - - window.pubHaloCb = (haloId) => { - userIds.haloId = haloId; - getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, userIds); - } - - const haloIdUrl = rtdConfig.params && rtdConfig.params.haloIdUrl; - script.src = paramOrDefault(haloIdUrl, 'https://id.halo.ad.gt/api/v1/haloid', userIds); - document.getElementsByTagName('head')[0].appendChild(script); - } -} - -/** - * Async rtd retrieval from Audigent - * @param {function} onDone - * @param {Object} rtdConfig - * @param {Object} userConsent - * @param {Object} userIds - */ -export function getRealTimeDataAsync(bidConfig, onDone, rtdConfig, userConsent, userIds) { - let reqParams = {}; - - if (isPlainObject(rtdConfig)) { - set(rtdConfig, 'params.requestParams.ortb2', config.getConfig('ortb2')); - reqParams = rtdConfig.params.requestParams; - } - - if (isPlainObject(window.pubHaloPm)) { - reqParams.pubHaloPm = window.pubHaloPm; - } - - const url = `https://seg.halo.ad.gt/api/v1/rtd`; - ajax(url, { - success: function (response, req) { - if (req.status === 200) { - try { - const data = JSON.parse(response); - if (data && data.rtd) { - addRealTimeData(bidConfig, data.rtd, rtdConfig); - onDone(); - storage.setDataInLocalStorage(RTD_LOCAL_NAME, JSON.stringify(data)); - } else { - onDone(); - } - } catch (err) { - logError('unable to parse audigent segment data'); - onDone(); - } - } else if (req.status === 204) { - // unrecognized partner config - onDone(); - } - }, - error: function () { - onDone(); - logError('unable to get audigent segment data'); - } - }, - JSON.stringify({'userIds': userIds, 'config': reqParams}), - {contentType: 'application/json'} - ); -} - -/** - * Module init - * @param {Object} provider - * @param {Objkect} userConsent - * @return {boolean} - */ -function init(provider, userConsent) { - return true; -} - -/** @type {RtdSubmodule} */ -export const haloSubmodule = { - name: SUBMODULE_NAME, - getBidRequestData: getRealTimeData, - init: init -}; - -submodule(MODULE_NAME, haloSubmodule); diff --git a/modules/haloRtdProvider.md b/modules/haloRtdProvider.md deleted file mode 100644 index 6ae5a3f75fa..00000000000 --- a/modules/haloRtdProvider.md +++ /dev/null @@ -1,3 +0,0 @@ -## Audigent Halo has been rebranded as Hadron -## Use the Hadron Rtd Submodule -## The Halo modules will be removed from Prebid 7 \ No newline at end of file diff --git a/modules/haxmediaBidAdapter.md b/modules/haxmediaBidAdapter.md deleted file mode 100644 index f661a9e4e71..00000000000 --- a/modules/haxmediaBidAdapter.md +++ /dev/null @@ -1,72 +0,0 @@ -# Overview - -``` -Module Name: haxmedia Bidder Adapter -Module Type: haxmedia Bidder Adapter -Maintainer: haxmixqk@haxmediapartners.io -``` - -# Description - -Module that connects to haxmedia demand sources - -# Test Parameters -``` - var adUnits = [ - { - code:'1', - mediaTypes:{ - banner: { - sizes: [[300, 250]], - } - }, - bids:[ - { - bidder: 'haxmedia', - params: { - placementId: 0 - } - } - ] - }, - { - code:'1', - mediaTypes:{ - video: { - playerSize: [640, 480], - context: 'instream' - } - }, - bids:[ - { - bidder: 'haxmedia', - params: { - placementId: 0 - } - } - ] - }, - { - code:'1', - mediaTypes:{ - native: { - title: { - required: true - }, - icon: { - required: true, - size: [64, 64] - } - } - }, - bids:[ - { - bidder: 'haxmedia', - params: { - placementId: 0 - } - } - ] - } - ]; -``` diff --git a/modules/holidBidAdapter.js b/modules/holidBidAdapter.js new file mode 100644 index 00000000000..fbcbb9492c7 --- /dev/null +++ b/modules/holidBidAdapter.js @@ -0,0 +1,188 @@ +import { + deepAccess, + deepSetValue, getBidIdParameter, + isStr, + logMessage, + triggerPixel, +} from '../src/utils.js'; +import * as events from '../src/events.js'; +import CONSTANTS from '../src/constants.json'; +import {BANNER} from '../src/mediaTypes.js'; + +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'holid' +const GVLID = 1177 +const ENDPOINT = 'https://helloworld.holid.io/openrtb2/auction' +const COOKIE_SYNC_ENDPOINT = 'https://null.holid.io/sync.html' +const TIME_TO_LIVE = 300 +const TMAX = 500 +let wurlMap = {} + +events.on(CONSTANTS.EVENTS.BID_WON, bidWonHandler) + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER], + + isBidRequestValid: function (bid) { + return !!bid.params.adUnitID + }, + + buildRequests: function (validBidRequests, bidderRequest) { + return validBidRequests.map((bid) => { + const requestData = { + ...bid.ortb2, + source: {schain: bid.schain}, + id: bidderRequest.bidderRequestId, + imp: [getImp(bid)], + tmax: TMAX, + ...buildStoredRequest(bid) + } + + if (bid.userIdAsEids) { + deepSetValue(requestData, 'user.ext.eids', bid.userIdAsEids) + } + + return { + method: 'POST', + url: ENDPOINT, + data: JSON.stringify(requestData), + bidId: bid.bidId, + } + }) + }, + + interpretResponse: function (serverResponse, bidRequest) { + const bidResponses = [] + + if (!serverResponse.body.seatbid) { + return [] + } + + serverResponse.body.seatbid.map((response) => { + response.bid.map((bid) => { + const requestId = bidRequest.bidId + const wurl = deepAccess(bid, 'ext.prebid.events.win') + const bidResponse = { + requestId, + cpm: bid.price, + width: bid.w, + height: bid.h, + ad: bid.adm, + creativeId: bid.crid, + currency: serverResponse.body.cur, + netRevenue: true, + ttl: TIME_TO_LIVE, + } + + addWurl(requestId, wurl) + + bidResponses.push(bidResponse) + }) + }) + + return bidResponses + }, + + getUserSyncs(optionsType, serverResponse, gdprConsent, uspConsent) { + const syncs = [{ + type: 'image', + url: 'https://track.adform.net/Serving/TrackPoint/?pm=2992097&lid=132720821' + }] + + if (!serverResponse || serverResponse.length === 0) { + return syncs + } + + const bidders = getBidders(serverResponse) + + if (optionsType.iframeEnabled && bidders) { + const queryParams = [] + + queryParams.push('bidders=' + bidders) + queryParams.push('gdpr=' + +gdprConsent.gdprApplies) + queryParams.push('gdpr_consent=' + gdprConsent.consentString) + queryParams.push('usp_consent=' + (uspConsent || '')) + + let strQueryParams = queryParams.join('&') + + if (strQueryParams.length > 0) { + strQueryParams = '?' + strQueryParams + } + + syncs.push({ + type: 'iframe', + url: COOKIE_SYNC_ENDPOINT + strQueryParams + '&type=iframe', + }) + } + + return syncs + }, +} + +function getImp(bid) { + const imp = buildStoredRequest(bid) + const sizes = + bid.sizes && !Array.isArray(bid.sizes[0]) ? [bid.sizes] : bid.sizes + + if (deepAccess(bid, 'mediaTypes.banner')) { + imp.banner = { + format: sizes.map((size) => { + return { w: size[0], h: size[1] } + }), + } + } + + return imp +} + +function buildStoredRequest(bid) { + return { + ext: { + prebid: { + storedrequest: { + id: getBidIdParameter('adUnitID', bid.params), + }, + }, + }, + } +} + +function getBidders(serverResponse) { + const bidders = serverResponse + .map((res) => Object.keys(res.body.ext.responsetimemillis || [])) + .flat(1) + + if (bidders.length) { + return encodeURIComponent(JSON.stringify([...new Set(bidders)])) + } +} + +function addWurl(requestId, wurl) { + if (isStr(requestId)) { + wurlMap[requestId] = wurl + } +} + +function removeWurl(requestId) { + delete wurlMap[requestId] +} + +function getWurl(requestId) { + if (isStr(requestId)) { + return wurlMap[requestId] + } +} + +function bidWonHandler(bid) { + const wurl = getWurl(bid.requestId) + if (wurl) { + logMessage(`Invoking image pixel for wurl on BID_WIN: "${wurl}"`) + triggerPixel(wurl) + removeWurl(bid.requestId) + } +} + +registerBidder(spec) diff --git a/modules/holidBidAdapter.md b/modules/holidBidAdapter.md new file mode 100644 index 00000000000..1d83918c00a --- /dev/null +++ b/modules/holidBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: Holid Bid Adapter +Module Type: Bidder Adapter +Maintainer: richard@holid.se +``` + +# Description + +Currently module supports only banner mediaType. + +# Test Parameters + +## Sample Banner Ad Unit + +```js +var adUnits = [ + { + code: 'bannerAdUnit', + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + bids: [ + { + bidder: 'holid', + params: { + adUnitID: '12345', + }, + }, + ], + }, +] +``` diff --git a/modules/hpmdnetworkBidAdapter.md b/modules/hpmdnetworkBidAdapter.md deleted file mode 100644 index b7ac51a9311..00000000000 --- a/modules/hpmdnetworkBidAdapter.md +++ /dev/null @@ -1,32 +0,0 @@ -# Overview - -Module Name: HPMD Network Bidder Adapter - -Module Type: Bidder Adapter - -Maintainer: a.fominov@hpmdnetwork.ru - -# Description - -You can use this adapter to get a bid from HPMD Network. - -About us : https://www.hpmdnetwork.ru/ - - -# Test Parameters -```javascript - var adUnits = [ - { - code: 'test-div', - bids: [ - { - bidder: "hpmdnetwork", - params: { - placementId: "123" - } - } - ] - } - ]; -``` - diff --git a/modules/huddledmassesBidAdapter.md b/modules/huddledmassesBidAdapter.md deleted file mode 100644 index c743f4a2fd8..00000000000 --- a/modules/huddledmassesBidAdapter.md +++ /dev/null @@ -1,26 +0,0 @@ -# Overview - -``` -Module Name: HuddledMasses Bidder Adapter -Module Type: Bidder Adapter -Maintainer: supply@huddledmasses.com -``` - -# Description - -Module that connects to HuddledMasses' demand sources - -# Test Parameters -``` - var adUnits = [{ - code: 'placementid_0', - sizes: [[300, 250]], - bids: [{ - bidder: 'huddledmasses', - params: { - placement_id: 0 - } - }] - } - ]; -``` diff --git a/modules/hybridBidAdapter.js b/modules/hybridBidAdapter.js index 98fecf04d8d..f746e69cbba 100644 --- a/modules/hybridBidAdapter.js +++ b/modules/hybridBidAdapter.js @@ -25,7 +25,7 @@ function buildBidRequests(validBidRequests) { const params = validBidRequest.params; const bidRequest = { bidId: validBidRequest.bidId, - transactionId: validBidRequest.transactionId, + transactionId: validBidRequest.ortb2Imp?.ext?.tid, sizes: validBidRequest.sizes, placement: placementTypes[params.placement], placeId: params.placeId, @@ -88,6 +88,7 @@ function buildBid(bidData) { bid.vastXml = bidData.content; bid.mediaType = VIDEO; + // TODO: why does this need to iterate through every ad unit? let adUnit = find(auctionManager.getAdUnits(), function (unit) { return unit.transactionId === bidData.transactionId; }); @@ -204,7 +205,8 @@ export const spec = { */ buildRequests(validBidRequests, bidderRequest) { const payload = { - url: bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + url: bidderRequest.refererInfo.page, cmp: !!bidderRequest.gdprConsent, trafficType: TRAFFIC_TYPE_WEB, bidRequests: buildBidRequests(validBidRequests) @@ -243,7 +245,6 @@ export const spec = { return item.bidId === bid.bidId; }); bid.placement = rawBid.placement; - bid.transactionId = rawBid.transactionId; bid.placeId = rawBid.placeId; return buildBid(bid); }); diff --git a/modules/hypelabBidAdapter.js b/modules/hypelabBidAdapter.js new file mode 100644 index 00000000000..a625c7299a6 --- /dev/null +++ b/modules/hypelabBidAdapter.js @@ -0,0 +1,153 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { generateUUID } from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; + +export const BIDDER_CODE = 'hypelab'; +export const ENDPOINT_URL = 'https://api.hypelab.com'; + +export const REQUEST_ROUTE = '/v1/prebid_requests'; +export const EVENT_ROUTE = '/v1/events'; +export const REPORTING_ROUTE = ''; + +const PREBID_VERSION = '$prebid.version$'; +const PROVIDER_NAME = 'prebid'; +const PROVIDER_VERSION = '0.0.1'; + +const url = (route) => ENDPOINT_URL + route; + +export function mediaSize(data) { + if (!data || !data.creative_set) return { width: 0, height: 0 }; + const media = data.creative_set.video || data.creative_set.image || {}; + return { width: media.width, height: media.height }; +} + +function isBidRequestValid(bidderRequest) { + return ( + !!bidderRequest.params?.property_slug && + !!bidderRequest.params?.placement_slug + ); +} + +function buildRequests(validBidRequests, bidderRequest) { + const result = validBidRequests.map((request) => { + const uids = (request.userIdAsEids || []).reduce((a, c) => { + const ids = c.uids.map((uid) => uid.id); + return [...a, ...ids]; + }, []); + + const uuid = uids[0] ? uids[0] : generateTemporaryUUID(); + + const payload = { + property_slug: request.params.property_slug, + placement_slug: request.params.placement_slug, + provider_version: PROVIDER_VERSION, + provider_name: PROVIDER_NAME, + referrer: + bidderRequest.refererInfo?.page || typeof window != 'undefined' + ? window.location.href + : '', + sdk_version: PREBID_VERSION, + sizes: request.sizes, + wids: [], + uuid, + bidRequestsCount: request.bidRequestsCount, + bidderRequestsCount: request.bidderRequestsCount, + bidderWinsCount: request.bidderWinsCount, + wp: { + ada: typeof window != 'undefined' && !!window.cardano, + bnb: typeof window != 'undefined' && !!window.BinanceChain, + eth: typeof window != 'undefined' && !!window.ethereum, + sol: typeof window != 'undefined' && !!window.solana, + tron: typeof window != 'undefined' && !!window.tron, + }, + }; + + return { + method: 'POST', + url: url(REQUEST_ROUTE), + options: { contentType: 'application/json', withCredentials: false }, + data: payload, + bidId: request.bidId, + }; + }); + + return result; +} + +function generateTemporaryUUID() { + return 'tmp_' + generateUUID(); +} + +function interpretResponse(serverResponse, bidRequest) { + const { data } = serverResponse.body; + + if (!data.cpm || !data.html) return []; + + const size = mediaSize(data); + + const result = { + requestId: bidRequest.bidId, + cpm: data.cpm, + width: size.width, + height: size.height, + creativeId: data.creative_set_slug, + currency: data.currency, + netRevenue: true, + referrer: bidRequest.data.referrer, + ttl: data.ttl, + ad: data.html, + mediaType: serverResponse.body.data.media_type, + meta: { + advertiserDomains: data.advertiserDomains || [], + }, + }; + + return [result]; +} + +export function report(eventType, data, route = REPORTING_ROUTE) { + if (!route) return; + + const options = { + method: 'POST', + contentType: 'application/json', + withCredentials: true, + }; + + const request = { type: eventType, data }; + ajax(url(route), null, request, options); +} + +function onTimeout(timeoutData) { + this.report('timeout', timeoutData); +} + +function onBidWon(bid) { + this.report('bidWon', bid); +} + +function onSetTargeting(bid) { + this.report('setTargeting', bid); +} + +function onBidderError(errorData) { + this.report('bidderError', errorData); +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + aliases: ['hype'], + isBidRequestValid, + buildRequests, + interpretResponse, + onTimeout, + onBidWon, + onSetTargeting, + onBidderError, + report, + REPORTING_ROUTE: 'a', +}; + +registerBidder(spec); diff --git a/modules/hypelabBidAdapter.md b/modules/hypelabBidAdapter.md new file mode 100644 index 00000000000..f33664da578 --- /dev/null +++ b/modules/hypelabBidAdapter.md @@ -0,0 +1,38 @@ +# Overview + +``` +Module Name: HypeLab Bid Adapter +Module Type: Bidder Adapter +Maintainer: sdk@hypelab.com +``` + +# Description + +Prebid.JS adapter that connects to HypeLab ad network for bids. +*NOTE*: The HypeLab Adapter requires setup and approval before use. Please reach out to `partnerships@hypelab.com` for more details. To get started, replace the `property_slug` with your property_slug and the `placement_slug` with your placement slug to receive bids. The placement slug will depend on the required size and can be set via the HypeLab interface. + +# Test Parameters + +## Sample Banner Ad Unit + +```js +var adUnits = [ + { + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [[728, 90]], + }, + }, + bids: [ + { + bidder: 'hypelab', + params: { + property_slug: 'prebid', + placement_slug: 'test_placement' + } + } + ] + } +] +``` diff --git a/modules/iasRtdProvider.js b/modules/iasRtdProvider.js index 58899d7a8c0..b9de7ef4e46 100644 --- a/modules/iasRtdProvider.js +++ b/modules/iasRtdProvider.js @@ -1,7 +1,9 @@ -import { submodule } from '../src/hook.js'; +import {submodule} from '../src/hook.js'; import * as utils from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import { getGlobal } from '../src/prebidGlobal.js'; +import {ajax} from '../src/ajax.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; /** @type {string} */ const MODULE_NAME = 'realTimeData'; @@ -38,7 +40,7 @@ const IAS_KEY_MAPPINGS = { /** * Module init - * @param {Object} provider + * @param {Object} config * @param {Object} userConsent * @return {boolean} */ @@ -71,14 +73,28 @@ function stringifySlotSizes(sizes) { return result; } -function stringifySlot(bidRequest) { - const sizes = utils.getAdUnitSizes(bidRequest); +function getAdUnitPath(adSlot, bidRequest, adUnitPath) { + let p = bidRequest.code; + if (!utils.isEmpty(adSlot)) { + p = adSlot.gptSlot; + } else { + if (!utils.isEmpty(adUnitPath) && adUnitPath.hasOwnProperty(bidRequest.code)) { + if (utils.isStr(adUnitPath[bidRequest.code]) && !utils.isEmpty(adUnitPath[bidRequest.code])) { + p = adUnitPath[bidRequest.code]; + } + } + } + return p; +} + +function stringifySlot(bidRequest, adUnitPath) { + const sizes = getAdUnitSizes(bidRequest); const id = bidRequest.code; const ss = stringifySlotSizes(sizes); - const adSlot = utils.getGptSlotInfoForAdUnitCode(bidRequest.code); - const p = utils.isEmpty(adSlot) ? bidRequest.code : adSlot.gptSlot; + const adSlot = getGptSlotInfoForAdUnitCode(bidRequest.code); + const p = getAdUnitPath(adSlot, bidRequest, adUnitPath); const slot = { id, ss, p }; - const keyValues = utils.getKeys(slot).map(function (key) { + const keyValues = Object.keys(slot).map(function (key) { return [key, slot[key]].join(':'); }); return '{' + keyValues.join(',') + '}'; @@ -119,18 +135,18 @@ function formatTargetingData(adUnit) { return renameKeyValues(result); } -function constructQueryString(anId, adUnits) { +function constructQueryString(anId, adUnits, pageUrl, adUnitPath) { let queries = []; queries.push(['anId', anId]); queries = queries.concat(adUnits.reduce(function (acc, request) { - acc.push(['slot', stringifySlot(request)]); + acc.push(['slot', stringifySlot(request, adUnitPath)]); return acc; }, [])); queries.push(['wr', stringifyWindowSize()]); queries.push(['sr', stringifyScreenSize()]); - queries.push(['url', encodeURIComponent(window.location.href)]); + queries.push(['url', encodeURIComponent(pageUrl)]); return encodeURI(queries.map(qs => qs.join('=')).join('&')); } @@ -160,6 +176,16 @@ function getTargetingData(adUnits, config, userConsent) { return targeting; } +function isValidHttpUrl(string) { + let url; + try { + url = new URL(string); + } catch (_) { + return false; + } + return url.protocol === 'http:' || url.protocol === 'https:'; +} + export function getApiCallback() { return { success: function (response, req) { @@ -180,7 +206,12 @@ export function getApiCallback() { function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) { const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; const { pubId } = config.params; - const queryString = constructQueryString(pubId, adUnits); + let { pageUrl } = config.params; + const { adUnitPath } = config.params; + if (!isValidHttpUrl(pageUrl)) { + pageUrl = document.location.href; + } + const queryString = constructQueryString(pubId, adUnits, pageUrl, adUnitPath); ajax( `${IAS_HOST}?${queryString}`, getApiCallback(), diff --git a/modules/iasRtdProvider.md b/modules/iasRtdProvider.md index d8c46ff2697..be47822eb58 100644 --- a/modules/iasRtdProvider.md +++ b/modules/iasRtdProvider.md @@ -2,7 +2,7 @@ Module Name: Integral Ad Science(IAS) Rtd Provider Module Type: Rtd Provider -Maintainer: raguilar@integralads.com +Maintainer: punereporting@integralads.com # Description diff --git a/modules/id5AnalyticsAdapter.js b/modules/id5AnalyticsAdapter.js index 69e303b520a..d0f3198e03d 100644 --- a/modules/id5AnalyticsAdapter.js +++ b/modules/id5AnalyticsAdapter.js @@ -1,9 +1,10 @@ -import buildAdapter from '../src/AnalyticsAdapter.js'; +import buildAdapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import { ajax } from '../src/ajax.js'; import { logInfo, logError } from '../src/utils.js'; import * as events from '../src/events.js'; +import {getGlobal} from '../src/prebidGlobal.js'; const { EVENTS: { @@ -34,7 +35,7 @@ const FLUSH_EVENTS = [ const CONFIG_URL_PREFIX = 'https://api.id5-sync.com/analytics' const TZ = new Date().getTimezoneOffset(); -const PBJS_VERSION = $$PREBID_GLOBAL$$.version; +const PBJS_VERSION = getGlobal().version; const ID5_REDACTED = '__ID5_REDACTED__'; const isArray = Array.isArray; @@ -141,7 +142,7 @@ const ENABLE_FUNCTION = (config) => { logInfo('id5Analytics: Tracking events', _this.eventsToTrack); if (sampling > 0 && _this.random() < (1 / sampling)) { // Init the module only if we got lucky - logInfo('id5Analytics: Selected by sampling. Starting up!') + logInfo('id5Analytics: Selected by sampling. Starting up!'); // Clean start _this.eventBuffer = {}; diff --git a/modules/id5IdSystem.js b/modules/id5IdSystem.js index f2143c1cced..e12aea5f8d1 100644 --- a/modules/id5IdSystem.js +++ b/modules/id5IdSystem.js @@ -5,12 +5,22 @@ * @requires module:modules/userId */ -import { deepAccess, logInfo, deepSetValue, logError, isEmpty, isEmptyStr, logWarn } from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import { submodule } from '../src/hook.js'; -import { getRefererInfo } from '../src/refererDetection.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { uspDataHandler } from '../src/adapterManager.js'; +import { + deepAccess, + deepSetValue, + isEmpty, + isEmptyStr, + logError, + logInfo, + logWarn, + safeJSONParse +} from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; +import {submodule} from '../src/hook.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {uspDataHandler} from '../src/adapterManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'id5Id'; const GVLID = 131; @@ -19,12 +29,13 @@ export const ID5_STORAGE_NAME = 'id5id'; export const ID5_PRIVACY_STORAGE_NAME = `${ID5_STORAGE_NAME}_privacy`; const LOCAL_STORAGE = 'html5'; const LOG_PREFIX = 'User ID - ID5 submodule: '; +const ID5_API_CONFIG_URL = 'https://id5-sync.com/api/config/prebid'; // order the legacy cookie names in reverse priority order so the last // cookie in the array is the most preferred to use -const LEGACY_COOKIE_NAMES = [ 'pbjs-id5id', 'id5id.1st', 'id5id' ]; +const LEGACY_COOKIE_NAMES = ['pbjs-id5id', 'id5id.1st', 'id5id']; -const storage = getStorageManager({gvlid: GVLID, moduleName: MODULE_NAME}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); /** @type {Submodule} */ export const id5IdSubmodule = { @@ -49,11 +60,11 @@ export const id5IdSubmodule = { */ decode(value, config) { let universalUid; - let linkType = 0; + let ext = {}; if (value && typeof value.universal_uid === 'string') { universalUid = value.universal_uid; - linkType = value.link_type || linkType; + ext = value.ext || ext; } else { return undefined; } @@ -61,9 +72,7 @@ export const id5IdSubmodule = { let responseObj = { id5id: { uid: universalUid, - ext: { - linkType: linkType - } + ext: ext } }; @@ -93,92 +102,32 @@ export const id5IdSubmodule = { /** * performs action to obtain id and return a value in the callback's response argument * @function getId - * @param {SubmoduleConfig} config + * @param {SubmoduleConfig} submoduleConfig * @param {ConsentData} consentData * @param {(Object|undefined)} cacheIdObj * @returns {IdResponse|undefined} */ - getId(config, consentData, cacheIdObj) { - if (!hasRequiredConfig(config)) { + getId(submoduleConfig, consentData, cacheIdObj) { + if (!validateConfig(submoduleConfig)) { return undefined; } - const url = `https://id5-sync.com/g/v2/${config.params.partner}.json`; - const hasGdpr = (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) ? 1 : 0; - const usp = uspDataHandler.getConsentData(); - const referer = getRefererInfo(); - const signature = (cacheIdObj && cacheIdObj.signature) ? cacheIdObj.signature : getLegacyCookieSignature(); - const data = { - 'partner': config.params.partner, - 'gdpr': hasGdpr, - 'nbPage': incrementNb(config.params.partner), - 'o': 'pbjs', - 'rf': referer.referer, - 'top': referer.reachedTop ? 1 : 0, - 'u': referer.stack[0] || window.location.href, - 'v': '$prebid.version$' - }; - - // pass in optional data, but only if populated - if (hasGdpr && typeof consentData.consentString !== 'undefined' && !isEmpty(consentData.consentString) && !isEmptyStr(consentData.consentString)) { - data.gdpr_consent = consentData.consentString; - } - if (typeof usp !== 'undefined' && !isEmpty(usp) && !isEmptyStr(usp)) { - data.us_privacy = usp; - } - if (typeof signature !== 'undefined' && !isEmptyStr(signature)) { - data.s = signature; - } - if (typeof config.params.pd !== 'undefined' && !isEmptyStr(config.params.pd)) { - data.pd = config.params.pd; - } - if (typeof config.params.provider !== 'undefined' && !isEmptyStr(config.params.provider)) { - data.provider = config.params.provider; - } - - const abTestingConfig = getAbTestingConfig(config); - if (abTestingConfig.enabled === true) { - data.ab_testing = { - enabled: true, - control_group_pct: abTestingConfig.controlGroupPct // The server validates - }; + if (!hasWriteConsentToLocalStorage(consentData)) { + logInfo(LOG_PREFIX + 'Skipping ID5 local storage write because no consent given.') + return undefined; } - const resp = function (callback) { - const callbacks = { - success: response => { - let responseObj; - if (response) { - try { - responseObj = JSON.parse(response); - logInfo(LOG_PREFIX + 'response received from the server', responseObj); - - resetNb(config.params.partner); - - if (responseObj.privacy) { - storeInLocalStorage(ID5_PRIVACY_STORAGE_NAME, JSON.stringify(responseObj.privacy), NB_EXP_DAYS); - } - - // TODO: remove after requiring publishers to use localstorage and - // all publishers have upgraded - if (config.storage.type === LOCAL_STORAGE) { - removeLegacyCookies(config.params.partner); - } - } catch (error) { - logError(LOG_PREFIX + error); - } - } - callback(responseObj); - }, - error: error => { + const resp = function (cbFunction) { + new IdFetchFlow(submoduleConfig, consentData, cacheIdObj, uspDataHandler.getConsentData()).execute() + .then(response => { + cbFunction(response) + }) + .catch(error => { logError(LOG_PREFIX + 'getId fetch encountered an error', error); - callback(); - } - }; - logInfo(LOG_PREFIX + 'requesting an ID from the server', data); - ajax(url, callbacks, JSON.stringify(data), { method: 'POST', withCredentials: true }); + cbFunction(); + }); }; - return { callback: resp }; + return {callback: resp}; }, /** @@ -193,19 +142,186 @@ export const id5IdSubmodule = { * @return {(IdResponse|function(callback:function))} A response object that contains id and/or callback. */ extendId(config, consentData, cacheIdObj) { - hasRequiredConfig(config); + if (!hasWriteConsentToLocalStorage(consentData)) { + logInfo(LOG_PREFIX + 'No consent given for ID5 local storage writing, skipping nb increment.') + return cacheIdObj; + } - const partnerId = (config && config.params && config.params.partner) || 0; + const partnerId = validateConfig(config) ? config.params.partner : 0; incrementNb(partnerId); logInfo(LOG_PREFIX + 'using cached ID', cacheIdObj); return cacheIdObj; - } + }, + eids: { + 'id5id': { + getValue: function(data) { + return data.uid + }, + source: 'id5-sync.com', + atype: 1, + getUidExt: function(data) { + if (data.ext) { + return data.ext; + } + } + }, + }, }; -function hasRequiredConfig(config) { - if (!config || !config.params || !config.params.partner || typeof config.params.partner !== 'number') { - logError(LOG_PREFIX + 'partner required to be defined as a number'); +class IdFetchFlow { + constructor(submoduleConfig, gdprConsentData, cacheIdObj, usPrivacyData) { + this.submoduleConfig = submoduleConfig + this.gdprConsentData = gdprConsentData + this.cacheIdObj = cacheIdObj + this.usPrivacyData = usPrivacyData + } + + execute() { + return this.#callForConfig(this.submoduleConfig) + .then(fetchFlowConfig => { + return this.#callForExtensions(fetchFlowConfig.extensionsCall) + .then(extensionsData => { + return this.#callId5Fetch(fetchFlowConfig.fetchCall, extensionsData) + }) + }) + .then(fetchCallResponse => { + try { + resetNb(this.submoduleConfig.params.partner); + if (fetchCallResponse.privacy) { + storeInLocalStorage(ID5_PRIVACY_STORAGE_NAME, JSON.stringify(fetchCallResponse.privacy), NB_EXP_DAYS); + } + } catch (error) { + logError(LOG_PREFIX + error); + } + return fetchCallResponse; + }) + } + + #ajaxPromise(url, data, options) { + return new Promise((resolve, reject) => { + ajax(url, + { + success: function (res) { + resolve(res) + }, + error: function (err) { + reject(err) + } + }, data, options) + }) + } + + // eslint-disable-next-line no-dupe-class-members + #callForConfig(submoduleConfig) { + let url = submoduleConfig.params.configUrl || ID5_API_CONFIG_URL; // override for debug/test purposes only + return this.#ajaxPromise(url, JSON.stringify(submoduleConfig), {method: 'POST'}) + .then(response => { + let responseObj = JSON.parse(response); + logInfo(LOG_PREFIX + 'config response received from the server', responseObj); + return responseObj; + }); + } + + // eslint-disable-next-line no-dupe-class-members + #callForExtensions(extensionsCallConfig) { + if (extensionsCallConfig === undefined) { + return Promise.resolve(undefined) + } + let extensionsUrl = extensionsCallConfig.url + let method = extensionsCallConfig.method || 'GET' + let data = method === 'GET' ? undefined : JSON.stringify(extensionsCallConfig.body || {}) + return this.#ajaxPromise(extensionsUrl, data, {'method': method}) + .then(response => { + let responseObj = JSON.parse(response); + logInfo(LOG_PREFIX + 'extensions response received from the server', responseObj); + return responseObj; + }) + } + + // eslint-disable-next-line no-dupe-class-members + #callId5Fetch(fetchCallConfig, extensionsData) { + let url = fetchCallConfig.url; + let additionalData = fetchCallConfig.overrides || {}; + let data = { + ...this.#createFetchRequestData(), + ...additionalData, + extensions: extensionsData + }; + return this.#ajaxPromise(url, JSON.stringify(data), {method: 'POST', withCredentials: true}) + .then(response => { + let responseObj = JSON.parse(response); + logInfo(LOG_PREFIX + 'fetch response received from the server', responseObj); + return responseObj; + }); + } + + // eslint-disable-next-line no-dupe-class-members + #createFetchRequestData() { + const params = this.submoduleConfig.params; + const hasGdpr = (this.gdprConsentData && typeof this.gdprConsentData.gdprApplies === 'boolean' && this.gdprConsentData.gdprApplies) ? 1 : 0; + const referer = getRefererInfo(); + const signature = (this.cacheIdObj && this.cacheIdObj.signature) ? this.cacheIdObj.signature : getLegacyCookieSignature(); + const nbPage = incrementNb(params.partner); + const data = { + 'partner': params.partner, + 'gdpr': hasGdpr, + 'nbPage': nbPage, + 'o': 'pbjs', + 'tml': referer.topmostLocation, + 'ref': referer.ref, + 'cu': referer.canonicalUrl, + 'top': referer.reachedTop ? 1 : 0, + 'u': referer.stack[0] || window.location.href, + 'v': '$prebid.version$', + 'storage': this.submoduleConfig.storage, + 'localStorage': storage.localStorageIsEnabled() ? 1 : 0 + }; + + // pass in optional data, but only if populated + if (hasGdpr && this.gdprConsentData.consentString !== undefined && !isEmpty(this.gdprConsentData.consentString) && !isEmptyStr(this.gdprConsentData.consentString)) { + data.gdpr_consent = this.gdprConsentData.consentString; + } + if (this.usPrivacyData !== undefined && !isEmpty(this.usPrivacyData) && !isEmptyStr(this.usPrivacyData)) { + data.us_privacy = this.usPrivacyData; + } + if (signature !== undefined && !isEmptyStr(signature)) { + data.s = signature; + } + if (params.pd !== undefined && !isEmptyStr(params.pd)) { + data.pd = params.pd; + } + if (params.provider !== undefined && !isEmptyStr(params.provider)) { + data.provider = params.provider; + } + const abTestingConfig = params.abTesting || {enabled: false}; + + if (abTestingConfig.enabled) { + data.ab_testing = { + enabled: true, control_group_pct: abTestingConfig.controlGroupPct // The server validates + }; + } + return data; + } +} + +function validateConfig(config) { + if (!config || !config.params || !config.params.partner) { + logError(LOG_PREFIX + 'partner required to be defined'); + return false; + } + + const partner = config.params.partner + if (typeof partner === 'string' || partner instanceof String) { + let parsedPartnerId = parseInt(partner); + if (isNaN(parsedPartnerId) || parsedPartnerId < 0) { + logError(LOG_PREFIX + 'partner required to be a number or a String parsable to a positive integer'); + return false; + } else { + config.params.partner = parsedPartnerId; + } + } else if (typeof partner !== 'number') { + logError(LOG_PREFIX + 'partner required to be a number or a String parsable to a positive integer'); return false; } @@ -233,47 +349,36 @@ export function expDaysStr(expDays) { export function nbCacheName(partnerId) { return `${ID5_STORAGE_NAME}_${partnerId}_nb`; } + export function storeNbInCache(partnerId, nb) { storeInLocalStorage(nbCacheName(partnerId), nb, NB_EXP_DAYS); } + export function getNbFromCache(partnerId) { let cacheNb = getFromLocalStorage(nbCacheName(partnerId)); return (cacheNb) ? parseInt(cacheNb) : 0; } + function incrementNb(partnerId) { const nb = (getNbFromCache(partnerId) + 1); storeNbInCache(partnerId, nb); return nb; } + function resetNb(partnerId) { storeNbInCache(partnerId, 0); } function getLegacyCookieSignature() { let legacyStoredValue; - LEGACY_COOKIE_NAMES.forEach(function(cookie) { + LEGACY_COOKIE_NAMES.forEach(function (cookie) { if (storage.getCookie(cookie)) { - legacyStoredValue = JSON.parse(storage.getCookie(cookie)) || legacyStoredValue; + legacyStoredValue = safeJSONParse(storage.getCookie(cookie)) || legacyStoredValue; } }); return (legacyStoredValue && legacyStoredValue.signature) || ''; } -/** - * Remove our legacy cookie values. Needed until we move all publishers - * to html5 storage in a future release - * @param {integer} partnerId - */ -function removeLegacyCookies(partnerId) { - logInfo(LOG_PREFIX + 'removing legacy cookies'); - LEGACY_COOKIE_NAMES.forEach(function(cookie) { - storage.setCookie(`${cookie}`, ' ', expDaysStr(-1)); - storage.setCookie(`${cookie}_nb`, ' ', expDaysStr(-1)); - storage.setCookie(`${cookie}_${partnerId}_nb`, ' ', expDaysStr(-1)); - storage.setCookie(`${cookie}_last`, ' ', expDaysStr(-1)); - }); -} - /** * This will make sure we check for expiration before accessing local storage * @param {string} key @@ -294,6 +399,7 @@ export function getFromLocalStorage(key) { storage.removeDataFromLocalStorage(key); return null; } + /** * Ensure that we always set an expiration in local storage since * by default it's not required @@ -307,13 +413,18 @@ export function storeInLocalStorage(key, value, expDays) { } /** - * gets the existing abTesting config or generates a default config with abTesting off - * - * @param {SubmoduleConfig|undefined} config - * @returns {Object} an object which always contains at least the property "enabled" + * Check to see if we can write to local storage based on purpose consent 1, and that we have vendor consent (ID5=131) + * @param {ConsentData} consentData + * @returns {boolean} */ -function getAbTestingConfig(config) { - return deepAccess(config, 'params.abTesting', { enabled: false }); +function hasWriteConsentToLocalStorage(consentData) { + const hasGdpr = consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies; + const localstorageConsent = deepAccess(consentData, `vendorData.purpose.consents.1`) + const id5VendorConsent = deepAccess(consentData, `vendorData.vendor.consents.${GVLID.toString()}`) + if (hasGdpr && (!localstorageConsent || !id5VendorConsent)) { + return false; + } + return true; } submodule('userId', id5IdSubmodule); diff --git a/modules/id5IdSystem.md b/modules/id5IdSystem.md index 11f8ffc5609..927fa10f87b 100644 --- a/modules/id5IdSystem.md +++ b/modules/id5IdSystem.md @@ -1,6 +1,6 @@ -# ID5 Universal ID +# ID5 ID -The ID5 ID is a shared, neutral identifier that publishers and ad tech platforms can use to recognise users even in environments where 3rd party cookies are not available. The ID5 ID is designed to respect users' privacy choices and publishers’ preferences throughout the advertising value chain. For more information about the ID5 ID and detailed integration docs, please visit [our documentation](https://support.id5.io/portal/en/kb/articles/prebid-js-user-id-module). +The ID5 ID is a shared, neutral identifier that publishers and ad tech platforms can use to recognise users even in environments where 3rd party cookies are not available. The ID5 ID is designed to respect users' privacy choices and publishers’ preferences throughout the advertising value chain. For more information about the ID5 ID and detailed integration docs, please visit [our documentation](https://wiki.id5.io/en/identitycloud/retrieve-id5-ids/prebid-user-id-module/id5-prebid-user-id-module). ## ID5 ID Registration @@ -29,7 +29,8 @@ pbjs.setConfig({ abTesting: { // optional enabled: true, // false by default controlGroupPct: 0.1 // valid values are 0.0 - 1.0 (inclusive) - } + }, + disableExtensions: false // optional }, storage: { type: 'html5', // "html5" is the required storage type @@ -43,21 +44,22 @@ pbjs.setConfig({ }); ``` -| Param under userSync.userIds[] | Scope | Type | Description | Example | +| Param under userSync.userIds[] | Scope | Type | Description | Example | | --- | --- | --- | --- | --- | -| name | Required | String | The name of this module: `"id5Id"` | `"id5Id"` | -| params | Required | Object | Details for the ID5 ID. | | -| params.partner | Required | Number | This is the ID5 Partner Number obtained from registering with ID5. | `173` | -| params.pd | Optional | String | Partner-supplied data used for linking ID5 IDs across domains. See [our documentation](https://support.id5.io/portal/en/kb/articles/passing-partner-data-to-id5) for details on generating the string. Omit the parameter or leave as an empty string if no data to supply | `"MT1iNTBjY..."` | -| params.provider | Optional | String | An identifier provided by ID5 to technology partners who manage Prebid setups on behalf of publishers. Reach out to [ID5](mailto:prebid@id5.io) if you have questions about this parameter | `pubmatic-identity-hub` | -| params.abTesting | Optional | Object | Allows publishers to easily run an A/B Test. If enabled and the user is in the Control Group, the ID5 ID will NOT be exposed to bid adapters for that request | Disabled by default | -| params.abTesting.enabled | Optional | Boolean | Set this to `true` to turn on this feature | `true` or `false` | +| name | Required | String | The name of this module: `"id5Id"` | `"id5Id"` | +| params | Required | Object | Details for the ID5 ID. | | +| params.partner | Required | Number | This is the ID5 Partner Number obtained from registering with ID5. | `173` | +| params.pd | Optional | String | Partner-supplied data used for linking ID5 IDs across domains. See [our documentation](https://wiki.id5.io/en/identitycloud/retrieve-id5-ids/passing-partner-data-to-id5) for details on generating the string. Omit the parameter or leave as an empty string if no data to supply | `"MT1iNTBjY..."` | +| params.provider | Optional | String | An identifier provided by ID5 to technology partners who manage Prebid setups on behalf of publishers. Reach out to [ID5](mailto:prebid@id5.io) if you have questions about this parameter | `pubmatic-identity-hub` | +| params.abTesting | Optional | Object | Allows publishers to easily run an A/B Test. If enabled and the user is in the Control Group, the ID5 ID will NOT be exposed to bid adapters for that request | Disabled by default | +| params.abTesting.enabled | Optional | Boolean | Set this to `true` to turn on this feature | `true` or `false` | | params.abTesting.controlGroupPct | Optional | Number | Must be a number between `0.0` and `1.0` (inclusive) and is used to determine the percentage of requests that fall into the control group (and thus not exposing the ID5 ID). For example, a value of `0.20` will result in 20% of requests without an ID5 ID and 80% with an ID. | `0.1` | -| storage | Required | Object | Storage settings for how the User ID module will cache the ID5 ID locally | | -| storage.type | Required | String | This is where the results of the user ID will be stored. ID5 **requires** `"html5"`. | `"html5"` | -| storage.name | Required | String | The name of the local storage where the user ID will be stored. ID5 **requires** `"id5id"`. | `"id5id"` | -| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. ID5 recommends `90`. | `90` | -| storage.refreshInSeconds | Optional | Integer | How many seconds until the ID5 ID will be refreshed. ID5 strongly recommends 8 hours between refreshes | `8*3600` | +| params.disableExtensions | Optional | Boolean | Set this to `true` to force turn off extensions call. Default `false` | `true` or `false` | +| storage | Required | Object | Storage settings for how the User ID module will cache the ID5 ID locally | | +| storage.type | Required | String | This is where the results of the user ID will be stored. ID5 **requires** `"html5"`. | `"html5"` | +| storage.name | Required | String | The name of the local storage where the user ID will be stored. ID5 **requires** `"id5id"`. | `"id5id"` | +| storage.expires | Optional | Integer | How long (in days) the user ID information will be stored. ID5 recommends `90`. | `90` | +| storage.refreshInSeconds | Optional | Integer | How many seconds until the ID5 ID will be refreshed. ID5 strongly recommends 8 hours between refreshes | `8*3600` | **ATTENTION:** As of Prebid.js v4.14.0, ID5 requires `storage.type` to be `"html5"` and `storage.name` to be `"id5id"`. Using other values will display a warning today, but in an upcoming release, it will prevent the ID5 module from loading. This change is to ensure the ID5 module in Prebid.js interoperates properly with the [ID5 API](https://github.com/id5io/id5-api.js) and to reduce the size of publishers' first-party cookies that are sent to their web servers. If you have any questions, please reach out to us at [prebid@id5.io](mailto:prebid@id5.io). @@ -66,3 +68,6 @@ pbjs.setConfig({ Publishers may want to test the value of the ID5 ID with their downstream partners. While there are various ways to do this, A/B testing is a standard approach. Instead of publishers manually enabling or disabling the ID5 User ID Module based on their control group settings (which leads to fewer calls to ID5, reducing our ability to recognize the user), we have baked this in to our module directly. To turn on A/B Testing, simply edit the configuration (see above table) to enable it and set what percentage of users you would like to set for the control group. The control group is the set of user where an ID5 ID will not be exposed in to bid adapters or in the various user id functions available on the `pbjs` global. An additional value of `ext.abTestingControlGroup` will be set to `true` or `false` that can be used to inform reporting systems that the user was in the control group or not. It's important to note that the control group is user based, and not request based. In other words, from one page view to another, a user will always be in or out of the control group. + +### A Note on Using Multiple Wrappers +If you or your monetization partners are deploying multiple Prebid wrappers on your websites, you should make sure you add the ID5 ID User ID module to *every* wrapper. Only the bidders configured in the Prebid wrapper where the ID5 ID User ID module is installed and configured will be able to pick up the ID5 ID. Bidders from other Prebid instances will not be able to pick up the ID5 ID. diff --git a/modules/idWardRtdProvider.js b/modules/idWardRtdProvider.js index a130d3cc8d2..29dda216fdc 100644 --- a/modules/idWardRtdProvider.js +++ b/modules/idWardRtdProvider.js @@ -5,25 +5,25 @@ * @module modules/idWardRtdProvider * @requires module:modules/realTimeData */ -import {config} from '../src/config.js'; import {getStorageManager} from '../src/storageManager.js'; import {submodule} from '../src/hook.js'; import {isPlainObject, mergeDeep, logMessage, logError} from '../src/utils.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; const MODULE_NAME = 'realTimeData'; const SUBMODULE_NAME = 'idWard'; -export const storage = getStorageManager({moduleName: SUBMODULE_NAME}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: SUBMODULE_NAME}); /** - * Add real-time data & merge segments. - * @param {Object} rtd - */ -function addRealTimeData(rtd) { + * Add real-time data & merge segments. + * @param ortb2 object to merge into + * @param {Object} rtd + */ +function addRealTimeData(ortb2, rtd) { if (isPlainObject(rtd.ortb2)) { - const ortb2 = config.getConfig('ortb2') || {}; logMessage('idWardRtdProvider: merging original: ', ortb2); logMessage('idWardRtdProvider: merging in: ', rtd.ortb2); - config.setConfig({ortb2: mergeDeep(ortb2, rtd.ortb2)}); + mergeDeep(ortb2, rtd.ortb2); } } @@ -78,7 +78,7 @@ export function getRealTimeData(reqBidsConfigObj, onDone, rtdConfig, userConsent } } }; - addRealTimeData(data.rtd); + addRealTimeData(reqBidsConfigObj.ortb2Fragments?.global, data.rtd); onDone(); } } diff --git a/modules/identityLinkIdSystem.js b/modules/identityLinkIdSystem.js index df7b03b4e6e..ba794df1a9c 100644 --- a/modules/identityLinkIdSystem.js +++ b/modules/identityLinkIdSystem.js @@ -9,8 +9,13 @@ import * as utils from '../src/utils.js' import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; -export const storage = getStorageManager(); +const MODULE_NAME = 'identityLink'; + +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); + +const liverampEnvelopeName = '_lr_env'; /** @type {Submodule} */ export const identityLinkSubmodule = { @@ -18,7 +23,7 @@ export const identityLinkSubmodule = { * used to link submodule with config * @type {string} */ - name: 'identityLink', + name: MODULE_NAME, /** * used to specify vendor id * @type {number} @@ -71,11 +76,24 @@ export const identityLinkSubmodule = { } }); } else { - getEnvelope(url, callback, configParams); + // try to get envelope directly from storage if ats lib is not present on a page + let envelope = getEnvelopeFromStorage(); + if (envelope) { + utils.logInfo('identityLink: LiveRamp envelope successfully retrieved from storage!'); + callback(JSON.parse(envelope).envelope); + } else { + getEnvelope(url, callback, configParams); + } } }; return { callback: resp }; + }, + eids: { + 'idl_env': { + source: 'liveramp.com', + atype: 3 + }, } }; // return envelope from third party endpoint @@ -118,4 +136,9 @@ function setEnvelopeSource(src) { storage.setCookie('_lr_env_src_ats', src, now.toUTCString()); } +export function getEnvelopeFromStorage() { + let rawEnvelope = storage.getCookie(liverampEnvelopeName) || storage.getDataFromLocalStorage(liverampEnvelopeName); + return rawEnvelope ? window.atob(rawEnvelope) : undefined; +} + submodule('userId', identityLinkSubmodule); diff --git a/modules/idxBidAdapter.js b/modules/idxBidAdapter.js new file mode 100644 index 00000000000..48739275788 --- /dev/null +++ b/modules/idxBidAdapter.js @@ -0,0 +1,80 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js' +import { BANNER } from '../src/mediaTypes.js' +import { isArray, isNumber } from '../src/utils.js' + +const BIDDER_CODE = 'idx' +const ENDPOINT_URL = 'https://dev-event.dxmdp.com/rest/api/v1/bid' +const SUPPORTED_MEDIA_TYPES = [ BANNER ] + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, + isBidRequestValid: function (bid) { + return isArray(bid.mediaTypes?.banner?.sizes) && bid.mediaTypes.banner.sizes.every(size => { + return isArray(size) && size.length === 2 && isNumber(size[0]) && isNumber(size[1]) + }) + }, + buildRequests: function (bidRequests, bidderRequest) { + const payload = { + id: bidderRequest.bidderRequestId, + imp: bidRequests.map(request => { + const { bidId, sizes } = request + + const item = { + id: bidId, + } + + if (request.mediaTypes.banner) { + item.banner = { + format: (request.mediaTypes.banner.sizes || sizes).map(size => { + return { w: size[0], h: size[1] } + }), + } + } + + return item + }), + } + + const payloadString = JSON.stringify(payload) + + return { + method: 'POST', + url: ENDPOINT_URL, + data: payloadString, + bidderRequest, + options: { + withCredentials: false, + contentType: 'application/json' + } + } + }, + interpretResponse: function (serverResponse) { + const response = serverResponse.body + + const bids = [] + + response.seatbid.forEach(seat => { + seat.bid.forEach(bid => { + bids.push({ + requestId: bid.impid, + cpm: bid.price, + width: bid.w, + height: bid.h, + creativeId: bid.crid, + ad: bid.adm, + currency: 'USD', + netRevenue: true, + ttl: 300, + meta: { + advertiserDomains: bid.adomain || [], + }, + }) + }) + }) + + return bids + }, +} + +registerBidder(spec) diff --git a/modules/idxBidAdapter.md b/modules/idxBidAdapter.md new file mode 100644 index 00000000000..4f0e35f2c24 --- /dev/null +++ b/modules/idxBidAdapter.md @@ -0,0 +1,28 @@ +# Overview + +``` +Module Name: IDX Bidder Adapter +Module Type: Bidder Adapter +Maintainer: dmitry@brainway.co.il +``` + +# Description + +Module that connects to the IDX solution. +The IDX bidder need one mediaTypes parameter: banner + +# Test Parameters +``` + var adUnits = [{ + code: 'your-slot-div-id', // This is your slot div id + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [{ + bidder: 'idx', + params: {} + }] + }] +``` diff --git a/modules/idxIdSystem.js b/modules/idxIdSystem.js index 908edad4c04..bf807f199a6 100644 --- a/modules/idxIdSystem.js +++ b/modules/idxIdSystem.js @@ -6,11 +6,12 @@ */ import { isStr, isPlainObject, logError } from '../src/utils.js'; import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const IDX_MODULE_NAME = 'idx'; const IDX_COOKIE_NAME = '_idx'; -export const storage = getStorageManager(); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: IDX_MODULE_NAME}); function readIDxFromCookie() { return storage.cookiesAreEnabled ? storage.getCookie(IDX_COOKIE_NAME) : null; @@ -56,6 +57,12 @@ export const idxIdSubmodule = { } } return undefined; + }, + eids: { + 'idx': { + source: 'idx.lat', + atype: 1 + }, } }; submodule('userId', idxIdSubmodule); diff --git a/modules/imRtdProvider.js b/modules/imRtdProvider.js index 6c582df3df3..26d49c49f8c 100644 --- a/modules/imRtdProvider.js +++ b/modules/imRtdProvider.js @@ -18,16 +18,18 @@ import { isFn } from '../src/utils.js' import {submodule} from '../src/hook.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; export const imUidLocalName = '__im_uid'; export const imVidCookieName = '_im_vid'; export const imRtdLocalName = '__im_sids'; -export const storage = getStorageManager(); const submoduleName = 'im'; const segmentsMaxAge = 3600000; // 1 hour (30 * 60 * 1000) const uidMaxAge = 1800000; // 30 minites (30 * 60 * 1000) const vidMaxAge = 97200000000; // 37 months ((365 * 3 + 30) * 24 * 60 * 60 * 1000) +export const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: submoduleName}); + function setImDataInCookie(value) { storage.setCookie( imVidCookieName, @@ -37,36 +39,40 @@ function setImDataInCookie(value) { ); } +/** + * @param {Object} segments + * @param {Object} moduleConfig + */ +function getSegments(segments, moduleConfig) { + if (!segments) return; + const maxSegments = !Number.isNaN(moduleConfig.params.maxSegments) ? moduleConfig.params.maxSegments : 200; + return segments.slice(0, maxSegments); +} + /** * @param {string} bidderName */ export function getBidderFunction(bidderName) { const biddersFunction = { - ix: function (bid, data) { - if (data.im_segments && data.im_segments.length) { - config.setConfig({ - ix: {firstPartyData: {im_segments: data.im_segments}}, - }); - } - return bid - }, - pubmatic: function (bid, data) { + pubmatic: function (bid, data, moduleConfig) { if (data.im_segments && data.im_segments.length) { + const segments = getSegments(data.im_segments, moduleConfig); const dctr = deepAccess(bid, 'params.dctr'); deepSetValue( bid, 'params.dctr', - `${dctr ? dctr + '|' : ''}im_segments=${data.im_segments.join(',')}` + `${dctr ? dctr + '|' : ''}im_segments=${segments.join(',')}` ); } return bid }, - fluct: function (bid, data) { + fluct: function (bid, data, moduleConfig) { if (data.im_segments && data.im_segments.length) { + const segments = getSegments(data.im_segments, moduleConfig); deepSetValue( bid, 'params.kv.imsids', - data.im_segments + segments ); } return bid @@ -96,15 +102,15 @@ export function setRealTimeData(bidConfig, moduleConfig, data) { const utils = {deepSetValue, deepAccess, logInfo, logError, mergeDeep}; if (data.im_segments) { - const ortb2 = config.getConfig('ortb2') || {}; - deepSetValue(ortb2, 'user.ext.data.im_segments', data.im_segments); - config.setConfig({ortb2: ortb2}); + const segments = getSegments(data.im_segments, moduleConfig); + const ortb2 = bidConfig.ortb2Fragments?.global || {}; + deepSetValue(ortb2, 'user.ext.data.im_segments', segments); if (moduleConfig.params.setGptKeyValues || !moduleConfig.params.hasOwnProperty('setGptKeyValues')) { window.googletag = window.googletag || {cmd: []}; window.googletag.cmd = window.googletag.cmd || []; window.googletag.cmd.push(() => { - window.googletag.pubads().setTargeting('im_segments', data.im_segments); + window.googletag.pubads().setTargeting('im_segments', segments); }); } } @@ -116,7 +122,7 @@ export function setRealTimeData(bidConfig, moduleConfig, data) { if (overwriteFunction) { overwriteFunction(bid, data, utils, config); } else if (bidderFunction) { - bidderFunction(bid, data); + bidderFunction(bid, data, moduleConfig); } }) }); diff --git a/modules/imRtdProvider.md b/modules/imRtdProvider.md index 7ece2b996b4..8f31d3eb545 100644 --- a/modules/imRtdProvider.md +++ b/modules/imRtdProvider.md @@ -21,7 +21,8 @@ pbjs.setConfig( waitForIt: true, params: { cid: 5126, // Set your Intimate Merger Customer ID here for production - setGptKeyValues: true + setGptKeyValues: true, + maxSegments: 200 // maximum number is 200 } } ] @@ -39,3 +40,4 @@ pbjs.setConfig( | params | Required | Object | Details of module params. | | | params.cid | Required | Number | This is the Customer ID value obtained via Intimate Merger. | `5126` | | params.setGptKeyValues | Optional | Boolean | This is set targeting for GPT/GAM. Default setting is true. | `true` | +| params.maxSegments | Optional | Number | This is set maximum number of rtd segments at once. Default setting is 200. | `200` | diff --git a/modules/synacormediaBidAdapter.js b/modules/imdsBidAdapter.js similarity index 73% rename from modules/synacormediaBidAdapter.js rename to modules/imdsBidAdapter.js index 4cc648a2e04..122662feb8a 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/imdsBidAdapter.js @@ -1,14 +1,16 @@ 'use strict'; -import {deepSetValue, getAdUnitSizes, isFn, isPlainObject, logWarn} from '../src/utils.js'; +import {deepAccess, deepSetValue, isFn, isPlainObject, logWarn, mergeDeep} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {includes} from '../src/polyfill.js'; import {config} from '../src/config.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; const BID_SCHEME = 'https://'; const BID_DOMAIN = 'technoratimedia.com'; -const USER_SYNC_HOST = 'https://ad-cdn.technoratimedia.com'; +const USER_SYNC_IFRAME_URL = 'https://ad-cdn.technoratimedia.com/html/usersync.html'; +const USER_SYNC_PIXEL_URL = 'https://sync.technoratimedia.com/services'; const VIDEO_PARAMS = [ 'minduration', 'maxduration', 'startdelay', 'placement', 'linearity', 'mimes', 'protocols', 'api' ]; const BLOCKED_AD_SIZES = [ '1x1', @@ -16,7 +18,10 @@ const BLOCKED_AD_SIZES = [ ]; const DEFAULT_MAX_TTL = 420; // 7 minutes export const spec = { - code: 'synacormedia', + code: 'imds', + aliases: [ + { code: 'synacormedia' } + ], supportedMediaTypes: [ BANNER, VIDEO ], sizeMap: {}, @@ -35,18 +40,24 @@ export const spec = { return; } const refererInfo = bidderRequest.refererInfo; - const openRtbBidRequest = { - id: bidderRequest.auctionId, + // start with some defaults, overridden by anything set in ortb2, if provided. + const openRtbBidRequest = mergeDeep({ + id: bidderRequest.bidderRequestId, site: { - domain: config.getConfig('publisherDomain') || location.hostname, - page: refererInfo.referer, - ref: document.referrer + domain: refererInfo.domain, + page: refererInfo.page, + ref: refererInfo.ref }, device: { ua: navigator.userAgent }, imp: [] - }; + }, bidderRequest.ortb2 || {}); + + const tmax = bidderRequest.timeout; + if (tmax) { + openRtbBidRequest.tmax = tmax; + } const schain = validBidReqs[0].schain; if (schain) { @@ -57,15 +68,15 @@ export const spec = { validBidReqs.forEach((bid, i) => { if (seatId && seatId !== bid.params.seatId) { - logWarn(`Synacormedia: there is an inconsistent seatId: ${bid.params.seatId} but only sending bid requests for ${seatId}, you should double check your configuration`); + logWarn(`IMDS: there is an inconsistent seatId: ${bid.params.seatId} but only sending bid requests for ${seatId}, you should double check your configuration`); return; } else { seatId = bid.params.seatId; } const tagIdOrPlacementId = bid.params.tagId || bid.params.placementId; - let pos = parseInt(bid.params.pos, 10); + let pos = parseInt(bid.params.pos || deepAccess(bid.mediaTypes, 'video.pos'), 10); if (isNaN(pos)) { - logWarn(`Synacormedia: there is an invalid POS: ${bid.params.pos}`); + logWarn(`IMDS: there is an invalid POS: ${bid.params.pos}`); pos = 0; } const videoOrBannerKey = this.isVideoBid(bid) ? 'video' : 'banner'; @@ -79,13 +90,30 @@ export const spec = { imps = this.buildVideoImpressions(adSizes, bid, tagIdOrPlacementId, pos, videoOrBannerKey); } if (imps.length > 0) { - imps.forEach(i => openRtbBidRequest.imp.push(i)); + imps.forEach(i => { + // Deeply add ext section to all imp[] for GPID, prebid slot id, and anything else down the line + const extSection = deepAccess(bid, 'ortb2Imp.ext'); + if (extSection) { + deepSetValue(i, 'ext', extSection); + } + + // Add imp[] to request object + openRtbBidRequest.imp.push(i); + }); } }); - // CCPA - if (bidderRequest && bidderRequest.uspConsent) { - deepSetValue(openRtbBidRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); + // Move us_privacy from regs.ext to regs if there isn't already a us_privacy in regs + if (openRtbBidRequest.regs?.ext?.us_privacy && !openRtbBidRequest.regs?.us_privacy) { + deepSetValue(openRtbBidRequest, 'regs.us_privacy', openRtbBidRequest.regs.ext.us_privacy); + } + + // Remove regs.ext.us_privacy + if (openRtbBidRequest.regs?.ext?.us_privacy) { + delete openRtbBidRequest.regs.ext.us_privacy; + if (Object.keys(openRtbBidRequest.regs.ext).length < 1) { + delete openRtbBidRequest.regs.ext; + } } // User ID @@ -99,7 +127,7 @@ export const spec = { if (openRtbBidRequest.imp.length && seatId) { return { method: 'POST', - url: `${BID_SCHEME}${seatId}.${BID_DOMAIN}/openrtb/bids/${seatId}?src=$$REPO_AND_VERSION$$`, + url: `${BID_SCHEME}${seatId}.${BID_DOMAIN}/openrtb/bids/${seatId}?src=pbjs%2F$prebid.version$`, data: openRtbBidRequest, options: { contentType: 'application/json', @@ -134,7 +162,7 @@ export const spec = { }; const bidFloor = getBidFloor(bid, 'banner', '*'); if (isNaN(bidFloor)) { - logWarn(`Synacormedia: there is an invalid bid floor: ${bid.params.bidfloor}`); + logWarn(`IMDS: there is an invalid bid floor: ${bid.params.bidfloor}`); } if (bidFloor !== null && !isNaN(bidFloor)) { imp.bidfloor = bidFloor; @@ -158,7 +186,7 @@ export const spec = { }; const bidFloor = getBidFloor(bid, 'video', size); if (isNaN(bidFloor)) { - logWarn(`Synacormedia: there is an invalid bid floor: ${bid.params.bidfloor}`); + logWarn(`IMDS: there is an invalid bid floor: ${bid.params.bidfloor}`); } if (bidFloor !== null && !isNaN(bidFloor)) { @@ -196,7 +224,7 @@ export const spec = { }; if (!serverResponse.body || typeof serverResponse.body != 'object') { - logWarn('Synacormedia: server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); + logWarn('IMDS: server returned empty/non-json response: ' + JSON.stringify(serverResponse.body)); return; } const {id, seatbid: seatbids} = serverResponse.body; @@ -276,16 +304,31 @@ export const spec = { } return bids; }, - getUserSyncs: function (syncOptions, serverResponses) { + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { const syncs = []; + const queryParams = ['src=pbjs%2F$prebid.version$']; + if (gdprConsent) { + queryParams.push(`gdpr=${Number(gdprConsent.gdprApplies && 1)}&consent=${encodeURIComponent(gdprConsent.consentString || '')}`); + } + if (uspConsent) { + queryParams.push('us_privacy=' + encodeURIComponent(uspConsent)); + } + if (gppConsent) { + queryParams.push('gpp=' + encodeURIComponent(gppConsent.gppString || '') + '&gppsid=' + encodeURIComponent((gppConsent.applicableSections || []).join(','))); + } + if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: `${USER_SYNC_HOST}/html/usersync.html?src=$$REPO_AND_VERSION$$` + url: `${USER_SYNC_IFRAME_URL}?${queryParams.join('&')}` + }); + } else if (syncOptions.pixelEnabled) { + syncs.push({ + type: 'pixel', + url: `${USER_SYNC_PIXEL_URL}?srv=cs&${queryParams.join('&')}` }); - } else { - logWarn('Synacormedia: Please enable iframe based user sync.'); } + return syncs; } }; diff --git a/modules/synacormediaBidAdapter.md b/modules/imdsBidAdapter.md similarity index 84% rename from modules/synacormediaBidAdapter.md rename to modules/imdsBidAdapter.md index 523c66fd1d9..15fb407e7ef 100644 --- a/modules/synacormediaBidAdapter.md +++ b/modules/imdsBidAdapter.md @@ -1,14 +1,14 @@ # Overview ``` -Module Name: Synacor Media Bidder Adapter +Module Name: iMedia Digital Services Bidder Adapter Module Type: Bidder Adapter -Maintainer: eng-demand@synacor.com +Maintainer: eng-demand@imds.tv ``` # Description -The Synacor Media adapter requires setup and approval from Synacor. +The iMedia Digital Services adapter requires setup and approval from iMedia Digital Services. Please reach out to your account manager for more information. ### DFP Video Creative @@ -30,7 +30,7 @@ https://track.technoratimedia.com/openrtb/tags?ID=%%PATTERN:hb_cache_id_synacorm } }, bids: [{ - bidder: "synacormedia", + bidder: "imds", params: { seatId: "prebid", tagId: "demo1", @@ -49,7 +49,7 @@ https://track.technoratimedia.com/openrtb/tags?ID=%%PATTERN:hb_cache_id_synacorm } }, bids: [{ - bidder: "synacormedia", + bidder: "imds", params: { seatId: "prebid", tagId: "demo1", diff --git a/modules/imonomyBidAdapter.md b/modules/imonomyBidAdapter.md deleted file mode 100644 index 451eb0994d8..00000000000 --- a/modules/imonomyBidAdapter.md +++ /dev/null @@ -1,29 +0,0 @@ -# Overview - -**Module Name**: Imonomy Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: support@imonomy.com - -# Description - -Connects to Imonomy demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [{ - code: 'banner-ad-div', - sizes: [[300, 250]], - - // Replace this object to test a new Adapter! - bids: [{ - bidder: 'imonomy', - params: { - placementId: 'e69148e0ba6c4c07977dc2daae5e1577', - hbid: '14567718624', - floorPrice: 0.5 - } - }] - }]; -``` - - diff --git a/modules/impactifyBidAdapter.js b/modules/impactifyBidAdapter.js index b204e81f22c..f2bf9aaddcb 100644 --- a/modules/impactifyBidAdapter.js +++ b/modules/impactifyBidAdapter.js @@ -1,8 +1,7 @@ -import { deepAccess, deepSetValue, generateUUID } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; +import {deepAccess, deepSetValue, generateUUID} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; import {ajax} from '../src/ajax.js'; -import { createEidsArray } from './userId/eids.js'; const BIDDER_CODE = 'impactify'; const BIDDER_ALIAS = ['imp']; @@ -25,21 +24,37 @@ const getDeviceType = () => { return 4; } return 2; +}; + +const getFloor = (bid) => { + const floorInfo = bid.getFloor({ + currency: DEFAULT_CURRENCY, + mediaType: '*', + size: '*' + }); + if (typeof floorInfo === 'object' && floorInfo.currency === DEFAULT_CURRENCY && !isNaN(parseFloat(floorInfo.floor))) { + return parseFloat(floorInfo.floor); + } + return null; } const createOpenRtbRequest = (validBidRequests, bidderRequest) => { // Create request and set imp bids inside let request = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, validBidRequests, cur: [DEFAULT_CURRENCY], imp: [], - source: {tid: bidderRequest.auctionId} + source: {tid: bidderRequest.ortb2?.source?.tid} }; + // Get the url parameters + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const checkPrebid = urlParams.get('_checkPrebid'); // Force impactify debugging parameter - if (window.localStorage.getItem('_im_db_bidder') != null) { - request.test = Number(window.localStorage.getItem('_im_db_bidder')); + if (checkPrebid != null) { + request.test = Number(checkPrebid); } // Set Schain in request @@ -47,9 +62,8 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => { if (schain) request.source.ext = { schain: schain }; // Set eids - let bidUserId = deepAccess(validBidRequests, '0.userId'); - let eids = createEidsArray(bidUserId); - if (eids.length) { + let eids = deepAccess(validBidRequests, '0.userIdAsEids'); + if (eids && eids.length) { deepSetValue(request, 'user.ext.eids', eids); } @@ -65,7 +79,7 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => { dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, language: ((navigator.language || navigator.userLanguage || '').split('-'))[0] || 'en', }; - request.site = {page: bidderRequest.refererInfo.referer}; + request.site = {page: bidderRequest.refererInfo.page}; // Handle privacy settings for GDPR/CCPA/COPPA let gdprApplies = 0; @@ -77,7 +91,6 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => { if (bidderRequest.uspConsent) { deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); - this.syncStore.uspConsent = bidderRequest.uspConsent; } if (GETCONFIG('coppa') == true) deepSetValue(request, 'regs.coppa', 1); @@ -110,6 +123,12 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => { if (bid.params.container) { imp.ext.impactify.container = bid.params.container; } + if (typeof bid.getFloor === 'function') { + const floor = getFloor(bid); + if (floor) { + imp.bidfloor = floor; + } + } request.imp.push(imp); }); diff --git a/modules/improvedigitalBidAdapter.js b/modules/improvedigitalBidAdapter.js index c696dabc64a..b56cc56a186 100644 --- a/modules/improvedigitalBidAdapter.js +++ b/modules/improvedigitalBidAdapter.js @@ -1,62 +1,35 @@ -import { - cleanObj, deepAccess, deepClone, deepSetValue, getBidIdParameter, getBidRequest, getDNT, - getUniqueIdentifierStr, isFn, isPlainObject, logWarn, mergeDeep, parseUrl -} from '../src/utils.js'; +import {deepAccess, deepSetValue, getBidIdParameter, getUniqueIdentifierStr, logWarn, mergeDeep} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {Renderer} from '../src/Renderer.js'; -import {createEidsArray} from './userId/eids.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {ortbConverter} from '../libraries/ortbConverter/converter.js'; +import {loadExternalScript} from '../src/adloader.js'; const BIDDER_CODE = 'improvedigital'; -const REQUEST_URL = 'https://ad.360yield.com/pb'; const CREATIVE_TTL = 300; +const AD_SERVER_BASE_URL = 'https://ad.360yield.com'; +const BASIC_ADS_BASE_URL = 'https://ad.360yield-basic.com'; +const PB_ENDPOINT = 'pb'; +const EXTEND_URL = 'https://pbs.360yield.com/openrtb2/auction'; +const IFRAME_SYNC_URL = 'https://hb.360yield.com/prebid-universal-creative/load-cookie.html'; + const VIDEO_PARAMS = { DEFAULT_MIMES: ['video/mp4'], - SUPPORTED_PROPERTIES: ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', 'placement', 'linearity', 'skip', 'skipmin', - 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', - 'api', 'companiontype', 'ext'], PLACEMENT_TYPE: { INSTREAM: 1, OUTSTREAM: 3, } }; -const NATIVE_DATA = { - VERSION: '1.2', - ASSET_TYPES: { - TITLE: 'title', - IMG: 'img', - DATA: 'data', - }, - ASSETS: { - title: {id: 0, name: 'title', assetType: 'title', default: {len: 140}}, - sponsoredBy: {id: 1, name: 'sponsoredBy', assetType: 'data', type: 1}, - icon: {id: 2, name: 'icon', assetType: 'img', type: 2}, - body: {id: 3, name: 'body', assetType: 'data', type: 2}, - image: {id: 4, name: 'image', assetType: 'img', type: 3}, - rating: {id: 5, name: 'rating', assetType: 'data', type: 3}, - likes: {id: 6, name: 'likes', assetType: 'data', type: 4}, - downloads: {id: 7, name: 'downloads', assetType: 'data', type: 5}, - price: {id: 8, name: 'price', assetType: 'data', type: 6}, - salePrice: {id: 9, name: 'salePrice', assetType: 'data', type: 7}, - phone: {id: 10, name: 'phone', assetType: 'data', type: 8}, - address: {id: 11, name: 'address', assetType: 'data', type: 9}, - body2: {id: 12, name: 'body2', assetType: 'data', type: 10}, - displayUrl: {id: 13, name: 'displayUrl', assetType: 'data', type: 11}, - cta: {id: 14, name: 'cta', assetType: 'data', type: 12}, - }, - getAssetById(id) { - return Object.values(this.ASSETS).find(asset => id === asset.id); - } -}; - export const spec = { code: BIDDER_CODE, gvlid: 253, aliases: ['id'], supportedMediaTypes: [BANNER, NATIVE, VIDEO], + syncStore: { extendMode: false, placementId: null }, /** * Determines whether or not the given bid request is valid. @@ -76,76 +49,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests(bidRequests, bidderRequest) { - const request = { - id: getUniqueIdentifierStr(), - cur: [config.getConfig('currency.adServerCurrency') || 'USD'], - ext: { - improvedigital: { - sdk: { - name: 'pbjs', - version: '$prebid.version$', - } - } - } - }; - - // Device - request.device = (typeof config.getConfig('device') === 'object') ? config.getConfig('device') : {}; - request.device.w = request.device.w || window.innerWidth; - request.device.h = request.device.h || window.innerHeight; - if (getDNT()) { - request.device.dnt = 1; - } - - // Coppa - const coppa = config.getConfig('coppa'); - if (typeof coppa === 'boolean') { - deepSetValue(request, 'regs.coppa', ID_UTIL.toBit(coppa)); - } - - if (bidderRequest) { - // GDPR - const gdprConsent = deepAccess(bidderRequest, 'gdprConsent') - if (gdprConsent) { - if (typeof gdprConsent.gdprApplies === 'boolean') { - deepSetValue(request, 'regs.ext.gdpr', ID_UTIL.toBit(gdprConsent.gdprApplies)); - } - deepSetValue(request, 'user.ext.consent', gdprConsent.consentString); - - // Additional Consent String - const additionalConsent = deepAccess(gdprConsent, 'addtlConsent'); - if (additionalConsent && additionalConsent.indexOf('~') !== -1) { - // Google Ad Tech Provider IDs - const atpIds = additionalConsent.substring(additionalConsent.indexOf('~') + 1); - deepSetValue( - request, - 'user.ext.consented_providers_settings.consented_providers', - atpIds.split('.').map(id => parseInt(id, 10)) - ); - } - } - - // Timeout - deepSetValue(request, 'tmax', bidderRequest.timeout); - // US Privacy - if (typeof bidderRequest.uspConsent !== typeof undefined) { - deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); - } - } - - ID_REQUEST.buildSiteOrApp(request, bidderRequest); - - const bidRequest0 = bidRequests[0]; - - deepSetValue(request, 'source.ext.schain', bidRequest0.schain); - deepSetValue(request, 'source.tid', bidRequest0.transactionId); - - if (bidRequest0.userId) { - const eids = createEidsArray(bidRequest0.userId); - deepSetValue(request, 'user.ext.eids', eids.length ? eids : undefined); - } - - return ID_REQUEST.buildServerRequests(request, bidRequests, bidderRequest); + // Save a placement id to send it to the ad server when fetching the user syncs + this.syncStore.placementId = this.syncStore.placementId || bidRequests[0].params.placementId; + return ID_REQUEST.buildServerRequests(bidRequests, bidderRequest); }, /** @@ -155,48 +61,8 @@ export const spec = { * @param bidderRequest * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse(serverResponse, { bidderRequest }) { - if (!Array.isArray(deepAccess(serverResponse, 'body.seatbid'))) { - return []; - } - - const bids = []; - - serverResponse.body.seatbid.forEach(seatbid => { - if (!Array.isArray(seatbid.bid)) return; - - seatbid.bid.forEach(bidObject => { - if (!bidObject.adm || !bidObject.price || bidObject.hasOwnProperty('errorCode')) { - return; - } - const bidRequest = getBidRequest(bidObject.impid, [bidderRequest]); - const idExt = deepAccess(bidObject, `ext.${BIDDER_CODE}`); - - const bid = { - requestId: bidObject.impid, - cpm: bidObject.price, - creativeId: bidObject.crid, - currency: serverResponse.body.cur.toUpperCase() || 'USD', - dealId: (typeof idExt.buying_type === 'string' && idExt.buying_type !== 'rtb') ? idExt.line_item_id : undefined, - meta: { - advertiserDomains: bidObject.adomain ? bidObject.adomain : [] - }, - netRevenue: idExt.is_net || false, - ttl: CREATIVE_TTL - } - - ID_RESPONSE.buildAd(bid, bidRequest, bidObject); - - ID_RAZR.addBidData({ - bidRequest, - bid - }); - - bids.push(bid); - }); - }); - - return bids; + interpretResponse(serverResponse, { ortbRequest }) { + return CONVERTER.fromORTB({request: ortbRequest, response: serverResponse.body}).bids; }, /** @@ -206,318 +72,261 @@ export const spec = { * @param {ServerResponse[]} serverResponses List of server's responses. * @return {UserSync[]} The user syncs which should be dropped. */ - getUserSyncs(syncOptions, serverResponses) { - if (syncOptions.pixelEnabled) { - const syncs = []; + getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { + if (config.getConfig('coppa') === true || !hasPurpose1Consent(gdprConsent)) { + return []; + } + + const syncs = []; + if ((this.syncStore.extendMode || !syncOptions.pixelEnabled) && syncOptions.iframeEnabled) { + const { gdprApplies, consentString } = gdprConsent || {}; + const bidders = new Set(); + if (this.syncStore.extendMode && serverResponses) { + serverResponses.forEach(response => { + if (!response?.body?.ext?.responsetimemillis) return; + Object.keys(response.body.ext.responsetimemillis).forEach(b => bidders.add(b)) + }) + } + syncs.push({ + type: 'iframe', + url: IFRAME_SYNC_URL + + `?placement_id=${this.syncStore.placementId}` + + (this.syncStore.extendMode ? '&pbs=1' : '') + + (typeof gdprApplies === 'boolean' ? `&gdpr=${Number(gdprApplies)}` : '') + + (consentString ? `&gdpr_consent=${consentString}` : '') + + (uspConsent ? `&us_privacy=${encodeURIComponent(uspConsent)}` : '') + + (bidders.size ? `&bidders=${[...bidders].join(',')}` : '') + }); + } else if (syncOptions.pixelEnabled) { serverResponses.forEach(response => { const syncArr = deepAccess(response, `body.ext.${BIDDER_CODE}.sync`, []); - syncArr.forEach(syncElement => { - if (syncs.indexOf(syncElement) === -1) { - syncs.push(syncElement); + syncArr.forEach(url => { + if (!syncs.some(sync => sync.url === url)) { + syncs.push({ type: 'image', url }); } }); }); - return syncs.map(sync => ({ type: 'image', url: sync })); } - return []; + + return syncs; } }; registerBidder(spec); -const ID_REQUEST = { - buildServerRequests(requestObject, bidRequests, bidderRequest) { - const requests = []; - if (config.getConfig('improvedigital.singleRequest') === true) { - requestObject.imp = bidRequests.map((bidRequest) => this.buildImp(bidRequest)); - requests[0] = this.formatRequest(requestObject, bidderRequest); - } else { - bidRequests.map((bidRequest) => { - const request = deepClone(requestObject); - request.id = bidRequest.bidId || getUniqueIdentifierStr(); - request.imp = [this.buildImp(bidRequest)]; - deepSetValue(request, 'source.tid', bidRequest.transactionId); - requests.push(this.formatRequest(request, bidderRequest)); - }); +export const CONVERTER = ortbConverter({ + context: { + ttl: CREATIVE_TTL, + nativeRequest: { + eventtrackers: [ + {event: 1, methods: [1, 2]}, + ] } - - return requests; }, - - formatRequest(request, bidderRequest) { - return { - method: 'POST', - url: REQUEST_URL, - data: JSON.stringify(request), - bidderRequest + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + imp.secure = Number(window.location.protocol === 'https:'); + if (!imp.bidfloor && bidRequest.params.bidFloor) { + imp.bidfloor = bidRequest.params.bidFloor; + imp.bidfloorcur = getBidIdParameter('bidFloorCur', bidRequest.params).toUpperCase() || 'USD' } - }, - - buildImp(bidRequest) { - const imp = { - id: getBidIdParameter('bidId', bidRequest) || getUniqueIdentifierStr(), - secure: ID_UTIL.toBit(window.location.protocol === 'https:'), - }; - - // Floor - const bidFloor = this.getBidFloor(bidRequest) || getBidIdParameter('bidFloor', bidRequest.params); - if (bidFloor) { - const bidFloorCur = getBidIdParameter('bidFloorCur', bidRequest.params) || 'USD'; - deepSetValue(imp, 'bidfloor', bidFloor); - deepSetValue(imp, 'bidfloorcur', bidFloorCur ? bidFloorCur.toUpperCase() : undefined); - } - - const placementId = getBidIdParameter('placementId', bidRequest.params); + const bidderParamsPath = context.extendMode ? 'ext.prebid.bidder.improvedigital' : 'ext.bidder'; + const placementId = bidRequest.params.placementId; if (placementId) { - deepSetValue(imp, 'ext.bidder.placementId', placementId); + deepSetValue(imp, `${bidderParamsPath}.placementId`, placementId); + if (context.extendMode) { + deepSetValue(imp, 'ext.prebid.storedrequest.id', '' + placementId); + } } else { - deepSetValue(imp, 'ext.bidder.publisherId', getBidIdParameter('publisherId', bidRequest.params)); - deepSetValue(imp, 'ext.bidder.placementKey', getBidIdParameter('placementKey', bidRequest.params)); - } - - deepSetValue(imp, 'ext.bidder.keyValues', getBidIdParameter('keyValues', bidRequest.params) || undefined); - - // Adding GPID - const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid') || - deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot') || - deepAccess(bidRequest, 'ortb2Imp.ext.data.adserver.adslot'); - - deepSetValue(imp, 'ext.gpid', gpid); - - // Adding Interstitial Signal - if (deepAccess(bidRequest, 'ortb2Imp.instl')) { - imp.instl = 1; - } - - const videoParams = deepAccess(bidRequest, 'mediaTypes.video'); - if (videoParams) { - imp.video = this.buildVideoRequest(bidRequest); - deepSetValue(imp, 'ext.is_rewarded_inventory', (videoParams.rewarded === 1 || deepAccess(videoParams, 'ext.rewarded') === 1) || undefined); - } - - if (deepAccess(bidRequest, 'mediaTypes.banner')) { - imp.banner = this.buildBannerRequest(bidRequest); - } - - if (deepAccess(bidRequest, 'mediaTypes.native')) { - imp.native = this.buildNativeRequest(bidRequest); + deepSetValue(imp, `${bidderParamsPath}.publisherId`, getBidIdParameter('publisherId', bidRequest.params)); + deepSetValue(imp, `${bidderParamsPath}.placementKey`, getBidIdParameter('placementKey', bidRequest.params)); } + deepSetValue(imp, `${bidderParamsPath}.keyValues`, getBidIdParameter('keyValues', bidRequest.params) || undefined); return imp; }, + request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + mergeDeep(request, { + id: getUniqueIdentifierStr(), + source: { - buildVideoRequest(bidRequest) { - const videoParams = deepClone(bidRequest.mediaTypes.video); - const videoImproveParams = deepClone(deepAccess(bidRequest, 'params.video', {})); - const video = {...videoParams, ...videoImproveParams}; - - if (Array.isArray(video.playerSize)) { - // Player size can be defined as [w, h] or [[w, h]] - const size = Array.isArray(video.playerSize[0]) ? video.playerSize[0] : video.playerSize; - video.w = size[0]; - video.h = size[1]; - } - video.placement = this.isOutstreamVideo(bidRequest) ? VIDEO_PARAMS.PLACEMENT_TYPE.OUTSTREAM : VIDEO_PARAMS.PLACEMENT_TYPE.INSTREAM; - - // Mimes is required - if (!video.mimes) { - video.mimes = VIDEO_PARAMS.DEFAULT_MIMES; - } - - // skip must be 0 or 1 - if (video.skip !== 1) { - delete video.skipmin; - delete video.skipafter; - if (video.skip !== 0) { - logWarn(`video.skip: invalid value '${video.skip}'. Expected 0 or 1`); - delete video.skip; - } - } - - Object.keys(video).forEach(prop => { - if (VIDEO_PARAMS.SUPPORTED_PROPERTIES.indexOf(prop) === -1) delete video[prop]; + }, + ext: { + improvedigital: { + sdk: { + name: 'pbjs', + version: '$prebid.version$', + } + } + }, }); - return video; + return request; }, - - buildBannerRequest(bidRequest) { - // Set the desired creative sizes - // Input Format: array of pairs, i.e. [[300, 250], [250, 250]] - // Unless improvedigital.usePrebidSizes == true, no sizes are sent to the server - // and the sizes defined in the server for the placement will be used - const banner = {}; - if (config.getConfig('improvedigital.usePrebidSizes') === true && bidRequest.sizes) { - // Convert sizes from [x, y] to { w: x, h: y} - banner.format = bidRequest.sizes.map(sizePair => ({w: sizePair[0], h: sizePair[1]})); + bidResponse(buildBidResponse, bid, context) { + if (!bid.adm || !bid.price || bid.hasOwnProperty('errorCode')) { + return; } - return banner; - }, - - buildNativeRequest(bidRequest) { - const nativeParams = bidRequest.mediaTypes.native; - const request = { - assets: [], + const {bidRequest} = context; + context.mediaType = (() => { + const requestMediaTypes = Object.keys(bidRequest.mediaTypes); + if (requestMediaTypes.length === 1) return requestMediaTypes[0]; + // Detect media type for multi-format response + if (bid.adm.search(/^(<\?xml| parseInt(id, 10)) + ); + } } - request.assets.push(asset); } } - return { ver: NATIVE_DATA.VERSION, request: JSON.stringify(request) }; - }, - - isOutstreamVideo(bidRequest) { - return deepAccess(bidRequest, 'mediaTypes.video.context') === 'outstream'; - }, + } +}) - getBidFloor(bidRequest) { - if (!isFn(bidRequest.getFloor)) { - return null; - } - const floor = bidRequest.getFloor({ - currency: 'USD', - mediaType: '*', - size: '*' - }); - if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { - return floor.floor; - } - return null; - }, +const ID_REQUEST = { + buildServerRequests(bidRequests, bidderRequest) { + const globalExtendMode = config.getConfig('improvedigital.extend') === true; + const requests = []; + const singleRequestMode = config.getConfig('improvedigital.singleRequest') === true; - buildSiteOrApp(request, bidderRequest) { - const app = {}; - const configAppSettings = config.getConfig('app') || {}; - const fpdAppSettings = config.getConfig('ortb2.app') || {}; - mergeDeep(app, configAppSettings, fpdAppSettings); + const extendBids = []; + const adServerBids = []; - if (Object.keys(app).length !== 0) { - request.app = app; - } else { - const site = {}; - const url = config.getConfig('pageUrl') || deepAccess(bidderRequest, 'refererInfo.referer'); - if (url) { - site.page = url; - site.domain = parseUrl(url).hostname; + function adServerUrl(extendMode, publisherId) { + if (extendMode) { + return EXTEND_URL; } - const configSiteSettings = config.getConfig('site') || {}; - const fpdSiteSettings = config.getConfig('ortb2.site') || {}; - mergeDeep(site, configSiteSettings, fpdSiteSettings); - request.site = site; + const urlSegments = []; + urlSegments.push(hasPurpose1Consent(bidderRequest?.gdprConsent) ? AD_SERVER_BASE_URL : BASIC_ADS_BASE_URL) + if (publisherId) { + urlSegments.push(publisherId) + } + urlSegments.push(PB_ENDPOINT) + return urlSegments.join('/'); } - }, -}; -const ID_RESPONSE = { - buildAd(bid, bidRequest, bidResponse) { - if (bidRequest.mediaTypes && Object.keys(bidRequest.mediaTypes).length === 1) { - if (deepAccess(bidRequest, 'mediaTypes.video')) { - this.buildVideoAd(bid, bidRequest, bidResponse); - } else if (deepAccess(bidRequest, 'mediaTypes.banner')) { - this.buildBannerAd(bid, bidRequest, bidResponse); - } else if (deepAccess(bidRequest, 'mediaTypes.native')) { - this.buildNativeAd(bid, bidRequest, bidResponse) + function formatRequest(bidRequests, publisherId, extendMode) { + const ortbRequest = CONVERTER.toORTB({bidRequests, bidderRequest, context: {extendMode}}); + return { + method: 'POST', + url: adServerUrl(extendMode, publisherId), + data: JSON.stringify(ortbRequest), + ortbRequest, + bidderRequest } - } else { - if (bidResponse.adm.search(/^ { + const bidParamsPublisherId = bidRequest.params.publisherId; + const extendModeEnabled = this.isExtendModeEnabled(globalExtendMode, bidRequest.params); + if (singleRequestMode) { + if (!publisherId) { + publisherId = bidParamsPublisherId; + } else if (bidParamsPublisherId && publisherId !== bidParamsPublisherId) { + throw new Error(`All Improve Digital placements in a single call must have the same publisherId. Please check your 'params.publisherId' or turn off the single request mode.`); + } + extendModeEnabled ? extendBids.push(bidRequest) : adServerBids.push(bidRequest); } else { - this.buildBannerAd(bid, bidRequest, bidResponse); + requests.push(formatRequest([bidRequest], bidParamsPublisherId, extendModeEnabled)); } + }); + + if (!singleRequestMode) { + return requests; + } + // In the single request mode, split imps between those going to the ad server and those going to extend server + if (extendBids.length) { + requests.push(formatRequest(extendBids, publisherId, true)); + } + if (adServerBids.length) { + requests.push(formatRequest(adServerBids, publisherId, false)); } + + return requests; }, - buildVideoAd(bid, bidRequest, bidResponse) { - bid.mediaType = VIDEO; - bid.vastXml = bidResponse.adm; - if (ID_REQUEST.isOutstreamVideo(bidRequest)) { - bid.adResponse = { content: bid.vastXml }; - bid.renderer = ID_OUTSTREAM.createRenderer(bidRequest); + isExtendModeEnabled(globalExtendMode, bidParams) { + const extendMode = typeof bidParams.extend === 'boolean' ? bidParams.extend : globalExtendMode; + if (extendMode && !spec.syncStore.extendMode) { + spec.syncStore.extendMode = true; } + return extendMode; }, - buildBannerAd(bid, bidRequest, bidResponse) { - bid.mediaType = BANNER; - bid.ad = bidResponse.adm; - bid.width = bidResponse.w; - bid.height = bidResponse.h; + isOutstreamVideo(bidRequest) { + return deepAccess(bidRequest, 'mediaTypes.video.context') === 'outstream'; }, - buildNativeAd(bid, bidRequest, bidResponse) { - bid.mediaType = NATIVE; - const nativeResponse = JSON.parse(bidResponse.adm); - const nativeAd = { - clickUrl: deepAccess(nativeResponse, 'link.url'), - clickTrackers: deepAccess(nativeResponse, 'link.clicktrackers'), - privacyLink: nativeResponse.privacy - } - // Trackers - if (nativeResponse.eventtrackers) { - nativeAd.impressionTrackers = []; - nativeResponse.eventtrackers.forEach(tracker => { - // Only handle impression event. Viewability events are not supported yet. - if (tracker.event !== 1) return; - switch (tracker.method) { - case 1: // img - nativeAd.impressionTrackers.push(tracker.url); - break; - case 2: // js - // javascriptTrackers is a string. If there's more than one JS tracker in bid response, the last script will be used. - nativeAd.javascriptTrackers = ``; - break; - } - }); - } else { - nativeAd.impressionTrackers = nativeResponse.imptrackers || []; - nativeAd.javascriptTrackers = nativeResponse.jstracker; - } - nativeResponse.assets.map(asset => { - const assetParams = NATIVE_DATA.getAssetById(asset.id); - switch (assetParams.assetType) { - case NATIVE_DATA.ASSET_TYPES.TITLE: - nativeAd.title = asset.title.text; - break; - case NATIVE_DATA.ASSET_TYPES.DATA: - nativeAd[assetParams.name] = asset.data.value; - break; - case NATIVE_DATA.ASSET_TYPES.IMG: - nativeAd[assetParams.name] = { - url: asset.img.url, - width: asset.img.w, - height: asset.img.h, - }; - break; - } - }); - bid.native = nativeAd; - }, }; const ID_OUTSTREAM = { @@ -554,43 +363,58 @@ const ID_OUTSTREAM = { }; const ID_RAZR = { - RENDERER_URL: 'https://razr.improvedigital.com/renderer.js', - addBidData({bid, bidRequest}) { - if (this.isValidBid(bid)) { - bid.renderer = Renderer.install({ - url: this.RENDERER_URL, - config: {bidRequest} - }); - bid.renderer.setRender(this.render); - } - }, + RENDERER_URL: 'https://cdn.360yield.com/razr/tag.js', - isValidBid(bid) { - return bid && /razr:\/\//.test(bid.ad); - }, + forwardBid({bidRequest, bid}) { + if (bid.mediaType !== BANNER) { + return; + } - render(bid) { - const {bidRequest} = bid.renderer.getConfig(); - - const payload = { - type: 'prebid', - bidRequest, - bid, - config: mergeDeep( - {}, - config.getConfig('improvedigital.rendererConfig'), - deepAccess(bidRequest, 'params.rendererConfig') - ) + const cfg = { + prebid: { + bidRequest, + bid + } }; - const razr = window.razr = window.razr || {}; - razr.queue = razr.queue || []; - razr.queue.push(payload); - } -}; + const cfgStr = JSON.stringify(cfg).replace(/<\/script>/ig, '\\x3C/script>'); + const s = ``; + bid.ad = bid.ad.replace(/]*>/, match => match + s); -const ID_UTIL = { - toBit(val) { - return val ? 1 : 0; + this.installListener(); }, + + installListener() { + if (this._listenerInstalled) { + return; + } + + window.addEventListener('message', function(e) { + const data = e.data?.razr?.load; + if (!data) { + return; + } + + if (e.source) { + data.source = e.source; + if (data.id) { + e.source.postMessage({ + razr: { + id: data.id + } + }, '*'); + } + } + + const ns = window.razr = window.razr || {}; + ns.q = ns.q || []; + ns.q.push(data); + + if (!ns.loaded) { + loadExternalScript(ID_RAZR.RENDERER_URL, BIDDER_CODE); + } + }); + + this._listenerInstalled = true; + } }; diff --git a/modules/imuIdSystem.js b/modules/imuIdSystem.js index 72e81d243a3..38870c9403b 100644 --- a/modules/imuIdSystem.js +++ b/modules/imuIdSystem.js @@ -8,26 +8,20 @@ import { timestamp, logError } from '../src/utils.js'; import { ajax } from '../src/ajax.js' import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; -export const storage = getStorageManager(); +const MODULE_NAME = 'imuid'; + +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); export const storageKey = '__im_uid'; +export const storagePpKey = '__im_ppid'; export const cookieKey = '_im_vid'; -export const apiUrl = 'https://audiencedata.im-apps.net/imuid/get'; +export const apiDomain = 'sync6.im-apps.net'; const storageMaxAge = 1800000; // 30 minites (30 * 60 * 1000) const cookiesMaxAge = 97200000000; // 37 months ((365 * 3 + 30) * 24 * 60 * 60 * 1000) -export function setImDataInLocalStorage(value) { - storage.setDataInLocalStorage(storageKey, value); - storage.setDataInLocalStorage(`${storageKey}_mt`, new Date(timestamp()).toUTCString()); -} - -export function removeImDataFromLocalStorage() { - storage.removeDataFromLocalStorage(storageKey); - storage.removeDataFromLocalStorage(`${storageKey}_mt`); -} - function setImDataInCookie(value) { storage.setCookie( cookieKey, @@ -37,6 +31,12 @@ function setImDataInCookie(value) { ); } +export function removeImDataFromLocalStorage() { + storage.removeDataFromLocalStorage(storageKey); + storage.removeDataFromLocalStorage(`${storageKey}_mt`); + storage.removeDataFromLocalStorage(storagePpKey); +} + export function getLocalData() { const mt = storage.getDataFromLocalStorage(`${storageKey}_mt`); let expired = true; @@ -45,17 +45,27 @@ export function getLocalData() { } return { id: storage.getDataFromLocalStorage(storageKey), + ppid: storage.getDataFromLocalStorage(storagePpKey), vid: storage.getCookie(cookieKey), expired: expired }; } +export function getApiUrl(cid, url) { + if (url) { + return `${url}?cid=${cid}`; + } + return `https://${apiDomain}/${cid}/pid`; +} + export function apiSuccessProcess(jsonResponse) { if (!jsonResponse) { return; } - if (jsonResponse.uid) { - setImDataInLocalStorage(jsonResponse.uid); + if (jsonResponse.uid && jsonResponse.ppid) { + storage.setDataInLocalStorage(storageKey, jsonResponse.uid); + storage.setDataInLocalStorage(`${storageKey}_mt`, new Date(timestamp()).toUTCString()); + storage.setDataInLocalStorage(storagePpKey, jsonResponse.ppid); if (jsonResponse.vid) { setImDataInCookie(jsonResponse.vid); } @@ -77,7 +87,11 @@ export function getApiCallback(callback) { } } if (callback && responseObj.uid) { - callback(responseObj.uid); + const callbackObj = { + imuid: responseObj.uid, + imppid: responseObj.ppid + }; + callback(callbackObj); } }, error: error => { @@ -95,35 +109,31 @@ export function callImuidApi(apiUrl) { }; } -export function getApiUrl(cid, url) { - if (url) { - return `${url}?cid=${cid}`; - } - return `${apiUrl}?cid=${cid}`; -} - /** @type {Submodule} */ export const imuIdSubmodule = { /** * used to link submodule with config * @type {string} */ - name: 'imuid', + name: MODULE_NAME, /** * decode the stored id value for passing to bid requests * @function - * @returns {{imuid: string} | undefined} + * @returns {{imuid: string, imppid: string} | undefined} */ - decode(id) { - if (id && typeof id === 'string') { - return {imuid: id}; + decode(ids) { + if (ids && typeof ids === 'object') { + return { + imuid: ids.imuid, + imppid: ids.imppid + }; } return undefined; }, /** * @function * @param {SubmoduleConfig} [config] - * @returns {{id: string} | undefined | {callback:function}}} + * @returns {{id:{imuid: string, imppid: string}} | undefined | {callback:function}}} */ getId(config) { const configParams = (config && config.params) || {}; @@ -139,12 +149,27 @@ export const imuIdSubmodule = { } if (!localData.id) { - return {callback: callImuidApi(apiUrl)} + return {callback: callImuidApi(apiUrl)}; } if (localData.expired) { callImuidApi(apiUrl)(); } - return {id: localData.id}; + return { + id: { + imuid: localData.id, + imppid: localData.ppid + } + }; + }, + eids: { + 'imppid': { + source: 'ppid.intimatemerger.com', + atype: 1 + }, + 'imuid': { + source: 'intimatemerger.com', + atype: 1 + }, } }; diff --git a/modules/imuIdSystem.md b/modules/imuIdSystem.md index 81aa87ba1d4..cda7fa6528d 100644 --- a/modules/imuIdSystem.md +++ b/modules/imuIdSystem.md @@ -16,6 +16,7 @@ The following configuration parameters are available: ```javascript pbjs.setConfig({ userSync: { + ppid: 'ppid.intimatemerger.com', // GAM Publisher Provided id support userIds: [{ name: 'imuid', params: { diff --git a/modules/incrxBidAdapter.js b/modules/incrxBidAdapter.js new file mode 100644 index 00000000000..d054309ee40 --- /dev/null +++ b/modules/incrxBidAdapter.js @@ -0,0 +1,90 @@ +import { parseSizesInput, isEmpty } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js' + +const BIDDER_CODE = 'incrementx'; +const ENDPOINT_URL = 'https://hb.incrementxserv.com/vzhbidder/bid'; +const DEFAULT_CURRENCY = 'USD'; +const CREATIVE_TTL = 300; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + return !!(bid.params.placementId); + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param validBidRequests + * @param bidderRequest + * @return Array Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + return validBidRequests.map(bidRequest => { + const sizes = parseSizesInput(bidRequest.params.size || bidRequest.sizes); + + const requestParams = { + _vzPlacementId: bidRequest.params.placementId, + sizes: sizes, + _slotBidId: bidRequest.bidId, + // TODO: is 'page' the right value here? + _rqsrc: bidderRequest.refererInfo.page, + }; + + const payload = { + q: encodeURI(JSON.stringify(requestParams)) + } + + return { + method: 'POST', + url: ENDPOINT_URL, + data: payload + }; + }); + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse) { + const response = serverResponse.body; + const bids = []; + if (isEmpty(response)) { + return bids; + } + const responseBid = { + requestId: response.slotBidId, + cpm: response.cpm, + currency: response.currency || DEFAULT_CURRENCY, + adType: response.adType || '1', + settings: response.settings, + width: response.adWidth, + height: response.adHeight, + ttl: CREATIVE_TTL, + creativeId: response.creativeId || 0, + netRevenue: response.netRevenue || false, + meta: { + mediaType: response.mediaType || BANNER, + advertiserDomains: response.advertiserDomains || [] + }, + ad: response.ad + }; + bids.push(responseBid); + return bids; + } + +}; + +registerBidder(spec); diff --git a/modules/inmarBidAdapter.js b/modules/inmarBidAdapter.js deleted file mode 100755 index 0e056551b35..00000000000 --- a/modules/inmarBidAdapter.js +++ /dev/null @@ -1,110 +0,0 @@ -import { logError } from '../src/utils.js'; -import { config } from '../src/config.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; - -const BIDDER_CODE = 'inmar'; - -export const spec = { - code: BIDDER_CODE, - aliases: ['inm'], - supportedMediaTypes: [BANNER, VIDEO], - - /** - * Determines whether or not the given bid request is valid - * - * @param {bidRequest} bid The bid params to validate. - * @returns {boolean} True if this is a valid bid, and false otherwise - */ - isBidRequestValid: function(bid) { - return !!(bid.params && bid.params.partnerId); - }, - - /** - * Build a server request from the list of valid BidRequests - * @param {validBidRequests} is an array of the valid bids - * @param {bidderRequest} bidder request object - * @returns {ServerRequest} Info describing the request to the server - */ - buildRequests: function(validBidRequests, bidderRequest) { - var payload = { - bidderCode: bidderRequest.bidderCode, - auctionId: bidderRequest.auctionId, - bidderRequestId: bidderRequest.bidderRequestId, - bidRequests: validBidRequests, - auctionStart: bidderRequest.auctionStart, - timeout: bidderRequest.timeout, - refererInfo: bidderRequest.refererInfo, - start: bidderRequest.start, - gdprConsent: bidderRequest.gdprConsent, - uspConsent: bidderRequest.uspConsent, - currencyCode: config.getConfig('currency.adServerCurrency'), - coppa: config.getConfig('coppa'), - firstPartyData: config.getLegacyFpd(config.getConfig('ortb2')), - prebidVersion: '$prebid.version$' - }; - - var payloadString = JSON.stringify(payload); - - return { - method: 'POST', - url: 'https://prebid.owneriq.net:8443/bidder/pb/bid', - data: payloadString, - }; - }, - - /** - * Read the response from the server and build a list of bids - * @param {serverResponse} Response from the server. - * @param {bidRequest} Bid request object - * @returns {bidResponses} Array of bids which were nested inside the server - */ - interpretResponse: function(serverResponse, bidRequest) { - const bidResponses = []; - var response = serverResponse.body; - - try { - if (response) { - var bidResponse = { - requestId: response.requestId, - cpm: response.cpm, - currency: response.currency, - width: response.width, - height: response.height, - ad: response.ad, - ttl: response.ttl, - creativeId: response.creativeId, - netRevenue: response.netRevenue, - vastUrl: response.vastUrl, - dealId: response.dealId, - meta: response.meta - }; - - bidResponses.push(bidResponse); - } - } catch (error) { - logError('Error while parsing inmar response', error); - } - return bidResponses; - }, - - /** - * User Syncs - * - * @param {syncOptions} Publisher prebid configuration - * @param {serverResponses} Response from the server - * @returns {Array} - */ - getUserSyncs: function(syncOptions, serverResponses) { - const syncs = []; - if (syncOptions.pixelEnabled) { - syncs.push({ - type: 'image', - url: 'https://px.owneriq.net/eucm/p/pb' - }); - } - return syncs; - } -}; - -registerBidder(spec); diff --git a/modules/inmarBidAdapter.md b/modules/inmarBidAdapter.md deleted file mode 100644 index 8ed6b998602..00000000000 --- a/modules/inmarBidAdapter.md +++ /dev/null @@ -1,44 +0,0 @@ -# Overview - -``` -Module Name: Inmar Bidder Adapter -Module Type: Bidder Adapter -Maintainer: oiq_rtb@inmar.com -``` - -# Description - -Connects to Inmar for bids. This adapter supports Display and Video. - -The Inmar adapter requires setup and approval from the Inmar team. -Please reach out to your account manager for more information. - -# Test Parameters - -## Web -``` - var adUnits = [ - { - code: 'test-div1', - sizes: [[300, 250],[300, 600]], - bids: [{ - bidder: 'inmar', - params: { - partnerId: 12345, - position: 1 - } - }] - }, - { - code: 'test-div2', - sizes: [[728, 90],[970, 250]], - bids: [{ - bidder: 'inmar', - params: { - partnerId: 12345, - position: 0 - } - }] - } - ]; -``` diff --git a/modules/innityBidAdapter.js b/modules/innityBidAdapter.js index 0a2f701ef64..99eec210193 100644 --- a/modules/innityBidAdapter.js +++ b/modules/innityBidAdapter.js @@ -23,13 +23,14 @@ export const spec = { output: 'js', pub: bidRequest.params.pub, zone: bidRequest.params.zone, - url: bidderRequest && bidderRequest.refererInfo ? encodeURIComponent(bidderRequest.refererInfo.referer) : '', + url: bidderRequest && bidderRequest.refererInfo ? encodeURIComponent(bidderRequest.refererInfo.page) : '', width: arrSize[0], height: arrSize[1], vpw: window.screen.width, vph: window.screen.height, callback: 'json', callback_uid: bidRequest.bidId, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auction: bidRequest.auctionId, }, }; diff --git a/modules/inskinBidAdapter.js b/modules/inskinBidAdapter.js deleted file mode 100644 index 781bca90660..00000000000 --- a/modules/inskinBidAdapter.js +++ /dev/null @@ -1,392 +0,0 @@ -import { createTrackPixelHtml } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'inskin'; - -const CONFIG = { - BASE_URI: 'https://mfad.inskinad.com/api/v2' -}; - -export const spec = { - code: BIDDER_CODE, - - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.networkId && bid.params.siteId); - }, - - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @param {bidderRequest} - the full bidder request object - * @return ServerRequest Info describing the request to the server. - */ - - buildRequests: function(validBidRequests, bidderRequest) { - // Do we need to group by bidder? i.e. to make multiple requests for - // different endpoints. - - let ret = { - method: 'POST', - url: '', - data: '', - bidRequest: [] - }; - - if (validBidRequests.length < 1) { - return ret; - } - - let ENDPOINT_URL; - - const data = Object.assign({ - placements: [], - time: Date.now(), - user: {}, - url: bidderRequest.refererInfo.referer, - enableBotFiltering: true, - includePricingData: true, - parallel: true - }, validBidRequests[0].params); - - if (validBidRequests[0].schain) { - data.rtb = { - schain: validBidRequests[0].schain - }; - } else if (data.publisherId) { - data.rtb = { - schain: { - ext: { - sid: String(data.publisherId) - } - } - }; - } - - delete data.publisherId; - - data.keywords = data.keywords || []; - const restrictions = []; - - if (bidderRequest && bidderRequest.gdprConsent) { - data.consent = { - gdprVendorId: 150, - gdprConsentString: bidderRequest.gdprConsent.consentString, - // will check if the gdprApplies field was populated with a boolean value (ie from page config). If it's undefined, then default to true - gdprConsentRequired: (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true - }; - - if (bidderRequest.gdprConsent.apiVersion === 2) { - const purposes = [ - {id: 1, kw: 'nocookies'}, - {id: 2, kw: 'nocontext'}, - {id: 3, kw: 'nodmp'}, - {id: 4, kw: 'nodata'}, - {id: 7, kw: 'noclicks'}, - {id: 9, kw: 'noresearch'} - ]; - - const d = bidderRequest.gdprConsent.vendorData; - - if (d) { - if (d.purposeOneTreatment) { - data.keywords.push('cst-nodisclosure'); - restrictions.push('nodisclosure'); - } - - purposes.map(p => { - if (!checkConsent(p.id, d)) { - data.keywords.push('cst-' + p.kw); - restrictions.push(p.kw); - } - }); - } - } - } - - validBidRequests.map(bid => { - ENDPOINT_URL = CONFIG.BASE_URI; - - const placement = Object.assign({ - divName: bid.bidId, - adTypes: bid.adTypes || getSize(bid.sizes), - eventIds: [40, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295] - }, bid.params); - - placement.adTypes.push(5, 9, 163, 2163, 3006); - - placement.properties = placement.properties || {}; - - placement.properties.screenWidth = screen.width; - placement.properties.screenHeight = screen.height; - - if (restrictions.length) { - placement.properties.restrictions = restrictions; - } - - if (placement.networkId && placement.siteId) { - data.placements.push(placement); - } - }); - - ret.data = JSON.stringify(data); - ret.bidRequest = validBidRequests; - ret.url = ENDPOINT_URL; - - return ret; - }, - - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - let bid; - let bids; - let bidId; - let bidObj; - let bidResponses = []; - let bidsMap = {}; - - bids = bidRequest.bidRequest; - - serverResponse = (serverResponse || {}).body; - for (let i = 0; i < bids.length; i++) { - bid = {}; - bidObj = bids[i]; - bidId = bidObj.bidId; - - bidsMap[bidId] = bidObj; - - if (serverResponse) { - const decision = serverResponse.decisions && serverResponse.decisions[bidId]; - const data = decision && decision.contents && decision.contents[0] && decision.contents[0].data; - const pubCPM = data && data.customData && data.customData.pubCPM; - const clearPrice = decision && decision.pricing && decision.pricing.clearPrice; - const price = pubCPM || clearPrice; - - if (decision && price) { - decision.impressionUrl += ('&property:pubcpm=' + price); - bidObj.price = price; - - bid.requestId = bidId; - bid.cpm = price; - bid.width = decision.width; - bid.height = decision.height; - bid.ad = retrieveAd(bidId, decision); - bid.currency = 'USD'; - bid.creativeId = decision.adId; - bid.ttl = 360; - bid.meta = { advertiserDomains: decision.adomain ? decision.adomain : [] } - bid.netRevenue = true; - - bidResponses.push(bid); - } - } - } - - if (bidResponses.length) { - window.addEventListener('message', function(e) { - if (!e.data || e.data.from !== 'ism-bid') { - return; - } - - const decision = serverResponse.decisions && serverResponse.decisions[e.data.bidId]; - if (!decision) { - return; - } - - const id = 'ism_tag_' + Math.floor((Math.random() * 10e16)); - window[id] = { - plr_AdSlot: e.source && e.source.frameElement, - bidId: e.data.bidId, - bidPrice: bidsMap[e.data.bidId].price, - serverResponse - }; - const script = document.createElement('script'); - script.src = 'https://cdn.inskinad.com/isfe/publishercode/' + bidsMap[e.data.bidId].params.siteId + '/default.js?autoload&id=' + id; - document.getElementsByTagName('head')[0].appendChild(script); - }); - } - - return bidResponses; - }, - - getUserSyncs: function(syncOptions) { - const userSyncs = []; - - if (syncOptions.pixelEnabled) { - userSyncs.push({ - type: 'image', - url: 'https://e.serverbid.com/udb/9969/match?redir=https%3A%2F%2Fmfad.inskinad.com%2Fudb%2F9874%2Fpool%2Fset%2Fi.gif%3FpoolId%3D9969%26poolKey%3D' - }); - userSyncs.push({ - type: 'image', - url: 'https://ssum.casalemedia.com/usermatchredir?s=185638&cb=https%3A%2F%2Fmfad.inskinad.com%2Fudb%2F9874%2Fsync%2Fi.gif%3FpartnerId%3D1%26userId%3D' - }); - } - - if (syncOptions.iframeEnabled) { - userSyncs.push({ - type: 'iframe', - url: 'https://ssum-sec.casalemedia.com/usermatch?s=184665&cb=https%3A%2F%2Fmfad.inskinad.com%2Fudb%2F9874%2Fsync%2Fi.gif%3FpartnerId%3D1%26userId%3D' - }); - } - - return userSyncs; - } -}; - -const sizeMap = [ - null, - '120x90', - '120x90', - '468x60', - '728x90', - '300x250', - '160x600', - '120x600', - '300x100', - '180x150', - '336x280', - '240x400', - '234x60', - '88x31', - '120x60', - '120x240', - '125x125', - '220x250', - '250x250', - '250x90', - '0x0', - '200x90', - '300x50', - '320x50', - '320x480', - '185x185', - '620x45', - '300x125', - '800x250' -]; - -sizeMap[77] = '970x90'; -sizeMap[123] = '970x250'; -sizeMap[43] = '300x600'; - -function getSize(sizes) { - const result = []; - sizes.forEach(function(size) { - const index = sizeMap.indexOf(size[0] + 'x' + size[1]); - if (index >= 0) { - result.push(index); - } - }); - return result; -} - -function retrieveAd(bidId, decision) { - return " + +``` + +[Additional embed instructions](https://docs.jwplayer.com/platform/docs/players-get-started) + +[Obtaining a license](https://info.jwplayer.com/contact-us/) diff --git a/modules/kargoAnalyticsAdapter.js b/modules/kargoAnalyticsAdapter.js index 83c20846c0d..652e105167d 100644 --- a/modules/kargoAnalyticsAdapter.js +++ b/modules/kargoAnalyticsAdapter.js @@ -1,14 +1,96 @@ -import adapter from '../src/AnalyticsAdapter.js'; +import { logError } from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; +import CONSTANTS from '../src/constants.json'; -var kargoAdapter = adapter({ - analyticsType: 'endpoint', - url: 'https://krk.kargo.com/api/v1/event/prebid' -}); +const EVENT_URL = 'https://krk.kargo.com/api/v1/event'; +const KARGO_BIDDER_CODE = 'kargo'; + +const analyticsType = 'endpoint'; + +let _initOptions = {}; + +let _logBidResponseData = { + auctionId: '', + auctionTimeout: 0, + responseTime: 0, +}; + +let _bidResponseDataLogged = []; + +var kargoAnalyticsAdapter = Object.assign( + adapter({ analyticsType }), { + track({ eventType, args }) { + switch (eventType) { + case CONSTANTS.EVENTS.AUCTION_INIT: { + _logBidResponseData.auctionTimeout = args.timeout; + break; + } + case CONSTANTS.EVENTS.BID_RESPONSE: { + handleBidResponseData(args); + break; + } + } + } + } +); + +// handleBidResponseData: Get auction data for Kargo bids and send to server +function handleBidResponseData (bidResponse) { + // Verify this is Kargo and we haven't seen this auction data yet + if (bidResponse.bidder !== KARGO_BIDDER_CODE || _bidResponseDataLogged.includes(bidResponse.auctionId) !== false) { + return + } + + _logBidResponseData.auctionId = bidResponse.auctionId; + _logBidResponseData.responseTime = bidResponse.timeToRespond; + sendAuctionData(_logBidResponseData); +} + +// sendAuctionData: Send auction data to the server +function sendAuctionData (data) { + try { + _bidResponseDataLogged.push(data.auctionId); + + if (!shouldFireEventRequest()) { + return; + } + + ajax( + `${EVENT_URL}/auction-data`, + null, + { + aid: data.auctionId, + ato: data.auctionTimeout, + rt: data.responseTime, + it: 0, + }, + { + method: 'GET', + } + ); + } catch (err) { + logError('Error sending auction data: ', err); + } +} + +// Sampling rate out of 100 +function shouldFireEventRequest () { + const samplingRate = (_initOptions && _initOptions.sampling) || 100; + return ((Math.floor(Math.random() * 100) + 1) <= parseInt(samplingRate)); +} + +kargoAnalyticsAdapter.originEnableAnalytics = kargoAnalyticsAdapter.enableAnalytics; + +kargoAnalyticsAdapter.enableAnalytics = function (config) { + _initOptions = config.options; + kargoAnalyticsAdapter.originEnableAnalytics(config); +}; adapterManager.registerAnalyticsAdapter({ - adapter: kargoAdapter, + adapter: kargoAnalyticsAdapter, code: 'kargo' }); -export default kargoAdapter; +export default kargoAnalyticsAdapter; diff --git a/modules/kargoAnalyticsAdapter.md b/modules/kargoAnalyticsAdapter.md new file mode 100644 index 00000000000..5a1e538902a --- /dev/null +++ b/modules/kargoAnalyticsAdapter.md @@ -0,0 +1,33 @@ +# Overview + +Module Name: Kargo Analytics Adapter +Module Type: Analytics Adapter +Maintainer: support@kargo.com + +# Description + +Analytics adapter for Kargo. Contact support@kargo.com for information. + +# Usage + +The simplest way to enable the analytics adapter is this + +```javascript +pbjs.enableAnalytics([{ + provider: 'kargo', + options: { + sampling: 100 // value out of 100 + } +}]); +``` + +# Test Parameters + +``` +{ + provider: 'kargo', + options: { + sampling: 100 + } +} +``` \ No newline at end of file diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js index 098e38b2c43..1dde4453222 100644 --- a/modules/kargoBidAdapter.js +++ b/modules/kargoBidAdapter.js @@ -1,253 +1,526 @@ -import { _each } from '../src/utils.js'; +import { _each, isEmpty, buildUrl, deepAccess, pick, triggerPixel } from '../src/utils.js'; import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -const BIDDER_CODE = 'kargo'; -const HOST = 'https://krk.kargo.com'; -const SYNC = 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}'; -const SYNC_COUNT = 5; -const GVLID = 972; -const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO] -const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); +const PREBID_VERSION = '$prebid.version$' + +const BIDDER = Object.freeze({ + CODE: 'kargo', + HOST: 'krk2.kargo.com', + REQUEST_METHOD: 'POST', + REQUEST_ENDPOINT: '/api/v1/prebid', + TIMEOUT_ENDPOINT: '/api/v1/event/timeout', + GVLID: 972, + SUPPORTED_MEDIA_TYPES: [BANNER, VIDEO], +}); + +const STORAGE = getStorageManager({bidderCode: BIDDER.CODE}); + +const CURRENCY = Object.freeze({ + KEY: 'currency', + US_DOLLAR: 'USD', +}); + +const REQUEST_KEYS = Object.freeze({ + SOCIAL_CANVAS: 'params.socialCanvas', + SUA: 'ortb2.device.sua', + TDID_ADAPTER: 'userId.tdid', +}); + +const SUA = Object.freeze({ + BROWSERS: 'browsers', + MOBILE: 'mobile', + MODEL: 'model', + PLATFORM: 'platform', + SOURCE: 'source', +}); + +const SUA_ATTRIBUTES = [ + SUA.BROWSERS, + SUA.MOBILE, + SUA.MODEL, + SUA.SOURCE, + SUA.PLATFORM, +]; + +const CERBERUS = Object.freeze({ + KEY: 'krg_crb', + SYNC_URL: 'https://crb.kargo.com/api/v1/initsyncrnd/{UUID}?seed={SEED}&idx={INDEX}&gdpr={GDPR}&gdpr_consent={GDPR_CONSENT}&us_privacy={US_PRIVACY}&gpp={GPP_STRING}&gpp_sid={GPP_SID}', + SYNC_COUNT: 5, + PAGE_VIEW_ID: 'pageViewId', + PAGE_VIEW_TIMESTAMP: 'pageViewTimestamp', + PAGE_VIEW_URL: 'pageViewUrl' +}); let sessionId, lastPageUrl, requestCounter; -export const spec = { - gvlid: GVLID, - code: BIDDER_CODE, - isBidRequestValid: function(bid) { - if (!bid || !bid.params) { - return false; - } +function isBidRequestValid(bid) { + if (!bid || !bid.params) { + return false; + } - return !!bid.params.placementId; - }, - buildRequests: function(validBidRequests, bidderRequest) { - const currencyObj = config.getConfig('currency'); - const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD'; - const bidIDs = {}; - const bidSizes = {}; - - _each(validBidRequests, bid => { - bidIDs[bid.bidId] = bid.params.placementId; - bidSizes[bid.bidId] = bid.sizes; - }); + return !!bid.params.placementId; +} - let tdid; - if (validBidRequests.length > 0 && validBidRequests[0].userId && validBidRequests[0].userId.tdid) { - tdid = validBidRequests[0].userId.tdid; - } +function buildRequests(validBidRequests, bidderRequest) { + const currencyObj = config.getConfig(CURRENCY.KEY); + const currency = (currencyObj && currencyObj.adServerCurrency) ? currencyObj.adServerCurrency : null; + const impressions = []; - const transformedParams = Object.assign({}, { - sessionId: spec._getSessionId(), - requestCount: spec._getRequestCount(), - timeout: bidderRequest.timeout, - currency, - cpmGranularity: 1, - timestamp: (new Date()).getTime(), - cpmRange: { - floor: 0, - ceil: 20 - }, - bidIDs, - bidSizes, - prebidRawBidRequests: validBidRequests - }, spec._getAllMetadata(tdid, bidderRequest.uspConsent, bidderRequest.gdprConsent)); - const encodedParams = encodeURIComponent(JSON.stringify(transformedParams)); - return Object.assign({}, bidderRequest, { - method: 'GET', - url: `${HOST}/api/v2/bid`, - data: `json=${encodedParams}`, - currency: currency - }); - }, - interpretResponse: function(response, bidRequest) { - let bids = response.body; - const bidResponses = []; - for (let bidId in bids) { - let adUnit = bids[bidId]; - let meta; - if (adUnit.metadata && adUnit.metadata.landingPageDomain) { - meta = { - clickUrl: adUnit.metadata.landingPageDomain[0], - advertiserDomains: adUnit.metadata.landingPageDomain - }; + _each(validBidRequests, bid => { + impressions.push(getImpression(bid)) + }); + + const firstBidRequest = validBidRequests[0]; + const tdidAdapter = deepAccess(firstBidRequest, REQUEST_KEYS.TDID_ADAPTER); + + const metadata = getAllMetadata(bidderRequest); + + const krakenParams = Object.assign({}, { + pbv: PREBID_VERSION, + aid: firstBidRequest.auctionId, + sid: _getSessionId(), + url: metadata.pageURL, + timeout: bidderRequest.timeout, + ts: new Date().getTime(), + device: { + size: [ + window.screen.width, + window.screen.height + ] + }, + imp: impressions, + user: getUserIds(tdidAdapter, bidderRequest.uspConsent, bidderRequest.gdprConsent, firstBidRequest.userIdAsEids, bidderRequest.gppConsent), + }); + + if (firstBidRequest.schain && firstBidRequest.schain.nodes) { + krakenParams.schain = firstBidRequest.schain + } + + const reqCount = getRequestCount() + if (reqCount != null) { + krakenParams.requestCount = reqCount; + } + + if (currency != null && currency != CURRENCY.US_DOLLAR) { + krakenParams.cur = currency; + } + + if (metadata.rawCRB != null) { + krakenParams.rawCRB = metadata.rawCRB + } + + if (metadata.rawCRBLocalStorage != null) { + krakenParams.rawCRBLocalStorage = metadata.rawCRBLocalStorage + } + + // Pull Social Canvas segments and embed URL + const socialCanvas = deepAccess(firstBidRequest, REQUEST_KEYS.SOCIAL_CANVAS); + + if (socialCanvas != null) { + krakenParams.socan = socialCanvas; + } + + // User Agent Client Hints / SUA + const uaClientHints = deepAccess(firstBidRequest, REQUEST_KEYS.SUA); + if (uaClientHints) { + const suaValidAttributes = [] + + SUA_ATTRIBUTES.forEach(suaKey => { + const suaValue = uaClientHints[suaKey]; + if (!suaValue) { + return; } - bidResponses.push({ - requestId: bidId, - cpm: Number(adUnit.cpm), - width: adUnit.width, - height: adUnit.height, - ad: adUnit.adm, - ttl: 300, - creativeId: adUnit.id, - dealId: adUnit.targetingCustom, - netRevenue: true, - currency: adUnit.currency || bidRequest.currency, - meta: meta - }); - } + + // Do not pass any empty strings + if (typeof suaValue == 'string' && suaValue.trim() === '') { + return; + } + + switch (suaKey) { + case SUA.MOBILE && suaValue < 1: // Do not pass 0 value for mobile + case SUA.SOURCE && suaValue < 1: // Do not pass 0 value for source + break; + default: + suaValidAttributes.push(suaKey); + } + }); + + krakenParams.device.sua = pick(uaClientHints, suaValidAttributes); + } + + const validPageId = getLocalStorageSafely(CERBERUS.PAGE_VIEW_ID) != null + const validPageTimestamp = getLocalStorageSafely(CERBERUS.PAGE_VIEW_TIMESTAMP) != null + const validPageUrl = getLocalStorageSafely(CERBERUS.PAGE_VIEW_URL) != null + + const page = {} + if (validPageId) { + page.id = getLocalStorageSafely(CERBERUS.PAGE_VIEW_ID); + } + if (validPageTimestamp) { + page.timestamp = Number(getLocalStorageSafely(CERBERUS.PAGE_VIEW_TIMESTAMP)); + } + if (validPageUrl) { + page.url = getLocalStorageSafely(CERBERUS.PAGE_VIEW_URL); + } + if (!isEmpty(page)) { + krakenParams.page = page; + } + + return Object.assign({}, bidderRequest, { + method: BIDDER.REQUEST_METHOD, + url: `https://${BIDDER.HOST}${BIDDER.REQUEST_ENDPOINT}`, + data: krakenParams, + currency: currency + }); +} + +function interpretResponse(response, bidRequest) { + let bids = response.body; + const bidResponses = []; + + if (isEmpty(bids)) { + return bidResponses; + } + + if (typeof bids !== 'object') { return bidResponses; - }, - getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy) { - const syncs = []; - const seed = spec._generateRandomUuid(); - const clientId = spec._getClientId(); - var gdpr = (gdprConsent && gdprConsent.gdprApplies) ? 1 : 0; - var gdprConsentString = (gdprConsent && gdprConsent.consentString) ? gdprConsent.consentString : ''; - // don't sync if opted out via usPrivacy - if (typeof usPrivacy == 'string' && usPrivacy.length == 4 && usPrivacy[0] == 1 && usPrivacy[2] == 'Y') { - return syncs; + } + + Object.entries(bids).forEach((entry) => { + const [bidID, adUnit] = entry; + + let meta = { + mediaType: adUnit.mediaType && BIDDER.SUPPORTED_MEDIA_TYPES.includes(adUnit.mediaType) ? adUnit.mediaType : BANNER + }; + + if (adUnit.metadata && adUnit.metadata.landingPageDomain) { + meta.clickUrl = adUnit.metadata.landingPageDomain[0]; + meta.advertiserDomains = adUnit.metadata.landingPageDomain; } - if (syncOptions.iframeEnabled && seed && clientId) { - for (let i = 0; i < SYNC_COUNT; i++) { - syncs.push({ - type: 'iframe', - url: SYNC.replace('{UUID}', clientId).replace('{SEED}', seed) - .replace('{INDEX}', i) - .replace('{GDPR}', gdpr) - .replace('{GDPR_CONSENT}', gdprConsentString) - .replace('{US_PRIVACY}', usPrivacy || '') - }); + + const bidResponse = { + requestId: bidID, + cpm: Number(adUnit.cpm), + width: adUnit.width, + height: adUnit.height, + ttl: 300, + creativeId: adUnit.id, + dealId: adUnit.targetingCustom, + netRevenue: true, + currency: adUnit.currency || bidRequest.currency, + mediaType: meta.mediaType, + meta: meta + }; + + if (meta.mediaType == VIDEO) { + if (adUnit.admUrl) { + bidResponse.vastUrl = adUnit.admUrl; + } else { + bidResponse.vastXml = adUnit.adm; } + } else { + bidResponse.ad = adUnit.adm; } - return syncs; - }, - supportedMediaTypes: SUPPORTED_MEDIA_TYPES, - // PRIVATE - _readCookie(name) { - if (!storage.cookiesAreEnabled()) { - return null; + bidResponses.push(bidResponse); + }) + + return bidResponses; +} + +function getUserSyncs(syncOptions, _, gdprConsent, usPrivacy, gppConsent) { + const syncs = []; + const seed = _generateRandomUUID(); + const clientId = getClientId(); + + var gdpr = (gdprConsent && gdprConsent.gdprApplies) ? 1 : 0; + var gdprConsentString = (gdprConsent && gdprConsent.consentString) ? gdprConsent.consentString : ''; + + var gppString = (gppConsent && gppConsent.consentString) ? gppConsent.consentString : ''; + var gppApplicableSections = (gppConsent && gppConsent.applicableSections && Array.isArray(gppConsent.applicableSections)) ? gppConsent.applicableSections.join(',') : ''; + + // don't sync if opted out via usPrivacy + if (typeof usPrivacy == 'string' && usPrivacy.length == 4 && usPrivacy[0] == 1 && usPrivacy[2] == 'Y') { + return syncs; + } + if (syncOptions.iframeEnabled && seed && clientId) { + for (let i = 0; i < CERBERUS.SYNC_COUNT; i++) { + syncs.push({ + type: 'iframe', + url: CERBERUS.SYNC_URL.replace('{UUID}', clientId) + .replace('{SEED}', seed) + .replace('{INDEX}', i) + .replace('{GDPR}', gdpr) + .replace('{GDPR_CONSENT}', gdprConsentString) + .replace('{US_PRIVACY}', usPrivacy || '') + .replace('{GPP_STRING}', gppString) + .replace('{GPP_SID}', gppApplicableSections) + }); } - let nameEquals = `${name}=`; - let cookies = document.cookie.split(';'); + } + return syncs; +} - for (let i = 0; i < cookies.length; i++) { - let cookie = cookies[i]; - while (cookie.charAt(0) === ' ') { - cookie = cookie.substring(1, cookie.length); - } +function onTimeout(timeoutData) { + if (timeoutData == null) { + return; + } + + timeoutData.forEach((bid) => { + sendTimeoutData(bid.auctionId, bid.timeout); + }); +} + +function _generateRandomUUID() { + try { + // crypto.getRandomValues is supported everywhere but Opera Mini for years + var buffer = new Uint8Array(16); + crypto.getRandomValues(buffer); + buffer[6] = (buffer[6] & ~176) | 64; + buffer[8] = (buffer[8] & ~64) | 128; + var hex = Array.prototype.map.call(new Uint8Array(buffer), function(x) { + return ('00' + x.toString(16)).slice(-2); + }).join(''); + return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16) + '-' + hex.slice(16, 20) + '-' + hex.slice(20); + } catch (e) { + return ''; + } +} + +function _getCrb() { + let localStorageCrb = getCrbFromLocalStorage(); + if (Object.keys(localStorageCrb).length) { + return localStorageCrb; + } + return getCrbFromCookie(); +} + +function _getSessionId() { + if (!sessionId) { + sessionId = _generateRandomUUID(); + } + return sessionId; +} - if (cookie.indexOf(nameEquals) === 0) { - return cookie.substring(nameEquals.length, cookie.length); +function getCrbFromCookie() { + try { + const crb = JSON.parse(STORAGE.getCookie(CERBERUS.KEY)); + if (crb && crb.v) { + let vParsed = JSON.parse(atob(crb.v)); + if (vParsed) { + return vParsed; } } + return {}; + } catch (e) { + return {}; + } +} +function getCrbFromLocalStorage() { + try { + return JSON.parse(atob(getLocalStorageSafely(CERBERUS.KEY))); + } catch (e) { + return {}; + } +} + +function getLocalStorageSafely(key) { + try { + return STORAGE.getDataFromLocalStorage(key); + } catch (e) { return null; - }, - - _getCrbFromCookie() { - try { - const crb = JSON.parse(decodeURIComponent(spec._readCookie('krg_crb'))); - if (crb && crb.v) { - let vParsed = JSON.parse(atob(crb.v)); - if (vParsed) { - return vParsed; - } + } +} + +function getUserIds(tdidAdapter, usp, gdpr, eids, gpp) { + const crb = spec._getCrb(); + const userIds = { + crbIDs: crb.syncIds || {} + }; + + // Pull Trade Desk ID from adapter + if (tdidAdapter) { + userIds.tdID = tdidAdapter; + } + + // Pull Trade Desk ID from our storage + if (!tdidAdapter && crb.tdID) { + userIds.tdID = crb.tdID; + } + + if (usp) { + userIds.usp = usp; + } + + try { + if (gdpr) { + userIds['gdpr'] = { + consent: gdpr.consentString || '', + applies: !!gdpr.gdprApplies, } - return {}; - } catch (e) { - return {}; } - }, + } catch (e) { + } - _getCrbFromLocalStorage() { - try { - return JSON.parse(atob(spec._getLocalStorageSafely('krg_crb'))); - } catch (e) { - return {}; - } - }, + if (crb.lexId != null) { + userIds.kargoID = crb.lexId; + } + + if (crb.clientId != null) { + userIds.clientID = crb.clientId; + } - _getCrb() { - let localStorageCrb = spec._getCrbFromLocalStorage(); - if (Object.keys(localStorageCrb).length) { - return localStorageCrb; + if (crb.optOut != null) { + userIds.optOut = crb.optOut; + } + + if (eids != null) { + userIds.sharedIDEids = eids; + } + + if (gpp) { + const parsedGPP = {} + if (gpp && gpp.consentString) { + parsedGPP.gppString = gpp.consentString } - return spec._getCrbFromCookie(); - }, - - _getLocalStorageSafely(key) { - try { - return storage.getDataFromLocalStorage(key); - } catch (e) { - return null; + if (gpp && gpp.applicableSections) { + parsedGPP.applicableSections = gpp.applicableSections } - }, - - _getUserIds(tdid, usp, gdpr) { - const crb = spec._getCrb(); - const userIds = { - kargoID: crb.lexId, - clientID: crb.clientId, - crbIDs: crb.syncIds || {}, - optOut: crb.optOut, - usp: usp - }; + if (!isEmpty(parsedGPP)) { + userIds.gpp = parsedGPP + } + } - try { - if (gdpr) { - userIds['gdpr'] = { - consent: gdpr.consentString || '', - applies: !!gdpr.gdprApplies, - } - } - } catch (e) { + return userIds; +} + +function getClientId() { + const crb = spec._getCrb(); + return crb.clientId; +} + +function getAllMetadata(bidderRequest) { + return { + pageURL: bidderRequest?.refererInfo?.page, + rawCRB: STORAGE.getCookie(CERBERUS.KEY), + rawCRBLocalStorage: getLocalStorageSafely(CERBERUS.KEY) + }; +} + +function getRequestCount() { + if (lastPageUrl === window.location.pathname) { + return ++requestCounter; + } + lastPageUrl = window.location.pathname; + return requestCounter = 0; +} + +function sendTimeoutData(auctionId, auctionTimeout) { + let params = { + aid: auctionId, + ato: auctionTimeout + }; + + try { + let timeoutRequestUrl = buildUrl({ + protocol: 'https', + hostname: BIDDER.HOST, + pathname: BIDDER.TIMEOUT_ENDPOINT, + search: params + }); + + triggerPixel(timeoutRequestUrl); + } catch (e) {} +} + +function getImpression(bid) { + const imp = { + id: bid.bidId, + tid: bid.ortb2Imp?.ext?.tid, + pid: bid.params.placementId, + code: bid.adUnitCode + }; + + if (bid.floorData != null && bid.floorData.floorMin > 0) { + imp.floor = bid.floorData.floorMin; + } + + if (bid.bidRequestsCount > 0) { + imp.bidRequestCount = bid.bidRequestsCount; + } + + if (bid.bidderRequestsCount > 0) { + imp.bidderRequestCount = bid.bidderRequestsCount; + } + + if (bid.bidderWinsCount > 0) { + imp.bidderWinCount = bid.bidderWinsCount; + } + + const gpid = getGPID(bid) + if (gpid != null && gpid != '') { + imp.fpd = { + gpid: gpid } - if (tdid) { - userIds.tdID = tdid; + } + + if (bid.mediaTypes != null) { + if (bid.mediaTypes.banner != null) { + imp.banner = bid.mediaTypes.banner; } - return userIds; - }, - - _getClientId() { - const crb = spec._getCrb(); - return crb.clientId; - }, - - _getAllMetadata(tdid, usp, gdpr) { - return { - userIDs: spec._getUserIds(tdid, usp, gdpr), - pageURL: window.location.href, - rawCRB: spec._readCookie('krg_crb'), - rawCRBLocalStorage: spec._getLocalStorageSafely('krg_crb') - }; - }, - _getSessionId() { - if (!sessionId) { - sessionId = spec._generateRandomUuid(); + if (bid.mediaTypes.video != null) { + imp.video = bid.mediaTypes.video; } - return sessionId; - }, - _getRequestCount() { - if (lastPageUrl === window.location.pathname) { - return ++requestCounter; + if (bid.mediaTypes.native != null) { + imp.native = bid.mediaTypes.native; } - lastPageUrl = window.location.pathname; - return requestCounter = 0; - }, - - _generateRandomUuid() { - try { - // crypto.getRandomValues is supported everywhere but Opera Mini for years - var buffer = new Uint8Array(16); - crypto.getRandomValues(buffer); - buffer[6] = (buffer[6] & ~176) | 64; - buffer[8] = (buffer[8] & ~64) | 128; - var hex = Array.prototype.map.call(new Uint8Array(buffer), function(x) { - return ('00' + x.toString(16)).slice(-2); - }).join(''); - return hex.slice(0, 8) + '-' + hex.slice(8, 12) + '-' + hex.slice(12, 16) + '-' + hex.slice(16, 20) + '-' + hex.slice(20); - } catch (e) { - return ''; + } + + return imp +} + +function getGPID(bid) { + if (bid.ortb2Imp != null) { + if (bid.ortb2Imp.gpid != null && bid.ortb2Imp.gpid != '') { + return bid.ortb2Imp.gpid; } + + if (bid.ortb2Imp.ext != null && bid.ortb2Imp.ext.data != null) { + if (bid.ortb2Imp.ext.data.pbAdSlot != null && bid.ortb2Imp.ext.data.pbAdSlot != '') { + return bid.ortb2Imp.ext.data.pbAdSlot; + } + + if (bid.ortb2Imp.ext.data.adServer != null && bid.ortb2Imp.ext.data.adServer.adSlot != null && bid.ortb2Imp.ext.data.adServer.adSlot != '') { + return bid.ortb2Imp.ext.data.adServer.adSlot; + } + } + } + + if (bid.adUnitCode != null && bid.adUnitCode != '') { + return bid.adUnitCode; } + return ''; +} + +export const spec = { + gvlid: BIDDER.GVLID, + code: BIDDER.CODE, + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, + supportedMediaTypes: BIDDER.SUPPORTED_MEDIA_TYPES, + onTimeout, + _getCrb, + _getSessionId }; + registerBidder(spec); diff --git a/modules/kinessoIdSystem.js b/modules/kinessoIdSystem.js index 632f3a669aa..c13ed3976d3 100644 --- a/modules/kinessoIdSystem.js +++ b/modules/kinessoIdSystem.js @@ -233,8 +233,13 @@ export const kinessoIdSubmodule = { const payloadString = JSON.stringify(kinessoIdPayload); ajax(kinessoSyncUrl(accountId, consentData), syncId(knnsoId), payloadString, {method: 'POST', withCredentials: true}); return {'id': knnsoId}; - } - + }, + eids: { + 'kpuid': { + source: 'kpuid.com', + atype: 3 + }, + }, }; // Register submodule for userId diff --git a/modules/kiviadsBidAdapter.js b/modules/kiviadsBidAdapter.js new file mode 100644 index 00000000000..13739d57cb2 --- /dev/null +++ b/modules/kiviadsBidAdapter.js @@ -0,0 +1,212 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'kiviads'; +const AD_URL = 'https://lb.kiviads.com/pbjs'; +const SYNC_URL = 'https://sync.kiviads.com'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: bidderRequest.coppa === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + gpp: bidderRequest.gppConsent || undefined, + tmax: bidderRequest.bidderTimeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/kiviadsBidAdapter.md b/modules/kiviadsBidAdapter.md new file mode 100644 index 00000000000..47eb16bd6c8 --- /dev/null +++ b/modules/kiviadsBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: KiviAds Bidder Adapter +Module Type: KiviAds Bidder Adapter +Maintainer: prebid@kiviads.com +``` + +# Description + +Connects to Kivi Ads exchange for bids. +KiviJS bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'kiviads', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'kiviads', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'kiviads', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/koblerBidAdapter.js b/modules/koblerBidAdapter.js index 80aa038a9f7..596e5b2695f 100644 --- a/modules/koblerBidAdapter.js +++ b/modules/koblerBidAdapter.js @@ -1,4 +1,12 @@ -import { deepAccess, isStr, replaceAuctionPrice, triggerPixel, isArray, parseQueryStringParameters, getWindowSelf } from '../src/utils.js'; +import { + deepAccess, + getWindowSelf, + isArray, + isStr, + parseQueryStringParameters, + replaceAuctionPrice, + triggerPixel +} from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; @@ -6,19 +14,25 @@ import {getRefererInfo} from '../src/refererDetection.js'; const BIDDER_CODE = 'kobler'; const BIDDER_ENDPOINT = 'https://bid.essrtb.com/bid/prebid_rtb_call'; +const DEV_BIDDER_ENDPOINT = 'https://bid-service.dev.essrtb.com/bid/prebid_rtb_call'; const TIMEOUT_NOTIFICATION_ENDPOINT = 'https://bid.essrtb.com/notify/prebid_timeout'; const SUPPORTED_CURRENCY = 'USD'; -const DEFAULT_TIMEOUT = 1000; const TIME_TO_LIVE_IN_SECONDS = 10 * 60; export const isBidRequestValid = function (bid) { - return !!(bid && bid.bidId && bid.params && bid.params.placementId); + if (!bid || !bid.bidId) { + return false; + } + + const sizes = deepAccess(bid, 'mediaTypes.banner.sizes', bid.sizes); + return isArray(sizes) && sizes.length > 0; }; export const buildRequests = function (validBidRequests, bidderRequest) { + const bidderEndpoint = isTest(validBidRequests[0]) ? DEV_BIDDER_ENDPOINT : BIDDER_ENDPOINT; return { method: 'POST', - url: BIDDER_ENDPOINT, + url: bidderEndpoint, data: buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest), options: { contentType: 'application/json' @@ -27,14 +41,11 @@ export const buildRequests = function (validBidRequests, bidderRequest) { }; export const interpretResponse = function (serverResponse) { - const adServerPriceCurrency = config.getConfig('currency.adServerCurrency') || SUPPORTED_CURRENCY; const res = serverResponse.body; const bids = [] if (res) { res.seatbid.forEach(sb => { sb.bid.forEach(b => { - const adWithCorrectCurrency = b.adm - .replace(/\${AUCTION_PRICE_CURRENCY}/g, adServerPriceCurrency); bids.push({ requestId: b.impid, cpm: b.price, @@ -45,7 +56,7 @@ export const interpretResponse = function (serverResponse) { dealId: b.dealid, netRevenue: true, ttl: TIME_TO_LIVE_IN_SECONDS, - ad: adWithCorrectCurrency, + ad: b.adm, nurl: b.nurl, meta: { advertiserDomains: b.adomain @@ -58,13 +69,15 @@ export const interpretResponse = function (serverResponse) { }; export const onBidWon = function (bid) { - const cpm = bid.cpm || 0; - const cpmCurrency = bid.currency || SUPPORTED_CURRENCY; + // We intentionally use the price set by the publisher to replace the ${AUCTION_PRICE} macro + // instead of the `originalCpm` here. This notification is not used for billing, only for extra logging. + const publisherPrice = bid.cpm || 0; + const publisherCurrency = bid.currency || config.getConfig('currency.adServerCurrency') || SUPPORTED_CURRENCY; const adServerPrice = deepAccess(bid, 'adserverTargeting.hb_pb', 0); const adServerPriceCurrency = config.getConfig('currency.adServerCurrency') || SUPPORTED_CURRENCY; if (isStr(bid.nurl) && bid.nurl !== '') { - const winNotificationUrl = replaceAuctionPrice(bid.nurl, bid.originalCpm || cpm) - .replace(/\${AUCTION_PRICE_CURRENCY}/g, cpmCurrency) + const winNotificationUrl = replaceAuctionPrice(bid.nurl, publisherPrice) + .replace(/\${AUCTION_PRICE_CURRENCY}/g, publisherCurrency) .replace(/\${AD_SERVER_PRICE}/g, adServerPrice) .replace(/\${AD_SERVER_PRICE_CURRENCY}/g, adServerPriceCurrency); triggerPixel(winNotificationUrl); @@ -73,17 +86,14 @@ export const onBidWon = function (bid) { export const onTimeout = function (timeoutDataArray) { if (isArray(timeoutDataArray)) { - const refererInfo = getRefererInfo(); - const pageUrl = (refererInfo && refererInfo.referer) - ? refererInfo.referer - : window.location.href; + const pageUrl = getPageUrlFromRefererInfo(); timeoutDataArray.forEach(timeoutData => { const query = parseQueryStringParameters({ ad_unit_code: timeoutData.adUnitCode, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auction_id: timeoutData.auctionId, bid_id: timeoutData.bidId, timeout: timeoutData.timeout, - placement_id: deepAccess(timeoutData, 'params.0.placementId'), page_url: pageUrl, }); const timeoutNotificationUrl = `${TIMEOUT_NOTIFICATION_ENDPOINT}?${query}`; @@ -92,27 +102,43 @@ export const onTimeout = function (timeoutDataArray) { } }; -function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { - const imps = validBidRequests.map(buildOpenRtbImpObject); - const timeout = bidderRequest.timeout || config.getConfig('bidderTimeout') || DEFAULT_TIMEOUT; - const pageUrl = (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) - ? bidderRequest.refererInfo.referer +function getPageUrlFromRequest(validBidRequest, bidderRequest) { + // pageUrl is considered only when testing to ensure that non-test requests always contain the correct URL + if (isTest(validBidRequest) && config.getConfig('pageUrl')) { + // TODO: it's not clear what the intent is here - but all adapters should always respect pageUrl. + // With prebid 7, using `refererInfo.page` will do that automatically. + return config.getConfig('pageUrl'); + } + + return (bidderRequest.refererInfo && bidderRequest.refererInfo.page) + ? bidderRequest.refererInfo.page : window.location.href; +} +function getPageUrlFromRefererInfo() { + const refererInfo = getRefererInfo(); + return (refererInfo && refererInfo.page) + ? refererInfo.page + : window.location.href; +} + +function buildOpenRtbBidRequestPayload(validBidRequests, bidderRequest) { + const imps = validBidRequests.map(buildOpenRtbImpObject); + const timeout = bidderRequest.timeout; + const pageUrl = getPageUrlFromRequest(validBidRequests[0], bidderRequest) const request = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, at: 1, tmax: timeout, cur: [SUPPORTED_CURRENCY], imp: imps, device: { - devicetype: getDevice(), - geo: getGeo(validBidRequests[0]) + devicetype: getDevice() }, site: { page: pageUrl, }, - test: getTest(validBidRequests[0]) + test: getTestAsNumber(validBidRequests[0]) }; return JSON.stringify(request); @@ -128,14 +154,8 @@ function buildOpenRtbImpObject(validBidRequest) { banner: { format: buildFormatArray(sizes), w: mainSize[0], - h: mainSize[1], - ext: { - kobler: { - pos: getPosition(validBidRequest) - } - } + h: mainSize[1] }, - tagid: validBidRequest.params.placementId, bidfloor: floorInfo.floor, bidfloorcur: floorInfo.currency, pmp: buildPmpObject(validBidRequest) @@ -157,17 +177,12 @@ function getDevice() { return 2; // personal computers } -function getGeo(validBidRequest) { - if (validBidRequest.params.zip) { - return { - zip: validBidRequest.params.zip - }; - } - return {}; +function getTestAsNumber(validBidRequest) { + return isTest(validBidRequest) ? 1 : 0; } -function getTest(validBidRequest) { - return validBidRequest.params.test ? 1 : 0; +function isTest(validBidRequest) { + return validBidRequest.params && validBidRequest.params.test === true; } function getSizes(validBidRequest) { @@ -188,10 +203,6 @@ function buildFormatArray(sizes) { }); } -function getPosition(validBidRequest) { - return parseInt(validBidRequest.params.position) || 0; -} - function getFloorInfo(validBidRequest, mainSize) { if (typeof validBidRequest.getFloor === 'function') { const sizeParam = mainSize[0] === 0 && mainSize[1] === 0 ? '*' : mainSize; @@ -209,11 +220,11 @@ function getFloorInfo(validBidRequest, mainSize) { } function getFloorPrice(validBidRequest) { - return parseFloat(validBidRequest.params.floorPrice) || 0.0; + return parseFloat(deepAccess(validBidRequest, 'params.floorPrice', 0.0)); } function buildPmpObject(validBidRequest) { - if (validBidRequest.params.dealIds) { + if (validBidRequest.params && validBidRequest.params.dealIds && isArray(validBidRequest.params.dealIds)) { return { deals: validBidRequest.params.dealIds.map(dealId => { return { diff --git a/modules/koblerBidAdapter.md b/modules/koblerBidAdapter.md index 7a7b2388367..63b0c3ead68 100644 --- a/modules/koblerBidAdapter.md +++ b/modules/koblerBidAdapter.md @@ -12,14 +12,15 @@ This adapter currently only supports Banner Ads. # Parameters -| Parameter (in `params`) | Scope | Type | Description | Example | -| --- | --- | --- | --- | --- | -| placementId | Required | String | The identifier of the placement, it has to be issued by Kobler. | `'xjer0ch8'` | -| zip | Optional | String | Zip code of the user or the medium. When multiple ad units are submitted together, it is enough to set this parameter on the first one. | `'102 22'` | -| test | Optional | Boolean | Whether the request is for testing only. When multiple ad units are submitted together, it is enough to set this parameter on the first one. Defaults to false. | `true` | -| floorPrice | Optional | Float | Floor price in CPM and USD. Can be used as an alternative to the [Floors module](https://docs.prebid.org/dev-docs/modules/floors.html), which is also supported by this adapter. Defaults to 0. | `5.0` | -| position | Optional | Integer | The position of the ad unit. Can be used to differentiate between ad units if the same placement ID is used across multiple ad units. The first ad unit should have a `position` of 0, the second one should have a `position` of 1 and so on. Defaults to 0. | `1` | -| dealIds | Optional | Array of Strings | Array of deal IDs. | `['abc328745', 'mxw243253']` | +| Parameter (in `params`) | Scope | Type | Description | Example | +|-------------------------|----------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------| +| test | Optional | Boolean | Whether the request is for testing only. When multiple ad units are submitted together, it is enough to set this parameter on the first one. Enables providing a custom URL through config.pageUrl. Defaults to false. | `true` | +| floorPrice | Optional | Float | Floor price in CPM and USD. Can be used as an alternative to the [Floors module](https://docs.prebid.org/dev-docs/modules/floors.html), which is also supported by this adapter. Defaults to 0. | `5.0` | +| dealIds | Optional | Array of Strings | Array of deal IDs. | `['abc328745', 'mxw243253']` | + +## Implicit parameters + +Kobler identifies the placement using the combination of the page URL and the allowed sizes. As a result, it's important that the correct sizes are provided in `banner.sizes` in order for Kobler to correctly identify the placement. The main, desired format should be the first element of this array. # Test Parameters ```javascript @@ -31,17 +32,14 @@ This adapter currently only supports Banner Ads. } }, bids: [{ - bidder: 'kobler', - params: { - placementId: 'k5H7et3R0' - } + bidder: 'kobler' }] }]; ``` In order to see a sample bid from Kobler (without a proper setup), you have to also do the following: -- Change the [`refererInfo` function](https://github.com/prebid/Prebid.js/blob/master/src/refererDetection.js) to return `'https://www.tv2.no/a/11734615'` as a [`referer`](https://github.com/prebid/Prebid.js/blob/caead3ccccc448e4cd09d074fd9f8833f56fe9b3/src/refererDetection.js#L169). This is necessary because Kobler only bids on recognized articles. -- Change the adapter's [`BIDDER_ENDPOINT`](https://github.com/prebid/Prebid.js/blob/master/modules/koblerBidAdapter.js#L8) to `'https://bid-service.dev.essrtb.com/bid/prebid_rtb_call'`. This endpoint belongs to the development server that is set up to always return a bid for the correct `placementId` and page URL combination. +- Set the `test` parameter to `true`. +- Set `config.pageUrl` to `'https://www.tv2.no/mening-og-analyse/14555348/'`. This is necessary because Kobler only bids on recognized articles. Kobler runs its own test campaign to make sure there is always a bid for this specific page URL. # Test Optional Parameters ```javascript @@ -55,11 +53,8 @@ In order to see a sample bid from Kobler (without a proper setup), you have to a bids: [{ bidder: 'kobler', params: { - placementId: 'k5H7et3R0', - zip: '102 22', test: true, floorPrice: 5.0, - position: 1, dealIds: ['abc328745', 'mxw243253'] } }] diff --git a/modules/komoonaBidAdapter.md b/modules/komoonaBidAdapter.md deleted file mode 100644 index 6f88c19dfa6..00000000000 --- a/modules/komoonaBidAdapter.md +++ /dev/null @@ -1,29 +0,0 @@ -# Overview - -**Module Name**: Komoona Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: support@komoona.com - -# Description - -Connects to Komoona demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [{ - code: 'banner-ad-div', - sizes: [[300, 250]], - - // Replace this object to test a new Adapter! - bids: [{ - bidder: 'komoona', - params: { - placementId: 'e69148e0ba6c4c07977dc2daae5e1577', - hbid: '1f5b2c10e66e419580bd943b9af692ab', - floorPrice: 0.5 - } - }] - }]; -``` - - diff --git a/modules/konduitAnalyticsAdapter.js b/modules/konduitAnalyticsAdapter.js index f8a44d7cc94..a1a586b25db 100644 --- a/modules/konduitAnalyticsAdapter.js +++ b/modules/konduitAnalyticsAdapter.js @@ -1,6 +1,6 @@ import { parseSizesInput, logError, uniques } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import { targeting } from '../src/targeting.js'; import { config } from '../src/config.js'; diff --git a/modules/krushmediaBidAdapter.js b/modules/krushmediaBidAdapter.js index da68bddcb7b..876f0ebabc6 100644 --- a/modules/krushmediaBidAdapter.js +++ b/modules/krushmediaBidAdapter.js @@ -1,6 +1,7 @@ import { isFn, deepAccess, logMessage } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'krushmedia'; const AD_URL = 'https://ads4.krushmedia.com/?c=rtb&m=hb'; @@ -49,10 +50,14 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page); winTop = window.top; } catch (e) { location = winTop.location; @@ -75,7 +80,7 @@ export const spec = { request.ccpa = bidderRequest.uspConsent; } if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent + request.gdpr = bidderRequest.gdprConsent; } } diff --git a/modules/kubientBidAdapter.js b/modules/kubientBidAdapter.js index 46360572576..57cbe6acd07 100644 --- a/modules/kubientBidAdapter.js +++ b/modules/kubientBidAdapter.js @@ -67,8 +67,9 @@ export const spec = { data.coppa = 1 } - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - data.referer = bidderRequest.refererInfo.referer + if (bidderRequest?.refererInfo?.page) { + // TODO: is 'page' the right value here? + data.referer = bidderRequest.refererInfo.page } if (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) { @@ -151,15 +152,7 @@ function encodeQueryData(data) { function kubientGetConsentGiven(gdprConsent) { let consentGiven = 0; if (typeof gdprConsent !== 'undefined') { - let apiVersion = deepAccess(gdprConsent, `apiVersion`); - switch (apiVersion) { - case 1: - consentGiven = deepAccess(gdprConsent, `vendorData.vendorConsents.${VENDOR_ID}`) ? 1 : 0; - break; - case 2: - consentGiven = deepAccess(gdprConsent, `vendorData.vendor.consents.${VENDOR_ID}`) ? 1 : 0; - break; - } + consentGiven = deepAccess(gdprConsent, `vendorData.vendor.consents.${VENDOR_ID}`) ? 1 : 0; } return consentGiven; } diff --git a/modules/kueezBidAdapter.js b/modules/kueezBidAdapter.js new file mode 100644 index 00000000000..5a5536e0c1a --- /dev/null +++ b/modules/kueezBidAdapter.js @@ -0,0 +1,483 @@ +import { + logWarn, + logInfo, + isArray, + isFn, + deepAccess, + isEmpty, + contains, + timestamp, + triggerPixel, + isInteger, + getBidIdParameter +} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_ENDPOINT = 'https://hb.kueezssp.com/hb-kz-multi'; +const BIDDER_TEST_ENDPOINT = 'https://hb.kueezssp.com/hb-multi-kz-test' +const BIDDER_CODE = 'kueez'; +const MAIN_CURRENCY = 'USD'; +const MEDIA_TYPES = [BANNER, VIDEO]; +const TTL = 420; +const VERSION = '1.0.0'; +const SUPPORTED_SYNC_METHODS = { + IFRAME: 'iframe', + PIXEL: 'pixel' +} + +export const spec = { + code: BIDDER_CODE, + version: VERSION, + supportedMediaTypes: MEDIA_TYPES, + isBidRequestValid: function (bidRequest) { + return validateParams(bidRequest); + }, + buildRequests: function (validBidRequests, bidderRequest) { + const [ sharedParams ] = validBidRequests; + const testMode = sharedParams.params.testMode; + const bidsToSend = prepareBids(validBidRequests, sharedParams, bidderRequest); + + return { + method: 'POST', + url: getBidderEndpoint(testMode), + data: bidsToSend + } + }, + interpretResponse: function ({body}) { + const bidResponses = body?.bids; + + if (!bidResponses || !bidResponses.length) { + return []; + } + + return parseBidResponses(bidResponses); + }, + getUserSyncs: function (syncOptions, serverResponses) { + const syncs = []; + for (const response of serverResponses) { + if (syncOptions.pixelEnabled && isArray(response.body.params.userSyncPixels)) { + const pixels = response.body.params.userSyncPixels.map(pixel => { + return { + type: 'image', + url: pixel + } + }) + syncs.push(...pixels) + } + if (syncOptions.iframeEnabled && response.body.params.userSyncURL) { + syncs.push({ + type: 'iframe', + url: response.body.params.userSyncURL + }); + } + } + return syncs; + }, + onBidWon: function (bid) { + if (bid == null) { + return; + } + + logInfo('onBidWon:', bid); + if (bid.hasOwnProperty('nurl') && bid.nurl.length > 0) { + triggerPixel(bid.nurl); + } + } +}; + +registerBidder(spec); + +/** + * Get schain string value + * @param schainObject {Object} + * @returns {string} + */ +function getSupplyChain(schainObject) { + if (isEmpty(schainObject)) { + return ''; + } + let scStr = `${schainObject.ver},${schainObject.complete}`; + schainObject.nodes.forEach((node) => { + scStr += '!'; + scStr += `${getEncodedValIfNotEmpty(node.asi)},`; + scStr += `${getEncodedValIfNotEmpty(node.sid)},`; + scStr += `${node.hp ? encodeURIComponent(node.hp) : ''},`; + scStr += `${getEncodedValIfNotEmpty(node.rid)},`; + scStr += `${getEncodedValIfNotEmpty(node.name)},`; + scStr += `${getEncodedValIfNotEmpty(node.domain)}`; + }); + return scStr; +} + +/** + * Get the encoded value + * @param val {string} + * @returns {string} + */ +function getEncodedValIfNotEmpty(val) { + return !isEmpty(val) ? encodeURIComponent(val) : ''; +} + +/** + * get device type + * @returns {string} + */ +function getDeviceType() { + const ua = navigator.userAgent; + if (/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i + .test(ua.toLowerCase())) { + return '5'; + } + if (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i + .test(ua.toLowerCase())) { + return '4'; + } + if (/smart[-_\s]?tv|hbbtv|appletv|googletv|hdmi|netcast|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b/i + .test(ua.toLowerCase())) { + return '3'; + } + return '1'; +} + +/** + * Get floor price + * @param bid {bid} + * @param mediaType {string} + * @returns {Number} + */ +function getFloorPrice(bid, mediaType) { + let floor = 0; + + if (isFn(bid.getFloor)) { + let floorResult = bid.getFloor({ + currency: MAIN_CURRENCY, + mediaType: mediaType, + size: '*' + }); + floor = floorResult.currency === MAIN_CURRENCY && floorResult.floor ? floorResult.floor : 0; + } + + return floor; +} + +/** + * Get the ad sizes array from the bid + * @param bid {bid} + * @param mediaType {string} + * @returns {Array} + */ +function getSizesArray(bid, mediaType) { + let sizes = [] + + if (deepAccess(bid, `mediaTypes.${mediaType}.sizes`)) { + sizes = bid.mediaTypes[mediaType].sizes; + } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { + sizes = bid.sizes; + } + + return sizes; +} + +/** + * Get the preferred user-sync method + * @param filterSettings {filterSettings} + * @param bidderCode {string} + * @returns {string} + */ +function getSyncMethod(filterSettings, bidderCode) { + const iframeConfigs = ['all', 'iframe']; + const pixelConfig = 'image'; + if (filterSettings && iframeConfigs.some(config => isSyncMethodAllowed(filterSettings[config], bidderCode))) { + return SUPPORTED_SYNC_METHODS.IFRAME; + } + if (!filterSettings || !filterSettings[pixelConfig] || isSyncMethodAllowed(filterSettings[pixelConfig], bidderCode)) { + return SUPPORTED_SYNC_METHODS.PIXEL; + } +} + +/** + * Check sync rule support + * @param filterSetting {Object} + * @param bidderCode {string} + * @returns {boolean} + */ +function isSyncMethodAllowed(filterSetting, bidderCode) { + if (!filterSetting) { + return false; + } + const bidders = isArray(filterSetting.bidders) ? filterSetting.bidders : [bidderCode]; + return filterSetting.filter === 'include' && contains(bidders, bidderCode); +} + +/** + * Get the bidder endpoint + * @param testMode {boolean} + * @returns {string} + */ +function getBidderEndpoint(testMode) { + return testMode ? BIDDER_TEST_ENDPOINT : BIDDER_ENDPOINT; +} + +/** + * Generates the bidder parameters + * @param validBidRequests {Array} + * @param bidderRequest {bidderRequest} + * @returns {Array} + */ +function generateBidParams(validBidRequests, bidderRequest) { + const bidsArray = []; + + if (validBidRequests.length) { + validBidRequests.forEach(bid => { + bidsArray.push(generateBidParameters(bid, bidderRequest)); + }); + } + + return bidsArray; +} + +/** + * Generate bid specific parameters + * @param bid {bid} + * @param bidderRequest {bidderRequest} + * @returns {Object} bid specific params object + */ +function generateBidParameters(bid, bidderRequest) { + const {params} = bid; + const mediaType = isBanner(bid) ? BANNER : VIDEO; + const sizesArray = getSizesArray(bid, mediaType); + const gpid = deepAccess(bid, `ortb2Imp.ext.gpid`); + const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`); + const placementId = params.placementId || deepAccess(bid, `mediaTypes.${mediaType}.name`); + const paramsFloorPrice = isNaN(params.floorPrice) ? 0 : params.floorPrice; + + const bidObject = { + adUnitCode: getBidIdParameter('adUnitCode', bid), + bidId: getBidIdParameter('bidId', bid), + loop: getBidIdParameter('bidderRequestsCount', bid), + bidderRequestId: getBidIdParameter('bidderRequestId', bid), + floorPrice: Math.max(getFloorPrice(bid, mediaType), paramsFloorPrice), + mediaType, + sizes: sizesArray, + transactionId: bid.ortb2Imp?.ext?.tid || '' + }; + + if (pos) { + bidObject.pos = pos; + } + + if (gpid) { + bidObject.gpid = gpid; + } + + if (placementId) { + bidObject.placementId = placementId; + } + + if (mediaType === VIDEO) { + populateVideoParams(bidObject, bid); + } + + return bidObject; +} + +/** + * Checks if the media type is a banner + * @param bid {bid} + * @returns {boolean} + */ +function isBanner(bid) { + return bid.mediaTypes && bid.mediaTypes.banner; +} + +/** + * Generate params that are common between all bids + * @param sharedParams {sharedParams} + * @param bidderRequest {bidderRequest} + * @returns {object} the common params object + */ +function generateSharedParams(sharedParams, bidderRequest) { + const {bidderCode} = bidderRequest; + const {syncEnabled, filterSettings} = config.getConfig('userSync') || {}; + const domain = window.location.hostname; + const generalBidParams = getBidIdParameter('params', sharedParams); + const userIds = getBidIdParameter('userId', sharedParams); + const ortb2Metadata = bidderRequest.ortb2 || {}; + const timeout = bidderRequest.timeout; + + const params = { + adapter_version: VERSION, + auction_start: timestamp(), + device_type: getDeviceType(), + dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, + publisher_id: generalBidParams.org, + publisher_name: domain, + session_id: getBidIdParameter('auctionId', sharedParams), + site_domain: domain, + tmax: timeout, + ua: navigator.userAgent, + wrapper_type: 'prebidjs', + wrapper_vendor: '$$PREBID_GLOBAL$$', + wrapper_version: '$prebid.version$' + }; + + if (syncEnabled) { + const allowedSyncMethod = getSyncMethod(filterSettings, bidderCode); + if (allowedSyncMethod) { + params.cs_method = allowedSyncMethod; + } + } + + if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { + params.gdpr = bidderRequest.gdprConsent.gdprApplies; + params.gdpr_consent = bidderRequest.gdprConsent.consentString; + } + + if (bidderRequest.uspConsent) { + params.us_privacy = bidderRequest.uspConsent; + } + + if (generalBidParams.ifa) { + params.ifa = generalBidParams.ifa; + } + + if (ortb2Metadata.site) { + params.site_metadata = JSON.stringify(ortb2Metadata.site); + } + + if (ortb2Metadata.user) { + params.user_metadata = JSON.stringify(ortb2Metadata.user); + } + + if (bidderRequest && bidderRequest.refererInfo) { + params.referrer = deepAccess(bidderRequest, 'refererInfo.ref'); + params.page_url = deepAccess(bidderRequest, 'refererInfo.page') || deepAccess(window, 'location.href'); + } + + if (sharedParams.schain) { + params.schain = getSupplyChain(sharedParams.schain); + } + + if (userIds) { + params.userIds = JSON.stringify(userIds); + } + + return params; +} + +/** + * Validates the bidder params + * @param bidRequest {bidRequest} + * @returns {boolean} + */ +function validateParams(bidRequest) { + let isValid = true; + + if (!bidRequest.params) { + logWarn('Kueez adapter - missing params'); + isValid = false; + } + + if (!bidRequest.params.org) { + logWarn('Kueez adapter - org is a required param'); + isValid = false; + } + + return isValid; +} + +/** + * Validates the bidder params + * @param validBidRequests {Array} + * @param sharedParams {sharedParams} + * @param bidderRequest {bidderRequest} + * @returns {Object} + */ +function prepareBids(validBidRequests, sharedParams, bidderRequest) { + return { + params: generateSharedParams(sharedParams, bidderRequest), + bids: generateBidParams(validBidRequests, bidderRequest) + } +} + +function getPlaybackMethod(bid) { + const playbackMethod = deepAccess(bid, `mediaTypes.video.playbackmethod`); + + if (Array.isArray(playbackMethod) && isInteger(playbackMethod[0])) { + return playbackMethod[0]; + } else if (isInteger(playbackMethod)) { + return playbackMethod; + } +} + +function populateVideoParams(params, bid) { + const linearity = deepAccess(bid, `mediaTypes.video.linearity`); + const maxDuration = deepAccess(bid, `mediaTypes.video.maxduration`); + const minDuration = deepAccess(bid, `mediaTypes.video.minduration`); + const placement = deepAccess(bid, `mediaTypes.video.placement`); + const playbackMethod = getPlaybackMethod(bid); + const skip = deepAccess(bid, `mediaTypes.video.skip`); + + if (linearity) { + params.linearity = linearity; + } + + if (maxDuration) { + params.maxDuration = maxDuration; + } + + if (minDuration) { + params.minDuration = minDuration; + } + + if (placement) { + params.placement = placement; + } + + if (playbackMethod) { + params.playbackMethod = playbackMethod; + } + + if (skip) { + params.skip = skip; + } +} + +/** + * Processes the bid responses + * @param bids {Array} + * @returns {Array} + */ +function parseBidResponses(bids) { + return bids.map(bid => { + const bidResponse = { + cpm: bid.cpm, + creativeId: bid.requestId, + currency: bid.currency || MAIN_CURRENCY, + height: bid.height, + mediaType: bid.mediaType, + meta: { + mediaType: bid.mediaType + }, + netRevenue: bid.netRevenue || true, + nurl: bid.nurl, + requestId: bid.requestId, + ttl: bid.ttl || TTL, + width: bid.width + }; + + if (bid.adomain && bid.adomain.length) { + bidResponse.meta.advertiserDomains = bid.adomain; + } + + if (bid.mediaType === VIDEO) { + bidResponse.vastXml = bid.vastXml; + } else if (bid.mediaType === BANNER) { + bidResponse.ad = bid.ad; + } + + return bidResponse; + }); +} diff --git a/modules/kueezBidAdapter.md b/modules/kueezBidAdapter.md new file mode 100644 index 00000000000..8b17e40f503 --- /dev/null +++ b/modules/kueezBidAdapter.md @@ -0,0 +1,73 @@ +#Overview + +Module Name: Kueez Bidder Adapter + +Module Type: Bidder Adapter + +Maintainer: prebid@kueez.com + +# Description + +The Kueez adapter requires setup and approval from the Kueez team. Please reach out to prebid@kueez.com for more information. + +The adapter supports Banner and Video(instream) media types. + +# Bid Parameters + +## Video + +| Name | Scope | Type | Description | Example +|---------------| ----- | ---- |-------------------------------------------------------------------| ------- +| `org` | required | String | the organization Id provided by your Kueez representative | "test-publisher-id" +| `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 1.50 +| `placementId` | optional | String | A unique placement identifier | "12345678" +| `testMode` | optional | Boolean | This activates the test mode | false + +# Test Parameters + +```javascript +var adUnits = [{ + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] + } + }, + bids: [{ + bidder: 'kueez', + params: { + org: 'test-org-id', // Required + floorPrice: 0.2, // Optional + placementId: '12345678', // Optional + testMode: true // Optional + } + }] +}, + { + code: 'dfp-video-div', + sizes: [ + [640, 480] + ], + mediaTypes: { + video: { + playerSize: [ + [640, 480] + ], + context: 'instream' + } + }, + bids: [{ + bidder: 'kueez', + params: { + org: 'test-org-id', // Required + floorPrice: 1.50, // Optional + placementId: '12345678', // Optional + testMode: true // Optional + } + }] + } +]; +``` diff --git a/modules/kueezRtbBidAdapter.js b/modules/kueezRtbBidAdapter.js new file mode 100644 index 00000000000..9a336b16136 --- /dev/null +++ b/modules/kueezRtbBidAdapter.js @@ -0,0 +1,348 @@ +import {_each, deepAccess, parseSizesInput, parseUrl, uniques, isFn} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {config} from '../src/config.js'; + +const GVLID = 1165; +const DEFAULT_SUB_DOMAIN = 'exchange'; +const BIDDER_CODE = 'kueezrtb'; +const BIDDER_VERSION = '1.0.0'; +const CURRENCY = 'USD'; +const TTL_SECONDS = 60 * 5; +const UNIQUE_DEAL_ID_EXPIRY = 1000 * 60 * 15; +const storage = getStorageManager({bidderCode: BIDDER_CODE}); + +function getTopWindowQueryParams() { + try { + const parsedUrl = parseUrl(window.top.document.URL, {decodeSearchAsString: true}); + return parsedUrl.search; + } catch (e) { + return ''; + } +} + +export function createDomain(subDomain = DEFAULT_SUB_DOMAIN) { + return `https://${subDomain}.kueezrtb.com`; +} + +export function extractCID(params) { + return params.cId || params.CID || params.cID || params.CId || params.cid || params.ciD || params.Cid || params.CiD; +} + +export function extractPID(params) { + return params.pId || params.PID || params.pID || params.PId || params.pid || params.piD || params.Pid || params.PiD; +} + +export function extractSubDomain(params) { + return params.subDomain || params.SubDomain || params.Subdomain || params.subdomain || params.SUBDOMAIN || params.subDOMAIN; +} + +function isBidRequestValid(bid) { + const params = bid.params || {}; + return !!(extractCID(params) && extractPID(params)); +} + +function buildRequest(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout) { + const { + params, + bidId, + userId, + adUnitCode, + schain, + mediaTypes, + auctionId, + transactionId, + bidderRequestId, + bidRequestsCount, + bidderRequestsCount, + bidderWinsCount + } = bid; + let {bidFloor, ext} = params; + const hashUrl = hashCode(topWindowUrl); + const uniqueDealId = getUniqueDealId(hashUrl); + const cId = extractCID(params); + const pId = extractPID(params); + const subDomain = extractSubDomain(params); + + const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', '')); + + if (isFn(bid.getFloor)) { + const floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + + if (floorInfo.currency === 'USD') { + bidFloor = floorInfo.floor; + } + } + + let data = { + url: encodeURIComponent(topWindowUrl), + uqs: getTopWindowQueryParams(), + cb: Date.now(), + bidFloor: bidFloor, + bidId: bidId, + referrer: bidderRequest.refererInfo.ref, + adUnitCode: adUnitCode, + publisherId: pId, + sizes: sizes, + uniqueDealId: uniqueDealId, + bidderVersion: BIDDER_VERSION, + prebidVersion: '$prebid.version$', + res: `${screen.width}x${screen.height}`, + schain: schain, + mediaTypes: mediaTypes, + gpid: gpid, + // TODO: fix auctionId/transactionId leak: https://github.com/prebid/Prebid.js/issues/9781 + auctionId: auctionId, + transactionId: transactionId, + bidderRequestId: bidderRequestId, + bidRequestsCount: bidRequestsCount, + bidderRequestsCount: bidderRequestsCount, + bidderWinsCount: bidderWinsCount, + bidderTimeout: bidderTimeout + }; + + appendUserIdsToRequestPayload(data, userId); + + const sua = deepAccess(bidderRequest, 'ortb2.device.sua'); + + if (sua) { + data.sua = sua; + } + + if (bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent.consentString) { + data.gdprConsent = bidderRequest.gdprConsent.consentString; + } + if (bidderRequest.gdprConsent.gdprApplies !== undefined) { + data.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + } + if (bidderRequest.uspConsent) { + data.usPrivacy = bidderRequest.uspConsent; + } + + if (bidderRequest.gppConsent) { + data.gppString = bidderRequest.gppConsent.gppString; + data.gppSid = bidderRequest.gppConsent.applicableSections; + } else if (bidderRequest.ortb2?.regs?.gpp) { + data.gppString = bidderRequest.ortb2.regs.gpp; + data.gppSid = bidderRequest.ortb2.regs.gpp_sid; + } + + const dto = { + method: 'POST', + url: `${createDomain(subDomain)}/prebid/multi/${cId}`, + data: data + }; + + _each(ext, (value, key) => { + dto.data['ext.' + key] = value; + }); + + return dto; +} + +function appendUserIdsToRequestPayload(payloadRef, userIds) { + let key; + _each(userIds, (userId, idSystemProviderName) => { + key = `uid.${idSystemProviderName}`; + + switch (idSystemProviderName) { + case 'digitrustid': + payloadRef[key] = deepAccess(userId, 'data.id'); + break; + case 'lipb': + payloadRef[key] = userId.lipbid; + break; + case 'parrableId': + payloadRef[key] = userId.eid; + break; + case 'id5id': + payloadRef[key] = userId.uid; + break; + default: + payloadRef[key] = userId; + } + }); +} + +function buildRequests(validBidRequests, bidderRequest) { + const topWindowUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; + const bidderTimeout = config.getConfig('bidderTimeout'); + const requests = []; + validBidRequests.forEach(validBidRequest => { + const sizes = parseSizesInput(validBidRequest.sizes); + const request = buildRequest(validBidRequest, topWindowUrl, sizes, bidderRequest, bidderTimeout); + requests.push(request); + }); + return requests; +} + +function interpretResponse(serverResponse, request) { + if (!serverResponse || !serverResponse.body) { + return []; + } + const {bidId} = request.data; + const {results} = serverResponse.body; + + let output = []; + + try { + results.forEach(result => { + const { + creativeId, + ad, + price, + exp, + width, + height, + currency, + metaData, + advertiserDomains, + mediaType = BANNER + } = result; + if (!ad || !price) { + return; + } + + const response = { + requestId: bidId, + cpm: price, + width: width, + height: height, + creativeId: creativeId, + currency: currency || CURRENCY, + netRevenue: true, + ttl: exp || TTL_SECONDS, + }; + + if (metaData) { + Object.assign(response, { + meta: metaData + }) + } else { + Object.assign(response, { + meta: { + advertiserDomains: advertiserDomains || [] + } + }) + } + + if (mediaType === BANNER) { + Object.assign(response, { + ad: ad, + }); + } else { + Object.assign(response, { + vastXml: ad, + mediaType: VIDEO + }); + } + output.push(response); + }); + return output; + } catch (e) { + return []; + } +} + +function getUserSyncs(syncOptions, responses, gdprConsent = {}, uspConsent = '', gppConsent = {}) { + let syncs = []; + const {iframeEnabled, pixelEnabled} = syncOptions; + const {gdprApplies, consentString = ''} = gdprConsent; + const {gppString, applicableSections} = gppConsent; + + const cidArr = responses.filter(resp => deepAccess(resp, 'body.cid')).map(resp => resp.body.cid).filter(uniques); + let params = `?cid=${encodeURIComponent(cidArr.join(','))}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${encodeURIComponent(consentString || '')}&us_privacy=${encodeURIComponent(uspConsent || '')}` + + if (gppString && applicableSections?.length) { + params += '&gpp=' + encodeURIComponent(gppString); + params += '&gpp_sid=' + encodeURIComponent(applicableSections.join(',')); + } + + if (iframeEnabled) { + syncs.push({ + type: 'iframe', + url: `https://sync.kueezrtb.com/api/sync/iframe/${params}` + }); + } + if (pixelEnabled) { + syncs.push({ + type: 'image', + url: `https://sync.kueezrtb.com/api/sync/image/${params}` + }); + } + return syncs; +} + +export function hashCode(s, prefix = '_') { + const l = s.length; + let h = 0 + let i = 0; + if (l > 0) { + while (i < l) { + h = (h << 5) - h + s.charCodeAt(i++) | 0; + } + } + return prefix + h; +} + +export function getUniqueDealId(key, expiry = UNIQUE_DEAL_ID_EXPIRY) { + const storageKey = `u_${key}`; + const now = Date.now(); + const data = getStorageItem(storageKey); + let uniqueId; + + if (!data || !data.value || now - data.created > expiry) { + uniqueId = `${key}_${now.toString()}`; + setStorageItem(storageKey, uniqueId); + } else { + uniqueId = data.value; + } + + return uniqueId; +} + +export function getStorageItem(key) { + try { + return tryParseJSON(storage.getDataFromLocalStorage(key)); + } catch (e) { + } + + return null; +} + +export function setStorageItem(key, value, timestamp) { + try { + const created = timestamp || Date.now(); + const data = JSON.stringify({value, created}); + storage.setDataInLocalStorage(key, data); + } catch (e) { + } +} + +export function tryParseJSON(value) { + try { + return JSON.parse(value); + } catch (e) { + return value; + } +} + +export const spec = { + code: BIDDER_CODE, + version: BIDDER_VERSION, + gvlid: GVLID, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs +}; + +registerBidder(spec); diff --git a/modules/kueezRtbBidAdapter.md b/modules/kueezRtbBidAdapter.md new file mode 100644 index 00000000000..52d11aa362a --- /dev/null +++ b/modules/kueezRtbBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +**Module Name:** Kueez RTB Bidder Adapter + +**Module Type:** Bidder Adapter + +**Maintainer:** rtb@kueez.com + +# Description + +Module that connects to Kueez's demand sources. + +# Test Parameters +```js +var adUnits = [ + { + code: 'test-ad', + sizes: [[300, 250]], + bids: [ + { + bidder: 'kueezrtb', + params: { + cId: '562524b21b1c1f08117fc7f9', + pId: '59ac17c192832d0011283fe3', + bidFloor: 0.0001, + ext: { + param1: 'loremipsum', + param2: 'dolorsitamet' + } + } + } + ] + } +]; +``` diff --git a/modules/kummaBidAdapter.md b/modules/kummaBidAdapter.md deleted file mode 100644 index 639e0c97d08..00000000000 --- a/modules/kummaBidAdapter.md +++ /dev/null @@ -1,87 +0,0 @@ -# Overview - -**Module Name**: Kumma Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: yehonatan@kumma.com - -# Description - -Connects to Kumma demand source to fetch bids. -Banner, Native, Video formats are supported. -Please use ```kumma``` as the bidder code. - -# Test Parameters -``` - var adUnits = [{ - code: 'dfp-native-div', - mediaType: 'native', - mediaTypes: { - native: { - title: { - required: true, - len: 75 - }, - image: { - required: true - }, - body: { - len: 200 - }, - icon: { - required: false - } - } - }, - bids: [{ - bidder: 'kumma', - params: { - pubId: '29521', - siteId: '26047', - placementId: '123', - bidFloor: '0.001', // optional - ifa: 'XXX-XXX', // optional - latitude: '40.712775', // optional - longitude: '-74.005973', // optional - } - }] - }, - { - code: 'dfp-banner-div', - mediaTypes: { - banner: { - sizes: [ - [300, 250] - ], - } - }, - bids: [{ - bidder: 'kumma', - params: { - pubId: '29521', - siteId: '26049', - placementId: '123', - } - }] - }, - { - code: 'dfp-video-div', - sizes: [640, 480], - mediaTypes: { - video: { - context: "instream" - } - }, - bids: [{ - bidder: 'kumma', - params: { - pubId: '29521', - siteId: '26049', - placementId: '123', - video: { - skipppable: true, - } - } - }] - } - ]; -``` diff --git a/modules/lassoBidAdapter.js b/modules/lassoBidAdapter.js new file mode 100644 index 00000000000..e1f9636e4f1 --- /dev/null +++ b/modules/lassoBidAdapter.js @@ -0,0 +1,138 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { ajax } from '../src/ajax.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'lasso'; +const ENDPOINT_URL = 'https://trc.lhmos.com/prebid'; +const GET_IUD_URL = 'https://secure.adnxs.com/getuid?'; +const COOKIE_NAME = 'aim-xr'; +const storage = getStorageManager({bidderCode: BIDDER_CODE}); + +export const spec = { + code: BIDDER_CODE, + isBidRequestValid: function(bid) { + return !!(bid.params && bid.params.adUnitId); + }, + + buildRequests: function(validBidRequests, bidderRequest) { + if (validBidRequests.length === 0) { + return []; + } + + let aimXR = ''; + if (storage.cookiesAreEnabled) { + aimXR = storage.getCookie(COOKIE_NAME, undefined); + } + + return validBidRequests.map(bidRequest => { + let sizes = [] + if (bidRequest.mediaTypes && bidRequest.mediaTypes[BANNER] && bidRequest.mediaTypes[BANNER].sizes) { + sizes = bidRequest.mediaTypes[BANNER].sizes; + } + + const payload = { + auctionStart: bidderRequest.auctionStart, + url: encodeURIComponent(window.location.href), + bidderRequestId: bidRequest.bidderRequestId, + adUnitCode: bidRequest.adUnitCode, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + auctionId: bidRequest.auctionId, + bidId: bidRequest.bidId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, + device: encodeURIComponent(JSON.stringify(getDeviceData())), + sizes, + aimXR, + uid: '$UID', + params: JSON.stringify(bidRequest.params), + crumbs: JSON.stringify(bidRequest.crumbs), + prebidVersion: '$prebid.version$', + version: 3, + coppa: config.getConfig('coppa') == true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined + } + + return { + method: 'GET', + url: getBidRequestUrl(aimXR, bidRequest.params), + data: payload, + options: { + withCredentials: true + }, + }; + }); + }, + + interpretResponse: function(serverResponse) { + const response = serverResponse && serverResponse.body; + const bidResponses = []; + + if (!response || !response.bid.ad) { + return bidResponses; + } + + const bidResponse = { + requestId: response.bidid, + cpm: response.bid.price, + currency: response.cur, + width: response.bid.w, + height: response.bid.h, + creativeId: response.bid.crid, + netRevenue: response.netRevenue, + ttl: response.ttl, + ad: response.bid.ad, + mediaType: response.bid.mediaType, + meta: { + secondaryCatIds: response.bid.cat, + advertiserDomains: response.bid.advertiserDomains, + advertiserName: response.meta.advertiserName, + mediaType: response.bid.mediaType + } + }; + bidResponses.push(bidResponse); + return bidResponses; + }, + + onTimeout: function(timeoutData) { + if (timeoutData === null) { + return; + } + ajax(ENDPOINT_URL + '/timeout', null, JSON.stringify(timeoutData), { + method: 'POST', + withCredentials: false + }); + }, + + onBidWon: function(bid) { + ajax(ENDPOINT_URL + '/won', null, JSON.stringify(bid), { + method: 'POST', + withCredentials: false + }); + }, + + supportedMediaTypes: [BANNER] +} + +function getBidRequestUrl(aimXR, params) { + let path = '/request'; + if (params && params.dtc) { + path = '/dtc-request'; + } + if (!aimXR) { + return GET_IUD_URL + ENDPOINT_URL + path; + } + return ENDPOINT_URL + path; +} + +function getDeviceData() { + const win = window.top; + return { + ua: navigator.userAgent, + width: win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth, + height: win.innerHeight || win.document.documentElement.clientHeight || win.document.body.clientHeight, + browserLanguage: navigator.language, + } +} + +registerBidder(spec); diff --git a/modules/lassoBidAdapter.md b/modules/lassoBidAdapter.md new file mode 100644 index 00000000000..43927fe890c --- /dev/null +++ b/modules/lassoBidAdapter.md @@ -0,0 +1,29 @@ +# Overview + +**Module Name**: Lasso Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: headerbidding@lassomarketing.io + +# Description + +Connects to Lasso demand source to fetch bids. +Only banner format supported. + +# Test Parameters + +``` +var adUnits = [{ + code: 'banner-ad-unit', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [{ + bidder: 'lasso', + params: { + adUnitId: '0' + } + }] +}]; +``` diff --git a/modules/lemmaDigitalBidAdapter.js b/modules/lemmaDigitalBidAdapter.js new file mode 100644 index 00000000000..9fa3081a47e --- /dev/null +++ b/modules/lemmaDigitalBidAdapter.js @@ -0,0 +1,570 @@ +import * as utils from '../src/utils.js'; +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; + +var BIDDER_CODE = 'lemmadigital'; +var LOG_WARN_PREFIX = 'LEMMADIGITAL: '; +var ENDPOINT = 'https://bid.lemmadigital.com/lemma/servad'; +var USER_SYNC = 'https://sync.lemmadigital.com/js/usersync.html?'; +var DEFAULT_CURRENCY = 'USD'; +var AUCTION_TYPE = 2; +var DEFAULT_TMAX = 300; +var DEFAULT_NET_REVENUE = false; +var DEFAULT_SECURE = 1; +var RESPONSE_TTL = 300; +var pubId = 0; +var adunitId = 0; + +export var spec = { + + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + **/ + isBidRequestValid: (bid) => { + if (!bid || !bid.params) { + utils.logError(LOG_WARN_PREFIX, 'nil/empty bid object'); + return false; + } + if (!utils.isEmpty(bid.params.pubId) || !utils.isNumber(bid.params.pubId)) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: publisherId is mandatory and cannot be string. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); + return false; + } + if (!bid.params.adunitId) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: adUnitId is mandatory. Call to OpenBid will not be sent for ad unit: ' + JSON.stringify(bid)); + return false; + } + // video bid request validation + if (bid.params.hasOwnProperty('video')) { + if (!bid.params.video.hasOwnProperty('mimes') || !utils.isArray(bid.params.video.mimes) || bid.params.video.mimes.length === 0) { + utils.logWarn(LOG_WARN_PREFIX + 'Error: For video ads, mimes is mandatory and must specify atlease 1 mime value. Call to OpenBid will not be sent for ad unit:' + JSON.stringify(bid)); + return false; + } + } + return true; + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + **/ + buildRequests: (validBidRequests, bidderRequest) => { + if (validBidRequests.length === 0) { + return; + } + var refererInfo; + if (bidderRequest && bidderRequest.refererInfo) { + refererInfo = bidderRequest.refererInfo; + } + var conf = spec._setRefURL(refererInfo); + const request = spec._createoRTBRequest(validBidRequests, conf); + if (request && request.imp.length == 0) { + return; + } + spec._setOtherParams(bidderRequest, request); + const endPoint = spec._endPointURL(validBidRequests); + return { + method: 'POST', + url: endPoint, + data: JSON.stringify(request), + }; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} response A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + **/ + interpretResponse: (response, request) => { + return spec._parseRTBResponse(request, response.body); + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + **/ + getUserSyncs: (syncOptions, serverResponses) => { + let syncurl = USER_SYNC + 'pid=' + pubId; + if (syncOptions.iframeEnabled) { + return [{ + type: 'iframe', + url: syncurl + }]; + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Please enable iframe based user sync.'); + } + }, + + /** + * Generate UUID + */ + _createUUID: () => { + return new Date().getTime().toString(); + }, + + /** + * parse object + **/ + _parseJSON: function (rawPayload) { + try { + if (rawPayload) { + return JSON.parse(rawPayload); + } + } catch (ex) { + utils.logError(LOG_WARN_PREFIX, 'Exception: ', ex); + } + return null; + }, + + /** + * + * set referal url + */ + _setRefURL: (refererInfo) => { + var conf = {}; + conf.pageURL = (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href; + if (refererInfo && refererInfo.referer) { + conf.refURL = refererInfo.referer; + } else { + conf.refURL = ''; + } + return conf; + }, + + /** + * set other params into oRTB request + */ + _setOtherParams: (request, ortbRequest) => { + var params = request && request.params ? request.params : null; + if (params) { + ortbRequest.tmax = params.tmax; + ortbRequest.bcat = params.bcat; + } + }, + + /** + * create IAB standard OpenRTB bid request + **/ + _createoRTBRequest: (bidRequests, conf) => { + var oRTBObject = {}; + try { + oRTBObject = { + id: spec._createUUID(), + at: AUCTION_TYPE, + tmax: DEFAULT_TMAX, + cur: [DEFAULT_CURRENCY], + imp: spec._getImpressionArray(bidRequests), + user: {}, + ext: {} + }; + var bid = bidRequests[0]; + + var site = spec._getSiteObject(bid, conf); + if (site) { + oRTBObject.site = site; + // add the content object from config in request + if (typeof config.getConfig('content') === 'object') { + oRTBObject.site.content = config.getConfig('content'); + } + } + var app = spec._getAppObject(bid); + if (app) { + oRTBObject.app = app; + if (typeof oRTBObject.app.content !== 'object' && typeof config.getConfig('content') === 'object') { + oRTBObject.app.content = + config.getConfig('content') || undefined; + } + } + var device = spec._getDeviceObject(bid); + if (device) { + oRTBObject.device = device; + } + var source = spec._getSourceObject(bid); + if (source) { + oRTBObject.source = source; + } + return oRTBObject; + } catch (ex) { + utils.logError(LOG_WARN_PREFIX, 'ERROR ', ex); + } + }, + + /** + * create impression array objects + **/ + _getImpressionArray: (request) => { + var impArray = []; + var map = request.map(bid => spec._getImpressionObject(bid)); + if (map) { + map.forEach(o => { + if (o) { + impArray.push(o); + } + }); + } + return impArray; + }, + + /** + * create impression (single) object + **/ + _getImpressionObject: (bid) => { + var impression = {}; + var bObj; + var vObj; + var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : []; + var mediaTypes = ''; + var format = []; + var params = bid && bid.params ? bid.params : null; + impression = { + id: bid.bidId, + tagid: params.adunitId ? params.adunitId.toString() : undefined, + secure: DEFAULT_SECURE, + bidfloorcur: params.currency ? params.currency : DEFAULT_CURRENCY + }; + if (params.bidFloor) { + impression.bidfloor = params.bidFloor; + } + if (bid.hasOwnProperty('mediaTypes')) { + for (mediaTypes in bid.mediaTypes) { + switch (mediaTypes) { + case BANNER: + bObj = spec._getBannerRequest(bid); + if (bObj) { + impression.banner = bObj; + } + break; + case VIDEO: + vObj = spec._getVideoRequest(bid); + if (vObj) { + impression.video = vObj; + } + break; + } + } + } else { + bObj = { + pos: 0, + w: sizes && sizes[0] ? sizes[0][0] : 0, + h: sizes && sizes[0] ? sizes[0][1] : 0, + }; + if (utils.isArray(sizes) && sizes.length > 1) { + sizes = sizes.splice(1, sizes.length - 1); + sizes.forEach(size => { + format.push({ + w: size[0], + h: size[1] + }); + }); + bObj.format = format; + } + impression.banner = bObj; + } + spec._setFloor(impression, bid); + return impression.hasOwnProperty(BANNER) || + impression.hasOwnProperty(VIDEO) ? impression : undefined; + }, + + /** + * set bid floor + **/ + _setFloor: (impObj, bid) => { + let bidFloor = -1; + // get lowest floor from floorModule + if (typeof bid.getFloor === 'function') { + [BANNER, VIDEO].forEach(mediaType => { + if (impObj.hasOwnProperty(mediaType)) { + let floorInfo = bid.getFloor({ currency: impObj.bidfloorcur, mediaType: mediaType, size: '*' }); + if (typeof floorInfo === 'object' && floorInfo.currency === impObj.bidfloorcur && !isNaN(parseInt(floorInfo.floor))) { + let mediaTypeFloor = parseFloat(floorInfo.floor); + bidFloor = (bidFloor == -1 ? mediaTypeFloor : Math.min(mediaTypeFloor, bidFloor)); + } + } + }); + } + // get highest from impObj.bidfllor and floor from floor module + // as we are using Math.max, it is ok if we have not got any floor from floorModule, then value of bidFloor will be -1 + if (impObj.bidfloor) { + bidFloor = Math.max(bidFloor, impObj.bidfloor); + } + + // assign value only if bidFloor is > 0 + impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : undefined); + }, + + /** + * parse Open RTB response + **/ + _parseRTBResponse: (request, response) => { + var bidResponses = []; + try { + if (response.seatbid) { + var currency = response.curr || DEFAULT_CURRENCY; + var seatbid = response.seatbid; + seatbid.forEach(seatbidder => { + var bidder = seatbidder.bid; + bidder.forEach(bid => { + var req = spec._parseJSON(request.data); + var newBid = { + requestId: bid.impid, + cpm: parseFloat(bid.price).toFixed(2), + width: bid.w, + height: bid.h, + creativeId: bid.crid, + currency: currency, + netRevenue: DEFAULT_NET_REVENUE, + ttl: RESPONSE_TTL, + referrer: req.site.ref, + ad: bid.adm + }; + if (bid.dealid) { + newBid.dealId = bid.dealid; + } + if (req.imp && req.imp.length > 0) { + req.imp.forEach(robj => { + if (bid.impid === robj.id) { + spec._checkMediaType(bid.adm, newBid); + switch (newBid.mediaType) { + case BANNER: + break; + case VIDEO: + newBid.width = bid.hasOwnProperty('w') ? bid.w : robj.video.w; + newBid.height = bid.hasOwnProperty('h') ? bid.h : robj.video.h; + newBid.vastXml = bid.adm; + break; + } + } + }); + } + bidResponses.push(newBid); + }); + }); + } + } catch (error) { + utils.logError(LOG_WARN_PREFIX, 'ERROR ', error); + } + return bidResponses; + }, + + /** + * get bid request api end point url + **/ + _endPointURL: (request) => { + var params = request && request[0].params ? request[0].params : null; + if (params) { + pubId = params.pubId ? params.pubId : 0; + adunitId = params.adunitId ? params.adunitId : 0; + return ENDPOINT + '?pid=' + pubId + '&aid=' + adunitId; + } + return null; + }, + + /** + * get domain name from url + **/ + _getDomain: (url) => { + var a = document.createElement('a'); + a.setAttribute('href', url); + return a.hostname; + }, + + /** + * create the site object + **/ + _getSiteObject: (request, conf) => { + var params = request && request.params ? request.params : null; + if (params) { + pubId = params.pubId ? params.pubId : '0'; + var siteId = params.siteId ? params.siteId : '0'; + var appParams = params.app; + if (!appParams) { + return { + publisher: { + id: pubId.toString() + }, + domain: spec._getDomain(conf.pageURL), + id: siteId.toString(), + ref: conf.refURL, + page: conf.pageURL, + cat: params.category, + pagecat: params.page_category + }; + } + } + return null; + }, + + /** + * create the app object + **/ + _getAppObject: (request) => { + var params = request && request.params ? request.params : null; + if (params) { + pubId = params.pubId ? params.pubId : 0; + var appParams = params.app; + if (appParams) { + return { + publisher: { + id: pubId.toString(), + }, + id: appParams.id, + name: appParams.name, + bundle: appParams.bundle, + storeurl: appParams.storeUrl, + domain: appParams.domain, + cat: appParams.cat || params.category, + pagecat: appParams.pagecat || params.page_category + }; + } + } + return null; + }, + + /** + * create the device object + **/ + _getDeviceObject: (request) => { + var params = request && request.params ? request.params : null; + if (params) { + return { + dnt: utils.getDNT() ? 1 : 0, + ua: navigator.userAgent, + language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), + w: (window.screen.width || window.innerWidth), + h: (window.screen.height || window.innerHeigh), + geo: { + country: params.country, + lat: params.latitude, + lon: params.longitude, + accuracy: params.accuracy, + region: params.region, + city: params.city, + zip: params.zip + }, + ip: params.ip, + make: params.make, + model: params.model, + os: params.os, + carrier: params.carrier, + devicetype: params.device_type, + ifa: params.ifa, + }; + } + return null; + }, + + /** + * create source object + */ + _getSourceObject: (request) => { + var params = request && request.params ? request.params : null; + if (params) { + return { + pchain: params.pchain, + ext: { + schain: request.schain + }, + }; + } + return null; + }, + + /** + * get request ad sizes + **/ + _getSizes: (request) => { + if (request && request.sizes && utils.isArray(request.sizes[0]) && request.sizes[0].length > 0) { + return request.sizes[0]; + } + return null; + }, + + /** + * create the banner object + **/ + _getBannerRequest: (bid) => { + var bObj; + var adFormat = []; + if (utils.deepAccess(bid, 'mediaTypes.banner')) { + var params = bid ? bid.params : null; + var bannerData = params && params.banner; + var sizes = spec._getSizes(bid) || []; + if (sizes && sizes.length == 0) { + sizes = bid.mediaTypes.banner.sizes[0]; + } + if (sizes && sizes.length > 0) { + bObj = {}; + bObj.w = sizes[0]; + bObj.h = sizes[1]; + bObj.pos = 0; + if (bannerData) { + bObj = utils.deepClone(bannerData); + } + sizes = bid.mediaTypes.banner.sizes; + if (sizes.length > 0) { + adFormat = []; + sizes.forEach(function (size) { + if (size.length > 1) { + adFormat.push({ w: size[0], h: size[1] }); + } + }); + if (adFormat.length > 0) { + bObj.format = adFormat; + } + } + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.banner.sizes missing for adunit: ' + bid.params.adunitId); + } + } + return bObj; + }, + + /** + * create the video object + **/ + _getVideoRequest: (bid) => { + var vObj; + if (utils.deepAccess(bid, 'mediaTypes.video')) { + var params = bid ? bid.params : null; + var videoData = utils.mergeDeep(utils.deepAccess(bid.mediaTypes, 'video'), params.video); + var sizes = bid.mediaTypes.video ? bid.mediaTypes.video.playerSize : [] + if (sizes && sizes.length > 0) { + vObj = {}; + if (videoData) { + vObj = utils.deepClone(videoData); + } + vObj.w = sizes[0]; + vObj.h = sizes[1]; + } else { + utils.logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.video.sizes missing for adunit: ' + bid.params.adunitId); + } + } + return vObj; + }, + + /** + * check media type + **/ + _checkMediaType: (adm, newBid) => { + // Create a regex here to check the strings + var videoRegex = new RegExp(/VAST.*version/); + if (videoRegex.test(adm)) { + newBid.mediaType = VIDEO; + } else { + newBid.mediaType = BANNER; + } + } +}; + +registerBidder(spec); diff --git a/modules/lemmaBidAdapter.md b/modules/lemmaDigitalBidAdapter.md similarity index 82% rename from modules/lemmaBidAdapter.md rename to modules/lemmaDigitalBidAdapter.md index 29e72e028b9..5a22a7588da 100644 --- a/modules/lemmaBidAdapter.md +++ b/modules/lemmaDigitalBidAdapter.md @@ -1,7 +1,7 @@ # Overview ``` -Module Name: Lemma Bid Adapter +Module Name: Lemmadigital Bid Adapter Module Type: Bidder Adapter Maintainer: lemmadev@lemmatechnologies.com ``` @@ -9,7 +9,7 @@ Maintainer: lemmadev@lemmatechnologies.com # Description Connects to Lemma exchange for bids. -Lemma bid adapter supports Video, Banner formats. +Lemmadigital bid adapter supports Video, Banner formats. # Sample Banner Ad Unit: For Publishers ``` @@ -22,17 +22,13 @@ var adUnits = [{ }, // Replace this object to test a new Adapter! bids: [{ - bidder: 'lemma', + bidder: 'lemmadigital', params: { pubId: 1, // required adunitId: '3768', // required latitude: 37.3230, longitude: -122.0322, - device_type: 2, - banner: { - w: 300, - h: 250 - } + device_type: 2 } }] }]; @@ -41,7 +37,6 @@ var adUnits = [{ # Sample Video Ad Unit: For Publishers ``` var adUnits = [{ - mediaType: 'video', mediaTypes: { video: { playerSize: [640, 480], // required @@ -50,7 +45,7 @@ var adUnits = [{ }, // Replace this object to test a new Adapter! bids: [{ - bidder: 'lemma', + bidder: 'lemmadigital', params: { pubId: 1, // required adunitId: '3769', // required diff --git a/modules/lifestreetBidAdapter.js b/modules/lifestreetBidAdapter.js new file mode 100644 index 00000000000..6a8b783ce21 --- /dev/null +++ b/modules/lifestreetBidAdapter.js @@ -0,0 +1,143 @@ +import { isInteger } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'lifestreet'; +const ADAPTER_VERSION = '$prebid.version$'; + +const urlTemplate = template`https://ads.lfstmedia.com/gate/${'adapter'}/${'slot'}?adkey=${'adkey'}&ad_size=${'ad_size'}&__location=${'location'}&__referrer=${'referrer'}&__wn=${'wn'}&__sf=${'sf'}&__fif=${'fif'}&__if=${'if'}&__stamp=${'stamp'}&__pp=1&__hb=1&_prebid_json=1&__gz=1&deferred_format=vast_2_0,vast_3_0&__hbver=${'hbver'}`; + +/** + * A helper function for template to generate string from boolean + */ +function boolToString(value) { + return value ? '1' : '0'; +} + +/** + * A helper function to form URL from the template + */ +function template(strings, ...keys) { + return function(...values) { + let dict = values[values.length - 1] || {}; + let result = [strings[0]]; + keys.forEach(function(key, i) { + let value = isInteger(key) ? values[key] : dict[key]; + result.push(value, strings[i + 1]); + }); + return result.join(''); + }; +} + +/** + * Creates a bid requests for a given bid. + * + * @param {BidRequest} bid The bid params to use for formatting a request + */ +function formatBidRequest(bid, bidderRequest = {}) { + const {params} = bid; + const {referer} = (bidderRequest.refererInfo || {}); + let url = urlTemplate({ + adapter: 'prebid', + slot: params.slot, + adkey: params.adkey, + ad_size: params.ad_size, + location: referer, + referrer: referer, + wn: boolToString(/fb_http/i.test(window.name)), + sf: boolToString(window['sfAPI'] || window['$sf']), + fif: boolToString(window['inDapIF'] === true), + if: boolToString(window !== window.top), + stamp: new Date().getTime(), + hbver: ADAPTER_VERSION + }); + + if (bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent.gdprApplies !== undefined) { + const gdpr = '&__gdpr=' + (bidderRequest.gdprConsent.gdprApplies ? '1' : '0'); + url += gdpr; + } + if (bidderRequest.gdprConsent.consentString !== undefined) { + url += `&__consent=${bidderRequest.gdprConsent.consentString}`; + } + } + + // ccpa support + if (bidderRequest.uspConsent) { + url += `&__us_privacy=${bidderRequest.uspConsent}` + } + + return { + method: 'GET', + url: url, + bidId: bid.bidId + }; +} + +function isResponseValid(response) { + return !/^\s*\{\s*"advertisementAvailable"\s*:\s*false/i.test(response.content) && + response.content.indexOf('') === -1 && /* (typeof response.cpm !== 'undefined') && */ + response.status === 1; +} + +export const spec = { + code: BIDDER_CODE, + aliases: ['lsm'], + supportedMediaTypes: [BANNER, VIDEO], + + isBidRequestValid: (bid = {}) => { + const {params = {}} = bid; + return !!(params.slot && params.adkey && params.ad_size); + }, + + buildRequests: (validBidRequests, bidderRequest) => { + return validBidRequests.map(bid => { + return formatBidRequest(bid, bidderRequest) + }); + }, + + interpretResponse: (serverResponse, bidRequest) => { + const bidResponses = []; + let response = serverResponse.body; + if (!isResponseValid(response)) { + return bidResponses; + } + + const isVideo = response.content_type.indexOf('vast') > -1; + const mediaType = isVideo ? VIDEO : BANNER; + + const bidResponse = { + requestId: bidRequest.bidId, + cpm: response.cpm, + currency: response.currency ? response.currency : 'USD', + width: response.width, + height: response.height, + creativeId: response.creativeId, + netRevenue: response.netRevenue ? response.netRevenue : true, + ttl: response.ttl ? response.ttl : 86400, + mediaType, + meta: { + mediaType, + advertiserDomains: response.advertiserDomains + } + }; + + if (response.hasOwnProperty('dealId')) { + bidResponse.dealId = response.dealId; + } + if (isVideo) { + if (typeof response.vastUrl !== 'undefined') { + bidResponse.vastUrl = response.vastUrl; + } else { + bidResponse.vastXml = response.content; + } + } else { + bidResponse.ad = response.content; + } + + bidResponses.push(bidResponse); + return bidResponses; + } +}; + +registerBidder(spec); diff --git a/modules/lifestreetBidAdapter.md b/modules/lifestreetBidAdapter.md deleted file mode 100644 index a874792d84c..00000000000 --- a/modules/lifestreetBidAdapter.md +++ /dev/null @@ -1,76 +0,0 @@ -# Overview - -``` -Module Name: Lifestreet Bid Adapter -Module Type: Lifestreet Adapter -Maintainer: hb.tech@lifestreet.com -``` - -# Description - -Module that connects to Lifestreet's demand sources - -Values, listed in `ALL_BANNER_SIZES` and `ALL_VIDEO_SIZES` are all the values which our server supports. -For `ad_size`, please use one of that values in following format: `ad_size: WIDTHxHEIGHT` - -# Test Parameters -```javascript - const ALL_BANNER_SIZES = [ - [120, 600], [160, 600], [300, 250], [300, 600], [320, 480], - [320, 50], [468, 60], [510, 510], [600, 300], - [720, 300], [728, 90], [760, 740], [768, 1024] - ]; - - const ALL_VIDEO_SIZES = [ - [640, 480], [650, 520], [970, 580] - ] -``` - -# Test Parameters (Banner) -``` - const adUnits = [ - { - code: 'test-ad', - mediaTypes: { - banner: { - sizes: [[160, 600]], - } - }, - bids: [ - { - bidder: 'lifestreet', - params: { - slot: 'slot166704', - adkey: '78c', - ad_size: '160x600' - } - } - ] - }, - ]; -``` - -# Test Parameters (Video) -``` - const adUnits = [ - { - code: 'test-video-ad', - mediaTypes: { - video: { - playerSize: [[640, 480]], - context: 'instream' - } - }, - bids: [ - { - bidder: 'lifestreet', - params: { - slot: 'slot1227631', - adkey: 'a98', - ad_size: '640x480' - } - } - ] - } - ]; -``` diff --git a/modules/limelightDigitalBidAdapter.js b/modules/limelightDigitalBidAdapter.js index a278a587038..0eb9e900160 100644 --- a/modules/limelightDigitalBidAdapter.js +++ b/modules/limelightDigitalBidAdapter.js @@ -26,7 +26,7 @@ function isBidResponseValid(bid) { export const spec = { code: BIDDER_CODE, - aliases: ['pll'], + aliases: ['pll', 'iionads', 'apester'], supportedMediaTypes: [BANNER, VIDEO], /** @@ -148,7 +148,7 @@ function buildPlacement(bidRequest) { adUnit: { id: bidRequest.params.adUnitId, bidId: bidRequest.bidId, - transactionId: bidRequest.transactionId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, sizes: sizes.map(size => { return { width: size[0], @@ -157,7 +157,13 @@ function buildPlacement(bidRequest) { }), type: bidRequest.params.adUnitType.toUpperCase(), publisherId: bidRequest.params.publisherId, - userIdAsEids: bidRequest.userIdAsEids + userIdAsEids: bidRequest.userIdAsEids, + supplyChain: bidRequest.schain, + custom1: bidRequest.params.custom1, + custom2: bidRequest.params.custom2, + custom3: bidRequest.params.custom3, + custom4: bidRequest.params.custom4, + custom5: bidRequest.params.custom5 } } } diff --git a/modules/limelightDigitalBidAdapter.md b/modules/limelightDigitalBidAdapter.md index a4abb6f1411..2c773859a7f 100644 --- a/modules/limelightDigitalBidAdapter.md +++ b/modules/limelightDigitalBidAdapter.md @@ -24,7 +24,12 @@ var adUnits = [{ params: { host: 'exchange-9qao.ortb.net', adUnitId: 0, - adUnitType: 'banner' + adUnitType: 'banner', + custom1: 'custom1', + custom2: 'custom2', + custom3: 'custom3', + custom4: 'custom4', + custom5: 'custom5' } }] }]; @@ -40,7 +45,12 @@ var videoAdUnit = [{ params: { host: 'exchange-9qao.ortb.net', adUnitId: 0, - adUnitType: 'video' + adUnitType: 'video', + custom1: 'custom1', + custom2: 'custom2', + custom3: 'custom3', + custom4: 'custom4', + custom5: 'custom5' } }] }]; diff --git a/modules/liveIntentAnalyticsAdapter.js b/modules/liveIntentAnalyticsAdapter.js new file mode 100644 index 00000000000..ffe4f8f58b0 --- /dev/null +++ b/modules/liveIntentAnalyticsAdapter.js @@ -0,0 +1,148 @@ +import {ajax} from '../src/ajax.js'; +import { generateUUID, logInfo, logWarn } from '../src/utils.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager.js'; +import { auctionManager } from '../src/auctionManager.js'; +import { getRefererInfo } from '../src/refererDetection.js'; + +const ANALYTICS_TYPE = 'endpoint'; +const URL = 'https://wba.liadm.com/analytic-events'; +const GVL_ID = 148; +const ADAPTER_CODE = 'liveintent'; +const DEFAULT_SAMPLING = 0.1; +const DEFAULT_BID_WON_TIMEOUT = 2000; +const { EVENTS: { AUCTION_END } } = CONSTANTS; +let initOptions = {}; +let isSampled; +let bidWonTimeout; + +function handleAuctionEnd(args) { + setTimeout(() => { + const auction = auctionManager.index.getAuction(args.auctionId); + const winningBids = (auction) ? auction.getWinningBids() : []; + const data = createAnalyticsEvent(args, winningBids); + sendAnalyticsEvent(data); + }, bidWonTimeout); +} + +function getAnalyticsEventBids(bidsReceived) { + return bidsReceived.map(bid => { + return { + adUnitCode: bid.adUnitCode, + timeToRespond: bid.timeToRespond, + cpm: bid.cpm, + currency: bid.currency, + ttl: bid.ttl, + bidder: bid.bidder + }; + }); +} + +function getBannerSizes(banner) { + if (banner && banner.sizes) { + return banner.sizes.map(size => { + const [width, height] = size; + return {w: width, h: height}; + }); + } else return []; +} + +function getUniqueBy(arr, key) { + return [...new Map(arr.map(item => [item[key], item])).values()] +} + +function createAnalyticsEvent(args, winningBids) { + let payload = { + instanceId: generateUUID(), + url: getRefererInfo().page, + bidsReceived: getAnalyticsEventBids(args.bidsReceived), + auctionStart: args.timestamp, + auctionEnd: args.auctionEnd, + adUnits: [], + userIds: [], + bidders: [] + } + let allUserIds = []; + + if (args.adUnits) { + args.adUnits.forEach(unit => { + if (unit.mediaTypes && unit.mediaTypes.banner) { + payload['adUnits'].push({ + code: unit.code, + mediaType: 'banner', + sizes: getBannerSizes(unit.mediaTypes.banner), + ortb2Imp: unit.ortb2Imp + }); + } + if (unit.bids) { + let userIds = unit.bids.flatMap(getAnalyticsEventUserIds); + allUserIds.push(...userIds); + let bidders = unit.bids.map(({bidder, params}) => { + return { bidder, params } + }); + + payload['bidders'].push(...bidders); + } + }) + let uniqueUserIds = getUniqueBy(allUserIds, 'source'); + payload['userIds'] = uniqueUserIds; + } + payload['winningBids'] = getAnalyticsEventBids(winningBids); + payload['auctionId'] = args.auctionId; + return payload; +} + +function getAnalyticsEventUserIds(bid) { + if (bid && bid.userIdAsEids) { + return bid.userIdAsEids.map(({source, uids, ext}) => { + let analyticsEventUserId = {source, uids, ext}; + return ignoreUndefined(analyticsEventUserId) + }); + } else { return []; } +} + +function sendAnalyticsEvent(data) { + ajax(URL, { + success: function () { + logInfo('LiveIntent Prebid Analytics: send data success'); + }, + error: function (e) { + logWarn('LiveIntent Prebid Analytics: send data error' + e); + } + }, JSON.stringify(data), { + contentType: 'application/json', + method: 'POST' + }) +} + +function ignoreUndefined(data) { + const filteredData = Object.entries(data).filter(([key, value]) => value) + return Object.fromEntries(filteredData) +} + +let liAnalytics = Object.assign(adapter({URL, ANALYTICS_TYPE}), { + track({ eventType, args }) { + if (eventType == AUCTION_END && args && isSampled) { handleAuctionEnd(args); } + } +}); + +// save the base class function +liAnalytics.originEnableAnalytics = liAnalytics.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +liAnalytics.enableAnalytics = function (config) { + initOptions = config.options; + const sampling = (initOptions && initOptions.sampling) ?? DEFAULT_SAMPLING; + isSampled = Math.random() < parseFloat(sampling); + bidWonTimeout = (initOptions && initOptions.bidWonTimeout) ?? DEFAULT_BID_WON_TIMEOUT; + liAnalytics.originEnableAnalytics(config); // call the base class function +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: liAnalytics, + code: ADAPTER_CODE, + gvlid: GVL_ID +}); + +export default liAnalytics; diff --git a/modules/liveIntentAnalyticsAdapter.md b/modules/liveIntentAnalyticsAdapter.md new file mode 100644 index 00000000000..15f51006134 --- /dev/null +++ b/modules/liveIntentAnalyticsAdapter.md @@ -0,0 +1,22 @@ +# Overview +Module Name: LiveIntent Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: product@liveintent.com + +# Description + +Analytics adapter for [LiveIntent](https://www.liveintent.com/). Contact product@liveintent.com for information. + +# Test Parameters + +``` +{ + provider: 'liveintent', + options: { + bidWonTimeout: 2000, + sampling: 0.5 // the tracked event percentage, a number between 0 to 1 + } +} +``` diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 68cbb3b2412..8fab266ecce 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -7,13 +7,17 @@ import { triggerPixel, logError } from '../src/utils.js'; import { ajaxBuilder } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; -import { LiveConnect } from 'live-connect-js/esm/initializer.js'; +import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/validate-imports import { gdprDataHandler, uspDataHandler } from '../src/adapterManager.js'; -import { getStorageManager } from '../src/storageManager.js'; -import { MinimalLiveConnect } from 'live-connect-js/esm/minimal-live-connect.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +const DEFAULT_AJAX_TIMEOUT = 5000 +const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; -export const storage = getStorageManager({gvlid: null, moduleName: MODULE_NAME}); +const LI_PROVIDER_DOMAIN = 'liveintent.com'; +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); +const defaultRequestedAttributes = {'nonId': true} const calls = { ajaxGet: (url, onSuccess, onError, timeout) => { ajaxBuilder(timeout)( @@ -39,14 +43,22 @@ let liveConnect = null; * This function is used in tests */ export function reset() { - if (window && window.liQ) { - window.liQ = []; + if (window && window.liQ_instances) { + window.liQ_instances.forEach(i => i.eventBus.off(EVENTS_TOPIC, setEventFiredFlag)) + window.liQ_instances = []; } liveIntentIdSubmodule.setModuleMode(null) eventFired = false; liveConnect = null; } +/** + * This function is also used in tests + */ +export function setEventFiredFlag() { + eventFired = true; +} + function parseLiveIntentCollectorConfig(collectConfig) { const config = {}; collectConfig = collectConfig || {} @@ -54,9 +66,27 @@ function parseLiveIntentCollectorConfig(collectConfig) { collectConfig.fpiStorageStrategy && (config.storageStrategy = collectConfig.fpiStorageStrategy); collectConfig.fpiExpirationDays && (config.expirationDays = collectConfig.fpiExpirationDays); collectConfig.collectorUrl && (config.collectorUrl = collectConfig.collectorUrl); + config.ajaxTimeout = collectConfig.ajaxTimeout || DEFAULT_AJAX_TIMEOUT; return config; } +/** + * Create requestedAttributes array to pass to liveconnect + * @function + * @param {Object} overrides - object with boolean values that will override defaults { 'foo': true, 'bar': false } + * @returns {Array} + */ +function parseRequestedAttributes(overrides) { + function createParameterArray(config) { + return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); + } + if (typeof overrides === 'object') { + return createParameterArray({...defaultRequestedAttributes, ...overrides}) + } else { + return createParameterArray(defaultRequestedAttributes); + } +} + function initializeLiveConnect(configParams) { configParams = configParams || {}; if (liveConnect) { @@ -65,23 +95,28 @@ function initializeLiveConnect(configParams) { const publisherId = configParams.publisherId || 'any'; const identityResolutionConfig = { - source: 'prebid', - publisherId: publisherId + publisherId: publisherId, + requestedAttributes: parseRequestedAttributes(configParams.requestedAttributesOverrides) }; if (configParams.url) { identityResolutionConfig.url = configParams.url } - if (configParams.partner) { - identityResolutionConfig.source = configParams.partner - } - if (configParams.ajaxTimeout) { - identityResolutionConfig.ajaxTimeout = configParams.ajaxTimeout; - } + + identityResolutionConfig.ajaxTimeout = configParams.ajaxTimeout || DEFAULT_AJAX_TIMEOUT; const liveConnectConfig = parseLiveIntentCollectorConfig(configParams.liCollectConfig); + + if (!liveConnectConfig.appId && configParams.distributorId) { + liveConnectConfig.distributorId = configParams.distributorId; + identityResolutionConfig.source = configParams.distributorId; + } else { + identityResolutionConfig.source = configParams.partner || 'prebid' + } + liveConnectConfig.wrapperName = 'prebid'; liveConnectConfig.identityResolutionConfig = identityResolutionConfig; liveConnectConfig.identifiersToResolve = configParams.identifiersToResolve || []; + liveConnectConfig.fireEventDelay = configParams.fireEventDelay; const usPrivacyString = uspDataHandler.getConsentData(); if (usPrivacyString) { liveConnectConfig.usPrivacyString = usPrivacyString; @@ -103,8 +138,14 @@ function initializeLiveConnect(configParams) { function tryFireEvent() { if (!eventFired && liveConnect) { - liveConnect.fire(); - eventFired = true; + const eventDelay = liveConnect.config.fireEventDelay || 500 + setTimeout(() => { + const instances = window.liQ_instances + instances.forEach(i => i.eventBus.once(EVENTS_TOPIC, setEventFiredFlag)) + if (!eventFired && liveConnect) { + liveConnect.fire(); + } + }, eventDelay) } } @@ -121,7 +162,7 @@ export const liveIntentIdSubmodule = { this.moduleMode = mode }, getInitializer() { - return this.moduleMode === 'minimal' ? MinimalLiveConnect : LiveConnect + return (liveConnectConfig, storage, calls) => LiveConnect(liveConnectConfig, storage, calls, this.moduleMode) }, /** @@ -136,9 +177,40 @@ export const liveIntentIdSubmodule = { decode(value, config) { const configParams = (config && config.params) || {}; function composeIdObject(value) { - const base = { 'lipbid': value.unifiedId }; - delete value.unifiedId; - return { 'lipb': { ...base, ...value } }; + const result = {}; + + // old versions stored lipbid in unifiedId. Ensure that we can still read the data. + const lipbid = value.nonId || value.unifiedId + if (lipbid) { + value.lipbid = lipbid + delete value.unifiedId + result.lipb = value + } + + // Lift usage of uid2 by exposing uid2 if we were asked to resolve it. + // As adapters are applied in lexicographical order, we will always + // be overwritten by the 'proper' uid2 module if it is present. + if (value.uid2) { + result.uid2 = { 'id': value.uid2, ext: { provider: LI_PROVIDER_DOMAIN } } + } + + if (value.bidswitch) { + result.bidswitch = { 'id': value.bidswitch, ext: { provider: LI_PROVIDER_DOMAIN } } + } + + if (value.medianet) { + result.medianet = { 'id': value.medianet, ext: { provider: LI_PROVIDER_DOMAIN } } + } + + if (value.magnite) { + result.magnite = { 'id': value.magnite, ext: { provider: LI_PROVIDER_DOMAIN } } + } + + if (value.index) { + result.index = { 'id': value.index, ext: { provider: LI_PROVIDER_DOMAIN } } + } + + return result } if (!liveConnect) { @@ -146,7 +218,7 @@ export const liveIntentIdSubmodule = { } tryFireEvent(); - return (value && typeof value['unifiedId'] === 'string') ? composeIdObject(value) : undefined; + return composeIdObject(value); }, /** @@ -175,6 +247,70 @@ export const liveIntentIdSubmodule = { } return { callback: result }; + }, + eids: { + 'lipb': { + getValue: function(data) { + return data.lipbid; + }, + source: 'liveintent.com', + atype: 3, + getEidExt: function(data) { + if (Array.isArray(data.segments) && data.segments.length) { + return { + segments: data.segments + }; + } + } + }, + 'bidswitch': { + source: 'bidswitch.net', + atype: 3, + getValue: function(data) { + return data.id; + }, + getUidExt: function(data) { + if (data.ext) { + return data.ext; + } + } + }, + 'medianet': { + source: 'media.net', + atype: 3, + getValue: function(data) { + return data.id; + }, + getUidExt: function(data) { + if (data.ext) { + return data.ext; + } + } + }, + 'magnite': { + source: 'rubiconproject.com', + atype: 3, + getValue: function(data) { + return data.id; + }, + getUidExt: function(data) { + if (data.ext) { + return data.ext; + } + } + }, + 'index': { + source: 'liveintent.indexexchange.com', + atype: 3, + getValue: function(data) { + return data.id; + }, + getUidExt: function(data) { + if (data.ext) { + return data.ext; + } + } + } } }; diff --git a/modules/livewrappedAnalyticsAdapter.js b/modules/livewrappedAnalyticsAdapter.js index 1116fd99ba0..f3ee81cae7a 100644 --- a/modules/livewrappedAnalyticsAdapter.js +++ b/modules/livewrappedAnalyticsAdapter.js @@ -1,6 +1,6 @@ import { timestamp, logInfo, getWindowTop } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import { getGlobal } from '../src/prebidGlobal.js'; @@ -67,10 +67,10 @@ let livewrappedAnalyticsAdapter = Object.assign(adapter({EMPTYURL, ANALYTICSTYPE auc: bidRequest.auc, buc: bidRequest.buc, lw: bidRequest.lw - } + }; logInfo(bidRequest); - }) + }); logInfo(livewrappedAnalyticsAdapter.requestEvents); break; case CONSTANTS.EVENTS.BID_RESPONSE: @@ -168,7 +168,7 @@ livewrappedAnalyticsAdapter.sendEvents = function() { requests: sentRequests.sentRequests, responses: getResponses(sentRequests.gdpr, sentRequests.auctionIds), wins: getWins(sentRequests.gdpr, sentRequests.auctionIds), - timeouts: getTimeouts(sentRequests.auctionIds), + timeouts: getTimeouts(sentRequests.gdpr, sentRequests.auctionIds), bidAdUnits: getbidAdUnits(), rf: getAdRenderFailed(sentRequests.auctionIds), rcv: getAdblockerRecovered() @@ -183,7 +183,7 @@ livewrappedAnalyticsAdapter.sendEvents = function() { } ajax(initOptions.endpoint || URL, undefined, JSON.stringify(events), {method: 'POST'}); -} +}; function getAdblockerRecovered() { try { @@ -237,27 +237,9 @@ function getResponses(gdpr, auctionIds) { if (bid.readyToSend && !(bid.sendStatus & RESPONSESENT) && !bid.timeout) { bid.sendStatus |= RESPONSESENT; - responses.push({ - timeStamp: auction.timeStamp, - adUnit: bid.adUnit, - adUnitId: bid.adUnitId, - bidder: bid.bidder, - width: bid.width, - height: bid.height, - cpm: bid.cpm, - orgCpm: bid.originalCpm, - ttr: bid.ttr, - IsBid: bid.isBid, - mediaType: bid.mediaType, - gdpr: gdprPos, - floor: bid.lwFloor ? bid.lwFloor : (bid.floorData ? bid.floorData.floorValue : undefined), - floorCur: bid.floorData ? bid.floorData.floorCurrency : undefined, - auctionId: auctionIdPos, - auc: bid.auc, - buc: bid.buc, - lw: bid.lw, - meta: bid.meta - }); + let response = getResponseObject(auction, bid, gdprPos, auctionIdPos); + + responses.push(response); } }); }); @@ -337,27 +319,45 @@ function getAuctionIdPos(auctionIds, auctionId) { return auctionIdPos; } -function getTimeouts(auctionIds) { +function getResponseObject(auction, bid, gdprPos, auctionIdPos) { + return { + timeStamp: auction.timeStamp, + adUnit: bid.adUnit, + adUnitId: bid.adUnitId, + bidder: bid.bidder, + width: bid.width, + height: bid.height, + cpm: bid.cpm, + orgCpm: bid.originalCpm, + ttr: bid.ttr, + IsBid: bid.isBid, + mediaType: bid.mediaType, + gdpr: gdprPos, + floor: bid.lwFloor ? bid.lwFloor : (bid.floorData ? bid.floorData.floorValue : undefined), + floorCur: bid.floorData ? bid.floorData.floorCurrency : undefined, + auctionId: auctionIdPos, + auc: bid.auc, + buc: bid.buc, + lw: bid.lw, + meta: bid.meta + }; +} + +function getTimeouts(gdpr, auctionIds) { var timeouts = []; Object.keys(cache.auctions).forEach(auctionId => { let auctionIdPos = getAuctionIdPos(auctionIds, auctionId); Object.keys(cache.auctions[auctionId].bids).forEach(bidId => { let auction = cache.auctions[auctionId]; + let gdprPos = getGdprPos(gdpr, auction); let bid = auction.bids[bidId]; if (!(bid.sendStatus & TIMEOUTSENT) && bid.timeout) { bid.sendStatus |= TIMEOUTSENT; - timeouts.push({ - bidder: bid.bidder, - adUnit: bid.adUnit, - adUnitId: bid.adUnitId, - timeStamp: auction.timeStamp, - auctionId: auctionIdPos, - auc: bid.auc, - buc: bid.buc, - lw: bid.lw - }); + let timeout = getResponseObject(auction, bid, gdprPos, auctionIdPos); + + timeouts.push(timeout); } }); }); diff --git a/modules/livewrappedBidAdapter.js b/modules/livewrappedBidAdapter.js index 32e09e4b28e..82affe40e03 100644 --- a/modules/livewrappedBidAdapter.js +++ b/modules/livewrappedBidAdapter.js @@ -1,9 +1,10 @@ -import {deepAccess, getWindowTop, isSafariBrowser, mergeDeep} from '../src/utils.js'; +import {deepAccess, getWindowTop, isSafariBrowser, mergeDeep, isFn, isPlainObject} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {find} from '../src/polyfill.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {getStorageManager} from '../src/storageManager.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'livewrapped'; export const storage = getStorageManager({bidderCode: BIDDER_CODE}); @@ -46,6 +47,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + const userId = find(bidRequests, hasUserId); const pubcid = find(bidRequests, hasPubcid); const publisherId = find(bidRequests, hasPublisherId); @@ -59,18 +63,21 @@ export const spec = { const bundle = find(bidRequests, hasBundleParam); const tid = find(bidRequests, hasTidParam); const schain = bidRequests[0].schain; - let ortb2 = config.getConfig('ortb2'); + let ortb2 = bidderRequest.ortb2; const eids = handleEids(bidRequests); bidUrl = bidUrl ? bidUrl.params.bidUrl : URL; url = url ? url.params.url : (getAppDomain() || getTopWindowLocation(bidderRequest)); test = test ? test.params.test : undefined; - var adRequests = bidRequests.map(bidToAdRequest); + const currency = config.getConfig('currency.adServerCurrency') || 'USD'; + var adRequests = bidRequests.map(b => bidToAdRequest(b, currency)); + const adRequestsContainFloors = adRequests.some(r => r.flr !== undefined); if (eids) { - ortb2 = mergeDeep(ortb2 || {}, eids); + ortb2 = mergeDeep(mergeDeep({}, ortb2 || {}), eids); } const payload = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: auctionId ? auctionId.auctionId : undefined, publisherId: publisherId ? publisherId.params.publisherId : undefined, userId: userId ? userId.params.userId : (pubcid ? pubcid.crumbs.pubcid : undefined), @@ -92,7 +99,8 @@ export const spec = { rcv: getAdblockerRecovered(), adRequests: [...adRequests], rtbData: ortb2, - schain: schain + schain: schain, + flrCur: adRequestsContainFloors ? currency : undefined }; if (config.getConfig().debug) { @@ -123,7 +131,6 @@ export const spec = { serverResponse.body.ads.forEach(function(ad) { var bidResponse = { requestId: ad.bidId, - bidderCode: BIDDER_CODE, cpm: ad.cpmBid, width: ad.width, height: ad.height, @@ -219,13 +226,14 @@ function hasPubcid(bid) { return !!bid.crumbs && !!bid.crumbs.pubcid; } -function bidToAdRequest(bid) { +function bidToAdRequest(bid, currency) { var adRequest = { adUnitId: bid.params.adUnitId, callerAdUnitId: bid.params.adUnitName || bid.adUnitCode || bid.placementCode, bidId: bid.bidId, - transactionId: bid.transactionId, + transactionId: bid.ortb2Imp?.ext?.tid, formats: getSizes(bid).map(sizeToFormat), + flr: getBidFloor(bid, currency), options: bid.params.options }; @@ -260,6 +268,22 @@ function sizeToFormat(size) { } } +function getBidFloor(bid, currency) { + if (!isFn(bid.getFloor)) { + return undefined; + } + + const floor = bid.getFloor({ + currency: currency, + mediaType: '*', + size: '*' + }); + + return isPlainObject(floor) && !isNaN(floor.floor) && floor.currency == currency + ? floor.floor + : undefined; +} + function getAdblockerRecovered() { try { return getWindowTop().I12C && getWindowTop().I12C.Morph === 1; @@ -276,8 +300,7 @@ function handleEids(bidRequests) { } function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return config.getConfig('pageUrl') || url; + return bidderRequest?.refererInfo?.page; } function getAppBundle() { @@ -299,21 +322,13 @@ function getDeviceIfa() { } function getDeviceWidth() { - let device = config.getConfig('device'); - if (typeof device === 'object' && device.width) { - return device.width; - } - - return window.innerWidth; + const device = config.getConfig('device') || {}; + return device.w || window.innerWidth; } function getDeviceHeight() { - let device = config.getConfig('device'); - if (typeof device === 'object' && device.height) { - return device.height; - } - - return window.innerHeight; + const device = config.getConfig('device') || {}; + return device.h || window.innerHeight; } function getCoppa() { diff --git a/modules/liveyieldAnalyticsAdapter.js b/modules/liveyieldAnalyticsAdapter.js deleted file mode 100644 index 411b76a5149..00000000000 --- a/modules/liveyieldAnalyticsAdapter.js +++ /dev/null @@ -1,454 +0,0 @@ -import { logError } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; -import adapterManager from '../src/adapterManager.js'; -import CONSTANTS from '../src/constants.json'; - -const { - EVENTS: { BID_REQUESTED, BID_TIMEOUT, BID_RESPONSE, BID_WON } -} = CONSTANTS; - -const prebidVersion = '$prebid.version$'; - -const adapterConfig = { - /** Name of the `rta` function, override only when instructed. */ - rtaFunctionName: 'rta', - - /** This is optional but highly recommended. The value returned by the - * function will be used as ad impression ad unit attribute value. - * - * As such if you have placement (10293845) or ad unit codes - * (div-gpt-ad-124984-0) but you want these to be translated to meaningful - * values like 'SIDEBAR-AD-01-MOBILE' then this function shall express this - * mapping. - */ - getAdUnitName: function(placementOrAdUnitCode) { - return placementOrAdUnitCode; - }, - - /** - * Function used to extract placement/adUnitCode (depending on prebid - * version). - * - * The extracted value will be passed to the `getAdUnitName()` for mapping into - * human friendly value. - */ - getPlacementOrAdUnitCode: function(bid, version) { - return version[0] === '0' ? bid.placementCode : bid.adUnitCode; - }, - - /** - * Optional reference to Google Publisher Tag (gpt) - */ - googlePublisherTag: false, - - /** - * Do not override unless instructed. Useful for testing. Allows to redefined - * the event that triggers the ad impression event. - */ - wireGooglePublisherTag: function(gpt, cb) { - gpt.pubads().addEventListener('slotRenderEnded', function(event) { - cb(event.slot); - }); - }, - - /** - * Map which keeps BID_WON events. Keyed by adId property. - */ - prebidWinnersCache: {}, - - /** - * Map which keeps all BID_RESPONSE events. Keyed by adId property. - */ - prebidBidResponsesCache: {}, - - /** - * Decides if the GPT slot contains prebid ad impression or not. - * - * When BID_WON event is emitted adid is added to prebidWinnersCache, - * then we check if prebidWinnersCache contains slot.hb_adid. - * - * This function is optional and used only when googlePublisherTag is provided. - * - * Default implementation uses slot's `hb_adid` targeting parameter. - * - * @param slot the gpt slot - */ - isPrebidAdImpression: function(slot) { - const hbAdIdTargeting = slot.getTargeting('hb_adid'); - if (hbAdIdTargeting.length > 0) { - const hbAdId = hbAdIdTargeting[0]; - return typeof this.prebidWinnersCache[hbAdId] !== 'undefined'; - } - return false; - }, - - /** - * If isPrebidAdImpression decides that slot contain prebid ad impression, - * this function should return prebids highest ad impression partner for that - * slot. - * - * Default implementation uses slot's `hb_adid` targeting value to find - * highest bid response and when present then returns `bidder`. - * - * @param instanceConfig merged analytics adapter instance configuration - * @param slot the gpt slot for which the name of the highest bidder shall be - * returned - * @param version the version of the prebid.js library - */ - getHighestPrebidAdImpressionPartner: function(instanceConfig, slot, version) { - const bid = getHighestPrebidBidResponseBySlotTargeting( - instanceConfig, - slot, - version - ); - - // this is bid response event has `bidder` while bid won has bidderCode property - return bid ? bid.bidderCode || bid.bidder : null; - }, - - /** - * If isPrebidAdImpression decides that slot contain prebid ad impression, - * this function should return prebids highest ad impression value for that - * slot. - * - * Default implementation uses slot's `hb_adid` targeting value to find - * highest bid response and when present then returns `cpm`. - * - * @param instanceConfig merged analytics adapter instance configuration - * @param slot the gpt slot for which the highest ad impression value shall be - * returned - * @param version the version of the prebid.js library - */ - getHighestPrebidAdImpressionValue: function(instanceConfig, slot, version) { - const bid = getHighestPrebidBidResponseBySlotTargeting( - instanceConfig, - slot, - version - ); - - return bid ? bid.cpm : null; - }, - - /** - * This function should return proper ad unit name for slot given as a - * parameter. Unit names returned by this function should be meaningful, for - * example 'FOO_728x90_TOP'. The values returned shall be inline with - * `getAdUnitName`. - * - * Required when googlePublisherTag is defined. - * - * @param slot the gpt slot to translate into friendly name - * @param version the version of the prebid.js library - */ - getAdUnitNameByGooglePublisherTagSlot: (slot, version) => { - throw 'Required when googlePublisherTag is defined.'; - }, - - /** - * Function used to prepare and return parameters provided to rta. - * More information will be in docs given by LiveYield team. - * - * When googlePublisherTag is not provided, second parameter(slot) will always - * equal null. - * - * @param resolution the original ad impression details - * @param slot gpt slot, will be empty in pure Prebid.js-case (when - * googlePublisherTag is not provided) - * @param hbPartner the name of the highest bidding partner - * @param hbValue the value of the highest bid - * @param version version of the prebid.js library - */ - postProcessResolution: (resolution, slot, hbPartner, hbValue, version) => { - return resolution; - } -}; - -const cpmToMicroUSD = v => (isNaN(v) ? 0 : Math.round(v * 1000)); - -const getHighestPrebidBidResponseBySlotTargeting = function( - instanceConfig, - slot, - version -) { - const hbAdIdTargeting = slot.getTargeting('hb_adid'); - if (hbAdIdTargeting.length > 0) { - const hbAdId = hbAdIdTargeting[0]; - return ( - instanceConfig.prebidWinnersCache[hbAdId] || - instanceConfig.prebidBidResponsesCache[hbAdId] - ); - } - return null; -}; - -const liveyield = Object.assign(adapter({ analyticsType: 'bundle' }), { - track({ eventType, args }) { - switch (eventType) { - case BID_REQUESTED: - args.bids.forEach(function(b) { - try { - window[liveyield.instanceConfig.rtaFunctionName]( - 'bidRequested', - liveyield.instanceConfig.getAdUnitName( - liveyield.instanceConfig.getPlacementOrAdUnitCode( - b, - prebidVersion - ) - ), - args.bidderCode - ); - } catch (e) { - logError(e); - } - }); - break; - case BID_RESPONSE: - liveyield.instanceConfig.prebidBidResponsesCache[args.adId] = args; - var cpm = args.statusMessage === 'Bid available' ? args.cpm : null; - try { - window[liveyield.instanceConfig.rtaFunctionName]( - 'addBid', - liveyield.instanceConfig.getAdUnitName( - liveyield.instanceConfig.getPlacementOrAdUnitCode( - args, - prebidVersion - ) - ), - args.bidder || 'unknown', - cpmToMicroUSD(cpm), - typeof args.bidder === 'undefined', - args.statusMessage !== 'Bid available' - ); - } catch (e) { - logError(e); - } - break; - case BID_TIMEOUT: - window[liveyield.instanceConfig.rtaFunctionName]( - 'biddersTimeout', - args - ); - break; - case BID_WON: - liveyield.instanceConfig.prebidWinnersCache[args.adId] = args; - if (liveyield.instanceConfig.googlePublisherTag) { - break; - } - - try { - const ad = liveyield.instanceConfig.getAdUnitName( - liveyield.instanceConfig.getPlacementOrAdUnitCode( - args, - prebidVersion - ) - ); - if (!ad) { - logError( - 'Cannot find ad by unit name: ' + - liveyield.instanceConfig.getAdUnitName( - liveyield.instanceConfig.getPlacementOrAdUnitCode( - args, - prebidVersion - ) - ) - ); - break; - } - if (!args.bidderCode || !args.cpm) { - logError('Bidder code or cpm is not valid'); - break; - } - const resolution = { targetings: [] }; - resolution.prebidWon = true; - resolution.prebidPartner = args.bidderCode; - resolution.prebidValue = cpmToMicroUSD(parseFloat(args.cpm)); - const resolutionToUse = liveyield.instanceConfig.postProcessResolution( - resolution, - null, - resolution.prebidPartner, - resolution.prebidValue, - prebidVersion - ); - window[liveyield.instanceConfig.rtaFunctionName]( - 'resolveSlot', - liveyield.instanceConfig.getAdUnitName( - liveyield.instanceConfig.getPlacementOrAdUnitCode( - args, - prebidVersion - ) - ), - resolutionToUse - ); - } catch (e) { - logError(e); - } - break; - } - } -}); - -liveyield.originEnableAnalytics = liveyield.enableAnalytics; - -/** - * Minimal valid config: - * - * ``` - * { - * provider: 'liveyield', - * options: { - * // will be provided by the LiveYield team - * customerId: 'UUID', - * // will be provided by the LiveYield team, - * customerName: 'Customer Name', - * // do NOT use window.location.host, use constant value - * customerSite: 'Fixed Site Name', - * // this is used to be inline with GA 'sessionizer' which closes the session on midnight (EST-time). - * sessionTimezoneOffset: '-300' - * } - * } - * ``` - */ -liveyield.enableAnalytics = function(config) { - if (!config || !config.provider || config.provider !== 'liveyield') { - logError('expected config.provider to equal liveyield'); - return; - } - if (!config.options) { - logError('options must be defined'); - return; - } - if (!config.options.customerId) { - logError('options.customerId is required'); - return; - } - if (!config.options.customerName) { - logError('options.customerName is required'); - return; - } - if (!config.options.customerSite) { - logError('options.customerSite is required'); - return; - } - if (!config.options.sessionTimezoneOffset) { - logError('options.sessionTimezoneOffset is required'); - return; - } - liveyield.instanceConfig = Object.assign( - { prebidWinnersCache: {}, prebidBidResponsesCache: {} }, - adapterConfig, - config.options - ); - - if (typeof window[liveyield.instanceConfig.rtaFunctionName] !== 'function') { - logError( - `Function ${liveyield.instanceConfig.rtaFunctionName} is not defined.` + - `Make sure that LiveYield snippet in included before the Prebid Analytics configuration.` - ); - return; - } - if (liveyield.instanceConfig.googlePublisherTag) { - liveyield.instanceConfig.wireGooglePublisherTag( - liveyield.instanceConfig.googlePublisherTag, - onSlotRenderEnded(liveyield.instanceConfig) - ); - } - - const additionalParams = { - customerTimezone: config.options.customerTimezone, - contentId: config.options.contentId, - contentPart: config.options.contentPart, - contentAuthor: config.options.contentAuthor, - contentTitle: config.options.contentTitle, - contentCategory: config.options.contentCategory, - contentLayout: config.options.contentLayout, - contentVariants: config.options.contentVariants, - contentTimezone: config.options.contentTimezone, - cstringDim1: config.options.cstringDim1, - cstringDim2: config.options.cstringDim2, - cintDim1: config.options.cintDim1, - cintDim2: config.options.cintDim2, - cintArrayDim1: config.options.cintArrayDim1, - cintArrayDim2: config.options.cintArrayDim2, - cuniqueStringMet1: config.options.cuniqueStringMet1, - cuniqueStringMet2: config.options.cuniqueStringMet2, - cavgIntMet1: config.options.cavgIntMet1, - cavgIntMet2: config.options.cavgIntMet2, - csumIntMet1: config.options.csumIntMet1, - csumIntMet2: config.options.csumIntMet2 - }; - - Object.keys(additionalParams).forEach( - key => additionalParams[key] == null && delete additionalParams[key] - ); - - window[liveyield.instanceConfig.rtaFunctionName]( - 'create', - config.options.customerId, - config.options.customerName, - config.options.customerSite, - config.options.sessionTimezoneOffset, - additionalParams - ); - liveyield.originEnableAnalytics(config); -}; - -const onSlotRenderEnded = function(instanceConfig) { - const addDfpDetails = (resolution, slot) => { - const responseInformation = slot.getResponseInformation(); - if (responseInformation) { - resolution.dfpAdvertiserId = responseInformation.advertiserId; - resolution.dfpLineItemId = responseInformation.sourceAgnosticLineItemId; - resolution.dfpCreativeId = responseInformation.creativeId; - } - }; - - const addPrebidDetails = (resolution, slot) => { - if (instanceConfig.isPrebidAdImpression(slot)) { - resolution.prebidWon = true; - } - const highestPrebidAdImpPartner = instanceConfig.getHighestPrebidAdImpressionPartner( - instanceConfig, - slot, - prebidVersion - ); - const highestPrebidAdImpValue = instanceConfig.getHighestPrebidAdImpressionValue( - instanceConfig, - slot, - prebidVersion - ); - if (highestPrebidAdImpPartner) { - resolution.prebidPartner = highestPrebidAdImpPartner; - } - if (highestPrebidAdImpValue) { - resolution.prebidValue = cpmToMicroUSD( - parseFloat(highestPrebidAdImpValue) - ); - } - }; - return slot => { - const resolution = { targetings: [] }; - - addDfpDetails(resolution, slot); - addPrebidDetails(resolution, slot); - - const resolutionToUse = instanceConfig.postProcessResolution( - resolution, - slot, - resolution.highestPrebidAdImpPartner, - resolution.highestPrebidAdImpValue, - prebidVersion - ); - window[instanceConfig.rtaFunctionName]( - 'resolveSlot', - instanceConfig.getAdUnitNameByGooglePublisherTagSlot(slot, prebidVersion), - resolutionToUse - ); - }; -}; - -adapterManager.registerAnalyticsAdapter({ - adapter: liveyield, - code: 'liveyield' -}); - -export default liveyield; diff --git a/modules/liveyieldAnalyticsAdapter.md b/modules/liveyieldAnalyticsAdapter.md deleted file mode 100644 index a5e602361a1..00000000000 --- a/modules/liveyieldAnalyticsAdapter.md +++ /dev/null @@ -1,45 +0,0 @@ -# Overview - -Module Name: LiveYield Analytics Adapter - -Module Type: Analytics Adapter - -Maintainer: liveyield@pubocean.com - -# Description - -To install the LiveYield Tracker following snippet shall be added at the top of -the page. - -``` -(function(i,s,o,g,r,a,m,z){i['RTAAnalyticsObject']=r;i[r]=i[r]||function(){ -z=Array.prototype.slice.call(arguments);z.unshift(+new Date()); -(i[r].q=i[r].q||[]).push(z)},i[r].t=1,i[r].l=1*new Date();a=s.createElement(o), -m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) -})(window,document,'script','https://rta.pubocean.com/lib/pubocean-tracker.min.js','rta'); -``` - -# Test Parameters - -The LiveYield team will provide you configurations for each of your sites, it -will be similar to: - -``` -{ - provider: 'liveyield', - options: { - // will be provided by the LiveYield team - customerId: 'UUID', - // will be provided by the LiveYield team, - customerName: 'Customer Name', - // do NOT use window.location.host, use constant value - customerSite: 'Fixed Site Name', - // this is used to be inline with GA 'sessionizer' which closes the session on midnight (EST-time). - sessionTimezoneOffset: '-300' - } -} -``` - -Additional documentation and support will be provided by the LiveYield team as -part of the onboarding process. - diff --git a/modules/lkqdBidAdapter.js b/modules/lkqdBidAdapter.js index 275ab38915d..1dbe89f5a49 100644 --- a/modules/lkqdBidAdapter.js +++ b/modules/lkqdBidAdapter.js @@ -36,9 +36,9 @@ export const spec = { const serverRequestObjects = []; const UTC_OFFSET = new Date().getTimezoneOffset(); const UA = navigator.userAgent; - const IP = navigator.ip ? navigator.ip : 'prebid.js'; const USP = BIDDER_REQUEST.uspConsent || null; - const REFERER = BIDDER_REQUEST.refererInfo ? new URL(BIDDER_REQUEST.refererInfo.referer).hostname : window.location.hostname; + // TODO: does the fallback make sense here? + const REFERER = BIDDER_REQUEST?.refererInfo?.domain || window.location.host; const BIDDER_GDPR = BIDDER_REQUEST.gdprConsent && BIDDER_REQUEST.gdprConsent.gdprApplies ? 1 : null; const BIDDER_GDPRS = BIDDER_REQUEST.gdprConsent && BIDDER_REQUEST.gdprConsent.consentString ? BIDDER_REQUEST.gdprConsent.consentString : null; @@ -60,8 +60,7 @@ export const spec = { ua: UA, geo: { utcoffset: UTC_OFFSET - }, - ip: IP + } }, user: { ext: {} @@ -75,7 +74,7 @@ export const spec = { us_privacy: USP } } - } + }; if (isSet(DNT)) { requestData.device.dnt = DNT; @@ -95,7 +94,7 @@ export const spec = { id: bid.params.aid, name: bid.params.appname, bundle: bid.params.bundleid - } + }; if (bid.params.contentId) { requestData.app.content = { diff --git a/modules/lockerdomeBidAdapter.js b/modules/lockerdomeBidAdapter.js index 66accb4e02a..5038eadce30 100644 --- a/modules/lockerdomeBidAdapter.js +++ b/modules/lockerdomeBidAdapter.js @@ -1,6 +1,6 @@ -import { getBidIdParameter } from '../src/utils.js'; import {BANNER} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getBidIdParameter} from '../src/utils.js'; export const spec = { code: 'lockerdome', @@ -21,12 +21,11 @@ export const spec = { }; }); - const bidderRequestCanonicalUrl = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.canonicalUrl) || ''; - const bidderRequestReferer = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || ''; const payload = { bidRequests: adUnitBidRequests, - url: encodeURIComponent(bidderRequestCanonicalUrl), - referrer: encodeURIComponent(bidderRequestReferer) + // TODO: are these the right refererInfo values? + url: encodeURIComponent(bidderRequest?.refererInfo?.canonicalUrl || ''), + referrer: encodeURIComponent(bidderRequest?.refererInfo?.topmostLocation || '') }; if (schain) { payload.schain = schain; diff --git a/modules/loganBidAdapter.js b/modules/loganBidAdapter.js index 75327453b2e..7aa82e3046c 100644 --- a/modules/loganBidAdapter.js +++ b/modules/loganBidAdapter.js @@ -2,6 +2,7 @@ import { isFn, deepAccess, getWindowTop } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'logan'; const AD_URL = 'https://USeast2.logan.ai/pbjs'; @@ -50,6 +51,9 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const winTop = getWindowTop(); const location = winTop.location; const placements = []; @@ -68,7 +72,7 @@ export const spec = { request.ccpa = bidderRequest.uspConsent; } if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent + request.gdpr = bidderRequest.gdprConsent; } } @@ -81,7 +85,7 @@ export const spec = { schain: bid.schain || {}, bidfloor: getBidFloor(bid) }; - const mediaType = bid.mediaTypes + const mediaType = bid.mediaTypes; if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { placement.sizes = mediaType[BANNER].sizes; diff --git a/modules/logicadBidAdapter.js b/modules/logicadBidAdapter.js index 2c919f9c157..07f9b893887 100644 --- a/modules/logicadBidAdapter.js +++ b/modules/logicadBidAdapter.js @@ -1,5 +1,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { deepAccess } from '../src/utils.js'; const BIDDER_CODE = 'logicad'; const ENDPOINT_URL = 'https://pb.ladsp.com/adrequest/prebid'; @@ -11,6 +13,9 @@ export const spec = { return !!(bid.params && bid.params.tid); }, buildRequests: function (bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + const requests = []; for (let i = 0, len = bidRequests.length; i < len; i++) { const request = { @@ -48,22 +53,36 @@ export const spec = { }; function newBidRequest(bid, bidderRequest) { - return { + const data = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bid.auctionId, bidderRequestId: bid.bidderRequestId, bids: [{ adUnitCode: bid.adUnitCode, bidId: bid.bidId, - transactionId: bid.transactionId, + transactionId: bid.ortb2Imp?.ext?.tid, sizes: bid.sizes, params: bid.params, mediaTypes: bid.mediaTypes }], prebidJsVersion: '$prebid.version$', - referrer: bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + referrer: bidderRequest.refererInfo.page, auctionStartTime: bidderRequest.auctionStart, eids: bid.userIdAsEids, }; + + const sua = deepAccess(bid, 'ortb2.device.sua'); + if (sua) { + data.sua = sua; + } + + const userData = deepAccess(bid, 'ortb2.user.data'); + if (userData) { + data.userData = userData; + } + + return data; } registerBidder(spec); diff --git a/modules/loglyliftBidAdapter.js b/modules/loglyliftBidAdapter.js index dd5f0af1cdf..7cd76bb719d 100644 --- a/modules/loglyliftBidAdapter.js +++ b/modules/loglyliftBidAdapter.js @@ -1,6 +1,7 @@ import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'loglylift'; const ENDPOINT_URL = 'https://bid.logly.co.jp/prebid/client/v1'; @@ -14,6 +15,9 @@ export const spec = { }, buildRequests: function (bidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + const requests = []; for (let i = 0, len = bidRequests.length; i < len; i++) { const request = { @@ -60,17 +64,18 @@ function newBidRequest(bid, bidderRequest) { const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD'; return { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bid.auctionId, bidderRequestId: bid.bidderRequestId, - transactionId: bid.transactionId, + transactionId: bid.ortb2Imp?.ext?.tid, adUnitCode: bid.adUnitCode, bidId: bid.bidId, mediaTypes: bid.mediaTypes, params: bid.params, prebidJsVersion: '$prebid.version$', url: window.location.href, - domain: config.getConfig('publisherDomain'), - referer: bidderRequest.refererInfo.referer, + domain: bidderRequest.refererInfo.domain, + referer: bidderRequest.refererInfo.page, auctionStartTime: bidderRequest.auctionStart, currency: currency, timeout: config.getConfig('bidderTimeout') diff --git a/modules/loopmeBidAdapter.md b/modules/loopmeBidAdapter.md deleted file mode 100644 index 1b195a118f2..00000000000 --- a/modules/loopmeBidAdapter.md +++ /dev/null @@ -1,48 +0,0 @@ -# Overview - -``` -Module Name: LoopMe Bid Adapter -Module Type: Bidder Adapter -Maintainer: support@loopme.com -``` - -# Description - -Connect to LoopMe's exchange for bids. - -# Test Parameters (Banner) -``` -var adUnits = [{ - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [{ - bidder: 'loopme', - params: { - ak: 'cc885e3acc' - } - }] -}]; -``` - -# Test Parameters (Video) -``` -var adUnits = [{ - code: 'video1', - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'outstream' - } - }, - bids: [{ - bidder: 'loopme', - params: { - ak: '223051e07f' - } - }] -}]; -``` diff --git a/modules/lotamePanoramaIdSystem.js b/modules/lotamePanoramaIdSystem.js index a03626d4a1f..808a67492b0 100644 --- a/modules/lotamePanoramaIdSystem.js +++ b/modules/lotamePanoramaIdSystem.js @@ -16,8 +16,9 @@ import { } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; import { uspDataHandler } from '../src/adapterManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const KEY_ID = 'panoramaId'; const KEY_EXPIRY = `${KEY_ID}_expiry`; @@ -28,8 +29,10 @@ const DAYS_TO_CACHE = 7; const DAY_MS = 60 * 60 * 24 * 1000; const MISSING_CORE_CONSENT = 111; const GVLID = 95; +const ID_HOST = 'id.crwdcntrl.net'; +const ID_HOST_COOKIELESS = 'c.ltmsphrcl.net'; -export const storage = getStorageManager({gvlid: GVLID, moduleName: MODULE_NAME}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); let cookieDomain; /** @@ -57,12 +60,14 @@ function setProfileId(profileId) { * Get the Lotame profile id by checking cookies first and then local storage */ function getProfileId() { + let profileId; if (storage.cookiesAreEnabled()) { - return storage.getCookie(KEY_PROFILE, undefined); + profileId = storage.getCookie(KEY_PROFILE, undefined); } - if (storage.hasLocalStorage()) { - return storage.getDataFromLocalStorage(KEY_PROFILE, undefined); + if (!profileId && storage.hasLocalStorage()) { + profileId = storage.getDataFromLocalStorage(KEY_PROFILE, undefined); } + return profileId; } /** @@ -78,10 +83,11 @@ function getFromStorage(key) { const storedValueExp = storage.getDataFromLocalStorage( `${key}_exp`, undefined ); - if (storedValueExp === '') { + + if (storedValueExp === '' || storedValueExp === null) { value = storage.getDataFromLocalStorage(key, undefined); } else if (storedValueExp) { - if ((new Date(storedValueExp)).getTime() - Date.now() > 0) { + if ((new Date(parseInt(storedValueExp, 10))).getTime() - Date.now() > 0) { value = storage.getDataFromLocalStorage(key, undefined); } } @@ -248,6 +254,13 @@ export const lotamePanoramaIdSubmodule = { usPrivacy = getFromStorage('us_privacy'); } + const getRequestHost = function() { + if (navigator.userAgent && navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { + return ID_HOST_COOKIELESS; + } + return ID_HOST; + } + const resolveIdFunction = function (callback) { let queryParams = {}; if (storedUserId) { @@ -284,7 +297,7 @@ export const lotamePanoramaIdSubmodule = { const url = buildUrl({ protocol: 'https', - host: `id.crwdcntrl.net`, + host: getRequestHost(), pathname: '/id', search: isEmpty(queryParams) ? undefined : queryParams, }); @@ -355,6 +368,12 @@ export const lotamePanoramaIdSubmodule = { return { callback: resolveIdFunction }; }, + eids: { + lotamePanoramaId: { + source: 'crwdcntrl.net', + atype: 1, + }, + }, }; submodule('userId', lotamePanoramaIdSubmodule); diff --git a/modules/lunamediaBidAdapter.md b/modules/lunamediaBidAdapter.md deleted file mode 100755 index ff5cc86c462..00000000000 --- a/modules/lunamediaBidAdapter.md +++ /dev/null @@ -1,69 +0,0 @@ -# Overview - -``` -Module Name: LunaMedia Bidder Adapter -Module Type: Bidder Adapter -Maintainer: lokesh@advangelists.com -``` - -# Description - -Connects to LunaMedia exchange for bids. - -LunaMedia bid adapter supports Banner and Video ads currently. - -For more informatio - -# Sample Display Ad Unit: For Publishers -```javascript - -var displayAdUnit = [ -{ - code: 'display', - mediaTypes: { - banner: { - sizes: [[300, 250],[320, 50]] - } - } - bids: [{ - bidder: 'lunamedia', - params: { - pubid: '121ab139faf7ac67428a23f1d0a9a71b', - placement: 1234, - size: "320x50" - } - }] -}]; -``` - -# Sample Video Ad Unit: For Publishers -```javascript - -var videoAdUnit = { - code: 'video', - sizes: [320,480], - mediaTypes: { - video: { - playerSize : [[320, 480]], - context: 'instream' - } - }, - bids: [ - { - bidder: 'lunamedia', - params: { - pubid: '121ab139faf7ac67428a23f1d0a9a71b', - placement: 1234, - size: "320x480", - video: { - id: 123, - skip: 1, - mimes : ['video/mp4', 'application/javascript'], - playbackmethod : [2,6], - maxduration: 30 - } - } - } - ] - }; -``` \ No newline at end of file diff --git a/modules/lunamediahbBidAdapter.js b/modules/lunamediahbBidAdapter.js index ebd88d34940..66838014e18 100644 --- a/modules/lunamediahbBidAdapter.js +++ b/modules/lunamediahbBidAdapter.js @@ -2,6 +2,7 @@ import { logMessage } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'lunamediahb'; const AD_URL = 'https://balancer.lmgssp.com/?c=o&m=multi'; @@ -33,10 +34,14 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page) winTop = window.top; } catch (e) { location = winTop.location; diff --git a/modules/luponmediaBidAdapter.js b/modules/luponmediaBidAdapter.js index 897dc3c8825..20fa601bade 100755 --- a/modules/luponmediaBidAdapter.js +++ b/modules/luponmediaBidAdapter.js @@ -1,8 +1,20 @@ -import {isArray, logMessage, deepAccess, logWarn, parseSizesInput, deepSetValue, generateUUID, isEmpty, logError, _each, isFn} from '../src/utils.js'; +import { + _each, + deepAccess, + deepSetValue, + generateUUID, + isArray, + isEmpty, + isFn, + logError, + logMessage, + logWarn, + parseSizesInput +} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {BANNER} from '../src/mediaTypes.js'; -import { ajax } from '../src/ajax.js'; +import {ajax} from '../src/ajax.js'; const BIDDER_CODE = 'luponmedia'; const ENDPOINT_URL = 'https://rtb.adxpremium.services/openrtb2/auction'; @@ -176,7 +188,7 @@ export const spec = { responses.forEach(csResp => { if (csResp.body && csResp.body.ext && csResp.body.ext.usersyncs) { try { - let response = csResp.body.ext.usersyncs + let response = csResp.body.ext.usersyncs; let bidders = response.bidder_status; for (let synci in bidders) { let thisSync = bidders[synci]; @@ -287,12 +299,12 @@ function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) { } const data = { - id: bidRequest.transactionId, + id: bidderRequest.bidderRequestId, test: config.getConfig('debug') ? 1 : 0, source: { - tid: bidRequest.transactionId + tid: bidderRequest.ortb2?.source?.tid, }, - tmax: config.getConfig('timeout') || 1500, + tmax: bidderRequest.timeout, imp: currentImps.concat([{ id: bidRequest.bidId, secure: 1, @@ -314,7 +326,7 @@ function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) { }, user: { } - } + }; let bidFloor; if (isFn(bidRequest.getFloor) && !config.getConfig('disableFloors')) { @@ -431,6 +443,10 @@ function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) { deepSetValue(data, 'source.ext.schain', bidRequest.schain); } + // TODO: getConfig('fpd.context') should not have worked even with legacy FPD support - 'fpd' gets translated + // into 'ortb2' by `setConfig` + // Unclear what the intent was here - maybe `const {context: siteData, user: userData} = getLegacyFpd(config.getConfig('ortb2'))` ? + // (with PB7 `config.getConfig('ortb2')` should be replaced by `bidderRequest.ortb2`) const siteData = Object.assign({}, bidRequest.params.inventory, config.getConfig('fpd.context')); const userData = Object.assign({}, bidRequest.params.visitor, config.getConfig('fpd.user')); @@ -453,6 +469,8 @@ function newOrtbBidRequest(bidRequest, bidderRequest, currentImps) { deepSetValue(data, 'ext.prebid.bidderconfig.0', bidderData); } + // TODO: bidRequest.fpd is not the right place for pbadslot - who's filling that in, if anyone? + // is this meant to be bidRequest.ortb2Imp.ext.data.pbadslot? const pbAdSlot = deepAccess(bidRequest, 'fpd.context.pbAdSlot'); if (typeof pbAdSlot === 'string' && pbAdSlot) { deepSetValue(data.imp[0].ext, 'context.data.adslot', pbAdSlot); @@ -494,11 +512,12 @@ function _getDigiTrustQueryParams(bidRequest = {}, endpointName) { } function _getPageUrl(bidRequest, bidderRequest) { - let pageUrl = config.getConfig('pageUrl'); + // TODO: do the fallbacks make sense here? + let pageUrl = bidderRequest.refererInfo.page; if (bidRequest.params.referrer) { pageUrl = bidRequest.params.referrer; } else if (!pageUrl) { - pageUrl = bidderRequest.refererInfo.referer; + pageUrl = bidderRequest.refererInfo.topmostLocation; } return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl; } @@ -559,7 +578,7 @@ function parseSizes(bid, mediaType) { } else if (typeof deepAccess(bid, 'mediaTypes.banner.sizes') !== 'undefined') { sizes = mapSizes(bid.mediaTypes.banner.sizes); } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { - sizes = mapSizes(bid.sizes) + sizes = mapSizes(bid.sizes); } else { logWarn('LuponMedia: no sizes are setup or found'); } diff --git a/modules/mabidderBidAdapter.js b/modules/mabidderBidAdapter.js new file mode 100644 index 00000000000..632403c6643 --- /dev/null +++ b/modules/mabidderBidAdapter.js @@ -0,0 +1,62 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import {getGlobal} from '../src/prebidGlobal.js'; + +const BIDDER_CODE = 'mabidder'; +export const baseUrl = 'https://prebid.ecdrsvc.com/bid'; +export const spec = { + supportedMediaTypes: [BANNER], + code: BIDDER_CODE, + isBidRequestValid: function(bid) { + if (typeof bid.params === 'undefined') { + return false; + } + return !!(bid.params.ppid && bid.sizes && Array.isArray(bid.sizes) && Array.isArray(bid.sizes[0])) + }, + buildRequests: function(validBidRequests, bidderRequest) { + const fpd = bidderRequest.ortb2; + const bids = []; + validBidRequests.forEach(bidRequest => { + const sizes = []; + bidRequest.sizes.forEach(size => { + sizes.push({ + width: size[0], + height: size[1] + }); + }); + bids.push({ + bidId: bidRequest.bidId, + sizes: sizes, + ppid: bidRequest.params.ppid, + mediaType: BANNER + }) + }); + const req = { + url: baseUrl, + method: 'POST', + data: { + v: getGlobal().version, + bids: bids, + url: bidderRequest.refererInfo.page || '', + referer: bidderRequest.refererInfo.ref || '', + fpd: fpd || {} + } + }; + + return req; + }, + interpretResponse: function(serverResponse, request) { + const bidResponses = []; + if (serverResponse.body) { + const body = serverResponse.body; + if (!body || typeof body !== 'object' || !body.Responses || !(body.Responses.length > 0)) { + return []; + } + body.Responses.forEach((bidResponse) => { + bidResponses.push(bidResponse); + }); + } + return bidResponses; + } +} +registerBidder(spec); diff --git a/modules/mabidderBidAdapter.md b/modules/mabidderBidAdapter.md new file mode 100644 index 00000000000..ee57cb8cab2 --- /dev/null +++ b/modules/mabidderBidAdapter.md @@ -0,0 +1,31 @@ +#Overview + +``` +Module Name: mabidder Bid Adapter +Module Type: Bidder Adapter +Maintainer: lmprebidadapter@loblaw.ca +``` + +# Description + +Module that connects to MediaAisle demand sources + +# Test Parameters +``` +var adUnits = [ + { + code: 'test_banner', + mediaTypes: { + banner: { + sizes: [300, 250] + } + }, + bids: [{ + bidder: 'mabidder', + params: { + ppid: 'test' + } + }], + } +]; +``` diff --git a/modules/magniteAnalyticsAdapter.js b/modules/magniteAnalyticsAdapter.js new file mode 100644 index 00000000000..b9665b93494 --- /dev/null +++ b/modules/magniteAnalyticsAdapter.js @@ -0,0 +1,1056 @@ +import { + debugTurnedOn, + deepAccess, + deepClone, + deepSetValue, + generateUUID, + getWindowLocation, + isAdUnitCodeMatchingSlot, + isEmpty, + isGptPubadsDefined, + isNumber, + logError, + logInfo, + logWarn, + mergeDeep, + parseQS, + parseUrl, + pick +} from '../src/utils.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import CONSTANTS from '../src/constants.json'; +import {ajax} from '../src/ajax.js'; +import {config} from '../src/config.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; + +const RUBICON_GVL_ID = 52; +export const storage = getStorageManager({ moduleType: MODULE_TYPE_ANALYTICS, moduleName: 'magnite' }); +const COOKIE_NAME = 'mgniSession'; +const LAST_SEEN_EXPIRE_TIME = 1800000; // 30 mins +const END_EXPIRE_TIME = 21600000; // 6 hours +const MODULE_NAME = 'Magnite Analytics'; +const BID_REJECTED_IPF = 'rejected-ipf'; + +// List of known rubicon aliases +// This gets updated on auction init to account for any custom aliases present +let rubiconAliases = ['rubicon']; + +const pbsErrorMap = { + 1: 'timeout-error', + 2: 'input-error', + 3: 'connect-error', + 4: 'request-error', + 999: 'generic-error' +} + +let prebidGlobal = getGlobal(); +const { + EVENTS: { + AUCTION_INIT, + AUCTION_END, + BID_REQUESTED, + BID_RESPONSE, + BIDDER_DONE, + BID_TIMEOUT, + BID_WON, + BILLABLE_EVENT, + SEAT_NON_BID, + BID_REJECTED + } +} = CONSTANTS; + +// The saved state of rubicon specific setConfig controls +export let rubiConf; +// Saving state of all our data we want +let cache; +const resetConfs = () => { + cache = { + auctions: {}, + auctionOrder: [], + timeouts: {}, + billing: {}, + pendingEvents: {}, + eventPending: false, + elementIdMap: {}, + sessionData: {} + } + rubiConf = { + pvid: generateUUID().slice(0, 8), + analyticsEventDelay: 500, + analyticsBatchTimeout: 5000, + analyticsProcessDelay: 1, + dmBilling: { + enabled: false, + vendors: [], + waitForAuction: true + } + } +} +resetConfs(); + +config.getConfig('rubicon', config => { + mergeDeep(rubiConf, config.rubicon); + if (deepAccess(config, 'rubicon.updatePageView') === true) { + rubiConf.pvid = generateUUID().slice(0, 8) + } +}); + +// pbs confs +let serverConfig; +config.getConfig('s2sConfig', ({ s2sConfig }) => { + serverConfig = s2sConfig; +}); + +const DEFAULT_INTEGRATION = 'pbjs'; + +const adUnitIsOnlyInstream = adUnit => { + return adUnit.mediaTypes && Object.keys(adUnit.mediaTypes).length === 1 && deepAccess(adUnit, 'mediaTypes.video.context') === 'instream'; +} + +const sendPendingEvents = () => { + cache.pendingEvents.trigger = `batched-${Object.keys(cache.pendingEvents).sort().join('-')}`; + sendEvent(cache.pendingEvents); + cache.pendingEvents = {}; + cache.eventPending = false; +} + +const addEventToQueue = (event, auctionId, eventName) => { + // If it's auction has not left yet, add it there + if (cache.auctions[auctionId] && !cache.auctions[auctionId].sent) { + cache.auctions[auctionId].pendingEvents = mergeDeep(cache.auctions[auctionId].pendingEvents, event); + } else if (rubiConf.analyticsEventDelay > 0) { + // else if we are trying to batch stuff up, add it to pending events to be fired + cache.pendingEvents = mergeDeep(cache.pendingEvents, event); + + // If no event is pending yet, start a timer for them to be sent and attempted to be gathered together + if (!cache.eventPending) { + setTimeout(sendPendingEvents, rubiConf.analyticsEventDelay); + cache.eventPending = true; + } + } else { + // else - send it solo + event.trigger = `solo-${eventName}`; + sendEvent(event); + } +} + +const sendEvent = payload => { + const event = { + ...getTopLevelDetails(), + ...payload + } + if (window.pbjs?.rp?.eventDispatcher) { + const analyticsEvent = new CustomEvent('beforeSendingMagniteAnalytics', { detail: event }); + window.pbjs.rp.eventDispatcher.dispatchEvent(analyticsEvent); + } + ajax( + endpoint, + null, + JSON.stringify(event), + { + contentType: 'application/json' + } + ); +} + +const sendAuctionEvent = (auctionId, trigger) => { + let auctionCache = cache.auctions[auctionId]; + const auctionEvent = formatAuction(auctionCache.auction); + + auctionCache.sent = true; + sendEvent({ + auctions: [auctionEvent], + ...(auctionCache.pendingEvents || {}), // if any pending events were attached + trigger + }); +} + +const formatAuction = auction => { + const auctionEvent = deepClone(auction); + + auctionEvent.samplingFactor = 1; + + // We stored adUnits and bids as objects for quick lookups, now they are mapped into arrays for PBA + auctionEvent.adUnits = Object.entries(auctionEvent.adUnits).map(([tid, adUnit]) => { + adUnit.bids = Object.entries(adUnit.bids).map(([bidId, bid]) => { + // determine adUnit.status from its bid statuses. Use priority below to determine, higher index is better + let statusPriority = ['error', 'no-bid', 'success']; + if (statusPriority.indexOf(bid.status) > statusPriority.indexOf(adUnit.status)) { + adUnit.status = bid.status; + } + + // If PBS told us to overwrite the bid ID, do so + if (bid.pbsBidId) { + bid.oldBidId = bid.bidId; + bid.bidId = bid.pbsBidId; + delete bid.pbsBidId; + } + return bid; + }); + return adUnit; + }); + return auctionEvent; +} + +const isBillingEventValid = event => { + // vendor is whitelisted + const isWhitelistedVendor = rubiConf.dmBilling.vendors.includes(event.vendor); + // event is not duplicated + const isNotDuplicate = typeof deepAccess(cache.billing, `${event.vendor}.${event.billingId}`) !== 'boolean'; + // billingId is defined and a string + return typeof event.billingId === 'string' && isWhitelistedVendor && isNotDuplicate; +} + +const formatBillingEvent = event => { + let billingEvent = deepClone(event); + // Pass along type if is string and not empty else general + billingEvent.type = (typeof event.type === 'string' && event.type) || 'general'; + billingEvent.accountId = accountId; + // mark as sent + deepSetValue(cache.billing, `${event.vendor}.${event.billingId}`, true); + return billingEvent; +} + +const getBidPrice = bid => { + // get the cpm from bidResponse + let cpm; + let currency; + if (typeof deepAccess(bid, 'floorData.cpmAfterAdjustments') === 'number') { + // if bid was rejected and bid.floorData.cpmAfterAdjustments use it + cpm = bid.floorData.cpmAfterAdjustments; + currency = bid.floorData.floorCurrency; + } else if (typeof bid.currency === 'string' && bid.currency.toUpperCase() === 'USD') { + // bid is in USD use it + return Number(bid.cpm); + } else { + // else grab cpm + cpm = bid.cpm; + currency = bid.currency; + } + // if after this it is still going and is USD then return it. + if (currency === 'USD') { + return Number(cpm); + } + // otherwise we convert and return + try { + return Number(prebidGlobal.convertCurrency(cpm, currency, 'USD')); + } catch (err) { + logWarn(`${MODULE_NAME}: Could not determine the bidPriceUSD of the bid `, bid); + bid.conversionError = true; + bid.ogCurrency = currency; + bid.ogPrice = cpm; + return 0; + } +} + +export const parseBidResponse = (bid, previousBidResponse) => { + // The current bidResponse for this matching requestId/bidRequestId + let responsePrice = getBidPrice(bid) + // we need to compare it with the previous one (if there was one) log highest only + // THIS WILL CHANGE WITH ALLOWING MULTIBID BETTER + if (previousBidResponse && previousBidResponse.bidPriceUSD > responsePrice) { + return previousBidResponse; + } + + return pick(bid, [ + 'bidPriceUSD', () => responsePrice, + 'dealId', dealId => dealId || undefined, + 'mediaType', + 'dimensions', () => { + const width = bid.width || bid.playerWidth; + const height = bid.height || bid.playerHeight; + return (width && height) ? { width, height } : undefined; + }, + 'floorValue', () => deepAccess(bid, 'floorData.floorValue'), + 'floorRuleValue', () => deepAccess(bid, 'floorData.floorRuleValue'), + 'floorRule', () => debugTurnedOn() ? deepAccess(bid, 'floorData.floorRule') : undefined, + 'adomains', () => { + const adomains = deepAccess(bid, 'meta.advertiserDomains'); + const validAdomains = Array.isArray(adomains) && adomains.filter(domain => typeof domain === 'string'); + return validAdomains && validAdomains.length > 0 ? validAdomains.slice(0, 10) : undefined + }, + 'networkId', () => { + const networkId = deepAccess(bid, 'meta.networkId'); + // if not a valid after this, set to undefined so it gets filtered out + return (networkId && networkId.toString()) || undefined; + }, + 'conversionError', conversionError => conversionError === true || undefined, // only pass if exactly true + 'ogCurrency', + 'ogPrice', + 'rejectionReason' + ]); +} + +const addFloorData = floorData => { + if (floorData.location === 'noData') { + return pick(floorData, [ + 'location', + 'fetchStatus', + 'floorProvider as provider' + ]); + } else { + return pick(floorData, [ + 'location', + 'modelVersion as modelName', + 'modelWeight', + 'modelTimestamp', + 'skipped', + 'enforcement', () => deepAccess(floorData, 'enforcements.enforceJS'), + 'dealsEnforced', () => deepAccess(floorData, 'enforcements.floorDeals'), + 'skipRate', + 'fetchStatus', + 'floorMin', + 'floorProvider as provider' + ]); + } +} + +let pageReferer; + +const getTopLevelDetails = () => { + let payload = { + channel: 'web', + integration: rubiConf.int_type || DEFAULT_INTEGRATION, + referrerUri: pageReferer, + version: '$prebid.version$', + referrerHostname: magniteAdapter.referrerHostname || getHostNameFromReferer(pageReferer), + timestamps: { + timeSincePageLoad: performance.now(), + eventTime: Date.now(), + prebidLoaded: magniteAdapter.MODULE_INITIALIZED_TIME + } + } + + if (browser) { + deepSetValue(payload, rubiConf.pbaBrowserLocation || 'client.browser', browser); + } + + // Add DM wrapper details + if (rubiConf.wrapperName) { + payload.wrapper = { + name: rubiConf.wrapperName, + family: rubiConf.wrapperFamily, + rule: rubiConf.rule_name + } + } + + if (cache.sessionData) { + // gather session info + payload.session = pick(cache.sessionData, [ + 'id', + 'pvid', + 'start', + 'expires' + ]); + // Any FPKVS set? + if (!isEmpty(cache.sessionData.fpkvs)) { + payload.fpkvs = Object.keys(cache.sessionData.fpkvs).map(key => { + return { key, value: cache.sessionData.fpkvs[key] }; + }); + } + } + return payload; +} + +export const getHostNameFromReferer = referer => { + try { + magniteAdapter.referrerHostname = parseUrl(referer, { noDecodeWholeURL: true }).hostname; + } catch (e) { + logError(`${MODULE_NAME}: Unable to parse hostname from supplied url: `, referer, e); + magniteAdapter.referrerHostname = ''; + } + return magniteAdapter.referrerHostname +}; + +const getRpaCookie = () => { + let encodedCookie = storage.getDataFromLocalStorage(COOKIE_NAME); + if (encodedCookie) { + try { + return JSON.parse(window.atob(encodedCookie)); + } catch (e) { + logError(`${MODULE_NAME}: Unable to decode ${COOKIE_NAME} value: `, e); + } + } + return {}; +} + +const setRpaCookie = (decodedCookie) => { + try { + storage.setDataInLocalStorage(COOKIE_NAME, window.btoa(JSON.stringify(decodedCookie))); + } catch (e) { + logError(`${MODULE_NAME}: Unable to encode ${COOKIE_NAME} value: `, e); + } +} + +const updateRpaCookie = () => { + const currentTime = Date.now(); + let decodedRpaCookie = getRpaCookie(); + if ( + !Object.keys(decodedRpaCookie).length || + (currentTime - decodedRpaCookie.lastSeen) > LAST_SEEN_EXPIRE_TIME || + decodedRpaCookie.expires < currentTime + ) { + decodedRpaCookie = { + id: generateUUID(), + start: currentTime, + expires: currentTime + END_EXPIRE_TIME, // six hours later, + } + } + // possible that decodedRpaCookie is undefined, and if it is, we probably are blocked by storage or some other exception + if (Object.keys(decodedRpaCookie).length) { + decodedRpaCookie.lastSeen = currentTime; + decodedRpaCookie.fpkvs = { ...decodedRpaCookie.fpkvs, ...getFpkvs() }; + decodedRpaCookie.pvid = rubiConf.pvid; + setRpaCookie(decodedRpaCookie) + } + return decodedRpaCookie; +} + +/* + Filters and converts URL Params into an object and returns only KVs that match the 'utm_KEY' format +*/ +const getUtmParams = () => { + let search; + + try { + search = parseQS(getWindowLocation().search); + } catch (e) { + search = {}; + } + + return Object.keys(search).reduce((accum, param) => { + if (param.match(/utm_/)) { + accum[param.replace(/utm_/, '')] = search[param]; + } + return accum; + }, {}); +} + +const getFpkvs = () => { + rubiConf.fpkvs = Object.assign((rubiConf.fpkvs || {}), getUtmParams()); + + // convert all values to strings + Object.keys(rubiConf.fpkvs).forEach(key => { + rubiConf.fpkvs[key] = rubiConf.fpkvs[key] + ''; + }); + + return rubiConf.fpkvs; +} + +/* + Checks the alias registry for any entries of the rubicon bid adapter. + adds to the rubiconAliases list if found +*/ +const setRubiconAliases = (aliasRegistry) => { + const otherAliases = Object.keys(aliasRegistry).filter(alias => aliasRegistry[alias] === 'rubicon'); + rubiconAliases.push(...otherAliases); +} + +const sizeToDimensions = size => { + return { + width: size.w || size[0], + height: size.h || size[1] + }; +} + +const findMatchingAdUnitFromAuctions = (matchesFunction, returnFirstMatch) => { + // finding matching adUnit / auction + let matches = {}; + + // loop through auctions in order and adunits + for (const auctionId of cache.auctionOrder) { + const auction = cache.auctions[auctionId].auction; + for (const transactionId in auction.adUnits) { + const adUnit = auction.adUnits[transactionId]; + + // check if this matches + let doesMatch; + try { + doesMatch = matchesFunction(adUnit, auction); + } catch (error) { + logWarn(`${MODULE_NAME}: Error running matches function: ${returnFirstMatch}`, error); + doesMatch = false; + } + if (doesMatch) { + matches = { adUnit, auction }; + + // we either return first match or we want last one matching so go to end + if (returnFirstMatch) return matches; + } + } + } + return matches; +}; + +const getRenderingIds = bidWonData => { + // if bid caching off -> return the bidWon auction id + if (!config.getConfig('useBidCache')) { + return { + renderTransactionId: bidWonData.transactionId, + renderAuctionId: bidWonData.auctionId + }; + } + + // a rendering auction id is the LATEST auction / adunit which contains GAM ID's + const matchingFunction = (adUnit, auction) => { + // does adUnit match our bidWon and gam id's are present + const gamHasRendered = deepAccess(cache, `auctions.${auction.auctionId}.gamRenders.${adUnit.transactionId}`); + return adUnit.adUnitCode === bidWonData.adUnitCode && gamHasRendered; + } + let { adUnit, auction } = findMatchingAdUnitFromAuctions(matchingFunction, false); + // If no match was found, we will use the actual bid won auction id + return { + renderTransactionId: (adUnit && adUnit.transactionId) || bidWonData.transactionId, + renderAuctionId: (auction && auction.auctionId) || bidWonData.auctionId + } +} + +const formatBidWon = bidWonData => { + // get transaction and auction id of where this "rendered" + const { renderTransactionId, renderAuctionId } = getRenderingIds(bidWonData); + + const isCachedBid = renderTransactionId !== bidWonData.transactionId; + logInfo(`${MODULE_NAME}: Bid Won : `, { + isCachedBid, + renderAuctionId, + renderTransactionId, + sourceAuctionId: bidWonData.auctionId, + sourceTransactionId: bidWonData.transactionId, + }); + + // get the bid from the source auction id + let bid = deepAccess(cache, `auctions.${bidWonData.auctionId}.auction.adUnits.${bidWonData.transactionId}.bids.${bidWonData.requestId}`); + let adUnit = deepAccess(cache, `auctions.${bidWonData.auctionId}.auction.adUnits.${bidWonData.transactionId}`); + let bidWon = { + ...bid, + sourceAuctionId: bidWonData.auctionId, + renderAuctionId, + transactionId: bidWonData.transactionId, + sourceTransactionId: bidWonData.transactionId, + bidId: bid.pbsBidId || bidWonData.bidId || bidWonData.requestId, // if PBS had us overwrite bidId, use that as signal + renderTransactionId, + accountId, + siteId: adUnit.siteId, + zoneId: adUnit.zoneId, + mediaTypes: adUnit.mediaTypes, + adUnitCode: adUnit.adUnitCode, + isCachedBid: isCachedBid || undefined // only send if it is true (save some space) + } + delete bidWon.pbsBidId; // if pbsBidId is there delete it (no need to pass it) + return bidWon; +} + +const formatGamEvent = (slotEvent, adUnit, auction) => { + const gamEvent = pick(slotEvent, [ + // these come in as `null` from Gpt, which when stringified does not get removed + // so set explicitly to undefined when not a number + 'advertiserId', advertiserId => isNumber(advertiserId) ? advertiserId : undefined, + 'creativeId', creativeId => isNumber(slotEvent.sourceAgnosticCreativeId) ? slotEvent.sourceAgnosticCreativeId : isNumber(creativeId) ? creativeId : undefined, + 'lineItemId', lineItemId => isNumber(slotEvent.sourceAgnosticLineItemId) ? slotEvent.sourceAgnosticLineItemId : isNumber(lineItemId) ? lineItemId : undefined, + 'adSlot', () => slotEvent.slot.getAdUnitPath(), + 'isSlotEmpty', () => slotEvent.isEmpty || undefined + ]); + gamEvent.auctionId = auction.auctionId; + gamEvent.transactionId = adUnit.transactionId; + return gamEvent; +} + +const subscribeToGamSlots = () => { + window.googletag.pubads().addEventListener('slotRenderEnded', event => { + const isMatchingAdSlot = isAdUnitCodeMatchingSlot(event.slot); + + // We want to find the FIRST auction - adUnit that matches and does not have gam data yet + const matchingFunction = (adUnit, auction) => { + // first it has to match the slot + // if the code is present in the elementIdMap then we use the matched id as code here + const elementIds = cache.elementIdMap[adUnit.adUnitCode] || [adUnit.adUnitCode]; + const matchesSlot = elementIds.some(isMatchingAdSlot); + + // next it has to have NOT already been counted as gam rendered + const gamHasRendered = deepAccess(cache, `auctions.${auction.auctionId}.gamRenders.${adUnit.transactionId}`); + return matchesSlot && !gamHasRendered; + } + let { adUnit, auction } = findMatchingAdUnitFromAuctions(matchingFunction, true); + + const slotName = `${event.slot.getAdUnitPath()} - ${event.slot.getSlotElementId()}`; + + if (!adUnit || !auction) { + logInfo(`${MODULE_NAME}: Could not find matching adUnit for Gam Render: `, { + slotName + }); + return; + } + const auctionId = auction.auctionId; + + logInfo(`${MODULE_NAME}: Gam Render: `, { + slotName, + transactionId: adUnit.transactionId, + auctionId: auctionId, + adUnit: adUnit, + }); + + // if we have an adunit, then we need to make a gam event + const gamEvent = formatGamEvent(event, adUnit, auction); + + // marking that this prebid adunit has had its matching gam render found + deepSetValue(cache, `auctions.${auctionId}.gamRenders.${adUnit.transactionId}`, true); + + addEventToQueue({ gamRenders: [gamEvent] }, auctionId, 'gam'); + + // If this auction now has all gam slots rendered, fire the payload + if (!cache.auctions[auctionId].sent && Object.keys(cache.auctions[auctionId].gamRenders).every(tid => cache.auctions[auctionId].gamRenders[tid])) { + // clear the auction end timeout + clearTimeout(cache.timeouts[auctionId]); + delete cache.timeouts[auctionId]; + + // wait for bid wons a bit or send right away + if (rubiConf.analyticsEventDelay > 0) { + setTimeout(() => { + sendAuctionEvent(auctionId, 'gam-delayed'); + }, rubiConf.analyticsEventDelay); + } else { + sendAuctionEvent(auctionId, 'gam'); + } + } + }); +} + +/** + * Lazy parsing of UA to determine browser + * @param {string} userAgent string from prebid ortb ua or navigator + * @returns {string} lazily guessed browser name + */ +export const detectBrowserFromUa = userAgent => { + let normalizedUa = userAgent.toLowerCase(); + + if (normalizedUa.includes('edg')) { + return 'Edge'; + } else if ((/opr|opera|opt/i).test(normalizedUa)) { + return 'Opera'; + } else if ((/chrome|crios/i).test(normalizedUa)) { + return 'Chrome'; + } else if ((/fxios|firefox/i).test(normalizedUa)) { + return 'Firefox'; + } else if (normalizedUa.includes('safari') && !(/chromium|ucbrowser/i).test(normalizedUa)) { + return 'Safari'; + } + return 'OTHER'; +} + +let accountId; +let endpoint; + +let magniteAdapter = adapter({ analyticsType: 'endpoint' }); + +magniteAdapter.originEnableAnalytics = magniteAdapter.enableAnalytics; +function enableMgniAnalytics(config = {}) { + let error = false; + // endpoint + endpoint = deepAccess(config, 'options.endpoint'); + if (!endpoint) { + logError(`${MODULE_NAME}: required endpoint missing`); + error = true; + } + // accountId + accountId = Number(deepAccess(config, 'options.accountId')); + if (!accountId) { + logError(`${MODULE_NAME}: required accountId missing`); + error = true; + } + if (!error) { + magniteAdapter.originEnableAnalytics(config); + } + // listen to gam slot renders! + if (isGptPubadsDefined()) { + subscribeToGamSlots(); + } else { + window.googletag = window.googletag || {}; + window.googletag.cmd = window.googletag.cmd || []; + window.googletag.cmd.push(() => subscribeToGamSlots()); + } +}; + +const handleBidWon = args => { + const bidWon = formatBidWon(args); + addEventToQueue({ bidsWon: [bidWon] }, bidWon.renderAuctionId, 'bidWon'); +} + +magniteAdapter.enableAnalytics = enableMgniAnalytics; + +magniteAdapter.originDisableAnalytics = magniteAdapter.disableAnalytics; +magniteAdapter.disableAnalytics = function () { + // trick analytics module to register our enable back as main one + magniteAdapter._oldEnable = enableMgniAnalytics; + endpoint = undefined; + accountId = undefined; + resetConfs(); + magniteAdapter.originDisableAnalytics(); +}; + +magniteAdapter.onDataDeletionRequest = function () { + if (storage.localStorageIsEnabled()) { + storage.removeDataFromLocalStorage(COOKIE_NAME); + } else { + throw Error('Unable to access local storage, no data deleted'); + } +}; + +magniteAdapter.MODULE_INITIALIZED_TIME = Date.now(); +magniteAdapter.referrerHostname = ''; + +const handleBidResponse = (args, bidStatus) => { + const auctionEntry = deepAccess(cache, `auctions.${args.auctionId}.auction`); + const adUnit = deepAccess(auctionEntry, `adUnits.${args.transactionId}`); + let bid = adUnit.bids[args.requestId]; + + // if this came from multibid, there might now be matching bid, so check + // THIS logic will change when we support multibid per bid request + if (!bid && args.originalRequestId) { + let ogBid = adUnit.bids[args.originalRequestId]; + // create new bid + adUnit.bids[args.requestId] = { + ...ogBid, + bidId: args.requestId, + bidderDetail: args.targetingBidder + }; + bid = adUnit.bids[args.requestId]; + } + + // if we have not set enforcements yet set it (This is hidden from bidders until now so we have to get from here) + if (typeof deepAccess(auctionEntry, 'floors.enforcement') !== 'boolean' && deepAccess(args, 'floorData.enforcements')) { + deepSetValue(auctionEntry, 'floors.enforcement', args.floorData.enforcements.enforceJS); + deepSetValue(auctionEntry, 'floors.dealsEnforced', args.floorData.enforcements.floorDeals); + } + + // no-bid from server. report it! + if (!bid && args.seatBidId) { + bid = adUnit.bids[args.seatBidId] = { + bidder: args.bidderCode, + source: 'server', + bidId: args.seatBidId, + unknownBid: true + }; + } + + if (!bid) { + logError(`${MODULE_NAME}: Could not find associated bid request for bid response with requestId: `, args.requestId); + return; + } + + // set bid status + bid.status = bidStatus; + const latencies = getLatencies(args, auctionEntry.auctionStart); + bid.clientLatencyMillis = latencies.total; + bid.httpLatencyMillis = latencies.net; + bid.bidResponse = parseBidResponse(args, bid.bidResponse); + + // if pbs gave us back a bidId, we need to use it and update our bidId to PBA + const pbsBidId = (args.pbsBidId == 0 ? generateUUID() : args.pbsBidId) || (args.seatBidId == 0 ? generateUUID() : args.seatBidId); + if (pbsBidId) { + bid.pbsBidId = pbsBidId; + } +} + +const getLatencies = (args, auctionStart) => { + try { + const metrics = args.metrics.getMetrics(); + const src = args.src || args.source; + return { + total: parseInt(metrics[`adapter.${src}.total`]), + // If it is array, get slowest + net: parseInt(Array.isArray(metrics[`adapter.${src}.net`]) ? metrics[`adapter.${src}.net`][metrics[`adapter.${src}.net`].length - 1] : metrics[`adapter.${src}.net`]) + } + } catch (error) { + // default to old way if not able to get better ones + const latency = Date.now() - auctionStart; + return { + total: latency, + net: latency + } + } +} + +let browser; +magniteAdapter.track = ({ eventType, args }) => { + switch (eventType) { + case AUCTION_INIT: + // Update session + cache.sessionData = storage.localStorageIsEnabled() && updateRpaCookie(); + // set the rubicon aliases + setRubiconAliases(adapterManager.aliasRegistry); + + // latest page "referer" + pageReferer = deepAccess(args, 'bidderRequests.0.refererInfo.page'); + + // set auction level data + let auctionData = pick(args, [ + 'auctionId', + 'timestamp as auctionStart', + 'timeout as clientTimeoutMillis', + ]); + auctionData.accountId = accountId; + + // get browser + if (!browser) { + const userAgent = deepAccess(args, 'bidderRequests.0.ortb2.device.ua', navigator.userAgent) || ''; + browser = detectBrowserFromUa(userAgent); + } + + // Order bidders were called + auctionData.bidderOrder = args.bidderRequests.map(bidderRequest => bidderRequest.bidderCode); + + // Price Floors information + const floorData = deepAccess(args, 'bidderRequests.0.bids.0.floorData'); + if (floorData) { + auctionData.floors = addFloorData(floorData); + } + + // GDPR info + const gdprData = deepAccess(args, 'bidderRequests.0.gdprConsent'); + if (gdprData) { + auctionData.gdpr = pick(gdprData, [ + 'gdprApplies as applies', + 'consentString', + 'apiVersion as version' + ]); + } + + // User ID Data included in auction + const userIds = Object.keys(deepAccess(args, 'bidderRequests.0.bids.0.userId', {})).map(id => { + return { provider: id, hasId: true } + }); + if (userIds.length) { + auctionData.user = { ids: userIds }; + } + + if (serverConfig) { + auctionData.serverTimeoutMillis = serverConfig.timeout; + } + + // lets us keep a map of adunit and wether it had a gam or bid won render yet, used to track when to send events + let gamRenders = {}; + // adunits saved as map of transactionIds + auctionData.adUnits = args.adUnits.reduce((adMap, adUnit) => { + let ad = pick(adUnit, [ + 'code as adUnitCode', + 'transactionId', + 'mediaTypes', mediaTypes => Object.keys(mediaTypes), + 'sizes as dimensions', sizes => (sizes || [[1, 1]]).map(sizeToDimensions), + ]); + ad.pbAdSlot = deepAccess(adUnit, 'ortb2Imp.ext.data.pbadslot'); + ad.pattern = deepAccess(adUnit, 'ortb2Imp.ext.data.aupname'); + ad.gpid = deepAccess(adUnit, 'ortb2Imp.ext.gpid'); + ad.bids = {}; + adMap[adUnit.transactionId] = ad; + gamRenders[adUnit.transactionId] = false; + + // Handle case elementId's (div Id's) are set on adUnit - PPI + const elementIds = deepAccess(adUnit, 'ortb2Imp.ext.data.elementid'); + if (elementIds) { + cache.elementIdMap[adUnit.code] = cache.elementIdMap[adUnit.code] || []; + // set it to array if set to string to be careful (should be array of strings) + const newIds = typeof elementIds === 'string' ? [elementIds] : elementIds; + newIds.forEach(id => { + if (!cache.elementIdMap[adUnit.code].includes(id)) { + cache.elementIdMap[adUnit.code].push(id); + } + }); + } + return adMap; + }, {}); + + // holding our pba data to send + cache.auctions[args.auctionId] = { + auction: auctionData, + gamRenders, + pendingEvents: {} + } + break; + case BID_REQUESTED: + args.bids.forEach(bid => { + const adUnit = deepAccess(cache, `auctions.${args.auctionId}.auction.adUnits.${bid.transactionId}`); + adUnit.bids[bid.bidId] = pick(bid, [ + 'bidder', + 'bidId', + 'source', () => bid.src === 's2s' ? 'server' : 'client', + 'status', () => 'no-bid' + ]); + // set acct site zone id on adunit + if ((!adUnit.siteId || !adUnit.zoneId) && rubiconAliases.indexOf(bid.bidder) !== -1) { + if (deepAccess(bid, 'params.accountId') == accountId) { + adUnit.accountId = parseInt(accountId); + adUnit.siteId = parseInt(deepAccess(bid, 'params.siteId')); + adUnit.zoneId = parseInt(deepAccess(bid, 'params.zoneId')); + } + } + }); + break; + case BID_RESPONSE: + handleBidResponse(args, 'success'); + break; + case BID_REJECTED: + const bidStatus = args.rejectionReason === CONSTANTS.REJECTION_REASON.FLOOR_NOT_MET ? BID_REJECTED_IPF : 'rejected'; + handleBidResponse(args, bidStatus); + break; + case SEAT_NON_BID: + handleNonBidEvent(args); + break; + case BIDDER_DONE: + const serverError = deepAccess(args, 'serverErrors.0'); + const serverResponseTimeMs = args.serverResponseTimeMs; + args.bids.forEach(bid => { + let cachedBid = deepAccess(cache, `auctions.${bid.auctionId}.auction.adUnits.${bid.transactionId}.bids.${bid.bidId}`); + if (typeof bid.serverResponseTimeMs !== 'undefined') { + cachedBid.serverLatencyMillis = bid.serverResponseTimeMs; + } else if (serverResponseTimeMs && bid.source === 's2s') { + cachedBid.serverLatencyMillis = serverResponseTimeMs; + } + // if PBS said we had an error, and this bid has not been processed by BID_RESPONSE YET + if (serverError && (!cachedBid.status || ['no-bid', 'error'].indexOf(cachedBid.status) !== -1)) { + cachedBid.status = 'error'; + cachedBid.error = { + code: pbsErrorMap[serverError.code] || pbsErrorMap[999], + description: serverError.message + } + } + + // set client latency if not done yet + if (!cachedBid.clientLatencyMillis || !cachedBid.httpLatencyMillis) { + const latencies = getLatencies(bid, deepAccess(cache, `auctions.${args.auctionId}.auction.auctionStart`)); + cachedBid.clientLatencyMillis = cachedBid.clientLatencyMillis || latencies.total; + cachedBid.httpLatencyMillis = cachedBid.httpLatencyMillis || latencies.net; + } + }); + break; + case BID_WON: + // Allowing us to delay bidWon handling so it happens at right time + // we expect it to happen after gpt slotRenderEnded, but have seen it happen before when testing + // this will ensure it happens after if set + if (rubiConf.analyticsProcessDelay > 0) { + setTimeout(() => { + handleBidWon(args); + }, rubiConf.analyticsProcessDelay); + } else { + handleBidWon(args); + } + break; + case AUCTION_END: + let auctionCache = cache.auctions[args.auctionId]; + // if for some reason the auction did not do its normal thing, this could be undefied so bail + if (!auctionCache) { + break; + } + // Set this auction as being done + auctionCache.auction.auctionEnd = args.auctionEnd; + + // keeping order of auctions and if the payload has been sent or not + cache.auctionOrder.push(args.auctionId); + + const isOnlyInstreamAuction = args.adUnits && args.adUnits.every(adUnit => adUnitIsOnlyInstream(adUnit)); + + // if we are not waiting OR it is instream only auction + if (isOnlyInstreamAuction || rubiConf.analyticsBatchTimeout === 0) { + sendAuctionEvent(args.auctionId, 'solo-auction'); + } else { + // start timer to send batched payload just in case we don't hear any BID_WON events + cache.timeouts[args.auctionId] = setTimeout(() => { + sendAuctionEvent(args.auctionId, 'auctionEnd'); + }, rubiConf.analyticsBatchTimeout); + } + break; + case BID_TIMEOUT: + args.forEach(badBid => { + let bid = deepAccess(cache, `auctions.${badBid.auctionId}.auction.adUnits.${badBid.transactionId}.bids.${badBid.bidId}`, {}); + // might be set already by bidder-done, so do not overwrite + if (bid.status !== 'error') { + bid.status = 'error'; + bid.error = { + code: 'timeout-error', + description: 'prebid.js timeout' // will help us diff if timeout was set by PBS or PBJS + }; + } + }); + break; + case BILLABLE_EVENT: + if (rubiConf.dmBilling.enabled && isBillingEventValid(args)) { + // add to the map indicating it has not been sent yet + deepSetValue(cache.billing, `${args.vendor}.${args.billingId}`, false); + const billingEvent = formatBillingEvent(args); + addEventToQueue({ billableEvents: [billingEvent] }, args.auctionId, 'billing'); + } else { + logInfo(`${MODULE_NAME}: Billing event ignored`, args); + } + break; + } +}; + +const handleNonBidEvent = function(args) { + const {seatnonbid, auctionId} = args; + const auction = deepAccess(cache, `auctions.${auctionId}.auction`); + // if no auction just bail + if (!auction) { + logWarn(`Unable to match nonbid to auction`); + return; + } + const adUnits = auction.adUnits; + seatnonbid.forEach(seatnonbid => { + let {seat} = seatnonbid; + seatnonbid.nonbid.forEach(nonbid => { + try { + const {status, impid} = nonbid; + const matchingTid = Object.keys(adUnits).find(tid => adUnits[tid].adUnitCode === impid); + const adUnit = adUnits[matchingTid]; + const statusInfo = statusMap[status] || { status: 'no-bid' }; + adUnit.bids[generateUUID()] = { + bidder: seat, + source: 'server', + isSeatNonBid: true, + clientLatencyMillis: Date.now() - auction.auctionStart, + ...statusInfo + }; + } catch (error) { + logWarn(`Unable to match nonbid to adUnit`); + } + }); + }); +}; + +const statusMap = { + 0: { + status: 'no-bid' + }, + 100: { + status: 'error', + error: { + code: 'request-error', + description: 'general error' + } + }, + 101: { + status: 'error', + error: { + code: 'timeout-error', + description: 'prebid server timeout' + } + }, + 200: { + status: 'rejected' + }, + 202: { + status: 'rejected' + }, + 301: { + status: 'rejected-ipf' + } +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: magniteAdapter, + code: 'magnite', + gvlid: RUBICON_GVL_ID +}); + +export default magniteAdapter; diff --git a/modules/magniteAnalyticsAdapter.md b/modules/magniteAnalyticsAdapter.md new file mode 100644 index 00000000000..a9ad0f4345b --- /dev/null +++ b/modules/magniteAnalyticsAdapter.md @@ -0,0 +1,18 @@ +# Magnite Analytics Adapter + +``` +Module Name: Magnite Analytics Adapter +Module Type: Analytics Adapter +Maintainer: demand-manager-support@magnite.com +``` + +## How to configure? +``` +pbjs.enableAnalytics({ + provider: 'magnite', + options: { + accountId: 12345, // The account id assigned to you by the Magnite Team + endpoint: 'http:localhost:9999/event' // Given by the Magnite Team + } +}); +``` diff --git a/modules/malltvAnalyticsAdapter.js b/modules/malltvAnalyticsAdapter.js index a0e2a208bc9..af903795e49 100644 --- a/modules/malltvAnalyticsAdapter.js +++ b/modules/malltvAnalyticsAdapter.js @@ -1,5 +1,5 @@ import {ajax} from '../src/ajax.js' -import adapter from '../src/AnalyticsAdapter.js' +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js' import CONSTANTS from '../src/constants.json' import adapterManager from '../src/adapterManager.js' import {getGlobal} from '../src/prebidGlobal.js' diff --git a/modules/malltvBidAdapter.js b/modules/malltvBidAdapter.js index 53f745d4004..5ac50936ed6 100644 --- a/modules/malltvBidAdapter.js +++ b/modules/malltvBidAdapter.js @@ -47,7 +47,8 @@ export const spec = { if (!propertyId) { propertyId = bidRequest.params.propertyId; } if (!pageViewGuid && bidRequest.params) { pageViewGuid = bidRequest.params.pageViewGuid || ''; } if (!bidderRequestId) { bidderRequestId = bidRequest.bidderRequestId; } - if (!url && bidderRequest) { url = bidderRequest.refererInfo.referer; } + // TODO: is 'page' the right value here? + if (!url && bidderRequest) { url = bidderRequest.refererInfo.page; } if (!contents.length && bidRequest.params.contents && bidRequest.params.contents.length) { contents = bidRequest.params.contents; } if (Object.keys(data).length === 0 && bidRequest.params.data && Object.keys(bidRequest.params.data).length !== 0) { data = bidRequest.params.data; } if (bidderRequest && bidRequest.gdprConsent) { gdrpApplies = bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? bidderRequest.gdprConsent.gdprApplies : true; } @@ -67,6 +68,7 @@ export const spec = { }); let body = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: auctionId, propertyId: propertyId, pageViewGuid: pageViewGuid, @@ -80,7 +82,7 @@ export const spec = { data: data, gdpr_applies: gdrpApplies, gdpr_consent: gdprConsent, - } + }; return [{ method: 'POST', @@ -119,7 +121,7 @@ export const spec = { } return bidResponses; } -} +}; /** * Generate size param for bid request using sizes array diff --git a/modules/mantisBidAdapter.js b/modules/mantisBidAdapter.js index 8d62b0ffba7..4520bad0f3a 100644 --- a/modules/mantisBidAdapter.js +++ b/modules/mantisBidAdapter.js @@ -1,5 +1,6 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; +import { ajax } from '../src/ajax.js'; export const storage = getStorageManager({bidderCode: 'mantis'}); @@ -10,12 +11,7 @@ function inIframe() { return true; } } -function pixel(url, parent) { - var img = document.createElement('img'); - img.src = url; - img.style.cssText = 'display:none !important;'; - (parent || document.body).appendChild(img); -} + export function onVisible(win, element, doOnVisible, time, pct) { var started = null; var notified = false; @@ -301,9 +297,9 @@ export function iframePostMessage (win, name, callback) { onMessage('iframe', function (data) { if (window.$sf) { - sfPostMessage(window.$sf, data.width, data.height, () => pixel(data.pixel)); + sfPostMessage(window.$sf, data.width, data.height, () => ajax(data.pixel)); } else { - iframePostMessage(window, data.frame, () => pixel(data.pixel)); + iframePostMessage(window, data.frame, () => ajax(data.pixel)); } }); diff --git a/modules/marsmediaAnalyticsAdapter.js b/modules/marsmediaAnalyticsAdapter.js index 12c333631a2..f1e53a3c20c 100644 --- a/modules/marsmediaAnalyticsAdapter.js +++ b/modules/marsmediaAnalyticsAdapter.js @@ -1,6 +1,7 @@ import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; +import {getGlobal} from '../src/prebidGlobal.js'; /**** * Mars Media Analytics @@ -33,7 +34,7 @@ var marsmediaAnalyticsAdapter = Object.assign(adapter( success: function() {}, error: function() {} }, - JSON.stringify({act: 'prebid_analytics', params: events, 'pbjs': $$PREBID_GLOBAL$$.getBidResponses(), ver: MARS_VERSION}), + JSON.stringify({act: 'prebid_analytics', params: events, 'pbjs': getGlobal().getBidResponses(), ver: MARS_VERSION}), { method: 'POST' } diff --git a/modules/marsmediaBidAdapter.js b/modules/marsmediaBidAdapter.js index 92374b748c7..82a25af60d1 100644 --- a/modules/marsmediaBidAdapter.js +++ b/modules/marsmediaBidAdapter.js @@ -31,6 +31,7 @@ function MarsmediaAdapter() { var isSecure = 0; if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.stack.length) { // clever trick to get the protocol + // TODO: this should probably use parseUrl var el = document.createElement('a'); el.href = bidderRequest.refererInfo.stack[0]; isSecure = (el.protocol == 'https:') ? 1 : 0; @@ -68,12 +69,15 @@ function MarsmediaAdapter() { } if (bidderRequest && bidderRequest.refererInfo) { var ri = bidderRequest.refererInfo; - site.ref = ri.referer; + // TODO: is 'ref' the right value here? + site.ref = ri.ref; if (ri.stack.length) { site.page = ri.stack[ri.stack.length - 1]; // clever trick to get the domain + // TODO: does this logic make sense? why should domain be set to the lowermost frame's? + // TODO: this should probably use parseUrl var el = document.createElement('a'); el.href = ri.stack[0]; site.domain = el.hostname; diff --git a/modules/mass.js b/modules/mass.js deleted file mode 100644 index f38f833f4d3..00000000000 --- a/modules/mass.js +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This module adds MASS support to Prebid.js. - */ - -import {config} from '../src/config.js'; -import {getHook} from '../src/hook.js'; -import {auctionManager} from '../src/auctionManager.js'; - -const defaultCfg = { - dealIdPattern: /^MASS/i -}; -let cfg; - -export let listenerAdded = false; -export let isEnabled = false; - -const matchedBids = {}; -let renderers; - -init(); -config.getConfig('mass', config => init(config.mass)); - -/** - * Module init. - */ -export function init(userCfg) { - cfg = Object.assign({}, defaultCfg, window.massConfig && window.massConfig.mass, userCfg); - - if (cfg.enabled === false) { - if (isEnabled) { - getHook('addBidResponse').getHooks({hook: addBidResponseHook}).remove(); - isEnabled = false; - } - } else { - if (!isEnabled) { - getHook('addBidResponse').before(addBidResponseHook); - isEnabled = true; - } - } - - if (isEnabled) { - updateRenderers(); - } -} - -/** - * Update the list of renderers based on current config. - */ -export function updateRenderers() { - renderers = []; - - // official MASS renderer: - if (cfg.dealIdPattern && cfg.renderUrl) { - renderers.push({ - match: isMassBid, - render: useDefaultRender(cfg.renderUrl, 'mass') - }); - } - - // add any custom renderer defined in the config: - (cfg.custom || []).forEach(renderer => { - if (!renderer.match && renderer.dealIdPattern) { - renderer.match = useDefaultMatch(renderer.dealIdPattern); - } - - if (!renderer.render && renderer.renderUrl && renderer.namespace) { - renderer.render = useDefaultRender(renderer.renderUrl, renderer.namespace); - } - - if (renderer.match && renderer.render) { - renderers.push(renderer); - } - }); - - return renderers; -} - -/** - * Before hook for 'addBidResponse'. - */ -export function addBidResponseHook(next, adUnitCode, bid, {index = auctionManager.index} = {}) { - let renderer; - for (let i = 0; i < renderers.length; i++) { - if (renderers[i].match(bid)) { - renderer = renderers[i]; - break; - } - } - - if (renderer) { - const bidRequest = index.getBidRequest(bid); - - matchedBids[bid.requestId] = { - renderer, - payload: { - bidRequest, - bid, - adm: bid.ad - } - }; - - bid.ad = '`; + const script = ``; + if (!native.javascriptTrackers) { + native.javascriptTrackers = script; + } else { + native.javascriptTrackers += `\n${script}`; + } break; } }); @@ -611,12 +601,13 @@ export const spec = { }, buildRequests: function(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const payload = createOrtbTemplate(); - // Pass the auctionId as ortb2 id - // See https://github.com/prebid/Prebid.js/issues/6563 - deepSetValue(payload, 'id', bidderRequest.auctionId); - deepSetValue(payload, 'source.tid', bidderRequest.auctionId); + deepSetValue(payload, 'id', bidderRequest.bidderRequestId); + deepSetValue(payload, 'source.tid', bidderRequest.ortb2.source?.tid); validBidRequests.forEach(validBid => { let bid = deepClone(validBid); @@ -644,27 +635,24 @@ export const spec = { deepSetValue(payload, 'regs.coppa', 1); } - if (deepAccess(validBidRequests[0], 'userId')) { - deepSetValue(payload, 'user.ext.eids', createEidsArray(validBidRequests[0].userId)); + if (deepAccess(validBidRequests[0], 'userIdAsEids')) { + deepSetValue(payload, 'user.ext.eids', validBidRequests[0].userIdAsEids); } // Assign payload.site from refererinfo if (bidderRequest.refererInfo) { + // TODO: reachedTop is probably not the right check here - it may be false when page is available or vice-versa if (bidderRequest.refererInfo.reachedTop) { - const sitePage = bidderRequest.refererInfo.referer; - deepSetValue(payload, 'site.page', sitePage); - deepSetValue(payload, 'site.domain', parseUrl(sitePage, { - noDecodeWholeURL: true - }).hostname); - - if (canAccessTopWindow()) { - deepSetValue(payload, 'site.ref', getWindowTop().document.referrer); + deepSetValue(payload, 'site.page', bidderRequest.refererInfo.page); + deepSetValue(payload, 'site.domain', bidderRequest.refererInfo.domain) + if (bidderRequest.refererInfo.ref) { + deepSetValue(payload, 'site.ref', bidderRequest.refererInfo.ref); } } } // Handle First Party Data (need publisher fpd setup) - const fpd = config.getConfig('ortb2') || {}; + const fpd = bidderRequest.ortb2 || {}; if (fpd.site) { mergeDeep(payload, { site: fpd.site }); } @@ -717,7 +705,7 @@ export const spec = { agencyName: deepAccess(bid, 'ext.agency_name', null), primaryCatId: getPrimaryCatFromResponse(bid.cat), mediaType - } + }; const newBid = { requestId: bid.impid, diff --git a/modules/mediakeysBidAdapter.md b/modules/mediakeysBidAdapter.md index ec313c2fe3a..b0654771d19 100644 --- a/modules/mediakeysBidAdapter.md +++ b/modules/mediakeysBidAdapter.md @@ -14,9 +14,10 @@ Connects to Mediakeys demand source to fetch bids. ## Banner only Ad Unit -``` -var adUnits = [ -{ +The Mediakeys adapter accepts any valid OpenRTB Spec 2.5 property. + +```javascript +var adUnits = [{ code: 'test', mediaTypes: { banner: { @@ -27,20 +28,26 @@ var adUnits = [ bidder: 'mediakeys', params: {} // no params required. }] -}, +}] ``` ## Native only Ad Unit The Mediakeys adapter accepts two optional params for native requests. Please see the [OpenRTB Native Ads Specification](https://www.iab.com/wp-content/uploads/2018/03/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) for valid values. -``` -var adUnits = [ -{ +```javascript +var adUnits = [{ code: 'test', mediaTypes: { native: { - type: 'image', + title: { + required: true, + len: 120 + }, + image: { + required: true, + sizes: [300, 250] + } } }, bids: [{ @@ -52,7 +59,7 @@ var adUnits = [ } } }] -}, +}] ``` ## Video only Ad Unit @@ -61,63 +68,65 @@ The Mediakeys adapter accepts any valid openRTB 2.5 video property. Properties c ### Outstream context -``` -var adUnits = [ -{ +```javascript +var adUnits = [{ code: 'test', mediaTypes: { video: { context: 'outstream', - playerSize: [300, 250], + playerSize: [1280, 720], // additional OpenRTB video params // placement: 2, // api: [1], // … + mimes: ['video/mp4'], + protocols: [2, 3], + skip: 0 } }, renderer: { url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', + // the render method must fetch the vast xml document before displaying video render: function (bid) { - var bidReqConfig = pbjs.adUnits.find(bidReq => bidReq.bidId === bid.impid); - - if (bidReqConfig && bidReqConfig.mediaTypes && bidReqConfig.mediaTypes.video && bidReqConfig.mediaTypes.video.context === 'outstream') { - var adResponse = fetch(bid.vastUrl).then(resp => resp.text()).then(text => ({ - ad: { - video: { - content: text, - player_width: bid.width || bidReqConfig.mediaTypes.video.playerSize[0], - player_height: bid.height || bidReqConfig.mediaTypes.video.playerSize[1], - } + var adResponse = fetch(bid.vastUrl).then(resp => resp.text()).then(text => ({ + ad: { + video: { + content: text, + player_height: bid.playerHeight, + player_width: bid.playerWidth } - })) - - adResponse.then((ad) => { - bid.renderer.push(() => { - ANOutstreamVideo.renderAd({ - targetId: bid.adUnitCode, - adResponse: ad - }); + } + })) + + adResponse.then((content) => { + bid.renderer.push(() => { + ANOutstreamVideo.renderAd({ + targetId: bid.adUnitCode, + adResponse: content }); - }) - } + }); + }) } }, bids: [{ bidder: 'mediakeys', params: { video: { - // additional OpenRTB video params. Will be merged with params defined at mediaTypes level + // additional OpenRTB video params. + // will be merged with params defined at mediaTypes level + api: [1] } } }] -}, +}] ``` ### Instream context -``` -var adUnits = [ -{ +For Instream Video, you have to enable the Instream Tracking Module to have Prebid emit the onBidWon required event. + +```javascript +var adUnits = [{ code: 'test', mediaTypes: { video: { @@ -132,8 +141,9 @@ var adUnits = [ bids: [{ bidder: 'mediakeys', params: { - // additional OpenRTB video params. Will be merged with params defined at mediaTypes level + // additional OpenRTB video params. + // will be merged with params defined at mediaTypes level } }] -}, +}] ``` diff --git a/modules/medianetAnalyticsAdapter.js b/modules/medianetAnalyticsAdapter.js index 09ebbc9bc31..b902727a730 100644 --- a/modules/medianetAnalyticsAdapter.js +++ b/modules/medianetAnalyticsAdapter.js @@ -8,16 +8,16 @@ import { logError, logInfo, triggerPixel, - uniques, - getHighestCpm + uniques } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; import {ajax} from '../src/ajax.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {AUCTION_COMPLETED, AUCTION_IN_PROGRESS, getPriceGranularity} from '../src/auction.js'; import {includes} from '../src/polyfill.js'; +import {getGlobal} from '../src/prebidGlobal.js'; const analyticsType = 'endpoint'; const ENDPOINT = 'https://pb-logs.media.net/log?logid=kfk&evtid=prebid_analytics_events_client'; @@ -37,9 +37,11 @@ const PRICE_GRANULARITY = { const MEDIANET_BIDDER_CODE = 'medianet'; // eslint-disable-next-line no-undef -const PREBID_VERSION = $$PREBID_GLOBAL$$.version; +const PREBID_VERSION = getGlobal().version; const ERROR_CONFIG_JSON_PARSE = 'analytics_config_parse_fail'; const ERROR_CONFIG_FETCH = 'analytics_config_ajax_fail'; +const ERROR_WINNING_BID_ABSENT = 'winning_bid_absent'; +const ERROR_WINNING_AUCTION_MISSING = 'winning_auction_missing'; const BID_SUCCESS = 1; const BID_NOBID = 2; const BID_TIMEOUT = 3; @@ -51,7 +53,7 @@ const CONFIG_PASS = 1; const CONFIG_ERROR = 3; const VALID_URL_KEY = ['canonical_url', 'og_url', 'twitter_url']; -const DEFAULT_URL_KEY = 'page'; +const DEFAULT_URL_KEY = 'topmostLocation'; const LOG_TYPE = { APPR: 'APPR', @@ -62,6 +64,7 @@ let auctions = {}; let config; let pageDetails; let logsQueue = []; +let errorQueue = []; class ErrorLogger { constructor(event, additionalData) { @@ -70,7 +73,7 @@ class ErrorLogger { this.evtid = 'projectevents'; this.project = 'prebidanalytics'; this.dn = pageDetails.domain || ''; - this.requrl = pageDetails.requrl || ''; + this.requrl = pageDetails.topmostLocation || ''; this.pbversion = PREBID_VERSION; this.cid = config.cid || ''; this.rd = additionalData; @@ -78,6 +81,7 @@ class ErrorLogger { send() { let url = EVENT_PIXEL_URL + '?' + formatQS(this); + errorQueue.push(url); triggerPixel(url); } } @@ -160,7 +164,7 @@ class Configure { init() { // Forces Logging % to 100% - let urlObj = URL.parseUrl(pageDetails.page); + let urlObj = URL.parseUrl(pageDetails.topmostLocation); if (deepAccess(urlObj, 'search.medianet_test') || urlObj.hostname === 'localhost') { this.loggingPercent = 100; this.ajaxState = CONFIG_PASS; @@ -182,29 +186,22 @@ class Configure { class PageDetail { constructor () { - const canonicalUrl = this._getUrlFromSelector('link[rel="canonical"]', 'href'); const ogUrl = this._getUrlFromSelector('meta[property="og:url"]', 'content'); const twitterUrl = this._getUrlFromSelector('meta[name="twitter:url"]', 'content'); const refererInfo = getRefererInfo(); - this.domain = URL.parseUrl(refererInfo.referer).hostname; - this.page = refererInfo.referer; + // TODO: are these the right refererInfo values? + this.domain = refererInfo.domain; + this.page = refererInfo.page; this.is_top = refererInfo.reachedTop; - this.referrer = this._getTopWindowReferrer(); - this.canonical_url = canonicalUrl; + this.referrer = refererInfo.ref || window.document.referrer; + this.canonical_url = refererInfo.canonicalUrl; this.og_url = ogUrl; this.twitter_url = twitterUrl; + this.topmostLocation = refererInfo.topmostLocation; this.screen = this._getWindowSize(); } - _getTopWindowReferrer() { - try { - return window.top.document.referrer; - } catch (e) { - return document.referrer; - } - } - _getWindowSize() { let w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth || -1; let h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || -1; @@ -235,7 +232,7 @@ class PageDetail { getLoggingData() { return { - requrl: this[config.urlToConsume] || this.page, + requrl: this[config.urlToConsume] || this.topmostLocation, dn: this.domain, ref: this.referrer, screen: this.screen @@ -274,6 +271,52 @@ class AdSlot { } } +class BidWrapper { + constructor() { + this.bidReqs = []; + this.bidObjs = []; + } + + findReqBid(bidId) { + return this.bidReqs.find(bid => { + return bid['bidId'] === bidId + }); + } + + findBidObj(key, value) { + return this.bidObjs.find(bid => { + return bid[key] === value + }); + } + + addBidReq(bidRequest) { + this.bidReqs.push(bidRequest) + } + + addBidObj(bidObj) { + if (!(bidObj instanceof Bid)) { + bidObj = Bid.getInstance(bidObj); + } + const bidReq = this.findReqBid(bidObj.bidId); + if (bidReq instanceof Bid) { + bidReq.used = true; + } + this.bidObjs.push(bidObj); + } + + getAdSlotBids(adSlot) { + const bidResponses = this.getAdSlotBidObjs(adSlot); + return bidResponses.map((bid) => bid.getLoggingData()); + } + + getAdSlotBidObjs(adSlot) { + const bidResponses = this.bidObjs + .filter((bid) => bid.adUnitCode === adSlot); + const remResponses = this.bidReqs.filter(bid => !bid.used && bid.adUnitCode === adSlot); + return [...bidResponses, ...remResponses]; + } +} + class Bid { constructor(bidId, bidder, src, start, adUnitCode, mediaType, allMediaTypeSizes) { this.bidId = bidId; @@ -303,6 +346,9 @@ class Bid { this.floorPrice = undefined; this.floorRule = undefined; this.serverLatencyMillis = undefined; + this.used = false; + this.originalRequestId = bidId; + this.requestId = undefined; } get size() { @@ -312,8 +358,15 @@ class Bid { return this.width + 'x' + this.height; } + static getInstance(bidProps) { + const bidObj = new Bid(); + return bidProps && Object.assign(bidObj, bidProps); + } + getLoggingData() { return { + reqId: this.requestId || this.bidId, + ogReqId: this.originalRequestId, adid: this.adId, pvnm: this.bidder, src: this.src, @@ -345,7 +398,7 @@ class Auction { constructor(acid) { this.acid = acid; this.status = AUCTION_IN_PROGRESS; - this.bids = []; + this.bidWrapper = new BidWrapper(); this.adSlots = {}; this.auctionInitTime = undefined; this.auctionStartTime = undefined; @@ -382,28 +435,31 @@ class Auction { addSlot({ adUnitCode, supplyAdCode, mediaTypes, allMediaTypeSizes, tmax, adext, context }) { if (adUnitCode && this.adSlots[adUnitCode] === undefined) { this.adSlots[adUnitCode] = new AdSlot(tmax, supplyAdCode, context, adext); - this.addBid(new Bid('-1', DUMMY_BIDDER, 'client', '-1', adUnitCode, mediaTypes, allMediaTypeSizes)); + this.addBidObj(new Bid('-1', DUMMY_BIDDER, 'client', Date.now(), adUnitCode, mediaTypes, allMediaTypeSizes)); } } addBid(bid) { - this.bids.push(bid); + this.bidWrapper.addBidReq(bid); } - findBid(key, value) { - return this.bids.filter(bid => { - return bid[key] === value - })[0]; + addBidObj(bidObj) { + this.bidWrapper.addBidObj(bidObj) + } + + findReqBid(bidId) { + return this.bidWrapper.findReqBid(bidId) } - getAdslotBids(adslot) { - return this.bids - .filter((bid) => bid.adUnitCode === adslot) - .map((bid) => bid.getLoggingData()); + findBidObj(key, value) { + return this.bidWrapper.findBidObj(key, value) } - getWinnerAdslotBid(adslot) { - return this.getAdslotBids(adslot).filter((bid) => bid.winner); + getAdSlotBids(adSlot) { + return this.bidWrapper.getAdSlotBids(adSlot); + } + getAdSlotBidObjs(adSlot) { + return this.bidWrapper.getAdSlotBidObjs(adSlot); } _mergeFieldsToLog(objParams) { @@ -502,41 +558,26 @@ function _getSizes(mediaTypes, sizes) { } } -/* - - The code is used to determine if the current bid is higher than the previous bid. - - If it is, then the code will return true and if not, it will return false. - */ -function canSelectCurrentBid(previousBid, currentBid) { - if (!(previousBid instanceof Bid)) return false; - - // For first bid response the previous bid will be containing bid request obj - // in which the cpm would be undefined so the current bid can directly be selected. - const isFirstBidResponse = previousBid.cpm === undefined && currentBid.cpm !== undefined; - if (isFirstBidResponse) return true; - - // if there are 2 bids, get the highest bid - const selectedBid = getHighestCpm(previousBid, currentBid); - - // Return true if selectedBid is currentBid, - // The timeToRespond field is used as an identifier for distinguishing - // between the current iterating bid and the previous bid. - return selectedBid.timeToRespond === currentBid.timeToRespond; -} - function bidResponseHandler(bid) { - const { width, height, mediaType, cpm, requestId, timeToRespond, auctionId, dealId } = bid; - const {originalCpm, bidderCode, creativeId, adId, currency} = bid; + const { width, height, mediaType, cpm, requestId, timeToRespond, auctionId, dealId, originalRequestId, bidder } = bid; + const {originalCpm, creativeId, adId, currency} = bid; if (!(auctions[auctionId] instanceof Auction)) { return; } - let bidObj = auctions[auctionId].findBid('bidId', requestId); - if (!canSelectCurrentBid(bidObj, bid)) { - return; + const reqId = originalRequestId || requestId; + const bidReq = auctions[auctionId].findReqBid(reqId); + + if (!(bidReq instanceof Bid)) return; + + let bidObj = auctions[auctionId].findBidObj('bidId', requestId); + let isBidOverridden = true; + if (!bidObj || bidObj.status === BID_SUCCESS) { + bidObj = {}; + isBidOverridden = false; } - Object.assign( - bidObj, - { cpm, width, height, mediaType, timeToRespond, dealId, creativeId }, + Object.assign(bidObj, bidReq, + { cpm, width, height, mediaType, timeToRespond, dealId, creativeId, originalRequestId, requestId }, { adId, currency } ); bidObj.floorPrice = deepAccess(bid, 'floorData.floorValue'); @@ -555,7 +596,7 @@ function bidResponseHandler(bid) { bidObj.status = BID_SUCCESS; } - if (bidderCode === MEDIANET_BIDDER_CODE && bid.ext instanceof Object) { + if (bidder === MEDIANET_BIDDER_CODE && bid.ext instanceof Object) { Object.assign( bidObj, { 'ext': bid.ext }, @@ -566,6 +607,7 @@ function bidResponseHandler(bid) { if (typeof bid.serverResponseTimeMs !== 'undefined') { bidObj.serverLatencyMillis = bid.serverResponseTimeMs; } + !isBidOverridden && auctions[auctionId].addBidObj(bidObj); } function noBidResponseHandler({ auctionId, bidId }) { @@ -575,11 +617,13 @@ function noBidResponseHandler({ auctionId, bidId }) { if (auctions[auctionId].hasEnded()) { return; } - let bidObj = auctions[auctionId].findBid('bidId', bidId); - if (!(bidObj instanceof Bid)) { + const bidReq = auctions[auctionId].findReqBid(bidId); + if (!(bidReq instanceof Bid) || bidReq.used) { return; } + const bidObj = {...bidReq}; bidObj.status = BID_NOBID; + auctions[auctionId].addBidObj(bidObj); } function bidTimeoutHandler(timedOutBids) { @@ -587,11 +631,13 @@ function bidTimeoutHandler(timedOutBids) { if (!(auctions[auctionId] instanceof Auction)) { return; } - let bidObj = auctions[auctionId].findBid('bidId', bidId); - if (!(bidObj instanceof Bid)) { + const bidReq = auctions[auctionId].findReqBid('bidId', bidId); + if (!(bidReq instanceof Bid) || bidReq.used) { return; } + const bidObj = {...bidReq}; bidObj.status = BID_TIMEOUT; + auctions[auctionId].addBidObj(bidObj); }) } @@ -622,13 +668,13 @@ function setTargetingHandler(params) { const winnerAdId = params[adunit][CONSTANTS.TARGETING_KEYS.AD_ID]; let winningBid; let bidAdIds = Object.keys(targetingObj).map(k => targetingObj[k]); - auctionObj.bids.filter((bid) => bidAdIds.indexOf(bid.adId) !== -1).map(function(bid) { + auctionObj.bidWrapper.bidObjs.filter((bid) => bidAdIds.indexOf(bid.adId) !== -1).map(function(bid) { bid.iwb = 1; if (bid.adId === winnerAdId) { winningBid = bid; } }); - auctionObj.bids.forEach(bid => { + auctionObj.bidWrapper.bidObjs.forEach(bid => { if (bid.bidder === DUMMY_BIDDER && bid.adUnitCode === adunit) { bid.iwb = bidAdIds.length === 0 ? 0 : 1; bid.width = deepAccess(winningBid, 'width'); @@ -641,17 +687,33 @@ function setTargetingHandler(params) { } function bidWonHandler(bid) { - const { requestId, auctionId, adUnitCode } = bid; + const { auctionId, adUnitCode, adId, bidder, requestId, originalRequestId } = bid; if (!(auctions[auctionId] instanceof Auction)) { + new ErrorLogger(ERROR_WINNING_AUCTION_MISSING, { + adId, + auctionId, + adUnitCode, + bidder, + requestId, + originalRequestId + }).send(); return; } - let bidObj = auctions[auctionId].findBid('bidId', requestId); + let bidObj = auctions[auctionId].findBidObj('adId', adId); if (!(bidObj instanceof Bid)) { + new ErrorLogger(ERROR_WINNING_BID_ABSENT, { + adId, + auctionId, + adUnitCode, + bidder, + requestId, + originalRequestId + }).send(); return; } auctions[auctionId].bidWonTime = Date.now(); bidObj.winner = 1; - sendEvent(auctionId, adUnitCode, LOG_TYPE.RA); + sendEvent(auctionId, adUnitCode, LOG_TYPE.RA, bidObj.adId); } function isSampled() { @@ -662,12 +724,12 @@ function isValidAuctionAdSlot(acid, adtag) { return (auctions[acid] instanceof Auction) && (auctions[acid].adSlots[adtag] instanceof AdSlot); } -function sendEvent(id, adunit, logType) { +function sendEvent(id, adunit, logType, adId) { if (!isValidAuctionAdSlot(id, adunit)) { return; } if (logType === LOG_TYPE.RA) { - fireAuctionLog(id, adunit, logType); + fireAuctionLog(id, adunit, logType, adId); } else { fireApPrLog(id, adunit, logType) } @@ -688,7 +750,7 @@ function getCommonLoggingData(acid, adtag) { return Object.assign(commonParams, adunitParams, auctionParams); } -function fireAuctionLog(acid, adtag, logType) { +function fireAuctionLog(acid, adtag, logType, adId) { let commonParams = getCommonLoggingData(acid, adtag); commonParams.lgtp = logType; let targeting = deepAccess(commonParams, 'targ'); @@ -699,10 +761,13 @@ function fireAuctionLog(acid, adtag, logType) { let bidParams; if (logType === LOG_TYPE.RA) { - bidParams = auctions[acid].getWinnerAdslotBid(adtag); + const winningBidObj = auctions[acid].findBidObj('adId', adId); + if (!winningBidObj) return; + const winLogData = winningBidObj.getLoggingData(); + bidParams = [winLogData]; commonParams.lper = 1; } else { - bidParams = auctions[acid].getAdslotBids(adtag).map(({winner, ...restParams}) => restParams); + bidParams = auctions[acid].getAdSlotBids(adtag).map(({winner, ...restParams}) => restParams); delete commonParams.wts; } let mnetPresent = bidParams.filter(b => b.pvnm === MEDIANET_BIDDER_CODE).length > 0; @@ -767,8 +832,12 @@ let medianetAnalytics = Object.assign(adapter({URL, analyticsType}), { getlogsQueue() { return logsQueue; }, + getErrorQueue() { + return errorQueue; + }, clearlogsQueue() { logsQueue = []; + errorQueue = []; auctions = {}; }, track({ eventType, args }) { @@ -818,8 +887,8 @@ medianetAnalytics.enableAnalytics = function (configuration) { logError('Media.net Analytics adapter: cid is required.'); return; } - $$PREBID_GLOBAL$$.medianetGlobals = $$PREBID_GLOBAL$$.medianetGlobals || {}; - $$PREBID_GLOBAL$$.medianetGlobals.analyticsEnabled = true; + getGlobal().medianetGlobals = getGlobal().medianetGlobals || {}; + getGlobal().medianetGlobals.analyticsEnabled = true; pageDetails = new PageDetail(); diff --git a/modules/medianetBidAdapter.js b/modules/medianetBidAdapter.js index db3921c9a47..041db71cd34 100644 --- a/modules/medianetBidAdapter.js +++ b/modules/medianetBidAdapter.js @@ -1,12 +1,28 @@ -import { parseUrl, getWindowTop, isArray, getGptSlotInfoForAdUnitCode, isStr, deepAccess, isEmpty, logError, triggerPixel, buildUrl, isEmptyStr, logInfo } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import { getRefererInfo } from '../src/refererDetection.js'; -import { Renderer } from '../src/Renderer.js'; +import { + buildUrl, + deepAccess, + getWindowTop, + isArray, + isEmpty, + isEmptyStr, + isStr, + logError, + logInfo, + triggerPixel +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {Renderer} from '../src/Renderer.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const BIDDER_CODE = 'medianet'; +const TRUSTEDSTACK_CODE = 'trustedstack'; const BID_URL = 'https://prebid.media.net/rtb/prebid'; +const TRUSTEDSTACK_URL = 'https://prebid.trustedstack.com/rtb/trustedstack'; const PLAYER_URL = 'https://prebid.media.net/video/bundle.js'; const SLOT_VISIBILITY = { NOT_DETERMINED: 0, @@ -19,6 +35,8 @@ const EVENTS = { }; const EVENT_PIXEL_URL = 'qsearch-a.akamaihd.net/log'; const OUTSTREAM = 'outstream'; + +// TODO: this should be picked from bidderRequest let refererInfo = getRefererInfo(); let mnData = {}; @@ -27,12 +45,16 @@ window.mnet = window.mnet || {}; window.mnet.queue = window.mnet.queue || []; mnData.urlData = { - domain: parseUrl(refererInfo.referer).hostname, - page: refererInfo.referer, + domain: refererInfo.domain, + page: refererInfo.page, isTop: refererInfo.reachedTop -} +}; -$$PREBID_GLOBAL$$.medianetGlobals = $$PREBID_GLOBAL$$.medianetGlobals || {}; +const aliases = [ + { code: TRUSTEDSTACK_CODE }, +]; + +getGlobal().medianetGlobals = getGlobal().medianetGlobals || {}; function getTopWindowReferrer() { try { @@ -42,13 +64,15 @@ function getTopWindowReferrer() { } } -function siteDetails(site) { +function siteDetails(site, bidderRequest) { + const urlData = bidderRequest.refererInfo; site = site || {}; let siteData = { - domain: site.domain || mnData.urlData.domain, - page: site.page || mnData.urlData.page, + domain: site.domain || urlData.domain, + page: site.page || urlData.page, ref: site.ref || getTopWindowReferrer(), - isTop: site.isTop || mnData.urlData.isTop + topMostLocation: urlData.topmostLocation, + isTop: site.isTop || urlData.reachedTop }; return Object.assign(siteData, getPageMeta()); @@ -156,7 +180,7 @@ function extParams(bidRequest, bidderRequests) { const coppaApplies = !!(config.getConfig('coppa')); return Object.assign({}, { customer_id: params.cid }, - { prebid_version: $$PREBID_GLOBAL$$.version }, + { prebid_version: getGlobal().version }, { gdpr_applies: gdprApplies }, (gdprApplies) && { gdpr_consent_string: gdpr.consentString || '' }, { usp_applies: uspApplies }, @@ -164,7 +188,7 @@ function extParams(bidRequest, bidderRequests) { {coppa_applies: coppaApplies}, windowSize.w !== -1 && windowSize.h !== -1 && { screen: windowSize }, userId && { user_id: userId }, - $$PREBID_GLOBAL$$.medianetGlobals.analyticsEnabled && { analytics: true }, + getGlobal().medianetGlobals.analyticsEnabled && { analytics: true }, !isEmpty(sChain) && {schain: sChain} ); } @@ -173,6 +197,7 @@ function slotParams(bidRequest) { // check with Media.net Account manager for bid floor and crid parameters let params = { id: bidRequest.bidId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, ext: { dfp_id: bidRequest.adUnitCode, display_count: bidRequest.bidRequestsCount @@ -300,17 +325,20 @@ function normalizeCoordinates(coordinates) { } } -function getBidderURL(cid) { - return BID_URL + '?cid=' + encodeURIComponent(cid); +function getBidderURL(bidderCode, cid) { + const url = (bidderCode === TRUSTEDSTACK_CODE) ? TRUSTEDSTACK_URL : BID_URL; + return url + '?cid=' + encodeURIComponent(cid); } function generatePayload(bidRequests, bidderRequests) { return { - site: siteDetails(bidRequests[0].params.site), + site: siteDetails(bidRequests[0].params.site, bidderRequests), ext: extParams(bidRequests[0], bidderRequests), + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 id: bidRequests[0].auctionId, imp: bidRequests.map(request => slotParams(request)), - tmax: bidderRequests.timeout || config.getConfig('bidderTimeout') + ortb2: bidderRequests.ortb2, + tmax: bidderRequests.timeout } } @@ -335,7 +363,7 @@ function getLoggingData(event, data) { params.evtid = 'projectevents'; params.project = 'prebid'; params.acid = deepAccess(data, '0.auctionId') || ''; - params.cid = $$PREBID_GLOBAL$$.medianetGlobals.cid || ''; + params.cid = getGlobal().medianetGlobals.cid || ''; params.crid = data.map((adunit) => deepAccess(adunit, 'params.0.crid') || adunit.adUnitCode).join('|'); params.adunit_count = data.length || 0; params.dn = mnData.urlData.domain || ''; @@ -399,7 +427,7 @@ export const spec = { code: BIDDER_CODE, gvlid: 142, - + aliases, supportedMediaTypes: [BANNER, NATIVE, VIDEO], /** @@ -419,7 +447,7 @@ export const spec = { return false; } - Object.assign($$PREBID_GLOBAL$$.medianetGlobals, !$$PREBID_GLOBAL$$.medianetGlobals.cid && {cid: bid.params.cid}); + Object.assign(getGlobal().medianetGlobals, !getGlobal().medianetGlobals.cid && {cid: bid.params.cid}); return true; }, @@ -432,10 +460,13 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(bidRequests, bidderRequests) { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + let payload = generatePayload(bidRequests, bidderRequests); return { method: 'POST', - url: getBidderURL(payload.ext.customer_id), + url: getBidderURL(bidderRequests.bidderCode, payload.ext.customer_id), data: JSON.stringify(payload) }; }, diff --git a/modules/medianetRtdProvider.js b/modules/medianetRtdProvider.js index 07b1d66fbc5..5a159b39081 100644 --- a/modules/medianetRtdProvider.js +++ b/modules/medianetRtdProvider.js @@ -1,4 +1,5 @@ -import {insertElement, isEmptyStr, isFn, isStr, logError, mergeDeep} from '../src/utils.js'; +import {isEmptyStr, isFn, isStr, logError, mergeDeep} from '../src/utils.js'; +import {loadExternalScript} from '../src/adloader.js'; import {submodule} from '../src/hook.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {includes} from '../src/polyfill.js'; @@ -58,14 +59,14 @@ function onAuctionInitEvent(auctionInit) { }, SOURCE)); } -function getTargetingData(adUnitCode) { - const adUnits = getAdUnits(undefined, adUnitCode); +function getTargetingData(adUnitCodes, config, consent, auction) { + const adUnits = getAdUnits(auction.adUnits, adUnitCodes); let targetingData = {}; if (window.mnjs.loaded && isFn(window.mnjs.getTargetingData)) { - targetingData = window.mnjs.getTargetingData(adUnitCode, adUnits, SOURCE) || {}; + targetingData = window.mnjs.getTargetingData(adUnitCodes, adUnits, SOURCE) || {}; } const targeting = {}; - adUnitCode.forEach(adUnitCode => { + adUnitCodes.forEach(adUnitCode => { targeting[adUnitCode] = targeting[adUnitCode] || {}; targetingData[adUnitCode] = targetingData[adUnitCode] || {}; targeting[adUnitCode] = { @@ -82,11 +83,8 @@ function executeCommand(command) { } function loadRtdScript(customerId) { - const script = document.createElement('script'); - script.type = 'text/javascript'; - script.async = true; - script.src = getClientUrl(customerId, window.location.hostname); - insertElement(script, window.document, 'head'); + const url = getClientUrl(customerId, window.location.hostname); + loadExternalScript(url, MODULE_NAME) } function getAdUnits(adUnits, adUnitCodes) { diff --git a/modules/mediasniperBidAdapter.js b/modules/mediasniperBidAdapter.js index 3e57503f7fb..aee5f6230b2 100644 --- a/modules/mediasniperBidAdapter.js +++ b/modules/mediasniperBidAdapter.js @@ -1,24 +1,21 @@ import { deepAccess, deepClone, - deepSetValue, - getWindowTop, + deepSetValue, getBidIdParameter, inIframe, isArray, isEmpty, isFn, isNumber, isStr, - logWarn, logError, logMessage, - parseUrl, - getBidIdParameter, + logWarn, triggerPixel, } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'mediasniper'; const DEFAULT_BID_TTL = 360; @@ -61,7 +58,7 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { const payload = createOrtbTemplate(); - deepSetValue(payload, 'id', bidderRequest.auctionId); + deepSetValue(payload, 'id', bidderRequest.bidderRequestId); validBidRequests.forEach((validBid) => { let bid = deepClone(validBid); @@ -76,19 +73,18 @@ export const spec = { // Assign payload.site from refererinfo if (bidderRequest.refererInfo) { + // TODO: reachedTop is probably not the right check - it may be false when page is available or vice-versa if (bidderRequest.refererInfo.reachedTop) { - const sitePage = bidderRequest.refererInfo.referer; + const sitePage = bidderRequest.refererInfo.page; deepSetValue(payload, 'site.page', sitePage); deepSetValue( payload, 'site.domain', - parseUrl(sitePage, { - noDecodeWholeURL: true, - }).hostname + bidderRequest.refererInfo.domain ); - if (canAccessTopWindow()) { - deepSetValue(payload, 'site.ref', getWindowTop().document.referrer); + if (bidderRequest.refererInfo?.ref) { + deepSetValue(payload, 'site.ref', bidderRequest.refererInfo.ref); } } } @@ -119,7 +115,6 @@ export const spec = { bidderSeat.bid.forEach((bid) => { const newBid = { requestId: bid.impid, - bidderCode: spec.code, cpm: bid.price || 0, width: bid.w, height: bid.h, @@ -165,19 +160,6 @@ export const spec = { }; registerBidder(spec); -/** - * Detects the capability to reach window.top. - * - * @returns {boolean} - */ -function canAccessTopWindow() { - try { - return !!getWindowTop().location.href; - } catch (error) { - return false; - } -} - /** * Returns an openRTB 2.5 object. * This one will be populated at each step of the buildRequest process. diff --git a/modules/mediasquareBidAdapter.js b/modules/mediasquareBidAdapter.js index 427a16f1341..87404b7a9ff 100644 --- a/modules/mediasquareBidAdapter.js +++ b/modules/mediasquareBidAdapter.js @@ -2,6 +2,9 @@ import {ajax} from '../src/ajax.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import {Renderer} from '../src/Renderer.js'; +import { getRefererInfo } from '../src/refererDetection.js'; const BIDDER_CODE = 'mediasquare'; const BIDDER_URL_PROD = 'https://pbs-front.mediasquare.fr/' @@ -9,6 +12,8 @@ const BIDDER_URL_TEST = 'https://bidder-test.mediasquare.fr/' const BIDDER_ENDPOINT_AUCTION = 'msq_prebid'; const BIDDER_ENDPOINT_WINNING = 'winning'; +const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; + export const spec = { code: BIDDER_CODE, gvlid: 791, @@ -30,32 +35,41 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let codes = []; let endpoint = document.location.search.match(/msq_test=true/) ? BIDDER_URL_TEST : BIDDER_URL_PROD; let floor = {}; const test = config.getConfig('debug') ? 1 : 0; let adunitValue = null; Object.keys(validBidRequests).forEach(key => { + floor = {}; adunitValue = validBidRequests[key]; if (typeof adunitValue.getFloor === 'function') { - floor = adunitValue.getFloor({currency: 'EUR', mediaType: '*', size: '*'}); - } else { - floor = {}; + if (Array.isArray(adunitValue.sizes)) { + adunitValue.sizes.forEach(value => { + let tmpFloor = adunitValue.getFloor({currency: 'USD', mediaType: '*', size: value}); + if (tmpFloor != {}) { floor[value.join('x')] = tmpFloor; } + }); + } } codes.push({ owner: adunitValue.params.owner, code: adunitValue.params.code, adunit: adunitValue.adUnitCode, bidId: adunitValue.bidId, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: adunitValue.auctionId, - transactionId: adunitValue.transactionId, + transactionId: adunitValue.ortb2Imp?.ext?.tid, mediatypes: adunitValue.mediaTypes, floor: floor }); }); const payload = { codes: codes, - referer: encodeURIComponent(bidderRequest.refererInfo.referer), + // TODO: is 'page' the right value here? + referer: encodeURIComponent(bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation), pbjs: '$prebid.version$' }; if (bidderRequest) { // modules informations (gdpr, ccpa, schain, userId) @@ -106,20 +120,17 @@ export const spec = { netRevenue: value['net_revenue'], ttl: value['ttl'], ad: value['ad'], - mediasquare: { - 'bidder': value['bidder'], - 'code': value['code'] - }, + mediasquare: {}, meta: { 'advertiserDomains': value['adomain'] } }; - if ('match' in value) { - bidResponse['mediasquare']['match'] = value['match']; - } - if ('hasConsent' in value) { - bidResponse['mediasquare']['hasConsent'] = value['hasConsent']; - } + let paramsToSearchFor = ['bidder', 'code', 'match', 'hasConsent', 'context', 'increment']; + paramsToSearchFor.forEach(param => { + if (param in value) { + bidResponse['mediasquare'][param] = value[param]; + } + }); if ('native' in value) { bidResponse['native'] = value['native']; bidResponse['mediaType'] = 'native'; @@ -127,6 +138,7 @@ export const spec = { if ('url' in value['video']) { bidResponse['vastUrl'] = value['video']['url'] } if ('xml' in value['video']) { bidResponse['vastXml'] = value['video']['xml'] } bidResponse['mediaType'] = 'video'; + bidResponse['renderer'] = createRenderer(value, OUTSTREAM_RENDERER_URL); } if (value.hasOwnProperty('deal_id')) { bidResponse['dealId'] = value['deal_id']; } bidResponses.push(bidResponse); @@ -157,24 +169,65 @@ export const spec = { */ onBidWon: function(bid) { // fires a pixel to confirm a winning bid - let params = {'pbjs': '$prebid.version$'}; + if (bid.hasOwnProperty('mediaType') && bid.mediaType == 'video') { + return; + } + let params = { pbjs: '$prebid.version$', referer: encodeURIComponent(getRefererInfo().page || getRefererInfo().topmostLocation) }; let endpoint = document.location.search.match(/msq_test=true/) ? BIDDER_URL_TEST : BIDDER_URL_PROD; - let paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond', 'requestId', 'auctionId'] + let paramsToSearchFor = ['bidder', 'code', 'match', 'hasConsent', 'context', 'increment']; if (bid.hasOwnProperty('mediasquare')) { - if (bid['mediasquare'].hasOwnProperty('bidder')) { params['bidder'] = bid['mediasquare']['bidder']; } - if (bid['mediasquare'].hasOwnProperty('code')) { params['code'] = bid['mediasquare']['code']; } - if (bid['mediasquare'].hasOwnProperty('match')) { params['match'] = bid['mediasquare']['match']; } - if (bid['mediasquare'].hasOwnProperty('hasConsent')) { params['hasConsent'] = bid['mediasquare']['hasConsent']; } + paramsToSearchFor.forEach(param => { + if (bid['mediasquare'].hasOwnProperty(param)) { + params[param] = bid['mediasquare'][param]; + if (typeof params[param] == 'number') { + params[param] = params[param].toString(); + } + } + }); }; - for (let i = 0; i < paramsToSearchFor.length; i++) { - if (bid.hasOwnProperty(paramsToSearchFor[i])) { - params[paramsToSearchFor[i]] = bid[paramsToSearchFor[i]]; - if (typeof params[paramsToSearchFor[i]] == 'number') { params[paramsToSearchFor[i]] = params[paramsToSearchFor[i]].toString() } + paramsToSearchFor = ['cpm', 'size', 'mediaType', 'currency', 'creativeId', 'adUnitCode', 'timeToRespond', 'requestId', 'auctionId', 'originalCpm', 'originalCurrency']; + paramsToSearchFor.forEach(param => { + if (bid.hasOwnProperty(param)) { + params[param] = bid[param]; + if (typeof params[param] == 'number') { + params[param] = params[param].toString(); + } } - } + }); ajax(endpoint + BIDDER_ENDPOINT_WINNING, null, JSON.stringify(params), {method: 'POST', withCredentials: true}); return true; } } + +function outstreamRender(bid) { + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: [bid.width, bid.height], + targetId: bid.adUnitCode, + adResponse: bid.adResponse, + rendererOptions: { + showBigPlayButton: false, + showProgressBar: 'bar', + showVolume: false, + allowFullscreen: true, + skippable: false, + content: bid.vastXml + } + }); + }); +} + +function createRenderer(bid, url) { + const renderer = Renderer.install({ + id: bid.bidId, + url: url, + loaded: false, + adUnitCode: bid.adUnitCode, + targetId: bid.adUnitCode + }); + renderer.setRender(outstreamRender); + return renderer; +} + registerBidder(spec); diff --git a/modules/merkleIdSystem.js b/modules/merkleIdSystem.js index 352c2d074e8..fc77c7cc97d 100644 --- a/modules/merkleIdSystem.js +++ b/modules/merkleIdSystem.js @@ -9,13 +9,14 @@ import { logInfo, logError, logWarn } from '../src/utils.js'; import * as ajaxLib from '../src/ajax.js'; import {submodule} from '../src/hook.js' import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'merkleId'; -const ID_URL = 'https://id2.sv.rkdms.com/identity/'; +const ID_URL = 'https://prebid.sv.rkdms.com/identity/'; const DEFAULT_REFRESH = 7 * 3600; const SESSION_COOKIE_NAME = '_svsid'; -export const storage = getStorageManager(); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); function getSession(configParams) { let session = null; @@ -30,19 +31,19 @@ function getSession(configParams) { function setCookie(name, value, expires) { let expTime = new Date(); expTime.setTime(expTime.getTime() + expires * 1000 * 60); - storage.setCookie(name, value, expTime.toUTCString()); + storage.setCookie(name, value, expTime.toUTCString(), 'Lax'); } function setSession(storage, response) { - logInfo('Merkle setting session '); - if (response && response.c && response.c.value && typeof response.c.value === 'string') { - setCookie(SESSION_COOKIE_NAME, response.c.value, storage.expires); + logInfo('Merkle setting ' + `${SESSION_COOKIE_NAME}`); + if (response && response[SESSION_COOKIE_NAME] && typeof response[SESSION_COOKIE_NAME] === 'string') { + setCookie(SESSION_COOKIE_NAME, response[SESSION_COOKIE_NAME], storage.expires); } } function constructUrl(configParams) { const session = getSession(configParams); - let url = configParams.endpoint + `?vendor=${configParams.vendor}&sv_cid=${configParams.sv_cid}&sv_domain=${configParams.sv_domain}&sv_pubid=${configParams.sv_pubid}`; + let url = configParams.endpoint + `?sv_domain=${configParams.sv_domain}&sv_pubid=${configParams.sv_pubid}&ssp_ids=${configParams.ssp_ids.join()}`; if (session) { url = `${url}&sv_session=${session}`; } @@ -86,45 +87,52 @@ function generateId(configParams, configStorage) { /** @type {Submodule} */ export const merkleIdSubmodule = { /** - * used to link submodule with config - * @type {string} - */ + * used to link submodule with config + * @type {string} + */ name: MODULE_NAME, + /** - * decode the stored id value for passing to bid requests - * @function - * @param {string} value - * @returns {{merkleId:string}} - */ + * decode the stored id value for passing to bid requests + * @function + * @param {string} value + * @returns {{eids:arrayofields}} + */ decode(value) { + // Legacy support for a single id const id = (value && value.pam_id && typeof value.pam_id.id === 'string') ? value.pam_id : undefined; logInfo('Merkle id ' + JSON.stringify(id)); - return id ? {'merkleId': id} : undefined; + + if (id) { + return {'merkleId': id} + } + + // Supports multiple IDs for different SSPs + const merkleIds = (value && value?.merkleId && Array.isArray(value.merkleId)) ? value.merkleId : undefined; + logInfo('merkleIds: ' + JSON.stringify(merkleIds)); + + return merkleIds ? {'merkleId': merkleIds} : undefined; }, + /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleConfig} [config] - * @param {ConsentData} [consentData] - * @returns {IdResponse|undefined} - */ + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} [config] + * @param {ConsentData} [consentData] + * @returns {IdResponse|undefined} + */ getId(config, consentData) { logInfo('User ID - merkleId generating id'); const configParams = (config && config.params) || {}; - if (!configParams || typeof configParams.vendor !== 'string') { - logError('User ID - merkleId submodule requires a valid vendor to be defined'); - return; - } - - if (typeof configParams.sv_cid !== 'string') { - logError('User ID - merkleId submodule requires a valid sv_cid string to be defined'); + if (typeof configParams.sv_pubid !== 'string') { + logError('User ID - merkleId submodule requires a valid sv_pubid string to be defined'); return; } - if (typeof configParams.sv_pubid !== 'string') { - logError('User ID - merkleId submodule requires a valid sv_pubid string to be defined'); + if (!Array.isArray(configParams.ssp_ids)) { + logError('User ID - merkleId submodule requires a valid ssp_ids array to be defined'); return; } @@ -132,6 +140,7 @@ export const merkleIdSubmodule = { logError('User ID - merkleId submodule does not currently handle consent strings'); return; } + if (typeof configParams.endpoint !== 'string') { logWarn('User ID - merkleId submodule endpoint string is not defined'); configParams.endpoint = ID_URL @@ -146,12 +155,12 @@ export const merkleIdSubmodule = { return {callback: resp}; }, extendId: function (config = {}, consentData, storedId) { - logInfo('User ID - merkleId stored id ' + storedId); + logInfo('User ID - stored id ' + storedId); const configParams = (config && config.params) || {}; if (typeof configParams.endpoint !== 'string') { logWarn('User ID - merkleId submodule endpoint string is not defined'); - configParams.endpoint = ID_URL + configParams.endpoint = ID_URL; } if (consentData && typeof consentData.gdprApplies === 'boolean' && consentData.gdprApplies) { @@ -162,27 +171,55 @@ export const merkleIdSubmodule = { if (typeof configParams.sv_domain !== 'string') { configParams.sv_domain = merkleIdSubmodule.findRootDomain(); } + const configStorage = (config && config.storage) || {}; if (configStorage && configStorage.refreshInSeconds && typeof configParams.refreshInSeconds === 'number') { return {id: storedId}; } + let refreshInSeconds = DEFAULT_REFRESH; if (configParams && configParams.refreshInSeconds && typeof configParams.refreshInSeconds === 'number') { refreshInSeconds = configParams.refreshInSeconds; logInfo('User ID - merkleId param refreshInSeconds' + refreshInSeconds); } + const storedDate = new Date(storedId.date); let refreshNeeded = false; if (storedDate) { refreshNeeded = storedDate && (Date.now() - storedDate.getTime() > refreshInSeconds * 1000); if (refreshNeeded) { logInfo('User ID - merkleId needs refreshing id'); - const resp = generateId(configParams, configStorage) + const resp = generateId(configParams, configStorage); return {callback: resp}; } } + logInfo('User ID - merkleId not refreshed'); return {id: storedId}; + }, + eids: { + 'merkleId': { + atype: 3, + getSource: function(data) { + if (data?.ext?.ssp) { + return `${data.ext.ssp}.merkleinc.com` + } + return 'merkleinc.com' + }, + getValue: function(data) { + return data.id; + }, + getUidExt: function(data) { + if (data.keyID) { + return { + keyID: data.keyID + } + } + if (data.ext) { + return data.ext; + } + } + }, } }; diff --git a/modules/mgidBidAdapter.js b/modules/mgidBidAdapter.js index 51b713c8958..1e158236deb 100644 --- a/modules/mgidBidAdapter.js +++ b/modules/mgidBidAdapter.js @@ -1,13 +1,30 @@ -import { _each, deepAccess, isPlainObject, isArray, isStr, logInfo, parseUrl, isEmpty, triggerPixel, logWarn, getBidIdParameter, isFn, isNumber } from '../src/utils.js'; +import { + _each, + deepAccess, + isPlainObject, + isArray, + isStr, + logInfo, + parseUrl, + isEmpty, + triggerPixel, + logWarn, + isFn, + isNumber, + isBoolean, + isInteger, deepSetValue, getBidIdParameter, +} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import { getStorageManager } from '../src/storageManager.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import {USERSYNC_DEFAULT_CONFIG} from '../src/userSync.js'; const GVLID = 358; const DEFAULT_CUR = 'USD'; const BIDDER_CODE = 'mgid'; -export const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); const ENDPOINT_URL = 'https://prebid.mgid.com/prebid/'; const LOG_WARN_PREFIX = '[MGID warn]: '; const LOG_INFO_PREFIX = '[MGID info]: '; @@ -63,8 +80,9 @@ _each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_ID_TO_KEY_MAP[anAsset.ID] = anAs _each(NATIVE_ASSETS, anAsset => { _NATIVE_ASSET_KEY_TO_ASSET_MAP[anAsset.KEY] = anAsset }); export const spec = { - VERSION: '1.5', + VERSION: '1.6', code: BIDDER_CODE, + gvlid: GVLID, supportedMediaTypes: [BANNER, NATIVE], reId: /^[1-9][0-9]*$/, NATIVE_ASSET_ID_TO_KEY_MAP: _NATIVE_ASSET_ID_TO_KEY_MAP, @@ -87,7 +105,7 @@ export const spec = { let v = nativeParams[k]; const supportProp = spec.NATIVE_ASSET_KEY_TO_ASSET_MAP.hasOwnProperty(k); if (supportProp) { - assetsCount++ + assetsCount++; } if (!isPlainObject(v) || (!supportProp && deepAccess(v, 'required'))) { nativeOk = false; @@ -113,18 +131,19 @@ export const spec = { /** * Make a server request from the list of BidRequests. * - * @param {validBidRequests[]} - an array of bids + * @param {BidRequest[]} validBidRequests A non-empty list of bid requests which should be sent to the Server. + * @param bidderRequest * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const [bidRequest] = validBidRequests; logInfo(LOG_INFO_PREFIX + `buildRequests`); if (validBidRequests.length === 0) { return; } const info = pageInfo(); - const page = info.location || deepAccess(bidderRequest, 'refererInfo.referer') || deepAccess(bidderRequest, 'refererInfo.canonicalUrl'); - const hostname = parseUrl(page).hostname; - let domain = extractDomainFromHost(hostname) || hostname; const accountId = setOnAny(validBidRequests, 'params.accountId'); const muid = getLocalStorageSafely('mgMuidn'); let url = (setOnAny(validBidRequests, 'params.bidUrl') || ENDPOINT_URL) + accountId; @@ -147,7 +166,7 @@ export const spec = { impObj.bidfloor = floorData.floor; } if (floorData.cur) { - impObj.bidfloorcur = floorData.cur + impObj.bidfloorcur = floorData.cur; } for (let mediaTypes in bid.mediaTypes) { switch (mediaTypes) { @@ -172,29 +191,112 @@ export const spec = { return; } + const ortb2Data = bidderRequest?.ortb2 || {}; + let request = { id: deepAccess(bidderRequest, 'bidderRequestId'), - site: {domain, page}, + site: ortb2Data?.site || {}, cur: [cur], geo: {utcoffset: info.timeOffset}, - device: { - ua: navigator.userAgent, - js: 1, - dnt: (navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1' || navigator.msDoNotTrack === '1') ? 1 : 0, - h: screen.height, - w: screen.width, - language: getLanguage() + device: ortb2Data?.device || {}, + ext: { + mgid_ver: spec.VERSION, + prebid_ver: '$prebid.version$', }, - ext: {mgid_ver: spec.VERSION, prebid_ver: '$prebid.version$'}, - imp + imp, + tmax: bidderRequest?.timeout || config.getConfig('bidderTimeout') || 500, }; - if (bidderRequest && bidderRequest.gdprConsent) { - request.user = {ext: {consent: bidderRequest.gdprConsent.consentString}}; - request.regs = {ext: {gdpr: (bidderRequest.gdprConsent.gdprApplies ? 1 : 0)}} + // request level + const bcat = ortb2Data?.bcat || bidRequest?.params?.bcat || []; + const badv = ortb2Data?.badv || bidRequest?.params?.badv || []; + const wlang = ortb2Data?.wlang || bidRequest?.params?.wlang || []; + if (bcat.length > 0) { + request.bcat = bcat; + } + if (badv.length > 0) { + request.badv = badv; + } + if (wlang.length > 0) { + request.wlang = wlang; + } + // site level + const page = deepAccess(bidderRequest, 'refererInfo.page') || info.location + if (!isStr(deepAccess(request.site, 'domain'))) { + const hostname = parseUrl(page).hostname; + request.site.domain = extractDomainFromHost(hostname) || hostname + } + if (!isStr(deepAccess(request.site, 'page'))) { + request.site.page = page + } + if (!isStr(deepAccess(request.site, 'ref'))) { + const ref = deepAccess(bidderRequest, 'refererInfo.ref') || info.referrer; + if (ref) { + request.site.ref = ref + } + } + // device level + if (!isStr(deepAccess(request.device, 'ua'))) { + request.device.ua = navigator.userAgent; + } + request.device.js = 1; + if (!isInteger(deepAccess(request.device, 'dnt'))) { + request.device.dnt = (navigator?.doNotTrack === 'yes' || navigator?.doNotTrack === '1' || navigator?.msDoNotTrack === '1') ? 1 : 0; + } + if (!isInteger(deepAccess(request.device, 'h'))) { + request.device.h = screen.height; + } + if (!isInteger(deepAccess(request.device, 'w'))) { + request.device.w = screen.width; + } + if (!isStr(deepAccess(request.device, 'language'))) { + request.device.language = getLanguage(); + } + // user & regs & privacy + if (isPlainObject(ortb2Data?.user)) { + request.user = ortb2Data.user; + } + if (isPlainObject(ortb2Data?.regs)) { + request.regs = ortb2Data.regs; + } + if (bidderRequest && isPlainObject(bidderRequest.gdprConsent)) { + if (!isStr(deepAccess(request.user, 'ext.consent'))) { + deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent?.consentString); + } + if (!isBoolean(deepAccess(request.regs, 'ext.gdpr'))) { + deepSetValue(request, 'regs.ext.gdpr', bidderRequest.gdprConsent?.gdprApplies ? 1 : 0); + } + } + const userId = deepAccess(bidderRequest, 'userId') + if (isStr(userId)) { + deepSetValue(request, 'user.id', userId); + } + const eids = setOnAny(validBidRequests, 'userIdAsEids') + if (eids && eids.length > 0) { + deepSetValue(request, 'user.ext.eids', eids); + } + if (bidderRequest && isStr(bidderRequest.uspConsent)) { + if (!isBoolean(deepAccess(request.regs, 'ext.us_privacy'))) { + deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } + } + if (bidderRequest && isPlainObject(bidderRequest.gppConsent)) { + if (!isStr(deepAccess(request.regs, 'gpp'))) { + deepSetValue(request, 'regs.gpp', bidderRequest.gppConsent?.gppString); + } + if (!isArray(deepAccess(request.regs, 'gpp_sid'))) { + deepSetValue(request, 'regs.gpp_sid', bidderRequest.gppConsent?.applicableSections); + } + } + if (config.getConfig('coppa')) { + if (!isInteger(deepAccess(request.regs, 'coppa'))) { + deepSetValue(request, 'regs.coppa', 1); + } } - if (info.referrer) { - request.site.ref = info.referrer + const schain = setOnAny(validBidRequests, 'schain'); + if (schain) { + deepSetValue(request, 'source.ext.schain', schain); } + logInfo(LOG_INFO_PREFIX + `buildRequest:`, request); return { method: 'POST', @@ -206,6 +308,7 @@ export const spec = { * Unpack the response from the server into a list of bids. * * @param {ServerResponse} serverResponse A successful response from the server. + * @param bidRequests * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: (serverResponse, bidRequests) => { @@ -256,8 +359,67 @@ export const spec = { } logInfo(LOG_INFO_PREFIX + `onBidWon`); }, - getUserSyncs: (syncOptions, serverResponses) => { + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => { logInfo(LOG_INFO_PREFIX + `getUserSyncs`); + const spb = isPlainObject(config.getConfig('userSync')) && + isNumber(config.getConfig('userSync').syncsPerBidder) + ? config.getConfig('userSync').syncsPerBidder : USERSYNC_DEFAULT_CONFIG.syncsPerBidder; + + if (spb > 0 && isPlainObject(syncOptions) && (syncOptions.iframeEnabled || syncOptions.pixelEnabled)) { + let pixels = []; + if (serverResponses && + isArray(serverResponses) && + serverResponses.length > 0 && + isPlainObject(serverResponses[0].body) && + isPlainObject(serverResponses[0].body.ext) && + isArray(serverResponses[0].body.ext.cm) && + serverResponses[0].body.ext.cm.length > 0) { + pixels = serverResponses[0].body.ext.cm; + } + + const syncs = []; + const query = []; + query.push('cbuster={cbuster}'); + query.push('gdpr_consent=' + encodeURIComponent(isPlainObject(gdprConsent) && isStr(gdprConsent?.consentString) ? gdprConsent.consentString : '')); + if (isPlainObject(gdprConsent) && typeof gdprConsent?.gdprApplies === 'boolean' && gdprConsent.gdprApplies) { + query.push('gdpr=1'); + } else { + query.push('gdpr=0'); + } + if (isPlainObject(uspConsent) && uspConsent?.consentString) { + query.push(`us_privacy=${encodeURIComponent(uspConsent?.consentString)}`); + } + if (isPlainObject(gppConsent) && gppConsent?.gppString) { + query.push(`gppString=${encodeURIComponent(gppConsent?.gppString)}`); + } + if (config.getConfig('coppa')) { + query.push('coppa=1') + } + const q = query.join('&') + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: 'https://cm.mgid.com/i.html?' + q.replace('{cbuster}', Math.round(new Date().getTime())) + }); + } else if (syncOptions.pixelEnabled) { + if (pixels.length === 0) { + for (let i = 0; i < spb; i++) { + syncs.push({ + type: 'image', + url: 'https://cm.mgid.com/i.gif?' + q.replace('{cbuster}', Math.round(new Date().getTime())) // randomly selects partner if sync required + }); + } + } else { + for (let i = 0; i < spb && i < pixels.length; i++) { + syncs.push({ + type: 'image', + url: pixels[i] + (pixels[i].indexOf('?') > 0 ? '&' : '?') + q.replace('{cbuster}', Math.round(new Date().getTime())) + }); + } + } + } + return syncs; + } } }; @@ -275,6 +437,7 @@ function setOnAny(collection, key) { /** * Unpack the Server's Bid into a Prebid-compatible one. * @param serverBid + * @param cur * @return Bid */ function prebidBid(serverBid, cur) { @@ -318,7 +481,7 @@ function setMediaType(bid, newBid) { } function extractDomainFromHost(pageHost) { - if (pageHost == 'localhost') { + if (pageHost === 'localhost') { return 'localhost' } let domain = null; @@ -588,6 +751,7 @@ function pageInfo() { * Get the floor price from bid.params for backward compatibility. * If not found, then check floor module. * @param bid A valid bid object + * @param cur * @returns {*|number} floor price */ function getBidFloor(bid, cur) { diff --git a/modules/mgidRtdProvider.js b/modules/mgidRtdProvider.js new file mode 100644 index 00000000000..fd2c0bbe6fd --- /dev/null +++ b/modules/mgidRtdProvider.js @@ -0,0 +1,192 @@ +import { submodule } from '../src/hook.js'; +import {ajax} from '../src/ajax.js'; +import {deepAccess, logError, logInfo, mergeDeep} from '../src/utils.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; + +const MODULE_NAME = 'realTimeData'; +const SUBMODULE_NAME = 'mgid'; +const MGID_RTD_API_URL = 'https://servicer.mgid.com/sda'; +const MGUID_LOCAL_STORAGE_KEY = 'mguid'; +const ORTB2_NAME = 'www.mgid.com' + +const GVLID = 358; +/** @type {?Object} */ +export const storage = getStorageManager({ + moduleType: MODULE_TYPE_RTD, + moduleName: SUBMODULE_NAME +}); + +function init(moduleConfig) { + if (!moduleConfig?.params?.clientSiteId) { + logError('Mgid clientSiteId is not set!'); + return false; + } + return true; +} + +function getBidRequestData(reqBidsConfigObj, onDone, moduleConfig, userConsent) { + let mguid; + try { + mguid = storage.getDataFromLocalStorage(MGUID_LOCAL_STORAGE_KEY); + } catch (e) { + logInfo(`Can't get mguid from localstorage`); + } + + const params = [ + { + name: 'gdprApplies', + data: typeof userConsent?.gdpr?.gdprApplies !== 'undefined' ? userConsent?.gdpr?.gdprApplies + '' : undefined, + }, + { + name: 'consentData', + data: userConsent?.gdpr?.consentString, + }, + { + name: 'uspString', + data: userConsent?.usp, + }, + { + name: 'cxurl', + data: encodeURIComponent(getContextUrl()), + }, + { + name: 'muid', + data: mguid, + }, + { + name: 'clientSiteId', + data: moduleConfig?.params?.clientSiteId, + }, + { + name: 'cxlang', + data: deepAccess(reqBidsConfigObj.ortb2Fragments.global, 'site.content.language'), + }, + ]; + + const url = MGID_RTD_API_URL + '?' + params.filter((p) => p.data).map((p) => p.name + '=' + p.data).join('&'); + + let isDone = false; + + ajax(url, { + success: (response, req) => { + if (req.status === 200) { + try { + const data = JSON.parse(response); + const ortb2 = reqBidsConfigObj?.ortb2Fragments?.global || {}; + + mergeDeep(ortb2, getDataForMerge(data)); + + if (data?.muid) { + try { + mguid = storage.setDataInLocalStorage(MGUID_LOCAL_STORAGE_KEY, data.muid); + } catch (e) { + logInfo(`Can't set mguid to localstorage`); + } + } + + onDone(); + isDone = true; + } catch (e) { + onDone(); + isDone = true; + + logError('Unable to parse Mgid RTD data', e); + } + } else { + onDone(); + isDone = true; + + logError('Mgid RTD wrong response status'); + } + }, + error: () => { + onDone(); + isDone = true; + + logError('Unable to get Mgid RTD data'); + } + }, + null, { + method: 'GET', + withCredentials: false, + }); + + setTimeout(function () { + if (!isDone) { + onDone(); + logInfo('Mgid RTD timeout'); + isDone = true; + } + }, moduleConfig.params.timeout || 1000); +} + +function getContextUrl() { + const refererInfo = getRefererInfo(); + + let resultUrl = refererInfo.canonicalUrl || refererInfo.topmostLocation; + + const metaElements = document.getElementsByTagName('meta'); + for (let i = 0; i < metaElements.length; i++) { + if (metaElements[i].getAttribute('property') === 'og:url') { + resultUrl = metaElements[i].content; + } + } + + return resultUrl; +} + +function getDataForMerge(responseData) { + let siteData = { + name: ORTB2_NAME + }; + let userData = { + name: ORTB2_NAME + }; + + if (responseData.siteSegments) { + siteData.segment = responseData.siteSegments.map((segmentId) => ({ id: segmentId })); + } + if (responseData.siteSegtax) { + siteData.ext = { + segtax: responseData.siteSegtax + } + } + + if (responseData.userSegments) { + userData.segment = responseData.userSegments.map((segmentId) => ({ id: segmentId })); + } + if (responseData.userSegtax) { + userData.ext = { + segtax: responseData.userSegtax + } + } + + let result = {}; + if (siteData.segment || siteData.ext) { + result.site = { + content: { + data: [siteData], + } + } + } + + if (userData.segment || userData.ext) { + result.user = { + data: [userData], + } + } + + return result; +} + +/** @type {RtdSubmodule} */ +export const mgidSubmodule = { + name: SUBMODULE_NAME, + init: init, + getBidRequestData: getBidRequestData, + gvlid: GVLID +}; + +submodule(MODULE_NAME, mgidSubmodule); diff --git a/modules/mgidRtdProvider.md b/modules/mgidRtdProvider.md new file mode 100644 index 00000000000..58d4564e14e --- /dev/null +++ b/modules/mgidRtdProvider.md @@ -0,0 +1,51 @@ +# Overview + +``` +Module Name: Mgid RTD Provider +Module Type: RTD Provider +Maintainer: prebid@mgid.com +``` + +# Description + +Mgid RTD module allows you to enrich bid data with contextual and audience signals, based on IAB taxonomies. + +## Configuration + +This module is configured as part of the `realTimeData.dataProviders` object. + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +|------------|----------|----------------------------------------|---------------|----------| +| `name ` | required | Real time data module name | `'mgid'` | `string` | +| `params` | required | | | `Object` | +| `params.clientSiteId` | required | The client site id provided by Mgid. | `'123456'` | `string` | +| `params.timeout` | optional | Maximum amount of milliseconds allowed for module to finish working | `1000` | `number` | + +#### Example + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'mgid', + params: { + clientSiteId: '123456' + } + }] + } +}); +``` + +## Integration +To install the module, follow these instructions: + +#### Step 1: Prepare the base Prebid file + +- Option 1: Use Prebid [Download](/download.html) page to build the prebid package. Ensure that you do check *Mgid Realtime Module* module + +- Option 2: From the command line, run `gulp build --modules=mgidRtdProvider,...` + +#### Step 2: Set configuration + +Enable Mgid Real Time Module using `pbjs.setConfig`. Example is provided in Configuration section. diff --git a/modules/mgidXBidAdapter.js b/modules/mgidXBidAdapter.js new file mode 100644 index 00000000000..5789f0d8b95 --- /dev/null +++ b/modules/mgidXBidAdapter.js @@ -0,0 +1,263 @@ +import { + isFn, + deepAccess, + logMessage, + logError, + isPlainObject, + isNumber, + isArray, + isStr +} from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; +import { USERSYNC_DEFAULT_CONFIG } from '../src/userSync.js'; + +const BIDDER_CODE = 'mgidX'; +const GVLID = 358; +const AD_URL = 'https://us-east-x.mgid.com/pbjs'; +const PIXEL_SYNC_URL = 'https://cm.mgid.com/i.gif'; +const IFRAME_SYNC_URL = 'https://cm.mgid.com/i.html'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: config.getConfig('bidderTimeout') + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) => { + const spb = isPlainObject(config.getConfig('userSync')) && + isNumber(config.getConfig('userSync').syncsPerBidder) + ? config.getConfig('userSync').syncsPerBidder : USERSYNC_DEFAULT_CONFIG.syncsPerBidder; + + if (spb > 0 && isPlainObject(syncOptions) && (syncOptions.iframeEnabled || syncOptions.pixelEnabled)) { + let pixels = []; + if (serverResponses && + isArray(serverResponses) && + serverResponses.length > 0 && + isPlainObject(serverResponses[0].body) && + isPlainObject(serverResponses[0].body.ext) && + isArray(serverResponses[0].body.ext.cm) && + serverResponses[0].body.ext.cm.length > 0) { + pixels = serverResponses[0].body.ext.cm; + } + + const syncs = []; + const query = []; + query.push('cbuster={cbuster}'); + query.push('gdpr_consent=' + encodeURIComponent(isPlainObject(gdprConsent) && isStr(gdprConsent?.consentString) ? gdprConsent.consentString : '')); + if (isPlainObject(gdprConsent) && typeof gdprConsent?.gdprApplies === 'boolean' && gdprConsent.gdprApplies) { + query.push('gdpr=1'); + } else { + query.push('gdpr=0'); + } + if (isPlainObject(uspConsent) && uspConsent?.consentString) { + query.push(`us_privacy=${encodeURIComponent(uspConsent?.consentString)}`); + } + if (isPlainObject(gppConsent) && gppConsent?.gppString) { + query.push(`gppString=${encodeURIComponent(gppConsent?.gppString)}`); + } + if (config.getConfig('coppa')) { + query.push('coppa=1') + } + const q = query.join('&') + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: IFRAME_SYNC_URL + '?' + q.replace('{cbuster}', Math.round(new Date().getTime())) + }); + } else if (syncOptions.pixelEnabled) { + if (pixels.length === 0) { + for (let i = 0; i < spb; i++) { + syncs.push({ + type: 'image', + url: PIXEL_SYNC_URL + '?' + q.replace('{cbuster}', Math.round(new Date().getTime())) // randomly selects partner if sync required + }); + } + } else { + for (let i = 0; i < spb && i < pixels.length; i++) { + syncs.push({ + type: 'image', + url: pixels[i] + (pixels[i].indexOf('?') > 0 ? '&' : '?') + q.replace('{cbuster}', Math.round(new Date().getTime())) + }); + } + } + } + return syncs; + } + } +}; + +registerBidder(spec); diff --git a/modules/mgidXBidAdapter.md b/modules/mgidXBidAdapter.md new file mode 100644 index 00000000000..f160aebb589 --- /dev/null +++ b/modules/mgidXBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: MgidX Bidder Adapter +Module Type: MgidX Bidder Adapter +Maintainer: prebid@mgid.com +``` + +# Description + +One of the easiest way to gain access to MGID demand sources - MGIDX header bidding adapter. +MGIDX header bidding adapter connects with MGID demand sources to fetch bids for display placements + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'mgidX', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'mgidX', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'mgidX', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/microadBidAdapter.js b/modules/microadBidAdapter.js index 982bd61840a..ed88dce757c 100644 --- a/modules/microadBidAdapter.js +++ b/modules/microadBidAdapter.js @@ -1,6 +1,8 @@ -import { deepAccess, isEmpty, isStr } from '../src/utils.js'; +import { deepAccess, isArray, isEmpty, isStr } from '../src/utils.js'; +import { find } from '../src/polyfill.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'microad'; @@ -15,13 +17,25 @@ const EXT_URL_STRING = '${COMPASS_EXT_URL}'; const EXT_REF_STRING = '${COMPASS_EXT_REF}'; const EXT_IFA_STRING = '${COMPASS_EXT_IFA}'; const EXT_APPID_STRING = '${COMPASS_EXT_APPID}'; -const EXT_GEO_STRING = '${COMPASS_EXT_GEO}'; /* eslint-enable no-template-curly-in-string */ const BANNER_CODE = 1; const NATIVE_CODE = 2; const VIDEO_CODE = 4; +const AUDIENCE_IDS = [ + {type: 6, bidKey: 'userId.imuid', source: 'intimatemerger.com'}, + {type: 8, bidKey: 'userId.id5id.uid', source: 'id5-sync.com'}, + {type: 9, bidKey: 'userId.tdid', source: 'adserver.org'}, + {type: 10, bidKey: 'userId.novatiq.snowflake', source: 'novatiq.com'}, + {type: 11, bidKey: 'userId.parrableId.eid', source: 'parrable.com'}, + {type: 12, bidKey: 'userId.dacId.id', source: 'dac.co.jp'}, + {type: 13, bidKey: 'userId.idl_env', source: 'liveramp.com'}, + {type: 14, bidKey: 'userId.criteoId', source: 'criteo.com'}, + {type: 15, bidKey: 'userId.pubcid', source: 'pubcid.org'}, + {type: 17, bidKey: 'userId.uid2.id', source: 'uidapi.com'} +]; + function createCBT() { const randomValue = Math.floor(Math.random() * Math.pow(10, 18)).toString(16); const date = new Date().getTime().toString(16); @@ -45,16 +59,20 @@ export const spec = { return !!(bid && bid.params && bid.params.spot && bid.mediaTypes && (bid.mediaTypes.banner || bid.mediaTypes.native || bid.mediaTypes.video)); }, buildRequests: function(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const requests = []; validBidRequests.forEach(bid => { const bidParams = bid.params; const params = { spot: bidParams.spot, - url: bidderRequest.refererInfo.canonicalUrl || window.location.href, - referrer: bidderRequest.refererInfo.referer, + // TODO: are these the right refererInfo values - does the fallback make sense here? + url: bidderRequest.refererInfo.page || window.location.href, + referrer: bidderRequest.refererInfo.ref, bid_id: bid.bidId, - transaction_id: bid.transactionId, + transaction_id: bid.ortb2Imp?.ext?.tid, media_types: convertMediaTypes(bid), cbt: createCBT() }; @@ -75,16 +93,26 @@ export const spec = { params['appid'] = bidParams.appid.replace(EXT_APPID_STRING, ''); } - if (bidParams.geo) { - const geo = bidParams.geo.replace(EXT_GEO_STRING, ''); - if (/^[0-9.\-]+,[0-9.\-]+$/.test(geo)) { - params['geo'] = geo; + const aidsParams = [] + const userIdAsEids = bid.userIdAsEids; + AUDIENCE_IDS.forEach((audienceId) => { + const bidAudienceId = deepAccess(bid, audienceId.bidKey); + if (!isEmpty(bidAudienceId) && isStr(bidAudienceId)) { + const aidParam = { type: audienceId.type, id: bidAudienceId }; + // Set ext + if (isArray(userIdAsEids)) { + const targetEid = find(userIdAsEids, (eid) => eid.source === audienceId.source) || {}; + if (!isEmpty(deepAccess(targetEid, 'uids.0.ext'))) { + aidParam.ext = targetEid.uids[0].ext; + } + } + aidsParams.push(aidParam); + // Set Ramp ID + if (audienceId.type === 13) params['idl_env'] = bidAudienceId; } - } - - const idlEnv = deepAccess(bid, 'userId.idl_env') - if (!isEmpty(idlEnv) && isStr(idlEnv)) { - params['idl_env'] = idlEnv + }) + if (aidsParams.length > 0) { + params['aids'] = JSON.stringify(aidsParams) } requests.push({ diff --git a/modules/minutemediaBidAdapter.js b/modules/minutemediaBidAdapter.js index 1a9ccfdf824..e67534d74fe 100644 --- a/modules/minutemediaBidAdapter.js +++ b/modules/minutemediaBidAdapter.js @@ -1,17 +1,29 @@ -import { logWarn, isArray, isFn, deepAccess, isEmpty, contains, timestamp, getBidIdParameter } from '../src/utils.js'; +import { + logWarn, + logInfo, + isArray, + isFn, + deepAccess, + isEmpty, + contains, + timestamp, + triggerPixel, + isInteger, + getBidIdParameter +} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {VIDEO} from '../src/mediaTypes.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; -const SUPPORTED_AD_TYPES = [VIDEO]; +const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; const BIDDER_CODE = 'minutemedia'; -const ADAPTER_VERSION = '5.0.1'; +const ADAPTER_VERSION = '6.0.0'; const TTL = 360; const CURRENCY = 'USD'; const SELLER_ENDPOINT = 'https://hb.minutemedia-prebid.com/'; const MODES = { - PRODUCTION: 'hb-mm', - TEST: 'hb-mm-test' + PRODUCTION: 'hb-mm-multi', + TEST: 'hb-multi-mm-test' } const SUPPORTED_SYNC_METHODS = { IFRAME: 'iframe', @@ -23,7 +35,7 @@ export const spec = { gvlid: 918, version: ADAPTER_VERSION, supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid: function(bidRequest) { + isBidRequestValid: function (bidRequest) { if (!bidRequest.params) { logWarn('no params have been set to MinuteMedia adapter'); return false; @@ -36,54 +48,70 @@ export const spec = { return true; }, - buildRequests: function (bidRequests, bidderRequest) { - if (bidRequests.length === 0) { - return []; - } + buildRequests: function (validBidRequests, bidderRequest) { + const combinedRequestsObject = {}; - const requests = []; + // use data from the first bid, to create the general params for all bids + const generalObject = validBidRequests[0]; + const testMode = generalObject.params.testMode; - bidRequests.forEach(bid => { - requests.push(buildVideoRequest(bid, bidderRequest)); - }); + combinedRequestsObject.params = generateGeneralParams(generalObject, bidderRequest); + combinedRequestsObject.bids = generateBidsParams(validBidRequests, bidderRequest); - return requests; + return { + method: 'POST', + url: getEndpoint(testMode), + data: combinedRequestsObject + } }, - interpretResponse: function({body}) { + interpretResponse: function ({body}) { const bidResponses = []; - const bidResponse = { - requestId: body.requestId, - cpm: body.cpm, - width: body.width, - height: body.height, - creativeId: body.requestId, - currency: body.currency, - netRevenue: body.netRevenue, - ttl: body.ttl || TTL, - vastXml: body.vastXml, - mediaType: VIDEO - }; - - if (body.adomain && body.adomain.length) { - bidResponse.meta = {}; - bidResponse.meta.advertiserDomains = body.adomain + if (body.bids) { + body.bids.forEach(adUnit => { + const bidResponse = { + requestId: adUnit.requestId, + cpm: adUnit.cpm, + currency: adUnit.currency || CURRENCY, + width: adUnit.width, + height: adUnit.height, + ttl: adUnit.ttl || TTL, + creativeId: adUnit.requestId, + netRevenue: adUnit.netRevenue || true, + nurl: adUnit.nurl, + mediaType: adUnit.mediaType, + meta: { + mediaType: adUnit.mediaType + } + }; + + if (adUnit.mediaType === VIDEO) { + bidResponse.vastXml = adUnit.vastXml; + } else if (adUnit.mediaType === BANNER) { + bidResponse.ad = adUnit.ad; + } + + if (adUnit.adomain && adUnit.adomain.length) { + bidResponse.meta.advertiserDomains = adUnit.adomain; + } + + bidResponses.push(bidResponse); + }); } - bidResponses.push(bidResponse); return bidResponses; }, - getUserSyncs: function(syncOptions, serverResponses) { + getUserSyncs: function (syncOptions, serverResponses) { const syncs = []; for (const response of serverResponses) { - if (syncOptions.iframeEnabled && response.body.userSyncURL) { + if (syncOptions.iframeEnabled && response.body.params.userSyncURL) { syncs.push({ type: 'iframe', - url: response.body.userSyncURL + url: response.body.params.userSyncURL }); } - if (syncOptions.pixelEnabled && isArray(response.body.userSyncPixels)) { - const pixels = response.body.userSyncPixels.map(pixel => { + if (syncOptions.pixelEnabled && isArray(response.body.params.userSyncPixels)) { + const pixels = response.body.params.userSyncPixels.map(pixel => { return { type: 'image', url: pixel @@ -93,6 +121,16 @@ export const spec = { } } return syncs; + }, + onBidWon: function (bid) { + if (bid == null) { + return; + } + + logInfo('onBidWon:', bid); + if (bid.hasOwnProperty('nurl') && bid.nurl.length > 0) { + triggerPixel(bid.nurl); + } } }; @@ -103,46 +141,33 @@ registerBidder(spec); * @param bid {bid} * @returns {Number} */ -function getFloor(bid) { +function getFloor(bid, mediaType) { if (!isFn(bid.getFloor)) { return 0; } let floorResult = bid.getFloor({ currency: CURRENCY, - mediaType: VIDEO, + mediaType: mediaType, size: '*' }); return floorResult.currency === CURRENCY && floorResult.floor ? floorResult.floor : 0; } /** - * Build the video request - * @param bid {bid} - * @param bidderRequest {bidderRequest} - * @returns {Object} - */ -function buildVideoRequest(bid, bidderRequest) { - const sellerParams = generateParameters(bid, bidderRequest); - const {params} = bid; - return { - method: 'GET', - url: getEndpoint(params.testMode), - data: sellerParams - }; -} - -/** - * Get the the ad size from the bid + * Get the the ad sizes array from the bid * @param bid {bid} * @returns {Array} */ -function getSizes(bid) { - if (deepAccess(bid, 'mediaTypes.video.sizes')) { - return bid.mediaTypes.video.sizes[0]; +function getSizesArray(bid, mediaType) { + let sizesArray = [] + + if (deepAccess(bid, `mediaTypes.${mediaType}.sizes`)) { + sizesArray = bid.mediaTypes[mediaType].sizes; } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { - return bid.sizes[0]; + sizesArray = bid.sizes; } - return []; + + return sizesArray; } /** @@ -239,122 +264,212 @@ function getDeviceType(ua) { return '1'; } +function generateBidsParams(validBidRequests, bidderRequest) { + const bidsArray = []; + + if (validBidRequests.length) { + validBidRequests.forEach(bid => { + bidsArray.push(generateBidParameters(bid, bidderRequest)); + }); + } + + return bidsArray; +} + /** - * Generate query parameters for the request - * @param bid {bid} - * @param bidderRequest {bidderRequest} - * @returns {Object} + * Generate bid specific parameters + * @param {bid} bid + * @param {bidderRequest} bidderRequest + * @returns {Object} bid specific params object */ -function generateParameters(bid, bidderRequest) { +function generateBidParameters(bid, bidderRequest) { const {params} = bid; - const timeout = config.getConfig('bidderTimeout'); - const {syncEnabled, filterSettings} = config.getConfig('userSync') || {}; - const [width, height] = getSizes(bid); - const {bidderCode} = bidderRequest; - const domain = window.location.hostname; + const mediaType = isBanner(bid) ? BANNER : VIDEO; + const sizesArray = getSizesArray(bid, mediaType); // fix floor price in case of NAN if (isNaN(params.floorPrice)) { params.floorPrice = 0; } - const requestParams = { - wrapper_type: 'prebidjs', - wrapper_vendor: '$$PREBID_GLOBAL$$', - wrapper_version: '$prebid.version$', - adapter_version: ADAPTER_VERSION, - auction_start: timestamp(), - ad_unit_code: getBidIdParameter('adUnitCode', bid), - tmax: timeout, - width: width, - height: height, - publisher_id: params.org, - floor_price: Math.max(getFloor(bid), params.floorPrice), - ua: navigator.userAgent, - bid_id: getBidIdParameter('bidId', bid), - bidder_request_id: getBidIdParameter('bidderRequestId', bid), - transaction_id: getBidIdParameter('transactionId', bid), - session_id: getBidIdParameter('auctionId', bid), - publisher_name: domain, - site_domain: domain, - dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, - device_type: getDeviceType(navigator.userAgent) + const bidObject = { + mediaType, + adUnitCode: getBidIdParameter('adUnitCode', bid), + sizes: sizesArray, + floorPrice: Math.max(getFloor(bid, mediaType), params.floorPrice), + bidId: getBidIdParameter('bidId', bid), + loop: getBidIdParameter('bidderRequestsCount', bid), + bidderRequestId: getBidIdParameter('bidderRequestId', bid), + transactionId: bid.ortb2Imp?.ext?.tid || '', + coppa: 0 }; - const userIdsParam = getBidIdParameter('userId', bid); - if (userIdsParam) { - requestParams.userIds = JSON.stringify(userIdsParam); + const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`); + if (pos) { + bidObject.pos = pos; } - const ortb2Metadata = config.getConfig('ortb2') || {}; - if (ortb2Metadata.site) { - requestParams.site_metadata = JSON.stringify(ortb2Metadata.site); + const gpid = deepAccess(bid, `ortb2Imp.ext.gpid`); + if (gpid) { + bidObject.gpid = gpid; } - if (ortb2Metadata.user) { - requestParams.user_metadata = JSON.stringify(ortb2Metadata.user); + + const placementId = params.placementId || deepAccess(bid, `mediaTypes.${mediaType}.name`); + if (placementId) { + bidObject.placementId = placementId; } - const playbackMethod = deepAccess(bid, 'mediaTypes.video.playbackmethod'); - if (playbackMethod) { - requestParams.playback_method = playbackMethod; + const mimes = deepAccess(bid, `mediaTypes.${mediaType}.mimes`); + if (mimes) { + bidObject.mimes = mimes; } - const placement = deepAccess(bid, 'mediaTypes.video.placement'); - if (placement) { - requestParams.placement = placement; + const api = deepAccess(bid, `mediaTypes.${mediaType}.api`); + if (api) { + bidObject.api = api; } - const pos = deepAccess(bid, 'mediaTypes.video.pos'); - if (pos) { - requestParams.pos = pos; + + const sua = deepAccess(bid, `ortb2.device.sua`); + if (sua) { + bidObject.sua = sua; } - const minduration = deepAccess(bid, 'mediaTypes.video.minduration'); - if (minduration) { - requestParams.min_duration = minduration; + + const coppa = deepAccess(bid, `ortb2.regs.coppa`) + if (coppa) { + bidObject.coppa = 1; } - const maxduration = deepAccess(bid, 'mediaTypes.video.maxduration'); - if (maxduration) { - requestParams.max_duration = maxduration; + + if (mediaType === VIDEO) { + const playbackMethod = deepAccess(bid, `mediaTypes.video.playbackmethod`); + let playbackMethodValue; + + // verify playbackMethod is of type integer array, or integer only. + if (Array.isArray(playbackMethod) && isInteger(playbackMethod[0])) { + // only the first playbackMethod in the array will be used, according to OpenRTB 2.5 recommendation + playbackMethodValue = playbackMethod[0]; + } else if (isInteger(playbackMethod)) { + playbackMethodValue = playbackMethod; + } + + if (playbackMethodValue) { + bidObject.playbackMethod = playbackMethodValue; + } + + const placement = deepAccess(bid, `mediaTypes.video.placement`); + if (placement) { + bidObject.placement = placement; + } + + const minDuration = deepAccess(bid, `mediaTypes.video.minduration`); + if (minDuration) { + bidObject.minDuration = minDuration; + } + + const maxDuration = deepAccess(bid, `mediaTypes.video.maxduration`); + if (maxDuration) { + bidObject.maxDuration = maxDuration; + } + + const skip = deepAccess(bid, `mediaTypes.video.skip`); + if (skip) { + bidObject.skip = skip; + } + + const linearity = deepAccess(bid, `mediaTypes.video.linearity`); + if (linearity) { + bidObject.linearity = linearity; + } + + const protocols = deepAccess(bid, `mediaTypes.video.protocols`); + if (protocols) { + bidObject.protocols = protocols; + } + + const plcmt = deepAccess(bid, `mediaTypes.video.plcmt`); + if (plcmt) { + bidObject.plcmt = plcmt; + } } - const skip = deepAccess(bid, 'mediaTypes.video.skip'); - if (skip) { - requestParams.skip = skip; + + return bidObject; +} + +function isBanner(bid) { + return bid.mediaTypes && bid.mediaTypes.banner; +} + +/** + * Generate params that are common between all bids + * @param {single bid object} generalObject + * @param {bidderRequest} bidderRequest + * @returns {object} the common params object + */ +function generateGeneralParams(generalObject, bidderRequest) { + const domain = window.location.hostname; + const {syncEnabled, filterSettings} = config.getConfig('userSync') || {}; + const {bidderCode} = bidderRequest; + const generalBidParams = generalObject.params; + const timeout = bidderRequest.timeout; + + // these params are snake_case instead of camelCase to allow backwards compatability on the server. + // in the future, these will be converted to camelCase to match our convention. + const generalParams = { + wrapper_type: 'prebidjs', + wrapper_vendor: '$$PREBID_GLOBAL$$', + wrapper_version: '$prebid.version$', + adapter_version: ADAPTER_VERSION, + auction_start: timestamp(), + publisher_id: generalBidParams.org, + publisher_name: domain, + site_domain: domain, + dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, + device_type: getDeviceType(navigator.userAgent), + ua: navigator.userAgent, + is_wrapper: !!generalBidParams.isWrapper, + session_id: generalBidParams.sessionId || getBidIdParameter('bidderRequestId', generalObject), + tmax: timeout } - const linearity = deepAccess(bid, 'mediaTypes.video.linearity'); - if (linearity) { - requestParams.linearity = linearity; + + const userIdsParam = getBidIdParameter('userId', generalObject); + if (userIdsParam) { + generalParams.userIds = JSON.stringify(userIdsParam); } - if (params.placementId) { - requestParams.placement_id = params.placementId; + const ortb2Metadata = bidderRequest.ortb2 || {}; + if (ortb2Metadata.site) { + generalParams.site_metadata = JSON.stringify(ortb2Metadata.site); + } + if (ortb2Metadata.user) { + generalParams.user_metadata = JSON.stringify(ortb2Metadata.user); } if (syncEnabled) { const allowedSyncMethod = getAllowedSyncMethod(filterSettings, bidderCode); if (allowedSyncMethod) { - requestParams.cs_method = allowedSyncMethod; + generalParams.cs_method = allowedSyncMethod; } } if (bidderRequest.uspConsent) { - requestParams.us_privacy = bidderRequest.uspConsent; + generalParams.us_privacy = bidderRequest.uspConsent; } if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { - requestParams.gdpr = bidderRequest.gdprConsent.gdprApplies; - requestParams.gdpr_consent = bidderRequest.gdprConsent.consentString; + generalParams.gdpr = bidderRequest.gdprConsent.gdprApplies; + generalParams.gdpr_consent = bidderRequest.gdprConsent.consentString; } - if (params.ifa) { - requestParams.ifa = params.ifa; + if (generalBidParams.ifa) { + generalParams.ifa = generalBidParams.ifa; } - if (bid.schain) { - requestParams.schain = getSupplyChain(bid.schain); + if (generalObject.schain) { + generalParams.schain = getSupplyChain(generalObject.schain); } if (bidderRequest && bidderRequest.refererInfo) { - requestParams.referrer = deepAccess(bidderRequest, 'refererInfo.referer'); - requestParams.page_url = config.getConfig('pageUrl') || deepAccess(window, 'location.href'); + generalParams.referrer = deepAccess(bidderRequest, 'refererInfo.ref'); + generalParams.page_url = deepAccess(bidderRequest, 'refererInfo.page') || deepAccess(window, 'location.href'); } - return requestParams; + return generalParams } diff --git a/modules/minutemediaBidAdapter.md b/modules/minutemediaBidAdapter.md index 348cc586e08..66b54adaf0e 100644 --- a/modules/minutemediaBidAdapter.md +++ b/modules/minutemediaBidAdapter.md @@ -13,39 +13,64 @@ Module that connects to MinuteMedia's demand sources. The MinuteMedia adapter requires setup and approval from the MinuteMedia. Please reach out to hb@minutemedia.com to create an MinuteMedia account. -The adapter supports Video(instream). +The adapter supports Video(instream) & Banner. # Bid Parameters ## Video | Name | Scope | Type | Description | Example | ---- | ----- | ---- | ----------- | ------- -| `org` | required | String | MinuteMedia publisher Id provided by your MinuteMedia representative | "56f91cd4d3e3660002000033" +| `org` | required | String | MinuteMedia publisher Id provided by your MinuteMedia representative | "1234567890abcdef12345678" | `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 2.00 | `placementId` | optional | String | A unique placement identifier | "12345678" | `testMode` | optional | Boolean | This activates the test mode | false # Test Parameters ```javascript -var adUnits = [ - { +var adUnits = [{ code: 'dfp-video-div', - sizes: [[640, 480]], + sizes: [ + [640, 480] + ], mediaTypes: { - video: { - playerSize: [[640, 480]], - context: 'instream' - } + video: { + playerSize: [ + [640, 480] + ], + context: 'instream' + } }, bids: [{ - bidder: 'minutemedia', - params: { - org: '56f91cd4d3e3660002000033', // Required - floorPrice: 2.00, // Optional - placementId: '12345678', // Optional - testMode: false // Optional - } + bidder: 'minutemedia', + params: { + org: '1234567890abcdef12345678', // Required + floorPrice: 2.00, // Optional + placementId: 'video-test', // Optional + testMode: false // Optional + } }] - } - ]; + }, + { + code: 'dfp-banner-div', + sizes: [ + [640, 480] + ], + mediaTypes: { + banner: { + sizes: [ + [640, 480] + ] + } + }, + bids: [{ + bidder: 'minutemedia', + params: { + org: '1234567890abcdef12345678', // Required + floorPrice: 2.00, // Optional + placementId: 'banner-test', // Optional + testMode: false // Optional + } + }] + } +]; ``` diff --git a/modules/minutemediaplusBidAdapter.js b/modules/minutemediaplusBidAdapter.js new file mode 100644 index 00000000000..146d437b1fa --- /dev/null +++ b/modules/minutemediaplusBidAdapter.js @@ -0,0 +1,349 @@ +import {_each, deepAccess, parseSizesInput, parseUrl, uniques, isFn} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {config} from '../src/config.js'; + +const GVLID = 918; +const DEFAULT_SUB_DOMAIN = 'exchange'; +const BIDDER_CODE = 'mmplus'; +const BIDDER_VERSION = '1.0.0'; +const CURRENCY = 'USD'; +const TTL_SECONDS = 60 * 5; +const UNIQUE_DEAL_ID_EXPIRY = 1000 * 60 * 15; + +const storage = getStorageManager({bidderCode: BIDDER_CODE}); + +function getTopWindowQueryParams() { + try { + const parsedUrl = parseUrl(window.top.document.URL, {decodeSearchAsString: true}); + return parsedUrl.search; + } catch (e) { + return ''; + } +} + +export function createDomain(subDomain = DEFAULT_SUB_DOMAIN) { + return `https://${subDomain}.minutemedia-prebid.com`; +} + +export function extractCID(params) { + return params.cId || params.CID || params.cID || params.CId || params.cid || params.ciD || params.Cid || params.CiD; +} + +export function extractPID(params) { + return params.pId || params.PID || params.pID || params.PId || params.pid || params.piD || params.Pid || params.PiD; +} + +export function extractSubDomain(params) { + return params.subDomain || params.SubDomain || params.Subdomain || params.subdomain || params.SUBDOMAIN || params.subDOMAIN; +} + +function isBidRequestValid(bid) { + const params = bid.params || {}; + return !!(extractCID(params) && extractPID(params)); +} + +function buildRequest(bid, topWindowUrl, sizes, bidderRequest, bidderTimeout) { + const { + params, + bidId, + userId, + adUnitCode, + schain, + mediaTypes, + auctionId, + ortb2Imp, + bidderRequestId, + bidRequestsCount, + bidderRequestsCount, + bidderWinsCount + } = bid; + let {bidFloor, ext} = params; + const hashUrl = hashCode(topWindowUrl); + const uniqueDealId = getUniqueDealId(hashUrl); + const cId = extractCID(params); + const pId = extractPID(params); + const subDomain = extractSubDomain(params); + + const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', '')); + + if (isFn(bid.getFloor)) { + const floorInfo = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*' + }); + + if (floorInfo.currency === 'USD') { + bidFloor = floorInfo.floor; + } + } + + let data = { + url: encodeURIComponent(topWindowUrl), + uqs: getTopWindowQueryParams(), + cb: Date.now(), + bidFloor: bidFloor, + bidId: bidId, + referrer: bidderRequest.refererInfo.ref, + adUnitCode: adUnitCode, + publisherId: pId, + sizes: sizes, + uniqueDealId: uniqueDealId, + bidderVersion: BIDDER_VERSION, + prebidVersion: '$prebid.version$', + res: `${screen.width}x${screen.height}`, + schain: schain, + mediaTypes: mediaTypes, + gpid: gpid, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + auctionId: auctionId, + transactionId: ortb2Imp?.ext?.tid, + bidderRequestId: bidderRequestId, + bidRequestsCount: bidRequestsCount, + bidderRequestsCount: bidderRequestsCount, + bidderWinsCount: bidderWinsCount, + bidderTimeout: bidderTimeout + }; + + appendUserIdsToRequestPayload(data, userId); + + const sua = deepAccess(bidderRequest, 'ortb2.device.sua'); + + if (sua) { + data.sua = sua; + } + + if (bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent.consentString) { + data.gdprConsent = bidderRequest.gdprConsent.consentString; + } + if (bidderRequest.gdprConsent.gdprApplies !== undefined) { + data.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + } + if (bidderRequest.uspConsent) { + data.usPrivacy = bidderRequest.uspConsent; + } + + if (bidderRequest.gppConsent) { + data.gppString = bidderRequest.gppConsent.gppString; + data.gppSid = bidderRequest.gppConsent.applicableSections; + } else if (bidderRequest.ortb2?.regs?.gpp) { + data.gppString = bidderRequest.ortb2.regs.gpp; + data.gppSid = bidderRequest.ortb2.regs.gpp_sid; + } + + const dto = { + method: 'POST', + url: `${createDomain(subDomain)}/prebid/multi/${cId}`, + data: data + }; + + _each(ext, (value, key) => { + dto.data['ext.' + key] = value; + }); + + return dto; +} + +function appendUserIdsToRequestPayload(payloadRef, userIds) { + let key; + _each(userIds, (userId, idSystemProviderName) => { + key = `uid.${idSystemProviderName}`; + + switch (idSystemProviderName) { + case 'digitrustid': + payloadRef[key] = deepAccess(userId, 'data.id'); + break; + case 'lipb': + payloadRef[key] = userId.lipbid; + break; + case 'parrableId': + payloadRef[key] = userId.eid; + break; + case 'id5id': + payloadRef[key] = userId.uid; + break; + default: + payloadRef[key] = userId; + } + }); +} + +function buildRequests(validBidRequests, bidderRequest) { + const topWindowUrl = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; + const bidderTimeout = config.getConfig('bidderTimeout'); + const requests = []; + validBidRequests.forEach(validBidRequest => { + const sizes = parseSizesInput(validBidRequest.sizes); + const request = buildRequest(validBidRequest, topWindowUrl, sizes, bidderRequest, bidderTimeout); + requests.push(request); + }); + return requests; +} + +function interpretResponse(serverResponse, request) { + if (!serverResponse || !serverResponse.body) { + return []; + } + const {bidId} = request.data; + const {results} = serverResponse.body; + + let output = []; + + try { + results.forEach(result => { + const { + creativeId, + ad, + price, + exp, + width, + height, + currency, + metaData, + advertiserDomains, + mediaType = BANNER + } = result; + if (!ad || !price) { + return; + } + + const response = { + requestId: bidId, + cpm: price, + width: width, + height: height, + creativeId: creativeId, + currency: currency || CURRENCY, + netRevenue: true, + ttl: exp || TTL_SECONDS, + }; + + if (metaData) { + Object.assign(response, { + meta: metaData + }) + } else { + Object.assign(response, { + meta: { + advertiserDomains: advertiserDomains || [] + } + }) + } + + if (mediaType === BANNER) { + Object.assign(response, { + ad: ad, + }); + } else { + Object.assign(response, { + vastXml: ad, + mediaType: VIDEO + }); + } + output.push(response); + }); + return output; + } catch (e) { + return []; + } +} + +function getUserSyncs(syncOptions, responses, gdprConsent = {}, uspConsent = '', gppConsent = {}) { + let syncs = []; + const {iframeEnabled, pixelEnabled} = syncOptions; + const {gdprApplies, consentString = ''} = gdprConsent; + const {gppString, applicableSections} = gppConsent; + + const cidArr = responses.filter(resp => deepAccess(resp, 'body.cid')).map(resp => resp.body.cid).filter(uniques); + let params = `?cid=${encodeURIComponent(cidArr.join(','))}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${encodeURIComponent(consentString || '')}&us_privacy=${encodeURIComponent(uspConsent || '')}` + + if (gppString && applicableSections?.length) { + params += '&gpp=' + encodeURIComponent(gppString); + params += '&gpp_sid=' + encodeURIComponent(applicableSections.join(',')); + } + + if (iframeEnabled) { + syncs.push({ + type: 'iframe', + url: `https://sync.minutemedia-prebid.com/api/sync/iframe/${params}` + }); + } + if (pixelEnabled) { + syncs.push({ + type: 'image', + url: `https://sync.minutemedia-prebid.com/api/sync/image/${params}` + }); + } + return syncs; +} + +export function hashCode(s, prefix = '_') { + const l = s.length; + let h = 0 + let i = 0; + if (l > 0) { + while (i < l) { + h = (h << 5) - h + s.charCodeAt(i++) | 0; + } + } + return prefix + h; +} + +export function getUniqueDealId(key, expiry = UNIQUE_DEAL_ID_EXPIRY) { + const storageKey = `u_${key}`; + const now = Date.now(); + const data = getStorageItem(storageKey); + let uniqueId; + + if (!data || !data.value || now - data.created > expiry) { + uniqueId = `${key}_${now.toString()}`; + setStorageItem(storageKey, uniqueId); + } else { + uniqueId = data.value; + } + + return uniqueId; +} + +export function getStorageItem(key) { + try { + return tryParseJSON(storage.getDataFromLocalStorage(key)); + } catch (e) { + } + + return null; +} + +export function setStorageItem(key, value, timestamp) { + try { + const created = timestamp || Date.now(); + const data = JSON.stringify({value, created}); + storage.setDataInLocalStorage(key, data); + } catch (e) { + } +} + +export function tryParseJSON(value) { + try { + return JSON.parse(value); + } catch (e) { + return value; + } +} + +export const spec = { + code: BIDDER_CODE, + version: BIDDER_VERSION, + gvlid: GVLID, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs +}; + +registerBidder(spec); diff --git a/modules/minutemediaplusBidAdapter.md b/modules/minutemediaplusBidAdapter.md new file mode 100644 index 00000000000..410c00e7017 --- /dev/null +++ b/modules/minutemediaplusBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +**Module Name:** MinuteMediaPlus Bidder Adapter + +**Module Type:** Bidder Adapter + +**Maintainer:** hb@minutemedia.com + +# Description + +Module that connects to MinuteMediaPlus's demand sources. + +# Test Parameters +```js +var adUnits = [ + { + code: 'test-ad', + sizes: [[300, 250]], + bids: [ + { + bidder: 'mmplus', + params: { + cId: '562524b21b1c1f08117fc7f9', + pId: '59ac17c192832d0011283fe3', + bidFloor: 0.0001, + ext: { + param1: 'loremipsum', + param2: 'dolorsitamet' + } + } + } + ] + } +]; +``` diff --git a/modules/missenaBidAdapter.js b/modules/missenaBidAdapter.js index 41bae4d6568..33fa6857e85 100644 --- a/modules/missenaBidAdapter.js +++ b/modules/missenaBidAdapter.js @@ -1,12 +1,14 @@ -import { formatQS, logInfo } from '../src/utils.js'; +import { buildUrl, formatQS, logInfo, triggerPixel } from '../src/utils.js'; import { BANNER } from '../src/mediaTypes.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'missena'; const ENDPOINT_URL = 'https://bid.missena.io/'; +const EVENTS_DOMAIN = 'events.missena.io'; +const EVENTS_DOMAIN_DEV = 'events.staging.missena.xyz'; export const spec = { - aliases: [BIDDER_CODE], + aliases: ['msna'], code: BIDDER_CODE, gvlid: 687, supportedMediaTypes: [BANNER], @@ -30,12 +32,14 @@ export const spec = { buildRequests: function (validBidRequests, bidderRequest) { return validBidRequests.map((bidRequest) => { const payload = { + adunit: bidRequest.adUnitCode, request_id: bidRequest.bidId, timeout: bidderRequest.timeout, }; if (bidderRequest && bidderRequest.refererInfo) { - payload.referer = bidderRequest.refererInfo.referer; + // TODO: is 'topmostLocation' the right value here? + payload.referer = bidderRequest.refererInfo.topmostLocation; payload.referer_canonical = bidderRequest.refererInfo.canonicalUrl; } @@ -44,6 +48,19 @@ export const spec = { payload.consent_required = bidderRequest.gdprConsent.gdprApplies; } const baseUrl = bidRequest.params.baseUrl || ENDPOINT_URL; + if (bidRequest.params.test) { + payload.test = bidRequest.params.test; + } + if (bidRequest.params.placement) { + payload.placement = bidRequest.params.placement; + } + if (bidRequest.params.formats) { + payload.formats = bidRequest.params.formats; + } + if (bidRequest.params.isInternal) { + payload.is_internal = bidRequest.params.isInternal; + } + payload.userEids = bidRequest.userIdAsEids || []; return { method: 'POST', url: baseUrl + '?' + formatQS({ t: bidRequest.params.apiKey }), @@ -68,7 +85,30 @@ export const spec = { return bidResponses; }, + getUserSyncs: function ( + syncOptions, + serverResponses, + gdprConsent, + uspConsent + ) { + if (!syncOptions.iframeEnabled) { + return []; + } + let gdprParams = ''; + if ( + gdprConsent && + 'gdprApplies' in gdprConsent && + typeof gdprConsent.gdprApplies === 'boolean' + ) { + gdprParams = `?gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${ + gdprConsent.consentString + }`; + } + return [ + { type: 'iframe', url: 'https://sync.missena.io/iframe' + gdprParams }, + ]; + }, /** * Register bidder specific code, which will execute if bidder timed out after an auction * @param {data} Containing timeout specific data @@ -82,6 +122,15 @@ export const spec = { * @param {Bid} The bid that won the auction */ onBidWon: function (bid) { + const hostname = bid.params[0].baseUrl ? EVENTS_DOMAIN_DEV : EVENTS_DOMAIN; + triggerPixel( + buildUrl({ + protocol: 'https', + hostname, + pathname: '/v1/bidsuccess', + search: { t: bid.params[0].apiKey, provider: bid.meta?.networkName, cpm: bid.cpm, currency: bid.currency }, + }) + ); logInfo('Missena - Bid won', bid); }, }; diff --git a/modules/mobfoxBidAdapter.md b/modules/mobfoxBidAdapter.md deleted file mode 100644 index 31b60606d2f..00000000000 --- a/modules/mobfoxBidAdapter.md +++ /dev/null @@ -1,29 +0,0 @@ -# Overview - -``` -Module Name: Mobfox Bidder Adapter -Module Type: Bidder Adapter -Maintainer: solutions-team@matomy.com -``` - -# Description - -Module that connects to Mobfox's demand sources - -# Test Parameters -``` - var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - sizes: [[320, 480], [300, 250], [300,600]], - - // Replace this object to test a new Adapter! - bids: [{ - bidder: 'mobfox', - params: { - s: "267d72ac3f77a3f447b32cf7ebf20673", // required - The hash of your inventory to identify which app is making the request, - imp_instl: 1 // optional - set to 1 if using interstitial otherwise delete or set to 0 - } - }] - - }]; -``` diff --git a/modules/mobfoxpbBidAdapter.js b/modules/mobfoxpbBidAdapter.js index a4af7133370..9ff50e2531f 100644 --- a/modules/mobfoxpbBidAdapter.js +++ b/modules/mobfoxpbBidAdapter.js @@ -1,6 +1,7 @@ import { isFn, deepAccess, getWindowTop } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'mobfoxpb'; const AD_URL = 'https://bes.mobfox.com/pbjs'; @@ -48,6 +49,8 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); const winTop = getWindowTop(); const location = winTop.location; const placements = []; @@ -66,7 +69,7 @@ export const spec = { request.ccpa = bidderRequest.uspConsent; } if (bidderRequest.gdprConsent) { - request.gdpr = bidderRequest.gdprConsent + request.gdpr = bidderRequest.gdprConsent; } } @@ -79,7 +82,7 @@ export const spec = { schain: bid.schain || {}, bidfloor: getBidFloor(bid) }; - const mediaType = bid.mediaTypes + const mediaType = bid.mediaTypes; if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { placement.traffic = BANNER; diff --git a/modules/mobsmartBidAdapter.md b/modules/mobsmartBidAdapter.md deleted file mode 100644 index 1240d6db494..00000000000 --- a/modules/mobsmartBidAdapter.md +++ /dev/null @@ -1,50 +0,0 @@ -# Overview - -``` -Module Name: Mobsmart Bidder Adapter -Module Type: Bidder Adapter -Maintainer: adx@kpis.jp -``` - -# Description - -Module that connects to Mobsmart demand sources to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: "mobsmart", - params: { - floorPrice: 100, - currency: 'JPY' - } - } - ] - },{ - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[320, 50]], // a mobile size - } - }, - bids: [ - { - bidder: "mobsmart", - params: { - floorPrice: 90, - currency: 'JPY' - } - } - ] - } - ]; -``` diff --git a/modules/multibid/index.js b/modules/multibid/index.js index 8081e40ccb2..df77a157bee 100644 --- a/modules/multibid/index.js +++ b/modules/multibid/index.js @@ -12,6 +12,8 @@ import * as events from '../../src/events.js'; import CONSTANTS from '../../src/constants.json'; import {addBidderRequests} from '../../src/auction.js'; import {getHighestCpmBidsFromBidPool, sortByDealAndPriceBucketOrCpm} from '../../src/targeting.js'; +import {PBS, registerOrtbProcessor, REQUEST} from '../../src/pbjsORTB.js'; +import {timedBidResponseHook} from '../../src/utils/perfMetrics.js'; const MODULE_NAME = 'multibid'; let hasMultibid = false; @@ -98,7 +100,7 @@ export function adjustBidderRequestsHook(fn, bidderRequests) { * @param {String} ad unit code for bid * @param {Object} bid object */ -export function addBidResponseHook(fn, adUnitCode, bid) { +export const addBidResponseHook = timedBidResponseHook('multibid', function addBidResponseHook(fn, adUnitCode, bid, reject) { let floor = deepAccess(bid, 'floorData.floorValue'); if (!config.getConfig('multibid')) resetMultiConfig(); @@ -106,7 +108,7 @@ export function addBidResponseHook(fn, adUnitCode, bid) { // Else checks if multiconfig exists and bid bidderCode exists within config // Else continue with no modifications if (hasMultibid && multiConfig[bid.bidderCode] && deepAccess(bid, 'video.context') === 'adpod') { - fn.call(this, adUnitCode, bid); + fn.call(this, adUnitCode, bid, reject); } else if (hasMultibid && multiConfig[bid.bidderCode]) { // Set property multibidPrefix on bid if (multiConfig[bid.bidderCode].prefix) bid.multibidPrefix = multiConfig[bid.bidderCode].prefix; @@ -126,7 +128,7 @@ export function addBidResponseHook(fn, adUnitCode, bid) { if (multiConfig[bid.bidderCode].prefix) bid.targetingBidder = multiConfig[bid.bidderCode].prefix + length; if (length === multiConfig[bid.bidderCode].maxbids) multibidUnits[adUnitCode][bid.bidderCode].maxReached = true; - fn.call(this, adUnitCode, bid); + fn.call(this, adUnitCode, bid, reject); } else { logWarn(`Filtering multibid received from bidder ${bid.bidderCode}: ` + ((multibidUnits[adUnitCode][bid.bidderCode].maxReached) ? `Maximum bid limit reached for ad unit code ${adUnitCode}` : 'Bid cpm under floors value.')); } @@ -136,12 +138,12 @@ export function addBidResponseHook(fn, adUnitCode, bid) { deepSetValue(multibidUnits, [adUnitCode, bid.bidderCode], {ads: [bid]}); if (multibidUnits[adUnitCode][bid.bidderCode].ads.length === multiConfig[bid.bidderCode].maxbids) multibidUnits[adUnitCode][bid.bidderCode].maxReached = true; - fn.call(this, adUnitCode, bid); + fn.call(this, adUnitCode, bid, reject); } } else { - fn.call(this, adUnitCode, bid); + fn.call(this, adUnitCode, bid, reject); } -} +}); /** * A descending sort function that will sort the list of objects based on the following: @@ -227,6 +229,7 @@ export const resetMultibidUnits = () => multibidUnits = {}; * Set up hooks on init */ function init() { + // TODO: does this reset logic make sense - what about simultaneous auctions? events.on(CONSTANTS.EVENTS.AUCTION_INIT, resetMultibidUnits); setupBeforeHookFnOnce(addBidderRequests, adjustBidderRequestsHook); getHook('addBidResponse').before(addBidResponseHook, 3); @@ -234,3 +237,14 @@ function init() { } init(); + +export function setOrtbExtPrebidMultibid(ortbRequest) { + const multibid = config.getConfig('multibid'); + if (multibid) { + deepSetValue(ortbRequest, 'ext.prebid.multibid', multibid.map(o => + Object.fromEntries(Object.entries(o).map(([k, v]) => [k.toLowerCase(), v]))) + ) + } +} + +registerOrtbProcessor({type: REQUEST, name: 'extPrebidMultibid', fn: setOrtbExtPrebidMultibid, dialects: [PBS]}); diff --git a/modules/mwOpenLinkIdSystem.js b/modules/mwOpenLinkIdSystem.js index 552223fa73c..ff23547224b 100644 --- a/modules/mwOpenLinkIdSystem.js +++ b/modules/mwOpenLinkIdSystem.js @@ -8,14 +8,15 @@ import { timestamp, logError, deepClone, generateUUID, isPlainObject } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const openLinkID = { name: 'mwol', cookie_expiration: (86400 * 1000 * 365 * 1) // 1 year } -const storage = getStorageManager(); +const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: openLinkID.name}); function getExpirationDate() { return (new Date(timestamp() + openLinkID.cookie_expiration)).toGMTString(); @@ -136,6 +137,12 @@ export const mwOpenLinkIdSubModule = { const submoduleConfigParams = (submoduleConfig && submoduleConfig.params) || {}; if (!isValidConfig(submoduleConfigParams)) return undefined; return setID(submoduleConfigParams); + }, + eids: { + 'mwOpenLinkId': { + source: 'mediawallahscript.com', + atype: 1 + }, } }; diff --git a/modules/my6senseBidAdapter.js b/modules/my6senseBidAdapter.js index 018baa37461..27eb9a9541d 100644 --- a/modules/my6senseBidAdapter.js +++ b/modules/my6senseBidAdapter.js @@ -1,6 +1,7 @@ import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; -const {registerBidder} = require('../src/adapters/bidderFactory.js'); const BIDDER_CODE = 'my6sense'; const END_POINT = 'https://hb.mynativeplatform.com/pub2/web/v1.15.0/hbwidget.json'; const END_POINT_METHOD = 'POST'; @@ -11,6 +12,7 @@ function isBidRequestValid(bid) { } function getUrl(url) { + // TODO: this should probably look at refererInfo if (!url) { url = window.location.href;// "clean" url of current web page } @@ -118,6 +120,9 @@ function buildGdprServerProperty(bidderRequest) { } function buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let requests = []; if (validBidRequests && validBidRequests.length) { diff --git a/modules/mytargetBidAdapter.js b/modules/mytargetBidAdapter.js index f55f2e6b802..b9ce8b133d1 100644 --- a/modules/mytargetBidAdapter.js +++ b/modules/mytargetBidAdapter.js @@ -51,7 +51,7 @@ export const spec = { let referrer = ''; if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; + referrer = bidderRequest.refererInfo.page; } const payload = { diff --git a/modules/nafdigitalBidAdapter.md b/modules/nafdigitalBidAdapter.md deleted file mode 100644 index b17b1f13e1e..00000000000 --- a/modules/nafdigitalBidAdapter.md +++ /dev/null @@ -1,38 +0,0 @@ -# Overview - -``` -Module Name: NAF Digital Bid Adapter -Module Type: Bidder Adapter -Maintainer: vyatsun@gmail.com -``` - -# Description - -NAF Digital adapter integration to the Prebid library. - -# Test Parameters - -``` -var adUnits = [ - { - code: 'test-leaderboard', - sizes: [[728, 90]], - bids: [{ - bidder: 'nafdigital', - params: { - publisherId: 2141020, - bidFloor: 0.01 - } - }] - }, { - code: 'test-banner', - sizes: [[300, 250]], - bids: [{ - bidder: 'nafdigital', - params: { - publisherId: 2141020 - } - }] - } -] -``` diff --git a/modules/nanointeractiveBidAdapter.md b/modules/nanointeractiveBidAdapter.md deleted file mode 100644 index c1790ff6337..00000000000 --- a/modules/nanointeractiveBidAdapter.md +++ /dev/null @@ -1,152 +0,0 @@ -# Overview - -``` -Module Name: Nano Interactive Bid Adapter -Module Type: Bidder Adapter -Maintainer: rade@nanointeractive.com -``` - -# Description - -Connects to Nano Interactive search retargeting Ad Server for bids. - - - -
-### Requirements: -To be able to get identification key (`pid`), please contact us at
-`https://www.nanointeractive.com/publishers`
-


- -#### Send All Bids Ad Server Keys: -(truncated to 20 chars due to [DFP limit](https://support.google.com/dfp_premium/answer/1628457?hl=en#Key-values)) - -`hb_adid_nanointeract` -`hb_bidder_nanointera` -`hb_pb_nanointeractiv` -`hb_format_nanointera` -`hb_size_nanointeract` -`hb_source_nanointera` - -#### Default Deal ID Keys: -`hb_deal_nanointeract` - -### bid params - -{: .table .table-bordered .table-striped } -| Name | Scope | Description | Example | -| :------------- | :------- | :----------------------------------------------- | :--------------------------- | -| `pid` | required | Identification key, provided by Nano Interactive | `'5afaa0280ae8996eb578de53'` | -| `category` | optional | Contextual taxonomy | `'automotive'` | -| `categoryName` | optional | Contextual taxonomy (from URL query param) | `'cat_name'` | -| `nq` | optional | User search query | `'automobile search query'` | -| `name` | optional | User search query (from URL query param) | `'search_param'` | -| `subId` | optional | Channel - used to separate traffic sources | `'123'` | - -#### Configuration -The `category` and `categoryName` are mutually exclusive. If you pass both, `categoryName` takes precedence. -
-The `nq` and `name` are mutually exclusive. If you pass both, `name` takes precedence. - -#### Example with only required field `pid` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53' - } - }] - }]; - -#### Example with `category` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53', - category: 'automotive', - subId: '123' - } - }] - }]; - -#### Example with `categoryName` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53', - // Category "automotive" is in the URL like: - // https://www....?cat_name=automotive&... - categoryName: 'cat_name', - subId: '123' - } - }] - }]; - -#### Example with `nq` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53', - // User searched "automobile search query" (extracted from search text field) - nq: 'automobile search query', - subId: '123' - } - }] - }]; - -#### Example with `name` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53', - // User searched "automobile search query" and it is in the URL like: - // https://www....?search_param=automobile%20search%20query&... - name: 'search_param', - subId: '123' - } - }] - }]; - -#### Example with `category` and `nq` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53', - category: 'automotive', - nq: 'automobile search query', - subId: '123' - } - }] - }]; - -#### Example with `categoryName` and `name` - var adUnits = [{ - code: 'nano-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'nanointeractive', - params: { - pid: '5afaa0280ae8996eb578de53', - categoryName: 'cat_name', - name: 'search_param', - subId: '123' - } - }] - }]; \ No newline at end of file diff --git a/modules/nasmediaAdmixerBidAdapter.md b/modules/nasmediaAdmixerBidAdapter.md deleted file mode 100644 index 096acf27f61..00000000000 --- a/modules/nasmediaAdmixerBidAdapter.md +++ /dev/null @@ -1,36 +0,0 @@ -# Overview - -``` -Module Name: NasmediaAdmixer Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebid@nasmedia.co.kr -``` -`` -# Description - -Module that connects to NasmediaAdmixer demand sources. -Banner formats are supported. -The NasmediaAdmixer adapter doesn't support multiple sizes per ad-unit and will use the first one if multiple sizes are defined. - -# Test Parameters -``` - var adUnits = [ - { - code: 'banner-ad-div', - mediaTypes: { - banner: { // banner size - sizes: [[300, 250]] - } - }, - bids: [ - { - bidder: 'nasmediaAdmixer', - params: { - media_key: '19038695', //required - adunit_id: '24190632', //required - } - } - ] - } - ]; -``` diff --git a/modules/nativoBidAdapter.js b/modules/nativoBidAdapter.js index e07a124665f..69a270247cd 100644 --- a/modules/nativoBidAdapter.js +++ b/modules/nativoBidAdapter.js @@ -1,7 +1,21 @@ import { deepAccess, isEmpty } from '../src/utils.js' import { registerBidder } from '../src/adapters/bidderFactory.js' import { BANNER } from '../src/mediaTypes.js' -// import { config } from 'src/config' +import { getGlobal } from '../src/prebidGlobal.js' +import { ortbConverter } from '../libraries/ortbConverter/converter.js' + +const converter = ortbConverter({ + context: { + // `netRevenue` and `ttl` are required properties of bid responses - provide a default for them + netRevenue: true, // or false if your adapter should set bidResponse.netRevenue = false + ttl: 30 // default bidResponse.ttl (when not specified in ORTB response.seatbid[].bid[].exp) + }, + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + imp.tagid = bidRequest.adUnitCode + return imp; + } +}); const BIDDER_CODE = 'nativo' const BIDDER_ENDPOINT = 'https://exchange.postrelease.com/prebid' @@ -11,12 +25,16 @@ const GVLID = 263 const TIME_TO_LIVE = 360 const SUPPORTED_AD_TYPES = [BANNER] +const FLOOR_PRICE_CURRENCY = 'USD' +const PRICE_FLOOR_WILDCARD = '*' + +const localPbjsRef = getGlobal() /** * Keep track of bid data by keys * @returns {Object} - Map of bid data that can be referenced by multiple keys */ -const BidDataMap = () => { +export const BidDataMap = () => { const referenceMap = {} const bids = [] @@ -25,7 +43,7 @@ const BidDataMap = () => { * @param {String} key - The key to store the index reference * @param {Integer} index - The index value of the bidData */ - function adKeyReference(key, index) { + function addKeyReference(key, index) { if (!referenceMap.hasOwnProperty(key)) { referenceMap[key] = index } @@ -42,12 +60,12 @@ const BidDataMap = () => { if (Array.isArray(keys)) { keys.forEach((key) => { - adKeyReference(String(key), index) + addKeyReference(String(key), index) }) return } - adKeyReference(String(keys), index) + addKeyReference(String(keys), index) } /** @@ -131,72 +149,115 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { + // Get OpenRTB Data + const openRTBData = converter.toORTB({bidRequests: validBidRequests, bidderRequest}) + const openRTBDataString = JSON.stringify(openRTBData) + + const requestData = new RequestData() + requestData.addBidRequestDataSource(new UserEIDs()) + + // Parse values from bid requests const placementIds = new Set() - let placementId, pageUrl const bidDataMap = BidDataMap() - validBidRequests.forEach((request) => { - pageUrl = deepAccess( - request, - 'params.url', - bidderRequest.refererInfo.referer - ) - placementId = deepAccess(request, 'params.placementId') + const placementSizes = { length: 0 } + const floorPriceData = {} + let placementId, pageUrl + validBidRequests.forEach((bidRequest) => { + pageUrl = + getPageUrlFromBidRequest(bidRequest) || + bidderRequest.refererInfo.location - if (placementId) { + placementId = deepAccess(bidRequest, 'params.placementId') + + const bidDataKeys = [bidRequest.adUnitCode] + + if (placementId && !placementIds.has(placementId)) { placementIds.add(placementId) + bidDataKeys.push(placementId) + + placementSizes[placementId] = bidRequest.sizes + placementSizes.length++ } const bidData = { - bidId: request.bidId, - size: getLargestSize(request.sizes), + bidId: bidRequest.bidId, + size: getLargestSize(bidRequest.sizes), + } + bidDataMap.addBidData(bidData, bidDataKeys) + + const bidRequestFloorPriceData = parseFloorPriceData(bidRequest) + if (bidRequestFloorPriceData) { + floorPriceData[bidRequest.adUnitCode] = bidRequestFloorPriceData } - bidDataMap.addBidData(bidData, [placementId, request.adUnitCode]) + + requestData.processBidRequestData(bidRequest, bidderRequest) }) bidRequestMap[bidderRequest.bidderRequestId] = bidDataMap // Build adUnit data - const adUnitData = { - adUnits: validBidRequests.map((adUnit) => { - // Track if we've already requested for this ad unit code - adUnitsRequested[adUnit.adUnitCode] = - adUnitsRequested[adUnit.adUnitCode] !== undefined - ? adUnitsRequested[adUnit.adUnitCode] + 1 - : 0 - return { - adUnitCode: adUnit.adUnitCode, - mediaTypes: adUnit.mediaTypes, - } - }), - } + const adUnitData = buildAdUnitData(validBidRequests) - // Build QS Params + // Build basic required QS Params let params = [ + // Prebid version + { + key: 'ntv_pbv', value: localPbjsRef.version + }, + // Prebid request id { key: 'ntv_pb_rid', value: bidderRequest.bidderRequestId }, + // Ad unit data { key: 'ntv_ppc', value: btoa(JSON.stringify(adUnitData)), // Convert to Base 64 }, + // Number count of requests per ad unit { key: 'ntv_dbr', - value: btoa(JSON.stringify(adUnitsRequested)), + value: btoa(JSON.stringify(adUnitsRequested)), // Convert to Base 64 }, + // Page url { key: 'ntv_url', value: encodeURIComponent(pageUrl), }, ] + // Floor pricing + if (Object.keys(floorPriceData).length) { + params.unshift({ + key: 'ntv_ppf', + value: btoa(JSON.stringify(floorPriceData)), + }) + } + // Add filtering if (adsToFilter.size > 0) { - params.unshift({ key: 'ntv_atf', value: Array.from(adsToFilter).join(',') }) + params.unshift({ + key: 'ntv_atf', + value: Array.from(adsToFilter).join(','), + }) } if (advertisersToFilter.size > 0) { - params.unshift({ key: 'ntv_avtf', value: Array.from(advertisersToFilter).join(',') }) + params.unshift({ + key: 'ntv_avtf', + value: Array.from(advertisersToFilter).join(','), + }) } if (campaignsToFilter.size > 0) { - params.unshift({ key: 'ntv_ctf', value: Array.from(campaignsToFilter).join(',') }) + params.unshift({ + key: 'ntv_ctf', + value: Array.from(campaignsToFilter).join(','), + }) + } + + // Placement Sizes + if (placementSizes.length) { + params.unshift({ + key: 'ntv_pas', + value: btoa(JSON.stringify(placementSizes)), + }) } // Add placement IDs @@ -223,9 +284,13 @@ export const spec = { params.unshift({ key: 'us_privacy', value: bidderRequest.uspConsent }) } + const qsParamStrings = [requestData.getRequestDataQueryString(), arrayToQS(params)] + const requestUrl = buildRequestUrl(BIDDER_ENDPOINT, qsParamStrings) + let serverRequest = { - method: 'GET', - url: BIDDER_ENDPOINT + arrayToQS(params), + method: 'POST', + url: requestUrl, + data: openRTBDataString, } return serverRequest @@ -344,10 +409,12 @@ export const spec = { return syncs } - body = - typeof response.body === 'string' - ? JSON.parse(response.body) - : response.body + try { + body = + typeof response.body === 'string' + ? JSON.parse(response.body) + : response.body + } catch (err) { return } // Make sure we have valid content if (!body || !body.seatbid || body.seatbid.length === 0) return @@ -370,13 +437,6 @@ export const spec = { return syncs }, - /** - * Will be called when an adpater timed out for an auction. - * Adapter can fire a ajax or pixel call to register a timeout at thier end. - * @param {Object} timeoutData - Timeout specific data - */ - onTimeout: function (timeoutData) {}, - /** * Will be called when a bid from the adapter won the auction. * @param {Object} bid - The bid that won the auction @@ -391,12 +451,6 @@ export const spec = { appendFilterData(campaignsToFilter, ext.campaignsToFilter) }, - /** - * Will be called when the adserver targeting has been set for a bid from the adapter. - * @param {Object} bidder - The bid of which the targeting has been set - */ - onSetTargeting: function (bid) {}, - /** * Maps Prebid's bidId to Nativo's placementId values per unique bidderRequestId * @param {String} bidderRequestId - The unique ID value associated with the bidderRequest @@ -417,6 +471,199 @@ export const spec = { registerBidder(spec) // Utils +export class RequestData { + constructor() { + this.bidRequestDataSources = [] + } + + addBidRequestDataSource(bidRequestDataSource) { + if (!(bidRequestDataSource instanceof BidRequestDataSource)) return + + this.bidRequestDataSources.push(bidRequestDataSource) + } + + processBidRequestData(bidRequest, bidderRequest) { + for (let bidRequestDataSource of this.bidRequestDataSources) { + bidRequestDataSource.processBidRequestData(bidRequest, bidderRequest) + } + } + + getRequestDataQueryString() { + if (this.bidRequestDataSources.length == 0) return + + const queryParams = this.bidRequestDataSources.map(dataSource => dataSource.getRequestQueryString()).filter(queryString => queryString !== '') + return queryParams.join('&') + } +} + +export class BidRequestDataSource { + constructor() { + this.type = 'BidRequestDataSource' + } + processBidRequestData(bidRequest, bidderRequest) { } + getRequestQueryString() { return '' } +} + +export class UserEIDs extends BidRequestDataSource { + constructor() { + super() + this.type = 'UserEIDs' + this.qsParam = new QueryStringParam('ntv_pb_eid') + this.eids = [] + } + + processBidRequestData(bidRequest, bidderRequest) { + if (bidRequest.userIdAsEids === undefined || this.eids.length > 0) return + this.eids = bidRequest.userIdAsEids + } + + getRequestQueryString() { + if (this.eids.length === 0) return '' + + const encodedValueArray = encodeToBase64(this.eids) + this.qsParam.value = encodedValueArray + return this.qsParam.toString() + } +} + +export class QueryStringParam { + constructor(key, value) { + this.key = key + this.value = value + } +} + +QueryStringParam.prototype.toString = function () { + return `${this.key}=${this.value}` +} + +export function encodeToBase64(value) { + try { + return btoa(JSON.stringify(value)) + } catch (err) { } +} + +export function parseFloorPriceData(bidRequest) { + if (typeof bidRequest.getFloor !== 'function') return + + // Setup price floor data per bid request + let bidRequestFloorPriceData = {} + let bidMediaTypes = bidRequest.mediaTypes + let sizeOptions = new Set() + // Step through meach media type so we can get floor data for each media type per bid request + Object.keys(bidMediaTypes).forEach((mediaType) => { + // Setup price floor data per media type + let mediaTypeData = bidMediaTypes[mediaType] + let mediaTypeFloorPriceData = {} + let mediaTypeSizes = mediaTypeData.sizes || mediaTypeData.playerSize || [] + // Step through each size of the media type so we can get floor data for each size per media type + mediaTypeSizes.forEach((size) => { + // Get floor price data per the getFloor method and respective media type / size combination + const priceFloorData = bidRequest.getFloor({ + currency: FLOOR_PRICE_CURRENCY, + mediaType, + size, + }) + // Save the data and track the sizes + mediaTypeFloorPriceData[sizeToString(size)] = priceFloorData.floor + sizeOptions.add(size) + }) + bidRequestFloorPriceData[mediaType] = mediaTypeFloorPriceData + + // Get floor price of current media type with a wildcard size + const sizeWildcardFloor = getSizeWildcardPrice(bidRequest, mediaType) + // Save the wildcard floor price if it was retrieved successfully + if (sizeWildcardFloor.floor > 0) { + mediaTypeFloorPriceData['*'] = sizeWildcardFloor.floor + } + }) + + // Get floor price for wildcard media type using all of the sizes present in the previous media types + const mediaWildCardPrices = getMediaWildcardPrices(bidRequest, [ + PRICE_FLOOR_WILDCARD, + ...Array.from(sizeOptions), + ]) + bidRequestFloorPriceData['*'] = mediaWildCardPrices + + return bidRequestFloorPriceData +} + +/** + * Get price floor data by always setting the size value to the wildcard for a specific size + * @param {Object} bidRequest - The bid request + * @param {String} mediaType - The media type + * @returns {Object} - Bid floor data + */ +export function getSizeWildcardPrice(bidRequest, mediaType) { + return bidRequest.getFloor({ + currency: FLOOR_PRICE_CURRENCY, + mediaType, + size: PRICE_FLOOR_WILDCARD, + }) +} + +/** + * Get price data for a range of sizes and always setting the media type to the wildcard value + * @param {*} bidRequest - The bid request + * @param {*} sizes - The sizes to get the floor price data for + * @returns {Object} - Bid floor data + */ +export function getMediaWildcardPrices( + bidRequest, + sizes = [PRICE_FLOOR_WILDCARD] +) { + const sizePrices = {} + sizes.forEach((size) => { + // MODIFY the bid request's mediaTypes property (so we can get the wildcard media type value) + const temp = bidRequest.mediaTypes + bidRequest.mediaTypes = { PRICE_FLOOR_WILDCARD: temp.sizes } + // Get price floor data + const priceFloorData = bidRequest.getFloor({ + currency: FLOOR_PRICE_CURRENCY, + mediaType: PRICE_FLOOR_WILDCARD, + size, + }) + // RESTORE initial property value + bidRequest.mediaTypes = temp + + // Only save valid floor price data + const key = + size !== PRICE_FLOOR_WILDCARD ? sizeToString(size) : PRICE_FLOOR_WILDCARD + sizePrices[key] = priceFloorData.floor + }) + return sizePrices +} + +/** + * Format size array to a string + * @param {Array} size - Size data [width, height] + * @returns {String} - Formated size string + */ +export function sizeToString(size) { + if (!Array.isArray(size) || size.length < 2) return '' + return `${size[0]}x${size[1]}` +} + +/** + * Build the ad unit data to send back to the request endpoint + * @param {Array} requests - Bid requests + * @returns {Array} - Array of ad unit data + */ +function buildAdUnitData(requests) { + return requests.map((request) => { + // Track if we've already requested for this ad unit code + adUnitsRequested[request.adUnitCode] = + adUnitsRequested[request.adUnitCode] !== undefined + ? adUnitsRequested[request.adUnitCode] + 1 + : 0 + // Return a new object with only the data we need + return { + adUnitCode: request.adUnitCode, + mediaTypes: request.mediaTypes, + } + }) +} + /** * Append QS param to existing string * @param {String} str - String to append to @@ -434,12 +681,9 @@ function appendQSParamString(str, key, value) { * @returns */ function arrayToQS(arr) { - return ( - '?' + - arr.reduce((value, obj) => { - return appendQSParamString(value, obj.key, obj.value) - }, '') - ) + return arr.reduce((value, obj) => { + return appendQSParamString(value, obj.key, obj.value) + }, '') } /** @@ -460,6 +704,24 @@ function getLargestSize(sizes, method = area) { }) } +/** + * Build the final request url + */ +export function buildRequestUrl(baseUrl, qsParamStringArray = []) { + if (qsParamStringArray.length === 0 || !Array.isArray(qsParamStringArray)) return baseUrl + + const nonEmptyQSParamStrings = qsParamStringArray.filter(qsParamString => qsParamString.trim() !== '') + + if (nonEmptyQSParamStrings.length === 0) return baseUrl + + let requestUrl = `${baseUrl}?${nonEmptyQSParamStrings[0]}` + for (let i = 1; i < nonEmptyQSParamStrings.length; i++) { + requestUrl += `&${nonEmptyQSParamStrings[i]}` + } + + return requestUrl +} + /** * Calculate the area * @param {Array} size - [width, height] @@ -477,3 +739,37 @@ function appendFilterData(filter, filterData) { filterData.forEach((ad) => filter.add(ad)) } } + +export function getPageUrlFromBidRequest(bidRequest) { + let paramPageUrl = deepAccess(bidRequest, 'params.url') + + if (paramPageUrl == undefined) return + + if (hasProtocol(paramPageUrl)) return paramPageUrl + + paramPageUrl = addProtocol(paramPageUrl) + + try { + const url = new URL(paramPageUrl) + return url.href + } catch (err) { } +} + +export function hasProtocol(url) { + const protocolRegexp = /^http[s]?\:/ + return protocolRegexp.test(url) +} + +export function addProtocol(url) { + if (hasProtocol(url)) { + return url + } + + let protocolPrefix = 'https:' + + if (url.indexOf('//') !== 0) { + protocolPrefix += '//' + } + + return `${protocolPrefix}${url}` +} diff --git a/modules/naveggIdSystem.js b/modules/naveggIdSystem.js index 7bd86879e9d..8a472259873 100644 --- a/modules/naveggIdSystem.js +++ b/modules/naveggIdSystem.js @@ -6,16 +6,53 @@ */ import { isStr, isPlainObject, logError } from '../src/utils.js'; import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import { ajax } from '../src/ajax.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'naveggId'; const OLD_NAVEGG_ID = 'nid'; -const NAVEGG_ID = 'nvggid' +const NAVEGG_ID = 'nvggid'; +const BASE_URL = 'https://id.navegg.com/uid/'; +const DEFAULT_EXPIRE = 8 * 24 * 3600 * 1000; +const INVALID_EXPIRE = 3600 * 1000; -export const storage = getStorageManager(); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); + +function getNaveggIdFromApi() { + const callbacks = { + success: response => { + if (response) { + try { + const responseObj = JSON.parse(response); + writeCookie(NAVEGG_ID, responseObj[NAVEGG_ID]); + } catch (error) { + logError(error); + } + } + }, + error: error => { + logError('Navegg ID fetch encountered an error', error); + } + }; + ajax(BASE_URL, callbacks, undefined, { method: 'GET', withCredentials: false }); +} + +function writeCookie(key, value) { + try { + if (storage.cookiesAreEnabled) { + let expTime = new Date(); + const expires = value ? DEFAULT_EXPIRE : INVALID_EXPIRE; + expTime.setTime(expTime.getTime() + expires); + storage.setCookie(key, value, expTime.toUTCString(), 'none'); + } + } catch (e) { + logError(e); + } +} function readnaveggIdFromLocalStorage() { - return storage.getDataFromLocalStorage(NAVEGG_ID); + return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(NAVEGG_ID) : null; } function readnaveggIDFromCookie() { @@ -34,48 +71,33 @@ function readnavIDFromCookie() { return storage.cookiesAreEnabled ? (storage.findSimilarCookies('nav') ? storage.findSimilarCookies('nav')[0] : null) : null; } -function readnvgnavFromLocalStorage() { - var i; - const query = '^nvg|^nav'; - for (i in window.localStorage) { - if (i.match(query) || (!query && typeof i === 'string')) { - return storage.getDataFromLocalStorage(i.match(query).input); - } - } -} - /** @type {Submodule} */ export const naveggIdSubmodule = { /** - * used to link submodule with config - * @type {string} - */ + * used to link submodule with config + * @type {string} + */ name: MODULE_NAME, /** - * decode the stored id value for passing to bid requests - * @function - * @param { Object | string | undefined } value - * @return { Object | string | undefined } - */ + * decode the stored id value for passing to bid requests + * @function + * @param { Object | string | undefined } value + * @return { Object | string | undefined } + */ decode(value) { const naveggIdVal = value ? isStr(value) ? value : isPlainObject(value) ? value.id : undefined : undefined; return naveggIdVal ? { - 'naveggId': naveggIdVal + 'naveggId': naveggIdVal.split('|')[0] } : undefined; }, /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleConfig} config - * @return {{id: string | undefined } | undefined} - */ + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} config + * @return {{id: string | undefined } | undefined} + */ getId() { - let naveggIdStringFromLocalStorage = null; - if (storage.localStorageIsEnabled) { - naveggIdStringFromLocalStorage = readnaveggIdFromLocalStorage() || readnvgnavFromLocalStorage(); - } - - const naveggIdString = naveggIdStringFromLocalStorage || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie(); + const naveggIdString = readnaveggIdFromLocalStorage() || readnaveggIDFromCookie() || getNaveggIdFromApi() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie(); if (typeof naveggIdString == 'string' && naveggIdString) { try { @@ -85,6 +107,12 @@ export const naveggIdSubmodule = { } } return undefined; + }, + eids: { + 'naveggId': { + source: 'navegg.com', + atype: 1 + }, } }; submodule('userId', naveggIdSubmodule); diff --git a/modules/netIdSystem.js b/modules/netIdSystem.js index 90c8735c993..6f1ffe8b0e7 100644 --- a/modules/netIdSystem.js +++ b/modules/netIdSystem.js @@ -34,6 +34,12 @@ export const netIdSubmodule = { getId(config) { /* currently not possible */ return {}; + }, + eids: { + 'netId': { + source: 'netid.de', + atype: 1 + }, } }; diff --git a/modules/neuwoRtdProvider.js b/modules/neuwoRtdProvider.js new file mode 100644 index 00000000000..881bbc10b11 --- /dev/null +++ b/modules/neuwoRtdProvider.js @@ -0,0 +1,174 @@ +import { deepAccess, deepSetValue, generateUUID, logError, logInfo, mergeDeep } from '../src/utils.js'; +import { getRefererInfo } from '../src/refererDetection.js'; +import { ajax } from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import * as events from '../src/events.js'; +import CONSTANTS from '../src/constants.json'; + +export const DATA_PROVIDER = 'neuwo.ai'; +const SEGTAX_IAB = 6 // IAB - Content Taxonomy version 2 +const RESPONSE_IAB_TIER_1 = 'marketing_categories.iab_tier_1' +const RESPONSE_IAB_TIER_2 = 'marketing_categories.iab_tier_2' + +function init(config, userConsent) { + // config.params = config.params || {} + // ignore module if publicToken is missing (module setup failure) + if (!config || !config.params || !config.params.publicToken) { + logError('publicToken missing', 'NeuwoRTDModule', 'config.params.publicToken') + return false; + } + if (!config || !config.params || !config.params.apiUrl) { + logError('apiUrl missing', 'NeuwoRTDModule', 'config.params.apiUrl') + return false; + } + return true; +} + +export function getBidRequestData(reqBidsConfigObj, callback, config, userConsent) { + const confParams = config.params || {}; + logInfo('NeuwoRTDModule', 'starting getBidRequestData') + + const wrappedArgUrl = encodeURIComponent(confParams.argUrl || getRefererInfo().page); + /* adjust for pages api.url?prefix=test (to add params with '&') as well as api.url (to add params with '?') */ + const joiner = confParams.apiUrl.indexOf('?') < 0 ? '?' : '&' + const url = confParams.apiUrl + joiner + [ + 'token=' + confParams.publicToken, + 'url=' + wrappedArgUrl + ].join('&') + const billingId = generateUUID(); + + const success = (responseContent) => { + logInfo('NeuwoRTDModule', 'GetAiTopics: response', responseContent) + try { + const jsonContent = JSON.parse(responseContent); + if (jsonContent.marketing_categories) { + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { type: 'request', billingId, vendor: neuwoRtdModule.name }) + } + injectTopics(jsonContent, reqBidsConfigObj, billingId) + } catch (ex) { + logError('NeuwoRTDModule', 'Response to JSON parse error', ex) + } + callback() + } + + const error = (err) => { + logError('xhr error', null, err); + callback() + } + + ajax(url, {success, error}, null, { + // could assume Origin header is set, or + // customHeaders: { 'Origin': 'Origin' } + }) +} + +export function addFragment(base, path, addition) { + const container = {} + deepSetValue(container, path, addition) + mergeDeep(base, container) +} + +/** + * Concatenate a base array and an array within an object + * non-array bases will be arrays, non-arrays at object key will be discarded + * @param {array} base base array to add to + * @param {object} source object to get an array from + * @param {string} key dot-notated path to array within object + * @returns base + source[key] if that's an array + */ +function combineArray(base, source, key) { + if (Array.isArray(base) === false) base = [] + const addition = deepAccess(source, key, []) + if (Array.isArray(addition)) return base.concat(addition) + else return base +} + +export function injectTopics(topics, bidsConfig) { + topics = topics || {} + + // join arrays of IAB category details to single array + const combinedTiers = combineArray( + combineArray([], topics, RESPONSE_IAB_TIER_1), + topics, RESPONSE_IAB_TIER_2) + + const segment = pickSegments(combinedTiers) + // effectively gets topics.marketing_categories.iab_tier_1, topics.marketing_categories.iab_tier_2 + // used as FPD segments content + + const IABSegments = { + name: DATA_PROVIDER, + ext: { segtax: SEGTAX_IAB }, + segment + } + + addFragment(bidsConfig.ortb2Fragments.global, 'site.content.data', [IABSegments]) + + // upgrade category taxonomy to IAB 2.2, inject result to page categories + if (segment.length > 0) { + addFragment(bidsConfig.ortb2Fragments.global, 'site.pagecat', segment.map(s => s.id)) + } + + logInfo('NeuwoRTDModule', 'injectTopics: post-injection bidsConfig', bidsConfig) +} + +/* eslint-disable object-property-newline */ +const D_IAB_ID = { // Content Taxonomy version 2.0 final release November 2017 [sic] (Taxonomy ID Mapping, IAB versions 2.0 - 2.2) + 'IAB19-1': '603', 'IAB6-1': '193', 'IAB5-2': '133', 'IAB20-1': '665', 'IAB20-2': '656', 'IAB23-2': '454', 'IAB3-2': '102', 'IAB20-3': '672', 'IAB8-5': '211', + 'IAB8-18': '211', 'IAB7-4': '288', 'IAB7-5': '233', 'IAB17-12': '484', 'IAB19-3': '608', 'IAB21-1': '442', 'IAB9-2': '248', 'IAB15-1': '456', 'IAB9-17': '265', 'IAB20-4': '658', + 'IAB2-3': '30', 'IAB2-1': '32', 'IAB17-1': '518', 'IAB2-2': '34', 'IAB2': '1', 'IAB8-2': '215', 'IAB17-2': '545', 'IAB17-26': '547', 'IAB9-3': '249', 'IAB18-1': '553', 'IAB20-5': '674', + 'IAB15-2': '465', 'IAB3-3': '119', 'IAB16-2': '423', 'IAB9-4': '259', 'IAB9-5': '270', 'IAB18-2': '574', 'IAB17-4': '549', 'IAB7-33': '312', 'IAB1-1': '42', 'IAB17-5': '485', 'IAB23-3': '458', + 'IAB20-6': '675', 'IAB3': '53', 'IAB20-7': '676', 'IAB19-5': '633', 'IAB20-9': '677', 'IAB9-6': '250', 'IAB17-6': '499', 'IAB2-4': '25', 'IAB9-7': '271', 'IAB4-11': '125', 'IAB4-1': '126', + 'IAB4': '123', 'IAB16-3': '424', 'IAB2-5': '18', 'IAB17-7': '486', 'IAB15-3': '466', 'IAB23-5': '459', 'IAB9-9': '260', 'IAB2-22': '19', 'IAB17-8': '500', 'IAB9-10': '261', 'IAB5-5': '137', + 'IAB9-11': '262', 'IAB2-21': '3', 'IAB19-2': '610', 'IAB19-8': '600', 'IAB19-9': '601', 'IAB3-5': '121', 'IAB9-15': '264', 'IAB2-6': '8', 'IAB2-7': '9', 'IAB22-2': '474', 'IAB17-9': '491', + 'IAB2-8': '10', 'IAB20-12': '678', 'IAB17-3': '492', 'IAB19-12': '611', 'IAB14-1': '188', 'IAB6-3': '194', 'IAB7-17': '316', 'IAB19-13': '612', 'IAB8-8': '217', 'IAB9-1': '205', 'IAB19-22': '613', + 'IAB8-9': '218', 'IAB14-2': '189', 'IAB16-4': '425', 'IAB9-12': '251', 'IAB5': '132', 'IAB6-9': '190', 'IAB19-15': '623', 'IAB17-17': '496', 'IAB20-14': '659', 'IAB6': '186', 'IAB20-26': '666', + 'IAB17-10': '510', 'IAB13-4': '396', 'IAB1-3': '201', 'IAB16-1': '426', 'IAB17-11': '511', 'IAB17-13': '511', 'IAB17-32': '511', 'IAB7-1': '225', 'IAB8': '210', 'IAB8-10': '219', 'IAB9-13': '266', + 'IAB10-4': '275', 'IAB9-14': '273', 'IAB15-8': '469', 'IAB15-4': '470', 'IAB17-15': '512', 'IAB3-7': '77', 'IAB19-16': '614', 'IAB3-8': '78', 'IAB2-10': '22', 'IAB2-12': '22', 'IAB2-11': '11', + 'IAB8-12': '221', 'IAB7-35': '223', 'IAB7-38': '223', 'IAB7-24': '296', 'IAB13-5': '411', 'IAB7-25': '234', 'IAB23-6': '460', 'IAB9': '239', 'IAB7-26': '235', 'IAB10': '274', 'IAB10-1': '278', + 'IAB10-2': '279', 'IAB19-17': '634', 'IAB10-5': '280', 'IAB5-10': '145', 'IAB5-11': '146', 'IAB20-17': '667', 'IAB17-16': '497', 'IAB20-18': '668', 'IAB3-9': '55', 'IAB1-4': '440', 'IAB17-18': '514', + 'IAB17-27': '515', 'IAB10-3': '282', 'IAB19-25': '618', 'IAB17-19': '516', 'IAB13-6': '398', 'IAB10-7': '283', 'IAB12-1': '382', 'IAB19-24': '624', 'IAB6-4': '195', 'IAB23-7': '461', 'IAB9-19': '252', + 'IAB4-4': '128', 'IAB4-5': '127', 'IAB23-8': '462', 'IAB10-8': '284', 'IAB5-8': '147', 'IAB16-5': '427', 'IAB11-2': '383', 'IAB12-3': '384', 'IAB3-10': '57', 'IAB2-13': '23', 'IAB9-20': '241', + 'IAB3-1': '58', 'IAB3-11': '58', 'IAB14-4': '191', 'IAB17-20': '520', 'IAB7-31': '228', 'IAB7-37': '301', 'IAB3-12': '107', 'IAB2-14': '13', 'IAB17-25': '519', 'IAB2-15': '27', 'IAB1-5': '324', + 'IAB1-6': '338', 'IAB9-16': '243', 'IAB13-8': '412', 'IAB12-2': '385', 'IAB9-21': '253', 'IAB8-6': '222', 'IAB7-32': '229', 'IAB2-16': '14', 'IAB17-23': '521', 'IAB13-9': '413', 'IAB17-24': '501', + 'IAB9-22': '254', 'IAB15-5': '244', 'IAB6-2': '196', 'IAB6-5': '197', 'IAB6-6': '198', 'IAB2-17': '24', 'IAB13-2': '405', 'IAB13': '391', 'IAB13-7': '410', 'IAB13-12': '415', 'IAB16': '422', + 'IAB9-23': '255', 'IAB7-36': '236', 'IAB15-6': '471', 'IAB2-18': '15', 'IAB11-4': '386', 'IAB1-2': '432', 'IAB5-9': '139', 'IAB6-7': '305', 'IAB5-12': '149', 'IAB5-13': '134', 'IAB19-4': '631', + 'IAB19-19': '631', 'IAB19-20': '631', 'IAB19-32': '631', 'IAB9-24': '245', 'IAB21': '441', 'IAB21-3': '451', 'IAB23': '453', 'IAB10-9': '276', 'IAB4-9': '130', 'IAB16-6': '429', 'IAB4-6': '129', + 'IAB13-10': '416', 'IAB2-19': '28', 'IAB17-28': '525', 'IAB9-25': '272', 'IAB17-29': '527', 'IAB17-30': '227', 'IAB17-31': '530', 'IAB22-1': '481', 'IAB15': '464', 'IAB9-26': '246', 'IAB9-27': '256', + 'IAB9-28': '267', 'IAB17-33': '502', 'IAB19-35': '627', 'IAB2-20': '4', 'IAB7-39': '307', 'IAB19-30': '605', 'IAB22': '473', 'IAB17-34': '503', 'IAB17-35': '531', 'IAB7-19': '309', 'IAB7-40': '310', + 'IAB19-6': '635', 'IAB7-41': '237', 'IAB17-36': '504', 'IAB17-44': '533', 'IAB20-23': '662', 'IAB15-7': '472', 'IAB20-24': '671', 'IAB5-14': '136', 'IAB6-8': '199', 'IAB17': '483', 'IAB9-29': '263', + 'IAB2-23': '5', 'IAB13-11': '414', 'IAB4-3': '395', 'IAB18': '552', 'IAB7-42': '311', 'IAB17-37': '505', 'IAB17-38': '537', 'IAB17-39': '538', 'IAB19-26': '636', 'IAB19': '596', 'IAB1-7': '640', + 'IAB17-40': '539', 'IAB7-43': '293', 'IAB20': '653', 'IAB8-16': '212', 'IAB8-17': '213', 'IAB16-7': '430', 'IAB9-30': '680', 'IAB17-41': '541', 'IAB17-42': '542', 'IAB17-43': '506', 'IAB15-10': '390', + 'IAB19-23': '607', 'IAB19-34': '629', 'IAB14-7': '165', 'IAB7-44': '231', 'IAB7-45': '238', 'IAB9-31': '257', 'IAB5-1': '135', 'IAB7-2': '301', 'IAB18-6': '580', 'IAB7-3': '297', 'IAB23-1': '453', + 'IAB8-1': '214', 'IAB7-6': '312', 'IAB7-7': '300', 'IAB7-8': '301', 'IAB13-1': '410', 'IAB7-9': '301', 'IAB15-9': '465', 'IAB7-10': '313', 'IAB3-4': '602', 'IAB20-8': '660', 'IAB8-3': '214', + 'IAB20-10': '660', 'IAB7-11': '314', 'IAB20-11': '660', 'IAB23-4': '459', 'IAB9-8': '270', 'IAB8-4': '214', 'IAB7-12': '306', 'IAB7-13': '313', 'IAB7-14': '287', 'IAB18-5': '575', 'IAB7-15': '315', + 'IAB8-7': '214', 'IAB19-11': '616', 'IAB7-16': '289', 'IAB7-18': '301', 'IAB7-20': '290', 'IAB20-13': '659', 'IAB7-21': '313', 'IAB18-3': '579', 'IAB13-3': '52', 'IAB20-15': '659', 'IAB8-11': '214', + 'IAB7-22': '318', 'IAB20-16': '659', 'IAB7-23': '313', 'IAB7': '223', 'IAB10-6': '634', 'IAB7-27': '318', 'IAB11-1': '388', 'IAB7-29': '318', 'IAB7-30': '304', 'IAB19-18': '619', 'IAB8-13': '214', + 'IAB20-19': '659', 'IAB20-20': '657', 'IAB8-14': '214', 'IAB18-4': '565', 'IAB23-9': '459', 'IAB11': '379', 'IAB8-15': '214', 'IAB20-21': '662', 'IAB17-21': '492', 'IAB17-22': '518', 'IAB12': '379', + 'IAB23-10': '453', 'IAB7-34': '301', 'IAB4-8': '395', 'IAB26-3': '608', 'IAB20-25': '151', 'IAB20-27': '659' +} + +export function convertSegment(segment) { + if (!segment) return {} + return { + id: D_IAB_ID[segment.id || segment.ID] + } +} + +/** + * map array of objects to segments + * @param {Array[{ID: string}]} normalizable + * @returns array of IAB "segments" + */ +export function pickSegments(normalizable) { + if (Array.isArray(normalizable) === false) return [] + return normalizable.map(convertSegment) + .filter(t => t.id) +} + +export const neuwoRtdModule = { + name: 'NeuwoRTDModule', + init, + getBidRequestData +} + +submodule('realTimeData', neuwoRtdModule) diff --git a/modules/neuwoRtdProvider.md b/modules/neuwoRtdProvider.md new file mode 100644 index 00000000000..fb52734d451 --- /dev/null +++ b/modules/neuwoRtdProvider.md @@ -0,0 +1,51 @@ +# Overview + +Module Name: Neuwo Rtd Provider +Module Type: Rtd Provider +Maintainer: neuwo.ai + +# Description + +The Neuwo AI RTD module is an advanced AI solution for real-time data processing in the field of contextual targeting and advertising. With its cutting-edge algorithms, it allows advertisers to target their audiences with the highest level of precision based on context, while also delivering a seamless user experience. + +The module provides advertiser with valuable insights and real-time contextual bidding capabilities. Whether you're a seasoned advertising professional or just starting out, Neuwo AI RTD module is the ultimate tool for contextual targeting and advertising. + +The benefit of Neuwo AI RTD module is that it provides an alternative solution for advertisers to target their audiences and deliver relevant advertisements, as the widespread use of cookies for tracking and targeting is becoming increasingly limited. + +The RTD module uses cutting-edge algorithms to process real-time data, allowing advertisers to target their audiences based on contextual information, such as segments, IAB Tiers and brand safety. The RTD module is designed to be flexible and scalable, making it an ideal solution for advertisers looking to stay ahead of the curve in the post-cookie era. + +Generate your token at: [https://neuwo.ai/generatetoken/] + +# Configuration + +```javascript + +const neuwoDataProvider = { + name: 'NeuwoRTDModule', + params: { + publicToken: '', + apiUrl: '' + } +} +pbjs.setConfig({realTimeData: { dataProviders: [ neuwoDataProvider ]}}) + +``` + +# Testing + +`gulp test --modules=rtdModule,neuwoRtdProvider` + +## Add development tools if necessary + +- Install node for npm +- run in prebid.js source folder: +`npm ci` +`npm i -g gulp-cli` + +## Serve + +`gulp serve --modules=rtdModule,neuwoRtdProvider,appnexusBidAdapter` + +- in your browser, navigate to: + +`http://localhost:9999/integrationExamples/gpt/neuwoRtdProvider_example.html` diff --git a/modules/newborntownWebBidAdapter.md b/modules/newborntownWebBidAdapter.md deleted file mode 100644 index f607369ffb6..00000000000 --- a/modules/newborntownWebBidAdapter.md +++ /dev/null @@ -1,35 +0,0 @@ -# Overview - -``` -Module Name: NewborntownWeb Bidder Adapter -Module Type: Bidder Adapter -Maintainer: zhuyushuang@newborntown.com -``` - -# Description - -Integration for website - -# Test Parameters -``` - var adUnits = [ - { - code: '/19968336/header-bid-tag-1', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bids: [ - { - bidder: "newborntownWeb", - params: { - 'publisher_id': '1238122', - 'slot_id': '123123', - 'bidfloor': 0.2 - } - } - ] - } - ]; -``` diff --git a/modules/newspassid.md b/modules/newspassid.md new file mode 100644 index 00000000000..6fa709e5ba6 --- /dev/null +++ b/modules/newspassid.md @@ -0,0 +1,76 @@ +--- +Module Name: NewspassId Bidder Adapter +Module Type: Bidder Adapter +Maintainer: techsupport@newspassid.com +layout: bidder +title: Newspass ID +description: LMC Newspass ID Prebid JS Bidder Adapter +biddercode: newspassid +gdpr_supported: false +gvl_id: none +usp_supported: true +coppa_supported: false +schain_supported: true +dchain_supported: false +userIds: criteo, id5Id, tdid, identityLink, liveIntentId, parrableId, pubCommonId, lotamePanoramaId, sharedId, fabrickId +media_types: banner +safeframes_ok: true +deals_supported: true +floors_supported: false +fpd_supported: false +pbjs: true +pbs: false +prebid_member: false +multiformat_supported: will-bid-on-any +--- + +### Description + +LMC Newspass ID Prebid JS Bidder Adapter that connects to the NewspassId demand source(s). + +The Newspass bid adapter supports Banner mediaTypes ONLY. +This is intended for USA audiences only, and does not support GDPR + + +### Bid Params + +{: .table .table-bordered .table-striped } + +| Name | Scope | Description | Example | Type | +|-----------|----------|---------------------------|------------|----------| +| `siteId` | required | The site ID. | `"NPID0000001"` | `string` | +| `publisherId` | required | The publisher ID. | `"4204204201"` | `string` | +| `placementId` | required | The placement ID. | `"0420420421"` | `string` | +| `customData` | optional | publisher key-values used for targeting | `[{"settings":{},"targeting":{"key1": "value1", "key2": "value2"}}], ` | `array` | + +### Test Parameters + + +A test ad unit that will consistently return test creatives: + +``` + +//Banner adUnit + +adUnits = [{ + code: 'id-of-your-banner-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'newspassid', + params: { + publisherId: 'NEWSPASS0001', /* an ID to identify the publisher account - required */ + siteId: '4204204201', /* An ID used to identify a site within a publisher account - required */ + placementId: '8000000015', /* an ID used to identify the piece of inventory - required - for appnexus test use 13144370. */ + customData: [{"settings": {}, "targeting": {"key": "value", "key2": ["value1", "value2"]}}],/* optional array with 'targeting' placeholder for passing publisher specific key-values for targeting. */ + } + }] + }]; +``` + +### Note: + +Please contact us at techsupport@newspassid.com for any assistance testing your implementation before going live into production. diff --git a/modules/newspassidBidAdapter.js b/modules/newspassidBidAdapter.js new file mode 100644 index 00000000000..2a4b2da186b --- /dev/null +++ b/modules/newspassidBidAdapter.js @@ -0,0 +1,677 @@ +import { + logInfo, + logError, + deepAccess, + logWarn, + deepSetValue, + isArray, + contains, + parseUrl, + generateUUID +} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import {getPriceBucketString} from '../src/cpmBucketManager.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +const BIDDER_CODE = 'newspassid'; +const ORIGIN = 'https://bidder.newspassid.com' // applies only to auction & cookie +const AUCTIONURI = '/openrtb2/auction'; +const NEWSPASSCOOKIESYNC = '/static/load-cookie.html'; +const NEWSPASSVERSION = '1.1.4'; +export const spec = { + version: NEWSPASSVERSION, + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + cookieSyncBag: {publisherId: null, siteId: null, userIdObject: {}}, // variables we want to make available to cookie sync + propertyBag: {config: null, pageId: null, buildRequestsStart: 0, buildRequestsEnd: 0, endpointOverride: null}, /* allow us to store vars in instance scope - needs to be an object to be mutable */ + config_defaults: { + 'logId': 'NEWSPASSID', + 'bidder': 'newspassid', + 'auctionUrl': ORIGIN + AUCTIONURI, + 'cookieSyncUrl': ORIGIN + NEWSPASSCOOKIESYNC + }, + loadConfiguredData(bid) { + if (this.propertyBag.config) { return; } + this.propertyBag.config = JSON.parse(JSON.stringify(this.config_defaults)); + let bidder = bid.bidder || 'newspassid'; + this.propertyBag.config.logId = bidder.toUpperCase(); + this.propertyBag.config.bidder = bidder; + let bidderConfig = config.getConfig(bidder) || {}; + logInfo('got bidderConfig: ', JSON.parse(JSON.stringify(bidderConfig))); + let arrGetParams = this.getGetParametersAsObject(); + if (bidderConfig.endpointOverride) { + if (bidderConfig.endpointOverride.origin) { + this.propertyBag.endpointOverride = bidderConfig.endpointOverride.origin; + this.propertyBag.config.auctionUrl = bidderConfig.endpointOverride.origin + AUCTIONURI; + this.propertyBag.config.cookieSyncUrl = bidderConfig.endpointOverride.origin + NEWSPASSCOOKIESYNC; + } + if (bidderConfig.endpointOverride.cookieSyncUrl) { + this.propertyBag.config.cookieSyncUrl = bidderConfig.endpointOverride.cookieSyncUrl; + } + if (bidderConfig.endpointOverride.auctionUrl) { + this.propertyBag.endpointOverride = bidderConfig.endpointOverride.auctionUrl; + this.propertyBag.config.auctionUrl = bidderConfig.endpointOverride.auctionUrl; + } + } + try { + if (arrGetParams.hasOwnProperty('auction')) { + logInfo('GET: setting auction endpoint to: ' + arrGetParams.auction); + this.propertyBag.config.auctionUrl = arrGetParams.auction; + } + if (arrGetParams.hasOwnProperty('cookiesync')) { + logInfo('GET: setting cookiesync to: ' + arrGetParams.cookiesync); + this.propertyBag.config.cookieSyncUrl = arrGetParams.cookiesync; + } + } catch (e) {} + logInfo('set propertyBag.config to', this.propertyBag.config); + }, + getAuctionUrl() { + return this.propertyBag.config.auctionUrl; + }, + getCookieSyncUrl() { + return this.propertyBag.config.cookieSyncUrl; + }, + isBidRequestValid(bid) { + this.loadConfiguredData(bid); + logInfo('isBidRequestValid : ', config.getConfig(), bid); + let adUnitCode = bid.adUnitCode; // adunit[n].code + let err1 = 'VALIDATION FAILED : missing {param} : siteId, placementId and publisherId are REQUIRED'; + if (!(bid.params.hasOwnProperty('placementId'))) { + logError(err1.replace('{param}', 'placementId'), adUnitCode); + return false; + } + if (!this.isValidPlacementId(bid.params.placementId)) { + logError('VALIDATION FAILED : placementId must be exactly 10 numeric characters', adUnitCode); + return false; + } + if (!(bid.params.hasOwnProperty('publisherId'))) { + logError(err1.replace('{param}', 'publisherId'), adUnitCode); + return false; + } + if (!(bid.params.publisherId).toString().match(/^[a-zA-Z0-9\-]{12}$/)) { + logError('VALIDATION FAILED : publisherId must be exactly 12 alphanumeric characters including hyphens', adUnitCode); + return false; + } + if (!(bid.params.hasOwnProperty('siteId'))) { + logError(err1.replace('{param}', 'siteId'), adUnitCode); + return false; + } + if (!(bid.params.siteId).toString().match(/^[0-9]{10}$/)) { + logError('VALIDATION FAILED : siteId must be exactly 10 numeric characters', adUnitCode); + return false; + } + if (bid.params.hasOwnProperty('customParams')) { + logError('VALIDATION FAILED : customParams should be renamed to customData', adUnitCode); + return false; + } + if (bid.params.hasOwnProperty('customData')) { + if (!Array.isArray(bid.params.customData)) { + logError('VALIDATION FAILED : customData is not an Array', adUnitCode); + return false; + } + if (bid.params.customData.length < 1) { + logError('VALIDATION FAILED : customData is an array but does not contain any elements', adUnitCode); + return false; + } + if (!(bid.params.customData[0]).hasOwnProperty('targeting')) { + logError('VALIDATION FAILED : customData[0] does not contain "targeting"', adUnitCode); + return false; + } + if (typeof bid.params.customData[0]['targeting'] != 'object') { + logError('VALIDATION FAILED : customData[0] targeting is not an object', adUnitCode); + return false; + } + } + return true; + }, + isValidPlacementId(placementId) { + return placementId.toString().match(/^[0-9]{10}$/); + }, + buildRequests(validBidRequests, bidderRequest) { + this.loadConfiguredData(validBidRequests[0]); + this.propertyBag.buildRequestsStart = new Date().getTime(); + logInfo(`buildRequests time: ${this.propertyBag.buildRequestsStart} v ${NEWSPASSVERSION} validBidRequests`, JSON.parse(JSON.stringify(validBidRequests)), 'bidderRequest', JSON.parse(JSON.stringify(bidderRequest))); + if (this.blockTheRequest()) { + return []; + } + let htmlParams = {'publisherId': '', 'siteId': ''}; + if (validBidRequests.length > 0) { + this.cookieSyncBag.userIdObject = Object.assign(this.cookieSyncBag.userIdObject, this.findAllUserIds(validBidRequests[0])); + this.cookieSyncBag.siteId = deepAccess(validBidRequests[0], 'params.siteId'); + this.cookieSyncBag.publisherId = deepAccess(validBidRequests[0], 'params.publisherId'); + htmlParams = validBidRequests[0].params; + } + logInfo('cookie sync bag', this.cookieSyncBag); + let singleRequest = config.getConfig('newspassid.singleRequest'); + singleRequest = singleRequest !== false; // undefined & true will be true + logInfo(`config newspassid.singleRequest : `, singleRequest); + let npRequest = {}; // we only want to set specific properties on this, not validBidRequests[0].params + logInfo('going to get ortb2 from bidder request...'); + let fpd = deepAccess(bidderRequest, 'ortb2', null); + logInfo('got fpd: ', fpd); + if (fpd && deepAccess(fpd, 'user')) { + logInfo('added FPD user object'); + npRequest.user = fpd.user; + } + const getParams = this.getGetParametersAsObject(); + const isTestMode = getParams['nptestmode'] || null; // this can be any string, it's used for testing ads + npRequest.device = {'w': window.innerWidth, 'h': window.innerHeight}; + let placementIdOverrideFromGetParam = this.getPlacementIdOverrideFromGetParam(); // null or string + let schain = null; + let tosendtags = validBidRequests.map(npBidRequest => { + var obj = {}; + let placementId = placementIdOverrideFromGetParam || this.getPlacementId(npBidRequest); // prefer to use a valid override param, else the bidRequest placement Id + obj.id = npBidRequest.bidId; // this causes an error if we change it to something else, even if you update the bidRequest object: "WARNING: Bidder newspass made bid for unknown request ID: mb7953.859498327448. Ignoring." + obj.tagid = placementId; + let parsed = parseUrl(this.getRefererInfo().page); + obj.secure = parsed.protocol === 'https' ? 1 : 0; + let arrBannerSizes = []; + if (!npBidRequest.hasOwnProperty('mediaTypes')) { + if (npBidRequest.hasOwnProperty('sizes')) { + logInfo('no mediaTypes detected - will use the sizes array in the config root'); + arrBannerSizes = npBidRequest.sizes; + } else { + logInfo('Cannot set sizes for banner type'); + } + } else { + if (npBidRequest.mediaTypes.hasOwnProperty(BANNER)) { + arrBannerSizes = npBidRequest.mediaTypes[BANNER].sizes; /* Note - if there is a sizes element in the config root it will be pushed into here */ + logInfo('setting banner size from the mediaTypes.banner element for bidId ' + obj.id + ': ', arrBannerSizes); + } + if (npBidRequest.mediaTypes.hasOwnProperty(NATIVE)) { + obj.native = npBidRequest.mediaTypes[NATIVE]; + logInfo('setting native object from the mediaTypes.native element: ' + obj.id + ':', obj.native); + } + } + if (arrBannerSizes.length > 0) { + obj.banner = { + topframe: 1, + w: arrBannerSizes[0][0] || 0, + h: arrBannerSizes[0][1] || 0, + format: arrBannerSizes.map(s => { + return {w: s[0], h: s[1]}; + }) + }; + } + obj.placementId = placementId; + deepSetValue(obj, 'ext.prebid', {'storedrequest': {'id': placementId}}); + obj.ext['newspassid'] = {}; + obj.ext['newspassid'].adUnitCode = npBidRequest.adUnitCode; // eg. 'mpu' + if (npBidRequest.params.hasOwnProperty('customData')) { + obj.ext['newspassid'].customData = npBidRequest.params.customData; + } + logInfo(`obj.ext.newspassid is `, obj.ext['newspassid']); + if (isTestMode != null) { + logInfo('setting isTestMode to ', isTestMode); + if (obj.ext['newspassid'].hasOwnProperty('customData')) { + for (let i = 0; i < obj.ext['newspassid'].customData.length; i++) { + obj.ext['newspassid'].customData[i]['targeting']['nptestmode'] = isTestMode; + } + } else { + obj.ext['newspassid'].customData = [{'settings': {}, 'targeting': {}}]; + obj.ext['newspassid'].customData[0].targeting['nptestmode'] = isTestMode; + } + } + if (fpd && deepAccess(fpd, 'site')) { + logInfo('adding fpd.site'); + if (deepAccess(obj, 'ext.newspassid.customData.0.targeting', false)) { + obj.ext.newspassid.customData[0].targeting = Object.assign(obj.ext.newspassid.customData[0].targeting, fpd.site); + } else { + deepSetValue(obj, 'ext.newspassid.customData.0.targeting', fpd.site); + } + } + if (!schain && deepAccess(npBidRequest, 'schain')) { + schain = npBidRequest.schain; + } + let gpid = deepAccess(npBidRequest, 'ortb2Imp.ext.gpid'); + if (gpid) { + deepSetValue(obj, 'ext.gpid', gpid); + } + return obj; + }); + let extObj = {}; + extObj['newspassid'] = {}; + extObj['newspassid']['np_pb_v'] = NEWSPASSVERSION; + extObj['newspassid']['np_rw'] = placementIdOverrideFromGetParam ? 1 : 0; + if (validBidRequests.length > 0) { + let userIds = this.cookieSyncBag.userIdObject; // 2021-01-06 - slight optimisation - we've already found this info + if (userIds.hasOwnProperty('pubcid')) { + extObj['newspassid'].pubcid = userIds.pubcid; + } + } + extObj['newspassid'].pv = this.getPageId(); // attach the page ID that will be common to all auction calls for this page if refresh() is called + let whitelistAdserverKeys = config.getConfig('newspassid.np_whitelist_adserver_keys'); + let useWhitelistAdserverKeys = isArray(whitelistAdserverKeys) && whitelistAdserverKeys.length > 0; + extObj['newspassid']['np_kvp_rw'] = useWhitelistAdserverKeys ? 1 : 0; + if (getParams.hasOwnProperty('npf')) { extObj['newspassid']['npf'] = getParams.npf === 'true' || getParams.npf === '1' ? 1 : 0; } + if (getParams.hasOwnProperty('nppf')) { extObj['newspassid']['nppf'] = getParams.nppf === 'true' || getParams.nppf === '1' ? 1 : 0; } + if (getParams.hasOwnProperty('nprp') && getParams.nprp.match(/^[0-3]$/)) { extObj['newspassid']['nprp'] = parseInt(getParams.nprp); } + if (getParams.hasOwnProperty('npip') && getParams.npip.match(/^\d+$/)) { extObj['newspassid']['npip'] = parseInt(getParams.npip); } + if (this.propertyBag.endpointOverride != null) { extObj['newspassid']['origin'] = this.propertyBag.endpointOverride; } + let userExtEids = deepAccess(validBidRequests, '0.userIdAsEids', []); // generate the UserIDs in the correct format for UserId module + npRequest.site = { + 'publisher': {'id': htmlParams.publisherId}, + 'page': this.getRefererInfo().page, + 'id': htmlParams.siteId + }; + npRequest.test = config.getConfig('debug') ? 1 : 0; + if (bidderRequest && bidderRequest.uspConsent) { + logInfo('ADDING USP consent info'); + deepSetValue(npRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); + } else { + logInfo('WILL NOT ADD USP consent info; no bidderRequest.uspConsent.'); + } + if (schain) { // we set this while iterating over the bids + logInfo('schain found'); + deepSetValue(npRequest, 'source.ext.schain', schain); + } + if (config.getConfig('coppa') === true) { + deepSetValue(npRequest, 'regs.coppa', 1); + } + if (singleRequest) { + logInfo('buildRequests starting to generate response for a single request'); + npRequest.id = generateUUID(); // Unique ID of the bid request, provided by the exchange. (REQUIRED) + npRequest.imp = tosendtags; + npRequest.ext = extObj; + deepSetValue(npRequest, 'user.ext.eids', userExtEids); + var ret = { + method: 'POST', + url: this.getAuctionUrl(), + data: JSON.stringify(npRequest), + bidderRequest: bidderRequest + }; + logInfo('buildRequests request data for single = ', JSON.parse(JSON.stringify(npRequest))); + this.propertyBag.buildRequestsEnd = new Date().getTime(); + logInfo(`buildRequests going to return for single at time ${this.propertyBag.buildRequestsEnd} (took ${this.propertyBag.buildRequestsEnd - this.propertyBag.buildRequestsStart}ms): `, ret); + return ret; + } + let arrRet = tosendtags.map(imp => { + logInfo('buildRequests starting to generate non-single response, working on imp : ', imp); + let npRequestSingle = Object.assign({}, npRequest); + npRequestSingle.id = generateUUID(); + npRequestSingle.imp = [imp]; + npRequestSingle.ext = extObj; + deepSetValue(npRequestSingle, 'user.ext.eids', userExtEids); + logInfo('buildRequests RequestSingle (for non-single) = ', npRequestSingle); + return { + method: 'POST', + url: this.getAuctionUrl(), + data: JSON.stringify(npRequestSingle), + bidderRequest: bidderRequest + }; + }); + this.propertyBag.buildRequestsEnd = new Date().getTime(); + logInfo(`buildRequests going to return for non-single at time ${this.propertyBag.buildRequestsEnd} (took ${this.propertyBag.buildRequestsEnd - this.propertyBag.buildRequestsStart}ms): `, arrRet); + return arrRet; + }, + interpretResponse(serverResponse, request) { + if (request && request.bidderRequest && request.bidderRequest.bids) { this.loadConfiguredData(request.bidderRequest.bids[0]); } + let startTime = new Date().getTime(); + logInfo(`interpretResponse time: ${startTime}. buildRequests done -> interpretResponse start was ${startTime - this.propertyBag.buildRequestsEnd}ms`); + logInfo(`serverResponse, request`, JSON.parse(JSON.stringify(serverResponse)), JSON.parse(JSON.stringify(request))); + serverResponse = serverResponse.body || {}; + let aucId = serverResponse.id; // this will be correct for single requests and non-single + if (!serverResponse.hasOwnProperty('seatbid')) { + return []; + } + if (typeof serverResponse.seatbid !== 'object') { + return []; + } + let arrAllBids = []; + let enhancedAdserverTargeting = config.getConfig('newspassid.enhancedAdserverTargeting'); + logInfo('enhancedAdserverTargeting', enhancedAdserverTargeting); + if (typeof enhancedAdserverTargeting == 'undefined') { + enhancedAdserverTargeting = true; + } + logInfo('enhancedAdserverTargeting', enhancedAdserverTargeting); + serverResponse.seatbid = injectAdIdsIntoAllBidResponses(serverResponse.seatbid); // we now make sure that each bid in the bidresponse has a unique (within page) adId attribute. + serverResponse.seatbid = this.removeSingleBidderMultipleBids(serverResponse.seatbid); + let whitelistAdserverKeys = config.getConfig('newspassid.np_whitelist_adserver_keys'); + let useWhitelistAdserverKeys = isArray(whitelistAdserverKeys) && whitelistAdserverKeys.length > 0; + for (let i = 0; i < serverResponse.seatbid.length; i++) { + let sb = serverResponse.seatbid[i]; + for (let j = 0; j < sb.bid.length; j++) { + let thisRequestBid = this.getBidRequestForBidId(sb.bid[j].impid, request.bidderRequest.bids); + logInfo(`seatbid:${i}, bid:${j} Going to set default w h for seatbid/bidRequest`, sb.bid[j], thisRequestBid); + const {defaultWidth, defaultHeight} = defaultSize(thisRequestBid); + let thisBid = this.addStandardProperties(sb.bid[j], defaultWidth, defaultHeight); + thisBid.meta = {advertiserDomains: thisBid.adomain || []}; + let bidType = deepAccess(thisBid, 'ext.prebid.type'); + logInfo(`this bid type is : ${bidType}`, j); + let adserverTargeting = {}; + if (enhancedAdserverTargeting) { + let allBidsForThisBidid = this.getAllBidsForBidId(thisBid.bidId, serverResponse.seatbid); + logInfo('Going to iterate allBidsForThisBidId', allBidsForThisBidid); + Object.keys(allBidsForThisBidid).forEach((bidderName, index, ar2) => { + logInfo(`adding adserverTargeting for ${bidderName} for bidId ${thisBid.bidId}`); + adserverTargeting['np_' + bidderName] = bidderName; + adserverTargeting['np_' + bidderName + '_crid'] = String(allBidsForThisBidid[bidderName].crid); + adserverTargeting['np_' + bidderName + '_adv'] = String(allBidsForThisBidid[bidderName].adomain); + adserverTargeting['np_' + bidderName + '_adId'] = String(allBidsForThisBidid[bidderName].adId); + adserverTargeting['np_' + bidderName + '_pb_r'] = getRoundedBid(allBidsForThisBidid[bidderName].price, allBidsForThisBidid[bidderName].ext.prebid.type); + if (allBidsForThisBidid[bidderName].hasOwnProperty('dealid')) { + adserverTargeting['np_' + bidderName + '_dealid'] = String(allBidsForThisBidid[bidderName].dealid); + } + }); + } else { + logInfo(`newspassid.enhancedAdserverTargeting is set to false, no per-bid keys will be sent to adserver.`); + } + let {seat: winningSeat, bid: winningBid} = this.getWinnerForRequestBid(thisBid.bidId, serverResponse.seatbid); + adserverTargeting['np_auc_id'] = String(aucId); + adserverTargeting['np_winner'] = String(winningSeat); + adserverTargeting['np_bid'] = 'true'; + if (enhancedAdserverTargeting) { + adserverTargeting['np_imp_id'] = String(winningBid.impid); + adserverTargeting['np_pb_r'] = getRoundedBid(winningBid.price, bidType); + adserverTargeting['np_adId'] = String(winningBid.adId); + adserverTargeting['np_size'] = `${winningBid.width}x${winningBid.height}`; + } + if (useWhitelistAdserverKeys) { // delete any un-whitelisted keys + logInfo('Going to filter out adserver targeting keys not in the whitelist: ', whitelistAdserverKeys); + Object.keys(adserverTargeting).forEach(function(key) { if (whitelistAdserverKeys.indexOf(key) === -1) { delete adserverTargeting[key]; } }); + } + thisBid.adserverTargeting = adserverTargeting; + arrAllBids.push(thisBid); + } + } + let endTime = new Date().getTime(); + logInfo(`interpretResponse going to return at time ${endTime} (took ${endTime - startTime}ms) Time from buildRequests Start -> interpretRequests End = ${endTime - this.propertyBag.buildRequestsStart}ms`, arrAllBids); + return arrAllBids; + }, + removeSingleBidderMultipleBids(seatbid) { + var ret = []; + for (let i = 0; i < seatbid.length; i++) { + let sb = seatbid[i]; + var retSeatbid = {'seat': sb.seat, 'bid': []}; + var bidIds = []; + for (let j = 0; j < sb.bid.length; j++) { + var candidate = sb.bid[j]; + if (contains(bidIds, candidate.impid)) { + continue; // we've already fully assessed this impid, found the highest bid from this seat for it + } + bidIds.push(candidate.impid); + for (let k = j + 1; k < sb.bid.length; k++) { + if (sb.bid[k].impid === candidate.impid && sb.bid[k].price > candidate.price) { + candidate = sb.bid[k]; + } + } + retSeatbid.bid.push(candidate); + } + ret.push(retSeatbid); + } + return ret; + }, + getUserSyncs(optionsType, serverResponse, gdprConsent, usPrivacy) { + logInfo('getUserSyncs optionsType', optionsType, 'serverResponse', serverResponse, 'usPrivacy', usPrivacy, 'cookieSyncBag', this.cookieSyncBag); + if (!serverResponse || serverResponse.length === 0) { + return []; + } + if (optionsType.iframeEnabled) { + var arrQueryString = []; + if (config.getConfig('debug')) { + arrQueryString.push('pbjs_debug=true'); + } + arrQueryString.push('usp_consent=' + (usPrivacy || '')); + for (let keyname in this.cookieSyncBag.userIdObject) { + arrQueryString.push(keyname + '=' + this.cookieSyncBag.userIdObject[keyname]); + } + arrQueryString.push('publisherId=' + this.cookieSyncBag.publisherId); + arrQueryString.push('siteId=' + this.cookieSyncBag.siteId); + arrQueryString.push('cb=' + Date.now()); + arrQueryString.push('bidder=' + this.propertyBag.config.bidder); + var strQueryString = arrQueryString.join('&'); + if (strQueryString.length > 0) { + strQueryString = '?' + strQueryString; + } + logInfo('getUserSyncs going to return cookie sync url : ' + this.getCookieSyncUrl() + strQueryString); + return [{ + type: 'iframe', + url: this.getCookieSyncUrl() + strQueryString + }]; + } + }, + getBidRequestForBidId(bidId, arrBids) { + for (let i = 0; i < arrBids.length; i++) { + if (arrBids[i].bidId === bidId) { // bidId in the request comes back as impid in the seatbid bids + return arrBids[i]; + } + } + return null; + }, + findAllUserIds(bidRequest) { + var ret = {}; + let searchKeysSingle = ['pubcid', 'tdid', 'idl_env', 'criteoId', 'lotamePanoramaId', 'fabrickId']; + if (bidRequest.hasOwnProperty('userId')) { + for (let arrayId in searchKeysSingle) { + let key = searchKeysSingle[arrayId]; + if (bidRequest.userId.hasOwnProperty(key)) { + if (typeof (bidRequest.userId[key]) == 'string') { + ret[key] = bidRequest.userId[key]; + } else if (typeof (bidRequest.userId[key]) == 'object') { + logError(`WARNING: findAllUserIds had to use first key in user object to get value for bid.userId key: ${key}. Prebid adapter should be updated.`); + ret[key] = bidRequest.userId[key][Object.keys(bidRequest.userId[key])[0]]; // cannot use Object.values + } else { + logError(`failed to get string key value for userId : ${key}`); + } + } + } + let lipbid = deepAccess(bidRequest.userId, 'lipb.lipbid'); + if (lipbid) { + ret['lipb'] = {'lipbid': lipbid}; + } + let id5id = deepAccess(bidRequest.userId, 'id5id.uid'); + if (id5id) { + ret['id5id'] = id5id; + } + let parrableId = deepAccess(bidRequest.userId, 'parrableId.eid'); + if (parrableId) { + ret['parrableId'] = parrableId; + } + let sharedid = deepAccess(bidRequest.userId, 'sharedid.id'); + if (sharedid) { + ret['sharedid'] = sharedid; + } + } + if (!ret.hasOwnProperty('pubcid')) { + let pubcid = deepAccess(bidRequest, 'crumbs.pubcid'); + if (pubcid) { + ret['pubcid'] = pubcid; // if built with old pubCommonId module + } + } + return ret; + }, + getPlacementId(bidRequest) { + return (bidRequest.params.placementId).toString(); + }, + getPlacementIdOverrideFromGetParam() { + let arr = this.getGetParametersAsObject(); + if (arr.hasOwnProperty('npstoredrequest')) { + if (this.isValidPlacementId(arr['npstoredrequest'])) { + logInfo(`using GET npstoredrequest ` + arr['npstoredrequest'] + ' to replace placementId'); + return arr['npstoredrequest']; + } else { + logError(`GET npstoredrequest FAILED VALIDATION - will not use it`); + } + } + return null; + }, + getGetParametersAsObject() { + let parsed = parseUrl(this.getRefererInfo().location); // was getRefererInfo().page but this is not backwards compatible + logInfo('getGetParametersAsObject found:', parsed.search); + return parsed.search; + }, + getRefererInfo() { + if (getRefererInfo().hasOwnProperty('location')) { + logInfo('FOUND location on getRefererInfo OK (prebid >= 7); will use getRefererInfo for location & page'); + return getRefererInfo(); + } else { + logInfo('DID NOT FIND location on getRefererInfo (prebid < 7); will use legacy code that ALWAYS worked reliably to get location & page ;-)'); + try { + return { + page: top.location.href, + location: top.location.href + }; + } catch (e) { + return { + page: window.location.href, + location: window.location.href + }; + } + } + }, + blockTheRequest() { + let npRequest = config.getConfig('newspassid.np_request'); + if (typeof npRequest == 'boolean' && !npRequest) { + logWarn(`Will not allow auction : np_request is set to false`); + return true; + } + return false; + }, + getPageId: function() { + if (this.propertyBag.pageId == null) { + let randPart = ''; + let allowable = '0123456789abcdefghijklmnopqrstuvwxyz'; + for (let i = 20; i > 0; i--) { + randPart += allowable[Math.floor(Math.random() * 36)]; + } + this.propertyBag.pageId = new Date().getTime() + '_' + randPart; + } + return this.propertyBag.pageId; + }, + addStandardProperties(seatBid, defaultWidth, defaultHeight) { + seatBid.cpm = seatBid.price; + seatBid.bidId = seatBid.impid; + seatBid.requestId = seatBid.impid; + seatBid.width = seatBid.w || defaultWidth; + seatBid.height = seatBid.h || defaultHeight; + seatBid.ad = seatBid.adm; + seatBid.netRevenue = true; + seatBid.creativeId = seatBid.crid; + seatBid.currency = 'USD'; + seatBid.ttl = 300; + return seatBid; + }, + getWinnerForRequestBid(requestBidId, serverResponseSeatBid) { + let thisBidWinner = null; + let winningSeat = null; + for (let j = 0; j < serverResponseSeatBid.length; j++) { + let theseBids = serverResponseSeatBid[j].bid; + let thisSeat = serverResponseSeatBid[j].seat; + for (let k = 0; k < theseBids.length; k++) { + if (theseBids[k].impid === requestBidId) { + if ((thisBidWinner == null) || (thisBidWinner.price < theseBids[k].price)) { + thisBidWinner = theseBids[k]; + winningSeat = thisSeat; + break; + } + } + } + } + return {'seat': winningSeat, 'bid': thisBidWinner}; + }, + getAllBidsForBidId(matchBidId, serverResponseSeatBid) { + let objBids = {}; + for (let j = 0; j < serverResponseSeatBid.length; j++) { + let theseBids = serverResponseSeatBid[j].bid; + let thisSeat = serverResponseSeatBid[j].seat; + for (let k = 0; k < theseBids.length; k++) { + if (theseBids[k].impid === matchBidId) { + if (objBids.hasOwnProperty(thisSeat)) { // > 1 bid for an adunit from a bidder - only use the one with the highest bid + if (objBids[thisSeat]['price'] < theseBids[k].price) { + objBids[thisSeat] = theseBids[k]; + } + } else { + objBids[thisSeat] = theseBids[k]; + } + } + } + } + return objBids; + } +}; +export function injectAdIdsIntoAllBidResponses(seatbid) { + logInfo('injectAdIdsIntoAllBidResponses', seatbid); + for (let i = 0; i < seatbid.length; i++) { + let sb = seatbid[i]; + for (let j = 0; j < sb.bid.length; j++) { + sb.bid[j]['adId'] = `${sb.bid[j]['impid']}-${i}-np-${j}`; + } + } + return seatbid; +} +export function checkDeepArray(Arr) { + if (Array.isArray(Arr)) { + if (Array.isArray(Arr[0])) { + return Arr[0]; + } else { + return Arr; + } + } else { + return Arr; + } +} +export function defaultSize(thebidObj) { + if (!thebidObj) { + logInfo('defaultSize received empty bid obj! going to return fixed default size'); + return { + 'defaultHeight': 250, + 'defaultWidth': 300 + }; + } + const {sizes} = thebidObj; + const returnObject = {}; + returnObject.defaultWidth = checkDeepArray(sizes)[0]; + returnObject.defaultHeight = checkDeepArray(sizes)[1]; + return returnObject; +} +export function getRoundedBid(price, mediaType) { + const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${mediaType}`); // might be string or object or nothing; if set then this takes precedence over 'priceGranularity' + let objBuckets = config.getConfig('customPriceBucket'); // this is always an object - {} if strBuckets is not 'custom' + let strBuckets = config.getConfig('priceGranularity'); // priceGranularity value, always a string ** if priceGranularity is set to an object then it's always 'custom' ** + let theConfigObject = getGranularityObject(mediaType, mediaTypeGranularity, strBuckets, objBuckets); + let theConfigKey = getGranularityKeyName(mediaType, mediaTypeGranularity, strBuckets); + logInfo('getRoundedBid. price:', price, 'mediaType:', mediaType, 'configkey:', theConfigKey, 'configObject:', theConfigObject, 'mediaTypeGranularity:', mediaTypeGranularity, 'strBuckets:', strBuckets); + let priceStringsObj = getPriceBucketString( + price, + theConfigObject, + config.getConfig('currency.granularityMultiplier') + ); + logInfo('priceStringsObj', priceStringsObj); + let granularityNamePriceStringsKeyMapping = { + 'medium': 'med', + 'custom': 'custom', + 'high': 'high', + 'low': 'low', + 'dense': 'dense' + }; + if (granularityNamePriceStringsKeyMapping.hasOwnProperty(theConfigKey)) { + let priceStringsKey = granularityNamePriceStringsKeyMapping[theConfigKey]; + logInfo('getRoundedBid: looking for priceStringsKey:', priceStringsKey); + return priceStringsObj[priceStringsKey]; + } + return priceStringsObj['auto']; +} +export function getGranularityKeyName(mediaType, mediaTypeGranularity, strBuckets) { + if (typeof mediaTypeGranularity === 'string') { + return mediaTypeGranularity; + } + if (typeof mediaTypeGranularity === 'object') { + return 'custom'; + } + if (typeof strBuckets === 'string') { + return strBuckets; + } + return 'auto'; // fall back to a default key - should literally never be needed. +} +export function getGranularityObject(mediaType, mediaTypeGranularity, strBuckets, objBuckets) { + if (typeof mediaTypeGranularity === 'object') { + return mediaTypeGranularity; + } + if (strBuckets === 'custom') { + return objBuckets; + } + return ''; +} +registerBidder(spec); +logInfo(`*BidAdapter ${NEWSPASSVERSION} was loaded`); diff --git a/modules/nextMillenniumBidAdapter.js b/modules/nextMillenniumBidAdapter.js index 91508d38ca0..0cbe954175c 100644 --- a/modules/nextMillenniumBidAdapter.js +++ b/modules/nextMillenniumBidAdapter.js @@ -1,16 +1,50 @@ -import { isStr, _each, parseUrl, getWindowTop, getBidIdParameter } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; +import { + _each, + createTrackPixelHtml, + deepAccess, getBidIdParameter, + getDefinedParams, + getWindowTop, + isArray, + isStr, + logMessage, + parseGPTSingleSizeArrayToRtbSize, + parseUrl, + triggerPixel, +} from '../src/utils.js'; + +import CONSTANTS from '../src/constants.json'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import * as events from '../src/events.js'; + +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getRefererInfo} from '../src/refererDetection.js'; const BIDDER_CODE = 'nextMillennium'; const ENDPOINT = 'https://pbs.nextmillmedia.com/openrtb2/auction'; const TEST_ENDPOINT = 'https://test.pbs.nextmillmedia.com/openrtb2/auction'; -const SYNC_ENDPOINT = 'https://statics.nextmillmedia.com/load-cookie.html?v=4'; +const SYNC_ENDPOINT = 'https://cookies.nextmillmedia.com/sync?'; +const REPORT_ENDPOINT = 'https://report2.hb.brainlyads.com/statistics/metric'; const TIME_TO_LIVE = 360; +const VIDEO_PARAMS = [ + 'api', 'linearity', 'maxduration', 'mimes', 'minduration', 'placement', + 'playbackmethod', 'protocols', 'startdelay' +]; +const GVLID = 1060; + +const sendingDataStatistic = initSendingDataStatistic(); +events.on(CONSTANTS.EVENTS.AUCTION_INIT, auctionInitHandler); + +const EXPIRENCE_WURL = 20 * 60000; +const wurlMap = {}; +cleanWurl(); + +events.on(CONSTANTS.EVENTS.BID_WON, bidWonHandler); export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER], + supportedMediaTypes: [BANNER, VIDEO], + gvlid: GVLID, isBidRequestValid: function(bid) { return !!( @@ -24,56 +58,105 @@ export const spec = { _each(validBidRequests, function(bid) { window.nmmRefreshCounts[bid.adUnitCode] = window.nmmRefreshCounts[bid.adUnitCode] || 0; + const id = getPlacementId(bid); + const auctionId = bid.auctionId; + const bidId = bid.bidId; + let sizes = bid.sizes; + if (sizes && !Array.isArray(sizes[0])) sizes = [sizes]; + + const site = getSiteObj(); + const device = getDeviceObj(); + const postBody = { - 'id': bid.auctionId, + 'id': bidderRequest?.bidderRequestId, 'ext': { 'prebid': { 'storedrequest': { - 'id': getPlacementId(bid) + 'id': id } }, 'nextMillennium': { 'refresh_count': window.nmmRefreshCounts[bid.adUnitCode]++, + 'elOffsets': getBoundingClient(bid), + 'scrollTop': window.pageYOffset || document.documentElement.scrollTop + } + }, + + device, + site, + imp: [] + }; + + const imp = { + id: bid.adUnitCode, + ext: { + prebid: { + storedrequest: {id} } } - } + }; + + if (deepAccess(bid, 'mediaTypes.banner')) { + imp.banner = { + format: (sizes || []).map(s => { return {w: s[0], h: s[1]} }) + }; + }; + + const video = deepAccess(bid, 'mediaTypes.video'); + if (video) { + imp.video = getDefinedParams(video, VIDEO_PARAMS); + if (video.playerSize) { + imp.video = Object.assign( + imp.video, parseGPTSingleSizeArrayToRtbSize(video.playerSize[0]) || {} + ); + } else if (video.w && video.h) { + imp.video.w = video.w; + imp.video.h = video.h; + }; + }; + + postBody.imp.push(imp); const gdprConsent = bidderRequest && bidderRequest.gdprConsent; - const uspConsent = bidderRequest && bidderRequest.uspConsent + const uspConsent = bidderRequest && bidderRequest.uspConsent; if (gdprConsent || uspConsent) { - postBody.regs = { ext: {} } + postBody.regs = { ext: {} }; if (uspConsent) { postBody.regs.ext.us_privacy = uspConsent; - } + }; if (gdprConsent) { if (typeof gdprConsent.gdprApplies !== 'undefined') { postBody.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0; - } + }; if (typeof gdprConsent.consentString !== 'undefined') { postBody.user = { ext: { consent: gdprConsent.consentString } - } - } - } - } + }; + }; + }; + }; const urlParameters = parseUrl(getWindowTop().location.href).search; const isTest = urlParameters['pbs'] && urlParameters['pbs'] === 'test'; + const params = bid.params; requests.push({ method: 'POST', url: isTest ? TEST_ENDPOINT : ENDPOINT, data: JSON.stringify(postBody), options: { - contentType: 'application/json', + contentType: 'text/plain', withCredentials: true }, - bidId: bid.bidId + + bidId, + params, + auctionId, }); }); @@ -86,21 +169,41 @@ export const spec = { _each(response.seatbid, (resp) => { _each(resp.bid, (bid) => { - bidResponses.push({ - requestId: bidRequest.bidId, + const requestId = bidRequest.bidId; + const params = bidRequest.params; + const auctionId = bidRequest.auctionId; + const wurl = deepAccess(bid, 'ext.prebid.events.win'); + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + addWurl({auctionId, requestId, wurl}); + + const {ad, adUrl, vastUrl, vastXml} = getAd(bid); + + const bidResponse = { + requestId, + params, cpm: bid.price, width: bid.w, height: bid.h, creativeId: bid.adid, currency: response.cur, - netRevenue: false, + netRevenue: true, ttl: TIME_TO_LIVE, meta: { advertiserDomains: bid.adomain || [] - }, + } + }; + + if (vastUrl || vastXml) { + bidResponse.mediaType = VIDEO; + + if (vastUrl) bidResponse.vastUrl = vastUrl; + if (vastXml) bidResponse.vastXml = vastXml; + } else { + bidResponse.ad = ad; + bidResponse.adUrl = adUrl; + }; - ad: bid.adm - }); + bidResponses.push(bidResponse); }); }); @@ -108,59 +211,305 @@ export const spec = { }, getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { - if (!syncOptions.iframeEnabled) { - return - } + const pixels = []; - let syncurl = gdprConsent && gdprConsent.gdprApplies ? `${SYNC_ENDPOINT}&gdpr=1&gdpr_consent=${gdprConsent.consentString}` : SYNC_ENDPOINT + if (isArray(responses)) { + responses.forEach(response => { + if (syncOptions.pixelEnabled) { + deepAccess(response, 'body.ext.sync.image', []).forEach(imgUrl => { + pixels.push({ + type: 'image', + url: replaceUsersyncMacros(imgUrl, gdprConsent, uspConsent) + }); + }) + } - let bidders = [] - if (responses) { - _each(responses, (response) => { - if (!(response && response.body && response.body.ext && response.body.ext.responsetimemillis)) return - _each(Object.keys(response.body.ext.responsetimemillis), b => bidders.push(b)) + if (syncOptions.iframeEnabled) { + deepAccess(response, 'body.ext.sync.iframe', []).forEach(iframeUrl => { + pixels.push({ + type: 'iframe', + url: replaceUsersyncMacros(iframeUrl, gdprConsent, uspConsent) + }); + }) + } }) } - if (bidders.length) { - syncurl += `&bidders=${bidders.join(',')}` + if (!pixels.length) { + let syncUrl = SYNC_ENDPOINT; + if (gdprConsent && gdprConsent.gdprApplies) syncUrl += 'gdpr=1&gdpr_consent=' + gdprConsent.consentString + '&'; + if (uspConsent) syncUrl += 'us_privacy=' + uspConsent + '&'; + if (syncOptions.iframeEnabled) pixels.push({type: 'iframe', url: syncUrl + 'type=iframe'}); + if (syncOptions.pixelEnabled) pixels.push({type: 'image', url: syncUrl + 'type=image'}); } + return pixels; + }, + + getUrlPixelMetric(eventName, bid) { + const bidder = bid.bidder || bid.bidderCode; + if (bidder != BIDDER_CODE) return; + + let params; + if (bid.params) { + params = Array.isArray(bid.params) ? bid.params : [bid.params]; + } else { + if (Array.isArray(bid.bids)) params = bid.bids.map(bidI => bidI.params); + }; + + if (!params.length) return; - return [{ - type: 'iframe', - url: syncurl - }]; + const placementIdsArray = []; + const groupIdsArray = []; + params.forEach(paramsI => { + if (paramsI.group_id) { + groupIdsArray.push(paramsI.group_id); + } else { + if (paramsI.placement_id) placementIdsArray.push(paramsI.placement_id); + }; + }); + + const placementIds = (placementIdsArray.length && `&placements=${placementIdsArray.join(';')}`) || ''; + const groupIds = (groupIdsArray.length && `&groups=${groupIdsArray.join(';')}`) || ''; + + if (!(groupIds || placementIds)) { + return; + }; + + const url = `${REPORT_ENDPOINT}?event=${eventName}&bidder=${bidder}&source=pbjs${groupIds}${placementIds}`; + + return url; }, }; +function replaceUsersyncMacros(url, gdprConsent, uspConsent) { + const { consentString, gdprApplies } = gdprConsent || {}; + + if (gdprApplies) { + const gdpr = Number(gdprApplies); + url = url.replace('{{.GDPR}}', gdpr); + + if (gdpr == 1 && consentString && consentString.length > 0) { + url = url.replace('{{.GDPRConsent}}', consentString); + } + } else { + url = url.replace('{{.GDPR}}', 0); + url = url.replace('{{.GDPRConsent}}', ''); + } + + if (uspConsent) { + url = url.replace('{{.USPrivacy}}', uspConsent); + } + + return url; +}; + +function getAdEl(bid) { + // best way I could think of to get El, is by matching adUnitCode to google slots... + const slot = window.googletag && window.googletag.pubads && window.googletag.pubads().getSlots().find(slot => slot.getAdUnitPath() === bid.adUnitCode); + const slotElementId = slot && slot.getSlotElementId(); + if (!slotElementId) return null; + return document.querySelector('#' + slotElementId); +} + +function getBoundingClient(bid) { + const el = getAdEl(bid); + if (!el) return {}; + return el.getBoundingClientRect(); +} + function getPlacementId(bid) { - const groupId = getBidIdParameter('group_id', bid.params) - const placementId = getBidIdParameter('placement_id', bid.params) - if (!groupId) return placementId + const groupId = getBidIdParameter('group_id', bid.params); + const placementId = getBidIdParameter('placement_id', bid.params); + if (!groupId) return placementId; - let windowTop = getTopWindow(window) - let size = [] + let windowTop = getTopWindow(window); + let sizes = []; if (bid.mediaTypes) { - if (bid.mediaTypes.banner) size = bid.mediaTypes.banner.sizes && bid.mediaTypes.banner.sizes[0] - if (bid.mediaTypes.video) size = bid.mediaTypes.video.playerSize - } + if (bid.mediaTypes.banner) sizes = bid.mediaTypes.banner.sizes; + if (bid.mediaTypes.video) sizes = [bid.mediaTypes.video.playerSize]; + }; - const host = (windowTop && windowTop.location && windowTop.location.host) || '' - return `g${groupId};${size.join('x')};${host}` + const host = (windowTop && windowTop.location && windowTop.location.host) || ''; + return `g${groupId};${sizes.map(size => size.join('x')).join('|')};${host}`; } function getTopWindow(curWindow, nesting = 0) { if (nesting > 10) { - return curWindow - } + return curWindow; + }; try { if (curWindow.parent.document) { - return getTopWindow(curWindow.parent.window, ++nesting) - } + return getTopWindow(curWindow.parent.window, ++nesting); + }; } catch (err) { - return curWindow + return curWindow; + }; +} + +function getAd(bid) { + let ad, adUrl, vastXml, vastUrl; + + switch (deepAccess(bid, 'ext.prebid.type')) { + case VIDEO: + if (bid.adm.substr(0, 4) === 'http') { + vastUrl = bid.adm; + } else { + vastXml = bid.adm; + }; + + break; + default: + if (bid.adm && bid.nurl) { + ad = bid.adm; + ad += createTrackPixelHtml(decodeURIComponent(bid.nurl)); + } else if (bid.adm) { + ad = bid.adm; + } else if (bid.nurl) { + adUrl = bid.nurl; + }; } + + return {ad, adUrl, vastXml, vastUrl}; +} + +function getSiteObj() { + const refInfo = (getRefererInfo && getRefererInfo()) || {}; + + return { + page: refInfo.page, + ref: refInfo.ref, + domain: refInfo.domain + }; +} + +function getDeviceObj() { + return { + w: window.innerWidth || window.document.documentElement.clientWidth || window.document.body.clientWidth || 0, + h: window.innerHeight || window.document.documentElement.clientHeight || window.document.body.clientHeight || 0, + }; +} + +function getKeyWurl({auctionId, requestId}) { + return `${auctionId}-${requestId}`; +} + +function addWurl({wurl, requestId, auctionId}) { + if (!wurl) return; + + const expirence = Date.now() + EXPIRENCE_WURL; + const key = getKeyWurl({auctionId, requestId}); + wurlMap[key] = {wurl, expirence}; +} + +function removeWurl({auctionId, requestId}) { + const key = getKeyWurl({auctionId, requestId}); + delete wurlMap[key]; +} + +function getWurl({auctionId, requestId}) { + const key = getKeyWurl({auctionId, requestId}); + return wurlMap[key] && wurlMap[key].wurl; +} + +function bidWonHandler(bid) { + const {auctionId, requestId} = bid; + const wurl = getWurl({auctionId, requestId}); + if (wurl) { + logMessage(`(nextmillennium) Invoking image pixel for wurl on BID_WIN: "${wurl}"`); + triggerPixel(wurl); + removeWurl({auctionId, requestId}); + }; +} + +function auctionInitHandler() { + sendingDataStatistic.initEvents(); +} + +function cleanWurl() { + const dateNow = Date.now(); + Object.keys(wurlMap).forEach(key => { + if (dateNow >= wurlMap[key].expirence) { + delete wurlMap[key]; + }; + }); + + setTimeout(cleanWurl, 60000); +} + +function initSendingDataStatistic() { + class SendingDataStatistic { + eventNames = [ + CONSTANTS.EVENTS.BID_TIMEOUT, + CONSTANTS.EVENTS.BID_RESPONSE, + CONSTANTS.EVENTS.BID_REQUESTED, + CONSTANTS.EVENTS.NO_BID, + ]; + + disabledSending = false; + enabledSending = false; + eventHendlers = {}; + + initEvents() { + this.disabledSending = !!config.getBidderConfig()?.nextMillennium?.disabledSendingStatisticData; + if (this.disabledSending) { + this.removeEvents(); + } else { + this.createEvents(); + }; + } + + createEvents() { + if (this.enabledSending) return; + + this.enabledSending = true; + for (let eventName of this.eventNames) { + if (!this.eventHendlers[eventName]) { + this.eventHendlers[eventName] = this.eventHandler(eventName); + }; + + events.on(eventName, this.eventHendlers[eventName]); + }; + } + + removeEvents() { + if (!this.enabledSending) return; + + this.enabledSending = false; + for (let eventName of this.eventNames) { + if (!this.eventHendlers[eventName]) continue; + + events.off(eventName, this.eventHendlers[eventName]); + }; + } + + eventHandler(eventName) { + const eventHandlerFunc = this.getEventHandler(eventName); + if (eventName == CONSTANTS.EVENTS.BID_TIMEOUT) { + return bids => { + if (this.disabledSending || !Array.isArray(bids)) return; + + for (let bid of bids) { + eventHandlerFunc(bid); + }; + } + }; + + return eventHandlerFunc; + } + + getEventHandler(eventName) { + return bid => { + if (this.disabledSending) return; + + const url = spec.getUrlPixelMetric(eventName, bid); + if (!url) return; + triggerPixel(url); + }; + } + }; + + return new SendingDataStatistic(); } registerBidder(spec); diff --git a/modules/nextMillenniumBidAdapter.md b/modules/nextMillenniumBidAdapter.md index 136f97d94d5..5374accfe35 100644 --- a/modules/nextMillenniumBidAdapter.md +++ b/modules/nextMillenniumBidAdapter.md @@ -2,7 +2,7 @@ ``` Module Name: NextMillennium Bid Adapter Module Type: Bidder Adapter -Maintainer: mihail.ivanchenko@nextmillennium.io +Maintainer: accountmanagers@nextmillennium.io ``` # Description diff --git a/modules/nextrollBidAdapter.js b/modules/nextrollBidAdapter.js index 4e82bc1cbda..eab174d22dd 100644 --- a/modules/nextrollBidAdapter.js +++ b/modules/nextrollBidAdapter.js @@ -1,6 +1,5 @@ import { - deepAccess, - getBidIdParameter, + deepAccess, getBidIdParameter, isArray, isFn, isNumber, @@ -11,6 +10,7 @@ import { } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; import {find} from '../src/polyfill.js'; @@ -39,7 +39,10 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { - let topLocation = parseUrl(deepAccess(bidderRequest, 'refererInfo.referer')); + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + // TODO: is 'page' the right value here? + let topLocation = parseUrl(deepAccess(bidderRequest, 'refererInfo.page')); return validBidRequests.map((bidRequest) => { return { @@ -65,7 +68,6 @@ export const spec = { } }, - user: _getUser(validBidRequests), site: _getSite(bidRequest, topLocation), seller: _getSeller(bidRequest), device: _getDevice(bidRequest), @@ -186,22 +188,6 @@ function _getNativeAssets(mediaTypeNative) { .filter(asset => asset !== undefined); } -function _getUser(requests) { - const id = deepAccess(requests, '0.userId.nextrollId'); - if (id === undefined) { - return; - } - - return { - ext: { - eid: [{ - 'source': 'nextroll', - id - }] - } - }; -} - function _getFloor(bidRequest) { if (!isFn(bidRequest.getFloor)) { return (bidRequest.params.bidfloor) ? bidRequest.params.bidfloor : null; diff --git a/modules/nextrollIdSystem.js b/modules/nextrollIdSystem.js deleted file mode 100644 index 5a59e216394..00000000000 --- a/modules/nextrollIdSystem.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This module adds Nextroll ID to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/nextrollIdSystem - * @requires module:modules/userId - */ - -import { deepAccess } from '../src/utils.js'; -import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const NEXTROLL_ID_LS_KEY = 'dca0.com'; -const KEY_PREFIX = 'AdID:' - -export const storage = getStorageManager(); - -/** @type {Submodule} */ -export const nextrollIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: 'nextrollId', - - /** - * decode the stored id value for passing to bid requests - * @function - * @return {{nextrollId: string} | undefined} - */ - decode(value) { - return value; - }, - - /** - * performs action to obtain id and return a value. - * @function - * @param {SubmoduleConfig} [config] - * @returns {{id: {nextrollId: string} | undefined}} - */ - getId(config) { - const key = KEY_PREFIX + deepAccess(config, 'params.partnerId', 'undefined'); - const dataString = storage.getDataFromLocalStorage(NEXTROLL_ID_LS_KEY) || '{}'; - const data = JSON.parse(dataString); - const idValue = deepAccess(data, `${key}.value`); - - return { id: idValue ? {nextrollId: idValue} : undefined }; - } -}; - -submodule('userId', nextrollIdSubmodule); diff --git a/modules/nexx360BidAdapter.js b/modules/nexx360BidAdapter.js index 0689d3b04ce..c65544936fa 100644 --- a/modules/nexx360BidAdapter.js +++ b/modules/nexx360BidAdapter.js @@ -1,165 +1,283 @@ -import {ajax} from '../src/ajax.js'; import {config} from '../src/config.js'; +import { deepAccess, deepSetValue, generateUUID, logError, logInfo } from '../src/utils.js'; +import {Renderer} from '../src/Renderer.js'; +import {getStorageManager} from '../src/storageManager.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {ortbConverter} from '../libraries/ortbConverter/converter.js' +import { INSTREAM, OUTSTREAM } from '../src/video.js'; + +const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; const BIDDER_CODE = 'nexx360'; -const BIDDER_URL = 'https://fast.nexx360.io/prebid'; -const CACHE_URL = 'https://fast.nexx360.io/cache'; -const METRICS_TRACKER_URL = 'https://fast.nexx360.io/track-imp'; +const REQUEST_URL = 'https://fast.nexx360.io/booster'; +const PAGE_VIEW_ID = generateUUID(); +const BIDDER_VERSION = '3.0'; +const GVLID = 965; +const NEXXID_KEY = 'nexx360_storage'; -export const spec = { - code: BIDDER_CODE, - aliases: ['revenuemaker'], // short code - supportedMediaTypes: [BANNER, VIDEO], - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - return !!(bid.params.account && bid.params.tagId); - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function(validBidRequests, bidderRequest) { - const adUnits = []; - const test = config.getConfig('debug') ? 1 : 0; - let adunitValue = null; - let userEids = null; - Object.keys(validBidRequests).forEach(key => { - adunitValue = validBidRequests[key]; - adUnits.push({ - account: adunitValue.params.account, - tagId: adunitValue.params.tagId, - videoExt: adunitValue.params.videoExt, - label: adunitValue.adUnitCode, - bidId: adunitValue.bidId, - auctionId: adunitValue.auctionId, - transactionId: adunitValue.transactionId, - mediatypes: adunitValue.mediaTypes - }); - if (adunitValue.userIdAsEids) userEids = adunitValue.userIdAsEids; - }); - const payload = { - adUnits, - href: encodeURIComponent(bidderRequest.refererInfo.referer) - }; - if (bidderRequest) { // modules informations (gdpr, ccpa, schain, userId) - if (bidderRequest.gdprConsent) { - payload.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; - payload.gdprConsent = bidderRequest.gdprConsent.consentString; - } else { - payload.gdpr = 0; - payload.gdprConsent = ''; - } - if (bidderRequest.uspConsent) { payload.uspConsent = bidderRequest.uspConsent; } - if (bidderRequest.schain) { payload.schain = bidderRequest.schain; } - if (userEids !== null) payload.userEids = userEids; - }; - if (test) payload.test = 1; - const payloadString = JSON.stringify(payload); - return { - method: 'POST', - url: BIDDER_URL, - data: payloadString, - }; +const ALIASES = [ + { code: 'revenuemaker' }, + { code: 'first-id', gvlid: 1178 }, + { code: 'adwebone' }, + { code: 'league-m', gvlid: 965 }, + { code: 'prjads' }, + { code: 'pubtech' }, +]; + +export const storage = getStorageManager({ + bidderCode: BIDDER_CODE, +}); + +/** + * Get the NexxId + * @param + * @return {object | false } false if localstorageNotEnabled + */ + +export function getNexx360LocalStorage() { + if (!storage.localStorageIsEnabled()) { + logInfo(`localstorage not enabled for Nexx360`); + return false; + } + const output = storage.getDataFromLocalStorage(NEXXID_KEY); + if (output === null) { + const nexx360Storage = { nexx360Id: generateUUID() }; + storage.setDataInLocalStorage(NEXXID_KEY, JSON.stringify(nexx360Storage)); + return nexx360Storage; + } + try { + return JSON.parse(output) + } catch (e) { + return false; + } +} + +function getAdContainer(container) { + if (document.getElementById(container)) { + return document.getElementById(container); + } +} + +const converter = ortbConverter({ + context: { + netRevenue: true, // or false if your adapter should set bidResponse.netRevenue = false + ttl: 90, // default bidResponse.ttl (when not specified in ORTB response.seatbid[].bid[].exp) }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {ServerResponse} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(serverResponse, bidRequest) { - const serverBody = serverResponse.body; - // const headerValue = serverResponse.headers.get('some-response-header'); - const bidResponses = []; - let bidResponse = null; - let value = null; - if (serverBody.hasOwnProperty('responses')) { - Object.keys(serverBody['responses']).forEach(key => { - value = serverBody['responses'][key]; - const url = `${CACHE_URL}?uuid=${value['uuid']}`; - bidResponse = { - requestId: value['bidId'], - cpm: value['cpm'], - currency: value['currency'], - width: value['width'], - height: value['height'], - ttl: value['ttl'], - creativeId: value['creativeId'], - netRevenue: true, - nexx360: { - 'ssp': value['bidder'], - 'consent': value['consent'], - 'tagId': value['tagId'] - }, - /* - meta: { - 'advertiserDomains': value['adomain'] - } - */ - }; - if (value.type === 'banner') bidResponse.adUrl = url; - if (value.type === 'video') { - const params = { - type: 'prebid', - mediatype: 'video', - ssp: value.bidder, - tag_id: value.tagId, - consent: value.consent, - price: value.cpm, - }; - bidResponse.cpm = value.cpm; - bidResponse.mediaType = 'video'; - bidResponse.vastUrl = url; - bidResponse.vastImpUrl = `${METRICS_TRACKER_URL}?${new URLSearchParams(params).toString()}`; - } - bidResponses.push(bidResponse); - }); + imp(buildImp, bidRequest, context) { + // console.log(bidRequest, context); + const imp = buildImp(bidRequest, context); + const tagid = bidRequest.params.adUnitName ? bidRequest.params.adUnitName : bidRequest.adUnitCode; + deepSetValue(imp, 'tagid', tagid); + deepSetValue(imp, 'ext.adUnitCode', bidRequest.adUnitCode); + const divId = bidRequest.params.divId ? bidRequest.params.divId : bidRequest.adUnitCode; + deepSetValue(imp, 'ext.divId', divId); + const slotEl = getAdContainer(divId); + if (slotEl) { + deepSetValue(imp, 'ext.dimensions.slotW', slotEl.offsetWidth); + deepSetValue(imp, 'ext.dimensions.slotH', slotEl.offsetHeight); + deepSetValue(imp, 'ext.dimensions.cssMaxW', slotEl.style?.maxWidth); + deepSetValue(imp, 'ext.dimensions.cssMaxH', slotEl.style?.maxHeight); } - return bidResponses; - }, - - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { - if (typeof serverResponses === 'object' && serverResponses != null && serverResponses.length > 0 && serverResponses[0].hasOwnProperty('body') && - serverResponses[0].body.hasOwnProperty('cookies') && typeof serverResponses[0].body.cookies === 'object') { - return serverResponses[0].body.cookies.slice(0, 5); - } else { - return []; + deepSetValue(imp, 'ext.nexx360', bidRequest.params.tagId); + deepSetValue(imp, 'ext.nexx360.tagId', bidRequest.params.tagId); + deepSetValue(imp, 'ext.nexx360.videoTagId', bidRequest.params.videoTagId); + deepSetValue(imp, 'ext.nexx360.allBids', bidRequest.params.allBids); + if (imp.video) { + const playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize'); + const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context'); + deepSetValue(imp, 'video.ext.playerSize', playerSize); + deepSetValue(imp, 'video.ext.context', videoContext); } + + if (bidRequest.params.adUnitName) deepSetValue(imp, 'ext.adUnitName', bidRequest.params.adUnitName); + if (bidRequest.params.adUnitPath) deepSetValue(imp, 'ext.adUnitPath', bidRequest.params.adUnitPath); + return imp; + }, + request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + const nexx360LocalStorage = getNexx360LocalStorage(); + if (nexx360LocalStorage) deepSetValue(request, 'ext.nexx360Id', nexx360LocalStorage.nexx360Id); + deepSetValue(request, 'ext.version', '$prebid.version$'); + deepSetValue(request, 'ext.source', 'prebid.js'); + deepSetValue(request, 'ext.pageViewId', PAGE_VIEW_ID); + deepSetValue(request, 'ext.bidderVersion', BIDDER_VERSION); + deepSetValue(request, 'cur', [config.getConfig('currency.adServerCurrency') || 'USD']); + if (!request.user) deepSetValue(request, 'user', {}); + return request; }, +}); - /** - * Register bidder specific code, which will execute if a bid from this bidder won the auction - * @param {Bid} The bid that won the auction - */ - onBidWon: function(bid) { - // fires a pixel to confirm a winning bid - const params = { type: 'prebid', mediatype: 'banner' }; - if (bid.hasOwnProperty('nexx360')) { - if (bid.nexx360.hasOwnProperty('ssp')) params.ssp = bid.nexx360.ssp; - if (bid.nexx360.hasOwnProperty('tagId')) params.tag_id = bid.nexx360.tagId; - if (bid.nexx360.hasOwnProperty('consent')) params.consent = bid.nexx360.consent; - }; - params.price = bid.cpm; - const url = `${METRICS_TRACKER_URL}?${new URLSearchParams(params).toString()}`; - ajax(url, null, undefined, {method: 'GET', withCredentials: true}); - return true; +/** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ +function isBidRequestValid(bid) { + if (bid.params.adUnitName && (typeof bid.params.adUnitName !== 'string' || bid.params.adUnitName === '')) { + logError('bid.params.adUnitName needs to be a string'); + return false; + } + if (bid.params.adUnitPath && (typeof bid.params.adUnitPath !== 'string' || bid.params.adUnitPath === '')) { + logError('bid.params.adUnitPath needs to be a string'); + return false; + } + if (bid.params.divId && (typeof bid.params.divId !== 'string' || bid.params.divId === '')) { + logError('bid.params.divId needs to be a string'); + return false; + } + if (bid.params.allBids && typeof bid.params.allBids !== 'boolean') { + logError('bid.params.allBids needs to be a boolean'); + return false; + } + if (!bid.params.tagId && !bid.params.videoTagId && !bid.params.nativeTagId) { + logError('bid.params.tagId or bid.params.videoTagId or bid.params.nativeTagId must be defined'); + return false; } + return true; +}; +/** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + +function buildRequests(bidRequests, bidderRequest) { + const data = converter.toORTB({bidRequests, bidderRequest}) + return { + method: 'POST', + url: REQUEST_URL, + data, + } +} + +/** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + +function interpretResponse(serverResponse) { + const respBody = serverResponse.body; + if (!respBody || !Array.isArray(respBody.seatbid)) { + return []; + } + + const { bidderSettings } = getGlobal(); + const allowAlternateBidderCodes = bidderSettings && bidderSettings.standard ? bidderSettings.standard.allowAlternateBidderCodes : false; + + let bids = []; + respBody.seatbid.forEach(seatbid => { + bids = [...bids, ...seatbid.bid.map(bid => { + const response = { + requestId: bid.impid, + cpm: bid.price, + width: bid.w, + height: bid.h, + creativeId: bid.crid, + dealId: bid.dealid, + currency: respBody.cur, + netRevenue: true, + ttl: 120, + mediaType: [OUTSTREAM, INSTREAM].includes(bid.ext.mediaType) ? 'video' : bid.ext.mediaType, + meta: { + advertiserDomains: bid.adomain, + demandSource: bid.ext.ssp, + }, + }; + if (allowAlternateBidderCodes) response.bidderCode = `n360_${bid.ext.ssp}`; + + if (bid.ext.mediaType === BANNER) { + if (bid.adm) { + response.ad = bid.adm; + } else { + response.adUrl = bid.ext.adUrl; + } + } + if ([INSTREAM, OUTSTREAM].includes(bid.ext.mediaType)) response.vastXml = bid.ext.vastXml; + + if (bid.ext.mediaType === OUTSTREAM) { + response.renderer = createRenderer(bid, OUTSTREAM_RENDERER_URL); + response.divId = bid.ext.divId + }; + if (bid.ext.mediaType === NATIVE) { + try { + response.native = { + ortb: JSON.parse(bid.adm) + } + } catch (e) {} + } + return response; + })]; + }); + return bids; +} + +/** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ +function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { + if (typeof serverResponses === 'object' && + serverResponses != null && + serverResponses.length > 0 && + serverResponses[0].hasOwnProperty('body') && + serverResponses[0].body.hasOwnProperty('ext') && + serverResponses[0].body.ext.hasOwnProperty('cookies') && + typeof serverResponses[0].body.ext.cookies === 'object') { + return serverResponses[0].body.ext.cookies.slice(0, 5); + } else { + return []; + } +}; + +function outstreamRender(response) { + response.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: [response.width, response.height], + targetId: response.divId, + adResponse: response.vastXml, + rendererOptions: { + showBigPlayButton: false, + showProgressBar: 'bar', + showVolume: false, + allowFullscreen: true, + skippable: false, + content: response.vastXml + } + }); + }); } + +function createRenderer(bid, url) { + const renderer = Renderer.install({ + id: bid.id, + url: url, + loaded: false, + adUnitCode: bid.ext.adUnitCode, + targetId: bid.ext.divId, + }); + renderer.setRender(outstreamRender); + return renderer; +} + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + aliases: ALIASES, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, +}; + registerBidder(spec); diff --git a/modules/nobidAnalyticsAdapter.js b/modules/nobidAnalyticsAdapter.js new file mode 100644 index 00000000000..27ec1cd9451 --- /dev/null +++ b/modules/nobidAnalyticsAdapter.js @@ -0,0 +1,199 @@ +import {deepClone, logError, getParameterByName} from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; +import {getStorageManager} from '../src/storageManager.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import CONSTANTS from '../src/constants.json'; +import adapterManager from '../src/adapterManager.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; + +const VERSION = '1.0.4'; +const MODULE_NAME = 'nobidAnalyticsAdapter'; +const ANALYTICS_DATA_NAME = 'analytics.nobid.io'; +const RETENTION_SECONDS = 7 * 24 * 3600; +const TEST_ALLOCATION_PERCENTAGE = 5; // dont block 5% of the time; +window.nobidAnalyticsVersion = VERSION; +const analyticsType = 'endpoint'; +const url = 'localhost:8383/event'; +const GVLID = 816; +const storage = getStorageManager({gvlid: GVLID, moduleName: MODULE_NAME, moduleType: MODULE_TYPE_ANALYTICS}); +const { + EVENTS: { + AUCTION_INIT, + BID_REQUESTED, + BID_TIMEOUT, + BID_RESPONSE, + BID_WON, + AUCTION_END, + AD_RENDER_SUCCEEDED + } +} = CONSTANTS; +function log (msg) { + // eslint-disable-next-line no-console + console.log(`%cNoBid Analytics ${VERSION}`, 'padding: 2px 8px 2px 8px; background-color:#f50057; color: white', msg); +} +function isJson (str) { + return str && str.startsWith('{') && str.endsWith('}'); +} +function isExpired (data, retentionSeconds) { + retentionSeconds = retentionSeconds || RETENTION_SECONDS; + if (data.ts + retentionSeconds * 1000 < Date.now()) return true; + return false; +} +function sendEvent (event, eventType) { + function resolveEndpoint() { + var ret = 'https://carbon-nv.servenobids.com/admin/status'; + var env = (typeof getParameterByName === 'function') && (getParameterByName('nobid-env')); + env = window.location.href.indexOf('nobid-env=dev') > 0 ? 'dev' : env; + if (!env) ret = 'https://carbon-nv.servenobids.com'; + else if (env == 'dev') ret = 'https://localhost:8383'; + return ret; + } + if (!nobidAnalytics.initOptions || !nobidAnalytics.initOptions.siteId || !event) return; + if (nobidAnalytics.isAnalyticsDisabled()) { + log('NoBid Analytics is Disabled'); + return; + } + try { + const endpoint = `${resolveEndpoint()}/event/${eventType}?pubid=${nobidAnalytics.initOptions.siteId}`; + ajax(endpoint, + function (response) { + try { + nobidAnalytics.processServerResponse(response); + } catch (e) { + logError(e); + } + }, + JSON.stringify(event), + { + contentType: 'application/json', + method: 'POST' + } + ); + } catch (err) { + log(`Sending event error ${err}`); + } +} +function cleanupObjectAttributes (obj, attributes) { + if (!obj) return; + if (Array.isArray(obj)) { + obj.forEach(item => { + Object.keys(item).forEach(attr => { if (!attributes.includes(attr)) delete item[attr] }); + }); + } else Object.keys(obj).forEach(attr => { if (!attributes.includes(attr)) delete obj[attr] }); +} +function sendBidWonEvent (event, eventType) { + const data = deepClone(event); + cleanupObjectAttributes(data, ['bidderCode', 'size', 'statusMessage', 'adId', 'requestId', 'mediaType', 'adUnitCode', 'cpm', 'timeToRespond']); + if (nobidAnalytics.topLocation) data.topLocation = nobidAnalytics.topLocation; + sendEvent(data, eventType); +} +function sendAuctionEndEvent (event, eventType) { + if (event?.bidderRequests?.length > 0 && event?.bidderRequests[0]?.refererInfo?.topmostLocation) { + nobidAnalytics.topLocation = event.bidderRequests[0].refererInfo.topmostLocation; + } + const data = deepClone(event); + + cleanupObjectAttributes(data, ['timestamp', 'timeout', 'auctionId', 'bidderRequests', 'bidsReceived']); + if (data) cleanupObjectAttributes(data.bidderRequests, ['bidderCode', 'bidderRequestId', 'bids', 'refererInfo']); + if (data) cleanupObjectAttributes(data.bidsReceived, ['bidderCode', 'width', 'height', 'adUnitCode', 'statusMessage', 'requestId', 'mediaType', 'cpm']); + if (data) cleanupObjectAttributes(data.noBids, ['bidder', 'sizes', 'bidId']); + if (data.bidderRequests) cleanupObjectAttributes(data.bidderRequests.bids, ['mediaTypes', 'adUnitCode', 'sizes', 'bidId']); + if (data.bidderRequests) cleanupObjectAttributes(data.bidderRequests.refererInfo, ['topmostLocation']); + sendEvent(data, eventType); +} +function auctionInit (event) { + if (event?.bidderRequests?.length > 0 && event?.bidderRequests[0]?.refererInfo?.topmostLocation) { + nobidAnalytics.topLocation = event.bidderRequests[0].refererInfo.topmostLocation; + } +} +let nobidAnalytics = Object.assign(adapter({url, analyticsType}), { + track({ eventType, args }) { + switch (eventType) { + case AUCTION_INIT: + auctionInit(args); + break; + case BID_REQUESTED: + break; + case BID_RESPONSE: + break; + case BID_WON: + sendBidWonEvent(args, eventType); + break; + case BID_TIMEOUT: + break; + case AUCTION_END: + sendAuctionEndEvent(args, eventType); + break; + case AD_RENDER_SUCCEEDED: + break; + default: + break; + } + } +}); + +nobidAnalytics = { + ...nobidAnalytics, + originEnableAnalytics: nobidAnalytics.enableAnalytics, // save the base class function + enableAnalytics: function (config) { // override enableAnalytics so we can get access to the config passed in from the page + if (!config.options.siteId) { + logError('NoBid Analytics - siteId parameter is not defined. Analytics won\'t work'); + return; + } + this.initOptions = config.options; + this.originEnableAnalytics(config); // call the base class function + }, + retentionSeconds: RETENTION_SECONDS, + isExpired (data) { + return isExpired(data, this.retentionSeconds); + }, + isAnalyticsDisabled () { + let stored = storage.getDataFromLocalStorage(ANALYTICS_DATA_NAME); + if (!isJson(stored)) return false; + stored = JSON.parse(stored); + if (this.isExpired(stored)) return false; + return stored.disabled; + }, + processServerResponse (response) { + if (!isJson(response)) return; + const resp = JSON.parse(response); + storage.setDataInLocalStorage(ANALYTICS_DATA_NAME, JSON.stringify({ ...resp, ts: Date.now() })); + } +} + +adapterManager.registerAnalyticsAdapter({ + adapter: nobidAnalytics, + code: 'nobidAnalytics', + gvlid: GVLID +}); +window.nobidCarbonizer = { + getStoredLocalData: function () { + return storage.getDataFromLocalStorage(ANALYTICS_DATA_NAME); + }, + isActive: function () { + let stored = storage.getDataFromLocalStorage(ANALYTICS_DATA_NAME); + if (!isJson(stored)) return false; + stored = JSON.parse(stored); + if (isExpired(stored, nobidAnalytics.retentionSeconds)) return false; + return stored.carbonizer_active || false; + }, + carbonizeAdunits: function (adunits, skipTestGroup) { + function carbonizeAdunit (adunit) { + let stored = storage.getDataFromLocalStorage(ANALYTICS_DATA_NAME); + if (!isJson(stored)) return; + stored = JSON.parse(stored); + if (isExpired(stored, nobidAnalytics.retentionSeconds)) return; + const carbonizerBidders = stored.bidders || []; + const allowedBidders = adunit.bids.filter(rec => carbonizerBidders.includes(rec.bidder)); + adunit.bids = allowedBidders; + } + if (this.isActive()) { + // 5% of the time do not block; + if (!skipTestGroup && Math.floor(Math.random() * 101) <= TEST_ALLOCATION_PERCENTAGE) return; + adunits.forEach(adunit => { + carbonizeAdunit(adunit); + }); + } + } +}; +export default nobidAnalytics; diff --git a/modules/nobidAnalyticsAdapter.md b/modules/nobidAnalyticsAdapter.md new file mode 100644 index 00000000000..92b9bdbb3cb --- /dev/null +++ b/modules/nobidAnalyticsAdapter.md @@ -0,0 +1,38 @@ +# Overview +Module Name: NoBid Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: [nobid.io](https://nobid.io) + + +# NoBid Analytics Registration + +The NoBid Analytics Adapter is free to use during our Beta period, but requires a simple registration with NoBid. Please visit [www.nobid.io](https://www.nobid.io/contact-1/) to sign up and request your NoBid Site ID to get started. If you're already using the NoBid Prebid Adapter, you may use your existing Site ID with the NoBid Analytics Adapter. + +The NoBid privacy policy is at [nobid.io/privacy-policy](https://www.nobid.io/privacy-policy/). + +## NoBid Analytics Configuration + +First, make sure to add the NoBid Analytics submodule to your Prebid.js package with: + +``` +gulp build --modules=...,nobidAnalyticsAdapter... +``` + +The following configuration parameters are available: + +```javascript +pbjs.enableAnalytics({ + provider: 'nobidAnalytics', + options: { + siteId: 123 // change to the Site ID you received from NoBid + } +}); +``` + +{: .table .table-bordered .table-striped } +| Parameter | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| provider | Required | String | The name of this module: `nobidAnalytics` | `nobidAnalytics` | +| options.siteId | Required | Number | This is the NoBid Site ID Number obtained from registering with NoBid. | `1234` | diff --git a/modules/nobidBidAdapter.js b/modules/nobidBidAdapter.js index f788093f833..68010b32b37 100644 --- a/modules/nobidBidAdapter.js +++ b/modules/nobidBidAdapter.js @@ -3,11 +3,12 @@ import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { getStorageManager } from '../src/storageManager.js'; +import { hasPurpose1Consent } from '../src/utils/gpdr.js'; const GVLID = 816; const BIDDER_CODE = 'nobid'; -const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); -window.nobidVersion = '1.3.2'; +const storage = getStorageManager({bidderCode: BIDDER_CODE}); +window.nobidVersion = '1.3.3'; window.nobid = window.nobid || {}; window.nobid.bidResponses = window.nobid.bidResponses || {}; window.nobid.timeoutTotal = 0; @@ -25,20 +26,11 @@ function nobidSetCookie(cname, cvalue, hours) { function nobidGetCookie(cname) { return storage.getCookie(cname); } -function nobidHasPurpose1Consent(bidderRequest) { - let result = true; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) { - result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} function nobidBuildRequests(bids, bidderRequest) { var serializeState = function(divIds, siteId, adunits) { var filterAdUnitsByIds = function(divIds, adUnits) { var filtered = []; - if (!divIds || !divIds.length) { + if (!divIds.length) { filtered = adUnits; } else if (adUnits) { var a = []; @@ -71,6 +63,19 @@ function nobidBuildRequests(bids, bidderRequest) { } return uspConsent; } + var gppConsent = function(bidderRequest) { + let gppConsent = null; + if (bidderRequest?.gppConsent?.gppString && bidderRequest?.gppConsent?.applicableSections) { + gppConsent = {}; + gppConsent.gpp = bidderRequest.gppConsent.gppString; + gppConsent.gpp_sid = Array.isArray(bidderRequest.gppConsent.applicableSections) ? bidderRequest.gppConsent.applicableSections : []; + } else if (bidderRequest?.ortb2?.regs?.gpp && bidderRequest?.ortb2.regs?.gpp_sid) { + gppConsent = {}; + gppConsent.gpp = bidderRequest.ortb2.regs.gpp; + gppConsent.gpp_sid = Array.isArray(bidderRequest.ortb2.regs.gpp_sid) ? bidderRequest.ortb2.regs.gpp_sid : []; + } + return gppConsent; + } var schain = function(bids) { if (bids && bids.length > 0) { return bids[0].schain @@ -88,9 +93,10 @@ function nobidBuildRequests(bids, bidderRequest) { } var topLocation = function(bidderRequest) { var ret = ''; - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - ret = bidderRequest.refererInfo.referer; + if (bidderRequest?.refererInfo?.page) { + ret = bidderRequest.refererInfo.page; } else { + // TODO: does this fallback make sense here? ret = (window.context && window.context.location && window.context.location.href) ? window.context.location.href : document.location.href; } return encodeURIComponent(ret.replace(/\%/g, '')); @@ -152,9 +158,12 @@ function nobidBuildRequests(bids, bidderRequest) { if (cop) state['coppa'] = cop; const eids = getEIDs(deepAccess(bids, '0.userIdAsEids')); if (eids && eids.length > 0) state['eids'] = eids; - if (config && config.getConfig('ortb2')) state['ortb2'] = config.getConfig('ortb2'); + const gpp = gppConsent(bidderRequest); + if (gpp?.gpp) state['gpp'] = gpp.gpp; + if (gpp?.gpp_sid) state['gpp_sid'] = gpp.gpp_sid; + if (bidderRequest && bidderRequest.ortb2) state['ortb2'] = bidderRequest.ortb2; return state; - } + }; function newAdunit(adunitObject, adunits) { var getAdUnit = function(divid, adunits) { for (var i = 0; i < adunits.length; i++) { @@ -182,6 +191,9 @@ function nobidBuildRequests(bids, bidderRequest) { if (adunitObject.div) { a.d = adunitObject.div; } + if (adunitObject.floor) { + a.floor = adunitObject.floor; + } if (adunitObject.targeting) { a.g = adunitObject.targeting; } else { @@ -208,6 +220,12 @@ function nobidBuildRequests(bids, bidderRequest) { adunits.push(a); return adunits; } + function getFloor (bid) { + if (bid && typeof bid.getFloor === 'function' && bid.getFloor().floor) { + return bid.getFloor().floor; + } + return null; + } if (typeof window.nobid.refreshLimit !== 'undefined') { if (window.nobid.refreshLimit < window.nobid.refreshCount) return false; } @@ -228,12 +246,13 @@ function nobidBuildRequests(bids, bidderRequest) { siteId = (typeof bid.params['siteId'] != 'undefined' && bid.params['siteId']) ? bid.params['siteId'] : siteId; var placementId = bid.params['placementId']; - var adType = 'banner'; + let adType = 'banner'; const videoMediaType = deepAccess(bid, 'mediaTypes.video'); - const context = deepAccess(bid, 'mediaTypes.video.context'); + const context = deepAccess(bid, 'mediaTypes.video.context') || ''; if (bid.mediaType === VIDEO || (videoMediaType && (context === 'instream' || context === 'outstream'))) { adType = 'video'; } + const floor = getFloor(bid); if (siteId) { newAdunit({ @@ -242,7 +261,9 @@ function nobidBuildRequests(bids, bidderRequest) { siteId: siteId, placementId: placementId, ad_type: adType, - params: bid.params + params: bid.params, + floor: floor, + ctx: context }, adunits); } @@ -365,6 +386,7 @@ export const spec = { function resolveEndpoint() { var ret = 'https://ads.servenobid.com/'; var env = (typeof getParameterByName === 'function') && (getParameterByName('nobid-env')); + env = window.location.href.indexOf('nobid-env=dev') > 0 ? 'dev' : env; if (!env) ret = 'https://ads.servenobid.com/'; else if (env == 'beta') ret = 'https://beta.servenobid.com/'; else if (env == 'dev') ret = '//localhost:8282/'; @@ -386,7 +408,7 @@ export const spec = { const endpoint = buildEndpoint(); let options = {}; - if (!nobidHasPurpose1Consent(bidderRequest)) { + if (!hasPurpose1Consent(bidderRequest?.gdprConsent)) { options = { withCredentials: false }; } @@ -417,7 +439,7 @@ export const spec = { * @param {ServerResponse[]} serverResponses List of server's responses. * @return {UserSync[]} The user syncs which should be dropped. */ - getUserSyncs: function(syncOptions, serverResponses, gdprConsent, usPrivacy) { + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, usPrivacy, gppConsent) { if (syncOptions.iframeEnabled) { let params = ''; if (gdprConsent && typeof gdprConsent.consentString === 'string') { @@ -433,6 +455,12 @@ export const spec = { else params += '?'; params += 'usp_consent=' + usPrivacy; } + if (gppConsent?.gppString && gppConsent?.applicableSections?.length) { + if (params.length > 0) params += '&'; + else params += '?'; + params += 'gpp=' + encodeURIComponent(gppConsent.gppString); + params += 'gpp_sid=' + encodeURIComponent(gppConsent.applicableSections.join(',')); + } return [{ type: 'iframe', url: 'https://public.servenobid.com/sync.html' + params @@ -445,7 +473,7 @@ export const spec = { type: 'image', url: element }); - }) + }); } return syncs; } else { diff --git a/modules/nobidBidAdapter.md b/modules/nobidBidAdapter.md index 9e47aa5f43f..e2f1c75e782 100644 --- a/modules/nobidBidAdapter.md +++ b/modules/nobidBidAdapter.md @@ -4,9 +4,10 @@ title: Nobid description: Prebid Nobid Bidder Adaptor biddercode: nobid hide: true -media_types: banner +media_types: banner, video gdpr_supported: true usp_supported: true +gpp_supported: true --- ### Bid Params @@ -51,4 +52,4 @@ usp_supported: true ] } ]; -``` \ No newline at end of file +``` diff --git a/modules/novatiqIdSystem.js b/modules/novatiqIdSystem.js index ae9cc4c818f..7eced81d35e 100644 --- a/modules/novatiqIdSystem.js +++ b/modules/novatiqIdSystem.js @@ -8,7 +8,10 @@ import { logInfo, getWindowLocation } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import { submodule } from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; + +const MODULE_NAME = 'novatiq'; /** @type {Submodule} */ export const novatiqIdSubmodule = { @@ -17,7 +20,12 @@ export const novatiqIdSubmodule = { * used to link submodule with config * @type {string} */ - name: 'novatiq', + name: MODULE_NAME, + /** + * used to specify vendor id + * @type {number} + */ + gvlid: 1119, /** * decode the stored id value for passing to bid requests @@ -30,6 +38,16 @@ export const novatiqIdSubmodule = { snowflake: novatiqId } }; + + if (novatiqId.syncResponse !== undefined) { + responseObj.novatiq.ext = {}; + responseObj.novatiq.ext.syncResponse = novatiqId.syncResponse; + } + + if (typeof config != 'undefined' && typeof config.params !== 'undefined' && typeof config.params.removeAdditionalInfo !== 'undefined' && config.params.removeAdditionalInfo === true) { + delete responseObj.novatiq.snowflake.syncResponse; + } + return responseObj; }, @@ -115,7 +133,7 @@ export const novatiqIdSubmodule = { getNovatiqId(urlParams) { // standard uuid format let uuidFormat = [1e7] + -1e3 + -4e3 + -8e3 + -1e11; - if (urlParams.useStandardUuid == false) { + if (urlParams.useStandardUuid === false) { // novatiq standard uuid(like) format uuidFormat = uuidFormat + 1e3; } @@ -202,7 +220,7 @@ export const novatiqIdSubmodule = { let sharedId = null; if (this.useSharedId(configParams)) { let cookieOrStorageID = this.getCookieOrStorageID(configParams); - const storage = getStorageManager({moduleName: 'pubCommonId'}); + const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); // first check local storage if (storage.hasLocalStorage()) { @@ -240,7 +258,19 @@ export const novatiqIdSubmodule = { } else { srcId = configParams.sourceid; } - return srcId + return srcId; + }, + eids: { + 'novatiq': { + getValue: function(data) { + if (data.snowflake.id === undefined) { + return data.snowflake; + } + + return data.snowflake.id; + }, + source: 'novatiq.com', + }, } }; submodule('userId', novatiqIdSubmodule); diff --git a/modules/oguryBidAdapter.js b/modules/oguryBidAdapter.js index 7d2989b2066..c1c8376de87 100644 --- a/modules/oguryBidAdapter.js +++ b/modules/oguryBidAdapter.js @@ -1,16 +1,40 @@ 'use strict'; -import { BANNER } from '../src/mediaTypes.js'; -import { getAdUnitSizes, logWarn, isFn, getWindowTop, getWindowSelf } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { ajax } from '../src/ajax.js' +import {BANNER} from '../src/mediaTypes.js'; +import {getWindowSelf, getWindowTop, isFn, logWarn} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {ajax} from '../src/ajax.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; const BIDDER_CODE = 'ogury'; +const GVLID = 31; const DEFAULT_TIMEOUT = 1000; const BID_HOST = 'https://mweb-hb.presage.io/api/header-bidding-request'; const TIMEOUT_MONITORING_HOST = 'https://ms-ads-monitoring-events.presage.io'; const MS_COOKIE_SYNC_DOMAIN = 'https://ms-cookie-sync.presage.io'; -const ADAPTER_VERSION = '1.2.10'; +const ADAPTER_VERSION = '1.5.0'; + +function getClientWidth() { + const documentElementClientWidth = window.top.document.documentElement.clientWidth + ? window.top.document.documentElement.clientWidth + : 0 + const innerWidth = window.top.innerWidth ? window.top.innerWidth : 0 + const outerWidth = window.top.outerWidth ? window.top.outerWidth : 0 + const screenWidth = window.top.screen.width ? window.top.screen.width : 0 + + return documentElementClientWidth || innerWidth || outerWidth || screenWidth +} + +function getClientHeight() { + const documentElementClientHeight = window.top.document.documentElement.clientHeight + ? window.top.document.documentElement.clientHeight + : 0 + const innerHeight = window.top.innerHeight ? window.top.innerHeight : 0 + const outerHeight = window.top.outerHeight ? window.top.outerHeight : 0 + const screenHeight = window.top.screen.height ? window.top.screen.height : 0 + + return documentElementClientHeight || innerHeight || outerHeight || screenHeight +} function isBidRequestValid(bid) { const adUnitSizes = getAdUnitSizes(bid); @@ -23,23 +47,40 @@ function isBidRequestValid(bid) { } function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { - if (!syncOptions.pixelEnabled) return []; + const consent = (gdprConsent && gdprConsent.consentString) || ''; - return [ - { - type: 'image', - url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid` - }, - { - type: 'image', - url: `${MS_COOKIE_SYNC_DOMAIN}/ttd/init-sync?iab_string=${(gdprConsent && gdprConsent.consentString) || ''}&source=prebid` - } - ] + if (syncOptions.iframeEnabled) { + return [ + { + type: 'iframe', + url: `${MS_COOKIE_SYNC_DOMAIN}/user-sync.html?gdpr_consent=${consent}&source=prebid` + } + ]; + } + + if (syncOptions.pixelEnabled) { + return [ + { + type: 'image', + url: `${MS_COOKIE_SYNC_DOMAIN}/v1/init-sync/bid-switch?iab_string=${consent}&source=prebid` + }, + { + type: 'image', + url: `${MS_COOKIE_SYNC_DOMAIN}/ttd/init-sync?iab_string=${consent}&source=prebid` + }, + { + type: 'image', + url: `${MS_COOKIE_SYNC_DOMAIN}/xandr/init-sync?iab_string=${consent}&source=prebid` + } + ]; + } + + return []; } function buildRequests(validBidRequests, bidderRequest) { const openRtbBidRequestBanner = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, tmax: DEFAULT_TIMEOUT, at: 1, regs: { @@ -60,6 +101,11 @@ function buildRequests(validBidRequests, bidderRequest) { ext: { adapterversion: ADAPTER_VERSION, prebidversion: '$prebid.version$' + }, + device: { + w: getClientWidth(), + h: getClientHeight(), + pxratio: window.devicePixelRatio } }; @@ -74,15 +120,19 @@ function buildRequests(validBidRequests, bidderRequest) { if (bidRequest.mediaTypes && bidRequest.mediaTypes.hasOwnProperty('banner')) { openRtbBidRequestBanner.site.id = bidRequest.params.assetKey; + const floor = getFloor(bidRequest); openRtbBidRequestBanner.imp.push({ id: bidRequest.bidId, tagid: bidRequest.params.adUnitId, - bidfloor: getFloor(bidRequest), + ...(floor && {bidfloor: floor}), banner: { format: sizes }, - ext: bidRequest.params + ext: { + ...bidRequest.params, + timeSpentOnPage: document.timeline && document.timeline.currentTime ? document.timeline.currentTime : 0 + } }); } }); @@ -171,6 +221,7 @@ function onTimeout(timeoutData) { export const spec = { code: BIDDER_CODE, + gvlid: GVLID, supportedMediaTypes: [BANNER], isBidRequestValid, getUserSyncs, diff --git a/modules/oneKeyIdSystem.js b/modules/oneKeyIdSystem.js new file mode 100644 index 00000000000..699a7a6ab95 --- /dev/null +++ b/modules/oneKeyIdSystem.js @@ -0,0 +1,104 @@ +/** + * This module adds Onekey data to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/oneKeyIdSystem + * @requires module:modules/userId + */ + +import {submodule} from '../src/hook.js'; +import { logError, logMessage } from '../src/utils.js'; + +// Pre-init OneKey if it has not load yet. +window.OneKey = window.OneKey || {}; +window.OneKey.queue = window.OneKey.queue || []; + +const logPrefix = 'OneKey.Id-Module'; + +/** + * Generate callback that deserializes the result of getIdsAndPreferences. + */ +const onIdsAndPreferencesResult = (callback) => { + return (result) => { + logMessage(logPrefix, `Has got Ids and Prefs with status: `, result); + callback(result.data); + }; +}; + +/** + * Call OneKey once it is loaded for retrieving + * the ids and the preferences. + */ +const getIdsAndPreferences = (callback) => { + logMessage(logPrefix, 'Queue getIdsAndPreferences call'); + // Call OneKey in a queue so that we are sure + // it will be called when fully load and configured + // within the page. + window.OneKey.queue.push(() => { + logMessage(logPrefix, 'Get Ids and Prefs'); + window.OneKey.getIdsAndPreferences() + .then(onIdsAndPreferencesResult(callback)) + .catch(() => { + logError(logPrefix, 'Cannot retrieve the ids and preferences from OneKey.'); + callback(undefined); + }); + }); +}; + +/** @type {Submodule} */ +export const oneKeyIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: 'oneKeyData', + /** + * decode the stored data value for passing to bid requests + * @function decode + * @param {(Object|string)} value + * @returns {(Object|undefined)} + */ + decode(data) { + return { oneKeyData: data }; + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} [config] + * @param {ConsentData} [consentData] + * @param {(Object|undefined)} cacheIdObj + * @returns {IdResponse|undefined} + */ + getId(config) { + return { + callback: getIdsAndPreferences + }; + }, + eids: { + 'oneKeyData': { + getValue: function(data) { + if (data && Array.isArray(data.identifiers) && data.identifiers[0]) { + return data.identifiers[0].value; + } + }, + source: 'paf', + atype: 1, + getEidExt: function(data) { + if (data && data.preferences) { + return {preferences: data.preferences}; + } + }, + getUidExt: function(data) { + if (data && Array.isArray(data.identifiers) && data.identifiers[0]) { + const id = data.identifiers[0]; + return { + version: id.version, + type: id.type, + source: id.source + }; + } + } + } + } +}; + +submodule('userId', oneKeyIdSubmodule); diff --git a/modules/oneKeyIdSystem.md b/modules/oneKeyIdSystem.md new file mode 100644 index 00000000000..36caf382065 --- /dev/null +++ b/modules/oneKeyIdSystem.md @@ -0,0 +1,109 @@ +# OneKey + +The OneKey real-time data module in Prebid has been built so that publishers +can quickly and easily setup the OneKey Addressability Framework. +This module is used along with the oneKeyRtdProvider to pass OneKey data to your partners. +Both modules are required. This module will pass oneKeyData to your partners +while the oneKeyRtdProvider will pass the transmission requests. + +Background information: +- [OneKey-Network/addressability-framework](https://github.com/OneKey-Network/addressability-framework) +- [OneKey-Network/OneKey-implementation](https://github.com/OneKey-Network/OneKey-implementation) + +It can be added to you Prebid.js package with: + +{: .alert.alert-info :} +gulp build –modules=userId,oneKeyIdSystem + +⚠️ This module works in association with a RTD module. See [oneKeyRtdProvider](oneKeyRtdProvider.md). + +#### OneKey Registration + +OneKey is a community based Framework with a decentralized approach. +Go to [onekey.community](https://onekey.community/) for more details. + +#### OneKey Configuration + +{: .table .table-bordered .table-striped } +| Param under userSync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | The name of this module | `"oneKeyData"` | + + +#### OneKey Exemple + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'oneKeyData' + }] + } +}); +``` + +Bidders will receive the data in the following format: + +```json +{ + "identifiers": [{ + "version": "0.1", + "type": "paf_browser_id", + "value": "da135b3a-7d04-44bf-a0af-c4709f10420b", + "source": { + "domain": "crto-poc-1.onekey.network", + "timestamp": 1648836556881, + "signature": "+NF27bBvPM54z103YPExXuS834+ggAQe6JV0jPeGo764vRYiiBl5OmEXlnB7UZgxNe3KBU7rN2jk0SkI4uL0bg==" + } + }], + "preferences": { + "version": "0.1", + "data": { + "use_browsing_for_personalization": true + }, + "source": { + "domain": "cmp.pafdemopublisher.com", + "timestamp": 1648836566468, + "signature": "ipbYhU8IbSFm2tCqAVYI2d5w4DnGF7Xa2AaiZScx2nmBPLfMmIT/FkBYGitR8Mi791DHtcy5MXr4+bs1aeZFqw==" + } + } +} +``` + +If the bidder elects to use pbjs.getUserIdsAsEids() then the format will be: + +```json +"user": { + "ext": { + "eids": [{ + "source": "paf", + "uids": [{ + "id": "da135b3a-7d04-44bf-a0af-c4709f10420b", + "atype": 1, + "ext": { + "version": "0.1", + "type": "paf_browser_id", + "source": { + "domain": "crto-poc-1.onekey.network", + "timestamp": 1648836556881, + "signature": "+NF27bBvPM54z103YPExXuS834+ggAQe6JV0jPeGo764vRYiiBl5OmEXlnB7UZgxNe3KBU7rN2jk0SkI4uL0bg==" + } + } + }], + "ext": { + "preferences": { + "version": "0.1", + "data": { + "use_browsing_for_personalization": true + }, + "source": { + "domain": "cmp.pafdemopublisher.com", + "timestamp": 1648836566468, + "signature": "ipbYhU8IbSFm2tCqAVYI2d5w4DnGF7Xa2AaiZScx2nmBPLfMmIT/FkBYGitR8Mi791DHtcy5MXr4+bs1aeZFqw==" + } + } + } + }] + } +} +``` \ No newline at end of file diff --git a/modules/oneKeyRtdProvider.js b/modules/oneKeyRtdProvider.js new file mode 100644 index 00000000000..27511017676 --- /dev/null +++ b/modules/oneKeyRtdProvider.js @@ -0,0 +1,98 @@ + +import { submodule } from '../src/hook.js'; +import { mergeDeep, logError, logMessage, deepSetValue, generateUUID } from '../src/utils.js'; +import { getGlobal } from '../src/prebidGlobal.js'; + +const SUBMODULE_NAME = 'oneKey'; +const prefixLog = 'OneKey.RTD-module' + +// Pre-init OneKey if it has not load yet. +window.OneKey = window.OneKey || {}; +window.OneKey.queue = window.OneKey.queue || []; + +/** + * Generate the OneKey transmission and include it in the Bid Request. + * + * Modify the AdUnit object for each auction. + * It’s called as part of the requestBids hook. + * https://docs.prebid.org/dev-docs/add-rtd-submodule.html#getbidrequestdata + * + * @param {Object} reqBidsConfigObj + * @param {function} callback + * @param {Object} rtdConfig + * @param {Object} userConsent + */ +const getTransmissionInBidRequest = (reqBidsConfigObj, done, rtdConfig) => { + const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; + const transactionIds = adUnits.map(() => generateUUID()); + + logMessage(prefixLog, 'Queue seed generation.'); + window.OneKey.queue.push(() => { + logMessage(prefixLog, 'Generate a seed.'); + window.OneKey.generateSeed(transactionIds) + .then(onGetSeed(reqBidsConfigObj, rtdConfig, adUnits, transactionIds)) + .catch((err) => { logError(SUBMODULE_NAME, err.message); }) + .finally(done); + }); +} + +const onGetSeed = (reqBidsConfigObj, rtdConfig, adUnits, transactionIds) => { + return (seed) => { + if (!seed) { + logMessage(prefixLog, 'No seed generated.'); + return; + } + + logMessage(prefixLog, 'Has retrieved a seed:', seed); + addTransactionIdsToAdUnits(adUnits, transactionIds); + addTransmissionToOrtb2(reqBidsConfigObj, rtdConfig, seed); + }; +}; + +const addTransactionIdsToAdUnits = (adUnits, transactionIds) => { + adUnits.forEach((unit, index) => { + deepSetValue(unit, `ortb2Imp.ext.data.paf.transaction_id`, transactionIds[index]); + }); +}; + +const addTransmissionToOrtb2 = (reqBidsConfigObj, rtdConfig, seed) => { + const okOrtb2 = { + ortb2: { + user: { + ext: { + paf: { + transmission: { + seed + } + } + } + } + } + } + + const shareSeedWithAllBidders = !rtdConfig.params || !rtdConfig.params.bidders; + if (shareSeedWithAllBidders) { + // Change global first party data with OneKey + logMessage(prefixLog, 'set ortb2:', okOrtb2); + mergeDeep(reqBidsConfigObj.ortb2Fragments.global, okOrtb2.ortb2); + } else { + // Change bidder-specific first party data with OneKey + logMessage(prefixLog, `set ortb2 for: ${rtdConfig.params.bidders.join(',')}`, okOrtb2); + rtdConfig.params.bidders.forEach(bidder => { + mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, { [bidder]: okOrtb2.ortb2 }); + }); + } +}; + +/** @type {RtdSubmodule} */ +export const oneKeyDataSubmodule = { + /** + * used to link submodule with realTimeData + * @type {string} + */ + name: SUBMODULE_NAME, + init: () => true, + getBidRequestData: getTransmissionInBidRequest, +}; + +submodule('realTimeData', oneKeyDataSubmodule); diff --git a/modules/oneKeyRtdProvider.md b/modules/oneKeyRtdProvider.md new file mode 100644 index 00000000000..075e91cafda --- /dev/null +++ b/modules/oneKeyRtdProvider.md @@ -0,0 +1,127 @@ +## OneKey Real-time Data Submodule + +The OneKey real-time data module in Prebid has been built so that publishers +can quickly and easily setup the OneKey Addressability Framework. +This module is used along with the oneKeyIdSystem to pass OneKey data to your partners. +Both modules are required. This module will pass transmission requests to your partners +while the oneKeyIdSystem will pass the oneKeyData. + +Background information: +- [OneKey-Network/addressability-framework](https://github.com/OneKey-Network/addressability-framework) +- [OneKey-Network/OneKey-implementation](https://github.com/OneKey-Network/OneKey-implementation) + +## Implementation for Publishers + +### Integration + +1) Compile the OneKey RTD Provider and the OneKey UserID sub-module into your Prebid build. + +``` +gulp build --modules=rtdModule,oneKeyRtdProvider +``` + +2) Publishers must register OneKey RTD Provider as a Real Time Data provider by using `setConfig` +to load a Prebid Config containing a `realTimeData.dataProviders` array: + +```javascript +pbjs.setConfig({ + ..., + realTimeData: { + auctionDelay: 100, + dataProviders: [ + { + name: 'oneKey', + waitForIt: true + } + ] + } +}); +``` + +3) Configure the OneKey RTD Provider with the bidders that are part of the OneKey community. If there is no bidders specified, the RTD provider +will share OneKey data with all adapters. + +⚠️ This module works in association with a RTD module. See [oneKeyIdSystem](oneKeyIdSystem.md). + +### Parameters + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| name | String | Real time data module name | Always 'oneKey' | +| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | +| params | Object | | Optional | +| params.bidders | Array | List of bidders to restrict the data to. | Optional | + +## Implementation for Bidders + +### Bidder Requests + +The data will provided to the bidders using the `ortb2` object. +The following is an example of the format of the data: + +```json +"user": { + "ext": { + "paf": { + "transmission": { + "seed": { + "version": "0.1", + "transaction_ids": ["06df6992-691c-4342-bbb0-66d2a005d5b1", "d2cd0aa7-8810-478c-bd15-fb5bfa8138b8"], + "publisher": "cmp.pafdemopublisher.com", + "source": { + "domain": "cmp.pafdemopublisher.com", + "timestamp": 1649712888, + "signature": "turzZlXh9IqD5Rjwh4vWR78pKLrVsmwQrGr6fgw8TPgQVJSC8K3HvkypTV7lm3UaCi+Zzjl+9sd7Hrv87gdI8w==" + } + } + } + } + } +} +``` + +```json +"ortb2Imp": { + "ext": { + "data": { + "paf": { + "transaction_id": "52d23fed-4f50-4c17-b07a-c458143e9d09" + } + } + } +} +``` + +### Bidder Responses + +Bidders who are part of the OneKey Addressability Framework and receive OneKey +transmissions are required to return transmission responses as outlined in +[OneKey-Network/addressability-framework]https://github.com/OneKey-Network/addressability-framework/blob/main/mvp-spec/ad-auction.md). Transmission responses should be appended to bids +along with the releveant content_id using the meta.paf field. The paf-lib will +be responsible for collecting all of the transmission responses. + +Below is an example of setting a transmission response: + +```javascript +bid.meta.paf = { + content_id: "90141190-26fe-497c-acee-4d2b649c2112", + transmission: { + version: "0.1", + contents: [ + { + transaction_id: "f55a401d-e8bb-4de1-a3d2-fa95619393e8", + content_id: "90141190-26fe-497c-acee-4d2b649c2112" + } + ], + status: "success", + details: "", + receiver: "dsp1.com", + source: { + domain: "dsp1.com", + timestamp: 1639589531, + signature: "d01c6e83f14b4f057c2a2a86d320e2454fc0c60df4645518d993b5f40019d24c" + }, + children: [] + } +} +``` diff --git a/modules/oneVideoBidAdapter.js b/modules/oneVideoBidAdapter.js deleted file mode 100644 index aeb19e7c32c..00000000000 --- a/modules/oneVideoBidAdapter.js +++ /dev/null @@ -1,408 +0,0 @@ -import { logError, logWarn, parseSizesInput, generateUUID, isFn, logMessage, isPlainObject, isStr, isNumber, isArray } from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; - -const BIDDER_CODE = 'oneVideo'; -export const spec = { - code: 'oneVideo', - VERSION: '3.1.2', - ENDPOINT: 'https://ads.adaptv.advertising.com/rtb/openrtb?ext_id=', - E2ETESTENDPOINT: 'https://ads-wc.v.ssp.yahoo.com/rtb/openrtb?ext_id=', - SYNC_ENDPOINT1: 'https://pixel.advertising.com/ups/57304/sync?gdpr=&gdpr_consent=&_origin=0&redir=true', - SYNC_ENDPOINT2: 'https://match.adsrvr.org/track/cmf/generic?ttd_pid=adaptv&ttd_tpi=1', - supportedMediaTypes: ['video', 'banner'], - gvlid: 25, - /** - * Determines whether or not the given bid request is valid. - * - * @param {BidRequest} bid The bid params to validate. - * @return boolean True if this is a valid bid, and false otherwise. - */ - isBidRequestValid: function(bid) { - // Bidder code validation - if (bid.bidder !== BIDDER_CODE || typeof bid.params === 'undefined') { - return false; - } - - // E2E test skip validations - if (bid.params && bid.params.video && bid.params.video.e2etest) { - return true; - } - // MediaTypes Video / Banner validation - if (typeof bid.mediaTypes.video === 'undefined' && typeof bid.mediaTypes.banner === 'undefined') { - logError('Failed validation: adUnit mediaTypes.video OR mediaTypes.banner not declared'); - return false; - }; - - if (bid.mediaTypes.video) { - // Player size validation - if (typeof bid.mediaTypes.video.playerSize === 'undefined') { - if (bid.params.video && (typeof bid.params.video.playerWidth === 'undefined' || typeof bid.params.video.playerHeight === 'undefined')) { - logError('Failed validation: Player size not declared in either mediaTypes.playerSize OR bid.params.video.plauerWidth & bid.params.video.playerHeight.'); - return false; - }; - }; - // Mimes validation - if (typeof bid.mediaTypes.video.mimes === 'undefined') { - if (!bid.params.video || typeof bid.params.video.mimes === 'undefined') { - logError('Failed validation: adUnit mediaTypes.mimes OR params.video.mimes not declared'); - return false; - }; - }; - // Prevend DAP Outstream validation, Banner DAP validation & Multi-Format adUnit support - if (bid.mediaTypes.video.context === 'outstream' && bid.params.video && bid.params.video.display === 1) { - logError('Failed validation: Dynamic Ad Placement cannot be used with context Outstream (params.video.display=1)'); - return false; - }; - }; - - // Publisher Id (Exchange) validation - if (typeof bid.params.pubId === 'undefined') { - logError('Failed validation: Adapter cannot send requests without bid.params.pubId'); - return false; - } - - return true; - }, - /** - * Make a server request from the list of BidRequests. - * - * @param {validBidRequests[]} - an array of bids - * @param bidderRequest - * @return ServerRequest Info describing the request to the server. - */ - buildRequests: function (bids, bidRequest) { - let consentData = bidRequest ? bidRequest.gdprConsent : null; - - return bids.map(bid => { - let url = spec.ENDPOINT - let pubId = bid.params.pubId; - if (bid.params.video.e2etest) { - url = spec.E2ETESTENDPOINT; - pubId = 'HBExchange'; - } - return { - method: 'POST', - /** removing adding local protocal since we - * can get cookie data only if we call with https. */ - url: url + pubId, - data: getRequestData(bid, consentData, bidRequest), - bidRequest: bid - } - }) - }, - /** - * Unpack the response from the server into a list of bids. - * - * @param {*} serverResponse A successful response from the server. - * @return {Bid[]} An array of bids which were nested inside the server. - */ - interpretResponse: function(response, {bidRequest}) { - let bid; - let size; - let bidResponse; - try { - response = response.body; - bid = response.seatbid[0].bid[0]; - } catch (e) { - response = null; - } - if (!response || !bid || (!bid.adm && !bid.nurl) || !bid.price) { - logWarn(`No valid bids from ${spec.code} bidder`); - return []; - } - size = getSize(bidRequest.sizes); - bidResponse = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: bid.price, - creativeId: bid.crid, - width: size.width, - height: size.height, - currency: response.cur, - ttl: (bidRequest.params.video.ttl > 0 && bidRequest.params.video.ttl <= 3600) ? bidRequest.params.video.ttl : 300, - netRevenue: true, - adUnitCode: bidRequest.adUnitCode, - meta: { - advertiserDomains: bid.adomain - } - }; - - bidResponse.mediaType = (bidRequest.mediaTypes.banner) ? 'banner' : 'video' - - if (bid.nurl) { - bidResponse.vastUrl = bid.nurl; - } else if (bid.adm && bidRequest.params.video.display === 1) { - bidResponse.ad = bid.adm - } else if (bid.adm) { - bidResponse.vastXml = bid.adm; - } - if (bidRequest.mediaTypes.video) { - bidResponse.renderer = (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined; - } - - return bidResponse; - }, - /** - * Register the user sync pixels which should be dropped after the auction. - * - * @param {SyncOptions} syncOptions Which user syncs are allowed? - * @param {ServerResponse[]} serverResponses List of server's responses. - * @return {UserSync[]} The user syncs which should be dropped. - */ - getUserSyncs: function(syncOptions, responses, consentData = {}) { - let { - gdprApplies, - consentString = '' - } = consentData; - - if (syncOptions.pixelEnabled) { - return [{ - type: 'image', - url: spec.SYNC_ENDPOINT1 - }, - { - type: 'image', - url: `https://sync-tm.everesttech.net/upi/pid/m7y5t93k?gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&redir=https%3A%2F%2Fpixel.advertising.com%2Fups%2F55986%2Fsync%3Fuid%3D%24%7BUSER_ID%7D%26_origin%3D0` + encodeURI(`&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}`) - }, - { - type: 'image', - url: spec.SYNC_ENDPOINT2 - }]; - } - } -}; - -function getSize(sizes) { - let parsedSizes = parseSizesInput(sizes); - let [ width, height ] = parsedSizes.length ? parsedSizes[0].split('x') : []; - return { - width: parseInt(width, 10) || undefined, - height: parseInt(height, 10) || undefined - }; -} - -function isConsentRequired(consentData) { - return !!(consentData && consentData.gdprApplies); -} - -function getRequestData(bid, consentData, bidRequest) { - let loc = bidRequest.refererInfo.referer; - let page = (bid.params.site && bid.params.site.page) ? (bid.params.site.page) : (loc.href); - let ref = (bid.params.site && bid.params.site.referrer) ? bid.params.site.referrer : bidRequest.refererInfo.referer; - let getFloorRequestObject = { - currency: bid.params.cur || 'USD', - mediaType: 'video', - size: '*' - }; - let bidData = { - id: generateUUID(), - at: 2, - imp: [{ - id: '1', - secure: isSecure(), - ext: { - hb: 1, - prebidver: '$prebid.version$', - adapterver: spec.VERSION, - } - }], - site: { - page: page, - ref: ref - }, - device: { - ua: navigator.userAgent - }, - tmax: 200 - }; - - if (bid.params.video.display == undefined || bid.params.video.display != 1) { - bidData.imp[0].video = { - linearity: 1 - }; - if (bid.params.video.playerWidth && bid.params.video.playerHeight) { - bidData.imp[0].video.w = bid.params.video.playerWidth; - bidData.imp[0].video.h = bid.params.video.playerHeight; - } else { - const playerSize = getSize(bid.mediaTypes.video.playerSize); - bidData.imp[0].video.w = playerSize.width; - bidData.imp[0].video.h = playerSize.height; - }; - if (bid.params.video.mimes) { - bidData.imp[0].video.mimes = bid.params.video.mimes; - } else { - bidData.imp[0].video.mimes = bid.mediaTypes.video.mimes; - }; - if (bid.mediaTypes.video.maxbitrate || bid.params.video.maxbitrate) { - bidData.imp[0].video.maxbitrate = bid.params.video.maxbitrate || bid.mediaTypes.video.maxbitrate; - } - if (bid.mediaTypes.video.maxduration || bid.params.video.maxduration) { - bidData.imp[0].video.maxduration = bid.params.video.maxduration || bid.mediaTypes.video.maxduration; - } - if (bid.mediaTypes.video.minduration || bid.params.video.minduration) { - bidData.imp[0].video.minduration = bid.params.video.minduration || bid.mediaTypes.video.minduration; - } - if (bid.mediaTypes.video.api || bid.params.video.api) { - bidData.imp[0].video.api = bid.params.video.api || bid.mediaTypes.video.api; - } - if (bid.mediaTypes.video.delivery || bid.params.video.delivery) { - bidData.imp[0].video.delivery = bid.params.video.delivery || bid.mediaTypes.video.delivery; - } - if (bid.mediaTypes.video.position || bid.params.video.position) { - bidData.imp[0].video.pos = bid.params.video.position || bid.mediaTypes.video.position; - } - if (bid.mediaTypes.video.playbackmethod || bid.params.video.playbackmethod) { - bidData.imp[0].video.playbackmethod = bid.params.video.playbackmethod || bid.mediaTypes.video.playbackmethod; - } - if (bid.mediaTypes.video.placement || bid.params.video.placement) { - bidData.imp[0].video.placement = bid.params.video.placement || bid.mediaTypes.video.placement; - } - if (bid.params.video.rewarded) { - bidData.imp[0].ext.rewarded = bid.params.video.rewarded - } - if (bid.mediaTypes.video.linearity || bid.params.video.linearity) { - bidData.imp[0].video.linearity = bid.params.video.linearity || bid.mediaTypes.video.linearity || 1; - } - if (bid.mediaTypes.video.protocols || bid.params.video.protocols) { - bidData.imp[0].video.protocols = bid.params.video.protocols || bid.mediaTypes.video.protocols || [2, 5]; - } - } else if (bid.params.video.display == 1) { - getFloorRequestObject.mediaType = 'banner'; - bidData.imp[0].banner = { - mimes: bid.params.video.mimes, - w: bid.params.video.playerWidth, - h: bid.params.video.playerHeight, - pos: bid.params.video.position, - }; - if (bid.params.video.placement) { - bidData.imp[0].banner.placement = bid.params.video.placement - } - if (bid.params.video.maxduration) { - bidData.imp[0].banner.ext = bidData.imp[0].banner.ext || {} - bidData.imp[0].banner.ext.maxduration = bid.params.video.maxduration - } - if (bid.params.video.minduration) { - bidData.imp[0].banner.ext = bidData.imp[0].banner.ext || {} - bidData.imp[0].banner.ext.minduration = bid.params.video.minduration - } - } - - if (isFn(bid.getFloor)) { - let floorData = bid.getFloor(getFloorRequestObject); - bidData.imp[0].bidfloor = floorData.floor; - bidData.cur = floorData.currency; - } else { - bidData.imp[0].bidfloor = bid.params.bidfloor; - }; - - if (bid.params.video.inventoryid) { - bidData.imp[0].ext.inventoryid = bid.params.video.inventoryid - } - if (bid.params.video.sid) { - bidData.source = { - ext: { - schain: { - complete: 1, - nodes: [{ - sid: bid.params.video.sid, - rid: bidData.id, - }] - } - } - } - if (bid.params.video.hp == 1) { - bidData.source.ext.schain.nodes[0].hp = bid.params.video.hp; - } - } else if (bid.schain) { - bidData.source = { - ext: { - schain: bid.schain - } - } - bidData.source.ext.schain.nodes[0].rid = bidData.id; - } - if (bid.params.site && bid.params.site.id) { - bidData.site.id = bid.params.site.id - } - if (isConsentRequired(consentData) || (bidRequest && bidRequest.uspConsent)) { - bidData.regs = { - ext: {} - }; - if (isConsentRequired(consentData)) { - bidData.regs.ext.gdpr = 1 - } - - if (consentData && consentData.consentString) { - bidData.user = { - ext: { - consent: consentData.consentString - } - }; - } - // ccpa support - if (bidRequest && bidRequest.uspConsent) { - bidData.regs.ext.us_privacy = bidRequest.uspConsent - } - } - if (bid.params.video.e2etest) { - logMessage('E2E test mode enabled: \n The following parameters are being overridden by e2etest mode:\n* bidfloor:null\n* width:300\n* height:250\n* mimes: video/mp4, application/javascript\n* api:2\n* site.page/ref: verizonmedia.com\n* tmax:1000'); - bidData.imp[0].bidfloor = null; - bidData.imp[0].video.w = 300; - bidData.imp[0].video.h = 250; - bidData.imp[0].video.mimes = ['video/mp4', 'application/javascript']; - bidData.imp[0].video.api = [2]; - bidData.site.page = 'https://verizonmedia.com'; - bidData.site.ref = 'https://verizonmedia.com'; - bidData.tmax = 1000; - } - if (bid.params.video.custom && isPlainObject(bid.params.video.custom)) { - bidData.imp[0].ext.custom = {}; - for (const key in bid.params.video.custom) { - if (isStr(bid.params.video.custom[key]) || isNumber(bid.params.video.custom[key])) { - bidData.imp[0].ext.custom[key] = bid.params.video.custom[key]; - } - } - } - if (bid.params.video.content && isPlainObject(bid.params.video.content)) { - bidData.site.content = {}; - const contentStringKeys = ['id', 'title', 'series', 'season', 'genre', 'contentrating', 'language']; - const contentNumberkeys = ['episode', 'prodq', 'context', 'livestream', 'len']; - const contentArrayKeys = ['cat']; - const contentObjectKeys = ['ext']; - for (const contentKey in bid.params.video.content) { - if ( - (contentStringKeys.indexOf(contentKey) > -1 && isStr(bid.params.video.content[contentKey])) || - (contentNumberkeys.indexOf(contentKey) > -1 && isNumber(bid.params.video.content[contentKey])) || - (contentObjectKeys.indexOf(contentKey) > -1 && isPlainObject(bid.params.video.content[contentKey])) || - (contentArrayKeys.indexOf(contentKey) > -1 && isArray(bid.params.video.content[contentKey]) && - bid.params.video.content[contentKey].every(catStr => isStr(catStr)))) { - bidData.site.content[contentKey] = bid.params.video.content[contentKey]; - } else { - logMessage('oneVideo bid adapter validation error: ', contentKey, ' is either not supported is OpenRTB V2.5 or value is undefined'); - } - } - } - return bidData; -} - -function isSecure() { - return document.location.protocol === 'https:'; -} -/** - * Create oneVideo renderer - * @returns {*} - */ -function newRenderer(bidRequest, bid) { - if (!bidRequest.renderer) { - bidRequest.renderer = {}; - bidRequest.renderer.url = 'https://cdn.vidible.tv/prod/hb-outstream-renderer/renderer.js'; - bidRequest.renderer.render = function(bid) { - setTimeout(function() { - // eslint-disable-next-line no-undef - o2PlayerRender(bid); - }, 700) - }; - } -} - -registerBidder(spec); diff --git a/modules/oneVideoBidAdapter.md b/modules/oneVideoBidAdapter.md deleted file mode 100644 index 149a4b20e2f..00000000000 --- a/modules/oneVideoBidAdapter.md +++ /dev/null @@ -1,442 +0,0 @@ -# Overview - -**Module Name**: One Video Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: deepthi.neeladri.sravana@verizonmedia.com - adam.browning@verizonmedia.com - -# Description -Connects to Verizon Media's Video SSP (AKA ONE Video / Adap.tv) demand source to fetch bids. -# Prebid.js V5.0 Support -The oneVideo adapter now reads `mediaTypes.video` for mandatory parameters such as `playerSize` & `mimes`. -Note: You can use the `bid.params.video` object to specify explicit overrides for whatever is declared in `mediaTypes.video`. -Important: You must pass `bid.params.video = {}` as bare minimum for the adapter to work. -# Integration Examples: - -## Instream Video adUnit using mediaTypes.video -*Note:* By default, the adapter will read the mandatory parameters from mediaTypes.video. -*Note:* The Video SSP ad server will respond with an VAST XML to load into your defined player. -``` - var adUnits = [ - { - code: 'video1', - mediaTypes: { - video: { - context: 'instream', - playerSize: [480, 640], - mimes: ['video/mp4', 'application/javascript'], - protocols: [2,5], - api: [2], - position: 1, - delivery: [2], - minduration: 10, - maxduration: 30, - placement: 1, - playbackmethod: [1,5], - protocols: [2,5], - api: [2], - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - sid: YOUR_VSSP_ORG_ID, - hp: 1, - rewarded: 1, - inventoryid: 123, - ttl: 300, - custom: { - key1: "value1", - key2: 123345 - } - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchange' - } - } - ] - } - ] -``` -## Instream Video adUnit using params.video overrides -*Note:* If the mandatory parameters are not specified in mediaTypes.video the adapter will read check to see if overrides are set in params.video. Decalring values using params.video will always override the settings in mediaTypes.video. -*Note:* The Video SSP ad server will respond with an VAST XML to load into your defined player. -``` - var adUnits = [ - { - code: 'video1', - mediaTypes: { - video: { - context: 'instream', - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'], - protocols: [2,5], - api: [2], - position: 1, - delivery: [2], - minduration: 10, - maxduration: 30, - placement: 1, - playbackmethod: [1,5], - protocols: [2,5], - api: [2], - sid: YOUR_VSSP_ORG_ID, - hp: 1, - rewarded: 1, - inventoryid: 123, - ttl: 300, - custom: { - key1: "value1", - key2: 123345 - } - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchange' - } - } - ] - } - ] -``` -## Outstream Video adUnit example & parameters -*Note:* The Video SSP ad server will load it's own Outstream Renderer (player) as a fallback if no player is defined on the publisher page. The Outstream player will inject into the div id that has an identical adUnit code. -``` - var adUnits = [ - { - code: 'video1', - mediaTypes: { - video: { - context: 'outstream', - playerSize: [480, 640], - mimes: ['video/mp4', 'application/javascript'], - protocols: [2,5], - api: [2], - position: 1, - delivery: [2], - minduration: 10, - maxduration: 30, - placement: 1, - playbackmethod: [1,5], - protocols: [2,5], - api: [2], - - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - sid: YOUR_VSSP_ORG_ID, - hp: 1, - rewarded: 1, - ttl: 250 - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchange' - } - } - ] - } - ] -``` - -## S2S / Video: Dynamic Ad Placement (DAP) adUnit example & parameters -*Note:* The Video SSP ad server will respond with HTML embed tag to be injected into an iFrame you create. -``` - var adUnits = [ - { - code: 'video1', - mediaTypes: { - video: { - context: "instream", - playerSize: [480, 640], - mimes: ['video/mp4', 'application/javascript'], - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - ttl: 250 - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchangeDAP' - } - } - ] - } -] -``` -## Prebid.js / Banner: Dynamic Ad Placement (DAP) adUnit example & parameters -*Note:* The Video SSP ad server will respond with HTML embed tag to be injected into an iFrame created by Google Ad Manager (GAM). -``` - var adUnits = [ - { - code: 'banner-1', - mediaTypes: { - banner: { - sizes: [300, 250] - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - playerWidth: 300, - playerHeight: 250, - mimes: ['video/mp4', 'application/javascript'], - display: 1 - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchangeDAP' - } - } - ] - } -] -``` - -# End 2 End Testing Mode -By passing bid.params.video.e2etest = true you will be able to receive a test creative when connecting via VPN location U.S West Coast. This will allow you to trubleshoot how your player/ad-server parses and uses the VAST XML response. -This automatically sets default values for the outbound bid-request to respond from our test exchange. -No need to override the site/ref urls or change your pubId -``` -var adUnits = [ - { - code: 'video-1', - mediaTypes: { - video: { - context: "instream", - playerSize: [480, 640] - mimes: ['video/mp4', 'application/javascript'], - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - e2etest: true - } - } - } - ] - } -] -``` - -# Supply Chain Object Support -The oneVideoBidAdapter supports 2 methods for passing/creating an schain object. -1. By passing your Video SSP Org ID in the bid.video.params.sid - The adapter will create a new schain object and our ad-server will fill in the data for you. -2. Using the Prebid Supply Chain Object Module - The adapter will capture the schain object -*Note:* You cannot pass both schain object and bid.video.params.sid together. Option 1 will always be the default. - -## Create new schain using bid.video.params.sid -sid = your Video SSP Organization ID. -This is for direct publishers only. -``` -var adUnits = [ - { - code: 'video1', - mediaTypes: { - video: { - context: 'instream', - playerSize: [480, 640], - mimes: ['video/mp4', 'application/javascript'], - protocols: [2,5], - api: [2], - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - sid: 123456 - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchange' - } - } - ] - } - ] -``` - -## Pass global schain using pbjs.setConfig(SCHAIN_OBJECT) -For both Authorized resellers and direct publishers. -``` -pbjs.setConfig({ - "schain": { - "validation": "strict", - "config": { - "ver": "1.0", - "complete": 1, - "nodes": [{ - "asi": "some-platform.com", - "sid": "111111", - "hp": 1 - }] - } - } -}); - -var adUnits = [ - { - code: 'video1', - mediaTypes: { - video: { - context: 'instream', - playerSize: [480, 640], - mimes: ['video/mp4', 'application/javascript'], - protocols: [2,5], - api: [2], - } - }, - bids: [ - { - bidder: 'oneVideo', - params: { - video: { - ttl: 250 - }, - bidfloor: 0.5, - site: { - id: 1, - page: 'https://verizonmedia.com', - referrer: 'https://verizonmedia.com' - }, - pubId: 'HBExchange' - } - } - ] - } - ] -``` -# Content Object Support -The oneVideoBidAdapter supports passing of OpenRTB V2.5 Content Object. - -``` -const adUnits = [{ - code: 'video1', - mediaTypes: { - video: { - context: 'outstream', - playerSize: [640, 480], - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [1, 2], - } - }, - bids: [{ - bidder: 'oneVideo', - params: { - video: { - ttl: 300, - content: { - id: "1234", - title: "Title", - series: "Series", - season: "Season", - episode: 1 - cat: [ - "IAB1", - "IAB1-1", - "IAB1-2", - "IAB2", - "IAB2-1" - ], - genre: "Genre", - contentrating: "C-Rating", - language: "EN", - prodq: 1, - context: 1, - livestream: 0, - len: 360, - ext: { - network: "ext-network", - channel: "ext-channel" - } - } - }, - bidfloor: 0.5, - pubId: 'HBExchange' - } - } - }] - }] -``` - - -# TTL Support -The oneVideoBidAdapter supports passing of "Time To Live" (ttl) that indicates to prebid chache for how long to keep the chaced winning bid alive. -Value is Number in seconds -You can enter any number between 1 - 3600 (seconds) -``` -const adUnits = [{ - code: 'video1', - mediaTypes: { - video: { - context: 'outstream', - playerSize: [640, 480], - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [1, 2], - } - }, - bids: [{ - bidder: 'oneVideo', - params: { - video: { - ttl: 300 - }, - bidfloor: 0.5, - pubId: 'HBExchange' - } - }] - }] -``` - diff --git a/modules/oneplanetonlyBidAdapter.md b/modules/oneplanetonlyBidAdapter.md deleted file mode 100644 index 973adb33efd..00000000000 --- a/modules/oneplanetonlyBidAdapter.md +++ /dev/null @@ -1,50 +0,0 @@ -# Overview - -``` -Module Name: OnePlanetOnly Bidder Adapter -Module Type: Bidder Adapter -Maintainer: vitaly@oneplanetonly.com -``` - -# Description - -Module that connects to OnePlanetOnly's demand sources - -# Test Parameters -``` - var adUnits = [ - { - code: 'desktop-banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]], - } - }, - bids: [ - { - bidder: 'oneplanetonly', - params: { - siteId: '5', - adUnitId: '5-4587544' - } - } - ] - },{ - code: 'mobile-banner-ad-div', - mediaTypes: { - banner: { - sizes: [[320, 50], [320, 100]], - } - }, - bids: [ - { - bidder: "oneplanetonly", - params: { - siteId: '5', - adUnitId: '5-81037880' - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/onetagBidAdapter.js b/modules/onetagBidAdapter.js index 89c614dba23..801bb747e34 100644 --- a/modules/onetagBidAdapter.js +++ b/modules/onetagBidAdapter.js @@ -1,20 +1,19 @@ 'use strict'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {INSTREAM, OUTSTREAM} from '../src/video.js'; -import {Renderer} from '../src/Renderer.js'; -import {find} from '../src/polyfill.js'; -import {getStorageManager} from '../src/storageManager.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {createEidsArray} from './userId/eids.js'; -import {deepClone} from '../src/utils.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { INSTREAM, OUTSTREAM } from '../src/video.js'; +import { Renderer } from '../src/Renderer.js'; +import { find } from '../src/polyfill.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { deepClone, logError, deepAccess } from '../src/utils.js'; const ENDPOINT = 'https://onetag-sys.com/prebid-request'; const USER_SYNC_ENDPOINT = 'https://onetag-sys.com/usync/'; const BIDDER_CODE = 'onetag'; const GVLID = 241; -const storage = getStorageManager({gvlid: GVLID, bidderCode: BIDDER_CODE}); +const storage = getStorageManager({ bidderCode: BIDDER_CODE }); /** * Determines whether or not the given bid request is valid. @@ -54,7 +53,7 @@ export function isValid(type, bid) { function buildRequests(validBidRequests, bidderRequest) { const payload = { bids: requestsToBids(validBidRequests), - ...getPageInfo() + ...getPageInfo(bidderRequest) }; if (bidderRequest && bidderRequest.gdprConsent) { payload.gdprConsent = { @@ -62,17 +61,32 @@ function buildRequests(validBidRequests, bidderRequest) { consentRequired: bidderRequest.gdprConsent.gdprApplies }; } + if (bidderRequest && bidderRequest.gppConsent) { + payload.gppConsent = { + consentString: bidderRequest.gppConsent.gppString, + applicableSections: bidderRequest.gppConsent.applicableSections + } + } if (bidderRequest && bidderRequest.uspConsent) { payload.usPrivacy = bidderRequest.uspConsent; } - if (validBidRequests && validBidRequests.length !== 0 && validBidRequests[0].userId) { - payload.userId = createEidsArray(validBidRequests[0].userId); + if (bidderRequest && bidderRequest.ortb2) { + payload.ortb2 = bidderRequest.ortb2; + } + if (validBidRequests && validBidRequests.length !== 0 && validBidRequests[0].userIdAsEids) { + payload.userId = validBidRequests[0].userIdAsEids; + } + if (validBidRequests && validBidRequests.length !== 0 && validBidRequests[0].schain && isSchainValid(validBidRequests[0].schain)) { + payload.schain = validBidRequests[0].schain; } try { if (storage.hasLocalStorage()) { payload.onetagSid = storage.getDataFromLocalStorage('onetag_sid'); } - } catch (e) {} + } catch (e) { } + const connection = navigator.connection || navigator.webkitConnection; + payload.networkConnectionType = (connection && connection.type) ? connection.type : null; + payload.networkEffectiveConnectionType = (connection && connection.effectiveType) ? connection.effectiveType : null; return { method: 'POST', url: ENDPOINT, @@ -110,7 +124,7 @@ function interpretResponse(serverResponse, bidderRequest) { if (bid.mediaType === BANNER) { responseBid.ad = bid.ad; } else if (bid.mediaType === VIDEO) { - const {context, adUnitCode} = find(requestData.bids, (item) => + const { context, adUnitCode } = find(requestData.bids, (item) => item.bidId === bid.requestId && item.type === VIDEO ); @@ -139,7 +153,7 @@ function createRenderer(bid, rendererOptions = {}) { loaded: false }); try { - renderer.setRender(({renderer, width, height, vastXml, adUnitCode}) => { + renderer.setRender(({ renderer, width, height, vastXml, adUnitCode }) => { renderer.push(() => { window.onetag.Player.init({ ...bid, @@ -160,7 +174,6 @@ function createRenderer(bid, rendererOptions = {}) { function getFrameNesting() { let topmostFrame = window; let parent = window.parent; - let currentFrameNesting = 0; try { while (topmostFrame !== topmostFrame.parent) { parent = topmostFrame.parent; @@ -168,13 +181,8 @@ function getFrameNesting() { parent.location.href; topmostFrame = topmostFrame.parent; } - } catch (e) { - currentFrameNesting = parent === topmostFrame.top ? 1 : 2; - } - return { - topmostFrame, - currentFrameNesting - } + } catch (e) { } + return topmostFrame; } function getDocumentVisibility(window) { @@ -195,21 +203,15 @@ function getDocumentVisibility(window) { /** * Returns information about the page needed by the server in an object to be converted in JSON - * @returns {{location: *, referrer: (*|string), masked: *, wWidth: (*|Number), wHeight: (*|Number), sWidth, sHeight, date: string, timeOffset: number}} + * @returns {{location: *, referrer: (*|string), stack: (*|Array.), numIframes: (*|Number), wWidth: (*|Number), wHeight: (*|Number), sWidth, sHeight, date: string, timeOffset: number}} */ -function getPageInfo() { - const { topmostFrame, currentFrameNesting } = getFrameNesting(); +function getPageInfo(bidderRequest) { + const topmostFrame = getFrameNesting(); return { - location: topmostFrame.location.href, - referrer: - topmostFrame.document.referrer !== '' - ? topmostFrame.document.referrer - : null, - ancestorOrigin: - window.location.ancestorOrigins && window.location.ancestorOrigins.length > 0 - ? window.location.ancestorOrigins[window.location.ancestorOrigins.length - 1] - : null, - masked: currentFrameNesting, + location: deepAccess(bidderRequest, 'refererInfo.page', null), + referrer: deepAccess(bidderRequest, 'refererInfo.ref', null), + stack: deepAccess(bidderRequest, 'refererInfo.stack', []), + numIframes: deepAccess(bidderRequest, 'refererInfo.numIframes', 0), wWidth: topmostFrame.innerWidth, wHeight: topmostFrame.innerHeight, oWidth: topmostFrame.outerWidth, @@ -228,7 +230,7 @@ function getPageInfo() { timing: getTiming(), version: { prebid: '$prebid.version$', - adapter: '1.1.0' + adapter: '1.1.1' } }; } @@ -245,6 +247,7 @@ function requestsToBids(bidRequests) { // Other params videoObj['mediaTypeInfo'] = deepClone(bidRequest.mediaTypes.video); videoObj['type'] = VIDEO; + videoObj['priceFloors'] = getBidFloor(bidRequest, VIDEO, videoObj['playerSize']); return videoObj; }); const bannerBidRequests = bidRequests.filter(bidRequest => isValid(BANNER, bidRequest)).map(bidRequest => { @@ -253,6 +256,7 @@ function requestsToBids(bidRequests) { bannerObj['sizes'] = parseSizes(bidRequest); bannerObj['type'] = BANNER; bannerObj['mediaTypeInfo'] = deepClone(bidRequest.mediaTypes.banner); + bannerObj['priceFloors'] = getBidFloor(bidRequest, BANNER, bannerObj['sizes']); return bannerObj; }); return videoBidRequests.concat(bannerBidRequests); @@ -263,8 +267,10 @@ function setGeneralInfo(bidRequest) { this['adUnitCode'] = bidRequest.adUnitCode; this['bidId'] = bidRequest.bidId; this['bidderRequestId'] = bidRequest.bidderRequestId; + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 this['auctionId'] = bidRequest.auctionId; - this['transactionId'] = bidRequest.transactionId; + this['transactionId'] = bidRequest.ortb2Imp?.ext?.tid; + this['gpid'] = deepAccess(bidRequest, 'ortb2Imp.ext.gpid') || deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot'); this['pubId'] = params.pubId; this['ext'] = params.ext; if (params.pubClick) { @@ -339,12 +345,12 @@ function getSizes(sizes) { const ret = []; for (let i = 0; i < sizes.length; i++) { const size = sizes[i]; - ret.push({width: size[0], height: size[1]}) + ret.push({ width: size[0], height: size[1] }) } return ret; } -function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { +function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { let syncs = []; let params = ''; if (gdprConsent) { @@ -355,6 +361,11 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { params += '&gdpr_consent=' + gdprConsent.consentString; } } + if (gppConsent) { + if (typeof gppConsent.gppString === 'string') { + params += '&gpp_consent=' + gppConsent.gppString; + } + } if (uspConsent && typeof uspConsent === 'string') { params += '&us_privacy=' + uspConsent; } @@ -373,6 +384,37 @@ function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { return syncs; } +function getBidFloor(bidRequest, mediaType, sizes) { + const priceFloors = []; + if (typeof bidRequest.getFloor === 'function') { + sizes.forEach(size => { + const floor = bidRequest.getFloor({ + currency: 'EUR', + mediaType: mediaType || '*', + size: [size.width, size.height] + }); + floor.size = deepClone(size); + if (!floor.floor) { floor.floor = null; } + priceFloors.push(floor); + }); + } + return priceFloors; +} + +export function isSchainValid(schain) { + let isValid = false; + const requiredFields = ['asi', 'sid', 'hp']; + if (!schain || !schain.nodes) return isValid; + isValid = schain.nodes.reduce((status, node) => { + if (!status) return status; + return requiredFields.every(field => node.hasOwnProperty(field)); + }, true); + if (!isValid) { + logError('OneTag: required schain params missing'); + } + return isValid; +} + export const spec = { code: BIDDER_CODE, gvlid: GVLID, diff --git a/modules/onomagicBidAdapter.js b/modules/onomagicBidAdapter.js index 25b0f1a5934..78f00153a8b 100644 --- a/modules/onomagicBidAdapter.js +++ b/modules/onomagicBidAdapter.js @@ -1,7 +1,17 @@ -import { getBidIdParameter, _each, isArray, getWindowTop, getUniqueIdentifierStr, parseUrl, logError, logWarn, createTrackPixelHtml, getWindowSelf, isFn, isPlainObject } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { config } from '../src/config.js'; +import { + _each, + createTrackPixelHtml, getBidIdParameter, + getUniqueIdentifierStr, + getWindowSelf, + getWindowTop, + isArray, + isFn, + isPlainObject, + logError, + logWarn +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; const BIDDER_CODE = 'onomagic'; const URL = 'https://bidder.onomagic.com/hb'; @@ -19,7 +29,7 @@ function buildRequests(bidReqs, bidderRequest) { try { let referrer = ''; if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; + referrer = bidderRequest.refererInfo.page; } const onomagicImps = []; const publisherId = getBidIdParameter('publisherId', bidReqs[0].params); @@ -56,7 +66,8 @@ function buildRequests(bidReqs, bidderRequest) { id: getUniqueIdentifierStr(), imp: onomagicImps, site: { - domain: parseUrl(referrer).host, + // TODO: does the fallback make sense here? + domain: bidderRequest?.refererInfo?.domain || window.location.host, page: referrer, publisher: { id: publisherId @@ -67,7 +78,7 @@ function buildRequests(bidReqs, bidderRequest) { w: screen.width, h: screen.height }, - tmax: config.getConfig('bidderTimeout') + tmax: bidderRequest?.timeout }; return { diff --git a/modules/ooloAnalyticsAdapter.js b/modules/ooloAnalyticsAdapter.js index 398459d604d..9bc140f0536 100644 --- a/modules/ooloAnalyticsAdapter.js +++ b/modules/ooloAnalyticsAdapter.js @@ -1,5 +1,6 @@ -import { _each, deepClone, pick, deepSetValue, getOrigin, logError, logInfo } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js' +import { _each, deepClone, pick, deepSetValue, logError, logInfo } from '../src/utils.js'; +import { getOrigin } from '../libraries/getOrigin/index.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js' import adapterManager from '../src/adapterManager.js' import CONSTANTS from '../src/constants.json' import { ajax } from '../src/ajax.js' diff --git a/modules/open8BidAdapter.js b/modules/open8BidAdapter.js index 7fa97235525..49523926c0e 100644 --- a/modules/open8BidAdapter.js +++ b/modules/open8BidAdapter.js @@ -1,8 +1,9 @@ import { Renderer } from '../src/Renderer.js'; import {ajax} from '../src/ajax.js'; -import { createTrackPixelHtml, getBidIdParameter, logError, logWarn, tryAppendQueryString } from '../src/utils.js'; +import {createTrackPixelHtml, getBidIdParameter, logError, logWarn} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; const BIDDER_CODE = 'open8'; const URL = 'https://as.vt.open8.com/v1/control/prebid'; @@ -68,7 +69,7 @@ export const spec = { meta: { advertiserDomains: ad.adomain || [] } - } + }; if (ad.adType === AD_TYPE.VIDEO) { const videoAd = bidderResponse.ad.video; diff --git a/modules/openwebBidAdapter.js b/modules/openwebBidAdapter.js index f515eb14011..547447039da 100644 --- a/modules/openwebBidAdapter.js +++ b/modules/openwebBidAdapter.js @@ -1,8 +1,9 @@ -import {convertTypes, deepAccess, flatten, isArray, isNumber, parseSizesInput} from '../src/utils.js'; +import {deepAccess, flatten, isArray, isNumber, parseSizesInput} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {ADPOD, BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {find} from '../src/polyfill.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; const ENDPOINT = 'https://ghb.spotim.market/v2/auction'; const BIDDER_CODE = 'openweb'; @@ -126,7 +127,8 @@ function parseRTBResponse(serverResponse, adapterRequest) { function bidToTag(bidRequests, adapterRequest) { // start publisher env const tag = { - Domain: deepAccess(adapterRequest, 'refererInfo.referer') + // TODO: is 'page' the right value here? + Domain: deepAccess(adapterRequest, 'refererInfo.page') }; if (config.getConfig('coppa') === true) { tag.Coppa = 1; @@ -148,7 +150,7 @@ function bidToTag(bidRequests, adapterRequest) { tag.UserEids = deepAccess(bidRequests[0], 'userIdAsEids'); } // end publisher env - const bids = [] + const bids = []; for (let i = 0, length = bidRequests.length; i < length; i++) { const bid = prepareBidRequests(bidRequests[i]); diff --git a/modules/openxAnalyticsAdapter.js b/modules/openxAnalyticsAdapter.js deleted file mode 100644 index 89140c0aacd..00000000000 --- a/modules/openxAnalyticsAdapter.js +++ /dev/null @@ -1,766 +0,0 @@ -import { - _each, - _map, - deepAccess, - flatten, - getWindowLocation, - isEmpty, - logError, - logInfo, - logMessage, - logWarn, - parseQS, - parseSizesInput, - uniques -} from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; -import CONSTANTS from '../src/constants.json'; -import adapterManager from '../src/adapterManager.js'; -import {ajax} from '../src/ajax.js'; -import {find, includes} from '../src/polyfill.js'; - -export const AUCTION_STATES = { - INIT: 'initialized', // auction has initialized - ENDED: 'ended', // all auction requests have been accounted for - COMPLETED: 'completed' // all slots have rendered -}; - -const ADAPTER_VERSION = '0.1'; -const SCHEMA_VERSION = '0.1'; - -const AUCTION_END_WAIT_TIME = 1000; -const URL_PARAM = ''; -const ANALYTICS_TYPE = 'endpoint'; -const ENDPOINT = 'https://prebid.openx.net/ox/analytics/'; - -// Event Types -const { - EVENTS: { AUCTION_INIT, BID_REQUESTED, BID_RESPONSE, BID_TIMEOUT, AUCTION_END, BID_WON } -} = CONSTANTS; -const SLOT_LOADED = 'slotOnload'; - -const UTM_TAGS = [ - 'utm_campaign', - 'utm_source', - 'utm_medium', - 'utm_term', - 'utm_content' -]; -const UTM_TO_CAMPAIGN_PROPERTIES = { - 'utm_campaign': 'name', - 'utm_source': 'source', - 'utm_medium': 'medium', - 'utm_term': 'term', - 'utm_content': 'content' -}; - -/** - * @typedef {Object} OxAnalyticsConfig - * @property {string} orgId - * @property {string} publisherPlatformId - * @property {number} publisherAccountId - * @property {string} configId - * @property {string} optimizerConfig - * @property {number} sampling - * @property {Object} campaign - * @property {number} payloadWaitTime - * @property {number} payloadWaitTimePadding - * @property {Array} adUnits - */ - -/** - * @type {OxAnalyticsConfig} - */ -const DEFAULT_ANALYTICS_CONFIG = { - orgId: void (0), - publisherPlatformId: void (0), - publisherAccountId: void (0), - sampling: 0.05, // default sampling rate of 5% - testCode: 'default', - campaign: {}, - adUnits: [], - payloadWaitTime: AUCTION_END_WAIT_TIME, - payloadWaitTimePadding: 2000 -}; - -// Initialization -/** - * @type {OxAnalyticsConfig} - */ -let analyticsConfig; -let auctionMap = {}; -let auctionOrder = 1; // tracks the number of auctions ran on the page - -let googletag = window.googletag || {}; -googletag.cmd = googletag.cmd || []; - -let openxAdapter = Object.assign(adapter({ urlParam: URL_PARAM, analyticsType: ANALYTICS_TYPE })); - -openxAdapter.originEnableAnalytics = openxAdapter.enableAnalytics; - -openxAdapter.enableAnalytics = function(adapterConfig = {options: {}}) { - if (isValidConfig(adapterConfig)) { - analyticsConfig = {...DEFAULT_ANALYTICS_CONFIG, ...adapterConfig.options}; - - // campaign properties defined by config will override utm query parameters - analyticsConfig.campaign = {...buildCampaignFromUtmCodes(), ...analyticsConfig.campaign}; - - logInfo('OpenX Analytics enabled with config', analyticsConfig); - - // override track method with v2 handlers - openxAdapter.track = prebidAnalyticsEventHandler; - - googletag.cmd.push(function () { - let pubads = googletag.pubads(); - - if (pubads.addEventListener) { - pubads.addEventListener(SLOT_LOADED, args => { - openxAdapter.track({eventType: SLOT_LOADED, args}); - logInfo('OX: SlotOnLoad event triggered'); - }); - } - }); - - openxAdapter.originEnableAnalytics(adapterConfig); - } -}; - -adapterManager.registerAnalyticsAdapter({ - adapter: openxAdapter, - code: 'openx' -}); - -export default openxAdapter; - -/** - * Test Helper Functions - */ - -// reset the cache for unit tests -openxAdapter.reset = function() { - auctionMap = {}; - auctionOrder = 1; -}; - -/** - * Private Functions - */ - -function isValidConfig({options: analyticsOptions}) { - let hasOrgId = analyticsOptions && analyticsOptions.orgId !== void (0); - - const fieldValidations = [ - // tuple of property, type, required - ['orgId', 'string', hasOrgId], - ['publisherPlatformId', 'string', !hasOrgId], - ['publisherAccountId', 'number', !hasOrgId], - ['configId', 'string', false], - ['optimizerConfig', 'string', false], - ['sampling', 'number', false], - ['adIdKey', 'string', false], - ['payloadWaitTime', 'number', false], - ['payloadWaitTimePadding', 'number', false], - ]; - - let failedValidation = find(fieldValidations, ([property, type, required]) => { - // if required, the property has to exist - // if property exists, type check value - return (required && !analyticsOptions.hasOwnProperty(property)) || - /* eslint-disable valid-typeof */ - (analyticsOptions.hasOwnProperty(property) && typeof analyticsOptions[property] !== type); - }); - if (failedValidation) { - let [property, type, required] = failedValidation; - - if (required) { - logError(`OpenXAnalyticsAdapter: Expected '${property}' to exist and of type '${type}'`); - } else { - logError(`OpenXAnalyticsAdapter: Expected '${property}' to be type '${type}'`); - } - } - - return !failedValidation; -} - -function buildCampaignFromUtmCodes() { - const location = getWindowLocation(); - const queryParams = parseQS(location && location.search); - let campaign = {}; - - UTM_TAGS.forEach(function(utmKey) { - let utmValue = queryParams[utmKey]; - if (utmValue) { - let key = UTM_TO_CAMPAIGN_PROPERTIES[utmKey]; - campaign[key] = decodeURIComponent(utmValue); - } - }); - return campaign; -} - -function detectMob() { - if ( - navigator.userAgent.match(/Android/i) || - navigator.userAgent.match(/webOS/i) || - navigator.userAgent.match(/iPhone/i) || - navigator.userAgent.match(/iPad/i) || - navigator.userAgent.match(/iPod/i) || - navigator.userAgent.match(/BlackBerry/i) || - navigator.userAgent.match(/Windows Phone/i) - ) { - return true; - } else { - return false; - } -} - -function detectOS() { - if (navigator.userAgent.indexOf('Android') != -1) return 'Android'; - if (navigator.userAgent.indexOf('like Mac') != -1) return 'iOS'; - if (navigator.userAgent.indexOf('Win') != -1) return 'Windows'; - if (navigator.userAgent.indexOf('Mac') != -1) return 'Macintosh'; - if (navigator.userAgent.indexOf('Linux') != -1) return 'Linux'; - if (navigator.appVersion.indexOf('X11') != -1) return 'Unix'; - return 'Others'; -} - -function detectBrowser() { - var isChrome = - /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); - var isCriOS = navigator.userAgent.match('CriOS'); - var isSafari = - /Safari/.test(navigator.userAgent) && - /Apple Computer/.test(navigator.vendor); - var isFirefox = /Firefox/.test(navigator.userAgent); - var isIE = - /Trident/.test(navigator.userAgent) || /MSIE/.test(navigator.userAgent); - var isEdge = /Edge/.test(navigator.userAgent); - if (isIE) return 'Internet Explorer'; - if (isEdge) return 'Microsoft Edge'; - if (isCriOS) return 'Chrome'; - if (isSafari) return 'Safari'; - if (isFirefox) return 'Firefox'; - if (isChrome) return 'Chrome'; - return 'Others'; -} - -function prebidAnalyticsEventHandler({eventType, args}) { - logMessage(eventType, Object.assign({}, args)); - switch (eventType) { - case AUCTION_INIT: - onAuctionInit(args); - break; - case BID_REQUESTED: - onBidRequested(args); - break; - case BID_RESPONSE: - onBidResponse(args); - break; - case BID_TIMEOUT: - onBidTimeout(args); - break; - case AUCTION_END: - onAuctionEnd(args); - break; - case BID_WON: - onBidWon(args); - break; - case SLOT_LOADED: - onSlotLoadedV2(args); - break; - } -} - -/** - * @typedef {Object} PbAuction - * @property {string} auctionId - Auction ID of the request this bid responded to - * @property {number} timestamp //: 1586675964364 - * @property {number} auctionEnd - timestamp of when auction ended //: 1586675964364 - * @property {string} auctionStatus //: "inProgress" - * @property {Array} adUnits //: [{…}] - * @property {string} adUnitCodes //: ["video1"] - * @property {string} labels //: undefined - * @property {Array} bidderRequests //: (2) [{…}, {…}] - * @property {Array} noBids //: [] - * @property {Array} bidsReceived //: [] - * @property {Array} winningBids //: [] - * @property {number} timeout //: 3000 - * @property {Object} config //: {publisherPlatformId: "a3aece0c-9e80-4316-8deb-faf804779bd1", publisherAccountId: 537143056, sampling: 1}/* - */ - -function onAuctionInit({auctionId, timestamp: startTime, timeout, adUnitCodes}) { - auctionMap[auctionId] = { - id: auctionId, - startTime, - endTime: void (0), - timeout, - auctionOrder, - userIds: [], - adUnitCodesCount: adUnitCodes.length, - adunitCodesRenderedCount: 0, - state: AUCTION_STATES.INIT, - auctionSendDelayTimer: void (0), - }; - - // setup adunit properties in map - auctionMap[auctionId].adUnitCodeToAdUnitMap = adUnitCodes.reduce((obj, adunitCode) => { - obj[adunitCode] = { - code: adunitCode, - adPosition: void (0), - bidRequestsMap: {} - }; - return obj; - }, {}); - - auctionOrder++; -} - -/** - * @typedef {Object} PbBidRequest - * @property {string} auctionId - Auction ID of the request this bid responded to - * @property {number} auctionStart //: 1586675964364 - * @property {Object} refererInfo - * @property {PbBidderRequest} bids - * @property {number} start - Start timestamp of the bidder request - * - */ - -/** - * @typedef {Object} PbBidderRequest - * @property {string} adUnitCode - Name of div or google adunit path - * @property {string} bidder - Bame of bidder - * @property {string} bidId - Identifies the bid request - * @property {Object} mediaTypes - * @property {Object} params - * @property {string} src - * @property {Object} userId - Map of userId module to module object - */ - -/** - * Tracks the bid request - * @param {PbBidRequest} bidRequest - */ -function onBidRequested(bidRequest) { - const {auctionId, bids: bidderRequests, start, timeout} = bidRequest; - const auction = auctionMap[auctionId]; - const adUnitCodeToAdUnitMap = auction.adUnitCodeToAdUnitMap; - - bidderRequests.forEach(bidderRequest => { - const { adUnitCode, bidder, bidId: requestId, mediaTypes, params, src, userId } = bidderRequest; - - auction.userIds.push(userId); - adUnitCodeToAdUnitMap[adUnitCode].bidRequestsMap[requestId] = { - bidder, - params, - mediaTypes, - source: src, - startTime: start, - timedOut: false, - timeLimit: timeout, - bids: {} - }; - }); -} - -/** - * - * @param {BidResponse} bidResponse - */ -function onBidResponse(bidResponse) { - let { - auctionId, - adUnitCode, - requestId, - cpm, - creativeId, - requestTimestamp, - responseTimestamp, - ts, - mediaType, - dealId, - ttl, - netRevenue, - currency, - originalCpm, - originalCurrency, - width, - height, - timeToRespond: latency, - adId, - meta - } = bidResponse; - - auctionMap[auctionId].adUnitCodeToAdUnitMap[adUnitCode].bidRequestsMap[requestId].bids[adId] = { - cpm, - creativeId, - requestTimestamp, - responseTimestamp, - ts, - adId, - meta, - mediaType, - dealId, - ttl, - netRevenue, - currency, - originalCpm, - originalCurrency, - width, - height, - latency, - winner: false, - rendered: false, - renderTime: 0, - }; -} - -function onBidTimeout(args) { - _each(args, ({auctionId, adUnitCode, bidId: requestId}) => { - let timedOutRequest = deepAccess(auctionMap, - `${auctionId}.adUnitCodeToAdUnitMap.${adUnitCode}.bidRequestsMap.${requestId}`); - - if (timedOutRequest) { - timedOutRequest.timedOut = true; - } - }); -} -/** - * - * @param {PbAuction} endedAuction - */ -function onAuctionEnd(endedAuction) { - let auction = auctionMap[endedAuction.auctionId]; - - if (!auction) { - return; - } - - clearAuctionTimer(auction); - auction.endTime = endedAuction.auctionEnd; - auction.state = AUCTION_STATES.ENDED; - delayedSend(auction); -} - -/** - * - * @param {BidResponse} bidResponse - */ -function onBidWon(bidResponse) { - const { auctionId, adUnitCode, requestId, adId } = bidResponse; - let winningBid = deepAccess(auctionMap, - `${auctionId}.adUnitCodeToAdUnitMap.${adUnitCode}.bidRequestsMap.${requestId}.bids.${adId}`); - - if (winningBid) { - winningBid.winner = true; - const auction = auctionMap[auctionId]; - if (auction.sent) { - const endpoint = (analyticsConfig.endpoint || ENDPOINT) + 'event'; - const bidder = auction.adUnitCodeToAdUnitMap[adUnitCode].bidRequestsMap[requestId].bidder; - ajax(`${endpoint}?t=win&b=${adId}&a=${analyticsConfig.orgId}&bidder=${bidder}&ts=${auction.startTime}`, - () => { - logInfo(`Openx Analytics - Sending complete impression event for ${adId} at ${Date.now()}`) - }); - } else { - logInfo(`Openx Analytics - impression event for ${adId} will be sent with auction data`) - } - } -} - -/** - * - * @param {GoogleTagSlot} slot - * @param {string} serviceName - */ -function onSlotLoadedV2({ slot }) { - const renderTime = Date.now(); - const elementId = slot.getSlotElementId(); - const bidId = slot.getTargeting('hb_adid')[0]; - - let [auction, adUnit, bid] = getPathToBidResponseByBidId(bidId); - - if (!auction) { - // attempt to get auction by adUnitCode - auction = getAuctionByGoogleTagSLot(slot); - - if (!auction) { - return; // slot is not participating in an active prebid auction - } - } - - clearAuctionTimer(auction); - - // track that an adunit code has completed within an auction - auction.adunitCodesRenderedCount++; - - // mark adunit as rendered - if (bid) { - let {x, y} = getPageOffset(); - bid.rendered = true; - bid.renderTime = renderTime; - adUnit.adPosition = isAtf(elementId, x, y) ? 'ATF' : 'BTF'; - } - - if (auction.adunitCodesRenderedCount === auction.adUnitCodesCount) { - auction.state = AUCTION_STATES.COMPLETED; - } - - // prepare to send regardless if auction is complete or not as a failsafe in case not all events are tracked - // add additional padding when not all slots are rendered - delayedSend(auction); -} - -function isAtf(elementId, scrollLeft = 0, scrollTop = 0) { - let elem = document.querySelector('#' + elementId); - let isAtf = false; - if (elem) { - let bounding = elem.getBoundingClientRect(); - if (bounding) { - let windowWidth = (window.innerWidth || document.documentElement.clientWidth); - let windowHeight = (window.innerHeight || document.documentElement.clientHeight); - - // intersection coordinates - let left = Math.max(0, bounding.left + scrollLeft); - let right = Math.min(windowWidth, bounding.right + scrollLeft); - let top = Math.max(0, bounding.top + scrollTop); - let bottom = Math.min(windowHeight, bounding.bottom + scrollTop); - - let intersectionWidth = right - left; - let intersectionHeight = bottom - top; - - let intersectionArea = (intersectionHeight > 0 && intersectionWidth > 0) ? (intersectionHeight * intersectionWidth) : 0; - let adSlotArea = (bounding.right - bounding.left) * (bounding.bottom - bounding.top); - - if (adSlotArea > 0) { - // Atleast 50% of intersection in window - isAtf = intersectionArea * 2 >= adSlotArea; - } - } - } else { - logWarn('OX: DOM element not for id ' + elementId); - } - return isAtf; -} - -// backwards compatible pageOffset from https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX -function getPageOffset() { - var x = (window.pageXOffset !== undefined) - ? window.pageXOffset - : (document.documentElement || document.body.parentNode || document.body).scrollLeft; - - var y = (window.pageYOffset !== undefined) - ? window.pageYOffset - : (document.documentElement || document.body.parentNode || document.body).scrollTop; - return {x, y}; -} - -function delayedSend(auction) { - if (auction.sent) { - return; - } - const delayTime = auction.adunitCodesRenderedCount === auction.adUnitCodesCount - ? analyticsConfig.payloadWaitTime - : analyticsConfig.payloadWaitTime + analyticsConfig.payloadWaitTimePadding; - - auction.auctionSendDelayTimer = setTimeout(() => { - auction.sent = true; // any BidWon emitted after this will be recorded separately - let payload = JSON.stringify([buildAuctionPayload(auction)]); - - ajax(analyticsConfig.endpoint || ENDPOINT, () => { - logInfo(`OpenX Analytics - Sending complete auction at ${Date.now()}`); - }, payload, { contentType: 'application/json' }); - }, delayTime); -} - -function clearAuctionTimer(auction) { - // reset the delay timer to send the auction data - if (auction.auctionSendDelayTimer) { - clearTimeout(auction.auctionSendDelayTimer); - auction.auctionSendDelayTimer = void (0); - } -} - -/** - * Returns the path to a bid (auction, adunit, bidRequest, and bid) based on a bidId - * @param {string} bidId - * @returns {Array<*>} - */ -function getPathToBidResponseByBidId(bidId) { - let auction; - let adUnit; - let bidResponse; - - if (!bidId) { - return []; - } - - _each(auctionMap, currentAuction => { - // skip completed auctions - if (currentAuction.state === AUCTION_STATES.COMPLETED) { - return; - } - - _each(currentAuction.adUnitCodeToAdUnitMap, (currentAdunit) => { - _each(currentAdunit.bidRequestsMap, currentBiddRequest => { - _each(currentBiddRequest.bids, (currentBidResponse, bidResponseId) => { - if (bidId === bidResponseId) { - auction = currentAuction; - adUnit = currentAdunit; - bidResponse = currentBidResponse; - } - }); - }); - }); - }); - return [auction, adUnit, bidResponse]; -} - -function getAuctionByGoogleTagSLot(slot) { - let slotAdunitCodes = [slot.getSlotElementId(), slot.getAdUnitPath()]; - let slotAuction; - - _each(auctionMap, auction => { - if (auction.state === AUCTION_STATES.COMPLETED) { - return; - } - - _each(auction.adUnitCodeToAdUnitMap, (bidderRequestIdMap, adUnitCode) => { - if (includes(slotAdunitCodes, adUnitCode)) { - slotAuction = auction; - } - }); - }); - - return slotAuction; -} - -function buildAuctionPayload(auction) { - let {startTime, endTime, state, timeout, auctionOrder, userIds, adUnitCodeToAdUnitMap, id} = auction; - const auctionId = id; - let {orgId, publisherPlatformId, publisherAccountId, campaign, testCode, configId, optimizerConfig} = analyticsConfig; - - return { - auctionId, - adapterVersion: ADAPTER_VERSION, - schemaVersion: SCHEMA_VERSION, - orgId, - publisherPlatformId, - publisherAccountId, - configId, - optimizerConfig, - campaign, - state, - startTime, - endTime, - timeLimit: timeout, - auctionOrder, - deviceType: detectMob() ? 'Mobile' : 'Desktop', - deviceOSType: detectOS(), - browser: detectBrowser(), - testCode: testCode, - // return an array of module name that have user data - userIdProviders: buildUserIdProviders(userIds), - adUnits: buildAdUnitsPayload(adUnitCodeToAdUnitMap), - }; - - function buildAdUnitsPayload(adUnitCodeToAdUnitMap) { - return _map(adUnitCodeToAdUnitMap, (adUnit) => { - let {code, adPosition} = adUnit; - - return { - code, - adPosition, - bidRequests: buildBidRequestPayload(adUnit.bidRequestsMap) - }; - - function buildBidRequestPayload(bidRequestsMap) { - return _map(bidRequestsMap, (bidRequest) => { - let {bidder, source, bids, mediaTypes, timeLimit, timedOut} = bidRequest; - return { - bidder, - source, - hasBidderResponded: Object.keys(bids).length > 0, - availableAdSizes: getMediaTypeSizes(mediaTypes), - availableMediaTypes: getMediaTypes(mediaTypes), - timeLimit, - timedOut, - bidResponses: _map(bidRequest.bids, (bidderBidResponse) => { - let { - adId, - cpm, - creativeId, - ts, - meta, - mediaType, - dealId, - ttl, - netRevenue, - currency, - width, - height, - latency, - winner, - rendered, - renderTime - } = bidderBidResponse; - - return { - bidId: adId, - microCpm: cpm * 1000000, - netRevenue, - currency, - mediaType, - height, - width, - size: `${width}x${height}`, - dealId, - latency, - ttl, - winner, - creativeId, - ts, - rendered, - renderTime, - meta - } - }) - } - }); - } - }); - } - - function buildUserIdProviders(userIds) { - return _map(userIds, (userId) => { - return _map(userId, (id, module) => { - return hasUserData(module, id) ? module : false - }).filter(module => module); - }).reduce(flatten, []).filter(uniques).sort(); - } - - function hasUserData(module, idOrIdObject) { - let normalizedId; - - switch (module) { - case 'digitrustid': - normalizedId = deepAccess(idOrIdObject, 'data.id'); - break; - case 'lipb': - normalizedId = idOrIdObject.lipbid; - break; - default: - normalizedId = idOrIdObject; - } - - return !isEmpty(normalizedId); - } - - function getMediaTypeSizes(mediaTypes) { - return _map(mediaTypes, (mediaTypeConfig, mediaType) => { - return parseSizesInput(mediaTypeConfig.sizes) - .map(size => `${mediaType}_${size}`); - }).reduce(flatten, []); - } - - function getMediaTypes(mediaTypes) { - return _map(mediaTypes, (mediaTypeConfig, mediaType) => mediaType); - } -} diff --git a/modules/openxAnalyticsAdapter.md b/modules/openxAnalyticsAdapter.md deleted file mode 100644 index af40486f2a4..00000000000 --- a/modules/openxAnalyticsAdapter.md +++ /dev/null @@ -1,131 +0,0 @@ - -# OpenX Analytics Adapter to Prebid.js -## Implementation Guide -#### Internal use only - ---- - -# About this Guide -This implementation guide walks through the flow of onboarding an alpha Publisher to test OpenX’s new Analytics Adapter. - -- [Adding OpenX Analytics Adapter to Prebid.js](#adding-openx-analytics-adapter-to-prebidjs) - - [Publisher Builds Prebid.js File Flow](#publisher-builds-prebidjs-file-flow) - - [OpenX Builds Prebid.js File Flow](#openx-builds-prebidjs-file-flow) -- [Website Configuration](#website-configuration) -- [Configuration Options](#configuration-options) -- [Viewing Data](#viewing-data) - ---- - -# Adding OpenX Analytics Adapter to Prebid.js -A Publisher has two options to add the OpenX Analytics Adapter to Prebid.js: - -1. [Publisher builds the Prebid.js file](#publisher-builds-prebid.js-file-flow): If the Publisher is familiar with building Prebid.js (through the command line and not through the download site), OpenX can provide to the Publisher only the Analytics Adapter code. - -2. [OpenX builds the Prebid.js file](#openx-builds-prebid.js-file-flow): If the Publisher is unfamiliar with building Prebid.js, the Publisher should advise OpenX which modules to include by going to the [Prebid download site](http://prebid.org/download.html) and selecting all the desired items (adapters and modules) for OpenX. - ---- - -## Publisher Builds Prebid.js File Flow -Use this option if the Publisher is building the Prebid.js file. - -1. OpenX sends Publisher the new Analytics Adapter code. - -2. Publisher replaces the file in `/modules/openxAnalyticsAdapter.js` with the file provided by OpenX. - -3. Publisher runs the build command in `` and includes `openxAnalyticsAdapter` as one of the modules to include. - - For example: - - ```shell - gulp build --modules=openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter,openxBidAdapter,openxAnalyticsAdapter,dfpAdServerVideo - ``` - -4. Publisher deploys the Prebid.js file from `/build/dist/prebid.js` to a website. - ---- - -## OpenX Builds Prebid.js File Flow -Use this option if OpenX is building the Prebid.js file on behalf of the Publisher. - -1. Publisher refers to the [Prebid download site](http://prebid.org/download.html) and sends a list of adapters and modules to OpenX. - - >Note: The Publisher must be aware that only Prebid 3.0+ is supported. - - For example (does not have to follow exact format): - - ```yaml - Prebid Version: 3.10+ - Modules: - Bidders - OpenX - Rubicon - Sovrn - Consent Management - US Privacy - User ID - IdentityLink ID - DFP Video - Supply Chain Object - Currency - ``` - -2. OpenX uses the information to build a package to the user’s specification and includes `openxAnalyticsAdapter` as an additional module. - -3. OpenX sends the built package to the Publisher. - -4. Publisher deploys the modified Prebid.js to a website. - ---- - -# Website Configuration -To configure your website, add the following code snippet to your website: - -```javascript -pbjs.que.push(function () { - pbjs.enableAnalytics([{ - provider: "openx", - options: { - publisherPlatformId: "OPENX_PROVIDED_PLATFORM_ID", // eg: "a3aece0c-9e80-4316-8deb-faf804779bd1" - publisherAccountId: PUBLISHER_ACCOUNT_ID, // eg: 537143056 - sampling: 0.05, // 5% sample rate - testCode: 'test-code-1' - } - }]); -}); -``` - ---- - -## Configuration Options -Configuration options are a follows: - -| Property | Type | Required? | Description | Example | -|:---|:---|:---|:---|:---| -| `orgId` | `string` | Yes | Used to determine ownership of data. | `aa1bb2cc-3dd4-4316-8deb-faf804779bd1` | -| `publisherPlatformId` | `string` | No
**__Deprecated. Please use orgId__** | Used to determine ownership of data. | `a3aece0c-9e80-4316-8deb-faf804779bd1` | -| `publisherAccountId` | `number` | No
**__Deprecated. Please use orgId__** | Used to determine ownership of data. | `1537143056` | -| `sampling` | `number` | Yes | Sampling rate | Undefined or `1.00` - No sampling. Analytics is sent all the time.
0.5 - 50% of users will send analytics data. | -| `testCode` | `string` | No | Used to label analytics data for the purposes of tests.
This label is treated as a dimension and can be compared against other labels. | `timeout_config_1`
`timeout_config_2`
`timeout_default` | -| `campaign` | `Object` | No | Object with 5 parameters:
  • content
  • medium
  • name
  • source
  • term
Each parameter is a free-form string. Refer to metrics doc on when to use these fields. By setting a value to one of these properties, you override the associated url utm query parameter. | | -| `payloadWaitTime` | `number` | No | Delay after all slots of an auction renders before the payload is sent.
Defaults to 100ms | 1000 | ---- - -# Viewing Data -The Prebid Report available in the Reporting in the Cloud tool, allows you to view your data. - -**To view your data:** - -1. Log in to [OpenX Reporting](https://openx.sigmoid.io/app). - -2. In the top right, click on the **View** list and then select **Prebidreport**. - -3. On the left icon bar, click on the dimensions icon. - -4. Add the dimensions that you need. - -5. On the left icon bar, click on the metrics icon. - -6. Add the metrics (graphs) that you need. - - The data appears on the Analyze screen. diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index 85dcfbb3b47..181a0c70c7e 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -1,610 +1,240 @@ -import { - _each, - _map, - convertTypes, - deepAccess, - deepSetValue, - inIframe, - isArray, - parseSizesInput, - parseUrl -} from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import {mergeDeep} from '../src/utils.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {includes} from '../src/polyfill.js'; - -const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; -const VIDEO_TARGETING = ['startdelay', 'mimes', 'minduration', 'maxduration', - 'startdelay', 'skippable', 'playbackmethod', 'api', 'protocols', 'boxingallowed', - 'linearity', 'delivery', 'protocol', 'placement', 'minbitrate', 'maxbitrate']; -const BIDDER_CODE = 'openx'; -const BIDDER_CONFIG = 'hb_pb'; -const BIDDER_VERSION = '3.0.3'; - -const DEFAULT_CURRENCY = 'USD'; - -export const USER_ID_CODE_TO_QUERY_ARG = { - britepoolid: 'britepoolid', // BritePool ID - criteoId: 'criteoid', // CriteoID - fabrickId: 'nuestarid', // Fabrick ID by Nuestar - haloId: 'audigentid', // Halo ID from Audigent - id5id: 'id5id', // ID5 ID - idl_env: 'lre', // LiveRamp IdentityLink - IDP: 'zeotapid', // zeotapIdPlus ID+ - idxId: 'idxid', // idIDx, - intentIqId: 'intentiqid', // IntentIQ ID - lipb: 'lipbid', // LiveIntent ID - lotamePanoramaId: 'lotameid', // Lotame Panorama ID - merkleId: 'merkleid', // Merkle ID - netId: 'netid', // netID - parrableId: 'parrableid', // Parrable ID - pubcid: 'pubcid', // PubCommon ID - quantcastId: 'quantcastid', // Quantcast ID - tapadId: 'tapadid', // Tapad Id - tdid: 'ttduuid', // The Trade Desk Unified ID - uid2: 'uid2', // Unified ID 2.0 - flocId: 'floc', // Chrome FLoC, - admixerId: 'admixerid', // AdMixer ID - deepintentId: 'deepintentid', // DeepIntent ID - dmdId: 'dmdid', // DMD Marketing Corp ID - nextrollId: 'nextrollid', // NextRoll ID - novatiq: 'novatiqid', // Novatiq ID - mwOpenLinkId: 'mwopenlinkid', // MediaWallah OpenLink ID - dapId: 'dapid', // Akamai DAP ID - amxId: 'amxid', // AMX RTB ID - kpuid: 'kpuid', // Kinesso ID - publinkId: 'publinkid', // Publisher Link - naveggId: 'naveggid', // Navegg ID - imuid: 'imuid', // IM-UID by Intimate Merger - adtelligentId: 'adtelligentid' // Adtelligent ID -}; - +import {ortbConverter} from '../libraries/ortbConverter/converter.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; + +const bidderConfig = 'hb_pb_ortb'; +const bidderVersion = '2.0'; +export const REQUEST_URL = 'https://rtb.openx.net/openrtbb/prebidjs'; +export const SYNC_URL = 'https://u.openx.net/w/1.0/pd'; +export const DEFAULT_PH = '2d1251ae-7f3a-47cf-bd2a-2f288854a0ba'; export const spec = { - code: BIDDER_CODE, + code: 'openx', gvlid: 69, - supportedMediaTypes: SUPPORTED_AD_TYPES, - isBidRequestValid: function (bidRequest) { - const hasDelDomainOrPlatform = bidRequest.params.delDomain || bidRequest.params.platform; - if (deepAccess(bidRequest, 'mediaTypes.banner') && hasDelDomainOrPlatform) { - return !!bidRequest.params.unit || deepAccess(bidRequest, 'mediaTypes.banner.sizes.length') > 0; - } - - return !!(bidRequest.params.unit && hasDelDomainOrPlatform); - }, - buildRequests: function (bidRequests, bidderRequest) { - if (bidRequests.length === 0) { - return []; - } - - let requests = []; - let [videoBids, bannerBids] = partitionByVideoBids(bidRequests); - - // build banner requests - if (bannerBids.length > 0) { - requests.push(buildOXBannerRequest(bannerBids, bidderRequest)); - } - // build video requests - if (videoBids.length > 0) { - videoBids.forEach(videoBid => { - requests.push(buildOXVideoRequest(videoBid, bidderRequest)) - }); - } + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, + transformBidParams +}; - return requests; - }, - interpretResponse: function ({body: oxResponseObj}, serverRequest) { - let mediaType = getMediaTypeFromRequest(serverRequest); +registerBidder(spec); - return mediaType === VIDEO ? createVideoBidResponses(oxResponseObj, serverRequest.payload) - : createBannerBidResponses(oxResponseObj, serverRequest.payload); +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 300 }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { - if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) { - let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image'; - let url = deepAccess(responses, '0.body.ads.pixels') || - deepAccess(responses, '0.body.pixels') || - generateDefaultSyncUrl(gdprConsent, uspConsent); - - return [{ - type: pixelType, - url: url - }]; + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + mergeDeep(imp, { + tagid: bidRequest.params.unit, + ext: { + divid: bidRequest.adUnitCode + } + }); + if (bidRequest.params.customParams) { + utils.deepSetValue(imp, 'ext.customParams', bidRequest.params.customParams); } - }, - transformBidParams: function(params, isOpenRtb) { - return convertTypes({ - 'unit': 'string', - 'customFloor': 'number' - }, params); - } -}; - -function generateDefaultSyncUrl(gdprConsent, uspConsent) { - let url = 'https://u.openx.net/w/1.0/pd'; - let queryParamStrings = []; - - if (gdprConsent) { - queryParamStrings.push('gdpr=' + (gdprConsent.gdprApplies ? 1 : 0)); - queryParamStrings.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '')); - } - - // CCPA - if (uspConsent) { - queryParamStrings.push('us_privacy=' + encodeURIComponent(uspConsent)); - } - - return `${url}${queryParamStrings.length > 0 ? '?' + queryParamStrings.join('&') : ''}`; -} - -function isVideoRequest(bidRequest) { - return (deepAccess(bidRequest, 'mediaTypes.video') && !deepAccess(bidRequest, 'mediaTypes.banner')) || bidRequest.mediaType === VIDEO; -} - -function createBannerBidResponses(oxResponseObj, {bids, startTime}) { - let adUnits = oxResponseObj.ads.ad; - let bidResponses = []; - for (let i = 0; i < adUnits.length; i++) { - let adUnit = adUnits[i]; - let adUnitIdx = parseInt(adUnit.idx, 10); - let bidResponse = {}; - - bidResponse.requestId = bids[adUnitIdx].bidId; - - if (adUnit.pub_rev) { - bidResponse.cpm = Number(adUnit.pub_rev) / 1000; - } else { - // No fill, do not add the bidresponse - continue; + if (bidRequest.params.customFloor && !imp.bidfloor) { + imp.bidfloor = bidRequest.params.customFloor; } - let creative = adUnit.creative[0]; - if (creative) { - bidResponse.width = creative.width; - bidResponse.height = creative.height; + return imp; + }, + request(buildRequest, imps, bidderRequest, context) { + const req = buildRequest(imps, bidderRequest, context); + mergeDeep(req, { + at: 1, + ext: { + bc: `${bidderConfig}_${bidderVersion}` + } + }) + const bid = context.bidRequests[0]; + if (bid.params.coppa) { + utils.deepSetValue(req, 'regs.coppa', 1); } - bidResponse.creativeId = creative.id; - bidResponse.ad = adUnit.html; - if (adUnit.deal_id) { - bidResponse.dealId = adUnit.deal_id; + if (bid.params.doNotTrack) { + utils.deepSetValue(req, 'device.dnt', 1); } - // default 5 mins - bidResponse.ttl = 300; - // true is net, false is gross - bidResponse.netRevenue = true; - bidResponse.currency = adUnit.currency; - - // additional fields to add - if (adUnit.tbd) { - bidResponse.tbd = adUnit.tbd; + if (bid.params.platform) { + utils.deepSetValue(req, 'ext.platform', bid.params.platform); } - bidResponse.ts = adUnit.ts; - - bidResponse.meta = {}; - if (adUnit.brand_id) { - bidResponse.meta.brandId = adUnit.brand_id; + if (bid.params.delDomain) { + utils.deepSetValue(req, 'ext.delDomain', bid.params.delDomain); } - - if (adUnit.adomain && length(adUnit.adomain) > 0) { - bidResponse.meta.advertiserDomains = adUnit.adomain; - } else { - bidResponse.meta.advertiserDomains = []; + if (bid.params.response_template_name) { + utils.deepSetValue(req, 'ext.response_template_name', bid.params.response_template_name); } - - if (adUnit.adv_id) { - bidResponse.meta.dspid = adUnit.adv_id; + if (bid.params.test) { + req.test = 1 } - - bidResponses.push(bidResponse); - } - return bidResponses; -} - -function getViewportDimensions(isIfr) { - let width; - let height; - let tWin = window; - let tDoc = document; - let docEl = tDoc.documentElement; - let body; - - if (isIfr) { - try { - tWin = window.top; - tDoc = window.top.document; - } catch (e) { - return; + return req; + }, + bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); + if (bid.ext) { + bidResponse.meta.networkId = bid.ext.dsp_id; + bidResponse.meta.advertiserId = bid.ext.buyer_id; + bidResponse.meta.brandId = bid.ext.brand_id; + } + const {ortbResponse} = context; + if (ortbResponse.ext && ortbResponse.ext.paf) { + bidResponse.meta.paf = Object.assign({}, ortbResponse.ext.paf); + bidResponse.meta.paf.content_id = utils.deepAccess(bid, 'ext.paf.content_id'); + } + return bidResponse; + }, + response(buildResponse, bidResponses, ortbResponse, context) { + // pass these from request to the responses for use in userSync + const {ortbRequest} = context; + if (ortbRequest.ext) { + if (ortbRequest.ext.delDomain) { + utils.deepSetValue(ortbResponse, 'ext.delDomain', ortbRequest.ext.delDomain); + } + if (ortbRequest.ext.platform) { + utils.deepSetValue(ortbResponse, 'ext.platform', ortbRequest.ext.platform); + } } - docEl = tDoc.documentElement; - body = tDoc.body; - - width = tWin.innerWidth || docEl.clientWidth || body.clientWidth; - height = tWin.innerHeight || docEl.clientHeight || body.clientHeight; - } else { - docEl = tDoc.documentElement; - width = tWin.innerWidth || docEl.clientWidth; - height = tWin.innerHeight || docEl.clientHeight; - } - - return `${width}x${height}`; -} - -function formatCustomParms(customKey, customParams) { - let value = customParams[customKey]; - if (isArray(value)) { - // if value is an array, join them with commas first - value = value.join(','); - } - // return customKey=customValue format, escaping + to . and / to _ - return (customKey.toLowerCase() + '=' + value.toLowerCase()).replace('+', '.').replace('/', '_') -} - -function partitionByVideoBids(bidRequests) { - return bidRequests.reduce(function (acc, bid) { - // Fallback to banner ads if nothing specified - if (isVideoRequest(bid)) { - acc[0].push(bid); + const response = buildResponse(bidResponses, ortbResponse, context); + // TODO: we may want to standardize this and move fledge logic to ortbConverter + let fledgeAuctionConfigs = utils.deepAccess(ortbResponse, 'ext.fledge_auction_configs'); + if (fledgeAuctionConfigs) { + fledgeAuctionConfigs = Object.entries(fledgeAuctionConfigs).map(([bidId, cfg]) => { + return { + bidId, + config: Object.assign({ + auctionSignals: {}, + }, cfg) + } + }); + return { + bids: response.bids, + fledgeAuctionConfigs, + } } else { - acc[1].push(bid); - } - return acc; - }, [[], []]); -} - -function getMediaTypeFromRequest(serverRequest) { - return /avjp$/.test(serverRequest.url) ? VIDEO : BANNER; -} - -function buildCommonQueryParamsFromBids(bids, bidderRequest) { - const isInIframe = inIframe(); - let defaultParams; - - defaultParams = { - ju: config.getConfig('pageUrl') || bidderRequest.refererInfo.referer, - ch: document.charSet || document.characterSet, - res: `${screen.width}x${screen.height}x${screen.colorDepth}`, - ifr: isInIframe, - tz: new Date().getTimezoneOffset(), - tws: getViewportDimensions(isInIframe), - be: 1, - bc: bids[0].params.bc || `${BIDDER_CONFIG}_${BIDDER_VERSION}`, - dddid: _map(bids, bid => bid.transactionId).join(','), - nocache: new Date().getTime() - }; - - const userDataSegments = buildFpdQueryParams('ortb2.user.data'); - if (userDataSegments.length > 0) { - defaultParams.sm = userDataSegments; - } - - const siteContentDataSegments = buildFpdQueryParams('ortb2.site.content.data'); - if (siteContentDataSegments.length > 0) { - defaultParams.scsm = siteContentDataSegments; - } - - if (bids[0].params.platform) { - defaultParams.ph = bids[0].params.platform; - } - - if (bidderRequest.gdprConsent) { - let gdprConsentConfig = bidderRequest.gdprConsent; - - if (gdprConsentConfig.consentString !== undefined) { - defaultParams.gdpr_consent = gdprConsentConfig.consentString; - } - - if (gdprConsentConfig.gdprApplies !== undefined) { - defaultParams.gdpr = gdprConsentConfig.gdprApplies ? 1 : 0; + return response.bids } - - if (config.getConfig('consentManagement.cmpApi') === 'iab') { - defaultParams.x_gdpr_f = 1; - } - } - - if (bidderRequest && bidderRequest.uspConsent) { - defaultParams.us_privacy = bidderRequest.uspConsent; - } - - // normalize publisher common id - if (deepAccess(bids[0], 'crumbs.pubcid')) { - deepSetValue(bids[0], 'userId.pubcid', deepAccess(bids[0], 'crumbs.pubcid')); - } - defaultParams = appendUserIdsToQueryParams(defaultParams, bids[0].userId); - - // supply chain support - if (bids[0].schain) { - defaultParams.schain = serializeSupplyChain(bids[0].schain); - } - - return defaultParams; -} - -function buildFpdQueryParams(fpdPath) { - const firstPartyData = config.getConfig(fpdPath); - if (!Array.isArray(firstPartyData) || !firstPartyData.length) { - return ''; - } - const fpd = firstPartyData - .filter( - data => (Array.isArray(data.segment) && - data.segment.length > 0 && - data.name !== undefined && - data.name.length > 0) - ) - .reduce((acc, data) => { - const name = typeof data.ext === 'object' && data.ext.segtax ? `${data.name}/${data.ext.segtax}` : data.name; - acc[name] = (acc[name] || []).concat(data.segment.map(seg => seg.id)); - return acc; - }, {}) - return Object.keys(fpd) - .map((name, _) => name + ':' + fpd[name].join('|')) - .join(',') -} - -function appendUserIdsToQueryParams(queryParams, userIds) { - _each(userIds, (userIdObjectOrValue, userIdProviderKey) => { - const key = USER_ID_CODE_TO_QUERY_ARG[userIdProviderKey]; - - if (USER_ID_CODE_TO_QUERY_ARG.hasOwnProperty(userIdProviderKey)) { - switch (userIdProviderKey) { - case 'merkleId': - queryParams[key] = userIdObjectOrValue.id; - break; - case 'flocId': - queryParams[key] = userIdObjectOrValue.id; - break; - case 'uid2': - queryParams[key] = userIdObjectOrValue.id; - break; - case 'lipb': - queryParams[key] = userIdObjectOrValue.lipbid; - if (Array.isArray(userIdObjectOrValue.segments) && userIdObjectOrValue.segments.length > 0) { - const liveIntentSegments = 'liveintent:' + userIdObjectOrValue.segments.join('|') - queryParams.sm = `${queryParams.sm ? queryParams.sm + ',' : ''}${liveIntentSegments}`; + }, + overrides: { + imp: { + bidfloor(setBidFloor, imp, bidRequest, context) { + // enforce floors should always be in USD + // TODO: does it make sense that request.cur can be any currency, but request.imp[].bidfloorcur must be USD? + const floor = {}; + setBidFloor(floor, bidRequest, {...context, currency: 'USD'}); + if (floor.bidfloorcur === 'USD') { + Object.assign(imp, floor); + } + }, + video(orig, imp, bidRequest, context) { + if (FEATURES.VIDEO) { + // `orig` is the video imp processor, which looks at bidRequest.mediaTypes[VIDEO] + // to populate imp.video + // alter its input `bidRequest` to also pick up parameters from `bidRequest.params` + let videoParams = bidRequest.mediaTypes[VIDEO]; + if (videoParams) { + videoParams = Object.assign({}, videoParams, bidRequest.params.video); + bidRequest = {...bidRequest, mediaTypes: {[VIDEO]: videoParams}} + } + orig(imp, bidRequest, context); + if (imp.video && videoParams?.context === 'outstream') { + imp.video.placement = imp.video.placement || 4; } - break; - case 'parrableId': - queryParams[key] = userIdObjectOrValue.eid; - break; - case 'id5id': - queryParams[key] = userIdObjectOrValue.uid; - break; - case 'novatiq': - queryParams[key] = userIdObjectOrValue.snowflake; - break; - default: - queryParams[key] = userIdObjectOrValue; + } } } - }); - - return queryParams; -} - -function serializeSupplyChain(supplyChain) { - return `${supplyChain.ver},${supplyChain.complete}!${serializeSupplyChainNodes(supplyChain.nodes)}`; -} - -function serializeSupplyChainNodes(supplyChainNodes) { - const supplyChainNodePropertyOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + } +}); - return supplyChainNodes.map(supplyChainNode => { - return supplyChainNodePropertyOrder.map(property => supplyChainNode[property] || '') - .join(','); - }).join('!'); +function transformBidParams(params, isOpenRtb) { + return convertTypes({ + 'unit': 'string', + 'customFloor': 'number' + }, params); } -function buildOXBannerRequest(bids, bidderRequest) { - let customParamsForAllBids = []; - let hasCustomParam = false; - let queryParams = buildCommonQueryParamsFromBids(bids, bidderRequest); - let auids = _map(bids, bid => bid.params.unit); +function isBidRequestValid(bidRequest) { + const hasDelDomainOrPlatform = bidRequest.params.delDomain || + bidRequest.params.platform; - queryParams.aus = _map(bids, bid => parseSizesInput(bid.mediaTypes.banner.sizes).join(',')).join('|'); - queryParams.divids = _map(bids, bid => encodeURIComponent(bid.adUnitCode)).join(','); - // gpid - queryParams.aucs = _map(bids, function (bid) { - let gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); - return encodeURIComponent(gpid || '') - }).join(','); - - if (auids.some(auid => auid)) { - queryParams.auid = auids.join(','); - } - - if (bids.some(bid => bid.params.doNotTrack)) { - queryParams.ns = 1; + if (utils.deepAccess(bidRequest, 'mediaTypes.banner') && + hasDelDomainOrPlatform) { + return !!bidRequest.params.unit || + utils.deepAccess(bidRequest, 'mediaTypes.banner.sizes.length') > 0; } - if (config.getConfig('coppa') === true || bids.some(bid => bid.params.coppa)) { - queryParams.tfcd = 1; - } + return !!(bidRequest.params.unit && hasDelDomainOrPlatform); +} - bids.forEach(function (bid) { - if (bid.params.customParams) { - let customParamsForBid = _map(Object.keys(bid.params.customParams), customKey => formatCustomParms(customKey, bid.params.customParams)); - let formattedCustomParams = window.btoa(customParamsForBid.join('&')); - hasCustomParam = true; - customParamsForAllBids.push(formattedCustomParams); - } else { - customParamsForAllBids.push(''); - } +function buildRequests(bids, bidderRequest) { + let videoBids = bids.filter(bid => isVideoBid(bid)); + let bannerBids = bids.filter(bid => isBannerBid(bid)); + let requests = bannerBids.length ? [createRequest(bannerBids, bidderRequest, BANNER)] : []; + videoBids.forEach(bid => { + requests.push(createRequest([bid], bidderRequest, VIDEO)); }); - if (hasCustomParam) { - queryParams.tps = customParamsForAllBids.join(','); - } - - enrichQueryWithFloors(queryParams, BANNER, bids); - - let url = queryParams.ph - ? `https://u.openx.net/w/1.0/arj` - : `https://${bids[0].params.delDomain}/w/1.0/arj`; - - return { - method: 'GET', - url: url, - data: queryParams, - payload: {'bids': bids, 'startTime': new Date()} - }; + return requests; } -function buildOXVideoRequest(bid, bidderRequest) { - let oxVideoParams = generateVideoParameters(bid, bidderRequest); - let url = oxVideoParams.ph - ? `https://u.openx.net/v/1.0/avjp` - : `https://${bid.params.delDomain}/v/1.0/avjp`; +function createRequest(bidRequests, bidderRequest, mediaType) { return { - method: 'GET', - url: url, - data: oxVideoParams, - payload: {'bid': bid, 'startTime': new Date()} - }; -} - -function generateVideoParameters(bid, bidderRequest) { - const videoMediaType = deepAccess(bid, `mediaTypes.video`); - let queryParams = buildCommonQueryParamsFromBids([bid], bidderRequest); - let oxVideoConfig = deepAccess(bid, 'params.video') || {}; - let context = deepAccess(bid, 'mediaTypes.video.context'); - let playerSize = deepAccess(bid, 'mediaTypes.video.playerSize'); - let width; - let height; - - // normalize config for video size - if (isArray(bid.sizes) && bid.sizes.length === 2 && !isArray(bid.sizes[0])) { - width = parseInt(bid.sizes[0], 10); - height = parseInt(bid.sizes[1], 10); - } else if (isArray(bid.sizes) && isArray(bid.sizes[0]) && bid.sizes[0].length === 2) { - width = parseInt(bid.sizes[0][0], 10); - height = parseInt(bid.sizes[0][1], 10); - } else if (isArray(playerSize) && playerSize.length === 2) { - width = parseInt(playerSize[0], 10); - height = parseInt(playerSize[1], 10); - } - - let openRtbParams = {w: width, h: height}; - - // legacy openrtb params could be in video, openrtb, or video.openrtb - let legacyParams = bid.params.video || bid.params.openrtb || {}; - if (legacyParams.openrtb) { - legacyParams = legacyParams.openrtb; - } - // support for video object or full openrtb object - if (isArray(legacyParams.imp)) { - legacyParams = legacyParams.imp[0].video; - } - Object.keys(legacyParams) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => openRtbParams[param] = legacyParams[param]); - - // 5.0 openrtb video params - Object.keys(videoMediaType) - .filter(param => includes(VIDEO_TARGETING, param)) - .forEach(param => openRtbParams[param] = videoMediaType[param]); - - let openRtbReq = { - imp: [ - { - video: openRtbParams - } - ] - } - - queryParams['openrtb'] = JSON.stringify(openRtbReq); - - queryParams.auid = bid.params.unit; - // override prebid config with openx config if available - queryParams.vwd = width || oxVideoConfig.vwd; - queryParams.vht = height || oxVideoConfig.vht; - - if (context === 'outstream') { - queryParams.vos = '101'; - } - - if (oxVideoConfig.mimes) { - queryParams.vmimes = oxVideoConfig.mimes; + method: 'POST', + url: config.getConfig('openxOrtbUrl') || REQUEST_URL, + data: converter.toORTB({bidRequests, bidderRequest, context: {mediaType}}) } - - if (bid.params.test) { - queryParams.vtest = 1; - } - - let gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); - if (gpid) { - queryParams.aucs = encodeURIComponent(gpid) - } - - // each video bid makes a separate request - enrichQueryWithFloors(queryParams, VIDEO, [bid]); - - return queryParams; } -function createVideoBidResponses(response, {bid, startTime}) { - let bidResponses = []; - - if (response !== undefined && response.vastUrl !== '' && response.pub_rev > 0) { - let vastQueryParams = parseUrl(response.vastUrl).search || {}; - let bidResponse = {}; - bidResponse.requestId = bid.bidId; - if (response.deal_id) { - bidResponse.dealId = response.deal_id; - } - // default 5 mins - bidResponse.ttl = 300; - // true is net, false is gross - bidResponse.netRevenue = true; - bidResponse.currency = response.currency; - bidResponse.cpm = parseInt(response.pub_rev, 10) / 1000; - bidResponse.width = parseInt(response.width, 10); - bidResponse.height = parseInt(response.height, 10); - bidResponse.creativeId = response.adid; - bidResponse.vastUrl = response.vastUrl; - bidResponse.mediaType = VIDEO; +function isVideoBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.video'); +} - // enrich adunit with vast parameters - response.ph = vastQueryParams.ph; - response.colo = vastQueryParams.colo; - response.ts = vastQueryParams.ts; +function isBannerBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid); +} - bidResponses.push(bidResponse); +function interpretResponse(resp, req) { + if (!resp.body) { + resp.body = {nbr: 0}; } - - return bidResponses; + return converter.fromORTB({request: req.data, response: resp.body}); } -function enrichQueryWithFloors(queryParams, mediaType, bids) { - let customFloorsForAllBids = []; - let hasCustomFloor = false; - bids.forEach(function (bid) { - let floor = getBidFloor(bid, mediaType); - - if (floor) { - customFloorsForAllBids.push(floor); - hasCustomFloor = true; +/** + * @param syncOptions + * @param responses + * @param gdprConsent + * @param uspConsent + * @return {{type: (string), url: (*|string)}[]} + */ +function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) { + if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) { + let pixelType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let queryParamStrings = []; + let syncUrl = SYNC_URL; + if (gdprConsent) { + queryParamStrings.push('gdpr=' + (gdprConsent.gdprApplies ? 1 : 0)); + queryParamStrings.push('gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || '')); + } + if (uspConsent) { + queryParamStrings.push('us_privacy=' + encodeURIComponent(uspConsent)); + } + if (responses.length > 0 && responses[0].body && responses[0].body.ext) { + const ext = responses[0].body.ext; + if (ext.delDomain) { + syncUrl = `https://${ext.delDomain}/w/1.0/pd` + } else if (ext.platform) { + queryParamStrings.push('ph=' + ext.platform) + } } else { - customFloorsForAllBids.push(0); + queryParamStrings.push('ph=' + DEFAULT_PH) } - }); - if (hasCustomFloor) { - queryParams.aumfs = customFloorsForAllBids.join(','); + return [{ + type: pixelType, + url: `${syncUrl}${queryParamStrings.length > 0 ? '?' + queryParamStrings.join('&') : ''}` + }]; } } - -function getBidFloor(bidRequest, mediaType) { - let floorInfo = {}; - const currency = config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY; - - if (typeof bidRequest.getFloor === 'function') { - floorInfo = bidRequest.getFloor({ - currency: currency, - mediaType: mediaType, - size: '*' - }); - } - let floor = floorInfo.floor || bidRequest.params.customFloor || 0; - - return Math.round(floor * 1000); // normalize to micro currency -} - -registerBidder(spec); diff --git a/modules/openxBidAdapter.md b/modules/openxBidAdapter.md index 68e41a93b18..a39aa1580cd 100644 --- a/modules/openxBidAdapter.md +++ b/modules/openxBidAdapter.md @@ -8,7 +8,11 @@ Maintainer: team-openx@openx.com # Description -Module that connects to OpenX's demand sources +Module that connects to OpenX's demand sources. +Note that this adapter mirrors openxOrtbBidAdapter and any updates must be +completed in both adapters. +openxOrtbBidAdapter will be removed in a future release and should not be used. +Please note you should only include either openxBidAdapter or openxOrtbBidAdapter in your build. # Bid Parameters ## Banner @@ -20,7 +24,7 @@ Module that connects to OpenX's demand sources | `customParams` | optional | Object | User-defined targeting key-value pairs. customParams applies to a specific unit. | `{key1: "v1", key2: ["v2","v3"]}` | `customFloor` | optional | Number | Minimum price in USD. customFloor applies to a specific unit. For example, use the following value to set a $1.50 floor: 1.50

**WARNING:**
Misuse of this parameter can impact revenue | 1.50 | `doNotTrack` | optional | Boolean | Prevents advertiser from using data for this user.

**WARNING:**
Request-level setting. May impact revenue. | true -| `coppa` | optional | Boolean | Enables Child's Online Privacy Protection Act (COPPA) regulations. | true +| `coppa` | optional | Boolean | Enables Child's Online Privacy Protection Act (COPPA) regulations. Use of `pbjs.setConfig({coppa: true});` is now preferred. | true ## Video @@ -28,7 +32,7 @@ Module that connects to OpenX's demand sources | ---- | ----- | ---- | ----------- | ------- | `unit` | required | String | OpenX ad unit ID provided by your OpenX representative. | "1611023122" | `delDomain` | required | String | OpenX delivery domain provided by your OpenX representative. | "PUBLISHER-d.openx.net" -| `openrtb` | optional | OpenRTB Impression | An OpenRtb Impression with Video subtype properties | `{ imp: [{ video: {mimes: ['video/x-ms-wmv, video/mp4']} }] }` +| `video` | optional | OpenRTB video subtypes | Use of adUnit.mediaTypes.video is now preferred. | `{ video: {mimes: ['video/mp4']}` # Example @@ -67,7 +71,8 @@ var adUnits = [ mediaTypes: { video: { playerSize: [640, 480], - context: 'instream' + context: 'instream', + mimes: ['video/x-ms-wmv, video/mp4'] } }, bids: [{ @@ -76,10 +81,10 @@ var adUnits = [ unit: '1611023124', delDomain: 'PUBLISHER-d.openx.net', video: { - mimes: ['video/x-ms-wmv, video/mp4'] + mimes: ['video/x-ms-wmv, video/mp4'] // mediaTypes.video preferred } } - }] + }]p } ]; ``` diff --git a/modules/operaadsBidAdapter.js b/modules/operaadsBidAdapter.js index 61ea8cdcb76..b45c0452319 100644 --- a/modules/operaadsBidAdapter.js +++ b/modules/operaadsBidAdapter.js @@ -1,9 +1,22 @@ -import { logWarn, isArray, isStr, triggerPixel, deepAccess, deepSetValue, isPlainObject, generateUUID, parseUrl, isFn, getDNT, logError } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; -import { Renderer } from '../src/Renderer.js'; -import { OUTSTREAM } from '../src/video.js'; +import { + deepAccess, + deepSetValue, + generateUUID, + getDNT, + isArray, + isFn, + isPlainObject, + isStr, + logError, + logWarn, + triggerPixel +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; +import {OUTSTREAM} from '../src/video.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; const BIDDER_CODE = 'operaads'; @@ -106,6 +119,9 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + return validBidRequests.map(validBidRequest => (buildOpenRtbBidRequest(validBidRequest, bidderRequest))) }, @@ -209,20 +225,19 @@ export const spec = { * @returns {Request} */ function buildOpenRtbBidRequest(bidRequest, bidderRequest) { - const pageReferrer = deepAccess(bidderRequest, 'refererInfo.referer'); - // build OpenRTB request body const payload = { - id: bidderRequest.auctionId, - tmax: bidderRequest.timeout || config.getConfig('bidderTimeout'), + id: bidderRequest.bidderRequestId, + tmax: bidderRequest.timeout, test: config.getConfig('debug') ? 1 : 0, imp: createImp(bidRequest), device: getDevice(), site: { id: String(deepAccess(bidRequest, 'params.publisherId')), - domain: getDomain(pageReferrer), - page: pageReferrer, - ref: window.self === window.top ? document.referrer : '', + // TODO: does the fallback make sense here? + domain: bidderRequest?.refererInfo?.domain || window.location.host, + page: bidderRequest?.refererInfo?.page, + ref: bidderRequest?.refererInfo?.ref || '', }, at: 1, bcat: getBcat(bidRequest), @@ -534,7 +549,7 @@ function createImp(bidRequest) { const floorDetail = getBidFloor(bidRequest, { mediaType: mediaType || '*', size: size || '*' - }) + }); impItem.bidfloor = floorDetail.floor; impItem.bidfloorcur = floorDetail.currency; @@ -665,6 +680,11 @@ function mapNativeImage(image, type) { * @returns {String} userId */ function getUserId(bidRequest) { + let operaId = deepAccess(bidRequest, 'userId.operaId'); + if (operaId) { + return operaId; + } + let sharedId = deepAccess(bidRequest, 'userId.sharedid.id'); if (sharedId) { return sharedId; @@ -680,23 +700,6 @@ function getUserId(bidRequest) { return generateUUID(); } -/** - * Get publisher domain - * - * @param {String} referer - * @returns {String} domain - */ -function getDomain(referer) { - let domain; - - if (!(domain = config.getConfig('publisherDomain'))) { - const u = parseUrl(referer); - domain = u.hostname; - } - - return domain.replace(/^https?:\/\/([\w\-\.]+)(?::\d+)?/, '$1'); -} - /** * Get bid floor price * diff --git a/modules/operaadsBidAdapter.md b/modules/operaadsBidAdapter.md index 709c67a04a7..6c5a4646dd0 100644 --- a/modules/operaadsBidAdapter.md +++ b/modules/operaadsBidAdapter.md @@ -135,18 +135,18 @@ var adUnits = [{ ### User Ids -Opera Ads Bid Adapter uses `sharedId`, `pubcid` or `tdid`, please config at least one. +Opera Ads Bid Adapter uses `operaId`, please refer to [`Opera ID System`](./operaadsIdSystem.md). ```javascript pbjs.setConfig({ ..., userSync: { userIds: [{ - name: 'sharedId', + name: 'operaId', storage: { - name: '_sharedID', // name of the 1st party cookie - type: 'cookie', - expires: 30 + name: 'operaId', + type: 'html5', + expires: 14 } }] } diff --git a/modules/operaadsIdSystem.js b/modules/operaadsIdSystem.js new file mode 100644 index 00000000000..09dd8512a2b --- /dev/null +++ b/modules/operaadsIdSystem.js @@ -0,0 +1,106 @@ +/** + * This module adds operaId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/operaadsIdSystem + * @requires module:modules/userId + */ +import * as ajax from '../src/ajax.js'; +import { submodule } from '../src/hook.js'; +import { logMessage, logError } from '../src/utils.js'; + +const MODULE_NAME = 'operaId'; +const ID_KEY = MODULE_NAME; +const version = '1.0'; +const SYNC_URL = 'https://t.adx.opera.com/identity/'; +const AJAX_TIMEOUT = 300; +const AJAX_OPTIONS = {method: 'GET', withCredentials: true, contentType: 'application/json'}; + +function constructUrl(pairs) { + const queries = []; + for (let key in pairs) { + queries.push(`${key}=${encodeURIComponent(pairs[key])}`); + } + return `${SYNC_URL}?${queries.join('&')}`; +} + +function asyncRequest(url, cb) { + ajax.ajaxBuilder(AJAX_TIMEOUT)( + url, + { + success: response => { + try { + const jsonResponse = JSON.parse(response); + const { uid: operaId } = jsonResponse; + cb(operaId); + return; + } catch (e) { + logError(`${MODULE_NAME}: invalid response`, response); + } + cb(); + }, + error: (err) => { + logError(`${MODULE_NAME}: ID error response`, err); + cb(); + } + }, + null, + AJAX_OPTIONS + ); +} + +export const operaIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + + /** + * @type {string} + */ + version, + + /** + * decode the stored id value for passing to bid requests + * @function + * @param {string} id + * @returns {{'operaId': string}} + */ + decode: (id) => + id != null && id.length > 0 + ? { [ID_KEY]: id } + : undefined, + + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} [config] + * @returns {IdResponse|undefined} + */ + getId(config, consentData) { + logMessage(`${MODULE_NAME}: start synchronizing opera uid`); + const params = (config && config.params) || {}; + if (typeof params.pid !== 'string' || params.pid.length == 0) { + logError(`${MODULE_NAME}: submodule requires a publisher ID to be defined`); + return; + } + + const { pid, syncUrl = SYNC_URL } = params; + const url = constructUrl(syncUrl, { publisherId: pid }); + + return { + callback: (cb) => { + asyncRequest(url, cb); + } + } + }, + + eids: { + 'operaId': { + source: 't.adx.opera.com', + atype: 1 + }, + } +}; + +submodule('userId', operaIdSubmodule); diff --git a/modules/operaadsIdSystem.md b/modules/operaadsIdSystem.md new file mode 100644 index 00000000000..288fb960b96 --- /dev/null +++ b/modules/operaadsIdSystem.md @@ -0,0 +1,52 @@ +# Opera ID System + +For help adding this module, please contact [adtech-prebid-group@opera.com](adtech-prebid-group@opera.com). + +### Prebid Configuration + +You should configure this module under your `userSync.userIds[]` configuration: + +```javascript +pbjs.setConfig({ + userSync: { + userIds: [ + { + name: "operaId", + storage: { + name: "operaId", + type: "html5", + expires: 14 + }, + params: { + pid: "your-pulisher-ID-here" + } + } + ] + } +}) +``` +
+ +| Param under `userSync.userIds[]` | Scope | Type | Description | Example | +| -------------------------------- | -------- | ------ | ----------------------------- | ----------------------------------------- | +| name | Required | string | ID for the operaId module | `"operaId"` | +| storage | Optional | Object | Settings for operaId storage | See [storage settings](#storage-settings) | +| params | Required | Object | Parameters for opreaId module | See [params](#params) | +
+ +### Params + +| Param under `params` | Scope | Type | Description | Example | +| -------------------- | -------- | ------ | ------------------------------ | --------------- | +| pid | Required | string | Publisher ID assigned by Opera | `"pub12345678"` | +
+ +### Storage Settings + +The following settings are suggested for the `storage` property in the `userSync.userIds[]` object: + +| Param under `storage` | Type | Description | Example | +| --------------------- | ------------- | -------------------------------------------------------------------------------- | ----------- | +| name | String | Where the ID will be stored | `"operaId"` | +| type | String | For best performance, this should be `"html5"` | `"html5"` | +| expires | Number <= 30 | number of days until the stored ID expires. **Must be less than or equal to 30** | `14` | \ No newline at end of file diff --git a/modules/optidigitalBidAdapter.js b/modules/optidigitalBidAdapter.js new file mode 100755 index 00000000000..9f27ae49d1e --- /dev/null +++ b/modules/optidigitalBidAdapter.js @@ -0,0 +1,243 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {deepAccess, parseSizesInput} from '../src/utils.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; + +const BIDDER_CODE = 'optidigital'; +const GVL_ID = 915; +const ENDPOINT_URL = 'https://pbs.optidigital.com/bidder'; +const USER_SYNC_URL_IFRAME = 'https://scripts.opti-digital.com/js/presync.html?endpoint=optidigital'; +let CUR = 'USD'; +let isSynced = false; + +export const spec = { + code: BIDDER_CODE, + gvlid: GVL_ID, + supportedMediaTypes: [BANNER], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + let isValid = false; + if (typeof bid.params !== 'undefined' && bid.params.placementId && bid.params.publisherId) { + isValid = true; + } + + return isValid; + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + if (!validBidRequests || validBidRequests.length === 0 || !bidderRequest || !bidderRequest.bids) { + return []; + } + + const ortb2 = bidderRequest.ortb2 || { + bcat: [], + badv: [] + }; + + const payload = { + referrer: (bidderRequest.refererInfo && bidderRequest.refererInfo.page) ? bidderRequest.refererInfo.page : '', + hb_version: '$prebid.version$', + deviceWidth: document.documentElement.clientWidth, + bidderRequestId: deepAccess(validBidRequests[0], 'bidderRequestId'), + publisherId: deepAccess(validBidRequests[0], 'params.publisherId'), + imp: validBidRequests.map(bidRequest => buildImp(bidRequest, ortb2)), + badv: ortb2.badv || deepAccess(validBidRequests[0], 'params.badv') || [], + bcat: ortb2.bcat || deepAccess(validBidRequests[0], 'params.bcat') || [], + bapp: deepAccess(validBidRequests[0], 'params.bapp') || [] + } + + if (validBidRequests[0].auctionId) { + payload.auctionId = validBidRequests[0].auctionId; + } + + if (validBidRequests[0].params.pageTemplate && validBidRequests[0].params.pageTemplate !== '') { + payload.pageTemplate = validBidRequests[0].params.pageTemplate; + } + + if (validBidRequests[0].schain) { + payload.schain = validBidRequests[0].schain; + } + + const gdpr = deepAccess(bidderRequest, 'gdprConsent'); + if (bidderRequest && gdpr) { + const isConsentString = typeof gdpr.consentString === 'string'; + payload.gdpr = { + consent: isConsentString ? gdpr.consentString : '', + required: true + }; + } + if (bidderRequest && !gdpr) { + payload.gdpr = { + consent: '', + required: false + } + } + + if (window.location.href.indexOf('optidigitalTestMode=true') !== -1) { + payload.testMode = true; + } + + if (bidderRequest && bidderRequest.uspConsent) { + payload.uspConsent = bidderRequest.uspConsent; + } + + if (_getEids(validBidRequests[0])) { + payload.user = { + eids: _getEids(validBidRequests[0]) + } + } + + const payloadObject = JSON.stringify(payload); + return { + method: 'POST', + url: ENDPOINT_URL, + data: payloadObject + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + const bidResponses = []; + serverResponse = serverResponse.body; + + if (serverResponse.bids) { + serverResponse.bids.forEach((bid) => { + const bidResponse = { + placementId: bid.placementId, + requestId: bid.bidId, + ttl: bid.ttl, + creativeId: bid.creativeId, + currency: bid.cur, + cpm: bid.cpm, + width: bid.w, + height: bid.h, + ad: bid.adm, + netRevenue: true, + meta: { + advertiserDomains: bid.adomain && bid.adomain.length > 0 ? bid.adomain : [] + } + }; + bidResponses.push(bidResponse); + }); + } + return bidResponses; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + let syncurl = ''; + if (!isSynced) { + // Attaching GDPR Consent Params in UserSync url + if (gdprConsent) { + syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + } + if (uspConsent && uspConsent.consentString) { + syncurl += `&ccpa_consent=${uspConsent.consentString}`; + } + + if (syncOptions.iframeEnabled) { + isSynced = true; + return [{ + type: 'iframe', + url: USER_SYNC_URL_IFRAME + syncurl + }]; + } + } + }, +}; + +function buildImp(bidRequest, ortb2) { + let imp = {}; + imp = { + sizes: parseSizesInput(deepAccess(bidRequest, 'mediaTypes.banner.sizes')), + bidId: deepAccess(bidRequest, 'bidId'), + adUnitCode: deepAccess(bidRequest, 'adUnitCode'), + transactionId: deepAccess(bidRequest, 'ortb2Imp.ext.tid'), + placementId: deepAccess(bidRequest, 'params.placementId') + }; + + if (bidRequest.params.divId && bidRequest.params.divId !== '') { + if (getAdContainer(bidRequest.params.divId)) { + imp.adContainerWidth = getAdContainer(bidRequest.params.divId).offsetWidth; + imp.adContainerHeight = getAdContainer(bidRequest.params.divId).offsetHeight; + } + } + + let floorSizes = []; + if (deepAccess(bidRequest, 'mediaTypes.banner')) { + floorSizes = getAdUnitSizes(bidRequest); + } + + if (bidRequest.params.currency && bidRequest.params.currency !== '') { + CUR = bidRequest.params.currency; + } + + let bidFloor = _getFloor(bidRequest, floorSizes, CUR); + if (bidFloor) { + imp.bidFloor = bidFloor; + } + + let battr = ortb2.battr || deepAccess(bidRequest, 'params.battr'); + if (battr && Array.isArray(battr) && battr.length) { + imp.battr = battr; + } + + return imp; +} + +function getAdContainer(container) { + if (document.getElementById(container)) { + return document.getElementById(container); + } +} + +function _getFloor (bid, sizes, currency) { + let floor = null; + let size = sizes.length === 1 ? sizes[0] : '*'; + if (typeof bid.getFloor === 'function') { + try { + const floorInfo = bid.getFloor({ + currency: currency, + mediaType: 'banner', + size: size + }); + if (typeof floorInfo === 'object' && floorInfo.currency === CUR && !isNaN(parseFloat(floorInfo.floor))) { + floor = parseFloat(floorInfo.floor); + } + } catch (err) {} + } + return floor !== null ? floor : bid.params.floor; +} + +function _getEids(bidRequest) { + if (deepAccess(bidRequest, 'userIdAsEids')) { + return bidRequest.userIdAsEids; + } +} + +export function resetSync() { + isSynced = false; +} + +registerBidder(spec); diff --git a/modules/optidigitalBidAdapter.md b/modules/optidigitalBidAdapter.md new file mode 100755 index 00000000000..327e7a27c75 --- /dev/null +++ b/modules/optidigitalBidAdapter.md @@ -0,0 +1,49 @@ +# Overview + +**Module Name**: OptiDigital Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: prebid@optidigital.com + +# Description + +Bidder Adapter for Prebid.js. + +## AdUnits configuration example +``` + var adUnits = [{ + code: 'your-slot_1-div', //use exactly the same code as your slot div id. + mediaTypes: { + banner: { + sizes: [[300,600]] + } + }, + bids: [{ + bidder: 'optidigital', + params: { + publisherId: 'test', + placementId: 'Billboard_Top', + divId: 'Billboard_Top_3c5425', // optional parameter + pageTemplate: 'home', // optional parameter + badv: ['example.com'], // optional parameter + bcat: ['IAB1-1'], // optional parameter + bapp: ['com.blocked'], // optional parameter + battr: [1, 2] // optional parameter + } + }] + }]; +``` + +## UserSync example + +``` +pbjs.setConfig({ +  userSync: { +    filterSettings: { +      iframe: { +        bidders: '*', // '*' represents all bidders +        filter: 'include' +      } +    } +  } +}); +``` diff --git a/modules/optimaticBidAdapter.md b/modules/optimaticBidAdapter.md deleted file mode 100644 index edaa3da90f6..00000000000 --- a/modules/optimaticBidAdapter.md +++ /dev/null @@ -1,30 +0,0 @@ -# Overview - -``` -Module Name: Optimatic Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebid@optimatic.com -``` - -# Description - -Optimatic Bid Adapter Module connects to Optimatic Demand Sources for Video Ads - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[640,480]], // a video size - bids: [ - { - bidder: "optimatic", - params: { - placement: "2chy7Gc2eSQL", - bidfloor: 2.5 - } - } - ] - }, - ]; -``` diff --git a/modules/optimeraRtdProvider.js b/modules/optimeraRtdProvider.js index dfe8f1bfcf2..04d9b9d1b9f 100644 --- a/modules/optimeraRtdProvider.js +++ b/modules/optimeraRtdProvider.js @@ -16,6 +16,7 @@ * @property {string} clientID * @property {string} optimeraKeyName * @property {string} device + * @property {string} apiVersion */ import { logInfo, logError } from '../src/utils.js'; @@ -38,7 +39,10 @@ export let optimeraKeyName = 'hb_deal_optimera'; * the targeting values. * @type {string} */ -export const scoresBaseURL = 'https://dyv1bugovvq1g.cloudfront.net/'; +export const scoresBaseURL = { + v0: 'https://dyv1bugovvq1g.cloudfront.net/', + v1: 'https://v1.oapi26b.com/', +}; /** * Optimera Score File URL. @@ -58,6 +62,12 @@ export let clientID; */ export let device = 'default'; +/** + * Optional apiVersion parameter. + * @type {string} + */ +export let apiVersion = 'v0'; + /** * Targeting object for all ad positions. * @type {string} @@ -127,6 +137,7 @@ export function onAuctionInit(auctionDetails, config, userConsent) { /** * Initialize the Module. + * moduleConfig.params.apiVersion can be either v0 or v1. */ export function init(moduleConfig) { _moduleParams = moduleConfig.params; @@ -138,6 +149,9 @@ export function init(moduleConfig) { if (_moduleParams.device) { device = _moduleParams.device; } + if (_moduleParams.apiVersion) { + apiVersion = (_moduleParams.apiVersion.includes('v1', 'v0')) ? _moduleParams.apiVersion : 'v0'; + } setScoresURL(); scoreFileRequest(); return true; @@ -162,7 +176,15 @@ export function init(moduleConfig) { export function setScoresURL() { const optimeraHost = window.location.host; const optimeraPathName = window.location.pathname; - const newScoresURL = `${scoresBaseURL}${clientID}/${optimeraHost}${optimeraPathName}.js`; + const baseUrl = scoresBaseURL[apiVersion] ? scoresBaseURL[apiVersion] : scoresBaseURL.v0; + let newScoresURL; + + if (apiVersion === 'v1') { + newScoresURL = `${baseUrl}api/products/scores?c=${clientID}&h=${optimeraHost}&p=${optimeraPathName}&s=${device}`; + } else { + newScoresURL = `${baseUrl}${clientID}/${optimeraHost}${optimeraPathName}.js`; + } + if (scoresURL !== newScoresURL) { scoresURL = newScoresURL; fetchScoreFile = true; diff --git a/modules/optimeraRtdProvider.md b/modules/optimeraRtdProvider.md index 610dec537e0..8b66deb5ad5 100644 --- a/modules/optimeraRtdProvider.md +++ b/modules/optimeraRtdProvider.md @@ -1,6 +1,6 @@ # Overview ``` -Module Name: Optimera Real Time Date Module +Module Name: Optimera Real Time Data Module Module Type: RTD Module Maintainer: mcallari@optimera.nyc ``` @@ -26,7 +26,8 @@ Configuration example for using RTD module with `optimera` provider params: { clientID: '9999', optimeraKeyName: 'optimera', - device: 'de' + device: 'de', + apiVersion: 'v0', } } ] @@ -42,3 +43,4 @@ Contact Optimera to get assistance with the params. | clientID | string | required | Optimera Client ID | | optimeraKeyName | string | optional | GAM key name for Optimera. If migrating from the Optimera bidder adapter this will default to hb_deal_optimera and can be ommitted from the configuration. | | device | string | optional | Device type code for mobile, tablet, or desktop. Either mo, tb, de | +| apiVersion | string | optional | Optimera API Versions. Either v0, or v1. ** Note: v1 wll need to be enabled specifically for your account, otherwise use v0. \ No newline at end of file diff --git a/modules/optimonAnalyticsAdapter.js b/modules/optimonAnalyticsAdapter.js index 34b2778afc9..82bc18f605d 100644 --- a/modules/optimonAnalyticsAdapter.js +++ b/modules/optimonAnalyticsAdapter.js @@ -8,7 +8,7 @@ * */ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; const optimonAnalyticsAdapter = adapter({ diff --git a/modules/optoutBidAdapter.js b/modules/optoutBidAdapter.js index d218a65bf90..f7b5934665c 100644 --- a/modules/optoutBidAdapter.js +++ b/modules/optoutBidAdapter.js @@ -1,6 +1,7 @@ import { deepAccess } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; const BIDDER_CODE = 'optout'; @@ -19,16 +20,6 @@ function getCurrency() { return cur; } -function hasPurpose1Consent(bidderRequest) { - let result = false; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.apiVersion === 2) { - result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} - export const spec = { code: BIDDER_CODE, @@ -36,7 +27,7 @@ export const spec = { return !!bid.params.publisher && !!bid.params.adslot; }, - buildRequests: function(validBidRequests) { + buildRequests: function(validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { let endPoint = 'https://adscience-nocookie.nl/prebid/display'; let consentString = ''; @@ -44,7 +35,7 @@ export const spec = { if (bidRequest.gdprConsent) { gdpr = (typeof bidRequest.gdprConsent.gdprApplies === 'boolean') ? Number(bidRequest.gdprConsent.gdprApplies) : 0; consentString = bidRequest.gdprConsent.consentString; - if (!gdpr || hasPurpose1Consent(bidRequest)) { + if (!gdpr || hasPurpose1Consent(bidRequest.gdprConsent)) { endPoint = 'https://prebid.adscience.nl/prebid/display'; } } @@ -57,7 +48,7 @@ export const spec = { adSlot: bidRequest.params.adslot, cur: getCurrency(), url: getDomain(bidRequest), - ortb2: config.getConfig('ortb2'), + ortb2: bidderRequest.ortb2, consent: consentString, gdpr: gdpr @@ -73,7 +64,7 @@ export const spec = { getUserSyncs: function (syncOptions, responses, gdprConsent) { if (gdprConsent) { let gdpr = (typeof gdprConsent.gdprApplies === 'boolean') ? Number(gdprConsent.gdprApplies) : 0; - if (syncOptions.iframeEnabled && (!gdprConsent.gdprApplies || hasPurpose1Consent({gdprConsent}))) { + if (syncOptions.iframeEnabled && (!gdprConsent.gdprApplies || hasPurpose1Consent(gdprConsent))) { return [{ type: 'iframe', url: 'https://umframe.adscience.nl/matching/iframe?gdpr=' + gdpr + '&gdpr_consent=' + gdprConsent.consentString diff --git a/modules/orbidderBidAdapter.js b/modules/orbidderBidAdapter.js index 38af3a8d1d6..53fff39047f 100644 --- a/modules/orbidderBidAdapter.js +++ b/modules/orbidderBidAdapter.js @@ -1,9 +1,11 @@ import { isFn, isPlainObject } from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; import { getStorageManager } from '../src/storageManager.js'; import { BANNER, NATIVE } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { getGlobal } from '../src/prebidGlobal.js'; -const storageManager = getStorageManager({bidderCode: 'orbidder'}); +const storageManager = getStorageManager({ bidderCode: 'orbidder' }); /** * Determines whether or not the given bid response is valid. @@ -67,7 +69,7 @@ export const spec = { return !!(bid.sizes && bid.bidId && bid.params && (bid.params.accountId && (typeof bid.params.accountId === 'string')) && (bid.params.placementId && (typeof bid.params.placementId === 'string')) && - ((typeof bid.params.profile === 'undefined') || (typeof bid.params.profile === 'object'))); + ((typeof bid.params.keyValues === 'undefined') || (typeof bid.params.keyValues === 'object'))); }, /** @@ -78,11 +80,14 @@ export const spec = { * @return The requests for the orbidder /bid endpoint, i.e. the server. */ buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const hostname = this.getHostname(); return validBidRequests.map((bidRequest) => { let referer = ''; if (bidderRequest && bidderRequest.refererInfo) { - referer = bidderRequest.refererInfo.referer || ''; + referer = bidderRequest.refererInfo.page || ''; } bidRequest.params.bidfloor = getBidFloor(bidRequest); @@ -92,11 +97,12 @@ export const spec = { method: 'POST', options: { withCredentials: true }, data: { - v: $$PREBID_GLOBAL$$.version, + v: getGlobal().version, pageUrl: referer, bidId: bidRequest.bidId, auctionId: bidRequest.auctionId, - transactionId: bidRequest.transactionId, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + transactionId: bidRequest.ortb2Imp?.ext?.tid, adUnitCode: bidRequest.adUnitCode, bidRequestCount: bidRequest.bidRequestCount, params: bidRequest.params, diff --git a/modules/orbitsoftBidAdapter.js b/modules/orbitsoftBidAdapter.js new file mode 100644 index 00000000000..f55c7ff9917 --- /dev/null +++ b/modules/orbitsoftBidAdapter.js @@ -0,0 +1,150 @@ +import * as utils from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {getBidIdParameter} from '../src/utils.js'; + +const BIDDER_CODE = 'orbitsoft'; +let styleParamsMap = { + 'title.family': 'f1', // headerFont + 'title.size': 'fs1', // headerFontSize + 'title.weight': 'w1', // headerWeight + 'title.style': 's1', // headerStyle + 'title.color': 'c3', // headerColor + 'description.family': 'f2', // descriptionFont + 'description.size': 'fs2', // descriptionFontSize + 'description.weight': 'w2', // descriptionWeight + 'description.style': 's2', // descriptionStyle + 'description.color': 'c4', // descriptionColor + 'url.family': 'f3', // urlFont + 'url.size': 'fs3', // urlFontSize + 'url.weight': 'w3', // urlWeight + 'url.style': 's3', // urlStyle + 'url.color': 'c5', // urlColor + 'colors.background': 'c2', // borderColor + 'colors.border': 'c1', // borderColor + 'colors.link': 'c6', // lnkColor +}; +export const spec = { + code: BIDDER_CODE, + aliases: ['oas', '152media'], // short code and customer aliases + isBidRequestValid: function (bid) { + switch (true) { + case !('params' in bid): + utils.logError(bid.bidder + ': No required params'); + return false; + case !(bid.params.placementId): + utils.logError(bid.bidder + ': No required param placementId'); + return false; + case !(bid.params.requestUrl): + utils.logError(bid.bidder + ': No required param requestUrl'); + return false; + } + return true; + }, + buildRequests: function (validBidRequests) { + let bidRequest; + let serverRequests = []; + for (let i = 0; i < validBidRequests.length; i++) { + bidRequest = validBidRequests[i]; + let bidRequestParams = bidRequest.params; + let placementId = getBidIdParameter('placementId', bidRequestParams); + let requestUrl = getBidIdParameter('requestUrl', bidRequestParams); + let referrer = getBidIdParameter('ref', bidRequestParams); + let location = getBidIdParameter('loc', bidRequestParams); + // Append location & referrer + if (location === '') { + location = utils.getWindowLocation(); + } + if (referrer === '' && bidRequest && bidRequest.refererInfo) { + referrer = bidRequest.refererInfo.referer; + } + + // Styles params + let stylesParams = getBidIdParameter('style', bidRequestParams); + let stylesParamsArray = {}; + for (let currentValue in stylesParams) { + if (stylesParams.hasOwnProperty(currentValue)) { + let currentStyle = stylesParams[currentValue]; + for (let field in currentStyle) { + if (currentStyle.hasOwnProperty(field)) { + let styleField = styleParamsMap[currentValue + '.' + field]; + if (typeof styleField !== 'undefined') { + stylesParamsArray[styleField] = currentStyle[field]; + } + } + } + } + } + // Custom params + let customParams = getBidIdParameter('customParams', bidRequestParams); + let customParamsArray = {}; + for (let customField in customParams) { + if (customParams.hasOwnProperty(customField)) { + customParamsArray['c.' + customField] = customParams[customField]; + } + } + + // Sizes params (not supports by server, for future features) + let sizesParams = bidRequest.sizes; + let parsedSizes = utils.parseSizesInput(sizesParams); + let requestData = Object.assign({ + 'scid': placementId, + 'callback_uid': utils.generateUUID(), + 'loc': location, + 'ref': referrer, + 'size': parsedSizes + }, stylesParamsArray, customParamsArray); + + serverRequests.push({ + method: 'POST', + url: requestUrl, + data: requestData, + options: {withCredentials: false}, + bidRequest: bidRequest + }); + } + return serverRequests; + }, + interpretResponse: function (serverResponse, request) { + let bidResponses = []; + if (!serverResponse || serverResponse.error) { + utils.logError(BIDDER_CODE + ': Server response error'); + return bidResponses; + } + + const serverBody = serverResponse.body; + if (!serverBody) { + utils.logError(BIDDER_CODE + ': Empty bid response'); + return bidResponses; + } + + const CPM = serverBody.cpm; + const WIDTH = serverBody.width; + const HEIGHT = serverBody.height; + const CREATIVE = serverBody.content_url; + const CALLBACK_UID = serverBody.callback_uid; + const TIME_TO_LIVE = 60; + const REFERER = utils.getWindowTop(); + let bidRequest = request.bidRequest; + if (CPM > 0 && WIDTH > 0 && HEIGHT > 0) { + let bidResponse = { + requestId: bidRequest.bidId, + cpm: CPM, + width: WIDTH, + height: HEIGHT, + creativeId: CALLBACK_UID, + ttl: TIME_TO_LIVE, + referrer: REFERER, + currency: 'USD', + netRevenue: true, + adUrl: CREATIVE, + meta: { + advertiserDomains: serverBody.adomain ? serverBody.adomain : [] + } + }; + bidResponses.push(bidResponse); + } + + return bidResponses; + } +}; +registerBidder(spec); diff --git a/modules/orbitsoftBidAdapter.md b/modules/orbitsoftBidAdapter.md deleted file mode 100644 index a18f075b6b1..00000000000 --- a/modules/orbitsoftBidAdapter.md +++ /dev/null @@ -1,60 +0,0 @@ -# Overview - -``` -Module Name: Orbitsoft Bidder Adapter -Module Type: Bidder Adapter -Maintainer: support@orbitsoft.com -``` - -# Description - -Module that connects to Orbitsoft's demand sources. The “sizes” option is not supported, and the size of the ad depends on the placement settings. You can use an optional “style” parameter to set the appearance only for text ad. Specify the “requestUrl” param to your Orbitsoft ad server header bidding endpoint. - -# Test Parameters -``` - var adUnits = [ - { - code: 'orbitsoft-div', - bids: [ - { - bidder: "orbitsoft", - params: { - placementId: '132', - requestUrl: 'https://orbitsoft.com/php/ads/hb.php', - style: { - title: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - description: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - url: { - family: 'Tahoma', - size: 'medium', - weight: 'normal', - style: 'normal', - color: '0053F9' - }, - colors: { - background: 'ffffff', - border: 'E0E0E0', - link: '5B99FE' - } - }, - customParams: { - macro_name: "macro_value" - } - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/otmBidAdapter.js b/modules/otmBidAdapter.js index a0e91a480a2..7d4049e3054 100644 --- a/modules/otmBidAdapter.js +++ b/modules/otmBidAdapter.js @@ -1,10 +1,20 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import {logInfo, logError, getBidIdParameter, _each, getValue, isFn, isPlainObject} from '../src/utils.js'; +import { + logInfo, + logError, + _each, + getValue, + isFn, + isPlainObject, + isArray, + isStr, + isNumber, getBidIdParameter, +} from '../src/utils.js'; import { BANNER } from '../src/mediaTypes.js'; const BIDDER_CODE = 'otm'; const OTM_BID_URL = 'https://ssp.otm-r.com/adjson'; -const DEF_CUR = 'RUB' +const DEFAULT_CURRENCY = 'RUB' export const spec = { @@ -19,7 +29,7 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - return !!bid.params.tid; + return Boolean(bid.params.tid); }, /** @@ -33,43 +43,40 @@ export const spec = { logInfo('validBidRequests', validBidRequests); const bidRequests = []; - let tz = new Date().getTimezoneOffset() - let referrer = ''; - if (bidderRequest && bidderRequest.refererInfo) { - referrer = bidderRequest.refererInfo.referer; - } + const tz = new Date().getTimezoneOffset() + // TODO: are these the right referer values? + const referrer = bidderRequest?.refererInfo?.page || ''; + const topOrigin = bidderRequest?.refererInfo?.domain || ''; _each(validBidRequests, (bid) => { - let domain = getValue(bid.params, 'domain') || '' - let tid = getValue(bid.params, 'tid') - let cur = getValue(bid.params, 'currency') || DEF_CUR - let bidid = getBidIdParameter('bidId', bid) - let transactionid = getBidIdParameter('transactionId', bid) - let auctionid = getBidIdParameter('auctionId', bid) - let bidfloor = _getBidFloor(bid) + const domain = isStr(bid.params.domain) ? bid.params.domain : topOrigin + const cur = getValue(bid.params, 'currency') || DEFAULT_CURRENCY + const bidid = getBidIdParameter('bidId', bid) + const transactionid = bid.ortb2Imp?.ext?.tid || ''; + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + const auctionid = getBidIdParameter('auctionId', bid) + const bidfloor = _getBidFloor(bid) _each(bid.sizes, size => { - let width = 0; - let height = 0; - if (size.length && typeof size[0] === 'number' && typeof size[1] === 'number') { - width = size[0]; - height = size[1]; - } + const hasSizes = isArray(size) && isNumber(size[0]) && isNumber(size[1]) + const width = hasSizes ? size[0] : 0; + const height = hasSizes ? size[1] : 0; + bidRequests.push({ method: 'GET', url: OTM_BID_URL, data: { - tz: tz, + tz, w: width, h: height, - domain: domain, + domain, l: referrer, - s: tid, - cur: cur, - bidid: bidid, - transactionid: transactionid, - auctionid: auctionid, - bidfloor: bidfloor, + s: bid.params.tid, + cur, + bidid, + transactionid, + auctionid, + bidfloor, }, }) }) @@ -81,10 +88,9 @@ export const spec = { * Generate response. * * @param serverResponse - * @param request * @returns {[]|*[]} */ - interpretResponse: function (serverResponse, request) { + interpretResponse: function (serverResponse) { logInfo('serverResponse', serverResponse.body); const responsesBody = serverResponse ? serverResponse.body : {}; @@ -102,11 +108,10 @@ export const spec = { width: bid.w, height: bid.h, creativeId: bid.creativeid, - currency: bid.currency || 'RUB', + currency: bid.currency || DEFAULT_CURRENCY, netRevenue: true, ad: bid.ad, ttl: bid.ttl, - transactionId: bid.transactionid, meta: { advertiserDomains: bid.adDomain ? [bid.adDomain] : [] } @@ -132,12 +137,12 @@ function _getBidFloor(bid) { return bid.params.bidfloor ? bid.params.bidfloor : 0; } - let floor = bid.getFloor({ - currency: DEF_CUR, + const floor = bid.getFloor({ + currency: DEFAULT_CURRENCY, mediaType: '*', size: '*' }); - if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === DEF_CUR) { + if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === DEFAULT_CURRENCY) { return floor.floor; } return 0; diff --git a/modules/outbrainBidAdapter.js b/modules/outbrainBidAdapter.js index e903f053c7e..0637d680912 100644 --- a/modules/outbrainBidAdapter.js +++ b/modules/outbrainBidAdapter.js @@ -1,13 +1,14 @@ // jshint esversion: 6, es3: false, node: true 'use strict'; -import { - registerBidder -} from '../src/adapters/bidderFactory.js'; -import { NATIVE, BANNER } from '../src/mediaTypes.js'; -import { deepAccess, deepSetValue, replaceAuctionPrice, _map, isArray } from '../src/utils.js'; -import { ajax } from '../src/ajax.js'; -import { config } from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {OUTSTREAM} from '../src/video.js'; +import {_map, deepAccess, deepSetValue, isArray, logWarn, replaceAuctionPrice} from '../src/utils.js'; +import {ajax} from '../src/ajax.js'; +import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {Renderer} from '../src/Renderer.js'; const BIDDER_CODE = 'outbrain'; const GVLID = 164; @@ -21,11 +22,12 @@ const NATIVE_PARAMS = { body: { id: 4, name: 'data', type: 2 }, cta: { id: 1, type: 12, name: 'data' } }; +const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js'; export const spec = { code: BIDDER_CODE, gvlid: GVLID, - supportedMediaTypes: [ NATIVE, BANNER ], + supportedMediaTypes: [ NATIVE, BANNER, VIDEO ], isBidRequestValid: (bid) => { if (typeof bid.params !== 'object') { return false; @@ -49,17 +51,21 @@ export const spec = { return ( !!config.getConfig('outbrain.bidderUrl') && - !!(bid.nativeParams || bid.sizes) + (!!(bid.nativeParams || bid.sizes) || isValidVideoRequest(bid)) ); }, buildRequests: (validBidRequests, bidderRequest) => { - const page = bidderRequest.refererInfo.referer; + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const ortb2 = bidderRequest.ortb2 || {}; + const page = bidderRequest.refererInfo.page; const ua = navigator.userAgent; const test = setOnAny(validBidRequests, 'params.test'); const publisher = setOnAny(validBidRequests, 'params.publisher'); - const bcat = setOnAny(validBidRequests, 'params.bcat'); - const badv = setOnAny(validBidRequests, 'params.badv'); - const eids = setOnAny(validBidRequests, 'userIdAsEids') + const bcat = ortb2.bcat || setOnAny(validBidRequests, 'params.bcat'); + const badv = ortb2.badv || setOnAny(validBidRequests, 'params.badv'); + const eids = setOnAny(validBidRequests, 'userIdAsEids'); + const wlang = ortb2.wlang; const cur = CURRENCY; const endpointUrl = config.getConfig('outbrain.bidderUrl'); const timeout = bidderRequest.timeout; @@ -80,6 +86,8 @@ export const spec = { assets: getNativeAssets(bid) }) } + } else if (isVideoRequest(bid)) { + imp.video = getVideoAsset(bid); } else { imp.banner = { format: transformSizes(bid.sizes) @@ -97,7 +105,7 @@ export const spec = { }); const request = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, site: { page, publisher }, device: { ua }, source: { fd: 1 }, @@ -106,6 +114,7 @@ export const spec = { imp: imps, bcat: bcat, badv: badv, + wlang: wlang, ext: { prebid: { channel: { @@ -157,7 +166,12 @@ export const spec = { return bids.map((bid, id) => { const bidResponse = bidResponses[id]; if (bidResponse) { - const type = bid.nativeParams ? NATIVE : BANNER; + let type = BANNER; + if (bid.nativeParams) { + type = NATIVE; + } else if (isVideoRequest(bid)) { + type = VIDEO; + } const bidObject = { requestId: bid.bidId, cpm: bidResponse.price, @@ -170,10 +184,16 @@ export const spec = { }; if (type === NATIVE) { bidObject.native = parseNative(bidResponse); - } else { + } else if (type === BANNER) { bidObject.ad = bidResponse.adm; bidObject.width = bidResponse.w; bidObject.height = bidResponse.h; + } else if (type === VIDEO) { + bidObject.vastXml = bidResponse.adm; + const videoContext = deepAccess(bid, 'mediaTypes.video.context'); + if (videoContext === OUTSTREAM) { + bidObject.renderer = createRenderer(bid); + } } bidObject.meta = {}; if (bidResponse.adomain && bidResponse.adomain.length > 0) { @@ -298,6 +318,27 @@ function getNativeAssets(bid) { }).filter(Boolean); } +function getVideoAsset(bid) { + const sizes = flatten(bid.mediaTypes.video.playerSize); + return { + w: parseInt(sizes[0], 10), + h: parseInt(sizes[1], 10), + protocols: bid.mediaTypes.video.protocols, + playbackmethod: bid.mediaTypes.video.playbackmethod, + mimes: bid.mediaTypes.video.mimes, + skip: bid.mediaTypes.video.skip, + delivery: bid.mediaTypes.video.delivery, + api: bid.mediaTypes.video.api, + minbitrate: bid.mediaTypes.video.minbitrate, + maxbitrate: bid.mediaTypes.video.maxbitrate, + minduration: bid.mediaTypes.video.minduration, + maxduration: bid.mediaTypes.video.maxduration, + startdelay: bid.mediaTypes.video.startdelay, + placement: bid.mediaTypes.video.placement, + linearity: bid.mediaTypes.video.linearity + }; +} + /* Turn bid request sizes into ut-compatible format */ function transformSizes(requestSizes) { if (!isArray(requestSizes)) { @@ -332,3 +373,63 @@ function _getFloor(bid, type) { } return null; } + +function isVideoRequest(bid) { + return bid.mediaType === 'video' || !!deepAccess(bid, 'mediaTypes.video'); +} + +function createRenderer(bid) { + let config = {}; + let playerUrl = OUTSTREAM_RENDERER_URL; + let render = function (bid) { + bid.renderer.push(() => { + window.ANOutstreamVideo.renderAd({ + sizes: bid.sizes, + targetId: bid.adUnitCode, + adResponse: { content: bid.vastXml } + }); + }); + }; + + let externalRenderer = deepAccess(bid, 'mediaTypes.video.renderer'); + if (!externalRenderer) { + externalRenderer = deepAccess(bid, 'renderer'); + } + + if (externalRenderer) { + config = externalRenderer.options; + playerUrl = externalRenderer.url; + render = externalRenderer.render; + } + + const renderer = Renderer.install({ + id: bid.adUnitCode, + url: playerUrl, + config: config, + adUnitCode: bid.adUnitCode, + loaded: false + }); + try { + renderer.setRender(render); + } catch (err) { + logWarn('Prebid Error calling setRender on renderer', err); + } + return renderer; +} + +function isValidVideoRequest(bid) { + const videoAdUnit = deepAccess(bid, 'mediaTypes.video') + if (!videoAdUnit) { + return false; + } + + if (!Array.isArray(videoAdUnit.playerSize)) { + return false; + } + + if (videoAdUnit.context == '') { + return false; + } + + return true; +} diff --git a/modules/outconAdapter.md b/modules/outconAdapter.md deleted file mode 100644 index 88ed45396bc..00000000000 --- a/modules/outconAdapter.md +++ /dev/null @@ -1,26 +0,0 @@ -# Overview - -``` -Module Name: outconAdapter -Module Type: Bidder Adapter -Maintainer: mfolmer@dokkogroup.com.ar -``` - -# Description - -Module that connects to Outcon demand sources - -# Test Parameters -``` - var adUnits = [ - { - bidder: 'outcon', - params: { - internalId: '12345678', - publisher: '5d5d66f2306ea4114a37c7c2', - bidId: '123456789', - env: 'test' - } - } - ]; -``` \ No newline at end of file diff --git a/modules/oxxionAnalyticsAdapter.js b/modules/oxxionAnalyticsAdapter.js new file mode 100644 index 00000000000..cc69443d8bf --- /dev/null +++ b/modules/oxxionAnalyticsAdapter.js @@ -0,0 +1,257 @@ +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; +import CONSTANTS from '../src/constants.json'; +import { ajax } from '../src/ajax.js'; +import { getRefererInfo } from '../src/refererDetection.js'; + +const analyticsType = 'endpoint'; +const url = 'URL_TO_SERVER_ENDPOINT'; + +const { + EVENTS: { + AUCTION_END, + BID_WON, + BID_RESPONSE, + BID_REQUESTED, + BID_TIMEOUT, + } +} = CONSTANTS; + +let saveEvents = {} +let allEvents = {} +let auctionEnd = {} +let initOptions = {} +let mode = {}; +let endpoint = 'https://default' +let requestsAttributes = ['adUnitCode', 'auctionId', 'bidder', 'bidderCode', 'bidId', 'cpm', 'creativeId', 'currency', 'width', 'height', 'mediaType', 'netRevenue', 'originalCpm', 'originalCurrency', 'requestId', 'size', 'source', 'status', 'timeToRespond', 'transactionId', 'ttl', 'sizes', 'mediaTypes', 'src', 'params', 'userId', 'labelAny', 'bids', 'adId']; + +function getAdapterNameForAlias(aliasName) { + return adapterManager.aliasRegistry[aliasName] || aliasName; +} + +function filterAttributes(arg, removead) { + let response = {}; + if (typeof arg == 'object') { + if (typeof arg['bidderCode'] == 'string') { + response['originalBidder'] = getAdapterNameForAlias(arg['bidderCode']); + } else if (typeof arg['bidder'] == 'string') { + response['originalBidder'] = getAdapterNameForAlias(arg['bidder']); + } + if (!removead && typeof arg['ad'] != 'undefined') { + response['ad'] = arg['ad']; + } + if (typeof arg['gdprConsent'] != 'undefined') { + response['gdprConsent'] = {}; + if (typeof arg['gdprConsent']['consentString'] != 'undefined') { + response['gdprConsent']['consentString'] = arg['gdprConsent']['consentString']; + } + } + if (typeof arg['meta'] == 'object') { + response['meta'] = {}; + if (typeof arg['meta']['advertiserDomains'] != 'undefined') { + response['meta']['advertiserDomains'] = arg['meta']['advertiserDomains']; + } + if (typeof arg['meta']['demandSource'] == 'string') { + response['meta']['demandSource'] = arg['meta']['demandSource']; + } + } + requestsAttributes.forEach((attr) => { + if (typeof arg[attr] != 'undefined') { response[attr] = arg[attr]; } + }); + if (typeof response['creativeId'] == 'number') { + response['creativeId'] = response['creativeId'].toString(); + } + } + response['oxxionMode'] = mode; + return response; +} + +function cleanAuctionEnd(args) { + let response = {}; + let filteredObj; + let objects = ['bidderRequests', 'bidsReceived', 'noBids', 'adUnits']; + objects.forEach((attr) => { + if (Array.isArray(args[attr])) { + response[attr] = []; + args[attr].forEach((obj) => { + filteredObj = filterAttributes(obj, true); + if (typeof obj['bids'] == 'object') { + filteredObj['bids'] = []; + obj['bids'].forEach((bid) => { + filteredObj['bids'].push(filterAttributes(bid, true)); + }); + } + response[attr].push(filteredObj); + }); + } + }); + return response; +} + +function cleanCreatives(args) { + let stringArgs = JSON.parse(dereferenceWithoutRenderer(args)); + return filterAttributes(stringArgs, false); +} + +function enhanceMediaType(arg) { + saveEvents['bidRequested'].forEach((bidRequested) => { + if (bidRequested['auctionId'] == arg['auctionId'] && Array.isArray(bidRequested['bids'])) { + bidRequested['bids'].forEach((bid) => { + if (bid['transactionId'] == arg['transactionId'] && bid['bidId'] == arg['requestId']) { arg['mediaTypes'] = bid['mediaTypes']; } + }); + } + }); + return arg; +} + +function addBidResponse(args) { + let eventType = BID_RESPONSE; + let argsCleaned = cleanCreatives(args); ; + if (allEvents[eventType] == undefined) { allEvents[eventType] = [] } + allEvents[eventType].push(argsCleaned); +} + +function addBidRequested(args) { + let eventType = BID_REQUESTED; + let argsCleaned = filterAttributes(args, true); + if (saveEvents[eventType] == undefined) { saveEvents[eventType] = [] } + saveEvents[eventType].push(argsCleaned); +} + +function addTimeout(args) { + let eventType = BID_TIMEOUT; + if (saveEvents[eventType] == undefined) { saveEvents[eventType] = [] } + saveEvents[eventType].push(args); + let argsCleaned = []; + let argsDereferenced = {}; + let stringArgs = JSON.parse(dereferenceWithoutRenderer(args)); + argsDereferenced = stringArgs; + argsDereferenced.forEach((attr) => { + argsCleaned.push(filterAttributes(JSON.parse(JSON.stringify(attr)), false)); + }); + if (auctionEnd[eventType] == undefined) { auctionEnd[eventType] = [] } + auctionEnd[eventType].push(argsCleaned); +} + +export const dereferenceWithoutRenderer = function(args) { + if (args.renderer) { + let tmp = args.renderer; + delete args.renderer; + let stringified = JSON.stringify(args); + args['renderer'] = tmp; + return stringified; + } + if (args.bidsReceived) { + let tmp = {} + for (let key in args.bidsReceived) { + if (args.bidsReceived[key].renderer) { + tmp[key] = args.bidsReceived[key].renderer; + delete args.bidsReceived[key].renderer; + } + } + let stringified = JSON.stringify(args); + for (let key in tmp) { + args.bidsReceived[key].renderer = tmp[key]; + } + return stringified; + } + return JSON.stringify(args); +} + +function addAuctionEnd(args) { + let eventType = AUCTION_END; + if (saveEvents[eventType] == undefined) { saveEvents[eventType] = [] } + saveEvents[eventType].push(args); + let argsCleaned = cleanAuctionEnd(JSON.parse(dereferenceWithoutRenderer(args))); + if (auctionEnd[eventType] == undefined) { auctionEnd[eventType] = [] } + auctionEnd[eventType].push(argsCleaned); +} + +function handleBidWon(args) { + args = enhanceMediaType(filterAttributes(JSON.parse(dereferenceWithoutRenderer(args)), true)); + let increment = args['cpm']; + if (typeof saveEvents['auctionEnd'] == 'object') { + saveEvents['auctionEnd'].forEach((auction) => { + if (auction['auctionId'] == args['auctionId'] && typeof auction['bidsReceived'] == 'object') { + auction['bidsReceived'].forEach((bid) => { + if (bid['transactionId'] == args['transactionId'] && bid['adId'] != args['adId']) { + if (args['cpm'] < bid['cpm']) { + increment = 0; + } else if (increment > args['cpm'] - bid['cpm']) { + increment = args['cpm'] - bid['cpm']; + } + } + }); + } + }); + } + args['cpmIncrement'] = increment; + args['referer'] = encodeURIComponent(getRefererInfo().page || getRefererInfo().topmostLocation); + if (typeof saveEvents.bidRequested == 'object' && saveEvents.bidRequested.length > 0 && saveEvents.bidRequested[0].gdprConsent) { args.gdpr = saveEvents.bidRequested[0].gdprConsent; } + ajax(endpoint + '.oxxion.io/analytics/bid_won', null, JSON.stringify(args), {method: 'POST', withCredentials: true}); +} + +function handleAuctionEnd() { + ajax(endpoint + '.oxxion.io/analytics/auctions', function (data) { + let list = JSON.parse(data); + if (Array.isArray(list) && typeof allEvents['bidResponse'] != 'undefined') { + let alreadyCalled = []; + allEvents['bidResponse'].forEach((bidResponse) => { + let tmpId = bidResponse['originalBidder'] + '_' + bidResponse['creativeId']; + if (list.includes(tmpId) && !alreadyCalled.includes(tmpId)) { + alreadyCalled.push(tmpId); + ajax(endpoint + '.oxxion.io/analytics/creatives', null, JSON.stringify(bidResponse), {method: 'POST', withCredentials: true}); + } + }); + } + allEvents = {}; + }, JSON.stringify(auctionEnd), {method: 'POST', withCredentials: true}); + auctionEnd = {}; +} + +let oxxionAnalytics = Object.assign(adapter({url, analyticsType}), { + track({ + eventType, + args + }) { + switch (eventType) { + case AUCTION_END: + addAuctionEnd(args); + handleAuctionEnd(); + break; + case BID_WON: + handleBidWon(args); + break; + case BID_RESPONSE: + addBidResponse(args); + break; + case BID_REQUESTED: + addBidRequested(args); + break; + case BID_TIMEOUT: + addTimeout(args); + break; + } + }}); + +// save the base class function +oxxionAnalytics.originEnableAnalytics = oxxionAnalytics.enableAnalytics; + +// override enableAnalytics so we can get access to the config passed in from the page +oxxionAnalytics.enableAnalytics = function (config) { + oxxionAnalytics.originEnableAnalytics(config); // call the base class function + initOptions = config.options; + if (initOptions.domain) { + endpoint = 'https://' + initOptions.domain; + } + if (window.OXXION_MODE) { + mode = window.OXXION_MODE; + } +}; + +adapterManager.registerAnalyticsAdapter({ + adapter: oxxionAnalytics, + code: 'oxxion' +}); + +export default oxxionAnalytics; diff --git a/modules/oxxionAnalyticsAdapter.md b/modules/oxxionAnalyticsAdapter.md new file mode 100644 index 00000000000..506f013eb37 --- /dev/null +++ b/modules/oxxionAnalyticsAdapter.md @@ -0,0 +1,33 @@ +# Overview +Module Name: oxxion Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: tech@oxxion.io + +# Oxxion Analytics Adapter + +Oxxion helps you to understand how your prebid stack performs. + +# Integration + +Add the oxxion analytics adapter module to your prebid configuration : +``` +pbjs.enableAnalytics( + ... + { + provider: 'oxxion', + options : { + domain: 'test.endpoint' + } + } + ... +) +``` + +# Parameters + +| Name | Type | Description | +|:-------------------------------|:---------|:------------------------------------------------------------------------------------------------------------| +| domain | String | This string identifies yourself in Oxxion's systems and is provided to you by your Oxxion representative. | + diff --git a/modules/oxxionRtdProvider.js b/modules/oxxionRtdProvider.js new file mode 100644 index 00000000000..c6f8b9a902b --- /dev/null +++ b/modules/oxxionRtdProvider.js @@ -0,0 +1,210 @@ +import { submodule } from '../src/hook.js' +import { deepAccess, logInfo, logError } from '../src/utils.js' +import { ajax } from '../src/ajax.js'; +import adapterManager from '../src/adapterManager.js'; + +const oxxionRtdSearchFor = [ 'adUnitCode', 'auctionId', 'bidder', 'bidderCode', 'bidId', 'cpm', 'creativeId', 'currency', 'width', 'height', 'mediaType', 'netRevenue', 'originalCpm', 'originalCurrency', 'requestId', 'size', 'source', 'status', 'timeToRespond', 'transactionId', 'ttl', 'sizes', 'mediaTypes', 'src', 'userId', 'labelAny', 'adId' ]; +const LOG_PREFIX = 'oxxionRtdProvider submodule: '; + +const allAdUnits = []; +const bidderAliasRegistry = adapterManager.aliasRegistry || {}; + +/** @type {RtdSubmodule} */ +export const oxxionSubmodule = { + name: 'oxxionRtd', + init: init, + getBidRequestData: getAdUnits, + onBidResponseEvent: insertVideoTracking, + getRequestsList: getRequestsList, + getFilteredAdUnitsOnBidRates: getFilteredAdUnitsOnBidRates, +}; + +function init(config, userConsent) { + if (!config.params || !config.params.domain) { return false } + if (config.params.contexts && Array.isArray(config.params.contexts) && config.params.contexts.length > 0) { return true; } + if (typeof config.params.threshold != 'undefined' && typeof config.params.samplingRate == 'number') { return true } + return false; +} + +function getAdUnits(reqBidsConfigObj, callback, config, userConsent) { + logInfo(LOG_PREFIX + 'started with ', config); + if (typeof config.params.threshold != 'undefined' && typeof config.params.samplingRate == 'number') { + let filteredBids; + const requests = getRequestsList(reqBidsConfigObj); + const gdpr = userConsent && userConsent.gdpr ? userConsent.gdpr.consentString : null; + const payload = { + gdpr, + requests + }; + const endpoint = 'https://' + config.params.domain + '.oxxion.io/analytics/bid_rate_interests'; + getPromisifiedAjax(endpoint, JSON.stringify(payload), { + method: 'POST', + withCredentials: true + }).then(bidsRateInterests => { + if (bidsRateInterests.length) { + [reqBidsConfigObj.adUnits, filteredBids] = getFilteredAdUnitsOnBidRates(bidsRateInterests, reqBidsConfigObj.adUnits, config.params, true); + } + if (filteredBids.length > 0) { + getPromisifiedAjax('https://' + config.params.domain + '.oxxion.io/analytics/request_rejecteds', JSON.stringify({'bids': filteredBids, 'gdpr': gdpr}), { + method: 'POST', + withCredentials: true + }); + } + if (typeof callback == 'function') { callback(); } + }).catch(error => logError(LOG_PREFIX, 'bidInterestError', error)); + } + if (config.params.contexts && Array.isArray(config.params.contexts) && config.params.contexts.length > 0) { + const reqAdUnits = reqBidsConfigObj.adUnits; + if (Array.isArray(reqAdUnits)) { + reqAdUnits.forEach(adunit => { + if (config.params.contexts.includes(deepAccess(adunit, 'mediaTypes.video.context'))) { + allAdUnits.push(adunit); + } + }); + } + if (!(typeof config.params.threshold != 'undefined' && typeof config.params.samplingRate == 'number') && typeof callback == 'function') { + callback(); + } + } +} + +function insertVideoTracking(bidResponse, config, userConsent) { + // this should only be do for video bids + if (bidResponse.mediaType === 'video') { + let maxCpm = 0; + const trackingUrl = getImpUrl(config, bidResponse, maxCpm); + if (!trackingUrl) { + return; + } + // Vast Impression URL + if (bidResponse.vastUrl) { + bidResponse.vastImpUrl = bidResponse.vastImpUrl + ? trackingUrl + '&url=' + encodeURI(bidResponse.vastImpUrl) + : trackingUrl; + logInfo(LOG_PREFIX + 'insert into vastImpUrl for adId ' + bidResponse.adId); + } + // Vast XML document + if (bidResponse.vastXml !== undefined) { + const doc = new DOMParser().parseFromString(bidResponse.vastXml, 'text/xml'); + const wrappers = doc.querySelectorAll('VAST Ad Wrapper, VAST Ad InLine'); + let hasAltered = false; + if (wrappers.length) { + wrappers.forEach(wrapper => { + const impression = doc.createElement('Impression'); + impression.appendChild(doc.createCDATASection(trackingUrl)); + wrapper.appendChild(impression) + }); + bidResponse.vastXml = new XMLSerializer().serializeToString(doc); + hasAltered = true; + } + if (hasAltered) { + logInfo(LOG_PREFIX + 'insert into vastXml for adId ' + bidResponse.adId); + } + } + } +} + +function getImpUrl(config, data, maxCpm) { + const adUnitCode = data.adUnitCode; + const adUnits = allAdUnits.find(adunit => adunit.code === adUnitCode && + 'mediaTypes' in adunit && + 'video' in adunit.mediaTypes && + typeof adunit.mediaTypes.video.context === 'string'); + const context = adUnits !== undefined + ? adUnits.mediaTypes.video.context + : 'unknown'; + if (!config.params.contexts.includes(context)) { + return false; + } + let trackingImpUrl = 'https://' + config.params.domain + '.oxxion.io/analytics/vast_imp?'; + trackingImpUrl += oxxionRtdSearchFor.reduce((acc, param) => { + switch (typeof data[param]) { + case 'string': + case 'number': + acc += param + '=' + data[param] + '&' + break; + } + return acc; + }, ''); + const cpmIncrement = 0.0; + return trackingImpUrl + 'cpmIncrement=' + cpmIncrement + '&context=' + context; +} + +function getPromisifiedAjax (url, data = {}, options = {}) { + return new Promise((resolve, reject) => { + const callbacks = { + success(responseText, { response }) { + resolve(JSON.parse(response)); + }, + error(error) { + reject(error); + } + }; + ajax(url, callbacks, data, options); + }) +} + +function getFilteredAdUnitsOnBidRates (bidsRateInterests, adUnits, params, useSampling) { + const { threshold, samplingRate } = params; + const filteredBids = []; + // Separate bidsRateInterests in two groups against threshold & samplingRate + const { interestingBidsRates, uninterestingBidsRates } = bidsRateInterests.reduce((acc, interestingBid) => { + const isBidRateUpper = typeof threshold == 'number' ? interestingBid.rate === true || interestingBid.rate > threshold : interestingBid.suggestion; + const isBidInteresting = isBidRateUpper || (getRandomNumber(100) < samplingRate && useSampling); + const key = isBidInteresting ? 'interestingBidsRates' : 'uninterestingBidsRates'; + acc[key].push(interestingBid); + return acc; + }, { + interestingBidsRates: [], + uninterestingBidsRates: [] // Do something with later + }); + logInfo(LOG_PREFIX, 'getFilteredAdUnitsOnBidRates()', interestingBidsRates, uninterestingBidsRates); + // Filter bids and adUnits against interesting bids rates + const newAdUnits = adUnits.filter(({ bids = [] }, adUnitIndex) => { + adUnits[adUnitIndex].bids = bids.filter(bid => { + if (!params.bidders || params.bidders.includes(bid.bidder)) { + const index = interestingBidsRates.findIndex(({ id }) => id === bid._id); + if (index == -1) { + let tmpBid = bid; + tmpBid['code'] = adUnits[adUnitIndex].code; + tmpBid['mediaTypes'] = adUnits[adUnitIndex].mediaTypes; + tmpBid['originalBidder'] = bidderAliasRegistry[bid.bidder] || bid.bidder; + if (tmpBid.floorData) { + delete tmpBid.floorData; + } + filteredBids.push(tmpBid); + } + delete bid._id; + return index !== -1; + } else { + return true; + } + }); + return !!adUnits[adUnitIndex].bids.length; + }); + return [newAdUnits, filteredBids]; +} + +function getRandomNumber (max = 10) { + return Math.round(Math.random() * max); +} + +function getRequestsList(reqBidsConfigObj) { + let count = 0; + return reqBidsConfigObj.adUnits.flatMap(({ + bids = [], + mediaTypes = {}, + code = '' + }) => bids.reduce((acc, { bidder = '', params = {} }, index) => { + const id = count++; + bids[index]._id = id; + return acc.concat({ + id, + adUnit: code, + bidder, + mediaTypes, + }); + }, [])); +} + +submodule('realTimeData', oxxionSubmodule); diff --git a/modules/oxxionRtdProvider.md b/modules/oxxionRtdProvider.md new file mode 100644 index 00000000000..14b4abec5c2 --- /dev/null +++ b/modules/oxxionRtdProvider.md @@ -0,0 +1,63 @@ +# Overview + +Module Name: Oxxion Rtd Provider +Module Type: Rtd Provider +Maintainer: tech@oxxion.io + +# Oxxion Real-Time-Data submodule + +Oxxion helps you to understand how your prebid stack performs. +This Rtd module is to use in order to improve video events tracking and/or to filter bidder requested. + +# Integration + +Make sure to have the following modules listed while building prebid : `rtdModule,oxxionRtdProvider` +`rtdModule` is required to activate real-time-data submodules. +For example : +``` +gulp build --modules=schain,priceFloors,currency,consentManagement,appnexusBidAdapter,rubiconBidAdapter,rtdModule,oxxionRtdProvider +``` + +Then add the oxxion Rtd module to your prebid configuration : +``` +pbjs.setConfig( + ... + realTimeData: { + auctionDelay: 300, + dataProviders: [ + { + name: "oxxionRtd", + waitForIt: true, + params: { + domain: "test.endpoint", + contexts: ["instream"], + threshold: false, + samplingRate: 10, + } + } + ] + } + ... +) +``` + +# setConfig Parameters General + +| Name | Type | Description | +|:---------------------------------|:---------|:------------------------------------------------------------------------------------------------------------| +| domain | String | This string identifies yourself in Oxxion's systems and is provided to you by your Oxxion representative. | + +# setConfig Parameters for Video Tracking + +| Name | Type | Description | +|:---------------------------------|:---------|:------------------------------------------------------------------------------------------------------------| +| contexts | Array | Array defining which video contexts to add tracking events into. Values can be instream and/or outstream. | + +# setConfig Parameters for bidder filtering + +| Name | Type | Description | +|:---------------------------------|:-----------|:------------------------------------------------------------------------------------------------------------| +| threshold | Float/Bool | False or minimum expected bid rate to call a bidder (ex: 1.0 for 1% bid rate). | +| samplingRate | Integer | Percentage of request not meeting the criterias to run anyway in order to check for any change. | +| bidders | Array | Optional: If set, filtering will only be applied to bidders listed. + diff --git a/modules/ozoneBidAdapter.js b/modules/ozoneBidAdapter.js index 3b5147907eb..970c7d49fb9 100644 --- a/modules/ozoneBidAdapter.js +++ b/modules/ozoneBidAdapter.js @@ -1,22 +1,31 @@ -import { logInfo, logError, deepAccess, logWarn, deepSetValue, isArray, contains, isStr, mergeDeep } from '../src/utils.js'; +import { + logInfo, + logError, + deepAccess, + logWarn, + deepSetValue, + isArray, + contains, + mergeDeep, + parseUrl, + generateUUID +} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {getPriceBucketString} from '../src/cpmBucketManager.js'; import { Renderer } from '../src/Renderer.js'; - +import {getRefererInfo} from '../src/refererDetection.js'; const BIDDER_CODE = 'ozone'; - const ORIGIN = 'https://elb.the-ozone-project.com' // applies only to auction & cookie const AUCTIONURI = '/openrtb2/auction'; const OZONECOOKIESYNC = '/static/load-cookie.html'; const OZONE_RENDERER_URL = 'https://prebid.the-ozone-project.com/ozone-renderer.js'; const ORIGIN_DEV = 'https://test.ozpr.net'; - -const OZONEVERSION = '2.7.0'; +const OZONEVERSION = '2.9.0'; export const spec = { gvlid: 524, - aliases: [{code: 'lmc', gvlid: 524}, {code: 'newspassid', gvlid: 524}], + aliases: [{code: 'lmc', gvlid: 524}], version: OZONEVERSION, code: BIDDER_CODE, supportedMediaTypes: [VIDEO, BANNER], @@ -28,12 +37,9 @@ export const spec = { 'keyPrefix': 'oz', 'auctionUrl': ORIGIN + AUCTIONURI, 'cookieSyncUrl': ORIGIN + OZONECOOKIESYNC, - 'rendererUrl': OZONE_RENDERER_URL + 'rendererUrl': OZONE_RENDERER_URL, + 'batchRequests': false /* you can change this to true OR override it in the config: config.ozone.batchRequests */ }, - /** - * make sure that the whitelabel/default values are available in the propertyBag - * @param bid Object : the bid - */ loadWhitelabelData(bid) { if (this.propertyBag.whitelabel) { return; } this.propertyBag.whitelabel = JSON.parse(JSON.stringify(this.whitelabel_defaults)); @@ -52,7 +58,6 @@ export const spec = { this.propertyBag.whitelabel.auctionUrl = bidderConfig.endpointOverride.origin + AUCTIONURI; this.propertyBag.whitelabel.cookieSyncUrl = bidderConfig.endpointOverride.origin + OZONECOOKIESYNC; } - if (arr.hasOwnProperty('renderer')) { if (arr.renderer.match('%3A%2F%2F')) { this.propertyBag.whitelabel.rendererUrl = decodeURIComponent(arr['renderer']); @@ -70,6 +75,9 @@ export const spec = { this.propertyBag.whitelabel.auctionUrl = bidderConfig.endpointOverride.auctionUrl; } } + if (bidderConfig.hasOwnProperty('batchRequests')) { + this.propertyBag.whitelabel.batchRequests = bidderConfig.batchRequests; + } try { if (arr.hasOwnProperty('auction') && arr.auction === 'dev') { logInfo('GET: auction=dev'); @@ -91,11 +99,9 @@ export const spec = { getRendererUrl() { return this.propertyBag.whitelabel.rendererUrl; }, - /** - * Basic check to see whether required parameters are in the request. - * @param bid - * @returns {boolean} - */ + isBatchRequests() { + return this.propertyBag.whitelabel.batchRequests; + }, isBidRequestValid(bid) { this.loadWhitelabelData(bid); logInfo('isBidRequestValid : ', config.getConfig(), bid); @@ -114,7 +120,7 @@ export const spec = { return false; } if (!(bid.params.publisherId).toString().match(/^[a-zA-Z0-9\-]{12}$/)) { - logError('VALIDATION FAILED : publisherId must be exactly 12 alphanumieric characters including hyphens', adUnitCode); + logError('VALIDATION FAILED : publisherId must be exactly 12 alphanumeric characters including hyphens', adUnitCode); return false; } if (!(bid.params.hasOwnProperty('siteId'))) { @@ -159,15 +165,9 @@ export const spec = { } return true; }, - - /** - * Split this out so that we can validate the placementId and also the override GET parameter ozstoredrequest - * @param placementId - */ isValidPlacementId(placementId) { return placementId.toString().match(/^[0-9]{10}$/); }, - buildRequests(validBidRequests, bidderRequest) { this.loadWhitelabelData(validBidRequests[0]); this.propertyBag.buildRequestsStart = new Date().getTime(); @@ -189,14 +189,13 @@ export const spec = { singleRequest = singleRequest !== false; // undefined & true will be true logInfo(`config ${whitelabelBidder}.singleRequest : `, singleRequest); let ozoneRequest = {}; // we only want to set specific properties on this, not validBidRequests[0].params - delete ozoneRequest.test; // don't allow test to be set in the config - ONLY use $_GET['pbjs_debug'] - - let fpd = config.getConfig('ortb2'); + logInfo('going to get ortb2 from bidder request...'); + let fpd = deepAccess(bidderRequest, 'ortb2', null); + logInfo('got fpd: ', fpd); if (fpd && deepAccess(fpd, 'user')) { logInfo('added FPD user object'); ozoneRequest.user = fpd.user; } - const getParams = this.getGetParametersAsObject(); const wlOztestmodeKey = whitelabelPrefix + 'testmode'; const isTestMode = getParams[wlOztestmodeKey] || null; // this can be any string, it's used for testing ads @@ -208,7 +207,8 @@ export const spec = { let placementId = placementIdOverrideFromGetParam || this.getPlacementId(ozoneBidRequest); // prefer to use a valid override param, else the bidRequest placement Id obj.id = ozoneBidRequest.bidId; // this causes an error if we change it to something else, even if you update the bidRequest object: "WARNING: Bidder ozone made bid for unknown request ID: mb7953.859498327448. Ignoring." obj.tagid = placementId; - obj.secure = window.location.protocol === 'https:' ? 1 : 0; + let parsed = parseUrl(this.getRefererInfo().page); + obj.secure = parsed.protocol === 'https' ? 1 : 0; let arrBannerSizes = []; if (!ozoneBidRequest.hasOwnProperty('mediaTypes')) { if (ozoneBidRequest.hasOwnProperty('sizes')) { @@ -271,7 +271,6 @@ export const spec = { deepSetValue(obj, 'ext.prebid', {'storedrequest': {'id': placementId}}); obj.ext[whitelabelBidder] = {}; obj.ext[whitelabelBidder].adUnitCode = ozoneBidRequest.adUnitCode; // eg. 'mpu' - obj.ext[whitelabelBidder].transactionId = ozoneBidRequest.transactionId; // this is the transactionId PER adUnit, common across bidders for this unit if (ozoneBidRequest.params.hasOwnProperty('customData')) { obj.ext[whitelabelBidder].customData = ozoneBidRequest.params.customData; } @@ -288,7 +287,7 @@ export const spec = { } } if (fpd && deepAccess(fpd, 'site')) { - logInfo('added fpd.site'); + logInfo('adding fpd.site'); if (deepAccess(obj, 'ext.' + whitelabelBidder + '.customData.0.targeting', false)) { obj.ext[whitelabelBidder].customData[0].targeting = Object.assign(obj.ext[whitelabelBidder].customData[0].targeting, fpd.site); } else { @@ -298,9 +297,12 @@ export const spec = { if (!schain && deepAccess(ozoneBidRequest, 'schain')) { schain = ozoneBidRequest.schain; } + let gpid = deepAccess(ozoneBidRequest, 'ortb2Imp.ext.gpid'); + if (gpid) { + deepSetValue(obj, 'ext.gpid', gpid); + } return obj; }); - let extObj = {}; extObj[whitelabelBidder] = {}; extObj[whitelabelBidder][whitelabelPrefix + '_pb_v'] = OZONEVERSION; @@ -311,8 +313,7 @@ export const spec = { extObj[whitelabelBidder].pubcid = userIds.pubcid; } } - - extObj[whitelabelBidder].pv = this.getPageId(); // attach the page ID that will be common to all auciton calls for this page if refresh() is called + extObj[whitelabelBidder].pv = this.getPageId(); // attach the page ID that will be common to all auction calls for this page if refresh() is called let ozOmpFloorDollars = this.getWhitelabelConfigItem('ozone.oz_omp_floor'); // valid only if a dollar value (typeof == 'number') logInfo(`${whitelabelPrefix}_omp_floor dollar value = `, ozOmpFloorDollars); if (typeof ozOmpFloorDollars === 'number') { @@ -323,25 +324,22 @@ export const spec = { let ozWhitelistAdserverKeys = this.getWhitelabelConfigItem('ozone.oz_whitelist_adserver_keys'); let useOzWhitelistAdserverKeys = isArray(ozWhitelistAdserverKeys) && ozWhitelistAdserverKeys.length > 0; extObj[whitelabelBidder][whitelabelPrefix + '_kvp_rw'] = useOzWhitelistAdserverKeys ? 1 : 0; - if (whitelabelBidder != 'ozone') { + if (whitelabelBidder !== 'ozone') { logInfo('setting aliases object'); extObj.prebid = {aliases: {'ozone': whitelabelBidder}}; } - if (getParams.hasOwnProperty('ozf')) { extObj[whitelabelBidder]['ozf'] = getParams.ozf == 'true' || getParams.ozf == 1 ? 1 : 0; } - if (getParams.hasOwnProperty('ozpf')) { extObj[whitelabelBidder]['ozpf'] = getParams.ozpf == 'true' || getParams.ozpf == 1 ? 1 : 0; } + if (getParams.hasOwnProperty('ozf')) { extObj[whitelabelBidder]['ozf'] = getParams.ozf === 'true' || getParams.ozf === '1' ? 1 : 0; } + if (getParams.hasOwnProperty('ozpf')) { extObj[whitelabelBidder]['ozpf'] = getParams.ozpf === 'true' || getParams.ozpf === '1' ? 1 : 0; } if (getParams.hasOwnProperty('ozrp') && getParams.ozrp.match(/^[0-3]$/)) { extObj[whitelabelBidder]['ozrp'] = parseInt(getParams.ozrp); } if (getParams.hasOwnProperty('ozip') && getParams.ozip.match(/^\d+$/)) { extObj[whitelabelBidder]['ozip'] = parseInt(getParams.ozip); } if (this.propertyBag.endpointOverride != null) { extObj[whitelabelBidder]['origin'] = this.propertyBag.endpointOverride; } - - var userExtEids = this.generateEids(validBidRequests); // generate the UserIDs in the correct format for UserId module - + let userExtEids = deepAccess(validBidRequests, '0.userIdAsEids', []); // generate the UserIDs in the correct format for UserId module ozoneRequest.site = { 'publisher': {'id': htmlParams.publisherId}, - 'page': document.location.href, + 'page': this.getRefererInfo().page, 'id': htmlParams.siteId }; - ozoneRequest.test = (getParams.hasOwnProperty('pbjs_debug') && getParams['pbjs_debug'] === 'true') ? 1 : 0; - + ozoneRequest.test = config.getConfig('debug') ? 1 : 0; if (bidderRequest && bidderRequest.gdprConsent) { logInfo('ADDING GDPR info'); let apiVersion = deepAccess(bidderRequest, 'gdprConsent.apiVersion', 1); @@ -355,27 +353,45 @@ export const spec = { logInfo('WILL NOT ADD GDPR info; no bidderRequest.gdprConsent object'); } if (bidderRequest && bidderRequest.uspConsent) { - logInfo('ADDING CCPA info'); - deepSetValue(ozoneRequest, 'user.ext.uspConsent', bidderRequest.uspConsent); + logInfo('ADDING USP consent info'); + deepSetValue(ozoneRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); } else { - logInfo('WILL NOT ADD CCPA info; no bidderRequest.uspConsent.'); + logInfo('WILL NOT ADD USP consent info; no bidderRequest.uspConsent.'); } if (schain) { // we set this while iterating over the bids logInfo('schain found'); deepSetValue(ozoneRequest, 'source.ext.schain', schain); } - if (config.getConfig('coppa') === true) { deepSetValue(ozoneRequest, 'regs.coppa', 1); } - + let ozUuid = generateUUID(); + if (this.isBatchRequests()) { + logInfo('going to batch the requests'); + let arrRet = []; // return an array of objects containing data describing max 10 bids + for (let i = 0; i < tosendtags.length; i += 10) { + ozoneRequest.id = ozUuid; // Unique ID of the bid request, provided by the exchange. (REQUIRED) + ozoneRequest.imp = tosendtags.slice(i, i + 10); + ozoneRequest.ext = extObj; + deepSetValue(ozoneRequest, 'user.ext.eids', userExtEids); + if (ozoneRequest.imp.length > 0) { + arrRet.push({ + method: 'POST', + url: this.getAuctionUrl(), + data: JSON.stringify(ozoneRequest), + bidderRequest: bidderRequest + }); + } + } + logInfo('batch request going to return : ', arrRet); + return arrRet; + } + logInfo('requests will not be batched.'); if (singleRequest) { logInfo('buildRequests starting to generate response for a single request'); - ozoneRequest.id = bidderRequest.auctionId; // Unique ID of the bid request, provided by the exchange. - ozoneRequest.auctionId = bidderRequest.auctionId; // not sure if this should be here? + ozoneRequest.id = ozUuid; // Unique ID of the bid request, provided by the exchange. (REQUIRED) ozoneRequest.imp = tosendtags; ozoneRequest.ext = extObj; - deepSetValue(ozoneRequest, 'source.tid', bidderRequest.auctionId);// RTB 2.5 : tid is Transaction ID that must be common across all participants in this bid request (e.g., potentially multiple exchanges). deepSetValue(ozoneRequest, 'user.ext.eids', userExtEids); var ret = { method: 'POST', @@ -391,12 +407,9 @@ export const spec = { let arrRet = tosendtags.map(imp => { logInfo('buildRequests starting to generate non-single response, working on imp : ', imp); let ozoneRequestSingle = Object.assign({}, ozoneRequest); - imp.ext[whitelabelBidder].pageAuctionId = bidderRequest['auctionId']; // make a note in the ext object of what the original auctionId was, in the bidderRequest object - ozoneRequestSingle.id = imp.ext[whitelabelBidder].transactionId; // Unique ID of the bid request, provided by the exchange. - ozoneRequestSingle.auctionId = imp.ext[whitelabelBidder].transactionId; // not sure if this should be here? + ozoneRequestSingle.id = generateUUID(); // Unique ID of the bid request, provided by the exchange. (REQUIRED) ozoneRequestSingle.imp = [imp]; ozoneRequestSingle.ext = extObj; - deepSetValue(ozoneRequestSingle, 'source.tid', imp.ext[whitelabelBidder].transactionId);// RTB 2.5 : tid is Transaction ID that must be common across all participants in this bid request (e.g., potentially multiple exchanges). deepSetValue(ozoneRequestSingle, 'user.ext.eids', userExtEids); logInfo('buildRequests RequestSingle (for non-single) = ', ozoneRequestSingle); return { @@ -410,19 +423,6 @@ export const spec = { logInfo(`buildRequests going to return for non-single at time ${this.propertyBag.buildRequestsEnd} (took ${this.propertyBag.buildRequestsEnd - this.propertyBag.buildRequestsStart}ms): `, arrRet); return arrRet; }, - /** - * parse a bidRequestRef that contains getFloor(), get all the data from it for the sizes & media requested for this bid & return an object containing floor data you can send to auciton endpoint - * @param bidRequestRef object = a valid bid request object reference - * @return object - * - * call: - * bidObj.getFloor({ - currency: 'USD', <- currency to return the value in - mediaType: ‘banner’, - size: ‘*’ <- or [300,250] or [[300,250],[640,480]] - * }); - * - */ getFloorObjectForAuction(bidRequestRef) { const mediaTypesSizes = { banner: deepAccess(bidRequestRef, 'mediaTypes.banner.sizes', null), @@ -443,16 +443,6 @@ export const spec = { logInfo('getFloorObjectForAuction returning : ', JSON.parse(JSON.stringify(ret))); return ret; }, - /** - * Interpret the response if the array contains BIDDER elements, in the format: [ [bidder1 bid 1, bidder1 bid 2], [bidder2 bid 1, bidder2 bid 2] ] - * NOte that in singleRequest mode this will be called once, else it will be called for each adSlot's response - * - * Updated April 2019 to return all bids, not just the one we decide is the 'winner' - * - * @param serverResponse - * @param request - * @returns {*} - */ interpretResponse(serverResponse, request) { if (request && request.bidderRequest && request.bidderRequest.bids) { this.loadWhitelabelData(request.bidderRequest.bids[0]); } let startTime = new Date().getTime(); @@ -461,6 +451,7 @@ export const spec = { logInfo(`interpretResponse time: ${startTime} . Time between buildRequests done and interpretResponse start was ${startTime - this.propertyBag.buildRequestsEnd}ms`); logInfo(`serverResponse, request`, JSON.parse(JSON.stringify(serverResponse)), JSON.parse(JSON.stringify(request))); serverResponse = serverResponse.body || {}; + let aucId = serverResponse.id; // this will be correct for single requests and non-single if (!serverResponse.hasOwnProperty('seatbid')) { return []; } @@ -474,15 +465,12 @@ export const spec = { enhancedAdserverTargeting = true; } logInfo('enhancedAdserverTargeting', enhancedAdserverTargeting); - serverResponse.seatbid = injectAdIdsIntoAllBidResponses(serverResponse.seatbid); // we now make sure that each bid in the bidresponse has a unique (within page) adId attribute. - serverResponse.seatbid = this.removeSingleBidderMultipleBids(serverResponse.seatbid); let ozOmpFloorDollars = this.getWhitelabelConfigItem('ozone.oz_omp_floor'); // valid only if a dollar value (typeof == 'number') let addOzOmpFloorDollars = typeof ozOmpFloorDollars === 'number'; let ozWhitelistAdserverKeys = this.getWhitelabelConfigItem('ozone.oz_whitelist_adserver_keys'); let useOzWhitelistAdserverKeys = isArray(ozWhitelistAdserverKeys) && ozWhitelistAdserverKeys.length > 0; - for (let i = 0; i < serverResponse.seatbid.length; i++) { let sb = serverResponse.seatbid[i]; for (let j = 0; j < sb.bid.length; j++) { @@ -495,17 +483,30 @@ export const spec = { let isVideo = false; let bidType = deepAccess(thisBid, 'ext.prebid.type'); logInfo(`this bid type is : ${bidType}`, j); + let adserverTargeting = {}; if (bidType === VIDEO) { isVideo = true; + this.setBidMediaTypeIfNotExist(thisBid, VIDEO); videoContext = this.getVideoContextForBidId(thisBid.bidId, request.bidderRequest.bids); // should be instream or outstream (or null if error) if (videoContext === 'outstream') { - logInfo('going to attach a renderer to OUTSTREAM video : ', j); + logInfo('going to set thisBid.mediaType = VIDEO & attach a renderer to OUTSTREAM video : ', j); thisBid.renderer = newRenderer(thisBid.bidId); } else { - logInfo('bid is not an outstream video, will not attach a renderer: ', j); + logInfo('bid is not an outstream video, will set thisBid.mediaType = VIDEO and thisBid.vastUrl and not attach a renderer: ', j); + thisBid.vastUrl = `https://${deepAccess(thisBid, 'ext.prebid.targeting.hb_cache_host', 'missing_host')}${deepAccess(thisBid, 'ext.prebid.targeting.hb_cache_path', 'missing_path')}?id=${deepAccess(thisBid, 'ext.prebid.targeting.hb_cache_id', 'missing_id')}`; // need to see if this works ok for ozone + adserverTargeting['hb_cache_host'] = deepAccess(thisBid, 'ext.prebid.targeting.hb_cache_host', 'no-host'); + adserverTargeting['hb_cache_path'] = deepAccess(thisBid, 'ext.prebid.targeting.hb_cache_path', 'no-path'); + if (!thisBid.hasOwnProperty('videoCacheKey')) { + let videoCacheUuid = deepAccess(thisBid, 'ext.prebid.targeting.hb_uuid', 'no_hb_uuid'); + logInfo(`Adding videoCacheKey: ${videoCacheUuid}`); + thisBid.videoCacheKey = videoCacheUuid; + } else { + logInfo('videoCacheKey already exists on the bid object, will not add it'); + } } + } else { + this.setBidMediaTypeIfNotExist(thisBid, BANNER); } - let adserverTargeting = {}; if (enhancedAdserverTargeting) { let allBidsForThisBidid = ozoneGetAllBidsForBidId(thisBid.bidId, serverResponse.seatbid); logInfo('Going to iterate allBidsForThisBidId', allBidsForThisBidid); @@ -545,10 +546,11 @@ export const spec = { } } let {seat: winningSeat, bid: winningBid} = ozoneGetWinnerForRequestBid(thisBid.bidId, serverResponse.seatbid); - adserverTargeting[whitelabelPrefix + '_auc_id'] = String(request.bidderRequest.auctionId); + adserverTargeting[whitelabelPrefix + '_auc_id'] = String(aucId); // was request.bidderRequest.auctionId adserverTargeting[whitelabelPrefix + '_winner'] = String(winningSeat); adserverTargeting[whitelabelPrefix + '_bid'] = 'true'; - + adserverTargeting[whitelabelPrefix + '_cache_id'] = deepAccess(thisBid, 'ext.prebid.targeting.hb_cache_id', 'no-id'); + adserverTargeting[whitelabelPrefix + '_uuid'] = deepAccess(thisBid, 'ext.prebid.targeting.hb_uuid', 'no-id'); if (enhancedAdserverTargeting) { adserverTargeting[whitelabelPrefix + '_imp_id'] = String(winningBid.impid); adserverTargeting[whitelabelPrefix + '_pb_v'] = OZONEVERSION; @@ -566,26 +568,24 @@ export const spec = { } } let endTime = new Date().getTime(); - logInfo(`interpretResponse going to return at time ${endTime} (took ${endTime - startTime}ms) Time from buildRequests Start -> interpretRequests End = ${endTime - this.propertyBag.buildRequestsStart}ms`, arrAllBids); + logInfo(`interpretResponse going to return at time ${endTime} (took ${endTime - startTime}ms) Time from buildRequests Start -> interpretRequests End = ${endTime - this.propertyBag.buildRequestsStart}ms`); + logInfo('interpretResponse arrAllBids (serialised): ', JSON.parse(JSON.stringify(arrAllBids))); // this is ok to log because the renderer has not been attached yet return arrAllBids; }, - /** - * Use this to get all config values - * Now it's getting complicated with whitelabeling, this simplifies the code for getting config values. - * eg. to get whitelabelled version you just sent the ozone default string like ozone.oz_omp_floor - * @param ozoneVersion string like 'ozone.oz_omp_floor' - * @return {string|object} - */ + setBidMediaTypeIfNotExist(thisBid, mediaType) { + if (!thisBid.hasOwnProperty('mediaType')) { + logInfo(`setting thisBid.mediaType = ${mediaType}`); + thisBid.mediaType = mediaType; + } else { + logInfo(`found value for thisBid.mediaType: ${thisBid.mediaType}`); + } + }, getWhitelabelConfigItem(ozoneVersion) { - if (this.propertyBag.whitelabel.bidder == 'ozone') { return config.getConfig(ozoneVersion); } + if (this.propertyBag.whitelabel.bidder === 'ozone') { return config.getConfig(ozoneVersion); } let whitelabelledSearch = ozoneVersion.replace('ozone', this.propertyBag.whitelabel.bidder); whitelabelledSearch = whitelabelledSearch.replace('oz_', this.propertyBag.whitelabel.keyPrefix + '_'); return config.getConfig(whitelabelledSearch); }, - /** - * If a bidder bids for > 1 size for an adslot, allow only the highest bid - * @param seatbid object (serverResponse.seatbid) - */ removeSingleBidderMultipleBids(seatbid) { var ret = []; for (let i = 0; i < seatbid.length; i++) { @@ -616,7 +616,7 @@ export const spec = { } if (optionsType.iframeEnabled) { var arrQueryString = []; - if (document.location.search.match(/pbjs_debug=true/)) { + if (config.getConfig('debug')) { arrQueryString.push('pbjs_debug=true'); } arrQueryString.push('gdpr=' + (deepAccess(gdprConsent, 'gdprApplies', false) ? '1' : '0')); @@ -629,7 +629,6 @@ export const spec = { arrQueryString.push('siteId=' + this.cookieSyncBag.siteId); arrQueryString.push('cb=' + Date.now()); arrQueryString.push('bidder=' + this.propertyBag.whitelabel.bidder); - var strQueryString = arrQueryString.join('&'); if (strQueryString.length > 0) { strQueryString = '?' + strQueryString; @@ -641,11 +640,6 @@ export const spec = { }]; } }, - /** - * Find the bid matching the bidId in the request object - * get instream or outstream if this was a video request else null - * @return object|null - */ getBidRequestForBidId(bidId, arrBids) { for (let i = 0; i < arrBids.length; i++) { if (arrBids[i].bidId === bidId) { // bidId in the request comes back as impid in the seatbid bids @@ -654,13 +648,6 @@ export const spec = { } return null; }, - /** - * Locate the bid inside the arrBids for this bidId, then discover the video context, and return it. - * IF the bid cannot be found return null, else return a string. - * @param bidId - * @param arrBids - * @return string|null - */ getVideoContextForBidId(bidId, arrBids) { let requestBid = this.getBidRequestForBidId(bidId, arrBids); if (requestBid != null) { @@ -668,11 +655,6 @@ export const spec = { } return null; }, - /** - * This is used for cookie sync, not auction call - * Look for pubcid & all the other IDs according to http://prebid.org/dev-docs/modules/userId.html - * @return map - */ findAllUserIds(bidRequest) { var ret = {}; let searchKeysSingle = ['pubcid', 'tdid', 'idl_env', 'criteoId', 'lotamePanoramaId', 'fabrickId']; @@ -706,10 +688,6 @@ export const spec = { if (sharedid) { ret['sharedid'] = sharedid; } - let sharedidthird = deepAccess(bidRequest.userId, 'sharedid.third'); - if (sharedidthird) { - ret['sharedidthird'] = sharedidthird; - } } if (!ret.hasOwnProperty('pubcid')) { let pubcid = deepAccess(bidRequest, 'crumbs.pubcid'); @@ -719,20 +697,9 @@ export const spec = { } return ret; }, - /** - * Convenient method to get the value we need for the placementId - ONLY from the bidRequest - NOT taking into account any GET override ID - * @param bidRequest - * @return string - */ getPlacementId(bidRequest) { return (bidRequest.params.placementId).toString(); }, - /** - * GET parameter introduced in 2.2.0 : ozstoredrequest - * IF the GET parameter exists then it must validate for placementId correctly - * IF there's a $_GET['ozstoredrequest'] & it's valid then return this. Else return null. - * @returns null|string - */ getPlacementIdOverrideFromGetParam() { let whitelabelPrefix = this.propertyBag.whitelabel.keyPrefix; let arr = this.getGetParametersAsObject(); @@ -746,68 +713,38 @@ export const spec = { } return null; }, - /** - * Generate an object we can append to the auction request, containing user data formatted correctly for different ssps - * http://prebid.org/dev-docs/modules/userId.html - * @param validBidRequests - * @return {Array} - */ - generateEids(validBidRequests) { - let eids; - const bidRequest = validBidRequests[0]; - if (bidRequest && bidRequest.userId) { - eids = bidRequest.userIdAsEids; - this.handleTTDId(eids, validBidRequests); - } - return eids; - }, - handleTTDId(eids, validBidRequests) { - let ttdId = null; - let adsrvrOrgId = config.getConfig('adsrvrOrgId'); - if (isStr(deepAccess(validBidRequests, '0.userId.tdid'))) { - ttdId = validBidRequests[0].userId.tdid; - } else if (adsrvrOrgId && isStr(adsrvrOrgId.TDID)) { - ttdId = adsrvrOrgId.TDID; - } - if (ttdId !== null) { - eids.push({ - 'source': 'adserver.org', - 'uids': [{ - 'id': ttdId, - 'atype': 1, - 'ext': { - 'rtiPartner': 'TDID' - } - }] - }); - } - }, getGetParametersAsObject() { - let items = location.search.substr(1).split('&'); - let ret = {}; - let tmp = null; - for (let index = 0; index < items.length; index++) { - tmp = items[index].split('='); - ret[tmp[0]] = tmp[1]; + let parsed = parseUrl(this.getRefererInfo().location); + logInfo('getGetParametersAsObject found:', parsed.search); + return parsed.search; + }, + getRefererInfo() { + if (getRefererInfo().hasOwnProperty('location')) { + logInfo('FOUND location on getRefererInfo OK (prebid >= 7); will use getRefererInfo for location & page'); + return getRefererInfo(); + } else { + logInfo('DID NOT FIND location on getRefererInfo (prebid < 7); will use legacy code that ALWAYS worked reliably to get location & page ;-)'); + try { + return { + page: top.location.href, + location: top.location.href + }; + } catch (e) { + return { + page: window.location.href, + location: window.location.href + }; + } } - return ret; }, - /** - * Do we have to block this request? Could be due to config values (no longer checking gdpr) - * @return {boolean|*[]} true = block the request, else false - */ blockTheRequest() { let ozRequest = this.getWhitelabelConfigItem('ozone.oz_request'); if (typeof ozRequest == 'boolean' && !ozRequest) { - logWarn(`Will not allow auction : ${this.propertyBag.whitelabel.keyPrefix}one.${this.propertyBag.whitelabel.keyPrefix}_request is set to false`); + logWarn(`Will not allow auction : ${this.propertyBag.whitelabel.keyPrefix}_request is set to false`); return true; } return false; }, - /** - * This returns a random ID for this page. It starts off with the current ms timestamp then appends a random component - * @return {string} - */ getPageId: function() { if (this.propertyBag.pageId == null) { let randPart = ''; @@ -825,14 +762,6 @@ export const spec = { ret = this._unpackVideoConfigIntoIABformat(ret, childConfig); return ret; }, - /** - * - * look in ONE object to get video config (we need to call this multiple times, so child settings override parent) - * @param ret - * @param objConfig - * @return {*} - * @private - */ _unpackVideoConfigIntoIABformat(ret, objConfig) { let arrVideoKeysAllowed = ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', 'api', 'companiontype']; for (const key in objConfig) { @@ -861,14 +790,6 @@ export const spec = { objRet = this._addVideoDefaults(objRet, childConfig, true); // child config will override parent config return objRet; }, - /** - * modify objRet, adding in default values - * @param objRet - * @param objConfig - * @param addIfMissing - * @return {*} - * @private - */ _addVideoDefaults(objRet, objConfig, addIfMissing) { let context = deepAccess(objConfig, 'context'); if (context === 'outstream') { @@ -885,15 +806,38 @@ export const spec = { objRet.skip = skippable ? 1 : 0; } return objRet; + }, + getLoggableBidObject(bid) { + let logObj = { + ad: bid.ad, + adId: bid.adId, + adUnitCode: bid.adUnitCode, + adm: bid.adm, + adomain: bid.adomain, + adserverTargeting: bid.adserverTargeting, + auctionId: bid.auctionId, + bidId: bid.bidId, + bidder: bid.bidder, + bidderCode: bid.bidderCode, + cpm: bid.cpm, + creativeId: bid.creativeId, + crid: bid.crid, + currency: bid.currency, + h: bid.h, + w: bid.w, + impid: bid.impid, + mediaType: bid.mediaType, + params: bid.params, + price: bid.price, + transactionId: bid.transactionId, + ttl: bid.ttl + }; + if (bid.hasOwnProperty('floorData')) { + logObj.floorData = bid.floorData; + } + return logObj; } }; - -/** - * add a page-level-unique adId element to all server response bids. - * NOTE that this is destructive - it mutates the serverResponse object sent in as a parameter - * @param seatbid object (serverResponse.seatbid) - * @returns seatbid object - */ export function injectAdIdsIntoAllBidResponses(seatbid) { logInfo('injectAdIdsIntoAllBidResponses', seatbid); for (let i = 0; i < seatbid.length; i++) { @@ -904,7 +848,6 @@ export function injectAdIdsIntoAllBidResponses(seatbid) { } return seatbid; } - export function checkDeepArray(Arr) { if (Array.isArray(Arr)) { if (Array.isArray(Arr[0])) { @@ -916,7 +859,6 @@ export function checkDeepArray(Arr) { return Arr; } } - export function defaultSize(thebidObj) { if (!thebidObj) { logInfo('defaultSize received empty bid obj! going to return fixed default size'); @@ -931,13 +873,6 @@ export function defaultSize(thebidObj) { returnObject.defaultHeight = checkDeepArray(sizes)[1]; return returnObject; } - -/** - * Do the messy searching for the best bid response in the serverResponse.seatbid array matching the requestBid.bidId - * @param requestBid - * @param serverResponseSeatBid - * @returns {*} bid object - */ export function ozoneGetWinnerForRequestBid(requestBidId, serverResponseSeatBid) { let thisBidWinner = null; let winningSeat = null; @@ -956,13 +891,6 @@ export function ozoneGetWinnerForRequestBid(requestBidId, serverResponseSeatBid) } return {'seat': winningSeat, 'bid': thisBidWinner}; } - -/** - * Get a list of all the bids, for this bidId. The keys in the response object will be {seatname} OR {seatname}{w}x{h} if seatname already exists - * @param matchBidId - * @param serverResponseSeatBid - * @returns {} = {ozone|320x600:{obj}, ozone|320x250:{obj}, appnexus|300x250:{obj}, ... } - */ export function ozoneGetAllBidsForBidId(matchBidId, serverResponseSeatBid) { let objBids = {}; for (let j = 0; j < serverResponseSeatBid.length; j++) { @@ -982,21 +910,13 @@ export function ozoneGetAllBidsForBidId(matchBidId, serverResponseSeatBid) { } return objBids; } - -/** - * Round the bid price down according to the granularity - * @param price - * @param mediaType = video, banner or native - */ export function getRoundedBid(price, mediaType) { const mediaTypeGranularity = config.getConfig(`mediaTypePriceGranularity.${mediaType}`); // might be string or object or nothing; if set then this takes precedence over 'priceGranularity' let objBuckets = config.getConfig('customPriceBucket'); // this is always an object - {} if strBuckets is not 'custom' let strBuckets = config.getConfig('priceGranularity'); // priceGranularity value, always a string ** if priceGranularity is set to an object then it's always 'custom' ** let theConfigObject = getGranularityObject(mediaType, mediaTypeGranularity, strBuckets, objBuckets); let theConfigKey = getGranularityKeyName(mediaType, mediaTypeGranularity, strBuckets); - logInfo('getRoundedBid. price:', price, 'mediaType:', mediaType, 'configkey:', theConfigKey, 'configObject:', theConfigObject, 'mediaTypeGranularity:', mediaTypeGranularity, 'strBuckets:', strBuckets); - let priceStringsObj = getPriceBucketString( price, theConfigObject, @@ -1017,13 +937,6 @@ export function getRoundedBid(price, mediaType) { } return priceStringsObj['auto']; } - -/** - * return the key to use to get the value out of the priceStrings object, taking into account anything at - * config.priceGranularity level or config.mediaType.xxx level - * I've noticed that the key specified by prebid core : config.getConfig('priceGranularity') does not properly - * take into account the 2-levels of config - */ export function getGranularityKeyName(mediaType, mediaTypeGranularity, strBuckets) { if (typeof mediaTypeGranularity === 'string') { return mediaTypeGranularity; @@ -1036,11 +949,6 @@ export function getGranularityKeyName(mediaType, mediaTypeGranularity, strBucket } return 'auto'; // fall back to a default key - should literally never be needed. } - -/** - * return the object to use to create the custom value of the priceStrings object, taking into account anything at - * config.priceGranularity level or config.mediaType.xxx level - */ export function getGranularityObject(mediaType, mediaTypeGranularity, strBuckets, objBuckets) { if (typeof mediaTypeGranularity === 'object') { return mediaTypeGranularity; @@ -1050,12 +958,6 @@ export function getGranularityObject(mediaType, mediaTypeGranularity, strBuckets } return ''; } - -/** - * We expect to be able to find a standard set of properties on winning bid objects; add them here. - * @param seatBid - * @returns {*} - */ export function ozoneAddStandardProperties(seatBid, defaultWidth, defaultHeight) { seatBid.cpm = seatBid.price; seatBid.bidId = seatBid.impid; @@ -1069,12 +971,6 @@ export function ozoneAddStandardProperties(seatBid, defaultWidth, defaultHeight) seatBid.ttl = 300; return seatBid; } - -/** - * - * @param objVideo will be like {"playerSize":[640,480],"mimes":["video/mp4"],"context":"outstream"} or POSSIBLY {"playerSize":[[640,480]],"mimes":["video/mp4"],"context":"outstream"} - * @return object {w,h} or null - */ export function getWidthAndHeightFromVideoObject(objVideo) { let playerSize = getPlayerSizeFromObject(objVideo); if (!playerSize) { @@ -1094,11 +990,6 @@ export function getWidthAndHeightFromVideoObject(objVideo) { } return ({'w': playerSize[0], 'h': playerSize[1]}); } - -/** - * @param objVideo will be like {"playerSize":[640,480],"mimes":["video/mp4"],"context":"outstream"} or POSSIBLY {"playerSize":[[640,480]],"mimes":["video/mp4"],"context":"outstream"} - * @return object {w,h} or null - */ export function playerSizeIsNestedArray(objVideo) { let playerSize = getPlayerSizeFromObject(objVideo); if (!playerSize) { @@ -1109,12 +1000,6 @@ export function playerSizeIsNestedArray(objVideo) { } return (playerSize[0] && typeof playerSize[0] === 'object'); } - -/** - * Common functionality when looking at a video object, to get the playerSize - * @param objVideo - * @returns {*} - */ function getPlayerSizeFromObject(objVideo) { logInfo('getPlayerSizeFromObject received object', objVideo); let playerSize = deepAccess(objVideo, 'playerSize'); @@ -1131,10 +1016,6 @@ function getPlayerSizeFromObject(objVideo) { } return playerSize; } -/* - Rendering video ads - create a renderer instance, mark it as not loaded, set a renderer function. - The renderer function will not assume that the renderer script is loaded - it will push() the ultimate render function call - */ function newRenderer(adUnitCode, rendererOptions = {}) { let isLoaded = window.ozoneVideo; logInfo(`newRenderer going to set loaded to ${isLoaded ? 'true' : 'false'}`); @@ -1147,16 +1028,18 @@ function newRenderer(adUnitCode, rendererOptions = {}) { try { renderer.setRender(outstreamRender); } catch (err) { - logError('Prebid Error when calling setRender on renderer', JSON.parse(JSON.stringify(renderer)), err); + logError('Prebid Error when calling setRender on renderer', renderer, err); } + logInfo('returning renderer object'); return renderer; } function outstreamRender(bid) { - logInfo('outstreamRender called. Going to push the call to window.ozoneVideo.outstreamRender(bid) bid =', JSON.parse(JSON.stringify(bid))); + logInfo('outstreamRender called. Going to push the call to window.ozoneVideo.outstreamRender(bid) bid = (first static, then reference)'); + logInfo(JSON.parse(JSON.stringify(spec.getLoggableBidObject(bid)))); bid.renderer.push(() => { + logInfo('Going to execute window.ozoneVideo.outstreamRender'); window.ozoneVideo.outstreamRender(bid); }); } - registerBidder(spec); logInfo(`*BidAdapter ${OZONEVERSION} was loaded`); diff --git a/modules/ozoneBidAdapter.md b/modules/ozoneBidAdapter.md index ca18c962219..9787e069283 100644 --- a/modules/ozoneBidAdapter.md +++ b/modules/ozoneBidAdapter.md @@ -72,3 +72,42 @@ adUnits = [{ }] }]; ``` + + +``` +//Instream Video adUnit + +adUnits = [{ + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream', + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2] + } + }, + bids: [{ + bidder: 'ozone', + params: { + publisherId: 'OZONENUK0001', + placementId: '8000000328', // or 999 + siteId: '4204204201', + video: { + skippable: true, + playback_method: ['auto_play_sound_off'] + }, + customData: [{ + "settings": {}, + "targeting": { + "key": "value", + "key2": ["value1", "value2"] + } + } + ] + + } + }] + }; +``` \ No newline at end of file diff --git a/modules/padsquadBidAdapter.js b/modules/padsquadBidAdapter.js index 72449cf28be..48471fc98e3 100644 --- a/modules/padsquadBidAdapter.js +++ b/modules/padsquadBidAdapter.js @@ -1,4 +1,4 @@ -import { logInfo, deepAccess } from '../src/utils.js'; +import {deepAccess, logInfo} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; @@ -40,12 +40,12 @@ export const spec = { })); const openrtbRequest = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: impressions, site: { - domain: window.location.hostname, - page: window.location.href, - ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null + domain: bidderRequest?.refererInfo?.domain, + page: bidderRequest?.refererInfo?.page, + ref: bidderRequest?.refererInfo?.ref, }, ext: { exchange: { diff --git a/modules/pairIdSystem.js b/modules/pairIdSystem.js new file mode 100644 index 00000000000..489b97d02e3 --- /dev/null +++ b/modules/pairIdSystem.js @@ -0,0 +1,90 @@ +/** + * This module adds PAIR Id to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/pairIdSystem + * @requires module:modules/userId + */ + +import { submodule } from '../src/hook.js'; +import {getStorageManager} from '../src/storageManager.js' +import { logInfo } from '../src/utils.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; + +const MODULE_NAME = 'pairId'; +const PAIR_ID_KEY = 'pairId'; +const DEFAULT_LIVERAMP_PAIR_ID_KEY = '_lr_pairId'; + +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); + +function pairIdFromLocalStorage(key) { + return storage.localStorageIsEnabled() ? storage.getDataFromLocalStorage(key) : null; +} + +function pairIdFromCookie(key) { + return storage.cookiesAreEnabled() ? storage.getCookie(key) : null; +} + +/** @type {Submodule} */ +export const pairIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + /** + * used to specify vendor id + * @type {number} + */ + gvlid: 755, + /** + * decode the stored id value for passing to bid requests + * @function + * @param { string | undefined } value + * @returns {{pairId:string} | undefined } + */ + decode(value) { + return value && Array.isArray(value) ? {'pairId': value} : undefined + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @returns {id: string | undefined } + */ + getId(config) { + const pairIdsString = pairIdFromLocalStorage(PAIR_ID_KEY) || pairIdFromCookie(PAIR_ID_KEY) + let ids = [] + if (pairIdsString && typeof pairIdsString == 'string') { + try { + ids = ids.concat(JSON.parse(atob(pairIdsString))) + } catch (error) { + logInfo(error) + } + } + + const configParams = (config && config.params) || {}; + if (configParams && configParams.liveramp) { + let LRStorageLocation = configParams.liveramp.storageKey || DEFAULT_LIVERAMP_PAIR_ID_KEY + const liverampValue = pairIdFromLocalStorage(LRStorageLocation) || pairIdFromCookie(LRStorageLocation) + try { + const obj = JSON.parse(atob(liverampValue)); + ids = ids.concat(obj.envelope); + } catch (error) { + logInfo(error) + } + } + + if (ids.length == 0) { + logInfo('PairId not found.') + return undefined; + } + return {'id': ids}; + }, + eids: { + 'pairId': { + source: 'google.com', + atype: 571187 + }, + } +}; + +submodule('userId', pairIdSubmodule); diff --git a/modules/pangleBidAdapter.js b/modules/pangleBidAdapter.js new file mode 100644 index 00000000000..408a8b24c29 --- /dev/null +++ b/modules/pangleBidAdapter.js @@ -0,0 +1,110 @@ +// ver V1.0.3 +import { BANNER } from '../src/mediaTypes.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js' +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { deepSetValue, generateUUID, timestamp } from '../src/utils.js'; +import { getStorageManager } from '../src/storageManager.js'; +import { MODULE_TYPE_RTD } from '../src/activities/modules.js'; + +const BIDDER_CODE = 'pangle'; +const ENDPOINT = 'https://pangle.pangleglobal.com/api/ad/union/web_js/common/get_ads'; + +const DEFAULT_BID_TTL = 30; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_NET_REVENUE = true; +const PANGLE_COOKIE = '_pangle_id'; +const COOKIE_EXP = 86400 * 1000 * 365 * 1; // 1 year +export const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: BIDDER_CODE }) + +export function isValidUuid(uuid) { + return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test( + uuid + ); +} + +function getPangleCookieId() { + let sid = storage.cookiesAreEnabled() && storage.getCookie(PANGLE_COOKIE); + + if ( + !sid || !isValidUuid(sid) + ) { + sid = generateUUID(); + setPangleCookieId(sid); + } + + return sid; +} + +function setPangleCookieId(sid) { + if (storage.cookiesAreEnabled()) { + const expires = (new Date(timestamp() + COOKIE_EXP)).toGMTString(); + + storage.setCookie(PANGLE_COOKIE, sid, expires); + } +} + +const converter = ortbConverter({ + context: { + netRevenue: DEFAULT_NET_REVENUE, + ttl: DEFAULT_BID_TTL, + currency: DEFAULT_CURRENCY, + mediaType: BANNER + } +}); + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + getDeviceType: function (ua) { + if ((/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(ua.toLowerCase()))) { + return 5; // 'tablet' + } + if ((/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(ua.toLowerCase()))) { + return 4; // 'mobile' + } + return 2; // 'desktop' + }, + + isBidRequestValid: function (bid) { + return Boolean(bid.params.token); + }, + + buildRequests(bidRequests, bidderRequest) { + const data = converter.toORTB({ bidRequests, bidderRequest }) + const devicetype = spec.getDeviceType(navigator.userAgent); + deepSetValue(data, 'device.devicetype', devicetype); + if (bidderRequest.userId && typeof bidderRequest.userId === 'object') { + const pangleId = getPangleCookieId(); + // add pangle cookie + const _eids = data.user?.ext?.eids ?? [] + deepSetValue(data, 'user.ext.eids', [..._eids, { + source: document.location.host, + uids: [ + { + id: pangleId, + atype: 1 + } + ] + }]); + } + bidRequests.forEach((item, idx) => { + deepSetValue(data.imp[idx], 'ext.networkids', item.params); + deepSetValue(data.imp[idx], 'banner.api', [5]); + }); + + return [{ + method: 'POST', + url: ENDPOINT, + data, + options: { contentType: 'application/json', withCredentials: true } + }] + }, + + interpretResponse(response, request) { + const bids = converter.fromORTB({ response: response.body, request: request.data }).bids; + return bids; + }, +}; + +registerBidder(spec); diff --git a/modules/pangleBidAdapter.md b/modules/pangleBidAdapter.md new file mode 100644 index 00000000000..8fc628dcc89 --- /dev/null +++ b/modules/pangleBidAdapter.md @@ -0,0 +1,32 @@ +# Overview + +Module Name: pangle Bidder Adapter +Module Type: Bidder Adapter +Maintainer: + +# Description + +An adapter to get a bid from pangle DSP. + +# Test Parameters + +```javascript +var adUnits = [{ + // banner + code: 'test1', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + + bids: [{ + bidder: 'pangle', + params: { + token: 'aass', + appid: 612, + placementid: 123, + } + }] +}]; +``` diff --git a/modules/papyrusBidAdapter.md b/modules/papyrusBidAdapter.md deleted file mode 100644 index 98a42e542ec..00000000000 --- a/modules/papyrusBidAdapter.md +++ /dev/null @@ -1,41 +0,0 @@ -# Overview - -``` -Module Name: Papyrus Bid Adapter -Module Type: Bidder Adapter -Maintainer: alexander.holodov@papyrus.global -``` - -# Description - -Connect to Papyrus system for bids. - -Papyrus bid adapter supports Banner. - -Please contact to info@papyrus.global for -further details - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [ - [320, 50] - ] - } - }, - bids: [ - { - bidder: 'papyrus', - params: { - address: '0xd7e2a771c5dcd5df7f789477356aecdaeee6c985', - placementId: 'b57e55fd18614b0591893e9fff41fbea' - } - } - ] - } - ]; -``` diff --git a/modules/parrableIdSystem.js b/modules/parrableIdSystem.js index 04f36d0cb63..3e3488f72f3 100644 --- a/modules/parrableIdSystem.js +++ b/modules/parrableIdSystem.js @@ -7,13 +7,24 @@ // ci trigger: 1 -import {contains, deepClone, inIframe, isEmpty, isPlainObject, logError, logWarn, timestamp} from '../src/utils.js'; +import { + contains, + deepClone, + inIframe, + isEmpty, + isPlainObject, + logError, + logWarn, + pick, + timestamp +} from '../src/utils.js'; import {find} from '../src/polyfill.js'; import {ajax} from '../src/ajax.js'; import {submodule} from '../src/hook.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {uspDataHandler} from '../src/adapterManager.js'; import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const PARRABLE_URL = 'https://h.parrable.com/prebid'; const PARRABLE_COOKIE_NAME = '_parrable_id'; @@ -22,8 +33,9 @@ const LEGACY_ID_COOKIE_NAME = '_parrable_eid'; const LEGACY_OPTOUT_COOKIE_NAME = '_parrable_optout'; const ONE_YEAR_MS = 364 * 24 * 60 * 60 * 1000; const EXPIRE_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:00 GMT'; +const MODULE_NAME = 'parrableId'; -const storage = getStorageManager({gvlid: PARRABLE_GVLID}); +const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); function getExpirationDate() { const oneYearFromNow = new Date(timestamp() + ONE_YEAR_MS); @@ -244,7 +256,7 @@ function fetchId(configParams, gdprConsentData) { const data = { eid, trackers, - url: refererInfo.referer, + url: refererInfo.page, prebidVersion: '$prebid.version$', isIframe: inIframe(), tpcSupport @@ -336,7 +348,7 @@ export const parrableIdSubmodule = { * used to link submodule with config * @type {string} */ - name: 'parrableId', + name: MODULE_NAME, /** * Global Vendor List ID * @type {number} @@ -366,7 +378,33 @@ export const parrableIdSubmodule = { getId(config, gdprConsentData, currentStoredId) { const configParams = (config && config.params) || {}; return fetchId(configParams, gdprConsentData); - } + }, + eids: { + 'parrableId': { + source: 'parrable.com', + atype: 1, + getValue: function(parrableId) { + if (parrableId.eid) { + return parrableId.eid; + } + if (parrableId.ccpaOptout) { + // If the EID was suppressed due to a non consenting ccpa optout then + // we still wish to provide this as a reason to the adapters + return ''; + } + return null; + }, + getUidExt: function(parrableId) { + const extendedData = pick(parrableId, [ + 'ibaOptout', + 'ccpaOptout' + ]); + if (Object.keys(extendedData).length) { + return extendedData; + } + } + }, + }, }; submodule('userId', parrableIdSubmodule); diff --git a/modules/peak226BidAdapter.md b/modules/peak226BidAdapter.md deleted file mode 100644 index bae15d6c99f..00000000000 --- a/modules/peak226BidAdapter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Overview - -``` -Module Name: Peak226 Bidder Adapter -Module Type: Bidder Adapter -Maintainer: support@edge226.com -``` - -# Description - -Module that connects to Peak226's demand sources - -# Test Parameters - -``` - var adUnits = [ - { - code: "test-div", - sizes: [[300, 250]], - mediaType: "banner", - bids: [ - { - bidder: "peak226", - params: { - uid: 76131369 - } - } - ] - } - ]; -``` diff --git a/modules/performaxBidAdapter.md b/modules/performaxBidAdapter.md deleted file mode 100644 index 4cf2984a79d..00000000000 --- a/modules/performaxBidAdapter.md +++ /dev/null @@ -1,36 +0,0 @@ -# Overview - -``` -Module Name: Performax Bid Adapter -Module Type: Bidder Adapter -Maintainer: development@performax.cz -``` - -# Description - -Connects to Performax exchange for bids. - -Performax bid adapter supports Banner. - - -# Sample Banner Ad Unit: For Publishers - -```javascript - var adUnits = [ - { - code: 'performax-div', - sizes: [[300, 300]], - bids: [ - { - bidder: "performax", - params: { - slotId: 28 // required - } - } - ] - } - ]; -``` - -Where: -* slotId - id of slot in PX system diff --git a/modules/permutiveRtdProvider.js b/modules/permutiveRtdProvider.js index c4674132416..697d7721205 100644 --- a/modules/permutiveRtdProvider.js +++ b/modules/permutiveRtdProvider.js @@ -8,91 +8,136 @@ import {getGlobal} from '../src/prebidGlobal.js'; import {submodule} from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js'; -import {deepAccess, deepSetValue, isFn, logError, mergeDeep} from '../src/utils.js'; -import {config} from '../src/config.js'; +import {deepAccess, deepSetValue, isFn, logError, mergeDeep, isPlainObject, safeJSONParse, prefixLog} from '../src/utils.js'; import {includes} from '../src/polyfill.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; const MODULE_NAME = 'permutive' -export const storage = getStorageManager({gvlid: null, moduleName: MODULE_NAME}) +const logger = prefixLog('[PermutiveRTD]') + +export const PERMUTIVE_SUBMODULE_CONFIG_KEY = 'permutive-prebid-rtd' +export const PERMUTIVE_STANDARD_KEYWORD = 'p_standard' +export const PERMUTIVE_CUSTOM_COHORTS_KEYWORD = 'permutive' +export const PERMUTIVE_STANDARD_AUD_KEYWORD = 'p_standard_aud' + +export const storage = getStorageManager({moduleType: MODULE_TYPE_RTD, moduleName: MODULE_NAME}) + +function init(moduleConfig, userConsent) { + readPermutiveModuleConfigFromCache() -function init (moduleConfig, userConsent) { return true } +function liftIntoParams(params) { + return isPlainObject(params) ? { params } : {} +} + +let cachedPermutiveModuleConfig = {} + /** - * Set segment targeting from cache and then try to wait for Permutive - * to initialise to get realtime segment targeting - * @param {Object} reqBidsConfigObj - * @param {function} callback - Called when submodule is done - * @param {customModuleConfig} reqBidsConfigObj - Publisher config for module + * Access the submodules RTD params that are cached to LocalStorage by the Permutive SDK. This lets the RTD submodule + * apply publisher defined params set in the Permutive platform, so they may still be applied if the Permutive SDK has + * not initialised before this submodule is initialised. */ -export function initSegments (reqBidsConfigObj, callback, customModuleConfig) { - const permutiveOnPage = isPermutiveOnPage() - const moduleConfig = getModuleConfig(customModuleConfig) - const segmentData = getSegments(moduleConfig.params.maxSegs) - - setSegments(reqBidsConfigObj, moduleConfig, segmentData) +function readPermutiveModuleConfigFromCache() { + const params = safeJSONParse(storage.getDataFromLocalStorage(PERMUTIVE_SUBMODULE_CONFIG_KEY)) + return cachedPermutiveModuleConfig = liftIntoParams(params) +} - if (moduleConfig.waitForIt && permutiveOnPage) { - window.permutive.ready(function () { - setSegments(reqBidsConfigObj, moduleConfig, segmentData) - callback() - }, 'realtime') - } else { - callback() +/** + * Access the submodules RTD params attached to the Permutive SDK. + * + * @return The Permutive config available by the Permutive SDK or null if the operation errors. + */ +function getParamsFromPermutive() { + try { + return liftIntoParams(window.permutive.addons.prebid.getPermutiveRtdConfig()) + } catch (e) { + return null } } /** - * Merges segments into existing bidder config + * Merges segments into existing bidder config in reverse priority order. The highest priority is 1. + * + * 1. customModuleConfig <- set by publisher with pbjs.setConfig + * 2. permutiveRtdConfig <- set by the publisher using the Permutive platform + * 3. defaultConfig + * + * As items with a higher priority will be deeply merged into the previous config, deep merges are performed by + * reversing the priority order. + * * @param {Object} customModuleConfig - Publisher config for module - * @return {Object} Merged defatul and custom config + * @return {Object} Deep merges of the default, Permutive and custom config. */ -function getModuleConfig (customModuleConfig) { +export function getModuleConfig(customModuleConfig) { + // Use the params from Permutive if available, otherwise fallback to the cached value set by Permutive. + const permutiveModuleConfig = getParamsFromPermutive() || cachedPermutiveModuleConfig + return mergeDeep({ waitForIt: false, params: { maxSegs: 500, acBidders: [], - overwrites: {} - } - }, customModuleConfig) + overwrites: {}, + }, + }, + permutiveModuleConfig, + customModuleConfig, + ) } /** * Sets ortb2 config for ac bidders - * @param {Object} auctionDetails + * @param {Object} bidderOrtb2 - The ortb2 object for the all bidders * @param {Object} customModuleConfig - Publisher config for module */ -export function setBidderRtb (auctionDetails, customModuleConfig) { - const bidderConfig = config.getBidderConfig() - const moduleConfig = getModuleConfig(customModuleConfig) +export function setBidderRtb (bidderOrtb2, moduleConfig, segmentData) { const acBidders = deepAccess(moduleConfig, 'params.acBidders') const maxSegs = deepAccess(moduleConfig, 'params.maxSegs') const transformationConfigs = deepAccess(moduleConfig, 'params.transformations') || [] - const segmentData = getSegments(maxSegs) - acBidders.forEach(function (bidder) { - const currConfig = bidderConfig[bidder] || {} - const nextConfig = updateOrtbConfig(currConfig, segmentData.ac, transformationConfigs) // ORTB2 uses the `ac` segment IDs + const ssps = segmentData?.ssp?.ssps ?? [] + const sspCohorts = segmentData?.ssp?.cohorts ?? [] - config.setBidderConfig({ - bidders: [bidder], - config: nextConfig - }) + const bidders = new Set([...acBidders, ...ssps]) + bidders.forEach(function (bidder) { + const currConfig = { ortb2: bidderOrtb2[bidder] || {} } + + let cohorts = [] + + const isAcBidder = acBidders.indexOf(bidder) > -1 + if (isAcBidder) { + cohorts = segmentData.ac + } + + const isSspBidder = ssps.indexOf(bidder) > -1 + if (isSspBidder) { + cohorts = [...new Set([...cohorts, ...sspCohorts])].slice(0, maxSegs) + } + + const nextConfig = updateOrtbConfig(bidder, currConfig, cohorts, sspCohorts, transformationConfigs, segmentData) + bidderOrtb2[bidder] = nextConfig.ortb2 }) } /** * Updates `user.data` object in existing bidder config with Permutive segments + * @param string bidder - The bidder * @param {Object} currConfig - Current bidder config * @param {Object[]} transformationConfigs - array of objects with `id` and `config` properties, used to determine * the transformations on user data to include the ORTB2 object * @param {string[]} segmentIDs - Permutive segment IDs + * @param {string[]} sspSegmentIDs - Permutive SSP segment IDs + * @param {Object} segmentData - The segments available for targeting * @return {Object} Merged ortb2 object */ -function updateOrtbConfig (currConfig, segmentIDs, transformationConfigs) { +function updateOrtbConfig(bidder, currConfig, segmentIDs, sspSegmentIDs, transformationConfigs, segmentData) { + logger.logInfo(`Current ortb2 config`, { bidder, config: currConfig }) + + const customCohortsData = deepAccess(segmentData, bidder) || [] + const name = 'permutive.com' const permutiveUserData = { @@ -104,15 +149,65 @@ function updateOrtbConfig (currConfig, segmentIDs, transformationConfigs) { .filter(({ id }) => ortb2UserDataTransformations.hasOwnProperty(id)) .map(({ id, config }) => ortb2UserDataTransformations[id](permutiveUserData, config)) + const customCohortsUserData = { + name: PERMUTIVE_CUSTOM_COHORTS_KEYWORD, + segment: customCohortsData.map(cohortID => ({ id: cohortID })), + } + const ortbConfig = mergeDeep({}, currConfig) const currentUserData = deepAccess(ortbConfig, 'ortb2.user.data') || [] const updatedUserData = currentUserData - .filter(el => el.name !== name) - .concat(permutiveUserData, transformedUserData) + .filter(el => el.name !== permutiveUserData.name && el.name !== customCohortsUserData.name) + .concat(permutiveUserData, transformedUserData, customCohortsUserData) + logger.logInfo(`Updating ortb2.user.data`, { bidder, user_data: updatedUserData }) deepSetValue(ortbConfig, 'ortb2.user.data', updatedUserData) + // Set ortb2.user.keywords + const currentKeywords = deepAccess(ortbConfig, 'ortb2.user.keywords') + const keywordGroups = { + [PERMUTIVE_STANDARD_KEYWORD]: segmentIDs, + [PERMUTIVE_STANDARD_AUD_KEYWORD]: sspSegmentIDs, + [PERMUTIVE_CUSTOM_COHORTS_KEYWORD]: customCohortsData, + } + + // Transform groups of key-values into a single array of strings + // i.e { permutive: ['1', '2'], p_standard: ['3', '4'] } => ['permutive=1', 'permutive=2', 'p_standard=3',' p_standard=4'] + const transformedKeywordGroups = Object.entries(keywordGroups) + .flatMap(([keyword, ids]) => ids.map(id => `${keyword}=${id}`)) + + const keywords = [ + currentKeywords, + ...transformedKeywordGroups, + ] + .filter(Boolean) + .join(',') + + logger.logInfo(`Updating ortb2.user.keywords`, { + bidder, + keywords, + }) + deepSetValue(ortbConfig, 'ortb2.user.keywords', keywords) + + // Set user extensions + if (segmentIDs.length > 0) { + deepSetValue(ortbConfig, `ortb2.user.ext.data.${PERMUTIVE_STANDARD_KEYWORD}`, segmentIDs) + logger.logInfo(`Extending ortb2.user.ext.data with "${PERMUTIVE_STANDARD_KEYWORD}"`, segmentIDs) + } + + if (customCohortsData.length > 0) { + deepSetValue(ortbConfig, `ortb2.user.ext.data.${PERMUTIVE_CUSTOM_COHORTS_KEYWORD}`, customCohortsData.map(String)) + logger.logInfo(`Extending ortb2.user.ext.data with "${PERMUTIVE_CUSTOM_COHORTS_KEYWORD}"`, customCohortsData) + } + + // Set site extensions + if (segmentIDs.length > 0) { + deepSetValue(ortbConfig, `ortb2.site.ext.permutive.${PERMUTIVE_STANDARD_KEYWORD}`, segmentIDs) + logger.logInfo(`Extending ortb2.site.ext.permutive with "${PERMUTIVE_STANDARD_KEYWORD}"`, segmentIDs) + } + + logger.logInfo(`Updated ortb2 config`, { bidder, config: ortbConfig }) return ortbConfig } @@ -141,12 +236,11 @@ function setSegments (reqBidsConfigObj, moduleConfig, segmentData) { } const acEnabled = isAcEnabled(moduleConfig, bidder) const customFn = getCustomBidderFn(moduleConfig, bidder) - const defaultFn = getDefaultBidderFn(bidder) if (customFn) { - customFn(bid, segmentData, acEnabled, utils, defaultFn) - } else if (defaultFn) { - defaultFn(bid, segmentData, acEnabled) + // For backwards compatibility we pass an identity function to any custom bidder function set by a publisher + const bidIdentity = (bid) => bid + customFn(bid, segmentData, acEnabled, utils, bidIdentity) } }) }) @@ -174,46 +268,6 @@ function getCustomBidderFn (moduleConfig, bidder) { } } -/** - * Returns a function that receives a `bid` object, a `data` object and a `acEnabled` boolean - * and which will set the right segment targeting keys for `bid` based on `data` and `acEnabled` - * @param {string} bidder - Bidder name - * @return {Object} Bidder function - */ -function getDefaultBidderFn (bidder) { - const bidderMap = { - appnexus: function (bid, data, acEnabled) { - if (acEnabled && data.ac && data.ac.length) { - deepSetValue(bid, 'params.keywords.p_standard', data.ac) - } - if (data.appnexus && data.appnexus.length) { - deepSetValue(bid, 'params.keywords.permutive', data.appnexus) - } - - return bid - }, - rubicon: function (bid, data, acEnabled) { - if (acEnabled && data.ac && data.ac.length) { - deepSetValue(bid, 'params.visitor.p_standard', data.ac) - } - if (data.rubicon && data.rubicon.length) { - deepSetValue(bid, 'params.visitor.permutive', data.rubicon) - } - - return bid - }, - ozone: function (bid, data, acEnabled) { - if (acEnabled && data.ac && data.ac.length) { - deepSetValue(bid, 'params.customData.0.targeting.p_standard', data.ac) - } - - return bid - } - } - - return bidderMap[bidder] -} - /** * Check whether ac is enabled for bidder * @param {Object} moduleConfig - Module configuration @@ -239,19 +293,30 @@ export function isPermutiveOnPage () { * @return {Object} */ export function getSegments (maxSegs) { - const legacySegs = readSegments('_psegs').map(Number).filter(seg => seg >= 1000000).map(String) - const _ppam = readSegments('_ppam') - const _pcrprs = readSegments('_pcrprs') + const legacySegs = readSegments('_psegs', []).map(Number).filter(seg => seg >= 1000000).map(String) + const _ppam = readSegments('_ppam', []) + const _pcrprs = readSegments('_pcrprs', []) const segments = { ac: [..._pcrprs, ..._ppam, ...legacySegs], - rubicon: readSegments('_prubicons'), - appnexus: readSegments('_papns'), - gam: readSegments('_pdfps'), + ix: readSegments('_pindexs', []), + rubicon: readSegments('_prubicons', []), + appnexus: readSegments('_papns', []), + gam: readSegments('_pdfps', []), + ssp: readSegments('_pssps', { + cohorts: [], + ssps: [] + }), } for (const bidder in segments) { - segments[bidder] = segments[bidder].slice(0, maxSegs) + if (bidder === 'ssp') { + if (segments[bidder].cohorts && Array.isArray(segments[bidder].cohorts)) { + segments[bidder].cohorts = segments[bidder].cohorts.slice(0, maxSegs) + } + } else { + segments[bidder] = segments[bidder].slice(0, maxSegs) + } } return segments @@ -259,15 +324,17 @@ export function getSegments (maxSegs) { /** * Gets an array of segment IDs from LocalStorage - * or returns an empty array + * or return the default value provided. + * @template A * @param {string} key - * @return {string[]|number[]} + * @param {A} defaultValue + * @return {A} */ -function readSegments (key) { +function readSegments (key, defaultValue) { try { - return JSON.parse(storage.getDataFromLocalStorage(key) || '[]') + return JSON.parse(storage.getDataFromLocalStorage(key)) || defaultValue } catch (e) { - return [] + return defaultValue } } @@ -299,19 +366,55 @@ function iabSegmentId(permutiveSegmentId, iabIds) { return iabIds[permutiveSegmentId] || unknownIabSegmentId } +/** + * Pull the latest configuration and cohort information and update accordingly. + * + * @param reqBidsConfigObj - Bidder provided config for request + * @param customModuleConfig - Publisher provide config + */ +export function readAndSetCohorts(reqBidsConfigObj, moduleConfig) { + const segmentData = getSegments(deepAccess(moduleConfig, 'params.maxSegs')) + + makeSafe(function () { + // Legacy route with custom parameters + // ACK policy violation, in process of removing + setSegments(reqBidsConfigObj, moduleConfig, segmentData) + }); + + makeSafe(function () { + // Route for bidders supporting ORTB2 + setBidderRtb(reqBidsConfigObj.ortb2Fragments?.bidder, moduleConfig, segmentData) + }) +} + +let permutiveSDKInRealTime = false + /** @type {RtdSubmodule} */ export const permutiveSubmodule = { name: MODULE_NAME, getBidRequestData: function (reqBidsConfigObj, callback, customModuleConfig) { + const completeBidRequestData = () => { + logger.logInfo(`Request data updated`) + callback() + } + + const moduleConfig = getModuleConfig(customModuleConfig) + + readAndSetCohorts(reqBidsConfigObj, moduleConfig) + makeSafe(function () { - // Legacy route with custom parameters - initSegments(reqBidsConfigObj, callback, customModuleConfig) - }) - }, - onAuctionInitEvent: function (auctionDetails, customModuleConfig) { - makeSafe(function () { - // Route for bidders supporting ORTB2 - setBidderRtb(auctionDetails, customModuleConfig) + if (permutiveSDKInRealTime || !(moduleConfig.waitForIt && isPermutiveOnPage())) { + return completeBidRequestData() + } + + window.permutive.ready(function () { + logger.logInfo(`SDK is realtime, updating cohorts`) + permutiveSDKInRealTime = true + readAndSetCohorts(reqBidsConfigObj, getModuleConfig(customModuleConfig)) + completeBidRequestData() + }, 'realtime') + + logger.logInfo(`Registered cohort update when SDK is realtime`) }) }, init: init diff --git a/modules/permutiveRtdProvider.md b/modules/permutiveRtdProvider.md index 5fa6e14a474..9399dffab93 100644 --- a/modules/permutiveRtdProvider.md +++ b/modules/permutiveRtdProvider.md @@ -1,9 +1,10 @@ -# Permutive Real-time Data Submodule +## Prebid Config for Permutive RTD Module -This submodule reads cohorts from Permutive and attaches them as targeting keys to bid requests. Using this module will deliver best targeting results, leveraging Permutive's real-time segmentation and modelling capabilities. +This module reads cohorts from Permutive and attaches them as targeting keys to bid requests. -## Usage +### _Permutive Real-time Data Submodule_ +#### Usage Compile the Permutive RTD module into your Prebid build: ``` @@ -12,7 +13,7 @@ gulp build --modules=rtdModule,permutiveRtdProvider > Note that the global RTD module, `rtdModule`, is a prerequisite of the Permutive RTD module. -You then need to enable the Permutive RTD in your Prebid configuration, using the below format: +You then need to enable the Permutive RTD in your Prebid configuration. Below is an example of the format: ```javascript pbjs.setConfig({ @@ -31,39 +32,122 @@ pbjs.setConfig({ }) ``` -## Supported Bidders +#### Parameters -The Permutive RTD module sets Audience Connector cohorts as bidder-specific `ortb2.user.data` first-party data, following the Prebid `ortb2` convention, for any bidder included in `acBidders`. The module also supports bidder-specific data locations per ad unit (custom parameters) for the below bidders: +The parameters below provide configurability for general behaviours of the RTD submodule, +as well as enabling settings for specific use cases mentioned above (e.g. acbidders). -| Bidder | ID | Custom Cohorts | Audience Connector | -| ------- | ---------- | -------------- | ------------------ | -| Xandr | `appnexus` | Yes | Yes | -| Magnite | `rubicon` | Yes | No | -| Ozone | `ozone` | No | Yes | +## Parameters -Key-values details for custom parameters: +{: .table .table-bordered .table-striped } +| Name | Type | Description | Default | +| ---------------------- | -------------------- | --------------------------------------------------------------------------------------------- | ------------------ | +| name | String | This should always be `permutive` | - | +| waitForIt | Boolean | Should be `true` if there's an `auctionDelay` defined (optional) | `false` | +| params | Object | | - | +| params.acBidders | String[] | An array of bidder codes to share cohorts with in certain versions of Prebid, see below | `[]` | +| params.maxSegs | Integer | Maximum number of cohorts to be included in either the `permutive` or `p_standard` key-value. | `500` | -- **Custom Cohorts:** When enabling the respective Activation for a cohort in Permutive, this module will automatically attach that cohort ID to the bid request. There is no need to enable individual bidders in the module configuration, it will automatically reflect which SSP integrations you have enabled in your Permutive dashboard. Permutive cohorts will be sent in the `permutive` key-value. +#### Context -- **Audience Connector:** You'll need to define which bidders should receive Audience Connector cohorts. You need to include the `ID` of any bidder in the `acBidders` array. Audience Connector cohorts will be sent in the `p_standard` key-value. +Permutive is not listed as a TCF vendor as all data collection is on behalf of the publisher and based on consent the publisher has received from the user. +Rather than through the TCF framework, this consent is provided to Permutive when the user gives the relevant permissions on the publisher website which allow the Permutive SDK to run. +This means that if GDPR enforcement is configured _and_ the user consent isn’t given for Permutive to fire, no cohorts will populate. +As Prebid utilizes TCF vendor consent, for the Permutive RTD module to load, Permutive needs to be labeled within the Vendor Exceptions -## Parameters +#### Instructions + +1. Publisher enables rules within Prebid GDPR module +2. Label Permutive as an exception, as shown below. +```javascript +[ + { + purpose: 'storage', + enforcePurpose: true, + enforceVendor: true, + vendorExceptions: ["permutive"] + }, + { + purpose: 'basicAds', + enforcePurpose: true, + enforceVendor: true, + vendorExceptions: [] + } +] +``` + +Before making any updates to this configuration, please ensure that this approach aligns with internal policies and current regulations regarding consent. + +## Cohort Activation with Permutive RTD Module + +**Note**: Publishers must be enabled on the above Permutive RTD Submodule to enable Standard Cohorts. + +### _Enabling Publisher Cohorts_ + +#### Standard Cohorts + +The Permutive RTD module sets Standard Cohort IDs as bidder-specific ortb2.user.data first-party data, following the Prebid ortb2 convention. Cohorts will be sent in the `p_standard` key-value. + +For Prebid versions below 7.29.0, populate the acbidders config in the Permutive RTD with an array of bidder codes with whom you wish to share Standard Cohorts with. You also need to permission the bidders by communicating the bidder list to the Permutive team at strategicpartnershipops@permutive.com. + +For Prebid versions 7.29.0 and above, do not populate bidder codes in acbidders for the purpose of sharing Standard Cohorts (Note: there may be other business needs that require you to populate acbidders for Prebid versions 7.29.0+, see Advertiser Cohorts below). To share Standard Cohorts with bidders in Prebid versions 7.29.0 and above, communicate the bidder list to the Permutive team at strategicpartnershipops@permutive.com. + +#### _Bidder Specific Requirements for Standard Cohorts_ +For PubMatic or OpenX: Please ensure you are using Prebid.js 7.13 (or later) +For Xandr: Please ensure you are using Prebid.js 7.29 (or later) +For Equativ: Please ensure you are using Prebid.js 7.26 (or later) + +#### Custom Cohorts + +The Permutive RTD module also supports passing any of the **Custom** Cohorts created in the dashboard to some SSP partners for targeting +e.g. setting up publisher deals. For these activations, cohort IDs are set in bidder-specific locations per ad unit (custom parameters). + +Currently, bidders with known support for custom cohort targeting are: + +- Xandr +- Magnite + +When enabling the respective Activation for a cohort in Permutive, this module will automatically attach that cohort ID to the bid request. +There is no need to enable individual bidders in the module configuration, it will automatically reflect which SSP integrations you have enabled in your Permutive dashboard. +Permutive cohorts will be sent in the permutive key-value. + + +### _Enabling Advertiser Cohorts_ + +If you are connecting to an Advertiser seat within Permutive to share Advertiser Cohorts, populate the acbidders config in the Permutive RTD with an array of bidder codes with whom you wish to share Advertiser Cohorts with. + +### _Managing acbidders_ + +If your business needs require you to populate acbidders with bidder codes based on the criteria above, there are **two** ways to manage it. + +#### Option 1 - Automated + +If you are using Prebid.js v7.13.0+, bidders may be added to or removed from the acbidders config directly within the Permutive Dashboard. + +**Permutive can do this on your behalf**. Simply contact your Permutive CSM with strategicpartnershipops@permutive.com on cc, +indicating which bidders you would like added. + +Or, a publisher may do this themselves within the Permutive Dashboard using the below instructions. + +##### Create Integration + +In order to manage acbidders via the Permutive dashboard, it is necessary to first enable the Prebid integration via the integrations page (settings). + +**Note on Revenue Insights:** The prebid integration includes a feature for revenue insights, +which is not required for the purpose of updating acbidders config. +Please see [this document](https://support.permutive.com/hc/en-us/articles/360019044079-Revenue-Insights) for more information about revenue insights. + +##### Update acbidders + +The input for the “Data Provider config” is a multi-input free text. A valid “bidder code” needs to be entered in order to enable Standard or Advertiser Cohorts to be passed to the desired partner. The [prebid Bidders page](https://docs.prebid.org/dev-docs/bidders.html) contains instructions and a link to a list of possible bidder codes. -| Name | Type | Description | Default | -| ---------------------- | -------- | --------------------------------------------------------------------------------------------- | ------- | -| name | String | This should always be `permutive` | - | -| waitForIt | Boolean | Should be `true` if there's an `auctionDelay` defined (optional) | `false` | -| params | Object | | - | -| params.acBidders | String[] | An array of bidders which should receive AC cohorts. | `[]` | -| params.maxSegs | Integer | Maximum number of cohorts to be included in either the `permutive` or `p_standard` key-value. | `500` | -| params.transformations | Object[] | An array of configurations for ORTB2 user data transformations | | +Bidders can be added or removed from acbidders using this feature, however, this will not impact any bidders that have been applied using the manual method below. -### The `transformations` parameter +#### Option 2 - Manual -This array contains configurations for transformations we'll apply to the Permutive object in the ORTB2 `user.data` array. The results of these transformations will be appended to the `user.data` array that's attached to ORTB2 bid requests. +As a secondary option, bidders may be added manually. -#### Supported transformations +To do so, define which bidders should receive Standard or Advertiser Cohorts by +including the _bidder code_ of any bidder in the `acBidders` array. -| Name | ID | Config structure | Description | -| -------------- | --- | ------------------------------------------------- | ------------------------------------------------------------------------------------ | -| IAB taxonomies | iab | { segtax: number, iabIds: Object} | Transform segment IDs from Permutive to IAB (note: alpha version, subject to change) | +**Note:** If you ever need to remove a manually-added bidder, the bidder will also need to be removed manually. diff --git a/modules/pgamsspBidAdapter.js b/modules/pgamsspBidAdapter.js new file mode 100644 index 00000000000..7d285daf3c6 --- /dev/null +++ b/modules/pgamsspBidAdapter.js @@ -0,0 +1,212 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'pgamssp'; +const AD_URL = 'https://us-east.pgammedia.com/pbjs'; +const SYNC_URL = 'https://cs.pgammedia.com'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/pgamsspBidAdapter.md b/modules/pgamsspBidAdapter.md new file mode 100644 index 00000000000..c162ec33053 --- /dev/null +++ b/modules/pgamsspBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: PGAMSSP Bidder Adapter +Module Type: PGAMSSP Bidder Adapter +Maintainer: info@pgammedia.com +``` + +# Description + +Connects to PGAMSSP exchange for bids. +PGAMSSP bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'pgamssp', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'pgamssp', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'pgamssp', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/pianoDmpAnalyticcsAdapter.md b/modules/pianoDmpAnalyticcsAdapter.md new file mode 100644 index 00000000000..9bdcaaf0c7a --- /dev/null +++ b/modules/pianoDmpAnalyticcsAdapter.md @@ -0,0 +1,13 @@ +# Overview + +Module Name: Piano DMP Analytics Adapter + +Module Type: Analytics Adapter + +Maintainer: [support@piano.com](mailto:support@piano.com) + +# Description + +Analytics adapter to be used with cx.js + +Visit [https://piano.io/product/dmp/](https://piano.io/product/dmp/) for more information. diff --git a/modules/pianoDmpAnalyticsAdapter.js b/modules/pianoDmpAnalyticsAdapter.js new file mode 100644 index 00000000000..47159475b5d --- /dev/null +++ b/modules/pianoDmpAnalyticsAdapter.js @@ -0,0 +1,38 @@ +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; +import adapterManager from '../src/adapterManager.js'; + +const pianoDmpAnalytics = adapter({ analyticsType: 'bundle', handler: 'on' }); + +const { enableAnalytics: _enableAnalytics } = pianoDmpAnalytics; + +Object.assign(pianoDmpAnalytics, { + /** + * Save event in the global array that will be consumed later by cx.js + */ + track: ({ eventType, args: params }) => { + window.cX.callQueue.push([ + 'prebid', + { eventType, params, time: Date.now() }, + ]); + }, + + /** + * Before forwarding the call to the original enableAnalytics function - + * create (if needed) the global array that is used to pass events to the cx.js library + * by the 'track' function above. + */ + enableAnalytics: function (...args) { + window.cX = window.cX || {}; + window.cX.callQueue = window.cX.callQueue || []; + + return _enableAnalytics.call(this, ...args); + }, +}); + +adapterManager.registerAnalyticsAdapter({ + adapter: pianoDmpAnalytics, + code: 'pianoDmp', + gvlid: 412, +}); + +export default pianoDmpAnalytics; diff --git a/modules/pixfutureBidAdapter.js b/modules/pixfutureBidAdapter.js index 29552ec796d..1c3f9b8da1a 100644 --- a/modules/pixfutureBidAdapter.js +++ b/modules/pixfutureBidAdapter.js @@ -3,23 +3,21 @@ import {getStorageManager} from '../src/storageManager.js'; import {BANNER} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; import {find, includes} from '../src/polyfill.js'; -import { - convertCamelToUnderscore, - deepAccess, - isArray, - isEmpty, - isFn, - isNumber, - isPlainObject, - transformBidderParamKeywords -} from '../src/utils.js'; +import {deepAccess, isArray, isFn, isNumber, isPlainObject} from '../src/utils.js'; import {auctionManager} from '../src/auctionManager.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {getANKeywordParam} from '../libraries/appnexusUtils/anKeywords.js'; +import {convertCamelToUnderscore} from '../libraries/appnexusUtils/anUtils.js'; const SOURCE = 'pbjs'; const storageManager = getStorageManager({bidderCode: 'pixfuture'}); const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language']; +let pixID = ''; +const GVLID = 839; + export const spec = { code: 'pixfuture', + gvlid: GVLID, hostname: 'https://gosrv.pixfuture.com', getHostname() { @@ -40,9 +38,13 @@ export const spec = { const tags = validBidRequests.map(bidToTag); const hostname = this.getHostname(); return validBidRequests.map((bidRequest) => { + if (bidRequest.params.pix_id) { + pixID = bidRequest.params.pix_id + } + let referer = ''; if (bidderRequest && bidderRequest.refererInfo) { - referer = bidderRequest.refererInfo.referer || ''; + referer = bidderRequest.refererInfo.page || ''; } const userObjBid = find(validBidRequests, hasUserInfo); @@ -90,7 +92,8 @@ export const spec = { if (bidderRequest && bidderRequest.refererInfo) { let refererinfo = { - rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer), + // TODO: this collects everything it finds, except for canonicalUrl + rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation), rd_top: bidderRequest.refererInfo.reachedTop, rd_ifs: bidderRequest.refererInfo.numIframes, rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(',') @@ -101,7 +104,6 @@ export const spec = { if (validBidRequests[0].userId) { let eids = []; - addUserId(eids, deepAccess(validBidRequests[0], `userId.flocId.id`), 'chrome.com', null); addUserId(eids, deepAccess(validBidRequests[0], `userId.criteoId`), 'criteo.com', null); addUserId(eids, deepAccess(validBidRequests[0], `userId.unifiedId`), 'thetradedesk.com', null); addUserId(eids, deepAccess(validBidRequests[0], `userId.id5Id`), 'id5.io', null); @@ -122,13 +124,14 @@ export const spec = { const ret = { url: `${hostname}/pixservices`, method: 'POST', - options: {withCredentials: false}, + options: {withCredentials: true}, data: { - v: $$PREBID_GLOBAL$$.version, + v: getGlobal().version, pageUrl: referer, bidId: bidRequest.bidId, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidRequest.auctionId, - transactionId: bidRequest.transactionId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, adUnitCode: bidRequest.adUnitCode, bidRequestCount: bidRequest.bidRequestCount, sizes: bidRequest.sizes, @@ -161,15 +164,39 @@ export const spec = { return bids; }, - getUserSyncs: function (syncOptions, bid, gdprConsent) { - var pixid = ''; - if (typeof bid[0] === 'undefined' || bid[0] === null) { pixid = '0'; } else { pixid = bid[0].body.pix_id; } - if (syncOptions.iframeEnabled && hasPurpose1Consent({gdprConsent})) { - return [{ + getUserSyncs: function (syncOptions, bid, gdprConsent, uspConsent) { + const syncs = []; + + let syncurl = 'pixid=' + pixID; + let gdpr = (gdprConsent && gdprConsent.gdprApplies) ? 1 : 0; + let consent = gdprConsent ? encodeURIComponent(gdprConsent.consentString || '') : ''; + + // Attaching GDPR Consent Params in UserSync url + syncurl += '&gdprconcent=' + gdpr + '&adsync=' + consent; + + // CCPA + if (uspConsent) { + syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); + } + + // coppa compliance + if (config.getConfig('coppa') === true) { + syncurl += '&coppa=1'; + } + + if (syncOptions.iframeEnabled) { + syncs.push({ type: 'iframe', - url: 'https://gosrv.pixfuture.com/cookiesync?adsync=' + gdprConsent.consentString + '&pixid=' + pixid + '&gdprconcent=' + gdprConsent.gdprApplies - }]; + url: 'https://gosrv.pixfuture.com/cookiesync?f=b&' + syncurl + }); + } else { + syncs.push({ + type: 'image', + url: 'https://gosrv.pixfuture.com/cookiesync?f=i&' + syncurl + }); } + + return syncs; } }; @@ -197,16 +224,6 @@ function newBid(serverBid, rtbBid, placementId, uuid) { return bid; } -function hasPurpose1Consent(bidderRequest) { - let result = true; - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) { - result = !!(deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} - // Functions related optional parameters function bidToTag(bid) { const tag = {}; @@ -220,7 +237,7 @@ function bidToTag(bid) { tag.code = bid.params.invCode; } tag.allow_smaller_sizes = bid.params.allowSmallerSizes || false; - tag.use_pmt_rule = bid.params.usePaymentRule || false + tag.use_pmt_rule = bid.params.usePaymentRule || false; tag.prebid = true; tag.disable_psa = true; let bidFloor = getBidFloor(bid); @@ -229,6 +246,13 @@ function bidToTag(bid) { } if (bid.params.position) { tag.position = {'above': 1, 'below': 2}[bid.params.position] || 0; + } else { + let mediaTypePos = deepAccess(bid, `mediaTypes.banner.pos`) || deepAccess(bid, `mediaTypes.video.pos`); + // only support unknown, atf, and btf values for position at this time + if (mediaTypePos === 0 || mediaTypePos === 1 || mediaTypePos === 3) { + // ortb spec treats btf === 3, but our system interprets btf === 2; so converting the ortb value here for consistency + tag.position = (mediaTypePos === 3) ? 2 : mediaTypePos; + } } if (bid.params.trafficSourceCode) { tag.traffic_source_code = bid.params.trafficSourceCode; @@ -251,14 +275,7 @@ function bidToTag(bid) { if (bid.params.externalImpId) { tag.external_imp_id = bid.params.externalImpId; } - if (!isEmpty(bid.params.keywords)) { - let keywords = transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - tag.keywords = keywords; - } + tag.keywords = getANKeywordParam(bid.ortb2, bid.params.keywords) let gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); if (gpid) { @@ -272,7 +289,7 @@ function bidToTag(bid) { if (bid.params.frameworks && isArray(bid.params.frameworks)) { tag['banner_frameworks'] = bid.params.frameworks; } - + // TODO: why does this need to iterate through every adUnit? let adUnit = find(auctionManager.getAdUnits(), au => bid.transactionId === au.transactionId); if (adUnit && adUnit.mediaTypes && adUnit.mediaTypes.banner) { tag.ad_types.push(BANNER); @@ -338,14 +355,4 @@ function getBidFloor(bid) { return null; } -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} - -function isPopulatedArray(arr) { - return !!(isArray(arr) && arr.length > 0); -} - registerBidder(spec); diff --git a/modules/piximediaBidAdapter.md b/modules/piximediaBidAdapter.md deleted file mode 100644 index fae014cbdff..00000000000 --- a/modules/piximediaBidAdapter.md +++ /dev/null @@ -1,25 +0,0 @@ -# Overview - -**Module Name**: Piximedia Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: contact@piximedia.fr - -# Description - -Piximedia Bidder Adapter for Prebid.js. - -# Test Parameters -``` - var adUnits = [{ - code: 'mpu', - sizes: [[300, 250]], - bids: [{ - bidder: 'piximedia', - params: { - siteId: 'PIXIMEDIA', - placementId: 'PREBID' - } - }] - }]; - -``` diff --git a/modules/platformioBidAdapter.md b/modules/platformioBidAdapter.md deleted file mode 100644 index 863e023f0d7..00000000000 --- a/modules/platformioBidAdapter.md +++ /dev/null @@ -1,86 +0,0 @@ -# Overview - -**Module Name**: Platform.io Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: siarhei.kasukhin@platform.io - -# Description - -Connects to Platform.io demand source to fetch bids. -Banner, Native, Video formats are supported. -Please use ```platformio``` as the bidder code. - -# Test Parameters -``` - var adUnits = [{ - code: 'dfp-native-div', - mediaTypes: { - native: { - title: { - required: true, - len: 75 - }, - image: { - required: true - }, - body: { - len: 200 - }, - icon: { - required: false - } - } - }, - bids: [{ - bidder: 'platformio', - params: { - pubId: '29521', - siteId: '26048', - placementId: '123', - bidFloor: '0.001', // optional - ifa: 'XXX-XXX', // optional - latitude: '40.712775', // optional - longitude: '-74.005973', // optional - } - }] - }, - { - code: 'dfp-banner-div', - mediaTypes: { - banner: { - sizes: [ - [300, 250],[300,600] - ], - } - }, - bids: [{ - bidder: 'platformio', - params: { - pubId: '29521', - siteId: '26049', - placementId: '123', - } - }] - }, - { - code: 'dfp-video-div', - mediaTypes: { - video: { - playerSize: [[640, 480]], - context: "instream" - } - }, - bids: [{ - bidder: 'platformio', - params: { - pubId: '29521', - siteId: '26049', - placementId: '123', - video: { - skipppable: true, - } - } - }] - } - ]; -``` diff --git a/modules/playwireBidAdapter.md b/modules/playwireBidAdapter.md deleted file mode 100644 index dddb57c9bc1..00000000000 --- a/modules/playwireBidAdapter.md +++ /dev/null @@ -1,61 +0,0 @@ -# Overview - -Module Name: Playwire Bidder Adapter -Module Type: Bidder Adapter -Maintainer: grid-tech@themediagrid.com - -# Description - -Module that connects to Grid demand source to fetch bids. -The adapter is GDPR compliant and supports banner and video (instream and outstream). - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "playwire", - params: { - uid: '1', - bidFloor: 0.5 - } - } - ] - },{ - code: 'test-div', - sizes: [[728, 90]], - bids: [ - { - bidder: "playwire", - params: { - uid: 2, - keywords: { - brandsafety: ['disaster'], - topic: ['stress', 'fear'] - } - } - } - ] - }, - { - code: 'test-div', - sizes: [[728, 90]], - mediaTypes: { video: { - context: 'instream', - playerSize: [728, 90], - mimes: ['video/mp4'] - }, - bids: [ - { - bidder: "playwire", - params: { - uid: 11 - } - } - ] - } - ]; -``` diff --git a/modules/polluxBidAdapter.md b/modules/polluxBidAdapter.md deleted file mode 100644 index 79bf84e79b9..00000000000 --- a/modules/polluxBidAdapter.md +++ /dev/null @@ -1,33 +0,0 @@ -# Overview - -**Module Name**: Pollux Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: tech@polluxnetwork.com - -# Description - -Module that connects to Pollux Network LLC demand source to fetch bids. -All bids will present CPM in EUR (Euro). - -# Test Parameters -``` - var adUnits = [{ - code: '34f724kh32', - sizes: [[300, 250]], // a single size - bids: [{ - bidder: 'pollux', - params: { - zone: '1806' // a single zone - } - }] - },{ - code: '34f789r783', - sizes: [[300, 250], [728, 90]], // multiple sizes - bids: [{ - bidder: 'pollux', - params: { - zone: '1806,276' // multiple zones, max 5 - } - }] - }]; -``` diff --git a/modules/polymorphBidAdapter.md b/modules/polymorphBidAdapter.md deleted file mode 100644 index e778b312e56..00000000000 --- a/modules/polymorphBidAdapter.md +++ /dev/null @@ -1,43 +0,0 @@ -# Overview - -``` -Module Name: Polymorph Bidder Adapter -Module Type: Bidder Adapter -Maintainer: kuldeep@getpolymorph.com -``` - -# Description - -Connects to Polymorph Demand Cloud (s2s header-bidding) - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div-1', - sizes: [[300, 250]], - bids: [ - { - bidder: "polymorph", - params: { - placementId: 'ping' - } - } - ] - },{ - code: 'test-div-2', - sizes: [[300, 250], [300,600]] - bids: [ - { - bidder: "polymorph", - params: { - placementId: 'ping', - // In case multiple ad sizes are supported, it's recommended to specify default height and width for native ad (in case native ad is chose as a winner). In case of banner or outstream ad any one of the above sizes can be chosen depending on the highest bid. - defaultWidth: 300, - defaultHeight: 600 - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/prebidServerBidAdapter/index.js b/modules/prebidServerBidAdapter/index.js index d30fd5bf810..0fff93cdcd1 100644 --- a/modules/prebidServerBidAdapter/index.js +++ b/modules/prebidServerBidAdapter/index.js @@ -1,20 +1,11 @@ import Adapter from '../../src/adapter.js'; -import {createBid} from '../../src/bidfactory.js'; import { - bind, - cleanObj, - createTrackPixelHtml, deepAccess, deepClone, - deepSetValue, flatten, generateUUID, - getBidRequest, - getDefinedParams, getPrebidInternal, insertUserSyncIframe, - isArray, - isEmpty, isNumber, isPlainObject, isStr, @@ -22,31 +13,28 @@ import { logInfo, logMessage, logWarn, - mergeDeep, - parseSizesInput, - pick, timestamp, triggerPixel, - uniques + uniques, } from '../../src/utils.js'; import CONSTANTS from '../../src/constants.json'; -import adapterManager from '../../src/adapterManager.js'; -import { config } from '../../src/config.js'; -import { VIDEO, NATIVE } from '../../src/mediaTypes.js'; -import { isValid } from '../../src/adapters/bidderFactory.js'; +import adapterManager, {s2sActivityParams} from '../../src/adapterManager.js'; +import {config} from '../../src/config.js'; +import {addComponentAuction, isValid} from '../../src/adapters/bidderFactory.js'; import * as events from '../../src/events.js'; -import {find, includes} from '../../src/polyfill.js'; -import { S2S_VENDORS } from './config.js'; -import { ajax } from '../../src/ajax.js'; +import {includes} from '../../src/polyfill.js'; +import {S2S_VENDORS} from './config.js'; +import {ajax} from '../../src/ajax.js'; import {hook} from '../../src/hook.js'; +import {hasPurpose1Consent} from '../../src/utils/gpdr.js'; +import {buildPBSRequest, interpretPBSResponse} from './ortbConverter.js'; +import {useMetrics} from '../../src/utils/perfMetrics.js'; +import {isActivityAllowed} from '../../src/activities/rules.js'; +import {ACTIVITY_TRANSMIT_UFPD} from '../../src/activities/activities.js'; const getConfig = config.getConfig; const TYPE = CONSTANTS.S2S.SRC; let _syncCount = 0; -const DEFAULT_S2S_TTL = 60; -const DEFAULT_S2S_CURRENCY = 'USD'; -const DEFAULT_S2S_NETREVENUE = true; - let _s2sConfigs; let eidPermissions; @@ -93,12 +81,13 @@ let eidPermissions; * @property {boolean} [cacheMarkup] whether to cache the adm result * @property {string} [syncEndpoint] endpoint URL for syncing cookies * @property {Object} [extPrebid] properties will be merged into request.ext.prebid + * @property {Object} [ortbNative] base value for imp.native.request */ /** * @type {S2SDefaultConfig} */ -const s2sDefaultConfig = { +export const s2sDefaultConfig = { bidders: Object.freeze([]), timeout: 1000, syncTimeout: 1000, @@ -106,7 +95,12 @@ const s2sDefaultConfig = { adapter: 'prebidServer', allowUnknownBidderCodes: false, adapterOptions: {}, - syncUrlModifier: {} + syncUrlModifier: {}, + ortbNative: { + eventtrackers: [ + {event: 1, methods: [1, 2]} + ], + } }; config.setDefaults({ @@ -221,16 +215,29 @@ export function resetSyncedStatus() { /** * @param {Array} bidderCodes list of bidders to request user syncs for. */ -function queueSync(bidderCodes, gdprConsent, uspConsent, s2sConfig) { +function queueSync(bidderCodes, gdprConsent, uspConsent, gppConsent, s2sConfig) { if (_s2sConfigs.length === _syncCount) { return; } _syncCount++; + let filterSettings = {}; + const userSyncFilterSettings = getConfig('userSync.filterSettings'); + + if (userSyncFilterSettings) { + const { all, iframe, image } = userSyncFilterSettings; + const ifrm = iframe || all; + const img = image || all; + + if (ifrm) filterSettings = Object.assign({ iframe: ifrm }, filterSettings); + if (img) filterSettings = Object.assign({ image: img }, filterSettings); + } + const payload = { uuid: generateUUID(), bidders: bidderCodes, - account: s2sConfig.accountId + account: s2sConfig.accountId, + filterSettings }; let userSyncLimit = s2sConfig.userSyncLimit; @@ -251,6 +258,13 @@ function queueSync(bidderCodes, gdprConsent, uspConsent, s2sConfig) { payload.us_privacy = uspConsent; } + if (gppConsent) { + payload.gpp_sid = gppConsent.applicableSections.join(); + // should we add check if applicableSections was not equal to -1 (where user was out of scope)? + // this would be similar to what was done above for TCF + payload.gpp = gppConsent.gppString; + } + if (typeof s2sConfig.coopSync === 'boolean') { payload.coopSync = s2sConfig.coopSync; } @@ -282,7 +296,7 @@ function doAllSyncs(bidders, s2sConfig) { // if PBS reports this bidder doesn't have an ID, then call the sync and recurse to the next sync entry if (thisSync.no_cookie) { - doPreBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, bind.call(doAllSyncs, null, bidders, s2sConfig), s2sConfig); + doPreBidderSync(thisSync.usersync.type, thisSync.usersync.url, thisSync.bidder, doAllSyncs.bind(null, bidders, s2sConfig), s2sConfig); } else { // bidder already has an ID, so just recurse to the next sync entry doAllSyncs(bidders, s2sConfig); @@ -335,130 +349,24 @@ function doBidderSync(type, url, bidder, done, timeout) { * * @param {Array} bidders a list of bidder names */ -function doClientSideSyncs(bidders, gdprConsent, uspConsent) { +function doClientSideSyncs(bidders, gdprConsent, uspConsent, gppConsent) { bidders.forEach(bidder => { let clientAdapter = adapterManager.getBidAdapter(bidder); if (clientAdapter && clientAdapter.registerSyncs) { config.runWithBidder( bidder, - bind.call( - clientAdapter.registerSyncs, + clientAdapter.registerSyncs.bind( clientAdapter, [], gdprConsent, - uspConsent + uspConsent, + gppConsent ) ); } }); } -function _appendSiteAppDevice(request, pageUrl, accountId) { - if (!request) return; - - // ORTB specifies app OR site - if (typeof config.getConfig('app') === 'object') { - request.app = config.getConfig('app'); - request.app.publisher = {id: accountId} - } else { - request.site = {}; - if (isPlainObject(config.getConfig('site'))) { - request.site = config.getConfig('site'); - } - // set publisher.id if not already defined - if (!deepAccess(request.site, 'publisher.id')) { - deepSetValue(request.site, 'publisher.id', accountId); - } - // set site.page if not already defined - if (!request.site.page) { - request.site.page = pageUrl; - } - } - if (typeof config.getConfig('device') === 'object') { - request.device = config.getConfig('device'); - } - if (!request.device) { - request.device = {}; - } - if (!request.device.w) { - request.device.w = window.innerWidth; - } - if (!request.device.h) { - request.device.h = window.innerHeight; - } -} - -function addBidderFirstPartyDataToRequest(request) { - const bidderConfig = config.getBidderConfig(); - const fpdConfigs = Object.keys(bidderConfig).reduce((acc, bidder) => { - const currBidderConfig = bidderConfig[bidder]; - if (currBidderConfig.ortb2) { - const ortb2 = mergeDeep({}, currBidderConfig.ortb2); - - acc.push({ - bidders: [ bidder ], - config: { ortb2 } - }); - } - return acc; - }, []); - - if (fpdConfigs.length) { - deepSetValue(request, 'ext.prebid.bidderconfig', fpdConfigs); - } -} - -// https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=40 -let nativeDataIdMap = { - sponsoredBy: 1, // sponsored - body: 2, // desc - rating: 3, - likes: 4, - downloads: 5, - price: 6, - salePrice: 7, - phone: 8, - address: 9, - body2: 10, // desc2 - cta: 12 // ctatext -}; -let nativeDataNames = Object.keys(nativeDataIdMap); - -let nativeImgIdMap = { - icon: 1, - image: 3 -}; - -let nativeEventTrackerEventMap = { - impression: 1, - 'viewable-mrc50': 2, - 'viewable-mrc100': 3, - 'viewable-video50': 4, -}; - -let nativeEventTrackerMethodMap = { - img: 1, - js: 2 -}; - -// enable reverse lookup -[ - nativeDataIdMap, - nativeImgIdMap, - nativeEventTrackerEventMap, - nativeEventTrackerMethodMap -].forEach(map => { - Object.keys(map).forEach(key => { - map[map[key]] = key; - }); -}); - -/* - * Protocol spec for OpenRTB endpoint - * e.g., https:///v1/openrtb2/auction - */ -let nativeAssetCache = {}; // store processed native params to preserve - /** * map wurl to auction id and adId for use in the BID_WON event */ @@ -475,18 +383,6 @@ function addWurl(auctionId, adId, wurl) { } } -function getPbsResponseData(bidderRequests, response, pbsName, pbjsName) { - const bidderValues = deepAccess(response, `ext.${pbsName}`); - if (bidderValues) { - Object.keys(bidderValues).forEach(bidder => { - let biddersReq = find(bidderRequests, bidderReq => bidderReq.bidderCode === bidder); - if (biddersReq) { - biddersReq[pbjsName] = bidderValues[bidder]; - } - }); - } -} - /** * @param {string} auctionId * @param {string} adId generated value set to bidObject.adId by bidderFactory Bid() @@ -514,584 +410,6 @@ export function resetWurlMap() { wurlMap = {}; } -function ORTB2(s2sBidRequest, bidderRequests, adUnits, requestedBidders) { - this.s2sBidRequest = s2sBidRequest; - this.bidderRequests = bidderRequests; - this.adUnits = adUnits; - this.s2sConfig = s2sBidRequest.s2sConfig; - this.requestedBidders = requestedBidders; - - this.bidIdMap = {}; - this.adUnitsByImp = {}; - this.impRequested = {}; - this.auctionId = bidderRequests.map(br => br.auctionId).reduce((l, r) => (l == null || l === r) && r); - this.requestTimestamp = timestamp(); -} - -Object.assign(ORTB2.prototype, { - buildRequest() { - const {s2sBidRequest, bidderRequests: bidRequests, adUnits, s2sConfig, requestedBidders} = this; - - let imps = []; - let aliases = {}; - const firstBidRequest = bidRequests[0]; - - // transform ad unit into array of OpenRTB impression objects - let impIds = new Set(); - adUnits.forEach(adUnit => { - // TODO: support labels / conditional bids - // for now, just warn about them - adUnit.bids.forEach((bid) => { - if (bid.mediaTypes != null) { - logWarn(`Prebid Server adapter does not (yet) support bidder-specific mediaTypes for the same adUnit. Size mapping configuration will be ignored for adUnit: ${adUnit.code}, bidder: ${bid.bidder}`); - } - }) - - // in case there is a duplicate imp.id, add '-2' suffix to the second imp.id. - // e.g. if there are 2 adUnits (case of twin adUnit codes) with code 'test', - // first imp will have id 'test' and second imp will have id 'test-2' - let impressionId = adUnit.code; - let i = 1; - while (impIds.has(impressionId)) { - i++; - impressionId = `${adUnit.code}-${i}`; - } - impIds.add(impressionId); - this.adUnitsByImp[impressionId] = adUnit; - - const nativeParams = adUnit.nativeParams; - let nativeAssets; - if (nativeParams) { - try { - nativeAssets = nativeAssetCache[impressionId] = Object.keys(nativeParams).reduce((assets, type) => { - let params = nativeParams[type]; - - function newAsset(obj) { - return Object.assign({ - required: params.required ? 1 : 0 - }, obj ? cleanObj(obj) : {}); - } - - switch (type) { - case 'image': - case 'icon': - let imgTypeId = nativeImgIdMap[type]; - let asset = cleanObj({ - type: imgTypeId, - w: deepAccess(params, 'sizes.0'), - h: deepAccess(params, 'sizes.1'), - wmin: deepAccess(params, 'aspect_ratios.0.min_width'), - hmin: deepAccess(params, 'aspect_ratios.0.min_height') - }); - if (!((asset.w && asset.h) || (asset.hmin && asset.wmin))) { - throw 'invalid img sizes (must provide sizes or min_height & min_width if using aspect_ratios)'; - } - if (Array.isArray(params.aspect_ratios)) { - // pass aspect_ratios as ext data I guess? - const aspectRatios = params.aspect_ratios - .filter((ar) => ar.ratio_width && ar.ratio_height) - .map(ratio => `${ratio.ratio_width}:${ratio.ratio_height}`); - if (aspectRatios.length > 0) { - asset.ext = { - aspectratios: aspectRatios - } - } - } - assets.push(newAsset({ - img: asset - })); - break; - case 'title': - if (!params.len) { - throw 'invalid title.len'; - } - assets.push(newAsset({ - title: { - len: params.len - } - })); - break; - default: - let dataAssetTypeId = nativeDataIdMap[type]; - if (dataAssetTypeId) { - assets.push(newAsset({ - data: { - type: dataAssetTypeId, - len: params.len - } - })) - } - } - return assets; - }, []); - } catch (e) { - logError('error creating native request: ' + String(e)) - } - } - const videoParams = deepAccess(adUnit, 'mediaTypes.video'); - const bannerParams = deepAccess(adUnit, 'mediaTypes.banner'); - - adUnit.bids.forEach(bid => { - this.setBidRequestId(impressionId, bid.bidder, bid.bid_id); - // check for and store valid aliases to add to the request - if (adapterManager.aliasRegistry[bid.bidder]) { - const bidder = adapterManager.bidderRegistry[bid.bidder]; - // adding alias only if alias source bidder exists and alias isn't configured to be standalone - // pbs adapter - if (bidder && !bidder.getSpec().skipPbsAliasing) { - aliases[bid.bidder] = adapterManager.aliasRegistry[bid.bidder]; - } - } - }); - - let mediaTypes = {}; - if (bannerParams && bannerParams.sizes) { - const sizes = parseSizesInput(bannerParams.sizes); - - // get banner sizes in form [{ w: , h: }, ...] - const format = sizes.map(size => { - const [ width, height ] = size.split('x'); - const w = parseInt(width, 10); - const h = parseInt(height, 10); - return { w, h }; - }); - - mediaTypes['banner'] = {format}; - - if (bannerParams.pos) mediaTypes['banner'].pos = bannerParams.pos; - } - - if (!isEmpty(videoParams)) { - if (videoParams.context === 'outstream' && !videoParams.renderer && !adUnit.renderer) { - // Don't push oustream w/o renderer to request object. - logError('Outstream bid without renderer cannot be sent to Prebid Server.'); - } else { - if (videoParams.context === 'instream' && !videoParams.hasOwnProperty('placement')) { - videoParams.placement = 1; - } - - mediaTypes['video'] = Object.keys(videoParams).filter(param => param !== 'context') - .reduce((result, param) => { - if (param === 'playerSize') { - result.w = deepAccess(videoParams, `${param}.0.0`); - result.h = deepAccess(videoParams, `${param}.0.1`); - } else { - result[param] = videoParams[param]; - } - return result; - }, {}); - } - } - - if (nativeAssets) { - try { - mediaTypes['native'] = { - request: JSON.stringify({ - // TODO: determine best way to pass these and if we allow defaults - context: 1, - plcmttype: 1, - eventtrackers: [ - {event: 1, methods: [1]} - ], - // TODO: figure out how to support privacy field - // privacy: int - assets: nativeAssets - }), - ver: '1.2' - } - } catch (e) { - logError('error creating native request: ' + String(e)) - } - } - - // get bidder params in form { : {...params} } - // initialize reduce function with the user defined `ext` properties on the ad unit - const ext = adUnit.bids.reduce((acc, bid) => { - if (bid.bidder == null) return acc; - const adapter = adapterManager.bidderRegistry[bid.bidder]; - if (adapter && adapter.getSpec().transformBidParams) { - bid.params = adapter.getSpec().transformBidParams(bid.params, true, adUnit, bidRequests); - } - acc[bid.bidder] = (s2sConfig.adapterOptions && s2sConfig.adapterOptions[bid.bidder]) ? Object.assign({}, bid.params, s2sConfig.adapterOptions[bid.bidder]) : bid.params; - return acc; - }, {...deepAccess(adUnit, 'ortb2Imp.ext')}); - - const imp = { ...adUnit.ortb2Imp, id: impressionId, ext, secure: s2sConfig.secure }; - - const ortb2 = {...deepAccess(adUnit, 'ortb2Imp.ext.data')}; - Object.keys(ortb2).forEach(prop => { - /** - * Prebid AdSlot - * @type {(string|undefined)} - */ - if (prop === 'pbadslot') { - if (typeof ortb2[prop] === 'string' && ortb2[prop]) { - deepSetValue(imp, 'ext.data.pbadslot', ortb2[prop]); - } else { - // remove pbadslot property if it doesn't meet the spec - delete imp.ext.data.pbadslot; - } - } else if (prop === 'adserver') { - /** - * Copy GAM AdUnit and Name to imp - */ - ['name', 'adslot'].forEach(name => { - /** @type {(string|undefined)} */ - const value = deepAccess(ortb2, `adserver.${name}`); - if (typeof value === 'string' && value) { - deepSetValue(imp, `ext.data.adserver.${name.toLowerCase()}`, value); - } - }); - } else { - deepSetValue(imp, `ext.data.${prop}`, ortb2[prop]); - } - }); - - mergeDeep(imp, mediaTypes); - - // if storedAuctionResponse has been set, pass SRID - const storedAuctionResponseBid = find(firstBidRequest.bids, bid => (bid.adUnitCode === adUnit.code && bid.storedAuctionResponse)); - if (storedAuctionResponseBid) { - deepSetValue(imp, 'ext.prebid.storedauctionresponse.id', storedAuctionResponseBid.storedAuctionResponse.toString()); - } - - const getFloorBid = find(firstBidRequest.bids, bid => bid.adUnitCode === adUnit.code && typeof bid.getFloor === 'function'); - - if (getFloorBid) { - let floorInfo; - try { - floorInfo = getFloorBid.getFloor({ - currency: config.getConfig('currency.adServerCurrency') || DEFAULT_S2S_CURRENCY, - }); - } catch (e) { - logError('PBS: getFloor threw an error: ', e); - } - if (floorInfo && floorInfo.currency && !isNaN(parseFloat(floorInfo.floor))) { - imp.bidfloor = parseFloat(floorInfo.floor); - imp.bidfloorcur = floorInfo.currency - } - } - - if (imp.banner || imp.video || imp.native) { - imps.push(imp); - } - }); - - if (!imps.length) { - logError('Request to Prebid Server rejected due to invalid media type(s) in adUnit.'); - return; - } - const request = { - id: firstBidRequest.auctionId, - source: {tid: s2sBidRequest.tid}, - tmax: s2sConfig.timeout, - imp: imps, - // to do: add setconfig option to pass test = 1 - test: 0, - ext: { - prebid: { - // set ext.prebid.auctiontimestamp with the auction timestamp. Data type is long integer. - auctiontimestamp: firstBidRequest.auctionStart, - targeting: { - // includewinners is always true for openrtb - includewinners: true, - // includebidderkeys always false for openrtb - includebidderkeys: false - } - } - } - }; - - // This is no longer overwritten unless name and version explicitly overwritten by extPrebid (mergeDeep) - request.ext.prebid = Object.assign(request.ext.prebid, {channel: {name: 'pbjs', version: $$PREBID_GLOBAL$$.version}}) - - // set debug flag if in debug mode - if (getConfig('debug')) { - request.ext.prebid = Object.assign(request.ext.prebid, {debug: true}) - } - - // s2sConfig video.ext.prebid is passed through openrtb to PBS - if (s2sConfig.extPrebid && typeof s2sConfig.extPrebid === 'object') { - request.ext.prebid = mergeDeep(request.ext.prebid, s2sConfig.extPrebid); - } - - /** - * @type {(string[]|string|undefined)} - OpenRTB property 'cur', currencies available for bids - */ - const adServerCur = config.getConfig('currency.adServerCurrency'); - if (adServerCur && typeof adServerCur === 'string') { - // if the value is a string, wrap it with an array - request.cur = [adServerCur]; - } else if (Array.isArray(adServerCur) && adServerCur.length) { - // if it's an array, get the first element - request.cur = [adServerCur[0]]; - } - - _appendSiteAppDevice(request, bidRequests[0].refererInfo.referer, s2sConfig.accountId); - - // pass schain object if it is present - const schain = deepAccess(bidRequests, '0.bids.0.schain'); - if (schain) { - request.source.ext = { - schain: schain - }; - } - - if (!isEmpty(aliases)) { - request.ext.prebid.aliases = {...request.ext.prebid.aliases, ...aliases}; - } - - const bidUserIdAsEids = deepAccess(bidRequests, '0.bids.0.userIdAsEids'); - if (isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) { - deepSetValue(request, 'user.ext.eids', bidUserIdAsEids); - } - - if (isArray(eidPermissions) && eidPermissions.length > 0) { - if (requestedBidders && isArray(requestedBidders)) { - eidPermissions.forEach(i => { - if (i.bidders) { - i.bidders = i.bidders.filter(bidder => includes(requestedBidders, bidder)) - } - }); - } - deepSetValue(request, 'ext.prebid.data.eidpermissions', eidPermissions); - } - - const multibid = config.getConfig('multibid'); - if (multibid) { - deepSetValue(request, 'ext.prebid.multibid', multibid.reduce((result, i) => { - let obj = {}; - - Object.keys(i).forEach(key => { - obj[key.toLowerCase()] = i[key]; - }); - - result.push(obj); - - return result; - }, [])); - } - - if (bidRequests) { - if (firstBidRequest.gdprConsent) { - // note - gdprApplies & consentString may be undefined in certain use-cases for consentManagement module - let gdprApplies; - if (typeof firstBidRequest.gdprConsent.gdprApplies === 'boolean') { - gdprApplies = firstBidRequest.gdprConsent.gdprApplies ? 1 : 0; - } - deepSetValue(request, 'regs.ext.gdpr', gdprApplies); - deepSetValue(request, 'user.ext.consent', firstBidRequest.gdprConsent.consentString); - if (firstBidRequest.gdprConsent.addtlConsent && typeof firstBidRequest.gdprConsent.addtlConsent === 'string') { - deepSetValue(request, 'user.ext.ConsentedProvidersSettings.consented_providers', firstBidRequest.gdprConsent.addtlConsent); - } - } - - // US Privacy (CCPA) support - if (firstBidRequest.uspConsent) { - deepSetValue(request, 'regs.ext.us_privacy', firstBidRequest.uspConsent); - } - } - - if (getConfig('coppa') === true) { - deepSetValue(request, 'regs.coppa', 1); - } - - const commonFpd = getConfig('ortb2') || {}; - mergeDeep(request, commonFpd); - - addBidderFirstPartyDataToRequest(request); - - request.imp.forEach((imp) => this.impRequested[imp.id] = imp); - return request; - }, - - interpretResponse(response) { - const {bidderRequests, s2sConfig} = this; - const bids = []; - - [['errors', 'serverErrors'], ['responsetimemillis', 'serverResponseTimeMs']] - .forEach(info => getPbsResponseData(bidderRequests, response, info[0], info[1])) - - if (response.seatbid) { - // a seatbid object contains a `bid` array and a `seat` string - response.seatbid.forEach(seatbid => { - (seatbid.bid || []).forEach(bid => { - let bidRequest = this.getBidRequest(bid.impid, seatbid.seat); - if (bidRequest == null) { - if (!s2sConfig.allowUnknownBidderCodes) { - logWarn(`PBS adapter received bid from unknown bidder (${seatbid.seat}), but 's2sConfig.allowUnknownBidderCodes' is not set. Ignoring bid.`); - return; - } - // for stored impression, a request was made with bidder code `null`. Pick it up here so that NO_BID, BID_WON, etc events - // can work as expected (otherwise, the original request will always result in NO_BID). - bidRequest = this.getBidRequest(bid.impid, null); - } - - const cpm = bid.price; - const status = cpm !== 0 ? CONSTANTS.STATUS.GOOD : CONSTANTS.STATUS.NO_BID; - let bidObject = createBid(status, { - bidder: seatbid.seat, - src: TYPE, - bidId: bidRequest ? (bidRequest.bidId || bidRequest.bid_Id) : null, - transactionId: this.adUnitsByImp[bid.impid].transactionId, - auctionId: this.auctionId, - }); - bidObject.requestTimestamp = this.requestTimestamp; - bidObject.cpm = cpm; - - // temporarily leaving attaching it to each bidResponse so no breaking change - // BUT: this is a flat map, so it should be only attached to bidderRequest, a the change above does - let serverResponseTimeMs = deepAccess(response, ['ext', 'responsetimemillis', seatbid.seat].join('.')); - if (bidRequest && serverResponseTimeMs) { - bidRequest.serverResponseTimeMs = serverResponseTimeMs; - } - - // Look for seatbid[].bid[].ext.prebid.bidid and place it in the bidResponse object for use in analytics adapters as 'pbsBidId' - const bidId = deepAccess(bid, 'ext.prebid.bidid'); - if (isStr(bidId)) { - bidObject.pbsBidId = bidId; - } - - // store wurl by auctionId and adId so it can be accessed from the BID_WON event handler - if (isStr(deepAccess(bid, 'ext.prebid.events.win'))) { - addWurl(this.auctionId, bidObject.adId, deepAccess(bid, 'ext.prebid.events.win')); - } - - let extPrebidTargeting = deepAccess(bid, 'ext.prebid.targeting'); - - // If ext.prebid.targeting exists, add it as a property value named 'adserverTargeting' - // The removal of hb_winurl and hb_bidid targeting values is temporary - // once we get through the transition, this block will be removed. - if (isPlainObject(extPrebidTargeting)) { - // If wurl exists, remove hb_winurl and hb_bidid targeting attributes - if (isStr(deepAccess(bid, 'ext.prebid.events.win'))) { - extPrebidTargeting = getDefinedParams(extPrebidTargeting, Object.keys(extPrebidTargeting) - .filter(i => (i.indexOf('hb_winurl') === -1 && i.indexOf('hb_bidid') === -1))); - } - bidObject.adserverTargeting = extPrebidTargeting; - } - - bidObject.seatBidId = bid.id; - - if (deepAccess(bid, 'ext.prebid.type') === VIDEO) { - bidObject.mediaType = VIDEO; - const impReq = this.impRequested[bid.impid]; - [bidObject.playerWidth, bidObject.playerHeight] = [impReq.video.w, impReq.video.h]; - - // try to get cache values from 'response.ext.prebid.cache.js' - // else try 'bid.ext.prebid.targeting' as fallback - if (bid.ext.prebid.cache && typeof bid.ext.prebid.cache.vastXml === 'object' && bid.ext.prebid.cache.vastXml.cacheId && bid.ext.prebid.cache.vastXml.url) { - bidObject.videoCacheKey = bid.ext.prebid.cache.vastXml.cacheId; - bidObject.vastUrl = bid.ext.prebid.cache.vastXml.url; - } else if (extPrebidTargeting && extPrebidTargeting.hb_uuid && extPrebidTargeting.hb_cache_host && extPrebidTargeting.hb_cache_path) { - bidObject.videoCacheKey = extPrebidTargeting.hb_uuid; - // build url using key and cache host - bidObject.vastUrl = `https://${extPrebidTargeting.hb_cache_host}${extPrebidTargeting.hb_cache_path}?uuid=${extPrebidTargeting.hb_uuid}`; - } - - if (bid.adm) { bidObject.vastXml = bid.adm; } - if (!bidObject.vastUrl && bid.nurl) { bidObject.vastUrl = bid.nurl; } - } else if (deepAccess(bid, 'ext.prebid.type') === NATIVE) { - bidObject.mediaType = NATIVE; - let adm; - if (typeof bid.adm === 'string') { - adm = bidObject.adm = JSON.parse(bid.adm); - } else { - adm = bidObject.adm = bid.adm; - } - - let trackers = { - [nativeEventTrackerMethodMap.img]: adm.imptrackers || [], - [nativeEventTrackerMethodMap.js]: adm.jstracker ? [adm.jstracker] : [] - }; - if (adm.eventtrackers) { - adm.eventtrackers.forEach(tracker => { - switch (tracker.method) { - case nativeEventTrackerMethodMap.img: - trackers[nativeEventTrackerMethodMap.img].push(tracker.url); - break; - case nativeEventTrackerMethodMap.js: - trackers[nativeEventTrackerMethodMap.js].push(tracker.url); - break; - } - }); - } - - if (isPlainObject(adm) && Array.isArray(adm.assets)) { - let origAssets = nativeAssetCache[bid.impid]; - bidObject.native = cleanObj(adm.assets.reduce((native, asset) => { - let origAsset = origAssets[asset.id]; - if (isPlainObject(asset.img)) { - native[origAsset.img.type ? nativeImgIdMap[origAsset.img.type] : 'image'] = pick( - asset.img, - ['url', 'w as width', 'h as height'] - ); - } else if (isPlainObject(asset.title)) { - native['title'] = asset.title.text - } else if (isPlainObject(asset.data)) { - nativeDataNames.forEach(dataType => { - if (nativeDataIdMap[dataType] === origAsset.data.type) { - native[dataType] = asset.data.value; - } - }); - } - return native; - }, cleanObj({ - clickUrl: adm.link, - clickTrackers: deepAccess(adm, 'link.clicktrackers'), - impressionTrackers: trackers[nativeEventTrackerMethodMap.img], - javascriptTrackers: trackers[nativeEventTrackerMethodMap.js] - }))); - } else { - logError('prebid server native response contained no assets'); - } - } else { // banner - if (bid.adm && bid.nurl) { - bidObject.ad = bid.adm; - bidObject.ad += createTrackPixelHtml(decodeURIComponent(bid.nurl)); - } else if (bid.adm) { - bidObject.ad = bid.adm; - } else if (bid.nurl) { - bidObject.adUrl = bid.nurl; - } - } - - bidObject.width = bid.w; - bidObject.height = bid.h; - if (bid.dealid) { bidObject.dealId = bid.dealid; } - bidObject.creative_id = bid.crid; - bidObject.creativeId = bid.crid; - if (bid.burl) { bidObject.burl = bid.burl; } - bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY; - bidObject.meta = {}; - let extPrebidMeta = deepAccess(bid, 'ext.prebid.meta'); - if (extPrebidMeta && isPlainObject(extPrebidMeta)) { bidObject.meta = deepClone(extPrebidMeta); } - if (bid.adomain) { bidObject.meta.advertiserDomains = bid.adomain; } - - // the OpenRTB location for "TTL" as understood by Prebid.js is "exp" (expiration). - const configTtl = s2sConfig.defaultTtl || DEFAULT_S2S_TTL; - bidObject.ttl = (bid.exp) ? bid.exp : configTtl; - bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE; - - bids.push({ adUnit: this.adUnitsByImp[bid.impid].code, bid: bidObject }); - }); - }); - } - - return bids; - }, - setBidRequestId(impId, bidderCode, bidId) { - this.bidIdMap[this.impBidderKey(impId, bidderCode)] = bidId; - }, - getBidRequest(impId, bidderCode) { - const key = this.impBidderKey(impId, bidderCode); - return this.bidIdMap[key] && getBidRequest(this.bidIdMap[key], this.bidderRequests); - }, - impBidderKey(impId, bidderCode) { - return `${impId}${bidderCode}`; - } -}); - /** * BID_WON event to request the wurl * @param {Bid} bid the winning bid object @@ -1107,27 +425,18 @@ function bidWonHandler(bid) { } } -function hasPurpose1Consent(gdprConsent) { - let result = true; - if (gdprConsent) { - if (gdprConsent.gdprApplies && gdprConsent.apiVersion === 2) { - result = !!(deepAccess(gdprConsent, 'vendorData.purpose.consents.1') === true); - } - } - return result; -} - function getMatchingConsentUrl(urlProp, gdprConsent) { return hasPurpose1Consent(gdprConsent) ? urlProp.p1Consent : urlProp.noP1Consent; } function getConsentData(bidRequests) { - let gdprConsent, uspConsent; + let gdprConsent, uspConsent, gppConsent; if (Array.isArray(bidRequests) && bidRequests.length > 0) { gdprConsent = bidRequests[0].gdprConsent; uspConsent = bidRequests[0].uspConsent; + gppConsent = bidRequests[0].gppConsent; } - return { gdprConsent, uspConsent }; + return { gdprConsent, uspConsent, gppConsent }; } /** @@ -1138,7 +447,13 @@ export function PrebidServer() { /* Prebid executes this function when the page asks to send out bid requests */ baseAdapter.callBids = function(s2sBidRequest, bidRequests, addBidResponse, done, ajax) { - let { gdprConsent, uspConsent } = getConsentData(bidRequests); + const adapterMetrics = s2sBidRequest.metrics = useMetrics(deepAccess(bidRequests, '0.metrics')) + .newMetrics() + .renameWith((n) => [`adapter.s2s.${n}`, `adapters.s2s.${s2sBidRequest.s2sConfig.defaultVendor}.${n}`]) + done = adapterMetrics.startTiming('total').stopBefore(done); + bidRequests.forEach(req => useMetrics(req.metrics).join(adapterMetrics, {continuePropagation: false})); + + let { gdprConsent, uspConsent, gppConsent } = getConsentData(bidRequests); if (Array.isArray(_s2sConfigs)) { if (s2sBidRequest.s2sConfig && s2sBidRequest.s2sConfig.syncEndpoint && getMatchingConsentUrl(s2sBidRequest.s2sConfig.syncEndpoint, gdprConsent)) { @@ -1146,22 +461,50 @@ export function PrebidServer() { .map(bidder => adapterManager.aliasRegistry[bidder] || bidder) .filter((bidder, index, array) => (array.indexOf(bidder) === index)); - queueSync(syncBidders, gdprConsent, uspConsent, s2sBidRequest.s2sConfig); + queueSync(syncBidders, gdprConsent, uspConsent, gppConsent, s2sBidRequest.s2sConfig); } processPBSRequest(s2sBidRequest, bidRequests, ajax, { - onResponse: function (isValid, requestedBidders) { + onResponse: function (isValid, requestedBidders, response) { if (isValid) { bidRequests.forEach(bidderRequest => events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest)); } + if (shouldEmitNonbids(s2sBidRequest.s2sConfig, response)) { + events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, { + seatnonbid: response.ext.seatnonbid, + auctionId: bidRequests[0].auctionId, + requestedBidders, + response, + adapterMetrics + }); + } + done(); + doClientSideSyncs(requestedBidders, gdprConsent, uspConsent, gppConsent); + }, + onError(msg, error) { + logError(`Prebid server call failed: '${msg}'`, error); + bidRequests.forEach(bidderRequest => events.emit(CONSTANTS.EVENTS.BIDDER_ERROR, {error, bidderRequest})); done(); - doClientSideSyncs(requestedBidders, gdprConsent, uspConsent); }, - onError: done, onBid: function ({adUnit, bid}) { - if (isValid(adUnit, bid)) { - addBidResponse(adUnit, bid); + const metrics = bid.metrics = s2sBidRequest.metrics.fork().renameWith(); + metrics.checkpoint('addBidResponse'); + if ((bid.requestId == null || bid.requestBidder == null) && !s2sBidRequest.s2sConfig.allowUnknownBidderCodes) { + logWarn(`PBS adapter received bid from unknown bidder (${bid.bidder}), but 's2sConfig.allowUnknownBidderCodes' is not set. Ignoring bid.`); + addBidResponse.reject(adUnit, bid, CONSTANTS.REJECTION_REASON.BIDDER_DISALLOWED); + } else { + if (metrics.measureTime('addBidResponse.validate', () => isValid(adUnit, bid))) { + addBidResponse(adUnit, bid); + if (bid.pbsWurl) { + addWurl(bid.auctionId, bid.adId, bid.pbsWurl); + } + } else { + addBidResponse.reject(adUnit, bid, CONSTANTS.REJECTION_REASON.INVALID); + } } + }, + onFledge: ({adUnitCode, config}) => { + addComponentAuction(bidRequests[0].auctionId, adUnitCode, config); } }) } @@ -1187,36 +530,35 @@ export function PrebidServer() { * @param onError {function(String, {})} invoked on HTTP failure - with status message and XHR error * @param onBid {function({})} invoked once for each bid in the response - with the bid as returned by interpretResponse */ -export const processPBSRequest = hook('sync', function (s2sBidRequest, bidRequests, ajax, {onResponse, onError, onBid}) { +export const processPBSRequest = hook('sync', function (s2sBidRequest, bidRequests, ajax, {onResponse, onError, onBid, onFledge}) { let { gdprConsent } = getConsentData(bidRequests); const adUnits = deepClone(s2sBidRequest.ad_units); - // at this point ad units should have a size array either directly or mapped so filter for that - const validAdUnits = adUnits.filter(unit => - unit.mediaTypes && (unit.mediaTypes.native || (unit.mediaTypes.banner && unit.mediaTypes.banner.sizes) || (unit.mediaTypes.video && unit.mediaTypes.video.playerSize)) - ); - // in case config.bidders contains invalid bidders, we only process those we sent requests for - const requestedBidders = validAdUnits + const requestedBidders = adUnits .map(adUnit => adUnit.bids.map(bid => bid.bidder).filter(uniques)) - .reduce(flatten) + .reduce(flatten, []) .filter(uniques); - const ortb2 = new ORTB2(s2sBidRequest, bidRequests, validAdUnits, requestedBidders); - const request = ortb2.buildRequest(); + const request = s2sBidRequest.metrics.measureTime('buildRequests', () => buildPBSRequest(s2sBidRequest, bidRequests, adUnits, requestedBidders, eidPermissions)); const requestJson = request && JSON.stringify(request); logInfo('BidRequest: ' + requestJson); const endpointUrl = getMatchingConsentUrl(s2sBidRequest.s2sConfig.endpoint, gdprConsent); if (request && requestJson && endpointUrl) { + const networkDone = s2sBidRequest.metrics.startTiming('net'); ajax( endpointUrl, { success: function (response) { + networkDone(); let result; try { result = JSON.parse(response); - const bids = ortb2.interpretResponse(result); + const {bids, fledgeAuctionConfigs} = s2sBidRequest.metrics.measureTime('interpretResponse', () => interpretPBSResponse(result, request)); bids.forEach(onBid); + if (fledgeAuctionConfigs) { + fledgeAuctionConfigs.forEach(onFledge); + } } catch (error) { logError(error); } @@ -1224,19 +566,30 @@ export const processPBSRequest = hook('sync', function (s2sBidRequest, bidReques logError('error parsing response: ', result ? result.status : 'not valid JSON'); onResponse(false, requestedBidders); } else { - onResponse(true, requestedBidders); + onResponse(true, requestedBidders, result); } }, - error: onError + error: function () { + networkDone(); + onError.apply(this, arguments); + } }, requestJson, - {contentType: 'text/plain', withCredentials: true} + { + contentType: 'text/plain', + withCredentials: true, + browsingTopics: isActivityAllowed(ACTIVITY_TRANSMIT_UFPD, s2sActivityParams(s2sBidRequest.s2sConfig)) + } ); } else { logError('PBS request not made. Check endpoints.'); } }, 'processPBSRequest'); +function shouldEmitNonbids(s2sConfig, response) { + return s2sConfig?.extPrebid?.returnallbidstatus && response?.ext?.seatnonbid; +} + /** * Global setter that sets eids permissions for bidders * This setter is to be used by userId module when included diff --git a/modules/prebidServerBidAdapter/ortbConverter.js b/modules/prebidServerBidAdapter/ortbConverter.js new file mode 100644 index 00000000000..54f71c7dc3e --- /dev/null +++ b/modules/prebidServerBidAdapter/ortbConverter.js @@ -0,0 +1,324 @@ +import {ortbConverter} from '../../libraries/ortbConverter/converter.js'; +import { + deepAccess, + deepSetValue, + getBidRequest, + getDefinedParams, + isArray, + logError, + logWarn, + mergeDeep, + timestamp +} from '../../src/utils.js'; +import {config} from '../../src/config.js'; +import CONSTANTS from '../../src/constants.json'; +import {createBid} from '../../src/bidfactory.js'; +import {pbsExtensions} from '../../libraries/pbsExtensions/pbsExtensions.js'; +import {setImpBidParams} from '../../libraries/pbsExtensions/processors/params.js'; +import {SUPPORTED_MEDIA_TYPES} from '../../libraries/pbsExtensions/processors/mediaType.js'; +import {IMP, REQUEST, RESPONSE} from '../../src/pbjsORTB.js'; +import {redactor} from '../../src/activities/redactor.js'; +import {s2sActivityParams} from '../../src/adapterManager.js'; +import {activityParams} from '../../src/activities/activityParams.js'; +import {MODULE_TYPE_BIDDER} from '../../src/activities/modules.js'; +import {isActivityAllowed} from '../../src/activities/rules.js'; +import {ACTIVITY_TRANSMIT_TID} from '../../src/activities/activities.js'; +import {currencyCompare} from '../../libraries/currencyUtils/currency.js'; +import {minimum} from '../../src/utils/reducers.js'; + +const DEFAULT_S2S_TTL = 60; +const DEFAULT_S2S_CURRENCY = 'USD'; +const DEFAULT_S2S_NETREVENUE = true; +const BIDDER_SPECIFIC_REQUEST_PROPS = new Set(['bidderCode', 'bidderRequestId', 'uniquePbsTid', 'bids', 'timeout']); + +const PBS_CONVERTER = ortbConverter({ + processors: pbsExtensions, + context: { + netRevenue: DEFAULT_S2S_NETREVENUE, + }, + imp(buildImp, proxyBidRequest, context) { + Object.assign(context, proxyBidRequest.pbsData); + const imp = buildImp(proxyBidRequest, context); + (proxyBidRequest.bids || []).forEach(bid => { + if (bid.ortb2Imp && Object.keys(bid.ortb2Imp).length > 0) { + // set bidder-level imp attributes; see https://github.com/prebid/prebid-server/issues/2335 + deepSetValue(imp, `ext.prebid.imp.${bid.bidder}`, bid.ortb2Imp); + } + }); + if (Object.values(SUPPORTED_MEDIA_TYPES).some(mtype => imp[mtype])) { + imp.secure = context.s2sBidRequest.s2sConfig.secure; + return imp; + } + }, + request(buildRequest, imps, proxyBidderRequest, context) { + if (!imps.length) { + logError('Request to Prebid Server rejected due to invalid media type(s) in adUnit.'); + } else { + let {s2sBidRequest, requestedBidders, eidPermissions} = context; + const request = buildRequest(imps, proxyBidderRequest, context); + + request.tmax = s2sBidRequest.s2sConfig.timeout; + + [request.app, request.dooh, request.site].forEach(section => { + if (section && !section.publisher?.id) { + deepSetValue(section, 'publisher.id', s2sBidRequest.s2sConfig.accountId); + } + }) + + if (isArray(eidPermissions) && eidPermissions.length > 0) { + if (requestedBidders && isArray(requestedBidders)) { + eidPermissions = eidPermissions.map(p => ({ + ...p, + bidders: p.bidders.filter(bidder => requestedBidders.includes(bidder)) + })) + } + deepSetValue(request, 'ext.prebid.data.eidpermissions', eidPermissions); + } + + if (!context.transmitTids) { + deepSetValue(request, 'ext.prebid.createtids', false); + } + + return request; + } + }, + bidResponse(buildBidResponse, bid, context) { + // before sending the response throgh "stock" ortb conversion, here we need to: + // - filter out ones that come from an "unknown" bidder (if allowUnknownBidderCode is not set) + // - overwrite context.bidRequest with the actual bid request for this seat / imp combination + + let bidRequest = context.actualBidRequests.get(context.seatbid.seat); + if (bidRequest == null) { + // for stored impressions, a request was made with bidder code `null`. Pick it up here so that NO_BID, BID_WON, etc events + // can work as expected (otherwise, the original request will always result in NO_BID). + bidRequest = context.actualBidRequests.get(null); + } + + if (bidRequest) { + Object.assign(context, { + bidRequest, + bidderRequest: context.actualBidderRequests.find(req => req.bidderCode === bidRequest.bidder) + }) + } + + const bidResponse = buildBidResponse(bid, context); + bidResponse.requestBidder = bidRequest?.bidder; + + if (bidResponse.native?.ortb) { + // TODO: do we need to set bidResponse.adm here? + // Any consumers can now get the same object from bidResponse.native.ortb; + // I could not find any, which raises the question - who is looking for this? + bidResponse.adm = bidResponse.native.ortb; + } + + // because core has special treatment for PBS adapter responses, we need some additional processing + bidResponse.requestTimestamp = context.requestTimestamp; + return { + bid: Object.assign(createBid(CONSTANTS.STATUS.GOOD, { + src: CONSTANTS.S2S.SRC, + bidId: bidRequest ? (bidRequest.bidId || bidRequest.bid_Id) : null, + transactionId: context.adUnit.transactionId, + auctionId: context.bidderRequest.auctionId, + }), bidResponse), + adUnit: context.adUnit.code + }; + }, + overrides: { + [IMP]: { + id(orig, imp, proxyBidRequest, context) { + imp.id = context.impId; + }, + params(orig, imp, proxyBidRequest, context) { + // override params processing to do it for each bidRequest in this imp; + // also, take overrides from s2sConfig.adapterOptions + const adapterOptions = context.s2sBidRequest.s2sConfig.adapterOptions; + for (const req of context.actualBidRequests.values()) { + setImpBidParams(imp, req, context, context); + if (adapterOptions && adapterOptions[req.bidder]) { + Object.assign(imp.ext.prebid.bidder[req.bidder], adapterOptions[req.bidder]); + } + } + }, + bidfloor(orig, imp, proxyBidRequest, context) { + // for bid floors, we pass each bidRequest associated with this imp through normal bidfloor processing, + // and aggregate all of them into a single, minimum floor to put in the request + const getMin = minimum(currencyCompare(floor => [floor.bidfloor, floor.bidfloorcur])); + let min; + for (const req of context.actualBidRequests.values()) { + const floor = {}; + orig(floor, req, context); + // if any bid does not have a valid floor, do not attempt to send any to PBS + if (floor.bidfloorcur == null || floor.bidfloor == null) { + min = null; + break; + } + min = min == null ? floor : getMin(min, floor); + } + if (min != null) { + Object.assign(imp, min); + } + } + }, + [REQUEST]: { + fpd(orig, ortbRequest, proxyBidderRequest, context) { + // FPD is handled different for PBS - the base request will only contain global FPD; + // bidder-specific values are set in ext.prebid.bidderconfig + + if (context.transmitTids) { + deepSetValue(ortbRequest, 'source.tid', proxyBidderRequest.auctionId); + } + + mergeDeep(ortbRequest, context.s2sBidRequest.ortb2Fragments?.global); + + // also merge in s2sConfig.extPrebid + if (context.s2sBidRequest.s2sConfig.extPrebid && typeof context.s2sBidRequest.s2sConfig.extPrebid === 'object') { + deepSetValue(ortbRequest, 'ext.prebid', mergeDeep(ortbRequest.ext?.prebid || {}, context.s2sBidRequest.s2sConfig.extPrebid)); + } + + // for global FPD, check allowed activities against "prebid.pbsBidAdapter"... + context.getRedactor().ortb2(ortbRequest); + + const fpdConfigs = Object.entries(context.s2sBidRequest.ortb2Fragments?.bidder || {}).filter(([bidder]) => { + const bidders = context.s2sBidRequest.s2sConfig.bidders; + const allowUnknownBidderCodes = context.s2sBidRequest.s2sConfig.allowUnknownBidderCodes; + return allowUnknownBidderCodes || (bidders && bidders.includes(bidder)); + }).map(([bidder, ortb2]) => ({ + // ... but for bidder specific FPD we can use the actual bidder + bidders: [bidder], + config: {ortb2: context.getRedactor(bidder).ortb2(ortb2)} + })); + if (fpdConfigs.length) { + deepSetValue(ortbRequest, 'ext.prebid.bidderconfig', fpdConfigs); + } + }, + extPrebidAliases(orig, ortbRequest, proxyBidderRequest, context) { + // override alias processing to do it for each bidder in the request + context.actualBidderRequests.forEach(req => orig(ortbRequest, req, context)); + }, + sourceExtSchain(orig, ortbRequest, proxyBidderRequest, context) { + // pass schains in ext.prebid.schains, with the most commonly used one in source.ext.schain + let mainChain; + + let chains = (deepAccess(ortbRequest, 'ext.prebid.schains') || []); + const chainBidders = new Set(chains.flatMap((item) => item.bidders)); + + chains = Object.values( + chains + .concat(context.actualBidderRequests + .filter((req) => !chainBidders.has(req.bidderCode)) // schain defined in s2sConfig.extPrebid takes precedence + .map((req) => ({ + bidders: [req.bidderCode], + schain: deepAccess(req, 'bids.0.schain') + }))) + .filter(({bidders, schain}) => bidders?.length > 0 && schain) + .reduce((chains, {bidders, schain}) => { + const key = JSON.stringify(schain); + if (!chains.hasOwnProperty(key)) { + chains[key] = {bidders: new Set(), schain}; + } + bidders.forEach((bidder) => chains[key].bidders.add(bidder)); + if (mainChain == null || chains[key].bidders.size > mainChain.bidders.size) { + mainChain = chains[key] + } + return chains; + }, {}) + ).map(({bidders, schain}) => ({bidders: Array.from(bidders), schain})); + + if (mainChain != null) { + deepSetValue(ortbRequest, 'source.ext.schain', mainChain.schain); + } + + if (chains.length) { + deepSetValue(ortbRequest, 'ext.prebid.schains', chains); + } + } + }, + [RESPONSE]: { + serverSideStats(orig, response, ortbResponse, context) { + // override to process each request + context.actualBidderRequests.forEach(req => orig(response, ortbResponse, {...context, bidderRequest: req, bidRequests: req.bids})); + }, + fledgeAuctionConfigs(orig, response, ortbResponse, context) { + const configs = Object.values(context.impContext) + .flatMap((impCtx) => (impCtx.fledgeConfigs || []).map(cfg => ({adUnitCode: impCtx.adUnit.code, config: cfg.config}))); + if (configs.length > 0) { + response.fledgeAuctionConfigs = configs; + } + } + } + }, +}); + +export function buildPBSRequest(s2sBidRequest, bidderRequests, adUnits, requestedBidders, eidPermissions) { + const requestTimestamp = timestamp(); + const impIds = new Set(); + const proxyBidRequests = []; + const s2sParams = s2sActivityParams(s2sBidRequest.s2sConfig); + + const getRedactor = (() => { + const global = redactor(s2sParams); + const bidders = {}; + return (bidder) => { + if (bidder == null) return global; + if (!bidders.hasOwnProperty(bidder)) { + bidders[bidder] = redactor(activityParams(MODULE_TYPE_BIDDER, bidder)); + } + return bidders[bidder] + } + })(); + + adUnits = adUnits.map((au) => getRedactor().bidRequest(au)) + + adUnits.forEach(adUnit => { + const actualBidRequests = new Map(); + adUnits.bids = adUnit.bids.map(br => getRedactor(br.bidder).bidRequest(br)); + adUnit.bids.forEach((bid) => { + if (bid.mediaTypes != null) { + // TODO: support labels / conditional bids + // for now, just warn about them + logWarn(`Prebid Server adapter does not (yet) support bidder-specific mediaTypes for the same adUnit. Size mapping configuration will be ignored for adUnit: ${adUnit.code}, bidder: ${bid.bidder}`); + } + actualBidRequests.set(bid.bidder, getBidRequest(bid.bid_id, bidderRequests)); + }); + + let impId = adUnit.code; + let i = 1; + while (impIds.has(impId)) { + i++; + impId = `${adUnit.code}-${i}`; + } + impIds.add(impId) + proxyBidRequests.push({ + ...adUnit, + adUnitCode: adUnit.code, + ...getDefinedParams(actualBidRequests.values().next().value || {}, ['userId', 'userIdAsEids', 'schain']), + pbsData: {impId, actualBidRequests, adUnit}, + }); + }); + + const proxyBidderRequest = { + ...Object.fromEntries(Object.entries(bidderRequests[0]).filter(([k]) => !BIDDER_SPECIFIC_REQUEST_PROPS.has(k))), + fledgeEnabled: bidderRequests.some(req => req.fledgeEnabled) + } + + return PBS_CONVERTER.toORTB({ + bidderRequest: proxyBidderRequest, + bidRequests: proxyBidRequests, + context: { + currency: config.getConfig('currency.adServerCurrency') || DEFAULT_S2S_CURRENCY, + ttl: s2sBidRequest.s2sConfig.defaultTtl || DEFAULT_S2S_TTL, + requestTimestamp, + s2sBidRequest, + requestedBidders, + actualBidderRequests: bidderRequests, + eidPermissions, + nativeRequest: s2sBidRequest.s2sConfig.ortbNative, + getRedactor, + transmitTids: isActivityAllowed(ACTIVITY_TRANSMIT_TID, s2sParams), + } + }); +} + +export function interpretPBSResponse(response, request) { + return PBS_CONVERTER.fromORTB({response, request}); +} diff --git a/modules/prebidmanagerAnalyticsAdapter.js b/modules/prebidmanagerAnalyticsAdapter.js index 1ac7ba84916..b877918d16d 100644 --- a/modules/prebidmanagerAnalyticsAdapter.js +++ b/modules/prebidmanagerAnalyticsAdapter.js @@ -1,18 +1,19 @@ import { generateUUID, getParameterByName, logError, parseUrl, logInfo } from '../src/utils.js'; import {ajaxBuilder} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import CONSTANTS from '../src/constants.json'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; /** * prebidmanagerAnalyticsAdapter.js - analytics adapter for prebidmanager */ -export const storage = getStorageManager({gvlid: undefined, moduleName: 'prebidmanager'}); -const DEFAULT_EVENT_URL = 'https://endpoint.prebidmanager.com/endpoint' +export const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: 'prebidmanager'}); +const DEFAULT_EVENT_URL = 'https://endpt.prebidmanager.com/endpoint'; const analyticsType = 'endpoint'; -const analyticsName = 'Prebid Manager Analytics: '; +const analyticsName = 'Prebid Manager Analytics'; -var CONSTANTS = require('../src/constants.json'); let ajax = ajaxBuilder(0); var _VERSION = 1; @@ -28,8 +29,8 @@ var w = window; var d = document; var e = d.documentElement; var g = d.getElementsByTagName('body')[0]; -var x = w.innerWidth || e.clientWidth || g.clientWidth; -var y = w.innerHeight || e.clientHeight || g.clientHeight; +var x = (w && w.innerWidth) || (e && e.clientWidth) || (g && g.clientWidth); +var y = (w && w.innerHeight) || (e && e.clientHeight) || (g && g.clientHeight); var _pageView = { eventType: 'pageView', @@ -56,13 +57,20 @@ prebidmanagerAnalytics.originEnableAnalytics = prebidmanagerAnalytics.enableAnal prebidmanagerAnalytics.enableAnalytics = function (config) { initOptions = config.options || {}; initOptions.url = initOptions.url || DEFAULT_EVENT_URL; - pmAnalyticsEnabled = true; + initOptions.sampling = initOptions.sampling || 1; + + if (Math.floor(Math.random() * initOptions.sampling) === 0) { + pmAnalyticsEnabled = true; + flushInterval = setInterval(flush, 1000); + } else { + logInfo(`${analyticsName} isn't enabled because of sampling`); + } + prebidmanagerAnalytics.originEnableAnalytics(config); - flushInterval = setInterval(flush, 1000); }; prebidmanagerAnalytics.originDisableAnalytics = prebidmanagerAnalytics.disableAnalytics; -prebidmanagerAnalytics.disableAnalytics = function() { +prebidmanagerAnalytics.disableAnalytics = function () { if (!pmAnalyticsEnabled) { return; } @@ -95,7 +103,7 @@ function collectUtmTagData() { }); } } catch (e) { - logError(`${analyticsName}Error`, e); + logError(`${analyticsName} Error`, e); pmUtmTags['error_utm'] = 1; } return pmUtmTags; @@ -126,6 +134,16 @@ function flush() { pageInfo: collectPageInfo(), }; + if ('version' in initOptions) { + data.version = initOptions.version; + } + if ('tcf_compliant' in initOptions) { + data.tcf_compliant = initOptions.tcf_compliant; + } + if ('sampling' in initOptions) { + data.sampling = initOptions.sampling; + } + ajax( initOptions.url, () => logInfo(`${analyticsName} sent events batch`), @@ -142,65 +160,156 @@ function flush() { } } +function trimAdUnit(adUnit) { + if (!adUnit) return adUnit; + const res = {}; + res.code = adUnit.code; + res.sizes = adUnit.sizes; + return res; +} + +function trimBid(bid) { + if (!bid) return bid; + const res = {}; + res.auctionId = bid.auctionId; + res.bidder = bid.bidder; + res.bidderRequestId = bid.bidderRequestId; + res.bidId = bid.bidId; + res.crumbs = bid.crumbs; + res.cpm = bid.cpm; + res.currency = bid.currency; + res.mediaTypes = bid.mediaTypes; + res.sizes = bid.sizes; + res.transactionId = bid.transactionId; + res.adUnitCode = bid.adUnitCode; + res.bidRequestsCount = bid.bidRequestsCount; + res.serverResponseTimeMs = bid.serverResponseTimeMs; + return res; +} + +function trimBidderRequest(bidderRequest) { + if (!bidderRequest) return bidderRequest; + const res = {}; + res.auctionId = bidderRequest.auctionId; + res.auctionStart = bidderRequest.auctionStart; + res.bidderRequestId = bidderRequest.bidderRequestId; + res.bidderCode = bidderRequest.bidderCode; + res.bids = bidderRequest.bids && bidderRequest.bids.map(trimBid); + return res; +} + function handleEvent(eventType, eventArgs) { - eventArgs = eventArgs ? JSON.parse(JSON.stringify(eventArgs)) : {}; - var pmEvent = {}; + try { + eventArgs = eventArgs ? JSON.parse(JSON.stringify(eventArgs)) : {}; + } catch (e) { + // keep eventArgs as is + } + + const pmEvent = {}; switch (eventType) { case CONSTANTS.EVENTS.AUCTION_INIT: { - pmEvent = eventArgs; + pmEvent.auctionId = eventArgs.auctionId; + pmEvent.timeout = eventArgs.timeout; + pmEvent.eventType = eventArgs.eventType; + pmEvent.adUnits = eventArgs.adUnits && eventArgs.adUnits.map(trimAdUnit) + pmEvent.bidderRequests = eventArgs.bidderRequests && eventArgs.bidderRequests.map(trimBidderRequest) _startAuction = pmEvent.timestamp; _bidRequestTimeout = pmEvent.timeout; break; } case CONSTANTS.EVENTS.AUCTION_END: { - pmEvent = eventArgs; + pmEvent.auctionId = eventArgs.auctionId; + pmEvent.end = eventArgs.end; + pmEvent.start = eventArgs.start; + pmEvent.adUnitCodes = eventArgs.adUnitCodes; + pmEvent.bidsReceived = eventArgs.bidsReceived && eventArgs.bidsReceived.map(trimBid); pmEvent.start = _startAuction; pmEvent.end = Date.now(); break; } case CONSTANTS.EVENTS.BID_ADJUSTMENT: { - pmEvent.bidders = eventArgs; break; } case CONSTANTS.EVENTS.BID_TIMEOUT: { - pmEvent.bidders = eventArgs; + pmEvent.bidders = eventArgs && eventArgs.map ? eventArgs.map(trimBid) : eventArgs; pmEvent.duration = _bidRequestTimeout; break; } case CONSTANTS.EVENTS.BID_REQUESTED: { - pmEvent = eventArgs; + pmEvent.auctionId = eventArgs.auctionId; + pmEvent.bidderCode = eventArgs.bidderCode; + pmEvent.doneCbCallCount = eventArgs.doneCbCallCount; + pmEvent.start = eventArgs.start; + pmEvent.bidderRequestId = eventArgs.bidderRequestId; + pmEvent.bids = eventArgs.bids && eventArgs.bids.map(trimBid); + pmEvent.auctionStart = eventArgs.auctionStart; + pmEvent.timeout = eventArgs.timeout; break; } case CONSTANTS.EVENTS.BID_RESPONSE: { - pmEvent = eventArgs; - delete pmEvent.ad; + pmEvent.bidderCode = eventArgs.bidderCode; + pmEvent.width = eventArgs.width; + pmEvent.height = eventArgs.height; + pmEvent.adId = eventArgs.adId; + pmEvent.mediaType = eventArgs.mediaType; + pmEvent.cpm = eventArgs.cpm; + pmEvent.currency = eventArgs.currency; + pmEvent.requestId = eventArgs.requestId; + pmEvent.adUnitCode = eventArgs.adUnitCode; + pmEvent.auctionId = eventArgs.auctionId; + pmEvent.timeToRespond = eventArgs.timeToRespond; + pmEvent.responseTimestamp = eventArgs.responseTimestamp; + pmEvent.requestTimestamp = eventArgs.requestTimestamp; + pmEvent.netRevenue = eventArgs.netRevenue; + pmEvent.size = eventArgs.size; + pmEvent.adserverTargeting = eventArgs.adserverTargeting; break; } case CONSTANTS.EVENTS.BID_WON: { - pmEvent = eventArgs; - delete pmEvent.ad; - delete pmEvent.adUrl; + pmEvent.auctionId = eventArgs.auctionId; + pmEvent.adId = eventArgs.adId; + pmEvent.adserverTargeting = eventArgs.adserverTargeting; + pmEvent.adUnitCode = eventArgs.adUnitCode; + pmEvent.bidderCode = eventArgs.bidderCode; + pmEvent.height = eventArgs.height; + pmEvent.mediaType = eventArgs.mediaType; + pmEvent.netRevenue = eventArgs.netRevenue; + pmEvent.cpm = eventArgs.cpm; + pmEvent.requestTimestamp = eventArgs.requestTimestamp; + pmEvent.responseTimestamp = eventArgs.responseTimestamp; + pmEvent.size = eventArgs.size; + pmEvent.width = eventArgs.width; + pmEvent.currency = eventArgs.currency; + pmEvent.bidder = eventArgs.bidder; break; } case CONSTANTS.EVENTS.BIDDER_DONE: { - pmEvent = eventArgs; + pmEvent.auctionId = eventArgs.auctionId; + pmEvent.auctionStart = eventArgs.auctionStart; + pmEvent.bidderCode = eventArgs.bidderCode; + pmEvent.bidderRequestId = eventArgs.bidderRequestId; + pmEvent.bids = eventArgs.bids && eventArgs.bids.map(trimBid); + pmEvent.doneCbCallCount = eventArgs.doneCbCallCount; + pmEvent.start = eventArgs.start; + pmEvent.timeout = eventArgs.timeout; + pmEvent.tid = eventArgs.tid; + pmEvent.src = eventArgs.src; break; } case CONSTANTS.EVENTS.SET_TARGETING: { - pmEvent.targetings = eventArgs; break; } case CONSTANTS.EVENTS.REQUEST_BIDS: { - pmEvent = eventArgs; break; } case CONSTANTS.EVENTS.ADD_AD_UNITS: { - pmEvent = eventArgs; break; } case CONSTANTS.EVENTS.AD_RENDER_FAILED: { - pmEvent = eventArgs; + pmEvent.bid = eventArgs.bid; + pmEvent.message = eventArgs.message; + pmEvent.reason = eventArgs.reason; break; } default: @@ -215,7 +324,7 @@ function handleEvent(eventType, eventArgs) { function sendEvent(event) { _eventQueue.push(event); - logInfo(`${analyticsName}Event ${event.eventType}:`, event); + logInfo(`${analyticsName} Event ${event.eventType}:`, event); if (event.eventType === CONSTANTS.EVENTS.AUCTION_END) { flush(); diff --git a/modules/precisoBidAdapter.js b/modules/precisoBidAdapter.js new file mode 100644 index 00000000000..c7f7db56fd4 --- /dev/null +++ b/modules/precisoBidAdapter.js @@ -0,0 +1,164 @@ +import { logMessage, isFn, deepAccess } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +const BIDDER_CODE = 'preciso'; +const AD_URL = 'https://ssp-bidder.mndtrk.com/bid_request/openrtb'; +const URL_SYNC = 'https://ck.2trk.info/rtb/user/usersync.aspx?id=preciso_srl'; +const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO]; +const GVLID = 874; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, + gvlid: GVLID, + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && !isNaN(bid.params.publisherId) && bid.params.host == 'prebid'); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let winTop = window; + let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin + try { + location = new URL(bidderRequest.refererInfo.page) + winTop = window.top; + } catch (e) { + location = winTop.location; + logMessage(e); + }; + + let site = { + 'domain': location.domain || '', + 'page': location || '' + } + + let request = { + id: '123456678', + imp: validBidRequests.map(request => { + const { bidId, sizes, mediaType } = request + const item = { + id: bidId, + region: request.params.region, + traffic: mediaType, + bidFloor: getBidFloor(request) + } + + if (request.mediaTypes.banner) { + item.banner = { + format: (request.mediaTypes.banner.sizes || sizes).map(size => { + return { w: size[0], h: size[1] } + }), + } + } + + if (request.schain) { + item.schain = request.schain; + } + + return item + }), + + 'site': site, + 'deviceWidth': winTop.screen.width, + 'deviceHeight': winTop.screen.height, + 'language': (navigator && navigator.language) ? navigator.language : '', + 'secure': 1, + 'host': location.host, + 'page': location.pathname, + 'coppa': config.getConfig('coppa') === true ? 1 : 0 + }; + + request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0]) + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent + } + if (bidderRequest.gppConsent) { + request.gpp = bidderRequest.gppConsent; + } + } + + return { + method: 'POST', + url: AD_URL, + data: request, + + }; + }, + + interpretResponse: function (serverResponse) { + const response = serverResponse.body + + const bids = [] + + response.seatbid.forEach(seat => { + seat.bid.forEach(bid => { + bids.push({ + requestId: bid.impid, + cpm: bid.price, + width: bid.w, + height: bid.h, + creativeId: bid.crid, + ad: bid.adm, + currency: 'USD', + netRevenue: true, + ttl: 300, + meta: { + advertiserDomains: bid.adomain || [], + }, + }) + }) + }) + + return bids + }, + + getUserSyncs: (syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = '') => { + let syncs = []; + let { gdprApplies, consentString = '' } = gdprConsent; + + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&us_privacy=${uspConsent}&t=4` + }); + } else { + syncs.push({ + type: 'image', + url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&us_privacy=${uspConsent}&t=2` + }); + } + + return syncs + } + +}; + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidFloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0 + } +} + +registerBidder(spec); diff --git a/modules/precisoBidAdapter.md b/modules/precisoBidAdapter.md new file mode 100644 index 00000000000..b1fb0d062da --- /dev/null +++ b/modules/precisoBidAdapter.md @@ -0,0 +1,84 @@ +# Overview + +``` +Module Name: Preciso Bidder Adapter +Module Type: Bidder Adapter +Maintainer: tech@preciso.net +``` + +# Description + +Module that connects to preciso' demand sources + +# Parameters + +| Name | Scope | Description | Example | +| :------------ | :------- | :------------------------ | :------------------- | +| `region` | required (for prebid.js) | region | "prebid-eu" | +| `publisherId` | required (for prebid-server) | partner ID | "1901" | +| `traffic` | optional (for prebid.js) | Configures the mediaType that should be used. Values can be banner, native or video | "banner" | + +# Test Parameters +``` + var adUnits = [ + // Will return static native ad. Assets are stored through user UI for each placement separetly + { + code: 'placementId_0', + mediaTypes: { + native: {} + }, + bids: [ + { + bidder: 'preciso', + params: { + host: 'prebid', + publisherId: '0', + region: 'prebid-eu', + traffic: 'native' + } + } + ] + }, + // Will return static test banner + { + code: 'placementId_0', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'preciso', + params: { + host: 'prebid', + publisherId: '0', + region: 'prebid-eu', + traffic: 'banner' + } + } + ] + }, + // Will return test vast xml. All video params are stored under placement in publishers UI + { + code: 'placementId_0', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [ + { + bidder: 'preciso', + params: { + host: 'prebid', + publisherId: '0', + region: 'prebid-eu', + traffic: 'video' + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/priceFloors.js b/modules/priceFloors.js index ff4213f1330..07f8fbed45d 100644 --- a/modules/priceFloors.js +++ b/modules/priceFloors.js @@ -4,15 +4,16 @@ import { deepClone, deepSetValue, generateUUID, - getGptSlotInfoForAdUnitCode, getParameterByName, isNumber, logError, logInfo, logWarn, + mergeDeep, parseGPTSingleSizeArray, parseUrl, - pick + pick, + deepEqual } from '../src/utils.js'; import {getGlobal} from '../src/prebidGlobal.js'; import {config} from '../src/config.js'; @@ -20,11 +21,15 @@ import {ajaxBuilder} from '../src/ajax.js'; import * as events from '../src/events.js'; import CONSTANTS from '../src/constants.json'; import {getHook} from '../src/hook.js'; -import {createBid} from '../src/bidfactory.js'; import {find} from '../src/polyfill.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {bidderSettings} from '../src/bidderSettings.js'; import {auctionManager} from '../src/auctionManager.js'; +import {IMP, PBS, registerOrtbProcessor, REQUEST} from '../src/pbjsORTB.js'; +import {timedAuctionHook, timedBidResponseHook} from '../src/utils/perfMetrics.js'; +import {adjustCpm} from '../src/utils/cpm.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; +import {convertCurrency} from '../libraries/currencyUtils/currency.js'; /** * @summary This Module is intended to provide users with the ability to dynamically set and enforce price floors on a per auction basis. @@ -36,10 +41,13 @@ const MODULE_NAME = 'Price Floors'; */ const ajax = ajaxBuilder(10000); +// eslint-disable-next-line symbol-description +const SYN_FIELD = Symbol(); + /** * @summary Allowed fields for rules to have */ -export let allowedFields = ['gptSlot', 'adUnitCode', 'size', 'domain', 'mediaType']; +export let allowedFields = [SYN_FIELD, 'gptSlot', 'adUnitCode', 'size', 'domain', 'mediaType']; /** * @summary This is a flag to indicate if a AJAX call is processing for a floors request @@ -75,11 +83,15 @@ function roundUp(number, precision) { return Math.ceil((parseFloat(number) * Math.pow(10, precision)).toFixed(1)) / Math.pow(10, precision); } -let referrerHostname; -function getHostNameFromReferer(referer) { - referrerHostname = parseUrl(referer, {noDecodeWholeURL: true}).hostname; - return referrerHostname; -} +const getHostname = (() => { + let domain; + return function() { + if (domain == null) { + domain = parseUrl(getRefererInfo().topmostLocation, {noDecodeWholeURL: true}).hostname; + } + return domain; + } +})(); // First look into bidRequest! function getGptSlotFromAdUnit(transactionId, {index = auctionManager.index} = {}) { @@ -96,10 +108,11 @@ function getAdUnitCode(request, response, {index = auctionManager.index} = {}) { * @summary floor field types with their matching functions to resolve the actual matched value */ export let fieldMatchingFunctions = { + [SYN_FIELD]: () => '*', 'size': (bidRequest, bidResponse) => parseGPTSingleSizeArray(bidResponse.size) || '*', 'mediaType': (bidRequest, bidResponse) => bidResponse.mediaType || 'banner', 'gptSlot': (bidRequest, bidResponse) => getGptSlotFromAdUnit((bidRequest || bidResponse).transactionId) || getGptSlotInfoForAdUnitCode(getAdUnitCode(bidRequest, bidResponse)).gptSlot, - 'domain': (bidRequest, bidResponse) => referrerHostname || getHostNameFromReferer(getRefererInfo().referer), + 'domain': getHostname, 'adUnitCode': (bidRequest, bidResponse) => getAdUnitCode(bidRequest, bidResponse) } @@ -109,6 +122,7 @@ export let fieldMatchingFunctions = { * Returns array of Tuple [exact match, catch all] for each field in rules file */ function enumeratePossibleFieldValues(floorFields, bidObject, responseObject) { + if (!floorFields.length) return []; // generate combination of all exact matches and catch all for each field type return floorFields.reduce((accum, field) => { let exactMatch = fieldMatchingFunctions[field](bidObject, responseObject) || '*'; @@ -124,7 +138,9 @@ function enumeratePossibleFieldValues(floorFields, bidObject, responseObject) { */ export function getFirstMatchingFloor(floorData, bidObject, responseObject = {}) { let fieldValues = enumeratePossibleFieldValues(deepAccess(floorData, 'schema.fields') || [], bidObject, responseObject); - if (!fieldValues.length) return { matchingFloor: floorData.default }; + if (!fieldValues.length) { + return {matchingFloor: undefined} + } // look to see if a request for this context was made already let matchingInput = fieldValues.map(field => field[0]).join('-'); @@ -138,10 +154,15 @@ export function getFirstMatchingFloor(floorData, bidObject, responseObject = {}) let matchingData = { floorMin: floorData.floorMin || 0, - floorRuleValue: isNaN(floorData.values[matchingRule]) ? floorData.default : floorData.values[matchingRule], + floorRuleValue: floorData.values[matchingRule], matchingData: allPossibleMatches[0], // the first possible match is an "exact" so contains all data relevant for anlaytics adapters - matchingRule + matchingRule: matchingRule === floorData.meta?.defaultRule ? undefined : matchingRule }; + // use adUnit floorMin as priority! + const floorMin = deepAccess(bidObject, 'ortb2Imp.ext.prebid.floors.floorMin'); + if (typeof floorMin === 'number') { + matchingData.floorMin = floorMin; + } matchingData.matchingFloor = Math.max(matchingData.floorMin, matchingData.floorRuleValue); // save for later lookup if needed deepSetValue(floorData, `matchingInputs.${matchingInput}`, {...matchingData}); @@ -168,12 +189,8 @@ function generatePossibleEnumerations(arrayOfFields, delimiter) { /** * @summary If a the input bidder has a registered cpmadjustment it returns the input CPM after being adjusted */ -export function getBiddersCpmAdjustment(bidderName, inputCpm, bid = {}) { - const adjustmentFunction = bidderSettings.get(bidderName, 'bidCpmAdjustment'); - if (adjustmentFunction) { - return parseFloat(adjustmentFunction(inputCpm, {...bid, cpm: inputCpm})); - } - return parseFloat(inputCpm); +export function getBiddersCpmAdjustment(inputCpm, bid, bidRequest) { + return parseFloat(adjustCpm(inputCpm, {...bid, cpm: inputCpm}, bidRequest)); } /** @@ -238,8 +255,14 @@ export function getFloor(requestParams = {currency: 'USD', mediaType: '*', size: // if cpmAdjustment flag is true and we have a valid floor then run the adjustment on it if (floorData.enforcement.bidAdjustment && floorInfo.matchingFloor) { - let cpmAdjustment = getBiddersCpmAdjustment(bidRequest.bidder, floorInfo.matchingFloor); - floorInfo.matchingFloor = cpmAdjustment ? calculateAdjustedFloor(floorInfo.matchingFloor, cpmAdjustment) : floorInfo.matchingFloor; + // pub provided inverse function takes precedence, otherwise do old adjustment stuff + const inverseFunction = bidderSettings.get(bidRequest.bidder, 'inverseBidAdjustment'); + if (inverseFunction) { + floorInfo.matchingFloor = inverseFunction(floorInfo.matchingFloor, bidRequest); + } else { + let cpmAdjustment = getBiddersCpmAdjustment(floorInfo.matchingFloor, null, bidRequest); + floorInfo.matchingFloor = cpmAdjustment ? calculateAdjustedFloor(floorInfo.matchingFloor, cpmAdjustment) : floorInfo.matchingFloor; + } } if (floorInfo.matchingFloor) { @@ -285,17 +308,25 @@ function normalizeRulesForAuction(floorData, adUnitCode) { * Only called if no set config or fetch level data has returned */ export function getFloorDataFromAdUnits(adUnits) { + const schemaAu = adUnits.find(au => au.floors?.schema != null); return adUnits.reduce((accum, adUnit) => { - if (isFloorsDataValid(adUnit.floors)) { + if (adUnit.floors?.schema != null && !deepEqual(adUnit.floors.schema, schemaAu?.floors?.schema)) { + logError(`${MODULE_NAME}: adUnit '${adUnit.code}' declares a different schema from one previously declared by adUnit '${schemaAu.code}'. Floor config for '${adUnit.code}' will be ignored.`) + return accum; + } + const floors = Object.assign({}, schemaAu?.floors, {values: undefined}, adUnit.floors) + if (isFloorsDataValid(floors)) { // if values already exist we want to not overwrite them if (!accum.values) { - accum = getFloorsDataForAuction(adUnit.floors, adUnit.code); + accum = getFloorsDataForAuction(floors, adUnit.code); accum.location = 'adUnit'; } else { - let newRules = getFloorsDataForAuction(adUnit.floors, adUnit.code).values; + let newRules = getFloorsDataForAuction(floors, adUnit.code).values; // copy over the new rules into our values object Object.assign(accum.values, newRules); } + } else if (adUnit.floors != null) { + logWarn(`adUnit '${adUnit.code}' provides an invalid \`floor\` definition, it will be ignored for floor calculations`, adUnit); } return accum; }, {}); @@ -426,7 +457,26 @@ function validateRules(floorsData, numFields, delimiter) { return Object.keys(floorsData.values).length > 0; } +export function normalizeDefault(model) { + if (isNumber(model.default)) { + let defaultRule = '*'; + const numFields = (model.schema?.fields || []).length; + if (!numFields) { + deepSetValue(model, 'schema.fields', [SYN_FIELD]); + } else { + defaultRule = Array(numFields).fill('*').join(model.schema?.delimiter || '|'); + } + model.values = model.values || {}; + if (model.values[defaultRule] == null) { + model.values[defaultRule] = model.default; + model.meta = {defaultRule}; + } + } + return model; +} + function modelIsValid(model) { + model = normalizeDefault(model); // schema.fields has only allowed attributes if (!validateSchemaFields(deepAccess(model, 'schema.fields'))) { return false; @@ -493,7 +543,7 @@ export function parseFloorData(floorsData, location) { * @param {Object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. * @param {function} fn required; The next function in the chain, used by hook.js */ -export function requestBidsHook(fn, reqBidsConfigObj) { +export const requestBidsHook = timedAuctionHook('priceFloors', function requestBidsHook(fn, reqBidsConfigObj) { // preserves all module related variables for the current auction instance (used primiarily for concurrent auctions) const hookConfig = { reqBidsConfigObj, @@ -514,7 +564,7 @@ export function requestBidsHook(fn, reqBidsConfigObj) { } else { continueAuction(hookConfig); } -} +}); /** * @summary If an auction was queued to be delayed (waiting for a fetch) then this function will resume @@ -616,7 +666,7 @@ export function handleSetFloorsConfig(config) { 'bidAdjustment', bidAdjustment => bidAdjustment !== false, // defaults to true ]), 'additionalSchemaFields', additionalSchemaFields => typeof additionalSchemaFields === 'object' && Object.keys(additionalSchemaFields).length > 0 ? addFieldOverrides(additionalSchemaFields) : undefined, - 'data', data => (data && parseFloorData(data, 'setConfig')) || _floorsConfig.data // do not overwrite if passed in data not valid + 'data', data => (data && parseFloorData(data, 'setConfig')) || undefined ]); // if enabled then do some stuff @@ -685,21 +735,21 @@ function shouldFloorBid(floorData, floorInfo, bid) { * @summary The main driving force of floors. On bidResponse we hook in and intercept bidResponses. * And if the rule we find determines a bid should be floored we will do so. */ -export function addBidResponseHook(fn, adUnitCode, bid) { +export const addBidResponseHook = timedBidResponseHook('priceFloors', function addBidResponseHook(fn, adUnitCode, bid, reject) { let floorData = _floorDataForAuction[bid.auctionId]; // if no floor data then bail if (!floorData || !bid || floorData.skipped) { - return fn.call(this, adUnitCode, bid); + return fn.call(this, adUnitCode, bid, reject); } - const matchingBidRequest = auctionManager.index.getBidRequest(bid) + const matchingBidRequest = auctionManager.index.getBidRequest(bid); // get the matching rule let floorInfo = getFirstMatchingFloor(floorData.data, matchingBidRequest, {...bid, size: [bid.width, bid.height]}); if (!floorInfo.matchingFloor) { logWarn(`${MODULE_NAME}: unable to determine a matching price floor for bidResponse`, bid); - return fn.call(this, adUnitCode, bid); + return fn.call(this, adUnitCode, bid, reject); } // determine the base cpm to use based on if the currency matches the floor currency @@ -715,12 +765,12 @@ export function addBidResponseHook(fn, adUnitCode, bid) { adjustedCpm = getGlobal().convertCurrency(bid.cpm, bidResponseCurrency.toUpperCase(), floorCurrency); } catch (err) { logError(`${MODULE_NAME}: Unable do get currency conversion for bidResponse to Floor Currency. Do you have Currency module enabled? ${bid}`); - return fn.call(this, adUnitCode, bid); + return fn.call(this, adUnitCode, bid, reject); } } // ok we got the bid response cpm in our desired currency. Now we need to run the bidders CPMAdjustment function if it exists - adjustedCpm = getBiddersCpmAdjustment(bid.bidderCode, adjustedCpm, bid); + adjustedCpm = getBiddersCpmAdjustment(adjustedCpm, bid, matchingBidRequest); // add necessary data information for analytics adapters / floor providers would possibly need addFloorDataToBid(floorData, floorInfo, bid, adjustedCpm); @@ -728,25 +778,80 @@ export function addBidResponseHook(fn, adUnitCode, bid) { // now do the compare! if (shouldFloorBid(floorData, floorInfo, bid)) { // bid fails floor -> throw it out - // create basic bid no-bid with necessary data fro analytics adapters - let flooredBid = createBid(CONSTANTS.STATUS.NO_BID, bid.getIdentifiers()); - Object.assign(flooredBid, pick(bid, [ - 'floorData', - 'width', - 'height', - 'mediaType', - 'currency', - 'originalCpm', - 'originalCurrency', - 'getCpmInNewCurrency', - ])); - flooredBid.status = CONSTANTS.BID_STATUS.BID_REJECTED; - // if floor not met update bid with 0 cpm so it is not included downstream and marked as no-bid - flooredBid.cpm = 0; - logWarn(`${MODULE_NAME}: ${flooredBid.bidderCode}'s Bid Response for ${adUnitCode} was rejected due to floor not met`, bid); - return fn.call(this, adUnitCode, flooredBid); - } - return fn.call(this, adUnitCode, bid); -} + reject(CONSTANTS.REJECTION_REASON.FLOOR_NOT_MET); + logWarn(`${MODULE_NAME}: ${bid.bidderCode}'s Bid Response for ${adUnitCode} was rejected due to floor not met (adjusted cpm: ${bid?.floorData?.cpmAfterAdjustments}, floor: ${floorInfo?.matchingFloor})`, bid); + return; + } + return fn.call(this, adUnitCode, bid, reject); +}); config.getConfig('floors', config => handleSetFloorsConfig(config.floors)); + +/** + * Sets bidfloor and bidfloorcur for ORTB imp objects + */ +export function setOrtbImpBidFloor(imp, bidRequest, context) { + if (typeof bidRequest.getFloor === 'function') { + let currency, floor; + try { + ({currency, floor} = bidRequest.getFloor({ + currency: context.currency || config.getConfig('currency.adServerCurrency') || 'USD', + mediaType: context.mediaType || '*', + size: '*' + })); + } catch (e) { + logWarn('Cannot compute floor for bid', bidRequest); + return; + } + floor = parseFloat(floor); + if (currency != null && floor != null && !isNaN(floor)) { + Object.assign(imp, { + bidfloor: floor, + bidfloorcur: currency + }); + } + } +} + +export function setImpExtPrebidFloors(imp, bidRequest, context) { + // logic below relates to https://github.com/prebid/Prebid.js/issues/8749 and does the following: + // 1. check client-side floors (ref bidfloor/bidfloorcur & ortb2Imp floorMin/floorMinCur (if present)) + // 2. set pbs req wide floorMinCur to the first floor currency found when iterating over imp's + // (if currency conversion logic present, convert all imp floor values to this currency) + // 3. compare/store ref to lowest floorMin value as each imp is iterated over + // 4. set req wide floorMin and floorMinCur values for pbs after iterations are done + + if (imp.bidfloor != null) { + let {floorMinCur, floorMin} = context.reqContext.floorMin || {}; + + if (floorMinCur == null) { floorMinCur = imp.bidfloorcur } + const ortb2ImpFloorCur = imp.ext?.prebid?.floors?.floorMinCur || imp.ext?.prebid?.floorMinCur || floorMinCur; + const ortb2ImpFloorMin = imp.ext?.prebid?.floors?.floorMin || imp.ext?.prebid?.floorMin; + const convertedFloorMinValue = convertCurrency(imp.bidfloor, imp.bidfloorcur, floorMinCur); + const convertedOrtb2ImpFloorMinValue = ortb2ImpFloorMin && ortb2ImpFloorCur ? convertCurrency(ortb2ImpFloorMin, ortb2ImpFloorCur, floorMinCur) : false; + + const lowestImpFloorMin = convertedOrtb2ImpFloorMinValue && convertedOrtb2ImpFloorMinValue < convertedFloorMinValue + ? convertedOrtb2ImpFloorMinValue + : convertedFloorMinValue; + + deepSetValue(imp, 'ext.prebid.floors.floorMin', lowestImpFloorMin); + if (floorMin == null || floorMin > lowestImpFloorMin) { floorMin = lowestImpFloorMin } + context.reqContext.floorMin = {floorMin, floorMinCur}; + } +} + +/** + * PBS specific extension: set ext.prebid.floors.enabled = false if floors are processed client-side + */ +export function setOrtbExtPrebidFloors(ortbRequest, bidderRequest, context) { + if (addedFloorsHook) { + deepSetValue(ortbRequest, 'ext.prebid.floors.enabled', ortbRequest.ext?.prebid?.floors?.enabled || false); + } + if (context?.floorMin) { + mergeDeep(ortbRequest, {ext: {prebid: {floors: context.floorMin}}}) + } +} + +registerOrtbProcessor({type: IMP, name: 'bidfloor', fn: setOrtbImpBidFloor}); +registerOrtbProcessor({type: IMP, name: 'extPrebidFloors', fn: setImpExtPrebidFloors, dialects: [PBS], priority: -1}); +registerOrtbProcessor({type: REQUEST, name: 'extPrebidFloors', fn: setOrtbExtPrebidFloors, dialects: [PBS]}); diff --git a/modules/prismaBidAdapter.js b/modules/prismaBidAdapter.js new file mode 100644 index 00000000000..c13e6e1c330 --- /dev/null +++ b/modules/prismaBidAdapter.js @@ -0,0 +1,200 @@ +import {ajax} from '../src/ajax.js'; +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {getANKeywordParam} from '../libraries/appnexusUtils/anKeywords.js'; + +const BIDDER_CODE = 'prisma'; +const BIDDER_URL = 'https://prisma.nexx360.io/prebid'; +const CACHE_URL = 'https://prisma.nexx360.io/cache'; +const METRICS_TRACKER_URL = 'https://prisma.nexx360.io/track-imp'; + +const GVLID = 965; + +function getConnectionType() { + const connection = navigator.connection || navigator.webkitConnection; + if (!connection) { + return 0; + } + switch (connection.type) { + case 'ethernet': + return 1; + case 'wifi': + return 2; + case 'cellular': + switch (connection.effectiveType) { + case 'slow-2g': + case '2g': + return 4; + case '3g': + return 5; + case '4g': + return 6; + default: + return 3; + } + default: + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + aliases: ['prismadirect'], // short code + supportedMediaTypes: [BANNER, VIDEO], + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + return !!(bid.params.account && bid.params.tagId); + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function(validBidRequests, bidderRequest) { + const adUnits = []; + const test = config.getConfig('debug') ? 1 : 0; + let adunitValue = null; + let userEids = null; + Object.keys(validBidRequests).forEach(key => { + adunitValue = validBidRequests[key]; + const foo = { + account: adunitValue.params.account, + tagId: adunitValue.params.tagId, + label: adunitValue.adUnitCode, + bidId: adunitValue.bidId, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + auctionId: adunitValue.auctionId, + transactionId: adunitValue.ortb2Imp?.ext?.tid, + mediatypes: adunitValue.mediaTypes, + bidfloor: 0, + bidfloorCurrency: 'USD', + keywords: getANKeywordParam(bidderRequest.ortb2, adunitValue.params.keywords) + } + adUnits.push(foo); + if (adunitValue.userIdAsEids) userEids = adunitValue.userIdAsEids; + }); + const payload = { + adUnits, + // TODO: does the fallback make sense here? + href: encodeURIComponent(bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation) + }; + if (bidderRequest) { // modules informations (gdpr, ccpa, schain, userId) + if (bidderRequest.gdprConsent) { + payload.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + payload.gdprConsent = bidderRequest.gdprConsent.consentString; + } else { + payload.gdpr = 0; + payload.gdprConsent = ''; + } + if (bidderRequest.uspConsent) { payload.uspConsent = bidderRequest.uspConsent; } + if (bidderRequest.schain) { payload.schain = bidderRequest.schain; } + if (userEids !== null) payload.userEids = userEids; + }; + payload.connectionType = getConnectionType(); + + if (test) payload.test = 1; + const payloadString = JSON.stringify(payload); + return { + method: 'POST', + url: BIDDER_URL, + data: payloadString, + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function(serverResponse, bidRequest) { + const serverBody = serverResponse.body; + const bidResponses = []; + let bidResponse = null; + let value = null; + if (serverBody.hasOwnProperty('responses')) { + Object.keys(serverBody['responses']).forEach(key => { + value = serverBody['responses'][key]; + const url = `${CACHE_URL}?uuid=${value['uuid']}`; + bidResponse = { + requestId: value['bidId'], + cpm: value['cpm'], + currency: value['currency'], + width: value['width'], + height: value['height'], + ttl: value['ttl'], + creativeId: value['creativeId'], + netRevenue: true, + prisma: { + 'ssp': value['bidder'], + 'consent': value['consent'], + 'tagId': value['tagId'] + }, + meta: { + 'advertiserDomains': value['adomain'] || [] + } + }; + if (value.type === 'banner') bidResponse.adUrl = url; + if (value.type === 'video') { + const params = { + type: 'prebid', + mediatype: 'video', + ssp: value.bidder, + tag_id: value.tagId, + consent: value.consent, + price: value.cpm, + }; + bidResponse.cpm = value.cpm; + bidResponse.mediaType = 'video'; + bidResponse.vastUrl = url; + bidResponse.vastImpUrl = `${METRICS_TRACKER_URL}?${new URLSearchParams(params).toString()}`; + } + bidResponses.push(bidResponse); + }); + } + return bidResponses; + }, + + /** + * Register the user sync pixels which should be dropped after the auction. + * + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @param {ServerResponse[]} serverResponses List of server's responses. + * @return {UserSync[]} The user syncs which should be dropped. + */ + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + if (typeof serverResponses === 'object' && serverResponses != null && serverResponses.length > 0 && serverResponses[0].hasOwnProperty('body') && + serverResponses[0].body.hasOwnProperty('cookies') && typeof serverResponses[0].body.cookies === 'object') { + return serverResponses[0].body.cookies.slice(0, 5); + } else { + return []; + } + }, + + /** + * Register bidder specific code, which will execute if a bid from this bidder won the auction + * @param {Bid} The bid that won the auction + */ + onBidWon: function(bid) { + // fires a pixel to confirm a winning bid + const params = { type: 'prebid', mediatype: 'banner' }; + if (bid.hasOwnProperty('prisma')) { + if (bid.prisma.hasOwnProperty('ssp')) params.ssp = bid.prisma.ssp; + if (bid.prisma.hasOwnProperty('tagId')) params.tag_id = bid.prisma.tagId; + if (bid.prisma.hasOwnProperty('consent')) params.consent = bid.prisma.consent; + }; + params.price = bid.cpm; + const url = `${METRICS_TRACKER_URL}?${new URLSearchParams(params).toString()}`; + ajax(url, null, undefined, {method: 'GET', withCredentials: true}); + return true; + } + +} +registerBidder(spec); diff --git a/modules/prismaBidAdapter.md b/modules/prismaBidAdapter.md new file mode 100644 index 00000000000..a400183cec6 --- /dev/null +++ b/modules/prismaBidAdapter.md @@ -0,0 +1,59 @@ +# Overview + +``` +Module Name: Prisma Bid Adapter +Module Type: Bidder Adapter +Maintainer: gabriel@nexx360.io +``` + +# Description + +Connects to Prisma network for bids. + +To use us as a bidder you must have an account and an active "tagId" on our platform. + +# Test Parameters + +## Web + +### Display +``` +var adUnits = [ + // Banner adUnit + { + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [[300, 250], [300,600]] + } + }, + bids: [{ + bidder: 'prisma', + params: { + account: '1067', + tagId: 'luvxjvgn' + } + }] + }, +]; +``` + +### Video Instream +``` + var videoAdUnit = { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bids: [{ + bidder: 'prisma', + params: { + account: '1067', + tagId: 'luvxjvgn' + } + }] + }; +``` diff --git a/modules/proxistoreBidAdapter.js b/modules/proxistoreBidAdapter.js index 42a98bcdb09..f3fb662ba06 100644 --- a/modules/proxistoreBidAdapter.js +++ b/modules/proxistoreBidAdapter.js @@ -3,9 +3,9 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'proxistore'; const PROXISTORE_VENDOR_ID = 418; -const COOKIE_BASE_URL = 'https://abs.proxistore.com/v3/rtb/prebid/multi'; +const COOKIE_BASE_URL = 'https://api.proxistore.com/v3/rtb/prebid/multi'; const COOKIE_LESS_URL = - 'https://abs.cookieless-proxistore.com/v3/rtb/prebid/multi'; + 'https://api.cookieless-proxistore.com/v3/rtb/prebid/multi'; function _createServerRequest(bidRequests, bidderRequest) { var sizeIds = []; @@ -24,8 +24,9 @@ function _createServerRequest(bidRequests, bidderRequest) { sizeIds.push(sizeId); }); var payload = { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidRequests[0].auctionId, - transactionId: bidRequests[0].auctionId, + transactionId: bidRequests[0].ortb2Imp?.ext?.tid, bids: sizeIds, website: bidRequests[0].params.website, language: bidRequests[0].params.language, @@ -54,10 +55,8 @@ function _createServerRequest(bidRequests, bidderRequest) { if (gdprConsent.vendorData) { var vendorData = gdprConsent.vendorData; - var apiVersion = gdprConsent.apiVersion; if ( - apiVersion === 2 && vendorData.vendor && vendorData.vendor.consents && typeof vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)] !== @@ -65,14 +64,6 @@ function _createServerRequest(bidRequests, bidderRequest) { ) { payload.gdpr.consentGiven = !!vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)]; - } else if ( - apiVersion === 1 && - vendorData.vendorConsents && - typeof vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== - 'undefined' - ) { - payload.gdpr.consentGiven = - !!vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)]; } } } @@ -98,23 +89,20 @@ function _createServerRequest(bidRequests, bidderRequest) { } function _assignSegments(bid) { - if ( - bid.ortb2 && - bid.ortb2.user && - bid.ortb2.user.ext && - bid.ortb2.user.ext.data - ) { - return ( - bid.ortb2.user.ext.data || { - segments: [], - contextual_categories: {}, - } - ); + var segs = (bid.ortb2 && bid.ortb2.user && bid.ortb2.user.ext && bid.ortb2.user.ext.data && bid.ortb2.user.ext.data.sd_rtd && bid.ortb2.user.ext.data.sd_rtd.segments ? bid.ortb2.user.ext.data.sd_rtd.segments : []); + var cats = {}; + if (bid.ortb2 && bid.ortb2.site && bid.ortb2.site.ext && bid.ortb2.site.ext.data && bid.ortb2.site.ext.data.sd_rtd) { + if (bid.ortb2.site.ext.data.sd_rtd.categories) { + segs = segs.concat(bid.ortb2.site.ext.data.sd_rtd.categories); + } + if (bid.ortb2.site.ext.data.sd_rtd.categories_score) { + cats = bid.ortb2.site.ext.data.sd_rtd.categories_score; + } } return { - segments: [], - contextual_categories: {}, + segments: segs, + contextual_categories: cats }; } diff --git a/modules/pubCircleBidAdapter.js b/modules/pubCircleBidAdapter.js new file mode 100644 index 00000000000..54224fd0403 --- /dev/null +++ b/modules/pubCircleBidAdapter.js @@ -0,0 +1,231 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'pubcircle'; +const AD_URL = 'https://ml.pubcircle.ai/pbjs'; +const SYNC_URL = 'https://cs.pubcircle.ai'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + placement.placementId = placementId; + placement.type = 'publisher'; + + if (bid.userId) { + getUserId(placement.eids, bid.userId.uid2 && bid.userId.uid2.id, 'uidapi.com'); + getUserId(placement.eids, bid.userId.lotamePanoramaId, 'lotame.com'); + getUserId(placement.eids, bid.userId.idx, 'idx.lat'); + getUserId(placement.eids, bid.userId.idl_env, 'liveramp.com'); + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +function getUserId(eids, id, source, uidExt) { + if (id) { + var uid = { id }; + if (uidExt) { + uid.ext = uidExt; + } + eids.push({ + source, + uids: [ uid ] + }); + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && params.placementId); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + }, + + onBidViewable: function (bid) { + // to do : we need to implement js tag to fire pixel with viewability counter + } +}; + +registerBidder(spec); diff --git a/modules/pubCircleBidAdapter.md b/modules/pubCircleBidAdapter.md new file mode 100644 index 00000000000..4fc114bf20c --- /dev/null +++ b/modules/pubCircleBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: PubCirlce Bidder Adapter +Module Type: PubCirlce Bidder Adapter +Maintainer: system@smartyads.com +``` + +# Description + +Connects to PubCirlce exchange for bids. +PubCirlce bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'addunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'pubcircle', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'pubcircle', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'pubcircle', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/pubCommonId.js b/modules/pubCommonId.js deleted file mode 100644 index faca59cce1c..00000000000 --- a/modules/pubCommonId.js +++ /dev/null @@ -1,297 +0,0 @@ -/** - * This modules adds Publisher Common ID support to prebid.js. It's a simple numeric id - * stored in the page's domain. When the module is included, an id is generated if needed, - * persisted as a cookie, and automatically appended to all the bidRequest as bid.crumbs.pubcid. - */ -import { logMessage, parseUrl, buildUrl, triggerPixel, generateUUID, isArray } from '../src/utils.js'; -import { config } from '../src/config.js'; -import * as events from '../src/events.js'; -import CONSTANTS from '../src/constants.json'; -import { getStorageManager } from '../src/storageManager.js'; - -const storage = getStorageManager(); - -const ID_NAME = '_pubcid'; -const OPTOUT_NAME = '_pubcid_optout'; -const DEFAULT_EXPIRES = 525600; // 1-year worth of minutes -const PUB_COMMON = 'PublisherCommonId'; -const EXP_SUFFIX = '_exp'; -const COOKIE = 'cookie'; -const LOCAL_STORAGE = 'html5'; - -let pubcidConfig = { - enabled: true, - interval: DEFAULT_EXPIRES, - typeEnabled: LOCAL_STORAGE, - create: true, - extend: true, - pixelUrl: '' -}; - -/** - * Set an item in the storage with expiry time. - * @param {string} key Key of the item to be stored - * @param {string} val Value of the item to be stored - * @param {number} expires Expiry time in minutes - */ - -export function setStorageItem(key, val, expires) { - try { - if (expires !== undefined && expires != null) { - const expStr = (new Date(Date.now() + (expires * 60 * 1000))).toUTCString(); - storage.setDataInLocalStorage(key + EXP_SUFFIX, expStr); - } - - storage.setDataInLocalStorage(key, val); - } catch (e) { - logMessage(e); - } -} - -/** - * Retrieve an item from storage if it exists and hasn't expired. - * @param {string} key Key of the item. - * @returns {string|null} Value of the item. - */ -export function getStorageItem(key) { - let val = null; - - try { - const expVal = storage.getDataFromLocalStorage(key + EXP_SUFFIX); - - if (!expVal) { - // If there is no expiry time, then just return the item - val = storage.getDataFromLocalStorage(key); - } else { - // Only return the item if it hasn't expired yet. - // Otherwise delete the item. - const expDate = new Date(expVal); - const isValid = (expDate.getTime() - Date.now()) > 0; - if (isValid) { - val = storage.getDataFromLocalStorage(key); - } else { - removeStorageItem(key); - } - } - } catch (e) { - logMessage(e); - } - - return val; -} - -/** - * Remove an item from storage - * @param {string} key Key of the item to be removed - */ -export function removeStorageItem(key) { - try { - storage.removeDataFromLocalStorage(key + EXP_SUFFIX); - storage.removeDataFromLocalStorage(key); - } catch (e) { - logMessage(e); - } -} - -/** - * Read a value either from cookie or local storage - * @param {string} name Name of the item - * @param {string} type storage type override - * @returns {string|null} a string if item exists - */ -function readValue(name, type) { - let value; - if (!type) { type = pubcidConfig.typeEnabled; } - if (type === COOKIE) { - value = storage.getCookie(name); - } else if (type === LOCAL_STORAGE) { - value = getStorageItem(name); - } - - if (value === 'undefined' || value === 'null') { return null; } - - return value; -} - -/** - * Write a value to either cookies or local storage - * @param {string} name Name of the item - * @param {string} value Value to be stored - * @param {number} expInterval Expiry time in minutes - */ -function writeValue(name, value, expInterval) { - if (name && value) { - if (pubcidConfig.typeEnabled === COOKIE) { - setCookie(name, value, expInterval, 'Lax'); - } else if (pubcidConfig.typeEnabled === LOCAL_STORAGE) { - setStorageItem(name, value, expInterval); - } - } -} - -/** - * Add a callback at end of auction to fetch a pixel - * @param {string} pixelUrl Pixel URL - * @param {string} id pubcid - * @returns {boolean} True if callback is queued - */ -function queuePixelCallback(pixelUrl, id) { - if (!pixelUrl) { return false; } - - id = id || ''; - - // Use pubcid as a cache buster - const urlInfo = parseUrl(pixelUrl); - urlInfo.search.id = encodeURIComponent('pubcid:' + id); - const targetUrl = buildUrl(urlInfo); - - events.on(CONSTANTS.EVENTS.AUCTION_END, function auctionEndHandler() { - events.off(CONSTANTS.EVENTS.AUCTION_END, auctionEndHandler); - triggerPixel(targetUrl); - }); - - return true; -} - -export function isPubcidEnabled() { return pubcidConfig.enabled; } -export function getExpInterval() { return pubcidConfig.interval; } -export function getPubcidConfig() { return pubcidConfig; } - -/** - * Decorate ad units with pubcid. This hook function is called before the - * real pbjs.requestBids is invoked, and can modify its parameter. The cookie is - * not updated until this function is called. - * @param {Object} config This is the same parameter as pbjs.requestBids, and config.adUnits will be updated. - * @param {function} next The next function in the chain - */ - -export function requestBidHook(next, config) { - let adUnits = config.adUnits || $$PREBID_GLOBAL$$.adUnits; - let pubcid = null; - - // Pass control to the next function if not enabled - if (!pubcidConfig.enabled || !pubcidConfig.typeEnabled) { - return next.call(this, config); - } - - if (typeof window[PUB_COMMON] === 'object') { - // If the page includes its own pubcid object, then use that instead. - pubcid = window[PUB_COMMON].getId(); - logMessage(PUB_COMMON + ': pubcid = ' + pubcid); - } else { - // Otherwise get the existing cookie - pubcid = readValue(ID_NAME); - - if (!pubcid) { - if (pubcidConfig.create) { - // Special handling for local storage to retain previously stored id in cookies - if (pubcidConfig.typeEnabled === LOCAL_STORAGE) { - pubcid = readValue(ID_NAME, COOKIE); - } - // Generate a new id - if (!pubcid) { - pubcid = generateUUID(); - } - // Update the cookie/storage with the latest expiration date - writeValue(ID_NAME, pubcid, pubcidConfig.interval); - // Only return pubcid if it is saved successfully - pubcid = readValue(ID_NAME); - } - queuePixelCallback(pubcidConfig.pixelUrl, pubcid); - } else if (pubcidConfig.extend) { - // Update the cookie/storage with the latest expiration date - if (!queuePixelCallback(pubcidConfig.pixelUrl, pubcid)) { - writeValue(ID_NAME, pubcid, pubcidConfig.interval); - } - } - - logMessage('pbjs: pubcid = ' + pubcid); - } - - // Append pubcid to each bid object, which will be incorporated - // into bid requests later. - if (adUnits && pubcid) { - adUnits.forEach((unit) => { - if (unit.bids && isArray(unit.bids)) { - unit.bids.forEach((bid) => { - Object.assign(bid, {crumbs: {pubcid}}); - }); - } - }); - } - - return next.call(this, config); -} - -// Helper to set a cookie -export function setCookie(name, value, expires, sameSite) { - let expTime = new Date(); - expTime.setTime(expTime.getTime() + expires * 1000 * 60); - storage.setCookie(name, value, expTime.toGMTString(), sameSite); -} - -// Helper to read a cookie -export function getCookie(name) { - return storage.getCookie(name); -} - -/** - * Configuration function - * @param {boolean} enable Enable or disable pubcid. By default the module is enabled. - * @param {number} expInterval Expiration interval of the cookie in minutes. - * @param {string} type Type of storage to use - * @param {boolean} create Create the id if missing. Default is true. - * @param {boolean} extend Extend the stored value when id is retrieved. Default is true. - * @param {string} pixelUrl A pixel URL back to the publisher's own domain that may modify cookie attributes. - */ - -export function setConfig({ enable, expInterval, type = 'html5,cookie', create, extend, pixelUrl } = {}) { - if (enable !== undefined) { pubcidConfig.enabled = enable; } - - if (expInterval !== undefined) { pubcidConfig.interval = parseInt(expInterval, 10); } - - if (isNaN(pubcidConfig.interval)) { - pubcidConfig.interval = DEFAULT_EXPIRES; - } - - if (create !== undefined) { pubcidConfig.create = create; } - if (extend !== undefined) { pubcidConfig.extend = extend; } - if (pixelUrl !== undefined) { pubcidConfig.pixelUrl = pixelUrl; } - - // Default is to use local storage. Fall back to - // cookie only if local storage is not supported. - - pubcidConfig.typeEnabled = null; - - const typeArray = type.split(','); - for (let i = 0; i < typeArray.length; ++i) { - const name = typeArray[i].trim(); - if (name === COOKIE) { - if (storage.cookiesAreEnabled()) { - pubcidConfig.typeEnabled = COOKIE; - break; - } - } else if (name === LOCAL_STORAGE) { - if (storage.hasLocalStorage()) { - pubcidConfig.typeEnabled = LOCAL_STORAGE; - break; - } - } - } -} - -/** - * Initialize module by 1) subscribe to configuration changes and 2) register hook - */ -export function initPubcid() { - config.getConfig('pubcid', config => setConfig(config.pubcid)); - - const optout = (storage.cookiesAreEnabled() && readValue(OPTOUT_NAME, COOKIE)) || - (storage.hasLocalStorage() && readValue(OPTOUT_NAME, LOCAL_STORAGE)); - - if (!optout) { - $$PREBID_GLOBAL$$.requestBids.before(requestBidHook); - } -} - -initPubcid(); diff --git a/modules/pubCommonId.md b/modules/pubCommonId.md deleted file mode 100644 index 79531bfe87c..00000000000 --- a/modules/pubCommonId.md +++ /dev/null @@ -1,37 +0,0 @@ -## Publisher Common ID Example Configuration - -When the module is included, it's automatically enabled and saves an id to both cookie and local storage with an expiration time of 1 year. - -Example of disabling publisher common id. - -``` -pbjs.setConfig( - pubcid: { - enable: false - } -); -``` - -Example of setting expiration interval to 30 days. The interval is expressed in minutes. - -``` -pbjs.setConfig( - pubcid: { - expInterval: 43200 - } -); -``` - -Example of using local storage only and setting expiration interval to 30 days. - -``` -pbjs.setConfig( - pubcid: { - expInterval: 43200, - type: 'html5' - } -); -``` - - - diff --git a/modules/pubProvidedIdSystem.js b/modules/pubProvidedIdSystem.js index 669d223c57f..baffd997443 100644 --- a/modules/pubProvidedIdSystem.js +++ b/modules/pubProvidedIdSystem.js @@ -7,6 +7,7 @@ import {submodule} from '../src/hook.js'; import { logInfo, isArray } from '../src/utils.js'; +import {VENDORLESS_GVLID} from '../src/consentHandler.js'; const MODULE_NAME = 'pubProvidedId'; @@ -18,6 +19,7 @@ export const pubProvidedIdSubmodule = { * @type {string} */ name: MODULE_NAME, + gvlid: VENDORLESS_GVLID, /** * decode the stored id value for passing to bid request diff --git a/modules/pubgeniusBidAdapter.js b/modules/pubgeniusBidAdapter.js index 28c4fdefd42..d92a9352cee 100644 --- a/modules/pubgeniusBidAdapter.js +++ b/modules/pubgeniusBidAdapter.js @@ -1,7 +1,7 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { ajax } from '../src/ajax.js'; -import { config } from '../src/config.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {ajax} from '../src/ajax.js'; +import {config} from '../src/config.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; import { deepAccess, deepSetValue, @@ -41,7 +41,7 @@ export const spec = { buildRequests: function (bidRequests, bidderRequest) { const data = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: bidRequests.map(buildImp), tmax: bidderRequest.timeout, ext: { @@ -228,20 +228,15 @@ function buildSite(bidderRequest) { let site = null; const { refererInfo } = bidderRequest; - const pageUrl = config.getConfig('pageUrl') || refererInfo.canonicalUrl || refererInfo.referer; + const pageUrl = refererInfo.page; if (pageUrl) { site = site || {}; site.page = pageUrl; } - if (refererInfo.reachedTop) { - try { - const pageRef = window.top.document.referrer; - if (pageRef) { - site = site || {}; - site.ref = pageRef; - } - } catch (e) {} + if (refererInfo.ref) { + site = site || {}; + site.ref = refererInfo.ref; } return site; diff --git a/modules/publinkIdSystem.js b/modules/publinkIdSystem.js index 9d5645a38cb..5b20dbb620a 100644 --- a/modules/publinkIdSystem.js +++ b/modules/publinkIdSystem.js @@ -10,13 +10,14 @@ import {getStorageManager} from '../src/storageManager.js'; import {ajax} from '../src/ajax.js'; import { parseUrl, buildUrl, logError } from '../src/utils.js'; import {uspDataHandler} from '../src/adapterManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const MODULE_NAME = 'publinkId'; const GVLID = 24; const PUBLINK_COOKIE = '_publink'; const PUBLINK_S2S_COOKIE = '_publink_srv'; -export const storage = getStorageManager({gvlid: GVLID}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); function isHex(s) { return /^[A-F0-9]+$/i.test(s); @@ -139,6 +140,12 @@ export const publinkIdSubmodule = { if (!storedId) { return {callback: makeCallback(config, consentData)}; } - } + }, + eids: { + 'publinkId': { + source: 'epsilon.com', + atype: 3 + }, + }, }; submodule('userId', publinkIdSubmodule); diff --git a/modules/pubmaticAnalyticsAdapter.js b/modules/pubmaticAnalyticsAdapter.js index f69fb20e5d5..0651b373f12 100755 --- a/modules/pubmaticAnalyticsAdapter.js +++ b/modules/pubmaticAnalyticsAdapter.js @@ -1,10 +1,11 @@ -import { _each, pick, logWarn, isStr, isArray, logError } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import {_each, isArray, isStr, logError, logWarn, pick} from '../src/utils.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import { ajax } from '../src/ajax.js'; -import { config } from '../src/config.js'; -import { getGlobal } from '../src/prebidGlobal.js'; +import {ajax} from '../src/ajax.js'; +import {config} from '../src/config.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; /// /////////// CONSTANTS ////////////// const ADAPTER_CODE = 'pubmatic'; @@ -22,6 +23,7 @@ const ERROR = 'error'; const REQUEST_ERROR = 'request-error'; const TIMEOUT_ERROR = 'timeout-error'; const EMPTY_STRING = ''; +const OPEN_AUCTION_DEAL_ID = '-1'; const MEDIA_TYPE_BANNER = 'banner'; const CURRENCY_USD = 'USD'; const BID_PRECISION = 2; @@ -30,6 +32,11 @@ const DEFAULT_PUBLISHER_ID = 0; const DEFAULT_PROFILE_ID = 0; const DEFAULT_PROFILE_VERSION_ID = 0; const enc = window.encodeURIComponent; +const MEDIATYPE = { + BANNER: 0, + VIDEO: 1, + NATIVE: 2 +} /// /////////// VARIABLES ////////////// let publisherId = DEFAULT_PUBLISHER_ID; // int: mandatory @@ -83,14 +90,17 @@ function setMediaTypes(types, bid) { function copyRequiredBidDetails(bid) { return pick(bid, [ 'bidder', + 'bidderCode', + 'adapterCode', 'bidId', 'status', () => NO_BID, // default a bid to NO_BID until response is recieved or bid is timed out 'finalSource as source', 'params', + 'floorData', 'adUnit', () => pick(bid, [ 'adUnitCode', 'transactionId', - 'sizes as dimensions', sizes => sizes.map(sizeToDimensions), + 'sizes as dimensions', sizes => sizes && sizes.map(sizeToDimensions), 'mediaTypes', (types) => setMediaTypes(types, bid) ]) ]); @@ -102,10 +112,6 @@ function setBidStatus(bid, args) { bid.status = SUCCESS; delete bid.error; // it's possible for this to be set by a previous timeout break; - case CONSTANTS.STATUS.NO_BID: - bid.status = NO_BID; - delete bid.error; - break; default: bid.status = ERROR; bid.error = { @@ -151,6 +157,7 @@ function parseBidResponse(bid) { 'bidId', 'mediaType', 'params', + 'floorData', 'mi', 'regexPattern', () => bid.regexPattern || undefined, 'partnerImpId', // partner impression ID @@ -185,11 +192,11 @@ function getDevicePlatform() { } function getValueForKgpv(bid, adUnitId) { - if (bid.params.regexPattern) { + if (bid.params && bid.params.regexPattern) { return bid.params.regexPattern; } else if (bid.bidResponse && bid.bidResponse.regexPattern) { return bid.bidResponse.regexPattern; - } else if (bid.params.kgpv) { + } else if (bid.params && bid.params.kgpv) { return bid.params.kgpv; } else { return adUnitId; @@ -215,44 +222,126 @@ function getAdDomain(bidResponse) { } } +function isObject(object) { + return typeof object === 'object' && object !== null; +}; + +function isEmptyObject(object) { + return isObject(object) && Object.keys(object).length === 0; +}; + +/** + * Prepare meta object to pass in logger call + * @param {*} meta + */ +export function getMetadata(meta) { + if (!meta || isEmptyObject(meta)) return; + const metaObj = {}; + if (meta.networkId) metaObj.nwid = meta.networkId; + if (meta.advertiserId) metaObj.adid = meta.advertiserId; + if (meta.networkName) metaObj.nwnm = meta.networkName; + if (meta.primaryCatId) metaObj.pcid = meta.primaryCatId; + if (meta.advertiserName) metaObj.adnm = meta.advertiserName; + if (meta.agencyId) metaObj.agid = meta.agencyId; + if (meta.agencyName) metaObj.agnm = meta.agencyName; + if (meta.brandId) metaObj.brid = meta.brandId; + if (meta.brandName) metaObj.brnm = meta.brandName; + if (meta.dchain) metaObj.dc = meta.dchain; + if (meta.demandSource) metaObj.ds = meta.demandSource; + if (meta.secondaryCatIds) metaObj.scids = meta.secondaryCatIds; + + if (isEmptyObject(metaObj)) return; + return metaObj; +} + +function isS2SBidder(bidder) { + return (s2sBidders.indexOf(bidder) > -1) ? 1 : 0 +} + function gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestBid) { highestBid = (highestBid && highestBid.length > 0) ? highestBid[0] : null; return Object.keys(adUnit.bids).reduce(function(partnerBids, bidId) { - let bid = adUnit.bids[bidId]; - partnerBids.push({ - 'pn': getAdapterNameForAlias(bid.bidder), - 'bc': bid.bidder, - 'bidid': bid.bidId, - 'db': bid.bidResponse ? 0 : 1, - 'kgpv': getValueForKgpv(bid, adUnitId), - 'kgpsv': bid.params.kgpv ? bid.params.kgpv : adUnitId, - 'psz': bid.bidResponse ? (bid.bidResponse.dimensions.width + 'x' + bid.bidResponse.dimensions.height) : '0x0', - 'eg': bid.bidResponse ? bid.bidResponse.bidGrossCpmUSD : 0, - 'en': bid.bidResponse ? bid.bidResponse.bidPriceUSD : 0, - 'di': bid.bidResponse ? (bid.bidResponse.dealId || EMPTY_STRING) : EMPTY_STRING, - 'dc': bid.bidResponse ? (bid.bidResponse.dealChannel || EMPTY_STRING) : EMPTY_STRING, - 'l1': bid.bidResponse ? bid.clientLatencyTimeMs : 0, - 'l2': 0, - 'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined, - 'ss': (s2sBidders.indexOf(bid.bidder) > -1) ? 1 : 0, - 't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0, - 'wb': (highestBid && highestBid.requestId === bid.bidId ? 1 : 0), - 'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined, - 'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined, - 'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0, - 'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD, - 'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING + adUnit.bids[bidId].forEach(function(bid) { + partnerBids.push({ + 'pn': getAdapterNameForAlias(bid.adapterCode || bid.bidder), + 'bc': bid.bidderCode || bid.bidder, + 'bidid': bid.bidId || bidId, + 'db': bid.bidResponse ? 0 : 1, + 'kgpv': getValueForKgpv(bid, adUnitId), + 'kgpsv': bid.params && bid.params.kgpv ? bid.params.kgpv : adUnitId, + 'psz': bid.bidResponse ? (bid.bidResponse.dimensions.width + 'x' + bid.bidResponse.dimensions.height) : '0x0', + 'eg': bid.bidResponse ? bid.bidResponse.bidGrossCpmUSD : 0, + 'en': bid.bidResponse ? bid.bidResponse.bidPriceUSD : 0, + 'di': bid.bidResponse ? (bid.bidResponse.dealId || OPEN_AUCTION_DEAL_ID) : OPEN_AUCTION_DEAL_ID, + 'dc': bid.bidResponse ? (bid.bidResponse.dealChannel || EMPTY_STRING) : EMPTY_STRING, + 'l1': bid.bidResponse ? bid.partnerTimeToRespond : 0, + 'ol1': bid.bidResponse ? bid.clientLatencyTimeMs : 0, + 'l2': 0, + 'adv': bid.bidResponse ? getAdDomain(bid.bidResponse) || undefined : undefined, + 'ss': isS2SBidder(bid.bidder), + 't': (bid.status == ERROR && bid.error.code == TIMEOUT_ERROR) ? 1 : 0, + 'wb': (highestBid && highestBid.adId === bid.adId ? 1 : 0), + 'mi': bid.bidResponse ? (bid.bidResponse.mi || undefined) : undefined, + 'af': bid.bidResponse ? (bid.bidResponse.mediaType || undefined) : undefined, + 'ocpm': bid.bidResponse ? (bid.bidResponse.originalCpm || 0) : 0, + 'ocry': bid.bidResponse ? (bid.bidResponse.originalCurrency || CURRENCY_USD) : CURRENCY_USD, + 'piid': bid.bidResponse ? (bid.bidResponse.partnerImpId || EMPTY_STRING) : EMPTY_STRING, + 'frv': (bid.bidResponse ? (bid.bidResponse.floorData ? bid.bidResponse.floorData.floorRuleValue : undefined) : undefined), + 'md': bid.bidResponse ? getMetadata(bid.bidResponse.meta) : undefined + }); }); return partnerBids; }, []) } +function getSizesForAdUnit(adUnit) { + var bid = Object.values(adUnit.bids).filter((bid) => !!bid.bidResponse && bid.bidResponse.mediaType === 'native')[0]; + if (!!bid || (bid === undefined && adUnit.dimensions.length === 0)) { + return ['1x1']; + } else { + return adUnit.dimensions.map(function (e) { + return e[0] + 'x' + e[1]; + }) + } +} + +function getAdUnitAdFormats(adUnit) { + var af = adUnit ? Object.keys(adUnit.mediaTypes || {}).map(format => MEDIATYPE[format.toUpperCase()]) : []; + return af; +} + +function getAdUnit(adUnits, adUnitId) { + return adUnits.filter(adUnit => (adUnit.divID && adUnit.divID == adUnitId) || (adUnit.code == adUnitId))[0]; +} + +function getTgId() { + var testGroupId = parseInt(config.getConfig('testGroupId') || 0); + if (testGroupId <= 15 && testGroupId >= 0) { + return testGroupId; + } + return 0; +} + +function getFloorFetchStatus(floorData) { + if (!floorData?.floorRequestData) { + return false; + } + const { location, fetchStatus } = floorData?.floorRequestData; + const isDataValid = location !== CONSTANTS.FLOOR_VALUES.NO_DATA; + const isFetchSuccessful = location === CONSTANTS.FLOOR_VALUES.FETCH && fetchStatus === CONSTANTS.FLOOR_VALUES.SUCCESS; + const isAdUnitOrSetConfig = location === CONSTANTS.FLOOR_VALUES.AD_UNIT || location === CONSTANTS.FLOOR_VALUES.SET_CONFIG; + return isDataValid && (isAdUnitOrSetConfig || isFetchSuccessful); +} + function executeBidsLoggerCall(e, highestCpmBids) { let auctionId = e.auctionId; let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || ''; let auctionCache = cache.auctions[auctionId]; + let floorData = auctionCache.floorData; let outputObj = { s: [] }; let pixelURL = END_POINT_BID_LOGGER; + // will return true if floor data is present. + let fetchStatus = getFloorFetchStatus(auctionCache.floorData); if (!auctionCache) { return; @@ -272,20 +361,24 @@ function executeBidsLoggerCall(e, highestCpmBids) { outputObj['pid'] = '' + profileId; outputObj['pdvid'] = '' + profileVersionId; outputObj['dvc'] = {'plt': getDevicePlatform()}; - outputObj['tgid'] = (function() { - var testGroupId = parseInt(config.getConfig('testGroupId') || 0); - if (testGroupId <= 15 && testGroupId >= 0) { - return testGroupId; - } - return 0; - })(); + outputObj['tgid'] = getTgId(); + + if (floorData && fetchStatus) { + outputObj['fmv'] = floorData.floorRequestData ? floorData.floorRequestData.modelVersion || undefined : undefined; + outputObj['ft'] = floorData.floorResponseData ? (floorData.floorResponseData.enforcements.enforceJS == false ? 0 : 1) : undefined; + } outputObj.s = Object.keys(auctionCache.adUnitCodes).reduce(function(slotsArray, adUnitId) { let adUnit = auctionCache.adUnitCodes[adUnitId]; + let origAdUnit = getAdUnit(auctionCache.origAdUnits, adUnitId) || {}; + // getGptSlotInfoForAdUnitCode returns gptslot corresponding to adunit provided as input. let slotObject = { 'sn': adUnitId, - 'sz': adUnit.dimensions.map(e => e[0] + 'x' + e[1]), - 'ps': gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestCpmBids.filter(bid => bid.adUnitCode === adUnitId)) + 'au': origAdUnit.adUnitId || getGptSlotInfoForAdUnitCode(adUnitId)?.gptSlot || adUnitId, + 'mt': getAdUnitAdFormats(origAdUnit), + 'sz': getSizesForAdUnit(adUnit, adUnitId), + 'ps': gatherPartnerBidsForAdUnitForLogger(adUnit, adUnitId, highestCpmBids.filter(bid => bid.adUnitCode === adUnitId)), + 'fskp': (floorData && fetchStatus) ? (floorData.floorRequestData ? (floorData.floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined, }; slotsArray.push(slotObject); return slotsArray; @@ -307,8 +400,21 @@ function executeBidsLoggerCall(e, highestCpmBids) { function executeBidWonLoggerCall(auctionId, adUnitId) { const winningBidId = cache.auctions[auctionId].adUnitCodes[adUnitId].bidWon; - const winningBid = cache.auctions[auctionId].adUnitCodes[adUnitId].bids[winningBidId]; - const adapterName = getAdapterNameForAlias(winningBid.bidder); + const winningBids = cache.auctions[auctionId].adUnitCodes[adUnitId].bids[winningBidId]; + let winningBid = winningBids[0]; + + if (winningBids.length > 1) { + winningBid = winningBids.filter(bid => bid.adId === cache.auctions[auctionId].adUnitCodes[adUnitId].bidWonAdId)[0]; + } + + const adapterName = getAdapterNameForAlias(winningBid.adapterCode || winningBid.bidder); + let origAdUnit = getAdUnit(cache.auctions[auctionId].origAdUnits, adUnitId) || {}; + let auctionCache = cache.auctions[auctionId]; + let floorData = auctionCache.floorData; + let referrer = config.getConfig('pageUrl') || cache.auctions[auctionId].referer || ''; + let adv = winningBid.bidResponse ? getAdDomain(winningBid.bidResponse) || undefined : undefined; + let fskp = floorData ? (floorData.floorRequestData ? (floorData.floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined; + let pixelURL = END_POINT_WIN_BID_LOGGER; pixelURL += 'pubid=' + publisherId; pixelURL += '&purl=' + enc(config.getConfig('pageUrl') || cache.auctions[auctionId].referer || ''); @@ -318,12 +424,25 @@ function executeBidWonLoggerCall(auctionId, adUnitId) { pixelURL += '&pid=' + enc(profileId); pixelURL += '&pdvid=' + enc(profileVersionId); pixelURL += '&slot=' + enc(adUnitId); + pixelURL += '&au=' + enc(origAdUnit.adUnitId || adUnitId); pixelURL += '&pn=' + enc(adapterName); - pixelURL += '&bc=' + enc(winningBid.bidder); + pixelURL += '&bc=' + enc(winningBid.bidderCode || winningBid.bidder); pixelURL += '&en=' + enc(winningBid.bidResponse.bidPriceUSD); pixelURL += '&eg=' + enc(winningBid.bidResponse.bidGrossCpmUSD); pixelURL += '&kgpv=' + enc(getValueForKgpv(winningBid, adUnitId)); pixelURL += '&piid=' + enc(winningBid.bidResponse.partnerImpId || EMPTY_STRING); + pixelURL += '&di=' + enc(winningBid?.bidResponse?.dealId || OPEN_AUCTION_DEAL_ID); + + pixelURL += '&plt=' + enc(getDevicePlatform()); + pixelURL += '&psz=' + enc((winningBid?.bidResponse?.dimensions?.width || '0') + 'x' + + (winningBid?.bidResponse?.dimensions?.height || '0')); + pixelURL += '&tgid=' + enc(getTgId()); + adv && (pixelURL += '&adv=' + enc(adv)); + pixelURL += '&orig=' + enc(getDomainFromUrl(referrer)); + pixelURL += '&ss=' + enc(isS2SBidder(winningBid.bidder)); + (fskp != undefined) && (pixelURL += '&fskp=' + enc(fskp)); + pixelURL += '&af=' + enc(winningBid.bidResponse ? (winningBid.bidResponse.mediaType || undefined) : undefined); + ajax( pixelURL, null, @@ -349,7 +468,9 @@ function auctionInitHandler(args) { 'bidderDonePendingCount', () => args.bidderRequests.length, ]); cacheEntry.adUnitCodes = {}; - cacheEntry.referer = args.bidderRequests[0].refererInfo.referer; + cacheEntry.floorData = {}; + cacheEntry.origAdUnits = args.adUnits; + cacheEntry.referer = args.bidderRequests[0].refererInfo.topmostLocation; cache.auctions[args.auctionId] = cacheEntry; } @@ -362,22 +483,50 @@ function bidRequestedHandler(args) { dimensions: bid.sizes }; } - cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = copyRequiredBidDetails(bid); + cache.auctions[args.auctionId].adUnitCodes[bid.adUnitCode].bids[bid.bidId] = [copyRequiredBidDetails(bid)]; + if (bid.floorData) { + cache.auctions[args.auctionId].floorData['floorRequestData'] = bid.floorData; + } }) } function bidResponseHandler(args) { - let bid = cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId]; + let bid = cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId][0]; if (!bid) { logError(LOG_PRE_FIX + 'Could not find associated bid request for bid response with requestId: ', args.requestId); return; } + + if ((bid.bidder && args.bidderCode && bid.bidder !== args.bidderCode) || (bid.bidder === args.bidderCode && bid.status === SUCCESS)) { + bid = copyRequiredBidDetails(args); + cache.auctions[args.auctionId].adUnitCodes[args.adUnitCode].bids[args.requestId].push(bid); + } + + if (args.floorData) { + cache.auctions[args.auctionId].floorData['floorResponseData'] = args.floorData; + } + + bid.adId = args.adId; bid.source = formatSource(bid.source || args.source); setBidStatus(bid, args); + const latency = args?.timeToRespond || Date.now() - cache.auctions[args.auctionId].timestamp; + const auctionTime = cache.auctions[args.auctionId].timeout; + // Check if latency is greater than auctiontime+150, then log auctiontime+150 to avoid large numbers + bid.partnerTimeToRespond = latency > (auctionTime + 150) ? (auctionTime + 150) : latency; bid.clientLatencyTimeMs = Date.now() - cache.auctions[args.auctionId].timestamp; bid.bidResponse = parseBidResponse(args); } +function bidRejectedHandler(args) { + // If bid is rejected due to floors value did not met + // make cpm as 0, status as bidRejected and forward the bid for logging + if (args.rejectionReason === CONSTANTS.REJECTION_REASON.FLOOR_NOT_MET) { + args.cpm = 0; + args.status = CONSTANTS.BID_STATUS.BID_REJECTED; + bidResponseHandler(args); + } +} + function bidderDoneHandler(args) { cache.auctions[args.auctionId].bidderDonePendingCount--; args.bids.forEach(bid => { @@ -397,6 +546,7 @@ function bidderDoneHandler(args) { function bidWonHandler(args) { let auctionCache = cache.auctions[args.auctionId]; auctionCache.adUnitCodes[args.adUnitCode].bidWon = args.requestId; + auctionCache.adUnitCodes[args.adUnitCode].bidWonAdId = args.adId; executeBidWonLoggerCall(args.auctionId, args.adUnitCode); } @@ -413,7 +563,7 @@ function bidTimeoutHandler(args) { // db = 0 and t = 1 means bidder did respond with a bid but post timeout args.forEach(badBid => { let auctionCache = cache.auctions[badBid.auctionId]; - let bid = auctionCache.adUnitCodes[badBid.adUnitCode].bids[ badBid.bidId || badBid.requestId ]; + let bid = auctionCache.adUnitCodes[badBid.adUnitCode].bids[ badBid.bidId || badBid.requestId ][0]; if (bid) { bid.status = ERROR; bid.error = { @@ -475,6 +625,9 @@ let pubmaticAdapter = Object.assign({}, baseAdapter, { case CONSTANTS.EVENTS.BID_RESPONSE: bidResponseHandler(args); break; + case CONSTANTS.EVENTS.BID_REJECTED: + bidRejectedHandler(args) + break; case CONSTANTS.EVENTS.BIDDER_DONE: bidderDoneHandler(args); break; diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 0667ac0fc74..16d909c2fea 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -1,8 +1,11 @@ -import { logWarn, _each, isBoolean, isStr, isArray, inIframe, mergeDeep, deepAccess, isNumber, deepSetValue, logInfo, logError, deepClone, convertTypes } from '../src/utils.js'; +import { getBidRequest, logWarn, isBoolean, isStr, isArray, inIframe, mergeDeep, deepAccess, isNumber, deepSetValue, logInfo, logError, deepClone, uniques, isPlainObject, isInteger } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; -import {config} from '../src/config.js'; +import { BANNER, VIDEO, NATIVE, ADPOD } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; +import { bidderSettings } from '../src/bidderSettings.js'; +import CONSTANTS from '../src/constants.json'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; const BIDDER_CODE = 'pubmatic'; const LOG_WARN_PREFIX = 'PubMatic: '; @@ -11,8 +14,6 @@ const USER_SYNC_URL_IFRAME = 'https://ads.pubmatic.com/AdServer/js/user_sync.htm const USER_SYNC_URL_IMAGE = 'https://image8.pubmatic.com/AdServer/ImgSync?p='; const DEFAULT_CURRENCY = 'USD'; const AUCTION_TYPE = 1; -const GROUPM_ALIAS = {code: 'groupm', gvlid: 98}; -const MARKETPLACE_PARTNERS = ['groupm'] const UNDEFINED = undefined; const DEFAULT_WIDTH = 0; const DEFAULT_HEIGHT = 0; @@ -20,6 +21,7 @@ const PREBID_NATIVE_HELP_LINK = 'http://prebid.org/dev-docs/show-native-ads.html const PUBLICATION = 'pubmatic'; // Your publication on Blue Billywig, potentially with environment (e.g. publication.bbvms.com or publication.test.bbvms.com) const RENDERER_URL = 'https://pubmatic.bbvms.com/r/'.concat('$RENDERER', '.js'); // URL of the renderer application const MSG_VIDEO_PLACEMENT_MISSING = 'Video.Placement param missing'; + const CUSTOM_PARAMS = { 'kadpageurl': '', // Custom page url 'gender': '', // User gender @@ -50,61 +52,17 @@ const VIDEO_CUSTOM_PARAMS = { 'battr': DATA_TYPES.ARRAY, 'linearity': DATA_TYPES.NUMBER, 'placement': DATA_TYPES.NUMBER, + 'plcmt': DATA_TYPES.NUMBER, 'minbitrate': DATA_TYPES.NUMBER, 'maxbitrate': DATA_TYPES.NUMBER, 'skip': DATA_TYPES.NUMBER } -const NATIVE_ASSETS = { - 'TITLE': { ID: 1, KEY: 'title', TYPE: 0 }, - 'IMAGE': { ID: 2, KEY: 'image', TYPE: 0 }, - 'ICON': { ID: 3, KEY: 'icon', TYPE: 0 }, - 'SPONSOREDBY': { ID: 4, KEY: 'sponsoredBy', TYPE: 1 }, // please note that type of SPONSORED is also 1 - 'BODY': { ID: 5, KEY: 'body', TYPE: 2 }, // please note that type of DESC is also set to 2 - 'CLICKURL': { ID: 6, KEY: 'clickUrl', TYPE: 0 }, - 'VIDEO': { ID: 7, KEY: 'video', TYPE: 0 }, - 'EXT': { ID: 8, KEY: 'ext', TYPE: 0 }, - 'DATA': { ID: 9, KEY: 'data', TYPE: 0 }, - 'LOGO': { ID: 10, KEY: 'logo', TYPE: 0 }, - 'SPONSORED': { ID: 11, KEY: 'sponsored', TYPE: 1 }, // please note that type of SPONSOREDBY is also set to 1 - 'DESC': { ID: 12, KEY: 'data', TYPE: 2 }, // please note that type of BODY is also set to 2 - 'RATING': { ID: 13, KEY: 'rating', TYPE: 3 }, - 'LIKES': { ID: 14, KEY: 'likes', TYPE: 4 }, - 'DOWNLOADS': { ID: 15, KEY: 'downloads', TYPE: 5 }, - 'PRICE': { ID: 16, KEY: 'price', TYPE: 6 }, - 'SALEPRICE': { ID: 17, KEY: 'saleprice', TYPE: 7 }, - 'PHONE': { ID: 18, KEY: 'phone', TYPE: 8 }, - 'ADDRESS': { ID: 19, KEY: 'address', TYPE: 9 }, - 'DESC2': { ID: 20, KEY: 'desc2', TYPE: 10 }, - 'DISPLAYURL': { ID: 21, KEY: 'displayurl', TYPE: 11 }, - 'CTA': { ID: 22, KEY: 'cta', TYPE: 12 } -}; - const NATIVE_ASSET_IMAGE_TYPE = { 'ICON': 1, - 'LOGO': 2, 'IMAGE': 3 } -// check if title, image can be added with mandatory field default values -const NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS = [ - { - id: NATIVE_ASSETS.SPONSOREDBY.ID, - required: true, - data: { - type: 1 - } - }, - { - id: NATIVE_ASSETS.TITLE.ID, - required: true, - }, - { - id: NATIVE_ASSETS.IMAGE.ID, - required: true, - } -] - const NET_REVENUE = true; const dealChannelValues = { 1: 'PMP', @@ -112,10 +70,6 @@ const dealChannelValues = { 6: 'PMPG' }; -const FLOC_FORMAT = { - 'EID': 1, - 'SEGMENT': 2 -} // BB stands for Blue BillyWig const BB_RENDERER = { bootstrapPlayer: function(bid) { @@ -179,15 +133,10 @@ const MEDIATYPE = [ let publisherId = 0; let isInvalidNativeRequest = false; -let NATIVE_ASSET_ID_TO_KEY_MAP = {}; -let NATIVE_ASSET_KEY_TO_ASSET_MAP = {}; +let biddersList = ['pubmatic']; +const allBiddersList = ['all']; -// loading NATIVE_ASSET_ID_TO_KEY_MAP -_each(NATIVE_ASSETS, anAsset => { NATIVE_ASSET_ID_TO_KEY_MAP[anAsset.ID] = anAsset.KEY }); -// loading NATIVE_ASSET_KEY_TO_ASSET_MAP -_each(NATIVE_ASSETS, anAsset => { NATIVE_ASSET_KEY_TO_ASSET_MAP[anAsset.KEY] = anAsset }); - -function _getDomainFromURL(url) { +export function _getDomainFromURL(url) { let anchor = document.createElement('a'); anchor.href = url; return anchor.hostname; @@ -274,8 +223,9 @@ function _parseAdSlot(bid) { function _initConf(refererInfo) { return { - pageURL: (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href, - refURL: window.document.referrer + // TODO: do the fallbacks make sense here? + pageURL: refererInfo?.page || window.location.href, + refURL: refererInfo?.ref || window.document.referrer }; } @@ -356,145 +306,189 @@ function _checkParamDataType(key, value, datatype) { return UNDEFINED; } -function _commonNativeRequestObject(nativeAsset, params) { - var key = nativeAsset.KEY; - return { - id: nativeAsset.ID, - required: params[key].required ? 1 : 0, - data: { - type: nativeAsset.TYPE, - len: params[key].len, - ext: params[key].ext - } - }; -} +// TODO delete this code when removing native 1.1 support +const PREBID_NATIVE_DATA_KEYS_TO_ORTB = { + 'desc': 'desc', + 'desc2': 'desc2', + 'body': 'desc', + 'body2': 'desc2', + 'sponsoredBy': 'sponsored', + 'cta': 'ctatext', + 'rating': 'rating', + 'address': 'address', + 'downloads': 'downloads', + 'likes': 'likes', + 'phone': 'phone', + 'price': 'price', + 'salePrice': 'saleprice', + 'displayUrl': 'displayurl', + 'saleprice': 'saleprice', + 'displayurl': 'displayurl' +}; -function _createNativeRequest(params) { - var nativeRequestObject = { +const { NATIVE_IMAGE_TYPES, NATIVE_KEYS_THAT_ARE_NOT_ASSETS, NATIVE_KEYS, NATIVE_ASSET_TYPES } = CONSTANTS; +const PREBID_NATIVE_DATA_KEY_VALUES = Object.values(PREBID_NATIVE_DATA_KEYS_TO_ORTB); + +// TODO remove this function when the support for 1.1 is removed +/** + * Copy of the function toOrtbNativeRequest from core native.js to handle the title len/length + * and ext and mimes parameters from legacy assets. + * @param {object} legacyNativeAssets + * @returns an OpenRTB format of the same bid request + */ +export function toOrtbNativeRequest(legacyNativeAssets) { + if (!legacyNativeAssets && !isPlainObject(legacyNativeAssets)) { + logWarn(`${LOG_WARN_PREFIX}: Native assets object is empty or not an object: ${legacyNativeAssets}`); + isInvalidNativeRequest = true; + return; + } + const ortb = { + ver: '1.2', assets: [] }; - for (var key in params) { - if (params.hasOwnProperty(key)) { - var assetObj = {}; - if (!(nativeRequestObject.assets && nativeRequestObject.assets.length > 0 && nativeRequestObject.assets.hasOwnProperty(key))) { - switch (key) { - case NATIVE_ASSETS.TITLE.KEY: - if (params[key].len || params[key].length) { - assetObj = { - id: NATIVE_ASSETS.TITLE.ID, - required: params[key].required ? 1 : 0, - title: { - len: params[key].len || params[key].length, - ext: params[key].ext - } - }; - } else { - logWarn(LOG_WARN_PREFIX + 'Error: Title Length is required for native ad: ' + JSON.stringify(params)); - } - break; - case NATIVE_ASSETS.IMAGE.KEY: - if (params[key].sizes && params[key].sizes.length > 0) { - assetObj = { - id: NATIVE_ASSETS.IMAGE.ID, - required: params[key].required ? 1 : 0, - img: { - type: NATIVE_ASSET_IMAGE_TYPE.IMAGE, - w: params[key].w || params[key].width || (params[key].sizes ? params[key].sizes[0] : UNDEFINED), - h: params[key].h || params[key].height || (params[key].sizes ? params[key].sizes[1] : UNDEFINED), - wmin: params[key].wmin || params[key].minimumWidth || (params[key].minsizes ? params[key].minsizes[0] : UNDEFINED), - hmin: params[key].hmin || params[key].minimumHeight || (params[key].minsizes ? params[key].minsizes[1] : UNDEFINED), - mimes: params[key].mimes, - ext: params[key].ext, - } - }; - } else { - logWarn(LOG_WARN_PREFIX + 'Error: Image sizes is required for native ad: ' + JSON.stringify(params)); + for (let key in legacyNativeAssets) { + // skip conversion for non-asset keys + if (NATIVE_KEYS_THAT_ARE_NOT_ASSETS.includes(key)) continue; + if (!NATIVE_KEYS.hasOwnProperty(key) && !PREBID_NATIVE_DATA_KEY_VALUES.includes(key)) { + logWarn(`${LOG_WARN_PREFIX}: Unrecognized native asset code: ${key}. Asset will be ignored.`); + continue; + } + + const asset = legacyNativeAssets[key]; + let required = 0; + if (asset.required && isBoolean(asset.required)) { + required = Number(asset.required); + } + const ortbAsset = { + id: ortb.assets.length, + required + }; + // data cases + if (key in PREBID_NATIVE_DATA_KEYS_TO_ORTB) { + ortbAsset.data = { + type: NATIVE_ASSET_TYPES[PREBID_NATIVE_DATA_KEYS_TO_ORTB[key]] + } + if (asset.len || asset.length) { + ortbAsset.data.len = asset.len || asset.length; + } + if (asset.ext) { + ortbAsset.data.ext = asset.ext; + } + // icon or image case + } else if (key === 'icon' || key === 'image') { + ortbAsset.img = { + type: key === 'icon' ? NATIVE_IMAGE_TYPES.ICON : NATIVE_IMAGE_TYPES.MAIN, + } + // if min_width and min_height are defined in aspect_ratio, they are preferred + if (asset.aspect_ratios) { + if (!isArray(asset.aspect_ratios)) { + logWarn(`${LOG_WARN_PREFIX}: image.aspect_ratios was passed, but it's not a an array: ${asset.aspect_ratios}`); + } else if (!asset.aspect_ratios.length) { + logWarn(`${LOG_WARN_PREFIX}: image.aspect_ratios was passed, but it's empty: ${asset.aspect_ratios}`); + } else { + const { min_width: minWidth, min_height: minHeight } = asset.aspect_ratios[0]; + if (!isInteger(minWidth) || !isInteger(minHeight)) { + logWarn(`${LOG_WARN_PREFIX}: image.aspect_ratios min_width or min_height are invalid: ${minWidth}, ${minHeight}`); + } else { + ortbAsset.img.wmin = minWidth; + ortbAsset.img.hmin = minHeight; + } + const aspectRatios = asset.aspect_ratios + .filter((ar) => ar.ratio_width && ar.ratio_height) + .map(ratio => `${ratio.ratio_width}:${ratio.ratio_height}`); + if (aspectRatios.length > 0) { + ortbAsset.img.ext = { + aspectratios: aspectRatios } - break; - case NATIVE_ASSETS.ICON.KEY: - if (params[key].sizes && params[key].sizes.length > 0) { - assetObj = { - id: NATIVE_ASSETS.ICON.ID, - required: params[key].required ? 1 : 0, - img: { - type: NATIVE_ASSET_IMAGE_TYPE.ICON, - w: params[key].w || params[key].width || (params[key].sizes ? params[key].sizes[0] : UNDEFINED), - h: params[key].h || params[key].height || (params[key].sizes ? params[key].sizes[1] : UNDEFINED), - } - }; - } else { - logWarn(LOG_WARN_PREFIX + 'Error: Icon sizes is required for native ad: ' + JSON.stringify(params)); - }; - break; - case NATIVE_ASSETS.VIDEO.KEY: - assetObj = { - id: NATIVE_ASSETS.VIDEO.ID, - required: params[key].required ? 1 : 0, - video: { - minduration: params[key].minduration, - maxduration: params[key].maxduration, - protocols: params[key].protocols, - mimes: params[key].mimes, - ext: params[key].ext - } - }; - break; - case NATIVE_ASSETS.EXT.KEY: - assetObj = { - id: NATIVE_ASSETS.EXT.ID, - required: params[key].required ? 1 : 0, - }; - break; - case NATIVE_ASSETS.LOGO.KEY: - assetObj = { - id: NATIVE_ASSETS.LOGO.ID, - required: params[key].required ? 1 : 0, - img: { - type: NATIVE_ASSET_IMAGE_TYPE.LOGO, - w: params[key].w || params[key].width || (params[key].sizes ? params[key].sizes[0] : UNDEFINED), - h: params[key].h || params[key].height || (params[key].sizes ? params[key].sizes[1] : UNDEFINED) - } - }; - break; - case NATIVE_ASSETS.SPONSOREDBY.KEY: - case NATIVE_ASSETS.BODY.KEY: - case NATIVE_ASSETS.RATING.KEY: - case NATIVE_ASSETS.LIKES.KEY: - case NATIVE_ASSETS.DOWNLOADS.KEY: - case NATIVE_ASSETS.PRICE.KEY: - case NATIVE_ASSETS.SALEPRICE.KEY: - case NATIVE_ASSETS.PHONE.KEY: - case NATIVE_ASSETS.ADDRESS.KEY: - case NATIVE_ASSETS.DESC2.KEY: - case NATIVE_ASSETS.DISPLAYURL.KEY: - case NATIVE_ASSETS.CTA.KEY: - assetObj = _commonNativeRequestObject(NATIVE_ASSET_KEY_TO_ASSET_MAP[key], params); - break; + } + } + } + + ortbAsset.img.w = asset.w || asset.width; + ortbAsset.img.h = asset.h || asset.height; + ortbAsset.img.wmin = asset.wmin || asset.minimumWidth || (asset.minsizes ? asset.minsizes[0] : UNDEFINED); + ortbAsset.img.hmin = asset.hmin || asset.minimumHeight || (asset.minsizes ? asset.minsizes[1] : UNDEFINED); + + // if asset.sizes exist, by OpenRTB spec we should remove wmin and hmin + if (asset.sizes) { + if (asset.sizes.length !== 2 || !isInteger(asset.sizes[0]) || !isInteger(asset.sizes[1])) { + logWarn(`${LOG_WARN_PREFIX}: image.sizes was passed, but its value is not an array of integers: ${asset.sizes}`); + } else { + logInfo(`${LOG_WARN_PREFIX}: if asset.sizes exist, by OpenRTB spec we should remove wmin and hmin`); + ortbAsset.img.w = asset.sizes[0]; + ortbAsset.img.h = asset.sizes[1]; + delete ortbAsset.img.hmin; + delete ortbAsset.img.wmin; } } + asset.ext && (ortbAsset.img.ext = asset.ext); + asset.mimes && (ortbAsset.img.mimes = asset.mimes); + // title case + } else if (key === 'title') { + ortbAsset.title = { + // in openRTB, len is required for titles, while in legacy prebid was not. + // for this reason, if len is missing in legacy prebid, we're adding a default value of 140. + len: asset.len || asset.length || 140 + } + asset.ext && (ortbAsset.title.ext = asset.ext); + // all extensions to the native bid request are passed as is + } else if (key === 'ext') { + ortbAsset.ext = asset; + // in `ext` case, required field is not needed + delete ortbAsset.required; } - if (assetObj && assetObj.id) { - nativeRequestObject.assets[nativeRequestObject.assets.length] = assetObj; + ortb.assets.push(ortbAsset); + } + + if (ortb.assets.length < 1) { + logWarn(`${LOG_WARN_PREFIX}: Could not find any valid asset`); + isInvalidNativeRequest = true; + return; + } + + return ortb; +} +// TODO delete this code when removing native 1.1 support + +function _createNativeRequest(params) { + var nativeRequestObject; + + // TODO delete this code when removing native 1.1 support + if (!params.ortb) { // legacy assets definition found + nativeRequestObject = toOrtbNativeRequest(params); + } else { // ortb assets definition found + params = params.ortb; + // TODO delete this code when removing native 1.1 support + nativeRequestObject = { ver: '1.2', ...params, assets: [] }; + const { assets } = params; + + const isValidAsset = (asset) => asset.title || asset.img || asset.data || asset.video; + + if (assets.length < 1 || !assets.some(asset => isValidAsset(asset))) { + logWarn(`${LOG_WARN_PREFIX}: Native assets object is empty or contains some invalid object`); + isInvalidNativeRequest = true; + return nativeRequestObject; } - }; - // for native image adtype prebid has to have few required assests i.e. title,sponsoredBy, image - // if any of these are missing from the request then request will not be sent - var requiredAssetCount = NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS.length; - var presentrequiredAssetCount = 0; - NATIVE_MINIMUM_REQUIRED_IMAGE_ASSETS.forEach(ele => { - var lengthOfExistingAssets = nativeRequestObject.assets.length; - for (var i = 0; i < lengthOfExistingAssets; i++) { - if (ele.id == nativeRequestObject.assets[i].id) { - presentrequiredAssetCount++; - break; + assets.forEach(asset => { + var assetObj = asset; + if (assetObj.img) { + if (assetObj.img.type == NATIVE_ASSET_IMAGE_TYPE.IMAGE) { + assetObj.w = assetObj.w || assetObj.width || (assetObj.sizes ? assetObj.sizes[0] : UNDEFINED); + assetObj.h = assetObj.h || assetObj.height || (assetObj.sizes ? assetObj.sizes[1] : UNDEFINED); + assetObj.wmin = assetObj.wmin || assetObj.minimumWidth || (assetObj.minsizes ? assetObj.minsizes[0] : UNDEFINED); + assetObj.hmin = assetObj.hmin || assetObj.minimumHeight || (assetObj.minsizes ? assetObj.minsizes[1] : UNDEFINED); + } else if (assetObj.img.type == NATIVE_ASSET_IMAGE_TYPE.ICON) { + assetObj.w = assetObj.w || assetObj.width || (assetObj.sizes ? assetObj.sizes[0] : UNDEFINED); + assetObj.h = assetObj.h || assetObj.height || (assetObj.sizes ? assetObj.sizes[1] : UNDEFINED); + } + } + + if (assetObj && assetObj.id !== undefined && isValidAsset(assetObj)) { + nativeRequestObject.assets.push(assetObj); } } - }); - if (requiredAssetCount == presentrequiredAssetCount) { - isInvalidNativeRequest = false; - } else { - isInvalidNativeRequest = true; + ); } return nativeRequestObject; } @@ -542,7 +536,7 @@ function _createBannerRequest(bid) { export function checkVideoPlacement(videoData, adUnitCode) { // Check for video.placement property. If property is missing display log message. - if (!deepAccess(videoData, 'placement')) { + if (FEATURES.VIDEO && !deepAccess(videoData, 'placement')) { logWarn(MSG_VIDEO_PLACEMENT_MISSING + ' for ' + adUnitCode); }; } @@ -551,7 +545,7 @@ function _createVideoRequest(bid) { var videoData = mergeDeep(deepAccess(bid.mediaTypes, 'video'), bid.params.video); var videoObj; - if (videoData !== UNDEFINED) { + if (FEATURES.VIDEO && videoData !== UNDEFINED) { videoObj = {}; checkVideoPlacement(videoData, bid.adUnitCode); for (var key in VIDEO_CUSTOM_PARAMS) { @@ -609,14 +603,14 @@ function _addDealCustomTargetings(imp, bid) { if (dctr.substring(dctrLen, dctrLen - 1) === '|') { dctr = dctr.substring(0, dctrLen - 1); } - imp.ext['key_val'] = dctr.trim() + imp.ext['key_val'] = dctr.trim(); } else { logWarn(LOG_WARN_PREFIX + 'Ignoring param : dctr with value : ' + dctr + ', expects string-value, found empty or non-string value'); } } } -function _addJWPlayerSegmentData(imp, bid, isS2S) { +function _addJWPlayerSegmentData(imp, bid) { var jwSegData = (bid.rtd && bid.rtd.jwplayer && bid.rtd.jwplayer.targeting) || undefined; var jwPlayerData = ''; const jwMark = 'jw-'; @@ -633,15 +627,11 @@ function _addJWPlayerSegmentData(imp, bid, isS2S) { var ext; - if (isS2S) { - (imp.dctr === undefined || imp.dctr.length == 0) ? imp.dctr = jwPlayerData : imp.dctr += '|' + jwPlayerData; - } else { - ext = imp.ext; - ext && ext.key_val === undefined ? ext.key_val = jwPlayerData : ext.key_val += '|' + jwPlayerData; - } + ext = imp.ext; + ext && ext.key_val === undefined ? ext.key_val = jwPlayerData : ext.key_val += '|' + jwPlayerData; } -function _createImpressionObject(bid, conf) { +function _createImpressionObject(bid, bidderRequest) { var impObj = {}; var bannerObj; var videoObj; @@ -649,6 +639,7 @@ function _createImpressionObject(bid, conf) { var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : []; var mediaTypes = ''; var format = []; + var isFledgeEnabled = bidderRequest?.fledgeEnabled; impObj = { id: bid.bidId, @@ -674,14 +665,18 @@ function _createImpressionObject(bid, conf) { } break; case NATIVE: + // TODO uncomment below line when removing native 1.1 support + // nativeObj['request'] = JSON.stringify(_createNativeRequest(bid.nativeOrtbRequest)); + // TODO delete below line when removing native 1.1 support nativeObj['request'] = JSON.stringify(_createNativeRequest(bid.nativeParams)); if (!isInvalidNativeRequest) { impObj.native = nativeObj; } else { logWarn(LOG_WARN_PREFIX + 'Error: Error in Native adunit ' + bid.params.adUnit + '. Ignoring the adunit. Refer to ' + PREBID_NATIVE_HELP_LINK + ' for more details.'); + isInvalidNativeRequest = false; } break; - case VIDEO: + case FEATURES.VIDEO && VIDEO: videoObj = _createVideoRequest(bid); if (videoObj !== UNDEFINED) { impObj.video = videoObj; @@ -715,9 +710,24 @@ function _createImpressionObject(bid, conf) { _addFloorFromFloorModule(impObj, bid); + _addFledgeflag(impObj, bid, isFledgeEnabled) + return impObj.hasOwnProperty(BANNER) || impObj.hasOwnProperty(NATIVE) || - impObj.hasOwnProperty(VIDEO) ? impObj : UNDEFINED; + (FEATURES.VIDEO && impObj.hasOwnProperty(VIDEO)) ? impObj : UNDEFINED; +} + +function _addFledgeflag(impObj, bid, isFledgeEnabled) { + if (isFledgeEnabled) { + impObj.ext = impObj.ext || {}; + if (bid?.ortb2Imp?.ext?.ae !== undefined) { + impObj.ext.ae = bid.ortb2Imp.ext.ae; + } + } else { + if (impObj.ext?.ae) { + delete impObj.ext.ae; + } + } } function _addImpressionFPD(imp, bid) { @@ -800,67 +810,8 @@ function _addFloorFromFloorModule(impObj, bid) { logInfo(LOG_WARN_PREFIX, 'new impObj.bidfloor value:', impObj.bidfloor); } -function _getFlocId(validBidRequests, flocFormat) { - var flocIdObject = null; - var flocId = deepAccess(validBidRequests, '0.userId.flocId'); - if (flocId && flocId.id) { - switch (flocFormat) { - case FLOC_FORMAT.SEGMENT: - flocIdObject = { - id: 'FLOC', - name: 'FLOC', - ext: { - ver: flocId.version - }, - segment: [{ - id: flocId.id, - name: 'chrome.com', - value: flocId.id.toString() - }] - } - break; - case FLOC_FORMAT.EID: - default: - flocIdObject = { - source: 'chrome.com', - uids: [ - { - atype: 1, - id: flocId.id, - ext: { - ver: flocId.version - } - }, - ] - } - break; - } - } - return flocIdObject; -} - -function _handleFlocId(payload, validBidRequests) { - var flocObject = _getFlocId(validBidRequests, FLOC_FORMAT.SEGMENT); - if (flocObject) { - if (!payload.user) { - payload.user = {}; - } - if (!payload.user.data) { - payload.user.data = []; - } - payload.user.data.push(flocObject); - } -} - function _handleEids(payload, validBidRequests) { let bidUserIdAsEids = deepAccess(validBidRequests, '0.userIdAsEids'); - let flocObject = _getFlocId(validBidRequests, FLOC_FORMAT.EID); - if (flocObject) { - if (!bidUserIdAsEids) { - bidUserIdAsEids = []; - } - bidUserIdAsEids.push(flocObject); - } if (isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) { deepSetValue(payload, 'user.eids', bidUserIdAsEids); } @@ -871,13 +822,13 @@ function _checkMediaType(bid, newBid) { if (bid.ext && bid.ext['bidtype'] != undefined) { newBid.mediaType = MEDIATYPE[bid.ext.bidtype]; } else { - logInfo(LOG_WARN_PREFIX + 'bid.ext.bidtype does not exist, checking alternatively for mediaType') + logInfo(LOG_WARN_PREFIX + 'bid.ext.bidtype does not exist, checking alternatively for mediaType'); var adm = bid.adm; var admStr = ''; var videoRegex = new RegExp(/VAST\s+version/); if (adm.indexOf('span class="PubAPIAd"') >= 0) { newBid.mediaType = BANNER; - } else if (videoRegex.test(adm)) { + } else if (FEATURES.VIDEO && videoRegex.test(adm)) { newBid.mediaType = VIDEO; } else { try { @@ -893,7 +844,6 @@ function _checkMediaType(bid, newBid) { } function _parseNativeResponse(bid, newBid) { - newBid.native = {}; if (bid.hasOwnProperty('adm')) { var adm = ''; try { @@ -902,53 +852,15 @@ function _parseNativeResponse(bid, newBid) { logWarn(LOG_WARN_PREFIX + 'Error: Cannot parse native reponse for ad response: ' + newBid.adm); return; } - if (adm && adm.native && adm.native.assets && adm.native.assets.length > 0) { - newBid.mediaType = NATIVE; - for (let i = 0, len = adm.native.assets.length; i < len; i++) { - switch (adm.native.assets[i].id) { - case NATIVE_ASSETS.TITLE.ID: - newBid.native.title = adm.native.assets[i].title && adm.native.assets[i].title.text; - break; - case NATIVE_ASSETS.IMAGE.ID: - newBid.native.image = { - url: adm.native.assets[i].img && adm.native.assets[i].img.url, - height: adm.native.assets[i].img && adm.native.assets[i].img.h, - width: adm.native.assets[i].img && adm.native.assets[i].img.w, - }; - break; - case NATIVE_ASSETS.ICON.ID: - newBid.native.icon = { - url: adm.native.assets[i].img && adm.native.assets[i].img.url, - height: adm.native.assets[i].img && adm.native.assets[i].img.h, - width: adm.native.assets[i].img && adm.native.assets[i].img.w, - }; - break; - case NATIVE_ASSETS.SPONSOREDBY.ID: - case NATIVE_ASSETS.BODY.ID: - case NATIVE_ASSETS.LIKES.ID: - case NATIVE_ASSETS.DOWNLOADS.ID: - case NATIVE_ASSETS.PRICE: - case NATIVE_ASSETS.SALEPRICE.ID: - case NATIVE_ASSETS.PHONE.ID: - case NATIVE_ASSETS.ADDRESS.ID: - case NATIVE_ASSETS.DESC2.ID: - case NATIVE_ASSETS.CTA.ID: - case NATIVE_ASSETS.RATING.ID: - case NATIVE_ASSETS.DISPLAYURL.ID: - newBid.native[NATIVE_ASSET_ID_TO_KEY_MAP[adm.native.assets[i].id]] = adm.native.assets[i].data && adm.native.assets[i].data.value; - break; - } - } - newBid.native.clickUrl = adm.native.link && adm.native.link.url; - newBid.native.clickTrackers = (adm.native.link && adm.native.link.clicktrackers) || []; - newBid.native.impressionTrackers = adm.native.imptrackers || []; - newBid.native.jstracker = adm.native.jstracker || []; - if (!newBid.width) { - newBid.width = DEFAULT_WIDTH; - } - if (!newBid.height) { - newBid.height = DEFAULT_HEIGHT; - } + newBid.native = { + ortb: { ...adm.native } + }; + newBid.mediaType = NATIVE; + if (!newBid.width) { + newBid.width = DEFAULT_WIDTH; + } + if (!newBid.height) { + newBid.height = DEFAULT_HEIGHT; } } } @@ -977,13 +889,35 @@ function _blockedIabCategoriesValidation(payload, blockedIabCategories) { } } +function _allowedIabCategoriesValidation(payload, allowedIabCategories) { + allowedIabCategories = allowedIabCategories + .filter(function(category) { + if (typeof category === 'string') { // returns only strings + return true; + } else { + logWarn(LOG_WARN_PREFIX + 'acat: Each category should be a string, ignoring category: ' + category); + return false; + } + }) + .map(category => category.trim()) // trim all categories + .filter((category, index, arr) => arr.indexOf(category) === index); // return unique values only + + if (allowedIabCategories.length > 0) { + logWarn(LOG_WARN_PREFIX + 'acat: Selected: ', allowedIabCategories); + payload.ext.acat = allowedIabCategories; + } +} + function _assignRenderer(newBid, request) { let bidParams, context, adUnitCode; if (request.bidderRequest && request.bidderRequest.bids) { for (let bidderRequestBidsIndex = 0; bidderRequestBidsIndex < request.bidderRequest.bids.length; bidderRequestBidsIndex++) { if (request.bidderRequest.bids[bidderRequestBidsIndex].bidId === newBid.requestId) { bidParams = request.bidderRequest.bids[bidderRequestBidsIndex].params; - context = request.bidderRequest.bids[bidderRequestBidsIndex].mediaTypes[VIDEO].context; + + if (FEATURES.VIDEO) { + context = request.bidderRequest.bids[bidderRequestBidsIndex].mediaTypes[VIDEO].context; + } adUnitCode = request.bidderRequest.bids[bidderRequestBidsIndex].adUnitCode; } } @@ -994,6 +928,29 @@ function _assignRenderer(newBid, request) { } } +/** + * In case of adpod video context, assign prebiddealpriority to the dealtier property of adpod-video bid, + * so that adpod module can set the hb_pb_cat_dur targetting key. + * @param {*} newBid + * @param {*} bid + * @param {*} request + * @returns + */ +export function assignDealTier(newBid, bid, request) { + if (!bid?.ext?.prebiddealpriority || !FEATURES.VIDEO) return; + const bidRequest = getBidRequest(newBid.requestId, [request.bidderRequest]); + const videoObj = deepAccess(bidRequest, 'mediaTypes.video'); + if (videoObj?.context != ADPOD) return; + + const duration = bid?.ext?.video?.duration || videoObj?.maxduration; + // if (!duration) return; + newBid.video = { + context: ADPOD, + durationSeconds: duration, + dealTier: bid.ext.prebiddealpriority + }; +} + function isNonEmptyArray(test) { if (isArray(test) === true) { if (test.length > 0) { @@ -1003,11 +960,53 @@ function isNonEmptyArray(test) { return false; } +/** + * Prepare meta object to pass as params + * @param {*} br : bidResponse + * @param {*} bid : bids + */ +export function prepareMetaObject(br, bid, seat) { + br.meta = {}; + + if (bid.ext && bid.ext.dspid) { + br.meta.networkId = bid.ext.dspid; + br.meta.demandSource = bid.ext.dspid; + } + + // NOTE: We will not recieve below fields from the translator response also not sure on what will be the key names for these in the response, + // when we needed we can add it back. + // New fields added, assignee fields name may change + // if (bid.ext.networkName) br.meta.networkName = bid.ext.networkName; + // if (bid.ext.advertiserName) br.meta.advertiserName = bid.ext.advertiserName; + // if (bid.ext.agencyName) br.meta.agencyName = bid.ext.agencyName; + // if (bid.ext.brandName) br.meta.brandName = bid.ext.brandName; + if (bid.ext && bid.ext.dchain) { + br.meta.dchain = bid.ext.dchain; + } + + const advid = seat || (bid.ext && bid.ext.advid); + if (advid) { + br.meta.advertiserId = advid; + br.meta.agencyId = advid; + br.meta.buyerId = advid; + } + + if (bid.adomain && isNonEmptyArray(bid.adomain)) { + br.meta.advertiserDomains = bid.adomain; + br.meta.clickUrl = bid.adomain[0]; + br.meta.brandId = bid.adomain[0]; + } + + if (bid.cat && isNonEmptyArray(bid.cat)) { + br.meta.secondaryCatIds = bid.cat; + br.meta.primaryCatId = bid.cat[0]; + } +} + export const spec = { code: BIDDER_CODE, gvlid: 76, supportedMediaTypes: [BANNER, VIDEO, NATIVE], - aliases: [GROUPM_ALIAS], /** * Determines whether or not the given bid request is valid. Valid bid request must have placementId and hbid * @@ -1021,7 +1020,7 @@ export const spec = { return false; } // video ad validation - if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { + if (FEATURES.VIDEO && bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { // bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array let mediaTypesVideoMimes = deepAccess(bid.mediaTypes, 'video.mimes'); let paramsVideoMimes = deepAccess(bid, 'params.video.mimes'); @@ -1066,12 +1065,8 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { - if (bidderRequest && MARKETPLACE_PARTNERS.includes(bidderRequest.bidderCode)) { - // We have got the buildRequests function call for Marketplace Partners - logInfo('For all publishers using ' + bidderRequest.bidderCode + ' bidder, the PubMatic bidder will also be enabled so PubMatic server will respond back with the bids that needs to be submitted for PubMatic and ' + bidderRequest.bidderCode + ' in the network call sent by PubMatic bidder. Hence we do not want to create a network call for ' + bidderRequest.bidderCode + '. This way we are trying to save a network call from browser.'); - return; - } - + // convert Native ORTB definition to old-style prebid native definition + // validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); var refererInfo; if (bidderRequest && bidderRequest.refererInfo) { refererInfo = bidderRequest.refererInfo; @@ -1082,6 +1077,7 @@ export const spec = { var dctrArr = []; var bid; var blockedIabCategories = []; + var allowedIabCategories = []; validBidRequests.forEach(originalBid => { bid = deepClone(originalBid); @@ -1099,7 +1095,7 @@ export const spec = { } conf.pubId = conf.pubId || bid.params.publisherId; conf = _handleCustomParams(bid.params, conf); - conf.transactionId = bid.transactionId; + conf.transactionId = bid.ortb2Imp?.ext?.tid; if (bidCurrency === '') { bidCurrency = bid.params.currency || UNDEFINED; } else if (bid.params.hasOwnProperty('currency') && bidCurrency !== bid.params.currency) { @@ -1113,7 +1109,10 @@ export const spec = { if (bid.params.hasOwnProperty('bcat') && isArray(bid.params.bcat)) { blockedIabCategories = blockedIabCategories.concat(bid.params.bcat); } - var impObj = _createImpressionObject(bid, conf); + if (bid.params.hasOwnProperty('acat') && isArray(bid.params.acat)) { + allowedIabCategories = allowedIabCategories.concat(bid.params.acat); + } + var impObj = _createImpressionObject(bid, bidderRequest); if (impObj) { payload.imp.push(impObj); } @@ -1128,17 +1127,31 @@ export const spec = { payload.ext.wrapper = {}; payload.ext.wrapper.profile = parseInt(conf.profId) || UNDEFINED; payload.ext.wrapper.version = parseInt(conf.verId) || UNDEFINED; + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 payload.ext.wrapper.wiid = conf.wiid || bidderRequest.auctionId; // eslint-disable-next-line no-undef payload.ext.wrapper.wv = $$REPO_AND_VERSION$$; payload.ext.wrapper.transactionId = conf.transactionId; payload.ext.wrapper.wp = 'pbjs'; + const allowAlternateBidder = bidderRequest ? bidderSettings.get(bidderRequest.bidderCode, 'allowAlternateBidderCodes') : undefined; + if (allowAlternateBidder !== undefined) { + payload.ext.marketplace = {}; + if (bidderRequest && allowAlternateBidder == true) { + let allowedBiddersList = bidderSettings.get(bidderRequest.bidderCode, 'allowedAlternateBidderCodes'); + if (isArray(allowedBiddersList)) { + allowedBiddersList = allowedBiddersList.map(val => val.trim().toLowerCase()).filter(val => !!val).filter(uniques); + biddersList = allowedBiddersList.includes('*') ? allBiddersList : [...biddersList, ...allowedBiddersList]; + } else { + biddersList = allBiddersList; + } + } + payload.ext.marketplace.allowedbidders = biddersList.filter(uniques); + } + payload.user.gender = (conf.gender ? conf.gender.trim() : UNDEFINED); payload.user.geo = {}; - payload.user.geo.lat = _parseSlotParam('lat', conf.lat); - payload.user.geo.lon = _parseSlotParam('lon', conf.lon); + // TODO: fix lat and long to only come from request object, not params payload.user.yob = _parseSlotParam('yob', conf.yob); - payload.device.geo = payload.user.geo; payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim(); payload.site.domain = _getDomainFromURL(payload.site.page); @@ -1152,8 +1165,11 @@ export const spec = { payload.device = Object.assign(payload.device, config.getConfig('device')); } + // update device.language to ISO-639-1-alpha-2 (2 character language) + payload.device.language = payload.device.language && payload.device.language.split('-')[0]; + // passing transactionId in source.tid - deepSetValue(payload, 'source.tid', conf.transactionId); + deepSetValue(payload, 'source.tid', bidderRequest?.ortb2?.source?.tid); // test bids if (window.location.href.indexOf('pubmaticTest=true') !== -1) { @@ -1176,22 +1192,71 @@ export const spec = { deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent); } + // Attaching GPP Consent Params + if (bidderRequest?.gppConsent?.gppString) { + deepSetValue(payload, 'regs.gpp', bidderRequest.gppConsent.gppString); + deepSetValue(payload, 'regs.gpp_sid', bidderRequest.gppConsent.applicableSections); + } else if (bidderRequest?.ortb2?.regs?.gpp) { + deepSetValue(payload, 'regs.gpp', bidderRequest.ortb2.regs.gpp); + deepSetValue(payload, 'regs.gpp_sid', bidderRequest.ortb2.regs.gpp_sid); + } + // coppa compliance if (config.getConfig('coppa') === true) { deepSetValue(payload, 'regs.coppa', 1); } _handleEids(payload, validBidRequests); - _blockedIabCategoriesValidation(payload, blockedIabCategories); - _handleFlocId(payload, validBidRequests); + // First Party Data - const commonFpd = config.getConfig('ortb2') || {}; - if (commonFpd.site) { - mergeDeep(payload, {site: commonFpd.site}); + const commonFpd = (bidderRequest && bidderRequest.ortb2) || {}; + const { user, device, site, bcat } = commonFpd; + if (site) { + const { page, domain, ref } = payload.site; + mergeDeep(payload, {site: site}); + payload.site.page = page; + payload.site.domain = domain; + payload.site.ref = ref; + } + if (user) { + mergeDeep(payload, {user: user}); + } + if (bcat) { + blockedIabCategories = blockedIabCategories.concat(bcat); + } + // check if fpd ortb2 contains device property with sua object + if (device?.sua) { + payload.device.sua = device?.sua; } - if (commonFpd.user) { - mergeDeep(payload, {user: commonFpd.user}); + + if (user?.geo && device?.geo) { + payload.device.geo = { ...payload.device.geo, ...device.geo }; + payload.user.geo = { ...payload.user.geo, ...user.geo }; + } else { + if (user?.geo || device?.geo) { + payload.user.geo = payload.device.geo = (user?.geo ? { ...payload.user.geo, ...user.geo } : { ...payload.user.geo, ...device.geo }); + } + } + + if (commonFpd.ext?.prebid?.bidderparams?.[bidderRequest.bidderCode]?.acat) { + const acatParams = commonFpd.ext.prebid.bidderparams[bidderRequest.bidderCode].acat; + _allowedIabCategoriesValidation(payload, acatParams); + } else if (allowedIabCategories.length) { + _allowedIabCategoriesValidation(payload, allowedIabCategories); } + _blockedIabCategoriesValidation(payload, blockedIabCategories); + + // Check if bidderRequest has timeout property if present send timeout as tmax value to translator request + // bidderRequest has timeout property if publisher sets during calling requestBids function from page + // if not bidderRequest contains global value set by Prebid + if (bidderRequest?.timeout) { + payload.tmax = bidderRequest.timeout; + } else { + payload.tmax = window?.PWT?.versionDetails?.timeout; + } + + // Sending epoch timestamp in request.ext object + payload.ext.epoch = new Date().getTime(); // Note: Do not move this block up // if site object is set in Prebid config then we need to copy required fields from site into app and unset the site object @@ -1237,7 +1302,7 @@ export const spec = { seatbidder.bid.forEach(bid => { let newBid = { requestId: bid.impid, - cpm: (parseFloat(bid.price) || 0).toFixed(2), + cpm: parseFloat((bid.price || 0).toFixed(2)), width: bid.w, height: bid.h, creativeId: bid.crid || bid.id, @@ -1258,11 +1323,12 @@ export const spec = { switch (newBid.mediaType) { case BANNER: break; - case VIDEO: + case FEATURES.VIDEO && VIDEO: newBid.width = bid.hasOwnProperty('w') ? bid.w : req.video.w; newBid.height = bid.hasOwnProperty('h') ? bid.h : req.video.h; newBid.vastXml = bid.adm; _assignRenderer(newBid, request); + assignDealTier(newBid, bid, request); break; case NATIVE: _parseNativeResponse(bid, newBid); @@ -1275,17 +1341,7 @@ export const spec = { newBid['dealChannel'] = dealChannelValues[bid.ext.deal_channel] || null; } - newBid.meta = {}; - if (bid.ext && bid.ext.dspid) { - newBid.meta.networkId = bid.ext.dspid; - } - if (bid.ext && bid.ext.advid) { - newBid.meta.buyerId = bid.ext.advid; - } - if (bid.adomain && bid.adomain.length > 0) { - newBid.meta.advertiserDomains = bid.adomain; - newBid.meta.clickUrl = bid.adomain[0]; - } + prepareMetaObject(newBid, bid, seatbidder.seat); // adserverTargeting if (seatbidder.ext && seatbidder.ext.buyid) { @@ -1296,15 +1352,29 @@ export const spec = { // if from the server-response the bid.ext.marketplace is set then // submit the bid to Prebid as marketplace name - if (bid.ext && !!bid.ext.marketplace && MARKETPLACE_PARTNERS.includes(bid.ext.marketplace)) { + if (bid.ext && !!bid.ext.marketplace) { newBid.bidderCode = bid.ext.marketplace; - newBid.bidder = bid.ext.marketplace; } bidResponses.push(newBid); }); }); } + let fledgeAuctionConfigs = deepAccess(response.body, 'ext.fledge_auction_configs'); + if (fledgeAuctionConfigs) { + fledgeAuctionConfigs = Object.entries(fledgeAuctionConfigs).map(([bidId, cfg]) => { + return { + bidId, + config: Object.assign({ + auctionSignals: {}, + }, cfg) + } + }); + return { + bids: bidResponses, + fledgeAuctionConfigs, + } + } } catch (error) { logError(error); } @@ -1314,7 +1384,7 @@ export const spec = { /** * Register User Sync. */ - getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent) => { + getUserSyncs: (syncOptions, responses, gdprConsent, uspConsent, gppConsent) => { let syncurl = '' + publisherId; // Attaching GDPR Consent Params in UserSync url @@ -1328,6 +1398,12 @@ export const spec = { syncurl += '&us_privacy=' + encodeURIComponent(uspConsent); } + // GPP Consent + if (gppConsent?.gppString && gppConsent?.applicableSections?.length) { + syncurl += '&gpp=' + encodeURIComponent(gppConsent.gppString); + syncurl += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(',')); + } + // coppa compliance if (config.getConfig('coppa') === true) { syncurl += '&coppa=1'; @@ -1354,7 +1430,6 @@ export const spec = { */ transformBidParams: function (params, isOpenRtb, adUnit, bidRequests) { - _addJWPlayerSegmentData(params, adUnit.bids[0], true); return convertTypes({ 'publisherId': 'string', 'adSlot': 'string' diff --git a/modules/pubnxBidAdapter.md b/modules/pubnxBidAdapter.md deleted file mode 100644 index 6c843322402..00000000000 --- a/modules/pubnxBidAdapter.md +++ /dev/null @@ -1,31 +0,0 @@ -# Overview - -``` -Module Name: PubNX Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebid-team@pubnx.com -``` - -# Description - -Connects to PubNX exchange for bids. -PubNX Bidder adapter supports Banner ads. -Use bidder code ```pubnx``` for all PubNX traffic. - -# Test Parameters -``` -var adUnits = [ - // Banner adUnit - { - code: 'banner-div', - sizes: [[300, 250], [300,600]], // a display size(s) - bids: [{ - bidder: 'pubnx', - params: { - placementId: 'PNX-HB-G396432V4809F3' - } - }] - }, -]; -``` - diff --git a/modules/pubperfAnalyticsAdapter.js b/modules/pubperfAnalyticsAdapter.js index 9282d5814c0..9ef95adb77a 100644 --- a/modules/pubperfAnalyticsAdapter.js +++ b/modules/pubperfAnalyticsAdapter.js @@ -2,7 +2,7 @@ * Analytics Adapter for Pubperf */ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import { logError } from '../src/utils.js'; diff --git a/modules/pubstackAnalyticsAdapter.js b/modules/pubstackAnalyticsAdapter.js index b1da40c5b89..ef33b2d75ae 100644 --- a/modules/pubstackAnalyticsAdapter.js +++ b/modules/pubstackAnalyticsAdapter.js @@ -1,4 +1,4 @@ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; const pubstackAnalytics = adapter({ diff --git a/modules/pubwiseAnalyticsAdapter.js b/modules/pubwiseAnalyticsAdapter.js index 006d6da7eb7..6aed462f2d5 100644 --- a/modules/pubwiseAnalyticsAdapter.js +++ b/modules/pubwiseAnalyticsAdapter.js @@ -1,10 +1,12 @@ import { getParameterByName, logInfo, generateUUID, debugTurnedOn } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import { getStorageManager } from '../src/storageManager.js'; -const storage = getStorageManager(); +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; +const MODULE_CODE = 'pubwise'; +const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); /**** * PubWise.io Analytics @@ -157,7 +159,7 @@ function extendUserSessionTimeout() { } function userSessionID() { - return storage.getDataFromLocalStorage(localStorageSessName()) ? localStorage.getItem(localStorageSessName()) : ''; + return storage.getDataFromLocalStorage(localStorageSessName()) || ''; } function sessionExpired() { @@ -224,7 +226,8 @@ function filterAuctionInit(data) { modified.refererInfo = {}; // handle clean referrer, we only need one if (typeof modified.bidderRequests !== 'undefined' && typeof modified.bidderRequests[0] !== 'undefined' && typeof modified.bidderRequests[0].refererInfo !== 'undefined') { - modified.refererInfo = modified.bidderRequests[0].refererInfo; + // TODO: please do not send internal data structures over the network + modified.refererInfo = modified.bidderRequests[0].refererInfo.legacy; } if (typeof modified.adUnitCodes !== 'undefined') { @@ -294,7 +297,7 @@ pubwiseAnalytics.handleEvent = function(eventType, data) { if (eventType === CONSTANTS.EVENTS.AUCTION_END || eventType === CONSTANTS.EVENTS.BID_WON) { flushEvents(); } -} +}; pubwiseAnalytics.storeSessionID = function (userSessID) { storage.setDataInLocalStorage(localStorageSessName(), userSessID); @@ -303,11 +306,14 @@ pubwiseAnalytics.storeSessionID = function (userSessID) { // ensure a session exists, if not make one, always store it pubwiseAnalytics.ensureSession = function () { - if (sessionExpired() === true || userSessionID() === null || userSessionID() === '') { + let sessionId = userSessionID(); + if (sessionExpired() === true || sessionId === null || sessionId === '') { let generatedId = generateUUID(); expireUtmData(); this.storeSessionID(generatedId); sessionData.sessionId = generatedId; + } else if (sessionId != null) { + sessionData.sessionId = sessionId; } // eslint-disable-next-line // console.log('ensured session'); @@ -330,7 +336,7 @@ pubwiseAnalytics.enableAnalytics = function (config) { adapterManager.registerAnalyticsAdapter({ adapter: pubwiseAnalytics, - code: 'pubwise', + code: MODULE_CODE, gvlid: 842 }); diff --git a/modules/pubwiseBidAdapter.js b/modules/pubwiseBidAdapter.js index a1b9ffb56a0..6a5d866c76d 100644 --- a/modules/pubwiseBidAdapter.js +++ b/modules/pubwiseBidAdapter.js @@ -1,19 +1,32 @@ -import { _each, isStr, deepClone, isArray, deepSetValue, inIframe, logMessage, logInfo, logWarn, logError } from '../src/utils.js'; -import { config } from '../src/config.js'; + +import { _each, isBoolean, isEmptyStr, isNumber, isStr, deepClone, isArray, deepSetValue, inIframe, mergeDeep, deepAccess, logMessage, logInfo, logWarn, logError } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE } from '../src/mediaTypes.js'; -const VERSION = '0.1.0'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { OUTSTREAM, INSTREAM } from '../src/video.js'; + +const VERSION = '0.3.0'; const GVLID = 842; const NET_REVENUE = true; const UNDEFINED = undefined; const DEFAULT_CURRENCY = 'USD'; const AUCTION_TYPE = 1; const BIDDER_CODE = 'pwbid'; +const LOG_PREFIX = 'PubWise: '; const ENDPOINT_URL = 'https://bid.pubwise.io/prebid'; +// const ENDPOINT_URL = 'https://bid.pubwise.io/prebid'; // testing observable endpoint const DEFAULT_WIDTH = 0; const DEFAULT_HEIGHT = 0; const PREBID_NATIVE_HELP_LINK = 'https://prebid.org/dev-docs/show-native-ads.html'; // const USERSYNC_URL = '//127.0.0.1:8080/usersync' +const MSG_VIDEO_PLACEMENT_MISSING = 'Video.Placement param missing'; + +const MEDIATYPE = [ + BANNER, + VIDEO, + NATIVE +] const CUSTOM_PARAMS = { 'gender': '', // User gender @@ -22,6 +35,32 @@ const CUSTOM_PARAMS = { 'lon': '', // User Location - Longitude }; +const DATA_TYPES = { + 'NUMBER': 'number', + 'STRING': 'string', + 'BOOLEAN': 'boolean', + 'ARRAY': 'array', + 'OBJECT': 'object' +}; + +const VIDEO_CUSTOM_PARAMS = { + 'mimes': DATA_TYPES.ARRAY, + 'minduration': DATA_TYPES.NUMBER, + 'maxduration': DATA_TYPES.NUMBER, + 'startdelay': DATA_TYPES.NUMBER, + 'playbackmethod': DATA_TYPES.ARRAY, + 'api': DATA_TYPES.ARRAY, + 'protocols': DATA_TYPES.ARRAY, + 'w': DATA_TYPES.NUMBER, + 'h': DATA_TYPES.NUMBER, + 'battr': DATA_TYPES.ARRAY, + 'linearity': DATA_TYPES.NUMBER, + 'placement': DATA_TYPES.NUMBER, + 'minbitrate': DATA_TYPES.NUMBER, + 'maxbitrate': DATA_TYPES.NUMBER, + 'skip': DATA_TYPES.NUMBER +} + // rtb native types are meant to be dynamic and extendable // the extendable data asset types are nicely aligned // in practice we set an ID that is distinct for each real type of return @@ -88,7 +127,7 @@ _each(NATIVE_ASSETS, anAsset => { NATIVE_ASSET_KEY_TO_ASSET_MAP[anAsset.KEY] = a export const spec = { code: BIDDER_CODE, gvlid: GVLID, - supportedMediaTypes: [BANNER, NATIVE], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** * Determines whether or not the given bid request is valid. * @@ -96,18 +135,40 @@ export const spec = { * @return boolean True if this is a valid bid, and false otherwise. */ isBidRequestValid: function (bid) { - // siteId is required + // siteId is required for any type if (bid.params && bid.params.siteId) { // it must be a string if (!isStr(bid.params.siteId)) { _logWarn('siteId is required for bid', bid); return false; } - } else { - return false; + + // video ad validation + if (bid.hasOwnProperty('mediaTypes') && bid.mediaTypes.hasOwnProperty(VIDEO)) { + // bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array + let mediaTypesVideoMimes = deepAccess(bid.mediaTypes, 'video.mimes'); + let paramsVideoMimes = deepAccess(bid, 'params.video.mimes'); + if (_isNonEmptyArray(mediaTypesVideoMimes) === false && _isNonEmptyArray(paramsVideoMimes) === false) { + _logWarn('Error: For video ads, bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array. Call suppressed:', JSON.stringify(bid)); + return false; + } + + if (!bid.mediaTypes[VIDEO].hasOwnProperty('context')) { + _logError(`no context specified in bid. Rejecting bid: `, JSON.stringify(bid)); + return false; + } + + if (bid.mediaTypes[VIDEO].context === 'outstream') { + delete bid.mediaTypes[VIDEO]; + _logWarn(`outstream not currently supported `, JSON.stringify(bid)); + return false; + } + } + + return true; } - return true; + return false; }, /** * Make a server request from the list of BidRequests. @@ -116,6 +177,7 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (validBidRequests, bidderRequest) { + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); var refererInfo; if (bidderRequest && bidderRequest.refererInfo) { refererInfo = bidderRequest.refererInfo; @@ -132,7 +194,7 @@ export const spec = { _parseAdSlot(bid); conf = _handleCustomParams(bid.params, conf); - conf.transactionId = bid.transactionId; + conf.transactionId = bid.ortb2Imp?.ext?.tid; bidCurrency = bid.params.currency || UNDEFINED; bid.params.currency = bidCurrency; @@ -157,16 +219,17 @@ export const spec = { } if (bid.params.isTest) { - payload.test = Number(bid.params.isTest) // should be 1 or 0 + payload.test = Number(bid.params.isTest); // should be 1 or 0 } payload.site.publisher.id = bid.params.siteId.trim(); payload.user.gender = (conf.gender ? conf.gender.trim() : UNDEFINED); payload.user.geo = {}; - payload.user.geo.lat = _parseSlotParam('lat', conf.lat); - payload.user.geo.lon = _parseSlotParam('lon', conf.lon); + // TODO: fix lat and long to only come from ortb2 object so publishers can control precise location + payload.user.geo.lat = _parseSlotParam('lat', 0); + payload.user.geo.lon = _parseSlotParam('lon', 0); payload.user.yob = _parseSlotParam('yob', conf.yob); payload.device.geo = payload.user.geo; - payload.site.page = payload.site.page.trim(); + payload.site.page = payload.site?.page?.trim(); payload.site.domain = _getDomainFromURL(payload.site.page); // add the content object from config in request @@ -180,7 +243,7 @@ export const spec = { } // passing transactionId in source.tid - deepSetValue(payload, 'source.tid', conf.transactionId); + deepSetValue(payload, 'source.tid', bidderRequest?.ortb2?.source?.tid); // schain if (validBidRequests[0].schain) { @@ -203,14 +266,14 @@ export const spec = { deepSetValue(payload, 'regs.coppa', 1); } - var options = {contentType: 'text/plain'} + var options = {contentType: 'text/plain'}; _logInfo('buildRequests payload', payload); _logInfo('buildRequests bidderRequest', bidderRequest); return { method: 'POST', - url: ENDPOINT_URL, + url: _getEndpointURL(bid), data: payload, options: options, bidderRequest: bidderRequest, @@ -231,6 +294,7 @@ export const spec = { // try { if (response.body && response.body.seatbid && isArray(response.body.seatbid)) { + _logInfo('interpretResponse response body', response.body); // Supporting multiple bid responses for same adSize respCur = response.body.cur || respCur; response.body.seatbid.forEach(seatbidder => { @@ -254,10 +318,24 @@ export const spec = { if (parsedRequest.imp && parsedRequest.imp.length > 0) { parsedRequest.imp.forEach(req => { if (bid.impid === req.id) { - _checkMediaType(bid.adm, newBid); + _checkMediaType(bid, newBid); switch (newBid.mediaType) { case BANNER: break; + case VIDEO: + const videoContext = deepAccess(request, 'mediaTypes.video.context'); + switch (videoContext) { + case OUTSTREAM: + // not currently supported + break; + case INSTREAM: + break; + } + newBid.width = bid.hasOwnProperty('w') ? bid.w : req.video.w; + newBid.height = bid.hasOwnProperty('h') ? bid.h : req.video.h; + newBid.vastXml = bid.adm; + newBid.vastUrl = bid.vastUrl; + break; case NATIVE: _parseNativeResponse(bid, newBid); break; @@ -289,20 +367,31 @@ export const spec = { } } -function _checkMediaType(adm, newBid) { - // Create a regex here to check the strings - var admJSON = ''; - if (adm.indexOf('"ver":') >= 0) { - try { - admJSON = JSON.parse(adm.replace(/\\/g, '')); - if (admJSON && admJSON.assets) { - newBid.mediaType = NATIVE; +function _checkMediaType(bid, newBid) { + // Check Various ADM Aspects to Determine Media Type + if (bid.ext && bid.ext['bidtype'] != undefined) { + // this is the most explicity check + newBid.mediaType = MEDIATYPE[bid.ext.bidtype]; + } else { + _logInfo('bid.ext.bidtype does not exist, checking alternatively for mediaType'); + var adm = bid.adm; + var videoRegex = new RegExp(/VAST\s+version/); + + if (adm.indexOf('"ver":') >= 0) { + try { + var admJSON = ''; + admJSON = JSON.parse(adm.replace(/\\/g, '')); + if (admJSON && admJSON.assets) { + newBid.mediaType = NATIVE; + } + } catch (e) { + _logWarn('Error: Cannot parse native reponse for ad response: ', adm); } - } catch (e) { - _logWarn('Error: Cannot parse native reponse for ad response: ' + adm); + } else if (videoRegex.test(adm)) { + newBid.mediaType = VIDEO; + } else { + newBid.mediaType = BANNER; } - } else { - newBid.mediaType = BANNER; } } @@ -416,7 +505,8 @@ function _createOrtbTemplate(conf) { dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, h: screen.height, w: screen.width, - language: navigator.language + language: navigator.language, + devicetype: _getDeviceType() }, user: {}, ext: { @@ -428,6 +518,7 @@ function _createOrtbTemplate(conf) { function _createImpressionObject(bid, conf) { var impObj = {}; var bannerObj; + var videoObj; var nativeObj = {}; var mediaTypes = ''; @@ -436,7 +527,10 @@ function _createImpressionObject(bid, conf) { tagid: bid.params.adUnit || undefined, bidfloor: _parseSlotParam('bidFloor', bid.params.bidFloor), // capitalization dicated by 3.2.4 spec secure: 1, - bidfloorcur: bid.params.currency ? _parseSlotParam('currency', bid.params.currency) : DEFAULT_CURRENCY // capitalization dicated by 3.2.4 spec + bidfloorcur: bid.params.currency ? _parseSlotParam('currency', bid.params.currency) : DEFAULT_CURRENCY, // capitalization dicated by 3.2.4 spec + ext: { + tid: bid.ortb2Imp?.ext?.tid || '' + } }; if (bid.hasOwnProperty('mediaTypes')) { @@ -456,16 +550,23 @@ function _createImpressionObject(bid, conf) { _logWarn('Error: Error in Native adunit ' + bid.params.adUnit + '. Ignoring the adunit. Refer to ' + PREBID_NATIVE_HELP_LINK + ' for more details.'); } break; + case VIDEO: + videoObj = _createVideoRequest(bid); + if (videoObj !== UNDEFINED) { + impObj.video = videoObj; + } + break; } } } else { - _logWarn('MediaTypes are Required for all Adunit Configs', bid) + _logWarn('MediaTypes are Required for all Adunit Configs', bid); } _addFloorFromFloorModule(impObj, bid); return impObj.hasOwnProperty(BANNER) || - impObj.hasOwnProperty(NATIVE) ? impObj : UNDEFINED; + impObj.hasOwnProperty(NATIVE) || + impObj.hasOwnProperty(VIDEO) ? impObj : UNDEFINED; } function _parseSlotParam(paramName, paramValue) { @@ -489,15 +590,19 @@ function _parseSlotParam(paramName, paramValue) { } function _parseAdSlot(bid) { - _logInfo('parseAdSlot bid', bid) - bid.params.adUnit = ''; + _logInfo('parseAdSlot bid', bid); + if (bid.adUnitCode) { + bid.params.adUnit = bid.adUnitCode; + } else { + bid.params.adUnit = ''; + } bid.params.width = 0; bid.params.height = 0; bid.params.adSlot = _cleanSlotName(bid.params.adSlot); if (bid.hasOwnProperty('mediaTypes')) { if (bid.mediaTypes.hasOwnProperty(BANNER) && - bid.mediaTypes.banner.hasOwnProperty('sizes')) { // if its a banner, has mediaTypes and sizes + bid.mediaTypes.banner.hasOwnProperty('sizes')) { // if its a banner, has mediaTypes and sizes var i = 0; var sizeArray = []; for (;i < bid.mediaTypes.banner.sizes.length; i++) { @@ -515,7 +620,7 @@ function _parseAdSlot(bid) { } } } else { - _logWarn('MediaTypes are Required for all Adunit Configs', bid) + _logWarn('MediaTypes are Required for all Adunit Configs', bid); } } @@ -528,8 +633,8 @@ function _cleanSlotName(slotName) { function _initConf(refererInfo) { return { - pageURL: (refererInfo && refererInfo.referer) ? refererInfo.referer : window.location.href, - refURL: window.document.referrer + pageURL: refererInfo?.page, + refURL: refererInfo?.ref }; } @@ -551,7 +656,7 @@ function _addFloorFromFloorModule(impObj, bid) { // get lowest floor from floorModule if (typeof bid.getFloor === 'function' && !config.getConfig('pubwise.disableFloors')) { - [BANNER, NATIVE].forEach(mediaType => { + [BANNER, VIDEO, NATIVE].forEach(mediaType => { if (impObj.hasOwnProperty(mediaType)) { let floorInfo = bid.getFloor({ currency: impObj.bidFloorCur, mediaType: mediaType, size: '*' }); if (typeof floorInfo === 'object' && floorInfo.currency === impObj.bidFloorCur && !isNaN(parseInt(floorInfo.floor))) { @@ -739,28 +844,162 @@ function _createBannerRequest(bid) { _logWarn('Error: mediaTypes.banner.size missing for adunit: ' + bid.params.adUnit + '. Ignoring the banner impression in the adunit.'); bannerObj = UNDEFINED; } + return bannerObj; } // various error levels are not always used // eslint-disable-next-line no-unused-vars function _logMessage(textValue, objectValue) { - logMessage('PubWise: ' + textValue, objectValue); + objectValue = objectValue || ''; + logMessage(LOG_PREFIX + textValue, objectValue); } // eslint-disable-next-line no-unused-vars function _logInfo(textValue, objectValue) { - logInfo('PubWise: ' + textValue, objectValue); + objectValue = objectValue || ''; + logInfo(LOG_PREFIX + textValue, objectValue); } // eslint-disable-next-line no-unused-vars function _logWarn(textValue, objectValue) { - logWarn('PubWise: ' + textValue, objectValue); + objectValue = objectValue || ''; + logWarn(LOG_PREFIX + textValue, objectValue); } // eslint-disable-next-line no-unused-vars function _logError(textValue, objectValue) { - logError('PubWise: ' + textValue, objectValue); + objectValue = objectValue || ''; + logError(LOG_PREFIX + textValue, objectValue); +} + +function _checkVideoPlacement(videoData, adUnitCode) { + // Check for video.placement property. If property is missing display log message. + if (!deepAccess(videoData, 'placement')) { + _logWarn(`${MSG_VIDEO_PLACEMENT_MISSING} for ${adUnitCode}`, adUnitCode); + }; +} + +function _createVideoRequest(bid) { + var videoData = mergeDeep(deepAccess(bid.mediaTypes, 'video'), bid.params.video); + var videoObj; + + if (videoData !== UNDEFINED) { + videoObj = {}; + _checkVideoPlacement(videoData, bid.adUnitCode); + for (var key in VIDEO_CUSTOM_PARAMS) { + if (videoData.hasOwnProperty(key)) { + videoObj[key] = _checkParamDataType(key, videoData[key], VIDEO_CUSTOM_PARAMS[key]); + } + } + // read playersize and assign to h and w. + if (isArray(bid.mediaTypes.video.playerSize[0])) { + videoObj.w = parseInt(bid.mediaTypes.video.playerSize[0][0], 10); + videoObj.h = parseInt(bid.mediaTypes.video.playerSize[0][1], 10); + } else if (isNumber(bid.mediaTypes.video.playerSize[0])) { + videoObj.w = parseInt(bid.mediaTypes.video.playerSize[0], 10); + videoObj.h = parseInt(bid.mediaTypes.video.playerSize[1], 10); + } + } else { + videoObj = UNDEFINED; + _logWarn('Error: Video config params missing for adunit: ' + bid.params.adUnit + ' with mediaType set as video. Ignoring video impression in the adunit.', bid.params); + } + return videoObj; +} + +/** + * Determines if the array has values + * + * @param {object} test + * @returns {boolean} + */ +function _isNonEmptyArray(test) { + if (isArray(test) === true) { + if (test.length > 0) { + return true; + } + } + return false; +} + +/** + * Returns the overridden bid endpoint_url if it is set, primarily used for testing + * + * @param {object} bid the current bid + * @returns + */ +function _getEndpointURL(bid) { + if (!isEmptyStr(bid?.params?.endpoint_url) && bid?.params?.endpoint_url != UNDEFINED) { + return bid.params.endpoint_url; + } + + return ENDPOINT_URL; +} + +/** + * + * @param {object} key + * @param {object}} value + * @param {object} datatype + * @returns + */ +function _checkParamDataType(key, value, datatype) { + var errMsg = 'Ignoring param key: ' + key + ', expects ' + datatype + ', found ' + typeof value; + var functionToExecute; + switch (datatype) { + case DATA_TYPES.BOOLEAN: + functionToExecute = isBoolean; + break; + case DATA_TYPES.NUMBER: + functionToExecute = isNumber; + break; + case DATA_TYPES.STRING: + functionToExecute = isStr; + break; + case DATA_TYPES.ARRAY: + functionToExecute = isArray; + break; + } + if (functionToExecute(value)) { + return value; + } + _logWarn(errMsg, key); + return UNDEFINED; +} + +function _isMobile() { + if (navigator.userAgentData && navigator.userAgentData.mobile) { + return true; + } else { + return (/(mobi)/i).test(navigator.userAgent); + } +} + +function _isConnectedTV() { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); +} + +function _isTablet() { + return (/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())); +} + +/** + * Very high level device detection, order matters + */ +function _getDeviceType() { + if (_isTablet()) { + return 5; + } + + if (_isMobile()) { + return 4; + } + + if (_isConnectedTV()) { + return 3; + } + + return 2; } // function _decorateLog() { @@ -770,6 +1009,7 @@ function _logError(textValue, objectValue) { // these are exported only for testing so maintaining the JS convention of _ to indicate the intent export { + _checkVideoPlacement, _checkMediaType, _parseAdSlot } diff --git a/modules/pubxBidAdapter.js b/modules/pubxBidAdapter.js index 18d2bb11404..ee28d549475 100644 --- a/modules/pubxBidAdapter.js +++ b/modules/pubxBidAdapter.js @@ -1,4 +1,4 @@ -import { deepSetValue } from '../src/utils.js'; +import { deepSetValue, deepAccess } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'pubx'; @@ -16,8 +16,11 @@ export const spec = { const bidId = bidRequest.bidId; const params = bidRequest.params; const sid = params.sid; + const pageUrl = deepAccess(bidRequest, 'ortb2.site.page').replace(/\?.*$/, ''); + const pageEnc = encodeURIComponent(pageUrl); const payload = { - sid: sid + sid: sid, + pu: pageEnc, }; return { id: bidId, @@ -76,7 +79,7 @@ export const spec = { } else { kwString = kwContents; } - kwEnc = encodeURIComponent(kwString) + kwEnc = encodeURIComponent(kwString); } else { } if (titleContent) { if (titleContent.length > 30) { diff --git a/modules/pubxaiAnalyticsAdapter.js b/modules/pubxaiAnalyticsAdapter.js index 669bd062206..e97e5505768 100644 --- a/modules/pubxaiAnalyticsAdapter.js +++ b/modules/pubxaiAnalyticsAdapter.js @@ -1,12 +1,14 @@ -import { deepAccess, getGptSlotInfoForAdUnitCode, parseSizesInput, getWindowLocation, buildUrl } from '../src/utils.js'; +import { deepAccess, parseSizesInput, getWindowLocation, buildUrl } from '../src/utils.js'; import { ajax } from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const emptyUrl = ''; const analyticsType = 'endpoint'; -const pubxaiAnalyticsVersion = 'v1.1.0'; +const pubxaiAnalyticsVersion = 'v1.2.0'; const defaultHost = 'api.pbxai.com'; const auctionPath = '/analytics/auction'; const winningBidPath = '/analytics/bidwon'; @@ -91,7 +93,12 @@ function mapBidResponse(bidResponse, status) { } else { Object.assign(bid, { bidId: bidResponse.requestId, - floorProvider: events.floorDetail ? events.floorDetail.floorProvider : null, + floorProvider: events.floorDetail?.floorProvider || null, + floorFetchStatus: events.floorDetail?.fetchStatus || null, + floorLocation: events.floorDetail?.location || null, + floorModelVersion: events.floorDetail?.modelVersion || null, + floorSkipRate: events.floorDetail?.skipRate || 0, + isFloorSkipped: events.floorDetail?.skipped || false, isWinningBid: true, placementId: bidResponse.params ? deepAccess(bidResponse, 'params.0.placementId') : null, renderedSize: bidResponse.size, @@ -135,7 +142,7 @@ export function getOS() { // add sampling rate pubxaiAnalyticsAdapter.shouldFireEventRequest = function (samplingRate = 1) { return (Math.floor((Math.random() * samplingRate + 1)) === parseInt(samplingRate)); -} +}; function send(data, status) { if (pubxaiAnalyticsAdapter.shouldFireEventRequest(initOptions.samplingRate)) { @@ -149,11 +156,11 @@ function send(data, status) { search: location.search }); if (typeof data !== 'undefined' && typeof data.auctionInit !== 'undefined') { - data.pageDetail.adUnitCount = data.auctionInit.adUnitCodes ? data.auctionInit.adUnitCodes.length : null; + data.pageDetail.adUnits = data.auctionInit.adUnitCodes; data.initOptions.auctionId = data.auctionInit.auctionId; delete data.auctionInit; - data.pmcDetail = {} + data.pmcDetail = {}; Object.assign(data.pmcDetail, { bidDensity: storage ? storage.getItem('pbx:dpbid') : null, maxBid: storage ? storage.getItem('pbx:mxbid') : null, @@ -175,7 +182,7 @@ function send(data, status) { search: { auctionTimestamp: auctionTimestamp, pubxaiAnalyticsVersion: pubxaiAnalyticsVersion, - prebidVersion: $$PREBID_GLOBAL$$.version + prebidVersion: getGlobal().version } }); if (status == 'bidwon') { diff --git a/modules/pulsepointAnalyticsAdapter.js b/modules/pulsepointAnalyticsAdapter.js index 375a817f257..999ae3dd3de 100644 --- a/modules/pulsepointAnalyticsAdapter.js +++ b/modules/pulsepointAnalyticsAdapter.js @@ -2,7 +2,7 @@ * pulsepoint.js - Analytics Adapter for PulsePoint */ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; var pulsepointAdapter = adapter({ diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index c0280e944ae..516254b358b 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -1,20 +1,11 @@ -/* eslint dot-notation:0, quote-props:0 */ -import { convertTypes, deepAccess, isArray, logError, isFn } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { Renderer } from '../src/Renderer.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import {isArray} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; -const NATIVE_DEFAULTS = { - TITLE_LEN: 100, - DESCR_LEN: 200, - SPONSORED_BY_LEN: 50, - IMG_MIN: 150, - ICON_MIN: 50, -}; - -const DEFAULT_BID_TTL = 20; const DEFAULT_CURRENCY = 'USD'; -const DEFAULT_NET_REVENUE = true; -const KNOWN_PARAMS = ['cp', 'ct', 'cf', 'video', 'battr', 'bcat', 'badv', 'bidfloor']; +const KNOWN_PARAMS = ['cp', 'ct', 'cf', 'battr', 'deals']; +const DEFAULT_TMAX = 500; /** * PulsePoint Bid Adapter. @@ -39,29 +30,21 @@ export const spec = { ), buildRequests: (bidRequests, bidderRequest) => { - const request = { - id: bidRequests[0].bidderRequestId, - imp: bidRequests.map(slot => impression(slot)), - site: site(bidRequests, bidderRequest), - app: app(bidRequests), - device: device(), - bcat: bidRequests[0].params.bcat, - badv: bidRequests[0].params.badv, - user: user(bidRequests[0], bidderRequest), - regs: regs(bidderRequest), - source: source(bidRequests[0].schain), - }; + const data = converter.toORTB({bidRequests, bidderRequest}); return { method: 'POST', url: 'https://bid.contextweb.com/header/ortb?src=prebid', - data: request, + data, bidderRequest }; }, - interpretResponse: (response, request) => ( - bidResponseAvailable(request, response) - ), + interpretResponse: (response, request) => { + if (response.body) { + return converter.fromORTB({response: response.body, request: request.data}).bids; + } + return []; + }, getUserSyncs: syncOptions => { if (syncOptions.iframeEnabled) { @@ -76,7 +59,7 @@ export const spec = { }]; } }, - transformBidParams: function(params, isOpenRtb) { + transformBidParams: function(params) { return convertTypes({ 'cf': 'string', 'cp': 'number', @@ -85,127 +68,66 @@ export const spec = { } }; -/** - * Callback for bids, after the call to PulsePoint completes. - */ -function bidResponseAvailable(request, response) { - const idToImpMap = {}; - const idToBidMap = {}; - const idToSlotConfig = {}; - const bidResponse = response.body - // extract the request bids and the response bids, keyed by impr-id - const ortbRequest = request.data; - ortbRequest.imp.forEach(imp => { - idToImpMap[imp.id] = imp; - }); - if (bidResponse) { - bidResponse.seatbid.forEach(seatBid => seatBid.bid.forEach(bid => { - idToBidMap[bid.impid] = bid; - })); - } - if (request.bidderRequest && request.bidderRequest.bids) { - request.bidderRequest.bids.forEach(bid => { - idToSlotConfig[bid.bidId] = bid; - }); - } - const bids = []; - Object.keys(idToImpMap).forEach(id => { - if (idToBidMap[id]) { - const bid = { - requestId: id, - cpm: idToBidMap[id].price, - creative_id: idToBidMap[id].crid, - creativeId: idToBidMap[id].crid, - adId: id, - ttl: idToBidMap[id].exp || DEFAULT_BID_TTL, - netRevenue: DEFAULT_NET_REVENUE, - currency: bidResponse.cur || DEFAULT_CURRENCY, - meta: { advertiserDomains: idToBidMap[id].adomain || [] } - }; - if (idToImpMap[id].video) { - // for outstream, a renderer is specified - if (idToSlotConfig[id] && deepAccess(idToSlotConfig[id], 'mediaTypes.video.context') === 'outstream') { - bid.renderer = outstreamRenderer(deepAccess(idToSlotConfig[id], 'renderer.options'), deepAccess(idToBidMap[id], 'ext.outstream')); +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 300, + currency: 'USD' + }, + + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + // tagid + imp.tagid = bidRequest.params.ct.toString(); + // unknown params + const unknownParams = slotUnknownParams(bidRequest); + if (imp.ext || unknownParams) { + imp.ext = Object.assign({}, imp.ext, unknownParams); + } + // battr + if (bidRequest.params.battr) { + ['banner', 'video', 'audio', 'native'].forEach(k => { + if (imp[k]) { + imp[k].battr = bidRequest.params.battr; } - bid.vastXml = idToBidMap[id].adm; - bid.mediaType = 'video'; - bid.width = idToBidMap[id].w; - bid.height = idToBidMap[id].h; - } else if (idToImpMap[id].banner) { - bid.ad = idToBidMap[id].adm; - bid.width = idToBidMap[id].w || idToImpMap[id].banner.w; - bid.height = idToBidMap[id].h || idToImpMap[id].banner.h; - } else if (idToImpMap[id]['native']) { - bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]); - bid.mediaType = 'native'; - } - bids.push(bid); + }); } - }); - return bids; -} - -/** - * Produces an OpenRTBImpression from a slot config. - */ -function impression(slot) { - return { - id: slot.bidId, - banner: banner(slot), - 'native': nativeImpression(slot), - tagid: slot.params.ct.toString(), - video: video(slot), - bidfloor: bidFloor(slot), - ext: ext(slot), - }; -} - -/** - * Produces an OpenRTB Banner object for the slot given. - */ -function banner(slot) { - const sizes = parseSizes(slot); - const size = adSize(slot, sizes); - return (slot.mediaTypes && slot.mediaTypes.banner) ? { - w: size[0], - h: size[1], - battr: slot.params.battr, - format: sizes - } : null; -} + // deals + if (bidRequest.params.deals && isArray(bidRequest.params.deals)) { + imp.pmp = { + private_auction: 0, + deals: bidRequest.params.deals + }; + } + return imp; + }, -/** - * Produce openrtb format objects based on the sizes configured for the slot. - */ -function parseSizes(slot) { - const sizes = deepAccess(slot, 'mediaTypes.banner.sizes'); - if (sizes && isArray(sizes)) { - return sizes.filter(sz => isArray(sz) && sz.length === 2).map(sz => ({ - w: sz[0], - h: sz[1] - })); - } - return null; -} + request(buildRequest, imps, bidderRequest, context) { + const request = buildRequest(imps, bidderRequest, context); + // publisher id + const siteOrApp = request.site || request.app; + const pubId = context.bidRequests && context.bidRequests.length > 0 ? context.bidRequests[0].params.cp : '0'; + if (siteOrApp) { + siteOrApp.publisher = Object.assign({}, siteOrApp.publisher, { + id: pubId.toString() + }); + } + // tmax + request.tmax = request.tmax || DEFAULT_TMAX; + return request; + }, -/** - * Produces an OpenRTB Video object for the slot given - */ -function video(slot) { - if (slot.params.video) { - return Object.assign({}, - slot.params.video, // previously supported as bidder param - slot.mediaTypes && slot.mediaTypes.video ? slot.mediaTypes.video : {}, // params on mediaTypes.video - {battr: slot.params.battr} - ); - } - return null; -} + bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); + bidResponse.cur = bidResponse.cur || DEFAULT_CURRENCY; + return bidResponse; + }, +}); /** * Unknown params are captured and sent on ext */ -function ext(slot) { +function slotUnknownParams(slot) { const ext = {}; const knownParamsMap = {}; KNOWN_PARAMS.forEach(value => knownParamsMap[value] = 1); @@ -217,285 +139,4 @@ function ext(slot) { return Object.keys(ext).length > 0 ? { prebid: ext } : null; } -/** - * Sets up the renderer on the bid, for outstream bid responses. - */ -function outstreamRenderer(rendererOptions, outstreamExtOptions) { - const renderer = Renderer.install({ - url: outstreamExtOptions.rendererUrl, - config: { - defaultOptions: outstreamExtOptions.config, - rendererOptions, - type: outstreamExtOptions.type - }, - loaded: false, - }); - renderer.setRender((bid) => { - bid.renderer.push(() => { - const config = bid.renderer.getConfig(); - new window.PulsePointOutstreamRenderer().render({ - adUnitCode: bid.adUnitCode, - vastXml: bid.vastXml, - type: config.type, - defaultOptions: config.defaultOptions, - rendererOptions - }); - }); - }); - return renderer; -} - -/** - * Produces an OpenRTB Native object for the slot given. - */ -function nativeImpression(slot) { - if (slot.nativeParams) { - const assets = []; - addAsset(assets, titleAsset(assets.length + 1, slot.nativeParams.title, NATIVE_DEFAULTS.TITLE_LEN)); - addAsset(assets, dataAsset(assets.length + 1, slot.nativeParams.body, 2, NATIVE_DEFAULTS.DESCR_LEN)); - addAsset(assets, dataAsset(assets.length + 1, slot.nativeParams.sponsoredBy, 1, NATIVE_DEFAULTS.SPONSORED_BY_LEN)); - addAsset(assets, imageAsset(assets.length + 1, slot.nativeParams.icon, 1, NATIVE_DEFAULTS.ICON_MIN, NATIVE_DEFAULTS.ICON_MIN)); - addAsset(assets, imageAsset(assets.length + 1, slot.nativeParams.image, 3, NATIVE_DEFAULTS.IMG_MIN, NATIVE_DEFAULTS.IMG_MIN)); - return { - request: JSON.stringify({ assets }), - ver: '1.1', - battr: slot.params.battr, - }; - } - return null; -} - -/** - * Helper method to add an asset to the assets list. - */ -function addAsset(assets, asset) { - if (asset) { - assets.push(asset); - } -} - -/** - * Produces a Native Title asset for the configuration given. - */ -function titleAsset(id, params, defaultLen) { - if (params) { - return { - id, - required: params.required ? 1 : 0, - title: { - len: params.len || defaultLen, - }, - }; - } - return null; -} - -/** - * Produces a Native Image asset for the configuration given. - */ -function imageAsset(id, params, type, defaultMinWidth, defaultMinHeight) { - return params ? { - id, - required: params.required ? 1 : 0, - img: { - type, - wmin: params.wmin || defaultMinWidth, - hmin: params.hmin || defaultMinHeight, - } - } : null; -} - -/** - * Produces a Native Data asset for the configuration given. - */ -function dataAsset(id, params, type, defaultLen) { - return params ? { - id, - required: params.required ? 1 : 0, - data: { - type, - len: params.len || defaultLen, - } - } : null; -} - -/** - * Produces an OpenRTB site object. - */ -function site(bidRequests, bidderRequest) { - const pubId = bidRequests && bidRequests.length > 0 ? bidRequests[0].params.cp : '0'; - const appParams = bidRequests[0].params.app; - if (!appParams) { - return { - publisher: { - id: pubId.toString(), - }, - ref: referrer(), - page: bidderRequest && bidderRequest.refererInfo ? bidderRequest.refererInfo.referer : '', - } - } - return null; -} - -/** - * Produces an OpenRTB App object. - */ -function app(bidderRequest) { - const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0'; - const appParams = bidderRequest[0].params.app; - if (appParams) { - return { - publisher: { - id: pubId.toString(), - }, - bundle: appParams.bundle, - storeurl: appParams.storeUrl, - domain: appParams.domain, - } - } - return null; -} - -/** - * Attempts to capture the referrer url. - */ -function referrer() { - try { - return window.top.document.referrer; - } catch (e) { - return document.referrer; - } -} - -/** - * Produces an OpenRTB Device object. - */ -function device() { - return { - ua: navigator.userAgent, - language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), - }; -} - -/** - * Safely parses the input given. Returns null on - * parsing failure. - */ -function parse(rawResponse) { - try { - if (rawResponse) { - return JSON.parse(rawResponse); - } - } catch (ex) { - logError('pulsepointLite.safeParse', 'ERROR', ex); - } - return null; -} - -/** - * Determines the AdSize for the slot. - */ -function adSize(slot, sizes) { - if (slot.params.cf) { - const size = slot.params.cf.toUpperCase().split('X'); - const width = parseInt(slot.params.cw || size[0], 10); - const height = parseInt(slot.params.ch || size[1], 10); - return [width, height]; - } else if (sizes && sizes.length > 0) { - return [sizes[0].w, sizes[0].h]; - } - return [1, 1]; -} - -/** - * Handles the user level attributes and produces - * an openrtb User object. - */ -function user(bidRequest, bidderRequest) { - var ext = {}; - if (bidderRequest) { - if (bidderRequest.gdprConsent) { - ext.consent = bidderRequest.gdprConsent.consentString; - } - } - if (bidRequest) { - let eids = bidRequest.userIdAsEids; - if (eids) { - ext.eids = eids; - } - } - return { ext }; -} - -/** - * Produces the regulations ortb object - */ -function regs(bidderRequest) { - if (bidderRequest.gdprConsent || bidderRequest.uspConsent) { - var ext = {}; - // GDPR applies attribute (actual consent value is in user object) - if (bidderRequest.gdprConsent) { - ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; - } - // CCPA - if (bidderRequest.uspConsent) { - ext.us_privacy = bidderRequest.uspConsent; - } - return { ext }; - } - return null; -} - -/** - * Creates source object with supply chain - */ -function source(schain) { - if (schain) { - return { - ext: { schain } - }; - } - return null; -} - -/** - * Parses the native response from the Bid given. - */ -function nativeResponse(imp, bid) { - if (imp['native']) { - const nativeAd = parse(bid.adm); - const keys = {}; - if (nativeAd && nativeAd['native'] && nativeAd['native'].assets) { - nativeAd['native'].assets.forEach(asset => { - keys.title = asset.title ? asset.title.text : keys.title; - keys.body = asset.data && asset.data.type === 2 ? asset.data.value : keys.body; - keys.sponsoredBy = asset.data && asset.data.type === 1 ? asset.data.value : keys.sponsoredBy; - keys.image = asset.img && asset.img.type === 3 ? asset.img.url : keys.image; - keys.icon = asset.img && asset.img.type === 1 ? asset.img.url : keys.icon; - }); - if (nativeAd['native'].link) { - keys.clickUrl = encodeURIComponent(nativeAd['native'].link.url); - } - keys.impressionTrackers = nativeAd['native'].imptrackers; - return keys; - } - } - return null; -} - -function bidFloor(slot) { - let floor = slot.params.bidfloor; - if (isFn(slot.getFloor)) { - const floorData = slot.getFloor({ - mediaType: slot.mediaTypes.banner ? 'banner' : slot.mediaTypes.video ? 'video' : 'Native', - size: '*', - currency: DEFAULT_CURRENCY, - }); - if (floorData && floorData.floor) { - floor = floorData.floor; - } - } - return floor; -} - registerBidder(spec); diff --git a/modules/pulsepointBidAdapter.md b/modules/pulsepointBidAdapter.md index 7f4b7e6b611..899c277f92f 100644 --- a/modules/pulsepointBidAdapter.md +++ b/modules/pulsepointBidAdapter.md @@ -2,7 +2,7 @@ **Module Name**: PulsePoint Bidder Adapter **Module Type**: Bidder Adapter -**Maintainer**: ExchangeTeam@pulsepoint.com +**Maintainer**: ExchangeTeam@pulsepoint.com # Description @@ -18,55 +18,49 @@ Please use ```pulsepoint``` as the bidder code. sizes: [[300, 250]], bids: [{ bidder: 'pulsepoint', - params: { - cf: '300X250', + params: { cp: 512379, ct: 486653 } }] },{ - code: 'native-ad-div', - sizes: [[1, 1]], - nativeParams: { - title: { required: true, len: 75 }, - image: { required: true }, - body: { len: 200 }, - sponsoredBy: { len: 20 } - }, - bids: [{ - bidder: 'pulsepoint', - params: { - cp: 512379, - ct: 505642 - } - }] - },{ - code: 'outstream-div', - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'outstream', - h: 300, - w: 400, - minduration: 1, - maxduration: 210, - linearity: 1, - mimes: ["video/mp4", "video/ogg", "video/webm"], - pos: 3 - } - }, - bids: [{ - bidder: 'pulsepoint', - params: { - cp: 512379, - ct: 505642 - } - }], - renderer: { - options: { - text: "PulsePoint Outstream" - } - } + code: 'native-1-slot', + mediaTypes: { + native: { + ortb: { + assets: [{ + id: 1, + required: 1, + img: { + type: 3, + w: 150, + h: 50, + } + }, + { + id: 2, + required: 1, + title: { + len: 80 + } + }, + { + id: 3, + required: 1, + data: { + type: 1 + } + }] + } + } + }, + bids: [{ + bidder: 'pulsepoint', + params: { + cp: 512379, + ct: 694973 + } + }] },{ code: 'instream', mediaTypes: { diff --git a/modules/pxyzBidAdapter.js b/modules/pxyzBidAdapter.js index e144eb84a01..1ab432496a3 100644 --- a/modules/pxyzBidAdapter.js +++ b/modules/pxyzBidAdapter.js @@ -1,6 +1,6 @@ -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { BANNER } from '../src/mediaTypes.js'; -import { logInfo, logError, isArray } from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {isArray, logError, logInfo} from '../src/utils.js'; const BIDDER_CODE = 'pxyz'; const URL = 'https://ads.playground.xyz/host-config/prebid?v=2'; @@ -32,7 +32,7 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (bidRequests, bidderRequest) { - const referer = bidderRequest.refererInfo.referer; + const referer = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; const parts = referer.split('/'); let protocol, hostname; @@ -42,7 +42,7 @@ export const spec = { } const payload = { - id: bidRequests[0].auctionId, + id: bidderRequest.bidderRequestId, site: { domain: protocol + '//' + hostname, name: hostname, diff --git a/modules/quantcastBidAdapter.js b/modules/quantcastBidAdapter.js index 449c7d12d6f..2c721a61616 100644 --- a/modules/quantcastBidAdapter.js +++ b/modules/quantcastBidAdapter.js @@ -4,6 +4,7 @@ import {config} from '../src/config.js'; import {getStorageManager} from '../src/storageManager.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {find} from '../src/polyfill.js'; +import {parseDomain} from '../src/refererDetection.js'; const BIDDER_CODE = 'quantcast'; const DEFAULT_BID_FLOOR = 0.0000000001; @@ -21,7 +22,7 @@ export const QUANTCAST_PROTOCOL = 'https'; export const QUANTCAST_PORT = '8443'; export const QUANTCAST_FPA = '__qca'; -export const storage = getStorageManager({gvlid: QUANTCAST_VENDOR_ID, bidderCode: BIDDER_CODE}); +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); function makeVideoImp(bid) { const videoInMediaType = deepAccess(bid, 'mediaTypes.video') || {}; @@ -74,21 +75,7 @@ function makeBannerImp(bid) { }; } -function getDomain(url) { - if (!url) { - return url; - } - return url.replace('http://', '').replace('https://', '').replace('www.', '').split(/[/?#]/)[0]; -} - -function checkTCFv1(vendorData) { - let vendorConsent = vendorData.vendorConsents && vendorData.vendorConsents[QUANTCAST_VENDOR_ID]; - let purposeConsent = vendorData.purposeConsents && vendorData.purposeConsents[PURPOSE_DATA_COLLECT]; - - return !!(vendorConsent && purposeConsent); -} - -function checkTCFv2(tcData) { +function checkTCF(tcData) { let restrictions = tcData.publisher ? tcData.publisher.restrictions : {}; let qcRestriction = restrictions && restrictions[PURPOSE_DATA_COLLECT] ? restrictions[PURPOSE_DATA_COLLECT][QUANTCAST_VENDOR_ID] @@ -144,19 +131,15 @@ export const spec = { const bids = bidRequests || []; const gdprConsent = deepAccess(bidderRequest, 'gdprConsent') || {}; const uspConsent = deepAccess(bidderRequest, 'uspConsent'); - const referrer = deepAccess(bidderRequest, 'refererInfo.referer'); - const page = deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || config.getConfig('pageUrl') || deepAccess(window, 'location.href'); - const domain = getDomain(page); + const referrer = deepAccess(bidderRequest, 'refererInfo.ref'); + const page = deepAccess(bidderRequest, 'refererInfo.page') || deepAccess(window, 'location.href'); + const domain = parseDomain(page, {noLeadingWww: true}); // Check for GDPR consent for purpose 1, and drop request if consent has not been given // Remaining consent checks are performed server-side. if (gdprConsent.gdprApplies) { if (gdprConsent.vendorData) { - if (gdprConsent.apiVersion === 1 && !checkTCFv1(gdprConsent.vendorData)) { - logInfo(`${BIDDER_CODE}: No purpose 1 consent for TCF v1`); - return; - } - if (gdprConsent.apiVersion === 2 && !checkTCFv2(gdprConsent.vendorData)) { + if (!checkTCF(gdprConsent.vendorData)) { logInfo(`${BIDDER_CODE}: No purpose 1 consent for TCF v2`); return; } diff --git a/modules/quantcastIdSystem.js b/modules/quantcastIdSystem.js index 7d82be884da..2faf638fc0b 100644 --- a/modules/quantcastIdSystem.js +++ b/modules/quantcastIdSystem.js @@ -6,9 +6,10 @@ */ import {submodule} from '../src/hook.js' -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; import { triggerPixel, logInfo } from '../src/utils.js'; import { uspDataHandler, coppaDataHandler, gdprDataHandler } from '../src/adapterManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const QUANTCAST_FPA = '__qca'; const DEFAULT_COOKIE_EXP_DAYS = 392; // (13 months - 2 days) @@ -23,8 +24,9 @@ const QC_TCF_CONSENT_FIRST_PURPOSES = [PURPOSE_DATA_COLLECT]; const QC_TCF_CONSENT_ONLY_PUPROSES = [PURPOSE_DATA_COLLECT]; const GDPR_PRIVACY_STRING = gdprDataHandler.getConsentData(); const US_PRIVACY_STRING = uspDataHandler.getConsentData(); +const MODULE_NAME = 'quantcastId'; -export const storage = getStorageManager(); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); export function firePixel(clientId, cookieExpDays = DEFAULT_COOKIE_EXP_DAYS) { // check for presence of Quantcast Measure tag _qevent obj and publisher provided clientID @@ -74,13 +76,7 @@ export function hasGDPRConsent(gdprConsent) { if (!gdprConsent.vendorData) { return false; } - if (gdprConsent.apiVersion === 1) { - // We are not supporting TCF v1 - return false; - } - if (gdprConsent.apiVersion === 2) { - return checkTCFv2(gdprConsent.vendorData); - } + return checkTCFv2(gdprConsent.vendorData); } return true; } @@ -166,7 +162,7 @@ export const quantcastIdSubmodule = { * used to link submodule with config * @type {string} */ - name: 'quantcastId', + name: MODULE_NAME, /** * Vendor id of Quantcast @@ -217,7 +213,13 @@ export const quantcastIdSubmodule = { }); } - return { id: fpa ? { quantcastId: fpa } : undefined } + return { id: fpa ? { quantcastId: fpa } : undefined }; + }, + eids: { + 'quantcastId': { + source: 'quantcast.com', + atype: 1 + }, } }; diff --git a/modules/qwarryBidAdapter.js b/modules/qwarryBidAdapter.js index c9a86f73910..4b3e8fa8a19 100644 --- a/modules/qwarryBidAdapter.js +++ b/modules/qwarryBidAdapter.js @@ -28,7 +28,7 @@ export const spec = { let payload = { requestId: bidderRequest.bidderRequestId, bids, - referer: bidderRequest.refererInfo.referer, + referer: bidderRequest.refererInfo.page, schain: validBidRequests[0].schain } diff --git a/modules/radsBidAdapter.js b/modules/radsBidAdapter.js index fee5daa3fb4..ae16bcf9d83 100644 --- a/modules/radsBidAdapter.js +++ b/modules/radsBidAdapter.js @@ -1,7 +1,6 @@ -import { deepAccess } from '../src/utils.js'; -import {config} from '../src/config.js'; +import {deepAccess} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; const BIDDER_CODE = 'rads'; const ENDPOINT_URL = 'https://rads.recognified.net/md.request.php'; @@ -23,7 +22,7 @@ export const spec = { const placementId = params.placement; const rnd = Math.floor(Math.random() * 99999999999); - const referrer = encodeURIComponent(bidderRequest.refererInfo.referer); + const referrer = encodeURIComponent(bidderRequest.refererInfo.page); const bidId = bidRequest.bidId; const isDev = params.devMode || false; @@ -65,7 +64,7 @@ export const spec = { method: 'GET', url: endpoint, data: objectToQueryString(payload), - } + }; }); }, interpretResponse: function(serverResponse, bidRequest) { @@ -86,7 +85,7 @@ export const spec = { dealId: dealId, currency: currency, netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), + ttl: 60, meta: { advertiserDomains: response.adomain || [] } @@ -184,7 +183,7 @@ function prepareExtraParams(params, payload, bidderRequest, bidRequest) { } if (params.bcat !== undefined) { - payload.bcat = params.bcat; + payload.bcat = deepAccess(bidderRequest.ortb2Imp, 'bcat') || params.bcat; } if (params.dvt !== undefined) { payload.dvt = params.dvt; diff --git a/modules/rakutenBidAdapter/index.js b/modules/rakutenBidAdapter/index.js index e567509b3c1..27c04029231 100644 --- a/modules/rakutenBidAdapter/index.js +++ b/modules/rakutenBidAdapter/index.js @@ -22,8 +22,9 @@ export const spec = { l: navigator.browserLanguage || navigator.language, d: document.domain, + // TODO: what are 'tp' and 'pp'? tp: bidderRequest.refererInfo.stack[0] || window.location.href, - pp: bidderRequest.refererInfo.referer, + pp: bidderRequest.refererInfo.topmostLocation, gdpr: ((_a = bidderRequest.gdprConsent) === null || _a === void 0 ? void 0 : _a.gdprApplies) ? 1 : 0, ...((_b = bidderRequest.gdprConsent) === null || _b === void 0 ? void 0 : _b.consentString) && { cd: bidderRequest.gdprConsent.consentString diff --git a/modules/rasBidAdapter.js b/modules/rasBidAdapter.js new file mode 100644 index 00000000000..801457aa552 --- /dev/null +++ b/modules/rasBidAdapter.js @@ -0,0 +1,167 @@ +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { isEmpty, parseSizesInput, deepAccess } from '../src/utils.js'; +import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; + +const BIDDER_CODE = 'ras'; +const VERSION = '1.0'; + +const getEndpoint = (network) => { + return `https://csr.onet.pl/${encodeURIComponent(network)}/csr-006/csr.json?nid=${encodeURIComponent(network)}&`; +}; + +function parseParams(params, bidderRequest) { + const newParams = {}; + if (params.customParams && typeof params.customParams === 'object') { + for (const param in params.customParams) { + if (params.customParams.hasOwnProperty(param)) { + newParams[param] = params.customParams[param]; + } + } + } + const du = deepAccess(bidderRequest, 'refererInfo.page'); + const dr = deepAccess(bidderRequest, 'refererInfo.ref'); + if (du) { + newParams.du = du; + } + if (dr) { + newParams.dr = dr; + } + const pageContext = params.pageContext; + if (!pageContext) { + return newParams; + } + if (pageContext.du) { + newParams.du = pageContext.du; + } + if (pageContext.dr) { + newParams.dr = pageContext.dr; + } + if (pageContext.dv) { + newParams.DV = pageContext.dv; + } + const keywords = getAllOrtbKeywords(bidderRequest?.ortb2, pageContext.keyWords) + if (keywords.length > 0) { + newParams.kwrd = keywords.join('+') + } + if (pageContext.capping) { + newParams.local_capping = pageContext.capping; + } + if (pageContext.keyValues && typeof pageContext.keyValues === 'object') { + for (const param in pageContext.keyValues) { + if (pageContext.keyValues.hasOwnProperty(param)) { + const kvName = 'kv' + param; + newParams[kvName] = pageContext.keyValues[param]; + } + } + } + return newParams; +} + +const buildBid = (ad) => { + if (ad.type === 'empty') { + return null; + } + return { + requestId: ad.id, + cpm: ad.bid_rate ? ad.bid_rate.toFixed(2) : 0, + width: ad.width || 0, + height: ad.height || 0, + ttl: 300, + creativeId: ad.adid ? parseInt(ad.adid.split(',')[2], 10) : 0, + netRevenue: true, + currency: ad.currency || 'USD', + dealId: null, + meta: { + mediaType: BANNER + }, + ad: ad.html || null + }; +}; + +const getContextParams = (bidRequests, bidderRequest) => { + const bid = bidRequests[0]; + const { params } = bid; + const requestParams = { + site: params.site, + area: params.area, + cre_format: 'html', + systems: 'das', + kvprver: VERSION, + ems_url: 1, + bid_rate: 1, + ...parseParams(params, bidderRequest) + }; + return Object.keys(requestParams).map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(requestParams[key])).join('&'); +}; + +const getSlots = (bidRequests) => { + let queryString = ''; + const batchSize = bidRequests.length; + for (let i = 0; i < batchSize; i++) { + const adunit = bidRequests[i]; + const slotSequence = deepAccess(adunit, 'params.slotSequence'); + + const sizes = parseSizesInput(getAdUnitSizes(adunit)).join(','); + + queryString += `&slot${i}=${encodeURIComponent(adunit.params.slot)}&id${i}=${encodeURIComponent(adunit.bidId)}&composition${i}=CHILD`; + + if (sizes.length) { + queryString += `&iusizes${i}=${encodeURIComponent(sizes)}`; + } + if (slotSequence !== undefined) { + queryString += `&pos${i}=${encodeURIComponent(slotSequence)}`; + } + } + return queryString; +}; + +const getGdprParams = (bidderRequest) => { + const gdprApplies = deepAccess(bidderRequest, 'gdprConsent.gdprApplies'); + let consentString = deepAccess(bidderRequest, 'gdprConsent.consentString'); + let queryString = ''; + if (gdprApplies !== undefined) { + queryString += `&gdpr_applies=${encodeURIComponent(gdprApplies)}`; + } + if (consentString !== undefined) { + queryString += `&euconsent=${encodeURIComponent(consentString)}`; + } + return queryString; +}; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + isBidRequestValid: function (bidRequest) { + if (!bidRequest || !bidRequest.params || typeof bidRequest.params !== 'object') { + return; + } + const { params } = bidRequest; + return Boolean(params.network && params.site && params.area && params.slot); + }, + + buildRequests: function (bidRequests, bidderRequest) { + const slotsQuery = getSlots(bidRequests); + const contextQuery = getContextParams(bidRequests, bidderRequest); + const gdprQuery = getGdprParams(bidderRequest); + const bidIds = bidRequests.map((bid) => ({ slot: bid.params.slot, bidId: bid.bidId })); + const network = bidRequests[0].params.network; + return [{ + method: 'GET', + url: getEndpoint(network) + contextQuery + slotsQuery + gdprQuery, + bidIds: bidIds + }]; + }, + + interpretResponse: function (serverResponse, bidRequest) { + const response = serverResponse.body; + if (!response || !response.ads || response.ads.length === 0) { + return []; + } + return response.ads.map(buildBid).filter((bid) => !isEmpty(bid)); + } +}; + +registerBidder(spec); diff --git a/modules/rasBidAdapter.md b/modules/rasBidAdapter.md new file mode 100644 index 00000000000..e8a61974130 --- /dev/null +++ b/modules/rasBidAdapter.md @@ -0,0 +1,52 @@ +# Overview + +``` +Module Name: Ringier Axel Springer Bidder Adapter +Module Type: Bidder Adapter +Maintainer: support@ringpublishing.com +``` + +# Description + +Module that connects to Ringer Axel Springer demand sources. +Only banner format is supported. + +# Test Parameters +```js +var adUnits = [{ + code: 'test-div-ad', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bids: [{ + bidder: 'ras', + params: { + network: '4178463', + site: 'test', + area: 'areatest', + slot: 'slot' + } + }] +}]; +``` + +# Parameters + +| Name | Scope | Type | Description | Example | +|------------------------------|----------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| +| network | required | String | Specific identifier provided by RAS | `"4178463"` | +| site | required | String | Specific identifier name (case-insensitive) that is associated with this ad unit and provided by RAS | `"example_com"` | +| area | required | String | Ad unit category name; only case-insensitive alphanumeric with underscores and hyphens are allowed | `"sport"` | +| slot | required | String | Ad unit placement name (case-insensitive) provided by RAS | `"slot"` | +| slotSequence | optional | Number | Ad unit sequence position provided by RAS | `1` | +| pageContext | optional | Object | Web page context data | `{}` | +| pageContext.dr | optional | String | Document referrer URL address | `"https://example.com/"` | +| pageContext.du | optional | String | Document URL address | `"https://example.com/sport/football/article.html?id=932016a5-02fc-4d5c-b643-fafc2f270f06"` | +| pageContext.dv | optional | String | Document virtual address as slash-separated path that may consist of any number of parts (case-insensitive alphanumeric with underscores and hyphens); first part should be the same as `site` value and second as `area` value; next parts may reflect website navigation | `"example_com/sport/football"` | +| pageContext.keyWords | optional | String[] | List of keywords associated with this ad unit; only case-insensitive alphanumeric with underscores and hyphens are allowed | `["euro", "lewandowski"]` | +| pageContext.keyValues | optional | Object | Key-values associated with this ad unit (case-insensitive); following characters are not allowed in the values: `" ' = ! + # * ~ ; ^ ( ) < > [ ] & @` | `{}` | +| pageContext.keyValues.ci | optional | String | Content unique identifier | `"932016a5-02fc-4d5c-b643-fafc2f270f06"` | +| pageContext.keyValues.adunit | optional | String | Ad unit name | `"example_com/sport"` | +| customParams | optional | Object | Custom request params | `{}` | \ No newline at end of file diff --git a/modules/rdnBidAdapter.md b/modules/rdnBidAdapter.md deleted file mode 100644 index 9082c95c520..00000000000 --- a/modules/rdnBidAdapter.md +++ /dev/null @@ -1,33 +0,0 @@ -# Overview - -``` -Module Name: RDN Bidder Adapter -Module Type: Bidder Adapter -Maintainer: engineer@lob-inc.com -``` - -# Description - -Connect to RDN for bids. - -RDN bid adapter supports Banner currently. - -# Test Parameters - -``` - var adUnits = [ - { - code: 'test-ad-div', - sizes: [[300, 250]], - mediaTypes: {banner: {}}, - bids: [ - { - bidder: 'rdn', - params: { - adSpotId: '10000' - } - } - ] - } - ]; -``` diff --git a/modules/readpeakBidAdapter.js b/modules/readpeakBidAdapter.js index 099e1fb6332..718d6504b56 100644 --- a/modules/readpeakBidAdapter.js +++ b/modules/readpeakBidAdapter.js @@ -1,7 +1,8 @@ -import { logError, replaceAuctionPrice, parseUrl } from '../src/utils.js'; +import { logError, replaceAuctionPrice, triggerPixel, isStr } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { NATIVE, BANNER } from '../src/mediaTypes.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; export const ENDPOINT = 'https://app.readpeak.com/header/prebid'; @@ -24,6 +25,9 @@ export const spec = { isBidRequestValid: bid => !!(bid && bid.params && bid.params.publisherId), buildRequests: (bidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + bidRequests = convertOrtbRequestToProprietaryNative(bidRequests); + const currencyObj = config.getConfig('currency'); const currency = (currencyObj && currencyObj.adServerCurrency) || 'USD'; @@ -37,7 +41,7 @@ export const spec = { cur: [currency], source: { fd: 1, - tid: bidRequests[0].transactionId, + tid: bidderRequest.ortb2?.source?.tid, ext: { prebid: '$prebid.version$' } @@ -64,8 +68,16 @@ export const spec = { }; }, - interpretResponse: (response, request) => - bidResponseAvailable(request, response) + interpretResponse: (response, request) => { + return bidResponseAvailable(request, response) + }, + + onBidWon: (bid) => { + if (bid.burl && isStr(bid.burl)) { + bid.burl = replaceAuctionPrice(bid.burl, bid.cpm); + triggerPixel(bid.burl); + } + }, }; function bidResponseAvailable(bidRequest, bidResponse) { @@ -103,6 +115,7 @@ function bidResponseAvailable(bidRequest, bidResponse) { bid.ad = idToBidMap[id].adm bid.width = idToBidMap[id].w bid.height = idToBidMap[id].h + bid.burl = idToBidMap[id].burl } if (idToBidMap[id].adomain) { bid.meta = { @@ -238,12 +251,6 @@ function bannerImpression(slot) { } function site(bidRequests, bidderRequest) { - const url = - config.getConfig('pageUrl') || - (bidderRequest && - bidderRequest.refererInfo && - bidderRequest.refererInfo.referer); - const pubId = bidRequests && bidRequests.length > 0 ? bidRequests[0].params.publisherId @@ -255,12 +262,11 @@ function site(bidRequests, bidderRequest) { return { publisher: { id: pubId.toString(), - domain: config.getConfig('publisherDomain') + domain: bidderRequest?.refererInfo?.domain, }, id: siteId ? siteId.toString() : pubId.toString(), - page: url, - domain: - (url && parseUrl(url).hostname) || config.getConfig('publisherDomain') + page: bidderRequest?.refererInfo?.page, + domain: bidderRequest?.refererInfo?.domain }; } return undefined; diff --git a/modules/realvuAnalyticsAdapter.js b/modules/realvuAnalyticsAdapter.js deleted file mode 100644 index 832e907893c..00000000000 --- a/modules/realvuAnalyticsAdapter.js +++ /dev/null @@ -1,973 +0,0 @@ -// RealVu Analytics Adapter -import adapter from '../src/AnalyticsAdapter.js'; -import adapterManager from '../src/adapterManager.js'; -import CONSTANTS from '../src/constants.json'; -import { getStorageManager } from '../src/storageManager.js'; -import { logMessage, logError } from '../src/utils.js'; -const storage = getStorageManager(); - -let realvuAnalyticsAdapter = adapter({ - global: 'realvuAnalytics', - handler: 'on', - analyticsType: 'bundle' -}); -window.top1 = window; -try { - let wnd = window; - while ((window.top1 != top) && (typeof (wnd.document) != 'undefined')) { - window.top1 = wnd; - wnd = wnd.parent; - } -} catch (e) { - /* continue regardless of error */ -} - -export let lib = { - ads: [], - x1: 0, - y1: 0, - x2: 0, - y2: 0, - t0: new Date(), - nn: 0, - frm: false, // check first if we are inside other domain iframe - msg: [], - foc: !window.top1.document.hidden, // 1-in, 0-out of focus - c: '', // owner id - sr: '', // - beacons: [], // array of beacons to collect while 'conf' is not responded - defer: [], - init: function () { - let z = this; - let u = navigator.userAgent; - z.device = u.match(/iPhone|iPod|Android|Opera Mini|IEMobile/gi) ? 'mobile' : 'desktop'; - if (typeof (z.len) == 'undefined') z.len = 0; - z.ie = navigator.appVersion.match(/MSIE/); - z.saf = (u.match(/Safari/) && !u.match(/Chrome/)); - z.ff = u.match(/Firefox/i); - z.cr = (u.match(/Chrome/)); - z.ope = window.opera; - z.fr = 0; - if (window.top1 != top) { - z.fr = 2; - if (typeof window.top1.$sf != 'undefined') { - z.fr = 1; - } - } - z.add_evt(window.top1, 'focus', function () { - window.top1.realvu_aa.foc = 1; - }); - z.add_evt(window.top1, 'scroll', function () { - window.top1.realvu_aa.foc = 1; - }); - z.add_evt(window.top1, 'blur', function () { - window.top1.realvu_aa.foc = 0; - }); - z.add_evt(window.top1.document, 'blur', function () { - window.top1.realvu_aa.foc = 0; - }); - z.add_evt(window.top1, 'visibilitychange', function () { - window.top1.realvu_aa.foc = !window.top1.document.hidden; - }); - z.doLog = (window.top1.location.search.match(/boost_log/) || document.referrer.match(/boost_log/)) ? 1 : 0; - if (z.doLog) { - window.setTimeout(z.scr('https://ac.realvu.net/realvu_aa_viz.js'), 500); - } - }, - - add_evt: function (elem, evtType, func) { - elem.addEventListener(evtType, func, true); - this.defer.push(function() { - elem.removeEventListener(evtType, func, true); - }); - }, - - update: function () { - let z = this; - let t = window.top1; - let de = t.document.documentElement; - z.x1 = t.pageXOffset ? t.pageXOffset : de.scrollLeft; - z.y1 = t.pageYOffset ? t.pageYOffset : de.scrollTop; - let w1 = t.innerWidth ? t.innerWidth : de.clientWidth; - let h1 = t.innerHeight ? t.innerHeight : de.clientHeight; - z.x2 = z.x1 + w1; - z.y2 = z.y1 + h1; - }, - brd: function (s, p) { // return a board Width, s-element, p={Top,Right,Bottom, Left} - let u; - if (window.getComputedStyle) u = window.getComputedStyle(s, null); - else u = s.style; - let a = u['border' + p + 'Width']; - return parseInt(a.length > 2 ? a.slice(0, -2) : 0); - }, - - padd: function (s, p) { // return a board Width, s-element, p={Top,Right,Bottom, Left} - let u; - if (window.getComputedStyle) u = window.getComputedStyle(s, null); - else u = s.style; - let a = u['padding' + p]; - return parseInt(a.length > 2 ? a.slice(0, -2) : 0); - }, - - viz_area: function (x1, x2, y1, y2) { // coords of Ad - if (this.fr == 1) { - try { - let iv = Math.round(100 * window.top1.$sf.ext.geom().self.iv); - return iv; - } catch (e) { - /* continue regardless of error */ - } - } - let xv1 = Math.max(x1, this.x1); - let yv1 = Math.max(y1, this.y1); - let xv2 = Math.min(x2, this.x2); - let yv2 = Math.min(y2, this.y2); - let A = Math.round(100 * ((xv2 - xv1) * (yv2 - yv1)) / ((x2 - x1) * (y2 - y1))); - return (A > 0) ? A : 0; - }, - - viz_dist: function (x1, x2, y1, y2) { // coords of Ad - let d = Math.max(0, this.x1 - x2, x1 - this.x2) + Math.max(0, this.y1 - y2, y1 - this.y2); - return d; - }, - - track: function (a, f, params) { - let z = this; - let s1 = z.tru(a, f) + params; - if (f == 'conf') { - z.scr(s1, a); - z.log(' ' + f + '', a.num); - } else { - let bk = { - s1: s1, - a: a, - f: f - }; - z.beacons.push(bk); - } - }, - - send_track: function () { - let z = this; - if (z.sr >= 'a') { // conf, send beacons - let bk = z.beacons.shift(); - while (typeof bk != 'undefined') { - bk.s1 = bk.s1.replace(/_sr=0*_/, '_sr=' + z.sr + '_'); - z.log(' ' + bk.a.riff + ' ' + bk.a.unit_id + /* ' '+pin.mode+ */ ' ' + bk.a.w + 'x' + bk.a.h + '@' + bk.a.x + ',' + bk.a.y + - ' ' + bk.f + '', bk.a.num); - if (bk.a.rnd < Math.pow(10, 1 - (z.sr.charCodeAt(0) & 7))) { - z.scr(bk.s1, bk.a); - } - bk = z.beacons.shift(); - } - } - }, - - scr: function (s1, a) { - let st = document.createElement('script'); - st.async = true; - st.type = 'text/javascript'; - st.src = s1; - if (a && a.dv0 != null) { - a.dv0.appendChild(st); - } else { - let x = document.getElementsByTagName('script')[0]; - x.parentNode.insertBefore(st, x); - } - }, - - tru: function (a, f) { - let pin = a.pins[0]; - let s2 = 'https://ac.realvu.net/flip/3/c=' + pin.partner_id + - '_f=' + f + '_r=' + a.riff + - '_s=' + a.w + 'x' + a.h; - if (a.p) s2 += '_p=' + a.p; - if (f != 'conf') s2 += '_ps=' + this.enc(a.unit_id); - s2 += '_dv=' + this.device + - // + '_a=' + this.enc(a.a) - '_d=' + pin.mode + - '_sr=' + this.sr + - '_h=' + this.enc(a.ru) + '?'; - return s2.replace(/%/g, '!'); - }, - - enc: function (s1) { - // return escape(s1).replace(/[0-9a-f]{5,}/gi,'RANDOM').replace(/\*/g, '%2A').replace(/_/g, '%5F').replace(/\+/g, - return escape(s1).replace(/\*/g, '%2A').replace(/_/g, '%5F').replace(/\+/g, - '%2B').replace(/\./g, '%2E').replace(/\x2F/g, '%2F'); - }, - - findPosG: function (adi) { - let t = this; - let ad = adi; - let xp = 0; - let yp = 0; - let dc = adi.ownerDocument; - let wnd = dc.defaultView || dc.parentWindow; - - try { - while (ad != null && typeof (ad) != 'undefined') { - if (ad.getBoundingClientRect) { // Internet Explorer, Firefox 3+, Google Chrome, Opera 9.5+, Safari 4+ - let r = ad.getBoundingClientRect(); - xp += r.left; // +sL; - yp += r.top; // +sT; - if (wnd == window.top1) { - xp += t.x1; - yp += t.y1; - } - } else { - if (ad.tagName == 'IFRAME') { - xp += t.brd(ad, 'Left'); - yp += t.brd(ad, 'Top'); - } - xp += ad.offsetLeft; - yp += ad.offsetTop; - - let op = ad.offsetParent; - let pn = ad.parentNode; - let opf = ad; - while (opf != null) { - let cs = window.getComputedStyle(opf, null); - if (cs.position == 'fixed') { - if (cs.top) yp += parseInt(cs.top) + this.y1; - } - if (opf == op) break; - opf = opf.parentNode; - } - while (op != null && typeof (op) != 'undefined') { - xp += op.offsetLeft; - yp += op.offsetTop; - let ptn = op.tagName; - if (t.cr || t.saf || (t.ff && ptn == 'TD')) { - xp += t.brd(op, 'Left'); - yp += t.brd(op, 'Top'); - } - if (ad.tagName != 'IFRAME' && op != document.body && op != document.documentElement) { - xp -= op.scrollLeft; - yp -= op.scrollTop; - } - if (!t.ie) { - while (op != pn && pn != null) { - xp -= pn.scrollLeft; - yp -= pn.scrollTop; - if (t.ff_o) { - xp += t.brd(pn, 'Left'); - yp += t.brd(pn, 'Top'); - } - pn = pn.parentNode; - } - } - pn = pn.parentNode; - op = op.offsetParent; - } - } - if (this.fr) break; // inside different domain iframe or sf - ad = wnd.frameElement; // in case Ad is allocated inside iframe here we go up - wnd = wnd.parent; - } - } catch (e) { - /* continue regardless of error */ - } - let q = { - 'x': Math.round(xp), - 'y': Math.round(yp) - }; - return q; - }, - - poll: function () { - let fifo = window.top1.realvu_aa_fifo; - while (fifo.length > 0) { - (fifo.shift())(); - } - let z = this; - z.update(); - let now = new Date(); - if (typeof (z.ptm) == 'undefined') { - z.ptm = now; - } - let dvz = now - z.ptm; - z.ptm = now; - for (let i = 0; i < z.len; i++) { - let a = z.ads[i]; - let restored = false; - if (a.div == null) { // ad unit is not found yet - let adobj = document.getElementById(a.pins[0].unit_id); - if (adobj == null) { - restored = z.readPos(a); - if (!restored) continue; // do nothing if not found - } else { - z.bind_obj(a, adobj); - z.log('{m}"' + a.unit_id + '" is bound', a.num); - } - } - if (!restored) { - a.target = z.questA(a.div); - let target = (a.target !== null) ? a.target : a.div; - if (window.getComputedStyle(target).display == 'none') { - let targSibl = target.previousElementSibling; // for 'none' containers on mobile define y as previous sibling y+h - if (targSibl) { - let q = z.findPosG(targSibl); - a.x = q.x; - a.y = q.y + targSibl.offsetHeight; - } else { - target = target.parentNode; - let q = z.findPosG(target); - a.x = q.x; - a.y = q.y; - } - a.box.x = a.x; - a.box.y = a.y; - a.box.w = a.w; - a.box.h = a.h; - } else { - a.box.w = Math.max(target.offsetWidth, a.w); - a.box.h = Math.max(target.offsetHeight, a.h); - let q = z.findPosG(target); - let pad = {}; - pad.t = z.padd(target, 'Top'); - pad.l = z.padd(target, 'Left'); - pad.r = z.padd(target, 'Right'); - pad.b = z.padd(target, 'Bottom'); - let ax = q.x + pad.l; - let ay = q.y + pad.t; - a.box.x = ax; - a.box.y = ay; - if (a.box.w > a.w && a.box.w > 1) { - ax += (a.box.w - a.w - pad.l - pad.r) / 2; - } - if (a.box.h > a.h && a.box.h > 1) { - ay += (a.box.h - a.h - pad.t - pad.b) / 2; - } - if ((ax > 0 && ay > 0) && (a.x != ax || a.y != ay)) { - a.x = ax; - a.y = ay; - z.writePos(a); - } - } - } - let vtr = ((a.box.w * a.box.h) < 242500) ? 49 : 29; // treashfold more then 49% and more then 29% for "oversized" - if (a.pins[0].edge) { - vtr = a.pins[0].edge - 1; // override default edge 50% (>49) - } - a.vz = z.viz_area(a.box.x, a.box.x + a.box.w, a.box.y, a.box.y + a.box.h); - a.r = (z.fr > 1 ? 'frame' : (((a.vz > vtr) && z.foc) ? 'yes' : 'no')); // f-frame, y-yes in view,n-not in view - if (a.y < 0) { - a.r = 'out'; // if the unit intentionaly moved out, count it as out. - } - if (a.vz > vtr && z.foc) { - a.vt += dvz; // real dt counter in milliseconds, because of poll() can be called irregularly - a.vtu += dvz; - } - // now process every pin - let plen = a.pins.length; - for (let j = 0; j < plen; j++) { - let pin = a.pins[j]; - if (pin.state <= 1) { - let dist = z.viz_dist(a.x, a.x + a.w, a.y, a.y + a.h); - let near = (pin.dist != null && dist <= pin.dist); - // apply "near" rule for ad call only - a.r = (z.fr > 1) ? 'frame' : (((a.vz > vtr) && z.foc) ? 'yes' : 'no'); - if (near && a.r == 'no') { - a.r = 'yes'; - } - if (a.riff === '') { - a.riff = a.r; - let vrScore = z.score(a, 'v:r'); - if (vrScore != null) { - if (a.r == 'no' && vrScore > 75) { - a.riff = 'yes'; - } - } - let vv0Score = z.score(a, 'v:v0'); - if (vv0Score != null) { - if (a.r == 'yes' && vv0Score < (30 + 25 * Math.random())) { - a.riff = 'no'; - } - } - } - if ((pin.mode == 'kvp' || pin.mode == 'tx2') || (((a.vz > vtr) || near) && ((pin.mode == 'in-view' || pin.mode == 'video')))) { - z.show(a, pin); // in-view or flip show immediately if initial realvu=yes, or delay is over - } - } - if (pin.state == 2) { - a.target = z.questA(a.div); - if (a.target != null) { - pin.state = 3; - dvz = 0; - a.vt = 0; - // @if NODE_ENV='debug' - let now = new Date(); - let msg = (now.getTime() - time0) / 1000 + ' RENDERED ' + a.unit_id; - logMessage(msg); - // @endif - let rpt = z.bids_rpt(a, true); - z.track(a, 'rend', rpt); - z.incrMem(a, 'r', 'v:r'); - } - } - if (pin.state > 2) { - let tmin = (pin.mode == 'video') ? 2E3 : 1E3; // mrc min view time - if (a.vz > vtr) { - pin.vt += dvz; // real dt counter in milliseconds, because of poll() can be called irregularly - if (pin.state == 3) { - pin.state = 4; - z.incrMem(a, 'r', 'v:v0'); - } - if (pin.state == 4 && pin.vt >= tmin) { - pin.state = 5; - let rpt = z.bids_rpt(a, true); - z.track(a, 'view', rpt); - z.incrMem(a, 'v', 'v:r'); - z.incrMem(a, 'v', 'v:v0'); - } - if (pin.state == 5 && pin.vt >= 5 * tmin) { - pin.state = 6; - let rpt = z.bids_rpt(a, true); - z.track(a, 'view2', rpt); - } - } else if (pin.vt < tmin) { - pin.vt = 0; // reset to track continuous 1 sec - } - } - if (pin.state >= 2 && pin.mode === 'tx2' && - ((a.vtu > pin.rotate) || (pin.delay > 0 && a.vtu > pin.delay && a.riff === 'no' && a.ncall < 2)) && pin.tx2n > 0) { - // flip or rotate - pin.tx2n--; - pin.state = 1; - a.vtu = 0; - a.target = null; - } - } - } - this.send_track(); - }, - - questA: function (a) { // look for the visible object of ad_sizes size - // returns the object or null - if (a == null) return a; - if (a.nodeType == Node.TEXT_NODE) { - let dc = a.ownerDocument; - let wnd = dc.defaultView || dc.parentWindow; - let par = a.parentNode; - if (wnd == wnd.top) { - return par; - } else { - return par.offsetParent; - } - } - let notFriendly = false; - let ain = null; - let tn = a.tagName; - if (tn == 'HEAD' || tn == 'SCRIPT') return null; - if (tn == 'IFRAME') { - ain = this.doc(a); - if (ain == null) { - notFriendly = true; - } else { - a = ain; - tn = a.tagName; - } - } - if (notFriendly || tn == 'OBJECT' || tn == 'IMG' || tn == 'EMBED' || tn == 'SVG' || tn == 'CANVAS' || - (tn == 'DIV' && a.style.backgroundImage)) { - let w1 = a.offsetWidth; - let h1 = a.offsetHeight; - if (w1 > 33 && h1 > 33 && a.style.display != 'none') return a; - } - if (a.hasChildNodes()) { - let b = a.firstChild; - while (b != null) { - let c = this.questA(b); - if (c != null) return c; - b = b.nextSibling; - } - } - return null; - }, - - doc: function(f) { // return document of f-iframe - let d = null; - try { - if (f.contentDocument) d = f.contentDocument; // DOM - else if (f.contentWindow) d = f.contentWindow.document; // IE - } catch (e) { - /* continue regardless of error */ - } - return d; - }, - - bind_obj: function (a, adobj) { - a.div = adobj; - a.target = null; // initially null, found ad when served - a.unit_id = adobj.id; // placement id or name - a.w = adobj.offsetWidth || 1; // width, min 1 - a.h = adobj.offsetHeight || 1; // height, min 1 - }, - add: function (wnd1, p) { // p - realvu unit id - let a = { - num: this.len, - x: 0, - y: 0, - box: { - x: 0, - y: 0, - h: 1, - w: 1 - }, // measured ad box - p: p, - state: 0, // 0-init, (1-loaded,2-rendered,3-viewed) - delay: 0, // delay in msec to show ad after gets in view - vt: 0, // total view time - vtu: 0, // view time to update and mem - a: '', // ad_placement id - wnd: wnd1, - div: null, - pins: [], - frm: null, // it will be frame when "show" - riff: '', // r to report - rnd: Math.random(), - ncall: 0, // a callback number - rq_bids: [], // rq bids of registered partners - bids: [] // array of bids - }; - a.ru = window.top1.location.hostname; - window.top1.realvu_aa.ads[this.len++] = a; - return a; - }, - - fmt: function (a, pin) { - return { - 'realvu': a.r, - 'riff': a.riff, - 'area': a.vz, - 'ncall': a.ncall, - 'n': a.num, - 'id': a.unit_id, - 'pin': pin - }; - }, - - show: function (a, pin) { - pin.state = 2; // 2-published - pin.vt = 0; // reset view time counter - if (pin.size) { - let asz = this.setSize(pin.size); - if (asz != null) { - a.w = asz.w; - a.h = asz.h; - } - } - if (typeof pin.callback != 'undefined') { - pin.callback(this.fmt(a, pin)); - } - a.ncall++; - this.track(a, 'show', ''); - }, - - check: function (p1) { - let pin = { - dist: 150, - state: 0, - tx2n: 7 - }; // if dist is set trigger ad when distance < pin.dist - for (let attr in p1) { - if (p1.hasOwnProperty(attr)) { - if ((attr == 'ad_sizes') && (typeof (p1[attr]) == 'string')) { - pin[attr] = p1[attr].split(','); - } else if (attr == 'edge') { - try { - let ed = parseInt(p1[attr]); - if (ed > 0 && ed < 251) pin[attr] = ed; - } catch (e) { - /* continue regardless of error */ - } - } else { - pin[attr] = p1[attr]; - } - } - } - let a = null; - let z = this; - try { - // not to track the same object more than one time - for (let i = 0; i < z.len; i++) { - // if (z.ads[i].div == adobj) { a = z.ads[i]; break; } - if (z.ads[i].unit_id == pin.unit_id) { - a = z.ads[i]; - break; - } - } - pin.wnd = pin.wnd || window; - if (a == null) { - a = z.add(pin.wnd, pin.p); - a.unit_id = pin.unit_id; - let adobj = (pin.unit) ? pin.unit : document.getElementById(a.unit_id); - if (adobj != null) { - z.bind_obj(a, adobj); - } else { - z.log('{w}"' + pin.unit_id + '" not found', a.num); - } - if (pin.size) { - let asz = z.setSize(pin.size); - if (asz != null) { - a.w = asz.w; - a.h = asz.h; - } - } - pin.delay = pin.delay || 0; // delay in msec - if (typeof pin.mode == 'undefined') { - if ((typeof pin.callback != 'undefined') || (typeof pin.content != 'undefined')) { - pin.mode = (pin.delay > 0) ? 'tx2' : 'in-view'; - } else { - pin.mode = 'kvp'; - } - // delays are for views only - } - pin.vt = 0; // view time - pin.state = 0; - a.pins.push(pin); - } - if (this.sr === '') { - z.track(a, 'conf', ''); - this.sr = '0'; - } - this.poll(); - return a; - } catch (e) { - z.log(e.message, -1); - return { - r: 'err' - }; - } - }, - - setSize: function (sa) { - let sb = sa; - try { - if (typeof (sa) == 'string') sb = sa.split('x'); // pin.size is a string WWWxHHH or array - else if (Array.isArray(sa)) { - let mm = 4; - while (--mm > 0 && Array.isArray(sa[0]) && Array.isArray(sa[0][0])) { - sa = sa[0]; - } - for (let m = 0; m < sa.length; m++) { - if (Array.isArray(sa[m])) { - sb = sa[m]; // if size is [][] - let s = sb[0] + 'x' + sb[1]; - if (s == '300x250' || s == '728x90' || s == '320x50' || s == '970x90') { - break; // use most popular sizes - } - } else if (sa.length > 1) { - sb = sa; - } - } - } - let w1 = parseInt(sb[0]); - let h1 = parseInt(sb[1]); - return { - w: w1, - h: h1 - }; - } catch (e) { - /* continue regardless of error */ - } - return null; - }, - // API functions - addUnitById: function (partnerId, unitId, callback, delay) { - let p1 = partnerId; - if (typeof (p1) == 'string') { - p1 = { - partner_id: partnerId, - unit_id: unitId, - callback: callback, - delay: delay - }; - } - let a = window.top1.realvu_aa.check(p1); - return a.riff; - }, - - checkBidIn: function(partnerId, args, b) { // process a bid from hb - // b==true - add/update, b==false - update only - if (args.cpm == 0) return; // collect only bids submitted - const boost = window.top1.realvu_aa; - let pushBid = false; - let adi = null; - if (!b) { // update only if already checked in by xyzBidAdapter - for (let i = 0; i < boost.ads.length; i++) { - adi = boost.ads[i]; - if (adi.unit_id == args.adUnitCode) { - pushBid = true; - break; - } - } - } else { - pushBid = true; - adi = window.top1.realvu_aa.check({ - unit_id: args.adUnitCode, - size: args.size, - partner_id: partnerId - }); - } - if (pushBid) { - let pb = { - bidder: args.bidder, - cpm: args.cpm, - size: args.size, - adId: args.adId, - requestId: args.requestId, - crid: '', - ttr: args.timeToRespond, - winner: 0 - }; - if (args.creative_id) { - pb.crid = args.creative_id; - } - adi.bids.push(pb); - } - }, - - checkBidWon: function(partnerId, args, b) { - // b==true - add/update, b==false - update only - const z = this; - const unitId = args.adUnitCode; - for (let i = 0; i < z.ads.length; i++) { - let adi = z.ads[i]; - if (adi.unit_id == unitId) { - for (let j = 0; j < adi.bids.length; j++) { - let bj = adi.bids[j]; - if (bj.adId == args.adId) { - bj.winner = 1; - break; - } - } - let rpt = z.bids_rpt(adi, false); - z.track(adi, 'win', rpt); - break; - } - } - }, - - bids_rpt: function(a, wo) { // a-unit, wo=true - WinnerOnly - let rpt = ''; - for (let i = 0; i < a.bids.length; i++) { - let g = a.bids[i]; - if (wo && !g.winner) continue; - rpt += '&bdr=' + g.bidder + '&cpm=' + g.cpm + '&vi=' + a.riff + - '&gw=' + g.winner + '&crt=' + g.crid + '&ttr=' + g.ttr; - // append bid partner_id if any - let pid = ''; - for (let j = 0; j < a.rq_bids.length; j++) { - let rqb = a.rq_bids[j]; - if (rqb.adId == g.adId) { - pid = rqb.partner_id; - break; - } - } - rpt += '&bc=' + pid; - } - return rpt; - }, - - getStatusById: function (unitId) { // return status object - for (let i = 0; i < this.ads.length; i++) { - let adi = this.ads[i]; - if (adi.unit_id == unitId) return this.fmt(adi); - } - return null; - }, - - log: function (m1, i) { - if (this.doLog) { - this.msg.push({ - dt: new Date() - this.t0, - s: 'U' + (i + 1) + m1 - }); - } - }, - - keyPos: function (a) { - if (a.pins[0].unit_id) { - let level = 'L' + (window.top1.location.pathname.match(/\//g) || []).length; - return 'realvu.' + level + '.' + a.pins[0].unit_id.replace(/[0-9]{5,}/gi, 'RANDOM'); - } - }, - - writePos: function (a) { - try { - let v = a.x + ',' + a.y + ',' + a.w + ',' + a.h; - storage.setDataInLocalStorage(this.keyPos(a), v); - } catch (ex) { - /* continue regardless of error */ - } - }, - - readPos: function (a) { - try { - let s = storage.getDataFromLocalStorage(this.keyPos(a)); - if (s) { - let v = s.split(','); - a.x = parseInt(v[0], 10); - a.y = parseInt(v[1], 10); - a.w = parseInt(v[2], 10); - a.h = parseInt(v[3], 10); - a.box = {x: a.x, y: a.y, w: a.w, h: a.h}; - return true; - } - } catch (ex) { - /* do nothing */ - } - return false; - }, - - incrMem: function(a, evt, name) { - try { - let k1 = this.keyPos(a) + '.' + name; - let vmem = storage.getDataFromLocalStorage(k1); - if (vmem == null) vmem = '1:3'; - let vr = vmem.split(':'); - let nv = parseInt(vr[0], 10); - let nr = parseInt(vr[1], 10); - if (evt == 'r') { - nr <<= 1; - nr |= 1; - nv <<= 1; - } - if (evt == 'v') { - nv |= 1; - } - storage.setDataInLocalStorage(k1, nv + ':' + nr); - } catch (ex) { - /* do nothing */ - } - }, - - score: function (a, name) { - try { - let vstr = storage.getDataFromLocalStorage(this.keyPos(a) + '.' + name); - if (vstr != null) { - let vr = vstr.split(':'); - let nv = parseInt(vr[0], 10); - let nr = parseInt(vr[1], 10); - let sv = 0; - let sr = 0; - for (nr &= 0x3FF; nr > 0; nr >>>= 1, nv >>>= 1) { // count 10 deliveries - if (nr & 0x1) sr++; - if (nv & 0x1) sv++; - } - return Math.round(sv * 100 / sr); - } - } catch (ex) { - /* do nothing */ - } - return null; - } -}; - -window.top1.realvu_aa_fifo = window.top1.realvu_aa_fifo || []; -window.top1.realvu_aa = window.top1.realvu_aa || lib; - -if (typeof (window.top1.boost_poll) == 'undefined') { - window.top1.realvu_aa.init(); - window.top1.boost_poll = setInterval(function () { - window.top1 && window.top1.realvu_aa && window.top1.realvu_aa.poll(); - }, 20); -} - -let _options = {}; - -realvuAnalyticsAdapter.originEnableAnalytics = realvuAnalyticsAdapter.enableAnalytics; - -realvuAnalyticsAdapter.enableAnalytics = function (config) { - _options = config.options; - if (typeof (_options.partnerId) == 'undefined' || _options.partnerId == '') { - logError('Missed realvu.com partnerId parameter', 101, 'Missed partnerId parameter'); - } - realvuAnalyticsAdapter.originEnableAnalytics(config); - return _options.partnerId; -}; - -const time0 = (new Date()).getTime(); - -realvuAnalyticsAdapter.track = function ({eventType, args}) { - // @if NODE_ENV='debug' - let msg = ''; - let now = new Date(); - msg += (now.getTime() - time0) / 1000 + ' eventType=' + eventType; - if (typeof (args) != 'undefined') { - msg += ', args.bidder=' + args.bidder + ' args.adUnitCode=' + args.adUnitCode + - ' args.adId=' + args.adId + - ' args.cpm=' + args.cpm + - ' creativei_id=' + args.creative_id; - } - // msg += '\nargs=' + JSON.stringify(args) + '
'; - logMessage(msg); - // @endif - - const boost = window.top1.realvu_aa; - let b = false; // false - update only, true - add if not checked in yet - let partnerId = null; - if (_options && _options.partnerId && args) { - partnerId = _options.partnerId; - let code = args.adUnitCode; - b = _options.regAllUnits; - if (!b && _options.unitIds) { - for (let j = 0; j < _options.unitIds.length; j++) { - if (code === _options.unitIds[j]) { - b = true; - break; - } - } - } - } - if (eventType === CONSTANTS.EVENTS.BID_RESPONSE) { - boost.checkBidIn(partnerId, args, b); - } else if (eventType === CONSTANTS.EVENTS.BID_WON) { - boost.checkBidWon(partnerId, args, b); - } -}; - -// xyzBidAdapter calls checkin() to obtain "yes/no" viewability -realvuAnalyticsAdapter.checkIn = function (bid, partnerId) { - // find (or add if not registered yet) the unit in boost - if (typeof (partnerId) == 'undefined' || partnerId == '') { - logError('Missed realvu.com partnerId parameter', 102, 'Missed partnerId parameter'); - } - let a = window.top1.realvu_aa.check({ - unit_id: bid.adUnitCode, - size: bid.sizes, - partner_id: partnerId - }); - a.rq_bids.push({ - bidder: bid.bidder, - adId: bid.bidId, - partner_id: partnerId - }); - return a.riff; -}; - -realvuAnalyticsAdapter.isInView = function (adUnitCode) { - let r = 'NA'; - let s = window.top1.realvu_aa.getStatusById(adUnitCode); - if (s) { - r = s.realvu; - } - return r; -}; - -let disableAnalyticsSuper = realvuAnalyticsAdapter.disableAnalytics; -realvuAnalyticsAdapter.disableAnalytics = function () { - while (lib.defer.length) { - lib.defer.pop()(); - } - disableAnalyticsSuper.apply(this, arguments); -}; - -adapterManager.registerAnalyticsAdapter({ - adapter: realvuAnalyticsAdapter, - code: 'realvuAnalytics' -}); - -export default realvuAnalyticsAdapter; diff --git a/modules/realvuAnalyticsAdapter.md b/modules/realvuAnalyticsAdapter.md deleted file mode 100644 index c534f78bc94..00000000000 --- a/modules/realvuAnalyticsAdapter.md +++ /dev/null @@ -1,9 +0,0 @@ -# Overview - -Module Name: RealVu Analytics Adapter -Module Type: Analytics Adapter -Maintainer: it@realvu.com - -# Description - -Analytics adapter for realvu.com. Contact support@realvu.com for information. diff --git a/modules/redtramBidAdapter.js b/modules/redtramBidAdapter.js new file mode 100644 index 00000000000..e1dc0e2a148 --- /dev/null +++ b/modules/redtramBidAdapter.js @@ -0,0 +1,155 @@ +import { + isFn, + isStr, + deepAccess, + getWindowTop, + triggerPixel +} from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'redtram'; +const AD_URL = 'https://prebid.redtram.com/pbjs'; +const SYNC_URL = 'https://prebid.redtram.com/sync'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || + !bid.ttl || !bid.currency || !bid.meta) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + default: + return false; + } +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidFloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (_) { + return 0 + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER], + + isBidRequestValid: (bid) => { + return Boolean(bid.bidId && bid.params && bid.params.placementId); + }, + + buildRequests: (validBidRequests = [], bidderRequest) => { + const winTop = getWindowTop(); + const location = winTop.location; + const placements = []; + + const request = { + deviceWidth: winTop.screen.width, + deviceHeight: winTop.screen.height, + language: (navigator && navigator.language) ? navigator.language.split('-')[0] : '', + host: location.host, + page: location.pathname, + placements: placements + }; + + if (bidderRequest) { + if (bidderRequest.uspConsent) { + request.ccpa = bidderRequest.uspConsent; + } + if (bidderRequest.gdprConsent) { + request.gdpr = bidderRequest.gdprConsent; + } + } + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + const placement = { + placementId: bid.params.placementId, + bidId: bid.bidId, + schain: bid.schain || {}, + bidfloor: getBidFloor(bid) + }; + + if (typeof bid.userId !== 'undefined') { + placement.userId = bid.userId; + } + + const mediaType = bid.mediaTypes; + + if (mediaType && mediaType[BANNER] && mediaType[BANNER].sizes) { + placement.sizes = mediaType[BANNER].sizes; + placement.adFormat = BANNER; + } + + placements.push(placement); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + }, + + onBidWon: (bid) => { + const cpm = deepAccess(bid, 'adserverTargeting.hb_pb') || ''; + if (isStr(bid.nurl) && bid.nurl !== '') { + bid.nurl = bid.nurl.replace(/\${AUCTION_PRICE}/, cpm); + triggerPixel(bid.nurl); + } + } +}; + +registerBidder(spec); diff --git a/modules/redtramBidAdapter.md b/modules/redtramBidAdapter.md new file mode 100644 index 00000000000..39115502aa7 --- /dev/null +++ b/modules/redtramBidAdapter.md @@ -0,0 +1,33 @@ +# Overview + +``` +Module Name: redtram Bidder Adapter +Module Type: redtram Bidder Adapter +Maintainer: support@redtram.com +``` + +# Description + +Module that connects to redtram demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'div-prebid', + mediaTypes:{ + banner: { + sizes: [[300, 250]], + } + }, + bids:[ + { + bidder: 'redtram', + params: { + placementId: '23611' //test, please replace after test + } + } + ] + }, + ]; +``` \ No newline at end of file diff --git a/modules/reklamstoreBidAdapter.md b/modules/reklamstoreBidAdapter.md deleted file mode 100644 index 8615341f5cc..00000000000 --- a/modules/reklamstoreBidAdapter.md +++ /dev/null @@ -1,32 +0,0 @@ -# Overview - -Module Name: ReklamStore Bidder Adapter -Module Type: Bidder Adapter -Maintainer: it@reklamstore.com - -# Description - -Module that connects to ReklamStore's demand sources. - -ReklamStore supports display. - - -# Test Parameters -# display -``` - - var adUnits = [ - { - code: 'banner-ad-div', - sizes: [[300, 250]], - bids: [ - { - bidder: 'reklamstore', - params: { - regionId:532211 - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/relaidoBidAdapter.js b/modules/relaidoBidAdapter.js index db381555ef9..1e702d812f0 100644 --- a/modules/relaidoBidAdapter.js +++ b/modules/relaidoBidAdapter.js @@ -1,12 +1,23 @@ -import { deepAccess, logWarn, getBidIdParameter, parseQueryStringParameters, triggerPixel, generateUUID, isArray } from '../src/utils.js'; +import { + deepAccess, + logWarn, + parseQueryStringParameters, + triggerPixel, + generateUUID, + isArray, + isNumber, + parseSizesInput, + getBidIdParameter +} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { Renderer } from '../src/Renderer.js'; import { getStorageManager } from '../src/storageManager.js'; +import sha1 from 'crypto-js/sha1'; const BIDDER_CODE = 'relaido'; const BIDDER_DOMAIN = 'api.relaido.jp'; -const ADAPTER_VERSION = '1.0.7'; +const ADAPTER_VERSION = '1.1.0'; const DEFAULT_TTL = 300; const UUID_KEY = 'relaido_uuid'; @@ -44,7 +55,10 @@ function buildRequests(validBidRequests, bidderRequest) { let height = 0; if (hasVideoMediaType(bidRequest) && isVideoValid(bidRequest)) { - const playerSize = getValidSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')); + let playerSize = getValidSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize')); + if (playerSize.length === 0) { + playerSize = getValidSizes(deepAccess(bidRequest, 'params.video.playerSize')); + } width = playerSize[0][0]; height = playerSize[0][1]; mediaType = VIDEO; @@ -67,11 +81,11 @@ function buildRequests(validBidRequests, bidderRequest) { } if (!bidder) { - bidder = bidRequest.bidder + bidder = bidRequest.bidder; } if (!bidder) { - bidder = bidRequest.bidder + bidder = bidRequest.bidder; } if (!count) { @@ -81,13 +95,15 @@ function buildRequests(validBidRequests, bidderRequest) { bids.push({ bid_id: bidRequest.bidId, placement_id: getBidIdParameter('placementId', bidRequest.params), - transaction_id: bidRequest.transactionId, + transaction_id: bidRequest.ortb2Imp?.ext?.tid, bidder_request_id: bidRequest.bidderRequestId, ad_unit_code: bidRequest.adUnitCode, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auction_id: bidRequest.auctionId, player: bidRequest.params.player, width: width, height: height, + banner_sizes: getBannerSizes(bidRequest), media_type: mediaType }); } @@ -101,8 +117,9 @@ function buildRequests(validBidRequests, bidderRequest) { uuid: getUuid(), pv: '$prebid.version$', imuid: imuid, - ref: bidderRequest.refererInfo.referer - }) + canonical_url_hash: getCanonicalUrlHash(bidderRequest.refererInfo), + ref: bidderRequest.refererInfo.page + }); return { method: 'POST', @@ -134,26 +151,27 @@ function interpretResponse(serverResponse, bidRequest) { dealId: body.dealId || '', ttl: body.ttl || DEFAULT_TTL, netRevenue: true, - mediaType: res.mediaType || VIDEO, meta: { advertiserDomains: res.adomain || [], mediaType: VIDEO } }; - if (bidResponse.mediaType === VIDEO) { + if (res.vast && res.mediaType === VIDEO) { + bidResponse.mediaType = VIDEO; bidResponse.vastXml = res.vast; bidResponse.renderer = newRenderer(res.bidId, playerUrl); - } else { + } else if (res.vast && res.mediaType === BANNER) { + bidResponse.mediaType = BANNER; const playerTag = createPlayerTag(playerUrl); const renderTag = createRenderTag(res.width, res.height, res.vast); bidResponse.ad = `
${playerTag}${renderTag}
`; + } else if (res.adTag) { + bidResponse.mediaType = BANNER; + bidResponse.ad = decodeURIComponent(res.adTag); } bidResponses.push(bidResponse); } - - // eslint-disable-next-line no-console - console.log(JSON.stringify(bidResponses)); return bidResponses; } @@ -244,9 +262,6 @@ function outstreamRender(bid) { } function isBannerValid(bid) { - if (!isMobile()) { - return false; - } const sizes = getValidSizes(deepAccess(bid, 'mediaTypes.banner.sizes')); if (sizes.length > 0) { return true; @@ -255,7 +270,10 @@ function isBannerValid(bid) { } function isVideoValid(bid) { - const playerSize = getValidSizes(deepAccess(bid, 'mediaTypes.video.playerSize')); + let playerSize = getValidSizes(deepAccess(bid, 'mediaTypes.video.playerSize')); + if (playerSize.length === 0) { + playerSize = getValidSizes(deepAccess(bid, 'params.video.playerSize')); + } if (playerSize.length > 0) { const context = deepAccess(bid, 'mediaTypes.video.context'); if (context && context === 'outstream') { @@ -273,12 +291,12 @@ function getUuid() { return newId; } -export function isMobile() { - const ua = navigator.userAgent; - if (ua.indexOf('iPhone') > -1 || ua.indexOf('iPod') > -1 || (ua.indexOf('Android') > -1 && ua.indexOf('Tablet') == -1)) { - return true; +function getCanonicalUrlHash(refererInfo) { + const canonicalUrl = refererInfo.canonicalUrl || null; + if (!canonicalUrl) { + return null; } - return false; + return sha1(canonicalUrl).toString(); } function hasBannerMediaType(bid) { @@ -302,12 +320,32 @@ function getValidSizes(sizes) { if ((width >= 300 && height >= 250)) { result.push([width, height]); } + } else if (isNumber(sizes[i])) { + const width = sizes[0]; + const height = sizes[1]; + if (width == 1 && height == 1) { + return [[1, 1]]; + } + if ((width >= 300 && height >= 250)) { + return [[width, height]]; + } } } } return result; } +function getBannerSizes(bidRequest) { + if (!hasBannerMediaType(bidRequest)) { + return null; + } + const sizes = deepAccess(bidRequest, 'mediaTypes.banner.sizes'); + if (!isArray(sizes)) { + return null; + } + return parseSizesInput(sizes).join(','); +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], diff --git a/modules/relayBidAdapter.js b/modules/relayBidAdapter.js new file mode 100644 index 00000000000..af145a5e163 --- /dev/null +++ b/modules/relayBidAdapter.js @@ -0,0 +1,99 @@ +import { isNumber, logMessage } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js' + +const BIDDER_CODE = 'relay'; +const METHOD = 'POST'; +const ENDPOINT_URL = 'https://e.relay.bid/p/openrtb2'; + +// The default impl from the prebid docs. +const CONVERTER = + ortbConverter({ + context: { + netRevenue: true, + ttl: 30 + } + }); + +function buildRequests(bidRequests, bidderRequest) { + const prebidVersion = config.getConfig('prebid_version') || 'v8.1.0'; + // Group bids by accountId param + const groupedByAccountId = bidRequests.reduce((accu, item) => { + const accountId = ((item || {}).params || {}).accountId; + if (!accu[accountId]) { accu[accountId] = []; }; + accu[accountId].push(item); + return accu; + }, {}); + // Send one overall request with all grouped bids per accountId + let reqs = []; + for (const [accountId, accountBidRequests] of Object.entries(groupedByAccountId)) { + const url = `${ENDPOINT_URL}?a=${accountId}&pb=1&pbv=${prebidVersion}`; + const data = CONVERTER.toORTB({ bidRequests: accountBidRequests, bidderRequest }) + const req = { + method: METHOD, + url, + data + }; + reqs.push(req); + } + return reqs; +}; + +function interpretResponse(response, request) { + return CONVERTER.fromORTB({ response: response.body, request: request.data }).bids; +}; + +function isBidRequestValid(bid) { + return isNumber((bid.params || {}).accountId); +}; + +function getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { + let syncs = [] + for (const response of serverResponses) { + const responseSyncs = ((((response || {}).body || {}).ext || {}).user_syncs || []) + // Relay returns user_syncs in the format expected by prebid. If for any + // reason the request/response failed to properly capture the GDPR settings + // -- fallback to those identified by Prebid. + for (const sync of responseSyncs) { + const syncUrl = new URL(sync.url); + const missingGdpr = !syncUrl.searchParams.has('gdpr'); + const missingGdprConsent = !syncUrl.searchParams.has('gdpr_consent'); + if (missingGdpr) { + syncUrl.searchParams.set('gdpr', Number(gdprConsent.gdprApplies)) + sync.url = syncUrl.toString(); + } + if (missingGdprConsent) { + syncUrl.searchParams.set('gdpr_consent', gdprConsent.consentString); + sync.url = syncUrl.toString(); + } + if (syncOptions.iframeEnabled && sync.type === 'iframe') { + syncs.push(sync); + } else if (syncOptions.pixelEnabled && sync.type === 'image') { + syncs.push(sync); + } + } + } + + return syncs; +} + +export const spec = { + code: BIDDER_CODE, + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs, + onTimeout: function (timeoutData) { + logMessage('Timeout: ', timeoutData); + }, + onBidWon: function (bid) { + logMessage('Bid won: ', bid); + }, + onBidderError: function ({ error, bidderRequest }) { + logMessage('Error: ', error, bidderRequest); + }, + supportedMediaTypes: [BANNER, VIDEO, NATIVE] +} +registerBidder(spec); diff --git a/modules/relayBidAdapter.md b/modules/relayBidAdapter.md new file mode 100644 index 00000000000..882e04b7b13 --- /dev/null +++ b/modules/relayBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: Relay Bid Adapter +Module Type: Bid Adapter +Maintainer: relay@kevel.co +``` + +# Description + +Connects to Relay exchange API for bids. +Supports Banner, Video and Native. + +# Test Parameters + +``` +var adUnits = [ + // Banner with minimal bid configuration + { + code: 'minimal', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [ + { + bidder: 'relay', + params: { + accountId: 1234 + }, + ortb2imp: { + ext: { + relay: { + bidders: { + bidderA: { + param: 1234 + } + } + } + } + } + } + ] + }, + // Minimal video + { + code: 'video-minimal', + mediaTypes: { + video: { + maxduration: 30, + api: [1, 3], + mimes: ['video/mp4'], + placement: 3, + protocols: [2,3,5,6] + } + }, + bids: [ + { + bidder: 'relay', + params: { + accountId: 1234 + }, + ortb2imp: { + ext: { + relay: { + bidders: { + bidderA: { + param: 'example' + } + } + } + } + } + } + ] + } +]; +``` diff --git a/modules/relevadRtdProvider.js b/modules/relevadRtdProvider.js new file mode 100644 index 00000000000..613eaa71a1f --- /dev/null +++ b/modules/relevadRtdProvider.js @@ -0,0 +1,364 @@ +/** + * This module adds Relevad provider to the real time data module + * The {@link module:modules/realTimeData} module is required + * The module will fetch categories and segments from Relevad server and pass them to the bidders + * @module modules/relevadRtdProvider + * @requires module:modules/realTimeData + */ + +import {deepSetValue, isEmpty, logError, mergeDeep} from '../src/utils.js'; +import {submodule} from '../src/hook.js'; +import {ajax} from '../src/ajax.js'; +import {findIndex} from '../src/polyfill.js'; +import {getRefererInfo} from '../src/refererDetection.js'; +import {config} from '../src/config.js'; + +const MODULE_NAME = 'realTimeData'; +const SUBMODULE_NAME = 'RelevadRTDModule'; + +const SEGTAX_IAB = 6; // IAB Content Taxonomy v2 +const CATTAX_IAB = 6; // IAB Contextual Taxonomy v2.2 +const RELEVAD_API_DOMAIN = 'https://prebid.relestar.com'; +const entries = Object.entries; +const AJAX_OPTIONS = { + withCredentials: true, + referrerPolicy: 'unsafe-url', + crossOrigin: true, +}; + +export let serverData = {}; // Tracks data returned from Relevad RTD server + +/** + * Provides contextual IAB categories and segments to the bidders. + * + * @param {} reqBidsConfigObj Bids request configuration + * @param {Function} onDone Ajax callbacek + * @param {} moduleConfig Rtd module configuration + * @param {} userConsent user GDPR consent + */ +export function getBidRequestData(reqBidsConfigObj, onDone, moduleConfig, userConsent) { + moduleConfig.params = moduleConfig.params || {}; + moduleConfig.params.partnerid = moduleConfig.params.partnerid ? moduleConfig.params.partnerid : 1; + + let adunitInfo = reqBidsConfigObj.adUnits.map(adunit => { return [adunit.code, adunit.bids.map(bid => { return [bid.bidder, bid.params] })]; }); + serverData.page = moduleConfig.params.actualUrl || getRefererInfo().page || ''; + const url = (RELEVAD_API_DOMAIN + '/apis/rweb2/' + + '?url=' + encodeURIComponent(serverData.page) + + '&au=' + encodeURIComponent(JSON.stringify(adunitInfo)) + + '&pid=' + encodeURIComponent(moduleConfig.params?.publisherid || '') + + '&aid=' + encodeURIComponent(moduleConfig.params?.apikey || '') + + '&cid=' + encodeURIComponent(moduleConfig.params?.partnerid || '') + + '&gdpra=' + encodeURIComponent(userConsent?.gdpr?.gdprApplies || '') + + '&gdprc=' + encodeURIComponent(userConsent?.gdpr?.consentString || '') + ); + + ajax(url, + { + success: function (response, req) { + if (req.status === 200) { + try { + const data = JSON.parse(response); + serverData.rawdata = data; + if (data) { + addRtdData(reqBidsConfigObj, data, moduleConfig); + } + } catch (e) { + logError(SUBMODULE_NAME, 'unable to parse data: ' + e); + } + onDone(); + } + }, + error: function () { + logError(SUBMODULE_NAME, 'unable to receive data'); + onDone(); + } + }, + null, + { method: 'GET', ...AJAX_OPTIONS, }, + ); +} + +/** + * Sets global ORTB user and site data + * + * @param {dictionary} ortb2 The gloabl ORTB structure + * @param {dictionary} rtdData Rtd segments and categories + */ +export function setGlobalOrtb2(ortb2, rtdData) { + try { + let addOrtb2 = composeOrtb2Data(rtdData, 'site'); + !isEmpty(addOrtb2) && mergeDeep(ortb2, addOrtb2); + } catch (e) { + logError(e) + } +} + +/** + * Compose ORTB2 data fragment from RTD data + * + * @param {dictionary} rtdData RTD segments and categories + * @param {string} prefix Site path prefix + * @return {dictionary} ORTB2 fragment ready to be merged into global or bidder ORTB + */ +function composeOrtb2Data(rtdData, prefix) { + const segments = rtdData.segments; + const categories = rtdData.categories; + const content = rtdData.content; + let addOrtb2 = {}; + + !isEmpty(segments) && deepSetValue(addOrtb2, 'user.ext.data.relevad_rtd', segments); + !isEmpty(categories.cat) && deepSetValue(addOrtb2, prefix + '.cat', categories.cat); + !isEmpty(categories.pagecat) && deepSetValue(addOrtb2, prefix + '.pagecat', categories.pagecat); + !isEmpty(categories.sectioncat) && deepSetValue(addOrtb2, prefix + '.sectioncat', categories.sectioncat); + !isEmpty(categories.sectioncat) && deepSetValue(addOrtb2, prefix + '.ext.data.relevad_rtd', categories.sectioncat); + !isEmpty(categories.cattax) && deepSetValue(addOrtb2, prefix + '.cattax', categories.cattax); + + if (!isEmpty(content) && !isEmpty(content.segs) && content.segtax) { + const contentSegments = { + name: 'relevad', + ext: { segtax: content.segtax }, + segment: content.segs.map(x => { return {id: x}; }) + }; + deepSetValue(addOrtb2, prefix + '.content.data', [contentSegments]); + } + return addOrtb2; +} + +/** + * Sets ORTB user and site data for a given bidder + * + * @param {dictionary} bidderOrtbFragment The bidder ORTB fragment + * @param {object} bidder The bidder name + * @param {object} rtdData RTD categories and segments + */ +function setBidderSiteAndContent(bidderOrtbFragment, bidder, rtdData) { + try { + let addOrtb2 = composeOrtb2Data(rtdData, 'site'); + !isEmpty(rtdData.segments) && deepSetValue(addOrtb2, 'user.ext.data.relevad_rtd', rtdData.segments); + !isEmpty(rtdData.segments) && deepSetValue(addOrtb2, 'user.ext.data.segments', rtdData.segments); + !isEmpty(rtdData.categories) && deepSetValue(addOrtb2, 'user.ext.data.contextual_categories', rtdData.categories.pagecat); + if (isEmpty(addOrtb2)) { + return; + } + bidderOrtbFragment[bidder] = bidderOrtbFragment[bidder] || {}; + mergeDeep(bidderOrtbFragment[bidder], addOrtb2); + } catch (e) { + logError(e) + } +} + +/** + * Filters dictionary entries + * + * @param {array of {key:value}} dict A dictionary with numeric values + * @param {string} minscore The minimum value + * @return {array[names]} Array of category names with scores greater or equal to minscore + */ +function filterByScore(dict, minscore) { + if (dict && !isEmpty(dict)) { + minscore = minscore && typeof minscore == 'number' ? minscore : 30; + try { + const filteredCategories = Object.keys(Object.fromEntries(Object.entries(dict).filter(([k, v]) => v > minscore))); + return isEmpty(filteredCategories) ? null : filteredCategories; + } catch (e) { + logError(e); + } + } + return null; +} + +/** + * Filters RTD by relevancy score + * + * @param {object} data The Input RTD + * @param {string} minscore The minimum relevancy score + * @return {object} Filtered RTD + */ +function getFiltered(data, minscore) { + let relevadData = {'segments': []}; + + minscore = minscore && typeof minscore == 'number' ? minscore : 30; + + const cats = filterByScore(data.cats, minscore); + const pcats = filterByScore(data.pcats, minscore) || cats; + const scats = filterByScore(data.scats, minscore) || pcats; + const cattax = (data.cattax || data.cattax === undefined) ? data.cattax : CATTAX_IAB; + relevadData.categories = {cat: cats, pagecat: pcats, sectioncat: scats, cattax: cattax}; + + const contsegs = filterByScore(data.contsegs, minscore); + const segtax = data.segtax ? data.segtax : SEGTAX_IAB; + relevadData.content = {segs: contsegs, segtax: segtax}; + + try { + if (data && data.segments) { + for (let segId in data.segments) { + if (data.segments.hasOwnProperty(segId)) { + relevadData.segments.push(data.segments[segId].toString()); + } + } + } + } catch (e) { + logError(e); + } + return relevadData; +} + +/** + * Adds Rtd data to global ORTB structure and bidder requests + * + * @param {} reqBids The bid requests list + * @param {} data The Rtd data + * @param {} moduleConfig The Rtd module configuration + */ +export function addRtdData(reqBids, data, moduleConfig) { + moduleConfig = moduleConfig || {}; + moduleConfig.params = moduleConfig.params || {}; + const globalMinScore = moduleConfig.params.hasOwnProperty('minscore') ? moduleConfig.params.minscore : 30; + const relevadData = getFiltered(data, globalMinScore); + const relevadList = relevadData.segments.concat(relevadData.categories.pagecat); + // Publisher side bidder whitelist + const biddersParamsExist = !!(moduleConfig?.params?.bidders); + // RTD Server-side bidder whitelist + const wl = data.wl || null; + const noWhitelists = !biddersParamsExist && isEmpty(wl); + + // Add RTD data to the global ORTB fragments when no whitelists present + noWhitelists && setGlobalOrtb2(reqBids.ortb2Fragments?.global, relevadData); + + // Target GAM/GPT + let setgpt = moduleConfig.params.setgpt || !moduleConfig.params.hasOwnProperty('setgpt'); + if (moduleConfig.dryrun || (typeof window.googletag !== 'undefined' && setgpt)) { + try { + if (window.googletag && window.googletag.pubads && (typeof window.googletag.pubads === 'function')) { + window.googletag.pubads().getSlots().forEach(function (n) { + if (typeof n.setTargeting !== 'undefined' && relevadList && relevadList.length > 0) { + n.setTargeting('relevad_rtd', relevadList); + } + }); + } + } catch (e) { + logError(e); + } + } + + // Set per-bidder RTD + const adUnits = reqBids.adUnits; + adUnits.forEach(adUnit => { + noWhitelists && deepSetValue(adUnit, 'ortb2Imp.ext.data.relevad_rtd', relevadList); + + adUnit.hasOwnProperty('bids') && adUnit.bids.forEach(bid => { + let bidderIndex = (moduleConfig.params.hasOwnProperty('bidders') ? findIndex(moduleConfig.params.bidders, function (i) { + return i.bidder === bid.bidder; + }) : false); + const indexFound = !!(typeof bidderIndex == 'number' && bidderIndex >= 0); + try { + if ( + !biddersParamsExist || + (indexFound && + (!moduleConfig.params.bidders[bidderIndex].hasOwnProperty('adUnitCodes') || + moduleConfig.params.bidders[bidderIndex].adUnitCodes.indexOf(adUnit.code) !== -1 + ) + ) + ) { + let wb = isEmpty(wl) || wl[bid.bidder] === true; + if (!wb && !isEmpty(wl[bid.bidder])) { + wb = true; + for (const [key, value] of entries(wl[bid.bidder])) { + let params = bid?.params || {}; + wb = wb && (key in params) && params[key] == value; + } + } + if (wb && !isEmpty(relevadList)) { + setBidderSiteAndContent(reqBids.ortb2Fragments?.bidder, bid.bidder, relevadData); + setBidderSiteAndContent(bid, 'ortb2', relevadData); + deepSetValue(bid, 'params.keywords.relevad_rtd', relevadList); + !(bid.params?.target || '').includes('relevad_rtd=') && deepSetValue(bid, 'params.target', [].concat(bid.params?.target ? [bid.params.target] : []).concat(relevadList.map(entry => { return 'relevad_rtd=' + entry; })).join(';')); + let firstPartyData = {}; + firstPartyData[bid.bidder] = { firstPartyData: { relevad_rtd: relevadList } }; + config.setConfig(firstPartyData); + } + } + } catch (e) { + logError(e); + } + }); + }); + + serverData = {...serverData, ...relevadData}; + return adUnits; +} + +/** + * Sends bid info to the RTD server + * + * @param {JSON} data Bids information + * @param {object} config Configuraion + */ +function sendBids(data, config) { + let dataJson = JSON.stringify(data); + + if (!config.dryrun) { + ajax(RELEVAD_API_DOMAIN + '/apis/bids/', () => {}, dataJson, AJAX_OPTIONS); + } + serverData = { clientdata: data }; +}; + +/** + * Processes AUCTION_END event + * + * @param {object} auctionDetails Auction details + * @param {object} config Module configuration + * @param {object} userConsent User GDPR consent object + */ +function onAuctionEnd(auctionDetails, config, userConsent) { + let adunitObj = {}; + let adunits = []; + + // Add Bids Received + auctionDetails.bidsReceived.forEach((bidObj) => { + if (!adunitObj[bidObj.adUnitCode]) { adunitObj[bidObj.adUnitCode] = []; } + + adunitObj[bidObj.adUnitCode].push({ + bidder: bidObj.bidderCode || bidObj.bidder, + cpm: bidObj.cpm, + currency: bidObj.currency, + dealId: bidObj.dealId, + type: bidObj.mediaType, + ttr: bidObj.timeToRespond, + size: bidObj.size + }); + }); + + entries(adunitObj).forEach(([adunitCode, bidsReceived]) => { + adunits.push({code: adunitCode, bids: bidsReceived}); + }); + + let data = { + event: 'bids', + adunits: adunits, + reledata: serverData.rawdata, + pid: encodeURIComponent(config.params?.publisherid || ''), + aid: encodeURIComponent(config.params?.apikey || ''), + cid: encodeURIComponent(config.params?.partnerid || ''), + gdpra: encodeURIComponent(userConsent?.gdpr?.gdprApplies || ''), + gdprc: encodeURIComponent(userConsent?.gdpr?.consentString || ''), + } + if (!config.dryrun) { + data.page = serverData?.page || config?.params?.actualUrl || getRefererInfo().page || ''; + } + + sendBids(data, config); +} + +export function init(config) { + return true; +} + +export const relevadSubmodule = { + name: SUBMODULE_NAME, + init: init, + onAuctionEndEvent: onAuctionEnd, + getBidRequestData: getBidRequestData +}; + +submodule(MODULE_NAME, relevadSubmodule); diff --git a/modules/relevadRtdProvider.md b/modules/relevadRtdProvider.md new file mode 100644 index 00000000000..fcbc7a7fb36 --- /dev/null +++ b/modules/relevadRtdProvider.md @@ -0,0 +1,108 @@ +# Relevad Real-Time Data Submodule + +Module Name: Relevad Rtd Provider +Module Type: Rtd Provider +Maintainer: anna@relevad.com + +# Description + +Relevad is a contextual semantic analytics company. Our privacy-first, cookieless contextual categorization, segmentation, and keyword generation platform is designed to help publishers and advertisers optimize targeting and increase ad inventory yield. + +Our real-time data processing module provides quality contextual IAB categories and segments along with their relevancy scores to the publisher’s web page. It places them into auction bid requests as global and/or bidder-specific: + +| Attrubute Type | ORTB2 Attribute | +| -------------- | ------------------------------------------------------------ | +| Contextual | “site.cat”: [IAB category codes]
“site.pagecat”: [IAB category codes],
“site.sectioncat”: [IAB category codes]
“site.cattax”: 6 | +| Content | “site.content.data”: {“name”: “relevad”, “ext”: …, “segment”: …} | +| User Data | “user.ext.data.relevad_rtd”: {segments} | + +Publisher may configre minimum relevancy score to restrict the categories and segments we pass to the bidders. +Relevad service does not use browser cookies and is fully GDPR compliant. + +### Publisher Integration + +Compile the Relevad RTD module into the Prebid.js package with + +`gulp build --modules=rtdModule,relevadRtdProvider` + +Add Relevad RTD provider to your Prebid config. Here is an example: + +``` +pbjs.setConfig( + ... + realTimeData: { + auctionDelay: 1000, + dataProviders: [ + { + name: "RelevadRTDModule", + waitForIt: true, + params: { + partnerId: your_partner_id, // Your Relevad partner id. + setgpt: true, // Target or not google GAM/GPT on your page. + minscore: 30, // Minimum relevancy score (0-100). If absent, defaults to 30. + + // The list of bidders to target with Relevad categories and segments. If absent or empty, target all bidders. + bidders: [ + { bidder: "appnexus", // Bidder name + adUnitCodes: ['adUnit-1','adUnit-2'], // List of adUnit codes to target. If absent or empty, target all ad units. + minscore: 70, // Minimum relevancy score for this bidder (0-100). If absent, defaults to the global minscore. + }, + ... + ] + } + } + ] + } + ... +} +``` + +### Relevad Real Time Submodule Configuration Parameters + + + +{: .table .table-bordered .table-striped } +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| name | String | Relevad RTD module name | Mandatory, must be **RelevadRTDModule** | +| waitForIt | Boolean | Whether to delay auction for the RTD module response | Optional. Defaults to false.We recommend setting it to true. Relevad RTD service is very fast. | +| params | Object | | Relevad RTD module configuration | +| params.partnerid | String | Relevad Partner ID, required to enable the service | Mandatory | +| params.publisherid | String | Relevad publisher id | Mandatory | +| params.apikey | String | Relevad API key | Mandatory | +| param.actualUrl | String | Your page URL. When present, will be categorized instead of the browser-provided URL | Optional, defaults to the browser-providedURL | +| params.setgpt | Boolean | Target or not Google GPT/GAM when it is configured on your page | Optional, defaults to true. | +| params.minscore | Integer | Minimum categorization relevancy score in the range of 0-100. Our categories and segments come with their relevancy scores. We’ll send to the bidders only categories and segments with the scores higher than the minscore. |Optional, defaults to 30| +| params.bidders | Dictionary | Bidders with which to share category and segment information | Optional. If empty or absent, target all bidders. | + + + +#### Bidder-specific configuration. Every bidder may have these configuration parameters + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| bidder | String | Bidder name | Mandatory. Example: “appnexus” | +| adUnitCodes | Array of Strings | List of specific AdUnit codes you with to target | Optional. If empty or absent, all ad units are targeted. | +| minscore | Integer | Bidder-specific minimum categorization relevancy score (0, 100) | Optional, defaults to global minscore above. | + +If you do not have your own `partnerid, publisherid, apikey` please reach out to [info@relevad.com](mailto:info@relevad.com). + +### Testing + +To view an example of the on page setup required: + +```bash +gulp serve-fast --modules=rtdModule,relevadRtdProvider +``` + +Then in your browser access: + +``` +http://localhost:9999/integrationExamples/gpt/relevadRtdProvider_example.html +``` + +Run the unit tests for Relevad RTD module: + +```bash +gulp test --file "test/spec/modules/relevadRtdProvider_spec.js" +``` \ No newline at end of file diff --git a/modules/relevantAnalyticsAdapter.js b/modules/relevantAnalyticsAdapter.js index 5917262c810..7774370f7ad 100644 --- a/modules/relevantAnalyticsAdapter.js +++ b/modules/relevantAnalyticsAdapter.js @@ -1,4 +1,4 @@ -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; const relevantAnalytics = adapter({ analyticsType: 'bundle', handler: 'on' }); diff --git a/modules/relevantdigitalBidAdapter.js b/modules/relevantdigitalBidAdapter.js new file mode 100644 index 00000000000..ad9ee5e1e14 --- /dev/null +++ b/modules/relevantdigitalBidAdapter.js @@ -0,0 +1,198 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {ortbConverter} from '../libraries/ortbConverter/converter.js' +import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; +import {pbsExtensions} from '../libraries/pbsExtensions/pbsExtensions.js' +import {deepSetValue, isEmpty, deepClone, shuffle, triggerPixel, deepAccess} from '../src/utils.js'; + +const BIDDER_CODE = 'relevantdigital'; + +/** Global settings per bidder-code for this adapter (which might be > 1 if using aliasing) */ +let configByBidder = {}; + +/** Used by the tests */ +export const resetBidderConfigs = () => { + configByBidder = {}; +}; + +/** Settings ber bidder-code. checkParams === true means that it can optionally be set in bid-params */ +const FIELDS = [ + { name: 'pbsHost', checkParams: true, required: true }, + { name: 'accountId', checkParams: true, required: true }, + { name: 'pbsBufferMs', checkParams: false, required: false, default: 250 }, + { name: 'useSourceBidderCode', checkParams: false, required: false, default: false }, +]; + +const SYNC_HTML = 'https://cdn.relevant-digital.com/resources/load-cookie.html'; +const MAX_SYNC_COUNT = 10; // Max server-side bidder to sync at once via the iframe + +/** Get settings for a bidder-code via config and, if needed, bid parameters */ +const getBidderConfig = (bids) => { + const { bidder } = bids[0]; + const cfg = configByBidder[bidder] || { + ...Object.fromEntries(FIELDS.filter((f) => 'default' in f).map((f) => [f.name, f.default])), + syncedBidders: {}, // To keep track of S2S-bidders we already (started to) synced + }; + if (cfg.complete) { + return cfg; // Most common case, we already have the settings we need (and we won't re-read them) + } + configByBidder[bidder] = cfg; + const bidderConfiguration = config.getConfig(bidder) || {}; + + // Read settings set by setConfig({ [bidder]: { ... }}) and if not available - from bid params + FIELDS.forEach(({ name, checkParams }) => { + cfg[name] = bidderConfiguration[name] || cfg[name]; + if (!cfg[name] && checkParams) { + bids.forEach((bid) => { + cfg[name] = cfg[name] || bid.params?.[name]; + }); + } + }); + cfg.complete = FIELDS.every((field) => !field.required || cfg[field.name]); + if (cfg.complete) { + cfg.pbsHost = cfg.pbsHost.trim().replace('http://', 'https://'); + if (cfg.pbsHost.indexOf('https://') < 0) { + cfg.pbsHost = `https://${cfg.pbsHost}`; + } + } + return cfg; +} + +const converter = ortbConverter({ + context: { + netRevenue: true, + ttl: 300 + }, + processors: pbsExtensions, + imp(buildImp, bidRequest, context) { + // Set stored request id from placementId + const imp = buildImp(bidRequest, context); + const { placementId } = bidRequest.params; + deepSetValue(imp, 'ext.prebid.storedrequest.id', placementId); + delete imp.ext.prebid.bidder; + return imp; + }, + overrides: { + bidResponse: { + bidderCode(orig, bidResponse, bid, { bidRequest }) { + const { bidder, params = {} } = bidRequest || {}; + let useSourceBidderCode = configByBidder[bidder]?.useSourceBidderCode; + if ('useSourceBidderCode' in params) { + useSourceBidderCode = params.useSourceBidderCode; + } + // Only use the orignal function when useSourceBidderCode is true, else our own bidder code will be used + if (useSourceBidderCode) { + orig.apply(this, [...arguments].slice(1)); + } + }, + }, + } +}); + +export const spec = { + code: BIDDER_CODE, + gvlid: 1100, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + /** We need both params.placementId + a complete configuration (pbsHost + accountId) to continue **/ + isBidRequestValid: (bid) => bid.params?.placementId && getBidderConfig([bid]).complete, + + /** Trigger impression-pixel */ + onBidWon: ({pbsWurl}) => pbsWurl && triggerPixel(pbsWurl), + + /** Build BidRequest for PBS */ + buildRequests(bidRequests, bidderRequest) { + const { bidder } = bidRequests[0]; + const cfg = getBidderConfig(bidRequests); + const data = converter.toORTB({bidRequests, bidderRequest}); + + /** Set tmax, in general this will be timeout - pbsBufferMs */ + const pbjsTimeout = bidderRequest.timeout || 1000; + data.tmax = Math.min(Math.max(pbjsTimeout - cfg.pbsBufferMs, cfg.pbsBufferMs), pbjsTimeout); + + delete data.ext?.prebid?.aliases; // We don't need/want to send aliases to PBS + deepSetValue(data, 'ext.relevant', { + ...data.ext?.relevant, + adapter: true, // For internal analytics + }); + deepSetValue(data, 'ext.prebid.storedrequest.id', cfg.accountId); + data.ext.prebid.passthrough = { + ...data.ext.prebid.passthrough, + relevant: { bidder }, // to find config for the right bidder-code in interpretResponse / getUserSyncs + }; + return [{ + method: 'POST', + url: `${cfg.pbsHost}/openrtb2/auction`, + data + }]; + }, + + /** Read BidResponse from PBS and make necessary adjustments to not make it appear to come from unknown bidders */ + interpretResponse(response, request) { + const resp = deepClone(response.body); + const { bidder } = request.data.ext.prebid.passthrough.relevant; + + // Modify response times / errors for actual PBS bidders into a single value + const MODIFIERS = { + responsetimemillis: (values) => Math.max(...values), + errors: (values) => [].concat(...values), + }; + Object.entries(MODIFIERS).forEach(([field, combineFn]) => { + const obj = resp.ext?.[field]; + if (!isEmpty(obj)) { + resp.ext[field] = {[bidder]: combineFn(Object.values(obj))}; + } + }); + + const bids = converter.fromORTB({response: resp, request: request.data}).bids; + return bids; + }, + + /** Do syncing, but avoid running the sync > 1 time for S2S bidders */ + getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { + if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) { + return []; + } + const syncs = []; + serverResponses.forEach(({ body }) => { + const { pbsHost, syncedBidders } = configByBidder[body.ext.prebid.passthrough.relevant.bidder] || {}; + if (!pbsHost) { + return; + } + const { gdprApplies, consentString } = gdprConsent || {}; + let bidders = Object.keys(body.ext?.responsetimemillis || {}); + bidders = bidders.reduce((acc, curr) => { + if (!syncedBidders[curr]) { + acc.push(curr); + syncedBidders[curr] = true; + } + return acc; + }, []); + bidders = shuffle(bidders).slice(0, MAX_SYNC_COUNT); // Shuffle to not always leave out the same bidders + if (!bidders.length) { + return; // All bidders already synced + } + if (syncOptions.iframeEnabled) { + const params = { + endpoint: `${pbsHost}/cookie_sync`, + max_sync_count: bidders.length, + gdpr: gdprApplies ? 1 : 0, + gdpr_consent: consentString, + us_privacy: uspConsent, + bidders: bidders.join(','), + }; + const qs = Object.entries(params) + .filter(([k, v]) => ![null, undefined, ''].includes(v)) + .map(([k, v]) => `${k}=${encodeURIComponent(v.toString())}`) + .join('&'); + syncs.push({ type: 'iframe', url: `${SYNC_HTML}?${qs}` }); + } else { // Else, try to pixel-sync (for future-compatibility) + const pixels = deepAccess(body, `ext.relevant.sync`, []).filter(({ type }) => type === 'redirect'); + syncs.push(...pixels.map(({ url }) => ({ type: 'image', url }))); + } + }); + return syncs; + }, +}; + +registerBidder(spec); diff --git a/modules/relevantdigitalBidAdapter.md b/modules/relevantdigitalBidAdapter.md new file mode 100644 index 00000000000..d54e3e95137 --- /dev/null +++ b/modules/relevantdigitalBidAdapter.md @@ -0,0 +1,117 @@ +# Overview + +``` +Module Name: Relevant Digital Bid Adapter +Module Type: Bidder Adapter +Maintainer: support@relevant-digital.com +``` + +# Description + +This adapter is used for integration with providers using the **[Relevant Yield](https://www.relevant-digital.com/relevantyield)** platform. The provider will supply the necessary **pbsHost** and **accountId** settings along with the **placementId** bid parameters per ad unit. + +# Example setup using pbjs.setConfig() +This is the recommended method to set the global configuration parameters. +```javascript +pbjs.setConfig({ + relevantdigital: { + pbsHost: 'pbs-example.relevant-digital.com', + accountId: '6204e5fa70e3ad10821b84ff', + }, +}); + +var adUnits = [ + { + code: 'test-div', + mediaTypes: { banner: { sizes: [[300, 250], [320, 320]] }}, + bids: [ + { + bidder: 'relevantdigital', + params: { + placementId: '6204e83a077c5825441b8508_620f9e8e4fe67c1f87cd30ed', + } + } + ], + } +]; +``` +# Example setup using only bid params +This method to set the global configuration parameters (like **pbsHost**) in **params** could simplify integration of a provider for some publishers. Setting different global config-parameters on different bids is not supported in general*, as the first settings found will be used and any subsequent global settings will be ignored. + +  * _The exception is `useSourceBidderCode` which can be overriden individually per ad unit._ +```javascript +var adUnits = [ + { + code: 'test-div', + mediaTypes: { banner: { sizes: [[300, 250], [320, 320]] }}, + bids: [ + { + bidder: 'relevantdigital', + params: { + placementId: '6204e83a077c5825441b8508_620f9e8e4fe67c1f87cd30ed', + pbsHost: 'pbs-example.relevant-digital.com', + accountId: '6204e5fa70e3ad10821b84ff', + } + } + ], + } +]; +``` + +# Example setup with multiple providers +**Notice:** Placements below are _not_ live test placements +```javascript + +pbjs.aliasBidder('relevantdigital', 'providerA'); +pbjs.aliasBidder('relevantdigital', 'providerB'); + +pbjs.setConfig({ + providerA: { + pbsHost: 'pbs-example-a.relevant-digital.com', + accountId: '620533ae7f5bbe1691bbb815', + }, + providerB: { + pbsHost: 'pbs-example-b.relevant-digital.com', + accountId: '990533ae7f5bbe1691bbb815', + }, +}); + +var adUnits = [ + { + code: 'test-div', + mediaTypes: { banner: { sizes: [[300, 250], [320, 320]] }}, + bids: [ + { + bidder: 'providerA', + params: { + placementId: '610525862d7517bfd4bbb81e_620523b7d1dbed6b0fbbb817', + } + }, + { + bidder: 'providerB', + params: { + placementId: '990525862d7517bfd4bbb81e_770523b7d1dbed6b0fbbb817', + } + }, + ], + } +]; +``` + +# Bid Parameters + +| Name | Scope | Description | Example | Type | +|---------------|----------|---------------------------------------------------------|----------------------------|--------------| +| `placementId` | required | The placement id. | `'6204e83a077c5825441b8508_620f9e8e4fe67c1f87cd30ed'` | `String` | +| `pbsHost` | required if not set in config | Host name of the server. | `'pbs-example.relevant-digital.com'` | `String` | +| `accountId` | required if not set in config | The account id. | `'6204e5fa70e3ad10821b84ff'` | `String` | +| `useSourceBidderCode` | optional | Set to `true` in order to use the bidder code of the actual server-side bidder in bid responses. You **MUST** also use `allowAlternateBidderCodes: true` in `bidderSettings` if you enabled this - as otherwise the bids will be rejected.| `true` | `Boolean` | + +# Config Parameters + +| Name | Scope | Description | Example | Type | +|---------------|----------|---------------------------------------------------------|----------------------------|--------------| +| `pbsHost` | required if not set in bid parameters | Host name of the server. | `'pbs-example.relevant-digital.com'` | `String` | +| `accountId` | required if not set in bid parameters | The account id. | `'6204e5fa70e3ad10821b84ff'` | `String` | +| `pbsBufferMs` | optional | How much less in *milliseconds* the server's internal timeout should be compared to the normal Prebid timeout. Default is *250*. To be increased in cases of frequent timeouts. | `250` | `Integer` | +| `useSourceBidderCode` | optional | Set to `true` in order to use the bidder code of the actual server-side bidder in bid responses. You **MUST** also use `allowAlternateBidderCodes: true` in `bidderSettings` if you enabled this - as otherwise the bids will be rejected.| `true` | `Boolean` | diff --git a/modules/reloadBidAdapter.md b/modules/reloadBidAdapter.md deleted file mode 100644 index 42fe11b40b3..00000000000 --- a/modules/reloadBidAdapter.md +++ /dev/null @@ -1,48 +0,0 @@ -# Overview - -Module Name: Reload Bid Adapter - -Module Type: Bidder Adapter - -Maintainer: prebid@reload.net - -# Description - -Prebid module for connecting to Reload - -# Parameters -## Banner - -| Name | Scope | Description | Example | -| :------------ | :------- | :---------------------------------------------- | :--------------------------------- | -| `plcmID` | required | Placement ID (provided by Reload) | "4234897234" | -| `partID` | required | Partition ID (provided by Reload) | "part_01" | -| `opdomID` | required | Internal parameter (provided by Reload) | 0 | -| `bsrvID` | required | Internal parameter (provided by Reload) | 12 | -| `type` | optional | Internal parameter (provided by Reload) | "pcm" | - -# Example ad units -# Test Parameters -``` -var adUnits = [ - // Banner adUnit - { - code: 'banner-div', - mediaTypes: { - banner: { - sizes: [ - [300, 250] - ], - } - }, - bids: [{ - bidder: 'reload', - params: { - plcmID: 'prebid_check', - partID: 'part_4', - opdomID: '0', - bsrvID: 0, - type: 'pcm' - } - }] - }]; \ No newline at end of file diff --git a/modules/resetdigitalBidAdapter.js b/modules/resetdigitalBidAdapter.js index 255ee32629c..8264e0cc9cc 100644 --- a/modules/resetdigitalBidAdapter.js +++ b/modules/resetdigitalBidAdapter.js @@ -1,8 +1,11 @@ - -import { timestamp, deepAccess, getOrigin } from '../src/utils.js'; +import { timestamp, deepAccess, isStr, deepClone } from '../src/utils.js'; +import { getOrigin } from '../libraries/getOrigin/index.js'; import { config } from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; + const BIDDER_CODE = 'resetdigital'; +const CURRENCY = 'USD'; export const spec = { code: BIDDER_CODE, @@ -24,9 +27,11 @@ export const spec = { site: { domain: getOrigin(), iframe: !bidderRequest.refererInfo.reachedTop, + // TODO: the last element in refererInfo.stack is window.location.href, that's unlikely to have been the intent here url: stack && stack.length > 0 ? [stack.length - 1] : null, https: (window.location.protocol === 'https:'), - referrer: bidderRequest.refererInfo.referer + // TODO: is 'page' the right value here? + referrer: bidderRequest.refererInfo.page }, imps: [], user_ids: validBidRequests[0].userId, @@ -40,16 +45,71 @@ export const spec = { }; } + if (bidderRequest && bidderRequest.uspConsent) { + payload.ccpa = bidderRequest.uspConsent; + } + + function getOrtb2Keywords(ortb2Obj) { + const fields = ['site.keywords', 'site.content.keywords', 'user.keywords', 'app.keywords', 'app.content.keywords']; + let result = []; + + fields.forEach(path => { + let keyStr = deepAccess(ortb2Obj, path); + if (isStr(keyStr)) result.push(keyStr); + }); + return result; + } + + // get the ortb2 keywords data (if it exists) + let ortb2 = deepClone(bidderRequest && bidderRequest.ortb2); + let ortb2KeywordsList = getOrtb2Keywords(ortb2); + // get meta keywords data (if it exists) + let metaKeywords = document.getElementsByTagName('meta')['keywords']; + if (metaKeywords && metaKeywords.content) { + metaKeywords = metaKeywords.content.split(','); + } + for (let x = 0; x < validBidRequests.length; x++) { - let req = validBidRequests[x] + let req = validBidRequests[x]; + + let bidFloor = req.params.bidFloor ? req.params.bidFloor : null; + let bidFloorCur = req.params.bidFloor ? req.params.bidFloorCur : null; + + if (typeof req.getFloor === 'function') { + const floorInfo = req.getFloor({ + currency: CURRENCY, + mediaType: BANNER, + size: '*' + }); + if (typeof floorInfo === 'object' && floorInfo.currency === CURRENCY && !isNaN(parseFloat(floorInfo.floor))) { + bidFloor = parseFloat(floorInfo.floor); + bidFloorCur = CURRENCY; + } + } + + // get param kewords (if it exists) + let paramsKeywords = req.params.keywords ? req.params.keywords.split(',') : []; + // merge all keywords + let keywords = ortb2KeywordsList.concat(paramsKeywords).concat(metaKeywords); payload.imps.push({ pub_id: req.params.pubId, + site_id: req.params.siteID ? req.params.siteID : null, + placement_id: req.params.placement ? req.params.placement : null, + position: req.params.position ? req.params.position : null, + bid_floor: bidFloor, + bid_floor_cur: bidFloorCur, + lat_long: req.params.latLong ? req.params.latLong : null, + inventory: req.params.inventory ? req.params.inventory : null, + visitor: req.params.visitor ? req.params.visitor : null, + keywords: keywords.join(','), zone_id: req.params.zoneId, bid_id: req.bidId, + // TODO: fix transactionId leak: https://github.com/prebid/Prebid.js/issues/9781 imp_id: req.transactionId, sizes: req.sizes, force_bid: req.params.forceBid, + coppa: config.getConfig('coppa') === true ? 1 : 0, media_types: deepAccess(req, 'mediaTypes') }); } @@ -59,7 +119,8 @@ export const spec = { return { method: 'POST', url: url, - data: JSON.stringify(payload) + data: JSON.stringify(payload), + bids: validBidRequests }; }, interpretResponse: function(serverResponse, bidRequest) { diff --git a/modules/resetdigitalBidAdapter.md b/modules/resetdigitalBidAdapter.md index 2f9f69b5e84..a368c7f5633 100644 --- a/modules/resetdigitalBidAdapter.md +++ b/modules/resetdigitalBidAdapter.md @@ -21,17 +21,43 @@ Video is supported but requires a publisher supplied renderer at this time. mediaTypes: { banner: { sizes: [[300,250]] + }, + + }, + bids: [ + { + bidder: "resetdigital", + params: { + pubId: "your-pub-id", + site_id: "your-site-id", + forceBid: true, + } } + ] + } + ]; + + + var videoAdUnits = [ + { + code: 'your-div', + mediaTypes: { + video: { + playerSize: [640, 480] + }, + }, bids: [ { bidder: "resetdigital", params: { pubId: "your-pub-id", - forceBid: true + site_id: "your-site-id", + forceBid: true, } } ] } ]; + ``` diff --git a/modules/resultsmediaBidAdapter.md b/modules/resultsmediaBidAdapter.md deleted file mode 100644 index 0b65264c8e4..00000000000 --- a/modules/resultsmediaBidAdapter.md +++ /dev/null @@ -1,47 +0,0 @@ -# Overview - -``` -Module Name: ResultsMedia (resultsmedia.com) Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebid@resultsmedia.COM -``` - -# Description - -Prebid adapter for ResultsMedia RTB. Requires approval and account setup. - -# Test Parameters - -## Web -``` - var adUnits = [{ - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [ - [300, 200] // banner sizes - ], - } - }, - bids: [{ - bidder: 'resultsmedia', - params: { - zoneId: 9999 - } - }] - }, { - code: 'video-ad-player', - mediaTypes: { - video: { - context: 'instream', // or 'outstream' - playerSize: [640, 480] // video player size - } - }, - bids: [{ - bidder: 'resultsmedia', - params: { - zoneId: 9999 - } - }] - }]; -``` \ No newline at end of file diff --git a/modules/retailspotBidAdapter .md b/modules/retailspotBidAdapter .md new file mode 100644 index 00000000000..a9b4cb4bec3 --- /dev/null +++ b/modules/retailspotBidAdapter .md @@ -0,0 +1,32 @@ +# Overview + +Module Name: RetailSpot Bidder Adapter +Module Type: Bidder Adapter +Maintainer: guillaume@retail-spot.io + +# Description + +Module that connects to RetailSpot demand sources. +Banner and Video ad formats are supported. + +# Test Parameters +``` + var adUnits = { + "code": "test-div", + "mediaTypes": { + "banner": { + "sizes": ["300x250"] + }, + "video": { + context: "instream", + playerSize: [[640, 480]] + } + }, + bids: [{ + bidder: "retailspot", + params: { + placement: "test-12345" + } + }] + }; +``` diff --git a/modules/retailspotBidAdapter.js b/modules/retailspotBidAdapter.js new file mode 100644 index 00000000000..616b638e840 --- /dev/null +++ b/modules/retailspotBidAdapter.js @@ -0,0 +1,186 @@ +import {buildUrl, deepAccess, parseSizesInput} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; + +const BIDDER_CODE = 'retailspot'; +const DEFAULT_SUBDOMAIN = 'ssp'; +const PREPROD_SUBDOMAIN = 'ssp-preprod'; +const HOST = 'retail-spot.io'; +const ENDPOINT = '/prebid'; +const DEV_URL = 'http://localhost:8090/prebid'; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + aliases: ['rs'], // short code + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bid) { + const sizes = getSize(getSizeArray(bid)); + const sizeValid = sizes.width > 0 && sizes.height > 0; + + return deepAccess(bid, 'params.placement') && sizeValid; + }, + /** + * Make a server request from the list of BidRequests. + * + * @param {bidRequests} - bidRequests.bids[] is an array of AdUnits and bids + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (bidRequests, bidderRequest) { + const payload = bidderRequest; + payload.rs_pbjs_version = '$prebid.version$'; + + const data = JSON.stringify(payload); + const options = { + withCredentials: true + }; + + const envParam = bidRequests[0].params.env; + var subDomain = DEFAULT_SUBDOMAIN; + if (envParam === 'preprod') { + subDomain = PREPROD_SUBDOMAIN; + } + + let url = buildUrl({ + protocol: 'https', + host: `${subDomain}.${HOST}`, + pathname: ENDPOINT + }); + + if (envParam === 'dev') { + url = DEV_URL; + } + + return { + method: 'POST', + url, + data, + options + }; + }, + /** + * Unpack the response from the server into a list of bids. + * + * @param {*} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, request) { + const bidResponses = []; + var bidRequests = {}; + + try { + bidRequests = JSON.parse(request.data).bids; + } catch (err) { + // json error initial request can't be read + } + + // For this adapter, serverResponse is a list + serverResponse.body.forEach(response => { + const bid = createBid(response, bidRequests); + if (bid) { + bidResponses.push(bid); + } + }); + + return bidResponses; + } +} + +function getSizeArray(bid) { + let inputSize = bid.sizes || []; + + if (bid.mediaTypes && bid.mediaTypes.banner) { + inputSize = bid.mediaTypes.banner.sizes || []; + } + + // handle size in bid.params in formats: [w, h] and [[w,h]]. + if (bid.params && Array.isArray(bid.params.size)) { + inputSize = bid.params.size; + if (!Array.isArray(inputSize[0])) { + inputSize = [inputSize] + } + } + + return parseSizesInput(inputSize); +} + +/* Get parsed size from request size */ +function getSize(sizesArray) { + const parsed = {}; + // the main requested size is the first one + const size = sizesArray[0]; + + if (typeof size !== 'string') { + return parsed; + } + + const parsedSize = size.toUpperCase().split('X'); + const width = parseInt(parsedSize[0], 10); + if (width) { + parsed.width = width; + } + + const height = parseInt(parsedSize[1], 10); + if (height) { + parsed.height = height; + } + + return parsed; +} + +/* Create bid from response */ +function createBid(response, bidRequests) { + if (!response || !response.mediaType || + (response.mediaType === 'video' && !response.vastXml) || + (response.mediaType === 'banner' && !response.ad)) { + return; + } + + const request = bidRequests && bidRequests.length && bidRequests.find(itm => response.requestId === itm.bidId); + // In case we don't retreive the size from the adserver, use the given one. + if (request) { + if (!response.width || response.width === '0') { + response.width = request.width; + } + + if (!response.height || response.height === '0') { + response.height = request.height; + } + } + + const bid = { + bidderCode: BIDDER_CODE, + width: response.width, + height: response.height, + requestId: response.requestId, + ttl: response.ttl || 3600, + creativeId: response.creativeId, + cpm: response.cpm, + netRevenue: response.netRevenue, + currency: response.currency, + meta: response.meta || { advertiserDomains: ['retail-spot.io'] }, + mediaType: response.mediaType + }; + + // retreive video response if present + if (response.mediaType === 'video') { + bid.vastXml = window.atob(response.vastXml); + } else { + bid.ad = response.ad; + } + if (response.adId) { + bid.adId = response.adId; + } + if (response.dealId) { + bid.dealId = response.dealId; + } + + return bid; +} + +registerBidder(spec); diff --git a/modules/revcontentBidAdapter.js b/modules/revcontentBidAdapter.js index 0888e5ad1b4..f1d5521f780 100644 --- a/modules/revcontentBidAdapter.js +++ b/modules/revcontentBidAdapter.js @@ -2,8 +2,11 @@ 'use strict'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { BANNER, NATIVE } from '../src/mediaTypes.js'; -import { triggerPixel, isFn, deepAccess, getAdUnitSizes, parseGPTSingleSizeArrayToRtbSize, _map } from '../src/utils.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import {_map, deepAccess, isFn, parseGPTSingleSizeArrayToRtbSize, triggerPixel} from '../src/utils.js'; +import {parseDomain} from '../src/refererDetection.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; const BIDDER_CODE = 'revcontent'; const NATIVE_PARAMS = { @@ -31,6 +34,9 @@ export const spec = { return (typeof bid.params.apiKey !== 'undefined' && typeof bid.params.userId !== 'undefined'); }, buildRequests: (validBidRequests, bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const userId = validBidRequests[0].params.userId; const widgetId = validBidRequests[0].params.widgetId; const apiKey = validBidRequests[0].params.apiKey; @@ -44,11 +50,11 @@ export const spec = { let serverRequests = []; var refererInfo; if (bidderRequest && bidderRequest.refererInfo) { - refererInfo = bidderRequest.refererInfo.referer; + refererInfo = bidderRequest.refererInfo.page; } if (typeof domain === 'undefined') { - domain = extractHostname(refererInfo); + domain = parseDomain(refererInfo, {noPort: true}); } var endpoint = 'https://' + host + '/rtb?apiKey=' + apiKey + '&userId=' + userId; @@ -60,7 +66,7 @@ export const spec = { const imp = validBidRequests.map((bid, id) => buildImp(bid, id)); let data = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: imp, site: { id: widgetId, @@ -115,8 +121,6 @@ export const spec = { currency: response.cur || 'USD', ttl: 360, netRevenue: true, - bidder: 'revcontent', - bidderCode: 'revcontent' }; if ('banner' in imp) { prBid.mediaType = BANNER; @@ -196,23 +200,6 @@ function getTemplate(size, customTemplate) { return ''; } -function extractHostname(url) { - if (typeof url == 'undefined' || url == null) { - return ''; - } - var hostname; - if (url.indexOf('//') > -1) { - hostname = url.split('/')[2]; - } else { - hostname = url.split('/')[0]; - } - - hostname = hostname.split(':')[0]; - hostname = hostname.split('?')[0]; - - return hostname; -} - function buildImp(bid, id) { let bidfloor; if (isFn(bid.getFloor)) { @@ -229,8 +216,9 @@ function buildImp(bid, id) { id: id + 1, tagid: bid.adUnitCode, bidderRequestId: bid.bidderRequestId, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bid.auctionId, - transactionId: bid.transactionId, + transactionId: bid.ortb2Imp?.ext?.tid, instl: 0, bidfloor: bidfloor, secure: '1' @@ -244,7 +232,7 @@ function buildImp(bid, id) { w: sizes[0][0], h: sizes[0][1], format: sizes.map(wh => parseGPTSingleSizeArrayToRtbSize(wh)), - } + }; } else if (nativeReq) { const assets = _map(bid.nativeParams, (bidParams, key) => { const props = NATIVE_PARAMS[key]; diff --git a/modules/rexrtbBidAdapter.md b/modules/rexrtbBidAdapter.md deleted file mode 100644 index 1cb937b0a3d..00000000000 --- a/modules/rexrtbBidAdapter.md +++ /dev/null @@ -1,32 +0,0 @@ -# Overview - -Module Name: REXRTB Bidder Adapter - -Module Type: Bidder Adapter - -Maintainer: tech@rexrtb.com - - -# Description - -Module that connects to REXRTB's demand source - -# Test Parameters -```javascript - var adUnits = [ - { - code: 'test-ad', - sizes: [[728, 98]], - bids: [ - { - bidder: 'rexrtb', - params: { - id: 89, - token: '658f11a5efbbce2f9be3f1f146fcbc22', - source: 'prebidtest' - } - } - ] - }, - ]; -``` \ No newline at end of file diff --git a/modules/rhythmoneBidAdapter.js b/modules/rhythmoneBidAdapter.js index 9e378f2d2ed..749ab92c0dc 100644 --- a/modules/rhythmoneBidAdapter.js +++ b/modules/rhythmoneBidAdapter.js @@ -16,7 +16,6 @@ function RhythmOneBidAdapter() { let SUPPORTED_VIDEO_DELIVERY = [1]; let SUPPORTED_VIDEO_API = [1, 2, 5]; let slotsToBids = {}; - let that = this; let version = '2.1'; this.isBidRequestValid = function (bid) { @@ -62,25 +61,11 @@ function RhythmOneBidAdapter() { } function frameSite(bidderRequest) { - var site = { - domain: '', - page: '', - ref: '' - } - if (bidderRequest && bidderRequest.refererInfo) { - var ri = bidderRequest.refererInfo; - site.ref = ri.referer; - - if (ri.stack.length) { - site.page = ri.stack[ri.stack.length - 1]; - - // clever trick to get the domain - var el = document.createElement('a'); - el.href = ri.stack[0]; - site.domain = el.hostname; - } + return { + domain: bidderRequest?.refererInfo?.domain || '', + page: bidderRequest?.refererInfo?.page || '', + ref: bidderRequest?.refererInfo?.ref || '' } - return site; } function frameDevice() { @@ -251,7 +236,6 @@ function RhythmOneBidAdapter() { let bidRequest = slotsToBids[bid.impid]; let bidResponse = { requestId: bidRequest.bidId, - bidderCode: that.code, cpm: parseFloat(bid.price), width: bid.w, height: bid.h, diff --git a/modules/richaudienceBidAdapter.js b/modules/richaudienceBidAdapter.js index b49d7c5584c..1625912ddb8 100755 --- a/modules/richaudienceBidAdapter.js +++ b/modules/richaudienceBidAdapter.js @@ -1,8 +1,9 @@ -import {isEmpty, deepAccess, isStr} from '../src/utils.js'; +import {deepAccess, isStr} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import { Renderer } from '../src/Renderer.js'; +import {Renderer} from '../src/Renderer.js'; +import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; const BIDDER_CODE = 'richaudience'; let REFERER = ''; @@ -36,6 +37,7 @@ export const spec = { pid: bid.params.pid, supplyType: bid.params.supplyType, currencyCode: config.getConfig('currency.adServerCurrency'), + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bid.auctionId, bidId: bid.bidId, BidRequestsCount: bid.bidRequestsCount, @@ -43,20 +45,23 @@ export const spec = { bidderRequestId: bid.bidderRequestId, tagId: bid.adUnitCode, sizes: raiGetSizes(bid), - referer: (typeof bidderRequest.refererInfo.referer != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.referer) : null), + // TODO: is 'page' the right value here? + referer: (typeof bidderRequest.refererInfo.page != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.page) : null), numIframes: (typeof bidderRequest.refererInfo.numIframes != 'undefined' ? bidderRequest.refererInfo.numIframes : null), - transactionId: bid.transactionId, + transactionId: bid.ortb2Imp?.ext?.tid, timeout: config.getConfig('bidderTimeout'), user: raiSetEids(bid), demand: raiGetDemandType(bid), videoData: raiGetVideoInfo(bid), scr_rsl: raiGetResolution(), cpuc: (typeof window.navigator != 'undefined' ? window.navigator.hardwareConcurrency : null), - kws: (!isEmpty(bid.params.keywords) ? bid.params.keywords : null), - schain: bid.schain + kws: getAllOrtbKeywords(bidderRequest.ortb2, bid.params.keywords).join(','), + schain: bid.schain, + gpid: raiSetPbAdSlot(bid) }; - REFERER = (typeof bidderRequest.refererInfo.referer != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.referer) : null) + // TODO: is 'page' the right value here? + REFERER = (typeof bidderRequest.refererInfo.page != 'undefined' ? encodeURIComponent(bidderRequest.refererInfo.page) : null) payload.gdpr_consent = ''; payload.gdpr = false; @@ -130,7 +135,7 @@ export const spec = { bidResponses.push(bidResponse); } - return bidResponses + return bidResponses; }, /*** * User Syncs @@ -281,6 +286,14 @@ function raiGetResolution() { return resolution; } +function raiSetPbAdSlot(bid) { + let pbAdSlot = ''; + if (deepAccess(bid, 'ortb2Imp.ext.data.pbadslot') != null) { + pbAdSlot = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot') + } + return pbAdSlot +} + function raiGetSyncInclude(config) { try { let raConfig = null; diff --git a/modules/riseBidAdapter.js b/modules/riseBidAdapter.js index a8ea023d46a..78740f7f87d 100644 --- a/modules/riseBidAdapter.js +++ b/modules/riseBidAdapter.js @@ -1,4 +1,16 @@ -import { logWarn, logInfo, isArray, isFn, deepAccess, isEmpty, contains, timestamp, getBidIdParameter, triggerPixel, isInteger } from '../src/utils.js'; +import { + logWarn, + logInfo, + isArray, + isFn, + deepAccess, + isEmpty, + contains, + timestamp, + triggerPixel, + isInteger, + getBidIdParameter +} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; @@ -8,7 +20,7 @@ const BIDDER_CODE = 'rise'; const ADAPTER_VERSION = '6.0.0'; const TTL = 360; const CURRENCY = 'USD'; -const SELLER_ENDPOINT = 'https://hb.yellowblue.io/'; +const DEFAULT_SELLER_ENDPOINT = 'https://hb.yellowblue.io/'; const MODES = { PRODUCTION: 'hb-multi', TEST: 'hb-multi-test' @@ -42,13 +54,14 @@ export const spec = { // use data from the first bid, to create the general params for all bids const generalObject = validBidRequests[0]; const testMode = generalObject.params.testMode; + const rtbDomain = generalObject.params.rtbDomain; combinedRequestsObject.params = generateGeneralParams(generalObject, bidderRequest); combinedRequestsObject.bids = generateBidsParams(validBidRequests, bidderRequest); return { method: 'POST', - url: getEndpoint(testMode), + url: getEndpoint(testMode, rtbDomain), data: combinedRequestsObject } }, @@ -223,9 +236,11 @@ function isSyncMethodAllowed(syncRule, bidderCode) { /** * Get the seller endpoint * @param testMode {boolean} + * @param rtbDomain {string} * @returns {string} */ -function getEndpoint(testMode) { +function getEndpoint(testMode, rtbDomain) { + const SELLER_ENDPOINT = rtbDomain ? `https://${rtbDomain}/` : DEFAULT_SELLER_ENDPOINT; return testMode ? SELLER_ENDPOINT + MODES.TEST : SELLER_ENDPOINT + MODES.PRODUCTION; @@ -287,7 +302,9 @@ function generateBidParameters(bid, bidderRequest) { floorPrice: Math.max(getFloor(bid, mediaType), params.floorPrice), bidId: getBidIdParameter('bidId', bid), bidderRequestId: getBidIdParameter('bidderRequestId', bid), - transactionId: getBidIdParameter('transactionId', bid), + loop: getBidIdParameter('bidderRequestsCount', bid), + transactionId: bid.ortb2Imp?.ext?.tid, + coppa: 0 }; const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`); @@ -305,6 +322,26 @@ function generateBidParameters(bid, bidderRequest) { bidObject.placementId = placementId; } + const mimes = deepAccess(bid, `mediaTypes.${mediaType}.mimes`); + if (mimes) { + bidObject.mimes = mimes; + } + + const api = deepAccess(bid, `mediaTypes.${mediaType}.api`); + if (api) { + bidObject.api = api; + } + + const sua = deepAccess(bid, `ortb2.device.sua`); + if (sua) { + bidObject.sua = sua; + } + + const coppa = deepAccess(bid, `ortb2.regs.coppa`) + if (coppa) { + bidObject.coppa = 1; + } + if (mediaType === VIDEO) { const playbackMethod = deepAccess(bid, `mediaTypes.video.playbackmethod`); let playbackMethodValue; @@ -345,6 +382,16 @@ function generateBidParameters(bid, bidderRequest) { if (linearity) { bidObject.linearity = linearity; } + + const protocols = deepAccess(bid, `mediaTypes.video.protocols`); + if (protocols) { + bidObject.protocols = protocols; + } + + const plcmt = deepAccess(bid, `mediaTypes.video.plcmt`); + if (plcmt) { + bidObject.plcmt = plcmt; + } } return bidObject; @@ -365,7 +412,7 @@ function generateGeneralParams(generalObject, bidderRequest) { const {syncEnabled, filterSettings} = config.getConfig('userSync') || {}; const {bidderCode} = bidderRequest; const generalBidParams = generalObject.params; - const timeout = config.getConfig('bidderTimeout'); + const timeout = bidderRequest.timeout; // these params are snake_case instead of camelCase to allow backwards compatability on the server. // in the future, these will be converted to camelCase to match our convention. @@ -381,16 +428,17 @@ function generateGeneralParams(generalObject, bidderRequest) { dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, device_type: getDeviceType(navigator.userAgent), ua: navigator.userAgent, - session_id: getBidIdParameter('auctionId', generalObject), + is_wrapper: !!generalBidParams.isWrapper, + session_id: generalBidParams.sessionId || getBidIdParameter('bidderRequestId', generalObject), tmax: timeout - } + }; const userIdsParam = getBidIdParameter('userId', generalObject); if (userIdsParam) { generalParams.userIds = JSON.stringify(userIdsParam); } - const ortb2Metadata = config.getConfig('ortb2') || {}; + const ortb2Metadata = bidderRequest.ortb2 || {}; if (ortb2Metadata.site) { generalParams.site_metadata = JSON.stringify(ortb2Metadata.site); } @@ -423,9 +471,11 @@ function generateGeneralParams(generalObject, bidderRequest) { } if (bidderRequest && bidderRequest.refererInfo) { - generalParams.referrer = deepAccess(bidderRequest, 'refererInfo.referer'); - generalParams.page_url = config.getConfig('pageUrl') || deepAccess(window, 'location.href'); + // TODO: is 'ref' the right value here? + generalParams.referrer = deepAccess(bidderRequest, 'refererInfo.ref'); + // TODO: does the fallback make sense here? + generalParams.page_url = deepAccess(bidderRequest, 'refererInfo.page') || deepAccess(window, 'location.href'); } - return generalParams + return generalParams; } diff --git a/modules/riseBidAdapter.md b/modules/riseBidAdapter.md index 83f8adfd645..f0837cb5508 100644 --- a/modules/riseBidAdapter.md +++ b/modules/riseBidAdapter.md @@ -20,10 +20,13 @@ The adapter supports Video(instream). | Name | Scope | Type | Description | Example | ---- | ----- | ---- | ----------- | ------- -| `org` | required | String | Rise publisher Id provided by your Rise representative | "56f91cd4d3e3660002000033" +| `org` | required | String | Rise publisher Id provided by your Rise representative | "1234567890abcdef12345678" | `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 2.00 | `placementId` | optional | String | A unique placement identifier | "12345678" | `testMode` | optional | Boolean | This activates the test mode | false +| `rtbDomain` | optional | String | Sets the seller end point | "www.test.com" +| `is_wrapper` | private | Boolean | Please don't use unless your account manager asked you to | false + # Test Parameters ```javascript @@ -40,10 +43,11 @@ var adUnits = [ bids: [{ bidder: 'rise', params: { - org: '56f91cd4d3e3660002000033', // Required + org: '1234567890abcdef12345678', // Required floorPrice: 2.00, // Optional placementId: '12345678', // Optional - testMode: false // Optional + testMode: false, // Optional, + rtbDomain: "www.test.com" //Optional } }] } diff --git a/modules/rivrAnalyticsAdapter.js b/modules/rivrAnalyticsAdapter.js index 279b1b13051..c74ce519ab9 100644 --- a/modules/rivrAnalyticsAdapter.js +++ b/modules/rivrAnalyticsAdapter.js @@ -1,7 +1,8 @@ import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import * as utils from '../src/utils.js'; +import {getGlobal} from '../src/prebidGlobal.js'; const analyticsType = 'endpoint'; @@ -20,7 +21,7 @@ rivrAnalytics.originEnableAnalytics = rivrAnalytics.enableAnalytics; // override enableAnalytics so we can get access to the config passed in from the page rivrAnalytics.enableAnalytics = (config) => { if (window.rivraddon && window.rivraddon.analytics) { - window.rivraddon.analytics.enableAnalytics(config, {utils, ajax, pbjsGlobalVariable: $$PREBID_GLOBAL$$}); + window.rivraddon.analytics.enableAnalytics(config, {utils, ajax, pbjsGlobalVariable: getGlobal()}); rivrAnalytics.originEnableAnalytics(config); } }; diff --git a/modules/rockyouBidAdapter.md b/modules/rockyouBidAdapter.md deleted file mode 100644 index 1c6d2708b99..00000000000 --- a/modules/rockyouBidAdapter.md +++ /dev/null @@ -1,58 +0,0 @@ -# Overview - -``` -Module Name: RockYou Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebid.adapter@rockyou.com -``` - -# Description - -Connects to the RockYou exchange for bids. - -The RockYou bid adapter supports Banner and Video. - -For publishers who wish to be set up on the RockYou Ad Network, please contact -publishers@rockyou.com. - -RockYou user syncing requires the `userSync.iframeEnabled` property be set to `true`. - -# Test PARAMETERS -``` -var adUnits = [ - - // Banner adUnit - { - code: 'banner-div', - mediaTypes: { - banner: { - sizes: [[720, 480]] - } - }, - - bids: [{ - bidder: 'rockyou', - params: { - placementId: '4954' - } - }] - }, - - // Video (outstream) - { - code: 'video-outstream', - mediaTypes: { - video: { - context: 'outstream', - playerSize: [720, 480] - } - }, - bids: [{ - bidder: 'rockyou', - params: { - placementId: '4957' - } - }] - } -] -``` diff --git a/modules/roxotAnalyticsAdapter.js b/modules/roxotAnalyticsAdapter.js index b11898b9ea8..2c3be3e1757 100644 --- a/modules/roxotAnalyticsAdapter.js +++ b/modules/roxotAnalyticsAdapter.js @@ -1,12 +1,15 @@ import {deepClone, getParameterByName, logError, logInfo} from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import {includes} from '../src/polyfill.js'; import {ajaxBuilder} from '../src/ajax.js'; import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; -const storage = getStorageManager(); +const MODULE_CODE = 'roxot'; + +const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); let ajax = ajaxBuilder(0); @@ -504,7 +507,7 @@ function buildLogMessage(message) { adapterManager.registerAnalyticsAdapter({ adapter: roxotAdapter, - code: 'roxot' + code: MODULE_CODE, }); export default roxotAdapter; diff --git a/modules/rtbdemandBidAdapter.md b/modules/rtbdemandBidAdapter.md deleted file mode 100644 index 2727d85e084..00000000000 --- a/modules/rtbdemandBidAdapter.md +++ /dev/null @@ -1,26 +0,0 @@ -# Overview - -**Module Name**: Rtbdemand Media fmxSSP Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: rtb@rtbdemand.com - -# Description - -Connects to Rtbdemand Media fmxSSP demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [{ - code: 'banner-ad-div', - sizes: [[300, 250]], - bids: [{ - bidder: 'rtbdemand', - params: { - zoneid: '9999', - floor: 0.005, - server: 'bidding.rtbdemand.com' - } - }] - }]; - -``` diff --git a/modules/rtbdemandadkBidAdapter.md b/modules/rtbdemandadkBidAdapter.md deleted file mode 100644 index 96bd3f6c8d7..00000000000 --- a/modules/rtbdemandadkBidAdapter.md +++ /dev/null @@ -1,45 +0,0 @@ -# Overview - -``` -Module Name: Rtbdemandadk Bidder Adapter -Module Type: Bidder Adapter -Maintainer: shreyanschopra@rtbdemand.com -``` - -# Description - -Connects to Rtbdemandadk whitelabel platform. -Banner and video formats are supported. - - -# Test Parameters -``` - var adUnits = [ - { - code: 'banner-ad-div', - sizes: [[300, 250]], // banner size - bids: [ - { - bidder: 'rtbdemandadk', - params: { - zoneId: '30164', //required parameter - host: 'cpm.metaadserving.com' //required parameter - } - } - ] - }, { - code: 'video-ad-player', - sizes: [640, 480], // video player size - bids: [ - { - bidder: 'rtbdemandadk', - mediaType : 'video', - params: { - zoneId: '30164', //required parameter - host: 'cpm.metaadserving.com' //required parameter - } - } - ] - } - ]; -``` diff --git a/modules/rtbhouseBidAdapter.js b/modules/rtbhouseBidAdapter.js index b8436179a30..4ca4e4f90a9 100644 --- a/modules/rtbhouseBidAdapter.js +++ b/modules/rtbhouseBidAdapter.js @@ -1,11 +1,18 @@ -import {deepAccess, getOrigin, isArray, logError} from '../src/utils.js'; +import {deepAccess, isArray, logError, logInfo, mergeDeep} from '../src/utils.js'; +import {getOrigin} from '../libraries/getOrigin/index.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {includes} from '../src/polyfill.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +import {config} from '../src/config.js'; const BIDDER_CODE = 'rtbhouse'; const REGIONS = ['prebid-eu', 'prebid-us', 'prebid-asia']; const ENDPOINT_URL = 'creativecdn.com/bidder/prebid/bids'; +const FLEDGE_ENDPOINT_URL = 'creativecdn.com/bidder/prebidfledge/bids'; +const FLEDGE_SELLER_URL = 'https://fledge-ssp.creativecdn.com'; +const FLEDGE_DECISION_LOGIC_URL = 'https://fledge-ssp.creativecdn.com/component-seller-prebid.js'; + const DEFAULT_CURRENCY_ARR = ['USD']; // NOTE - USD is the only supported currency right now; Hardcoded for bids const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE]; const TTL = 55; @@ -43,14 +50,18 @@ export const spec = { return !!(includes(REGIONS, bid.params.region) && bid.params.publisherId); }, buildRequests: function (validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + const request = { - id: validBidRequests[0].auctionId, - imp: validBidRequests.map(slot => mapImpression(slot)), + id: bidderRequest.bidderRequestId, + imp: validBidRequests.map(slot => mapImpression(slot, bidderRequest)), site: mapSite(validBidRequests, bidderRequest), cur: DEFAULT_CURRENCY_ARR, test: validBidRequests[0].params.test || 0, - source: mapSource(validBidRequests[0]), + source: mapSource(validBidRequests[0], bidderRequest), }; + if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { const consentStr = (bidderRequest.gdprConsent.consentString) ? bidderRequest.gdprConsent.consentString.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '') : ''; @@ -63,7 +74,7 @@ export const spec = { if (schain) { request.ext = { schain: schain, - } + }; } } @@ -76,13 +87,33 @@ export const spec = { } } + const ortb2Params = bidderRequest?.ortb2 || {}; + ['site', 'user', 'device', 'bcat', 'badv'].forEach(entry => { + const ortb2Param = ortb2Params[entry]; + if (ortb2Param) { + mergeDeep(request, { [entry]: ortb2Param }); + } + }); + + let computedEndpointUrl = ENDPOINT_URL; + + if (bidderRequest.fledgeEnabled) { + const fledgeConfig = config.getConfig('fledgeConfig') || { + seller: FLEDGE_SELLER_URL, + decisionLogicUrl: FLEDGE_DECISION_LOGIC_URL, + sellerTimeout: 500 + }; + mergeDeep(request, { ext: { fledge_config: fledgeConfig } }); + computedEndpointUrl = FLEDGE_ENDPOINT_URL; + } + return { method: 'POST', - url: 'https://' + validBidRequests[0].params.region + '.' + ENDPOINT_URL, + url: 'https://' + validBidRequests[0].params.region + '.' + computedEndpointUrl, data: JSON.stringify(request) }; }, - interpretResponse: function (serverResponse, originalRequest) { + interpretOrtbResponse: function (serverResponse, originalRequest) { const responseBody = serverResponse.body; if (!isArray(responseBody)) { return []; @@ -90,17 +121,74 @@ export const spec = { const bids = []; responseBody.forEach(serverBid => { - if (serverBid.price === 0) { + if (!serverBid.price) { // price may exist and is === 0 or there's no price prop at all (fledge req case) return; } + + let interpretedBid; + // try...catch would be risky cause JSON.parse throws SyntaxError if (serverBid.adm.indexOf('{') === 0) { - bids.push(interpretNativeBid(serverBid)); + interpretedBid = interpretNativeBid(serverBid); } else { - bids.push(interpretBannerBid(serverBid)); + interpretedBid = interpretBannerBid(serverBid); } + if (serverBid.ext) interpretedBid.ext = serverBid.ext; + + bids.push(interpretedBid); }); return bids; + }, + interpretResponse: function (serverResponse, originalRequest) { + let bids; + + const responseBody = serverResponse.body; + let fledgeAuctionConfigs = null; + + if (responseBody.bidid && isArray(responseBody?.ext?.igbid)) { + // we have fledge response + // mimic the original response ([{},...]) + bids = this.interpretOrtbResponse({ body: responseBody.seatbid[0]?.bid }, originalRequest); + + const seller = responseBody.ext.seller; + const decisionLogicUrl = responseBody.ext.decisionLogicUrl; + const sellerTimeout = 'sellerTimeout' in responseBody.ext ? { sellerTimeout: responseBody.ext.sellerTimeout } : {}; + responseBody.ext.igbid.forEach((igbid) => { + const perBuyerSignals = {}; + igbid.igbuyer.forEach(buyerItem => { + perBuyerSignals[buyerItem.igdomain] = buyerItem.buyersignal + }); + fledgeAuctionConfigs = fledgeAuctionConfigs || {}; + fledgeAuctionConfigs[igbid.impid] = mergeDeep( + { + seller, + decisionLogicUrl, + interestGroupBuyers: Object.keys(perBuyerSignals), + perBuyerSignals, + }, + sellerTimeout + ); + }); + } else { + bids = this.interpretOrtbResponse(serverResponse, originalRequest); + } + + if (fledgeAuctionConfigs) { + fledgeAuctionConfigs = Object.entries(fledgeAuctionConfigs).map(([bidId, cfg]) => { + return { + bidId, + config: Object.assign({ + auctionSignals: {} + }, cfg) + } + }); + logInfo('Response with FLEDGE:', { bids, fledgeAuctionConfigs }); + return { + bids, + fledgeAuctionConfigs, + } + } + return bids; } }; registerBidder(spec); @@ -125,7 +213,7 @@ function applyFloor(slot) { * @param {object} slot Ad Unit Params by Prebid * @returns {object} Imp by OpenRTB 2.5 §3.2.4 */ -function mapImpression(slot) { +function mapImpression(slot, bidderRequest) { const imp = { id: slot.bidId, banner: mapBanner(slot), @@ -138,6 +226,21 @@ function mapImpression(slot) { imp.bidfloor = bidfloor; } + if (bidderRequest.fledgeEnabled) { + imp.ext = imp.ext || {}; + imp.ext.ae = slot?.ortb2Imp?.ext?.ae + } else { + if (imp.ext?.ae) { + delete imp.ext.ae; + } + } + + const tid = deepAccess(slot, 'ortb2Imp.ext.tid'); + if (tid) { + imp.ext = imp.ext || {}; + imp.ext.tid = tid; + } + return imp; } @@ -180,7 +283,7 @@ function mapSite(slot, bidderRequest) { publisher: { id: pubId.toString(), }, - page: bidderRequest.refererInfo.referer, + page: bidderRequest.refererInfo.page, name: getOrigin() }; if (channel) { @@ -193,9 +296,9 @@ function mapSite(slot, bidderRequest) { * @param {object} slot Ad Unit Params by Prebid * @returns {object} Source by OpenRTB 2.5 §3.2.2 */ -function mapSource(slot) { +function mapSource(slot, bidderRequest) { const source = { - tid: slot.transactionId, + tid: bidderRequest?.auctionId || '', }; return source; @@ -380,7 +483,7 @@ function interpretNativeBid(serverBid) { function interpretNativeAd(adm) { const native = JSON.parse(adm).native; const result = { - clickUrl: encodeURIComponent(native.link.url), + clickUrl: encodeURI(native.link.url), impressionTrackers: native.imptrackers }; native.assets.forEach(asset => { @@ -390,14 +493,14 @@ function interpretNativeAd(adm) { break; case OPENRTB.NATIVE.ASSET_ID.IMAGE: result.image = { - url: encodeURIComponent(asset.img.url), + url: encodeURI(asset.img.url), width: asset.img.w, height: asset.img.h }; break; case OPENRTB.NATIVE.ASSET_ID.ICON: result.icon = { - url: encodeURIComponent(asset.img.url), + url: encodeURI(asset.img.url), width: asset.img.w, height: asset.img.h }; diff --git a/modules/rtbhouseBidAdapter.md b/modules/rtbhouseBidAdapter.md index b8b59aa9edc..338ba6b4df4 100644 --- a/modules/rtbhouseBidAdapter.md +++ b/modules/rtbhouseBidAdapter.md @@ -65,3 +65,46 @@ Please reach out to pmp@rtbhouse.com to receive your own } ]; ``` + +# Protected Audience API (FLEDGE) support +There’s an option to receive demand for Protected Audience API (FLEDGE/PAAPI) +ads using RTB House bid adapter. +Prebid’s [fledgeForGpt](https://docs.prebid.org/dev-docs/modules/fledgeForGpt.html) +module and Google Ad Manager is currently required. + +The following steps should be taken to setup Protected Audience for RTB House: + +1. Reach out to your RTB House representative for setup coordination. + +2. Build and enable FLEDGE module as described in +[fledgeForGpt](https://docs.prebid.org/dev-docs/modules/fledgeForGpt.html) +module documentation. + + a. Make sure to enable RTB House bidder to participate in FLEDGE. If there are any other bidders to be allowed for that, add them to the **bidders** array: + ```javascript + pbjs.setBidderConfig({ + bidders: ["rtbhouse"], + config: { + fledgeEnabled: true + } + }); + ``` + + b. If you as a publisher have your own [decisionLogicUrl](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction) + you may utilize it by setting up a dedicated `fledgeConfig` object: + ```javascript + pbjs.setBidderConfig({ + bidders: ["rtbhouse"], + config: { + fledgeEnabled: true, + fledgeConfig: { + seller: 'https://seller.domain', + decisionLogicUrl: 'https://seller.domain/decisionLogicFile.js', + sellerTimeout: 100 + } + } + }); + ``` + The `decisionLogicUrl` must be in the same domain as `seller` and has to respond with `X-Allow-FLEDGE: true` http header. + + `sellerTimeout` is optional, defaults to 50 as per spec, will be clamped to 500 if greater. diff --git a/modules/rtbsapeBidAdapter.js b/modules/rtbsapeBidAdapter.js index d58b3a1f240..5b1a92b02a0 100644 --- a/modules/rtbsapeBidAdapter.js +++ b/modules/rtbsapeBidAdapter.js @@ -39,11 +39,13 @@ export const spec = { url: ENDPOINT, method: 'POST', data: { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidderRequest.auctionId, requestId: bidderRequest.bidderRequestId, bids: validBidRequests, timezone: (tz > 0 ? '-' : '+') + padInt(Math.floor(Math.abs(tz) / 60)) + ':' + padInt(Math.abs(tz) % 60), - refererInfo: bidderRequest.refererInfo + // TODO: please do not send internal data structures over the network + refererInfo: bidderRequest.refererInfo.legacy }, } }, diff --git a/modules/rtbsolutionsBidAdapter.md b/modules/rtbsolutionsBidAdapter.md deleted file mode 100644 index e671de306a0..00000000000 --- a/modules/rtbsolutionsBidAdapter.md +++ /dev/null @@ -1,128 +0,0 @@ -# Overview - -Module Name: Rtbsolutions Bidder Adapter -Module Type: Bidder Adapter -Maintainer: info@rtbsolutions.pro - -# Description - -You can use this adapter to get a bid from rtbsolutions. - -About us: http://rtbsolutions.pro - - -# Test Parameters -```javascript - var adUnits = [ - { - code: '/19968336/header-bid-tag-1', - mediaTypes: { - banner: { - sizes: sizes - } - }, - bids: [{ - bidder: 'rtbsolutions', - params: { - blockId: 777, - s1: 'sub_1', - s2: 'sub_2', - s3: 'sub_3', - s4: 'sub_4' - } - }] - }]; -``` - -Where: - -* blockId - Block ID from platform (required) -* s1..s4 - Sub Id (optional) - -# Example page - -```html - - - - - Prebid - - - - - -

Prebid

-
Div-1
-
- -
- - -``` diff --git a/modules/rtdModule/index.js b/modules/rtdModule/index.js index 381059c68f7..633c4f4cdc1 100644 --- a/modules/rtdModule/index.js +++ b/modules/rtdModule/index.js @@ -108,6 +108,13 @@ * @param {UserConsentData} userConsent */ +/** + * @function? + * @summary on data deletion request + * @name RtdSubmodule#onDataDeletionRequest + * @param {SubmoduleConfig} config + */ + /** * @interface ModuleConfig */ @@ -152,13 +159,19 @@ */ import {config} from '../../src/config.js'; -import {module} from '../../src/hook.js'; +import {getHook, module} from '../../src/hook.js'; import {logError, logInfo, logWarn} from '../../src/utils.js'; import * as events from '../../src/events.js'; import CONSTANTS from '../../src/constants.json'; -import {gdprDataHandler, uspDataHandler} from '../../src/adapterManager.js'; +import adapterManager, {gdprDataHandler, uspDataHandler, gppDataHandler} from '../../src/adapterManager.js'; import {find} from '../../src/polyfill.js'; -import {getGlobal} from '../../src/prebidGlobal.js'; +import {timedAuctionHook} from '../../src/utils/perfMetrics.js'; +import {GDPR_GVLIDS} from '../../src/consentHandler.js'; +import {MODULE_TYPE_RTD} from '../../src/activities/modules.js'; +import {guardOrtb2Fragments} from '../../libraries/objectGuard/ortbGuard.js'; +import {activityParamsBuilder} from '../../src/activities/params.js'; + +const activityParams = activityParamsBuilder((al) => adapterManager.resolveAlias(al)); /** @type {string} */ const MODULE_NAME = 'realTimeData'; @@ -181,6 +194,7 @@ let _userConsent; */ export function attachRealTimeDataProvider(submodule) { registeredSubModules.push(submodule); + GDPR_GVLIDS.register(MODULE_TYPE_RTD, submodule.name, submodule.gvlid) return function detach() { const idx = registeredSubModules.indexOf(submodule) if (idx >= 0) { @@ -229,7 +243,8 @@ export function init(config) { _moduleConfig = realTimeData; _dataProviders = realTimeData.dataProviders; setEventsListeners(); - getGlobal().requestBids.before(setBidRequestsData, 40); + getHook('startAuction').before(setBidRequestsData, 20); // RTD should run before FPD + adapterManager.callDataDeletionRequest.before(onDataDeletionRequest); initSubModules(); }); } @@ -238,6 +253,7 @@ function getConsentData() { return { gdpr: gdprDataHandler.getConsentData(), usp: uspDataHandler.getConsentData(), + gpp: gppDataHandler.getConsentData(), coppa: !!(config.getConfig('coppa')) } } @@ -267,7 +283,7 @@ function initSubModules() { * @param {Object} reqBidsConfigObj required; This is the same param that's used in pbjs.requestBids. * @param {function} fn required; The next function in the chain, used by hook.js */ -export function setBidRequestsData(fn, reqBidsConfigObj) { +export const setBidRequestsData = timedAuctionHook('rtd', function setBidRequestsData(fn, reqBidsConfigObj) { _userConsent = getConsentData(); const relevantSubModules = []; @@ -287,6 +303,7 @@ export function setBidRequestsData(fn, reqBidsConfigObj) { let callbacksExpected = prioritySubModules.length; let isDone = false; let waitTimeout; + const verifiers = []; if (!relevantSubModules.length) { return exitHook(); @@ -295,7 +312,12 @@ export function setBidRequestsData(fn, reqBidsConfigObj) { waitTimeout = setTimeout(exitHook, shouldDelayAuction ? _moduleConfig.auctionDelay : 0); relevantSubModules.forEach(sm => { - sm.getBidRequestData(reqBidsConfigObj, onGetBidRequestDataCallback.bind(sm), sm.config, _userConsent) + const fpdGuard = guardOrtb2Fragments(reqBidsConfigObj.ortb2Fragments || {}, activityParams(MODULE_TYPE_RTD, sm.name)); + verifiers.push(fpdGuard.verify); + sm.getBidRequestData({ + ...reqBidsConfigObj, + ortb2Fragments: fpdGuard.obj + }, onGetBidRequestDataCallback.bind(sm), sm.config, _userConsent) }); function onGetBidRequestDataCallback() { @@ -316,9 +338,10 @@ export function setBidRequestsData(fn, reqBidsConfigObj) { } isDone = true; clearTimeout(waitTimeout); + verifiers.forEach(fn => fn()); fn.call(this, reqBidsConfigObj); } -} +}); /** * loop through configured data providers If the data provider has registered getTargetingData, @@ -386,5 +409,18 @@ export function deepMerge(arr) { }, {}); } +export function onDataDeletionRequest(next, ...args) { + subModules.forEach((sm) => { + if (typeof sm.onDataDeletionRequest === 'function') { + try { + sm.onDataDeletionRequest(sm.config); + } catch (e) { + logError(`Error executing ${sm.name}.onDataDeletionRequest`, e) + } + } + }); + next.apply(this, args); +} + module('realTimeData', attachRealTimeDataProvider); init(config); diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js deleted file mode 100644 index 69335ff33a8..00000000000 --- a/modules/rubiconAnalyticsAdapter.js +++ /dev/null @@ -1,931 +0,0 @@ -import { generateUUID, mergeDeep, deepAccess, parseUrl, logError, pick, isEmpty, logWarn, debugTurnedOn, parseQS, getWindowLocation, isAdUnitCodeMatchingSlot, isNumber, isGptPubadsDefined, _each, deepSetValue, deepClone, logInfo } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; -import adapterManager from '../src/adapterManager.js'; -import CONSTANTS from '../src/constants.json'; -import { ajax } from '../src/ajax.js'; -import { config } from '../src/config.js'; -import { getGlobal } from '../src/prebidGlobal.js'; -import { getStorageManager } from '../src/storageManager.js'; - -const RUBICON_GVL_ID = 52; -export const storage = getStorageManager({gvlid: RUBICON_GVL_ID, moduleName: 'rubicon'}); -const COOKIE_NAME = 'rpaSession'; -const LAST_SEEN_EXPIRE_TIME = 1800000; // 30 mins -const END_EXPIRE_TIME = 21600000; // 6 hours -const MODULE_NAME = 'Rubicon Analytics'; - -const pbsErrorMap = { - 1: 'timeout-error', - 2: 'input-error', - 3: 'connect-error', - 4: 'request-error', - 999: 'generic-error' -} - -let prebidGlobal = getGlobal(); -const { - EVENTS: { - AUCTION_INIT, - AUCTION_END, - BID_REQUESTED, - BID_RESPONSE, - BIDDER_DONE, - BID_TIMEOUT, - BID_WON, - SET_TARGETING, - BILLABLE_EVENT - }, - STATUS: { - GOOD, - NO_BID - }, - BID_STATUS: { - BID_REJECTED - } -} = CONSTANTS; - -let serverConfig; -config.getConfig('s2sConfig', ({ s2sConfig }) => { - serverConfig = s2sConfig; -}); - -export const SEND_TIMEOUT = 3000; -const DEFAULT_INTEGRATION = 'pbjs'; - -const cache = { - auctions: {}, - targeting: {}, - timeouts: {}, - gpt: {}, - billing: {} -}; - -const BID_REJECTED_IPF = 'rejected-ipf'; - -export let rubiConf = { - pvid: generateUUID().slice(0, 8), - analyticsEventDelay: 0, - dmBilling: { - enabled: false, - vendors: [], - waitForAuction: true - } -}; -// we are saving these as global to this module so that if a pub accidentally overwrites the entire -// rubicon object, then we do not lose other data -config.getConfig('rubicon', config => { - mergeDeep(rubiConf, config.rubicon); - if (deepAccess(config, 'rubicon.updatePageView') === true) { - rubiConf.pvid = generateUUID().slice(0, 8) - } -}); - -export function getHostNameFromReferer(referer) { - try { - rubiconAdapter.referrerHostname = parseUrl(referer, { noDecodeWholeURL: true }).hostname; - } catch (e) { - logError(`${MODULE_NAME}: Unable to parse hostname from supplied url: `, referer, e); - rubiconAdapter.referrerHostname = ''; - } - return rubiconAdapter.referrerHostname -}; - -function stringProperties(obj) { - return Object.keys(obj).reduce((newObj, prop) => { - let value = obj[prop]; - if (typeof value === 'number') { - value = value.toFixed(3); - } else if (typeof value !== 'string') { - value = String(value); - } - newObj[prop] = value || undefined; - return newObj; - }, {}); -} - -function sizeToDimensions(size) { - return { - width: size.w || size[0], - height: size.h || size[1] - }; -} - -function validMediaType(type) { - return ['banner', 'native', 'video'].indexOf(type) !== -1; -} - -function formatSource(src) { - if (typeof src === 'undefined') { - src = 'client'; - } else if (src === 's2s') { - src = 'server'; - } - return src.toLowerCase(); -} - -function getBillingPayload(event) { - // for now we are mapping all events to type "general", later we will expand support for specific types - let billingEvent = deepClone(event); - billingEvent.type = 'general'; - billingEvent.accountId = accountId; - // mark as sent - deepSetValue(cache.billing, `${event.vendor}.${event.billingId}`, true); - return billingEvent; -} - -function sendBillingEvent(event) { - let message = getBasicEventDetails(undefined, 'soloBilling'); - message.billableEvents = [getBillingPayload(event)]; - ajax( - rubiconAdapter.getUrl(), - null, - JSON.stringify(message), - { - contentType: 'application/json' - } - ); -} - -function getBasicEventDetails(auctionId, trigger) { - let auctionCache = cache.auctions[auctionId]; - let referrer = config.getConfig('pageUrl') || pageReferer || (auctionCache && auctionCache.referrer); - let message = { - timestamps: { - prebidLoaded: rubiconAdapter.MODULE_INITIALIZED_TIME, - auctionEnded: auctionCache ? auctionCache.endTs : undefined, - eventTime: Date.now() - }, - trigger, - integration: rubiConf.int_type || DEFAULT_INTEGRATION, - version: '$prebid.version$', - referrerUri: referrer, - referrerHostname: rubiconAdapter.referrerHostname || getHostNameFromReferer(referrer), - channel: 'web', - }; - if (rubiConf.wrapperName) { - message.wrapper = { - name: rubiConf.wrapperName, - family: rubiConf.wrapperFamily, - rule: rubiConf.rule_name - } - } - return message; -} - -function sendMessage(auctionId, bidWonId, trigger) { - function formatBid(bid) { - return pick(bid, [ - 'bidder', - 'bidderDetail', - 'bidId', bidId => deepAccess(bid, 'bidResponse.pbsBidId') || deepAccess(bid, 'bidResponse.seatBidId') || bidId, - 'status', - 'error', - 'source', (source, bid) => { - if (source) { - return source; - } - return serverConfig && Array.isArray(serverConfig.bidders) && serverConfig.bidders.some(s2sBidder => s2sBidder.toLowerCase() === bid.bidder) !== -1 - ? 'server' : 'client' - }, - 'clientLatencyMillis', - 'serverLatencyMillis', - 'params', - 'bidResponse', bidResponse => bidResponse ? pick(bidResponse, [ - 'bidPriceUSD', - 'dealId', - 'dimensions', - 'mediaType', - 'floorValue', - 'floorRuleValue', - 'floorRule', - 'adomains' - ]) : undefined - ]); - } - function formatBidWon(bid) { - return Object.assign(formatBid(bid), pick(bid.adUnit, [ - 'adUnitCode', - 'transactionId', - 'videoAdFormat', () => bid.videoAdFormat, - 'mediaTypes' - ]), { - adserverTargeting: !isEmpty(cache.targeting[bid.adUnit.adUnitCode]) ? stringProperties(cache.targeting[bid.adUnit.adUnitCode]) : undefined, - bidwonStatus: 'success', // hard-coded for now - accountId, - siteId: bid.siteId, - zoneId: bid.zoneId, - samplingFactor - }); - } - let message = getBasicEventDetails(auctionId, trigger); - let auctionCache = cache.auctions[auctionId]; - if (auctionCache && !auctionCache.sent) { - let adUnitMap = Object.keys(auctionCache.bids).reduce((adUnits, bidId) => { - let bid = auctionCache.bids[bidId]; - let adUnit = adUnits[bid.adUnit.adUnitCode]; - if (!adUnit) { - adUnit = adUnits[bid.adUnit.adUnitCode] = pick(bid.adUnit, [ - 'adUnitCode', - 'transactionId', - 'mediaTypes', - 'dimensions', - 'adserverTargeting', () => !isEmpty(cache.targeting[bid.adUnit.adUnitCode]) ? stringProperties(cache.targeting[bid.adUnit.adUnitCode]) : undefined, - 'gam', gam => !isEmpty(gam) ? gam : undefined, - 'pbAdSlot', - 'gpid', - 'pattern' - ]); - adUnit.bids = []; - adUnit.status = 'no-bid'; // default it to be no bid - } - - // Add site and zone id if not there and if we found a rubicon bidder - if ((!adUnit.siteId || !adUnit.zoneId) && rubiconAliases.indexOf(bid.bidder) !== -1) { - if (deepAccess(bid, 'params.accountId') == accountId) { - adUnit.accountId = parseInt(accountId); - adUnit.siteId = parseInt(deepAccess(bid, 'params.siteId')); - adUnit.zoneId = parseInt(deepAccess(bid, 'params.zoneId')); - } - } - - if (bid.videoAdFormat && !adUnit.videoAdFormat) { - adUnit.videoAdFormat = bid.videoAdFormat; - } - - // determine adUnit.status from its bid statuses. Use priority below to determine, higher index is better - let statusPriority = ['error', 'no-bid', 'success']; - if (statusPriority.indexOf(bid.status) > statusPriority.indexOf(adUnit.status)) { - adUnit.status = bid.status; - } - - adUnit.bids.push(formatBid(bid)); - - return adUnits; - }, {}); - - // We need to mark each cached bid response with its appropriate rubicon site-zone id - // This allows the bidWon events to have these params even in the case of a delayed render - Object.keys(auctionCache.bids).forEach(function (bidId) { - let adCode = auctionCache.bids[bidId].adUnit.adUnitCode; - Object.assign(auctionCache.bids[bidId], pick(adUnitMap[adCode], ['accountId', 'siteId', 'zoneId'])); - }); - - let auction = { - clientTimeoutMillis: auctionCache.timeout, - auctionStart: auctionCache.timestamp, - auctionEnd: auctionCache.endTs, - bidderOrder: auctionCache.bidderOrder, - samplingFactor, - accountId, - adUnits: Object.keys(adUnitMap).map(i => adUnitMap[i]), - requestId: auctionId - }; - - // pick our of top level floor data we want to send! - if (auctionCache.floorData) { - if (auctionCache.floorData.location === 'noData') { - auction.floors = pick(auctionCache.floorData, [ - 'location', - 'fetchStatus', - 'floorProvider as provider' - ]); - } else { - auction.floors = pick(auctionCache.floorData, [ - 'location', - 'modelVersion as modelName', - 'modelWeight', - 'modelTimestamp', - 'skipped', - 'enforcement', () => deepAccess(auctionCache.floorData, 'enforcements.enforceJS'), - 'dealsEnforced', () => deepAccess(auctionCache.floorData, 'enforcements.floorDeals'), - 'skipRate', - 'fetchStatus', - 'floorMin', - 'floorProvider as provider' - ]); - } - } - - // gather gdpr info - if (auctionCache.gdprConsent) { - auction.gdpr = pick(auctionCache.gdprConsent, [ - 'gdprApplies as applies', - 'consentString', - 'apiVersion as version' - ]); - } - - // gather session info - if (auctionCache.session) { - message.session = pick(auctionCache.session, [ - 'id', - 'pvid', - 'start', - 'expires' - ]); - if (!isEmpty(auctionCache.session.fpkvs)) { - message.fpkvs = Object.keys(auctionCache.session.fpkvs).map(key => { - return { key, value: auctionCache.session.fpkvs[key] }; - }); - } - } - - if (serverConfig) { - auction.serverTimeoutMillis = serverConfig.timeout; - } - - if (auctionCache.userIds.length) { - auction.user = { ids: auctionCache.userIds }; - } - - message.auctions = [auction]; - - let bidsWon = Object.keys(auctionCache.bidsWon).reduce((memo, adUnitCode) => { - let bidId = auctionCache.bidsWon[adUnitCode]; - if (bidId) { - memo.push(formatBidWon(auctionCache.bids[bidId])); - } - return memo; - }, []); - - if (bidsWon.length > 0) { - message.bidsWon = bidsWon; - } - - auctionCache.sent = true; - } else if (bidWonId && auctionCache && auctionCache.bids[bidWonId]) { - message.bidsWon = [ - formatBidWon(auctionCache.bids[bidWonId]) - ]; - } - - // if we have not sent any billingEvents send them - const pendingBillingEvents = getPendingBillingEvents(auctionCache); - if (pendingBillingEvents && pendingBillingEvents.length) { - message.billableEvents = pendingBillingEvents; - } - - ajax( - this.getUrl(), - null, - JSON.stringify(message), - { - contentType: 'application/json' - } - ); -} - -function getPendingBillingEvents(auctionCache) { - if (auctionCache && auctionCache.billing && auctionCache.billing.length) { - return auctionCache.billing.reduce((accum, billingEvent) => { - if (deepAccess(cache.billing, `${billingEvent.vendor}.${billingEvent.billingId}`) === false) { - accum.push(getBillingPayload(billingEvent)); - } - return accum; - }, []); - } -} - -function adUnitIsOnlyInstream(adUnit) { - return adUnit.mediaTypes && Object.keys(adUnit.mediaTypes).length === 1 && deepAccess(adUnit, 'mediaTypes.video.context') === 'instream'; -} - -function getBidPrice(bid) { - // get the cpm from bidResponse - let cpm; - let currency; - if (bid.status === BID_REJECTED && deepAccess(bid, 'floorData.cpmAfterAdjustments')) { - // if bid was rejected and bid.floorData.cpmAfterAdjustments use it - cpm = bid.floorData.cpmAfterAdjustments; - currency = bid.floorData.floorCurrency; - } else if (typeof bid.currency === 'string' && bid.currency.toUpperCase() === 'USD') { - // bid is in USD use it - return Number(bid.cpm); - } else { - // else grab cpm - cpm = bid.cpm; - currency = bid.currency; - } - // if after this it is still going and is USD then return it. - if (currency === 'USD') { - return Number(cpm); - } - // otherwise we convert and return - try { - return Number(prebidGlobal.convertCurrency(cpm, currency, 'USD')); - } catch (err) { - logWarn(`${MODULE_NAME}: Could not determine the bidPriceUSD of the bid `, bid); - } -} - -export function parseBidResponse(bid, previousBidResponse, auctionFloorData) { - // The current bidResponse for this matching requestId/bidRequestId - let responsePrice = getBidPrice(bid) - // we need to compare it with the previous one (if there was one) - if (previousBidResponse && previousBidResponse.bidPriceUSD > responsePrice) { - return previousBidResponse; - } - return pick(bid, [ - 'bidPriceUSD', () => responsePrice, - 'dealId', - 'status', - 'mediaType', - 'dimensions', () => { - const width = bid.width || bid.playerWidth; - const height = bid.height || bid.playerHeight; - return (width && height) ? { width, height } : undefined; - }, - // Handling use case where pbs sends back 0 or '0' bidIds - 'pbsBidId', pbsBidId => pbsBidId == 0 ? generateUUID() : pbsBidId, - 'seatBidId', seatBidId => seatBidId == 0 ? generateUUID() : seatBidId, - 'floorValue', () => deepAccess(bid, 'floorData.floorValue'), - 'floorRuleValue', () => deepAccess(bid, 'floorData.floorRuleValue'), - 'floorRule', () => debugTurnedOn() ? deepAccess(bid, 'floorData.floorRule') : undefined, - 'adomains', () => { - const adomains = deepAccess(bid, 'meta.advertiserDomains'); - const validAdomains = Array.isArray(adomains) && adomains.filter(domain => typeof domain === 'string'); - return validAdomains && validAdomains.length > 0 ? validAdomains.slice(0, 10) : undefined - } - ]); -} - -/* - Filters and converts URL Params into an object and returns only KVs that match the 'utm_KEY' format -*/ -function getUtmParams() { - let search; - - try { - search = parseQS(getWindowLocation().search); - } catch (e) { - search = {}; - } - - return Object.keys(search).reduce((accum, param) => { - if (param.match(/utm_/)) { - accum[param.replace(/utm_/, '')] = search[param]; - } - return accum; - }, {}); -} - -function getFpkvs() { - rubiConf.fpkvs = Object.assign((rubiConf.fpkvs || {}), getUtmParams()); - - // convert all values to strings - Object.keys(rubiConf.fpkvs).forEach(key => { - rubiConf.fpkvs[key] = rubiConf.fpkvs[key] + ''; - }); - - return rubiConf.fpkvs; -} - -let samplingFactor = 1; -let accountId; -// List of known rubicon aliases -// This gets updated on auction init to account for any custom aliases present -let rubiconAliases = ['rubicon']; - -/* - Checks the alias registry for any entries of the rubicon bid adapter. - adds to the rubiconAliases list if found -*/ -function setRubiconAliases(aliasRegistry) { - Object.keys(aliasRegistry).forEach(function (alias) { - if (aliasRegistry[alias] === 'rubicon') { - rubiconAliases.push(alias); - } - }); -} - -function getRpaCookie() { - let encodedCookie = storage.getDataFromLocalStorage(COOKIE_NAME); - if (encodedCookie) { - try { - return JSON.parse(window.atob(encodedCookie)); - } catch (e) { - logError(`${MODULE_NAME}: Unable to decode ${COOKIE_NAME} value: `, e); - } - } - return {}; -} - -function setRpaCookie(decodedCookie) { - try { - storage.setDataInLocalStorage(COOKIE_NAME, window.btoa(JSON.stringify(decodedCookie))); - } catch (e) { - logError(`${MODULE_NAME}: Unable to encode ${COOKIE_NAME} value: `, e); - } -} - -function updateRpaCookie() { - const currentTime = Date.now(); - let decodedRpaCookie = getRpaCookie(); - if ( - !Object.keys(decodedRpaCookie).length || - (currentTime - decodedRpaCookie.lastSeen) > LAST_SEEN_EXPIRE_TIME || - decodedRpaCookie.expires < currentTime - ) { - decodedRpaCookie = { - id: generateUUID(), - start: currentTime, - expires: currentTime + END_EXPIRE_TIME, // six hours later, - } - } - // possible that decodedRpaCookie is undefined, and if it is, we probably are blocked by storage or some other exception - if (Object.keys(decodedRpaCookie).length) { - decodedRpaCookie.lastSeen = currentTime; - decodedRpaCookie.fpkvs = { ...decodedRpaCookie.fpkvs, ...getFpkvs() }; - decodedRpaCookie.pvid = rubiConf.pvid; - setRpaCookie(decodedRpaCookie) - } - return decodedRpaCookie; -} - -function subscribeToGamSlots() { - window.googletag.pubads().addEventListener('slotRenderEnded', event => { - const isMatchingAdSlot = isAdUnitCodeMatchingSlot(event.slot); - // loop through auctions and adUnits and mark the info - // only mark first auction which finds a match - let hasMatch = false; - Object.keys(cache.auctions).find(auctionId => { - (Object.keys(cache.auctions[auctionId].bids) || []).forEach(bidId => { - let bid = cache.auctions[auctionId].bids[bidId]; - // if this slot matches this bids adUnit, add the adUnit info - // only mark it if it already has not been marked - if (!bid.adUnit.gamRendered && isMatchingAdSlot(bid.adUnit.adUnitCode)) { - // mark this adUnit as having been rendered by gam - cache.auctions[auctionId].gamHasRendered[bid.adUnit.adUnitCode] = true; - - // this current auction has an adunit that matched the slot, so mark it as matched so next auciton is skipped - hasMatch = true; - - bid.adUnit.gam = pick(event, [ - // these come in as `null` from Gpt, which when stringified does not get removed - // so set explicitly to undefined when not a number - 'advertiserId', advertiserId => isNumber(advertiserId) ? advertiserId : undefined, - 'creativeId', creativeId => isNumber(event.sourceAgnosticCreativeId) ? event.sourceAgnosticCreativeId : isNumber(creativeId) ? creativeId : undefined, - 'lineItemId', lineItemId => isNumber(event.sourceAgnosticLineItemId) ? event.sourceAgnosticLineItemId : isNumber(lineItemId) ? lineItemId : undefined, - 'adSlot', () => event.slot.getAdUnitPath(), - 'isSlotEmpty', () => event.isEmpty || undefined - ]); - - // this lets us know next iteration not to check this bids adunit - bid.adUnit.gamRendered = true; - } - }); - // Now if all adUnits have gam rendered, send the payload - if (rubiConf.waitForGamSlots && !cache.auctions[auctionId].sent && Object.keys(cache.auctions[auctionId].gamHasRendered).every(adUnitCode => cache.auctions[auctionId].gamHasRendered[adUnitCode])) { - clearTimeout(cache.timeouts[auctionId]); - delete cache.timeouts[auctionId]; - if (rubiConf.analyticsEventDelay > 0) { - setTimeout(() => sendMessage.call(rubiconAdapter, auctionId, undefined, 'delayedGam'), rubiConf.analyticsEventDelay) - } else { - sendMessage.call(rubiconAdapter, auctionId, undefined, 'gam') - } - } - return hasMatch; - }); - }); -} - -let pageReferer; - -const isBillingEventValid = event => { - // vendor is whitelisted - const isWhitelistedVendor = rubiConf.dmBilling.vendors.includes(event.vendor); - // event is not duplicated - const isNotDuplicate = typeof deepAccess(cache.billing, `${event.vendor}.${event.billingId}`) !== 'boolean'; - // billingId is defined and a string - return typeof event.billingId === 'string' && isWhitelistedVendor && isNotDuplicate; -} - -const sendOrAddEventToQueue = event => { - // if any auction is not sent yet, then add it to the auction queue - const pendingAuction = Object.keys(cache.auctions).find(auctionId => !cache.auctions[auctionId].sent); - - if (rubiConf.dmBilling.waitForAuction && pendingAuction) { - cache.auctions[pendingAuction].billing = cache.auctions[pendingAuction].billing || []; - cache.auctions[pendingAuction].billing.push(event); - } else { - // send it - sendBillingEvent(event); - } -} - -let baseAdapter = adapter({ analyticsType: 'endpoint' }); -let rubiconAdapter = Object.assign({}, baseAdapter, { - MODULE_INITIALIZED_TIME: Date.now(), - referrerHostname: '', - enableAnalytics(config = {}) { - let error = false; - samplingFactor = 1; - - if (typeof config.options === 'object') { - if (config.options.accountId) { - accountId = Number(config.options.accountId); - } - if (config.options.endpoint) { - this.getUrl = () => config.options.endpoint; - } else { - logError(`${MODULE_NAME}: required endpoint missing`); - error = true; - } - if (typeof config.options.sampling !== 'undefined') { - samplingFactor = 1 / parseFloat(config.options.sampling); - } - if (typeof config.options.samplingFactor !== 'undefined') { - if (typeof config.options.sampling !== 'undefined') { - logWarn(`${MODULE_NAME}: Both options.samplingFactor and options.sampling enabled defaulting to samplingFactor`); - } - samplingFactor = parseFloat(config.options.samplingFactor); - config.options.sampling = 1 / samplingFactor; - } - } - - let validSamplingFactors = [1, 10, 20, 40, 100]; - if (validSamplingFactors.indexOf(samplingFactor) === -1) { - error = true; - logError(`${MODULE_NAME}: invalid samplingFactor ${samplingFactor} - must be one of ${validSamplingFactors.join(', ')}`); - } else if (!accountId) { - error = true; - logError(`${MODULE_NAME}: required accountId missing for rubicon analytics`); - } - - if (!error) { - baseAdapter.enableAnalytics.call(this, config); - } - }, - disableAnalytics() { - this.getUrl = baseAdapter.getUrl; - accountId = undefined; - rubiConf = {}; - cache.gpt.registered = false; - cache.billing = {}; - baseAdapter.disableAnalytics.apply(this, arguments); - }, - track({ eventType, args }) { - switch (eventType) { - case AUCTION_INIT: - // set the rubicon aliases - setRubiconAliases(adapterManager.aliasRegistry); - let cacheEntry = pick(args, [ - 'timestamp', - 'timeout' - ]); - cacheEntry.bids = {}; - cacheEntry.bidsWon = {}; - cacheEntry.gamHasRendered = {}; - cacheEntry.referrer = pageReferer = deepAccess(args, 'bidderRequests.0.refererInfo.referer'); - cacheEntry.bidderOrder = []; - const floorData = deepAccess(args, 'bidderRequests.0.bids.0.floorData'); - if (floorData) { - cacheEntry.floorData = { ...floorData }; - } - cacheEntry.gdprConsent = deepAccess(args, 'bidderRequests.0.gdprConsent'); - cacheEntry.session = storage.localStorageIsEnabled() && updateRpaCookie(); - cacheEntry.userIds = Object.keys(deepAccess(args, 'bidderRequests.0.bids.0.userId', {})).map(id => { - return { provider: id, hasId: true } - }); - cache.auctions[args.auctionId] = cacheEntry; - // register to listen to gpt events if not done yet - if (!cache.gpt.registered && isGptPubadsDefined()) { - subscribeToGamSlots(); - cache.gpt.registered = true; - } else if (!cache.gpt.registered) { - cache.gpt.registered = true; - window.googletag = window.googletag || {}; - window.googletag.cmd = window.googletag.cmd || []; - window.googletag.cmd.push(function () { - subscribeToGamSlots(); - }); - } - break; - case BID_REQUESTED: - cache.auctions[args.auctionId].bidderOrder.push(args.bidderCode); - Object.assign(cache.auctions[args.auctionId].bids, args.bids.reduce((memo, bid) => { - // mark adUnits we expect bidWon events for - cache.auctions[args.auctionId].bidsWon[bid.adUnitCode] = false; - - if (rubiConf.waitForGamSlots && !adUnitIsOnlyInstream(bid)) { - cache.auctions[args.auctionId].gamHasRendered[bid.adUnitCode] = false; - } - - memo[bid.bidId] = pick(bid, [ - 'bidder', bidder => bidder.toLowerCase(), - 'bidId', - 'status', () => 'no-bid', // default a bid to no-bid until response is recieved or bid is timed out - 'source', () => formatSource(bid.src), - 'params', (params, bid) => { - switch (bid.bidder) { - // specify bidder params we want here - case 'rubicon': - return pick(params, [ - 'accountId', - 'siteId', - 'zoneId' - ]); - } - }, - 'videoAdFormat', (_, cachedBid) => { - if (cachedBid.bidder === 'rubicon') { - return ({ - 201: 'pre-roll', - 202: 'interstitial', - 203: 'outstream', - 204: 'mid-roll', - 205: 'post-roll', - 207: 'vertical' - })[deepAccess(bid, 'params.video.size_id')]; - } else { - let startdelay = parseInt(deepAccess(bid, 'params.video.startdelay'), 10); - if (!isNaN(startdelay)) { - if (startdelay > 0) { - return 'mid-roll'; - } - return ({ - '0': 'pre-roll', - '-1': 'mid-roll', - '-2': 'post-roll' - })[startdelay] - } - } - }, - 'adUnit', () => pick(bid, [ - 'adUnitCode', - 'transactionId', - 'sizes as dimensions', sizes => sizes.map(sizeToDimensions), - 'mediaTypes', (types) => { - if (bid.mediaType && validMediaType(bid.mediaType)) { - return [bid.mediaType]; - } - if (Array.isArray(types)) { - return types.filter(validMediaType); - } - if (typeof types === 'object') { - if (!bid.sizes) { - bid.dimensions = []; - _each(types, (type) => - bid.dimensions = bid.dimensions.concat( - type.sizes.map(sizeToDimensions) - ) - ); - } - return Object.keys(types).filter(validMediaType); - } - return ['banner']; - }, - 'gam', () => { - if (deepAccess(bid, 'ortb2Imp.ext.data.adserver.name') === 'gam') { - return { adSlot: bid.ortb2Imp.ext.data.adserver.adslot } - } - }, - 'pbAdSlot', () => deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'), - 'pattern', () => deepAccess(bid, 'ortb2Imp.ext.data.aupname'), - 'gpid', () => deepAccess(bid, 'ortb2Imp.ext.gpid') - ]) - ]); - return memo; - }, {})); - break; - case BID_RESPONSE: - let auctionEntry = cache.auctions[args.auctionId]; - - if (!auctionEntry.bids[args.requestId] && args.originalRequestId) { - auctionEntry.bids[args.requestId] = { ...auctionEntry.bids[args.originalRequestId] }; - auctionEntry.bids[args.requestId].bidId = args.requestId; - auctionEntry.bids[args.requestId].bidderDetail = args.targetingBidder; - } - - let bid = auctionEntry.bids[args.requestId]; - // If floor resolved gptSlot but we have not yet, then update the adUnit to have the adSlot name - if (!deepAccess(bid, 'adUnit.gam.adSlot') && deepAccess(args, 'floorData.matchedFields.gptSlot')) { - deepSetValue(bid, 'adUnit.gam.adSlot', args.floorData.matchedFields.gptSlot); - } - // if we have not set enforcements yet set it - if (!deepAccess(auctionEntry, 'floorData.enforcements') && deepAccess(args, 'floorData.enforcements')) { - auctionEntry.floorData.enforcements = { ...args.floorData.enforcements }; - } - if (!bid) { - logError(`${MODULE_NAME}: Could not find associated bid request for bid response with requestId: `, args.requestId); - break; - } - bid.source = formatSource(bid.source || args.source); - switch (args.getStatusCode()) { - case GOOD: - bid.status = 'success'; - delete bid.error; // it's possible for this to be set by a previous timeout - break; - case NO_BID: - bid.status = args.status === BID_REJECTED ? BID_REJECTED_IPF : 'no-bid'; - delete bid.error; - break; - default: - bid.status = 'error'; - bid.error = { - code: 'request-error' - }; - } - bid.clientLatencyMillis = bid.timeToRespond || Date.now() - cache.auctions[args.auctionId].timestamp; - bid.bidResponse = parseBidResponse(args, bid.bidResponse); - break; - case BIDDER_DONE: - const serverError = deepAccess(args, 'serverErrors.0'); - const serverResponseTimeMs = args.serverResponseTimeMs; - args.bids.forEach(bid => { - let cachedBid = cache.auctions[bid.auctionId].bids[bid.bidId || bid.requestId]; - if (typeof bid.serverResponseTimeMs !== 'undefined') { - cachedBid.serverLatencyMillis = bid.serverResponseTimeMs; - } else if (serverResponseTimeMs && bid.source === 's2s') { - cachedBid.serverLatencyMillis = serverResponseTimeMs; - } - // if PBS said we had an error, and this bid has not been processed by BID_RESPONSE YET - if (serverError && (!cachedBid.status || ['no-bid', 'error'].indexOf(cachedBid.status) !== -1)) { - cachedBid.status = 'error'; - cachedBid.error = { - code: pbsErrorMap[serverError.code] || pbsErrorMap[999], - description: serverError.message - } - } - if (!cachedBid.status) { - cachedBid.status = 'no-bid'; - } - if (!cachedBid.clientLatencyMillis) { - cachedBid.clientLatencyMillis = Date.now() - cache.auctions[bid.auctionId].timestamp; - } - }); - break; - case SET_TARGETING: - Object.assign(cache.targeting, args); - break; - case BID_WON: - let auctionCache = cache.auctions[args.auctionId]; - auctionCache.bidsWon[args.adUnitCode] = args.requestId; - - // check if this BID_WON missed the boat, if so send by itself - if (auctionCache.sent === true) { - sendMessage.call(this, args.auctionId, args.requestId, 'soloBidWon'); - } else if (!rubiConf.waitForGamSlots && Object.keys(auctionCache.bidsWon).reduce((memo, adUnitCode) => { - // only send if we've received bidWon events for all adUnits in auction - memo = memo && auctionCache.bidsWon[adUnitCode]; - return memo; - }, true)) { - clearTimeout(cache.timeouts[args.auctionId]); - delete cache.timeouts[args.auctionId]; - - sendMessage.call(this, args.auctionId, undefined, 'allBidWons'); - } - break; - case AUCTION_END: - // see how long it takes for the payload to come fire - let auctionData = cache.auctions[args.auctionId]; - // if for some reason the auction did not do its normal thing, this could be undefied so bail - if (!auctionData) { - break; - } - auctionData.endTs = Date.now(); - - const isOnlyInstreamAuction = args.adUnits && args.adUnits.every(adUnit => adUnitIsOnlyInstream(adUnit)); - // If only instream, do not wait around, just send payload - if (isOnlyInstreamAuction) { - sendMessage.call(this, args.auctionId, undefined, 'instreamAuction'); - } else { - // start timer to send batched payload just in case we don't hear any BID_WON events - cache.timeouts[args.auctionId] = setTimeout(() => { - sendMessage.call(this, args.auctionId, undefined, 'auctionEnd'); - }, rubiConf.analyticsBatchTimeout || SEND_TIMEOUT); - } - break; - case BID_TIMEOUT: - args.forEach(badBid => { - let auctionCache = cache.auctions[badBid.auctionId]; - let bid = auctionCache.bids[badBid.bidId || badBid.requestId]; - // might be set already by bidder-done, so do not overwrite - if (bid.status !== 'error') { - bid.status = 'error'; - bid.error = { - code: 'timeout-error', - description: 'prebid.js timeout' // will help us diff if timeout was set by PBS or PBJS - }; - } - }); - break; - case BILLABLE_EVENT: - if (rubiConf.dmBilling.enabled && isBillingEventValid(args)) { - // add to the map indicating it has not been sent yet - deepSetValue(cache.billing, `${args.vendor}.${args.billingId}`, false); - sendOrAddEventToQueue(args); - } else { - logInfo(`${MODULE_NAME}: Billing event ignored`, args); - } - } - } -}); - -adapterManager.registerAnalyticsAdapter({ - adapter: rubiconAdapter, - code: 'rubicon', - gvlid: RUBICON_GVL_ID -}); - -export default rubiconAdapter; diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index afb95d56d69..4cfd40fb682 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -1,6 +1,12 @@ +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import { pbsExtensions } from '../libraries/pbsExtensions/pbsExtensions.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { find } from '../src/polyfill.js'; +import { getGlobal } from '../src/prebidGlobal.js'; +import { Renderer } from '../src/Renderer.js'; import { - _each, - convertTypes, deepAccess, deepSetValue, formatQS, @@ -11,21 +17,17 @@ import { logMessage, logWarn, mergeDeep, - parseSizesInput + parseSizesInput, _each } from '../src/utils.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {config} from '../src/config.js'; -import {BANNER, VIDEO} from '../src/mediaTypes.js'; -import {find} from '../src/polyfill.js'; -import {Renderer} from '../src/Renderer.js'; -import {getGlobal} from '../src/prebidGlobal.js'; +import {getAllOrtbKeywords} from '../libraries/keywords/keywords.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; const DEFAULT_INTEGRATION = 'pbjs_lite'; const DEFAULT_PBS_INTEGRATION = 'pbjs'; const DEFAULT_RENDERER_URL = 'https://video-outstream.rubiconproject.com/apex-2.2.1.js'; // renderer code at https://github.com/rubicon-project/apex2 -let rubiConf = {}; +let rubiConf = config.getConfig('rubicon') || {}; // we are saving these as global to this module so that if a pub accidentally overwrites the entire // rubicon object, then we do not lose other data config.getConfig('rubicon', config => { @@ -115,12 +117,14 @@ var sizeMap = { 257: '400x600', 258: '500x200', 259: '998x200', + 261: '480x480', 264: '970x1000', 265: '1920x1080', 274: '1800x200', 278: '320x500', 282: '320x400', 288: '640x380', + 524: '1x2', 548: '500x1000', 550: '980x480', 552: '300x200', @@ -134,19 +138,114 @@ var sizeMap = { 574: '620x891', 576: '610x877', 578: '980x552', - 580: '505x656' + 580: '505x656', + 622: '192x160', + 632: '1200x450', + 634: '340x450' }; + _each(sizeMap, (item, key) => sizeMap[item] = key); +export const converter = ortbConverter({ + request(buildRequest, imps, bidderRequest, context) { + const {bidRequests} = context; + const data = buildRequest(imps, bidderRequest, context); + data.cur = ['USD']; + data.test = config.getConfig('debug') ? 1 : 0; + deepSetValue(data, 'ext.prebid.cache', { + vastxml: { + returnCreative: rubiConf.returnVast === true + } + }); + + deepSetValue(data, 'ext.prebid.bidders', { + rubicon: { + integration: rubiConf.int_type || DEFAULT_PBS_INTEGRATION, + } + }); + + deepSetValue(data, 'ext.prebid.targeting.pricegranularity', getPriceGranularity(config)); + + let modules = (getGlobal()).installedModules; + if (modules && (!modules.length || modules.indexOf('rubiconAnalyticsAdapter') !== -1)) { + deepSetValue(data, 'ext.prebid.analytics', {'rubicon': {'client-analytics': true}}); + } + + addOrtbFirstPartyData(data, bidRequests, bidderRequest.ortb2); + + delete data?.ext?.prebid?.storedrequest; + + // floors + if (rubiConf.disableFloors === true) { + delete data.ext.prebid.floors; + } + + // If the price floors module is active, then we need to signal to PBS! If floorData obj is present is best way to check + const haveFloorDataBidRequests = bidRequests.filter(bidRequest => typeof bidRequest.floorData === 'object'); + if (haveFloorDataBidRequests.length > 0) { + data.ext.prebid.floors = { enabled: false }; + } + return data; + }, + imp(buildImp, bidRequest, context) { + // skip banner-only requests + const bidRequestType = bidType(bidRequest); + if (bidRequestType.includes(BANNER) && bidRequestType.length == 1) return; + + const imp = buildImp(bidRequest, context); + imp.id = bidRequest.adUnitCode; + delete imp.banner; + if (config.getConfig('s2sConfig.defaultTtl')) { + imp.exp = config.getConfig('s2sConfig.defaultTtl'); + }; + bidRequest.params.position === 'atf' && imp.video && (imp.video.pos = 1); + bidRequest.params.position === 'btf' && imp.video && (imp.video.pos = 3); + delete imp.ext?.prebid?.storedrequest; + + if (bidRequest.params.bidonmultiformat === true && bidRequestType.length > 1) { + deepSetValue(imp, 'ext.prebid.bidder.rubicon.formats', bidRequestType); + } + + setBidFloors(bidRequest, imp); + + return imp; + }, + bidResponse(buildBidResponse, bid, context) { + const bidResponse = buildBidResponse(bid, context); + bidResponse.meta.mediaType = deepAccess(bid, 'ext.prebid.type'); + const {bidRequest} = context; + + let [parseSizeWidth, parseSizeHeight] = bidRequest.mediaTypes.video?.context === 'outstream' ? parseSizes(bidRequest, VIDEO) : [undefined, undefined]; + + bidResponse.width = bid.w || parseSizeWidth || bidResponse.playerWidth; + bidResponse.height = bid.h || parseSizeHeight || bidResponse.playerHeight; + + if (bidResponse.mediaType === VIDEO && bidRequest.mediaTypes.video.context === 'outstream') { + bidResponse.renderer = outstreamRenderer(bidResponse); + } + + if (deepAccess(bid, 'ext.bidder.rp.advid')) { + deepSetValue(bidResponse, 'meta.advertiserId', bid.ext.bidder.rp.advid); + } + return bidResponse; + }, + context: { + netRevenue: rubiConf.netRevenue !== false, // If anything other than false, netRev is true + ttl: 300, + }, + processors: pbsExtensions +}); + export const spec = { code: 'rubicon', gvlid: GVLID, - supportedMediaTypes: [BANNER, VIDEO], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], /** * @param {object} bid * @return boolean */ isBidRequestValid: function (bid) { + let valid = true; if (typeof bid.params !== 'object') { return false; } @@ -158,15 +257,16 @@ export const spec = { return false } } - let bidFormat = bidType(bid, true); + let bidFormats = bidType(bid, true); // bidType is undefined? Return false - if (!bidFormat) { + if (!bidFormats.length) { return false; - } else if (bidFormat === 'video') { // bidType is video, make sure it has required params - return hasValidVideoParams(bid); + } else if (bidFormats.includes(VIDEO)) { // bidType is video, make sure it has required params + valid = hasValidVideoParams(bid); } - // bidType is banner? return true - return true; + const hasBannerOrNativeMediaType = [BANNER, NATIVE].filter(mediaType => bidFormats.includes(mediaType)).length > 0; + if (!hasBannerOrNativeMediaType) return valid; + return valid && hasBannerOrNativeMediaType; }, /** * @param {BidRequest[]} bidRequests @@ -176,160 +276,57 @@ export const spec = { buildRequests: function (bidRequests, bidderRequest) { // separate video bids because the requests are structured differently let requests = []; - const videoRequests = bidRequests.filter(bidRequest => bidType(bidRequest) === 'video').map(bidRequest => { - bidRequest.startTime = new Date().getTime(); - - const data = { - id: bidRequest.transactionId, - test: config.getConfig('debug') ? 1 : 0, - cur: ['USD'], - source: { - tid: bidRequest.transactionId - }, - tmax: bidderRequest.timeout, - imp: [{ - exp: config.getConfig('s2sConfig.defaultTtl'), - id: bidRequest.adUnitCode, - secure: 1, - ext: { - [bidRequest.bidder]: bidRequest.params - }, - video: deepAccess(bidRequest, 'mediaTypes.video') || {} - }], - ext: { - prebid: { - channel: { - name: 'pbjs', - version: $$PREBID_GLOBAL$$.version - }, - cache: { - vastxml: { - returnCreative: rubiConf.returnVast === true - } - }, - targeting: { - includewinners: true, - // includebidderkeys always false for openrtb - includebidderkeys: false, - pricegranularity: getPriceGranularity(config) - }, - bidders: { - rubicon: { - integration: rubiConf.int_type || DEFAULT_PBS_INTEGRATION - } - } - } - } - } - - // Add alias if it is there - if (bidRequest.bidder !== 'rubicon') { - data.ext.prebid.aliases = { - [bidRequest.bidder]: 'rubicon' - } - } - - let modules = (getGlobal()).installedModules; - if (modules && (!modules.length || modules.indexOf('rubiconAnalyticsAdapter') !== -1)) { - deepSetValue(data, 'ext.prebid.analytics', {'rubicon': {'client-analytics': true}}); - } - - let bidFloor; - if (typeof bidRequest.getFloor === 'function' && !rubiConf.disableFloors) { - let floorInfo; - try { - floorInfo = bidRequest.getFloor({ - currency: 'USD', - mediaType: 'video', - size: parseSizes(bidRequest, 'video') - }); - } catch (e) { - logError('Rubicon: getFloor threw an error: ', e); - } - bidFloor = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? parseFloat(floorInfo.floor) : undefined; - } else { - bidFloor = parseFloat(deepAccess(bidRequest, 'params.floor')); - } - if (!isNaN(bidFloor)) { - data.imp[0].bidfloor = bidFloor; - } - // if value is set, will overwrite with same value - data.imp[0].ext[bidRequest.bidder].video.size_id = determineRubiconVideoSizeId(bidRequest) - - appendSiteAppDevice(data, bidRequest, bidderRequest); - - addVideoParameters(data, bidRequest); - - if (bidderRequest.gdprConsent) { - // note - gdprApplies & consentString may be undefined in certain use-cases for consentManagement module - let gdprApplies; - if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { - gdprApplies = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; - } - - deepSetValue(data, 'regs.ext.gdpr', gdprApplies); - deepSetValue(data, 'user.ext.consent', bidderRequest.gdprConsent.consentString); - } - - if (bidderRequest.uspConsent) { - deepSetValue(data, 'regs.ext.us_privacy', bidderRequest.uspConsent); - } - - const eids = deepAccess(bidderRequest, 'bids.0.userIdAsEids'); - if (eids && eids.length) { - deepSetValue(data, 'user.ext.eids', eids); - } - - // set user.id value from config value - const configUserId = config.getConfig('user.id'); - if (configUserId) { - deepSetValue(data, 'user.id', configUserId); - } - - if (config.getConfig('coppa') === true) { - deepSetValue(data, 'regs.coppa', 1); - } - - if (bidRequest.schain && hasValidSupplyChainParams(bidRequest.schain)) { - deepSetValue(data, 'source.ext.schain', bidRequest.schain); - } - - const multibid = config.getConfig('multibid'); - if (multibid) { - deepSetValue(data, 'ext.prebid.multibid', multibid.reduce((result, i) => { - let obj = {}; - - Object.keys(i).forEach(key => { - obj[key.toLowerCase()] = i[key]; - }); - - result.push(obj); - - return result; - }, [])); - } - - applyFPD(bidRequest, VIDEO, data); - - // if storedAuctionResponse has been set, pass SRID - if (bidRequest.storedAuctionResponse) { - deepSetValue(data.imp[0], 'ext.prebid.storedauctionresponse.id', bidRequest.storedAuctionResponse.toString()); - } + let filteredHttpRequest = []; + let filteredRequests; + + filteredRequests = bidRequests.filter(req => { + const mediaTypes = bidType(req) || []; + const { length } = mediaTypes; + const { bidonmultiformat, video } = req.params || {}; + + return ( + // if there's just one mediaType and it's video or native, just send it! + (length === 1 && (mediaTypes.includes(VIDEO) || mediaTypes.includes(NATIVE))) || + // if it's two mediaTypes, and they don't contain banner, send to PBS both native & video + (length === 2 && !mediaTypes.includes(BANNER)) || + // if it contains the video param and the Video mediaType, send Video to PBS (not native!) + (video && mediaTypes.includes(VIDEO)) || + // if bidonmultiformat is on, send everything to PBS + (bidonmultiformat && (mediaTypes.includes(VIDEO) || mediaTypes.includes(NATIVE))) + ) + }); - // set ext.prebid.auctiontimestamp using auction time - deepSetValue(data.imp[0], 'ext.prebid.auctiontimestamp', bidderRequest.auctionStart); + if (filteredRequests && filteredRequests.length) { + const data = converter.toORTB({bidRequests: filteredRequests, bidderRequest}); - return { + filteredHttpRequest.push({ method: 'POST', url: `https://${rubiConf.videoHost || 'prebid-server'}.rubiconproject.com/openrtb2/auction`, data, - bidRequest - } - }); + bidRequest: filteredRequests + }); + } + const bannerBidRequests = bidRequests.filter((req) => { + const mediaTypes = bidType(req) || []; + const {bidonmultiformat, video} = req.params || {}; + return ( + // Send to fastlane if: it must include BANNER and... + mediaTypes.includes(BANNER) && ( + // if it's just banner + (mediaTypes.length === 1) || + // if bidonmultiformat is true + bidonmultiformat || + // if bidonmultiformat is false and there's no video parameter + (!bidonmultiformat && !video) || + // if there's video parameter, but there's no video mediatype + (!bidonmultiformat && video && !mediaTypes.includes(VIDEO)) + ) + ); + }); if (rubiConf.singleRequest !== true) { // bids are not grouped if single request mode is not enabled - requests = videoRequests.concat(bidRequests.filter(bidRequest => bidType(bidRequest) === 'banner').map(bidRequest => { + requests = filteredHttpRequest.concat(bannerBidRequests.map(bidRequest => { const bidParams = spec.createSlotParams(bidRequest, bidderRequest); return { method: 'GET', @@ -344,8 +341,7 @@ export const spec = { } else { // single request requires bids to be grouped by site id into a single request // note: groupBy wasn't used because deep property access was needed - const nonVideoRequests = bidRequests.filter(bidRequest => bidType(bidRequest) === 'banner'); - const groupedBidRequests = nonVideoRequests.reduce((groupedBids, bid) => { + const groupedBidRequests = bannerBidRequests.reduce((groupedBids, bid) => { (groupedBids[bid.params['siteId']] = groupedBids[bid.params['siteId']] || []).push(bid); return groupedBids; }, {}); @@ -354,7 +350,7 @@ export const spec = { const SRA_BID_LIMIT = 10; // multiple requests are used if bids groups have more than 10 bids - requests = videoRequests.concat(Object.keys(groupedBidRequests).reduce((aggregate, bidGroupKey) => { + requests = filteredHttpRequest.concat(Object.keys(groupedBidRequests).reduce((aggregate, bidGroupKey) => { // for each partioned bidGroup, append a bidRequest to requests list partitionArray(groupedBidRequests[bidGroupKey], SRA_BID_LIMIT).forEach(bidsInGroup => { const combinedSlotParams = spec.combineSlotUrlParams(bidsInGroup.map(bidRequest => { @@ -393,6 +389,8 @@ export const spec = { 'gdpr', 'gdpr_consent', 'us_privacy', + 'gpp', + 'gpp_sid', 'rp_schain', ].concat(Object.keys(params).filter(item => containsUId.test(item))) .concat([ @@ -408,7 +406,6 @@ export const spec = { 'tk_flint', 'x_source.tid', 'l_pb_bid_id', - 'x_source.pchain', 'p_screen_res', 'rp_floor', 'rp_secure', @@ -480,9 +477,9 @@ export const spec = { 'rp_floor': (params.floor = parseFloat(params.floor)) >= 0.01 ? params.floor : undefined, 'rp_secure': '1', 'tk_flint': `${rubiConf.int_type || DEFAULT_INTEGRATION}_v$prebid.version$`, - 'x_source.tid': bidRequest.transactionId, + 'x_source.tid': bidderRequest.ortb2?.source?.tid, + 'x_imp.ext.tid': bidRequest.ortb2Imp?.ext?.tid, 'l_pb_bid_id': bidRequest.bidId, - 'x_source.pchain': params.pchain, 'p_screen_res': _getScreenResolution(), 'tk_user_key': params.userId, 'p_geo.latitude': isNaN(parseFloat(latitude)) ? undefined : parseFloat(latitude).toFixed(4), @@ -506,6 +503,11 @@ export const spec = { data['rp_hard_floor'] = typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseInt(floorInfo.floor)) ? floorInfo.floor : undefined; } + // Send multiformat data if requested + if (params.bidonmultiformat === true && deepAccess(bidRequest, 'mediaTypes') && Object.keys(bidRequest.mediaTypes).length > 1) { + data['p_formats'] = Object.keys(bidRequest.mediaTypes).join(','); + } + // add p_pos only if specified and valid // For SRA we need to explicitly put empty semi colons so AE treats it as empty, instead of copying the latter value let posMapping = {1: 'atf', 3: 'btf'}; @@ -537,7 +539,9 @@ export const spec = { data['eid_id5-sync.com'] = `${eid.uids[0].id}^${eid.uids[0].atype}^${(eid.uids[0].ext && eid.uids[0].ext.linkType) || ''}`; } else { // add anything else with this generic format - data[`eid_${eid.source}`] = `${eid.uids[0].id}^${eid.uids[0].atype || ''}`; + // if rubicon drop ^ + const id = eid.source === 'rubiconproject.com' ? eid.uids[0].id : `${eid.uids[0].id}^${eid.uids[0].atype || ''}` + data[`eid_${eid.source}`] = id; } // send AE "ppuid" signal if exists, and hasn't already been sent if (!data['ppuid']) { @@ -565,6 +569,11 @@ export const spec = { data['us_privacy'] = encodeURIComponent(bidderRequest.uspConsent); } + if (bidderRequest.gppConsent?.gppString) { + data['gpp'] = bidderRequest.gppConsent.gppString; + data['gpp_sid'] = bidderRequest.gppConsent?.applicableSections?.toString(); + } + data['rp_maxbids'] = bidderRequest.bidLimit || 1; applyFPD(bidRequest, BANNER, data); @@ -607,106 +616,36 @@ export const spec = { /** * @param {*} responseObj - * @param {BidRequest|Object.} bidRequest - if request was SRA the bidRequest argument will be a keyed BidRequest array object, + * @param {BidRequest|Object.} request - if request was SRA the bidRequest argument will be a keyed BidRequest array object, * non-SRA responses return a plain BidRequest object * @return {Bid[]} An array of bids which */ - interpretResponse: function (responseObj, {bidRequest}) { + interpretResponse: function (responseObj, request) { responseObj = responseObj.body; + const {data} = request; // check overall response if (!responseObj || typeof responseObj !== 'object') { return []; } - // video response from PBS Java openRTB + // Response from PBS Java openRTB if (responseObj.seatbid) { const responseErrors = deepAccess(responseObj, 'ext.errors.rubicon'); if (Array.isArray(responseErrors) && responseErrors.length > 0) { logWarn('Rubicon: Error in video response'); } - const bids = []; - responseObj.seatbid.forEach(seatbid => { - (seatbid.bid || []).forEach(bid => { - let bidObject = { - requestId: bidRequest.bidId, - currency: responseObj.cur || 'USD', - creativeId: bid.crid, - cpm: bid.price || 0, - bidderCode: seatbid.seat, - ttl: 300, - netRevenue: rubiConf.netRevenue !== false, // If anything other than false, netRev is true - width: bid.w || deepAccess(bidRequest, 'mediaTypes.video.w') || deepAccess(bidRequest, 'params.video.playerWidth'), - height: bid.h || deepAccess(bidRequest, 'mediaTypes.video.h') || deepAccess(bidRequest, 'params.video.playerHeight'), - }; - - if (bid.id) { - bidObject.seatBidId = bid.id; - } - - if (bid.dealid) { - bidObject.dealId = bid.dealid; - } - - if (bid.adomain) { - deepSetValue(bidObject, 'meta.advertiserDomains', Array.isArray(bid.adomain) ? bid.adomain : [bid.adomain]); - } - - if (deepAccess(bid, 'ext.bidder.rp.advid')) { - deepSetValue(bidObject, 'meta.advertiserId', bid.ext.bidder.rp.advid); - } - - let serverResponseTimeMs = deepAccess(responseObj, 'ext.responsetimemillis.rubicon'); - if (bidRequest && serverResponseTimeMs) { - bidRequest.serverResponseTimeMs = serverResponseTimeMs; - } - - if (deepAccess(bid, 'ext.prebid.type') === VIDEO) { - bidObject.mediaType = VIDEO; - deepSetValue(bidObject, 'meta.mediaType', VIDEO); - const extPrebidTargeting = deepAccess(bid, 'ext.prebid.targeting'); - - // If ext.prebid.targeting exists, add it as a property value named 'adserverTargeting' - if (extPrebidTargeting && typeof extPrebidTargeting === 'object') { - bidObject.adserverTargeting = extPrebidTargeting; - } - - // try to get cache values from 'response.ext.prebid.cache.js' - // else try 'bid.ext.prebid.targeting' as fallback - if (bid.ext.prebid.cache && typeof bid.ext.prebid.cache.vastXml === 'object' && bid.ext.prebid.cache.vastXml.cacheId && bid.ext.prebid.cache.vastXml.url) { - bidObject.videoCacheKey = bid.ext.prebid.cache.vastXml.cacheId; - bidObject.vastUrl = bid.ext.prebid.cache.vastXml.url; - } else if (extPrebidTargeting && extPrebidTargeting.hb_uuid && extPrebidTargeting.hb_cache_host && extPrebidTargeting.hb_cache_path) { - bidObject.videoCacheKey = extPrebidTargeting.hb_uuid; - // build url using key and cache host - bidObject.vastUrl = `https://${extPrebidTargeting.hb_cache_host}${extPrebidTargeting.hb_cache_path}?uuid=${extPrebidTargeting.hb_uuid}`; - } - - if (bid.adm) { bidObject.vastXml = bid.adm; } - if (bid.nurl) { bidObject.vastUrl = bid.nurl; } - if (!bidObject.vastUrl && bid.nurl) { bidObject.vastUrl = bid.nurl; } - - const videoContext = deepAccess(bidRequest, 'mediaTypes.video.context'); - if (videoContext.toLowerCase() === 'outstream') { - bidObject.renderer = outstreamRenderer(bidObject); - } - } else { - logWarn('Rubicon: video response received non-video media type'); - } - - bids.push(bidObject); - }); - }); - + const bids = converter.fromORTB({request: data, response: responseObj}).bids; return bids; } let ads = responseObj.ads; let lastImpId; let multibid = 0; + const {bidRequest} = request; // video ads array is wrapped in an object - if (typeof bidRequest === 'object' && !Array.isArray(bidRequest) && bidType(bidRequest) === 'video' && typeof ads === 'object') { + if (typeof bidRequest === 'object' && !Array.isArray(bidRequest) && bidType(bidRequest).includes(VIDEO) && typeof ads === 'object') { ads = ads[bidRequest.adUnitCode]; } @@ -772,13 +711,12 @@ export const spec = { } else { logError(`Rubicon: bidRequest undefined at index position:${i}`, bidRequest, responseObj); } - return bids; }, []).sort((adA, adB) => { return (adB.cpm || 0.0) - (adA.cpm || 0.0); }); }, - getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent) { + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) { if (!hasSynced && syncOptions.iframeEnabled) { // data is only assigned if params are available to pass to syncEndpoint let params = {}; @@ -796,6 +734,11 @@ export const spec = { params['us_privacy'] = encodeURIComponent(uspConsent); } + if (gppConsent?.gppString) { + params['gpp'] = gppConsent.gppString; + params['gpp_sid'] = gppConsent.applicableSections?.toString(); + } + params = Object.keys(params).length ? `?${formatQS(params)}` : ''; hasSynced = true; @@ -830,11 +773,11 @@ function _getScreenResolution() { * @returns {string} */ function _getPageUrl(bidRequest, bidderRequest) { - let pageUrl = config.getConfig('pageUrl'); + let pageUrl; if (bidRequest.params.referrer) { pageUrl = bidRequest.params.referrer; - } else if (!pageUrl) { - pageUrl = bidderRequest.refererInfo.referer; + } else { + pageUrl = bidderRequest.refererInfo.page; } return bidRequest.params.secure ? pageUrl.replace(/^http:/i, 'https:') : pageUrl; } @@ -911,7 +854,7 @@ function outstreamRenderer(rtbBid) { function parseSizes(bid, mediaType) { let params = bid.params; - if (mediaType === 'video') { + if (mediaType === VIDEO) { let size = []; if (params.video && params.video.playerWidth && params.video.playerHeight) { size = [ @@ -933,7 +876,7 @@ function parseSizes(bid, mediaType) { } else if (typeof deepAccess(bid, 'mediaTypes.banner.sizes') !== 'undefined') { sizes = mapSizes(bid.mediaTypes.banner.sizes); } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { - sizes = mapSizes(bid.sizes) + sizes = mapSizes(bid.sizes); } else { logWarn('Rubicon: no sizes are setup or found'); } @@ -941,65 +884,6 @@ function parseSizes(bid, mediaType) { return masSizeOrdering(sizes); } -/** - * @param {Object} data - * @param bidRequest - * @param bidderRequest - */ -function appendSiteAppDevice(data, bidRequest, bidderRequest) { - if (!data) return; - - // ORTB specifies app OR site - if (typeof config.getConfig('app') === 'object') { - data.app = config.getConfig('app'); - } else { - data.site = { - page: _getPageUrl(bidRequest, bidderRequest) - } - } - if (typeof config.getConfig('device') === 'object') { - data.device = config.getConfig('device'); - } - // Add language to site and device objects if there - if (bidRequest.params.video.language) { - ['site', 'device'].forEach(function(param) { - if (data[param]) { - if (param === 'site') { - data[param].content = Object.assign({language: bidRequest.params.video.language}, data[param].content) - } else { - data[param] = Object.assign({language: bidRequest.params.video.language}, data[param]) - } - } - }); - } -} - -/** - * @param {Object} data - * @param {BidRequest} bidRequest - */ -function addVideoParameters(data, bidRequest) { - if (typeof data.imp[0].video === 'object' && data.imp[0].video.skip === undefined) { - data.imp[0].video.skip = bidRequest.params.video.skip; - } - if (typeof data.imp[0].video === 'object' && data.imp[0].video.skipafter === undefined) { - data.imp[0].video.skipafter = bidRequest.params.video.skipdelay; - } - // video.pos can already be specified by adunit.mediatypes.video.pos. - // but if not, it might be specified in the params - if (typeof data.imp[0].video === 'object' && data.imp[0].video.pos === undefined) { - if (bidRequest.params.position === 'atf') { - data.imp[0].video.pos = 1; - } else if (bidRequest.params.position === 'btf') { - data.imp[0].video.pos = 3; - } - } - - const size = parseSizes(bidRequest, 'video') - data.imp[0].video.w = size[0] - data.imp[0].video.h = size[1] -} - function applyFPD(bidRequest, mediaType, data) { const BID_FPD = { user: {ext: {data: {...bidRequest.params.visitor}}}, @@ -1008,8 +892,9 @@ function applyFPD(bidRequest, mediaType, data) { if (bidRequest.params.keywords) BID_FPD.site.keywords = (isArray(bidRequest.params.keywords)) ? bidRequest.params.keywords.join(',') : bidRequest.params.keywords; - let fpd = mergeDeep({}, config.getConfig('ortb2') || {}, BID_FPD); - let impData = deepAccess(bidRequest.ortb2Imp, 'ext.data') || {}; + let fpd = mergeDeep({}, bidRequest.ortb2 || {}, BID_FPD); + let impExt = deepAccess(bidRequest.ortb2Imp, 'ext') || {}; + let impExtData = deepAccess(bidRequest.ortb2Imp, 'ext.data') || {}; const gpid = deepAccess(bidRequest, 'ortb2Imp.ext.gpid'); const SEGTAX = {user: [4], site: [1, 2, 5, 6]}; @@ -1025,7 +910,7 @@ function applyFPD(bidRequest, mediaType, data) { if (segments.length > 0) return segments.toString(); }).toString(); } else if (typeof prop === 'object' && !Array.isArray(prop)) { - logWarn('Rubicon: Filtered FPD key: ', key, ': Expected value to be string, integer, or an array of strings/ints'); + return undefined; } else if (typeof prop !== 'undefined') { return (Array.isArray(prop)) ? prop.filter(value => { if (typeof value !== 'object' && typeof value !== 'undefined') return value.toString(); @@ -1038,7 +923,7 @@ function applyFPD(bidRequest, mediaType, data) { let val = validate(obj, key, name); let loc = (MAP[key] && isParent) ? `${MAP[key]}` : (key === 'data') ? `${MAP[name]}iab` : `${MAP[name]}${key}`; data[loc] = (data[loc]) ? data[loc].concat(',', val) : val; - } + }; if (mediaType === BANNER) { ['site', 'user'].forEach(name => { @@ -1054,11 +939,11 @@ function applyFPD(bidRequest, mediaType, data) { } }); }); - Object.keys(impData).forEach((key) => { + Object.keys(impExtData).forEach((key) => { if (key !== 'adserver') { - addBannerData(impData[key], 'site', key); - } else if (impData[key].name === 'gam') { - addBannerData(impData[key].adslot, name, key) + addBannerData(impExtData[key], 'site', key); + } else if (impExtData[key].name === 'gam') { + addBannerData(impExtData[key].adslot, name, key) } }); @@ -1072,8 +957,8 @@ function applyFPD(bidRequest, mediaType, data) { delete data['tg_i.dfp_ad_unit_code']; } } else { - if (Object.keys(impData).length) { - mergeDeep(data.imp[0].ext, {data: impData}); + if (Object.keys(impExt).length) { + mergeDeep(data.imp[0].ext, impExt); } // add in gpid if (gpid) { @@ -1102,63 +987,84 @@ function mapSizes(sizes) { /** * Test if bid has mediaType or mediaTypes set for video. - * Also makes sure the video object is present in the rubicon bidder params + * Also checks if the video object is present in the rubicon bidder params * @param {BidRequest} bidRequest * @returns {boolean} */ -export function hasVideoMediaType(bidRequest) { - if (typeof deepAccess(bidRequest, 'params.video') !== 'object') { - return false; +export function classifiedAsVideo(bidRequest) { + let isVideo = typeof deepAccess(bidRequest, `mediaTypes.${VIDEO}`) !== 'undefined'; + let isBanner = typeof deepAccess(bidRequest, `mediaTypes.${BANNER}`) !== 'undefined'; + let isBidOnMultiformat = typeof deepAccess(bidRequest, `params.bidonmultiformat`) !== 'undefined'; + let isMissingVideoParams = typeof deepAccess(bidRequest, 'params.video') !== 'object'; + // If an ad has both video and banner types, a legacy implementation allows choosing video over banner + // based on whether or not there is a video object defined in the params + // Given this legacy implementation, other code depends on params.video being defined + + // if it's bidonmultiformat, we don't care of the video object + if (isVideo && isBidOnMultiformat) return true; + + if (isBanner && isMissingVideoParams) { + isVideo = false; + } + if (isVideo && isMissingVideoParams) { + deepSetValue(bidRequest, 'params.video', {}); } - return (typeof deepAccess(bidRequest, `mediaTypes.${VIDEO}`) !== 'undefined'); + return isVideo; } /** - * Determine bidRequest mediaType + * Determine bidRequest mediaTypes. All mediaTypes must be correct. If one fails, all the others will fail too. * @param bid the bid to test - * @param log whether we should log errors/warnings for invalid bids - * @returns {string|undefined} Returns 'video' or 'banner' if resolves to a type, or undefined otherwise (invalid). + * @param log boolean. whether we should log errors/warnings for invalid bids + * @returns {string|undefined} Returns an array containing one of 'video' or 'banner' or 'native' if resolves to a type. */ function bidType(bid, log = false) { // Is it considered video ad unit by rubicon - if (hasVideoMediaType(bid)) { + let bidTypes = []; + if (classifiedAsVideo(bid)) { // Removed legacy mediaType support. new way using mediaTypes.video object is now required // We require either context as instream or outstream if (['outstream', 'instream'].indexOf(deepAccess(bid, `mediaTypes.${VIDEO}.context`)) === -1) { if (log) { logError('Rubicon: mediaTypes.video.context must be outstream or instream'); } - return; + return bidTypes; } // we require playerWidth and playerHeight to come from one of params.playerWidth/playerHeight or mediaTypes.video.playerSize or adUnit.sizes - if (parseSizes(bid, 'video').length < 2) { + if (parseSizes(bid, VIDEO).length < 2) { if (log) { logError('Rubicon: could not determine the playerSize of the video'); } - return; + return bidTypes; } if (log) { logMessage('Rubicon: making video request for adUnit', bid.adUnitCode); } - return 'video'; - } else { + bidTypes.push(VIDEO); + } + if (typeof deepAccess(bid, `mediaTypes.${NATIVE}`) !== 'undefined') { + bidTypes.push(NATIVE); + } + + if (typeof deepAccess(bid, `mediaTypes.${BANNER}`) !== 'undefined') { // we require banner sizes to come from one of params.sizes or mediaTypes.banner.sizes or adUnit.sizes, in that order // if we cannot determine them, we reject it! - if (parseSizes(bid, 'banner').length === 0) { + if (parseSizes(bid, BANNER).length === 0) { if (log) { logError('Rubicon: could not determine the sizes for banner request'); } - return; + return bidTypes; } // everything looks good for banner so lets do it if (log) { logMessage('Rubicon: making banner request for adUnit', bid.adUnitCode); } - return 'banner'; + bidTypes.push(BANNER); } + return bidTypes; } export const resetRubiConf = () => rubiConf = {}; @@ -1262,8 +1168,7 @@ export function hasValidSupplyChainParams(schain) { } /** - * Creates a URL key value param, encoding the - * param unless the key is schain + * Creates a URL key value param, encoding the param unless the key is schain * @param {String} key * @param {String} param * @returns {String} @@ -1289,4 +1194,60 @@ export function resetUserSync() { hasSynced = false; } +/** + * Sets the floor on the bidRequest. imp.bidfloor and imp.bidfloorcur + * should be already set by the conversion library. if they're not, + * or invalid, try to read from params.floor. + * @param {*} bidRequest + * @param {*} imp + */ +function setBidFloors(bidRequest, imp) { + if (imp.bidfloorcur != 'USD') { + delete imp.bidfloor; + delete imp.bidfloorcur; + } + + if (!imp.bidfloor) { + let bidFloor = parseFloat(deepAccess(bidRequest, 'params.floor')); + + if (!isNaN(bidFloor)) { + imp.bidfloor = bidFloor; + imp.bidfloorcur = 'USD'; + } + } +} + +function addOrtbFirstPartyData(data, nonBannerRequests, ortb2) { + let fpd = {}; + const keywords = getAllOrtbKeywords(ortb2, ...nonBannerRequests.map(req => req.params.keywords)) + nonBannerRequests.forEach(bidRequest => { + const bidFirstPartyData = { + user: {ext: {data: {...bidRequest.params.visitor}}}, + site: {ext: {data: {...bidRequest.params.inventory}}} + }; + + // add site.content.language + const impThatHasVideoLanguage = data.imp.find(imp => imp.ext?.prebid?.bidder?.rubicon?.video?.language); + if (impThatHasVideoLanguage) { + bidFirstPartyData.site.content = { + language: impThatHasVideoLanguage.ext?.prebid?.bidder?.rubicon?.video?.language + } + } + + fpd = mergeDeep(fpd, bidRequest.ortb2 || {}, bidFirstPartyData); + + // add user.id from config. + // NOTE: This is DEPRECATED. user.id should come from setConfig({ortb2}). + const configUserId = config.getConfig('user.id'); + fpd.user.id = fpd.user.id || configUserId; + }); + + mergeDeep(data, fpd); + + if (keywords && keywords.length) { + deepSetValue(data, 'site.keywords', keywords.join(',')); + } + delete data?.ext?.prebid?.storedrequest; +} + registerBidder(spec); diff --git a/modules/saambaaBidAdapter.js b/modules/saambaaBidAdapter.js index 36ab50bfddd..da6e7028abe 100644 --- a/modules/saambaaBidAdapter.js +++ b/modules/saambaaBidAdapter.js @@ -1,3 +1,5 @@ +// TODO: this adapter appears to have no tests + import {deepAccess, generateUUID, isEmpty, isFn, parseSizesInput, parseUrl} from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; @@ -60,7 +62,6 @@ export const spec = { if (isVideoBid(bidRequest)) { let bidResponse = { requestId: response.id, - bidderCode: BIDDER_CODE, cpm: response.seatbid[0].bid[0].price, width: response.seatbid[0].bid[0].w, height: response.seatbid[0].bid[0].h, @@ -321,8 +322,7 @@ function createVideoRequestData(bid, bidderRequest) { } function getTopWindowLocation(bidderRequest) { - let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer; - return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true }); + return parseUrl(bidderRequest?.refererInfo?.page || '', { decodeSearchAsString: true }); } function createBannerRequestData(bid, bidderRequest) { diff --git a/modules/saraBidAdapter.md b/modules/saraBidAdapter.md deleted file mode 100644 index 65572528181..00000000000 --- a/modules/saraBidAdapter.md +++ /dev/null @@ -1,40 +0,0 @@ -# Overview - -Module Name: Sara Bidder Adapter -Module Type: Bidder Adapter -Maintainer: github@sara.media - -# Description - -Module that connects to Sara demand source to fetch bids. - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "sara", - params: { - uid: '5', - priceType: 'gross' // by default is 'net' - } - } - ] - },{ - code: 'test-div', - sizes: [[728, 90]], - bids: [ - { - bidder: "sara", - params: { - uid: 6, - priceType: 'gross' - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/scaleableAnalyticsAdapter.js b/modules/scaleableAnalyticsAdapter.js index d7379462e0d..46f9d45d84d 100644 --- a/modules/scaleableAnalyticsAdapter.js +++ b/modules/scaleableAnalyticsAdapter.js @@ -2,7 +2,7 @@ import { ajax } from '../src/ajax.js'; import CONSTANTS from '../src/constants.json'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import { logMessage } from '../src/utils.js'; diff --git a/modules/scatteredBidAdapter.js b/modules/scatteredBidAdapter.js new file mode 100644 index 00000000000..47dc09cd1b2 --- /dev/null +++ b/modules/scatteredBidAdapter.js @@ -0,0 +1,72 @@ +// jshint esversion: 6, es3: false, node: true +'use strict'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { deepAccess, logInfo } from '../src/utils.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; + +const BIDDER_CODE = 'scattered'; +const GVLID = 1179; +export const converter = ortbConverter({ + context: { + mediaType: BANNER, + ttl: 360, + netRevenue: true + } +}) + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER], + + // 1. + isBidRequestValid: function (bid) { + const bidderDomain = deepAccess(bid, 'params.bidderDomain') + if (bidderDomain === undefined || bidderDomain === '') { + return false + } + + const sizes = deepAccess(bid, 'mediaTypes.banner.sizes') + if (sizes === undefined || sizes.length < 1) { + return false + } + + return true + }, + + // 2. + buildRequests: function (bidRequests, bidderRequest) { + return { + method: 'POST', + url: 'https://' + getKeyOnAny(bidRequests, 'params.bidderDomain'), + data: converter.toORTB({ bidderRequest, bidRequests }), + options: { + contentType: 'application/json' + }, + }; + }, + + // 3. + interpretResponse: function (response, request) { + if (!response.body) return; + return converter.fromORTB({ response: response.body, request: request.data }).bids; + }, + + // 4 + onBidWon: function (bid) { + logInfo('onBidWon', bid) + } +} + +function getKeyOnAny(collection, key) { + for (let i = 0; i < collection.length; i++) { + const result = deepAccess(collection[i], key); + if (result) { + return result; + } + } +} + +registerBidder(spec); diff --git a/modules/scatteredBidAdapter.md b/modules/scatteredBidAdapter.md new file mode 100644 index 00000000000..031d953e32b --- /dev/null +++ b/modules/scatteredBidAdapter.md @@ -0,0 +1,36 @@ +# Overview + +``` +Module Name: Scattered Adapter +Module Type: Bidder Adapter +Maintainer: office@scattered.pl +``` + +# Description + +Module that connects to Scattered's demand sources. +It uses OpenRTB standard to communicate between the adapter and bidding servers. + +# Test Parameters + +```javascript + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + banner: { + sizes: [[300, 250]], // a display size + } + }, + bids: [ + { + bidder: "scattered", + params: { + bidderDomain: "prebid-test.scattered.eu/bid", + test: 0 + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/schain.js b/modules/schain.js index d409e74df48..726679b133f 100644 --- a/modules/schain.js +++ b/modules/schain.js @@ -1,6 +1,19 @@ -import { config } from '../src/config.js'; +import {config} from '../src/config.js'; import adapterManager from '../src/adapterManager.js'; -import { isNumber, isStr, isArray, isPlainObject, hasOwn, logError, isInteger, _each, logWarn } from '../src/utils.js'; +import { + _each, + deepAccess, + deepClone, + deepSetValue, + isArray, + isInteger, + isNumber, + isPlainObject, + isStr, + logError, + logWarn +} from '../src/utils.js'; +import {registerOrtbProcessor, REQUEST} from '../src/pbjsORTB.js'; // https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md @@ -19,7 +32,7 @@ _each(MODE, mode => MODES.push(mode)); // validate the supply chain object export function isSchainObjectValid(schainObject, returnOnError) { - let failPrefix = 'Detected something wrong within an schain config:' + let failPrefix = 'Detected something wrong within an schain config:'; let failMsg = ''; function appendFailMsg(msg) { @@ -51,7 +64,7 @@ export function isSchainObjectValid(schainObject, returnOnError) { } // ext: Object [optional] - if (hasOwn(schainObject, 'ext')) { + if (schainObject.hasOwnProperty('ext')) { if (!isPlainObject(schainObject.ext)) { appendFailMsg(`schain.config.ext` + shouldBeAnObject); } @@ -80,28 +93,28 @@ export function isSchainObjectValid(schainObject, returnOnError) { } // rid: String [Optional] - if (hasOwn(node, 'rid')) { + if (node.hasOwnProperty('rid')) { if (!isStr(node.rid)) { appendFailMsg(`schain.config.nodes[${index}].rid` + shouldBeAString); } } // name: String [Optional] - if (hasOwn(node, 'name')) { + if (node.hasOwnProperty('name')) { if (!isStr(node.name)) { appendFailMsg(`schain.config.nodes[${index}].name` + shouldBeAString); } } // domain: String [Optional] - if (hasOwn(node, 'domain')) { + if (node.hasOwnProperty('domain')) { if (!isStr(node.domain)) { appendFailMsg(`schain.config.nodes[${index}].domain` + shouldBeAString); } } // ext: Object [Optional] - if (hasOwn(node, 'ext')) { + if (node.hasOwnProperty('ext')) { if (!isPlainObject(node.ext)) { appendFailMsg(`schain.config.nodes[${index}].ext` + shouldBeAnObject); } @@ -168,7 +181,7 @@ export function makeBidRequestsHook(fn, bidderRequests) { bidderRequest.bids.forEach(bid => { let result = resolveSchainConfig(schainConfig, bidder); if (result) { - bid.schain = result; + bid.schain = deepClone(result); } }); }); @@ -181,3 +194,14 @@ export function init() { } init() + +export function setOrtbSourceExtSchain(ortbRequest, bidderRequest, context) { + if (!deepAccess(ortbRequest, 'source.ext.schain')) { + const schain = deepAccess(context, 'bidRequests.0.schain'); + if (schain) { + deepSetValue(ortbRequest, 'source.ext.schain', schain); + } + } +} + +registerOrtbProcessor({type: REQUEST, name: 'sourceExtSchain', fn: setOrtbSourceExtSchain}); diff --git a/modules/seedingAllianceBidAdapter.js b/modules/seedingAllianceBidAdapter.js index 05dcf15909a..e287ea7ff78 100755 --- a/modules/seedingAllianceBidAdapter.js +++ b/modules/seedingAllianceBidAdapter.js @@ -1,151 +1,146 @@ // jshint esversion: 6, es3: false, node: true 'use strict'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { NATIVE } from '../src/mediaTypes.js'; -import { _map, deepSetValue, isEmpty, deepAccess } from '../src/utils.js'; -import { config } from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, NATIVE} from '../src/mediaTypes.js'; +import {_map, deepSetValue, isArray, isEmpty, replaceAuctionPrice} from '../src/utils.js'; +import {config} from '../src/config.js'; +import {convertOrtbRequestToProprietaryNative} from '../src/native.js'; +const GVL_ID = 371; const BIDDER_CODE = 'seedingAlliance'; const DEFAULT_CUR = 'EUR'; -const ENDPOINT_URL = 'https://b.nativendo.de/cds/rtb/bid?format=openrtb2.5&ssp=nativendo'; +const ENDPOINT_URL = 'https://b.nativendo.de/cds/rtb/bid?format=openrtb2.5&ssp=pb'; -const NATIVE_ASSET_IDS = {0: 'title', 1: 'body', 2: 'sponsoredBy', 3: 'image', 4: 'cta', 5: 'icon'}; +const NATIVE_ASSET_IDS = { 0: 'title', 1: 'body', 2: 'sponsoredBy', 3: 'image', 4: 'cta', 5: 'icon' }; const NATIVE_PARAMS = { - title: { - id: 0, - name: 'title' - }, - - body: { - id: 1, - name: 'data', - type: 2 - }, - - sponsoredBy: { - id: 2, - name: 'data', - type: 1 - }, - - image: { - id: 3, - type: 3, - name: 'img' - }, - - cta: { - id: 4, - type: 12, - name: 'data' - }, - - icon: { - id: 5, - type: 1, - name: 'img' - } + title: { id: 0, name: 'title' }, + body: { id: 1, name: 'data', type: 2 }, + sponsoredBy: { id: 2, name: 'data', type: 1 }, + image: { id: 3, type: 3, name: 'img' }, + cta: { id: 4, type: 12, name: 'data' }, + icon: { id: 5, type: 1, name: 'img' } }; export const spec = { code: BIDDER_CODE, + gvlid: GVL_ID, + supportedMediaTypes: [NATIVE, BANNER], - supportedMediaTypes: [NATIVE], - - isBidRequestValid: function(bid) { + isBidRequestValid: function (bid) { return !!bid.params.adUnitId; }, - buildRequests: (validBidRequests, bidderRequest) => { - const pt = setOnAny(validBidRequests, 'params.pt') || setOnAny(validBidRequests, 'params.priceType') || 'net'; - const tid = validBidRequests[0].transactionId; - const cur = [config.getConfig('currency.adServerCurrency') || DEFAULT_CUR]; - let url = bidderRequest.refererInfo.referer; + buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); - const imp = validBidRequests.map((bid, id) => { - const assets = _map(bid.nativeParams, (bidParams, key) => { - const props = NATIVE_PARAMS[key]; + let url = bidderRequest.refererInfo.page; - const asset = { - required: bidParams.required & 1 - }; + const imps = validBidRequests.map((bidRequest, id) => { + const imp = { + id: String(id + 1), + tagid: bidRequest.params.adUnitId + }; - if (props) { - asset.id = props.id; + /** + * Native Ad + */ + if (bidRequest.nativeParams) { + const assets = _map(bidRequest.nativeParams, (nativeAsset, key) => { + const props = NATIVE_PARAMS[key]; + + if (props) { + let wmin, hmin, w, h; + let aRatios = nativeAsset.aspect_ratios; + + if (aRatios && aRatios[0]) { + aRatios = aRatios[0]; + wmin = aRatios.min_width || 0; + hmin = aRatios.ratio_height * wmin / aRatios.ratio_width | 0; + } - let w, h; + if (nativeAsset.sizes) { + const sizes = flatten(nativeAsset.sizes); + w = parseInt(sizes[0], 10); + h = parseInt(sizes[1], 10); + } - if (bidParams.sizes) { - w = bidParams.sizes[0]; - h = bidParams.sizes[1]; + const asset = { + id: props.id, + required: nativeAsset.required & 1 + }; + + asset[props.name] = { + len: nativeAsset.len, + type: props.type, + wmin, + hmin, + w, + h + }; + + return asset; + } else { + // TODO Filter impressions with required assets we don't support } + }).filter(Boolean); - asset[props.name] = { - len: bidParams.len, - type: props.type, - w, - h - }; + imp.native = { + request: { + assets + } + }; + } else { + let sizes = transformSizes(bidRequest.sizes); - return asset; + imp.banner = { + format: sizes, + w: sizes[0] ? sizes[0].w : 0, + h: sizes[0] ? sizes[0].h : 0 } - }) - .filter(Boolean); + } - if (bid.params.url) { - url = bid.params.url; + if (bidRequest.params.url) { + url = bidRequest.params.url; } - return { - id: String(id + 1), - tagid: bid.params.adUnitId, - tid: tid, - pt: pt, - native: { - request: { - assets - } - } - }; + return imp; }); const request = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, site: { page: url }, - device: { - ua: navigator.userAgent - }, - cur, - imp, - user: {}, + cur: [config.getConfig('currency.adServerCurrency') || DEFAULT_CUR], + imp: imps, + tmax: bidderRequest.timeout, regs: { ext: { - gdpr: 0 + gdpr: 0, + pb_ver: '$prebid.version$' } } }; - if (bidderRequest && bidderRequest.gdprConsent) { + if (bidderRequest.gdprConsent) { + request.user = {}; + deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString); deepSetValue(request, 'regs.ext.gdpr', (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0); } return { method: 'POST', - url: ENDPOINT_URL, + url: config.getConfig('seedingAlliance.endpoint') || ENDPOINT_URL, data: JSON.stringify(request), - options: { - contentType: 'application/json' - }, - bids: validBidRequests + bidRequests: validBidRequests }; }, - interpretResponse: function(serverResponse, { bids }) { + interpretResponse: function (serverResponse, { bidRequests }) { if (isEmpty(serverResponse.body)) { return []; } @@ -157,41 +152,80 @@ export const spec = { return result; }, []) : []; - return bids - .map((bid, id) => { + return bidRequests + .map((bidRequest, id) => { const bidResponse = bidResponses[id]; + const type = bidRequest.nativeParams ? NATIVE : BANNER; + if (bidResponse) { - return { - requestId: bid.bidId, + const bidObject = { + requestId: bidRequest.bidId, // TODO get this value from response? cpm: bidResponse.price, creativeId: bidResponse.crid, - ttl: 1000, - netRevenue: (!bid.netRevenue || bid.netRevenue === 'net'), + ttl: 600, + netRevenue: true, currency: cur, - mediaType: NATIVE, - bidderCode: BIDDER_CODE, - native: parseNative(bidResponse), + mediaType: type, meta: { advertiserDomains: bidResponse.adomain && bidResponse.adomain.length > 0 ? bidResponse.adomain : [] } }; + + if (type === NATIVE) { + bidObject.native = parseNative(bidResponse); + bidObject.mediaType = NATIVE; + } + + if (type === BANNER) { + bidObject.ad = replaceAuctionPrice(bidResponse.adm, bidResponse.price); + bidObject.width = bidResponse.w; + bidObject.height = bidResponse.h; + bidObject.mediaType = BANNER; + } + + return bidObject; } }) .filter(Boolean); } }; -registerBidder(spec); +function transformSizes(requestSizes) { + if (!isArray(requestSizes)) { + return []; + } + + if (requestSizes.length === 2 && !isArray(requestSizes[0])) { + return [{ + w: parseInt(requestSizes[0], 10), + h: parseInt(requestSizes[1], 10) + }]; + } else if (isArray(requestSizes[0])) { + return requestSizes.map(item => ({ + w: parseInt(item[0], 10), + h: parseInt(item[1], 10) + })); + } + + return []; +} + +function flatten(arr) { + return [].concat(...arr); +} function parseNative(bid) { - const {assets, link, imptrackers} = bid.adm.native; + const { assets, link, imptrackers } = bid.adm.native; + + let clickUrl = link.url.replace(/\$\{AUCTION_PRICE\}/g, bid.price); if (link.clicktrackers) { link.clicktrackers.forEach(function (clicktracker, index) { link.clicktrackers[index] = clicktracker.replace(/\$\{AUCTION_PRICE\}/g, bid.price); }); } + if (imptrackers) { imptrackers.forEach(function (imptracker, index) { imptrackers[index] = imptracker.replace(/\$\{AUCTION_PRICE\}/g, bid.price); @@ -199,8 +233,8 @@ function parseNative(bid) { } const result = { - url: link.url, - clickUrl: link.url, + url: clickUrl, + clickUrl: clickUrl, clickTrackers: link.clicktrackers || undefined, impressionTrackers: imptrackers || undefined }; @@ -217,15 +251,4 @@ function parseNative(bid) { return result; } -function setOnAny(collection, key) { - for (let i = 0, result; i < collection.length; i++) { - result = deepAccess(collection[i], key); - if (result) { - return result; - } - } -} - -function flatten(arr) { - return [].concat(...arr); -} +registerBidder(spec); diff --git a/modules/seedtagBidAdapter.js b/modules/seedtagBidAdapter.js index 2f61e0bc56a..7ac7d048c50 100644 --- a/modules/seedtagBidAdapter.js +++ b/modules/seedtagBidAdapter.js @@ -1,18 +1,18 @@ import { isArray, _map, triggerPixel } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js' -import { VIDEO, BANNER } from '../src/mediaTypes.js' +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { VIDEO, BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'seedtag'; const SEEDTAG_ALIAS = 'st'; const SEEDTAG_SSP_ENDPOINT = 'https://s.seedtag.com/c/hb/bid'; const SEEDTAG_SSP_ONTIMEOUT_ENDPOINT = 'https://s.seedtag.com/se/hb/timeout'; -const ALLOWED_PLACEMENTS = { - inImage: true, - inScreen: true, - inArticle: true, - banner: true, - video: true -} +const ALLOWED_DISPLAY_PLACEMENTS = [ + 'inScreen', + 'inImage', + 'inArticle', + 'inBanner', +]; // Global Vendor List Id // https://iabeurope.eu/vendor-list-tcf-v2-0/ @@ -20,27 +20,33 @@ const GVLID = 157; const mediaTypesMap = { [BANNER]: 'display', - [VIDEO]: 'video' + [VIDEO]: 'video', }; const deviceConnection = { FIXED: 'fixed', MOBILE: 'mobile', - UNKNOWN: 'unknown' + UNKNOWN: 'unknown', }; const getConnectionType = () => { - const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection || {} + const connection = + navigator.connection || + navigator.mozConnection || + navigator.webkitConnection || + {}; switch (connection.type || connection.effectiveType) { case 'wifi': case 'ethernet': - return deviceConnection.FIXED + return deviceConnection.FIXED; case 'cellular': case 'wimax': - return deviceConnection.MOBILE + return deviceConnection.MOBILE; default: - const isMobile = /iPad|iPhone|iPod/.test(navigator.userAgent) || /android/i.test(navigator.userAgent) - return isMobile ? deviceConnection.UNKNOWN : deviceConnection.FIXED + const isMobile = + /iPad|iPhone|iPod/.test(navigator.userAgent) || + /android/i.test(navigator.userAgent); + return isMobile ? deviceConnection.UNKNOWN : deviceConnection.FIXED; } }; @@ -51,24 +57,46 @@ function mapMediaType(seedtagMediaType) { } function hasVideoMediaType(bid) { - return (!!bid.mediaTypes && !!bid.mediaTypes.video) || (!!bid.params && !!bid.params.video) + return !!bid.mediaTypes && !!bid.mediaTypes.video; +} + +function hasBannerMediaType(bid) { + return !!bid.mediaTypes && !!bid.mediaTypes.banner; } -function hasMandatoryParams(params) { +function hasMandatoryDisplayParams(bid) { + const p = bid.params; return ( - !!params.publisherId && - !!params.adUnitId && - !!params.placement && - !!ALLOWED_PLACEMENTS[params.placement] + !!p.publisherId && + !!p.adUnitId && + ALLOWED_DISPLAY_PLACEMENTS.indexOf(p.placement) > -1 ); } function hasMandatoryVideoParams(bid) { - const videoParams = getVideoParams(bid) + const videoParams = getVideoParams(bid); - return hasVideoMediaType(bid) && !!videoParams.playerSize && + let isValid = + !!bid.params.publisherId && + !!bid.params.adUnitId && + hasVideoMediaType(bid) && + !!videoParams.playerSize && isArray(videoParams.playerSize) && videoParams.playerSize.length > 0; + + switch (bid.params.placement) { + // instream accept only video format + case 'inStream': + return isValid && videoParams.context === 'instream'; + // outstream accept banner/native/video format + default: + return ( + isValid && + videoParams.context === 'outstream' && + hasBannerMediaType(bid) && + hasMandatoryDisplayParams(bid) + ); + } } function buildBidRequest(validBidRequest) { @@ -82,21 +110,17 @@ function buildBidRequest(validBidRequest) { const bidRequest = { id: validBidRequest.bidId, - transactionId: validBidRequest.transactionId, + transactionId: validBidRequest.ortb2Imp?.ext?.tid, sizes: validBidRequest.sizes, supplyTypes: mediaTypes, adUnitId: params.adUnitId, adUnitCode: validBidRequest.adUnitCode, placement: params.placement, - requestCount: validBidRequest.bidderRequestsCount || 1 // FIXME : in unit test the parameter bidderRequestsCount is undefined + requestCount: validBidRequest.bidderRequestsCount || 1, // FIXME : in unit test the parameter bidderRequestsCount is undefined }; - if (params.adPosition) { - bidRequest.adPosition = params.adPosition; - } - if (hasVideoMediaType(validBidRequest)) { - bidRequest.videoParams = getVideoParams(validBidRequest) + bidRequest.videoParams = getVideoParams(validBidRequest); } return bidRequest; @@ -112,13 +136,7 @@ function getVideoParams(validBidRequest) { videoParams.h = videoParams.playerSize[0][1]; } - const bidderVideoParams = (validBidRequest.params && validBidRequest.params.video) || {} - // override video params from seedtag bidder params - Object.keys(bidderVideoParams).forEach(key => { - videoParams[key] = validBidRequest.params.video[key] - }) - - return videoParams + return videoParams; } function buildBidResponse(seedtagBid) { @@ -135,8 +153,11 @@ function buildBidResponse(seedtagBid) { ttl: seedtagBid.ttl, nurl: seedtagBid.nurl, meta: { - advertiserDomains: seedtagBid && seedtagBid.adomain && seedtagBid.adomain.length > 0 ? seedtagBid.adomain : [] - } + advertiserDomains: + seedtagBid && seedtagBid.adomain && seedtagBid.adomain.length > 0 + ? seedtagBid.adomain + : [], + }, }; if (mediaType === VIDEO) { @@ -147,19 +168,54 @@ function buildBidResponse(seedtagBid) { return bid; } -export function getTimeoutUrl (data) { +/** + * + * @returns Measure time to first byte implementation + * @see https://web.dev/ttfb/ + * https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API + */ +function ttfb() { + const ttfb = (() => { + // Timing API V2 + try { + const entry = performance.getEntriesByType('navigation')[0]; + return Math.round(entry.responseStart - entry.startTime); + } catch (e) { + // Timing API V1 + try { + const entry = performance.timing; + return Math.round(entry.responseStart - entry.fetchStart); + } catch (e) { + // Timing API not available + return 0; + } + } + })(); + + // prevent negative or excessive value + // @see https://github.com/googleChrome/web-vitals/issues/162 + // https://github.com/googleChrome/web-vitals/issues/137 + return ttfb >= 0 && ttfb <= performance.now() ? ttfb : 0; +} + +export function getTimeoutUrl(data) { let queryParams = ''; if ( - isArray(data) && data[0] && - isArray(data[0].params) && data[0].params[0] + isArray(data) && + data[0] && + isArray(data[0].params) && + data[0].params[0] ) { const params = data[0].params[0]; - const timeout = data[0].timeout + const timeout = data[0].timeout; queryParams = - '?publisherToken=' + params.publisherId + - '&adUnitId=' + params.adUnitId + - '&timeout=' + timeout; + '?publisherToken=' + + params.publisherId + + '&adUnitId=' + + params.adUnitId + + '&timeout=' + + timeout; } return SEEDTAG_SSP_ONTIMEOUT_ENDPOINT + queryParams; } @@ -177,8 +233,8 @@ export const spec = { */ isBidRequestValid(bid) { return hasVideoMediaType(bid) - ? hasMandatoryParams(bid.params) && hasMandatoryVideoParams(bid) - : hasMandatoryParams(bid.params); + ? hasMandatoryVideoParams(bid) + : hasMandatoryDisplayParams(bid); }, /** @@ -189,13 +245,15 @@ export const spec = { */ buildRequests(validBidRequests, bidderRequest) { const payload = { - url: bidderRequest.refererInfo.referer, + url: bidderRequest.refererInfo.page, publisherToken: validBidRequests[0].params.publisherId, cmp: !!bidderRequest.gdprConsent, timeout: bidderRequest.timeout, version: '$prebid.version$', connectionType: getConnectionType(), - bidRequests: _map(validBidRequests, buildBidRequest) + auctionStart: bidderRequest.auctionStart || Date.now(), + ttfb: ttfb(), + bidRequests: _map(validBidRequests, buildBidRequest), }; if (payload.cmp) { @@ -203,13 +261,37 @@ export const spec = { if (gdprApplies !== undefined) payload['ga'] = gdprApplies; payload['cd'] = bidderRequest.gdprConsent.consentString; } + if (bidderRequest.uspConsent) { + payload['uspConsent'] = bidderRequest.uspConsent; + } + + if (validBidRequests[0].schain) { + payload.schain = validBidRequests[0].schain; + } + + let coppa = config.getConfig('coppa'); + if (coppa) { + payload.coppa = coppa; + } + + if (bidderRequest.gppConsent) { + payload.gppConsent = { + gppString: bidderRequest.gppConsent.gppString, + applicableSections: bidderRequest.gppConsent.applicableSections + } + } else if (bidderRequest.ortb2?.regs?.gpp) { + payload.gppConsent = { + gppString: bidderRequest.ortb2.regs.gpp, + applicableSections: bidderRequest.ortb2.regs.gpp_sid + } + } - const payloadString = JSON.stringify(payload) + const payloadString = JSON.stringify(payload); return { method: 'POST', url: SEEDTAG_SSP_ENDPOINT, - data: payloadString - } + data: payloadString, + }; }, /** @@ -218,10 +300,10 @@ export const spec = { * @param {ServerResponse} serverResponse A successful response from the server. * @return {Bid[]} An array of bids which were nested inside the server. */ - interpretResponse: function(serverResponse) { + interpretResponse: function (serverResponse) { const serverBody = serverResponse.body; if (serverBody && serverBody.bids && isArray(serverBody.bids)) { - return _map(serverBody.bids, function(bid) { + return _map(serverBody.bids, function (bid) { return buildBidResponse(bid); }); } else { @@ -263,6 +345,6 @@ export const spec = { if (bid && bid.nurl) { triggerPixel(bid.nurl); } - } -} + }, +}; registerBidder(spec); diff --git a/modules/seedtagBidAdapter.md b/modules/seedtagBidAdapter.md index f4249fb2e89..8ccfcfb701e 100644 --- a/modules/seedtagBidAdapter.md +++ b/modules/seedtagBidAdapter.md @@ -8,19 +8,42 @@ Maintainer: prebid@seedtag.com # Description -Module that connects to Seedtag demand sources to fetch bids. +Prebidjs seedtag bidder -# Test Parameters +# Sample integration -## Sample Banner Ad Unit +## InScreen +```js +const adUnits = [ + { + code: '/21804003197/prebid_test_320x100', + mediaTypes: { + banner: { + sizes: [[320, 100]] + } + }, + bids: [ + { + bidder: 'seedtag', + params: { + publisherId: '0000-0000-01', // required + adUnitId: '0000', // required + placement: 'inScreen', // required + } + } + ] + } +] +``` +## InArticle ```js const adUnits = [ { code: '/21804003197/prebid_test_300x250', mediaTypes: { banner: { - sizes: [[300, 250]] + sizes: [[300, 250], [1, 1]] } }, bids: [ @@ -29,8 +52,7 @@ const adUnits = [ params: { publisherId: '0000-0000-01', // required adUnitId: '0000', // required - placement: 'banner', // required - adPosition: 0 // optional + placement: 'inArticle', // required } } ] @@ -38,15 +60,39 @@ const adUnits = [ ] ``` -## Sample inStream Video Ad Unit +## InBanner +```js +const adUnits = [ + { + code: '/21804003197/prebid_test_300x250', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [ + { + bidder: 'seedtag', + params: { + publisherId: '0000-0000-01', // required + adUnitId: '0000', // required + placement: 'inBanner', // required + } + } + ] + } +] +``` +## inStream Video ```js var adUnits = [{ code: 'video', mediaTypes: { video: { context: 'instream', // required - playerSize: [600, 300], // required + playerSize: [640, 360], // required + // Video object as specified in OpenRTB 2.5 mimes: ['video/mp4'], // recommended minduration: 5, // optional maxduration: 60, // optional @@ -67,24 +113,7 @@ var adUnits = [{ params: { publisherId: '0000-0000-01', // required adUnitId: '0000', // required - placement: 'video', // required - adPosition: 0, // optional - video: { // optional - context: 'instream', // optional - playerSize: [600, 300], // optional - mimes: ['video/mp4'], // optional - minduration: 5, // optional - maxduration: 60, // optional - boxingallowed: 1, // optional - skip: 1, // optional - startdelay: 1, // optional - linearity: 1, // optional - battr: [1, 2], // optional - maxbitrate: 10, // optional - playbackmethod: [1], // optional - delivery: [1], // optional - placement: 1, // optional - } + placement: 'inStream', // required } } ] diff --git a/modules/segmentoBidAdapter.md b/modules/segmentoBidAdapter.md deleted file mode 100644 index e64153195c5..00000000000 --- a/modules/segmentoBidAdapter.md +++ /dev/null @@ -1,33 +0,0 @@ -# Overview - -``` -Module Name: Segmento Bidder Adapter -Module Type: Bidder Adapter -Maintainer: ssp@segmento.ru -``` - -# Description - -Module that connects to Segmento's demand sources - -# Test Parameters -``` -var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[240,400],[160,600]], - } - }, - bids: [ - { - bidder: 'segmento', - params: { - placementId: -1 - } - } - ] - } -]; -``` diff --git a/modules/sekindoUMBidAdapter.md b/modules/sekindoUMBidAdapter.md deleted file mode 100644 index eeffff928eb..00000000000 --- a/modules/sekindoUMBidAdapter.md +++ /dev/null @@ -1,43 +0,0 @@ -# Overview - -**Module Name**: sekindoUM Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: nissime@sekindo.com - -# Description - -Connects to Sekindo (part of UM) demand source to fetch bids. -Banner, Outstream and Native formats are supported. - - -# Test Parameters -``` - var adUnits = [{ - code: 'banner-ad-div', - sizes: [[300, 250]], - bids: [{ - bidder: 'sekindoUM', - params: { - spaceId: 14071 - width:300, ///optional - height:250, //optional - } - }] - }, - { - code: 'video-ad-div', - sizes: [[640, 480]], - bids: [{ - bidder: 'sekindoUM', - params: { - spaceId: 87812, - video:{ - playerWidth:640, - playerHeight:480, - vid_vastType: 5 //optional - } - } - }] - } - ]; -``` diff --git a/modules/sharedIdSystem.js b/modules/sharedIdSystem.js index 656b62815c7..9046d6a633d 100644 --- a/modules/sharedIdSystem.js +++ b/modules/sharedIdSystem.js @@ -5,13 +5,15 @@ * @requires module:modules/userId */ -import { parseUrl, buildUrl, triggerPixel, logInfo, hasDeviceAccess, generateUUID } from '../src/utils.js'; +import {parseUrl, buildUrl, triggerPixel, logInfo, hasDeviceAccess, generateUUID} from '../src/utils.js'; import {submodule} from '../src/hook.js'; -import { coppaDataHandler } from '../src/adapterManager.js'; +import {coppaDataHandler} from '../src/adapterManager.js'; import {getStorageManager} from '../src/storageManager.js'; +import {VENDORLESS_GVLID} from '../src/consentHandler.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import {domainOverrideToRootDomain} from '../libraries/domainOverrideToRootDomain/index.js'; -const GVLID = 887; -export const storage = getStorageManager({gvlid: GVLID, moduleName: 'pubCommonId'}); +export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: 'sharedId'}); const COOKIE = 'cookie'; const LOCAL_STORAGE = 'html5'; const OPTOUT_NAME = '_pubcid_optout'; @@ -38,12 +40,15 @@ function readValue(name, type) { } } -function getIdCallback(pubcid, pixelCallback) { - return function (callback) { - if (typeof pixelCallback === 'function') { - pixelCallback(); +function getIdCallback(pubcid, pixelUrl) { + return function (callback, getStoredId) { + if (pixelUrl) { + queuePixelCallback(pixelUrl, pubcid, () => { + callback(getStoredId() || pubcid); + })(); + } else { + callback(pubcid); } - callback(pubcid); } } @@ -58,7 +63,7 @@ function queuePixelCallback(pixelUrl, id = '', callback) { const targetUrl = buildUrl(urlInfo); return function () { - triggerPixel(targetUrl); + triggerPixel(targetUrl, callback); }; } @@ -74,11 +79,7 @@ export const sharedIdSystemSubmodule = { */ name: 'sharedId', aliasName: 'pubCommonId', - /** - * Vendor id of prebid - * @type {Number} - */ - gvlid: GVLID, + gvlid: VENDORLESS_GVLID, /** * decode the stored id value for passing to bid requests @@ -129,8 +130,7 @@ export const sharedIdSystemSubmodule = { if (!newId) newId = (create && hasDeviceAccess()) ? generateUUID() : undefined; } - const pixelCallback = queuePixelCallback(pixelUrl, newId); - return {id: newId, callback: getIdCallback(newId, pixelCallback)}; + return {id: newId, callback: getIdCallback(newId, pixelUrl)}; }, /** * performs action to extend an id. There are generally two ways to extend the expiration time @@ -173,31 +173,13 @@ export const sharedIdSystemSubmodule = { } }, - domainOverride: function () { - const domainElements = document.domain.split('.'); - const cookieName = `_gd${Date.now()}`; - for (let i = 0, topDomain, testCookie; i < domainElements.length; i++) { - const nextDomain = domainElements.slice(i).join('.'); - - // write test cookie - storage.setCookie(cookieName, '1', undefined, undefined, nextDomain); - - // read test cookie to verify domain was valid - testCookie = storage.getCookie(cookieName); - - // delete test cookie - storage.setCookie(cookieName, '', 'Thu, 01 Jan 1970 00:00:01 GMT', undefined, nextDomain); - - if (testCookie === '1') { - // cookie was written successfully using test domain so the topDomain is updated - topDomain = nextDomain; - } else { - // cookie failed to write using test domain so exit by returning the topDomain - return topDomain; - } - } + domainOverride: domainOverrideToRootDomain(storage, 'sharedId'), + eids: { + 'pubcid': { + source: 'pubcid.org', + atype: 1 + }, } - }; submodule('userId', sharedIdSystemSubmodule); diff --git a/modules/sharethroughAnalyticsAdapter.js b/modules/sharethroughAnalyticsAdapter.js index 4f065cbca23..dc621e8da92 100644 --- a/modules/sharethroughAnalyticsAdapter.js +++ b/modules/sharethroughAnalyticsAdapter.js @@ -1,6 +1,6 @@ -import { tryAppendQueryString } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; const emptyUrl = ''; const analyticsType = 'endpoint'; diff --git a/modules/sharethroughBidAdapter.js b/modules/sharethroughBidAdapter.js index 1dd95812e12..a8beb018b73 100644 --- a/modules/sharethroughBidAdapter.js +++ b/modules/sharethroughBidAdapter.js @@ -1,10 +1,9 @@ -import { deepAccess, generateUUID, inIframe } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { config } from '../src/config.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { createEidsArray } from './userId/eids.js'; +import { deepAccess, generateUUID, inIframe } from '../src/utils.js'; -const VERSION = '4.1.0'; +const VERSION = '4.3.0'; const BIDDER_CODE = 'sharethrough'; const SUPPLY_ID = 'WYu2BXv1'; @@ -19,14 +18,14 @@ export const sharethroughAdapterSpec = { code: BIDDER_CODE, supportedMediaTypes: [VIDEO, BANNER], gvlid: 80, - isBidRequestValid: bid => !!bid.params.pkey && bid.bidder === BIDDER_CODE, + isBidRequestValid: (bid) => !!bid.params.pkey && bid.bidder === BIDDER_CODE, buildRequests: (bidRequests, bidderRequest) => { - const timeout = config.getConfig('bidderTimeout'); - const firstPartyData = config.getConfig('ortb2') || {}; + const timeout = bidderRequest.timeout; + const firstPartyData = bidderRequest.ortb2 || {}; const nonHttp = sharethroughInternal.getProtocol().indexOf('http') < 0; - const secure = nonHttp || (sharethroughInternal.getProtocol().indexOf('https') > -1); + const secure = nonHttp || sharethroughInternal.getProtocol().indexOf('https') > -1; const req = { id: generateUUID(), @@ -34,9 +33,9 @@ export const sharethroughAdapterSpec = { cur: ['USD'], tmax: timeout, site: { - domain: window.location.hostname, - page: window.location.href, - ref: deepAccess(bidderRequest, 'refererInfo.referer'), + domain: deepAccess(bidderRequest, 'refererInfo.domain', window.location.hostname), + page: deepAccess(bidderRequest, 'refererInfo.page', window.location.href), + ref: deepAccess(bidderRequest, 'refererInfo.ref'), ...firstPartyData.site, }, device: { @@ -52,20 +51,21 @@ export const sharethroughAdapterSpec = { ext: {}, }, source: { + tid: bidderRequest.ortb2?.source?.tid, ext: { version: '$prebid.version$', str: VERSION, schain: bidRequests[0].schain, }, }, - bcat: bidRequests[0].params.bcat || [], - badv: bidRequests[0].params.badv || [], + bcat: deepAccess(bidderRequest.ortb2, 'bcat') || bidRequests[0].params.bcat || [], + badv: deepAccess(bidderRequest.ortb2, 'badv') || bidRequests[0].params.badv || [], test: 0, }; req.user = nullish(firstPartyData.user, {}); if (!req.user.ext) req.user.ext = {}; - req.user.ext.eids = userIdAsEids(bidRequests[0]); + req.user.ext.eids = bidRequests[0].userIdAsEids || []; if (bidderRequest.gdprConsent) { const gdprApplies = bidderRequest.gdprConsent.gdprApplies === true; @@ -79,63 +79,79 @@ export const sharethroughAdapterSpec = { req.regs.ext.us_privacy = bidderRequest.uspConsent; } - const imps = bidRequests.map(bidReq => { - const impression = {}; - - const gpid = deepAccess(bidReq, 'ortb2Imp.ext.data.pbadslot'); - if (gpid) { - impression.ext = { gpid: gpid }; - } - - const videoRequest = deepAccess(bidReq, 'mediaTypes.video'); + if (bidderRequest?.gppConsent?.gppString) { + req.regs.gpp = bidderRequest.gppConsent.gppString; + req.regs.gpp_sid = bidderRequest.gppConsent.applicableSections; + } else if (bidderRequest?.ortb2?.regs?.gpp) { + req.regs.ext.gpp = bidderRequest.ortb2.regs.gpp; + req.regs.ext.gpp_sid = bidderRequest.ortb2.regs.gpp_sid; + } - if (videoRequest) { - // default playerSize, only change this if we know width and height are properly defined in the request - let [w, h] = [640, 360]; - if (videoRequest.playerSize && videoRequest.playerSize[0] && videoRequest.playerSize[1]) { - [w, h] = videoRequest.playerSize; + const imps = bidRequests + .map((bidReq) => { + const impression = { ext: {} }; + + // mergeDeep(impression, bidReq.ortb2Imp); // leaving this out for now as we may want to leave stuff out on purpose + const tid = deepAccess(bidReq, 'ortb2Imp.ext.tid'); + if (tid) impression.ext.tid = tid; + const gpid = deepAccess(bidReq, 'ortb2Imp.ext.gpid', deepAccess(bidReq, 'ortb2Imp.ext.data.pbadslot')); + if (gpid) impression.ext.gpid = gpid; + + const videoRequest = deepAccess(bidReq, 'mediaTypes.video'); + + if (videoRequest) { + // default playerSize, only change this if we know width and height are properly defined in the request + let [w, h] = [640, 360]; + if ( + videoRequest.playerSize && + videoRequest.playerSize[0] && + videoRequest.playerSize[0][0] && + videoRequest.playerSize[0][1] + ) { + [w, h] = videoRequest.playerSize[0]; + } + + impression.video = { + pos: nullish(videoRequest.pos, 0), + topframe: inIframe() ? 0 : 1, + skip: nullish(videoRequest.skip, 0), + linearity: nullish(videoRequest.linearity, 1), + minduration: nullish(videoRequest.minduration, 5), + maxduration: nullish(videoRequest.maxduration, 60), + playbackmethod: videoRequest.playbackmethod || [2], + api: getVideoApi(videoRequest), + mimes: videoRequest.mimes || ['video/mp4'], + protocols: getVideoProtocols(videoRequest), + w, + h, + startdelay: nullish(videoRequest.startdelay, 0), + skipmin: nullish(videoRequest.skipmin, 0), + skipafter: nullish(videoRequest.skipafter, 0), + placement: videoRequest.context === 'instream' ? 1 : +deepAccess(videoRequest, 'placement', 4), + }; + + if (videoRequest.delivery) impression.video.delivery = videoRequest.delivery; + if (videoRequest.companiontype) impression.video.companiontype = videoRequest.companiontype; + if (videoRequest.companionad) impression.video.companionad = videoRequest.companionad; + } else { + impression.banner = { + pos: deepAccess(bidReq, 'mediaTypes.banner.pos', 0), + topframe: inIframe() ? 0 : 1, + format: bidReq.sizes.map((size) => ({ w: +size[0], h: +size[1] })), + }; } - impression.video = { - pos: nullish(videoRequest.pos, 0), - topframe: inIframe() ? 0 : 1, - skip: nullish(videoRequest.skip, 0), - linearity: nullish(videoRequest.linearity, 1), - minduration: nullish(videoRequest.minduration, 5), - maxduration: nullish(videoRequest.maxduration, 60), - playbackmethod: videoRequest.playbackmethod || [2], - api: getVideoApi(videoRequest), - mimes: videoRequest.mimes || ['video/mp4'], - protocols: getVideoProtocols(videoRequest), - w, - h, - startdelay: nullish(videoRequest.startdelay, 0), - skipmin: nullish(videoRequest.skipmin, 0), - skipafter: nullish(videoRequest.skipafter, 0), - placement: videoRequest.context === 'instream' ? 1 : +deepAccess(videoRequest, 'placement', 4), + return { + id: bidReq.bidId, + tagid: String(bidReq.params.pkey), + secure: secure ? 1 : 0, + bidfloor: getBidRequestFloor(bidReq), + ...impression, }; + }) + .filter((imp) => !!imp); - if (videoRequest.delivery) impression.video.delivery = videoRequest.delivery; - if (videoRequest.companiontype) impression.video.companiontype = videoRequest.companiontype; - if (videoRequest.companionad) impression.video.companionad = videoRequest.companionad; - } else { - impression.banner = { - pos: deepAccess(bidReq, 'mediaTypes.banner.pos', 0), - topframe: inIframe() ? 0 : 1, - format: bidReq.sizes.map(size => ({ w: +size[0], h: +size[1] })), - }; - } - - return { - id: bidReq.bidId, - tagid: String(bidReq.params.pkey), - secure: secure ? 1 : 0, - bidfloor: getBidRequestFloor(bidReq), - ...impression, - }; - }).filter(imp => !!imp); - - return imps.map(impression => { + return imps.map((impression) => { return { method: 'POST', url: STR_ENDPOINT, @@ -148,11 +164,18 @@ export const sharethroughAdapterSpec = { }, interpretResponse: ({ body }, req) => { - if (!body || !body.seatbid || body.seatbid.length === 0 || !body.seatbid[0].bid || body.seatbid[0].bid.length === 0) { + if ( + !body || + !body.seatbid || + body.seatbid.length === 0 || + !body.seatbid[0].bid || + body.seatbid[0].bid.length === 0 + ) { return []; } - return body.seatbid[0].bid.map(bid => { + return body.seatbid[0].bid.map((bid) => { + // Spec: https://docs.prebid.org/dev-docs/bidder-adaptor.html#interpreting-the-response const response = { requestId: bid.impid, width: +bid.w, @@ -168,6 +191,19 @@ export const sharethroughAdapterSpec = { nurl: bid.nurl, meta: { advertiserDomains: bid.adomain || [], + networkId: bid.ext?.networkId || null, + networkName: bid.ext?.networkName || null, + agencyId: bid.ext?.agencyId || null, + agencyName: bid.ext?.agencyName || null, + advertiserId: bid.ext?.advertiserId || null, + advertiserName: bid.ext?.advertiserName || null, + brandId: bid.ext?.brandId || null, + brandName: bid.ext?.brandName || null, + demandSource: bid.ext?.demandSource || null, + dchain: bid.ext?.dchain || null, + primaryCatId: bid.ext?.primaryCatId || null, + secondaryCatIds: bid.ext?.secondaryCatIds || null, + mediaType: bid.ext?.mediaType || null, }, }; @@ -180,34 +216,36 @@ export const sharethroughAdapterSpec = { }); }, - getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { - const syncParams = uspConsent ? `&us_privacy=${uspConsent}` : ''; - const syncs = []; - const shouldCookieSync = syncOptions.pixelEnabled && - serverResponses.length > 0 && - serverResponses[0].body && - serverResponses[0].body.cookieSyncUrls; - - if (shouldCookieSync) { - serverResponses[0].body.cookieSyncUrls.forEach(url => { - syncs.push({ type: 'image', url: url + syncParams }); - }); + getUserSyncs: (syncOptions, serverResponses, gdprConsent, gppConsent) => { + const shouldCookieSync = + syncOptions.pixelEnabled && deepAccess(serverResponses, '0.body.cookieSyncUrls') !== undefined; + + let syncurl = ''; + + // Attaching GDPR Consent Params in UserSync url + if (gdprConsent) { + syncurl += '&gdpr=' + (gdprConsent.gdprApplies ? 1 : 0); + syncurl += '&gdpr_consent=' + encodeURIComponent(gdprConsent.consentString || ''); + } + if (gppConsent) { + syncurl += '&gpp=' + encodeURIComponent(gppConsent?.gppString); + syncurl += '&gpp_sid=' + encodeURIComponent(gppConsent?.applicableSections?.join(',')); } - return syncs; + return shouldCookieSync ? serverResponses[0].body.cookieSyncUrls.map((url) => ( + { type: 'image', + url: url + syncurl + })) : []; }, // Empty implementation for prebid core to be able to find it - onTimeout: (data) => { - }, + onTimeout: (data) => {}, // Empty implementation for prebid core to be able to find it - onBidWon: (bid) => { - }, + onBidWon: (bid) => {}, // Empty implementation for prebid core to be able to find it - onSetTargeting: (bid) => { - }, + onSetTargeting: (bid) => {}, }; function getVideoApi({ api }) { @@ -234,7 +272,7 @@ function getBidRequestFloor(bid) { const floorInfo = bid.getFloor({ currency: 'USD', mediaType: bid.mediaTypes && bid.mediaTypes.video ? 'video' : 'banner', - size: bid.sizes.map(size => ({ w: size[0], h: size[1] })), + size: bid.sizes.map((size) => ({ w: size[0], h: size[1] })), }); if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { floor = parseFloat(floorInfo.floor); @@ -243,21 +281,6 @@ function getBidRequestFloor(bid) { return floor !== null ? floor : bid.params.floor; } -function userIdAsEids(bidRequest) { - const eids = createEidsArray(deepAccess(bidRequest, 'userId')) || []; - - const flocData = deepAccess(bidRequest, 'userId.flocId'); - const isFlocIdValid = flocData && flocData.id && flocData.version; - if (isFlocIdValid) { - eids.push({ - source: 'chrome.com', - uids: [{ id: flocData.id, atype: 1, ext: { ver: flocData.version } }], - }); - } - - return eids; -} - function getProtocol() { return window.location.protocol; } diff --git a/modules/shinezBidAdapter.js b/modules/shinezBidAdapter.js new file mode 100644 index 00000000000..47fca317de2 --- /dev/null +++ b/modules/shinezBidAdapter.js @@ -0,0 +1,447 @@ +import { + logWarn, + logInfo, + isArray, + isFn, + deepAccess, + isEmpty, + contains, + timestamp, + triggerPixel, + isInteger, + getBidIdParameter +} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {config} from '../src/config.js'; + +const SUPPORTED_AD_TYPES = [BANNER, VIDEO]; +const BIDDER_CODE = 'shinez'; +const ADAPTER_VERSION = '1.0.0'; +const TTL = 360; +const CURRENCY = 'USD'; +const SELLER_ENDPOINT = 'https://hb.sweetgum.io/'; +const MODES = { + PRODUCTION: 'hb-sz-multi', + TEST: 'hb-multi-sz-test' +} +const SUPPORTED_SYNC_METHODS = { + IFRAME: 'iframe', + PIXEL: 'pixel' +} + +export const spec = { + code: BIDDER_CODE, + version: ADAPTER_VERSION, + supportedMediaTypes: SUPPORTED_AD_TYPES, + isBidRequestValid: function (bidRequest) { + if (!bidRequest.params) { + logWarn('no params have been set to Shinez adapter'); + return false; + } + + if (!bidRequest.params.org) { + logWarn('org is a mandatory param for Shinez adapter'); + return false; + } + + return true; + }, + buildRequests: function (validBidRequests, bidderRequest) { + const combinedRequestsObject = {}; + + // use data from the first bid, to create the general params for all bids + const generalObject = validBidRequests[0]; + const testMode = generalObject.params.testMode; + + combinedRequestsObject.params = generateGeneralParams(generalObject, bidderRequest); + combinedRequestsObject.bids = generateBidsParams(validBidRequests, bidderRequest); + + return { + method: 'POST', + url: getEndpoint(testMode), + data: combinedRequestsObject + } + }, + interpretResponse: function ({body}) { + const bidResponses = []; + + if (body.bids) { + body.bids.forEach(adUnit => { + const bidResponse = { + requestId: adUnit.requestId, + cpm: adUnit.cpm, + currency: adUnit.currency || CURRENCY, + width: adUnit.width, + height: adUnit.height, + ttl: adUnit.ttl || TTL, + creativeId: adUnit.requestId, + netRevenue: adUnit.netRevenue || true, + nurl: adUnit.nurl, + mediaType: adUnit.mediaType, + meta: { + mediaType: adUnit.mediaType + } + }; + + if (adUnit.mediaType === VIDEO) { + bidResponse.vastXml = adUnit.vastXml; + } else if (adUnit.mediaType === BANNER) { + bidResponse.ad = adUnit.ad; + } + + if (adUnit.adomain && adUnit.adomain.length) { + bidResponse.meta.advertiserDomains = adUnit.adomain; + } + + bidResponses.push(bidResponse); + }); + } + + return bidResponses; + }, + getUserSyncs: function (syncOptions, serverResponses) { + const syncs = []; + for (const response of serverResponses) { + if (syncOptions.iframeEnabled && response.body.params.userSyncURL) { + syncs.push({ + type: 'iframe', + url: response.body.params.userSyncURL + }); + } + if (syncOptions.pixelEnabled && isArray(response.body.params.userSyncPixels)) { + const pixels = response.body.params.userSyncPixels.map(pixel => { + return { + type: 'image', + url: pixel + } + }) + syncs.push(...pixels) + } + } + return syncs; + }, + onBidWon: function (bid) { + if (bid == null) { + return; + } + + logInfo('onBidWon:', bid); + if (bid.hasOwnProperty('nurl') && bid.nurl.length > 0) { + triggerPixel(bid.nurl); + } + } +}; + +registerBidder(spec); + +/** + * Get floor price + * @param bid {bid} + * @returns {Number} + */ +function getFloor(bid, mediaType) { + if (!isFn(bid.getFloor)) { + return 0; + } + let floorResult = bid.getFloor({ + currency: CURRENCY, + mediaType: mediaType, + size: '*' + }); + return floorResult.currency === CURRENCY && floorResult.floor ? floorResult.floor : 0; +} + +/** + * Get the the ad sizes array from the bid + * @param bid {bid} + * @returns {Array} + */ +function getSizesArray(bid, mediaType) { + let sizesArray = [] + + if (deepAccess(bid, `mediaTypes.${mediaType}.sizes`)) { + sizesArray = bid.mediaTypes[mediaType].sizes; + } else if (Array.isArray(bid.sizes) && bid.sizes.length > 0) { + sizesArray = bid.sizes; + } + + return sizesArray; +} + +/** + * Get schain string value + * @param schainObject {Object} + * @returns {string} + */ +function getSupplyChain(schainObject) { + if (isEmpty(schainObject)) { + return ''; + } + let scStr = `${schainObject.ver},${schainObject.complete}`; + schainObject.nodes.forEach((node) => { + scStr += '!'; + scStr += `${getEncodedValIfNotEmpty(node.asi)},`; + scStr += `${getEncodedValIfNotEmpty(node.sid)},`; + scStr += `${node.hp ? encodeURIComponent(node.hp) : ''},`; + scStr += `${getEncodedValIfNotEmpty(node.rid)},`; + scStr += `${getEncodedValIfNotEmpty(node.name)},`; + scStr += `${getEncodedValIfNotEmpty(node.domain)}`; + }); + return scStr; +} + +/** + * Get encoded node value + * @param val {string} + * @returns {string} + */ +function getEncodedValIfNotEmpty(val) { + return !isEmpty(val) ? encodeURIComponent(val) : ''; +} + +/** + * Get preferred user-sync method based on publisher configuration + * @param bidderCode {string} + * @returns {string} + */ +function getAllowedSyncMethod(filterSettings, bidderCode) { + const iframeConfigsToCheck = ['all', 'iframe']; + const pixelConfigToCheck = 'image'; + if (filterSettings && iframeConfigsToCheck.some(config => isSyncMethodAllowed(filterSettings[config], bidderCode))) { + return SUPPORTED_SYNC_METHODS.IFRAME; + } + if (!filterSettings || !filterSettings[pixelConfigToCheck] || isSyncMethodAllowed(filterSettings[pixelConfigToCheck], bidderCode)) { + return SUPPORTED_SYNC_METHODS.PIXEL; + } +} + +/** + * Check if sync rule is supported + * @param syncRule {Object} + * @param bidderCode {string} + * @returns {boolean} + */ +function isSyncMethodAllowed(syncRule, bidderCode) { + if (!syncRule) { + return false; + } + const isInclude = syncRule.filter === 'include'; + const bidders = isArray(syncRule.bidders) ? syncRule.bidders : [bidderCode]; + return isInclude && contains(bidders, bidderCode); +} + +/** + * Get the seller endpoint + * @param testMode {boolean} + * @returns {string} + */ +function getEndpoint(testMode) { + return testMode + ? SELLER_ENDPOINT + MODES.TEST + : SELLER_ENDPOINT + MODES.PRODUCTION; +} + +/** + * get device type + * @param uad {ua} + * @returns {string} + */ +function getDeviceType(ua) { + if (/ipad|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i + .test(ua.toLowerCase())) { + return '5'; + } + if (/iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i + .test(ua.toLowerCase())) { + return '4'; + } + if (/smart[-_\s]?tv|hbbtv|appletv|googletv|hdmi|netcast|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b/i + .test(ua.toLowerCase())) { + return '3'; + } + return '1'; +} + +function generateBidsParams(validBidRequests, bidderRequest) { + const bidsArray = []; + + if (validBidRequests.length) { + validBidRequests.forEach(bid => { + bidsArray.push(generateBidParameters(bid, bidderRequest)); + }); + } + + return bidsArray; +} + +/** + * Generate bid specific parameters + * @param {bid} bid + * @param {bidderRequest} bidderRequest + * @returns {Object} bid specific params object + */ +function generateBidParameters(bid, bidderRequest) { + const {params} = bid; + const mediaType = isBanner(bid) ? BANNER : VIDEO; + const sizesArray = getSizesArray(bid, mediaType); + + // fix floor price in case of NAN + if (isNaN(params.floorPrice)) { + params.floorPrice = 0; + } + + const bidObject = { + mediaType, + adUnitCode: getBidIdParameter('adUnitCode', bid), + sizes: sizesArray, + floorPrice: Math.max(getFloor(bid, mediaType), params.floorPrice), + bidId: getBidIdParameter('bidId', bid), + bidderRequestId: getBidIdParameter('bidderRequestId', bid), + transactionId: bid.ortb2Imp?.ext?.tid || '', + }; + + const pos = deepAccess(bid, `mediaTypes.${mediaType}.pos`); + if (pos) { + bidObject.pos = pos; + } + + const gpid = deepAccess(bid, `ortb2Imp.ext.gpid`); + if (gpid) { + bidObject.gpid = gpid; + } + + const placementId = params.placementId || deepAccess(bid, `mediaTypes.${mediaType}.name`); + if (placementId) { + bidObject.placementId = placementId; + } + + if (mediaType === VIDEO) { + const playbackMethod = deepAccess(bid, `mediaTypes.video.playbackmethod`); + let playbackMethodValue; + + // verify playbackMethod is of type integer array, or integer only. + if (Array.isArray(playbackMethod) && isInteger(playbackMethod[0])) { + // only the first playbackMethod in the array will be used, according to OpenRTB 2.5 recommendation + playbackMethodValue = playbackMethod[0]; + } else if (isInteger(playbackMethod)) { + playbackMethodValue = playbackMethod; + } + + if (playbackMethodValue) { + bidObject.playbackMethod = playbackMethodValue; + } + + const placement = deepAccess(bid, `mediaTypes.video.placement`); + if (placement) { + bidObject.placement = placement; + } + + const minDuration = deepAccess(bid, `mediaTypes.video.minduration`); + if (minDuration) { + bidObject.minDuration = minDuration; + } + + const maxDuration = deepAccess(bid, `mediaTypes.video.maxduration`); + if (maxDuration) { + bidObject.maxDuration = maxDuration; + } + + const skip = deepAccess(bid, `mediaTypes.video.skip`); + if (skip) { + bidObject.skip = skip; + } + + const linearity = deepAccess(bid, `mediaTypes.video.linearity`); + if (linearity) { + bidObject.linearity = linearity; + } + } + + return bidObject; +} + +function isBanner(bid) { + return bid.mediaTypes && bid.mediaTypes.banner; +} + +/** + * Generate params that are common between all bids + * @param {single bid object} generalObject + * @param {bidderRequest} bidderRequest + * @returns {object} the common params object + */ +function generateGeneralParams(generalObject, bidderRequest) { + const domain = window.location.hostname; + const {syncEnabled, filterSettings} = config.getConfig('userSync') || {}; + const {bidderCode} = bidderRequest; + const generalBidParams = generalObject.params; + const timeout = bidderRequest.timeout; + + // these params are snake_case instead of camelCase to allow backwards compatability on the server. + // in the future, these will be converted to camelCase to match our convention. + const generalParams = { + wrapper_type: 'prebidjs', + wrapper_vendor: '$$PREBID_GLOBAL$$', + wrapper_version: '$prebid.version$', + adapter_version: ADAPTER_VERSION, + auction_start: timestamp(), + publisher_id: generalBidParams.org, + publisher_name: domain, + site_domain: domain, + dnt: (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0, + device_type: getDeviceType(navigator.userAgent), + ua: navigator.userAgent, + session_id: getBidIdParameter('auctionId', generalObject), + tmax: timeout + }; + + const userIdsParam = getBidIdParameter('userId', generalObject); + if (userIdsParam) { + generalParams.userIds = JSON.stringify(userIdsParam); + } + + const ortb2Metadata = bidderRequest.ortb2 || {}; + if (ortb2Metadata.site) { + generalParams.site_metadata = JSON.stringify(ortb2Metadata.site); + } + if (ortb2Metadata.user) { + generalParams.user_metadata = JSON.stringify(ortb2Metadata.user); + } + + if (syncEnabled) { + const allowedSyncMethod = getAllowedSyncMethod(filterSettings, bidderCode); + if (allowedSyncMethod) { + generalParams.cs_method = allowedSyncMethod; + } + } + + if (bidderRequest.uspConsent) { + generalParams.us_privacy = bidderRequest.uspConsent; + } + + if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) { + generalParams.gdpr = bidderRequest.gdprConsent.gdprApplies; + generalParams.gdpr_consent = bidderRequest.gdprConsent.consentString; + } + + if (generalBidParams.ifa) { + generalParams.ifa = generalBidParams.ifa; + } + + if (generalObject.schain) { + generalParams.schain = getSupplyChain(generalObject.schain); + } + + if (bidderRequest.ortb2 && bidderRequest.ortb2.site) { + generalParams.referrer = bidderRequest.ortb2.site.ref; + generalParams.page_url = bidderRequest.ortb2.site.page; + } + + if (bidderRequest && bidderRequest.refererInfo) { + generalParams.referrer = generalParams.referrer || deepAccess(bidderRequest, 'refererInfo.referer'); + generalParams.page_url = generalParams.page_url || config.getConfig('pageUrl') || deepAccess(window, 'location.href'); + } + + return generalParams; +} diff --git a/modules/shinezBidAdapter.md b/modules/shinezBidAdapter.md index e040cfbf36b..f0ef7a6c218 100644 --- a/modules/shinezBidAdapter.md +++ b/modules/shinezBidAdapter.md @@ -1,33 +1,76 @@ -# Overview - -``` -Module Name: Shinez Bidder Adapter -Module Type: Bidder Adapter -Maintainer: tech-team@shinez.io -``` - -# Description - -Connects to shinez.io demand sources. - -The Shinez adapter requires setup and approval from the Shinez team. -Please reach out to tech-team@shinez.io for more information. - -# Test Parameters - -```javascript -var adUnits = [{ - code: "test-div", - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bids: [{ - bidder: "shinez", - params: { - placementId: "00654321" - } - }] -}]; +#Overview + +Module Name: Shinez Bidder Adapter + +Module Type: Bidder Adapter + +Maintainer: tech-team@shinez.io + + +# Description + +Module that connects to Shinez's demand sources. + +The Shinez adapter requires setup and approval from the Shinez. Please reach out to tech-team@shinez.io to create an Shinez account. + +The adapter supports Video(instream) & Banner. + +# Bid Parameters +## Video + +| Name | Scope | Type | Description | Example +| ---- | ----- | ---- | ----------- | ------- +| `org` | required | String | Shinez publisher Id provided by your Shinez representative | "56f91cd4d3e3660002000033" +| `floorPrice` | optional | Number | Minimum price in USD. Misuse of this parameter can impact revenue | 2.00 +| `placementId` | optional | String | A unique placement identifier | "12345678" +| `testMode` | optional | Boolean | This activates the test mode | false + +# Test Parameters +```javascript +var adUnits = [{ + code: 'dfp-video-div', + sizes: [ + [640, 480] + ], + mediaTypes: { + video: { + playerSize: [ + [640, 480] + ], + context: 'instream' + } + }, + bids: [{ + bidder: 'shinez', + params: { + org: '56f91cd4d3e3660002000033', // Required + floorPrice: 2.00, // Optional + placementId: 'shinez-video-test', // Optional + testMode: true // Optional + } + }] + }, + { + code: 'dfp-banner-div', + sizes: [ + [640, 480] + ], + mediaTypes: { + banner: { + sizes: [ + [640, 480] + ] + } + }, + bids: [{ + bidder: 'shinez', + params: { + org: '56f91cd4d3e3660002000033', // Required + floorPrice: 2.00, // Optional + placementId: 'shinez-banner-test', // Optional + testMode: true // Optional + } + }] + } +]; ``` \ No newline at end of file diff --git a/modules/showheroes-bsBidAdapter.js b/modules/showheroes-bsBidAdapter.js index 4c8fb812edc..a1e7df49d18 100644 --- a/modules/showheroes-bsBidAdapter.js +++ b/modules/showheroes-bsBidAdapter.js @@ -1,4 +1,10 @@ -import { deepAccess, getBidIdParameter, getWindowTop, logError } from '../src/utils.js'; +import { + deepAccess, + getWindowTop, + triggerPixel, + logInfo, + logError, getBidIdParameter +} from '../src/utils.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; @@ -7,6 +13,7 @@ import { loadExternalScript } from '../src/adloader.js'; const PROD_ENDPOINT = 'https://bs.showheroes.com/api/v1/bid'; const STAGE_ENDPOINT = 'https://bid-service.stage.showheroes.com/api/v1/bid'; +const VIRALIZE_ENDPOINT = 'https://ads.viralize.tv/prebid-sh/'; const PROD_PUBLISHER_TAG = 'https://static.showheroes.com/publishertag.js'; const STAGE_PUBLISHER_TAG = 'https://pubtag.stage.showheroes.com/publishertag.js'; const PROD_VL = 'https://video-library.showheroes.com'; @@ -26,12 +33,15 @@ export const spec = { aliases: ['showheroesBs'], supportedMediaTypes: [VIDEO, BANNER], isBidRequestValid: function(bid) { - return !!bid.params.playerId; + return !!bid.params.playerId || !!bid.params.unitId; }, buildRequests: function(validBidRequests, bidderRequest) { let adUnits = []; - const pageURL = validBidRequests[0].params.contentPageUrl || bidderRequest.refererInfo.referer; + const pageURL = validBidRequests[0].params.contentPageUrl || + bidderRequest.refererInfo.canonicalUrl || + deepAccess(window, 'location.href'); const isStage = !!validBidRequests[0].params.stage; + const isViralize = !!validBidRequests[0].params.unitId; const isOutstream = deepAccess(validBidRequests[0], 'mediaTypes.video.context') === 'outstream'; const isCustomRender = deepAccess(validBidRequests[0], 'params.outstreamOptions.customRender'); const isNodeRender = deepAccess(validBidRequests[0], 'params.outstreamOptions.slot') || deepAccess(validBidRequests[0], 'params.outstreamOptions.iframe'); @@ -40,12 +50,20 @@ export const spec = { const isBanner = !!validBidRequests[0].mediaTypes.banner || (isOutstream && !(isCustomRender || isNativeRender || isNodeRender)); const defaultSchain = validBidRequests[0].schain || {}; + const consentData = bidderRequest.gdprConsent || {}; + const uspConsent = bidderRequest.uspConsent || ''; + const gdprConsent = { + apiVersion: consentData.apiVersion || 2, + gdprApplies: consentData.gdprApplies || 0, + consentString: consentData.consentString || '', + } + validBidRequests.forEach((bid) => { const videoSizes = getVideoSizes(bid); const bannerSizes = getBannerSizes(bid); const vpaidMode = getBidIdParameter('vpaidMode', bid.params); - const makeBids = (type, size) => { + const makeBids = (type, size, isViralize) => { let context = ''; let streamType = 2; @@ -61,53 +79,81 @@ export const spec = { } } - const consentData = bidderRequest.gdprConsent || {}; - - const gdprConsent = { - apiVersion: consentData.apiVersion || 2, - gdprApplies: consentData.gdprApplies || 0, - consentString: consentData.consentString || '', - } - - return { + let rBid = { type: streamType, adUnitCode: bid.adUnitCode, bidId: bid.bidId, - mediaType: type, context: context, - playerId: getBidIdParameter('playerId', bid.params), + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidderRequest.auctionId, - bidderCode: BIDDER_CODE, - gdprConsent: gdprConsent, start: +new Date(), timeout: 3000, - size: { - width: size[0], - height: size[1] - }, params: bid.params, - schain: bid.schain || defaultSchain, + schain: bid.schain || defaultSchain }; + + if (isViralize) { + rBid.unitId = getBidIdParameter('unitId', bid.params); + rBid.sizes = size; + rBid.mediaTypes = { + [type]: {'context': context} + }; + } else { + rBid.playerId = getBidIdParameter('playerId', bid.params); + rBid.mediaType = type; + rBid.size = { + width: size[0], + height: size[1] + }; + rBid.gdprConsent = gdprConsent; + rBid.uspConsent = uspConsent; + } + + return rBid; }; - videoSizes.forEach((size) => { - adUnits.push(makeBids(VIDEO, size)); - }); + if (isViralize) { + if (videoSizes && videoSizes[0]) { + adUnits.push(makeBids(VIDEO, videoSizes, isViralize)); + } + if (bannerSizes && bannerSizes[0]) { + adUnits.push(makeBids(BANNER, bannerSizes, isViralize)); + } + } else { + videoSizes.forEach((size) => { + adUnits.push(makeBids(VIDEO, size)); + }); - bannerSizes.forEach((size) => { - adUnits.push(makeBids(BANNER, size)); - }); + bannerSizes.forEach((size) => { + adUnits.push(makeBids(BANNER, size)); + }); + } }); - return { - url: isStage ? STAGE_ENDPOINT : PROD_ENDPOINT, - method: 'POST', - options: {contentType: 'application/json', accept: 'application/json'}, - data: { + let endpointUrl; + let data; + + const QA = validBidRequests[0].params.qa || {}; + + if (isViralize) { + endpointUrl = VIRALIZE_ENDPOINT; + data = { + 'bidRequests': adUnits, + 'context': { + 'gdprConsent': gdprConsent, + 'uspConsent': uspConsent, + 'schain': defaultSchain, + 'pageURL': QA.pageURL || encodeURIComponent(pageURL) + } + } + } else { + endpointUrl = isStage ? STAGE_ENDPOINT : PROD_ENDPOINT; + + data = { 'user': [], 'meta': { 'adapterVersion': 2, - 'pageURL': encodeURIComponent(pageURL), + 'pageURL': QA.pageURL || encodeURIComponent(pageURL), 'vastCacheEnabled': (!!config.getConfig('cache') && !isBanner && !outstreamOptions) || false, 'isDesktop': getWindowTop().document.documentElement.clientWidth > 700, 'xmlAndTag': !!(isOutstream && isCustomRender) || false, @@ -116,6 +162,13 @@ export const spec = { 'requests': adUnits, 'debug': validBidRequests[0].params.debug || false, } + } + + return { + url: QA.endpoint || endpointUrl, + method: 'POST', + options: {contentType: 'application/json', accept: 'application/json'}, + data: data }; }, interpretResponse: function(response, request) { @@ -149,33 +202,53 @@ export const spec = { } return syncs; }, + + onBidWon(bid) { + if (bid.callbacks) { + triggerPixel(bid.callbacks.won); + } + logInfo( + `Showheroes adapter won the auction. Bid id: ${bid.bidId || bid.requestId}` + ); + }, }; function createBids(bidRes, reqData) { - if (bidRes && (!Array.isArray(bidRes.bids) || bidRes.bids.length < 1)) { + if (!bidRes) { + return []; + } + const responseBids = bidRes.bids || bidRes.bidResponses; + if (!Array.isArray(responseBids) || responseBids.length < 1) { return []; } const bids = []; const bidMap = {}; - (reqData.requests || []).forEach((bid) => { + (reqData.requests || reqData.bidRequests || []).forEach((bid) => { bidMap[bid.bidId] = bid; }); - bidRes.bids.forEach(function (bid) { - const reqBid = bidMap[bid.bidId]; + responseBids.forEach(function (bid) { + const requestId = bid.bidId || bid.requestId; + const reqBid = bidMap[requestId]; const currentBidParams = reqBid.params; + const isViralize = !!reqBid.params.unitId; + const size = { + width: bid.width || bid.size.width, + height: bid.height || bid.size.height + }; + let bidUnit = {}; bidUnit.cpm = bid.cpm; - bidUnit.requestId = bid.bidId; + bidUnit.requestId = requestId; bidUnit.adUnitCode = reqBid.adUnitCode; bidUnit.currency = bid.currency; bidUnit.mediaType = bid.mediaType || VIDEO; bidUnit.ttl = TTL; - bidUnit.creativeId = 'c_' + bid.bidId; + bidUnit.creativeId = 'c_' + requestId; bidUnit.netRevenue = true; - bidUnit.width = bid.size.width; - bidUnit.height = bid.size.height; + bidUnit.width = size.width; + bidUnit.height = size.height; bidUnit.meta = { advertiserDomains: bid.adomain || [] }; @@ -185,24 +258,26 @@ function createBids(bidRes, reqData) { content: bid.vastXml, }; } - if (bid.vastTag) { - bidUnit.vastUrl = bid.vastTag; + if (bid.vastTag || bid.vastUrl) { + bidUnit.vastUrl = bid.vastTag || bid.vastUrl; } if (bid.mediaType === BANNER) { bidUnit.ad = getBannerHtml(bid, reqBid, reqData); } else if (bid.context === 'outstream') { const renderer = Renderer.install({ - id: bid.bidId, + id: requestId, url: 'https://static.showheroes.com/renderer.js', adUnitCode: reqBid.adUnitCode, config: { playerId: reqBid.playerId, - width: bid.size.width, - height: bid.size.height, + width: size.width, + height: size.height, vastUrl: bid.vastTag, vastXml: bid.vastXml, + ad: bid.ad, debug: reqData.debug, - isStage: !!reqData.meta.stage, + isStage: reqData.meta && !!reqData.meta.stage, + isViralize: isViralize, customRender: getBidIdParameter('customRender', currentBidParams.outstreamOptions), slot: getBidIdParameter('slot', currentBidParams.outstreamOptions), iframe: getBidIdParameter('iframe', currentBidParams.outstreamOptions), @@ -218,7 +293,12 @@ function createBids(bidRes, reqData) { } function outstreamRender(bid) { - const embedCode = createOutstreamEmbedCode(bid); + let embedCode; + if (bid.renderer.config.isViralize) { + embedCode = createOutstreamEmbedCodeV2(bid); + } else { + embedCode = createOutstreamEmbedCode(bid); + } if (typeof bid.renderer.config.customRender === 'function') { bid.renderer.config.customRender(bid, embedCode); } else { @@ -238,7 +318,7 @@ function outstreamRender(bid) { logError('[ShowHeroes][renderer] Error: spot not found'); } } catch (err) { - logError('[ShowHeroes][renderer] Error:' + err.message) + logError('[ShowHeroes][renderer] Error:' + err.message); } } } @@ -266,6 +346,12 @@ function createOutstreamEmbedCode(bid) { return fragment; } +function createOutstreamEmbedCodeV2(bid) { + const range = document.createRange(); + range.selectNode(document.getElementsByTagName('body')[0]); + return range.createContextualFragment(getBidIdParameter('ad', bid.renderer.config)); +} + function getBannerHtml (bid, reqBid, reqData) { const isStage = !!reqData.meta.stage; const urls = getEnvURLs(isStage); diff --git a/modules/showheroes-bsBidAdapter.md b/modules/showheroes-bsBidAdapter.md index cde652e9d83..a32a77a2525 100644 --- a/modules/showheroes-bsBidAdapter.md +++ b/modules/showheroes-bsBidAdapter.md @@ -125,3 +125,52 @@ Module that connects to ShowHeroes demand source to fetch bids. } ]; ``` + +# Test Parameters (V2) +``` + var adUnits = [ + { + code: 'video', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream', + } + }, + bids: [ + { + bidder: "showheroes-bs", + params: { + unitId: 'AACBWAcof-611K4U', + vpaidMode: true // by default is 'false' + } + } + ] + }, + { + code: 'video', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream', + } + }, + bids: [ + { + bidder: "showheroes-bs", + params: { + unitId: 'AACBTwsZVANd9NlB', + + outstreamOptions: { + // Required for the outstream renderer to exact node, one of + iframe: 'iframe_id', + // or + slot: 'slot_id' + } + } + } + ] + } + ]; +``` + diff --git a/modules/sigmoidAnalyticsAdapter.js b/modules/sigmoidAnalyticsAdapter.js index a0521bd5297..18e1e20e3e3 100644 --- a/modules/sigmoidAnalyticsAdapter.js +++ b/modules/sigmoidAnalyticsAdapter.js @@ -1,13 +1,15 @@ /* Sigmoid Analytics Adapter for prebid.js v1.1.0-pre Updated : 2018-03-28 */ import {includes} from '../src/polyfill.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import {getStorageManager} from '../src/storageManager.js'; import {generateUUID, logError, logInfo} from '../src/utils.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; -const storage = getStorageManager(); +const MODULE_CODE = 'sigmoid'; +const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); const url = 'https://kinesis.us-east-1.amazonaws.com/'; const analyticsType = 'endpoint'; @@ -285,7 +287,7 @@ function pushEvent(eventType, args) { adapterManager.registerAnalyticsAdapter({ adapter: sigmoidAdapter, - code: 'sigmoid' + code: MODULE_CODE, }); export default sigmoidAdapter; diff --git a/modules/silverpushBidAdapter.js b/modules/silverpushBidAdapter.js new file mode 100644 index 00000000000..5403f3bd88c --- /dev/null +++ b/modules/silverpushBidAdapter.js @@ -0,0 +1,326 @@ +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import { mergeDeep } from '../src/utils.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import { Renderer } from '../src/Renderer.js'; +import { ajax } from '../src/ajax.js'; + +const BIDDER_CODE = 'silverpush'; +const bidderConfig = 'sp_pb_ortb'; +const bidderVersion = '1.0.0'; +const DEFAULT_CURRENCY = 'USD'; + +export const REQUEST_URL = 'https://prebid.chocolateplatform.co/bidder/?identifier=prebidchoc'; +export const SP_OUTSTREAM_PLAYER_URL = 'https://xaido.sgp1.cdn.digitaloceanspaces.com/prebid/spoutstream.min.js'; + +const VIDEO_ORTB_PARAMS = [ + 'mimes', + 'minduration', + 'maxduration', + 'placement', + 'protocols', + 'startdelay', + 'skip', + 'skipafter', + 'minbitrate', + 'maxbitrate', + 'delivery', + 'playbackmethod', + 'api', + 'linearity' +]; + +export const VIDEO_ORTB_REQUIRED = ['api', 'mimes', 'placement', 'protocols', 'minduration', 'maxduration', 'startdelay']; + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO], + isBidRequestValid, + buildRequests, + interpretResponse, + onBidWon, + getRequest: function(endpoint) { + ajax(endpoint, null, undefined, {method: 'GET'}); + }, + getOS: function(ua) { + if (ua.indexOf('Windows') != -1) { return 'Windows'; } else if (ua.match(/(iPhone|iPod|iPad)/)) { return 'iOS'; } else if (ua.indexOf('Mac OS X') != -1) { return 'macOS'; } else if (ua.match(/Android/)) { return 'Android'; } else if (ua.indexOf('Linux') != -1) { return 'Linux'; } else { return 'Unknown'; } + } +}; + +registerBidder(spec); + +export const CONVERTER = ortbConverter({ + context: { + netRevenue: true, + ttl: 300 + }, + imp(buildImp, bidRequest, context) { + let imp = buildImp(bidRequest, context); + + if (bidRequest.mediaTypes[VIDEO]) { + imp = buildVideoImp(bidRequest, imp); + } else if (bidRequest.mediaTypes[BANNER]) { + imp = buildBannerImp(bidRequest, imp); + } + + const bidFloor = getBidFloor(bidRequest); + + utils.deepSetValue(imp, 'bidfloor', bidFloor); + + if (bidRequest.params.deals && bidRequest.params.deals.length > 0) { + utils.deepSetValue(imp, 'pmp', { deals: bidRequest.params.deals }); + } + + return imp; + }, + request(buildRequest, imps, bidderRequest, context) { + const req = buildRequest(imps, bidderRequest, context); + mergeDeep(req, { + at: 1, + ext: { + bc: `${bidderConfig}_${bidderVersion}` + } + }) + + let userAgent = navigator.userAgent; + utils.deepSetValue(req, 'device.os', spec.getOS(userAgent)); + utils.deepSetValue(req, 'device.devicetype', _isMobile() ? 1 : _isConnectedTV() ? 3 : 2); + + const bid = context.bidRequests[0]; + if (bid.params.publisherId) { + utils.deepSetValue(req, 'site.publisher.id', bid.params.publisherId); + } + + return req; + }, + + bidResponse(buildBidResponse, bid, context) { + let bidResponse = buildBidResponse(bid, context); + + if (bid.ext) { + bidResponse.meta.networkId = bid.ext.dsp_id; + bidResponse.meta.advertiserId = bid.ext.buyer_id; + bidResponse.meta.brandId = bid.ext.brand_id; + } + + if (context.ortbResponse.ext && context.ortbResponse.ext.paf) { + bidResponse.meta.paf = Object.assign({}, context.ortbResponse.ext.paf); + bidResponse.meta.paf.content_id = utils.deepAccess(bid, 'ext.paf.content_id'); + } + + bidResponse = buildVideoVastResponse(bidResponse); + bidResponse = buildVideoOutstreamResponse(bidResponse, context) + + return bidResponse; + }, + response(buildResponse, bidResponses, ortbResponse, context) { + const response = buildResponse(bidResponses, ortbResponse, context); + + let fledgeAuctionConfigs = utils.deepAccess(ortbResponse, 'ext.fledge_auction_configs'); + if (fledgeAuctionConfigs) { + fledgeAuctionConfigs = Object.entries(fledgeAuctionConfigs).map(([bidId, cfg]) => { + return Object.assign({ + bidId, + auctionSignals: {} + }, cfg); + }); + return { + bids: response.bids, + fledgeAuctionConfigs, + } + } else { + return response.bids + } + } +}); + +function isBidRequestValid(bidRequest) { + return (isPublisherIdValid(bidRequest) && (isValidBannerRequest(bidRequest) || isValidVideoRequest(bidRequest))); +} + +function isPublisherIdValid(bidRequest) { + let pubId = utils.deepAccess(bidRequest, 'params.publisherId'); + return (pubId != null && utils.isStr(pubId) && pubId != ''); +} + +function isValidBannerRequest(bidRequest) { + const bannerSizes = utils.deepAccess(bidRequest, `mediaTypes.${BANNER}.sizes`); + + return utils.isArray(bannerSizes) && bannerSizes.length > 0 && bannerSizes.every(size => utils.isNumber(size[0]) && utils.isNumber(size[1])); +} + +function isValidVideoRequest(bidRequest) { + const videoSizes = utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}.playerSize`); + const PARAM_EXISTS = VIDEO_ORTB_REQUIRED.every(param => utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}.${param}`) != null); + + return PARAM_EXISTS && utils.isArray(videoSizes) && videoSizes.length > 0 && videoSizes.every(size => utils.isNumber(size[0]) && utils.isNumber(size[1])); +} + +function buildRequests(validBids, bidderRequest) { + let videoBids = validBids.filter(bid => isVideoBid(bid)); + let bannerBids = validBids.filter(bid => isBannerBid(bid)); + let requests = []; + + bannerBids.forEach(bid => { + requests.push(createRequest([bid], bidderRequest, BANNER)); + }); + + videoBids.forEach(bid => { + requests.push(createRequest([bid], bidderRequest, VIDEO)); + }); + + return requests; +} + +function buildVideoImp(bidRequest, imp) { + if (bidRequest.mediaTypes[VIDEO]?.context === 'outstream') { + imp.video.placement = imp.video.placement || 4; + } + + const videoMediaType = utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}`); + const videoSizes = (videoMediaType && videoMediaType.playerSize) || []; + + if (videoSizes && videoSizes.length > 0) { + utils.deepSetValue(imp, 'video.w', videoSizes[0][0]); + utils.deepSetValue(imp, 'video.h', videoSizes[0][1]); + } + + const videoAdUnitParams = utils.deepAccess(bidRequest, `mediaTypes.${VIDEO}`, {}); + const videoBidderParams = utils.deepAccess(bidRequest, `params.${VIDEO}`, {}); + + const videoParams = { ...videoAdUnitParams, ...videoBidderParams }; + + VIDEO_ORTB_PARAMS.forEach((param) => { + if (videoParams.hasOwnProperty(param)) { + utils.deepSetValue(imp, `video.${param}`, videoParams[param]); + } + }); + + return { ...imp }; +} + +function buildBannerImp(bidRequest, imp) { + const bannerSizes = utils.deepAccess(bidRequest, `mediaTypes.${BANNER}.sizes`, []); + + if (bannerSizes && bannerSizes.length > 0) { + utils.deepSetValue(imp, 'banner.w', bannerSizes[0][0]); + utils.deepSetValue(imp, 'banner.h', bannerSizes[0][1]); + } + + return {...imp}; +} + +function createRequest(bidRequests, bidderRequest, mediaType) { + return { + method: 'POST', + url: REQUEST_URL, + data: CONVERTER.toORTB({ bidRequests, bidderRequest, context: { mediaType } }) + } +} + +function buildVideoVastResponse(bidResponse) { + if (bidResponse.mediaType == VIDEO && bidResponse.vastXml) { + bidResponse.vastUrl = bidResponse.vastXml; + } + + return { ...bidResponse } +} + +function buildVideoOutstreamResponse(bidResponse, context) { + if (context.bidRequest.mediaTypes[VIDEO]?.context === 'outstream') { + bidResponse.rendererUrl = SP_OUTSTREAM_PLAYER_URL; + bidResponse.adUnitCode = context.bidRequest.adUnitCode; + + bidResponse.renderer = Renderer.install({ + id: bidResponse.requestId, + adUnitCode: context.bidRequest.adUnitCode, + url: bidResponse.rendererUrl + }); + + bidResponse.renderer.setRender(_renderer(bidResponse)); + + bidResponse.renderer.render(bidResponse); + } + + return {...bidResponse}; +} + +function getBidFloor(bid) { + const currency = config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY; + + if (typeof bid.getFloor !== 'function') { + return utils.deepAccess(bid, 'params.bidFloor', 0.05); + } + + const bidFloor = bid.getFloor({ + currency: currency, + mediaType: '*', + size: '*', + }); + return bidFloor.floor; +} + +function _renderer(bid) { + bid.renderer.push(() => { + if (typeof window.SPOutStreamPlayer === 'function') { + const spoplayer = new window.SPOutStreamPlayer(bid); + + spoplayer.on('ready', () => { + spoplayer.startAd(); + }); + + try { + let vastUrlbt = 'data:text/xml;charset=utf-8;base64,' + btoa(bid.vastUrl.replace(/\\"/g, '"')); + spoplayer.load(vastUrlbt).then(function() { + window.spoplayer = spoplayer; + }).catch(function(reason) { + setTimeout(function() { throw reason; }, 0); + }); + } catch (err) { + utils.logMessage(err); + } + } else { + utils.logMessage(`Silverpush outstream player is not defined`); + } + }); +} + +function isVideoBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.video'); +} + +function isBannerBid(bid) { + return utils.deepAccess(bid, 'mediaTypes.banner') || !isVideoBid(bid); +} + +function interpretResponse(resp, req) { + if (!resp.body) { + resp.body = { nbr: 0 }; + } + + return CONVERTER.fromORTB({ request: req.data, response: resp.body }); +} + +function onBidWon(bid) { + if (bid == null) { return; } + if (bid['burl'] == null) { return; } + + let burlMac = bid['burl']; + burlMac = burlMac.replace('$' + '{AUCTION_PRICE}', bid['cpm']); + burlMac = burlMac.replace('$' + '{AUCTION_ID}', bid['auctionId']); + burlMac = burlMac.replace('$' + '{AUCTION_IMP_ID}', bid['requestId']); + burlMac = burlMac.replace('$' + '{AUCTION_AD_ID}', bid['adId']); + burlMac = burlMac.replace('$' + '{AUCTION_SEAT_ID}', bid['seatBidId']); + + spec.getRequest(burlMac); +} + +function _isMobile() { + return (/(ios|ipod|ipad|iphone|android)/i).test(navigator.userAgent); +} + +function _isConnectedTV() { + return (/(smart[-]?tv|hbbtv|appletv|googletv|hdmi|netcast\.tv|viera|nettv|roku|\bdtv\b|sonydtv|inettvbrowser|\btv\b)/i).test(navigator.userAgent); +} diff --git a/modules/silverpushBidAdapter.md b/modules/silverpushBidAdapter.md new file mode 100644 index 00000000000..d0af8ba8da8 --- /dev/null +++ b/modules/silverpushBidAdapter.md @@ -0,0 +1,107 @@ +# Overview + +``` +Module Name: Silverpush OpenRTB Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid@silverpush.co +``` + +# Description + +Prebid.JS adapter that connects to the Chocolate Ad Exchange. + +*NOTE*: The Silverpush Bidder Adapter requires setup and approval before use. Please reach out to prebid@silverpush.co representative for more details. + +# Bid Parameters + +## Banner/Video + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +| -------------- | ----------- | ------------------------------------------ | ------------- | ------------ | +| `publisherId` | required | Publisher id provided by silverpush | "123456" | String | +| `bidFloor` | optional | Minimum price in USD. bidFloor applies to a specific unit. For example, use the following value to set a $1.50 floor: 1.50.
| 1.50 | Number | + + + + +# mediaTypes Parameters + +## mediaTypes.banner + +The following banner parameters are supported here so publishers may fully declare their banner inventory: + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +| --------- | ------------| ----------------------------------------------------------------- | --------- | --------- | +| sizes | required | Avalaible sizes supported for banner ad unit | [ [300, 250], [300, 600] ] | [[Integer, Integer], [Integer, Integer]] | + +## mediaTypes.video + + +The following video parameters are supported here so publishers may fully declare their video inventory: + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +| --------- | ------------| ----------------------------------------------------------------- | --------- | --------- | +| context | required | instream or outstream |"outstream" | string | +| playerSize | required | Avalaible sizes supported for video ad unit. | [300, 250] | [Integer, Integer] | +| mimes | required | List of content MIME types supported by the player. | ["video/mp4"]| [String]| +| protocols | required | Supported video bid response protocol values. | [2,3,5,6] | [integers]| +| api | required | Supported API framework values. | [2] | [integers] | +| maxduration | required | Maximum video ad duration in seconds. | 30 | Integer | +| minduration | required | Minimum video ad duration in seconds. | 6 | Integer | +| startdelay | required | Indicates the start delay in seconds for pre-roll, mid-roll, or post-roll ad placements. | 0 | Integer | +| placement | required | Placement type for the impression. | 1 | Integer | +| minbitrate | optional | Minimum bit rate in Kbps. | 300 | Integer | +| maxbitrate | optional | Maximum bit rate in Kbps. | 9600 | Integer | +| playbackmethod | optional | Playback methods that may be in use. Only one method is typically used in practice. | [2]| [Integers] | +| linearity | optional | OpenRTB2 linearity. in-strea,overlay... | 1 | Integer | +| skip | optional | Indicates if the player will allow the video to be skipped, where 0 = no, 1 = yes . | 1 | Integer | +| skipafter | optional | Number of seconds a video must play before skipping is enabled; only applicable if the ad is skippable. | 5 | Integer | +| delivery | optional | OpenRTB2 delivery. Supported delivery methods (e.g., streaming, progressive). If none specified, assume all are supported. | 1 | [Integer] | + + +# Example +```javascript + var adUnits = [{ + code: 'div-1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [300,600] ] + } + }, + bids: [{ + bidder: 'silverpush', + params: { + publisherId: "123456", + bidFloor: 1.2 + } + }] + },{ + code: 'video-1', + mediaTypes: { + video: { + api: [1, 2, 4, 6], + mimes: ['video/mp4'], + context: 'instream', // or 'outstream' + playerSize: [ 640, 480 ], + protocols: [4,5,6,7], + placement: 1, + minduration: 0, + maxduration: 60, + startdelay: 0 + } + }, + bids: [ + { + bidder: 'silverpush', + params: { + publisherId: "123456", + bidfloor: 2.5 + } + } + ] + } +]; +``` diff --git a/modules/sirdataRtdProvider.js b/modules/sirdataRtdProvider.js index 182ff384fef..aaa3c48856b 100644 --- a/modules/sirdataRtdProvider.js +++ b/modules/sirdataRtdProvider.js @@ -1,13 +1,13 @@ /** * This module adds Sirdata provider to the real time data module + * and now supports Seller Defined Audience * The {@link module:modules/realTimeData} module is required * The module will fetch segments (user-centric) and categories (page-centric) from Sirdata server * The module will automatically handle user's privacy and choice in California (IAB TL CCPA Framework) and in Europe (IAB EU TCF FOR GDPR) * @module modules/sirdataRtdProvider * @requires module:modules/realTimeData */ -import {getGlobal} from '../src/prebidGlobal.js'; -import {deepAccess, deepEqual, deepSetValue, isEmpty, logError, mergeDeep} from '../src/utils.js'; +import {deepAccess, deepSetValue, isEmpty, logError, mergeDeep} from '../src/utils.js'; import {submodule} from '../src/hook.js'; import {ajax} from '../src/ajax.js'; import {findIndex} from '../src/polyfill.js'; @@ -17,9 +17,54 @@ import {config} from '../src/config.js'; /** @type {string} */ const MODULE_NAME = 'realTimeData'; const SUBMODULE_NAME = 'SirdataRTDModule'; +const ORTB2_NAME = 'sirdata.com'; + +const partnerIds = { + 'criteo': 27443, + 'openx': 30342, + 'pubmatic': 30345, + 'smaato': 27520, + 'triplelift': 27518, + 'yahoossp': 30339, + 'rubicon': 27452, + 'appnexus': 27446, + 'appnexusAst': 27446, + 'brealtime': 27446, + 'emxdigital': 27446, + 'pagescience': 27446, + 'gourmetads': 33394, + 'matomy': 27446, + 'featureforward': 27446, + 'oftmedia': 27446, + 'districtm': 27446, + 'adasta': 27446, + 'beintoo': 27446, + 'gravity': 27446, + 'msq_classic': 27878, + 'msq_max': 27878, + '366_apx': 27878, + 'mediasquare': 27878, + 'smartadserver': 27440, + 'smart': 27440, + 'proxistore': 27484, + 'ix': 27248, + 'sdRtdForGpt': 27449, + 'smilewanted': 28690, + 'taboola': 33379, + 'ttd': 33382, + 'zeta_global': 33385, + 'teads': 33388, + 'conversant': 33391, + 'improvedigital': 33397, + 'invibes': 33400, + 'sublime': 33403, + 'rtbhouse': 33406, + 'zeta_global_ssp': 33385, +}; + +let CONTEXT_ONLY = true; export function getSegmentsAndCategories(reqBidsConfigObj, onDone, moduleConfig, userConsent) { - const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; moduleConfig.params = moduleConfig.params || {}; var tcString = (userConsent && userConsent.gdpr && userConsent.gdpr.consentString ? userConsent.gdpr.consentString : ''); @@ -37,89 +82,112 @@ export function getSegmentsAndCategories(reqBidsConfigObj, onDone, moduleConfig, sendWithCredentials = false; gdprApplies = null; tcString = ''; - } else if (getGlobal().getConfig('consentManagement.gdpr')) { - // Default endpoint is cookieless if gdpr management is set. Needed because the cookie-based endpoint will fail and return error if user is located in Europe and no consent has been given + } else if (config.getConfig('consentManagement.gdpr')) { + // Default endpoint is cookieless if gdpr management is set. Needed because the cookie-based endpoint will fail and return error if user is located in Europe and no consent has been given sirdataDomain = 'cookieless-data.com'; sendWithCredentials = false; } // default global endpoint is cookie-based if no rules falls into cookieless or consent has been given or GDPR doesn't apply + if (!sirdataDomain || !gdprApplies || (deepAccess(userConsent, 'gdpr.vendorData.vendor.consents') && userConsent.gdpr.vendorData.vendor.consents[53] && userConsent.gdpr.vendorData.purpose.consents[1] && userConsent.gdpr.vendorData.purpose.consents[4])) { sirdataDomain = 'sddan.com'; sendWithCredentials = true; + CONTEXT_ONLY = false; } - var actualUrl = moduleConfig.params.actualUrl || getRefererInfo().referer; - - const url = 'https://kvt.' + sirdataDomain + '/api/v1/public/p/' + moduleConfig.params.partnerId + '/d/' + moduleConfig.params.key + '/s?callback=&gdpr=' + gdprApplies + '&gdpr_consent=' + tcString + (actualUrl ? '&url=' + actualUrl : ''); - ajax(url, { - success: function (response, req) { - if (req.status === 200) { - try { - const data = JSON.parse(response); - if (data && data.segments) { - addSegmentData(adUnits, data, moduleConfig, onDone); - } else { + var actualUrl = moduleConfig.params.actualUrl || getRefererInfo().stack.pop() || getRefererInfo().page; + + const url = 'https://kvt.' + sirdataDomain + '/api/v1/public/p/' + moduleConfig.params.partnerId + '/d/' + moduleConfig.params.key + '/s?callback=&gdpr=' + gdprApplies + '&gdpr_consent=' + tcString + (actualUrl ? '&url=' + encodeURIComponent(actualUrl) : ''); + + ajax(url, + { + success: function (response, req) { + if (req.status === 200) { + try { + const data = JSON.parse(response); + if (data && data.segments) { + addSegmentData(reqBidsConfigObj, data, moduleConfig, onDone); + } else { + onDone(); + } + } catch (e) { onDone(); + logError('unable to parse Sirdata data' + e); } - } catch (e) { + } else if (req.status === 204) { onDone(); - logError('unable to parse Sirdata data' + e); } - } else if (req.status === 204) { + }, + error: function () { onDone(); + logError('unable to get Sirdata data'); } }, - error: function () { - onDone(); - logError('unable to get Sirdata data'); - } - }, - null, - { - contentType: 'text/plain', - method: 'GET', - withCredentials: sendWithCredentials, - referrerPolicy: 'unsafe-url', - crossOrigin: true - }); + null, + { + contentType: 'text/plain', + method: 'GET', + withCredentials: sendWithCredentials, + referrerPolicy: 'unsafe-url', + crossOrigin: true + }); } -export function setGlobalOrtb2(segments, categories) { +export function pushToOrtb2(ortb2Fragments, bidder, data, segtaxid, cattaxid) { try { - let addOrtb2 = {}; - let testGlobal = getGlobal().getConfig('ortb2') || {}; - if (!deepAccess(testGlobal, 'user.ext.data.sd_rtd') || !deepEqual(testGlobal.user.ext.data.sd_rtd, segments)) { - deepSetValue(addOrtb2, 'user.ext.data.sd_rtd', segments || {}); + if (!isEmpty(data.segments)) { + if (segtaxid) { + setOrtb2Sda(ortb2Fragments, bidder, 'user', data.segments, segtaxid); + } else { + setOrtb2(ortb2Fragments, bidder, 'user.ext.data', {sd_rtd: {segments: data.segments}}); + } } - if (!deepAccess(testGlobal, 'site.ext.data.sd_rtd') || !deepEqual(testGlobal.site.ext.data.sd_rtd, categories)) { - deepSetValue(addOrtb2, 'site.ext.data.sd_rtd', categories || {}); + if (!isEmpty(data.categories)) { + if (cattaxid) { + setOrtb2Sda(ortb2Fragments, bidder, 'site', data.categories, cattaxid); + } else { + setOrtb2(ortb2Fragments, bidder, 'site.ext.data', {sd_rtd: {categories: data.categories}}); + } } - if (!isEmpty(addOrtb2)) { - let ortb2 = {ortb2: mergeDeep({}, testGlobal, addOrtb2)}; - getGlobal().setConfig(ortb2); + if (!isEmpty(data.categories_score) && !cattaxid) { + setOrtb2(ortb2Fragments, bidder, 'site.ext.data', {sd_rtd: {categories_score: data.categories_score}}); } } catch (e) { logError(e) } - return true; } -export function setBidderOrtb2(bidder, segments, categories) { +export function setOrtb2Sda(ortb2Fragments, bidder, type, segments, segtaxValue) { try { - let addOrtb2 = {}; - let testBidder = deepAccess(config.getBidderConfig(), bidder + '.ortb2') || {}; - if (!deepAccess(testBidder, 'user.ext.data.sd_rtd') || !deepEqual(testBidder.user.ext.data.sd_rtd, segments)) { - deepSetValue(addOrtb2, 'user.ext.data.sd_rtd', segments || {}); + let ortb2Data = [{ + name: ORTB2_NAME, + segment: segments.map((segmentId) => ({ id: segmentId })), + }]; + if (segtaxValue) { + ortb2Data[0].ext = { segtax: segtaxValue }; } - if (!deepAccess(testBidder, 'site.ext.data.sd_rtd') || !deepEqual(testBidder.site.ext.data.sd_rtd, categories)) { - deepSetValue(addOrtb2, 'site.ext.data.sd_rtd', categories || {}); + let ortb2Conf = (type == 'site' ? {site: {content: {data: ortb2Data}}} : {user: {data: ortb2Data}}); + if (bidder) { + ortb2Conf = {[bidder]: ortb2Conf}; } - if (!isEmpty(addOrtb2)) { - let ortb2 = {ortb2: mergeDeep({}, testBidder, addOrtb2)}; - getGlobal().setBidderConfig({ bidders: [bidder], config: ortb2 }); + mergeDeep(ortb2Fragments, ortb2Conf); + } catch (e) { + logError(e) + } + return true; +} + +export function setOrtb2(ortb2Fragments, bidder, path, segments) { + try { + if (isEmpty(segments)) { return false; } + let ortb2Conf = {}; + deepSetValue(ortb2Conf, path, segments || {}); + if (bidder) { + ortb2Conf = {[bidder]: ortb2Conf}; } + mergeDeep(ortb2Fragments, ortb2Conf); } catch (e) { logError(e) } @@ -127,71 +195,145 @@ export function setBidderOrtb2(bidder, segments, categories) { return true; } -export function loadCustomFunction (todo, adUnit, list, data, bid) { +export function loadCustomFunction(todo, adUnit, list, data, bid) { try { if (typeof todo == 'function') { todo(adUnit, list, data, bid); } - } catch (e) { logError(e); } + } catch (e) { + logError(e); + } return true; } -export function getSegAndCatsArray(data, minScore) { - var sirdataData = {'segments': [], 'categories': []}; +export function getSegAndCatsArray(data, minScore, pid) { + let sirdataData = {'segments': [], 'categories': [], 'categories_score': {}}; minScore = minScore && typeof minScore == 'number' ? minScore : 30; + let cattaxid = data.cattaxid || null; + let segtaxid = data.segtaxid || null; try { if (data && data.contextual_categories) { for (let catId in data.contextual_categories) { - let value = data.contextual_categories[catId]; - if (value >= minScore && sirdataData.categories.indexOf(catId) === -1) { - sirdataData.categories.push(catId.toString()); + if (data.contextual_categories.hasOwnProperty(catId) && data.contextual_categories[catId]) { + let value = data.contextual_categories[catId]; + if (value >= minScore && sirdataData.categories.indexOf(catId) === -1) { + if (pid && cattaxid) { + sirdataData.categories.push(pid.toString() + 'cc' + catId.toString()); + } else { + sirdataData.categories.push(catId.toString()); + sirdataData.categories_score[catId] = value; + } + } } } } - } catch (e) { logError(e); } + } catch (e) { + logError(e); + } try { if (data && data.segments) { for (let segId in data.segments) { - sirdataData.segments.push(data.segments[segId].toString()); + if (data.segments.hasOwnProperty(segId) && data.segments[segId]) { + let id = data.segments[segId].toString(); + if (pid && CONTEXT_ONLY) { + if (segtaxid) { + sirdataData.categories.push(pid.toString() + 'uc' + id); + } else { + sirdataData.categories.push(id); + sirdataData.categories_score[id] = 100; + } + } else { + sirdataData.segments.push((pid && segtaxid) ? pid.toString() + 'us' + id : id); + } + } } } - } catch (e) { logError(e); } + } catch (e) { + logError(e); + } return sirdataData; } -export function addSegmentData(adUnits, data, moduleConfig, onDone) { +export function applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit) { + // only share SDA data if whitelisted + if (!biddersParamsExist || indexFound) { + // SDA Publisher + let sirdataDataForSDA = getSegAndCatsArray(data, minScore, moduleConfig.params.partnerId); + pushToOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, sirdataDataForSDA, data.segtaxid, data.cattaxid); + } + + // always share SDA for curation + let curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : (partnerIds[bid.bidder] ? partnerIds[bid.bidder] : null)); + if (curationId) { + // seller defined audience & bidder specific data + if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { + // Get Bidder Specific Data + let curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore, curationId); + pushToOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, curationData, data.shared_taxonomy[curationId].segtaxid, data.shared_taxonomy[curationId].cattaxid); + } + } + + // Apply custom function or return Bidder Specific Data if publisher is ok + if (!biddersParamsExist || indexFound) { + if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { + return loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataData, data, bid); + } else { + return sirdataData; + } + } +} + +export function applySdaAndDefaultSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit) { + sirdataData = applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); + /* + if (sirdataData.segments && sirdataData.segments.length > 0) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.ext.data', {sd_rtd: sirdataData.segments}); + } + if (sirdataData.categories && sirdataData.categories.length > 0) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'site.ext.data', {sd_rtd: sirdataData.categories}); + } + */ +} + +export function addSegmentData(reqBids, data, moduleConfig, onDone) { + const adUnits = reqBids.adUnits; moduleConfig = moduleConfig || {}; moduleConfig.params = moduleConfig.params || {}; const globalMinScore = moduleConfig.params.hasOwnProperty('contextualMinRelevancyScore') ? moduleConfig.params.contextualMinRelevancyScore : 30; - var sirdataData = getSegAndCatsArray(data, globalMinScore); - - if (!sirdataData || (sirdataData.segments.length < 1 && sirdataData.categories.length < 1)) { logError('no cats'); onDone(); return adUnits; } - - const sirdataList = sirdataData.segments.concat(sirdataData.categories); + var sirdataData = getSegAndCatsArray(data, globalMinScore, null); - var curationData = {'segments': [], 'categories': []}; - var curationId = '1'; const biddersParamsExist = (!!(moduleConfig.params && moduleConfig.params.bidders)); - // Global ortb2 - if (!biddersParamsExist) { - setGlobalOrtb2(sirdataData.segments, sirdataData.categories); + // Global ortb2 SDA + if (data.global_taxonomy && !isEmpty(data.global_taxonomy)) { + let globalData = {'segments': [], 'categories': [], 'categories_score': []}; + for (let i in data.global_taxonomy) { + if (!isEmpty(data.global_taxonomy[i])) { + globalData = getSegAndCatsArray(data.global_taxonomy[i], globalMinScore, null); + pushToOrtb2(reqBids.ortb2Fragments?.global, null, globalData, data.global_taxonomy[i].segtaxid, data.global_taxonomy[i].cattaxid); + } + } } // Google targeting if (typeof window.googletag !== 'undefined' && (moduleConfig.params.setGptKeyValues || !moduleConfig.params.hasOwnProperty('setGptKeyValues'))) { try { - // For curation Google is pid 27449 - curationId = (moduleConfig.params.gptCurationId ? moduleConfig.params.gptCurationId : '27449'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], globalMinScore); + let gptCurationId = (moduleConfig.params.gptCurationId ? moduleConfig.params.gptCurationId : (partnerIds['sdRtdForGpt'] ? partnerIds['sdRtdForGpt'] : null)); + let sirdataMergedList = sirdataData.segments.concat(sirdataData.categories); + if (gptCurationId && data.shared_taxonomy && data.shared_taxonomy[gptCurationId]) { + let gamCurationData = getSegAndCatsArray(data.shared_taxonomy[gptCurationId], globalMinScore, null); + sirdataMergedList = sirdataMergedList.concat(gamCurationData.segments).concat(gamCurationData.categories); } - window.googletag.pubads().getSlots().forEach(function(n) { - if (typeof n.setTargeting !== 'undefined') { - n.setTargeting('sd_rtd', sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - }) - } catch (e) { logError(e); } + window.googletag.cmd.push(function() { + window.googletag.pubads().getSlots().forEach(function (n) { + if (typeof n.setTargeting !== 'undefined' && sirdataMergedList && sirdataMergedList.length > 0) { + n.setTargeting('sd_rtd', sirdataMergedList); + } + }); + }); + } catch (e) { + logError(e); + } } // Bid targeting level for FPD non-generic biders @@ -199,189 +341,48 @@ export function addSegmentData(adUnits, data, moduleConfig, onDone) { var indexFound = false; adUnits.forEach(adUnit => { - if (!biddersParamsExist && !deepAccess(adUnit, 'ortb2Imp.ext.data.sd_rtd')) { - deepSetValue(adUnit, 'ortb2Imp.ext.data.sd_rtd', sirdataList); - } - adUnit.hasOwnProperty('bids') && adUnit.bids.forEach(bid => { - bidderIndex = (moduleConfig.params.hasOwnProperty('bidders') ? findIndex(moduleConfig.params.bidders, function(i) { return i.bidder === bid.bidder; }) : false); + bidderIndex = (moduleConfig.params.hasOwnProperty('bidders') ? findIndex(moduleConfig.params.bidders, function (i) { + return i.bidder === bid.bidder; + }) : false); indexFound = (!!(typeof bidderIndex == 'number' && bidderIndex >= 0)); try { - curationData = {'segments': [], 'categories': []}; - let minScore = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('contextualMinRelevancyScore') ? moduleConfig.params.bidders[bidderIndex].contextualMinRelevancyScore : globalMinScore) - - if (!biddersParamsExist || (indexFound && (!moduleConfig.params.bidders[bidderIndex].hasOwnProperty('adUnitCodes') || moduleConfig.params.bidders[bidderIndex].adUnitCodes.indexOf(adUnit.code) !== -1))) { - switch (bid.bidder) { - case 'appnexus': - case 'appnexusAst': - case 'brealtime': - case 'emxdigital': - case 'pagescience': - case 'gourmetads': - case 'matomy': - case 'featureforward': - case 'oftmedia': - case 'districtm': - case 'adasta': - case 'beintoo': - case 'gravity': - case 'msq_classic': - case 'msq_max': - case '366_apx': - // For curation Xandr is pid 27446 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27446'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - deepSetValue(bid, 'params.keywords.sd_rtd', sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - break; - - case 'smartadserver': - case 'smart': - var target = []; - if (bid.hasOwnProperty('params') && bid.params.hasOwnProperty('target')) { - target.push(bid.params.target); - } - // For curation Smart is pid 27440 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27440'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - sirdataList.concat(curationData.segments).concat(curationData.categories).forEach(function(entry) { - if (target.indexOf('sd_rtd=' + entry) === -1) { - target.push('sd_rtd=' + entry); - } - }); - deepSetValue(bid, 'params.target', target.join(';')); - } - break; - - case 'rubicon': - // For curation Magnite is pid 27518 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27452'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - setBidderOrtb2(bid.bidder, data.segments.concat(curationData.segments), sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - break; - - case 'ix': - var ixConfig = getGlobal().getConfig('ix.firstPartyData.sd_rtd'); - if (!ixConfig) { - // For curation index is pid 27248 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27248'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - var cappIxCategories = []; - var ixLength = 0; - var ixLimit = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('sizeLimit') ? moduleConfig.params.bidders[bidderIndex].sizeLimit : 1000); - // Push ids For publisher use and for curation if exists but limit size because the bidder uses GET parameters - sirdataList.concat(curationData.segments).concat(curationData.categories).forEach(function(entry) { - if (ixLength < ixLimit) { - cappIxCategories.push(entry); - ixLength += entry.toString().length; - } - }); - getGlobal().setConfig({ix: {firstPartyData: {sd_rtd: cappIxCategories}}}); - } - } - break; - - case 'proxistore': - // For curation Proxistore is pid 27484 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27484'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } else { - data.shared_taxonomy[curationId] = {contextual_categories: {}}; - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - deepSetValue(bid, 'ortb2.user.ext.data', {segments: sirdataData.segments.concat(curationData.segments), contextual_categories: {...data.contextual_categories, ...data.shared_taxonomy[curationId].contextual_categories}}); - } - break; - - case 'criteo': - // For curation Smart is pid 27443 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27443'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - setBidderOrtb2(bid.bidder, sirdataList.concat(curationData.segments).concat(curationData.categories), sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - break; - - case 'triplelift': - // For curation Triplelift is pid 27518 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27518'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - setBidderOrtb2(bid.bidder, data.segments.concat(curationData.segments), sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - break; - - case 'avct': - case 'avocet': - // For curation Avocet is pid 27522 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27522'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - setBidderOrtb2(bid.bidder, data.segments.concat(curationData.segments), sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - break; - - case 'smaato': - // For curation Smaato is pid 27520 - curationId = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('curationId') ? moduleConfig.params.bidders[bidderIndex].curationId : '27520'); - if (data.shared_taxonomy && data.shared_taxonomy[curationId]) { - curationData = getSegAndCatsArray(data.shared_taxonomy[curationId], minScore); - } - if (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('customFunction')) { - loadCustomFunction(moduleConfig.params.bidders[bidderIndex].customFunction, adUnit, sirdataList.concat(curationData.segments).concat(curationData.categories), data, bid); - } else { - setBidderOrtb2(bid.bidder, data.segments.concat(curationData.segments), sirdataList.concat(curationData.segments).concat(curationData.categories)); - } - break; - - default: - if (!biddersParamsExist || indexFound) { - if (!deepAccess(bid, 'ortb2.site.ext.data.sd_rtd')) { - deepSetValue(bid, 'ortb2.site.ext.data.sd_rtd', sirdataData.categories); - } - if (!deepAccess(bid, 'ortb2.user.ext.data.sd_rtd')) { - deepSetValue(bid, 'ortb2.user.ext.data.sd_rtd', sirdataData.segments); - } - } - } + let minScore = (indexFound && moduleConfig.params.bidders[bidderIndex].hasOwnProperty('contextualMinRelevancyScore') ? moduleConfig.params.bidders[bidderIndex].contextualMinRelevancyScore : globalMinScore); + + switch (bid.bidder) { + case 'appnexus': + case 'appnexusAst': + case 'brealtime': + case 'emxdigital': + case 'pagescience': + case 'gourmetads': + case 'matomy': + case 'featureforward': + case 'oftmedia': + case 'districtm': + case 'adasta': + case 'beintoo': + case 'gravity': + case 'msq_classic': + case 'msq_max': + case '366_apx': + sirdataData = applySdaGetSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); + if (sirdataData.segments && sirdataData.segments.length > 0) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'user.keywords', 'sd_rtd=' + sirdataData.segments.join(',sd_rtd=')); + } + if (sirdataData.categories && sirdataData.categories.length > 0) { + setOrtb2(reqBids.ortb2Fragments?.bidder, bid.bidder, 'site.content.keywords', 'sd_rtd=' + sirdataData.categories.join(',sd_rtd=')); + } + break; + + default: + if (!biddersParamsExist || (indexFound && (!moduleConfig.params.bidders[bidderIndex].hasOwnProperty('adUnitCodes') || moduleConfig.params.bidders[bidderIndex].adUnitCodes.indexOf(adUnit.code) !== -1))) { + applySdaAndDefaultSpecificData(data, sirdataData, biddersParamsExist, minScore, reqBids, bid, moduleConfig, indexFound, bidderIndex, adUnit); + } } - } catch (e) { logError(e) } + } catch (e) { + logError(e); + } }) }); diff --git a/src/sizeMapping.js b/modules/sizeMapping.js similarity index 73% rename from src/sizeMapping.js rename to modules/sizeMapping.js index 4333608ca95..fcd0b0963f2 100644 --- a/src/sizeMapping.js +++ b/modules/sizeMapping.js @@ -1,7 +1,10 @@ -import { config } from './config.js'; -import {logWarn, logInfo, isPlainObject, deepAccess, deepClone, getWindowTop} from './utils.js'; -import {includes} from './polyfill.js'; +import {config} from '../src/config.js'; +import {deepAccess, deepClone, deepSetValue, getWindowTop, logInfo, logWarn} from '../src/utils.js'; +import {includes} from '../src/polyfill.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {setupAdUnitMediaTypes} from '../src/adapterManager.js'; +let installed = false; let sizeConfig = []; /** @@ -21,6 +24,10 @@ let sizeConfig = []; */ export function setSizeConfig(config) { sizeConfig = config; + if (!installed) { + setupAdUnitMediaTypes.before((next, adUnit, labels) => next(processAdUnitsForLabels(adUnit, labels), labels)); + installed = true; + } } config.getConfig('sizeConfig', config => setSizeConfig(config.sizeConfig)); @@ -51,6 +58,13 @@ export function sizeSupported(size, configs = sizeConfig) { return !!maps.sizesSupported[size]; } +const SIZE_PROPS = { + [BANNER]: 'banner.sizes' +} +if (FEATURES.VIDEO) { + SIZE_PROPS[VIDEO] = 'video.playerSize' +} + /** * Resolves the unique set of the union of all sizes and labels that are active from a SizeConfig.mediaQuery match * @param {Array} labels Labels specified on adUnit or bidder @@ -61,36 +75,39 @@ export function sizeSupported(size, configs = sizeConfig) { * @param {Array} configs * @returns {{labels: Array, sizes: Array>}} */ -export function resolveStatus({labels = [], labelAll = false, activeLabels = []} = {}, mediaTypes, sizes, configs = sizeConfig) { +export function resolveStatus({labels = [], labelAll = false, activeLabels = []} = {}, mediaTypes, configs = sizeConfig) { let maps = evaluateSizeConfig(configs); - if (!isPlainObject(mediaTypes)) { - // add support for deprecated adUnit.sizes by creating correct banner mediaTypes if they don't already exist - if (sizes) { - mediaTypes = { - banner: { - sizes + let filtered = false; + let hasSize = false; + const filterResults = {before: {}, after: {}}; + + if (maps.shouldFilter) { + Object.entries(SIZE_PROPS).forEach(([mediaType, sizeProp]) => { + const oldSizes = deepAccess(mediaTypes, sizeProp); + if (oldSizes) { + if (!filtered) { + mediaTypes = deepClone(mediaTypes); + filtered = true; } - }; - } else { - mediaTypes = {}; - } + const newSizes = oldSizes.filter(size => maps.sizesSupported[size]); + deepSetValue(mediaTypes, sizeProp, newSizes); + hasSize = hasSize || newSizes.length > 0; + if (oldSizes.length !== newSizes.length) { + filterResults.before[mediaType] = oldSizes; + filterResults.after[mediaType] = newSizes + } + } + }) } else { - mediaTypes = deepClone(mediaTypes); - } - - let oldSizes = deepAccess(mediaTypes, 'banner.sizes'); - if (maps.shouldFilter && oldSizes) { - mediaTypes.banner.sizes = oldSizes.filter(size => maps.sizesSupported[size]); + hasSize = Object.values(SIZE_PROPS).find(prop => deepAccess(mediaTypes, prop)?.length) != null } - let allMediaTypes = Object.keys(mediaTypes); - let results = { active: ( - allMediaTypes.every(type => type !== 'banner') + !Object.keys(SIZE_PROPS).find(mediaType => mediaTypes.hasOwnProperty(mediaType)) ) || ( - allMediaTypes.some(type => type === 'banner') && deepAccess(mediaTypes, 'banner.sizes.length') > 0 && ( + hasSize && ( labels.length === 0 || ( (!labelAll && ( labels.some(label => maps.labels[label]) || @@ -107,13 +124,9 @@ export function resolveStatus({labels = [], labelAll = false, activeLabels = []} mediaTypes }; - if (oldSizes && oldSizes.length !== mediaTypes.banner.sizes.length) { - results.filterResults = { - before: oldSizes, - after: mediaTypes.banner.sizes - } + if (Object.keys(filterResults.before).length > 0) { + results.filterResults = filterResults; } - return results; } @@ -164,14 +177,13 @@ export function processAdUnitsForLabels(adUnits, activeLabels) { } = resolveStatus( getLabels(adUnit, activeLabels), adUnit.mediaTypes, - adUnit.sizes ); if (!active) { logInfo(`Size mapping disabled adUnit "${adUnit.code}"`); } else { if (filterResults) { - logInfo(`Size mapping filtered adUnit "${adUnit.code}" banner sizes from `, filterResults.before, 'to ', filterResults.after); + logInfo(`Size mapping filtered adUnit "${adUnit.code}" sizes from `, filterResults.before, 'to ', filterResults.after); } adUnit.mediaTypes = mediaTypes; @@ -187,7 +199,7 @@ export function processAdUnitsForLabels(adUnits, activeLabels) { logInfo(`Size mapping deactivated adUnit "${adUnit.code}" bidder "${bid.bidder}"`); } else { if (filterResults) { - logInfo(`Size mapping filtered adUnit "${adUnit.code}" bidder "${bid.bidder}" banner sizes from `, filterResults.before, 'to ', filterResults.after); + logInfo(`Size mapping filtered adUnit "${adUnit.code}" bidder "${bid.bidder}" sizes from `, filterResults.before, 'to ', filterResults.after); bid.mediaTypes = mediaTypes; } bids.push(bid); diff --git a/modules/sizeMappingV2.js b/modules/sizeMappingV2.js index 405799813eb..d212d98f50b 100644 --- a/modules/sizeMappingV2.js +++ b/modules/sizeMappingV2.js @@ -98,7 +98,7 @@ export function checkAdUnitSetupHook(adUnits) { */ if (!isArrayOfNums(config.minViewPort, 2)) { logError(`Ad unit ${adUnitCode}: Invalid declaration of 'minViewPort' in 'mediaTypes.${mediaType}.sizeConfig[${index}]'. ${conditionalLogMessages[mediaType]}`); - isValid = false + isValid = false; return; } /* @@ -129,7 +129,7 @@ export function checkAdUnitSetupHook(adUnits) { Verify that 'config.active' is a 'boolean'. If not, return 'false'. */ - if (mediaType === 'native') { + if (FEATURES.NATIVE && mediaType === 'native') { if (typeof config[propertyName] !== 'boolean') { logError(`Ad unit ${adUnitCode}: Invalid declaration of 'active' in 'mediaTypes.${mediaType}.sizeConfig[${index}]'. ${conditionalLogMessages[mediaType]}`); isValid = false; @@ -182,7 +182,7 @@ export function checkAdUnitSetupHook(adUnits) { } } - if (mediaTypes.video) { + if (FEATURES.VIDEO && mediaTypes.video) { if (mediaTypes.video.playerSize) { // Ad unit is using 'mediaTypes.video.playerSize' instead of the new property 'sizeConfig'. Apply the old checks! validatedVideo = validatedBanner ? adUnitSetupChecks.validateVideoMediaType(validatedBanner) : adUnitSetupChecks.validateVideoMediaType(adUnit); @@ -206,7 +206,7 @@ export function checkAdUnitSetupHook(adUnits) { } } - if (mediaTypes.native) { + if (FEATURES.NATIVE && mediaTypes.native) { // Apply the old native checks validatedNative = validatedVideo ? adUnitSetupChecks.validateNativeMediaType(validatedVideo) : validatedBanner ? adUnitSetupChecks.validateNativeMediaType(validatedBanner) : adUnitSetupChecks.validateNativeMediaType(adUnit); diff --git a/modules/slimcutBidAdapter.js b/modules/slimcutBidAdapter.js index 2d35e09d777..c3f06556652 100644 --- a/modules/slimcutBidAdapter.js +++ b/modules/slimcutBidAdapter.js @@ -1,4 +1,4 @@ -import { getValue, parseSizesInput, getBidIdParameter } from '../src/utils.js'; +import {getBidIdParameter, getValue, parseSizesInput} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; @@ -9,8 +9,8 @@ const BIDDER_CODE = 'slimcut'; const ENDPOINT_URL = 'https://sb.freeskreen.com/pbr'; export const spec = { code: BIDDER_CODE, - gvlid: 52, - aliases: [{ code: 'scm', gvlid: 52 }], + gvlid: 102, + aliases: [{ code: 'scm', gvlid: 102 }], supportedMediaTypes: ['video', 'banner'], /** * Determines whether or not the given bid request is valid. @@ -75,7 +75,6 @@ export const spec = { ad: bid.ad, requestId: bid.requestId, creativeId: bid.creativeId, - transactionId: bid.tranactionId, winUrl: bid.winUrl, meta: { advertiserDomains: bid.adomain || [] @@ -107,14 +106,15 @@ function buildRequestObject(bid) { reqObj.bidderRequestId = getBidIdParameter('bidderRequestId', bid); reqObj.placementId = parseInt(placementId); reqObj.adUnitCode = getBidIdParameter('adUnitCode', bid); + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 reqObj.auctionId = getBidIdParameter('auctionId', bid); - reqObj.transactionId = getBidIdParameter('transactionId', bid); + reqObj.transactionId = bid.ortb2Imp?.ext?.tid || ''; return reqObj; } function getReferrerInfo(bidderRequest) { let ref = window.location.href; - if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - ref = bidderRequest.refererInfo.referer; + if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.page) { + ref = bidderRequest.refererInfo.page; } return ref; } diff --git a/modules/smaatoBidAdapter.js b/modules/smaatoBidAdapter.js index b792983534d..b735953d099 100644 --- a/modules/smaatoBidAdapter.js +++ b/modules/smaatoBidAdapter.js @@ -1,24 +1,31 @@ -import { deepAccess, getDNT, deepSetValue, logInfo, logError, isEmpty, getAdUnitSizes, fill, chunk, getMaxValueFromArray, getMinValueFromArray } from '../src/utils.js'; +import {deepAccess, deepSetValue, getDNT, isEmpty, isNumber, logError, logInfo} from '../src/utils.js'; +import {find} from '../src/polyfill.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {config} from '../src/config.js'; -import {ADPOD, BANNER, VIDEO} from '../src/mediaTypes.js'; +import {ADPOD, BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; +import CONSTANTS from '../src/constants.json'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; +import {fill} from '../libraries/appnexusUtils/anUtils.js'; +import {chunk} from '../libraries/chunk/chunk.js'; +const { NATIVE_IMAGE_TYPES } = CONSTANTS; const BIDDER_CODE = 'smaato'; const SMAATO_ENDPOINT = 'https://prebid.ad.smaato.net/oapi/prebid'; -const SMAATO_CLIENT = 'prebid_js_$prebid.version$_1.6' +const SMAATO_CLIENT = 'prebid_js_$prebid.version$_1.8' const CURRENCY = 'USD'; const buildOpenRtbBidRequest = (bidRequest, bidderRequest) => { const requestTemplate = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, at: 1, cur: [CURRENCY], tmax: bidderRequest.timeout, site: { id: window.location.hostname, - domain: window.location.hostname, - page: window.location.href, - ref: bidderRequest.refererInfo.referer + // TODO: do the fallbacks make sense here? + domain: bidderRequest.refererInfo.domain || window.location.hostname, + page: bidderRequest.refererInfo.page || window.location.href, + ref: bidderRequest.refererInfo.ref }, device: { language: (navigator && navigator.language) ? navigator.language.split('-')[0] : '', @@ -44,7 +51,7 @@ const buildOpenRtbBidRequest = (bidRequest, bidderRequest) => { } }; - let ortb2 = config.getConfig('ortb2') || {}; + let ortb2 = bidderRequest.ortb2 || {}; Object.assign(requestTemplate.user, ortb2.user); Object.assign(requestTemplate.site, ortb2.site); @@ -59,11 +66,28 @@ const buildOpenRtbBidRequest = (bidRequest, bidderRequest) => { deepSetValue(requestTemplate, 'regs.ext.us_privacy', bidderRequest.uspConsent); } + if (ortb2.regs?.gpp !== undefined) { + deepSetValue(requestTemplate, 'regs.ext.gpp', ortb2.regs.gpp); + deepSetValue(requestTemplate, 'regs.ext.gpp_sid', ortb2.regs.gpp_sid); + } + + if (ortb2.device?.ifa !== undefined) { + deepSetValue(requestTemplate, 'device.ifa', ortb2.device.ifa); + } + + if (ortb2.device?.geo !== undefined) { + deepSetValue(requestTemplate, 'device.geo', ortb2.device.geo); + } + if (deepAccess(bidRequest, 'params.app')) { - const geo = deepAccess(bidRequest, 'params.app.geo'); - deepSetValue(requestTemplate, 'device.geo', geo); - const ifa = deepAccess(bidRequest, 'params.app.ifa') - deepSetValue(requestTemplate, 'device.ifa', ifa); + if (!deepAccess(requestTemplate, 'device.geo')) { + const geo = deepAccess(bidRequest, 'params.app.geo'); + deepSetValue(requestTemplate, 'device.geo', geo); + } + if (!deepAccess(requestTemplate, 'device.ifa')) { + const ifa = deepAccess(bidRequest, 'params.app.ifa'); + deepSetValue(requestTemplate, 'device.ifa', ifa); + } } const eids = deepAccess(bidRequest, 'userIdAsEids'); @@ -90,6 +114,12 @@ const buildOpenRtbBidRequest = (bidRequest, bidderRequest) => { } } + const nativeOrtbRequest = bidRequest.nativeOrtbRequest; + if (nativeOrtbRequest) { + const nativeRequest = Object.assign({}, requestTemplate, createNativeImp(bidRequest, nativeOrtbRequest)); + requests.push(nativeRequest); + } + return requests; } @@ -108,11 +138,11 @@ const buildServerRequest = (validBidRequest, data) => { export const spec = { code: BIDDER_CODE, - supportedMediaTypes: [BANNER, VIDEO], + supportedMediaTypes: [BANNER, VIDEO, NATIVE], gvlid: 82, /** - * Determines whether or not the given bid request is valid. + * Determines whether the given bid request is valid. * * @param {BidRequest} bid The bid params to validate. * @return boolean True if this is a valid bid, and false otherwise. @@ -170,6 +200,7 @@ export const spec = { * Unpack the response from the server into a list of bids. * * @param {ServerResponse} serverResponse A successful response from the server. + * @param {BidRequest} bidRequest * @return {Bid[]} An array of bids which were nested inside the server. */ interpretResponse: (serverResponse, bidRequest) => { @@ -209,7 +240,7 @@ export const spec = { } }; - const videoContext = deepAccess(JSON.parse(bidRequest.data).imp[0], 'video.ext.context') + const videoContext = deepAccess(JSON.parse(bidRequest.data).imp[0], 'video.ext.context'); if (videoContext === ADPOD) { resultingBid.vastXml = bid.adm; resultingBid.mediaType = VIDEO; @@ -238,6 +269,11 @@ export const spec = { resultingBid.mediaType = VIDEO; bids.push(resultingBid); break; + case 'Native': + resultingBid.native = createNativeAd(bid.adm); + resultingBid.mediaType = NATIVE; + bids.push(resultingBid); + break; default: logInfo('[SMAATO] Invalid ad type:', smtAdType); } @@ -296,6 +332,13 @@ const createRichmediaAd = (adm) => { return markup + ''; }; +const createNativeAd = (adm) => { + const nativeResponse = JSON.parse(adm).native; + return { + ortb: nativeResponse + } +}; + function createBannerImp(bidRequest) { const adUnitSizes = getAdUnitSizes(bidRequest); const sizes = adUnitSizes.map((size) => ({w: size[0], h: size[1]})); @@ -341,6 +384,33 @@ function createVideoImp(bidRequest, videoMediaType) { }; } +function createNativeImp(bidRequest, nativeRequest) { + return { + imp: [{ + id: bidRequest.bidId, + tagid: deepAccess(bidRequest, 'params.adspaceId'), + bidfloor: getBidFloor(bidRequest, NATIVE, getNativeMainImageSize(nativeRequest)), + native: { + request: JSON.stringify(nativeRequest), + ver: '1.2' + } + }] + }; +} + +function getNativeMainImageSize(nativeRequest) { + const mainImage = find(nativeRequest.assets, asset => asset.hasOwnProperty('img') && asset.img.type === NATIVE_IMAGE_TYPES.MAIN) + if (mainImage) { + if (isNumber(mainImage.img.w) && isNumber(mainImage.img.h)) { + return [[mainImage.img.w, mainImage.img.h]] + } + if (isNumber(mainImage.img.wmin) && isNumber(mainImage.img.hmin)) { + return [[mainImage.img.wmin, mainImage.img.hmin]] + } + } + return [] +} + function createAdPodImp(bidRequest, videoMediaType) { const tagid = deepAccess(bidRequest, 'params.adbreakId') const bce = config.getConfig('adpod.brandCategoryExclusion') @@ -386,7 +456,7 @@ function createAdPodImp(bidRequest, videoMediaType) { }); } else { // all maxdurations should be the same - const maxDuration = getMaxValueFromArray(durationRangeSec); + const maxDuration = Math.max(...durationRangeSec); imps.map((imp, index) => { const sequence = index + 1; imp.video.maxduration = maxDuration @@ -401,7 +471,7 @@ function createAdPodImp(bidRequest, videoMediaType) { function getAdPodNumberOfPlacements(videoMediaType) { const {adPodDurationSec, durationRangeSec, requireExactDuration} = videoMediaType - const minAllowedDuration = getMinValueFromArray(durationRangeSec) + const minAllowedDuration = Math.min(...durationRangeSec) const numberOfPlacements = Math.floor(adPodDurationSec / minAllowedDuration) return requireExactDuration diff --git a/modules/smaatoBidAdapter.md b/modules/smaatoBidAdapter.md index 41e1c952f2a..170880c3fc0 100644 --- a/modules/smaatoBidAdapter.md +++ b/modules/smaatoBidAdapter.md @@ -63,6 +63,84 @@ var adUnits = [{ }]; ``` +For native adunits: + +``` +var adUnits = [{ + "code": "native unit", + "mediaTypes": { + native: { + ortb: { + ver: "1.2", + assets: [ + { + id: 1, + required: 1, + img: { + type: 3, + w: 150, + h: 50, + } + }, + { + id: 2, + required: 1, + img: { + type: 2, + w: 50, + h: 50 + } + }, + { + id: 3, + required: 1, + title: { + len: 80 + } + }, + { + id: 4, + required: 1, + data: { + type: 1 + } + }, + { + id: 5, + required: 1, + data: { + type: 2 + } + }, + { + id: 6, + required: 0, + data: { + type: 3 + } + }, + { + id: 7, + required: 0, + data: { + type: 12 + } + } + ] + }, + sendTargetingKeys: false, + } + }, + "bids": [{ + "bidder": "smaato", + "params": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + }] +}]; +``` + For adpod adunits: ``` diff --git a/modules/smartadserverBidAdapter.js b/modules/smartadserverBidAdapter.js index d6e1c8de452..ca43c26ffd7 100644 --- a/modules/smartadserverBidAdapter.js +++ b/modules/smartadserverBidAdapter.js @@ -1,7 +1,6 @@ import { deepAccess, deepClone, logError, isFn, isPlainObject } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; -import { createEidsArray } from './userId/eids.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'smartadserver'; @@ -13,6 +12,7 @@ export const spec = { gvlid: GVL_ID, aliases: ['smart'], // short code supportedMediaTypes: [BANNER, VIDEO], + /** * Determines whether or not the given bid request is valid. * @@ -131,8 +131,9 @@ export const spec = { */ buildRequests: function (validBidRequests, bidderRequest) { // use bidderRequest.bids[] to get bidder-dependent request info - const adServerCurrency = config.getConfig('currency.adServerCurrency'); + const sellerDefinedAudience = deepAccess(bidderRequest, 'ortb2.user.data', config.getAnyConfig('ortb2.user.data')); + const sellerDefinedContext = deepAccess(bidderRequest, 'ortb2.site.content.data', config.getAnyConfig('ortb2.site.content.data')); // pull requested transaction ID from bidderRequest.bids[].transactionId return validBidRequests.reduce((bidRequests, bid) => { @@ -142,52 +143,74 @@ export const spec = { pageid: bid.params.pageId, formatid: bid.params.formatId, currencyCode: adServerCurrency, - bidfloor: bid.params.bidfloor || spec.getBidFloor(bid, adServerCurrency), targeting: bid.params.target && bid.params.target !== '' ? bid.params.target : undefined, buid: bid.params.buId && bid.params.buId !== '' ? bid.params.buId : undefined, appname: bid.params.appName && bid.params.appName !== '' ? bid.params.appName : undefined, ckid: bid.params.ckId || 0, tagId: bid.adUnitCode, - pageDomain: bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer ? bidderRequest.refererInfo.referer : undefined, - transactionId: bid.transactionId, + // TODO: is 'page' the right value here? + pageDomain: bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.page ? bidderRequest.refererInfo.page : undefined, + transactionId: bid.ortb2Imp?.ext?.tid, timeout: config.getConfig('bidderTimeout'), bidId: bid.bidId, prebidVersion: '$prebid.version$', - schain: spec.serializeSupplyChain(bid.schain) + schain: spec.serializeSupplyChain(bid.schain), + sda: sellerDefinedAudience, + sdc: sellerDefinedContext }; - if (bidderRequest && bidderRequest.gdprConsent) { - payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent; - payload.gdpr_consent = bidderRequest.gdprConsent.consentString; - payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side + const gpid = deepAccess(bid, 'ortb2Imp.ext.gpid', deepAccess(bid, 'ortb2Imp.ext.data.pbadslot', '')); + if (gpid) { + payload.gpid = gpid; + } + + if (bidderRequest) { + if (bidderRequest.gdprConsent) { + payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent; + payload.gdpr_consent = bidderRequest.gdprConsent.consentString; + payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side + } + + if (bidderRequest.gppConsent) { + payload.gpp = bidderRequest.gppConsent.gppString; + payload.gpp_sid = bidderRequest.gppConsent.applicableSections; + } + + if (bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } } - if (bid && bid.userId) { - payload.eids = createEidsArray(bid.userId); + if (bid && bid.userIdAsEids) { + payload.eids = bid.userIdAsEids; } if (bidderRequest && bidderRequest.uspConsent) { payload.us_privacy = bidderRequest.uspConsent; } - const videoMediaType = deepAccess(bid, 'mediaTypes.video'); const bannerMediaType = deepAccess(bid, 'mediaTypes.banner'); - const isAdUnitContainingVideo = videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream'); - if (!isAdUnitContainingVideo && bannerMediaType) { - payload.sizes = spec.adaptBannerSizes(bannerMediaType.sizes); - bidRequests.push(spec.createServerRequest(payload, bid.params.domain)); - } else if (isAdUnitContainingVideo && !bannerMediaType) { - spec.fillPayloadForVideoBidRequest(payload, videoMediaType, bid.params.video); - bidRequests.push(spec.createServerRequest(payload, bid.params.domain)); - } else if (isAdUnitContainingVideo && bannerMediaType) { - // If there are video and banner media types in the ad unit, we clone the payload - // to create a specific one for video. - let videoPayload = deepClone(payload); + const videoMediaType = deepAccess(bid, 'mediaTypes.video'); + const isSupportedVideoContext = videoMediaType && (videoMediaType.context === 'instream' || videoMediaType.context === 'outstream'); - spec.fillPayloadForVideoBidRequest(videoPayload, videoMediaType, bid.params.video); - bidRequests.push(spec.createServerRequest(videoPayload, bid.params.domain)); + if (bannerMediaType || isSupportedVideoContext) { + let type; + if (bannerMediaType) { + type = BANNER; + payload.sizes = spec.adaptBannerSizes(bannerMediaType.sizes); - payload.sizes = spec.adaptBannerSizes(bannerMediaType.sizes); + if (isSupportedVideoContext) { + let videoPayload = deepClone(payload); + spec.fillPayloadForVideoBidRequest(videoPayload, videoMediaType, bid.params.video); + videoPayload.bidfloor = bid.params.bidfloor || spec.getBidFloor(bid, adServerCurrency, VIDEO); + bidRequests.push(spec.createServerRequest(videoPayload, bid.params.domain)); + } + } else { + type = VIDEO; + spec.fillPayloadForVideoBidRequest(payload, videoMediaType, bid.params.video); + } + + payload.bidfloor = bid.params.bidfloor || spec.getBidFloor(bid, adServerCurrency, type); bidRequests.push(spec.createServerRequest(payload, bid.params.domain)); } else { bidRequests.push({}); @@ -208,7 +231,7 @@ export const spec = { const bidResponses = []; let response = serverResponse.body; try { - if (response && !response.isNoAd) { + if (response && !response.isNoAd && (response.ad || response.adUrl)) { const bidRequest = JSON.parse(bidRequestString.data); let bidResponse = { @@ -248,24 +271,21 @@ export const spec = { * * @param {object} bid Bid request object * @param {string} currency Ad server currency + * @param {string} mediaType Bid media type * @return {number} Floor price */ - getBidFloor: function (bid, currency) { + getBidFloor: function (bid, currency, mediaType) { if (!isFn(bid.getFloor)) { return DEFAULT_FLOOR; } const floor = bid.getFloor({ currency: currency || 'USD', - mediaType: '*', + mediaType, size: '*' }); - if (isPlainObject(floor) && !isNaN(floor.floor)) { - return floor.floor; - } - - return DEFAULT_FLOOR; + return isPlainObject(floor) && !isNaN(floor.floor) ? floor.floor : DEFAULT_FLOOR; }, /** diff --git a/modules/smarthubBidAdapter.js b/modules/smarthubBidAdapter.js index a94ed972b2e..2889bd5358b 100644 --- a/modules/smarthubBidAdapter.js +++ b/modules/smarthubBidAdapter.js @@ -2,6 +2,7 @@ import {deepAccess, isFn, logError, logMessage} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'smarthub'; @@ -100,7 +101,7 @@ function buildRequestParams(bidderRequest = {}, placements = []) { winLocation = window.location; } - const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.referer; + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; let refferLocation; try { refferLocation = refferUrl && new URL(refferUrl); @@ -124,7 +125,7 @@ function buildRequestParams(bidderRequest = {}, placements = []) { coppa: config.getConfig('coppa') === true ? 1 : 0, ccpa: bidderRequest.uspConsent || undefined, gdpr: bidderRequest.gdprConsent || undefined, - tmax: config.getConfig('bidderTimeout') + tmax: bidderRequest.timeout }; } @@ -149,6 +150,8 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); const tempObj = {}; const len = validBidRequests.length; diff --git a/modules/smarticoBidAdapter.js b/modules/smarticoBidAdapter.js index edb774f812f..26ecc0f55e3 100644 --- a/modules/smarticoBidAdapter.js +++ b/modules/smarticoBidAdapter.js @@ -66,6 +66,7 @@ export const spec = { method: SMARTICO_CONFIG.method, url: SMARTICO_CONFIG.bidRequestUrl, bids: validBidRequests, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 data: {bidParams: bidParams, auctionId: bidderRequest.auctionId} } return ServerRequestObjects; diff --git a/modules/smartrtbBidAdapter.md b/modules/smartrtbBidAdapter.md deleted file mode 100644 index c44903114cf..00000000000 --- a/modules/smartrtbBidAdapter.md +++ /dev/null @@ -1,41 +0,0 @@ -# Overview - -``` -Module Name: Smart RTB (smrtb.com) Bidder Adapter -Module Type: Bidder Adapter -Maintainer: evanm@smrtb.com -``` - -# Description - -Prebid adapter for Smart RTB. Requires approval and account setup. -Video is supported but requires a publisher supplied adunit renderer at this time. - -# Test Parameters - -## Web -``` - var adUnits = [ - { - code: 'test-div', - mediaTypes: { - banner: { - sizes: [[300,250]] - }, - video: { /* requires publisher supplied renderer */ - context: 'outstream', - playerDimension: [640, 480] - } - }, - bids: [ - { - bidder: "smartrtb", - params: { - zoneId: "N4zTDq3PPEHBIODv7cXK", - forceBid: true - } - } - ] - } - ]; -``` diff --git a/modules/smartxBidAdapter.js b/modules/smartxBidAdapter.js index 00c962445d9..45cc45192ef 100644 --- a/modules/smartxBidAdapter.js +++ b/modules/smartxBidAdapter.js @@ -1,4 +1,17 @@ -import { logError, deepAccess, isArray, getBidIdParameter, getDNT, generateUUID, isEmpty, _each, logMessage, logWarn, isFn, isPlainObject } from '../src/utils.js'; +import { + logError, + deepAccess, + isArray, + getDNT, + generateUUID, + isEmpty, + _each, + logMessage, + logWarn, + isFn, + isPlainObject, + getBidIdParameter +} from '../src/utils.js'; import { Renderer } from '../src/Renderer.js'; @@ -10,8 +23,10 @@ import { } from '../src/mediaTypes.js'; const BIDDER_CODE = 'smartx'; const URL = 'https://bid.sxp.smartclip.net/bid/1000'; +const GVLID = 115; export const spec = { code: BIDDER_CODE, + gvlid: GVLID, supportedMediaTypes: [VIDEO], /** * Determines whether or not the given bid request is valid. @@ -67,7 +82,7 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (bidRequests, bidderRequest) { - const page = bidderRequest.refererInfo.referer; + const page = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; const isPageSecure = !!page.match(/^https:/) const smartxRequests = bidRequests.map(function (bid) { @@ -76,6 +91,7 @@ export const spec = { const bidfloor = getBidFloor(bid) || 0; const bidfloorcur = getBidIdParameter('bidfloorcur', bid.params) || 'EUR'; const siteId = getBidIdParameter('siteId', bid.params); + const sitekey = getBidIdParameter('sitekey', bid.params); const domain = getBidIdParameter('domain', bid.params); const cat = getBidIdParameter('cat', bid.params) || ['']; let pubcid = null; @@ -191,11 +207,25 @@ export const spec = { } } + // Add sitekey if available + if (sitekey) { + requestPayload.site.content.ext.sitekey = sitekey; + } + // Add common id if available if (pubcid) { userExt.fpc = pubcid; } + // Add schain object if available + if (bid && bid.schain) { + requestPayload['source'] = { + ext: { + schain: bid.schain + } + }; + } + // Only add the user object if it's not empty if (!isEmpty(userExt)) { requestPayload.user = { @@ -203,9 +233,7 @@ export const spec = { }; } - // requestPayload.user.ext.ver = pbjs.version; - - // Targeting + // Add targeting if (getBidIdParameter('data', bid.params.user)) { var targetingarr = []; for (var i = 0; i < bid.params.user.data.length; i++) { @@ -220,16 +248,14 @@ export const spec = { name: provider, value: targetingstring, } - }) + }); } } - // Todo: USER ID MODULE - requestPayload.user = { ext: userExt, data: targetingarr - } + }; } return { @@ -240,7 +266,7 @@ export const spec = { options: { contentType: 'application/json', customHeaders: { - 'x-openrtb-version': '2.3' + 'x-openrtb-version': '2.5' } } }; @@ -268,7 +294,6 @@ export const spec = { } /** * Make sure currency and price are the right ones - * TODO: what about the pre_market_bid partners sizes? */ _each(currentBidRequest.params.pre_market_bids, function (pmb) { if (pmb.deal_id == smartxBid.id) { @@ -302,7 +327,7 @@ export const spec = { const playersize = deepAccess(currentBidRequest, 'mediaTypes.video.playerSize'); const renderer = Renderer.install({ id: 0, - url: 'https://dco.smartclip.net/?plc=7777778', + url: 'https://dco.smartclip.net/?plc=7777779', config: { adText: 'SmartX Outstream Video Ad via Prebid.js', player_width: playersize[0][0], @@ -352,65 +377,73 @@ function createOutstreamConfig(bid) { logMessage('[SMARTX][renderer] Handle SmartX outstream renderer'); - var smartPlayObj = { + var playerConfig = { minAdWidth: confMinAdWidth, maxAdWidth: confMaxAdWidth, - onStartCallback: function (m, n) { - try { - window.sc_smartIntxtStart(n); - } catch (f) {} - }, - onCappedCallback: function (m, n) { - try { - window.sc_smartIntxtNoad(n); - } catch (f) {} - }, - onEndCallback: function (m, n) { + coreSetup: {}, + layoutSettings: {}, + onCappedCallback: function() { try { - window.sc_smartIntxtEnd(n); + window.sc_smartIntxtNoad(); } catch (f) {} }, }; if (confStartOpen == 'true') { - smartPlayObj.startOpen = true; + playerConfig.startOpen = true; } else if (confStartOpen == 'false') { - smartPlayObj.startOpen = false; + playerConfig.startOpen = false; } if (confEndingScreen == 'true') { - smartPlayObj.endingScreen = true; + playerConfig.endingScreen = true; } else if (confEndingScreen == 'false') { - smartPlayObj.endingScreen = false; + playerConfig.endingScreen = false; } if (confTitle || (typeof bid.renderer.config.outstream_options.title == 'string' && bid.renderer.config.outstream_options.title == '')) { - smartPlayObj.title = confTitle; + playerConfig.layoutSettings.advertisingLabel = confTitle; } if (confSkipOffset) { - smartPlayObj.skipOffset = confSkipOffset; + playerConfig.coreSetup.skipOffset = confSkipOffset; } if (confDesiredBitrate) { - smartPlayObj.desiredBitrate = confDesiredBitrate; + playerConfig.coreSetup.desiredBitrate = confDesiredBitrate; } if (confVisibilityThreshold) { - smartPlayObj.visibilityThreshold = confVisibilityThreshold; + playerConfig.visibilityThreshold = confVisibilityThreshold; } - smartPlayObj.adResponse = bid.vastContent; + playerConfig.adResponse = bid.vastContent; const divID = '[id="' + elementId + '"]'; + var playerListener = function callback(event) { + switch (event) { + case 'AdSlotStarted': + try { + window.sc_smartIntxtStart(); + } catch (f) {} + break; + + case 'AdSlotComplete': + try { + window.sc_smartIntxtEnd(); + } catch (f) {} + break; + } + }; + try { // eslint-disable-next-line - let _outstreamPlayer = new OutstreamPlayer(divID, smartPlayObj); + outstreamplayer.connect(divID).setup(playerConfig, playerListener) } catch (e) { logError('[SMARTX][renderer] Error caught: ' + e); } - return smartPlayObj; + return playerConfig; } /** diff --git a/modules/smartxBidAdapter.md b/modules/smartxBidAdapter.md index 853f06d6baf..50f78660458 100644 --- a/modules/smartxBidAdapter.md +++ b/modules/smartxBidAdapter.md @@ -3,7 +3,7 @@ ``` Module Name: smartclip Bidder Adapter Module Type: Bidder Adapter -Maintainer: adtech@smartclip.tv +Maintainer: bidding@smartclip.tv ``` # Description @@ -170,4 +170,4 @@ This adapter requires setup and approval from the smartclip team. } }], }]; -``` \ No newline at end of file +``` diff --git a/modules/smartyadsBidAdapter.js b/modules/smartyadsBidAdapter.js index b999d02b059..3e6c5cf360b 100644 --- a/modules/smartyadsBidAdapter.js +++ b/modules/smartyadsBidAdapter.js @@ -2,6 +2,8 @@ import { logMessage } from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { ajax } from '../src/ajax.js'; const BIDDER_CODE = 'smartyads'; const AD_URL = 'https://n1.smartyads.com/?c=o&m=prebid&secret_key=prebid_js'; @@ -16,7 +18,7 @@ function isBidResponseValid(bid) { case BANNER: return Boolean(bid.width && bid.height && bid.ad); case VIDEO: - return Boolean(bid.vastUrl); + return Boolean(bid.vastUrl) || Boolean(bid.vastXml); case NATIVE: return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers); default: @@ -33,10 +35,14 @@ export const spec = { }, buildRequests: (validBidRequests = [], bidderRequest) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + let winTop = window; let location; + // TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin try { - location = new URL(bidderRequest.refererInfo.referer) + location = new URL(bidderRequest.refererInfo.page) winTop = window.top; } catch (e) { location = winTop.location; @@ -61,6 +67,9 @@ export const spec = { if (bidderRequest.gdprConsent) { request.gdpr = bidderRequest.gdprConsent } + if (bidderRequest.gppConsent) { + request.gpp = bidderRequest.gppConsent; + } } const len = validBidRequests.length; @@ -97,24 +106,46 @@ export const spec = { return response; }, - getUserSyncs: (syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '') => { + getUserSyncs: (syncOptions, serverResponses = [], gdprConsent = {}, uspConsent = '', gppConsent = '') => { let syncs = []; let { gdprApplies, consentString = '' } = gdprConsent; if (syncOptions.iframeEnabled) { syncs.push({ type: 'iframe', - url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&type=iframe&us_privacy=${uspConsent}` + url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&type=iframe&us_privacy=${uspConsent}&gpp=${gppConsent}` }); } else { syncs.push({ type: 'image', - url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&type=image&us_privacy=${uspConsent}` + url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&type=image&us_privacy=${uspConsent}&gpp=${gppConsent}` }); } return syncs - } + }, + + onBidWon: function(bid) { + if (bid.winUrl) { + ajax(bid.winUrl, () => {}, JSON.stringify(bid)); + } else { + if (bid?.postData && bid?.postData[0] && bid?.postData[0].params && bid?.postData[0].params[0].host == 'prebid') { + ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&winTest=1', () => {}, JSON.stringify(bid)); + } + } + }, + + onTimeout: function(bid) { + if (bid?.postData && bid?.postData[0] && bid?.postData[0].params && bid?.postData[0].params[0].host == 'prebid') { + ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&bidTimeout=1', () => {}, JSON.stringify(bid)); + } + }, + + onBidderError: function(bid) { + if (bid?.postData && bid?.postData[0] && bid?.postData[0].params && bid?.postData[0].params[0].host == 'prebid') { + ajax('https://et-nd43.itdsmr.com/?c=o&m=prebid&secret_key=prebid_js&bidderError=1', () => {}, JSON.stringify(bid)); + } + }, }; diff --git a/modules/smartyadsBidAdapter.md b/modules/smartyadsBidAdapter.md index f078d905e62..e0d6023a794 100644 --- a/modules/smartyadsBidAdapter.md +++ b/modules/smartyadsBidAdapter.md @@ -10,6 +10,15 @@ Maintainer: supply@smartyads.com Module that connects to SmartyAds' demand sources +# Parameters + +| Name | Scope | Description | Example | +| :------------ | :------- | :------------------------ | :------------------- | +| `sourceid` | required (for prebid.js) | placement ID | "0" | +| `host` | required (for prebid-server) | const value, set to "prebid" | "prebid" | +| `accountid` | required (for prebid-server) | partner ID | "1901" | +| `traffic` | optional (for prebid.js) | Configures the mediaType that should be used. Values can be banner, native or video | "banner" | + # Test Parameters ``` var adUnits = [ diff --git a/modules/smartytechBidAdapter.js b/modules/smartytechBidAdapter.js new file mode 100644 index 00000000000..af1442bd301 --- /dev/null +++ b/modules/smartytechBidAdapter.js @@ -0,0 +1,143 @@ +import {buildUrl, deepAccess} from '../src/utils.js' +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'smartytech'; +export const ENDPOINT_PROTOCOL = 'https'; +export const ENDPOINT_DOMAIN = 'server.smartytech.io'; +export const ENDPOINT_PATH = '/hb/v2/bidder'; + +export const spec = { + supportedMediaTypes: [ BANNER, VIDEO ], + code: BIDDER_CODE, + + isBidRequestValid: function (bidRequest) { + return ( + !!parseInt(bidRequest.params.endpointId) && + spec._validateBanner(bidRequest) && + spec._validateVideo(bidRequest) + ); + }, + + _validateBanner: function(bidRequest) { + const bannerAdUnit = deepAccess(bidRequest, 'mediaTypes.banner'); + + if (bannerAdUnit === undefined) { + return true; + } + + if (!Array.isArray(bannerAdUnit.sizes)) { + return false; + } + + return true; + }, + + _validateVideo: function(bidRequest) { + const videoAdUnit = deepAccess(bidRequest, 'mediaTypes.video'); + + if (videoAdUnit === undefined) { + return true; + } + + if (!Array.isArray(videoAdUnit.playerSize)) { + return false; + } + + if (!videoAdUnit.context) { + return false; + } + + return true; + }, + + buildRequests: function (validBidRequests, bidderRequest) { + const referer = bidderRequest?.refererInfo?.page || window.location.href; + + const bidRequests = validBidRequests.map((validBidRequest) => { + let video = deepAccess(validBidRequest, 'mediaTypes.video', false); + let banner = deepAccess(validBidRequest, 'mediaTypes.banner', false); + let sizes = validBidRequest.params.sizes; + + let oneRequest = { + endpointId: validBidRequest.params.endpointId, + adUnitCode: validBidRequest.adUnitCode, + referer: referer, + bidId: validBidRequest.bidId + }; + + if (video) { + oneRequest.video = video; + + if (sizes) { + oneRequest.video.sizes = sizes; + } + } else if (banner) { + oneRequest.banner = banner; + + if (sizes) { + oneRequest.banner.sizes = sizes; + } + } + + return oneRequest + }); + + let adPartnerRequestUrl = buildUrl({ + protocol: ENDPOINT_PROTOCOL, + hostname: ENDPOINT_DOMAIN, + pathname: ENDPOINT_PATH, + }); + + return { + method: 'POST', + url: adPartnerRequestUrl, + data: bidRequests + }; + }, + + interpretResponse: function (serverResponse, bidRequest) { + if (typeof serverResponse.body === 'undefined') { + return []; + } + + const validBids = bidRequest.data; + const keys = Object.keys(serverResponse.body) + const responseBody = serverResponse.body; + + return keys.filter(key => { + return responseBody[key].ad + }).map(key => { + return { + bid: validBids.find(b => b.adUnitCode === key), + response: responseBody[key] + } + }).map(item => spec._adResponse(item.bid, item.response)); + }, + + _adResponse: function (request, response) { + const bidObject = { + requestId: request.bidId, + adUnitCode: request.adUnitCode, + ad: response.ad, + cpm: response.cpm, + width: response.width, + height: response.height, + ttl: 60, + creativeId: response.creativeId, + netRevenue: true, + currency: response.currency, + mediaType: BANNER + } + + if (response.mediaType === VIDEO) { + bidObject.vastXml = response.ad; + bidObject.mediaType = VIDEO; + } + + return bidObject; + }, + +} + +registerBidder(spec); diff --git a/modules/smartytechBidAdapter.md b/modules/smartytechBidAdapter.md new file mode 100644 index 00000000000..9df57ddbde7 --- /dev/null +++ b/modules/smartytechBidAdapter.md @@ -0,0 +1,55 @@ +# Overview + +``` +Module Name: SmartyTech Bid Adapter +Module Type: Bidder Adapter +Maintainer: info@adpartner.pro +``` + +# Description + +Connects to SmartyTech's exchange for bids. + +SmartyTech bid adapter supports Banner and Video + +# Sample Ad Unit: For Publishers +## Sample Banner Ad Unit +``` +var adUnits = [{ + code: '/123123123/prebidjs-banner', + mediaTypes: { + banner: { + sizes: [ + [300, 301], + [300, 250] + ] + } + }, + bids: [{ + bidder: 'smartytech', + params: { + endpointId: 12 + } + }] +}]; +``` + +## Sample Video Ad Unit +``` +var videoAdUnit = { + code: '/123123123/video-vast-banner', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4'], + } + }, + bids: [{ + bidder: 'smartytech', + params: { + endpointId: 12 + } + }] +}; +``` diff --git a/modules/smilewantedBidAdapter.js b/modules/smilewantedBidAdapter.js index 73bd6101670..2fbfcaa79af 100644 --- a/modules/smilewantedBidAdapter.js +++ b/modules/smilewantedBidAdapter.js @@ -4,9 +4,12 @@ import { config } from '../src/config.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; +const GVL_ID = 639; + export const spec = { code: 'smilewanted', aliases: ['smile', 'sw'], + gvlid: GVL_ID, supportedMediaTypes: [BANNER, VIDEO], /** * Determines whether or not the given bid request is valid. @@ -34,9 +37,14 @@ export const spec = { w: size[0], h: size[1] })), - transactionId: bid.transactionId, - timeout: config.getConfig('bidderTimeout'), + transactionId: bid.ortb2Imp?.ext?.tid, + timeout: bidderRequest?.timeout, bidId: bid.bidId, + /** positionType is undocumented + It is unclear what this parameter means. + If it means the same as pos in openRTB, + It should read from openRTB object + or from mediaTypes.banner.pos */ positionType: bid.params.positionType || '', prebidVersion: '$prebid.version$' }; @@ -51,13 +59,18 @@ export const spec = { } if (bidderRequest && bidderRequest.refererInfo) { - payload.pageDomain = bidderRequest.refererInfo.referer || ''; + payload.pageDomain = bidderRequest.refererInfo.page || ''; } if (bidderRequest && bidderRequest.gdprConsent) { payload.gdpr_consent = bidderRequest.gdprConsent.consentString; payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side } + + if (bid && bid.userIdAsEids) { + payload.eids = bid.userIdAsEids; + } + var payloadString = JSON.stringify(payload); return { method: 'POST', diff --git a/modules/smmsBidAdapter.md b/modules/smmsBidAdapter.md deleted file mode 100644 index f1d6e233f96..00000000000 --- a/modules/smmsBidAdapter.md +++ /dev/null @@ -1,60 +0,0 @@ -# Overview - -Module Name: SMMS Bid Adapter - -Maintainer: SBBGRP-SSP-PMP@g.softbank.co.jp - -# Description - -Module that connects to softbank's demand sources - -# Test Parameters - -```javascript - var adUnits = [ - { - code: 'test', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - bids: [ - { - bidder: 'smms', - params: { - placementId: 1440837, - currency: 'USD' - } - } - ] - }, - { - code: 'test', - mediaTypes: { - native: { - title: { - required: true, - len: 80 - }, - image: { - required: true, - sizes: [150, 50] - }, - sponsoredBy: { - required: true - } - } - }, - bids: [ - { - bidder: 'smms', - params: { - placementId: 1440838, - currency: 'USD' - } - }, - ], - } - ]; -``` diff --git a/modules/smnBidAdapter.md b/modules/smnBidAdapter.md new file mode 100644 index 00000000000..c9cb777e743 --- /dev/null +++ b/modules/smnBidAdapter.md @@ -0,0 +1,52 @@ +# Overview + +Module Name: SMN Bidder Adapter +Module Type: Bidder Adapter +Maintainer: smnoffice.belgrade@gmail.com + +# Description + +Connects to SMN demand source to fetch bids. +Banner and Video formats are supported. +Please use ```smn``` as the bidder code. + +# Test Parameters +``` + var adUnits = [ + { + code: 'desktop-banner-ad-div', + sizes: [[300, 250]], // a display size + bids: [ + { + bidder: "smn", + params: { + zone: '2eb6bd58-865c-47ce-af7f-a918108c3fd2' + } + } + ] + },{ + code: 'mobile-banner-ad-div', + sizes: [[300, 50]], // a mobile size + bids: [ + { + bidder: "smn", + params: { + zone: '62211486-c50b-4356-9f0f-411778d31fcc' + } + } + ] + },{ + code: 'video-ad', + sizes: [[300, 50]], + mediaType: 'video', + bids: [ + { + bidder: "smn", + params: { + zone: 'ebeb1e79-8cb4-4473-b2d0-2e24b7ff47fd' + } + } + ] + }, + ]; +``` diff --git a/modules/snigelBidAdapter.js b/modules/snigelBidAdapter.js new file mode 100644 index 00000000000..489d0bcdc9e --- /dev/null +++ b/modules/snigelBidAdapter.js @@ -0,0 +1,204 @@ +import {config} from '../src/config.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {deepAccess, isArray, isFn, isPlainObject, inIframe, getDNT} from '../src/utils.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {getGlobal} from '../src/prebidGlobal.js'; + +const BIDDER_CODE = 'snigel'; +const GVLID = 1076; +const DEFAULT_URL = 'https://adserv.snigelweb.com/bp/v1/prebid'; +const DEFAULT_TTL = 60; +const DEFAULT_CURRENCIES = ['USD']; +const FLOOR_MATCH_ALL_SIZES = '*'; + +const getConfig = config.getConfig; +const refreshes = {}; + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER], + + isBidRequestValid: function (bidRequest) { + return !!bidRequest.params.placement; + }, + + buildRequests: function (bidRequests, bidderRequest) { + const gdprApplies = deepAccess(bidderRequest, 'gdprConsent.gdprApplies'); + return { + method: 'POST', + url: getEndpoint(), + data: JSON.stringify({ + id: bidderRequest.auctionId, + accountId: deepAccess(bidRequests, '0.params.accountId'), + site: deepAccess(bidRequests, '0.params.site'), + cur: getCurrencies(), + test: getTestFlag(), + version: getGlobal().version, + gpp: deepAccess(bidderRequest, 'gppConsent.gppString') || deepAccess(bidderRequest, 'ortb2.regs.gpp'), + gpp_sid: + deepAccess(bidderRequest, 'gppConsent.applicableSections') || deepAccess(bidderRequest, 'ortb2.regs.gpp_sid'), + gdprApplies: gdprApplies, + gdprConsentString: gdprApplies === true ? deepAccess(bidderRequest, 'gdprConsent.consentString') : undefined, + gdprConsentProv: gdprApplies === true ? deepAccess(bidderRequest, 'gdprConsent.addtlConsent') : undefined, + uspConsent: deepAccess(bidderRequest, 'uspConsent'), + coppa: getConfig('coppa'), + eids: deepAccess(bidRequests, '0.userIdAsEids'), + schain: deepAccess(bidRequests, '0.schain'), + page: getPage(bidderRequest), + topframe: inIframe() === true ? 0 : 1, + device: { + w: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, + h: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight, + dnt: getDNT() ? 1 : 0, + language: getLanguage(), + }, + placements: bidRequests.map((r) => { + return { + id: r.adUnitCode, + tid: r.transactionId, + gpid: deepAccess(r, 'ortb2Imp.ext.gpid'), + pbadslot: deepAccess(r, 'ortb2Imp.ext.data.pbadslot') || deepAccess(r, 'ortb2Imp.ext.gpid'), + name: r.params.placement, + sizes: r.sizes, + floor: getPriceFloor(r, BANNER, FLOOR_MATCH_ALL_SIZES), + refresh: getRefreshInformation(r.adUnitCode), + params: r.params.additionalParams, + }; + }), + }), + bidderRequest, + }; + }, + + interpretResponse: function (serverResponse, bidRequest) { + if (!serverResponse.body || !serverResponse.body.bids) { + return []; + } + + return serverResponse.body.bids.map((bid) => { + return { + requestId: mapIdToRequestId(bid.id, bidRequest), + cpm: bid.price, + creativeId: bid.crid, + currency: serverResponse.body.cur, + width: bid.width, + height: bid.height, + ad: bid.ad, + netRevenue: true, + ttl: bid.ttl || DEFAULT_TTL, + meta: bid.meta, + }; + }); + }, + + getUserSyncs: function (syncOptions, responses, gdprConsent, uspConsent, gppConsent) { + const syncUrl = getSyncUrl(responses || []); + if (syncUrl && syncOptions.iframeEnabled && hasSyncConsent(gdprConsent, uspConsent, gppConsent)) { + return [{type: 'iframe', url: getSyncEndpoint(syncUrl, gdprConsent)}]; + } + }, +}; + +registerBidder(spec); + +function getPage(bidderRequest) { + return ( + getConfig(`${BIDDER_CODE}.page`) || deepAccess(bidderRequest, 'refererInfo.canonicalUrl') || window.location.href + ); +} + +function getEndpoint() { + return getConfig(`${BIDDER_CODE}.url`) || DEFAULT_URL; +} + +function getTestFlag() { + return getConfig(`${BIDDER_CODE}.test`) === true; +} + +function getLanguage() { + return navigator && navigator.language + ? navigator.language.indexOf('-') != -1 + ? navigator.language.split('-')[0] + : navigator.language + : undefined; +} + +function getCurrencies() { + const currencyOverrides = getConfig(`${BIDDER_CODE}.cur`); + if (currencyOverrides !== undefined && (!isArray(currencyOverrides) || currencyOverrides.length === 0)) { + throw Error('Currency override must be an array with at least one currency'); + } + return currencyOverrides || DEFAULT_CURRENCIES; +} + +function getFloorCurrency() { + return getConfig(`${BIDDER_CODE}.floorCur`) || getCurrencies()[0]; +} + +function getPriceFloor(bidRequest, mediaType, size) { + if (isFn(bidRequest.getFloor)) { + const cur = getFloorCurrency(); + const floorInfo = bidRequest.getFloor({ + currency: cur, + mediaType: mediaType, + size: size, + }); + if (isPlainObject(floorInfo) && !isNaN(floorInfo.floor)) { + return { + cur: floorInfo.currency || cur, + value: floorInfo.floor, + }; + } + } +} + +function getRefreshInformation(adUnitCode) { + const refresh = refreshes[adUnitCode]; + if (!refresh) { + refreshes[adUnitCode] = { + count: 0, + previousTime: new Date(), + }; + return undefined; + } + + const currentTime = new Date(); + const timeDifferenceSeconds = Math.floor((currentTime - refresh.previousTime) / 1000); + refresh.count += 1; + refresh.previousTime = currentTime; + return { + count: refresh.count, + time: timeDifferenceSeconds, + }; +} + +function mapIdToRequestId(id, bidRequest) { + return bidRequest.bidderRequest.bids.filter((bid) => bid.adUnitCode === id)[0].bidId; +} + +function hasUspConsent(uspConsent) { + return typeof uspConsent !== 'string' || !(uspConsent[0] === '1' && uspConsent[2] === 'Y'); +} + +function hasGppConsent(gppConsent) { + return ( + !(gppConsent && Array.isArray(gppConsent.applicableSections)) || + gppConsent.applicableSections.every((section) => typeof section === 'number' && section <= 5) + ); +} + +function hasSyncConsent(gdprConsent, uspConsent, gppConsent) { + return hasPurpose1Consent(gdprConsent) && hasUspConsent(uspConsent) && hasGppConsent(gppConsent); +} + +function getSyncUrl(responses) { + return getConfig(`${BIDDER_CODE}.syncUrl`) || deepAccess(responses[0], 'body.syncUrl'); +} + +function getSyncEndpoint(url, gdprConsent) { + return `${url}?gdpr=${gdprConsent?.gdprApplies ? 1 : 0}&gdpr_consent=${encodeURIComponent( + gdprConsent?.consentString || '' + )}`; +} diff --git a/modules/snigelBidAdapter.md b/modules/snigelBidAdapter.md new file mode 100644 index 00000000000..f9bb1951d21 --- /dev/null +++ b/modules/snigelBidAdapter.md @@ -0,0 +1,52 @@ +# Overview + +- Module name: Snigel Bid Adapter +- Module type: Bidder Adapter +- Maintainer: devops@snigel.com +- Bidder code: snigel +- Supported media types: Banner + +# Description + +Connects to Snigel demand sources for bids. + +**Note:** This bid adapter requires our ad operation experts to create an optimized setup for the desired placements on your property. +Please reach out to us [through our contact form](https://snigel.com/get-in-touch). We will reply as soon as possible. + +# Parameters + +| Name | Required | Description | +| :-------- | :------- | :------------------- | +| accountId | Yes | Account identifier | +| site | Yes | Site identifier | +| placement | Yes | Placement identifier | + +Snigel will provide all of these parameters to you. + +# Test + +```js +var adUnits = [ + { + code: "example", + mediaTypes: { + banner: { + sizes: [ + [970, 90], + [728, 90], + ], + }, + }, + bids: [ + { + bidder: "snigel", + params: { + accountId: "1000", + site: "test.com", + placement: "prebid_test_placement", + }, + }, + ], + }, +]; +``` diff --git a/modules/somoBidAdapter.md b/modules/somoBidAdapter.md deleted file mode 100644 index e8457fc0ca2..00000000000 --- a/modules/somoBidAdapter.md +++ /dev/null @@ -1,49 +0,0 @@ -# Overview - -**Module Name**: Somo Audience Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: prebid@somoaudience.com -# Description -Connects to Somo Audience demand source. -Please use ```somo``` as the bidder code. - -For video integration, Somo Audience returns content as vastXML and requires the publisher to define the cache url in config passed to Prebid for it to be valid in the auction -# Test Site Parameters -``` - var adUnits = [{ - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bids: [{ - bidder: 'somo', - params: { - placementId: '22a58cfb0c9b656bff713d1236e930e8' - } - }] - }]; -``` -# Test App Parameters -``` -var adUnits = [{ - code: 'banner-ad-div', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - bids: [{ - bidder: 'somo', - params: { - placementId: '22a58cfb0c9b656bff713d1236e930e8', - app: { - bundle: 'com.somoaudience.apps', - storeUrl: 'http://somoaudience.com/apps', - domain: 'somoaudience.com', - } - } - }] -}]; -``` diff --git a/modules/sonobiAnalyticsAdapter.js b/modules/sonobiAnalyticsAdapter.js index 0de6647149a..0057944b201 100644 --- a/modules/sonobiAnalyticsAdapter.js +++ b/modules/sonobiAnalyticsAdapter.js @@ -1,5 +1,5 @@ import { deepClone, logInfo, logError } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import {ajaxBuilder} from '../src/ajax.js'; @@ -255,7 +255,7 @@ sonobiAdapter.sendData = function (auction, data) { contentType: 'text/plain' } ); -} +}; function _logInfo(message, meta) { logInfo(buildLogMessage(message), meta); diff --git a/modules/sonobiBidAdapter.js b/modules/sonobiBidAdapter.js index c5fc07320d8..a2d1f385623 100644 --- a/modules/sonobiBidAdapter.js +++ b/modules/sonobiBidAdapter.js @@ -1,9 +1,12 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, deepClone, getGptSlotInfoForAdUnitCode, isFn, isPlainObject } from '../src/utils.js'; +import { parseSizesInput, logError, generateUUID, isEmpty, deepAccess, logWarn, logMessage, isFn, isPlainObject } from '../src/utils.js'; import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; import { userSync } from '../src/userSync.js'; +import { bidderSettings } from '../src/bidderSettings.js'; +import { getAllOrtbKeywords } from '../libraries/keywords/keywords.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; const BIDDER_CODE = 'sonobi'; const STR_ENDPOINT = 'https://apex.go.sonobi.com/trinity.json'; const PAGEVIEW_ID = generateUUID(); @@ -11,6 +14,7 @@ const OUTSTREAM_REDNERER_URL = 'https://mtrx.go.sonobi.com/sbi_outstream_rendere export const spec = { code: BIDDER_CODE, + gvlid: 104, supportedMediaTypes: [BANNER, VIDEO], /** * Determines whether or not the given bid request is valid. @@ -36,8 +40,8 @@ export const spec = { return false; } } else if (deepAccess(bid, 'mediaTypes.video')) { - if (deepAccess(bid, 'mediaTypes.video.context') === 'outstream' && !bid.params.sizes) { - // bids.params.sizes is required for outstream video adUnits + if (deepAccess(bid, 'mediaTypes.video.context') === 'outstream' && !deepAccess(bid, 'mediaTypes.video.playerSize')) { + // playerSize is required for outstream video adUnits return false; } if (deepAccess(bid, 'mediaTypes.video.context') === 'instream' && !deepAccess(bid, 'mediaTypes.video.playerSize')) { @@ -48,6 +52,7 @@ export const spec = { return true; }, + /** * Make a server request from the list of BidRequests. * @@ -60,11 +65,11 @@ export const spec = { if (/^[\/]?[\d]+[[\/].+[\/]?]?$/.test(slotIdentifier)) { slotIdentifier = slotIdentifier.charAt(0) === '/' ? slotIdentifier : '/' + slotIdentifier; return { - [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}${_validateFloor(bid)}${_validateGPID(bid)}` + [`${slotIdentifier}|${bid.bidId}`]: `${_validateSize(bid)}|${_validateFloor(bid)}${_validateGPID(bid)}${_validateMediaType(bid)}` } } else if (/^[0-9a-fA-F]{20}$/.test(slotIdentifier) && slotIdentifier.length === 20) { return { - [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}${_validateFloor(bid)}${_validateGPID(bid)}` + [bid.bidId]: `${slotIdentifier}|${_validateSize(bid)}|${_validateFloor(bid)}${_validateGPID(bid)}${_validateMediaType(bid)}` } } else { logError(`The ad unit code or Sonobi Placement id for slot ${bid.bidId} is invalid`); @@ -76,17 +81,18 @@ export const spec = { const payload = { 'key_maker': JSON.stringify(data), - 'ref': bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + 'ref': bidderRequest.refererInfo.page, 's': generateUUID(), 'pv': PAGEVIEW_ID, 'vp': _getPlatform(), 'lib_name': 'prebid', 'lib_v': '$prebid.version$', 'us': 0, - + 'iqid': bidderSettings.get(BIDDER_CODE, 'storageAllowed') ? JSON.stringify(loadOrCreateFirstPartyData()) : null, }; - const fpd = config.getConfig('ortb2'); + const fpd = bidderRequest.ortb2; if (fpd) { payload.fpd = JSON.stringify(fpd); @@ -120,16 +126,7 @@ export const spec = { } if (validBidRequests[0].schain) { - payload.schain = JSON.stringify(validBidRequests[0].schain) - } - if (deepAccess(validBidRequests[0], 'userId') && Object.keys(validBidRequests[0].userId).length > 0) { - const userIds = deepClone(validBidRequests[0].userId); - - if (userIds.id5id) { - userIds.id5id = deepAccess(userIds, 'id5id.uid'); - } - - payload.userid = JSON.stringify(userIds); + payload.schain = JSON.stringify(validBidRequests[0].schain); } const eids = deepAccess(validBidRequests[0], 'userIdAsEids'); @@ -137,7 +134,7 @@ export const spec = { payload.eids = JSON.stringify(eids); } - let keywords = validBidRequests[0].params.keywords; // a CSV of keywords + let keywords = getAllOrtbKeywords(bidderRequest.ortb2, ...validBidRequests.map(br => br.params.keywords)).join(','); if (keywords) { payload.kw = keywords; @@ -208,7 +205,7 @@ export const spec = { ] = bid.sbi_size.split('x'); let aDomains = []; if (bid.sbi_adomain) { - aDomains = [bid.sbi_adomain] + aDomains = [bid.sbi_adomain]; } const bids = { requestId: bidId, @@ -244,10 +241,7 @@ export const spec = { bidRequest, 'renderer.options' )); - let videoSize = deepAccess(bidRequest, 'params.sizes'); - if (Array.isArray(videoSize) && Array.isArray(videoSize[0])) { // handle case of multiple sizes - videoSize = videoSize[0] // Only take the first size for outstream - } + let videoSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize'); if (videoSize) { bids.width = videoSize[0]; bids.height = videoSize[1]; @@ -272,7 +266,7 @@ export const spec = { }); }); } - } catch (e) {} + } catch (e) { } return syncs; } }; @@ -285,36 +279,43 @@ function _findBidderRequest(bidderRequests, bidId) { } } -function _validateSize (bid) { - if (deepAccess(bid, 'mediaTypes.video')) { - return ''; // Video bids arent allowed to override sizes via the trinity request +// This function takes all the possible sizes. +// returns string csv. +function _validateSize(bid) { + let size = []; + if (deepAccess(bid, 'mediaTypes.video.playerSize')) { + size.push(deepAccess(bid, 'mediaTypes.video.playerSize')) } - - if (bid.params.sizes) { - return parseSizesInput(bid.params.sizes).join(','); + if (deepAccess(bid, 'mediaTypes.video.sizes')) { + size.push(deepAccess(bid, 'mediaTypes.video.sizes')) + } + if (deepAccess(bid, 'params.sizes')) { + size.push(deepAccess(bid, 'params.sizes')); } if (deepAccess(bid, 'mediaTypes.banner.sizes')) { - return parseSizesInput(deepAccess(bid, 'mediaTypes.banner.sizes')).join(','); + size.push(deepAccess(bid, 'mediaTypes.banner.sizes')) } - - // Handle deprecated sizes definition - if (bid.sizes) { - return parseSizesInput(bid.sizes).join(','); + if (deepAccess(bid, 'sizes')) { + size.push(deepAccess(bid, 'sizes')) } + // Pass the 2d sizes array into parseSizeInput to flatten it into an array of x separated sizes. + // Then throw it into Set to uniquify it. + // Then spread it to an array again. Then join it into a csv of sizes. + return [...new Set(parseSizesInput(...size))].join(','); } -function _validateSlot (bid) { +function _validateSlot(bid) { if (bid.params.ad_unit) { return bid.params.ad_unit; } return bid.params.placement_id; } -function _validateFloor (bid) { +function _validateFloor(bid) { const floor = getBidFloor(bid); if (floor) { - return `|f=${floor}`; + return `f=${floor},`; } return ''; } @@ -323,11 +324,40 @@ function _validateGPID(bid) { const gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot') || deepAccess(getGptSlotInfoForAdUnitCode(bid.adUnitCode), 'gptSlot') || bid.params.ad_unit; if (gpid) { - return `|gpid=${gpid}` + return `gpid=${gpid},` } return '' } +function _validateMediaType(bidRequest) { + let mediaType; + if (deepAccess(bidRequest, 'mediaTypes.video')) { + mediaType = 'video'; + } else if (deepAccess(bidRequest, 'mediaTypes.banner')) { + mediaType = 'display'; + } + + let mediaTypeValidation = ''; + if (mediaType === 'video') { + mediaTypeValidation = 'c=v,'; + if (deepAccess(bidRequest, 'mediaTypes.video.playbackmethod')) { + mediaTypeValidation = `${mediaTypeValidation}pm=${deepAccess(bidRequest, 'mediaTypes.video.playbackmethod').join(':')},`; + } + if (deepAccess(bidRequest, 'mediaTypes.video.placement')) { + let placement = deepAccess(bidRequest, 'mediaTypes.video.placement'); + mediaTypeValidation = `${mediaTypeValidation}p=${placement},`; + } + if (deepAccess(bidRequest, 'mediaTypes.video.plcmt')) { + let plcmt = deepAccess(bidRequest, 'mediaTypes.video.plcmt'); + mediaTypeValidation = `${mediaTypeValidation}pl=${plcmt},`; + } + } else if (mediaType === 'display') { + mediaTypeValidation = 'c=d,'; + } + + return mediaTypeValidation; +} + const _creative = (mediaType, referer) => (sbiDc, sbiAid) => { if (mediaType === 'video' || mediaType === 'outstream') { return _videoCreative(sbiDc, sbiAid, referer) @@ -340,7 +370,7 @@ function _videoCreative(sbiDc, sbiAid, referer) { return `https://${sbiDc}apex.go.sonobi.com/vast.xml?vid=${sbiAid}&ref=${encodeURIComponent(referer)}` } -function _getBidIdFromTrinityKey (key) { +function _getBidIdFromTrinityKey(key) { return key.split('|').slice(-1)[0] } @@ -369,6 +399,67 @@ export function _getPlatform(context = window) { } return 'desktop'; } +/** + * Check for local storage + * Generate a UUID for the user if one does not exist in local storage + * Store the UUID in local storage for future use + * @return {object} firstPartyData - Data object containing first party information + */ +function loadOrCreateFirstPartyData() { + var localStorageEnabled; + + var FIRST_PARTY_KEY = '_iiq_fdata'; + var tryParse = function (data) { + try { + return JSON.parse(data); + } catch (err) { + return null; + } + }; + var readData = function (key) { + if (hasLocalStorage()) { + return window.localStorage.getItem(key); + } + return null; + }; + var hasLocalStorage = function () { + if (typeof localStorageEnabled != 'undefined') { return localStorageEnabled; } else { + try { + localStorageEnabled = !!window.localStorage; + return localStorageEnabled; + } catch (e) { + localStorageEnabled = false; + } + } + return false; + }; + var generateGUID = function () { + var d = new Date().getTime(); + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d / 16); + return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16); + }); + }; + var storeData = function (key, value) { + try { + if (hasLocalStorage()) { + window.localStorage.setItem(key, value); + } + } catch (error) { + return null; + } + }; + var firstPartyData = tryParse(readData(FIRST_PARTY_KEY)); + if (!firstPartyData || !firstPartyData.pcid) { + var firstPartyId = generateGUID(); + firstPartyData = { pcid: firstPartyId, pcidDate: Date.now() }; + } else if (firstPartyData && !firstPartyData.pcidDate) { + firstPartyData.pcidDate = Date.now(); + } + storeData(FIRST_PARTY_KEY, JSON.stringify(firstPartyData)); + return firstPartyData; +}; function newRenderer(adUnitCode, bid, rendererOptions = {}) { const renderer = Renderer.install({ diff --git a/modules/sortableAnalyticsAdapter.js b/modules/sortableAnalyticsAdapter.js deleted file mode 100644 index 4580ce6dbb8..00000000000 --- a/modules/sortableAnalyticsAdapter.js +++ /dev/null @@ -1,535 +0,0 @@ -import { logInfo, getParameterByName, getOldestHighestCpmBid } from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; -import CONSTANTS from '../src/constants.json'; -import adapterManager from '../src/adapterManager.js'; -import {ajax} from '../src/ajax.js'; -import {getGlobal} from '../src/prebidGlobal.js'; -import { config } from '../src/config.js'; -import {bidderSettings} from '../src/bidderSettings.js'; - -const DEFAULT_PROTOCOL = 'https'; -const DEFAULT_HOST = 'pa.deployads.com'; -const DEFAULT_URL = `${DEFAULT_PROTOCOL}://${DEFAULT_HOST}/pae`; -const ANALYTICS_TYPE = 'endpoint'; -const UTM_STORE_KEY = 'sortable_utm'; - -export const DEFAULT_PBID_TIMEOUT = 1000; -export const TIMEOUT_FOR_REGISTRY = 250; - -const settings = {}; -const { - EVENTS: { - AUCTION_INIT, - AUCTION_END, - BID_REQUESTED, - BID_ADJUSTMENT, - BID_WON, - BID_TIMEOUT, - } -} = CONSTANTS; - -const minsToMillis = mins => mins * 60 * 1000; -const UTM_TTL = minsToMillis(30); - -const SORTABLE_EVENTS = { - BID_WON: 'pbrw', - BID_TIMEOUT: 'pbto', - ERROR: 'pber', - PB_BID: 'pbid' -}; - -const UTM_PARAMS = [ - 'utm_campaign', - 'utm_source', - 'utm_medium', - 'utm_content', - 'utm_term' -]; - -const EVENT_KEYS_SHORT_NAMES = { - 'auctionId': 'ai', - 'adUnitCode': 'ac', - 'adId': 'adi', - 'bidderAlias': 'bs', - 'bidFactor': 'bif', - 'bidId': 'bid', - 'bidRequestCount': 'brc', - 'bidderRequestId': 'brid', - 'bidRequestedSizes': 'rs', - 'bidTopCpm': 'btcp', - 'bidTopCpmCurrency': 'btcc', - 'bidTopIsNetRevenue': 'btin', - 'bidTopFactor': 'btif', - 'bidTopSrc': 'btsrc', - 'cpm': 'c', - 'currency': 'cc', - 'dealId': 'did', - 'isNetRevenue': 'inr', - 'isTop': 'it', - 'isWinner': 'iw', - 'isTimeout': 'ito', - 'mediaType': 'mt', - 'reachedTop': 'rtp', - 'numIframes': 'nif', - 'size': 'siz', - 'start': 'st', - 'tagId': 'tgid', - 'transactionId': 'trid', - 'ttl': 'ttl', - 'ttr': 'ttr', - 'url': 'u', - 'utm_campaign': 'uc', - 'utm_source': 'us', - 'utm_medium': 'um', - 'utm_content': 'un', - 'utm_term': 'ut' -}; - -const auctionCache = {}; - -let bidderFactors = null; - -let timeoutId = null; -let eventsToBeSent = []; - -function getStorage() { - try { - return window['sessionStorage']; - } catch (e) { - return null; - } -} - -function putParams(k, v) { - try { - const storage = getStorage(); - if (!storage) { - return false; - } - if (v === null) { - storage.removeItem(k); - } else { - storage.setItem(k, JSON.stringify(v)); - } - return true; - } catch (e) { - return false; - } -} - -function getParams(k) { - try { - let storage = getStorage(); - if (!storage) { - return null; - } - let value = storage.getItem(k); - return value === null ? null : JSON.parse(value); - } catch (e) { - return null; - } -} - -function storeParams(key, paramsToSave) { - if (!settings.disableSessionTracking) { - for (let property in paramsToSave) { - if (paramsToSave.hasOwnProperty(property)) { - putParams(key, paramsToSave); - break; - } - } - } -} - -function getSiteKey(options) { - const sortableConfig = config.getConfig('sortable') || {}; - const globalSiteId = sortableConfig.siteId; - return globalSiteId || options.siteId; -} - -function generateRandomId() { - let s = (+new Date()).toString(36); - for (let i = 0; i < 6; ++i) { s += (Math.random() * 36 | 0).toString(36); } - return s; -} - -function getSessionParams() { - const stillValid = paramsFromStorage => (paramsFromStorage.created) < (+new Date() + UTM_TTL); - let sessionParams = null; - if (!settings.disableSessionTracking) { - const paramsFromStorage = getParams(UTM_STORE_KEY); - sessionParams = paramsFromStorage && stillValid(paramsFromStorage) ? paramsFromStorage : null; - } - sessionParams = sessionParams || {'created': +new Date(), 'sessionId': generateRandomId()}; - const urlParams = UTM_PARAMS.map(getParameterByName); - if (UTM_PARAMS.every(key => !sessionParams[key])) { - UTM_PARAMS.forEach((v, i) => sessionParams[v] = urlParams[i] || sessionParams[v]); - sessionParams.created = +new Date(); - storeParams(UTM_STORE_KEY, sessionParams); - } - return sessionParams; -} - -function getPrebidVersion() { - return getGlobal().version; -} - -function getFactor(bidder) { - if (bidder && bidder.bidCpmAdjustment) { - return bidder.bidCpmAdjustment(1.0); - } else { - return null; - } -} - -function getBiddersFactors() { - const result = {}; - const settings = bidderSettings.getSettings(); - if (settings) { - Object.keys(settings).forEach(bidderKey => { - const bidder = settings[bidderKey]; - const factor = getFactor(bidder); - if (factor !== null) { - result[bidderKey] = factor; - } - }); - } - return result; -} - -function getBaseEvent(auctionId, adUnitCode, bidderCode) { - const event = {}; - event.s = settings.key; - event.ai = auctionId; - event.ac = adUnitCode; - event.bs = bidderCode; - return event; -} - -function getBidBaseEvent(auctionId, adUnitCode, bidderCode) { - const sessionParams = getSessionParams(); - const prebidVersion = getPrebidVersion(); - const event = getBaseEvent(auctionId, adUnitCode, bidderCode); - event.sid = sessionParams.sessionId; - event.pv = settings.pageviewId; - event.to = auctionCache[auctionId].timeout; - event.pbv = prebidVersion; - UTM_PARAMS.filter(k => sessionParams[k]).forEach(k => event[EVENT_KEYS_SHORT_NAMES[k]] = sessionParams[k]); - return event; -} - -function createPBBidEvent(bid) { - const event = getBidBaseEvent(bid.auctionId, bid.adUnitCode, bid.bidderAlias); - Object.keys(bid).forEach(k => { - const shortName = EVENT_KEYS_SHORT_NAMES[k]; - if (shortName) { - event[shortName] = bid[k]; - } - }); - event._type = SORTABLE_EVENTS.PB_BID; - return event; -} - -function getBidFactor(bidderAlias) { - if (!bidderFactors) { - bidderFactors = getBiddersFactors(); - } - const factor = bidderFactors[bidderAlias]; - return typeof factor !== 'undefined' ? factor : 1.0; -} - -function createPrebidBidWonEvent({auctionId, adUnitCode, bidderAlias, cpm, currency, isNetRevenue}) { - const bidFactor = getBidFactor(bidderAlias); - const event = getBaseEvent(auctionId, adUnitCode, bidderAlias); - event.bif = bidFactor; - bidderFactors = null; - event.c = cpm; - event.cc = currency; - event.inr = isNetRevenue; - event._type = SORTABLE_EVENTS.BID_WON; - return event; -} - -function createPrebidTimeoutEvent({auctionId, adUnitCode, bidderAlias}) { - const event = getBaseEvent(auctionId, adUnitCode, bidderAlias); - event._type = SORTABLE_EVENTS.BID_TIMEOUT; - return event; -} - -function getDistinct(arr) { - return arr.filter((v, i, a) => a.indexOf(v) === i); -} - -function groupBy(list, keyGetterFn) { - const map = {}; - list.forEach(item => { - const key = keyGetterFn(item); - map[key] = map[key] ? map[key].concat(item) : [item]; - }); - return map; -} - -function mergeAndCompressEventsByType(events, type) { - if (!events.length) { - return {}; - } - const allKeys = getDistinct(events.map(ev => Object.keys(ev)).reduce((prev, curr) => prev.concat(curr), [])); - const eventsAsMap = {}; - allKeys.forEach(k => { - events.forEach(ev => eventsAsMap[k] = eventsAsMap[k] ? eventsAsMap[k].concat(ev[k]) : [ev[k]]); - }); - const allSame = arr => arr.every(el => arr[0] === el); - Object.keys(eventsAsMap) - .forEach(k => eventsAsMap[k] = (eventsAsMap[k].length && allSame(eventsAsMap[k])) ? eventsAsMap[k][0] : eventsAsMap[k]); - eventsAsMap._count = events.length; - const result = {}; - result[type] = eventsAsMap; - return result; -} - -function mergeAndCompressEvents(events) { - const types = getDistinct(events.map(e => e._type)); - const groupedEvents = groupBy(events, e => e._type); - const results = types.map(t => groupedEvents[t]) - .map(events => mergeAndCompressEventsByType(events, events[0]._type)); - return results.reduce((prev, eventMap) => { - const key = Object.keys(eventMap)[0]; - prev[key] = eventMap[key]; - return prev; - }, {}); -} - -function registerEvents(events) { - eventsToBeSent = eventsToBeSent.concat(events); - if (!timeoutId) { - timeoutId = setTimeout(() => { - const _eventsToBeSent = eventsToBeSent.slice(); - eventsToBeSent = []; - sendEvents(_eventsToBeSent); - timeoutId = null; - }, TIMEOUT_FOR_REGISTRY); - } -} - -function sendEvents(events) { - const url = settings.url; - const mergedEvents = mergeAndCompressEvents(events); - const options = { - 'contentType': 'text/plain', - 'method': 'POST', - 'withCredentials': true - }; - const onSend = () => logInfo('Sortable Analytics data sent'); - ajax(url, onSend, JSON.stringify(mergedEvents), options); -} - -// converts [[300, 250], [728, 90]] to '300x250,728x90' -function sizesToString(sizes) { - return sizes.map(s => s.join('x')).join(','); -} - -function dimsToSizeString(width, height) { - return `${width}x${height}`; -} - -function handleBidRequested(event) { - const refererInfo = event.refererInfo; - const url = refererInfo.referer; - const reachedTop = refererInfo.reachedTop; - const numIframes = refererInfo.numIframes; - event.bids.forEach(bid => { - const auctionId = bid.auctionId; - const adUnitCode = bid.adUnitCode; - const tagId = bid.bidder === 'sortable' ? bid.params.tagId : ''; - if (!auctionCache[auctionId].adUnits[adUnitCode]) { - auctionCache[auctionId].adUnits[adUnitCode] = {bids: {}}; - } - const adUnit = auctionCache[auctionId].adUnits[adUnitCode]; - const bids = adUnit.bids; - const newBid = { - adUnitCode: bid.adUnitCode, - auctionId: event.auctionId, - bidderAlias: bid.bidder, - bidId: bid.bidId, - bidderRequestId: bid.bidderRequestId, - bidRequestCount: bid.bidRequestsCount, - bidRequestedSizes: sizesToString(bid.sizes), - currency: bid.currency, - cpm: 0.0, - isTimeout: false, - isTop: false, - isWinner: false, - numIframes: numIframes, - start: event.start, - tagId: tagId, - transactionId: bid.transactionId, - reachedTop: reachedTop, - url: encodeURI(url) - }; - bids[newBid.bidderAlias] = newBid; - }); -} - -function handleBidAdjustment(event) { - const auctionId = event.auctionId; - const adUnitCode = event.adUnitCode; - const adUnit = auctionCache[auctionId].adUnits[adUnitCode]; - const bid = adUnit.bids[event.bidderCode]; - const bidFactor = getBidFactor(event.bidderCode); - bid.adId = event.adId; - bid.adUnitCode = event.adUnitCode; - bid.auctionId = event.auctionId; - bid.bidderAlias = event.bidderCode; - bid.bidFactor = bidFactor; - bid.cpm = event.cpm; - bid.currency = event.currency; - bid.dealId = event.dealId; - bid.isNetRevenue = event.netRevenue; - bid.mediaType = event.mediaType; - bid.responseTimestamp = event.responseTimestamp; - bid.size = dimsToSizeString(event.width, event.height); - bid.ttl = event.ttl; - bid.ttr = event.timeToRespond; -} - -function handleBidWon(event) { - const auctionId = event.auctionId; - const auction = auctionCache[auctionId]; - if (auction) { - const adUnitCode = event.adUnitCode; - const adUnit = auction.adUnits[adUnitCode]; - Object.keys(adUnit.bids).forEach(bidderCode => { - const bidFromUnit = adUnit.bids[bidderCode]; - bidFromUnit.isWinner = event.bidderCode === bidderCode; - }); - } else { - const ev = createPrebidBidWonEvent({ - adUnitCode: event.adUnitCode, - auctionId: event.auctionId, - bidderAlias: event.bidderCode, - currency: event.currency, - cpm: event.cpm, - isNetRevenue: event.netRevenue, - }); - registerEvents([ev]); - } -} - -function handleBidTimeout(event) { - event.forEach(timeout => { - const auctionId = timeout.auctionId; - const adUnitCode = timeout.adUnitCode; - const bidderAlias = timeout.bidder; - const auction = auctionCache[auctionId]; - if (auction) { - const adUnit = auction.adUnits[adUnitCode]; - const bid = adUnit.bids[bidderAlias]; - bid.isTimeout = true; - } else { - const prebidTimeoutEvent = createPrebidTimeoutEvent({auctionId, adUnitCode, bidderAlias}); - registerEvents([prebidTimeoutEvent]); - } - }); -} - -function handleAuctionInit(event) { - const auctionId = event.auctionId; - const timeout = event.timeout; - auctionCache[auctionId] = {timeout: timeout, auctionId: auctionId, adUnits: {}}; -} - -function handleAuctionEnd(event) { - const auction = auctionCache[event.auctionId]; - const adUnits = auction.adUnits; - setTimeout(() => { - const events = Object.keys(adUnits).map(adUnitCode => { - const bidderKeys = Object.keys(auction.adUnits[adUnitCode].bids); - const bids = bidderKeys.map(bidderCode => auction.adUnits[adUnitCode].bids[bidderCode]); - const highestBid = bids.length ? bids.reduce(getOldestHighestCpmBid) : null; - return bidderKeys.map(bidderCode => { - const bid = auction.adUnits[adUnitCode].bids[bidderCode]; - if (highestBid && highestBid.cpm) { - bid.isTop = highestBid.bidderAlias === bid.bidderAlias; - bid.bidTopFactor = getBidFactor(highestBid.bidderAlias); - bid.bidTopCpm = highestBid.cpm; - bid.bidTopCpmCurrency = highestBid.currency; - bid.bidTopIsNetRevenue = highestBid.isNetRevenue; - bid.bidTopSrc = highestBid.bidderAlias; - } - return createPBBidEvent(bid); - }); - }).reduce((prev, curr) => prev.concat(curr), []); - bidderFactors = null; - sendEvents(events); - delete auctionCache[event.auctionId]; - }, settings.timeoutForPbid); -} - -function handleError(eventType, event, e) { - const ev = {}; - ev.s = settings.key; - ev.ti = eventType; - ev.args = JSON.stringify(event); - ev.msg = e.message; - ev._type = SORTABLE_EVENTS.ERROR; - registerEvents([ev]); -} - -const sortableAnalyticsAdapter = Object.assign(adapter({url: DEFAULT_URL, ANALYTICS_TYPE}), { - track({eventType, args}) { - try { - switch (eventType) { - case AUCTION_INIT: - handleAuctionInit(args); - break; - case AUCTION_END: - handleAuctionEnd(args); - break; - case BID_REQUESTED: - handleBidRequested(args); - break; - case BID_ADJUSTMENT: - handleBidAdjustment(args); - break; - case BID_WON: - handleBidWon(args); - break; - case BID_TIMEOUT: - handleBidTimeout(args); - break; - } - } catch (e) { - handleError(eventType, args, e); - } - } -}); - -sortableAnalyticsAdapter.originEnableAnalytics = sortableAnalyticsAdapter.enableAnalytics; - -sortableAnalyticsAdapter.enableAnalytics = function (setupConfig) { - if (this.initConfig(setupConfig)) { - logInfo('Sortable Analytics adapter enabled'); - sortableAnalyticsAdapter.originEnableAnalytics(setupConfig); - } -}; - -sortableAnalyticsAdapter.initConfig = function (setupConfig) { - settings.disableSessionTracking = setupConfig.disableSessionTracking === undefined ? false : setupConfig.disableSessionTracking; - settings.key = getSiteKey(setupConfig.options); - settings.protocol = setupConfig.options.protocol || DEFAULT_PROTOCOL; - settings.url = `${settings.protocol}://${setupConfig.options.eventHost || DEFAULT_HOST}/pae/${settings.key}`; - settings.pageviewId = generateRandomId(); - settings.timeoutForPbid = setupConfig.timeoutForPbid ? Math.max(setupConfig.timeoutForPbid, 0) : DEFAULT_PBID_TIMEOUT; - return !!settings.key; -}; - -sortableAnalyticsAdapter.getOptions = function () { - return settings; -}; - -adapterManager.registerAnalyticsAdapter({ - adapter: sortableAnalyticsAdapter, - code: 'sortable' -}); - -export default sortableAnalyticsAdapter; diff --git a/modules/sortableAnalyticsAdapter.md b/modules/sortableAnalyticsAdapter.md deleted file mode 100644 index a4aa8019031..00000000000 --- a/modules/sortableAnalyticsAdapter.md +++ /dev/null @@ -1,9 +0,0 @@ -# Overview - -Module Name: Sortable Analytics Adapter -Module Type: Analytics Adapter -Maintainer: prebid@sortable.com - -# Description - -Analytics adapter for Sortable. Contact prebid@sortable.com for information. diff --git a/modules/sortableBidAdapter.js b/modules/sortableBidAdapter.js deleted file mode 100644 index 15246a10eab..00000000000 --- a/modules/sortableBidAdapter.js +++ /dev/null @@ -1,366 +0,0 @@ -import { _each, logError, isFn, isPlainObject, isNumber, isStr, deepAccess, parseUrl, _map, getUniqueIdentifierStr, createTrackPixelHtml } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; -import { createEidsArray } from './userId/eids.js'; - -const BIDDER_CODE = 'sortable'; -const SERVER_URL = 'https://c.deployads.com'; - -function setAssetRequired(native, asset) { - if (native.required) { - asset.required = 1; - } - return asset; -} - -function buildNativeRequest(nativeMediaType) { - const assets = []; - const title = nativeMediaType.title; - if (title) { - assets.push(setAssetRequired(title, { - title: {len: title.len} - })); - } - const img = nativeMediaType.image; - if (img) { - assets.push(setAssetRequired(img, { - img: { - type: 3, // Main - wmin: 1, - hmin: 1 - } - })); - } - const icon = nativeMediaType.icon; - if (icon) { - assets.push(setAssetRequired(icon, { - img: { - type: 1, // Icon - wmin: 1, - hmin: 1 - } - })); - } - const body = nativeMediaType.body; - if (body) { - assets.push(setAssetRequired(body, {data: {type: 2}})); - } - const cta = nativeMediaType.cta; - if (cta) { - assets.push(setAssetRequired(cta, {data: {type: 12}})); - } - const sponsoredBy = nativeMediaType.sponsoredBy; - if (sponsoredBy) { - assets.push(setAssetRequired(sponsoredBy, {data: {type: 1}})); - } - - _each(assets, (asset, id) => asset.id = id); - return { - ver: '1', - request: JSON.stringify({ - ver: '1', - assets - }) - }; -} - -function tryParseNativeResponse(adm) { - let native = null; - try { - native = JSON.parse(adm); - } catch (e) { - logError('Sortable bid adapter unable to parse native bid response:\n\n' + e); - } - return native && native.native; -} - -function createImgObject(img) { - if (img.w || img.h) { - return { - url: img.url, - width: img.w, - height: img.h - }; - } else { - return img.url; - } -} - -function interpretNativeResponse(response) { - const native = {}; - if (response.link) { - native.clickUrl = response.link.url; - } - _each(response.assets, asset => { - switch (asset.id) { - case 1: - native.title = asset.title.text; - break; - case 2: - native.image = createImgObject(asset.img); - break; - case 3: - native.icon = createImgObject(asset.img); - break; - case 4: - native.body = asset.data.value; - break; - case 5: - native.cta = asset.data.value; - break; - case 6: - native.sponsoredBy = asset.data.value; - break; - } - }); - return native; -} - -function transformSyncs(responses, type, syncs) { - _each(responses, res => { - if (res.body && res.body.ext && res.body.ext.sync_dsps && res.body.ext.sync_dsps.length) { - _each(res.body.ext.sync_dsps, sync => { - if (sync[0] === type && sync[1]) { - syncs.push({type, url: sync[1]}); - } - }); - } - }); -} - -function getBidFloor(bid) { - if (!isFn(bid.getFloor)) { - return bid.params.floor ? bid.params.floor : null; - } - - // MediaType and Size will automatically get set for us if the bid only has - // one media type or one size. - let floor = bid.getFloor({ - currency: 'USD', - mediaType: '*', - size: '*' - }); - if (isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') { - return floor.floor; - } - return null; -} - -export const spec = { - code: BIDDER_CODE, - supportedMediaTypes: [BANNER, NATIVE, VIDEO], - - isBidRequestValid: function(bid) { - const sortableConfig = config.getConfig('sortable'); - const haveSiteId = (sortableConfig && !!sortableConfig.siteId) || bid.params.siteId; - const floor = getBidFloor(bid); - const validFloor = !floor || isNumber(floor); - const validKeywords = !bid.params.keywords || - (isPlainObject(bid.params.keywords) && - Object.keys(bid.params.keywords).every(key => - isStr(key) && isStr(bid.params.keywords[key]) - )) - const isBanner = !bid.mediaTypes || bid.mediaTypes[BANNER] || !(bid.mediaTypes[NATIVE] || bid.mediaTypes[VIDEO]); - const bannerSizes = isBanner ? deepAccess(bid, `mediaType.${BANNER}.sizes`) || bid.sizes : null; - return !!(bid.params.tagId && haveSiteId && validFloor && validKeywords && (!isBanner || - (bannerSizes && bannerSizes.length > 0 && bannerSizes.every(sizeArr => sizeArr.length == 2 && sizeArr.every(num => isNumber(num)))))); - }, - - buildRequests: function(validBidReqs, bidderRequest) { - const sortableConfig = config.getConfig('sortable') || {}; - const globalSiteId = sortableConfig.siteId; - let loc = parseUrl(bidderRequest.refererInfo.referer); - - const sortableImps = _map(validBidReqs, bid => { - const rv = { - id: bid.bidId, - tagid: bid.params.tagId, - ext: {} - }; - const bannerMediaType = deepAccess(bid, `mediaTypes.${BANNER}`); - const nativeMediaType = deepAccess(bid, `mediaTypes.${NATIVE}`); - const videoMediaType = deepAccess(bid, `mediaTypes.${VIDEO}`); - if (bannerMediaType || !(nativeMediaType || videoMediaType)) { - const bannerSizes = (bannerMediaType && bannerMediaType.sizes) || bid.sizes; - rv.banner = { - format: _map(bannerSizes, ([width, height]) => ({w: width, h: height})) - }; - } - if (nativeMediaType) { - rv.native = buildNativeRequest(nativeMediaType); - } - if (videoMediaType && videoMediaType.context === 'instream') { - const video = {placement: 1}; - video.mimes = videoMediaType.mimes || []; - video.minduration = deepAccess(bid, 'params.video.minduration') || 10; - video.maxduration = deepAccess(bid, 'params.video.maxduration') || 60; - const startDelay = deepAccess(bid, 'params.video.startdelay'); - if (startDelay != null) { - video.startdelay = startDelay; - } - if (videoMediaType.playerSize && videoMediaType.playerSize.length) { - const size = videoMediaType.playerSize[0]; - video.w = size[0]; - video.h = size[1]; - } - if (videoMediaType.api) { - video.api = videoMediaType.api; - } - if (videoMediaType.protocols) { - video.protocols = videoMediaType.protocols; - } - if (videoMediaType.playbackmethod) { - video.playbackmethod = videoMediaType.playbackmethod; - } - rv.video = video; - } - const floor = getBidFloor(bid); - if (floor) { - rv.floor = floor; - } - if (bid.params.keywords) { - rv.ext.keywords = bid.params.keywords; - } - if (bid.params.bidderParams) { - _each(bid.params.bidderParams, (params, partner) => { - rv.ext[partner] = params; - }); - } - rv.ext.gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); - return rv; - }); - const gdprConsent = bidderRequest && bidderRequest.gdprConsent; - const bidUserId = validBidReqs[0].userId; - const eids = createEidsArray(bidUserId); - const sortableBidReq = { - id: getUniqueIdentifierStr(), - imp: sortableImps, - source: { - ext: { - schain: validBidReqs[0].schain - } - }, - regs: { - ext: {} - }, - site: { - domain: loc.hostname, - page: loc.href, - ref: loc.href, - publisher: { - id: globalSiteId || validBidReqs[0].params.siteId, - }, - device: { - w: screen.width, - h: screen.height - }, - }, - user: { - ext: {} - } - }; - if (bidderRequest && bidderRequest.timeout > 0) { - sortableBidReq.tmax = bidderRequest.timeout; - } - if (gdprConsent) { - sortableBidReq.user = { - ext: { - consent: gdprConsent.consentString - } - }; - if (typeof gdprConsent.gdprApplies == 'boolean') { - sortableBidReq.regs.ext.gdpr = gdprConsent.gdprApplies ? 1 : 0 - } - } - if (eids.length) { - sortableBidReq.user.ext.eids = eids; - } - if (bidderRequest.uspConsent) { - sortableBidReq.regs.ext.us_privacy = bidderRequest.uspConsent; - } - return { - method: 'POST', - url: `${SERVER_URL}/openrtb2/auction?src=$$REPO_AND_VERSION$$&host=${loc.hostname}`, - data: JSON.stringify(sortableBidReq), - options: {contentType: 'text/plain'} - }; - }, - - interpretResponse: function(serverResponse) { - const { body: {id, seatbid} } = serverResponse; - const sortableBids = []; - if (id && seatbid) { - _each(seatbid, seatbid => { - _each(seatbid.bid, bid => { - const bidObj = { - requestId: bid.impid, - cpm: parseFloat(bid.price), - width: parseInt(bid.w), - height: parseInt(bid.h), - creativeId: bid.crid || bid.id, - dealId: bid.dealid || null, - currency: 'USD', - netRevenue: true, - mediaType: BANNER, - ttl: 60, - meta: { - advertiserDomains: bid.adomain || [] - } - }; - if (bid.adm) { - const adFormat = deepAccess(bid, 'ext.ad_format') - if (adFormat === 'native') { - let native = tryParseNativeResponse(bid.adm); - if (!native) { - return; - } - bidObj.mediaType = NATIVE; - bidObj.native = interpretNativeResponse(native); - } else if (adFormat === 'instream') { - bidObj.mediaType = VIDEO; - bidObj.vastXml = bid.adm; - } else { - bidObj.mediaType = BANNER; - bidObj.ad = bid.adm; - if (bid.nurl) { - bidObj.ad += createTrackPixelHtml(decodeURIComponent(bid.nurl)); - } - } - } else if (bid.nurl) { - bidObj.adUrl = bid.nurl; - } - if (bid.ext) { - bidObj[BIDDER_CODE] = bid.ext; - } - sortableBids.push(bidObj); - }); - }); - } - return sortableBids; - }, - - getUserSyncs: (syncOptions, responses) => { - const syncs = []; - if (syncOptions.iframeEnabled) { - transformSyncs(responses, 'iframe', syncs); - } - if (syncOptions.pixelEnabled) { - transformSyncs(responses, 'image', syncs); - } - return syncs; - }, - - onTimeout(details) { - fetch(`${SERVER_URL}/prebid/timeout`, { - method: 'POST', - body: JSON.stringify(details), - mode: 'no-cors', - headers: new Headers({ - 'Content-Type': 'text/plain' - }) - }); - } -}; - -registerBidder(spec); diff --git a/modules/sortableBidAdapter.md b/modules/sortableBidAdapter.md deleted file mode 100644 index c24ad85b752..00000000000 --- a/modules/sortableBidAdapter.md +++ /dev/null @@ -1,109 +0,0 @@ -# Overview - -``` -Module Name: Sortable Bid Adapter -Module Type: Bidder Adapter -Maintainer: prebid@sortable.com -``` - -# Description - -Sortable's adapter integration to the Prebid library. Posts plain-text JSON to the /openrtb2/auction endpoint. - -# Test Parameters - -``` -var adUnits = [ - { - code: 'test-pb-leaderboard', - mediaTypes: { - banner: { - sizes: [[728, 90]], - } - }, - bids: [{ - bidder: 'sortable', - params: { - tagId: 'test-pb-leaderboard', - siteId: 'prebid.example.com', - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - } - } - }] - }, { - code: 'test-pb-banner', - mediaTypes: { - banner: { - sizes: [[300, 250]], - } - }, - bids: [{ - bidder: 'sortable', - params: { - tagId: 'test-pb-banner', - siteId: 'prebid.example.com' - } - }] - }, { - code: 'test-pb-sidebar', - mediaTypes: { - banner: { - sizes: [[160, 600]], - } - }, - bids: [{ - bidder: 'sortable', - params: { - tagId: 'test-pb-sidebar', - siteId: 'prebid.example.com', - 'keywords': { - 'keyA': 'valA' - } - } - }] - }, { - code: 'test-pb-native', - mediaTypes: { - native: { - title: { - required: true, - len: 800 - }, - image: { - required: true, - sizes: [790, 294], - }, - sponsoredBy: { - required: true - } - } - }, - bids: [{ - bidder: 'sortable', - params: { - tagId: 'test-pb-native', - siteId: 'prebid.example.com' - } - }] - }, { - code: 'test-pb-video', - mediaTypes: { - video: { - playerSize: [640,480], - context: 'instream' - } - }, - bids: [ - { - bidder: 'sortable', - params: { - tagId: 'test-pb-video', - siteId: 'prebid.example.com' - } - } - ] - } -] -``` diff --git a/modules/sovrnAnalyticsAdapter.js b/modules/sovrnAnalyticsAdapter.js index 065cfaa58bc..a72c4b1a5a5 100644 --- a/modules/sovrnAnalyticsAdapter.js +++ b/modules/sovrnAnalyticsAdapter.js @@ -1,10 +1,11 @@ import {logError, timestamp} from '../src/utils.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adaptermanager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; import {ajaxBuilder} from '../src/ajax.js'; import {config} from '../src/config.js'; import {find, includes} from '../src/polyfill.js'; +import {getRefererInfo} from '../src/refererDetection.js'; const ajax = ajaxBuilder(0) @@ -22,49 +23,11 @@ let pbaUrl = 'https://pba.aws.lijit.com/analytics' let currentAuctions = {}; const analyticsType = 'endpoint' -const getClosestTop = () => { - let topFrame = window; - let err = false; - try { - while (topFrame.parent.document !== topFrame.document) { - if (topFrame.parent.document) { - topFrame = topFrame.parent; - } else { - throw new Error(); - } - } - } catch (e) { - // bException = true; - } - - return { - topFrame, - err - }; -}; - -const getBestPageUrl = ({err: crossDomainError, topFrame}) => { - let sBestPageUrl = ''; - - if (!crossDomainError) { - // easy case- we can get top frame location - sBestPageUrl = topFrame.location.href; - } else { - try { - try { - sBestPageUrl = window.top.location.href; - } catch (e) { - let aOrigins = window.location.ancestorOrigins; - sBestPageUrl = aOrigins[aOrigins.length - 1]; - } - } catch (e) { - sBestPageUrl = topFrame.document.referrer; - } - } - - return sBestPageUrl; -}; -const rootURL = getBestPageUrl(getClosestTop()) +const rootURL = (() => { + const ref = getRefererInfo(); + // TODO: does the fallback make sense here? + return ref.page || ref.topmostLocation; +})(); let sovrnAnalyticsAdapter = Object.assign(adapter({url: pbaUrl, analyticsType}), { track({ eventType, args }) { diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 4ca8f03c6b4..79481b81936 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -1,8 +1,19 @@ -import { _each, getBidIdParameter, isArray, deepClone, parseUrl, getUniqueIdentifierStr, deepSetValue, logError, deepAccess, isInteger, logWarn } from '../src/utils.js'; +import { + _each, + isArray, + getUniqueIdentifierStr, + deepSetValue, + logError, + deepAccess, + isInteger, + logWarn, getBidIdParameter +} from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js' -import { ADPOD, BANNER, VIDEO } from '../src/mediaTypes.js' -import { createEidsArray } from './userId/eids.js' -import {config} from '../src/config.js' +import { + ADPOD, + BANNER, + VIDEO +} from '../src/mediaTypes.js' const ORTB_VIDEO_PARAMS = { 'mimes': (value) => Array.isArray(value) && value.length > 0 && value.every(v => typeof v === 'string'), @@ -30,6 +41,14 @@ const ORTB_VIDEO_PARAMS = { 'api': (value) => Array.isArray(value) && value.every(v => v >= 1 && v <= 6) } +const REQUIRED_VIDEO_PARAMS = { + context: (value) => value !== ADPOD, + mimes: ORTB_VIDEO_PARAMS.mimes, + minduration: ORTB_VIDEO_PARAMS.minduration, + maxduration: ORTB_VIDEO_PARAMS.maxduration, + protocols: ORTB_VIDEO_PARAMS.protocols +} + export const spec = { code: 'sovrn', supportedMediaTypes: [BANNER, VIDEO], @@ -40,19 +59,25 @@ export const spec = { * @param {object} bid the Sovrn bid to validate * @return boolean for whether or not a bid is valid */ - isBidRequestValid: function(bid) { + isBidRequestValid: function (bid) { + const video = bid?.mediaTypes?.video return !!( bid.params.tagid && !isNaN(parseFloat(bid.params.tagid)) && - isFinite(bid.params.tagid) && - deepAccess(bid, 'mediaTypes.video.context') !== ADPOD + isFinite(bid.params.tagid) && ( + !video || ( + Object.keys(REQUIRED_VIDEO_PARAMS) + .every(key => REQUIRED_VIDEO_PARAMS[key](video[key])) + ) + ) ) }, /** * Format the bid request object for our endpoint - * @param {BidRequest[]} bidRequests Array of Sovrn bidders * @return object of parameters for Prebid AJAX request + * @param bidReqs + * @param bidderRequest */ buildRequests: function(bidReqs, bidderRequest) { try { @@ -60,18 +85,16 @@ export const spec = { let iv; let schain; let eids; - let tpid = [] let criteoId; _each(bidReqs, function (bid) { - if (!eids && bid.userId) { - eids = createEidsArray(bid.userId) + if (!eids && bid.userIdAsEids) { + eids = bid.userIdAsEids; eids.forEach(function (id) { if (id.uids && id.uids[0]) { if (id.source === 'criteo.com') { criteoId = id.uids[0].id } - tpid.push({source: id.source, uid: id.uids[0].id}) } }) } @@ -121,18 +144,20 @@ export const spec = { sovrnImps.push(imp) }) - const fpd = deepClone(config.getConfig('ortb2')) + const fpd = bidderRequest.ortb2 || {}; const site = fpd.site || {} - site.page = bidderRequest.refererInfo.referer - // clever trick to get the domain - site.domain = parseUrl(site.page).hostname + site.page = bidderRequest.refererInfo.page + site.domain = bidderRequest.refererInfo.domain + + const tmax = deepAccess(bidderRequest, 'timeout'); const sovrnBidReq = { id: getUniqueIdentifierStr(), imp: sovrnImps, site: site, - user: fpd.user || {} + user: fpd.user || {}, + tmax: tmax } if (schain) { @@ -143,6 +168,11 @@ export const spec = { }; } + const tid = deepAccess(bidderRequest, 'ortb2.source.tid') + if (tid) { + deepSetValue(sovrnBidReq, 'source.tid', tid) + } + if (bidderRequest.gdprConsent) { deepSetValue(sovrnBidReq, 'regs.ext.gdpr', +bidderRequest.gdprConsent.gdprApplies); deepSetValue(sovrnBidReq, 'user.ext.consent', bidderRequest.gdprConsent.consentString) @@ -150,10 +180,13 @@ export const spec = { if (bidderRequest.uspConsent) { deepSetValue(sovrnBidReq, 'regs.ext.us_privacy', bidderRequest.uspConsent); } + if (bidderRequest.gppConsent) { + deepSetValue(sovrnBidReq, 'regs.gpp', bidderRequest.gppConsent.gppString); + deepSetValue(sovrnBidReq, 'regs.gpp_sid', bidderRequest.gppConsent.applicableSections); + } if (eids) { deepSetValue(sovrnBidReq, 'user.ext.eids', eids) - deepSetValue(sovrnBidReq, 'user.ext.tpid', tpid) if (criteoId) { deepSetValue(sovrnBidReq, 'user.ext.prebid_criteoid', criteoId) } @@ -179,14 +212,12 @@ export const spec = { * @return {Bid[]} An array of formatted bids. */ interpretResponse: function({ body: {id, seatbid} }) { + if (!id || !seatbid || !Array.isArray(seatbid)) return [] + try { - let sovrnBidResponses = []; - if (id && - seatbid && - seatbid.length > 0 && - seatbid[0].bid && - seatbid[0].bid.length > 0) { - seatbid[0].bid.map(sovrnBid => { + return seatbid + .filter(seat => seat) + .map(seat => seat.bid.map(sovrnBid => { const bid = { requestId: sovrnBid.impid, cpm: parseFloat(sovrnBid.price), @@ -196,27 +227,27 @@ export const spec = { dealId: sovrnBid.dealid || null, currency: 'USD', netRevenue: true, - ttl: sovrnBid.ext ? (sovrnBid.ext.ttl || 90) : 90, + mediaType: sovrnBid.nurl ? BANNER : VIDEO, + ttl: sovrnBid.ext?.ttl || 90, meta: { advertiserDomains: sovrnBid && sovrnBid.adomain ? sovrnBid.adomain : [] } } - if (!sovrnBid.nurl) { - bid.mediaType = VIDEO - bid.vastXml = decodeURIComponent(sovrnBid.adm) - } else { - bid.mediaType = BANNER + if (sovrnBid.nurl) { bid.ad = decodeURIComponent(`${sovrnBid.adm}`) + } else { + bid.vastXml = decodeURIComponent(sovrnBid.adm) } - sovrnBidResponses.push(bid); - }); - } - return sovrnBidResponses + + return bid + })) + .flat() } catch (e) { - logError('Could not intrepret bidresponse, error deatils:', e); + logError('Could not interpret bidresponse, error details:', e) + return e } }, - getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { try { const tracks = [] if (serverResponses && serverResponses.length !== 0) { @@ -230,6 +261,10 @@ export const spec = { if (uspConsent) { params.push(['us_privacy', uspConsent]); } + if (gppConsent) { + params.push(['gpp', gppConsent.gppString]); + params.push(['gpp_sid', gppConsent.applicableSections]) + } if (iidArr[0]) { params.push(['informer', iidArr[0]]); @@ -256,11 +291,16 @@ export const spec = { function _buildVideoRequestObj(bid) { const videoObj = {} + const bidSizes = deepAccess(bid, 'sizes') const videoAdUnitParams = deepAccess(bid, 'mediaTypes.video', {}) const videoBidderParams = deepAccess(bid, 'params.video', {}) const computedParams = {} - if (Array.isArray(videoAdUnitParams.playerSize)) { + if (bidSizes) { + const sizes = (Array.isArray(bidSizes[0])) ? bidSizes[0] : bidSizes + computedParams.w = sizes[0] + computedParams.h = sizes[1] + } else if (Array.isArray(videoAdUnitParams.playerSize)) { const sizes = (Array.isArray(videoAdUnitParams.playerSize[0])) ? videoAdUnitParams.playerSize[0] : videoAdUnitParams.playerSize computedParams.w = sizes[0] computedParams.h = sizes[1] diff --git a/modules/spotxBidAdapter.js b/modules/spotxBidAdapter.js index 2fd403058d1..017544cc596 100644 --- a/modules/spotxBidAdapter.js +++ b/modules/spotxBidAdapter.js @@ -1,8 +1,25 @@ -import { logError, deepAccess, isArray, getBidIdParameter, getDNT, deepSetValue, isEmpty, _each, logMessage, logWarn, isBoolean, isNumber, isPlainObject, isFn } from '../src/utils.js'; +import { + logError, + deepAccess, + isArray, + getDNT, + deepSetValue, + isEmpty, + _each, + logMessage, + logWarn, + isBoolean, + isNumber, + isPlainObject, + isFn, + setScriptAttributes, + getBidIdParameter +} from '../src/utils.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { VIDEO } from '../src/mediaTypes.js'; +import { loadExternalScript } from '../src/adloader.js'; const BIDDER_CODE = 'spotx'; const URL = 'https://search.spotxchange.com/openrtb/2.3/dados/'; @@ -11,7 +28,7 @@ export const GOOGLE_CONSENT = { consented_providers: ['3', '7', '11', '12', '15' export const spec = { code: BIDDER_CODE, - gvlid: 52, + gvlid: 165, supportedMediaTypes: [VIDEO], /** @@ -68,7 +85,8 @@ export const spec = { * @return {ServerRequest} Info describing the request to the server. */ buildRequests: function(bidRequests, bidderRequest) { - const referer = bidderRequest.refererInfo.referer; + // TODO: does the fallback make sense here? + const referer = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; const isPageSecure = !!referer.match(/^https:/); const siteId = ''; @@ -76,8 +94,6 @@ export const spec = { let page; if (getBidIdParameter('page', bid.params)) { page = getBidIdParameter('page', bid.params); - } else if (config.getConfig('pageUrl')) { - page = config.getConfig('pageUrl'); } else { page = referer; } @@ -149,7 +165,7 @@ export const spec = { } } - const mimes = getBidIdParameter('mimes', bid.params) || ['application/javascript', 'video/mp4', 'video/webm']; + const mimes = getBidIdParameter('mimes', bid.params) || deepAccess(bid, 'mediaTypes.video.mimes') || ['application/javascript', 'video/mp4', 'video/webm']; const spotxReq = { id: bid.bidId, @@ -176,24 +192,29 @@ export const spec = { spotxReq.bidfloor = getBidIdParameter('price_floor', bid.params); } - if (getBidIdParameter('start_delay', bid.params) != '') { - spotxReq.video.startdelay = 0 + Boolean(getBidIdParameter('start_delay', bid.params)); + const startdelay = getBidIdParameter('start_delay', bid.params) || deepAccess(bid, 'mediaTypes.video.startdelay'); + if (startdelay) { + spotxReq.video.startdelay = 0 + Boolean(startdelay); } - if (getBidIdParameter('min_duration', bid.params) != '') { - spotxReq.video.minduration = getBidIdParameter('min_duration', bid.params); + const minduration = getBidIdParameter('min_duration', bid.params) || deepAccess(bid, 'mediaTypes.video.minduration'); + if (minduration) { + spotxReq.video.minduration = minduration; } - if (getBidIdParameter('max_duration', bid.params) != '') { - spotxReq.video.maxduration = getBidIdParameter('max_duration', bid.params); + const maxduration = getBidIdParameter('max_duration', bid.params) || deepAccess(bid, 'mediaTypes.video.maxduration'); + if (maxduration) { + spotxReq.video.maxduration = maxduration; } - if (getBidIdParameter('placement_type', bid.params) != '') { - spotxReq.video.ext.placement = getBidIdParameter('placement_type', bid.params); + const placement = getBidIdParameter('placement_type', bid.params) || deepAccess(bid, 'mediaTypes.video.placement'); + if (placement) { + spotxReq.video.ext.placement = placement; } - if (getBidIdParameter('position', bid.params) != '') { - spotxReq.video.ext.pos = getBidIdParameter('position', bid.params); + const position = getBidIdParameter('position', bid.params) || deepAccess(bid, 'mediaTypes.video.pos'); + if (position) { + spotxReq.video.ext.pos = position; } if (bid.crumbs && bid.crumbs.pubcid) { @@ -253,18 +274,17 @@ export const spec = { deepSetValue(requestPayload, 'regs.ext.us_privacy', bidderRequest.uspConsent); } - // ID5 fied - if (deepAccess(bid, 'userId.id5id.uid')) { - userExt.eids = userExt.eids || []; - userExt.eids.push( - { - source: 'id5-sync.com', - uids: [{ - id: bid.userId.id5id.uid, - ext: bid.userId.id5id.ext || {} - }] + if (bid.userIdAsEids) { + userExt.eids = bid.userIdAsEids; + + userExt.eids.forEach(eid => { + if (eid.source === 'uidapi.com') { + eid.uids.forEach(uid => { + uid.ext = uid.ext || {}; + uid.ext.rtiPartner = 'UID2' + }); } - ) + }); } // Add common id if available @@ -281,26 +301,11 @@ export const spec = { }; } - if (bid && bid.userId && bid.userId.tdid) { - userExt.eids = userExt.eids || []; - userExt.eids.push( - { - source: 'adserver.org', - uids: [{ - id: bid.userId.tdid, - ext: { - rtiPartner: 'TDID' - } - }] - } - ) - } - // Only add the user object if it's not empty if (!isEmpty(userExt)) { requestPayload.user = { ext: userExt }; } - const urlQueryParams = 'src_sys=prebid' + const urlQueryParams = 'src_sys=prebid'; return { method: 'POST', url: URL + channelId + '?' + urlQueryParams, @@ -361,7 +366,7 @@ export const spec = { bid.vastXml = spotxBid.adm; } else { bid.cache_key = spotxBid.ext.cache_key; - bid.vastUrl = 'https://search.spotxchange.com/ad/vast.html?key=' + spotxBid.ext.cache_key + bid.vastUrl = 'https://search.spotxchange.com/ad/vast.html?key=' + spotxBid.ext.cache_key; bid.videoCacheKey = spotxBid.ext.cache_key; } @@ -376,6 +381,7 @@ export const spec = { const playersize = deepAccess(currentBidRequest, 'mediaTypes.video.playerSize'); const renderer = Renderer.install({ id: 0, + renderNow: true, url: '/', config: { adText: 'SpotX Outstream Video Ad via Prebid.js', @@ -418,11 +424,45 @@ export const spec = { } function createOutstreamScript(bid) { - const slot = getBidIdParameter('slot', bid.renderer.config.outstream_options); - logMessage('[SPOTX][renderer] Handle SpotX outstream renderer'); const script = window.document.createElement('script'); + let dataSpotXParams = createScriptAttributeMap(bid); + script.type = 'text/javascript'; script.src = 'https://js.spotx.tv/easi/v1/' + bid.channel_id + '.js'; + + setScriptAttributes(script, dataSpotXParams); + + return script; +} + +function outstreamRender(bid) { + if (bid.renderer.config.outstream_function != null && typeof bid.renderer.config.outstream_function === 'function') { + const script = createOutstreamScript(bid); + bid.renderer.config.outstream_function(bid, script); + } else { + try { + const inIframe = getBidIdParameter('in_iframe', bid.renderer.config.outstream_options); + const easiUrl = 'https://js.spotx.tv/easi/v1/' + bid.channel_id + '.js'; + let attributes = createScriptAttributeMap(bid); + if (inIframe && window.document.getElementById(inIframe).nodeName == 'IFRAME') { + const rawframe = window.document.getElementById(inIframe); + let framedoc = rawframe.contentDocument; + if (!framedoc && rawframe.contentWindow) { + framedoc = rawframe.contentWindow.document; + } + loadExternalScript(easiUrl, BIDDER_CODE, undefined, framedoc, attributes); + } else { + loadExternalScript(easiUrl, BIDDER_CODE, undefined, undefined, attributes); + } + } catch (err) { + logError('[SPOTX][renderer] Error:' + err.message); + } + } +} + +function createScriptAttributeMap(bid) { + const slot = getBidIdParameter('slot', bid.renderer.config.outstream_options); + logMessage('[SPOTX][renderer] Handle SpotX outstream renderer'); let dataSpotXParams = {}; dataSpotXParams['data-spotx_channel_id'] = '' + bid.channel_id; dataSpotXParams['data-spotx_vast_url'] = '' + bid.vastUrl; @@ -437,6 +477,7 @@ function createOutstreamScript(bid) { dataSpotXParams['data-spotx_autoplay'] = '1'; dataSpotXParams['data-spotx_blocked_autoplay_override_mode'] = '1'; dataSpotXParams['data-spotx_video_slot_can_autoplay'] = '1'; + dataSpotXParams['data-spotx_content_container_id'] = slot; const playersizeAutoAdapt = getBidIdParameter('playersize_auto_adapt', bid.renderer.config.outstream_options); if (playersizeAutoAdapt && isBoolean(playersizeAutoAdapt) && playersizeAutoAdapt === true) { @@ -475,42 +516,7 @@ function createOutstreamScript(bid) { } } } - - for (let key in dataSpotXParams) { - if (dataSpotXParams.hasOwnProperty(key)) { - script.setAttribute(key, dataSpotXParams[key]); - } - } - - return script; -} - -function outstreamRender(bid) { - const script = createOutstreamScript(bid); - if (bid.renderer.config.outstream_function != null && typeof bid.renderer.config.outstream_function === 'function') { - bid.renderer.config.outstream_function(bid, script); - } else { - try { - const inIframe = getBidIdParameter('in_iframe', bid.renderer.config.outstream_options); - if (inIframe && window.document.getElementById(inIframe).nodeName == 'IFRAME') { - const rawframe = window.document.getElementById(inIframe); - let framedoc = rawframe.contentDocument; - if (!framedoc && rawframe.contentWindow) { - framedoc = rawframe.contentWindow.document; - } - framedoc.body.appendChild(script); - } else { - const slot = getBidIdParameter('slot', bid.renderer.config.outstream_options); - if (slot && window.document.getElementById(slot)) { - window.document.getElementById(slot).appendChild(script); - } else { - window.document.getElementsByTagName('head')[0].appendChild(script); - } - } - } catch (err) { - logError('[SPOTX][renderer] Error:' + err.message) - } - } + return dataSpotXParams; } registerBidder(spec); diff --git a/modules/ssmasBidAdapter.js b/modules/ssmasBidAdapter.js new file mode 100644 index 00000000000..0b70a80e757 --- /dev/null +++ b/modules/ssmasBidAdapter.js @@ -0,0 +1,133 @@ +import { BANNER } from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { triggerPixel, deepSetValue } from '../src/utils.js'; +import { ortbConverter } from '../libraries/ortbConverter/converter.js'; +import {config} from '../src/config.js'; + +export const SSMAS_CODE = 'ssmas'; +const SSMAS_SERVER = 'ads.ssmas.com'; +export const SSMAS_ENDPOINT = `https://${SSMAS_SERVER}/ortb`; +const SYNC_URL = `https://sync.ssmas.com/user_sync`; +export const SSMAS_REQUEST_METHOD = 'POST'; +const GDPR_VENDOR_ID = 1183; + +export const ssmasOrtbConverter = ortbConverter({ + context: { + netRevenue: true, + ttl: 300, + mediaType: BANNER, + }, + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + deepSetValue(imp, 'ext.placementId', bidRequest.params.placementId); + return imp; + }, +}); + +export const spec = { + code: SSMAS_CODE, + supportedMediaTypes: [BANNER], + gvlid: GDPR_VENDOR_ID, + + isBidRequestValid: (bid) => { + return !!bid.params.placementId && !!bid.bidId && bid.bidder === SSMAS_CODE; + }, + + buildRequests: (bidRequests, bidderRequest) => { + const data = ssmasOrtbConverter.toORTB({ bidRequests, bidderRequest }); + + const options = { + contentType: 'application/json', + withCredentials: false, + }; + + data.imp && data.imp.forEach(imp => { + if (imp.ext && imp.ext.placementId) { + imp.tagId = imp.ext.placementId; + } + }); + + data.regs = data.regs || {}; + data.regs.ext = data.regs.ext || {}; + + if (bidderRequest.gdprConsent) { + data.regs.ext.consent = bidderRequest.gdprConsent.consentString; + data.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + } + if (bidderRequest.uspConsent) { + data.regs.ext.consent = bidderRequest.uspConsent.consentString; + data.regs.ext.ccpa = 1; + } + if (config.getConfig('coppa') === true) { + data.regs.coppa = 1; + } + + return [ + { + method: SSMAS_REQUEST_METHOD, + url: SSMAS_ENDPOINT, + data, + options, + }, + ]; + }, + + interpretResponse: (serverResponse, bidRequest) => { + const bids = ssmasOrtbConverter.fromORTB({ + response: serverResponse.body, + request: bidRequest.data, + }).bids; + + return bids.filter((bid) => { + return bid.cpm > 0; + }); + }, + + onBidWon: (bid) => { + if (bid.burl) { + triggerPixel(bid.burl); + } + }, + + getUserSyncs: ( + syncOptions, + serverResponses, + gdprConsent, + uspConsent + ) => { + const syncs = []; + + let params = ['pbjs=1']; + + if (gdprConsent) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + params.push(`gdpr=${Boolean(gdprConsent.gdprApplies)}&gdpr_consent=${ + gdprConsent.consentString + }`); + } else { + params.push(`gdpr_consent=${gdprConsent.consentString}`); + } + } + + if (uspConsent && uspConsent.consentString) { + params.push(`ccpa_consent=${uspConsent.consentString}`); + } + + if (syncOptions.iframeEnabled && serverResponses.length > 0) { + syncs.push({ + type: 'iframe', + url: `${SYNC_URL}/iframe?${params.join('&')}` + }); + } + + // if (syncOptions.pixelEnabled && serverResponses.length > 0) { + // syncs.push({ + // type: 'image', + // url: `${SYNC_URL}/image?${params.join('&')}` + // }); + // } + return syncs; + }, +}; + +registerBidder(spec); diff --git a/modules/ssmasBidAdapter.md b/modules/ssmasBidAdapter.md new file mode 100644 index 00000000000..1b15764a54d --- /dev/null +++ b/modules/ssmasBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +Module Name: SSMas Bidder Adapter +Module Type: Bidder Adapter +Maintainer: hzchen.work@gmail.com + +# Description + +Module that connects to Sem Seo & Mas header bidding endpoint to fetch bids. +Supports Banner +Supported currencies: EUR + +Required parameters: +- placement id + +# Test Parameters +``` +var adUnits = [ + // Banner adUnit + { + code: 'banner-div', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bids: [{ + bidder: 'ssmas', + params: { + placementId: "10336" + } + }] + } +]; +``` diff --git a/modules/sspBCBidAdapter.js b/modules/sspBCBidAdapter.js index e46073a63ba..2b39faa02d8 100644 --- a/modules/sspBCBidAdapter.js +++ b/modules/sspBCBidAdapter.js @@ -1,25 +1,90 @@ -import {deepAccess, isArray, logWarn, parseUrl} from '../src/utils.js'; -import {ajax} from '../src/ajax.js'; -import {registerBidder} from '../src/adapters/bidderFactory.js'; -import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js'; -import {includes as strIncludes} from '../src/polyfill.js'; +import { deepAccess, getWindowTop, isArray, logWarn } from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; +import { config } from '../src/config.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { includes as strIncludes } from '../src/polyfill.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; const BIDDER_CODE = 'sspBC'; const BIDDER_URL = 'https://ssp.wp.pl/bidder/'; const SYNC_URL = 'https://ssp.wp.pl/bidder/usersync'; const NOTIFY_URL = 'https://ssp.wp.pl/bidder/notify'; -const TRACKER_URL = 'https://bdr.wpcdn.pl/tag/jstracker.js'; const GVLID = 676; const TMAX = 450; -const BIDDER_VERSION = '5.41'; +const BIDDER_VERSION = '5.91'; +const DEFAULT_CURRENCY = 'PLN'; const W = window; const { navigator } = W; const oneCodeDetection = {}; const adUnitsCalled = {}; const adSizesCalled = {}; +const bidderRequestsMap = {}; const pageView = {}; var consentApiVersion; +/** + * Native asset mapping - we use constant id per type + * id > 10 indicates additional images + */ +var nativeAssetMap = { + title: 0, + cta: 1, + icon: 2, + image: 3, + body: 4, + sponsoredBy: 5 +}; + +/** + * return native asset type, based on asset id + * @param {int} id - native asset id + * @returns {string} asset type + */ +const getNativeAssetType = id => { + // id>10 will always be an image... + if (id > 10) { + return 'image'; + } + + // ...others should be decoded from nativeAssetMap + for (let assetName in nativeAssetMap) { + const assetId = nativeAssetMap[assetName]; + if (assetId === id) { + return assetName; + } + } +} + +/** + * Get preferred language of browser (i.e. user) + * @returns {string} languageCode - ISO language code + */ +const getBrowserLanguage = () => navigator.language || (navigator.languages && navigator.languages[0]); + +/** + * Get language of top level html object + * @returns {string} languageCode - ISO language code + */ +const getContentLanguage = () => { + try { + const topWindow = getWindowTop(); + return topWindow.document.body.parentNode.lang; + } catch (err) { + logWarn('Could not read language form top-level html', err); + } +}; + +/** + * Get Bid parameters - returns bid params from Object, or 1el array + * @param {*} bidData - bid (bidWon), or array of bids (timeout) + * @returns {object} params object + */ +const unpackParams = (bidParams) => { + const result = isArray(bidParams) ? bidParams[0] : bidParams; + return result || {}; +} + /** * Get bid parameters for notification * @param {*} bidData - bid (bidWon), or array of bids (timeout) @@ -28,51 +93,56 @@ const getNotificationPayload = bidData => { if (bidData) { const bids = isArray(bidData) ? bidData : [bidData]; if (bids.length > 0) { - const result = { - requestId: undefined, + let result = { siteId: [], slotId: [], tagid: [], } bids.forEach(bid => { - let params = isArray(bid.params) ? bid.params[0] : bid.params; - params = params || {}; + const { adUnitCode, cpm, creativeId, meta, mediaType, params: bidParams, bidderRequestId, requestId, timeout } = bid; + const params = unpackParams(bidParams); + + // basic notification data + const bidBasicData = { + requestId: bidderRequestId || bidderRequestsMap[requestId], + timeout: timeout || result.timeout, + pvid: pageView.id, + } + result = { ...result, ...bidBasicData } + + result.tagid.push(adUnitCode); // check for stored detection - if (oneCodeDetection[bid.requestId]) { - params.siteId = oneCodeDetection[bid.requestId][0]; - params.id = oneCodeDetection[bid.requestId][1]; + if (oneCodeDetection[requestId]) { + params.siteId = oneCodeDetection[requestId][0]; + params.id = oneCodeDetection[requestId][1]; } - if (params.siteId) { result.siteId.push(params.siteId); } if (params.id) { result.slotId.push(params.id); } - if (bid.cpm) { - const meta = bid.meta || {}; - result.cpm = bid.cpm; - result.creativeId = bid.creativeId; - result.adomain = meta.advertiserDomains && meta.advertiserDomains[0]; - result.networkName = meta.networkName; + + if (cpm) { + // non-empty bid data + const { advertiserDomains = [], networkName, pricepl } = meta; + const bidNonEmptyData = { + cpm, + cpmpl: pricepl, + creativeId, + adomain: advertiserDomains[0], + adtype: mediaType, + networkName, + } + result = { ...result, ...bidNonEmptyData } } - result.tagid.push(bid.adUnitCode); - result.requestId = bid.auctionId || result.requestId; - result.timeout = bid.timeout || result.timeout; }) return result; } } } -const cookieSupport = () => { - const isSafari = /^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent); - const useCookies = navigator.cookieEnabled || !!document.cookie.length; - - return !isSafari && useCookies; -}; - const applyClientHints = ortbRequest => { const { location } = document; const { connection = {}, deviceMemory, userAgentData = {} } = navigator; @@ -97,7 +167,7 @@ const applyClientHints = ortbRequest => { */ if (!pageView.id || location.pathname !== pageView.path) { pageView.path = location.pathname; - pageView.id = Math.floor(1E20 * Math.random()); + pageView.id = Math.floor(1E20 * Math.random()).toString(); } Object.keys(hints).forEach(key => { @@ -120,7 +190,7 @@ const applyClientHints = ortbRequest => { name: 'pvid', segment: [ { - value: `${pageView.id}` + value: pageView.id } ] }]; @@ -129,6 +199,22 @@ const applyClientHints = ortbRequest => { ortbRequest.user = { ...ortbRequest.user, ...ch }; }; +const applyTopics = (validBidRequest, ortbRequest) => { + const userData = validBidRequest.ortb2?.user?.data || []; + const topicsData = userData.filter(dataObj => { + const segtax = dataObj.ext?.segtax; + return segtax >= 600 && segtax <= 609; + })[0]; + + // format topics obj for exchange + if (topicsData) { + topicsData.id = `${topicsData.ext.segtax}`; + topicsData.name = 'topics'; + delete (topicsData.ext); + ortbRequest.user.data.push(topicsData); + } +}; + const applyUserIds = (validBidRequest, ortbRequest) => { const eids = validBidRequest.userIdAsEids if (eids && eids.length) { @@ -151,6 +237,52 @@ const applyGdpr = (bidderRequest, ortbRequest) => { } } +/** + * Get highest floorprice for a given adslot + * (sspBC adapter accepts one floor per imp) + * returns floor = 0 if getFloor() is not defined + * + * @param {object} slot bid request adslot + * @returns {float} floorprice + */ +const getHighestFloor = (slot) => { + const currency = getCurrency(); + let result = { floor: 0, currency }; + + if (typeof slot.getFloor === 'function') { + let bannerFloor = 0; + + if (slot.sizes.length) { + bannerFloor = slot.sizes.reduce(function (prev, next) { + const { floor: currentFloor = 0 } = slot.getFloor({ + mediaType: 'banner', + size: next, + currency + }); + return prev > currentFloor ? prev : currentFloor; + }, 0); + } + + const { floor: nativeFloor = 0 } = slot.getFloor({ + mediaType: 'native', currency + }); + + const { floor: videoFloor = 0 } = slot.getFloor({ + mediaType: 'video', currency + }); + + result.floor = Math.max(bannerFloor, nativeFloor, videoFloor); + } + + return result; +}; + +/** + * Get currency (either default or adserver) + * @returns {string} currency name + */ +const getCurrency = () => config.getConfig('currency.adServerCurrency') || DEFAULT_CURRENCY; + /** * Get value for first occurence of key within the collection */ @@ -193,79 +325,120 @@ const mapBanner = slot => { * @param {object} paramValue Native parameter value * @returns {object} native asset object that conforms to ortb native ads spec */ -const mapAsset = (paramName, paramValue) => { - let asset; - switch (paramName) { - case 'title': - asset = { - id: 0, - required: paramValue.required, - title: { len: paramValue.len } - } - break; - case 'cta': - asset = { - id: 1, - required: paramValue.required, - data: { type: 12 } - } - break; - case 'icon': - asset = { - id: 2, - required: paramValue.required, - img: { type: 1, w: paramValue.sizes[0], h: paramValue.sizes[1] } - } - break; - case 'image': - asset = { - id: 3, - required: paramValue.required, - img: { type: 3, w: paramValue.sizes[0], h: paramValue.sizes[1] } - } - break; - case 'body': - asset = { - id: 4, - required: paramValue.required, - data: { type: 2 } - } - break; - case 'sponsoredBy': - asset = { - id: 5, - required: paramValue.required, - data: { type: 1 } - } - break; +var mapAsset = function mapAsset(paramName, paramValue) { + const { required, sizes, wmin, hmin, len } = paramValue; + var id = nativeAssetMap[paramName]; + var assets = []; + + if (id !== undefined) { + switch (paramName) { + case 'title': + assets.push({ + id: id, + required: required, + title: { + len: len + } + }); + break; + + case 'cta': + assets.push({ + id: id, + required: required, + data: { + type: 12 + } + }); + break; + + case 'icon': + assets.push({ + id: id, + required: required, + img: { + type: 1, + w: sizes && sizes[0], + h: sizes && sizes[1] + } + }); + break; + + case 'image': + var hasMultipleImages = sizes && Array.isArray(sizes[0]); + var imageSizes = hasMultipleImages ? sizes : [sizes]; + + for (var i = 0; i < imageSizes.length; i++) { + assets.push({ + id: i > 0 ? 10 + i : id, + required: required, + img: { + type: 3, + w: imageSizes[i][0], + h: imageSizes[i][1], + wmin: wmin, + hmin: hmin + } + }); + } + + break; + + case 'body': + assets.push({ + id: id, + required: required, + data: { + type: 2 + } + }); + break; + + case 'sponsoredBy': + assets.push({ + id: id, + required: required, + data: { + type: 1 + } + }); + break; + } } - return asset; -} + + return assets; +}; /** * @param {object} slot Ad Unit Params by Prebid * @returns {object} native object that conforms to ortb native ads spec */ -const mapNative = slot => { +const mapNative = (slot) => { const native = deepAccess(slot, 'mediaTypes.native'); - let assets; if (native) { - const nativeParams = Object.keys(native); - assets = []; - nativeParams.forEach(par => { - const newAsset = mapAsset(par, native[par]); - if (newAsset) { assets.push(newAsset) }; + var nativeParams = Object.keys(native); + var assets = []; + nativeParams.forEach(function (par) { + var newAssets = mapAsset(par, native[par]); + assets = assets.concat(newAssets); }); + return { + request: JSON.stringify({ + native: { + assets: assets + } + }) + }; } - return assets ? { request: JSON.stringify({ native: { assets } }) } : undefined; } -var mapVideo = slot => { - var video = deepAccess(slot, 'mediaTypes.video'); - var videoParamsUsed = ['api', 'context', 'linearity', 'maxduration', 'mimes', 'protocols']; +var mapVideo = (slot, videoFromBid) => { + var videoFromSlot = deepAccess(slot, 'mediaTypes.video'); + var videoParamsUsed = ['api', 'context', 'linearity', 'maxduration', 'mimes', 'protocols', 'playbackmethod']; var videoAssets; - if (video) { + if (videoFromSlot) { + const video = videoFromBid ? Object.assign(videoFromSlot, videoFromBid) : videoFromSlot; var videoParams = Object.keys(video); var playerSize = video.playerSize; videoAssets = {}; // player width / height @@ -291,10 +464,15 @@ var mapVideo = slot => { }; const mapImpression = slot => { - const { adUnitCode, bidId, params = {}, ortb2Imp = {} } = slot; - const { id, siteId } = params; + const { adUnitCode, bidderRequestId, bidId, params = {}, ortb2Imp = {} } = slot; + const { id, siteId, video } = params; const { ext = {} } = ortb2Imp; + /* + store bidId <-> bidderRequestId mapping for bidWon notification + */ + bidderRequestsMap[bidId] = bidderRequestId; + /* check max size for this imp, and check/store number this size was called (for current view) send this info as ext.pbsize @@ -304,7 +482,7 @@ const mapImpression = slot => { if (!adUnitsCalled[adUnitCode]) { // this is a new adunit - assign & save pbsize adSizesCalled[slotSize] = adSizesCalled[slotSize] ? adSizesCalled[slotSize] += 1 : 1; - adUnitsCalled[adUnitCode] = `${slotSize}_${adSizesCalled[slotSize]}` + adUnitsCalled[adUnitCode] = `${slotSize}_${adSizesCalled[slotSize]}`; } ext.data = Object.assign({ pbsize: adUnitsCalled[adUnitCode] }, ext.data); @@ -312,36 +490,18 @@ const mapImpression = slot => { const imp = { id: id && siteId ? id.padStart(3, '0') : 'bidid-' + bidId, banner: mapBanner(slot), - native: mapNative(slot), - video: mapVideo(slot), + native: mapNative(slot, bidId), + video: mapVideo(slot, video), tagid: adUnitCode, ext, }; // Check floorprices for this imp - if (typeof slot.getFloor === 'function') { - var bannerFloor = 0; - var nativeFloor = 0; - var videoFloor = 0; // sspBC adapter accepts only floor per imp - check for maximum value for requested ad types and sizes + const { floor, currency } = getHighestFloor(slot); - if (slot.sizes.length) { - bannerFloor = slot.sizes.reduce(function (prev, next) { - var currentFloor = slot.getFloor({ - mediaType: 'banner', - size: next - }).floor; - return prev > currentFloor ? prev : currentFloor; - }, 0); - } + imp.bidfloor = floor; + imp.bidfloorcur = currency; - nativeFloor = slot.getFloor({ - mediaType: 'native' - }); - videoFloor = slot.getFloor({ - mediaType: 'video' - }); - imp.bidfloor = Math.max(bannerFloor, nativeFloor, videoFloor); - } return imp; } @@ -356,50 +516,56 @@ const isNativeAd = bid => { return bid.admNative || (bid.adm && bid.adm.match(xmlTester)); } -const parseNative = nativeData => { - const result = {}; - nativeData.assets.forEach(asset => { - const id = parseInt(asset.id); - switch (id) { - case 0: - result.title = asset.title.text; - break; - case 1: - result.cta = asset.data.value; - break; - case 2: - result.icon = { - url: asset.img.url, - width: asset.img.w, - height: asset.img.h, - }; - break; - case 3: - result.image = { - url: asset.img.url, - width: asset.img.w, - height: asset.img.h, - }; - break; - case 4: - result.body = asset.data.value; - break; - case 5: - result.sponsoredBy = asset.data.value; - break; +const parseNative = (nativeData, adUnitCode) => { + const { link = {}, imptrackers: impressionTrackers, jstracker } = nativeData; + const { url: clickUrl, clicktrackers: clickTrackers = [] } = link; + const macroReplacer = tracker => tracker.replace(new RegExp('%native_dom_id%', 'g'), adUnitCode); + let javascriptTrackers = isArray(jstracker) ? jstracker : jstracker && [jstracker]; - default: - logWarn('Unrecognized native asset', asset); + // replace known macros in js trackers + javascriptTrackers = javascriptTrackers && javascriptTrackers.map(macroReplacer); + + const result = { + clickUrl, + clickTrackers, + impressionTrackers, + javascriptTrackers, + }; + + nativeData.assets.forEach(asset => { + const { id, img = {}, title = {}, data = {} } = asset; + const { w: imgWidth, h: imgHeight, url: imgUrl, type: imgType } = img; + const { type: dataType, value: dataValue } = data; + const { text: titleText } = title; + const detectedType = getNativeAssetType(id); + if (titleText) { + result.title = titleText; + } + if (imgUrl) { + // image or icon + const thisImage = { + url: imgUrl, + width: imgWidth, + height: imgHeight, + }; + if (imgType === 3 || detectedType === 'image') { + result.image = thisImage; + } else if (imgType === 1 || detectedType === 'icon') { + result.icon = thisImage; + } + } + if (dataValue) { + // call-to-action, sponsored-by or body + if (dataType === 1 || detectedType === 'sponsoredBy') { + result.sponsoredBy = dataValue; + } else if (dataType === 2 || detectedType === 'body') { + result.body = dataValue; + } else if (dataType === 12 || detectedType === 'cta') { + result.cta = dataValue; + } } }); - result.clickUrl = nativeData.link.url; - result.impressionTrackers = nativeData.imptrackers; - if (isArray(nativeData.jstracker)) { - result.javascriptTrackers = nativeData.jstracker; - } else if (nativeData.jstracker) { - result.javascriptTrackers = [nativeData.jstracker]; - } return result; } @@ -463,13 +629,15 @@ const renderCreative = (site, auctionId, bid, seat, request) => { window.ref = "${site.ref}"; window.adlabel = "${site.adLabel ? site.adLabel : ''}"; window.pubid = "${site.publisherId ? site.publisherId : ''}"; + window.requestPVID = "${pageView.id}"; `; adcode += `
- + + `; @@ -486,48 +654,55 @@ const spec = { return true; }, buildRequests(validBidRequests, bidderRequest) { + logWarn('DEBUG: buildRequests', bidderRequest.auctionId, bidderRequest.bidderRequestId); + + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + if ((!validBidRequests) || (validBidRequests.length < 1)) { return false; } const siteId = setOnAny(validBidRequests, 'params.siteId'); const publisherId = setOnAny(validBidRequests, 'params.publisherId'); - const page = setOnAny(validBidRequests, 'params.page') || bidderRequest.refererInfo.referer; - const domain = setOnAny(validBidRequests, 'params.domain') || parseUrl(page).hostname; + const page = setOnAny(validBidRequests, 'params.page') || bidderRequest.refererInfo.page; + const domain = setOnAny(validBidRequests, 'params.domain') || bidderRequest.refererInfo.domain; const tmax = setOnAny(validBidRequests, 'params.tmax') ? parseInt(setOnAny(validBidRequests, 'params.tmax'), 10) : TMAX; const pbver = '$prebid.version$'; const testMode = setOnAny(validBidRequests, 'params.test') ? 1 : undefined; - - let ref; - - try { - if (W.self === W.top && document.referrer) { ref = document.referrer; } - } catch (e) { - } + const ref = bidderRequest.refererInfo.ref; const payload = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, site: { - id: siteId, + id: siteId ? `${siteId}` : undefined, publisher: publisherId ? { id: publisherId } : undefined, page, domain, - ref + ref, + content: { language: getContentLanguage() }, }, imp: validBidRequests.map(slot => mapImpression(slot)), + cur: [getCurrency()], tmax, user: {}, regs: {}, + device: { + language: getBrowserLanguage(), + w: screen.width, + h: screen.height, + }, test: testMode, }; applyGdpr(bidderRequest, payload); applyClientHints(payload); applyUserIds(validBidRequests[0], payload); + applyTopics(bidderRequest, payload); return { method: 'POST', - url: `${BIDDER_URL}?cs=${cookieSupport()}&bdver=${BIDDER_VERSION}&pbver=${pbver}&inver=0`, + url: `${BIDDER_URL}?bdver=${BIDDER_VERSION}&pbver=${pbver}&inver=0`, data: JSON.stringify(payload), bidderRequest, }; @@ -537,8 +712,9 @@ const spec = { const { bidderRequest } = request; const response = serverResponse.body; const bids = []; - const site = JSON.parse(request.data).site; // get page and referer data from request + let site = JSON.parse(request.data).site; // get page and referer data from request site.sn = response.sn || 'mc_adapter'; // WPM site name (wp_sn) + pageView.sn = site.sn; // store site_name (for syncing and notifications) let seat; if (response.seatbid !== undefined) { @@ -550,37 +726,36 @@ const spec = { seat = seatbid.seat; seatbid.bid.forEach(serverBid => { // get data from bid response - const { adomain, crid = `mcad_${bidderRequest.auctionId}_${site.slot}`, impid, exp = 300, ext, price, w, h } = serverBid; + const { adomain, crid = `mcad_${bidderRequest.auctionId}_${site.slot}`, impid, exp = 300, ext = {}, price, w, h } = serverBid; const bidRequest = bidderRequest.bids.filter(b => { - const { bidId, params = {} } = b; + const { bidId, params: requestParams = {} } = b; + const params = unpackParams(requestParams); const { id, siteId } = params; const currentBidId = id && siteId ? id : 'bidid-' + bidId; return currentBidId === impid; })[0]; - // get data from linked bidRequest - const { bidId, params } = bidRequest || {}; + // get bidid from linked bidRequest + const { bidId } = bidRequest || {}; - // get slot id for current bid - site.slot = params && params.id; + // get ext data from bid + const { siteid = site.id, slotid = site.slot, pubid, adlabel, cache: creativeCache, vurls = [] } = ext; - if (ext) { - /* - bid response might include ext object containing siteId / slotId, as detected by OneCode - update site / slot data in this case - - ext also might contain publisherId and custom ad label - */ - const { siteid, slotid, pubid, adlabel } = ext; - site.id = siteid || site.id; - site.slot = slotid || site.slot; - site.publisherId = pubid; - site.adLabel = adlabel; - } + // update site data + site = { + ...site, + ...{ + id: siteid, + slot: slotid, + publisherId: pubid, + adLabel: adlabel + } + }; if (bidRequest && site.id && !strIncludes(site.id, 'bidid')) { // found a matching request; add this bid + const { adUnitCode } = bidRequest; // store site data for future notification oneCodeDetection[bidId] = [site.id, site.slot]; @@ -593,12 +768,13 @@ const spec = { ttl: exp, width: w, height: h, - bidderCode: BIDDER_CODE, meta: { advertiserDomains: adomain, networkName: seat, + pricepl: ext && ext.pricepl, }, netRevenue: true, + vurls, }; // mediaType and ad data for instream / native / banner @@ -608,33 +784,16 @@ const spec = { bid.mediaType = 'video'; bid.vastXml = serverBid.adm; bid.vastContent = serverBid.adm; + bid.vastUrl = creativeCache; } else if (isNativeAd(serverBid)) { // native bid.mediaType = 'native'; // check native object try { const nativeData = serverBid.admNative || JSON.parse(serverBid.adm).native; - bid.native = parseNative(nativeData); + bid.native = parseNative(nativeData, adUnitCode); bid.width = 1; bid.height = 1; - - // append viewability tracker - const jsData = { - rid: bidRequest.auctionId, - crid: bid.creativeId, - adunit: bidRequest.adUnitCode, - url: bid.native.clickUrl, - vendor: seat, - site: site.id, - slot: site.slot, - cpm: bid.cpm.toPrecision(4), - } - const jsTracker = ' + +``` diff --git a/modules/videojsVideoProvider.js b/modules/videojsVideoProvider.js new file mode 100644 index 00000000000..7764e8af995 --- /dev/null +++ b/modules/videojsVideoProvider.js @@ -0,0 +1,863 @@ +import { + SETUP_COMPLETE, SETUP_FAILED, DESTROYED, + PLAYLIST, PLAYBACK_REQUEST, CONTENT_LOADED, PLAY, PAUSE, TIME, SEEK_START, SEEK_END, MUTE, VOLUME, ERROR, COMPLETE, + FULLSCREEN, PLAYER_RESIZE, + AD_REQUEST, AD_IMPRESSION, AD_TIME, AD_COMPLETE, AD_SKIPPED, AD_CLICK, AD_STARTED, AD_ERROR, AD_LOADED, AD_PLAY, AD_PAUSE +} from '../libraries/video/constants/events.js'; +// missing events: , AD_BREAK_START, , AD_BREAK_END, VIEWABLE, BUFFER, CAST, PLAYLIST_COMPLETE, RENDITION_UPDATE, PLAY_ATTEMPT_FAILED, AUTOSTART_BLOCKED +import { + PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE, AD_POSITION, PLAYBACK_END +} from '../libraries/video/constants/ortb.js'; +import { VIDEO_JS_VENDOR } from '../libraries/video/constants/vendorCodes.js'; +import { submodule } from '../src/hook.js'; +import stateFactory from '../libraries/video/shared/state.js'; +import { PLAYBACK_MODE } from '../libraries/video/constants/constants.js'; +import { getEventHandler } from '../libraries/video/shared/eventHandler.js'; + +/* +Plugins of interest: +https://www.npmjs.com/package/videojs-chromecast +https://www.npmjs.com/package/@silvermine/videojs-airplay +https://www.npmjs.com/package/videojs-airplay +https://www.npmjs.com/package/@silvermine/videojs-chromecast +https://www.npmjs.com/package/videojs-ima +https://github.com/googleads/videojs-ima +https://github.com/videojs/videojs-playlist +https://github.com/videojs/videojs-contrib-ads +https://github.com/videojs/videojs-errors +https://github.com/videojs/videojs-overlay +https://github.com/videojs/videojs-playlist-ui + +inspiration: +https://github.com/Conviva/conviva-js-videojs/blob/master/conviva-videojs-module.js + */ + +const setupFailMessage = 'Failed to instantiate the player'; +const AD_MANAGER_EVENTS = [AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, AD_PAUSE, AD_TIME, AD_COMPLETE, AD_SKIPPED]; + +export function VideojsProvider(providerConfig, vjs_, adState_, timeState_, callbackStorage_, utils) { + let vjs = vjs_; + // Supplied callbacks are typically wrapped by handlers + // we use this dict to keep track of these pairings + const callbackToHandler = {}; + + const adState = adState_; + const timeState = timeState_; + let player = null; + let playerVersion = null; + let playerIsSetup = false; + const {playerConfig, divId} = providerConfig; + let isMuted; + let previousLastTimePosition = 0; + let lastTimePosition = 0; + + let setupCompleteCallbacks = []; + let setupFailedCallbacks = []; + let setupFailedEventHandlers = []; + + // TODO: test with older videojs versions + let minimumSupportedPlayerVersion = '7.17.0'; + + function init() { + if (!vjs) { + triggerSetupFailure(-1, setupFailMessage + ': Videojs not present') + return; + } + + playerVersion = vjs.VERSION; + if (playerVersion < minimumSupportedPlayerVersion) { + triggerSetupFailure(-2, setupFailMessage + ': Videojs version not supported'); + return; + } + + if (!document.getElementById(divId)) { + triggerSetupFailure(-3, setupFailMessage + ': No div found with id ' + divId); + return; + } + + const instantiatedPlayers = vjs.players; + if (instantiatedPlayers && instantiatedPlayers[divId]) { + // already instantiated + player = instantiatedPlayers[divId]; + onReady(); + return; + } + + setupPlayer(playerConfig); + + if (!player) { + triggerSetupFailure(-4, setupFailMessage); + } + } + + function getId() { + return divId; + } + + function getOrtbVideo() { + if (!player) { + return; + } + + let playBackMethod = PLAYBACK_METHODS.CLICK_TO_PLAY; + // returns a boolean or a string with the autoplay strategy + const autoplay = player.autoplay(); + const muted = player.muted() || autoplay === 'muted'; + // check if autoplay is truthy since it may be a bool or string + if (autoplay) { + playBackMethod = muted ? PLAYBACK_METHODS.AUTOPLAY_MUTED : PLAYBACK_METHODS.AUTOPLAY; + } + const supportedMediaTypes = Object.values(VIDEO_MIME_TYPE).filter( + // Follows w3 spec https://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-navigator-canplaytype + type => player.canPlayType(type) !== '' + ) + + // IMA supports vpaid unless its expliclty turned off + // TODO: needs a reference to the imaOptions used at setup to determine if vpaid can be used + // if (imaOptions && imaOptions.vpaidMode !== 0) { + supportedMediaTypes.push(VPAID_MIME_TYPE); + // } + + const video = { + mimes: supportedMediaTypes, + // Based on the protocol support provided by the videojs-ima plugin + // https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/compatibility + // Need to check for the plugins + protocols: [ + PROTOCOLS.VAST_2_0, + ], + api: [ + API_FRAMEWORKS.VPAID_2_0 // TODO: needs a reference to the imaOptions used at setup to determine if vpaid can be used + ], + // TODO: Make sure this returns dimensions in DIPS + h: player.currentHeight(), + w: player.currentWidth(), + // TODO: implement startdelay since its reccomend param + // both linearity forms are supported so the param is excluded + // sequence - TODO not yet supported + maxextended: -1, + boxingallowed: 1, + playbackmethod: [ playBackMethod ], + playbackend: PLAYBACK_END.VIDEO_COMPLETION, + // Per ortb 7.4 skip is omitted since neither the player nor ima plugin imposes a skip button, or a skipmin/max + }; + + // TODO: Determine placement may not be in stream if videojs is only used to serve ad content + // ~ Sort of resolved check if the player has a source to tell if the placement is instream + // Still cannot reliably check what type of placement the player is if its outstream + // i.e. we can't tell if its interstitial, in article, etc. + if (player.src()) { + video.placement = PLACEMENT.INSTREAM; + } + + // Placement according to IQG Guidelines 4.2.8 + // https://cdn2.hubspot.net/hubfs/2848641/TrustworthyAccountabilityGroup_May2017/Docs/TAG-Inventory-Quality-Guidelines-v2_2-10-18-2016.pdf?t=1509469105938 + const findPosition = vjs.dom.findPosition; + if (player.isFullscreen()) { + video.pos = AD_POSITION.FULL_SCREEN; + } else if (findPosition) { + video.pos = utils.getPositionCode(findPosition(player.el())); + } + + return video; + } + + function getOrtbContent() { + if (!player) { + return; + } + + const content = { + // id:, TODO: find a suitable id for videojs sources + url: player.currentSrc() + }; + // Only include length if player is ready + // player.readyState() returns a level of readiness from 0 to 4 + // https://docs.videojs.com/player#readyState + if (player.readyState()) { + content.len = Math.round(player.duration()); + } + + const mediaItem = utils.getMedia(player); + if (mediaItem) { + for (let param of ['id', 'title', 'description', 'album', 'artist']) { + if (mediaItem[param]) { + content[param] = mediaItem[param]; + } + } + } + + const contentUrl = utils.getValidMediaUrl(mediaItem && mediaItem.src, player.src) + if (contentUrl) { + content.url = contentUrl; + } + + return content; + } + + // Plugins to integrate: https://github.com/googleads/videojs-ima + function setAdTagUrl(adTagUrl, options) { + if (!player.ima || !adTagUrl) { + return; + } + + // The VideoJS IMA plugin version 1.11.0 will throw when the ad is empty. + try { + player.ima.changeAdTag(adTagUrl); + player.ima.requestAds(); + } catch (e) { + /* + Handling is not required; ad errors are emitted automatically by video.js + */ + } + } + + function onEvent(type, callback, payload) { + registerSetupListeners(type, callback, payload); + + if (!player) { + return; + } + + player.ready(() => { + registerListeners(type, callback, payload); + }); + } + + function registerSetupListeners(externalEventName, callback, basePayload) { + // no point in registering for setup failures if already setup. + if (playerIsSetup) { + return; + } + + if (externalEventName === SETUP_COMPLETE) { + setupCompleteCallbacks.push(callback); + } else if (externalEventName === SETUP_FAILED) { + setupFailedCallbacks.push(callback); + registerSetupErrorListener() + } + } + + function registerSetupErrorListener() { + if (!player) { + return + } + + const eventHandler = () => { + /* + Videojs has no specific setup error handler + so we imitate it by hooking to the general error + handler and checking to see if the player has been setup + */ + if (playerIsSetup) { + return; + } + + const error = player.error(); + triggerSetupFailure(error.code, error.message, error); + }; + + player.on(ERROR, eventHandler); + setupFailedEventHandlers.push(eventHandler) + } + + function registerListeners(externalEventName, callback, basePayload) { + if (externalEventName === MUTE) { + const eventHandler = () => { + if (isMuted !== player.muted()) { + basePayload.mute = isMuted = !isMuted; + callback(externalEventName, basePayload); + } + }; + player.on(utils.getVideojsEventName(VOLUME), eventHandler); + return; + } + + let getEventPayload; + + switch (externalEventName) { + case PLAY: + case PAUSE: + case DESTROYED: + break; + + case PLAYBACK_REQUEST: + getEventPayload = e => ({ playReason: 'unknown' }); + break; + + case AD_REQUEST: + getEventPayload = e => { + const adTagUrl = e.AdsRequest.adTagUrl; + adState.updateState({ adTagUrl }); + return { adTagUrl }; + }; + break + + case AD_LOADED: + getEventPayload = (e) => { + const imaAd = e.getAdData && e.getAdData(); + adState.updateForEvent(imaAd); + timeState.clearState(); + return adState.getState(); + }; + break + + case AD_STARTED: + case AD_PLAY: + case AD_PAUSE: + getEventPayload = () => adState.getState(); + break + + case AD_IMPRESSION: + case AD_CLICK: + getEventPayload = () => Object.assign({}, adState.getState(), timeState.getState()); + break + + case AD_TIME: + getEventPayload = (e) => { + const adTimeEvent = e && e.getAdData && e.getAdData(); + timeState.updateForTimeEvent(adTimeEvent); + return Object.assign({}, adState.getState(), timeState.getState()); + }; + break + + case AD_COMPLETE: + getEventPayload = () => { + const currentState = adState.getState(); + adState.clearState(); + return currentState; + }; + break + + case AD_SKIPPED: + getEventPayload = () => { + const currentState = Object.assign({}, adState.getState(), timeState.getState()); + adState.clearState(); + return currentState; + }; + break + + case AD_ERROR: + getEventPayload = e => { + const imaAdError = e.data && e.data.AdError; + const extraPayload = Object.assign({ + playerErrorCode: imaAdError.getErrorCode(), + vastErrorCode: imaAdError.getVastErrorCode(), + errorMessage: imaAdError.getMessage(), + sourceError: imaAdError.getInnerError() + // timeout + }, adState.getState(), timeState.getState()); + adState.clearState(); + return extraPayload; + }; + break + + case PLAYLIST: + getEventPayload = e => ({ + playlistItemCount: utils.getPlaylistCount(player), + autostart: player.autoplay() + }); + break + + case CONTENT_LOADED: + getEventPayload = e => { + const media = utils.getMedia(player); + const contentUrl = utils.getValidMediaUrl(media && media.src, player.src, e && e.target && e.target.currentSrc) + return { + contentId: media && media.id, + contentUrl, + title: media && media.title, + description: media && media.description, + playlistIndex: utils.getCurrentPlaylistIndex(player), + contentTags: media && media.contentTags + }; + }; + break; + + case TIME: + // TODO: might want to check seeking() and/or scrubbing() + getEventPayload = e => { + previousLastTimePosition = lastTimePosition; + const currentTime = player.currentTime(); + const duration = player.duration(); + timeState.updateForTimeEvent({ currentTime, duration }); + lastTimePosition = currentTime; + return { + position: lastTimePosition, + duration + }; + }; + break; + + case SEEK_START: + getEventPayload = e => { + return { + position: previousLastTimePosition, + destination: player.currentTime(), + duration: player.duration() + }; + } + break; + + case SEEK_END: + getEventPayload = () => ({ + position: player.currentTime(), + duration: player.duration() + }); + break; + + case VOLUME: + getEventPayload = e => ({ volumePercentage: player.volume() * 100 }); + break; + + case ERROR: + getEventPayload = e => { + const error = player.error(); + return { + sourceError: error, + errorCode: error.code, + errorMessage: error.message, + }; + }; + break; + + case COMPLETE: + getEventPayload = e => { + previousLastTimePosition = lastTimePosition = 0; + timeState.clearState(); + }; + break; + + case FULLSCREEN: + getEventPayload = e => ({ fullscreen: player.isFullscreen() }); + break; + + case PLAYER_RESIZE: + getEventPayload = e => ({ + height: player.currentHeight(), + width: player.currentWidth(), + }); + break; + + default: + return; + } + + const eventHandler = getEventHandler(externalEventName, callback, basePayload, getEventPayload); + + if (externalEventName === PLAYLIST) { + registerPlaylistEventListener(eventHandler); + return; + } + + const videojsEventName = utils.getVideojsEventName(externalEventName); + + if (AD_MANAGER_EVENTS.includes(externalEventName)) { + player.on('ads-manager', () => player.ima.addEventListener(videojsEventName, eventHandler)); + } else { + player.on(videojsEventName, eventHandler); + } + } + + function registerPlaylistEventListener(eventHandler) { + if (player.playlist) { + // force a playlist event on first item load + player.one('loadstart', eventHandler); + player.on('playlistchange', eventHandler); + } else { + // When playlist plugin is not used, treat each media item as a single item playlist + player.on('loadstart', eventHandler); + } + } + + function offEvent(event, callback) { + const videojsEvent = utils.getVideojsEventName(event) + if (!callback) { + player.off(videojsEvent); + return; + } + + const eventHandler = callbackToHandler[event];// callbackStorage.getCallback(event, callback); + if (eventHandler) { + player.off(videojsEvent, eventHandler); + } + } + + function destroy() { + if (!player) { + return; + } + player.remove(); + player = null; + } + + return { + init, + getId, + getOrtbVideo, + getOrtbContent, + setAdTagUrl, + onEvent, + offEvent, + destroy + }; + + function setupPlayer(config) { + const setupConfig = utils.getSetupConfig(config); + player = vjs(divId, setupConfig, onReady); + } + + function onReady() { + try { + setupAds(); + } catch (e) { + triggerSetupFailure(-5, e.message); + return; + } + triggerSetupComplete(); + } + + // TODO: consider supporting https://www.npmjs.com/package/videojs-vast-vpaid as well + function setupAds() { + if (!player.ima) { + throw new Error(setupFailMessage + ': ima plugin is missing'); + } + + if (typeof player.ima !== 'function') { + // when player.ima is already instantiated, it is an object. Early abort if already instantiated. + return; + } + + const adConfig = utils.getAdConfig(playerConfig); + player.ima(adConfig); + } + + function triggerSetupFailure(errorCode, msg, sourceError) { + const payload = { + divId, + playerVersion, + type: SETUP_FAILED, + errorCode, + errorMessage: msg, + sourceError: sourceError + }; + setupFailedCallbacks.forEach(setupFailedCallback => setupFailedCallback(SETUP_FAILED, payload)); + setupFailedCallbacks = []; + } + + function triggerSetupComplete() { + playerIsSetup = true; + const payload = { + divId, + playerVersion, + type: SETUP_COMPLETE, + }; + + setupCompleteCallbacks.forEach(callback => callback(SETUP_COMPLETE, payload)); + setupCompleteCallbacks = []; + + isMuted = player.muted(); + + setupFailedEventHandlers.forEach(eventHandler => player.off('error', eventHandler)); + setupFailedEventHandlers = []; + } +} + +export const utils = { + getSetupConfig: function (config) { + if (!config) { + return; + } + + const params = config.params || {}; + const videojsConfig = params.vendorConfig || {}; + + if (videojsConfig.autostart === undefined && config.autostart !== undefined) { + videojsConfig.autostart = config.autostart + } + + if (videojsConfig.muted === undefined && config.mute !== undefined) { + videojsConfig.muted = config.mute; + } + + return videojsConfig; + }, + + getAdConfig: function (config) { + const params = config && config.params; + if (!params) { + return {}; + } + + return params.adPluginConfig || {}; // TODO: add adPluginConfig to spec + }, + + getPositionCode: function({left, top, width, height}) { + const bottom = window.innerHeight - top - height; + const right = window.innerWidth - left - width; + + if (left < 0 || right < 0 || top < 0) { + return AD_POSITION.UNKNOWN; + } + + return bottom >= 0 ? AD_POSITION.ABOVE_THE_FOLD : AD_POSITION.BELOW_THE_FOLD; + }, + + getVideojsEventName: function(eventName) { + switch (eventName) { + case SETUP_COMPLETE: + return 'ready'; + case SETUP_FAILED: + return 'error'; + case DESTROYED: + return 'dispose'; + case AD_REQUEST: + return 'ads-request'; + case AD_LOADED: + return 'loaded' + case AD_STARTED: + return 'start'; + case AD_IMPRESSION: + return 'impression'; + case AD_PLAY: + return 'resume' + case AD_PAUSE: + return PAUSE; + case AD_TIME: + return 'adProgress'; + case AD_CLICK: + return 'click'; + case AD_COMPLETE: + return COMPLETE; + case AD_SKIPPED: + return 'skip'; + case AD_ERROR: + return 'adserror'; + case CONTENT_LOADED: + return 'loadstart'; + case ERROR: + return ['error', 'aderror', 'contenterror']; + case PLAY: + return PLAY + 'ing'; + case PLAYBACK_REQUEST: + return PLAY; + case SEEK_START: + return 'seeking'; + case SEEK_END: + return 'seeked'; + case TIME: + return TIME + 'update'; + case VOLUME: + return VOLUME + 'change'; + case MUTE: + return MUTE + 'change'; + case PLAYER_RESIZE: + return 'playerresize'; + case FULLSCREEN: + return FULLSCREEN + 'change'; + case COMPLETE: + return 'ended'; + default: + return eventName; + } + /* + The following video.js events might map to an event in our spec + 'loadstart', + 'progress', buffer load ? + 'suspend', + 'abort', + 'error', + 'emptied', + 'stalled', + 'loadedmetadata', meta + 'loadeddata', meta + 'canplay', + 'canplaythrough', + 'waiting', buffer? + 'durationchange', meta-duration + 'ratechange', + */ + }, + + getMedia: function(player) { + const playlistItem = this.getCurrentPlaylistItem(player); + if (playlistItem) { + return playlistItem.sources[0]; + } + + return player.getMedia(); + }, + + getValidMediaUrl: function(mediaSrc, playerSrc, eventTargetSrc) { + return this.getMediaUrl(mediaSrc) || this.getMediaUrl(playerSrc) || this.getMediaUrl(eventTargetSrc); + }, + + getMediaUrl: function(source) { + if (!source) { + return; + } + + if (Array.isArray(source) && source.length) { + return this.parseSource(source[0]); + } + + return this.parseSource(source) + }, + + parseSource: function (source) { + const type = typeof source; + if (type === 'string') { + return source; + } else if (type === 'object') { + return source.src; + } + }, + + getPlaylistCount: function (player) { + const playlist = player.playlist; // has playlist plugin + if (!playlist) { + return 1; + } + return playlist.lastIndex && playlist.lastIndex() + 1; + }, + + getCurrentPlaylistIndex: function (player) { + const playlist = player.playlist; // has playlist plugin + if (!playlist) { + return 0; + } + return playlist.currentIndex && playlist.currentIndex(); + }, + + getCurrentPlaylistItem: function(player) { + const playlist = player.playlist; // has playlist plugin + if (!playlist) { + return; + } + + const currentIndex = this.getCurrentPlaylistIndex(player); + if (!currentIndex) { + return + } + + const item = playlist()[currentIndex]; + return item; + } +}; + +const videojsSubmoduleFactory = function (config) { + const adState = adStateFactory(); + const timeState = timeStateFactory(); + const callbackStorage = null; + // videojs factory is stored to window by default + const vjs = window.videojs; + return VideojsProvider(config, vjs, adState, timeState, callbackStorage, utils); +} + +videojsSubmoduleFactory.vendorCode = VIDEO_JS_VENDOR; +submodule('video', videojsSubmoduleFactory); +export default videojsSubmoduleFactory; + +// STATE + +/** + * @returns {State} + */ +export function adStateFactory() { + const adState = Object.assign({}, stateFactory()); + + function updateForEvent(event) { + if (!event) { + return; + } + + const skippable = event.skippable; + // TODO: possibly can check traffickingParameters to determine if winning bid is passed + const updates = { + adId: event.adId, + adServer: event.adSystem, + advertiserName: event.advertiserName, + redirectUrl: event.clickThroughUrl, + creativeId: event.creativeId || event.creativeAdId, + dealId: event.dealId, + adDescription: event.description, + linear: event.linear, + creativeUrl: event.mediaUrl, + adTitle: event.title, + universalAdId: event.universalAdIdValue, + creativeType: event.contentType, + wrapperAdIds: event.adWrapperIds, + skip: skippable ? 1 : 0, + // missing fields: + // loadTime + // advertiserId - TODO: does this even exist ? If not, remove from spec + // vastVersion + // adCategories + // campaignId + // waterfallIndex + // waterfallCount + // skipmin + // adTagUrl - for now, only has request ad tag + // adPlacementType + }; + + const adPodInfo = event.adPodInfo; + if (adPodInfo && adPodInfo.podIndex > -1) { + updates.adPodCount = adPodInfo.totalAds; + updates.adPodIndex = adPodInfo.adPosition - 1; // Per IMA docs, adPosition is 1 based. + } + + if (adPodInfo && adPodInfo.timeOffset) { + switch (adPodInfo.timeOffset) { + case -1: + updates.offset = 'post'; + break + + case 0: + // TODO: Defaults to 0 if this ad is not part of a pod, or the pod is not part of an ad playlist. - need to check if loaded dynamically and pass last content time update + updates.offset = 'pre'; + break + + default: + updates.offset = '' + adPodInfo.timeOffset; + } + } + + if (skippable) { + updates.skipafter = event.skipTimeOffset; + } + + this.updateState(updates); + } + + adState.updateForEvent = updateForEvent; + + return adState; +} + +export function timeStateFactory() { + const timeState = Object.assign({}, stateFactory()); + + function updateForTimeEvent(event) { + const { currentTime, duration } = event; + this.updateState({ + time: currentTime, + duration, + playbackMode: getPlaybackMode(duration) + }); + } + + timeState.updateForTimeEvent = updateForTimeEvent; + + function getPlaybackMode(duration) { + if (duration > 0) { + return PLAYBACK_MODE.VOD; + } else if (duration < 0) { + return PLAYBACK_MODE.DVR; + } + + return PLAYBACK_MODE.LIVE; + } + + return timeState; +} diff --git a/modules/videojsVideoProvider.md b/modules/videojsVideoProvider.md new file mode 100644 index 00000000000..70f4daa64e1 --- /dev/null +++ b/modules/videojsVideoProvider.md @@ -0,0 +1,17 @@ +# Overview + +Module Name: Video.js Video Provider +Module Type: Video Submodule +Video Player: video.js +Player website: https://videojs.com/ +Maintainer: Prebid Video Task Force + +# Description + +Video provider to connect the Prebid Video Module to video.js. + +# Requirements + +- Your page must include a build of video.js. For instructions see https://videojs.com/getting-started . +- Your video.js instance must include the Google IMA plugin. + - The Google IMA plugin must be accessible publicly in order for the Video.js Video Provider to reference it. diff --git a/modules/videonowBidAdapter.js b/modules/videonowBidAdapter.js new file mode 100644 index 00000000000..bfbc07fdff1 --- /dev/null +++ b/modules/videonowBidAdapter.js @@ -0,0 +1,122 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {BANNER} from '../src/mediaTypes.js'; +import {_each, getBidIdParameter, getValue, logError, logInfo} from '../src/utils.js'; + +const BIDDER_CODE = 'videonow'; +const RTB_URL = 'https://adx.videonow.ru/yhb' +const DEFAULT_CURRENCY = 'RUB' +const DEFAULT_CODE_TYPE = 'combo' +const TTL_SECONDS = 60 * 5 + +export const spec = { + + code: BIDDER_CODE, + url: RTB_URL, + supportedMediaTypes: [ BANNER ], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bidRequest The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function (bidRequest) { + if (!bidRequest.params) { + return false; + } + + if (!bidRequest.params.pId) { + logError('failed validation: pId not declared'); + return false + } + + return true + }, + + /** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequests[]} validBidRequests - an array of bids + * @param bidderRequest + * @return ServerRequest Info describing the request to the server. + */ + buildRequests: function (validBidRequests, bidderRequest) { + logInfo('validBidRequests', validBidRequests); + + const bidRequests = []; + + _each(validBidRequests, (bid) => { + const bidId = getBidIdParameter('bidId', bid) + const placementId = getValue(bid.params, 'pId') + const currency = getValue(bid.params, 'currency') || DEFAULT_CURRENCY + const url = getValue(bid.params, 'url') || RTB_URL + const codeType = getValue(bid.params, 'codeType') || DEFAULT_CODE_TYPE + const sizes = getValue(bid, 'sizes') + + bidRequests.push({ + method: 'POST', + url, + data: { + places: [ + { + id: bidId, + placementId, + codeType, + sizes + } + ], + settings: { + currency, + } + }, + }) + }) + + return bidRequests; + }, + + /** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @param {BidRequest} bidRequest The bid params + * @return {Bid[]} An array of bids which were nested inside the server. + */ + interpretResponse: function (serverResponse, bidRequest) { + logInfo('serverResponse', serverResponse.body); + + const responsesBody = serverResponse ? serverResponse.body : {}; + const bidResponses = []; + try { + if (!responsesBody?.bids?.length) { + return []; + } + + _each(responsesBody.bids, (bid) => { + if (bid?.displayCode) { + const bidResponse = { + requestId: bid.id, + cpm: bid.cpm, + currency: bid.currency, + width: bid.size.width, + height: bid.size.height, + ad: bid.displayCode, + ttl: TTL_SECONDS, + creativeId: bid.id, + netRevenue: true, + meta: { + advertiserDomains: bid.adDomain ? [bid.adDomain] : [] + } + }; + bidResponses.push(bidResponse) + } + }) + } catch (error) { + logError(error); + } + + return bidResponses + }, +} + +registerBidder(spec); diff --git a/modules/videonowBidAdapter.md b/modules/videonowBidAdapter.md new file mode 100644 index 00000000000..0762880f666 --- /dev/null +++ b/modules/videonowBidAdapter.md @@ -0,0 +1,37 @@ +# Overview + +**Module Name**: Videonow Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: nregularniy@videonow.ru + +# Description + +Videonow Bidder Adapter for Prebid.js. About: https://videonow.ru/ + + +Use `videonow` as bidder: + +# Params +- `pId` required, profile ID +- `currency` optional, currency, default is 'RUB' +- `url` optional, for debug, bidder url +- `codeType` optional, for debug, yhb codeType + +## AdUnits configuration example +``` + var adUnits = [{ + code: 'your-slot', //use exactly the same code as your slot div id. + mediaTypes: { + banner: { + sizes: [[640, 480]] + } + }, + bids: [{ + bidder: 'videonow', + params: { + pId: '1234', + currency: 'RUB', + } + }] + }]; +``` diff --git a/modules/videoreachBidAdapter.js b/modules/videoreachBidAdapter.js index 61ecd55a2ef..8835398d7cc 100644 --- a/modules/videoreachBidAdapter.js +++ b/modules/videoreachBidAdapter.js @@ -1,4 +1,4 @@ -import { getValue, getBidIdParameter } from '../src/utils.js'; +import {getBidIdParameter, getValue} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'videoreach'; const ENDPOINT_URL = 'https://a.videoreach.com/hb/'; @@ -21,14 +21,16 @@ export const spec = { adUnitCode: getBidIdParameter('adUnitCode', bid), bidId: getBidIdParameter('bidId', bid), bidderRequestId: getBidIdParameter('bidderRequestId', bid), + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: getBidIdParameter('auctionId', bid), - transactionId: getBidIdParameter('transactionId', bid) + transactionId: bid.ortb2Imp?.ext?.tid, } }) }; if (bidderRequest && bidderRequest.refererInfo) { - data.referrer = bidderRequest.refererInfo.referer; + // TODO: is 'page' the right value here? + data.referrer = bidderRequest.refererInfo.page; } if (bidderRequest && bidderRequest.gdprConsent) { diff --git a/modules/vidoomyBidAdapter.js b/modules/vidoomyBidAdapter.js index d268f7a9d64..c9ac9fae0f4 100644 --- a/modules/vidoomyBidAdapter.js +++ b/modules/vidoomyBidAdapter.js @@ -1,24 +1,21 @@ -import { logError, deepAccess, parseSizesInput } from '../src/utils.js'; +import {deepAccess, logError, parseSizesInput} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; -import { Renderer } from '../src/Renderer.js'; -import { INSTREAM, OUTSTREAM } from '../src/video.js'; +import {Renderer} from '../src/Renderer.js'; +import {INSTREAM, OUTSTREAM} from '../src/video.js'; const ENDPOINT = `https://d.vidoomy.com/api/rtbserver/prebid/`; const BIDDER_CODE = 'vidoomy'; const GVLID = 380; const COOKIE_SYNC_FALLBACK_URLS = [ - 'https://x.bidswitch.net/sync?ssp=vidoomy', - 'https://ib.adnxs.com/getuid?https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D{{GDPR}}%26gdpr_consent%3D{{GDPR_CONSENT}}%26uid%3D%24UID', - 'https://pixel-sync.sitescout.com/dmp/pixelSync?nid=120&redir=https%3A%2F%2Fa.vidoomy.com%2Fapi%2Frtbserver%2Fcookie%3Fi%3DCEN%26uid%3D%7BuserId%7D', - 'https://sync.1rx.io/usersync2/vidoomy?redir=https%3A%2F%2Fa.vidoomy.com%2Fapi%2Frtbserver%2Fcookie%3Fi%3DUN%26uid%3D%5BRX_UUID%5D', - 'https://rtb.openx.net/sync/prebid?gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&r=https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dopenx%26uid%3D$%7BUID%7D', - 'https://ads.pubmatic.com/AdServer/js/user_sync.html?gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&us_privacy=&predirect=https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{GDPR}}%26gdpr_consent%3D{{GDPR_CONSENT}}%26uid%3D', + 'https://x.bidswitch.net/sync?ssp=vidoomy&gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&us_privacy=', + 'https://pixel-sync.sitescout.com/dmp/pixelSync?nid=120&gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&redir=https%3A%2F%2Fa.vidoomy.com%2Fapi%2Frtbserver%2Fcookie%3Fi%3DCEN%26uid%3D%7BuserId%7D', 'https://cm.adform.net/cookie?redirect_url=https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dadf%26gdpr%3D{{GDPR}}%26gdpr_consent%3D{{GDPR_CONSENT}}%26uid%3D%24UID', - 'https://ups.analytics.yahoo.com/ups/58531/occ?gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}', - 'https://ap.lijit.com/pixel?redir=https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{GDPR}}%26gdpr_consent%3D{{GDPR_CONSENT}}%26uid%3D%24UID' + 'https://pixel.rubiconproject.com/exchange/sync.php?p=pbs-vidoomy&gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&us_privacy=', + 'https://rtb.openx.net/sync/prebid?gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&r=https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dopenx%26uid%3D$%7BUID%7D', + 'https://ads.pubmatic.com/AdServer/js/user_sync.html?gdpr={{GDPR}}&gdpr_consent={{GDPR_CONSENT}}&us_privacy=&predirect=https%3A%2F%2Fa-prebid.vidoomy.com%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{GDPR}}%26gdpr_consent%3D{{GDPR_CONSENT}}%26uid%3D' ]; const isBidRequestValid = bid => { @@ -50,6 +47,54 @@ const isBidRequestValid = bid => { return true; }; +/** + * Schain Object needed encodes URI Component with exlamation mark + * @param {String} str + * @returns {String} + */ +function encodeURIComponentWithExlamation(str) { + return encodeURIComponent(str).replace(/!/g, '%21'); +} + +/** + * Serializes the supply chain object based on IAB standards + * @see https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/supplychainobject.md + * @param {Object} schainObj supply chain object + * @returns {string} serialized supply chain value + */ +function serializeSupplyChainObj(schainObj) { + if (!schainObj || !schainObj.nodes) { + return ''; + } + const nodeProps = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + const serializedNodes = schainObj.nodes.map(node => + nodeProps.map(prop => encodeURIComponentWithExlamation(node[prop] || '')).join(',') + ).join('!'); + + const serializedSchain = `${schainObj.ver},${schainObj.complete}!${serializedNodes}`; + return serializedSchain; +} + +/** + * Gets highest floor between getFloor.floor and params.bidfloor + * @param {Object} bid + * @param {Object} mediaType + * @param {Array} sizes + * @param {Number} bidfloor + * @returns {Number} floor + */ +function getBidFloor(bid, mediaType, sizes, bidfloor) { + let floor = bidfloor; + var size = sizes && sizes.length > 0 ? sizes[0] : '*'; + if (typeof bid.getFloor === 'function') { + const floorInfo = bid.getFloor({currency: 'USD', mediaType, size}); + if (typeof floorInfo === 'object' && floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) { + floor = Math.max(bidfloor, parseFloat(floorInfo.floor)); + } + } + return floor; +} + const isBidResponseValid = bid => { if (!bid || !bid.requestId || !bid.cpm || !bid.ttl || !bid.currency) { return false; @@ -77,12 +122,26 @@ const buildRequests = (validBidRequests, bidderRequest) => { } const [w, h] = (parseSizesInput(sizes)[0] || '0x0').split('x'); - const aElement = document.createElement('a'); - aElement.href = (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) || top.location.href; - const hostname = aElement.hostname + // TODO: is 'domain' the right value here? + const hostname = bidderRequest.refererInfo.domain || window.location.hostname; const videoContext = deepAccess(bid, 'mediaTypes.video.context'); const bidfloor = deepAccess(bid, `params.bidfloor`, 0); + const floor = getBidFloor(bid, adType, sizes, bidfloor); + + const ortb2 = bidderRequest.ortb2 || { + bcat: [], + badv: [], + bapp: [], + btype: [], + battr: [] + }; + + let eids; + const userEids = deepAccess(bid, 'userIdAsEids'); + if (Array.isArray(userEids) && userEids.length > 0) { + eids = JSON.stringify(userEids) || ''; + } const queryParams = { id: bid.params.id, @@ -96,13 +155,20 @@ const buildRequests = (validBidRequests, bidderRequest) => { dt: /Mobi/.test(navigator.userAgent) ? 2 : 1, pid: bid.params.pid, requestId: bid.bidId, - schain: bid.schain || '', - bidfloor, + schain: serializeSupplyChainObj(bid.schain) || '', + eids: eids || '', + bidfloor: floor, d: getDomainWithoutSubdomain(hostname), // 'vidoomy.com', - sp: encodeURIComponent(aElement.href), + // TODO: does the fallback make sense here? + sp: encodeURIComponent(bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation), usp: bidderRequest.uspConsent || '', coppa: !!config.getConfig('coppa'), - videoContext: videoContext || '' + videoContext: videoContext || '', + bcat: ortb2.bcat || bid.params.bcat || [], + badv: ortb2.badv || bid.params.badv || [], + bapp: ortb2.bapp || bid.params.bapp || [], + btype: ortb2.btype || bid.params.btype || [], + battr: ortb2.battr || bid.params.battr || [] }; if (bidderRequest.gdprConsent) { @@ -114,7 +180,7 @@ const buildRequests = (validBidRequests, bidderRequest) => { method: 'GET', url: ENDPOINT, data: queryParams - } + }; }); return serverRequests; }; @@ -208,7 +274,7 @@ const interpretResponse = (serverResponse, bidRequest) => { } }; -function getUserSyncs (syncOptions, responses, gdprConsent, uspConsent) { +function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) { if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) { const pixelType = syncOptions.pixelEnabled ? 'image' : 'iframe'; const urls = deepAccess(responses, '0.body.pixels') || COOKIE_SYNC_FALLBACK_URLS; @@ -235,7 +301,7 @@ export const spec = { registerBidder(spec); -function getDomainWithoutSubdomain (hostname) { +function getDomainWithoutSubdomain(hostname) { const parts = hostname.split('.'); const newParts = []; for (let i = parts.length - 1; i >= 0; i--) { diff --git a/modules/vidoomyBidAdapter.md b/modules/vidoomyBidAdapter.md index d91ace5a7b9..b4095606d9b 100644 --- a/modules/vidoomyBidAdapter.md +++ b/modules/vidoomyBidAdapter.md @@ -27,7 +27,12 @@ var adUnits = [ params: { id: '123123', pid: '123123', - bidfloor: 0.5 // This is optional + bidfloor: 0.5, // This is optional + bcat: ['IAB1-1'], // Optional - default is [] + badv: ['example.com'], // Optional - default is [] + bapp: ['app.com'], // Optional - default is [] + btype: [1, 2, 3], // Optional - default is [] + battr: [1, 2, 3] // Optional - default is [] } } ] @@ -52,7 +57,12 @@ var adUnits = [ params: { id: '123123', pid: '123123', - bidfloor: 0.5 // This is optional + bidfloor: 0.5, // This is optional + bcat: ['IAB1-1'], // Optional - default is [] + badv: ['example.com'], // Optional - default is [] + bapp: ['app.com'], // Optional - default is [] + btype: [1, 2, 3], // Optional - default is [] + battr: [1, 2, 3] // Optional - default is [] } } ] diff --git a/modules/viewability.js b/modules/viewability.js deleted file mode 100644 index 39b2ee3da16..00000000000 --- a/modules/viewability.js +++ /dev/null @@ -1,177 +0,0 @@ -import {insertHtmlIntoIframe, isFn, isStr, logInfo, logWarn, triggerPixel} from '../src/utils.js'; -import {getGlobal} from '../src/prebidGlobal.js'; -import {find} from '../src/polyfill.js'; - -export const MODULE_NAME = 'viewability'; - -export function init() { - (getGlobal()).viewability = { - startMeasurement: startMeasurement, - stopMeasurement: stopMeasurement, - }; - - listenMessagesFromCreative(); -} - -const observers = {}; - -function isValid(vid, element, tracker, criteria) { - if (!element) { - logWarn(`${MODULE_NAME}: no html element provided`); - return false; - } - - let validTracker = tracker && - ((tracker.method === 'img' && isStr(tracker.value)) || - (tracker.method === 'js' && isStr(tracker.value)) || - (tracker.method === 'callback' && isFn(tracker.value))); - - if (!validTracker) { - logWarn(`${MODULE_NAME}: invalid tracker`, tracker); - return false; - } - - if (!criteria || !criteria.inViewThreshold || !criteria.timeInView) { - logWarn(`${MODULE_NAME}: missing criteria`, criteria); - return false; - } - - if (!vid || observers[vid]) { - logWarn(`${MODULE_NAME}: must provide an unregistered vid`, vid); - return false; - } - - return true; -} - -function stopObserving(observer, vid, element) { - observer.unobserve(element); - observers[vid].done = true; -} - -function fireViewabilityTracker(element, tracker) { - switch (tracker.method) { - case 'img': - triggerPixel(tracker.value, () => { - logInfo(`${MODULE_NAME}: viewability pixel fired`, tracker.value); - }); - break; - case 'js': - insertHtmlIntoIframe(``); - break; - case 'callback': - tracker.value(element); - break; - } -} - -function viewabilityCriteriaMet(observer, vid, element, tracker) { - stopObserving(observer, vid, element); - fireViewabilityTracker(element, tracker); -} - -/** - * Start measuring viewability of an element - * @typedef {{ method: string='img','js','callback', value: string|function }} ViewabilityTracker { method: 'img', value: 'http://my.tracker/123' } - * @typedef {{ inViewThreshold: number, timeInView: number }} ViewabilityCriteria { inViewThreshold: 0.5, timeInView: 1000 } - * @param {string} vid unique viewability identifier - * @param {HTMLElement} element - * @param {ViewabilityTracker} tracker - * @param {ViewabilityCriteria} criteria - */ -export function startMeasurement(vid, element, tracker, criteria) { - if (!isValid(vid, element, tracker, criteria)) { - return; - } - - const options = { - root: null, - rootMargin: '0px', - threshold: criteria.inViewThreshold, - }; - - let observer; - let viewable = false; - let stateChange = (entries) => { - viewable = entries[0].isIntersecting; - - if (viewable) { - observers[vid].timeoutId = window.setTimeout(() => { - viewabilityCriteriaMet(observer, vid, element, tracker); - }, criteria.timeInView); - } else if (observers[vid].timeoutId) { - window.clearTimeout(observers[vid].timeoutId); - } - }; - - observer = new IntersectionObserver(stateChange, options); - observers[vid] = { - observer: observer, - element: element, - timeoutId: null, - done: false, - }; - - observer.observe(element); - - logInfo(`${MODULE_NAME}: startMeasurement called with:`, arguments); -} - -/** - * Stop measuring viewability of an element - * @param {string} vid unique viewability identifier - */ -export function stopMeasurement(vid) { - if (!vid || !observers[vid]) { - logWarn(`${MODULE_NAME}: must provide a registered vid`, vid); - return; - } - - observers[vid].observer.unobserve(observers[vid].element); - if (observers[vid].timeoutId) { - window.clearTimeout(observers[vid].timeoutId); - } - - // allow the observer under this vid to be created again - if (!observers[vid].done) { - delete observers[vid]; - } -} - -function listenMessagesFromCreative() { - window.addEventListener('message', receiveMessage, false); -} - -/** - * Recieve messages from creatives - * @param {MessageEvent} evt - */ -export function receiveMessage(evt) { - var key = evt.message ? 'message' : 'data'; - var data = {}; - try { - data = JSON.parse(evt[key]); - } catch (e) { - return; - } - - if (!data || data.message !== 'Prebid Viewability') { - return; - } - - switch (data.action) { - case 'startMeasurement': - let element = data.elementId && document.getElementById(data.elementId); - if (!element) { - element = find(document.getElementsByTagName('IFRAME'), iframe => (iframe.contentWindow || iframe.contentDocument.defaultView) == evt.source); - } - - startMeasurement(data.vid, element, data.tracker, data.criteria); - break; - case 'stopMeasurement': - stopMeasurement(data.vid); - break; - } -} - -init(); diff --git a/modules/viewability.md b/modules/viewability.md deleted file mode 100644 index df93b5c40db..00000000000 --- a/modules/viewability.md +++ /dev/null @@ -1,87 +0,0 @@ -# Overview - -Module Name: Viewability - -Purpose: Track when a given HTML element becomes viewable - -Maintainer: atrajkovic@magnite.com - -# Configuration - -Module does not need any configuration, as long as you include it in your PBJS bundle. -Viewability module has only two functions `startMeasurement` and `stopMeasurement` which can be used to enable more complex viewability measurements. Since it allows tracking from within creative (possibly inside a safe frame) this module registers a message listener, for messages with a format that is described bellow. - -## `startMeasurement` - -| startMeasurement Arg Object | Scope | Type | Description | Example | -| --------------------- | -------- | ------------ | -------------------------------------------------------------------------------- | --------- | -| vid | Required | String | Unique viewability identifier, used to reference particular observer | `"ae0f9"` | -| element | Required | HTMLElement | Reference to an HTML element that needs to be tracked | `document.getElementById('test_div')` | -| tracker | Required | ViewabilityTracker | How viewaility event is communicated back to the parties of interest | `{ method: 'img', value: 'http://my.tracker/123' }` | -| criteria | Required | ViewabilityCriteria| Defines custom viewability criteria using the threshold and duration provided | `{ inViewThreshold: 0.5, timeInView: 1000 }` | - -| ViewabilityTracker | Scope | Type | Description | Example | -| --------------------- | -------- | ------------ | -------------------------------------------------------------------------------- | --------- | -| method | Required | String | Type of method for Tracker | `'img' OR 'js' OR 'callback'` | -| value | Required | String | URL string for 'img' and 'js' Trackers, or a function for 'callback' Tracker | `'http://my.tracker/123'` | - -| ViewabilityCriteria | Scope | Type | Description | Example | -| --------------------- | -------- | ------------ | -------------------------------------------------------------------------------- | --------- | -| inViewThreshold | Required | Number | Represents a percentage threshold for the Element to be registered as in view | `0.5` | -| timeInView | Required | Number | Number of milliseconds that a given element needs to be in view continuously, above the threshold | `1000` | - -## Please Note: -- `vid` allows for multiple trackers, with different criteria to be registered for a given HTML element, independently. It's not autogenerated by `startMeasurement()`, it needs to be provided by the caller so that it doesn't have to be posted back to the source iframe (in case viewability is started from within the creative). -- In case of 'callback' method, HTML element is being passed back to the callback function. -- When a tracker needs to be started, without direct access to pbjs, postMessage mechanism can be used to invoke `startMeasurement`, with a following payload: `vid`, `tracker` and `criteria` as described above, but also with `message: 'Prebid Viewability'` and `action: 'startMeasurement'`. Optionally payload can provide `elementId`, if available at that time (for ad servers where name of the iframe is known, or adservers that render outside an iframe). If `elementId` is not provided, viewability module will try to find the iframe that corresponds to the message source. - - -## `stopMeasurement` - -| stopMeasurement Arg Object | Scope | Type | Description | Example | -| --------------------- | -------- | ------------ | -------------------------------------------------------------------------------- | --------- | -| vid | Required | String | Unique viewability identifier, referencing an already started viewability tracker. | `"ae0f9"` | - -## Please Note: -- When a tracker needs to be stopped, without direct access to pbjs, postMessage mechanism can be used here as well. To invoke `stopMeasurement`, you provide the payload with `vid`, `message: 'Prebid Viewability'` and `action: 'stopMeasurement`. Check the example bellow. - -# Examples - -## Example of starting a viewability measurement, when you have direct access to pbjs -``` -pbjs.viewability.startMeasurement( - 'ae0f9', - document.getElementById('test_div'), - { method: 'img', value: 'http://my.tracker/123' }, - { inViewThreshold: 0.5, timeInView: 1000 } -); -``` - -## Example of starting a viewability measurement from within a rendered creative -``` -let viewabilityRecord = { - vid: 'ae0f9', - tracker: { method: 'img', value: 'http://my.tracker/123'}, - criteria: { inViewThreshold: 0.5, timeInView: 1000 }, - message: 'Prebid Viewability', - action: 'startMeasurement' -} - -window.parent.postMessage(JSON.stringify(viewabilityRecord), '*'); -``` - -## Example of stopping the viewability measurement, when you have direct access to pbjs -``` -pbjs.viewability.stopMeasurement('ae0f9'); -``` - -## Example of stopping the viewability measurement from within a rendered creative -``` -let viewabilityRecord = { - vid: 'ae0f9', - message: 'Prebid Viewability', - action: 'stopMeasurement' -} - -window.parent.postMessage(JSON.stringify(viewabilityRecord), '*'); -``` diff --git a/modules/viewdeosDXBidAdapter.js b/modules/viewdeosDXBidAdapter.js index 9e0cb91af9b..7afd23cbde7 100644 --- a/modules/viewdeosDXBidAdapter.js +++ b/modules/viewdeosDXBidAdapter.js @@ -125,7 +125,8 @@ function parseRTBResponse(serverResponse, bidderRequest) { function bidToTag(bidRequests, bidderRequest) { const tag = { - domain: deepAccess(bidderRequest, 'refererInfo.referer') + // TODO: is 'page' the right value here? + domain: deepAccess(bidderRequest, 'refererInfo.page') }; if (deepAccess(bidderRequest, 'gdprConsent.gdprApplies')) { diff --git a/modules/viouslyBidAdapter.js b/modules/viouslyBidAdapter.js new file mode 100644 index 00000000000..5ccca7590dd --- /dev/null +++ b/modules/viouslyBidAdapter.js @@ -0,0 +1,240 @@ +import { deepAccess, logError, parseUrl, parseSizesInput, triggerPixel } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { config } from '../src/config.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import find from 'core-js-pure/features/array/find.js'; // eslint-disable-line prebid/validate-imports + +const BIDDER_CODE = 'viously'; +const GVLID = 1028; +const CURRENCY = 'EUR'; +const TTL = 60; +const HTTP_METHOD = 'POST'; +const REQUEST_URL = 'https://bidder.viously.com/bid'; +const REQUIRED_VIDEO_PARAMS = ['context', 'playbackmethod', 'playerSize']; +const REQUIRED_VIOUSLY_PARAMS = ['pid']; + +export const spec = { + code: BIDDER_CODE, + gvlid: GVLID, + supportedMediaTypes: [BANNER, VIDEO], + + /** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: function(bid) { + let videoParams = deepAccess(bid, 'mediaTypes.video'); + let bannerParams = deepAccess(bid, 'mediaTypes.banner'); + + if (!bid.params) { + logError('The bid params are missing'); + return false; + } + + if (!bannerParams && !videoParams) { + logError('The placement must be of banner or video type'); + return false; + } + + /** + * BANNER checks + */ + + if (bannerParams) { + let sizes = bannerParams.sizes; + + if (!sizes || parseSizesInput(sizes).length == 0) { + logError('mediaTypes.banner.sizes must be set for banner placement at the right format.'); + return false; + } + } + + /** + * VIDEO checks + */ + let areParamsValid = true; + + if (videoParams) { + REQUIRED_VIDEO_PARAMS.forEach(function(videoParam) { + if (typeof videoParams[videoParam] === 'undefined') { + logError('mediaTypes.video.' + videoParam + ' must be set for video placement.'); + areParamsValid = false; + } + }); + + if (parseSizesInput(videoParams.playerSize).length === 0) { + logError('mediaTypes.video.playerSize must be set for video placement at the right format.'); + areParamsValid = false; + } + } + + /** + * Viously checks + */ + + REQUIRED_VIOUSLY_PARAMS.forEach(function(viouslyParam) { + if (typeof bid.params[viouslyParam] === 'undefined') { + logError('The ' + viouslyParam + ' is missing.'); + areParamsValid = false; + } + }); + + if (!areParamsValid) { + return false; + } + + return true; + }, + + buildRequests: function(validBidRequests, bidderRequest) { + let payload = {}; + + /** Viously Publisher ID */ + if (validBidRequests[0].params.pid) { + payload.pid = validBidRequests[0].params.pid; + } + + // Referer Info + if (config.getConfig('pageUrl')) { + let parsedUrl = parseUrl(config.getConfig('pageUrl')); + + payload.domain = parsedUrl.hostname; + payload.page_domain = config.getConfig('pageUrl'); + } else if (bidderRequest && bidderRequest.refererInfo) { + let parsedUrl = parseUrl(bidderRequest.refererInfo.page); + + payload.domain = parsedUrl.hostname; + payload.page_domain = bidderRequest.refererInfo.page; + } + if (payload.domain) { + /** Make sur that the scheme is not part of the domain */ + payload.domain = payload.domain.replace(/(^\w+:|^)\/\//, ''); + payload.domain = payload.domain.replace(/\/$/, ''); + } + + // Handle GDPR + if (bidderRequest && bidderRequest.gdprConsent) { + payload.gdpr = bidderRequest.gdprConsent.gdprApplies; + payload.gdpr_consent = bidderRequest.gdprConsent.consentString; + if (bidderRequest.gdprConsent.addtlConsent && bidderRequest.gdprConsent.addtlConsent.indexOf('~') !== -1) { + payload.addtl_consent = bidderRequest.gdprConsent.addtlConsent; + } + } + + // US Privacy + if (bidderRequest && bidderRequest.uspConsent) { + payload.us_privacy = bidderRequest.uspConsent; + } + + // Schain + if (validBidRequests[0].schain) { + payload.schain = validBidRequests[0].schain; + } + // Currency + payload.currency_code = CURRENCY; + + // User IDs + if (validBidRequests[0].userIdAsEids) { + payload.users_uid = validBidRequests[0].userIdAsEids; + } + + // Placements + payload.placements = validBidRequests.map(bidRequest => { + let request = { + id: bidRequest.adUnitCode, + bid_id: bidRequest.bidId + }; + + if (deepAccess(bidRequest, 'mediaTypes.banner')) { + let position = deepAccess(bidRequest, 'mediaTypes.banner.pos'); + + request.type = BANNER; + + request.sizes = parseSizesInput(deepAccess(bidRequest, 'mediaTypes.banner.sizes')); + + request.position = position || 0; + } else { + request.type = VIDEO; + + request.video_params = { + context: deepAccess(bidRequest, 'mediaTypes.video.context'), + playbackmethod: deepAccess(bidRequest, 'mediaTypes.video.playbackmethod'), + size: parseSizesInput(deepAccess(bidRequest, 'mediaTypes.video.playerSize')) + }; + } + + return request; + }); + + return { + method: HTTP_METHOD, + url: validBidRequests[0].params.endpoint ? validBidRequests[0].params.endpoint : REQUEST_URL, + data: payload + }; + }, + + interpretResponse: function(serverResponse, requests) { + const bidResponses = []; + const responseBody = serverResponse.body; + + if (responseBody.ads && responseBody.ads.length > 0) { + responseBody.ads.forEach(function(bidResponse) { + if (bidResponse.bid) { + let bidRequest = find(requests.data.placements, bid => bid.bid_id === bidResponse.bid_id); + + if (bidRequest) { + let sizes = bidResponse.size.split('x'); + + const bid = { + requestId: bidRequest.bid_id, + id: bidResponse.id, + cpm: bidResponse.cpm, + width: sizes[0], + height: sizes[1], + creativeId: bidResponse.creative_id || '', + currency: CURRENCY, + netRevenue: true, + ttl: TTL, + mediaType: bidResponse.type, + meta: {}, + // Tracking data + nurl: bidResponse.nurl ? bidResponse.nurl : [] + }; + + if (bidResponse.type == VIDEO) { + if (bidResponse.ad_url) { + bid.vastUrl = bidResponse.ad_url; + } else { + bid.vastXml = bidResponse.ad; + } + } else { + bid.ad = bidResponse.ad; + } + + bidResponses.push(bid); + } + } + }); + } + + return bidResponses; + }, + + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) {}, + + onTimeout: function(timeoutData) {}, + + onBidWon: function(bid) { + if (bid && bid.nurl && bid.nurl.length > 0) { + bid.nurl.forEach(function(winUrl) { + triggerPixel(winUrl, null); + }); + } + }, + + onSetTargeting: function(bid) {} +}; + +registerBidder(spec); diff --git a/modules/viouslyBidAdapter.md b/modules/viouslyBidAdapter.md new file mode 100644 index 00000000000..0d15525cc72 --- /dev/null +++ b/modules/viouslyBidAdapter.md @@ -0,0 +1,35 @@ +# Overview + +``` +Module Name: Viously Bidder Adapter +Module Type: Bidder Adapter +Maintainer: prebid@viously.com +``` + +# Description + +Module that connects to Viously's demand sources + +# Test Parameters +``` + var adUnits = [ + { + code: 'test-div', + mediaTypes: { + video: { + playerSize: [640, 360], + context: 'instream', + playbackmethod: [1, 2, 3, 4, 5, 6] + } + }, + bids: [ + { + bidder: 'viously', + params: { + pid: '20d30b78-43ec-11ed-b878-0242ac120002' + } + } + ] + } + ]; +``` \ No newline at end of file diff --git a/modules/viqeoBidAdapter.js b/modules/viqeoBidAdapter.js new file mode 100644 index 00000000000..5762a794c8e --- /dev/null +++ b/modules/viqeoBidAdapter.js @@ -0,0 +1,180 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {logError, logInfo, _each, mergeDeep, isFn, isNumber, isPlainObject} from '../src/utils.js' +import {VIDEO} from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; + +const BIDDER_CODE = 'viqeo'; +const DEFAULT_MIMES = ['application/javascript']; +const VIQEO_ENDPOINT = 'https://ads.betweendigital.com/openrtb_bid'; +const RENDERER_URL = 'https://cdn.viqeo.tv/js/vq_starter.js'; +const DEFAULT_CURRENCY = 'USD'; +const DEFAULT_SSPID = 44697; + +function getBidFloor(bid) { + const {floor, currency} = bid.params; + const curr = currency || DEFAULT_CURRENCY; + if (!isFn(bid.getFloor)) { + return {floor: isNumber(floor) ? floor : 0, currency: curr}; + } + const floorInfo = bid.getFloor({currency: curr, mediaType: VIDEO, size: '*'}); + if (isPlainObject(floorInfo) && isNumber(floorInfo.floor) && floorInfo.currency === curr) { + return floorInfo; + } + return {floor: floor || 0, currency: currency || DEFAULT_CURRENCY}; +} + +function getVideoTargetingParams({mediaTypes: {video}}) { + const result = {}; + Object.keys(Object(video)) + .forEach(key => { + if (key === 'playerSize') { + result.w = video.playerSize[0][0]; + result.h = video.playerSize[0][1]; + } else if (key !== 'context') { + result[key] = video[key]; + } + }) + return result; +} + +/** + * @type {BidderSpec} + */ +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [VIDEO], + /** + * @param {BidRequest} bidRequest The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ + isBidRequestValid: ({params}) => { + if (!params) { + logError('failed validation: params not declared'); + return false; + } + if (!params.user && !params.user?.buyeruid) { + logError('failed validation: user.buyeruid not declared'); + return false; + } + if (!params.playerOptions) { + logError('failed validation: playerOptions not declared'); + return false; + } + const {profileId, videoId, playerId} = params.playerOptions; + if (!profileId) { + logError('failed validation: profileId not declared'); + return false; + } + if (!videoId && !playerId) { + logError('failed validation: videoId or playerId not declared'); + return false; + } + return true; + }, + /** + * @param validBidRequests {BidRequest[]} + * @returns {ServerRequest[]} + */ + buildRequests: (validBidRequests) => { + logInfo('validBidRequests', validBidRequests); + const bidRequests = []; + _each(validBidRequests, (bid, i) => { + const { + params: {test, sspId, endpointUrl}, + mediaTypes: {video}, + } = bid; + const ortb2 = bid.ortb2 || {}; + const user = bid.params.user || {}; + const device = bid.params.device || {}; + const site = bid.params.site || {}; + const w = window; + const floorInfo = getBidFloor(bid); + const data = { + id: bid.bidId, + test, + imp: [{ + id: `${i}`, + tagid: bid.adUnitCode, + video: { + ...getVideoTargetingParams(bid), + mimes: video.mimes || DEFAULT_MIMES, + }, + bidfloor: floorInfo.floor, + bidfloorcur: floorInfo.currency, + secure: 1 + }], + site: test === 1 ? { + page: 'https://viqeo.tv', + domain: 'viqeo.tv' + } : mergeDeep({ + domain: w.location.hostname, + page: w.location.href + }, ortb2.site, site), + device: mergeDeep({ + w: w.screen.width, + h: w.screen.height, + ua: w.navigator.userAgent, + }, ortb2.device, device), + user: mergeDeep({...user}, ortb2.user), + app: bid.params.app, + }; + bidRequests.push({ + url: endpointUrl || `${VIQEO_ENDPOINT}/?sspId=${sspId || DEFAULT_SSPID}`, + method: 'POST', + data, + bids: validBidRequests, + }); + }); + return bidRequests; + }, + /** + * @param {ServerResponse} serverResponse + * @param {BidRequest} bidRequests + * @return {Bid[]} + */ + interpretResponse: (serverResponse, bidRequests) => { + logInfo('serverResponse', serverResponse); + const bidResponses = []; + if (!serverResponse || !serverResponse.body) { + logError('empty response'); + return []; + } + try { + const {id, seatbid, cur} = serverResponse.body; + _each(seatbid, (sb) => { + const {bid} = sb; + _each(bid, (b) => { + const bidRequest = bidRequests.bids.find(({bidId}) => bidId === id); + const renderer = Renderer.install({ + url: bidRequest?.params?.renderUrl || RENDERER_URL, + }); + renderer.setRender((bid) => { + if (window.VIQEO) { + window.VIQEO.renderPrebid(bid); + } else { + logError('failed get window.VIQEO'); + } + }); + bidResponses.push({ + requestId: id, + currency: cur, + cpm: b.price, + ttl: b.exp, + netRevenue: true, + creativeId: b.cid, + width: b.w || bidRequest?.mediaTypes[VIDEO].playerSize[0][0], + height: b.h || bidRequest?.mediaTypes[VIDEO].playerSize[0][1], + vastXml: b.adm, + vastUrl: b.nurl, + mediaType: VIDEO, + renderer, + }) + }) + }); + } catch (error) { + logError(error); + } + return bidResponses; + }, +} +registerBidder(spec); diff --git a/modules/viqeoBidAdapter.md b/modules/viqeoBidAdapter.md new file mode 100644 index 00000000000..b4a020bf057 --- /dev/null +++ b/modules/viqeoBidAdapter.md @@ -0,0 +1,56 @@ +# Overview + +**Module Name**: Viqeo Bidder Adapter +**Module Type**: Bidder Adapter +**Maintainer**: muravjovv1@gmail.com + +# Description + +Viqeo Bidder Adapter for Prebid.js. About: https://viqeo.tv/ + +### Bid params + +{: .table .table-bordered .table-striped } +| Name | Scope | Description | Example | Type | +|-----------------------------|----------|----------------------------------------------------------------------------------------------------------------------------|--------------------------|-----------| +| `user` | required | The object containing user data (See OpenRTB spec) | `user: {}` | `object` | +| `user.buyeruid` | required | User id | `"12345"` | `string` | +| `playerOptions` | required | The object containing Viqeo player options | `playerOptions: {}` | `object` | +| `playerOptions.profileId` | required | Viqeo profile id | `1382` | `number` | +| `playerOptions.videId` | optional | Viqeo video id | `"ed584da454c7205ca7e4"` | `string` | +| `playerOptions.playerId` | optional | Viqeo player id | `1` | `number` | +| `device` | optional | The object containing device data (See OpenRTB spec) | `device: {}` | `object` | +| `site` | optional | The object containing site data (See OpenRTB spec) | `site: {}` | `object` | +| `app` | optional | The object containing app data (See OpenRTB spec) | `app: {}` | `object` | +| `floor` | optional | Bid floor price | `0.5` | `number` | +| `currency` | optional | 3-letter ISO 4217 code defining the currency of the bid. | `EUR` | `string` | +| `test` | optional | Flag which will induce a sample bid response when true; only set to true for testing purposes (1 = true, 0 = false) | `1` | `integer` | +| `sspId` | optional | For debug, request id | `1` | `number` | +| `renderUrl` | optional | For debug, script player url | `"https://viqeo.tv"` | `string` | +| `endpointUrl` | optional | For debug, api endpoint | `"https://viqeo.tv"` | `string` | + +# Test Parameters +``` + var adUnits = [{ + code: 'your-slot', // use exactly the same code as your slot div id. + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }, + bids: [{ + bidder: 'viqeo', + params: { + user: { + buyeruid: '1', + }, + playerOptions: { + videoId: 'ed584da454c7205ca7e4', + profileId: 1382, + }, + test: 1, + } + }] + }]; +``` diff --git a/modules/visiblemeasuresBidAdapter.js b/modules/visiblemeasuresBidAdapter.js new file mode 100644 index 00000000000..e77477c812b --- /dev/null +++ b/modules/visiblemeasuresBidAdapter.js @@ -0,0 +1,212 @@ +import { isFn, deepAccess, logMessage, logError } from '../src/utils.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; + +const BIDDER_CODE = 'visiblemeasures'; +const AD_URL = 'https://us-e.visiblemeasures.com/pbjs'; +const SYNC_URL = 'https://cs.visiblemeasures.com'; + +function isBidResponseValid(bid) { + if (!bid.requestId || !bid.cpm || !bid.creativeId || !bid.ttl || !bid.currency) { + return false; + } + + switch (bid.mediaType) { + case BANNER: + return Boolean(bid.width && bid.height && bid.ad); + case VIDEO: + return Boolean(bid.vastUrl || bid.vastXml); + case NATIVE: + return Boolean(bid.native && bid.native.impressionTrackers && bid.native.impressionTrackers.length); + default: + return false; + } +} + +function getPlacementReqData(bid) { + const { params, bidId, mediaTypes } = bid; + const schain = bid.schain || {}; + const { placementId, endpointId } = params; + const bidfloor = getBidFloor(bid); + + const placement = { + bidId, + schain, + bidfloor + }; + + if (placementId) { + placement.placementId = placementId; + placement.type = 'publisher'; + } else if (endpointId) { + placement.endpointId = endpointId; + placement.type = 'network'; + } + + if (mediaTypes && mediaTypes[BANNER]) { + placement.adFormat = BANNER; + placement.sizes = mediaTypes[BANNER].sizes; + } else if (mediaTypes && mediaTypes[VIDEO]) { + placement.adFormat = VIDEO; + placement.playerSize = mediaTypes[VIDEO].playerSize; + placement.minduration = mediaTypes[VIDEO].minduration; + placement.maxduration = mediaTypes[VIDEO].maxduration; + placement.mimes = mediaTypes[VIDEO].mimes; + placement.protocols = mediaTypes[VIDEO].protocols; + placement.startdelay = mediaTypes[VIDEO].startdelay; + placement.placement = mediaTypes[VIDEO].placement; + placement.skip = mediaTypes[VIDEO].skip; + placement.skipafter = mediaTypes[VIDEO].skipafter; + placement.minbitrate = mediaTypes[VIDEO].minbitrate; + placement.maxbitrate = mediaTypes[VIDEO].maxbitrate; + placement.delivery = mediaTypes[VIDEO].delivery; + placement.playbackmethod = mediaTypes[VIDEO].playbackmethod; + placement.api = mediaTypes[VIDEO].api; + placement.linearity = mediaTypes[VIDEO].linearity; + } else if (mediaTypes && mediaTypes[NATIVE]) { + placement.native = mediaTypes[NATIVE]; + placement.adFormat = NATIVE; + } + + return placement; +} + +function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return deepAccess(bid, 'params.bidfloor', 0); + } + + try { + const bidFloor = bid.getFloor({ + currency: 'USD', + mediaType: '*', + size: '*', + }); + return bidFloor.floor; + } catch (err) { + logError(err); + return 0; + } +} + +export const spec = { + code: BIDDER_CODE, + supportedMediaTypes: [BANNER, VIDEO, NATIVE], + + isBidRequestValid: (bid = {}) => { + const { params, bidId, mediaTypes } = bid; + let valid = Boolean(bidId && params && (params.placementId || params.endpointId)); + + if (mediaTypes && mediaTypes[BANNER]) { + valid = valid && Boolean(mediaTypes[BANNER] && mediaTypes[BANNER].sizes); + } else if (mediaTypes && mediaTypes[VIDEO]) { + valid = valid && Boolean(mediaTypes[VIDEO] && mediaTypes[VIDEO].playerSize); + } else if (mediaTypes && mediaTypes[NATIVE]) { + valid = valid && Boolean(mediaTypes[NATIVE]); + } else { + valid = false; + } + return valid; + }, + + buildRequests: (validBidRequests = [], bidderRequest = {}) => { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + let deviceWidth = 0; + let deviceHeight = 0; + + let winLocation; + try { + const winTop = window.top; + deviceWidth = winTop.screen.width; + deviceHeight = winTop.screen.height; + winLocation = winTop.location; + } catch (e) { + logMessage(e); + winLocation = window.location; + } + + const refferUrl = bidderRequest.refererInfo && bidderRequest.refererInfo.page; + let refferLocation; + try { + refferLocation = refferUrl && new URL(refferUrl); + } catch (e) { + logMessage(e); + } + // TODO: does the fallback make sense here? + let location = refferLocation || winLocation; + const language = (navigator && navigator.language) ? navigator.language.split('-')[0] : ''; + const host = location.host; + const page = location.pathname; + const secure = location.protocol === 'https:' ? 1 : 0; + const placements = []; + const request = { + deviceWidth, + deviceHeight, + language, + secure, + host, + page, + placements, + coppa: config.getConfig('coppa') === true ? 1 : 0, + ccpa: bidderRequest.uspConsent || undefined, + gdpr: bidderRequest.gdprConsent || undefined, + tmax: bidderRequest.timeout + }; + + const len = validBidRequests.length; + for (let i = 0; i < len; i++) { + const bid = validBidRequests[i]; + placements.push(getPlacementReqData(bid)); + } + + return { + method: 'POST', + url: AD_URL, + data: request + }; + }, + + interpretResponse: (serverResponse) => { + let response = []; + for (let i = 0; i < serverResponse.body.length; i++) { + let resItem = serverResponse.body[i]; + if (isBidResponseValid(resItem)) { + const advertiserDomains = resItem.adomain && resItem.adomain.length ? resItem.adomain : []; + resItem.meta = { ...resItem.meta, advertiserDomains }; + + response.push(resItem); + } + } + return response; + }, + + getUserSyncs: (syncOptions, serverResponses, gdprConsent, uspConsent) => { + let syncType = syncOptions.iframeEnabled ? 'iframe' : 'image'; + let syncUrl = SYNC_URL + `/${syncType}?pbjs=1`; + if (gdprConsent && gdprConsent.consentString) { + if (typeof gdprConsent.gdprApplies === 'boolean') { + syncUrl += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`; + } else { + syncUrl += `&gdpr=0&gdpr_consent=${gdprConsent.consentString}`; + } + } + if (uspConsent && uspConsent.consentString) { + syncUrl += `&ccpa_consent=${uspConsent.consentString}`; + } + + const coppa = config.getConfig('coppa') ? 1 : 0; + syncUrl += `&coppa=${coppa}`; + + return [{ + type: syncType, + url: syncUrl + }]; + } +}; + +registerBidder(spec); diff --git a/modules/visiblemeasuresBidAdapter.md b/modules/visiblemeasuresBidAdapter.md new file mode 100644 index 00000000000..aff91f47a2a --- /dev/null +++ b/modules/visiblemeasuresBidAdapter.md @@ -0,0 +1,79 @@ +# Overview + +``` +Module Name: VisibleMeasures Bidder Adapter +Module Type: VisibleMeasures Bidder Adapter +Maintainer: Support@visiblemeasures.com +``` + +# Description + +Connects to VisibleMeasures exchange for bids. +VisibleMeasures bid adapter supports Banner, Video (instream and outstream) and Native. + +# Test Parameters +``` + var adUnits = [ + // Will return static test banner + { + code: 'adunit1', + mediaTypes: { + banner: { + sizes: [ [300, 250], [320, 50] ], + } + }, + bids: [ + { + bidder: 'visiblemeasures', + params: { + placementId: 'testBanner', + } + } + ] + }, + { + code: 'addunit2', + mediaTypes: { + video: { + playerSize: [ [640, 480] ], + context: 'instream', + minduration: 5, + maxduration: 60, + } + }, + bids: [ + { + bidder: 'visiblemeasures', + params: { + placementId: 'testVideo', + } + } + ] + }, + { + code: 'addunit3', + mediaTypes: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + }, + bids: [ + { + bidder: 'visiblemeasures', + params: { + placementId: 'testNative', + } + } + ] + } + ]; +``` diff --git a/modules/visxBidAdapter.js b/modules/visxBidAdapter.js index 696d54e4b52..a45a1db9ece 100644 --- a/modules/visxBidAdapter.js +++ b/modules/visxBidAdapter.js @@ -1,8 +1,11 @@ -import { triggerPixel, parseSizesInput, deepAccess, logError, getGptSlotInfoForAdUnitCode } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; -import { config } from '../src/config.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; -import { INSTREAM as VIDEO_INSTREAM } from '../src/video.js'; +import {deepAccess, logError, parseSizesInput, triggerPixel} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import {config} from '../src/config.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; +import {INSTREAM as VIDEO_INSTREAM} from '../src/video.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {getGptSlotInfoForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; + const BIDDER_CODE = 'visx'; const GVLID = 154; const BASE_URL = 'https://t.visx.net'; @@ -29,6 +32,7 @@ const LOG_ERROR_MESS = { videoMissing: 'Bid request videoType property is missing - ' }; const currencyWhiteList = ['EUR', 'USD', 'GBP', 'PLN']; +export const storage = getStorageManager({bidderCode: BIDDER_CODE}); export const spec = { code: BIDDER_CODE, gvlid: GVLID, @@ -94,8 +98,9 @@ export const spec = { if (bidderRequest) { timeout = bidderRequest.timeout; - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - payload.u = bidderRequest.refererInfo.referer; + if (bidderRequest.refererInfo && bidderRequest.refererInfo.page) { + // TODO: is 'page' the right value here? + payload.u = bidderRequest.refererInfo.page; } if (bidderRequest.gdprConsent) { if (bidderRequest.gdprConsent.consentString) { @@ -116,10 +121,13 @@ export const spec = { ...(payloadSchain && { schain: payloadSchain }) } }; + + const vads = _getUserId(); const user = { ext: { ...(payloadUserEids && { eids: payloadUserEids }), - ...(payload.gdpr_consent && { consent: payload.gdpr_consent }) + ...(payload.gdpr_consent && { consent: payload.gdpr_consent }), + ...(vads && { vads }) } }; const regs = ('gdpr_applies' in payload) && { @@ -203,16 +211,16 @@ export const spec = { }, onTimeout: function(timeoutData) { // Call '/track/bid_timeout' with timeout data - timeoutData.forEach(({ params }) => { + const dataToSend = timeoutData.map(({ params, timeout }) => { + const data = { timeout }; if (params) { - params.forEach((item) => { - if (item && item.uid) { - item.uid = parseInt(item.uid); - } + data.params = params.map((item) => { + return item && item.uid ? { uid: parseInt(item.uid) } : {}; }); } + return data; }); - triggerPixel(buildUrl(TRACK_TIMEOUT_PATH) + '//' + JSON.stringify(timeoutData)); + triggerPixel(buildUrl(TRACK_TIMEOUT_PATH) + '//' + JSON.stringify(dataToSend)); } }; @@ -374,11 +382,56 @@ function _isAdSlotExists(adUnitCode) { } const gptAdSlot = getGptSlotInfoForAdUnitCode(adUnitCode); - if (gptAdSlot && gptAdSlot.divId && document.getElementById(gptAdSlot.divId)) { + if (gptAdSlot.divId && document.getElementById(gptAdSlot.divId)) { return true; } return false; } +// Generate user id (25 chars) with NanoID +// https://github.com/ai/nanoid/ +function _generateUserId() { + for ( + var t = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict', + e = new Date().getTime() % 1073741824, + i = '', + o = 0; + o < 5; + o++ + ) { + i += t[e % 64]; + e = Math.floor(e / 64); + } + for (o = 20; o--;) i += t[(64 * Math.random()) | 0]; + return i; +} + +function _getUserId() { + const USER_ID_KEY = '__vads'; + let vads; + + if (storage.cookiesAreEnabled()) { + vads = storage.getCookie(USER_ID_KEY); + } else if (storage.localStorageIsEnabled()) { + vads = storage.getDataFromLocalStorage(USER_ID_KEY); + } + + if (vads && vads.length) { + return vads; + } + + vads = _generateUserId(); + if (storage.cookiesAreEnabled()) { + const expires = new Date(Date.now() + 2592e6).toUTCString(); + storage.setCookie(USER_ID_KEY, vads, expires); + return vads; + } else if (storage.localStorageIsEnabled()) { + storage.setDataInLocalStorage(USER_ID_KEY, vads); + return vads; + } + + return null; +} + registerBidder(spec); diff --git a/modules/vlybyBidAdapter.js b/modules/vlybyBidAdapter.js index 10352179044..08ab415e8ae 100644 --- a/modules/vlybyBidAdapter.js +++ b/modules/vlybyBidAdapter.js @@ -23,6 +23,7 @@ export const spec = { url: `${ENDPOINT}`, data: { request: { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidderRequest.auctionId }, gdprConsent: { diff --git a/modules/vmgBidAdapter.md b/modules/vmgBidAdapter.md deleted file mode 100644 index 3ebfce91dee..00000000000 --- a/modules/vmgBidAdapter.md +++ /dev/null @@ -1,28 +0,0 @@ -# Overview - -``` -Module Name: VMG Bidder Adapter -Module Type: Bidder Adapter -Maintainer: paul@vmgood.com -``` - -# Description - -Connects DFP to the VMG Predict engine. - -# Test Parameters -``` - var adUnits = [{ - code: 'div-0', - mediaTypes: { - banner: { - sizes: sizes - } - }, - bids: [ - { - bidder: 'vmg' - } - ] - }]; -``` diff --git a/modules/voxBidAdapter.js b/modules/voxBidAdapter.js index 25dbbda90cf..34bd46ccb98 100644 --- a/modules/voxBidAdapter.js +++ b/modules/voxBidAdapter.js @@ -4,6 +4,9 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {find} from '../src/polyfill.js'; import {auctionManager} from '../src/auctionManager.js'; import {Renderer} from '../src/Renderer.js'; +import {config} from '../src/config.js' + +const { getConfig } = config; const BIDDER_CODE = 'vox'; const SSP_ENDPOINT = 'https://ssp.hybrid.ai/auction/prebid'; @@ -11,12 +14,21 @@ const VIDEO_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVi const TTL = 60; function buildBidRequests(validBidRequests) { - return _map(validBidRequests, function(validBidRequest) { - const params = validBidRequest.params; + return _map(validBidRequests, function(bid) { + const currency = getConfig('currency.adServerCurrency'); + const floorInfo = bid.getFloor ? bid.getFloor({ + currency: currency || 'USD' + }) : {}; + + const params = bid.params; const bidRequest = { - bidId: validBidRequest.bidId, - transactionId: validBidRequest.transactionId, - sizes: validBidRequest.sizes, + floorInfo, + schain: bid.schain, + userId: bid.userId, + bidId: bid.bidId, + // TODO: fix transactionId leak: https://github.com/prebid/Prebid.js/issues/9781 + transactionId: bid.transactionId, + sizes: bid.sizes, placement: params.placement, placeId: params.placementId, imageUrl: params.imageUrl @@ -80,6 +92,7 @@ function buildBid(bidData) { bid.vastXml = bidData.content; bid.mediaType = VIDEO; + // TODO: why does this need to iterate through every ad unit? let adUnit = find(auctionManager.getAdUnits(), function (unit) { return unit.transactionId === bidData.transactionId; }); @@ -198,7 +211,8 @@ export const spec = { */ buildRequests(validBidRequests, bidderRequest) { const payload = { - url: bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + url: bidderRequest.refererInfo.page, cmp: !!bidderRequest.gdprConsent, bidRequests: buildBidRequests(validBidRequests) }; diff --git a/modules/vrtcalBidAdapter.js b/modules/vrtcalBidAdapter.js index d08ef52106e..21870e3218a 100644 --- a/modules/vrtcalBidAdapter.js +++ b/modules/vrtcalBidAdapter.js @@ -1,13 +1,17 @@ import {registerBidder} from '../src/adapters/bidderFactory.js'; import { BANNER } from '../src/mediaTypes.js'; import {ajax} from '../src/ajax.js'; -import {isFn, isPlainObject} from '../src/utils.js'; +import { config } from '../src/config.js'; +import {deepAccess, isFn, isPlainObject} from '../src/utils.js'; + +const GVLID = 706; export const spec = { code: 'vrtcal', + gvlid: GVLID, supportedMediaTypes: [BANNER], isBidRequestValid: function (bid) { - if (bid.bidId == '' || bid.auctionId == '') { return false; } else { return true; }// No extras params required + return true; }, buildRequests: function (bidRequests) { const requests = bidRequests.map(function (bid) { @@ -21,10 +25,37 @@ export const spec = { } } + let gdprApplies = 0; + let gdprConsent = ''; + let ccpa = ''; + let coppa = 0; + let tmax = 0; + let eids = []; + + if (bidRequests[0].userIdAsEids && bidRequests[0].userIdAsEids.length > 0) { + eids = bidRequests[0].userIdAsEids; + } + + if (bid && bid.gdprConsent) { + gdprApplies = bid.gdprConsent.gdprApplies ? 1 : 0; + gdprConsent = bid.gdprConsent.consentString; + } + + if (bid && bid.uspConsent) { + ccpa = bid.uspConsent; + } + + if (config.getConfig('coppa') === true) { + coppa = 1; + } + + tmax = bid.timeout; + const params = { prebidJS: 1, prebidAdUnitCode: bid.adUnitCode, id: bid.bidId, + tmax: tmax, imp: [{ id: '1', banner: { @@ -34,13 +65,27 @@ export const spec = { site: { id: 'VRTCAL_FILLED', name: 'VRTCAL_FILLED', - cat: ['VRTCAL_FILLED'], - domain: decodeURIComponent(window.location.href).replace('https://', '').replace('http://', '').split('/')[0] - + cat: deepAccess(bid, 'ortb2.site.cat', []), + domain: decodeURIComponent(window.location.href).replace('https://', '').replace('http://', '').split('/')[0], + page: bid.refererInfo.page }, device: { - ua: 'VRTCAL_FILLED', - ip: 'VRTCAL_FILLED' + language: navigator.language, + ua: navigator.userAgent, + ip: deepAccess(bid, 'params.bidOverride.device.ip') || deepAccess(bid, 'params.ext.ip') || undefined + }, + regs: { + coppa: coppa, + ext: { + gdpr: gdprApplies, + us_privacy: ccpa + } + }, + user: { + ext: { + consent: gdprConsent, + eids: eids + } } }; @@ -52,7 +97,12 @@ export const spec = { params.imp[0].banner.h = bid.sizes[0][1]; } - return {method: 'POST', url: 'https://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804', data: JSON.stringify(params), options: {withCredentials: false, crossOrigin: true}} + if (bid.ortb2?.regs?.gpp) { + params.regs.ext.gpp = bid.ortb2.regs.gpp; + params.regs.ext.gpp_sid = bid.ortb2.regs.gpp_sid; + } + + return {method: 'POST', url: 'https://rtb.vrtcal.com/bidder_prebid.vap?ssp=1804', data: JSON.stringify(params), options: {withCredentials: false, crossOrigin: true}}; }); return requests; diff --git a/modules/vubleAnalyticsAdapter.md b/modules/vubleAnalyticsAdapter.md deleted file mode 100644 index dfe0a8d8eb0..00000000000 --- a/modules/vubleAnalyticsAdapter.md +++ /dev/null @@ -1,23 +0,0 @@ -# Overview - -Module Name: Vuble Analytics Adapter - -Module Type: Vuble Analytics Adapter - -Maintainer: abruyere@mediabong.com - -# Description - -Analytics adapter for vuble.tv Contact contact@mediabong.com for information. - -# Test Parameters - -``` -{ - provider: 'vuble', - options: { - pubId: 18, // require - env: 'net', // require - } -} -``` diff --git a/modules/vubleBidAdapter.md b/modules/vubleBidAdapter.md deleted file mode 100644 index 6bd8d3f779a..00000000000 --- a/modules/vubleBidAdapter.md +++ /dev/null @@ -1,58 +0,0 @@ -# Overview - -``` -Module Name: Vuble Bidder Adapter -Module Type: Vuble Adapter -Maintainer: gv@mediabong.com -``` - -# Description - -Module that connects to Vuble's demand sources - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-video-instream', - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'instream' - } - }, - bids: [ - { - bidder: "vuble", - params: { - env: 'net', - pubId: '18', - zoneId: '12345', - referrer: "http://www.vuble.tv/", // optional - floorPrice: 5.00 // optional - } - } - ] - }, - { - code: 'test-video-outstream', - sizes: [[640, 360]], - mediaTypes: { - video: { - context: 'outstream' - } - }, - bids: [ - { - bidder: "vuble", - params: { - env: 'net', - pubId: '18', - zoneId: '12345', - referrer: "http://www.vuble.tv/", // optional - floorPrice: 5.00 // optional - } - } - ] - } - ]; \ No newline at end of file diff --git a/modules/vuukleBidAdapter.js b/modules/vuukleBidAdapter.js index ddf96b3e940..f3ab2562ef4 100644 --- a/modules/vuukleBidAdapter.js +++ b/modules/vuukleBidAdapter.js @@ -1,18 +1,24 @@ -import { parseSizesInput } from '../src/utils.js'; +import { parseSizesInput, deepAccess } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER } from '../src/mediaTypes.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'vuukle'; const URL = 'https://pb.vuukle.com/adapter'; const TIME_TO_LIVE = 360; +const VENDOR_ID = 1004; export const spec = { code: BIDDER_CODE, + gvlid: VENDOR_ID, + supportedMediaTypes: [ BANNER ], isBidRequestValid: function(bid) { return true }, - buildRequests: function(bidRequests) { + buildRequests: function(bidRequests, bidderRequest) { + bidderRequest = bidderRequest || {}; const requests = bidRequests.map(function (bid) { const parseSized = parseSizesInput(bid.sizes); const arrSize = parseSized[0].split('x'); @@ -25,10 +31,27 @@ export const spec = { rnd: Math.random(), bidId: bid.bidId, source: 'pbjs', + schain: JSON.stringify(bid.schain), + requestId: bid.bidderRequestId, + tmax: bidderRequest.timeout, + gdpr: (bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0, + consentGiven: vuukleGetConsentGiven(bidderRequest.gdprConsent), version: '$prebid.version$', - v: 1, + v: 2, }; + if (bidderRequest.uspConsent) { + params.uspConsent = bidderRequest.uspConsent; + } + + if (config.getConfig('coppa') === true) { + params.coppa = 1; + } + + if (bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) { + params.consent = bidderRequest.gdprConsent.consentString; + } + return { method: 'GET', url: URL, @@ -65,3 +88,11 @@ export const spec = { }, } registerBidder(spec); + +function vuukleGetConsentGiven(gdprConsent) { + let consentGiven = 0; + if (typeof gdprConsent !== 'undefined') { + consentGiven = deepAccess(gdprConsent, `vendorData.vendor.consents.${VENDOR_ID}`) ? 1 : 0; + } + return consentGiven; +} diff --git a/modules/waardexBidAdapter.js b/modules/waardexBidAdapter.js index 1a97e3bd351..92b7fc26e4c 100644 --- a/modules/waardexBidAdapter.js +++ b/modules/waardexBidAdapter.js @@ -69,7 +69,8 @@ const getCommonBidsData = bidderRequest => { }; if (bidderRequest && bidderRequest.refererInfo) { - payload.referer = encodeURIComponent(bidderRequest.refererInfo.referer); + // TODO: is 'page' the right value here? + payload.referer = encodeURIComponent(bidderRequest.refererInfo.page || ''); } if (bidderRequest && bidderRequest.uspConsent) { @@ -97,7 +98,7 @@ const getBidRequestToSend = validBidRequest => { bidId: validBidRequest.bidId, bidfloor: 0, position: parseInt(validBidRequest.params.position) || 1, - instl: parseInt(validBidRequest.params.instl) || 0, + instl: deepAccess(validBidRequest.ortb2Imp, 'instl') === 1 || parseInt(validBidRequest.params.instl) === 1 ? 1 : 0, }; if (validBidRequest.mediaTypes[BANNER]) { diff --git a/modules/weboramaRtdProvider.js b/modules/weboramaRtdProvider.js index 0885df02f05..14abba95323 100644 --- a/modules/weboramaRtdProvider.js +++ b/modules/weboramaRtdProvider.js @@ -7,57 +7,109 @@ * @requires module:modules/realTimeData */ +/** profile metadata + * @typedef dataCallbackMetadata + * @property {boolean} user if true it is user-centric data + * @property {string} source describe the source of data, if 'contextual' or 'wam' + * @property {boolean} isDefault if true it the default profile defined in the configuration + */ + +/** profile from contextual, wam or sfbx + * @typedef {Object.} Profile + */ + /** onData callback type * @callback dataCallback - * @param {Object} data profile data - * @param {Boolean} site true if site, else it is user + * @param {Profile} data profile data + * @param {dataCallbackMetadata} meta metadata * @returns {void} */ +/** setPrebidTargeting callback type + * @callback setPrebidTargetingCallback + * @param {string} adUnitCode + * @param {Profile} data + * @param {dataCallbackMetadata} metadata + * @returns {boolean} + */ + +/** sendToBidders callback type + * @callback sendToBiddersCallback + * @param {Object} bid + * @param {string} adUnitCode + * @param {Profile} data + * @param {dataCallbackMetadata} metadata + * @returns {boolean} + */ + /** * @typedef {Object} ModuleParams - * @property {?Boolean} setPrebidTargeting if true, will set the GAM targeting (default undefined) - * @property {?Boolean} sendToBidders if true, will send the contextual profile to all bidders (default undefined) + * @property {?setPrebidTargetingCallback|?boolean|?Object} setPrebidTargeting if true, will set the GAM targeting (default undefined) + * @property {?sendToBiddersCallback|?boolean|?Object} sendToBidders if true, will send the contextual profile to all bidders, else expects a list of allowed bidders (default undefined) * @property {?dataCallback} onData callback - * @property {?WeboCtxConf} weboCtxConf - * @property {?WeboUserDataConf} weboUserDataConf + * @property {?WeboCtxConf} weboCtxConf site-centric contextual configuration + * @property {?WeboUserDataConf} weboUserDataConf user-centric wam configuration + * @property {?SfbxLiteDataConf} sfbxLiteDataConf site-centric lite configuration */ +/** + * @callback assetIDcallback + * @returns {string} should return asset identifier using the form datasource:docId + */ /** * @typedef {Object} WeboCtxConf * @property {string} token required token to be used on bigsea contextual API requests * @property {?string} targetURL specify the target url instead use the referer - * @property {?Boolean} setPrebidTargeting if true, will set the GAM targeting (default params.setPrebidTargeting or true) - * @property {?Boolean} sendToBidders if true, will send the contextual profile to all bidders (default params.sendToBidders or true) + * @property {?assetIDcallback|?string} assetID specifies the assert identifier using the form datasource:docId or via callback + * @property {?setPrebidTargetingCallback|?boolean|?Object} setPrebidTargeting if true, will set the GAM targeting (default undefined) + * @property {?sendToBiddersCallback|?boolean|?Object} sendToBidders if true, will send the contextual profile to all bidders, else expects a list of allowed bidders (default undefined) * @property {?dataCallback} onData callback - * @property {?object} defaultProfile to be used if the profile is not found - * @property {?Boolean} enabled if false, will ignore this configuration + * @property {?Profile} defaultProfile to be used if the profile is not found + * @property {?boolean} enabled if false, will ignore this configuration + * @property {?string} baseURLProfileAPI to be used to point to a different domain than ctx.weborama.com */ /** * @typedef {Object} WeboUserDataConf * @property {?number} accountId wam account id - * @property {?Boolean} setPrebidTargeting if true, will set the GAM targeting (default params.setPrebidTargeting or true) - * @property {?Boolean} sendToBidders if true, will send the user-centric profile to all bidders (default params.sendToBidders or true) - * @property {?object} defaultProfile to be used if the profile is not found + * @property {?setPrebidTargetingCallback|?boolean|?Object} setPrebidTargeting if true, will set the GAM targeting (default undefined) + * @property {?sendToBiddersCallback|?boolean|?Object} sendToBidders if true, will send the contextual profile to all bidders, else expects a list of allowed bidders (default undefined) + * @property {?Profile} defaultProfile to be used if the profile is not found * @property {?dataCallback} onData callback * @property {?string} localStorageProfileKey can be used to customize the local storage key (default is 'webo_wam2gam_entry') - * @property {?Boolean} enabled if false, will ignore this configuration + * @property {?boolean} enabled if false, will ignore this configuration + */ + +/** + * @typedef {Object} SfbxLiteDataConf + * @property {?setPrebidTargetingCallback|?boolean|?Object} setPrebidTargeting if true, will set the GAM targeting (default undefined) + * @property {?sendToBiddersCallback|?boolean|?Object} sendToBidders if true, will send the contextual profile to all bidders, else expects a list of allowed bidders (default undefined) + * @property {?Profile} defaultProfile to be used if the profile is not found + * @property {?dataCallback} onData callback + * @property {?string} localStorageProfileKey can be used to customize the local storage key (default is '_lite') + * @property {?boolean} enabled if false, will ignore this configuration + */ + +/** common configuration between contextual, wam and sfbx + * @typedef {WeboCtxConf|WeboUserDataConf|SfbxLiteDataConf} CommonConf */ import { getGlobal } from '../src/prebidGlobal.js'; import { + deepClone, deepSetValue, - deepAccess, isEmpty, - mergeDeep, + isFn, logError, - logWarn, - tryAppendQueryString, logMessage, - isFn + isArray, + isStr, + isBoolean, + isPlainObject, + logWarn, + mergeDeep } from '../src/utils.js'; import { submodule @@ -68,552 +120,863 @@ import { import { getStorageManager } from '../src/storageManager.js'; - -const adapterManager = require('../src/adapterManager.js').default; +import adapterManager from '../src/adapterManager.js'; +import {MODULE_TYPE_RTD} from '../src/activities/modules.js'; +import {tryAppendQueryString} from '../libraries/urlUtils/urlUtils.js'; /** @type {string} */ const MODULE_NAME = 'realTimeData'; /** @type {string} */ const SUBMODULE_NAME = 'weborama'; /** @type {string} */ +const BASE_URL_CONTEXTUAL_PROFILE_API = 'ctx.weborama.com'; +/** @type {string} */ export const DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY = 'webo_wam2gam_entry'; /** @type {string} */ const LOCAL_STORAGE_USER_TARGETING_SECTION = 'targeting'; +/** @type {string} */ +export const DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY = '_lite'; +/** @type {string} */ +const LOCAL_STORAGE_LITE_TARGETING_SECTION = 'webo'; +/** @type {string} */ +const WEBO_CTX_CONF_SECTION = 'weboCtxConf'; +/** @type {string} */ +const WEBO_USER_DATA_CONF_SECTION = 'weboUserDataConf'; +/** @type {string} */ +const SFBX_LITE_DATA_CONF_SECTION = 'sfbxLiteDataConf'; +/** @type {string} */ +const WEBO_CTX_SOURCE_LABEL = 'contextual'; +/** @type {string} */ +const WEBO_USER_DATA_SOURCE_LABEL = 'wam'; +/** @type {string} */ +const SFBX_LITE_DATA_SOURCE_LABEL = 'lite'; /** @type {number} */ const GVLID = 284; -/** @type {object} */ -export const storage = getStorageManager({gvlid: GVLID, moduleName: SUBMODULE_NAME}); -/** @type {null|Object} */ -let _weboContextualProfile = null; +export const storage = getStorageManager({ + moduleType: MODULE_TYPE_RTD, + moduleName: SUBMODULE_NAME +}); -/** @type {Boolean} */ -let _weboCtxInitialized = false; - -/** @type {null|Object} */ -let _weboUserDataUserProfile = null; +/** + * @typedef {Object} Component + * @property {boolean} initialized + * @property {?Profile} data + * @property {boolean} user if true it is user-centric data + * @property {string} source describe the source of data, if 'contextual' or 'wam' + * @property {buildProfileHandlerCallbackBuilder} callbackBuilder + */ -/** @type {Boolean} */ -let _weboUserDataInitialized = false; +/** + * @typedef {Object} Components + * @property {Component} WeboCtx + * @property {Component} WeboUserData + * @property {Component} SfbxLiteData + */ -/** Initialize module - * @param {object} moduleConfig - * @return {Boolean} true if module was initialized with success +/** + * @classdesc Weborama Real Time Data Provider + * @class */ -function init(moduleConfig) { - moduleConfig = moduleConfig || {}; - const moduleParams = moduleConfig.params || {}; - const weboCtxConf = moduleParams.weboCtxConf; - const weboUserDataConf = moduleParams.weboUserDataConf; +class WeboramaRtdProvider { + #components; + name = SUBMODULE_NAME; + gvlid = GVLID; + /** + * @param {Components} components + */ + constructor(components) { + this.#components = components; + } + /** Initialize module + * @method + * @param {Object} moduleConfig + * @param {?ModuleParams} moduleConfig.params + * @return {boolean} true if module was initialized with success + */ + init(moduleConfig) { + /** @type {Object} */ + const globalDefaults = { + setPrebidTargeting: true, + sendToBidders: true, + onData: () => { + /* do nothing */ + } + }; + /** @type {ModuleParams} */ + const moduleParams = Object.assign({}, globalDefaults, moduleConfig?.params || {}); - _weboCtxInitialized = initWeboCtx(moduleParams, weboCtxConf); - _weboUserDataInitialized = initWeboUserData(moduleParams, weboUserDataConf); + // reset profiles - return _weboCtxInitialized || _weboUserDataInitialized; -} + this.#components.WeboCtx.data = null; + this.#components.WeboUserData.data = null; + this.#components.SfbxLiteData.data = null; -/** Initialize contextual sub module - * @param {ModuleParams} moduleParams - * @param {WeboCtxConf} weboCtxConf - * @return {Boolean} true if sub module was initialized with success - */ -function initWeboCtx(moduleParams, weboCtxConf) { - if (!weboCtxConf || weboCtxConf.enabled === false) { - moduleParams.weboCtxConf = null; + this.#components.WeboCtx.initialized = this.#initSubSection(moduleParams, WEBO_CTX_CONF_SECTION, 'token'); + this.#components.WeboUserData.initialized = this.#initSubSection(moduleParams, WEBO_USER_DATA_CONF_SECTION); + this.#components.SfbxLiteData.initialized = this.#initSubSection(moduleParams, SFBX_LITE_DATA_CONF_SECTION); - return false + return Object.values(this.#components).some((c) => c.initialized); } - normalizeConf(moduleParams, weboCtxConf); + /** function that will allow RTD sub-modules to modify the AdUnit object for each auction + * @method + * @param {Object} reqBidsConfigObj + * @param {doneCallback} onDone + * @param {Object} moduleConfig + * @param {?ModuleParams} moduleConfig.params + * @returns {void} + */ + getBidRequestData(reqBidsConfigObj, onDone, moduleConfig) { + /** @type {ModuleParams} */ + const moduleParams = moduleConfig?.params || {}; + + if (!this.#components.WeboCtx.initialized) { + this.#handleBidRequestData(reqBidsConfigObj, moduleParams); - _weboCtxInitialized = false; - _weboContextualProfile = null; + onDone(); - if (!weboCtxConf.token) { - logWarn('missing param "token" for weborama contextual sub module initialization'); - return false; - } + return; + } - logMessage('weborama contextual intialized with success'); + /** @type {WeboCtxConf} */ + const weboCtxConf = moduleParams.weboCtxConf || {}; - return true; -} + this.#fetchContextualProfile(weboCtxConf, (data) => { + logMessage('fetchContextualProfile on getBidRequestData is done'); -/** Initialize weboUserData sub module - * @param {ModuleParams} moduleParams - * @param {WeboUserDataConf} weboUserDataConf - * @return {Boolean} true if sub module was initialized with success - */ -function initWeboUserData(moduleParams, weboUserDataConf) { - if (!weboUserDataConf || weboUserDataConf.enabled === false) { - moduleParams.weboUserDataConf = null; + this.#setWeboContextualProfile(data); + }, () => { + this.#handleBidRequestData(reqBidsConfigObj, moduleParams); - return false; + onDone(); + }); } - normalizeConf(moduleParams, weboUserDataConf); - - _weboUserDataInitialized = false; - _weboUserDataUserProfile = null; + /** function that provides ad server targeting data to RTD-core + * @method + * @param {string[]} adUnitsCodes + * @param {Object} moduleConfig + * @param {?ModuleParams} moduleConfig.params + * @returns {Object} target data + */ + getTargetingData(adUnitsCodes, moduleConfig) { + /** @type {ModuleParams} */ + const moduleParams = moduleConfig?.params || {}; + + const profileHandlers = this.#buildProfileHandlers(moduleParams); + + if (isEmpty(profileHandlers)) { + logMessage('no data to set targeting'); + return {}; + } - let message = 'weborama user-centric intialized with success'; - if (weboUserDataConf.hasOwnProperty('accountId')) { - message = `weborama user-centric intialized with success for account: ${weboUserDataConf.accountId}`; - } + try { + return adUnitsCodes.reduce((data, adUnitCode) => { + data[adUnitCode] = profileHandlers.reduce((targeting, ph) => { + // logMessage(`check if should set targeting for adunit '${adUnitCode}'`); + const [data, metadata] = this.#copyDataAndMetadata(ph); + if (ph.setTargeting(adUnitCode, data, metadata)) { + // logMessage(`set targeting for adunit '${adUnitCode}', source '${metadata.source}'`); - logMessage(message); + mergeDeep(targeting, data); + } - return true; -} + return targeting; + }, {}); -/** @type {Object} */ -const globalDefaults = { - setPrebidTargeting: true, - sendToBidders: true, - onData: (data, kind, def) => logMessage('onData(data,kind,default)', data, kind, def), -} + return data; + }, {}); + } catch (e) { + logError(`unable to format weborama rtd targeting data:`, e); -/** normalize submodule configuration - * @param {ModuleParams} moduleParams - * @param {WeboCtxConf|WeboUserDataConf} submoduleParams - * @return {void} - */ -function normalizeConf(moduleParams, submoduleParams) { - Object.entries(globalDefaults).forEach(([propertyName, globalDefaultValue]) => { - if (!submoduleParams.hasOwnProperty(propertyName)) { - const hasModuleParam = moduleParams.hasOwnProperty(propertyName); - submoduleParams[propertyName] = (hasModuleParam) ? moduleParams[propertyName] : globalDefaultValue; + return {}; } - }) -} + } -/** function that provides ad server targeting data to RTD-core - * @param {Array} adUnitsCodes - * @param {Object} moduleConfig - * @returns {Object} target data - */ -function getTargetingData(adUnitsCodes, moduleConfig) { - moduleConfig = moduleConfig || {}; - const moduleParams = moduleConfig.params || {}; - const weboCtxConf = moduleParams.weboCtxConf || {}; - const weboUserDataConf = moduleParams.weboUserDataConf || {}; - const weboCtxConfTargeting = weboCtxConf.setPrebidTargeting; - const weboUserDataConfTargeting = weboUserDataConf.setPrebidTargeting; - - try { - const profile = getCompleteProfile(moduleParams, weboCtxConfTargeting, weboUserDataConfTargeting); - - if (isEmpty(profile)) { - return {}; + /** Initialize subsection module + * @method + * @private + * @param {ModuleParams} moduleParams + * @param {string} subSection subsection name to initialize + * @param {string[]} requiredFields + * @return {boolean} true if module subsection was initialized with success + */ + #initSubSection(moduleParams, subSection, ...requiredFields) { + /** @type {CommonConf} */ + const weboSectionConf = moduleParams[subSection] || { enabled: false }; + + if (weboSectionConf.enabled === false) { + delete moduleParams[subSection]; + + return false; } - const td = adUnitsCodes.reduce((data, adUnitCode) => { - if (adUnitCode) { - data[adUnitCode] = profile; - } - return data; - }, {}); + try { + this.#normalizeConf(moduleParams, weboSectionConf); - return td; - } catch (e) { - logError('unable to format weborama rtd targeting data', e); - return {}; - } -} + requiredFields.forEach(field => { + if (!(field in weboSectionConf)) { + throw `missing required field '${field}''`; + } + }); + } catch (e) { + logError(`unable to initialize: error on ${subSection} configuration:`, e); + return false; + } -/** function that provides complete profile formatted to be used - * @param {ModuleParams} moduleParams - * @param {Boolean} weboCtxConfTargeting - * @param {Boolean} weboUserDataConfTargeting - * @returns {Object} complete profile - */ -function getCompleteProfile(moduleParams, weboCtxConfTargeting, weboUserDataConfTargeting) { - const profile = {}; + logMessage(`weborama ${subSection} initialized with success`); - if (weboCtxConfTargeting) { - const contextualProfile = getContextualProfile(moduleParams.weboCtxConf || {}); - mergeDeep(profile, contextualProfile); + return true; } - if (weboUserDataConfTargeting) { - const weboUserDataProfile = getWeboUserDataProfile(moduleParams.weboUserDataConf || {}); - mergeDeep(profile, weboUserDataProfile); - } + /** normalize submodule configuration + * @method + * @private + * @param {ModuleParams} moduleParams + * @param {CommonConf} submoduleParams + * @return {void} + * @throws will throw an error in case of invalid configuration + */ + // eslint-disable-next-line no-dupe-class-members + #normalizeConf(moduleParams, submoduleParams) { + submoduleParams.defaultProfile = submoduleParams.defaultProfile || {}; - return profile; -} + const { setPrebidTargeting, sendToBidders, onData } = moduleParams; -/** return contextual profile - * @param {WeboCtxConf} weboCtxConf - * @returns {Object} contextual profile - */ -function getContextualProfile(weboCtxConf) { - const defaultContextualProfile = weboCtxConf.defaultProfile || {}; - return _weboContextualProfile || defaultContextualProfile; -} + submoduleParams.setPrebidTargeting ??= setPrebidTargeting; + submoduleParams.sendToBidders ??= sendToBidders; + submoduleParams.onData ??= onData; -/** return weboUserData profile - * @param {WeboUserDataConf} weboUserDataConf - * @returns {Object} weboUserData profile - */ -function getWeboUserDataProfile(weboUserDataConf) { - const weboUserDataDefaultUserProfile = weboUserDataConf.defaultProfile || {}; + // handle setPrebidTargeting + this.#coerceSetPrebidTargeting(submoduleParams); - if (storage.localStorageIsEnabled() && !_weboUserDataUserProfile) { - const localStorageProfileKey = weboUserDataConf.localStorageProfileKey || DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY; + // handle sendToBidders + this.#coerceSendToBidders(submoduleParams); - const entry = storage.getDataFromLocalStorage(localStorageProfileKey); - if (entry) { - const data = JSON.parse(entry); - if (data && Object.keys(data).length > 0) { - _weboUserDataUserProfile = data[LOCAL_STORAGE_USER_TARGETING_SECTION]; - } + if (!isFn(submoduleParams.onData)) { + throw 'onData parameter should be a callback'; + } + + if (!isValidProfile(submoduleParams.defaultProfile)) { + throw 'defaultProfile is not valid'; } } - return _weboUserDataUserProfile || weboUserDataDefaultUserProfile; -} + /** coerce setPrebidTargeting to a callback + * @method + * @private + * @param {CommonConf} submoduleParams + * @return {void} + * @throws will throw an error in case of invalid configuration + */ + // eslint-disable-next-line no-dupe-class-members + #coerceSetPrebidTargeting(submoduleParams) { + try { + submoduleParams.setPrebidTargeting = this.#wrapValidatorCallback(submoduleParams.setPrebidTargeting); + } catch (e) { + throw `invalid setPrebidTargeting: ${e}`; + } + } -/** function that will allow RTD sub-modules to modify the AdUnit object for each auction - * @param {Object} reqBidsConfigObj - * @param {doneCallback} onDone - * @param {Object} moduleConfig - * @returns {void} - */ -export function getBidRequestData(reqBidsConfigObj, onDone, moduleConfig) { - moduleConfig = moduleConfig || {}; - const moduleParams = moduleConfig.params || {}; - const weboCtxConf = moduleParams.weboCtxConf || {}; + /** coerce sendToBidders to a callback + * @method + * @private + * @param {CommonConf} submoduleParams + * @return {void} + * @throws will throw an error in case of invalid configuration + */ + // eslint-disable-next-line no-dupe-class-members + #coerceSendToBidders(submoduleParams) { + let sendToBidders = submoduleParams.sendToBidders; + + if (isPlainObject(sendToBidders)) { + const sendToBiddersMap = Object.entries(sendToBidders).reduce((map, [key, value]) => { + map[key] = this.#wrapValidatorCallback(value); + return map; + }, {}); + + submoduleParams.sendToBidders = (bid, adUnitCode) => { + const bidder = bid.bidder; + if (!(bidder in sendToBiddersMap)) { + return false; + } - const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; + const validatorCallback = sendToBiddersMap[bidder]; - if (!_weboCtxInitialized) { - handleBidRequestData(adUnits, moduleParams); + try { + return validatorCallback(adUnitCode); + } catch (e) { + throw `invalid sendToBidders[${bidder}]: ${e}`; + } + }; - onDone(); + return; + } - return; + try { + submoduleParams.sendToBidders = this.#wrapValidatorCallback(submoduleParams.sendToBidders, + (bid) => bid.bidder); + } catch (e) { + throw `invalid sendToBidders: ${e}`; + } } - fetchContextualProfile(weboCtxConf, (data) => { - logMessage('fetchContextualProfile on getBidRequestData is done'); + /** + * @typedef {Object} AdUnit + * @property {Object[]} bids + */ + /** function that handles bid request data + * @method + * @private + * @param {Object} reqBidsConfigObj + * @param {AdUnit[]} reqBidsConfigObj.adUnits + * @param {Object} reqBidsConfigObj.ortb2Fragments + * @param {Object} reqBidsConfigObj.ortb2Fragments.bidder + * @param {ModuleParams} moduleParams + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #handleBidRequestData(reqBidsConfigObj, moduleParams) { + const profileHandlers = this.#buildProfileHandlers(moduleParams); + + if (isEmpty(profileHandlers)) { + logMessage('no data to send to bidders'); + return; + } - setWeboContextualProfile(data); - }, () => { - handleBidRequestData(adUnits, moduleParams); + const adUnits = reqBidsConfigObj.adUnits || getGlobal().adUnits; - onDone(); - }); -} + try { + adUnits.forEach( + adUnit => adUnit.bids?.forEach( + bid => profileHandlers.forEach(ph => { + // logMessage(`check if bidder '${bid.bidder}' and adunit '${adUnit.code} are share ${ph.metadata.source} data`); + + const [data, metadata] = this.#copyDataAndMetadata(ph); + if (ph.sendToBidders(bid, adUnit.code, data, metadata)) { + // logMessage(`handling bidder '${bid.bidder}' with ${ph.metadata.source} data`); + + this.#handleBid(reqBidsConfigObj, bid, data, ph.metadata); + } + }) + ) + ); + } catch (e) { + logError('unable to send data to bidders:', e); + } -/** function that handles bid request data - * @param {Object[]} adUnits - * @param {ModuleParams} moduleParams - * @returns {void} - */ + profileHandlers.forEach(ph => { + try { + const [data, metadata] = this.#copyDataAndMetadata(ph); + ph.onData(data, metadata); + } catch (e) { + logError(`error while execute onData callback with ${ph.metadata.source}-based data:`, e); + } + }); + } -function handleBidRequestData(adUnits, moduleParams) { - const weboCtxConf = moduleParams.weboCtxConf || {}; - const weboUserDataConf = moduleParams.weboUserDataConf || {}; - const weboCtxConfTargeting = weboCtxConf.sendToBidders; - const weboUserDataConfTargeting = weboUserDataConf.sendToBidders; + /** onSuccess callback type + * @callback successCallback + * @param {?Object} data + * @returns {void} + */ + + /** onDone callback type + * @callback doneCallback + * @returns {void} + */ + + /** Fetch Bigsea Contextual Profile + * @method + * @private + * @param {WeboCtxConf} weboCtxConf + * @param {successCallback} onSuccess callback + * @param {doneCallback} onDone callback + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #fetchContextualProfile(weboCtxConf, onSuccess, onDone) { + const token = weboCtxConf.token; + const baseURLProfileAPI = weboCtxConf.baseURLProfileAPI || BASE_URL_CONTEXTUAL_PROFILE_API; + + let path = '/profile'; + let queryString = ''; + queryString = tryAppendQueryString(queryString, 'token', token); + + if (weboCtxConf.assetID) { + path = '/document-profile'; + + let assetID = weboCtxConf.assetID; + if (isFn(assetID)) { + try { + assetID = weboCtxConf.assetID(); + } catch (e) { + logError('unexpected error while fetching asset id from callback', e); - if (weboCtxConfTargeting) { - const contextualProfile = getContextualProfile(weboCtxConf); - if (!isEmpty(contextualProfile)) { - setBidRequestProfile(adUnits, contextualProfile, true); - } - } + onDone(); - if (weboUserDataConfTargeting) { - const weboUserDataProfile = getWeboUserDataProfile(weboUserDataConf); - if (!isEmpty(weboUserDataProfile)) { - setBidRequestProfile(adUnits, weboUserDataProfile, false); - } - } + return; + } + } - handleOnData(weboCtxConf, weboUserDataConf); -} + if (!assetID) { + logError('missing asset id'); -/** function that handle with onData callbacks - * @param {WeboCtxConf} weboCtxConf - * @param {WeboUserDataConf} weboUserDataConf - */ + onDone(); -function handleOnData(weboCtxConf, weboUserDataConf) { - const callbacks = [{ - onData: weboCtxConf.onData, - fetchData: () => getContextualProfile(weboCtxConf), - site: true, - }, { - onData: weboUserDataConf.onData, - fetchData: () => getWeboUserDataProfile(weboUserDataConf), - site: false, - }]; - - callbacks.filter(obj => isFn(obj.onData)).forEach(obj => { - try { - const data = obj.fetchData(); - obj.onData(data, obj.site); - } catch (e) { - const kind = (obj.site) ? 'site' : 'user'; - logError(`error while executure onData callback with ${kind}-based data:`, e); + return; + } + + queryString = tryAppendQueryString(queryString, 'assetId', assetID); } - }); -} -/** function that set bid request data on each segment (site or user centric) - * @param {Object[]} adUnits - * @param {Object} profile - * @param {Boolean} site true if site centric, else it is user centric - * @returns {void} - */ -function setBidRequestProfile(adUnits, profile, site) { - setGlobalOrtb2(profile, site); + const targetURL = weboCtxConf.targetURL || document.URL; + queryString = tryAppendQueryString(queryString, 'url', targetURL); - adUnits.forEach(adUnit => { - if (adUnit.hasOwnProperty('bids')) { - const adUnitCode = adUnit.code || 'no code'; - adUnit.bids.forEach(bid => handleBid(adUnitCode, profile, site, bid)); - } - }); -} + const urlProfileAPI = `https://${baseURLProfileAPI}/api${path}?${queryString}`; -/** @type {string} */ -const APPNEXUS = 'appnexus'; + const success = (response, req) => { + if (req.status === 200) { + const data = JSON.parse(response); + onSuccess(data); + } else { + throw `unexpected http status response ${req.status} with response ${response}`; + } -/** @type {string} */ -const PUBMATIC = 'pubmatic'; + onDone(); + }; -/** @type {string} */ -const RUBICON = 'rubicon'; + const error = (e, req) => { + logError(`unable to get weborama data`, e, req); -/** @type {string} */ -const SMARTADSERVER = 'smartadserver'; + onDone(); + }; -/** @type {Object} */ -const bidderAliasRegistry = adapterManager.aliasRegistry || {}; + const callback = { + success, + error, + }; -/** handle individual bid - * @param {string} adUnitCode - * @param {Object} profile - * @param {Boolean} site true if site centric, else it is user centric - * @param {Object} bid - * @returns {void} - */ -function handleBid(adUnitCode, profile, site, bid) { - const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder; + const options = { + method: 'GET', + withCredentials: false, + }; - logMessage(`handling on adunit '${adUnitCode}', bidder '${bidder}' and bid`, bid); + ajax(urlProfileAPI, callback, null, options); + } + + /** set bigsea contextual profile on module state + * @method + * @private + * @param {?Object} data + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #setWeboContextualProfile(data) { + if (data && isPlainObject(data) && isValidProfile(data) && !isEmpty(data)) { + this.#components.WeboCtx.data = data; + } + } - switch (bidder) { - case APPNEXUS: - handleAppnexusBid(profile, bid); + /** function that provides data handlers based on the configuration + * @method + * @private + * @param {ModuleParams} moduleParams + * @returns {ProfileHandler[]} + */ + // eslint-disable-next-line no-dupe-class-members + #buildProfileHandlers(moduleParams) { + const steps = [{ + component: this.#components.WeboCtx, + conf: moduleParams?.weboCtxConf, + }, { + component: this.#components.WeboUserData, + conf: moduleParams?.weboUserDataConf, + }, { + component: this.#components.SfbxLiteData, + conf: moduleParams?.sfbxLiteDataConf, + }]; + + return steps.filter(step => step.component.initialized).reduce((ph, { component, conf }) => { + const user = component.user; + const source = component.source; + const callback = component.callbackBuilder(component /* equivalent to this */); + const profileHandler = this.#buildProfileHandler(conf, callback, user, source); + if (profileHandler) { + ph.push(profileHandler); + } else { + logMessage(`skip ${source} profile: no data`); + } - break; + return ph; + }, []); + } - case PUBMATIC: - handlePubmaticBid(profile, bid); + /** + * @typedef {Object} ProfileHandler + * @property {Profile} data + * @property {dataCallbackMetadata} metadata + * @property {setPrebidTargetingCallback} setTargeting + * @property {sendToBiddersCallback} sendToBidders + * @property {dataCallback} onData + */ + + /** + * @callback buildProfileHandlerCallbackBuilder + * @param {Component} component + * @returns {buildProfileHandlerCallback} + */ + + /** + * @callback buildProfileHandlerCallback + * @param {CommonConf} dataConf + * @returns {[Profile,boolean]} profile + is default flag + */ + + /** + * return specific profile handler + * @method + * @private + * @param {CommonConf} dataConf + * @param {buildProfileHandlerCallback} callback + * @param {boolean} user + * @param {string} source + * @returns {ProfileHandler} + */ + // eslint-disable-next-line no-dupe-class-members + #buildProfileHandler(dataConf, callback, user, source) { + if (!dataConf) { + return; + } - break; + const [data, isDefault] = callback(dataConf); + if (isEmpty(data)) { + return; + } - case SMARTADSERVER: - handleSmartadserverBid(profile, bid); + return { + data: data, + metadata: { + user: user, + source: source, + isDefault: !!isDefault, + }, + setTargeting: dataConf.setPrebidTargeting, + sendToBidders: dataConf.sendToBidders, + onData: dataConf.onData, + }; + } + /** handle individual bid + * @method + * @private + * @param {Object} reqBidsConfigObj + * @param {Object} reqBidsConfigObj.ortb2Fragments + * @param {Object} reqBidsConfigObj.ortb2Fragments.bidder + * @param {Object} bid + * @param {string} bid.bidder + * @param {Profile} profile + * @param {dataCallbackMetadata} metadata + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #handleBid(reqBidsConfigObj, bid, profile, metadata) { + this.#handleBidViaORTB2(reqBidsConfigObj, bid.bidder, profile, metadata); + + /** @type {Object.} */ + const bidderAliasRegistry = adapterManager.aliasRegistry || {}; + + /** @type {string} */ + const bidder = bidderAliasRegistry[bid.bidder] || bid.bidder; + + if (bidder == 'appnexus') { + this.#handleAppnexusBid(reqBidsConfigObj, bid, profile); + } + } - break; - case RUBICON: - handleRubiconBid(profile, site, bid); + /** function that handles bid request data + * @method + * @private + * @param {ProfileHandler} ph profile handler + * @returns {[Profile,dataCallbackMetadata]} deeply copy data + metadata + */ + // eslint-disable-next-line no-dupe-class-members + #copyDataAndMetadata(ph) { + return [deepClone(ph.data), deepClone(ph.metadata)]; + } - break; - default: - logMessage(`unsupported bidder '${bidder}', trying via bidder ortb2 fpd`); - const section = ((site) ? 'site' : 'user'); - const base = `ortb2.${section}.ext.data`; + /** handle appnexus/xandr bid + * @method + * @private + * @param {Object} reqBidsConfigObj + * @param {Object} reqBidsConfigObj.ortb2Fragments + * @param {Object} reqBidsConfigObj.ortb2Fragments.bidder + * @param {Object} bid + * @param {Object} bid.parameters + * @param {Profile} profile + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #handleAppnexusBid(reqBidsConfigObj, bid, profile) { + const base = 'params.keywords'; + this.#assignProfileToObject(bid, base, profile); + // this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bid.bidder, base, profile); + } - assignProfileToObject(bid, base, profile); + /** handle generic bid via ortb2 arbitrary data + * @method + * @private + * @param {Object} reqBidsConfigObj + * @param {Object} reqBidsConfigObj.ortb2Fragments + * @param {Object} reqBidsConfigObj.ortb2Fragments.bidder + * @param {string} bidder + * @param {Profile} profile + * @param {dataCallbackMetadata} metadata + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #handleBidViaORTB2(reqBidsConfigObj, bidder, profile, metadata) { + if (isBoolean(metadata.user)) { + logMessage(`bidder '${bidder}' is not directly supported, trying set data via bidder ortb2 fpd`); + const section = metadata.user ? 'user' : 'site'; + const path = `${section}.ext.data`; + + this.#setBidderOrtb2(reqBidsConfigObj.ortb2Fragments?.bidder, bidder, path, profile) + } else { + logMessage(`SKIP unsupported bidder '${bidder}', data from '${metadata.source}' is not defined as user or site-centric`); + } + } + /** + * set bidder ortb2 data + * @method + * @private + * @param {Object} bidderOrtb2Fragments + * @param {string} bidder + * @param {string} path + * @param {Profile} profile + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #setBidderOrtb2(bidderOrtb2Fragments, bidder, path, profile) { + const base = `${bidder}.${path}`; + this.#assignProfileToObject(bidderOrtb2Fragments, base, profile) + } + /** + * assign profile to object + * @method + * @private + * @param {Object} destination + * @param {string} base + * @param {Profile} profile + * @returns {void} + */ + // eslint-disable-next-line no-dupe-class-members + #assignProfileToObject(destination, base, profile) { + Object.entries(profile).forEach(([key, values]) => { + const path = `${base}.${key}`; + deepSetValue(destination, path, values); + }) } -} -/** - * set ortb2 global data - * @param {Object} profile - * @param {Boolean} site - * @returns {void} - */ -function setGlobalOrtb2(profile, site) { - const section = ((site) ? 'site' : 'user'); - const base = `${section}.ext.data`; - const addOrtb2 = {}; + /** + * @callback validatorCallback + * @param {string} target + * @returns {boolean} + */ + + /** + * @callback coerceCallback + * @param {*} input + * @returns {*} + */ + + /** + * wrap value into validator + * @method + * @private + * @param {*} value + * @param {coerceCallback} coerce + * @returns {validatorCallback} + * @throws will throw an error in case of unsupported type + */ + // eslint-disable-next-line no-dupe-class-members + #wrapValidatorCallback(value, coerce = (x) => x) { + if (isFn(value)) { + return value; + } - assignProfileToObject(addOrtb2, base, profile); + if (isBoolean(value)) { + return (_) => value; + } - if (!isEmpty(addOrtb2)) { - const testGlobal = getGlobal().getConfig('ortb2') || {}; - const ortb2 = { - ortb2: mergeDeep({}, testGlobal, addOrtb2) - }; - getGlobal().setConfig(ortb2); + if (isStr(value)) { + return (target) => { + return value == coerce(target); + }; + } + + if (isArray(value)) { + return (target) => { + return value.includes(coerce(target)); + }; + } + + throw `unexpected format: ${typeof value} (expects function, boolean, string or array)`; } } /** - * assign profile to object - * @param {Object} destination - * @param {string} base - * @param {Object} profile - * @returns {void} + * check if profile is valid + * @param {*} profile + * @returns {boolean} */ -function assignProfileToObject(destination, base, profile) { - Object.keys(profile).forEach(key => { - const path = `${base}.${key}`; - deepSetValue(destination, path, profile[key]) - }) -} - -/** handle rubicon bid - * @param {Object} profile - * @param {Boolean} site - * @param {Object} bid - * @returns {void} - */ -function handleRubiconBid(profile, site, bid) { - const section = (site) ? 'inventory' : 'visitor'; - const base = `params.${section}`; - assignProfileToObject(bid, base, profile); -} +export function isValidProfile(profile) { + if (!isPlainObject(profile)) { + return false; + } -/** handle appnexus/xandr bid - * @param {Object} profile - * @param {Object} bid - * @returns {void} - */ -function handleAppnexusBid(profile, bid) { - const base = 'params.keywords'; - assignProfileToObject(bid, base, profile); + return Object.values(profile).every((field) => isArray(field) && field.every(isStr)); } -/** handle pubmatic bid - * @param {Object} profile - * @param {Object} bid - * @returns {void} +/** + * bind callback with component + * @param {Component} component + * @returns {buildProfileHandlerCallback} */ -function handlePubmaticBid(profile, bid) { - const sep = '|'; - const subsep = ','; - const bidKey = 'params.dctr'; - const target = []; - - const data = deepAccess(bid, bidKey); - if (data) { - data.split(sep).forEach(t => target.push(t)); - } - - Object.keys(profile).forEach(key => { - const value = profile[key].join(subsep); - const keyword = `${key}=${value}`; - if (target.indexOf(keyword) === -1) { - target.push(keyword); +function getContextualProfile(component /* equivalent to this */) { + /** return contextual profile + * @param {WeboCtxConf} weboCtxConf + * @returns {[Profile,boolean]} contextual profile + isDefault boolean flag + */ + return function (weboCtxConf) { + if (component.data) { + return [component.data, false]; } - }); - deepSetValue(bid, bidKey, target.join(sep)); + const defaultContextualProfile = weboCtxConf.defaultProfile || {}; + + return [defaultContextualProfile, true]; + } } -/** handle smartadserver bid - * @param {Object} profile - * @param {Object} bid - * @returns {void} +/** + * bind callback with component + * @param {Component} component + * @returns {buildProfileHandlerCallback} */ -function handleSmartadserverBid(profile, bid) { - const sep = ';'; - const bidKey = 'params.target'; - const target = []; - - const data = deepAccess(bid, bidKey); - if (data) { - data.split(sep).forEach(t => target.push(t)); +function getWeboUserDataProfile(component /* equivalent to this */) { + /** return weboUserData profile + * @param {WeboUserDataConf} weboUserDataConf + * @returns {[Profile,boolean]} weboUserData profile + isDefault boolean flag + */ + return function (weboUserDataConf) { + return getDataFromLocalStorage(weboUserDataConf, + () => component.data, + (data) => component.data = data, + DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY, + LOCAL_STORAGE_USER_TARGETING_SECTION, + WEBO_USER_DATA_SOURCE_LABEL); } - - Object.keys(profile).forEach(key => { - profile[key].forEach(value => { - const keyword = `${key}=${value}`; - if (target.indexOf(keyword) === -1) { - target.push(keyword); - } - }); - }); - deepSetValue(bid, bidKey, target.join(sep)); } -/** set bigsea contextual profile on module state - * @param {null|Object} data - * @returns {void} +/** + * bind callback with component + * @param {Component} component + * @returns {buildProfileHandlerCallback} */ -export function setWeboContextualProfile(data) { - if (data && Object.keys(data).length > 0) { - _weboContextualProfile = data; +function getSfbxLiteDataProfile(component /* equivalent to this */) { + /** return weboUserData profile + * @param {SfbxLiteDataConf} sfbxLiteDataConf + * @returns {[Profile,boolean]} sfbxLiteData profile + isDefault boolean flag + */ + return function getSfbxLiteDataProfile(sfbxLiteDataConf) { + return getDataFromLocalStorage(sfbxLiteDataConf, + () => component.data, + (data) => component.data = data, + DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY, + LOCAL_STORAGE_LITE_TARGETING_SECTION, + SFBX_LITE_DATA_SOURCE_LABEL); } } -/** onSuccess callback type - * @callback successCallback - * @param {null|Object} data - * @returns {void} +/** + * @callback cacheGetCallback + * @returns {Profile} */ - -/** onDone callback type - * @callback doneCallback +/** + * @callback cacheSetCallback + * @param {Profile} profile * @returns {void} */ -/** Fetch Bigsea Contextual Profile - * @param {WeboCtxConf} weboCtxConf - * @param {successCallback} onSuccess callback - * @param {doneCallback} onDone callback - * @returns {void} +/** return generic webo data profile + * @param {WeboUserDataConf|SfbxLiteDataConf} weboDataConf + * @param {cacheGetCallback} cacheGet + * @param {cacheSetCallback} cacheSet + * @param {string} defaultLocalStorageProfileKey + * @param {string} targetingSection + * @param {string} source + * @returns {[Profile,boolean]} webo (user|lite) data profile + isDefault boolean flag */ -function fetchContextualProfile(weboCtxConf, onSuccess, onDone) { - const targetURL = weboCtxConf.targetURL || document.URL; - const token = weboCtxConf.token; +function getDataFromLocalStorage(weboDataConf, cacheGet, cacheSet, defaultLocalStorageProfileKey, targetingSection, source) { + const defaultProfile = weboDataConf.defaultProfile || {}; - let queryString = ''; - queryString = tryAppendQueryString(queryString, 'token', token); - queryString = tryAppendQueryString(queryString, 'url', targetURL); + if (storage.hasLocalStorage() && storage.localStorageIsEnabled() && !cacheGet()) { + const localStorageProfileKey = weboDataConf.localStorageProfileKey || defaultLocalStorageProfileKey; - const url = `https://ctx.weborama.com/api/profile?${queryString}`; + const entry = storage.getDataFromLocalStorage(localStorageProfileKey); + if (entry) { + const data = JSON.parse(entry); + if (data && isPlainObject(data) && targetingSection in data) { + /** @type {profile} */ + const profile = data[targetingSection]; + const valid = isValidProfile(profile); + if (!valid) { + logWarn(`found invalid ${source} profile on local storage key ${localStorageProfileKey}, section ${targetingSection}`); + + return; + } - ajax(url, { - success: function(response, req) { - if (req.status === 200) { - try { - const data = JSON.parse(response); - onSuccess(data); - onDone(); - } catch (e) { - onDone(); - logError('unable to parse weborama data', e); - throw e; + if (!isEmpty(data)) { + cacheSet(profile); } - } else if (req.status === 204) { - onDone(); } - }, - error: function() { - onDone(); - logError('unable to get weborama data'); } - }, - null, { - method: 'GET', - withCredentials: false, - }); -} + } + + const profile = cacheGet(); -export const weboramaSubmodule = { - name: SUBMODULE_NAME, - init: init, - getTargetingData: getTargetingData, - getBidRequestData: getBidRequestData, + if (profile) { + return [profile, false]; + } + + return [defaultProfile, true]; +} +/** @type {Components} */ +const components = { + WeboCtx: { + initialized: false, + data: null, + user: false, + source: WEBO_CTX_SOURCE_LABEL, + callbackBuilder: getContextualProfile, + }, + WeboUserData: { + initialized: false, + data: null, + user: true, + source: WEBO_USER_DATA_SOURCE_LABEL, + callbackBuilder: getWeboUserDataProfile, + }, + SfbxLiteData: { + initialized: false, + data: null, + user: false, + source: SFBX_LITE_DATA_SOURCE_LABEL, + callbackBuilder: getSfbxLiteDataProfile, + }, }; +export const weboramaSubmodule = new WeboramaRtdProvider(components); + submodule(MODULE_NAME, weboramaSubmodule); diff --git a/modules/weboramaRtdProvider.md b/modules/weboramaRtdProvider.md index 732944c6e1c..0c6e3339787 100644 --- a/modules/weboramaRtdProvider.md +++ b/modules/weboramaRtdProvider.md @@ -6,11 +6,17 @@ Module Type: Rtd Provider Maintainer: prebid-support@weborama.com ``` -# Description +## Description -Weborama provides a Semantic AI Contextual API that classifies in Real-time a web page seen by a web user within generic and custom topics. It enables publishers to better monetize their inventory and unlock it to programmatic. +Weborama provides a Real-Time Data Submodule for `Prebid.js`, allowing to easy integrate different products such as: -Contact prebid-support@weborama.com for information. +* Semantic AI Contextual API that classifies in Real-time a web page seen by a web user within generic and custom topics. It enables publishers to better monetize their inventory and unlock it to programmatic. + +* Weborama Audience Manager (WAM) is a DMP (Data Management Platform) used by over 60 companies in the world. This platform distinguishes itself particularly by a high level interconnexion with the adtech & martech ecosystem and a transparent access to the database intelligence. + +* LiTE by SFBX® (Local inApp Trust Engine) provides “Zero Party Data” given by users, stored and calculated only on the user’s device. Through a unique cohorting system, it enables better monetization in a consent/consentless and identity-less mode. + +Contact prebid-support@weborama.com for more information. ### Publisher Usage @@ -18,7 +24,7 @@ Compile the Weborama RTD module into your Prebid build: `gulp build --modules=rtdModule,weboramaRtdProvider` -Add the Weborama RTD provider to your Prebid config. +Add the Weborama RTD provider to your Prebid config, use the configuration template below: ```javascript var pbjs = pbjs || {}; @@ -26,94 +32,554 @@ pbjs.que = pbjs.que || []; pbjs.que.push(function () { pbjs.setConfig({ - debug: true, + debug: true, // Output debug messages to the web console, *should* be disabled in production realTimeData: { auctionDelay: 1000, dataProviders: [{ name: "weborama", waitForIt: true, params: { - setPrebidTargeting: true, // optional - sendToBidders: true, // optional - onData: function(data, site){ // optional - var kind = (site)? 'site' : 'user'; - console.log('onData', kind, data); - }, - weboCtxConf: { - token: "to-be-defined", // mandatory - targetURL: "https://prebid.org", // default is document.URL - setPrebidTargeting: true, // override param.setPrebidTargeting or default true - sendToBidders: true, // override param.sendToBidders or default true - defaultProfile: { // optional - webo_ctx: ['moon'], - webo_ds: ['bar'] - } - //, onData: function (data, ...) { ...} - }, - weboUserDataConf: { - accountId: 12345, // optional, used for logging - setPrebidTargeting: true, // override param.setPrebidTargeting or default true - sendToBidders: true, // override param.sendToBidders or default true - defaultProfile: { // optional - webo_cs: ['Red'], - webo_audiences: ['bam'] - }, - localStorageProfileKey: 'webo_wam2gam_entry' // default - //, onData: function (data, ...) { ...} - } - } - }] + /* add weborama rtd submodule configuration here */ + }, + }, + // other modules... + ] } }); }); ``` +The module configuration has 3 independent sections (`weboCtxConf`, `weboUserDataConf` and `sfbxLiteDataConf`), each one mapped to a single product (`contextual`, `wam` and `lite`). No section is enabled by default, we must be explicit like in the minimal example below: + +```javascript +pbjs.setConfig({ + debug: true, + realTimeData: { + auctionDelay: 1000, + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + weboCtxConf: { // contextual site-centric configuration, *omit if not needed* + token: "<>", // mandatory + }, + weboUserDataConf: { // wam user-centric configuration, *omit if not needed* + enabled: true, + }, + sfbxLiteDataConf: { // sfbx-lite site-centric configuration, *omit if not needed* + enabled: true, + }, + } + }, + // other modules... + ] + } +}); +``` + +Each module can perform two actions: + +* set targeting on [GPT](https://docs.prebid.org/dev-docs/publisher-api-reference/setTargetingForGPTAsync.html) / [AST](https://docs.prebid.org/dev-docs/publisher-api-reference/setTargetingForAst.html]) via `prebid.js` + +* send data to other `prebid.js` bidder modules (check the complete list at the end of this page) + ### Parameter Descriptions for the Weborama Configuration Section +This is the main configuration section + | Name |Type | Description | Notes | | :------------ | :------------ | :------------ |:------------ | | name | String | Real time data module name | Mandatory. Always 'Weborama' | | waitForIt | Boolean | Mandatory. Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false but recommended to true | | params | Object | | Optional | -| params.setPrebidTargeting | Boolean | If true, may use the profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js | Optional. Affects the `weboCtxConf` and `weboUserDataConf` sections | -| params.sendToBidders | Boolean | If true, may send the profile to all bidders | Optional. Affects the `weboCtxConf` and `weboUserDataConf` sections | -| params.weboCtxConf | Object | Weborama Contextual Configuration | Optional -| params.weboUserDataConf | Object | Weborama User-Centric Configuration | Optional | -| params.onData | Callback | If set, will receive the profile and site flag | Optional. Affects the `weboCtxConf` and `weboUserDataConf` sections | +| params.setPrebidTargeting | Boolean | If true, may use the profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js | Optional. Affects the `weboCtxConf`, `weboUserDataConf` and `sfbxLiteDataConf` sections | +| params.sendToBidders | Boolean or Array | If true, may send the profile to all bidders. If an array, will specify the bidders to send data | Optional. Affects the `weboCtxConf`, `weboUserDataConf` and `sfbxLiteDataConf` sections | +| params.weboCtxConf | Object | Weborama Contextual Site-Centric Configuration | Optional | +| params.weboUserDataConf | Object | Weborama WAM User-Centric Configuration | Optional | +| params.sfbxLiteDataConf | Object | Sfbx LiTE Site-Centric Configuration | Optional | +| params.onData | Callback | If set, will receive the profile and metadata | Optional. Affects the `weboCtxConf`, `weboUserDataConf` and `sfbxLiteDataConf` sections | + +#### Contextual Site-Centric Configuration -#### Contextual Configuration +To be possible use the integration with Weborama Contextual Service you must be a client with a valid API token. Please contact weborama if you don't have it. + +On this section we will explain the `params.weboCtxConf` subconfiguration: | Name |Type | Description | Notes | | :------------ | :------------ | :------------ |:------------ | | token | String | Security Token provided by Weborama, unique per client | Mandatory | | targetURL | String | Url to be profiled in the contextual api | Optional. Defaults to `document.URL` | -| setPrebidTargeting|Boolean|If true, will use the contextual profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is `params.setPrebidTargeting` (if any) or **true**.| -| sendToBidders|Boolean|If true, will send the contextual profile to all bidders| Optional. Default is `params.sendToBidders` (if any) or **true**.| +| assetID | Function or String | if provided, we will call the document-profile api using this asset id. |Optional| +| setPrebidTargeting|Various|If true, will use the contextual profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is `params.setPrebidTargeting` (if any) or `true`.| +| sendToBidders|Various|If true, will send the contextual profile to all bidders. If an array, will specify the bidders to send data| Optional. Default is `params.sendToBidders` (if any) or `true`.| | defaultProfile | Object | default value of the profile to be used when there are no response from contextual api (such as timeout)| Optional. Default is `{}` | +| onData | Callback | If set, will receive the profile and metadata | Optional. Default is `params.onData` (if any) or log via prebid debug | +| enabled | Boolean| if false, will ignore this configuration| Default is `true` if this section is present| +| baseURLProfileAPI | String| if present, update the domain of the contextual api| Optional. Default is `ctx.weborama.com` | + +#### WAM User-Centric Configuration + +To be possible use the integration with Weborama Audience Manager (WAM) you must be a client with an account id and you lust include the `wamfactory` script in your pages with `wam2gam` feature activated. +Please contact weborama if you don't have it. + +On this section we will explain the `params.weboUserDataConf` subconfiguration: + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| accountId|Number|WAM account id. If you don't have it, please contact weborama. | Recommended.| +| setPrebidTargeting|Various|If true, will use the user profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is `params.setPrebidTargeting` (if any) or `true`.| +| sendToBidders|Various|If true, will send the user profile to all bidders| Optional. Default is `params.sendToBidders` (if any) or `true`.| | onData | Callback | If set, will receive the profile and site flag | Optional. Default is `params.onData` (if any) or log via prebid debug | -| enabled | Boolean| if false, will ignore this configuration| default true| +| defaultProfile | Object | default value of the profile to be used when there are no response from contextual api (such as timeout)| Optional. Default is `{}` | +| localStorageProfileKey| String | can be used to customize the local storage key | Optional | +| enabled | Boolean| if false, will ignore this configuration| Default is `true` if this section is present| + +#### Sfbx LiTE Site-Centric Configuration + +To be possible use the integration between Weborama and Sfbx LiTE you should also contact SFBX® to setup this product. -#### User-Centric Configuration +On this section we will explain the `params.sfbxLiteDataConf` subconfiguration: | Name |Type | Description | Notes | | :------------ | :------------ | :------------ |:------------ | -| accountId|Number|WAM account id. If present, will be used on logging and statistics| Optional.| -| setPrebidTargeting|Boolean|If true, will use the user profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is `params.setPrebidTargeting` (if any) or **true**.| -| sendToBidders|Boolean|If true, will send the user profile to all bidders| Optional. Default is `params.sendToBidders` (if any) or **true**.| +| setPrebidTargeting|Various|If true, will use the user profile to set the prebid (GPT/GAM or AST) targeting of all adunits managed by prebid.js| Optional. Default is `params.setPrebidTargeting` (if any) or `true`.| +| sendToBidders|Varios|If true, will send the user profile to all bidders| Optional. Default is `params.sendToBidders` (if any) or `true`.| | onData | Callback | If set, will receive the profile and site flag | Optional. Default is `params.onData` (if any) or log via prebid debug | | defaultProfile | Object | default value of the profile to be used when there are no response from contextual api (such as timeout)| Optional. Default is `{}` | -| localStorageProfileKey| String | can be used to customize the local storage key | Optional | -| enabled | Boolean| if false, will ignore this configuration| default true| +| localStorageProfileKey| String | can be used to customize the local storage key | Optional | +| enabled | Boolean| if false, will ignore this configuration| Default is `true` if this section is present| + +##### Property setPrebidTargeting supported types + +This property support the following types + +| Type | Description | Example | Notes | +| :------------ | :------------ | :------------ |:------------ | +| Boolean|If true, set prebid targeting for all adunits, or not in case of false| `true` | default value | +| String|Will set prebid targeting only for one adunit | `'adUnitCode1'` | | +| Array of Strings|Will set prebid targeting only for some adunits| `['adUnitCode1','adUnitCode2']` | | +| Callback |Will be executed for each adunit, expects return a true value to set prebid targeting or not| `function(adUnitCode){return adUnitCode == 'adUnitCode';}` | | + +The complete callback function signature is: + +```javascript +setPrebidTargeting: function(adUnitCode, data, metadata){ + return true; // or false, depending on the logic +} +``` + +This callback will be executed with the adUnitCode, profile and a metadata with the following fields + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| user | Boolean | If true, it contains user-centric data | | +| source | String | Represent the source of data | can be `contextual`, `wam` or `lite` | +| isDefault | Boolean | If true, it contains the default profile defined in the configuration | | + +It is possible customize the targeting based on the parameters: + +```javascript +setPrebidTargeting: function(adUnitCode, data, metadata){ + // check metadata.source can be omitted if defined in params.weboUserDataConf + if (adUnitCode == 'adUnitCode1' && metadata.source == 'wam'){ + data['foo']=['bar']; // add this section only for adUnitCode1 + delete data['other']; // remove this section + } + return true; +} +``` + +##### Property sendToBidders supported types + +This property support the following types + +| Type | Description | Example | Notes | +| :------------ | :------------ | :------------ |:------------ | +| Boolean|If true, send data to all bidders, or not in case of false| `true` | default value | +| String|Will send data to only one bidder | `'appnexus'` | | +| Array of Strings|Will send data to only some bidders | `['appnexus','pubmatic']` | | +| Object |Will send data to only some bidders and some ad units | `{appnexus: true, pubmatic:['adUnitCode1']}` | | +| Callback |Will be executed for each adunit, expects return a true value to set prebid targeting or not| `function(bid, adUnitCode){return bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode';}` | | + +A better look on the `Object` type + +```javascript +sendToBidders: { + appnexus: true, // send profile to appnexus on all ad units + pubmatic: ['adUnitCode1'],// send profile to pubmatic on this ad units +} +``` + +The complete callback function signature is: + +```javascript +sendToBidders: function(bid, adUnitCode, data, metadata){ + return true; // or false, depending on the logic +} +``` + +This callback will be executed with the bid object (contains a field `bidder` with name), adUnitCode, profile and a metadata with the following fields + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| user | Boolean | If true, it contains user-centric data | | +| source | String | Represent the source of data | can be `contextual`, `wam` or `lite` | +| isDefault | Boolean | If true, it contains the default profile defined in the configuration | | + +It is possible customize the targeting based on the parameters: + +```javascript +sendToBidders: function(bid, adUnitCode, data, metadata){ + if (bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode1'){ + data['foo']=['bar']; // add this section only for appnexus + adUnitCode1 + delete data['other']; // remove this section + } + return true; +} +``` + +To be possible customize the way we send data to bidders via this callback: + +```javascript +sendToBidders: function(bid, adUnitCode, data, metadata){ + if (bid.bidder == 'other'){ + /* use bid object to store data based on this specific logic, like in the example below */ + + bid.params = bid.params || {}; + bid.params['some_specific_key'] = data; + + return false; // will prevent the module to follow the pre-defined logic per bidder + } + // others + return true; +} +``` + +In case of using bid _aliases_, we should match the same string used in the adUnit configuration. + +```javascript +pbjs.aliasBidder('appnexus', 'foo'); +pbjs.aliasBidder('criteo', 'bar'); +pbjs.aliasBidder('pubmatic', 'baz'); +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + weboCtxConf: { + token: "to-be-defined", // mandatory + sendToBidders: ['foo','bar'], // will share site-centric data with bidders foo and bar + }, + weboUserDataConf: { + accountId: 12345, // recommended, + sendToBidders: ['baz'], // will share user-centric data with only bidder baz + } + } + }] + } +}); +``` + +##### Using onData callback + +We can specify a callback to handle the profile data from site-centric or user-centric data. + +This callback will be executed with the profile and a metadata with the following fields + +| Name |Type | Description | Notes | +| :------------ | :------------ | :------------ |:------------ | +| user | Boolean | If true, it contains user-centric data | | +| source | String | Represent the source of data | can be `contextual`, `wam` or `lite` | +| isDefault | Boolean | If true, it contains the default profile defined in the configuration | | + +The metadata maybe not useful if we define the callback on site-centric of user-centric configuration, but if defined in the global level: + +```javascript +params: { + onData: function(data, metadata){ + var hasUserCentricData = metadata.user; + var dataSource = metadata.source; + console.log('onData', data, hasUserCentricData, dataSource); + } +} +``` + +an interesting example is to set GAM targeting in global level instead in slot level only for contextual data: + +```javascript +params: { + weboCtxConf: { + token: 'to-be-defined', + setPrebidTargeting: false, + onData: function(data, metadata){ + var googletag = googletag || {}; + googletag.cmd = googletag.cmd || []; + googletag.cmd.push(function () { + for(var key in data){ + googletag.pubads().setTargeting(key, data[key]); + } + }); + }, + } +} +``` + +### More configuration examples + +A more complete example can be found below. We can define default profiles, for each section, to be used in case of no data are found. + +We can control if we will set prebid targeting or send data to bidders in a global level or on each section (`contextual`, `wam` or `lite`). + +By default we try to send the data to all destinations, always. To restrict we can have two choices: + +* Set `setPrebidTargeting` or `sendToBidders` explicity to `true` or `false` on each section; +* Set `setPrebidTargeting` or `sendToBidders` globally to `false` and only enable on the right sections; + +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function () { + pbjs.setConfig({ + debug: true, + realTimeData: { + auctionDelay: 1000, + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + weboCtxConf: { + token: "<>", // mandatory + targetURL: "https://example.org", // default is document.URL + setPrebidTargeting: true, // override param.setPrebidTargeting. default is true + sendToBidders: true, // override param.sendToBidders. default is true + defaultProfile: { // optional, used if nothing is found + webo_ctx: [ ... ], // contextual segments + webo_ds: [ ...], // data science segments + }, + enabled: true, + }, + weboUserDataConf: { + setPrebidTargeting: true, // override param.setPrebidTargeting. default is true + sendToBidders: true, // override param.sendToBidders. default is true + defaultProfile: { // optional, used if nothing is found + webo_cs: [...], // wam custom segments + webo_audiences: [...], // wam audiences + }, + enabled: true, + }, + sfbxLiteDataConf: { + setPrebidTargeting: true, // override param.setPrebidTargeting. default is true + sendToBidders: true, // override param.sendToBidders. default is true + defaultProfile: { // optional, used if nothing is found + /* add specific lite segments here */ + }, + enabled: true, + }, + } + }] + } + }); +}); +``` + +An alternative version, using asset id instead of target url on contextual, can be found here: + +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function () { + pbjs.setConfig({ + debug: true, + realTimeData: { + auctionDelay: 1000, + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + weboCtxConf: { + token: "<>", // mandatory + assetID: "datasource:docId", // can be a callback to be executed in runtime and returns the identifier + setPrebidTargeting: true, // override param.setPrebidTargeting. default is true + sendToBidders: true, // override param.sendToBidders. default is true + defaultProfile: { // optional, used if nothing is found + webo_ctx: [ ... ], // contextual segments + webo_ds: [ ...], // data science segments + }, + enabled: true, + }, + ... + }); +}); +``` + +Imagine we need to configure the following options using the previous example, we can write the configuration like the one below. + +||contextual|wam|lite| +| :------------ | :------------ | :------------ |:------------ | +|setPrebidTargeting|true|false|true| +|sendToBidders|false|true|true| + +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function () { + pbjs.setConfig({ + debug: true, + realTimeData: { + auctionDelay: 1000, + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + setPrebidTargeting: false, // optional. set the default value of each section. + sendToBidders: false, // optional. set the default value of each section. + weboCtxConf: { + token: "<>", // mandatory + targetURL: "https://example.org", // default is document.URL + setPrebidTargeting: true, // override param.setPrebidTargeting. default is true + enabled: true, + }, + weboUserDataConf: { + sendToBidders: true, // override param.sendToBidders. default is true + enabled: true, + }, + sfbxLiteDataConf: { + setPrebidTargeting: true, // override param.setPrebidTargeting. default is true + sendToBidders: true, // override param.sendToBidders. default is true + enabled: true, + }, + } + }] + } + }); +}); +``` + +We can also define a list of adunits / bidders that will receive data instead of using boolean values. + +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function () { + pbjs.setConfig({ + debug: true, + realTimeData: { + auctionDelay: 1000, + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + weboCtxConf: { + token: "to-be-defined", // mandatory + setPrebidTargeting: ['adUnitCode1',...], // set target only on certain adunits + sendToBidders: ['appnexus',...], // overide, send to only some bidders + enabled: true, + }, + weboUserDataConf: { + accountId: 12345, // recommended + setPrebidTargeting: ['adUnitCode2',...], // set target only on certain adunits + sendToBidders: ['rubicon',...], // overide, send to only some bidders + enabled: true, + }, + sfbxLiteDataConf: { + setPrebidTargeting: ['adUnitCode3',...], // set target only on certain adunits + sendToBidders: ['smartadserver',...], // overide, send to only some bidders + enabled: true, + } + } + }] + } + }); +}); +``` + +Finally, we can combine several styles in the same configuration if needed. Including the callback style. + +```javascript +var pbjs = pbjs || {}; +pbjs.que = pbjs.que || []; + +pbjs.que.push(function () { + pbjs.setConfig({ + debug: true, + realTimeData: { + auctionDelay: 1000, + dataProviders: [{ + name: "weborama", + waitForIt: true, + params: { + setPrebidTargeting: true, // optional + sendToBidders: true, // optional + onData: function(data, meta){ // optional + var userCentricData = meta.user; // maybe undefined + var sourceOfData = meta.source; // contextual, wam or lite + + var isDefault = meta.isDefault; // true if uses default profile + + console.log('onData', data, meta); + }, + weboCtxConf: { + token: "to-be-defined", // mandatory + targetURL: "https://prebid.org", // default is document.URL + setPrebidTargeting: true, // override param.setPrebidTargeting or default true + sendToBidders: ['appnexus',...], // overide, send to only some bidders + defaultProfile: { // optional + webo_ctx: ['moon'], + webo_ds: ['bar'] + }, + enabled: true, + //, onData: function (data, ...) { ...} + }, + weboUserDataConf: { + accountId: 12345, // recommended + setPrebidTargeting: ['adUnitCode1',...], // set target only on certain adunits + sendToBidders: { // send to only some bidders and adunits + 'appnexus': true, // all adunits for appnexus + 'pubmatic': ['adUnitCode1',...] // some adunits for pubmatic + // other bidders will be ignored + }, + defaultProfile: { // optional + webo_cs: ['Red'], + webo_audiences: ['bam'] + }, + localStorageProfileKey: 'webo_wam2gam_entry', // default + enabled: true, + //, onData: function (data, ...) { ...} + }, + sfbxLiteDataConf: { + setPrebidTargeting: function(adUnitCode){ // specify set target via callback + return adUnitCode == 'adUnitCode1'; + }, + sendToBidders: function(bid, adUnitCode){ // specify sendToBidders via callback + return bid.bidder == 'appnexus' && adUnitCode == 'adUnitCode1'; + } + defaultProfile: { // optional + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }, + localStorageProfileKey: '_lite', // default + enabled: true, + //, onData: function (data, ...) { ...} + } + } + }] + } + }); +}); +``` ### Supported Bidders -We currently support the following bidder adapters: -* SmartADServer SSP -* PubMatic SSP +We currently support the following bidder adapters with dedicated code: + * AppNexus SSP -* Rubicon SSP -We also set the bidder and global ortb2 `site` and `user` sections. The following bidders may support it, to be sure, check the `First Party Data Support` on the feature list for the particular bidder from here: https://docs.prebid.org/dev-docs/bidders +We also set the bidder (and global, if no specific bidders are set on `sendToBidders`) ortb2 `site.ext.data` and `user.ext.data` sections (as arbitrary data). The following bidders may support it, to be sure, check the `First Party Data Support` on the feature list for the particular bidder from [here](https://docs.prebid.org/dev-docs/bidders). * Adagio * AdformOpenRTB @@ -136,8 +602,11 @@ We also set the bidder and global ortb2 `site` and `user` sections. The followin * Opt Out Advertising * Ozone Project * Proxistore +* PubMatic SSP * Rise +* Rubicon SSP * Smaato +* Smart ADServer SSP * Sonobi * TheMediaGrid * TripleLift diff --git a/modules/widespaceBidAdapter.js b/modules/widespaceBidAdapter.js index ba94f90f9c9..ea6f1bce793 100644 --- a/modules/widespaceBidAdapter.js +++ b/modules/widespaceBidAdapter.js @@ -185,28 +185,6 @@ function storeData(data, name, stringify = true) { function getData(name, remove = true) { let data = []; - if (storage.hasLocalStorage()) { - Object.keys(localStorage).filter((key) => { - if (key.indexOf(name) > -1) { - data.push(storage.getDataFromLocalStorage(key)); - if (remove) { - storage.removeDataFromLocalStorage(key); - } - } - }); - } - - if (storage.cookiesAreEnabled()) { - document.cookie.split(';').forEach((item) => { - let value = item.split('='); - if (value[0].indexOf(name) > -1) { - data.push(value[1]); - if (remove) { - storage.setCookie(value[0], '', 'Thu, 01 Jan 1970 00:00:01 GMT'); - } - } - }); - } return data; } diff --git a/modules/windtalkerBidAdapter.md b/modules/windtalkerBidAdapter.md deleted file mode 100644 index f7441effc47..00000000000 --- a/modules/windtalkerBidAdapter.md +++ /dev/null @@ -1,86 +0,0 @@ -# Overview - -**Module Name**: Windtalker Bidder Adapter -**Module Type**: Bidder Adapter -**Maintainer**: corbin@windtalker.io - -# Description - -Connects to Windtalker demand source to fetch bids. -Banner, Native, Video formats are supported. -Please use ```windtalker``` as the bidder code. - -# Test Parameters -``` - var adUnits = [{ - code: 'dfp-native-div', - mediaTypes: { - native: { - title: { - required: true, - len: 75 - }, - image: { - required: true - }, - body: { - len: 200 - }, - icon: { - required: false - } - } - }, - bids: [{ - bidder: 'windtalker', - params: { - pubId: '584971', - siteId: '584971', - placementId: '123', - bidFloor: '0.001', // optional - ifa: 'XXX-XXX', // optional - latitude: '40.712775', // optional - longitude: '-74.005973', // optional - } - }] - }, - { - code: 'dfp-banner-div', - mediaTypes: { - banner: { - sizes: [ - [300, 250],[300,600] - ], - } - }, - bids: [{ - bidder: 'windtalker', - params: { - pubId: '584971', - siteId: '584971', - placementId: '123', - } - }] - }, - { - code: 'dfp-video-div', - mediaTypes: { - video: { - playerSize: [[640, 480]], - context: "instream" - } - }, - bids: [{ - bidder: 'windtalker', - params: { - pubId: '584971', - siteId: '584971', - placementId: '123', - video: { - skipppable: true, - } - } - }] - } - ]; -``` diff --git a/modules/winrBidAdapter.js b/modules/winrBidAdapter.js index 124aba57866..41efc432e11 100644 --- a/modules/winrBidAdapter.js +++ b/modules/winrBidAdapter.js @@ -1,22 +1,22 @@ import { - convertCamelToUnderscore, - convertTypes, deepAccess, getBidRequest, getParameterByName, isArray, - isEmpty, isFn, isNumber, isPlainObject, - logError, - transformBidderParamKeywords + logError } from '../src/utils.js'; import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; import {find, includes} from '../src/polyfill.js'; import {getStorageManager} from '../src/storageManager.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; +import {getANKeywordParam, transformBidderParamKeywords} from '../libraries/appnexusUtils/anKeywords.js'; +import {convertCamelToUnderscore} from '../libraries/appnexusUtils/anUtils.js'; +import {convertTypes} from '../libraries/transformParamsUtils/convertTypes.js'; const BIDDER_CODE = 'winr'; const URL = 'https://ib.adnxs.com/ut/v3/prebid'; @@ -207,7 +207,7 @@ export const spec = { } if (appDeviceObjBid) { - payload.device = appDeviceObj + payload.device = appDeviceObj; } if (appIdObjBid) { payload.app = appIdObj; @@ -227,7 +227,8 @@ export const spec = { if (bidderRequest && bidderRequest.refererInfo) { let refererinfo = { - rd_ref: encodeURIComponent(bidderRequest.refererInfo.referer), + // TODO: this collects everything it finds, except for canonicalUrl + rd_ref: encodeURIComponent(bidderRequest.refererInfo.topmostLocation), rd_top: bidderRequest.refererInfo.reachedTop, rd_ifs: bidderRequest.refererInfo.numIframes, rd_stk: bidderRequest.refererInfo.stack @@ -240,7 +241,6 @@ export const spec = { if (bidRequests[0].userId) { let eids = []; - addUserId(eids, deepAccess(bidRequests[0], `userId.flocId.id`), 'chrome.com', null); addUserId(eids, deepAccess(bidRequests[0], `userId.criteoId`), 'criteo.com', null); addUserId(eids, deepAccess(bidRequests[0], `userId.netId`), 'netid.de', null); addUserId(eids, deepAccess(bidRequests[0], `userId.idl_env`), 'liveramp.com', null); @@ -329,10 +329,6 @@ export const spec = { delete params.usePaymentRule; } - if (isPopulatedArray(params.keywords)) { - params.keywords.forEach(deleteValues); - } - Object.keys(params).forEach((paramKey) => { let convertedKey = convertCamelToUnderscore(paramKey); if (convertedKey !== paramKey) { @@ -346,34 +342,6 @@ export const spec = { }, }; -function isPopulatedArray(arr) { - return !!(isArray(arr) && arr.length > 0); -} - -function deleteValues(keyPairObj) { - if (isPopulatedArray(keyPairObj.value) && keyPairObj.value[0] === '') { - delete keyPairObj.value; - } -} - -function hasPurpose1Consent(bidderRequest) { - let result = true; - if (bidderRequest && bidderRequest.gdprConsent) { - if ( - bidderRequest.gdprConsent.gdprApplies && - bidderRequest.gdprConsent.apiVersion === 2 - ) { - result = !!( - deepAccess( - bidderRequest.gdprConsent, - 'vendorData.purpose.consents.1' - ) === true - ); - } - } - return result; -} - function formatRequest(payload, bidderRequest) { let request = []; let options = { @@ -382,7 +350,7 @@ function formatRequest(payload, bidderRequest) { let endpointUrl = URL; - if (!hasPurpose1Consent(bidderRequest)) { + if (!hasPurpose1Consent(bidderRequest?.gdprConsent)) { endpointUrl = URL_SIMPLE; } @@ -419,6 +387,7 @@ function newBid(serverBid, rtbBid, bidderRequest) { const bid = { adType: rtbBid.ad_type, requestId: serverBid.uuid, + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 auctionId: bidRequest.auctionId, cpm: rtbBid.cpm, creativeId: rtbBid.creative_id, @@ -514,14 +483,7 @@ function bidToTag(bid) { if (bid.params.externalImpId) { tag.external_imp_id = bid.params.externalImpId; } - if (!isEmpty(bid.params.keywords)) { - let keywords = transformBidderParamKeywords(bid.params.keywords); - - if (keywords.length > 0) { - keywords.forEach(deleteValues); - } - tag.keywords = keywords; - } + tag.keywords = getANKeywordParam(bid.ortb2, bid.params.keywords) let gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot'); if (gpid) { diff --git a/modules/wipesBidAdapter.js b/modules/wipesBidAdapter.js index 3d040fee8d3..56a4aeecd71 100644 --- a/modules/wipesBidAdapter.js +++ b/modules/wipesBidAdapter.js @@ -1,5 +1,4 @@ -import { logWarn } from '../src/utils.js'; -import {config} from '../src/config.js'; +import {logWarn} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; @@ -50,7 +49,7 @@ function interpretResponse(serverResponse, bidRequest) { dealId: response.deal_id, currency: 'JPY', netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), + ttl: 60, referrer: bidRequest.data.r || '', mediaType: BANNER, ad: response.ad_tag, diff --git a/modules/xeBidAdapter.js b/modules/xeBidAdapter.js new file mode 100644 index 00000000000..6f527d905d6 --- /dev/null +++ b/modules/xeBidAdapter.js @@ -0,0 +1,208 @@ +import { config } from '../src/config.js'; +import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {parseSizesInput, isFn, deepAccess, logError, isArray, getBidIdParameter} from '../src/utils.js'; +import {getAdUnitSizes} from '../libraries/sizeUtils/sizeUtils.js'; + +const CUR = 'USD'; +const BIDDER_CODE = 'xe'; +const ENDPOINT = 'https://pbjs.xe.works/bid'; + +/** + * Determines whether or not the given bid request is valid. + * + * @param {BidRequest} bid The bid params to validate. + * @return boolean True if this is a valid bid, and false otherwise. + */ +function isBidRequestValid(req) { + if (req && typeof req.params !== 'object') { + logError('Params is not defined or is incorrect in the bidder settings'); + return false; + } + + if (!getBidIdParameter('env', req.params) || !getBidIdParameter('placement', req.params)) { + logError('Env or placement is not present in bidder params'); + return false; + } + + if (deepAccess(req, 'mediaTypes.video') && !isArray(deepAccess(req, 'mediaTypes.video.playerSize'))) { + logError('mediaTypes.video.playerSize is required for video'); + return false; + } + + return true; +} + +/** + * Make a server request from the list of BidRequests. + * + * @param {validBidRequest?pbjs_debug=trues[]} - an array of bids + * @return ServerRequest Info describing the request to the server. + */ +function buildRequests(validBidRequests, bidderRequest) { + const { refererInfo = {}, gdprConsent = {}, uspConsent } = bidderRequest; + const requests = validBidRequests.map(req => { + const request = {}; + request.bidId = req.bidId; + request.banner = deepAccess(req, 'mediaTypes.banner'); + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + request.auctionId = req.auctionId; + request.transactionId = req.ortb2Imp?.ext?.tid; + request.sizes = parseSizesInput(getAdUnitSizes(req)); + request.schain = req.schain; + request.location = { + page: refererInfo.page, + location: refererInfo.location, + domain: refererInfo.domain, + whost: window.location.host, + ref: refererInfo.ref, + isAmp: refererInfo.isAmp + }; + request.device = { + ua: navigator.userAgent, + lang: navigator.language + }; + request.env = { + env: req.params.env, + placement: req.params.placement + }; + request.ortb2 = req.ortb2; + request.ortb2Imp = req.ortb2Imp; + request.tz = new Date().getTimezoneOffset(); + request.ext = req.params.ext; + request.bc = req.bidRequestsCount; + request.floor = getBidFloor(req); + + if (req.userIdAsEids && req.userIdAsEids.length !== 0) { + request.userEids = req.userIdAsEids; + } else { + request.userEids = []; + } + if (gdprConsent.gdprApplies) { + request.gdprApplies = Number(gdprConsent.gdprApplies); + request.consentString = gdprConsent.consentString; + } else { + request.gdprApplies = 0; + request.consentString = ''; + } + if (uspConsent) { + request.usPrivacy = uspConsent; + } else { + request.usPrivacy = ''; + } + if (config.getConfig('coppa')) { + request.coppa = 1; + } else { + request.coppa = 0; + } + + const video = deepAccess(req, 'mediaTypes.video'); + if (video) { + request.sizes = parseSizesInput(deepAccess(req, 'mediaTypes.video.playerSize')); + request.video = video; + } + + return request; + }); + + return { + method: 'POST', + url: ENDPOINT, + data: JSON.stringify(requests), + withCredentials: true, + bidderRequest, + options: { + contentType: 'application/json' + } + }; +} + +/** + * Unpack the response from the server into a list of bids. + * + * @param {ServerResponse} serverResponse A successful response from the server. + * @return {Bid[]} An array of bids which were nested inside the server. + */ +function interpretResponse(serverResponse, { bidderRequest }) { + const response = []; + if (!isArray(deepAccess(serverResponse, 'body.data'))) { + return response; + } + + serverResponse.body.data.forEach(serverBid => { + const bid = { + requestId: bidderRequest.bidId, + dealId: bidderRequest.dealId || null, + ...serverBid + }; + response.push(bid); + }); + + return response; +} + +/** +* Register the user sync pixels which should be dropped after the auction. +* +* @param {SyncOptions} syncOptions Which user syncs are allowed? +* @param {ServerResponse[]} serverResponses List of server's responses. +* @return {UserSync[]} The user syncs which should be dropped. +*/ +function getUserSyncs(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '') { + const syncs = []; + const pixels = deepAccess(serverResponses, '0.body.data.0.ext.pixels'); + + if ((syncOptions.iframeEnabled || syncOptions.pixelEnabled) && isArray(pixels) && pixels.length !== 0) { + const gdprFlag = `&gdpr=${gdprConsent.gdprApplies ? 1 : 0}`; + const gdprString = `&gdpr_consent=${encodeURIComponent((gdprConsent.consentString || ''))}`; + const usPrivacy = `us_privacy=${encodeURIComponent(uspConsent)}`; + + pixels.forEach(pixel => { + const [ type, url ] = pixel; + const sync = { type, url: `${url}&${usPrivacy}${gdprFlag}${gdprString}` }; + if (type === 'iframe' && syncOptions.iframeEnabled) { + syncs.push(sync) + } else if (type === 'image' && syncOptions.pixelEnabled) { + syncs.push(sync) + } + }); + } + + return syncs; +} + +/** +* Get valid floor value from getFloor fuction. +* +* @param {Object} bid Current bid request. +* @return {null|Number} Returns floor value when bid.getFloor is function and returns valid floor object with USD currency, otherwise returns null. +*/ +export function getBidFloor(bid) { + if (!isFn(bid.getFloor)) { + return null; + } + + let floor = bid.getFloor({ + currency: CUR, + mediaType: '*', + size: '*' + }); + + if (typeof floor === 'object' && !isNaN(floor.floor) && floor.currency === CUR) { + return floor.floor; + } + + return null; +} + +export const spec = { + code: BIDDER_CODE, + aliases: [ 'xeworks', 'lunamediax' ], + supportedMediaTypes: [ BANNER, VIDEO ], + isBidRequestValid, + buildRequests, + interpretResponse, + getUserSyncs +} + +registerBidder(spec); diff --git a/modules/xeBidAdapter.md b/modules/xeBidAdapter.md new file mode 100644 index 00000000000..aad00cb45e8 --- /dev/null +++ b/modules/xeBidAdapter.md @@ -0,0 +1,54 @@ +# Overview + +``` +Module Name: xe Bidder Adapter +Module Type: xe Bidder Adapter +Maintainer: dima@xe.works +``` + +# Description + +Module that connects to xe.works demand sources + +# Test Parameters +``` +var adUnits = [ + { + code: 'test-banner', + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + bids: [ + { + bidder: 'xe', + params: { + env: 'xe', + placement: 'test-banner', + ext: {} + } + } + ] + }, + { + code: 'test-video', + sizes: [ [ 640, 480 ] ], + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream', + skipppable: true + } + }, + bids: [{ + bidder: 'xe', + params: { + env: 'xe', + placement: 'test-video', + ext: {} + } + }] + } +]; +``` \ No newline at end of file diff --git a/modules/xendizBidAdapter.md b/modules/xendizBidAdapter.md deleted file mode 100644 index 4ecabe7070f..00000000000 --- a/modules/xendizBidAdapter.md +++ /dev/null @@ -1,41 +0,0 @@ -# Overview - -Module Name: Xendiz Bidder Adapter -Module Type: Bidder Adapter -Maintainer: hello@xendiz.com - -# Description - -Module that connects to Xendiz demand sources - -# Test Parameters -``` - var adUnits = [ - { - code: 'test-div', - sizes: [[300, 250]], - bids: [ - { - bidder: "xendiz", - params: { - pid: '00000000-0000-0000-0000-000000000000' - } - } - ] - },{ - code: 'test-div', - sizes: [[300, 50]], - bids: [ - { - bidder: "xendiz", - params: { - pid: '00000000-0000-0000-0000-000000000000', - ext: { - uid: '550e8400-e29b-41d4-a716-446655440000' - } - } - } - ] - } - ]; -``` \ No newline at end of file diff --git a/modules/xhbBidAdapter.md b/modules/xhbBidAdapter.md deleted file mode 100644 index bb95f4f499c..00000000000 --- a/modules/xhbBidAdapter.md +++ /dev/null @@ -1,100 +0,0 @@ -# Overview - -``` -Module Name: XHB Bid Adapter -Module Type: Bidder Adapter -Maintainer: daniel.hoffmann@xaxis.com -``` - -# Description - -Connects to Appnexus exchange for bids. - -XHB bid adapter supports Banner, Video (instream and outstream) and Native. - -# Test Parameters -``` -var adUnits = [ - // Banner adUnit - { - code: 'banner-div', - sizes: [[300, 250], [300,600]], - bids: [{ - bidder: 'xhb', - params: { - placementId: '10433394' - } - }] - }, - // Native adUnit - { - code: 'native-div', - sizes: [[300, 250], [300,600]], - mediaTypes: { - native: { - title: { - required: true, - len: 80 - }, - body: { - required: true - }, - image: { - required: true - }, - clickUrl: { - required: true - }, - } - }, - bids: [{ - bidder: 'xhb', - params: { - placementId: '9880618' - } - }] - }, - // Video instream adUnit - { - code: 'video-instream', - sizes: [640, 480], - mediaTypes: { - video: { - context: 'instream' - }, - }, - bids: [{ - bidder: 'xhb', - params: { - placementId: '9333431', - video: { - skippable: true, - playback_methods: ['auto_play_sound_off'] - } - } - }] - }, - // Video outstream adUnit - { - code: 'video-outstream', - sizes: [[640, 480]], - mediaTypes: { - video: { - context: 'outstream' - } - }, - bids: [ - { - bidder: 'xhb', - params: { - placementId: '5768085', - video: { - skippable: true, - playback_method: ['auto_play_sound_off'] - } - } - } - ] - } -]; -``` diff --git a/modules/yahoosspBidAdapter.js b/modules/yahoosspBidAdapter.js index b14efc9bce7..a66d76f8689 100644 --- a/modules/yahoosspBidAdapter.js +++ b/modules/yahoosspBidAdapter.js @@ -3,11 +3,13 @@ import { BANNER, VIDEO } from '../src/mediaTypes.js'; import { deepAccess, isFn, isStr, isNumber, isArray, isEmpty, isPlainObject, generateUUID, logInfo, logWarn } from '../src/utils.js'; import { config } from '../src/config.js'; import { Renderer } from '../src/Renderer.js'; +import {hasPurpose1Consent} from '../src/utils/gpdr.js'; const INTEGRATION_METHOD = 'prebid.js'; -const BIDDER_CODE = 'yahoossp'; +const BIDDER_CODE = 'yahooAds'; +const BIDDER_ALIASES = ['yahoossp', 'yahooAdvertising'] const GVLID = 25; -const ADAPTER_VERSION = '1.0.2'; +const ADAPTER_VERSION = '1.1.0'; const PREBID_VERSION = '$prebid.version$'; const DEFAULT_BID_TTL = 300; const TEST_MODE_DCN = '8a969516017a7a396ec539d97f540011'; @@ -23,12 +25,13 @@ const SUPPORTED_USER_ID_SOURCES = [ 'adserver.org', 'adtelligent.com', 'akamai.com', - 'amxrtb.com', + 'amxdt.net', 'audigent.com', 'britepool.com', 'criteo.com', 'crwdcntrl.net', 'deepintent.com', + 'epsilon.com', 'hcn.health', 'id5-sync.com', 'idx.lat', @@ -45,22 +48,17 @@ const SUPPORTED_USER_ID_SOURCES = [ 'parrable.com', 'pubcid.org', 'quantcast.com', - 'quantcast.com', 'tapad.com', 'uidapi.com', - 'verizonmedia.com', 'yahoo.com', 'zeotap.com' ]; /* Utility functions */ -function hasPurpose1Consent(bidderRequest) { - if (bidderRequest && bidderRequest.gdprConsent) { - if (bidderRequest.gdprConsent.gdprApplies && bidderRequest.gdprConsent.apiVersion === 2) { - return deepAccess(bidderRequest.gdprConsent, 'vendorData.purpose.consents.1') === true; - } - } - return true; + +function getConfigValue(bid, key) { + const bidderCode = bid.bidder || bid.bidderCode; + return config.getConfig(`${bidderCode}.${key}`); } function getSize(size) { @@ -108,6 +106,38 @@ function extractUserSyncUrls(syncOptions, pixels) { return userSyncObjects; } +/** + * @param {string} url + * @param {object} consentData + * @param {object} consentData.gpp + * @param {string} consentData.gpp.gppConsent + * @param {array} consentData.gpp.applicableSections + * @param {object} consentData.gdpr + * @param {object} consentData.gdpr.consentString + * @param {object} consentData.gdpr.gdprApplies + * @param {string} consentData.uspConsent + */ +function updateConsentQueryParams(url, consentData) { + const parameterMap = { + 'gdpr_consent': consentData.gdpr ? consentData.gdpr.consentString : '', + 'gdpr': consentData.gdpr && consentData.gdpr.gdprApplies ? '1' : '0', + 'us_privacy': consentData.uspConsent ? consentData.uspConsent : '', + 'gpp': consentData.gpp ? consentData.gpp.gppString : '', + 'gpp_sid': consentData.gpp && Array.isArray(consentData.gpp.applicableSections) + ? consentData.gpp.applicableSections.join(',') : '' + } + + const existingUrl = new URL(url); + const params = existingUrl.searchParams; + + for (const [key, value] of Object.entries(parameterMap)) { + params.set(key, value); + } + + existingUrl.search = params.toString(); + return existingUrl.toString(); +}; + function getSupportedEids(bid) { if (isArray(deepAccess(bid, 'userIdAsEids'))) { return bid.userIdAsEids.filter(eid => { @@ -131,8 +161,8 @@ function getPubIdMode(bid) { return pubIdMode; }; -function getAdapterMode() { - let adapterMode = config.getConfig('yahoossp.mode'); +function getAdapterMode(bid) { + let adapterMode = getConfigValue(bid, 'mode'); adapterMode = adapterMode ? adapterMode.toLowerCase() : undefined; if (typeof adapterMode === 'undefined' || adapterMode === BANNER) { return BANNER; @@ -153,7 +183,7 @@ function getResponseFormat(bid) { }; function getFloorModuleData(bid) { - const adapterMode = getAdapterMode(); + const adapterMode = getAdapterMode(bid); const getFloorRequestObject = { currency: deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY, mediaType: adapterMode, @@ -163,7 +193,7 @@ function getFloorModuleData(bid) { }; function filterBidRequestByMode(validBidRequests) { - const mediaTypesMode = getAdapterMode(); + const mediaTypesMode = getAdapterMode(validBidRequests[0]); let result = []; if (mediaTypesMode === BANNER) { result = validBidRequests.filter(bid => { @@ -220,7 +250,7 @@ function validateAppendObject(validationType, allowedKeys, inputObject, appendTo }; function getTtl(bidderRequest) { - const globalTTL = config.getConfig('yahoossp.ttl'); + const globalTTL = getConfigValue(bidderRequest, 'ttl'); return globalTTL ? validateTTL(globalTTL) : validateTTL(deepAccess(bidderRequest, 'params.ttl')); }; @@ -239,17 +269,21 @@ function generateOpenRtbObject(bidderRequest, bid) { cur: [getFloorModuleData(bidderRequest).currency || deepAccess(bid, 'params.bidOverride.cur') || DEFAULT_CURRENCY], imp: [], site: { - page: deepAccess(bidderRequest, 'refererInfo.referer'), + page: deepAccess(bidderRequest, 'refererInfo.page'), }, device: { dnt: 0, ua: navigator.userAgent, - ip: deepAccess(bid, 'params.bidOverride.device.ip') || deepAccess(bid, 'params.ext.ip') || undefined + ip: deepAccess(bid, 'params.bidOverride.device.ip') || deepAccess(bid, 'params.ext.ip') || undefined, + w: window.screen.width, + h: window.screen.height }, regs: { ext: { 'us_privacy': bidderRequest.uspConsent ? bidderRequest.uspConsent : '', - gdpr: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? 1 : 0 + gdpr: bidderRequest.gdprConsent && bidderRequest.gdprConsent.gdprApplies ? 1 : 0, + gpp: bidderRequest.gppConsent ? bidderRequest.gppConsent.gppString : '', + gpp_sid: bidderRequest.gppConsent ? bidderRequest.gppConsent.applicableSections : [] } }, source: { @@ -284,11 +318,17 @@ function generateOpenRtbObject(bidderRequest, bid) { outBoundBidRequest.site.id = bid.params.dcn; }; - if (config.getConfig('ortb2')) { + if (bidderRequest.ortb2?.regs?.gpp) { + outBoundBidRequest.regs.ext.gpp = bidderRequest.ortb2.regs.gpp; + outBoundBidRequest.regs.ext.gpp_sid = bidderRequest.ortb2.regs.gpp_sid + }; + + if (bidderRequest.ortb2) { outBoundBidRequest = appendFirstPartyData(outBoundBidRequest, bid); }; - if (deepAccess(bid, 'schain')) { + const schainData = deepAccess(bid, 'schain.nodes'); + if (isArray(schainData) && schainData.length > 0) { outBoundBidRequest.source.ext.schain = bid.schain; outBoundBidRequest.source.ext.schain.nodes[0].rid = outBoundBidRequest.id; }; @@ -298,7 +338,7 @@ function generateOpenRtbObject(bidderRequest, bid) { }; function appendImpObject(bid, openRtbObject) { - const mediaTypeMode = getAdapterMode(); + const mediaTypeMode = getAdapterMode(bid); if (openRtbObject && bid) { const impObject = { @@ -376,9 +416,10 @@ function appendImpObject(bid, openRtbObject) { }; function appendFirstPartyData(outBoundBidRequest, bid) { - const ortb2Object = config.getConfig('ortb2'); + const ortb2Object = bid.ortb2; const siteObject = deepAccess(ortb2Object, 'site') || undefined; const siteContentObject = deepAccess(siteObject, 'content') || undefined; + const sitePublisherObject = deepAccess(siteObject, 'publisher') || undefined; const siteContentDataArray = deepAccess(siteObject, 'content.data') || undefined; const appContentObject = deepAccess(ortb2Object, 'app.content') || undefined; const appContentDataArray = deepAccess(ortb2Object, 'app.content.data') || undefined; @@ -393,6 +434,11 @@ function appendFirstPartyData(outBoundBidRequest, bid) { outBoundBidRequest.site = validateAppendObject('object', allowedSiteObjectKeys, siteObject, outBoundBidRequest.site); }; + if (sitePublisherObject && isPlainObject(sitePublisherObject)) { + const allowedPublisherObjectKeys = ['ext']; + outBoundBidRequest.site.publisher = validateAppendObject('object', allowedPublisherObjectKeys, sitePublisherObject, outBoundBidRequest.site.publisher); + } + if (siteContentObject && isPlainObject(siteContentObject)) { const allowedContentStringKeys = ['id', 'title', 'series', 'season', 'genre', 'contentrating', 'language']; const allowedContentNumberkeys = ['episode', 'prodq', 'context', 'livestream', 'len']; @@ -414,7 +460,7 @@ function appendFirstPartyData(outBoundBidRequest, bid) { newDataObject = validateAppendObject('object', allowedContentDataObjectKeys, dataObject, newDataObject); outBoundBidRequest.site.content.data = []; outBoundBidRequest.site.content.data.push(newDataObject); - }) + }); }; }; @@ -434,7 +480,7 @@ function appendFirstPartyData(outBoundBidRequest, bid) { } }; outBoundBidRequest.app.content.data.push(newDataObject); - }) + }); }; }; @@ -454,20 +500,21 @@ function appendFirstPartyData(outBoundBidRequest, bid) { function generateServerRequest({payload, requestOptions, bidderRequest}) { const pubIdMode = getPubIdMode(bidderRequest); - let sspEndpoint = config.getConfig('yahoossp.endpoint') || SSP_ENDPOINT_DCN_POS; + const overrideEndpoint = getConfigValue(bidderRequest, 'endpoint'); + let sspEndpoint = overrideEndpoint || SSP_ENDPOINT_DCN_POS; if (pubIdMode === true) { - sspEndpoint = config.getConfig('yahoossp.endpoint') || SSP_ENDPOINT_PUBID; + sspEndpoint = overrideEndpoint || SSP_ENDPOINT_PUBID; }; if (deepAccess(bidderRequest, 'params.testing.e2etest') === true) { - logInfo('yahoossp adapter e2etest mode is active'); + logInfo('Adapter e2etest mode is active'); requestOptions.withCredentials = false; if (pubIdMode === true) { payload.site.id = TEST_MODE_PUBID_DCN; } else { - const mediaTypeMode = getAdapterMode(); + const mediaTypeMode = getAdapterMode(bidderRequest); payload.site.id = TEST_MODE_DCN; payload.imp.forEach(impObject => { impObject.ext.e2eTestMode = true; @@ -476,8 +523,9 @@ function generateServerRequest({payload, requestOptions, bidderRequest}) { } else if (mediaTypeMode === VIDEO) { impObject.tagid = TEST_MODE_VIDEO_POS; // video passback } else { - logWarn('yahoossp adapter e2etest mode does not support yahoossp.mode="all". \n Please specify either "banner" or "video"'); - logWarn('yahoossp adapter e2etest mode: Please make sure your adUnit matches the yahoossp.mode video or banner'); + const bidderCode = bidderRequest.bidderCode; + logWarn(`e2etest mode does not support ${bidderCode}.mode="all". \n Please specify either "banner" or "video"`); + logWarn(`Adapter e2etest mode: Please make sure your adUnit matches the ${bidderCode}.mode video or banner`); } }); } @@ -488,13 +536,13 @@ function generateServerRequest({payload, requestOptions, bidderRequest}) { method: 'POST', data: payload, options: requestOptions, - bidderRequest: bidderRequest + bidderRequest // Additional data for use in interpretResponse() }; }; function createRenderer(bidderRequest, bidResponse) { const renderer = Renderer.install({ - url: 'https://cdn.vidible.tv/prod/hb-outstream-renderer/renderer.js', + url: 'https://s.yimg.com/kp/prebid-outstream-renderer/renderer.js', loaded: false, adUnitCode: bidderRequest.adUnitCode }) @@ -507,16 +555,17 @@ function createRenderer(bidderRequest, bidResponse) { }, deepAccess(bidderRequest, 'params.testing.renderer.setTimeout') || DEFAULT_RENDERER_TIMEOUT); }); } catch (error) { - logWarn('yahoossp renderer error: setRender() failed', error); + logWarn('Renderer error: setRender() failed', error); } return renderer; } + /* Utility functions */ export const spec = { code: BIDDER_CODE, gvlid: GVLID, - aliases: [], + aliases: BIDDER_ALIASES, supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function(bid) { @@ -529,14 +578,14 @@ export const spec = { ) { return true; } else { - logWarn('yahoossp bidder params missing or incorrect, please pass object with either: dcn & pos OR pubId'); + logWarn('Bidder params missing or incorrect, please pass object with either: dcn & pos OR pubId'); return false; } }, buildRequests: function(validBidRequests, bidderRequest) { if (isEmpty(validBidRequests) || isEmpty(bidderRequest)) { - logWarn('yahoossp Adapter: buildRequests called with either empty "validBidRequests" or "bidderRequest"'); + logWarn('buildRequests called with either empty "validBidRequests" or "bidderRequest"'); return undefined; }; @@ -547,17 +596,16 @@ export const spec = { } }; - requestOptions.withCredentials = hasPurpose1Consent(bidderRequest); + requestOptions.withCredentials = hasPurpose1Consent(bidderRequest.gdprConsent); const filteredBidRequests = filterBidRequestByMode(validBidRequests); - if (config.getConfig('yahoossp.singleRequestMode') === true) { + if (getConfigValue(bidderRequest, 'singleRequestMode') === true) { const payload = generateOpenRtbObject(bidderRequest, filteredBidRequests[0]); filteredBidRequests.forEach(bid => { appendImpObject(bid, payload); }); - - return generateServerRequest({payload, requestOptions, bidderRequest}); + return [generateServerRequest({payload, requestOptions, bidderRequest})]; } return filteredBidRequests.map(bid => { @@ -567,12 +615,11 @@ export const spec = { }); }, - interpretResponse: function(serverResponse, { data, bidderRequest }) { + interpretResponse: function(serverResponse, { bidderRequest }) { const response = []; if (!serverResponse.body || !Array.isArray(serverResponse.body.seatbid)) { return response; } - let seatbids = serverResponse.body.seatbid; seatbids.forEach(seatbid => { let bid; @@ -587,7 +634,6 @@ export const spec = { let bidResponse = { adId: deepAccess(bid, 'adId') ? bid.adId : bid.impid || bid.crid, - adUnitCode: bidderRequest.adUnitCode, requestId: bid.impid, cpm: cpm, width: bid.w, @@ -627,11 +673,19 @@ export const spec = { return response; }, - getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent) { + getUserSyncs: function(syncOptions, serverResponses, gdprConsent, uspConsent, gppConsent) { const bidResponse = !isEmpty(serverResponses) && serverResponses[0].body; if (bidResponse && bidResponse.ext && bidResponse.ext.pixels) { - return extractUserSyncUrls(syncOptions, bidResponse.ext.pixels); + const userSyncObjects = extractUserSyncUrls(syncOptions, bidResponse.ext.pixels); + userSyncObjects.forEach(userSyncObject => { + userSyncObject.url = updateConsentQueryParams(userSyncObject.url, { + gpp: gppConsent, + gdpr: gdprConsent, + uspConsent: uspConsent + }); + }); + return userSyncObjects; } return []; diff --git a/modules/yahoosspBidAdapter.md b/modules/yahoosspBidAdapter.md index 7fb7a307192..c8c42930e5b 100644 --- a/modules/yahoosspBidAdapter.md +++ b/modules/yahoosspBidAdapter.md @@ -1,10 +1,10 @@ # Overview -**Module Name:** yahoossp Bid Adapter +**Module Name:** Yahoo Advertising Bid Adapter **Module Type:** Bidder Adapter **Maintainer:** hb-fe-tech@yahooinc.com # Description -The Yahoo SSP Bid Adapter is an OpenRTB interface that consolidates all previous "Oath.inc" adapters such as: "aol", "oneMobile", "oneDisplay" & "oneVideo" supply-side platforms. +The Yahoo Advertising Bid Adapter is an OpenRTB interface that consolidates all previous "Oath.inc" adapters such as: "aol", "oneMobile", "oneDisplay" & "oneVideo" supply-side platforms. # Supported Features: * Media Types: Banner & Video @@ -21,49 +21,51 @@ The Yahoo SSP Bid Adapter is an OpenRTB interface that consolidates all previous # Adapter Request mode -Since the yahoossp adapter now supports both Banner and Video adUnits a controller was needed to allow you to define when the adapter should generate a bid-requests to our Yahoo SSP. +Since the Yahoo Advertising bid adapter supports both Banner and Video adUnits, a controller was needed to allow you to define when the adapter should generate a bid-requests to the Yahoo bid endpoint. **Important!** By default the adapter mode is set to "banner" only. -This means that you do not need to explicitly declare the yahoossp.mode in the Global config to initiate banner adUnit requests. +This means that you do not need to explicitly declare the `yahooAds.mode` property in the global config to initiate banner adUnit requests. ## Request modes: * **undefined** - (Default) Will generate bid-requests for "Banner" formats only. * **banner** - Will generate bid-requests for "Banner" formats only (Explicit declaration). * **video** - Will generate bid-requests for "Video" formats only (Explicit declaration). -* **all** - Will generate bid-requests for both "Banner" & "Video" formats +* **all** - Will generate bid-requests for both "Banner" & "Video" formats. -**Important!** When setting yahoossp.mode = 'all' Make sure your Yahoo SSP Placement (pos id) supports both Banner & Video placements. -If it does not, the Yahoo SSP will respond only in the format it is set too. +**Important!** When setting `yahooAds.mode` to `'all'`, make sure your Yahoo Placement (pos id) supports both Banner & Video placements. +If it does not, the Yahoo bid server will respond only in the format it is set too. +### Example: explicitly setting the request mode ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { mode: 'banner' // 'all', 'video', 'banner' (default) } }); ``` + # Integration Options -The `yahoossp` bid adapter supports 2 types of integration: +The Yahoo Advertising bid adapter supports 2 types of integration: 1. **dcn & pos** DEFAULT (Site/App & Position targeting) - For Display partners/publishers. -2. **pubId** (Publisher ID) - For legacy "oneVideo" AND New partners/publishers. -**Important:** pubId integration (option 2) is only possible when your Seller account is setup for "Inventory Mapping". +2. **pubId** (Publisher ID) - For legacy "oneVideo" AND new partners/publishers. +**Important:** pubId integration (option 2) is only possible when your seller account is setup for "Inventory Mapping". **Please Note:** Most examples in this file are using dcn & pos. ## Who is currently eligible for "pubId" integration At this time, only the following partners/publishers are eligble for pubId integration: -1. New partners/publishers that do not have any existing accounts on Yahoo SSP (aka: aol, oneMobile, oneDisplay). +1. New partners/publishers that do not have an existing account with Yahoo Advertising (aka: aol, oneMobile, oneDisplay). 2. Video SSP (oneVideo) partners/publishers that A. Do not have any display/banner inventory. - B. Do not have any existing accounts on Yahoo SSP (aka: aol, oneMobile, oneDisplay). + B. Do not have an existing account with Yahoo Advertising (aka: aol, oneMobile, oneDisplay). # Mandatory Bidder Parameters ## dcn & pos (DEFAULT) -The minimal requirements for the 'yahoossp' bid adapter to generate an outbound bid-request to our Yahoo SSP are: +The minimal requirements for the Yahoo Advertising bid adapter to generate an outbound bid-request to Yahoo's bid endpoint are: 1. At least 1 adUnit including mediaTypes: banner or video 2. **bidder.params** object must include: - A. **dcn:** Yahoo SSP Site/App inventory parameter. - B. **pos:** Yahoo SSP position inventory parameter. + A. **dcn:** Yahoo Advertising Site/App inventory parameter. + B. **pos:** Yahoo Advertising position inventory parameter. ### Example: dcn & pos Mandatory Parameters (Single banner adUnit) ```javascript @@ -76,10 +78,10 @@ const adUnits = [{ }, bids: [ { - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided from SSP - pos: '8a969978017a7aaabab4ab0bc01a0009' // Placement ID provided from SSP + dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided by Yahoo Advertising + pos: '8a969978017a7aaabab4ab0bc01a0009' // Placement ID provided by Yahoo Advertising } } ] @@ -87,10 +89,10 @@ const adUnits = [{ ``` ## pubId -The minimal requirements for the 'yahoossp' bid adapter to generate an outbound bid-request to our Yahoo SSP are: +The minimal requirements for the Yahoo Advertising bid adapter to generate an outbound bid-request to Yahoo's bid endpoint are: 1. At least 1 adUnit including mediaTypes: banner or video 2. **bidder.params** object must include: - A. **pubId:** Yahoo SSP Publisher ID (AKA oneVideo pubId/Exchange name) + A. **pubId:** Yahoo Advertising Publisher ID (AKA oneVideo pubId/Exchange name) ### Example: pubId Mandatory Parameters (Single banner adUnit) ```javascript @@ -103,14 +105,15 @@ const adUnits = [{ }, bids: [ { - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - pubId: 'DemoPublisher', // Publisher External ID provided from Yahoo SSP. + pubId: 'DemoPublisher', // Publisher defined external ID as configured by Yahoo Advertising. } } ] }]; ``` + # Advanced adUnit Examples: ## Banner ```javascript @@ -124,21 +127,22 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided from Yahoo SSP - pos: '8a969978017a7aaabab4ab0bc01a0009', // Placement ID provided from Yahoo SSP + dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided by Yahoo Advertising + pos: '8a969978017a7aaabab4ab0bc01a0009', // Placement ID provided by Yahoo Advertising } } }] }]; ``` + ## Video Instream -**Important!** Make sure that the Yahoo SSP Placement type (in-stream) matches the adUnit video inventory type. +**Important!** Make sure that the Yahoo Advertising Placement type (in-stream) matches the adUnit video inventory type. **Note:** Make sure to set the adapter mode to allow video requests by setting it to mode: 'video' OR mode: 'all'. ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { mode: 'video' } }); @@ -156,20 +160,21 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided from Yahoo SSP - pos: '8a96958a017a7a57ac375d50c0c700cc', // Placement ID provided from Yahoo SSP + dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided by Yahoo Advertising + pos: '8a96958a017a7a57ac375d50c0c700cc', // Placement ID provided by Yahoo Advertising } }] }]; + ``` ## Video Outstream -**Important!** Make sure that the Yahoo SSP Placement type (in-feed/ in-article) matches the adUnit video inventory type. +**Important!** Make sure that the Yahoo Advertsing placement type (in-feed/ in-article) matches the adUnit video inventory type. **Note:** Make sure to set the adapter mode to allow video requests by setting it to mode: 'video' OR mode: 'all' ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { mode: 'video' } }); @@ -187,22 +192,22 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided from Yahoo SSP - pos: '8a96958a017a7a57ac375d50c0c700cc', // Placement ID provided from Yahoo SSP + dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided by Yahoo Advertising + pos: '8a96958a017a7a57ac375d50c0c700cc', // Placement ID provided by Yahoo Advertising } }] }]; + ``` ## Multi-Format -**Important!** If you intend to use the yahoossp bidder for both Banner and Video formats please make sure: -1. Set the adapter as mode: 'all' - to call the Yahoo SSP for both banner & video formats. -2. Make sure the Yahoo SSP placement (pos id) supports both banner & video format requests. - +**Important!** If you intend to use the Yahoo Advertising bidder for both Banner and Video formats please make sure: +1. Set the adapter as mode: 'all' - to configure the bid adapter to call the bid endpoint for both banner & video formats. +2. Make sure the Yahoo Advertising placement (pos id) supports both banner & video format requests. ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { mode: 'all' } }); @@ -223,19 +228,18 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided from Yahoo SSP - pos: '8a96958a017a7a57ac375d50c0c700cc', // Placement ID provided from Yahoo SSP + dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided by Yahoo Advertising + pos: '8a96958a017a7a57ac375d50c0c700cc', // Placement ID provided by Yahoo Advertising } }] }]; ``` # Optional: Schain module support -The yahoossp adapter supports the Prebid.org Schain module and will pass it through to our Yahoo SSP +The Yahoo Advertising bid adapter supports the Prebid.org Schain module and will pass it through to our bid endpoint. For further details please see, https://docs.prebid.org/dev-docs/modules/schain.html - ## Global Schain Example: ```javascript pbjs.setConfig({ @@ -256,7 +260,7 @@ For further details please see, https://docs.prebid.org/dev-docs/modules/schain. ## Bidder Specific Schain Example: ```javascript pbjs.setBidderConfig({ - "bidders": ['yahoossp'], // can list more bidders here if they share the same config + "bidders": ['yahooAds'], // can list more bidders here if they share the same config "config": { "schain": { "validation": "strict", @@ -275,12 +279,10 @@ For further details please see, https://docs.prebid.org/dev-docs/modules/schain. ``` # Optional: Price floors module & bidfloor -The yahoossp adapter supports the Prebid.org Price Floors module and will use it to define the outbound bidfloor and currency. -By default the adapter will always check the existance of Module price floor. -If a module price floor does not exist you can set a custom bid floor for your impression using "params.bidOverride.imp.bidfloor". +The Yahoo Advertising bid adapter supports the Prebid.org Price Floors module and will use it to define the outbound bidfloor and currency, if the relevant floors have been defined in the configuration. +A cusom method for defining bid floors is also supported, this can be enabled by setting the `params.bidOverride.imp.bidfloor` bidder parameter. **Note:** All override params apply to all requests generated using this configuration regardless of format type. - ```javascript const adUnits = [{ code: 'override-pricefloor', @@ -292,10 +294,10 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { - dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided from Yahoo SSP - pos: '8a969978017a7aaabab4ab0bc01a0009', // Placement ID provided from Yahoo SSP + dcn: '8a969516017a7a396ec539d97f540011', // Site/App ID provided by Yahoo Advertising + pos: '8a969978017a7aaabab4ab0bc01a0009', // Placement ID provided by Yahoo Advertising bidOverride :{ imp: { bidfloor: 5.00 // bidOverride priceFloor @@ -310,21 +312,21 @@ const adUnits = [{ For further details please see, https://docs.prebid.org/dev-docs/modules/floors.html # Optional: Self-served E2E testing mode -If you want to see how the yahoossp adapter works and loads you are invited to try it out using our testing mode. +If you want to see how the Yahoo Advertising bid adapter works and loads you are invited to try it out using our testing mode. This is useful for integration testing and response parsing when checking banner vs video capabilities. ## How to use E2E test mode: -1. Set the yahoossp global config mode to either 'banner' or 'video' - depending on the adUnit you want to test. +1. Set the `yahooAds` global config mode to either `'banner'` or `'video'` - depending on the adUnit you want to test. 2. Add params.testing.e2etest: true to your adUnit bidder config - See examples below. **Note:** When using E2E Test Mode you do not need to pass mandatory bidder params dcn or pos. -**Important!** E2E Testing Mode only works when the Bidder Request Mode is set explicitly to either 'banner' or 'video'. +**Important!** E2E Testing Mode only works when the Bidder Request Mode is set explicitly to either `'banner'` or `'video'`. ## Activating E2E Test for "Banner" ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { mode: 'banner' // select 'banner' or 'video' to define what response to load } }); @@ -338,7 +340,7 @@ const adUnits = [{ }, bids: [ { - bidder: 'yahoossp', + bidder: 'yahooAds', params: { testing: { e2etest: true // Activate E2E Test mode @@ -353,7 +355,7 @@ const adUnits = [{ **Note:** We recommend using Video Outstream as it would load the video response using our Outstream Renderer feature ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { mode: 'video' } }); @@ -371,7 +373,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { testing: { e2etest: true // Activate E2E Test mode @@ -382,8 +384,8 @@ const adUnits = [{ ``` # Optional: First Party Data -The yahoossp adapter now supports first party data passed via: -1. Global ortb2 object using pbjs.setConfig() +The Yahoo Advertising bid adapter supports first party data passed via: +1. Global ortb2 object using `pbjs.setConfig()` 2. adUnit ortb2Imp object declared within an adUnit. For further details please see, https://docs.prebid.org/features/firstPartyData.html ## Global First Party Data "ortb2" @@ -392,15 +394,15 @@ For further details please see, https://docs.prebid.org/features/firstPartyData. pbjs.setConfig({ ortb2: { site: { - name: 'yahooAdTech', - domain: 'yahooadtech.com', + name: 'Yahoo Advertising', + domain: 'yahooadvertising.com', cat: ['IAB2'], sectioncat: ['IAB2-2'], pagecat: ['IAB2-2'], - page: 'https://page.yahooadtech.com/here.html', - ref: 'https://ref.yahooadtech.com/there.html', + page: 'https://page.yahooadvertising.com.com/here.html', + ref: 'https://ref.yahooadvertising.com.com/there.html', keywords:'yahoo, ad, tech', - search: 'SSP', + search: 'header bidding', content: { id: '1234', title: 'Title', @@ -435,6 +437,43 @@ pbjs.setConfig({ } }); ``` + +Notes: The first party site info is filtered and only the following specific keys are allowed in the bidRequests: + +| Field | Type | +|-----------------------------|--------| +| site.name | String | +| site.domain | String | +| site.page | String | +| site.ref | String | +| site.keywords | String | +| site.search | String | +| site.cat | Array | +| site.sectioncat | Array | +| site.pagecat | Array | +| site.ext | Object | +| site.publisher.ext | Object | +| site.content.id | String | +| site.content.title | String | +| site.content.series | String | +| site.content.season | String | +| site.content.genre | String | +| site.content.contentrating | String | +| site.content.language | String | +| site.content.episode | Number | +| site.content.prodq | Number | +| site.content.context | Number | +| site.content.livestream | Number | +| site.content.len | Number | +| site.content.cat | Array | +| site.content.ext | Object | +| site.content.data | Array | +| site.content.data[].id | String | +| site.content.data[].name | String | +| site.content.data[].segment | Array | +| site.content.data[].ext | Object | + + ### Passing First Party "user" data: ```javascript pbjs.setConfig({ @@ -484,7 +523,7 @@ pbjs.setConfig({ ## AdUnit First Party Data "ortb2Imp" Most DSPs are adopting the Global Placement ID (GPID). -Please pass your placement specific GPID value to Yahoo SSP using `adUnit.ortb2Imp.ext.data.pbadslot`. +Please pass your placement specific GPID value by setting `adUnit.ortb2Imp.ext.data.pbadslot`. ```javascript const adUnits = [{ code: 'placement', @@ -504,7 +543,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { pubdId: 'DemoPublisher' } @@ -514,7 +553,7 @@ const adUnits = [{ ``` # Optional: Bidder bidOverride Parameters -The yahoossp adapter allows passing override data to the outbound bid-request in that overrides First Party Data. +The Yahoo Advertising bid adapter allows passing override data to the outbound bid-request that overrides First Party Data. **Important!** We highly recommend using prebid modules to pass data instead of bidder speicifc overrides. The use of these parameters are a last resort to force a specific feature or use case in your implementation. @@ -540,7 +579,6 @@ Currently the bidOverride object only accepts the following: * device * ip - ```javascript const adUnits = [{ code: 'bidOverride-adUnit', @@ -553,7 +591,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { dcn: '8a969516017a7a396ec539d97f540011', pos: '8a96958a017a7a57ac375d50c0c700cc', @@ -578,7 +616,7 @@ const adUnits = [{ } }, site: { - page: 'https://yahoossp-bid-adapter.com', + page: 'https://yahooAdvertising-bid-adapter.com', }, device: { ip: "1.2.3.4" @@ -593,7 +631,7 @@ const adUnits = [{ Custom key-value paris can be used for both inventory targeting and reporting. You must set up key-value pairs in the Yahoo SSP before sending them via the adapter otherwise the Ad Server will not be listening and picking them up. -Important! Key-value pairs can only contain values of types: String, Number, Array of strings OR Array of numbers +Important! Key-value pairs can only contain values of the following data types: String, Number, Array of strings OR Array of numbers ```javascript const adUnits = [{ @@ -607,7 +645,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { dcn: '8a969516017a7a396ec539d97f540011', pos: '8a96958a017a7a57ac375d50c0c700cc', @@ -623,14 +661,14 @@ const adUnits = [{ ``` # Optional: Custom Cache Time To Live (ttl): -The yahoossp adapter supports passing of "Time To Live" (ttl) that indicates to prebid chache for how long to keep the chaced winning bid alive. Value is Number in seconds and you can enter any number between 1 - 3600 (seconds). -The setting can be defined globally using setConfig or within the adUnit.params. -Global level setConfig overrides adUnit.params. +The Yahoo Advertising bid adapter supports passing of "Time To Live" (ttl) to indicate to prebid how long the bid response from Yahoo Advertising should be retained by Prebid for. This configuration value must be a Number in seconds, with the valid range being 1 - 3600 inclusive. +The setting can be defined globally using `setConfig` or within the adUnit.params. +Global level `setConfig` overrides adUnit.params. If no value is being passed default is 300 seconds. ## Global TTL ```javascript pbjs.setConfig({ - yahoossp: { + yahooAds: { ttl: 300 } }); @@ -646,7 +684,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { dcn: '8a969516017a7a396ec539d97f540011', pos: '8a96958a017a7a57ac375d50c0c700cc', @@ -665,7 +703,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { dcn: '8a969516017a7a396ec539d97f540011', pos: '8a96958a017a7a57ac375d50c0c700cc', @@ -673,10 +711,11 @@ const adUnits = [{ } }] }] + ``` # Optional: Video Features ## Rewarded video flag -To indicate to Yahoo SSP that this adUnit is a rewarded video you can pass the following in the params.bidOverride.imp.video.rewarded: 1 +To indicate to Yahoo Advertising that this adUnit is a rewarded video you can set the `params.bidOverride.imp.video.rewarded` property to `1` ```javascript const adUnits = [{ @@ -690,7 +729,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { dcn: '8a969516017a7a396ec539d97f540011', pos: '8a96958a017a7a57ac375d50c0c700cc', @@ -707,7 +746,7 @@ const adUnits = [{ ``` ## Site/App Targeting for "pubId" Inventory Mapping -To target your adUnit explicitly to a specific Site/App Object in Yahoo SSP, you can pass one of the following: +To target your adUnit explicitly to a specific Site/App Object in Yahoo Advertising, you can pass one of the following: 1. params.siteId = External Site ID || Video SSP RTBIS Id (in String format). 2. params.bidOverride.site.id = External Site ID || Video SSP RTBIS Id (in String format). **Important:** Site override is a only supported when using "pubId" mode. @@ -725,7 +764,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { pubId: 'DemoPublisher', siteId: '1234567'; @@ -735,13 +774,13 @@ const adUnits = [{ ``` ## Placement Targeting for "pubId" Inventory Mapping -To target your adUnit explicitly to a specific Placement within a Site/App Object in Yahoo SSP, you can pass the following params.placementId = External Placement ID || Placement Alias +To target your adUnit explicitly to a specific Placement within a Site/App Object in Yahoo Advertising, you can pass the following params.placementId = External Placement ID || Placement Alias **Important!** Placement override is a only supported when using "pubId" mode. -**Important!** It is highly recommended that you pass both `siteId` AND `placementId` together to avoid inventory miss matching. +**Important!** It is highly recommended that you pass both `siteId` AND `placementId` together to avoid inventory mismatching. ### Site & Placement override -**Important!** If the placement ID does not reside under the defined Site/App object, the request will not resolve and no response will be sent back from the ad-server. +**Important!** If the placement ID does not reside under the defined Site/App object, the request will not resolve and no response will be sent back from the bid-server. ```javascript const adUnits = [{ code: 'pubId-site-targeting-adUnit', @@ -754,7 +793,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { pubId: 'DemoPublisher', siteId: '1234567', @@ -764,7 +803,7 @@ const adUnits = [{ }] ``` ### Placement only override -**Important!** Using this method is not advised if you have multiple Site/Apps that are broken out of a Run Of Network (RON) Site/App. If the placement ID does not reside under a matching Site/App object, the request will not resolve and no response will be sent back from the ad-server. +**Important!** Using this method is not advised if you have multiple Site/Apps that are broken out of a Run Of Network (RON) Site/App. If the placement ID does not reside under a matching Site/App object, the request will not resolve and no response will be sent back from the bid-server. ```javascript const adUnits = [{ code: 'pubId-site-targeting-adUnit', @@ -777,7 +816,7 @@ const adUnits = [{ } }, bids: [{ - bidder: 'yahoossp', + bidder: 'yahooAds', params: { pubId: 'DemoPublisher', placementId: 'header-250x300' @@ -787,9 +826,8 @@ const adUnits = [{ ``` # Optional: Legacy override Parameters -This adapter does not support passing legacy overrides via 'bidder.params.ext' since most of the data should be passed using prebid modules (First Party Data, Schain, Price Floors etc.). +This adapter does not support passing legacy overrides via `bidder.params.ext` since most of the data should be passed using prebid modules (First Party Data, Schain, Price Floors etc.). If you do not know how to pass a custom parameter that you previously used, please contact us using the information provided above. -Thanks you, -Yahoo SSP - +Thank you, +Yahoo Advertsing diff --git a/modules/yandexBidAdapter.js b/modules/yandexBidAdapter.js index e20f71bc08d..9ca989b2259 100644 --- a/modules/yandexBidAdapter.js +++ b/modules/yandexBidAdapter.js @@ -1,107 +1,388 @@ -import {parseUrl, formatQS, deepAccess} from '../src/utils.js'; +import { formatQS, deepAccess, deepSetValue, triggerPixel, _each, _map } from '../src/utils.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { BANNER, NATIVE } from '../src/mediaTypes.js' +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; +import { config } from '../src/config.js'; const BIDDER_CODE = 'yandex'; -const BIDDER_URL = 'https://bs-metadsp.yandex.ru/metadsp'; +const BIDDER_URL = 'https://bs.yandex.ru/prebid'; const DEFAULT_TTL = 180; +const DEFAULT_CURRENCY = 'EUR'; +const SUPPORTED_MEDIA_TYPES = [ BANNER, NATIVE ]; const SSP_ID = 10500; +const IMAGE_ASSET_TYPES = { + ICON: 1, + IMAGE: 3, +}; +const DATA_ASSET_TYPES = { + TITLE: 0, + SPONSORED: 1, + DESC: 2, + RATING: 3, + LIKES: 4, + ADDRESS: 9, + DESC2: 10, + DISPLAY_URL: 11, + CTA_TEXT: 12, + E_504: 504, +}; +export const NATIVE_ASSETS = { + title: [1, DATA_ASSET_TYPES.TITLE], + body: [2, DATA_ASSET_TYPES.DESC], + body2: [3, DATA_ASSET_TYPES.DESC2], + sponsoredBy: [4, DATA_ASSET_TYPES.SPONSORED], + icon: [5, IMAGE_ASSET_TYPES.ICON], + image: [6, IMAGE_ASSET_TYPES.IMAGE], + displayUrl: [7, DATA_ASSET_TYPES.DISPLAY_URL], + cta: [8, DATA_ASSET_TYPES.CTA_TEXT], + rating: [9, DATA_ASSET_TYPES.RATING], + likes: [10, DATA_ASSET_TYPES.LIKES], +} +const NATIVE_ASSETS_IDS = {}; +_each(NATIVE_ASSETS, (asset, key) => { NATIVE_ASSETS_IDS[asset[0]] = key }); + export const spec = { code: BIDDER_CODE, aliases: ['ya'], // short code + supportedMediaTypes: SUPPORTED_MEDIA_TYPES, isBidRequestValid: function(bid) { - return !!(bid.params && bid.params.pageId && bid.params.impId); + const { params } = bid; + if (!params) { + return false; + } + const { pageId, impId } = extractPlacementIds(params); + if (!(pageId && impId)) { + return false; + } + return true; }, buildRequests: function(validBidRequests, bidderRequest) { - const gdprApplies = deepAccess(bidderRequest, 'gdprConsent.gdprApplies'); - const consentString = deepAccess(bidderRequest, 'gdprConsent.consentString'); + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); let referrer = ''; + let domain = ''; + let page = ''; + if (bidderRequest && bidderRequest.refererInfo) { - const url = parseUrl(bidderRequest.refererInfo.referer); - referrer = url.hostname; + referrer = bidderRequest.refererInfo.ref; + domain = bidderRequest.refererInfo.domain; + page = bidderRequest.refererInfo.page; } + let timeout = null; + if (bidderRequest) { + timeout = bidderRequest.timeout; + } + + const adServerCurrency = config.getConfig('currency.adServerCurrency'); + return validBidRequests.map((bidRequest) => { const { params } = bidRequest; - const { pageId, impId, targetRef, withCredentials = true } = params; + const { targetRef, withCredentials = true, cur } = params; + + const { pageId, impId } = extractPlacementIds(params); const queryParams = { 'imp-id': impId, - 'target-ref': targetRef || referrer, + 'target-ref': targetRef || domain, 'ssp-id': SSP_ID, }; - if (gdprApplies !== undefined) { + + const gdprApplies = Boolean(deepAccess(bidderRequest, 'gdprConsent.gdprApplies')); + if (gdprApplies) { + const consentString = deepAccess(bidderRequest, 'gdprConsent.consentString'); queryParams['gdpr'] = 1; queryParams['tcf-consent'] = consentString; } + const imp = { id: impId, + banner: mapBanner(bidRequest), + native: mapNative(bidRequest), }; - const bannerParams = deepAccess(bidRequest, 'mediaTypes.banner'); - if (bannerParams) { - const [ w, h ] = bannerParams.sizes[0]; - imp.banner = { - w, - h, - }; + const bidfloor = getBidfloor(bidRequest); + if (bidfloor) { + imp.bidfloor = bidfloor.floor; + imp.bidfloorcur = bidfloor.currency; + } + + const currency = cur || adServerCurrency; + if (currency) { + queryParams['ssp-cur'] = currency; + } + + const data = { + id: bidRequest.bidId, + imp: [imp], + site: { + ref: referrer, + page, + domain, + }, + tmax: timeout, + }; + + const eids = deepAccess(bidRequest, 'userIdAsEids'); + if (eids && eids.length) { + deepSetValue(data, 'user.ext.eids', eids); } const queryParamsString = formatQS(queryParams); return { method: 'POST', url: BIDDER_URL + `/${pageId}?${queryParamsString}`, - data: { - id: bidRequest.bidId, - imp: [imp], - site: { - page: referrer, - }, - }, + data, options: { withCredentials, }, bidRequest, - } + }; }); }, - interpretResponse: function(serverResponse, {bidRequest}) { - let response = serverResponse.body; - if (!response.seatbid) { - return []; + interpretResponse: interpretResponse, + + onBidWon: function (bid) { + const nurl = bid['nurl']; + + if (!nurl) { + return; } - const { cur, seatbid } = serverResponse.body; - const rtbBids = seatbid - .map(seatbid => seatbid.bid) - .reduce((a, b) => a.concat(b), []); - - return rtbBids.map(rtbBid => { - let prBid = { - requestId: bidRequest.bidId, - cpm: rtbBid.price, - currency: cur || 'USD', - width: rtbBid.w, - height: rtbBid.h, - creativeId: rtbBid.adid, - - netRevenue: true, - ttl: DEFAULT_TTL, - - meta: { - advertiserDomains: rtbBid.adomain && rtbBid.adomain.length > 0 ? rtbBid.adomain : [], - } - }; + triggerPixel(nurl); + } +} + +function extractPlacementIds(bidRequestParams) { + const { placementId } = bidRequestParams; + const result = { pageId: null, impId: null }; + + let pageId, impId; + if (placementId) { + /* + * Possible formats + * R-I-123456-2 + * R-123456-1 + * 123456-789 + */ + const num = placementId.lastIndexOf('-'); + if (num === -1) { + return result; + } + const num2 = placementId.lastIndexOf('-', num - 1); + pageId = placementId.slice(num2 + 1, num); + impId = placementId.slice(num + 1); + } else { + pageId = bidRequestParams.pageId; + impId = bidRequestParams.impId; + } + + if (!parseInt(pageId, 10) || !parseInt(impId, 10)) { + return result; + } - prBid.ad = rtbBid.adm; + result.pageId = pageId; + result.impId = impId; - return prBid; + return result; +} + +function getBidfloor(bidRequest) { + const floors = []; + + if (typeof bidRequest.getFloor === 'function') { + SUPPORTED_MEDIA_TYPES.forEach(type => { + if (bidRequest.hasOwnProperty(type)) { + const floorInfo = bidRequest.getFloor({ + currency: DEFAULT_CURRENCY, + mediaType: type, + size: bidRequest.sizes || '*' } + ) + floors.push(floorInfo); + } }); - }, + } + + return floors.sort((a, b) => b.floor - a.floor)[0]; +} + +function mapBanner(bidRequest) { + if (deepAccess(bidRequest, 'mediaTypes.banner')) { + const sizes = bidRequest.sizes || bidRequest.mediaTypes.banner.sizes; + const format = sizes.map((size) => ({ + w: size[0], + h: size[1], + })); + const { w, h } = format[0]; + + return { + format, + w, + h, + } + } +} + +function mapNative(bidRequest) { + const adUnitNativeAssets = deepAccess(bidRequest, 'mediaTypes.native'); + if (adUnitNativeAssets) { + const assets = []; + + Object.keys(adUnitNativeAssets).forEach((assetCode) => { + if (NATIVE_ASSETS.hasOwnProperty(assetCode)) { + const nativeAsset = NATIVE_ASSETS[assetCode]; + const adUnitAssetParams = adUnitNativeAssets[assetCode]; + const asset = mapAsset(assetCode, adUnitAssetParams, nativeAsset); + assets.push(asset); + } + }); + + return { + ver: 1.1, + request: JSON.stringify({ + ver: 1.1, + assets + }), + }; + } +} + +function mapAsset(assetCode, adUnitAssetParams, nativeAsset) { + const [ nativeAssetId, nativeAssetType ] = nativeAsset; + const asset = { + id: nativeAssetId, + }; + + if (adUnitAssetParams.required) { + asset.required = 1; + } + + if (assetCode === 'title') { + asset.title = { + len: adUnitAssetParams.len || 25, + }; + } else if (assetCode === 'image' || assetCode === 'icon') { + asset.img = mapImageAsset(adUnitAssetParams, nativeAssetType); + } else { + asset.data = { + type: nativeAssetType, + len: adUnitAssetParams.len, + }; + } + + return asset; +} + +function mapImageAsset(adUnitImageAssetParams, nativeAssetType) { + const img = { + type: nativeAssetType, + }; + + if (adUnitImageAssetParams.aspect_ratios) { + const ratio = adUnitImageAssetParams.aspect_ratios[0]; + const minWidth = ratio.min_width || 100; + + img.wmin = minWidth; + img.hmin = (minWidth / ratio.ratio_width * ratio.ratio_height); + } + + if (adUnitImageAssetParams.sizes) { + const size = Array.isArray(adUnitImageAssetParams.sizes[0]) ? adUnitImageAssetParams.sizes[0] : adUnitImageAssetParams.sizes; + img.w = size[0]; + img.h = size[1]; + } + + return img; +} + +function interpretResponse(serverResponse, { bidRequest }) { + let response = serverResponse.body; + if (!response.seatbid) { + return []; + } + const { seatbid, cur } = serverResponse.body; + const bidsReceived = seatbid + .map(seatbid => seatbid.bid) + .reduce((a, b) => a.concat(b), []); + + const currency = cur || DEFAULT_CURRENCY; + + return bidsReceived.map(bidReceived => { + const price = bidReceived.price; + let prBid = { + requestId: bidRequest.bidId, + cpm: price, + currency: currency, + width: bidReceived.w, + height: bidReceived.h, + creativeId: bidReceived.adid, + nurl: replaceAuctionPrice(bidReceived.nurl, price, currency), + + netRevenue: true, + ttl: DEFAULT_TTL, + + meta: { + advertiserDomains: bidReceived.adomain && bidReceived.adomain.length > 0 ? bidReceived.adomain : [], + } + }; + + if (bidReceived.adm.indexOf('{') === 0) { + prBid.mediaType = NATIVE; + prBid.native = interpretNativeAd(bidReceived, price, currency); + } else { + prBid.mediaType = BANNER; + prBid.ad = bidReceived.adm; + } + + return prBid; + }); +} + +function interpretNativeAd(bidReceived, price, currency) { + try { + const { adm } = bidReceived; + const { native } = JSON.parse(adm); + + const result = { + clickUrl: native.link.url, + }; + + native.assets.forEach(asset => { + const assetCode = NATIVE_ASSETS_IDS[asset.id]; + if (!assetCode) { + return; + } + if (assetCode === 'image' || assetCode === 'icon') { + result[assetCode] = { + url: asset.img.url, + width: asset.img.w, + height: asset.img.h + }; + } else if (assetCode === 'title') { + result[assetCode] = asset.title.text; + } else { + result[assetCode] = asset.data.value; + } + }); + + result.impressionTrackers = _map(native.imptrackers, (tracker) => + replaceAuctionPrice(tracker, price, currency) + ); + + return result; + } catch (e) {} +} + +function replaceAuctionPrice(url, price, currency) { + if (!url) return; + + return url + .replace(/\${AUCTION_PRICE}/, price) + .replace(/\${AUCTION_CURRENCY}/, currency); } registerBidder(spec); diff --git a/modules/yandexBidAdapter.md b/modules/yandexBidAdapter.md index 7a51d7bc5fb..55a658cc25c 100644 --- a/modules/yandexBidAdapter.md +++ b/modules/yandexBidAdapter.md @@ -12,29 +12,66 @@ Yandex Bidder Adapter for Prebid.js. # Parameters -| Name | Scope | Description | Example | Type | -|---------------|----------|-------------------------|-----------|-----------| -| `pageId` | required | Page ID | `123` | `Integer` | -| `impId` | required | Block ID | `1` | `Integer` | +| Name | Required? | Description | Example | Type | +|---------------|--------------------------------------------|-------------|---------|-----------| +| `placementId` | Yes | Block ID | `123-1` | `String` | +| `pageId` | No
Deprecated. Please use `placementId` | Page ID | `123` | `Integer` | +| `impId` | No
Deprecated. Please use `placementId` | Imp ID | `1` | `Integer` | # Test Parameters -``` -var adUnits = [{ - code: 'banner-1', - mediaTypes: { - banner: { - sizes: [[240, 400]], - } +```javascript +var adUnits = [ + { // banner + code: 'banner-1', + mediaTypes: { + banner: { + sizes: [[240, 400], [300, 600]], + } + }, + bids: [ + { + bidder: 'yandex', + params: { + placementId: '346580-1' + }, + } + ], }, - bids: [{ - { - bidder: 'yandex', - params: { - pageId: 346580, - impId: 143, + { // native + code: 'banner-2', + mediaTypes: { + native: { + title: { + required: true, + len: 25 + }, + image: { + required: true, + sizes: [300, 250], + }, + icon: { + sizes: [32, 32], + }, + body: { + len: 90 + }, + body2: { + len: 90 + }, + sponsoredBy: { + len: 25, + } }, - } - }] -}]; + }, + bids: [ + { + bidder: 'yandex', + params: { + placementId: '346580-1' + }, + } + ], + }, +]; ``` diff --git a/modules/yieldlabBidAdapter.js b/modules/yieldlabBidAdapter.js index 9535461f4c7..b0136cd21ea 100644 --- a/modules/yieldlabBidAdapter.js +++ b/modules/yieldlabBidAdapter.js @@ -1,117 +1,152 @@ -import { _each, deepAccess, isArray, isPlainObject, timestamp } from '../src/utils.js' -import { registerBidder } from '../src/adapters/bidderFactory.js' -import { find } from '../src/polyfill.js' -import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js' -import { Renderer } from '../src/Renderer.js' -import { config } from '../src/config.js' - -const ENDPOINT = 'https://ad.yieldlab.net' -const BIDDER_CODE = 'yieldlab' -const BID_RESPONSE_TTL_SEC = 300 -const CURRENCY_CODE = 'EUR' -const OUTSTREAMPLAYER_URL = 'https://ad.adition.com/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event' -const GVLID = 70 +import { _each, deepAccess, isArray, isFn, isPlainObject, timestamp } from '../src/utils.js'; +import { registerBidder } from '../src/adapters/bidderFactory.js'; +import { find } from '../src/polyfill.js'; +import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'; +import { Renderer } from '../src/Renderer.js'; +import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; + +const ENDPOINT = 'https://ad.yieldlab.net'; +const BIDDER_CODE = 'yieldlab'; +const BID_RESPONSE_TTL_SEC = 300; +const CURRENCY_CODE = 'EUR'; +const OUTSTREAMPLAYER_URL = 'https://ad.adition.com/dynamic.ad?a=o193092&ma_loadEvent=ma-start-event'; +const GVLID = 70; +const DIMENSION_SIGN = 'x'; +const IMG_TYPE_ICON = 1; +const IMG_TYPE_MAIN = 3; export const spec = { code: BIDDER_CODE, gvlid: GVLID, supportedMediaTypes: [VIDEO, BANNER, NATIVE], - isBidRequestValid: function (bid) { + /** + * @param {object} bid + * @returns {boolean} + */ + isBidRequestValid(bid) { if (bid && bid.params && bid.params.adslotId && bid.params.supplyId) { - return true + return true; } - return false + return false; }, /** * This method should build correct URL - * @param validBidRequests - * @returns {{method: string, url: string}} + * @param {BidRequest[]} validBidRequests + * @param [bidderRequest] + * @returns {ServerRequest|ServerRequest[]} */ - buildRequests: function (validBidRequests, bidderRequest) { - const adslotIds = [] - const timestamp = Date.now() + buildRequests(validBidRequests, bidderRequest) { + // convert Native ORTB definition to old-style prebid native definition + validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + + const adslotIds = []; + const adslotSizes = []; + const adslotFloors = []; + const timestamp = Date.now(); const query = { ts: timestamp, - json: true - } + json: true, + }; _each(validBidRequests, function (bid) { - adslotIds.push(bid.params.adslotId) + adslotIds.push(bid.params.adslotId); + const sizes = extractSizes(bid); + if (sizes.length > 0) { + adslotSizes.push(bid.params.adslotId + ':' + sizes.join('|')); + } + if (bid.params.extId) { + query.id = bid.params.extId; + } if (bid.params.targeting) { - query.t = createTargetingString(bid.params.targeting) + query.t = createTargetingString(bid.params.targeting); } if (bid.userIdAsEids && Array.isArray(bid.userIdAsEids)) { - query.ids = createUserIdString(bid.userIdAsEids) + query.ids = createUserIdString(bid.userIdAsEids); + query.atypes = createUserIdAtypesString(bid.userIdAsEids); } if (bid.params.customParams && isPlainObject(bid.params.customParams)) { - for (let prop in bid.params.customParams) { - query[prop] = bid.params.customParams[prop] + for (const prop in bid.params.customParams) { + query[prop] = bid.params.customParams[prop]; } } if (bid.schain && isPlainObject(bid.schain) && Array.isArray(bid.schain.nodes)) { - query.schain = createSchainString(bid.schain) + query.schain = createSchainString(bid.schain); } - const iabContent = getContentObject(bid) + const iabContent = getContentObject(bid); if (iabContent) { - query.iab_content = createIabContentString(iabContent) + query.iab_content = createIabContentString(iabContent); + } + const floor = getBidFloor(bid, sizes); + if (floor) { + adslotFloors.push(bid.params.adslotId + ':' + floor); } - }) + }); if (bidderRequest) { - if (bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { - query.pubref = bidderRequest.refererInfo.referer + if (bidderRequest.refererInfo && bidderRequest.refererInfo.page) { + // TODO: is 'page' the right value here? + query.pubref = bidderRequest.refererInfo.page; } if (bidderRequest.gdprConsent) { - query.gdpr = (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true + query.gdpr = (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') ? bidderRequest.gdprConsent.gdprApplies : true; if (query.gdpr) { - query.consent = bidderRequest.gdprConsent.consentString + query.consent = bidderRequest.gdprConsent.consentString; } } } - const adslots = adslotIds.join(',') - const queryString = createQueryString(query) + const adslots = adslotIds.join(','); + if (adslotSizes.length > 0) { + query.sizes = adslotSizes.join(','); + } + + if (adslotFloors.length > 0) { + query.floor = adslotFloors.join(','); + } + + const queryString = createQueryString(query); return { method: 'GET', url: `${ENDPOINT}/yp/${adslots}?${queryString}`, validBidRequests: validBidRequests, - queryParams: query - } + queryParams: query, + }; }, /** * Map ad values and pricing and stuff - * @param serverResponse - * @param originalBidRequest + * @param {ServerResponse} serverResponse + * @param {BidRequest} originalBidRequest + * @returns {Bid[]} */ - interpretResponse: function (serverResponse, originalBidRequest) { - const bidResponses = [] - const timestamp = Date.now() - const reqParams = originalBidRequest.queryParams + interpretResponse(serverResponse, originalBidRequest) { + const bidResponses = []; + const timestamp = Date.now(); + const reqParams = originalBidRequest.queryParams; originalBidRequest.validBidRequests.forEach(function (bidRequest) { if (!serverResponse.body) { - return + return; } - let matchedBid = find(serverResponse.body, function (bidResponse) { - return bidRequest.params.adslotId == bidResponse.id - }) + const matchedBid = find(serverResponse.body, function (bidResponse) { + return bidRequest.params.adslotId == bidResponse.id; + }); if (matchedBid) { - const adUnitSize = bidRequest.sizes.length === 2 && !isArray(bidRequest.sizes[0]) ? bidRequest.sizes : bidRequest.sizes[0] - const adSize = bidRequest.params.adSize !== undefined ? parseSize(bidRequest.params.adSize) : (matchedBid.adsize !== undefined) ? parseSize(matchedBid.adsize) : adUnitSize - const extId = bidRequest.params.extId !== undefined ? '&id=' + bidRequest.params.extId : '' - const adType = matchedBid.adtype !== undefined ? matchedBid.adtype : '' - const gdprApplies = reqParams.gdpr ? '&gdpr=' + reqParams.gdpr : '' - const gdprConsent = reqParams.consent ? '&consent=' + reqParams.consent : '' - const pvId = matchedBid.pvid !== undefined ? '&pvid=' + matchedBid.pvid : '' - const iabContent = reqParams.iab_content ? '&iab_content=' + reqParams.iab_content : '' + const adUnitSize = bidRequest.sizes.length === 2 && !isArray(bidRequest.sizes[0]) ? bidRequest.sizes : bidRequest.sizes[0]; + const adSize = bidRequest.params.adSize !== undefined ? parseSize(bidRequest.params.adSize) : (matchedBid.adsize !== undefined) ? parseSize(matchedBid.adsize) : adUnitSize; + const extId = bidRequest.params.extId !== undefined ? '&id=' + bidRequest.params.extId : ''; + const adType = matchedBid.adtype !== undefined ? matchedBid.adtype : ''; + const gdprApplies = reqParams.gdpr ? '&gdpr=' + reqParams.gdpr : ''; + const gdprConsent = reqParams.consent ? '&consent=' + reqParams.consent : ''; + const pvId = matchedBid.pvid !== undefined ? '&pvid=' + matchedBid.pvid : ''; + const iabContent = reqParams.iab_content ? '&iab_content=' + reqParams.iab_content : ''; const bidResponse = { requestId: bidRequest.bidId, @@ -126,54 +161,64 @@ export const spec = { referrer: '', ad: ``, meta: { - advertiserDomains: (matchedBid.advertiser) ? matchedBid.advertiser : 'n/a' - } - } + advertiserDomains: (matchedBid.advertiser) ? matchedBid.advertiser : 'n/a', + }, + }; if (isVideo(bidRequest, adType)) { - const playersize = getPlayerSize(bidRequest) + const playersize = getPlayerSize(bidRequest); if (playersize) { - bidResponse.width = playersize[0] - bidResponse.height = playersize[1] + bidResponse.width = playersize[0]; + bidResponse.height = playersize[1]; } - bidResponse.mediaType = VIDEO - bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}${pvId}${iabContent}` + bidResponse.mediaType = VIDEO; + bidResponse.vastUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}${pvId}${iabContent}`; if (isOutstream(bidRequest)) { const renderer = Renderer.install({ id: bidRequest.bidId, url: OUTSTREAMPLAYER_URL, - loaded: false - }) - renderer.setRender(outstreamRender) - bidResponse.renderer = renderer + loaded: false, + }); + renderer.setRender(outstreamRender); + bidResponse.renderer = renderer; } } if (isNative(bidRequest, adType)) { - const url = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}${pvId}` - bidResponse.adUrl = url - bidResponse.mediaType = NATIVE - const nativeImageAssetObj = find(matchedBid.native.assets, e => e.id === 2) - const nativeImageAsset = nativeImageAssetObj ? nativeImageAssetObj.img : {url: '', w: 0, h: 0}; - const nativeTitleAsset = find(matchedBid.native.assets, e => e.id === 1) - const nativeBodyAsset = find(matchedBid.native.assets, e => e.id === 3) + const { native } = matchedBid; + const { assets } = native; + bidResponse.adUrl = `${ENDPOINT}/d/${matchedBid.id}/${bidRequest.params.supplyId}/?ts=${timestamp}${extId}${gdprApplies}${gdprConsent}${pvId}`; + bidResponse.mediaType = NATIVE; + const nativeIconAssetObj = find(assets, isImageAssetOfType(IMG_TYPE_ICON)); + const nativeImageAssetObj = find(assets, isImageAssetOfType(IMG_TYPE_MAIN)); + const nativeImageAsset = nativeImageAssetObj ? nativeImageAssetObj.img : { url: '', w: 0, h: 0 }; + const nativeTitleAsset = find(assets, asset => hasValidProperty(asset, 'title')); + const nativeBodyAsset = find(assets, asset => hasValidProperty(asset, 'data')); bidResponse.native = { title: nativeTitleAsset ? nativeTitleAsset.title.text : '', body: nativeBodyAsset ? nativeBodyAsset.data.value : '', + ...nativeIconAssetObj?.img && { + icon: { + url: nativeIconAssetObj.img.url, + width: nativeIconAssetObj.img.w, + height: nativeIconAssetObj.img.h, + }, + }, image: { url: nativeImageAsset.url, width: nativeImageAsset.w, height: nativeImageAsset.h, }, - clickUrl: matchedBid.native.link.url, - impressionTrackers: matchedBid.native.imptrackers, + clickUrl: native.link.url, + impressionTrackers: native.imptrackers, + assets: assets, }; } - bidResponses.push(bidResponse) + bidResponses.push(bidResponse); } - }) - return bidResponses + }); + return bidResponses; }, /** @@ -185,13 +230,13 @@ export const spec = { * @param {string} uspConsent Is the US Privacy Consent string. * @return {UserSync[]} The user syncs which should be dropped. */ - getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { + getUserSyncs(syncOptions, serverResponses, gdprConsent, uspConsent) { const syncs = []; if (syncOptions.iframeEnabled) { - let params = []; + const params = []; params.push(`ts=${timestamp()}`); - params.push(`type=h`) + params.push(`type=h`); if (gdprConsent && (typeof gdprConsent.gdprApplies === 'boolean')) { params.push(`gdpr=${Number(gdprConsent.gdprApplies)}`); } @@ -200,12 +245,12 @@ export const spec = { } syncs.push({ type: 'iframe', - url: `${ENDPOINT}/d/6846326/766/2x2?${params.join('&')}` + url: `${ENDPOINT}/d/6846326/766/2x2?${params.join('&')}`, }); } return syncs; - } + }, }; /** @@ -215,7 +260,7 @@ export const spec = { * @returns {Boolean} */ function isVideo(format, adtype) { - return deepAccess(format, 'mediaTypes.video') && adtype.toLowerCase() === 'video' + return deepAccess(format, 'mediaTypes.video') && adtype.toLowerCase() === 'video'; } /** @@ -225,7 +270,7 @@ function isVideo(format, adtype) { * @returns {Boolean} */ function isNative(format, adtype) { - return deepAccess(format, 'mediaTypes.native') && adtype.toLowerCase() === 'native' + return deepAccess(format, 'mediaTypes.native') && adtype.toLowerCase() === 'native'; } /** @@ -234,8 +279,8 @@ function isNative(format, adtype) { * @returns {Boolean} */ function isOutstream(format) { - let context = deepAccess(format, 'mediaTypes.video.context') - return (context === 'outstream') + const context = deepAccess(format, 'mediaTypes.video.context'); + return (context === 'outstream'); } /** @@ -244,30 +289,45 @@ function isOutstream(format) { * @returns {Array} */ function getPlayerSize(format) { - let playerSize = deepAccess(format, 'mediaTypes.video.playerSize') - return (playerSize && isArray(playerSize[0])) ? playerSize[0] : playerSize + const playerSize = deepAccess(format, 'mediaTypes.video.playerSize'); + return (playerSize && isArray(playerSize[0])) ? playerSize[0] : playerSize; } /** - * Expands a 'WxH' string as a 2-element [W, H] array + * Expands a 'WxH' string to a 2-element [W, H] array * @param {String} size * @returns {Array} */ function parseSize(size) { - return size.split('x').map(Number) + return size.split(DIMENSION_SIGN).map(Number); } /** * Creates a string out of an array of eids with source and uid - * @param {Array} eids + * @param {Array.<{source: String, uids: Array.<{id: String, atype: Number, ext: Object}>}>} eids * @returns {String} */ function createUserIdString(eids) { - let str = [] + const str = []; for (let i = 0; i < eids.length; i++) { - str.push(eids[i].source + ':' + eids[i].uids[0].id) + str.push(eids[i].source + ':' + eids[i].uids[0].id); } - return str.join(',') + return str.join(','); +} + +/** + * Creates a string from an array of eids with ID provider and atype if atype exists + * @param {Array.<{source: String, uids: Array.<{id: String, atype: Number, ext: Object}>}>} eids + * @returns {String} idprovider:atype,idprovider2:atype2,... + */ +function createUserIdAtypesString(eids) { + const str = []; + for (let i = 0; i < eids.length; i++) { + if (eids[i].uids[0].atype) { + str.push(eids[i].source + ':' + eids[i].uids[0].atype); + } + } + return str.join(','); } /** @@ -276,18 +336,18 @@ function createUserIdString(eids) { * @returns {String} */ function createQueryString(obj) { - let str = [] - for (var p in obj) { + const str = []; + for (const p in obj) { if (obj.hasOwnProperty(p)) { - let val = obj[p] + const val = obj[p]; if (p !== 'schain' && p !== 'iab_content') { - str.push(encodeURIComponent(p) + '=' + encodeURIComponent(val)) + str.push(encodeURIComponent(p) + '=' + encodeURIComponent(val)); } else { - str.push(p + '=' + val) + str.push(p + '=' + val); } } } - return str.join('&') + return str.join('&'); } /** @@ -296,15 +356,15 @@ function createQueryString(obj) { * @returns {String} */ function createTargetingString(obj) { - let str = [] - for (var p in obj) { + const str = []; + for (const p in obj) { if (obj.hasOwnProperty(p)) { - let key = p - let val = obj[p] - str.push(key + '=' + val) + const key = p; + const val = obj[p]; + str.push(key + '=' + val); } } - return str.join('&') + return str.join('&'); } /** @@ -313,13 +373,13 @@ function createTargetingString(obj) { * @returns {String} */ function createSchainString(schain) { - const ver = schain.ver || '' - const complete = (schain.complete === 1 || schain.complete === 0) ? schain.complete : '' - const keys = ['asi', 'sid', 'hp', 'rid', 'name', 'domain', 'ext'] + const ver = schain.ver || ''; + const complete = (schain.complete === 1 || schain.complete === 0) ? schain.complete : ''; + const keys = ['asi', 'sid', 'hp', 'rid', 'name', 'domain', 'ext']; const nodesString = schain.nodes.reduce((acc, node) => { - return acc += `!${keys.map(key => node[key] ? encodeURIComponentWithBangIncluded(node[key]) : '').join(',')}` - }, '') - return `${ver},${complete}${nodesString}` + return acc += `!${keys.map(key => node[key] ? encodeURIComponentWithBangIncluded(node[key]) : '').join(',')}`; + }, ''); + return `${ver},${complete}${nodesString}`; } /** @@ -331,33 +391,44 @@ function createSchainString(schain) { */ function getContentObject(bid) { if (bid.params.iabContent && isPlainObject(bid.params.iabContent)) { - return bid.params.iabContent + return bid.params.iabContent; } - const globalContent = config.getConfig('ortb2.site') ? config.getConfig('ortb2.site.content') - : config.getConfig('ortb2.app.content') + const globalContent = deepAccess(bid, 'ortb2.site') ? deepAccess(bid, 'ortb2.site.content') + : deepAccess(bid, 'ortb2.app.content'); if (globalContent && isPlainObject(globalContent)) { - return globalContent + return globalContent; } - return undefined + return undefined; } /** - * Creates a string for iab_content object + * Creates a string for iab_content object by + * 1. flatten the iab content object + * 2. encoding the values + * 3. joining array of defined keys ('keyword', 'cat') into one value seperated with '|' + * 4. encoding the whole string * @param {Object} iabContent * @returns {String} */ function createIabContentString(iabContent) { - const arrKeys = ['keywords', 'cat'] - let str = [] - for (let key in iabContent) { - if (iabContent.hasOwnProperty(key)) { - const value = (arrKeys.indexOf(key) !== -1 && Array.isArray(iabContent[key])) - ? iabContent[key].map(node => encodeURIComponent(node)).join('|') : encodeURIComponent(iabContent[key]) - str.push(''.concat(key, ':', value)) + const arrKeys = ['keywords', 'cat']; + const str = []; + const transformObjToParam = (obj = {}, extraKey = '') => { + for (const key in obj) { + if ((arrKeys.indexOf(key) !== -1 && Array.isArray(obj[key]))) { + // Array of defined keyword which have to be joined into one value from "key: [value1, value2, value3]" to "key:value1|value2|value3" + str.push(''.concat(key, ':', obj[key].map(node => encodeURIComponent(node)).join('|'))); + } else if (typeof obj[key] !== 'object') { + str.push(''.concat(extraKey + key, ':', encodeURIComponent(obj[key]))); + } else { + // Object has to be further flattened + transformObjToParam(obj[key], ''.concat(extraKey, key, '.')); + } } - } - return encodeURIComponent(str.join(',')) + return str.join(','); + }; + return encodeURIComponent(transformObjToParam(iabContent)); } /** @@ -366,7 +437,7 @@ function createIabContentString(iabContent) { * @returns {String} */ function encodeURIComponentWithBangIncluded(str) { - return encodeURIComponent(str).replace(/!/g, '%21') + return encodeURIComponent(str).replace(/!/g, '%21'); } /** @@ -375,12 +446,94 @@ function encodeURIComponentWithBangIncluded(str) { */ function outstreamRender(bid) { bid.renderer.push(() => { - window.ma_width = bid.width - window.ma_height = bid.height - window.ma_vastUrl = bid.vastUrl - window.ma_container = bid.adUnitCode - window.document.dispatchEvent(new Event('ma-start-event')) + window.ma_width = bid.width; + window.ma_height = bid.height; + window.ma_vastUrl = bid.vastUrl; + window.ma_container = bid.adUnitCode; + window.document.dispatchEvent(new Event('ma-start-event')); }); } -registerBidder(spec) +/** + * Extract sizes for a given bid from either `mediaTypes` or `sizes` directly. + * + * @param {Object} bid + * @returns {string[]} + */ +function extractSizes(bid) { + const { mediaTypes } = bid; // see https://docs.prebid.org/dev-docs/adunit-reference.html#examples + const sizes = []; + + if (isPlainObject(mediaTypes)) { + const { [BANNER]: bannerType } = mediaTypes; + + // only applies for multi size Adslots -> BANNER + if (bannerType && isArray(bannerType.sizes)) { + if (isArray(bannerType.sizes[0])) { // multiple sizes given + sizes.push(bannerType.sizes); + } else { // just one size provided as array -> wrap to uniformly flatten later + sizes.push([bannerType.sizes]); + } + } + // The bid top level field `sizes` is deprecated and should not be used anymore. Keeping it for compatibility. + } else if (isArray(bid.sizes)) { + if (isArray(bid.sizes[0])) { + sizes.push(bid.sizes); + } else { + sizes.push([bid.sizes]); + } + } + + /** @type {Set} */ + const deduplicatedSizeStrings = new Set(sizes.flat().map(([width, height]) => width + DIMENSION_SIGN + height)); + + return Array.from(deduplicatedSizeStrings); +} + +/** + * Gets the floor price if the Price Floors Module is enabled for a given auction, + * which will add the getFloor() function to the bidRequest object. + * + * @param {Object} bid + * @param {string[]} sizes + * @returns The floor CPM in cents of a matched rule based on the rule selection process (mediaType, size and currency), + * using the getFloor() inputs. Multi sizes and unsupported media types will default to '*' + */ +function getBidFloor(bid, sizes) { + if (!isFn(bid.getFloor)) { + return undefined; + } + const mediaTypes = deepAccess(bid, 'mediaTypes'); + const mediaType = mediaTypes !== undefined ? Object.keys(mediaTypes)[0].toLowerCase() : undefined; + const floor = bid.getFloor({ + currency: CURRENCY_CODE, + mediaType: mediaType !== undefined && spec.supportedMediaTypes.includes(mediaType) ? mediaType : '*', + size: sizes.length !== 1 ? '*' : sizes[0].split(DIMENSION_SIGN), + }); + if (floor.currency === CURRENCY_CODE) { + return (floor.floor * 100).toFixed(0); + } + return undefined; +} + +/** + * Checks if an object has a property with a given name and the property value is not null or undefined. + * + * @param {Object} obj - The object to check. + * @param {string} propName - The name of the property to check. + * @returns {boolean} Returns true if the object has a property with the given name and the property value is not null or undefined, otherwise false. + */ +function hasValidProperty(obj, propName) { + return obj.hasOwnProperty(propName) && obj[propName] != null; +} + +/** + * Returns a filtering function for image assets based on type. + * @param {number} type - The desired asset type to filter for i.e. IMG_TYPE_ICON = 1, IMG_TYPE_MAIN = 3 + * @returns {function} - A filtering function that accepts an asset and checks if its img.type matches the desired type. + */ +function isImageAssetOfType(type) { + return asset => asset?.img?.type === type; +} + +registerBidder(spec); diff --git a/modules/yieldliftBidAdapter.js b/modules/yieldliftBidAdapter.js index 61b99d95605..d4cafd77c2d 100644 --- a/modules/yieldliftBidAdapter.js +++ b/modules/yieldliftBidAdapter.js @@ -1,10 +1,10 @@ -import { deepSetValue, logInfo, deepAccess } from '../src/utils.js'; +import {deepAccess, deepSetValue, logInfo} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; -const ENDPOINT_URL = 'https://x.yieldlift.com/auction'; +const ENDPOINT_URL = 'https://x.yieldlift.com/pbjs'; -const DEFAULT_BID_TTL = 30; +const DEFAULT_BID_TTL = 300; const DEFAULT_CURRENCY = 'USD'; const DEFAULT_NET_REVENUE = true; @@ -41,12 +41,12 @@ export const spec = { })); const openrtbRequest = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: impressions, site: { - domain: window.location.hostname, - page: window.location.href, - ref: bidderRequest.refererInfo ? bidderRequest.refererInfo.referer || null : null + domain: bidderRequest.refererInfo?.domain, + page: bidderRequest.refererInfo?.page, + ref: bidderRequest.refererInfo?.ref, }, ext: { exchange: { @@ -72,6 +72,12 @@ export const spec = { deepSetValue(openrtbRequest, 'regs.ext.us_privacy', bidderRequest.uspConsent); } + // EIDS + const eids = deepAccess(validBidRequests[0], 'userIdAsEids'); + if (Array.isArray(eids) && eids.length > 0) { + deepSetValue(openrtbRequest, 'user.ext.eids', eids); + } + const payloadString = JSON.stringify(openrtbRequest); return { method: 'POST', @@ -92,13 +98,11 @@ export const spec = { width: bid.w, height: bid.h, ad: bid.adm, - ttl: DEFAULT_BID_TTL, + ttl: typeof bid.exp === 'number' ? bid.exp : DEFAULT_BID_TTL, creativeId: bid.crid, netRevenue: DEFAULT_NET_REVENUE, currency: DEFAULT_CURRENCY, - meta: { - adomain: bid.adomain - } + meta: { advertiserDomains: bid && bid.advertiserDomains ? bid.advertiserDomains : [] } }) }) } else { diff --git a/modules/yieldloveBidAdapter.js b/modules/yieldloveBidAdapter.js new file mode 100644 index 00000000000..4568206b20a --- /dev/null +++ b/modules/yieldloveBidAdapter.js @@ -0,0 +1,149 @@ +import {registerBidder} from '../src/adapters/bidderFactory.js'; +import * as utils from '../src/utils.js'; +import {BANNER} from '../src/mediaTypes.js'; + +const ENDPOINT_URL = 'https://s2s.yieldlove-ad-serving.net/openrtb2/auction'; + +const DEFAULT_BID_TTL = 300; /* 5 minutes */ +const DEFAULT_CURRENCY = 'EUR'; + +const participatedBidders = [] + +export const spec = { + gvlid: 251, + code: 'yieldlove', + aliases: [], + supportedMediaTypes: [BANNER], + + isBidRequestValid: function (bid) { + return !!(bid.params.pid && bid.params.rid) + }, + + buildRequests: function (validBidRequests, bidderRequest) { + const anyValidBidRequest = validBidRequests[0] + + const impressions = validBidRequests.map(bidRequest => { + return { + ext: { + prebid: { + storedrequest: { + id: bidRequest.params.pid?.toString() + } + } + }, + banner: { + format: bidRequest.sizes.map(sizeArr => ({ + w: sizeArr[0], + h: sizeArr[1], + })) + }, + secure: 1, + id: bidRequest.bidId + } + }) + + const s2sRequest = { + device: { + ua: window.navigator.userAgent, + w: window.innerWidth, + h: window.innerHeight, + }, + site: { + ver: '1.9.0', + publisher: { + id: anyValidBidRequest.params.rid + }, + page: window.location.href, + domain: anyValidBidRequest.params.rid + }, + ext: { + prebid: { + targeting: {}, + cache: { + bids: {} + }, + storedrequest: { + id: anyValidBidRequest.params.rid + }, + } + }, + user: { + ext: { + consent: bidderRequest.gdprConsent?.consentString + }, + }, + id: utils.generateUUID(), + imp: impressions, + regs: { + ext: { + gdpr: 1 + } + } + } + + return { + method: 'POST', + url: ENDPOINT_URL, + data: s2sRequest, + options: { + contentType: 'text/plain', + withCredentials: true + }, + }; + }, + + interpretResponse: function (serverResponse) { + const bidResponses = [] + const seatBids = serverResponse.body?.seatbid || [] + seatBids.reduce((bids, cur) => { + if (cur.bid && cur.bid.length > 0) bids = bids.concat(cur.bid) + return bids + }, []).forEach(bid => { + bidResponses.push({ + requestId: bid.impid, + cpm: bid.price, + width: bid.w, + height: bid.h, + ad: bid.adm, + ttl: DEFAULT_BID_TTL, + creativeId: bid.crid, + netRevenue: true, + currency: DEFAULT_CURRENCY + }) + }) + + const bidders = serverResponse.body?.ext.responsetimemillis || {} + Object.keys(bidders).forEach(bidder => { + if (!participatedBidders.includes(bidder)) participatedBidders.push(bidder) + }) + + if (bidResponses.length === 0) { + utils.logInfo('interpretResponse :: no bid'); + } + + return bidResponses; + }, + + getUserSyncs: function (syncOptions, serverResponses, gdprConsent, uspConsent) { + const syncs = [] + + let gdprParams = '' + gdprParams = `gdpr=${Number(gdprConsent?.gdprApplies)}&` + gdprParams += `gdpr_consent=${gdprConsent?.consentString || ''}` + + let bidderParams = '' + if (participatedBidders.length > 0) { + bidderParams = `bidders=${participatedBidders.join(',')}` + } + + syncs.push({ + type: 'iframe', + url: `https://cdn-a.yieldlove.com/load-cookie.html?endpoint=yieldlove&max_sync_count=100&${gdprParams}&${bidderParams}` + }) + + return syncs + }, + +}; + +registerBidder(spec); diff --git a/modules/yieldloveBidAdapter.md b/modules/yieldloveBidAdapter.md new file mode 100644 index 00000000000..8fd71b55f88 --- /dev/null +++ b/modules/yieldloveBidAdapter.md @@ -0,0 +1,38 @@ +# Overview + +``` +Module Name: Yieldlove Bid Adapter +Module Type: Bidder Adapter +Maintainer: adapter@yieldlove.com +``` + + +# Description + +Connects to **[Yieldlove](https://www.yieldlove.com/)**s S2S platform for bids. + +```js +const adUnits = [ + { + code: 'test-div', + mediaTypes: { banner: { sizes: [[300, 250]] }}, + bids: [ + { + bidder: 'yieldlove', + params: { + pid: 34437, + rid: 'website.com' + } + } + ] + } +] +``` + + +# Bid Parameters + +| Name | Scope | Description | Example | Type | +|---------------|--------------|---------------------------------------------------------|----------------------------|--------------| +| rid | **required** | Publisher ID on the Yieldlove platform | `website.com` | String | +| pid | **required** | Placement ID on the Yieldlove platform | `34437` | Number | diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index bc29f4822c8..d2e97f5178e 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -17,14 +17,17 @@ import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {Renderer} from '../src/Renderer.js'; import {find, includes} from '../src/polyfill.js'; -import {createEidsArray} from './userId/eids.js'; const BIDDER_CODE = 'yieldmo'; +const GVLID = 173; const CURRENCY = 'USD'; const TIME_TO_LIVE = 300; const NET_REVENUE = true; -const BANNER_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; -const VIDEO_SERVER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo'; +const PB_COOKIE_ASSIST_SYNC_ENDPOINT = `https://ads.yieldmo.com/pbcas`; +const BANNER_PATH = '/exchange/prebid'; +const VIDEO_PATH = '/exchange/prebidvideo'; +const STAGE_DOMAIN = 'https://ads-stg.yieldmo.com'; +const PROD_DOMAIN = 'https://ads.yieldmo.com'; const OUTSTREAM_VIDEO_PLAYER_URL = 'https://prebid-outstream.yieldmo.com/bundle.js'; const OPENRTB_VIDEO_BIDPARAMS = ['mimes', 'startdelay', 'placement', 'startdelay', 'skipafter', 'protocols', 'api', 'playbackmethod', 'maxduration', 'minduration', 'pos', 'skip', 'skippable']; @@ -39,7 +42,7 @@ const BANNER_REQUEST_PROPERTIES_TO_REDUCE = ['description', 'title', 'pr', 'page export const spec = { code: BIDDER_CODE, supportedMediaTypes: [BANNER, VIDEO], - + gvlid: GVLID, /** * Determines whether or not the given bid request is valid. * @param {object} bid, bid to validate @@ -58,22 +61,29 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: function (bidRequests, bidderRequest) { + const stage = isStage(bidderRequest); + const bannerUrl = getAdserverUrl(BANNER_PATH, stage); + const videoUrl = getAdserverUrl(VIDEO_PATH, stage); const bannerBidRequests = bidRequests.filter(request => hasBannerMediaType(request)); const videoBidRequests = bidRequests.filter(request => hasVideoMediaType(request)); let serverRequests = []; const eids = getEids(bidRequests[0]) || []; + if (bannerBidRequests.length > 0) { let serverRequest = { pbav: '$prebid.version$', p: [], - page_url: bidderRequest.refererInfo.referer, + // TODO: is 'page' the right value here? + page_url: bidderRequest.refererInfo.page, bust: new Date().getTime().toString(), dnt: getDNT(), description: getPageDescription(), userConsent: JSON.stringify({ // case of undefined, stringify will remove param gdprApplies: deepAccess(bidderRequest, 'gdprConsent.gdprApplies') || '', - cmp: deepAccess(bidderRequest, 'gdprConsent.consentString') || '' + cmp: deepAccess(bidderRequest, 'gdprConsent.consentString') || '', + gpp: deepAccess(bidderRequest, 'gppConsent.gppString') || '', + gpp_sid: deepAccess(bidderRequest, 'gppConsent.applicableSections') || [] }), us_privacy: deepAccess(bidderRequest, 'uspConsent') || '' }; @@ -120,8 +130,8 @@ export const spec = { serverRequest.eids = JSON.stringify(eids); }; // check if url exceeded max length - const url = `${BANNER_SERVER_ENDPOINT}?${parseQueryStringParameters(serverRequest)}`; - let extraCharacters = url.length - MAX_BANNER_REQUEST_URL_LENGTH; + const fullUrl = `${bannerUrl}?${parseQueryStringParameters(serverRequest)}`; + let extraCharacters = fullUrl.length - MAX_BANNER_REQUEST_URL_LENGTH; if (extraCharacters > 0) { for (let i = 0; i < BANNER_REQUEST_PROPERTIES_TO_REDUCE.length; i++) { extraCharacters = shortcutProperty(extraCharacters, serverRequest, BANNER_REQUEST_PROPERTIES_TO_REDUCE[i]); @@ -134,7 +144,7 @@ export const spec = { serverRequests.push({ method: 'GET', - url: BANNER_SERVER_ENDPOINT, + url: bannerUrl, data: serverRequest }); } @@ -146,7 +156,7 @@ export const spec = { }; serverRequests.push({ method: 'POST', - url: VIDEO_SERVER_ENDPOINT, + url: videoUrl, data: serverRequest }); } @@ -176,8 +186,25 @@ export const spec = { return bids; }, - getUserSyncs: function () { - return []; + getUserSyncs: function(syncOptions, serverResponses, gdprConsent = {}, uspConsent = '') { + const syncs = []; + const gdprFlag = `&gdpr=${gdprConsent.gdprApplies ? 1 : 0}`; + const gdprString = `&gdpr_consent=${encodeURIComponent((gdprConsent.consentString || ''))}`; + const usPrivacy = `us_privacy=${encodeURIComponent(uspConsent)}`; + const pbCookieAssistSyncUrl = `${PB_COOKIE_ASSIST_SYNC_ENDPOINT}?${usPrivacy}${gdprFlag}${gdprString}`; + + if (syncOptions.iframeEnabled) { + syncs.push({ + type: 'iframe', + url: pbCookieAssistSyncUrl + '&type=iframe' + }); + } else if (syncOptions.pixelEnabled) { + syncs.push({ + type: 'image', + url: pbCookieAssistSyncUrl + '&type=image' + }); + } + return syncs; } }; registerBidder(spec); @@ -223,6 +250,17 @@ function addPlacement(request) { if (gpid) { placementInfo.gpid = gpid; } + + // get the transaction id for the banner bid. + const transactionId = deepAccess(request, 'ortb2Imp.ext.tid'); + + if (transactionId) { + placementInfo.tid = transactionId; + } + if (request.auctionId) { + // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 + placementInfo.auctionId = request.auctionId; + } return JSON.stringify(placementInfo); } @@ -347,12 +385,13 @@ function openRtbRequest(bidRequests, bidderRequest) { const schain = bidRequests[0].schain; let openRtbRequest = { id: bidRequests[0].bidderRequestId, + tmax: bidderRequest.timeout || 400, at: 1, imp: bidRequests.map(bidRequest => openRtbImpression(bidRequest)), site: openRtbSite(bidRequests[0], bidderRequest), - device: openRtbDevice(bidRequests[0]), + device: deepAccess(bidderRequest, 'ortb2.device'), badv: bidRequests[0].params.badv || [], - bcat: bidRequests[0].params.bcat || [], + bcat: deepAccess(bidderRequest, 'bcat') || bidRequests[0].params.bcat || [], ext: { prebid: '$prebid.version$', }, @@ -363,6 +402,9 @@ function openRtbRequest(bidRequests, bidderRequest) { openRtbRequest.schain = schain; } + if (bidRequests[0].auctionId) { + openRtbRequest.auctionId = bidRequests[0].auctionId; + } populateOpenRtbGdpr(openRtbRequest, bidderRequest); return openRtbRequest; @@ -380,7 +422,8 @@ function openRtbImpression(bidRequest) { tagid: bidRequest.adUnitCode, bidfloor: getBidFloor(bidRequest, VIDEO), ext: { - placement_id: bidRequest.params.placementId + placement_id: bidRequest.params.placementId, + tid: deepAccess(bidRequest, 'ortb2Imp.ext.tid') }, video: { w: size[0], @@ -389,12 +432,12 @@ function openRtbImpression(bidRequest) { } }; - const mediaTypesParams = deepAccess(bidRequest, 'mediaTypes.video'); + const mediaTypesParams = deepAccess(bidRequest, 'mediaTypes.video', {}); Object.keys(mediaTypesParams) .filter(param => includes(OPENRTB_VIDEO_BIDPARAMS, param)) .forEach(param => imp.video[param] = mediaTypesParams[param]); - const videoParams = deepAccess(bidRequest, 'params.video'); + const videoParams = deepAccess(bidRequest, 'params.video', {}); Object.keys(videoParams) .filter(param => includes(OPENRTB_VIDEO_BIDPARAMS, param)) .forEach(param => imp.video[param] = videoParams[param]); @@ -445,13 +488,13 @@ function extractPlayerSize(bidRequest) { function openRtbSite(bidRequest, bidderRequest) { let result = {}; - const loc = parseUrl(deepAccess(bidderRequest, 'refererInfo.referer')); + const loc = parseUrl(deepAccess(bidderRequest, 'refererInfo.page')); if (!isEmpty(loc)) { result.page = `${loc.protocol}://${loc.hostname}${loc.pathname}`; } - if (self === top && document.referrer) { - result.ref = document.referrer; + if (bidderRequest.refererInfo?.ref) { + result.ref = bidderRequest.refererInfo.ref; } const keywords = document.getElementsByTagName('meta')['keywords']; @@ -468,17 +511,6 @@ function openRtbSite(bidRequest, bidderRequest) { return result; } -/** - * @return Object OpenRTB's 'device' object - */ -function openRtbDevice(bidRequest) { - const deviceObj = { - ua: navigator.userAgent, - language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), - }; - return deviceObj; -} - /** * Updates openRtbRequest with GDPR info from bidderRequest, if present. * @param {Object} openRtbRequest OpenRTB's request to update. @@ -486,12 +518,19 @@ function openRtbDevice(bidRequest) { */ function populateOpenRtbGdpr(openRtbRequest, bidderRequest) { const gdpr = bidderRequest.gdprConsent; - if (gdpr && 'gdprApplies' in gdpr) { - deepSetValue(openRtbRequest, 'regs.ext.gdpr', gdpr.gdprApplies ? 1 : 0); - deepSetValue(openRtbRequest, 'user.ext.consent', gdpr.consentString); + const gpp = deepAccess(bidderRequest, 'gppConsent.gppString'); + const gppsid = deepAccess(bidderRequest, 'gppConsent.applicableSections'); + if (gpp) { + deepSetValue(openRtbRequest, 'regs.ext.gpp', gpp); + } else { + deepSetValue(openRtbRequest, 'regs.ext.gdpr', gdpr && gdpr.gdprApplies ? 1 : 0); + deepSetValue(openRtbRequest, 'user.ext.consent', gdpr && gdpr.consentString ? gdpr.consentString : ''); + } + if (gppsid && gppsid.length > 0) { + deepSetValue(openRtbRequest, 'regs.ext.gpp_sid', gppsid); } const uspConsent = deepAccess(bidderRequest, 'uspConsent'); - if (uspConsent) { + if (!gpp && uspConsent) { deepSetValue(openRtbRequest, 'regs.ext.us_privacy', uspConsent); } } @@ -512,13 +551,13 @@ function validateVideoParams(bid) { error += ' when ' + conditionStr; } throw new Error(error); - } + }; const paramInvalid = (paramStr, value, expectedStr) => { expectedStr = expectedStr ? ', expected: ' + expectedStr : ''; value = JSON.stringify(value); throw new Error(`"${paramStr}"=${value} is invalid${expectedStr}`); - } + }; const isDefined = val => typeof val !== 'undefined'; const validate = (fieldPath, validateCb, errorCb, errorCbParam) => { @@ -544,7 +583,7 @@ function validateVideoParams(bid) { } return value; } - } + }; try { validate('video.context', val => !isEmpty(val), paramRequired); @@ -568,8 +607,14 @@ function validateVideoParams(bid) { } validate('video.protocols', val => isDefined(val), paramRequired); - validate('video.protocols', val => isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)), - paramInvalid, 'array of numbers, ex: [2,3]'); + validate( + 'video.protocols', + (val) => + isArrayOfNums(val) && + val.every((v) => v >= 1 && v <= 12 && v != 9 && v != 10), // 9 and 10 are for DAST which are not supported. + paramInvalid, + 'array of numbers between 1 and 12 except for 9 or 10 , ex: [2,3, 7, 11]' + ); validate('video.api', val => isDefined(val), paramRequired); validate('video.api', val => isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)), @@ -623,8 +668,8 @@ function shortcutProperty(extraCharacters, target, propertyName) { * @return array of eids objects */ function getEids(bidRequest) { - if (deepAccess(bidRequest, 'userId')) { - return createEidsArray(bidRequest.userId) || []; + if (deepAccess(bidRequest, 'userIdAsEids')) { + return bidRequest.userIdAsEids || []; } }; @@ -642,3 +687,12 @@ function canAccessTopWindow() { return false; } } + +function isStage(bidderRequest) { + return !!bidderRequest.refererInfo?.referer?.includes('pb_force_a'); +} + +function getAdserverUrl(path, stage) { + const domain = stage ? STAGE_DOMAIN : PROD_DOMAIN; + return `${domain}${path}`; +} diff --git a/modules/yieldnexusBidAdapter.md b/modules/yieldnexusBidAdapter.md deleted file mode 100644 index 675e8948a3e..00000000000 --- a/modules/yieldnexusBidAdapter.md +++ /dev/null @@ -1,53 +0,0 @@ -# Overview - -``` -Module Name: YieldNexus Bid Adapter -Module Type: Bidder Adapter -Maintainer: rtbops@yieldnexus.com -``` - -# Description - -Adds support to query the YieldNexus platform for bids. The YieldNexus platform supports banners & video. - -Only one parameter is required: `spid`, which provides your YieldNexus account number. - -# Test Parameters -``` -var adUnits = [ - // Banner: - { - code: 'banner-ad-unit', - sizes: [[300, 250]], - bids: [{ - bidder: 'yieldnexus', - params: { - spid: '1253', // your supply ID in your YieldNexus dashboard - bidfloor: 0.03, // an optional custom bid floor - adpos: 1, // ad position on the page (optional) - instl: 0 // interstitial placement? (0 or 1, optional) - } - }] - }, - // Outstream video: - { - code: 'video-ad-unit', - sizes: [[640, 480]], - mediaTypes: { - video: { - context: 'outstream', - playerSize: [640, 480] - } - }, - bids: [ { - bidder: 'yieldnexus', - params: { - spid: '1254', // your supply ID in your YieldNexus dashboard - bidfloor: 0.03, // an optional custom bid floor - adpos: 1, // ad position on the page (optional) - instl: 0 // interstitial placement? (0 or 1, optional) - } - }] - } -]; -``` diff --git a/modules/yieldoneAnalyticsAdapter.js b/modules/yieldoneAnalyticsAdapter.js index cb13503365e..0663ecb3f76 100644 --- a/modules/yieldoneAnalyticsAdapter.js +++ b/modules/yieldoneAnalyticsAdapter.js @@ -1,6 +1,6 @@ import { isArray, deepClone } from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import CONSTANTS from '../src/constants.json'; import adapterManager from '../src/adapterManager.js'; import { targeting } from '../src/targeting.js'; @@ -99,7 +99,8 @@ const yieldoneAnalytics = Object.assign(adapter({analyticsType}), { if (currentAuctionId) { const eventsStorage = yieldoneAnalytics.eventsStorage; if (!eventsStorage[currentAuctionId]) eventsStorage[currentAuctionId] = {events: []}; - const referrer = args.refererInfo && args.refererInfo.referer; + // TODO: is 'page' the right value here? + const referrer = args.refererInfo && args.refererInfo.page; if (referrer && referrers[currentAuctionId] !== referrer) { referrers[currentAuctionId] = referrer; } diff --git a/modules/yieldoneBidAdapter.js b/modules/yieldoneBidAdapter.js index 334de9eb3fa..8ad7e69aa6e 100644 --- a/modules/yieldoneBidAdapter.js +++ b/modules/yieldoneBidAdapter.js @@ -1,8 +1,18 @@ import {deepAccess, isEmpty, isStr, logWarn, parseSizesInput} from '../src/utils.js'; -import {config} from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; -import { Renderer } from '../src/Renderer.js'; -import { BANNER, VIDEO } from '../src/mediaTypes.js'; +import {Renderer} from '../src/Renderer.js'; +import {BANNER, VIDEO} from '../src/mediaTypes.js'; + +/** + * @typedef {import('../src/adapters/bidderFactory').Bid} Bid + * @typedef {import('../src/adapters/bidderFactory').BidRequest} BidRequest + * @typedef {import('../src/adapters/bidderFactory').BidderSpec} BidderSpec + * @typedef {import('../src/adapters/bidderFactory').ServerRequest} ServerRequest + * @typedef {import('../src/adapters/bidderFactory').ServerResponse} ServerResponse + * @typedef {import('../src/adapters/bidderFactory').SyncOptions} SyncOptions + * @typedef {import('../src/adapters/bidderFactory').UserSync} UserSync + * @typedef {import('../src/auction').BidderRequest} BidderRequest + */ const BIDDER_CODE = 'yieldone'; const ENDPOINT_URL = 'https://y.one.impact-ad.jp/h_bid'; @@ -13,23 +23,38 @@ const VIEWABLE_PERCENTAGE_URL = 'https://img.ak.impact-ad.jp/ic/pone/ivt/firstvi const DEFAULT_VIDEO_SIZE = {w: 640, h: 360}; +/** @type BidderSpec */ export const spec = { code: BIDDER_CODE, aliases: ['y1'], supportedMediaTypes: [BANNER, VIDEO], + /** + * Determines whether or not the given bid request is valid. + * @param {BidRequest} bid The bid params to validate. + * @returns {boolean} True if this is a valid bid, and false otherwise. + */ isBidRequestValid: function(bid) { return !!(bid.params.placementId); }, + /** + * Make a server request from the list of BidRequests. + * @param {Bid[]} validBidRequests - An array of bids. + * @param {BidderRequest} bidderRequest - bidder request object. + * @returns {ServerRequest|ServerRequest[]} ServerRequest Info describing the request to the server. + */ buildRequests: function(validBidRequests, bidderRequest) { return validBidRequests.map(bidRequest => { const params = bidRequest.params; const placementId = params.placementId; const cb = Math.floor(Math.random() * 99999999999); - const referrer = bidderRequest.refererInfo.referer; + // TODO: is 'page' the right value here? + const referrer = bidderRequest.refererInfo.page; const bidId = bidRequest.bidId; - const transactionId = bidRequest.transactionId; + const transactionId = bidRequest.ortb2Imp?.ext?.tid; const unitCode = bidRequest.adUnitCode; - const timeout = config.getConfig('bidderTimeout'); + const timeout = bidderRequest.timeout; + const language = window.navigator.language; + const screenSize = window.screen.width + 'x' + window.screen.height; const payload = { v: 'hb1', p: placementId, @@ -39,7 +64,9 @@ export const spec = { tid: transactionId, uc: unitCode, tmax: timeout, - t: 'i' + t: 'i', + language: language, + screen_size: screenSize }; const mediaType = getMediaType(bidRequest); @@ -68,13 +95,35 @@ export const spec = { payload.imuid = imuid; } + // DACID + const fuuid = deepAccess(bidRequest, 'userId.dacId.fuuid'); + const dacid = deepAccess(bidRequest, 'userId.dacId.id'); + if (isStr(fuuid) && !isEmpty(fuuid)) { + payload.fuuid = fuuid; + } + if (isStr(dacid) && !isEmpty(dacid)) { + payload.dac_id = dacid; + } + + // ID5 + const id5id = deepAccess(bidRequest, 'userId.id5id.uid'); + if (isStr(id5id) && !isEmpty(id5id)) { + payload.id5Id = id5id; + } + return { method: 'GET', url: ENDPOINT_URL, data: payload, - } + }; }); }, + /** + * Unpack the response from the server into a list of bids. + * @param {ServerResponse} serverResponse - A successful response from the server. + * @param {BidRequest} bidRequests + * @returns {Bid[]} - An array of bids which were nested inside the server. + */ interpretResponse: function(serverResponse, bidRequest) { const bidResponses = []; const response = serverResponse.body; @@ -97,7 +146,7 @@ export const spec = { dealId: dealId, currency: currency, netRevenue: netRevenue, - ttl: config.getConfig('_bidderTimeout'), + ttl: 60, referrer: referrer, meta: { advertiserDomains: response.adomain ? response.adomain : [] @@ -167,6 +216,11 @@ export const spec = { } return bidResponses; }, + /** + * Register the user sync pixels which should be dropped after the auction. + * @param {SyncOptions} syncOptions Which user syncs are allowed? + * @returns {UserSync[]} The user syncs which should be dropped. + */ getUserSyncs: function(syncOptions) { if (syncOptions.iframeEnabled) { return [{ @@ -181,7 +235,7 @@ export const spec = { * NOTE: server side does not yet support multiple formats. * @param {Object} bidRequest - * @param {boolean} [enabledOldFormat = true] - default: `true`. - * @return {string|null} - `"banner"` or `"video"` or `null`. + * @returns {string|null} - `"banner"` or `"video"` or `null`. */ function getMediaType(bidRequest, enabledOldFormat = true) { let hasBannerType = Boolean(deepAccess(bidRequest, 'mediaTypes.banner')); @@ -194,7 +248,7 @@ function getMediaType(bidRequest, enabledOldFormat = true) { } if (hasBannerType && hasVideoType) { - const playerParams = deepAccess(bidRequest, 'params.playerParams') + const playerParams = deepAccess(bidRequest, 'params.playerParams'); if (playerParams) { return VIDEO; } else { @@ -218,7 +272,7 @@ function getMediaType(bidRequest, enabledOldFormat = true) { * @param {Object} bidRequest.banner - * @param {Array} bidRequest.banner.sizes - * @param {boolean} [enabledOldFormat = true] - default: `true`. - * @return {string} - strings like `"300x250"` or `"300x250,728x90"`. + * @returns {string} - strings like `"300x250"` or `"300x250,728x90"`. */ function getBannerSizes(bidRequest, enabledOldFormat = true) { let sizes = deepAccess(bidRequest, 'mediaTypes.banner.sizes'); @@ -233,10 +287,10 @@ function getBannerSizes(bidRequest, enabledOldFormat = true) { /** * @param {Object} bidRequest - * @param {boolean} [enabledOldFormat = true] - default: `true`. - * @param {boolean} [enabledFlux = true] - default: `true`. - * @return {{w: number, h: number}} - + * @param {boolean} [enabled1x1 = true] - default: `true`. + * @returns {{w: number, h: number}} - */ -function getVideoSize(bidRequest, enabledOldFormat = true, enabledFlux = true) { +function getVideoSize(bidRequest, enabledOldFormat = true, enabled1x1 = true) { /** * @param {Array | Array>} sizes - * @return {{w: number, h: number} | null} - @@ -266,10 +320,10 @@ function getVideoSize(bidRequest, enabledOldFormat = true, enabledFlux = true) { playerSize = playerSize || _getPlayerSize(bidRequest.sizes); } - if (enabledFlux) { - // NOTE: `video.playerSize` in Flux is always [1,1]. + if (enabled1x1) { + // NOTE: `video.playerSize` in 1x1 is always [1,1]. if (playerSize && (playerSize.w === 1 && playerSize.h === 1)) { - // NOTE: `params.playerSize` is a specific object to support `FLUX`. + // NOTE: `params.playerSize` is a specific object to support `1x1`. playerSize = _getPlayerSize(deepAccess(bidRequest, 'params.playerSize')); } } @@ -277,6 +331,11 @@ function getVideoSize(bidRequest, enabledOldFormat = true, enabledFlux = true) { return playerSize || DEFAULT_VIDEO_SIZE; } +/** + * Create render for outstream video. + * @param {Object} serverResponse.body - + * @returns {Renderer} - Prebid Renderer object + */ function newRenderer(response) { const renderer = Renderer.install({ id: response.uid, @@ -293,12 +352,21 @@ function newRenderer(response) { return renderer; } +/** + * Handles an outstream response after the library is loaded + * @param {Object} bid + */ function outstreamRender(bid) { bid.renderer.push(() => { window.DACIVTPREBID.renderPrebid(bid); }); } +/** + * Create render for cmer outstream video. + * @param {Object} serverResponse.body - + * @returns {Renderer} - Prebid Renderer object + */ function newCmerRenderer(response) { const renderer = Renderer.install({ id: response.uid, @@ -315,6 +383,10 @@ function newCmerRenderer(response) { return renderer; } +/** + * Handles an outstream response after the library is loaded + * @param {Object} bid + */ function cmerRender(bid) { bid.renderer.push(() => { window.CMERYONEPREBID.renderPrebid(bid); diff --git a/modules/yieldoneBidAdapter.md b/modules/yieldoneBidAdapter.md index 1414d4e464f..d1306a08202 100644 --- a/modules/yieldoneBidAdapter.md +++ b/modules/yieldoneBidAdapter.md @@ -13,8 +13,7 @@ Connect to YIELDONE for bids. THE YIELDONE adapter requires setup and approval from the YIELDONE team. Please reach out to your account team or y1s@platform-one.co.jp for more information. -Note: THE YIELDONE adapter do not support "multi-format" scenario... if both -banner and video are specified as mediatypes, YIELDONE will treat it as a video unit. +YIELDONE adapter supports Banner, Video and Multi-Format(video, banner) currently. # Test Parameters ```javascript @@ -24,13 +23,16 @@ var adUnits = [ code: 'banner-div', mediaTypes: { banner: { - sizes: [[300, 250], [336, 280]] + sizes: [ + [300, 250], + [336, 280] + ] } }, bids: [{ bidder: 'yieldone', params: { - placementId: '36891' + placementId: '36891' // required } }] }, @@ -44,11 +46,109 @@ var adUnits = [ }, }, bids: [{ - bidder: 'yieldone', - params: { - placementId: '41993' - } - }] + bidder: "yieldone", + params: { + placementId: "36892", // required + playerParams: { // optional + wrapperWidth: "320px", // optional + wrapperHeight: "180px" // optional + }, + } + }] + }, + // Video adUnit(mediaTypes.video.playerSize: [1,1]) + { + code: 'video-1x1-div', + mediaTypes: { + video: { + playerSize: [[1, 1]], + context: 'outstream' + }, + }, + bids: [{ + bidder: 'yieldone', + params: { + placementId: "36892", // required + playerSize: [640, 360], // required + playerParams: { // optional + wrapperWidth: "320px", // optional + wrapperHeight: "180px" // optional + }, + } + }] + }, + // Multi-Format adUnit + { + code: "multi-format-div", + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [1, 1] + ] + }, + video: { + playerSize: [640, 360], + context: "outstream" + } + }, + bids: [{ + // * "video" bid object should be placed before "banner" bid object. + // This bid will request a "video" media type ad. + bidder: "yieldone", + params: { + placementId: "36892", // required + playerParams: { // required + wrapperWidth: "320px", // optional + wrapperHeight: "180px" // optional + }, + } + }, + { + // This bid will request a "banner" media type ad. + bidder: "yieldone", + params: { + placementId: "36891" // required + } + } + ] + }, + // Multi-Format adUnit(mediaTypes.video.playerSize: [1,1]) + { + code: "multi-format-1x1-div", + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [1, 1] + ] + }, + video: { + playerSize: [1, 1], + context: "outstream" + } + }, + bids: [{ + // * "video" bid object should be placed before "banner" bid object. + // This bid will request a "video" media type ad. + bidder: "yieldone", + params: { + placementId: "36892", // required + playerSize: [640, 360], // required + playerParams: { // required + wrapperWidth: "320px", // optional + wrapperHeight: "180px" // optional + }, + } + }, + { + // This bid will request a "banner" media type ad. + bidder: "yieldone", + params: { + placementId: "36891" // required + } + } + ] } ``` diff --git a/modules/yuktamediaAnalyticsAdapter.js b/modules/yuktamediaAnalyticsAdapter.js index 6872820dd48..820e6365a9f 100644 --- a/modules/yuktamediaAnalyticsAdapter.js +++ b/modules/yuktamediaAnalyticsAdapter.js @@ -1,13 +1,16 @@ import {buildUrl, generateUUID, getWindowLocation, logError, logInfo, parseSizesInput, parseUrl} from '../src/utils.js'; import {ajax} from '../src/ajax.js'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; import {getStorageManager} from '../src/storageManager.js'; import {getRefererInfo} from '../src/refererDetection.js'; import {includes as strIncludes} from '../src/polyfill.js'; +import {getGlobal} from '../src/prebidGlobal.js'; +import {MODULE_TYPE_ANALYTICS} from '../src/activities/modules.js'; -const storage = getStorageManager(); +const MODULE_CODE = 'yuktamedia'; +const storage = getStorageManager({moduleType: MODULE_TYPE_ANALYTICS, moduleName: MODULE_CODE}); const yuktamediaAnalyticsVersion = 'v3.1.0'; let initOptions; @@ -18,7 +21,8 @@ const events = { const localStoragePrefix = 'yuktamediaAnalytics_'; const utmTags = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content']; const location = getWindowLocation(); -const referer = getRefererInfo().referer; +// TODO: is 'page' the right value here? +const referer = getRefererInfo().page; const _pageInfo = { userAgent: window.navigator.userAgent, timezoneOffset: new Date().getTimezoneOffset(), @@ -33,7 +37,7 @@ const _pageInfo = { referer: referer, refererDomain: parseUrl(referer).host, yuktamediaAnalyticsVersion: yuktamediaAnalyticsVersion, - prebidVersion: $$PREBID_GLOBAL$$.version + prebidVersion: getGlobal().version }; function getParameterByName(param) { @@ -259,7 +263,7 @@ yuktamediaAnalyticsAdapter.enableAnalytics = function (config) { adapterManager.registerAnalyticsAdapter({ adapter: yuktamediaAnalyticsAdapter, - code: 'yuktamedia' + code: MODULE_CODE, }); export default yuktamediaAnalyticsAdapter; diff --git a/modules/zedoBidAdapter.md b/modules/zedoBidAdapter.md deleted file mode 100644 index 2f31e8aed9b..00000000000 --- a/modules/zedoBidAdapter.md +++ /dev/null @@ -1,65 +0,0 @@ -# Overview - -Module Name: ZEDO Bidder Adapter -Module Type: Bidder Adapter -Maintainer: prebidsupport@zedo.com - -# Description - -Module that connects to ZEDO's demand sources. - -ZEDO supports both display and video. -For video integration, ZEDO returns content as vastXML and requires the publisher to define the cache url in config passed to Prebid for it to be valid in the auction - -ZEDO has its own renderer and will render the video unit if not defined in the config. - - -# Test Parameters -# display -``` - - var adUnits = [{ - code: 'div-gpt-ad-1460505748561-0', - mediaTypes: { - banner: { - sizes: [[300, 250], [300,600]], - } - }, - // Replace this object to test a new Adapter! - bids: [{ - bidder: 'zedo', - params: { - channelCode: 2264004735, //REQUIRED - dimId:9 //REQUIRED - } - }] - - }]; -``` -# video -``` - - var adUnit1 = [ - { - code: 'videoAdUnit', - mediaTypes: - { - video: - { - context: 'outstream', - playerSize: [640, 480] - } - }, - bids: [ - { - bidder: 'zedo', - params: - { - channelCode: 2264004735, // required - dimId: 85, // required - pubId: 1 // optional - } - } - ] - }]; -``` \ No newline at end of file diff --git a/modules/zeotapIdPlusIdSystem.js b/modules/zeotapIdPlusIdSystem.js index 3437928df4b..ab7bf7c237b 100644 --- a/modules/zeotapIdPlusIdSystem.js +++ b/modules/zeotapIdPlusIdSystem.js @@ -6,7 +6,8 @@ */ import { isStr, isPlainObject } from '../src/utils.js'; import {submodule} from '../src/hook.js'; -import { getStorageManager } from '../src/storageManager.js'; +import {getStorageManager} from '../src/storageManager.js'; +import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const ZEOTAP_COOKIE_NAME = 'IDP'; const ZEOTAP_VENDOR_ID = 301; @@ -21,7 +22,7 @@ function readFromLocalStorage() { } export function getStorage() { - return getStorageManager({gvlid: ZEOTAP_VENDOR_ID, moduleName: ZEOTAP_MODULE_NAME}); + return getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: ZEOTAP_MODULE_NAME}); } export const storage = getStorage(); @@ -59,6 +60,12 @@ export const zeotapIdPlusSubmodule = { getId() { const id = readCookie() || readFromLocalStorage(); return id ? { id } : undefined; + }, + eids: { + 'IDP': { + source: 'zeotap.com', + atype: 1 + }, } }; submodule('userId', zeotapIdPlusSubmodule); diff --git a/modules/zetaBidAdapter.js b/modules/zetaBidAdapter.js index 27650888677..527030efc9a 100644 --- a/modules/zetaBidAdapter.js +++ b/modules/zetaBidAdapter.js @@ -1,6 +1,7 @@ -import { logWarn } from '../src/utils.js'; -import { registerBidder } from '../src/adapters/bidderFactory.js'; +import {deepAccess, logWarn} from '../src/utils.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER} from '../src/mediaTypes.js'; + const BIDDER_CODE = 'zeta_global'; const PREBID_DEFINER_ID = '44253' const ENDPOINT_URL = 'https://prebid.rfihub.com/prebid'; @@ -40,12 +41,6 @@ export const spec = { return false; } - if (!(bid.params.device.geo && - bid.params.device.geo.country)) { - logWarn('Invalid bid request - missing required geo data'); - return false; - } - if (!bid.params.definerId) { logWarn('Invalid bid request - missing required definer data'); return false; @@ -71,7 +66,7 @@ export const spec = { banner: buildBanner(request) }; let payload = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, imp: [impData], site: params.site ? params.site : {}, app: params.app ? params.app : {}, @@ -84,7 +79,7 @@ export const spec = { allimps: params.allimps, cur: [DEFAULT_CUR], wlang: params.wlang, - bcat: params.bcat, + bcat: deepAccess(bidderRequest.ortb2Imp, 'bcat') || params.bcat, badv: params.badv, bapp: params.bapp, source: params.source ? params.source : {}, @@ -94,7 +89,7 @@ export const spec = { payload.device.ua = navigator.userAgent; payload.device.ip = navigator.ip; - payload.site.page = bidderRequest.refererInfo.referer; + payload.site.page = bidderRequest.refererInfo.page; payload.site.mobile = /(ios|ipod|ipad|iphone|android)/i.test(navigator.userAgent) ? 1 : 0; payload.ext.definerId = params.definerId; diff --git a/modules/zetaSspBidAdapter.md b/modules/zetaSspBidAdapter.md deleted file mode 100644 index 00d8663586c..00000000000 --- a/modules/zetaSspBidAdapter.md +++ /dev/null @@ -1,74 +0,0 @@ -# Overview - -``` -Module Name: Zeta Ssp Bidder Adapter -Module Type: Bidder Adapter -Maintainer: miakovlev@zetaglobal.com -``` - -# Description - -Module that connects to Zeta's SSP - -# Banner Ad Unit: For Publishers -``` - var adUnits = [ - { - mediaTypes: { - banner: { - sizes: [[300, 250]], // a display size - } - }, - bids: [ - { - bidder: 'zeta_global_ssp', - bidId: 12345, - params: { - placement: 12345, - user: { - uid: 12345, - buyeruid: 12345 - }, - tags: { - someTag: 123, - sid: 'publisherId' - }, - test: 1 - } - } - ] - } - ]; -``` - -# Video Ad Unit: For Publishers -``` - var adUnits = [ - { - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'outstream' - } - }, - bids: [ - { - bidder: 'zeta_global_ssp', - bidId: 12345, - params: { - placement: 12345, - user: { - uid: 12345, - buyeruid: 12345 - }, - tags: { - someTag: 123, - sid: 'publisherId' - }, - test: 1 - } - } - ] - } - ]; -``` diff --git a/modules/zeta_global_sspAnalyticsAdapter.js b/modules/zeta_global_sspAnalyticsAdapter.js index 906e6e19cc2..3d5466dd906 100644 --- a/modules/zeta_global_sspAnalyticsAdapter.js +++ b/modules/zeta_global_sspAnalyticsAdapter.js @@ -1,15 +1,19 @@ -import { logInfo, logError } from '../src/utils.js'; +import {logInfo, logError} from '../src/utils.js'; import { ajax } from '../src/ajax.js'; import adapterManager from '../src/adapterManager.js'; import CONSTANTS from '../src/constants.json'; -import adapter from '../src/AnalyticsAdapter.js'; +import adapter from '../libraries/analyticsAdapter/AnalyticsAdapter.js'; const ZETA_GVL_ID = 833; const ADAPTER_CODE = 'zeta_global_ssp'; const BASE_URL = 'https://ssp.disqus.com/prebid/event'; const LOG_PREFIX = 'ZetaGlobalSsp-Analytics: '; +const cache = { + auctions: {} +}; + /// /////////// VARIABLES //////////////////////////////////// let publisherId; // int @@ -24,12 +28,37 @@ function sendEvent(eventType, event) { ); } +function getZetaParams(event) { + if (event.adUnits) { + for (const i in event.adUnits) { + const unit = event.adUnits[i]; + if (unit.bids) { + for (const j in unit.bids) { + const bid = unit.bids[j]; + if (bid.bidder === ADAPTER_CODE && bid.params) { + return bid.params; + } + } + } + } + } + return null; +} + /// /////////// ADAPTER EVENT HANDLER FUNCTIONS ////////////// function adRenderSucceededHandler(args) { let eventType = CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED logInfo(LOG_PREFIX + 'handle ' + eventType + ' event'); + // set zetaParams from cache + if (args.bid && args.bid.auctionId) { + const zetaParams = cache.auctions[args.bid.auctionId]; + if (zetaParams) { + args.bid.params = [ zetaParams ]; + } + } + sendEvent(eventType, args); } @@ -37,6 +66,12 @@ function auctionEndHandler(args) { let eventType = CONSTANTS.EVENTS.AUCTION_END; logInfo(LOG_PREFIX + 'handle ' + eventType + ' event'); + // save zetaParams to cache + const zetaParams = getZetaParams(args); + if (zetaParams && args.auctionId) { + cache.auctions[args.auctionId] = zetaParams; + } + sendEvent(eventType, args); } diff --git a/modules/zeta_global_sspBidAdapter.js b/modules/zeta_global_sspBidAdapter.js index 87fdbe1396f..687afb6c692 100644 --- a/modules/zeta_global_sspBidAdapter.js +++ b/modules/zeta_global_sspBidAdapter.js @@ -2,17 +2,18 @@ import {deepAccess, deepSetValue, isArray, isBoolean, isNumber, isStr, logWarn} import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from '../src/mediaTypes.js'; import {config} from '../src/config.js'; +import {parseDomain} from '../src/refererDetection.js'; +import {ajax} from '../src/ajax.js'; const BIDDER_CODE = 'zeta_global_ssp'; -const ENDPOINT_URL = 'https://ssp.disqus.com/bid'; +const ENDPOINT_URL = 'https://ssp.disqus.com/bid/prebid'; +const TIMEOUT_URL = 'https://ssp.disqus.com/timeout/prebid'; const USER_SYNC_URL_IFRAME = 'https://ssp.disqus.com/sync?type=iframe'; const USER_SYNC_URL_IMAGE = 'https://ssp.disqus.com/sync?type=image'; const DEFAULT_CUR = 'USD'; -const TTL = 200; +const TTL = 300; const NET_REV = true; -const VIDEO_REGEX = new RegExp(/VAST\s+version/); - const DATA_TYPES = { 'NUMBER': 'number', 'STRING': 'string', @@ -33,6 +34,7 @@ const VIDEO_CUSTOM_PARAMS = { 'battr': DATA_TYPES.ARRAY, 'linearity': DATA_TYPES.NUMBER, 'placement': DATA_TYPES.NUMBER, + 'plcmt': DATA_TYPES.NUMBER, 'minbitrate': DATA_TYPES.NUMBER, 'maxbitrate': DATA_TYPES.NUMBER, 'skip': DATA_TYPES.NUMBER @@ -68,34 +70,54 @@ export const spec = { */ buildRequests: function (validBidRequests, bidderRequest) { const secure = 1; // treat all requests as secure - const request = validBidRequests[0]; - const params = request.params; - const impData = { - id: request.bidId, - secure: secure - }; - if (request.mediaTypes) { - for (const mediaType in request.mediaTypes) { - switch (mediaType) { - case BANNER: - impData.banner = buildBanner(request); - break; - case VIDEO: - impData.video = buildVideo(request); - break; + const params = validBidRequests[0].params; + const imps = validBidRequests.map(request => { + const impData = { + id: request.bidId, + secure: secure + }; + if (params.tagid) { + impData.tagid = params.tagid; + } + if (request.mediaTypes) { + for (const mediaType in request.mediaTypes) { + switch (mediaType) { + case BANNER: + impData.banner = buildBanner(request); + break; + case VIDEO: + impData.video = buildVideo(request); + break; + } } } - } - if (!impData.banner && !impData.video) { - impData.banner = buildBanner(request); - } - const fpd = config.getLegacyFpd(config.getConfig('ortb2')) || {}; + if (!impData.banner && !impData.video) { + impData.banner = buildBanner(request); + } + + if (typeof request.getFloor === 'function') { + const floorInfo = request.getFloor({ + currency: 'USD', + mediaType: impData.video ? 'video' : 'banner', + size: [ impData.video ? impData.video.w : impData.banner.w, impData.video ? impData.video.h : impData.banner.h ] + }); + if (floorInfo && floorInfo.floor) { + impData.bidfloor = floorInfo.floor; + } + } + if (!impData.bidfloor && params.bidfloor) { + impData.bidfloor = params.bidfloor; + } + + return impData; + }); + let payload = { - id: bidderRequest.auctionId, + id: bidderRequest.bidderRequestId, cur: [DEFAULT_CUR], - imp: [impData], + imp: imps, site: params.site ? params.site : {}, - device: {...fpd.device, ...params.device}, + device: {...(bidderRequest.ortb2?.device || {}), ...params.device}, user: params.user ? params.user : {}, app: params.app ? params.app : {}, ext: { @@ -104,8 +126,9 @@ export const spec = { } }; const rInfo = bidderRequest.refererInfo; - payload.site.page = config.getConfig('pageUrl') || ((rInfo && rInfo.referer) ? rInfo.referer.trim() : window.location.href); - payload.site.domain = config.getConfig('publisherDomain') || getDomainFromURL(payload.site.page); + // TODO: do the fallbacks make sense here? + payload.site.page = rInfo.page || rInfo.topmostLocation; + payload.site.domain = parseDomain(payload.site.page, {noLeadingWww: true}); payload.device.ua = navigator.userAgent; payload.device.language = navigator.language; @@ -125,10 +148,24 @@ export const spec = { deepSetValue(payload, 'regs.ext.us_privacy', bidderRequest.uspConsent); } - provideEids(request, payload); + // schain + if (validBidRequests[0].schain) { + payload.source = { + ext: { + schain: validBidRequests[0].schain + } + } + } + + if (bidderRequest?.timeout) { + payload.tmax = bidderRequest.timeout; + } + + provideEids(validBidRequests[0], payload); + const url = params.shortname ? ENDPOINT_URL.concat('?shortname=', params.shortname) : ENDPOINT_URL; return { method: 'POST', - url: ENDPOINT_URL, + url: url, data: JSON.stringify(payload), }; }, @@ -162,7 +199,10 @@ export const spec = { advertiserDomains: zetaBid.adomain }; } - provideMediaType(zetaBid, bid); + provideMediaType(zetaBid, bid, bidRequest.data); + if (bid.mediaType === VIDEO) { + bid.vastXml = bid.ad; + } bidResponses.push(bid); }) }) @@ -203,6 +243,18 @@ export const spec = { url: USER_SYNC_URL_IMAGE + syncurl }]; } + }, + + onTimeout: function(timeoutData) { + if (timeoutData) { + ajax(TIMEOUT_URL, null, JSON.stringify(timeoutData), { + method: 'POST', + options: { + withCredentials: false, + contentType: 'application/json' + } + }); + } } } @@ -213,10 +265,24 @@ function buildBanner(request) { request.mediaTypes.banner.sizes) { sizes = request.mediaTypes.banner.sizes; } - return { - w: sizes[0][0], - h: sizes[0][1] - }; + if (sizes.length > 1) { + const format = sizes.map(s => { + return { + w: s[0], + h: s[1] + } + }); + return { + w: sizes[0][0], + h: sizes[0][1], + format: format + } + } else { + return { + w: sizes[0][0], + h: sizes[0][1] + } + } } function buildVideo(request) { @@ -268,31 +334,11 @@ function provideEids(request, payload) { } } -function getDomainFromURL(url) { - let anchor = document.createElement('a'); - anchor.href = url; - let hostname = anchor.hostname; - if (hostname.indexOf('www.') === 0) { - return hostname.substring(4); - } - return hostname; -} - -function provideMediaType(zetaBid, bid) { - if (zetaBid.ext && zetaBid.ext.bidtype) { - if (zetaBid.ext.bidtype === VIDEO) { - bid.mediaType = VIDEO; - bid.vastXml = bid.ad; - } else { - bid.mediaType = BANNER; - } +function provideMediaType(zetaBid, bid, bidRequest) { + if (zetaBid.ext && zetaBid.ext.prebid && zetaBid.ext.prebid.type) { + bid.mediaType = zetaBid.ext.prebid.type === VIDEO ? VIDEO : BANNER; } else { - if (VIDEO_REGEX.test(bid.ad)) { - bid.mediaType = VIDEO; - bid.vastXml = bid.ad; - } else { - bid.mediaType = BANNER; - } + bid.mediaType = bidRequest.imp[0].video ? VIDEO : BANNER; } } diff --git a/package-lock.json b/package-lock.json index 205876791ff..e2f0f242d86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,47 +1,48 @@ { "name": "prebid.js", - "version": "6.21.0-pre", + "version": "8.17.0-pre", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prebid.js", - "version": "6.20.0-pre", + "version": "8.8.0-pre", "license": "Apache-2.0", "dependencies": { - "babel-plugin-transform-object-assign": "^6.22.0", + "@babel/core": "^7.16.7", + "@babel/plugin-transform-runtime": "^7.18.9", + "@babel/preset-env": "^7.16.8", + "@babel/runtime": "^7.18.9", "core-js": "^3.13.0", "core-js-pure": "^3.13.0", "criteo-direct-rsa-validate": "^1.1.0", "crypto-js": "^3.3.0", "dlv": "1.1.3", - "dset": "2.0.1", + "dset": "3.1.2", "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "2.3.1" + "live-connect-js": "^6.0.1" }, "devDependencies": { - "@babel/core": "^7.16.7", "@babel/eslint-parser": "^7.16.5", - "@babel/preset-env": "^7.16.8", - "@jsdevtools/coverage-istanbul-loader": "^3.0.3", - "@wdio/browserstack-service": "^7.16.0", - "@wdio/cli": "^7.5.2", - "@wdio/concise-reporter": "^7.5.2", - "@wdio/local-runner": "^7.5.2", - "@wdio/mocha-framework": "^7.5.2", - "@wdio/spec-reporter": "^7.19.0", - "@wdio/sync": "^7.5.2", + "@wdio/browserstack-service": "~7.16.0", + "@wdio/cli": "~7.5.2", + "@wdio/concise-reporter": "~7.5.2", + "@wdio/local-runner": "~7.5.2", + "@wdio/mocha-framework": "~7.5.2", + "@wdio/spec-reporter": "~7.19.0", + "@wdio/sync": "~7.5.2", "ajv": "6.12.3", "assert": "^2.0.0", "babel-loader": "^8.0.5", + "babel-plugin-istanbul": "^6.1.1", "babel-register": "^6.26.0", "body-parser": "^1.19.0", "chai": "^4.2.0", "coveralls": "^3.1.0", "deep-equal": "^2.0.3", - "documentation": "^13.2.5", + "documentation": "^14.0.0", "es5-shim": "^4.5.14", "eslint": "^7.27.0", "eslint-config-standard": "^10.2.1", @@ -54,12 +55,10 @@ "faker": "^5.5.3", "fs.extra": "^1.3.2", "gulp": "^4.0.0", - "gulp-clean": "^0.3.2", + "gulp-clean": "^0.4.0", "gulp-concat": "^2.6.0", "gulp-connect": "^5.7.0", - "gulp-eslint": "^4.0.0", - "gulp-footer": "^2.0.2", - "gulp-header": "^2.0.9", + "gulp-eslint": "^6.0.0", "gulp-if": "^3.0.0", "gulp-js-escape": "^1.0.1", "gulp-replace": "^1.0.0", @@ -89,7 +88,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^5.0.0", "lodash": "^4.17.21", - "mocha": "^5.0.0", + "mocha": "^10.0.0", "morgan": "^1.10.0", "opn": "^5.4.0", "resolve-from": "^5.0.0", @@ -97,9 +96,14 @@ "through2": "^4.0.2", "url": "^0.11.0", "url-parse": "^1.0.5", + "video.js": "^7.17.0", + "videojs-contrib-ads": "^6.9.0", + "videojs-ima": "^1.11.0", + "videojs-playlist": "^5.0.0", "webdriverio": "^7.6.1", "webpack": "^5.70.0", "webpack-bundle-analyzer": "^4.5.0", + "webpack-manifest-plugin": "^5.0.0", "webpack-stream": "^7.0.0", "yargs": "^1.3.1" }, @@ -111,58 +115,55 @@ } }, "node_modules/@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", - "dev": true, + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", "dependencies": { - "@jridgewell/trace-mapping": "^0.3.0" + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" }, "engines": { "node": ">=6.0.0" } }, "node_modules/@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", + "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", "dependencies": { - "@babel/highlight": "^7.16.7" + "@babel/highlight": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/compat-data": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.0.tgz", - "integrity": "sha512-392byTlpGWXMv4FbyWw3sAZ/FrW/DrwqLGXpy0mbyNe9Taqv1mg9yON5/o0cnr8XYCkFTZbC1eV+c+LAROgrng==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.20.1.tgz", + "integrity": "sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.17.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.5.tgz", - "integrity": "sha512-/BBMw4EvjmyquN5O+t5eh0+YqB3XXJkYD2cjKpYtWOfFy4lQ4UozNSmxAcWT8r2XtZs0ewG+zrfsqeR15i1ajA==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.19.6.tgz", + "integrity": "sha512-D2Ue4KHpc6Ys2+AxpIx1BZ8+UegLLLE2p3KJEuJRKmokHOtl49jQ5ny1773KsGLZs8MQvBidAF6yWUJxRqtKtg==", "dependencies": { "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.3", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helpers": "^7.17.2", - "@babel/parser": "^7.17.3", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0", + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.19.6", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helpers": "^7.19.4", + "@babel/parser": "^7.19.6", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.6", + "@babel/types": "^7.19.4", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.1.2", + "json5": "^2.2.1", "semver": "^6.3.0" }, "engines": { @@ -174,12 +175,12 @@ } }, "node_modules/@babel/eslint-parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz", - "integrity": "sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.19.1.tgz", + "integrity": "sha512-AqNf2QWt1rtu2/1rLswy6CDP7H9Oh3mMhk177Y67Rg8d7RD9WfOLLv8CGn6tisFvS2htm86yIe1yLF6I1UDaGQ==", "dev": true, "dependencies": { - "eslint-scope": "^5.1.1", + "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", "eslint-visitor-keys": "^2.1.0", "semver": "^6.3.0" }, @@ -192,53 +193,62 @@ } }, "node_modules/@babel/generator": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.3.tgz", - "integrity": "sha512-+R6Dctil/MgUsZsZAkYgK+ADNSZzJRRy0TvY65T71z/CR854xHQ1EweBYXdfT+HNeN7w0cSJJEzgxZMv40pxsg==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.1.tgz", + "integrity": "sha512-u1dMdBUmA7Z0rBB97xh8pIhviK7oItYOkjbsCxTWMknyvbQRBwX7/gn4JXurRdirWMFh+ZtYARqkA6ydogVZpg==", "dependencies": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" + "@babel/types": "^7.20.0", + "@jridgewell/gen-mapping": "^0.3.2", + "jsesc": "^2.5.1" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz", - "integrity": "sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz", + "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz", - "integrity": "sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.18.9.tgz", + "integrity": "sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw==", "dependencies": { - "@babel/helper-explode-assignable-expression": "^7.16.7", - "@babel/types": "^7.16.7" + "@babel/helper-explode-assignable-expression": "^7.18.6", + "@babel/types": "^7.18.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.7.tgz", - "integrity": "sha512-mGojBwIWcwGD6rfqgRXVlVYmPAv7eOpIemUG3dGnDdCY4Pae70ROij3XmfrH6Fa1h1aiDylpglbZyktfzyo/hA==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz", + "integrity": "sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ==", "dependencies": { - "@babel/compat-data": "^7.16.4", - "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", + "@babel/compat-data": "^7.20.0", + "@babel/helper-validator-option": "^7.18.6", + "browserslist": "^4.21.3", "semver": "^6.3.0" }, "engines": { @@ -249,18 +259,17 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.17.6.tgz", - "integrity": "sha512-SogLLSxXm2OkBbSsHZMM4tUi8fUzjs63AT/d0YQIzr6GSd8Hxsbk2KYDX0k0DweAzGMj/YWeiCsorIdtdcW8Eg==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.19.0.tgz", + "integrity": "sha512-NRz8DwF4jT3UfrmUoZjd0Uph9HQnP30t7Ash+weACcyNkiYTywpIjDBgReJMKgr+n86sn2nPVVmJ28Dm053Kqw==", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-member-expression-to-functions": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7" + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-member-expression-to-functions": "^7.18.9", + "@babel/helper-optimise-call-expression": "^7.18.6", + "@babel/helper-replace-supers": "^7.18.9", + "@babel/helper-split-export-declaration": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -270,13 +279,12 @@ } }, "node_modules/@babel/helper-create-regexp-features-plugin": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.17.0.tgz", - "integrity": "sha512-awO2So99wG6KnlE+TPs6rn83gCz5WlEePJDTnLEqbchMVrBeAujURVphRdigsk094VhvZehFoNOihSlcBjwsXA==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.19.0.tgz", + "integrity": "sha512-htnV+mHX32DF81amCDrwIDr8nrp1PTm+3wfBN9/v8QJOLEioOCOG7qNyq0nHeFiWbT3Eb7gsPwEmV64UCQ1jzw==", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "regexpu-core": "^5.0.1" + "@babel/helper-annotate-as-pure": "^7.18.6", + "regexpu-core": "^5.1.0" }, "engines": { "node": ">=6.9.0" @@ -286,15 +294,12 @@ } }, "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz", - "integrity": "sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==", - "dev": true, + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz", + "integrity": "sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==", "dependencies": { - "@babel/helper-compilation-targets": "^7.13.0", - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "@babel/traverse": "^7.13.0", + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", "debug": "^4.1.1", "lodash.debounce": "^4.0.8", "resolve": "^1.14.2", @@ -305,251 +310,228 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" - }, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", + "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-explode-assignable-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz", - "integrity": "sha512-KyUenhWMC8VrxzkGP0Jizjo4/Zx+1nNZhgocs+gLzyZyB8SHidhoq9KK/8Ato4anhwsivfkBLftky7gvzbZMtQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.18.6.tgz", + "integrity": "sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz", - "integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz", + "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==", "dependencies": { - "@babel/helper-get-function-arity": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/types": "^7.16.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-get-function-arity": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz", - "integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==", - "dev": true, - "dependencies": { - "@babel/types": "^7.16.7" + "@babel/template": "^7.18.10", + "@babel/types": "^7.19.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", + "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.16.7.tgz", - "integrity": "sha512-VtJ/65tYiU/6AbMTDwyoXGPKHgTsfRarivm+YbB5uAzKUyuPjgZSgAFeG87FCigc7KNHu2Pegh1XIT3lXjvz3Q==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.18.9.tgz", + "integrity": "sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-imports": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz", - "integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", + "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.6.tgz", - "integrity": "sha512-2ULmRdqoOMpdvkbT8jONrZML/XALfzxlb052bldftkicAUy8AxSCkD5trDPQcwHNmolcl7wP6ehNqMlyUw6AaA==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.19.6.tgz", + "integrity": "sha512-fCmcfQo/KYr/VXXDIyd3CBGZ6AFhPFy1TfSEJ+PilGVlQT6jcbqtHAM4C1EciRqMza7/TpOUZliuSH+U6HAhJw==", "dependencies": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-simple-access": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-simple-access": "^7.19.4", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.19.1", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.6", + "@babel/types": "^7.19.4" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz", - "integrity": "sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz", + "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", - "integrity": "sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.19.0.tgz", + "integrity": "sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-remap-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz", - "integrity": "sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz", + "integrity": "sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-wrap-function": "^7.16.8", - "@babel/types": "^7.16.8" + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-wrap-function": "^7.18.9", + "@babel/types": "^7.18.9" }, "engines": { "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz", - "integrity": "sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw==", - "dev": true, + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.19.1.tgz", + "integrity": "sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw==", "dependencies": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-member-expression-to-functions": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/traverse": "^7.16.7", - "@babel/types": "^7.16.7" + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-member-expression-to-functions": "^7.18.9", + "@babel/helper-optimise-call-expression": "^7.18.6", + "@babel/traverse": "^7.19.1", + "@babel/types": "^7.19.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-simple-access": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.7.tgz", - "integrity": "sha512-ZIzHVyoeLMvXMN/vok/a4LWRy8G2v205mNP0XOuf9XRLyX5/u9CnVulUtDgUTama3lT+bf/UqucuZjqiGuTS1g==", - "dev": true, + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.19.4.tgz", + "integrity": "sha512-f9Xq6WqBFqaDfbCzn2w85hwklswz5qsKlh7f08w4Y9yhJHpnNC0QemtSkK5YyOY8kPGvyiwdzZksGUhnGdaUIg==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.19.4" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz", - "integrity": "sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz", + "integrity": "sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==", "dependencies": { - "@babel/types": "^7.16.0" + "@babel/types": "^7.20.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", + "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", "dependencies": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" }, "engines": { "node": ">=6.9.0" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", + "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true, + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-option": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz", - "integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", + "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-wrap-function": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz", - "integrity": "sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.19.0.tgz", + "integrity": "sha512-txX8aN8CZyYGTwcLhlk87KRqncAzhh5TpQamZUa0/u3an36NtDpUP6bQgBCBcLeBs09R/OwQu3OjK0k/HwfNDg==", "dependencies": { - "@babel/helper-function-name": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.16.8", - "@babel/types": "^7.16.8" + "@babel/helper-function-name": "^7.19.0", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.0", + "@babel/types": "^7.19.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.17.2", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.2.tgz", - "integrity": "sha512-0Qu7RLR1dILozr/6M0xgj+DFPmi6Bnulgm9M8BVa9ZCWxDqlSnqt3cf8IDPB5m45sVXUZ0kuQAgUrdSFFH79fQ==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.20.1.tgz", + "integrity": "sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg==", "dependencies": { - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.0", - "@babel/types": "^7.17.0" + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.20.1", + "@babel/types": "^7.20.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -558,10 +540,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.3.tgz", - "integrity": "sha512-7yJPvPV+ESz2IUTPbOL+YkIGyCqOyNIzdguKQuJGnH7bg1WTIifuM21YqokFt/THWh1AkCRn9IgoykTRCBVpzA==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.1.tgz", + "integrity": "sha512-hp0AYxaZJhxULfM1zyp7Wgr+pSUKBcP3M+PHnSzWGdXOzg/kHWIgiUWARvubhUKGOEw3xqY4x+lyZ9ytBVcELw==", "bin": { "parser": "bin/babel-parser.js" }, @@ -570,12 +551,11 @@ } }, "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz", - "integrity": "sha512-anv/DObl7waiGEnC24O9zqL0pSuI9hljihqiDuFHC8d7/bjr/4RLGPWuc8rYOff/QPzbEPSkzG8wGG9aDuhHRg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz", + "integrity": "sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -585,14 +565,13 @@ } }, "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.7.tgz", - "integrity": "sha512-di8vUHRdf+4aJ7ltXhaDbPoszdkh59AQtJM5soLsuHpQJdFQZOA4uGj0V2u/CZ8bJ/u8ULDL5yq6FO/bCXnKHw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.18.9.tgz", + "integrity": "sha512-AHrP9jadvH7qlOj6PINbgSuphjQUAK7AOT7DPjBo9EHoLhQTnnK5u45e1Hd4DbSQEO9nqPWtQ89r+XEOWFScKg==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", - "@babel/plugin-proposal-optional-chaining": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9", + "@babel/plugin-proposal-optional-chaining": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -602,13 +581,13 @@ } }, "node_modules/@babel/plugin-proposal-async-generator-functions": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz", - "integrity": "sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.1.tgz", + "integrity": "sha512-Gh5rchzSwE4kC+o/6T8waD0WHEQIsDmjltY8WnWRXHUdH8axZhuH86Ov9M72YhJfDrZseQwuuWaaIT/TmePp3g==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-remap-async-to-generator": "^7.18.9", "@babel/plugin-syntax-async-generators": "^7.8.4" }, "engines": { @@ -619,13 +598,12 @@ } }, "node_modules/@babel/plugin-proposal-class-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz", - "integrity": "sha512-IobU0Xme31ewjYOShSIqd/ZGM/r/cuOz2z0MDbNrhF5FW+ZVgi0f2lyeoj9KFPDOAqsYxmLWZte1WOwlvY9aww==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", + "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -635,13 +613,12 @@ } }, "node_modules/@babel/plugin-proposal-class-static-block": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.17.6.tgz", - "integrity": "sha512-X/tididvL2zbs7jZCeeRJ8167U/+Ac135AM6jCAx6gYXDUviZV5Ku9UDvWS2NCuWlFjIRXklYhwo6HhAC7ETnA==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.18.6.tgz", + "integrity": "sha512-+I3oIiNxrCpup3Gi8n5IGMwj0gOCAjcJUSQEcotNnCCPMEnixawOQ+KeJPlgfjzx+FKQ1QSyZOWe7wmoJp7vhw==", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.17.6", - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-class-static-block": "^7.14.5" }, "engines": { @@ -652,12 +629,11 @@ } }, "node_modules/@babel/plugin-proposal-dynamic-import": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.7.tgz", - "integrity": "sha512-I8SW9Ho3/8DRSdmDdH3gORdyUuYnk1m4cMxUAdu5oy4n3OfN8flDEH+d60iG7dUfi0KkYwSvoalHzzdRzpWHTg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz", + "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-dynamic-import": "^7.8.3" }, "engines": { @@ -668,12 +644,11 @@ } }, "node_modules/@babel/plugin-proposal-export-namespace-from": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.7.tgz", - "integrity": "sha512-ZxdtqDXLRGBL64ocZcs7ovt71L3jhC1RGSyR996svrCi3PYqHNkb3SwPJCs8RIzD86s+WPpt2S73+EHCGO+NUA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz", + "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.9", "@babel/plugin-syntax-export-namespace-from": "^7.8.3" }, "engines": { @@ -684,12 +659,11 @@ } }, "node_modules/@babel/plugin-proposal-json-strings": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.7.tgz", - "integrity": "sha512-lNZ3EEggsGY78JavgbHsK9u5P3pQaW7k4axlgFLYkMd7UBsiNahCITShLjNQschPyjtO6dADrL24757IdhBrsQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz", + "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-json-strings": "^7.8.3" }, "engines": { @@ -700,12 +674,11 @@ } }, "node_modules/@babel/plugin-proposal-logical-assignment-operators": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.7.tgz", - "integrity": "sha512-K3XzyZJGQCr00+EtYtrDjmwX7o7PLK6U9bi1nCwkQioRFVUv6dJoxbQjtWVtP+bCPy82bONBKG8NPyQ4+i6yjg==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.18.9.tgz", + "integrity": "sha512-128YbMpjCrP35IOExw2Fq+x55LMP42DzhOhX2aNNIdI9avSWl2PI0yuBWarr3RYpZBSPtabfadkH2yeRiMD61Q==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.9", "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" }, "engines": { @@ -716,12 +689,11 @@ } }, "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.7.tgz", - "integrity": "sha512-aUOrYU3EVtjf62jQrCj63pYZ7k6vns2h/DQvHPWGmsJRYzWXZ6/AsfgpiRy6XiuIDADhJzP2Q9MwSMKauBQ+UQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", + "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" }, "engines": { @@ -732,12 +704,11 @@ } }, "node_modules/@babel/plugin-proposal-numeric-separator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.7.tgz", - "integrity": "sha512-vQgPMknOIgiuVqbokToyXbkY/OmmjAzr/0lhSIbG/KmnzXPGwW/AdhdKpi+O4X/VkWiWjnkKOBiqJrTaC98VKw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz", + "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-numeric-separator": "^7.10.4" }, "engines": { @@ -748,16 +719,15 @@ } }, "node_modules/@babel/plugin-proposal-object-rest-spread": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.17.3.tgz", - "integrity": "sha512-yuL5iQA/TbZn+RGAfxQXfi7CNLmKi1f8zInn4IgobuCWcAb7i+zj4TYzQ9l8cEzVyJ89PDGuqxK1xZpUDISesw==", - "dev": true, + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.19.4.tgz", + "integrity": "sha512-wHmj6LDxVDnL+3WhXteUBaoM1aVILZODAUjg11kHqG4cOlfgMQGxw6aCgvrXrmaJR3Bn14oZhImyCPZzRpC93Q==", "dependencies": { - "@babel/compat-data": "^7.17.0", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/compat-data": "^7.19.4", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-plugin-utils": "^7.19.0", "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.16.7" + "@babel/plugin-transform-parameters": "^7.18.8" }, "engines": { "node": ">=6.9.0" @@ -767,12 +737,11 @@ } }, "node_modules/@babel/plugin-proposal-optional-catch-binding": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz", - "integrity": "sha512-eMOH/L4OvWSZAE1VkHbr1vckLG1WUcHGJSLqqQwl2GaUqG6QjddvrOaTUMNYiv77H5IKPMZ9U9P7EaHwvAShfA==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz", + "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" }, "engines": { @@ -783,13 +752,12 @@ } }, "node_modules/@babel/plugin-proposal-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.7.tgz", - "integrity": "sha512-eC3xy+ZrUcBtP7x+sq62Q/HYd674pPTb/77XZMb5wbDPGWIdUbSr4Agr052+zaUPSb+gGRnjxXfKFvx5iMJ+DA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.18.9.tgz", + "integrity": "sha512-v5nwt4IqBXihxGsW2QmCWMDS3B3bzGIk/EQVZz2ei7f3NJl8NzAJVvUmpDW5q1CRNY+Beb/k58UAH1Km1N411w==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", + "@babel/helper-plugin-utils": "^7.18.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9", "@babel/plugin-syntax-optional-chaining": "^7.8.3" }, "engines": { @@ -800,13 +768,12 @@ } }, "node_modules/@babel/plugin-proposal-private-methods": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz", - "integrity": "sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz", + "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.16.10", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -816,14 +783,13 @@ } }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.7.tgz", - "integrity": "sha512-rMQkjcOFbm+ufe3bTZLyOfsOUOxyvLXZJCTARhJr+8UMSoZmqTe1K1BgkFcrW37rAchWg57yI69ORxiWvUINuQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.18.6.tgz", + "integrity": "sha512-9Rysx7FOctvT5ouj5JODjAFAkgGoudQuLPamZb0v1TGLpapdNaftzifU8NTWQm0IRjqoYypdrSmyWgkocDQ8Dw==", "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-private-property-in-object": "^7.14.5" }, "engines": { @@ -834,13 +800,12 @@ } }, "node_modules/@babel/plugin-proposal-unicode-property-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.7.tgz", - "integrity": "sha512-QRK0YI/40VLhNVGIjRNAAQkEHws0cswSdFFjpFyt943YmJIU1da9uW63Iu6NFV6CxTZW5eTDCrwZUstBWgp/Rg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz", + "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=4" @@ -853,7 +818,6 @@ "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -865,7 +829,6 @@ "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.12.13" }, @@ -877,7 +840,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.14.5" }, @@ -892,7 +854,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -904,7 +865,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.3" }, @@ -912,11 +872,24 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-syntax-import-assertions": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz", + "integrity": "sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ==", + "dependencies": { + "@babel/helper-plugin-utils": "^7.19.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-syntax-json-strings": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -928,7 +901,6 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -940,7 +912,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -952,7 +923,6 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.10.4" }, @@ -964,7 +934,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -976,7 +945,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -988,7 +956,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.8.0" }, @@ -1000,7 +967,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.14.5" }, @@ -1015,7 +981,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.14.5" }, @@ -1027,12 +992,11 @@ } }, "node_modules/@babel/plugin-transform-arrow-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.7.tgz", - "integrity": "sha512-9ffkFFMbvzTvv+7dTp/66xvZAWASuPD5Tl9LK3Z9vhOmANo6j94rik+5YMBt4CwHVMWLWpMsriIc2zsa3WW3xQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.18.6.tgz", + "integrity": "sha512-9S9X9RUefzrsHZmKMbDXxweEH+YlE8JJEuat9FdvW9Qh1cw7W64jELCtWNkPBPX5En45uy28KGvA/AySqUh8CQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1042,14 +1006,13 @@ } }, "node_modules/@babel/plugin-transform-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.8.tgz", - "integrity": "sha512-MtmUmTJQHCnyJVrScNzNlofQJ3dLFuobYn3mwOTKHnSCMtbNsqvF71GQmJfFjdrXSsAA7iysFmYWw4bXZ20hOg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.18.6.tgz", + "integrity": "sha512-ARE5wZLKnTgPW7/1ftQmSi1CmkqqHo2DNmtztFhvgtOWSDfq0Cq9/9L+KnZNYSNrydBekhW3rwShduf59RoXag==", "dependencies": { - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8" + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/helper-remap-async-to-generator": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1059,12 +1022,11 @@ } }, "node_modules/@babel/plugin-transform-block-scoped-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz", - "integrity": "sha512-JUuzlzmF40Z9cXyytcbZEZKckgrQzChbQJw/5PuEHYeqzCsvebDx0K0jWnIIVcmmDOAVctCgnYs0pMcrYj2zJg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz", + "integrity": "sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1074,12 +1036,11 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.7.tgz", - "integrity": "sha512-ObZev2nxVAYA4bhyusELdo9hb3H+A56bxH3FZMbEImZFiEDYVHXQSJ1hQKFlDnlt8G9bBrCZ5ZpURZUrV4G5qQ==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.20.0.tgz", + "integrity": "sha512-sXOohbpHZSk7GjxK9b3dKB7CfqUD5DwOH+DggKzOQ7TXYP+RCSbRykfjQmn/zq+rBjycVRtLf9pYhAaEJA786w==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.19.0" }, "engines": { "node": ">=6.9.0" @@ -1089,18 +1050,18 @@ } }, "node_modules/@babel/plugin-transform-classes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.7.tgz", - "integrity": "sha512-WY7og38SFAGYRe64BrjKf8OrE6ulEHtr5jEYaZMwox9KebgqPi67Zqz8K53EKk1fFEJgm96r32rkKZ3qA2nCWQ==", - "dev": true, - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.19.0.tgz", + "integrity": "sha512-YfeEE9kCjqTS9IitkgfJuxjcEtLUHMqa8yUJ6zdz8vR7hKuo6mOy2C05P0F1tdMmDCeuyidKnlrw/iTppHcr2A==", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-compilation-targets": "^7.19.0", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-optimise-call-expression": "^7.18.6", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-replace-supers": "^7.18.9", + "@babel/helper-split-export-declaration": "^7.18.6", "globals": "^11.1.0" }, "engines": { @@ -1111,12 +1072,11 @@ } }, "node_modules/@babel/plugin-transform-computed-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.7.tgz", - "integrity": "sha512-gN72G9bcmenVILj//sv1zLNaPyYcOzUho2lIJBMh/iakJ9ygCo/hEF9cpGb61SCMEDxbbyBoVQxrt+bWKu5KGw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.18.9.tgz", + "integrity": "sha512-+i0ZU1bCDymKakLxn5srGHrsAPRELC2WIbzwjLhHW9SIE1cPYkLCL0NlnXMZaM1vhfgA2+M7hySk42VBvrkBRw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1126,12 +1086,11 @@ } }, "node_modules/@babel/plugin-transform-destructuring": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.17.3.tgz", - "integrity": "sha512-dDFzegDYKlPqa72xIlbmSkly5MluLoaC1JswABGktyt6NTXSBcUuse/kWE/wvKFWJHPETpi158qJZFS3JmykJg==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.20.0.tgz", + "integrity": "sha512-1dIhvZfkDVx/zn2S1aFwlruspTt4189j7fEkH0Y0VyuDM6bQt7bD6kLcz3l4IlLG+e5OReaBz9ROAbttRtUHqA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.19.0" }, "engines": { "node": ">=6.9.0" @@ -1141,13 +1100,12 @@ } }, "node_modules/@babel/plugin-transform-dotall-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.7.tgz", - "integrity": "sha512-Lyttaao2SjZF6Pf4vk1dVKv8YypMpomAbygW+mU5cYP3S5cWTfCJjG8xV6CFdzGFlfWK81IjL9viiTvpb6G7gQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz", + "integrity": "sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg==", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1157,12 +1115,11 @@ } }, "node_modules/@babel/plugin-transform-duplicate-keys": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.7.tgz", - "integrity": "sha512-03DvpbRfvWIXyK0/6QiR1KMTWeT6OcQ7tbhjrXyFS02kjuX/mu5Bvnh5SDSWHxyawit2g5aWhKwI86EE7GUnTw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz", + "integrity": "sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1172,13 +1129,12 @@ } }, "node_modules/@babel/plugin-transform-exponentiation-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.7.tgz", - "integrity": "sha512-8UYLSlyLgRixQvlYH3J2ekXFHDFLQutdy7FfFAMm3CPZ6q9wHCwnUyiXpQCe3gVVnQlHc5nsuiEVziteRNTXEA==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz", + "integrity": "sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw==", "dependencies": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-builder-binary-assignment-operator-visitor": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1188,12 +1144,11 @@ } }, "node_modules/@babel/plugin-transform-for-of": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.7.tgz", - "integrity": "sha512-/QZm9W92Ptpw7sjI9Nx1mbcsWz33+l8kuMIQnDwgQBG5s3fAfQvkRjQ7NqXhtNcKOnPkdICmUHyCaWW06HCsqg==", - "dev": true, + "version": "7.18.8", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.18.8.tgz", + "integrity": "sha512-yEfTRnjuskWYo0k1mHUqrVWaZwrdq8AYbfrpqULOJOaucGSp4mNMVps+YtA8byoevxS/urwU75vyhQIxcCgiBQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1203,14 +1158,13 @@ } }, "node_modules/@babel/plugin-transform-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.7.tgz", - "integrity": "sha512-SU/C68YVwTRxqWj5kgsbKINakGag0KTgq9f2iZEXdStoAbOzLHEBRYzImmA6yFo8YZhJVflvXmIHUO7GWHmxxA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz", + "integrity": "sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ==", "dependencies": { - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-compilation-targets": "^7.18.9", + "@babel/helper-function-name": "^7.18.9", + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1220,12 +1174,11 @@ } }, "node_modules/@babel/plugin-transform-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.7.tgz", - "integrity": "sha512-6tH8RTpTWI0s2sV6uq3e/C9wPo4PTqqZps4uF0kzQ9/xPLFQtipynvmT1g/dOfEJ+0EQsHhkQ/zyRId8J2b8zQ==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz", + "integrity": "sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1235,12 +1188,11 @@ } }, "node_modules/@babel/plugin-transform-member-expression-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.7.tgz", - "integrity": "sha512-mBruRMbktKQwbxaJof32LT9KLy2f3gH+27a5XSuXo6h7R3vqltl0PgZ80C8ZMKw98Bf8bqt6BEVi3svOh2PzMw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz", + "integrity": "sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1250,14 +1202,12 @@ } }, "node_modules/@babel/plugin-transform-modules-amd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.7.tgz", - "integrity": "sha512-KaaEtgBL7FKYwjJ/teH63oAmE3lP34N3kshz8mm4VMAw7U3PxjVwwUmxEFksbgsNUaO3wId9R2AVQYSEGRa2+g==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.19.6.tgz", + "integrity": "sha512-uG3od2mXvAtIFQIh0xrpLH6r5fpSQN04gIVovl+ODLdUMANokxQLZnPBHcjmv3GxRjnqwLuHvppjjcelqUFZvg==", "dependencies": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helper-plugin-utils": "^7.19.0" }, "engines": { "node": ">=6.9.0" @@ -1267,15 +1217,13 @@ } }, "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.16.8.tgz", - "integrity": "sha512-oflKPvsLT2+uKQopesJt3ApiaIS2HW+hzHFcwRNtyDGieAeC/dIHZX8buJQ2J2X1rxGPy4eRcUijm3qcSPjYcA==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.19.6.tgz", + "integrity": "sha512-8PIa1ym4XRTKuSsOUXqDG0YaOlEuTVvHMe5JCfgBMOtHvJKw/4NGovEGN33viISshG/rZNVrACiBmPQLvWN8xQ==", "dependencies": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-simple-access": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-simple-access": "^7.19.4" }, "engines": { "node": ">=6.9.0" @@ -1285,16 +1233,14 @@ } }, "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.16.7.tgz", - "integrity": "sha512-DuK5E3k+QQmnOqBR9UkusByy5WZWGRxfzV529s9nPra1GE7olmxfqO2FHobEOYSPIjPBTr4p66YDcjQnt8cBmw==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.19.6.tgz", + "integrity": "sha512-fqGLBepcc3kErfR9R3DnVpURmckXP7gj7bAlrTQyBxrigFqszZCkFkcoxzCp2v32XmwXLvbw+8Yq9/b+QqksjQ==", "dependencies": { - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-validator-identifier": "^7.19.1" }, "engines": { "node": ">=6.9.0" @@ -1304,13 +1250,12 @@ } }, "node_modules/@babel/plugin-transform-modules-umd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz", - "integrity": "sha512-EMh7uolsC8O4xhudF2F6wedbSHm1HHZ0C6aJ7K67zcDNidMzVcxWdGr+htW9n21klm+bOn+Rx4CBsAntZd3rEQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz", + "integrity": "sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ==", "dependencies": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-module-transforms": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1320,12 +1265,12 @@ } }, "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz", - "integrity": "sha512-j3Jw+n5PvpmhRR+mrgIh04puSANCk/T/UA3m3P1MjJkhlK906+ApHhDIqBQDdOgL/r1UYpz4GNclTXxyZrYGSw==", - "dev": true, + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.19.1.tgz", + "integrity": "sha512-oWk9l9WItWBQYS4FgXD4Uyy5kq898lvkXpXQxoJEY1RnvPk4R/Dvu2ebXU9q8lP+rlMwUQTFf2Ok6d78ODa0kw==", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.19.0", + "@babel/helper-plugin-utils": "^7.19.0" }, "engines": { "node": ">=6.9.0" @@ -1335,12 +1280,11 @@ } }, "node_modules/@babel/plugin-transform-new-target": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.7.tgz", - "integrity": "sha512-xiLDzWNMfKoGOpc6t3U+etCE2yRnn3SM09BXqWPIZOBpL2gvVrBWUKnsJx0K/ADi5F5YC5f8APFfWrz25TdlGg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz", + "integrity": "sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1350,13 +1294,12 @@ } }, "node_modules/@babel/plugin-transform-object-super": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz", - "integrity": "sha512-14J1feiQVWaGvRxj2WjyMuXS2jsBkgB3MdSN5HuC2G5nRspa5RK9COcs82Pwy5BuGcjb+fYaUj94mYcOj7rCvw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz", + "integrity": "sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/helper-replace-supers": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1366,12 +1309,11 @@ } }, "node_modules/@babel/plugin-transform-parameters": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.7.tgz", - "integrity": "sha512-AT3MufQ7zZEhU2hwOA11axBnExW0Lszu4RL/tAlUJBuNoRak+wehQW8h6KcXOcgjY42fHtDxswuMhMjFEuv/aw==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.20.1.tgz", + "integrity": "sha512-nDvKLrAvl+kf6BOy1UJ3MGwzzfTMgppxwiD2Jb4LO3xjYyZq30oQzDNJbCQpMdG9+j2IXHoiMrw5Cm/L6ZoxXQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.19.0" }, "engines": { "node": ">=6.9.0" @@ -1381,12 +1323,11 @@ } }, "node_modules/@babel/plugin-transform-property-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.7.tgz", - "integrity": "sha512-z4FGr9NMGdoIl1RqavCqGG+ZuYjfZ/hkCIeuH6Do7tXmSm0ls11nYVSJqFEUOSJbDab5wC6lRE/w6YjVcr6Hqw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz", + "integrity": "sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1396,12 +1337,12 @@ } }, "node_modules/@babel/plugin-transform-regenerator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.16.7.tgz", - "integrity": "sha512-mF7jOgGYCkSJagJ6XCujSQg+6xC1M77/03K2oBmVJWoFGNUtnVJO4WHKJk3dnPC8HCcj4xBQP1Egm8DWh3Pb3Q==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.18.6.tgz", + "integrity": "sha512-poqRI2+qiSdeldcz4wTSTXBRryoq3Gc70ye7m7UD5Ww0nE29IXqMl6r7Nd15WBgRd74vloEMlShtH6CKxVzfmQ==", "dependencies": { - "regenerator-transform": "^0.14.2" + "@babel/helper-plugin-utils": "^7.18.6", + "regenerator-transform": "^0.15.0" }, "engines": { "node": ">=6.9.0" @@ -1411,12 +1352,30 @@ } }, "node_modules/@babel/plugin-transform-reserved-words": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.7.tgz", - "integrity": "sha512-KQzzDnZ9hWQBjwi5lpY5v9shmm6IVG0U9pB18zvMu2i4H90xpT4gmqwPYsn8rObiadYe2M0gmgsiOIF5A/2rtg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz", + "integrity": "sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-runtime": { + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.19.6.tgz", + "integrity": "sha512-PRH37lz4JU156lYFW1p8OxE5i7d6Sl/zV58ooyr+q1J1lnQPyg5tIiXlIwNVhJaY4W3TmOtdc8jqdXQcB1v5Yw==", + "dependencies": { + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-plugin-utils": "^7.19.0", + "babel-plugin-polyfill-corejs2": "^0.3.3", + "babel-plugin-polyfill-corejs3": "^0.6.0", + "babel-plugin-polyfill-regenerator": "^0.4.1", + "semver": "^6.3.0" }, "engines": { "node": ">=6.9.0" @@ -1426,12 +1385,11 @@ } }, "node_modules/@babel/plugin-transform-shorthand-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", - "integrity": "sha512-hah2+FEnoRoATdIb05IOXf+4GzXYTq75TVhIn1PewihbpyrNWUt2JbudKQOETWw6QpLe+AIUpJ5MVLYTQbeeUg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz", + "integrity": "sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1441,13 +1399,12 @@ } }, "node_modules/@babel/plugin-transform-spread": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz", - "integrity": "sha512-+pjJpgAngb53L0iaA5gU/1MLXJIfXcYepLgXB3esVRf4fqmj8f2cxM3/FKaHsZms08hFQJkFccEWuIpm429TXg==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.19.0.tgz", + "integrity": "sha512-RsuMk7j6n+r752EtzyScnWkQyuJdli6LdO5Klv8Yx0OfPVTcQkIUfS8clx5e9yHXzlnhOZF3CbQ8C2uP5j074w==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0" + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1457,12 +1414,11 @@ } }, "node_modules/@babel/plugin-transform-sticky-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.7.tgz", - "integrity": "sha512-NJa0Bd/87QV5NZZzTuZG5BPJjLYadeSZ9fO6oOUoL4iQx+9EEuw/eEM92SrsT19Yc2jgB1u1hsjqDtH02c3Drw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz", + "integrity": "sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1472,12 +1428,11 @@ } }, "node_modules/@babel/plugin-transform-template-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.7.tgz", - "integrity": "sha512-VwbkDDUeenlIjmfNeDX/V0aWrQH2QiVyJtwymVQSzItFDTpxfyJh3EVaQiS0rIN/CqbLGr0VcGmuwyTdZtdIsA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz", + "integrity": "sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1487,12 +1442,11 @@ } }, "node_modules/@babel/plugin-transform-typeof-symbol": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.7.tgz", - "integrity": "sha512-p2rOixCKRJzpg9JB4gjnG4gjWkWa89ZoYUnl9snJ1cWIcTH/hvxZqfO+WjG6T8DRBpctEol5jw1O5rA8gkCokQ==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz", + "integrity": "sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1502,12 +1456,11 @@ } }, "node_modules/@babel/plugin-transform-unicode-escapes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.7.tgz", - "integrity": "sha512-TAV5IGahIz3yZ9/Hfv35TV2xEm+kaBDaZQCn2S/hG9/CZ0DktxJv9eKfPc7yYCvOYR4JGx1h8C+jcSOvgaaI/Q==", - "dev": true, + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz", + "integrity": "sha512-kKAdAI+YzPgGY/ftStBFXTI1LZFju38rYThnfMykS+IXy8BVx+res7s2fxf1l8I35DV2T97ezo6+SGrXz6B3iQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" }, "engines": { "node": ">=6.9.0" @@ -1517,13 +1470,12 @@ } }, "node_modules/@babel/plugin-transform-unicode-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.7.tgz", - "integrity": "sha512-oC5tYYKw56HO75KZVLQ+R/Nl3Hro9kf8iG0hXoaHP7tjAyCpvqBiSNe6vGrZni1Z6MggmUOC6A7VP7AVmw225Q==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz", + "integrity": "sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA==", "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" }, "engines": { "node": ">=6.9.0" @@ -1533,37 +1485,37 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.11.tgz", - "integrity": "sha512-qcmWG8R7ZW6WBRPZK//y+E3Cli151B20W1Rv7ln27vuPaXU/8TKms6jFdiJtF7UDTxcrb7mZd88tAeK9LjdT8g==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.16.8", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-option": "^7.16.7", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.7", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-async-generator-functions": "^7.16.8", - "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-class-static-block": "^7.16.7", - "@babel/plugin-proposal-dynamic-import": "^7.16.7", - "@babel/plugin-proposal-export-namespace-from": "^7.16.7", - "@babel/plugin-proposal-json-strings": "^7.16.7", - "@babel/plugin-proposal-logical-assignment-operators": "^7.16.7", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", - "@babel/plugin-proposal-numeric-separator": "^7.16.7", - "@babel/plugin-proposal-object-rest-spread": "^7.16.7", - "@babel/plugin-proposal-optional-catch-binding": "^7.16.7", - "@babel/plugin-proposal-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-private-methods": "^7.16.11", - "@babel/plugin-proposal-private-property-in-object": "^7.16.7", - "@babel/plugin-proposal-unicode-property-regex": "^7.16.7", + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.19.4.tgz", + "integrity": "sha512-5QVOTXUdqTCjQuh2GGtdd7YEhoRXBMVGROAtsBeLGIbIz3obCBIfRMT1I3ZKkMgNzwkyCkftDXSSkHxnfVf4qg==", + "dependencies": { + "@babel/compat-data": "^7.19.4", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-validator-option": "^7.18.6", + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-async-generator-functions": "^7.19.1", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-class-static-block": "^7.18.6", + "@babel/plugin-proposal-dynamic-import": "^7.18.6", + "@babel/plugin-proposal-export-namespace-from": "^7.18.9", + "@babel/plugin-proposal-json-strings": "^7.18.6", + "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", + "@babel/plugin-proposal-numeric-separator": "^7.18.6", + "@babel/plugin-proposal-object-rest-spread": "^7.19.4", + "@babel/plugin-proposal-optional-catch-binding": "^7.18.6", + "@babel/plugin-proposal-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-private-methods": "^7.18.6", + "@babel/plugin-proposal-private-property-in-object": "^7.18.6", + "@babel/plugin-proposal-unicode-property-regex": "^7.18.6", "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-class-properties": "^7.12.13", "@babel/plugin-syntax-class-static-block": "^7.14.5", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-import-assertions": "^7.18.6", "@babel/plugin-syntax-json-strings": "^7.8.3", "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", @@ -1573,44 +1525,44 @@ "@babel/plugin-syntax-optional-chaining": "^7.8.3", "@babel/plugin-syntax-private-property-in-object": "^7.14.5", "@babel/plugin-syntax-top-level-await": "^7.14.5", - "@babel/plugin-transform-arrow-functions": "^7.16.7", - "@babel/plugin-transform-async-to-generator": "^7.16.8", - "@babel/plugin-transform-block-scoped-functions": "^7.16.7", - "@babel/plugin-transform-block-scoping": "^7.16.7", - "@babel/plugin-transform-classes": "^7.16.7", - "@babel/plugin-transform-computed-properties": "^7.16.7", - "@babel/plugin-transform-destructuring": "^7.16.7", - "@babel/plugin-transform-dotall-regex": "^7.16.7", - "@babel/plugin-transform-duplicate-keys": "^7.16.7", - "@babel/plugin-transform-exponentiation-operator": "^7.16.7", - "@babel/plugin-transform-for-of": "^7.16.7", - "@babel/plugin-transform-function-name": "^7.16.7", - "@babel/plugin-transform-literals": "^7.16.7", - "@babel/plugin-transform-member-expression-literals": "^7.16.7", - "@babel/plugin-transform-modules-amd": "^7.16.7", - "@babel/plugin-transform-modules-commonjs": "^7.16.8", - "@babel/plugin-transform-modules-systemjs": "^7.16.7", - "@babel/plugin-transform-modules-umd": "^7.16.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.8", - "@babel/plugin-transform-new-target": "^7.16.7", - "@babel/plugin-transform-object-super": "^7.16.7", - "@babel/plugin-transform-parameters": "^7.16.7", - "@babel/plugin-transform-property-literals": "^7.16.7", - "@babel/plugin-transform-regenerator": "^7.16.7", - "@babel/plugin-transform-reserved-words": "^7.16.7", - "@babel/plugin-transform-shorthand-properties": "^7.16.7", - "@babel/plugin-transform-spread": "^7.16.7", - "@babel/plugin-transform-sticky-regex": "^7.16.7", - "@babel/plugin-transform-template-literals": "^7.16.7", - "@babel/plugin-transform-typeof-symbol": "^7.16.7", - "@babel/plugin-transform-unicode-escapes": "^7.16.7", - "@babel/plugin-transform-unicode-regex": "^7.16.7", + "@babel/plugin-transform-arrow-functions": "^7.18.6", + "@babel/plugin-transform-async-to-generator": "^7.18.6", + "@babel/plugin-transform-block-scoped-functions": "^7.18.6", + "@babel/plugin-transform-block-scoping": "^7.19.4", + "@babel/plugin-transform-classes": "^7.19.0", + "@babel/plugin-transform-computed-properties": "^7.18.9", + "@babel/plugin-transform-destructuring": "^7.19.4", + "@babel/plugin-transform-dotall-regex": "^7.18.6", + "@babel/plugin-transform-duplicate-keys": "^7.18.9", + "@babel/plugin-transform-exponentiation-operator": "^7.18.6", + "@babel/plugin-transform-for-of": "^7.18.8", + "@babel/plugin-transform-function-name": "^7.18.9", + "@babel/plugin-transform-literals": "^7.18.9", + "@babel/plugin-transform-member-expression-literals": "^7.18.6", + "@babel/plugin-transform-modules-amd": "^7.18.6", + "@babel/plugin-transform-modules-commonjs": "^7.18.6", + "@babel/plugin-transform-modules-systemjs": "^7.19.0", + "@babel/plugin-transform-modules-umd": "^7.18.6", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.19.1", + "@babel/plugin-transform-new-target": "^7.18.6", + "@babel/plugin-transform-object-super": "^7.18.6", + "@babel/plugin-transform-parameters": "^7.18.8", + "@babel/plugin-transform-property-literals": "^7.18.6", + "@babel/plugin-transform-regenerator": "^7.18.6", + "@babel/plugin-transform-reserved-words": "^7.18.6", + "@babel/plugin-transform-shorthand-properties": "^7.18.6", + "@babel/plugin-transform-spread": "^7.19.0", + "@babel/plugin-transform-sticky-regex": "^7.18.6", + "@babel/plugin-transform-template-literals": "^7.18.9", + "@babel/plugin-transform-typeof-symbol": "^7.18.9", + "@babel/plugin-transform-unicode-escapes": "^7.18.10", + "@babel/plugin-transform-unicode-regex": "^7.18.6", "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.16.8", - "babel-plugin-polyfill-corejs2": "^0.3.0", - "babel-plugin-polyfill-corejs3": "^0.5.0", - "babel-plugin-polyfill-regenerator": "^0.3.0", - "core-js-compat": "^3.20.2", + "@babel/types": "^7.19.4", + "babel-plugin-polyfill-corejs2": "^0.3.3", + "babel-plugin-polyfill-corejs3": "^0.6.0", + "babel-plugin-polyfill-regenerator": "^0.4.1", + "core-js-compat": "^3.25.1", "semver": "^6.3.0" }, "engines": { @@ -1624,7 +1576,6 @@ "version": "0.1.5", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz", "integrity": "sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==", - "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", @@ -1637,51 +1588,55 @@ } }, "node_modules/@babel/runtime": { - "version": "7.17.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.2.tgz", - "integrity": "sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.1.tgz", + "integrity": "sha512-mrzLkl6U9YLF8qpqI7TB82PESyEGjm/0Ly91jG575eVxMMlb8fYfOXFZIJ8XfLrJZQbm7dlKry2bJmXBUEkdFg==", "dependencies": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.13.10" }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/runtime/node_modules/regenerator-runtime": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "dev": true + "node_modules/@babel/runtime-corejs3": { + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.1.tgz", + "integrity": "sha512-CGulbEDcg/ND1Im7fUNRZdGXmX2MTWVVZacQi/6DiKE5HNwZ3aVTm5PV4lO8HHz0B2h8WQyvKKjbX5XgTtydsg==", + "dev": true, + "dependencies": { + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.10" + }, + "engines": { + "node": ">=6.9.0" + } }, "node_modules/@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", + "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.18.10", + "@babel/types": "^7.18.10" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.3.tgz", - "integrity": "sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.3", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.3", - "@babel/types": "^7.17.0", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.1.tgz", + "integrity": "sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA==", + "dependencies": { + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.20.1", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.20.1", + "@babel/types": "^7.20.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1690,12 +1645,12 @@ } }, "node_modules/@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.0.tgz", + "integrity": "sha512-Jlgt3H0TajCW164wkTOTzHkZb075tMQMULzrLUoUeKmO7eFL96GgDxf7/Axhc5CAuKE3KFyVW1p6ysKsi2oXAg==", "dependencies": { - "@babel/helper-validator-identifier": "^7.16.7", + "@babel/helper-string-parser": "^7.19.4", + "@babel/helper-validator-identifier": "^7.19.1", "to-fast-properties": "^2.0.0" }, "engines": { @@ -1748,9 +1703,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1859,7 +1814,7 @@ "node_modules/@gulp-sourcemaps/map-sources": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", - "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", + "integrity": "sha512-o/EatdaGt8+x2qpb0vFLC/2Gug/xYPRXb6a+ET1wGYKozKN3krDWC/zZFZAtrzxJHuDL12mwdfEFKcKMNvc55A==", "dev": true, "dependencies": { "normalize-path": "^2.0.1", @@ -1872,7 +1827,7 @@ "node_modules/@gulp-sourcemaps/map-sources/node_modules/normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "dependencies": { "remove-trailing-separator": "^1.0.1" @@ -1891,6 +1846,33 @@ "xtend": "~4.0.1" } }, + "node_modules/@hapi/boom": { + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/@hapi/boom/-/boom-9.1.4.tgz", + "integrity": "sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw==", + "dev": true, + "dependencies": { + "@hapi/hoek": "9.x.x" + } + }, + "node_modules/@hapi/cryptiles": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@hapi/cryptiles/-/cryptiles-5.1.0.tgz", + "integrity": "sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA==", + "dev": true, + "dependencies": { + "@hapi/boom": "9.x.x" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@hapi/hoek": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", + "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==", + "dev": true + }, "node_modules/@humanwhocodes/config-array": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", @@ -1911,13 +1893,20 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, - "node_modules/@hutson/parse-repository-url": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz", - "integrity": "sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==", + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, "engines": { - "node": ">=6.9.0" + "node": ">=8" } }, "node_modules/@istanbuljs/schema": { @@ -1930,19 +1919,19 @@ } }, "node_modules/@jest/types": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.5.1.tgz", - "integrity": "sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", + "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", "dev": true, "dependencies": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^16.0.0", + "@types/yargs": "^15.0.0", "chalk": "^4.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/@jest/types/node_modules/ansi-styles": { @@ -1994,6 +1983,15 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/@jest/types/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@jest/types/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -2006,42 +2004,79 @@ "node": ">=8" } }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/source-map/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, "engines": { "node": ">=6.0.0" } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", - "dev": true + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", - "dev": true, + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", + "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" } }, - "node_modules/@jsdevtools/coverage-istanbul-loader": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jsdevtools/coverage-istanbul-loader/-/coverage-istanbul-loader-3.0.5.tgz", - "integrity": "sha512-EUCPEkaRPvmHjWAAZkWMT7JDzpw7FKB00WTISaiXsbNOd5hCHg77XLA8sLYLFDo1zepYLo2w7GstN8YBqRXZfA==", + "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { + "version": "5.1.1-v1", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", + "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", "dev": true, "dependencies": { - "convert-source-map": "^1.7.0", - "istanbul-lib-instrument": "^4.0.3", - "loader-utils": "^2.0.0", - "merge-source-map": "^1.1.0", - "schema-utils": "^2.7.0" + "eslint-scope": "5.1.1" } }, "node_modules/@polka/url": { @@ -2092,19 +2127,16 @@ } }, "node_modules/@sinonjs/text-encoding": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", - "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz", + "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, - "node_modules/@socket.io/base64-arraybuffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", - "integrity": "sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ==", - "dev": true, - "engines": { - "node": ">= 0.6.0" - } + "node_modules/@socket.io/component-emitter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", + "dev": true }, "node_modules/@szmarczak/http-timer": { "version": "4.0.6", @@ -2119,9 +2151,9 @@ } }, "node_modules/@types/aria-query": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.0.tgz", - "integrity": "sha512-P+dkdFu0n08PDIvw+9nT9ByQnd+Udc8DaWPb9HKfaPwCvWvQpC5XaMRx2xLWECm9x1VKNps6vEAlirjA6+uNrQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz", + "integrity": "sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==", "dev": true }, "node_modules/@types/cacheable-request": { @@ -2136,12 +2168,6 @@ "@types/responselike": "*" } }, - "node_modules/@types/component-emitter": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.11.tgz", - "integrity": "sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ==", - "dev": true - }, "node_modules/@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", @@ -2149,10 +2175,22 @@ "dev": true }, "node_modules/@types/cors": { - "version": "2.8.12", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", - "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==", - "dev": true + "version": "2.8.13", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz", + "integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/debug": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", + "integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==", + "dev": true, + "dependencies": { + "@types/ms": "*" + } }, "node_modules/@types/diff": { "version": "5.0.2", @@ -2167,15 +2205,15 @@ "dev": true }, "node_modules/@types/ejs": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.0.tgz", - "integrity": "sha512-DCg+Ka+uDQ31lJ/UtEXVlaeV3d6t81gifaVWKJy4MYVVgvJttyX/viREy+If7fz+tK/gVxTGMtyrFPnm4gjrVA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.1.tgz", + "integrity": "sha512-RQul5wEfY7BjWm0sYY86cmUN/pcXWGyVxWX93DFFJvcrxax5zKlieLwA3T77xJGwNcZW0YW6CYG70p1m8xPFmA==", "dev": true }, "node_modules/@types/eslint": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.1.tgz", - "integrity": "sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA==", + "version": "8.4.9", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.9.tgz", + "integrity": "sha512-jFCSo4wJzlHQLCpceUhUnXdrPuCNOjGFMQ8Eg6JXxlz3QaCKOb7eGi2cephQdM4XTYsNej69P9JDJ1zqNIbncQ==", "dev": true, "dependencies": { "@types/estree": "*", @@ -2183,9 +2221,9 @@ } }, "node_modules/@types/eslint-scope": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.3.tgz", - "integrity": "sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g==", + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", + "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", "dev": true, "dependencies": { "@types/eslint": "*", @@ -2204,6 +2242,12 @@ "integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==", "dev": true }, + "node_modules/@types/extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/extend/-/extend-3.0.1.tgz", + "integrity": "sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==", + "dev": true + }, "node_modules/@types/fibers": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@types/fibers/-/fibers-3.1.1.tgz", @@ -2219,6 +2263,21 @@ "@types/node": "*" } }, + "node_modules/@types/github-slugger": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/github-slugger/-/github-slugger-1.3.0.tgz", + "integrity": "sha512-J/rMZa7RqiH/rT29TEVZO4nBoDP9XJOjnbbIofg7GQKs4JIduEO3WLpte+6WeUz/TcrXKlY+bM7FYrp8yFB+3g==", + "dev": true + }, + "node_modules/@types/hast": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz", + "integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==", + "dev": true, + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/http-cache-semantics": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", @@ -2226,13 +2285,13 @@ "dev": true }, "node_modules/@types/inquirer": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-8.2.0.tgz", - "integrity": "sha512-BNoMetRf3gmkpAlV5we+kxyZTle7YibdOntIZbU5pyIfMdcwy784KfeZDAcuyMznkh5OLa17RVXZOGA5LTlkgQ==", + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-HhxyLejTHMfohAuhRun4csWigAMjXTmRyiJTU1Y/I1xmggikFMkOUoMQRlFm+zQcPEGHSs3io/0FAmNZf8EymQ==", "dev": true, "dependencies": { "@types/through": "*", - "rxjs": "^7.2.0" + "rxjs": "^6.4.0" } }, "node_modules/@types/istanbul-lib-coverage": { @@ -2260,54 +2319,55 @@ } }, "node_modules/@types/json-schema": { - "version": "7.0.9", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, "node_modules/@types/keyv": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.3.tgz", - "integrity": "sha512-FXCJgyyN3ivVgRoml4h94G/p3kY+u/B86La+QptcqJaWtBWtmc6TtkNfS40n9bIvyLteHh7zXOtgbobORKPbDg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-4.2.0.tgz", + "integrity": "sha512-xoBtGl5R9jeKUhc8ZqeYaRDx04qqJ10yhhXYGmJ4Jr8qKpvMsDQQrNUvF/wUJ4klOtmJeJM+p2Xo3zp9uaC3tw==", + "deprecated": "This is a stub types definition. keyv provides its own type definitions, so you do not need this installed.", "dev": true, "dependencies": { - "@types/node": "*" + "keyv": "*" } }, "node_modules/@types/lodash": { - "version": "4.14.179", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.179.tgz", - "integrity": "sha512-uwc1x90yCKqGcIOAT6DwOSuxnrAbpkdPsUOZtwrXb4D/6wZs+6qG7QnIawDuZWg0sWpxl+ltIKCaLoMlna678w==", + "version": "4.14.187", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.187.tgz", + "integrity": "sha512-MrO/xLXCaUgZy3y96C/iOsaIqZSeupyTImKClHunL5GrmaiII2VwvWmLBu2hwa0Kp0sV19CsyjtrTc/Fx8rg/A==", "dev": true }, "node_modules/@types/lodash.flattendeep": { - "version": "4.4.6", - "resolved": "https://registry.npmjs.org/@types/lodash.flattendeep/-/lodash.flattendeep-4.4.6.tgz", - "integrity": "sha512-uLm2MaRVlqJSGsMK0RZpP5T3KqReq+9WbYDHCUhBhp98v56hMG/Yht52bsoTSui9xz2mUvQ9NfG3LrNGDL92Ng==", + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/lodash.flattendeep/-/lodash.flattendeep-4.4.7.tgz", + "integrity": "sha512-1h6GW/AeZw/Wej6uxrqgmdTDZX1yFS39lRsXYkg+3kWvOWWrlGCI6H7lXxlUHOzxDT4QeYGmgPpQ3BX9XevzOg==", "dev": true, "dependencies": { "@types/lodash": "*" } }, "node_modules/@types/lodash.pickby": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/@types/lodash.pickby/-/lodash.pickby-4.6.6.tgz", - "integrity": "sha512-NFa13XxlMd9eFi0UFZFWIztpMpXhozbijrx3Yb1viYZphT7jyopIFVoIRF4eYMjruWNEG1rnyrRmg/8ej9T8Iw==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/@types/lodash.pickby/-/lodash.pickby-4.6.7.tgz", + "integrity": "sha512-4ebXRusuLflfscbD0PUX4eVknDHD9Yf+uMtBIvA/hrnTqeAzbuHuDjvnYriLjUrI9YrhCPVKUf4wkRSXJQ6gig==", "dev": true, "dependencies": { "@types/lodash": "*" } }, "node_modules/@types/lodash.union": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/@types/lodash.union/-/lodash.union-4.6.6.tgz", - "integrity": "sha512-Wu0ZEVNcyCz8eAn6TlUbYWZoGbH9E+iOHxAZbwUoCEXdUiy6qpcz5o44mMXViM4vlPLLCPlkAubEP1gokoSZaw==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/@types/lodash.union/-/lodash.union-4.6.7.tgz", + "integrity": "sha512-6HXM6tsnHJzKgJE0gA/LhTGf/7AbjUk759WZ1MziVm+OBNAATHhdgj+a3KVE8g76GCLAnN4ZEQQG1EGgtBIABA==", "dev": true, "dependencies": { "@types/lodash": "*" @@ -2322,22 +2382,22 @@ "@types/unist": "*" } }, - "node_modules/@types/minimist": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", - "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", + "node_modules/@types/mocha": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", + "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", "dev": true }, - "node_modules/@types/mocha": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", - "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==", + "node_modules/@types/ms": { + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", + "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==", "dev": true }, "node_modules/@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", + "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -2353,18 +2413,18 @@ "dev": true }, "node_modules/@types/puppeteer": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-5.4.5.tgz", - "integrity": "sha512-lxCjpDEY+DZ66+W3x5Af4oHnEmUXt0HuaRzkBGE2UZiZEp/V1d3StpLPlmNVu/ea091bdNmVPl44lu8Wy/0ZCA==", + "version": "5.4.7", + "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-5.4.7.tgz", + "integrity": "sha512-JdGWZZYL0vKapXF4oQTC5hLVNfOgdPrqeZ1BiQnGk5cB7HeE91EWUiTdVSdQPobRN8rIcdffjiOgCYJ/S8QrnQ==", "dev": true, "dependencies": { "@types/node": "*" } }, "node_modules/@types/recursive-readdir": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.0.tgz", - "integrity": "sha512-HGk753KRu2N4mWduovY4BLjYq4jTOL29gV2OfGdGxHcPSWGFkC5RRIdk+VTs5XmYd7MVAD+JwKrcb5+5Y7FOCg==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.1.tgz", + "integrity": "sha512-Xd+Ptc4/F2ueInqy5yK2FI5FxtwwbX2+VZpcg+9oYsFJVen8qQKGapCr+Bi5wQtHU1cTXT8s+07lo/nKPgu8Gg==", "dev": true, "dependencies": { "@types/node": "*" @@ -2444,9 +2504,9 @@ "dev": true }, "node_modules/@types/yargs": { - "version": "16.0.4", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", - "integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==", + "version": "15.0.14", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.14.tgz", + "integrity": "sha512-yEJzHoxf6SyQGhBhIYGXQDSCkJjB6HohDShto7m8vaKg9Yp0Yn8+71J9eakh2bnPg6BfsH9PRMhiRTZnd4eXGQ==", "dev": true, "dependencies": { "@types/yargs-parser": "*" @@ -2459,9 +2519,9 @@ "dev": true }, "node_modules/@types/yauzl": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz", - "integrity": "sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==", "dev": true, "optional": true, "dependencies": { @@ -2474,15 +2534,64 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "node_modules/@videojs/http-streaming": { + "version": "2.14.3", + "resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-2.14.3.tgz", + "integrity": "sha512-2tFwxCaNbcEZzQugWf8EERwNMyNtspfHnvxRGRABQs09W/5SqmkWFuGWfUAm4wQKlXGfdPyAJ1338ASl459xAA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "3.0.5", + "aes-decrypter": "3.1.3", + "global": "^4.4.0", + "m3u8-parser": "4.7.1", + "mpd-parser": "0.21.1", + "mux.js": "6.0.1", + "video.js": "^6 || ^7" + }, + "engines": { + "node": ">=8", + "npm": ">=5" + }, + "peerDependencies": { + "video.js": "^6 || ^7" + } + }, + "node_modules/@videojs/vhs-utils": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@videojs/vhs-utils/-/vhs-utils-3.0.5.tgz", + "integrity": "sha512-PKVgdo8/GReqdx512F+ombhS+Bzogiofy1LgAj4tN8PfdBx3HSS7V5WfJotKTqtOWGwVfSWsrYN/t09/DSryrw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "global": "^4.4.0", + "url-toolkit": "^2.2.1" + }, + "engines": { + "node": ">=8", + "npm": ">=5" + } + }, + "node_modules/@videojs/xhr": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@videojs/xhr/-/xhr-2.6.0.tgz", + "integrity": "sha512-7J361GiN1tXpm+gd0xz2QWr3xNWBE+rytvo8J3KuggFaLg+U37gZQ2BuPLcnkfGffy2e+ozY70RHC8jt7zjA6Q==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.5.5", + "global": "~4.4.0", + "is-function": "^1.0.1" + } + }, "node_modules/@vue/compiler-core": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.31.tgz", - "integrity": "sha512-aKno00qoA4o+V/kR6i/pE+aP+esng5siNAVQ422TkBNM6qA4veXiZbSe8OTXHXquEi/f6Akc+nLfB4JGfe4/WQ==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.41.tgz", + "integrity": "sha512-oA4mH6SA78DT+96/nsi4p9DX97PHcNROxs51lYk7gb9Z4BPKQ3Mh+BLn6CQZBw857Iuhu28BfMSRHAlPvD4vlw==", "dev": true, "optional": true, "dependencies": { "@babel/parser": "^7.16.4", - "@vue/shared": "3.2.31", + "@vue/shared": "3.2.41", "estree-walker": "^2.0.2", "source-map": "^0.6.1" } @@ -2498,29 +2607,29 @@ } }, "node_modules/@vue/compiler-dom": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.31.tgz", - "integrity": "sha512-60zIlFfzIDf3u91cqfqy9KhCKIJgPeqxgveH2L+87RcGU/alT6BRrk5JtUso0OibH3O7NXuNOQ0cDc9beT0wrg==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.41.tgz", + "integrity": "sha512-xe5TbbIsonjENxJsYRbDJvthzqxLNk+tb3d/c47zgREDa/PCp6/Y4gC/skM4H6PIuX5DAxm7fFJdbjjUH2QTMw==", "dev": true, "optional": true, "dependencies": { - "@vue/compiler-core": "3.2.31", - "@vue/shared": "3.2.31" + "@vue/compiler-core": "3.2.41", + "@vue/shared": "3.2.41" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.31.tgz", - "integrity": "sha512-748adc9msSPGzXgibHiO6T7RWgfnDcVQD+VVwYgSsyyY8Ans64tALHZANrKtOzvkwznV/F4H7OAod/jIlp/dkQ==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.41.tgz", + "integrity": "sha512-+1P2m5kxOeaxVmJNXnBskAn3BenbTmbxBxWOtBq3mQTCokIreuMULFantBUclP0+KnzNCMOvcnKinqQZmiOF8w==", "dev": true, "optional": true, "dependencies": { "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.31", - "@vue/compiler-dom": "3.2.31", - "@vue/compiler-ssr": "3.2.31", - "@vue/reactivity-transform": "3.2.31", - "@vue/shared": "3.2.31", + "@vue/compiler-core": "3.2.41", + "@vue/compiler-dom": "3.2.41", + "@vue/compiler-ssr": "3.2.41", + "@vue/reactivity-transform": "3.2.41", + "@vue/shared": "3.2.41", "estree-walker": "^2.0.2", "magic-string": "^0.25.7", "postcss": "^8.1.10", @@ -2538,34 +2647,34 @@ } }, "node_modules/@vue/compiler-ssr": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.31.tgz", - "integrity": "sha512-mjN0rqig+A8TVDnsGPYJM5dpbjlXeHUm2oZHZwGyMYiGT/F4fhJf/cXy8QpjnLQK4Y9Et4GWzHn9PS8AHUnSkw==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.41.tgz", + "integrity": "sha512-Y5wPiNIiaMz/sps8+DmhaKfDm1xgj6GrH99z4gq2LQenfVQcYXmHIOBcs5qPwl7jaW3SUQWjkAPKMfQemEQZwQ==", "dev": true, "optional": true, "dependencies": { - "@vue/compiler-dom": "3.2.31", - "@vue/shared": "3.2.31" + "@vue/compiler-dom": "3.2.41", + "@vue/shared": "3.2.41" } }, "node_modules/@vue/reactivity-transform": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.2.31.tgz", - "integrity": "sha512-uS4l4z/W7wXdI+Va5pgVxBJ345wyGFKvpPYtdSgvfJfX/x2Ymm6ophQlXXB6acqGHtXuBqNyyO3zVp9b1r0MOA==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.2.41.tgz", + "integrity": "sha512-mK5+BNMsL4hHi+IR3Ft/ho6Za+L3FA5j8WvreJ7XzHrqkPq8jtF/SMo7tuc9gHjLDwKZX1nP1JQOKo9IEAn54A==", "dev": true, "optional": true, "dependencies": { "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.31", - "@vue/shared": "3.2.31", + "@vue/compiler-core": "3.2.41", + "@vue/shared": "3.2.41", "estree-walker": "^2.0.2", "magic-string": "^0.25.7" } }, "node_modules/@vue/shared": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.31.tgz", - "integrity": "sha512-ymN2pj6zEjiKJZbrf98UM2pfDd6F2H7ksKw7NDt/ZZ1fh5Ei39X5tABugtT03ZRlWd9imccoK0hE8hpjpU7irQ==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.41.tgz", + "integrity": "sha512-W9mfWLHmJhkfAmV+7gDjcHeAWALQtgGT3JErxULl0oz6R6+3ug91I7IErs93eCFhPCZPHBs4QJS7YWEV7A3sxw==", "dev": true, "optional": true }, @@ -2589,37 +2698,224 @@ "@wdio/cli": "^7.0.0" } }, - "node_modules/@wdio/cli": { + "node_modules/@wdio/browserstack-service/node_modules/@wdio/config": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.16.16.tgz", + "integrity": "sha512-K/ObPuo6Da2liz++OKOIfbdpFwI7UWiFcBylfJkCYbweuXCoW1aUqlKI6rmKPwCH9Uqr/RHWu6p8eo0zWe6xVA==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.16.0", + "@wdio/types": "7.16.14", + "deepmerge": "^4.0.0", + "glob": "^7.1.2" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/@wdio/protocols": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.16.7.tgz", + "integrity": "sha512-Wv40pNQcLiPzQ3o98Mv4A8T1EBQ6k4khglz/e2r16CTm+F3DDYh8eLMAsU5cgnmuwwDKX1EyOiFwieykBn5MCg==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/@wdio/repl": { + "version": "7.16.14", + "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.16.14.tgz", + "integrity": "sha512-Ezih0Y+lsGkKv3H3U56hdWgZiQGA3VaAYguSLd9+g1xbQq+zMKqSmfqECD9bAy+OgCCiVTRstES6lHZxJVPhAg==", + "dev": true, + "dependencies": { + "@wdio/utils": "7.16.14" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/@wdio/utils": { + "version": "7.16.14", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.16.14.tgz", + "integrity": "sha512-wwin8nVpIlhmXJkq6GJw9aDDzgLOJKgXTcEua0T2sdXjoW78u5Ly/GZrFXTjMGhacFvoZfitTrjyfyy4CxMVvw==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.16.0", + "@wdio/types": "7.16.14", + "p-iteration": "^1.1.8" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/devtools": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.16.16.tgz", + "integrity": "sha512-M0kzkuSgfEhpqIis3gdtWsNjn/HQ+vRAmEzDnbYx/7FfjFxhSv1d+rOOT20pvd60soItMYpsOova1igACEGkGQ==", + "dev": true, + "dependencies": { + "@types/node": "^17.0.4", + "@types/ua-parser-js": "^0.7.33", + "@wdio/config": "7.16.16", + "@wdio/logger": "7.16.0", + "@wdio/protocols": "7.16.7", + "@wdio/types": "7.16.14", + "@wdio/utils": "7.16.14", + "chrome-launcher": "^0.15.0", + "edge-paths": "^2.1.0", + "puppeteer-core": "^13.1.3", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^1.0.1", + "uuid": "^8.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/devtools-protocol": { + "version": "0.0.973690", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.973690.tgz", + "integrity": "sha512-myh3hSFp0YWa2GED11PmbLhV4dv9RdO7YUz27XJrbQLnP5bMbZL6dfOOILTHO57yH0kX5GfuOZBsg/4NamfPvQ==", + "dev": true + }, + "node_modules/@wdio/browserstack-service/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/ua-parser-js": { + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.33.tgz", + "integrity": "sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ], + "engines": { + "node": "*" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/webdriver": { "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/cli/-/cli-7.16.16.tgz", - "integrity": "sha512-Wz/e5zm1UNHB9RAIsJIM7ioDzVllUwTvhVWOrI7HR/53GmO/cIvAVjpnlglizJNgK8WlbnM/cKNVIXxqxrnFmw==", + "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.16.16.tgz", + "integrity": "sha512-x8UoG9k/P8KDrfSh1pOyNevt9tns3zexoMxp9cKnyA/7HYSErhZYTLGlgxscAXLtQG41cMH/Ba/oBmOx7Hgd8w==", + "dev": true, + "dependencies": { + "@types/node": "^17.0.4", + "@wdio/config": "7.16.16", + "@wdio/logger": "7.16.0", + "@wdio/protocols": "7.16.7", + "@wdio/types": "7.16.14", + "@wdio/utils": "7.16.14", + "got": "^11.0.2", + "ky": "^0.29.0", + "lodash.merge": "^4.6.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/browserstack-service/node_modules/webdriverio": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.16.16.tgz", + "integrity": "sha512-caPaEWyuD3Qoa7YkW4xCCQA4v9Pa9wmhFGPvNZh3ERtjMCNi8L/XXOdkekWNZmFh3tY0kFguBj7+fAwSY7HAGw==", + "dev": true, + "dependencies": { + "@types/aria-query": "^5.0.0", + "@types/node": "^17.0.4", + "@wdio/config": "7.16.16", + "@wdio/logger": "7.16.0", + "@wdio/protocols": "7.16.7", + "@wdio/repl": "7.16.14", + "@wdio/types": "7.16.14", + "@wdio/utils": "7.16.14", + "archiver": "^5.0.0", + "aria-query": "^5.0.0", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.16.16", + "devtools-protocol": "^0.0.973690", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^5.0.0", + "puppeteer-core": "^13.1.3", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.16.16" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/cli": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/cli/-/cli-7.5.7.tgz", + "integrity": "sha512-nOQJLskrY+UECDd3NxE7oBzb6cDA7e7x02YWQugOlOgnZ4a+PJmkFoSsO8C2uNCpdFngy5rJKGUo5vbtAHEF9Q==", "dev": true, "dependencies": { "@types/ejs": "^3.0.5", "@types/fs-extra": "^9.0.4", - "@types/inquirer": "^8.1.2", + "@types/inquirer": "^7.3.1", "@types/lodash.flattendeep": "^4.4.6", "@types/lodash.pickby": "^4.6.6", "@types/lodash.union": "^4.6.6", - "@types/node": "^17.0.4", "@types/recursive-readdir": "^2.2.0", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", "async-exit-hook": "^2.0.1", "chalk": "^4.0.0", "chokidar": "^3.0.0", "cli-spinners": "^2.1.0", "ejs": "^3.0.1", "fs-extra": "^10.0.0", - "inquirer": "8.1.5", + "inquirer": "^8.0.0", "lodash.flattendeep": "^4.4.0", "lodash.pickby": "^4.6.0", "lodash.union": "^4.6.0", "mkdirp": "^1.0.4", "recursive-readdir": "^2.2.2", - "webdriverio": "7.16.16", + "webdriverio": "7.5.7", "yargs": "^17.0.0", "yarn-install": "^1.0.0" }, @@ -2630,6 +2926,39 @@ "node": ">=12.0.0" } }, + "node_modules/@wdio/cli/node_modules/@types/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==", + "dev": true + }, + "node_modules/@wdio/cli/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/cli/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@wdio/cli/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -2645,6 +2974,19 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/@wdio/cli/node_modules/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.10.2", + "@babel/runtime-corejs3": "^7.10.2" + }, + "engines": { + "node": ">=6.0" + } + }, "node_modules/@wdio/cli/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2661,6 +3003,32 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/@wdio/cli/node_modules/chrome-launcher": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.4.tgz", + "integrity": "sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==", + "dev": true, + "dependencies": { + "@types/node": "*", + "escape-string-regexp": "^1.0.5", + "is-wsl": "^2.2.0", + "lighthouse-logger": "^1.0.0", + "mkdirp": "^0.5.3", + "rimraf": "^3.0.2" + } + }, + "node_modules/@wdio/cli/node_modules/chrome-launcher/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/@wdio/cli/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2679,6 +3047,72 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/@wdio/cli/node_modules/devtools": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.5.7.tgz", + "integrity": "sha512-+kqmvFbceElhYpN35yjm1T4Rz3VbH0QaqrNWKRpeyFp657Y5W0bm1s5FyMUeIv0aTNkAgWcETtqL+EG9X9uvjQ==", + "dev": true, + "dependencies": { + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "chrome-launcher": "^0.13.1", + "edge-paths": "^2.1.0", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^0.7.21", + "uuid": "^8.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/cli/node_modules/devtools-protocol": { + "version": "0.0.878340", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.878340.tgz", + "integrity": "sha512-W0q8Y02r1RNwfZtI4Jjh1/MZxRHyrIgy9FvElbJzQelZjmNH197H4mBQs7DZjlUUDA9s6Zz2jl+zUYFgLgEnzw==", + "dev": true + }, + "node_modules/@wdio/cli/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/cli/node_modules/puppeteer-core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-9.1.1.tgz", + "integrity": "sha512-zbedbitVIGhmgz0nt7eIdLsnaoVZSlNJfBivqm2w67T8LR2bU1dvnruDZ8nQO0zn++Iet7zHbAOdnuS5+H2E7A==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.869402", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.1.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "engines": { + "node": ">=10.18.1" + } + }, + "node_modules/@wdio/cli/node_modules/puppeteer-core/node_modules/devtools-protocol": { + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", + "dev": true + }, "node_modules/@wdio/cli/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -2691,13 +3125,82 @@ "node": ">=8" } }, + "node_modules/@wdio/cli/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@wdio/cli/node_modules/webdriverio": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.5.7.tgz", + "integrity": "sha512-TLluVPLo6Snn/dxEITvMz7ZuklN4qZOBddDuLb9LO3rhsfKDMNbnhcBk0SLdFsWny0aCuhWNpJ6co93702XC0A==", + "dev": true, + "dependencies": { + "@types/aria-query": "^4.2.1", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "archiver": "^5.0.0", + "aria-query": "^4.2.2", + "atob": "^2.1.2", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.5.7", + "devtools-protocol": "^0.0.878340", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^3.0.4", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.5.3" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/cli/node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/@wdio/cli/node_modules/yargs": { - "version": "17.3.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.1.tgz", - "integrity": "sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", "dev": true, "dependencies": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", @@ -2710,13 +3213,13 @@ } }, "node_modules/@wdio/concise-reporter": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/concise-reporter/-/concise-reporter-7.16.14.tgz", - "integrity": "sha512-CR+9+skJ3mXPIdRo0AnIJTJHOArrWdKlXTnyZ/DD6M9VrNk5aiTWQyphT/IeHV5+fxjHlMNIf/KgIhj1ewschQ==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/concise-reporter/-/concise-reporter-7.5.7.tgz", + "integrity": "sha512-964i7eQ4sboSla2bdR8714Er82QBgS6u39GmDFX8Izy9Ge38xaE75HuF5S7mnOWGzSojCWgqtwy5k7Rfg6GE3g==", "dev": true, "dependencies": { - "@wdio/reporter": "7.16.14", - "@wdio/types": "7.16.14", + "@wdio/reporter": "7.5.7", + "@wdio/types": "7.5.3", "chalk": "^4.0.0", "pretty-ms": "^7.0.0" }, @@ -2727,6 +3230,18 @@ "@wdio/cli": "^7.0.0" } }, + "node_modules/@wdio/concise-reporter/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@wdio/concise-reporter/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -2776,6 +3291,15 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/@wdio/concise-reporter/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/@wdio/concise-reporter/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -2789,13 +3313,13 @@ } }, "node_modules/@wdio/config": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.16.16.tgz", - "integrity": "sha512-K/ObPuo6Da2liz++OKOIfbdpFwI7UWiFcBylfJkCYbweuXCoW1aUqlKI6rmKPwCH9Uqr/RHWu6p8eo0zWe6xVA==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.5.3.tgz", + "integrity": "sha512-udvVizYoilOxuWj/BmoN6y7ZCd4wPdYNlSfWznrbCezAdaLZ4/pNDOO0WRWx2C4+q1wdkXZV/VuQPUGfL0lEHQ==", "dev": true, "dependencies": { - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", "deepmerge": "^4.0.0", "glob": "^7.1.2" }, @@ -2803,44 +3327,34 @@ "node": ">=12.0.0" } }, - "node_modules/@wdio/local-runner": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/local-runner/-/local-runner-7.16.16.tgz", - "integrity": "sha512-AJaOyM842PWgMffrrXyHJjouVseLHoiL5U1sw2VVproi3ORWHbltl1AMnreU/lrGu9L0CVKHYT1pxu5UbSOCxQ==", + "node_modules/@wdio/config/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", "dev": true, "dependencies": { - "@types/stream-buffers": "^3.0.3", - "@wdio/logger": "7.16.0", - "@wdio/repl": "7.16.14", - "@wdio/runner": "7.16.16", - "@wdio/types": "7.16.14", - "async-exit-hook": "^2.0.1", - "split2": "^4.0.0", - "stream-buffers": "^3.0.2" + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" }, "engines": { "node": ">=12.0.0" - }, - "peerDependencies": { - "@wdio/cli": "^7.0.0" } }, - "node_modules/@wdio/logger": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.16.0.tgz", - "integrity": "sha512-/6lOGb2Iow5eSsy7RJOl1kCwsP4eMlG+/QKro5zUJsuyNJSQXf2ejhpkzyKWLgQbHu83WX6cM1014AZuLkzoQg==", + "node_modules/@wdio/config/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", "dev": true, "dependencies": { - "chalk": "^4.0.0", - "loglevel": "^1.6.0", - "loglevel-plugin-prefix": "^0.8.4", - "strip-ansi": "^6.0.0" + "got": "^11.8.1" }, "engines": { "node": ">=12.0.0" } }, - "node_modules/@wdio/logger/node_modules/ansi-styles": { + "node_modules/@wdio/config/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", @@ -2855,7 +3369,7 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/@wdio/logger/node_modules/chalk": { + "node_modules/@wdio/config/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", @@ -2871,7 +3385,7 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@wdio/logger/node_modules/color-convert": { + "node_modules/@wdio/config/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", @@ -2883,13 +3397,22 @@ "node": ">=7.0.0" } }, - "node_modules/@wdio/logger/node_modules/color-name": { + "node_modules/@wdio/config/node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/@wdio/logger/node_modules/supports-color": { + "node_modules/@wdio/config/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/config/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", @@ -2901,24 +3424,56 @@ "node": ">=8" } }, - "node_modules/@wdio/mocha-framework": { - "version": "7.16.15", - "resolved": "https://registry.npmjs.org/@wdio/mocha-framework/-/mocha-framework-7.16.15.tgz", - "integrity": "sha512-XRya85/RYPZk4MZ7Cvl3oudTdrOo+RyO8b5Ff+dH8hD3GBCACaWgW9AjbsyhvbSTdUlF0gNLPdqOCsxV5XyM3w==", + "node_modules/@wdio/local-runner": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/local-runner/-/local-runner-7.5.7.tgz", + "integrity": "sha512-aYc0XUV+/e3cg8Fp+CWlC4FbwSSG3mKAv1iuy/+Hwzg2kJE+aa+Rf2p2BQYc7HPRtKNW0bM8o+aCImZLAiPM+A==", "dev": true, "dependencies": { - "@types/mocha": "^9.0.0", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", - "expect-webdriverio": "^3.0.0", - "mocha": "^9.0.0" + "@types/stream-buffers": "^3.0.3", + "@wdio/logger": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/runner": "7.5.7", + "@wdio/types": "7.5.3", + "async-exit-hook": "^2.0.1", + "split2": "^3.2.2", + "stream-buffers": "^3.0.2" }, "engines": { "node": ">=12.0.0" + }, + "peerDependencies": { + "@wdio/cli": "^7.0.0" } }, - "node_modules/@wdio/mocha-framework/node_modules/ansi-styles": { + "node_modules/@wdio/local-runner/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/local-runner/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/local-runner/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", @@ -2933,13 +3488,92 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/@wdio/mocha-framework/node_modules/argparse": { + "node_modules/@wdio/local-runner/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@wdio/local-runner/node_modules/color-convert": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@wdio/local-runner/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/@wdio/mocha-framework/node_modules/chalk": { + "node_modules/@wdio/local-runner/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/local-runner/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/logger": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.16.0.tgz", + "integrity": "sha512-/6lOGb2Iow5eSsy7RJOl1kCwsP4eMlG+/QKro5zUJsuyNJSQXf2ejhpkzyKWLgQbHu83WX6cM1014AZuLkzoQg==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/logger/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@wdio/logger/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", @@ -2955,7 +3589,34 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@wdio/mocha-framework/node_modules/chalk/node_modules/supports-color": { + "node_modules/@wdio/logger/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@wdio/logger/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@wdio/logger/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/logger/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", @@ -2967,6 +3628,128 @@ "node": ">=8" } }, + "node_modules/@wdio/mocha-framework": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/mocha-framework/-/mocha-framework-7.5.3.tgz", + "integrity": "sha512-96QCVWsiyZxEgOZP3oTq2B2T7zne5dCdehLa2n4q/BLjk96Rj0jifidJZfd/1+vdNPKX0gWWAzpy98Znn8MVMw==", + "dev": true, + "dependencies": { + "@types/mocha": "^8.0.0", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "expect-webdriverio": "^2.0.0", + "mocha": "^8.0.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/@wdio/mocha-framework/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.1" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, "node_modules/@wdio/mocha-framework/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2985,6 +3768,32 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/@wdio/mocha-framework/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@wdio/mocha-framework/node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/@wdio/mocha-framework/node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -3013,19 +3822,39 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@wdio/mocha-framework/node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "node_modules/@wdio/mocha-framework/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, - "bin": { - "he": "bin/he" + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" } }, "node_modules/@wdio/mocha-framework/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", + "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", "dev": true, "dependencies": { "argparse": "^2.0.1" @@ -3050,19 +3879,15 @@ } }, "node_modules/@wdio/mocha-framework/node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", + "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", "dev": true, "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" + "chalk": "^4.0.0" }, "engines": { "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/@wdio/mocha-framework/node_modules/minimatch": { @@ -3078,32 +3903,33 @@ } }, "node_modules/@wdio/mocha-framework/node_modules/mocha": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.1.tgz", - "integrity": "sha512-T7uscqjJVS46Pq1XDXyo9Uvey9gd3huT/DD9cYBb4K2Xc/vbKRPUWK067bxDQRK0yIz6Jxk73IrnimvASzBNAQ==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", + "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", "dev": true, "dependencies": { "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.3", + "chokidar": "3.5.1", + "debug": "4.3.1", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "7.1.6", "growl": "1.10.5", "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", + "js-yaml": "4.0.0", + "log-symbols": "4.0.0", "minimatch": "3.0.4", "ms": "2.1.3", - "nanoid": "3.2.0", - "serialize-javascript": "6.0.0", + "nanoid": "3.1.20", + "serialize-javascript": "5.0.1", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", "which": "2.0.2", - "workerpool": "6.2.0", + "wide-align": "1.1.3", + "workerpool": "6.1.0", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" @@ -3113,23 +3939,38 @@ "mocha": "bin/mocha" }, "engines": { - "node": ">= 12.0.0" + "node": ">= 10.12.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/mochajs" } }, - "node_modules/@wdio/mocha-framework/node_modules/ms": { + "node_modules/@wdio/mocha-framework/node_modules/mocha/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/@wdio/mocha-framework/node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/@wdio/mocha-framework/node_modules/nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.1.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", + "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" @@ -3168,13 +4009,25 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@wdio/mocha-framework/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "node_modules/@wdio/mocha-framework/node_modules/readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, "engines": { - "node": ">=8" + "node": ">=8.10.0" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/serialize-javascript": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", + "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" } }, "node_modules/@wdio/mocha-framework/node_modules/strip-json-comments": { @@ -3189,6 +4042,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@wdio/mocha-framework/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/mocha-framework/node_modules/workerpool": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", + "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==", + "dev": true + }, "node_modules/@wdio/mocha-framework/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -3217,139 +4088,104 @@ } }, "node_modules/@wdio/protocols": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.16.7.tgz", - "integrity": "sha512-Wv40pNQcLiPzQ3o98Mv4A8T1EBQ6k4khglz/e2r16CTm+F3DDYh8eLMAsU5cgnmuwwDKX1EyOiFwieykBn5MCg==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.5.3.tgz", + "integrity": "sha512-lpNaKwxYhDSL6neDtQQYXvzMAw+u4PXx65ryeMEX82mkARgzSZps5Kyrg9ub7X4T17K1NPfnY6UhZEWg6cKJCg==", "dev": true, "engines": { "node": ">=12.0.0" } }, "node_modules/@wdio/repl": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.16.14.tgz", - "integrity": "sha512-Ezih0Y+lsGkKv3H3U56hdWgZiQGA3VaAYguSLd9+g1xbQq+zMKqSmfqECD9bAy+OgCCiVTRstES6lHZxJVPhAg==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.5.3.tgz", + "integrity": "sha512-jfNJwNoc2nWdnLsFoGHmOJR9zaWfDTBMWM3W1eR5kXIjevD6gAfWsB5ZoA4IdybujCXxdnhlsm4o2jIzp/6f7A==", "dev": true, "dependencies": { - "@wdio/utils": "7.16.14" + "@wdio/utils": "7.5.3" }, "engines": { "node": ">=12.0.0" } }, "node_modules/@wdio/reporter": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.16.14.tgz", - "integrity": "sha512-e/I2oGfqjx9+zI4NT/garqxm7Afnos1EcrGSNu75WmP3PNJt4i+9DKkROu4PM6XWcpUB4v2UF7Mv/NrL3TU9aA==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.5.7.tgz", + "integrity": "sha512-9PXqZtCXDtU6UYLNDPu9MZQ8BiABGnRlJTrlbYB3gBfZDibMkJMvwXzPderipBv2+ifDZXmGe3Njf1ao2TkbFA==", "dev": true, "dependencies": { - "@types/diff": "^5.0.0", - "@types/node": "^17.0.4", - "@types/object-inspect": "^1.8.0", - "@types/supports-color": "^8.1.0", - "@types/tmp": "^0.2.0", - "@wdio/types": "7.16.14", - "diff": "^5.0.0", - "fs-extra": "^10.0.0", - "object-inspect": "^1.10.3", - "supports-color": "8.1.1" + "@wdio/types": "7.5.3", + "fs-extra": "^10.0.0" }, "engines": { "node": ">=12.0.0" } }, - "node_modules/@wdio/runner": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/runner/-/runner-7.16.16.tgz", - "integrity": "sha512-Tt2ja6GukGPq1m98WP26yOWUGwzK1y7gPTLy6rKlamz3mOBC7koL0T9+iqcFREquUe4CMy2jWp1lqvPlwMbu7g==", + "node_modules/@wdio/reporter/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", "dev": true, "dependencies": { - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", - "deepmerge": "^4.0.0", - "gaze": "^1.1.2", - "webdriver": "7.16.16", - "webdriverio": "7.16.16" + "got": "^11.8.1" }, "engines": { "node": ">=12.0.0" } }, - "node_modules/@wdio/spec-reporter": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@wdio/spec-reporter/-/spec-reporter-7.19.1.tgz", - "integrity": "sha512-qnZkn3VcyBPtcorUtpyCFE8v5ubyWmR7mFETXNzyriHyvjvk+NeFCWaFcIehpXYXiAmNpAwyfnZoIY6tkKQixQ==", + "node_modules/@wdio/runner": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/runner/-/runner-7.5.7.tgz", + "integrity": "sha512-RzVXd+xnwK/thkx1/xo9K5iscQ0Ofobgsx5dNVtwLDVMn9V7jCW/WX4dSCPAPaVSqnUCmkcQp3P5AoSBPpCZnQ==", "dev": true, "dependencies": { - "@types/easy-table": "^0.0.33", - "@wdio/reporter": "7.19.1", - "@wdio/types": "7.19.1", - "chalk": "^4.0.0", - "easy-table": "^1.1.1", - "pretty-ms": "^7.0.0" + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "deepmerge": "^4.0.0", + "gaze": "^1.1.2", + "webdriver": "7.5.3", + "webdriverio": "7.5.7" }, "engines": { "node": ">=12.0.0" - }, - "peerDependencies": { - "@wdio/cli": "^7.0.0" } }, - "node_modules/@wdio/spec-reporter/node_modules/@wdio/reporter": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.19.1.tgz", - "integrity": "sha512-sWmBBV4dPCZkGk9Qq0m35T/vHGen0N10nH4osQcVP3IZJqpo2eLIH4w+X6EUbjZ2GdgOA2bLMMzb1bl9JqnGPg==", - "dev": true, - "dependencies": { - "@types/diff": "^5.0.0", - "@types/node": "^17.0.4", - "@types/object-inspect": "^1.8.0", - "@types/supports-color": "^8.1.0", - "@types/tmp": "^0.2.0", - "@wdio/types": "7.19.1", - "diff": "^5.0.0", - "fs-extra": "^10.0.0", - "object-inspect": "^1.10.3", - "supports-color": "8.1.1" - }, - "engines": { - "node": ">=12.0.0" - } + "node_modules/@wdio/runner/node_modules/@types/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==", + "dev": true }, - "node_modules/@wdio/spec-reporter/node_modules/@wdio/reporter/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "node_modules/@wdio/runner/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", "dev": true, "dependencies": { - "has-flag": "^4.0.0" + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "node": ">=12.0.0" } }, - "node_modules/@wdio/spec-reporter/node_modules/@wdio/types": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.19.1.tgz", - "integrity": "sha512-mOodKlmvYxpj8P5BhjggEGpXuiRSlsyn2ClG8QqJ3lfXgOtOVEzFNfv/Ai7TkHr+lHDQNXLjllCjSqoCHhwlqg==", + "node_modules/@wdio/runner/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", "dev": true, "dependencies": { - "@types/node": "^17.0.4", "got": "^11.8.1" }, "engines": { "node": ">=12.0.0" - }, - "peerDependencies": { - "typescript": "^4.6.2" } }, - "node_modules/@wdio/spec-reporter/node_modules/ansi-styles": { + "node_modules/@wdio/runner/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", @@ -3364,7 +4200,20 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/@wdio/spec-reporter/node_modules/chalk": { + "node_modules/@wdio/runner/node_modules/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.10.2", + "@babel/runtime-corejs3": "^7.10.2" + }, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/@wdio/runner/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", @@ -3380,7 +4229,21 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/@wdio/spec-reporter/node_modules/color-convert": { + "node_modules/@wdio/runner/node_modules/chrome-launcher": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.4.tgz", + "integrity": "sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==", + "dev": true, + "dependencies": { + "@types/node": "*", + "escape-string-regexp": "^1.0.5", + "is-wsl": "^2.2.0", + "lighthouse-logger": "^1.0.0", + "mkdirp": "^0.5.3", + "rimraf": "^3.0.2" + } + }, + "node_modules/@wdio/runner/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", @@ -3392,107 +4255,760 @@ "node": ">=7.0.0" } }, - "node_modules/@wdio/spec-reporter/node_modules/color-name": { + "node_modules/@wdio/runner/node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/@wdio/spec-reporter/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "node_modules/@wdio/runner/node_modules/devtools": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.5.7.tgz", + "integrity": "sha512-+kqmvFbceElhYpN35yjm1T4Rz3VbH0QaqrNWKRpeyFp657Y5W0bm1s5FyMUeIv0aTNkAgWcETtqL+EG9X9uvjQ==", "dev": true, "dependencies": { - "has-flag": "^4.0.0" + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "chrome-launcher": "^0.13.1", + "edge-paths": "^2.1.0", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^0.7.21", + "uuid": "^8.0.0" }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/runner/node_modules/devtools-protocol": { + "version": "0.0.878340", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.878340.tgz", + "integrity": "sha512-W0q8Y02r1RNwfZtI4Jjh1/MZxRHyrIgy9FvElbJzQelZjmNH197H4mBQs7DZjlUUDA9s6Zz2jl+zUYFgLgEnzw==", + "dev": true + }, + "node_modules/@wdio/runner/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, "engines": { "node": ">=8" } }, - "node_modules/@wdio/sync": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/sync/-/sync-7.16.16.tgz", - "integrity": "sha512-MbVFAteaAOxHLKkMiMzOnh1hzINAK2U41GDIfy1yaPumcw1pNuJIhWrBYxprNMlqt8srk++wqQWgj5XpFjCL6g==", + "node_modules/@wdio/runner/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "@types/fibers": "^3.1.0", - "@types/puppeteer": "^5.4.0", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "fibers": "^5.0.0", - "webdriverio": "7.16.16" + "minimist": "^1.2.6" }, - "engines": { - "node": ">=12.0.0 <16" + "bin": { + "mkdirp": "bin/cmd.js" } }, - "node_modules/@wdio/types": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.16.14.tgz", - "integrity": "sha512-AyNI9iBSos9xWBmiFAF3sBs6AJXO/55VppU/eeF4HRdbZMtMarnvMuahM+jlUrA3vJSmDW+ufelG0MT//6vrnw==", + "node_modules/@wdio/runner/node_modules/puppeteer-core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-9.1.1.tgz", + "integrity": "sha512-zbedbitVIGhmgz0nt7eIdLsnaoVZSlNJfBivqm2w67T8LR2bU1dvnruDZ8nQO0zn++Iet7zHbAOdnuS5+H2E7A==", "dev": true, "dependencies": { - "@types/node": "^17.0.4", - "got": "^11.8.1" + "debug": "^4.1.0", + "devtools-protocol": "0.0.869402", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.1.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" }, "engines": { - "node": ">=12.0.0" + "node": ">=10.18.1" } }, - "node_modules/@wdio/utils": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.16.14.tgz", - "integrity": "sha512-wwin8nVpIlhmXJkq6GJw9aDDzgLOJKgXTcEua0T2sdXjoW78u5Ly/GZrFXTjMGhacFvoZfitTrjyfyy4CxMVvw==", + "node_modules/@wdio/runner/node_modules/puppeteer-core/node_modules/devtools-protocol": { + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", + "dev": true + }, + "node_modules/@wdio/runner/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "p-iteration": "^1.1.8" + "has-flag": "^4.0.0" }, "engines": { - "node": ">=12.0.0" + "node": ">=8" } }, - "node_modules/@webassemblyjs/ast": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", - "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "node_modules/@wdio/runner/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", "dev": true, - "dependencies": { - "@webassemblyjs/helper-numbers": "1.11.1", - "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + "bin": { + "uuid": "dist/bin/uuid" } }, - "node_modules/@webassemblyjs/floating-point-hex-parser": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", - "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==", - "dev": true - }, - "node_modules/@webassemblyjs/helper-api-error": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", - "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==", - "dev": true - }, - "node_modules/@webassemblyjs/helper-buffer": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", - "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==", - "dev": true - }, - "node_modules/@webassemblyjs/helper-numbers": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", - "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "node_modules/@wdio/runner/node_modules/webdriverio": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.5.7.tgz", + "integrity": "sha512-TLluVPLo6Snn/dxEITvMz7ZuklN4qZOBddDuLb9LO3rhsfKDMNbnhcBk0SLdFsWny0aCuhWNpJ6co93702XC0A==", "dev": true, "dependencies": { - "@webassemblyjs/floating-point-hex-parser": "1.11.1", - "@webassemblyjs/helper-api-error": "1.11.1", - "@xtuc/long": "4.2.2" - } - }, + "@types/aria-query": "^4.2.1", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "archiver": "^5.0.0", + "aria-query": "^4.2.2", + "atob": "^2.1.2", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.5.7", + "devtools-protocol": "^0.0.878340", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^3.0.4", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.5.3" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/runner/node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/@wdio/spec-reporter": { + "version": "7.19.7", + "resolved": "https://registry.npmjs.org/@wdio/spec-reporter/-/spec-reporter-7.19.7.tgz", + "integrity": "sha512-BDBZU2EK/GuC9VxtfqPtoW43FmvKxYDsvcDVDi3F7o+9fkcuGSJiWbw1AX251ZzzVQ7YP9ImTitSpdpUKXkilQ==", + "dev": true, + "dependencies": { + "@types/easy-table": "^0.0.33", + "@wdio/reporter": "7.19.7", + "@wdio/types": "7.19.5", + "chalk": "^4.0.0", + "easy-table": "^1.1.1", + "pretty-ms": "^7.0.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "@wdio/cli": "^7.0.0" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/@wdio/reporter": { + "version": "7.19.7", + "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.19.7.tgz", + "integrity": "sha512-Dum19gpfru66FnIq78/4HTuW87B7ceLDp6PJXwQM5kXyN7Gb7zhMgp6FZTM0FCYLyi6U/zXZSvpNUYl77caS6g==", + "dev": true, + "dependencies": { + "@types/diff": "^5.0.0", + "@types/node": "^17.0.4", + "@types/object-inspect": "^1.8.0", + "@types/supports-color": "^8.1.0", + "@types/tmp": "^0.2.0", + "@wdio/types": "7.19.5", + "diff": "^5.0.0", + "fs-extra": "^10.0.0", + "object-inspect": "^1.10.3", + "supports-color": "8.1.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/@wdio/types": { + "version": "7.19.5", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.19.5.tgz", + "integrity": "sha512-S1lC0pmtEO7NVH/2nM1c7NHbkgxLZH3VVG/z6ym3Bbxdtcqi2LMsEvvawMAU/fmhyiIkMsGZCO8vxG9cRw4z4A==", + "dev": true, + "dependencies": { + "@types/node": "^17.0.4", + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "typescript": "^4.6.2" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@wdio/spec-reporter/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/spec-reporter/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/@wdio/sync": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/sync/-/sync-7.5.7.tgz", + "integrity": "sha512-Zu/AYLjwqbFSbaOU1US7ownv3ov8JrtoGHq51JfJ4masefJDXNkHix2cZ0qEgl3IvkkWQ0ewL0G8GTXb3KOemA==", + "dev": true, + "dependencies": { + "@types/fibers": "^3.1.0", + "@types/puppeteer": "^5.4.0", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "fibers": "^5.0.0", + "webdriverio": "7.5.7" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/sync/node_modules/@types/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==", + "dev": true + }, + "node_modules/@wdio/sync/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/sync/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/sync/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@wdio/sync/node_modules/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.10.2", + "@babel/runtime-corejs3": "^7.10.2" + }, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/@wdio/sync/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@wdio/sync/node_modules/chrome-launcher": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.4.tgz", + "integrity": "sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==", + "dev": true, + "dependencies": { + "@types/node": "*", + "escape-string-regexp": "^1.0.5", + "is-wsl": "^2.2.0", + "lighthouse-logger": "^1.0.0", + "mkdirp": "^0.5.3", + "rimraf": "^3.0.2" + } + }, + "node_modules/@wdio/sync/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@wdio/sync/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@wdio/sync/node_modules/devtools": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.5.7.tgz", + "integrity": "sha512-+kqmvFbceElhYpN35yjm1T4Rz3VbH0QaqrNWKRpeyFp657Y5W0bm1s5FyMUeIv0aTNkAgWcETtqL+EG9X9uvjQ==", + "dev": true, + "dependencies": { + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "chrome-launcher": "^0.13.1", + "edge-paths": "^2.1.0", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^0.7.21", + "uuid": "^8.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/sync/node_modules/devtools-protocol": { + "version": "0.0.878340", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.878340.tgz", + "integrity": "sha512-W0q8Y02r1RNwfZtI4Jjh1/MZxRHyrIgy9FvElbJzQelZjmNH197H4mBQs7DZjlUUDA9s6Zz2jl+zUYFgLgEnzw==", + "dev": true + }, + "node_modules/@wdio/sync/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/sync/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/@wdio/sync/node_modules/puppeteer-core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-9.1.1.tgz", + "integrity": "sha512-zbedbitVIGhmgz0nt7eIdLsnaoVZSlNJfBivqm2w67T8LR2bU1dvnruDZ8nQO0zn++Iet7zHbAOdnuS5+H2E7A==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.869402", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.1.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "engines": { + "node": ">=10.18.1" + } + }, + "node_modules/@wdio/sync/node_modules/puppeteer-core/node_modules/devtools-protocol": { + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", + "dev": true + }, + "node_modules/@wdio/sync/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/sync/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/@wdio/sync/node_modules/webdriverio": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.5.7.tgz", + "integrity": "sha512-TLluVPLo6Snn/dxEITvMz7ZuklN4qZOBddDuLb9LO3rhsfKDMNbnhcBk0SLdFsWny0aCuhWNpJ6co93702XC0A==", + "dev": true, + "dependencies": { + "@types/aria-query": "^4.2.1", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "archiver": "^5.0.0", + "aria-query": "^4.2.2", + "atob": "^2.1.2", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.5.7", + "devtools-protocol": "^0.0.878340", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^3.0.4", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.5.3" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/sync/node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/@wdio/types": { + "version": "7.16.14", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.16.14.tgz", + "integrity": "sha512-AyNI9iBSos9xWBmiFAF3sBs6AJXO/55VppU/eeF4HRdbZMtMarnvMuahM+jlUrA3vJSmDW+ufelG0MT//6vrnw==", + "dev": true, + "dependencies": { + "@types/node": "^17.0.4", + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/utils": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.5.3.tgz", + "integrity": "sha512-nlLDKr8v8abLOHCKroBwQkGPdCIxjID2MllgWX23xqkYZylM9RdwPBdL8osQt9m3rq2TxiPAT4OlbzNt2WtN6Q==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/utils/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/utils/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@wdio/utils/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@wdio/utils/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@wdio/utils/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@wdio/utils/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@wdio/utils/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wdio/utils/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@webassemblyjs/ast": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", + "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "dev": true, + "dependencies": { + "@webassemblyjs/helper-numbers": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + } + }, + "node_modules/@webassemblyjs/floating-point-hex-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", + "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-api-error": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", + "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-buffer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", + "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-numbers": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", + "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "dev": true, + "dependencies": { + "@webassemblyjs/floating-point-hex-parser": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, "node_modules/@webassemblyjs/helper-wasm-bytecode": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", @@ -3600,6 +5116,15 @@ "@xtuc/long": "4.2.2" } }, + "node_modules/@xmldom/xmldom": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.8.tgz", + "integrity": "sha512-PrJx38EfpitFhwmILRl37jAdBlsww6AZ6rRVK4QS7T7RHLhX7mSs647sTmgr9GIxe3qjXdesmomEgbgaokrVFg==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -3615,7 +5140,7 @@ "node_modules/abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "integrity": "sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==", "dev": true }, "node_modules/accepts": { @@ -3651,37 +5176,35 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-node": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", - "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", - "dev": true, - "dependencies": { - "acorn": "^7.0.0", - "acorn-walk": "^7.0.0", - "xtend": "^4.0.2" - } - }, "node_modules/acorn-walk": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", - "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", "dev": true, "engines": { "node": ">=0.4.0" } }, - "node_modules/add-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", - "integrity": "sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=", - "dev": true + "node_modules/aes-decrypter": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/aes-decrypter/-/aes-decrypter-3.1.3.tgz", + "integrity": "sha512-VkG9g4BbhMBy+N5/XodDeV6F02chEk9IpgRTq/0bS80y4dzy79VH2Gtms02VXomf3HmyRe3yyJYkJ990ns+d6A==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "^3.0.5", + "global": "^4.4.0", + "pkcs7": "^1.0.4" + } }, "node_modules/agent-base": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", - "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "dev": true, + "dependencies": { + "debug": "4" + }, "engines": { "node": ">= 6.0.0" } @@ -3702,10 +5225,19 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "peerDependencies": { + "ajv": "^6.9.1" + } + }, "node_modules/amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "integrity": "sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==", "dev": true, "optional": true, "engines": { @@ -3713,14 +5245,26 @@ } }, "node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", "dev": true, "engines": { "node": ">=6" } }, + "node_modules/ansi-cyan": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz", + "integrity": "sha512-eCjan3AVo/SxZ0/MyIYRtkpxIu/H3xZN7URr1vXVrISxeyz8fUFz0FJziamK4sS8I+t35y4rHg1b2PklyBe/7A==", + "dev": true, + "dependencies": { + "ansi-wrap": "0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -3739,7 +5283,7 @@ "node_modules/ansi-gray": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", - "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", + "integrity": "sha512-HrgGIZUl8h2EHuZaU9hTR/cU5nhKxpVE1V6kdGsQ8e4zirElJ5fvtfc8N7Q1oq1aatO275i8pUFUCpNWCAnVWw==", "dev": true, "dependencies": { "ansi-wrap": "0.1.0" @@ -3748,16 +5292,16 @@ "node": ">=0.10.0" } }, - "node_modules/ansi-html": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz", - "integrity": "sha1-gTWEAhliqenm/QOflA0S9WynhZ4=", + "node_modules/ansi-red": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", + "integrity": "sha512-ewaIr5y+9CUTGFwZfpECUbFlGcC0GCw1oqR9RI6h1gQCd9Aj2GxSckCnPsVJnmfMZbwFYE+leZGASgkWl06Jow==", "dev": true, - "engines": [ - "node >= 0.8.0" - ], - "bin": { - "ansi-html": "bin/ansi-html" + "dependencies": { + "ansi-wrap": "0.1.0" + }, + "engines": { + "node": ">=0.10.0" } }, "node_modules/ansi-regex": { @@ -3773,7 +5317,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "dependencies": { "color-convert": "^1.9.0" }, @@ -3784,7 +5327,7 @@ "node_modules/ansi-wrap": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", - "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", + "integrity": "sha512-ZyznvL8k/FZeQHr2T6LzcJ/+vBApDnMNZvfVFy3At0knswWd6rJ3/0Hhmpu8oqa6C92npmozs890sX9Dl6q+Qw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3806,7 +5349,7 @@ "node_modules/append-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz", - "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", + "integrity": "sha512-WLbYiXzD3y/ATLZFufV/rZvWdZOs+Z/+5v1rBZ463Jn398pa6kcde27cvozYnBoxXblGZTFfoPpsaEw0orU5BA==", "dev": true, "dependencies": { "buffer-equal": "^1.0.0" @@ -3816,13 +5359,13 @@ } }, "node_modules/archiver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/archiver/-/archiver-5.3.0.tgz", - "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-5.3.1.tgz", + "integrity": "sha512-8KyabkmbYrH+9ibcTScQ1xCJC/CGcugdVIwB+53f5sZziXgwUh3iXlAlANMxcZyDEfTHMe6+Z5FofV8nopXP7w==", "dev": true, "dependencies": { "archiver-utils": "^2.1.0", - "async": "^3.2.0", + "async": "^3.2.3", "buffer-crc32": "^0.2.1", "readable-stream": "^3.6.0", "readdir-glob": "^1.0.0", @@ -3855,9 +5398,9 @@ } }, "node_modules/archiver/node_modules/async": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", - "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", "dev": true }, "node_modules/archiver/node_modules/readable-stream": { @@ -3877,7 +5420,7 @@ "node_modules/archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", "dev": true }, "node_modules/argparse": { @@ -3890,18 +5433,31 @@ } }, "node_modules/aria-query": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz", - "integrity": "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", + "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", "dev": true, - "engines": { - "node": ">=6.0" + "dependencies": { + "deep-equal": "^2.0.5" } }, "node_modules/arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz", + "integrity": "sha512-OQwDZUqYaQwyyhDJHThmzId8daf4/RFNLaeh3AevmSeZ5Y7ug4Ga/yKc6l6kTZOBW781rCj103ZuTh8GAsB3+Q==", + "dev": true, + "dependencies": { + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/arr-diff/node_modules/array-slice": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", + "integrity": "sha512-rlVfZW/1Ph2SNySXwR9QYkChp8EkOEiTMO5Vwx60usw04i4nWemkm9RXmQqgkQFaLHsqLuADvjp6IfgL9l2M8Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3910,7 +5466,7 @@ "node_modules/arr-filter": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz", - "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", + "integrity": "sha512-A2BETWCqhsecSvCkWAeVBFLH6sXEUGASuzkpjL3GR1SlL/PWL6M3J8EAAld2Uubmh39tvkJTqC9LeLHCUKmFXA==", "dev": true, "dependencies": { "make-iterator": "^1.0.0" @@ -3931,7 +5487,7 @@ "node_modules/arr-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz", - "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", + "integrity": "sha512-tVqVTHt+Q5Xb09qRkbu+DidW1yYzz5izWS2Xm2yFm7qJnmUfz4HPzNxbHkdRJbz2lrqI7S+z17xNYdFcBBO8Hw==", "dev": true, "dependencies": { "make-iterator": "^1.0.0" @@ -3941,9 +5497,9 @@ } }, "node_modules/arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz", + "integrity": "sha512-t5db90jq+qdgk8aFnxEkjqta0B/GHrM1pxzuuZz2zWsOXc5nKu3t+76s/PQBA8FTcM/ipspIH9jWG4OxCBc2eA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3952,7 +5508,7 @@ "node_modules/array-differ": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "integrity": "sha512-LeZY+DZDRnvP7eMuQ6LHfCzUGxAAIViUBliK24P3hWXL6y4SortgR6Nim6xrkfSLlmH0+k+9NYNwVC2s53ZrYQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3961,16 +5517,7 @@ "node_modules/array-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", - "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3979,29 +5526,23 @@ "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, "node_modules/array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, - "node_modules/array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "integrity": "sha512-GQTc6Uupx1FCavi5mPzBvVT7nEOeWMmUA9P95wpfpW1XwMSKs+KaymD5C2Up7KAUKg/mYwbsUYzdZWcoajlNZg==", "dev": true }, "node_modules/array-includes": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", - "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", "get-intrinsic": "^1.1.1", "is-string": "^1.0.7" }, @@ -4015,7 +5556,7 @@ "node_modules/array-initial": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz", - "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", + "integrity": "sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==", "dev": true, "dependencies": { "array-slice": "^1.0.0", @@ -4081,7 +5622,7 @@ "node_modules/array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "integrity": "sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -4090,21 +5631,22 @@ "node_modules/array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "integrity": "sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/array.prototype.flat": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz", - "integrity": "sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", "dev": true, "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.19.0" + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" }, "engines": { "node": ">= 0.4" @@ -4113,15 +5655,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -4146,7 +5679,7 @@ "node_modules/assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", "dev": true, "engines": { "node": ">=0.8" @@ -4164,7 +5697,7 @@ "node_modules/assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -4182,7 +5715,7 @@ "node_modules/async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "integrity": "sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==", "dev": true }, "node_modules/async-done": { @@ -4218,7 +5751,7 @@ "node_modules/async-settle": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz", - "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", + "integrity": "sha512-VPXfB4Vk49z1LHHodrEQ6Xf7W4gg1w0dAPROHngx7qgDjqmIQ+fXmwgGXTW/ITLai0YLSvWepJOP9EVpMnEAcw==", "dev": true, "dependencies": { "async-done": "^1.2.2" @@ -4230,7 +5763,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, "node_modules/atob": { @@ -4260,7 +5793,7 @@ "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", "dev": true, "engines": { "node": "*" @@ -4275,7 +5808,7 @@ "node_modules/babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "integrity": "sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==", "dev": true, "dependencies": { "chalk": "^1.1.3", @@ -4286,7 +5819,7 @@ "node_modules/babel-code-frame/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -4295,7 +5828,7 @@ "node_modules/babel-code-frame/node_modules/ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -4304,7 +5837,7 @@ "node_modules/babel-code-frame/node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "dependencies": { "ansi-styles": "^2.2.1", @@ -4320,13 +5853,13 @@ "node_modules/babel-code-frame/node_modules/js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "integrity": "sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==", "dev": true }, "node_modules/babel-code-frame/node_modules/strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "dependencies": { "ansi-regex": "^2.0.0" @@ -4338,7 +5871,7 @@ "node_modules/babel-code-frame/node_modules/supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true, "engines": { "node": ">=0.8.0" @@ -4383,7 +5916,7 @@ "node_modules/babel-core/node_modules/json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "integrity": "sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==", "dev": true, "bin": { "json5": "lib/cli.js" @@ -4392,18 +5925,9 @@ "node_modules/babel-core/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, - "node_modules/babel-core/node_modules/slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/babel-generator": { "version": "6.26.1", "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", @@ -4420,22 +5944,10 @@ "trim-right": "^1.0.1" } }, - "node_modules/babel-generator/node_modules/detect-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", - "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", - "dev": true, - "dependencies": { - "repeating": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/babel-generator/node_modules/jsesc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", + "integrity": "sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA==", "dev": true, "bin": { "jsesc": "bin/jsesc" @@ -4444,7 +5956,7 @@ "node_modules/babel-helpers": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", - "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "integrity": "sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ==", "dev": true, "dependencies": { "babel-runtime": "^6.22.0", @@ -4452,13 +5964,13 @@ } }, "node_modules/babel-loader": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.2.3.tgz", - "integrity": "sha512-n4Zeta8NC3QAsuyiizu0GkmRcQ6clkV9WFUnUf1iXP//IeSKbWjofW3UHyZVwlOB4y039YQKefawyTn64Zwbuw==", + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.2.5.tgz", + "integrity": "sha512-OSiFfH89LrEMiWd4pLNqGz4CwJDtbs2ZVc+iGu2HrkRfPxId9F2anQj38IxWpmRfsUY0aBZYi1EFcd3mhtRMLQ==", "dev": true, "dependencies": { "find-cache-dir": "^3.3.1", - "loader-utils": "^1.4.0", + "loader-utils": "^2.0.0", "make-dir": "^3.1.0", "schema-utils": "^2.6.5" }, @@ -4470,58 +5982,38 @@ "webpack": ">=2" } }, - "node_modules/babel-loader/node_modules/json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/babel-loader/node_modules/loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", - "dev": true, - "dependencies": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^1.0.1" - }, - "engines": { - "node": ">=4.0.0" - } - }, "node_modules/babel-messages": { "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", - "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "integrity": "sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==", "dev": true, "dependencies": { "babel-runtime": "^6.22.0" } }, - "node_modules/babel-plugin-dynamic-import-node": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", - "integrity": "sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==", + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", "dev": true, "dependencies": { - "object.assign": "^4.1.0" + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" } }, "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz", - "integrity": "sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w==", - "dev": true, + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", + "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==", "dependencies": { - "@babel/compat-data": "^7.13.11", - "@babel/helper-define-polyfill-provider": "^0.3.1", + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.3", "semver": "^6.1.1" }, "peerDependencies": { @@ -4529,42 +6021,32 @@ } }, "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", - "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", - "dev": true, + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz", + "integrity": "sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA==", "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.1", - "core-js-compat": "^3.21.0" + "@babel/helper-define-polyfill-provider": "^0.3.3", + "core-js-compat": "^3.25.1" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "node_modules/babel-plugin-polyfill-regenerator": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.1.tgz", - "integrity": "sha512-Y2B06tvgHYt1x0yz17jGkGeeMr5FeKUu+ASJ+N6nB5lQ8Dapfg42i0OVrf8PNGJ3zKL4A23snMi1IRwrqqND7A==", - "dev": true, + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz", + "integrity": "sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw==", "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.1" + "@babel/helper-define-polyfill-provider": "^0.3.3" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, - "node_modules/babel-plugin-transform-object-assign": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-assign/-/babel-plugin-transform-object-assign-6.22.0.tgz", - "integrity": "sha1-+Z0vZvGgsNSY40bFNZaEdAyqILo=", - "dependencies": { - "babel-runtime": "^6.22.0" - } - }, "node_modules/babel-register": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", - "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "integrity": "sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A==", "dev": true, "dependencies": { "babel-core": "^6.26.0", @@ -4580,7 +6062,7 @@ "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "dev": true, "hasInstallScript": true }, @@ -4596,19 +6078,11 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/babel-register/node_modules/source-map-support": { - "version": "0.4.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", - "dev": true, - "dependencies": { - "source-map": "^0.5.6" - } - }, "node_modules/babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dev": true, "dependencies": { "core-js": "^2.4.0", "regenerator-runtime": "^0.11.0" @@ -4618,13 +6092,20 @@ "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", + "dev": true, "hasInstallScript": true }, + "node_modules/babel-runtime/node_modules/regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, "node_modules/babel-template": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", - "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "integrity": "sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg==", "dev": true, "dependencies": { "babel-runtime": "^6.26.0", @@ -4637,7 +6118,7 @@ "node_modules/babel-traverse": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", - "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "integrity": "sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==", "dev": true, "dependencies": { "babel-code-frame": "^6.26.0", @@ -4672,13 +6153,13 @@ "node_modules/babel-traverse/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/babel-types": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", - "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "integrity": "sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==", "dev": true, "dependencies": { "babel-runtime": "^6.26.0", @@ -4690,24 +6171,12 @@ "node_modules/babel-types/node_modules/to-fast-properties": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "integrity": "sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og==", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/babelify": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/babelify/-/babelify-10.0.0.tgz", - "integrity": "sha512-X40FaxyH7t3X+JFAKvb1H9wooWKLRCi8pg3m8poqtdZaIng+bjzp9RvKQCvRjF9isHiPkXspbbXT/zwXLtwgwg==", - "dev": true, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, "node_modules/babylon": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", @@ -4720,7 +6189,7 @@ "node_modules/bach": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", - "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", + "integrity": "sha512-bZOOfCb3gXBXbTFXq3OZtGR88LwGeJvzu6szttaIzymOTS4ZttBNOWSv7aLZja2EMycKtRYV0Oa8SNKH/zkxvg==", "dev": true, "dependencies": { "arr-filter": "^1.1.1", @@ -4738,9 +6207,9 @@ } }, "node_modules/bail": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.5.tgz", - "integrity": "sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", + "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==", "dev": true, "funding": { "type": "github", @@ -4774,7 +6243,7 @@ "node_modules/base/node_modules/define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "dependencies": { "is-descriptor": "^1.0.0" @@ -4824,16 +6293,22 @@ "node": ">= 0.8" } }, + "node_modules/basic-auth/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, "node_modules/batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", - "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", + "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==", "dev": true }, "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", "dev": true, "dependencies": { "tweetnacl": "^0.14.3" @@ -4842,7 +6317,7 @@ "node_modules/beeper": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "integrity": "sha512-3vqtKL1N45I5dV0RdssXZG7X6pCqQrWPNOlBPZPrd+QkE2HEhR57Z04m0KtpbsZH73j+a3F8UD1TQnn+ExTvIA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -4869,7 +6344,7 @@ "node_modules/binary": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", + "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==", "dev": true, "dependencies": { "buffers": "~0.1.1", @@ -4938,13 +6413,13 @@ "node_modules/bluebird": { "version": "3.4.7", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", - "integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=", + "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==", "dev": true }, "node_modules/body": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz", - "integrity": "sha1-5LoM5BCkaTYyM2dgnstOZVMSUGk=", + "integrity": "sha512-chUsBxGRtuElD6fmw1gHLpvnKdVLK302peeFa9ZqAEk8TyzZ3fygLyUEDDPTJvL9+Bor0dIwn6ePOsRM2y0zQQ==", "dev": true, "dependencies": { "continuable-cache": "^0.3.1", @@ -4954,23 +6429,26 @@ } }, "node_modules/body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.8.1", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.9.7", - "raw-body": "2.4.3", - "type-is": "~1.6.18" + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" }, "engines": { - "node": ">= 0.8" + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" } }, "node_modules/body-parser/node_modules/debug": { @@ -4984,18 +6462,18 @@ "node_modules/body-parser/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/body/node_modules/bytes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-1.0.0.tgz", - "integrity": "sha1-NWnt6Lo0MV+rmcPpLLBMciDeH6g=", + "integrity": "sha512-/x68VkHLeTl3/Ll8IvxdwzhrT+IyKc52e/oyHhA2RwqPqswSnjVbSddfPRwAsJtbilMAPSRWwAlpxdYsSWOTKQ==", "dev": true }, "node_modules/body/node_modules/raw-body": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.7.tgz", - "integrity": "sha1-HQJ8K/oRasxmI7yo8AAWVyqH1CU=", + "integrity": "sha512-WmJJU2e9Y6M5UzTOkHaM7xJGAPQD8PNzx3bAd2+uhZAim6wDk6dAZxPVYLF67XhbR4hmKGh33Lpmh4XWrCH5Mg==", "dev": true, "dependencies": { "bytes": "1", @@ -5008,7 +6486,7 @@ "node_modules/body/node_modules/string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", "dev": true }, "node_modules/brace-expansion": { @@ -5033,21 +6511,6 @@ "node": ">=8" } }, - "node_modules/browser-resolve": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", - "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", - "dev": true, - "dependencies": { - "resolve": "1.1.7" - } - }, - "node_modules/browser-resolve/node_modules/resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true - }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -5055,26 +6518,30 @@ "dev": true }, "node_modules/browserslist": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.0.tgz", - "integrity": "sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ==", - "dev": true, + "version": "4.21.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", + "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], "dependencies": { - "caniuse-lite": "^1.0.30001313", - "electron-to-chromium": "^1.4.76", - "escalade": "^3.1.1", - "node-releases": "^2.0.2", - "picocolors": "^1.0.0" + "caniuse-lite": "^1.0.30001400", + "electron-to-chromium": "^1.4.251", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.9" }, "bin": { "browserslist": "cli.js" }, "engines": { "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" } }, "node_modules/browserstack": { @@ -5087,12 +6554,13 @@ } }, "node_modules/browserstack-local": { - "version": "1.4.9", - "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.4.9.tgz", - "integrity": "sha512-V+q8HQwRQFr9nd32xR66ZZ3VDWa3Kct4IMMudhKgcuD7cWrvvFARZOibx71II+Rf7P5nMQpWWxl9z/3p927nbg==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.5.1.tgz", + "integrity": "sha512-T/wxyWDzvBHbDvl7fZKpFU7mYze6nrUkBhNy+d+8bXBqgQX10HTYvajIGO0wb49oGSLCPM0CMZTV/s7e6LF0sA==", "dev": true, "dependencies": { - "https-proxy-agent": "^4.0.0", + "agent-base": "^6.0.2", + "https-proxy-agent": "^5.0.1", "is-running": "^2.1.0", "ps-tree": "=1.2.0", "temp-fs": "^0.9.9" @@ -5133,9 +6601,9 @@ } }, "node_modules/browserstacktunnel-wrapper": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/browserstacktunnel-wrapper/-/browserstacktunnel-wrapper-2.0.4.tgz", - "integrity": "sha512-GCV599FUUxNOCFl3WgPnfc5dcqq9XTmMXoxWpqkvmk0R9TOIoqmjENNU6LY6DtgIL6WfBVbg/jmWtnM5K6UYSg==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/browserstacktunnel-wrapper/-/browserstacktunnel-wrapper-2.0.5.tgz", + "integrity": "sha512-oociT3nl+FhQnyJbAb1RM4oQ5pN7aKeXEURkTkiEVm/Rji2r0agl3Wbw5V23VFn9lCU5/fGyDejRZPtGYsEcFw==", "dev": true, "dependencies": { "https-proxy-agent": "^2.2.1", @@ -5206,19 +6674,22 @@ "node_modules/buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", "dev": true, "engines": { "node": "*" } }, "node_modules/buffer-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", - "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", "dev": true, "engines": { - "node": ">=0.4.0" + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/buffer-from": { @@ -5236,16 +6707,10 @@ "node": ">=0.10" } }, - "node_modules/buffer-shims": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", - "dev": true - }, "node_modules/buffers": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=", + "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==", "dev": true, "engines": { "node": ">=0.2.0" @@ -5262,7 +6727,7 @@ "node_modules/cac": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/cac/-/cac-3.0.4.tgz", - "integrity": "sha1-bSTO7Dcu/lybeYgIvH9JtHJCpO8=", + "integrity": "sha512-hq4rxE3NT5PlaEiVV39Z45d6MoFcQZG5dsgJqtAUeOz3408LEQAElToDkf9i5IYSCOmK0If/81dLg7nKxqPR0w==", "dev": true, "dependencies": { "camelcase-keys": "^3.0.0", @@ -5280,7 +6745,7 @@ "node_modules/cac/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -5289,38 +6754,16 @@ "node_modules/cac/node_modules/ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/cac/node_modules/camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/cac/node_modules/camelcase-keys": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-3.0.0.tgz", - "integrity": "sha1-/AxsNgNj9zd+N5O5oWvM8QcMHKQ=", - "dev": true, - "dependencies": { - "camelcase": "^3.0.0", - "map-obj": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/cac/node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "dependencies": { "ansi-styles": "^2.2.1", @@ -5336,7 +6779,7 @@ "node_modules/cac/node_modules/find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", "dev": true, "dependencies": { "path-exists": "^2.0.0", @@ -5346,91 +6789,40 @@ "node": ">=0.10.0" } }, - "node_modules/cac/node_modules/indent-string": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", - "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/cac/node_modules/load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/cac/node_modules/map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } + "node_modules/cac/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true }, - "node_modules/cac/node_modules/parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "node_modules/cac/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "dependencies": { - "error-ex": "^1.2.0" - }, - "engines": { - "node": ">=0.10.0" + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "node_modules/cac/node_modules/path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "dependencies": { - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/cac/node_modules/path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", "dev": true, "dependencies": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", "pinkie-promise": "^2.0.0" }, "engines": { "node": ">=0.10.0" } }, - "node_modules/cac/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/cac/node_modules/read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", "dev": true, "dependencies": { "load-json-file": "^1.0.0", @@ -5444,7 +6836,7 @@ "node_modules/cac/node_modules/read-pkg-up": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", "dev": true, "dependencies": { "find-up": "^1.0.0", @@ -5454,10 +6846,19 @@ "node": ">=0.10.0" } }, + "node_modules/cac/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, "node_modules/cac/node_modules/strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "dependencies": { "ansi-regex": "^2.0.0" @@ -5466,22 +6867,10 @@ "node": ">=0.10.0" } }, - "node_modules/cac/node_modules/strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "dependencies": { - "is-utf8": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/cac/node_modules/supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true, "engines": { "node": ">=0.8.0" @@ -5549,17 +6938,10 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cached-path-relative": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz", - "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==", - "dev": true - }, "node_modules/call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "dependencies": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -5568,27 +6950,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "dependencies": { - "callsites": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/caller-path/node_modules/callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -5608,36 +6969,37 @@ } }, "node_modules/camelcase-keys": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz", - "integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-3.0.0.tgz", + "integrity": "sha512-U4E6A6aFyYnNW+tDt5/yIUKQURKXe3WMFPfX4FxrQFcwZ/R08AUk1xWcUtlr7oq6CV07Ji+aa69V2g7BSpblnQ==", "dev": true, "dependencies": { - "camelcase": "^5.3.1", - "map-obj": "^4.0.0", - "quick-lru": "^4.0.1" + "camelcase": "^3.0.0", + "map-obj": "^1.0.0" }, "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=0.10.0" } }, - "node_modules/camelcase-keys/node_modules/quick-lru": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", - "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", + "node_modules/camelcase-keys/node_modules/camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", "dev": true, "engines": { - "node": ">=8" + "node": ">=0.10.0" } }, + "node_modules/can-autoplay": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/can-autoplay/-/can-autoplay-3.0.2.tgz", + "integrity": "sha512-Ih6wc7yJB4TylS/mLyAW0Dj5Nh3Gftq/g966TcxgvpNCOzlbqTs85srAq7mwIspo4w8gnLCVVGroyCHfh6l9aA==", + "dev": true + }, "node_modules/caniuse-lite": { - "version": "1.0.30001320", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001320.tgz", - "integrity": "sha512-MWPzG54AGdo3nWx7zHZTefseM5Y1ccM7hlQKHRqJkPozUaw3hNbBTMmLn16GG2FUzjR13Cr3NPfhIieX5PzXDA==", - "dev": true, + "version": "1.0.30001429", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", + "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==", "funding": [ { "type": "opencollective", @@ -5652,13 +7014,13 @@ "node_modules/caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, "node_modules/ccount": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.1.0.tgz", - "integrity": "sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", "dev": true, "funding": { "type": "github", @@ -5686,7 +7048,7 @@ "node_modules/chainsaw": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", + "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==", "dev": true, "dependencies": { "traverse": ">=0.3.0 <0.4" @@ -5699,7 +7061,6 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, "dependencies": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -5709,31 +7070,10 @@ "node": ">=4" } }, - "node_modules/chalk/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/character-entities": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz", - "integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", "dev": true, "funding": { "type": "github", @@ -5741,9 +7081,9 @@ } }, "node_modules/character-entities-html4": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.4.tgz", - "integrity": "sha512-HRcDxZuZqMx3/a+qrzxdBKBPUpxWEq9xw2OPZ3a/174ihfrQKVsFhqtthBInFy1zZ9GgZyFXOatNujm8M+El3g==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", "dev": true, "funding": { "type": "github", @@ -5751,19 +7091,9 @@ } }, "node_modules/character-entities-legacy": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz", - "integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/character-reference-invalid": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz", - "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", "dev": true, "funding": { "type": "github", @@ -5779,7 +7109,7 @@ "node_modules/check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", "dev": true, "engines": { "node": "*" @@ -5819,9 +7149,9 @@ "dev": true }, "node_modules/chrome-launcher": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.0.tgz", - "integrity": "sha512-ZQqX5kb9H0+jy1OqLnWampfocrtSZaGl7Ny3F9GRha85o4odbL8x55paUzh51UC7cEmZ5obp3H2Mm70uC2PpRA==", + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.1.tgz", + "integrity": "sha512-UugC8u59/w2AyX5sHLZUHoxBAiSiunUhZa3zZwMH6zPVis0C3dDKiRWyUGIo14tTbZHGVviWxv3PQWZ7taZ4fg==", "dev": true, "dependencies": { "@types/node": "*", @@ -5857,13 +7187,6 @@ "node": ">=6.0" } }, - "node_modules/circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "deprecated": "CircularJSON is in maintenance only, flatted is its successor.", - "dev": true - }, "node_modules/class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -5879,10 +7202,19 @@ "node": ">=0.10.0" } }, + "node_modules/class-utils/node_modules/arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/class-utils/node_modules/define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "dependencies": { "is-descriptor": "^0.1.0" @@ -5894,7 +7226,7 @@ "node_modules/class-utils/node_modules/is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -5906,7 +7238,7 @@ "node_modules/class-utils/node_modules/is-accessor-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -5924,7 +7256,7 @@ "node_modules/class-utils/node_modules/is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -5936,7 +7268,7 @@ "node_modules/class-utils/node_modules/is-data-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -5972,9 +7304,9 @@ } }, "node_modules/cli-spinners": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz", - "integrity": "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.7.0.tgz", + "integrity": "sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw==", "dev": true, "engines": { "node": ">=6" @@ -5993,20 +7325,23 @@ } }, "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, "dependencies": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" } }, "node_modules/clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", "dev": true, "engines": { "node": ">=0.8" @@ -6015,25 +7350,28 @@ "node_modules/clone-buffer": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "integrity": "sha512-KLLTJWrvwIP+OPfMn0x2PheDEP20RPUcGXj/ERegTgdmPEZylALQldygiqrPPu8P45uNuPs7ckmReLY6v/iA5g==", "dev": true, "engines": { "node": ">= 0.10" } }, "node_modules/clone-response": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", - "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", + "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", "dev": true, "dependencies": { "mimic-response": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/clone-stats": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "integrity": "sha512-au6ydSpg6nsrigcZ4m8Bc9hxjeW+GJ8xh5G3BJCMt4WXe1H10UNaVOamqQTmrx1kjVuxAHIQSNU6hY4Nsn9/ag==", "dev": true }, "node_modules/cloneable-readable": { @@ -6047,20 +7385,10 @@ "readable-stream": "^2.3.5" } }, - "node_modules/co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true, - "engines": { - "iojs": ">= 1.0.0", - "node": ">= 0.12.0" - } - }, "node_modules/code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -6069,7 +7397,7 @@ "node_modules/collection-map": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", - "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", + "integrity": "sha512-5D2XXSpkOnleOI21TG7p3T0bGAsZ/XknZpKBmGYyluO8pw4zA3K8ZlrBIbC4FXg3m6z/RNFiUFfT2sQK01+UHA==", "dev": true, "dependencies": { "arr-map": "^2.0.2", @@ -6083,7 +7411,7 @@ "node_modules/collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "integrity": "sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==", "dev": true, "dependencies": { "map-visit": "^1.0.0", @@ -6097,7 +7425,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "dependencies": { "color-name": "1.1.3" } @@ -6105,8 +7432,7 @@ "node_modules/color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, "node_modules/color-support": { "version": "1.1.3", @@ -6139,9 +7465,9 @@ } }, "node_modules/comma-separated-tokens": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz", - "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.2.tgz", + "integrity": "sha512-G5yTt3KQN4Yn7Yk4ed73hlZ1evrFKXeUW3086p3PRFNp7m2vIjI6Pg+Kgb+oyzhd9F2qdcoj67+y3SdxL5XWsg==", "dev": true, "funding": { "type": "github", @@ -6149,27 +7475,17 @@ } }, "node_modules/commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, "node_modules/commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", "dev": true }, - "node_modules/compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dev": true, - "dependencies": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, "node_modules/component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -6208,7 +7524,7 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "node_modules/concat-stream": { @@ -6277,12 +7593,51 @@ "ms": "2.0.0" } }, + "node_modules/connect/node_modules/finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/connect/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/connect/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/connect/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -6294,25 +7649,6 @@ "node": ">= 0.6" } }, - "node_modules/content-disposition/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, "node_modules/content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", @@ -6324,411 +7660,18 @@ "node_modules/continuable-cache": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/continuable-cache/-/continuable-cache-0.3.1.tgz", - "integrity": "sha1-vXJ6f67XfnH/OYWskzUakSczrQ8=", - "dev": true - }, - "node_modules/conventional-changelog": { - "version": "3.1.24", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.24.tgz", - "integrity": "sha512-ed6k8PO00UVvhExYohroVPXcOJ/K1N0/drJHx/faTH37OIZthlecuLIRX/T6uOp682CAoVoFpu+sSEaeuH6Asg==", - "dev": true, - "dependencies": { - "conventional-changelog-angular": "^5.0.12", - "conventional-changelog-atom": "^2.0.8", - "conventional-changelog-codemirror": "^2.0.8", - "conventional-changelog-conventionalcommits": "^4.5.0", - "conventional-changelog-core": "^4.2.1", - "conventional-changelog-ember": "^2.0.9", - "conventional-changelog-eslint": "^3.0.9", - "conventional-changelog-express": "^2.0.6", - "conventional-changelog-jquery": "^3.0.11", - "conventional-changelog-jshint": "^2.0.9", - "conventional-changelog-preset-loader": "^2.3.4" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-angular": { - "version": "5.0.13", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.13.tgz", - "integrity": "sha512-i/gipMxs7s8L/QeuavPF2hLnJgH6pEZAttySB6aiQLWcX3puWDL3ACVmvBhJGxnAy52Qc15ua26BufY6KpmrVA==", - "dev": true, - "dependencies": { - "compare-func": "^2.0.0", - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-atom": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-2.0.8.tgz", - "integrity": "sha512-xo6v46icsFTK3bb7dY/8m2qvc8sZemRgdqLb/bjpBsH2UyOS8rKNTgcb5025Hri6IpANPApbXMg15QLb1LJpBw==", - "dev": true, - "dependencies": { - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-codemirror": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-2.0.8.tgz", - "integrity": "sha512-z5DAsn3uj1Vfp7po3gpt2Boc+Bdwmw2++ZHa5Ak9k0UKsYAO5mH1UBTN0qSCuJZREIhX6WU4E1p3IW2oRCNzQw==", - "dev": true, - "dependencies": { - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-config-spec": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-config-spec/-/conventional-changelog-config-spec-2.1.0.tgz", - "integrity": "sha512-IpVePh16EbbB02V+UA+HQnnPIohgXvJRxHcS5+Uwk4AT5LjzCZJm5sp/yqs5C6KZJ1jMsV4paEV13BN1pvDuxQ==", + "integrity": "sha512-TF30kpKhTH8AGCG3dut0rdd/19B7Z+qCnrMoBLpyQu/2drZdNrrpcjPEoJeSVsQM+8KmWG5O56oPDjSSUsuTyA==", "dev": true }, - "node_modules/conventional-changelog-conventionalcommits": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.1.tgz", - "integrity": "sha512-lzWJpPZhbM1R0PIzkwzGBCnAkH5RKJzJfFQZcl/D+2lsJxAwGnDKBqn/F4C1RD31GJNn8NuKWQzAZDAVXPp2Mw==", - "dev": true, - "dependencies": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-core": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.2.4.tgz", - "integrity": "sha512-gDVS+zVJHE2v4SLc6B0sLsPiloR0ygU7HaDW14aNJE1v4SlqJPILPl/aJC7YdtRE4CybBf8gDwObBvKha8Xlyg==", - "dev": true, - "dependencies": { - "add-stream": "^1.0.0", - "conventional-changelog-writer": "^5.0.0", - "conventional-commits-parser": "^3.2.0", - "dateformat": "^3.0.0", - "get-pkg-repo": "^4.0.0", - "git-raw-commits": "^2.0.8", - "git-remote-origin-url": "^2.0.0", - "git-semver-tags": "^4.1.1", - "lodash": "^4.17.15", - "normalize-package-data": "^3.0.0", - "q": "^1.5.1", - "read-pkg": "^3.0.0", - "read-pkg-up": "^3.0.0", - "through2": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-core/node_modules/dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/conventional-changelog-core/node_modules/hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-core/node_modules/normalize-package-data": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", - "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", - "dev": true, - "dependencies": { - "hosted-git-info": "^4.0.1", - "is-core-module": "^2.5.0", - "semver": "^7.3.4", - "validate-npm-package-license": "^3.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-core/node_modules/read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "dev": true, - "dependencies": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/conventional-changelog-core/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-ember": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-2.0.9.tgz", - "integrity": "sha512-ulzIReoZEvZCBDhcNYfDIsLTHzYHc7awh+eI44ZtV5cx6LVxLlVtEmcO+2/kGIHGtw+qVabJYjdI5cJOQgXh1A==", - "dev": true, - "dependencies": { - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-eslint": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-3.0.9.tgz", - "integrity": "sha512-6NpUCMgU8qmWmyAMSZO5NrRd7rTgErjrm4VASam2u5jrZS0n38V7Y9CzTtLT2qwz5xEChDR4BduoWIr8TfwvXA==", - "dev": true, - "dependencies": { - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-express": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-2.0.6.tgz", - "integrity": "sha512-SDez2f3iVJw6V563O3pRtNwXtQaSmEfTCaTBPCqn0oG0mfkq0rX4hHBq5P7De2MncoRixrALj3u3oQsNK+Q0pQ==", - "dev": true, - "dependencies": { - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-jquery": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-3.0.11.tgz", - "integrity": "sha512-x8AWz5/Td55F7+o/9LQ6cQIPwrCjfJQ5Zmfqi8thwUEKHstEn4kTIofXub7plf1xvFA2TqhZlq7fy5OmV6BOMw==", - "dev": true, - "dependencies": { - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-jshint": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-2.0.9.tgz", - "integrity": "sha512-wMLdaIzq6TNnMHMy31hql02OEQ8nCQfExw1SE0hYL5KvU+JCTuPaDO+7JiogGT2gJAxiUGATdtYYfh+nT+6riA==", - "dev": true, - "dependencies": { - "compare-func": "^2.0.0", - "q": "^1.5.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-preset-loader": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-2.3.4.tgz", - "integrity": "sha512-GEKRWkrSAZeTq5+YjUZOYxdHq+ci4dNwHvpaBC3+ENalzFWuCWa9EZXSuZBpkr72sMdKB+1fyDV4takK1Lf58g==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-writer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-5.0.1.tgz", - "integrity": "sha512-5WsuKUfxW7suLblAbFnxAcrvf6r+0b7GvNaWUwUIk0bXMnENP/PEieGKVUQrjPqwPT4o3EPAASBXiY6iHooLOQ==", - "dev": true, - "dependencies": { - "conventional-commits-filter": "^2.0.7", - "dateformat": "^3.0.0", - "handlebars": "^4.7.7", - "json-stringify-safe": "^5.0.1", - "lodash": "^4.17.15", - "meow": "^8.0.0", - "semver": "^6.0.0", - "split": "^1.0.0", - "through2": "^4.0.0" - }, - "bin": { - "conventional-changelog-writer": "cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-changelog-writer/node_modules/dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/conventional-changelog-writer/node_modules/split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "dependencies": { - "through": "2" - }, - "engines": { - "node": "*" - } - }, - "node_modules/conventional-commits-filter": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-2.0.7.tgz", - "integrity": "sha512-ASS9SamOP4TbCClsRHxIHXRfcGCnIoQqkvAzCSbZzTFLfcTqJVugB0agRgsEELsqaeWgsXv513eS116wnlSSPA==", - "dev": true, - "dependencies": { - "lodash.ismatch": "^4.4.0", - "modify-values": "^1.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-commits-parser": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.2.4.tgz", - "integrity": "sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q==", - "dev": true, - "dependencies": { - "is-text-path": "^1.0.1", - "JSONStream": "^1.0.4", - "lodash": "^4.17.15", - "meow": "^8.0.0", - "split2": "^3.0.0", - "through2": "^4.0.0" - }, - "bin": { - "conventional-commits-parser": "cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-commits-parser/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/conventional-commits-parser/node_modules/split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "dev": true, - "dependencies": { - "readable-stream": "^3.0.0" - } - }, - "node_modules/conventional-recommended-bump": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/conventional-recommended-bump/-/conventional-recommended-bump-6.1.0.tgz", - "integrity": "sha512-uiApbSiNGM/kkdL9GTOLAqC4hbptObFo4wW2QRyHsKciGAfQuLU1ShZ1BIVI/+K2BE/W1AWYQMCXAsv4dyKPaw==", - "dev": true, - "dependencies": { - "concat-stream": "^2.0.0", - "conventional-changelog-preset-loader": "^2.3.4", - "conventional-commits-filter": "^2.0.7", - "conventional-commits-parser": "^3.2.0", - "git-raw-commits": "^2.0.8", - "git-semver-tags": "^4.1.1", - "meow": "^8.0.0", - "q": "^1.5.1" - }, - "bin": { - "conventional-recommended-bump": "cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/conventional-recommended-bump/node_modules/concat-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", - "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", - "dev": true, - "engines": [ - "node >= 6.0" - ], - "dependencies": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" - } - }, - "node_modules/conventional-recommended-bump/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/convert-source-map": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", - "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.1.1" - } + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, "node_modules/cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", "engines": { "node": ">= 0.6" } @@ -6736,12 +7679,12 @@ "node_modules/cookie-signature": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, "node_modules/copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "integrity": "sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -6758,9 +7701,9 @@ } }, "node_modules/core-js": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.21.1.tgz", - "integrity": "sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig==", + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.26.0.tgz", + "integrity": "sha512-+DkDrhoR4Y0PxDz6rurahuB+I45OsEUv8E1maPTB6OuHRohMMcznBq9TMpdpDMm/hUPob/mJJS3PqgbHpMTQgw==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -6768,32 +7711,21 @@ } }, "node_modules/core-js-compat": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.1.tgz", - "integrity": "sha512-gbgX5AUvMb8gwxC7FLVWYT7Kkgu/y7+h/h1X43yJkNqhlK2fuYyQimqvKGNZFAY6CKii/GFKJ2cp/1/42TN36g==", - "dev": true, + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.26.0.tgz", + "integrity": "sha512-piOX9Go+Z4f9ZiBFLnZ5VrOpBl0h7IGCkiFUN11QTe6LjAvOT3ifL/5TdoizMh99hcGy5SoLyWbapIY/PIb/3A==", "dependencies": { - "browserslist": "^4.19.1", - "semver": "7.0.0" + "browserslist": "^4.21.4" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" } }, - "node_modules/core-js-compat/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/core-js-pure": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.21.1.tgz", - "integrity": "sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ==", + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", + "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -6839,14 +7771,10 @@ } }, "node_modules/crc-32": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.1.tgz", - "integrity": "sha512-Dn/xm/1vFFgs3nfrpEVScHoIslO9NZRITWGz/1E/St6u4xw99vfZzVkW0OSnzx2h9egej9xwMCEut6sqwokM/w==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", "dev": true, - "dependencies": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.3.1" - }, "bin": { "crc32": "bin/crc32.njs" }, @@ -6934,7 +7862,7 @@ "node_modules/css-value": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", - "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", + "integrity": "sha512-FUV3xaJ63buRLgHrLQVlVgQnQdR4yqdLGaDu7g8CQcWjInDfM9plBTPI9FRfpahju1UBSaMckeb2/46ApS/V1Q==", "dev": true }, "node_modules/css/node_modules/source-map": { @@ -6946,22 +7874,10 @@ "node": ">=0.10.0" } }, - "node_modules/currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "dev": true, - "dependencies": { - "array-find-index": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", + "integrity": "sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg==", "dev": true }, "node_modules/d": { @@ -6974,19 +7890,10 @@ "type": "^1.0.1" } }, - "node_modules/dargs": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz", - "integrity": "sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "dev": true, "dependencies": { "assert-plus": "^1.0.0" @@ -6996,9 +7903,9 @@ } }, "node_modules/date-format": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.4.tgz", - "integrity": "sha512-/jyf4rhB17ge328HJuJjAcmRtCsGd+NDeAtahRBTaK6vSPR6MO5HlrAit3Nn7dVjaa6sowW0WXt8yQtLyZQFRg==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", + "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", "dev": true, "engines": { "node": ">=4.0" @@ -7007,7 +7914,7 @@ "node_modules/dateformat": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", - "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", + "integrity": "sha512-GODcnWq3YGoTnygPfi02ygEiRxqUxpJwuRHjdhJYuxpcZmDq4rjBiXYmbCCzStxo176ixfLT6i4NPwQooRySnw==", "dev": true, "engines": { "node": "*" @@ -7016,15 +7923,14 @@ "node_modules/de-indent": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", - "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=", + "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", "dev": true, "optional": true }, "node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dependencies": { "ms": "2.1.2" }, @@ -7058,40 +7964,34 @@ } }, "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/decamelize-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "node_modules/decode-named-character-reference": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz", + "integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==", "dev": true, "dependencies": { - "decamelize": "^1.1.0", - "map-obj": "^1.0.0" + "character-entities": "^2.0.0" }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/decamelize-keys/node_modules/map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true, - "engines": { - "node": ">=0.10.0" + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, "node_modules/decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", "dev": true, "engines": { "node": ">=0.10" @@ -7192,25 +8092,28 @@ "node_modules/default-resolution": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz", - "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=", + "integrity": "sha512-2xaP6GiwVwOEbXCGoJ4ufgC76m8cj805jrghScewJC2ZDsb9U0b4BIrba+xt/Uytyd0HvQ6+WymSRTfnYj59GQ==", "dev": true, "engines": { "node": ">= 0.10" } }, "node_modules/defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", "dev": true, "dependencies": { "clone": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/defaults/node_modules/clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", "dev": true, "engines": { "node": ">=0.8" @@ -7226,15 +8129,19 @@ } }, "node_modules/define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", "dev": true, "dependencies": { - "object-keys": "^1.0.12" + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/define-property": { @@ -7250,56 +8157,66 @@ "node": ">=0.10.0" } }, - "node_modules/defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "dev": true, "engines": { "node": ">=0.4.0" } }, "node_modules/depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", "engines": { - "node": ">= 0.6" + "node": ">= 0.8" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "engines": { + "node": ">=6" } }, "node_modules/destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } }, "node_modules/detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/detect-indent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", - "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==", "dev": true, + "dependencies": { + "repeating": "^2.0.0" + }, "engines": { - "node": ">=8" + "node": ">=0.10.0" } }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", "dev": true, "bin": { "detect-libc": "bin/detect-libc.js" @@ -7311,63 +8228,237 @@ "node_modules/detect-newline": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", - "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=", + "integrity": "sha512-CwffZFvlJffUg9zZA0uqrjQayUTC8ob94pnr5sFwaVv3IOmkfUHcWH+jXaQK3askE51Cqe8/9Ql/0uXNwqZ8Zg==", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/detective": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", - "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", - "dev": true, - "dependencies": { - "acorn-node": "^1.6.1", - "defined": "^1.0.0", - "minimist": "^1.1.1" - }, - "bin": { - "detective": "bin/detective.js" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/devtools": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.16.16.tgz", - "integrity": "sha512-M0kzkuSgfEhpqIis3gdtWsNjn/HQ+vRAmEzDnbYx/7FfjFxhSv1d+rOOT20pvd60soItMYpsOova1igACEGkGQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.25.4.tgz", + "integrity": "sha512-R6/S/dCqxoX4Y6PxIGM9JFAuSRZzUeV5r+CoE/frhmno6mTe7dEEgwkJlfit3LkKRoul8n4DsL2A3QtWOvq5IA==", "dev": true, "dependencies": { - "@types/node": "^17.0.4", + "@types/node": "^18.0.0", "@types/ua-parser-js": "^0.7.33", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/protocols": "7.16.7", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.25.4", + "@wdio/logger": "7.19.0", + "@wdio/protocols": "7.22.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", "chrome-launcher": "^0.15.0", "edge-paths": "^2.1.0", "puppeteer-core": "^13.1.3", "query-selector-shadow-dom": "^1.0.0", "ua-parser-js": "^1.0.1", - "uuid": "^8.0.0" + "uuid": "^9.0.0" }, "engines": { "node": ">=12.0.0" } }, "node_modules/devtools-protocol": { - "version": "0.0.973690", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.973690.tgz", - "integrity": "sha512-myh3hSFp0YWa2GED11PmbLhV4dv9RdO7YUz27XJrbQLnP5bMbZL6dfOOILTHO57yH0kX5GfuOZBsg/4NamfPvQ==", + "version": "0.0.1061995", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1061995.tgz", + "integrity": "sha512-pKZZWTjWa/IF4ENCg6GN8bu/AxSZgdhjSa26uc23wz38Blt2Tnm9icOPcSG3Cht55rMq35in1w3rWVPcZ60ArA==", + "dev": true + }, + "node_modules/devtools/node_modules/@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "dev": true + }, + "node_modules/devtools/node_modules/@wdio/config": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.25.4.tgz", + "integrity": "sha512-vb0emDtD9FbFh/yqW6oNdo2iuhQp8XKj6GX9fyy9v4wZgg3B0HPMVJxhIfcoHz7LMBWlHSo9YdvhFI5EQHRLBA==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", + "deepmerge": "^4.0.0", + "glob": "^8.0.3" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/devtools/node_modules/@wdio/logger": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.19.0.tgz", + "integrity": "sha512-xR7SN/kGei1QJD1aagzxs3KMuzNxdT/7LYYx+lt6BII49+fqL/SO+5X0FDCZD0Ds93AuQvvz9eGyzrBI2FFXmQ==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/devtools/node_modules/@wdio/protocols": { + "version": "7.22.0", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.22.0.tgz", + "integrity": "sha512-8EXRR+Ymdwousm/VGtW3H1hwxZ/1g1H99A1lF0U4GuJ5cFWHCd0IVE5H31Z52i8ZruouW8jueMkGZPSo2IIUSQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/devtools/node_modules/@wdio/types": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.25.4.tgz", + "integrity": "sha512-muvNmq48QZCvocctnbe0URq2FjJjUPIG4iLoeMmyF0AQgdbjaUkMkw3BHYNHVTbSOU9WMsr2z8alhj/I2H6NRQ==", + "dev": true, + "dependencies": { + "@types/node": "^18.0.0", + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "typescript": "^4.6.2" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/devtools/node_modules/@wdio/utils": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.25.4.tgz", + "integrity": "sha512-8iwQDk+foUqSzKZKfhLxjlCKOkfRJPNHaezQoevNgnrTq/t0ek+ldZCATezb9B8jprAuP4mgS9xi22akc6RkzA==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "p-iteration": "^1.1.8" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/devtools/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/devtools/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/devtools/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/devtools/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/devtools/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/devtools/node_modules/glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/devtools/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/devtools/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/devtools/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/devtools/node_modules/ua-parser-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz", - "integrity": "sha512-00y/AXhx0/SsnI51fTc0rLRmafiGOM4/O+ny10Ps7f+j/b8p/ZY11ytMgznXkOVo4GQ+KwQG5UQLkLGirsACRg==", + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.33.tgz", + "integrity": "sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==", "dev": true, "funding": [ { @@ -7384,9 +8475,9 @@ } }, "node_modules/devtools/node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "dev": true, "bin": { "uuid": "dist/bin/uuid" @@ -7395,25 +8486,25 @@ "node_modules/di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", + "integrity": "sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA==", "dev": true }, "node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true, "engines": { "node": ">=0.3.1" } }, "node_modules/diff-sequences": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz", - "integrity": "sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", + "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==", "dev": true, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/dlv": { @@ -7446,314 +8537,152 @@ } }, "node_modules/documentation": { - "version": "13.2.5", - "resolved": "https://registry.npmjs.org/documentation/-/documentation-13.2.5.tgz", - "integrity": "sha512-d1TrfrHXYZR63xrOzkYwwe297vkSwBoEhyyMBOi20T+7Ohe1aX1dW4nqXncQmdmE5MxluSaxxa3BW1dCvbF5AQ==", - "dev": true, - "dependencies": { - "@babel/core": "7.12.3", - "@babel/generator": "7.12.1", - "@babel/parser": "7.12.3", - "@babel/traverse": "^7.12.1", - "@babel/types": "^7.12.1", - "ansi-html": "^0.0.7", - "babelify": "^10.0.0", - "chalk": "^2.3.0", - "chokidar": "^3.4.0", - "concat-stream": "^1.6.0", - "diff": "^4.0.1", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/documentation/-/documentation-14.0.1.tgz", + "integrity": "sha512-Y/brACCE3sNnDJPFiWlhXrqGY+NelLYVZShLGse5bT1KdohP4JkPf5T2KNq1YWhIEbDYl/1tebRLC0WYbPQxVw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.18.10", + "@babel/generator": "^7.18.10", + "@babel/parser": "^7.18.11", + "@babel/traverse": "^7.18.11", + "@babel/types": "^7.18.10", + "chalk": "^5.0.1", + "chokidar": "^3.5.3", + "diff": "^5.1.0", "doctrine-temporary-fork": "2.1.0", - "get-port": "^5.0.0", - "git-url-parse": "^11.1.2", - "github-slugger": "1.2.0", - "glob": "^7.1.2", - "globals-docs": "^2.4.0", - "highlight.js": "^10.7.2", - "ini": "^1.3.5", - "js-yaml": "^3.10.0", - "lodash": "^4.17.10", - "mdast-util-find-and-replace": "^1.1.1", + "git-url-parse": "^13.1.0", + "github-slugger": "1.4.0", + "glob": "^8.0.3", + "globals-docs": "^2.4.1", + "highlight.js": "^11.6.0", + "ini": "^3.0.0", + "js-yaml": "^4.1.0", + "konan": "^2.1.1", + "lodash": "^4.17.21", + "mdast-util-find-and-replace": "^2.2.1", "mdast-util-inject": "^1.1.0", - "micromatch": "^3.1.5", - "mime": "^2.2.0", - "module-deps-sortable": "^5.0.3", + "micromark-util-character": "^1.1.0", "parse-filepath": "^1.0.2", - "pify": "^5.0.0", - "read-pkg-up": "^4.0.0", - "remark": "^13.0.0", - "remark-gfm": "^1.0.0", - "remark-html": "^13.0.1", - "remark-reference-links": "^5.0.0", - "remark-toc": "^7.2.0", - "resolve": "^1.8.1", - "stream-array": "^1.1.2", - "strip-json-comments": "^2.0.1", - "tiny-lr": "^1.1.0", - "unist-builder": "^2.0.3", - "unist-util-visit": "^2.0.3", - "vfile": "^4.0.0", - "vfile-reporter": "^6.0.0", - "vfile-sort": "^2.1.0", - "vinyl": "^2.1.0", - "vinyl-fs": "^3.0.2", - "yargs": "^15.3.1" + "pify": "^6.0.0", + "read-pkg-up": "^9.1.0", + "remark": "^14.0.2", + "remark-gfm": "^3.0.1", + "remark-html": "^15.0.1", + "remark-reference-links": "^6.0.1", + "remark-toc": "^8.0.1", + "resolve": "^1.22.1", + "strip-json-comments": "^5.0.0", + "unist-builder": "^3.0.0", + "unist-util-visit": "^4.1.0", + "vfile": "^5.3.4", + "vfile-reporter": "^7.0.4", + "vfile-sort": "^3.0.0", + "yargs": "^17.5.1" }, "bin": { "documentation": "bin/documentation.js" }, "engines": { - "node": ">=10" + "node": ">=14" }, "optionalDependencies": { - "@vue/compiler-sfc": "^3.0.11", - "vue-template-compiler": "^2.6.12" - } - }, - "node_modules/documentation/node_modules/@babel/core": { - "version": "7.12.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.12.3.tgz", - "integrity": "sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/generator": "^7.12.1", - "@babel/helper-module-transforms": "^7.12.1", - "@babel/helpers": "^7.12.1", - "@babel/parser": "^7.12.3", - "@babel/template": "^7.10.4", - "@babel/traverse": "^7.12.1", - "@babel/types": "^7.12.1", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.1", - "json5": "^2.1.2", - "lodash": "^4.17.19", - "resolve": "^1.3.2", - "semver": "^5.4.1", - "source-map": "^0.5.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/documentation/node_modules/@babel/generator": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.1.tgz", - "integrity": "sha512-DB+6rafIdc9o72Yc3/Ph5h+6hUjeOp66pF0naQBgUFFuPqzQwIlPTm3xZR7YNvduIMtkDIj2t21LSQwnbCrXvg==", - "dev": true, - "dependencies": { - "@babel/types": "^7.12.1", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - } - }, - "node_modules/documentation/node_modules/@babel/parser": { - "version": "7.12.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.3.tgz", - "integrity": "sha512-kFsOS0IbsuhO5ojF8Hc8z/8vEIOkylVBrjiZUbLTE3XFe0Qi+uu6HjzQixkFaqr0ZPAMZcBVxEwmsnsLPZ2Xsw==", - "dev": true, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/documentation/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/documentation/node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" + "@vue/compiler-sfc": "^3.2.37", + "vue-template-compiler": "^2.7.8" } }, - "node_modules/documentation/node_modules/color-convert": { + "node_modules/documentation/node_modules/argparse": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/documentation/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/documentation/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/documentation/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "node_modules/documentation/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" + "balanced-match": "^1.0.0" } }, - "node_modules/documentation/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "node_modules/documentation/node_modules/chalk": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.1.2.tgz", + "integrity": "sha512-E5CkT4jWURs1Vy5qGJye+XwCkNj7Od3Af7CP6SujMetSMkLs8Do2RWJK5yx1wamHV/op8Rz+9rltjaTQWDnEFQ==", "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, "engines": { - "node": ">=8" + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/documentation/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "node_modules/documentation/node_modules/glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "dev": true, "dependencies": { - "p-try": "^2.0.0" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": ">=6" + "node": ">=12" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/documentation/node_modules/p-locate": { + "node_modules/documentation/node_modules/js-yaml": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { - "p-limit": "^2.2.0" + "argparse": "^2.0.1" }, - "engines": { - "node": ">=8" - } - }, - "node_modules/documentation/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/documentation/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/documentation/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, "bin": { - "semver": "bin/semver" + "js-yaml": "bin/js-yaml.js" } }, - "node_modules/documentation/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "node_modules/documentation/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" + "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=8" + "node": ">=10" } }, - "node_modules/documentation/node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true - }, "node_modules/documentation/node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", "dev": true, "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/documentation/node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.0.0" }, "engines": { - "node": ">=6" + "node": ">=12" } }, "node_modules/dom-serialize": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", + "integrity": "sha512-Yra4DbvoW7/Z6LBN560ZwXMjoNOSAN2wRsKFGc4iBeso+mpIA6qj1vfdf9HpMaKAqG6wXTy+1SYEzmNpKXOSsQ==", "dev": true, "dependencies": { "custom-event": "~1.0.0", @@ -7762,97 +8691,16 @@ "void-elements": "^2.0.0" } }, - "node_modules/dot-prop": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", - "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", - "dev": true, - "dependencies": { - "is-obj": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/dotgitignore": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/dotgitignore/-/dotgitignore-2.1.0.tgz", - "integrity": "sha512-sCm11ak2oY6DglEPpCB8TixLjWAxd3kJTs6UIcSasNYxXdFPV+YKlye92c8H4kKFqV5qYMIh7d+cYecEg0dIkA==", - "dev": true, - "dependencies": { - "find-up": "^3.0.0", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/dotgitignore/node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "dependencies": { - "locate-path": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/dotgitignore/node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/dotgitignore/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/dotgitignore/node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "dependencies": { - "p-limit": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/dotgitignore/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } + "node_modules/dom-walk": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", + "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==", + "dev": true }, "node_modules/dset": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/dset/-/dset-2.0.1.tgz", - "integrity": "sha512-nI29OZMRYq36hOcifB6HTjajNAAiBKSXsyWZrq+VniusseuP2OpNlTiYgsaNRSGvpyq5Wjbc2gQLyBdTyWqhnQ==", - "deprecated": "Please use dset@2.1.0 or later for an important security patch", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.2.tgz", + "integrity": "sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==", "engines": { "node": ">=4" } @@ -7864,14 +8712,38 @@ "dev": true }, "node_modules/duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha512-+AWBwjGadtksxjOQSFDhPNQbed7icNXApT4+2BNpsXzcCBiInq2H9XW0O8sfHFaPmnQRs7cg/P0fAr2IWQSW0g==", "dev": true, "dependencies": { - "readable-stream": "^2.0.2" + "readable-stream": "~1.1.9" + } + }, + "node_modules/duplexer2/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true + }, + "node_modules/duplexer2/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" } }, + "node_modules/duplexer2/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "dev": true + }, "node_modules/duplexify": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz", @@ -7920,6 +8792,12 @@ "node": ">=0.10.0" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "node_modules/easy-table": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/easy-table/-/easy-table-1.2.0.tgz", @@ -7935,7 +8813,7 @@ "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", "dev": true, "dependencies": { "jsbn": "~0.1.0", @@ -7955,15 +8833,15 @@ "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/ejs": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz", - "integrity": "sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz", + "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==", "dev": true, "dependencies": { - "jake": "^10.6.1" + "jake": "^10.8.5" }, "bin": { "ejs": "bin/cli.js" @@ -7973,15 +8851,14 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.78", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.78.tgz", - "integrity": "sha512-o61+D/Lx7j/E0LIin/efOqeHpXhwi1TaQco9vUcRmr91m25SfZY6L5hWJDv/r+6kNjboFKgBw1LbfM0lbhuK6Q==", - "dev": true + "version": "1.4.284", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", + "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, "node_modules/emoji-regex": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz", - "integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4=", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "node_modules/emojis-list": { @@ -7996,7 +8873,7 @@ "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "engines": { "node": ">= 0.8" } @@ -8011,9 +8888,9 @@ } }, "node_modules/engine.io": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.3.tgz", - "integrity": "sha512-rqs60YwkvWTLLnfazqgZqLa/aKo+9cueVfEi/dZ8PyGyaf8TLOxj++4QMIgeG3Gn0AhrWiFXvghsoY9L9h25GA==", + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.2.tgz", + "integrity": "sha512-FKn/3oMiJjrOEOeUub2WCox6JhxBXq/Zn3fZOMCBxKnNYtsdKjxhl7yR3fZhM9PV+rdE75SU5SYMc+2PGzo+Tg==", "dev": true, "dependencies": { "@types/cookie": "^0.4.1", @@ -8025,28 +8902,34 @@ "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.0.3", - "ws": "~8.2.3" + "ws": "~8.11.0" }, "engines": { "node": ">=10.0.0" } }, "node_modules/engine.io-parser": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.3.tgz", - "integrity": "sha512-BtQxwF27XUNnSafQLvDi0dQ8s3i6VgzSoQMJacpIcGNrlUdfHSKbgm3jmjCVvQluGzqwujQMPAoMai3oYSTurg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.6.tgz", + "integrity": "sha512-tjuoZDMAdEhVnSFleYPCtdL2GXwVTGtNjoeJd9IhIG3C1xs9uwxqRNEu5WpnDZCaozwVlK/nuQhpodhXSIMaxw==", "dev": true, - "dependencies": { - "@socket.io/base64-arraybuffer": "~1.0.2" - }, "engines": { "node": ">=10.0.0" } }, + "node_modules/engine.io/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/enhanced-resolve": { - "version": "5.9.2", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz", - "integrity": "sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA==", + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", + "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==", "dev": true, "dependencies": { "graceful-fs": "^4.2.4", @@ -8071,7 +8954,7 @@ "node_modules/ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", - "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", + "integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==", "dev": true }, "node_modules/errno": { @@ -8105,31 +8988,35 @@ } }, "node_modules/es-abstract": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", - "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz", + "integrity": "sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA==", "dev": true, "dependencies": { "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.1.3", "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.2", + "has-property-descriptors": "^1.0.0", + "has-symbols": "^1.0.3", "internal-slot": "^1.0.3", - "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.1", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.1", + "is-shared-array-buffer": "^1.0.2", "is-string": "^1.0.7", - "is-weakref": "^1.0.1", - "object-inspect": "^1.11.0", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.2", "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.4.3", + "safe-regex-test": "^1.0.0", + "string.prototype.trimend": "^1.0.5", + "string.prototype.trimstart": "^1.0.5", + "unbox-primitive": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -8163,6 +9050,15 @@ "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", "dev": true }, + "node_modules/es-shim-unscopables": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", + "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + } + }, "node_modules/es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", @@ -8181,9 +9077,9 @@ } }, "node_modules/es5-ext": { - "version": "0.10.57", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.57.tgz", - "integrity": "sha512-L7cCNoPwTkAp7IBHxrKLsh7NKiVFkcdxlP9vbVw9QUvb7gF0Mz9bEBN0WY9xqdTjGF907EMT/iG013vnbqwu1Q==", + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -8196,9 +9092,9 @@ } }, "node_modules/es5-shim": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.6.5.tgz", - "integrity": "sha512-vfQ4UAai8szn0sAubCy97xnZ4sJVDD1gt/Grn736hg8D7540wemIb1YPrYZSTqlM2H69EQX1or4HU/tSwRTI3w==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.6.7.tgz", + "integrity": "sha512-jg21/dmlrNQI7JyyA2w7n+yifSxBng0ZralnSfVZjoCawgNTCnS+yBCyVM9DL5itm7SUnDGgv7hcq2XCZX4iRQ==", "dev": true, "engines": { "node": ">=0.4.0" @@ -8207,7 +9103,7 @@ "node_modules/es6-iterator": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", "dev": true, "dependencies": { "d": "1", @@ -8218,7 +9114,7 @@ "node_modules/es6-object-assign": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", - "integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=", + "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==", "dev": true }, "node_modules/es6-promise": { @@ -8230,7 +9126,7 @@ "node_modules/es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", "dev": true, "dependencies": { "es6-promise": "^4.0.3" @@ -8262,7 +9158,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true, "engines": { "node": ">=6" } @@ -8270,13 +9165,12 @@ "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "engines": { "node": ">=0.8.0" } @@ -8284,7 +9178,7 @@ "node_modules/escodegen": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", - "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "integrity": "sha512-yhi5S+mNTOuRvyW4gWlg5W1byMaQGWWSYHXsuFZ7GBo7tpyOwi2EdzMP/QWxh9hwkD2m+wDVHJsxhRIj+v/b/A==", "dev": true, "dependencies": { "esprima": "^2.7.1", @@ -8306,7 +9200,7 @@ "node_modules/escodegen/node_modules/estraverse": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", - "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "integrity": "sha512-25w1fMXQrGdoquWnScXZGckOv+Wes+JDnuN/+7ex3SauFRS72r2lFDec0EKPt2YD1wUJ/IrfEex+9yp4hfSOJA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -8315,7 +9209,7 @@ "node_modules/escodegen/node_modules/levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", "dev": true, "dependencies": { "prelude-ls": "~1.1.2", @@ -8345,7 +9239,7 @@ "node_modules/escodegen/node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", "dev": true, "engines": { "node": ">= 0.8.0" @@ -8354,7 +9248,7 @@ "node_modules/escodegen/node_modules/source-map": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", - "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "integrity": "sha512-CBdZ2oa/BHhS4xj5DlhjWNHcan57/5YuvfdLf17iVmIpd9KRm+DFLmC6nBNj+6Ua7Kt3TmOjDpQT1aTYOQtoUA==", "dev": true, "optional": true, "dependencies": { @@ -8367,7 +9261,7 @@ "node_modules/escodegen/node_modules/type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", "dev": true, "dependencies": { "prelude-ls": "~1.1.2" @@ -8436,7 +9330,7 @@ "node_modules/eslint-config-standard": { "version": "10.2.1", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz", - "integrity": "sha1-wGHk0GbzedwXzVYsZOgZtN1FRZE=", + "integrity": "sha512-UkFojTV1o0GOe1edOEiuI5ccYLJSuNngtqSeClNzhsmG8KPJ+7mRxgtp2oYhqZAK/brlXMoCd+VgXViE0AfyKw==", "dev": true, "peerDependencies": { "eslint": ">=3.19.0", @@ -8466,16 +9360,20 @@ } }, "node_modules/eslint-module-utils": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", - "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", + "integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==", "dev": true, "dependencies": { - "debug": "^3.2.7", - "find-up": "^2.1.0" + "debug": "^3.2.7" }, "engines": { "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } } }, "node_modules/eslint-module-utils/node_modules/debug": { @@ -8507,9 +9405,9 @@ } }, "node_modules/eslint-plugin-import": { - "version": "2.25.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz", - "integrity": "sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", "dev": true, "dependencies": { "array-includes": "^3.1.4", @@ -8517,14 +9415,14 @@ "debug": "^2.6.9", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.2", + "eslint-module-utils": "^2.7.3", "has": "^1.0.3", - "is-core-module": "^2.8.0", + "is-core-module": "^2.8.1", "is-glob": "^4.0.3", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "object.values": "^1.1.5", - "resolve": "^1.20.0", - "tsconfig-paths": "^3.12.0" + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" }, "engines": { "node": ">=4" @@ -8557,7 +9455,7 @@ "node_modules/eslint-plugin-import/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/eslint-plugin-node": { @@ -8669,22 +9567,6 @@ "@babel/highlight": "^7.10.4" } }, - "node_modules/eslint/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -8747,9 +9629,9 @@ } }, "node_modules/eslint/node_modules/globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -8761,10 +9643,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/eslint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/eslint/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -8838,7 +9729,7 @@ "node_modules/esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "integrity": "sha512-OarPfz0lFCiW4/AV2Oy1Rp9qu0iusTKqykwTspGCZtPxmF81JR4MmIebvF1F9+UOKth2ZubLQ4XGGaU+hSn99A==", "dev": true, "bin": { "esparse": "bin/esparse.js", @@ -8910,7 +9801,6 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -8918,7 +9808,7 @@ "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "engines": { "node": ">= 0.6" } @@ -8926,7 +9816,7 @@ "node_modules/event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", "dev": true, "dependencies": { "d": "1", @@ -8936,7 +9826,7 @@ "node_modules/event-stream": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "integrity": "sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==", "dev": true, "dependencies": { "duplexer": "~0.1.1", @@ -8951,7 +9841,7 @@ "node_modules/event-stream/node_modules/map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "integrity": "sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==", "dev": true }, "node_modules/eventemitter3": { @@ -9006,16 +9896,16 @@ "node_modules/execa/node_modules/path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", "dev": true, "engines": { "node": ">=4" } }, "node_modules/execa/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -9024,7 +9914,7 @@ "node_modules/execa/node_modules/shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", "dev": true, "dependencies": { "shebang-regex": "^1.0.0" @@ -9036,7 +9926,7 @@ "node_modules/execa/node_modules/shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -9054,19 +9944,10 @@ "which": "bin/which" } }, - "node_modules/exit-on-epipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", - "dev": true, - "engines": { - "node": ">=0.8" - } - }, "node_modules/expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "integrity": "sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==", "dev": true, "dependencies": { "debug": "^2.3.3", @@ -9093,7 +9974,7 @@ "node_modules/expand-brackets/node_modules/define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "dependencies": { "is-descriptor": "^0.1.0" @@ -9105,7 +9986,7 @@ "node_modules/expand-brackets/node_modules/extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "dependencies": { "is-extendable": "^0.1.0" @@ -9117,7 +9998,7 @@ "node_modules/expand-brackets/node_modules/is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -9129,7 +10010,7 @@ "node_modules/expand-brackets/node_modules/is-accessor-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -9147,7 +10028,7 @@ "node_modules/expand-brackets/node_modules/is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -9159,7 +10040,7 @@ "node_modules/expand-brackets/node_modules/is-data-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -9185,7 +10066,7 @@ "node_modules/expand-brackets/node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -9194,13 +10075,13 @@ "node_modules/expand-brackets/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==", "dev": true, "dependencies": { "homedir-polyfill": "^1.0.1" @@ -9210,62 +10091,98 @@ } }, "node_modules/expect": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-27.5.1.tgz", - "integrity": "sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-26.6.2.tgz", + "integrity": "sha512-9/hlOBkQl2l/PLHJx6JjoDF6xPKcJEsUlWKb23rKE7KzeDqUZKXKNMW27KIue5JMdBV9HgmoJPcc8HtO85t9IA==", "dev": true, "dependencies": { - "@jest/types": "^27.5.1", - "jest-get-type": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1" + "@jest/types": "^26.6.2", + "ansi-styles": "^4.0.0", + "jest-get-type": "^26.3.0", + "jest-matcher-utils": "^26.6.2", + "jest-message-util": "^26.6.2", + "jest-regex-util": "^26.0.0" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/expect-webdriverio": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/expect-webdriverio/-/expect-webdriverio-3.1.4.tgz", - "integrity": "sha512-65FTS3bmxcIp0cq6fLb/72TrCQXBCpwPLC7SwMWdpPlLq461mXcK1BPKJJjnIC587aXSKD+3E4hvnlCtwDmXfg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expect-webdriverio/-/expect-webdriverio-2.0.2.tgz", + "integrity": "sha512-dst0tqP1aZ2p7TPmbatqoIQ+7hRTw+IeKNi830XxKhu2DNNe5vQ85i9ttf9rpXgbnUf91HxKcocn4G7A5bQxDA==", + "dev": true, + "dependencies": { + "expect": "^26.6.2", + "jest-matcher-utils": "^26.6.2" + } + }, + "node_modules/expect/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { - "expect": "^27.0.2", - "jest-matcher-utils": "^27.0.2" + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/expect/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/expect/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "node_modules/express": { - "version": "4.17.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.3.tgz", - "integrity": "sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg==", + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.19.2", + "body-parser": "1.20.1", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.2", + "cookie": "0.5.0", "cookie-signature": "1.0.6", "debug": "2.6.9", - "depd": "~1.1.2", + "depd": "2.0.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "~1.1.2", + "finalhandler": "1.2.0", "fresh": "0.5.2", + "http-errors": "2.0.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", "proxy-addr": "~2.0.7", - "qs": "6.9.7", + "qs": "6.11.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.17.2", - "serve-static": "1.14.2", + "send": "0.18.0", + "serve-static": "1.15.0", "setprototypeof": "1.2.0", - "statuses": "~1.5.0", + "statuses": "2.0.1", "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" @@ -9285,40 +10202,21 @@ "node_modules/express/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "node_modules/express/node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/ext": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", "dev": true, "dependencies": { - "type": "^2.5.0" + "type": "^2.7.2" } }, "node_modules/ext/node_modules/type": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz", - "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==", + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==", "dev": true }, "node_modules/extend": { @@ -9328,18 +10226,26 @@ "dev": true }, "node_modules/extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz", + "integrity": "sha512-L7AGmkO6jhDkEBBGWlLtftA80Xq8DipnrRPr0pyi7GQLXkaq9JYA4xF4z6qnadIC6euiTDKco0cGSU9muw+WTw==", "dev": true, "dependencies": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" + "kind-of": "^1.1.0" }, "engines": { "node": ">=0.10.0" } }, + "node_modules/extend-shallow/node_modules/kind-of": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "integrity": "sha512-aUH6ElPnMGon2/YkxRIigV32MOpTVcoXQ1Oo8aYn40s+sJ3j+0gFZsT8HKDcxNy7Fi9zuquWtGaGAahOdv5p/g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -9376,7 +10282,7 @@ "node_modules/extglob/node_modules/define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "dependencies": { "is-descriptor": "^1.0.0" @@ -9388,7 +10294,7 @@ "node_modules/extglob/node_modules/extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "dependencies": { "is-extendable": "^0.1.0" @@ -9400,7 +10306,7 @@ "node_modules/extglob/node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -9444,7 +10350,7 @@ "node_modules/extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", "dev": true, "engines": [ "node >=0.6.0" @@ -9486,13 +10392,13 @@ "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "node_modules/faye-websocket": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", - "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=", + "integrity": "sha512-Xhj93RXbMSq8urNCUq4p9l0P6hnySJ/7YNRhYNug0bLOuii7pKO7xQFb5mx9xZXWCar88pLPb805PvUkwrLZpQ==", "dev": true, "dependencies": { "websocket-driver": ">=0.5.1" @@ -9504,16 +10410,16 @@ "node_modules/fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", "dev": true, "dependencies": { "pend": "~1.2.0" } }, "node_modules/fibers": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.1.tgz", - "integrity": "sha512-VMC7Frt87Oo0AOJ6EcPFbi+tZmkQ4tD85aatwyWL6I9cYMJmm2e+pXUJsfGZ36U7MffXtjou2XIiWJMtHriErw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.3.tgz", + "integrity": "sha512-/qYTSoZydQkM21qZpGLDLuCq8c+B8KhuCQ1kLPvnRNhxhVbvrpmH9l2+Lblf5neDuEsY4bfT7LeO553TXQDvJw==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -9558,12 +10464,33 @@ "optional": true }, "node_modules/filelist": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz", - "integrity": "sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", "dev": true, "dependencies": { - "minimatch": "^3.0.4" + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" } }, "node_modules/fill-range": { @@ -9578,26 +10505,17 @@ "node": ">=8" } }, - "node_modules/filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "dependencies": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", - "statuses": "~1.5.0", + "statuses": "2.0.1", "unpipe": "~1.0.0" }, "engines": { @@ -9615,7 +10533,7 @@ "node_modules/finalhandler/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/find-cache-dir": { "version": "3.3.2", @@ -9635,15 +10553,16 @@ } }, "node_modules/find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, "dependencies": { - "locate-path": "^2.0.0" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" }, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/findup-sync": { @@ -9661,6 +10580,182 @@ "node": ">= 0.10" } }, + "node_modules/findup-sync/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "dependencies": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/braces/node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/braces/node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", + "dev": true, + "dependencies": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/fill-range/node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/fill-range/node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "node_modules/findup-sync/node_modules/is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "dependencies": { + "kind-of": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/is-number/node_modules/kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "dependencies": { + "is-buffer": "^1.1.5" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "dependencies": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/findup-sync/node_modules/to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", + "dev": true, + "dependencies": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/fined": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", @@ -9721,9 +10816,9 @@ } }, "node_modules/flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, "node_modules/flush-write-stream": { @@ -9737,9 +10832,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true, "funding": [ { @@ -9756,10 +10851,19 @@ } } }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, "node_modules/for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -9768,7 +10872,7 @@ "node_modules/for-own": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==", "dev": true, "dependencies": { "for-in": "^1.0.1" @@ -9777,22 +10881,16 @@ "node": ">=0.10.0" } }, - "node_modules/foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, "node_modules/foreachasync": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/foreachasync/-/foreachasync-3.0.0.tgz", - "integrity": "sha1-VQKYfchxS+M5IJfzLgBxyd7gfPY=", + "integrity": "sha512-J+ler7Ta54FwwNcx6wQRDhTIbNeyDcARMkOcguEqnEdtm0jKvN3Li3PDAb2Du3ubJYEWfYL83XMROXdsXAXycw==", "dev": true }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", "dev": true, "engines": { "node": "*" @@ -9801,7 +10899,7 @@ "node_modules/fork-stream": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/fork-stream/-/fork-stream-0.0.4.tgz", - "integrity": "sha1-24Sfznf2cIpfjzhq5TOgkHtUrnA=", + "integrity": "sha512-Pqq5NnT78ehvUnAk/We/Jr22vSvanRlFTpAmQ88xBY/M1TlHe+P0ILuEyXS595ysdGfaj22634LBkGMA2GTcpA==", "dev": true }, "node_modules/form-data": { @@ -9829,7 +10927,7 @@ "node_modules/fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "integrity": "sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==", "dev": true, "dependencies": { "map-cache": "^0.2.2" @@ -9841,7 +10939,7 @@ "node_modules/fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", "engines": { "node": ">= 0.6" } @@ -9849,21 +10947,9 @@ "node_modules/from": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "integrity": "sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==", "dev": true }, - "node_modules/fs-access": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", - "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", - "dev": true, - "dependencies": { - "null-check": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -9871,9 +10957,9 @@ "dev": true }, "node_modules/fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, "dependencies": { "graceful-fs": "^4.2.0", @@ -9887,7 +10973,7 @@ "node_modules/fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", - "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", + "integrity": "sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==", "dev": true, "dependencies": { "graceful-fs": "^4.1.11", @@ -9910,7 +10996,7 @@ "node_modules/fs.extra": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fs.extra/-/fs.extra-1.3.2.tgz", - "integrity": "sha1-3QI/kwE77iRTHxszUUw3sg/ZM0k=", + "integrity": "sha512-Ig401VXtyrWrz23k9KxAx9OrnL8AHSLNhQ8YJH2wSYuH0ZUfxwBeY6zXkd/oOyVRFTlpEu/0n5gHeuZt7aqbkw==", "dev": true, "dependencies": { "fs-extra": "~0.6.1", @@ -9924,7 +11010,7 @@ "node_modules/fs.extra/node_modules/fs-extra": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.6.4.tgz", - "integrity": "sha1-9G8MdbeEH40gCzNIzU1pHVoJnRU=", + "integrity": "sha512-5rU898vl/Z948L+kkJedbmo/iltzmiF5bn/eEk0j/SgrPpI+Ydau9xlJPicV7Av2CHYBGz5LAlwTnBU80j1zPQ==", "dev": true, "dependencies": { "jsonfile": "~1.0.1", @@ -9936,20 +11022,20 @@ "node_modules/fs.extra/node_modules/jsonfile": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-1.0.1.tgz", - "integrity": "sha1-6l7+QLg2kLmGZ2FKc5L8YOhCwN0=", + "integrity": "sha512-KbsDJNRfRPF5v49tMNf9sqyyGqGLBcz1v5kZT01kG5ns5mQSltwxCKVmUzVKtEinkUnTDtSrp6ngWpV7Xw0ZlA==", "dev": true }, "node_modules/fs.extra/node_modules/mkdirp": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", - "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=", + "integrity": "sha512-8OCq0De/h9ZxseqzCH8Kw/Filf5pF/vMI6+BH7Lu0jXz2pqYCjTAQRolSxRIi+Ax+oCCjlxoJMP0YQ4XlrQNHg==", "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", "dev": true }, "node_modules/fs.extra/node_modules/rimraf": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", + "integrity": "sha512-R5KMKHnPAQaZMqLOsyuyUmcIjSeDm+73eoqQpaXA7AZ22BL+6C+1mcUscgOsNd8WVlJuvlgAPsegcx7pjlV0Dg==", "dev": true, "bin": { "rimraf": "bin.js" @@ -9958,7 +11044,7 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "node_modules/fsevents": { @@ -9990,12 +11076,12 @@ } }, "node_modules/fstream/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" }, "bin": { "mkdirp": "bin/cmd.js" @@ -10024,15 +11110,41 @@ "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gaze": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.3.tgz", @@ -10049,7 +11161,6 @@ "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true, "engines": { "node": ">=6.9.0" } @@ -10066,91 +11177,32 @@ "node_modules/get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", "dev": true, "engines": { "node": "*" } }, "node_modules/get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.3" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-pkg-repo": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-4.2.1.tgz", - "integrity": "sha512-2+QbHjFRfGB74v/pYWjd5OhU3TDIC2Gv/YKUTk/tCvAz0pkn/Mz6P3uByuBimLOcPvN2jYdScl3xGFSrx0jEcA==", - "dev": true, - "dependencies": { - "@hutson/parse-repository-url": "^3.0.0", - "hosted-git-info": "^4.0.0", - "through2": "^2.0.0", - "yargs": "^16.2.0" - }, - "bin": { - "get-pkg-repo": "src/cli.js" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/get-pkg-repo/node_modules/hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/get-pkg-repo/node_modules/through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "dependencies": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, - "node_modules/get-pkg-repo/node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/get-pkg-repo/node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", "dev": true, "engines": { - "node": ">=10" + "node": ">=8.0.0" } }, "node_modules/get-port": { @@ -10165,15 +11217,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -10205,7 +11248,7 @@ "node_modules/get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -10214,139 +11257,47 @@ "node_modules/getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", "dev": true, "dependencies": { "assert-plus": "^1.0.0" } }, - "node_modules/git-raw-commits": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-2.0.11.tgz", - "integrity": "sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A==", - "dev": true, - "dependencies": { - "dargs": "^7.0.0", - "lodash": "^4.17.15", - "meow": "^8.0.0", - "split2": "^3.0.0", - "through2": "^4.0.0" - }, - "bin": { - "git-raw-commits": "cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/git-raw-commits/node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/git-raw-commits/node_modules/split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "dev": true, - "dependencies": { - "readable-stream": "^3.0.0" - } - }, - "node_modules/git-remote-origin-url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz", - "integrity": "sha1-UoJlna4hBxRaERJhEq0yFuxfpl8=", - "dev": true, - "dependencies": { - "gitconfiglocal": "^1.0.0", - "pify": "^2.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/git-remote-origin-url/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/git-semver-tags": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-4.1.1.tgz", - "integrity": "sha512-OWyMt5zBe7xFs8vglMmhM9lRQzCWL3WjHtxNNfJTMngGym7pC1kh8sP6jevfydJ6LP3ZvGxfb6ABYgPUM0mtsA==", - "dev": true, - "dependencies": { - "meow": "^8.0.0", - "semver": "^6.0.0" - }, - "bin": { - "git-semver-tags": "cli.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/git-up": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/git-up/-/git-up-4.0.5.tgz", - "integrity": "sha512-YUvVDg/vX3d0syBsk/CKUTib0srcQME0JyHkL5BaYdwLsiCslPWmDSi8PUMo9pXYjrryMcmsCoCgsTpSCJEQaA==", - "dev": true, - "dependencies": { - "is-ssh": "^1.3.0", - "parse-url": "^6.0.0" - } - }, - "node_modules/git-url-parse": { - "version": "11.6.0", - "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-11.6.0.tgz", - "integrity": "sha512-WWUxvJs5HsyHL6L08wOusa/IXYtMuCAhrMmnTjQPpBU0TTHyDhnOATNH3xNQz7YOQUsqIIPTGr4xiVti1Hsk5g==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", + "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==", "dev": true, "dependencies": { - "git-up": "^4.0.0" + "is-ssh": "^1.4.0", + "parse-url": "^8.1.0" } }, - "node_modules/gitconfiglocal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz", - "integrity": "sha1-QdBF84UaXqiPA/JMocYXgRRGS5s=", + "node_modules/git-url-parse": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-13.1.0.tgz", + "integrity": "sha512-5FvPJP/70WkIprlUZ33bm4UAaFdjcLkJLpWft1BeZKqwR0uhhNGoKwlUaPtVb4LxCSQ++erHapRak9kWGj+FCA==", "dev": true, "dependencies": { - "ini": "^1.3.2" + "git-up": "^7.0.0" } }, "node_modules/github-slugger": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.2.0.tgz", - "integrity": "sha512-wIaa75k1vZhyPm9yWrD08A5Xnx/V+RmzGrpjQuLemGKSb77Qukiaei58Bogrl/LZSADDfPzKJX8jhLs4CRTl7Q==", - "dev": true, - "dependencies": { - "emoji-regex": ">=6.0.0 <=6.1.1" - } + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.4.0.tgz", + "integrity": "sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ==", + "dev": true }, "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" }, @@ -10372,7 +11323,7 @@ "node_modules/glob-stream": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", - "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", + "integrity": "sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw==", "dev": true, "dependencies": { "extend": "^3.0.0", @@ -10393,7 +11344,7 @@ "node_modules/glob-stream/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "dependencies": { "is-glob": "^3.1.0", @@ -10403,7 +11354,7 @@ "node_modules/glob-stream/node_modules/is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "dependencies": { "is-extglob": "^2.1.0" @@ -10449,7 +11400,7 @@ "node_modules/glob-watcher/node_modules/anymatch/node_modules/normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "dependencies": { "remove-trailing-separator": "^1.0.1" @@ -10458,6 +11409,15 @@ "node": ">=0.10.0" } }, + "node_modules/glob-watcher/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/glob-watcher/node_modules/binary-extensions": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", @@ -10514,7 +11474,7 @@ "node_modules/glob-watcher/node_modules/extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "dependencies": { "is-extendable": "^0.1.0" @@ -10526,7 +11486,7 @@ "node_modules/glob-watcher/node_modules/fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", "dev": true, "dependencies": { "extend-shallow": "^2.0.1", @@ -10560,7 +11520,7 @@ "node_modules/glob-watcher/node_modules/glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "dependencies": { "is-glob": "^3.1.0", @@ -10570,7 +11530,7 @@ "node_modules/glob-watcher/node_modules/glob-parent/node_modules/is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "dependencies": { "is-extglob": "^2.1.0" @@ -10582,7 +11542,7 @@ "node_modules/glob-watcher/node_modules/is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "integrity": "sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==", "dev": true, "dependencies": { "binary-extensions": "^1.0.0" @@ -10591,10 +11551,110 @@ "node": ">=0.10.0" } }, + "node_modules/glob-watcher/node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, "node_modules/glob-watcher/node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "dependencies": { + "kind-of": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "dependencies": { + "is-buffer": "^1.1.5" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "dependencies": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/micromatch/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/micromatch/node_modules/is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "dependencies": { + "is-plain-object": "^2.0.4" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/glob-watcher/node_modules/micromatch/node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -10617,7 +11677,7 @@ "node_modules/glob-watcher/node_modules/to-regex-range": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", "dev": true, "dependencies": { "is-number": "^3.0.0", @@ -10627,6 +11687,16 @@ "node": ">=0.10.0" } }, + "node_modules/global": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", + "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "dev": true, + "dependencies": { + "min-document": "^2.19.0", + "process": "^0.11.10" + } + }, "node_modules/global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", @@ -10644,7 +11714,7 @@ "node_modules/global-prefix": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==", "dev": true, "dependencies": { "expand-tilde": "^2.0.2", @@ -10657,6 +11727,12 @@ "node": ">=0.10.0" } }, + "node_modules/global-prefix/node_modules/ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "dev": true + }, "node_modules/global-prefix/node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -10673,7 +11749,6 @@ "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true, "engines": { "node": ">=4" } @@ -10685,13 +11760,13 @@ "dev": true }, "node_modules/globule": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.3.tgz", - "integrity": "sha512-mb1aYtDbIjTu4ShMB85m3UzjX9BVKe9WCzsnfMSZk+K5GpIbBOexgg4PPCt5eHDEG5/ZQAUX2Kct02zfiPLsKg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.4.tgz", + "integrity": "sha512-OPTIfhMBh7JbBYDpa5b+Q5ptmMWKwcNcFSR/0c6t8V4f3ZAVBEsKNY37QdVqmLRYSMhOUGYrY0QhSoEpzGr/Eg==", "dev": true, "dependencies": { "glob": "~7.1.1", - "lodash": "~4.17.10", + "lodash": "^4.17.21", "minimatch": "~3.0.2" }, "engines": { @@ -10743,9 +11818,9 @@ } }, "node_modules/got": { - "version": "11.8.3", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz", - "integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==", + "version": "11.8.5", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz", + "integrity": "sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==", "dev": true, "dependencies": { "@sindresorhus/is": "^4.0.0", @@ -10768,9 +11843,9 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, "node_modules/grapheme-splitter": { @@ -10807,384 +11882,19 @@ } }, "node_modules/gulp-clean": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/gulp-clean/-/gulp-clean-0.3.2.tgz", - "integrity": "sha1-o0fUc6zqQBgvk1WHpFGUFnGSgQI=", - "dev": true, - "dependencies": { - "gulp-util": "^2.2.14", - "rimraf": "^2.2.8", - "through2": "^0.4.2" - }, - "engines": { - "node": ">=0.9" - } - }, - "node_modules/gulp-clean/node_modules/ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/ansi-styles": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "dependencies": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/chalk": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", - "dev": true, - "dependencies": { - "ansi-styles": "^1.1.0", - "escape-string-regexp": "^1.0.0", - "has-ansi": "^0.1.0", - "strip-ansi": "^0.3.0", - "supports-color": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "node_modules/gulp-clean/node_modules/dateformat": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", - "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", - "dev": true, - "dependencies": { - "get-stdin": "^4.0.1", - "meow": "^3.3.0" - }, - "bin": { - "dateformat": "bin/cli.js" - }, - "engines": { - "node": "*" - } - }, - "node_modules/gulp-clean/node_modules/find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "dependencies": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/gulp-util": { - "version": "2.2.20", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz", - "integrity": "sha1-1xRuVyiRC9jwR6awseVJvCLb1kw=", - "deprecated": "gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5", - "dev": true, - "dependencies": { - "chalk": "^0.5.0", - "dateformat": "^1.0.7-1.2.3", - "lodash._reinterpolate": "^2.4.1", - "lodash.template": "^2.4.1", - "minimist": "^0.2.0", - "multipipe": "^0.1.0", - "through2": "^0.5.0", - "vinyl": "^0.2.1" - }, - "engines": { - "node": ">= 0.9" - } - }, - "node_modules/gulp-clean/node_modules/gulp-util/node_modules/through2": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", - "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", - "dev": true, - "dependencies": { - "readable-stream": "~1.0.17", - "xtend": "~3.0.0" - } - }, - "node_modules/gulp-clean/node_modules/gulp-util/node_modules/xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", - "dev": true, - "engines": { - "node": ">=0.4" - } - }, - "node_modules/gulp-clean/node_modules/has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", - "dev": true, - "dependencies": { - "ansi-regex": "^0.2.0" - }, - "bin": { - "has-ansi": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "dependencies": { - "repeating": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/gulp-clean/node_modules/load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/lodash._reinterpolate": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz", - "integrity": "sha1-TxInqlqHEfxjL1sHofRgequLMiI=", - "dev": true - }, - "node_modules/gulp-clean/node_modules/lodash.defaults": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-2.4.1.tgz", - "integrity": "sha1-p+iIXwXmiFEUS24SqPNngCa8TFQ=", - "dev": true, - "dependencies": { - "lodash._objecttypes": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, - "node_modules/gulp-clean/node_modules/lodash.template": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz", - "integrity": "sha1-nmEQB+32KRKal0qzxIuBez4c8g0=", - "dev": true, - "dependencies": { - "lodash._escapestringchar": "~2.4.1", - "lodash._reinterpolate": "~2.4.1", - "lodash.defaults": "~2.4.1", - "lodash.escape": "~2.4.1", - "lodash.keys": "~2.4.1", - "lodash.templatesettings": "~2.4.1", - "lodash.values": "~2.4.1" - } - }, - "node_modules/gulp-clean/node_modules/lodash.templatesettings": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz", - "integrity": "sha1-6nbHXRHrhtTb6JqDiTu4YZKaxpk=", - "dev": true, - "dependencies": { - "lodash._reinterpolate": "~2.4.1", - "lodash.escape": "~2.4.1" - } - }, - "node_modules/gulp-clean/node_modules/map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "dependencies": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/meow/node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - }, - "node_modules/gulp-clean/node_modules/minimist": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.1.tgz", - "integrity": "sha512-GY8fANSrTMfBVfInqJAY41QkOM+upUTytK1jZ0c8+3HdHrJxBJ3rF5i9moClXTE8uUSnUo8cAsCoxDXvSY4DHg==", - "dev": true - }, - "node_modules/gulp-clean/node_modules/object-keys": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true - }, - "node_modules/gulp-clean/node_modules/parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "dependencies": { - "error-ex": "^1.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "dependencies": { - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "dependencies": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "dependencies": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/gulp-clean/node_modules/redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", + "resolved": "https://registry.npmjs.org/gulp-clean/-/gulp-clean-0.4.0.tgz", + "integrity": "sha512-DARK8rNMo4lHOFLGTiHEJdf19GuoBDHqGUaypz+fOhrvOs3iFO7ntdYtdpNxv+AzSJBx/JfypF0yEj9ks1IStQ==", "dev": true, "dependencies": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" + "fancy-log": "^1.3.2", + "plugin-error": "^0.1.2", + "rimraf": "^2.6.2", + "through2": "^2.0.3", + "vinyl": "^2.1.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=0.9" } }, "node_modules/gulp-clean/node_modules/rimraf": { @@ -11199,107 +11909,14 @@ "rimraf": "bin.js" } }, - "node_modules/gulp-clean/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "node_modules/gulp-clean/node_modules/strip-ansi": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", - "dev": true, - "dependencies": { - "ansi-regex": "^0.2.1" - }, - "bin": { - "strip-ansi": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "dependencies": { - "is-utf8": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "dependencies": { - "get-stdin": "^4.0.1" - }, - "bin": { - "strip-indent": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", - "dev": true, - "bin": { - "supports-color": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/gulp-clean/node_modules/through2": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz", - "integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=", - "dev": true, - "dependencies": { - "readable-stream": "~1.0.17", - "xtend": "~2.1.1" - } - }, - "node_modules/gulp-clean/node_modules/trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-clean/node_modules/vinyl": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz", - "integrity": "sha1-vKk4IJWC7FpJrVOKAPofEl5RMlI=", - "dev": true, - "dependencies": { - "clone-stats": "~0.0.1" - }, - "engines": { - "node": ">= 0.9" - } - }, - "node_modules/gulp-clean/node_modules/xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, "dependencies": { - "object-keys": "~0.4.0" - }, - "engines": { - "node": ">=0.4" + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" } }, "node_modules/gulp-cli": { @@ -11349,7 +11966,7 @@ "node_modules/gulp-cli/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -11358,7 +11975,7 @@ "node_modules/gulp-cli/node_modules/camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -11367,7 +11984,7 @@ "node_modules/gulp-cli/node_modules/cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "integrity": "sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==", "dev": true, "dependencies": { "string-width": "^1.0.1", @@ -11375,10 +11992,19 @@ "wrap-ansi": "^2.0.0" } }, + "node_modules/gulp-cli/node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/gulp-cli/node_modules/find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", "dev": true, "dependencies": { "path-exists": "^2.0.0", @@ -11394,10 +12020,16 @@ "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, + "node_modules/gulp-cli/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, "node_modules/gulp-cli/node_modules/is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==", "dev": true, "dependencies": { "number-is-nan": "^1.0.0" @@ -11406,73 +12038,34 @@ "node": ">=0.10.0" } }, - "node_modules/gulp-cli/node_modules/load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-cli/node_modules/parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "node_modules/gulp-cli/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "dependencies": { - "error-ex": "^1.2.0" - }, - "engines": { - "node": ">=0.10.0" + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "node_modules/gulp-cli/node_modules/path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "dependencies": { - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-cli/node_modules/path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", "dev": true, "dependencies": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", "pinkie-promise": "^2.0.0" }, "engines": { "node": ">=0.10.0" } }, - "node_modules/gulp-cli/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/gulp-cli/node_modules/read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", "dev": true, "dependencies": { "load-json-file": "^1.0.0", @@ -11486,7 +12079,7 @@ "node_modules/gulp-cli/node_modules/read-pkg-up": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", "dev": true, "dependencies": { "find-up": "^1.0.0", @@ -11496,16 +12089,19 @@ "node": ">=0.10.0" } }, - "node_modules/gulp-cli/node_modules/require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true + "node_modules/gulp-cli/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } }, "node_modules/gulp-cli/node_modules/string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==", "dev": true, "dependencies": { "code-point-at": "^1.0.0", @@ -11519,37 +12115,19 @@ "node_modules/gulp-cli/node_modules/strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "dependencies": { - "ansi-regex": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/gulp-cli/node_modules/strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "dependencies": { - "is-utf8": "^0.2.0" + "ansi-regex": "^2.0.0" }, "engines": { "node": ">=0.10.0" } }, - "node_modules/gulp-cli/node_modules/which-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", - "dev": true - }, "node_modules/gulp-cli/node_modules/wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "integrity": "sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==", "dev": true, "dependencies": { "string-width": "^1.0.1", @@ -11599,7 +12177,7 @@ "node_modules/gulp-concat": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz", - "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", + "integrity": "sha512-a2scActrQrDBpBbR3WUZGyGS1JEPLg5PZJdIa7/Bi3GuKAmPYDK6SFhy/NZq5R8KsKKFvtfR0fakbUCcKGCCjg==", "dev": true, "dependencies": { "concat-with-sourcemaps": "^1.0.0", @@ -11658,10 +12236,25 @@ "ms": "2.0.0" } }, + "node_modules/gulp-connect/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/gulp-connect/node_modules/destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==", + "dev": true + }, "node_modules/gulp-connect/node_modules/http-errors": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", "dev": true, "dependencies": { "depd": "~1.1.2", @@ -11676,7 +12269,7 @@ "node_modules/gulp-connect/node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, "node_modules/gulp-connect/node_modules/mime": { @@ -11691,9 +12284,21 @@ "node_modules/gulp-connect/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/gulp-connect/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/gulp-connect/node_modules/send": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", @@ -11734,207 +12339,177 @@ } }, "node_modules/gulp-eslint": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-4.0.2.tgz", - "integrity": "sha512-fcFUQzFsN6dJ6KZlG+qPOEkqfcevRUXgztkYCvhNvJeSvOicC8ucutN4qR/ID8LmNZx9YPIkBzazTNnVvbh8wg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-6.0.0.tgz", + "integrity": "sha512-dCVPSh1sA+UVhn7JSQt7KEb4An2sQNbOdB3PA8UCfxsoPlAKjJHxYHGXdXC7eb+V1FAnilSFFqslPrq037l1ig==", "dev": true, "dependencies": { - "eslint": "^4.0.0", + "eslint": "^6.0.0", "fancy-log": "^1.3.2", - "plugin-error": "^1.0.0" - } - }, - "node_modules/gulp-eslint/node_modules/acorn": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", - "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" + "plugin-error": "^1.0.1" } }, - "node_modules/gulp-eslint/node_modules/acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "node_modules/gulp-eslint/node_modules/ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "dev": true, "dependencies": { - "acorn": "^3.0.4" - } - }, - "node_modules/gulp-eslint/node_modules/acorn-jsx/node_modules/acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true, - "bin": { - "acorn": "bin/acorn" + "ansi-wrap": "^0.1.0" }, "engines": { - "node": ">=0.4.0" + "node": ">=0.10.0" } }, - "node_modules/gulp-eslint/node_modules/ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "node_modules/gulp-eslint/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true, - "dependencies": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "engines": { + "node": ">=6" } }, - "node_modules/gulp-eslint/node_modules/ajv-keywords": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", - "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", + "node_modules/gulp-eslint/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", "dev": true, - "peerDependencies": { - "ajv": "^5.0.0" + "engines": { + "node": ">=0.10.0" } }, - "node_modules/gulp-eslint/node_modules/ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "node_modules/gulp-eslint/node_modules/arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", "dev": true, "engines": { - "node": ">=4" + "node": ">=0.10.0" } }, - "node_modules/gulp-eslint/node_modules/ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "node_modules/gulp-eslint/node_modules/astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true, "engines": { "node": ">=4" } }, - "node_modules/gulp-eslint/node_modules/chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", - "dev": true - }, - "node_modules/gulp-eslint/node_modules/cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "node_modules/gulp-eslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "dependencies": { - "restore-cursor": "^2.0.0" + "color-name": "~1.1.4" }, "engines": { - "node": ">=4" + "node": ">=7.0.0" } }, - "node_modules/gulp-eslint/node_modules/cli-width": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", - "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", + "node_modules/gulp-eslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "node_modules/gulp-eslint/node_modules/cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, "dependencies": { - "lru-cache": "^4.0.1", + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" + }, + "engines": { + "node": ">=4.8" } }, - "node_modules/gulp-eslint/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "node_modules/gulp-eslint/node_modules/cross-spawn/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, - "dependencies": { - "ms": "^2.1.1" + "bin": { + "semver": "bin/semver" } }, - "node_modules/gulp-eslint/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=0.10.0" - } + "node_modules/gulp-eslint/node_modules/emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true }, "node_modules/gulp-eslint/node_modules/eslint": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", - "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", "dev": true, "dependencies": { - "ajv": "^5.3.0", - "babel-code-frame": "^6.22.0", + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", "chalk": "^2.1.0", - "concat-stream": "^1.6.0", - "cross-spawn": "^5.1.0", - "debug": "^3.1.0", - "doctrine": "^2.1.0", - "eslint-scope": "^3.7.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^3.5.4", - "esquery": "^1.0.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", + "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.0.1", - "ignore": "^3.3.3", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^3.0.6", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.9.1", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.4", - "minimatch": "^3.0.2", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", + "optionator": "^0.8.3", "progress": "^2.0.0", - "regexpp": "^1.0.1", - "require-uncached": "^1.0.3", - "semver": "^5.3.0", - "strip-ansi": "^4.0.0", - "strip-json-comments": "~2.0.1", - "table": "4.0.2", - "text-table": "~0.2.0" + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { - "node": ">=4" + "node": "^8.10.0 || ^10.13.0 || >=11.10.1" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/gulp-eslint/node_modules/eslint-scope": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", - "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "node_modules/gulp-eslint/node_modules/eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", "dev": true, "dependencies": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" + "eslint-visitor-keys": "^1.1.0" }, "engines": { - "node": ">=4.0.0" + "node": ">=6" } }, "node_modules/gulp-eslint/node_modules/eslint-visitor-keys": { @@ -11946,182 +12521,188 @@ "node": ">=4" } }, - "node_modules/gulp-eslint/node_modules/espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "node_modules/gulp-eslint/node_modules/eslint/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", "dev": true, "dependencies": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" + "ansi-regex": "^4.1.0" }, "engines": { - "node": ">=0.10.0" + "node": ">=6" } }, - "node_modules/gulp-eslint/node_modules/external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "node_modules/gulp-eslint/node_modules/espree": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", "dev": true, "dependencies": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" + "acorn": "^7.1.1", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.1.0" }, "engines": { - "node": ">=0.12" + "node": ">=6.0.0" } }, - "node_modules/gulp-eslint/node_modules/fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true - }, - "node_modules/gulp-eslint/node_modules/figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "node_modules/gulp-eslint/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", "dev": true, "dependencies": { - "escape-string-regexp": "^1.0.5" + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" }, "engines": { - "node": ">=4" + "node": ">=0.10.0" } }, "node_modules/gulp-eslint/node_modules/file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", "dev": true, "dependencies": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flat-cache": "^2.0.1" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" } }, "node_modules/gulp-eslint/node_modules/flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", "dev": true, "dependencies": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" } }, - "node_modules/gulp-eslint/node_modules/ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "node_modules/gulp-eslint/node_modules/flatted": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", "dev": true }, - "node_modules/gulp-eslint/node_modules/inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", + "node_modules/gulp-eslint/node_modules/globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", "dev": true, "dependencies": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.0.4", - "figures": "^2.0.0", - "lodash": "^4.3.0", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rx-lite": "^4.0.8", - "rx-lite-aggregates": "^4.0.8", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", - "through": "^2.3.6" + "type-fest": "^0.8.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/gulp-eslint/node_modules/is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "node_modules/gulp-eslint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "engines": { - "node": ">=4" + "node": ">=8" } }, - "node_modules/gulp-eslint/node_modules/json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true + "node_modules/gulp-eslint/node_modules/inquirer": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", + "dev": true, + "dependencies": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.19", + "mute-stream": "0.0.8", + "run-async": "^2.4.0", + "rxjs": "^6.6.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6" + }, + "engines": { + "node": ">=8.0.0" + } }, - "node_modules/gulp-eslint/node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "node_modules/gulp-eslint/node_modules/inquirer/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "color-convert": "^2.0.1" }, "engines": { - "node": ">= 0.8.0" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/gulp-eslint/node_modules/lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "node_modules/gulp-eslint/node_modules/inquirer/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/gulp-eslint/node_modules/mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "node_modules/gulp-eslint/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", "dev": true, "engines": { "node": ">=4" } }, - "node_modules/gulp-eslint/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "node_modules/gulp-eslint/node_modules/levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" }, - "bin": { - "mkdirp": "bin/cmd.js" + "engines": { + "node": ">= 0.8.0" } }, - "node_modules/gulp-eslint/node_modules/mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "node_modules/gulp-eslint/node_modules/onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "node_modules/gulp-eslint/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "mimic-fn": "^1.0.0" + "minimist": "^1.2.6" }, - "engines": { - "node": ">=4" + "bin": { + "mkdirp": "bin/cmd.js" } }, "node_modules/gulp-eslint/node_modules/optionator": { @@ -12141,35 +12722,46 @@ "node": ">= 0.8.0" } }, + "node_modules/gulp-eslint/node_modules/path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/gulp-eslint/node_modules/plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "dependencies": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/gulp-eslint/node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", "dev": true, "engines": { "node": ">= 0.8.0" } }, "node_modules/gulp-eslint/node_modules/regexpp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", - "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", - "dev": true, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/gulp-eslint/node_modules/restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true, - "dependencies": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - }, "engines": { - "node": ">=4" + "node": ">=6.5.0" } }, "node_modules/gulp-eslint/node_modules/rimraf": { @@ -12184,19 +12776,10 @@ "rimraf": "bin.js" } }, - "node_modules/gulp-eslint/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, "node_modules/gulp-eslint/node_modules/shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", "dev": true, "dependencies": { "shebang-regex": "^1.0.0" @@ -12208,67 +12791,95 @@ "node_modules/gulp-eslint/node_modules/shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/gulp-eslint/node_modules/slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", "dev": true, "dependencies": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", "is-fullwidth-code-point": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=6" } }, - "node_modules/gulp-eslint/node_modules/string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "node_modules/gulp-eslint/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/gulp-eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "dependencies": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "has-flag": "^4.0.0" }, "engines": { - "node": ">=4" + "node": ">=8" } }, - "node_modules/gulp-eslint/node_modules/strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "node_modules/gulp-eslint/node_modules/table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "dev": true, "dependencies": { - "ansi-regex": "^3.0.0" + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" }, "engines": { - "node": ">=4" + "node": ">=6.0.0" } }, - "node_modules/gulp-eslint/node_modules/table": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", - "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "node_modules/gulp-eslint/node_modules/table/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", "dev": true, "dependencies": { - "ajv": "^5.2.3", - "ajv-keywords": "^2.1.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/gulp-eslint/node_modules/table/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" } }, "node_modules/gulp-eslint/node_modules/type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", "dev": true, "dependencies": { "prelude-ls": "~1.1.2" @@ -12277,6 +12888,15 @@ "node": ">= 0.8.0" } }, + "node_modules/gulp-eslint/node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/gulp-eslint/node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -12289,44 +12909,6 @@ "which": "bin/which" } }, - "node_modules/gulp-eslint/node_modules/yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true - }, - "node_modules/gulp-footer": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/gulp-footer/-/gulp-footer-2.1.0.tgz", - "integrity": "sha512-CK3nRBP3PG59XN2L1rDLkBHA7goYsW+tJuVQccLP9jq3mpBT2kuRq0ImgNjrUkDbF948aCVQH4J7uIEqiZ2MHA==", - "dev": true, - "dependencies": { - "lodash": "^4.17.21", - "map-stream": "^0.0.7" - } - }, - "node_modules/gulp-header": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/gulp-header/-/gulp-header-2.0.9.tgz", - "integrity": "sha512-LMGiBx+qH8giwrOuuZXSGvswcIUh0OiioNkUpLhNyvaC6/Ga8X6cfAeme2L5PqsbXMhL8o8b/OmVqIQdxprhcQ==", - "dev": true, - "dependencies": { - "concat-with-sourcemaps": "^1.1.0", - "lodash.template": "^4.5.0", - "map-stream": "0.0.7", - "through2": "^2.0.0" - } - }, - "node_modules/gulp-header/node_modules/through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "dependencies": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, "node_modules/gulp-if": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/gulp-if/-/gulp-if-3.0.0.tgz", @@ -12351,7 +12933,7 @@ "node_modules/gulp-js-escape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gulp-js-escape/-/gulp-js-escape-1.0.1.tgz", - "integrity": "sha1-HNRF+9AJ4Np2lZoDp/SbNWav+Gg=", + "integrity": "sha512-F+53crhLb78CTlG7ZZJFWzP0+/4q0vt2/pULXFkTMs6AGBo0Eh5cx+eWsqqHv8hrNIUsuTab3Se8rOOzP/6+EQ==", "dev": true, "dependencies": { "through2": "^0.6.3" @@ -12360,13 +12942,13 @@ "node_modules/gulp-js-escape/node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, "node_modules/gulp-js-escape/node_modules/readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", "dev": true, "dependencies": { "core-util-is": "~1.0.0", @@ -12378,13 +12960,13 @@ "node_modules/gulp-js-escape/node_modules/string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", "dev": true }, "node_modules/gulp-js-escape/node_modules/through2": { "version": "0.6.5", "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "integrity": "sha512-RkK/CCESdTKQZHdmKICijdKKsCRVHs5KsLZ6pACAmF/1GPUQhonHSXWNERctxEp7RmvjdNbZTL5z9V7nSCXKcg==", "dev": true, "dependencies": { "readable-stream": ">=1.0.33-1 <1.1.0-0", @@ -12417,9 +12999,9 @@ } }, "node_modules/gulp-replace/node_modules/@types/node": { - "version": "14.18.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz", - "integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==", + "version": "14.18.33", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.33.tgz", + "integrity": "sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==", "dev": true }, "node_modules/gulp-shell": { @@ -12439,6 +13021,18 @@ "node": ">=10.0.0" } }, + "node_modules/gulp-shell/node_modules/ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "dependencies": { + "ansi-wrap": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/gulp-shell/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -12454,6 +13048,24 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/gulp-shell/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gulp-shell/node_modules/arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/gulp-shell/node_modules/chalk": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", @@ -12485,6 +13097,43 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/gulp-shell/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gulp-shell/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/gulp-shell/node_modules/plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "dependencies": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/gulp-shell/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -12575,10 +13224,68 @@ "node": ">=10" } }, + "node_modules/gulp-terser/node_modules/ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "dependencies": { + "ansi-wrap": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gulp-terser/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gulp-terser/node_modules/arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gulp-terser/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gulp-terser/node_modules/plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "dependencies": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/gulp-util": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "integrity": "sha512-q5oWPc12lwSFS9h/4VIjG+1NuNDlJ48ywV2JKItY4Ycc/n1fXJeYPVQsfu5ZrhQi7FGSDBalwUCLar/GyHXKGw==", "deprecated": "gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5", "dev": true, "dependencies": { @@ -12608,7 +13315,7 @@ "node_modules/gulp-util/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -12617,7 +13324,7 @@ "node_modules/gulp-util/node_modules/ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -12626,7 +13333,7 @@ "node_modules/gulp-util/node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "dependencies": { "ansi-styles": "^2.2.1", @@ -12642,7 +13349,7 @@ "node_modules/gulp-util/node_modules/clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", "dev": true, "engines": { "node": ">=0.8" @@ -12651,33 +13358,13 @@ "node_modules/gulp-util/node_modules/clone-stats": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "integrity": "sha512-dhUqc57gSMCo6TX85FLfe51eC/s+Im2MLkAgJwfaRRexR2tA4dd3eLEW4L6efzHc2iNorrRRXITifnDLlRrhaA==", "dev": true }, - "node_modules/gulp-util/node_modules/lodash.escape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true, - "dependencies": { - "lodash._root": "^3.0.0" - } - }, - "node_modules/gulp-util/node_modules/lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "dependencies": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" - } - }, "node_modules/gulp-util/node_modules/lodash.template": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "integrity": "sha512-0B4Y53I0OgHUJkt+7RmlDFWKjVAI/YUpWNiL9GQz5ORDr4ttgfQGo+phBWKFLJbBdtOwgMuUkdOHOnPg45jKmQ==", "dev": true, "dependencies": { "lodash._basecopy": "^3.0.0", @@ -12694,7 +13381,7 @@ "node_modules/gulp-util/node_modules/lodash.templatesettings": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", - "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "integrity": "sha512-TcrlEr31tDYnWkHFWDCV3dHYroKEXpJZ2YJYvJdhN+y4AkWMDZ5I4I8XDtUKqSAyG81N7w+I1mFEJtcED+tGqQ==", "dev": true, "dependencies": { "lodash._reinterpolate": "^3.0.0", @@ -12704,7 +13391,7 @@ "node_modules/gulp-util/node_modules/object-assign": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "integrity": "sha512-jHP15vXVGeVh1HuaA2wY6lxk+whK/x4KBG88VXeRma7CCun7iGD5qPc4eYykQ9sdQvg8jkwFKsSxHln2ybW3xQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -12713,7 +13400,7 @@ "node_modules/gulp-util/node_modules/strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "dependencies": { "ansi-regex": "^2.0.0" @@ -12725,7 +13412,7 @@ "node_modules/gulp-util/node_modules/supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true, "engines": { "node": ">=0.8.0" @@ -12744,7 +13431,7 @@ "node_modules/gulp-util/node_modules/vinyl": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", - "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "integrity": "sha512-P5zdf3WB9uzr7IFoVQ2wZTmUwHL8cMZWJGzLBNCHNZ3NB6HTMsYABtt7z8tAGIINLXyAob9B9a1yzVGMFOYKEA==", "dev": true, "dependencies": { "clone": "^1.0.0", @@ -12758,7 +13445,7 @@ "node_modules/gulplog": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "integrity": "sha512-hm6N8nrm3Y08jXie48jsC55eCZz9mnb4OirAStEk2deqeyhXU3C1otDVh+ccttMuc1sBi6RX6ZJ720hs9RCvgw==", "dev": true, "dependencies": { "glogg": "^1.0.0" @@ -12815,7 +13502,7 @@ "node_modules/har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", "dev": true, "engines": { "node": ">=4" @@ -12835,36 +13522,10 @@ "node": ">=6" } }, - "node_modules/har-validator/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/hard-rejection": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", - "integrity": "sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -12875,7 +13536,7 @@ "node_modules/has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", "dev": true, "dependencies": { "ansi-regex": "^2.0.0" @@ -12887,34 +13548,33 @@ "node_modules/has-ansi/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "engines": { - "node": ">=8" + "node": ">=4" } }, "node_modules/has-gulplog": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "integrity": "sha512-+F4GzLjwHNNDEAJW2DC1xXfEoPkRDmUdJ7CBYw4MpqtDwOnqdImJl7GWlpqx+Wko6//J8uKTnIe4wZSv7yCqmw==", "dev": true, "dependencies": { "sparkles": "^1.0.0" @@ -12923,11 +13583,22 @@ "node": ">= 0.10" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true, "engines": { "node": ">= 0.4" }, @@ -12953,7 +13624,7 @@ "node_modules/has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "integrity": "sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==", "dev": true, "dependencies": { "get-value": "^2.0.6", @@ -12967,7 +13638,7 @@ "node_modules/has-values": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "integrity": "sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==", "dev": true, "dependencies": { "is-number": "^3.0.0", @@ -12983,10 +13654,34 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "node_modules/has-values/node_modules/is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "dependencies": { + "kind-of": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-values/node_modules/is-number/node_modules/kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "dependencies": { + "is-buffer": "^1.1.5" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/has-values/node_modules/kind-of": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "integrity": "sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -12996,22 +13691,26 @@ } }, "node_modules/hast-util-is-element": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.1.0.tgz", - "integrity": "sha512-oUmNua0bFbdrD/ELDSSEadRVtWZOf3iF6Lbv81naqsIV99RnSCieTbWuWCY8BAeEfKJTKl0gRdokv+dELutHGQ==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-2.1.2.tgz", + "integrity": "sha512-thjnlGAnwP8ef/GSO1Q8BfVk2gundnc2peGQqEg2kUt/IqesiGg/5mSwN2fE7nLzy61pg88NG6xV+UrGOrx9EA==", "dev": true, + "dependencies": { + "@types/hast": "^2.0.0", + "@types/unist": "^2.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, "node_modules/hast-util-sanitize": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-3.0.2.tgz", - "integrity": "sha512-+2I0x2ZCAyiZOO/sb4yNLFmdwPBnyJ4PBkVTUMKMqBwYNA+lXSgOmoRXlJFazoyid9QPogRRKgKhVEodv181sA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-4.0.0.tgz", + "integrity": "sha512-pw56+69jq+QSr/coADNvWTmBPDy+XsmwaF5KnUys4/wM1jt/fZdl7GPxhXXXYdXnz3Gj3qMkbUCH2uKjvX0MgQ==", "dev": true, "dependencies": { - "xtend": "^4.0.0" + "@types/hast": "^2.0.0" }, "funding": { "type": "opencollective", @@ -13019,21 +13718,21 @@ } }, "node_modules/hast-util-to-html": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.3.tgz", - "integrity": "sha512-yk2+1p3EJTEE9ZEUkgHsUSVhIpCsL/bvT8E5GzmWc+N1Po5gBw+0F8bo7dpxXR0nu0bQVxVZGX2lBGF21CmeDw==", - "dev": true, - "dependencies": { - "ccount": "^1.0.0", - "comma-separated-tokens": "^1.0.0", - "hast-util-is-element": "^1.0.0", - "hast-util-whitespace": "^1.0.0", - "html-void-elements": "^1.0.0", - "property-information": "^5.0.0", - "space-separated-tokens": "^1.0.0", - "stringify-entities": "^3.0.1", - "unist-util-is": "^4.0.0", - "xtend": "^4.0.0" + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-8.0.3.tgz", + "integrity": "sha512-/D/E5ymdPYhHpPkuTHOUkSatxr4w1ZKrZsG0Zv/3C2SRVT0JFJG53VS45AMrBtYk0wp5A7ksEhiC8QaOZM95+A==", + "dev": true, + "dependencies": { + "@types/hast": "^2.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-is-element": "^2.0.0", + "hast-util-whitespace": "^2.0.0", + "html-void-elements": "^2.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.2", + "unist-util-is": "^5.0.0" }, "funding": { "type": "opencollective", @@ -13041,9 +13740,9 @@ } }, "node_modules/hast-util-whitespace": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz", - "integrity": "sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.0.tgz", + "integrity": "sha512-Pkw+xBHuV6xFeJprJe2BBEoDV+AvQySaz3pPDRUs5PNZEMQjpXJJueqrpcHIXxnWTcAGi/UOCgVShlkY6kLoqg==", "dev": true, "funding": { "type": "opencollective", @@ -13051,27 +13750,27 @@ } }, "node_modules/he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true, "bin": { "he": "bin/he" } }, "node_modules/highlight.js": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", - "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "version": "11.6.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.6.0.tgz", + "integrity": "sha512-ig1eqDzJaB0pqEvlPVIpSSyMaO92bH1N2rJpLMN/nX396wTpDA4Eq0uK+7I/2XG17pFaaKE0kjV/XPeGt7Evjw==", "dev": true, "engines": { - "node": "*" + "node": ">=12.0.0" } }, "node_modules/home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", - "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", + "integrity": "sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg==", "dev": true, "dependencies": { "os-homedir": "^1.0.0", @@ -13094,10 +13793,16 @@ } }, "node_modules/hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "engines": { + "node": ">=10" + } }, "node_modules/html-escaper": { "version": "2.0.2", @@ -13106,9 +13811,9 @@ "dev": true }, "node_modules/html-void-elements": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.5.tgz", - "integrity": "sha512-uE/TxKuyNIcx44cIWnjr/rfIATDH7ZaOMmstu0CwhFG1Dunhlp4OC6/NMbhiwoq5BpW0ubi303qnEk/PZj614w==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-2.0.1.tgz", + "integrity": "sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A==", "dev": true, "funding": { "type": "github", @@ -13116,30 +13821,30 @@ } }, "node_modules/http-cache-semantics": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, "node_modules/http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "dependencies": { - "depd": "~1.1.2", + "depd": "2.0.0", "inherits": "2.0.4", "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", + "statuses": "2.0.1", "toidentifier": "1.0.1" }, "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, "node_modules/http-parser-js": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.6.tgz", - "integrity": "sha512-vDlkRPDJn93swjcjqMSaGSPABbIarsr1TLAui/gLDXzV5VsJNdXNzMYDyNBLQkjWQCJ1uizu8T2oDMhmGt0PRA==", + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.8.tgz", + "integrity": "sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q==", "dev": true }, "node_modules/http-proxy": { @@ -13159,7 +13864,7 @@ "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", "dev": true, "dependencies": { "assert-plus": "^1.0.0", @@ -13185,16 +13890,16 @@ } }, "node_modules/https-proxy-agent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", - "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, "dependencies": { - "agent-base": "5", + "agent-base": "6", "debug": "4" }, "engines": { - "node": ">= 6.0.0" + "node": ">= 6" } }, "node_modules/iconv-lite": { @@ -13265,25 +13970,31 @@ "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "engines": { "node": ">=0.8.19" } }, "node_modules/indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ==", "dev": true, "engines": { - "node": ">=8" + "node": ">=4" } }, + "node_modules/individual": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/individual/-/individual-2.0.0.tgz", + "integrity": "sha512-pWt8hBCqJsUWI/HtcfWod7+N9SgAqyPEaF7JQjwzjn5vGrpg6aQ5qeAFQ7dx//UH4J1O+7xqew+gCeeFt6xN/g==", + "dev": true + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "dependencies": { "once": "^1.3.0", @@ -13296,15 +14007,18 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ini/-/ini-3.0.1.tgz", + "integrity": "sha512-it4HyVAUTKBc6m8e1iXWvXSTdndF7HbdN713+kvLrymxTaU4AUBWrJ4vEooP+V7fexnVD3LKcBshjGGPefSMUQ==", + "dev": true, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } }, "node_modules/inquirer": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.1.5.tgz", - "integrity": "sha512-G6/9xUqmt/r+UvufSyrPpt84NYwhKZ9jLsgMbQzlx804XErNupor8WQdBnBRrXmBfTPpuwf1sV+ss2ovjgdXIg==", + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.5.tgz", + "integrity": "sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ==", "dev": true, "dependencies": { "ansi-escapes": "^4.2.1", @@ -13317,13 +14031,14 @@ "mute-stream": "0.0.8", "ora": "^5.4.1", "run-async": "^2.4.0", - "rxjs": "^7.2.0", + "rxjs": "^7.5.5", "string-width": "^4.1.0", "strip-ansi": "^6.0.0", - "through": "^2.3.6" + "through": "^2.3.6", + "wrap-ansi": "^7.0.0" }, "engines": { - "node": ">=8.0.0" + "node": ">=12.0.0" } }, "node_modules/inquirer/node_modules/ansi-styles": { @@ -13375,6 +14090,24 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/inquirer/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/inquirer/node_modules/rxjs": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", + "integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/inquirer/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -13387,6 +14120,12 @@ "node": ">=8" } }, + "node_modules/inquirer/node_modules/tslib": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", + "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==", + "dev": true + }, "node_modules/internal-slot": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", @@ -13422,7 +14161,7 @@ "node_modules/invert-kv": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "integrity": "sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -13470,30 +14209,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-alphabetical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz", - "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, - "node_modules/is-alphanumerical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", - "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", - "dev": true, - "dependencies": { - "is-alphabetical": "^1.0.0", - "is-decimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-arguments": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", @@ -13513,7 +14228,7 @@ "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, "node_modules/is-bigint": { @@ -13580,9 +14295,9 @@ } }, "node_modules/is-callable": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", - "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", "dev": true, "engines": { "node": ">= 0.4" @@ -13592,10 +14307,9 @@ } }, "node_modules/is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "dev": true, + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", "dependencies": { "has": "^1.0.3" }, @@ -13639,16 +14353,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-decimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz", - "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-descriptor": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", @@ -13714,7 +14418,7 @@ "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -13741,6 +14445,12 @@ "node": ">=8" } }, + "node_modules/is-function": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz", + "integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==", + "dev": true + }, "node_modules/is-generator-function": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", @@ -13768,16 +14478,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-hexadecimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz", - "integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -13815,7 +14515,7 @@ "node_modules/is-negated-glob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", - "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=", + "integrity": "sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug==", "dev": true, "engines": { "node": ">=0.10.0" @@ -13834,21 +14534,18 @@ } }, "node_modules/is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, - "dependencies": { - "kind-of": "^3.0.2" - }, "engines": { - "node": ">=0.10.0" + "node": ">=0.12.0" } }, "node_modules/is-number-object": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.6.tgz", - "integrity": "sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, "dependencies": { "has-tostringtag": "^1.0.0" @@ -13860,40 +14557,16 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-number/node_modules/is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "node_modules/is-number/node_modules/kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "dependencies": { - "is-buffer": "^1.1.5" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", + "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", "dev": true, "engines": { - "node": ">=0.10.0" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/is-plain-object": { @@ -13939,16 +14612,10 @@ "node": ">=0.10.0" } }, - "node_modules/is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", - "dev": true - }, "node_modules/is-running": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-running/-/is-running-2.1.0.tgz", - "integrity": "sha1-MKc/9cw4VOT8JUkICen1q/jeCeA=", + "integrity": "sha512-mjJd3PujZMl7j+D395WTIO5tU5RIDBfVSRtRR4VOJou3H66E38UjbjvDGh3slJzPuolsb+yQFqwHNNdyp5jg3w==", "dev": true }, "node_modules/is-set": { @@ -13961,27 +14628,30 @@ } }, "node_modules/is-shared-array-buffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz", - "integrity": "sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/is-ssh": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.3.3.tgz", - "integrity": "sha512-NKzJmQzJfEEma3w5cJNcUMxoXfDjz0Zj0eyCalHn2E6VOwlzjZo0yuO2fcBSf8zhFuVCL/82/r5gRcoi6aEPVQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", "dev": true, "dependencies": { - "protocols": "^1.1.0" + "protocols": "^2.0.1" } }, "node_modules/is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -14017,28 +14687,16 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-text-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", - "dev": true, - "dependencies": { - "text-extensions": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-typed-array": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.8.tgz", - "integrity": "sha512-HqH41TNZq2fgtGT8WHVFVJhBVGuY3AnP3Q36K8JKXUxSxRgk/d+7NjmwG2vo2mYmXK8UYZKu0qH8bVP5gEisjA==", + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.9.tgz", + "integrity": "sha512-kfrlnTTn8pZkfpJMUgYD7YZ3qzeJgWUn8XfVYBARc4wnmNOmLbmuuaAs3q5fvB0UJOn6yHAKaGTPM7d6ezoD/A==", "dev": true, "dependencies": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", - "es-abstract": "^1.18.5", - "foreach": "^2.0.5", + "es-abstract": "^1.20.0", + "for-each": "^0.3.3", "has-tostringtag": "^1.0.0" }, "engines": { @@ -14051,7 +14709,7 @@ "node_modules/is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, "node_modules/is-unc-path": { @@ -14081,13 +14739,13 @@ "node_modules/is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "integrity": "sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q==", "dev": true }, "node_modules/is-valid-glob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz", - "integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=", + "integrity": "sha512-AhiROmoEFDSsjx8hW+5sGwgKVIORcXnrlAx/R0ZSeaPw70Vw0CqkGBBhHGL58Uox2eXnU1AnvXJl1XlyedO5bA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -14155,9 +14813,9 @@ "dev": true }, "node_modules/isbinaryfile": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.8.tgz", - "integrity": "sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w==", + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", "dev": true, "engines": { "node": ">= 8.0.0" @@ -14169,13 +14827,13 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -14184,13 +14842,13 @@ "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", "dev": true }, "node_modules/istanbul": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", - "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "integrity": "sha512-nMtdn4hvK0HjUlzr1DrKSUY8ychprt8dzHOgY2KXsIhHu5PuQQEOTM27gV9Xblyon7aUH/TSFIjRHEODF/FRPg==", "deprecated": "This module is no longer maintained, try this instead:\n npm i nyc\nVisit https://istanbul.js.org/integrations for other alternatives.", "dev": true, "dependencies": { @@ -14223,14 +14881,15 @@ } }, "node_modules/istanbul-lib-instrument": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", - "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", "dev": true, "dependencies": { - "@babel/core": "^7.7.5", + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-coverage": "^3.2.0", "semver": "^6.3.0" }, "engines": { @@ -14251,6 +14910,15 @@ "node": ">=8" } }, + "node_modules/istanbul-lib-report/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/istanbul-lib-report/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -14287,9 +14955,9 @@ } }, "node_modules/istanbul-reports": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.4.tgz", - "integrity": "sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", "dev": true, "dependencies": { "html-escaper": "^2.0.0", @@ -14302,7 +14970,7 @@ "node_modules/istanbul/node_modules/glob": { "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "integrity": "sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==", "dev": true, "dependencies": { "inflight": "^1.0.4", @@ -14318,19 +14986,19 @@ "node_modules/istanbul/node_modules/has-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "integrity": "sha512-DyYHfIYwAJmjAjSSPKANxI8bFY9YtFrgkAfinBojQ8YJTOuOuav64tMUJv584SES4xl74PmuaevIyaLESHdTAA==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/istanbul/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" }, "bin": { "mkdirp": "bin/cmd.js" @@ -14339,13 +15007,13 @@ "node_modules/istanbul/node_modules/resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "integrity": "sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg==", "dev": true }, "node_modules/istanbul/node_modules/supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "integrity": "sha512-Jds2VIYDrlp5ui7t8abHN2bjAu4LV/q4N2KivFPpGH0lrka0BMq/33AmECUXlKPcHigkNaqfXRENFju+rlcy+A==", "dev": true, "dependencies": { "has-flag": "^1.0.0" @@ -14383,13 +15051,13 @@ } }, "node_modules/jake": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz", - "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==", + "version": "10.8.5", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz", + "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==", "dev": true, "dependencies": { - "async": "0.9.x", - "chalk": "^2.4.2", + "async": "^3.2.3", + "chalk": "^4.0.2", "filelist": "^1.0.1", "minimatch": "^3.0.4" }, @@ -14397,28 +15065,98 @@ "jake": "bin/cli.js" }, "engines": { - "node": "*" + "node": ">=10" + } + }, + "node_modules/jake/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, "node_modules/jake/node_modules/async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", "dev": true }, + "node_modules/jake/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/jake/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/jake/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/jake/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/jake/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/jest-diff": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.5.1.tgz", - "integrity": "sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-26.6.2.tgz", + "integrity": "sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==", "dev": true, "dependencies": { "chalk": "^4.0.0", - "diff-sequences": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" + "diff-sequences": "^26.6.2", + "jest-get-type": "^26.3.0", + "pretty-format": "^26.6.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/jest-diff/node_modules/ansi-styles": { @@ -14470,6 +15208,15 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/jest-diff/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/jest-diff/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -14483,27 +15230,27 @@ } }, "node_modules/jest-get-type": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.5.1.tgz", - "integrity": "sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==", + "version": "26.3.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-26.3.0.tgz", + "integrity": "sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig==", "dev": true, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/jest-matcher-utils": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz", - "integrity": "sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-26.6.2.tgz", + "integrity": "sha512-llnc8vQgYcNqDrqRDXWwMr9i7rS5XFiCwvh6DTP7Jqa2mqpcCBBlpCbn+trkG0KNhPu/h8rzyBkriOtBstvWhw==", "dev": true, "dependencies": { "chalk": "^4.0.0", - "jest-diff": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" + "jest-diff": "^26.6.2", + "jest-get-type": "^26.3.0", + "pretty-format": "^26.6.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/jest-matcher-utils/node_modules/ansi-styles": { @@ -14555,6 +15302,15 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/jest-matcher-utils/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/jest-matcher-utils/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -14568,23 +15324,23 @@ } }, "node_modules/jest-message-util": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-27.5.1.tgz", - "integrity": "sha512-rMyFe1+jnyAAf+NHwTclDz0eAaLkVDdKVHHBFWsBWHnnh5YeJMNWWsv7AbFYXfK3oTqvL7VTWkhNLu1jX24D+g==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-26.6.2.tgz", + "integrity": "sha512-rGiLePzQ3AzwUshu2+Rn+UMFk0pHN58sOG+IaJbk5Jxuqo3NYO1U2/MIR4S1sKgsoYSXSzdtSa0TgrmtUwEbmA==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^27.5.1", + "@babel/code-frame": "^7.0.0", + "@jest/types": "^26.6.2", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^27.5.1", + "graceful-fs": "^4.2.4", + "micromatch": "^4.0.2", + "pretty-format": "^26.6.2", "slash": "^3.0.0", - "stack-utils": "^2.0.3" + "stack-utils": "^2.0.2" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10.14.2" } }, "node_modules/jest-message-util/node_modules/ansi-styles": { @@ -14636,17 +15392,22 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/jest-message-util/node_modules/micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "node_modules/jest-message-util/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, - "dependencies": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - }, "engines": { - "node": ">=8.6" + "node": ">=8" + } + }, + "node_modules/jest-message-util/node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" } }, "node_modules/jest-message-util/node_modules/supports-color": { @@ -14661,6 +15422,15 @@ "node": ">=8" } }, + "node_modules/jest-regex-util": { + "version": "26.0.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", + "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "dev": true, + "engines": { + "node": ">= 10.14.2" + } + }, "node_modules/jest-worker": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", @@ -14675,11 +15445,42 @@ "node": ">= 10.13.0" } }, + "node_modules/jest-worker/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-cookie": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz", + "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==", + "engines": { + "node": ">=14" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { "version": "3.14.1", @@ -14710,14 +15511,13 @@ "node_modules/jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", "dev": true }, "node_modules/jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true, "bin": { "jsesc": "bin/jsesc" }, @@ -14731,12 +15531,6 @@ "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true }, - "node_modules/json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -14758,23 +15552,19 @@ "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, "node_modules/json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", + "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", "bin": { "json5": "lib/cli.js" }, @@ -14794,31 +15584,6 @@ "graceful-fs": "^4.1.6" } }, - "node_modules/jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true, - "engines": [ - "node >= 0.2.0" - ] - }, - "node_modules/JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "dependencies": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - }, - "bin": { - "JSONStream": "bin.js" - }, - "engines": { - "node": "*" - } - }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -14837,7 +15602,7 @@ "node_modules/just-clone": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/just-clone/-/just-clone-1.0.2.tgz", - "integrity": "sha1-v7P672WqEqMWBYcSlFwyb9jwFDQ=" + "integrity": "sha512-p93GINPwrve0w3HUzpXmpTl7MyzzWz1B5ag44KEtq/hP1mtK8lA2b9Q0VQaPlnY87352osJcE6uBmN0e8kuFMw==" }, "node_modules/just-debounce": { "version": "1.1.0", @@ -14852,9 +15617,9 @@ "dev": true }, "node_modules/karma": { - "version": "6.3.17", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.17.tgz", - "integrity": "sha512-2TfjHwrRExC8yHoWlPBULyaLwAFmXmxQrcuFImt/JsAsSZu1uOWTZ1ZsWjqQtWpHLiatJOHL5jFjXSJIgCd01g==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.1.tgz", + "integrity": "sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA==", "dev": true, "dependencies": { "@colors/colors": "1.5.0", @@ -14876,7 +15641,7 @@ "qjobs": "^1.2.0", "range-parser": "^1.2.1", "rimraf": "^3.0.2", - "socket.io": "^4.2.0", + "socket.io": "^4.4.1", "source-map": "^0.6.1", "tmp": "^0.2.1", "ua-parser-js": "^0.7.30", @@ -14918,7 +15683,7 @@ "node_modules/karma-chai": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz", - "integrity": "sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=", + "integrity": "sha512-mqKCkHwzPMhgTYca10S90aCEX9+HjVjjrBFAsw36Zj7BlQNbokXXCAe6Ji04VUMsxcY5RLP7YphpfO06XOubdg==", "dev": true, "peerDependencies": { "chai": "*", @@ -14926,9 +15691,9 @@ } }, "node_modules/karma-chrome-launcher": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.0.tgz", - "integrity": "sha512-3dPs/n7vgz1rxxtynpzZTvb9y/GIaW8xjAwcIGttLbycqoFtI7yo1NGnQi6oFTherRE+GIhCAHZC4vEqWGhNvg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz", + "integrity": "sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ==", "dev": true, "dependencies": { "which": "^1.2.1" @@ -15039,9 +15804,9 @@ } }, "node_modules/karma-coverage-istanbul-reporter/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true, "bin": { "semver": "bin/semver" @@ -15056,26 +15821,10 @@ "node": ">=0.10.0" } }, - "node_modules/karma-coverage/node_modules/istanbul-lib-instrument": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.1.0.tgz", - "integrity": "sha512-czwUz525rkOFDJxfKK6mYfIs9zBKILyrZQxjz3ABhjQXhbhFsSbo1HW/BFcsDnfJYJWA6thRR5/TUY2qs5W99Q==", - "dev": true, - "dependencies": { - "@babel/core": "^7.12.3", - "@babel/parser": "^7.14.7", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^6.3.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/karma-es5-shim": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/karma-es5-shim/-/karma-es5-shim-0.0.4.tgz", - "integrity": "sha1-zdADM8znfC5M4D46yT8vjs0fuVI=", + "integrity": "sha512-8xU6F2/R6u6HAZ/nlyhhx3WEhj4C6hJorG7FR2REX81pgj2LSo9ADJXxCGIeXg6Qr2BGpxp4hcZcEOYGAwiumg==", "dev": true, "dependencies": { "es5-shim": "^4.0.5" @@ -15094,7 +15843,7 @@ "node_modules/karma-ie-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-ie-launcher/-/karma-ie-launcher-1.0.0.tgz", - "integrity": "sha1-SXmGhCxJAZA0bNifVJTKmDDG1Zw=", + "integrity": "sha512-ts71ke8pHvw6qdRtq0+7VY3ANLoZuUNNkA8abRaWV13QRPNm7TtSOqyszjHUtuwOWKcsSz4tbUtrNICrQC+SXQ==", "dev": true, "dependencies": { "lodash": "^4.6.1" @@ -15115,7 +15864,7 @@ "node_modules/karma-mocha-reporter": { "version": "2.2.5", "resolved": "https://registry.npmjs.org/karma-mocha-reporter/-/karma-mocha-reporter-2.2.5.tgz", - "integrity": "sha1-FRIAlejtgZGG5HoLAS8810GJVWA=", + "integrity": "sha512-Hr6nhkIp0GIJJrvzY8JFeHpQZNseuIakGac4bpw8K1+5F0tLb6l7uvXRa8mt2Z+NVwYgCct4QAfp2R2QP6o00w==", "dev": true, "dependencies": { "chalk": "^2.1.0", @@ -15127,9 +15876,9 @@ } }, "node_modules/karma-mocha-reporter/node_modules/ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", "dev": true, "engines": { "node": ">=4" @@ -15138,7 +15887,7 @@ "node_modules/karma-mocha-reporter/node_modules/strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", "dev": true, "dependencies": { "ansi-regex": "^3.0.0" @@ -15150,7 +15899,7 @@ "node_modules/karma-opera-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-opera-launcher/-/karma-opera-launcher-1.0.0.tgz", - "integrity": "sha1-+lFihTGh0L6EstjcDX7iCfyP+Ro=", + "integrity": "sha512-rdty4FlVIowmUhPuG08TeXKHvaRxeDSzPxGIkWguCF3A32kE0uvXZ6dXW08PuaNjai8Ip3f5Pn9Pm2HlChaxCw==", "dev": true, "peerDependencies": { "karma": ">=0.9" @@ -15159,7 +15908,7 @@ "node_modules/karma-safari-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz", - "integrity": "sha1-lpgqLMR9BmquccVTursoMZEVos4=", + "integrity": "sha512-qmypLWd6F2qrDJfAETvXDfxHvKDk+nyIjpH9xIeI3/hENr0U3nuqkxaftq73PfXZ4aOuOChA6SnLW4m4AxfRjQ==", "dev": true, "peerDependencies": { "karma": ">=0.9" @@ -15168,7 +15917,7 @@ "node_modules/karma-script-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-script-launcher/-/karma-script-launcher-1.0.0.tgz", - "integrity": "sha1-zQF8TeXvCeWp2nkydhdhCN1LVC0=", + "integrity": "sha512-5NRc8KmTBjNPE3dNfpJP90BArnBohYV4//MsLFfUA1e6N+G1/A5WuWctaFBtMQ6MWRybs/oguSej0JwDr8gInA==", "dev": true, "peerDependencies": { "karma": ">=0.9" @@ -15177,7 +15926,7 @@ "node_modules/karma-sinon": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/karma-sinon/-/karma-sinon-1.0.5.tgz", - "integrity": "sha1-TjRD8oMP3s/2JNN0cWPxIX2qKpo=", + "integrity": "sha512-wrkyAxJmJbn75Dqy17L/8aILJWFm7znd1CE8gkyxTBFnjMSOe2XTJ3P30T8SkxWZHmoHX0SCaUJTDBEoXs25Og==", "dev": true, "engines": { "node": ">= 0.10.0" @@ -15199,7 +15948,7 @@ "node_modules/karma-spec-reporter": { "version": "0.0.32", "resolved": "https://registry.npmjs.org/karma-spec-reporter/-/karma-spec-reporter-0.0.32.tgz", - "integrity": "sha1-LpxyB+pyZ3EmAln4K+y1QyCeRAo=", + "integrity": "sha512-ZXsYERZJMTNRR2F3QN11OWF5kgnT/K2dzhM+oY3CDyMrDI3TjIWqYGG7c15rR9wjmy9lvdC+CCshqn3YZqnNrA==", "dev": true, "dependencies": { "colors": "^1.1.2" @@ -15225,13 +15974,24 @@ "webpack": "^5.0.0" } }, + "node_modules/karma/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, "node_modules/karma/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" }, "bin": { "mkdirp": "bin/cmd.js" @@ -15285,10 +16045,16 @@ "node": ">=10" } }, + "node_modules/keycode": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.1.tgz", + "integrity": "sha512-Rdgz9Hl9Iv4QKi8b0OlCRQEzp4AgVxyCtz5S/+VIHezDmrDhkp2N2TqBWOLz0/gbeREXOOiI9/4b8BY9uw2vFg==", + "dev": true + }, "node_modules/keyv": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.1.1.tgz", - "integrity": "sha512-tGv1yP6snQVDSM4X6yxrv2zzq/EvpW+oYiUz6aueW1u9CtS8RzUQYxxmFwgZlO2jSgCxQbchhxaqXXp2hnKGpQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.0.tgz", + "integrity": "sha512-2YvuMsA+jnFGtBareKqgANOEKe1mk3HKiXu2fRmAfyxG0MJAywNhi5ttWA3PMjl4NmpyjZNbFifR2vNjW1znfA==", "dev": true, "dependencies": { "json-buffer": "3.0.1" @@ -15303,6 +16069,15 @@ "node": ">=0.10.0" } }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/konan": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/konan/-/konan-2.1.1.tgz", @@ -15328,7 +16103,7 @@ "node_modules/last-run": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", - "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", + "integrity": "sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==", "dev": true, "dependencies": { "default-resolution": "^2.0.0", @@ -15353,7 +16128,7 @@ "node_modules/lcid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "integrity": "sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==", "dev": true, "dependencies": { "invert-kv": "^1.0.0" @@ -15365,7 +16140,7 @@ "node_modules/lcov-parse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", - "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", + "integrity": "sha512-aprLII/vPzuQvYZnDRU78Fns9I2Ag3gi4Ipga/hxnVMCZC8DnR2nI7XBqrPoywGfxqIx/DgarGvDJZAD3YBTgQ==", "dev": true, "bin": { "lcov-parse": "bin/cli.js" @@ -15374,7 +16149,7 @@ "node_modules/lead": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz", - "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", + "integrity": "sha512-IpSVCk9AYvLHo5ctcIXxOBpMWUe+4TKN3VPWAKUbJikkmsGp0VrSM8IttVc32D6J4WUsiPE6aEFRNmIoF/gdow==", "dev": true, "dependencies": { "flush-write-stream": "^1.0.2" @@ -15449,7 +16224,7 @@ "node_modules/lighthouse-logger/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/lines-and-columns": { @@ -15461,18 +16236,40 @@ "node_modules/listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", - "integrity": "sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc=", + "integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==", "dev": true }, + "node_modules/live-connect-common": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.0.tgz", + "integrity": "sha512-pa1SuzCg8ovsB6OziAQZpDid/OT8k37VgWFQkE8OUmG52Kf9PUtJM8wqaGdMXd/rNAe/NH8m+Kxx9MZuOvn5zg==", + "engines": { + "node": ">=18" + } + }, + "node_modules/live-connect-handlers": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/live-connect-handlers/-/live-connect-handlers-2.1.0.tgz", + "integrity": "sha512-uABe9D6yRp7HRgO6vhdIM5j88l17/ROzYGIOHc2Rv1TacLFH6IJ8sbmunY5mIJ9L6ArOVmL4WHY+QgOIkabhxg==", + "dependencies": { + "js-cookie": "^3.0.5", + "live-connect-common": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/live-connect-js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.3.1.tgz", - "integrity": "sha512-4IT8NEOOTNmoYpw5CTxdugSF2w9xqfOujrEqx6zLPdTT3xq/lLdxxvRTREDi+qYHDsCDovdiNO3uOSoemdTCdA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.0.1.tgz", + "integrity": "sha512-+TwM7cjgyutqaMNlTQKNY9nJFDPpSWfoazSHmlWxOPlimp10PSZGABIbtulNGGpYbR/Zxgc+C/uW5OxqcNEPXg==", "dependencies": { + "live-connect-common": "^3.0.0", + "live-connect-handlers": "^2.1.0", "tiny-hashes": "1.0.1" }, "engines": { - "node": ">=8" + "node": ">=18" } }, "node_modules/livereload-js": { @@ -15482,42 +16279,67 @@ "dev": true }, "node_modules/load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==", "dev": true, "dependencies": { "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=0.10.0" + } + }, + "node_modules/load-json-file/node_modules/parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==", + "dev": true, + "dependencies": { + "error-ex": "^1.2.0" + }, + "engines": { + "node": ">=0.10.0" } }, "node_modules/load-json-file/node_modules/pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", "dev": true, "engines": { - "node": ">=4" + "node": ">=0.10.0" + } + }, + "node_modules/load-json-file/node_modules/strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==", + "dev": true, + "dependencies": { + "is-utf8": "^0.2.0" + }, + "engines": { + "node": ">=0.10.0" } }, "node_modules/loader-runner": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.2.0.tgz", - "integrity": "sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", + "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", "dev": true, "engines": { "node": ">=6.11.5" } }, "node_modules/loader-utils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz", - "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", "dev": true, "dependencies": { "big.js": "^5.2.2", @@ -15529,16 +16351,15 @@ } }, "node_modules/locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, "dependencies": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "p-locate": "^4.1.0" }, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/lodash": { @@ -15550,216 +16371,146 @@ "node_modules/lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "integrity": "sha512-rFR6Vpm4HeCK1WPGvjZSJ+7yik8d8PVUdCJx5rT2pogG4Ve/2ZS7kfmO5l5T2o5V2mqlNIfSF5MZlr1+xOoYQQ==", "dev": true }, "node_modules/lodash._basetostring": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", - "dev": true - }, - "node_modules/lodash._basevalues": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", - "dev": true - }, - "node_modules/lodash._escapehtmlchar": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz", - "integrity": "sha1-32fDu2t+jh6DGrSL+geVuSr+iZ0=", - "dev": true, - "dependencies": { - "lodash._htmlescapes": "~2.4.1" - } + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "integrity": "sha512-mTzAr1aNAv/i7W43vOR/uD/aJ4ngbtsRaCubp2BfZhlGU/eORUjg/7F6X0orNMdv33JOrdgGybtvMN/po3EWrA==", + "dev": true }, - "node_modules/lodash._escapestringchar": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._escapestringchar/-/lodash._escapestringchar-2.4.1.tgz", - "integrity": "sha1-7P4iYYoq3lC/7qQ5N+Ud9m8O23I=", + "node_modules/lodash._basevalues": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", + "integrity": "sha512-H94wl5P13uEqlCg7OcNNhMQ8KvWSIyqXzOPusRgHC9DK3o54P6P3xtbXlVbRABG4q5gSmp7EDdJ0MSuW9HX6Mg==", "dev": true }, "node_modules/lodash._getnative": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "node_modules/lodash._htmlescapes": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._htmlescapes/-/lodash._htmlescapes-2.4.1.tgz", - "integrity": "sha1-MtFL8IRLbeb4tioFG09nwii2JMs=", + "integrity": "sha512-RrL9VxMEPyDMHOd9uFbvMe8X55X16/cGM5IgOKgRElQZutpX89iS6vwl64duTV1/16w5JY7tuFNXqoekmh1EmA==", "dev": true }, "node_modules/lodash._isiterateecall": { "version": "3.0.9", "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "node_modules/lodash._isnative": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._isnative/-/lodash._isnative-2.4.1.tgz", - "integrity": "sha1-PqZAS3hKe+g2x7V1gOHN95sUgyw=", - "dev": true - }, - "node_modules/lodash._objecttypes": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.4.1.tgz", - "integrity": "sha1-fAt/admKH3ZSn4kLDNsbTf7BHBE=", + "integrity": "sha512-De+ZbrMu6eThFti/CSzhRvTKMgQToLxbij58LMfM8JnYDNSOjkjTCIaa8ixglOeGh2nyPlakbt5bJWJ7gvpYlQ==", "dev": true }, "node_modules/lodash._reescape": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "integrity": "sha512-Sjlavm5y+FUVIF3vF3B75GyXrzsfYV8Dlv3L4mEpuB9leg8N6yf/7rU06iLPx9fY0Mv3khVp9p7Dx0mGV6V5OQ==", "dev": true }, "node_modules/lodash._reevaluate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "integrity": "sha512-OrPwdDc65iJiBeUe5n/LIjd7Viy99bKwDdk7Z5ljfZg0uFRFlfQaCy9tZ4YMAag9WAZmlVpe1iZrkIMMSMHD3w==", "dev": true }, "node_modules/lodash._reinterpolate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "integrity": "sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA==", "dev": true }, - "node_modules/lodash._reunescapedhtml": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._reunescapedhtml/-/lodash._reunescapedhtml-2.4.1.tgz", - "integrity": "sha1-dHxPxAED6zu4oJduVx96JlnpO6c=", - "dev": true, - "dependencies": { - "lodash._htmlescapes": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, "node_modules/lodash._root": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", - "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "integrity": "sha512-O0pWuFSK6x4EXhM1dhZ8gchNtG7JMqBtrHdoUFUWXD7dJnNSUze1GuyQr5sOs0aCvgGeI3o/OJW8f4ca7FDxmQ==", "dev": true }, - "node_modules/lodash._shimkeys": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.4.1.tgz", - "integrity": "sha1-bpzJZm/wgfC1psl4uD4kLmlJ0gM=", - "dev": true, - "dependencies": { - "lodash._objecttypes": "~2.4.1" - } - }, "node_modules/lodash.clone": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz", - "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=", + "integrity": "sha512-GhrVeweiTD6uTmmn5hV/lzgCQhccwReIVRLHp7LT4SopOjqEZ5BbX8b5WWEtAKasjmy8hR7ZPwsYlxRCku5odg==", "dev": true }, "node_modules/lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==", "dev": true }, "node_modules/lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" }, "node_modules/lodash.defaults": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", - "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==", "dev": true }, "node_modules/lodash.difference": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz", - "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=", + "integrity": "sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==", "dev": true }, "node_modules/lodash.escape": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz", - "integrity": "sha1-LOEsXghNsKV92l5dHu659dF1o7Q=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha512-n1PZMXgaaDWZDSvuNZ/8XOcYO2hOKDqZel5adtR30VKQAtoWs/5AOeFA0vPV8moiPzlqe7F4cP2tzpFewQyelQ==", "dev": true, "dependencies": { - "lodash._escapehtmlchar": "~2.4.1", - "lodash._reunescapedhtml": "~2.4.1", - "lodash.keys": "~2.4.1" + "lodash._root": "^3.0.0" } }, "node_modules/lodash.flatten": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", + "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==", "dev": true }, "node_modules/lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", "dev": true }, "node_modules/lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, "node_modules/lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==", "dev": true }, "node_modules/lodash.isarray": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "node_modules/lodash.ismatch": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz", - "integrity": "sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc=", + "integrity": "sha512-JwObCrNJuT0Nnbuecmqr5DgtuBppuCvGD9lxjFpAzwnVtdGoDQ1zig+5W8k5/6Gcn0gZ3936HDAlGd28i7sOGQ==", "dev": true }, "node_modules/lodash.isobject": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz", - "integrity": "sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0=", + "integrity": "sha512-3/Qptq2vr7WeJbB4KHUSKlq8Pl7ASXi3UG6CMbBm8WRtXi8+GHm7mKaU3urfpSEzWe2wCIChs6/sdocUsTKJiA==", "dev": true }, "node_modules/lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", "dev": true }, "node_modules/lodash.keys": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz", - "integrity": "sha1-SN6kbfj/djKxDXBrissmWR4rNyc=", - "dev": true, - "dependencies": { - "lodash._isnative": "~2.4.1", - "lodash._shimkeys": "~2.4.1", - "lodash.isobject": "~2.4.1" - } - }, - "node_modules/lodash.keys/node_modules/lodash.isobject": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.4.1.tgz", - "integrity": "sha1-Wi5H/mmVPx7mMafrof5k0tBlWPU=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha512-CuBsapFjcubOGMn3VD+24HOAPxM79tH+V6ivJL3CHYjtrawauDJHUk//Yew9Hvc6e9rbCrURGk8z6PC+8WJBfQ==", "dev": true, "dependencies": { - "lodash._objecttypes": "~2.4.1" + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" } }, "node_modules/lodash.merge": { @@ -15771,19 +16522,19 @@ "node_modules/lodash.pickby": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.pickby/-/lodash.pickby-4.6.0.tgz", - "integrity": "sha1-feoh2MGNdwOifHBMFdO4SmfjOv8=", + "integrity": "sha512-AZV+GsS/6ckvPOVQPXSiFFacKvKB4kOQu6ynt9wz0F3LO4R9Ij4K1ddYsIytDpSgLz88JHd9P+oaLeej5/Sl7Q==", "dev": true }, "node_modules/lodash.restparam": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "integrity": "sha512-L4/arjjuq4noiUJpt3yS6KIKDtJwNe2fIYgMqyYYKoeIfV1iEqvPwhCx23o+R9dzouGihDAPN1dTIRWa7zk8tw==", "dev": true }, "node_modules/lodash.some": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", - "integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=", + "integrity": "sha512-j7MJE+TuT51q9ggt4fSgVqro163BEFjAt3u97IqU+JA2DkWl80nFTrowzLpZ/BnpN7rrl0JA/593NAdd8p/scQ==", "dev": true }, "node_modules/lodash.template": { @@ -15808,28 +16559,19 @@ "node_modules/lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", "dev": true }, "node_modules/lodash.union": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.union/-/lodash.union-4.6.0.tgz", - "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=", + "integrity": "sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==", "dev": true }, - "node_modules/lodash.values": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz", - "integrity": "sha1-q/UUQ2s8twUAFieXjLzzCxKA7qQ=", - "dev": true, - "dependencies": { - "lodash.keys": "~2.4.1" - } - }, "node_modules/lodash.zip": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz", - "integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=", + "integrity": "sha512-C7IOaBBK/0gMORRBd8OETNx3kmOkgIWIPvyDpZSCTwUrpYmgZwJkjZeOD8ww4xbOUOs4/attY+pciKvadNfFbg==", "dev": true }, "node_modules/log-driver": { @@ -15854,16 +16596,16 @@ } }, "node_modules/log4js": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.2.tgz", - "integrity": "sha512-k80cggS2sZQLBwllpT1p06GtfvzMmSdUCkW96f0Hj83rKGJDAu2vZjt9B9ag2vx8Zz1IXzxoLgqvRJCdMKybGg==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.7.0.tgz", + "integrity": "sha512-KA0W9ffgNBLDj6fZCq/lRbgR6ABAodRIDHrZnS48vOtfKa4PzWImb0Md1lmGCdO3n3sbCm/n1/WmrNlZ8kCI3Q==", "dev": true, "dependencies": { - "date-format": "^4.0.4", - "debug": "^4.3.3", - "flatted": "^3.2.5", + "date-format": "^4.0.14", + "debug": "^4.3.4", + "flatted": "^3.2.7", "rfdc": "^1.3.0", - "streamroller": "^3.0.4" + "streamroller": "^3.1.3" }, "engines": { "node": ">=8.0" @@ -15895,9 +16637,9 @@ "dev": true }, "node_modules/longest-streak": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz", - "integrity": "sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.0.1.tgz", + "integrity": "sha512-cHlYSUpL2s7Fb3394mYxwTYj8niTaNHUCLr0qdiCXQfSjfuA7CKofpX2uSwEfFDQ0EB7JcnMnm+GjbqqoinYYg==", "dev": true, "funding": { "type": "github", @@ -15916,19 +16658,6 @@ "loose-envify": "cli.js" } }, - "node_modules/loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, - "dependencies": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/loupe": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", @@ -15962,12 +16691,23 @@ "node_modules/lru-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", "dev": true, "dependencies": { "es5-ext": "~0.10.2" } }, + "node_modules/m3u8-parser": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/m3u8-parser/-/m3u8-parser-4.7.1.tgz", + "integrity": "sha512-pbrQwiMiq+MmI9bl7UjtPT3AK603PV9bogNlr83uC+X9IoxqL5E4k7kU7fMQ0dpRgxgeSMygqUa0IMLQNXLBNA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "^3.0.5", + "global": "^4.4.0" + } + }, "node_modules/magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", @@ -16017,34 +16757,31 @@ "node_modules/map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/map-obj": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz", - "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==", "dev": true, "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=0.10.0" } }, "node_modules/map-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", - "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=", + "integrity": "sha512-C0X0KQmGm3N2ftbTGBhSyuydQ+vV1LC3f3zPvT3RXHXNZrvfPZcoXp/N5DOa8vedX/rTMm2CjTtivFg2STJMRQ==", "dev": true }, "node_modules/map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "integrity": "sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==", "dev": true, "dependencies": { "object-visit": "^1.0.0" @@ -16054,28 +16791,25 @@ } }, "node_modules/markdown-table": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-2.0.0.tgz", - "integrity": "sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.2.tgz", + "integrity": "sha512-y8j3a5/DkJCmS5x4dMCQL+OR0+2EAq3DOtio1COSHsmW2BGXnNCK3v12hJt1LrUz5iZH5g0LmuYOjDdI+czghA==", "dev": true, - "dependencies": { - "repeat-string": "^1.0.0" - }, "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" } }, "node_modules/marky": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.4.tgz", - "integrity": "sha512-zd2/GiSn6U3/jeFVZ0J9CA1LzQ8RfIVvXkb/U0swFHF/zT+dVohTAWjmo2DcIuofmIIIROlwTbd+shSeXmxr0w==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.5.tgz", + "integrity": "sha512-q9JtQJKjpsVxCRVgQ+WapguSbKC3SQ5HEzFGPAJMStgh3QjCawp00UKv3MTTAArTmGmmPUvllHZoNbZ3gs0I+Q==", "dev": true }, "node_modules/matchdep": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz", - "integrity": "sha1-xvNINKDY28OzfCfui7yyfHd1WC4=", + "integrity": "sha512-LFgVbaHIHMqCRuCZyfCtUOq9/Lnzhi7Z0KFUE2fhD54+JN2jLh3hC02RLkqauJ3U4soU6H1J3tfj/Byk7GoEjA==", "dev": true, "dependencies": { "findup-sync": "^2.0.0", @@ -16087,10 +16821,110 @@ "node": ">= 0.10.0" } }, + "node_modules/matchdep/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "dependencies": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/braces/node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/braces/node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", + "dev": true, + "dependencies": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/fill-range/node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/fill-range/node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/matchdep/node_modules/findup-sync": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "integrity": "sha512-vs+3unmJT45eczmcAZ6zMJtxN3l/QXeccaXQx5cu/MeJMhewVfoWZqibRkOxPnmoR59+Zy5hjabfQc6JLSah4g==", "dev": true, "dependencies": { "detect-file": "^1.0.0", @@ -16102,10 +16936,16 @@ "node": ">= 0.10" } }, + "node_modules/matchdep/node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, "node_modules/matchdep/node_modules/is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "dependencies": { "is-extglob": "^2.1.0" @@ -16114,13 +16954,85 @@ "node": ">=0.10.0" } }, + "node_modules/matchdep/node_modules/is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "dependencies": { + "kind-of": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/is-number/node_modules/kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "dependencies": { + "is-buffer": "^1.1.5" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "dependencies": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/matchdep/node_modules/to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", + "dev": true, + "dependencies": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/mdast-util-definitions": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-4.0.0.tgz", - "integrity": "sha512-k8AJ6aNnUkB7IE+5azR9h81O5EQ/cTDXtWdMq9Kk5KcEW/8ritU5CeLg/9HhOC++nALHBlaogJ5jz0Ybk3kPMQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-5.1.1.tgz", + "integrity": "sha512-rQ+Gv7mHttxHOBx2dkF4HWTg+EE+UR78ptQWDylzPKaQuVGdG4HIoY3SrS/pCp80nZ04greFvXbVFHT+uf0JVQ==", "dev": true, "dependencies": { - "unist-util-visit": "^2.0.0" + "@types/mdast": "^3.0.0", + "@types/unist": "^2.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", @@ -16128,14 +17040,14 @@ } }, "node_modules/mdast-util-find-and-replace": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-1.1.1.tgz", - "integrity": "sha512-9cKl33Y21lyckGzpSmEQnIDjEfeeWelN5s1kUW1LwdB0Fkuq2u+4GdqcGEygYxJE8GVqCl0741bYXHgamfWAZA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-2.2.1.tgz", + "integrity": "sha512-SobxkQXFAdd4b5WmEakmkVoh18icjQRxGy5OWTCzgsLRm1Fu/KCtwD1HIQSsmq5ZRjVH0Ehwg6/Fn3xIUk+nKw==", "dev": true, "dependencies": { - "escape-string-regexp": "^4.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "escape-string-regexp": "^5.0.0", + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^5.0.0" }, "funding": { "type": "opencollective", @@ -16143,28 +17055,35 @@ } }, "node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", "dev": true, "engines": { - "node": ">=10" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/mdast-util-from-markdown": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz", - "integrity": "sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-1.2.0.tgz", + "integrity": "sha512-iZJyyvKD1+K7QX1b5jXdE7Sc5dtoTry1vzV28UZZe8Z1xVnB/czKntJ7ZAkG0tANqRnBF6p3p7GpU1y19DTf2Q==", "dev": true, "dependencies": { "@types/mdast": "^3.0.0", - "mdast-util-to-string": "^2.0.0", - "micromark": "~2.11.0", - "parse-entities": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" + "@types/unist": "^2.0.0", + "decode-named-character-reference": "^1.0.0", + "mdast-util-to-string": "^3.1.0", + "micromark": "^3.0.0", + "micromark-util-decode-numeric-character-reference": "^1.0.0", + "micromark-util-decode-string": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "unist-util-stringify-position": "^3.0.0", + "uvu": "^0.5.0" }, "funding": { "type": "opencollective", @@ -16172,9 +17091,9 @@ } }, "node_modules/mdast-util-from-markdown/node_modules/mdast-util-to-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", - "integrity": "sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", + "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==", "dev": true, "funding": { "type": "opencollective", @@ -16182,16 +17101,18 @@ } }, "node_modules/mdast-util-gfm": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-0.1.2.tgz", - "integrity": "sha512-NNkhDx/qYcuOWB7xHUGWZYVXvjPFFd6afg6/e2g+SV4r9q5XUcCbV4Wfa3DLYIiD+xAEZc6K4MGaE/m0KDcPwQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-2.0.1.tgz", + "integrity": "sha512-42yHBbfWIFisaAfV1eixlabbsa6q7vHeSPY+cg+BBjX51M8xhgMacqH9g6TftB/9+YkcI0ooV4ncfrJslzm/RQ==", "dev": true, "dependencies": { - "mdast-util-gfm-autolink-literal": "^0.1.0", - "mdast-util-gfm-strikethrough": "^0.2.0", - "mdast-util-gfm-table": "^0.1.0", - "mdast-util-gfm-task-list-item": "^0.1.0", - "mdast-util-to-markdown": "^0.6.1" + "mdast-util-from-markdown": "^1.0.0", + "mdast-util-gfm-autolink-literal": "^1.0.0", + "mdast-util-gfm-footnote": "^1.0.0", + "mdast-util-gfm-strikethrough": "^1.0.0", + "mdast-util-gfm-table": "^1.0.0", + "mdast-util-gfm-task-list-item": "^1.0.0", + "mdast-util-to-markdown": "^1.0.0" }, "funding": { "type": "opencollective", @@ -16199,14 +17120,30 @@ } }, "node_modules/mdast-util-gfm-autolink-literal": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.3.tgz", - "integrity": "sha512-GjmLjWrXg1wqMIO9+ZsRik/s7PLwTaeCHVB7vRxUwLntZc8mzmTsLVr6HW1yLokcnhfURsn5zmSVdi3/xWWu1A==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-1.0.2.tgz", + "integrity": "sha512-FzopkOd4xTTBeGXhXSBU0OCDDh5lUj2rd+HQqG92Ld+jL4lpUfgX2AT2OHAVP9aEeDKp7G92fuooSZcYJA3cRg==", + "dev": true, + "dependencies": { + "@types/mdast": "^3.0.0", + "ccount": "^2.0.0", + "mdast-util-find-and-replace": "^2.0.0", + "micromark-util-character": "^1.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-gfm-footnote": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-1.0.1.tgz", + "integrity": "sha512-p+PrYlkw9DeCRkTVw1duWqPRHX6Ywh2BNKJQcZbCwAuP/59B0Lk9kakuAd7KbQprVO4GzdW8eS5++A9PUSqIyw==", "dev": true, "dependencies": { - "ccount": "^1.0.0", - "mdast-util-find-and-replace": "^1.1.0", - "micromark": "^2.11.3" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.3.0", + "micromark-util-normalize-identifier": "^1.0.0" }, "funding": { "type": "opencollective", @@ -16214,12 +17151,13 @@ } }, "node_modules/mdast-util-gfm-strikethrough": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-0.2.3.tgz", - "integrity": "sha512-5OQLXpt6qdbttcDG/UxYY7Yjj3e8P7X16LzvpX8pIQPYJ/C2Z1qFGMmcw+1PZMUM3Z8wt8NRfYTvCni93mgsgA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-1.0.1.tgz", + "integrity": "sha512-zKJbEPe+JP6EUv0mZ0tQUyLQOC+FADt0bARldONot/nefuISkaZFlmVK4tU6JgfyZGrky02m/I6PmehgAgZgqg==", "dev": true, "dependencies": { - "mdast-util-to-markdown": "^0.6.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.3.0" }, "funding": { "type": "opencollective", @@ -16227,13 +17165,15 @@ } }, "node_modules/mdast-util-gfm-table": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-0.1.6.tgz", - "integrity": "sha512-j4yDxQ66AJSBwGkbpFEp9uG/LS1tZV3P33fN1gkyRB2LoRL+RR3f76m0HPHaby6F4Z5xr9Fv1URmATlRRUIpRQ==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-1.0.6.tgz", + "integrity": "sha512-uHR+fqFq3IvB3Rd4+kzXW8dmpxUhvgCQZep6KdjsLK4O6meK5dYZEayLtIxNus1XO3gfjfcIFe8a7L0HZRGgag==", "dev": true, "dependencies": { - "markdown-table": "^2.0.0", - "mdast-util-to-markdown": "~0.6.0" + "@types/mdast": "^3.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^1.0.0", + "mdast-util-to-markdown": "^1.3.0" }, "funding": { "type": "opencollective", @@ -16241,12 +17181,13 @@ } }, "node_modules/mdast-util-gfm-task-list-item": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-0.1.6.tgz", - "integrity": "sha512-/d51FFIfPsSmCIRNp7E6pozM9z1GYPIkSy1urQ8s/o4TC22BZ7DqfHFWiqBD23bc7J3vV1Fc9O4QIHBlfuit8A==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-1.0.1.tgz", + "integrity": "sha512-KZ4KLmPdABXOsfnM6JHUIjxEvcx2ulk656Z/4Balw071/5qgnhz+H1uGtf2zIGnrnvDC8xR4Fj9uKbjAFGNIeA==", "dev": true, "dependencies": { - "mdast-util-to-markdown": "~0.6.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.3.0" }, "funding": { "type": "opencollective", @@ -16256,26 +17197,27 @@ "node_modules/mdast-util-inject": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mdast-util-inject/-/mdast-util-inject-1.1.0.tgz", - "integrity": "sha1-2wa4tYW+lZotzS+H9HK6m3VvNnU=", + "integrity": "sha512-CcJ0mHa36QYumDKiZ2OIR+ClhfOM7zIzN+Wfy8tRZ1hpH9DKLCS+Mh4DyK5bCxzE9uxMWcbIpeNFWsg1zrj/2g==", "dev": true, "dependencies": { "mdast-util-to-string": "^1.0.0" } }, "node_modules/mdast-util-to-hast": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-10.2.0.tgz", - "integrity": "sha512-JoPBfJ3gBnHZ18icCwHR50orC9kNH81tiR1gs01D8Q5YpV6adHNO9nKNuFBCJQ941/32PT1a63UF/DitmS3amQ==", + "version": "12.2.4", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-12.2.4.tgz", + "integrity": "sha512-a21xoxSef1l8VhHxS1Dnyioz6grrJkoaCUgGzMD/7dWHvboYX3VW53esRUfB5tgTyz4Yos1n25SPcj35dJqmAg==", "dev": true, "dependencies": { + "@types/hast": "^2.0.0", "@types/mdast": "^3.0.0", - "@types/unist": "^2.0.0", - "mdast-util-definitions": "^4.0.0", - "mdurl": "^1.0.0", - "unist-builder": "^2.0.0", - "unist-util-generated": "^1.0.0", - "unist-util-position": "^3.0.0", - "unist-util-visit": "^2.0.0" + "mdast-util-definitions": "^5.0.0", + "micromark-util-sanitize-uri": "^1.1.0", + "trim-lines": "^3.0.0", + "unist-builder": "^3.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", @@ -16283,17 +17225,18 @@ } }, "node_modules/mdast-util-to-markdown": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.5.tgz", - "integrity": "sha512-XeV9sDE7ZlOQvs45C9UKMtfTcctcaj/pGwH8YLbMHoMOXNNCn2LsqVQOqrF1+/NU8lKDAqozme9SCXWyo9oAcQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-1.3.0.tgz", + "integrity": "sha512-6tUSs4r+KK4JGTTiQ7FfHmVOaDrLQJPmpjD6wPMlHGUVXoG9Vjc3jIeP+uyBWRf8clwB2blM+W7+KrlMYQnftA==", "dev": true, "dependencies": { + "@types/mdast": "^3.0.0", "@types/unist": "^2.0.0", - "longest-streak": "^2.0.0", - "mdast-util-to-string": "^2.0.0", - "parse-entities": "^2.0.0", - "repeat-string": "^1.0.0", - "zwitch": "^1.0.0" + "longest-streak": "^3.0.0", + "mdast-util-to-string": "^3.0.0", + "micromark-util-decode-string": "^1.0.0", + "unist-util-visit": "^4.0.0", + "zwitch": "^2.0.0" }, "funding": { "type": "opencollective", @@ -16301,9 +17244,9 @@ } }, "node_modules/mdast-util-to-markdown/node_modules/mdast-util-to-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", - "integrity": "sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", + "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==", "dev": true, "funding": { "type": "opencollective", @@ -16321,359 +17264,106 @@ } }, "node_modules/mdast-util-toc": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-5.1.0.tgz", - "integrity": "sha512-csimbRIVkiqc+PpFeKDGQ/Ck2N4f9FYH3zzBMMJzcxoKL8m+cM0n94xXm0I9eaxHnKdY9n145SGTdyJC7i273g==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-6.1.0.tgz", + "integrity": "sha512-0PuqZELXZl4ms1sF7Lqigrqik4Ll3UhbI+jdTrfw7pZ9QPawgl7LD4GQ8MkU7bT/EwiVqChNTbifa2jLLKo76A==", "dev": true, "dependencies": { - "@types/mdast": "^3.0.3", - "@types/unist": "^2.0.3", - "extend": "^3.0.2", - "github-slugger": "^1.2.1", - "mdast-util-to-string": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit": "^2.0.0" + "@types/extend": "^3.0.0", + "@types/github-slugger": "^1.0.0", + "@types/mdast": "^3.0.0", + "extend": "^3.0.0", + "github-slugger": "^1.0.0", + "mdast-util-to-string": "^3.1.0", + "unist-util-is": "^5.0.0", + "unist-util-visit": "^3.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdast-util-toc/node_modules/github-slugger": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.4.0.tgz", - "integrity": "sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ==", - "dev": true - }, "node_modules/mdast-util-toc/node_modules/mdast-util-to-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", - "integrity": "sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", + "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==", "dev": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", - "dev": true - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/memoizee": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", - "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", - "dev": true, - "dependencies": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-weak-map": "^2.0.3", - "event-emitter": "^0.3.5", - "is-promise": "^2.2.2", - "lru-queue": "^0.1.0", - "next-tick": "^1.1.0", - "timers-ext": "^0.1.7" - } - }, - "node_modules/memory-fs": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", - "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", - "dev": true, - "dependencies": { - "errno": "^0.1.3", - "readable-stream": "^2.0.1" - }, - "engines": { - "node": ">=4.3.0 <5.0.0 || >=5.10" - } - }, - "node_modules/meow": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/meow/-/meow-8.1.2.tgz", - "integrity": "sha512-r85E3NdZ+mpYk1C6RjPFEMSE+s1iZMuHtsHAqY0DT3jZczl0diWUZ8g6oU7h0M9cD2EL+PzaYghhCLzR0ZNn5Q==", - "dev": true, - "dependencies": { - "@types/minimist": "^1.2.0", - "camelcase-keys": "^6.2.2", - "decamelize-keys": "^1.1.0", - "hard-rejection": "^2.1.0", - "minimist-options": "4.1.0", - "normalize-package-data": "^3.0.0", - "read-pkg-up": "^7.0.1", - "redent": "^3.0.0", - "trim-newlines": "^3.0.0", - "type-fest": "^0.18.0", - "yargs-parser": "^20.2.3" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/meow/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/meow/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/normalize-package-data": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", - "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", - "dev": true, - "dependencies": { - "hosted-git-info": "^4.0.1", - "is-core-module": "^2.5.0", - "semver": "^7.3.4", - "validate-npm-package-license": "^3.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/meow/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/meow/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/meow/node_modules/parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/meow/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/read-pkg": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", - "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", - "dev": true, - "dependencies": { - "@types/normalize-package-data": "^2.4.0", - "normalize-package-data": "^2.5.0", - "parse-json": "^5.0.0", - "type-fest": "^0.6.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/read-pkg-up": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", - "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", - "dev": true, - "dependencies": { - "find-up": "^4.1.0", - "read-pkg": "^5.2.0", - "type-fest": "^0.8.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/meow/node_modules/read-pkg-up/node_modules/type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/read-pkg/node_modules/hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true - }, - "node_modules/meow/node_modules/read-pkg/node_modules/normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "dependencies": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "node_modules/meow/node_modules/read-pkg/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, - "node_modules/meow/node_modules/read-pkg/node_modules/type-fest": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", - "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/meow/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/meow/node_modules/type-fest": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", - "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", + "node_modules/mdast-util-toc/node_modules/unist-util-visit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", + "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", "dev": true, - "engines": { - "node": ">=10" + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^4.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/meow/node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "node_modules/mdast-util-toc/node_modules/unist-util-visit-parents": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", + "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", "dev": true, - "engines": { - "node": ">=10" + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "engines": { + "node": ">= 0.6" + } }, - "node_modules/merge-source-map": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", - "integrity": "sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==", + "node_modules/memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", "dev": true, "dependencies": { - "source-map": "^0.6.1" + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" } }, - "node_modules/merge-source-map/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "node_modules/memory-fs": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", + "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", "dev": true, + "dependencies": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" + }, "engines": { - "node": ">=0.10.0" + "node": ">=4.3.0 <5.0.0 || >=5.10" } }, + "node_modules/merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -16683,15 +17373,15 @@ "node_modules/methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", "engines": { "node": ">= 0.6" } }, "node_modules/micromark": { - "version": "2.11.4", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.4.tgz", - "integrity": "sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-3.1.0.tgz", + "integrity": "sha512-6Mj0yHLdUZjHnOPgr5xfWIMqMWS12zDN6iws9SLuSz76W8jTtAv24MN4/CL7gJrl5vtxGInkkqDv/JIoRsQOvA==", "dev": true, "funding": [ { @@ -16704,22 +17394,73 @@ } ], "dependencies": { + "@types/debug": "^4.0.0", "debug": "^4.0.0", - "parse-entities": "^2.0.0" + "decode-named-character-reference": "^1.0.0", + "micromark-core-commonmark": "^1.0.1", + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-chunked": "^1.0.0", + "micromark-util-combine-extensions": "^1.0.0", + "micromark-util-decode-numeric-character-reference": "^1.0.0", + "micromark-util-encode": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-sanitize-uri": "^1.0.0", + "micromark-util-subtokenize": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.1", + "uvu": "^0.5.0" + } + }, + "node_modules/micromark-core-commonmark": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.0.6.tgz", + "integrity": "sha512-K+PkJTxqjFfSNkfAhp4GB+cZPfQd6dxtTXnf+RjZOV7T4EEXnvgzOcnp+eSTmpGk9d1S9sL6/lqrgSNn/s0HZA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-factory-destination": "^1.0.0", + "micromark-factory-label": "^1.0.0", + "micromark-factory-space": "^1.0.0", + "micromark-factory-title": "^1.0.0", + "micromark-factory-whitespace": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-chunked": "^1.0.0", + "micromark-util-classify-character": "^1.0.0", + "micromark-util-html-tag-name": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-subtokenize": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.1", + "uvu": "^0.5.0" } }, "node_modules/micromark-extension-gfm": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-0.3.3.tgz", - "integrity": "sha512-oVN4zv5/tAIA+l3GbMi7lWeYpJ14oQyJ3uEim20ktYFAcfX1x3LNlFGGlmrZHt7u9YlKExmyJdDGaTt6cMSR/A==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-2.0.1.tgz", + "integrity": "sha512-p2sGjajLa0iYiGQdT0oelahRYtMWvLjy8J9LOCxzIQsllMCGLbsLW+Nc+N4vi02jcRJvedVJ68cjelKIO6bpDA==", "dev": true, "dependencies": { - "micromark": "~2.11.0", - "micromark-extension-gfm-autolink-literal": "~0.5.0", - "micromark-extension-gfm-strikethrough": "~0.6.5", - "micromark-extension-gfm-table": "~0.4.0", - "micromark-extension-gfm-tagfilter": "~0.3.0", - "micromark-extension-gfm-task-list-item": "~0.3.0" + "micromark-extension-gfm-autolink-literal": "^1.0.0", + "micromark-extension-gfm-footnote": "^1.0.0", + "micromark-extension-gfm-strikethrough": "^1.0.0", + "micromark-extension-gfm-table": "^1.0.0", + "micromark-extension-gfm-tagfilter": "^1.0.0", + "micromark-extension-gfm-task-list-item": "^1.0.0", + "micromark-util-combine-extensions": "^1.0.0", + "micromark-util-types": "^1.0.0" }, "funding": { "type": "opencollective", @@ -16727,12 +17468,36 @@ } }, "node_modules/micromark-extension-gfm-autolink-literal": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.7.tgz", - "integrity": "sha512-ePiDGH0/lhcngCe8FtH4ARFoxKTUelMp4L7Gg2pujYD5CSMb9PbblnyL+AAMud/SNMyusbS2XDSiPIRcQoNFAw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-1.0.3.tgz", + "integrity": "sha512-i3dmvU0htawfWED8aHMMAzAVp/F0Z+0bPh3YrbTPPL1v4YAlCZpy5rBO5p0LPYiZo0zFVkoYh7vDU7yQSiCMjg==", + "dev": true, + "dependencies": { + "micromark-util-character": "^1.0.0", + "micromark-util-sanitize-uri": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-gfm-footnote": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-1.0.4.tgz", + "integrity": "sha512-E/fmPmDqLiMUP8mLJ8NbJWJ4bTw6tS+FEQS8CcuDtZpILuOb2kjLqPEeAePF1djXROHXChM/wPJw0iS4kHCcIg==", "dev": true, "dependencies": { - "micromark": "~2.11.3" + "micromark-core-commonmark": "^1.0.0", + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-sanitize-uri": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" }, "funding": { "type": "opencollective", @@ -16740,12 +17505,17 @@ } }, "node_modules/micromark-extension-gfm-strikethrough": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.5.tgz", - "integrity": "sha512-PpOKlgokpQRwUesRwWEp+fHjGGkZEejj83k9gU5iXCbDG+XBA92BqnRKYJdfqfkrRcZRgGuPuXb7DaK/DmxOhw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-1.0.4.tgz", + "integrity": "sha512-/vjHU/lalmjZCT5xt7CcHVJGq8sYRm80z24qAKXzaHzem/xsDYb2yLL+NNVbYvmpLx3O7SYPuGL5pzusL9CLIQ==", "dev": true, "dependencies": { - "micromark": "~2.11.0" + "micromark-util-chunked": "^1.0.0", + "micromark-util-classify-character": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" }, "funding": { "type": "opencollective", @@ -16753,12 +17523,16 @@ } }, "node_modules/micromark-extension-gfm-table": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.3.tgz", - "integrity": "sha512-hVGvESPq0fk6ALWtomcwmgLvH8ZSVpcPjzi0AjPclB9FsVRgMtGZkUcpE0zgjOCFAznKepF4z3hX8z6e3HODdA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-1.0.5.tgz", + "integrity": "sha512-xAZ8J1X9W9K3JTJTUL7G6wSKhp2ZYHrFk5qJgY/4B33scJzE2kpfRL6oiw/veJTbt7jiM/1rngLlOKPWr1G+vg==", "dev": true, "dependencies": { - "micromark": "~2.11.0" + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" }, "funding": { "type": "opencollective", @@ -16766,141 +17540,420 @@ } }, "node_modules/micromark-extension-gfm-tagfilter": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-0.3.0.tgz", - "integrity": "sha512-9GU0xBatryXifL//FJH+tAZ6i240xQuFrSL7mYi8f4oZSbc+NvXjkrHemeYP0+L4ZUT+Ptz3b95zhUZnMtoi/Q==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-1.0.1.tgz", + "integrity": "sha512-Ty6psLAcAjboRa/UKUbbUcwjVAv5plxmpUTy2XC/3nJFL37eHej8jrHrRzkqcpipJliuBH30DTs7+3wqNcQUVA==", "dev": true, + "dependencies": { + "micromark-util-types": "^1.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, "node_modules/micromark-extension-gfm-task-list-item": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-0.3.3.tgz", - "integrity": "sha512-0zvM5iSLKrc/NQl84pZSjGo66aTGd57C1idmlWmE87lkMcXrTxg1uXa/nXomxJytoje9trP0NDLvw4bZ/Z/XCQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-1.0.3.tgz", + "integrity": "sha512-PpysK2S1Q/5VXi72IIapbi/jliaiOFzv7THH4amwXeYXLq3l1uo8/2Be0Ac1rEwK20MQEsGH2ltAZLNY2KI/0Q==", "dev": true, "dependencies": { - "micromark": "~2.11.0" + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "node_modules/micromark-factory-destination": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-1.0.0.tgz", + "integrity": "sha512-eUBA7Rs1/xtTVun9TmV3gjfPz2wEwgK5R5xcbIM5ZYAtvGF6JkyaDsj0agx8urXnO31tEO6Ug83iVH3tdedLnw==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "dependencies": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - }, - "engines": { - "node": ">=0.10.0" + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" } }, - "node_modules/micromatch/node_modules/braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "node_modules/micromark-factory-label": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-1.0.2.tgz", + "integrity": "sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "dependencies": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "engines": { - "node": ">=0.10.0" + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" } }, - "node_modules/micromatch/node_modules/braces/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "node_modules/micromark-factory-space": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.0.0.tgz", + "integrity": "sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" + "micromark-util-character": "^1.0.0", + "micromark-util-types": "^1.0.0" } }, - "node_modules/micromatch/node_modules/fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "node_modules/micromark-factory-title": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-1.0.2.tgz", + "integrity": "sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "dependencies": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "engines": { - "node": ">=0.10.0" + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" } }, - "node_modules/micromatch/node_modules/fill-range/node_modules/extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "node_modules/micromark-factory-whitespace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-1.0.0.tgz", + "integrity": "sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "dependencies": { - "is-extendable": "^0.1.0" - }, - "engines": { - "node": ">=0.10.0" + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" } }, - "node_modules/micromatch/node_modules/is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "node_modules/micromark-util-character": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.1.0.tgz", + "integrity": "sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==", "dev": true, - "engines": { - "node": ">=0.10.0" + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" } }, - "node_modules/micromatch/node_modules/kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "node_modules/micromark-util-chunked": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-1.0.0.tgz", + "integrity": "sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==", "dev": true, - "engines": { - "node": ">=0.10.0" + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^1.0.0" } }, - "node_modules/micromatch/node_modules/to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "node_modules/micromark-util-classify-character": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-1.0.0.tgz", + "integrity": "sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "dependencies": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-1.0.0.tgz", + "integrity": "sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-chunked": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-1.0.0.tgz", + "integrity": "sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^1.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-1.0.2.tgz", + "integrity": "sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-decode-numeric-character-reference": "^1.0.0", + "micromark-util-symbol": "^1.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-1.0.1.tgz", + "integrity": "sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromark-util-html-tag-name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-1.1.0.tgz", + "integrity": "sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-1.0.0.tgz", + "integrity": "sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^1.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-1.0.0.tgz", + "integrity": "sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-types": "^1.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.1.0.tgz", + "integrity": "sha512-RoxtuSCX6sUNtxhbmsEFQfWzs8VN7cTctmBPvYivo98xb/kDEoTCtJQX5wyzIYEmk/lvNFTat4hL8oW0KndFpg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-character": "^1.0.0", + "micromark-util-encode": "^1.0.0", + "micromark-util-symbol": "^1.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-1.0.2.tgz", + "integrity": "sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-chunked": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.0.1.tgz", + "integrity": "sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromark-util-types": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.0.2.tgz", + "integrity": "sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" }, "engines": { - "node": ">=0.10.0" + "node": ">=8.6" } }, "node_modules/mime": { @@ -16916,19 +17969,19 @@ } }, "node_modules/mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dependencies": { - "mime-db": "1.51.0" + "mime-db": "1.52.0" }, "engines": { "node": ">= 0.6" @@ -16952,135 +18005,235 @@ "node": ">=4" } }, - "node_modules/min-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", - "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "node_modules/min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==", + "dev": true, + "dependencies": { + "dom-walk": "^0.1.0" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mixin-deep": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, + "dependencies": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true + }, + "node_modules/mocha": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", + "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true, "engines": { - "node": ">=4" + "node": ">=6" } }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "node_modules/mocha/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "dependencies": { - "brace-expansion": "^1.1.7" + "color-convert": "^2.0.1" }, "engines": { - "node": "*" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "node_modules/mocha/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/minimist-options": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz", - "integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==", + "node_modules/mocha/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "dependencies": { - "arrify": "^1.0.1", - "is-plain-obj": "^1.1.0", - "kind-of": "^6.0.3" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">= 6" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/minimist-options/node_modules/kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "node_modules/mocha/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, "engines": { - "node": ">=0.10.0" + "node": ">=8" } }, - "node_modules/mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "node_modules/mocha/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, "dependencies": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" } }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "node_modules/mocha/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, - "bin": { - "mkdirp": "bin/cmd.js" + "dependencies": { + "color-name": "~1.1.4" }, "engines": { - "node": ">=10" + "node": ">=7.0.0" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "node_modules/mocha/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "node_modules/mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "node_modules/mocha/node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true, - "dependencies": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha" - }, "engines": { - "node": ">= 4.0.0" + "node": ">=0.3.1" } }, - "node_modules/mocha/node_modules/debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "node_modules/mocha/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, - "dependencies": { - "ms": "2.0.0" + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "node_modules/mocha/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, "engines": { - "node": ">=0.3.1" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/mocha/node_modules/glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "dependencies": { "fs.realpath": "^1.0.0", @@ -17092,21 +18245,15 @@ }, "engines": { "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mocha/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "dependencies": { "brace-expansion": "^1.1.7" @@ -17115,136 +18262,167 @@ "node": "*" } }, - "node_modules/mocha/node_modules/minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "node_modules/mocha/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } }, - "node_modules/mocha/node_modules/mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", + "node_modules/mocha/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "dependencies": { - "minimist": "0.0.8" + "argparse": "^2.0.1" }, "bin": { - "mkdirp": "bin/cmd.js" + "js-yaml": "bin/js-yaml.js" } }, - "node_modules/mocha/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "node_modules/mocha/node_modules/supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "node_modules/mocha/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "dependencies": { - "has-flag": "^3.0.0" + "p-locate": "^5.0.0" }, "engines": { - "node": ">=4" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/modify-values": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", - "integrity": "sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==", + "node_modules/mocha/node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, "engines": { - "node": ">=0.10.0" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/module-deps-sortable": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/module-deps-sortable/-/module-deps-sortable-5.0.3.tgz", - "integrity": "sha512-eiyIZj/A0dj1o4ywXWqicazUL3l0HP3TydUR6xF0X3xh3LGBMLqW8a9aFe6MuNH4mxNMk53QKBHM6LOPR8kSgw==", + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, "dependencies": { - "browser-resolve": "^1.7.0", - "cached-path-relative": "^1.0.0", - "concat-stream": "~1.5.0", - "defined": "^1.0.0", - "detective": "^5.2.0", - "duplexer2": "^0.1.2", - "inherits": "^2.0.1", - "JSONStream": "^1.0.3", - "konan": "^2.1.1", - "readable-stream": "^2.0.2", - "resolve": "^1.1.3", - "standard-version": "^9.0.0", - "stream-combiner2": "^1.1.1", - "subarg": "^1.0.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - }, - "bin": { - "module-deps": "bin/cmd.js" + "brace-expansion": "^2.0.1" }, "engines": { - "node": ">= 0.6" + "node": ">=10" } }, - "node_modules/module-deps-sortable/node_modules/concat-stream": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", + "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, - "engines": [ - "node >= 0.8" - ], "dependencies": { - "inherits": "~2.0.1", - "readable-stream": "~2.0.0", - "typedarray": "~0.0.5" + "balanced-match": "^1.0.0" } }, - "node_modules/module-deps-sortable/node_modules/concat-stream/node_modules/readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/mocha/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/module-deps-sortable/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "node_modules/mocha/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "node_modules/module-deps-sortable/node_modules/process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true + "node_modules/mocha/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "node_modules/module-deps-sortable/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true + "node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } }, - "node_modules/module-deps-sortable/node_modules/through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "node_modules/mocha/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, "dependencies": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true, + "engines": { + "node": ">=10" } }, "node_modules/morgan": { @@ -17272,25 +18450,52 @@ "ms": "2.0.0" } }, - "node_modules/morgan/node_modules/depd": { + "node_modules/morgan/node_modules/ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/morgan/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, "engines": { "node": ">= 0.8" } }, - "node_modules/morgan/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true + "node_modules/mpd-parser": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/mpd-parser/-/mpd-parser-0.21.1.tgz", + "integrity": "sha512-BxlSXWbKE1n7eyEPBnTEkrzhS3PdmkkKdM1pgKbPnPOH0WFZIc0sPOWi7m0Uo3Wd2a4Or8Qf4ZbS7+ASqQ49fw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "^3.0.5", + "@xmldom/xmldom": "^0.7.2", + "global": "^4.4.0" + }, + "bin": { + "mpd-to-m3u8-json": "bin/parse.js" + } + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "engines": { + "node": ">=4" + } }, "node_modules/mrmime": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.0.tgz", - "integrity": "sha512-a70zx7zFfVO7XpnQ2IX1Myh9yY4UYvfld/dikWRnsXxbyvMcfz+u6UfgNAtH+k2QqtJuzVpv6eLTx1G2+WKZbQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz", + "integrity": "sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==", "dev": true, "engines": { "node": ">=10" @@ -17299,51 +18504,17 @@ "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/multipipe": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "integrity": "sha512-7ZxrUybYv9NonoXgwoOqtStIu18D1c3eFZj27hqgf5kBrBF8Q+tE8V0MW8dKM5QLkQPh1JhhbKgHLY9kifov4Q==", "dev": true, "dependencies": { "duplexer2": "0.0.2" } }, - "node_modules/multipipe/node_modules/duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "dependencies": { - "readable-stream": "~1.1.9" - } - }, - "node_modules/multipipe/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "node_modules/multipipe/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/multipipe/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "node_modules/mute-stdout": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz", @@ -17359,19 +18530,35 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, + "node_modules/mux.js": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-6.0.1.tgz", + "integrity": "sha512-22CHb59rH8pWGcPGW5Og7JngJ9s+z4XuSlYvnxhLuc58cA1WqGDQPzuG8I+sPm1/p0CdgpzVTaKW408k5DNn8w==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.11.2", + "global": "^4.4.0" + }, + "bin": { + "muxjs-transmux": "bin/transmux.js" + }, + "engines": { + "node": ">=8", + "npm": ">=5" + } + }, "node_modules/nan": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", - "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==", + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", + "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", "dev": true, "optional": true }, "node_modules/nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", "dev": true, - "optional": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -17401,6 +18588,28 @@ "node": ">=0.10.0" } }, + "node_modules/nanomatch/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/nanomatch/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/nanomatch/node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -17413,13 +18622,13 @@ "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "node_modules/ncp": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz", - "integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ=", + "integrity": "sha512-PfGU8jYWdRl4FqJfCy0IzbkGyFHntfWygZg46nFk/dJD/XRrk2cj0SsKSX9n5u5gE0E0YfEpKWrEkfjnlZSTXA==", "dev": true, "bin": { "ncp": "bin/ncp" @@ -17477,7 +18686,7 @@ "node_modules/nise/node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, "node_modules/nise/node_modules/lolex": { @@ -17519,15 +18728,14 @@ } }, "node_modules/node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", - "dev": true + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" }, "node_modules/nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "integrity": "sha512-4GUt3kSEYmk4ITxzB/b9vaIDfUVWN/Ml1Fwl11IlnIG2iaJ9O6WXZ9SrYM9NLI8OCBieN2Y8SWC2oJV0RQ7qYg==", "dev": true, "dependencies": { "abbrev": "1" @@ -17537,24 +18745,33 @@ } }, "node_modules/normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", + "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", "dev": true, "dependencies": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", + "hosted-git-info": "^4.0.1", + "is-core-module": "^2.5.0", + "semver": "^7.3.4", "validate-npm-package-license": "^3.0.1" + }, + "engines": { + "node": ">=10" } }, "node_modules/normalize-package-data/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, "bin": { - "semver": "bin/semver" + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" } }, "node_modules/normalize-path": { @@ -17593,7 +18810,7 @@ "node_modules/npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==", "dev": true, "dependencies": { "path-key": "^2.0.0" @@ -17605,25 +18822,16 @@ "node_modules/npm-run-path/node_modules/path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", "dev": true, "engines": { "node": ">=4" } }, - "node_modules/null-check": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", - "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -17641,7 +18849,7 @@ "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -17650,7 +18858,7 @@ "node_modules/object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "integrity": "sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==", "dev": true, "dependencies": { "copy-descriptor": "^0.1.0", @@ -17664,7 +18872,7 @@ "node_modules/object-copy/node_modules/define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "dependencies": { "is-descriptor": "^0.1.0" @@ -17676,7 +18884,7 @@ "node_modules/object-copy/node_modules/is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -17694,7 +18902,7 @@ "node_modules/object-copy/node_modules/is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -17729,7 +18937,7 @@ "node_modules/object-copy/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -17739,10 +18947,9 @@ } }, "node_modules/object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true, + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -17775,7 +18982,7 @@ "node_modules/object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "integrity": "sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==", "dev": true, "dependencies": { "isobject": "^3.0.0" @@ -17785,14 +18992,14 @@ } }, "node_modules/object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", "dev": true, "dependencies": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", "object-keys": "^1.1.1" }, "engines": { @@ -17805,7 +19012,7 @@ "node_modules/object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", - "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==", "dev": true, "dependencies": { "array-each": "^1.0.1", @@ -17820,7 +19027,7 @@ "node_modules/object.map": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", - "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==", "dev": true, "dependencies": { "for-own": "^1.0.0", @@ -17833,7 +19040,7 @@ "node_modules/object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", "dev": true, "dependencies": { "isobject": "^3.0.1" @@ -17845,7 +19052,7 @@ "node_modules/object.reduce": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz", - "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", + "integrity": "sha512-naLhxxpUESbNkRqc35oQ2scZSJueHGQNUfMW/0U37IgN6tE2dgDWg3whf+NEliy3F/QysrO48XKUz/nGPe+AQw==", "dev": true, "dependencies": { "for-own": "^1.0.0", @@ -17873,9 +19080,9 @@ } }, "node_modules/on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "dependencies": { "ee-first": "1.1.1" }, @@ -17895,7 +19102,7 @@ "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "dependencies": { "wrappy": "1" @@ -17940,7 +19147,7 @@ "node_modules/opn/node_modules/is-wsl": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", - "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "integrity": "sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==", "dev": true, "engines": { "node": ">=4" @@ -18035,6 +19242,15 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/ora/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ora/node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -18066,7 +19282,7 @@ "node_modules/ordered-read-streams": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", - "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", + "integrity": "sha512-Z87aSjx3r5c0ZB7bcJqIgIRX5bxR7A4aSzvIbaxd0oTkWBCOoKfuGHiKj60CHVUgg1Phm5yMZzBdt8XqRs73Mw==", "dev": true, "dependencies": { "readable-stream": "^2.0.1" @@ -18075,7 +19291,7 @@ "node_modules/os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -18084,7 +19300,7 @@ "node_modules/os-locale": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "integrity": "sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==", "dev": true, "dependencies": { "lcid": "^1.0.0" @@ -18096,7 +19312,7 @@ "node_modules/os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", "dev": true, "engines": { "node": ">=0.10.0" @@ -18114,7 +19330,7 @@ "node_modules/p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", "dev": true, "engines": { "node": ">=4" @@ -18130,36 +19346,39 @@ } }, "node_modules/p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, "dependencies": { - "p-try": "^1.0.0" + "p-try": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, "dependencies": { - "p-limit": "^1.1.0" + "p-limit": "^2.2.0" }, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true, "engines": { - "node": ">=4" + "node": ">=6" } }, "node_modules/parent-module": { @@ -18174,28 +19393,10 @@ "node": ">=6" } }, - "node_modules/parse-entities": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-2.0.0.tgz", - "integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==", - "dev": true, - "dependencies": { - "character-entities": "^1.0.0", - "character-entities-legacy": "^1.0.0", - "character-reference-invalid": "^1.0.0", - "is-alphanumerical": "^1.0.0", - "is-decimal": "^1.0.0", - "is-hexadecimal": "^1.0.0" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" - } - }, "node_modules/parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", - "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==", "dev": true, "dependencies": { "is-absolute": "^1.0.0", @@ -18207,16 +19408,21 @@ } }, "node_modules/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", "dev": true, "dependencies": { + "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" }, "engines": { - "node": ">=4" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/parse-ms": { @@ -18240,34 +19446,28 @@ "node_modules/parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/parse-path": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-4.0.3.tgz", - "integrity": "sha512-9Cepbp2asKnWTJ9x2kpw6Fe8y9JDbqwahGCTvklzd/cEq5C5JC59x2Xb0Kx+x0QZ8bvNquGO8/BWP0cwBHzSAA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz", + "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==", "dev": true, "dependencies": { - "is-ssh": "^1.3.0", - "protocols": "^1.4.0", - "qs": "^6.9.4", - "query-string": "^6.13.8" + "protocols": "^2.0.0" } }, "node_modules/parse-url": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-6.0.0.tgz", - "integrity": "sha512-cYyojeX7yIIwuJzledIHeLUBVJ6COVLeT4eF+2P6aKVzwvgKQPndCBv3+yQ7pcWjqToYwaligxzSYNNmGoMAvw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", "dev": true, "dependencies": { - "is-ssh": "^1.3.0", - "normalize-url": "^6.1.0", - "parse-path": "^4.0.0", - "protocols": "^1.4.0" + "parse-path": "^7.0.0" } }, "node_modules/parseurl": { @@ -18281,7 +19481,7 @@ "node_modules/pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -18290,33 +19490,27 @@ "node_modules/path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "integrity": "sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==", "dev": true }, "node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "engines": { - "node": ">=4" + "node": ">=8" } }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -18329,13 +19523,12 @@ "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, "node_modules/path-root": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==", "dev": true, "dependencies": { "path-root-regex": "^0.1.0" @@ -18347,7 +19540,7 @@ "node_modules/path-root-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -18356,27 +19549,29 @@ "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, "node_modules/path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==", "dev": true, "dependencies": { - "pify": "^3.0.0" + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=0.10.0" } }, "node_modules/path-type/node_modules/pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", "dev": true, "engines": { - "node": ">=4" + "node": ">=0.10.0" } }, "node_modules/pathval": { @@ -18391,7 +19586,7 @@ "node_modules/pause-stream": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "integrity": "sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==", "dev": true, "dependencies": { "through": "~2.3" @@ -18400,20 +19595,19 @@ "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", "dev": true }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "node_modules/picomatch": { "version": "2.3.1", @@ -18428,12 +19622,12 @@ } }, "node_modules/pify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz", - "integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-6.1.0.tgz", + "integrity": "sha512-KocF8ve28eFjjuBKKGvzOBGzG8ew2OqOOSxTTZhirkzH7h3BI1vyzqlR0qbfcDBve1Yzo3FVlWUAtCRrbVN8Fw==", "dev": true, "engines": { - "node": ">=10" + "node": ">=14.16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -18442,7 +19636,7 @@ "node_modules/pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -18451,7 +19645,7 @@ "node_modules/pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", "dev": true, "dependencies": { "pinkie": "^2.0.0" @@ -18460,150 +19654,91 @@ "node": ">=0.10.0" } }, - "node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "node_modules/pkcs7": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pkcs7/-/pkcs7-1.0.4.tgz", + "integrity": "sha512-afRERtHn54AlwaF2/+LFszyAANTCggGilmcmILUzEjvs3XgFZT+xE6+QWQcAGmu4xajy+Xtj7acLOPdx5/eXWQ==", "dev": true, "dependencies": { - "p-try": "^2.0.0" + "@babel/runtime": "^7.5.5" }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "bin": { + "pkcs7": "bin/cli.js" } }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, "dependencies": { - "p-limit": "^2.2.0" + "find-up": "^4.0.0" }, "engines": { "node": ">=8" } }, - "node_modules/pkg-dir/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-dir/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/plugin-error": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", - "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", - "dev": true, - "dependencies": { - "ansi-colors": "^1.0.1", - "arr-diff": "^4.0.0", - "arr-union": "^3.1.0", - "extend-shallow": "^3.0.2" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/plugin-error/node_modules/ansi-colors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", - "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz", + "integrity": "sha512-WzZHcm4+GO34sjFMxQMqZbsz3xiNEgonCskQ9v+IroMmYgk/tas8dG+Hr2D6IbRPybZ12oWpzE/w3cGJ6FJzOw==", "dev": true, "dependencies": { - "ansi-wrap": "^0.1.0" + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" }, "engines": { "node": ">=0.10.0" } }, - "node_modules/pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "integrity": "sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/postcss": { - "version": "8.4.8", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.8.tgz", - "integrity": "sha512-2tXEqGxrjvAO6U+CJzDL2Fk2kPHTv1jQsYkSoMeOis2SsYaXRO2COxTdQp99cYvif9JTXaAk9lYGc3VhJt7JPQ==", + "version": "8.4.18", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.18.tgz", + "integrity": "sha512-Wi8mWhncLJm11GATDaQKobXSNEYGUHeQLiQqDFG1qQ5UTDPTEvKw0Xt5NsTpktGTwLps3ByrWsBrG0rB8YQ9oA==", "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + } + ], "optional": true, "dependencies": { - "nanoid": "^3.3.1", + "nanoid": "^3.3.4", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" }, "engines": { "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "dev": true, + "optional": true, + "bin": { + "nanoid": "bin/nanoid.cjs" }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, "node_modules/prelude-ls": { @@ -18616,35 +19751,57 @@ } }, "node_modules/pretty-format": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", - "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz", + "integrity": "sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==", "dev": true, "dependencies": { - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", + "@jest/types": "^26.6.2", + "ansi-regex": "^5.0.0", + "ansi-styles": "^4.0.0", "react-is": "^17.0.1" }, "engines": { - "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + "node": ">= 10" } }, "node_modules/pretty-format/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, "engines": { - "node": ">=10" + "node": ">=8" }, "funding": { "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/pretty-format/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/pretty-format/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "node_modules/pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", + "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==", "dev": true, "engines": { "node": ">= 0.8" @@ -18665,18 +19822,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/printj": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.3.1.tgz", - "integrity": "sha512-GA3TdL8szPK4AQ2YnOe/b+Y1jUFwmmGMMK/qbY7VcE3Z7FU8JstbKiKRzO6CIiAKPhTO8m01NoQ0V5f3jc4OGg==", - "dev": true, - "bin": { - "printj": "bin/printj.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/private": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", @@ -18686,6 +19831,15 @@ "node": ">= 0.6" } }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "dev": true, + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -18702,22 +19856,19 @@ } }, "node_modules/property-information": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-5.6.0.tgz", - "integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.1.1.tgz", + "integrity": "sha512-hrzC564QIl0r0vy4l6MvRLhafmUowhO/O3KgVSoXIbbA2Sz4j8HGpJc6T2cubRVwMwpdiG/vKGfhT4IixmKN9w==", "dev": true, - "dependencies": { - "xtend": "^4.0.0" - }, "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" } }, "node_modules/protocols": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.8.tgz", - "integrity": "sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==", "dev": true }, "node_modules/proxy-addr": { @@ -18741,7 +19892,7 @@ "node_modules/prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", "dev": true }, "node_modules/ps-tree": { @@ -18762,13 +19913,13 @@ "node_modules/pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==", "dev": true }, "node_modules/psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", "dev": true }, "node_modules/pump": { @@ -18824,16 +19975,16 @@ } }, "node_modules/puppeteer-core": { - "version": "13.5.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.5.1.tgz", - "integrity": "sha512-dobVqWjV34ilyfQHR3BBnCYaekBYTi5MgegEYBRYd3s3uFy8jUpZEEWbaFjG9ETm+LGzR5Lmr0aF6LLuHtiuCg==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.7.0.tgz", + "integrity": "sha512-rXja4vcnAzFAP1OVLq/5dWNfwBGuzcOARJ6qGV7oAZhnLmVRU8G5MsdeQEAOy332ZhkIOnn9jp15R89LKHyp2Q==", "dev": true, "dependencies": { "cross-fetch": "3.1.5", - "debug": "4.3.3", - "devtools-protocol": "0.0.969999", + "debug": "4.3.4", + "devtools-protocol": "0.0.981744", "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.0", + "https-proxy-agent": "5.0.1", "pkg-dir": "4.2.0", "progress": "2.0.3", "proxy-from-env": "1.1.0", @@ -18846,37 +19997,12 @@ "node": ">=10.18.1" } }, - "node_modules/puppeteer-core/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/puppeteer-core/node_modules/devtools-protocol": { - "version": "0.0.969999", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.969999.tgz", - "integrity": "sha512-6GfzuDWU0OFAuOvBokXpXPLxjOJ5DZ157Ue3sGQQM3LgAamb8m0R0ruSfN0DDu+XG5XJgT50i6zZ/0o8RglreQ==", + "version": "0.0.981744", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", + "integrity": "sha512-0cuGS8+jhR67Fy7qG3i3Pc7Aw494sb9yG9QgpG97SFVWwolgYjlhJg7n+UaHxOQT30d1TYu/EYe9k01ivLErIg==", "dev": true }, - "node_modules/puppeteer-core/node_modules/https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "dev": true, - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/puppeteer-core/node_modules/ws": { "version": "8.5.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", @@ -18901,7 +20027,7 @@ "node_modules/q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", "dev": true, "engines": { "node": ">=0.6.0", @@ -18918,9 +20044,12 @@ } }, "node_modules/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dependencies": { + "side-channel": "^1.0.4" + }, "engines": { "node": ">=0.6" }, @@ -18934,28 +20063,10 @@ "integrity": "sha512-bK0/0cCI+R8ZmOF1QjT7HupDUYCxbf/9TJgAmSXQxZpftXmTAeil9DRoCnTDkWbvOyZzhcMBwKpptWcdkGFIMg==", "dev": true }, - "node_modules/query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", - "dev": true, - "dependencies": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==", "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", "dev": true, "engines": { @@ -18998,12 +20109,12 @@ } }, "node_modules/raw-body": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", - "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "dependencies": { "bytes": "3.1.2", - "http-errors": "1.8.1", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" }, @@ -19018,91 +20129,144 @@ "dev": true }, "node_modules/read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-7.1.0.tgz", + "integrity": "sha512-5iOehe+WF75IccPc30bWTbpdDQLOCc3Uu8bi3Dte3Eueij81yx1Mrufk8qBx/YAbR4uL1FdUr+7BKXDwEtisXg==", "dev": true, "dependencies": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" + "@types/normalize-package-data": "^2.4.1", + "normalize-package-data": "^3.0.2", + "parse-json": "^5.2.0", + "type-fest": "^2.0.0" }, "engines": { - "node": ">=4" + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-4.0.0.tgz", - "integrity": "sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-9.1.0.tgz", + "integrity": "sha512-vaMRR1AC1nrd5CQM0PhlRsO5oc2AAigqr7cCrZ/MW/Rsaflz4RlgzkpL4qoU/z1F6wrbd85iFv1OQj/y5RdGvg==", "dev": true, "dependencies": { - "find-up": "^3.0.0", - "read-pkg": "^3.0.0" + "find-up": "^6.3.0", + "read-pkg": "^7.1.0", + "type-fest": "^2.5.0" }, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up/node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz", + "integrity": "sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==", "dev": true, "dependencies": { - "locate-path": "^3.0.0" + "locate-path": "^7.1.0", + "path-exists": "^5.0.0" }, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up/node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.1.1.tgz", + "integrity": "sha512-vJXaRMJgRVD3+cUZs3Mncj2mxpt5mP0EmNOsxRSZRMlbqjvxzDEOIUWXGmavo0ZC9+tNZCBLQ66reA11nbpHZg==", "dev": true, "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "^6.0.0" }, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", "dev": true, "dependencies": { - "p-try": "^2.0.0" + "yocto-queue": "^1.0.0" }, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/read-pkg-up/node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz", + "integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==", "dev": true, "dependencies": { - "p-limit": "^2.0.0" + "p-limit": "^4.0.0" }, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/read-pkg-up/node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "node_modules/read-pkg-up/node_modules/path-exists": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", + "integrity": "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==", "dev": true, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/read-pkg-up/node_modules/type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg-up/node_modules/yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg/node_modules/type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "dev": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/readable-stream": { @@ -19123,16 +20287,43 @@ "node_modules/readable-stream/node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, "node_modules/readdir-glob": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-1.1.1.tgz", - "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-1.1.2.tgz", + "integrity": "sha512-6RLVvwJtVwEDfPdn6X6Ille4/lxGl0ATOY4FN/B9nxQcgOazvvI0nodiD19ScKq0PvA/29VpaOQML36o5IzZWA==", "dev": true, "dependencies": { - "minimatch": "^3.0.4" + "minimatch": "^5.1.0" + } + }, + "node_modules/readdir-glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/readdir-glob/node_modules/minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" } }, "node_modules/readdirp": { @@ -19150,7 +20341,7 @@ "node_modules/rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", "dev": true, "dependencies": { "resolve": "^1.1.6" @@ -19160,53 +20351,26 @@ } }, "node_modules/recursive-readdir": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz", - "integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz", + "integrity": "sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==", "dev": true, "dependencies": { - "minimatch": "3.0.4" + "minimatch": "^3.0.5" }, "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/recursive-readdir/node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/redent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", - "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", - "dev": true, - "dependencies": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" - }, - "engines": { - "node": ">=8" + "node": ">=6.0.0" } }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", - "dev": true + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==" }, "node_modules/regenerate-unicode-properties": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz", - "integrity": "sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw==", - "dev": true, + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.0.tgz", + "integrity": "sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ==", "dependencies": { "regenerate": "^1.4.2" }, @@ -19215,15 +20379,14 @@ } }, "node_modules/regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + "version": "0.13.10", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", + "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==" }, "node_modules/regenerator-transform": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.5.tgz", - "integrity": "sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw==", - "dev": true, + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.0.tgz", + "integrity": "sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==", "dependencies": { "@babel/runtime": "^7.8.4" } @@ -19241,14 +20404,28 @@ "node": ">=0.10.0" } }, + "node_modules/regex-not/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/regexp.prototype.flags": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.1.tgz", - "integrity": "sha512-pMR7hBVUUGI7PMA37m2ofIdQCsomVnas+Jn5UPGAHQ+/LlwKm/aTLJHdasmHRzlfeZwHiAOaRSo2rbBDm3nNUQ==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" }, "engines": { "node": ">= 0.4" @@ -19270,15 +20447,14 @@ } }, "node_modules/regexpu-core": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.0.1.tgz", - "integrity": "sha512-CriEZlrKK9VJw/xQGJpQM5rY88BtuL8DM+AEwvcThHilbxiTAy8vq4iJnd2tqq8wLmjbGZzP7ZcKFjbGkmEFrw==", - "dev": true, + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.2.1.tgz", + "integrity": "sha512-HrnlNtpvqP1Xkb28tMhBUO2EbyUHdQlsnlAhzWcwHy8WJR53UWr7/MAvqrsQKMbV4qdpv03oTMG8iIhfsPFktQ==", "dependencies": { "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.0.1", - "regjsgen": "^0.6.0", - "regjsparser": "^0.8.2", + "regenerate-unicode-properties": "^10.1.0", + "regjsgen": "^0.7.1", + "regjsparser": "^0.9.1", "unicode-match-property-ecmascript": "^2.0.0", "unicode-match-property-value-ecmascript": "^2.0.0" }, @@ -19287,16 +20463,14 @@ } }, "node_modules/regjsgen": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.6.0.tgz", - "integrity": "sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA==", - "dev": true + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.7.1.tgz", + "integrity": "sha512-RAt+8H2ZEzHeYWxZ3H2z6tF18zyyOnlcdaafLrm21Bguj7uZy6ULibiAFdXEtKQY4Sy7wDTwDiOazasMLc4KPA==" }, "node_modules/regjsparser": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.8.4.tgz", - "integrity": "sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA==", - "dev": true, + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.9.1.tgz", + "integrity": "sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==", "dependencies": { "jsesc": "~0.5.0" }, @@ -19307,21 +20481,21 @@ "node_modules/regjsparser/node_modules/jsesc": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true, + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", "bin": { "jsesc": "bin/jsesc" } }, "node_modules/remark": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/remark/-/remark-13.0.0.tgz", - "integrity": "sha512-HDz1+IKGtOyWN+QgBiAT0kn+2s6ovOxHyPAFGKVE81VSzJ+mq7RwHFledEvB5F1p4iJvOah/LOKdFuzvRnNLCA==", + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/remark/-/remark-14.0.2.tgz", + "integrity": "sha512-A3ARm2V4BgiRXaUo5K0dRvJ1lbogrbXnhkJRmD0yw092/Yl0kOCZt1k9ZeElEwkZsWGsMumz6qL5MfNJH9nOBA==", "dev": true, "dependencies": { - "remark-parse": "^9.0.0", - "remark-stringify": "^9.0.0", - "unified": "^9.1.0" + "@types/mdast": "^3.0.0", + "remark-parse": "^10.0.0", + "remark-stringify": "^10.0.0", + "unified": "^10.0.0" }, "funding": { "type": "opencollective", @@ -19329,13 +20503,15 @@ } }, "node_modules/remark-gfm": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-1.0.0.tgz", - "integrity": "sha512-KfexHJCiqvrdBZVbQ6RopMZGwaXz6wFJEfByIuEwGf0arvITHjiKKZ1dpXujjH9KZdm1//XJQwgfnJ3lmXaDPA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz", + "integrity": "sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==", "dev": true, "dependencies": { - "mdast-util-gfm": "^0.1.0", - "micromark-extension-gfm": "^0.3.0" + "@types/mdast": "^3.0.0", + "mdast-util-gfm": "^2.0.0", + "micromark-extension-gfm": "^2.0.0", + "unified": "^10.0.0" }, "funding": { "type": "opencollective", @@ -19343,14 +20519,16 @@ } }, "node_modules/remark-html": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/remark-html/-/remark-html-13.0.2.tgz", - "integrity": "sha512-LhSRQ+3RKdBqB/RGesFWkNNfkGqprDUCwjq54SylfFeNyZby5kqOG8Dn/vYsRoM8htab6EWxFXCY6XIZvMoRiQ==", + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/remark-html/-/remark-html-15.0.1.tgz", + "integrity": "sha512-7ta5UPRqj8nP0GhGMYUAghZ/DRno7dgq7alcW90A7+9pgJsXzGJlFgwF8HOP1b1tMgT3WwbeANN+CaTimMfyNQ==", "dev": true, "dependencies": { - "hast-util-sanitize": "^3.0.0", - "hast-util-to-html": "^7.0.0", - "mdast-util-to-hast": "^10.0.0" + "@types/mdast": "^3.0.0", + "hast-util-sanitize": "^4.0.0", + "hast-util-to-html": "^8.0.0", + "mdast-util-to-hast": "^12.0.0", + "unified": "^10.0.0" }, "funding": { "type": "opencollective", @@ -19358,12 +20536,14 @@ } }, "node_modules/remark-parse": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-9.0.0.tgz", - "integrity": "sha512-geKatMwSzEXKHuzBNU1z676sGcDcFoChMK38TgdHJNAYfFtsfHDQG7MoJAjs6sgYMqyLduCYWDIWZIxiPeafEw==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-10.0.1.tgz", + "integrity": "sha512-1fUyHr2jLsVOkhbvPRBJ5zTKZZyD6yZzYaWCS6BPBdQ8vEMBCH+9zNCDA6tET/zHCi/jLqjCWtlJZUPk+DbnFw==", "dev": true, "dependencies": { - "mdast-util-from-markdown": "^0.8.0" + "@types/mdast": "^3.0.0", + "mdast-util-from-markdown": "^1.0.0", + "unified": "^10.0.0" }, "funding": { "type": "opencollective", @@ -19371,12 +20551,14 @@ } }, "node_modules/remark-reference-links": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-5.0.0.tgz", - "integrity": "sha512-oSIo6lfDyG/1yYl2jPZNXmD9dgyPxp07mSd7snJagVMsDU6NRlD8i54MwHWUgMoOHTs8lIKPkwaUok/tbr5syQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-6.0.1.tgz", + "integrity": "sha512-34wY2C6HXSuKVTRtyJJwefkUD8zBOZOSHFZ4aSTnU2F656gr9WeuQ2dL6IJDK3NPd2F6xKF2t4XXcQY9MygAXg==", "dev": true, "dependencies": { - "unist-util-visit": "^2.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unist-util-visit": "^4.0.0" }, "funding": { "type": "opencollective", @@ -19384,12 +20566,14 @@ } }, "node_modules/remark-stringify": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-9.0.1.tgz", - "integrity": "sha512-mWmNg3ZtESvZS8fv5PTvaPckdL4iNlCHTt8/e/8oN08nArHRHjNZMKzA/YW3+p7/lYqIw4nx1XsjCBo/AxNChg==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-10.0.2.tgz", + "integrity": "sha512-6wV3pvbPvHkbNnWB0wdDvVFHOe1hBRAx1Q/5g/EpH4RppAII6J8Gnwe7VbHuXaoKIF6LAg6ExTel/+kNqSQ7lw==", "dev": true, "dependencies": { - "mdast-util-to-markdown": "^0.6.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.0.0", + "unified": "^10.0.0" }, "funding": { "type": "opencollective", @@ -19397,13 +20581,14 @@ } }, "node_modules/remark-toc": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/remark-toc/-/remark-toc-7.2.0.tgz", - "integrity": "sha512-ppHepvpbg7j5kPFmU5rzDC4k2GTcPDvWcxXyr/7BZzO1cBSPk0stKtEJdsgAyw2WHKPGxadcHIZRjb2/sHxjkg==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/remark-toc/-/remark-toc-8.0.1.tgz", + "integrity": "sha512-7he2VOm/cy13zilnOTZcyAoyoolV26ULlon6XyCFU+vG54Z/LWJnwphj/xKIDLOt66QmJUgTyUvLVHi2aAElyg==", "dev": true, "dependencies": { - "@types/unist": "^2.0.3", - "mdast-util-toc": "^5.0.0" + "@types/mdast": "^3.0.0", + "mdast-util-toc": "^6.0.0", + "unified": "^10.0.0" }, "funding": { "type": "opencollective", @@ -19432,7 +20617,7 @@ "node_modules/remove-bom-stream": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz", - "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", + "integrity": "sha512-wigO8/O08XHb8YPzpDDT+QmRANfW6vLqxfaXm1YXhnFf3AkSLyjfG3GEFg4McZkmgL7KvCj5u2KczkvSP6NfHA==", "dev": true, "dependencies": { "remove-bom-buffer": "^3.0.0", @@ -19456,7 +20641,7 @@ "node_modules/remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==", "dev": true }, "node_modules/repeat-element": { @@ -19471,7 +20656,7 @@ "node_modules/repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==", "dev": true, "engines": { "node": ">=0.10" @@ -19480,7 +20665,7 @@ "node_modules/repeating": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "integrity": "sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==", "dev": true, "dependencies": { "is-finite": "^1.0.0" @@ -19492,7 +20677,7 @@ "node_modules/replace-ext": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "integrity": "sha512-AFBWBy9EVRTa/LhEcG8QDP3FvpwZqmvN2QFDuJswFeaVhWnZMp8q3E6Zd90SR04PlIwfGdyVjNyLPyen/ek5CQ==", "dev": true, "engines": { "node": ">= 0.4" @@ -19501,7 +20686,7 @@ "node_modules/replace-homedir": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz", - "integrity": "sha1-6H9tUTuSjd6AgmDBK+f+xv9ueYw=", + "integrity": "sha512-CHPV/GAglbIB1tnQgaiysb8H2yCy8WQ7lcEwQ/eT+kLj0QHV8LnJW0zpqpE7RSkrMSRoa+EBoag86clf7WAgSg==", "dev": true, "dependencies": { "homedir-polyfill": "^1.0.1", @@ -19567,7 +20752,7 @@ "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, "engines": { "node": ">=0.10.0" @@ -19583,46 +20768,23 @@ } }, "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, - "node_modules/require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "dependencies": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-uncached/node_modules/resolve-from": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==", + "dev": true }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", "dev": true }, "node_modules/resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dependencies": { - "is-core-module": "^2.8.1", + "is-core-module": "^2.9.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -19642,7 +20804,7 @@ "node_modules/resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==", "dev": true, "dependencies": { "expand-tilde": "^2.0.0", @@ -19664,7 +20826,7 @@ "node_modules/resolve-options": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", - "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", + "integrity": "sha512-NYDgziiroVeDC29xq7bp/CacZERYsA9bXYd1ZmcJlF3BcrZv5pTb4NG7SjdyKDnXZ84aC4vo2u6sNKIA1LCu/A==", "dev": true, "dependencies": { "value-or-function": "^3.0.0" @@ -19676,17 +20838,20 @@ "node_modules/resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "integrity": "sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==", "deprecated": "https://github.com/lydell/resolve-url#deprecated", "dev": true }, "node_modules/responselike": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", - "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", + "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", "dev": true, "dependencies": { "lowercase-keys": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/resq": { @@ -19701,7 +20866,7 @@ "node_modules/resq/node_modules/fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "integrity": "sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==", "dev": true }, "node_modules/restore-cursor": { @@ -19762,57 +20927,87 @@ "node": ">=0.12.0" } }, - "node_modules/rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true - }, - "node_modules/rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "node_modules/rust-result": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rust-result/-/rust-result-1.0.0.tgz", + "integrity": "sha512-6cJzSBU+J/RJCF063onnQf0cDUOHs9uZI1oroSGnHOph+CQTIJ5Pp2hK5kEQq1+7yE/EEWfulSNXAQ2jikPthA==", "dev": true, "dependencies": { - "rx-lite": "*" + "individual": "^2.0.0" } }, "node_modules/rxjs": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz", - "integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==", + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", "dev": true, "dependencies": { - "tslib": "^2.1.0" + "tslib": "^1.9.0" + }, + "engines": { + "npm": ">=2.0.0" } }, - "node_modules/rxjs/node_modules/tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", - "dev": true + "node_modules/sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dev": true, + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">=6" + } }, "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, "node_modules/safe-json-parse": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-1.0.1.tgz", - "integrity": "sha1-PnZyPjjf3aE8mx0poeB//uSzC1c=", + "integrity": "sha512-o0JmTu17WGUaUOHa1l0FPGXKBfijbxK6qoHzlkihsDXxzBHvJcA7zgviKR92Xs841rX9pK16unfphLq0/KqX7A==", "dev": true }, "node_modules/safe-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==", "dev": true, "dependencies": { "ret": "~0.1.10" } }, + "node_modules/safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -19859,20 +21054,10 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/schema-utils/node_modules/ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "peerDependencies": { - "ajv": "^6.9.1" - } - }, "node_modules/semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true, + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "bin": { "semver": "bin/semver.js" } @@ -19880,7 +21065,7 @@ "node_modules/semver-greatest-satisfied-range": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz", - "integrity": "sha1-E+jCZYq5aRywzXEJMkAoDTb3els=", + "integrity": "sha512-Ny/iyOzSSa8M5ML46IAx3iXc6tfOsYU2R4AXi2UpHk60Zrgyq6eqPj/xiOfS0rRl/iiQ/rdJkVjw/5cdUyCntQ==", "dev": true, "dependencies": { "sver-compat": "^1.5.0" @@ -19890,23 +21075,23 @@ } }, "node_modules/send": { - "version": "0.17.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", - "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "dependencies": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", + "depd": "2.0.0", + "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "1.8.1", + "http-errors": "2.0.0", "mime": "1.6.0", "ms": "2.1.3", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "range-parser": "~1.2.1", - "statuses": "~1.5.0" + "statuses": "2.0.1" }, "engines": { "node": ">= 0.8.0" @@ -19923,7 +21108,7 @@ "node_modules/send/node_modules/debug/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/send/node_modules/mime": { "version": "1.6.0", @@ -19980,7 +21165,7 @@ "node_modules/serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", - "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", + "integrity": "sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw==", "dev": true, "dependencies": { "accepts": "~1.3.4", @@ -20004,10 +21189,19 @@ "ms": "2.0.0" } }, + "node_modules/serve-index/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/serve-index/node_modules/http-errors": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", "dev": true, "dependencies": { "depd": "~1.1.2", @@ -20022,13 +21216,13 @@ "node_modules/serve-index/node_modules/inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, "node_modules/serve-index/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/serve-index/node_modules/setprototypeof": { @@ -20037,15 +21231,24 @@ "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", "dev": true }, + "node_modules/serve-index/node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/serve-static": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", - "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "dependencies": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.2" + "send": "0.18.0" }, "engines": { "node": ">= 0.8.0" @@ -20054,7 +21257,7 @@ "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, "node_modules/set-value": { @@ -20075,7 +21278,7 @@ "node_modules/set-value/node_modules/extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "dependencies": { "is-extendable": "^0.1.0" @@ -20087,7 +21290,7 @@ "node_modules/set-value/node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -20108,7 +21311,7 @@ "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", "dev": true }, "node_modules/setprototypeof": { @@ -20141,7 +21344,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, "dependencies": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -20182,27 +21384,6 @@ "node": ">=0.3.1" } }, - "node_modules/sinon/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/sinon/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/sirv": { "version": "1.0.19", "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.19.tgz", @@ -20218,12 +21399,12 @@ } }, "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==", "dev": true, "engines": { - "node": ">=8" + "node": ">=0.10.0" } }, "node_modules/slice-ansi": { @@ -20312,7 +21493,7 @@ "node_modules/snapdragon-node/node_modules/define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "dependencies": { "is-descriptor": "^1.0.0" @@ -20342,7 +21523,7 @@ "node_modules/snapdragon-util/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -20363,7 +21544,7 @@ "node_modules/snapdragon/node_modules/define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "dependencies": { "is-descriptor": "^0.1.0" @@ -20375,7 +21556,7 @@ "node_modules/snapdragon/node_modules/extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "dependencies": { "is-extendable": "^0.1.0" @@ -20387,7 +21568,7 @@ "node_modules/snapdragon/node_modules/is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -20399,7 +21580,7 @@ "node_modules/snapdragon/node_modules/is-accessor-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -20417,7 +21598,7 @@ "node_modules/snapdragon/node_modules/is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -20429,7 +21610,7 @@ "node_modules/snapdragon/node_modules/is-data-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -20455,7 +21636,7 @@ "node_modules/snapdragon/node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -20464,7 +21645,7 @@ "node_modules/snapdragon/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "node_modules/snapdragon/node_modules/source-map-resolve": { @@ -20482,46 +21663,54 @@ } }, "node_modules/socket.io": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.4.1.tgz", - "integrity": "sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==", + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.6.1.tgz", + "integrity": "sha512-KMcaAi4l/8+xEjkRICl6ak8ySoxsYG+gG6/XfRCPJPQ/haCRIJBTL4wIl8YCsmtaBovcAXGLOShyVWQ/FG8GZA==", "dev": true, "dependencies": { "accepts": "~1.3.4", "base64id": "~2.0.0", "debug": "~4.3.2", - "engine.io": "~6.1.0", - "socket.io-adapter": "~2.3.3", - "socket.io-parser": "~4.0.4" + "engine.io": "~6.4.1", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.1" }, "engines": { "node": ">=10.0.0" } }, "node_modules/socket.io-adapter": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.3.3.tgz", - "integrity": "sha512-Qd/iwn3VskrpNO60BeRyCyr8ZWw9CPZyitW4AQwmRZ8zCiyDiL+znRnWX6tDHXnWn1sJrM1+b6Mn6wEDJJ4aYQ==", - "dev": true + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", + "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", + "dev": true, + "dependencies": { + "ws": "~8.11.0" + } }, "node_modules/socket.io-parser": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz", - "integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.3.tgz", + "integrity": "sha512-JMafRntWVO2DCJimKsRTh/wnqVvO4hrfwOqtO7f+uzwsQMuxO6VwImtYxaQ+ieoyshWOTJyV0fA21lccEXRPpQ==", "dev": true, "dependencies": { - "@types/component-emitter": "^1.2.10", - "component-emitter": "~1.3.0", + "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" }, "engines": { "node": ">=10.0.0" } }, + "node_modules/source-list-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", + "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==", + "dev": true + }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -20549,22 +21738,12 @@ } }, "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/source-map-support/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" + "source-map": "^0.5.6" } }, "node_modules/source-map-url": { @@ -20582,9 +21761,9 @@ "optional": true }, "node_modules/space-separated-tokens": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz", - "integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.1.tgz", + "integrity": "sha512-ekwEbFp5aqSPKaqeY1PGrlGQxPNaq+Cnx4+bE2D8sciBQrHpbwoBbawqTN2+6jPs9IdWxxiUcN0K2pkczD3zmw==", "dev": true, "funding": { "type": "github", @@ -20627,15 +21806,15 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", - "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz", + "integrity": "sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==", "dev": true }, "node_modules/split": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "integrity": "sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==", "dev": true, "dependencies": { "through": "2" @@ -20644,15 +21823,6 @@ "node": "*" } }, - "node_modules/split-on-first": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", - "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -20665,19 +21835,46 @@ "node": ">=0.10.0" } }, + "node_modules/split-string/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/split2": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", - "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", + "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", + "dev": true, + "dependencies": { + "readable-stream": "^3.0.0" + } + }, + "node_modules/split2/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, "engines": { - "node": ">= 10.x" + "node": ">= 6" } }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "node_modules/sshpk": { @@ -20708,7 +21905,7 @@ "node_modules/stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", "dev": true, "engines": { "node": "*" @@ -20735,160 +21932,10 @@ "node": ">=8" } }, - "node_modules/standard-version": { - "version": "9.3.2", - "resolved": "https://registry.npmjs.org/standard-version/-/standard-version-9.3.2.tgz", - "integrity": "sha512-u1rfKP4o4ew7Yjbfycv80aNMN2feTiqseAhUhrrx2XtdQGmu7gucpziXe68Z4YfHVqlxVEzo4aUA0Iu3VQOTgQ==", - "dev": true, - "dependencies": { - "chalk": "^2.4.2", - "conventional-changelog": "3.1.24", - "conventional-changelog-config-spec": "2.1.0", - "conventional-changelog-conventionalcommits": "4.6.1", - "conventional-recommended-bump": "6.1.0", - "detect-indent": "^6.0.0", - "detect-newline": "^3.1.0", - "dotgitignore": "^2.1.0", - "figures": "^3.1.0", - "find-up": "^5.0.0", - "fs-access": "^1.0.1", - "git-semver-tags": "^4.0.0", - "semver": "^7.1.1", - "stringify-package": "^1.0.1", - "yargs": "^16.0.0" - }, - "bin": { - "standard-version": "bin/cli.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/standard-version/node_modules/detect-newline": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", - "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/standard-version/node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/standard-version/node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/standard-version/node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/standard-version/node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/standard-version/node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/standard-version/node_modules/semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/standard-version/node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/standard-version/node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true, - "engines": { - "node": ">=10" - } - }, "node_modules/static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "integrity": "sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==", "dev": true, "dependencies": { "define-property": "^0.2.5", @@ -20901,7 +21948,7 @@ "node_modules/static-extend/node_modules/define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "dependencies": { "is-descriptor": "^0.1.0" @@ -20913,7 +21960,7 @@ "node_modules/static-extend/node_modules/is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -20925,7 +21972,7 @@ "node_modules/static-extend/node_modules/is-accessor-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -20943,7 +21990,7 @@ "node_modules/static-extend/node_modules/is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -20955,7 +22002,7 @@ "node_modules/static-extend/node_modules/is-data-descriptor/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -20979,58 +22026,13 @@ } }, "node_modules/statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/stream-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/stream-array/-/stream-array-1.1.2.tgz", - "integrity": "sha1-nl9zRfITfDDuO0mLkRToC1K7frU=", - "dev": true, - "dependencies": { - "readable-stream": "~2.1.0" - }, + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", "engines": { "node": ">= 0.8" } }, - "node_modules/stream-array/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "node_modules/stream-array/node_modules/process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "node_modules/stream-array/node_modules/readable-stream": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", - "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", - "dev": true, - "dependencies": { - "buffer-shims": "^1.0.0", - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/stream-array/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "node_modules/stream-buffers": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-3.0.2.tgz", @@ -21043,22 +22045,12 @@ "node_modules/stream-combiner": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "integrity": "sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==", "dev": true, "dependencies": { "duplexer": "~0.1.1" } }, - "node_modules/stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "dependencies": { - "duplexer2": "~0.1.0", - "readable-stream": "^2.0.2" - } - }, "node_modules/stream-exhaust": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", @@ -21072,26 +22064,49 @@ "dev": true }, "node_modules/streamroller": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.0.4.tgz", - "integrity": "sha512-GI9NzeD+D88UFuIlJkKNDH/IsuR+qIN7Qh8EsmhoRZr9bQoehTraRgwtLUkZbpcAw+hLPfHOypmppz8YyGK68w==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.3.tgz", + "integrity": "sha512-CphIJyFx2SALGHeINanjFRKQ4l7x2c+rXYJ4BMq0gd+ZK0gi4VT8b+eHe2wi58x4UayBAKx4xtHpXT/ea1cz8w==", "dev": true, "dependencies": { - "date-format": "^4.0.4", - "debug": "^4.3.3", - "fs-extra": "^10.0.1" + "date-format": "^4.0.14", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" }, "engines": { "node": ">=8.0" } }, - "node_modules/strict-uri-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", - "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=", + "node_modules/streamroller/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, "engines": { - "node": ">=4" + "node": ">=6 <7 || >=8" + } + }, + "node_modules/streamroller/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/streamroller/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" } }, "node_modules/string_decoder": { @@ -21103,10 +22118,16 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, "node_modules/string-template": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz", - "integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=", + "integrity": "sha512-Yptehjogou2xm4UJbxJ4CxgZx12HBfeystp0y3x7s4Dj32ltVVG1Gg8YhKjHZkHicuKpZX/ffilA8505VbUbpw==", "dev": true }, "node_modules/string-width": { @@ -21123,59 +22144,48 @@ "node": ">=8" } }, - "node_modules/string-width/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, "node_modules/string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", + "integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", + "integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", "dev": true, "dependencies": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/stringify-entities": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-3.1.0.tgz", - "integrity": "sha512-3FP+jGMmMV/ffZs86MoghGqAoqXAdxLrJP4GUdrDN1aIScYih5tuIO3eF4To5AJZ79KDZ8Fpdy7QJnK8SsL1Vg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.3.tgz", + "integrity": "sha512-BP9nNHMhhfcMbiuQKCqMjhDP5yBCAxsPu4pHFFzJ6Alo9dZgY4VLDPutXqIjpRiMoKdp7Av85Gr73Q5uH9k7+g==", "dev": true, "dependencies": { - "character-entities-html4": "^1.0.0", - "character-entities-legacy": "^1.0.0", - "xtend": "^4.0.0" + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" }, "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/stringify-package": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.1.tgz", - "integrity": "sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==", - "dev": true - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -21191,7 +22201,7 @@ "node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true, "engines": { "node": ">=4" @@ -21200,7 +22210,7 @@ "node_modules/strip-bom-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", - "integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=", + "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==", "dev": true, "engines": { "node": ">=0.10.0" @@ -21209,71 +22219,48 @@ "node_modules/strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==", "dev": true, "engines": { "node": ">=0.10.0" } }, - "node_modules/strip-indent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", - "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", - "dev": true, - "dependencies": { - "min-indent": "^1.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.0.tgz", + "integrity": "sha512-V1LGY4UUo0jgwC+ELQ2BNWfPa17TIuwBLg+j1AA/9RPzKINl1lhxVEu2r+ZTTO8aetIsUzE5Qj6LMSBkoGYKKw==", "dev": true, "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/subarg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", - "dev": true, - "dependencies": { - "minimist": "^1.1.0" + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/suffix": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/suffix/-/suffix-0.1.1.tgz", - "integrity": "sha1-zFgjFkag7xEC95R47zqSSP2chC8=", + "integrity": "sha512-j5uf6MJtMCfC4vBe5LFktSe4bGyNTBk7I2Kdri0jeLrcv5B9pWfxVa5JQpoxgtR8vaVB7bVxsWgnfQbX5wkhAA==", "dev": true, "engines": { "node": ">=4" } }, "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dependencies": { - "has-flag": "^4.0.0" + "has-flag": "^3.0.0" }, "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" + "node": ">=4" } }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, "engines": { "node": ">= 0.4" }, @@ -21284,7 +22271,7 @@ "node_modules/sver-compat": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz", - "integrity": "sha1-PPh9/rTQe0o/FIJ7wYaz/QxkXNg=", + "integrity": "sha512-aFTHfmjwizMNlNE6dsGmoAM4lHjL0CyiobWaFiXWSlD7cIxshW422Nb8KbXCmR6z+0ZEPY+daXJrDyh/vuwTyg==", "dev": true, "dependencies": { "es6-iterator": "^2.0.1", @@ -21308,9 +22295,9 @@ } }, "node_modules/table/node_modules/ajv": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -21383,7 +22370,7 @@ "node_modules/temp-fs": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/temp-fs/-/temp-fs-0.9.9.tgz", - "integrity": "sha1-gHFzBDeHByDpQxUy/igUNk+IA9c=", + "integrity": "sha512-WfecDCR1xC9b0nsrzSaxPf3ZuWeWLUWblW4vlDQAa1biQaKHiImHnJfeQocQe/hXKMcolRzgkcVX/7kK4zoWbw==", "dev": true, "dependencies": { "rimraf": "~2.5.2" @@ -21395,7 +22382,7 @@ "node_modules/temp-fs/node_modules/rimraf": { "version": "2.5.4", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", - "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", + "integrity": "sha512-Lw7SHMjssciQb/rRz7JyPIy9+bbUshEucPoLRvWqy09vC5zQixl8Uet+Zl+SROBB/JMWHJRdCk1qdxNWHNMvlQ==", "dev": true, "dependencies": { "glob": "^7.0.5" @@ -21427,14 +22414,14 @@ } }, "node_modules/terser": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.12.0.tgz", - "integrity": "sha512-R3AUhNBGWiFc77HXag+1fXpAxTAFRQTJemlJKjAgD9r8xXTpjNKqIXwHM/o7Rh+O0kUJtS3WQVdBeMKFk5sw9A==", + "version": "5.15.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.15.1.tgz", + "integrity": "sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==", "dev": true, "dependencies": { + "@jridgewell/source-map": "^0.3.2", "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.7.2", "source-map-support": "~0.5.20" }, "bin": { @@ -21445,16 +22432,16 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.1.tgz", - "integrity": "sha512-GvlZdT6wPQKbDNW/GDQzZFg/j4vKU96yl2q6mcUkzKOgW4gwf1Z8cZToUCrz31XHlPWH8MVb1r2tFtdDtTGJ7g==", + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", + "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", "dev": true, "dependencies": { + "@jridgewell/trace-mapping": "^0.3.14", "jest-worker": "^27.4.5", "schema-utils": "^3.1.1", "serialize-javascript": "^6.0.0", - "source-map": "^0.6.1", - "terser": "^5.7.2" + "terser": "^5.14.1" }, "engines": { "node": ">= 10.13.0" @@ -21494,15 +22481,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/terser-webpack-plugin/node_modules/ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "peerDependencies": { - "ajv": "^6.9.1" - } - }, "node_modules/terser-webpack-plugin/node_modules/schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -21521,19 +22499,10 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/terser-webpack-plugin/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/terser/node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -21542,34 +22511,43 @@ "node": ">=0.4.0" } }, - "node_modules/terser/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/terser/node_modules/source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, "engines": { - "node": ">= 8" + "node": ">=0.10.0" } }, - "node_modules/text-extensions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", - "integrity": "sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==", + "node_modules/terser/node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, "engines": { - "node": ">=0.10" + "node": ">=8" } }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "node_modules/textextensions": { @@ -21587,7 +22565,7 @@ "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "node_modules/through2": { @@ -21636,7 +22614,7 @@ "node_modules/time-stamp": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", - "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "integrity": "sha512-gLCeArryy2yNTRzTGKbZbloctj64jkZ57hj5zdraXue6aFgd6PmvVtEyiUU+hvU0v7q08oVv8r8ev0tRo6bvgw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -21695,7 +22673,7 @@ "node_modules/to-absolute-glob": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", - "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", + "integrity": "sha512-rtwLUQEwT8ZeKQbyFJyomBRYXyE16U5VKuy0ftxLMK/PZb2fkOsg5r9kHdauuVDbsNdIBoC/HCthpidamQFXYA==", "dev": true, "dependencies": { "is-absolute": "^1.0.0", @@ -21708,8 +22686,7 @@ "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true, + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", "engines": { "node": ">=4" } @@ -21717,7 +22694,7 @@ "node_modules/to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "integrity": "sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==", "dev": true, "dependencies": { "kind-of": "^3.0.2" @@ -21735,7 +22712,7 @@ "node_modules/to-object-path/node_modules/kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "dependencies": { "is-buffer": "^1.1.5" @@ -21771,19 +22748,23 @@ "node": ">=8.0" } }, - "node_modules/to-regex-range/node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "node_modules/to-regex/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, "engines": { - "node": ">=0.12.0" + "node": ">=0.10.0" } }, "node_modules/to-through": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz", - "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", + "integrity": "sha512-+QIz37Ly7acM4EMdw2PRN389OneM5+d844tirkGp4dPKzI5OE72V9OsbFp+CIYJDahZ41ZV05hNtcPAQUAm9/Q==", "dev": true, "dependencies": { "through2": "^2.0.3" @@ -21835,40 +22816,41 @@ "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, "node_modules/traverse": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=", + "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==", "dev": true, "engines": { "node": "*" } }, - "node_modules/trim-newlines": { + "node_modules/trim-lines": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", - "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", "dev": true, - "engines": { - "node": ">=8" + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" } }, "node_modules/trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "integrity": "sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/trough": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz", - "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/trough/-/trough-2.1.0.tgz", + "integrity": "sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==", "dev": true, "funding": { "type": "github", @@ -21876,14 +22858,14 @@ } }, "node_modules/tsconfig-paths": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.13.0.tgz", - "integrity": "sha512-nWuffZppoaYK0vQ1SQmkSsQzJoHA4s6uzdb2waRpD806x9yfq153AdVsWz4je2qZcW+pENrMQXbGQ3sMCkXuhw==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", "dev": true, "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.1", - "minimist": "^1.2.0", + "minimist": "^1.2.6", "strip-bom": "^3.0.0" } }, @@ -21908,7 +22890,7 @@ "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", "dev": true, "dependencies": { "safe-buffer": "^5.0.1" @@ -21920,7 +22902,7 @@ "node_modules/tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==", "dev": true }, "node_modules/type": { @@ -21977,13 +22959,13 @@ "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, "node_modules/typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true, "peer": true, "bin": { @@ -22016,9 +22998,9 @@ } }, "node_modules/ua-parser-js": { - "version": "0.7.31", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.31.tgz", - "integrity": "sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ==", + "version": "0.7.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.33.tgz", + "integrity": "sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw==", "dev": true, "funding": [ { @@ -22035,9 +23017,9 @@ } }, "node_modules/uglify-js": { - "version": "3.15.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.2.tgz", - "integrity": "sha512-peeoTk3hSwYdoc9nrdiEJk+gx1ALCtTjdYuKSXMTDqq7n1W7dHPqWDdSi+BPL0ni2YMeHD7hKUSdbj3TZauY2A==", + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", + "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", "dev": true, "optional": true, "bin": { @@ -22048,14 +23030,14 @@ } }, "node_modules/unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, "dependencies": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" }, "funding": { @@ -22075,7 +23057,7 @@ "node_modules/unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -22105,7 +23087,7 @@ "node_modules/undertaker-registry": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz", - "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=", + "integrity": "sha512-UR1khWeAjugW3548EfQmL9Z7pGMlBgXteQpr1IZeZBtnkCJQJIJ1Scj0mb9wQaPvUZ9Q17XqW6TIaPchJkyfqw==", "dev": true, "engines": { "node": ">= 0.10" @@ -22114,14 +23096,13 @@ "node_modules/undertaker/node_modules/fast-levenshtein": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz", - "integrity": "sha1-5qdUzI8V5YmHqpy9J69m/W9OWvk=", + "integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==", "dev": true }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==", - "dev": true, "engines": { "node": ">=4" } @@ -22130,7 +23111,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dev": true, "dependencies": { "unicode-canonical-property-names-ecmascript": "^2.0.0", "unicode-property-aliases-ecmascript": "^2.0.0" @@ -22143,47 +23123,37 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.0.0.tgz", "integrity": "sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw==", - "dev": true, "engines": { "node": ">=4" } }, "node_modules/unicode-property-aliases-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz", - "integrity": "sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ==", - "dev": true, + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", + "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==", "engines": { "node": ">=4" } }, "node_modules/unified": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.2.tgz", - "integrity": "sha512-Sg7j110mtefBD+qunSLO1lqOEKdrwBFBrR6Qd8f4uwkhWNlbkaqwHse6e7QvD3AP/MNoJdEDLaf8OxYyoWgorQ==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/unified/-/unified-10.1.2.tgz", + "integrity": "sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==", "dev": true, "dependencies": { - "bail": "^1.0.0", + "@types/unist": "^2.0.0", + "bail": "^2.0.0", "extend": "^3.0.0", "is-buffer": "^2.0.0", - "is-plain-obj": "^2.0.0", - "trough": "^1.0.0", - "vfile": "^4.0.0" + "is-plain-obj": "^4.0.0", + "trough": "^2.0.0", + "vfile": "^5.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/unified/node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", @@ -22199,10 +23169,19 @@ "node": ">=0.10.0" } }, + "node_modules/union-value/node_modules/arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/union-value/node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true, "engines": { "node": ">=0.10.0" @@ -22219,19 +23198,22 @@ } }, "node_modules/unist-builder": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-2.0.3.tgz", - "integrity": "sha512-f98yt5pnlMWlzP539tPc4grGMsFaQQlP/vM396b00jngsiINumNmsY8rkXjfoi1c6QaM8nQ3vaGDuoKWbe/1Uw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-3.0.0.tgz", + "integrity": "sha512-GFxmfEAa0vi9i5sd0R2kcrI9ks0r82NasRq5QHh2ysGngrc6GiqD5CDf1FjPenY4vApmFASBIIlk/jj5J5YbmQ==", "dev": true, + "dependencies": { + "@types/unist": "^2.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, "node_modules/unist-util-generated": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.6.tgz", - "integrity": "sha512-cln2Mm1/CZzN5ttGK7vkoGw+RZ8VcUH6BtGbq98DDtRGquAAOXig1mrBQYelOwMXYS8rK+vZDyyojSjp7JX+Lg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-2.0.0.tgz", + "integrity": "sha512-TiWE6DVtVe7Ye2QxOVW9kqybs6cZexNwTwSMVgkfjEReqy/xwGpAXb99OxktoWwmL+Z+Epb0Dn8/GNDYP1wnUw==", "dev": true, "funding": { "type": "opencollective", @@ -22239,9 +23221,9 @@ } }, "node_modules/unist-util-is": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz", - "integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", + "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", "dev": true, "funding": { "type": "opencollective", @@ -22249,22 +23231,25 @@ } }, "node_modules/unist-util-position": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.1.0.tgz", - "integrity": "sha512-w+PkwCbYSFw8vpgWD0v7zRCl1FpY3fjDSQ3/N/wNd9Ffa4gPi8+4keqt99N3XW6F99t/mUzp2xAhNmfKWp95QA==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.3.tgz", + "integrity": "sha512-p/5EMGIa1qwbXjA+QgcBXaPWjSnZfQ2Sc3yBEEfgPwsEmJd8Qh+DSk3LGnmOM4S1bY2C0AjmMnB8RuEYxpPwXQ==", "dev": true, + "dependencies": { + "@types/unist": "^2.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, "node_modules/unist-util-stringify-position": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", - "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz", + "integrity": "sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==", "dev": true, "dependencies": { - "@types/unist": "^2.0.2" + "@types/unist": "^2.0.0" }, "funding": { "type": "opencollective", @@ -22272,14 +23257,14 @@ } }, "node_modules/unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.1.1.tgz", + "integrity": "sha512-n9KN3WV9k4h1DxYR1LoajgN93wpEi/7ZplVe02IoB4gH5ctI1AaF2670BLHQYbwj+pY83gFtyeySFiyMHJklrg==", "dev": true, "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^5.1.1" }, "funding": { "type": "opencollective", @@ -22287,13 +23272,13 @@ } }, "node_modules/unist-util-visit-parents": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz", - "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.1.1.tgz", + "integrity": "sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==", "dev": true, "dependencies": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" + "unist-util-is": "^5.0.0" }, "funding": { "type": "opencollective", @@ -22312,7 +23297,7 @@ "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", "engines": { "node": ">= 0.8" } @@ -22320,7 +23305,7 @@ "node_modules/unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "integrity": "sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==", "dev": true, "dependencies": { "has-value": "^0.3.1", @@ -22333,7 +23318,7 @@ "node_modules/unset-value/node_modules/has-value": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "integrity": "sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==", "dev": true, "dependencies": { "get-value": "^2.0.3", @@ -22347,7 +23332,7 @@ "node_modules/unset-value/node_modules/has-value/node_modules/isobject": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==", "dev": true, "dependencies": { "isarray": "1.0.0" @@ -22359,7 +23344,7 @@ "node_modules/unset-value/node_modules/has-values": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "integrity": "sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -22368,7 +23353,7 @@ "node_modules/unset-value/node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "node_modules/unzipper": { @@ -22388,6 +23373,15 @@ "setimmediate": "~1.0.4" } }, + "node_modules/unzipper/node_modules/duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", + "dev": true, + "dependencies": { + "readable-stream": "^2.0.2" + } + }, "node_modules/upath": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", @@ -22398,6 +23392,31 @@ "yarn": "*" } }, + "node_modules/update-browserslist-db": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", + "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "browserslist-lint": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -22410,14 +23429,14 @@ "node_modules/urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "integrity": "sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==", "deprecated": "Please see https://github.com/lydell/urix#deprecated", "dev": true }, "node_modules/url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", "dev": true, "dependencies": { "punycode": "1.3.2", @@ -22434,10 +23453,16 @@ "requires-port": "^1.0.0" } }, + "node_modules/url-toolkit": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/url-toolkit/-/url-toolkit-2.2.5.tgz", + "integrity": "sha512-mtN6xk+Nac+oyJ/PrI7tzfmomRVNFIWKUbG8jdYFt52hxbiReFAXIjYskvu64/dvuW71IcB7lV8l0HvZMac6Jg==", + "dev": true + }, "node_modules/url/node_modules/punycode": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==", "dev": true }, "node_modules/use": { @@ -22450,29 +23475,28 @@ } }, "node_modules/util": { - "version": "0.12.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.4.tgz", - "integrity": "sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw==", + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", "dev": true, "dependencies": { "inherits": "^2.0.3", "is-arguments": "^1.0.4", "is-generator-function": "^1.0.7", "is-typed-array": "^1.1.3", - "safe-buffer": "^5.1.2", "which-typed-array": "^1.1.2" } }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", "engines": { "node": ">= 0.4.0" } @@ -22487,6 +23511,24 @@ "uuid": "bin/uuid" } }, + "node_modules/uvu": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz", + "integrity": "sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==", + "dev": true, + "dependencies": { + "dequal": "^2.0.0", + "diff": "^5.0.0", + "kleur": "^4.0.3", + "sade": "^1.7.3" + }, + "bin": { + "uvu": "bin.js" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -22518,7 +23560,7 @@ "node_modules/value-or-function": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", - "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=", + "integrity": "sha512-jdBB2FrWvQC/pnPtIqcLsMaQgjhdb6B7tk1MMyTKapox+tQZbdRP4uLxu/JY0t7fbfDCUMnuelzEYv5GsxHhdg==", "dev": true, "engines": { "node": ">= 0.10" @@ -22527,7 +23569,7 @@ "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", "engines": { "node": ">= 0.8" } @@ -22535,7 +23577,7 @@ "node_modules/verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", "dev": true, "engines": [ "node >=0.6.0" @@ -22549,19 +23591,19 @@ "node_modules/verror/node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true }, "node_modules/vfile": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.1.tgz", - "integrity": "sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==", + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.5.tgz", + "integrity": "sha512-U1ho2ga33eZ8y8pkbQLH54uKqGhFJ6GYIHnnG5AhRpAh3OWjkrRHKa/KogbmQn8We+c0KVV3rTOgR9V/WowbXQ==", "dev": true, "dependencies": { "@types/unist": "^2.0.0", "is-buffer": "^2.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-message": "^2.0.0" + "unist-util-stringify-position": "^3.0.0", + "vfile-message": "^3.0.0" }, "funding": { "type": "opencollective", @@ -22569,13 +23611,13 @@ } }, "node_modules/vfile-message": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", - "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.2.tgz", + "integrity": "sha512-QjSNP6Yxzyycd4SVOtmKKyTsSvClqBPJcd00Z0zuPj3hOIjg0rUPG6DbFGPvUKRgYyaIWLPKpuEclcuvb3H8qA==", "dev": true, "dependencies": { "@types/unist": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" + "unist-util-stringify-position": "^3.0.0" }, "funding": { "type": "opencollective", @@ -22583,64 +23625,203 @@ } }, "node_modules/vfile-reporter": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-6.0.2.tgz", - "integrity": "sha512-GN2bH2gs4eLnw/4jPSgfBjo+XCuvnX9elHICJZjVD4+NM0nsUrMTvdjGY5Sc/XG69XVTgLwj7hknQVc6M9FukA==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-7.0.4.tgz", + "integrity": "sha512-4cWalUnLrEnbeUQ+hARG5YZtaHieVK3Jp4iG5HslttkVl+MHunSGNAIrODOTLbtjWsNZJRMCkL66AhvZAYuJ9A==", "dev": true, "dependencies": { - "repeat-string": "^1.5.0", - "string-width": "^4.0.0", - "supports-color": "^6.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-sort": "^2.1.2", - "vfile-statistics": "^1.1.0" + "@types/supports-color": "^8.0.0", + "string-width": "^5.0.0", + "supports-color": "^9.0.0", + "unist-util-stringify-position": "^3.0.0", + "vfile-sort": "^3.0.0", + "vfile-statistics": "^2.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, - "node_modules/vfile-reporter/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "node_modules/vfile-reporter/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, "engines": { - "node": ">=4" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "node_modules/vfile-reporter/node_modules/supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "node_modules/vfile-reporter/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/vfile-reporter/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, "dependencies": { - "has-flag": "^3.0.0" + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" }, "engines": { - "node": ">=6" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/vfile-reporter/node_modules/strip-ansi": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", + "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/vfile-reporter/node_modules/supports-color": { + "version": "9.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.2.3.tgz", + "integrity": "sha512-aszYUX/DVK/ed5rFLb/dDinVJrQjG/vmU433wtqVSD800rYsJNWxh2R3USV90aLSU+UsyQkbNeffVLzc6B6foA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" } }, "node_modules/vfile-sort": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-2.2.2.tgz", - "integrity": "sha512-tAyUqD2R1l/7Rn7ixdGkhXLD3zsg+XLAeUDUhXearjfIcpL1Hcsj5hHpCoy/gvfK/Ws61+e972fm0F7up7hfYA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-3.0.0.tgz", + "integrity": "sha512-fJNctnuMi3l4ikTVcKpxTbzHeCgvDhnI44amA3NVDvA6rTC6oKCFpCVyT5n2fFMr3ebfr+WVQZedOCd73rzSxg==", "dev": true, + "dependencies": { + "vfile-message": "^3.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, "node_modules/vfile-statistics": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-1.1.4.tgz", - "integrity": "sha512-lXhElVO0Rq3frgPvFBwahmed3X03vjPF8OcjKMy8+F1xU/3Q3QU3tKEDp743SFtb74PdF0UWpxPvtOP0GCLheA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-2.0.0.tgz", + "integrity": "sha512-foOWtcnJhKN9M2+20AOTlWi2dxNfAoeNIoxD5GXcO182UJyId4QrXa41fWrgcfV3FWTjdEDy3I4cpLVcQscIMA==", "dev": true, + "dependencies": { + "vfile-message": "^3.0.0" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/unified" } }, + "node_modules/video.js": { + "version": "7.20.3", + "resolved": "https://registry.npmjs.org/video.js/-/video.js-7.20.3.tgz", + "integrity": "sha512-JMspxaK74LdfWcv69XWhX4rILywz/eInOVPdKefpQiZJSMD5O8xXYueqACP2Q5yqKstycgmmEKlJzZ+kVmDciw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "@videojs/http-streaming": "2.14.3", + "@videojs/vhs-utils": "^3.0.4", + "@videojs/xhr": "2.6.0", + "aes-decrypter": "3.1.3", + "global": "^4.4.0", + "keycode": "^2.2.0", + "m3u8-parser": "4.7.1", + "mpd-parser": "0.21.1", + "mux.js": "6.0.1", + "safe-json-parse": "4.0.0", + "videojs-font": "3.2.0", + "videojs-vtt.js": "^0.15.4" + } + }, + "node_modules/video.js/node_modules/safe-json-parse": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-4.0.0.tgz", + "integrity": "sha512-RjZPPHugjK0TOzFrLZ8inw44s9bKox99/0AZW9o/BEQVrJfhI+fIHMErnPyRa89/yRXUUr93q+tiN6zhoVV4wQ==", + "dev": true, + "dependencies": { + "rust-result": "^1.0.0" + } + }, + "node_modules/videojs-contrib-ads": { + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/videojs-contrib-ads/-/videojs-contrib-ads-6.9.0.tgz", + "integrity": "sha512-nzKz+jhCGMTYffSNVYrmp9p70s05v6jUMOY3Z7DpVk3iFrWK4Zi/BIkokDWrMoHpKjdmCdKzfJVBT+CrUj6Spw==", + "dev": true, + "dependencies": { + "global": "^4.3.2", + "video.js": "^6 || ^7" + }, + "engines": { + "node": ">=8", + "npm": ">=5" + } + }, + "node_modules/videojs-font": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/videojs-font/-/videojs-font-3.2.0.tgz", + "integrity": "sha512-g8vHMKK2/JGorSfqAZQUmYYNnXmfec4MLhwtEFS+mMs2IDY398GLysy6BH6K+aS1KMNu/xWZ8Sue/X/mdQPliA==", + "dev": true + }, + "node_modules/videojs-ima": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/videojs-ima/-/videojs-ima-1.11.0.tgz", + "integrity": "sha512-ZRoWuGyJ75zamwZgpr0i/gZ6q7Evda/Q6R46gpW88WN7u0ORU7apw/lM1MSG4c3YDXW8LDENgzMAvMZUdifWhg==", + "dev": true, + "dependencies": { + "@hapi/cryptiles": "^5.1.0", + "can-autoplay": "^3.0.0", + "extend": ">=3.0.2", + "lodash": ">=4.17.19", + "lodash.template": ">=4.5.0", + "videojs-contrib-ads": "^6.6.5" + }, + "engines": { + "node": ">=0.8.0" + }, + "peerDependencies": { + "video.js": "^5.19.2 || ^6 || ^7" + } + }, + "node_modules/videojs-playlist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/videojs-playlist/-/videojs-playlist-5.0.0.tgz", + "integrity": "sha512-TM9bytwKqkE05wdWPEKDpkwMGhS/VgMCIsEuNxmX1J1JO9zaTIl4Wm3egf5j1dhIw19oWrqGUV/nK0YNIelCpA==", + "dev": true, + "dependencies": { + "global": "^4.3.2", + "video.js": "^6 || ^7" + }, + "engines": { + "node": ">=4.4.0" + } + }, + "node_modules/videojs-vtt.js": { + "version": "0.15.4", + "resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.4.tgz", + "integrity": "sha512-r6IhM325fcLb1D6pgsMkTQT1PpFdUdYZa1iqk7wJEu+QlibBwATPfPc9Bg8Jiym0GE5yP1AG2rMLu+QMVWkYtA==", + "dev": true, + "dependencies": { + "global": "^4.3.1" + } + }, "node_modules/vinyl": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", @@ -22699,7 +23880,7 @@ "node_modules/vinyl-sourcemap": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", - "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", + "integrity": "sha512-NiibMgt6VJGJmyw7vtzhctDcfKch4e4n9TBeoWlirb7FMg9/1Ov9k+A5ZRAtywBpRPiyECvQRQllYM8dECegVA==", "dev": true, "dependencies": { "append-buffer": "^1.0.2", @@ -22717,7 +23898,7 @@ "node_modules/vinyl-sourcemap/node_modules/normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "dependencies": { "remove-trailing-separator": "^1.0.1" @@ -22729,7 +23910,7 @@ "node_modules/vinyl-sourcemaps-apply": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", - "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", + "integrity": "sha512-+oDh3KYZBoZC8hfocrbrxbLUeaYtQK7J5WU5Br9VqWqmCll3tFJqKp97GC9GmMsVIL0qnx2DgEDVxdo5EZ5sSw==", "dev": true, "dependencies": { "source-map": "^0.5.1" @@ -22747,21 +23928,21 @@ "node_modules/void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "integrity": "sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung==", "dev": true, "engines": { "node": ">=0.10.0" } }, "node_modules/vue-template-compiler": { - "version": "2.6.14", - "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.14.tgz", - "integrity": "sha512-ODQS1SyMbjKoO1JBJZojSw6FE4qnh9rIpUZn2EUT86FKizx9uH5z6uXiIrm4/Nb/gwxTi/o17ZDEGWAXHvtC7g==", + "version": "2.7.13", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.13.tgz", + "integrity": "sha512-jYM6TClwDS9YqP48gYrtAtaOhRKkbYmbzE+Q51gX5YDr777n7tNI/IZk4QV4l/PjQPNh/FVa/E92sh/RqKMrog==", "dev": true, "optional": true, "dependencies": { "de-indent": "^1.0.2", - "he": "^1.1.0" + "he": "^1.2.0" } }, "node_modules/walk": { @@ -22774,9 +23955,9 @@ } }, "node_modules/watchpack": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz", - "integrity": "sha512-x0t0JuydIo8qCNctdDrn1OzH/qDzk2+rdCOC3YzumZ42fiMqmQ7T3xQurykYMhYfHaPHTp4ZxAx2NfUo1K6QaA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", "dev": true, "dependencies": { "glob-to-regexp": "^0.4.1", @@ -22789,54 +23970,148 @@ "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", "dev": true, "dependencies": { "defaults": "^1.0.3" } }, "node_modules/webdriver": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.16.16.tgz", - "integrity": "sha512-x8UoG9k/P8KDrfSh1pOyNevt9tns3zexoMxp9cKnyA/7HYSErhZYTLGlgxscAXLtQG41cMH/Ba/oBmOx7Hgd8w==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.5.3.tgz", + "integrity": "sha512-cDTn/hYj5x8BYwXxVb/WUwqGxrhCMP2rC8ttIWCfzmiVtmOnJGulC7CyxU3+p9Q5R/gIKTzdJOss16dhb+5CoA==", "dev": true, "dependencies": { - "@types/node": "^17.0.4", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/protocols": "7.16.7", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", "got": "^11.0.2", - "ky": "^0.29.0", "lodash.merge": "^4.6.1" }, "engines": { "node": ">=12.0.0" } }, + "node_modules/webdriver/node_modules/@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriver/node_modules/@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "dependencies": { + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriver/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/webdriver/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/webdriver/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/webdriver/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/webdriver/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/webdriver/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/webdriverio": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.16.16.tgz", - "integrity": "sha512-caPaEWyuD3Qoa7YkW4xCCQA4v9Pa9wmhFGPvNZh3ERtjMCNi8L/XXOdkekWNZmFh3tY0kFguBj7+fAwSY7HAGw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.25.4.tgz", + "integrity": "sha512-agkgwn2SIk5cAJ03uue1GnGZcUZUDN3W4fUMY9/VfO8bVJrPEgWg31bPguEWPu+YhEB/aBJD8ECxJ3OEKdy4qQ==", "dev": true, "dependencies": { "@types/aria-query": "^5.0.0", - "@types/node": "^17.0.4", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/protocols": "7.16.7", - "@wdio/repl": "7.16.14", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@types/node": "^18.0.0", + "@wdio/config": "7.25.4", + "@wdio/logger": "7.19.0", + "@wdio/protocols": "7.22.0", + "@wdio/repl": "7.25.4", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", "archiver": "^5.0.0", "aria-query": "^5.0.0", "css-shorthand-properties": "^1.1.1", "css-value": "^0.0.1", - "devtools": "7.16.16", - "devtools-protocol": "^0.0.973690", + "devtools": "7.25.4", + "devtools-protocol": "^0.0.1061995", "fs-extra": "^10.0.0", - "get-port": "^5.1.1", "grapheme-splitter": "^1.0.2", "lodash.clonedeep": "^4.5.0", "lodash.isobject": "^3.0.2", @@ -22848,12 +24123,120 @@ "resq": "^1.9.1", "rgb2hex": "0.2.5", "serialize-error": "^8.0.0", - "webdriver": "7.16.16" + "webdriver": "7.25.4" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriverio/node_modules/@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "dev": true + }, + "node_modules/webdriverio/node_modules/@wdio/config": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.25.4.tgz", + "integrity": "sha512-vb0emDtD9FbFh/yqW6oNdo2iuhQp8XKj6GX9fyy9v4wZgg3B0HPMVJxhIfcoHz7LMBWlHSo9YdvhFI5EQHRLBA==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", + "deepmerge": "^4.0.0", + "glob": "^8.0.3" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriverio/node_modules/@wdio/logger": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.19.0.tgz", + "integrity": "sha512-xR7SN/kGei1QJD1aagzxs3KMuzNxdT/7LYYx+lt6BII49+fqL/SO+5X0FDCZD0Ds93AuQvvz9eGyzrBI2FFXmQ==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriverio/node_modules/@wdio/protocols": { + "version": "7.22.0", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.22.0.tgz", + "integrity": "sha512-8EXRR+Ymdwousm/VGtW3H1hwxZ/1g1H99A1lF0U4GuJ5cFWHCd0IVE5H31Z52i8ZruouW8jueMkGZPSo2IIUSQ==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriverio/node_modules/@wdio/repl": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.25.4.tgz", + "integrity": "sha512-kYhj9gLsUk4HmlXLqkVre+gwbfvw9CcnrHjqIjrmMS4mR9D8zvBb5CItb3ZExfPf9jpFzIFREbCAYoE9x/kMwg==", + "dev": true, + "dependencies": { + "@wdio/utils": "7.25.4" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/webdriverio/node_modules/@wdio/types": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.25.4.tgz", + "integrity": "sha512-muvNmq48QZCvocctnbe0URq2FjJjUPIG4iLoeMmyF0AQgdbjaUkMkw3BHYNHVTbSOU9WMsr2z8alhj/I2H6NRQ==", + "dev": true, + "dependencies": { + "@types/node": "^18.0.0", + "got": "^11.8.1" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "typescript": "^4.6.2" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/webdriverio/node_modules/@wdio/utils": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.25.4.tgz", + "integrity": "sha512-8iwQDk+foUqSzKZKfhLxjlCKOkfRJPNHaezQoevNgnrTq/t0ek+ldZCATezb9B8jprAuP4mgS9xi22akc6RkzA==", + "dev": true, + "dependencies": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "p-iteration": "^1.1.8" }, "engines": { "node": ">=12.0.0" } }, + "node_modules/webdriverio/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/webdriverio/node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -22863,10 +24246,84 @@ "balanced-match": "^1.0.0" } }, + "node_modules/webdriverio/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/webdriverio/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/webdriverio/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/webdriverio/node_modules/glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/webdriverio/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/webdriverio/node_modules/ky": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/ky/-/ky-0.30.0.tgz", + "integrity": "sha512-X/u76z4JtDVq10u1JA5UQfatPxgPaVDMYTrgHyiTpGN2z4TMEJkIHsoSBBSg9SWZEIXTKsi9kHgiQ9o3Y/4yog==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/ky?sponsor=1" + } + }, "node_modules/webdriverio/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -22875,16 +24332,48 @@ "node": ">=10" } }, + "node_modules/webdriverio/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/webdriverio/node_modules/webdriver": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.25.4.tgz", + "integrity": "sha512-6nVDwenh0bxbtUkHASz9B8T9mB531Fn1PcQjUGj2t5dolLPn6zuK1D7XYVX40hpn6r3SlYzcZnEBs4X0az5Txg==", + "dev": true, + "dependencies": { + "@types/node": "^18.0.0", + "@wdio/config": "7.25.4", + "@wdio/logger": "7.19.0", + "@wdio/protocols": "7.22.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", + "got": "^11.0.2", + "ky": "0.30.0", + "lodash.merge": "^4.6.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, "node_modules/webpack": { - "version": "5.70.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.70.0.tgz", - "integrity": "sha512-ZMWWy8CeuTTjCxbeaQI21xSswseF2oNOwc70QSKNePvmxE7XW36i7vpBMYZFAUHPwQiEbNGCEYIOOlyRbdGmxw==", + "version": "5.76.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz", + "integrity": "sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==", "dev": true, "dependencies": { "@types/eslint-scope": "^3.7.3", @@ -22892,24 +24381,24 @@ "@webassemblyjs/ast": "1.11.1", "@webassemblyjs/wasm-edit": "1.11.1", "@webassemblyjs/wasm-parser": "1.11.1", - "acorn": "^8.4.1", + "acorn": "^8.7.1", "acorn-import-assertions": "^1.7.6", "browserslist": "^4.14.5", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.9.2", + "enhanced-resolve": "^5.10.0", "es-module-lexer": "^0.9.0", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.2.9", - "json-parse-better-errors": "^1.0.2", + "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", "schema-utils": "^3.1.0", "tapable": "^2.1.1", "terser-webpack-plugin": "^5.1.3", - "watchpack": "^2.3.1", + "watchpack": "^2.4.0", "webpack-sources": "^3.2.3" }, "bin": { @@ -22929,9 +24418,9 @@ } }, "node_modules/webpack-bundle-analyzer": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz", - "integrity": "sha512-GUMZlM3SKwS8Z+CKeIFx7CVoHn3dXFcUAjT/dcZQQmfSZGvitPfMob2ipjai7ovFFqPvTqkEZ/leL4O0YOdAYQ==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.7.0.tgz", + "integrity": "sha512-j9b8ynpJS4K+zfO5GGwsAcQX4ZHpWV+yRiHDiL+bE0XHJ8NiPYLTNVQdlFYWxtpg9lfAQNlwJg16J9AJtFSXRg==", "dev": true, "dependencies": { "acorn": "^8.0.4", @@ -22952,9 +24441,9 @@ } }, "node_modules/webpack-bundle-analyzer/node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -22963,15 +24452,6 @@ "node": ">=0.4.0" } }, - "node_modules/webpack-bundle-analyzer/node_modules/acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/webpack-bundle-analyzer/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -23030,6 +24510,15 @@ "node": ">= 10" } }, + "node_modules/webpack-bundle-analyzer/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/webpack-bundle-analyzer/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -23043,9 +24532,9 @@ } }, "node_modules/webpack-bundle-analyzer/node_modules/ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", "dev": true, "engines": { "node": ">=8.3.0" @@ -23063,6 +24552,44 @@ } } }, + "node_modules/webpack-manifest-plugin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webpack-manifest-plugin/-/webpack-manifest-plugin-5.0.0.tgz", + "integrity": "sha512-8RQfMAdc5Uw3QbCQ/CBV/AXqOR8mt03B6GJmRbhWopE8GzRfEpn+k0ZuWywxW+5QZsffhmFDY1J6ohqJo+eMuw==", + "dev": true, + "dependencies": { + "tapable": "^2.0.0", + "webpack-sources": "^2.2.0" + }, + "engines": { + "node": ">=12.22.0" + }, + "peerDependencies": { + "webpack": "^5.47.0" + } + }, + "node_modules/webpack-manifest-plugin/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/webpack-manifest-plugin/node_modules/webpack-sources": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.3.1.tgz", + "integrity": "sha512-y9EI9AO42JjEcrTJFOYmVywVZdKVUfOvDUPsJea5GIr1JOEGFVqwlY2K098fFoIjOkDzHn2AjRvM8dsBZu+gCA==", + "dev": true, + "dependencies": { + "source-list-map": "^2.0.1", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/webpack-merge": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", @@ -23103,10 +24630,92 @@ "webpack": "^5.21.2" } }, + "node_modules/webpack-stream/node_modules/ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "dependencies": { + "ansi-wrap": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/webpack-stream/node_modules/arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/webpack-stream/node_modules/arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/webpack-stream/node_modules/extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "dependencies": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/webpack-stream/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/webpack-stream/node_modules/plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "dependencies": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/webpack-stream/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/webpack/node_modules/acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -23140,15 +24749,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/webpack/node_modules/ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "peerDependencies": { - "ajv": "^6.9.1" - } - }, "node_modules/webpack/node_modules/schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -23193,7 +24793,7 @@ "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, "dependencies": { "tr46": "~0.0.3", @@ -23247,23 +24847,23 @@ } }, "node_modules/which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==", "dev": true }, "node_modules/which-typed-array": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.7.tgz", - "integrity": "sha512-vjxaB4nfDqwKI0ws7wZpxIlde1XrLX5uB0ZjpfshgmapJMD7jJWhZI+yToJTqaFByF0eNBcYxbjmCzoRP7CfEw==", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.8.tgz", + "integrity": "sha512-Jn4e5PItbcAHyLoRDwvPj1ypu27DJbtdYXUa5zsinrUx77Uvfb0cXwwnGMTn7cjUfhhqgVQnVJCwF+7cgU7tpw==", "dev": true, "dependencies": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", - "es-abstract": "^1.18.5", - "foreach": "^2.0.5", + "es-abstract": "^1.20.0", + "for-each": "^0.3.3", "has-tostringtag": "^1.0.0", - "is-typed-array": "^1.1.7" + "is-typed-array": "^1.1.9" }, "engines": { "node": ">= 0.4" @@ -23272,10 +24872,62 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/wide-align/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/wide-align/node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/wide-align/node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/wide-align/node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -23284,13 +24936,13 @@ "node_modules/wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", "dev": true }, "node_modules/workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "node_modules/wrap-ansi": { @@ -23346,37 +24998,37 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "node_modules/write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", "dev": true, "dependencies": { "mkdirp": "^0.5.1" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" } }, "node_modules/write/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" }, "bin": { "mkdirp": "bin/cmd.js" } }, "node_modules/ws": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", - "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "dev": true, "engines": { "node": ">=10.0.0" @@ -23421,13 +25073,13 @@ "node_modules/yargs": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/yargs/-/yargs-1.3.3.tgz", - "integrity": "sha1-BU3oth8i7v23IHBZ6u+da4P7kxo=", + "integrity": "sha512-7OGt4xXoWJQh5ulgZ78rKaqY7dNWbjfK+UKxGcIlaM2j7C4fqGchyv8CPvEWdRPrHp6Ula/YU8yGRpYGOHrI+g==", "dev": true }, "node_modules/yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, "engines": { "node": ">=12" @@ -23460,18 +25112,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/yargs-unparser/node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/yargs-unparser/node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -23484,7 +25124,7 @@ "node_modules/yarn-install": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yarn-install/-/yarn-install-1.0.0.tgz", - "integrity": "sha1-V/RQULgu/VcYKzlzxUqgXLXSUjA=", + "integrity": "sha512-VO1u181msinhPcGvQTVMnHVOae8zjX/NSksR17e6eXHRveDvHCF5mGjh9hkN8mzyfnCqcBe42LdTs7bScuTaeg==", "dev": true, "dependencies": { "cac": "^3.0.3", @@ -23502,7 +25142,7 @@ "node_modules/yarn-install/node_modules/ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -23511,7 +25151,7 @@ "node_modules/yarn-install/node_modules/ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -23520,7 +25160,7 @@ "node_modules/yarn-install/node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "dependencies": { "ansi-styles": "^2.2.1", @@ -23536,7 +25176,7 @@ "node_modules/yarn-install/node_modules/cross-spawn": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz", - "integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=", + "integrity": "sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==", "dev": true, "dependencies": { "lru-cache": "^4.0.1", @@ -23556,7 +25196,7 @@ "node_modules/yarn-install/node_modules/strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "dependencies": { "ansi-regex": "^2.0.0" @@ -23568,7 +25208,7 @@ "node_modules/yarn-install/node_modules/supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true, "engines": { "node": ">=0.8.0" @@ -23589,13 +25229,13 @@ "node_modules/yarn-install/node_modules/yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true }, "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "dev": true, "dependencies": { "buffer-crc32": "~0.2.3", @@ -23643,9 +25283,9 @@ } }, "node_modules/zwitch": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-1.0.5.tgz", - "integrity": "sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.2.tgz", + "integrity": "sha512-JZxotl7SxAJH0j7dN4pxsTV6ZLXoLdGME+PsjkL/DaBrVryK9kTGq06GfKrwcSOqypP+fdXGoCHE36b99fWVoA==", "dev": true, "funding": { "type": "github", @@ -23661,140 +25301,140 @@ }, "dependencies": { "@ampproject/remapping": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.1.2.tgz", - "integrity": "sha512-hoyByceqwKirw7w3Z7gnIIZC3Wx3J484Y3L/cMpXFbr7d9ZQj2mODrirNzcJa+SM3UlpWXYvKV4RlRpFXlWgXg==", - "dev": true, + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", "requires": { - "@jridgewell/trace-mapping": "^0.3.0" + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" } }, "@babel/code-frame": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz", - "integrity": "sha512-iAXqUn8IIeBTNd72xsFlgaXHkMBMt6y4HJp1tIaK465CWLT/fG1aqB7ykr95gHHmlBdGbFeWWfyB4NJJ0nmeIg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", + "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", "requires": { - "@babel/highlight": "^7.16.7" + "@babel/highlight": "^7.18.6" } }, "@babel/compat-data": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.17.0.tgz", - "integrity": "sha512-392byTlpGWXMv4FbyWw3sAZ/FrW/DrwqLGXpy0mbyNe9Taqv1mg9yON5/o0cnr8XYCkFTZbC1eV+c+LAROgrng==", - "dev": true + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.20.1.tgz", + "integrity": "sha512-EWZ4mE2diW3QALKvDMiXnbZpRvlj+nayZ112nK93SnhqOtpdsbVD4W+2tEoT3YNBAG9RBR0ISY758ZkOgsn6pQ==" }, "@babel/core": { - "version": "7.17.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.17.5.tgz", - "integrity": "sha512-/BBMw4EvjmyquN5O+t5eh0+YqB3XXJkYD2cjKpYtWOfFy4lQ4UozNSmxAcWT8r2XtZs0ewG+zrfsqeR15i1ajA==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.19.6.tgz", + "integrity": "sha512-D2Ue4KHpc6Ys2+AxpIx1BZ8+UegLLLE2p3KJEuJRKmokHOtl49jQ5ny1773KsGLZs8MQvBidAF6yWUJxRqtKtg==", "requires": { "@ampproject/remapping": "^2.1.0", - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.3", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helpers": "^7.17.2", - "@babel/parser": "^7.17.3", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0", + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.19.6", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helpers": "^7.19.4", + "@babel/parser": "^7.19.6", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.6", + "@babel/types": "^7.19.4", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", - "json5": "^2.1.2", + "json5": "^2.2.1", "semver": "^6.3.0" } }, "@babel/eslint-parser": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.17.0.tgz", - "integrity": "sha512-PUEJ7ZBXbRkbq3qqM/jZ2nIuakUBqCYc7Qf52Lj7dlZ6zERnqisdHioL0l4wwQZnmskMeasqUNzLBFKs3nylXA==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.19.1.tgz", + "integrity": "sha512-AqNf2QWt1rtu2/1rLswy6CDP7H9Oh3mMhk177Y67Rg8d7RD9WfOLLv8CGn6tisFvS2htm86yIe1yLF6I1UDaGQ==", "dev": true, "requires": { - "eslint-scope": "^5.1.1", + "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", "eslint-visitor-keys": "^2.1.0", "semver": "^6.3.0" } }, "@babel/generator": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.17.3.tgz", - "integrity": "sha512-+R6Dctil/MgUsZsZAkYgK+ADNSZzJRRy0TvY65T71z/CR854xHQ1EweBYXdfT+HNeN7w0cSJJEzgxZMv40pxsg==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.1.tgz", + "integrity": "sha512-u1dMdBUmA7Z0rBB97xh8pIhviK7oItYOkjbsCxTWMknyvbQRBwX7/gn4JXurRdirWMFh+ZtYARqkA6ydogVZpg==", "requires": { - "@babel/types": "^7.17.0", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" + "@babel/types": "^7.20.0", + "@jridgewell/gen-mapping": "^0.3.2", + "jsesc": "^2.5.1" + }, + "dependencies": { + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + } } }, "@babel/helper-annotate-as-pure": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz", - "integrity": "sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz", + "integrity": "sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" } }, "@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.16.7.tgz", - "integrity": "sha512-C6FdbRaxYjwVu/geKW4ZeQ0Q31AftgRcdSnZ5/jsH6BzCJbtvXvhpfkbkThYSuutZA7nCXpPR6AD9zd1dprMkA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.18.9.tgz", + "integrity": "sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw==", "requires": { - "@babel/helper-explode-assignable-expression": "^7.16.7", - "@babel/types": "^7.16.7" + "@babel/helper-explode-assignable-expression": "^7.18.6", + "@babel/types": "^7.18.9" } }, "@babel/helper-compilation-targets": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.7.tgz", - "integrity": "sha512-mGojBwIWcwGD6rfqgRXVlVYmPAv7eOpIemUG3dGnDdCY4Pae70ROij3XmfrH6Fa1h1aiDylpglbZyktfzyo/hA==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.0.tgz", + "integrity": "sha512-0jp//vDGp9e8hZzBc6N/KwA5ZK3Wsm/pfm4CrY7vzegkVxc65SgSn6wYOnwHe9Js9HRQ1YTCKLGPzDtaS3RoLQ==", "requires": { - "@babel/compat-data": "^7.16.4", - "@babel/helper-validator-option": "^7.16.7", - "browserslist": "^4.17.5", + "@babel/compat-data": "^7.20.0", + "@babel/helper-validator-option": "^7.18.6", + "browserslist": "^4.21.3", "semver": "^6.3.0" } }, "@babel/helper-create-class-features-plugin": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.17.6.tgz", - "integrity": "sha512-SogLLSxXm2OkBbSsHZMM4tUi8fUzjs63AT/d0YQIzr6GSd8Hxsbk2KYDX0k0DweAzGMj/YWeiCsorIdtdcW8Eg==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.19.0.tgz", + "integrity": "sha512-NRz8DwF4jT3UfrmUoZjd0Uph9HQnP30t7Ash+weACcyNkiYTywpIjDBgReJMKgr+n86sn2nPVVmJ28Dm053Kqw==", "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-member-expression-to-functions": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7" + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-member-expression-to-functions": "^7.18.9", + "@babel/helper-optimise-call-expression": "^7.18.6", + "@babel/helper-replace-supers": "^7.18.9", + "@babel/helper-split-export-declaration": "^7.18.6" } }, "@babel/helper-create-regexp-features-plugin": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.17.0.tgz", - "integrity": "sha512-awO2So99wG6KnlE+TPs6rn83gCz5WlEePJDTnLEqbchMVrBeAujURVphRdigsk094VhvZehFoNOihSlcBjwsXA==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.19.0.tgz", + "integrity": "sha512-htnV+mHX32DF81amCDrwIDr8nrp1PTm+3wfBN9/v8QJOLEioOCOG7qNyq0nHeFiWbT3Eb7gsPwEmV64UCQ1jzw==", "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "regexpu-core": "^5.0.1" + "@babel/helper-annotate-as-pure": "^7.18.6", + "regexpu-core": "^5.1.0" } }, "@babel/helper-define-polyfill-provider": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz", - "integrity": "sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==", - "dev": true, + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz", + "integrity": "sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==", "requires": { - "@babel/helper-compilation-targets": "^7.13.0", - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "@babel/traverse": "^7.13.0", + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", "debug": "^4.1.1", "lodash.debounce": "^4.0.8", "resolve": "^1.14.2", @@ -23802,387 +25442,343 @@ } }, "@babel/helper-environment-visitor": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.16.7.tgz", - "integrity": "sha512-SLLb0AAn6PkUeAfKJCCOl9e1R53pQlGAfc4y4XuMRZfqeMYLE0dM1LMhqbGAlGQY0lfw5/ohoYWAe9V1yibRag==", - "dev": true, - "requires": { - "@babel/types": "^7.16.7" - } + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", + "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==" }, "@babel/helper-explode-assignable-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz", - "integrity": "sha512-KyUenhWMC8VrxzkGP0Jizjo4/Zx+1nNZhgocs+gLzyZyB8SHidhoq9KK/8Ato4anhwsivfkBLftky7gvzbZMtQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.18.6.tgz", + "integrity": "sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" } }, "@babel/helper-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.16.7.tgz", - "integrity": "sha512-QfDfEnIUyyBSR3HtrtGECuZ6DAyCkYFp7GHl75vFtTnn6pjKeK0T1DB5lLkFvBea8MdaiUABx3osbgLyInoejA==", - "dev": true, - "requires": { - "@babel/helper-get-function-arity": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/types": "^7.16.7" - } - }, - "@babel/helper-get-function-arity": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz", - "integrity": "sha512-flc+RLSOBXzNzVhcLu6ujeHUrD6tANAOU5ojrRx/as+tbzf8+stUCj7+IfRRoAbEZqj/ahXEMsjhOhgeZsrnTw==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz", + "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==", "requires": { - "@babel/types": "^7.16.7" + "@babel/template": "^7.18.10", + "@babel/types": "^7.19.0" } }, "@babel/helper-hoist-variables": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.7.tgz", - "integrity": "sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", + "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" } }, "@babel/helper-member-expression-to-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.16.7.tgz", - "integrity": "sha512-VtJ/65tYiU/6AbMTDwyoXGPKHgTsfRarivm+YbB5uAzKUyuPjgZSgAFeG87FCigc7KNHu2Pegh1XIT3lXjvz3Q==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.18.9.tgz", + "integrity": "sha512-RxifAh2ZoVU67PyKIO4AMi1wTenGfMR/O/ae0CCRqwgBAt5v7xjdtRw7UoSbsreKrQn5t7r89eruK/9JjYHuDg==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.9" } }, "@babel/helper-module-imports": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.16.7.tgz", - "integrity": "sha512-LVtS6TqjJHFc+nYeITRo6VLXve70xmq7wPhWTqDJusJEgGmkAACWwMiTNrvfoQo6hEhFwAIixNkvB0jPXDL8Wg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", + "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" } }, "@babel/helper-module-transforms": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.17.6.tgz", - "integrity": "sha512-2ULmRdqoOMpdvkbT8jONrZML/XALfzxlb052bldftkicAUy8AxSCkD5trDPQcwHNmolcl7wP6ehNqMlyUw6AaA==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.19.6.tgz", + "integrity": "sha512-fCmcfQo/KYr/VXXDIyd3CBGZ6AFhPFy1TfSEJ+PilGVlQT6jcbqtHAM4C1EciRqMza7/TpOUZliuSH+U6HAhJw==", "requires": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-simple-access": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.3", - "@babel/types": "^7.17.0" + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-simple-access": "^7.19.4", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.19.1", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.6", + "@babel/types": "^7.19.4" } }, "@babel/helper-optimise-call-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.7.tgz", - "integrity": "sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz", + "integrity": "sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" } }, "@babel/helper-plugin-utils": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", - "integrity": "sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==", - "dev": true + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.19.0.tgz", + "integrity": "sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==" }, "@babel/helper-remap-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz", - "integrity": "sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz", + "integrity": "sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA==", "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-wrap-function": "^7.16.8", - "@babel/types": "^7.16.8" + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-wrap-function": "^7.18.9", + "@babel/types": "^7.18.9" } }, "@babel/helper-replace-supers": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.16.7.tgz", - "integrity": "sha512-y9vsWilTNaVnVh6xiJfABzsNpgDPKev9HnAgz6Gb1p6UUwf9NepdlsV7VXGCftJM+jqD5f7JIEubcpLjZj5dBw==", - "dev": true, + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.19.1.tgz", + "integrity": "sha512-T7ahH7wV0Hfs46SFh5Jz3s0B6+o8g3c+7TMxu7xKfmHikg7EAZ3I2Qk9LFhjxXq8sL7UkP5JflezNwoZa8WvWw==", "requires": { - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-member-expression-to-functions": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/traverse": "^7.16.7", - "@babel/types": "^7.16.7" + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-member-expression-to-functions": "^7.18.9", + "@babel/helper-optimise-call-expression": "^7.18.6", + "@babel/traverse": "^7.19.1", + "@babel/types": "^7.19.0" } }, "@babel/helper-simple-access": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.16.7.tgz", - "integrity": "sha512-ZIzHVyoeLMvXMN/vok/a4LWRy8G2v205mNP0XOuf9XRLyX5/u9CnVulUtDgUTama3lT+bf/UqucuZjqiGuTS1g==", - "dev": true, + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.19.4.tgz", + "integrity": "sha512-f9Xq6WqBFqaDfbCzn2w85hwklswz5qsKlh7f08w4Y9yhJHpnNC0QemtSkK5YyOY8kPGvyiwdzZksGUhnGdaUIg==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.19.4" } }, "@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.16.0.tgz", - "integrity": "sha512-+il1gTy0oHwUsBQZyJvukbB4vPMdcYBrFHa0Uc4AizLxbq6BOYC51Rv4tWocX9BLBDLZ4kc6qUFpQ6HRgL+3zw==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz", + "integrity": "sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg==", "requires": { - "@babel/types": "^7.16.0" + "@babel/types": "^7.20.0" } }, "@babel/helper-split-export-declaration": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.7.tgz", - "integrity": "sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", + "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", "requires": { - "@babel/types": "^7.16.7" + "@babel/types": "^7.18.6" } }, + "@babel/helper-string-parser": { + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz", + "integrity": "sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==" + }, "@babel/helper-validator-identifier": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz", - "integrity": "sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==", - "dev": true + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==" }, "@babel/helper-validator-option": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz", - "integrity": "sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==", - "dev": true + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", + "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==" }, "@babel/helper-wrap-function": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz", - "integrity": "sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.19.0.tgz", + "integrity": "sha512-txX8aN8CZyYGTwcLhlk87KRqncAzhh5TpQamZUa0/u3an36NtDpUP6bQgBCBcLeBs09R/OwQu3OjK0k/HwfNDg==", "requires": { - "@babel/helper-function-name": "^7.16.7", - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.16.8", - "@babel/types": "^7.16.8" + "@babel/helper-function-name": "^7.19.0", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.0", + "@babel/types": "^7.19.0" } }, "@babel/helpers": { - "version": "7.17.2", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.17.2.tgz", - "integrity": "sha512-0Qu7RLR1dILozr/6M0xgj+DFPmi6Bnulgm9M8BVa9ZCWxDqlSnqt3cf8IDPB5m45sVXUZ0kuQAgUrdSFFH79fQ==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.20.1.tgz", + "integrity": "sha512-J77mUVaDTUJFZ5BpP6mMn6OIl3rEWymk2ZxDBQJUG3P+PbmyMcF3bYWvz0ma69Af1oobDqT/iAsvzhB58xhQUg==", "requires": { - "@babel/template": "^7.16.7", - "@babel/traverse": "^7.17.0", - "@babel/types": "^7.17.0" + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.20.1", + "@babel/types": "^7.20.0" } }, "@babel/highlight": { - "version": "7.16.10", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.10.tgz", - "integrity": "sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "requires": { - "@babel/helper-validator-identifier": "^7.16.7", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, "@babel/parser": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.17.3.tgz", - "integrity": "sha512-7yJPvPV+ESz2IUTPbOL+YkIGyCqOyNIzdguKQuJGnH7bg1WTIifuM21YqokFt/THWh1AkCRn9IgoykTRCBVpzA==", - "dev": true + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.1.tgz", + "integrity": "sha512-hp0AYxaZJhxULfM1zyp7Wgr+pSUKBcP3M+PHnSzWGdXOzg/kHWIgiUWARvubhUKGOEw3xqY4x+lyZ9ytBVcELw==" }, "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz", - "integrity": "sha512-anv/DObl7waiGEnC24O9zqL0pSuI9hljihqiDuFHC8d7/bjr/4RLGPWuc8rYOff/QPzbEPSkzG8wGG9aDuhHRg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz", + "integrity": "sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.16.7.tgz", - "integrity": "sha512-di8vUHRdf+4aJ7ltXhaDbPoszdkh59AQtJM5soLsuHpQJdFQZOA4uGj0V2u/CZ8bJ/u8ULDL5yq6FO/bCXnKHw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.18.9.tgz", + "integrity": "sha512-AHrP9jadvH7qlOj6PINbgSuphjQUAK7AOT7DPjBo9EHoLhQTnnK5u45e1Hd4DbSQEO9nqPWtQ89r+XEOWFScKg==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", - "@babel/plugin-proposal-optional-chaining": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9", + "@babel/plugin-proposal-optional-chaining": "^7.18.9" } }, "@babel/plugin-proposal-async-generator-functions": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz", - "integrity": "sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.1.tgz", + "integrity": "sha512-Gh5rchzSwE4kC+o/6T8waD0WHEQIsDmjltY8WnWRXHUdH8axZhuH86Ov9M72YhJfDrZseQwuuWaaIT/TmePp3g==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-remap-async-to-generator": "^7.18.9", "@babel/plugin-syntax-async-generators": "^7.8.4" } }, "@babel/plugin-proposal-class-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.16.7.tgz", - "integrity": "sha512-IobU0Xme31ewjYOShSIqd/ZGM/r/cuOz2z0MDbNrhF5FW+ZVgi0f2lyeoj9KFPDOAqsYxmLWZte1WOwlvY9aww==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", + "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", "requires": { - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-proposal-class-static-block": { - "version": "7.17.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.17.6.tgz", - "integrity": "sha512-X/tididvL2zbs7jZCeeRJ8167U/+Ac135AM6jCAx6gYXDUviZV5Ku9UDvWS2NCuWlFjIRXklYhwo6HhAC7ETnA==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.18.6.tgz", + "integrity": "sha512-+I3oIiNxrCpup3Gi8n5IGMwj0gOCAjcJUSQEcotNnCCPMEnixawOQ+KeJPlgfjzx+FKQ1QSyZOWe7wmoJp7vhw==", "requires": { - "@babel/helper-create-class-features-plugin": "^7.17.6", - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-class-static-block": "^7.14.5" } }, "@babel/plugin-proposal-dynamic-import": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.16.7.tgz", - "integrity": "sha512-I8SW9Ho3/8DRSdmDdH3gORdyUuYnk1m4cMxUAdu5oy4n3OfN8flDEH+d60iG7dUfi0KkYwSvoalHzzdRzpWHTg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz", + "integrity": "sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-dynamic-import": "^7.8.3" } }, "@babel/plugin-proposal-export-namespace-from": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.16.7.tgz", - "integrity": "sha512-ZxdtqDXLRGBL64ocZcs7ovt71L3jhC1RGSyR996svrCi3PYqHNkb3SwPJCs8RIzD86s+WPpt2S73+EHCGO+NUA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz", + "integrity": "sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.9", "@babel/plugin-syntax-export-namespace-from": "^7.8.3" } }, "@babel/plugin-proposal-json-strings": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.16.7.tgz", - "integrity": "sha512-lNZ3EEggsGY78JavgbHsK9u5P3pQaW7k4axlgFLYkMd7UBsiNahCITShLjNQschPyjtO6dADrL24757IdhBrsQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz", + "integrity": "sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-json-strings": "^7.8.3" } }, "@babel/plugin-proposal-logical-assignment-operators": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.16.7.tgz", - "integrity": "sha512-K3XzyZJGQCr00+EtYtrDjmwX7o7PLK6U9bi1nCwkQioRFVUv6dJoxbQjtWVtP+bCPy82bONBKG8NPyQ4+i6yjg==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.18.9.tgz", + "integrity": "sha512-128YbMpjCrP35IOExw2Fq+x55LMP42DzhOhX2aNNIdI9avSWl2PI0yuBWarr3RYpZBSPtabfadkH2yeRiMD61Q==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.9", "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" } }, "@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.16.7.tgz", - "integrity": "sha512-aUOrYU3EVtjf62jQrCj63pYZ7k6vns2h/DQvHPWGmsJRYzWXZ6/AsfgpiRy6XiuIDADhJzP2Q9MwSMKauBQ+UQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", + "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" } }, "@babel/plugin-proposal-numeric-separator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.16.7.tgz", - "integrity": "sha512-vQgPMknOIgiuVqbokToyXbkY/OmmjAzr/0lhSIbG/KmnzXPGwW/AdhdKpi+O4X/VkWiWjnkKOBiqJrTaC98VKw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz", + "integrity": "sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-numeric-separator": "^7.10.4" } }, "@babel/plugin-proposal-object-rest-spread": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.17.3.tgz", - "integrity": "sha512-yuL5iQA/TbZn+RGAfxQXfi7CNLmKi1f8zInn4IgobuCWcAb7i+zj4TYzQ9l8cEzVyJ89PDGuqxK1xZpUDISesw==", - "dev": true, + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.19.4.tgz", + "integrity": "sha512-wHmj6LDxVDnL+3WhXteUBaoM1aVILZODAUjg11kHqG4cOlfgMQGxw6aCgvrXrmaJR3Bn14oZhImyCPZzRpC93Q==", "requires": { - "@babel/compat-data": "^7.17.0", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/compat-data": "^7.19.4", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-plugin-utils": "^7.19.0", "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.16.7" + "@babel/plugin-transform-parameters": "^7.18.8" } }, "@babel/plugin-proposal-optional-catch-binding": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.16.7.tgz", - "integrity": "sha512-eMOH/L4OvWSZAE1VkHbr1vckLG1WUcHGJSLqqQwl2GaUqG6QjddvrOaTUMNYiv77H5IKPMZ9U9P7EaHwvAShfA==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz", + "integrity": "sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" } }, "@babel/plugin-proposal-optional-chaining": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.16.7.tgz", - "integrity": "sha512-eC3xy+ZrUcBtP7x+sq62Q/HYd674pPTb/77XZMb5wbDPGWIdUbSr4Agr052+zaUPSb+gGRnjxXfKFvx5iMJ+DA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.18.9.tgz", + "integrity": "sha512-v5nwt4IqBXihxGsW2QmCWMDS3B3bzGIk/EQVZz2ei7f3NJl8NzAJVvUmpDW5q1CRNY+Beb/k58UAH1Km1N411w==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0", + "@babel/helper-plugin-utils": "^7.18.9", + "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9", "@babel/plugin-syntax-optional-chaining": "^7.8.3" } }, "@babel/plugin-proposal-private-methods": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.16.11.tgz", - "integrity": "sha512-F/2uAkPlXDr8+BHpZvo19w3hLFKge+k75XUprE6jaqKxjGkSYcK+4c+bup5PdW/7W/Rpjwql7FTVEDW+fRAQsw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz", + "integrity": "sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA==", "requires": { - "@babel/helper-create-class-features-plugin": "^7.16.10", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-proposal-private-property-in-object": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.16.7.tgz", - "integrity": "sha512-rMQkjcOFbm+ufe3bTZLyOfsOUOxyvLXZJCTARhJr+8UMSoZmqTe1K1BgkFcrW37rAchWg57yI69ORxiWvUINuQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.18.6.tgz", + "integrity": "sha512-9Rysx7FOctvT5ouj5JODjAFAkgGoudQuLPamZb0v1TGLpapdNaftzifU8NTWQm0IRjqoYypdrSmyWgkocDQ8Dw==", "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-create-class-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6", "@babel/plugin-syntax-private-property-in-object": "^7.14.5" } }, "@babel/plugin-proposal-unicode-property-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.16.7.tgz", - "integrity": "sha512-QRK0YI/40VLhNVGIjRNAAQkEHws0cswSdFFjpFyt943YmJIU1da9uW63Iu6NFV6CxTZW5eTDCrwZUstBWgp/Rg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz", + "integrity": "sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w==", "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-syntax-async-generators": { "version": "7.8.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24191,7 +25787,6 @@ "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.12.13" } @@ -24200,7 +25795,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.14.5" } @@ -24209,7 +25803,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24218,16 +25811,22 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.3" } }, + "@babel/plugin-syntax-import-assertions": { + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz", + "integrity": "sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ==", + "requires": { + "@babel/helper-plugin-utils": "^7.19.0" + } + }, "@babel/plugin-syntax-json-strings": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24236,7 +25835,6 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.10.4" } @@ -24245,7 +25843,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24254,7 +25851,6 @@ "version": "7.10.4", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.10.4" } @@ -24263,7 +25859,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24272,7 +25867,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24281,7 +25875,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.8.0" } @@ -24290,7 +25883,6 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.14.5" } @@ -24299,357 +25891,337 @@ "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.14.5" } }, "@babel/plugin-transform-arrow-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.16.7.tgz", - "integrity": "sha512-9ffkFFMbvzTvv+7dTp/66xvZAWASuPD5Tl9LK3Z9vhOmANo6j94rik+5YMBt4CwHVMWLWpMsriIc2zsa3WW3xQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.18.6.tgz", + "integrity": "sha512-9S9X9RUefzrsHZmKMbDXxweEH+YlE8JJEuat9FdvW9Qh1cw7W64jELCtWNkPBPX5En45uy28KGvA/AySqUh8CQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-async-to-generator": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.8.tgz", - "integrity": "sha512-MtmUmTJQHCnyJVrScNzNlofQJ3dLFuobYn3mwOTKHnSCMtbNsqvF71GQmJfFjdrXSsAA7iysFmYWw4bXZ20hOg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.18.6.tgz", + "integrity": "sha512-ARE5wZLKnTgPW7/1ftQmSi1CmkqqHo2DNmtztFhvgtOWSDfq0Cq9/9L+KnZNYSNrydBekhW3rwShduf59RoXag==", "requires": { - "@babel/helper-module-imports": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-remap-async-to-generator": "^7.16.8" + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/helper-remap-async-to-generator": "^7.18.6" } }, "@babel/plugin-transform-block-scoped-functions": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.16.7.tgz", - "integrity": "sha512-JUuzlzmF40Z9cXyytcbZEZKckgrQzChbQJw/5PuEHYeqzCsvebDx0K0jWnIIVcmmDOAVctCgnYs0pMcrYj2zJg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz", + "integrity": "sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-block-scoping": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.16.7.tgz", - "integrity": "sha512-ObZev2nxVAYA4bhyusELdo9hb3H+A56bxH3FZMbEImZFiEDYVHXQSJ1hQKFlDnlt8G9bBrCZ5ZpURZUrV4G5qQ==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.20.0.tgz", + "integrity": "sha512-sXOohbpHZSk7GjxK9b3dKB7CfqUD5DwOH+DggKzOQ7TXYP+RCSbRykfjQmn/zq+rBjycVRtLf9pYhAaEJA786w==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.19.0" } }, "@babel/plugin-transform-classes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.16.7.tgz", - "integrity": "sha512-WY7og38SFAGYRe64BrjKf8OrE6ulEHtr5jEYaZMwox9KebgqPi67Zqz8K53EKk1fFEJgm96r32rkKZ3qA2nCWQ==", - "dev": true, - "requires": { - "@babel/helper-annotate-as-pure": "^7.16.7", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-optimise-call-expression": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.19.0.tgz", + "integrity": "sha512-YfeEE9kCjqTS9IitkgfJuxjcEtLUHMqa8yUJ6zdz8vR7hKuo6mOy2C05P0F1tdMmDCeuyidKnlrw/iTppHcr2A==", + "requires": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-compilation-targets": "^7.19.0", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-optimise-call-expression": "^7.18.6", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-replace-supers": "^7.18.9", + "@babel/helper-split-export-declaration": "^7.18.6", "globals": "^11.1.0" } }, "@babel/plugin-transform-computed-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.16.7.tgz", - "integrity": "sha512-gN72G9bcmenVILj//sv1zLNaPyYcOzUho2lIJBMh/iakJ9ygCo/hEF9cpGb61SCMEDxbbyBoVQxrt+bWKu5KGw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.18.9.tgz", + "integrity": "sha512-+i0ZU1bCDymKakLxn5srGHrsAPRELC2WIbzwjLhHW9SIE1cPYkLCL0NlnXMZaM1vhfgA2+M7hySk42VBvrkBRw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-destructuring": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.17.3.tgz", - "integrity": "sha512-dDFzegDYKlPqa72xIlbmSkly5MluLoaC1JswABGktyt6NTXSBcUuse/kWE/wvKFWJHPETpi158qJZFS3JmykJg==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.20.0.tgz", + "integrity": "sha512-1dIhvZfkDVx/zn2S1aFwlruspTt4189j7fEkH0Y0VyuDM6bQt7bD6kLcz3l4IlLG+e5OReaBz9ROAbttRtUHqA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.19.0" } }, "@babel/plugin-transform-dotall-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.16.7.tgz", - "integrity": "sha512-Lyttaao2SjZF6Pf4vk1dVKv8YypMpomAbygW+mU5cYP3S5cWTfCJjG8xV6CFdzGFlfWK81IjL9viiTvpb6G7gQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz", + "integrity": "sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg==", "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-duplicate-keys": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.16.7.tgz", - "integrity": "sha512-03DvpbRfvWIXyK0/6QiR1KMTWeT6OcQ7tbhjrXyFS02kjuX/mu5Bvnh5SDSWHxyawit2g5aWhKwI86EE7GUnTw==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz", + "integrity": "sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-exponentiation-operator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.16.7.tgz", - "integrity": "sha512-8UYLSlyLgRixQvlYH3J2ekXFHDFLQutdy7FfFAMm3CPZ6q9wHCwnUyiXpQCe3gVVnQlHc5nsuiEVziteRNTXEA==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz", + "integrity": "sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw==", "requires": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-builder-binary-assignment-operator-visitor": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-for-of": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.16.7.tgz", - "integrity": "sha512-/QZm9W92Ptpw7sjI9Nx1mbcsWz33+l8kuMIQnDwgQBG5s3fAfQvkRjQ7NqXhtNcKOnPkdICmUHyCaWW06HCsqg==", - "dev": true, + "version": "7.18.8", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.18.8.tgz", + "integrity": "sha512-yEfTRnjuskWYo0k1mHUqrVWaZwrdq8AYbfrpqULOJOaucGSp4mNMVps+YtA8byoevxS/urwU75vyhQIxcCgiBQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-function-name": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.16.7.tgz", - "integrity": "sha512-SU/C68YVwTRxqWj5kgsbKINakGag0KTgq9f2iZEXdStoAbOzLHEBRYzImmA6yFo8YZhJVflvXmIHUO7GWHmxxA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz", + "integrity": "sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ==", "requires": { - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-compilation-targets": "^7.18.9", + "@babel/helper-function-name": "^7.18.9", + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.16.7.tgz", - "integrity": "sha512-6tH8RTpTWI0s2sV6uq3e/C9wPo4PTqqZps4uF0kzQ9/xPLFQtipynvmT1g/dOfEJ+0EQsHhkQ/zyRId8J2b8zQ==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz", + "integrity": "sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-member-expression-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.16.7.tgz", - "integrity": "sha512-mBruRMbktKQwbxaJof32LT9KLy2f3gH+27a5XSuXo6h7R3vqltl0PgZ80C8ZMKw98Bf8bqt6BEVi3svOh2PzMw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz", + "integrity": "sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-modules-amd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.16.7.tgz", - "integrity": "sha512-KaaEtgBL7FKYwjJ/teH63oAmE3lP34N3kshz8mm4VMAw7U3PxjVwwUmxEFksbgsNUaO3wId9R2AVQYSEGRa2+g==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.19.6.tgz", + "integrity": "sha512-uG3od2mXvAtIFQIh0xrpLH6r5fpSQN04gIVovl+ODLdUMANokxQLZnPBHcjmv3GxRjnqwLuHvppjjcelqUFZvg==", "requires": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helper-plugin-utils": "^7.19.0" } }, "@babel/plugin-transform-modules-commonjs": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.16.8.tgz", - "integrity": "sha512-oflKPvsLT2+uKQopesJt3ApiaIS2HW+hzHFcwRNtyDGieAeC/dIHZX8buJQ2J2X1rxGPy4eRcUijm3qcSPjYcA==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.19.6.tgz", + "integrity": "sha512-8PIa1ym4XRTKuSsOUXqDG0YaOlEuTVvHMe5JCfgBMOtHvJKw/4NGovEGN33viISshG/rZNVrACiBmPQLvWN8xQ==", "requires": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-simple-access": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-simple-access": "^7.19.4" } }, "@babel/plugin-transform-modules-systemjs": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.16.7.tgz", - "integrity": "sha512-DuK5E3k+QQmnOqBR9UkusByy5WZWGRxfzV529s9nPra1GE7olmxfqO2FHobEOYSPIjPBTr4p66YDcjQnt8cBmw==", - "dev": true, + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.19.6.tgz", + "integrity": "sha512-fqGLBepcc3kErfR9R3DnVpURmckXP7gj7bAlrTQyBxrigFqszZCkFkcoxzCp2v32XmwXLvbw+8Yq9/b+QqksjQ==", "requires": { - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-identifier": "^7.16.7", - "babel-plugin-dynamic-import-node": "^2.3.3" + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-module-transforms": "^7.19.6", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-validator-identifier": "^7.19.1" } }, "@babel/plugin-transform-modules-umd": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.16.7.tgz", - "integrity": "sha512-EMh7uolsC8O4xhudF2F6wedbSHm1HHZ0C6aJ7K67zcDNidMzVcxWdGr+htW9n21klm+bOn+Rx4CBsAntZd3rEQ==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz", + "integrity": "sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ==", "requires": { - "@babel/helper-module-transforms": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-module-transforms": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.16.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz", - "integrity": "sha512-j3Jw+n5PvpmhRR+mrgIh04puSANCk/T/UA3m3P1MjJkhlK906+ApHhDIqBQDdOgL/r1UYpz4GNclTXxyZrYGSw==", - "dev": true, + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.19.1.tgz", + "integrity": "sha512-oWk9l9WItWBQYS4FgXD4Uyy5kq898lvkXpXQxoJEY1RnvPk4R/Dvu2ebXU9q8lP+rlMwUQTFf2Ok6d78ODa0kw==", "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.19.0", + "@babel/helper-plugin-utils": "^7.19.0" } }, "@babel/plugin-transform-new-target": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.16.7.tgz", - "integrity": "sha512-xiLDzWNMfKoGOpc6t3U+etCE2yRnn3SM09BXqWPIZOBpL2gvVrBWUKnsJx0K/ADi5F5YC5f8APFfWrz25TdlGg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz", + "integrity": "sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-object-super": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.16.7.tgz", - "integrity": "sha512-14J1feiQVWaGvRxj2WjyMuXS2jsBkgB3MdSN5HuC2G5nRspa5RK9COcs82Pwy5BuGcjb+fYaUj94mYcOj7rCvw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz", + "integrity": "sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-replace-supers": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6", + "@babel/helper-replace-supers": "^7.18.6" } }, "@babel/plugin-transform-parameters": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.16.7.tgz", - "integrity": "sha512-AT3MufQ7zZEhU2hwOA11axBnExW0Lszu4RL/tAlUJBuNoRak+wehQW8h6KcXOcgjY42fHtDxswuMhMjFEuv/aw==", - "dev": true, + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.20.1.tgz", + "integrity": "sha512-nDvKLrAvl+kf6BOy1UJ3MGwzzfTMgppxwiD2Jb4LO3xjYyZq30oQzDNJbCQpMdG9+j2IXHoiMrw5Cm/L6ZoxXQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.19.0" } }, "@babel/plugin-transform-property-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.16.7.tgz", - "integrity": "sha512-z4FGr9NMGdoIl1RqavCqGG+ZuYjfZ/hkCIeuH6Do7tXmSm0ls11nYVSJqFEUOSJbDab5wC6lRE/w6YjVcr6Hqw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz", + "integrity": "sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-regenerator": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.16.7.tgz", - "integrity": "sha512-mF7jOgGYCkSJagJ6XCujSQg+6xC1M77/03K2oBmVJWoFGNUtnVJO4WHKJk3dnPC8HCcj4xBQP1Egm8DWh3Pb3Q==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.18.6.tgz", + "integrity": "sha512-poqRI2+qiSdeldcz4wTSTXBRryoq3Gc70ye7m7UD5Ww0nE29IXqMl6r7Nd15WBgRd74vloEMlShtH6CKxVzfmQ==", "requires": { - "regenerator-transform": "^0.14.2" + "@babel/helper-plugin-utils": "^7.18.6", + "regenerator-transform": "^0.15.0" } }, "@babel/plugin-transform-reserved-words": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.16.7.tgz", - "integrity": "sha512-KQzzDnZ9hWQBjwi5lpY5v9shmm6IVG0U9pB18zvMu2i4H90xpT4gmqwPYsn8rObiadYe2M0gmgsiOIF5A/2rtg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz", + "integrity": "sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" + } + }, + "@babel/plugin-transform-runtime": { + "version": "7.19.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.19.6.tgz", + "integrity": "sha512-PRH37lz4JU156lYFW1p8OxE5i7d6Sl/zV58ooyr+q1J1lnQPyg5tIiXlIwNVhJaY4W3TmOtdc8jqdXQcB1v5Yw==", + "requires": { + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-plugin-utils": "^7.19.0", + "babel-plugin-polyfill-corejs2": "^0.3.3", + "babel-plugin-polyfill-corejs3": "^0.6.0", + "babel-plugin-polyfill-regenerator": "^0.4.1", + "semver": "^6.3.0" } }, "@babel/plugin-transform-shorthand-properties": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", - "integrity": "sha512-hah2+FEnoRoATdIb05IOXf+4GzXYTq75TVhIn1PewihbpyrNWUt2JbudKQOETWw6QpLe+AIUpJ5MVLYTQbeeUg==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz", + "integrity": "sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-spread": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.16.7.tgz", - "integrity": "sha512-+pjJpgAngb53L0iaA5gU/1MLXJIfXcYepLgXB3esVRf4fqmj8f2cxM3/FKaHsZms08hFQJkFccEWuIpm429TXg==", - "dev": true, + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.19.0.tgz", + "integrity": "sha512-RsuMk7j6n+r752EtzyScnWkQyuJdli6LdO5Klv8Yx0OfPVTcQkIUfS8clx5e9yHXzlnhOZF3CbQ8C2uP5j074w==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.16.0" + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-skip-transparent-expression-wrappers": "^7.18.9" } }, "@babel/plugin-transform-sticky-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.16.7.tgz", - "integrity": "sha512-NJa0Bd/87QV5NZZzTuZG5BPJjLYadeSZ9fO6oOUoL4iQx+9EEuw/eEM92SrsT19Yc2jgB1u1hsjqDtH02c3Drw==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz", + "integrity": "sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/plugin-transform-template-literals": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.16.7.tgz", - "integrity": "sha512-VwbkDDUeenlIjmfNeDX/V0aWrQH2QiVyJtwymVQSzItFDTpxfyJh3EVaQiS0rIN/CqbLGr0VcGmuwyTdZtdIsA==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz", + "integrity": "sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-typeof-symbol": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.16.7.tgz", - "integrity": "sha512-p2rOixCKRJzpg9JB4gjnG4gjWkWa89ZoYUnl9snJ1cWIcTH/hvxZqfO+WjG6T8DRBpctEol5jw1O5rA8gkCokQ==", - "dev": true, + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz", + "integrity": "sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-unicode-escapes": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.16.7.tgz", - "integrity": "sha512-TAV5IGahIz3yZ9/Hfv35TV2xEm+kaBDaZQCn2S/hG9/CZ0DktxJv9eKfPc7yYCvOYR4JGx1h8C+jcSOvgaaI/Q==", - "dev": true, + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz", + "integrity": "sha512-kKAdAI+YzPgGY/ftStBFXTI1LZFju38rYThnfMykS+IXy8BVx+res7s2fxf1l8I35DV2T97ezo6+SGrXz6B3iQ==", "requires": { - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-plugin-utils": "^7.18.9" } }, "@babel/plugin-transform-unicode-regex": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.16.7.tgz", - "integrity": "sha512-oC5tYYKw56HO75KZVLQ+R/Nl3Hro9kf8iG0hXoaHP7tjAyCpvqBiSNe6vGrZni1Z6MggmUOC6A7VP7AVmw225Q==", - "dev": true, + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz", + "integrity": "sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA==", "requires": { - "@babel/helper-create-regexp-features-plugin": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7" + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" } }, "@babel/preset-env": { - "version": "7.16.11", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.16.11.tgz", - "integrity": "sha512-qcmWG8R7ZW6WBRPZK//y+E3Cli151B20W1Rv7ln27vuPaXU/8TKms6jFdiJtF7UDTxcrb7mZd88tAeK9LjdT8g==", - "dev": true, - "requires": { - "@babel/compat-data": "^7.16.8", - "@babel/helper-compilation-targets": "^7.16.7", - "@babel/helper-plugin-utils": "^7.16.7", - "@babel/helper-validator-option": "^7.16.7", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.16.7", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-async-generator-functions": "^7.16.8", - "@babel/plugin-proposal-class-properties": "^7.16.7", - "@babel/plugin-proposal-class-static-block": "^7.16.7", - "@babel/plugin-proposal-dynamic-import": "^7.16.7", - "@babel/plugin-proposal-export-namespace-from": "^7.16.7", - "@babel/plugin-proposal-json-strings": "^7.16.7", - "@babel/plugin-proposal-logical-assignment-operators": "^7.16.7", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", - "@babel/plugin-proposal-numeric-separator": "^7.16.7", - "@babel/plugin-proposal-object-rest-spread": "^7.16.7", - "@babel/plugin-proposal-optional-catch-binding": "^7.16.7", - "@babel/plugin-proposal-optional-chaining": "^7.16.7", - "@babel/plugin-proposal-private-methods": "^7.16.11", - "@babel/plugin-proposal-private-property-in-object": "^7.16.7", - "@babel/plugin-proposal-unicode-property-regex": "^7.16.7", + "version": "7.19.4", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.19.4.tgz", + "integrity": "sha512-5QVOTXUdqTCjQuh2GGtdd7YEhoRXBMVGROAtsBeLGIbIz3obCBIfRMT1I3ZKkMgNzwkyCkftDXSSkHxnfVf4qg==", + "requires": { + "@babel/compat-data": "^7.19.4", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-plugin-utils": "^7.19.0", + "@babel/helper-validator-option": "^7.18.6", + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-async-generator-functions": "^7.19.1", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-class-static-block": "^7.18.6", + "@babel/plugin-proposal-dynamic-import": "^7.18.6", + "@babel/plugin-proposal-export-namespace-from": "^7.18.9", + "@babel/plugin-proposal-json-strings": "^7.18.6", + "@babel/plugin-proposal-logical-assignment-operators": "^7.18.9", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", + "@babel/plugin-proposal-numeric-separator": "^7.18.6", + "@babel/plugin-proposal-object-rest-spread": "^7.19.4", + "@babel/plugin-proposal-optional-catch-binding": "^7.18.6", + "@babel/plugin-proposal-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-private-methods": "^7.18.6", + "@babel/plugin-proposal-private-property-in-object": "^7.18.6", + "@babel/plugin-proposal-unicode-property-regex": "^7.18.6", "@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-class-properties": "^7.12.13", "@babel/plugin-syntax-class-static-block": "^7.14.5", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-import-assertions": "^7.18.6", "@babel/plugin-syntax-json-strings": "^7.8.3", "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", @@ -24659,44 +26231,44 @@ "@babel/plugin-syntax-optional-chaining": "^7.8.3", "@babel/plugin-syntax-private-property-in-object": "^7.14.5", "@babel/plugin-syntax-top-level-await": "^7.14.5", - "@babel/plugin-transform-arrow-functions": "^7.16.7", - "@babel/plugin-transform-async-to-generator": "^7.16.8", - "@babel/plugin-transform-block-scoped-functions": "^7.16.7", - "@babel/plugin-transform-block-scoping": "^7.16.7", - "@babel/plugin-transform-classes": "^7.16.7", - "@babel/plugin-transform-computed-properties": "^7.16.7", - "@babel/plugin-transform-destructuring": "^7.16.7", - "@babel/plugin-transform-dotall-regex": "^7.16.7", - "@babel/plugin-transform-duplicate-keys": "^7.16.7", - "@babel/plugin-transform-exponentiation-operator": "^7.16.7", - "@babel/plugin-transform-for-of": "^7.16.7", - "@babel/plugin-transform-function-name": "^7.16.7", - "@babel/plugin-transform-literals": "^7.16.7", - "@babel/plugin-transform-member-expression-literals": "^7.16.7", - "@babel/plugin-transform-modules-amd": "^7.16.7", - "@babel/plugin-transform-modules-commonjs": "^7.16.8", - "@babel/plugin-transform-modules-systemjs": "^7.16.7", - "@babel/plugin-transform-modules-umd": "^7.16.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.16.8", - "@babel/plugin-transform-new-target": "^7.16.7", - "@babel/plugin-transform-object-super": "^7.16.7", - "@babel/plugin-transform-parameters": "^7.16.7", - "@babel/plugin-transform-property-literals": "^7.16.7", - "@babel/plugin-transform-regenerator": "^7.16.7", - "@babel/plugin-transform-reserved-words": "^7.16.7", - "@babel/plugin-transform-shorthand-properties": "^7.16.7", - "@babel/plugin-transform-spread": "^7.16.7", - "@babel/plugin-transform-sticky-regex": "^7.16.7", - "@babel/plugin-transform-template-literals": "^7.16.7", - "@babel/plugin-transform-typeof-symbol": "^7.16.7", - "@babel/plugin-transform-unicode-escapes": "^7.16.7", - "@babel/plugin-transform-unicode-regex": "^7.16.7", + "@babel/plugin-transform-arrow-functions": "^7.18.6", + "@babel/plugin-transform-async-to-generator": "^7.18.6", + "@babel/plugin-transform-block-scoped-functions": "^7.18.6", + "@babel/plugin-transform-block-scoping": "^7.19.4", + "@babel/plugin-transform-classes": "^7.19.0", + "@babel/plugin-transform-computed-properties": "^7.18.9", + "@babel/plugin-transform-destructuring": "^7.19.4", + "@babel/plugin-transform-dotall-regex": "^7.18.6", + "@babel/plugin-transform-duplicate-keys": "^7.18.9", + "@babel/plugin-transform-exponentiation-operator": "^7.18.6", + "@babel/plugin-transform-for-of": "^7.18.8", + "@babel/plugin-transform-function-name": "^7.18.9", + "@babel/plugin-transform-literals": "^7.18.9", + "@babel/plugin-transform-member-expression-literals": "^7.18.6", + "@babel/plugin-transform-modules-amd": "^7.18.6", + "@babel/plugin-transform-modules-commonjs": "^7.18.6", + "@babel/plugin-transform-modules-systemjs": "^7.19.0", + "@babel/plugin-transform-modules-umd": "^7.18.6", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.19.1", + "@babel/plugin-transform-new-target": "^7.18.6", + "@babel/plugin-transform-object-super": "^7.18.6", + "@babel/plugin-transform-parameters": "^7.18.8", + "@babel/plugin-transform-property-literals": "^7.18.6", + "@babel/plugin-transform-regenerator": "^7.18.6", + "@babel/plugin-transform-reserved-words": "^7.18.6", + "@babel/plugin-transform-shorthand-properties": "^7.18.6", + "@babel/plugin-transform-spread": "^7.19.0", + "@babel/plugin-transform-sticky-regex": "^7.18.6", + "@babel/plugin-transform-template-literals": "^7.18.9", + "@babel/plugin-transform-typeof-symbol": "^7.18.9", + "@babel/plugin-transform-unicode-escapes": "^7.18.10", + "@babel/plugin-transform-unicode-regex": "^7.18.6", "@babel/preset-modules": "^0.1.5", - "@babel/types": "^7.16.8", - "babel-plugin-polyfill-corejs2": "^0.3.0", - "babel-plugin-polyfill-corejs3": "^0.5.0", - "babel-plugin-polyfill-regenerator": "^0.3.0", - "core-js-compat": "^3.20.2", + "@babel/types": "^7.19.4", + "babel-plugin-polyfill-corejs2": "^0.3.3", + "babel-plugin-polyfill-corejs3": "^0.6.0", + "babel-plugin-polyfill-regenerator": "^0.4.1", + "core-js-compat": "^3.25.1", "semver": "^6.3.0" } }, @@ -24704,7 +26276,6 @@ "version": "0.1.5", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.5.tgz", "integrity": "sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA==", - "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", @@ -24714,58 +26285,57 @@ } }, "@babel/runtime": { - "version": "7.17.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.2.tgz", - "integrity": "sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.1.tgz", + "integrity": "sha512-mrzLkl6U9YLF8qpqI7TB82PESyEGjm/0Ly91jG575eVxMMlb8fYfOXFZIJ8XfLrJZQbm7dlKry2bJmXBUEkdFg==", + "requires": { + "regenerator-runtime": "^0.13.10" + } + }, + "@babel/runtime-corejs3": { + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.20.1.tgz", + "integrity": "sha512-CGulbEDcg/ND1Im7fUNRZdGXmX2MTWVVZacQi/6DiKE5HNwZ3aVTm5PV4lO8HHz0B2h8WQyvKKjbX5XgTtydsg==", "dev": true, "requires": { - "regenerator-runtime": "^0.13.4" - }, - "dependencies": { - "regenerator-runtime": { - "version": "0.13.9", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "dev": true - } + "core-js-pure": "^3.25.1", + "regenerator-runtime": "^0.13.10" } }, "@babel/template": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", - "integrity": "sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==", - "dev": true, + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", + "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/parser": "^7.16.7", - "@babel/types": "^7.16.7" + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.18.10", + "@babel/types": "^7.18.10" } }, "@babel/traverse": { - "version": "7.17.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.17.3.tgz", - "integrity": "sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "@babel/generator": "^7.17.3", - "@babel/helper-environment-visitor": "^7.16.7", - "@babel/helper-function-name": "^7.16.7", - "@babel/helper-hoist-variables": "^7.16.7", - "@babel/helper-split-export-declaration": "^7.16.7", - "@babel/parser": "^7.17.3", - "@babel/types": "^7.17.0", + "version": "7.20.1", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.20.1.tgz", + "integrity": "sha512-d3tN8fkVJwFLkHkBN479SOsw4DMZnz8cdbL/gvuDuzy3TS6Nfw80HuQqhw1pITbIruHyh7d1fMA47kWzmcUEGA==", + "requires": { + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.20.1", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.20.1", + "@babel/types": "^7.20.0", "debug": "^4.1.0", "globals": "^11.1.0" } }, "@babel/types": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.17.0.tgz", - "integrity": "sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw==", - "dev": true, + "version": "7.20.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.20.0.tgz", + "integrity": "sha512-Jlgt3H0TajCW164wkTOTzHkZb075tMQMULzrLUoUeKmO7eFL96GgDxf7/Axhc5CAuKE3KFyVW1p6ysKsi2oXAg==", "requires": { - "@babel/helper-validator-identifier": "^7.16.7", + "@babel/helper-string-parser": "^7.19.4", + "@babel/helper-validator-identifier": "^7.19.1", "to-fast-properties": "^2.0.0" } }, @@ -24805,9 +26375,9 @@ } }, "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -24883,7 +26453,7 @@ "@gulp-sourcemaps/map-sources": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@gulp-sourcemaps/map-sources/-/map-sources-1.0.0.tgz", - "integrity": "sha1-iQrnxdjId/bThIYCFazp1+yUW9o=", + "integrity": "sha512-o/EatdaGt8+x2qpb0vFLC/2Gug/xYPRXb6a+ET1wGYKozKN3krDWC/zZFZAtrzxJHuDL12mwdfEFKcKMNvc55A==", "dev": true, "requires": { "normalize-path": "^2.0.1", @@ -24893,7 +26463,7 @@ "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "requires": { "remove-trailing-separator": "^1.0.1" @@ -24911,6 +26481,30 @@ } } }, + "@hapi/boom": { + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/@hapi/boom/-/boom-9.1.4.tgz", + "integrity": "sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw==", + "dev": true, + "requires": { + "@hapi/hoek": "9.x.x" + } + }, + "@hapi/cryptiles": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@hapi/cryptiles/-/cryptiles-5.1.0.tgz", + "integrity": "sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA==", + "dev": true, + "requires": { + "@hapi/boom": "9.x.x" + } + }, + "@hapi/hoek": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", + "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==", + "dev": true + }, "@humanwhocodes/config-array": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", @@ -24928,11 +26522,18 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, - "@hutson/parse-repository-url": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@hutson/parse-repository-url/-/parse-repository-url-3.0.2.tgz", - "integrity": "sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==", - "dev": true + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + } }, "@istanbuljs/schema": { "version": "0.1.3", @@ -24941,15 +26542,15 @@ "dev": true }, "@jest/types": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-27.5.1.tgz", - "integrity": "sha512-Cx46iJ9QpwQTjIdq5VJu2QTMMs3QlEjI0x1QbBP5W1+nMzyc2XmimiRR/CbX9TO0cPTeUlxWMOu8mslYsJ8DEw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-26.6.2.tgz", + "integrity": "sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==", "dev": true, "requires": { "@types/istanbul-lib-coverage": "^2.0.0", "@types/istanbul-reports": "^3.0.0", "@types/node": "*", - "@types/yargs": "^16.0.0", + "@types/yargs": "^15.0.0", "chalk": "^4.0.0" }, "dependencies": { @@ -24987,6 +26588,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -24998,39 +26605,69 @@ } } }, + "@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "requires": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "@jridgewell/resolve-uri": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz", - "integrity": "sha512-VPeQ7+wH0itvQxnG+lIzWgkysKIr3L9sslimFW55rHMdGu/qCQ5z5h9zq4gI8uBtqkpHhsF4Z/OwExufUCThew==", - "dev": true + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==" + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==" + }, + "@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "dependencies": { + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + } + } }, "@jridgewell/sourcemap-codec": { - "version": "1.4.11", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz", - "integrity": "sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg==", - "dev": true + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "@jridgewell/trace-mapping": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz", - "integrity": "sha512-vFv9ttIedivx0ux3QSjhgtCVjPZd5l46ZOMDSCwnH1yUO2e964gO8LZGyv2QkqcgR6TnBU1v+1IFqmeoG+0UJQ==", - "dev": true, + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", + "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", "requires": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/resolve-uri": "3.1.0", + "@jridgewell/sourcemap-codec": "1.4.14" } }, - "@jsdevtools/coverage-istanbul-loader": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@jsdevtools/coverage-istanbul-loader/-/coverage-istanbul-loader-3.0.5.tgz", - "integrity": "sha512-EUCPEkaRPvmHjWAAZkWMT7JDzpw7FKB00WTISaiXsbNOd5hCHg77XLA8sLYLFDo1zepYLo2w7GstN8YBqRXZfA==", + "@nicolo-ribaudo/eslint-scope-5-internals": { + "version": "5.1.1-v1", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", + "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", "dev": true, "requires": { - "convert-source-map": "^1.7.0", - "istanbul-lib-instrument": "^4.0.3", - "loader-utils": "^2.0.0", - "merge-source-map": "^1.1.0", - "schema-utils": "^2.7.0" + "eslint-scope": "5.1.1" } }, "@polka/url": { @@ -25075,15 +26712,15 @@ } }, "@sinonjs/text-encoding": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", - "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz", + "integrity": "sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==", "dev": true }, - "@socket.io/base64-arraybuffer": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@socket.io/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz", - "integrity": "sha512-dOlCBKnDw4iShaIsH/bxujKTM18+2TOAsYz+KSc11Am38H4q5Xw8Bbz97ZYdrVNM+um3p7w86Bvvmcn9q+5+eQ==", + "@socket.io/component-emitter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", "dev": true }, "@szmarczak/http-timer": { @@ -25096,9 +26733,9 @@ } }, "@types/aria-query": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.0.tgz", - "integrity": "sha512-P+dkdFu0n08PDIvw+9nT9ByQnd+Udc8DaWPb9HKfaPwCvWvQpC5XaMRx2xLWECm9x1VKNps6vEAlirjA6+uNrQ==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.1.tgz", + "integrity": "sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==", "dev": true }, "@types/cacheable-request": { @@ -25113,12 +26750,6 @@ "@types/responselike": "*" } }, - "@types/component-emitter": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.11.tgz", - "integrity": "sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ==", - "dev": true - }, "@types/cookie": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", @@ -25126,10 +26757,22 @@ "dev": true }, "@types/cors": { - "version": "2.8.12", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz", - "integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==", - "dev": true + "version": "2.8.13", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz", + "integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/debug": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", + "integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==", + "dev": true, + "requires": { + "@types/ms": "*" + } }, "@types/diff": { "version": "5.0.2", @@ -25144,15 +26787,15 @@ "dev": true }, "@types/ejs": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.0.tgz", - "integrity": "sha512-DCg+Ka+uDQ31lJ/UtEXVlaeV3d6t81gifaVWKJy4MYVVgvJttyX/viREy+If7fz+tK/gVxTGMtyrFPnm4gjrVA==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.1.tgz", + "integrity": "sha512-RQul5wEfY7BjWm0sYY86cmUN/pcXWGyVxWX93DFFJvcrxax5zKlieLwA3T77xJGwNcZW0YW6CYG70p1m8xPFmA==", "dev": true }, "@types/eslint": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.1.tgz", - "integrity": "sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA==", + "version": "8.4.9", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.9.tgz", + "integrity": "sha512-jFCSo4wJzlHQLCpceUhUnXdrPuCNOjGFMQ8Eg6JXxlz3QaCKOb7eGi2cephQdM4XTYsNej69P9JDJ1zqNIbncQ==", "dev": true, "requires": { "@types/estree": "*", @@ -25160,9 +26803,9 @@ } }, "@types/eslint-scope": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.3.tgz", - "integrity": "sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g==", + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", + "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", "dev": true, "requires": { "@types/eslint": "*", @@ -25181,6 +26824,12 @@ "integrity": "sha512-Q5Vn3yjTDyCMV50TB6VRIbQNxSE4OmZR86VSbGaNpfUolm0iePBB4KdEEHmxoY5sT2+2DIvXW0rvMDP2nHZ4Mg==", "dev": true }, + "@types/extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/extend/-/extend-3.0.1.tgz", + "integrity": "sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==", + "dev": true + }, "@types/fibers": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@types/fibers/-/fibers-3.1.1.tgz", @@ -25196,6 +26845,21 @@ "@types/node": "*" } }, + "@types/github-slugger": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/github-slugger/-/github-slugger-1.3.0.tgz", + "integrity": "sha512-J/rMZa7RqiH/rT29TEVZO4nBoDP9XJOjnbbIofg7GQKs4JIduEO3WLpte+6WeUz/TcrXKlY+bM7FYrp8yFB+3g==", + "dev": true + }, + "@types/hast": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz", + "integrity": "sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g==", + "dev": true, + "requires": { + "@types/unist": "*" + } + }, "@types/http-cache-semantics": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz", @@ -25203,13 +26867,13 @@ "dev": true }, "@types/inquirer": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-8.2.0.tgz", - "integrity": "sha512-BNoMetRf3gmkpAlV5we+kxyZTle7YibdOntIZbU5pyIfMdcwy784KfeZDAcuyMznkh5OLa17RVXZOGA5LTlkgQ==", + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-HhxyLejTHMfohAuhRun4csWigAMjXTmRyiJTU1Y/I1xmggikFMkOUoMQRlFm+zQcPEGHSs3io/0FAmNZf8EymQ==", "dev": true, "requires": { "@types/through": "*", - "rxjs": "^7.2.0" + "rxjs": "^6.4.0" } }, "@types/istanbul-lib-coverage": { @@ -25237,54 +26901,54 @@ } }, "@types/json-schema": { - "version": "7.0.9", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, "@types/keyv": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.3.tgz", - "integrity": "sha512-FXCJgyyN3ivVgRoml4h94G/p3kY+u/B86La+QptcqJaWtBWtmc6TtkNfS40n9bIvyLteHh7zXOtgbobORKPbDg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-4.2.0.tgz", + "integrity": "sha512-xoBtGl5R9jeKUhc8ZqeYaRDx04qqJ10yhhXYGmJ4Jr8qKpvMsDQQrNUvF/wUJ4klOtmJeJM+p2Xo3zp9uaC3tw==", "dev": true, "requires": { - "@types/node": "*" + "keyv": "*" } }, "@types/lodash": { - "version": "4.14.179", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.179.tgz", - "integrity": "sha512-uwc1x90yCKqGcIOAT6DwOSuxnrAbpkdPsUOZtwrXb4D/6wZs+6qG7QnIawDuZWg0sWpxl+ltIKCaLoMlna678w==", + "version": "4.14.187", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.187.tgz", + "integrity": "sha512-MrO/xLXCaUgZy3y96C/iOsaIqZSeupyTImKClHunL5GrmaiII2VwvWmLBu2hwa0Kp0sV19CsyjtrTc/Fx8rg/A==", "dev": true }, "@types/lodash.flattendeep": { - "version": "4.4.6", - "resolved": "https://registry.npmjs.org/@types/lodash.flattendeep/-/lodash.flattendeep-4.4.6.tgz", - "integrity": "sha512-uLm2MaRVlqJSGsMK0RZpP5T3KqReq+9WbYDHCUhBhp98v56hMG/Yht52bsoTSui9xz2mUvQ9NfG3LrNGDL92Ng==", + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/lodash.flattendeep/-/lodash.flattendeep-4.4.7.tgz", + "integrity": "sha512-1h6GW/AeZw/Wej6uxrqgmdTDZX1yFS39lRsXYkg+3kWvOWWrlGCI6H7lXxlUHOzxDT4QeYGmgPpQ3BX9XevzOg==", "dev": true, "requires": { "@types/lodash": "*" } }, "@types/lodash.pickby": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/@types/lodash.pickby/-/lodash.pickby-4.6.6.tgz", - "integrity": "sha512-NFa13XxlMd9eFi0UFZFWIztpMpXhozbijrx3Yb1viYZphT7jyopIFVoIRF4eYMjruWNEG1rnyrRmg/8ej9T8Iw==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/@types/lodash.pickby/-/lodash.pickby-4.6.7.tgz", + "integrity": "sha512-4ebXRusuLflfscbD0PUX4eVknDHD9Yf+uMtBIvA/hrnTqeAzbuHuDjvnYriLjUrI9YrhCPVKUf4wkRSXJQ6gig==", "dev": true, "requires": { "@types/lodash": "*" } }, "@types/lodash.union": { - "version": "4.6.6", - "resolved": "https://registry.npmjs.org/@types/lodash.union/-/lodash.union-4.6.6.tgz", - "integrity": "sha512-Wu0ZEVNcyCz8eAn6TlUbYWZoGbH9E+iOHxAZbwUoCEXdUiy6qpcz5o44mMXViM4vlPLLCPlkAubEP1gokoSZaw==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/@types/lodash.union/-/lodash.union-4.6.7.tgz", + "integrity": "sha512-6HXM6tsnHJzKgJE0gA/LhTGf/7AbjUk759WZ1MziVm+OBNAATHhdgj+a3KVE8g76GCLAnN4ZEQQG1EGgtBIABA==", "dev": true, "requires": { "@types/lodash": "*" @@ -25299,22 +26963,22 @@ "@types/unist": "*" } }, - "@types/minimist": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", - "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", + "@types/mocha": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", + "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", "dev": true }, - "@types/mocha": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz", - "integrity": "sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg==", + "@types/ms": { + "version": "0.7.31", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", + "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==", "dev": true }, "@types/node": { - "version": "17.0.21", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.21.tgz", - "integrity": "sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==", + "version": "17.0.45", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.45.tgz", + "integrity": "sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==", "dev": true }, "@types/normalize-package-data": { @@ -25330,18 +26994,18 @@ "dev": true }, "@types/puppeteer": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-5.4.5.tgz", - "integrity": "sha512-lxCjpDEY+DZ66+W3x5Af4oHnEmUXt0HuaRzkBGE2UZiZEp/V1d3StpLPlmNVu/ea091bdNmVPl44lu8Wy/0ZCA==", + "version": "5.4.7", + "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-5.4.7.tgz", + "integrity": "sha512-JdGWZZYL0vKapXF4oQTC5hLVNfOgdPrqeZ1BiQnGk5cB7HeE91EWUiTdVSdQPobRN8rIcdffjiOgCYJ/S8QrnQ==", "dev": true, "requires": { "@types/node": "*" } }, "@types/recursive-readdir": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.0.tgz", - "integrity": "sha512-HGk753KRu2N4mWduovY4BLjYq4jTOL29gV2OfGdGxHcPSWGFkC5RRIdk+VTs5XmYd7MVAD+JwKrcb5+5Y7FOCg==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/recursive-readdir/-/recursive-readdir-2.2.1.tgz", + "integrity": "sha512-Xd+Ptc4/F2ueInqy5yK2FI5FxtwwbX2+VZpcg+9oYsFJVen8qQKGapCr+Bi5wQtHU1cTXT8s+07lo/nKPgu8Gg==", "dev": true, "requires": { "@types/node": "*" @@ -25421,9 +27085,9 @@ "dev": true }, "@types/yargs": { - "version": "16.0.4", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-16.0.4.tgz", - "integrity": "sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw==", + "version": "15.0.14", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.14.tgz", + "integrity": "sha512-yEJzHoxf6SyQGhBhIYGXQDSCkJjB6HohDShto7m8vaKg9Yp0Yn8+71J9eakh2bnPg6BfsH9PRMhiRTZnd4eXGQ==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -25436,9 +27100,9 @@ "dev": true }, "@types/yauzl": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.2.tgz", - "integrity": "sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==", + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==", "dev": true, "optional": true, "requires": { @@ -25451,15 +27115,53 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "@videojs/http-streaming": { + "version": "2.14.3", + "resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-2.14.3.tgz", + "integrity": "sha512-2tFwxCaNbcEZzQugWf8EERwNMyNtspfHnvxRGRABQs09W/5SqmkWFuGWfUAm4wQKlXGfdPyAJ1338ASl459xAA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "3.0.5", + "aes-decrypter": "3.1.3", + "global": "^4.4.0", + "m3u8-parser": "4.7.1", + "mpd-parser": "0.21.1", + "mux.js": "6.0.1", + "video.js": "^6 || ^7" + } + }, + "@videojs/vhs-utils": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@videojs/vhs-utils/-/vhs-utils-3.0.5.tgz", + "integrity": "sha512-PKVgdo8/GReqdx512F+ombhS+Bzogiofy1LgAj4tN8PfdBx3HSS7V5WfJotKTqtOWGwVfSWsrYN/t09/DSryrw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "global": "^4.4.0", + "url-toolkit": "^2.2.1" + } + }, + "@videojs/xhr": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@videojs/xhr/-/xhr-2.6.0.tgz", + "integrity": "sha512-7J361GiN1tXpm+gd0xz2QWr3xNWBE+rytvo8J3KuggFaLg+U37gZQ2BuPLcnkfGffy2e+ozY70RHC8jt7zjA6Q==", + "dev": true, + "requires": { + "@babel/runtime": "^7.5.5", + "global": "~4.4.0", + "is-function": "^1.0.1" + } + }, "@vue/compiler-core": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.31.tgz", - "integrity": "sha512-aKno00qoA4o+V/kR6i/pE+aP+esng5siNAVQ422TkBNM6qA4veXiZbSe8OTXHXquEi/f6Akc+nLfB4JGfe4/WQ==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.41.tgz", + "integrity": "sha512-oA4mH6SA78DT+96/nsi4p9DX97PHcNROxs51lYk7gb9Z4BPKQ3Mh+BLn6CQZBw857Iuhu28BfMSRHAlPvD4vlw==", "dev": true, "optional": true, "requires": { "@babel/parser": "^7.16.4", - "@vue/shared": "3.2.31", + "@vue/shared": "3.2.41", "estree-walker": "^2.0.2", "source-map": "^0.6.1" }, @@ -25474,29 +27176,29 @@ } }, "@vue/compiler-dom": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.31.tgz", - "integrity": "sha512-60zIlFfzIDf3u91cqfqy9KhCKIJgPeqxgveH2L+87RcGU/alT6BRrk5JtUso0OibH3O7NXuNOQ0cDc9beT0wrg==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.41.tgz", + "integrity": "sha512-xe5TbbIsonjENxJsYRbDJvthzqxLNk+tb3d/c47zgREDa/PCp6/Y4gC/skM4H6PIuX5DAxm7fFJdbjjUH2QTMw==", "dev": true, "optional": true, "requires": { - "@vue/compiler-core": "3.2.31", - "@vue/shared": "3.2.31" + "@vue/compiler-core": "3.2.41", + "@vue/shared": "3.2.41" } }, "@vue/compiler-sfc": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.31.tgz", - "integrity": "sha512-748adc9msSPGzXgibHiO6T7RWgfnDcVQD+VVwYgSsyyY8Ans64tALHZANrKtOzvkwznV/F4H7OAod/jIlp/dkQ==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.41.tgz", + "integrity": "sha512-+1P2m5kxOeaxVmJNXnBskAn3BenbTmbxBxWOtBq3mQTCokIreuMULFantBUclP0+KnzNCMOvcnKinqQZmiOF8w==", "dev": true, "optional": true, "requires": { "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.31", - "@vue/compiler-dom": "3.2.31", - "@vue/compiler-ssr": "3.2.31", - "@vue/reactivity-transform": "3.2.31", - "@vue/shared": "3.2.31", + "@vue/compiler-core": "3.2.41", + "@vue/compiler-dom": "3.2.41", + "@vue/compiler-ssr": "3.2.41", + "@vue/reactivity-transform": "3.2.41", + "@vue/shared": "3.2.41", "estree-walker": "^2.0.2", "magic-string": "^0.25.7", "postcss": "^8.1.10", @@ -25513,34 +27215,34 @@ } }, "@vue/compiler-ssr": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.31.tgz", - "integrity": "sha512-mjN0rqig+A8TVDnsGPYJM5dpbjlXeHUm2oZHZwGyMYiGT/F4fhJf/cXy8QpjnLQK4Y9Et4GWzHn9PS8AHUnSkw==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.41.tgz", + "integrity": "sha512-Y5wPiNIiaMz/sps8+DmhaKfDm1xgj6GrH99z4gq2LQenfVQcYXmHIOBcs5qPwl7jaW3SUQWjkAPKMfQemEQZwQ==", "dev": true, "optional": true, "requires": { - "@vue/compiler-dom": "3.2.31", - "@vue/shared": "3.2.31" + "@vue/compiler-dom": "3.2.41", + "@vue/shared": "3.2.41" } }, "@vue/reactivity-transform": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.2.31.tgz", - "integrity": "sha512-uS4l4z/W7wXdI+Va5pgVxBJ345wyGFKvpPYtdSgvfJfX/x2Ymm6ophQlXXB6acqGHtXuBqNyyO3zVp9b1r0MOA==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.2.41.tgz", + "integrity": "sha512-mK5+BNMsL4hHi+IR3Ft/ho6Za+L3FA5j8WvreJ7XzHrqkPq8jtF/SMo7tuc9gHjLDwKZX1nP1JQOKo9IEAn54A==", "dev": true, "optional": true, "requires": { "@babel/parser": "^7.16.4", - "@vue/compiler-core": "3.2.31", - "@vue/shared": "3.2.31", + "@vue/compiler-core": "3.2.41", + "@vue/shared": "3.2.41", "estree-walker": "^2.0.2", "magic-string": "^0.25.7" } }, "@vue/shared": { - "version": "3.2.31", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.31.tgz", - "integrity": "sha512-ymN2pj6zEjiKJZbrf98UM2pfDd6F2H7ksKw7NDt/ZZ1fh5Ei39X5tABugtT03ZRlWd9imccoK0hE8hpjpU7irQ==", + "version": "3.2.41", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.41.tgz", + "integrity": "sha512-W9mfWLHmJhkfAmV+7gDjcHeAWALQtgGT3JErxULl0oz6R6+3ug91I7IErs93eCFhPCZPHBs4QJS7YWEV7A3sxw==", "dev": true, "optional": true }, @@ -25556,43 +27258,219 @@ "browserstack-local": "^1.4.5", "got": "^11.0.2", "webdriverio": "7.16.16" + }, + "dependencies": { + "@wdio/config": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.16.16.tgz", + "integrity": "sha512-K/ObPuo6Da2liz++OKOIfbdpFwI7UWiFcBylfJkCYbweuXCoW1aUqlKI6rmKPwCH9Uqr/RHWu6p8eo0zWe6xVA==", + "dev": true, + "requires": { + "@wdio/logger": "7.16.0", + "@wdio/types": "7.16.14", + "deepmerge": "^4.0.0", + "glob": "^7.1.2" + } + }, + "@wdio/protocols": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.16.7.tgz", + "integrity": "sha512-Wv40pNQcLiPzQ3o98Mv4A8T1EBQ6k4khglz/e2r16CTm+F3DDYh8eLMAsU5cgnmuwwDKX1EyOiFwieykBn5MCg==", + "dev": true + }, + "@wdio/repl": { + "version": "7.16.14", + "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.16.14.tgz", + "integrity": "sha512-Ezih0Y+lsGkKv3H3U56hdWgZiQGA3VaAYguSLd9+g1xbQq+zMKqSmfqECD9bAy+OgCCiVTRstES6lHZxJVPhAg==", + "dev": true, + "requires": { + "@wdio/utils": "7.16.14" + } + }, + "@wdio/utils": { + "version": "7.16.14", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.16.14.tgz", + "integrity": "sha512-wwin8nVpIlhmXJkq6GJw9aDDzgLOJKgXTcEua0T2sdXjoW78u5Ly/GZrFXTjMGhacFvoZfitTrjyfyy4CxMVvw==", + "dev": true, + "requires": { + "@wdio/logger": "7.16.0", + "@wdio/types": "7.16.14", + "p-iteration": "^1.1.8" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "devtools": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.16.16.tgz", + "integrity": "sha512-M0kzkuSgfEhpqIis3gdtWsNjn/HQ+vRAmEzDnbYx/7FfjFxhSv1d+rOOT20pvd60soItMYpsOova1igACEGkGQ==", + "dev": true, + "requires": { + "@types/node": "^17.0.4", + "@types/ua-parser-js": "^0.7.33", + "@wdio/config": "7.16.16", + "@wdio/logger": "7.16.0", + "@wdio/protocols": "7.16.7", + "@wdio/types": "7.16.14", + "@wdio/utils": "7.16.14", + "chrome-launcher": "^0.15.0", + "edge-paths": "^2.1.0", + "puppeteer-core": "^13.1.3", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^1.0.1", + "uuid": "^8.0.0" + } + }, + "devtools-protocol": { + "version": "0.0.973690", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.973690.tgz", + "integrity": "sha512-myh3hSFp0YWa2GED11PmbLhV4dv9RdO7YUz27XJrbQLnP5bMbZL6dfOOILTHO57yH0kX5GfuOZBsg/4NamfPvQ==", + "dev": true + }, + "minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "ua-parser-js": { + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.33.tgz", + "integrity": "sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==", + "dev": true + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + }, + "webdriver": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.16.16.tgz", + "integrity": "sha512-x8UoG9k/P8KDrfSh1pOyNevt9tns3zexoMxp9cKnyA/7HYSErhZYTLGlgxscAXLtQG41cMH/Ba/oBmOx7Hgd8w==", + "dev": true, + "requires": { + "@types/node": "^17.0.4", + "@wdio/config": "7.16.16", + "@wdio/logger": "7.16.0", + "@wdio/protocols": "7.16.7", + "@wdio/types": "7.16.14", + "@wdio/utils": "7.16.14", + "got": "^11.0.2", + "ky": "^0.29.0", + "lodash.merge": "^4.6.1" + } + }, + "webdriverio": { + "version": "7.16.16", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.16.16.tgz", + "integrity": "sha512-caPaEWyuD3Qoa7YkW4xCCQA4v9Pa9wmhFGPvNZh3ERtjMCNi8L/XXOdkekWNZmFh3tY0kFguBj7+fAwSY7HAGw==", + "dev": true, + "requires": { + "@types/aria-query": "^5.0.0", + "@types/node": "^17.0.4", + "@wdio/config": "7.16.16", + "@wdio/logger": "7.16.0", + "@wdio/protocols": "7.16.7", + "@wdio/repl": "7.16.14", + "@wdio/types": "7.16.14", + "@wdio/utils": "7.16.14", + "archiver": "^5.0.0", + "aria-query": "^5.0.0", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.16.16", + "devtools-protocol": "^0.0.973690", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^5.0.0", + "puppeteer-core": "^13.1.3", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.16.16" + } + } } }, "@wdio/cli": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/cli/-/cli-7.16.16.tgz", - "integrity": "sha512-Wz/e5zm1UNHB9RAIsJIM7ioDzVllUwTvhVWOrI7HR/53GmO/cIvAVjpnlglizJNgK8WlbnM/cKNVIXxqxrnFmw==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/cli/-/cli-7.5.7.tgz", + "integrity": "sha512-nOQJLskrY+UECDd3NxE7oBzb6cDA7e7x02YWQugOlOgnZ4a+PJmkFoSsO8C2uNCpdFngy5rJKGUo5vbtAHEF9Q==", "dev": true, "requires": { "@types/ejs": "^3.0.5", "@types/fs-extra": "^9.0.4", - "@types/inquirer": "^8.1.2", + "@types/inquirer": "^7.3.1", "@types/lodash.flattendeep": "^4.4.6", "@types/lodash.pickby": "^4.6.6", "@types/lodash.union": "^4.6.6", - "@types/node": "^17.0.4", "@types/recursive-readdir": "^2.2.0", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", "async-exit-hook": "^2.0.1", "chalk": "^4.0.0", "chokidar": "^3.0.0", "cli-spinners": "^2.1.0", "ejs": "^3.0.1", "fs-extra": "^10.0.0", - "inquirer": "8.1.5", + "inquirer": "^8.0.0", "lodash.flattendeep": "^4.4.0", "lodash.pickby": "^4.6.0", "lodash.union": "^4.6.0", "mkdirp": "^1.0.4", "recursive-readdir": "^2.2.2", - "webdriverio": "7.16.16", + "webdriverio": "7.5.7", "yargs": "^17.0.0", "yarn-install": "^1.0.0" }, "dependencies": { + "@types/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==", + "dev": true + }, + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -25602,6 +27480,16 @@ "color-convert": "^2.0.1" } }, + "aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.10.2", + "@babel/runtime-corejs3": "^7.10.2" + } + }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -25612,6 +27500,31 @@ "supports-color": "^7.1.0" } }, + "chrome-launcher": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.4.tgz", + "integrity": "sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==", + "dev": true, + "requires": { + "@types/node": "*", + "escape-string-regexp": "^1.0.5", + "is-wsl": "^2.2.0", + "lighthouse-logger": "^1.0.0", + "mkdirp": "^0.5.3", + "rimraf": "^3.0.2" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + } + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -25627,6 +27540,65 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "devtools": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.5.7.tgz", + "integrity": "sha512-+kqmvFbceElhYpN35yjm1T4Rz3VbH0QaqrNWKRpeyFp657Y5W0bm1s5FyMUeIv0aTNkAgWcETtqL+EG9X9uvjQ==", + "dev": true, + "requires": { + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "chrome-launcher": "^0.13.1", + "edge-paths": "^2.1.0", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^0.7.21", + "uuid": "^8.0.0" + } + }, + "devtools-protocol": { + "version": "0.0.878340", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.878340.tgz", + "integrity": "sha512-W0q8Y02r1RNwfZtI4Jjh1/MZxRHyrIgy9FvElbJzQelZjmNH197H4mBQs7DZjlUUDA9s6Zz2jl+zUYFgLgEnzw==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "puppeteer-core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-9.1.1.tgz", + "integrity": "sha512-zbedbitVIGhmgz0nt7eIdLsnaoVZSlNJfBivqm2w67T8LR2bU1dvnruDZ8nQO0zn++Iet7zHbAOdnuS5+H2E7A==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.869402", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.1.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "dependencies": { + "devtools-protocol": { + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", + "dev": true + } + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -25636,13 +27608,62 @@ "has-flag": "^4.0.0" } }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + }, + "webdriverio": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.5.7.tgz", + "integrity": "sha512-TLluVPLo6Snn/dxEITvMz7ZuklN4qZOBddDuLb9LO3rhsfKDMNbnhcBk0SLdFsWny0aCuhWNpJ6co93702XC0A==", + "dev": true, + "requires": { + "@types/aria-query": "^4.2.1", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "archiver": "^5.0.0", + "aria-query": "^4.2.2", + "atob": "^2.1.2", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.5.7", + "devtools-protocol": "^0.0.878340", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^3.0.4", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.5.3" + } + }, + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "requires": {} + }, "yargs": { - "version": "17.3.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.1.tgz", - "integrity": "sha512-WUANQeVgjLbNsEmGk20f+nlHgOqzRFpiGWVaBrYGYIGANIIu3lWjoyi0fNlFmJkvfhCZ6BXINe7/W2O2bV4iaA==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", "dev": true, "requires": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", @@ -25654,17 +27675,198 @@ } }, "@wdio/concise-reporter": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/concise-reporter/-/concise-reporter-7.16.14.tgz", - "integrity": "sha512-CR+9+skJ3mXPIdRo0AnIJTJHOArrWdKlXTnyZ/DD6M9VrNk5aiTWQyphT/IeHV5+fxjHlMNIf/KgIhj1ewschQ==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/concise-reporter/-/concise-reporter-7.5.7.tgz", + "integrity": "sha512-964i7eQ4sboSla2bdR8714Er82QBgS6u39GmDFX8Izy9Ge38xaE75HuF5S7mnOWGzSojCWgqtwy5k7Rfg6GE3g==", "dev": true, "requires": { - "@wdio/reporter": "7.16.14", - "@wdio/types": "7.16.14", + "@wdio/reporter": "7.5.7", + "@wdio/types": "7.5.3", "chalk": "^4.0.0", "pretty-ms": "^7.0.0" }, "dependencies": { + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@wdio/config": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.5.3.tgz", + "integrity": "sha512-udvVizYoilOxuWj/BmoN6y7ZCd4wPdYNlSfWznrbCezAdaLZ4/pNDOO0WRWx2C4+q1wdkXZV/VuQPUGfL0lEHQ==", + "dev": true, + "requires": { + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "deepmerge": "^4.0.0", + "glob": "^7.1.2" + }, + "dependencies": { + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@wdio/local-runner": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/local-runner/-/local-runner-7.5.7.tgz", + "integrity": "sha512-aYc0XUV+/e3cg8Fp+CWlC4FbwSSG3mKAv1iuy/+Hwzg2kJE+aa+Rf2p2BQYc7HPRtKNW0bM8o+aCImZLAiPM+A==", + "dev": true, + "requires": { + "@types/stream-buffers": "^3.0.3", + "@wdio/logger": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/runner": "7.5.7", + "@wdio/types": "7.5.3", + "async-exit-hook": "^2.0.1", + "split2": "^3.2.2", + "stream-buffers": "^3.0.2" + }, + "dependencies": { + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -25699,6 +27901,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -25710,34 +27918,6 @@ } } }, - "@wdio/config": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.16.16.tgz", - "integrity": "sha512-K/ObPuo6Da2liz++OKOIfbdpFwI7UWiFcBylfJkCYbweuXCoW1aUqlKI6rmKPwCH9Uqr/RHWu6p8eo0zWe6xVA==", - "dev": true, - "requires": { - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "deepmerge": "^4.0.0", - "glob": "^7.1.2" - } - }, - "@wdio/local-runner": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/local-runner/-/local-runner-7.16.16.tgz", - "integrity": "sha512-AJaOyM842PWgMffrrXyHJjouVseLHoiL5U1sw2VVproi3ORWHbltl1AMnreU/lrGu9L0CVKHYT1pxu5UbSOCxQ==", - "dev": true, - "requires": { - "@types/stream-buffers": "^3.0.3", - "@wdio/logger": "7.16.0", - "@wdio/repl": "7.16.14", - "@wdio/runner": "7.16.16", - "@wdio/types": "7.16.14", - "async-exit-hook": "^2.0.1", - "split2": "^4.0.0", - "stream-buffers": "^3.0.2" - } - }, "@wdio/logger": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.16.0.tgz", @@ -25784,6 +27964,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -25796,19 +27982,46 @@ } }, "@wdio/mocha-framework": { - "version": "7.16.15", - "resolved": "https://registry.npmjs.org/@wdio/mocha-framework/-/mocha-framework-7.16.15.tgz", - "integrity": "sha512-XRya85/RYPZk4MZ7Cvl3oudTdrOo+RyO8b5Ff+dH8hD3GBCACaWgW9AjbsyhvbSTdUlF0gNLPdqOCsxV5XyM3w==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/mocha-framework/-/mocha-framework-7.5.3.tgz", + "integrity": "sha512-96QCVWsiyZxEgOZP3oTq2B2T7zne5dCdehLa2n4q/BLjk96Rj0jifidJZfd/1+vdNPKX0gWWAzpy98Znn8MVMw==", "dev": true, "requires": { - "@types/mocha": "^9.0.0", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", - "expect-webdriverio": "^3.0.0", - "mocha": "^9.0.0" + "@types/mocha": "^8.0.0", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "expect-webdriverio": "^2.0.0", + "mocha": "^8.0.1" }, "dependencies": { + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -25832,17 +28045,33 @@ "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" - }, - "dependencies": { - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + } + }, + "chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.3.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" } }, "color-convert": { @@ -25860,6 +28089,21 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true + }, "escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -25876,16 +28120,30 @@ "path-exists": "^4.0.0" } }, - "he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz", + "integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==", "dev": true, "requires": { "argparse": "^2.0.1" @@ -25901,13 +28159,12 @@ } }, "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", + "integrity": "sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA==", "dev": true, "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" + "chalk": "^4.0.0" } }, "minimatch": { @@ -25920,47 +28177,59 @@ } }, "mocha": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.1.tgz", - "integrity": "sha512-T7uscqjJVS46Pq1XDXyo9Uvey9gd3huT/DD9cYBb4K2Xc/vbKRPUWK067bxDQRK0yIz6Jxk73IrnimvASzBNAQ==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", + "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.3", + "chokidar": "3.5.1", + "debug": "4.3.1", "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "7.1.6", "growl": "1.10.5", "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", + "js-yaml": "4.0.0", + "log-symbols": "4.0.0", "minimatch": "3.0.4", "ms": "2.1.3", - "nanoid": "3.2.0", - "serialize-javascript": "6.0.0", + "nanoid": "3.1.20", + "serialize-javascript": "5.0.1", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", "which": "2.0.2", - "workerpool": "6.2.0", + "wide-align": "1.1.3", + "workerpool": "6.1.0", "yargs": "16.2.0", "yargs-parser": "20.2.4", "yargs-unparser": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, - "ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, "nanoid": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.2.0.tgz", - "integrity": "sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==", + "version": "3.1.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", + "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", "dev": true }, "p-limit": { @@ -25981,11 +28250,23 @@ "p-limit": "^3.0.2" } }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true + "readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "serialize-javascript": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-5.0.1.tgz", + "integrity": "sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } }, "strip-json-comments": { "version": "3.1.1", @@ -25993,6 +28274,21 @@ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "workerpool": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz", + "integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==", + "dev": true + }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -26017,72 +28313,288 @@ } }, "@wdio/protocols": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.16.7.tgz", - "integrity": "sha512-Wv40pNQcLiPzQ3o98Mv4A8T1EBQ6k4khglz/e2r16CTm+F3DDYh8eLMAsU5cgnmuwwDKX1EyOiFwieykBn5MCg==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.5.3.tgz", + "integrity": "sha512-lpNaKwxYhDSL6neDtQQYXvzMAw+u4PXx65ryeMEX82mkARgzSZps5Kyrg9ub7X4T17K1NPfnY6UhZEWg6cKJCg==", "dev": true }, "@wdio/repl": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.16.14.tgz", - "integrity": "sha512-Ezih0Y+lsGkKv3H3U56hdWgZiQGA3VaAYguSLd9+g1xbQq+zMKqSmfqECD9bAy+OgCCiVTRstES6lHZxJVPhAg==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.5.3.tgz", + "integrity": "sha512-jfNJwNoc2nWdnLsFoGHmOJR9zaWfDTBMWM3W1eR5kXIjevD6gAfWsB5ZoA4IdybujCXxdnhlsm4o2jIzp/6f7A==", "dev": true, "requires": { - "@wdio/utils": "7.16.14" + "@wdio/utils": "7.5.3" } }, "@wdio/reporter": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.16.14.tgz", - "integrity": "sha512-e/I2oGfqjx9+zI4NT/garqxm7Afnos1EcrGSNu75WmP3PNJt4i+9DKkROu4PM6XWcpUB4v2UF7Mv/NrL3TU9aA==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.5.7.tgz", + "integrity": "sha512-9PXqZtCXDtU6UYLNDPu9MZQ8BiABGnRlJTrlbYB3gBfZDibMkJMvwXzPderipBv2+ifDZXmGe3Njf1ao2TkbFA==", "dev": true, "requires": { - "@types/diff": "^5.0.0", - "@types/node": "^17.0.4", - "@types/object-inspect": "^1.8.0", - "@types/supports-color": "^8.1.0", - "@types/tmp": "^0.2.0", - "@wdio/types": "7.16.14", - "diff": "^5.0.0", - "fs-extra": "^10.0.0", - "object-inspect": "^1.10.3", - "supports-color": "8.1.1" + "@wdio/types": "7.5.3", + "fs-extra": "^10.0.0" + }, + "dependencies": { + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + } } }, "@wdio/runner": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/runner/-/runner-7.16.16.tgz", - "integrity": "sha512-Tt2ja6GukGPq1m98WP26yOWUGwzK1y7gPTLy6rKlamz3mOBC7koL0T9+iqcFREquUe4CMy2jWp1lqvPlwMbu7g==", + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/runner/-/runner-7.5.7.tgz", + "integrity": "sha512-RzVXd+xnwK/thkx1/xo9K5iscQ0Ofobgsx5dNVtwLDVMn9V7jCW/WX4dSCPAPaVSqnUCmkcQp3P5AoSBPpCZnQ==", "dev": true, "requires": { - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", "deepmerge": "^4.0.0", "gaze": "^1.1.2", - "webdriver": "7.16.16", - "webdriverio": "7.16.16" + "webdriver": "7.5.3", + "webdriverio": "7.5.7" + }, + "dependencies": { + "@types/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==", + "dev": true + }, + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.10.2", + "@babel/runtime-corejs3": "^7.10.2" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "chrome-launcher": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.4.tgz", + "integrity": "sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==", + "dev": true, + "requires": { + "@types/node": "*", + "escape-string-regexp": "^1.0.5", + "is-wsl": "^2.2.0", + "lighthouse-logger": "^1.0.0", + "mkdirp": "^0.5.3", + "rimraf": "^3.0.2" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "devtools": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.5.7.tgz", + "integrity": "sha512-+kqmvFbceElhYpN35yjm1T4Rz3VbH0QaqrNWKRpeyFp657Y5W0bm1s5FyMUeIv0aTNkAgWcETtqL+EG9X9uvjQ==", + "dev": true, + "requires": { + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "chrome-launcher": "^0.13.1", + "edge-paths": "^2.1.0", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^0.7.21", + "uuid": "^8.0.0" + } + }, + "devtools-protocol": { + "version": "0.0.878340", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.878340.tgz", + "integrity": "sha512-W0q8Y02r1RNwfZtI4Jjh1/MZxRHyrIgy9FvElbJzQelZjmNH197H4mBQs7DZjlUUDA9s6Zz2jl+zUYFgLgEnzw==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "puppeteer-core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-9.1.1.tgz", + "integrity": "sha512-zbedbitVIGhmgz0nt7eIdLsnaoVZSlNJfBivqm2w67T8LR2bU1dvnruDZ8nQO0zn++Iet7zHbAOdnuS5+H2E7A==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.869402", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.1.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "dependencies": { + "devtools-protocol": { + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", + "dev": true + } + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + }, + "webdriverio": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.5.7.tgz", + "integrity": "sha512-TLluVPLo6Snn/dxEITvMz7ZuklN4qZOBddDuLb9LO3rhsfKDMNbnhcBk0SLdFsWny0aCuhWNpJ6co93702XC0A==", + "dev": true, + "requires": { + "@types/aria-query": "^4.2.1", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "archiver": "^5.0.0", + "aria-query": "^4.2.2", + "atob": "^2.1.2", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.5.7", + "devtools-protocol": "^0.0.878340", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^3.0.4", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.5.3" + } + }, + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "requires": {} + } } }, "@wdio/spec-reporter": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@wdio/spec-reporter/-/spec-reporter-7.19.1.tgz", - "integrity": "sha512-qnZkn3VcyBPtcorUtpyCFE8v5ubyWmR7mFETXNzyriHyvjvk+NeFCWaFcIehpXYXiAmNpAwyfnZoIY6tkKQixQ==", + "version": "7.19.7", + "resolved": "https://registry.npmjs.org/@wdio/spec-reporter/-/spec-reporter-7.19.7.tgz", + "integrity": "sha512-BDBZU2EK/GuC9VxtfqPtoW43FmvKxYDsvcDVDi3F7o+9fkcuGSJiWbw1AX251ZzzVQ7YP9ImTitSpdpUKXkilQ==", "dev": true, "requires": { "@types/easy-table": "^0.0.33", - "@wdio/reporter": "7.19.1", - "@wdio/types": "7.19.1", + "@wdio/reporter": "7.19.7", + "@wdio/types": "7.19.5", "chalk": "^4.0.0", "easy-table": "^1.1.1", "pretty-ms": "^7.0.0" }, "dependencies": { "@wdio/reporter": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.19.1.tgz", - "integrity": "sha512-sWmBBV4dPCZkGk9Qq0m35T/vHGen0N10nH4osQcVP3IZJqpo2eLIH4w+X6EUbjZ2GdgOA2bLMMzb1bl9JqnGPg==", + "version": "7.19.7", + "resolved": "https://registry.npmjs.org/@wdio/reporter/-/reporter-7.19.7.tgz", + "integrity": "sha512-Dum19gpfru66FnIq78/4HTuW87B7ceLDp6PJXwQM5kXyN7Gb7zhMgp6FZTM0FCYLyi6U/zXZSvpNUYl77caS6g==", "dev": true, "requires": { "@types/diff": "^5.0.0", @@ -26090,17 +28602,46 @@ "@types/object-inspect": "^1.8.0", "@types/supports-color": "^8.1.0", "@types/tmp": "^0.2.0", - "@wdio/types": "7.19.1", + "@wdio/types": "7.19.5", "diff": "^5.0.0", "fs-extra": "^10.0.0", "object-inspect": "^1.10.3", "supports-color": "8.1.1" + } + }, + "@wdio/types": { + "version": "7.19.5", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.19.5.tgz", + "integrity": "sha512-S1lC0pmtEO7NVH/2nM1c7NHbkgxLZH3VVG/z6ym3Bbxdtcqi2LMsEvvawMAU/fmhyiIkMsGZCO8vxG9cRw4z4A==", + "dev": true, + "requires": { + "@types/node": "^17.0.4", + "got": "^11.8.1" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "dependencies": { "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { "has-flag": "^4.0.0" @@ -26108,13 +28649,76 @@ } } }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "@wdio/sync": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@wdio/sync/-/sync-7.5.7.tgz", + "integrity": "sha512-Zu/AYLjwqbFSbaOU1US7ownv3ov8JrtoGHq51JfJ4masefJDXNkHix2cZ0qEgl3IvkkWQ0ewL0G8GTXb3KOemA==", + "dev": true, + "requires": { + "@types/fibers": "^3.1.0", + "@types/puppeteer": "^5.4.0", + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3", + "fibers": "^5.0.0", + "webdriverio": "7.5.7" + }, + "dependencies": { + "@types/aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==", + "dev": true + }, + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, "@wdio/types": { - "version": "7.19.1", - "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.19.1.tgz", - "integrity": "sha512-mOodKlmvYxpj8P5BhjggEGpXuiRSlsyn2ClG8QqJ3lfXgOtOVEzFNfv/Ai7TkHr+lHDQNXLjllCjSqoCHhwlqg==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", "dev": true, "requires": { - "@types/node": "^17.0.4", "got": "^11.8.1" } }, @@ -26127,6 +28731,16 @@ "color-convert": "^2.0.1" } }, + "aria-query": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-4.2.2.tgz", + "integrity": "sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.10.2", + "@babel/runtime-corejs3": "^7.10.2" + } + }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -26137,6 +28751,20 @@ "supports-color": "^7.1.0" } }, + "chrome-launcher": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.13.4.tgz", + "integrity": "sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==", + "dev": true, + "requires": { + "@types/node": "*", + "escape-string-regexp": "^1.0.5", + "is-wsl": "^2.2.0", + "lighthouse-logger": "^1.0.0", + "mkdirp": "^0.5.3", + "rimraf": "^3.0.2" + } + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -26152,6 +28780,74 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "devtools": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.5.7.tgz", + "integrity": "sha512-+kqmvFbceElhYpN35yjm1T4Rz3VbH0QaqrNWKRpeyFp657Y5W0bm1s5FyMUeIv0aTNkAgWcETtqL+EG9X9uvjQ==", + "dev": true, + "requires": { + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "chrome-launcher": "^0.13.1", + "edge-paths": "^2.1.0", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "ua-parser-js": "^0.7.21", + "uuid": "^8.0.0" + } + }, + "devtools-protocol": { + "version": "0.0.878340", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.878340.tgz", + "integrity": "sha512-W0q8Y02r1RNwfZtI4Jjh1/MZxRHyrIgy9FvElbJzQelZjmNH197H4mBQs7DZjlUUDA9s6Zz2jl+zUYFgLgEnzw==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "puppeteer-core": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-9.1.1.tgz", + "integrity": "sha512-zbedbitVIGhmgz0nt7eIdLsnaoVZSlNJfBivqm2w67T8LR2bU1dvnruDZ8nQO0zn++Iet7zHbAOdnuS5+H2E7A==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "devtools-protocol": "0.0.869402", + "extract-zip": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.1", + "pkg-dir": "^4.2.0", + "progress": "^2.0.1", + "proxy-from-env": "^1.1.0", + "rimraf": "^3.0.2", + "tar-fs": "^2.0.0", + "unbzip2-stream": "^1.3.3", + "ws": "^7.2.3" + }, + "dependencies": { + "devtools-protocol": { + "version": "0.0.869402", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", + "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", + "dev": true + } + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -26160,23 +28856,58 @@ "requires": { "has-flag": "^4.0.0" } + }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true + }, + "webdriverio": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.5.7.tgz", + "integrity": "sha512-TLluVPLo6Snn/dxEITvMz7ZuklN4qZOBddDuLb9LO3rhsfKDMNbnhcBk0SLdFsWny0aCuhWNpJ6co93702XC0A==", + "dev": true, + "requires": { + "@types/aria-query": "^4.2.1", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/repl": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", + "archiver": "^5.0.0", + "aria-query": "^4.2.2", + "atob": "^2.1.2", + "css-shorthand-properties": "^1.1.1", + "css-value": "^0.0.1", + "devtools": "7.5.7", + "devtools-protocol": "^0.0.878340", + "fs-extra": "^10.0.0", + "get-port": "^5.1.1", + "grapheme-splitter": "^1.0.2", + "lodash.clonedeep": "^4.5.0", + "lodash.isobject": "^3.0.2", + "lodash.isplainobject": "^4.0.6", + "lodash.zip": "^4.2.0", + "minimatch": "^3.0.4", + "puppeteer-core": "^9.1.0", + "query-selector-shadow-dom": "^1.0.0", + "resq": "^1.9.1", + "rgb2hex": "0.2.5", + "serialize-error": "^8.0.0", + "webdriver": "7.5.3" + } + }, + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "requires": {} } } }, - "@wdio/sync": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/@wdio/sync/-/sync-7.16.16.tgz", - "integrity": "sha512-MbVFAteaAOxHLKkMiMzOnh1hzINAK2U41GDIfy1yaPumcw1pNuJIhWrBYxprNMlqt8srk++wqQWgj5XpFjCL6g==", - "dev": true, - "requires": { - "@types/fibers": "^3.1.0", - "@types/puppeteer": "^5.4.0", - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "fibers": "^5.0.0", - "webdriverio": "7.16.16" - } - }, "@wdio/types": { "version": "7.16.14", "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.16.14.tgz", @@ -26188,14 +28919,85 @@ } }, "@wdio/utils": { - "version": "7.16.14", - "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.16.14.tgz", - "integrity": "sha512-wwin8nVpIlhmXJkq6GJw9aDDzgLOJKgXTcEua0T2sdXjoW78u5Ly/GZrFXTjMGhacFvoZfitTrjyfyy4CxMVvw==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.5.3.tgz", + "integrity": "sha512-nlLDKr8v8abLOHCKroBwQkGPdCIxjID2MllgWX23xqkYZylM9RdwPBdL8osQt9m3rq2TxiPAT4OlbzNt2WtN6Q==", "dev": true, "requires": { - "@wdio/logger": "7.16.0", - "@wdio/types": "7.16.14", - "p-iteration": "^1.1.8" + "@wdio/logger": "7.5.3", + "@wdio/types": "7.5.3" + }, + "dependencies": { + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "@webassemblyjs/ast": { @@ -26344,6 +29146,12 @@ "@xtuc/long": "4.2.2" } }, + "@xmldom/xmldom": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.8.tgz", + "integrity": "sha512-PrJx38EfpitFhwmILRl37jAdBlsww6AZ6rRVK4QS7T7RHLhX7mSs647sTmgr9GIxe3qjXdesmomEgbgaokrVFg==", + "dev": true + }, "@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -26359,7 +29167,7 @@ "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "integrity": "sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==", "dev": true }, "accepts": { @@ -26384,34 +29192,32 @@ "dev": true, "requires": {} }, - "acorn-node": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", - "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", - "dev": true, - "requires": { - "acorn": "^7.0.0", - "acorn-walk": "^7.0.0", - "xtend": "^4.0.2" - } - }, "acorn-walk": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", - "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", "dev": true }, - "add-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", - "integrity": "sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=", - "dev": true + "aes-decrypter": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/aes-decrypter/-/aes-decrypter-3.1.3.tgz", + "integrity": "sha512-VkG9g4BbhMBy+N5/XodDeV6F02chEk9IpgRTq/0bS80y4dzy79VH2Gtms02VXomf3HmyRe3yyJYkJ990ns+d6A==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "^3.0.5", + "global": "^4.4.0", + "pkcs7": "^1.0.4" + } }, "agent-base": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-5.1.1.tgz", - "integrity": "sha512-TMeqbNl2fMW0nMjTEPOwe3J/PRFP4vqeoNuQMG0HlMrtm5QxKqdvAkZ1pRBQ/ulIyDD5Yq0nJ7YbdD8ey0TO3g==", - "dev": true + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dev": true, + "requires": { + "debug": "4" + } }, "ajv": { "version": "6.12.3", @@ -26425,19 +29231,35 @@ "uri-js": "^4.2.2" } }, + "ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "requires": {} + }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "integrity": "sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==", "dev": true, "optional": true }, "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", "dev": true }, + "ansi-cyan": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz", + "integrity": "sha512-eCjan3AVo/SxZ0/MyIYRtkpxIu/H3xZN7URr1vXVrISxeyz8fUFz0FJziamK4sS8I+t35y4rHg1b2PklyBe/7A==", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } + }, "ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -26450,17 +29272,20 @@ "ansi-gray": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", - "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", + "integrity": "sha512-HrgGIZUl8h2EHuZaU9hTR/cU5nhKxpVE1V6kdGsQ8e4zirElJ5fvtfc8N7Q1oq1aatO275i8pUFUCpNWCAnVWw==", "dev": true, "requires": { "ansi-wrap": "0.1.0" } }, - "ansi-html": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz", - "integrity": "sha1-gTWEAhliqenm/QOflA0S9WynhZ4=", - "dev": true + "ansi-red": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", + "integrity": "sha512-ewaIr5y+9CUTGFwZfpECUbFlGcC0GCw1oqR9RI6h1gQCd9Aj2GxSckCnPsVJnmfMZbwFYE+leZGASgkWl06Jow==", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } }, "ansi-regex": { "version": "5.0.1", @@ -26472,7 +29297,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -26480,7 +29304,7 @@ "ansi-wrap": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", - "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", + "integrity": "sha512-ZyznvL8k/FZeQHr2T6LzcJ/+vBApDnMNZvfVFy3At0knswWd6rJ3/0Hhmpu8oqa6C92npmozs890sX9Dl6q+Qw==", "dev": true }, "anymatch": { @@ -26496,20 +29320,20 @@ "append-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz", - "integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=", + "integrity": "sha512-WLbYiXzD3y/ATLZFufV/rZvWdZOs+Z/+5v1rBZ463Jn398pa6kcde27cvozYnBoxXblGZTFfoPpsaEw0orU5BA==", "dev": true, "requires": { "buffer-equal": "^1.0.0" } }, "archiver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/archiver/-/archiver-5.3.0.tgz", - "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-5.3.1.tgz", + "integrity": "sha512-8KyabkmbYrH+9ibcTScQ1xCJC/CGcugdVIwB+53f5sZziXgwUh3iXlAlANMxcZyDEfTHMe6+Z5FofV8nopXP7w==", "dev": true, "requires": { "archiver-utils": "^2.1.0", - "async": "^3.2.0", + "async": "^3.2.3", "buffer-crc32": "^0.2.1", "readable-stream": "^3.6.0", "readdir-glob": "^1.0.0", @@ -26518,9 +29342,9 @@ }, "dependencies": { "async": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", - "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", "dev": true }, "readable-stream": { @@ -26557,7 +29381,7 @@ "archy": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", "dev": true }, "argparse": { @@ -26570,21 +29394,36 @@ } }, "aria-query": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.0.0.tgz", - "integrity": "sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg==", - "dev": true + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", + "integrity": "sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==", + "dev": true, + "requires": { + "deep-equal": "^2.0.5" + } }, "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz", + "integrity": "sha512-OQwDZUqYaQwyyhDJHThmzId8daf4/RFNLaeh3AevmSeZ5Y7ug4Ga/yKc6l6kTZOBW781rCj103ZuTh8GAsB3+Q==", + "dev": true, + "requires": { + "arr-flatten": "^1.0.1", + "array-slice": "^0.2.3" + }, + "dependencies": { + "array-slice": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", + "integrity": "sha512-rlVfZW/1Ph2SNySXwR9QYkChp8EkOEiTMO5Vwx60usw04i4nWemkm9RXmQqgkQFaLHsqLuADvjp6IfgL9l2M8Q==", + "dev": true + } + } }, "arr-filter": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/arr-filter/-/arr-filter-1.1.2.tgz", - "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", + "integrity": "sha512-A2BETWCqhsecSvCkWAeVBFLH6sXEUGASuzkpjL3GR1SlL/PWL6M3J8EAAld2Uubmh39tvkJTqC9LeLHCUKmFXA==", "dev": true, "requires": { "make-iterator": "^1.0.0" @@ -26599,62 +29438,50 @@ "arr-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/arr-map/-/arr-map-2.0.2.tgz", - "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", + "integrity": "sha512-tVqVTHt+Q5Xb09qRkbu+DidW1yYzz5izWS2Xm2yFm7qJnmUfz4HPzNxbHkdRJbz2lrqI7S+z17xNYdFcBBO8Hw==", "dev": true, "requires": { "make-iterator": "^1.0.0" } }, "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz", + "integrity": "sha512-t5db90jq+qdgk8aFnxEkjqta0B/GHrM1pxzuuZz2zWsOXc5nKu3t+76s/PQBA8FTcM/ipspIH9jWG4OxCBc2eA==", "dev": true }, "array-differ": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "integrity": "sha512-LeZY+DZDRnvP7eMuQ6LHfCzUGxAAIViUBliK24P3hWXL6y4SortgR6Nim6xrkfSLlmH0+k+9NYNwVC2s53ZrYQ==", "dev": true }, "array-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", - "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=", - "dev": true - }, - "array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==", "dev": true }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, "array-from": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", - "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", - "dev": true - }, - "array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "integrity": "sha512-GQTc6Uupx1FCavi5mPzBvVT7nEOeWMmUA9P95wpfpW1XwMSKs+KaymD5C2Up7KAUKg/mYwbsUYzdZWcoajlNZg==", "dev": true }, "array-includes": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", - "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.5.tgz", + "integrity": "sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3", - "es-abstract": "^1.19.1", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5", "get-intrinsic": "^1.1.1", "is-string": "^1.0.7" } @@ -26662,7 +29489,7 @@ "array-initial": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/array-initial/-/array-initial-1.1.0.tgz", - "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", + "integrity": "sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==", "dev": true, "requires": { "array-slice": "^1.0.0", @@ -26714,32 +29541,27 @@ "array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "integrity": "sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==", "dev": true }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "integrity": "sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==", "dev": true }, "array.prototype.flat": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz", - "integrity": "sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.0.tgz", + "integrity": "sha512-12IUEkHsAhA4DY5s0FPgNXIdc8VRSqD9Zp78a5au9abH/SOBrsp082JOWFNTjkMozh8mqcdiKuaLGhPeYztxSw==", "dev": true, "requires": { "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.19.0" + "es-abstract": "^1.19.2", + "es-shim-unscopables": "^1.0.0" } }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, "asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -26764,7 +29586,7 @@ "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", "dev": true }, "assertion-error": { @@ -26776,7 +29598,7 @@ "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==", "dev": true }, "astral-regex": { @@ -26788,7 +29610,7 @@ "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "integrity": "sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==", "dev": true }, "async-done": { @@ -26818,7 +29640,7 @@ "async-settle": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-settle/-/async-settle-1.0.0.tgz", - "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", + "integrity": "sha512-VPXfB4Vk49z1LHHodrEQ6Xf7W4gg1w0dAPROHngx7qgDjqmIQ+fXmwgGXTW/ITLai0YLSvWepJOP9EVpMnEAcw==", "dev": true, "requires": { "async-done": "^1.2.2" @@ -26827,7 +29649,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, "atob": { @@ -26845,7 +29667,7 @@ "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", "dev": true }, "aws4": { @@ -26857,7 +29679,7 @@ "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "integrity": "sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==", "dev": true, "requires": { "chalk": "^1.1.3", @@ -26868,19 +29690,19 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "requires": { "ansi-styles": "^2.2.1", @@ -26893,13 +29715,13 @@ "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "integrity": "sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==", "dev": true }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" @@ -26908,7 +29730,7 @@ "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true } } @@ -26952,19 +29774,13 @@ "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "integrity": "sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==", "dev": true }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } @@ -26985,19 +29801,10 @@ "trim-right": "^1.0.1" }, "dependencies": { - "detect-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", - "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, "jsesc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", + "integrity": "sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA==", "dev": true } } @@ -27005,7 +29812,7 @@ "babel-helpers": { "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", - "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", + "integrity": "sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ==", "dev": true, "requires": { "babel-runtime": "^6.22.0", @@ -27013,99 +29820,70 @@ } }, "babel-loader": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.2.3.tgz", - "integrity": "sha512-n4Zeta8NC3QAsuyiizu0GkmRcQ6clkV9WFUnUf1iXP//IeSKbWjofW3UHyZVwlOB4y039YQKefawyTn64Zwbuw==", + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.2.5.tgz", + "integrity": "sha512-OSiFfH89LrEMiWd4pLNqGz4CwJDtbs2ZVc+iGu2HrkRfPxId9F2anQj38IxWpmRfsUY0aBZYi1EFcd3mhtRMLQ==", "dev": true, "requires": { "find-cache-dir": "^3.3.1", - "loader-utils": "^1.4.0", + "loader-utils": "^2.0.0", "make-dir": "^3.1.0", "schema-utils": "^2.6.5" - }, - "dependencies": { - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "loader-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", - "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", - "dev": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^3.0.0", - "json5": "^1.0.1" - } - } } }, "babel-messages": { "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", - "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "integrity": "sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==", "dev": true, "requires": { "babel-runtime": "^6.22.0" } }, - "babel-plugin-dynamic-import-node": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", - "integrity": "sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==", + "babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", "dev": true, "requires": { - "object.assign": "^4.1.0" + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" } }, "babel-plugin-polyfill-corejs2": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz", - "integrity": "sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w==", - "dev": true, + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz", + "integrity": "sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==", "requires": { - "@babel/compat-data": "^7.13.11", - "@babel/helper-define-polyfill-provider": "^0.3.1", + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.3", "semver": "^6.1.1" } }, "babel-plugin-polyfill-corejs3": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", - "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", - "dev": true, + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz", + "integrity": "sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA==", "requires": { - "@babel/helper-define-polyfill-provider": "^0.3.1", - "core-js-compat": "^3.21.0" + "@babel/helper-define-polyfill-provider": "^0.3.3", + "core-js-compat": "^3.25.1" } }, "babel-plugin-polyfill-regenerator": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.3.1.tgz", - "integrity": "sha512-Y2B06tvgHYt1x0yz17jGkGeeMr5FeKUu+ASJ+N6nB5lQ8Dapfg42i0OVrf8PNGJ3zKL4A23snMi1IRwrqqND7A==", - "dev": true, - "requires": { - "@babel/helper-define-polyfill-provider": "^0.3.1" - } - }, - "babel-plugin-transform-object-assign": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-assign/-/babel-plugin-transform-object-assign-6.22.0.tgz", - "integrity": "sha1-+Z0vZvGgsNSY40bFNZaEdAyqILo=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz", + "integrity": "sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw==", "requires": { - "babel-runtime": "^6.22.0" + "@babel/helper-define-polyfill-provider": "^0.3.3" } }, "babel-register": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", - "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", + "integrity": "sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A==", "dev": true, "requires": { "babel-core": "^6.26.0", @@ -27131,22 +29909,14 @@ "requires": { "minimist": "^1.2.6" } - }, - "source-map-support": { - "version": "0.4.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", - "dev": true, - "requires": { - "source-map": "^0.5.6" - } } } }, "babel-runtime": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dev": true, "requires": { "core-js": "^2.4.0", "regenerator-runtime": "^0.11.0" @@ -27155,14 +29925,21 @@ "core-js": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==" + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "dev": true + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true } } }, "babel-template": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", - "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", + "integrity": "sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg==", "dev": true, "requires": { "babel-runtime": "^6.26.0", @@ -27175,7 +29952,7 @@ "babel-traverse": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", - "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "integrity": "sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==", "dev": true, "requires": { "babel-code-frame": "^6.26.0", @@ -27207,7 +29984,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } @@ -27215,7 +29992,7 @@ "babel-types": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", - "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "integrity": "sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==", "dev": true, "requires": { "babel-runtime": "^6.26.0", @@ -27227,18 +30004,11 @@ "to-fast-properties": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "integrity": "sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og==", "dev": true } } }, - "babelify": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/babelify/-/babelify-10.0.0.tgz", - "integrity": "sha512-X40FaxyH7t3X+JFAKvb1H9wooWKLRCi8pg3m8poqtdZaIng+bjzp9RvKQCvRjF9isHiPkXspbbXT/zwXLtwgwg==", - "dev": true, - "requires": {} - }, "babylon": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", @@ -27248,7 +30018,7 @@ "bach": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", - "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", + "integrity": "sha512-bZOOfCb3gXBXbTFXq3OZtGR88LwGeJvzu6szttaIzymOTS4ZttBNOWSv7aLZja2EMycKtRYV0Oa8SNKH/zkxvg==", "dev": true, "requires": { "arr-filter": "^1.1.1", @@ -27263,9 +30033,9 @@ } }, "bail": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.5.tgz", - "integrity": "sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/bail/-/bail-2.0.2.tgz", + "integrity": "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==", "dev": true }, "balanced-match": { @@ -27292,7 +30062,7 @@ "define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "requires": { "is-descriptor": "^1.0.0" @@ -27319,18 +30089,26 @@ "dev": true, "requires": { "safe-buffer": "5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "batch": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", - "integrity": "sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY=", + "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==", "dev": true }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", - "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", "dev": true, "requires": { "tweetnacl": "^0.14.3" @@ -27339,7 +30117,7 @@ "beeper": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "integrity": "sha512-3vqtKL1N45I5dV0RdssXZG7X6pCqQrWPNOlBPZPrd+QkE2HEhR57Z04m0KtpbsZH73j+a3F8UD1TQnn+ExTvIA==", "dev": true }, "big-integer": { @@ -27357,7 +30135,7 @@ "binary": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", + "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==", "dev": true, "requires": { "buffers": "~0.1.1", @@ -27413,13 +30191,13 @@ "bluebird": { "version": "3.4.7", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", - "integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=", + "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==", "dev": true }, "body": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz", - "integrity": "sha1-5LoM5BCkaTYyM2dgnstOZVMSUGk=", + "integrity": "sha512-chUsBxGRtuElD6fmw1gHLpvnKdVLK302peeFa9ZqAEk8TyzZ3fygLyUEDDPTJvL9+Bor0dIwn6ePOsRM2y0zQQ==", "dev": true, "requires": { "continuable-cache": "^0.3.1", @@ -27431,13 +30209,13 @@ "bytes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-1.0.0.tgz", - "integrity": "sha1-NWnt6Lo0MV+rmcPpLLBMciDeH6g=", + "integrity": "sha512-/x68VkHLeTl3/Ll8IvxdwzhrT+IyKc52e/oyHhA2RwqPqswSnjVbSddfPRwAsJtbilMAPSRWwAlpxdYsSWOTKQ==", "dev": true }, "raw-body": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.7.tgz", - "integrity": "sha1-HQJ8K/oRasxmI7yo8AAWVyqH1CU=", + "integrity": "sha512-WmJJU2e9Y6M5UzTOkHaM7xJGAPQD8PNzx3bAd2+uhZAim6wDk6dAZxPVYLF67XhbR4hmKGh33Lpmh4XWrCH5Mg==", "dev": true, "requires": { "bytes": "1", @@ -27447,26 +30225,28 @@ "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", "dev": true } } }, "body-parser": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz", - "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", + "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", "requires": { "bytes": "3.1.2", "content-type": "~1.0.4", "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.8.1", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.9.7", - "raw-body": "2.4.3", - "type-is": "~1.6.18" + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" }, "dependencies": { "debug": { @@ -27480,7 +30260,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, @@ -27503,23 +30283,6 @@ "fill-range": "^7.0.1" } }, - "browser-resolve": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", - "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", - "dev": true, - "requires": { - "resolve": "1.1.7" - }, - "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true - } - } - }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -27527,16 +30290,14 @@ "dev": true }, "browserslist": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.0.tgz", - "integrity": "sha512-bnpOoa+DownbciXj0jVGENf8VYQnE2LNWomhYuCsMmmx9Jd9lwq0WXODuwpSsp8AVdKM2/HorrzxAfbKvWTByQ==", - "dev": true, + "version": "4.21.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", + "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", "requires": { - "caniuse-lite": "^1.0.30001313", - "electron-to-chromium": "^1.4.76", - "escalade": "^3.1.1", - "node-releases": "^2.0.2", - "picocolors": "^1.0.0" + "caniuse-lite": "^1.0.30001400", + "electron-to-chromium": "^1.4.251", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.9" } }, "browserstack": { @@ -27579,21 +30340,22 @@ } }, "browserstack-local": { - "version": "1.4.9", - "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.4.9.tgz", - "integrity": "sha512-V+q8HQwRQFr9nd32xR66ZZ3VDWa3Kct4IMMudhKgcuD7cWrvvFARZOibx71II+Rf7P5nMQpWWxl9z/3p927nbg==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.5.1.tgz", + "integrity": "sha512-T/wxyWDzvBHbDvl7fZKpFU7mYze6nrUkBhNy+d+8bXBqgQX10HTYvajIGO0wb49oGSLCPM0CMZTV/s7e6LF0sA==", "dev": true, "requires": { - "https-proxy-agent": "^4.0.0", + "agent-base": "^6.0.2", + "https-proxy-agent": "^5.0.1", "is-running": "^2.1.0", "ps-tree": "=1.2.0", "temp-fs": "^0.9.9" } }, "browserstacktunnel-wrapper": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/browserstacktunnel-wrapper/-/browserstacktunnel-wrapper-2.0.4.tgz", - "integrity": "sha512-GCV599FUUxNOCFl3WgPnfc5dcqq9XTmMXoxWpqkvmk0R9TOIoqmjENNU6LY6DtgIL6WfBVbg/jmWtnM5K6UYSg==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/browserstacktunnel-wrapper/-/browserstacktunnel-wrapper-2.0.5.tgz", + "integrity": "sha512-oociT3nl+FhQnyJbAb1RM4oQ5pN7aKeXEURkTkiEVm/Rji2r0agl3Wbw5V23VFn9lCU5/fGyDejRZPtGYsEcFw==", "dev": true, "requires": { "https-proxy-agent": "^2.2.1", @@ -27643,13 +30405,13 @@ "buffer-crc32": { "version": "0.2.13", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", "dev": true }, "buffer-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.0.tgz", - "integrity": "sha1-WWFrSYME1Var1GaWayLu2j7KX74=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-1.0.1.tgz", + "integrity": "sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg==", "dev": true }, "buffer-from": { @@ -27664,16 +30426,10 @@ "integrity": "sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==", "dev": true }, - "buffer-shims": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", - "dev": true - }, "buffers": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=", + "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==", "dev": true }, "bytes": { @@ -27684,7 +30440,7 @@ "cac": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/cac/-/cac-3.0.4.tgz", - "integrity": "sha1-bSTO7Dcu/lybeYgIvH9JtHJCpO8=", + "integrity": "sha512-hq4rxE3NT5PlaEiVV39Z45d6MoFcQZG5dsgJqtAUeOz3408LEQAElToDkf9i5IYSCOmK0If/81dLg7nKxqPR0w==", "dev": true, "requires": { "camelcase-keys": "^3.0.0", @@ -27699,35 +30455,19 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true }, - "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", - "dev": true - }, - "camelcase-keys": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-3.0.0.tgz", - "integrity": "sha1-/AxsNgNj9zd+N5O5oWvM8QcMHKQ=", - "dev": true, - "requires": { - "camelcase": "^3.0.0", - "map-obj": "^1.0.0" - } - }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "requires": { "ansi-styles": "^2.2.1", @@ -27740,77 +30480,44 @@ "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", "dev": true, "requires": { "path-exists": "^2.0.0", "pinkie-promise": "^2.0.0" } }, - "indent-string": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", - "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", - "dev": true - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { - "error-ex": "^1.2.0" + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", "dev": true, "requires": { "pinkie-promise": "^2.0.0" } }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", "dev": true, "requires": { "load-json-file": "^1.0.0", @@ -27821,35 +30528,32 @@ "read-pkg-up": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", "dev": true, "requires": { "find-up": "^1.0.0", "read-pkg": "^1.0.0" } }, + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true + }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true } } @@ -27903,39 +30607,15 @@ } } }, - "cached-path-relative": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz", - "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==", - "dev": true - }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" } }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "^0.2.0" - }, - "dependencies": { - "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true - } - } - }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -27949,40 +30629,44 @@ "dev": true }, "camelcase-keys": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz", - "integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-3.0.0.tgz", + "integrity": "sha512-U4E6A6aFyYnNW+tDt5/yIUKQURKXe3WMFPfX4FxrQFcwZ/R08AUk1xWcUtlr7oq6CV07Ji+aa69V2g7BSpblnQ==", "dev": true, "requires": { - "camelcase": "^5.3.1", - "map-obj": "^4.0.0", - "quick-lru": "^4.0.1" + "camelcase": "^3.0.0", + "map-obj": "^1.0.0" }, "dependencies": { - "quick-lru": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", - "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", "dev": true } } }, - "caniuse-lite": { - "version": "1.0.30001320", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001320.tgz", - "integrity": "sha512-MWPzG54AGdo3nWx7zHZTefseM5Y1ccM7hlQKHRqJkPozUaw3hNbBTMmLn16GG2FUzjR13Cr3NPfhIieX5PzXDA==", + "can-autoplay": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/can-autoplay/-/can-autoplay-3.0.2.tgz", + "integrity": "sha512-Ih6wc7yJB4TylS/mLyAW0Dj5Nh3Gftq/g966TcxgvpNCOzlbqTs85srAq7mwIspo4w8gnLCVVGroyCHfh6l9aA==", "dev": true }, + "caniuse-lite": { + "version": "1.0.30001429", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001429.tgz", + "integrity": "sha512-511ThLu1hF+5RRRt0zYCf2U2yRr9GPF6m5y90SBCWsvSoYoW7yAGlv/elyPaNfvGCkp6kj/KFZWU0BMA69Prsg==" + }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", "dev": true }, "ccount": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.1.0.tgz", - "integrity": "sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", "dev": true }, "chai": { @@ -28003,7 +30687,7 @@ "chainsaw": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", + "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==", "dev": true, "requires": { "traverse": ">=0.3.0 <0.4" @@ -28013,52 +30697,28 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" - }, - "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - } } }, "character-entities": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz", - "integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", "dev": true }, "character-entities-html4": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.4.tgz", - "integrity": "sha512-HRcDxZuZqMx3/a+qrzxdBKBPUpxWEq9xw2OPZ3a/174ihfrQKVsFhqtthBInFy1zZ9GgZyFXOatNujm8M+El3g==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", "dev": true }, "character-entities-legacy": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz", - "integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==", - "dev": true - }, - "character-reference-invalid": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz", - "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", "dev": true }, "chardet": { @@ -28070,7 +30730,7 @@ "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", "dev": true }, "chokidar": { @@ -28096,9 +30756,9 @@ "dev": true }, "chrome-launcher": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.0.tgz", - "integrity": "sha512-ZQqX5kb9H0+jy1OqLnWampfocrtSZaGl7Ny3F9GRha85o4odbL8x55paUzh51UC7cEmZ5obp3H2Mm70uC2PpRA==", + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.1.tgz", + "integrity": "sha512-UugC8u59/w2AyX5sHLZUHoxBAiSiunUhZa3zZwMH6zPVis0C3dDKiRWyUGIo14tTbZHGVviWxv3PQWZ7taZ4fg==", "dev": true, "requires": { "@types/node": "*", @@ -28121,12 +30781,6 @@ "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", "dev": true }, - "circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "dev": true - }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -28139,10 +30793,16 @@ "static-extend": "^0.1.1" }, "dependencies": { + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true + }, "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -28151,7 +30811,7 @@ "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -28160,7 +30820,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -28177,7 +30837,7 @@ "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -28186,7 +30846,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -28217,9 +30877,9 @@ } }, "cli-spinners": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz", - "integrity": "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.7.0.tgz", + "integrity": "sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw==", "dev": true }, "cli-width": { @@ -28229,32 +30889,32 @@ "dev": true }, "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, "requires": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, "clone": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", - "integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", "dev": true }, "clone-buffer": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "integrity": "sha512-KLLTJWrvwIP+OPfMn0x2PheDEP20RPUcGXj/ERegTgdmPEZylALQldygiqrPPu8P45uNuPs7ckmReLY6v/iA5g==", "dev": true }, "clone-response": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", - "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", + "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", "dev": true, "requires": { "mimic-response": "^1.0.0" @@ -28263,7 +30923,7 @@ "clone-stats": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "integrity": "sha512-au6ydSpg6nsrigcZ4m8Bc9hxjeW+GJ8xh5G3BJCMt4WXe1H10UNaVOamqQTmrx1kjVuxAHIQSNU6hY4Nsn9/ag==", "dev": true }, "cloneable-readable": { @@ -28277,22 +30937,16 @@ "readable-stream": "^2.3.5" } }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "integrity": "sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA==", "dev": true }, "collection-map": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-map/-/collection-map-1.0.0.tgz", - "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", + "integrity": "sha512-5D2XXSpkOnleOI21TG7p3T0bGAsZ/XknZpKBmGYyluO8pw4zA3K8ZlrBIbC4FXg3m6z/RNFiUFfT2sQK01+UHA==", "dev": true, "requires": { "arr-map": "^2.0.2", @@ -28303,7 +30957,7 @@ "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "integrity": "sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==", "dev": true, "requires": { "map-visit": "^1.0.0", @@ -28314,7 +30968,6 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, "requires": { "color-name": "1.1.3" } @@ -28322,8 +30975,7 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, "color-support": { "version": "1.1.3", @@ -28347,33 +30999,23 @@ } }, "comma-separated-tokens": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz", - "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.2.tgz", + "integrity": "sha512-G5yTt3KQN4Yn7Yk4ed73hlZ1evrFKXeUW3086p3PRFNp7m2vIjI6Pg+Kgb+oyzhd9F2qdcoj67+y3SdxL5XWsg==", "dev": true }, "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", "dev": true }, - "compare-func": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", - "integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==", - "dev": true, - "requires": { - "array-ify": "^1.0.0", - "dot-prop": "^5.1.0" - } - }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -28408,7 +31050,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "concat-stream": { @@ -28461,10 +31103,40 @@ "ms": "2.0.0" } }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", "dev": true } } @@ -28481,13 +31153,6 @@ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", "requires": { "safe-buffer": "5.2.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - } } }, "content-type": { @@ -28498,339 +31163,28 @@ "continuable-cache": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/continuable-cache/-/continuable-cache-0.3.1.tgz", - "integrity": "sha1-vXJ6f67XfnH/OYWskzUakSczrQ8=", - "dev": true - }, - "conventional-changelog": { - "version": "3.1.24", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-3.1.24.tgz", - "integrity": "sha512-ed6k8PO00UVvhExYohroVPXcOJ/K1N0/drJHx/faTH37OIZthlecuLIRX/T6uOp682CAoVoFpu+sSEaeuH6Asg==", - "dev": true, - "requires": { - "conventional-changelog-angular": "^5.0.12", - "conventional-changelog-atom": "^2.0.8", - "conventional-changelog-codemirror": "^2.0.8", - "conventional-changelog-conventionalcommits": "^4.5.0", - "conventional-changelog-core": "^4.2.1", - "conventional-changelog-ember": "^2.0.9", - "conventional-changelog-eslint": "^3.0.9", - "conventional-changelog-express": "^2.0.6", - "conventional-changelog-jquery": "^3.0.11", - "conventional-changelog-jshint": "^2.0.9", - "conventional-changelog-preset-loader": "^2.3.4" - } - }, - "conventional-changelog-angular": { - "version": "5.0.13", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.13.tgz", - "integrity": "sha512-i/gipMxs7s8L/QeuavPF2hLnJgH6pEZAttySB6aiQLWcX3puWDL3ACVmvBhJGxnAy52Qc15ua26BufY6KpmrVA==", - "dev": true, - "requires": { - "compare-func": "^2.0.0", - "q": "^1.5.1" - } - }, - "conventional-changelog-atom": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-2.0.8.tgz", - "integrity": "sha512-xo6v46icsFTK3bb7dY/8m2qvc8sZemRgdqLb/bjpBsH2UyOS8rKNTgcb5025Hri6IpANPApbXMg15QLb1LJpBw==", - "dev": true, - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-codemirror": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-2.0.8.tgz", - "integrity": "sha512-z5DAsn3uj1Vfp7po3gpt2Boc+Bdwmw2++ZHa5Ak9k0UKsYAO5mH1UBTN0qSCuJZREIhX6WU4E1p3IW2oRCNzQw==", - "dev": true, - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-config-spec": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-config-spec/-/conventional-changelog-config-spec-2.1.0.tgz", - "integrity": "sha512-IpVePh16EbbB02V+UA+HQnnPIohgXvJRxHcS5+Uwk4AT5LjzCZJm5sp/yqs5C6KZJ1jMsV4paEV13BN1pvDuxQ==", - "dev": true - }, - "conventional-changelog-conventionalcommits": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.6.1.tgz", - "integrity": "sha512-lzWJpPZhbM1R0PIzkwzGBCnAkH5RKJzJfFQZcl/D+2lsJxAwGnDKBqn/F4C1RD31GJNn8NuKWQzAZDAVXPp2Mw==", - "dev": true, - "requires": { - "compare-func": "^2.0.0", - "lodash": "^4.17.15", - "q": "^1.5.1" - } - }, - "conventional-changelog-core": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.2.4.tgz", - "integrity": "sha512-gDVS+zVJHE2v4SLc6B0sLsPiloR0ygU7HaDW14aNJE1v4SlqJPILPl/aJC7YdtRE4CybBf8gDwObBvKha8Xlyg==", - "dev": true, - "requires": { - "add-stream": "^1.0.0", - "conventional-changelog-writer": "^5.0.0", - "conventional-commits-parser": "^3.2.0", - "dateformat": "^3.0.0", - "get-pkg-repo": "^4.0.0", - "git-raw-commits": "^2.0.8", - "git-remote-origin-url": "^2.0.0", - "git-semver-tags": "^4.1.1", - "lodash": "^4.17.15", - "normalize-package-data": "^3.0.0", - "q": "^1.5.1", - "read-pkg": "^3.0.0", - "read-pkg-up": "^3.0.0", - "through2": "^4.0.0" - }, - "dependencies": { - "dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", - "dev": true - }, - "hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "normalize-package-data": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", - "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", - "dev": true, - "requires": { - "hosted-git-info": "^4.0.1", - "is-core-module": "^2.5.0", - "semver": "^7.3.4", - "validate-npm-package-license": "^3.0.1" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "dev": true, - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, - "conventional-changelog-ember": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-2.0.9.tgz", - "integrity": "sha512-ulzIReoZEvZCBDhcNYfDIsLTHzYHc7awh+eI44ZtV5cx6LVxLlVtEmcO+2/kGIHGtw+qVabJYjdI5cJOQgXh1A==", - "dev": true, - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-eslint": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-3.0.9.tgz", - "integrity": "sha512-6NpUCMgU8qmWmyAMSZO5NrRd7rTgErjrm4VASam2u5jrZS0n38V7Y9CzTtLT2qwz5xEChDR4BduoWIr8TfwvXA==", - "dev": true, - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-express": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-2.0.6.tgz", - "integrity": "sha512-SDez2f3iVJw6V563O3pRtNwXtQaSmEfTCaTBPCqn0oG0mfkq0rX4hHBq5P7De2MncoRixrALj3u3oQsNK+Q0pQ==", - "dev": true, - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-jquery": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-3.0.11.tgz", - "integrity": "sha512-x8AWz5/Td55F7+o/9LQ6cQIPwrCjfJQ5Zmfqi8thwUEKHstEn4kTIofXub7plf1xvFA2TqhZlq7fy5OmV6BOMw==", - "dev": true, - "requires": { - "q": "^1.5.1" - } - }, - "conventional-changelog-jshint": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-2.0.9.tgz", - "integrity": "sha512-wMLdaIzq6TNnMHMy31hql02OEQ8nCQfExw1SE0hYL5KvU+JCTuPaDO+7JiogGT2gJAxiUGATdtYYfh+nT+6riA==", - "dev": true, - "requires": { - "compare-func": "^2.0.0", - "q": "^1.5.1" - } - }, - "conventional-changelog-preset-loader": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-2.3.4.tgz", - "integrity": "sha512-GEKRWkrSAZeTq5+YjUZOYxdHq+ci4dNwHvpaBC3+ENalzFWuCWa9EZXSuZBpkr72sMdKB+1fyDV4takK1Lf58g==", + "integrity": "sha512-TF30kpKhTH8AGCG3dut0rdd/19B7Z+qCnrMoBLpyQu/2drZdNrrpcjPEoJeSVsQM+8KmWG5O56oPDjSSUsuTyA==", "dev": true }, - "conventional-changelog-writer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-5.0.1.tgz", - "integrity": "sha512-5WsuKUfxW7suLblAbFnxAcrvf6r+0b7GvNaWUwUIk0bXMnENP/PEieGKVUQrjPqwPT4o3EPAASBXiY6iHooLOQ==", - "dev": true, - "requires": { - "conventional-commits-filter": "^2.0.7", - "dateformat": "^3.0.0", - "handlebars": "^4.7.7", - "json-stringify-safe": "^5.0.1", - "lodash": "^4.17.15", - "meow": "^8.0.0", - "semver": "^6.0.0", - "split": "^1.0.0", - "through2": "^4.0.0" - }, - "dependencies": { - "dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", - "dev": true - }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2" - } - } - } - }, - "conventional-commits-filter": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-2.0.7.tgz", - "integrity": "sha512-ASS9SamOP4TbCClsRHxIHXRfcGCnIoQqkvAzCSbZzTFLfcTqJVugB0agRgsEELsqaeWgsXv513eS116wnlSSPA==", - "dev": true, - "requires": { - "lodash.ismatch": "^4.4.0", - "modify-values": "^1.0.0" - } - }, - "conventional-commits-parser": { - "version": "3.2.4", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.2.4.tgz", - "integrity": "sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q==", - "dev": true, - "requires": { - "is-text-path": "^1.0.1", - "JSONStream": "^1.0.4", - "lodash": "^4.17.15", - "meow": "^8.0.0", - "split2": "^3.0.0", - "through2": "^4.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "dev": true, - "requires": { - "readable-stream": "^3.0.0" - } - } - } - }, - "conventional-recommended-bump": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/conventional-recommended-bump/-/conventional-recommended-bump-6.1.0.tgz", - "integrity": "sha512-uiApbSiNGM/kkdL9GTOLAqC4hbptObFo4wW2QRyHsKciGAfQuLU1ShZ1BIVI/+K2BE/W1AWYQMCXAsv4dyKPaw==", - "dev": true, - "requires": { - "concat-stream": "^2.0.0", - "conventional-changelog-preset-loader": "^2.3.4", - "conventional-commits-filter": "^2.0.7", - "conventional-commits-parser": "^3.2.0", - "git-raw-commits": "^2.0.8", - "git-semver-tags": "^4.1.1", - "meow": "^8.0.0", - "q": "^1.5.1" - }, - "dependencies": { - "concat-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", - "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^3.0.2", - "typedarray": "^0.0.6" - } - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, "convert-source-map": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", - "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.1" - } + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, "cookie": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", - "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==" }, "cookie-signature": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "integrity": "sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==", "dev": true }, "copy-props": { @@ -28844,32 +31198,22 @@ } }, "core-js": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.21.1.tgz", - "integrity": "sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig==" + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.26.0.tgz", + "integrity": "sha512-+DkDrhoR4Y0PxDz6rurahuB+I45OsEUv8E1maPTB6OuHRohMMcznBq9TMpdpDMm/hUPob/mJJS3PqgbHpMTQgw==" }, "core-js-compat": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.21.1.tgz", - "integrity": "sha512-gbgX5AUvMb8gwxC7FLVWYT7Kkgu/y7+h/h1X43yJkNqhlK2fuYyQimqvKGNZFAY6CKii/GFKJ2cp/1/42TN36g==", - "dev": true, + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.26.0.tgz", + "integrity": "sha512-piOX9Go+Z4f9ZiBFLnZ5VrOpBl0h7IGCkiFUN11QTe6LjAvOT3ifL/5TdoizMh99hcGy5SoLyWbapIY/PIb/3A==", "requires": { - "browserslist": "^4.19.1", - "semver": "7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true - } + "browserslist": "^4.21.4" } }, "core-js-pure": { - "version": "3.21.1", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.21.1.tgz", - "integrity": "sha512-12VZfFIu+wyVbBebyHmRTuEE/tZrB4tJToWcwAMcsp3h4+sHR+fMJWbKpYiCRWlhFBq+KNyO8rIV9rTkeVmznQ==" + "version": "3.26.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.26.0.tgz", + "integrity": "sha512-LiN6fylpVBVwT8twhhluD9TzXmZQQsr2I2eIKtWNbZI1XMfBT7CV18itaN6RA7EtQd/SDdRx/wzvAShX2HvhQA==" }, "core-util-is": { "version": "1.0.3", @@ -28901,14 +31245,10 @@ } }, "crc-32": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.1.tgz", - "integrity": "sha512-Dn/xm/1vFFgs3nfrpEVScHoIslO9NZRITWGz/1E/St6u4xw99vfZzVkW0OSnzx2h9egej9xwMCEut6sqwokM/w==", - "dev": true, - "requires": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.3.1" - } + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "dev": true }, "crc32-stream": { "version": "4.0.2", @@ -28991,22 +31331,13 @@ "css-value": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", - "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", + "integrity": "sha512-FUV3xaJ63buRLgHrLQVlVgQnQdR4yqdLGaDu7g8CQcWjInDfM9plBTPI9FRfpahju1UBSaMckeb2/46ApS/V1Q==", "dev": true }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "dev": true, - "requires": { - "array-find-index": "^1.0.1" - } - }, "custom-event": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", + "integrity": "sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg==", "dev": true }, "d": { @@ -29019,45 +31350,38 @@ "type": "^1.0.1" } }, - "dargs": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz", - "integrity": "sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==", - "dev": true - }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", "dev": true, "requires": { "assert-plus": "^1.0.0" } }, "date-format": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.4.tgz", - "integrity": "sha512-/jyf4rhB17ge328HJuJjAcmRtCsGd+NDeAtahRBTaK6vSPR6MO5HlrAit3Nn7dVjaa6sowW0WXt8yQtLyZQFRg==", + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", + "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", "dev": true }, "dateformat": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", - "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", + "integrity": "sha512-GODcnWq3YGoTnygPfi02ygEiRxqUxpJwuRHjdhJYuxpcZmDq4rjBiXYmbCCzStxo176ixfLT6i4NPwQooRySnw==", "dev": true }, "de-indent": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz", - "integrity": "sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=", + "integrity": "sha512-e/1zu3xH5MQryN2zdVaF0OrdNLUbvWxzMbi+iNA6Bky7l1RoP8a2fIbRocyHclXt/arDrrR6lL3TqFD9pMQTsg==", "dev": true, "optional": true }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "requires": { "ms": "2.1.2" } @@ -29085,33 +31409,24 @@ } }, "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true }, - "decamelize-keys": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", - "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "decode-named-character-reference": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz", + "integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==", "dev": true, "requires": { - "decamelize": "^1.1.0", - "map-obj": "^1.0.0" - }, - "dependencies": { - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - } + "character-entities": "^2.0.0" } }, "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", "dev": true }, "decompress-response": { @@ -29187,13 +31502,13 @@ "default-resolution": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/default-resolution/-/default-resolution-2.0.0.tgz", - "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=", + "integrity": "sha512-2xaP6GiwVwOEbXCGoJ4ufgC76m8cj805jrghScewJC2ZDsb9U0b4BIrba+xt/Uytyd0HvQ6+WymSRTfnYj59GQ==", "dev": true }, "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", + "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", "dev": true, "requires": { "clone": "^1.0.2" @@ -29202,7 +31517,7 @@ "clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", "dev": true } } @@ -29214,12 +31529,13 @@ "dev": true }, "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", "dev": true, "requires": { - "object-keys": "^1.0.12" + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" } }, "define-property": { @@ -29232,120 +31548,250 @@ "isobject": "^3.0.1" } }, - "defined": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "dev": true }, "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, + "dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true }, "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, "detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", - "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "integrity": "sha512-DtCOLG98P007x7wiiOmfI0fi3eIKyWiLTGJ2MDnVi/E04lWGbf+JzrRHMm0rgIIZJGtHpKpbVgLWHrv8xXpc3Q==", "dev": true }, "detect-indent": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", - "integrity": "sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==", - "dev": true + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==", + "dev": true, + "requires": { + "repeating": "^2.0.0" + } }, "detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", "dev": true }, "detect-newline": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", - "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=", + "integrity": "sha512-CwffZFvlJffUg9zZA0uqrjQayUTC8ob94pnr5sFwaVv3IOmkfUHcWH+jXaQK3askE51Cqe8/9Ql/0uXNwqZ8Zg==", "dev": true }, - "detective": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", - "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", - "dev": true, - "requires": { - "acorn-node": "^1.6.1", - "defined": "^1.0.0", - "minimist": "^1.1.1" - } - }, "devtools": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.16.16.tgz", - "integrity": "sha512-M0kzkuSgfEhpqIis3gdtWsNjn/HQ+vRAmEzDnbYx/7FfjFxhSv1d+rOOT20pvd60soItMYpsOova1igACEGkGQ==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/devtools/-/devtools-7.25.4.tgz", + "integrity": "sha512-R6/S/dCqxoX4Y6PxIGM9JFAuSRZzUeV5r+CoE/frhmno6mTe7dEEgwkJlfit3LkKRoul8n4DsL2A3QtWOvq5IA==", "dev": true, "requires": { - "@types/node": "^17.0.4", + "@types/node": "^18.0.0", "@types/ua-parser-js": "^0.7.33", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/protocols": "7.16.7", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.25.4", + "@wdio/logger": "7.19.0", + "@wdio/protocols": "7.22.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", "chrome-launcher": "^0.15.0", "edge-paths": "^2.1.0", "puppeteer-core": "^13.1.3", "query-selector-shadow-dom": "^1.0.0", "ua-parser-js": "^1.0.1", - "uuid": "^8.0.0" + "uuid": "^9.0.0" }, "dependencies": { + "@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "dev": true + }, + "@wdio/config": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.25.4.tgz", + "integrity": "sha512-vb0emDtD9FbFh/yqW6oNdo2iuhQp8XKj6GX9fyy9v4wZgg3B0HPMVJxhIfcoHz7LMBWlHSo9YdvhFI5EQHRLBA==", + "dev": true, + "requires": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", + "deepmerge": "^4.0.0", + "glob": "^8.0.3" + } + }, + "@wdio/logger": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.19.0.tgz", + "integrity": "sha512-xR7SN/kGei1QJD1aagzxs3KMuzNxdT/7LYYx+lt6BII49+fqL/SO+5X0FDCZD0Ds93AuQvvz9eGyzrBI2FFXmQ==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/protocols": { + "version": "7.22.0", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.22.0.tgz", + "integrity": "sha512-8EXRR+Ymdwousm/VGtW3H1hwxZ/1g1H99A1lF0U4GuJ5cFWHCd0IVE5H31Z52i8ZruouW8jueMkGZPSo2IIUSQ==", + "dev": true + }, + "@wdio/types": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.25.4.tgz", + "integrity": "sha512-muvNmq48QZCvocctnbe0URq2FjJjUPIG4iLoeMmyF0AQgdbjaUkMkw3BHYNHVTbSOU9WMsr2z8alhj/I2H6NRQ==", + "dev": true, + "requires": { + "@types/node": "^18.0.0", + "got": "^11.8.1" + } + }, + "@wdio/utils": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.25.4.tgz", + "integrity": "sha512-8iwQDk+foUqSzKZKfhLxjlCKOkfRJPNHaezQoevNgnrTq/t0ek+ldZCATezb9B8jprAuP4mgS9xi22akc6RkzA==", + "dev": true, + "requires": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "p-iteration": "^1.1.8" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, "ua-parser-js": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz", - "integrity": "sha512-00y/AXhx0/SsnI51fTc0rLRmafiGOM4/O+ny10Ps7f+j/b8p/ZY11ytMgznXkOVo4GQ+KwQG5UQLkLGirsACRg==", + "version": "1.0.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.33.tgz", + "integrity": "sha512-RqshF7TPTE0XLYAqmjlu5cLLuGdKrNu9O1KLA/qp39QtbZwuzwv1dT46DZSopoUMsYgXpB3Cv8a03FI8b74oFQ==", "dev": true }, "uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", "dev": true } } }, "devtools-protocol": { - "version": "0.0.973690", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.973690.tgz", - "integrity": "sha512-myh3hSFp0YWa2GED11PmbLhV4dv9RdO7YUz27XJrbQLnP5bMbZL6dfOOILTHO57yH0kX5GfuOZBsg/4NamfPvQ==", + "version": "0.0.1061995", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1061995.tgz", + "integrity": "sha512-pKZZWTjWa/IF4ENCg6GN8bu/AxSZgdhjSa26uc23wz38Blt2Tnm9icOPcSG3Cht55rMq35in1w3rWVPcZ60ArA==", "dev": true }, "di": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", + "integrity": "sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA==", "dev": true }, "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true }, "diff-sequences": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-27.5.1.tgz", - "integrity": "sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", + "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==", "dev": true }, "dlv": { @@ -29372,242 +31818,117 @@ } }, "documentation": { - "version": "13.2.5", - "resolved": "https://registry.npmjs.org/documentation/-/documentation-13.2.5.tgz", - "integrity": "sha512-d1TrfrHXYZR63xrOzkYwwe297vkSwBoEhyyMBOi20T+7Ohe1aX1dW4nqXncQmdmE5MxluSaxxa3BW1dCvbF5AQ==", - "dev": true, - "requires": { - "@babel/core": "7.12.3", - "@babel/generator": "7.12.1", - "@babel/parser": "7.12.3", - "@babel/traverse": "^7.12.1", - "@babel/types": "^7.12.1", - "@vue/compiler-sfc": "^3.0.11", - "ansi-html": "^0.0.7", - "babelify": "^10.0.0", - "chalk": "^2.3.0", - "chokidar": "^3.4.0", - "concat-stream": "^1.6.0", - "diff": "^4.0.1", + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/documentation/-/documentation-14.0.1.tgz", + "integrity": "sha512-Y/brACCE3sNnDJPFiWlhXrqGY+NelLYVZShLGse5bT1KdohP4JkPf5T2KNq1YWhIEbDYl/1tebRLC0WYbPQxVw==", + "dev": true, + "requires": { + "@babel/core": "^7.18.10", + "@babel/generator": "^7.18.10", + "@babel/parser": "^7.18.11", + "@babel/traverse": "^7.18.11", + "@babel/types": "^7.18.10", + "@vue/compiler-sfc": "^3.2.37", + "chalk": "^5.0.1", + "chokidar": "^3.5.3", + "diff": "^5.1.0", "doctrine-temporary-fork": "2.1.0", - "get-port": "^5.0.0", - "git-url-parse": "^11.1.2", - "github-slugger": "1.2.0", - "glob": "^7.1.2", - "globals-docs": "^2.4.0", - "highlight.js": "^10.7.2", - "ini": "^1.3.5", - "js-yaml": "^3.10.0", - "lodash": "^4.17.10", - "mdast-util-find-and-replace": "^1.1.1", + "git-url-parse": "^13.1.0", + "github-slugger": "1.4.0", + "glob": "^8.0.3", + "globals-docs": "^2.4.1", + "highlight.js": "^11.6.0", + "ini": "^3.0.0", + "js-yaml": "^4.1.0", + "konan": "^2.1.1", + "lodash": "^4.17.21", + "mdast-util-find-and-replace": "^2.2.1", "mdast-util-inject": "^1.1.0", - "micromatch": "^3.1.5", - "mime": "^2.2.0", - "module-deps-sortable": "^5.0.3", + "micromark-util-character": "^1.1.0", "parse-filepath": "^1.0.2", - "pify": "^5.0.0", - "read-pkg-up": "^4.0.0", - "remark": "^13.0.0", - "remark-gfm": "^1.0.0", - "remark-html": "^13.0.1", - "remark-reference-links": "^5.0.0", - "remark-toc": "^7.2.0", - "resolve": "^1.8.1", - "stream-array": "^1.1.2", - "strip-json-comments": "^2.0.1", - "tiny-lr": "^1.1.0", - "unist-builder": "^2.0.3", - "unist-util-visit": "^2.0.3", - "vfile": "^4.0.0", - "vfile-reporter": "^6.0.0", - "vfile-sort": "^2.1.0", - "vinyl": "^2.1.0", - "vinyl-fs": "^3.0.2", - "vue-template-compiler": "^2.6.12", - "yargs": "^15.3.1" - }, - "dependencies": { - "@babel/core": { - "version": "7.12.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.12.3.tgz", - "integrity": "sha512-0qXcZYKZp3/6N2jKYVxZv0aNCsxTSVCiK72DTiTYZAu7sjg73W0/aynWjMbiGd87EQL4WyA8reiJVh92AVla9g==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.10.4", - "@babel/generator": "^7.12.1", - "@babel/helper-module-transforms": "^7.12.1", - "@babel/helpers": "^7.12.1", - "@babel/parser": "^7.12.3", - "@babel/template": "^7.10.4", - "@babel/traverse": "^7.12.1", - "@babel/types": "^7.12.1", - "convert-source-map": "^1.7.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.1", - "json5": "^2.1.2", - "lodash": "^4.17.19", - "resolve": "^1.3.2", - "semver": "^5.4.1", - "source-map": "^0.5.0" - } - }, - "@babel/generator": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.1.tgz", - "integrity": "sha512-DB+6rafIdc9o72Yc3/Ph5h+6hUjeOp66pF0naQBgUFFuPqzQwIlPTm3xZR7YNvduIMtkDIj2t21LSQwnbCrXvg==", - "dev": true, - "requires": { - "@babel/types": "^7.12.1", - "jsesc": "^2.5.1", - "source-map": "^0.5.0" - } - }, - "@babel/parser": { - "version": "7.12.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.3.tgz", - "integrity": "sha512-kFsOS0IbsuhO5ojF8Hc8z/8vEIOkylVBrjiZUbLTE3XFe0Qi+uu6HjzQixkFaqr0ZPAMZcBVxEwmsnsLPZ2Xsw==", + "pify": "^6.0.0", + "read-pkg-up": "^9.1.0", + "remark": "^14.0.2", + "remark-gfm": "^3.0.1", + "remark-html": "^15.0.1", + "remark-reference-links": "^6.0.1", + "remark-toc": "^8.0.1", + "resolve": "^1.22.1", + "strip-json-comments": "^5.0.0", + "unist-builder": "^3.0.0", + "unist-util-visit": "^4.1.0", + "vfile": "^5.3.4", + "vfile-reporter": "^7.0.4", + "vfile-sort": "^3.0.0", + "vue-template-compiler": "^2.7.8", + "yargs": "^17.5.1" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "color-convert": { + "brace-expansion": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "requires": { - "color-name": "~1.1.4" + "balanced-match": "^1.0.0" } }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "chalk": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.1.2.tgz", + "integrity": "sha512-E5CkT4jWURs1Vy5qGJye+XwCkNj7Od3Af7CP6SujMetSMkLs8Do2RWJK5yx1wamHV/op8Rz+9rltjaTQWDnEFQ==", "dev": true }, - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", "dev": true, "requires": { - "p-try": "^2.0.0" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" } }, - "p-locate": { + "js-yaml": { "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { - "p-limit": "^2.2.0" + "argparse": "^2.0.1" } }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" + "brace-expansion": "^2.0.1" } }, - "y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true - }, "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", "dev": true, "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - } - }, - "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.0.0" } } } @@ -29615,7 +31936,7 @@ "dom-serialize": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", + "integrity": "sha512-Yra4DbvoW7/Z6LBN560ZwXMjoNOSAN2wRsKFGc4iBeso+mpIA6qj1vfdf9HpMaKAqG6wXTy+1SYEzmNpKXOSsQ==", "dev": true, "requires": { "custom-event": "~1.0.0", @@ -29624,74 +31945,16 @@ "void-elements": "^2.0.0" } }, - "dot-prop": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", - "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", - "dev": true, - "requires": { - "is-obj": "^2.0.0" - } - }, - "dotgitignore": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/dotgitignore/-/dotgitignore-2.1.0.tgz", - "integrity": "sha512-sCm11ak2oY6DglEPpCB8TixLjWAxd3kJTs6UIcSasNYxXdFPV+YKlye92c8H4kKFqV5qYMIh7d+cYecEg0dIkA==", - "dev": true, - "requires": { - "find-up": "^3.0.0", - "minimatch": "^3.0.4" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - } - } + "dom-walk": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", + "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==", + "dev": true }, "dset": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/dset/-/dset-2.0.1.tgz", - "integrity": "sha512-nI29OZMRYq36hOcifB6HTjajNAAiBKSXsyWZrq+VniusseuP2OpNlTiYgsaNRSGvpyq5Wjbc2gQLyBdTyWqhnQ==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.2.tgz", + "integrity": "sha512-g/M9sqy3oHe477Ar4voQxWtaPIFw1jTdKZuomOjhCcBx9nHUNn0pu6NopuFFrTh/TRZIKEj+76vLWFu9BNKk+Q==" }, "duplexer": { "version": "0.1.2", @@ -29700,12 +31963,38 @@ "dev": true }, "duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha512-+AWBwjGadtksxjOQSFDhPNQbed7icNXApT4+2BNpsXzcCBiInq2H9XW0O8sfHFaPmnQRs7cg/P0fAr2IWQSW0g==", "dev": true, "requires": { - "readable-stream": "^2.0.2" + "readable-stream": "~1.1.9" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", + "dev": true + } } }, "duplexify": { @@ -29754,6 +32043,12 @@ } } }, + "eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "easy-table": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/easy-table/-/easy-table-1.2.0.tgz", @@ -29767,7 +32062,7 @@ "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", - "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", "dev": true, "requires": { "jsbn": "~0.1.0", @@ -29787,27 +32082,26 @@ "ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "ejs": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.6.tgz", - "integrity": "sha512-9lt9Zse4hPucPkoP7FHDF0LQAlGyF9JVpnClFLFH3aSSbxmyoqINRpp/9wePWJTUl4KOQwRL72Iw3InHPDkoGw==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.8.tgz", + "integrity": "sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ==", "dev": true, "requires": { - "jake": "^10.6.1" + "jake": "^10.8.5" } }, "electron-to-chromium": { - "version": "1.4.78", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.78.tgz", - "integrity": "sha512-o61+D/Lx7j/E0LIin/efOqeHpXhwi1TaQco9vUcRmr91m25SfZY6L5hWJDv/r+6kNjboFKgBw1LbfM0lbhuK6Q==", - "dev": true + "version": "1.4.284", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz", + "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==" }, "emoji-regex": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.1.1.tgz", - "integrity": "sha1-xs0OwbBkLio8Z6ETfvxeeW2k+I4=", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "emojis-list": { @@ -29819,7 +32113,7 @@ "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" }, "end-of-stream": { "version": "1.4.4", @@ -29831,9 +32125,9 @@ } }, "engine.io": { - "version": "6.1.3", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.1.3.tgz", - "integrity": "sha512-rqs60YwkvWTLLnfazqgZqLa/aKo+9cueVfEi/dZ8PyGyaf8TLOxj++4QMIgeG3Gn0AhrWiFXvghsoY9L9h25GA==", + "version": "6.4.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.2.tgz", + "integrity": "sha512-FKn/3oMiJjrOEOeUub2WCox6JhxBXq/Zn3fZOMCBxKnNYtsdKjxhl7yR3fZhM9PV+rdE75SU5SYMc+2PGzo+Tg==", "dev": true, "requires": { "@types/cookie": "^0.4.1", @@ -29845,22 +32139,27 @@ "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.0.3", - "ws": "~8.2.3" + "ws": "~8.11.0" + }, + "dependencies": { + "cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "dev": true + } } }, "engine.io-parser": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.3.tgz", - "integrity": "sha512-BtQxwF27XUNnSafQLvDi0dQ8s3i6VgzSoQMJacpIcGNrlUdfHSKbgm3jmjCVvQluGzqwujQMPAoMai3oYSTurg==", - "dev": true, - "requires": { - "@socket.io/base64-arraybuffer": "~1.0.2" - } + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.6.tgz", + "integrity": "sha512-tjuoZDMAdEhVnSFleYPCtdL2GXwVTGtNjoeJd9IhIG3C1xs9uwxqRNEu5WpnDZCaozwVlK/nuQhpodhXSIMaxw==", + "dev": true }, "enhanced-resolve": { - "version": "5.9.2", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.9.2.tgz", - "integrity": "sha512-GIm3fQfwLJ8YZx2smuHpBKkXC1yOk+OBEmKckVyL0i/ea8mqDEykK3ld5dgH1QYPNyT/lIllxV2LULnxCHaHkA==", + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", + "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==", "dev": true, "requires": { "graceful-fs": "^4.2.4", @@ -29879,7 +32178,7 @@ "ent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", - "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", + "integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==", "dev": true }, "errno": { @@ -29910,31 +32209,35 @@ } }, "es-abstract": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", - "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.4.tgz", + "integrity": "sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA==", "dev": true, "requires": { "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.1.3", "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.2", + "has-property-descriptors": "^1.0.0", + "has-symbols": "^1.0.3", "internal-slot": "^1.0.3", - "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.1", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", "is-regex": "^1.1.4", - "is-shared-array-buffer": "^1.0.1", + "is-shared-array-buffer": "^1.0.2", "is-string": "^1.0.7", - "is-weakref": "^1.0.1", - "object-inspect": "^1.11.0", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.2", "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.4.3", + "safe-regex-test": "^1.0.0", + "string.prototype.trimend": "^1.0.5", + "string.prototype.trimstart": "^1.0.5", + "unbox-primitive": "^1.0.2" } }, "es-get-iterator": { @@ -29959,6 +32262,15 @@ "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", "dev": true }, + "es-shim-unscopables": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", + "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", @@ -29971,9 +32283,9 @@ } }, "es5-ext": { - "version": "0.10.57", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.57.tgz", - "integrity": "sha512-L7cCNoPwTkAp7IBHxrKLsh7NKiVFkcdxlP9vbVw9QUvb7gF0Mz9bEBN0WY9xqdTjGF907EMT/iG013vnbqwu1Q==", + "version": "0.10.62", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.62.tgz", + "integrity": "sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA==", "dev": true, "requires": { "es6-iterator": "^2.0.3", @@ -29982,15 +32294,15 @@ } }, "es5-shim": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.6.5.tgz", - "integrity": "sha512-vfQ4UAai8szn0sAubCy97xnZ4sJVDD1gt/Grn736hg8D7540wemIb1YPrYZSTqlM2H69EQX1or4HU/tSwRTI3w==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.6.7.tgz", + "integrity": "sha512-jg21/dmlrNQI7JyyA2w7n+yifSxBng0ZralnSfVZjoCawgNTCnS+yBCyVM9DL5itm7SUnDGgv7hcq2XCZX4iRQ==", "dev": true }, "es6-iterator": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "integrity": "sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g==", "dev": true, "requires": { "d": "1", @@ -30001,7 +32313,7 @@ "es6-object-assign": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", - "integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=", + "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==", "dev": true }, "es6-promise": { @@ -30013,7 +32325,7 @@ "es6-promisify": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", "dev": true, "requires": { "es6-promise": "^4.0.3" @@ -30044,24 +32356,22 @@ "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==" }, "escodegen": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", - "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "integrity": "sha512-yhi5S+mNTOuRvyW4gWlg5W1byMaQGWWSYHXsuFZ7GBo7tpyOwi2EdzMP/QWxh9hwkD2m+wDVHJsxhRIj+v/b/A==", "dev": true, "requires": { "esprima": "^2.7.1", @@ -30074,13 +32384,13 @@ "estraverse": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", - "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "integrity": "sha512-25w1fMXQrGdoquWnScXZGckOv+Wes+JDnuN/+7ex3SauFRS72r2lFDec0EKPt2YD1wUJ/IrfEex+9yp4hfSOJA==", "dev": true }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", "dev": true, "requires": { "prelude-ls": "~1.1.2", @@ -30104,13 +32414,13 @@ "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", "dev": true }, "source-map": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", - "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "integrity": "sha512-CBdZ2oa/BHhS4xj5DlhjWNHcan57/5YuvfdLf17iVmIpd9KRm+DFLmC6nBNj+6Ua7Kt3TmOjDpQT1aTYOQtoUA==", "dev": true, "optional": true, "requires": { @@ -30120,7 +32430,7 @@ "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", "dev": true, "requires": { "prelude-ls": "~1.1.2" @@ -30185,18 +32495,6 @@ "@babel/highlight": "^7.10.4" } }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -30238,18 +32536,24 @@ "dev": true }, "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "version": "13.17.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", + "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", "dev": true, "requires": { "type-fest": "^0.20.2" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -30281,7 +32585,7 @@ "eslint-config-standard": { "version": "10.2.1", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz", - "integrity": "sha1-wGHk0GbzedwXzVYsZOgZtN1FRZE=", + "integrity": "sha512-UkFojTV1o0GOe1edOEiuI5ccYLJSuNngtqSeClNzhsmG8KPJ+7mRxgtp2oYhqZAK/brlXMoCd+VgXViE0AfyKw==", "dev": true, "requires": {} }, @@ -30307,13 +32611,12 @@ } }, "eslint-module-utils": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.3.tgz", - "integrity": "sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==", + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz", + "integrity": "sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==", "dev": true, "requires": { - "debug": "^3.2.7", - "find-up": "^2.1.0" + "debug": "^3.2.7" }, "dependencies": { "debug": { @@ -30338,9 +32641,9 @@ } }, "eslint-plugin-import": { - "version": "2.25.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz", - "integrity": "sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==", + "version": "2.26.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz", + "integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==", "dev": true, "requires": { "array-includes": "^3.1.4", @@ -30348,14 +32651,14 @@ "debug": "^2.6.9", "doctrine": "^2.1.0", "eslint-import-resolver-node": "^0.3.6", - "eslint-module-utils": "^2.7.2", + "eslint-module-utils": "^2.7.3", "has": "^1.0.3", - "is-core-module": "^2.8.0", + "is-core-module": "^2.8.1", "is-glob": "^4.0.3", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "object.values": "^1.1.5", - "resolve": "^1.20.0", - "tsconfig-paths": "^3.12.0" + "resolve": "^1.22.0", + "tsconfig-paths": "^3.14.1" }, "dependencies": { "debug": { @@ -30379,7 +32682,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } @@ -30478,7 +32781,7 @@ "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "integrity": "sha512-OarPfz0lFCiW4/AV2Oy1Rp9qu0iusTKqykwTspGCZtPxmF81JR4MmIebvF1F9+UOKth2ZubLQ4XGGaU+hSn99A==", "dev": true }, "esquery": { @@ -30531,18 +32834,17 @@ "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "integrity": "sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==", "dev": true, "requires": { "d": "1", @@ -30552,7 +32854,7 @@ "event-stream": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "integrity": "sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==", "dev": true, "requires": { "duplexer": "~0.1.1", @@ -30567,7 +32869,7 @@ "map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "integrity": "sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==", "dev": true } } @@ -30615,19 +32917,19 @@ "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", "dev": true }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", "dev": true, "requires": { "shebang-regex": "^1.0.0" @@ -30636,7 +32938,7 @@ "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", "dev": true }, "which": { @@ -30650,16 +32952,10 @@ } } }, - "exit-on-epipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==", - "dev": true - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "integrity": "sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==", "dev": true, "requires": { "debug": "^2.3.3", @@ -30683,7 +32979,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -30692,7 +32988,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -30701,7 +32997,7 @@ "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -30710,7 +33006,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -30727,7 +33023,7 @@ "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -30736,7 +33032,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -30758,13 +33054,13 @@ "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } @@ -30772,66 +33068,95 @@ "expand-tilde": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "integrity": "sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw==", "dev": true, "requires": { "homedir-polyfill": "^1.0.1" } }, "expect": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-27.5.1.tgz", - "integrity": "sha512-E1q5hSUG2AmYQwQJ041nvgpkODHQvB+RKlB4IYdru6uJsyFTRyZAP463M+1lINorwbqAmUggi6+WwkD8lCS/Dw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-26.6.2.tgz", + "integrity": "sha512-9/hlOBkQl2l/PLHJx6JjoDF6xPKcJEsUlWKb23rKE7KzeDqUZKXKNMW27KIue5JMdBV9HgmoJPcc8HtO85t9IA==", "dev": true, "requires": { - "@jest/types": "^27.5.1", - "jest-get-type": "^27.5.1", - "jest-matcher-utils": "^27.5.1", - "jest-message-util": "^27.5.1" + "@jest/types": "^26.6.2", + "ansi-styles": "^4.0.0", + "jest-get-type": "^26.3.0", + "jest-matcher-utils": "^26.6.2", + "jest-message-util": "^26.6.2", + "jest-regex-util": "^26.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + } } }, "expect-webdriverio": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/expect-webdriverio/-/expect-webdriverio-3.1.4.tgz", - "integrity": "sha512-65FTS3bmxcIp0cq6fLb/72TrCQXBCpwPLC7SwMWdpPlLq461mXcK1BPKJJjnIC587aXSKD+3E4hvnlCtwDmXfg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expect-webdriverio/-/expect-webdriverio-2.0.2.tgz", + "integrity": "sha512-dst0tqP1aZ2p7TPmbatqoIQ+7hRTw+IeKNi830XxKhu2DNNe5vQ85i9ttf9rpXgbnUf91HxKcocn4G7A5bQxDA==", "dev": true, "requires": { - "expect": "^27.0.2", - "jest-matcher-utils": "^27.0.2" + "expect": "^26.6.2", + "jest-matcher-utils": "^26.6.2" } }, "express": { - "version": "4.17.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.3.tgz", - "integrity": "sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg==", + "version": "4.18.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", + "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.19.2", + "body-parser": "1.20.1", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.4.2", + "cookie": "0.5.0", "cookie-signature": "1.0.6", "debug": "2.6.9", - "depd": "~1.1.2", + "depd": "2.0.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "~1.1.2", + "finalhandler": "1.2.0", "fresh": "0.5.2", + "http-errors": "2.0.0", "merge-descriptors": "1.0.1", "methods": "~1.1.2", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", "path-to-regexp": "0.1.7", "proxy-addr": "~2.0.7", - "qs": "6.9.7", + "qs": "6.11.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.17.2", - "serve-static": "1.14.2", + "send": "0.18.0", + "serve-static": "1.15.0", "setprototypeof": "1.2.0", - "statuses": "~1.5.0", + "statuses": "2.0.1", "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" @@ -30848,28 +33173,23 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, "ext": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/ext/-/ext-1.6.0.tgz", - "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/ext/-/ext-1.7.0.tgz", + "integrity": "sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw==", "dev": true, "requires": { - "type": "^2.5.0" + "type": "^2.7.2" }, "dependencies": { "type": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz", - "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==", + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/type/-/type-2.7.2.tgz", + "integrity": "sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw==", "dev": true } } @@ -30881,13 +33201,20 @@ "dev": true }, "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz", + "integrity": "sha512-L7AGmkO6jhDkEBBGWlLtftA80Xq8DipnrRPr0pyi7GQLXkaq9JYA4xF4z6qnadIC6euiTDKco0cGSU9muw+WTw==", "dev": true, "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" + "kind-of": "^1.1.0" + }, + "dependencies": { + "kind-of": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", + "integrity": "sha512-aUH6ElPnMGon2/YkxRIigV32MOpTVcoXQ1Oo8aYn40s+sJ3j+0gFZsT8HKDcxNy7Fi9zuquWtGaGAahOdv5p/g==", + "dev": true + } } }, "external-editor": { @@ -30920,7 +33247,7 @@ "define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "requires": { "is-descriptor": "^1.0.0" @@ -30929,7 +33256,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -30938,7 +33265,7 @@ "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true } } @@ -30969,7 +33296,7 @@ "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", "dev": true }, "faker": { @@ -31005,13 +33332,13 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "faye-websocket": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", - "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=", + "integrity": "sha512-Xhj93RXbMSq8urNCUq4p9l0P6hnySJ/7YNRhYNug0bLOuii7pKO7xQFb5mx9xZXWCar88pLPb805PvUkwrLZpQ==", "dev": true, "requires": { "websocket-driver": ">=0.5.1" @@ -31020,16 +33347,16 @@ "fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", "dev": true, "requires": { "pend": "~1.2.0" } }, "fibers": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.1.tgz", - "integrity": "sha512-VMC7Frt87Oo0AOJ6EcPFbi+tZmkQ4tD85aatwyWL6I9cYMJmm2e+pXUJsfGZ36U7MffXtjou2XIiWJMtHriErw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/fibers/-/fibers-5.0.3.tgz", + "integrity": "sha512-/qYTSoZydQkM21qZpGLDLuCq8c+B8KhuCQ1kLPvnRNhxhVbvrpmH9l2+Lblf5neDuEsY4bfT7LeO553TXQDvJw==", "dev": true, "requires": { "detect-libc": "^1.0.3" @@ -31061,12 +33388,32 @@ "optional": true }, "filelist": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.2.tgz", - "integrity": "sha512-z7O0IS8Plc39rTCq6i6iHxk43duYOn8uFJiWSewIq0Bww1RNybVHSCjahmcC87ZqAm4OTvFzlzeGu3XAzG1ctQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", "dev": true, "requires": { - "minimatch": "^3.0.4" + "minimatch": "^5.0.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "fill-range": { @@ -31078,23 +33425,17 @@ "to-regex-range": "^5.0.1" } }, - "filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=", - "dev": true - }, "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "requires": { "debug": "2.6.9", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "parseurl": "~1.3.3", - "statuses": "~1.5.0", + "statuses": "2.0.1", "unpipe": "~1.0.0" }, "dependencies": { @@ -31109,7 +33450,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, @@ -31125,12 +33466,13 @@ } }, "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", "dev": true, "requires": { - "locate-path": "^2.0.0" + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" } }, "findup-sync": { @@ -31143,6 +33485,151 @@ "is-glob": "^4.0.0", "micromatch": "^3.0.4", "resolve-dir": "^1.0.1" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true + } + } + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true + } + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + } } }, "fined": { @@ -31192,9 +33679,9 @@ } }, "flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", "dev": true }, "flush-write-stream": { @@ -31208,48 +33695,51 @@ } }, "follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true }, + "for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "requires": { + "is-callable": "^1.1.3" + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==", "dev": true }, "for-own": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", - "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "integrity": "sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==", "dev": true, "requires": { "for-in": "^1.0.1" } }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, "foreachasync": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/foreachasync/-/foreachasync-3.0.0.tgz", - "integrity": "sha1-VQKYfchxS+M5IJfzLgBxyd7gfPY=", + "integrity": "sha512-J+ler7Ta54FwwNcx6wQRDhTIbNeyDcARMkOcguEqnEdtm0jKvN3Li3PDAb2Du3ubJYEWfYL83XMROXdsXAXycw==", "dev": true }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", "dev": true }, "fork-stream": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/fork-stream/-/fork-stream-0.0.4.tgz", - "integrity": "sha1-24Sfznf2cIpfjzhq5TOgkHtUrnA=", + "integrity": "sha512-Pqq5NnT78ehvUnAk/We/Jr22vSvanRlFTpAmQ88xBY/M1TlHe+P0ILuEyXS595ysdGfaj22634LBkGMA2GTcpA==", "dev": true }, "form-data": { @@ -31271,7 +33761,7 @@ "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "integrity": "sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==", "dev": true, "requires": { "map-cache": "^0.2.2" @@ -31280,23 +33770,14 @@ "fresh": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" }, "from": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "integrity": "sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==", "dev": true }, - "fs-access": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", - "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", - "dev": true, - "requires": { - "null-check": "^1.0.0" - } - }, "fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -31304,9 +33785,9 @@ "dev": true }, "fs-extra": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz", - "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, "requires": { "graceful-fs": "^4.2.0", @@ -31317,7 +33798,7 @@ "fs-mkdirp-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz", - "integrity": "sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes=", + "integrity": "sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ==", "dev": true, "requires": { "graceful-fs": "^4.1.11", @@ -31339,7 +33820,7 @@ "fs.extra": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/fs.extra/-/fs.extra-1.3.2.tgz", - "integrity": "sha1-3QI/kwE77iRTHxszUUw3sg/ZM0k=", + "integrity": "sha512-Ig401VXtyrWrz23k9KxAx9OrnL8AHSLNhQ8YJH2wSYuH0ZUfxwBeY6zXkd/oOyVRFTlpEu/0n5gHeuZt7aqbkw==", "dev": true, "requires": { "fs-extra": "~0.6.1", @@ -31350,7 +33831,7 @@ "fs-extra": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.6.4.tgz", - "integrity": "sha1-9G8MdbeEH40gCzNIzU1pHVoJnRU=", + "integrity": "sha512-5rU898vl/Z948L+kkJedbmo/iltzmiF5bn/eEk0j/SgrPpI+Ydau9xlJPicV7Av2CHYBGz5LAlwTnBU80j1zPQ==", "dev": true, "requires": { "jsonfile": "~1.0.1", @@ -31362,19 +33843,19 @@ "jsonfile": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-1.0.1.tgz", - "integrity": "sha1-6l7+QLg2kLmGZ2FKc5L8YOhCwN0=", + "integrity": "sha512-KbsDJNRfRPF5v49tMNf9sqyyGqGLBcz1v5kZT01kG5ns5mQSltwxCKVmUzVKtEinkUnTDtSrp6ngWpV7Xw0ZlA==", "dev": true }, "mkdirp": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz", - "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=", + "integrity": "sha512-8OCq0De/h9ZxseqzCH8Kw/Filf5pF/vMI6+BH7Lu0jXz2pqYCjTAQRolSxRIi+Ax+oCCjlxoJMP0YQ4XlrQNHg==", "dev": true }, "rimraf": { "version": "2.2.8", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", + "integrity": "sha512-R5KMKHnPAQaZMqLOsyuyUmcIjSeDm+73eoqQpaXA7AZ22BL+6C+1mcUscgOsNd8WVlJuvlgAPsegcx7pjlV0Dg==", "dev": true } } @@ -31382,7 +33863,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "fsevents": { @@ -31404,12 +33885,12 @@ }, "dependencies": { "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" } }, "rimraf": { @@ -31434,13 +33915,30 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + } }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", + "dev": true + }, + "functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", "dev": true }, "gaze": { @@ -31455,8 +33953,7 @@ "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "dev": true + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==" }, "get-caller-file": { "version": "2.0.5", @@ -31467,73 +33964,24 @@ "get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", "dev": true }, "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", - "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.3" } }, - "get-pkg-repo": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-4.2.1.tgz", - "integrity": "sha512-2+QbHjFRfGB74v/pYWjd5OhU3TDIC2Gv/YKUTk/tCvAz0pkn/Mz6P3uByuBimLOcPvN2jYdScl3xGFSrx0jEcA==", - "dev": true, - "requires": { - "@hutson/parse-repository-url": "^3.0.0", - "hosted-git-info": "^4.0.0", - "through2": "^2.0.0", - "yargs": "^16.2.0" - }, - "dependencies": { - "hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - } - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true - } - } + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true }, "get-port": { "version": "5.1.1", @@ -31541,12 +33989,6 @@ "integrity": "sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==", "dev": true }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true - }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -31569,128 +34011,53 @@ "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==", "dev": true }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", "dev": true, "requires": { "assert-plus": "^1.0.0" } }, - "git-raw-commits": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-2.0.11.tgz", - "integrity": "sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A==", - "dev": true, - "requires": { - "dargs": "^7.0.0", - "lodash": "^4.17.15", - "meow": "^8.0.0", - "split2": "^3.0.0", - "through2": "^4.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "split2": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", - "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", - "dev": true, - "requires": { - "readable-stream": "^3.0.0" - } - } - } - }, - "git-remote-origin-url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz", - "integrity": "sha1-UoJlna4hBxRaERJhEq0yFuxfpl8=", - "dev": true, - "requires": { - "gitconfiglocal": "^1.0.0", - "pify": "^2.3.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - } - } - }, - "git-semver-tags": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-4.1.1.tgz", - "integrity": "sha512-OWyMt5zBe7xFs8vglMmhM9lRQzCWL3WjHtxNNfJTMngGym7pC1kh8sP6jevfydJ6LP3ZvGxfb6ABYgPUM0mtsA==", - "dev": true, - "requires": { - "meow": "^8.0.0", - "semver": "^6.0.0" - } - }, "git-up": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/git-up/-/git-up-4.0.5.tgz", - "integrity": "sha512-YUvVDg/vX3d0syBsk/CKUTib0srcQME0JyHkL5BaYdwLsiCslPWmDSi8PUMo9pXYjrryMcmsCoCgsTpSCJEQaA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/git-up/-/git-up-7.0.0.tgz", + "integrity": "sha512-ONdIrbBCFusq1Oy0sC71F5azx8bVkvtZtMJAsv+a6lz5YAmbNnLD6HAB4gptHZVLPR8S2/kVN6Gab7lryq5+lQ==", "dev": true, "requires": { - "is-ssh": "^1.3.0", - "parse-url": "^6.0.0" + "is-ssh": "^1.4.0", + "parse-url": "^8.1.0" } }, "git-url-parse": { - "version": "11.6.0", - "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-11.6.0.tgz", - "integrity": "sha512-WWUxvJs5HsyHL6L08wOusa/IXYtMuCAhrMmnTjQPpBU0TTHyDhnOATNH3xNQz7YOQUsqIIPTGr4xiVti1Hsk5g==", + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/git-url-parse/-/git-url-parse-13.1.0.tgz", + "integrity": "sha512-5FvPJP/70WkIprlUZ33bm4UAaFdjcLkJLpWft1BeZKqwR0uhhNGoKwlUaPtVb4LxCSQ++erHapRak9kWGj+FCA==", "dev": true, "requires": { - "git-up": "^4.0.0" - } - }, - "gitconfiglocal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz", - "integrity": "sha1-QdBF84UaXqiPA/JMocYXgRRGS5s=", - "dev": true, - "requires": { - "ini": "^1.3.2" + "git-up": "^7.0.0" } }, "github-slugger": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.2.0.tgz", - "integrity": "sha512-wIaa75k1vZhyPm9yWrD08A5Xnx/V+RmzGrpjQuLemGKSb77Qukiaei58Bogrl/LZSADDfPzKJX8jhLs4CRTl7Q==", - "dev": true, - "requires": { - "emoji-regex": ">=6.0.0 <=6.1.1" - } + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.4.0.tgz", + "integrity": "sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ==", + "dev": true }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -31707,7 +34074,7 @@ "glob-stream": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-6.1.0.tgz", - "integrity": "sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ=", + "integrity": "sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw==", "dev": true, "requires": { "extend": "^3.0.0", @@ -31725,7 +34092,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "requires": { "is-glob": "^3.1.0", @@ -31735,7 +34102,7 @@ "is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "requires": { "is-extglob": "^2.1.0" @@ -31777,7 +34144,7 @@ "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "requires": { "remove-trailing-separator": "^1.0.1" @@ -31785,6 +34152,12 @@ } } }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, "binary-extensions": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", @@ -31832,7 +34205,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -31841,7 +34214,7 @@ "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -31864,7 +34237,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "requires": { "is-glob": "^3.1.0", @@ -31874,7 +34247,7 @@ "is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "requires": { "is-extglob": "^2.1.0" @@ -31885,18 +34258,99 @@ "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "integrity": "sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==", "dev": true, "requires": { "binary-extensions": "^1.0.0" } }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + } + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + }, + "dependencies": { + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + } + } + }, "readdirp": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", @@ -31911,7 +34365,7 @@ "to-regex-range": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", "dev": true, "requires": { "is-number": "^3.0.0", @@ -31920,6 +34374,16 @@ } } }, + "global": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", + "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "dev": true, + "requires": { + "min-document": "^2.19.0", + "process": "^0.11.10" + } + }, "global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", @@ -31934,7 +34398,7 @@ "global-prefix": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "integrity": "sha512-5lsx1NUDHtSjfg0eHlmYvZKv8/nVqX4ckFbM+FrGcQ+04KWcWFo9P5MxPZYSzUvyzmdTbI7Eix8Q4IbELDqzKg==", "dev": true, "requires": { "expand-tilde": "^2.0.2", @@ -31944,6 +34408,12 @@ "which": "^1.2.14" }, "dependencies": { + "ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "dev": true + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -31958,8 +34428,7 @@ "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, "globals-docs": { "version": "2.4.1", @@ -31968,13 +34437,13 @@ "dev": true }, "globule": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.3.tgz", - "integrity": "sha512-mb1aYtDbIjTu4ShMB85m3UzjX9BVKe9WCzsnfMSZk+K5GpIbBOexgg4PPCt5eHDEG5/ZQAUX2Kct02zfiPLsKg==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.3.4.tgz", + "integrity": "sha512-OPTIfhMBh7JbBYDpa5b+Q5ptmMWKwcNcFSR/0c6t8V4f3ZAVBEsKNY37QdVqmLRYSMhOUGYrY0QhSoEpzGr/Eg==", "dev": true, "requires": { "glob": "~7.1.1", - "lodash": "~4.17.10", + "lodash": "^4.17.21", "minimatch": "~3.0.2" }, "dependencies": { @@ -32013,9 +34482,9 @@ } }, "got": { - "version": "11.8.3", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz", - "integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==", + "version": "11.8.5", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.5.tgz", + "integrity": "sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==", "dev": true, "requires": { "@sindresorhus/is": "^4.0.0", @@ -32032,9 +34501,9 @@ } }, "graceful-fs": { - "version": "4.2.9", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", - "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, "grapheme-splitter": { @@ -32062,317 +34531,18 @@ } }, "gulp-clean": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/gulp-clean/-/gulp-clean-0.3.2.tgz", - "integrity": "sha1-o0fUc6zqQBgvk1WHpFGUFnGSgQI=", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/gulp-clean/-/gulp-clean-0.4.0.tgz", + "integrity": "sha512-DARK8rNMo4lHOFLGTiHEJdf19GuoBDHqGUaypz+fOhrvOs3iFO7ntdYtdpNxv+AzSJBx/JfypF0yEj9ks1IStQ==", "dev": true, "requires": { - "gulp-util": "^2.2.14", - "rimraf": "^2.2.8", - "through2": "^0.4.2" + "fancy-log": "^1.3.2", + "plugin-error": "^0.1.2", + "rimraf": "^2.6.2", + "through2": "^2.0.3", + "vinyl": "^2.1.0" }, "dependencies": { - "ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", - "dev": true - }, - "ansi-styles": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true - }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true - }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "requires": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" - } - }, - "chalk": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", - "dev": true, - "requires": { - "ansi-styles": "^1.1.0", - "escape-string-regexp": "^1.0.0", - "has-ansi": "^0.1.0", - "strip-ansi": "^0.3.0", - "supports-color": "^0.2.0" - } - }, - "clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "dateformat": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", - "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", - "dev": true, - "requires": { - "get-stdin": "^4.0.1", - "meow": "^3.3.0" - } - }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "gulp-util": { - "version": "2.2.20", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz", - "integrity": "sha1-1xRuVyiRC9jwR6awseVJvCLb1kw=", - "dev": true, - "requires": { - "chalk": "^0.5.0", - "dateformat": "^1.0.7-1.2.3", - "lodash._reinterpolate": "^2.4.1", - "lodash.template": "^2.4.1", - "minimist": "^0.2.0", - "multipipe": "^0.1.0", - "through2": "^0.5.0", - "vinyl": "^0.2.1" - }, - "dependencies": { - "through2": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", - "integrity": "sha1-390BLrnHAOIyP9M084rGIqs3Lac=", - "dev": true, - "requires": { - "readable-stream": "~1.0.17", - "xtend": "~3.0.0" - } - }, - "xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha1-XM50B7r2Qsunvs2laBEcST9ZZlo=", - "dev": true - } - } - }, - "has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", - "dev": true, - "requires": { - "ansi-regex": "^0.2.0" - } - }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "lodash._reinterpolate": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-2.4.1.tgz", - "integrity": "sha1-TxInqlqHEfxjL1sHofRgequLMiI=", - "dev": true - }, - "lodash.defaults": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-2.4.1.tgz", - "integrity": "sha1-p+iIXwXmiFEUS24SqPNngCa8TFQ=", - "dev": true, - "requires": { - "lodash._objecttypes": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, - "lodash.template": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-2.4.1.tgz", - "integrity": "sha1-nmEQB+32KRKal0qzxIuBez4c8g0=", - "dev": true, - "requires": { - "lodash._escapestringchar": "~2.4.1", - "lodash._reinterpolate": "~2.4.1", - "lodash.defaults": "~2.4.1", - "lodash.escape": "~2.4.1", - "lodash.keys": "~2.4.1", - "lodash.templatesettings": "~2.4.1", - "lodash.values": "~2.4.1" - } - }, - "lodash.templatesettings": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz", - "integrity": "sha1-6nbHXRHrhtTb6JqDiTu4YZKaxpk=", - "dev": true, - "requires": { - "lodash._reinterpolate": "~2.4.1", - "lodash.escape": "~2.4.1" - } - }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - }, - "meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "requires": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", - "dev": true - } - } - }, - "minimist": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.2.1.tgz", - "integrity": "sha512-GY8fANSrTMfBVfInqJAY41QkOM+upUTytK1jZ0c8+3HdHrJxBJ3rF5i9moClXTE8uUSnUo8cAsCoxDXvSY4DHg==", - "dev": true - }, - "object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "requires": { - "error-ex": "^1.2.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" - } - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "dev": true, - "requires": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" - } - }, "rimraf": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", @@ -32382,77 +34552,14 @@ "glob": "^7.1.3" } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "strip-ansi": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", - "dev": true, - "requires": { - "ansi-regex": "^0.2.1" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "requires": { - "get-stdin": "^4.0.1" - } - }, - "supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", - "dev": true - }, "through2": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.4.2.tgz", - "integrity": "sha1-2/WGYDEVHsg1K7bE22SiKSqEC5s=", - "dev": true, - "requires": { - "readable-stream": "~1.0.17", - "xtend": "~2.1.1" - } - }, - "trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true - }, - "vinyl": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.2.3.tgz", - "integrity": "sha1-vKk4IJWC7FpJrVOKAPofEl5RMlI=", - "dev": true, - "requires": { - "clone-stats": "~0.0.1" - } - }, - "xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, "requires": { - "object-keys": "~0.4.0" + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" } } } @@ -32495,19 +34602,19 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "camelcase": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "integrity": "sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg==", "dev": true }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "integrity": "sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w==", "dev": true, "requires": { "string-width": "^1.0.1", @@ -32515,10 +34622,16 @@ "wrap-ansi": "^2.0.0" } }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true + }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "integrity": "sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA==", "dev": true, "requires": { "path-exists": "^2.0.0", @@ -32531,67 +34644,46 @@ "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "integrity": "sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==", "dev": true, "requires": { "number-is-nan": "^1.0.0" } }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { - "error-ex": "^1.2.0" + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" } }, "path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "integrity": "sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ==", "dev": true, "requires": { "pinkie-promise": "^2.0.0" } }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "integrity": "sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ==", "dev": true, "requires": { "load-json-file": "^1.0.0", @@ -32602,23 +34694,23 @@ "read-pkg-up": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "integrity": "sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A==", "dev": true, "requires": { "find-up": "^1.0.0", "read-pkg": "^1.0.0" } }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "integrity": "sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw==", "dev": true, "requires": { "code-point-at": "^1.0.0", @@ -32629,31 +34721,16 @@ "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "which-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", - "dev": true - }, "wrap-ansi": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "integrity": "sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw==", "dev": true, "requires": { "string-width": "^1.0.1", @@ -32702,7 +34779,7 @@ "gulp-concat": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz", - "integrity": "sha1-Yz0WyV2IUEYorQJmVmPO5aR5M1M=", + "integrity": "sha512-a2scActrQrDBpBbR3WUZGyGS1JEPLg5PZJdIa7/Bi3GuKAmPYDK6SFhy/NZq5R8KsKKFvtfR0fakbUCcKGCCjg==", "dev": true, "requires": { "concat-with-sourcemaps": "^1.0.0", @@ -32754,10 +34831,22 @@ "ms": "2.0.0" } }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg==", + "dev": true + }, "http-errors": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", "dev": true, "requires": { "depd": "~1.1.2", @@ -32769,7 +34858,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, "mime": { @@ -32781,9 +34870,18 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } + }, "send": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", @@ -32820,174 +34918,154 @@ } }, "gulp-eslint": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-4.0.2.tgz", - "integrity": "sha512-fcFUQzFsN6dJ6KZlG+qPOEkqfcevRUXgztkYCvhNvJeSvOicC8ucutN4qR/ID8LmNZx9YPIkBzazTNnVvbh8wg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gulp-eslint/-/gulp-eslint-6.0.0.tgz", + "integrity": "sha512-dCVPSh1sA+UVhn7JSQt7KEb4An2sQNbOdB3PA8UCfxsoPlAKjJHxYHGXdXC7eb+V1FAnilSFFqslPrq037l1ig==", "dev": true, "requires": { - "eslint": "^4.0.0", + "eslint": "^6.0.0", "fancy-log": "^1.3.2", - "plugin-error": "^1.0.0" + "plugin-error": "^1.0.1" }, "dependencies": { - "acorn": { - "version": "5.7.4", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", - "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", - "dev": true - }, - "acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", - "dev": true, - "requires": { - "acorn": "^3.0.4" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } - } - }, - "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "dev": true, "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" + "ansi-wrap": "^0.1.0" } }, - "ajv-keywords": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz", - "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=", - "dev": true, - "requires": {} + "ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "dev": true }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", "dev": true }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", "dev": true }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "dev": true }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "color-name": "~1.1.4" } }, - "cli-width": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.1.tgz", - "integrity": "sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==", + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, "requires": { - "lru-cache": "^4.0.1", + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", "shebang-command": "^1.2.0", "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true + } } }, - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true }, "eslint": { - "version": "4.19.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz", - "integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", "dev": true, "requires": { - "ajv": "^5.3.0", - "babel-code-frame": "^6.22.0", + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", "chalk": "^2.1.0", - "concat-stream": "^1.6.0", - "cross-spawn": "^5.1.0", - "debug": "^3.1.0", - "doctrine": "^2.1.0", - "eslint-scope": "^3.7.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^3.5.4", - "esquery": "^1.0.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", "esutils": "^2.0.2", - "file-entry-cache": "^2.0.0", + "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.0.1", - "ignore": "^3.3.3", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^3.0.6", - "is-resolvable": "^1.0.0", - "js-yaml": "^3.9.1", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.4", - "minimatch": "^3.0.2", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "pluralize": "^7.0.0", + "optionator": "^0.8.3", "progress": "^2.0.0", - "regexpp": "^1.0.1", - "require-uncached": "^1.0.3", - "semver": "^5.3.0", - "strip-ansi": "^4.0.0", - "strip-json-comments": "~2.0.1", - "table": "4.0.2", - "text-table": "~0.2.0" + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } } }, - "eslint-scope": { - "version": "3.7.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.3.tgz", - "integrity": "sha512-W+B0SvF4gamyCTmUc+uITPY0989iXVfKvhwtmJocTaYoc/3khEHmEmvfY/Gn9HA9VV75jrQECsHizkNw1b68FA==", + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", "dev": true, "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" + "eslint-visitor-keys": "^1.1.0" } }, "eslint-visitor-keys": { @@ -32997,151 +35075,132 @@ "dev": true }, "espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", "dev": true, "requires": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" + "acorn": "^7.1.1", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.1.0" } }, - "external-editor": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", - "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", "dev": true, "requires": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" } }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", "dev": true, "requires": { - "escape-string-regexp": "^1.0.5" + "flat-cache": "^2.0.1" } }, - "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", "dev": true, "requires": { - "flat-cache": "^1.2.1", - "object-assign": "^4.0.1" + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" } }, - "flat-cache": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz", - "integrity": "sha512-VwyB3Lkgacfik2vhqR4uv2rvebqmDvFu4jlN/C1RzWoJEo8I7z4Q404oiqYCkq41mni8EzQnm95emU9seckwtg==", + "flatted": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "dev": true + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", "dev": true, "requires": { - "circular-json": "^0.3.1", - "graceful-fs": "^4.1.2", - "rimraf": "~2.6.2", - "write": "^0.2.1" + "type-fest": "^0.8.1" } }, - "ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.0.4", - "figures": "^2.0.0", - "lodash": "^4.3.0", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rx-lite": "^4.0.8", - "rx-lite-aggregates": "^4.0.8", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.19", + "mute-stream": "0.0.8", + "run-async": "^2.4.0", + "rxjs": "^6.6.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", "through": "^2.3.6" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + } } }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", "dev": true }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", "dev": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" } }, - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "dev": true, - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" + "minimist": "^1.2.6" } }, "optionator": { @@ -33158,28 +35217,36 @@ "word-wrap": "~1.2.3" } }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", + "dev": true + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", "dev": true }, "regexpp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz", - "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - } - }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -33189,16 +35256,10 @@ "glob": "^7.1.3" } }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", "dev": true, "requires": { "shebang-regex": "^1.0.0" @@ -33207,60 +35268,84 @@ "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", "dev": true }, "slice-ansi": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", - "integrity": "sha512-POqxBK6Lb3q6s047D/XsDVNPnF9Dl8JSaqe9h9lURl0OdNqy/ujDrOiIHtsqXMGbWWTIomRzAMaTyawAU//Reg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", "dev": true, "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", "is-fullwidth-code-point": "^2.0.0" } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { - "ansi-regex": "^3.0.0" + "has-flag": "^4.0.0" } }, "table": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", - "integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==", + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "dev": true, "requires": { - "ajv": "^5.2.3", - "ajv-keywords": "^2.1.0", - "chalk": "^2.1.0", - "lodash": "^4.17.4", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } } }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", "dev": true, "requires": { "prelude-ls": "~1.1.2" } }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -33269,46 +35354,6 @@ "requires": { "isexe": "^2.0.0" } - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true - } - } - }, - "gulp-footer": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/gulp-footer/-/gulp-footer-2.1.0.tgz", - "integrity": "sha512-CK3nRBP3PG59XN2L1rDLkBHA7goYsW+tJuVQccLP9jq3mpBT2kuRq0ImgNjrUkDbF948aCVQH4J7uIEqiZ2MHA==", - "dev": true, - "requires": { - "lodash": "^4.17.21", - "map-stream": "^0.0.7" - } - }, - "gulp-header": { - "version": "2.0.9", - "resolved": "https://registry.npmjs.org/gulp-header/-/gulp-header-2.0.9.tgz", - "integrity": "sha512-LMGiBx+qH8giwrOuuZXSGvswcIUh0OiioNkUpLhNyvaC6/Ga8X6cfAeme2L5PqsbXMhL8o8b/OmVqIQdxprhcQ==", - "dev": true, - "requires": { - "concat-with-sourcemaps": "^1.1.0", - "lodash.template": "^4.5.0", - "map-stream": "0.0.7", - "through2": "^2.0.0" - }, - "dependencies": { - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } } } }, @@ -33338,7 +35383,7 @@ "gulp-js-escape": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gulp-js-escape/-/gulp-js-escape-1.0.1.tgz", - "integrity": "sha1-HNRF+9AJ4Np2lZoDp/SbNWav+Gg=", + "integrity": "sha512-F+53crhLb78CTlG7ZZJFWzP0+/4q0vt2/pULXFkTMs6AGBo0Eh5cx+eWsqqHv8hrNIUsuTab3Se8rOOzP/6+EQ==", "dev": true, "requires": { "through2": "^0.6.3" @@ -33347,13 +35392,13 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, "readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", "dev": true, "requires": { "core-util-is": "~1.0.0", @@ -33365,13 +35410,13 @@ "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", "dev": true }, "through2": { "version": "0.6.5", "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "integrity": "sha512-RkK/CCESdTKQZHdmKICijdKKsCRVHs5KsLZ6pACAmF/1GPUQhonHSXWNERctxEp7RmvjdNbZTL5z9V7nSCXKcg==", "dev": true, "requires": { "readable-stream": ">=1.0.33-1 <1.1.0-0", @@ -33403,9 +35448,9 @@ }, "dependencies": { "@types/node": { - "version": "14.18.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz", - "integrity": "sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A==", + "version": "14.18.33", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.33.tgz", + "integrity": "sha512-qelS/Ra6sacc4loe/3MSjXNL1dNQ/GjxNHVzuChwMfmk7HuycRLVQN2qNY3XahK+fZc5E2szqQSKUyAF0E+2bg==", "dev": true } } @@ -33424,6 +35469,15 @@ "tslib": "^1.10.0" }, "dependencies": { + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -33433,6 +35487,18 @@ "color-convert": "^2.0.1" } }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true + }, "chalk": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", @@ -33458,6 +35524,34 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -33532,12 +35626,57 @@ "terser": "^5.9.0", "through2": "^4.0.2", "vinyl-sourcemaps-apply": "^0.2.1" + }, + "dependencies": { + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + } } }, "gulp-util": { "version": "3.0.8", "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", + "integrity": "sha512-q5oWPc12lwSFS9h/4VIjG+1NuNDlJ48ywV2JKItY4Ycc/n1fXJeYPVQsfu5ZrhQi7FGSDBalwUCLar/GyHXKGw==", "dev": true, "requires": { "array-differ": "^1.0.0", @@ -33563,19 +35702,19 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "requires": { "ansi-styles": "^2.2.1", @@ -33588,39 +35727,19 @@ "clone": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", "dev": true }, "clone-stats": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "integrity": "sha512-dhUqc57gSMCo6TX85FLfe51eC/s+Im2MLkAgJwfaRRexR2tA4dd3eLEW4L6efzHc2iNorrRRXITifnDLlRrhaA==", "dev": true }, - "lodash.escape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true, - "requires": { - "lodash._root": "^3.0.0" - } - }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "^3.0.0", - "lodash.isarguments": "^3.0.0", - "lodash.isarray": "^3.0.0" - } - }, "lodash.template": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", + "integrity": "sha512-0B4Y53I0OgHUJkt+7RmlDFWKjVAI/YUpWNiL9GQz5ORDr4ttgfQGo+phBWKFLJbBdtOwgMuUkdOHOnPg45jKmQ==", "dev": true, "requires": { "lodash._basecopy": "^3.0.0", @@ -33637,7 +35756,7 @@ "lodash.templatesettings": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", - "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", + "integrity": "sha512-TcrlEr31tDYnWkHFWDCV3dHYroKEXpJZ2YJYvJdhN+y4AkWMDZ5I4I8XDtUKqSAyG81N7w+I1mFEJtcED+tGqQ==", "dev": true, "requires": { "lodash._reinterpolate": "^3.0.0", @@ -33647,13 +35766,13 @@ "object-assign": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", + "integrity": "sha512-jHP15vXVGeVh1HuaA2wY6lxk+whK/x4KBG88VXeRma7CCun7iGD5qPc4eYykQ9sdQvg8jkwFKsSxHln2ybW3xQ==", "dev": true }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" @@ -33662,7 +35781,7 @@ "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true }, "through2": { @@ -33678,7 +35797,7 @@ "vinyl": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", - "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "integrity": "sha512-P5zdf3WB9uzr7IFoVQ2wZTmUwHL8cMZWJGzLBNCHNZ3NB6HTMsYABtt7z8tAGIINLXyAob9B9a1yzVGMFOYKEA==", "dev": true, "requires": { "clone": "^1.0.0", @@ -33691,7 +35810,7 @@ "gulplog": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "integrity": "sha512-hm6N8nrm3Y08jXie48jsC55eCZz9mnb4OirAStEk2deqeyhXU3C1otDVh+ccttMuc1sBi6RX6ZJ720hs9RCvgw==", "dev": true, "requires": { "glogg": "^1.0.0" @@ -33730,7 +35849,7 @@ "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", "dev": true }, "har-validator": { @@ -33741,33 +35860,12 @@ "requires": { "ajv": "^6.12.3", "har-schema": "^2.0.0" - }, - "dependencies": { - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - } } }, - "hard-rejection": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", - "integrity": "sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==", - "dev": true - }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -33775,7 +35873,7 @@ "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" @@ -33784,37 +35882,44 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true } } }, "has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", - "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true }, "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==" }, "has-gulplog": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "integrity": "sha512-+F4GzLjwHNNDEAJW2DC1xXfEoPkRDmUdJ7CBYw4MpqtDwOnqdImJl7GWlpqx+Wko6//J8uKTnIe4wZSv7yCqmw==", "dev": true, "requires": { "sparkles": "^1.0.0" } }, + "has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "requires": { + "get-intrinsic": "^1.1.1" + } + }, "has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, "has-tostringtag": { "version": "1.0.0", @@ -33828,7 +35933,7 @@ "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "integrity": "sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==", "dev": true, "requires": { "get-value": "^2.0.6", @@ -33839,7 +35944,7 @@ "has-values": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "integrity": "sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==", "dev": true, "requires": { "is-number": "^3.0.0", @@ -33852,10 +35957,30 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, "kind-of": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "integrity": "sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -33864,60 +35989,64 @@ } }, "hast-util-is-element": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.1.0.tgz", - "integrity": "sha512-oUmNua0bFbdrD/ELDSSEadRVtWZOf3iF6Lbv81naqsIV99RnSCieTbWuWCY8BAeEfKJTKl0gRdokv+dELutHGQ==", - "dev": true + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-2.1.2.tgz", + "integrity": "sha512-thjnlGAnwP8ef/GSO1Q8BfVk2gundnc2peGQqEg2kUt/IqesiGg/5mSwN2fE7nLzy61pg88NG6xV+UrGOrx9EA==", + "dev": true, + "requires": { + "@types/hast": "^2.0.0", + "@types/unist": "^2.0.0" + } }, "hast-util-sanitize": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-3.0.2.tgz", - "integrity": "sha512-+2I0x2ZCAyiZOO/sb4yNLFmdwPBnyJ4PBkVTUMKMqBwYNA+lXSgOmoRXlJFazoyid9QPogRRKgKhVEodv181sA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-4.0.0.tgz", + "integrity": "sha512-pw56+69jq+QSr/coADNvWTmBPDy+XsmwaF5KnUys4/wM1jt/fZdl7GPxhXXXYdXnz3Gj3qMkbUCH2uKjvX0MgQ==", "dev": true, "requires": { - "xtend": "^4.0.0" + "@types/hast": "^2.0.0" } }, "hast-util-to-html": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.3.tgz", - "integrity": "sha512-yk2+1p3EJTEE9ZEUkgHsUSVhIpCsL/bvT8E5GzmWc+N1Po5gBw+0F8bo7dpxXR0nu0bQVxVZGX2lBGF21CmeDw==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-8.0.3.tgz", + "integrity": "sha512-/D/E5ymdPYhHpPkuTHOUkSatxr4w1ZKrZsG0Zv/3C2SRVT0JFJG53VS45AMrBtYk0wp5A7ksEhiC8QaOZM95+A==", "dev": true, "requires": { - "ccount": "^1.0.0", - "comma-separated-tokens": "^1.0.0", - "hast-util-is-element": "^1.0.0", - "hast-util-whitespace": "^1.0.0", - "html-void-elements": "^1.0.0", - "property-information": "^5.0.0", - "space-separated-tokens": "^1.0.0", - "stringify-entities": "^3.0.1", - "unist-util-is": "^4.0.0", - "xtend": "^4.0.0" + "@types/hast": "^2.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-is-element": "^2.0.0", + "hast-util-whitespace": "^2.0.0", + "html-void-elements": "^2.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.2", + "unist-util-is": "^5.0.0" } }, "hast-util-whitespace": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz", - "integrity": "sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.0.tgz", + "integrity": "sha512-Pkw+xBHuV6xFeJprJe2BBEoDV+AvQySaz3pPDRUs5PNZEMQjpXJJueqrpcHIXxnWTcAGi/UOCgVShlkY6kLoqg==", "dev": true }, "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, "highlight.js": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", - "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "version": "11.6.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.6.0.tgz", + "integrity": "sha512-ig1eqDzJaB0pqEvlPVIpSSyMaO92bH1N2rJpLMN/nX396wTpDA4Eq0uK+7I/2XG17pFaaKE0kjV/XPeGt7Evjw==", "dev": true }, "home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", - "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", + "integrity": "sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg==", "dev": true, "requires": { "os-homedir": "^1.0.0", @@ -33934,10 +36063,13 @@ } }, "hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", + "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } }, "html-escaper": { "version": "2.0.2", @@ -33946,33 +36078,33 @@ "dev": true }, "html-void-elements": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.5.tgz", - "integrity": "sha512-uE/TxKuyNIcx44cIWnjr/rfIATDH7ZaOMmstu0CwhFG1Dunhlp4OC6/NMbhiwoq5BpW0ubi303qnEk/PZj614w==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-2.0.1.tgz", + "integrity": "sha512-0quDb7s97CfemeJAnW9wC0hw78MtW7NU3hqtCD75g2vFlDLt36llsYD7uB7SUzojLMP24N5IatXf7ylGXiGG9A==", "dev": true }, "http-cache-semantics": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", - "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", + "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, "http-errors": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz", - "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", "requires": { - "depd": "~1.1.2", + "depd": "2.0.0", "inherits": "2.0.4", "setprototypeof": "1.2.0", - "statuses": ">= 1.5.0 < 2", + "statuses": "2.0.1", "toidentifier": "1.0.1" } }, "http-parser-js": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.6.tgz", - "integrity": "sha512-vDlkRPDJn93swjcjqMSaGSPABbIarsr1TLAui/gLDXzV5VsJNdXNzMYDyNBLQkjWQCJ1uizu8T2oDMhmGt0PRA==", + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.8.tgz", + "integrity": "sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q==", "dev": true }, "http-proxy": { @@ -33989,7 +36121,7 @@ "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", "dev": true, "requires": { "assert-plus": "^1.0.0", @@ -34008,12 +36140,12 @@ } }, "https-proxy-agent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-4.0.0.tgz", - "integrity": "sha512-zoDhWrkR3of1l9QAL8/scJZyLu8j/gBkcwcaQOZh7Gyh/+uJQzGVETdgT30akuwkpL8HTRfssqI3BZuV18teDg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, "requires": { - "agent-base": "5", + "agent-base": "6", "debug": "4" } }, @@ -34058,19 +36190,25 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true }, "indent-string": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", - "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ==", + "dev": true + }, + "individual": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/individual/-/individual-2.0.0.tgz", + "integrity": "sha512-pWt8hBCqJsUWI/HtcfWod7+N9SgAqyPEaF7JQjwzjn5vGrpg6aQ5qeAFQ7dx//UH4J1O+7xqew+gCeeFt6xN/g==", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -34083,15 +36221,15 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ini/-/ini-3.0.1.tgz", + "integrity": "sha512-it4HyVAUTKBc6m8e1iXWvXSTdndF7HbdN713+kvLrymxTaU4AUBWrJ4vEooP+V7fexnVD3LKcBshjGGPefSMUQ==", "dev": true }, "inquirer": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.1.5.tgz", - "integrity": "sha512-G6/9xUqmt/r+UvufSyrPpt84NYwhKZ9jLsgMbQzlx804XErNupor8WQdBnBRrXmBfTPpuwf1sV+ss2ovjgdXIg==", + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.5.tgz", + "integrity": "sha512-QAgPDQMEgrDssk1XiwwHoOGYF9BAbUcc1+j+FhEvaOt8/cKRqyLn0U5qA6F74fGhTMGxf92pOvPBeh29jQJDTQ==", "dev": true, "requires": { "ansi-escapes": "^4.2.1", @@ -34104,10 +36242,11 @@ "mute-stream": "0.0.8", "ora": "^5.4.1", "run-async": "^2.4.0", - "rxjs": "^7.2.0", + "rxjs": "^7.5.5", "string-width": "^4.1.0", "strip-ansi": "^6.0.0", - "through": "^2.3.6" + "through": "^2.3.6", + "wrap-ansi": "^7.0.0" }, "dependencies": { "ansi-styles": { @@ -34144,6 +36283,21 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "rxjs": { + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.7.tgz", + "integrity": "sha512-z9MzKh/UcOqB3i20H6rtrlaE/CgjLOvheWK/9ILrbhROGTweAi1BaFsTT9FbwZi5Trr1qNRs+MXkhmR06awzQA==", + "dev": true, + "requires": { + "tslib": "^2.1.0" + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -34152,6 +36306,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "tslib": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", + "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==", + "dev": true } } }, @@ -34184,7 +36344,7 @@ "invert-kv": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "integrity": "sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ==", "dev": true }, "ipaddr.js": { @@ -34219,22 +36379,6 @@ } } }, - "is-alphabetical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz", - "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", - "dev": true - }, - "is-alphanumerical": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", - "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", - "dev": true, - "requires": { - "is-alphabetical": "^1.0.0", - "is-decimal": "^1.0.0" - } - }, "is-arguments": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", @@ -34248,7 +36392,7 @@ "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, "is-bigint": { @@ -34286,16 +36430,15 @@ "dev": true }, "is-callable": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", - "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", "dev": true }, "is-core-module": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", - "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", - "dev": true, + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", "requires": { "has": "^1.0.3" } @@ -34326,12 +36469,6 @@ "has-tostringtag": "^1.0.0" } }, - "is-decimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz", - "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", - "dev": true - }, "is-descriptor": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", @@ -34380,7 +36517,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-finite": { @@ -34395,6 +36532,12 @@ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, + "is-function": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz", + "integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==", + "dev": true + }, "is-generator-function": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", @@ -34413,12 +36556,6 @@ "is-extglob": "^2.1.1" } }, - "is-hexadecimal": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz", - "integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==", - "dev": true - }, "is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -34444,7 +36581,7 @@ "is-negated-glob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", - "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=", + "integrity": "sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug==", "dev": true }, "is-negative-zero": { @@ -34454,50 +36591,24 @@ "dev": true }, "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true }, "is-number-object": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.6.tgz", - "integrity": "sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, "requires": { "has-tostringtag": "^1.0.0" } }, - "is-obj": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", - "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", - "dev": true - }, "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", + "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", "dev": true }, "is-plain-object": { @@ -34531,16 +36642,10 @@ "is-unc-path": "^1.0.0" } }, - "is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", - "dev": true - }, "is-running": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-running/-/is-running-2.1.0.tgz", - "integrity": "sha1-MKc/9cw4VOT8JUkICen1q/jeCeA=", + "integrity": "sha512-mjJd3PujZMl7j+D395WTIO5tU5RIDBfVSRtRR4VOJou3H66E38UjbjvDGh3slJzPuolsb+yQFqwHNNdyp5jg3w==", "dev": true }, "is-set": { @@ -34550,24 +36655,27 @@ "dev": true }, "is-shared-array-buffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz", - "integrity": "sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==", - "dev": true + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } }, "is-ssh": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.3.3.tgz", - "integrity": "sha512-NKzJmQzJfEEma3w5cJNcUMxoXfDjz0Zj0eyCalHn2E6VOwlzjZo0yuO2fcBSf8zhFuVCL/82/r5gRcoi6aEPVQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", + "integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==", "dev": true, "requires": { - "protocols": "^1.1.0" + "protocols": "^2.0.1" } }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", "dev": true }, "is-string": { @@ -34588,32 +36696,23 @@ "has-symbols": "^1.0.2" } }, - "is-text-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", - "dev": true, - "requires": { - "text-extensions": "^1.0.0" - } - }, "is-typed-array": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.8.tgz", - "integrity": "sha512-HqH41TNZq2fgtGT8WHVFVJhBVGuY3AnP3Q36K8JKXUxSxRgk/d+7NjmwG2vo2mYmXK8UYZKu0qH8bVP5gEisjA==", + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.9.tgz", + "integrity": "sha512-kfrlnTTn8pZkfpJMUgYD7YZ3qzeJgWUn8XfVYBARc4wnmNOmLbmuuaAs3q5fvB0UJOn6yHAKaGTPM7d6ezoD/A==", "dev": true, "requires": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", - "es-abstract": "^1.18.5", - "foreach": "^2.0.5", + "es-abstract": "^1.20.0", + "for-each": "^0.3.3", "has-tostringtag": "^1.0.0" } }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", "dev": true }, "is-unc-path": { @@ -34634,13 +36733,13 @@ "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "integrity": "sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q==", "dev": true }, "is-valid-glob": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-valid-glob/-/is-valid-glob-1.0.0.tgz", - "integrity": "sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=", + "integrity": "sha512-AhiROmoEFDSsjx8hW+5sGwgKVIORcXnrlAx/R0ZSeaPw70Vw0CqkGBBhHGL58Uox2eXnU1AnvXJl1XlyedO5bA==", "dev": true }, "is-weakmap": { @@ -34690,33 +36789,33 @@ "dev": true }, "isbinaryfile": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.8.tgz", - "integrity": "sha512-53h6XFniq77YdW+spoRrebh0mnmTxRPTlcuIArO57lmMdq4uBKFKaeTjnb92oYWrSn/LVL+LT+Hap2tFQj8V+w==", + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", "dev": true }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==", "dev": true }, "istanbul": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", - "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "integrity": "sha512-nMtdn4hvK0HjUlzr1DrKSUY8ychprt8dzHOgY2KXsIhHu5PuQQEOTM27gV9Xblyon7aUH/TSFIjRHEODF/FRPg==", "dev": true, "requires": { "abbrev": "1.0.x", @@ -34738,7 +36837,7 @@ "glob": { "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "integrity": "sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==", "dev": true, "requires": { "inflight": "^1.0.4", @@ -34751,28 +36850,28 @@ "has-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "integrity": "sha512-DyYHfIYwAJmjAjSSPKANxI8bFY9YtFrgkAfinBojQ8YJTOuOuav64tMUJv584SES4xl74PmuaevIyaLESHdTAA==", "dev": true }, "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" } }, "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "integrity": "sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg==", "dev": true }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "integrity": "sha512-Jds2VIYDrlp5ui7t8abHN2bjAu4LV/q4N2KivFPpGH0lrka0BMq/33AmECUXlKPcHigkNaqfXRENFju+rlcy+A==", "dev": true, "requires": { "has-flag": "^1.0.0" @@ -34796,14 +36895,15 @@ "dev": true }, "istanbul-lib-instrument": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", - "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", "dev": true, "requires": { - "@babel/core": "^7.7.5", + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-coverage": "^3.2.0", "semver": "^6.3.0" } }, @@ -34818,6 +36918,12 @@ "supports-color": "^7.1.0" }, "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -34849,9 +36955,9 @@ } }, "istanbul-reports": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.4.tgz", - "integrity": "sha512-r1/DshN4KSE7xWEknZLLLLDn5CJybV3nw01VTkp6D5jzLuELlcbudfj/eSQFvrKsJuTVCGnePO7ho82Nw9zzfw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", "dev": true, "requires": { "html-escaper": "^2.0.0", @@ -34869,35 +36975,84 @@ } }, "jake": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz", - "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==", + "version": "10.8.5", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz", + "integrity": "sha512-sVpxYeuAhWt0OTWITwT98oyV0GsXyMlXCF+3L1SuafBVUIr/uILGRB+NqwkzhgXKvoJpDIpQvqkUALgdmQsQxw==", "dev": true, "requires": { - "async": "0.9.x", - "chalk": "^2.4.2", + "async": "^3.2.3", + "chalk": "^4.0.2", "filelist": "^1.0.1", "minimatch": "^3.0.4" }, "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "async": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", + "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } } } }, "jest-diff": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-27.5.1.tgz", - "integrity": "sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-26.6.2.tgz", + "integrity": "sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==", "dev": true, "requires": { "chalk": "^4.0.0", - "diff-sequences": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" + "diff-sequences": "^26.6.2", + "jest-get-type": "^26.3.0", + "pretty-format": "^26.6.2" }, "dependencies": { "ansi-styles": { @@ -34934,6 +37089,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -34946,21 +37107,21 @@ } }, "jest-get-type": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-27.5.1.tgz", - "integrity": "sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==", + "version": "26.3.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-26.3.0.tgz", + "integrity": "sha512-TpfaviN1R2pQWkIihlfEanwOXK0zcxrKEE4MlU6Tn7keoXdN6/3gK/xl0yEh8DOunn5pOVGKf8hB4R9gVh04ig==", "dev": true }, "jest-matcher-utils": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz", - "integrity": "sha512-z2uTx/T6LBaCoNWNFWwChLBKYxTMcGBRjAt+2SbP929/Fflb9aa5LGma654Rz8z9HLxsrUaYzxE9T/EFIL/PAw==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-26.6.2.tgz", + "integrity": "sha512-llnc8vQgYcNqDrqRDXWwMr9i7rS5XFiCwvh6DTP7Jqa2mqpcCBBlpCbn+trkG0KNhPu/h8rzyBkriOtBstvWhw==", "dev": true, "requires": { "chalk": "^4.0.0", - "jest-diff": "^27.5.1", - "jest-get-type": "^27.5.1", - "pretty-format": "^27.5.1" + "jest-diff": "^26.6.2", + "jest-get-type": "^26.3.0", + "pretty-format": "^26.6.2" }, "dependencies": { "ansi-styles": { @@ -34997,6 +37158,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -35009,20 +37176,20 @@ } }, "jest-message-util": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-27.5.1.tgz", - "integrity": "sha512-rMyFe1+jnyAAf+NHwTclDz0eAaLkVDdKVHHBFWsBWHnnh5YeJMNWWsv7AbFYXfK3oTqvL7VTWkhNLu1jX24D+g==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-26.6.2.tgz", + "integrity": "sha512-rGiLePzQ3AzwUshu2+Rn+UMFk0pHN58sOG+IaJbk5Jxuqo3NYO1U2/MIR4S1sKgsoYSXSzdtSa0TgrmtUwEbmA==", "dev": true, "requires": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^27.5.1", + "@babel/code-frame": "^7.0.0", + "@jest/types": "^26.6.2", "@types/stack-utils": "^2.0.0", "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^27.5.1", + "graceful-fs": "^4.2.4", + "micromatch": "^4.0.2", + "pretty-format": "^26.6.2", "slash": "^3.0.0", - "stack-utils": "^2.0.3" + "stack-utils": "^2.0.2" }, "dependencies": { "ansi-styles": { @@ -35059,15 +37226,17 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "dev": true, - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - } + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true }, "supports-color": { "version": "7.2.0", @@ -35080,6 +37249,12 @@ } } }, + "jest-regex-util": { + "version": "26.0.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-26.0.0.tgz", + "integrity": "sha512-Gv3ZIs/nA48/Zvjrl34bf+oD76JHiGDUxNOVgUjh3j890sblXryjY4rss71fPtD/njchl6PSE2hIhvyWa1eT0A==", + "dev": true + }, "jest-worker": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", @@ -35089,13 +37264,34 @@ "@types/node": "*", "merge-stream": "^2.0.0", "supports-color": "^8.0.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, + "js-cookie": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz", + "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { "version": "3.14.1", @@ -35118,14 +37314,13 @@ "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==", "dev": true }, "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, "json-buffer": { "version": "3.0.1", @@ -35133,12 +37328,6 @@ "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, "json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -35160,23 +37349,19 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, "json5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", - "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", + "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==" }, "jsonfile": { "version": "6.1.0", @@ -35188,22 +37373,6 @@ "universalify": "^2.0.0" } }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true - }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, "jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -35219,7 +37388,7 @@ "just-clone": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/just-clone/-/just-clone-1.0.2.tgz", - "integrity": "sha1-v7P672WqEqMWBYcSlFwyb9jwFDQ=" + "integrity": "sha512-p93GINPwrve0w3HUzpXmpTl7MyzzWz1B5ag44KEtq/hP1mtK8lA2b9Q0VQaPlnY87352osJcE6uBmN0e8kuFMw==" }, "just-debounce": { "version": "1.1.0", @@ -35234,9 +37403,9 @@ "dev": true }, "karma": { - "version": "6.3.17", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.17.tgz", - "integrity": "sha512-2TfjHwrRExC8yHoWlPBULyaLwAFmXmxQrcuFImt/JsAsSZu1uOWTZ1ZsWjqQtWpHLiatJOHL5jFjXSJIgCd01g==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.1.tgz", + "integrity": "sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA==", "dev": true, "requires": { "@colors/colors": "1.5.0", @@ -35258,20 +37427,31 @@ "qjobs": "^1.2.0", "range-parser": "^1.2.1", "rimraf": "^3.0.2", - "socket.io": "^4.2.0", + "socket.io": "^4.4.1", "source-map": "^0.6.1", "tmp": "^0.2.1", "ua-parser-js": "^0.7.30", "yargs": "^16.1.1" }, "dependencies": { + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" } }, "source-map": { @@ -35333,14 +37513,14 @@ "karma-chai": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz", - "integrity": "sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=", + "integrity": "sha512-mqKCkHwzPMhgTYca10S90aCEX9+HjVjjrBFAsw36Zj7BlQNbokXXCAe6Ji04VUMsxcY5RLP7YphpfO06XOubdg==", "dev": true, "requires": {} }, "karma-chrome-launcher": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.0.tgz", - "integrity": "sha512-3dPs/n7vgz1rxxtynpzZTvb9y/GIaW8xjAwcIGttLbycqoFtI7yo1NGnQi6oFTherRE+GIhCAHZC4vEqWGhNvg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz", + "integrity": "sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ==", "dev": true, "requires": { "which": "^1.2.1" @@ -35369,21 +37549,6 @@ "istanbul-lib-source-maps": "^4.0.1", "istanbul-reports": "^3.0.5", "minimatch": "^3.0.4" - }, - "dependencies": { - "istanbul-lib-instrument": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.1.0.tgz", - "integrity": "sha512-czwUz525rkOFDJxfKK6mYfIs9zBKILyrZQxjz3ABhjQXhbhFsSbo1HW/BFcsDnfJYJWA6thRR5/TUY2qs5W99Q==", - "dev": true, - "requires": { - "@babel/core": "^7.12.3", - "@babel/parser": "^7.14.7", - "@istanbuljs/schema": "^0.1.2", - "istanbul-lib-coverage": "^3.2.0", - "semver": "^6.3.0" - } - } } }, "karma-coverage-istanbul-reporter": { @@ -35446,9 +37611,9 @@ } }, "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", "dev": true }, "source-map": { @@ -35462,7 +37627,7 @@ "karma-es5-shim": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/karma-es5-shim/-/karma-es5-shim-0.0.4.tgz", - "integrity": "sha1-zdADM8znfC5M4D46yT8vjs0fuVI=", + "integrity": "sha512-8xU6F2/R6u6HAZ/nlyhhx3WEhj4C6hJorG7FR2REX81pgj2LSo9ADJXxCGIeXg6Qr2BGpxp4hcZcEOYGAwiumg==", "dev": true, "requires": { "es5-shim": "^4.0.5" @@ -35481,7 +37646,7 @@ "karma-ie-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-ie-launcher/-/karma-ie-launcher-1.0.0.tgz", - "integrity": "sha1-SXmGhCxJAZA0bNifVJTKmDDG1Zw=", + "integrity": "sha512-ts71ke8pHvw6qdRtq0+7VY3ANLoZuUNNkA8abRaWV13QRPNm7TtSOqyszjHUtuwOWKcsSz4tbUtrNICrQC+SXQ==", "dev": true, "requires": { "lodash": "^4.6.1" @@ -35499,7 +37664,7 @@ "karma-mocha-reporter": { "version": "2.2.5", "resolved": "https://registry.npmjs.org/karma-mocha-reporter/-/karma-mocha-reporter-2.2.5.tgz", - "integrity": "sha1-FRIAlejtgZGG5HoLAS8810GJVWA=", + "integrity": "sha512-Hr6nhkIp0GIJJrvzY8JFeHpQZNseuIakGac4bpw8K1+5F0tLb6l7uvXRa8mt2Z+NVwYgCct4QAfp2R2QP6o00w==", "dev": true, "requires": { "chalk": "^2.1.0", @@ -35508,15 +37673,15 @@ }, "dependencies": { "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", "dev": true }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", "dev": true, "requires": { "ansi-regex": "^3.0.0" @@ -35527,28 +37692,28 @@ "karma-opera-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-opera-launcher/-/karma-opera-launcher-1.0.0.tgz", - "integrity": "sha1-+lFihTGh0L6EstjcDX7iCfyP+Ro=", + "integrity": "sha512-rdty4FlVIowmUhPuG08TeXKHvaRxeDSzPxGIkWguCF3A32kE0uvXZ6dXW08PuaNjai8Ip3f5Pn9Pm2HlChaxCw==", "dev": true, "requires": {} }, "karma-safari-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz", - "integrity": "sha1-lpgqLMR9BmquccVTursoMZEVos4=", + "integrity": "sha512-qmypLWd6F2qrDJfAETvXDfxHvKDk+nyIjpH9xIeI3/hENr0U3nuqkxaftq73PfXZ4aOuOChA6SnLW4m4AxfRjQ==", "dev": true, "requires": {} }, "karma-script-launcher": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/karma-script-launcher/-/karma-script-launcher-1.0.0.tgz", - "integrity": "sha1-zQF8TeXvCeWp2nkydhdhCN1LVC0=", + "integrity": "sha512-5NRc8KmTBjNPE3dNfpJP90BArnBohYV4//MsLFfUA1e6N+G1/A5WuWctaFBtMQ6MWRybs/oguSej0JwDr8gInA==", "dev": true, "requires": {} }, "karma-sinon": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/karma-sinon/-/karma-sinon-1.0.5.tgz", - "integrity": "sha1-TjRD8oMP3s/2JNN0cWPxIX2qKpo=", + "integrity": "sha512-wrkyAxJmJbn75Dqy17L/8aILJWFm7znd1CE8gkyxTBFnjMSOe2XTJ3P30T8SkxWZHmoHX0SCaUJTDBEoXs25Og==", "dev": true, "requires": {} }, @@ -35564,7 +37729,7 @@ "karma-spec-reporter": { "version": "0.0.32", "resolved": "https://registry.npmjs.org/karma-spec-reporter/-/karma-spec-reporter-0.0.32.tgz", - "integrity": "sha1-LpxyB+pyZ3EmAln4K+y1QyCeRAo=", + "integrity": "sha512-ZXsYERZJMTNRR2F3QN11OWF5kgnT/K2dzhM+oY3CDyMrDI3TjIWqYGG7c15rR9wjmy9lvdC+CCshqn3YZqnNrA==", "dev": true, "requires": { "colors": "^1.1.2" @@ -35581,10 +37746,16 @@ "webpack-merge": "^4.1.5" } }, + "keycode": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.1.tgz", + "integrity": "sha512-Rdgz9Hl9Iv4QKi8b0OlCRQEzp4AgVxyCtz5S/+VIHezDmrDhkp2N2TqBWOLz0/gbeREXOOiI9/4b8BY9uw2vFg==", + "dev": true + }, "keyv": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.1.1.tgz", - "integrity": "sha512-tGv1yP6snQVDSM4X6yxrv2zzq/EvpW+oYiUz6aueW1u9CtS8RzUQYxxmFwgZlO2jSgCxQbchhxaqXXp2hnKGpQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.0.tgz", + "integrity": "sha512-2YvuMsA+jnFGtBareKqgANOEKe1mk3HKiXu2fRmAfyxG0MJAywNhi5ttWA3PMjl4NmpyjZNbFifR2vNjW1znfA==", "dev": true, "requires": { "json-buffer": "3.0.1" @@ -35596,6 +37767,12 @@ "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", "dev": true }, + "kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true + }, "konan": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/konan/-/konan-2.1.1.tgz", @@ -35615,7 +37792,7 @@ "last-run": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/last-run/-/last-run-1.1.1.tgz", - "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", + "integrity": "sha512-U/VxvpX4N/rFvPzr3qG5EtLKEnNI0emvIQB3/ecEwv+8GHaUKbIB8vxv1Oai5FAF0d0r7LXHhLLe5K/yChm5GQ==", "dev": true, "requires": { "default-resolution": "^2.0.0", @@ -35634,7 +37811,7 @@ "lcid": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "integrity": "sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw==", "dev": true, "requires": { "invert-kv": "^1.0.0" @@ -35643,13 +37820,13 @@ "lcov-parse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", - "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", + "integrity": "sha512-aprLII/vPzuQvYZnDRU78Fns9I2Ag3gi4Ipga/hxnVMCZC8DnR2nI7XBqrPoywGfxqIx/DgarGvDJZAD3YBTgQ==", "dev": true }, "lead": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/lead/-/lead-1.0.0.tgz", - "integrity": "sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI=", + "integrity": "sha512-IpSVCk9AYvLHo5ctcIXxOBpMWUe+4TKN3VPWAKUbJikkmsGp0VrSM8IttVc32D6J4WUsiPE6aEFRNmIoF/gdow==", "dev": true, "requires": { "flush-write-stream": "^1.0.2" @@ -35714,7 +37891,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true } } @@ -35728,14 +37905,30 @@ "listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", - "integrity": "sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc=", + "integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==", "dev": true }, + "live-connect-common": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.0.tgz", + "integrity": "sha512-pa1SuzCg8ovsB6OziAQZpDid/OT8k37VgWFQkE8OUmG52Kf9PUtJM8wqaGdMXd/rNAe/NH8m+Kxx9MZuOvn5zg==" + }, + "live-connect-handlers": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/live-connect-handlers/-/live-connect-handlers-2.1.0.tgz", + "integrity": "sha512-uABe9D6yRp7HRgO6vhdIM5j88l17/ROzYGIOHc2Rv1TacLFH6IJ8sbmunY5mIJ9L6ArOVmL4WHY+QgOIkabhxg==", + "requires": { + "js-cookie": "^3.0.5", + "live-connect-common": "^3.0.0" + } + }, "live-connect-js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.3.1.tgz", - "integrity": "sha512-4IT8NEOOTNmoYpw5CTxdugSF2w9xqfOujrEqx6zLPdTT3xq/lLdxxvRTREDi+qYHDsCDovdiNO3uOSoemdTCdA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.0.1.tgz", + "integrity": "sha512-+TwM7cjgyutqaMNlTQKNY9nJFDPpSWfoazSHmlWxOPlimp10PSZGABIbtulNGGpYbR/Zxgc+C/uW5OxqcNEPXg==", "requires": { + "live-connect-common": "^3.0.0", + "live-connect-handlers": "^2.1.0", "tiny-hashes": "1.0.1" } }, @@ -35746,35 +37939,54 @@ "dev": true }, "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A==", "dev": true, "requires": { "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" }, "dependencies": { + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", "dev": true + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g==", + "dev": true, + "requires": { + "is-utf8": "^0.2.0" + } } } }, "loader-runner": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.2.0.tgz", - "integrity": "sha512-92+huvxMvYlMzMt0iIOukcwYBFpkYJdpl2xsZ7LrlayO7E8SOv+JJUEK17B/dJIHAOLMfh2dZZ/Y18WgmGtYNw==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", + "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", "dev": true }, "loader-utils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz", - "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", "dev": true, "requires": { "big.js": "^5.2.2", @@ -35783,13 +37995,12 @@ } }, "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "dev": true, "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" + "p-locate": "^4.1.0" } }, "lodash": { @@ -35801,218 +38012,146 @@ "lodash._basecopy": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "integrity": "sha512-rFR6Vpm4HeCK1WPGvjZSJ+7yik8d8PVUdCJx5rT2pogG4Ve/2ZS7kfmO5l5T2o5V2mqlNIfSF5MZlr1+xOoYQQ==", "dev": true }, "lodash._basetostring": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", + "integrity": "sha512-mTzAr1aNAv/i7W43vOR/uD/aJ4ngbtsRaCubp2BfZhlGU/eORUjg/7F6X0orNMdv33JOrdgGybtvMN/po3EWrA==", "dev": true }, "lodash._basevalues": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", - "dev": true - }, - "lodash._escapehtmlchar": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._escapehtmlchar/-/lodash._escapehtmlchar-2.4.1.tgz", - "integrity": "sha1-32fDu2t+jh6DGrSL+geVuSr+iZ0=", - "dev": true, - "requires": { - "lodash._htmlescapes": "~2.4.1" - } - }, - "lodash._escapestringchar": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._escapestringchar/-/lodash._escapestringchar-2.4.1.tgz", - "integrity": "sha1-7P4iYYoq3lC/7qQ5N+Ud9m8O23I=", + "integrity": "sha512-H94wl5P13uEqlCg7OcNNhMQ8KvWSIyqXzOPusRgHC9DK3o54P6P3xtbXlVbRABG4q5gSmp7EDdJ0MSuW9HX6Mg==", "dev": true }, "lodash._getnative": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._htmlescapes": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._htmlescapes/-/lodash._htmlescapes-2.4.1.tgz", - "integrity": "sha1-MtFL8IRLbeb4tioFG09nwii2JMs=", + "integrity": "sha512-RrL9VxMEPyDMHOd9uFbvMe8X55X16/cGM5IgOKgRElQZutpX89iS6vwl64duTV1/16w5JY7tuFNXqoekmh1EmA==", "dev": true }, "lodash._isiterateecall": { "version": "3.0.9", "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "lodash._isnative": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._isnative/-/lodash._isnative-2.4.1.tgz", - "integrity": "sha1-PqZAS3hKe+g2x7V1gOHN95sUgyw=", - "dev": true - }, - "lodash._objecttypes": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.4.1.tgz", - "integrity": "sha1-fAt/admKH3ZSn4kLDNsbTf7BHBE=", + "integrity": "sha512-De+ZbrMu6eThFti/CSzhRvTKMgQToLxbij58LMfM8JnYDNSOjkjTCIaa8ixglOeGh2nyPlakbt5bJWJ7gvpYlQ==", "dev": true }, "lodash._reescape": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "integrity": "sha512-Sjlavm5y+FUVIF3vF3B75GyXrzsfYV8Dlv3L4mEpuB9leg8N6yf/7rU06iLPx9fY0Mv3khVp9p7Dx0mGV6V5OQ==", "dev": true }, "lodash._reevaluate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "integrity": "sha512-OrPwdDc65iJiBeUe5n/LIjd7Viy99bKwDdk7Z5ljfZg0uFRFlfQaCy9tZ4YMAag9WAZmlVpe1iZrkIMMSMHD3w==", "dev": true }, "lodash._reinterpolate": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "integrity": "sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA==", "dev": true }, - "lodash._reunescapedhtml": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._reunescapedhtml/-/lodash._reunescapedhtml-2.4.1.tgz", - "integrity": "sha1-dHxPxAED6zu4oJduVx96JlnpO6c=", - "dev": true, - "requires": { - "lodash._htmlescapes": "~2.4.1", - "lodash.keys": "~2.4.1" - } - }, "lodash._root": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", - "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "integrity": "sha512-O0pWuFSK6x4EXhM1dhZ8gchNtG7JMqBtrHdoUFUWXD7dJnNSUze1GuyQr5sOs0aCvgGeI3o/OJW8f4ca7FDxmQ==", "dev": true }, - "lodash._shimkeys": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.4.1.tgz", - "integrity": "sha1-bpzJZm/wgfC1psl4uD4kLmlJ0gM=", - "dev": true, - "requires": { - "lodash._objecttypes": "~2.4.1" - } - }, "lodash.clone": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz", - "integrity": "sha1-GVhwRQ9aExkkeN9Lw9I9LeoZB7Y=", + "integrity": "sha512-GhrVeweiTD6uTmmn5hV/lzgCQhccwReIVRLHp7LT4SopOjqEZ5BbX8b5WWEtAKasjmy8hR7ZPwsYlxRCku5odg==", "dev": true }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==", "dev": true }, "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" }, "lodash.defaults": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", - "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=", + "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==", "dev": true }, "lodash.difference": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz", - "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=", + "integrity": "sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==", "dev": true }, "lodash.escape": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-2.4.1.tgz", - "integrity": "sha1-LOEsXghNsKV92l5dHu659dF1o7Q=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha512-n1PZMXgaaDWZDSvuNZ/8XOcYO2hOKDqZel5adtR30VKQAtoWs/5AOeFA0vPV8moiPzlqe7F4cP2tzpFewQyelQ==", "dev": true, "requires": { - "lodash._escapehtmlchar": "~2.4.1", - "lodash._reunescapedhtml": "~2.4.1", - "lodash.keys": "~2.4.1" + "lodash._root": "^3.0.0" } }, "lodash.flatten": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", - "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", + "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==", "dev": true }, "lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", "dev": true }, "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==", "dev": true }, "lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==", "dev": true }, "lodash.isarray": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.ismatch": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz", - "integrity": "sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc=", + "integrity": "sha512-JwObCrNJuT0Nnbuecmqr5DgtuBppuCvGD9lxjFpAzwnVtdGoDQ1zig+5W8k5/6Gcn0gZ3936HDAlGd28i7sOGQ==", "dev": true }, "lodash.isobject": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz", - "integrity": "sha1-PI+41bW/S/kK4G4U8qUwpO2TXh0=", + "integrity": "sha512-3/Qptq2vr7WeJbB4KHUSKlq8Pl7ASXi3UG6CMbBm8WRtXi8+GHm7mKaU3urfpSEzWe2wCIChs6/sdocUsTKJiA==", "dev": true }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", "dev": true }, "lodash.keys": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.4.1.tgz", - "integrity": "sha1-SN6kbfj/djKxDXBrissmWR4rNyc=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha512-CuBsapFjcubOGMn3VD+24HOAPxM79tH+V6ivJL3CHYjtrawauDJHUk//Yew9Hvc6e9rbCrURGk8z6PC+8WJBfQ==", "dev": true, "requires": { - "lodash._isnative": "~2.4.1", - "lodash._shimkeys": "~2.4.1", - "lodash.isobject": "~2.4.1" - }, - "dependencies": { - "lodash.isobject": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.4.1.tgz", - "integrity": "sha1-Wi5H/mmVPx7mMafrof5k0tBlWPU=", - "dev": true, - "requires": { - "lodash._objecttypes": "~2.4.1" - } - } + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" } }, "lodash.merge": { @@ -36024,19 +38163,19 @@ "lodash.pickby": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.pickby/-/lodash.pickby-4.6.0.tgz", - "integrity": "sha1-feoh2MGNdwOifHBMFdO4SmfjOv8=", + "integrity": "sha512-AZV+GsS/6ckvPOVQPXSiFFacKvKB4kOQu6ynt9wz0F3LO4R9Ij4K1ddYsIytDpSgLz88JHd9P+oaLeej5/Sl7Q==", "dev": true }, "lodash.restparam": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "integrity": "sha512-L4/arjjuq4noiUJpt3yS6KIKDtJwNe2fIYgMqyYYKoeIfV1iEqvPwhCx23o+R9dzouGihDAPN1dTIRWa7zk8tw==", "dev": true }, "lodash.some": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", - "integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=", + "integrity": "sha512-j7MJE+TuT51q9ggt4fSgVqro163BEFjAt3u97IqU+JA2DkWl80nFTrowzLpZ/BnpN7rrl0JA/593NAdd8p/scQ==", "dev": true }, "lodash.template": { @@ -36061,28 +38200,19 @@ "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==", "dev": true }, "lodash.union": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.union/-/lodash.union-4.6.0.tgz", - "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=", + "integrity": "sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==", "dev": true }, - "lodash.values": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/lodash.values/-/lodash.values-2.4.1.tgz", - "integrity": "sha1-q/UUQ2s8twUAFieXjLzzCxKA7qQ=", - "dev": true, - "requires": { - "lodash.keys": "~2.4.1" - } - }, "lodash.zip": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz", - "integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=", + "integrity": "sha512-C7IOaBBK/0gMORRBd8OETNx3kmOkgIWIPvyDpZSCTwUrpYmgZwJkjZeOD8ww4xbOUOs4/attY+pciKvadNfFbg==", "dev": true }, "log-driver": { @@ -36101,16 +38231,16 @@ } }, "log4js": { - "version": "6.4.2", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.4.2.tgz", - "integrity": "sha512-k80cggS2sZQLBwllpT1p06GtfvzMmSdUCkW96f0Hj83rKGJDAu2vZjt9B9ag2vx8Zz1IXzxoLgqvRJCdMKybGg==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.7.0.tgz", + "integrity": "sha512-KA0W9ffgNBLDj6fZCq/lRbgR6ABAodRIDHrZnS48vOtfKa4PzWImb0Md1lmGCdO3n3sbCm/n1/WmrNlZ8kCI3Q==", "dev": true, "requires": { - "date-format": "^4.0.4", - "debug": "^4.3.3", - "flatted": "^3.2.5", + "date-format": "^4.0.14", + "debug": "^4.3.4", + "flatted": "^3.2.7", "rfdc": "^1.3.0", - "streamroller": "^3.0.4" + "streamroller": "^3.1.3" } }, "loglevel": { @@ -36132,9 +38262,9 @@ "dev": true }, "longest-streak": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-2.0.4.tgz", - "integrity": "sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.0.1.tgz", + "integrity": "sha512-cHlYSUpL2s7Fb3394mYxwTYj8niTaNHUCLr0qdiCXQfSjfuA7CKofpX2uSwEfFDQ0EB7JcnMnm+GjbqqoinYYg==", "dev": true }, "loose-envify": { @@ -36146,16 +38276,6 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, - "requires": { - "currently-unhandled": "^0.4.1", - "signal-exit": "^3.0.0" - } - }, "loupe": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", @@ -36183,12 +38303,23 @@ "lru-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", + "integrity": "sha512-BpdYkt9EvGl8OfWHDQPISVpcl5xZthb+XPsbELj5AQXxIC8IriDZIQYjBJPEm5rS420sjZ0TLEzRcq5KdBhYrQ==", "dev": true, "requires": { "es5-ext": "~0.10.2" } }, + "m3u8-parser": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/m3u8-parser/-/m3u8-parser-4.7.1.tgz", + "integrity": "sha512-pbrQwiMiq+MmI9bl7UjtPT3AK603PV9bogNlr83uC+X9IoxqL5E4k7kU7fMQ0dpRgxgeSMygqUa0IMLQNXLBNA==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "^3.0.5", + "global": "^4.4.0" + } + }, "magic-string": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", @@ -36228,49 +38359,46 @@ "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==", "dev": true }, "map-obj": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz", - "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==", "dev": true }, "map-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", - "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=", + "integrity": "sha512-C0X0KQmGm3N2ftbTGBhSyuydQ+vV1LC3f3zPvT3RXHXNZrvfPZcoXp/N5DOa8vedX/rTMm2CjTtivFg2STJMRQ==", "dev": true }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "integrity": "sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==", "dev": true, "requires": { "object-visit": "^1.0.0" } }, "markdown-table": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-2.0.0.tgz", - "integrity": "sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A==", - "dev": true, - "requires": { - "repeat-string": "^1.0.0" - } + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.2.tgz", + "integrity": "sha512-y8j3a5/DkJCmS5x4dMCQL+OR0+2EAq3DOtio1COSHsmW2BGXnNCK3v12hJt1LrUz5iZH5g0LmuYOjDdI+czghA==", + "dev": true }, "marky": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.4.tgz", - "integrity": "sha512-zd2/GiSn6U3/jeFVZ0J9CA1LzQ8RfIVvXkb/U0swFHF/zT+dVohTAWjmo2DcIuofmIIIROlwTbd+shSeXmxr0w==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.5.tgz", + "integrity": "sha512-q9JtQJKjpsVxCRVgQ+WapguSbKC3SQ5HEzFGPAJMStgh3QjCawp00UKv3MTTAArTmGmmPUvllHZoNbZ3gs0I+Q==", "dev": true }, "matchdep": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/matchdep/-/matchdep-2.0.0.tgz", - "integrity": "sha1-xvNINKDY28OzfCfui7yyfHd1WC4=", + "integrity": "sha512-LFgVbaHIHMqCRuCZyfCtUOq9/Lnzhi7Z0KFUE2fhD54+JN2jLh3hC02RLkqauJ3U4soU6H1J3tfj/Byk7GoEjA==", "dev": true, "requires": { "findup-sync": "^2.0.0", @@ -36279,10 +38407,90 @@ "stack-trace": "0.0.10" }, "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true + } + } + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true + } + } + }, "findup-sync": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "integrity": "sha512-vs+3unmJT45eczmcAZ6zMJtxN3l/QXeccaXQx5cu/MeJMhewVfoWZqibRkOxPnmoR59+Zy5hjabfQc6JLSah4g==", "dev": true, "requires": { "detect-file": "^1.0.0", @@ -36291,161 +38499,253 @@ "resolve-dir": "^1.0.1" } }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, "is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "requires": { "is-extglob": "^2.1.0" } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.2" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } } } }, "mdast-util-definitions": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-4.0.0.tgz", - "integrity": "sha512-k8AJ6aNnUkB7IE+5azR9h81O5EQ/cTDXtWdMq9Kk5KcEW/8ritU5CeLg/9HhOC++nALHBlaogJ5jz0Ybk3kPMQ==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-5.1.1.tgz", + "integrity": "sha512-rQ+Gv7mHttxHOBx2dkF4HWTg+EE+UR78ptQWDylzPKaQuVGdG4HIoY3SrS/pCp80nZ04greFvXbVFHT+uf0JVQ==", "dev": true, "requires": { - "unist-util-visit": "^2.0.0" + "@types/mdast": "^3.0.0", + "@types/unist": "^2.0.0", + "unist-util-visit": "^4.0.0" } }, "mdast-util-find-and-replace": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-1.1.1.tgz", - "integrity": "sha512-9cKl33Y21lyckGzpSmEQnIDjEfeeWelN5s1kUW1LwdB0Fkuq2u+4GdqcGEygYxJE8GVqCl0741bYXHgamfWAZA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-2.2.1.tgz", + "integrity": "sha512-SobxkQXFAdd4b5WmEakmkVoh18icjQRxGy5OWTCzgsLRm1Fu/KCtwD1HIQSsmq5ZRjVH0Ehwg6/Fn3xIUk+nKw==", "dev": true, "requires": { - "escape-string-regexp": "^4.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "escape-string-regexp": "^5.0.0", + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^5.0.0" }, "dependencies": { "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", "dev": true } } }, "mdast-util-from-markdown": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.5.tgz", - "integrity": "sha512-2hkTXtYYnr+NubD/g6KGBS/0mFmBcifAsI0yIWRiRo0PjVs6SSOSOdtzbp6kSGnShDN6G5aWZpKQ2lWRy27mWQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-1.2.0.tgz", + "integrity": "sha512-iZJyyvKD1+K7QX1b5jXdE7Sc5dtoTry1vzV28UZZe8Z1xVnB/czKntJ7ZAkG0tANqRnBF6p3p7GpU1y19DTf2Q==", "dev": true, "requires": { "@types/mdast": "^3.0.0", - "mdast-util-to-string": "^2.0.0", - "micromark": "~2.11.0", - "parse-entities": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" + "@types/unist": "^2.0.0", + "decode-named-character-reference": "^1.0.0", + "mdast-util-to-string": "^3.1.0", + "micromark": "^3.0.0", + "micromark-util-decode-numeric-character-reference": "^1.0.0", + "micromark-util-decode-string": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "unist-util-stringify-position": "^3.0.0", + "uvu": "^0.5.0" }, "dependencies": { "mdast-util-to-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", - "integrity": "sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", + "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==", "dev": true } } }, "mdast-util-gfm": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-0.1.2.tgz", - "integrity": "sha512-NNkhDx/qYcuOWB7xHUGWZYVXvjPFFd6afg6/e2g+SV4r9q5XUcCbV4Wfa3DLYIiD+xAEZc6K4MGaE/m0KDcPwQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-2.0.1.tgz", + "integrity": "sha512-42yHBbfWIFisaAfV1eixlabbsa6q7vHeSPY+cg+BBjX51M8xhgMacqH9g6TftB/9+YkcI0ooV4ncfrJslzm/RQ==", "dev": true, "requires": { - "mdast-util-gfm-autolink-literal": "^0.1.0", - "mdast-util-gfm-strikethrough": "^0.2.0", - "mdast-util-gfm-table": "^0.1.0", - "mdast-util-gfm-task-list-item": "^0.1.0", - "mdast-util-to-markdown": "^0.6.1" + "mdast-util-from-markdown": "^1.0.0", + "mdast-util-gfm-autolink-literal": "^1.0.0", + "mdast-util-gfm-footnote": "^1.0.0", + "mdast-util-gfm-strikethrough": "^1.0.0", + "mdast-util-gfm-table": "^1.0.0", + "mdast-util-gfm-task-list-item": "^1.0.0", + "mdast-util-to-markdown": "^1.0.0" } }, "mdast-util-gfm-autolink-literal": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-0.1.3.tgz", - "integrity": "sha512-GjmLjWrXg1wqMIO9+ZsRik/s7PLwTaeCHVB7vRxUwLntZc8mzmTsLVr6HW1yLokcnhfURsn5zmSVdi3/xWWu1A==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-1.0.2.tgz", + "integrity": "sha512-FzopkOd4xTTBeGXhXSBU0OCDDh5lUj2rd+HQqG92Ld+jL4lpUfgX2AT2OHAVP9aEeDKp7G92fuooSZcYJA3cRg==", + "dev": true, + "requires": { + "@types/mdast": "^3.0.0", + "ccount": "^2.0.0", + "mdast-util-find-and-replace": "^2.0.0", + "micromark-util-character": "^1.0.0" + } + }, + "mdast-util-gfm-footnote": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-1.0.1.tgz", + "integrity": "sha512-p+PrYlkw9DeCRkTVw1duWqPRHX6Ywh2BNKJQcZbCwAuP/59B0Lk9kakuAd7KbQprVO4GzdW8eS5++A9PUSqIyw==", "dev": true, "requires": { - "ccount": "^1.0.0", - "mdast-util-find-and-replace": "^1.1.0", - "micromark": "^2.11.3" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.3.0", + "micromark-util-normalize-identifier": "^1.0.0" } }, "mdast-util-gfm-strikethrough": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-0.2.3.tgz", - "integrity": "sha512-5OQLXpt6qdbttcDG/UxYY7Yjj3e8P7X16LzvpX8pIQPYJ/C2Z1qFGMmcw+1PZMUM3Z8wt8NRfYTvCni93mgsgA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-1.0.1.tgz", + "integrity": "sha512-zKJbEPe+JP6EUv0mZ0tQUyLQOC+FADt0bARldONot/nefuISkaZFlmVK4tU6JgfyZGrky02m/I6PmehgAgZgqg==", "dev": true, "requires": { - "mdast-util-to-markdown": "^0.6.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.3.0" } }, "mdast-util-gfm-table": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-0.1.6.tgz", - "integrity": "sha512-j4yDxQ66AJSBwGkbpFEp9uG/LS1tZV3P33fN1gkyRB2LoRL+RR3f76m0HPHaby6F4Z5xr9Fv1URmATlRRUIpRQ==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-1.0.6.tgz", + "integrity": "sha512-uHR+fqFq3IvB3Rd4+kzXW8dmpxUhvgCQZep6KdjsLK4O6meK5dYZEayLtIxNus1XO3gfjfcIFe8a7L0HZRGgag==", "dev": true, "requires": { - "markdown-table": "^2.0.0", - "mdast-util-to-markdown": "~0.6.0" + "@types/mdast": "^3.0.0", + "markdown-table": "^3.0.0", + "mdast-util-from-markdown": "^1.0.0", + "mdast-util-to-markdown": "^1.3.0" } }, "mdast-util-gfm-task-list-item": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-0.1.6.tgz", - "integrity": "sha512-/d51FFIfPsSmCIRNp7E6pozM9z1GYPIkSy1urQ8s/o4TC22BZ7DqfHFWiqBD23bc7J3vV1Fc9O4QIHBlfuit8A==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-1.0.1.tgz", + "integrity": "sha512-KZ4KLmPdABXOsfnM6JHUIjxEvcx2ulk656Z/4Balw071/5qgnhz+H1uGtf2zIGnrnvDC8xR4Fj9uKbjAFGNIeA==", "dev": true, "requires": { - "mdast-util-to-markdown": "~0.6.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.3.0" } }, "mdast-util-inject": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mdast-util-inject/-/mdast-util-inject-1.1.0.tgz", - "integrity": "sha1-2wa4tYW+lZotzS+H9HK6m3VvNnU=", + "integrity": "sha512-CcJ0mHa36QYumDKiZ2OIR+ClhfOM7zIzN+Wfy8tRZ1hpH9DKLCS+Mh4DyK5bCxzE9uxMWcbIpeNFWsg1zrj/2g==", "dev": true, "requires": { "mdast-util-to-string": "^1.0.0" } }, "mdast-util-to-hast": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-10.2.0.tgz", - "integrity": "sha512-JoPBfJ3gBnHZ18icCwHR50orC9kNH81tiR1gs01D8Q5YpV6adHNO9nKNuFBCJQ941/32PT1a63UF/DitmS3amQ==", + "version": "12.2.4", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-12.2.4.tgz", + "integrity": "sha512-a21xoxSef1l8VhHxS1Dnyioz6grrJkoaCUgGzMD/7dWHvboYX3VW53esRUfB5tgTyz4Yos1n25SPcj35dJqmAg==", "dev": true, "requires": { + "@types/hast": "^2.0.0", "@types/mdast": "^3.0.0", - "@types/unist": "^2.0.0", - "mdast-util-definitions": "^4.0.0", - "mdurl": "^1.0.0", - "unist-builder": "^2.0.0", - "unist-util-generated": "^1.0.0", - "unist-util-position": "^3.0.0", - "unist-util-visit": "^2.0.0" + "mdast-util-definitions": "^5.0.0", + "micromark-util-sanitize-uri": "^1.1.0", + "trim-lines": "^3.0.0", + "unist-builder": "^3.0.0", + "unist-util-generated": "^2.0.0", + "unist-util-position": "^4.0.0", + "unist-util-visit": "^4.0.0" } }, "mdast-util-to-markdown": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-0.6.5.tgz", - "integrity": "sha512-XeV9sDE7ZlOQvs45C9UKMtfTcctcaj/pGwH8YLbMHoMOXNNCn2LsqVQOqrF1+/NU8lKDAqozme9SCXWyo9oAcQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-markdown/-/mdast-util-to-markdown-1.3.0.tgz", + "integrity": "sha512-6tUSs4r+KK4JGTTiQ7FfHmVOaDrLQJPmpjD6wPMlHGUVXoG9Vjc3jIeP+uyBWRf8clwB2blM+W7+KrlMYQnftA==", "dev": true, "requires": { + "@types/mdast": "^3.0.0", "@types/unist": "^2.0.0", - "longest-streak": "^2.0.0", - "mdast-util-to-string": "^2.0.0", - "parse-entities": "^2.0.0", - "repeat-string": "^1.0.0", - "zwitch": "^1.0.0" + "longest-streak": "^3.0.0", + "mdast-util-to-string": "^3.0.0", + "micromark-util-decode-string": "^1.0.0", + "unist-util-visit": "^4.0.0", + "zwitch": "^2.0.0" }, "dependencies": { "mdast-util-to-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", - "integrity": "sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", + "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==", "dev": true } } @@ -36457,280 +38757,86 @@ "dev": true }, "mdast-util-toc": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-5.1.0.tgz", - "integrity": "sha512-csimbRIVkiqc+PpFeKDGQ/Ck2N4f9FYH3zzBMMJzcxoKL8m+cM0n94xXm0I9eaxHnKdY9n145SGTdyJC7i273g==", - "dev": true, - "requires": { - "@types/mdast": "^3.0.3", - "@types/unist": "^2.0.3", - "extend": "^3.0.2", - "github-slugger": "^1.2.1", - "mdast-util-to-string": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit": "^2.0.0" - }, - "dependencies": { - "github-slugger": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-1.4.0.tgz", - "integrity": "sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ==", - "dev": true - }, - "mdast-util-to-string": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-2.0.0.tgz", - "integrity": "sha512-AW4DRS3QbBayY/jJmD8437V1Gombjf8RSOUCMFBuo5iHi58AGEgVCKQ+ezHkZZDpAQS75hcBMpLqjpJTjtUL7w==", - "dev": true - } - } - }, - "mdurl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", - "dev": true - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, - "memoizee": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", - "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", - "dev": true, - "requires": { - "d": "^1.0.1", - "es5-ext": "^0.10.53", - "es6-weak-map": "^2.0.3", - "event-emitter": "^0.3.5", - "is-promise": "^2.2.2", - "lru-queue": "^0.1.0", - "next-tick": "^1.1.0", - "timers-ext": "^0.1.7" - } - }, - "memory-fs": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", - "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", - "dev": true, - "requires": { - "errno": "^0.1.3", - "readable-stream": "^2.0.1" - } - }, - "meow": { - "version": "8.1.2", - "resolved": "https://registry.npmjs.org/meow/-/meow-8.1.2.tgz", - "integrity": "sha512-r85E3NdZ+mpYk1C6RjPFEMSE+s1iZMuHtsHAqY0DT3jZczl0diWUZ8g6oU7h0M9cD2EL+PzaYghhCLzR0ZNn5Q==", - "dev": true, - "requires": { - "@types/minimist": "^1.2.0", - "camelcase-keys": "^6.2.2", - "decamelize-keys": "^1.1.0", - "hard-rejection": "^2.1.0", - "minimist-options": "4.1.0", - "normalize-package-data": "^3.0.0", - "read-pkg-up": "^7.0.1", - "redent": "^3.0.0", - "trim-newlines": "^3.0.0", - "type-fest": "^0.18.0", - "yargs-parser": "^20.2.3" - }, - "dependencies": { - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "hosted-git-info": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", - "integrity": "sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "normalize-package-data": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", - "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", - "dev": true, - "requires": { - "hosted-git-info": "^4.0.1", - "is-core-module": "^2.5.0", - "semver": "^7.3.4", - "validate-npm-package-license": "^3.0.1" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "parse-json": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", - "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "error-ex": "^1.3.1", - "json-parse-even-better-errors": "^2.3.0", - "lines-and-columns": "^1.1.6" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "read-pkg": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", - "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", - "dev": true, - "requires": { - "@types/normalize-package-data": "^2.4.0", - "normalize-package-data": "^2.5.0", - "parse-json": "^5.0.0", - "type-fest": "^0.6.0" - }, - "dependencies": { - "hosted-git-info": { - "version": "2.8.9", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", - "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", - "dev": true - }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "type-fest": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", - "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", - "dev": true - } - } + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-6.1.0.tgz", + "integrity": "sha512-0PuqZELXZl4ms1sF7Lqigrqik4Ll3UhbI+jdTrfw7pZ9QPawgl7LD4GQ8MkU7bT/EwiVqChNTbifa2jLLKo76A==", + "dev": true, + "requires": { + "@types/extend": "^3.0.0", + "@types/github-slugger": "^1.0.0", + "@types/mdast": "^3.0.0", + "extend": "^3.0.0", + "github-slugger": "^1.0.0", + "mdast-util-to-string": "^3.1.0", + "unist-util-is": "^5.0.0", + "unist-util-visit": "^3.0.0" + }, + "dependencies": { + "mdast-util-to-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", + "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==", + "dev": true }, - "read-pkg-up": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", - "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "unist-util-visit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", + "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", "dev": true, "requires": { - "find-up": "^4.1.0", - "read-pkg": "^5.2.0", - "type-fest": "^0.8.1" - }, - "dependencies": { - "type-fest": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", - "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", - "dev": true - } + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^4.0.0" } }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "unist-util-visit-parents": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", + "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", "dev": true, "requires": { - "lru-cache": "^6.0.0" + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0" } - }, - "type-fest": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", - "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", - "dev": true - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true } } }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" }, - "merge-source-map": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", - "integrity": "sha512-Qkcp7P2ygktpMPh2mCQZaf3jhN6D3Z/qVZHSdWvQ+2Ef5HgRAPBO57A77+ENm0CPx2+1Ce/MYKi3ymqdfuqibw==", + "memoizee": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz", + "integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==", "dev": true, "requires": { - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } + "d": "^1.0.1", + "es5-ext": "^0.10.53", + "es6-weak-map": "^2.0.3", + "event-emitter": "^0.3.5", + "is-promise": "^2.2.2", + "lru-queue": "^0.1.0", + "next-tick": "^1.1.0", + "timers-ext": "^0.1.7" + } + }, + "memory-fs": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.5.0.tgz", + "integrity": "sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA==", + "dev": true, + "requires": { + "errno": "^0.1.3", + "readable-stream": "^2.0.1" } }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -36740,169 +38846,343 @@ "methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" }, "micromark": { - "version": "2.11.4", - "resolved": "https://registry.npmjs.org/micromark/-/micromark-2.11.4.tgz", - "integrity": "sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-3.1.0.tgz", + "integrity": "sha512-6Mj0yHLdUZjHnOPgr5xfWIMqMWS12zDN6iws9SLuSz76W8jTtAv24MN4/CL7gJrl5vtxGInkkqDv/JIoRsQOvA==", "dev": true, "requires": { + "@types/debug": "^4.0.0", "debug": "^4.0.0", - "parse-entities": "^2.0.0" + "decode-named-character-reference": "^1.0.0", + "micromark-core-commonmark": "^1.0.1", + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-chunked": "^1.0.0", + "micromark-util-combine-extensions": "^1.0.0", + "micromark-util-decode-numeric-character-reference": "^1.0.0", + "micromark-util-encode": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-sanitize-uri": "^1.0.0", + "micromark-util-subtokenize": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.1", + "uvu": "^0.5.0" + } + }, + "micromark-core-commonmark": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-1.0.6.tgz", + "integrity": "sha512-K+PkJTxqjFfSNkfAhp4GB+cZPfQd6dxtTXnf+RjZOV7T4EEXnvgzOcnp+eSTmpGk9d1S9sL6/lqrgSNn/s0HZA==", + "dev": true, + "requires": { + "decode-named-character-reference": "^1.0.0", + "micromark-factory-destination": "^1.0.0", + "micromark-factory-label": "^1.0.0", + "micromark-factory-space": "^1.0.0", + "micromark-factory-title": "^1.0.0", + "micromark-factory-whitespace": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-chunked": "^1.0.0", + "micromark-util-classify-character": "^1.0.0", + "micromark-util-html-tag-name": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-subtokenize": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.1", + "uvu": "^0.5.0" } }, "micromark-extension-gfm": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-0.3.3.tgz", - "integrity": "sha512-oVN4zv5/tAIA+l3GbMi7lWeYpJ14oQyJ3uEim20ktYFAcfX1x3LNlFGGlmrZHt7u9YlKExmyJdDGaTt6cMSR/A==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-2.0.1.tgz", + "integrity": "sha512-p2sGjajLa0iYiGQdT0oelahRYtMWvLjy8J9LOCxzIQsllMCGLbsLW+Nc+N4vi02jcRJvedVJ68cjelKIO6bpDA==", "dev": true, "requires": { - "micromark": "~2.11.0", - "micromark-extension-gfm-autolink-literal": "~0.5.0", - "micromark-extension-gfm-strikethrough": "~0.6.5", - "micromark-extension-gfm-table": "~0.4.0", - "micromark-extension-gfm-tagfilter": "~0.3.0", - "micromark-extension-gfm-task-list-item": "~0.3.0" + "micromark-extension-gfm-autolink-literal": "^1.0.0", + "micromark-extension-gfm-footnote": "^1.0.0", + "micromark-extension-gfm-strikethrough": "^1.0.0", + "micromark-extension-gfm-table": "^1.0.0", + "micromark-extension-gfm-tagfilter": "^1.0.0", + "micromark-extension-gfm-task-list-item": "^1.0.0", + "micromark-util-combine-extensions": "^1.0.0", + "micromark-util-types": "^1.0.0" } }, "micromark-extension-gfm-autolink-literal": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-0.5.7.tgz", - "integrity": "sha512-ePiDGH0/lhcngCe8FtH4ARFoxKTUelMp4L7Gg2pujYD5CSMb9PbblnyL+AAMud/SNMyusbS2XDSiPIRcQoNFAw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-1.0.3.tgz", + "integrity": "sha512-i3dmvU0htawfWED8aHMMAzAVp/F0Z+0bPh3YrbTPPL1v4YAlCZpy5rBO5p0LPYiZo0zFVkoYh7vDU7yQSiCMjg==", + "dev": true, + "requires": { + "micromark-util-character": "^1.0.0", + "micromark-util-sanitize-uri": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + } + }, + "micromark-extension-gfm-footnote": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-1.0.4.tgz", + "integrity": "sha512-E/fmPmDqLiMUP8mLJ8NbJWJ4bTw6tS+FEQS8CcuDtZpILuOb2kjLqPEeAePF1djXROHXChM/wPJw0iS4kHCcIg==", "dev": true, "requires": { - "micromark": "~2.11.3" + "micromark-core-commonmark": "^1.0.0", + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-normalize-identifier": "^1.0.0", + "micromark-util-sanitize-uri": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" } }, "micromark-extension-gfm-strikethrough": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-0.6.5.tgz", - "integrity": "sha512-PpOKlgokpQRwUesRwWEp+fHjGGkZEejj83k9gU5iXCbDG+XBA92BqnRKYJdfqfkrRcZRgGuPuXb7DaK/DmxOhw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-1.0.4.tgz", + "integrity": "sha512-/vjHU/lalmjZCT5xt7CcHVJGq8sYRm80z24qAKXzaHzem/xsDYb2yLL+NNVbYvmpLx3O7SYPuGL5pzusL9CLIQ==", "dev": true, "requires": { - "micromark": "~2.11.0" + "micromark-util-chunked": "^1.0.0", + "micromark-util-classify-character": "^1.0.0", + "micromark-util-resolve-all": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" } }, "micromark-extension-gfm-table": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-0.4.3.tgz", - "integrity": "sha512-hVGvESPq0fk6ALWtomcwmgLvH8ZSVpcPjzi0AjPclB9FsVRgMtGZkUcpE0zgjOCFAznKepF4z3hX8z6e3HODdA==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-1.0.5.tgz", + "integrity": "sha512-xAZ8J1X9W9K3JTJTUL7G6wSKhp2ZYHrFk5qJgY/4B33scJzE2kpfRL6oiw/veJTbt7jiM/1rngLlOKPWr1G+vg==", "dev": true, "requires": { - "micromark": "~2.11.0" + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" } }, "micromark-extension-gfm-tagfilter": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-0.3.0.tgz", - "integrity": "sha512-9GU0xBatryXifL//FJH+tAZ6i240xQuFrSL7mYi8f4oZSbc+NvXjkrHemeYP0+L4ZUT+Ptz3b95zhUZnMtoi/Q==", - "dev": true + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-1.0.1.tgz", + "integrity": "sha512-Ty6psLAcAjboRa/UKUbbUcwjVAv5plxmpUTy2XC/3nJFL37eHej8jrHrRzkqcpipJliuBH30DTs7+3wqNcQUVA==", + "dev": true, + "requires": { + "micromark-util-types": "^1.0.0" + } }, "micromark-extension-gfm-task-list-item": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-0.3.3.tgz", - "integrity": "sha512-0zvM5iSLKrc/NQl84pZSjGo66aTGd57C1idmlWmE87lkMcXrTxg1uXa/nXomxJytoje9trP0NDLvw4bZ/Z/XCQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-1.0.3.tgz", + "integrity": "sha512-PpysK2S1Q/5VXi72IIapbi/jliaiOFzv7THH4amwXeYXLq3l1uo8/2Be0Ac1rEwK20MQEsGH2ltAZLNY2KI/0Q==", + "dev": true, + "requires": { + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + } + }, + "micromark-factory-destination": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-1.0.0.tgz", + "integrity": "sha512-eUBA7Rs1/xtTVun9TmV3gjfPz2wEwgK5R5xcbIM5ZYAtvGF6JkyaDsj0agx8urXnO31tEO6Ug83iVH3tdedLnw==", + "dev": true, + "requires": { + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "micromark-factory-label": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-1.0.2.tgz", + "integrity": "sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==", + "dev": true, + "requires": { + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + } + }, + "micromark-factory-space": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-1.0.0.tgz", + "integrity": "sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==", + "dev": true, + "requires": { + "micromark-util-character": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "micromark-factory-title": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-1.0.2.tgz", + "integrity": "sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==", + "dev": true, + "requires": { + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + } + }, + "micromark-factory-whitespace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-1.0.0.tgz", + "integrity": "sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==", + "dev": true, + "requires": { + "micromark-factory-space": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "micromark-util-character": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-1.1.0.tgz", + "integrity": "sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==", + "dev": true, + "requires": { + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "micromark-util-chunked": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-1.0.0.tgz", + "integrity": "sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==", + "dev": true, + "requires": { + "micromark-util-symbol": "^1.0.0" + } + }, + "micromark-util-classify-character": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-1.0.0.tgz", + "integrity": "sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==", + "dev": true, + "requires": { + "micromark-util-character": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "micromark-util-combine-extensions": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-1.0.0.tgz", + "integrity": "sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==", + "dev": true, + "requires": { + "micromark-util-chunked": "^1.0.0", + "micromark-util-types": "^1.0.0" + } + }, + "micromark-util-decode-numeric-character-reference": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-1.0.0.tgz", + "integrity": "sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==", + "dev": true, + "requires": { + "micromark-util-symbol": "^1.0.0" + } + }, + "micromark-util-decode-string": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-1.0.2.tgz", + "integrity": "sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==", + "dev": true, + "requires": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^1.0.0", + "micromark-util-decode-numeric-character-reference": "^1.0.0", + "micromark-util-symbol": "^1.0.0" + } + }, + "micromark-util-encode": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-1.0.1.tgz", + "integrity": "sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==", + "dev": true + }, + "micromark-util-html-tag-name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-1.1.0.tgz", + "integrity": "sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==", + "dev": true + }, + "micromark-util-normalize-identifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-1.0.0.tgz", + "integrity": "sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==", "dev": true, "requires": { - "micromark": "~2.11.0" + "micromark-util-symbol": "^1.0.0" } }, + "micromark-util-resolve-all": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-1.0.0.tgz", + "integrity": "sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==", + "dev": true, + "requires": { + "micromark-util-types": "^1.0.0" + } + }, + "micromark-util-sanitize-uri": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-1.1.0.tgz", + "integrity": "sha512-RoxtuSCX6sUNtxhbmsEFQfWzs8VN7cTctmBPvYivo98xb/kDEoTCtJQX5wyzIYEmk/lvNFTat4hL8oW0KndFpg==", + "dev": true, + "requires": { + "micromark-util-character": "^1.0.0", + "micromark-util-encode": "^1.0.0", + "micromark-util-symbol": "^1.0.0" + } + }, + "micromark-util-subtokenize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-1.0.2.tgz", + "integrity": "sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==", + "dev": true, + "requires": { + "micromark-util-chunked": "^1.0.0", + "micromark-util-symbol": "^1.0.0", + "micromark-util-types": "^1.0.0", + "uvu": "^0.5.0" + } + }, + "micromark-util-symbol": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-1.0.1.tgz", + "integrity": "sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==", + "dev": true + }, + "micromark-util-types": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-1.0.2.tgz", + "integrity": "sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==", + "dev": true + }, "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - }, - "dependencies": { - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - } + "braces": "^3.0.2", + "picomatch": "^2.3.1" } }, "mime": { @@ -36912,16 +39192,16 @@ "dev": true }, "mime-db": { - "version": "1.51.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" }, "mime-types": { - "version": "2.1.34", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", - "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "requires": { - "mime-db": "1.51.0" + "mime-db": "1.52.0" } }, "mimic-fn": { @@ -36936,11 +39216,14 @@ "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", "dev": true }, - "min-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", - "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", - "dev": true + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==", + "dev": true, + "requires": { + "dom-walk": "^0.1.0" + } }, "minimatch": { "version": "3.1.2", @@ -36952,30 +39235,11 @@ } }, "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", + "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", "dev": true }, - "minimist-options": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz", - "integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==", - "dev": true, - "requires": { - "arrify": "^1.0.1", - "is-plain-obj": "^1.1.0", - "kind-of": "^6.0.3" - }, - "dependencies": { - "kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true - } - } - }, "mixin-deep": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", @@ -36999,43 +39263,128 @@ "dev": true }, "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", + "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", "dev": true, "requires": { + "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" }, "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { - "ms": "2.0.0" + "color-convert": "^2.0.1" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" } }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, + "find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "requires": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + } + }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -37044,139 +39393,132 @@ "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } } }, "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "argparse": "^2.0.1" } }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "requires": { - "minimist": "0.0.8" + "p-locate": "^5.0.0" } }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" } - } - } - }, - "modify-values": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", - "integrity": "sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==", - "dev": true - }, - "module-deps-sortable": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/module-deps-sortable/-/module-deps-sortable-5.0.3.tgz", - "integrity": "sha512-eiyIZj/A0dj1o4ywXWqicazUL3l0HP3TydUR6xF0X3xh3LGBMLqW8a9aFe6MuNH4mxNMk53QKBHM6LOPR8kSgw==", - "dev": true, - "requires": { - "browser-resolve": "^1.7.0", - "cached-path-relative": "^1.0.0", - "concat-stream": "~1.5.0", - "defined": "^1.0.0", - "detective": "^5.2.0", - "duplexer2": "^0.1.2", - "inherits": "^2.0.1", - "JSONStream": "^1.0.3", - "konan": "^2.1.1", - "readable-stream": "^2.0.2", - "resolve": "^1.1.3", - "standard-version": "^9.0.0", - "stream-combiner2": "^1.1.1", - "subarg": "^1.0.0", - "through2": "^2.0.0", - "xtend": "^4.0.0" - }, - "dependencies": { - "concat-stream": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", + }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", "dev": true, "requires": { - "inherits": "~2.0.1", - "readable-stream": "~2.0.0", - "typedarray": "~0.0.5" + "brace-expansion": "^2.0.1" }, "dependencies": { - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" + "balanced-match": "^1.0.0" } } } }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "requires": { + "p-limit": "^3.0.2" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" + "has-flag": "^4.0.0" + } + }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true } } }, @@ -37202,74 +39544,59 @@ "ms": "2.0.0" } }, - "depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "dev": true - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "requires": { + "ee-first": "1.1.1" + } } } }, + "mpd-parser": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/mpd-parser/-/mpd-parser-0.21.1.tgz", + "integrity": "sha512-BxlSXWbKE1n7eyEPBnTEkrzhS3PdmkkKdM1pgKbPnPOH0WFZIc0sPOWi7m0Uo3Wd2a4Or8Qf4ZbS7+ASqQ49fw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "@videojs/vhs-utils": "^3.0.5", + "@xmldom/xmldom": "^0.7.2", + "global": "^4.4.0" + } + }, + "mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true + }, "mrmime": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.0.tgz", - "integrity": "sha512-a70zx7zFfVO7XpnQ2IX1Myh9yY4UYvfld/dikWRnsXxbyvMcfz+u6UfgNAtH+k2QqtJuzVpv6eLTx1G2+WKZbQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz", + "integrity": "sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==", "dev": true }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "multipipe": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "integrity": "sha512-7ZxrUybYv9NonoXgwoOqtStIu18D1c3eFZj27hqgf5kBrBF8Q+tE8V0MW8dKM5QLkQPh1JhhbKgHLY9kifov4Q==", "dev": true, "requires": { "duplexer2": "0.0.2" - }, - "dependencies": { - "duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "~1.1.9" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } } }, "mute-stdout": { @@ -37284,19 +39611,28 @@ "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, + "mux.js": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/mux.js/-/mux.js-6.0.1.tgz", + "integrity": "sha512-22CHb59rH8pWGcPGW5Og7JngJ9s+z4XuSlYvnxhLuc58cA1WqGDQPzuG8I+sPm1/p0CdgpzVTaKW408k5DNn8w==", + "dev": true, + "requires": { + "@babel/runtime": "^7.11.2", + "global": "^4.4.0" + } + }, "nan": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz", - "integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==", + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", + "integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", "dev": true, "optional": true }, "nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", - "dev": true, - "optional": true + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true }, "nanomatch": { "version": "1.2.13", @@ -37317,6 +39653,22 @@ "to-regex": "^3.0.1" }, "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, "kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -37328,13 +39680,13 @@ "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "ncp": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.4.2.tgz", - "integrity": "sha1-q8xsvT7C7Spyn/bnwfqPAXhKhXQ=", + "integrity": "sha512-PfGU8jYWdRl4FqJfCy0IzbkGyFHntfWygZg46nFk/dJD/XRrk2cj0SsKSX9n5u5gE0E0YfEpKWrEkfjnlZSTXA==", "dev": true }, "negotiator": { @@ -37386,7 +39738,7 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "dev": true }, "lolex": { @@ -37419,37 +39771,39 @@ } }, "node-releases": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.2.tgz", - "integrity": "sha512-XxYDdcQ6eKqp/YjI+tb2C5WM2LgjnZrfYg4vgQt49EK268b6gYCHsBLrK2qvJo4FmCtqmKezb0WZFK4fkrZNsg==", - "dev": true + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "integrity": "sha512-4GUt3kSEYmk4ITxzB/b9vaIDfUVWN/Ml1Fwl11IlnIG2iaJ9O6WXZ9SrYM9NLI8OCBieN2Y8SWC2oJV0RQ7qYg==", "dev": true, "requires": { "abbrev": "1" } }, "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", + "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", "dev": true, "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", + "hosted-git-info": "^4.0.1", + "is-core-module": "^2.5.0", + "semver": "^7.3.4", "validate-npm-package-license": "^3.0.1" }, "dependencies": { "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } } } }, @@ -37477,7 +39831,7 @@ "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==", "dev": true, "requires": { "path-key": "^2.0.0" @@ -37486,21 +39840,15 @@ "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", "dev": true } } }, - "null-check": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", - "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", - "dev": true - }, "number-is-nan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "integrity": "sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ==", "dev": true }, "oauth-sign": { @@ -37512,13 +39860,13 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "dev": true }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "integrity": "sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==", "dev": true, "requires": { "copy-descriptor": "^0.1.0", @@ -37529,7 +39877,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -37538,7 +39886,7 @@ "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -37553,7 +39901,7 @@ "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -37581,7 +39929,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -37590,10 +39938,9 @@ } }, "object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==" }, "object-is": { "version": "1.1.5", @@ -37614,28 +39961,28 @@ "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "integrity": "sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==", "dev": true, "requires": { "isobject": "^3.0.0" } }, "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", - "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", "dev": true, "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", "object-keys": "^1.1.1" } }, "object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", - "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "integrity": "sha512-c/K0mw/F11k4dEUBMW8naXUuBuhxRCfG7W+yFy8EcijU/rSmazOUd1XAEEe6bC0OuXY4HUKjTJv7xbxIMqdxrA==", "dev": true, "requires": { "array-each": "^1.0.1", @@ -37647,7 +39994,7 @@ "object.map": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", - "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "integrity": "sha512-3+mAJu2PLfnSVGHwIWubpOFLscJANBKuB/6A4CxBstc4aqwQY0FWcsppuy4jU5GSB95yES5JHSI+33AWuS4k6w==", "dev": true, "requires": { "for-own": "^1.0.0", @@ -37657,7 +40004,7 @@ "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", "dev": true, "requires": { "isobject": "^3.0.1" @@ -37666,7 +40013,7 @@ "object.reduce": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object.reduce/-/object.reduce-1.0.1.tgz", - "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", + "integrity": "sha512-naLhxxpUESbNkRqc35oQ2scZSJueHGQNUfMW/0U37IgN6tE2dgDWg3whf+NEliy3F/QysrO48XKUz/nGPe+AQw==", "dev": true, "requires": { "for-own": "^1.0.0", @@ -37685,9 +40032,9 @@ } }, "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", "requires": { "ee-first": "1.1.1" } @@ -37701,7 +40048,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" @@ -37734,7 +40081,7 @@ "is-wsl": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz", - "integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=", + "integrity": "sha512-gfygJYZ2gLTDlmbWMI0CE2MwnFzSN/2SZfkMlItC4K/JBlsWVDB0bO6XhqcY13YXE7iMcAJnzTCJjPiTeJJ0Mw==", "dev": true } } @@ -37804,6 +40151,12 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -37828,7 +40181,7 @@ "ordered-read-streams": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", - "integrity": "sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4=", + "integrity": "sha512-Z87aSjx3r5c0ZB7bcJqIgIRX5bxR7A4aSzvIbaxd0oTkWBCOoKfuGHiKj60CHVUgg1Phm5yMZzBdt8XqRs73Mw==", "dev": true, "requires": { "readable-stream": "^2.0.1" @@ -37837,13 +40190,13 @@ "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==", "dev": true }, "os-locale": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "integrity": "sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g==", "dev": true, "requires": { "lcid": "^1.0.0" @@ -37852,7 +40205,7 @@ "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", "dev": true }, "p-cancelable": { @@ -37864,7 +40217,7 @@ "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", "dev": true }, "p-iteration": { @@ -37874,27 +40227,27 @@ "dev": true }, "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, "requires": { - "p-try": "^1.0.0" + "p-try": "^2.0.0" } }, "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "dev": true, "requires": { - "p-limit": "^1.1.0" + "p-limit": "^2.2.0" } }, "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "parent-module": { @@ -37906,24 +40259,10 @@ "callsites": "^3.0.0" } }, - "parse-entities": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-2.0.0.tgz", - "integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==", - "dev": true, - "requires": { - "character-entities": "^1.0.0", - "character-entities-legacy": "^1.0.0", - "character-reference-invalid": "^1.0.0", - "is-alphanumerical": "^1.0.0", - "is-decimal": "^1.0.0", - "is-hexadecimal": "^1.0.0" - } - }, "parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", - "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "integrity": "sha512-FwdRXKCohSVeXqwtYonZTXtbGJKrn+HNyWDYVcp5yuJlesTwNH4rsmRZ+GrKAPJ5bLpRxESMeS+Rl0VCHRvB2Q==", "dev": true, "requires": { "is-absolute": "^1.0.0", @@ -37932,13 +40271,15 @@ } }, "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", "dev": true, "requires": { + "@babel/code-frame": "^7.0.0", "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" } }, "parse-ms": { @@ -37956,31 +40297,25 @@ "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "integrity": "sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q==", "dev": true }, "parse-path": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-4.0.3.tgz", - "integrity": "sha512-9Cepbp2asKnWTJ9x2kpw6Fe8y9JDbqwahGCTvklzd/cEq5C5JC59x2Xb0Kx+x0QZ8bvNquGO8/BWP0cwBHzSAA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz", + "integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==", "dev": true, "requires": { - "is-ssh": "^1.3.0", - "protocols": "^1.4.0", - "qs": "^6.9.4", - "query-string": "^6.13.8" + "protocols": "^2.0.0" } }, "parse-url": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-6.0.0.tgz", - "integrity": "sha512-cYyojeX7yIIwuJzledIHeLUBVJ6COVLeT4eF+2P6aKVzwvgKQPndCBv3+yQ7pcWjqToYwaligxzSYNNmGoMAvw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz", + "integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==", "dev": true, "requires": { - "is-ssh": "^1.3.0", - "normalize-url": "^6.1.0", - "parse-path": "^4.0.0", - "protocols": "^1.4.0" + "parse-path": "^7.0.0" } }, "parseurl": { @@ -37991,31 +40326,25 @@ "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==", "dev": true }, "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "integrity": "sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==", "dev": true }, "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -38027,13 +40356,12 @@ "path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" }, "path-root": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "integrity": "sha512-QLcPegTHF11axjfojBIoDygmS2E3Lf+8+jI6wOVmNVenrKSo3mFdSGiIgdSHenczw3wPtlVMQaFVwGmM7BJdtg==", "dev": true, "requires": { "path-root-regex": "^0.1.0" @@ -38042,27 +40370,29 @@ "path-root-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "integrity": "sha512-4GlJ6rZDhQZFE0DPVKh0e9jmZ5egZfxTkp7bcRDuPlJXbAwhxcl2dINPUAsjLdejqaLsCeg8axcLjIbvBjN4pQ==", "dev": true }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg==", "dev": true, "requires": { - "pify": "^3.0.0" + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" }, "dependencies": { "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", "dev": true } } @@ -38076,7 +40406,7 @@ "pause-stream": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "integrity": "sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==", "dev": true, "requires": { "through": "~2.3" @@ -38085,20 +40415,19 @@ "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", "dev": true }, "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, "picomatch": { "version": "2.3.1", @@ -38107,26 +40436,35 @@ "dev": true }, "pify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz", - "integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-6.1.0.tgz", + "integrity": "sha512-KocF8ve28eFjjuBKKGvzOBGzG8ew2OqOOSxTTZhirkzH7h3BI1vyzqlR0qbfcDBve1Yzo3FVlWUAtCRrbVN8Fw==", "dev": true }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", "dev": true, "requires": { "pinkie": "^2.0.0" } }, + "pkcs7": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/pkcs7/-/pkcs7-1.0.4.tgz", + "integrity": "sha512-afRERtHn54AlwaF2/+LFszyAANTCggGilmcmILUzEjvs3XgFZT+xE6+QWQcAGmu4xajy+Xtj7acLOPdx5/eXWQ==", + "dev": true, + "requires": { + "@babel/runtime": "^7.5.5" + } + }, "pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -38134,104 +40472,46 @@ "dev": true, "requires": { "find-up": "^4.0.0" - }, - "dependencies": { - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "requires": { - "p-limit": "^2.2.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - } } }, "plugin-error": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", - "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz", + "integrity": "sha512-WzZHcm4+GO34sjFMxQMqZbsz3xiNEgonCskQ9v+IroMmYgk/tas8dG+Hr2D6IbRPybZ12oWpzE/w3cGJ6FJzOw==", "dev": true, "requires": { - "ansi-colors": "^1.0.1", - "arr-diff": "^4.0.0", - "arr-union": "^3.1.0", - "extend-shallow": "^3.0.2" - }, - "dependencies": { - "ansi-colors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", - "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", - "dev": true, - "requires": { - "ansi-wrap": "^0.1.0" - } - } + "ansi-cyan": "^0.1.1", + "ansi-red": "^0.1.1", + "arr-diff": "^1.0.1", + "arr-union": "^2.0.1", + "extend-shallow": "^1.1.2" } }, - "pluralize": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", - "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", - "dev": true - }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "integrity": "sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==", "dev": true }, "postcss": { - "version": "8.4.8", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.8.tgz", - "integrity": "sha512-2tXEqGxrjvAO6U+CJzDL2Fk2kPHTv1jQsYkSoMeOis2SsYaXRO2COxTdQp99cYvif9JTXaAk9lYGc3VhJt7JPQ==", + "version": "8.4.18", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.18.tgz", + "integrity": "sha512-Wi8mWhncLJm11GATDaQKobXSNEYGUHeQLiQqDFG1qQ5UTDPTEvKw0Xt5NsTpktGTwLps3ByrWsBrG0rB8YQ9oA==", "dev": true, "optional": true, "requires": { - "nanoid": "^3.3.1", + "nanoid": "^3.3.4", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" + }, + "dependencies": { + "nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "dev": true, + "optional": true + } } }, "prelude-ls": { @@ -38241,20 +40521,39 @@ "dev": true }, "pretty-format": { - "version": "27.5.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", - "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "version": "26.6.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz", + "integrity": "sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==", "dev": true, "requires": { - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", + "@jest/types": "^26.6.2", + "ansi-regex": "^5.0.0", + "ansi-styles": "^4.0.0", "react-is": "^17.0.1" }, "dependencies": { "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true } } @@ -38262,7 +40561,7 @@ "pretty-hrtime": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", + "integrity": "sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==", "dev": true }, "pretty-ms": { @@ -38274,18 +40573,18 @@ "parse-ms": "^2.1.0" } }, - "printj": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.3.1.tgz", - "integrity": "sha512-GA3TdL8szPK4AQ2YnOe/b+Y1jUFwmmGMMK/qbY7VcE3Z7FU8JstbKiKRzO6CIiAKPhTO8m01NoQ0V5f3jc4OGg==", - "dev": true - }, "private": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", "dev": true }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "dev": true + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -38299,18 +40598,15 @@ "dev": true }, "property-information": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-5.6.0.tgz", - "integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==", - "dev": true, - "requires": { - "xtend": "^4.0.0" - } + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.1.1.tgz", + "integrity": "sha512-hrzC564QIl0r0vy4l6MvRLhafmUowhO/O3KgVSoXIbbA2Sz4j8HGpJc6T2cubRVwMwpdiG/vKGfhT4IixmKN9w==", + "dev": true }, "protocols": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.8.tgz", - "integrity": "sha512-IgjKyaUSjsROSO8/D49Ab7hP8mJgTYcqApOqdPhLoPxAplXmkp+zRvsrSQjFn5by0rhm4VH0GAUELIPpx7B1yg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/protocols/-/protocols-2.0.1.tgz", + "integrity": "sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q==", "dev": true }, "proxy-addr": { @@ -38331,7 +40627,7 @@ "prr": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", + "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", "dev": true }, "ps-tree": { @@ -38346,13 +40642,13 @@ "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==", "dev": true }, "psl": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", - "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==", "dev": true }, "pump": { @@ -38407,16 +40703,16 @@ "dev": true }, "puppeteer-core": { - "version": "13.5.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.5.1.tgz", - "integrity": "sha512-dobVqWjV34ilyfQHR3BBnCYaekBYTi5MgegEYBRYd3s3uFy8jUpZEEWbaFjG9ETm+LGzR5Lmr0aF6LLuHtiuCg==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-13.7.0.tgz", + "integrity": "sha512-rXja4vcnAzFAP1OVLq/5dWNfwBGuzcOARJ6qGV7oAZhnLmVRU8G5MsdeQEAOy332ZhkIOnn9jp15R89LKHyp2Q==", "dev": true, "requires": { "cross-fetch": "3.1.5", - "debug": "4.3.3", - "devtools-protocol": "0.0.969999", + "debug": "4.3.4", + "devtools-protocol": "0.0.981744", "extract-zip": "2.0.1", - "https-proxy-agent": "5.0.0", + "https-proxy-agent": "5.0.1", "pkg-dir": "4.2.0", "progress": "2.0.3", "proxy-from-env": "1.1.0", @@ -38426,31 +40722,12 @@ "ws": "8.5.0" }, "dependencies": { - "agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "requires": { - "debug": "4" - } - }, "devtools-protocol": { - "version": "0.0.969999", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.969999.tgz", - "integrity": "sha512-6GfzuDWU0OFAuOvBokXpXPLxjOJ5DZ157Ue3sGQQM3LgAamb8m0R0ruSfN0DDu+XG5XJgT50i6zZ/0o8RglreQ==", + "version": "0.0.981744", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", + "integrity": "sha512-0cuGS8+jhR67Fy7qG3i3Pc7Aw494sb9yG9QgpG97SFVWwolgYjlhJg7n+UaHxOQT30d1TYu/EYe9k01ivLErIg==", "dev": true }, - "https-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", - "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", - "dev": true, - "requires": { - "agent-base": "6", - "debug": "4" - } - }, "ws": { "version": "8.5.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", @@ -38463,7 +40740,7 @@ "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", "dev": true }, "qjobs": { @@ -38473,9 +40750,12 @@ "dev": true }, "qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==" + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "requires": { + "side-channel": "^1.0.4" + } }, "query-selector-shadow-dom": { "version": "1.0.0", @@ -38483,22 +40763,10 @@ "integrity": "sha512-bK0/0cCI+R8ZmOF1QjT7HupDUYCxbf/9TJgAmSXQxZpftXmTAeil9DRoCnTDkWbvOyZzhcMBwKpptWcdkGFIMg==", "dev": true }, - "query-string": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.1.tgz", - "integrity": "sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==", - "dev": true, - "requires": { - "decode-uri-component": "^0.2.0", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - } - }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==", "dev": true }, "querystringify": { @@ -38528,12 +40796,12 @@ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" }, "raw-body": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz", - "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", "requires": { "bytes": "3.1.2", - "http-errors": "1.8.1", + "http-errors": "2.0.0", "iconv-lite": "0.4.24", "unpipe": "1.0.0" } @@ -38545,67 +40813,89 @@ "dev": true }, "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-7.1.0.tgz", + "integrity": "sha512-5iOehe+WF75IccPc30bWTbpdDQLOCc3Uu8bi3Dte3Eueij81yx1Mrufk8qBx/YAbR4uL1FdUr+7BKXDwEtisXg==", "dev": true, "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" + "@types/normalize-package-data": "^2.4.1", + "normalize-package-data": "^3.0.2", + "parse-json": "^5.2.0", + "type-fest": "^2.0.0" + }, + "dependencies": { + "type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "dev": true + } } }, "read-pkg-up": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-4.0.0.tgz", - "integrity": "sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA==", + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-9.1.0.tgz", + "integrity": "sha512-vaMRR1AC1nrd5CQM0PhlRsO5oc2AAigqr7cCrZ/MW/Rsaflz4RlgzkpL4qoU/z1F6wrbd85iFv1OQj/y5RdGvg==", "dev": true, "requires": { - "find-up": "^3.0.0", - "read-pkg": "^3.0.0" + "find-up": "^6.3.0", + "read-pkg": "^7.1.0", + "type-fest": "^2.5.0" }, "dependencies": { "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-6.3.0.tgz", + "integrity": "sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==", "dev": true, "requires": { - "locate-path": "^3.0.0" + "locate-path": "^7.1.0", + "path-exists": "^5.0.0" } }, "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.1.1.tgz", + "integrity": "sha512-vJXaRMJgRVD3+cUZs3Mncj2mxpt5mP0EmNOsxRSZRMlbqjvxzDEOIUWXGmavo0ZC9+tNZCBLQ66reA11nbpHZg==", "dev": true, "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" + "p-locate": "^6.0.0" } }, "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", + "integrity": "sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==", "dev": true, "requires": { - "p-try": "^2.0.0" + "yocto-queue": "^1.0.0" } }, "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-6.0.0.tgz", + "integrity": "sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==", "dev": true, "requires": { - "p-limit": "^2.0.0" + "p-limit": "^4.0.0" } }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "path-exists": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", + "integrity": "sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==", + "dev": true + }, + "type-fest": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", + "dev": true + }, + "yocto-queue": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", + "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", "dev": true } } @@ -38628,18 +40918,44 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true } } }, "readdir-glob": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-1.1.1.tgz", - "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/readdir-glob/-/readdir-glob-1.1.2.tgz", + "integrity": "sha512-6RLVvwJtVwEDfPdn6X6Ille4/lxGl0ATOY4FN/B9nxQcgOazvvI0nodiD19ScKq0PvA/29VpaOQML36o5IzZWA==", "dev": true, "requires": { - "minimatch": "^3.0.4" + "minimatch": "^5.1.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "readdirp": { @@ -38654,67 +40970,43 @@ "rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", + "integrity": "sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==", "dev": true, "requires": { "resolve": "^1.1.6" } }, "recursive-readdir": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz", - "integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==", - "dev": true, - "requires": { - "minimatch": "3.0.4" - }, - "dependencies": { - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - } - } - }, - "redent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", - "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz", + "integrity": "sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA==", "dev": true, "requires": { - "indent-string": "^4.0.0", - "strip-indent": "^3.0.0" + "minimatch": "^3.0.5" } }, "regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", - "dev": true + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==" }, "regenerate-unicode-properties": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.0.1.tgz", - "integrity": "sha512-vn5DU6yg6h8hP/2OkQo3K7uVILvY4iu0oI4t3HFa81UPkhGJwkRwM10JEc3upjdhHjs/k8GJY1sRBhk5sr69Bw==", - "dev": true, + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.0.tgz", + "integrity": "sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ==", "requires": { "regenerate": "^1.4.2" } }, "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + "version": "0.13.10", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.10.tgz", + "integrity": "sha512-KepLsg4dU12hryUO7bp/axHAKvwGOCV0sGloQtpagJ12ai+ojVDqkeGSiRX1zlq+kjIMZ1t7gpze+26QqtdGqw==" }, "regenerator-transform": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.5.tgz", - "integrity": "sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw==", - "dev": true, + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.0.tgz", + "integrity": "sha512-LsrGtPmbYg19bcPHwdtmXwbW+TqNvtY4riE3P83foeHRroMbH6/2ddFBfab3t7kbzc7v7p4wbkIecHImqt0QNg==", "requires": { "@babel/runtime": "^7.8.4" } @@ -38727,16 +41019,29 @@ "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + } } }, "regexp.prototype.flags": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.1.tgz", - "integrity": "sha512-pMR7hBVUUGI7PMA37m2ofIdQCsomVnas+Jn5UPGAHQ+/LlwKm/aTLJHdasmHRzlfeZwHiAOaRSo2rbBDm3nNUQ==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" } }, "regexpp": { @@ -38746,30 +41051,27 @@ "dev": true }, "regexpu-core": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.0.1.tgz", - "integrity": "sha512-CriEZlrKK9VJw/xQGJpQM5rY88BtuL8DM+AEwvcThHilbxiTAy8vq4iJnd2tqq8wLmjbGZzP7ZcKFjbGkmEFrw==", - "dev": true, + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.2.1.tgz", + "integrity": "sha512-HrnlNtpvqP1Xkb28tMhBUO2EbyUHdQlsnlAhzWcwHy8WJR53UWr7/MAvqrsQKMbV4qdpv03oTMG8iIhfsPFktQ==", "requires": { "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.0.1", - "regjsgen": "^0.6.0", - "regjsparser": "^0.8.2", + "regenerate-unicode-properties": "^10.1.0", + "regjsgen": "^0.7.1", + "regjsparser": "^0.9.1", "unicode-match-property-ecmascript": "^2.0.0", "unicode-match-property-value-ecmascript": "^2.0.0" } }, "regjsgen": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.6.0.tgz", - "integrity": "sha512-ozE883Uigtqj3bx7OhL1KNbCzGyW2NQZPl6Hs09WTvCuZD5sTI4JY58bkbQWa/Y9hxIsvJ3M8Nbf7j54IqeZbA==", - "dev": true + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.7.1.tgz", + "integrity": "sha512-RAt+8H2ZEzHeYWxZ3H2z6tF18zyyOnlcdaafLrm21Bguj7uZy6ULibiAFdXEtKQY4Sy7wDTwDiOazasMLc4KPA==" }, "regjsparser": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.8.4.tgz", - "integrity": "sha512-J3LABycON/VNEu3abOviqGHuB/LOtOQj8SKmfP9anY5GfAVw/SPjwzSjxGjbZXIxbGfqTHtJw58C2Li/WkStmA==", - "dev": true, + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.9.1.tgz", + "integrity": "sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==", "requires": { "jsesc": "~0.5.0" }, @@ -38777,78 +41079,89 @@ "jsesc": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==" } } }, "remark": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/remark/-/remark-13.0.0.tgz", - "integrity": "sha512-HDz1+IKGtOyWN+QgBiAT0kn+2s6ovOxHyPAFGKVE81VSzJ+mq7RwHFledEvB5F1p4iJvOah/LOKdFuzvRnNLCA==", + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/remark/-/remark-14.0.2.tgz", + "integrity": "sha512-A3ARm2V4BgiRXaUo5K0dRvJ1lbogrbXnhkJRmD0yw092/Yl0kOCZt1k9ZeElEwkZsWGsMumz6qL5MfNJH9nOBA==", "dev": true, "requires": { - "remark-parse": "^9.0.0", - "remark-stringify": "^9.0.0", - "unified": "^9.1.0" + "@types/mdast": "^3.0.0", + "remark-parse": "^10.0.0", + "remark-stringify": "^10.0.0", + "unified": "^10.0.0" } }, "remark-gfm": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-1.0.0.tgz", - "integrity": "sha512-KfexHJCiqvrdBZVbQ6RopMZGwaXz6wFJEfByIuEwGf0arvITHjiKKZ1dpXujjH9KZdm1//XJQwgfnJ3lmXaDPA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-3.0.1.tgz", + "integrity": "sha512-lEFDoi2PICJyNrACFOfDD3JlLkuSbOa5Wd8EPt06HUdptv8Gn0bxYTdbU/XXQ3swAPkEaGxxPN9cbnMHvVu1Ig==", "dev": true, "requires": { - "mdast-util-gfm": "^0.1.0", - "micromark-extension-gfm": "^0.3.0" + "@types/mdast": "^3.0.0", + "mdast-util-gfm": "^2.0.0", + "micromark-extension-gfm": "^2.0.0", + "unified": "^10.0.0" } }, "remark-html": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/remark-html/-/remark-html-13.0.2.tgz", - "integrity": "sha512-LhSRQ+3RKdBqB/RGesFWkNNfkGqprDUCwjq54SylfFeNyZby5kqOG8Dn/vYsRoM8htab6EWxFXCY6XIZvMoRiQ==", + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/remark-html/-/remark-html-15.0.1.tgz", + "integrity": "sha512-7ta5UPRqj8nP0GhGMYUAghZ/DRno7dgq7alcW90A7+9pgJsXzGJlFgwF8HOP1b1tMgT3WwbeANN+CaTimMfyNQ==", "dev": true, "requires": { - "hast-util-sanitize": "^3.0.0", - "hast-util-to-html": "^7.0.0", - "mdast-util-to-hast": "^10.0.0" + "@types/mdast": "^3.0.0", + "hast-util-sanitize": "^4.0.0", + "hast-util-to-html": "^8.0.0", + "mdast-util-to-hast": "^12.0.0", + "unified": "^10.0.0" } }, "remark-parse": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-9.0.0.tgz", - "integrity": "sha512-geKatMwSzEXKHuzBNU1z676sGcDcFoChMK38TgdHJNAYfFtsfHDQG7MoJAjs6sgYMqyLduCYWDIWZIxiPeafEw==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-10.0.1.tgz", + "integrity": "sha512-1fUyHr2jLsVOkhbvPRBJ5zTKZZyD6yZzYaWCS6BPBdQ8vEMBCH+9zNCDA6tET/zHCi/jLqjCWtlJZUPk+DbnFw==", "dev": true, "requires": { - "mdast-util-from-markdown": "^0.8.0" + "@types/mdast": "^3.0.0", + "mdast-util-from-markdown": "^1.0.0", + "unified": "^10.0.0" } }, "remark-reference-links": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-5.0.0.tgz", - "integrity": "sha512-oSIo6lfDyG/1yYl2jPZNXmD9dgyPxp07mSd7snJagVMsDU6NRlD8i54MwHWUgMoOHTs8lIKPkwaUok/tbr5syQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/remark-reference-links/-/remark-reference-links-6.0.1.tgz", + "integrity": "sha512-34wY2C6HXSuKVTRtyJJwefkUD8zBOZOSHFZ4aSTnU2F656gr9WeuQ2dL6IJDK3NPd2F6xKF2t4XXcQY9MygAXg==", "dev": true, "requires": { - "unist-util-visit": "^2.0.0" + "@types/mdast": "^3.0.0", + "unified": "^10.0.0", + "unist-util-visit": "^4.0.0" } }, "remark-stringify": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-9.0.1.tgz", - "integrity": "sha512-mWmNg3ZtESvZS8fv5PTvaPckdL4iNlCHTt8/e/8oN08nArHRHjNZMKzA/YW3+p7/lYqIw4nx1XsjCBo/AxNChg==", + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-10.0.2.tgz", + "integrity": "sha512-6wV3pvbPvHkbNnWB0wdDvVFHOe1hBRAx1Q/5g/EpH4RppAII6J8Gnwe7VbHuXaoKIF6LAg6ExTel/+kNqSQ7lw==", "dev": true, "requires": { - "mdast-util-to-markdown": "^0.6.0" + "@types/mdast": "^3.0.0", + "mdast-util-to-markdown": "^1.0.0", + "unified": "^10.0.0" } }, "remark-toc": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/remark-toc/-/remark-toc-7.2.0.tgz", - "integrity": "sha512-ppHepvpbg7j5kPFmU5rzDC4k2GTcPDvWcxXyr/7BZzO1cBSPk0stKtEJdsgAyw2WHKPGxadcHIZRjb2/sHxjkg==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/remark-toc/-/remark-toc-8.0.1.tgz", + "integrity": "sha512-7he2VOm/cy13zilnOTZcyAoyoolV26ULlon6XyCFU+vG54Z/LWJnwphj/xKIDLOt66QmJUgTyUvLVHi2aAElyg==", "dev": true, "requires": { - "@types/unist": "^2.0.3", - "mdast-util-toc": "^5.0.0" + "@types/mdast": "^3.0.0", + "mdast-util-toc": "^6.0.0", + "unified": "^10.0.0" } }, "remove-bom-buffer": { @@ -38872,7 +41185,7 @@ "remove-bom-stream": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz", - "integrity": "sha1-BfGlk/FuQuH7kOv1nejlaVJflSM=", + "integrity": "sha512-wigO8/O08XHb8YPzpDDT+QmRANfW6vLqxfaXm1YXhnFf3AkSLyjfG3GEFg4McZkmgL7KvCj5u2KczkvSP6NfHA==", "dev": true, "requires": { "remove-bom-buffer": "^3.0.0", @@ -38895,7 +41208,7 @@ "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==", "dev": true }, "repeat-element": { @@ -38907,13 +41220,13 @@ "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==", "dev": true }, "repeating": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "integrity": "sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==", "dev": true, "requires": { "is-finite": "^1.0.0" @@ -38922,13 +41235,13 @@ "replace-ext": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "integrity": "sha512-AFBWBy9EVRTa/LhEcG8QDP3FvpwZqmvN2QFDuJswFeaVhWnZMp8q3E6Zd90SR04PlIwfGdyVjNyLPyen/ek5CQ==", "dev": true }, "replace-homedir": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/replace-homedir/-/replace-homedir-1.0.0.tgz", - "integrity": "sha1-6H9tUTuSjd6AgmDBK+f+xv9ueYw=", + "integrity": "sha512-CHPV/GAglbIB1tnQgaiysb8H2yCy8WQ7lcEwQ/eT+kLj0QHV8LnJW0zpqpE7RSkrMSRoa+EBoag86clf7WAgSg==", "dev": true, "requires": { "homedir-polyfill": "^1.0.1", @@ -38986,7 +41299,7 @@ "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true }, "require-from-string": { @@ -38996,42 +41309,23 @@ "dev": true }, "require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==", "dev": true }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", - "dev": true, - "requires": { - "caller-path": "^0.1.0", - "resolve-from": "^1.0.0" - }, - "dependencies": { - "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true - } - } - }, "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", "dev": true }, "resolve": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", - "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", - "dev": true, + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "requires": { - "is-core-module": "^2.8.1", + "is-core-module": "^2.9.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" } @@ -39045,7 +41339,7 @@ "resolve-dir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "integrity": "sha512-R7uiTjECzvOsWSfdM0QKFNBVFcK27aHOUwdvK53BcW8zqnGdYp0Fbj82cy54+2A4P2tFM22J5kRfe1R+lM/1yg==", "dev": true, "requires": { "expand-tilde": "^2.0.0", @@ -39061,7 +41355,7 @@ "resolve-options": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/resolve-options/-/resolve-options-1.1.0.tgz", - "integrity": "sha1-MrueOcBtZzONyTeMDW1gdFZq0TE=", + "integrity": "sha512-NYDgziiroVeDC29xq7bp/CacZERYsA9bXYd1ZmcJlF3BcrZv5pTb4NG7SjdyKDnXZ84aC4vo2u6sNKIA1LCu/A==", "dev": true, "requires": { "value-or-function": "^3.0.0" @@ -39070,13 +41364,13 @@ "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "integrity": "sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==", "dev": true }, "responselike": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.0.tgz", - "integrity": "sha512-xH48u3FTB9VsZw7R+vvgaKeLKzT6jOogbQhEe/jewwnZgzPcnyWui2Av6JpoYZF/91uueC+lqhWqeURw5/qhCw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", + "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", "dev": true, "requires": { "lowercase-keys": "^2.0.0" @@ -39094,7 +41388,7 @@ "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "integrity": "sha512-bCK/2Z4zLidyB4ReuIsvALH6w31YfAQDmXMqMx6FyfHqvBxtjC0eRumeSu4Bs3XtXwpyIywtSTrVT99BxY1f9w==", "dev": true } } @@ -39142,59 +41436,64 @@ "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", "dev": true }, - "rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true - }, - "rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "rust-result": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rust-result/-/rust-result-1.0.0.tgz", + "integrity": "sha512-6cJzSBU+J/RJCF063onnQf0cDUOHs9uZI1oroSGnHOph+CQTIJ5Pp2hK5kEQq1+7yE/EEWfulSNXAQ2jikPthA==", "dev": true, "requires": { - "rx-lite": "*" + "individual": "^2.0.0" } }, "rxjs": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.5.5.tgz", - "integrity": "sha512-sy+H0pQofO95VDmFLzyaw9xNJU4KTRSwQIGM6+iG3SypAtCiLDzpeG8sJrNCWn2Up9km+KhkvTdbkrdy+yzZdw==", + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", "dev": true, "requires": { - "tslib": "^2.1.0" - }, - "dependencies": { - "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", - "dev": true - } + "tslib": "^1.9.0" + } + }, + "sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dev": true, + "requires": { + "mri": "^1.1.0" } }, "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "safe-json-parse": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-1.0.1.tgz", - "integrity": "sha1-PnZyPjjf3aE8mx0poeB//uSzC1c=", + "integrity": "sha512-o0JmTu17WGUaUOHa1l0FPGXKBfijbxK6qoHzlkihsDXxzBHvJcA7zgviKR92Xs841rX9pK16unfphLq0/KqX7A==", "dev": true }, "safe-regex": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==", "dev": true, "requires": { "ret": "~0.1.10" } }, + "safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + } + }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -39228,49 +41527,41 @@ "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } - }, - "ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} } } }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", - "dev": true + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==" }, "semver-greatest-satisfied-range": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/semver-greatest-satisfied-range/-/semver-greatest-satisfied-range-1.1.0.tgz", - "integrity": "sha1-E+jCZYq5aRywzXEJMkAoDTb3els=", + "integrity": "sha512-Ny/iyOzSSa8M5ML46IAx3iXc6tfOsYU2R4AXi2UpHk60Zrgyq6eqPj/xiOfS0rRl/iiQ/rdJkVjw/5cdUyCntQ==", "dev": true, "requires": { "sver-compat": "^1.5.0" } }, "send": { - "version": "0.17.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz", - "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "requires": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", + "depd": "2.0.0", + "destroy": "1.2.0", "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "1.8.1", + "http-errors": "2.0.0", "mime": "1.6.0", "ms": "2.1.3", - "on-finished": "~2.3.0", + "on-finished": "2.4.1", "range-parser": "~1.2.1", - "statuses": "~1.5.0" + "statuses": "2.0.1" }, "dependencies": { "debug": { @@ -39284,7 +41575,7 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" } } }, @@ -39329,7 +41620,7 @@ "serve-index": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", - "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", + "integrity": "sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw==", "dev": true, "requires": { "accepts": "~1.3.4", @@ -39350,10 +41641,16 @@ "ms": "2.0.0" } }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==", + "dev": true + }, "http-errors": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "integrity": "sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A==", "dev": true, "requires": { "depd": "~1.1.2", @@ -39365,13 +41662,13 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "setprototypeof": { @@ -39379,24 +41676,30 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", "dev": true + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true } } }, "serve-static": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz", - "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "requires": { "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.17.2" + "send": "0.18.0" } }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, "set-value": { @@ -39414,7 +41717,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -39423,7 +41726,7 @@ "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true }, "is-plain-object": { @@ -39440,7 +41743,7 @@ "setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", "dev": true }, "setprototypeof": { @@ -39467,7 +41770,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, "requires": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -39500,21 +41802,6 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } } } }, @@ -39530,9 +41817,9 @@ } }, "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==", "dev": true }, "slice-ansi": { @@ -39600,7 +41887,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -39609,7 +41896,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -39618,7 +41905,7 @@ "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -39627,7 +41914,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -39644,7 +41931,7 @@ "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -39653,7 +41940,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -39675,13 +41962,13 @@ "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "source-map-resolve": { @@ -39713,7 +42000,7 @@ "define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "requires": { "is-descriptor": "^1.0.0" @@ -39739,7 +42026,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -39748,40 +42035,48 @@ } }, "socket.io": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.4.1.tgz", - "integrity": "sha512-s04vrBswdQBUmuWJuuNTmXUVJhP0cVky8bBDhdkf8y0Ptsu7fKU2LuLbts9g+pdmAdyMMn8F/9Mf1/wbtUN0fg==", + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.6.1.tgz", + "integrity": "sha512-KMcaAi4l/8+xEjkRICl6ak8ySoxsYG+gG6/XfRCPJPQ/haCRIJBTL4wIl8YCsmtaBovcAXGLOShyVWQ/FG8GZA==", "dev": true, "requires": { "accepts": "~1.3.4", "base64id": "~2.0.0", "debug": "~4.3.2", - "engine.io": "~6.1.0", - "socket.io-adapter": "~2.3.3", - "socket.io-parser": "~4.0.4" + "engine.io": "~6.4.1", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.1" } }, "socket.io-adapter": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.3.3.tgz", - "integrity": "sha512-Qd/iwn3VskrpNO60BeRyCyr8ZWw9CPZyitW4AQwmRZ8zCiyDiL+znRnWX6tDHXnWn1sJrM1+b6Mn6wEDJJ4aYQ==", - "dev": true + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", + "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", + "dev": true, + "requires": { + "ws": "~8.11.0" + } }, "socket.io-parser": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz", - "integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.3.tgz", + "integrity": "sha512-JMafRntWVO2DCJimKsRTh/wnqVvO4hrfwOqtO7f+uzwsQMuxO6VwImtYxaQ+ieoyshWOTJyV0fA21lccEXRPpQ==", "dev": true, "requires": { - "@types/component-emitter": "^1.2.10", - "component-emitter": "~1.3.0", + "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" } }, + "source-list-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", + "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==", + "dev": true + }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", "dev": true }, "source-map-js": { @@ -39802,21 +42097,12 @@ } }, "source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", "dev": true, "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } + "source-map": "^0.5.6" } }, "source-map-url": { @@ -39833,9 +42119,9 @@ "optional": true }, "space-separated-tokens": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz", - "integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.1.tgz", + "integrity": "sha512-ekwEbFp5aqSPKaqeY1PGrlGQxPNaq+Cnx4+bE2D8sciBQrHpbwoBbawqTN2+6jPs9IdWxxiUcN0K2pkczD3zmw==", "dev": true }, "sparkles": { @@ -39871,26 +42157,20 @@ } }, "spdx-license-ids": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", - "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz", + "integrity": "sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==", "dev": true }, "split": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "integrity": "sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==", "dev": true, "requires": { "through": "2" } }, - "split-on-first": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", - "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", - "dev": true - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -39898,18 +42178,46 @@ "dev": true, "requires": { "extend-shallow": "^3.0.0" + }, + "dependencies": { + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + } } }, "split2": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", - "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==", - "dev": true + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", + "integrity": "sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==", + "dev": true, + "requires": { + "readable-stream": "^3.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, "sshpk": { @@ -39932,7 +42240,7 @@ "stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", "dev": true }, "stack-utils": { @@ -39952,114 +42260,10 @@ } } }, - "standard-version": { - "version": "9.3.2", - "resolved": "https://registry.npmjs.org/standard-version/-/standard-version-9.3.2.tgz", - "integrity": "sha512-u1rfKP4o4ew7Yjbfycv80aNMN2feTiqseAhUhrrx2XtdQGmu7gucpziXe68Z4YfHVqlxVEzo4aUA0Iu3VQOTgQ==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "conventional-changelog": "3.1.24", - "conventional-changelog-config-spec": "2.1.0", - "conventional-changelog-conventionalcommits": "4.6.1", - "conventional-recommended-bump": "6.1.0", - "detect-indent": "^6.0.0", - "detect-newline": "^3.1.0", - "dotgitignore": "^2.1.0", - "figures": "^3.1.0", - "find-up": "^5.0.0", - "fs-access": "^1.0.1", - "git-semver-tags": "^4.0.0", - "semver": "^7.1.1", - "stringify-package": "^1.0.1", - "yargs": "^16.0.0" - }, - "dependencies": { - "detect-newline": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", - "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", - "dev": true - }, - "find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "requires": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - } - }, - "locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "requires": { - "p-locate": "^5.0.0" - } - }, - "p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "requires": { - "yocto-queue": "^0.1.0" - } - }, - "p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "requires": { - "p-limit": "^3.0.2" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - } - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true - } - } - }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "integrity": "sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==", "dev": true, "requires": { "define-property": "^0.2.5", @@ -40069,7 +42273,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -40078,7 +42282,7 @@ "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -40087,7 +42291,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -40104,7 +42308,7 @@ "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -40113,7 +42317,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -40135,53 +42339,9 @@ } }, "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" - }, - "stream-array": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/stream-array/-/stream-array-1.1.2.tgz", - "integrity": "sha1-nl9zRfITfDDuO0mLkRToC1K7frU=", - "dev": true, - "requires": { - "readable-stream": "~2.1.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", - "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", - "dev": true, - "requires": { - "buffer-shims": "^1.0.0", - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" }, "stream-buffers": { "version": "3.0.2", @@ -40192,22 +42352,12 @@ "stream-combiner": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "integrity": "sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==", "dev": true, "requires": { "duplexer": "~0.1.1" } }, - "stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "requires": { - "duplexer2": "~0.1.0", - "readable-stream": "^2.0.2" - } - }, "stream-exhaust": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", @@ -40221,22 +42371,44 @@ "dev": true }, "streamroller": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.0.4.tgz", - "integrity": "sha512-GI9NzeD+D88UFuIlJkKNDH/IsuR+qIN7Qh8EsmhoRZr9bQoehTraRgwtLUkZbpcAw+hLPfHOypmppz8YyGK68w==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.3.tgz", + "integrity": "sha512-CphIJyFx2SALGHeINanjFRKQ4l7x2c+rXYJ4BMq0gd+ZK0gi4VT8b+eHe2wi58x4UayBAKx4xtHpXT/ea1cz8w==", "dev": true, "requires": { - "date-format": "^4.0.4", - "debug": "^4.3.3", - "fs-extra": "^10.0.1" + "date-format": "^4.0.14", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" + }, + "dependencies": { + "fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + } } }, - "strict-uri-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", - "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=", - "dev": true - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -40244,12 +42416,20 @@ "dev": true, "requires": { "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "string-template": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz", - "integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=", + "integrity": "sha512-Yptehjogou2xm4UJbxJ4CxgZx12HBfeystp0y3x7s4Dj32ltVVG1Gg8YhKjHZkHicuKpZX/ffilA8505VbUbpw==", "dev": true }, "string-width": { @@ -40261,53 +42441,40 @@ "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.1" - }, - "dependencies": { - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - } } }, "string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", + "integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" } }, "string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", - "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", + "integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", "dev": true, "requires": { "call-bind": "^1.0.2", - "define-properties": "^1.1.3" + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" } }, "stringify-entities": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-3.1.0.tgz", - "integrity": "sha512-3FP+jGMmMV/ffZs86MoghGqAoqXAdxLrJP4GUdrDN1aIScYih5tuIO3eF4To5AJZ79KDZ8Fpdy7QJnK8SsL1Vg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.3.tgz", + "integrity": "sha512-BP9nNHMhhfcMbiuQKCqMjhDP5yBCAxsPu4pHFFzJ6Alo9dZgY4VLDPutXqIjpRiMoKdp7Av85Gr73Q5uH9k7+g==", "dev": true, "requires": { - "character-entities-html4": "^1.0.0", - "character-entities-legacy": "^1.0.0", - "xtend": "^4.0.0" + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" } }, - "stringify-package": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/stringify-package/-/stringify-package-1.0.1.tgz", - "integrity": "sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg==", - "dev": true - }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -40320,70 +42487,50 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true }, "strip-bom-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", - "integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=", + "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==", "dev": true }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==", "dev": true }, - "strip-indent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", - "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", - "dev": true, - "requires": { - "min-indent": "^1.0.0" - } - }, "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.0.tgz", + "integrity": "sha512-V1LGY4UUo0jgwC+ELQ2BNWfPa17TIuwBLg+j1AA/9RPzKINl1lhxVEu2r+ZTTO8aetIsUzE5Qj6LMSBkoGYKKw==", "dev": true }, - "subarg": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", - "dev": true, - "requires": { - "minimist": "^1.1.0" - } - }, "suffix": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/suffix/-/suffix-0.1.1.tgz", - "integrity": "sha1-zFgjFkag7xEC95R47zqSSP2chC8=", + "integrity": "sha512-j5uf6MJtMCfC4vBe5LFktSe4bGyNTBk7I2Kdri0jeLrcv5B9pWfxVa5JQpoxgtR8vaVB7bVxsWgnfQbX5wkhAA==", "dev": true }, "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "requires": { - "has-flag": "^4.0.0" + "has-flag": "^3.0.0" } }, "supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, "sver-compat": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/sver-compat/-/sver-compat-1.5.0.tgz", - "integrity": "sha1-PPh9/rTQe0o/FIJ7wYaz/QxkXNg=", + "integrity": "sha512-aFTHfmjwizMNlNE6dsGmoAM4lHjL0CyiobWaFiXWSlD7cIxshW422Nb8KbXCmR6z+0ZEPY+daXJrDyh/vuwTyg==", "dev": true, "requires": { "es6-iterator": "^2.0.1", @@ -40404,9 +42551,9 @@ }, "dependencies": { "ajv": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.10.0.tgz", - "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.11.0.tgz", + "integrity": "sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -40470,7 +42617,7 @@ "temp-fs": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/temp-fs/-/temp-fs-0.9.9.tgz", - "integrity": "sha1-gHFzBDeHByDpQxUy/igUNk+IA9c=", + "integrity": "sha512-WfecDCR1xC9b0nsrzSaxPf3ZuWeWLUWblW4vlDQAa1biQaKHiImHnJfeQocQe/hXKMcolRzgkcVX/7kK4zoWbw==", "dev": true, "requires": { "rimraf": "~2.5.2" @@ -40479,7 +42626,7 @@ "rimraf": { "version": "2.5.4", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", - "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", + "integrity": "sha512-Lw7SHMjssciQb/rRz7JyPIy9+bbUshEucPoLRvWqy09vC5zQixl8Uet+Zl+SROBB/JMWHJRdCk1qdxNWHNMvlQ==", "dev": true, "requires": { "glob": "^7.0.5" @@ -40512,48 +42659,52 @@ } }, "terser": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.12.0.tgz", - "integrity": "sha512-R3AUhNBGWiFc77HXag+1fXpAxTAFRQTJemlJKjAgD9r8xXTpjNKqIXwHM/o7Rh+O0kUJtS3WQVdBeMKFk5sw9A==", + "version": "5.15.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.15.1.tgz", + "integrity": "sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==", "dev": true, "requires": { + "@jridgewell/source-map": "^0.3.2", "acorn": "^8.5.0", "commander": "^2.20.0", - "source-map": "~0.7.2", "source-map-support": "~0.5.20" }, "dependencies": { "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", - "dev": true - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true }, "source-map": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", - "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true + }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } } } }, "terser-webpack-plugin": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.1.tgz", - "integrity": "sha512-GvlZdT6wPQKbDNW/GDQzZFg/j4vKU96yl2q6mcUkzKOgW4gwf1Z8cZToUCrz31XHlPWH8MVb1r2tFtdDtTGJ7g==", + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", + "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", "dev": true, "requires": { + "@jridgewell/trace-mapping": "^0.3.14", "jest-worker": "^27.4.5", "schema-utils": "^3.1.1", "serialize-javascript": "^6.0.0", - "source-map": "^0.6.1", - "terser": "^5.7.2" + "terser": "^5.14.1" }, "dependencies": { "ajv": { @@ -40568,13 +42719,6 @@ "uri-js": "^4.2.2" } }, - "ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} - }, "schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -40585,25 +42729,24 @@ "ajv": "^6.12.5", "ajv-keywords": "^3.5.2" } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true } } }, - "text-extensions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz", - "integrity": "sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==", - "dev": true + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "textextensions": { @@ -40615,7 +42758,7 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "through2": { @@ -40665,7 +42808,7 @@ "time-stamp": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", - "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "integrity": "sha512-gLCeArryy2yNTRzTGKbZbloctj64jkZ57hj5zdraXue6aFgd6PmvVtEyiUU+hvU0v7q08oVv8r8ev0tRo6bvgw==", "dev": true }, "timers-ext": { @@ -40720,7 +42863,7 @@ "to-absolute-glob": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz", - "integrity": "sha1-GGX0PZ50sIItufFFt4z/fQ98hJs=", + "integrity": "sha512-rtwLUQEwT8ZeKQbyFJyomBRYXyE16U5VKuy0ftxLMK/PZb2fkOsg5r9kHdauuVDbsNdIBoC/HCthpidamQFXYA==", "dev": true, "requires": { "is-absolute": "^1.0.0", @@ -40730,13 +42873,12 @@ "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==" }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "integrity": "sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -40751,7 +42893,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -40769,6 +42911,18 @@ "extend-shallow": "^3.0.2", "regex-not": "^1.0.2", "safe-regex": "^1.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + } } }, "to-regex-range": { @@ -40778,20 +42932,12 @@ "dev": true, "requires": { "is-number": "^7.0.0" - }, - "dependencies": { - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - } } }, "to-through": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-through/-/to-through-2.0.0.tgz", - "integrity": "sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY=", + "integrity": "sha512-+QIz37Ly7acM4EMdw2PRN389OneM5+d844tirkGp4dPKzI5OE72V9OsbFp+CIYJDahZ41ZV05hNtcPAQUAm9/Q==", "dev": true, "requires": { "through2": "^2.0.3" @@ -40833,42 +42979,42 @@ "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, "traverse": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=", + "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==", "dev": true }, - "trim-newlines": { + "trim-lines": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", - "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", + "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", + "integrity": "sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==", "dev": true }, "trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "integrity": "sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==", "dev": true }, "trough": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz", - "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/trough/-/trough-2.1.0.tgz", + "integrity": "sha512-AqTiAOLcj85xS7vQ8QkAV41hPDIJ71XJB4RCUrzo/1GM2CQwhkJGaf9Hgr7BOugMRpgGUrqRg/DrBDl4H40+8g==", "dev": true }, "tsconfig-paths": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.13.0.tgz", - "integrity": "sha512-nWuffZppoaYK0vQ1SQmkSsQzJoHA4s6uzdb2waRpD806x9yfq153AdVsWz4je2qZcW+pENrMQXbGQ3sMCkXuhw==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz", + "integrity": "sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==", "dev": true, "requires": { "@types/json5": "^0.0.29", "json5": "^1.0.1", - "minimist": "^1.2.0", + "minimist": "^1.2.6", "strip-bom": "^3.0.0" }, "dependencies": { @@ -40892,7 +43038,7 @@ "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", "dev": true, "requires": { "safe-buffer": "^5.0.1" @@ -40901,7 +43047,7 @@ "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==", "dev": true }, "type": { @@ -40943,13 +43089,13 @@ "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, "typescript": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.3.tgz", - "integrity": "sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true, "peer": true }, @@ -40975,27 +43121,27 @@ } }, "ua-parser-js": { - "version": "0.7.31", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.31.tgz", - "integrity": "sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ==", + "version": "0.7.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.33.tgz", + "integrity": "sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw==", "dev": true }, "uglify-js": { - "version": "3.15.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.15.2.tgz", - "integrity": "sha512-peeoTk3hSwYdoc9nrdiEJk+gx1ALCtTjdYuKSXMTDqq7n1W7dHPqWDdSi+BPL0ni2YMeHD7hKUSdbj3TZauY2A==", + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", + "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", "dev": true, "optional": true }, "unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", - "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, "requires": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", "which-boxed-primitive": "^1.0.2" } }, @@ -41012,7 +43158,7 @@ "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "integrity": "sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg==", "dev": true }, "undertaker": { @@ -41036,7 +43182,7 @@ "fast-levenshtein": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz", - "integrity": "sha1-5qdUzI8V5YmHqpy9J69m/W9OWvk=", + "integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==", "dev": true } } @@ -41044,20 +43190,18 @@ "undertaker-registry": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/undertaker-registry/-/undertaker-registry-1.0.1.tgz", - "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=", + "integrity": "sha512-UR1khWeAjugW3548EfQmL9Z7pGMlBgXteQpr1IZeZBtnkCJQJIJ1Scj0mb9wQaPvUZ9Q17XqW6TIaPchJkyfqw==", "dev": true }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", - "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==", - "dev": true + "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==" }, "unicode-match-property-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dev": true, "requires": { "unicode-canonical-property-names-ecmascript": "^2.0.0", "unicode-property-aliases-ecmascript": "^2.0.0" @@ -41066,35 +43210,26 @@ "unicode-match-property-value-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.0.0.tgz", - "integrity": "sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw==", - "dev": true + "integrity": "sha512-7Yhkc0Ye+t4PNYzOGKedDhXbYIBe1XEQYQxOPyhcXNMJ0WCABqqj6ckydd6pWRZTHV4GuCPKdBAUiMc60tsKVw==" }, "unicode-property-aliases-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.0.0.tgz", - "integrity": "sha512-5Zfuy9q/DFr4tfO7ZPeVXb1aPoeQSdeFMLpYuFebehDAhbuevLs5yxSZmIFN1tP5F9Wl4IpJrYojg85/zgyZHQ==", - "dev": true + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", + "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==" }, "unified": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.2.tgz", - "integrity": "sha512-Sg7j110mtefBD+qunSLO1lqOEKdrwBFBrR6Qd8f4uwkhWNlbkaqwHse6e7QvD3AP/MNoJdEDLaf8OxYyoWgorQ==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/unified/-/unified-10.1.2.tgz", + "integrity": "sha512-pUSWAi/RAnVy1Pif2kAoeWNBa3JVrx0MId2LASj8G+7AiHWoKZNTomq6LG326T68U7/e263X6fTdcXIy7XnF7Q==", "dev": true, "requires": { - "bail": "^1.0.0", + "@types/unist": "^2.0.0", + "bail": "^2.0.0", "extend": "^3.0.0", "is-buffer": "^2.0.0", - "is-plain-obj": "^2.0.0", - "trough": "^1.0.0", - "vfile": "^4.0.0" - }, - "dependencies": { - "is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true - } + "is-plain-obj": "^4.0.0", + "trough": "^2.0.0", + "vfile": "^5.0.0" } }, "union-value": { @@ -41109,10 +43244,16 @@ "set-value": "^2.0.1" }, "dependencies": { + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true } } @@ -41128,57 +43269,63 @@ } }, "unist-builder": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-2.0.3.tgz", - "integrity": "sha512-f98yt5pnlMWlzP539tPc4grGMsFaQQlP/vM396b00jngsiINumNmsY8rkXjfoi1c6QaM8nQ3vaGDuoKWbe/1Uw==", - "dev": true + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-3.0.0.tgz", + "integrity": "sha512-GFxmfEAa0vi9i5sd0R2kcrI9ks0r82NasRq5QHh2ysGngrc6GiqD5CDf1FjPenY4vApmFASBIIlk/jj5J5YbmQ==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0" + } }, "unist-util-generated": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.6.tgz", - "integrity": "sha512-cln2Mm1/CZzN5ttGK7vkoGw+RZ8VcUH6BtGbq98DDtRGquAAOXig1mrBQYelOwMXYS8rK+vZDyyojSjp7JX+Lg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-2.0.0.tgz", + "integrity": "sha512-TiWE6DVtVe7Ye2QxOVW9kqybs6cZexNwTwSMVgkfjEReqy/xwGpAXb99OxktoWwmL+Z+Epb0Dn8/GNDYP1wnUw==", "dev": true }, "unist-util-is": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.1.0.tgz", - "integrity": "sha512-ZOQSsnce92GrxSqlnEEseX0gi7GH9zTJZ0p9dtu87WRb/37mMPO2Ilx1s/t9vBHrFhbgweUwb+t7cIn5dxPhZg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-5.1.1.tgz", + "integrity": "sha512-F5CZ68eYzuSvJjGhCLPL3cYx45IxkqXSetCcRgUXtbcm50X2L9oOWQlfUfDdAf+6Pd27YDblBfdtmsThXmwpbQ==", "dev": true }, "unist-util-position": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.1.0.tgz", - "integrity": "sha512-w+PkwCbYSFw8vpgWD0v7zRCl1FpY3fjDSQ3/N/wNd9Ffa4gPi8+4keqt99N3XW6F99t/mUzp2xAhNmfKWp95QA==", - "dev": true + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-4.0.3.tgz", + "integrity": "sha512-p/5EMGIa1qwbXjA+QgcBXaPWjSnZfQ2Sc3yBEEfgPwsEmJd8Qh+DSk3LGnmOM4S1bY2C0AjmMnB8RuEYxpPwXQ==", + "dev": true, + "requires": { + "@types/unist": "^2.0.0" + } }, "unist-util-stringify-position": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", - "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-3.0.2.tgz", + "integrity": "sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==", "dev": true, "requires": { - "@types/unist": "^2.0.2" + "@types/unist": "^2.0.0" } }, "unist-util-visit": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", - "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-4.1.1.tgz", + "integrity": "sha512-n9KN3WV9k4h1DxYR1LoajgN93wpEi/7ZplVe02IoB4gH5ctI1AaF2670BLHQYbwj+pY83gFtyeySFiyMHJklrg==", "dev": true, "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0", - "unist-util-visit-parents": "^3.0.0" + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^5.1.1" } }, "unist-util-visit-parents": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz", - "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-5.1.1.tgz", + "integrity": "sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==", "dev": true, "requires": { "@types/unist": "^2.0.0", - "unist-util-is": "^4.0.0" + "unist-util-is": "^5.0.0" } }, "universalify": { @@ -41190,12 +43337,12 @@ "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "integrity": "sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==", "dev": true, "requires": { "has-value": "^0.3.1", @@ -41205,7 +43352,7 @@ "has-value": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "integrity": "sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==", "dev": true, "requires": { "get-value": "^2.0.3", @@ -41216,7 +43363,7 @@ "isobject": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==", "dev": true, "requires": { "isarray": "1.0.0" @@ -41227,13 +43374,13 @@ "has-values": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "integrity": "sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==", "dev": true }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true } } @@ -41253,6 +43400,17 @@ "listenercount": "~1.0.1", "readable-stream": "~2.3.6", "setimmediate": "~1.0.4" + }, + "dependencies": { + "duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", + "dev": true, + "requires": { + "readable-stream": "^2.0.2" + } + } } }, "upath": { @@ -41261,6 +43419,15 @@ "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", "dev": true }, + "update-browserslist-db": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", + "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -41273,13 +43440,13 @@ "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "integrity": "sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==", "dev": true }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", "dev": true, "requires": { "punycode": "1.3.2", @@ -41289,7 +43456,7 @@ "punycode": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==", "dev": true } } @@ -41304,6 +43471,12 @@ "requires-port": "^1.0.0" } }, + "url-toolkit": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/url-toolkit/-/url-toolkit-2.2.5.tgz", + "integrity": "sha512-mtN6xk+Nac+oyJ/PrI7tzfmomRVNFIWKUbG8jdYFt52hxbiReFAXIjYskvu64/dvuW71IcB7lV8l0HvZMac6Jg==", + "dev": true + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", @@ -41311,29 +43484,28 @@ "dev": true }, "util": { - "version": "0.12.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.4.tgz", - "integrity": "sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw==", + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", "dev": true, "requires": { "inherits": "^2.0.3", "is-arguments": "^1.0.4", "is-generator-function": "^1.0.7", "is-typed-array": "^1.1.3", - "safe-buffer": "^5.1.2", "which-typed-array": "^1.1.2" } }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==" }, "uuid": { "version": "3.4.0", @@ -41341,6 +43513,18 @@ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, + "uvu": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz", + "integrity": "sha512-+g8ENReyr8YsOc6fv/NVJs2vFdHBnBNdfE49rshrTzDWOlUx4Gq7KOS2GD8eqhy2j+Ejq29+SbKH8yjkAqXqoA==", + "dev": true, + "requires": { + "dequal": "^2.0.0", + "diff": "^5.0.0", + "kleur": "^4.0.3", + "sade": "^1.7.3" + } + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", @@ -41369,18 +43553,18 @@ "value-or-function": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz", - "integrity": "sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM=", + "integrity": "sha512-jdBB2FrWvQC/pnPtIqcLsMaQgjhdb6B7tk1MMyTKapox+tQZbdRP4uLxu/JY0t7fbfDCUMnuelzEYv5GsxHhdg==", "dev": true }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", "dev": true, "requires": { "assert-plus": "^1.0.0", @@ -41391,76 +43575,186 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true } } }, "vfile": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.1.tgz", - "integrity": "sha512-O6AE4OskCG5S1emQ/4gl8zK586RqA3srz3nfK/Viy0UPToBc5Trp9BVFb1u0CjsKrAWwnpr4ifM/KBXPWwJbCA==", + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-5.3.5.tgz", + "integrity": "sha512-U1ho2ga33eZ8y8pkbQLH54uKqGhFJ6GYIHnnG5AhRpAh3OWjkrRHKa/KogbmQn8We+c0KVV3rTOgR9V/WowbXQ==", "dev": true, "requires": { "@types/unist": "^2.0.0", "is-buffer": "^2.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-message": "^2.0.0" + "unist-util-stringify-position": "^3.0.0", + "vfile-message": "^3.0.0" } }, "vfile-message": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", - "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-3.1.2.tgz", + "integrity": "sha512-QjSNP6Yxzyycd4SVOtmKKyTsSvClqBPJcd00Z0zuPj3hOIjg0rUPG6DbFGPvUKRgYyaIWLPKpuEclcuvb3H8qA==", "dev": true, "requires": { "@types/unist": "^2.0.0", - "unist-util-stringify-position": "^2.0.0" + "unist-util-stringify-position": "^3.0.0" } }, "vfile-reporter": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-6.0.2.tgz", - "integrity": "sha512-GN2bH2gs4eLnw/4jPSgfBjo+XCuvnX9elHICJZjVD4+NM0nsUrMTvdjGY5Sc/XG69XVTgLwj7hknQVc6M9FukA==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/vfile-reporter/-/vfile-reporter-7.0.4.tgz", + "integrity": "sha512-4cWalUnLrEnbeUQ+hARG5YZtaHieVK3Jp4iG5HslttkVl+MHunSGNAIrODOTLbtjWsNZJRMCkL66AhvZAYuJ9A==", "dev": true, "requires": { - "repeat-string": "^1.5.0", - "string-width": "^4.0.0", - "supports-color": "^6.0.0", - "unist-util-stringify-position": "^2.0.0", - "vfile-sort": "^2.1.2", - "vfile-statistics": "^1.1.0" + "@types/supports-color": "^8.0.0", + "string-width": "^5.0.0", + "supports-color": "^9.0.0", + "unist-util-stringify-position": "^3.0.0", + "vfile-sort": "^3.0.0", + "vfile-statistics": "^2.0.0" }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true }, - "supports-color": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", - "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", + "emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "requires": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + } + }, + "strip-ansi": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", + "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "ansi-regex": "^6.0.1" } + }, + "supports-color": { + "version": "9.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.2.3.tgz", + "integrity": "sha512-aszYUX/DVK/ed5rFLb/dDinVJrQjG/vmU433wtqVSD800rYsJNWxh2R3USV90aLSU+UsyQkbNeffVLzc6B6foA==", + "dev": true } } }, "vfile-sort": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-2.2.2.tgz", - "integrity": "sha512-tAyUqD2R1l/7Rn7ixdGkhXLD3zsg+XLAeUDUhXearjfIcpL1Hcsj5hHpCoy/gvfK/Ws61+e972fm0F7up7hfYA==", - "dev": true + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/vfile-sort/-/vfile-sort-3.0.0.tgz", + "integrity": "sha512-fJNctnuMi3l4ikTVcKpxTbzHeCgvDhnI44amA3NVDvA6rTC6oKCFpCVyT5n2fFMr3ebfr+WVQZedOCd73rzSxg==", + "dev": true, + "requires": { + "vfile-message": "^3.0.0" + } }, "vfile-statistics": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-1.1.4.tgz", - "integrity": "sha512-lXhElVO0Rq3frgPvFBwahmed3X03vjPF8OcjKMy8+F1xU/3Q3QU3tKEDp743SFtb74PdF0UWpxPvtOP0GCLheA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/vfile-statistics/-/vfile-statistics-2.0.0.tgz", + "integrity": "sha512-foOWtcnJhKN9M2+20AOTlWi2dxNfAoeNIoxD5GXcO182UJyId4QrXa41fWrgcfV3FWTjdEDy3I4cpLVcQscIMA==", + "dev": true, + "requires": { + "vfile-message": "^3.0.0" + } + }, + "video.js": { + "version": "7.20.3", + "resolved": "https://registry.npmjs.org/video.js/-/video.js-7.20.3.tgz", + "integrity": "sha512-JMspxaK74LdfWcv69XWhX4rILywz/eInOVPdKefpQiZJSMD5O8xXYueqACP2Q5yqKstycgmmEKlJzZ+kVmDciw==", + "dev": true, + "requires": { + "@babel/runtime": "^7.12.5", + "@videojs/http-streaming": "2.14.3", + "@videojs/vhs-utils": "^3.0.4", + "@videojs/xhr": "2.6.0", + "aes-decrypter": "3.1.3", + "global": "^4.4.0", + "keycode": "^2.2.0", + "m3u8-parser": "4.7.1", + "mpd-parser": "0.21.1", + "mux.js": "6.0.1", + "safe-json-parse": "4.0.0", + "videojs-font": "3.2.0", + "videojs-vtt.js": "^0.15.4" + }, + "dependencies": { + "safe-json-parse": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-4.0.0.tgz", + "integrity": "sha512-RjZPPHugjK0TOzFrLZ8inw44s9bKox99/0AZW9o/BEQVrJfhI+fIHMErnPyRa89/yRXUUr93q+tiN6zhoVV4wQ==", + "dev": true, + "requires": { + "rust-result": "^1.0.0" + } + } + } + }, + "videojs-contrib-ads": { + "version": "6.9.0", + "resolved": "https://registry.npmjs.org/videojs-contrib-ads/-/videojs-contrib-ads-6.9.0.tgz", + "integrity": "sha512-nzKz+jhCGMTYffSNVYrmp9p70s05v6jUMOY3Z7DpVk3iFrWK4Zi/BIkokDWrMoHpKjdmCdKzfJVBT+CrUj6Spw==", + "dev": true, + "requires": { + "global": "^4.3.2", + "video.js": "^6 || ^7" + } + }, + "videojs-font": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/videojs-font/-/videojs-font-3.2.0.tgz", + "integrity": "sha512-g8vHMKK2/JGorSfqAZQUmYYNnXmfec4MLhwtEFS+mMs2IDY398GLysy6BH6K+aS1KMNu/xWZ8Sue/X/mdQPliA==", "dev": true }, + "videojs-ima": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/videojs-ima/-/videojs-ima-1.11.0.tgz", + "integrity": "sha512-ZRoWuGyJ75zamwZgpr0i/gZ6q7Evda/Q6R46gpW88WN7u0ORU7apw/lM1MSG4c3YDXW8LDENgzMAvMZUdifWhg==", + "dev": true, + "requires": { + "@hapi/cryptiles": "^5.1.0", + "can-autoplay": "^3.0.0", + "extend": ">=3.0.2", + "lodash": ">=4.17.19", + "lodash.template": ">=4.5.0", + "videojs-contrib-ads": "^6.6.5" + } + }, + "videojs-playlist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/videojs-playlist/-/videojs-playlist-5.0.0.tgz", + "integrity": "sha512-TM9bytwKqkE05wdWPEKDpkwMGhS/VgMCIsEuNxmX1J1JO9zaTIl4Wm3egf5j1dhIw19oWrqGUV/nK0YNIelCpA==", + "dev": true, + "requires": { + "global": "^4.3.2", + "video.js": "^6 || ^7" + } + }, + "videojs-vtt.js": { + "version": "0.15.4", + "resolved": "https://registry.npmjs.org/videojs-vtt.js/-/videojs-vtt.js-0.15.4.tgz", + "integrity": "sha512-r6IhM325fcLb1D6pgsMkTQT1PpFdUdYZa1iqk7wJEu+QlibBwATPfPc9Bg8Jiym0GE5yP1AG2rMLu+QMVWkYtA==", + "dev": true, + "requires": { + "global": "^4.3.1" + } + }, "vinyl": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.1.tgz", @@ -41523,7 +43817,7 @@ "vinyl-sourcemap": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz", - "integrity": "sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY=", + "integrity": "sha512-NiibMgt6VJGJmyw7vtzhctDcfKch4e4n9TBeoWlirb7FMg9/1Ov9k+A5ZRAtywBpRPiyECvQRQllYM8dECegVA==", "dev": true, "requires": { "append-buffer": "^1.0.2", @@ -41538,7 +43832,7 @@ "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "requires": { "remove-trailing-separator": "^1.0.1" @@ -41549,7 +43843,7 @@ "vinyl-sourcemaps-apply": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", - "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", + "integrity": "sha512-+oDh3KYZBoZC8hfocrbrxbLUeaYtQK7J5WU5Br9VqWqmCll3tFJqKp97GC9GmMsVIL0qnx2DgEDVxdo5EZ5sSw==", "dev": true, "requires": { "source-map": "^0.5.1" @@ -41558,18 +43852,18 @@ "void-elements": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "integrity": "sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung==", "dev": true }, "vue-template-compiler": { - "version": "2.6.14", - "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.14.tgz", - "integrity": "sha512-ODQS1SyMbjKoO1JBJZojSw6FE4qnh9rIpUZn2EUT86FKizx9uH5z6uXiIrm4/Nb/gwxTi/o17ZDEGWAXHvtC7g==", + "version": "2.7.13", + "resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.13.tgz", + "integrity": "sha512-jYM6TClwDS9YqP48gYrtAtaOhRKkbYmbzE+Q51gX5YDr777n7tNI/IZk4QV4l/PjQPNh/FVa/E92sh/RqKMrog==", "dev": true, "optional": true, "requires": { "de-indent": "^1.0.2", - "he": "^1.1.0" + "he": "^1.2.0" } }, "walk": { @@ -41582,9 +43876,9 @@ } }, "watchpack": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz", - "integrity": "sha512-x0t0JuydIo8qCNctdDrn1OzH/qDzk2+rdCOC3YzumZ42fiMqmQ7T3xQurykYMhYfHaPHTp4ZxAx2NfUo1K6QaA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", "dev": true, "requires": { "glob-to-regexp": "^0.4.1", @@ -41594,51 +43888,120 @@ "wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", + "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", "dev": true, "requires": { "defaults": "^1.0.3" } }, "webdriver": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.16.16.tgz", - "integrity": "sha512-x8UoG9k/P8KDrfSh1pOyNevt9tns3zexoMxp9cKnyA/7HYSErhZYTLGlgxscAXLtQG41cMH/Ba/oBmOx7Hgd8w==", + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.5.3.tgz", + "integrity": "sha512-cDTn/hYj5x8BYwXxVb/WUwqGxrhCMP2rC8ttIWCfzmiVtmOnJGulC7CyxU3+p9Q5R/gIKTzdJOss16dhb+5CoA==", "dev": true, "requires": { - "@types/node": "^17.0.4", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/protocols": "7.16.7", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@wdio/config": "7.5.3", + "@wdio/logger": "7.5.3", + "@wdio/protocols": "7.5.3", + "@wdio/types": "7.5.3", + "@wdio/utils": "7.5.3", "got": "^11.0.2", - "ky": "^0.29.0", "lodash.merge": "^4.6.1" + }, + "dependencies": { + "@wdio/logger": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.5.3.tgz", + "integrity": "sha512-r9EADpm0ncS1bDQSWi/nhF9C59/WNLbdAAFlo782E9ItFCpDhNit3aQP9vETv1vFxJRjUIM8Fw/HW8zwPadkbw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/types": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.5.3.tgz", + "integrity": "sha512-jmumhKBhNDABnpmrshYLEcdE9WoP5tmynsDNbDABlb/W8FFiLySQOejukhYIL9CLys4zXerV3/edks0SCzHOiQ==", + "dev": true, + "requires": { + "got": "^11.8.1" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "webdriverio": { - "version": "7.16.16", - "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.16.16.tgz", - "integrity": "sha512-caPaEWyuD3Qoa7YkW4xCCQA4v9Pa9wmhFGPvNZh3ERtjMCNi8L/XXOdkekWNZmFh3tY0kFguBj7+fAwSY7HAGw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-7.25.4.tgz", + "integrity": "sha512-agkgwn2SIk5cAJ03uue1GnGZcUZUDN3W4fUMY9/VfO8bVJrPEgWg31bPguEWPu+YhEB/aBJD8ECxJ3OEKdy4qQ==", "dev": true, "requires": { "@types/aria-query": "^5.0.0", - "@types/node": "^17.0.4", - "@wdio/config": "7.16.16", - "@wdio/logger": "7.16.0", - "@wdio/protocols": "7.16.7", - "@wdio/repl": "7.16.14", - "@wdio/types": "7.16.14", - "@wdio/utils": "7.16.14", + "@types/node": "^18.0.0", + "@wdio/config": "7.25.4", + "@wdio/logger": "7.19.0", + "@wdio/protocols": "7.22.0", + "@wdio/repl": "7.25.4", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", "archiver": "^5.0.0", "aria-query": "^5.0.0", "css-shorthand-properties": "^1.1.1", "css-value": "^0.0.1", - "devtools": "7.16.16", - "devtools-protocol": "^0.0.973690", + "devtools": "7.25.4", + "devtools-protocol": "^0.0.1061995", "fs-extra": "^10.0.0", - "get-port": "^5.1.1", "grapheme-splitter": "^1.0.2", "lodash.clonedeep": "^4.5.0", "lodash.isobject": "^3.0.2", @@ -41650,9 +44013,85 @@ "resq": "^1.9.1", "rgb2hex": "0.2.5", "serialize-error": "^8.0.0", - "webdriver": "7.16.16" + "webdriver": "7.25.4" }, "dependencies": { + "@types/node": { + "version": "18.11.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz", + "integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==", + "dev": true + }, + "@wdio/config": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/config/-/config-7.25.4.tgz", + "integrity": "sha512-vb0emDtD9FbFh/yqW6oNdo2iuhQp8XKj6GX9fyy9v4wZgg3B0HPMVJxhIfcoHz7LMBWlHSo9YdvhFI5EQHRLBA==", + "dev": true, + "requires": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", + "deepmerge": "^4.0.0", + "glob": "^8.0.3" + } + }, + "@wdio/logger": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@wdio/logger/-/logger-7.19.0.tgz", + "integrity": "sha512-xR7SN/kGei1QJD1aagzxs3KMuzNxdT/7LYYx+lt6BII49+fqL/SO+5X0FDCZD0Ds93AuQvvz9eGyzrBI2FFXmQ==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "loglevel": "^1.6.0", + "loglevel-plugin-prefix": "^0.8.4", + "strip-ansi": "^6.0.0" + } + }, + "@wdio/protocols": { + "version": "7.22.0", + "resolved": "https://registry.npmjs.org/@wdio/protocols/-/protocols-7.22.0.tgz", + "integrity": "sha512-8EXRR+Ymdwousm/VGtW3H1hwxZ/1g1H99A1lF0U4GuJ5cFWHCd0IVE5H31Z52i8ZruouW8jueMkGZPSo2IIUSQ==", + "dev": true + }, + "@wdio/repl": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/repl/-/repl-7.25.4.tgz", + "integrity": "sha512-kYhj9gLsUk4HmlXLqkVre+gwbfvw9CcnrHjqIjrmMS4mR9D8zvBb5CItb3ZExfPf9jpFzIFREbCAYoE9x/kMwg==", + "dev": true, + "requires": { + "@wdio/utils": "7.25.4" + } + }, + "@wdio/types": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/types/-/types-7.25.4.tgz", + "integrity": "sha512-muvNmq48QZCvocctnbe0URq2FjJjUPIG4iLoeMmyF0AQgdbjaUkMkw3BHYNHVTbSOU9WMsr2z8alhj/I2H6NRQ==", + "dev": true, + "requires": { + "@types/node": "^18.0.0", + "got": "^11.8.1" + } + }, + "@wdio/utils": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@wdio/utils/-/utils-7.25.4.tgz", + "integrity": "sha512-8iwQDk+foUqSzKZKfhLxjlCKOkfRJPNHaezQoevNgnrTq/t0ek+ldZCATezb9B8jprAuP4mgS9xi22akc6RkzA==", + "dev": true, + "requires": { + "@wdio/logger": "7.19.0", + "@wdio/types": "7.25.4", + "p-iteration": "^1.1.8" + } + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, "brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -41662,27 +44101,103 @@ "balanced-match": "^1.0.0" } }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "glob": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz", + "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "ky": { + "version": "0.30.0", + "resolved": "https://registry.npmjs.org/ky/-/ky-0.30.0.tgz", + "integrity": "sha512-X/u76z4JtDVq10u1JA5UQfatPxgPaVDMYTrgHyiTpGN2z4TMEJkIHsoSBBSg9SWZEIXTKsi9kHgiQ9o3Y/4yog==", + "dev": true + }, "minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "requires": { "brace-expansion": "^2.0.1" } + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "webdriver": { + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/webdriver/-/webdriver-7.25.4.tgz", + "integrity": "sha512-6nVDwenh0bxbtUkHASz9B8T9mB531Fn1PcQjUGj2t5dolLPn6zuK1D7XYVX40hpn6r3SlYzcZnEBs4X0az5Txg==", + "dev": true, + "requires": { + "@types/node": "^18.0.0", + "@wdio/config": "7.25.4", + "@wdio/logger": "7.19.0", + "@wdio/protocols": "7.22.0", + "@wdio/types": "7.25.4", + "@wdio/utils": "7.25.4", + "got": "^11.0.2", + "ky": "0.30.0", + "lodash.merge": "^4.6.1" + } } } }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", "dev": true }, "webpack": { - "version": "5.70.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.70.0.tgz", - "integrity": "sha512-ZMWWy8CeuTTjCxbeaQI21xSswseF2oNOwc70QSKNePvmxE7XW36i7vpBMYZFAUHPwQiEbNGCEYIOOlyRbdGmxw==", + "version": "5.76.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz", + "integrity": "sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==", "dev": true, "requires": { "@types/eslint-scope": "^3.7.3", @@ -41690,31 +44205,31 @@ "@webassemblyjs/ast": "1.11.1", "@webassemblyjs/wasm-edit": "1.11.1", "@webassemblyjs/wasm-parser": "1.11.1", - "acorn": "^8.4.1", + "acorn": "^8.7.1", "acorn-import-assertions": "^1.7.6", "browserslist": "^4.14.5", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.9.2", + "enhanced-resolve": "^5.10.0", "es-module-lexer": "^0.9.0", "eslint-scope": "5.1.1", "events": "^3.2.0", "glob-to-regexp": "^0.4.1", "graceful-fs": "^4.2.9", - "json-parse-better-errors": "^1.0.2", + "json-parse-even-better-errors": "^2.3.1", "loader-runner": "^4.2.0", "mime-types": "^2.1.27", "neo-async": "^2.6.2", "schema-utils": "^3.1.0", "tapable": "^2.1.1", "terser-webpack-plugin": "^5.1.3", - "watchpack": "^2.3.1", + "watchpack": "^2.4.0", "webpack-sources": "^3.2.3" }, "dependencies": { "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true }, "acorn-import-assertions": { @@ -41736,13 +44251,6 @@ "uri-js": "^4.2.2" } }, - "ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} - }, "schema-utils": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", @@ -41757,9 +44265,9 @@ } }, "webpack-bundle-analyzer": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.5.0.tgz", - "integrity": "sha512-GUMZlM3SKwS8Z+CKeIFx7CVoHn3dXFcUAjT/dcZQQmfSZGvitPfMob2ipjai7ovFFqPvTqkEZ/leL4O0YOdAYQ==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.7.0.tgz", + "integrity": "sha512-j9b8ynpJS4K+zfO5GGwsAcQX4ZHpWV+yRiHDiL+bE0XHJ8NiPYLTNVQdlFYWxtpg9lfAQNlwJg16J9AJtFSXRg==", "dev": true, "requires": { "acorn": "^8.0.4", @@ -41774,15 +44282,9 @@ }, "dependencies": { "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", - "dev": true - }, - "acorn-walk": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", - "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "version": "8.8.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", + "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", "dev": true }, "ansi-styles": { @@ -41825,6 +44327,12 @@ "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", "dev": true }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -41835,14 +44343,42 @@ } }, "ws": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", - "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", "dev": true, "requires": {} } } }, + "webpack-manifest-plugin": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webpack-manifest-plugin/-/webpack-manifest-plugin-5.0.0.tgz", + "integrity": "sha512-8RQfMAdc5Uw3QbCQ/CBV/AXqOR8mt03B6GJmRbhWopE8GzRfEpn+k0ZuWywxW+5QZsffhmFDY1J6ohqJo+eMuw==", + "dev": true, + "requires": { + "tapable": "^2.0.0", + "webpack-sources": "^2.2.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + }, + "webpack-sources": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-2.3.1.tgz", + "integrity": "sha512-y9EI9AO42JjEcrTJFOYmVywVZdKVUfOvDUPsJea5GIr1JOEGFVqwlY2K098fFoIjOkDzHn2AjRvM8dsBZu+gCA==", + "dev": true, + "requires": { + "source-list-map": "^2.0.1", + "source-map": "^0.6.1" + } + } + } + }, "webpack-merge": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.2.2.tgz", @@ -41872,6 +44408,66 @@ "supports-color": "^8.1.1", "through": "^2.3.8", "vinyl": "^2.2.1" + }, + "dependencies": { + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", + "dev": true, + "requires": { + "ansi-wrap": "^0.1.0" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" + } + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "websocket-driver": { @@ -41894,7 +44490,7 @@ "whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, "requires": { "tr46": "~0.0.3", @@ -41936,41 +44532,83 @@ } }, "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ==", "dev": true }, "which-typed-array": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.7.tgz", - "integrity": "sha512-vjxaB4nfDqwKI0ws7wZpxIlde1XrLX5uB0ZjpfshgmapJMD7jJWhZI+yToJTqaFByF0eNBcYxbjmCzoRP7CfEw==", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.8.tgz", + "integrity": "sha512-Jn4e5PItbcAHyLoRDwvPj1ypu27DJbtdYXUa5zsinrUx77Uvfb0cXwwnGMTn7cjUfhhqgVQnVJCwF+7cgU7tpw==", "dev": true, "requires": { "available-typed-arrays": "^1.0.5", "call-bind": "^1.0.2", - "es-abstract": "^1.18.5", - "foreach": "^2.0.5", + "es-abstract": "^1.20.0", + "for-each": "^0.3.3", "has-tostringtag": "^1.0.0", - "is-typed-array": "^1.1.7" + "is-typed-array": "^1.1.9" + } + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "requires": { + "string-width": "^1.0.2 || 2" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", "dev": true }, "workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", "dev": true }, "wrap-ansi": { @@ -42013,33 +44651,33 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", "dev": true, "requires": { "mkdirp": "^0.5.1" }, "dependencies": { "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" } } } }, "ws": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", - "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "dev": true, "requires": {} }, @@ -42064,13 +44702,13 @@ "yargs": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/yargs/-/yargs-1.3.3.tgz", - "integrity": "sha1-BU3oth8i7v23IHBZ6u+da4P7kxo=", + "integrity": "sha512-7OGt4xXoWJQh5ulgZ78rKaqY7dNWbjfK+UKxGcIlaM2j7C4fqGchyv8CPvEWdRPrHp6Ula/YU8yGRpYGOHrI+g==", "dev": true }, "yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true }, "yargs-unparser": { @@ -42091,12 +44729,6 @@ "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "dev": true }, - "decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true - }, "is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -42108,7 +44740,7 @@ "yarn-install": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yarn-install/-/yarn-install-1.0.0.tgz", - "integrity": "sha1-V/RQULgu/VcYKzlzxUqgXLXSUjA=", + "integrity": "sha512-VO1u181msinhPcGvQTVMnHVOae8zjX/NSksR17e6eXHRveDvHCF5mGjh9hkN8mzyfnCqcBe42LdTs7bScuTaeg==", "dev": true, "requires": { "cac": "^3.0.3", @@ -42119,19 +44751,19 @@ "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "requires": { "ansi-styles": "^2.2.1", @@ -42144,7 +44776,7 @@ "cross-spawn": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz", - "integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=", + "integrity": "sha512-yAXz/pA1tD8Gtg2S98Ekf/sewp3Lcp3YoFKJ4Hkp5h5yLWnKVTDU0kwjKJ8NDCYcfTLfyGkzTikst+jWypT1iA==", "dev": true, "requires": { "lru-cache": "^4.0.1", @@ -42164,7 +44796,7 @@ "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" @@ -42173,7 +44805,7 @@ "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", "dev": true }, "which": { @@ -42188,7 +44820,7 @@ "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true } } @@ -42196,7 +44828,7 @@ "yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", - "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "dev": true, "requires": { "buffer-crc32": "~0.2.3", @@ -42234,9 +44866,9 @@ } }, "zwitch": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-1.0.5.tgz", - "integrity": "sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.2.tgz", + "integrity": "sha512-JZxotl7SxAJH0j7dN4pxsTV6ZLXoLdGME+PsjkL/DaBrVryK9kTGq06GfKrwcSOqypP+fdXGoCHE36b99fWVoA==", "dev": true } } diff --git a/package.json b/package.json index aed77f3aa74..0bffde226f6 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "prebid.js", - "version": "6.21.0-pre", + "version": "8.17.0-pre", "description": "Header Bidding Management Library", "main": "src/prebid.js", "scripts": { + "serve": "gulp serve", "test": "gulp test", "lint": "gulp lint" }, @@ -28,32 +29,31 @@ "prebid" ], "globalVarName": "pbjs", + "defineGlobal": true, "author": "the prebid.js contributors", "license": "Apache-2.0", "engines": { "node": ">=8.9.0" }, "devDependencies": { - "@babel/core": "^7.16.7", "@babel/eslint-parser": "^7.16.5", - "@babel/preset-env": "^7.16.8", - "@jsdevtools/coverage-istanbul-loader": "^3.0.3", - "@wdio/browserstack-service": "^7.16.0", - "@wdio/cli": "^7.5.2", - "@wdio/concise-reporter": "^7.5.2", - "@wdio/local-runner": "^7.5.2", - "@wdio/mocha-framework": "^7.5.2", - "@wdio/spec-reporter": "^7.19.0", - "@wdio/sync": "^7.5.2", + "@wdio/browserstack-service": "~7.16.0", + "@wdio/cli": "~7.5.2", + "@wdio/concise-reporter": "~7.5.2", + "@wdio/local-runner": "~7.5.2", + "@wdio/mocha-framework": "~7.5.2", + "@wdio/spec-reporter": "~7.19.0", + "@wdio/sync": "~7.5.2", "ajv": "6.12.3", "assert": "^2.0.0", "babel-loader": "^8.0.5", + "babel-plugin-istanbul": "^6.1.1", "babel-register": "^6.26.0", "body-parser": "^1.19.0", "chai": "^4.2.0", "coveralls": "^3.1.0", "deep-equal": "^2.0.3", - "documentation": "^13.2.5", + "documentation": "^14.0.0", "es5-shim": "^4.5.14", "eslint": "^7.27.0", "eslint-config-standard": "^10.2.1", @@ -66,12 +66,10 @@ "faker": "^5.5.3", "fs.extra": "^1.3.2", "gulp": "^4.0.0", - "gulp-clean": "^0.3.2", + "gulp-clean": "^0.4.0", "gulp-concat": "^2.6.0", "gulp-connect": "^5.7.0", - "gulp-eslint": "^4.0.0", - "gulp-footer": "^2.0.2", - "gulp-header": "^2.0.9", + "gulp-eslint": "^6.0.0", "gulp-if": "^3.0.0", "gulp-js-escape": "^1.0.1", "gulp-replace": "^1.0.0", @@ -101,7 +99,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^5.0.0", "lodash": "^4.17.21", - "mocha": "^5.0.0", + "mocha": "^10.0.0", "morgan": "^1.10.0", "opn": "^5.4.0", "resolve-from": "^5.0.0", @@ -109,24 +107,32 @@ "through2": "^4.0.2", "url": "^0.11.0", "url-parse": "^1.0.5", + "video.js": "^7.17.0", + "videojs-contrib-ads": "^6.9.0", + "videojs-ima": "^1.11.0", + "videojs-playlist": "^5.0.0", "webdriverio": "^7.6.1", "webpack": "^5.70.0", "webpack-bundle-analyzer": "^4.5.0", + "webpack-manifest-plugin": "^5.0.0", "webpack-stream": "^7.0.0", "yargs": "^1.3.1" }, "dependencies": { - "babel-plugin-transform-object-assign": "^6.22.0", + "@babel/core": "^7.16.7", + "@babel/plugin-transform-runtime": "^7.18.9", + "@babel/preset-env": "^7.16.8", + "@babel/runtime": "^7.18.9", "core-js": "^3.13.0", "core-js-pure": "^3.13.0", "criteo-direct-rsa-validate": "^1.1.0", "crypto-js": "^3.3.0", "dlv": "1.1.3", - "dset": "2.0.1", + "dset": "3.1.2", "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "2.3.1" + "live-connect-js": "^6.0.1" }, "optionalDependencies": { "fsevents": "^2.3.2" diff --git a/plugins/eslint/validateImports.js b/plugins/eslint/validateImports.js index 37a87fffb50..324b75c4ce7 100644 --- a/plugins/eslint/validateImports.js +++ b/plugins/eslint/validateImports.js @@ -1,11 +1,17 @@ -let path = require('path'); -let _ = require('lodash'); -let resolveFrom = require('resolve-from'); +const path = require('path'); +const _ = require('lodash'); +const resolveFrom = require('resolve-from'); +const MODULES_PATH = path.resolve(__dirname, '../../modules'); + +function isInDirectory(filename, dir) { + const rel = path.relative(dir, filename); + return rel && !rel.startsWith('..') && !path.isAbsolute(rel); +} function flagErrors(context, node, importPath) { let absFileDir = path.dirname(context.getFilename()); - let absImportPath = path.resolve(absFileDir, importPath); + let absImportPath = importPath.startsWith('.') ? path.resolve(absFileDir, importPath) : require.resolve(importPath); try { resolveFrom(absFileDir, importPath); @@ -20,16 +26,9 @@ function flagErrors(context, node, importPath) { ) { context.report(node, `import "${importPath}" not in import whitelist`); } else { - let absModulePath = path.resolve(__dirname, '../../modules'); - - // don't allow import of any files directly within modules folder or index.js files within modules' sub-folders - if ( - path.dirname(absImportPath) === absModulePath || ( - absImportPath.startsWith(absModulePath) && - path.basename(absImportPath) === 'index.js' - ) - ) { - context.report(node, `import "${importPath}" cannot require module entry point`); + // do not allow cross-module imports + if (isInDirectory(absImportPath, MODULES_PATH) && (!isInDirectory(absImportPath, absFileDir) || absFileDir === MODULES_PATH)) { + context.report(node, `import "${importPath}": importing from modules is not allowed`); } // don't allow extension-less local imports diff --git a/plugins/pbjsGlobals.js b/plugins/pbjsGlobals.js index 79dafd1e8b2..6d1eeb0c57d 100644 --- a/plugins/pbjsGlobals.js +++ b/plugins/pbjsGlobals.js @@ -1,14 +1,40 @@ - let t = require('@babel/core').types; let prebid = require('../package.json'); const path = require('path'); +const allFeatures = new Set(require('../features.json')); + +const FEATURES_GLOBAL = 'FEATURES'; + +function featureMap(disable = []) { + disable = disable.map((s) => s.toUpperCase()); + disable.forEach((f) => { + if (!allFeatures.has(f)) { + throw new Error(`Unrecognized feature: ${f}`) + } + }); + disable = new Set(disable); + return Object.fromEntries([...allFeatures.keys()].map((f) => [f, !disable.has(f)])); +} + +function getNpmVersion(version) { + try { + // only use "real" versions (that is, not the -pre ones, they won't be on jsDelivr) + return /^([\d.]+)$/.exec(version)[1]; + } catch (e) { + return 'latest'; + } +} module.exports = function(api, options) { const pbGlobal = options.globalVarName || prebid.globalVarName; + const defineGlobal = typeof (options.defineGlobal) !== 'undefined' ? options.defineGlobal : prebid.defineGlobal; + const features = featureMap(options.disableFeatures); let replace = { '$prebid.version$': prebid.version, '$$PREBID_GLOBAL$$': pbGlobal, - '$$REPO_AND_VERSION$$': `${prebid.repository.url.split('/')[3]}_prebid_${prebid.version}` + '$$DEFINE_PREBID_GLOBAL$$': defineGlobal, + '$$REPO_AND_VERSION$$': `${prebid.repository.url.split('/')[3]}_prebid_${prebid.version}`, + '$$PREBID_DIST_URL_BASE$$': options.prebidDistUrlBase || `https://cdn.jsdelivr.net/npm/prebid.js@${getNpmVersion(prebid.version)}/dist/` }; let identifierToStringLiteral = [ @@ -16,6 +42,12 @@ module.exports = function(api, options) { ]; const PREBID_ROOT = path.resolve(__dirname, '..'); + // on Windows, require paths are not filesystem paths + const SEP_PAT = new RegExp(path.sep.replace(/\\/g, '\\\\'), 'g') + + function relPath(from, toRelToProjectRoot) { + return path.relative(path.dirname(from), path.join(PREBID_ROOT, toRelToProjectRoot)).replace(SEP_PAT, '/'); + } function getModuleName(filename) { const modPath = path.parse(path.relative(PREBID_ROOT, filename)); @@ -38,8 +70,14 @@ module.exports = function(api, options) { Program(path, state) { const modName = getModuleName(state.filename); if (modName != null) { - // append "registration" of module file to $$PREBID_GLOBAL$$.installedModules - path.node.body.push(...api.parse(`window.${pbGlobal}.installedModules.push('${modName}');`, {filename: state.filename}).program.body); + // append "registration" of module file to getGlobal().installedModules + let i = 0; + let registerName; + do { + registerName = `__r${i++}` + } while (path.scope.hasBinding(registerName)) + path.node.body.unshift(...api.parse(`import {registerModule as ${registerName}} from '${relPath(state.filename, 'src/prebidGlobal.js')}';`, {filename: state.filename}).program.body); + path.node.body.push(...api.parse(`${registerName}('${modName}');`, {filename: state.filename}).program.body); } }, StringLiteral(path) { @@ -47,7 +85,7 @@ module.exports = function(api, options) { if (path.node.value.includes(name)) { path.node.value = path.node.value.replace( new RegExp(escapeRegExp(name), 'g'), - replace[name] + replace[name].toString() ); } }); @@ -77,11 +115,22 @@ module.exports = function(api, options) { ); } else { path.replaceWith( - t.Identifier(replace[name]) + t.Identifier(replace[name].toString()) ); } } }); + }, + MemberExpression(path) { + if ( + t.isIdentifier(path.node.object) && + path.node.object.name === FEATURES_GLOBAL && + !path.scope.hasBinding(FEATURES_GLOBAL) && + t.isIdentifier(path.node.property) && + features.hasOwnProperty(path.node.property.name) + ) { + path.replaceWith(t.booleanLiteral(features[path.node.property.name])); + } } } }; diff --git a/src/AnalyticsAdapter.js b/src/AnalyticsAdapter.js deleted file mode 100644 index 6bed0d4cd6c..00000000000 --- a/src/AnalyticsAdapter.js +++ /dev/null @@ -1,165 +0,0 @@ -import CONSTANTS from './constants.json'; -import { ajax } from './ajax.js'; -import { logMessage, _each } from './utils.js'; - -const events = require('./events.js'); - -const { - EVENTS: { - AUCTION_INIT, - AUCTION_END, - REQUEST_BIDS, - BID_REQUESTED, - BID_TIMEOUT, - BID_RESPONSE, - NO_BID, - BID_WON, - BID_ADJUSTMENT, - BIDDER_DONE, - SET_TARGETING, - AD_RENDER_FAILED, - AD_RENDER_SUCCEEDED, - AUCTION_DEBUG, - ADD_AD_UNITS, - BILLABLE_EVENT - } -} = CONSTANTS; - -const ENDPOINT = 'endpoint'; -const BUNDLE = 'bundle'; - -var _sampled = true; - -export default function AnalyticsAdapter({ url, analyticsType, global, handler }) { - var _queue = []; - var _eventCount = 0; - var _enableCheck = true; - var _handlers; - - if (analyticsType === ENDPOINT || BUNDLE) { - _emptyQueue(); - } - - return { - track: _track, - enqueue: _enqueue, - enableAnalytics: _enable, - disableAnalytics: _disable, - getAdapterType: () => analyticsType, - getGlobal: () => global, - getHandler: () => handler, - getUrl: () => url - }; - - function _track({ eventType, args }) { - if (this.getAdapterType() === BUNDLE) { - window[global](handler, eventType, args); - } - - if (this.getAdapterType() === ENDPOINT) { - _callEndpoint(...arguments); - } - } - - function _callEndpoint({ eventType, args, callback }) { - ajax(url, callback, JSON.stringify({ eventType, args })); - } - - function _enqueue({ eventType, args }) { - const _this = this; - - if (global && window[global] && eventType && args) { - this.track({ eventType, args }); - } else { - _queue.push(function () { - _eventCount++; - _this.track({ eventType, args }); - }); - } - } - - function _enable(config) { - var _this = this; - - if (typeof config === 'object' && typeof config.options === 'object') { - _sampled = typeof config.options.sampling === 'undefined' || Math.random() < parseFloat(config.options.sampling); - } else { - _sampled = true; - } - - if (_sampled) { - // first send all events fired before enableAnalytics called - events.getEvents().forEach(event => { - if (!event) { - return; - } - - const { eventType, args } = event; - - if (eventType !== BID_TIMEOUT) { - _enqueue.call(_this, { eventType, args }); - } - }); - - // Next register event listeners to send data immediately - - _handlers = { - [REQUEST_BIDS]: args => this.enqueue({ eventType: REQUEST_BIDS, args }), - [BID_REQUESTED]: args => this.enqueue({ eventType: BID_REQUESTED, args }), - [BID_RESPONSE]: args => this.enqueue({ eventType: BID_RESPONSE, args }), - [NO_BID]: args => this.enqueue({ eventType: NO_BID, args }), - [BID_TIMEOUT]: args => this.enqueue({ eventType: BID_TIMEOUT, args }), - [BID_WON]: args => this.enqueue({ eventType: BID_WON, args }), - [BID_ADJUSTMENT]: args => this.enqueue({ eventType: BID_ADJUSTMENT, args }), - [BIDDER_DONE]: args => this.enqueue({ eventType: BIDDER_DONE, args }), - [SET_TARGETING]: args => this.enqueue({ eventType: SET_TARGETING, args }), - [AUCTION_END]: args => this.enqueue({ eventType: AUCTION_END, args }), - [AD_RENDER_FAILED]: args => this.enqueue({ eventType: AD_RENDER_FAILED, args }), - [AD_RENDER_SUCCEEDED]: args => this.enqueue({ eventType: AD_RENDER_SUCCEEDED, args }), - [AUCTION_DEBUG]: args => this.enqueue({ eventType: AUCTION_DEBUG, args }), - [ADD_AD_UNITS]: args => this.enqueue({ eventType: ADD_AD_UNITS, args }), - [BILLABLE_EVENT]: args => this.enqueue({ eventType: BILLABLE_EVENT, args }), - [AUCTION_INIT]: args => { - args.config = typeof config === 'object' ? config.options || {} : {}; // enableAnaltyics configuration object - this.enqueue({ eventType: AUCTION_INIT, args }); - } - }; - - _each(_handlers, (handler, event) => { - events.on(event, handler); - }); - } else { - logMessage(`Analytics adapter for "${global}" disabled by sampling`); - } - - // finally set this function to return log message, prevents multiple adapter listeners - this._oldEnable = this.enableAnalytics; - this.enableAnalytics = function _enable() { - return logMessage(`Analytics adapter for "${global}" already enabled, unnecessary call to \`enableAnalytics\`.`); - }; - } - - function _disable() { - _each(_handlers, (handler, event) => { - events.off(event, handler); - }); - this.enableAnalytics = this._oldEnable ? this._oldEnable : _enable; - } - - function _emptyQueue() { - if (_enableCheck) { - for (var i = 0; i < _queue.length; i++) { - _queue[i](); - } - - // override push to execute the command immediately from now on - _queue.push = function (fn) { - fn(); - }; - - _enableCheck = false; - } - - logMessage(`event count sent to ${global}: ${_eventCount}`); - } -} diff --git a/src/Renderer.js b/src/Renderer.js index f26a5a377c0..2f9b2e025cb 100644 --- a/src/Renderer.js +++ b/src/Renderer.js @@ -3,6 +3,9 @@ import { logError, logWarn, logMessage, deepAccess } from './utils.js'; import {find} from './polyfill.js'; +import {getGlobal} from './prebidGlobal.js'; + +const pbjsInstance = getGlobal(); const moduleCode = 'outstream'; /** @@ -14,11 +17,12 @@ const moduleCode = 'outstream'; */ export function Renderer(options) { - const { url, config, id, callback, loaded, adUnitCode } = options; + const { url, config, id, callback, loaded, adUnitCode, renderNow } = options; this.url = url; this.config = config; this.handlers = {}; this.id = id; + this.renderNow = renderNow; // a renderer may push to the command queue to delay rendering until the // render function is loaded by loadExternalScript, at which point the the command @@ -50,19 +54,21 @@ export function Renderer(options) { } } - if (!isRendererPreferredFromAdUnit(adUnitCode)) { + if (isRendererPreferredFromAdUnit(adUnitCode)) { + logWarn(`External Js not loaded by Renderer since renderer url and callback is already defined on adUnit ${adUnitCode}`); + runRender(); + } else if (renderNow) { + runRender(); + } else { // we expect to load a renderer url once only so cache the request to load script this.cmd.unshift(runRender) // should render run first ? loadExternalScript(url, moduleCode, this.callback, this.documentContext); - } else { - logWarn(`External Js not loaded by Renderer since renderer url and callback is already defined on adUnit ${adUnitCode}`); - runRender() } - }.bind(this) // bind the function to this object to avoid 'this' errors + }.bind(this); // bind the function to this object to avoid 'this' errors } -Renderer.install = function({ url, config, id, callback, loaded, adUnitCode }) { - return new Renderer({ url, config, id, callback, loaded, adUnitCode }); +Renderer.install = function({ url, config, id, callback, loaded, adUnitCode, renderNow }) { + return new Renderer({ url, config, id, callback, loaded, adUnitCode, renderNow }); }; Renderer.prototype.getConfig = function() { @@ -105,7 +111,7 @@ Renderer.prototype.process = function() { * @returns {Boolean} */ export function isRendererRequired(renderer) { - return !!(renderer && renderer.url); + return !!(renderer && (renderer.url || renderer.renderNow)); } /** @@ -127,7 +133,7 @@ export function executeRenderer(renderer, bid, doc) { } function isRendererPreferredFromAdUnit(adUnitCode) { - const adUnits = $$PREBID_GLOBAL$$.adUnits; + const adUnits = pbjsInstance.adUnits; const adUnit = find(adUnits, adUnit => { return adUnit.code === adUnitCode; }); diff --git a/src/activities/activities.js b/src/activities/activities.js new file mode 100644 index 00000000000..0a17750b0b0 --- /dev/null +++ b/src/activities/activities.js @@ -0,0 +1,52 @@ +/** + * Activity (that are relevant for privacy) definitions + * + * ref. https://docs.google.com/document/d/1dRxFUFmhh2jGanzGZvfkK_6jtHPpHXWD7Qsi6KEugeE + * & https://github.com/prebid/Prebid.js/issues/9546 + */ + +/** + * accessDevice: some component wants to read or write to localStorage or cookies. + */ +export const ACTIVITY_ACCESS_DEVICE = 'accessDevice'; +/** + * syncUser: A bid adapter wants to run a user sync. + */ +export const ACTIVITY_SYNC_USER = 'syncUser'; +/** + * enrichUfpd: some component wants to add user first-party data to bid requests. + */ +export const ACTIVITY_ENRICH_UFPD = 'enrichUfpd'; +/** + * enrichEids: some component wants to add user IDs to bid requests. + */ +export const ACTIVITY_ENRICH_EIDS = 'enrichEids'; +/** + * fetchBid: a bidder wants to bid. + */ +export const ACTIVITY_FETCH_BIDS = 'fetchBids'; + +/** + * reportAnalytics: some component wants to phone home with analytics data. + */ +export const ACTIVITY_REPORT_ANALYTICS = 'reportAnalytics'; + +/** + * some component wants access to (and send along) user IDs + */ +export const ACTIVITY_TRANSMIT_EIDS = 'transmitEids' + +/** + * transmitUfpd: some component wants access to (and send along) user FPD + */ +export const ACTIVITY_TRANSMIT_UFPD = 'transmitUfpd'; + +/** + * transmitPreciseGeo: some component wants access to (and send along) geolocation info + */ +export const ACTIVITY_TRANSMIT_PRECISE_GEO = 'transmitPreciseGeo'; + +/** + * transmit TID: some component wants access ot (and send along) transaction IDs + */ +export const ACTIVITY_TRANSMIT_TID = 'transmitTid'; diff --git a/src/activities/activityParams.js b/src/activities/activityParams.js new file mode 100644 index 00000000000..f33ceb2a9a4 --- /dev/null +++ b/src/activities/activityParams.js @@ -0,0 +1,8 @@ +import adapterManager from '../adapterManager.js'; +import {activityParamsBuilder} from './params.js'; + +/** + * Utility function for building common activity parameters - broken out to its own + * file to avoid circular imports. + */ +export const activityParams = activityParamsBuilder((alias) => adapterManager.resolveAlias(alias)); diff --git a/src/activities/modules.js b/src/activities/modules.js new file mode 100644 index 00000000000..474c546c07b --- /dev/null +++ b/src/activities/modules.js @@ -0,0 +1,5 @@ +export const MODULE_TYPE_PREBID = 'prebid'; +export const MODULE_TYPE_BIDDER = 'bidder'; +export const MODULE_TYPE_UID = 'userId'; +export const MODULE_TYPE_RTD = 'rtd'; +export const MODULE_TYPE_ANALYTICS = 'analytics'; diff --git a/src/activities/params.js b/src/activities/params.js new file mode 100644 index 00000000000..036a6657cf8 --- /dev/null +++ b/src/activities/params.js @@ -0,0 +1,62 @@ +import {MODULE_TYPE_BIDDER} from './modules.js'; +import {hook} from '../hook.js'; + +/** + * Component ID - who is trying to perform the activity? + * Relevant for all activities. + */ +export const ACTIVITY_PARAM_COMPONENT = 'component'; +export const ACTIVITY_PARAM_COMPONENT_TYPE = ACTIVITY_PARAM_COMPONENT + 'Type'; +export const ACTIVITY_PARAM_COMPONENT_NAME = ACTIVITY_PARAM_COMPONENT + 'Name'; + +/** + * Code of the bid adapter that `componentName` is an alias of. + * May be the same as the component name. + * + * relevant for all activities, but only when componentType is 'bidder'. + */ +export const ACTIVITY_PARAM_ADAPTER_CODE = 'adapterCode'; + +/** + * Storage type - either 'html5' or 'cookie'. + * Relevant for: accessDevice + */ +export const ACTIVITY_PARAM_STORAGE_TYPE = 'storageType'; + +/** + * s2sConfig[].configName, used to identify a particular s2s instance + * relevant for: fetchBids, but only when component is 'prebid.pbsBidAdapter' + */ +export const ACTIVITY_PARAM_S2S_NAME = 'configName'; +/** + * user sync type - 'iframe' or 'pixel' + * relevant for: syncUser + */ +export const ACTIVITY_PARAM_SYNC_TYPE = 'syncType' +/** + * user sync URL + * relevant for: syncUser + */ +export const ACTIVITY_PARAM_SYNC_URL = 'syncUrl'; +/** + * @private + * configuration options for analytics adapter - the argument passed to `enableAnalytics`. + * relevant for: reportAnalytics + */ +export const ACTIVITY_PARAM_ANL_CONFIG = '_config'; + +export function activityParamsBuilder(resolveAlias) { + return function activityParams(moduleType, moduleName, params) { + const defaults = { + [ACTIVITY_PARAM_COMPONENT_TYPE]: moduleType, + [ACTIVITY_PARAM_COMPONENT_NAME]: moduleName, + [ACTIVITY_PARAM_COMPONENT]: `${moduleType}.${moduleName}` + }; + if (moduleType === MODULE_TYPE_BIDDER) { + defaults[ACTIVITY_PARAM_ADAPTER_CODE] = resolveAlias(moduleName); + } + return buildActivityParams(Object.assign(defaults, params)); + } +} + +export const buildActivityParams = hook('sync', params => params); diff --git a/src/activities/redactor.js b/src/activities/redactor.js new file mode 100644 index 00000000000..d052c029c13 --- /dev/null +++ b/src/activities/redactor.js @@ -0,0 +1,195 @@ +import {deepAccess} from '../utils.js'; +import {config} from '../config.js'; +import {isActivityAllowed, registerActivityControl} from './rules.js'; +import { + ACTIVITY_TRANSMIT_EIDS, + ACTIVITY_TRANSMIT_PRECISE_GEO, + ACTIVITY_TRANSMIT_TID, + ACTIVITY_TRANSMIT_UFPD +} from './activities.js'; + +export const ORTB_UFPD_PATHS = [ + 'data', + 'ext.data', + 'yob', + 'gender', + 'keywords', + 'kwarray', + 'id', + 'buyeruid', + 'customdata' +].map(f => `user.${f}`); +export const ORTB_EIDS_PATHS = ['user.eids', 'user.ext.eids']; +export const ORTB_GEO_PATHS = ['user.geo.lat', 'user.geo.lon', 'device.geo.lat', 'device.geo.lon']; + +/** + * @typedef TransformationRuleDef + * @property {name} + * @property {Array[string]} paths dot-separated list of paths that this rule applies to. + * @property {function(*): boolean} applies a predicate that should return true if this rule applies + * (and the transformation defined herein should be applied). The arguments are those passed to the transformation function. + * @property {name} a name for the rule; used to debounce calls to `applies` (and avoid excessive logging): + * if a rule with the same name was already found to apply (or not), this one will (or won't) as well. + */ + +/** + * @typedef RedactRuleDef A rule that removes, or replaces, values from an object (modifications are done in-place). + * @augments TransformationRuleDef + * @property {function(*): *} get? substitution functions for values that should be redacted; + * takes in the original (unredacted) value as an input, and returns a substitute to use in the redacted + * version. If it returns undefined, or this option is omitted, protected paths will be removed + * from the redacted object. + */ + +/** + * @param {RedactRuleDef} ruleDef + * @return {TransformationRule} + */ +export function redactRule(ruleDef) { + return Object.assign({ + get() {}, + run(root, path, object, property, applies) { + const val = object && object[property]; + if (isData(val) && applies()) { + const repl = this.get(val); + if (repl === undefined) { + delete object[property]; + } else { + object[property] = repl; + } + } + } + }, ruleDef) +} + +/** + * @typedef TransformationRule + * @augments TransformationRuleDef + * @property {function} run rule logic - see `redactRule` for an example. + */ + +/** + * @typedef {Function} TransformationFunction + * @param object object to transform + * @param ...args arguments to pass down to rule's `apply` methods. + */ + +/** + * Return a transformation function that will apply the given rules to an object. + * + * @param {Array[TransformationRule]} rules + * @return {TransformationFunction} + */ +export function objectTransformer(rules) { + rules.forEach(rule => { + rule.paths = rule.paths.map((path) => { + const parts = path.split('.'); + const tail = parts.pop(); + return [parts.length > 0 ? parts.join('.') : null, tail] + }) + }) + return function applyTransform(session, obj, ...args) { + const result = []; + const applies = sessionedApplies(session, ...args); + rules.forEach(rule => { + if (session[rule.name] === false) return; + for (const [head, tail] of rule.paths) { + const parent = head == null ? obj : deepAccess(obj, head); + result.push(rule.run(obj, head, parent, tail, applies.bind(null, rule))); + if (session[rule.name] === false) return; + } + }) + return result.filter(el => el != null); + } +} + +export function sessionedApplies(session, ...args) { + return function applies(rule) { + if (!session.hasOwnProperty(rule.name)) { + session[rule.name] = !!rule.applies(...args); + } + return session[rule.name]; + } +} + +export function isData(val) { + return val != null && (typeof val !== 'object' || Object.keys(val).length > 0) +} + +export function appliesWhenActivityDenied(activity, isAllowed = isActivityAllowed) { + return function applies(params) { + return !isAllowed(activity, params); + }; +} + +function bidRequestTransmitRules(isAllowed = isActivityAllowed) { + return [ + { + name: ACTIVITY_TRANSMIT_EIDS, + paths: ['userId', 'userIdAsEids'], + applies: appliesWhenActivityDenied(ACTIVITY_TRANSMIT_EIDS, isAllowed), + }, + { + name: ACTIVITY_TRANSMIT_TID, + paths: ['ortb2Imp.ext.tid'], + applies: appliesWhenActivityDenied(ACTIVITY_TRANSMIT_TID, isAllowed) + } + ].map(redactRule) +} + +export function ortb2TransmitRules(isAllowed = isActivityAllowed) { + return [ + { + name: ACTIVITY_TRANSMIT_UFPD, + paths: ORTB_UFPD_PATHS, + applies: appliesWhenActivityDenied(ACTIVITY_TRANSMIT_UFPD, isAllowed), + }, + { + name: ACTIVITY_TRANSMIT_EIDS, + paths: ORTB_EIDS_PATHS, + applies: appliesWhenActivityDenied(ACTIVITY_TRANSMIT_EIDS, isAllowed), + }, + { + name: ACTIVITY_TRANSMIT_PRECISE_GEO, + paths: ORTB_GEO_PATHS, + applies: appliesWhenActivityDenied(ACTIVITY_TRANSMIT_PRECISE_GEO, isAllowed), + get(val) { + return Math.round((val + Number.EPSILON) * 100) / 100; + } + }, + { + name: ACTIVITY_TRANSMIT_TID, + paths: ['source.tid'], + applies: appliesWhenActivityDenied(ACTIVITY_TRANSMIT_TID, isAllowed), + } + ].map(redactRule); +} + +export function redactorFactory(isAllowed = isActivityAllowed) { + const redactOrtb2 = objectTransformer(ortb2TransmitRules(isAllowed)); + const redactBidRequest = objectTransformer(bidRequestTransmitRules(isAllowed)); + return function redactor(params) { + const session = {}; + return { + ortb2(obj) { redactOrtb2(session, obj, params); return obj }, + bidRequest(obj) { redactBidRequest(session, obj, params); return obj } + } + } +} + +/** + * Returns an object that can redact other privacy-sensitive objects according + * to activity rules. + * + * @param {{}} params activity parameters to use for activity checks + * @return {{ortb2: function({}): {}, bidRequest: function({}): {}}} methods + * that can redact disallowed data from ORTB2 and/or bid request objects. + */ +export const redactor = redactorFactory(); + +// by default, TIDs are off since version 8 +registerActivityControl(ACTIVITY_TRANSMIT_TID, 'enableTIDs config', () => { + if (!config.getConfig('enableTIDs')) { + return {allow: false, reason: 'TIDs are disabled'} + } +}); diff --git a/src/activities/rules.js b/src/activities/rules.js new file mode 100644 index 00000000000..f84f1080843 --- /dev/null +++ b/src/activities/rules.js @@ -0,0 +1,95 @@ +import {prefixLog} from '../utils.js'; +import {ACTIVITY_PARAM_COMPONENT} from './params.js'; + +export function ruleRegistry(logger = prefixLog('Activity control:')) { + const registry = {}; + + function getRules(activity) { + return registry[activity] = registry[activity] || []; + } + + function runRule(activity, name, rule, params) { + let res; + try { + res = rule(params); + } catch (e) { + logger.logError(`Exception in rule ${name} for '${activity}'`, e); + res = {allow: false, reason: e}; + } + return res && Object.assign({activity, name, component: params[ACTIVITY_PARAM_COMPONENT]}, res); + } + + const dupes = {}; + const DEDUPE_INTERVAL = 1000; + + function logResult({activity, name, allow, reason, component}) { + const msg = `${name} ${allow ? 'allowed' : 'denied'} '${activity}' for '${component}'${reason ? ':' : ''}`; + const deduping = dupes.hasOwnProperty(msg); + if (deduping) { + clearTimeout(dupes[msg]); + } + dupes[msg] = setTimeout(() => delete dupes[msg], DEDUPE_INTERVAL); + if (!deduping) { + const parts = [msg]; + reason && parts.push(reason); + (allow ? logger.logInfo : logger.logWarn).apply(logger, parts); + } + } + + return [ + /** + * Register an activity control rule. + * + * @param {string} activity activity name - set is defined in `activities.js` + * @param {string} ruleName a name for this rule; used for logging. + * @param {function({}): {allow: boolean, reason?: string}} rule definition function. Takes in activity + * parameters as a single map; MAY return an object {allow, reason}, where allow is true/false, + * and reason is an optional message used for logging. + * + * {allow: true} will allow this activity AS LONG AS no other rules with same or higher priority return {allow: false}; + * {allow: false} will deny this activity AS LONG AS no other rules with higher priority return {allow: true}; + * returning null/undefined has no effect - the decision is left to other rules. + * If no rule returns an allow value, the default is to allow the activity. + * + * @param {number} priority rule priority; lower number means higher priority + * @returns {function(void): void} a function that unregisters the rule when called. + */ + function registerActivityControl(activity, ruleName, rule, priority = 10) { + const rules = getRules(activity); + const pos = rules.findIndex(([itemPriority]) => priority < itemPriority); + const entry = [priority, ruleName, rule]; + rules.splice(pos < 0 ? rules.length : pos, 0, entry); + return function () { + const idx = rules.indexOf(entry); + if (idx >= 0) rules.splice(idx, 1); + } + }, + /** + * Test whether an activity is allowed. + * + * @param {string} activity activity name + * @param {{}} params activity parameters; should be generated through the `activityParams` utility. + * @return {boolean} true for allow, false for deny. + */ + function isActivityAllowed(activity, params) { + let lastPriority, foundAllow; + for (const [priority, name, rule] of getRules(activity)) { + if (lastPriority !== priority && foundAllow) break; + lastPriority = priority; + const ruleResult = runRule(activity, name, rule, params); + if (ruleResult) { + if (!ruleResult.allow) { + logResult(ruleResult); + return false; + } else { + foundAllow = ruleResult; + } + } + } + foundAllow && logResult(foundAllow); + return true; + } + ]; +} + +export const [registerActivityControl, isActivityAllowed] = ruleRegistry(); diff --git a/src/adRendering.js b/src/adRendering.js index a645ec77244..0a847d7cc25 100644 --- a/src/adRendering.js +++ b/src/adRendering.js @@ -23,7 +23,7 @@ export function emitAdRenderFail({ reason, message, bid, id }) { /** * Emit the AD_RENDER_SUCCEEDED event. - * + * (Note: Invocation of this function indicates that the render function did not generate an error, it does not guarantee that tracking for this event has occurred yet.) * @param doc document object that was used to `.write` the ad. Should be `null` if unavailable (e.g. for documents in * a cross-origin frame). * @param bid bid response object for the ad that was rendered diff --git a/src/adapterManager.js b/src/adapterManager.js index 93eeba51cde..575d28b35fa 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -1,8 +1,6 @@ /** @module adaptermanger */ import { - _each, - bind, deepAccess, deepClone, flatten, @@ -13,32 +11,47 @@ import { getUserConfiguredParams, groupBy, isArray, + isPlainObject, isValidMediaTypes, logError, logInfo, logMessage, logWarn, + mergeDeep, shuffle, timestamp, } from './utils.js'; -import {processAdUnitsForLabels} from './sizeMapping.js'; -import { decorateAdUnitsWithNativeParams, nativeAdapters } from './native.js'; -import { newBidder } from './adapters/bidderFactory.js'; -import { ajaxBuilder } from './ajax.js'; -import { config, RANDOM } from './config.js'; -import { hook } from './hook.js'; -import {includes, find} from './polyfill.js'; -import { adunitCounter } from './adUnits.js'; -import { getRefererInfo } from './refererDetection.js'; -import {GdprConsentHandler, UspConsentHandler} from './consentHandler.js'; - +import {decorateAdUnitsWithNativeParams, nativeAdapters} from './native.js'; +import {newBidder} from './adapters/bidderFactory.js'; +import {ajaxBuilder} from './ajax.js'; +import {config, RANDOM} from './config.js'; +import {hook} from './hook.js'; +import {find, includes} from './polyfill.js'; +import {adunitCounter} from './adUnits.js'; +import {getRefererInfo} from './refererDetection.js'; +import {GDPR_GVLIDS, gdprDataHandler, gppDataHandler, uspDataHandler, } from './consentHandler.js'; +import * as events from './events.js'; +import CONSTANTS from './constants.json'; +import {useMetrics} from './utils/perfMetrics.js'; +import {auctionManager} from './auctionManager.js'; +import {MODULE_TYPE_ANALYTICS, MODULE_TYPE_BIDDER, MODULE_TYPE_PREBID} from './activities/modules.js'; +import {isActivityAllowed} from './activities/rules.js'; +import {ACTIVITY_FETCH_BIDS, ACTIVITY_REPORT_ANALYTICS} from './activities/activities.js'; +import {ACTIVITY_PARAM_ANL_CONFIG, ACTIVITY_PARAM_S2S_NAME, activityParamsBuilder} from './activities/params.js'; +import {redactor} from './activities/redactor.js'; + +export {gdprDataHandler, gppDataHandler, uspDataHandler, coppaDataHandler} from './consentHandler.js'; + +export const PBS_ADAPTER_NAME = 'pbsBidAdapter'; export const PARTITIONS = { CLIENT: 'client', SERVER: 'server' } -var CONSTANTS = require('./constants.json'); -var events = require('./events.js'); +export const dep = { + isAllowed: isActivityAllowed, + redact: redactor +} let adapterManager = {}; @@ -54,6 +67,14 @@ config.getConfig('s2sConfig', config => { var _analyticsRegistry = {}; +const activityParams = activityParamsBuilder((alias) => adapterManager.resolveAlias(alias)); + +export function s2sActivityParams(s2sConfig) { + return activityParams(MODULE_TYPE_PREBID, PBS_ADAPTER_NAME, { + [ACTIVITY_PARAM_S2S_NAME]: s2sConfig.configName + }); +} + /** * @typedef {object} LabelDescriptor * @property {boolean} labelAll describes whether or not this object expects all labels to match, or any label to match @@ -61,17 +82,23 @@ var _analyticsRegistry = {}; * @property {Array} activeLabels the labels specified as being active by requestBids */ -function getBids({bidderCode, auctionId, bidderRequestId, adUnits, src}) { +function getBids({bidderCode, auctionId, bidderRequestId, adUnits, src, metrics}) { return adUnits.reduce((result, adUnit) => { - result.push(adUnit.bids.filter(bid => bid.bidder === bidderCode) - .reduce((bids, bid) => { - bid = Object.assign({}, bid, getDefinedParams(adUnit, [ - 'nativeParams', - 'ortb2Imp', - 'mediaType', - 'renderer', - 'storedAuctionResponse' - ])); + const bids = adUnit.bids.filter(bid => bid.bidder === bidderCode); + if (bidderCode == null && bids.length === 0 && adUnit.s2sBid != null) { + bids.push({bidder: null}); + } + result.push( + bids.reduce((bids, bid) => { + bid = Object.assign({}, bid, + {ortb2Imp: mergeDeep({}, adUnit.ortb2Imp, bid.ortb2Imp)}, + getDefinedParams(adUnit, [ + 'nativeParams', + 'nativeOrtbRequest', + 'mediaType', + 'renderer' + ]) + ); const mediaTypes = bid.mediaTypes == null ? adUnit.mediaTypes : bid.mediaTypes @@ -93,6 +120,7 @@ function getBids({bidderCode, auctionId, bidderRequestId, adUnits, src}) { bidderRequestId, auctionId, src, + metrics, bidRequestsCount: adunitCounter.getRequestsCounter(adUnit.code), bidderRequestsCount: adunitCounter.getBidderRequestsCounter(adUnit.code, bid.bidder), bidderWinsCount: adunitCounter.getBidderWinsCounter(adUnit.code, bid.bidder), @@ -125,9 +153,18 @@ export const filterBidsForAdUnit = hook('sync', _filterBidsForAdUnit, 'filterBid function getAdUnitCopyForPrebidServer(adUnits, s2sConfig) { let adUnitsCopy = deepClone(adUnits); + let hasModuleBids = false; adUnitsCopy.forEach((adUnit) => { // filter out client side bids + const s2sBids = adUnit.bids.filter((b) => b.module === PBS_ADAPTER_NAME && b.params?.configName === s2sConfig.configName); + if (s2sBids.length === 1) { + adUnit.s2sBid = s2sBids[0]; + hasModuleBids = true; + adUnit.ortb2Imp = mergeDeep({}, adUnit.s2sBid.ortb2Imp, adUnit.ortb2Imp); + } else if (s2sBids.length > 1) { + logWarn('Multiple "module" bids for the same s2s configuration; all will be ignored', s2sBids); + } adUnit.bids = filterBidsForAdUnit(adUnit.bids, s2sConfig) .map((bid) => { bid.bid_id = getUniqueIdentifierStr(); @@ -137,9 +174,9 @@ function getAdUnitCopyForPrebidServer(adUnits, s2sConfig) { // don't send empty requests adUnitsCopy = adUnitsCopy.filter(adUnit => { - return adUnit.bids.length !== 0; + return adUnit.bids.length !== 0 || adUnit.s2sBid != null; }); - return adUnitsCopy; + return {adUnits: adUnitsCopy, hasModuleBids}; } function getAdUnitCopyForClientAdapters(adUnits) { @@ -156,15 +193,6 @@ function getAdUnitCopyForClientAdapters(adUnits) { return adUnitsClientCopy; } -export let gdprDataHandler = new GdprConsentHandler(); -export let uspDataHandler = new UspConsentHandler(); - -export let coppaDataHandler = { - getCoppa: function() { - return !!(config.getConfig('coppa')) - } -}; - /** * Filter and/or modify media types for ad units based on the given labels. * @@ -173,7 +201,7 @@ export let coppaDataHandler = { * they should be exposed under `adUnit.bids[].mediaTypes`. */ export const setupAdUnitMediaTypes = hook('sync', (adUnits, labels) => { - return processAdUnitsForLabels(adUnits, labels); + return adUnits; }, 'setupAdUnitMediaTypes') /** @@ -207,13 +235,25 @@ export function _partitionBidders (adUnits, s2sConfigs, {getS2SBidders = getS2SB export const partitionBidders = hook('sync', _partitionBidders, 'partitionBidders'); -adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, auctionId, cbTimeout, labels) { +adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, auctionId, cbTimeout, labels, ortb2Fragments = {}, auctionMetrics) { + auctionMetrics = useMetrics(auctionMetrics); /** * emit and pass adunits for external modification * @see {@link https://github.com/prebid/Prebid.js/issues/4149|Issue} */ events.emit(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, adUnits); - decorateAdUnitsWithNativeParams(adUnits); + if (FEATURES.NATIVE) { + decorateAdUnitsWithNativeParams(adUnits); + } + + adUnits.forEach(au => { + if (!isPlainObject(au.mediaTypes)) { + au.mediaTypes = {}; + } + // filter out bidders that cannot participate in the auction + au.bids = au.bids.filter((bid) => !bid.bidder || dep.isAllowed(ACTIVITY_FETCH_BIDS, activityParams(MODULE_TYPE_BIDDER, bid.bidder))) + }); + adUnits = setupAdUnitMediaTypes(adUnits, labels); let {[PARTITIONS.CLIENT]: clientBidders, [PARTITIONS.SERVER]: serverBidders} = partitionBidders(adUnits, _s2sConfigs); @@ -225,25 +265,47 @@ adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, a let bidRequests = []; + const ortb2 = ortb2Fragments.global || {}; + const bidderOrtb2 = ortb2Fragments.bidder || {}; + + function addOrtb2(bidderRequest, s2sActivityParams) { + const redact = dep.redact( + s2sActivityParams != null + ? s2sActivityParams + : activityParams(MODULE_TYPE_BIDDER, bidderRequest.bidderCode) + ); + const fpd = Object.freeze(redact.ortb2(mergeDeep({source: {tid: auctionId}}, ortb2, bidderOrtb2[bidderRequest.bidderCode]))); + bidderRequest.ortb2 = fpd; + bidderRequest.bids = bidderRequest.bids.map((bid) => { + bid.ortb2 = fpd; + return redact.bidRequest(bid); + }) + return bidderRequest; + } + _s2sConfigs.forEach(s2sConfig => { - if (s2sConfig && s2sConfig.enabled) { - let adUnitsS2SCopy = getAdUnitCopyForPrebidServer(adUnits, s2sConfig); + const s2sParams = s2sActivityParams(s2sConfig); + if (s2sConfig && s2sConfig.enabled && dep.isAllowed(ACTIVITY_FETCH_BIDS, s2sParams)) { + let {adUnits: adUnitsS2SCopy, hasModuleBids} = getAdUnitCopyForPrebidServer(adUnits, s2sConfig); // uniquePbsTid is so we know which server to send which bids to during the callBids function let uniquePbsTid = generateUUID(); - serverBidders.forEach(bidderCode => { + + (serverBidders.length === 0 && hasModuleBids ? [null] : serverBidders).forEach(bidderCode => { const bidderRequestId = getUniqueIdentifierStr(); - const bidderRequest = { + const metrics = auctionMetrics.fork(); + const bidderRequest = addOrtb2({ bidderCode, auctionId, bidderRequestId, uniquePbsTid, - bids: hookedGetBids({bidderCode, auctionId, bidderRequestId, 'adUnits': deepClone(adUnitsS2SCopy), src: CONSTANTS.S2S.SRC}), + bids: hookedGetBids({bidderCode, auctionId, bidderRequestId, 'adUnits': deepClone(adUnitsS2SCopy), src: CONSTANTS.S2S.SRC, metrics}), auctionStart: auctionStart, timeout: s2sConfig.timeout, src: CONSTANTS.S2S.SRC, - refererInfo - }; + refererInfo, + metrics, + }, s2sParams); if (bidderRequest.bids.length !== 0) { bidRequests.push(bidderRequest); } @@ -260,25 +322,27 @@ adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, a bidRequests.forEach(request => { if (request.adUnitsS2SCopy === undefined) { - request.adUnitsS2SCopy = adUnitsS2SCopy.filter(adUnitCopy => adUnitCopy.bids.length > 0); + request.adUnitsS2SCopy = adUnitsS2SCopy.filter(au => au.bids.length > 0 || au.s2sBid != null); } }); } - }) + }); // client adapters let adUnitsClientCopy = getAdUnitCopyForClientAdapters(adUnits); clientBidders.forEach(bidderCode => { const bidderRequestId = getUniqueIdentifierStr(); - const bidderRequest = { + const metrics = auctionMetrics.fork(); + const bidderRequest = addOrtb2({ bidderCode, auctionId, bidderRequestId, - bids: hookedGetBids({bidderCode, auctionId, bidderRequestId, 'adUnits': deepClone(adUnitsClientCopy), labels, src: 'client'}), + bids: hookedGetBids({bidderCode, auctionId, bidderRequestId, 'adUnits': deepClone(adUnitsClientCopy), labels, src: 'client', metrics}), auctionStart: auctionStart, timeout: cbTimeout, - refererInfo - }; + refererInfo, + metrics, + }); const adapter = _bidderRegistry[bidderCode]; if (!adapter) { logError(`Trying to make a request for bidder that does not exist: ${bidderCode}`); @@ -289,33 +353,33 @@ adapterManager.makeBidRequests = hook('sync', function (adUnits, auctionStart, a } }); - if (gdprDataHandler.getConsentData()) { - bidRequests.forEach(bidRequest => { + bidRequests.forEach(bidRequest => { + if (gdprDataHandler.getConsentData()) { bidRequest['gdprConsent'] = gdprDataHandler.getConsentData(); - }); - } - - if (uspDataHandler.getConsentData()) { - bidRequests.forEach(bidRequest => { + } + if (uspDataHandler.getConsentData()) { bidRequest['uspConsent'] = uspDataHandler.getConsentData(); - }); - } + } + if (gppDataHandler.getConsentData()) { + bidRequest['gppConsent'] = gppDataHandler.getConsentData(); + } + }); return bidRequests; }, 'makeBidRequests'); -adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, requestCallbacks, requestBidsTimeout, onTimelyResponse) => { +adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, requestCallbacks, requestBidsTimeout, onTimelyResponse, ortb2Fragments = {}) => { if (!bidRequests.length) { logWarn('callBids executed with no bidRequests. Were they filtered by labels or sizing?'); return; } - let [clientBidRequests, serverBidRequests] = bidRequests.reduce((partitions, bidRequest) => { + let [clientBidderRequests, serverBidderRequests] = bidRequests.reduce((partitions, bidRequest) => { partitions[Number(typeof bidRequest.src !== 'undefined' && bidRequest.src === CONSTANTS.S2S.SRC)].push(bidRequest); return partitions; }, [[], []]); var uniqueServerBidRequests = []; - serverBidRequests.forEach(serverBidRequest => { + serverBidderRequests.forEach(serverBidRequest => { var index = -1; for (var i = 0; i < uniqueServerBidRequests.length; ++i) { if (serverBidRequest.uniquePbsTid === uniqueServerBidRequests[i].uniquePbsTid) { @@ -330,8 +394,6 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request let counter = 0; - // $.source.tid MUST be a unique UUID and also THE SAME between all PBS Requests for a given Auction - const sourceTid = generateUUID(); _s2sConfigs.forEach((s2sConfig) => { if (s2sConfig && uniqueServerBidRequests[counter] && getS2SBidderSet(s2sConfig).has(uniqueServerBidRequests[counter].bidderCode)) { // s2s should get the same client side timeout as other client side requests. @@ -344,14 +406,17 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request let uniquePbsTid = uniqueServerBidRequests[counter].uniquePbsTid; let adUnitsS2SCopy = uniqueServerBidRequests[counter].adUnitsS2SCopy; - let uniqueServerRequests = serverBidRequests.filter(serverBidRequest => serverBidRequest.uniquePbsTid === uniquePbsTid); + let uniqueServerRequests = serverBidderRequests.filter(serverBidRequest => serverBidRequest.uniquePbsTid === uniquePbsTid); if (s2sAdapter) { - let s2sBidRequest = {tid: sourceTid, 'ad_units': adUnitsS2SCopy, s2sConfig}; + let s2sBidRequest = {'ad_units': adUnitsS2SCopy, s2sConfig, ortb2Fragments}; if (s2sBidRequest.ad_units.length) { let doneCbs = uniqueServerRequests.map(bidRequest => { bidRequest.start = timestamp(); - return doneCb.bind(bidRequest); + return function () { + onTimelyResponse(bidRequest.bidderRequestId); + doneCb.apply(bidRequest, arguments); + } }); const bidders = getBidderCodes(s2sBidRequest.ad_units).filter((bidder) => adaptersServerSide.includes(bidder)); @@ -360,13 +425,13 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request // fire BID_REQUESTED event for each s2s bidRequest uniqueServerRequests.forEach(bidRequest => { // add the new sourceTid - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, {...bidRequest, tid: sourceTid}); + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, {...bidRequest, tid: bidRequest.auctionId}); }); // make bid requests s2sAdapter.callBids( s2sBidRequest, - serverBidRequests, + serverBidderRequests, addBidResponse, () => doneCbs.forEach(done => done()), s2sAjax @@ -375,40 +440,39 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request } else { logError('missing ' + s2sConfig.adapter); } - counter++ + counter++; } }); // handle client adapter requests - clientBidRequests.forEach(bidRequest => { - bidRequest.start = timestamp(); + clientBidderRequests.forEach(bidderRequest => { + bidderRequest.start = timestamp(); // TODO : Do we check for bid in pool from here and skip calling adapter again ? - const adapter = _bidderRegistry[bidRequest.bidderCode]; - config.runWithBidder(bidRequest.bidderCode, () => { + const adapter = _bidderRegistry[bidderRequest.bidderCode]; + config.runWithBidder(bidderRequest.bidderCode, () => { logMessage(`CALLING BIDDER`); - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidRequest); + events.emit(CONSTANTS.EVENTS.BID_REQUESTED, bidderRequest); }); let ajax = ajaxBuilder(requestBidsTimeout, requestCallbacks ? { - request: requestCallbacks.request.bind(null, bidRequest.bidderCode), + request: requestCallbacks.request.bind(null, bidderRequest.bidderCode), done: requestCallbacks.done } : undefined); - const adapterDone = doneCb.bind(bidRequest); + const adapterDone = doneCb.bind(bidderRequest); try { config.runWithBidder( - bidRequest.bidderCode, - bind.call( - adapter.callBids, + bidderRequest.bidderCode, + adapter.callBids.bind( adapter, - bidRequest, + bidderRequest, addBidResponse, adapterDone, ajax, - onTimelyResponse, - config.callbackWithBidder(bidRequest.bidderCode) + () => onTimelyResponse(bidderRequest.bidderRequestId), + config.callbackWithBidder(bidderRequest.bidderCode) ) ); } catch (e) { - logError(`${bidRequest.bidderCode} Bid Adapter emitted an uncaught error when parsing their bidRequest`, {e, bidRequest}); + logError(`${bidderRequest.bidderCode} Bid Adapter emitted an uncaught error when parsing their bidRequest`, {e, bidRequest: bidderRequest}); adapterDone(); } }); @@ -416,8 +480,8 @@ adapterManager.callBids = (adUnits, bidRequests, addBidResponse, doneCb, request function getSupportedMediaTypes(bidderCode) { let supportedMediaTypes = []; - if (includes(adapterManager.videoAdapters, bidderCode)) supportedMediaTypes.push('video'); - if (includes(nativeAdapters, bidderCode)) supportedMediaTypes.push('native'); + if (FEATURES.VIDEO && includes(adapterManager.videoAdapters, bidderCode)) supportedMediaTypes.push('video'); + if (FEATURES.NATIVE && includes(nativeAdapters, bidderCode)) supportedMediaTypes.push('native'); return supportedMediaTypes; } @@ -427,11 +491,12 @@ adapterManager.registerBidAdapter = function (bidAdapter, bidderCode, {supported if (bidAdapter && bidderCode) { if (typeof bidAdapter.callBids === 'function') { _bidderRegistry[bidderCode] = bidAdapter; + GDPR_GVLIDS.register(MODULE_TYPE_BIDDER, bidderCode, bidAdapter.getSpec?.().gvlid); - if (includes(supportedMediaTypes, 'video')) { + if (FEATURES.VIDEO && includes(supportedMediaTypes, 'video')) { adapterManager.videoAdapters.push(bidderCode); } - if (includes(supportedMediaTypes, 'native')) { + if (FEATURES.NATIVE && includes(supportedMediaTypes, 'native')) { nativeAdapters.push(bidderCode); } } else { @@ -462,7 +527,7 @@ adapterManager.aliasBidAdapter = function (bidderCode, alias, options) { }); nonS2SAlias.forEach(bidderCode => { logError('bidderCode "' + bidderCode + '" is not an existing bidder.', 'adapterManager.aliasBidAdapter'); - }) + }); } else { try { let newAdapter; @@ -475,6 +540,9 @@ adapterManager.aliasBidAdapter = function (bidderCode, alias, options) { } else { let spec = bidAdapter.getSpec(); let gvlid = options && options.gvlid; + if (spec.gvlid != null && gvlid == null) { + logWarn(`Alias '${alias}' will NOT re-use the GVL ID of the original adapter ('${spec.code}', gvlid: ${spec.gvlid}). Functionality that requires TCF consent may not work as expected.`) + } let skipPbsAliasing = options && options.skipPbsAliasing; newAdapter = newBidder(Object.assign({}, spec, { code: alias, gvlid, skipPbsAliasing })); _aliasRegistry[alias] = bidderCode; @@ -491,11 +559,22 @@ adapterManager.aliasBidAdapter = function (bidderCode, alias, options) { } }; +adapterManager.resolveAlias = function (alias) { + let code = alias; + let visited; + while (_aliasRegistry[code] && (!visited || !visited.has(code))) { + code = _aliasRegistry[code]; + (visited = visited || new Set()).add(code); + } + return code; +} + adapterManager.registerAnalyticsAdapter = function ({adapter, code, gvlid}) { if (adapter && code) { if (typeof adapter.enableAnalytics === 'function') { adapter.code = code; _analyticsRegistry[code] = { adapter, gvlid }; + GDPR_GVLIDS.register(MODULE_TYPE_ANALYTICS, code, gvlid); } else { logError(`Prebid Error: Analytics adaptor error for analytics "${code}" analytics adapter must implement an enableAnalytics() function`); @@ -510,10 +589,12 @@ adapterManager.enableAnalytics = function (config) { config = [config]; } - _each(config, adapterConfig => { + config.forEach(adapterConfig => { const entry = _analyticsRegistry[adapterConfig.provider]; if (entry && entry.adapter) { - entry.adapter.enableAnalytics(adapterConfig); + if (dep.isAllowed(ACTIVITY_REPORT_ANALYTICS, activityParams(MODULE_TYPE_ANALYTICS, adapterConfig.provider, {[ACTIVITY_PARAM_ANL_CONFIG]: adapterConfig}))) { + entry.adapter.enableAnalytics(adapterConfig); + } } else { logError(`Prebid Error: no analytics adapter found in registry for '${adapterConfig.provider}'.`); } @@ -528,19 +609,32 @@ adapterManager.getAnalyticsAdapter = function(code) { return _analyticsRegistry[code]; } -function tryCallBidderMethod(bidder, method, param) { +function getBidderMethod(bidder, method) { + const adapter = _bidderRegistry[bidder]; + const spec = adapter?.getSpec && adapter.getSpec(); + if (spec && spec[method] && typeof spec[method] === 'function') { + return [spec, spec[method]] + } +} + +function invokeBidderMethod(bidder, method, spec, fn, ...params) { try { - const adapter = _bidderRegistry[bidder]; - const spec = adapter.getSpec(); - if (spec && spec[method] && typeof spec[method] === 'function') { - logInfo(`Invoking ${bidder}.${method}`); - config.runWithBidder(bidder, bind.call(spec[method], spec, param)); - } + logInfo(`Invoking ${bidder}.${method}`); + config.runWithBidder(bidder, fn.bind(spec, ...params)); } catch (e) { logWarn(`Error calling ${method} of ${bidder}`); } } +function tryCallBidderMethod(bidder, method, param) { + if (param?.src !== CONSTANTS.S2S.SRC) { + const target = getBidderMethod(bidder, method); + if (target != null) { + invokeBidderMethod(bidder, method, ...target, param); + } + } +} + adapterManager.callTimedOutBidders = function(adUnits, timedOutBidders, cbTimeout) { timedOutBidders = timedOutBidders.map((timedOutBidder) => { // Adding user configured params & timeout to timeout event data @@ -562,6 +656,10 @@ adapterManager.callBidWonBidder = function(bidder, bid, adUnits) { tryCallBidderMethod(bidder, 'onBidWon', bid); }; +adapterManager.callBidBillableBidder = function(bid) { + tryCallBidderMethod(bid.bidder, 'onBidBillable', bid); +}; + adapterManager.callSetTargetingBidder = function(bidder, bid) { tryCallBidderMethod(bidder, 'onSetTargeting', bid); }; @@ -575,4 +673,41 @@ adapterManager.callBidderError = function(bidder, error, bidderRequest) { tryCallBidderMethod(bidder, 'onBidderError', param); }; +function resolveAlias(alias) { + const seen = new Set(); + while (_aliasRegistry.hasOwnProperty(alias) && !seen.has(alias)) { + seen.add(alias); + alias = _aliasRegistry[alias]; + } + return alias; +} +/** + * Ask every adapter to delete PII. + * See https://github.com/prebid/Prebid.js/issues/9081 + */ +adapterManager.callDataDeletionRequest = hook('sync', function (...args) { + const method = 'onDataDeletionRequest'; + Object.keys(_bidderRegistry) + .filter((bidder) => !_aliasRegistry.hasOwnProperty(bidder)) + .forEach(bidder => { + const target = getBidderMethod(bidder, method); + if (target != null) { + const bidderRequests = auctionManager.getBidsRequested().filter((br) => + resolveAlias(br.bidderCode) === bidder + ); + invokeBidderMethod(bidder, method, ...target, bidderRequests, ...args); + } + }); + Object.entries(_analyticsRegistry).forEach(([name, entry]) => { + const fn = entry?.adapter?.[method]; + if (typeof fn === 'function') { + try { + fn.apply(entry.adapter, args); + } catch (e) { + logError(`error calling ${method} of ${name}`, e); + } + } + }); +}); + export default adapterManager; diff --git a/src/adapters/bidderFactory.js b/src/adapters/bidderFactory.js index 87bc7a45491..df97d820c96 100644 --- a/src/adapters/bidderFactory.js +++ b/src/adapters/bidderFactory.js @@ -1,21 +1,31 @@ import Adapter from '../adapter.js'; import adapterManager from '../adapterManager.js'; -import { config } from '../config.js'; -import { createBid } from '../bidfactory.js'; -import { userSync } from '../userSync.js'; -import { nativeBidIsValid } from '../native.js'; -import { isValidVideoBid } from '../video.js'; +import {config} from '../config.js'; +import {createBid} from '../bidfactory.js'; +import {userSync} from '../userSync.js'; +import {nativeBidIsValid} from '../native.js'; +import {isValidVideoBid} from '../video.js'; import CONSTANTS from '../constants.json'; import * as events from '../events.js'; import {includes} from '../polyfill.js'; -import { ajax } from '../ajax.js'; -import { logWarn, logError, parseQueryStringParameters, delayExecution, parseSizesInput, flatten, uniques, timestamp, deepAccess, isArray, isPlainObject } from '../utils.js'; -import { ADPOD } from '../mediaTypes.js'; -import { getHook, hook } from '../hook.js'; -import { getCoreStorageManager } from '../storageManager.js'; +import { + delayExecution, + isArray, + isPlainObject, + logError, + logWarn, memoize, + parseQueryStringParameters, + parseSizesInput, pick, + uniques +} from '../utils.js'; +import {hook} from '../hook.js'; import {auctionManager} from '../auctionManager.js'; - -export const storage = getCoreStorageManager('bidderFactory'); +import {bidderSettings} from '../bidderSettings.js'; +import {useMetrics} from '../utils/perfMetrics.js'; +import {isActivityAllowed} from '../activities/rules.js'; +import {activityParams} from '../activities/activityParams.js'; +import {MODULE_TYPE_BIDDER} from '../activities/modules.js'; +import {ACTIVITY_TRANSMIT_TID, ACTIVITY_TRANSMIT_UFPD} from '../activities/activities.js'; /** * This file aims to support Adapters during the Prebid 0.x -> 1.x transition. @@ -71,6 +81,13 @@ export const storage = getCoreStorageManager('bidderFactory'); * @property {object} params Any bidder-specific params which the publisher used in their bid request. */ +/** + * @typedef {object} BidderAuctionResponse An object encapsulating an adapter response for current Auction + * + * @property {Array} bids Contextual bids returned by this adapter, if any + * @property {object|null} fledgeAuctionConfigs Optional FLEDGE response, as a map of impid -> auction_config + */ + /** * @typedef {object} ServerRequest * @@ -133,8 +150,7 @@ export const storage = getCoreStorageManager('bidderFactory'); // common params for all mediaTypes const COMMON_BID_RESPONSE_KEYS = ['cpm', 'ttl', 'creativeId', 'netRevenue', 'currency']; - -const DEFAULT_REFRESHIN_DAYS = 1; +const TIDS = ['auctionId', 'transactionId']; /** * Register a bidder with prebid, using the given spec. @@ -169,6 +185,46 @@ export function registerBidder(spec) { } } +export function guardTids(bidderCode) { + if (isActivityAllowed(ACTIVITY_TRANSMIT_TID, activityParams(MODULE_TYPE_BIDDER, bidderCode))) { + return { + bidRequest: (br) => br, + bidderRequest: (br) => br + }; + } + function get(target, prop, receiver) { + if (TIDS.includes(prop)) { + return null; + } + return Reflect.get(target, prop, receiver); + } + function privateAccessProxy(target, handler) { + const proxy = new Proxy(target, handler); + // always allow methods (such as getFloor) private access to TIDs + Object.entries(target) + .filter(([_, v]) => typeof v === 'function') + .forEach(([prop, fn]) => proxy[prop] = fn.bind(target)); + return proxy; + } + const bidRequest = memoize((br) => privateAccessProxy(br, {get}), (arg) => arg.bidId); + /** + * Return a view on bidd(er) requests where auctionId/transactionId are nulled if the bidder is not allowed `transmitTid`. + * + * Because both auctionId and transactionId are used for Prebid's own internal bookkeeping, we cannot simply erase them + * from request objects; and because request objects are quite complex and not easily cloneable, we hide the IDs + * with a proxy instead. This should be used only around the adapter logic. + */ + return { + bidRequest, + bidderRequest: (br) => privateAccessProxy(br, { + get(target, prop, receiver) { + if (prop === 'bids') return br.bids.map(bidRequest); + return get(target, prop, receiver); + } + }) + } +} + /** * Make a new bidder from the given spec. This is exported mainly for testing. * Adapters will probably find it more convenient to use registerBidder instead. @@ -178,19 +234,24 @@ export function registerBidder(spec) { export function newBidder(spec) { return Object.assign(new Adapter(spec.code), { getSpec: function() { - return Object.freeze(spec); + return Object.freeze(Object.assign({}, spec)); }, registerSyncs, callBids: function(bidderRequest, addBidResponse, done, ajax, onTimelyResponse, configEnabledCallback) { if (!Array.isArray(bidderRequest.bids)) { return; } + const tidGuard = guardTids(bidderRequest.bidderCode); const adUnitCodesHandled = {}; function addBidWithCode(adUnitCode, bid) { + const metrics = useMetrics(bid.metrics); + metrics.checkpoint('addBidResponse'); adUnitCodesHandled[adUnitCode] = true; - if (isValid(adUnitCode, bid)) { + if (metrics.measureTime('addBidResponse.validate', () => isValid(adUnitCode, bid))) { addBidResponse(adUnitCode, bid); + } else { + addBidResponse.reject(adUnitCode, bid, CONSTANTS.REJECTION_REASON.INVALID) } } @@ -201,11 +262,13 @@ export function newBidder(spec) { done(); config.runWithBidder(spec.code, () => { events.emit(CONSTANTS.EVENTS.BIDDER_DONE, bidderRequest); - registerSyncs(responses, bidderRequest.gdprConsent, bidderRequest.uspConsent); + registerSyncs(responses, bidderRequest.gdprConsent, bidderRequest.uspConsent, bidderRequest.gppConsent); }); } - const validBidRequests = bidderRequest.bids.filter(filterAndWarn); + const validBidRequests = adapterMetrics(bidderRequest) + .measureTime('validate', () => bidderRequest.bids.filter((br) => filterAndWarn(tidGuard.bidRequest(br)))); + if (validBidRequests.length === 0) { afterAllResponses(); return; @@ -219,12 +282,22 @@ export function newBidder(spec) { } }); - processBidderRequests(spec, validBidRequests, bidderRequest, ajax, configEnabledCallback, { + processBidderRequests(spec, validBidRequests.map(tidGuard.bidRequest), tidGuard.bidderRequest(bidderRequest), ajax, configEnabledCallback, { onRequest: requestObject => events.emit(CONSTANTS.EVENTS.BEFORE_BIDDER_HTTP, bidderRequest, requestObject), onResponse: (resp) => { onTimelyResponse(spec.code); responses.push(resp) }, + onFledgeAuctionConfigs: (fledgeAuctionConfigs) => { + fledgeAuctionConfigs.forEach((fledgeAuctionConfig) => { + const bidRequest = bidRequestMap[fledgeAuctionConfig.bidId]; + if (bidRequest) { + addComponentAuction(bidRequest.auctionId, bidRequest.adUnitCode, fledgeAuctionConfig.config); + } else { + logWarn('Received fledge auction configuration for an unknown bidId', fledgeAuctionConfig); + } + }); + }, // If the server responds with an error, there's not much we can do beside logging. onError: (errorMessage, error) => { onTimelyResponse(spec.code); @@ -235,14 +308,21 @@ export function newBidder(spec) { onBid: (bid) => { const bidRequest = bidRequestMap[bid.requestId]; if (bidRequest) { + bid.adapterCode = bidRequest.bidder; + if (isInvalidAlternateBidder(bid.bidderCode, bidRequest.bidder)) { + logWarn(`${bid.bidderCode} is not a registered partner or known bidder of ${bidRequest.bidder}, hence continuing without bid. If you wish to support this bidder, please mark allowAlternateBidderCodes as true in bidderSettings.`); + addBidResponse.reject(bidRequest.adUnitCode, bid, CONSTANTS.REJECTION_REASON.BIDDER_DISALLOWED) + return; + } // creating a copy of original values as cpm and currency are modified later bid.originalCpm = bid.cpm; bid.originalCurrency = bid.currency; bid.meta = bid.meta || Object.assign({}, bid[bidRequest.bidder]); - const prebidBid = Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid); + const prebidBid = Object.assign(createBid(CONSTANTS.STATUS.GOOD, bidRequest), bid, pick(bidRequest, TIDS)); addBidWithCode(bidRequest.adUnitCode, prebidBid); } else { logWarn(`Bidder ${spec.code} made bid for unknown request ID: ${bid.requestId}. Ignoring.`); + addBidResponse.reject(null, bid, CONSTANTS.REJECTION_REASON.INVALID_REQUEST_ID); } }, onCompletion: afterAllResponses, @@ -250,8 +330,21 @@ export function newBidder(spec) { } }); - function registerSyncs(responses, gdprConsent, uspConsent) { - registerSyncInner(spec, responses, gdprConsent, uspConsent); + function isInvalidAlternateBidder(responseBidder, requestBidder) { + let allowAlternateBidderCodes = bidderSettings.get(requestBidder, 'allowAlternateBidderCodes') || false; + let alternateBiddersList = bidderSettings.get(requestBidder, 'allowedAlternateBidderCodes'); + if (!!responseBidder && !!requestBidder && requestBidder !== responseBidder) { + alternateBiddersList = isArray(alternateBiddersList) ? alternateBiddersList.map(val => val.trim().toLowerCase()).filter(val => !!val).filter(uniques) : alternateBiddersList; + if (!allowAlternateBidderCodes || (isArray(alternateBiddersList) && (alternateBiddersList[0] !== '*' && !alternateBiddersList.includes(responseBidder)))) { + return true; + } + } + + return false; + } + + function registerSyncs(responses, gdprConsent, uspConsent, gppConsent) { + registerSyncInner(spec, responses, gdprConsent, uspConsent, gppConsent); } function filterAndWarn(bid) { @@ -278,8 +371,12 @@ export function newBidder(spec) { * @param onBid {function({})} invoked once for each bid in the response - with the bid as returned by interpretResponse * @param onCompletion {function()} invoked once when all bid requests have been processed */ -export const processBidderRequests = hook('sync', function (spec, bids, bidderRequest, ajax, wrapCallback, {onRequest, onResponse, onError, onBid, onCompletion}) { - let requests = spec.buildRequests(bids, bidderRequest); +export const processBidderRequests = hook('sync', function (spec, bids, bidderRequest, ajax, wrapCallback, {onRequest, onResponse, onFledgeAuctionConfigs, onError, onBid, onCompletion}) { + const metrics = adapterMetrics(bidderRequest); + onCompletion = metrics.startTiming('total').stopBefore(onCompletion); + + let requests = metrics.measureTime('buildRequests', () => spec.buildRequests(bids, bidderRequest)); + if (!requests || requests.length === 0) { onCompletion(); return; @@ -291,10 +388,16 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe const requestDone = delayExecution(onCompletion, requests.length); requests.forEach((request) => { + const requestMetrics = metrics.fork(); + function addBid(bid) { + if (bid != null) bid.metrics = requestMetrics.fork().renameWith(); + onBid(bid); + } // If the server responds successfully, use the adapter code to unpack the Bids from it. // If the adapter code fails, no bids should be added. After all the bids have been added, // make sure to call the `requestDone` function so that we're one step closer to calling onCompletion(). const onSuccess = wrapCallback(function(response, responseObj) { + networkDone(); try { response = JSON.parse(response); } catch (e) { /* response might not be JSON... that's ok. */ } @@ -306,20 +409,28 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe }; onResponse(response); - let bids; try { - bids = spec.interpretResponse(response, request); + response = requestMetrics.measureTime('interpretResponse', () => spec.interpretResponse(response, request)); } catch (err) { logError(`Bidder ${spec.code} failed to interpret the server's response. Continuing without bids`, null, err); requestDone(); return; } + let bids; + // Extract additional data from a structured {BidderAuctionResponse} response + if (response && isArray(response.fledgeAuctionConfigs)) { + onFledgeAuctionConfigs(response.fledgeAuctionConfigs); + bids = response.bids; + } else { + bids = response; + } + if (bids) { if (isArray(bids)) { - bids.forEach(onBid); + bids.forEach(addBid); } else { - onBid(bids); + addBid(bids); } } requestDone(); @@ -332,11 +443,23 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe }); const onFailure = wrapCallback(function (errorMessage, error) { + networkDone(); onError(errorMessage, error); requestDone(); }); onRequest(request); + + const networkDone = requestMetrics.startTiming('net'); + + function getOptions(defaults) { + const ro = request.options; + return Object.assign(defaults, ro, { + browsingTopics: ro?.hasOwnProperty('browsingTopics') && !ro.browsingTopics + ? false + : isActivityAllowed(ACTIVITY_TRANSMIT_UFPD, activityParams(MODULE_TYPE_BIDDER, spec.code)) + }) + } switch (request.method) { case 'GET': ajax( @@ -346,10 +469,10 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe error: onFailure }, undefined, - Object.assign({ + getOptions({ method: 'GET', withCredentials: true - }, request.options) + }) ); break; case 'POST': @@ -360,11 +483,11 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe error: onFailure }, typeof request.data === 'string' ? request.data : JSON.stringify(request.data), - Object.assign({ + getOptions({ method: 'POST', contentType: 'text/plain', withCredentials: true - }, request.options) + }) ); break; default: @@ -382,14 +505,14 @@ export const processBidderRequests = hook('sync', function (spec, bids, bidderRe }) }, 'processBidderRequests') -export const registerSyncInner = hook('async', function(spec, responses, gdprConsent, uspConsent) { +export const registerSyncInner = hook('async', function(spec, responses, gdprConsent, uspConsent, gppConsent) { const aliasSyncEnabled = config.getConfig('userSync.aliasSyncEnabled'); if (spec.getUserSyncs && (aliasSyncEnabled || !adapterManager.aliasRegistry[spec.code])) { let filterConfig = config.getConfig('userSync.filterSettings'); let syncs = spec.getUserSyncs({ iframeEnabled: !!(filterConfig && (filterConfig.iframe || filterConfig.all)), pixelEnabled: !!(filterConfig && (filterConfig.image || filterConfig.all)), - }, responses, gdprConsent, uspConsent); + }, responses, gdprConsent, uspConsent, gppConsent); if (syncs) { if (!Array.isArray(syncs)) { syncs = [syncs]; @@ -397,81 +520,13 @@ export const registerSyncInner = hook('async', function(spec, responses, gdprCon syncs.forEach((sync) => { userSync.registerSync(sync.type, spec.code, sync.url) }); + userSync.bidderDone(spec.code); } } }, 'registerSyncs') -export function preloadBidderMappingFile(fn, adUnits) { - if (!config.getConfig('adpod.brandCategoryExclusion')) { - return fn.call(this, adUnits); - } - let adPodBidders = adUnits - .filter((adUnit) => deepAccess(adUnit, 'mediaTypes.video.context') === ADPOD) - .map((adUnit) => adUnit.bids.map((bid) => bid.bidder)) - .reduce(flatten, []) - .filter(uniques); - - adPodBidders.forEach(bidder => { - let bidderSpec = adapterManager.getBidAdapter(bidder); - if (bidderSpec.getSpec().getMappingFileInfo) { - let info = bidderSpec.getSpec().getMappingFileInfo(); - let refreshInDays = (info.refreshInDays) ? info.refreshInDays : DEFAULT_REFRESHIN_DAYS; - let key = (info.localStorageKey) ? info.localStorageKey : bidderSpec.getSpec().code; - let mappingData = storage.getDataFromLocalStorage(key); - try { - mappingData = mappingData ? JSON.parse(mappingData) : undefined; - if (!mappingData || timestamp() > mappingData.lastUpdated + refreshInDays * 24 * 60 * 60 * 1000) { - ajax(info.url, - { - success: (response) => { - try { - response = JSON.parse(response); - let mapping = { - lastUpdated: timestamp(), - mapping: response.mapping - } - storage.setDataInLocalStorage(key, JSON.stringify(mapping)); - } catch (error) { - logError(`Failed to parse ${bidder} bidder translation mapping file`); - } - }, - error: () => { - logError(`Failed to load ${bidder} bidder translation file`) - } - }, - ); - } - } catch (error) { - logError(`Failed to parse ${bidder} bidder translation mapping file`); - } - } - }); - fn.call(this, adUnits); -} - -getHook('checkAdUnitSetup').before(preloadBidderMappingFile); - -/** - * Reads the data stored in localstorage and returns iab subcategory - * @param {string} bidderCode bidderCode - * @param {string} category bidders category - */ -export function getIabSubCategory(bidderCode, category) { - let bidderSpec = adapterManager.getBidAdapter(bidderCode); - if (bidderSpec.getSpec().getMappingFileInfo) { - let info = bidderSpec.getSpec().getMappingFileInfo(); - let key = (info.localStorageKey) ? info.localStorageKey : bidderSpec.getBidderCode(); - let data = storage.getDataFromLocalStorage(key); - if (data) { - try { - data = JSON.parse(data); - } catch (error) { - logError(`Failed to parse ${bidderCode} mapping data stored in local storage`); - } - return (data.mapping[category]) ? data.mapping[category] : null; - } - } -} +export const addComponentAuction = hook('sync', (adUnitCode, fledgeAuctionConfig) => { +}, 'addComponentAuction'); // check that the bid has a width and height set function validBidSize(adUnitCode, bid, {index = auctionManager.index} = {}) { @@ -525,11 +580,11 @@ export function isValid(adUnitCode, bid, {index = auctionManager.index} = {}) { return false; } - if (bid.mediaType === 'native' && !nativeBidIsValid(bid, {index})) { + if (FEATURES.NATIVE && bid.mediaType === 'native' && !nativeBidIsValid(bid, {index})) { logError(errorMessage('Native bid missing some required properties.')); return false; } - if (bid.mediaType === 'video' && !isValidVideoBid(bid, {index})) { + if (FEATURES.VIDEO && bid.mediaType === 'video' && !isValidVideoBid(bid, {index})) { logError(errorMessage(`Video bid does not have required vastUrl or renderer property`)); return false; } @@ -540,3 +595,7 @@ export function isValid(adUnitCode, bid, {index = auctionManager.index} = {}) { return true; } + +function adapterMetrics(bidderRequest) { + return useMetrics(bidderRequest.metrics).renameWith(n => [`adapter.client.${n}`, `adapters.client.${bidderRequest.bidderCode}.${n}`]) +} diff --git a/src/adloader.js b/src/adloader.js index db128c6d7ba..a87b930b7df 100644 --- a/src/adloader.js +++ b/src/adloader.js @@ -1,16 +1,32 @@ import {includes} from './polyfill.js'; -import { logError, logWarn, insertElement } from './utils.js'; +import { logError, logWarn, insertElement, setScriptAttributes } from './utils.js'; const _requestCache = new WeakMap(); // The below list contains modules or vendors whom Prebid allows to load external JS. const _approvedLoadExternalJSList = [ + 'debugging', 'adloox', 'criteo', 'outstream', 'adagio', + 'spotx', 'browsi', 'brandmetrics', - 'justtag' + 'justtag', + 'tncId', + 'akamaidap', + 'ftrackId', + 'inskin', + 'hadron', + 'medianet', + 'improvedigital', + 'aaxBlockmeter', + 'confiant', + 'arcspan', + 'airgrid', + 'clean.io', + 'a1Media', + 'geoedge', ] /** @@ -20,8 +36,9 @@ const _approvedLoadExternalJSList = [ * @param {string} moduleCode bidderCode or module code of the module requesting this resource * @param {function} [callback] callback function to be called after the script is loaded * @param {Document} [doc] the context document, in which the script will be loaded, defaults to loaded document + * @param {object} an object of attributes to be added to the script with setAttribute by [key] and [value]; Only the attributes passed in the first request of a url will be added. */ -export function loadExternalScript(url, moduleCode, callback, doc) { +export function loadExternalScript(url, moduleCode, callback, doc, attributes) { if (!moduleCode || !url) { logError('cannot load external script without url and moduleCode'); return; @@ -70,9 +87,9 @@ export function loadExternalScript(url, moduleCode, callback, doc) { } catch (e) { logError('Error executing callback', 'adloader.js:loadExternalScript', e); } - }, doc); + }, doc, attributes); - function requestResource(tagSrc, callback, doc) { + function requestResource(tagSrc, callback, doc, attributes) { if (!doc) { doc = document; } @@ -100,6 +117,10 @@ export function loadExternalScript(url, moduleCode, callback, doc) { jptScript.src = tagSrc; + if (attributes) { + setScriptAttributes(jptScript, attributes); + } + // add the new script tag to the page insertElement(jptScript, doc); diff --git a/src/adserver.js b/src/adserver.js index 61af8862972..db7aaaa1dc8 100644 --- a/src/adserver.js +++ b/src/adserver.js @@ -1,55 +1,6 @@ -import { formatQS } from './utils.js'; -import { targeting } from './targeting.js'; +import {hook} from './hook.js'; -// Adserver parent class -const AdServer = function(attr) { - this.name = attr.adserver; - this.code = attr.code; - this.getWinningBidByCode = function() { - return targeting.getWinningBids(this.code)[0]; - }; -}; - -// DFP ad server -export function dfpAdserver(options, urlComponents) { - var adserver = new AdServer(options); - adserver.urlComponents = urlComponents; - - var dfpReqParams = { - 'env': 'vp', - 'gdfp_req': '1', - 'impl': 's', - 'unviewed_position_start': '1' - }; - - var dfpParamsWithVariableValue = ['output', 'iu', 'sz', 'url', 'correlator', 'description_url', 'hl']; - - var getCustomParams = function(targeting) { - return encodeURIComponent(formatQS(targeting)); - }; - - adserver.appendQueryParams = function() { - var bid = adserver.getWinningBidByCode(); - if (bid) { - this.urlComponents.search.description_url = encodeURIComponent(bid.vastUrl); - this.urlComponents.search.cust_params = getCustomParams(bid.adserverTargeting); - this.urlComponents.search.correlator = Date.now(); - } - }; - - adserver.verifyAdserverTag = function() { - for (var key in dfpReqParams) { - if (!this.urlComponents.search.hasOwnProperty(key) || this.urlComponents.search[key] !== dfpReqParams[key]) { - return false; - } - } - for (var i in dfpParamsWithVariableValue) { - if (!this.urlComponents.search.hasOwnProperty(dfpParamsWithVariableValue[i])) { - return false; - } - } - return true; - }; - - return adserver; -}; +/** + * return the GAM PPID, if available (eid for the userID configured with `userSync.ppidSource`) + */ +export const getPPID = hook('sync', () => undefined); diff --git a/src/ajax.js b/src/ajax.js index 5e926f3210d..0601cc0e22b 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,99 +1,138 @@ -import { config } from './config.js'; -import { logMessage, logError, parseUrl, buildUrl, _each } from './utils.js'; +import {config} from './config.js'; +import {buildUrl, logError, parseUrl} from './utils.js'; -const XHR_DONE = 4; +export const dep = { + fetch: window.fetch.bind(window), + makeRequest: (r, o) => new Request(r, o), + timeout(timeout, resource) { + const ctl = new AbortController(); + let cancelTimer = setTimeout(() => { + ctl.abort(); + logError(`Request timeout after ${timeout}ms`, resource); + cancelTimer = null; + }, timeout); + return { + signal: ctl.signal, + done() { + cancelTimer && clearTimeout(cancelTimer) + } + } + } +} + +const GET = 'GET'; +const POST = 'POST'; +const CTYPE = 'Content-Type'; /** - * Simple IE9+ and cross-browser ajax request function - * Note: x-domain requests in IE9 do not support the use of cookies - * - * @param url string url - * @param callback {object | function} callback - * @param data mixed data - * @param options object + * transform legacy `ajax` parameters into a fetch request. + * @returns {Request} */ -export const ajax = ajaxBuilder(); - -export function ajaxBuilder(timeout = 3000, {request, done} = {}) { - return function(url, callback, data, options = {}) { - try { - let x; - let method = options.method || (data ? 'POST' : 'GET'); - let parser = document.createElement('a'); - parser.href = url; - - let callbacks = typeof callback === 'object' && callback !== null ? callback : { - success: function() { - logMessage('xhr success'); - }, - error: function(e) { - logError('xhr error', null, e); - } - }; +export function toFetchRequest(url, data, options = {}) { + const method = options.method || (data ? POST : GET); + if (method === GET && data) { + const urlInfo = parseUrl(url, options); + Object.assign(urlInfo.search, data); + url = buildUrl(urlInfo); + } + const headers = new Headers(options.customHeaders); + headers.set(CTYPE, options.contentType || 'text/plain'); + const rqOpts = { + method, + headers + } + if (method !== GET && data) { + rqOpts.body = data; + } + if (options.withCredentials) { + rqOpts.credentials = 'include'; + } + if (options.browsingTopics && isSecureContext) { + // the Request constructor will throw an exception if the browser supports topics + // but we're not in a secure context + rqOpts.browsingTopics = true; + } + return dep.makeRequest(url, rqOpts); +} - if (typeof callback === 'function') { - callbacks.success = callback; - } +/** + * Return a version of `fetch` that automatically cancels requests after `timeout` milliseconds. + * + * If provided, `request` and `done` should be functions accepting a single argument. + * `request` is invoked at the beginning of each request, and `done` at the end; both are passed its origin. + * + * @returns {function(*, {}?): Promise} + */ +export function fetcherFactory(timeout = 3000, {request, done} = {}) { + let fetcher = (resource, options) => { + let to; + if (timeout != null && options?.signal == null && !config.getConfig('disableAjaxTimeout')) { + to = dep.timeout(timeout, resource); + options = Object.assign({signal: to.signal}, options); + } + let pm = dep.fetch(resource, options); + if (to?.done != null) pm = pm.finally(to.done); + return pm; + }; - x = new window.XMLHttpRequest(); + if (request != null || done != null) { + fetcher = ((fetch) => function (resource, options) { + const origin = new URL(resource?.url == null ? resource : resource.url, document.location).origin; + let req = fetch(resource, options); + request && request(origin); + if (done) req = req.finally(() => done(origin)); + return req; + })(fetcher); + } + return fetcher; +} - x.onreadystatechange = function () { - if (x.readyState === XHR_DONE) { - if (typeof done === 'function') { - done(parser.origin); - } - let status = x.status; - if ((status >= 200 && status < 300) || status === 304) { - callbacks.success(x.responseText, x); - } else { - callbacks.error(x.statusText, x); - } +function toXHR({status, statusText = '', headers, url}, responseText) { + let xml = 0; + return { + readyState: XMLHttpRequest.DONE, + status, + statusText, + responseText, + response: responseText, + responseType: '', + responseURL: url, + get responseXML() { + if (xml === 0) { + try { + xml = new DOMParser().parseFromString(responseText, headers?.get(CTYPE)?.split(';')?.[0]) + } catch (e) { + xml = null; + logError(e); } - }; - - // Disabled timeout temporarily to avoid xhr failed requests. https://github.com/prebid/Prebid.js/issues/2648 - if (!config.getConfig('disableAjaxTimeout')) { - x.ontimeout = function () { - logError(' xhr timeout after ', x.timeout, 'ms'); - }; } + return xml; + }, + getResponseHeader: (header) => headers?.has(header) ? headers.get(header) : null, + } +} - if (method === 'GET' && data) { - let urlInfo = parseUrl(url, options); - Object.assign(urlInfo.search, data); - url = buildUrl(urlInfo); - } - - x.open(method, url, true); - // IE needs timeout to be set after open - see #1410 - // Disabled timeout temporarily to avoid xhr failed requests. https://github.com/prebid/Prebid.js/issues/2648 - if (!config.getConfig('disableAjaxTimeout')) { - x.timeout = timeout; - } - - if (options.withCredentials) { - x.withCredentials = true; - } - _each(options.customHeaders, (value, header) => { - x.setRequestHeader(header, value); - }); - if (options.preflight) { - x.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - } - x.setRequestHeader('Content-Type', options.contentType || 'text/plain'); - - if (typeof request === 'function') { - request(parser.origin); - } +/** + * attach legacy `ajax` callbacks to a fetch promise. + */ +export function attachCallbacks(fetchPm, callback) { + const {success, error} = typeof callback === 'object' && callback != null ? callback : { + success: typeof callback === 'function' ? callback : () => null, + error: (e, x) => logError('Network error', e, x) + }; + fetchPm.then(response => response.text().then((responseText) => [response, responseText])) + .then(([response, responseText]) => { + const xhr = toXHR(response, responseText); + response.ok || response.status === 304 ? success(responseText, xhr) : error(response.statusText, xhr); + }, () => error('', toXHR({status: 0}, ''))); +} - if (method === 'POST' && data) { - x.send(data); - } else { - x.send(); - } - } catch (error) { - logError('xhr construction', error); - typeof callback === 'object' && callback !== null && callback.error(error); - } - } +export function ajaxBuilder(timeout = 3000, {request, done} = {}) { + const fetcher = fetcherFactory(timeout, {request, done}); + return function (url, callback, data, options = {}) { + attachCallbacks(fetcher(toFetchRequest(url, data, options)), callback); + }; } + +export const ajax = ajaxBuilder(); +export const fetch = fetcherFactory(); diff --git a/src/auction.js b/src/auction.js index ae5c3c6156b..4bdd590f7ea 100644 --- a/src/auction.js +++ b/src/auction.js @@ -4,7 +4,7 @@ * In Prebid 0.x, $$PREBID_GLOBAL$$ had _bidsRequested and _bidsReceived as public properties. * Starting 1.0, Prebid will support concurrent auctions. Each auction instance will store private properties, bidsRequested and bidsReceived. * - * AuctionManager will create instance of auction and will store all the auctions. + * AuctionManager will create an instance of auction and will store all the auctions. * */ @@ -58,28 +58,41 @@ */ import { - flatten, timestamp, adUnitsFilter, deepAccess, getValue, parseUrl, generateUUID, - logMessage, bind, logError, logInfo, logWarn, isEmpty, _each, isFn, isEmptyStr + deepAccess, + generateUUID, + getValue, + isEmpty, + isEmptyStr, + isFn, + logError, + logInfo, + logMessage, + logWarn, + parseUrl, + timestamp } from './utils.js'; -import { getPriceBucketString } from './cpmBucketManager.js'; -import { getNativeTargeting } from './native.js'; -import { getCacheUrl, store } from './videoCache.js'; -import { Renderer } from './Renderer.js'; -import { config } from './config.js'; -import { userSync } from './userSync.js'; -import { hook } from './hook.js'; +import {getPriceBucketString} from './cpmBucketManager.js'; +import {getNativeTargeting, toLegacyResponse} from './native.js'; +import {getCacheUrl, store} from './videoCache.js'; +import {Renderer} from './Renderer.js'; +import {config} from './config.js'; +import {userSync} from './userSync.js'; +import {hook} from './hook.js'; import {find, includes} from './polyfill.js'; -import { OUTSTREAM } from './video.js'; -import { VIDEO } from './mediaTypes.js'; +import {OUTSTREAM} from './video.js'; +import {VIDEO} from './mediaTypes.js'; import {auctionManager} from './auctionManager.js'; import {bidderSettings} from './bidderSettings.js'; +import * as events from './events.js'; +import adapterManager from './adapterManager.js'; +import CONSTANTS from './constants.json'; +import {defer, GreedyPromise} from './utils/promise.js'; +import {useMetrics} from './utils/perfMetrics.js'; +import {adjustCpm} from './utils/cpm.js'; +import {getGlobal} from './prebidGlobal.js'; const { syncUsers } = userSync; -const adapterManager = require('./adapterManager.js').default; -const events = require('./events.js'); -const CONSTANTS = require('./constants.json'); - export const AUCTION_STARTED = 'started'; export const AUCTION_IN_PROGRESS = 'inProgress'; export const AUCTION_COMPLETED = 'completed'; @@ -94,6 +107,16 @@ const outstandingRequests = {}; const sourceInfo = {}; const queuedCalls = []; +const pbjsInstance = getGlobal(); + +/** + * Clear global state for tests + */ +export function resetAuctionState() { + queuedCalls.length = 0; + [outstandingRequests, sourceInfo].forEach((ob) => Object.keys(ob).forEach((k) => { delete ob[k] })); +} + /** * Creates new auction instance * @@ -104,29 +127,36 @@ const queuedCalls = []; * @param {number} requestConfig.cbTimeout * @param {Array.} requestConfig.labels * @param {string} requestConfig.auctionId - * + * @param {{global: {}, bidder: {}}} ortb2Fragments first party data, separated into global + * (from getConfig('ortb2') + requestBids({ortb2})) and bidder (a map from bidderCode to ortb2) * @returns {Auction} auction instance */ -export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId}) { - let _adUnits = adUnits; - let _labels = labels; - let _adUnitCodes = adUnitCodes; +export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId, ortb2Fragments, metrics}) { + metrics = useMetrics(metrics); + const _adUnits = adUnits; + const _labels = labels; + const _adUnitCodes = adUnitCodes; + const _auctionId = auctionId || generateUUID(); + const _timeout = cbTimeout; + const _timelyRequests = new Set(); + const done = defer(); + let _bidsRejected = []; + let _callback = callback; let _bidderRequests = []; let _bidsReceived = []; let _noBids = []; + let _winningBids = []; let _auctionStart; let _auctionEnd; - let _auctionId = auctionId || generateUUID(); + let _timeoutTimer; let _auctionStatus; - let _callback = callback; - let _timer; - let _timeout = cbTimeout; - let _winningBids = []; - let _timelyBidders = new Set(); + let _nonBids = []; function addBidRequests(bidderRequests) { _bidderRequests = _bidderRequests.concat(bidderRequests); } function addBidReceived(bidsReceived) { _bidsReceived = _bidsReceived.concat(bidsReceived); } + function addBidRejected(bidsRejected) { _bidsRejected = _bidsRejected.concat(bidsRejected); } function addNoBid(noBid) { _noBids = _noBids.concat(noBid); } + function addNonBids(seatnonbids) { _nonBids = _nonBids.concat(seatnonbids); } function getProperties() { return { @@ -140,54 +170,55 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a bidderRequests: _bidderRequests, noBids: _noBids, bidsReceived: _bidsReceived, + bidsRejected: _bidsRejected, winningBids: _winningBids, - timeout: _timeout + timeout: _timeout, + metrics: metrics, + seatNonBids: _nonBids }; } function startAuctionTimer() { - const timedOut = true; - const timeoutCallback = executeCallback.bind(null, timedOut); - let timer = setTimeout(timeoutCallback, _timeout); - _timer = timer; + _timeoutTimer = setTimeout(() => executeCallback(true), _timeout); } - function executeCallback(timedOut, cleartimer) { - // clear timer when done calls executeCallback - if (cleartimer) { - clearTimeout(_timer); + function executeCallback(timedOut) { + if (!timedOut) { + clearTimeout(_timeoutTimer); } - if (_auctionEnd === undefined) { - let timedOutBidders = []; + let timedOutRequests = []; if (timedOut) { logMessage(`Auction ${_auctionId} timedOut`); - timedOutBidders = getTimedOutBids(_bidderRequests, _timelyBidders); - if (timedOutBidders.length) { - events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutBidders); + timedOutRequests = _bidderRequests.filter(rq => !_timelyRequests.has(rq.bidderRequestId)).flatMap(br => br.bids) + if (timedOutRequests.length) { + events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, timedOutRequests); } } _auctionStatus = AUCTION_COMPLETED; _auctionEnd = Date.now(); + metrics.checkpoint('auctionEnd'); + metrics.timeBetween('requestBids', 'auctionEnd', 'requestBids.total'); + metrics.timeBetween('callBids', 'auctionEnd', 'requestBids.callBids'); + done.resolve(); events.emit(CONSTANTS.EVENTS.AUCTION_END, getProperties()); bidsBackCallback(_adUnits, function () { try { if (_callback != null) { - const adUnitCodes = _adUnitCodes; const bids = _bidsReceived - .filter(bind.call(adUnitsFilter, this, adUnitCodes)) + .filter(bid => _adUnitCodes.includes(bid.adUnitCode)) .reduce(groupByPlacement, {}); - _callback.apply($$PREBID_GLOBAL$$, [bids, timedOut, _auctionId]); + _callback.apply(pbjsInstance, [bids, timedOut, _auctionId]); _callback = null; } } catch (e) { logError('Error executing bidsBackHandler', null, e); } finally { // Calling timed out bidders - if (timedOutBidders.length) { - adapterManager.callTimedOutBidders(adUnits, timedOutBidders, _timeout); + if (timedOutRequests.length) { + adapterManager.callTimedOutBidders(adUnits, timedOutRequests, _timeout); } // Only automatically sync if the publisher has not chosen to "enableOverride" let userSyncConfig = config.getConfig('userSync') || {}; @@ -205,20 +236,23 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a // when all bidders have called done callback atleast once it means auction is complete logInfo(`Bids Received for Auction with id: ${_auctionId}`, _bidsReceived); _auctionStatus = AUCTION_COMPLETED; - executeCallback(false, true); + executeCallback(false); } - function onTimelyResponse(bidderCode) { - _timelyBidders.add(bidderCode); + function onTimelyResponse(bidderRequestId) { + _timelyRequests.add(bidderRequestId); } function callBids() { _auctionStatus = AUCTION_STARTED; _auctionStart = Date.now(); - let bidRequests = adapterManager.makeBidRequests(_adUnits, _auctionStart, _auctionId, _timeout, _labels); + let bidRequests = metrics.measureTime('requestBids.makeRequests', + () => adapterManager.makeBidRequests(_adUnits, _auctionStart, _auctionId, _timeout, _labels, ortb2Fragments, metrics)); logInfo(`Bids Requested for Auction with id: ${_auctionId}`, bidRequests); + metrics.checkpoint('callBids') + if (bidRequests.length < 1) { logWarn('No valid bid requests returned for auction'); auctionDone(); @@ -273,7 +307,7 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a } } } - }, _timeout, onTimelyResponse); + }, _timeout, onTimelyResponse, ortb2Fragments); } }; @@ -324,23 +358,32 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a } function addWinningBid(winningBid) { + const winningAd = adUnits.find(adUnit => adUnit.transactionId === winningBid.transactionId); _winningBids = _winningBids.concat(winningBid); - adapterManager.callBidWonBidder(winningBid.bidder, winningBid, adUnits); + adapterManager.callBidWonBidder(winningBid.adapterCode || winningBid.bidder, winningBid, adUnits); + if (winningAd && !winningAd.deferBilling) adapterManager.callBidBillableBidder(winningBid); } function setBidTargeting(bid) { - adapterManager.callSetTargetingBidder(bid.bidder, bid); + adapterManager.callSetTargetingBidder(bid.adapterCode || bid.bidder, bid); } + events.on(CONSTANTS.EVENTS.SEAT_NON_BID, (event) => { + if (event.auctionId === _auctionId) { + addNonBids(event.seatnonbid) + } + }); + return { addBidReceived, + addBidRejected, addNoBid, - executeCallback, callBids, addWinningBid, setBidTargeting, getWinningBids: () => _winningBids, getAuctionStart: () => _auctionStart, + getAuctionEnd: () => _auctionEnd, getTimeout: () => _timeout, getAuctionId: () => _auctionId, getAuctionStatus: () => _auctionStatus, @@ -349,11 +392,21 @@ export function newAuction({adUnits, adUnitCodes, callback, cbTimeout, labels, a getBidRequests: () => _bidderRequests, getBidsReceived: () => _bidsReceived, getNoBids: () => _noBids, - - } + getNonBids: () => _nonBids, + getFPD: () => ortb2Fragments, + getMetrics: () => metrics, + end: done.promise + }; } -export const addBidResponse = hook('sync', function(adUnitCode, bid) { +/** + * Hook into this to intercept bids before they are added to an auction. + * + * @param adUnitCode + * @param bid + * @param {function(String)} reject: a function that, when called, rejects `bid` with the given reason. + */ +export const addBidResponse = hook('sync', function(adUnitCode, bid, reject) { this.dispatch.call(null, adUnitCode, bid); }, 'addBidResponse'); @@ -376,9 +429,9 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM function waitFor(requestId, result) { if (ready[requestId] == null) { - ready[requestId] = Promise.resolve(); + ready[requestId] = GreedyPromise.resolve(); } - ready[requestId] = ready[requestId].then(() => Promise.resolve(result).catch(() => {})) + ready[requestId] = ready[requestId].then(() => GreedyPromise.resolve(result).catch(() => {})) } function guard(bidderRequest, fn) { @@ -390,9 +443,9 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM const wait = ready[bidderRequest.bidderRequestId]; const orphanWait = ready['']; // also wait for "orphan" responses that are not associated with any request if ((wait != null || orphanWait != null) && timeRemaining > 0) { - Promise.race([ - new Promise((resolve) => setTimeout(resolve, timeRemaining)), - Promise.resolve(orphanWait).then(() => wait) + GreedyPromise.race([ + GreedyPromise.timeout(timeRemaining), + GreedyPromise.resolve(orphanWait).then(() => wait) ]).then(fn); } else { fn(); @@ -406,20 +459,39 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM } } - function handleBidResponse(adUnitCode, bid) { + function handleBidResponse(adUnitCode, bid, handler) { bidResponseMap[bid.requestId] = true; - + addCommonResponseProperties(bid, adUnitCode) outstandingBidsAdded++; - let auctionId = auctionInstance.getAuctionId(); + return handler(afterBidAdded); + } - let bidResponse = getPreparedBidForAuction({adUnitCode, bid, auctionId}); + function acceptBidResponse(adUnitCode, bid) { + handleBidResponse(adUnitCode, bid, (done) => { + let bidResponse = getPreparedBidForAuction(bid); - if (bidResponse.mediaType === 'video') { - tryAddVideoBid(auctionInstance, bidResponse, afterBidAdded); - } else { - addBidToAuction(auctionInstance, bidResponse); - afterBidAdded(); - } + if (FEATURES.VIDEO && bidResponse.mediaType === VIDEO) { + tryAddVideoBid(auctionInstance, bidResponse, done); + } else { + if (FEATURES.NATIVE && bidResponse.native != null && typeof bidResponse.native === 'object') { + // NOTE: augment bidResponse.native even if bidResponse.mediaType !== NATIVE; it's possible + // to treat banner responses as native + addLegacyFieldsIfNeeded(bidResponse); + } + addBidToAuction(auctionInstance, bidResponse); + done(); + } + }); + } + + function rejectBidResponse(adUnitCode, bid, reason) { + return handleBidResponse(adUnitCode, bid, (done) => { + bid.rejectionReason = reason; + logWarn(`Bid from ${bid.bidder || 'unknown bidder'} was rejected: ${reason}`, bid) + events.emit(CONSTANTS.EVENTS.BID_REJECTED, bid); + auctionInstance.addBidRejected(bid); + done(); + }) } function adapterDone() { @@ -451,32 +523,37 @@ export function auctionCallbacks(auctionDone, auctionInstance, {index = auctionM } return { - addBidResponse: function (adUnit, bid) { - const bidderRequest = index.getBidderRequest(bid); - waitFor((bidderRequest && bidderRequest.bidderRequestId) || '', addBidResponse.call({ - dispatch: handleBidResponse, - }, adUnit, bid)); - }, + addBidResponse: (function () { + function addBid(adUnitCode, bid) { + const bidderRequest = index.getBidderRequest(bid); + waitFor((bidderRequest && bidderRequest.bidderRequestId) || '', addBidResponse.call({ + dispatch: acceptBidResponse, + }, adUnitCode, bid, (() => { + let rejected = false; + return (reason) => { + if (!rejected) { + rejectBidResponse(adUnitCode, bid, reason); + rejected = true; + } + } + })())); + } + addBid.reject = rejectBidResponse; + return addBid; + })(), adapterDone: function () { guard(this, adapterDone.bind(this)) } } } -export function doCallbacksIfTimedout(auctionInstance, bidResponse) { - if (bidResponse.timeToRespond > auctionInstance.getTimeout() + config.getConfig('timeoutBuffer')) { - auctionInstance.executeCallback(true); - } -} - // Add a bid to the auction. export function addBidToAuction(auctionInstance, bidResponse) { setupBidTargeting(bidResponse); - events.emit(CONSTANTS.EVENTS.BID_RESPONSE, bidResponse); + useMetrics(bidResponse.metrics).timeSince('addBidResponse', 'addBidResponse.total'); auctionInstance.addBidReceived(bidResponse); - - doCallbacksIfTimedout(auctionInstance, bidResponse); + events.emit(CONSTANTS.EVENTS.BID_RESPONSE, bidResponse); } // Video bids may fail if the cache is down, or there's trouble on the network. @@ -489,8 +566,9 @@ function tryAddVideoBid(auctionInstance, bidResponse, afterBidAdded, {index = au transactionId: bidResponse.transactionId }), 'video'); const context = videoMediaType && deepAccess(videoMediaType, 'context'); + const useCacheKey = videoMediaType && deepAccess(videoMediaType, 'useCacheKey'); - if (config.getConfig('cache.url') && context !== OUTSTREAM) { + if (config.getConfig('cache.url') && (useCacheKey || context !== OUTSTREAM)) { if (!bidResponse.videoCacheKey || config.getConfig('cache.ignoreBidderCacheKey')) { addBid = false; callPrebidCache(auctionInstance, bidResponse, afterBidAdded, videoMediaType); @@ -505,59 +583,121 @@ function tryAddVideoBid(auctionInstance, bidResponse, afterBidAdded, {index = au } } -export const callPrebidCache = hook('async', function(auctionInstance, bidResponse, afterBidAdded, videoMediaType) { - store([bidResponse], function (error, cacheIds) { - if (error) { - logWarn(`Failed to save to the video cache: ${error}. Video bid must be discarded.`); +// Native bid response might be in ortb2 format - adds legacy field for backward compatibility +const addLegacyFieldsIfNeeded = (bidResponse) => { + const nativeOrtbRequest = auctionManager.index.getAdUnit(bidResponse)?.nativeOrtbRequest; + const nativeOrtbResponse = bidResponse.native?.ortb - doCallbacksIfTimedout(auctionInstance, bidResponse); - } else { - if (cacheIds[0].uuid === '') { - logWarn(`Supplied video cache key was already in use by Prebid Cache; caching attempt was rejected. Video bid must be discarded.`); + if (nativeOrtbRequest && nativeOrtbResponse) { + const legacyResponse = toLegacyResponse(nativeOrtbResponse, nativeOrtbRequest); + Object.assign(bidResponse.native, legacyResponse); + } +} - doCallbacksIfTimedout(auctionInstance, bidResponse); +const _storeInCache = (batch) => { + store(batch.map(entry => entry.bidResponse), function (error, cacheIds) { + cacheIds.forEach((cacheId, i) => { + const { auctionInstance, bidResponse, afterBidAdded } = batch[i]; + if (error) { + logWarn(`Failed to save to the video cache: ${error}. Video bid must be discarded.`); } else { - bidResponse.videoCacheKey = cacheIds[0].uuid; - - if (!bidResponse.vastUrl) { - bidResponse.vastUrl = getCacheUrl(bidResponse.videoCacheKey); + if (cacheId.uuid === '') { + logWarn(`Supplied video cache key was already in use by Prebid Cache; caching attempt was rejected. Video bid must be discarded.`); + } else { + bidResponse.videoCacheKey = cacheId.uuid; + if (!bidResponse.vastUrl) { + bidResponse.vastUrl = getCacheUrl(bidResponse.videoCacheKey); + } + addBidToAuction(auctionInstance, bidResponse); + afterBidAdded(); } - addBidToAuction(auctionInstance, bidResponse); - afterBidAdded(); } - } + }); }); +}; + +const storeInCache = FEATURES.VIDEO ? _storeInCache : () => {}; + +let batchSize, batchTimeout; +config.getConfig('cache', (cacheConfig) => { + batchSize = typeof cacheConfig.cache.batchSize === 'number' && cacheConfig.cache.batchSize > 0 + ? cacheConfig.cache.batchSize + : 1; + batchTimeout = typeof cacheConfig.cache.batchTimeout === 'number' && cacheConfig.cache.batchTimeout > 0 + ? cacheConfig.cache.batchTimeout + : 0; +}); + +export const batchingCache = (timeout = setTimeout, cache = storeInCache) => { + let batches = [[]]; + let debouncing = false; + const noTimeout = cb => cb(); + + return function(auctionInstance, bidResponse, afterBidAdded) { + const batchFunc = batchTimeout > 0 ? timeout : noTimeout; + if (batches[batches.length - 1].length >= batchSize) { + batches.push([]); + } + + batches[batches.length - 1].push({auctionInstance, bidResponse, afterBidAdded}); + + if (!debouncing) { + debouncing = true; + batchFunc(() => { + batches.forEach(cache); + batches = [[]]; + debouncing = false; + }, batchTimeout); + } + } +}; + +const batchAndStore = batchingCache(); + +export const callPrebidCache = hook('async', function(auctionInstance, bidResponse, afterBidAdded, videoMediaType) { + batchAndStore(auctionInstance, bidResponse, afterBidAdded); }, 'callPrebidCache'); -// Postprocess the bids so that all the universal properties exist, no matter which bidder they came from. -// This should be called before addBidToAuction(). -function getPreparedBidForAuction({adUnitCode, bid, auctionId}, {index = auctionManager.index} = {}) { - const bidderRequest = index.getBidderRequest(bid); - const start = (bidderRequest && bidderRequest.start) || bid.requestTimestamp; - - let bidObject = Object.assign({}, bid, { - auctionId, - responseTimestamp: timestamp(), - requestTimestamp: start, - cpm: parseFloat(bid.cpm) || 0, - bidder: bid.bidderCode, +/** + * Augment `bidResponse` with properties that are common across all bids - including rejected bids. + * + */ +function addCommonResponseProperties(bidResponse, adUnitCode, {index = auctionManager.index} = {}) { + const bidderRequest = index.getBidderRequest(bidResponse); + const adUnit = index.getAdUnit(bidResponse); + const start = (bidderRequest && bidderRequest.start) || bidResponse.requestTimestamp; + + Object.assign(bidResponse, { + responseTimestamp: bidResponse.responseTimestamp || timestamp(), + requestTimestamp: bidResponse.requestTimestamp || start, + cpm: parseFloat(bidResponse.cpm) || 0, + bidder: bidResponse.bidder || bidResponse.bidderCode, adUnitCode }); - bidObject.timeToRespond = bidObject.responseTimestamp - bidObject.requestTimestamp; + if (adUnit?.ttlBuffer != null) { + bidResponse.ttlBuffer = adUnit.ttlBuffer; + } + + bidResponse.timeToRespond = bidResponse.responseTimestamp - bidResponse.requestTimestamp; +} +/** + * Add additional bid response properties that are universal for all _accepted_ bids. + */ +function getPreparedBidForAuction(bid, {index = auctionManager.index} = {}) { // Let listeners know that now is the time to adjust the bid, if they want to. // // CAREFUL: Publishers rely on certain bid properties to be available (like cpm), // but others to not be set yet (like priceStrings). See #1372 and #1389. - events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, bidObject); + events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, bid); // a publisher-defined renderer can be used to render bids - const adUnitRenderer = index.getAdUnit(bidObject).renderer; + const bidRenderer = index.getBidRequest(bid)?.renderer || index.getAdUnit(bid).renderer; // a publisher can also define a renderer for a mediaType - const bidObjectMediaType = bidObject.mediaType; - const mediaTypes = index.getMediaTypes(bidObject) + const bidObjectMediaType = bid.mediaType; + const mediaTypes = index.getMediaTypes(bid); const bidMediaType = mediaTypes && mediaTypes[bidObjectMediaType]; var mediaTypeRenderer = bidMediaType && bidMediaType.renderer; @@ -567,31 +707,31 @@ function getPreparedBidForAuction({adUnitCode, bid, auctionId}, {index = auction // the renderer for the mediaType takes precendence if (mediaTypeRenderer && mediaTypeRenderer.url && mediaTypeRenderer.render && !(mediaTypeRenderer.backupOnly === true && bid.renderer)) { renderer = mediaTypeRenderer; - } else if (adUnitRenderer && adUnitRenderer.url && adUnitRenderer.render && !(adUnitRenderer.backupOnly === true && bid.renderer)) { - renderer = adUnitRenderer; + } else if (bidRenderer && bidRenderer.url && bidRenderer.render && !(bidRenderer.backupOnly === true && bid.renderer)) { + renderer = bidRenderer; } if (renderer) { // be aware, an adapter could already have installed the bidder, in which case this overwrite's the existing adapter - bidObject.renderer = Renderer.install({ url: renderer.url, config: renderer.options });// rename options to config, to make it consistent? - bidObject.renderer.setRender(renderer.render); + bid.renderer = Renderer.install({ url: renderer.url, config: renderer.options });// rename options to config, to make it consistent? + bid.renderer.setRender(renderer.render); } // Use the config value 'mediaTypeGranularity' if it has been defined for mediaType, else use 'customPriceBucket' const mediaTypeGranularity = getMediaTypeGranularity(bid.mediaType, mediaTypes, config.getConfig('mediaTypePriceGranularity')); const priceStringsObj = getPriceBucketString( - bidObject.cpm, + bid.cpm, (typeof mediaTypeGranularity === 'object') ? mediaTypeGranularity : config.getConfig('customPriceBucket'), config.getConfig('currency.granularityMultiplier') ); - bidObject.pbLg = priceStringsObj.low; - bidObject.pbMg = priceStringsObj.med; - bidObject.pbHg = priceStringsObj.high; - bidObject.pbAg = priceStringsObj.auto; - bidObject.pbDg = priceStringsObj.dense; - bidObject.pbCg = priceStringsObj.custom; - - return bidObject; + bid.pbLg = priceStringsObj.low; + bid.pbMg = priceStringsObj.med; + bid.pbHg = priceStringsObj.high; + bid.pbAg = priceStringsObj.auto; + bid.pbDg = priceStringsObj.dense; + bid.pbCg = priceStringsObj.custom; + + return bid; } function setupBidTargeting(bidObject) { @@ -613,7 +753,7 @@ function setupBidTargeting(bidObject) { */ export function getMediaTypeGranularity(mediaType, mediaTypes, mediaTypePriceGranularity) { if (mediaType && mediaTypePriceGranularity) { - if (mediaType === VIDEO) { + if (FEATURES.VIDEO && mediaType === VIDEO) { const context = deepAccess(mediaTypes, `${VIDEO}.context`, 'instream'); if (mediaTypePriceGranularity[`${VIDEO}-${context}`]) { return mediaTypePriceGranularity[`${VIDEO}-${context}`]; @@ -660,13 +800,43 @@ export const getPriceByGranularity = (granularity) => { } } +/** + * This function returns a function to get crid from bid response + * @returns {function} + */ +export const getCreativeId = () => { + return (bid) => { + return (bid.creativeId) ? bid.creativeId : ''; + } +} + /** * This function returns a function to get first advertiser domain from bid response meta * @returns {function} */ export const getAdvertiserDomain = () => { return (bid) => { - return (bid.meta && bid.meta.advertiserDomains && bid.meta.advertiserDomains.length > 0) ? bid.meta.advertiserDomains[0] : ''; + return (bid.meta && bid.meta.advertiserDomains && bid.meta.advertiserDomains.length > 0) ? [bid.meta.advertiserDomains].flat()[0] : ''; + } +} + +/** + * This function returns a function to get dsp name or id from bid response meta + * @returns {function} + */ +export const getDSP = () => { + return (bid) => { + return (bid.meta && (bid.meta.networkId || bid.meta.networkName)) ? deepAccess(bid, 'meta.networkName') || deepAccess(bid, 'meta.networkId') : ''; + } +} + +/** + * This function returns a function to get the primary category id from bid response meta + * @returns {function} + */ +export const getPrimaryCatId = () => { + return (bid) => { + return (bid.meta && bid.meta.primaryCatId) ? bid.meta.primaryCatId : ''; } } @@ -695,6 +865,9 @@ function defaultAdserverTargeting() { createKeyVal(TARGETING_KEYS.SOURCE, 'source'), createKeyVal(TARGETING_KEYS.FORMAT, 'mediaType'), createKeyVal(TARGETING_KEYS.ADOMAIN, getAdvertiserDomain()), + createKeyVal(TARGETING_KEYS.ACAT, getPrimaryCatId()), + createKeyVal(TARGETING_KEYS.DSP, getDSP()), + createKeyVal(TARGETING_KEYS.CRID, getCreativeId()), ] } @@ -707,12 +880,11 @@ function defaultAdserverTargeting() { export function getStandardBidderSettings(mediaType, bidderCode) { const TARGETING_KEYS = CONSTANTS.TARGETING_KEYS; const standardSettings = Object.assign({}, bidderSettings.settingsFor(null)); - if (!standardSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]) { standardSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING] = defaultAdserverTargeting(); } - if (mediaType === 'video') { + if (FEATURES.VIDEO && mediaType === 'video') { const adserverTargeting = standardSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING].slice(); standardSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING] = adserverTargeting; @@ -735,6 +907,7 @@ export function getStandardBidderSettings(mediaType, bidderCode) { } } } + return standardSettings; } @@ -757,7 +930,7 @@ export function getKeyValueTargetingPairs(bidderCode, custBidObj, {index = aucti } // set native key value targeting - if (custBidObj['native']) { + if (FEATURES.NATIVE && custBidObj['native']) { keyValues = Object.assign({}, keyValues, getNativeTargeting(custBidObj)); } @@ -768,7 +941,7 @@ function setKeys(keyValues, bidderSettings, custBidObj, bidReq) { var targeting = bidderSettings[CONSTANTS.JSON_MAPPING.ADSERVER_TARGETING]; custBidObj.size = custBidObj.getSize(); - _each(targeting, function (kvPair) { + (targeting || []).forEach(function (kvPair) { var key = kvPair.key; var value = kvPair.val; @@ -786,7 +959,7 @@ function setKeys(keyValues, bidderSettings, custBidObj, bidReq) { if ( ((typeof bidderSettings.suppressEmptyKeys !== 'undefined' && bidderSettings.suppressEmptyKeys === true) || - key === CONSTANTS.TARGETING_KEYS.DEAL) && // hb_deal is suppressed automatically if not set + key === CONSTANTS.TARGETING_KEYS.DEAL || key === CONSTANTS.TARGETING_KEYS.ACAT || key === CONSTANTS.TARGETING_KEYS.DSP || key === CONSTANTS.TARGETING_KEYS.CRID) && // hb_deal & hb_acat are suppressed automatically if not set ( isEmptyStr(value) || value === null || @@ -803,17 +976,7 @@ function setKeys(keyValues, bidderSettings, custBidObj, bidReq) { } export function adjustBids(bid) { - let code = bid.bidderCode; - let bidPriceAdjusted = bid.cpm; - const bidCpmAdjustment = bidderSettings.get(code || null, 'bidCpmAdjustment'); - - if (bidCpmAdjustment && typeof bidCpmAdjustment === 'function') { - try { - bidPriceAdjusted = bidCpmAdjustment(bid.cpm, Object.assign({}, bid)); - } catch (e) { - logError('Error during bid adjustment', 'bidmanager.js', e); - } - } + let bidPriceAdjusted = adjustCpm(bid.cpm, bid); if (bidPriceAdjusted >= 0) { bid.cpm = bidPriceAdjusted; @@ -831,30 +994,3 @@ function groupByPlacement(bidsByPlacement, bid) { bidsByPlacement[bid.adUnitCode].bids.push(bid); return bidsByPlacement; } - -/** - * Returns a list of bids that we haven't received a response yet where the bidder did not call done - * @param {BidRequest[]} bidderRequests List of bids requested for auction instance - * @param {Set} timelyBidders Set of bidders which responded in time - * - * @typedef {Object} TimedOutBid - * @property {string} bidId The id representing the bid - * @property {string} bidder The string name of the bidder - * @property {string} adUnitCode The code used to uniquely identify the ad unit on the publisher's page - * @property {string} auctionId The id representing the auction - * - * @return {Array} List of bids that Prebid hasn't received a response for - */ -function getTimedOutBids(bidderRequests, timelyBidders) { - const timedOutBids = bidderRequests - .map(bid => (bid.bids || []).filter(bid => !timelyBidders.has(bid.bidder))) - .reduce(flatten, []) - .map(bid => ({ - bidId: bid.bidId, - bidder: bid.bidder, - adUnitCode: bid.adUnitCode, - auctionId: bid.auctionId, - })); - - return timedOutBids; -} diff --git a/src/auctionManager.js b/src/auctionManager.js index 31f82bb0a89..498c200ba21 100644 --- a/src/auctionManager.js +++ b/src/auctionManager.js @@ -19,12 +19,16 @@ * @property {function(): void} clearAllAuctions - clear all auctions for testing */ -import { uniques, flatten, logWarn } from './utils.js'; +import { uniques, logWarn } from './utils.js'; import { newAuction, getStandardBidderSettings, AUCTION_COMPLETED } from './auction.js'; -import {find} from './polyfill.js'; import {AuctionIndex} from './auctionIndex.js'; +import CONSTANTS from './constants.json'; +import {useMetrics} from './utils/perfMetrics.js'; +import {ttlCollection} from './utils/ttlCollection.js'; +import {getTTL, onTTLBufferChange} from './bidTTL.js'; +import {config} from './config.js'; -const CONSTANTS = require('./constants.json'); +const CACHE_TTL_SETTING = 'minBidCacheTTL'; /** * Creates new instance of auctionManager. There will only be one instance of auctionManager but @@ -33,11 +37,42 @@ const CONSTANTS = require('./constants.json'); * @returns {AuctionManager} auctionManagerInstance */ export function newAuctionManager() { - const _auctions = []; + let minCacheTTL = null; + + const _auctions = ttlCollection({ + startTime: (au) => au.end.then(() => au.getAuctionEnd()), + ttl: (au) => minCacheTTL == null ? null : au.end.then(() => { + return Math.max(minCacheTTL, ...au.getBidsReceived().map(getTTL)) * 1000 + }), + }); + + onTTLBufferChange(() => { + if (minCacheTTL != null) _auctions.refresh(); + }) + + config.getConfig(CACHE_TTL_SETTING, (cfg) => { + const prev = minCacheTTL; + minCacheTTL = cfg?.[CACHE_TTL_SETTING]; + minCacheTTL = typeof minCacheTTL === 'number' ? minCacheTTL : null; + if (prev !== minCacheTTL) { + _auctions.refresh(); + } + }) + const auctionManager = {}; + function getAuction(auctionId) { + for (const auction of _auctions) { + if (auction.getAuctionId() === auctionId) return auction; + } + } + auctionManager.addWinningBid = function(bid) { - const auction = find(_auctions, auction => auction.getAuctionId() === bid.auctionId); + const metrics = useMetrics(bid.metrics); + metrics.checkpoint('bidWon'); + metrics.timeBetween('auctionEnd', 'bidWon', 'render.pending'); + metrics.timeBetween('requestBids', 'bidWon', 'render.e2e'); + const auction = getAuction(bid.auctionId); if (auction) { bid.status = CONSTANTS.BID_STATUS.RENDERED; auction.addWinningBid(bid); @@ -46,56 +81,53 @@ export function newAuctionManager() { } }; - auctionManager.getAllWinningBids = function() { - return _auctions.map(auction => auction.getWinningBids()) - .reduce(flatten, []); - }; - - auctionManager.getBidsRequested = function() { - return _auctions.map(auction => auction.getBidRequests()) - .reduce(flatten, []); - }; - - auctionManager.getNoBids = function() { - return _auctions.map(auction => auction.getNoBids()) - .reduce(flatten, []); - }; - - auctionManager.getBidsReceived = function() { - return _auctions.map((auction) => { - if (auction.getAuctionStatus() === AUCTION_COMPLETED) { - return auction.getBidsReceived(); + Object.entries({ + getAllWinningBids: { + name: 'getWinningBids', + }, + getBidsRequested: { + name: 'getBidRequests' + }, + getNoBids: {}, + getAdUnits: {}, + getBidsReceived: { + pre(auction) { + return auction.getAuctionStatus() === AUCTION_COMPLETED; } - }).reduce(flatten, []) - .filter(bid => bid); - }; + }, + getAdUnitCodes: { + post: uniques, + } + }).forEach(([mgrMethod, {name = mgrMethod, pre, post}]) => { + const mapper = pre == null + ? (auction) => auction[name]() + : (auction) => pre(auction) ? auction[name]() : []; + const filter = post == null + ? (items) => items + : (items) => items.filter(post) + auctionManager[mgrMethod] = () => { + return filter(_auctions.toArray().flatMap(mapper)); + } + }) + + function allBidsReceived() { + return _auctions.toArray().flatMap(au => au.getBidsReceived()) + } auctionManager.getAllBidsForAdUnitCode = function(adUnitCode) { - return _auctions.map((auction) => { - return auction.getBidsReceived(); - }).reduce(flatten, []) + return allBidsReceived() .filter(bid => bid && bid.adUnitCode === adUnitCode) }; - auctionManager.getAdUnits = function() { - return _auctions.map(auction => auction.getAdUnits()) - .reduce(flatten, []); - }; - - auctionManager.getAdUnitCodes = function() { - return _auctions.map(auction => auction.getAdUnitCodes()) - .reduce(flatten, []) - .filter(uniques); - }; - - auctionManager.createAuction = function({ adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId }) { - const auction = newAuction({ adUnits, adUnitCodes, callback, cbTimeout, labels, auctionId }); + auctionManager.createAuction = function(opts) { + const auction = newAuction(opts); _addAuction(auction); return auction; }; auctionManager.findBidByAdId = function(adId) { - return find(_auctions.map(auction => auction.getBidsReceived()).reduce(flatten, []), bid => bid.adId === adId); + return allBidsReceived() + .find(bid => bid.adId === adId); }; auctionManager.getStandardBidderAdServerTargeting = function() { @@ -107,24 +139,25 @@ export function newAuctionManager() { if (bid) bid.status = status; if (bid && status === CONSTANTS.BID_STATUS.BID_TARGETING_SET) { - const auction = find(_auctions, auction => auction.getAuctionId() === bid.auctionId); + const auction = getAuction(bid.auctionId); if (auction) auction.setBidTargeting(bid); } } auctionManager.getLastAuctionId = function() { - return _auctions.length && _auctions[_auctions.length - 1].getAuctionId() + const auctions = _auctions.toArray(); + return auctions.length && auctions[auctions.length - 1].getAuctionId() }; auctionManager.clearAllAuctions = function() { - _auctions.length = 0; + _auctions.clear(); } function _addAuction(auction) { - _auctions.push(auction); + _auctions.add(auction); } - auctionManager.index = new AuctionIndex(() => _auctions); + auctionManager.index = new AuctionIndex(() => _auctions.toArray()); return auctionManager; } diff --git a/src/bidTTL.js b/src/bidTTL.js new file mode 100644 index 00000000000..55ba0c026b0 --- /dev/null +++ b/src/bidTTL.js @@ -0,0 +1,25 @@ +import {config} from './config.js'; +import {logError} from './utils.js'; +let TTL_BUFFER = 1; + +const listeners = []; + +config.getConfig('ttlBuffer', (cfg) => { + if (typeof cfg.ttlBuffer === 'number') { + const prev = TTL_BUFFER; + TTL_BUFFER = cfg.ttlBuffer; + if (prev !== TTL_BUFFER) { + listeners.forEach(l => l(TTL_BUFFER)) + } + } else { + logError('Invalid value for ttlBuffer', cfg.ttlBuffer); + } +}) + +export function getTTL(bid) { + return bid.ttl - (bid.hasOwnProperty('ttlBuffer') ? bid.ttlBuffer : TTL_BUFFER); +} + +export function onTTLBufferChange(listener) { + listeners.push(listener); +} diff --git a/src/bidderSettings.js b/src/bidderSettings.js index 343d35a89d2..b39bf480511 100644 --- a/src/bidderSettings.js +++ b/src/bidderSettings.js @@ -1,7 +1,6 @@ import {deepAccess, mergeDeep} from './utils.js'; import {getGlobal} from './prebidGlobal.js'; - -const CONSTANTS = require('./constants.json'); +import CONSTANTS from './constants.json'; export class ScopedSettings { constructor(getSettings, defaultScope) { diff --git a/src/bidfactory.js b/src/bidfactory.js index 95d69cf0adb..4c2e4cf3ffb 100644 --- a/src/bidfactory.js +++ b/src/bidfactory.js @@ -59,7 +59,7 @@ function Bid(statusCode, {src = 'client', bidder = '', bidId, transactionId, auc transactionId: this.transactionId, auctionId: this.auctionId } - } + }; } // Bid factory function. diff --git a/src/config.js b/src/config.js index 3fadebd9d07..d4dc07989af 100644 --- a/src/config.js +++ b/src/config.js @@ -12,18 +12,25 @@ * @property {(string|Object)} [video-outstream] */ -import { isValidPriceConfig } from './cpmBucketManager.js'; -import {find, includes, arrayFrom as from} from './polyfill.js'; +import {isValidPriceConfig} from './cpmBucketManager.js'; +import {arrayFrom as from, find, includes} from './polyfill.js'; import { - mergeDeep, deepClone, getParameterByName, isPlainObject, logMessage, logWarn, logError, - isArray, isStr, isBoolean, deepAccess, bind + deepAccess, + deepClone, + getParameterByName, + isArray, + isBoolean, + isPlainObject, + isStr, + logError, + logMessage, + logWarn, + mergeDeep } from './utils.js'; - -const CONSTANTS = require('./constants.json'); +import CONSTANTS from './constants.json'; const DEFAULT_DEBUG = getParameterByName(CONSTANTS.DEBUG_MODE).toUpperCase() === 'TRUE'; const DEFAULT_BIDDER_TIMEOUT = 3000; -const DEFAULT_PUBLISHER_DOMAIN = window.location.origin; const DEFAULT_ENABLE_SEND_ALL_BIDS = true; const DEFAULT_DISABLE_AJAX_TIMEOUT = false; const DEFAULT_BID_CACHE = false; @@ -68,158 +75,109 @@ export function newConfig() { function resetConfig() { defaults = {}; - let newConfig = { - // `debug` is equivalent to legacy `pbjs.logging` property - _debug: DEFAULT_DEBUG, - get debug() { - return this._debug; - }, - set debug(val) { - this._debug = val; - }, - // default timeout for all bids - _bidderTimeout: DEFAULT_BIDDER_TIMEOUT, - get bidderTimeout() { - return this._bidderTimeout; - }, - set bidderTimeout(val) { - this._bidderTimeout = val; - }, + function getProp(name) { + return props[name].val; + } - // domain where prebid is running for cross domain iframe communication - _publisherDomain: DEFAULT_PUBLISHER_DOMAIN, - get publisherDomain() { - return this._publisherDomain; - }, - set publisherDomain(val) { - this._publisherDomain = val; - }, + function setProp(name, val) { + props[name].val = val; + } - // calls existing function which may be moved after deprecation - _priceGranularity: GRANULARITY_OPTIONS.MEDIUM, - set priceGranularity(val) { - if (validatePriceGranularity(val)) { - if (typeof val === 'string') { - this._priceGranularity = (hasGranularity(val)) ? val : GRANULARITY_OPTIONS.MEDIUM; - } else if (isPlainObject(val)) { - this._customPriceBucket = val; - this._priceGranularity = GRANULARITY_OPTIONS.CUSTOM; - logMessage('Using custom price granularity'); + const props = { + publisherDomain: { + set(val) { + if (val != null) { + logWarn('publisherDomain is deprecated and has no effect since v7 - use pageUrl instead') } + setProp('publisherDomain', val); } }, - get priceGranularity() { - return this._priceGranularity; - }, - - _customPriceBucket: {}, - get customPriceBucket() { - return this._customPriceBucket; - }, - - /** - * mediaTypePriceGranularity - * @type {MediaTypePriceGranularity} - */ - _mediaTypePriceGranularity: {}, - - get mediaTypePriceGranularity() { - return this._mediaTypePriceGranularity; - }, - set mediaTypePriceGranularity(val) { - this._mediaTypePriceGranularity = Object.keys(val).reduce((aggregate, item) => { - if (validatePriceGranularity(val[item])) { + priceGranularity: { + val: GRANULARITY_OPTIONS.MEDIUM, + set(val) { + if (validatePriceGranularity(val)) { if (typeof val === 'string') { - aggregate[item] = (hasGranularity(val[item])) ? val[item] : this._priceGranularity; + setProp('priceGranularity', (hasGranularity(val)) ? val : GRANULARITY_OPTIONS.MEDIUM); } else if (isPlainObject(val)) { - aggregate[item] = val[item]; - logMessage(`Using custom price granularity for ${item}`); + setProp('customPriceBucket', val); + setProp('priceGranularity', GRANULARITY_OPTIONS.CUSTOM) + logMessage('Using custom price granularity'); } - } else { - logWarn(`Invalid price granularity for media type: ${item}`); } - return aggregate; - }, {}); - }, - - _sendAllBids: DEFAULT_ENABLE_SEND_ALL_BIDS, - get enableSendAllBids() { - return this._sendAllBids; + } }, - set enableSendAllBids(val) { - this._sendAllBids = val; + customPriceBucket: { + val: {}, + set() {} }, - - _useBidCache: DEFAULT_BID_CACHE, - get useBidCache() { - return this._useBidCache; + mediaTypePriceGranularity: { + val: {}, + set(val) { + val != null && setProp('mediaTypePriceGranularity', Object.keys(val).reduce((aggregate, item) => { + if (validatePriceGranularity(val[item])) { + if (typeof val === 'string') { + aggregate[item] = (hasGranularity(val[item])) ? val[item] : getProp('priceGranularity'); + } else if (isPlainObject(val)) { + aggregate[item] = val[item]; + logMessage(`Using custom price granularity for ${item}`); + } + } else { + logWarn(`Invalid price granularity for media type: ${item}`); + } + return aggregate; + }, {})); + } }, - set useBidCache(val) { - this._useBidCache = val; + bidderSequence: { + val: DEFAULT_BIDDER_SEQUENCE, + set(val) { + if (VALID_ORDERS[val]) { + setProp('bidderSequence', val); + } else { + logWarn(`Invalid order: ${val}. Bidder Sequence was not set.`); + } + } }, + auctionOptions: { + val: {}, + set(val) { + if (validateauctionOptions(val)) { + setProp('auctionOptions', val); + } + } + } + } + let newConfig = { + // `debug` is equivalent to legacy `pbjs.logging` property + debug: DEFAULT_DEBUG, + bidderTimeout: DEFAULT_BIDDER_TIMEOUT, + enableSendAllBids: DEFAULT_ENABLE_SEND_ALL_BIDS, + useBidCache: DEFAULT_BID_CACHE, /** * deviceAccess set to false will disable setCookie, getCookie, hasLocalStorage * @type {boolean} */ - _deviceAccess: DEFAULT_DEVICE_ACCESS, - get deviceAccess() { - return this._deviceAccess; - }, - set deviceAccess(val) { - this._deviceAccess = val; - }, - - _bidderSequence: DEFAULT_BIDDER_SEQUENCE, - get bidderSequence() { - return this._bidderSequence; - }, - set bidderSequence(val) { - if (VALID_ORDERS[val]) { - this._bidderSequence = val; - } else { - logWarn(`Invalid order: ${val}. Bidder Sequence was not set.`); - } - }, + deviceAccess: DEFAULT_DEVICE_ACCESS, // timeout buffer to adjust for bidder CDN latency - _timeoutBuffer: DEFAULT_TIMEOUTBUFFER, - get timeoutBuffer() { - return this._timeoutBuffer; - }, - set timeoutBuffer(val) { - this._timeoutBuffer = val; - }, - - _disableAjaxTimeout: DEFAULT_DISABLE_AJAX_TIMEOUT, - get disableAjaxTimeout() { - return this._disableAjaxTimeout; - }, - set disableAjaxTimeout(val) { - this._disableAjaxTimeout = val; - }, + timeoutBuffer: DEFAULT_TIMEOUTBUFFER, + disableAjaxTimeout: DEFAULT_DISABLE_AJAX_TIMEOUT, // default max nested iframes for referer detection - _maxNestedIframes: DEFAULT_MAX_NESTED_IFRAMES, - get maxNestedIframes() { - return this._maxNestedIframes; - }, - set maxNestedIframes(val) { - this._maxNestedIframes = val; - }, - - _auctionOptions: {}, - get auctionOptions() { - return this._auctionOptions; - }, - set auctionOptions(val) { - if (validateauctionOptions(val)) { - this._auctionOptions = val; - } - }, + maxNestedIframes: DEFAULT_MAX_NESTED_IFRAMES, }; + Object.defineProperties(newConfig, + Object.fromEntries(Object.entries(props) + .map(([k, def]) => [k, Object.assign({ + get: getProp.bind(null, k), + set: setProp.bind(null, k), + enumerable: true, + }, def)])) + ); + if (config) { callSubscribers( Object.keys(config).reduce((memo, topic) => { @@ -314,42 +272,52 @@ export function newConfig() { return Object.assign({}, config); } - /* - * Returns the configuration object if called without parameters, - * or single configuration property if given a string matching a configuration - * property name. Allows deep access e.g. getConfig('currency.adServerCurrency') - * - * If called with callback parameter, or a string and a callback parameter, - * subscribes to configuration updates. See `subscribe` function for usage. - * - * The object returned is a deepClone of the `config` property. - */ - function readConfig(...args) { - if (args.length <= 1 && typeof args[0] !== 'function') { - const option = args[0]; - const configClone = deepClone(_getConfig()); - return option ? deepAccess(configClone, option) : configClone; - } - - return subscribe(...args); + function _getRestrictedConfig() { + // This causes reading 'ortb2' to throw an error; with prebid 7, that will almost + // always be the incorrect way to access FPD configuration (https://github.com/prebid/Prebid.js/issues/7651) + // code that needs the ortb2 config should explicitly use `getAnyConfig` + // TODO: this is meant as a temporary tripwire to catch inadvertent use of `getConfig('ortb')` as we transition. + // It should be removed once the risk of that happening is low enough. + const conf = _getConfig(); + Object.defineProperty(conf, 'ortb2', { + get: function () { + throw new Error('invalid access to \'orbt2\' config - use request parameters instead'); + } + }); + return conf; } - /* - * Returns configuration object if called without parameters, - * or single configuration property if given a string matching a configuration - * property name. Allows deep access e.g. getConfig('currency.adServerCurrency') - * - * If called with callback parameter, or a string and a callback parameter, - * subscribes to configuration updates. See `subscribe` function for usage. - */ - function getConfig(...args) { - if (args.length <= 1 && typeof args[0] !== 'function') { - const option = args[0]; - return option ? deepAccess(_getConfig(), option) : _getConfig(); - } + const [getAnyConfig, getConfig] = [_getConfig, _getRestrictedConfig].map(accessor => { + /* + * Returns configuration object if called without parameters, + * or single configuration property if given a string matching a configuration + * property name. Allows deep access e.g. getConfig('currency.adServerCurrency') + * + * If called with callback parameter, or a string and a callback parameter, + * subscribes to configuration updates. See `subscribe` function for usage. + */ + return function getConfig(...args) { + if (args.length <= 1 && typeof args[0] !== 'function') { + const option = args[0]; + return option ? deepAccess(accessor(), option) : _getConfig(); + } - return subscribe(...args); - } + return subscribe(...args); + } + }) + + const [readConfig, readAnyConfig] = [getConfig, getAnyConfig].map(wrapee => { + /* + * Like getConfig, except that it returns a deepClone of the result. + */ + return function readConfig(...args) { + let res = wrapee(...args); + if (res && typeof res === 'object') { + res = deepClone(res); + } + return res; + } + }) /** * Internal API for modules (such as prebid-server) that might need access to all bidder config @@ -358,119 +326,6 @@ export function newConfig() { return bidderConfig; } - /** - * Returns backwards compatible FPD data for modules - */ - function getLegacyFpd(obj) { - if (typeof obj !== 'object') return; - - let duplicate = {}; - - Object.keys(obj).forEach((type) => { - let prop = (type === 'site') ? 'context' : type; - duplicate[prop] = (prop === 'context' || prop === 'user') ? Object.keys(obj[type]).filter(key => key !== 'data').reduce((result, key) => { - if (key === 'ext') { - mergeDeep(result, obj[type][key]); - } else { - mergeDeep(result, {[key]: obj[type][key]}); - } - - return result; - }, {}) : obj[type]; - }); - - return duplicate; - } - - /** - * Returns backwards compatible FPD data for modules - */ - function getLegacyImpFpd(obj) { - if (typeof obj !== 'object') return; - - let duplicate = {}; - - if (deepAccess(obj, 'ext.data')) { - Object.keys(obj.ext.data).forEach((key) => { - if (key === 'pbadslot') { - mergeDeep(duplicate, {context: {pbAdSlot: obj.ext.data[key]}}); - } else if (key === 'adserver') { - mergeDeep(duplicate, {context: {adServer: obj.ext.data[key]}}); - } else { - mergeDeep(duplicate, {context: {data: {[key]: obj.ext.data[key]}}}); - } - }); - } - - return duplicate; - } - - /** - * Copy FPD over to OpenRTB standard format in config - */ - function convertFpd(opt) { - let duplicate = {}; - - Object.keys(opt).forEach((type) => { - let prop = (type === 'context') ? 'site' : type; - duplicate[prop] = (prop === 'site' || prop === 'user') ? Object.keys(opt[type]).reduce((result, key) => { - if (key === 'data') { - mergeDeep(result, {ext: {data: opt[type][key]}}); - } else { - mergeDeep(result, {[key]: opt[type][key]}); - } - - return result; - }, {}) : opt[type]; - }); - - return duplicate; - } - - /** - * Copy Impression FPD over to OpenRTB standard format in config - * Only accepts bid level context.data values with pbAdSlot and adServer exceptions - */ - function convertImpFpd(opt) { - let duplicate = {}; - - Object.keys(opt).filter(prop => prop === 'context').forEach((type) => { - Object.keys(opt[type]).forEach((key) => { - if (key === 'data') { - mergeDeep(duplicate, {ext: {data: opt[type][key]}}); - } else { - if (typeof opt[type][key] === 'object' && !Array.isArray(opt[type][key])) { - Object.keys(opt[type][key]).forEach(data => { - mergeDeep(duplicate, {ext: {data: {[key.toLowerCase()]: {[data.toLowerCase()]: opt[type][key][data]}}}}); - }); - } else { - mergeDeep(duplicate, {ext: {data: {[key.toLowerCase()]: opt[type][key]}}}); - } - } - }); - }); - - return duplicate; - } - - /** - * Copy FPD over to OpenRTB standard format in each adunit - */ - function convertAdUnitFpd(arr) { - let convert = []; - - arr.forEach((adunit) => { - if (adunit.fpd) { - (adunit['ortb2Imp']) ? mergeDeep(adunit['ortb2Imp'], convertImpFpd(adunit.fpd)) : adunit['ortb2Imp'] = convertImpFpd(adunit.fpd); - convert.push((({ fpd, ...duplicate }) => duplicate)(adunit)); - } else { - convert.push(adunit); - } - }); - - return convert; - } - /* * Sets configuration given an object containing key-value pairs and calls * listeners that were added by the `subscribe` function @@ -485,14 +340,17 @@ export function newConfig() { let topicalConfig = {}; topics.forEach(topic => { - let prop = (topic === 'fpd') ? 'ortb2' : topic; - let option = (topic === 'fpd') ? convertFpd(options[topic]) : options[topic]; + let option = options[topic]; - if (isPlainObject(defaults[prop]) && isPlainObject(option)) { - option = Object.assign({}, defaults[prop], option); + if (isPlainObject(defaults[topic]) && isPlainObject(option)) { + option = Object.assign({}, defaults[topic], option); } - topicalConfig[prop] = config[prop] = option; + try { + topicalConfig[topic] = config[topic] = option; + } catch (e) { + logWarn(`Cannot set config for property ${topic} : `, e) + } }); callSubscribers(topicalConfig); @@ -520,6 +378,8 @@ export function newConfig() { * updates when specific properties are updated by passing a topic string as * the first parameter. * + * If `options.init` is true, the listener will be immediately called with the current options. + * * Returns an `unsubscribe` function for removing the subscriber from the * set of listeners * @@ -533,8 +393,9 @@ export function newConfig() { * // unsubscribe * const unsubscribe = subscribe(...); * unsubscribe(); // no longer listening + * */ - function subscribe(topic, listener) { + function subscribe(topic, listener, options = {}) { let callback = listener; if (typeof topic !== 'string') { @@ -542,6 +403,7 @@ export function newConfig() { // meaning it gets called for any config change callback = topic; topic = ALL_TOPICS; + options = listener || {}; } if (typeof callback !== 'function') { @@ -552,6 +414,15 @@ export function newConfig() { const nl = { topic, callback }; listeners.push(nl); + if (options.init) { + if (topic === ALL_TOPICS) { + callback(getConfig()); + } else { + // eslint-disable-next-line standard/no-callback-literal + callback({[topic]: getConfig(topic)}); + } + } + // save and call this function to remove the listener return function unsubscribe() { listeners.splice(listeners.indexOf(nl), 1); @@ -585,14 +456,13 @@ export function newConfig() { bidderConfig[bidder] = {}; } Object.keys(config.config).forEach(topic => { - let prop = (topic === 'fpd') ? 'ortb2' : topic; - let option = (topic === 'fpd') ? convertFpd(config.config[topic]) : config.config[topic]; + let option = config.config[topic]; if (isPlainObject(option)) { const func = mergeFlag ? mergeDeep : Object.assign; - bidderConfig[bidder][prop] = func({}, bidderConfig[bidder][prop] || {}, option); + bidderConfig[bidder][topic] = func({}, bidderConfig[bidder][topic] || {}, option); } else { - bidderConfig[bidder][prop] = option; + bidderConfig[bidder][topic] = option; } }); }); @@ -619,11 +489,7 @@ export function newConfig() { return; } - const mergedConfig = Object.keys(obj).reduce((accum, key) => { - const prevConf = _getConfig(key)[key] || {}; - accum[key] = mergeDeep(prevConf, obj[key]); - return accum; - }, {}); + const mergedConfig = mergeDeep(_getConfig(), obj); setConfig({ ...mergedConfig }); return mergedConfig; @@ -648,7 +514,7 @@ export function newConfig() { return function(cb) { return function(...args) { if (typeof cb === 'function') { - return runWithBidder(bidder, bind.call(cb, this, ...args)) + return runWithBidder(bidder, cb.bind(this, ...args)) } else { logWarn('config.callbackWithBidder callback is not a function'); } @@ -670,7 +536,9 @@ export function newConfig() { getCurrentBidder, resetBidder, getConfig, + getAnyConfig, readConfig, + readAnyConfig, setConfig, mergeConfig, setDefaults, @@ -680,9 +548,6 @@ export function newConfig() { setBidderConfig, getBidderConfig, mergeBidderConfig, - convertAdUnitFpd, - getLegacyFpd, - getLegacyImpFpd }; } diff --git a/src/consentHandler.js b/src/consentHandler.js index a56d06c8c90..9e3ee5b4c40 100644 --- a/src/consentHandler.js +++ b/src/consentHandler.js @@ -1,28 +1,40 @@ -import {isStr, timestamp} from './utils.js'; +import {cyrb53Hash, isStr, timestamp} from './utils.js'; +import {defer, GreedyPromise} from './utils/promise.js'; +import {config} from './config.js'; + +/** + * Placeholder gvlid for when vendor consent is not required. When this value is used as gvlid, the gdpr + * enforcement module will take it to mean "vendor consent was given". + * + * see https://github.com/prebid/Prebid.js/issues/8161 + */ +export const VENDORLESS_GVLID = Object.freeze({}); export class ConsentHandler { #enabled; #data; - #promise; - #resolve; + #defer; #ready; + #dirty = true; + #hash; generatedTime; + hashFields; constructor() { this.reset(); } + #resolve(data) { + this.#ready = true; + this.#data = data; + this.#defer.resolve(data); + } + /** * reset this handler (mainly for tests) */ reset() { - this.#promise = new Promise((resolve) => { - this.#resolve = (data) => { - this.#ready = true; - this.#data = data; - resolve(data); - }; - }); + this.#defer = defer(); this.#enabled = false; this.#data = null; this.#ready = false; @@ -56,25 +68,34 @@ export class ConsentHandler { */ get promise() { if (this.#ready) { - return Promise.resolve(this.#data); + return GreedyPromise.resolve(this.#data); } if (!this.#enabled) { this.#resolve(null); } - return this.#promise; + return this.#defer.promise; } setConsentData(data, time = timestamp()) { this.generatedTime = time; + this.#dirty = true; this.#resolve(data); } getConsentData() { return this.#data; } + + get hash() { + if (this.#dirty) { + this.#hash = cyrb53Hash(JSON.stringify(this.#data && this.hashFields ? this.hashFields.map(f => this.#data[f]) : this.#data)) + this.#dirty = false; + } + return this.#hash; + } } -export class UspConsentHandler extends ConsentHandler { +class UspConsentHandler extends ConsentHandler { getConsentMeta() { const consentData = this.getConsentData(); if (consentData && this.generatedTime) { @@ -86,7 +107,8 @@ export class UspConsentHandler extends ConsentHandler { } } -export class GdprConsentHandler extends ConsentHandler { +class GdprConsentHandler extends ConsentHandler { + hashFields = ['gdprApplies', 'consentString'] getConsentMeta() { const consentData = this.getConsentData(); if (consentData && consentData.vendorData && this.generatedTime) { @@ -99,3 +121,108 @@ export class GdprConsentHandler extends ConsentHandler { } } } + +class GppConsentHandler extends ConsentHandler { + hashFields = ['applicableSections', 'gppString']; + getConsentMeta() { + const consentData = this.getConsentData(); + if (consentData && this.generatedTime) { + return { + generatedAt: this.generatedTime, + } + } + } +} + +export function gvlidRegistry() { + const registry = {}; + const flat = {}; + const none = {}; + return { + /** + * Register a module's GVL ID. + * @param {string} moduleType defined in `activities/modules.js` + * @param {string} moduleName + * @param {number} gvlid + */ + register(moduleType, moduleName, gvlid) { + if (gvlid) { + (registry[moduleName] = registry[moduleName] || {})[moduleType] = gvlid; + if (flat.hasOwnProperty(moduleName)) { + if (flat[moduleName] !== gvlid) flat[moduleName] = none; + } else { + flat[moduleName] = gvlid; + } + } + }, + /** + * Get a module's GVL ID(s). + * + * @param {string} moduleName + * @return {{modules: {[moduleType]: number}, gvlid?: number}} an object where: + * `modules` is a map from module type to that module's GVL ID; + * `gvlid` is the single GVL ID for this family of modules (only defined + * if all modules with this name declared the same ID). + */ + get(moduleName) { + const result = {modules: registry[moduleName] || {}}; + if (flat.hasOwnProperty(moduleName) && flat[moduleName] !== none) { + result.gvlid = flat[moduleName]; + } + return result; + } + } +} + +export const gdprDataHandler = new GdprConsentHandler(); +export const uspDataHandler = new UspConsentHandler(); +export const gppDataHandler = new GppConsentHandler(); +export const coppaDataHandler = (() => { + function getCoppa() { + return !!(config.getConfig('coppa')) + } + return { + getCoppa, + getConsentData: getCoppa, + getConsentMeta: getCoppa, + reset() {}, + get promise() { + return GreedyPromise.resolve(getCoppa()) + }, + get hash() { + return getCoppa() ? '1' : '0' + } + } +})(); + +export const GDPR_GVLIDS = gvlidRegistry(); + +const ALL_HANDLERS = { + gdpr: gdprDataHandler, + usp: uspDataHandler, + gpp: gppDataHandler, + coppa: coppaDataHandler, +} + +export function multiHandler(handlers = ALL_HANDLERS) { + handlers = Object.entries(handlers); + function collector(method) { + return function () { + return Object.fromEntries(handlers.map(([name, handler]) => [name, handler[method]()])) + } + } + return Object.assign( + { + get promise() { + return GreedyPromise.all(handlers.map(([name, handler]) => handler.promise.then(val => [name, val]))) + .then(entries => Object.fromEntries(entries)); + }, + get hash() { + return cyrb53Hash(handlers.map(([_, handler]) => handler.hash).join(':')); + } + }, + Object.fromEntries(['getConsentData', 'getConsentMeta', 'reset'].map(n => [n, collector(n)])), + ) +} + +export const allConsent = multiHandler(); diff --git a/src/constants.json b/src/constants.json index 94696184e31..c763090f6d0 100644 --- a/src/constants.json +++ b/src/constants.json @@ -11,8 +11,7 @@ }, "DEBUG_MODE": "pbjs_debug", "STATUS": { - "GOOD": 1, - "NO_BID": 2 + "GOOD": 1 }, "CB": { "TYPE": { @@ -29,7 +28,9 @@ "BID_TIMEOUT": "bidTimeout", "BID_REQUESTED": "bidRequested", "BID_RESPONSE": "bidResponse", + "BID_REJECTED": "bidRejected", "NO_BID": "noBid", + "SEAT_NON_BID": "seatNonBid", "BID_WON": "bidWon", "BIDDER_DONE": "bidderDone", "BIDDER_ERROR": "bidderError", @@ -46,7 +47,7 @@ "STALE_RENDER": "staleRender", "BILLABLE_EVENT": "billableEvent" }, - "AD_RENDER_FAILED_REASON" : { + "AD_RENDER_FAILED_REASON": { "PREVENT_WRITING_ON_MAIN_DOCUMENT": "preventWritingOnMainDocument", "NO_AD": "noAd", "EXCEPTION": "exception", @@ -75,7 +76,10 @@ "UUID": "hb_uuid", "CACHE_ID": "hb_cache_id", "CACHE_HOST": "hb_cache_host", - "ADOMAIN" : "hb_adomain" + "ADOMAIN": "hb_adomain", + "ACAT": "hb_acat", + "CRID": "hb_crid", + "DSP": "hb_dsp" }, "DEFAULT_TARGETING_KEYS": { "BIDDER": "hb_bidder", @@ -109,14 +113,68 @@ "rendererUrl": "hb_renderer_url", "adTemplate": "hb_adTemplate" }, - "S2S" : { - "SRC" : "s2s", - "DEFAULT_ENDPOINT" : "https://prebid.adnxs.com/pbs/v1/openrtb2/auction", + "S2S": { + "SRC": "s2s", + "DEFAULT_ENDPOINT": "https://prebid.adnxs.com/pbs/v1/openrtb2/auction", "SYNCED_BIDDERS_KEY": "pbjsSyncs" }, - "BID_STATUS" : { + "BID_STATUS": { "BID_TARGETING_SET": "targetingSet", "RENDERED": "rendered", "BID_REJECTED": "bidRejected" + }, + "REJECTION_REASON": { + "INVALID": "Bid has missing or invalid properties", + "INVALID_REQUEST_ID": "Invalid request ID", + "BIDDER_DISALLOWED": "Bidder code is not allowed by allowedAlternateBidderCodes / allowUnknownBidderCodes", + "FLOOR_NOT_MET": "Bid does not meet price floor", + "CANNOT_CONVERT_CURRENCY": "Unable to convert currency" + }, + "PREBID_NATIVE_DATA_KEYS_TO_ORTB": { + "body": "desc", + "body2": "desc2", + "sponsoredBy": "sponsored", + "cta": "ctatext", + "rating": "rating", + "address": "address", + "downloads": "downloads", + "likes": "likes", + "phone": "phone", + "price": "price", + "salePrice": "saleprice", + "displayUrl": "displayurl" + }, + "NATIVE_ASSET_TYPES": { + "sponsored": 1, + "desc": 2, + "rating": 3, + "likes": 4, + "downloads": 5, + "price": 6, + "saleprice": 7, + "phone": 8, + "address": 9, + "desc2": 10, + "displayurl": 11, + "ctatext": 12 + }, + "NATIVE_IMAGE_TYPES": { + "ICON": 1, + "MAIN": 3 + }, + "NATIVE_KEYS_THAT_ARE_NOT_ASSETS": [ + "privacyIcon", + "clickUrl", + "sendTargetingKeys", + "adTemplate", + "rendererUrl", + "type" + ], + "FLOOR_VALUES": { + "NO_DATA": "noData", + "AD_UNIT": "adUnit", + "SET_CONFIG": "setConfig", + "FETCH": "fetch", + "SUCCESS": "success" } } diff --git a/src/cpmBucketManager.js b/src/cpmBucketManager.js index bd003ddb86d..5bb6675b8e1 100644 --- a/src/cpmBucketManager.js +++ b/src/cpmBucketManager.js @@ -1,5 +1,6 @@ import {find} from './polyfill.js'; -import { isEmpty } from './utils.js'; +import { isEmpty, logWarn } from './utils.js'; +import { config } from './config.js'; const _defaultPrecision = 2; const _lgPriceConfig = { @@ -118,6 +119,11 @@ function getCpmTarget(cpm, bucket, granularityMultiplier) { const precision = typeof bucket.precision !== 'undefined' ? bucket.precision : _defaultPrecision; const increment = bucket.increment * granularityMultiplier; const bucketMin = bucket.min * granularityMultiplier; + let roundingFunction = Math.floor; + let customRoundingFunction = config.getConfig('cpmRoundingFunction'); + if (typeof customRoundingFunction === 'function') { + roundingFunction = customRoundingFunction; + } // start increments at the bucket min and then add bucket min back to arrive at the correct rounding // note - we're padding the values to avoid using decimals in the math prior to flooring @@ -125,10 +131,23 @@ function getCpmTarget(cpm, bucket, granularityMultiplier) { // (eg 4.01 / 0.01 = 400.99999999999994) // min precison should be 2 to move decimal place over. let pow = Math.pow(10, precision + 2); - let cpmToFloor = ((cpm * pow) - (bucketMin * pow)) / (increment * pow); - let cpmTarget = ((Math.floor(cpmToFloor)) * increment) + bucketMin; + let cpmToRound = ((cpm * pow) - (bucketMin * pow)) / (increment * pow); + let cpmTarget; + let invalidRounding; + // It is likely that we will be passed {cpmRoundingFunction: roundingFunction()} + // rather than the expected {cpmRoundingFunction: roundingFunction}. Default back to floor in that case + try { + cpmTarget = (roundingFunction(cpmToRound) * increment) + bucketMin; + } catch (err) { + invalidRounding = true; + } + if (invalidRounding || typeof cpmTarget !== 'number') { + logWarn('Invalid rounding function passed in config'); + cpmTarget = (Math.floor(cpmToRound) * increment) + bucketMin; + } // force to 10 decimal places to deal with imprecise decimal/binary conversions // (for example 0.1 * 3 = 0.30000000000000004) + cpmTarget = Number(cpmTarget.toFixed(10)); return cpmTarget.toFixed(precision); } diff --git a/src/debugging.js b/src/debugging.js index 810cf4b432a..f5d13d1a134 100644 --- a/src/debugging.js +++ b/src/debugging.js @@ -1,165 +1,94 @@ import {config} from './config.js'; -import {addBidderRequests, addBidResponse} from './auction.js'; -import {hook} from './hook.js'; -import {prefixLog} from './utils.js'; +import {getHook, hook} from './hook.js'; +import {getGlobal} from './prebidGlobal.js'; +import {logMessage, prefixLog} from './utils.js'; +import {createBid} from './bidfactory.js'; +import {loadExternalScript} from './adloader.js'; +import {GreedyPromise} from './utils/promise.js'; -const {logWarn, logMessage} = prefixLog('DEBUG:'); +export const DEBUG_KEY = '__$$PREBID_GLOBAL$$_debugging__'; -const OVERRIDE_KEY = '$$PREBID_GLOBAL$$:debugging'; - -export let addBidResponseBound; -export let addBidderRequestsBound; - -export const onEnableOverrides = [ - (overrides) => { - removeHooks(); - addHooks(overrides); - } -]; -export const onDisableOverrides = [ - removeHooks -]; - -function addHooks(overrides) { - addBidResponseBound = addBidResponseHook.bind(overrides); - addBidResponse.before(addBidResponseBound, 5); - - addBidderRequestsBound = addBidderRequestsHook.bind(overrides); - addBidderRequests.before(addBidderRequestsBound, 5); +function isDebuggingInstalled() { + return getGlobal().installedModules.includes('debugging'); } -function removeHooks() { - addBidResponse.getHooks({hook: addBidResponseBound}).remove(); - addBidderRequests.getHooks({hook: addBidderRequestsBound}).remove(); -} - -export function enableOverrides(overrides, fromSession = false) { - config.setConfig({'debug': true}); - onEnableOverrides.forEach((fn) => fn(overrides)); - logMessage(`bidder overrides enabled${fromSession ? ' from session' : ''}`); +function loadScript(url) { + return new GreedyPromise((resolve) => { + loadExternalScript(url, 'debugging', resolve); + }); } -export function disableOverrides() { - onDisableOverrides.forEach((fn) => fn()); - logMessage('bidder overrides disabled'); +export function debuggingModuleLoader({alreadyInstalled = isDebuggingInstalled, script = loadScript} = {}) { + let loading = null; + return function () { + if (loading == null) { + loading = new GreedyPromise((resolve, reject) => { + // run this in a 0-delay timeout to give installedModules time to be populated + setTimeout(() => { + if (alreadyInstalled()) { + resolve(); + } else { + const url = '$$PREBID_DIST_URL_BASE$$debugging-standalone.js'; + logMessage(`Debugging module not installed, loading it from "${url}"...`); + getGlobal()._installDebugging = true; + script(url).then(() => { + getGlobal()._installDebugging({DEBUG_KEY, hook, config, createBid, logger: prefixLog('DEBUG:')}); + }).then(resolve, reject); + } + }); + }) + } + return loading; + } } -/** - * @param {{bidder:string, adUnitCode:string}} overrideObj - * @param {string} bidderCode - * @param {string} adUnitCode - * @returns {boolean} - */ -export function bidExcluded(overrideObj, bidderCode, adUnitCode) { - if (overrideObj.bidder && overrideObj.bidder !== bidderCode) { - return true; +export function debuggingControls({load = debuggingModuleLoader(), hook = getHook('requestBids')} = {}) { + let promise = null; + let enabled = false; + function waitForDebugging(next, ...args) { + return (promise || GreedyPromise.resolve()).then(() => next.apply(this, args)) } - if (overrideObj.adUnitCode && overrideObj.adUnitCode !== adUnitCode) { - return true; + function enable() { + if (!enabled) { + promise = load(); + // set debugging to high priority so that it has the opportunity to mess with most things + hook.before(waitForDebugging, 99); + enabled = true; + } } - return false; -} - -/** - * @param {string[]} bidders - * @param {string} bidderCode - * @returns {boolean} - */ -export function bidderExcluded(bidders, bidderCode) { - return (Array.isArray(bidders) && bidders.indexOf(bidderCode) === -1); -} - -/** - * @param {Object} overrideObj - * @param {Object} bidObj - * @param {Object} bidType - * @returns {Object} bidObj with overridden properties - */ -export function applyBidOverrides(overrideObj, bidObj, bidType) { - return Object.keys(overrideObj).filter(key => (['adUnitCode', 'bidder'].indexOf(key) === -1)).reduce(function(result, key) { - logMessage(`bidder overrides changed '${result.adUnitCode}/${result.bidderCode}' ${bidType}.${key} from '${result[key]}.js' to '${overrideObj[key]}'`); - result[key] = overrideObj[key]; - result.isDebug = true; - return result; - }, bidObj); -} - -export function addBidResponseHook(next, adUnitCode, bid) { - const overrides = this; - - if (bidderExcluded(overrides.bidders, bid.bidderCode)) { - logWarn(`bidder '${bid.bidderCode}' excluded from auction by bidder overrides`); - return; + function disable() { + hook.getHooks({hook: waitForDebugging}).remove(); + enabled = false; } - - if (Array.isArray(overrides.bids)) { - overrides.bids.forEach(function(overrideBid) { - if (!bidExcluded(overrideBid, bid.bidderCode, adUnitCode)) { - applyBidOverrides(overrideBid, bid, 'bidder'); - } - }); + function reset() { + promise = null; + disable(); } - - next(adUnitCode, bid); + return {enable, disable, reset}; } -export function addBidderRequestsHook(next, bidderRequests) { - const overrides = this; +const ctl = debuggingControls(); +export const reset = ctl.reset; - const includedBidderRequests = bidderRequests.filter(function (bidderRequest) { - if (bidderExcluded(overrides.bidders, bidderRequest.bidderCode)) { - logWarn(`bidRequest '${bidderRequest.bidderCode}' excluded from auction by bidder overrides`); - return false; - } - return true; - }); - - if (Array.isArray(overrides.bidRequests)) { - includedBidderRequests.forEach(function(bidderRequest) { - overrides.bidRequests.forEach(function(overrideBid) { - bidderRequest.bids.forEach(function(bid) { - if (!bidExcluded(overrideBid, bidderRequest.bidderCode, bid.adUnitCode)) { - applyBidOverrides(overrideBid, bid, 'bidRequest'); - } - }); - }); - }); - } - - next(includedBidderRequests); -} +export function loadSession() { + let storage = null; + try { + storage = window.sessionStorage; + } catch (e) {} -export const saveDebuggingConfig = hook('sync', function (debugConfig, {sessionStorage = window.sessionStorage} = {}) { - if (!debugConfig.enabled) { - try { - sessionStorage.removeItem(OVERRIDE_KEY); - } catch (e) {} - } else { + if (storage !== null) { + let debugging = ctl; + let config = null; try { - sessionStorage.setItem(OVERRIDE_KEY, JSON.stringify(debugConfig)); + config = storage.getItem(DEBUG_KEY); } catch (e) {} - } -}); - -export function getConfig(debugging, {sessionStorage = window.sessionStorage} = {}) { - saveDebuggingConfig(debugging, {sessionStorage}); - if (!debugging.enabled) { - disableOverrides(); - } else { - enableOverrides(debugging); + if (config !== null) { + // just make sure the module runs; it will take care of parsing the config (and disabling itself if necessary) + debugging.enable(); + } } } -config.getConfig('debugging', ({debugging}) => getConfig(debugging)); - -export function sessionLoader(storage) { - let overrides; - try { - storage = storage || window.sessionStorage; - overrides = JSON.parse(storage.getItem(OVERRIDE_KEY)); - } catch (e) { - } - if (overrides) { - enableOverrides(overrides, true); - } -} +config.getConfig('debugging', function ({debugging}) { + debugging?.enabled ? ctl.enable() : ctl.disable(); +}); diff --git a/src/events.js b/src/events.js index 148e7b3a2f1..7a1e25e0e49 100644 --- a/src/events.js +++ b/src/events.js @@ -1,24 +1,40 @@ /** * events.js */ -var utils = require('./utils.js'); -var CONSTANTS = require('./constants.json'); -var slice = Array.prototype.slice; -var push = Array.prototype.push; +import * as utils from './utils.js' +import CONSTANTS from './constants.json'; +import {ttlCollection} from './utils/ttlCollection.js'; +import {config} from './config.js'; +const TTL_CONFIG = 'eventHistoryTTL'; -// define entire events -// var allEvents = ['bidRequested','bidResponse','bidWon','bidTimeout']; -var allEvents = utils._map(CONSTANTS.EVENTS, function (v) { - return v; +let eventTTL = null; + +// keep a record of all events fired +const eventsFired = ttlCollection({ + monotonic: true, + ttl: () => eventTTL, +}) + +config.getConfig(TTL_CONFIG, (val) => { + const previous = eventTTL; + val = val?.[TTL_CONFIG]; + eventTTL = typeof val === 'number' ? val * 1000 : null; + if (previous !== eventTTL) { + eventsFired.refresh(); + } }); -var idPaths = CONSTANTS.EVENT_ID_PATHS; +let slice = Array.prototype.slice; +let push = Array.prototype.push; + +// define entire events +let allEvents = Object.values(CONSTANTS.EVENTS); + +const idPaths = CONSTANTS.EVENT_ID_PATHS; -// keep a record of all events fired -var eventsFired = []; const _public = (function () { - var _handlers = {}; - var _public = {}; + let _handlers = {}; + let _public = {}; /** * @@ -29,18 +45,16 @@ const _public = (function () { function _dispatch(eventString, args) { utils.logMessage('Emitting event for: ' + eventString); - var eventPayload = args[0] || {}; - var idPath = idPaths[eventString]; - var key = eventPayload[idPath]; - var event = _handlers[eventString] || { que: [] }; - var eventKeys = utils._map(event, function (v, k) { - return k; - }); + let eventPayload = args[0] || {}; + let idPath = idPaths[eventString]; + let key = eventPayload[idPath]; + let event = _handlers[eventString] || { que: [] }; + var eventKeys = Object.keys(event); - var callbacks = []; + let callbacks = []; // record the event: - eventsFired.push({ + eventsFired.add({ eventType: eventString, args: eventPayload, id: key, @@ -53,7 +67,7 @@ const _public = (function () { * each function in the `que` array as an argument to push to the * `callbacks` array * */ - if (key && utils.contains(eventKeys, key)) { + if (key && eventKeys.includes(key)) { push.apply(callbacks, event[key].que); } @@ -61,7 +75,7 @@ const _public = (function () { push.apply(callbacks, event.que); /** call each of the callbacks */ - utils._each(callbacks, function (fn) { + (callbacks || []).forEach(function (fn) { if (!fn) return; try { fn.apply(null, args); @@ -72,13 +86,13 @@ const _public = (function () { } function _checkAvailableEvent(event) { - return utils.contains(allEvents, event); + return allEvents.includes(event) } _public.on = function (eventString, handler, id) { // check whether available event or not if (_checkAvailableEvent(eventString)) { - var event = _handlers[eventString] || { que: [] }; + let event = _handlers[eventString] || { que: [] }; if (id) { event[id] = event[id] || { que: [] }; @@ -94,12 +108,12 @@ const _public = (function () { }; _public.emit = function (event) { - var args = slice.call(arguments, 1); + let args = slice.call(arguments, 1); _dispatch(event, args); }; _public.off = function (eventString, handler, id) { - var event = _handlers[eventString]; + let event = _handlers[eventString]; if (utils.isEmpty(event) || (utils.isEmpty(event.que) && utils.isEmpty(event[id]))) { return; @@ -110,15 +124,15 @@ const _public = (function () { } if (id) { - utils._each(event[id].que, function (_handler) { - var que = event[id].que; + (event[id].que || []).forEach(function (_handler) { + let que = event[id].que; if (_handler === handler) { que.splice(que.indexOf(_handler), 1); } }); } else { - utils._each(event.que, function (_handler) { - var que = event.que; + (event.que || []).forEach(function (_handler) { + let que = event.que; if (_handler === handler) { que.splice(que.indexOf(_handler), 1); } @@ -132,21 +146,25 @@ const _public = (function () { return _handlers; }; + _public.addEvents = function (events) { + allEvents = allEvents.concat(events); + } + /** * This method can return a copy of all the events fired * @return {Array} array of events fired */ _public.getEvents = function () { - var arrayCopy = []; - utils._each(eventsFired, function (value) { - var newProp = Object.assign({}, value); - arrayCopy.push(newProp); - }); - - return arrayCopy; + return eventsFired.toArray().map(val => Object.assign({}, val)) }; return _public; }()); -export const {on, off, get, getEvents, emit} = _public; +utils._setEventEmitter(_public.emit.bind(_public)); + +export const {on, off, get, getEvents, emit, addEvents} = _public; + +export function clearEvents() { + eventsFired.clear(); +} diff --git a/src/fpd/enrichment.js b/src/fpd/enrichment.js new file mode 100644 index 00000000000..f812d8435d9 --- /dev/null +++ b/src/fpd/enrichment.js @@ -0,0 +1,131 @@ +import {hook} from '../hook.js'; +import {getRefererInfo, parseDomain} from '../refererDetection.js'; +import {findRootDomain} from './rootDomain.js'; +import {deepSetValue, getDefinedParams, getDNT, getWindowSelf, getWindowTop, mergeDeep} from '../utils.js'; +import {config} from '../config.js'; +import {getHighEntropySUA, getLowEntropySUA} from './sua.js'; +import {GreedyPromise} from '../utils/promise.js'; +import {CLIENT_SECTIONS, clientSectionChecker, hasSection} from './oneClient.js'; + +export const dep = { + getRefererInfo, + findRootDomain, + getWindowTop, + getWindowSelf, + getHighEntropySUA, + getLowEntropySUA, +}; + +const oneClient = clientSectionChecker('FPD') + +/** + * Enrich an ortb2 object with first party data. + * @param {Promise[{}]} fpd: a promise to an ortb2 object. + * @returns: {Promise[{}]}: a promise to an enriched ortb2 object. + */ +export const enrichFPD = hook('sync', (fpd) => { + return GreedyPromise.all([fpd, getSUA().catch(() => null)]) + .then(([ortb2, sua]) => { + const ri = dep.getRefererInfo(); + mergeLegacySetConfigs(ortb2); + Object.entries(ENRICHMENTS).forEach(([section, getEnrichments]) => { + const data = getEnrichments(ortb2, ri); + if (data && Object.keys(data).length > 0) { + ortb2[section] = mergeDeep({}, data, ortb2[section]); + } + }); + if (sua) { + deepSetValue(ortb2, 'device.sua', Object.assign({}, sua, ortb2.device.sua)); + } + ortb2 = oneClient(ortb2); + for (let section of CLIENT_SECTIONS) { + if (hasSection(ortb2, section)) { + ortb2[section] = mergeDeep({}, clientEnrichment(ortb2, ri), ortb2[section]); + break; + } + } + return ortb2; + }); +}); + +function mergeLegacySetConfigs(ortb2) { + // merge in values from "legacy" setConfig({app, site, device}) + // TODO: deprecate these eventually + ['app', 'site', 'device'].forEach(prop => { + const cfg = config.getConfig(prop); + if (cfg != null) { + ortb2[prop] = mergeDeep({}, cfg, ortb2[prop]); + } + }) +} + +function winFallback(fn) { + try { + return fn(dep.getWindowTop()); + } catch (e) { + return fn(dep.getWindowSelf()); + } +} + +function getSUA() { + const hints = config.getConfig('firstPartyData.uaHints'); + return !Array.isArray(hints) || hints.length === 0 + ? GreedyPromise.resolve(dep.getLowEntropySUA()) + : dep.getHighEntropySUA(hints); +} + +function removeUndef(obj) { + return getDefinedParams(obj, Object.keys(obj)) +} + +const ENRICHMENTS = { + site(ortb2, ri) { + if (CLIENT_SECTIONS.filter(p => p !== 'site').some(hasSection.bind(null, ortb2))) { + // do not enrich site if dooh or app are set + return; + } + return removeUndef({ + page: ri.page, + ref: ri.ref, + }); + }, + device() { + return winFallback((win) => { + const w = win.innerWidth || win.document.documentElement.clientWidth || win.document.body.clientWidth; + const h = win.innerHeight || win.document.documentElement.clientHeight || win.document.body.clientHeight; + return { + w, + h, + dnt: getDNT() ? 1 : 0, + ua: win.navigator.userAgent, + language: win.navigator.language.split('-').shift(), + }; + }) + }, + regs() { + const regs = {}; + if (winFallback((win) => win.navigator.globalPrivacyControl)) { + deepSetValue(regs, 'ext.gpc', 1); + } + const coppa = config.getConfig('coppa'); + if (typeof coppa === 'boolean') { + regs.coppa = coppa ? 1 : 0; + } + return regs; + } +}; + +// Enrichment of properties common across dooh, app and site - will be dropped into whatever +// section is appropriate +function clientEnrichment(ortb2, ri) { + const domain = parseDomain(ri.page, {noLeadingWww: true}); + const keywords = winFallback((win) => win.document.querySelector('meta[name=\'keywords\']')) + ?.content?.replace?.(/\s/g, ''); + return removeUndef({ + domain, + keywords, + publisher: removeUndef({ + domain: dep.findRootDomain(domain) + }) + }) +} diff --git a/src/fpd/oneClient.js b/src/fpd/oneClient.js new file mode 100644 index 00000000000..67f53c73bd8 --- /dev/null +++ b/src/fpd/oneClient.js @@ -0,0 +1,26 @@ +import {logWarn} from '../utils.js'; + +// mutually exclusive ORTB sections in order of priority - 'dooh' beats 'app' & 'site' and 'app' beats 'site'; +// if one is set, the others will be removed +export const CLIENT_SECTIONS = ['dooh', 'app', 'site'] + +export function clientSectionChecker(logPrefix) { + return function onlyOneClientSection(ortb2) { + CLIENT_SECTIONS.reduce((found, section) => { + if (hasSection(ortb2, section)) { + if (found != null) { + logWarn(`${logPrefix} specifies both '${found}' and '${section}'; dropping the latter.`) + delete ortb2[section]; + } else { + found = section; + } + } + return found; + }, null); + return ortb2; + } +} + +export function hasSection(ortb2, section) { + return ortb2[section] != null && Object.keys(ortb2[section]).length > 0 +} diff --git a/src/fpd/rootDomain.js b/src/fpd/rootDomain.js new file mode 100644 index 00000000000..21547de8e2e --- /dev/null +++ b/src/fpd/rootDomain.js @@ -0,0 +1,57 @@ +import {memoize, timestamp} from '../utils.js'; +import {getCoreStorageManager} from '../storageManager.js'; + +export const coreStorage = getCoreStorageManager('fpdEnrichment'); + +/** + * Find the root domain by testing for the topmost domain that will allow setting cookies. + */ + +export const findRootDomain = memoize(function findRootDomain(fullDomain = window.location.host) { + if (!coreStorage.cookiesAreEnabled()) { + return fullDomain; + } + + const domainParts = fullDomain.split('.'); + if (domainParts.length === 2) { + return fullDomain; + } + let rootDomain; + let continueSearching; + let startIndex = -2; + const TEST_COOKIE_NAME = `_rdc${Date.now()}`; + const TEST_COOKIE_VALUE = 'writeable'; + do { + rootDomain = domainParts.slice(startIndex).join('.'); + let expirationDate = new Date(timestamp() + 10 * 1000).toUTCString(); + + // Write a test cookie + coreStorage.setCookie( + TEST_COOKIE_NAME, + TEST_COOKIE_VALUE, + expirationDate, + 'Lax', + rootDomain, + undefined + ); + + // See if the write was successful + const value = coreStorage.getCookie(TEST_COOKIE_NAME, undefined); + if (value === TEST_COOKIE_VALUE) { + continueSearching = false; + // Delete our test cookie + coreStorage.setCookie( + TEST_COOKIE_NAME, + '', + 'Thu, 01 Jan 1970 00:00:01 GMT', + undefined, + rootDomain, + undefined + ); + } else { + startIndex += -1; + continueSearching = Math.abs(startIndex) <= domainParts.length; + } + } while (continueSearching); + return rootDomain; +}); diff --git a/src/fpd/sua.js b/src/fpd/sua.js new file mode 100644 index 00000000000..565c3e1fd52 --- /dev/null +++ b/src/fpd/sua.js @@ -0,0 +1,104 @@ +import {isEmptyStr, isStr, isEmpty} from '../utils.js'; +import {GreedyPromise} from '../utils/promise.js'; + +export const SUA_SOURCE_UNKNOWN = 0; +export const SUA_SOURCE_LOW_ENTROPY = 1; +export const SUA_SOURCE_HIGH_ENTROPY = 2; +export const SUA_SOURCE_UA_HEADER = 3; + +// "high entropy" (i.e. privacy-sensitive) fields that can be requested from the navigator. +export const HIGH_ENTROPY_HINTS = [ + 'architecture', + 'bitness', + 'model', + 'platformVersion', + 'fullVersionList' +] + +export const LOW_ENTROPY_HINTS = [ + 'brands', + 'mobile', + 'platform' +] + +/** + * Returns low entropy UA client hints encoded as an ortb2.6 device.sua object; or null if no UA client hints are available. + */ +export const getLowEntropySUA = lowEntropySUAAccessor(); + +/** + * Returns a promise to high entropy UA client hints encoded as an ortb2.6 device.sua object, or null if no UA client hints are available. + * + * Note that the return value is a promise because the underlying browser API returns a promise; this + * seems to plan for additional controls (such as alerts / permission request prompts to the user); it's unclear + * at the moment if this means that asking for more hints would result in slower / more expensive calls. + * + * @param {Array[String]} hints hints to request, defaults to all (HIGH_ENTROPY_HINTS). + */ +export const getHighEntropySUA = highEntropySUAAccessor(); + +export function lowEntropySUAAccessor(uaData = window.navigator?.userAgentData) { + const sua = (uaData && LOW_ENTROPY_HINTS.some(h => typeof uaData[h] !== 'undefined')) ? Object.freeze(uaDataToSUA(SUA_SOURCE_LOW_ENTROPY, uaData)) : null; + return function () { + return sua; + } +} + +export function highEntropySUAAccessor(uaData = window.navigator?.userAgentData) { + const cache = {}; + const keys = new WeakMap(); + return function (hints = HIGH_ENTROPY_HINTS) { + if (!keys.has(hints)) { + const sorted = Array.from(hints); + sorted.sort(); + keys.set(hints, sorted.join('|')); + } + const key = keys.get(hints); + if (!cache.hasOwnProperty(key)) { + try { + cache[key] = uaData.getHighEntropyValues(hints).then(result => { + return isEmpty(result) ? null : Object.freeze(uaDataToSUA(SUA_SOURCE_HIGH_ENTROPY, result)) + }).catch(() => null); + } catch (e) { + cache[key] = GreedyPromise.resolve(null); + } + } + return cache[key]; + } +} + +/** + * Convert a User Agent client hints object to an ORTB 2.6 device.sua fragment + * https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf + * + * @param source source of the UAData object (0 to 3) + * @param uaData https://developer.mozilla.org/en-US/docs/Web/API/NavigatorUAData/ + * @return {{}} + */ +export function uaDataToSUA(source, uaData) { + function toBrandVersion(brand, version) { + const bv = {brand}; + if (isStr(version) && !isEmptyStr(version)) { + bv.version = version.split('.'); + } + return bv; + } + + const sua = {source}; + if (uaData.platform) { + sua.platform = toBrandVersion(uaData.platform, uaData.platformVersion); + } + if (uaData.fullVersionList || uaData.brands) { + sua.browsers = (uaData.fullVersionList || uaData.brands).map(({brand, version}) => toBrandVersion(brand, version)); + } + if (typeof uaData['mobile'] !== 'undefined') { + sua.mobile = uaData.mobile ? 1 : 0; + } + ['model', 'bitness', 'architecture'].forEach(prop => { + const value = uaData[prop]; + if (isStr(value)) { + sua[prop] = value; + } + }) + return sua; +} diff --git a/src/hook.js b/src/hook.js index 2c8e4c7a6e7..3f01114935d 100644 --- a/src/hook.js +++ b/src/hook.js @@ -1,10 +1,28 @@ - import funHooks from 'fun-hooks/no-eval/index.js'; +import {defer} from './utils/promise.js'; export let hook = funHooks({ ready: funHooks.SYNC | funHooks.ASYNC | funHooks.QUEUE }); +const readyCtl = defer(); +hook.ready = (() => { + const ready = hook.ready; + return function () { + try { + return ready.apply(hook, arguments); + } finally { + readyCtl.resolve(); + } + } +})(); + +/** + * A promise that resolves when hooks are ready. + * @type {Promise} + */ +export const ready = readyCtl.promise; + export const getHook = hook.get; export function setupBeforeHookFnOnce(baseFn, hookFn, priority = 15) { @@ -30,3 +48,14 @@ export function submodule(name, ...args) { next(modules); }); } + +/** + * Copy hook methods (.before, .after, etc) from a given hook to a given wrapper object. + */ +export function wrapHook(hook, wrapper) { + Object.defineProperties( + wrapper, + Object.fromEntries(['before', 'after', 'getHooks', 'removeAll'].map((m) => [m, {get: () => hook[m]}])) + ); + return wrapper; +} diff --git a/src/native.js b/src/native.js index ba5e3a62901..c4709dd77e2 100644 --- a/src/native.js +++ b/src/native.js @@ -1,8 +1,20 @@ -import { deepAccess, getKeyByValue, insertHtmlIntoIframe, logError, triggerPixel } from './utils.js'; +import { + deepAccess, + deepClone, + insertHtmlIntoIframe, + isArray, + isBoolean, + isInteger, + isNumber, + isPlainObject, + logError, + pick, + triggerPixel +} from './utils.js'; import {includes} from './polyfill.js'; import {auctionManager} from './auctionManager.js'; - -const CONSTANTS = require('./constants.json'); +import CONSTANTS from './constants.json'; +import {NATIVE} from './mediaTypes.js'; export const nativeAdapters = []; @@ -10,7 +22,51 @@ export const NATIVE_TARGETING_KEYS = Object.keys(CONSTANTS.NATIVE_KEYS).map( key => CONSTANTS.NATIVE_KEYS[key] ); -const IMAGE = { +export const IMAGE = { + ortb: { + ver: '1.2', + assets: [ + { + required: 1, + id: 1, + img: { + type: 3, + wmin: 100, + hmin: 100, + } + }, + { + required: 1, + id: 2, + title: { + len: 140, + } + }, + { + required: 1, + id: 3, + data: { + type: 1, + } + }, + { + required: 0, + id: 4, + data: { + type: 2, + } + }, + { + required: 0, + id: 5, + img: { + type: 1, + wmin: 20, + hmin: 20, + } + }, + ], + }, image: { required: true }, title: { required: true }, sponsoredBy: { required: true }, @@ -23,6 +79,26 @@ const SUPPORTED_TYPES = { image: IMAGE }; +const { NATIVE_ASSET_TYPES, NATIVE_IMAGE_TYPES, PREBID_NATIVE_DATA_KEYS_TO_ORTB, NATIVE_KEYS_THAT_ARE_NOT_ASSETS, NATIVE_KEYS } = CONSTANTS; + +// inverse native maps useful for converting to legacy +const PREBID_NATIVE_DATA_KEYS_TO_ORTB_INVERSE = inverse(PREBID_NATIVE_DATA_KEYS_TO_ORTB); +const NATIVE_ASSET_TYPES_INVERSE = inverse(NATIVE_ASSET_TYPES); + +const TRACKER_METHODS = { + img: 1, + js: 2, + 1: 'img', + 2: 'js' +} + +const TRACKER_EVENTS = { + impression: 1, + 'viewable-mrc50': 2, + 'viewable-mrc100': 3, + 'viewable-video50': 4, +} + /** * Recieves nativeParams from an adUnit. If the params were not of type 'type', * passes them on directly. If they were of type 'type', translate @@ -30,9 +106,12 @@ const SUPPORTED_TYPES = { */ export function processNativeAdUnitParams(params) { if (params && params.type && typeIsSupported(params.type)) { - return SUPPORTED_TYPES[params.type]; + params = SUPPORTED_TYPES[params.type]; } + if (params && params.ortb && !isOpenRTBBidRequestValid(params.ortb)) { + return; + } return params; } @@ -43,8 +122,66 @@ export function decorateAdUnitsWithNativeParams(adUnits) { if (nativeParams) { adUnit.nativeParams = processNativeAdUnitParams(nativeParams); } + if (adUnit.nativeParams) { + adUnit.nativeOrtbRequest = adUnit.nativeParams.ortb || toOrtbNativeRequest(adUnit.nativeParams); + } }); } +export function isOpenRTBBidRequestValid(ortb) { + const assets = ortb.assets; + if (!Array.isArray(assets) || assets.length === 0) { + logError(`assets in mediaTypes.native.ortb is not an array, or it's empty. Assets: `, assets); + return false; + } + + // validate that ids exist, that they are unique and that they are numbers + const ids = assets.map(asset => asset.id); + if (assets.length !== new Set(ids).size || ids.some(id => id !== parseInt(id, 10))) { + logError(`each asset object must have 'id' property, it must be unique and it must be an integer`); + return false; + } + + if (ortb.hasOwnProperty('eventtrackers') && !Array.isArray(ortb.eventtrackers)) { + logError('ortb.eventtrackers is not an array. Eventtrackers: ', ortb.eventtrackers); + return false; + } + + return assets.every(asset => isOpenRTBAssetValid(asset)) +} + +function isOpenRTBAssetValid(asset) { + if (!isPlainObject(asset)) { + logError(`asset must be an object. Provided asset: `, asset); + return false; + } + if (asset.img) { + if (!isNumber(asset.img.w) && !isNumber(asset.img.wmin)) { + logError(`for img asset there must be 'w' or 'wmin' property`); + return false; + } + if (!isNumber(asset.img.h) && !isNumber(asset.img.hmin)) { + logError(`for img asset there must be 'h' or 'hmin' property`); + return false; + } + } else if (asset.title) { + if (!isNumber(asset.title.len)) { + logError(`for title asset there must be 'len' property defined`); + return false; + } + } else if (asset.data) { + if (!isNumber(asset.data.type)) { + logError(`for data asset 'type' property must be a number`); + return false; + } + } else if (asset.video) { + if (!Array.isArray(asset.video.mimes) || !Array.isArray(asset.video.protocols) || + !isNumber(asset.video.minduration) || !isNumber(asset.video.maxduration)) { + logError('video asset is not properly configured'); + return false; + } + } + return true; +} /** * Check if the native type specified in the adUnit is supported by Prebid. @@ -80,24 +217,28 @@ export const hasNonNativeBidder = adUnit => * @return {Boolean} If object is valid */ export function nativeBidIsValid(bid, {index = auctionManager.index} = {}) { - // all native bid responses must define a landing page url - if (!deepAccess(bid, 'native.clickUrl')) { + const adUnit = index.getAdUnit(bid); + if (!adUnit) { return false; } + let ortbRequest = adUnit.nativeOrtbRequest + let ortbResponse = bid.native?.ortb || toOrtbNativeResponse(bid.native, ortbRequest); + return isNativeOpenRTBBidValid(ortbResponse, ortbRequest); +} + +export function isNativeOpenRTBBidValid(bidORTB, bidRequestORTB) { + if (!deepAccess(bidORTB, 'link.url')) { + logError(`native response doesn't have 'link' property. Ortb response: `, bidORTB); return false; } - const requestedAssets = index.getAdUnit(bid).nativeParams; - if (!requestedAssets) { - return true; - } + let requiredAssetIds = bidRequestORTB.assets.filter(asset => asset.required === 1).map(a => a.id); + let returnedAssetIds = bidORTB.assets.map(asset => asset.id); - const requiredAssets = Object.keys(requestedAssets).filter( - key => requestedAssets[key].required - ); - const returnedAssets = Object.keys(bid['native']).filter( - key => bid['native'][key] - ); + const match = requiredAssetIds.every(assetId => includes(returnedAssetIds, assetId)); + if (!match) { + logError(`didn't receive a bid with all required assets. Required ids: ${requiredAssetIds}, but received ids in response: ${returnedAssetIds}`); + } - return requiredAssets.every(asset => includes(returnedAssets, asset)); + return match; } /* @@ -126,20 +267,64 @@ export function nativeBidIsValid(bid, {index = auctionManager.index} = {}) { * fireTrackers(); // fires impressions when creative is loaded * */ -export function fireNativeTrackers(message, adObject) { - let trackers; +export function fireNativeTrackers(message, bidResponse) { + const nativeResponse = bidResponse.native.ortb || legacyPropertiesToOrtbNative(bidResponse.native); + if (message.action === 'click') { - trackers = adObject['native'] && adObject['native'].clickTrackers; + fireClickTrackers(nativeResponse, message?.assetId); } else { - trackers = adObject['native'] && adObject['native'].impressionTrackers; + fireImpressionTrackers(nativeResponse); + } + return message.action; +} + +export function fireImpressionTrackers(nativeResponse, {runMarkup = (mkup) => insertHtmlIntoIframe(mkup), fetchURL = triggerPixel} = {}) { + const impTrackers = (nativeResponse.eventtrackers || []) + .filter(tracker => tracker.event === TRACKER_EVENTS.impression); - if (adObject['native'] && adObject['native'].javascriptTrackers) { - insertHtmlIntoIframe(adObject['native'].javascriptTrackers); + let {img, js} = impTrackers.reduce((tally, tracker) => { + if (TRACKER_METHODS.hasOwnProperty(tracker.method)) { + tally[TRACKER_METHODS[tracker.method]].push(tracker.url) } + return tally; + }, {img: [], js: []}); + + if (nativeResponse.imptrackers) { + img = img.concat(nativeResponse.imptrackers); } + img.forEach(url => fetchURL(url)); - (trackers || []).forEach(triggerPixel); - return message.action; + js = js.map(url => ``); + if (nativeResponse.jstracker) { + // jstracker is already HTML markup + js = js.concat([nativeResponse.jstracker]); + } + if (js.length) { + runMarkup(js.join('\n')); + } +} + +export function fireClickTrackers(nativeResponse, assetId = null, {fetchURL = triggerPixel} = {}) { + // legacy click tracker + if (!assetId) { + (nativeResponse.link?.clicktrackers || []).forEach(url => fetchURL(url)); + } else { + // ortb click tracker. This will try to call the clicktracker associated with the asset; + // will fallback to the link if none is found. + const assetIdLinkMap = (nativeResponse.assets || []) + .filter(a => a.link) + .reduce((map, asset) => { + map[asset.id] = asset.link; + return map + }, {}); + const masterClickTrackers = nativeResponse.link?.clicktrackers || []; + let assetLink = assetIdLinkMap[assetId]; + let clickTrackers = masterClickTrackers; + if (assetLink) { + clickTrackers = assetLink.clicktrackers || []; + } + clickTrackers.forEach(url => fetchURL(url)); + } } /** @@ -184,7 +369,7 @@ export function getNativeTargeting(bid, {index = auctionManager.index} = {}) { value = placeholder; } - let assetSendTargetingKeys = deepAccess(adUnit, `nativeParams.${asset}.sendTargetingKeys`) + let assetSendTargetingKeys = deepAccess(adUnit, `nativeParams.${asset}.sendTargetingKeys`); if (typeof assetSendTargetingKeys !== 'boolean') { assetSendTargetingKeys = deepAccess(adUnit, `nativeParams.ext.${asset}.sendTargetingKeys`); } @@ -199,72 +384,64 @@ export function getNativeTargeting(bid, {index = auctionManager.index} = {}) { return keyValues; } -/** - * Constructs a message object containing asset values for each of the - * requested data keys. - */ -export function getAssetMessage(data, adObject) { +function assetsMessage(data, adObject, keys, {index = auctionManager.index} = {}) { const message = { message: 'assetResponse', adId: data.adId, - assets: [], }; - if (adObject.native.hasOwnProperty('adTemplate')) { - message.adTemplate = getAssetValue(adObject.native['adTemplate']); - } if (adObject.native.hasOwnProperty('rendererUrl')) { - message.rendererUrl = getAssetValue(adObject.native['rendererUrl']); - } - - data.assets.forEach(asset => { - const key = getKeyByValue(CONSTANTS.NATIVE_KEYS, asset); - const value = getAssetValue(adObject.native[key]); - - message.assets.push({ key, value }); - }); + const adUnit = index.getAdUnit(adObject); + let nativeResp = adObject.native; - return message; -} - -export function getAllAssetsMessage(data, adObject) { - const message = { - message: 'assetResponse', - adId: data.adId, - assets: [] - }; + if (adObject.native.ortb) { + message.ortb = adObject.native.ortb; + } else if (adUnit.mediaTypes?.native?.ortb) { + message.ortb = toOrtbNativeResponse(adObject.native, adUnit.nativeOrtbRequest); + } + message.assets = []; - Object.keys(adObject.native).forEach(function(key, index) { - if (key === 'adTemplate' && adObject.native[key]) { - message.adTemplate = getAssetValue(adObject.native[key]); - } else if (key === 'rendererUrl' && adObject.native[key]) { - message.rendererUrl = getAssetValue(adObject.native[key]); + (keys == null ? Object.keys(nativeResp) : keys).forEach(function(key) { + if (key === 'adTemplate' && nativeResp[key]) { + message.adTemplate = getAssetValue(nativeResp[key]); + } else if (key === 'rendererUrl' && nativeResp[key]) { + message.rendererUrl = getAssetValue(nativeResp[key]); } else if (key === 'ext') { - Object.keys(adObject.native[key]).forEach(extKey => { - if (adObject.native[key][extKey]) { - const value = getAssetValue(adObject.native[key][extKey]); + Object.keys(nativeResp[key]).forEach(extKey => { + if (nativeResp[key][extKey]) { + const value = getAssetValue(nativeResp[key][extKey]); message.assets.push({ key: extKey, value }); } }) - } else if (adObject.native[key] && CONSTANTS.NATIVE_KEYS.hasOwnProperty(key)) { - const value = getAssetValue(adObject.native[key]); + } else if (nativeResp[key] && CONSTANTS.NATIVE_KEYS.hasOwnProperty(key)) { + const value = getAssetValue(nativeResp[key]); message.assets.push({ key, value }); } }); - return message; } +const NATIVE_KEYS_INVERTED = Object.fromEntries(Object.entries(CONSTANTS.NATIVE_KEYS).map(([k, v]) => [v, k])); + +/** + * Constructs a message object containing asset values for each of the + * requested data keys. + */ +export function getAssetMessage(data, adObject) { + const keys = data.assets.map((k) => NATIVE_KEYS_INVERTED[k]); + return assetsMessage(data, adObject, keys); +} + +export function getAllAssetsMessage(data, adObject) { + return assetsMessage(data, adObject, null); +} + /** * Native assets can be a string or an object with a url prop. Returns the value * appropriate for sending in adserver targeting or placeholder replacement. */ function getAssetValue(value) { - if (typeof value === 'object' && value.url) { - return value.url; - } - - return value; + return value?.url || value; } function getNativeKeys(adUnit) { @@ -281,3 +458,368 @@ function getNativeKeys(adUnit) { ...extraNativeKeys } } + +/** + * converts Prebid legacy native assets request to OpenRTB format + * @param {object} legacyNativeAssets an object that describes a native bid request in Prebid proprietary format + * @returns an OpenRTB format of the same bid request + */ +export function toOrtbNativeRequest(legacyNativeAssets) { + if (!legacyNativeAssets && !isPlainObject(legacyNativeAssets)) { + logError('Native assets object is empty or not an object: ', legacyNativeAssets); + return; + } + const ortb = { + ver: '1.2', + assets: [] + }; + for (let key in legacyNativeAssets) { + // skip conversion for non-asset keys + if (NATIVE_KEYS_THAT_ARE_NOT_ASSETS.includes(key)) continue; + if (!NATIVE_KEYS.hasOwnProperty(key)) { + logError(`Unrecognized native asset code: ${key}. Asset will be ignored.`); + continue; + } + + if (key === 'privacyLink') { + ortb.privacy = 1; + continue; + } + + const asset = legacyNativeAssets[key]; + let required = 0; + if (asset.required && isBoolean(asset.required)) { + required = Number(asset.required); + } + const ortbAsset = { + id: ortb.assets.length, + required + }; + // data cases + if (key in PREBID_NATIVE_DATA_KEYS_TO_ORTB) { + ortbAsset.data = { + type: NATIVE_ASSET_TYPES[PREBID_NATIVE_DATA_KEYS_TO_ORTB[key]] + } + if (asset.len) { + ortbAsset.data.len = asset.len; + } + // icon or image case + } else if (key === 'icon' || key === 'image') { + ortbAsset.img = { + type: key === 'icon' ? NATIVE_IMAGE_TYPES.ICON : NATIVE_IMAGE_TYPES.MAIN, + } + // if min_width and min_height are defined in aspect_ratio, they are preferred + if (asset.aspect_ratios) { + if (!isArray(asset.aspect_ratios)) { + logError("image.aspect_ratios was passed, but it's not a an array:", asset.aspect_ratios); + } else if (!asset.aspect_ratios.length) { + logError("image.aspect_ratios was passed, but it's empty:", asset.aspect_ratios); + } else { + const { min_width: minWidth, min_height: minHeight } = asset.aspect_ratios[0]; + if (!isInteger(minWidth) || !isInteger(minHeight)) { + logError('image.aspect_ratios min_width or min_height are invalid: ', minWidth, minHeight); + } else { + ortbAsset.img.wmin = minWidth; + ortbAsset.img.hmin = minHeight; + } + const aspectRatios = asset.aspect_ratios + .filter((ar) => ar.ratio_width && ar.ratio_height) + .map(ratio => `${ratio.ratio_width}:${ratio.ratio_height}`); + if (aspectRatios.length > 0) { + ortbAsset.img.ext = { + aspectratios: aspectRatios + } + } + } + } + + // if asset.sizes exist, by OpenRTB spec we should remove wmin and hmin + if (asset.sizes) { + if (asset.sizes.length !== 2 || !isInteger(asset.sizes[0]) || !isInteger(asset.sizes[1])) { + logError('image.sizes was passed, but its value is not an array of integers:', asset.sizes); + } else { + ortbAsset.img.w = asset.sizes[0]; + ortbAsset.img.h = asset.sizes[1]; + delete ortbAsset.img.hmin; + delete ortbAsset.img.wmin; + } + } + // title case + } else if (key === 'title') { + ortbAsset.title = { + // in openRTB, len is required for titles, while in legacy prebid was not. + // for this reason, if len is missing in legacy prebid, we're adding a default value of 140. + len: asset.len || 140 + } + // all extensions to the native bid request are passed as is + } else if (key === 'ext') { + ortbAsset.ext = asset; + // in `ext` case, required field is not needed + delete ortbAsset.required; + } + ortb.assets.push(ortbAsset); + } + return ortb; +} + +/** + * Greatest common divisor between two positive integers + * https://en.wikipedia.org/wiki/Euclidean_algorithm + */ +function gcd(a, b) { + while (a && b && a !== b) { + if (a > b) { + a = a - b; + } else { + b = b - a; + } + } + return a || b; +} + +/** + * This function converts an OpenRTB native request object to Prebid proprietary + * format. The purpose of this function is to help adapters to handle the + * transition phase where publishers may be using OpenRTB objects but the + * bidder does not yet support it. + * @param {object} openRTBRequest an OpenRTB v1.2 request object + * @returns a Prebid legacy native format request + */ +export function fromOrtbNativeRequest(openRTBRequest) { + if (!isOpenRTBBidRequestValid(openRTBRequest)) { + return; + } + + const oldNativeObject = {}; + for (const asset of openRTBRequest.assets) { + if (asset.title) { + const title = { + required: asset.required ? Boolean(asset.required) : false, + len: asset.title.len + } + oldNativeObject.title = title; + } else if (asset.img) { + const image = { + required: asset.required ? Boolean(asset.required) : false, + } + if (asset.img.w && asset.img.h) { + image.sizes = [asset.img.w, asset.img.h]; + } else if (asset.img.wmin && asset.img.hmin) { + const scale = gcd(asset.img.wmin, asset.img.hmin) + image.aspect_ratios = [{ + min_width: asset.img.wmin, + min_height: asset.img.hmin, + ratio_width: asset.img.wmin / scale, + ratio_height: asset.img.hmin / scale + }] + } + + if (asset.img.type === NATIVE_IMAGE_TYPES.MAIN) { + oldNativeObject.image = image; + } else { + oldNativeObject.icon = image; + } + } else if (asset.data) { + let assetType = Object.keys(NATIVE_ASSET_TYPES).find(k => NATIVE_ASSET_TYPES[k] === asset.data.type); + let prebidAssetName = Object.keys(PREBID_NATIVE_DATA_KEYS_TO_ORTB).find(k => PREBID_NATIVE_DATA_KEYS_TO_ORTB[k] === assetType); + oldNativeObject[prebidAssetName] = { + required: asset.required ? Boolean(asset.required) : false, + } + if (asset.data.len) { + oldNativeObject[prebidAssetName].len = asset.data.len; + } + } + if (openRTBRequest.privacy) { + oldNativeObject.privacyLink = { required: false }; + } + // video was not supported by old prebid assets + } + return oldNativeObject; +} + +/** + * Converts an OpenRTB request to a proprietary Prebid.js format. + * The proprietary Prebid format has many limitations and will be dropped in + * the future; adapters are encouraged to stop using it in favour of OpenRTB format. + * IMPLEMENTATION DETAILS: This function returns the same exact object if no + * conversion is needed. If a conversion is needed (meaning, at least one + * bidRequest contains a native.ortb definition), it will return a copy. + * + * @param {BidRequest[]} bidRequests an array of valid bid requests + * @returns an array of valid bid requests where the openRTB bids are converted to proprietary format. + */ +export function convertOrtbRequestToProprietaryNative(bidRequests) { + if (FEATURES.NATIVE) { + if (!bidRequests || !isArray(bidRequests)) return bidRequests; + // check if a conversion is needed + if (!bidRequests.some(bidRequest => (bidRequest?.mediaTypes || {})[NATIVE]?.ortb)) { + return bidRequests; + } + let bidRequestsCopy = deepClone(bidRequests); + // convert Native ORTB definition to old-style prebid native definition + for (const bidRequest of bidRequestsCopy) { + if (bidRequest.mediaTypes && bidRequest.mediaTypes[NATIVE] && bidRequest.mediaTypes[NATIVE].ortb) { + bidRequest.mediaTypes[NATIVE] = Object.assign( + pick(bidRequest.mediaTypes[NATIVE], NATIVE_KEYS_THAT_ARE_NOT_ASSETS), + fromOrtbNativeRequest(bidRequest.mediaTypes[NATIVE].ortb) + ); + bidRequest.nativeParams = processNativeAdUnitParams(bidRequest.mediaTypes[NATIVE]); + } + } + return bidRequestsCopy; + } + return bidRequests; +} + +/** + * convert PBJS proprietary native properties that are *not* assets to the ORTB native format. + * + * @param legacyNative `bidResponse.native` object as returned by adapters + */ +export function legacyPropertiesToOrtbNative(legacyNative) { + const response = { + link: {}, + eventtrackers: [] + } + Object.entries(legacyNative).forEach(([key, value]) => { + switch (key) { + case 'clickUrl': + response.link.url = value; + break; + case 'clickTrackers': + response.link.clicktrackers = Array.isArray(value) ? value : [value]; + break; + case 'impressionTrackers': + (Array.isArray(value) ? value : [value]).forEach(url => { + response.eventtrackers.push({ + event: TRACKER_EVENTS.impression, + method: TRACKER_METHODS.img, + url + }); + }); + break; + case 'javascriptTrackers': + // jstracker is deprecated, but we need to use it here since 'javascriptTrackers' is markup, not an url + // TODO: at the time of writing this, core expected javascriptTrackers to be a string (despite the name), + // but many adapters are passing an array. It's possible that some of them are, in fact, passing URLs and not markup + // in general, native trackers seem to be neglected and/or broken + response.jstracker = Array.isArray(value) ? value.join('') : value; + break; + case 'privacyLink': + response.privacy = value; + break; + } + }); + return response; +} + +export function toOrtbNativeResponse(legacyResponse, ortbRequest) { + const ortbResponse = { + ...legacyPropertiesToOrtbNative(legacyResponse), + assets: [] + }; + + function useRequestAsset(predicate, fn) { + let asset = ortbRequest.assets.find(predicate); + if (asset != null) { + asset = deepClone(asset); + fn(asset); + ortbResponse.assets.push(asset); + } + } + + Object.keys(legacyResponse).filter(key => !!legacyResponse[key]).forEach(key => { + const value = getAssetValue(legacyResponse[key]); + switch (key) { + // process titles + case 'title': + useRequestAsset(asset => asset.title != null, titleAsset => { + titleAsset.title = { + text: value + }; + }) + break; + case 'image': + case 'icon': + const imageType = key === 'image' ? NATIVE_IMAGE_TYPES.MAIN : NATIVE_IMAGE_TYPES.ICON; + useRequestAsset(asset => asset.img != null && asset.img.type === imageType, imageAsset => { + imageAsset.img = { + url: value + }; + }) + break; + default: + if (key in PREBID_NATIVE_DATA_KEYS_TO_ORTB) { + useRequestAsset(asset => asset.data != null && asset.data.type === NATIVE_ASSET_TYPES[PREBID_NATIVE_DATA_KEYS_TO_ORTB[key]], dataAsset => { + dataAsset.data = { + value + }; + }) + } + break; + } + }); + return ortbResponse; +} + +/** + * Generates a legacy response from an ortb response. Useful during the transition period. + * @param {*} ortbResponse a standard ortb response object + * @param {*} ortbRequest the ortb request, useful to match ids. + * @returns an object containing the response in legacy native format: { title: "this is a title", image: ... } + */ +export function toLegacyResponse(ortbResponse, ortbRequest) { + const legacyResponse = {}; + const requestAssets = ortbRequest?.assets || []; + legacyResponse.clickUrl = ortbResponse.link.url; + legacyResponse.privacyLink = ortbResponse.privacy; + for (const asset of ortbResponse?.assets || []) { + const requestAsset = requestAssets.find(reqAsset => asset.id === reqAsset.id); + if (asset.title) { + legacyResponse.title = asset.title.text; + } else if (asset.img) { + legacyResponse[requestAsset.img.type === NATIVE_IMAGE_TYPES.MAIN ? 'image' : 'icon'] = { + url: asset.img.url, + width: asset.img.w, + height: asset.img.h + }; + } else if (asset.data) { + legacyResponse[PREBID_NATIVE_DATA_KEYS_TO_ORTB_INVERSE[NATIVE_ASSET_TYPES_INVERSE[requestAsset.data.type]]] = asset.data.value; + } + } + + // Handle trackers + legacyResponse.impressionTrackers = []; + let jsTrackers = []; + + if (ortbResponse.imptrackers) { + legacyResponse.impressionTrackers.push(...ortbResponse.imptrackers); + } + for (const eventTracker of ortbResponse?.eventtrackers || []) { + if (eventTracker.event === TRACKER_EVENTS.impression && eventTracker.method === TRACKER_METHODS.img) { + legacyResponse.impressionTrackers.push(eventTracker.url); + } + if (eventTracker.event === TRACKER_EVENTS.impression && eventTracker.method === TRACKER_METHODS.js) { + jsTrackers.push(eventTracker.url); + } + } + + jsTrackers = jsTrackers.map(url => ``); + if (ortbResponse?.jstracker) { jsTrackers.push(ortbResponse.jstracker); } + if (jsTrackers.length) { + legacyResponse.javascriptTrackers = jsTrackers.join('\n'); + } + + return legacyResponse; +} + +/** + * Inverts key-values of an object. + */ +function inverse(obj) { + var retobj = {}; + for (var key in obj) { + retobj[obj[key]] = key; + } + return retobj; +} diff --git a/src/pbjsORTB.js b/src/pbjsORTB.js new file mode 100644 index 00000000000..cc5c1c5bdd9 --- /dev/null +++ b/src/pbjsORTB.js @@ -0,0 +1,35 @@ +export const PROCESSOR_TYPES = ['request', 'imp', 'bidResponse', 'response']; +export const PROCESSOR_DIALECTS = ['default', 'pbs']; +export const [REQUEST, IMP, BID_RESPONSE, RESPONSE] = PROCESSOR_TYPES; +export const [DEFAULT, PBS] = PROCESSOR_DIALECTS; + +const types = new Set(PROCESSOR_TYPES); + +export function processorRegistry() { + const processors = {}; + + return { + registerOrtbProcessor({type, name, fn, priority = 0, dialects = [DEFAULT]}) { + if (!types.has(type)) { + throw new Error(`ORTB processor type must be one of: ${PROCESSOR_TYPES.join(', ')}`) + } + dialects.forEach(dialect => { + if (!processors.hasOwnProperty(dialect)) { + processors[dialect] = {}; + } + if (!processors[dialect].hasOwnProperty(type)) { + processors[dialect][type] = {}; + } + processors[dialect][type][name] = { + priority, + fn + } + }) + }, + getProcessors(dialect) { + return processors[dialect] || {}; + } + } +} + +export const {registerOrtbProcessor, getProcessors} = processorRegistry(); diff --git a/src/prebid.js b/src/prebid.js index 98655825e89..6ad5120ce82 100644 --- a/src/prebid.js +++ b/src/prebid.js @@ -1,31 +1,57 @@ /** @module pbjs */ -import { getGlobal } from './prebidGlobal.js'; +import {getGlobal} from './prebidGlobal.js'; import { - adUnitsFilter, flatten, getHighestCpm, isArrayOfNums, isGptPubadsDefined, uniques, logInfo, - contains, logError, isArray, deepClone, deepAccess, isNumber, logWarn, logMessage, isFn, - transformAdServerTargetingObj, bind, replaceAuctionPrice, replaceClickThrough, insertElement, - inIframe, callBurl, createInvisibleIframe, generateUUID, unsupportedBidderMessage, isEmpty + callBurl, + createInvisibleIframe, + deepAccess, + deepClone, + deepSetValue, + flatten, + generateUUID, + inIframe, + insertElement, + isArray, + isArrayOfNums, + isEmpty, + isFn, + isGptPubadsDefined, + isNumber, + logError, + logInfo, + logMessage, + logWarn, + mergeDeep, + replaceAuctionPrice, + replaceClickThrough, + transformAdServerTargetingObj, + uniques, + unsupportedBidderMessage } from './utils.js'; -import { listenMessagesFromCreative } from './secureCreatives.js'; -import { userSync } from './userSync.js'; -import { config } from './config.js'; -import { auctionManager } from './auctionManager.js'; -import { filters, targeting } from './targeting.js'; -import { hook } from './hook.js'; -import { sessionLoader } from './debugging.js'; +import {listenMessagesFromCreative} from './secureCreatives.js'; +import {userSync} from './userSync.js'; +import {config} from './config.js'; +import {auctionManager} from './auctionManager.js'; +import {isBidUsable, targeting} from './targeting.js'; +import {hook, wrapHook} from './hook.js'; +import {loadSession} from './debugging.js'; import {includes} from './polyfill.js'; -import { adunitCounter } from './adUnits.js'; -import { executeRenderer, isRendererRequired } from './Renderer.js'; -import { createBid } from './bidfactory.js'; -import { storageCallbacks } from './storageManager.js'; -import { emitAdRenderSucceeded, emitAdRenderFail } from './adRendering.js'; -import { gdprDataHandler, uspDataHandler } from './adapterManager.js' - -const $$PREBID_GLOBAL$$ = getGlobal(); -const CONSTANTS = require('./constants.json'); -const adapterManager = require('./adapterManager.js').default; -const events = require('./events.js'); +import {adunitCounter} from './adUnits.js'; +import {executeRenderer, isRendererRequired} from './Renderer.js'; +import {createBid} from './bidfactory.js'; +import {storageCallbacks} from './storageManager.js'; +import {emitAdRenderFail, emitAdRenderSucceeded} from './adRendering.js'; +import {default as adapterManager, getS2SBidderSet} from './adapterManager.js'; +import CONSTANTS from './constants.json'; +import * as events from './events.js'; +import {newMetrics, useMetrics} from './utils/perfMetrics.js'; +import {defer, GreedyPromise} from './utils/promise.js'; +import {enrichFPD} from './fpd/enrichment.js'; +import {allConsent} from './consentHandler.js'; +import {getHighestCpm} from './utils/reducers.js'; +import {fillVideoDefaults} from './video.js'; + +const pbjsInstance = getGlobal(); const { triggerUserSyncs } = userSync; /* private variables */ @@ -37,32 +63,32 @@ const eventValidators = { }; // initialize existing debugging sessions if present -sessionLoader(); +loadSession(); /* Public vars */ -$$PREBID_GLOBAL$$.bidderSettings = $$PREBID_GLOBAL$$.bidderSettings || {}; +pbjsInstance.bidderSettings = pbjsInstance.bidderSettings || {}; // let the world know we are loaded -$$PREBID_GLOBAL$$.libLoaded = true; +pbjsInstance.libLoaded = true; // version auto generated from build -$$PREBID_GLOBAL$$.version = 'v$prebid.version$'; +pbjsInstance.version = 'v$prebid.version$'; logInfo('Prebid.js v$prebid.version$ loaded'); -$$PREBID_GLOBAL$$.installedModules = $$PREBID_GLOBAL$$.installedModules || []; +pbjsInstance.installedModules = pbjsInstance.installedModules || []; // create adUnit array -$$PREBID_GLOBAL$$.adUnits = $$PREBID_GLOBAL$$.adUnits || []; +pbjsInstance.adUnits = pbjsInstance.adUnits || []; // Allow publishers who enable user sync override to trigger their sync -$$PREBID_GLOBAL$$.triggerUserSyncs = triggerUserSyncs; +pbjsInstance.triggerUserSyncs = triggerUserSyncs; function checkDefinedPlacement(id) { var adUnitCodes = auctionManager.getBidsRequested().map(bidSet => bidSet.bids.map(bid => bid.adUnitCode)) .reduce(flatten) .filter(uniques); - if (!contains(adUnitCodes, id)) { + if (!adUnitCodes.includes(id)) { logError('The "' + id + '" placement is not defined.'); return; } @@ -130,6 +156,16 @@ function validateVideoMediaType(adUnit) { function validateNativeMediaType(adUnit) { const validatedAdUnit = deepClone(adUnit); const native = validatedAdUnit.mediaTypes.native; + // if native assets are specified in OpenRTB format, remove legacy assets and print a warn. + if (native.ortb) { + const legacyNativeKeys = Object.keys(CONSTANTS.NATIVE_KEYS).filter(key => CONSTANTS.NATIVE_KEYS[key].includes('hb_native_')); + const nativeKeys = Object.keys(native); + const intersection = nativeKeys.filter(nativeKey => legacyNativeKeys.includes(nativeKey)); + if (intersection.length > 0) { + logError(`when using native OpenRTB format, you cannot use legacy native properties. Deleting ${intersection} keys from request.`); + intersection.forEach(legacyKey => delete validatedAdUnit.mediaTypes.native[legacyKey]); + } + } if (native.image && native.image.sizes && !Array.isArray(native.image.sizes)) { logError('Please use an array of sizes for native.image.sizes field. Removing invalid mediaTypes.native.image.sizes property from request.'); delete validatedAdUnit.mediaTypes.native.image.sizes; @@ -188,11 +224,17 @@ function validateAdUnit(adUnit) { export const adUnitSetupChecks = { validateAdUnit, validateBannerMediaType, - validateVideoMediaType, - validateNativeMediaType, validateSizes }; +if (FEATURES.NATIVE) { + Object.assign(adUnitSetupChecks, {validateNativeMediaType}); +} + +if (FEATURES.VIDEO) { + Object.assign(adUnitSetupChecks, { validateVideoMediaType }); +} + export const checkAdUnitSetup = hook('sync', function (adUnits) { const validatedAdUnits = []; @@ -208,12 +250,12 @@ export const checkAdUnitSetup = hook('sync', function (adUnits) { if (mediaTypes.banner.hasOwnProperty('pos')) validatedBanner = validateAdUnitPos(validatedBanner, 'banner'); } - if (mediaTypes.video) { + if (FEATURES.VIDEO && mediaTypes.video) { validatedVideo = validatedBanner ? validateVideoMediaType(validatedBanner) : validateVideoMediaType(adUnit); if (mediaTypes.video.hasOwnProperty('pos')) validatedVideo = validateAdUnitPos(validatedVideo, 'video'); } - if (mediaTypes.native) { + if (FEATURES.NATIVE && mediaTypes.native) { validatedNative = validatedVideo ? validateNativeMediaType(validatedVideo) : validatedBanner ? validateNativeMediaType(validatedBanner) : validateNativeMediaType(adUnit); } @@ -225,6 +267,12 @@ export const checkAdUnitSetup = hook('sync', function (adUnits) { return validatedAdUnits; }, 'checkAdUnitSetup'); +function fillAdUnitDefaults(adUnits) { + if (FEATURES.VIDEO) { + adUnits.forEach(au => fillVideoDefaults(au)) + } +} + /// /////////////////////////////// // // // Start Public APIs // @@ -237,12 +285,12 @@ export const checkAdUnitSetup = hook('sync', function (adUnits) { * @alias module:pbjs.getAdserverTargetingForAdUnitCodeStr * @return {Array} returnObj return bids array */ -$$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCodeStr = function (adunitCode) { +pbjsInstance.getAdserverTargetingForAdUnitCodeStr = function (adunitCode) { logInfo('Invoking $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCodeStr', arguments); // call to retrieve bids array if (adunitCode) { - var res = $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCode(adunitCode); + var res = pbjsInstance.getAdserverTargetingForAdUnitCode(adunitCode); return transformAdServerTargetingObj(res); } else { logMessage('Need to call getAdserverTargetingForAdUnitCodeStr with adunitCode'); @@ -255,11 +303,10 @@ $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCodeStr = function (adunitCode) { * @alias module:pbjs.getHighestUnusedBidResponseForAdUnitCode * @returns {Object} returnObj return bid */ -$$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode = function (adunitCode) { +pbjsInstance.getHighestUnusedBidResponseForAdUnitCode = function (adunitCode) { if (adunitCode) { const bid = auctionManager.getAllBidsForAdUnitCode(adunitCode) - .filter(filters.isUnusedBid) - .filter(filters.isBidNotExpired) + .filter(isBidUsable) return bid.length ? bid.reduce(getHighestCpm) : {} } else { @@ -273,8 +320,8 @@ $$PREBID_GLOBAL$$.getHighestUnusedBidResponseForAdUnitCode = function (adunitCod * @alias module:pbjs.getAdserverTargetingForAdUnitCode * @returns {Object} returnObj return bids */ -$$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCode = function (adUnitCode) { - return $$PREBID_GLOBAL$$.getAdserverTargeting(adUnitCode)[adUnitCode]; +pbjsInstance.getAdserverTargetingForAdUnitCode = function (adUnitCode) { + return pbjsInstance.getAdserverTargeting(adUnitCode)[adUnitCode]; }; /** @@ -283,32 +330,19 @@ $$PREBID_GLOBAL$$.getAdserverTargetingForAdUnitCode = function (adUnitCode) { * @alias module:pbjs.getAdserverTargeting */ -$$PREBID_GLOBAL$$.getAdserverTargeting = function (adUnitCode) { +pbjsInstance.getAdserverTargeting = function (adUnitCode) { logInfo('Invoking $$PREBID_GLOBAL$$.getAdserverTargeting', arguments); return targeting.getAllTargeting(adUnitCode); }; -/** - * returns all consent data - * @return {Object} Map of consent types and data - * @alias module:pbjs.getConsentData - */ -function getConsentMetadata() { - return { - gdpr: gdprDataHandler.getConsentMeta(), - usp: uspDataHandler.getConsentMeta(), - coppa: !!(config.getConfig('coppa')) - } -} - -$$PREBID_GLOBAL$$.getConsentMetadata = function () { +pbjsInstance.getConsentMetadata = function () { logInfo('Invoking $$PREBID_GLOBAL$$.getConsentMetadata'); - return getConsentMetadata(); + return allConsent.getConsentMeta() }; function getBids(type) { const responses = auctionManager[type]() - .filter(bind.call(adUnitsFilter, this, auctionManager.getAdUnitCodes())); + .filter(bid => auctionManager.getAdUnitCodes().includes(bid.adUnitCode)) // find the last auction id to get responses for most recent auction only const currentAuctionId = auctionManager.getLastAuctionId(); @@ -332,7 +366,7 @@ function getBids(type) { * @return {Object} map | object that contains the bidRequests */ -$$PREBID_GLOBAL$$.getNoBids = function () { +pbjsInstance.getNoBids = function () { logInfo('Invoking $$PREBID_GLOBAL$$.getNoBids', arguments); return getBids('getNoBids'); }; @@ -344,7 +378,7 @@ $$PREBID_GLOBAL$$.getNoBids = function () { * @return {Object} bidResponse object */ -$$PREBID_GLOBAL$$.getNoBidsForAdUnitCode = function (adUnitCode) { +pbjsInstance.getNoBidsForAdUnitCode = function (adUnitCode) { const bids = auctionManager.getNoBids().filter(bid => bid.adUnitCode === adUnitCode); return { bids }; }; @@ -355,7 +389,7 @@ $$PREBID_GLOBAL$$.getNoBidsForAdUnitCode = function (adUnitCode) { * @return {Object} map | object that contains the bidResponses */ -$$PREBID_GLOBAL$$.getBidResponses = function () { +pbjsInstance.getBidResponses = function () { logInfo('Invoking $$PREBID_GLOBAL$$.getBidResponses', arguments); return getBids('getBidsReceived'); }; @@ -367,7 +401,7 @@ $$PREBID_GLOBAL$$.getBidResponses = function () { * @return {Object} bidResponse object */ -$$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode = function (adUnitCode) { +pbjsInstance.getBidResponsesForAdUnitCode = function (adUnitCode) { const bids = auctionManager.getBidsReceived().filter(bid => bid.adUnitCode === adUnitCode); return { bids }; }; @@ -378,7 +412,7 @@ $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode = function (adUnitCode) { * @param {function(object)} customSlotMatching gets a GoogleTag slot and returns a filter function for adUnitCode, so you can decide to match on either eg. return slot => { return adUnitCode => { return slot.getSlotElementId() === 'myFavoriteDivId'; } }; * @alias module:pbjs.setTargetingForGPTAsync */ -$$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnit, customSlotMatching) { +pbjsInstance.setTargetingForGPTAsync = function (adUnit, customSlotMatching) { logInfo('Invoking $$PREBID_GLOBAL$$.setTargetingForGPTAsync', arguments); if (!isGptPubadsDefined()) { logError('window.googletag is not defined on the page'); @@ -411,7 +445,7 @@ $$PREBID_GLOBAL$$.setTargetingForGPTAsync = function (adUnit, customSlotMatching * @param {(string|string[])} adUnitCode adUnitCode or array of adUnitCodes * @alias module:pbjs.setTargetingForAst */ -$$PREBID_GLOBAL$$.setTargetingForAst = function (adUnitCodes) { +pbjsInstance.setTargetingForAst = function (adUnitCodes) { logInfo('Invoking $$PREBID_GLOBAL$$.setTargetingForAn', arguments); if (!targeting.isApntagDefined()) { logError('window.apntag is not defined on the page'); @@ -444,90 +478,105 @@ function reinjectNodeIfRemoved(node, doc, tagName) { * @param {string} id bid id to locate the ad * @alias module:pbjs.renderAd */ -$$PREBID_GLOBAL$$.renderAd = hook('async', function (doc, id, options) { +pbjsInstance.renderAd = hook('async', function (doc, id, options) { logInfo('Invoking $$PREBID_GLOBAL$$.renderAd', arguments); logMessage('Calling renderAd with adId :' + id); - if (doc && id) { - try { - // lookup ad by ad Id - const bid = auctionManager.findBidByAdId(id); - - if (bid) { - let shouldRender = true; - if (bid && bid.status === CONSTANTS.BID_STATUS.RENDERED) { - logWarn(`Ad id ${bid.adId} has been rendered before`); - events.emit(STALE_RENDER, bid); - if (deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) { - shouldRender = false; - } - } - - if (shouldRender) { - // replace macros according to openRTB with price paid = bid.cpm - bid.ad = replaceAuctionPrice(bid.ad, bid.originalCpm || bid.cpm); - bid.adUrl = replaceAuctionPrice(bid.adUrl, bid.originalCpm || bid.cpm); - // replacing clickthrough if submitted - if (options && options.clickThrough) { - const {clickThrough} = options; - bid.ad = replaceClickThrough(bid.ad, clickThrough); - bid.adUrl = replaceClickThrough(bid.adUrl, clickThrough); - } - - // save winning bids - auctionManager.addWinningBid(bid); - - // emit 'bid won' event here - events.emit(BID_WON, bid); - - const {height, width, ad, mediaType, adUrl, renderer} = bid; - - const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`); - insertElement(creativeComment, doc, 'html'); - - if (isRendererRequired(renderer)) { - executeRenderer(renderer, bid, doc); - reinjectNodeIfRemoved(creativeComment, doc, 'html'); - emitAdRenderSucceeded({ doc, bid, id }); - } else if ((doc === document && !inIframe()) || mediaType === 'video') { - const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`; - emitAdRenderFail({reason: PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid, id}); - } else if (ad) { - doc.write(ad); - doc.close(); - setRenderSize(doc, width, height); - reinjectNodeIfRemoved(creativeComment, doc, 'html'); - callBurl(bid); - emitAdRenderSucceeded({ doc, bid, id }); - } else if (adUrl) { - const iframe = createInvisibleIframe(); - iframe.height = height; - iframe.width = width; - iframe.style.display = 'inline'; - iframe.style.overflow = 'hidden'; - iframe.src = adUrl; - - insertElement(iframe, doc, 'body'); - setRenderSize(doc, width, height); - reinjectNodeIfRemoved(creativeComment, doc, 'html'); - callBurl(bid); - emitAdRenderSucceeded({ doc, bid, id }); - } else { - const message = `Error trying to write ad. No ad for bid response id: ${id}`; - emitAdRenderFail({reason: NO_AD, message, bid, id}); - } - } - } else { - const message = `Error trying to write ad. Cannot find ad by given id : ${id}`; - emitAdRenderFail({ reason: CANNOT_FIND_AD, message, id }); + if (!id) { + const message = `Error trying to write ad Id :${id} to the page. Missing adId`; + emitAdRenderFail({ reason: MISSING_DOC_OR_ADID, message, id }); + return; + } + + try { + // lookup ad by ad Id + const bid = auctionManager.findBidByAdId(id); + if (!bid) { + const message = `Error trying to write ad. Cannot find ad by given id : ${id}`; + emitAdRenderFail({ reason: CANNOT_FIND_AD, message, id }); + return; + } + + if (bid.status === CONSTANTS.BID_STATUS.RENDERED) { + logWarn(`Ad id ${bid.adId} has been rendered before`); + events.emit(STALE_RENDER, bid); + if (deepAccess(config.getConfig('auctionOptions'), 'suppressStaleRender')) { + return; } - } catch (e) { - const message = `Error trying to write ad Id :${id} to the page:${e.message}`; - emitAdRenderFail({ reason: EXCEPTION, message, id }); } - } else { - const message = `Error trying to write ad Id :${id} to the page. Missing document or adId`; - emitAdRenderFail({ reason: MISSING_DOC_OR_ADID, message, id }); + + // replace macros according to openRTB with price paid = bid.cpm + bid.ad = replaceAuctionPrice(bid.ad, bid.originalCpm || bid.cpm); + bid.adUrl = replaceAuctionPrice(bid.adUrl, bid.originalCpm || bid.cpm); + // replacing clickthrough if submitted + if (options && options.clickThrough) { + const {clickThrough} = options; + bid.ad = replaceClickThrough(bid.ad, clickThrough); + bid.adUrl = replaceClickThrough(bid.adUrl, clickThrough); + } + + // save winning bids + auctionManager.addWinningBid(bid); + + // emit 'bid won' event here + events.emit(BID_WON, bid); + + const {height, width, ad, mediaType, adUrl, renderer} = bid; + + // video module + if (FEATURES.VIDEO) { + const adUnitCode = bid.adUnitCode; + const adUnit = pbjsInstance.adUnits.filter(adUnit => adUnit.code === adUnitCode); + const videoModule = pbjsInstance.videoModule; + if (adUnit.video && videoModule) { + videoModule.renderBid(adUnit.video.divId, bid); + return; + } + } + + if (!doc) { + const message = `Error trying to write ad Id :${id} to the page. Missing document`; + emitAdRenderFail({ reason: MISSING_DOC_OR_ADID, message, id }); + return; + } + + const creativeComment = document.createComment(`Creative ${bid.creativeId} served by ${bid.bidder} Prebid.js Header Bidding`); + insertElement(creativeComment, doc, 'html'); + + if (isRendererRequired(renderer)) { + executeRenderer(renderer, bid, doc); + reinjectNodeIfRemoved(creativeComment, doc, 'html'); + emitAdRenderSucceeded({ doc, bid, id }); + } else if ((doc === document && !inIframe()) || mediaType === 'video') { + const message = `Error trying to write ad. Ad render call ad id ${id} was prevented from writing to the main document.`; + emitAdRenderFail({reason: PREVENT_WRITING_ON_MAIN_DOCUMENT, message, bid, id}); + } else if (ad) { + doc.write(ad); + doc.close(); + setRenderSize(doc, width, height); + reinjectNodeIfRemoved(creativeComment, doc, 'html'); + callBurl(bid); + emitAdRenderSucceeded({ doc, bid, id }); + } else if (adUrl) { + const iframe = createInvisibleIframe(); + iframe.height = height; + iframe.width = width; + iframe.style.display = 'inline'; + iframe.style.overflow = 'hidden'; + iframe.src = adUrl; + + insertElement(iframe, doc, 'body'); + setRenderSize(doc, width, height); + reinjectNodeIfRemoved(creativeComment, doc, 'html'); + callBurl(bid); + emitAdRenderSucceeded({ doc, bid, id }); + } else { + const message = `Error trying to write ad. No ad for bid response id: ${id}`; + emitAdRenderFail({reason: NO_AD, message, bid, id}); + } + } catch (e) { + const message = `Error trying to write ad Id :${id} to the page:${e.message}`; + emitAdRenderFail({ reason: EXCEPTION, message, id }); } }); @@ -536,11 +585,11 @@ $$PREBID_GLOBAL$$.renderAd = hook('async', function (doc, id, options) { * @param {string| Array} adUnitCode the adUnitCode(s) to remove * @alias module:pbjs.removeAdUnit */ -$$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { +pbjsInstance.removeAdUnit = function (adUnitCode) { logInfo('Invoking $$PREBID_GLOBAL$$.removeAdUnit', arguments); if (!adUnitCode) { - $$PREBID_GLOBAL$$.adUnits = []; + pbjsInstance.adUnits = []; return; } @@ -553,9 +602,9 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { } adUnitCodes.forEach((adUnitCode) => { - for (let i = $$PREBID_GLOBAL$$.adUnits.length - 1; i >= 0; i--) { - if ($$PREBID_GLOBAL$$.adUnits[i].code === adUnitCode) { - $$PREBID_GLOBAL$$.adUnits.splice(i, 1); + for (let i = pbjsInstance.adUnits.length - 1; i >= 0; i--) { + if (pbjsInstance.adUnits[i].code === adUnitCode) { + pbjsInstance.adUnits.splice(i, 1); } } }); @@ -571,33 +620,60 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { * @param {String} requestOptions.auctionId * @alias module:pbjs.requestBids */ -$$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeout, adUnits, adUnitCodes, labels, auctionId } = {}) { - events.emit(REQUEST_BIDS); - const cbTimeout = timeout || config.getConfig('bidderTimeout'); - adUnits = (adUnits && config.convertAdUnitFpd(isArray(adUnits) ? adUnits : [adUnits])) || $$PREBID_GLOBAL$$.adUnits; - - logInfo('Invoking $$PREBID_GLOBAL$$.requestBids', arguments); - - let _s2sConfigs = []; - const s2sBidders = []; - config.getConfig('s2sConfig', config => { - if (config && config.s2sConfig) { - _s2sConfigs = Array.isArray(config.s2sConfig) ? config.s2sConfig : [config.s2sConfig]; +pbjsInstance.requestBids = (function() { + const delegate = hook('async', function ({ bidsBackHandler, timeout, adUnits, adUnitCodes, labels, auctionId, ttlBuffer, ortb2, metrics, defer } = {}) { + events.emit(REQUEST_BIDS); + const cbTimeout = timeout || config.getConfig('bidderTimeout'); + logInfo('Invoking $$PREBID_GLOBAL$$.requestBids', arguments); + if (adUnitCodes && adUnitCodes.length) { + // if specific adUnitCodes supplied filter adUnits for those codes + adUnits = adUnits.filter(unit => includes(adUnitCodes, unit.code)); + } else { + // otherwise derive adUnitCodes from adUnits + adUnitCodes = adUnits && adUnits.map(unit => unit.code); } + const ortb2Fragments = { + global: mergeDeep({}, config.getAnyConfig('ortb2') || {}, ortb2 || {}), + bidder: Object.fromEntries(Object.entries(config.getBidderConfig()).map(([bidder, cfg]) => [bidder, cfg.ortb2]).filter(([_, ortb2]) => ortb2 != null)) + } + return enrichFPD(GreedyPromise.resolve(ortb2Fragments.global)).then(global => { + ortb2Fragments.global = global; + return startAuction({bidsBackHandler, timeout: cbTimeout, adUnits, adUnitCodes, labels, auctionId, ttlBuffer, ortb2Fragments, metrics, defer}); + }) + }, 'requestBids'); + + return wrapHook(delegate, function requestBids(req = {}) { + // unlike the main body of `delegate`, this runs before any other hook has a chance to; + // it's also not restricted in its return value in the way `async` hooks are. + + // if the request does not specify adUnits, clone the global adUnit array; + // otherwise, if the caller goes on to use addAdUnits/removeAdUnits, any asynchronous logic + // in any hook might see their effects. + let adUnits = req.adUnits || pbjsInstance.adUnits; + req.adUnits = (isArray(adUnits) ? adUnits.slice() : [adUnits]); + + req.metrics = newMetrics(); + req.metrics.checkpoint('requestBids'); + req.defer = defer({promiseFactory: (r) => new Promise(r)}) + delegate.call(this, req); + return req.defer.promise; }); +})(); - _s2sConfigs.forEach(s2sConfig => { - s2sBidders.push(...s2sConfig.bidders); - }); - - adUnits = checkAdUnitSetup(adUnits); +export const startAuction = hook('async', function ({ bidsBackHandler, timeout: cbTimeout, adUnits, ttlBuffer, adUnitCodes, labels, auctionId, ortb2Fragments, metrics, defer } = {}) { + const s2sBidders = getS2SBidderSet(config.getConfig('s2sConfig') || []); + fillAdUnitDefaults(adUnits); + adUnits = useMetrics(metrics).measureTime('requestBids.validate', () => checkAdUnitSetup(adUnits)); - if (adUnitCodes && adUnitCodes.length) { - // if specific adUnitCodes supplied filter adUnits for those codes - adUnits = adUnits.filter(unit => includes(adUnitCodes, unit.code)); - } else { - // otherwise derive adUnitCodes from adUnits - adUnitCodes = adUnits && adUnits.map(unit => unit.code); + function auctionDone(bids, timedOut, auctionId) { + if (typeof bidsBackHandler === 'function') { + try { + bidsBackHandler(bids, timedOut, auctionId); + } catch (e) { + logError('Error executing bidsBackHandler', null, e); + } + } + defer.resolve({bids, timedOut, auctionId}) } /* @@ -614,9 +690,15 @@ $$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeo const allBidders = adUnit.bids.map(bid => bid.bidder); const bidderRegistry = adapterManager.bidderRegistry; - const bidders = (s2sBidders) ? allBidders.filter(bidder => !includes(s2sBidders, bidder)) : allBidders; + const bidders = allBidders.filter(bidder => !s2sBidders.has(bidder)); - adUnit.transactionId = generateUUID(); + const tid = adUnit.ortb2Imp?.ext?.tid || generateUUID(); + adUnit.transactionId = tid; + if (ttlBuffer != null && !adUnit.hasOwnProperty('ttlBuffer')) { + adUnit.ttlBuffer = ttlBuffer; + } + // Populate ortb2Imp.ext.tid with transactionId. Specifying a transaction ID per item in the ortb impression array, lets multiple transaction IDs be transmitted in a single bid request. + deepSetValue(adUnit, 'ortb2Imp.ext.tid', tid); bidders.forEach(bidder => { const adapter = bidderRegistry[bidder]; @@ -639,27 +721,28 @@ $$PREBID_GLOBAL$$.requestBids = hook('async', function ({ bidsBackHandler, timeo if (!adUnits || adUnits.length === 0) { logMessage('No adUnits configured. No bids requested.'); - if (typeof bidsBackHandler === 'function') { - // executeCallback, this will only be called in case of first request - try { - bidsBackHandler(); - } catch (e) { - logError('Error executing bidsBackHandler', null, e); - } - } - return; - } + auctionDone(); + } else { + const auction = auctionManager.createAuction({ + adUnits, + adUnitCodes, + callback: auctionDone, + cbTimeout, + labels, + auctionId, + ortb2Fragments, + metrics, + }); - const auction = auctionManager.createAuction({ adUnits, adUnitCodes, callback: bidsBackHandler, cbTimeout, labels, auctionId }); + let adUnitsLen = adUnits.length; + if (adUnitsLen > 15) { + logInfo(`Current auction ${auction.getAuctionId()} contains ${adUnitsLen} adUnits.`, adUnits); + } - let adUnitsLen = adUnits.length; - if (adUnitsLen > 15) { - logInfo(`Current auction ${auction.getAuctionId()} contains ${adUnitsLen} adUnits.`, adUnits); + adUnitCodes.forEach(code => targeting.setLatestAuctionForAdUnit(code, auction.getAuctionId())); + auction.callBids(); } - - adUnitCodes.forEach(code => targeting.setLatestAuctionForAdUnit(code, auction.getAuctionId())); - auction.callBids(); -}); +}, 'startAuction'); export function executeCallbacks(fn, reqBidsConfigObj) { runAll(storageCallbacks); @@ -675,7 +758,7 @@ export function executeCallbacks(fn, reqBidsConfigObj) { } // This hook will execute all storage callbacks which were registered before gdpr enforcement hook was added. Some bidders, user id modules use storage functions when module is parsed but gdpr enforcement hook is not added at that stage as setConfig callbacks are yet to be called. Hence for such calls we execute all the stored callbacks just before requestBids. At this hook point we will know for sure that gdprEnforcement module is added or not -$$PREBID_GLOBAL$$.requestBids.before(executeCallbacks, 49); +pbjsInstance.requestBids.before(executeCallbacks, 49); /** * @@ -683,9 +766,9 @@ $$PREBID_GLOBAL$$.requestBids.before(executeCallbacks, 49); * @param {Array|Object} adUnitArr Array of adUnits or single adUnit Object. * @alias module:pbjs.addAdUnits */ -$$PREBID_GLOBAL$$.addAdUnits = function (adUnitArr) { +pbjsInstance.addAdUnits = function (adUnitArr) { logInfo('Invoking $$PREBID_GLOBAL$$.addAdUnits', arguments); - $$PREBID_GLOBAL$$.adUnits.push.apply($$PREBID_GLOBAL$$.adUnits, config.convertAdUnitFpd(isArray(adUnitArr) ? adUnitArr : [adUnitArr])); + pbjsInstance.adUnits.push.apply(pbjsInstance.adUnits, isArray(adUnitArr) ? adUnitArr : [adUnitArr]); // emit event events.emit(ADD_AD_UNITS); }; @@ -706,7 +789,7 @@ $$PREBID_GLOBAL$$.addAdUnits = function (adUnitArr) { * * Currently `bidWon` is the only event that accepts an `id` parameter. */ -$$PREBID_GLOBAL$$.onEvent = function (event, handler, id) { +pbjsInstance.onEvent = function (event, handler, id) { logInfo('Invoking $$PREBID_GLOBAL$$.onEvent', arguments); if (!isFn(handler)) { logError('The event handler provided is not a function and was not set on event "' + event + '".'); @@ -727,7 +810,7 @@ $$PREBID_GLOBAL$$.onEvent = function (event, handler, id) { * @param {string} id an identifier in the context of the event (see `$$PREBID_GLOBAL$$.onEvent`) * @alias module:pbjs.offEvent */ -$$PREBID_GLOBAL$$.offEvent = function (event, handler, id) { +pbjsInstance.offEvent = function (event, handler, id) { logInfo('Invoking $$PREBID_GLOBAL$$.offEvent', arguments); if (id && !eventValidators[event].call(null, id)) { return; @@ -741,7 +824,7 @@ $$PREBID_GLOBAL$$.offEvent = function (event, handler, id) { * * @alias module:pbjs.getEvents */ -$$PREBID_GLOBAL$$.getEvents = function () { +pbjsInstance.getEvents = function () { logInfo('Invoking $$PREBID_GLOBAL$$.getEvents'); return events.getEvents(); }; @@ -752,7 +835,7 @@ $$PREBID_GLOBAL$$.getEvents = function () { * @param {string} bidderCode [description] * @alias module:pbjs.registerBidAdapter */ -$$PREBID_GLOBAL$$.registerBidAdapter = function (bidderAdaptor, bidderCode) { +pbjsInstance.registerBidAdapter = function (bidderAdaptor, bidderCode) { logInfo('Invoking $$PREBID_GLOBAL$$.registerBidAdapter', arguments); try { adapterManager.registerBidAdapter(bidderAdaptor(), bidderCode); @@ -766,7 +849,7 @@ $$PREBID_GLOBAL$$.registerBidAdapter = function (bidderAdaptor, bidderCode) { * @param {Object} options [description] * @alias module:pbjs.registerAnalyticsAdapter */ -$$PREBID_GLOBAL$$.registerAnalyticsAdapter = function (options) { +pbjsInstance.registerAnalyticsAdapter = function (options) { logInfo('Invoking $$PREBID_GLOBAL$$.registerAnalyticsAdapter', arguments); try { adapterManager.registerAnalyticsAdapter(options); @@ -781,7 +864,7 @@ $$PREBID_GLOBAL$$.registerAnalyticsAdapter = function (options) { * @alias module:pbjs.createBid * @return {Object} bidResponse [description] */ -$$PREBID_GLOBAL$$.createBid = function (statusCode) { +pbjsInstance.createBid = function (statusCode) { logInfo('Invoking $$PREBID_GLOBAL$$.createBid', arguments); return createBid(statusCode); }; @@ -813,14 +896,14 @@ const enableAnalyticsCb = hook('async', function (config) { } }, 'enableAnalyticsCb'); -$$PREBID_GLOBAL$$.enableAnalytics = function (config) { +pbjsInstance.enableAnalytics = function (config) { enableAnalyticsCallbacks.push(enableAnalyticsCb.bind(this, config)); }; /** * @alias module:pbjs.aliasBidder */ -$$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias, options) { +pbjsInstance.aliasBidder = function (bidderCode, alias, options) { logInfo('Invoking $$PREBID_GLOBAL$$.aliasBidder', arguments); if (bidderCode && alias) { adapterManager.aliasBidAdapter(bidderCode, alias, options); @@ -829,6 +912,14 @@ $$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias, options) { } }; +/** + * @alias module:pbjs.aliasRegistry + */ +pbjsInstance.aliasRegistry = adapterManager.aliasRegistry; +config.getConfig('aliasRegistry', config => { + if (config.aliasRegistry === 'private') delete pbjsInstance.aliasRegistry; +}); + /** * The bid response object returned by an external bidder adapter during the auction. * @typedef {Object} AdapterBidResponse @@ -868,7 +959,7 @@ $$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias, options) { * Get all of the bids that have been rendered. Useful for [troubleshooting your integration](http://prebid.org/dev-docs/prebid-troubleshooting-guide.html). * @return {Array} A list of bids that have been rendered. */ -$$PREBID_GLOBAL$$.getAllWinningBids = function () { +pbjsInstance.getAllWinningBids = function () { return auctionManager.getAllWinningBids(); }; @@ -876,7 +967,7 @@ $$PREBID_GLOBAL$$.getAllWinningBids = function () { * Get all of the bids that have won their respective auctions. * @return {Array} A list of bids that have won their respective auctions. */ -$$PREBID_GLOBAL$$.getAllPrebidWinningBids = function () { +pbjsInstance.getAllPrebidWinningBids = function () { return auctionManager.getBidsReceived() .filter(bid => bid.status === CONSTANTS.BID_STATUS.BID_TARGETING_SET); }; @@ -888,35 +979,43 @@ $$PREBID_GLOBAL$$.getAllPrebidWinningBids = function () { * @alias module:pbjs.getHighestCpmBids * @return {Array} array containing highest cpm bid object(s) */ -$$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) { +pbjsInstance.getHighestCpmBids = function (adUnitCode) { return targeting.getWinningBids(adUnitCode); }; -/** - * Mark the winning bid as used, should only be used in conjunction with video - * @typedef {Object} MarkBidRequest - * @property {string} adUnitCode The ad unit code - * @property {string} adId The id representing the ad we want to mark - * - * @alias module:pbjs.markWinningBidAsUsed - */ -$$PREBID_GLOBAL$$.markWinningBidAsUsed = function (markBidRequest) { +if (FEATURES.VIDEO) { + /** + * Mark the winning bid as used, should only be used in conjunction with video + * @typedef {Object} MarkBidRequest + * @property {string} adUnitCode The ad unit code + * @property {string} adId The id representing the ad we want to mark + * + * @alias module:pbjs.markWinningBidAsUsed + */ + pbjsInstance.markWinningBidAsUsed = function (markBidRequest) { + const bids = fetchReceivedBids(markBidRequest, 'Improper use of markWinningBidAsUsed. It needs an adUnitCode or an adId to function.'); + + if (bids.length > 0) { + auctionManager.addWinningBid(bids[0]); + } + } +} + +const fetchReceivedBids = (bidRequest, warningMessage) => { let bids = []; - if (markBidRequest.adUnitCode && markBidRequest.adId) { + if (bidRequest.adUnitCode && bidRequest.adId) { bids = auctionManager.getBidsReceived() - .filter(bid => bid.adId === markBidRequest.adId && bid.adUnitCode === markBidRequest.adUnitCode); - } else if (markBidRequest.adUnitCode) { - bids = targeting.getWinningBids(markBidRequest.adUnitCode); - } else if (markBidRequest.adId) { - bids = auctionManager.getBidsReceived().filter(bid => bid.adId === markBidRequest.adId); + .filter(bid => bid.adId === bidRequest.adId && bid.adUnitCode === bidRequest.adUnitCode); + } else if (bidRequest.adUnitCode) { + bids = targeting.getWinningBids(bidRequest.adUnitCode); + } else if (bidRequest.adId) { + bids = auctionManager.getBidsReceived().filter(bid => bid.adId === bidRequest.adId); } else { - logWarn('Improper use of markWinningBidAsUsed. It needs an adUnitCode or an adId to function.'); + logWarn(warningMessage); } - if (bids.length > 0) { - bids[0].status = CONSTANTS.BID_STATUS.RENDERED; - } + return bids; }; /** @@ -924,61 +1023,21 @@ $$PREBID_GLOBAL$$.markWinningBidAsUsed = function (markBidRequest) { * @param {Object} options * @alias module:pbjs.getConfig */ -$$PREBID_GLOBAL$$.getConfig = config.getConfig; -$$PREBID_GLOBAL$$.readConfig = config.readConfig; -$$PREBID_GLOBAL$$.mergeConfig = config.mergeConfig; -$$PREBID_GLOBAL$$.mergeBidderConfig = config.mergeBidderConfig; +pbjsInstance.getConfig = config.getAnyConfig; +pbjsInstance.readConfig = config.readAnyConfig; +pbjsInstance.mergeConfig = config.mergeConfig; +pbjsInstance.mergeBidderConfig = config.mergeBidderConfig; /** * Set Prebid config options. - * (Added in version 0.27.0). - * - * `setConfig` is designed to allow for advanced configuration while - * reducing the surface area of the public API. For more information - * about the move to `setConfig` (and the resulting deprecations of - * some other public methods), see [the Prebid 1.0 public API - * proposal](https://gist.github.com/mkendall07/51ee5f6b9f2df01a89162cf6de7fe5b6). - * - * #### Troubleshooting your configuration - * - * If you call `pbjs.setConfig` without an object, e.g., - * - * `pbjs.setConfig('debug', 'true'))` - * - * then Prebid.js will print an error to the console that says: - * - * ``` - * ERROR: setConfig options must be an object - * ``` - * - * If you don't see that message, you can assume the config object is valid. + * See https://docs.prebid.org/dev-docs/publisher-api-reference/setConfig.html * * @param {Object} options Global Prebid configuration object. Must be JSON - no JavaScript functions are allowed. - * @param {string} options.bidderSequence The order in which bidders are called. Example: `pbjs.setConfig({ bidderSequence: "fixed" })`. Allowed values: `"fixed"` (order defined in `adUnit.bids` array on page), `"random"`. - * @param {boolean} options.debug Turn debug logging on/off. Example: `pbjs.setConfig({ debug: true })`. - * @param {string} options.priceGranularity The bid price granularity to use. Example: `pbjs.setConfig({ priceGranularity: "medium" })`. Allowed values: `"low"` ($0.50), `"medium"` ($0.10), `"high"` ($0.01), `"auto"` (sliding scale), `"dense"` (like `"auto"`, with smaller increments at lower CPMs), or a custom price bucket object, e.g., `{ "buckets" : [{"min" : 0,"max" : 20,"increment" : 0.1,"cap" : true}]}`. - * @param {boolean} options.enableSendAllBids Turn "send all bids" mode on/off. Example: `pbjs.setConfig({ enableSendAllBids: true })`. - * @param {number} options.bidderTimeout Set a global bidder timeout, in milliseconds. Example: `pbjs.setConfig({ bidderTimeout: 3000 })`. Note that it's still possible for a bid to get into the auction that responds after this timeout. This is due to how [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) works in JS: it queues the callback in the event loop in an approximate location that should execute after this time but it is not guaranteed. For more information about the asynchronous event loop and `setTimeout`, see [How JavaScript Timers Work](https://johnresig.com/blog/how-javascript-timers-work/). - * @param {string} options.publisherDomain The publisher's domain where Prebid is running, for cross-domain iFrame communication. Example: `pbjs.setConfig({ publisherDomain: "https://www.theverge.com" })`. - * @param {Object} options.s2sConfig The configuration object for [server-to-server header bidding](http://prebid.org/dev-docs/get-started-with-prebid-server.html). Example: - * @alias module:pbjs.setConfig - * ``` - * pbjs.setConfig({ - * s2sConfig: { - * accountId: '1', - * enabled: true, - * bidders: ['appnexus', 'pubmatic'], - * timeout: 1000, - * adapter: 'prebidServer', - * endpoint: 'https://prebid.adnxs.com/pbs/v1/auction' - * } - * }) - * ``` */ -$$PREBID_GLOBAL$$.setConfig = config.setConfig; -$$PREBID_GLOBAL$$.setBidderConfig = config.setBidderConfig; +pbjsInstance.setConfig = config.setConfig; +pbjsInstance.setBidderConfig = config.setBidderConfig; -$$PREBID_GLOBAL$$.que.push(() => listenMessagesFromCreative()); +pbjsInstance.que.push(() => listenMessagesFromCreative()); /** * This queue lets users load Prebid asynchronously, but run functions the same way regardless of whether it gets loaded @@ -1000,7 +1059,7 @@ $$PREBID_GLOBAL$$.que.push(() => listenMessagesFromCreative()); * the Prebid script has been fully loaded. * @alias module:pbjs.cmd.push */ -$$PREBID_GLOBAL$$.cmd.push = function (command) { +pbjsInstance.cmd.push = function (command) { if (typeof command === 'function') { try { command.call(); @@ -1012,7 +1071,7 @@ $$PREBID_GLOBAL$$.cmd.push = function (command) { } }; -$$PREBID_GLOBAL$$.que.push = $$PREBID_GLOBAL$$.cmd.push; +pbjsInstance.que.push = pbjsInstance.cmd.push; function processQueue(queue) { queue.forEach(function (cmd) { @@ -1030,10 +1089,28 @@ function processQueue(queue) { /** * @alias module:pbjs.processQueue */ -$$PREBID_GLOBAL$$.processQueue = function () { +pbjsInstance.processQueue = function () { hook.ready(); - processQueue($$PREBID_GLOBAL$$.que); - processQueue($$PREBID_GLOBAL$$.cmd); + processQueue(pbjsInstance.que); + processQueue(pbjsInstance.cmd); +}; + +/** + * @alias module:pbjs.triggerBilling + */ +pbjsInstance.triggerBilling = (winningBid) => { + const bids = fetchReceivedBids(winningBid, 'Improper use of triggerBilling. It requires a bid with at least an adUnitCode or an adId to function.'); + const triggerBillingBid = bids.find(bid => bid.requestId === winningBid.requestId) || bids[0]; + + if (bids.length > 0 && triggerBillingBid) { + try { + adapterManager.callBidBillableBidder(triggerBillingBid); + } catch (e) { + logError('Error when triggering billing :', e); + } + } else { + logWarn('The bid provided to triggerBilling did not match any bids received.'); + } }; -export default $$PREBID_GLOBAL$$; +export default pbjsInstance; diff --git a/src/prebidGlobal.js b/src/prebidGlobal.js index 5eed4b3670f..4cbc3e10ad1 100644 --- a/src/prebidGlobal.js +++ b/src/prebidGlobal.js @@ -1,13 +1,21 @@ // if $$PREBID_GLOBAL$$ already exists in global document scope, use it, if not, create the object // global defination should happen BEFORE imports to avoid global undefined errors. -window.$$PREBID_GLOBAL$$ = (window.$$PREBID_GLOBAL$$ || {}); -window.$$PREBID_GLOBAL$$.cmd = window.$$PREBID_GLOBAL$$.cmd || []; -window.$$PREBID_GLOBAL$$.que = window.$$PREBID_GLOBAL$$.que || []; +/* global $$DEFINE_PREBID_GLOBAL$$ */ +const scope = !$$DEFINE_PREBID_GLOBAL$$ ? {} : window; +const global = scope.$$PREBID_GLOBAL$$ = scope.$$PREBID_GLOBAL$$ || {}; +global.cmd = global.cmd || []; +global.que = global.que || []; // create a pbjs global pointer -window._pbjsGlobals = window._pbjsGlobals || []; -window._pbjsGlobals.push('$$PREBID_GLOBAL$$'); +if (scope === window) { + scope._pbjsGlobals = scope._pbjsGlobals || []; + scope._pbjsGlobals.push('$$PREBID_GLOBAL$$'); +} export function getGlobal() { - return window.$$PREBID_GLOBAL$$; + return global; +} + +export function registerModule(name) { + global.installedModules.push(name); } diff --git a/src/refererDetection.js b/src/refererDetection.js index 7e9f2a7e6c7..93ebf085dd5 100644 --- a/src/refererDetection.js +++ b/src/refererDetection.js @@ -9,7 +9,67 @@ */ import { config } from './config.js'; -import { logWarn } from './utils.js'; +import {logWarn} from './utils.js'; + +/** + * Prepend a URL with the page's protocol (http/https), if necessary. + */ +export function ensureProtocol(url, win = window) { + if (!url) return url; + if (/\w+:\/\//.exec(url)) { + // url already has protocol + return url; + } + let windowProto = win.location.protocol; + try { + windowProto = win.top.location.protocol; + } catch (e) {} + if (/^\/\//.exec(url)) { + // url uses relative protocol ("//example.com") + return windowProto + url; + } else { + return `${windowProto}//${url}`; + } +} + +/** + * Extract the domain portion from a URL. + * @param url + * @param noLeadingWww: if true, remove 'www.' appearing at the beginning of the domain. + * @param noPort: if true, do not include the ':[port]' portion + */ +export function parseDomain(url, {noLeadingWww = false, noPort = false} = {}) { + try { + url = new URL(ensureProtocol(url)); + } catch (e) { + return; + } + url = noPort ? url.hostname : url.host; + if (noLeadingWww && url.startsWith('www.')) { + url = url.substring(4); + } + return url; +} + +/** + * This function returns canonical URL which refers to an HTML link element, with the attribute of rel="canonical", found in the element of your webpage + * + * @param {Object} doc document + * @returns {string|null} + */ +function getCanonicalUrl(doc) { + try { + const element = doc.querySelector("link[rel='canonical']"); + + if (element !== null) { + return element.href; + } + } catch (e) { + // Ignore error + } + + return null; +} /** * @param {Window} win Window @@ -35,38 +95,20 @@ export function detectReferer(win) { } } - /** - * This function returns canonical URL which refers to an HTML link element, with the attribute of rel="canonical", found in the element of your webpage - * - * @param {Object} doc document - * @returns {string|null} - */ - function getCanonicalUrl(doc) { - let pageURL = config.getConfig('pageUrl'); - - if (pageURL) return pageURL; - - try { - const element = doc.querySelector("link[rel='canonical']"); - - if (element !== null) { - return element.href; - } - } catch (e) { - // Ignore error - } - - return null; - } + // TODO: the meaning of "reachedTop" seems to be intentionally ambiguous - best to leave them out of + // the typedef for now. (for example, unit tests enforce that "reachedTop" should be false in some situations where we + // happily provide a location for the top). /** - * Referer info * @typedef {Object} refererInfo - * @property {string} referer detected top url - * @property {boolean} reachedTop whether prebid was able to walk upto top window or not - * @property {number} numIframes number of iframes - * @property {string} stack comma separated urls of all origins - * @property {string} canonicalUrl canonical URL refers to an HTML link element, with the attribute of rel="canonical", found in the element of your webpage + * @property {string|null} location the browser's location, or null if not available (due to cross-origin restrictions) + * @property {string|null} canonicalUrl the site's canonical URL as set by the publisher, through setConfig({pageUrl}) or + * @property {string|null} page the best candidate for the current page URL: `canonicalUrl`, falling back to `location` + * @property {string|null} domain the domain portion of `page` + * @property {string|null} ref the referrer (document.referrer) to the current page, or null if not available (due to cross-origin restrictions) + * @property {string} topmostLocation of the top-most frame for which we could guess the location. Outside of cross-origin scenarios, this is equivalent to `location`. + * @property {number} numIframes number of steps between window.self and window.top + * @property {Array[string|null]} stack our best guess at the location for each frame, in the direction top -> self. */ /** @@ -78,20 +120,22 @@ export function detectReferer(win) { const stack = []; const ancestors = getAncestorOrigins(win); const maxNestedIframes = config.getConfig('maxNestedIframes'); + let currentWindow; - let bestReferrer; + let bestLocation; let bestCanonicalUrl; let reachedTop = false; let level = 0; let valuesFromAmp = false; let inAmpFrame = false; + let hasTopLocation = false; do { const previousWindow = currentWindow; const wasInAmpFrame = inAmpFrame; let currentLocation; let crossOrigin = false; - let foundReferrer = null; + let foundLocation = null; inAmpFrame = false; currentWindow = currentWindow ? currentWindow.parent : win; @@ -107,8 +151,9 @@ export function detectReferer(win) { const context = previousWindow.context; try { - foundReferrer = context.sourceUrl; - bestReferrer = foundReferrer; + foundLocation = context.sourceUrl; + bestLocation = foundLocation; + hasTopLocation = true; valuesFromAmp = true; @@ -124,10 +169,11 @@ export function detectReferer(win) { logWarn('Trying to access cross domain iframe. Continuing without referrer and location'); try { + // the referrer to an iframe is the parent window const referrer = previousWindow.document.referrer; if (referrer) { - foundReferrer = referrer; + foundLocation = referrer; if (currentWindow === win.top) { reachedTop = true; @@ -135,18 +181,21 @@ export function detectReferer(win) { } } catch (e) { /* Do nothing */ } - if (!foundReferrer && ancestors && ancestors[level - 1]) { - foundReferrer = ancestors[level - 1]; + if (!foundLocation && ancestors && ancestors[level - 1]) { + foundLocation = ancestors[level - 1]; + if (currentWindow === win.top) { + hasTopLocation = true; + } } - if (foundReferrer && !valuesFromAmp) { - bestReferrer = foundReferrer; + if (foundLocation && !valuesFromAmp) { + bestLocation = foundLocation; } } } else { if (currentLocation) { - foundReferrer = currentLocation; - bestReferrer = foundReferrer; + foundLocation = currentLocation; + bestLocation = foundLocation; valuesFromAmp = false; if (currentWindow === win.top) { @@ -165,23 +214,71 @@ export function detectReferer(win) { } } - stack.push(foundReferrer); + stack.push(foundLocation); level++; } while (currentWindow !== win.top && level < maxNestedIframes); stack.reverse(); + let ref; + try { + ref = win.top.document.referrer; + } catch (e) {} + + const location = reachedTop || hasTopLocation ? bestLocation : null; + const canonicalUrl = config.getConfig('pageUrl') || bestCanonicalUrl || null; + let page = config.getConfig('pageUrl') || location || ensureProtocol(canonicalUrl, win); + + if (location && location.indexOf('?') > -1 && page.indexOf('?') === -1) { + page = `${page}${location.substring(location.indexOf('?'))}`; + } + return { - referer: bestReferrer || null, reachedTop, isAmp: valuesFromAmp, numIframes: level - 1, stack, - canonicalUrl: bestCanonicalUrl || null + topmostLocation: bestLocation || null, + location, + canonicalUrl, + page, + domain: parseDomain(page) || null, + ref: ref || null, + // TODO: the "legacy" refererInfo object is provided here, for now, to accomodate + // adapters that decided to just send it verbatim to their backend. + legacy: { + reachedTop, + isAmp: valuesFromAmp, + numIframes: level - 1, + stack, + referer: bestLocation || null, + canonicalUrl + } }; } return refererInfo; } -export const getRefererInfo = detectReferer(window); +// cache result of fn (= referer info) as long as: +// - we are the top window +// - canonical URL tag and window location have not changed +export function cacheWithLocation(fn, win = window) { + if (win.top !== win) return fn; + let canonical, href, value; + return function () { + const newCanonical = getCanonicalUrl(win.document); + const newHref = win.location.href; + if (canonical !== newCanonical || newHref !== href) { + canonical = newCanonical; + href = newHref; + value = fn(); + } + return value; + } +} + +/** + * @type {function(): refererInfo} + */ +export const getRefererInfo = cacheWithLocation(detectReferer(window)); diff --git a/src/secureCreatives.js b/src/secureCreatives.js index 5cfa25fbbc8..c719bc191f2 100644 --- a/src/secureCreatives.js +++ b/src/secureCreatives.js @@ -4,7 +4,7 @@ */ import * as events from './events.js'; -import { fireNativeTrackers, getAssetMessage, getAllAssetsMessage } from './native.js'; +import {fireNativeTrackers, getAllAssetsMessage, getAssetMessage} from './native.js'; import constants from './constants.json'; import {deepAccess, isApnGetTagDefined, isGptPubadsDefined, logError, logWarn, replaceAuctionPrice} from './utils.js'; import {auctionManager} from './auctionManager.js'; @@ -15,13 +15,19 @@ import {emitAdRenderFail, emitAdRenderSucceeded} from './adRendering.js'; const BID_WON = constants.EVENTS.BID_WON; const STALE_RENDER = constants.EVENTS.STALE_RENDER; +const WON_AD_IDS = new WeakSet(); const HANDLER_MAP = { 'Prebid Request': handleRenderRequest, - 'Prebid Native': handleNativeRequest, 'Prebid Event': handleEventRequest, } +if (FEATURES.NATIVE) { + Object.assign(HANDLER_MAP, { + 'Prebid Native': handleNativeRequest, + }) +} + export function listenMessagesFromCreative() { window.addEventListener('message', receiveMessage, false); } @@ -67,7 +73,7 @@ function handleRenderRequest(reply, data, adObject) { if (adObject == null) { emitAdRenderFail({ reason: constants.AD_RENDER_FAILED_REASON.CANNOT_FIND_AD, - message: `Cannot find ad '${data.adId}' for cross-origin render request`, + message: `Cannot find ad for cross-origin render request: '${data.adId}'`, id: data.adId }); return; @@ -105,9 +111,16 @@ function handleNativeRequest(reply, data, adObject) { // adId: '%%PATTERN:hb_adid%%' // }), '*'); if (adObject == null) { - logError(`Cannot find ad '${data.adId}' for x-origin event request`); + logError(`Cannot find ad for x-origin event request: '${data.adId}'`); return; } + + if (!WON_AD_IDS.has(adObject)) { + WON_AD_IDS.add(adObject); + auctionManager.addWinningBid(adObject); + events.emit(BID_WON, adObject); + } + switch (data.action) { case 'assetRequest': reply(getAssetMessage(data, adObject)); @@ -121,12 +134,7 @@ function handleNativeRequest(reply, data, adObject) { resizeRemoteCreative(adObject); break; default: - const trackerType = fireNativeTrackers(data, adObject); - if (trackerType === 'click') { - return; - } - auctionManager.addWinningBid(adObject); - events.emit(BID_WON, adObject); + fireNativeTrackers(data, adObject); } } @@ -185,7 +193,7 @@ function resizeRemoteCreative({ adId, adUnitCode, width, height }) { let element = getElementByAdUnit(elmType + ':not([style*="display: none"])'); if (element) { let elementStyle = element.style; - elementStyle.width = width + 'px'; + elementStyle.width = width ? width + 'px' : '100%'; elementStyle.height = height + 'px'; } else { logWarn(`Unable to locate matching page element for adUnitCode ${adUnitCode}. Can't resize it to ad's dimensions. Please review setup.`); diff --git a/src/storageManager.js b/src/storageManager.js index 30e8d4c8abb..87d714f77b8 100644 --- a/src/storageManager.js +++ b/src/storageManager.js @@ -1,65 +1,49 @@ -import {hook} from './hook.js'; -import {hasDeviceAccess, checkCookieSupport, logError, logInfo, isPlainObject} from './utils.js'; -import {includes} from './polyfill.js'; -import {bidderSettings as defaultBidderSettings} from './bidderSettings.js'; +import {checkCookieSupport, hasDeviceAccess, logError} from './utils.js'; +import {bidderSettings} from './bidderSettings.js'; +import {MODULE_TYPE_BIDDER, MODULE_TYPE_PREBID} from './activities/modules.js'; +import {isActivityAllowed, registerActivityControl} from './activities/rules.js'; +import { + ACTIVITY_PARAM_ADAPTER_CODE, + ACTIVITY_PARAM_COMPONENT_TYPE, + ACTIVITY_PARAM_STORAGE_TYPE +} from './activities/params.js'; -const moduleTypeWhiteList = ['core', 'prebid-module']; +import {ACTIVITY_ACCESS_DEVICE} from './activities/activities.js'; +import {config} from './config.js'; +import adapterManager from './adapterManager.js'; +import {activityParams} from './activities/activityParams.js'; -export let storageCallbacks = []; +export const STORAGE_TYPE_LOCALSTORAGE = 'html5'; +export const STORAGE_TYPE_COOKIES = 'cookie'; -/** - * Storage options - * @typedef {Object} storageOptions - * @property {Number=} gvlid - Vendor id - * @property {string} moduleName? - Module name - * @property {string=} bidderCode? - Bidder code - * @property {string=} moduleType - Module type, value can be anyone of core or prebid-module - */ +export let storageCallbacks = []; -/** - * Returns list of storage related functions with gvlid, module name and module type in its scope. - * All three argument are optional here. Below shows the usage of of these - * - GVL Id: Pass GVL id if you are a vendor - * - Bidder code: All bid adapters need to pass bidderCode - * - Module name: All other modules need to pass module name - * - Module type: Some modules may need these functions but are not vendor. e.g prebid core files in src and modules like currency. - * @param {storageOptions} options +/* + * Storage manager constructor. Consumers should prefer one of `getStorageManager` or `getCoreStorageManager`. */ -export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = {}, {bidderSettings = defaultBidderSettings} = {}) { - function isBidderDisallowed() { - if (bidderCode == null) { - return false; +export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = isActivityAllowed} = {}) { + function isValid(cb, storageType) { + let mod = moduleName; + const curBidder = config.getCurrentBidder(); + if (curBidder && moduleType === MODULE_TYPE_BIDDER && adapterManager.aliasRegistry[curBidder] === moduleName) { + mod = curBidder; } - const storageAllowed = bidderSettings.get(bidderCode, 'storageAllowed'); - return storageAllowed == null ? false : !storageAllowed; + const result = { + valid: isAllowed(ACTIVITY_ACCESS_DEVICE, activityParams(moduleType, mod, { + [ACTIVITY_PARAM_STORAGE_TYPE]: storageType + })) + }; + return cb(result); } - function isValid(cb) { - if (includes(moduleTypeWhiteList, moduleType)) { - let result = { - valid: true - } - return cb(result); - } else if (isBidderDisallowed()) { - logInfo(`bidderSettings denied access to device storage for bidder '${bidderCode}'`); - const result = {valid: false}; - return cb(result); - } else { - let value; - let hookDetails = { - hasEnforcementHook: false - } - validateStorageEnforcement(gvlid, bidderCode || moduleName, hookDetails, function(result) { - if (result && result.hasEnforcementHook) { - value = cb(result); - } else { - let result = { - hasEnforcementHook: false, - valid: hasDeviceAccess() - } - value = cb(result); - } + + function schedule(operation, storageType, done) { + if (done && typeof done === 'function') { + storageCallbacks.push(function() { + let result = isValid(operation, storageType); + done(result); }); - return value; + } else { + return isValid(operation, storageType); } } @@ -83,14 +67,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = document.cookie = `${key}=${encodeURIComponent(value)}${expiresPortion}; path=/${domainPortion}${sameSite ? `; SameSite=${sameSite}` : ''}${secure}`; } } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_COOKIES, done); }; /** @@ -105,14 +82,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = } return null; } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_COOKIES, done); }; /** @@ -133,14 +103,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = } return false; } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done); } /** @@ -149,22 +112,11 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = const cookiesAreEnabled = function (done) { let cb = function (result) { if (result && result.valid) { - if (checkCookieSupport()) { - return true; - } - window.document.cookie = 'prebid.cookieTest'; - return window.document.cookie.indexOf('prebid.cookieTest') !== -1; + return checkCookieSupport(); } return false; } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_COOKIES, done); } /** @@ -177,14 +129,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = window.localStorage.setItem(key, value); } } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done); } /** @@ -198,14 +143,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = } return null; } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done); } /** @@ -217,14 +155,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = window.localStorage.removeItem(key); } } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done); } /** @@ -241,14 +172,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = } return false; } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done); } /** @@ -277,14 +201,7 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = } } - if (done && typeof done === 'function') { - storageCallbacks.push(function() { - let result = isValid(cb); - done(result); - }); - } else { - return isValid(cb); - } + return schedule(cb, STORAGE_TYPE_COOKIES, done); } return { @@ -301,35 +218,66 @@ export function newStorageManager({gvlid, moduleName, bidderCode, moduleType} = } /** - * This hook validates the storage enforcement if gdprEnforcement module is included + * Get a storage manager for a particular module. + * + * Either bidderCode or a combination of moduleType + moduleName must be provided. The former is a shorthand + * for `{moduleType: 'bidder', moduleName: bidderCode}`. + * */ -export const validateStorageEnforcement = hook('async', function(gvlid, moduleName, hookDetails, callback) { - callback(hookDetails); -}, 'validateStorageEnforcement'); +export function getStorageManager({moduleType, moduleName, bidderCode} = {}) { + function err() { + throw new Error(`Invalid invocation for getStorageManager: must set either bidderCode, or moduleType + moduleName`) + } + if (bidderCode) { + if ((moduleType && moduleType !== MODULE_TYPE_BIDDER) || moduleName) err() + moduleType = MODULE_TYPE_BIDDER; + moduleName = bidderCode; + } else if (!moduleName || !moduleType) { + err() + } + return newStorageManager({moduleType, moduleName}); +} /** - * This function returns storage functions to access cookies and localstorage. This function will bypass the gdpr enforcement requirement. Prebid as a software needs to use storage in some scenarios and is not a vendor so GDPR enforcement rules does not apply on Prebid. + * Get a storage manager for "core" (vendorless, or first-party) modules. Shorthand for `getStorageManager({moduleName, moduleType: 'core'})`. + * * @param {string} moduleName Module name */ export function getCoreStorageManager(moduleName) { - return newStorageManager({moduleName: moduleName, moduleType: 'core'}); + return newStorageManager({moduleName: moduleName, moduleType: MODULE_TYPE_PREBID}); +} + +/** + * Block all access to storage when deviceAccess = false + */ +export function deviceAccessRule() { + if (!hasDeviceAccess()) { + return {allow: false} + } } +registerActivityControl(ACTIVITY_ACCESS_DEVICE, 'deviceAccess config', deviceAccessRule); /** - * Note: Core modules or Prebid modules like Currency, SizeMapping should use getCoreStorageManager - * This function returns storage functions to access cookies and localstorage. Bidders and User id modules should import this and use it in their module if needed. - * Bid adapters should always provide `bidderCode`. GVL ID and Module name are optional param but gvl id is needed for when gdpr enforcement module is used. - * @param {Number=} gvlid? Vendor id - required for proper GDPR integration - * @param {string=} bidderCode? - required for bid adapters - * @param {string=} moduleName? module name + * By default, deny bidders accessDevice unless they enable it through bidderSettings + * + * // TODO: for backwards compat, the check is done on the adapter - rather than bidder's code. */ -export function getStorageManager({gvlid, moduleName, bidderCode} = {}) { - if (arguments.length > 1 || (arguments.length > 0 && !isPlainObject(arguments[0]))) { - throw new Error('Invalid invocation for getStorageManager') +export function storageAllowedRule(params, bs = bidderSettings) { + if (params[ACTIVITY_PARAM_COMPONENT_TYPE] !== MODULE_TYPE_BIDDER) return; + let allow = bs.get(params[ACTIVITY_PARAM_ADAPTER_CODE], 'storageAllowed'); + if (!allow || allow === true) { + allow = !!allow + } else { + const storageType = params[ACTIVITY_PARAM_STORAGE_TYPE]; + allow = Array.isArray(allow) ? allow.some((e) => e === storageType) : allow === storageType; + } + if (!allow) { + return {allow}; } - return newStorageManager({gvlid, moduleName, bidderCode}); } +registerActivityControl(ACTIVITY_ACCESS_DEVICE, 'bidderSettings.*.storageAllowed', storageAllowedRule); + export function resetData() { storageCallbacks = []; } diff --git a/src/targeting.js b/src/targeting.js index 6a80ce10806..0aa395aa9a3 100644 --- a/src/targeting.js +++ b/src/targeting.js @@ -1,22 +1,33 @@ import { - uniques, isGptPubadsDefined, getHighestCpm, getOldestHighestCpmBid, groupBy, isAdUnitCodeMatchingSlot, timestamp, - deepAccess, deepClone, logError, logWarn, logInfo, isFn, isArray, logMessage, isStr, + deepAccess, + deepClone, + groupBy, + isAdUnitCodeMatchingSlot, + isArray, + isFn, + isGptPubadsDefined, + isStr, + logError, + logInfo, + logMessage, + logWarn, + timestamp, + uniques, } from './utils.js'; -import { config } from './config.js'; -import { NATIVE_TARGETING_KEYS } from './native.js'; -import { auctionManager } from './auctionManager.js'; -import { sizeSupported } from './sizeMapping.js'; -import { ADPOD } from './mediaTypes.js'; -import { hook } from './hook.js'; -import { bidderSettings } from './bidderSettings.js'; -import {includes, find} from './polyfill.js'; - -var CONSTANTS = require('./constants.json'); +import {config} from './config.js'; +import {NATIVE_TARGETING_KEYS} from './native.js'; +import {auctionManager} from './auctionManager.js'; +import {ADPOD} from './mediaTypes.js'; +import {hook} from './hook.js'; +import {bidderSettings} from './bidderSettings.js'; +import {find, includes} from './polyfill.js'; +import CONSTANTS from './constants.json'; +import {getHighestCpm, getOldestHighestCpmBid} from './utils/reducers.js'; +import {getTTL} from './bidTTL.js'; var pbTargetingKeys = []; const MAX_DFP_KEYLENGTH = 20; -const TTL_BUFFER = 1000; const CFG_ALLOW_TARGETING_KEYS = `targetingControls.allowTargetingKeys`; const CFG_ADD_TARGETING_KEYS = `targetingControls.addTargetingKeys`; @@ -27,16 +38,23 @@ export const TARGETING_KEYS = Object.keys(CONSTANTS.TARGETING_KEYS).map( ); // return unexpired bids -const isBidNotExpired = (bid) => (bid.responseTimestamp + bid.ttl * 1000 - TTL_BUFFER) > timestamp(); +const isBidNotExpired = (bid) => (bid.responseTimestamp + getTTL(bid) * 1000) > timestamp(); // return bids whose status is not set. Winning bids can only have a status of `rendered`. const isUnusedBid = (bid) => bid && ((bid.status && !includes([CONSTANTS.BID_STATUS.RENDERED], bid.status)) || !bid.status); export let filters = { + isActualBid(bid) { + return bid.getStatusCode() === CONSTANTS.STATUS.GOOD + }, isBidNotExpired, isUnusedBid }; +export function isBidUsable(bid) { + return !Object.values(filters).some((predicate) => !predicate(bid)); +} + // If two bids are found for same adUnitCode, we will use the highest one to take part in auction // This can happen in case of concurrent auctions // If adUnitBidLimit is set above 0 return top N number of bids @@ -64,7 +82,7 @@ export const getHighestCpmBidsFromBidPool = hook('sync', function(bidsReceived, } return bidsReceived; -}) +}); /** * A descending sort function that will sort the list of objects based on the following two dimensions: @@ -177,7 +195,7 @@ export function newTargeting(auctionManager) { */ function getDealBids(adUnitCodes, bidsReceived) { if (config.getConfig('targetingControls.alwaysIncludeDeals') === true) { - const standardKeys = TARGETING_KEYS.concat(NATIVE_TARGETING_KEYS); + const standardKeys = FEATURES.NATIVE ? TARGETING_KEYS.concat(NATIVE_TARGETING_KEYS) : TARGETING_KEYS.slice(); // we only want the top bid from bidders who have multiple entries per ad unit code const bids = getHighestCpmBidsFromBidPool(bidsReceived, getHighestCpm); @@ -450,10 +468,7 @@ export function newTargeting(auctionManager) { bidsReceived = bidsReceived .filter(bid => deepAccess(bid, 'video.context') !== ADPOD) - .filter(bid => bid.mediaType !== 'banner' || sizeSupported([bid.width, bid.height])) - .filter(filters.isUnusedBid) - .filter(filters.isBidNotExpired) - ; + .filter(isBidUsable); return getHighestCpmBidsFromBidPool(bidsReceived, getOldestHighestCpmBid); } @@ -584,7 +599,10 @@ export function newTargeting(auctionManager) { } function getCustomKeys() { - let standardKeys = getStandardKeys().concat(NATIVE_TARGETING_KEYS); + let standardKeys = getStandardKeys(); + if (FEATURES.NATIVE) { + standardKeys = standardKeys.concat(NATIVE_TARGETING_KEYS); + } return function(key) { return standardKeys.indexOf(key) === -1; } @@ -624,7 +642,7 @@ export function newTargeting(auctionManager) { * @return {targetingArray} all non-winning bids targeting */ function getBidLandscapeTargeting(adUnitCodes, bidsReceived) { - const standardKeys = TARGETING_KEYS.concat(NATIVE_TARGETING_KEYS); + const standardKeys = FEATURES.NATIVE ? TARGETING_KEYS.concat(NATIVE_TARGETING_KEYS) : TARGETING_KEYS.slice(); const adUnitBidLimit = config.getConfig('sendBidsControl.bidLimit'); const bids = getHighestCpmBidsFromBidPool(bidsReceived, getHighestCpm, adUnitBidLimit); const allowSendAllBidsTargetingKeys = config.getConfig('targetingControls.allowSendAllBidsTargetingKeys'); diff --git a/src/userSync.js b/src/userSync.js index 96c3d662cad..936836eb12e 100644 --- a/src/userSync.js +++ b/src/userSync.js @@ -5,6 +5,15 @@ import { import { config } from './config.js'; import {includes} from './polyfill.js'; import { getCoreStorageManager } from './storageManager.js'; +import {isActivityAllowed, registerActivityControl} from './activities/rules.js'; +import {ACTIVITY_SYNC_USER} from './activities/activities.js'; +import { + ACTIVITY_PARAM_COMPONENT_NAME, + ACTIVITY_PARAM_COMPONENT_TYPE, + ACTIVITY_PARAM_SYNC_TYPE, ACTIVITY_PARAM_SYNC_URL +} from './activities/params.js'; +import {MODULE_TYPE_BIDDER} from './activities/modules.js'; +import {activityParams} from './activities/activityParams.js'; export const USERSYNC_DEFAULT_CONFIG = { syncEnabled: true, @@ -29,10 +38,10 @@ const storage = getCoreStorageManager('usersync'); /** * Factory function which creates a new UserSyncPool. * - * @param {UserSyncDependencies} userSyncDependencies Configuration options and dependencies which the + * @param {} deps Configuration options and dependencies which the * UserSync object needs in order to behave properly. */ -export function newUserSync(userSyncDependencies) { +export function newUserSync(deps) { let publicApi = {}; // A queue of user syncs for each adapter // Let getDefaultQueue() set the defaults @@ -50,7 +59,7 @@ export function newUserSync(userSyncDependencies) { }; // Use what is in config by default - let usConfig = userSyncDependencies.config; + let usConfig = deps.config; // Update if it's (re)set config.getConfig('userSync', (conf) => { // Added this logic for https://github.com/prebid/Prebid.js/issues/4864 @@ -70,6 +79,19 @@ export function newUserSync(userSyncDependencies) { usConfig = Object.assign(usConfig, conf.userSync); }); + deps.regRule(ACTIVITY_SYNC_USER, 'userSync config', (params) => { + if (!usConfig.syncEnabled) { + return {allow: false, reason: 'syncs are disabled'} + } + if (params[ACTIVITY_PARAM_COMPONENT_TYPE] === MODULE_TYPE_BIDDER) { + const syncType = params[ACTIVITY_PARAM_SYNC_TYPE]; + const bidder = params[ACTIVITY_PARAM_COMPONENT_NAME]; + if (!publicApi.canBidderRegisterSync(syncType, bidder)) { + return {allow: false, reason: `${syncType} syncs are not enabled for ${bidder}`} + } + } + }); + /** * @function getDefaultQueue * @summary Returns the default empty queue @@ -89,7 +111,7 @@ export function newUserSync(userSyncDependencies) { * @private */ function fireSyncs() { - if (!usConfig.syncEnabled || !userSyncDependencies.browserSupportsCookies) { + if (!usConfig.syncEnabled || !deps.browserSupportsCookies) { return; } @@ -109,10 +131,7 @@ export function newUserSync(userSyncDependencies) { // Randomize the order of the pixels before firing // This is to avoid giving any bidder who has registered multiple syncs // any preferential treatment and balancing them out - shuffle(queue).forEach((sync) => { - fn(sync); - hasFiredBidder.add(sync[0]); - }); + shuffle(queue).forEach(fn); } /** @@ -202,16 +221,22 @@ export function newUserSync(userSyncDependencies) { return logWarn(`Number of user syncs exceeded for "${bidder}"`); } - const canBidderRegisterSync = publicApi.canBidderRegisterSync(type, bidder); - if (!canBidderRegisterSync) { - return logWarn(`Bidder "${bidder}" not permitted to register their "${type}" userSync pixels.`); + if (deps.isAllowed(ACTIVITY_SYNC_USER, activityParams(MODULE_TYPE_BIDDER, bidder, { + [ACTIVITY_PARAM_SYNC_TYPE]: type, + [ACTIVITY_PARAM_SYNC_URL]: url + }))) { + // the bidder's pixel has passed all checks and is allowed to register + queue[type].push([bidder, url]); + numAdapterBids = incrementAdapterBids(numAdapterBids, bidder); } - - // the bidder's pixel has passed all checks and is allowed to register - queue[type].push([bidder, url]); - numAdapterBids = incrementAdapterBids(numAdapterBids, bidder); }; + /** + * Mark a bidder as done with its user syncs - no more will be accepted from them in this session. + * @param {string} bidderCode + */ + publicApi.bidderDone = hasFiredBidder.add.bind(hasFiredBidder); + /** * @function shouldBidderBeBlocked * @summary Check filterSettings logic to determine if the bidder should be prevented from registering their userSync tracker @@ -311,23 +336,22 @@ export function newUserSync(userSyncDependencies) { } } return true; - } + }; return publicApi; } -const browserSupportsCookies = !isSafariBrowser() && storage.cookiesAreEnabled(); - -export const userSync = newUserSync({ +export const userSync = newUserSync(Object.defineProperties({ config: config.getConfig('userSync'), - browserSupportsCookies: browserSupportsCookies -}); - -/** - * @typedef {Object} UserSyncDependencies - * - * @property {UserSyncConfig} config - * @property {boolean} browserSupportsCookies True if the current browser supports cookies, and false otherwise. - */ + isAllowed: isActivityAllowed, + regRule: registerActivityControl, +}, { + browserSupportsCookies: { + get: function() { + // call storage lazily to give time for consent data to be available + return !isSafariBrowser() && storage.cookiesAreEnabled(); + } + } +})); /** * @typedef {Object} UserSyncConfig diff --git a/src/utils.js b/src/utils.js index 33755a4fb82..256dfb15174 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,14 +1,13 @@ -/* eslint-disable no-console */ -import { config } from './config.js'; +import {config} from './config.js'; import clone from 'just-clone'; -import {find, includes} from './polyfill.js'; - -const CONSTANTS = require('./constants.json'); +import {includes} from './polyfill.js'; +import CONSTANTS from './constants.json'; +import {GreedyPromise} from './utils/promise.js'; +import {getGlobal} from './prebidGlobal.js'; export { default as deepAccess } from 'dlv/index.js'; -export { default as deepSetValue } from 'dset'; +export { dset as deepSetValue } from 'dset'; -var tArr = 'Array'; var tStr = 'String'; var tFn = 'Function'; var tNumb = 'Number'; @@ -21,16 +20,20 @@ let consoleInfoExists = Boolean(consoleExists && window.console.info); let consoleWarnExists = Boolean(consoleExists && window.console.warn); let consoleErrorExists = Boolean(consoleExists && window.console.error); -const emitEvent = (function () { - // lazy load events to avoid circular import - let ev; - return function() { - if (ev == null) { - ev = require('./events.js'); - } - return ev.emit.apply(ev, arguments); +let eventEmitter; + +const pbjsInstance = getGlobal(); + +export function _setEventEmitter(emitFn) { + // called from events.js - this hoop is to avoid circular imports + eventEmitter = emitFn; +} + +function emitEvent(...args) { + if (eventEmitter != null) { + eventEmitter(...args); } -})(); +} // this allows stubbing of utility functions that are used internally by other utility functions export const internal = { @@ -52,7 +55,7 @@ export const internal = { deepEqual }; -let prebidInternal = {} +let prebidInternal = {}; /** * Returns object that is used as internal prebid namespace */ @@ -60,17 +63,6 @@ export function getPrebidInternal() { return prebidInternal; } -var uniqueRef = {}; -export let bind = function(a, b) { return b; }.bind(null, 1, uniqueRef)() === uniqueRef - ? Function.prototype.bind - : function(bind) { - var self = this; - var args = Array.prototype.slice.call(arguments, 1); - return function() { - return self.apply(bind, args.concat(Array.prototype.slice.call(arguments))); - }; - }; - /* utility method to get incremental integer starting from 1 */ var getIncrementalInteger = (function () { var count = 0; @@ -110,19 +102,7 @@ function _getRandomData() { } export function getBidIdParameter(key, paramsObj) { - if (paramsObj && paramsObj[key]) { - return paramsObj[key]; - } - - return ''; -} - -export function tryAppendQueryString(existingUrl, key, value) { - if (value) { - return existingUrl + key + '=' + encodeURIComponent(value) + '&'; - } - - return existingUrl; + return paramsObj?.[key] || ''; } // parse a query string object passed in bid params @@ -141,84 +121,30 @@ export function parseQueryStringParameters(queryObj) { export function transformAdServerTargetingObj(targeting) { // we expect to receive targeting for a single slot at a time if (targeting && Object.getOwnPropertyNames(targeting).length > 0) { - return getKeys(targeting) - .map(key => `${key}=${encodeURIComponent(getValue(targeting, key))}`).join('&'); + return Object.keys(targeting) + .map(key => `${key}=${encodeURIComponent(targeting[key])}`).join('&'); } else { return ''; } } -/** - * Read an adUnit object and return the sizes used in an [[728, 90]] format (even if they had [728, 90] defined) - * Preference is given to the `adUnit.mediaTypes.banner.sizes` object over the `adUnit.sizes` - * @param {object} adUnit one adUnit object from the normal list of adUnits - * @returns {Array.} array of arrays containing numeric sizes - */ -export function getAdUnitSizes(adUnit) { - if (!adUnit) { - return; - } - - let sizes = []; - if (adUnit.mediaTypes && adUnit.mediaTypes.banner && Array.isArray(adUnit.mediaTypes.banner.sizes)) { - let bannerSizes = adUnit.mediaTypes.banner.sizes; - if (Array.isArray(bannerSizes[0])) { - sizes = bannerSizes; - } else { - sizes.push(bannerSizes); - } - // TODO - remove this else block when we're ready to deprecate adUnit.sizes for bidders - } else if (Array.isArray(adUnit.sizes)) { - if (Array.isArray(adUnit.sizes[0])) { - sizes = adUnit.sizes; - } else { - sizes.push(adUnit.sizes); - } - } - return sizes; -} - /** * Parse a GPT-Style general size Array like `[[300, 250]]` or `"300x250,970x90"` into an array of sizes `["300x250"]` or '['300x250', '970x90']' * @param {(Array.|Array.)} sizeObj Input array or double array [300,250] or [[300,250], [728,90]] * @return {Array.} Array of strings like `["300x250"]` or `["300x250", "728x90"]` */ export function parseSizesInput(sizeObj) { - var parsedSizes = []; - - // if a string for now we can assume it is a single size, like "300x250" if (typeof sizeObj === 'string') { // multiple sizes will be comma-separated - var sizes = sizeObj.split(','); - - // regular expression to match strigns like 300x250 - // start of line, at least 1 number, an "x" , then at least 1 number, and the then end of the line - var sizeRegex = /^(\d)+x(\d)+$/i; - if (sizes) { - for (var curSizePos in sizes) { - if (hasOwn(sizes, curSizePos) && sizes[curSizePos].match(sizeRegex)) { - parsedSizes.push(sizes[curSizePos]); - } - } - } + return sizeObj.split(',').filter(sz => sz.match(/^(\d)+x(\d)+$/i)) } else if (typeof sizeObj === 'object') { - var sizeArrayLength = sizeObj.length; - - // don't process empty array - if (sizeArrayLength > 0) { - // if we are a 2 item array of 2 numbers, we must be a SingleSize array - if (sizeArrayLength === 2 && typeof sizeObj[0] === 'number' && typeof sizeObj[1] === 'number') { - parsedSizes.push(parseGPTSingleSizeArray(sizeObj)); - } else { - // otherwise, we must be a MultiSize array - for (var i = 0; i < sizeArrayLength; i++) { - parsedSizes.push(parseGPTSingleSizeArray(sizeObj[i])); - } - } + if (sizeObj.length === 2 && typeof sizeObj[0] === 'number' && typeof sizeObj[1] === 'number') { + return [parseGPTSingleSizeArray(sizeObj)]; + } else { + return sizeObj.map(parseGPTSingleSizeArray) } } - - return parsedSizes; + return []; } // Parse a GPT style single size array, (i.e [300, 250]) @@ -259,18 +185,21 @@ export function getWindowLocation() { */ export function logMessage() { if (debugTurnedOn() && consoleLogExists) { + // eslint-disable-next-line no-console console.log.apply(console, decorateLog(arguments, 'MESSAGE:')); } } export function logInfo() { if (debugTurnedOn() && consoleInfoExists) { + // eslint-disable-next-line no-console console.info.apply(console, decorateLog(arguments, 'INFO:')); } } export function logWarn() { if (debugTurnedOn() && consoleWarnExists) { + // eslint-disable-next-line no-console console.warn.apply(console, decorateLog(arguments, 'WARNING:')); } emitEvent(CONSTANTS.EVENTS.AUCTION_DEBUG, {type: 'WARNING', arguments: arguments}); @@ -278,6 +207,7 @@ export function logWarn() { export function logError() { if (debugTurnedOn() && consoleErrorExists) { + // eslint-disable-next-line no-console console.error.apply(console, decorateLog(arguments, 'ERROR:')); } emitEvent(CONSTANTS.EVENTS.AUCTION_DEBUG, {type: 'ERROR', arguments: arguments}); @@ -337,6 +267,9 @@ export function createInvisibleIframe() { f.frameBorder = '0'; f.src = 'about:blank'; f.style.display = 'none'; + f.style.height = '0px'; + f.style.width = '0px'; + f.allowtransparency = 'true'; return f; } @@ -367,9 +300,7 @@ export function isStr(object) { return isA(object, tStr); } -export function isArray(object) { - return isA(object, tArr); -} +export const isArray = Array.isArray.bind(Array); export function isNumber(object) { return isA(object, tNumb); @@ -394,12 +325,7 @@ export function isEmpty(object) { if (isArray(object) || isStr(object)) { return !(object.length > 0); } - - for (var k in object) { - if (hasOwnProperty.call(object, k)) return false; - } - - return true; + return Object.keys(object).length <= 0; } /** @@ -418,38 +344,12 @@ export function isEmptyStr(str) { * @param {Function(value, key, object)} fn */ export function _each(object, fn) { - if (isEmpty(object)) return; - if (isFn(object.forEach)) return object.forEach(fn, this); - - var k = 0; - var l = object.length; - - if (l > 0) { - for (; k < l; k++) fn(object[k], k, object); - } else { - for (k in object) { - if (hasOwnProperty.call(object, k)) fn.call(this, object[k], k); - } - } + if (isFn(object?.forEach)) return object.forEach(fn, this); + Object.entries(object || {}).forEach(([k, v]) => fn.call(this, v, k)); } export function contains(a, obj) { - if (isEmpty(a)) { - return false; - } - - if (isFn(a.indexOf)) { - return a.indexOf(obj) !== -1; - } - - var i = a.length; - while (i--) { - if (a[i] === obj) { - return true; - } - } - - return false; + return isFn(a?.includes) && a.includes(obj); } /** @@ -460,31 +360,17 @@ export function contains(a, obj) { * @return {Array} */ export function _map(object, callback) { - if (isEmpty(object)) return []; - if (isFn(object.map)) return object.map(callback); - var output = []; - _each(object, function (value, key) { - output.push(callback(value, key, object)); - }); - - return output; + if (isFn(object?.map)) return object.map(callback); + return Object.entries(object || {}).map(([k, v]) => callback(v, k, object)) } -export function hasOwn(objectToCheck, propertyToCheckFor) { - if (objectToCheck.hasOwnProperty) { - return objectToCheck.hasOwnProperty(propertyToCheckFor); - } else { - return (typeof objectToCheck[propertyToCheckFor] !== 'undefined') && (objectToCheck.constructor.prototype[propertyToCheckFor] !== objectToCheck[propertyToCheckFor]); - } -}; - /* * Inserts an element(elm) as targets child, by default as first child * @param {HTMLElement} elm * @param {HTMLElement} [doc] * @param {HTMLElement} [target] * @param {Boolean} [asLastChildChild] -* @return {HTMLElement} +* @return {HTML Element} */ export function insertElement(elm, doc, target, asLastChildChild) { doc = doc || document; @@ -514,7 +400,7 @@ export function insertElement(elm, doc, target, asLastChildChild) { */ export function waitForElementToLoad(element, timeout) { let timer = null; - return new Promise((resolve) => { + return new GreedyPromise((resolve) => { const onLoad = function() { element.removeEventListener('load', onLoad); element.removeEventListener('error', onLoad); @@ -560,27 +446,14 @@ export function insertHtmlIntoIframe(htmlCode) { if (!htmlCode) { return; } - - let iframe = document.createElement('iframe'); - iframe.id = getUniqueIdentifierStr(); - iframe.width = 0; - iframe.height = 0; - iframe.hspace = '0'; - iframe.vspace = '0'; - iframe.marginWidth = '0'; - iframe.marginHeight = '0'; - iframe.style.display = 'none'; - iframe.style.height = '0px'; - iframe.style.width = '0px'; - iframe.scrolling = 'no'; - iframe.frameBorder = '0'; - iframe.allowtransparency = 'true'; - + const iframe = createInvisibleIframe(); internal.insertElement(iframe, document, 'body'); - iframe.contentWindow.document.open(); - iframe.contentWindow.document.write(htmlCode); - iframe.contentWindow.document.close(); + ((doc) => { + doc.open(); + doc.write(htmlCode); + doc.close(); + })(iframe.contentWindow.document); } /** @@ -646,19 +519,6 @@ export function createTrackPixelIframeHtml(url, encodeUri = true, sandbox = '') `; } -export function getValueString(param, val, defaultValue) { - if (val === undefined || val === null) { - return defaultValue; - } - if (isStr(val)) { - return val; - } - if (isNumber(val)) { - return val.toString(); - } - internal.logWarn('Unsuported type for param: ' + param + ' required type: String'); -} - export function uniques(value, index, arry) { return arry.indexOf(value) === index; } @@ -671,42 +531,18 @@ export function getBidRequest(id, bidderRequests) { if (!id) { return; } - let bidRequest; - bidderRequests.some(bidderRequest => { - let result = find(bidderRequest.bids, bid => ['bidId', 'adId', 'bid_id'].some(type => bid[type] === id)); - if (result) { - bidRequest = result; - } - return result; - }); - return bidRequest; -} - -export function getKeys(obj) { - return Object.keys(obj); + return bidderRequests.flatMap(br => br.bids) + .find(bid => ['bidId', 'adId', 'bid_id'].some(prop => bid[prop] === id)) } export function getValue(obj, key) { return obj[key]; } -/** - * Get the key of an object for a given value - */ -export function getKeyByValue(obj, value) { - for (let prop in obj) { - if (obj.hasOwnProperty(prop)) { - if (obj[prop] === value) { - return prop; - } - } - } -} - -export function getBidderCodes(adUnits = $$PREBID_GLOBAL$$.adUnits) { +export function getBidderCodes(adUnits = pbjsInstance.adUnits) { // this could memoize adUnits return adUnits.map(unit => unit.bids.map(bid => bid.bidder) - .reduce(flatten, [])).reduce(flatten, []).filter(uniques); + .reduce(flatten, [])).reduce(flatten, []).filter((bidder) => typeof bidder !== 'undefined').filter(uniques); } export function isGptPubadsDefined() { @@ -721,26 +557,6 @@ export function isApnGetTagDefined() { } } -// This function will get highest cpm value bid, in case of tie it will return the bid with lowest timeToRespond -export const getHighestCpm = getHighestCpmCallback('timeToRespond', (previous, current) => previous > current); - -// This function will get the oldest hightest cpm value bid, in case of tie it will return the bid which came in first -// Use case for tie: https://github.com/prebid/Prebid.js/issues/2448 -export const getOldestHighestCpmBid = getHighestCpmCallback('responseTimestamp', (previous, current) => previous > current); - -// This function will get the latest hightest cpm value bid, in case of tie it will return the bid which came in last -// Use case for tie: https://github.com/prebid/Prebid.js/issues/2539 -export const getLatestHighestCpmBid = getHighestCpmCallback('responseTimestamp', (previous, current) => previous < current); - -function getHighestCpmCallback(useTieBreakerProperty, tieBreakerCallback) { - return (previous, current) => { - if (previous.cpm === current.cpm) { - return tieBreakerCallback(previous[useTieBreakerProperty], current[useTieBreakerProperty]) ? current : previous; - } - return previous.cpm < current.cpm ? current : previous; - } -} - /** * Fisher–Yates shuffle * http://stackoverflow.com/a/6274398 @@ -767,10 +583,6 @@ export function shuffle(array) { return array; } -export function adUnitsFilter(filter, bid) { - return includes(filter, bid && bid.adUnitCode); -} - export function deepClone(obj) { return clone(obj); } @@ -900,7 +712,7 @@ export function isValidMediaTypes(mediaTypes) { return false; } - if (mediaTypes.video && mediaTypes.video.context) { + if (FEATURES.VIDEO && mediaTypes.video && mediaTypes.video.context) { return includes(SUPPORTED_STREAM_TYPES, mediaTypes.video.context); } @@ -917,22 +729,10 @@ export function isValidMediaTypes(mediaTypes) { export function getUserConfiguredParams(adUnits, adUnitCode, bidder) { return adUnits .filter(adUnit => adUnit.code === adUnitCode) - .map((adUnit) => adUnit.bids) - .reduce(flatten, []) + .flatMap((adUnit) => adUnit.bids) .filter((bidderData) => bidderData.bidder === bidder) .map((bidderData) => bidderData.params || {}); } -/** - * Returns the origin - */ -export function getOrigin() { - // IE10 does not have this property. https://gist.github.com/hbogs/7908703 - if (!window.location.origin) { - return window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); - } else { - return window.location.origin; - } -} /** * Returns Do Not Track state @@ -941,7 +741,7 @@ export function getDNT() { return navigator.doNotTrack === '1' || window.doNotTrack === '1' || navigator.msDoNotTrack === '1' || navigator.doNotTrack === 'yes'; } -const compareCodeAndSlot = (slot, adUnitCode) => slot.getAdUnitPath() === adUnitCode || slot.getSlotElementId() === adUnitCode; +export const compareCodeAndSlot = (slot, adUnitCode) => slot.getAdUnitPath() === adUnitCode || slot.getSlotElementId() === adUnitCode; /** * Returns filter function to match adUnitCode in slot @@ -952,33 +752,6 @@ export function isAdUnitCodeMatchingSlot(slot) { return (adUnitCode) => compareCodeAndSlot(slot, adUnitCode); } -/** - * Returns filter function to match adUnitCode in slot - * @param {string} adUnitCode AdUnit code - * @return {function} filter function - */ -export function isSlotMatchingAdUnitCode(adUnitCode) { - return (slot) => compareCodeAndSlot(slot, adUnitCode); -} - -/** - * @summary Uses the adUnit's code in order to find a matching gptSlot on the page - */ -export function getGptSlotInfoForAdUnitCode(adUnitCode) { - let matchingSlot; - if (isGptPubadsDefined()) { - // find the first matching gpt slot on the page - matchingSlot = find(window.googletag.pubads().getSlots(), isSlotMatchingAdUnitCode(adUnitCode)); - } - if (matchingSlot) { - return { - gptSlot: matchingSlot.getAdUnitPath(), - divId: matchingSlot.getSlotElementId() - } - } - return {}; -}; - /** * Constructs warning message for when unsupported bidders are dropped from an adunit * @param {Object} adUnit ad unit from which the bidder is being dropped @@ -1000,33 +773,14 @@ export function unsupportedBidderMessage(adUnit, bidder) { * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger * @param {*} value */ -export function isInteger(value) { - if (Number.isInteger) { - return Number.isInteger(value); - } else { - return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; - } -} - -/** - * Converts a string value in camel-case to underscore eg 'placementId' becomes 'placement_id' - * @param {string} value string value to convert - */ -export function convertCamelToUnderscore(value) { - return value.replace(/(?:^|\.?)([A-Z])/g, function (x, y) { return '_' + y.toLowerCase() }).replace(/^_/, ''); -} +export const isInteger = Number.isInteger.bind(Number); /** * Returns a new object with undefined properties removed from given object * @param obj the object to clean */ export function cleanObj(obj) { - return Object.keys(obj).reduce((newObj, key) => { - if (typeof obj[key] !== 'undefined') { - newObj[key] = obj[key]; - } - return newObj; - }, {}) + return Object.fromEntries(Object.entries(obj).filter(([_, v]) => typeof v !== 'undefined')) } /** @@ -1063,137 +817,10 @@ export function pick(obj, properties) { }, {}); } -/** - * Converts an object of arrays (either strings or numbers) into an array of objects containing key and value properties - * normally read from bidder params - * eg { foo: ['bar', 'baz'], fizz: ['buzz'] } - * becomes [{ key: 'foo', value: ['bar', 'baz']}, {key: 'fizz', value: ['buzz']}] - * @param {Object} keywords object of arrays representing keyvalue pairs - * @param {string} paramName name of parent object (eg 'keywords') containing keyword data, used in error handling - */ -export function transformBidderParamKeywords(keywords, paramName = 'keywords') { - let arrs = []; - - _each(keywords, (v, k) => { - if (isArray(v)) { - let values = []; - _each(v, (val) => { - val = getValueString(paramName + '.' + k, val); - if (val || val === '') { values.push(val); } - }); - v = values; - } else { - v = getValueString(paramName + '.' + k, v); - if (isStr(v)) { - v = [v]; - } else { - return; - } // unsuported types - don't send a key - } - arrs.push({key: k, value: v}); - }); - - return arrs; -} - -/** - * Try to convert a value to a type. - * If it can't be done, the value will be returned. - * - * @param {string} typeToConvert The target type. e.g. "string", "number", etc. - * @param {*} value The value to be converted into typeToConvert. - */ -function tryConvertType(typeToConvert, value) { - if (typeToConvert === 'string') { - return value && value.toString(); - } else if (typeToConvert === 'number') { - return Number(value); - } else { - return value; - } -} - -export function convertTypes(types, params) { - Object.keys(types).forEach(key => { - if (params[key]) { - if (isFn(types[key])) { - params[key] = types[key](params[key]); - } else { - params[key] = tryConvertType(types[key], params[key]); - } - - // don't send invalid values - if (isNaN(params[key])) { - delete params.key; - } - } - }); - return params; -} - export function isArrayOfNums(val, size) { return (isArray(val)) && ((size) ? val.length === size : true) && (val.every(v => isInteger(v))); } -/** - * Creates an array of n length and fills each item with the given value - */ -export function fill(value, length) { - let newArray = []; - - for (let i = 0; i < length; i++) { - let valueToPush = isPlainObject(value) ? deepClone(value) : value; - newArray.push(valueToPush); - } - - return newArray; -} - -/** - * http://npm.im/chunk - * Returns an array with *size* chunks from given array - * - * Example: - * ['a', 'b', 'c', 'd', 'e'] chunked by 2 => - * [['a', 'b'], ['c', 'd'], ['e']] - */ -export function chunk(array, size) { - let newArray = []; - - for (let i = 0; i < Math.ceil(array.length / size); i++) { - let start = i * size; - let end = start + size; - newArray.push(array.slice(start, end)); - } - - return newArray; -} - -export function getMinValueFromArray(array) { - return Math.min(...array); -} - -export function getMaxValueFromArray(array) { - return Math.max(...array); -} - -/** - * This function will create compare function to sort on object property - * @param {string} property - * @returns {function} compare function to be used in sorting - */ -export function compareOn(property) { - return function compare(a, b) { - if (a[property] < b[property]) { - return 1; - } - if (a[property] > b[property]) { - return -1; - } - return 0; - } -} - export function parseQS(query) { return !query ? {} : query .replace(/^\?/, '') @@ -1357,10 +984,70 @@ export function cyrb53Hash(str, seed = 0) { } /** - * returns a window object, which holds the provided document or null - * @param {Document} doc - * @returns {Window} + * returns the result of `JSON.parse(data)`, or undefined if that throws an error. + * @param data + * @returns {any} */ -export function getWindowFromDocument(doc) { - return (doc) ? doc.defaultView : null; +export function safeJSONParse(data) { + try { + return JSON.parse(data); + } catch (e) {} +} + +/** + * Returns a memoized version of `fn`. + * + * @param fn + * @param key cache key generator, invoked with the same arguments passed to `fn`. + * By default, the first argument is used as key. + * @return {function(): any} + */ +export function memoize(fn, key = function (arg) { return arg; }) { + const cache = new Map(); + const memoized = function () { + const cacheKey = key.apply(this, arguments); + if (!cache.has(cacheKey)) { + cache.set(cacheKey, fn.apply(this, arguments)); + } + return cache.get(cacheKey); + } + memoized.clear = cache.clear.bind(cache); + return memoized; +} + +/** + * Sets dataset attributes on a script + * @param {Script} script + * @param {object} attributes + */ +export function setScriptAttributes(script, attributes) { + Object.entries(attributes).forEach(([k, v]) => script.setAttribute(k, v)) +} + +/** + * Perform a binary search for `el` on an ordered array `arr`. + * + * @returns the lowest nonnegative integer I that satisfies: + * key(arr[i]) >= key(el) for each i between I and arr.length + * + * (if one or more matches are found for `el`, returns the index of the first; + * if the element is not found, return the index of the first element that's greater; + * if no greater element exists, return `arr.length`) + */ +export function binarySearch(arr, el, key = (el) => el) { + let left = 0; + let right = arr.length && arr.length - 1; + const target = key(el); + while (right - left > 1) { + const middle = left + Math.round((right - left) / 2); + if (target > key(arr[middle])) { + left = middle; + } else { + right = middle; + } + } + while (arr.length > left && target > key(arr[left])) { + left++; + } + return left; } diff --git a/src/utils/cpm.js b/src/utils/cpm.js new file mode 100644 index 00000000000..7601d0643fd --- /dev/null +++ b/src/utils/cpm.js @@ -0,0 +1,20 @@ +import {auctionManager} from '../auctionManager.js'; +import {bidderSettings} from '../bidderSettings.js'; +import {logError} from '../utils.js'; + +export function adjustCpm(cpm, bidResponse, bidRequest, {index = auctionManager.index, bs = bidderSettings} = {}) { + bidRequest = bidRequest || index.getBidRequest(bidResponse); + const adapterCode = bidResponse?.adapterCode; + const bidderCode = bidResponse?.bidderCode || bidRequest?.bidder; + const adjustAlternateBids = bs.get(bidResponse?.adapterCode, 'adjustAlternateBids'); + const bidCpmAdjustment = bs.getOwn(bidderCode, 'bidCpmAdjustment') || bs.get(adjustAlternateBids ? adapterCode : bidderCode, 'bidCpmAdjustment'); + + if (bidCpmAdjustment && typeof bidCpmAdjustment === 'function') { + try { + return bidCpmAdjustment(cpm, Object.assign({}, bidResponse), bidRequest); + } catch (e) { + logError('Error during bid adjustment', e); + } + } + return cpm; +} diff --git a/src/utils/gpdr.js b/src/utils/gpdr.js new file mode 100644 index 00000000000..19c7126b7d7 --- /dev/null +++ b/src/utils/gpdr.js @@ -0,0 +1,14 @@ +import {deepAccess} from '../utils.js'; + +/** + * Check if GDPR purpose 1 consent was given. + * + * @param gdprConsent GDPR consent data + * @returns {boolean} true if the gdprConsent is null-y; or GDPR does not apply; or if purpose 1 consent was given. + */ +export function hasPurpose1Consent(gdprConsent) { + if (gdprConsent?.gdprApplies) { + return deepAccess(gdprConsent, 'vendorData.purpose.consents.1') === true; + } + return true; +} diff --git a/src/utils/perfMetrics.js b/src/utils/perfMetrics.js new file mode 100644 index 00000000000..b1fdb38effe --- /dev/null +++ b/src/utils/perfMetrics.js @@ -0,0 +1,386 @@ +import {config} from '../config.js'; +export const CONFIG_TOGGLE = 'performanceMetrics'; +const getTime = window.performance && window.performance.now ? () => window.performance.now() : () => Date.now(); +const NODES = new WeakMap(); + +export function metricsFactory({now = getTime, mkNode = makeNode, mkTimer = makeTimer, mkRenamer = (rename) => rename, nodes = NODES} = {}) { + return function newMetrics() { + function makeMetrics(self, rename = (n) => ({forEach(fn) { fn(n); }})) { + rename = mkRenamer(rename); + + function accessor(slot) { + return function (name) { + return self.dfWalk({ + visit(edge, node) { + const obj = node[slot]; + if (obj.hasOwnProperty(name)) { + return obj[name]; + } + } + }); + }; + } + + const getTimestamp = accessor('timestamps'); + + /** + * Register a metric. + * + * @param name metric name + * @param value metric valiue + */ + function setMetric(name, value) { + const names = rename(name); + self.dfWalk({ + follow(inEdge, outEdge) { + return outEdge.propagate && (!inEdge || !inEdge.stopPropagation) + }, + visit(edge, node) { + names.forEach(name => { + if (edge == null) { + node.metrics[name] = value; + } else { + if (!node.groups.hasOwnProperty(name)) { + node.groups[name] = []; + } + node.groups[name].push(value); + } + }) + } + }); + } + + /** + * Mark the current time as a checkpoint with the given name, to be referenced later + * by `timeSince` or `timeBetween`. + * + * @param name checkpoint name + */ + function checkpoint(name) { + self.timestamps[name] = now(); + } + + /** + * Get the tame passed since `checkpoint`, and optionally save it as a metric. + * + * @param checkpoint checkpoint name + * @param metric? metric name + * @return {number} time between now and `checkpoint` + */ + function timeSince(checkpoint, metric) { + const ts = getTimestamp(checkpoint); + const elapsed = ts != null ? now() - ts : null; + if (metric != null) { + setMetric(metric, elapsed); + } + return elapsed; + } + + /** + * Get the time passed between `startCheckpoint` and `endCheckpoint`, optionally saving it as a metric. + * + * @param startCheckpoint begin checkpoint + * @param endCheckpoint end checkpoint + * @param metric? metric name + * @return {number} time passed between `startCheckpoint` and `endCheckpoint` + */ + function timeBetween(startCheckpoint, endCheckpoint, metric) { + const start = getTimestamp(startCheckpoint); + const end = getTimestamp(endCheckpoint); + const elapsed = start != null && end != null ? end - start : null; + if (metric != null) { + setMetric(metric, elapsed); + } + return elapsed; + } + + /** + * A function that, when called, stops a time measure and saves it as a metric. + * + * @typedef {function(): void} MetricsTimer + * @template {function} F + * @property {function(F): F} stopBefore returns a wrapper around the given function that begins by + * stopping this time measure. + * @property {function(F): F} stopAfter returns a wrapper around the given function that ends by + * stopping this time measure. + */ + + /** + * Start measuring a time metric with the given name. + * + * @param name metric name + * @return {MetricsTimer} + */ + function startTiming(name) { + return mkTimer(now, (val) => setMetric(name, val)) + } + + /** + * Run fn and measure the time spent in it. + * + * @template T + * @param name the name to use for the measured time metric + * @param {function(): T} fn + * @return {T} the return value of `fn` + */ + function measureTime(name, fn) { + return startTiming(name).stopAfter(fn)(); + } + + /** + * @typedef {function: T} HookFn + * @property {function(T): void} bail + * + * @template T + * @typedef {T: HookFn} TimedHookFn + * @property {function(): void} stopTiming + * @property {T} untimed + */ + + /** + * Convenience method for measuring time spent in a `.before` or `.after` hook. + * + * @template T + * @param name metric name + * @param {HookFn} next the hook's `next` (first) argument + * @param {function(TimedHookFn): T} fn a function that will be run immediately; it takes `next`, + * where both `next` and `next.bail` automatically + * call `stopTiming` before continuing with the original hook. + * @return {T} fn's return value + */ + function measureHookTime(name, next, fn) { + const stopTiming = startTiming(name); + return fn((function (orig) { + const next = stopTiming.stopBefore(orig); + next.bail = orig.bail && stopTiming.stopBefore(orig.bail); + next.stopTiming = stopTiming; + next.untimed = orig; + return next; + })(next)); + } + + /** + * Get all registered metrics. + * @return {{}} + */ + function getMetrics() { + let result = {} + self.dfWalk({ + visit(edge, node) { + result = Object.assign({}, !edge || edge.includeGroups ? node.groups : null, node.metrics, result); + } + }); + return result; + } + + /** + * Create and return a new metrics object that starts as a view on all metrics registered here, + * and - by default - also propagates all new metrics here. + * + * Propagated metrics are grouped together, and intended for repeated operations. For example, with the following: + * + * ``` + * const metrics = newMetrics(); + * const requests = metrics.measureTime('buildRequests', buildRequests) + * requests.forEach((req) => { + * const requestMetrics = metrics.fork(); + * requestMetrics.measureTime('processRequest', () => processRequest(req); + * }) + * ``` + * + * if `buildRequests` takes 10ms and returns 3 objects, which respectively take 100, 200, and 300ms in `processRequest`, then + * the final `metrics.getMetrics()` would be: + * + * ``` + * { + * buildRequests: 10, + * processRequest: [100, 200, 300] + * } + * ``` + * + * while the inner `requestMetrics.getMetrics()` would be: + * + * ``` + * { + * buildRequests: 10, + * processRequest: 100 // or 200 for the 2nd loop, etc + * } + * ``` + * + * + * @param propagate if false, the forked metrics will not be propagated here + * @param stopPropagation if true, propagation from the new metrics is stopped here - instead of + * continuing up the chain (if for example these metrics were themselves created through `.fork()`) + * @param includeGroups if true, the forked metrics will also replicate metrics that were propagated + * here from elsewhere. For example: + * ``` + * const metrics = newMetrics(); + * const op1 = metrics.fork(); + * const withoutGroups = metrics.fork(); + * const withGroups = metrics.fork({includeGroups: true}); + * op1.setMetric('foo', 'bar'); + * withoutGroups.getMetrics() // {} + * withGroups.getMetrics() // {foo: ['bar']} + * ``` + */ + function fork({propagate = true, stopPropagation = false, includeGroups = false} = {}) { + return makeMetrics(mkNode([[self, {propagate, stopPropagation, includeGroups}]]), rename); + } + + /** + * Join `otherMetrics` with these; all metrics from `otherMetrics` will (by default) be propagated here, + * and all metrics from here will be included in `otherMetrics`. + * + * `propagate`, `stopPropagation` and `includeGroups` have the same semantics as in `.fork()`. + */ + function join(otherMetrics, {propagate = true, stopPropagation = false, includeGroups = false} = {}) { + const other = nodes.get(otherMetrics); + if (other != null) { + other.addParent(self, {propagate, stopPropagation, includeGroups}); + } + } + + /** + * return a version of these metrics where all new metrics are renamed according to `renameFn`. + * + * @param {function(String): Array[String]} renameFn + */ + function renameWith(renameFn) { + return makeMetrics(self, renameFn); + } + + /** + * Create a new metrics object that uses the same propagation and renaming rules as this one. + */ + function newMetrics() { + return makeMetrics(self.newSibling(), rename); + } + + const metrics = { + startTiming, + measureTime, + measureHookTime, + checkpoint, + timeSince, + timeBetween, + setMetric, + getMetrics, + fork, + join, + newMetrics, + renameWith, + toJSON() { + return getMetrics(); + } + }; + nodes.set(metrics, self); + return metrics; + } + + return makeMetrics(mkNode([])); + } +} + +function wrapFn(fn, before, after) { + return function () { + before && before(); + try { + return fn.apply(this, arguments); + } finally { + after && after(); + } + }; +} + +function makeTimer(now, cb) { + const start = now(); + let done = false; + function stopTiming() { + if (!done) { + // eslint-disable-next-line standard/no-callback-literal + cb(now() - start); + done = true; + } + } + stopTiming.stopBefore = (fn) => wrapFn(fn, stopTiming); + stopTiming.stopAfter = (fn) => wrapFn(fn, null, stopTiming); + return stopTiming; +} + +function makeNode(parents) { + return { + metrics: {}, + timestamps: {}, + groups: {}, + addParent(node, edge) { + parents.push([node, edge]); + }, + newSibling() { + return makeNode(parents.slice()); + }, + dfWalk({visit, follow = () => true, visited = new Set(), inEdge} = {}) { + let res; + if (!visited.has(this)) { + visited.add(this); + res = visit(inEdge, this); + if (res != null) return res; + for (const [parent, outEdge] of parents) { + if (follow(inEdge, outEdge)) { + res = parent.dfWalk({visit, follow, visited, inEdge: outEdge}); + if (res != null) return res; + } + } + } + } + }; +} + +const nullMetrics = (() => { + const nop = function () {}; + const empty = () => ({}); + const none = {forEach: nop}; + const nullTimer = () => null; + nullTimer.stopBefore = (fn) => fn; + nullTimer.stopAfter = (fn) => fn; + const nullNode = Object.defineProperties( + {dfWalk: nop, newSibling: () => nullNode, addParent: nop}, + Object.fromEntries(['metrics', 'timestamps', 'groups'].map(prop => [prop, {get: empty}]))); + return metricsFactory({ + now: () => 0, + mkNode: () => nullNode, + mkRenamer: () => () => none, + mkTimer: () => nullTimer, + nodes: {get: nop, set: nop} + })(); +})(); + +let enabled = true; +config.getConfig(CONFIG_TOGGLE, (cfg) => { enabled = !!cfg[CONFIG_TOGGLE] }); + +/** + * convenience fallback function for metrics that may be undefined, especially during tests. + */ +export function useMetrics(metrics) { + return (enabled && metrics) || nullMetrics; +} + +export const newMetrics = (() => { + const makeMetrics = metricsFactory(); + return function () { + return enabled ? makeMetrics() : nullMetrics; + } +})(); + +export function hookTimer(prefix, getMetrics) { + return function(name, hookFn) { + return function (next, ...args) { + const that = this; + return useMetrics(getMetrics.apply(that, args)).measureHookTime(prefix + name, next, function (next) { + return hookFn.call(that, next, ...args); + }); + } + } +} + +export const timedAuctionHook = hookTimer('requestBids.', (req) => req.metrics); +export const timedBidResponseHook = hookTimer('addBidResponse.', (_, bid) => bid.metrics) diff --git a/src/utils/promise.js b/src/utils/promise.js new file mode 100644 index 00000000000..0cf0a47eb8e --- /dev/null +++ b/src/utils/promise.js @@ -0,0 +1,140 @@ +const SUCCESS = 0; +const FAIL = 1; + +/** + * A version of Promise that runs callbacks synchronously when it can (i.e. after it's been fulfilled or rejected). + */ +export class GreedyPromise { + #result; + #callbacks; + + /** + * Convenience wrapper for setTimeout; takes care of returning an already fulfilled GreedyPromise when the delay is zero. + * + * @param {Number} delayMs delay in milliseconds + * @returns {GreedyPromise} a promise that resolves (to undefined) in `delayMs` milliseconds + */ + static timeout(delayMs = 0) { + return new GreedyPromise((resolve) => { + delayMs === 0 ? resolve() : setTimeout(resolve, delayMs); + }); + } + + constructor(resolver) { + if (typeof resolver !== 'function') { + throw new Error('resolver not a function'); + } + const result = []; + const callbacks = []; + let [resolve, reject] = [SUCCESS, FAIL].map((type) => { + return function (value) { + if (type === SUCCESS && typeof value?.then === 'function') { + value.then(resolve, reject); + } else if (!result.length) { + result.push(type, value); + while (callbacks.length) callbacks.shift()(); + } + } + }); + try { + resolver(resolve, reject); + } catch (e) { + reject(e); + } + this.#result = result; + this.#callbacks = callbacks; + } + + then(onSuccess, onError) { + const result = this.#result; + return new this.constructor((resolve, reject) => { + const continuation = () => { + let value = result[1]; + let [handler, resolveFn] = result[0] === SUCCESS ? [onSuccess, resolve] : [onError, reject]; + if (typeof handler === 'function') { + try { + value = handler(value); + } catch (e) { + reject(e); + return; + } + resolveFn = resolve; + } + resolveFn(value); + } + result.length ? continuation() : this.#callbacks.push(continuation); + }); + } + + catch(onError) { + return this.then(null, onError); + } + + finally(onFinally) { + let val; + return this.then( + (v) => { val = v; return onFinally(); }, + (e) => { val = this.constructor.reject(e); return onFinally() } + ).then(() => val); + } + + static #collect(promises, collector, done) { + let cnt = promises.length; + function clt() { + collector.apply(this, arguments); + if (--cnt <= 0 && done) done(); + } + promises.length === 0 && done ? done() : promises.forEach((p, i) => this.resolve(p).then( + (val) => clt(true, val, i), + (err) => clt(false, err, i) + )); + } + + static race(promises) { + return new this((resolve, reject) => { + this.#collect(promises, (success, result) => success ? resolve(result) : reject(result)); + }) + } + + static all(promises) { + return new this((resolve, reject) => { + let res = []; + this.#collect(promises, (success, val, i) => success ? res[i] = val : reject(val), () => resolve(res)); + }) + } + + static allSettled(promises) { + return new this((resolve) => { + let res = []; + this.#collect(promises, (success, val, i) => res[i] = success ? {status: 'fulfilled', value: val} : {status: 'rejected', reason: val}, () => resolve(res)) + }) + } + + static resolve(value) { + return new this(resolve => resolve(value)) + } + + static reject(error) { + return new this((resolve, reject) => reject(error)) + } +} + +/** + * @returns a {promise, resolve, reject} trio where `promise` is resolved by calling `resolve` or `reject`. + */ +export function defer({promiseFactory = (resolver) => new GreedyPromise(resolver)} = {}) { + function invoker(delegate) { + return (val) => delegate(val); + } + + let resolveFn, rejectFn; + + return { + promise: promiseFactory((resolve, reject) => { + resolveFn = resolve; + rejectFn = reject; + }), + resolve: invoker(resolveFn), + reject: invoker(rejectFn) + } +} diff --git a/src/utils/reducers.js b/src/utils/reducers.js new file mode 100644 index 00000000000..28851be8aaa --- /dev/null +++ b/src/utils/reducers.js @@ -0,0 +1,44 @@ +export function simpleCompare(a, b) { + if (a === b) return 0; + return a < b ? -1 : 1; +} + +export function keyCompare(key = (item) => item) { + return (a, b) => simpleCompare(key(a), key(b)) +} + +export function reverseCompare(compare = simpleCompare) { + return (a, b) => -compare(a, b) || 0; +} + +export function tiebreakCompare(...compares) { + return function (a, b) { + for (const cmp of compares) { + const val = cmp(a, b); + if (val !== 0) return val; + } + return 0; + } +} + +export function minimum(compare = simpleCompare) { + return (min, item) => compare(item, min) < 0 ? item : min; +} + +export function maximum(compare = simpleCompare) { + return minimum(reverseCompare(compare)); +} + +const cpmCompare = keyCompare((bid) => bid.cpm); +const timestampCompare = keyCompare((bid) => bid.responseTimestamp); + +// This function will get highest cpm value bid, in case of tie it will return the bid with lowest timeToRespond +export const getHighestCpm = maximum(tiebreakCompare(cpmCompare, reverseCompare(keyCompare((bid) => bid.timeToRespond)))) + +// This function will get the oldest hightest cpm value bid, in case of tie it will return the bid which came in first +// Use case for tie: https://github.com/prebid/Prebid.js/issues/2448 +export const getOldestHighestCpmBid = maximum(tiebreakCompare(cpmCompare, reverseCompare(timestampCompare))) + +// This function will get the latest hightest cpm value bid, in case of tie it will return the bid which came in last +// Use case for tie: https://github.com/prebid/Prebid.js/issues/2539 +export const getLatestHighestCpmBid = maximum(tiebreakCompare(cpmCompare, timestampCompare)) diff --git a/src/utils/ttlCollection.js b/src/utils/ttlCollection.js new file mode 100644 index 00000000000..392ed1c9ad7 --- /dev/null +++ b/src/utils/ttlCollection.js @@ -0,0 +1,139 @@ +import {GreedyPromise} from './promise.js'; +import {binarySearch, timestamp} from '../utils.js'; + +/** + * Create a set-like collection that automatically forgets items after a certain time. + * + * @param {({}) => Number|Promise} startTime? a function taking an item added to this collection, + * and returning (a promise to) a timestamp to be used as the starting time for the item + * (the item will be dropped after `ttl(item)` milliseconds have elapsed since this timestamp). + * Defaults to the time the item was added to the collection. + * @param {({}) => Number|void|Promise} ttl a function taking an item added to this collection, + * and returning (a promise to) the duration (in milliseconds) the item should be kept in it. + * May return null to indicate that the item should be persisted indefinitely. + * @param {boolean} monotonic? set to true for better performance, but only if, given any two items A and B in this collection: + * if A was added before B, then: + * - startTime(A) + ttl(A) <= startTime(B) + ttl(B) + * - Promise.all([startTime(A), ttl(A)]) never resolves later than Promise.all([startTime(B), ttl(B)]) + * @param {number} slack? maximum duration (in milliseconds) that an item is allowed to persist + * once past its TTL. This is also roughly the interval between "garbage collection" sweeps. + */ +export function ttlCollection( + { + startTime = timestamp, + ttl = () => null, + monotonic = false, + slack = 5000 + } = {} +) { + const items = new Map(); + const pendingPurge = []; + const markForPurge = monotonic + ? (entry) => pendingPurge.push(entry) + : (entry) => pendingPurge.splice(binarySearch(pendingPurge, entry, (el) => el.expiry), 0, entry) + let nextPurge, task; + + function reschedulePurge() { + task && clearTimeout(task); + if (pendingPurge.length > 0) { + const now = timestamp(); + nextPurge = Math.max(now, pendingPurge[0].expiry + slack); + task = setTimeout(() => { + const now = timestamp(); + let cnt = 0; + for (const entry of pendingPurge) { + if (entry.expiry > now) break; + items.delete(entry.item) + cnt++; + } + pendingPurge.splice(0, cnt); + task = null; + reschedulePurge(); + }, nextPurge - now); + } else { + task = null; + } + } + + function mkEntry(item) { + const values = {}; + const thisCohort = currentCohort; + let expiry; + + function update() { + if (thisCohort === currentCohort && values.start != null && values.delta != null) { + expiry = values.start + values.delta; + markForPurge(entry); + if (task == null || nextPurge > expiry + slack) { + reschedulePurge(); + } + } + } + + const [init, refresh] = Object.entries({ + start: startTime, + delta: ttl + }).map(([field, getter]) => { + let currentCall; + return function() { + const thisCall = currentCall = {}; + GreedyPromise.resolve(getter(item)).then((val) => { + if (thisCall === currentCall) { + values[field] = val; + update(); + } + }); + } + }) + + const entry = { + item, + refresh, + get expiry() { + return expiry; + }, + }; + + init(); + refresh(); + return entry; + } + + let currentCohort = {}; + + return { + [Symbol.iterator]: () => items.keys(), + /** + * Add an item to this collection. + * @param item + */ + add(item) { + !items.has(item) && items.set(item, mkEntry(item)); + }, + /** + * Clear this collection. + */ + clear() { + pendingPurge.length = 0; + reschedulePurge(); + items.clear(); + currentCohort = {}; + }, + /** + * @returns {[]} all the items in this collection, in insertion order. + */ + toArray() { + return Array.from(items.keys()); + }, + /** + * Refresh the TTL for each item in this collection. + */ + refresh() { + pendingPurge.length = 0; + reschedulePurge(); + for (const entry of items.values()) { + entry.refresh(); + } + }, + }; +} diff --git a/src/video.js b/src/video.js index 977991b7134..ff137892a2b 100644 --- a/src/video.js +++ b/src/video.js @@ -1,25 +1,21 @@ -import adapterManager from './adapterManager.js'; -import { deepAccess, logError } from './utils.js'; -import { config } from '../src/config.js'; -import {includes} from './polyfill.js'; -import { hook } from './hook.js'; +import {deepAccess, logError} from './utils.js'; +import {config} from '../src/config.js'; +import {hook} from './hook.js'; import {auctionManager} from './auctionManager.js'; -const VIDEO_MEDIA_TYPE = 'video'; export const OUTSTREAM = 'outstream'; export const INSTREAM = 'instream'; -/** - * Helper functions for working with video-enabled adUnits - */ -export const videoAdUnit = adUnit => { - const mediaType = adUnit.mediaType === VIDEO_MEDIA_TYPE; - const mediaTypes = deepAccess(adUnit, 'mediaTypes.video'); - return mediaType || mediaTypes; -}; -export const videoBidder = bid => includes(adapterManager.videoAdapters, bid.bidder); -export const hasNonVideoBidder = adUnit => - adUnit.bids.filter(bid => !videoBidder(bid)).length; +export function fillVideoDefaults(adUnit) { + const video = adUnit?.mediaTypes?.video; + if (video != null && video.plcmt == null) { + if (video.context === OUTSTREAM || [2, 3, 4].includes(video.placement)) { + video.plcmt = 4; + } else if (video.context !== OUTSTREAM && [2, 6].includes(video.playbackmethod)) { + video.plcmt = 2; + } + } +} /** * @typedef {object} VideoBid @@ -35,15 +31,16 @@ export const hasNonVideoBidder = adUnit => export function isValidVideoBid(bid, {index = auctionManager.index} = {}) { const videoMediaType = deepAccess(index.getMediaTypes(bid), 'video'); const context = videoMediaType && deepAccess(videoMediaType, 'context'); + const useCacheKey = videoMediaType && deepAccess(videoMediaType, 'useCacheKey'); const adUnit = index.getAdUnit(bid); // if context not defined assume default 'instream' for video bids // instream bids require a vast url or vast xml content - return checkVideoBidSetup(bid, adUnit, videoMediaType, context); + return checkVideoBidSetup(bid, adUnit, videoMediaType, context, useCacheKey); } -export const checkVideoBidSetup = hook('sync', function(bid, adUnit, videoMediaType, context) { - if (videoMediaType && context !== OUTSTREAM) { +export const checkVideoBidSetup = hook('sync', function(bid, adUnit, videoMediaType, context, useCacheKey) { + if (videoMediaType && (useCacheKey || context !== OUTSTREAM)) { // xml-only video bids require a prebid cache url if (!config.getConfig('cache.url') && bid.vastXml && !bid.vastUrl) { logError(` @@ -57,7 +54,7 @@ export const checkVideoBidSetup = hook('sync', function(bid, adUnit, videoMediaT } // outstream bids require a renderer on the bid or pub-defined on adunit - if (context === OUTSTREAM) { + if (context === OUTSTREAM && !useCacheKey) { return !!(bid.renderer || (adUnit && adUnit.renderer) || videoMediaType.renderer); } diff --git a/src/videoCache.js b/src/videoCache.js index 219bca34726..88fc27625fd 100644 --- a/src/videoCache.js +++ b/src/videoCache.js @@ -9,10 +9,16 @@ * This trickery helps integrate with ad servers, which set character limits on request params. */ -import { ajax } from './ajax.js'; -import { config } from './config.js'; +import {ajaxBuilder} from './ajax.js'; +import {config} from './config.js'; import {auctionManager} from './auctionManager.js'; +/** + * Might be useful to be configurable in the future + * Depending on publisher needs + */ +const ttlBufferInSeconds = 15; + /** * @typedef {object} CacheableUrlBid * @property {string} vastUrl A URL which loads some valid VAST XML. @@ -63,11 +69,11 @@ function wrapURI(uri, impUrl) { function toStorageRequest(bid, {index = auctionManager.index} = {}) { const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); const auction = index.getAuction(bid); - + const ttlWithBuffer = Number(bid.ttl) + ttlBufferInSeconds; let payload = { type: 'xml', value: vastValue, - ttlseconds: Number(bid.ttl) + ttlseconds: ttlWithBuffer }; if (config.getConfig('cache.vasttrack')) { @@ -136,11 +142,11 @@ function shimStorageCallback(done) { * @param {videoCacheStoreCallback} [done] An optional callback which should be executed after * the data has been stored in the cache. */ -export function store(bids, done) { +export function store(bids, done, getAjax = ajaxBuilder) { const requestData = { puts: bids.map(toStorageRequest) }; - + const ajax = getAjax(config.getConfig('cache.timeout')); ajax(config.getConfig('cache.url'), shimStorageCallback(done), JSON.stringify(requestData), { contentType: 'text/plain', withCredentials: true diff --git a/test/fixtures/fixtures.js b/test/fixtures/fixtures.js index b0fbd7da806..7317ea039d1 100644 --- a/test/fixtures/fixtures.js +++ b/test/fixtures/fixtures.js @@ -1,5 +1,6 @@ // jscs:disable import CONSTANTS from 'src/constants.json'; +import {createBid} from '../../src/bidfactory.js'; const utils = require('src/utils.js'); function convertTargetingsFromOldToNew(targetings) { @@ -796,13 +797,6 @@ export function getAdUnits() { 'aId': 3080 } }, - { - 'bidder': 'aol', - 'params': { - 'network': '112345.45', - 'placement': 12345 - } - }, { 'bidder': 'sovrn', 'params': { @@ -1268,7 +1262,7 @@ export function createBidReceived({bidder, cpm, auctionId, responseTimestamp, ad if (typeof status !== 'undefined') { bid.status = status; } - return bid; + return Object.assign(createBid(CONSTANTS.STATUS.GOOD), bid); } export function getServerTestingsAds() { diff --git a/test/helpers/analytics.js b/test/helpers/analytics.js new file mode 100644 index 00000000000..b376118dc6f --- /dev/null +++ b/test/helpers/analytics.js @@ -0,0 +1,34 @@ +import * as pbEvents from 'src/events.js'; +import constants from '../../src/constants.json'; + +export function fireEvents(events = [ + constants.EVENTS.AUCTION_INIT, + constants.EVENTS.AUCTION_END, + constants.EVENTS.BID_REQUESTED, + constants.EVENTS.BID_RESPONSE, + constants.EVENTS.BID_WON +]) { + return events.map((ev, i) => { + ev = Array.isArray(ev) ? ev : [ev, {i: i}]; + pbEvents.emit.apply(null, ev) + return ev; + }); +} + +export function expectEvents(events) { + events = fireEvents(events); + return { + to: { + beTrackedBy(trackFn) { + events.forEach(([eventType, args]) => { + sinon.assert.calledWithMatch(trackFn, sinon.match({eventType, args})); + }); + }, + beBundledTo(bundleFn) { + events.forEach(([eventType, args]) => { + sinon.assert.calledWithMatch(bundleFn, sinon.match.any, eventType, sinon.match(args)) + }); + }, + }, + }; +} diff --git a/test/helpers/consentData.js b/test/helpers/consentData.js index 17ddc583f88..c708e397bd6 100644 --- a/test/helpers/consentData.js +++ b/test/helpers/consentData.js @@ -1,6 +1,12 @@ import {gdprDataHandler} from 'src/adapterManager.js'; +import {GreedyPromise} from '../../src/utils/promise.js'; export function mockGdprConsent(sandbox, getConsentData = () => null) { - sandbox.stub(gdprDataHandler, 'promise').get(() => Promise.resolve(getConsentData())); + sandbox.stub(gdprDataHandler, 'enabled').get(() => true) + sandbox.stub(gdprDataHandler, 'promise').get(() => GreedyPromise.resolve(getConsentData())); sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(getConsentData) } + +beforeEach(() => { + gdprDataHandler.reset(); +}) diff --git a/test/helpers/fpd.js b/test/helpers/fpd.js new file mode 100644 index 00000000000..89755f26541 --- /dev/null +++ b/test/helpers/fpd.js @@ -0,0 +1,71 @@ +import {dep, enrichFPD} from 'src/fpd/enrichment.js'; +import {GreedyPromise} from '../../src/utils/promise.js'; +import {deepClone} from '../../src/utils.js'; +import {gdprDataHandler, uspDataHandler} from '../../src/adapterManager.js'; + +export function mockFpdEnrichments(sandbox, overrides = {}) { + overrides = Object.assign({}, { + // override window getters, required for ChromeHeadless, apparently it sees window.self !== window + getWindowTop() { + return window + }, + getWindowSelf() { + return window + }, + getHighEntropySUA() { + return GreedyPromise.resolve() + } + }, overrides) + Object.entries(overrides) + .filter(([k]) => dep[k]) + .forEach(([k, v]) => { + sandbox.stub(dep, k).callsFake(v); + }); + Object.entries({ + gdprConsent: gdprDataHandler, + uspConsent: uspDataHandler, + }).forEach(([ovKey, handler]) => { + const v = overrides[ovKey]; + if (v) { + sandbox.stub(handler, 'getConsentData').callsFake(v); + } + }) +} + +export function addFPDEnrichments(ortb2 = {}, overrides) { + const sandbox = sinon.sandbox.create(); + mockFpdEnrichments(sandbox, overrides) + return enrichFPD(GreedyPromise.resolve(deepClone(ortb2))).finally(() => sandbox.restore()); +} + +export const syncAddFPDEnrichments = synchronize(addFPDEnrichments); + +export function addFPDToBidderRequest(bidderRequest, overrides) { + overrides = Object.assign({}, { + getRefererInfo() { + return bidderRequest.refererInfo || {}; + }, + gdprConsent() { + return bidderRequest.gdprConsent; + }, + uspConsent() { + return bidderRequest.uspConsent; + } + }, overrides); + return addFPDEnrichments(bidderRequest.ortb2 || {}, overrides).then(ortb2 => { + return { + ...bidderRequest, + ortb2 + } + }); +} + +export const syncAddFPDToBidderRequest = synchronize(addFPDToBidderRequest); + +function synchronize(fn) { + return function () { + let result; + fn.apply(this, arguments).then(res => { result = res }); + return result; + } +} diff --git a/test/helpers/hookSetup.js b/test/helpers/hookSetup.js new file mode 100644 index 00000000000..2de35bb1dd4 --- /dev/null +++ b/test/helpers/hookSetup.js @@ -0,0 +1,5 @@ +import {hook} from '../../src/hook.js'; + +before(() => { + hook.ready(); +}); diff --git a/test/helpers/refererDetectionHelper.js b/test/helpers/refererDetectionHelper.js new file mode 100644 index 00000000000..bdbfb205cdb --- /dev/null +++ b/test/helpers/refererDetectionHelper.js @@ -0,0 +1,88 @@ +/** + * Build a walkable linked list of window-like objects for testing. + * + * @param {Array} urls Array of URL strings starting from the top window. + * @param {string} [topReferrer] + * @param {string} [canonicalUrl] + * @param {boolean} [ancestorOrigins] + * @returns {Object} + */ +export function buildWindowTree(urls, topReferrer = null, canonicalUrl = null, ancestorOrigins = false) { + /** + * Find the origin from a given fully-qualified URL. + * + * @param {string} url The fully qualified URL + * @returns {string|null} + */ + function getOrigin(url) { + const originRegex = new RegExp('^(https?://[^/]+/?)'); + + const result = originRegex.exec(url); + + if (result && result[0]) { + return result[0]; + } + + return null; + } + + const inaccessibles = []; + + let previousWindow, topWindow; + const topOrigin = getOrigin(urls[0]); + + const windowList = urls.map((url, index) => { + const thisOrigin = getOrigin(url), + sameOriginAsPrevious = index === 0 ? true : (getOrigin(urls[index - 1]) === thisOrigin), + sameOriginAsTop = thisOrigin === topOrigin; + + const win = { + location: { + href: url, + }, + document: { + referrer: index === 0 ? topReferrer : urls[index - 1] + } + }; + + if (topWindow == null) { + topWindow = win; + win.document.querySelector = function (selector) { + if (selector === 'link[rel=\'canonical\']') { + return { + href: canonicalUrl + }; + } + return null; + }; + } + + if (sameOriginAsPrevious) { + win.parent = previousWindow; + } else { + win.parent = inaccessibles[inaccessibles.length - 1]; + } + if (ancestorOrigins) { + win.location.ancestorOrigins = urls.slice(0, index).reverse().map(getOrigin); + } + win.top = sameOriginAsTop ? topWindow : inaccessibles[0]; + + const inWin = {parent: inaccessibles[inaccessibles.length - 1], top: inaccessibles[0]}; + if (index === 0) { + inWin.top = inWin; + } + ['document', 'location'].forEach((prop) => { + Object.defineProperty(inWin, prop, { + get: function () { + throw new Error('cross-origin access'); + } + }); + }); + inaccessibles.push(inWin); + previousWindow = win; + + return win; + }); + + return windowList[windowList.length - 1]; +} diff --git a/test/helpers/syncPromise.js b/test/helpers/syncPromise.js deleted file mode 100644 index 99361bd716e..00000000000 --- a/test/helpers/syncPromise.js +++ /dev/null @@ -1,71 +0,0 @@ -const orig = {}; -['resolve', 'reject', 'all', 'race', 'allSettled'].forEach((k) => orig[k] = Promise[k].bind(Promise)) - -// Callbacks attached through Promise.resolve(value).then(...) will usually -// not execute immediately even if `value` is immediately available. This -// breaks tests that were written before promises even though they are semantically still valid. -// They can be made to work by making promises quasi-synchronous. - -export function SyncPromise(value, fail = false) { - if (value instanceof SyncPromise) { - return value; - } else if (typeof value === 'object' && typeof value.then === 'function') { - return orig.resolve(value); - } else { - Object.assign(this, { - then: function (cb, err) { - const handler = fail ? err : cb; - if (handler != null) { - return new SyncPromise(handler(value)); - } else { - return this; - } - }, - catch: function (cb) { - if (fail) { - return new SyncPromise(cb(value)) - } else { - return this; - } - }, - finally: function (cb) { - cb(); - return this; - }, - __value: fail ? {status: 'rejected', reason: value} : {status: 'fulfilled', value} - }) - } -} - -Object.assign(SyncPromise, { - resolve: (val) => new SyncPromise(val), - reject: (val) => new SyncPromise(val, true), - race: (promises) => promises.find((p) => p instanceof SyncPromise) || orig.race(promises), - allSettled: (promises) => { - if (promises.every((p) => p instanceof SyncPromise)) { - return new SyncPromise(promises.map((p) => p.__value)) - } else { - return orig.allSettled(promises); - } - }, - all: (promises) => { - if (promises.every((p) => p instanceof SyncPromise)) { - return SyncPromise.allSettled(promises).then((result) => { - const err = result.find((r) => r.status === 'rejected'); - if (err != null) { - return new SyncPromise(err.reason, true); - } else { - return new SyncPromise(result.map((r) => r.value)) - } - }) - } else { - return orig.all(promises); - } - } -}) - -export function synchronizePromise(sandbox) { - Object.keys(orig).forEach((k) => { - sandbox.stub(window.Promise, k).callsFake(SyncPromise[k]); - }) -} diff --git a/test/helpers/testing-utils.js b/test/helpers/testing-utils.js index 81f22ca471d..1336a90ecbf 100644 --- a/test/helpers/testing-utils.js +++ b/test/helpers/testing-utils.js @@ -1,12 +1,13 @@ /* eslint-disable no-console */ const {expect} = require('chai'); +const DEFAULT_TIMEOUT = 2000; const utils = { host: (process.env.TEST_SERVER_HOST) ? process.env.TEST_SERVER_HOST : 'localhost', protocol: (process.env.TEST_SERVER_PROTOCOL) ? 'https' : 'http', testPageURL: function(name) { return `${utils.protocol}://${utils.host}:9999/test/pages/${name}` }, - waitForElement: function(elementRef, time = 2000) { + waitForElement: function(elementRef, time = DEFAULT_TIMEOUT) { let element = $(elementRef); element.waitForExist({timeout: time}); }, @@ -14,7 +15,7 @@ const utils = { let iframe = $(frameRef); browser.switchToFrame(iframe); }, - loadAndWaitForElement(url, selector, pause = 3000, timeout = 2000, retries = 3, attempt = 1) { + loadAndWaitForElement(url, selector, pause = 3000, timeout = DEFAULT_TIMEOUT, retries = 3, attempt = 1) { browser.url(url); browser.pause(pause); if (selector != null) { @@ -27,7 +28,7 @@ const utils = { } } }, - setupTest({url, waitFor, expectGAMCreative = null, pause = 3000, timeout = 2000, retries = 3}, name, fn) { + setupTest({url, waitFor, expectGAMCreative = null, pause = 3000, timeout = DEFAULT_TIMEOUT, retries = 3}, name, fn) { describe(name, function () { this.retries(retries); before(() => utils.loadAndWaitForElement(url, waitFor, pause, timeout, retries)); diff --git a/test/mocks/analyticsStub.js b/test/mocks/analyticsStub.js new file mode 100644 index 00000000000..98e0f56688f --- /dev/null +++ b/test/mocks/analyticsStub.js @@ -0,0 +1,15 @@ +import {_internal, setDebounceDelay} from '../../libraries/analyticsAdapter/AnalyticsAdapter.js'; + +before(() => { + // stub out analytics networking to avoid random events polluting the global xhr mock + disableAjaxForAnalytics(); + // make analytics event handling synchronous + setDebounceDelay(0); +}) + +export function disableAjaxForAnalytics() { + sinon.stub(_internal, 'ajax').callsFake(() => null); +} +export function enableAjaxForAnalytics() { + _internal.ajax.restore(); +} diff --git a/test/mocks/timers.js b/test/mocks/timers.js new file mode 100644 index 00000000000..6efd798c881 --- /dev/null +++ b/test/mocks/timers.js @@ -0,0 +1,84 @@ +/* + * Provides wrappers for timers to allow easy cancelling and/or awaiting of outstanding timers. + * This helps avoid functionality leaking from one test to the next. + */ + +let wrappersActive = false; + +export function configureTimerInterceptors(debugLog = function() {}, generateStackTraces = false) { + if (wrappersActive) throw new Error(`Timer wrappers are already in place.`); + wrappersActive = true; + let theseWrappersActive = true; + + let originalSetTimeout = setTimeout, originalSetInterval = setInterval, originalClearTimeout = clearTimeout, originalClearInterval = clearInterval; + + let timerId = -1; + let timers = []; + + const waitOnTimersResolves = []; + function checkWaits() { + if (timers.length === 0) waitOnTimersResolves.forEach((r) => r()); + } + const waitAllActiveTimers = () => timers.length === 0 ? Promise.resolve() : new Promise((resolve) => waitOnTimersResolves.push(resolve)); + const clearAllActiveTimers = () => timers.forEach((timer) => timer.type === 'timeout' ? clearTimeout(timer.handle) : clearInterval(timer.handle)); + + const generateInterceptor = (type, originalFunctionWrapper) => (fn, delay, ...args) => { + timerId++; + debugLog(`Setting wrapped timeout ${timerId} for ${delay ?? 0}`); + const info = { timerId, type }; + if (generateStackTraces) { + try { + throw new Error(); + } catch (ex) { + info.stack = ex.stack; + } + } + info.handle = originalFunctionWrapper(info, fn, delay, ...args); + timers.push(info); + return info.handle; + }; + const setTimeoutInterceptor = generateInterceptor('timeout', (info, fn, delay, ...args) => originalSetTimeout(() => { + try { + debugLog(`Running timeout ${info.timerId}`); + fn(...args); + } finally { + const infoIndex = timers.indexOf(info); + if (infoIndex > -1) timers.splice(infoIndex, 1); + checkWaits(); + } + }, delay)); + + const setIntervalInterceptor = generateInterceptor('interval', (info, fn, interval, ...args) => originalSetInterval(() => { + debugLog(`Running interval ${info.timerId}`); + fn(...args); + }, interval)); + + const generateClearInterceptor = (type, originalClearFunction) => (handle) => { + originalClearFunction(handle); + const infoIndex = timers.findIndex((i) => i.handle === handle && i.type === type); + if (infoIndex > -1) timers.splice(infoIndex, 1); + checkWaits(); + } + const clearTimeoutInterceptor = generateClearInterceptor('timeout', originalClearTimeout); + const clearIntervalInterceptor = generateClearInterceptor('interval', originalClearInterval); + + setTimeout = setTimeoutInterceptor; + setInterval = setIntervalInterceptor; + clearTimeout = clearTimeoutInterceptor; + clearInterval = clearIntervalInterceptor; + + return { + waitAllActiveTimers, + clearAllActiveTimers, + timers, + restore: () => { + if (theseWrappersActive) { + theseWrappersActive = false; + setTimeout = originalSetTimeout; + setInterval = originalSetInterval; + clearTimeout = originalClearTimeout; + clearInterval = originalClearInterval; + } + } + } +} diff --git a/test/mocks/xhr.js b/test/mocks/xhr.js index 9fb8fe87fa0..e7b1d96f0a4 100644 --- a/test/mocks/xhr.js +++ b/test/mocks/xhr.js @@ -1,9 +1,278 @@ +import {getUniqueIdentifierStr} from '../../src/utils.js'; +import {GreedyPromise} from '../../src/utils/promise.js'; +import {fakeXhr} from 'nise'; +import {dep} from 'src/ajax.js'; -export let server = sinon.createFakeServer(); -export let xhr = global.XMLHttpRequest; +export const xhr = sinon.useFakeXMLHttpRequest(); +export const server = mockFetchServer(); -beforeEach(function() { - server.restore(); - server = sinon.createFakeServer(); - xhr = global.XMLHttpRequest; +/** + * An (incomplete) replica of nise's fakeServer, but backing fetch used in ajax.js (rather than XHR). + */ +function mockFetchServer() { + const sandbox = sinon.createSandbox(); + const bodies = new WeakMap(); + const requests = []; + const {DONE, UNSENT} = XMLHttpRequest; + + function makeRequest(resource, options) { + const requestBody = options?.body || bodies.get(resource); + const request = new Request(resource, options); + bodies.set(request, requestBody); + return request; + } + + function mockXHR(resource, options) { + let resolve, reject; + const promise = new GreedyPromise((res, rej) => { + resolve = res; + reject = rej; + }); + + function error(reason = new TypeError('Failed to fetch')) { + mockReq.status = 0; + reject(reason); + } + + const request = makeRequest(resource, options); + request.signal.onabort = () => error(new DOMException('The user aborted a request')); + let responseHeaders; + + const mockReq = { + fetch: { + request, + requestBody: bodies.get(request), + promise, + }, + readyState: UNSENT, + url: request.url, + method: request.method, + requestBody: bodies.get(request), + status: 0, + statusText: '', + requestHeaders: new Proxy(request.headers, { + get(target, prop) { + return typeof prop === 'string' && target.has(prop) ? target.get(prop) : {}[prop]; + }, + has(target, prop) { + return typeof prop === 'string' && target.has(prop); + }, + ownKeys(target) { + return Array.from(target.keys()); + }, + getOwnPropertyDescriptor(target, prop) { + if (typeof prop === 'string' && target.has(prop)) { + return { + enumerable: true, + configurable: true, + writable: false, + value: target.get(prop) + } + } + } + }), + withCredentials: request.credentials === 'include', + setStatus(status) { + // nise replaces invalid status with 200 + status = typeof status === 'number' ? status : 200; + mockReq.status = status; + mockReq.statusText = fakeXhr.FakeXMLHttpRequest.statusCodes[status] || ''; + }, + setResponseHeaders(headers) { + responseHeaders = headers; + }, + setResponseBody(body) { + if (mockReq.status === 0) { + error(); + return; + } + const resp = Object.defineProperties(new Response(body, { + status: mockReq.status, + statusText: mockReq.statusText, + headers: responseHeaders || {}, + }), { + url: { + get: () => mockReq.fetch.request.url, + } + }); + mockReq.readyState = DONE; + // tests expect respond() to run everything immediately, + // so make body available syncronously + resp.text = () => GreedyPromise.resolve(body || ''); + Object.assign(mockReq.fetch, { + response: resp, + responseBody: body || '' + }) + resolve(resp); + }, + respond(status = 200, headers, body) { + mockReq.setStatus(status); + mockReq.setResponseHeaders(headers); + mockReq.setResponseBody(body); + }, + error + }; + return mockReq; + } + + let enabled = false; + let timeoutsEnabled = false; + + function enable() { + if (!enabled) { + sandbox.stub(dep, 'fetch').callsFake((resource, options) => { + const req = mockXHR(resource, options); + requests.push(req); + return req.fetch.promise; + }); + sandbox.stub(dep, 'makeRequest').callsFake(makeRequest); + const timeout = dep.timeout; + sandbox.stub(dep, 'timeout').callsFake(function () { + if (timeoutsEnabled) { + return timeout.apply(null, arguments); + } else { + return {}; + } + }); + enabled = true; + } + } + + enable(); + + const responders = []; + + function respondWith() { + let response, urlMatcher, methodMatcher; + urlMatcher = methodMatcher = () => true; + switch (arguments.length) { + case 1: + ([response] = arguments); + break; + case 2: + ([urlMatcher, response] = arguments); + break; + case 3: + ([methodMatcher, urlMatcher, response] = arguments); + methodMatcher = ((toMatch) => (method) => method === toMatch)(methodMatcher); + break; + default: + throw new Error('Invalid respondWith invocation'); + } + if (typeof urlMatcher.exec === 'function') { + urlMatcher = ((rx) => (url) => rx.exec(url)?.slice(1))(urlMatcher); + } else if (typeof urlMatcher === 'string') { + urlMatcher = ((toMatch) => (url) => url === toMatch)(urlMatcher); + } + responders.push((req) => { + if (req.readyState !== DONE && methodMatcher(req.method)) { + const arg = urlMatcher(req.url); + if (arg) { + if (typeof response === 'function') { + response(req, ...(Array.isArray(arg) ? arg : [])); + } else if (typeof response === 'string') { + req.respond(200, null, response); + } else { + req.respond.apply(req, response); + } + } + } + }); + } + + function resetState() { + requests.length = 0; + responders.length = 0; + timeoutsEnabled = false; + } + + return { + requests, + enable, + restore() { + resetState(); + sandbox.restore(); + enabled = false; + }, + reset() { + sandbox.resetHistory(); + resetState(); + }, + respondWith, + respond() { + if (arguments.length > 0) { + respondWith.apply(null, arguments); + } + requests.forEach(req => { + for (let i = responders.length - 1; i >= 0; i--) { + responders[i](req); + if (req.readyState === DONE) break; + } + if (req.readyState !== DONE) { + req.respond(404, {}, ''); + } + }); + }, + /** + * the timeout mechanism is quite different between XHR and fetch + * by default, mocked fetch does not time out - to reflect fakeServer XHRs + * note that many tests will fire requests without caring or waiting for their response - + * if they are timed out later, during unrelated tests, the log messages might interfere with their + * assertions + */ + get autoTimeout() { + return timeoutsEnabled; + }, + set autoTimeout(val) { + timeoutsEnabled = !!val; + } + }; +} + +beforeEach(function () { + server.reset(); +}); + +const bid = getUniqueIdentifierStr().substring(4); +let fid = 0; + +/* eslint-disable */ +afterEach(function () { + if (this?.currentTest?.state === 'failed') { + const prepend = (() => { + const preamble = `[Failure ${bid}-${fid++}]`; + return (s) => s.split('\n').map(s => `${preamble} ${s}`).join('\n'); + })(); + + function format(obj, body = null) { + if (obj == null) return obj; + const fmt = {}; + let node = obj; + while (node != null) { + Object.keys(node).forEach((k) => { + const val = obj[k]; + if (typeof val !== 'function' && !fmt.hasOwnProperty(k)) { + fmt[k] = val; + } + }); + node = Object.getPrototypeOf(node); + } + if (obj.headers != null) { + fmt.headers = Object.fromEntries(obj.headers.entries()) + } + fmt.body = body; + return fmt; + } + + + console.log(prepend(`XHR mock state after failure (for test '${this.currentTest.fullTitle()}'): ${server.requests.length} requests`)); + server.requests.forEach((req, i) => { + console.log(prepend(`Request #${i}:`)); + console.log(prepend(JSON.stringify({ + request: format(req.fetch.request, req.fetch.requestBody), + response: format(req.fetch.response, req.fetch.responseBody) + }, null, 2))); + }); + } }); +/* eslint-enable */ diff --git a/test/pages/banner.html b/test/pages/banner.html index 2e88d356647..19593ff4909 100644 --- a/test/pages/banner.html +++ b/test/pages/banner.html @@ -57,6 +57,7 @@ }); pbjs.que.push(function () { + pbjs.setConfig({enableTIDs: true}); pbjs.addAdUnits(adUnits); pbjs.requestBids({ bidsBackHandler: sendAdServerRequest }); }); diff --git a/test/pages/bidderSettings.html b/test/pages/bidderSettings.html index 205fc250be1..1b4d60c166f 100644 --- a/test/pages/bidderSettings.html +++ b/test/pages/bidderSettings.html @@ -67,6 +67,7 @@ }); pbjs.que.push(function () { + pbjs.setConfig({enableTIDs: true}); pbjs.addAdUnits(adUnits); pbjs.bidderSettings = { appnexus: { diff --git a/test/pages/consent_mgt_gdpr.html b/test/pages/consent_mgt_gdpr.html index 2fd9e963d60..b22d1e958e0 100644 --- a/test/pages/consent_mgt_gdpr.html +++ b/test/pages/consent_mgt_gdpr.html @@ -146,6 +146,7 @@ pbjs.que.push(function () { pbjs.addAdUnits(adUnits); pbjs.setConfig({ + enableTIDs: true, consentManagement: { gdpr: { cmpApi: 'static', diff --git a/test/pages/currency.html b/test/pages/currency.html index 84abe75147c..27e0d801aec 100644 --- a/test/pages/currency.html +++ b/test/pages/currency.html @@ -77,6 +77,7 @@ pbjs.que.push(function() { pbjs.setConfig({ + enableTIDs: true, "currency": { "adServerCurrency": "GBP", "granularityMultiplier": 1, diff --git a/test/pages/instream.html b/test/pages/instream.html index 887b509813a..ca42815c1f8 100644 --- a/test/pages/instream.html +++ b/test/pages/instream.html @@ -8,8 +8,8 @@ Prebid.js video adUnit example - - + + @@ -60,6 +60,7 @@ pbjs.addAdUnits(videoAdUnit); pbjs.setConfig({ + enableTIDs: true, debug: true, cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' diff --git a/test/pages/multiple_bidders.html b/test/pages/multiple_bidders.html index b743306d1ba..8fb93f2b379 100644 --- a/test/pages/multiple_bidders.html +++ b/test/pages/multiple_bidders.html @@ -72,7 +72,7 @@ } }] }]; - + pbjs.setConfig({enableTIDs: true}); pbjs.addAdUnits(adUnits); pbjs.requestBids({ timeout: PREBID_TIMEOUT, diff --git a/test/pages/native.html b/test/pages/native.html index d5216dfb6e7..ab477d20c95 100644 --- a/test/pages/native.html +++ b/test/pages/native.html @@ -83,6 +83,7 @@ }); pbjs.que.push(function () { + pbjs.setConfig({enableTIDs: true}); pbjs.addAdUnits(adUnits); pbjs.requestBids({ bidsBackHandler: sendAdServerRequest }); }); diff --git a/test/pages/outstream.html b/test/pages/outstream.html index 96a219f02af..69195419923 100644 --- a/test/pages/outstream.html +++ b/test/pages/outstream.html @@ -61,7 +61,10 @@ googletag.cmd = googletag.cmd || []; pbjs.que.push(function () { - pbjs.setConfig({ debug: true }); + pbjs.setConfig({ + enableTIDs: true, + debug: true + }); pbjs.addAdUnits(outstreamVideoAdUnit); pbjs.bidderSettings = { appnexus: { diff --git a/test/spec/AnalyticsAdapter_spec.js b/test/spec/AnalyticsAdapter_spec.js index d9199f47af9..62c00e04403 100644 --- a/test/spec/AnalyticsAdapter_spec.js +++ b/test/spec/AnalyticsAdapter_spec.js @@ -1,19 +1,19 @@ -import { expect } from 'chai'; +import {expect} from 'chai'; import * as events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; -import { server } from 'test/mocks/xhr.js'; +import {server} from 'test/mocks/xhr.js'; +import {disableAjaxForAnalytics, enableAjaxForAnalytics} from '../mocks/analyticsStub.js'; +import {clearEvents} from 'src/events.js'; +import { + DEFAULT_EXCLUDE_EVENTS, + DEFAULT_INCLUDE_EVENTS, + setDebounceDelay +} from '../../libraries/analyticsAdapter/AnalyticsAdapter.js'; -const REQUEST_BIDS = CONSTANTS.EVENTS.REQUEST_BIDS; -const BID_REQUESTED = CONSTANTS.EVENTS.BID_REQUESTED; -const BID_RESPONSE = CONSTANTS.EVENTS.BID_RESPONSE; const BID_WON = CONSTANTS.EVENTS.BID_WON; -const BID_TIMEOUT = CONSTANTS.EVENTS.BID_TIMEOUT; -const AD_RENDER_FAILED = CONSTANTS.EVENTS.AD_RENDER_FAILED; -const AD_RENDER_SUCCEEDED = CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED; -const AUCTION_DEBUG = CONSTANTS.EVENTS.AUCTION_DEBUG; -const ADD_AD_UNITS = CONSTANTS.EVENTS.ADD_AD_UNITS; +const NO_BID = CONSTANTS.EVENTS.NO_BID; -const AnalyticsAdapter = require('src/AnalyticsAdapter').default; +const AnalyticsAdapter = require('libraries/analyticsAdapter/AnalyticsAdapter.js').default; const config = { url: 'https://localhost:9999/endpoint', analyticsType: 'endpoint' @@ -25,27 +25,39 @@ FEATURE: Analytics Adapters API AND an \`example\` instance of \`AnalyticsAdapter\`\n`, () => { let adapter; + before(enableAjaxForAnalytics); + after(disableAjaxForAnalytics); + beforeEach(function () { adapter = new AnalyticsAdapter(config); }); afterEach(function () { adapter.disableAnalytics(); + clearEvents(); + }); + + it('should track enable status in `enabled`', () => { + expect(adapter.enabled).to.equal(false); + adapter.enableAnalytics(); + expect(adapter.enabled).to.equal(true); + adapter.disableAnalytics(); + expect(adapter.enabled).to.equal(false); }); it(`SHOULD call the endpoint WHEN an event occurs that is to be tracked`, function () { - const eventType = BID_REQUESTED; - const args = { some: 'data' }; + const eventType = BID_WON; + const args = {some: 'data'}; - adapter.track({ eventType, args }); + adapter.track({eventType, args}); let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {some: 'data'}, eventType: 'bidRequested'}); + expect(result).to.deep.equal({args: {some: 'data'}, eventType}); }); it(`SHOULD queue the event first and then track it WHEN an event occurs before tracking library is available`, function () { - const eventType = BID_RESPONSE; - const args = { wat: 'wot' }; + const eventType = BID_WON; + const args = {wat: 'wot'}; events.emit(eventType, args); adapter.enableAnalytics(); @@ -53,9 +65,58 @@ FEATURE: Analytics Adapters API // As now AUCTION_DEBUG is triggered for WARNINGS too, the BID_RESPONSE goes last in the array const index = server.requests.length - 1; let result = JSON.parse(server.requests[index].requestBody); - expect(result).to.deep.equal({eventType: 'bidResponse', args: {wat: 'wot'}}); + expect(result).to.deep.equal({eventType, args: {wat: 'wot'}}); }); + describe('event filters', () => { + function fireEvents() { + events.emit(BID_WON, {}); + events.emit(NO_BID, {}); + } + function getEvents(ev) { + return server.requests + .map(r => JSON.parse(r.requestBody)) + .filter(r => r.eventType === ev) + } + + Object.entries({ + 'whitelist includeEvents': { + includeEvents: [BID_WON] + }, + 'blacklist excludeEvents': { + excludeEvents: [NO_BID] + }, + 'give precedence to exclude over include': { + includeEvents: [BID_WON, NO_BID], + excludeEvents: [NO_BID] + } + }).forEach(([t, config]) => { + it(`should ${t}`, () => { + fireEvents(); + adapter.enableAnalytics(config); + expect(getEvents(BID_WON).length).to.eql(1); + expect(getEvents(NO_BID).length).to.eql(0); + fireEvents(); + expect(getEvents(BID_WON).length).to.eql(2); + expect(getEvents(NO_BID).length).to.eql(0); + }) + }) + }) + + it('should prevent infinite loops when track triggers other events', () => { + let i = 0; + adapter.track = ((orig) => { + return function (event) { + i++; + orig.call(this, event); + events.emit(BID_WON, {}) + } + })(adapter.track); + adapter.enableAnalytics(config); + events.emit(BID_WON, {}); + expect(i >= 100).to.eql(false); + }) + describe(`WHEN an event occurs after enable analytics\n`, function () { beforeEach(function () { sinon.stub(events, 'getEvents').returns([]); // these tests shouldn't be affected by previous tests @@ -65,108 +126,26 @@ FEATURE: Analytics Adapters API events.getEvents.restore(); }); - it('SHOULD call global when a bidWon event occurs', function () { - const eventType = BID_WON; - const args = { more: 'info' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {more: 'info'}, eventType: 'bidWon'}); - }); - - it('SHOULD call global when a adRenderFailed event occurs', function () { - const eventType = AD_RENDER_FAILED; - const args = { call: 'adRenderFailed' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'adRenderFailed'}, eventType: 'adRenderFailed'}); - }); - - it('SHOULD call global when a adRenderSucceeded event occurs', function () { - const eventType = AD_RENDER_SUCCEEDED; - const args = { call: 'adRenderSucceeded' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'adRenderSucceeded'}, eventType: 'adRenderSucceeded'}); - }); - - it('SHOULD call global when an auction debug event occurs', function () { - const eventType = AUCTION_DEBUG; - const args = { call: 'auctionDebug' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'auctionDebug'}, eventType: 'auctionDebug'}); - }); - - it('SHOULD call global when an addAdUnits event occurs', function () { - const eventType = ADD_AD_UNITS; - const args = { call: 'addAdUnits' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'addAdUnits'}, eventType: 'addAdUnits'}); - }); - - it('SHOULD call global when a requestBids event occurs', function () { - const eventType = REQUEST_BIDS; - const args = { call: 'request' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'requestBids'}); - }); - - it('SHOULD call global when a bidRequest event occurs', function () { - const eventType = BID_REQUESTED; - const args = { call: 'request' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'request'}, eventType: 'bidRequested'}); - }); - - it('SHOULD call global when a bidResponse event occurs', function () { - const eventType = BID_RESPONSE; - const args = { call: 'response' }; + Object.values(DEFAULT_INCLUDE_EVENTS).forEach(eventType => { + it(`SHOULD call global when a ${eventType} event occurs`, () => { + const args = {more: 'info'}; - adapter.enableAnalytics(); - events.emit(eventType, args); - - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'response'}, eventType: 'bidResponse'}); - }); - - it('SHOULD call global when a bidTimeout event occurs', function () { - const eventType = BID_TIMEOUT; - const args = { call: 'timeout' }; - - adapter.enableAnalytics(); - events.emit(eventType, args); + adapter.enableAnalytics(); + events.emit(eventType, args); - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.deep.equal({args: {call: 'timeout'}, eventType: 'bidTimeout'}); + let result = JSON.parse(server.requests[server.requests.length - 1].requestBody); + sinon.assert.match(result, { + eventType, + args: { + more: 'info' + }, + }); + }); }); it('SHOULD NOT call global again when adapter.enableAnalytics is called with previous timeout', function () { - const eventType = BID_TIMEOUT; - const args = { call: 'timeout' }; + const eventType = BID_WON; + const args = {call: 'timeout'}; events.emit(eventType, args); adapter.enableAnalytics(); @@ -177,7 +156,7 @@ FEATURE: Analytics Adapters API describe(`AND sampling is enabled\n`, function () { const eventType = BID_WON; - const args = { more: 'info' }; + const args = {more: 'info'}; beforeEach(function () { sinon.stub(Math, 'random').returns(0.5); @@ -213,3 +192,39 @@ FEATURE: Analytics Adapters API }); }); }); + +describe('Analytics asynchronous event tracking', () => { + before(() => { + setDebounceDelay(100); + }); + after(() => { + setDebounceDelay(0); + }); + + let adapter, clock; + + beforeEach(() => { + clock = sinon.useFakeTimers(); + adapter = new AnalyticsAdapter(config); + adapter.track = sinon.stub(); + adapter.enableAnalytics({}); + }); + + afterEach(() => { + clock.restore(); + }) + + it('does not call track as long as events are coming', () => { + events.emit(BID_WON, {i: 0}); + sinon.assert.notCalled(adapter.track); + clock.tick(10); + events.emit(BID_WON, {i: 1}); + sinon.assert.notCalled(adapter.track); + clock.tick(10); + sinon.assert.notCalled(adapter.track); + clock.tick(100); + sinon.assert.calledTwice(adapter.track); + sinon.assert.calledWith(adapter.track.firstCall, {eventType: BID_WON, args: {i: 0}}); + sinon.assert.calledWith(adapter.track.secondCall, {eventType: BID_WON, args: {i: 1}}); + }); +}) diff --git a/test/spec/activities/allowActivites_spec.js b/test/spec/activities/allowActivites_spec.js new file mode 100644 index 00000000000..cc1c83ec4c9 --- /dev/null +++ b/test/spec/activities/allowActivites_spec.js @@ -0,0 +1,138 @@ +import {config} from 'src/config.js'; +import {ruleRegistry} from '../../../src/activities/rules.js'; +import {updateRulesFromConfig} from '../../../modules/allowActivities.js'; +import {activityParams} from '../../../src/activities/activityParams.js'; + +describe('allowActivities config', () => { + const MODULE_TYPE = 'test' + const MODULE_NAME = 'testMod'; + const ACTIVITY = 'testActivity'; + + let isAllowed, params; + + beforeEach(() => { + let registerRule; + [registerRule, isAllowed] = ruleRegistry(); + updateRulesFromConfig(registerRule); + params = activityParams(MODULE_TYPE, MODULE_NAME) + }); + + afterEach(() => { + config.resetConfig(); + }); + + function setupActivityConfig(cfg) { + config.setConfig({ + allowActivities: { + [ACTIVITY]: cfg + } + }) + } + + describe('default = false', () => { + it('should deny activites with no other rules', () => { + setupActivityConfig({ + default: false + }) + expect(isAllowed(ACTIVITY, {})).to.be.false; + }); + it('should not deny activities that are explicitly allowed', () => { + setupActivityConfig({ + default: false, + rules: [ + { + condition({componentName}) { + return componentName === MODULE_NAME + }, + allow: true + } + ] + }) + expect(isAllowed(ACTIVITY, params)).to.be.true; + }); + it('should be removable by a config update', () => { + setupActivityConfig({ + default: false + }); + setupActivityConfig({}); + expect(isAllowed(ACTIVITY, params)).to.be.true; + }) + }); + + describe('rules', () => { + it('are tested for their condition', () => { + setupActivityConfig({ + rules: [{ + condition({flag}) { return flag }, + allow: false + }] + }); + expect(isAllowed(ACTIVITY, params)).to.be.true; + params.flag = true; + expect(isAllowed(ACTIVITY, params)).to.be.false; + }); + + it('always apply if they have no condition', () => { + setupActivityConfig({ + rules: [{allow: false}] + }); + expect(isAllowed(ACTIVITY, params)).to.be.false; + }); + + it('do not choke when the condition throws', () => { + setupActivityConfig({ + rules: [{ + condition() { + throw new Error() + }, + allow: true + }] + }); + expect(isAllowed(ACTIVITY, params)).to.be.false; + }); + + it('does not pass private (underscored) parameters to condition', () => { + setupActivityConfig({ + rules: [{ + condition({_priv}) { return _priv }, + allow: false + }] + }); + params._priv = true; + expect(isAllowed(ACTIVITY, params)).to.be.true; + }) + + it('are evaluated in order of priority', () => { + setupActivityConfig({ + rules: [{ + priority: 1000, + allow: false + }, { + priority: 100, + allow: true + }] + }); + expect(isAllowed(ACTIVITY, params)).to.be.true; + }); + + it('can be set with priority 0', () => { + setupActivityConfig({ + rules: [{ + allow: false + }, { + priority: 0, + allow: true + }] + }); + expect(isAllowed(ACTIVITY, params)).to.be.true; + }) + + it('can be reset with a config update', () => { + setupActivityConfig({ + allow: false + }); + config.setConfig({allowActivities: {}}); + expect(isAllowed(ACTIVITY, params)).to.be.true; + }); + }); +}); diff --git a/test/spec/activities/objectGuard_spec.js b/test/spec/activities/objectGuard_spec.js new file mode 100644 index 00000000000..c88442e9111 --- /dev/null +++ b/test/spec/activities/objectGuard_spec.js @@ -0,0 +1,144 @@ +import {objectGuard, writeProtectRule} from '../../../libraries/objectGuard/objectGuard.js'; + +describe('objectGuard', () => { + describe('read rule', () => { + let rule, applies; + beforeEach(() => { + applies = true; + rule = { + paths: ['foo', 'outer.inner.foo'], + name: 'testRule', + applies: sinon.stub().callsFake(() => applies), + get(val) { return `repl${val}` }, + } + }) + it('can prevent top level read access', () => { + const {obj} = objectGuard([rule])({'foo': 1, 'other': 2}); + expect(obj).to.eql({ + foo: 'repl1', + other: 2 + }); + }); + + it('does not choke if a guarded property is missing', () => { + const {obj} = objectGuard([rule])({}); + expect(obj.foo).to.not.exist; + }); + + it('does not prevent access if applies returns false', () => { + applies = false; + const {obj} = objectGuard([rule])({foo: 1}); + expect(obj).to.eql({ + foo: 1 + }); + }) + + it('can prevent nested property access', () => { + const {obj} = objectGuard([rule])({ + other: 0, + outer: { + foo: 1, + inner: { + foo: 2 + }, + bar: { + foo: 3 + } + } + }); + expect(obj).to.eql({ + other: 0, + outer: { + foo: 1, + inner: { + foo: 'repl2', + }, + bar: { + foo: 3 + } + } + }) + }); + + it('does not call applies more than once', () => { + JSON.stringify(objectGuard([rule])({ + foo: 0, + outer: { + inner: { + foo: 1 + } + } + }).obj); + expect(rule.applies.callCount).to.equal(1); + }) + }); + + describe('write protection', () => { + let applies, rule; + + beforeEach(() => { + applies = true; + rule = writeProtectRule({ + paths: ['foo', 'bar', 'outer.inner.foo', 'outer.inner.bar'], + applies: sinon.stub().callsFake(() => applies) + }); + }); + + it('should undo top-level writes', () => { + const obj = {bar: {nested: 'val'}, other: 'val'}; + const guard = objectGuard([rule])(obj); + guard.obj.foo = 'denied'; + guard.obj.bar.nested = 'denied'; + guard.obj.bar.other = 'denied'; + guard.obj.other = 'allowed'; + guard.verify(); + expect(obj).to.eql({bar: {nested: 'val'}, other: 'allowed'}); + }); + + it('should undo top-level deletes', () => { + const obj = {foo: {nested: 'val'}, bar: 'val'}; + const guard = objectGuard([rule])(obj); + delete guard.obj.foo.nested; + delete guard.obj.bar; + guard.verify(); + expect(obj).to.eql({foo: {nested: 'val'}, bar: 'val'}); + }) + + it('should undo nested writes', () => { + const obj = {outer: {inner: {bar: {nested: 'val'}, other: 'val'}}}; + const guard = objectGuard([rule])(obj); + guard.obj.outer.inner.bar.other = 'denied'; + guard.obj.outer.inner.bar.nested = 'denied'; + guard.obj.outer.inner.foo = 'denied'; + guard.obj.outer.inner.other = 'allowed'; + guard.verify(); + expect(obj).to.eql({ + outer: { + inner: { + bar: { + nested: 'val' + }, + other: 'allowed' + } + } + }) + }); + + it('should undo nested deletes', () => { + const obj = {outer: {inner: {foo: {nested: 'val'}, bar: 'val'}}}; + const guard = objectGuard([rule])(obj); + delete guard.obj.outer.inner.foo.nested; + delete guard.obj.outer.inner.bar; + guard.verify(); + expect(obj).to.eql({outer: {inner: {foo: {nested: 'val'}, bar: 'val'}}}) + }); + + it('should work on null properties', () => { + const obj = {foo: null}; + const guard = objectGuard([rule])(obj); + guard.obj.foo = 'denied'; + guard.verify(); + expect(obj).to.eql({foo: null}); + }); + }); +}); diff --git a/test/spec/activities/ortbGuard_spec.js b/test/spec/activities/ortbGuard_spec.js new file mode 100644 index 00000000000..828cbe4e328 --- /dev/null +++ b/test/spec/activities/ortbGuard_spec.js @@ -0,0 +1,140 @@ +import {ortb2FragmentsGuardFactory, ortb2GuardFactory} from '../../../libraries/objectGuard/ortbGuard.js'; +import {ACTIVITY_PARAM_COMPONENT_NAME, ACTIVITY_PARAM_COMPONENT_TYPE} from '../../../src/activities/params.js'; +import { + ACTIVITY_ENRICH_EIDS, ACTIVITY_ENRICH_UFPD, + ACTIVITY_TRANSMIT_EIDS, + ACTIVITY_TRANSMIT_UFPD +} from '../../../src/activities/activities.js'; +import {activityParams} from '../../../src/activities/activityParams.js'; +import {deepAccess, deepClone, deepSetValue, mergeDeep} from '../../../src/utils.js'; +import {ORTB_EIDS_PATHS, ORTB_UFPD_PATHS} from '../../../src/activities/redactor.js'; +import {objectGuard, writeProtectRule} from '../../../libraries/objectGuard/objectGuard.js'; + +describe('ortb2Guard', () => { + const MOD_TYPE = 'test'; + const MOD_NAME = 'mock'; + let isAllowed, ortb2Guard; + beforeEach(() => { + isAllowed = sinon.stub(); + ortb2Guard = ortb2GuardFactory(function (activity, params) { + if (params[ACTIVITY_PARAM_COMPONENT_TYPE] === MOD_TYPE && params[ACTIVITY_PARAM_COMPONENT_NAME] === MOD_NAME) { + return isAllowed(activity) + } else { + throw new Error('wrong component') + } + }) + }); + + function testAllowDeny(transmitActivity, enrichActivity, fn) { + Object.entries({ + allowed: true, + denied: false + }).forEach(([t, allowed]) => { + describe(`when '${enrichActivity}' is ${t}`, () => { + beforeEach(() => { + isAllowed.callsFake((activity) => { + if (activity === transmitActivity) return true; + if (activity === enrichActivity) return allowed; + throw new Error('wrong activity'); + }) + }); + fn(allowed); + }) + }) + } + + function testPropertiesAreProtected(properties, allowed) { + properties.forEach(prop => { + it(`should ${allowed ? 'keep' : 'undo'} additions to ${prop}`, () => { + const orig = [{n: 'orig'}]; + const ortb2 = {}; + deepSetValue(ortb2, prop, deepClone(orig)); + const guard = ortb2Guard(ortb2, activityParams(MOD_TYPE, MOD_NAME)); + const mod = {}; + const insert = [{n: 'new'}]; + deepSetValue(mod, prop, insert); + mergeDeep(guard.obj, mod); + guard.verify(); + const actual = deepAccess(ortb2, prop); + if (allowed) { + expect(actual).to.eql(orig.concat(insert)) + } else { + expect(actual).to.eql(orig); + } + }); + + it(`should ${allowed ? 'keep' : 'undo'} modifications to ${prop}`, () => { + const orig = [{n: 'orig'}]; + const ortb2 = {}; + deepSetValue(ortb2, prop, orig); + const guard = ortb2Guard(ortb2, activityParams(MOD_TYPE, MOD_NAME)); + deepSetValue(guard.obj, `${prop}.0.n`, 'new'); + guard.verify(); + const actual = deepAccess(ortb2, prop); + if (allowed) { + expect(actual).to.eql([{n: 'new'}]); + } else { + expect(actual).to.eql([{n: 'orig'}]); + } + }); + }) + } + + testAllowDeny(ACTIVITY_TRANSMIT_EIDS, ACTIVITY_ENRICH_EIDS, (allowed) => { + testPropertiesAreProtected(ORTB_EIDS_PATHS, allowed); + }); + + testAllowDeny(ACTIVITY_TRANSMIT_UFPD, ACTIVITY_ENRICH_UFPD, (allowed) => { + testPropertiesAreProtected(ORTB_UFPD_PATHS, allowed); + }); +}); + +describe('ortb2FragmentsGuard', () => { + let guardFragments + beforeEach(() => { + const testGuard = objectGuard([ + writeProtectRule({ + paths: ['foo'], + applies: () => true, + name: 'testRule' + }) + ]) + guardFragments = ortb2FragmentsGuardFactory(testGuard); + }); + + it('should undo changes to global FPD', () => { + const fragments = { + global: { + foo: {inner: 'val'} + } + } + const guard = guardFragments(fragments); + guard.obj.global.foo = 'other'; + guard.verify(); + expect(fragments.global.foo).to.eql({inner: 'val'}); + }); + + it('should undo changes to bidder FPD', () => { + const fragments = { + bidder: { + A: { + foo: 'val' + } + } + }; + const guard = guardFragments(fragments); + guard.obj.bidder.A.foo = 'denied'; + guard.verify(); + expect(fragments.bidder.A).to.eql({foo: 'val'}); + }); + + it('should undo changes to bidder FPD that was not initially there', () => { + const fragments = { + bidder: {} + }; + const guard = guardFragments(fragments); + guard.obj.bidder.A = {foo: 'denied', other: 'allowed'}; + guard.verify(); + expect(fragments.bidder.A).to.eql({other: 'allowed'}); + }); +}) diff --git a/test/spec/activities/params_spec.js b/test/spec/activities/params_spec.js new file mode 100644 index 00000000000..d949cd41cb4 --- /dev/null +++ b/test/spec/activities/params_spec.js @@ -0,0 +1,25 @@ +import { + ACTIVITY_PARAM_ADAPTER_CODE, + ACTIVITY_PARAM_COMPONENT, ACTIVITY_PARAM_COMPONENT_NAME, + ACTIVITY_PARAM_COMPONENT_TYPE +} from '../../../src/activities/params.js'; +import adapterManager from '../../../src/adapterManager.js'; +import {MODULE_TYPE_BIDDER} from '../../../src/activities/modules.js'; +import {activityParams} from '../../../src/activities/activityParams.js'; + +describe('activityParams', () => { + it('fills out component params', () => { + sinon.assert.match(activityParams('bidder', 'mockBidder', {foo: 'bar'}), { + [ACTIVITY_PARAM_COMPONENT]: 'bidder.mockBidder', + [ACTIVITY_PARAM_COMPONENT_TYPE]: 'bidder', + [ACTIVITY_PARAM_COMPONENT_NAME]: 'mockBidder', + foo: 'bar' + }) + }); + + it('fills out adapterCode', () => { + adapterManager.registerBidAdapter({callBids: sinon.stub(), getSpec: sinon.stub().returns({})}, 'mockBidder') + adapterManager.aliasBidAdapter('mockBidder', 'mockAlias'); + expect(activityParams(MODULE_TYPE_BIDDER, 'mockAlias')[ACTIVITY_PARAM_ADAPTER_CODE]).to.equal('mockBidder'); + }); +}); diff --git a/test/spec/activities/redactor_spec.js b/test/spec/activities/redactor_spec.js new file mode 100644 index 00000000000..f54b2dcfb95 --- /dev/null +++ b/test/spec/activities/redactor_spec.js @@ -0,0 +1,304 @@ +import { + objectTransformer, + ORTB_EIDS_PATHS, ORTB_GEO_PATHS, + ORTB_UFPD_PATHS, + redactorFactory, redactRule +} from '../../../src/activities/redactor.js'; +import {ACTIVITY_PARAM_COMPONENT_NAME, ACTIVITY_PARAM_COMPONENT_TYPE} from '../../../src/activities/params.js'; +import { + ACTIVITY_TRANSMIT_EIDS, + ACTIVITY_TRANSMIT_PRECISE_GEO, ACTIVITY_TRANSMIT_TID, + ACTIVITY_TRANSMIT_UFPD +} from '../../../src/activities/activities.js'; +import {deepAccess, deepSetValue} from '../../../src/utils.js'; +import {activityParams} from '../../../src/activities/activityParams.js'; + +describe('objectTransformer', () => { + describe('using dummy rules', () => { + let rule, applies, run; + beforeEach(() => { + run = sinon.stub(); + applies = sinon.stub().callsFake(() => true) + rule = { + name: 'mockRule', + paths: ['foo', 'bar.baz'], + applies, + run, + } + }); + + it('runs rule for each path', () => { + const obj = {foo: 'val'}; + objectTransformer([rule])({}, obj); + sinon.assert.calledWith(run, obj, null, obj, 'foo'); + sinon.assert.calledWith(run, obj, 'bar', undefined, 'baz'); + }); + + it('does not run rule once it is known that it does not apply', () => { + applies.reset(); + applies.callsFake(() => false); + run.callsFake((_1, _2, _3, _4, applies) => applies()); + objectTransformer([rule])({}, {}); + expect(applies.callCount).to.equal(1); + expect(run.callCount).to.equal(1); + }); + + it('does not call apply more than once', () => { + run.callsFake((_1, _2, _3, _4, applies) => { + applies(); + applies(); + }); + objectTransformer([rule])({}, {}); + expect(applies.callCount).to.equal(1); + }); + + it('does not call apply if session already contains a result for the rule', () => { + objectTransformer([rule])({[rule.name]: false}, {}); + expect(applies.callCount).to.equal(0); + expect(run.callCount).to.equal(0); + }) + + it('passes arguments to applies', () => { + run.callsFake((_1, _2, _3, _4, applies) => applies()); + const arg1 = {n: 0}; + const arg2 = {n: 1}; + objectTransformer([rule])({}, {}, arg1, arg2); + sinon.assert.calledWith(applies, arg1, arg2); + }); + + it('collects rule results', () => { + let i = 0; + run.callsFake(() => i++); + const result = objectTransformer([rule])({}, {}); + expect(result).to.eql([0, 1]); + }) + }); + + describe('using redact rules', () => { + Object.entries({ + replacement: { + get(path, val) { + return `repl${val}` + }, + expectation(parent, prop, val) { + sinon.assert.match(parent, { + [prop]: val + }) + } + }, + removal: { + get(path, val) {}, + expectation(parent, prop, val) { + expect(Object.keys(parent)).to.not.include.members([prop]); + } + } + }).forEach(([t, {get, expectation}]) => { + describe(`property ${t}`, () => { + it('should work on top level properties', () => { + const obj = {foo: 1, bar: 2}; + objectTransformer([ + redactRule({ + name: 'test', + get, + paths: ['foo'], + applies() { return true } + }) + ])({}, obj); + sinon.assert.match(obj, { + bar: 2 + }); + expectation(obj, 'foo', get(1)); + }); + it('should work on nested properties', () => { + const obj = {outer: {inner: {foo: 'bar'}, baz: 0}}; + objectTransformer([ + redactRule({ + name: 'test', + get, + paths: ['outer.inner.foo'], + applies() { return true; } + }) + ])({}, obj); + sinon.assert.match(obj, { + outer: { + baz: 0 + } + }); + expectation(obj.outer.inner, 'foo', get('bar')) + }) + }); + }); + describe('should not run rule if property is', () => { + Object.entries({ + 'missing': {}, + 'empty array': {foo: []}, + 'empty object': {foo: {}}, + 'null': {foo: null}, + 'undefined': {foo: undefined} + }).forEach(([t, obj]) => { + it(t, () => { + const get = sinon.stub(); + const applies = sinon.stub() + objectTransformer([redactRule({ + name: 'test', + paths: ['foo'], + applies, + get, + })])({}, obj); + expect(get.called).to.be.false; + expect(applies.called).to.be.false; + }) + }) + }); + + describe('should run rule on falsy, but non-empty, value', () => { + Object.entries({ + zero: 0, + false: false + }).forEach(([t, val]) => { + it(t, () => { + const obj = {foo: val}; + objectTransformer([redactRule({ + name: 'test', + paths: ['foo'], + applies() { return true }, + get(val) { return 'repl' }, + })])({}, obj); + expect(obj).to.eql({foo: 'repl'}); + }) + }) + }); + + it('should not run applies twice for the same name/session combination', () => { + const applies = sinon.stub().callsFake(() => true); + const notApplies = sinon.stub().callsFake(() => false); + const t1 = objectTransformer([ + { + name: 'applies', + paths: ['foo'], + applies, + get(val) { return `repl_r1_${val}`; }, + }, + { + name: 'notApplies', + paths: ['notFoo'], + applies: notApplies, + } + ].map(redactRule)); + const t2 = objectTransformer([ + { + name: 'applies', + paths: ['bar'], + applies, + get(val) { return `repl_r2_${val}` } + }, + { + name: 'notApplies', + paths: ['notBar'], + applies: notApplies, + } + ].map(redactRule)); + const obj = { + foo: '1', + notFoo: '2', + bar: '3', + notBar: '4' + } + const session = {}; + t1(session, obj); + t2(session, obj); + expect(obj).to.eql({ + foo: 'repl_r1_1', + notFoo: '2', + bar: 'repl_r2_3', + notBar: '4' + }); + expect(applies.callCount).to.equal(1); + expect(notApplies.callCount).to.equal(1); + }) + }); +}); + +describe('redactor', () => { + const MODULE_TYPE = 'mockType'; + const MODULE_NAME = 'mockModule'; + + let isAllowed, redactor; + + beforeEach(() => { + isAllowed = sinon.stub(); + redactor = redactorFactory((activity, params) => { + if (params[ACTIVITY_PARAM_COMPONENT_TYPE] === MODULE_TYPE && params[ACTIVITY_PARAM_COMPONENT_NAME] === MODULE_NAME) { + return isAllowed(activity) + } else { + throw new Error('wrong component') + } + })(activityParams(MODULE_TYPE, MODULE_NAME)); + }); + + function testAllowDeny(activity, fn) { + Object.entries({ + allowed: true, + denied: false + }).forEach(([t, allowed]) => { + describe(`when '${activity}' is ${t}`, () => { + beforeEach(() => { + isAllowed.callsFake((act) => { + if (act === activity) { + return allowed; + } else { + throw new Error('wrong activity'); + } + }); + }); + fn(allowed); + }); + }); + } + + function testPropertiesAreRemoved(method, properties, allowed) { + properties.forEach(prop => { + it(`should ${allowed ? 'NOT ' : ''}remove ${prop}`, () => { + const obj = {}; + deepSetValue(obj, prop, 'mockVal'); + method()(obj); + expect(deepAccess(obj, prop)).to.eql(allowed ? 'mockVal' : undefined); + }) + }) + } + + describe('.bidRequest', () => { + testAllowDeny(ACTIVITY_TRANSMIT_EIDS, (allowed) => { + testPropertiesAreRemoved(() => redactor.bidRequest, ['userId', 'userIdAsEids'], allowed); + }); + + testAllowDeny(ACTIVITY_TRANSMIT_TID, (allowed) => { + testPropertiesAreRemoved(() => redactor.bidRequest, ['ortb2Imp.ext.tid'], allowed); + }) + }); + + describe('.ortb2', () => { + testAllowDeny(ACTIVITY_TRANSMIT_EIDS, (allowed) => { + testPropertiesAreRemoved(() => redactor.ortb2, ORTB_EIDS_PATHS, allowed) + }); + + testAllowDeny(ACTIVITY_TRANSMIT_UFPD, (allowed) => { + testPropertiesAreRemoved(() => redactor.ortb2, ORTB_UFPD_PATHS, allowed) + }); + + testAllowDeny(ACTIVITY_TRANSMIT_TID, (allowed) => { + testPropertiesAreRemoved(() => redactor.ortb2, ['source.tid'], allowed); + }); + + testAllowDeny(ACTIVITY_TRANSMIT_PRECISE_GEO, (allowed) => { + ORTB_GEO_PATHS.forEach(path => { + it(`should ${allowed ? 'NOT ' : ''} round down ${path}`, () => { + const ortb2 = {}; + deepSetValue(ortb2, path, 1.2345); + redactor.ortb2(ortb2); + expect(deepAccess(ortb2, path)).to.eql(allowed ? 1.2345 : 1.23); + }) + }) + }); + }); +}) diff --git a/test/spec/activities/rules_spec.js b/test/spec/activities/rules_spec.js new file mode 100644 index 00000000000..2acfae57980 --- /dev/null +++ b/test/spec/activities/rules_spec.js @@ -0,0 +1,135 @@ +import {ruleRegistry} from '../../../src/activities/rules.js'; + +describe('Activity control rules', () => { + const MOCK_ACTIVITY = 'mockActivity'; + const MOCK_RULE = 'mockRule'; + + let registerRule, isAllowed, logger; + + beforeEach(() => { + logger = { + logInfo: sinon.stub(), + logWarn: sinon.stub(), + logError: sinon.stub(), + }; + [registerRule, isAllowed] = ruleRegistry(logger); + }); + + it('allows by default', () => { + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.true; + }); + + it('denies if a rule throws', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => { + throw new Error('argh'); + }); + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.false; + }); + + it('denies if a rule denies', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false})); + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.false; + }); + + it('partitions rules by activity', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false})); + expect(isAllowed('other', {})).to.be.true; + }); + + it('passes params to rules', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, (params) => ({allow: params.foo !== 'bar'})); + expect(isAllowed(MOCK_ACTIVITY, {foo: 'notbar'})).to.be.true; + expect(isAllowed(MOCK_ACTIVITY, {foo: 'bar'})).to.be.false; + }); + + it('allows if rules do not opine', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => null); + expect(isAllowed(MOCK_ACTIVITY, {foo: 'bar'})).to.be.true; + }); + + it('denies if any rule denies', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => null); + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: true})); + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false})); + expect(isAllowed(MOCK_ACTIVITY, {foo: 'bar'})).to.be.false; + }); + + it('allows if higher priority allow rule trumps a lower priority deny rule', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false})); + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: true}), 0); + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.true; + }); + + it('denies if a higher priority deny rule trumps a lower priority allow rule', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: true})); + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false}), 0); + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.false; + }); + + it('can unregister rules', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: true})); + const r = registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false}), 0); + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.false; + r(); + expect(isAllowed(MOCK_ACTIVITY, {})).to.be.true; + }) + + it('logs INFO when explicit allow is found', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: true})); + isAllowed(MOCK_ACTIVITY, {}); + sinon.assert.calledWithMatch(logger.logInfo, new RegExp(MOCK_RULE)); + }); + + it('logs INFO with reason if the rule provides one', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: true, reason: 'because'})); + isAllowed(MOCK_ACTIVITY, {}); + sinon.assert.calledWithMatch(logger.logInfo, new RegExp(MOCK_RULE), /because/); + }); + + it('logs WARN when a deny is found', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false})); + isAllowed(MOCK_ACTIVITY, {}); + sinon.assert.calledWithMatch(logger.logWarn, new RegExp(MOCK_RULE)); + }); + + it('logs WARN with reason if the rule provides one', () => { + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({allow: false, reason: 'fail'})); + isAllowed(MOCK_ACTIVITY, {}); + sinon.assert.calledWithMatch(logger.logWarn, new RegExp(MOCK_RULE), /fail/); + }); + + describe('log message deduping', () => { + let clock, allow; + beforeEach(() => { + allow = false; + registerRule(MOCK_ACTIVITY, MOCK_RULE, () => ({ allow })); + clock = sinon.useFakeTimers(); + }); + afterEach(() => { + clock.restore(); + }); + + it('is applied to identical messages that are close in time', () => { + isAllowed(MOCK_ACTIVITY, {}); + clock.tick(100); + isAllowed(MOCK_ACTIVITY, {}); + expect(logger.logWarn.callCount).to.equal(1); + }); + + it('not to messages that show different results', () => { + isAllowed(MOCK_ACTIVITY, {}); + allow = true; + clock.tick(100); + isAllowed(MOCK_ACTIVITY, {}); + expect(logger.logWarn.callCount).to.equal(1); + expect(logger.logInfo.callCount).to.equal(1); + }); + + it('not to messages that are further apart in time', () => { + isAllowed(MOCK_ACTIVITY, {}); + clock.tick(2000); + isAllowed(MOCK_ACTIVITY, {}); + expect(logger.logWarn.callCount).to.equal(2); + }) + }) +}); diff --git a/test/spec/adUnits_spec.js b/test/spec/adUnits_spec.js index baa5b4ac8c4..089aabf22a5 100644 --- a/test/spec/adUnits_spec.js +++ b/test/spec/adUnits_spec.js @@ -1,3 +1,5 @@ +import 'src/prebid.js'; + describe('Publisher API _ AdUnits', function () { var assert = require('chai').assert; var expect = require('chai').expect; @@ -23,10 +25,10 @@ describe('Publisher API _ AdUnits', function () { } ] }, { - fpd: { - context: { - pbAdSlot: 'adSlotTest', + ortb2Imp: { + ext: { data: { + pbadslot: 'adSlotTest', inventory: [4], keywords: 'foo,bar', visitor: [1, 2, 3], diff --git a/test/spec/adloader_spec.js b/test/spec/adloader_spec.js index 0c50e66c63c..b775ec76e9b 100644 --- a/test/spec/adloader_spec.js +++ b/test/spec/adloader_spec.js @@ -69,4 +69,27 @@ describe('adLoader', function () { expect(utilsinsertElementStub.callCount).to.equal(2); }); }); + + it('attaches passed attributes to a script', function () { + const doc = { + createElement: function () { + return { + setAttribute: function (key, value) { + this[key] = value; + } + } + }, + getElementsByTagName: function() { + return { + firstChild: { + insertBefore: function() {} + } + } + } + }, + attrs = {'z': 'A', 'y': 2}; + let script = adLoader.loadExternalScript('someUrl', 'criteo', undefined, doc, attrs); + expect(script.z).to.equal('A'); + expect(script.y).to.equal(2); + }); }); diff --git a/test/spec/appnexusKeywords_spec.js b/test/spec/appnexusKeywords_spec.js new file mode 100644 index 00000000000..68faeff0b82 --- /dev/null +++ b/test/spec/appnexusKeywords_spec.js @@ -0,0 +1,70 @@ +import {transformBidderParamKeywords} from '../../libraries/appnexusUtils/anKeywords.js'; +import {expect} from 'chai/index.js'; +import * as utils from '../../src/utils.js'; + +describe('transformBidderParamKeywords', function () { + it('returns an array of objects when keyvalue is an array', function () { + let keywords = { + genre: ['rock', 'pop'] + }; + let result = transformBidderParamKeywords(keywords); + expect(result).to.deep.equal([{ + key: 'genre', + value: ['rock', 'pop'] + }]); + }); + + it('returns an array of objects when keyvalue is a string', function () { + let keywords = { + genre: 'opera' + }; + let result = transformBidderParamKeywords(keywords); + expect(result).to.deep.equal([{ + key: 'genre', + value: ['opera'] + }]); + }); + + it('returns an array of objects when keyvalue is a number', function () { + let keywords = { + age: 15 + }; + let result = transformBidderParamKeywords(keywords); + expect(result).to.deep.equal([{ + key: 'age', + value: ['15'] + }]); + }); + + it('returns an array of objects when using multiple keys with values of differing types', function () { + let keywords = { + genre: 'classical', + mix: ['1', 2, '3', 4], + age: 10 + }; + let result = transformBidderParamKeywords(keywords); + expect(result).to.deep.equal([{ + key: 'genre', + value: ['classical'] + }, { + key: 'mix', + value: ['1', '2', '3', '4'] + }, { + key: 'age', + value: ['10'] + }]); + }); + + it('returns an array of objects when the keyvalue uses an empty string', function () { + let keywords = { + test: [''], + test2: '' + }; + let result = transformBidderParamKeywords(keywords); + expect(result).to.deep.equal([{ + key: 'test', + }, { + key: 'test2', + }]); + }); +}); diff --git a/test/spec/auctionmanager_spec.js b/test/spec/auctionmanager_spec.js index a0435a83051..be4a7f819cd 100644 --- a/test/spec/auctionmanager_spec.js +++ b/test/spec/auctionmanager_spec.js @@ -5,7 +5,7 @@ import { adjustBids, getMediaTypeGranularity, getPriceByGranularity, - addBidResponse + addBidResponse, resetAuctionState } from 'src/auction.js'; import CONSTANTS from 'src/constants.json'; import * as auctionModule from 'src/auction.js'; @@ -18,10 +18,12 @@ import {find} from 'src/polyfill.js'; import { server } from 'test/mocks/xhr.js'; import {hook} from '../../src/hook.js'; import {auctionManager} from '../../src/auctionManager.js'; -import 'src/debugging.js' // some tests look for debugging side effects +import 'modules/debugging/index.js' // some tests look for debugging side effects import {AuctionIndex} from '../../src/auctionIndex.js'; import {expect} from 'chai'; -import {synchronizePromise} from '../helpers/syncPromise.js'; +import {deepClone} from '../../src/utils.js'; +import { IMAGE as ortbNativeRequest } from 'src/native.js'; +import {PrebidServer} from '../../modules/prebidServerBidAdapter/index.js'; var assert = require('assert'); @@ -47,6 +49,7 @@ function mockBid(opts) { let bidderCode = opts && opts.bidderCode; return { + adUnitCode: opts?.adUnitCode || ADUNIT_CODE, 'ad': 'creative', 'cpm': '1.99', 'width': 300, @@ -58,7 +61,21 @@ function mockBid(opts) { 'currency': 'USD', 'netRevenue': true, 'ttl': 360, - getSize: () => '300x250' + getSize: () => '300x250', + getIdentifiers() { + return { + src: this.source, + bidder: this.bidderCode, + bidId: this.requestId, + transactionId: this.transactionId, + auctionId: this.auctionId + } + }, + _ctx: { + adUnits: opts?.adUnits, + src: opts?.src, + uniquePbsTid: opts?.uniquePbsTid, + } }; } @@ -86,6 +103,9 @@ function mockBidRequest(bid, opts) { 'bidderCode': bidderCode || bid.bidderCode, 'auctionId': opts && opts.auctionId, 'bidderRequestId': requestId, + src: bid?._ctx?.src, + adUnitsS2SCopy: bid?._ctx?.src === CONSTANTS.S2S.SRC ? bid?._ctx?.adUnits : undefined, + uniquePbsTid: bid?._ctx?.src === CONSTANTS.S2S.SRC ? bid?._ctx?.uniquePbsTid : undefined, 'bids': [ { 'bidder': bidderCode || bid.bidderCode, @@ -98,7 +118,8 @@ function mockBidRequest(bid, opts) { 'bidId': bid.requestId, 'bidderRequestId': requestId, 'auctionId': opts && opts.auctionId, - 'mediaTypes': mediaType + 'mediaTypes': mediaType, + src: bid?._ctx?.src } ], 'auctionStart': 1505250713622, @@ -134,7 +155,7 @@ function mockAjaxBuilder() { } describe('auctionmanager.js', function () { - let indexAuctions, indexStub, promiseSandbox; + let indexAuctions, indexStub before(() => { // hooks are global and their side effects depend on what has been loaded @@ -150,13 +171,11 @@ describe('auctionmanager.js', function () { indexAuctions = []; indexStub = sinon.stub(auctionManager, 'index'); indexStub.get(() => new AuctionIndex(() => indexAuctions)); - promiseSandbox = sinon.createSandbox(); - synchronizePromise(promiseSandbox); + resetAuctionState(); }); afterEach(() => { indexStub.restore(); - promiseSandbox.restore(); }); describe('getKeyValueTargetingPairs', function () { @@ -178,8 +197,11 @@ describe('auctionmanager.js', function () { adId: '1adId', source: 'client', mediaType: 'banner', + creativeId: 'monkeys', meta: { - advertiserDomains: ['adomain'] + advertiserDomains: ['adomain'], + primaryCatId: 'IAB-test', + networkId: '123987' } }; @@ -193,6 +215,9 @@ describe('auctionmanager.js', function () { expected[ CONSTANTS.TARGETING_KEYS.SOURCE ] = bid.source; expected[ CONSTANTS.TARGETING_KEYS.FORMAT ] = bid.mediaType; expected[ CONSTANTS.TARGETING_KEYS.ADOMAIN ] = bid.meta.advertiserDomains[0]; + expected[ CONSTANTS.TARGETING_KEYS.ACAT ] = bid.meta.primaryCatId; + expected[ CONSTANTS.TARGETING_KEYS.DSP ] = bid.meta.networkId; + expected[ CONSTANTS.TARGETING_KEYS.CRID ] = bid.creativeId; if (bid.mediaType === 'video') { expected[ CONSTANTS.TARGETING_KEYS.UUID ] = bid.videoCacheKey; expected[ CONSTANTS.TARGETING_KEYS.CACHE_ID ] = bid.videoCacheKey; @@ -223,22 +248,33 @@ describe('auctionmanager.js', function () { assert.deepEqual(response, expected); }); - it('No bidder level configuration defined - default for video', function () { - config.setConfig({ - cache: { - url: 'https://prebid.adnxs.com/pbc/v1/cache' - } - }); - $$PREBID_GLOBAL$$.bidderSettings = {}; - let videoBid = utils.deepClone(bid); - videoBid.mediaType = 'video'; - videoBid.videoCacheKey = 'abc123def'; - - let expected = getDefaultExpected(videoBid); - let response = getKeyValueTargetingPairs(videoBid.bidderCode, videoBid); + it('should suppress acat if undefined', function () { + const noAcatBid = deepClone(DEFAULT_BID); + noAcatBid.meta.primaryCatId = '' + let expected = getDefaultExpected(noAcatBid); + delete expected.hb_acat; + let response = getKeyValueTargetingPairs(noAcatBid.bidderCode, noAcatBid); assert.deepEqual(response, expected); }); + if (FEATURES.VIDEO) { + it('No bidder level configuration defined - default for video', function () { + config.setConfig({ + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache' + } + }); + $$PREBID_GLOBAL$$.bidderSettings = {}; + let videoBid = utils.deepClone(bid); + videoBid.mediaType = 'video'; + videoBid.videoCacheKey = 'abc123def'; + + let expected = getDefaultExpected(videoBid); + let response = getKeyValueTargetingPairs(videoBid.bidderCode, videoBid); + assert.deepEqual(response, expected); + }); + } + it('Custom configuration for all bidders', function () { $$PREBID_GLOBAL$$.bidderSettings = { @@ -283,6 +319,24 @@ describe('auctionmanager.js', function () { val: function (bidResponse) { return bidResponse.meta.advertiserDomains[0]; } + }, + { + key: CONSTANTS.TARGETING_KEYS.CRID, + val: function (bidResponse) { + return bidResponse.creativeId; + } + }, + { + key: CONSTANTS.TARGETING_KEYS.DSP, + val: function (bidResponse) { + return bidResponse.meta.networkId; + } + }, + { + key: CONSTANTS.TARGETING_KEYS.ACAT, + val: function (bidResponse) { + return bidResponse.meta.primaryCatId; + } } ] @@ -296,17 +350,18 @@ describe('auctionmanager.js', function () { assert.deepEqual(response, expected); }); - it('Custom configuration for all bidders with video bid', function () { - config.setConfig({ - cache: { - url: 'https://prebid.adnxs.com/pbc/v1/cache' - } - }); - let videoBid = utils.deepClone(bid); - videoBid.mediaType = 'video'; - videoBid.videoCacheKey = 'abc123def'; + if (FEATURES.VIDEO) { + it('Custom configuration for all bidders with video bid', function () { + config.setConfig({ + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache' + } + }); + let videoBid = utils.deepClone(bid); + videoBid.mediaType = 'video'; + videoBid.videoCacheKey = 'abc123def'; - $$PREBID_GLOBAL$$.bidderSettings = + $$PREBID_GLOBAL$$.bidderSettings = { standard: { adserverTargeting: [ @@ -360,17 +415,36 @@ describe('auctionmanager.js', function () { val: function (bidResponse) { return bidResponse.meta.advertiserDomains[0]; } + }, + { + key: CONSTANTS.TARGETING_KEYS.CRID, + val: function (bidResponse) { + return bidResponse.creativeId; + } + }, + { + key: CONSTANTS.TARGETING_KEYS.DSP, + val: function (bidResponse) { + return bidResponse.meta.networkId; + } + }, + { + key: CONSTANTS.TARGETING_KEYS.ACAT, + val: function (bidResponse) { + return bidResponse.meta.primaryCatId; + } } ] } }; - let expected = getDefaultExpected(videoBid); + let expected = getDefaultExpected(videoBid); - let response = getKeyValueTargetingPairs(videoBid.bidderCode, videoBid); - assert.deepEqual(response, expected); - }); + let response = getKeyValueTargetingPairs(videoBid.bidderCode, videoBid); + assert.deepEqual(response, expected); + }); + } it('Custom configuration for one bidder', function () { $$PREBID_GLOBAL$$.bidderSettings = @@ -448,6 +522,24 @@ describe('auctionmanager.js', function () { assert.deepEqual(response, expected); }); + it('Should set targeting as expecting when pbs is enabled', function () { + config.setConfig({ + s2sConfig: { + accountId: '1', + enabled: true, + defaultVendor: 'appnexus', + bidders: ['appnexus'], + timeout: 1000, + adapter: 'prebidServer' + } + }); + + $$PREBID_GLOBAL$$.bidderSettings = {}; + let expected = getDefaultExpected(bid); + let response = getKeyValueTargetingPairs(bid.bidderCode, bid); + assert.deepEqual(response, expected); + }); + it('Custom bidCpmAdjustment for one bidder and inherit standard but doesn\'t use standard bidCpmAdjustment', function () { $$PREBID_GLOBAL$$.bidderSettings = { @@ -682,6 +774,136 @@ describe('auctionmanager.js', function () { }); }); + describe('createAuction', () => { + let adUnits, stubMakeBidRequests, stubCallAdapters, bids; + + beforeEach(() => { + bids = []; + stubMakeBidRequests = sinon.stub(adapterManager, 'makeBidRequests').returns([{ + bidderCode: BIDDER_CODE, + bids: [{ + bidder: BIDDER_CODE + }] + }]); + stubCallAdapters = sinon.stub(adapterManager, 'callBids').callsFake((au, reqs, addBid, done) => { + bids.forEach(bid => addBid(bid.adUnitCode, bid)); + reqs.forEach(r => done.apply(r)); + }); + adUnits = [{ + code: ADUNIT_CODE, + transactionId: ADUNIT_CODE, + bids: [ + {bidder: BIDDER_CODE}, + ] + }]; + }); + + afterEach(() => { + stubMakeBidRequests.restore(); + stubCallAdapters.restore(); + auctionManager.clearAllAuctions(); + }); + + it('passes global and bidder ortb2 to the auction', () => { + const ortb2Fragments = { + global: {}, + bidder: {} + } + const auction = auctionManager.createAuction({adUnits, ortb2Fragments}); + auction.callBids(); + const anyArgs = [...Array(7).keys()].map(() => sinon.match.any); + sinon.assert.calledWith(stubMakeBidRequests, ...anyArgs.slice(0, 5).concat([sinon.match.same(ortb2Fragments)])); + sinon.assert.calledWith(stubCallAdapters, ...anyArgs.slice(0, 7).concat([sinon.match.same(ortb2Fragments)])); + }); + + it('correctly adds nonbids when they are emitted', () => { + const ortb2Fragments = { + global: {}, + bidder: {} + } + const auction = auctionManager.createAuction({adUnits, ortb2Fragments}); + expect(auction.getNonBids()[0]).to.equal(undefined); + events.emit(CONSTANTS.EVENTS.SEAT_NON_BID, { + auctionId: auction.getAuctionId(), + seatnonbid: ['test'] + }); + expect(auction.getNonBids()[0]).to.equal('test'); + }); + + describe('stale auctions', () => { + let clock, auction; + beforeEach(() => { + clock = sinon.useFakeTimers(); + auction = auctionManager.createAuction({adUnits}); + indexAuctions.push(auction); + }); + afterEach(() => { + clock.restore(); + config.resetConfig(); + }); + + it('are dropped after their last bid becomes stale (if minBidCacheTTL is set)', () => { + config.setConfig({ + minBidCacheTTL: 0 + }); + bids = [ + { + adUnitCode: ADUNIT_CODE, + transactionId: ADUNIT_CODE, + ttl: 10 + }, { + adUnitCode: ADUNIT_CODE, + transactionId: ADUNIT_CODE, + ttl: 100 + } + ]; + auction.callBids(); + return auction.end.then(() => { + clock.tick(50 * 1000); + expect(auctionManager.getBidsReceived().length).to.equal(2); + clock.tick(56 * 1000); + expect(auctionManager.getBidsReceived()).to.eql([]); + }); + }); + + it('are dropped after `minBidCacheTTL` seconds if they had no bid', () => { + auction.callBids(); + config.setConfig({ + minBidCacheTTL: 2 + }); + return auction.end.then(() => { + expect(auctionManager.getNoBids().length).to.eql(1); + clock.tick(10 * 10000); + expect(auctionManager.getNoBids().length).to.eql(0); + }) + }); + + Object.entries({ + 'bids': { + bd: [{ + adUnitCode: ADUNIT_CODE, + transactionId: ADUNIT_CODE, + ttl: 10 + }], + entries: () => auctionManager.getBidsReceived() + }, + 'no bids': { + bd: [], + entries: () => auctionManager.getNoBids() + } + }).forEach(([t, {bd, entries}]) => { + it(`with ${t} are never dropped if minBidCacheTTL is not set`, () => { + bids = bd; + auction.callBids(); + return auction.end.then(() => { + clock.tick(100 * 1000); + expect(entries().length > 0).to.be.true; + }) + }) + }); + }) + }); + describe('addBidResponse #1', function () { let createAuctionStub; let adUnits; @@ -690,6 +912,7 @@ describe('auctionmanager.js', function () { let auction; let ajaxStub; let bids; + let bidderRequests; let makeRequestsStub; before(function () { @@ -704,6 +927,11 @@ describe('auctionmanager.js', function () { beforeEach(function () { ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder); adUnits = [{ + mediaTypes: { + banner: { + sizes: [] + } + }, code: ADUNIT_CODE, transactionId: ADUNIT_CODE, bids: [ @@ -713,7 +941,8 @@ describe('auctionmanager.js', function () { adUnitCodes = [ADUNIT_CODE]; auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: 3000}); bids = TEST_BIDS.slice(); - makeRequestsStub.returns(bids.map(b => mockBidRequest(b, {auctionId: auction.getAuctionId()}))); + bidderRequests = bids.map(b => mockBidRequest(b, {auctionId: auction.getAuctionId()})); + makeRequestsStub.returns(bidderRequests); indexAuctions = [auction]; createAuctionStub = sinon.stub(auctionModule, 'newAuction'); createAuctionStub.returns(auction); @@ -766,27 +995,45 @@ describe('auctionmanager.js', function () { assert.equal(registeredBid.adserverTargeting[CONSTANTS.TARGETING_KEYS.BIDDER], BIDDER_CODE); assert.equal(registeredBid.adserverTargeting.extra, 'stuff'); }); - - it('installs publisher-defined renderers on bids', function () { - let renderer = { - url: 'renderer.js', - render: (bid) => bid - }; - Object.assign(adUnits[0], {renderer}); - - let bids1 = Object.assign({}, - bids[0], - { - bidderCode: BIDDER_CODE, - mediaType: 'video-outstream', - } - ); - spec.interpretResponse.returns(bids1); + it('should add the bidResponse to the collection before calling BID_RESPONSE', function () { + let hasBid = false; + const eventHandler = function(bid) { + const storedBid = auction.getBidsReceived().pop(); + hasBid = storedBid === bid; + } + events.on(CONSTANTS.EVENTS.BID_RESPONSE, eventHandler); auction.callBids(); - const addedBid = auction.getBidsReceived().pop(); - assert.equal(addedBid.renderer.url, 'renderer.js'); + events.off(CONSTANTS.EVENTS.BID_RESPONSE, eventHandler); + assert.ok(hasBid, 'Bid not available'); }); + describe('install publisher-defined renderers', () => { + Object.entries({ + 'on adUnit': () => adUnits[0], + 'on bid': () => bidderRequests[0].bids[0], + }).forEach(([t, getObj]) => { + it(t, () => { + let renderer = { + url: 'renderer.js', + render: (bid) => bid + }; + + let bids1 = Object.assign({}, + bids[0], + { + bidderCode: BIDDER_CODE, + mediaType: 'video-outstream', + } + ); + Object.assign(getObj(), {renderer}); + spec.interpretResponse.returns(bids1); + auction.callBids(); + const addedBid = auction.getBidsReceived().pop(); + assert.equal(addedBid.renderer.url, 'renderer.js'); + }) + }) + }) + it('installs publisher-defined backup renderers on bids', function () { let renderer = { url: 'renderer.js', @@ -870,45 +1117,69 @@ describe('auctionmanager.js', function () { assert.strictEqual(addedBid.renderer.url, myBid.renderer.url); }); - it('bid for a regular unit and a video unit', function() { - let renderer = { - url: 'renderer.js', - render: (bid) => bid - }; - Object.assign(adUnits[0], {renderer}); - // make sure that if the renderer is only on the second ad unit, prebid - // still correctly uses it - let bid = mockBid(); - let bidRequests = [mockBidRequest(bid, {auctionId: auction.getAuctionId()})]; - - bidRequests[0].bids[1] = Object.assign({ - bidId: utils.getUniqueIdentifierStr() - }, bidRequests[0].bids[0]); - Object.assign(bidRequests[0].bids[0], { - adUnitCode: ADUNIT_CODE1, - transactionId: ADUNIT_CODE1, + describe('bid for a regular unit and a video unit', () => { + beforeEach(() => { + const renderer = { + url: 'renderer.js', + render: (bid) => bid + }; + Object.assign(adUnits[0], {renderer}); + // make sure that if the renderer is only on the second ad unit, prebid + // still correctly uses it + let bid = mockBid(); + let bidRequests = [mockBidRequest(bid, {auctionId: auction.getAuctionId()})]; + + bidRequests[0].bids[1] = Object.assign({ + bidId: utils.getUniqueIdentifierStr() + }, bidRequests[0].bids[0]); + Object.assign(bidRequests[0].bids[0], { + adUnitCode: ADUNIT_CODE1, + transactionId: ADUNIT_CODE1, + }); + + makeRequestsStub.returns(bidRequests); + + // this should correspond with the second bid in the bidReq because of the ad unit code + bid.mediaType = 'video-outstream'; + spec.interpretResponse.returns(bid); }); - makeRequestsStub.returns(bidRequests); + it('should use renderers on bid response', () => { + auction.callBids(); - // this should correspond with the second bid in the bidReq because of the ad unit code - bid.mediaType = 'video-outstream'; - spec.interpretResponse.returns(bid); + const addedBid = find(auction.getBidsReceived(), bid => bid.adUnitCode === ADUNIT_CODE); + assert.equal(addedBid.renderer.url, 'renderer.js'); + }); - auction.callBids(); + it('should resolve .end', () => { + auction.callBids(); + return auction.end.then(() => { + expect(auction.getBidsReceived().length).to.eql(1); + }) + }) + }) - const addedBid = find(auction.getBidsReceived(), bid => bid.adUnitCode == ADUNIT_CODE); - assert.equal(addedBid.renderer.url, 'renderer.js'); + it('sets bidResponse.ttlBuffer from adUnit.ttlBuffer', () => { + adUnits[0].ttlBuffer = 0; + auction.callBids(); + expect(auction.getBidsReceived()[0].ttlBuffer).to.eql(0); }); }); describe('when auction timeout is 20', function () { - let eventsEmitSpy; + let eventsEmitSpy, auctionDone; - function setupBids(auctionId) { - bids = [mockBid(), mockBid({ bidderCode: BIDDER_CODE1 })]; - let bidRequests = bids.map(bid => mockBidRequest(bid, {auctionId})); + function respondToRequest(requestIndex) { + server.requests[requestIndex].respond(200, {}, 'response body'); + } + + function runAuction() { + let bidRequests = bids.map(bid => mockBidRequest(bid, {auctionId: auction.getAuctionId()})); makeRequestsStub.returns(bidRequests); + return new Promise((resolve) => { + auctionDone = resolve; + auction.callBids(); + }) } beforeEach(function () { @@ -917,84 +1188,127 @@ describe('auctionmanager.js', function () { transactionId: ADUNIT_CODE, bids: [ {bidder: BIDDER_CODE, params: {placementId: 'id'}}, + {bidder: BIDDER_CODE1, params: {placementId: 'id'}}, ] }]; adUnitCodes = [ADUNIT_CODE]; eventsEmitSpy = sinon.spy(events, 'emit'); + bids = [mockBid(), mockBid({ bidderCode: BIDDER_CODE1 })]; + const spec1 = mockBidder(BIDDER_CODE, [bids[0]]); + registerBidder(spec1); + const spec2 = mockBidder(BIDDER_CODE1, [bids[1]]); + registerBidder(spec2); + auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: () => auctionDone(), cbTimeout: 20}); }); + afterEach(function () { events.emit.restore(); }); - it('should emit BID_TIMEOUT and AUCTION_END for timed out bids', function (done) { - const spec1 = mockBidder(BIDDER_CODE, [bids[0]]); - registerBidder(spec1); - const spec2 = mockBidder(BIDDER_CODE1, [bids[1]]); - registerBidder(spec2); + it('resolves .end on timeout', () => { + let endResolved = false; + auction.end.then(() => { + endResolved = true; + }) + const pm = runAuction().then(() => { + expect(endResolved).to.be.true; + }); + respondToRequest(0); + return pm; + }) - function respondToRequest(requestIndex) { - server.requests[requestIndex].respond(200, {}, 'response body'); - } - function auctionCallback() { + it('should emit BID_TIMEOUT and AUCTION_END for timed out bids', function () { + const pm = runAuction().then(() => { const bidTimeoutCall = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).getCalls()[0]; const timedOutBids = bidTimeoutCall.args[1]; assert.equal(timedOutBids.length, 1); assert.equal(timedOutBids[0].bidder, BIDDER_CODE1); + // Check that additional properties are available + assert.equal(timedOutBids[0].params[0].placementId, 'id'); const auctionEndCall = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.AUCTION_END).getCalls()[0]; const auctionProps = auctionEndCall.args[1]; assert.equal(auctionProps.adUnits, adUnits); assert.equal(auctionProps.timeout, 20); assert.equal(auctionProps.auctionStatus, AUCTION_COMPLETED) - done(); - } - auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: auctionCallback, cbTimeout: 20}); - setupBids(auction.getAuctionId()); - - auction.callBids(); + }); respondToRequest(0); + return pm; }); - it('should NOT emit BID_TIMEOUT when all bidders responded in time', function (done) { - const spec1 = mockBidder(BIDDER_CODE, [bids[0]]); - registerBidder(spec1); - const spec2 = mockBidder(BIDDER_CODE1, [bids[1]]); - registerBidder(spec2); - function respondToRequest(requestIndex) { - server.requests[requestIndex].respond(200, {}, 'response body'); - } - function auctionCallback() { + it('should NOT emit BID_TIMEOUT when all bidders responded in time', function () { + const pm = runAuction().then(() => { assert.ok(eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).notCalled, 'did not emit event BID_TIMEOUT'); - done(); - } - auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: auctionCallback, cbTimeout: 20}); - setupBids(auction.getAuctionId()); - auction.callBids(); + }); respondToRequest(0); respondToRequest(1); + return pm; }); - it('should NOT emit BID_TIMEOUT for bidders which responded in time but with an empty bid', function (done) { - const spec1 = mockBidder(BIDDER_CODE, []); - registerBidder(spec1); - const spec2 = mockBidder(BIDDER_CODE1, []); - registerBidder(spec2); - function respondToRequest(requestIndex) { - server.requests[requestIndex].respond(200, {}, 'response body'); - } - function auctionCallback() { + it('should NOT emit BID_TIMEOUT for bidders which responded in time but with an empty bid', function () { + const pm = runAuction().then(() => { const bidTimeoutCall = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).getCalls()[0]; const timedOutBids = bidTimeoutCall.args[1]; assert.equal(timedOutBids.length, 1); assert.equal(timedOutBids[0].bidder, BIDDER_CODE1); - done(); - } - auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: auctionCallback, cbTimeout: 20}); - setupBids(auction.getAuctionId()); - auction.callBids(); + }); respondToRequest(0); + return pm; }); + + it('should NOT emit BID_TIMEOUT for bidders that replied through S2S', () => { + adapterManager.registerBidAdapter(new PrebidServer(), 'pbs'); + config.setConfig({ + s2sConfig: [{ + accountId: '1', + enabled: true, + defaultVendor: 'appnexus', + bidders: ['mock-s2s-1'], + adapter: 'pbs' + }, { + accountId: '1', + enabled: true, + defaultVendor: 'rubicon', + bidders: ['mock-s2s-2'], + adapter: 'pbs' + }] + }) + adUnits[0].bids.push({bidder: 'mock-s2s-1'}, {bidder: 'mock-s2s-2'}) + const s2sAdUnits = deepClone(adUnits); + bids.unshift( + mockBid({bidderCode: 'mock-s2s-1', src: CONSTANTS.S2S.SRC, adUnits: s2sAdUnits, uniquePbsTid: '1'}), + mockBid({bidderCode: 'mock-s2s-2', src: CONSTANTS.S2S.SRC, adUnits: s2sAdUnits, uniquePbsTid: '2'}) + ); + Object.assign(s2sAdUnits[0], { + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bids: [ + { + bidder: 'mock-s2s-1', + bid_id: bids[0].requestId + }, + { + bidder: 'mock-s2s-2', + bid_id: bids[1].requestId + } + ] + }) + + const pm = runAuction().then(() => { + const toBids = eventsEmitSpy.withArgs(CONSTANTS.EVENTS.BID_TIMEOUT).getCalls()[0].args[1] + expect(toBids.map(bid => bid.bidder)).to.eql([ + 'mock-s2s-2', + BIDDER_CODE, + BIDDER_CODE1, + ]) + }); + respondToRequest(1); + return pm; + }) }); }); @@ -1152,8 +1466,7 @@ describe('auctionmanager.js', function () { enabled: true, bidRequests: [{ bidderCode: BIDDER_CODE, - adUnitCode: ADUNIT_CODE, - storedAuctionResponse: '11111' + adUnitCode: ADUNIT_CODE }] } }); @@ -1211,69 +1524,144 @@ describe('auctionmanager.js', function () { const bid = find(auctionBidRequests[0].bids, bid => bid.adUnitCode === ADUNIT_CODE); assert.equal(typeof bid !== 'undefined', true); - assert.equal(bid.hasOwnProperty('storedAuctionResponse'), true); - assert.equal(bid.storedAuctionResponse, '11111'); }); }); - describe('getMediaTypeGranularity', function () { - it('video', function () { - let mediaTypes = { video: {id: '1'} }; + if (FEATURES.NATIVE) { + describe('addBidResponse native', function () { + let makeRequestsStub; + let ajaxStub; + let spec; + let auction; - // mediaType is video and video.context is undefined - expect(getMediaTypeGranularity('video', mediaTypes, { - banner: 'low', - video: 'medium' - })).to.equal('medium'); + beforeEach(function () { + makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); + ajaxStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(mockAjaxBuilder); - expect(getMediaTypeGranularity('video', {}, { - banner: 'low', - video: 'medium' - })).to.equal('medium'); - `` - expect(getMediaTypeGranularity('video', undefined, { - banner: 'low', - video: 'medium' - })).to.equal('medium'); + const adUnits = [{ + code: ADUNIT_CODE, + transactionId: ADUNIT_CODE, + bids: [ + {bidder: BIDDER_CODE, params: {placementId: 'id'}}, + ], + nativeOrtbRequest: ortbNativeRequest.ortb, + mediaTypes: { native: { type: 'image' } } + }]; + auction = auctionModule.newAuction({adUnits, adUnitCodes: [ADUNIT_CODE], callback: function() {}, cbTimeout: 3000}); + indexAuctions = [auction]; + const createAuctionStub = sinon.stub(auctionModule, 'newAuction'); + createAuctionStub.returns(auction); - // also when mediaTypes.video is undefined - mediaTypes = { banner: {} }; - expect(getMediaTypeGranularity('video', mediaTypes, { - banner: 'low', - video: 'medium' - })).to.equal('medium'); + spec = mockBidder(BIDDER_CODE); + registerBidder(spec); + }); - // also when mediaTypes is undefined - expect(getMediaTypeGranularity('video', {}, { - banner: 'low', - video: 'medium' - })).to.equal('medium'); - }); + afterEach(function () { + ajaxStub.restore(); + auctionModule.newAuction.restore(); + adapterManager.makeBidRequests.restore(); + }); + + it('should add legacy fields to native response', function () { + let nativeBid = mockBid(); + nativeBid.mediaType = 'native'; + nativeBid.native = { + ortb: { + ver: '1.2', + assets: [ + { id: 2, title: { text: 'Sample title' } }, + { id: 4, data: { value: 'Sample body' } }, + { id: 3, data: { value: 'Sample sponsoredBy' } }, + { id: 1, img: { url: 'https://www.example.com/image.png', w: 200, h: 200 } }, + { id: 5, img: { url: 'https://www.example.com/icon.png', w: 32, h: 32 } } + ], + link: { url: 'http://www.click.com' }, + eventtrackers: [ + { event: 1, method: 1, url: 'http://www.imptracker.com' }, + { event: 1, method: 2, url: 'http://www.jstracker.com/file.js' } + ] + } + } - it('video-outstream', function () { - let mediaTypes = { video: { context: 'outstream' } }; + let bidRequest = mockBidRequest(nativeBid, { mediaType: { native: ortbNativeRequest } }); + makeRequestsStub.returns([bidRequest]); - expect(getMediaTypeGranularity('video', mediaTypes, { - 'banner': 'low', 'video': 'medium', 'video-outstream': 'high' - })).to.equal('high'); + spec.interpretResponse.returns(nativeBid); + auction.callBids(); + + const addedBid = auction.getBidsReceived().pop(); + assert.equal(addedBid.native.body, 'Sample body') + assert.equal(addedBid.native.title, 'Sample title') + assert.equal(addedBid.native.sponsoredBy, 'Sample sponsoredBy') + assert.equal(addedBid.native.clickUrl, 'http://www.click.com') + assert.equal(addedBid.native.image.url, 'https://www.example.com/image.png') + assert.equal(addedBid.native.icon.url, 'https://www.example.com/icon.png') + assert.equal(addedBid.native.impressionTrackers[0], 'http://www.imptracker.com') + assert.equal(addedBid.native.javascriptTrackers, '') + }); }); + } - it('video-instream', function () { - let mediaTypes = { video: { context: 'instream' } }; + describe('getMediaTypeGranularity', function () { + if (FEATURES.VIDEO) { + it('video', function () { + let mediaTypes = { video: {id: '1'} }; + + // mediaType is video and video.context is undefined + expect(getMediaTypeGranularity('video', mediaTypes, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + expect(getMediaTypeGranularity('video', {}, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + `` + expect(getMediaTypeGranularity('video', undefined, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + // also when mediaTypes.video is undefined + mediaTypes = { banner: {} }; + expect(getMediaTypeGranularity('video', mediaTypes, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + + // also when mediaTypes is undefined + expect(getMediaTypeGranularity('video', {}, { + banner: 'low', + video: 'medium' + })).to.equal('medium'); + }); - expect(getMediaTypeGranularity('video', mediaTypes, { - banner: 'low', video: 'medium', 'video-instream': 'high' - })).to.equal('high'); + it('video-outstream', function () { + let mediaTypes = { video: { context: 'outstream' } }; - // fall back to video if video-instream not found - expect(getMediaTypeGranularity('video', mediaTypes, { - banner: 'low', video: 'medium' - })).to.equal('medium'); + expect(getMediaTypeGranularity('video', mediaTypes, { + 'banner': 'low', 'video': 'medium', 'video-outstream': 'high' + })).to.equal('high'); + }); - expect(getMediaTypeGranularity('video', {mediaTypes: {banner: {}}}, { - banner: 'low', video: 'medium' - })).to.equal('medium'); - }); + it('video-instream', function () { + let mediaTypes = { video: { context: 'instream' } }; + + expect(getMediaTypeGranularity('video', mediaTypes, { + banner: 'low', video: 'medium', 'video-instream': 'high' + })).to.equal('high'); + + // fall back to video if video-instream not found + expect(getMediaTypeGranularity('video', mediaTypes, { + banner: 'low', video: 'medium' + })).to.equal('medium'); + + expect(getMediaTypeGranularity('video', {mediaTypes: {banner: {}}}, { + banner: 'low', video: 'medium' + })).to.equal('medium'); + }); + } it('native', function () { expect(getMediaTypeGranularity('native', {native: {}}, { @@ -1288,6 +1676,7 @@ describe('auctionmanager.js', function () { getAdUnits: () => getBidRequests().flatMap(br => br.bids).map(br => ({ code: br.adUnitCode, transactionId: br.transactionId, mediaTypes: br.mediaTypes })), getAuctionId: () => '1', addBidReceived: () => true, + addBidRejected: () => true, getTimeout: () => 1000, getAuctionStart: () => start, } @@ -1347,55 +1736,72 @@ describe('auctionmanager.js', function () { bidRequests = null; }); - it('should call auction done after bid is added to auction for mediaType banner', function () { - let ADUNIT_CODE2 = 'adUnitCode2'; - let BIDDER_CODE2 = 'sampleBidder2'; - - let bids1 = [mockBid({ bidderCode: BIDDER_CODE1, transactionId: ADUNIT_CODE1 })]; - let bids2 = [mockBid({ bidderCode: BIDDER_CODE2, transactionId: ADUNIT_CODE2 })]; - bidRequests = [ - mockBidRequest(bids[0]), - mockBidRequest(bids1[0], { adUnitCode: ADUNIT_CODE1 }), - mockBidRequest(bids2[0], { adUnitCode: ADUNIT_CODE2 }) - ]; - let cbs = auctionCallbacks(doneSpy, auction); - cbs.addBidResponse.call(bidRequests[0], ADUNIT_CODE, bids[0]); - cbs.adapterDone.call(bidRequests[0]); - cbs.addBidResponse.call(bidRequests[1], ADUNIT_CODE1, bids1[0]); - cbs.adapterDone.call(bidRequests[1]); - cbs.addBidResponse.call(bidRequests[2], ADUNIT_CODE2, bids2[0]); - cbs.adapterDone.call(bidRequests[2]); - assert.equal(doneSpy.callCount, 1); - }); + Object.entries({ + 'added to': (cbs) => cbs.addBidResponse, + 'rejected from': (cbs) => cbs.addBidResponse.reject, + }).forEach(([t, getMethod]) => { + it(`should call auction done after bid is ${t} auction for mediaType banner`, function () { + let ADUNIT_CODE2 = 'adUnitCode2'; + let BIDDER_CODE2 = 'sampleBidder2'; + + let bids1 = [mockBid({ bidderCode: BIDDER_CODE1, transactionId: ADUNIT_CODE1 })]; + let bids2 = [mockBid({ bidderCode: BIDDER_CODE2, transactionId: ADUNIT_CODE2 })]; + bidRequests = [ + mockBidRequest(bids[0]), + mockBidRequest(bids1[0], { adUnitCode: ADUNIT_CODE1 }), + mockBidRequest(bids2[0], { adUnitCode: ADUNIT_CODE2 }) + ]; + let cbs = auctionCallbacks(doneSpy, auction); + const method = getMethod(cbs); + method(ADUNIT_CODE, bids[0]); + cbs.adapterDone.call(bidRequests[0]); + method(ADUNIT_CODE1, bids1[0]); + cbs.adapterDone.call(bidRequests[1]); + method(ADUNIT_CODE2, bids2[0]); + cbs.adapterDone.call(bidRequests[2]); + assert.equal(doneSpy.callCount, 1); + }); + }) - it('should call auction done after prebid cache is complete for mediaType video', function() { - bids[0].mediaType = 'video'; - let bids1 = [mockBid({ bidderCode: BIDDER_CODE1 })]; + if (FEATURES.VIDEO) { + it('should call auction done after prebid cache is complete for mediaType video', function() { + bids[0].mediaType = 'video'; + let bids1 = [mockBid({ bidderCode: BIDDER_CODE1 })]; - let opts = { - mediaType: { - video: { - context: 'instream', - playerSize: [640, 480], - }, - } - }; - bidRequests = [ - mockBidRequest(bids[0], opts), - mockBidRequest(bids1[0], { adUnitCode: ADUNIT_CODE1 }), - ]; + let opts = { + mediaType: { + video: { + context: 'instream', + playerSize: [640, 480], + }, + } + }; + bidRequests = [ + mockBidRequest(bids[0], opts), + mockBidRequest(bids1[0], { adUnitCode: ADUNIT_CODE1 }), + ]; + + let cbs = auctionCallbacks(doneSpy, auction); + cbs.addBidResponse.call(bidRequests[0], ADUNIT_CODE, bids[0]); + cbs.adapterDone.call(bidRequests[0]); + cbs.addBidResponse.call(bidRequests[1], ADUNIT_CODE1, bids1[0]); + cbs.adapterDone.call(bidRequests[1]); + assert.equal(doneSpy.callCount, 0); + const uuid = 'c488b101-af3e-4a99-b538-00423e5a3371'; + const responseBody = `{"responses":[{"uuid":"${uuid}"}]}`; + server.requests[0].respond(200, { 'Content-Type': 'application/json' }, responseBody); + assert.equal(doneSpy.callCount, 1); + }); + } - let cbs = auctionCallbacks(doneSpy, auction); - cbs.addBidResponse.call(bidRequests[0], ADUNIT_CODE, bids[0]); - cbs.adapterDone.call(bidRequests[0]); - cbs.addBidResponse.call(bidRequests[1], ADUNIT_CODE1, bids1[0]); - cbs.adapterDone.call(bidRequests[1]); - assert.equal(doneSpy.callCount, 0); - const uuid = 'c488b101-af3e-4a99-b538-00423e5a3371'; - const responseBody = `{"responses":[{"uuid":"${uuid}"}]}`; - server.requests[0].respond(200, { 'Content-Type': 'application/json' }, responseBody); - assert.equal(doneSpy.callCount, 1); - }); + it('should convert cpm to number', () => { + auction.addBidReceived = sinon.spy(); + const cbs = auctionCallbacks(doneSpy, auction); + const bid = {...bids[0], cpm: '1.23'} + bidRequests = [mockBidRequest(bid)]; + cbs.addBidResponse.call(bidRequests[0], ADUNIT_CODE, bid); + sinon.assert.calledWith(auction.addBidReceived, sinon.match({cpm: 1.23})); + }) describe('when addBidResponse hook returns promises', () => { let resolvers, callbacks, bids; @@ -1419,7 +1825,6 @@ describe('auctionmanager.js', function () { } beforeEach(() => { - promiseSandbox.restore(); bids = [ mockBid({bidderCode: BIDDER_CODE1}), mockBid({bidderCode: BIDDER_CODE}) @@ -1509,6 +1914,65 @@ describe('auctionmanager.js', function () { }); }) }); + + describe('when bids are rejected', () => { + let cbs, bid, expectedRejection; + const onBidRejected = sinon.stub(); + const REJECTION_REASON = 'Bid rejected'; + const AU_CODE = 'au'; + + function rejectHook(fn, adUnitCode, bid, reject) { + reject(REJECTION_REASON); + reject(REJECTION_REASON); // second call should do nothing + } + + before(() => { + addBidResponse.before(rejectHook, 999); + events.on(CONSTANTS.EVENTS.BID_REJECTED, onBidRejected); + }); + + after(() => { + addBidResponse.getHooks({hook: rejectHook}).remove(); + events.off(CONSTANTS.EVENTS.BID_REJECTED, onBidRejected); + }); + + beforeEach(() => { + onBidRejected.reset(); + bid = mockBid({bidderCode: BIDDER_CODE}); + bidRequests = [ + mockBidRequest(bid), + ]; + cbs = auctionCallbacks(doneSpy, auction); + expectedRejection = sinon.match(Object.assign({}, bid, { + cpm: parseFloat(bid.cpm), + rejectionReason: REJECTION_REASON, + adUnitCode: AU_CODE + })); + auction.addBidRejected = sinon.stub(); + }); + + Object.entries({ + 'with addBidResponse.reject': () => cbs.addBidResponse.reject(AU_CODE, deepClone(bid), REJECTION_REASON), + 'from addBidResponse hooks': () => cbs.addBidResponse(AU_CODE, deepClone(bid)) + }).forEach(([t, rejectBid]) => { + describe(t, () => { + it('should emit a BID_REJECTED event', () => { + rejectBid(); + sinon.assert.calledWith(onBidRejected, expectedRejection); + }); + + it('should pass bid to auction.addBidRejected', () => { + rejectBid(); + sinon.assert.calledWith(auction.addBidRejected, expectedRejection); + }); + }) + }); + + it('addBidResponse hooks should not be able to reject the same bid twice', () => { + cbs.addBidResponse(AU_CODE, bid); + expect(auction.addBidRejected.calledOnce).to.be.true; + }); + }) }); describe('auctionOptions', function() { diff --git a/test/spec/config_spec.js b/test/spec/config_spec.js index 88d6e61c706..d7f6b9de6c0 100644 --- a/test/spec/config_spec.js +++ b/test/spec/config_spec.js @@ -20,9 +20,9 @@ describe('config API', function () { beforeEach(function () { config = newConfig(); - getConfig = config.getConfig; + getConfig = config.getAnyConfig; setConfig = config.setConfig; - readConfig = config.readConfig; + readConfig = config.readAnyConfig; mergeConfig = config.mergeConfig; getBidderConfig = config.getBidderConfig; setBidderConfig = config.setBidderConfig; @@ -106,6 +106,20 @@ describe('config API', function () { sinon.assert.calledOnce(wildcard); }); + it('getConfig subscribers are called immediately if passed {init: true}', () => { + const listener = sinon.spy(); + setConfig({foo: 'bar'}); + getConfig('foo', listener, {init: true}); + sinon.assert.calledWith(listener, {foo: 'bar'}); + }); + + it('getConfig subscribers with no topic are called immediately if passed {init: true}', () => { + const listener = sinon.spy(); + setConfig({foo: 'bar'}); + getConfig(listener, {init: true}); + sinon.assert.calledWith(listener, sinon.match({foo: 'bar'})); + }); + it('sets and gets arbitrary configuration properties', function () { setConfig({ baz: 'qux' }); expect(getConfig('baz')).to.equal('qux'); @@ -130,17 +144,6 @@ describe('config API', function () { expect(getConfig('foo')).to.eql({baz: 'qux'}); }); - it('moves fpd config into ortb2 properties', function () { - setConfig({fpd: {context: {keywords: 'foo,bar', data: {inventory: [1]}}}}); - expect(getConfig('ortb2')).to.eql({site: {keywords: 'foo,bar', ext: {data: {inventory: [1]}}}}); - expect(getConfig('fpd')).to.eql(undefined); - }); - - it('moves fpd bidderconfig into ortb2 properties', function () { - setBidderConfig({bidders: ['bidderA'], config: {fpd: {context: {keywords: 'foo,bar', data: {inventory: [1]}}}}}); - expect(getBidderConfig()).to.eql({'bidderA': {ortb2: {site: {keywords: 'foo,bar', ext: {data: {inventory: [1]}}}}}}); - }); - it('sets debugging', function () { setConfig({ debug: true }); expect(getConfig('debug')).to.be.true; @@ -593,6 +596,7 @@ describe('config API', function () { } setConfig({ + bidderTimeout: 2000, ortb2: { user: { data: [userObj1, userObj2] @@ -606,6 +610,7 @@ describe('config API', function () { }); const rtd = { + bidderTimeout: 3000, ortb2: { user: { data: [userObj1] @@ -620,11 +625,13 @@ describe('config API', function () { mergeConfig(rtd); let ortb2Config = getConfig('ortb2'); + let bidderTimeout = getConfig('bidderTimeout'); expect(ortb2Config.user.data).to.deep.include.members([userObj1, userObj2]); expect(ortb2Config.site.content.data).to.deep.include.members([siteObj1]); expect(ortb2Config.user.data).to.have.lengthOf(2); expect(ortb2Config.site.content.data).to.have.lengthOf(1); + expect(bidderTimeout).to.equal(3000); }); it('should not corrupt global configuration with bidder configuration', () => { diff --git a/test/spec/cpmBucketManager_spec.js b/test/spec/cpmBucketManager_spec.js index 0b8635a4e3b..044c65ca504 100644 --- a/test/spec/cpmBucketManager_spec.js +++ b/test/spec/cpmBucketManager_spec.js @@ -1,195 +1,257 @@ import { expect } from 'chai'; -import {getPriceBucketString, isValidPriceConfig} from 'src/cpmBucketManager.js'; +import { getPriceBucketString, isValidPriceConfig } from 'src/cpmBucketManager.js'; +import { config } from 'src/config.js'; + let cpmFixtures = require('test/fixtures/cpmInputsOutputs.json'); describe('cpmBucketManager', function () { - it('getPriceBucketString function generates the correct price strings', function () { - let input = cpmFixtures.cpmInputs; - for (let i = 0; i < input.length; i++) { - let output = getPriceBucketString(input[i]); - let jsonOutput = JSON.stringify(output); - expect(jsonOutput).to.deep.equal(JSON.stringify(cpmFixtures.priceStringOutputs[i])); - } - }); - - it('gets the correct custom bucket strings', function () { - let cpm = 16.50908; - let customConfig = { - 'buckets': [{ - 'precision': 4, - 'max': 3, - 'increment': 0.01, - }, - { - 'precision': 4, - 'max': 18, - 'increment': 0.05, - 'cap': true + describe('getPriceBucketString', function () { + it('getPriceBucketString function generates the correct price strings', function () { + let input = cpmFixtures.cpmInputs; + for (let i = 0; i < input.length; i++) { + let output = getPriceBucketString(input[i]); + let jsonOutput = JSON.stringify(output); + expect(jsonOutput).to.deep.equal(JSON.stringify(cpmFixtures.priceStringOutputs[i])); } - ] - }; - let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.5000"}'; - let output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - }); + }); - it('gets the correct custom bucket strings with irregular increment', function () { - let cpm = 14.50908; - let customConfig = { - 'buckets': [{ - 'precision': 4, - 'max': 4, - 'increment': 0.01, - }, - { - 'precision': 4, - 'max': 18, - 'increment': 0.3, - 'cap': true - } - ] - }; - let expected = '{"low":"5.00","med":"14.50","high":"14.50","auto":"14.50","dense":"14.50","custom":"14.5000"}'; - let output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - }); - - it('gets the correct custom bucket strings in non-USD currency', function () { - let cpm = 16.50908 * 110.49; - let customConfig = { - 'buckets': [{ - 'precision': 4, - 'max': 3, - 'increment': 0.01, - }, - { - 'precision': 4, - 'max': 18, - 'increment': 0.05, - 'cap': true - } - ] - }; - let expected = '{"low":"552.45","med":"1823.09","high":"1823.09","auto":"1823.09","dense":"1823.09","custom":"1823.0850"}'; - let output = getPriceBucketString(cpm, customConfig, 110.49); - expect(JSON.stringify(output)).to.deep.equal(expected); - }); - - it('gets the correct custom bucket strings with specific cpms that round oddly with certain increments', function () { - let customConfig = { - 'buckets': [{ - 'precision': 4, - 'max': 4, - 'increment': 0.10, - }] - }; - let cpm = 2.21; - let expected = '{"low":"2.00","med":"2.20","high":"2.21","auto":"2.20","dense":"2.21","custom":"2.2000"}'; - let output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - cpm = 3.15; - expected = '{"low":"3.00","med":"3.10","high":"3.15","auto":"3.15","dense":"3.15","custom":"3.1000"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - customConfig = { - 'buckets': [{ - 'precision': 3, - 'max': 6, - 'increment': 0.08, - }] - }; - cpm = 4.89; - expected = '{"low":"4.50","med":"4.80","high":"4.89","auto":"4.85","dense":"4.85","custom":"4.880"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - customConfig = { - 'buckets': [{ - 'precision': 3, - 'max': 6, - 'increment': 0.05, - }] - }; - cpm = 2.98; - expected = '{"low":"2.50","med":"2.90","high":"2.98","auto":"2.95","dense":"2.98","custom":"2.950"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - cpm = 2.99; - expected = '{"low":"2.50","med":"2.90","high":"2.99","auto":"2.95","dense":"2.99","custom":"2.950"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - customConfig = { - 'buckets': [{ - 'precision': 2, - 'max': 6, - 'increment': 0.01, - }] - }; - cpm = 4.01; - expected = '{"low":"4.00","med":"4.00","high":"4.01","auto":"4.00","dense":"4.00","custom":"4.01"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - cpm = 4.68; - expected = '{"low":"4.50","med":"4.60","high":"4.68","auto":"4.65","dense":"4.65","custom":"4.68"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - - cpm = 4.69; - expected = '{"low":"4.50","med":"4.60","high":"4.69","auto":"4.65","dense":"4.65","custom":"4.69"}'; - output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - }); - - it('gets custom bucket strings and it should honor 0', function () { - let cpm = 16.50908; - let customConfig = { - 'buckets': [ + it('gets the correct custom bucket strings', function () { + let cpm = 16.50908; + let customConfig = { + 'buckets': [{ + 'precision': 4, + 'max': 3, + 'increment': 0.01, + }, { - 'precision': 0, + 'precision': 4, 'max': 18, 'increment': 0.05, - } - ] - }; - let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"17"}'; - let output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); - }); + 'cap': true + }] + }; + let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.5000"}'; + let output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); - it('gets the custom bucket strings without passing precision and it should honor the default precision', function () { - let cpm = 16.50908; - let customConfig = { - 'buckets': [ + it('gets the correct custom bucket strings with irregular increment', function () { + let cpm = 14.50908; + let customConfig = { + 'buckets': [{ + 'precision': 4, + 'max': 4, + 'increment': 0.01, + }, { + 'precision': 4, + 'max': 18, + 'increment': 0.3, + 'cap': true + }] + }; + let expected = '{"low":"5.00","med":"14.50","high":"14.50","auto":"14.50","dense":"14.50","custom":"14.5000"}'; + let output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('gets the correct custom bucket strings in non-USD currency', function () { + let cpm = 16.50908 * 110.49; + let customConfig = { + 'buckets': [{ + 'precision': 4, + 'max': 3, + 'increment': 0.01, + }, + { + 'precision': 4, 'max': 18, 'increment': 0.05, - } - ] - }; - let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.50"}'; - let output = getPriceBucketString(cpm, customConfig); - expect(JSON.stringify(output)).to.deep.equal(expected); + 'cap': true + }] + }; + let expected = '{"low":"552.45","med":"1823.09","high":"1823.09","auto":"1823.09","dense":"1823.09","custom":"1823.0850"}'; + let output = getPriceBucketString(cpm, customConfig, 110.49); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('gets the correct custom bucket strings with specific cpms that round oddly with certain increments', function () { + let customConfig = { + 'buckets': [{ + 'precision': 4, + 'max': 4, + 'increment': 0.10, + }] + }; + let cpm = 2.21; + let expected = '{"low":"2.00","med":"2.20","high":"2.21","auto":"2.20","dense":"2.21","custom":"2.2000"}'; + let output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + cpm = 3.15; + expected = '{"low":"3.00","med":"3.10","high":"3.15","auto":"3.15","dense":"3.15","custom":"3.1000"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + customConfig = { + 'buckets': [{ + 'precision': 3, + 'max': 6, + 'increment': 0.08, + }] + }; + cpm = 4.89; + expected = '{"low":"4.50","med":"4.80","high":"4.89","auto":"4.85","dense":"4.85","custom":"4.880"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + customConfig = { + 'buckets': [{ + 'precision': 3, + 'max': 6, + 'increment': 0.05, + }] + }; + cpm = 2.98; + expected = '{"low":"2.50","med":"2.90","high":"2.98","auto":"2.95","dense":"2.98","custom":"2.950"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + cpm = 2.99; + expected = '{"low":"2.50","med":"2.90","high":"2.99","auto":"2.95","dense":"2.99","custom":"2.950"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + customConfig = { + 'buckets': [{ + 'precision': 2, + 'max': 6, + 'increment': 0.01, + }] + }; + cpm = 4.01; + expected = '{"low":"4.00","med":"4.00","high":"4.01","auto":"4.00","dense":"4.00","custom":"4.01"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + cpm = 4.68; + expected = '{"low":"4.50","med":"4.60","high":"4.68","auto":"4.65","dense":"4.65","custom":"4.68"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + + cpm = 4.69; + expected = '{"low":"4.50","med":"4.60","high":"4.69","auto":"4.65","dense":"4.65","custom":"4.69"}'; + output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('gets custom bucket strings and it should honor 0', function () { + let cpm = 16.50908; + let customConfig = { + 'buckets': [ + { + 'precision': 0, + 'max': 18, + 'increment': 0.05, + } + ] + }; + let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"17"}'; + let output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('gets the custom bucket strings without passing precision and it should honor the default precision', function () { + let cpm = 16.50908; + let customConfig = { + 'buckets': [ + { + 'max': 18, + 'increment': 0.05, + } + ] + }; + let expected = '{"low":"5.00","med":"16.50","high":"16.50","auto":"16.50","dense":"16.50","custom":"16.50"}'; + let output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('defaults to Math.floor if no rounding function is provided', function () { + let cpm = 6.516; + let customConfig = { + 'buckets': [ + { + 'max': 18, + 'increment': 0.05, + } + ] + }; + let expected = '{"low":"5.00","med":"6.50","high":"6.51","auto":"6.50","dense":"6.50","custom":"6.50"}'; + let output = getPriceBucketString(cpm, customConfig); + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('accepts custom rounding functions', function () { + let cpm = 6.516; + let customConfig = { + 'buckets': [ + { + 'max': 18, + 'increment': 0.05, + } + ] + }; + let getConfig = config.getConfig; + config.getConfig = () => Math.ceil; + let expected = '{"low":"5.00","med":"6.60","high":"6.52","auto":"6.60","dense":"6.55","custom":"6.55"}'; + let output = getPriceBucketString(cpm, customConfig); + config.getConfig = getConfig; + expect(JSON.stringify(output)).to.deep.equal(expected); + }); + + it('will default to Math.floor if passed an invalid rounding function', function () { + let cpm = 6.516; + let customConfig = { + 'buckets': [ + { + 'max': 18, + 'increment': 0.05, + } + ] + }; + let getConfig = config.getConfig; + config.getConfig = () => Math.ceil(5.3); + let expected = '{"low":"5.00","med":"6.50","high":"6.51","auto":"6.50","dense":"6.50","custom":"6.50"}'; + let output = getPriceBucketString(cpm, customConfig); + config.getConfig = getConfig; + expect(JSON.stringify(output)).to.deep.equal(expected); + }); }); - it('checks whether custom config is valid', function () { - let badConfig = { - 'buckets': [{ - 'max': 3, - 'increment': 0.01, - }, - { - 'max': 18, - // missing increment prop - 'cap': true - } - ] - }; + describe('isValidPriceConfig', function () { + it('checks whether custom config is valid', function () { + let badConfig = { + 'buckets': [{ + 'max': 3, + 'increment': 0.01, + }, + { + 'max': 18, + // missing increment prop + 'cap': true + }] + }; + expect(isValidPriceConfig(badConfig)).to.be.false; - expect(isValidPriceConfig(badConfig)).to.be.false; + let customConfig = { + 'buckets': [ + { + 'max': 18, + 'increment': 0.05, + } + ] + }; + expect(isValidPriceConfig(customConfig)).to.be.true; + }); }); }); diff --git a/test/spec/debugging_spec.js b/test/spec/debugging_spec.js index b0f78243e4a..8408ceec367 100644 --- a/test/spec/debugging_spec.js +++ b/test/spec/debugging_spec.js @@ -1,216 +1,93 @@ - -import { expect } from 'chai'; -import { sessionLoader, addBidResponseHook, addBidderRequestsHook, getConfig, disableOverrides, addBidResponseBound, addBidderRequestsBound } from 'src/debugging.js'; -import { addBidResponse, addBidderRequests } from 'src/auction.js'; -import { config } from 'src/config.js'; -import {hook} from '../../src/hook.js'; - -describe('bid overrides', function () { - let sandbox; - - before(() => { - hook.ready(); - }); - - beforeEach(function () { - sandbox = sinon.sandbox.create(); +import {ready, loadSession, getConfig, reset, debuggingModuleLoader, debuggingControls} from '../../src/debugging.js'; +import {getGlobal} from '../../src/prebidGlobal.js'; +import {defer} from '../../src/utils/promise.js'; +import funHooks from 'fun-hooks/no-eval/index.js'; + +describe('Debugging', () => { + beforeEach(() => { + reset(); }); - afterEach(function () { - window.sessionStorage.clear(); - config.resetConfig(); - sandbox.restore(); + after(() => { + reset(); }); - describe('initialization', function () { - beforeEach(function () { - sandbox.stub(config, 'setConfig'); - }); - - afterEach(function () { - disableOverrides(); - }); - - it('should happen when enabled with setConfig', function () { - getConfig({ - enabled: true + describe('module loader', () => { + let script, scriptResult, alreadyInstalled, loader; + beforeEach(() => { + script = sinon.stub().callsFake(() => { + getGlobal()._installDebugging = sinon.stub(); + return scriptResult; }); - - expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); - expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); + alreadyInstalled = sinon.stub(); + loader = debuggingModuleLoader({alreadyInstalled, script}); }); - it('should happen when configuration found in sessionStorage', function () { - sessionLoader({ - getItem: () => ('{"enabled": true}') - }); - expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); - expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); - }); - - it('should not throw if sessionStorage is inaccessible', function () { - expect(() => { - sessionLoader({ - getItem() { - throw new Error('test'); - } - }); - }).not.to.throw(); - }); - }); - - describe('bidResponse hook', function () { - let mockBids; - let bids; - - beforeEach(function () { - let baseBid = { - 'bidderCode': 'rubicon', - 'width': 970, - 'height': 250, - 'statusMessage': 'Bid available', - 'mediaType': 'banner', - 'source': 'client', - 'currency': 'USD', - 'cpm': 0.5, - 'ttl': 300, - 'netRevenue': false, - 'adUnitCode': '/19968336/header-bid-tag-0' - }; - mockBids = []; - mockBids.push(baseBid); - mockBids.push(Object.assign({}, baseBid, { - bidderCode: 'appnexus' - })); - - bids = []; - }); + afterEach(() => { + delete getGlobal()._installDebugging; + }) - function run(overrides) { - mockBids.forEach(bid => { - let next = (adUnitCode, bid) => { - bids.push(bid); - }; - addBidResponseHook.bind(overrides)(next, bid.adUnitCode, bid); + it('should not attempt to load if debugging module is already installed', () => { + alreadyInstalled.returns(true); + return loader().then(() => { + expect(script.called).to.be.false; }); - } - - it('should allow us to exclude bidders', function () { - run({ - enabled: true, - bidders: ['appnexus'] - }); - - expect(bids.length).to.equal(1); - expect(bids[0].bidderCode).to.equal('appnexus'); }); - it('should allow us to override all bids', function () { - run({ - enabled: true, - bids: [{ - cpm: 2 - }] - }); - - expect(bids.length).to.equal(2); - sinon.assert.match(bids[0], { - cpm: 2, - isDebug: true, - }) - sinon.assert.match(bids[1], { - cpm: 2, - isDebug: true, + it('should not attempt to load twice', () => { + alreadyInstalled.returns(false); + scriptResult = Promise.resolve(); + return Promise.all([loader(), loader()]).then(() => { + expect(script.callCount).to.equal(1); }); }); - it('should allow us to override bids by bidder', function () { - run({ - enabled: true, - bids: [{ - bidder: 'rubicon', - cpm: 2 - }] + it('should call _installDebugging after loading', () => { + alreadyInstalled.returns(false); + scriptResult = Promise.resolve(); + return loader().then(() => { + expect(getGlobal()._installDebugging.called).to.be.true; }); - - expect(bids.length).to.equal(2); - sinon.assert.match(bids[0], { - cpm: 2, - isDebug: true - }); - sinon.assert.match(bids[1], { - cpm: 0.5, - isDebug: sinon.match.falsy - }) }); - it('should allow us to override bids by adUnitCode', function () { - mockBids[1].adUnitCode = 'test'; - - run({ - enabled: true, - bids: [{ - adUnitCode: 'test', - cpm: 2 - }] - }); - - expect(bids.length).to.equal(2); - sinon.assert.match(bids[0], { - cpm: 0.5, - isDebug: sinon.match.falsy, - }); - sinon.assert.match(bids[1], { - cpm: 2, - isDebug: true, + it('should not call _installDebugging if load fails', () => { + const error = new Error(); + alreadyInstalled.returns(false); + scriptResult = Promise.reject(error) + return loader().then(() => { + throw new Error('loader should not resolve'); + }).catch((err) => { + expect(err).to.equal(error); + expect(getGlobal()._installDebugging.called).to.be.false; }); }); }); - describe('bidRequests hook', function () { - let mockBidRequests; - let bidderRequests; - - beforeEach(function () { - let baseBidderRequest = { - 'bidderCode': 'rubicon', - 'bids': [{ - 'width': 970, - 'height': 250, - 'statusMessage': 'Bid available', - 'mediaType': 'banner', - 'source': 'client', - 'currency': 'USD', - 'cpm': 0.5, - 'ttl': 300, - 'netRevenue': false, - 'adUnitCode': '/19968336/header-bid-tag-0' - }] - }; - mockBidRequests = []; - mockBidRequests.push(baseBidderRequest); - mockBidRequests.push(Object.assign({}, baseBidderRequest, { - bidderCode: 'appnexus' - })); - - bidderRequests = []; - }); - - function run(overrides) { - let next = (b) => { - bidderRequests = b; - }; - addBidderRequestsHook.bind(overrides)(next, mockBidRequests); - } - - it('should allow us to exclude bidders', function () { - run({ - enabled: true, - bidders: ['appnexus'] + describe('debugging controls', () => { + let debugging, loader, hook, hookRan; + + beforeEach(() => { + loader = defer(); + hookRan = false; + hook = funHooks()('sync', () => { hookRan = true }); + debugging = debuggingControls({load: sinon.stub().returns(loader.promise), hook}); + }) + + it('should delay execution of hook until module is loaded', () => { + debugging.enable(); + hook(); + expect(hookRan).to.be.false; + loader.resolve(); + return loader.promise.then(() => { + expect(hookRan).to.be.true; }); - - expect(bidderRequests.length).to.equal(1); - expect(bidderRequests[0].bidderCode).to.equal('appnexus'); }); + + it('should restore hook behavior when disabled', () => { + debugging.enable(); + debugging.disable(); + hook(); + expect(hookRan).to.be.true; + }) }); }); diff --git a/test/spec/fpd/enrichment_spec.js b/test/spec/fpd/enrichment_spec.js new file mode 100644 index 00000000000..3b3afb15f8c --- /dev/null +++ b/test/spec/fpd/enrichment_spec.js @@ -0,0 +1,326 @@ +import {dep, enrichFPD} from '../../../src/fpd/enrichment.js'; +import {hook} from '../../../src/hook.js'; +import {expect} from 'chai/index.mjs'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import {CLIENT_SECTIONS} from '../../../src/fpd/oneClient.js'; + +describe('FPD enrichment', () => { + let sandbox; + before(() => { + hook.ready(); + }); + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + afterEach(() => { + sandbox.restore(); + config.resetConfig(); + }); + + function fpd(ortb2 = {}) { + return enrichFPD(Promise.resolve(ortb2)); + } + + function mockWindow() { + return { + innerHeight: 1, + innerWidth: 1, + navigator: { + language: '' + }, + document: { + querySelector: sinon.stub() + } + }; + } + + function testWindows(getWindow, fn) { + Object.entries({ + 'top': ['getWindowTop', 'getWindowSelf'], + 'self': ['getWindowSelf', 'getWindowTop'] + }).forEach(([t, [winWorks, winThrows]]) => { + describe(`using window.${t}`, () => { + beforeEach(() => { + sandbox.stub(dep, winWorks).callsFake(getWindow); + sandbox.stub(dep, winThrows).throws(new Error()); + }); + fn(); + }); + }); + } + + CLIENT_SECTIONS.forEach(section => { + describe(`${section}, when set`, () => { + const ORTB2 = {[section]: {ext: {}}} + + it('sets domain and publisher.domain', () => { + const refererInfo = { + page: 'www.example.com', + }; + sandbox.stub(dep, 'getRefererInfo').callsFake(() => refererInfo); + sandbox.stub(dep, 'findRootDomain').callsFake((dom) => `publisher.${dom}`); + return fpd(ORTB2).then(ortb2 => { + sinon.assert.match(ortb2[section], { + domain: 'example.com', + publisher: { + domain: 'publisher.example.com' + } + }); + }); + }) + + describe('keywords', () => { + let metaTag; + beforeEach(() => { + metaTag = document.createElement('meta'); + metaTag.name = 'keywords'; + metaTag.content = 'kw1, kw2'; + document.head.appendChild(metaTag); + }); + afterEach(() => { + document.head.removeChild(metaTag); + }); + + testWindows(() => window, () => { + it(`sets kewwords from meta tag`, () => { + return fpd(ORTB2).then(ortb2 => { + expect(ortb2[section].keywords).to.eql('kw1,kw2'); + }); + }); + }); + }); + + it('should not set keywords if meta tag is not present', () => { + return fpd(ORTB2).then(ortb2 => { + expect(ortb2[section].hasOwnProperty('keywords')).to.be.false; + }); + }); + }) + }) + + describe('site', () => { + describe('when mixed with app/dooh', () => { + beforeEach(() => { + sinon.stub(utils, 'logWarn'); + }); + + afterEach(() => { + utils.logWarn.restore(); + }); + + ['dooh', 'app'].forEach(prop => { + it(`should not be set when ${prop} is set`, () => { + return fpd({[prop]: {foo: 'bar'}}).then(ortb2 => { + expect(ortb2.site).to.not.exist; + sinon.assert.notCalled(utils.logWarn); // make sure we don't generate "both site and app are set" warnings + }) + }) + }) + }) + + it('sets page, ref', () => { + const refererInfo = { + page: 'www.example.com', + ref: 'referrer.com' + }; + sandbox.stub(dep, 'getRefererInfo').callsFake(() => refererInfo); + return fpd().then(ortb2 => { + sinon.assert.match(ortb2.site, { + page: 'www.example.com', + ref: 'referrer.com', + }); + }); + }); + + it('respects pub-provided fpd', () => { + return fpd({ + site: { + publisher: { + domain: 'pub.com' + } + } + }).then(ortb2 => { + expect(ortb2.site.publisher.domain).to.eql('pub.com'); + }); + }); + + it('respects config set through setConfig({site})', () => { + sandbox.stub(dep, 'getRefererInfo').callsFake(() => ({ + page: 'www.example.com', + ref: 'referrer.com', + })); + config.setConfig({ + site: { + ref: 'override.com', + priority: 'lower' + } + }); + return fpd({site: {priority: 'highest'}}).then(ortb2 => { + sinon.assert.match(ortb2.site, { + page: 'www.example.com', + ref: 'override.com', + priority: 'highest' + }) + }) + }) + }); + + describe('device', () => { + let win; + beforeEach(() => { + win = mockWindow(); + }); + testWindows(() => win, () => { + it('sets w/h', () => { + win.innerHeight = 123; + win.innerWidth = 321; + return fpd().then(ortb2 => { + sinon.assert.match(ortb2.device, { + w: 321, + h: 123, + }); + }); + }); + + it('sets ua', () => { + win.navigator.userAgent = 'mock-ua'; + return fpd().then(ortb2 => { + expect(ortb2.device.ua).to.eql('mock-ua'); + }) + }); + + it('sets language', () => { + win.navigator.language = 'lang-ignored'; + return fpd().then(ortb2 => { + expect(ortb2.device.language).to.eql('lang'); + }) + }); + + it('respects setConfig({device})', () => { + win.navigator.userAgent = 'ua'; + win.navigator.language = 'lang'; + config.setConfig({ + device: { + language: 'override', + priority: 'lower' + } + }); + return fpd({device: {priority: 'highest'}}).then(ortb2 => { + sinon.assert.match(ortb2.device, { + language: 'override', + priority: 'highest', + ua: 'ua' + }) + }) + }) + }); + }); + + describe('app', () => { + it('respects setConfig({app})', () => { + config.setConfig({ + app: { + priority: 'lower', + prop: 'value' + } + }); + return fpd({app: {priority: 'highest'}}).then(ortb2 => { + sinon.assert.match(ortb2.app, { + priority: 'highest', + prop: 'value' + }) + }) + }) + }) + + describe('regs', () => { + describe('gpc', () => { + let win; + beforeEach(() => { + win = mockWindow(); + }); + testWindows(() => win, () => { + it('is set if globalPrivacyControl is set', () => { + win.navigator.globalPrivacyControl = true; + return fpd().then(ortb2 => { + expect(ortb2.regs.ext.gpc).to.eql(1); + }); + }); + + it('is not set otherwise', () => { + return fpd().then(ortb2 => { + expect(ortb2.regs?.ext?.gpc).to.not.exist; + }) + }) + }); + }) + describe('coppa', () => { + [[true, 1], [false, 0]].forEach(([cfgVal, regVal]) => { + it(`is set to ${regVal} if config = ${cfgVal}`, () => { + config.setConfig({coppa: cfgVal}); + return fpd().then(ortb2 => { + expect(ortb2.regs.coppa).to.eql(regVal); + }) + }); + }) + + it('is not set if not configured', () => { + return fpd().then(ortb2 => { + expect(ortb2.regs?.coppa).to.not.exist; + }) + }) + }); + }); + + describe('sua', () => { + it('does not set device.sua if resolved sua is null', () => { + sandbox.stub(dep, 'getHighEntropySUA').returns(Promise.resolve()); + // Add hints so it will attempt to retrieve high entropy values + config.setConfig({ + firstPartyData: { + uaHints: ['bitness'], + } + }); + return fpd().then(ortb2 => { + expect(ortb2.device.sua).to.not.exist; + }) + }); + it('uses low entropy values if uaHints is []', () => { + sandbox.stub(dep, 'getLowEntropySUA').callsFake(() => ({mock: 'sua'})); + config.setConfig({ + firstPartyData: { + uaHints: [], + } + }) + return fpd().then(ortb2 => { + expect(ortb2.device.sua).to.eql({mock: 'sua'}); + }) + }); + it('uses high entropy values otherwise', () => { + sandbox.stub(dep, 'getHighEntropySUA').callsFake((hints) => Promise.resolve({hints})); + config.setConfig({ + firstPartyData: { + uaHints: ['h1', 'h2'] + } + }); + return fpd().then(ortb2 => { + expect(ortb2.device.sua).to.eql({hints: ['h1', 'h2']}) + }) + }); + }); + + it('leaves only one of app, site, dooh', () => { + return fpd({ + app: {p: 'val'}, + site: {p: 'val'}, + dooh: {p: 'val'} + }).then(ortb2 => { + expect(ortb2.app).to.not.exist; + expect(ortb2.site).to.not.exist; + sinon.assert.match(ortb2.dooh, { + p: 'val' + }) + }); + }) +}); diff --git a/test/spec/fpd/gdpr_spec.js b/test/spec/fpd/gdpr_spec.js new file mode 100644 index 00000000000..8fc04815112 --- /dev/null +++ b/test/spec/fpd/gdpr_spec.js @@ -0,0 +1,47 @@ +import {gdprDataHandler} from '../../../src/adapterManager.js'; +import {enrichFPDHook} from '../../../modules/consentManagement.js'; + +describe('GDPR FPD enrichment', () => { + let sandbox, consent; + beforeEach(() => { + consent = null; + sandbox = sinon.sandbox.create(); + sandbox.stub(gdprDataHandler, 'getConsentData').callsFake(() => consent); + }); + afterEach(() => { + sandbox.restore(); + }) + + function callHook() { + let result; + enrichFPDHook((res) => { result = res }, Promise.resolve({})); + return result; + } + + it('sets gdpr properties from gdprDataHandler', () => { + consent = {gdprApplies: true, consentString: 'consent'}; + return callHook().then(ortb2 => { + expect(ortb2.regs.ext.gdpr).to.eql(1); + expect(ortb2.user.ext.consent).to.eql('consent'); + }) + }); + + it('does not set it if missing', () => { + return callHook().then((ortb2) => { + expect(ortb2).to.eql({}); + }) + }); + + it('sets user.ext.consent, but not regs.ext.gdpr, if gpdrApplies is not a boolean', () => { + consent = {consentString: 'mock-consent'}; + return callHook().then(ortb2 => { + expect(ortb2).to.eql({ + user: { + ext: { + consent: 'mock-consent' + } + } + }) + }) + }); +}); diff --git a/test/spec/fpd/oneClient.js b/test/spec/fpd/oneClient.js new file mode 100644 index 00000000000..4ecde8d8a38 --- /dev/null +++ b/test/spec/fpd/oneClient.js @@ -0,0 +1,24 @@ +import {clientSectionChecker} from '../../../src/fpd/oneClient.js'; + +describe('onlyOneClientSection', () => { + const oneClient = clientSectionChecker(); + [ + [['app'], 'app'], + [['site'], 'site'], + [['dooh'], 'dooh'], + [['app', 'site'], 'app'], + [['dooh', 'app', 'site'], 'dooh'], + [['dooh', 'site'], 'dooh'] + ].forEach(([sections, winner]) => { + it(`should leave only ${winner} in request when it contains ${sections.join(', ')}`, () => { + const req = Object.fromEntries(sections.map(s => [s, {foo: 'bar'}])); + oneClient(req); + expect(Object.keys(req)).to.eql([winner]); + }) + }); + it('should not choke if none of the sections are in the request', () => { + const req = {}; + oneClient(req); + expect(req).to.eql({}); + }); +}); diff --git a/test/spec/fpd/rootDomain_spec.js b/test/spec/fpd/rootDomain_spec.js new file mode 100644 index 00000000000..008ef749edc --- /dev/null +++ b/test/spec/fpd/rootDomain_spec.js @@ -0,0 +1,61 @@ +import {expect} from 'chai/index.js'; +import {findRootDomain, coreStorage} from 'src/fpd/rootDomain.js'; + +describe('findRootDomain', function () { + let sandbox, cookies, rejectDomain; + + beforeEach(function () { + findRootDomain.clear(); + cookies = {}; + rejectDomain = ''; + sandbox = sinon.createSandbox(); + sandbox.stub(coreStorage, 'cookiesAreEnabled').returns(true); + sandbox.stub(coreStorage, 'setCookie').callsFake((cookie, value, expiration, sameSite, domain) => { + if (rejectDomain !== domain) { + if (new Date(expiration) <= Date.now()) { + delete cookies[cookie]; + } else { + cookies[cookie] = value; + } + } + }) + sandbox.stub(coreStorage, 'getCookie').callsFake((cookie) => { + return cookies[cookie] + }); + }); + + afterEach(function () { + sandbox.restore(); + }); + + after(() => { + findRootDomain.clear(); + }) + + it('should just find the root domain', function () { + rejectDomain = 'co.uk'; + var domain = findRootDomain('sub.realdomain.co.uk'); + expect(domain).to.be.eq('realdomain.co.uk'); + expect(cookies).to.eql({}); + }); + + it('should find the full domain when no subdomain is present', function () { + rejectDomain = 'co.uk'; + var domain = findRootDomain('realdomain.co.uk'); + expect(domain).to.be.eq('realdomain.co.uk'); + expect(cookies).to.eql({}); + }); + + it('should return domain as-is if cookies are disabled', () => { + coreStorage.cookiesAreEnabled.returns(false); + expect(findRootDomain('sub.example.com')).to.eql('sub.example.com'); + sinon.assert.notCalled(coreStorage.setCookie); + }); + + it('should memoize default value', () => { + const domain = findRootDomain(); + expect(domain.length > 0).to.be.true; + expect(findRootDomain()).to.eql(domain); + sinon.assert.calledOnce(coreStorage.getCookie); + }); +}); diff --git a/test/spec/fpd/sua_spec.js b/test/spec/fpd/sua_spec.js new file mode 100644 index 00000000000..63e0068d0ef --- /dev/null +++ b/test/spec/fpd/sua_spec.js @@ -0,0 +1,256 @@ +import { + highEntropySUAAccessor, + lowEntropySUAAccessor, + SUA_SOURCE_HIGH_ENTROPY, + SUA_SOURCE_LOW_ENTROPY, + SUA_SOURCE_UNKNOWN, + suaFromUAData, + uaDataToSUA +} from '../../../src/fpd/sua.js'; + +describe('uaDataToSUA', () => { + Object.entries({ + 'platform': 'platform', + 'browsers': 'brands', + 'mobile': 'mobile', + 'architecture': 'architecture', + 'model': 'model', + 'bitness': 'bitness' + }).forEach(([suaKey, uaKey]) => { + it(`should not set ${suaKey} if ${uaKey} is missing from UAData`, () => { + const example = { + platform: 'Windows', + brands: [{brand: 'Mock', version: 'mk'}], + mobile: true, + model: 'mockModel', + bitness: '64', + architecture: 'arm' + } + delete example[uaKey]; + const sua = uaDataToSUA(SUA_SOURCE_UNKNOWN, example); + expect(sua.hasOwnProperty(suaKey)).to.be.false; + }) + }); + + it('should convert low-entropy userAgentData', () => { + const sua = uaDataToSUA(SUA_SOURCE_LOW_ENTROPY, { + 'brands': [ + { + 'brand': '.Not/A)Brand', + 'version': '99' + }, + { + 'brand': 'Google Chrome', + 'version': '103' + }, + { + 'brand': 'Chromium', + 'version': '103' + } + ], + 'mobile': false, + 'platform': 'Linux' + }); + + expect(sua).to.eql({ + source: SUA_SOURCE_LOW_ENTROPY, + mobile: 0, + platform: { + brand: 'Linux', + }, + browsers: [ + { + brand: '.Not/A)Brand', + version: [ + '99' + ] + }, + { + brand: 'Google Chrome', + version: [ + '103' + ] + }, + { + brand: 'Chromium', + version: [ + '103' + ] + } + ] + }) + }); + + it('should convert high entropy properties', () => { + const uaData = { + architecture: 'x86', + bitness: '64', + fullVersionList: [ + { + 'brand': '.Not/A)Brand', + 'version': '99.0.0.0' + }, + { + 'brand': 'Google Chrome', + 'version': '103.0.5060.134' + }, + { + 'brand': 'Chromium', + 'version': '103.0.5060.134' + } + ], + brands: [ + { + 'brand': '.Not/A)Brand', + 'version': '99' + }, + { + 'brand': 'Google Chrome', + 'version': '103' + }, + { + 'brand': 'Chromium', + 'version': '103' + } + ], + model: 'mockModel', + platform: 'Linux', + platformVersion: '5.14.0' + } + + expect(uaDataToSUA(SUA_SOURCE_HIGH_ENTROPY, uaData)).to.eql({ + source: SUA_SOURCE_HIGH_ENTROPY, + architecture: 'x86', + bitness: '64', + model: 'mockModel', + platform: { + brand: 'Linux', + version: [ + '5', + '14', + '0' + ] + }, + browsers: [ + { + brand: '.Not/A)Brand', + version: [ + '99', + '0', + '0', + '0' + ] + }, + { + brand: 'Google Chrome', + version: [ + '103', + '0', + '5060', + '134' + ] + }, + { + brand: 'Chromium', + version: [ + '103', + '0', + '5060', + '134' + ] + } + ] + }) + }) +}); + +describe('lowEntropySUAAccessor', () => { + // Set up a mock data with readonly property + class MockUserAgentData {} + Object.defineProperty(MockUserAgentData.prototype, 'mobile', { + value: false, + writable: false, + enumerable: true + }); + + function getSUA(uaData) { + return lowEntropySUAAccessor(uaData)(); + } + + it('should not be modifiable', () => { + const sua = getSUA({}); + expect(() => { sua.prop = 'value'; }).to.throw(); + }); + + it('should return null if no uaData is available', () => { + expect(getSUA(null)).to.eql(null); + }) + + it('should return null if uaData is empty', () => { + expect(getSUA({})).to.eql(null); + }) + + it('should return mobile and source', () => { + expect(getSUA(new MockUserAgentData())).to.eql({mobile: 0, source: 1}) + }) +}); + +describe('highEntropySUAAccessor', () => { + let userAgentData, uaResult, getSUA; + beforeEach(() => { + uaResult = {}; + userAgentData = { + getHighEntropyValues: sinon.stub().callsFake(() => Promise.resolve(uaResult)) + }; + getSUA = highEntropySUAAccessor(userAgentData); + }); + + describe('should resolve to null if', () => { + it('uaData is not available', () => { + getSUA = highEntropySUAAccessor(null); + return getSUA().then((result) => { + expect(result).to.eql(null); + }) + }); + it('getHighEntropyValues is not avialable', () => { + delete userAgentData.getHighEntropyValues; + return getSUA().then((result) => { + expect(result).to.eql(null); + }) + }); + it('getHighEntropyValues throws', () => { + userAgentData.getHighEntropyValues.callsFake(() => { throw new Error() }); + return getSUA().then((result) => { + expect(result).to.eql(null); + }) + }); + it('getHighEntropyValues rejects', () => { + userAgentData.getHighEntropyValues.callsFake(() => Promise.reject(new Error())); + return getSUA().then((result) => { + expect(result).to.eql(null); + }) + }); + it('getHighEntropyValues returns an empty object', () => { + userAgentData.getHighEntropyValues.callsFake(() => Promise.resolve({})); + return getSUA().then((result) => { + expect(result).to.eql(null); + }); + }) + }); + it('should pass hints to userAgentData', () => { + getSUA(['h1', 'h2']); + sinon.assert.calledWith(userAgentData.getHighEntropyValues, ['h1', 'h2']); + }); + + it('should cache results for a set of hints', () => { + getSUA(['h1', 'h2']); + getSUA(['h2', 'h1']); + sinon.assert.calledOnce(userAgentData.getHighEntropyValues); + }); + + it('should return unmodifiable objects', () => { + return getSUA().then(result => { + expect(() => { result.prop = 'value'; }).to.throw(); + }) + }) +}) diff --git a/test/spec/fpd/usp_spec.js b/test/spec/fpd/usp_spec.js new file mode 100644 index 00000000000..f616b086ffa --- /dev/null +++ b/test/spec/fpd/usp_spec.js @@ -0,0 +1,36 @@ +import {enrichFPDHook} from '../../../modules/consentManagementUsp.js'; +import {uspDataHandler} from '../../../src/adapterManager.js'; + +describe('FPD enrichment USP', () => { + let sandbox, consent; + beforeEach(() => { + consent = null; + sandbox = sinon.sandbox.create(); + sandbox.stub(uspDataHandler, 'getConsentData').callsFake(() => consent); + }); + + afterEach(() => { + sandbox.restore(); + }); + + function callHook() { + let result; + enrichFPDHook((res) => { + result = res; + }, Promise.resolve({})); + return result; + } + + it('sets regs.ext.us_privacy from uspDataHandler', () => { + consent = '1NN'; + return callHook().then(ortb2 => { + expect(ortb2.regs.ext.us_privacy).to.eql('1NN'); + }) + }); + + it('does not set if missing', () => { + return callHook().then(ortb2 => { + expect(ortb2).to.eql({}); + }) + }); +}); diff --git a/test/spec/keywords_spec.js b/test/spec/keywords_spec.js new file mode 100644 index 00000000000..e048ead3b98 --- /dev/null +++ b/test/spec/keywords_spec.js @@ -0,0 +1,102 @@ +import {getAllOrtbKeywords, mergeKeywords} from '../../libraries/keywords/keywords.js'; + +describe('mergeKeywords', () => { + Object.entries({ + 'single list': { + input: [ + 'one, two' + ], + output: [ + 'one', + 'two' + ] + }, + 'multiple lists': { + input: [ + 'one, two', + 'two, three' + ], + output: [ + 'one', + 'two', + 'three' + ] + }, + 'null lists': { + input: [ + undefined, + 'one, two', + null, + 'three' + ], + output: [ + 'one', + 'two', + 'three' + ] + }, + 'empty keywords': { + input: [ + 'one,,two' + ], + output: [ + 'one', + 'two' + ] + }, + 'extra whitespace': { + input: [ + ' one, two , three ' + ], + output: [ + 'one', + 'two', + 'three' + ] + }, + 'mixed with arrays': { + input: [ + ['one'], + 'one, two', + ['three', 'two'] + ], + output: [ + 'one', + 'two', + 'three' + ] + } + }).forEach(([t, {input, output}]) => { + it(`can merge ${t}`, () => { + expect(mergeKeywords(...input)).to.have.members(output); + }) + }) +}); + +describe('getAllOrtbKeywodrs', () => { + const SAMPLE_ORTB = { + app: { + keywords: 'one, two' + }, + site: { + content: { + keywords: 'one, three' + } + }, + user: { + keywords: 'four' + } + } + + it('can extract keywords from ortb', () => { + expect(getAllOrtbKeywords(SAMPLE_ORTB)).to.have.members([ + 'one', 'two', 'three', 'four' + ]); + }); + + it('merges with extra comma-separated keywords', () => { + expect(getAllOrtbKeywords(SAMPLE_ORTB, 'two,five')).to.have.members([ + 'one', 'two', 'three', 'four', 'five' + ]) + }) +}) diff --git a/test/spec/libraries/cmp/cmpClient_spec.js b/test/spec/libraries/cmp/cmpClient_spec.js new file mode 100644 index 00000000000..adbbbf5cb1d --- /dev/null +++ b/test/spec/libraries/cmp/cmpClient_spec.js @@ -0,0 +1,296 @@ +import {cmpClient, MODE_CALLBACK, MODE_RETURN} from '../../../../libraries/cmp/cmpClient.js'; + +describe('cmpClient', () => { + function mockWindow(props = {}) { + let listeners = []; + const win = { + addEventListener: sinon.stub().callsFake((evt, listener) => { + evt === 'message' && listeners.push(listener) + }), + removeEventListener: sinon.stub().callsFake((evt, listener) => { + evt === 'message' && (listeners = listeners.filter((l) => l !== listener)); + }), + postMessage: sinon.stub().callsFake((msg) => { + listeners.forEach(ln => ln({data: msg})) + }), + ...props, + }; + win.top = win.parent?.top || win; + return win; + } + + it('should return undefined when there is no CMP', () => { + expect(cmpClient({apiName: 'missing'}, mockWindow())).to.not.exist; + }); + + it('should return undefined when parent is inaccessible', () => { + const win = mockWindow(); + win.top = mockWindow(); + expect(cmpClient({apiName: 'missing'}, win)).to.not.exist; + }) + + describe('direct access', () => { + let mockApiFn; + beforeEach(() => { + mockApiFn = sinon.stub(); + }) + Object.entries({ + 'on same frame': () => mockWindow({mockApiFn}), + 'on parent frame': () => mockWindow({parent: mockWindow({parent: mockWindow({parent: mockWindow(), mockApiFn})})}), + }).forEach(([t, mkWindow]) => { + describe(t, () => { + let win, mkClient; + beforeEach(() => { + win = mkWindow(); + mkClient = (opts) => cmpClient(Object.assign({apiName: 'mockApiFn'}, opts), win) + }); + + it('should mark client function as direct', () => { + expect(mkClient().isDirect).to.equal(true); + }); + + it('should find and call the CMP api function', () => { + mkClient()({command: 'mockCmd'}); + sinon.assert.calledWith(mockApiFn, 'mockCmd'); + }); + + describe('should return a promise that', () => { + let cbResult; + beforeEach(() => { + cbResult = []; + mockApiFn.callsFake((cmd, callback) => { + if (typeof callback === 'function') { + callback.apply(this, cbResult); + } + return 'val' + }) + }) + + Object.entries({ + callback: [sinon.stub(), 'undefined', undefined], + 'callback, mode = MODE_CALLBACK': [sinon.stub(), 'undefined', undefined, MODE_CALLBACK], + 'callback, mode = MODE_RETURN': [sinon.stub(), 'api return value', 'val', MODE_RETURN], + 'no callback': [undefined, 'api return value', 'val'], + 'no callback, mode = MODE_CALLBACK': [undefined, 'callback arg', 'cbVal', MODE_CALLBACK], + 'no callback, mode = MODE_RETURN': [undefined, 'api return value', 'val', MODE_RETURN], + }).forEach(([t, [callback, tResult, expectedResult, mode]]) => { + describe(`when ${t} is provided`, () => { + Object.entries({ + 'no success flag': undefined, + 'success is set': true + }).forEach(([t, success]) => { + it(`resolves to ${tResult} (${t})`, (done) => { + cbResult = ['cbVal', success]; + mkClient({mode})({callback}).then((val) => { + expect(val).to.equal(expectedResult); + done(); + }) + }); + + it('should pass either a function or undefined as callback', () => { + mkClient({mode})({callback}); + sinon.assert.calledWith(mockApiFn, sinon.match.any, sinon.match(arg => typeof arg === 'undefined' || typeof arg === 'function')) + }) + }); + }) + }); + + it('rejects to undefined when callback is provided and success = false', (done) => { + cbResult = ['cbVal', false]; + mkClient()({callback: sinon.stub()}).catch(val => { + expect(val).to.not.exist; + done(); + }) + }); + + it('rejects to callback arg when callback is NOT provided, success = false, mode = MODE_CALLBACK', (done) => { + cbResult = ['cbVal', false]; + mkClient({mode: MODE_CALLBACK})().catch(val => { + expect(val).to.eql('cbVal'); + done(); + }) + }) + + it('rejects when CMP api throws', (done) => { + mockApiFn.reset(); + const e = new Error(); + mockApiFn.throws(e); + mkClient()({}).catch(val => { + expect(val).to.equal(e); + done(); + }); + }); + }) + + it('should use apiArgs to choose and order the arguments to pass to the API fn', () => { + mkClient({apiArgs: ['parameter', 'command']})({ + command: 'mockCmd', + parameter: 'mockParam', + callback() {} + }); + sinon.assert.calledWith(mockApiFn, 'mockParam', 'mockCmd'); + }); + + it('should not choke on .close()', () => { + mkClient({}).close(); + }) + }) + }) + }) + + describe('postMessage access', () => { + let messenger, win, response; + beforeEach(() => { + response = {}; + messenger = sinon.stub().callsFake((msg) => { + if (msg.mockApiCall) { + win.postMessage({mockApiReturn: {callId: msg.mockApiCall.callId, ...response}}); + } + }); + }); + + function mkClient(options) { + return cmpClient(Object.assign({apiName: 'mockApi'}, options), win); + } + + Object.entries({ + 'on same frame': () => { + win = mockWindow({frames: {mockApiLocator: true}}); + win.addEventListener('message', (evt) => messenger(evt.data)); + }, + 'on parent frame': () => { + win = mockWindow({parent: mockWindow({frames: {mockApiLocator: true}})}) + win.parent.addEventListener('message', evt => messenger(evt.data)) + } + }).forEach(([t, setup]) => { + describe(t, () => { + beforeEach(setup); + + it('should mark client as not direct', () => { + expect(mkClient().isDirect).to.equal(false); + }); + + it('should find and message the CMP frame', () => { + mkClient()({command: 'mockCmd', parameter: 'param'}); + sinon.assert.calledWithMatch(messenger, { + mockApiCall: { + command: 'mockCmd', + parameter: 'param' + } + }) + }); + + it('should use apiArgs to choose what to include in the message payload', () => { + mkClient({apiArgs: ['command']})({ + command: 'cmd', + parameter: 'param' + }); + sinon.assert.calledWithMatch(messenger, sinon.match((arg) => { + return arg.mockApiCall.command === 'cmd' && + !arg.mockApiCall.hasOwnProperty('parameter'); + })) + }); + + it('should not include callback in the payload, but still run it on response', () => { + const cb = sinon.stub(); + mkClient({apiArgs: ['command', 'callback']})({ + command: 'cmd', + callback: cb + }); + sinon.assert.calledWithMatch(messenger, sinon.match(arg => !arg.mockApiCall.hasOwnProperty('callback'))); + sinon.assert.called(cb); + }); + + it('should use callbackArgs to decide what to pass to callback', () => { + const cb = sinon.stub(); + response = {a: 'one', b: 'two'}; + mkClient({callbackArgs: ['a', 'b']})({callback: cb}); + sinon.assert.calledWith(cb, 'one', 'two'); + }) + + describe('should return a promise that', () => { + beforeEach(() => { + response = {returnValue: 'val'} + }) + Object.entries({ + 'callback': [sinon.stub(), 'undefined', undefined], + 'callback, mode = MODE_RETURN': [sinon.stub(), 'undefined', undefined, MODE_RETURN], + 'callback, mode = MODE_CALLBACK': [sinon.stub(), 'undefined', undefined, MODE_CALLBACK], + 'no callback': [undefined, 'response returnValue', 'val'], + 'no callback, mode = MODE_RETURN': [undefined, 'undefined', undefined, MODE_RETURN], + 'no callback, mode = MODE_CALLBACK': [undefined, 'response returnValue', 'val', MODE_CALLBACK], + }).forEach(([t, [callback, tResult, expectedResult, mode]]) => { + describe(`when ${t} is provided`, () => { + Object.entries({ + 'no success flag': {}, + 'with success flag': {success: true} + }).forEach(([t, resp]) => { + it(`resolves to ${tResult} (${t})`, () => { + Object.assign(response, resp); + mkClient({mode})({callback}).then((val) => { + expect(val).to.equal(expectedResult); + }) + }) + }); + + if (mode !== MODE_RETURN) { // in return mode, the promise never rejects + it(`rejects to ${tResult} when success = false`, (done) => { + response.success = false; + mkClient()({mode, callback}).catch((err) => { + expect(err).to.equal(expectedResult); + done(); + }); + }); + } + }) + }); + }); + + describe('messages with same callID', () => { + let callback, callId; + + function runCallback(returnValue) { + win.postMessage({mockApiReturn: {callId, returnValue}}); + } + + beforeEach(() => { + callId = null; + messenger.reset(); + messenger.callsFake((msg) => { + if (msg.mockApiCall) callId = msg.mockApiCall.callId; + }); + callback = sinon.stub(); + }); + + it('should re-use callback for messages with same callId', () => { + mkClient()({callback}); + expect(callId).to.exist; + runCallback('a'); + runCallback('b'); + sinon.assert.calledWith(callback, 'a'); + sinon.assert.calledWith(callback, 'b'); + }); + + it('should NOT re-use callback if once = true', () => { + mkClient()({callback}, true); + expect(callId).to.exist; + runCallback('a'); + runCallback('b'); + sinon.assert.calledWith(callback, 'a'); + sinon.assert.calledOnce(callback); + }); + + it('should NOT fire again after .close()', () => { + const client = mkClient(); + client({callback}); + runCallback('a'); + client.close(); + runCallback('b'); + sinon.assert.calledWith(callback, 'a'); + sinon.assert.calledOnce(callback); + }) + }); + }); + }); + }); +}); diff --git a/test/spec/libraries/currencyUtils_spec.js b/test/spec/libraries/currencyUtils_spec.js new file mode 100644 index 00000000000..9d3d73e6a5f --- /dev/null +++ b/test/spec/libraries/currencyUtils_spec.js @@ -0,0 +1,113 @@ +import {getGlobal} from 'src/prebidGlobal.js'; +import {convertCurrency, currencyCompare, currencyNormalizer} from 'libraries/currencyUtils/currency.js'; + +describe('currency utils', () => { + let sandbox; + before(() => { + if (!getGlobal().convertCurrency) { + getGlobal().convertCurrency = () => null; + getGlobal().convertCurrency.mock = true; + } + }); + + after(() => { + if (getGlobal().convertCurrency.mock) { + delete getGlobal().convertCurrency; + } + }) + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('convertCurrency', () => { + Object.entries({ + 'not available': () => sandbox.stub(getGlobal(), 'convertCurrency').value(undefined), + 'throwing errors': () => sandbox.stub(getGlobal(), 'convertCurrency').callsFake(() => { throw new Error(); }), + }).forEach(([t, setup]) => { + describe(`when currency module is ${t}`, () => { + beforeEach(setup); + + it('should "convert" to the same currency', () => { + expect(convertCurrency(123, 'mock', 'mock', false)).to.eql(123); + }); + + it('should throw when suppressErrors = false', () => { + expect(() => convertCurrency(123, 'c1', 'c2', false)).to.throw(); + }); + + it('should return input value when suppressErrors = true', () => { + expect(convertCurrency(123, 'c1', 'c2', true)).to.eql(123); + }) + }) + }); + + describe('when currency module is working', () => { + beforeEach(() => { + sandbox.stub(getGlobal(), 'convertCurrency').callsFake((amt) => amt * 10) + }); + + it('should be used for actual conversions', () => { + expect(convertCurrency(123, 'c1', 'c2')).to.eql(1230); + sinon.assert.calledWith(getGlobal().convertCurrency, 123, 'c1', 'c2'); + }); + + it('should NOT be used when no conversion is necessary', () => { + expect(convertCurrency(123, 'cur', 'cur')).to.eql(123); + sinon.assert.notCalled(getGlobal().convertCurrency); + }) + }) + }); + + describe('Currency normalization', () => { + let mockConvert; + beforeEach(() => { + mockConvert = sinon.stub().callsFake((amt, from, to) => { + if (from === to) return amt; + return amt / from * to + }) + }); + + describe('currencyNormalizer', () => { + it('converts to toCurrency if set', () => { + const normalize = currencyNormalizer(10, true, mockConvert); + expect(normalize(1, 1)).to.eql(10); + expect(normalize(10, 100)).to.eql(1); + }); + + it('converts to first currency if toCurrency is not set', () => { + const normalize = currencyNormalizer(null, true, mockConvert); + expect(normalize(1, 1)).to.eql(1); + expect(normalize(1, 10)).to.eql(0.1); + }); + + [true, false].forEach(bestEffort => { + it(`passes bestEffort = ${bestEffort} to convert`, () => { + currencyNormalizer(null, bestEffort, mockConvert)(1, 1); + sinon.assert.calledWith(mockConvert, 1, 1, 1, bestEffort); + }) + }) + }); + + describe('currencyCompare', () => { + let compare + beforeEach(() => { + compare = currencyCompare((val) => [val.amount, val.cur], currencyNormalizer(null, false, mockConvert)) + }); + [ + [{amount: 1, cur: 1}, {amount: 1, cur: 10}, 1], + [{amount: 10, cur: 1}, {amount: 0.1, cur: 100}, 1], + [{amount: 1, cur: 1}, {amount: 10, cur: 10}, 0], + ].forEach(([a, b, expected]) => { + it(`should compare ${a.amount}/${a.cur} and ${b.amount}/${b.cur}`, () => { + expect(compare(a, b)).to.equal(expected); + expect(compare(b, a)).to.equal(-expected); + }); + }); + }) + }) +}) diff --git a/test/spec/libraries/domainOverrideToRootDomain/index_spec.js b/test/spec/libraries/domainOverrideToRootDomain/index_spec.js new file mode 100644 index 00000000000..b490d80fd40 --- /dev/null +++ b/test/spec/libraries/domainOverrideToRootDomain/index_spec.js @@ -0,0 +1,77 @@ +import {domainOverrideToRootDomain} from 'libraries/domainOverrideToRootDomain/index.js'; +import {getStorageManager} from 'src/storageManager.js'; +import {MODULE_TYPE_UID} from '../../../../src/activities/modules'; + +const storage = getStorageManager({ moduleName: 'test', moduleType: MODULE_TYPE_UID }); +const domainOverride = domainOverrideToRootDomain(storage, 'test'); + +describe('domainOverride', () => { + let sandbox, domain, cookies, rejectCookiesFor; + let setCookieStub; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + sandbox.stub(document, 'domain').get(() => domain); + cookies = {}; + sandbox.stub(storage, 'getCookie').callsFake((key) => cookies[key]); + rejectCookiesFor = null; + setCookieStub = sandbox.stub(storage, 'setCookie').callsFake((key, value, expires, sameSite, domain) => { + if (domain !== rejectCookiesFor) { + if (expires != null) { + expires = new Date(expires); + } + if (expires == null || expires > Date.now()) { + cookies[key] = value; + } else { + delete cookies[key]; + } + } + }); + }); + + afterEach(() => sandbox.restore()) + + it('test cookies include the module name', () => { + domain = 'greatpublisher.com' + rejectCookiesFor = 'greatpublisher.com' + + // stub Date.now() to return a constant value + sandbox.stub(Date, 'now').returns(1234567890) + + const randomName = `adapterV${(Math.random() * 1e8).toString(16)}` + const localDomainOverride = domainOverrideToRootDomain(storage, randomName) + + const time = Date.now(); + localDomainOverride(); + + sandbox.assert.callCount(setCookieStub, 2) + sandbox.assert.calledWith(setCookieStub, `_gd${time}_${randomName}`, '1', undefined, undefined, 'greatpublisher.com') + }); + + it('will return the root domain when given a subdomain', () => { + const test_domains = [ + 'deeply.nested.subdomain.for.greatpublisher.com', + 'greatpublisher.com', + 'subdomain.greatpublisher.com', + 'a-subdomain.greatpublisher.com', + ]; + + test_domains.forEach((testDomain) => { + domain = testDomain + rejectCookiesFor = 'com' + expect(domainOverride()).to.equal('greatpublisher.com'); + }); + }); + + it(`If we can't set cookies on the root domain, we'll return the subdomain`, () => { + domain = 'subdomain.greatpublisher.com' + rejectCookiesFor = 'greatpublisher.com' + expect(domainOverride()).to.equal('subdomain.greatpublisher.com'); + }); + + it('Will return undefined if we can\'t set cookies on the root domain or the subdomain', () => { + domain = 'subdomain.greatpublisher.com' + rejectCookiesFor = 'subdomain.greatpublisher.com' + expect(domainOverride()).to.equal(undefined); + }); +}); diff --git a/test/spec/libraries/mspa/activityControls_spec.js b/test/spec/libraries/mspa/activityControls_spec.js new file mode 100644 index 00000000000..f232dc2563f --- /dev/null +++ b/test/spec/libraries/mspa/activityControls_spec.js @@ -0,0 +1,256 @@ +import {mspaRule, setupRules, isTransmitUfpdConsentDenied, isTransmitGeoConsentDenied, isBasicConsentDenied, sensitiveNoticeIs, isConsentDenied} from '../../../../libraries/mspa/activityControls.js'; +import {ruleRegistry} from '../../../../src/activities/rules.js'; + +describe('Consent interpretation', () => { + function mkConsent(flags) { + return Object.assign({ + // not covered, opt in to targeted, sale, and share, all notices given, opt into precise geo + Gpc: 0, + KnownChildSensitiveDataConsents: [0, 0], + MspaCoveredTransaction: 2, + MspaOptOutOptionMode: 0, + MspaServiceProviderMode: 0, + PersonalDataConsents: 0, + SaleOptOut: 2, + SaleOptOutNotice: 1, + SensitiveDataLimitUseNotice: 1, + SensitiveDataProcessing: [0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0], + SensitiveDataProcessingOptOutNotice: 1, + SharingNotice: 1, + SharingOptOut: 2, + SharingOptOutNotice: 1, + TargetedAdvertisingOptOut: 2, + TargetedAdvertisingOptOutNotice: 1, + Version: 1 + }, flags) + } + describe('isBasicConsentDenied', () => { + it('should be false (basic consent conditions pass) with variety of notice and opt in', () => { + const result = isBasicConsentDenied(mkConsent()); + expect(result).to.equal(false); + }); + it('should be true (basic consent conditions do not pass) with personal data consent set to true (invalid state)', () => { + const result = isBasicConsentDenied(mkConsent({ + PersonalDataConsents: 2 + })); + expect(result).to.equal(true); + }); + it('should be true (basic consent conditions do not pass) with covered set to zero (invalid state)', () => { + const result = isBasicConsentDenied(mkConsent({ + MspaCoveredTransaction: 0 + })); + expect(result).to.equal(true); + }); + it('should not deny when consent for under-13 is null', () => { + expect(isBasicConsentDenied(mkConsent({ + KnownChildSensitiveDataConsents: [0, null] + }))).to.be.false; + }) + }); + + describe('isConsentDenied', () => { + it('should be false (consent given personalized ads / sale / share) with variety of notice and opt in', () => { + const result = isConsentDenied(mkConsent()); + expect(result).to.equal(false); + }); + it('should be true (no consent) on opt out of targeted ads via TargetedAdvertisingOptOut', () => { + const result = isConsentDenied(mkConsent({ + TargetedAdvertisingOptOut: 1 + })); + expect(result).to.equal(true); + }); + it('should be true (no consent) on opt out of targeted ads via no TargetedAdvertisingOptOutNotice', () => { + const result = isConsentDenied(mkConsent({ + TargetedAdvertisingOptOutNotice: 2 + })); + expect(result).to.equal(true); + }); + it('should be true (no consent) if TargetedAdvertisingOptOutNotice is 0 and TargetedAdvertisingOptOut is 2', () => { + const result = isConsentDenied(mkConsent({ + TargetedAdvertisingOptOutNotice: 0 + })); + expect(result).to.equal(true); + }); + it('requires also SharingNotice to accept opt-in for Sharing', () => { + expect(isConsentDenied(mkConsent({ + SharingNotice: 0 + }))).to.be.true; + }) + }); + + describe('isTransmitUfpdConsentDenied', () => { + it('should be false (consent given to add ufpd) with variety of notice and opt in', () => { + const result = isTransmitUfpdConsentDenied(mkConsent()); + expect(result).to.equal(false); + }); + Object.entries({ + 'health information': 2, + 'biometric data': 6, + }).forEach(([t, flagNo]) => { + it(`'should be true (consent denied to add ufpd) if no consent to process ${t}'`, () => { + const consent = mkConsent(); + consent.SensitiveDataProcessing[flagNo] = 1; + expect(isTransmitUfpdConsentDenied(consent)).to.be.true; + }) + }); + + ['SharingNotice', 'SensitiveDataLimitUseNotice'].forEach(flag => { + it(`should be true (consent denied to add ufpd) without ${flag}`, () => { + expect(isTransmitUfpdConsentDenied(mkConsent({ + [flag]: 2 + }))).to.be.true; + }) + }); + + ['SaleOptOut', 'TargetedAdvertisingOptOut'].forEach(flag => { + it(`should be true (consent denied to add ufpd) with ${flag}`, () => { + expect(isTransmitUfpdConsentDenied(mkConsent({ + [flag]: 1 + }))).to.be.true; + }) + }); + + it('should be true (basic consent conditions do not pass) with sensitive opt in but no notice', () => { + const cd = mkConsent({ + SensitiveDataLimitUseNotice: 0 + }); + cd.SensitiveDataProcessing[0] = 2; + expect(isTransmitUfpdConsentDenied(cd)).to.be.true; + }); + + it('should deny when sensitive notice is missing', () => { + const result = isTransmitUfpdConsentDenied(mkConsent({ + SensitiveDataLimitUseNotice: 2 + })); + expect(result).to.equal(true); + }); + + it('should not deny when biometric data opt-out is null', () => { + const cd = mkConsent(); + cd.SensitiveDataProcessing[6] = null; + expect(isTransmitUfpdConsentDenied(cd)).to.be.false; + }) + }); + + describe('isTransmitGeoConsentDenied', () => { + function geoConsent(geoOptOut, flags) { + const consent = mkConsent(flags); + consent.SensitiveDataProcessing[7] = geoOptOut; + return consent; + } + it('should be true (consent denied to add precise geo) -- sensitive flag denied', () => { + const result = isTransmitGeoConsentDenied(geoConsent(1)); + expect(result).to.equal(true); + }); + it('should be true (consent denied to add precise geo) -- sensitive data limit usage not given', () => { + const result = isTransmitGeoConsentDenied(geoConsent(1, { + SensitiveDataLimitUseNotice: 0 + })); + expect(result).to.equal(true); + }); + it('should be false (consent given to add precise geo) -- sensitive position 8 (index 7) is true', () => { + const result = isTransmitGeoConsentDenied(geoConsent(2)); + expect(result).to.equal(false); + }); + }) +}); + +describe('mspaRule', () => { + it('does not apply if SID is not applicable', () => { + const rule = mspaRule([1, 2], () => null, () => true, () => [3, 4]); + expect(rule()).to.not.exist; + }); + + it('does not apply when no SID is applicable', () => { + const rule = mspaRule([1], () => null, () => true, () => []); + expect(rule()).to.not.exist; + }); + + describe('when SID is applicable', () => { + let consent, denies; + function mkRule() { + return mspaRule([1, 2], () => consent, denies, () => [2]) + } + + beforeEach(() => { + consent = null; + denies = sinon.stub(); + }); + + it('should deny when no consent is available', () => { + expect(mkRule()().allow).to.equal(false); + }); + + Object.entries({ + 'denies': true, + 'allows': false + }).forEach(([t, denied]) => { + it(`should check if deny fn ${t}`, () => { + denies.returns(denied); + consent = {mock: 'value'}; + const result = mkRule()(); + sinon.assert.calledWith(denies, consent); + if (denied) { + expect(result.allow).to.equal(false); + } else { + expect(result).to.not.exist; + } + }) + }) + }) +}); + +describe('setupRules', () => { + let rules, registerRule, isAllowed, consent; + beforeEach(() => { + rules = { + mockActivity: sinon.stub().returns(true) + }; + ([registerRule, isAllowed] = ruleRegistry()); + consent = { + applicableSections: [1], + parsedSections: { + mockApi: [ + { + mock: 'consent' + } + ] + } + }; + }); + + function runSetup(api, sids, normalize) { + return setupRules(api, sids, normalize, rules, registerRule, () => consent) + } + + it('should use flatten section data for the given api', () => { + runSetup('mockApi', [1]); + expect(isAllowed('mockActivity', {})).to.equal(false); + sinon.assert.calledWith(rules.mockActivity, {mock: 'consent'}) + }); + + it('should not choke when no consent data is available', () => { + consent = null; + runSetup('mockApi', [1]); + expect(isAllowed('mockActivity', {})).to.equal(true); + }); + + it('should check applicableSections against given SIDs', () => { + runSetup('mockApi', [2]); + expect(isAllowed('mockActivity', {})).to.equal(true); + }); + + it('should pass flattened consent through normalizeConsent', () => { + const normalize = sinon.stub().returns({normalized: 'consent'}) + runSetup('mockApi', [1], normalize); + expect(isAllowed('mockActivity', {})).to.equal(false); + sinon.assert.calledWith(normalize, {mock: 'consent'}); + sinon.assert.calledWith(rules.mockActivity, {normalized: 'consent'}); + }); + + it('should return a function that unregisters activity controls', () => { + const dereg = runSetup('mockApi', [1]); + dereg(); + expect(isAllowed('mockActivity', {})).to.equal(true); + }); +}) diff --git a/test/spec/libraries/sizeUtils_spec.js b/test/spec/libraries/sizeUtils_spec.js new file mode 100644 index 00000000000..1c954c6accf --- /dev/null +++ b/test/spec/libraries/sizeUtils_spec.js @@ -0,0 +1,30 @@ +import {getAdUnitSizes} from '../../../libraries/sizeUtils/sizeUtils.js'; +import {expect} from 'chai/index.js'; + +describe('getAdUnitSizes', function () { + it('returns an empty response when adUnits is undefined', function () { + let sizes = getAdUnitSizes(); + expect(sizes).to.be.undefined; + }); + + it('returns an empty array when invalid data is present in adUnit object', function () { + let sizes = getAdUnitSizes({sizes: 300}); + expect(sizes).to.deep.equal([]); + }); + + it('retuns an array of arrays when reading from adUnit.sizes', function () { + let sizes = getAdUnitSizes({sizes: [300, 250]}); + expect(sizes).to.deep.equal([[300, 250]]); + + sizes = getAdUnitSizes({sizes: [[300, 250], [300, 600]]}); + expect(sizes).to.deep.equal([[300, 250], [300, 600]]); + }); + + it('returns an array of arrays when reading from adUnit.mediaTypes.banner.sizes', function () { + let sizes = getAdUnitSizes({mediaTypes: {banner: {sizes: [300, 250]}}}); + expect(sizes).to.deep.equal([[300, 250]]); + + sizes = getAdUnitSizes({mediaTypes: {banner: {sizes: [[300, 250], [300, 600]]}}}); + expect(sizes).to.deep.equal([[300, 250], [300, 600]]); + }); +}); diff --git a/test/spec/libraries/urlUtils_spec.js b/test/spec/libraries/urlUtils_spec.js new file mode 100644 index 00000000000..9dd66b05407 --- /dev/null +++ b/test/spec/libraries/urlUtils_spec.js @@ -0,0 +1,24 @@ +import {tryAppendQueryString} from '../../../libraries/urlUtils/urlUtils.js'; +import assert from 'assert'; + +describe('tryAppendQueryString', function () { + it('should append query string to existing url', function () { + var url = 'www.a.com?'; + var key = 'b'; + var value = 'c'; + + var output = tryAppendQueryString(url, key, value); + + var expectedResult = url + key + '=' + encodeURIComponent(value) + '&'; + assert.equal(output, expectedResult); + }); + + it('should return existing url, if the value is empty', function () { + var url = 'www.a.com?'; + var key = 'b'; + var value = ''; + + var output = tryAppendQueryString(url, key, value); + assert.equal(output, url); + }); +}); diff --git a/test/spec/modules/1plusXRtdProvider_spec.js b/test/spec/modules/1plusXRtdProvider_spec.js new file mode 100644 index 00000000000..4e4092ea26e --- /dev/null +++ b/test/spec/modules/1plusXRtdProvider_spec.js @@ -0,0 +1,471 @@ +import assert from 'assert'; +import {config} from 'src/config'; +import { + buildOrtb2Updates, + extractConfig, + extractConsent, + extractFpid, + getPapiUrl, + onePlusXSubmodule, + segtaxes, + setTargetingDataToConfig, + updateBidderConfig, +} from 'modules/1plusXRtdProvider'; +import {deepClone} from '../../../src/utils.js'; + +describe('1plusXRtdProvider', () => { + // Fake server config + let fakeServer; + const fakeResponseHeaders = { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + }; + const fakeResponse = { + s: ['segment1', 'segment2', 'segment3'], + t: ['targeting1', 'targeting2', 'targeting3'] + }; + + // Bid request config + const reqBidsConfigObj = { + adUnits: [{ + bids: [ + { bidder: 'appnexus' } + ] + }] + }; + + // Bidder configs + const bidderConfigInitial = { + user: { keywords: '' }, + site: { ext: {} } + } + const bidderConfigInitialWith1plusXUserData = { + user: { + data: [{ name: '1plusX.com', segment: [{ id: 'initial' }] }] + }, + site: { content: { data: [] } } + } + const bidderConfigInitialWithUserData = { + user: { + data: [{ name: 'hello.world', segment: [{ id: 'initial' }] }] + }, + site: { content: { data: [] } } + } + const bidderConfigInitialWith1plusXSiteContent = { + user: { data: [] }, + site: { + content: { + data: [{ + name: '1plusX.com', segment: [{ id: 'initial' }], ext: { segtax: 525 } + }] + } + } + } + const bidderConfigInitialWithSiteContent = { + user: { data: [] }, + site: { + content: { + data: [{ name: 'hello.world', segment: [{ id: 'initial' }] }] + } + } + } + // Util functions + const randomBidder = (len = 5) => Math.random().toString(36).replace(/[^a-z]+/g, '').substring(0, len); + + before(() => { + config.resetConfig(); + }) + + after(() => { }) + + beforeEach(() => { + fakeServer = sinon.createFakeServer(); + fakeServer.respondWith('GET', '*', [200, fakeResponseHeaders, JSON.stringify(fakeResponse)]); + fakeServer.respondImmediately = true; + fakeServer.autoRespond = true; + }) + + describe('onePlusXSubmodule', () => { + it('init is successfull', () => { + const initResult = onePlusXSubmodule.init(); + expect(initResult).to.be.true; + }) + + it('callback is called after getBidRequestData', () => { + // Nice case; everything runs as expected + { + const callbackSpy = sinon.spy(); + const config = { params: { customerId: 'test', bidders: ['appnexus'] } }; + onePlusXSubmodule.getBidRequestData(reqBidsConfigObj, callbackSpy, config); + setTimeout(() => { + expect(callbackSpy.calledOnce).to.be.true + }, 100) + } + // No customer id in config => error but still callback called + { + const callbackSpy = sinon.spy(); + const config = {} + onePlusXSubmodule.getBidRequestData(reqBidsConfigObj, callbackSpy, config); + setTimeout(() => { + expect(callbackSpy.calledOnce).to.be.true + }, 100); + } + // No bidders in config => error but still callback called + { + const callbackSpy = sinon.spy(); + const config = { customerId: 'test' } + onePlusXSubmodule.getBidRequestData(reqBidsConfigObj, callbackSpy, config); + setTimeout(() => { + expect(callbackSpy.calledOnce).to.be.true + }, 100); + } + }) + }) + + describe('extractConfig', () => { + const customerId = 'test'; + const timeout = 1000; + const bidders = ['appnexus']; + + it('Throws an error if no customerId is specified', () => { + const moduleConfig = { params: { timeout, bidders } }; + expect(() => extractConfig(moduleConfig, reqBidsConfigObj)).to.throw(); + }) + it('Throws an error if no bidder is specified', () => { + const moduleConfig = { params: { customerId, timeout } }; + expect(() => extractConfig(moduleConfig, reqBidsConfigObj)).to.throw(); + }) + it("Throws an error if there's no bidder in reqBidsConfigObj", () => { + const moduleConfig = { params: { customerId, timeout, bidders } }; + const reqBidsConfigEmpty = { adUnits: [{ bids: [] }] }; + expect(() => extractConfig(moduleConfig, reqBidsConfigEmpty)).to.throw(); + }) + it('Returns an object containing the parameters specified', () => { + const moduleConfig = { params: { customerId, timeout, bidders } }; + const expectedKeys = ['customerId', 'timeout', 'bidders'] + const extractedConfig = extractConfig(moduleConfig, reqBidsConfigObj); + expect(extractedConfig).to.be.an('object').and.to.have.all.keys(expectedKeys); + expect(extractedConfig.customerId).to.equal(customerId); + expect(extractedConfig.timeout).to.equal(timeout); + expect(extractedConfig.bidders).to.deep.equal(bidders); + }) + /* 1plusX RTD module may only use bidders that are both specified in : + - the bid request configuration + - AND in the 1plusX RTD module configuration + Below 2 tests are enforcing those rules + */ + it('Returns the intersection of bidders found in bid request config & module config', () => { + const bidders = ['appnexus', 'rubicon']; + const moduleConfig = { params: { customerId, timeout, bidders } }; + const { bidders: extractedBidders } = extractConfig(moduleConfig, reqBidsConfigObj); + expect(extractedBidders).to.be.an('array').and.to.have.length(1); 7 + expect(extractedBidders[0]).to.equal('appnexus'); + }) + it('Throws an error if no bidder can be used by the module', () => { + const bidders = ['rubicon']; + const moduleConfig = { params: { customerId, timeout, bidders } }; + expect(() => extractConfig(moduleConfig, reqBidsConfigObj)).to.throw(); + }) + }) + + describe('buildOrtb2Updates', () => { + it('fills site.content.data & user.data in the ortb2 config', () => { + const rtdData = { segments: fakeResponse.s, topics: fakeResponse.t }; + const ortb2Updates = buildOrtb2Updates(rtdData, randomBidder()); + + const expectedOutput = { + siteContentData: { + name: '1plusX.com', + segment: rtdData.topics.map((topicId) => ({ id: topicId })), + ext: { segtax: segtaxes.CONTENT } + }, + userData: { + name: '1plusX.com', + segment: rtdData.segments.map((segmentId) => ({ id: segmentId })), + ext: { segtax: segtaxes.AUDIENCE } + } + } + expect([ortb2Updates]).to.deep.include.members([expectedOutput]); + }); + + it('defaults to empty array if no segment is given', () => { + const rtdData = { topics: fakeResponse.t }; + const ortb2Updates = buildOrtb2Updates(rtdData, randomBidder()); + + const expectedOutput = { + siteContentData: { + name: '1plusX.com', + segment: rtdData.topics.map((topicId) => ({ id: topicId })), + ext: { segtax: segtaxes.CONTENT } + }, + userData: { + name: '1plusX.com', + segment: [], + ext: { segtax: segtaxes.AUDIENCE } + } + } + expect(ortb2Updates).to.deep.include(expectedOutput); + }) + + it('defaults to empty array if no topic is given', () => { + const rtdData = { segments: fakeResponse.s }; + const ortb2Updates = buildOrtb2Updates(rtdData, randomBidder()); + + const expectedOutput = { + siteContentData: { + name: '1plusX.com', + segment: [], + ext: { segtax: segtaxes.CONTENT } + }, + userData: { + name: '1plusX.com', + segment: rtdData.segments.map((segmentId) => ({ id: segmentId })), + ext: { segtax: segtaxes.AUDIENCE } + }, + } + expect(ortb2Updates, `${JSON.stringify(ortb2Updates, null, 2)}`).to.deep.include(expectedOutput); + }) + }) + + describe('extractConsent', () => { + it('extracts consent strings correctly if given', () => { + const consent = { + gdpr: { + gdprApplies: 1, + consentString: 'myConsent' + } + } + const output = extractConsent(consent) + const expectedOutput = { + gdpr_applies: 1, + consent_string: 'myConsent' + } + expect(expectedOutput).to.deep.include(output) + expect(output).to.deep.include(expectedOutput) + }) + + it('extracts null if consent object is empty', () => { + const consent1 = {} + expect(extractConsent(consent1)).to.equal(null) + }) + + it('throws an error if the consent is malformed', () => { + const consent1 = { + gdpr: { + consentString: 'myConsent' + } + } + const consent2 = { + gdpr: { + gdprApplies: 1, + consentString: 3 + } + } + const consent3 = { + gdpr: { + gdprApplies: 'yes', + consentString: 'myConsent' + } + } + const consent4 = { + gdpr: {} + } + + for (const consent of [consent1, consent2, consent3, consent4]) { + var failed = false; + try { + extractConsent(consent) + } catch (e) { + failed = true; + } finally { + assert(failed, 'Should be throwing an exception') + } + } + }) + }) + + describe('extractFpid', () => { + it('correctly extracts an ope fpid if present', () => { + window.localStorage.setItem('ope_fpid', 'oneplusx_test_key') + const id1 = extractFpid() + window.localStorage.removeItem('ope_fpid') + const id2 = extractFpid() + expect(id1).to.equal('oneplusx_test_key') + expect(id2).to.equal(null) + }) + }) + + describe('getPapiUrl', () => { + const customer = 'acme' + const consent = { + gdpr: { + gdprApplies: 1, + consentString: 'myConsent' + } + } + + it('correctly builds URLs if gdpr parameters are present', () => { + const url1 = getPapiUrl(customer); + const url2 = getPapiUrl(customer, extractConsent(consent)); + expect(['&consent_string=myConsent&gdpr_applies=1', '&gdpr_applies=1&consent_string=myConsent']).to.contain(url2.replace(url1, '')); + }) + + it('correctly builds URLs if fpid parameters are present', () => { + const url1 = getPapiUrl(customer); + const url2 = getPapiUrl(customer, {}, 'my_first_party_id'); + expect(url2.replace(url1, '')).to.equal('&fpid=my_first_party_id'); + }) + }) + + describe('updateBidderConfig', () => { + const ortb2Updates = { + siteContentData: { + name: '1plusX.com', + segment: fakeResponse.t.map((topicId) => ({ id: topicId })), + ext: { segtax: segtaxes.CONTENT } + }, + userData: { + name: '1plusX.com', + segment: fakeResponse.s.map((segmentId) => ({ id: segmentId })) + }, + } + + it('merges fetched data in bidderConfig for configured bidders', () => { + // Set initial config + const bidder = randomBidder(); + const ortb2Fragments = { [bidder]: deepClone(bidderConfigInitial) } + // Call submodule's setBidderConfig + updateBidderConfig(bidder, ortb2Updates, ortb2Fragments); + const newBidderConfig = ortb2Fragments[bidder]; + // Check that the targeting data has been set in the config + expect(newBidderConfig).not.to.be.null.and.not.to.be.undefined; + expect(newBidderConfig.user).not.to.be.null.and.not.to.be.undefined; + expect(newBidderConfig.site).not.to.be.null.and.not.to.be.undefined; + expect(newBidderConfig.user.data).to.deep.include(ortb2Updates.userData); + expect(newBidderConfig.site.content.data).to.deep.include(ortb2Updates.siteContentData); + // Check that existing config didn't get erased + expect(newBidderConfig.site).to.deep.include(bidderConfigInitial.site); + expect(newBidderConfig.user).to.deep.include(bidderConfigInitial.user); + }) + + it('overwrites an existing 1plus.com entry in ortb2.user.data', () => { + // Set initial config + const bidder = randomBidder(); + const ortb2Fragments = { [bidder]: { ...bidderConfigInitialWith1plusXUserData } } + // Save previous user.data entry + const previousUserData = bidderConfigInitialWith1plusXUserData.user.data[0]; + // Call submodule's setBidderConfig + updateBidderConfig(bidder, ortb2Updates, ortb2Fragments); + const newBidderConfig = ortb2Fragments[bidder]; + // Check that the targeting data has been set in the config + expect(newBidderConfig).not.to.be.null; + expect(newBidderConfig.site).not.to.be.null; + expect(newBidderConfig.user).not.to.be.null; + expect(newBidderConfig.user.data).to.deep.include(ortb2Updates.userData); + expect(newBidderConfig.user.data).not.to.include(previousUserData); + }) + it("doesn't overwrite entries in ortb2.user.data that aren't 1plusx.com", () => { + // Set initial config + const bidder = randomBidder(); + const ortb2Fragments = { [bidder]: { ...bidderConfigInitialWithUserData } } + // Save previous user.data entry + const previousUserData = bidderConfigInitialWithUserData.user.data[0]; + // Call submodule's setBidderConfig + updateBidderConfig(bidder, ortb2Updates, ortb2Fragments); + const newBidderConfig = ortb2Fragments[bidder]; + // Check that the targeting data has been set in the config + expect(newBidderConfig).not.to.be.null; + expect(newBidderConfig.site).not.to.be.null; + expect(newBidderConfig.user).not.to.be.null; + expect(newBidderConfig.user.data).to.deep.include(ortb2Updates.userData); + expect(newBidderConfig.user.data).to.deep.include(previousUserData); + }) + + it('overwrites an existing 1plus.com entry in ortb2.site.content.data', () => { + // Set initial config + const bidder = randomBidder(); + const ortb2Fragments = { [bidder]: { ...bidderConfigInitialWith1plusXSiteContent } } + // Save previous user.data entry + const previousSiteContent = bidderConfigInitialWith1plusXSiteContent.site.content.data[0]; + // Call submodule's setBidderConfig + updateBidderConfig(bidder, ortb2Updates, ortb2Fragments); + const newBidderConfig = ortb2Fragments[bidder]; + // Check that the targeting data has been set in the config + expect(newBidderConfig).not.to.be.null; + expect(newBidderConfig.site).not.to.be.null; + expect(newBidderConfig.user).not.to.be.null; + expect(newBidderConfig.site.content.data).to.deep.include(ortb2Updates.siteContentData); + expect(newBidderConfig.site.content.data).not.to.include(previousSiteContent); + }) + it("doesn't overwrite entries in ortb2.site.content.data that aren't 1plusx.com", () => { + // Set initial config + const bidder = randomBidder(); + const ortb2Fragments = { [bidder]: { ...bidderConfigInitialWithSiteContent } } + // Save previous user.data entry + const previousSiteContent = bidderConfigInitialWithSiteContent.site.content.data[0]; + // Call submodule's setBidderConfig + updateBidderConfig(bidder, ortb2Updates, ortb2Fragments); + const newBidderConfig = ortb2Fragments[bidder]; + // Check that the targeting data has been set in the config + expect(newBidderConfig).not.to.be.null; + expect(newBidderConfig.site).not.to.be.null; + expect(newBidderConfig.user).not.to.be.null; + expect(newBidderConfig.site.content.data).to.deep.include(ortb2Updates.siteContentData); + expect(newBidderConfig.site.content.data).to.deep.include(previousSiteContent); + }) + }) + + describe('setTargetingDataToConfig', () => { + const expectedSiteContentObj = { + data: [{ + name: '1plusX.com', + segment: fakeResponse.t.map((topicId) => ({ id: topicId })), + ext: { segtax: segtaxes.CONTENT } + }] + } + const expectedUserObj = { + data: [{ + name: '1plusX.com', + segment: fakeResponse.s.map((segmentId) => ({ id: segmentId })), + ext: { segtax: segtaxes.AUDIENCE } + }] + } + const expectedOrtb2 = { + appnexus: { + site: { content: expectedSiteContentObj }, + user: expectedUserObj + }, + rubicon: { + site: { content: expectedSiteContentObj }, + user: expectedUserObj + } + } + + it('sets the config for the selected bidders', () => { + const bidders = ['appnexus', 'rubicon']; + // setting initial config for those bidders + config.setBidderConfig({ + bidders, + config: bidderConfigInitial + }) + const biddersOrtb2 = config.getBidderConfig(); + // call setTargetingDataToConfig + setTargetingDataToConfig(fakeResponse, { bidders, biddersOrtb2 }); + + // Check that the targeting data has been set in both configs + for (const bidder of bidders) { + const newConfig = config.getBidderConfig()[bidder]; + // Check that we got what we expect + const expectedConfErr = (prop) => `New config for ${bidder} doesn't comply with expected at ${prop}`; + expect(newConfig.site, expectedConfErr('site')).to.deep.include(expectedOrtb2[bidder].site); + if (expectedOrtb2[bidder].user) { + expect(newConfig.user, expectedConfErr('user')).to.deep.include(expectedOrtb2[bidder].user); + } + // Check that existing config didn't get erased + const existingConfErr = (prop) => `Existing config for ${bidder} got unlawfully overwritten at ${prop}`; + expect(newConfig.site, existingConfErr('site')).to.deep.include(bidderConfigInitial.site); + expect(newConfig.user, existingConfErr('user')).to.deep.include(bidderConfigInitial.user); + } + }) + }) +}) diff --git a/test/spec/modules/33acrossBidAdapter_spec.js b/test/spec/modules/33acrossBidAdapter_spec.js index 141edc1e61c..9cc038428bc 100644 --- a/test/spec/modules/33acrossBidAdapter_spec.js +++ b/test/spec/modules/33acrossBidAdapter_spec.js @@ -30,6 +30,33 @@ describe('33acrossBidAdapter:', function () { site: { id: siteId }, + device: { + ext: { + ttx: { + w: 1024, + h: 728, + pxr: 2, + vp: { + w: 800, + h: 600 + }, + ah: 500, + mtp: 0 + } + }, + sua: { + browsers: [{ + brand: 'Google Chrome', + version: ['104', '0', '5112', '79'] + }], + platform: { + brand: 'macOS', + version: ['11', '6', '8'] + }, + model: '', + mobile: 0 + } + }, id: 'r1', regs: { ext: { @@ -117,7 +144,7 @@ describe('33acrossBidAdapter:', function () { this.withProduct = (prod = 'siab') => { ttxRequest.imp.forEach((imp) => { - Object.assign(imp, { + utils.mergeDeep(imp, { ext: { ttx: { prod @@ -129,6 +156,18 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withGpid = (gpid) => { + ttxRequest.imp.forEach((imp) => { + utils.mergeDeep(imp, { + ext: { + gpid + } + }); + }); + + return this; + }; + this.withGdprConsent = (consent, gdpr) => { Object.assign(ttxRequest, { user: { @@ -161,11 +200,40 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withCoppa = coppaValue => { + Object.assign(ttxRequest.regs, { + coppa: coppaValue + }); + + return this; + }; + + this.withGppConsent = (consentString, applicableSections) => { + Object.assign(ttxRequest, { + regs: { + gpp: consentString, + gpp_sid: applicableSections, + ext: Object.assign( + {}, + ttxRequest.regs.ext + ) + } + }); + + return this; + }; + this.withSite = site => { Object.assign(ttxRequest, { site }); return this; }; + this.withDevice = (device) => { + utils.mergeDeep(ttxRequest, { device }); + + return this; + }; + this.withPageUrl = pageUrl => { Object.assign(ttxRequest.site, { page: pageUrl @@ -174,6 +242,14 @@ describe('33acrossBidAdapter:', function () { return this; }; + this.withReferer = referer => { + Object.assign(ttxRequest.site, { + ref: referer + }); + + return this; + }; + this.withSchain = schain => { Object.assign(ttxRequest, { source: { @@ -272,7 +348,23 @@ describe('33acrossBidAdapter:', function () { adUnitCode: 'div-id', auctionId: 'r1', mediaTypes: {}, - transactionId: 't1' + transactionId: 't1', + ortb2: { + device: { + sua: { + browsers: [{ + brand: 'Google Chrome', + version: ['104', '0', '5112', '79'] + }], + platform: { + brand: 'macOS', + version: ['11', '6', '8'] + }, + model: '', + mobile: 0 + } + } + } } ]; @@ -289,6 +381,22 @@ describe('33acrossBidAdapter:', function () { auctionId: 'r1', mediaTypes: {}, transactionId: 't2', + ortb2: { + device: { + sua: { + browsers: [{ + brand: 'Google Chrome', + version: ['104', '0', '5112', '79'] + }], + platform: { + brand: 'macOS', + version: ['11', '6', '8'] + }, + model: '', + mobile: 0 + } + } + }, ...bidParams }); @@ -338,6 +446,8 @@ describe('33acrossBidAdapter:', function () { this.build = () => bidRequests; } + let bidderRequest; + beforeEach(function() { element = { x: 0, @@ -360,8 +470,21 @@ describe('33acrossBidAdapter:', function () { }; win = { parent: null, + devicePixelRatio: 2, + screen: { + width: 1024, + height: 728, + availHeight: 500 + }, + navigator: { + maxTouchPoints: 0 + }, document: { - visibilityState: 'visible' + visibilityState: 'visible', + documentElement: { + clientWidth: 800, + clientHeight: 600 + } }, innerWidth: 800, @@ -373,20 +496,58 @@ describe('33acrossBidAdapter:', function () { .withBanner() .build() ); - sandbox = sinon.sandbox.create(); sandbox.stub(Date, 'now').returns(1); sandbox.stub(document, 'getElementById').returns(element); sandbox.stub(utils, 'getWindowTop').returns(win); sandbox.stub(utils, 'getWindowSelf').returns(win); + bidderRequest = {bidderRequestId: 'r1'}; }); afterEach(function() { sandbox.restore(); }); - describe('isBidRequestValid:', function() { context('basic validation', function() { + it('returns true for valid bidder name values', function() { + const validBidderName = [ + '33across', + '33across_mgni' + ]; + + validBidderName.forEach((bidderName) => { + const bid = { + bidder: bidderName, + params: { + siteId: 'sample33xGUID123456789' + } + }; + + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + }); + + it('returns false for invalid bidder name values', function() { + const invalidBidderName = [ + undefined, + '33', + '33x', + 'thirtythree', + '' + ]; + + invalidBidderName.forEach((bidderName) => { + const bid = { + bidder: bidderName, + params: { + siteId: 'sample33xGUID123456789' + } + }; + + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + it('returns true for valid guid values', function() { // NOTE: We ignore whitespace at the start and end since // in our experience these are common typos @@ -634,7 +795,7 @@ describe('33acrossBidAdapter:', function () { Object.assign(element, { width: 600, height: 400 }); - const [ buildRequest ] = spec.buildRequests(bidRequests); + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(buildRequest, serverRequest); }); }); @@ -652,7 +813,7 @@ describe('33acrossBidAdapter:', function () { Object.assign(element, { x: -300, y: 0, width: 207, height: 320 }); - const [ buildRequest ] = spec.buildRequests(bidRequests); + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(buildRequest, serverRequest); }); }); @@ -670,7 +831,7 @@ describe('33acrossBidAdapter:', function () { Object.assign(element, { width: 800, height: 800 }); - const [ buildRequest ] = spec.buildRequests(bidRequests); + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(buildRequest, serverRequest); }); }); @@ -690,7 +851,7 @@ describe('33acrossBidAdapter:', function () { Object.assign(element, { width: 0, height: 0 }); bidRequests[0].mediaTypes.banner.sizes = [[800, 2400]]; - const [ buildRequest ] = spec.buildRequests(bidRequests); + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(buildRequest, serverRequest); }); }); @@ -713,7 +874,152 @@ describe('33acrossBidAdapter:', function () { sandbox.stub(utils, 'getWindowTop').returns({}); sandbox.stub(utils, 'getWindowSelf').returns(win); - const [ buildRequest ] = spec.buildRequests(bidRequests); + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); + validateBuiltServerRequest(buildRequest, serverRequest); + }); + + context('when all the wrapping windows are accessible', function() { + it('returns the viewport dimensions of the top most accessible window', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + ext: { + ttx: { + vp: { + w: 6789, + h: 2345 + } + } + } + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + sandbox.stub(win, 'parent').value({ + document: { + documentElement: { + clientWidth: 1234, + clientHeight: 4567 + } + }, + parent: { + document: { + documentElement: { + clientWidth: 6789, + clientHeight: 2345 + } + }, + } + }); + + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); + validateBuiltServerRequest(buildRequest, serverRequest); + }); + }); + + context('when one of the wrapping windows cannot be accessed', function() { + it('returns the viewport dimensions of the top most accessible window', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + ext: { + ttx: { + vp: { + w: 9876, + h: 5432 + } + } + } + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + const notAccessibleParentWindow = {}; + + Object.defineProperty(notAccessibleParentWindow, 'document', { + get() { throw new Error('fakeError'); } + }); + + sandbox.stub(win, 'parent').value({ + document: { + documentElement: { + clientWidth: 1234, + clientHeight: 4567 + } + }, + parent: { + parent: notAccessibleParentWindow, + document: { + documentElement: { + clientWidth: 9876, + clientHeight: 5432 + } + }, + } + }); + + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); + validateBuiltServerRequest(buildRequest, serverRequest); + }); + }); + }); + + it('returns the screen dimensions', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + ext: { + ttx: { + w: 1024, + h: 728 + } + } + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + win.screen.width = 1024; + win.screen.height = 728; + + const [ buildRequest ] = spec.buildRequests(bidRequests, {bidderRequestId: 'r1'}); + + validateBuiltServerRequest(buildRequest, serverRequest); + }); + + context('when the window height is greater than the width', function() { + it('returns the smaller screen dimension as the width', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withDevice({ + ext: { + ttx: { + w: 728, + h: 1024 + } + } + }) + .withProduct() + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + win.screen.width = 1024; + win.screen.height = 728; + + win.innerHeight = 728; + win.innerWidth = 727; + + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); + validateBuiltServerRequest(buildRequest, serverRequest); }); }); @@ -735,16 +1041,15 @@ describe('33acrossBidAdapter:', function () { win.document.visibilityState = 'hidden'; sandbox.stub(utils, 'getWindowTop').returns(win); - const [ buildRequest ] = spec.buildRequests(bidRequests); + const [ buildRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(buildRequest, serverRequest); }); }); context('when gdpr consent data exists', function() { - let bidderRequest; - beforeEach(function() { bidderRequest = { + ...bidderRequest, gdprConsent: { consentString: 'foobarMyPreference', gdprApplies: true @@ -767,11 +1072,11 @@ describe('33acrossBidAdapter:', function () { }); it('returns corresponding test server requests with gdpr consent data', function() { - sandbox.stub(config, 'getConfig').callsFake(() => { - return { + sandbox.stub(config, 'getConfig') + .withArgs('ttxSettings') + .returns({ 'url': 'https://foo.com/hb/' - } - }); + }); const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -789,12 +1094,6 @@ describe('33acrossBidAdapter:', function () { }); context('when gdpr consent data does not exist', function() { - let bidderRequest; - - beforeEach(function() { - bidderRequest = {}; - }); - it('returns corresponding server requests with default gdpr consent data', function() { const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -809,11 +1108,11 @@ describe('33acrossBidAdapter:', function () { }); it('returns corresponding test server requests with default gdpr consent data', function() { - sandbox.stub(config, 'getConfig').callsFake(() => { - return { + sandbox.stub(config, 'getConfig') + .withArgs('ttxSettings') + .returns({ 'url': 'https://foo.com/hb/' - } - }); + }); const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -830,10 +1129,9 @@ describe('33acrossBidAdapter:', function () { }); context('when us_privacy consent data exists', function() { - let bidderRequest; - beforeEach(function() { bidderRequest = { + ...bidderRequest, uspConsent: 'foo' } }); @@ -853,11 +1151,11 @@ describe('33acrossBidAdapter:', function () { }); it('returns corresponding test server requests with us_privacy consent data', function() { - sandbox.stub(config, 'getConfig').callsFake(() => { - return { + sandbox.stub(config, 'getConfig') + .withArgs('ttxSettings') + .returns({ 'url': 'https://foo.com/hb/' - } - }); + }); const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -875,12 +1173,6 @@ describe('33acrossBidAdapter:', function () { }); context('when us_privacy consent data does not exist', function() { - let bidderRequest; - - beforeEach(function() { - bidderRequest = {}; - }); - it('returns corresponding server requests with default us_privacy data', function() { const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -895,11 +1187,11 @@ describe('33acrossBidAdapter:', function () { }); it('returns corresponding test server requests with default us_privacy consent data', function() { - sandbox.stub(config, 'getConfig').callsFake(() => { - return { + sandbox.stub(config, 'getConfig') + .withArgs('ttxSettings') + .returns({ 'url': 'https://foo.com/hb/' - } - }); + }); const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -915,34 +1207,175 @@ describe('33acrossBidAdapter:', function () { }); }); - context('when referer value is available', function() { - it('returns corresponding server requests with site.page set', function() { - const bidderRequest = { - refererInfo: { - referer: 'http://foo.com/bar' + context('when coppa has been enabled', function() { + beforeEach(function() { + sandbox.stub(config, 'getConfig').withArgs('coppa').returns(true); + }); + + it('returns corresponding server requests with coppa: 1', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProduct() + .withCoppa(1) + .build(); + + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + }); + + context('when coppa has been disabled', function() { + beforeEach(function() { + sandbox.stub(config, 'getConfig').withArgs('coppa').returns(false); + }); + + it('returns corresponding server requests with coppa: 0', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProduct() + .withCoppa(0) + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + }); + + context('when GPP consent data exists', function() { + beforeEach(function() { + bidderRequest = { + ...bidderRequest, + gppConsent: { + gppString: 'foo', + applicableSections: '123' } - }; + } + }); + it('returns corresponding server requests with GPP consent data', function() { const ttxRequest = new TtxRequestBuilder() .withBanner() .withProduct() - .withPageUrl('http://foo.com/bar') + .withGppConsent('foo', '123') .build(); const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + + it('returns corresponding test server requests with GPP consent data', function() { + sandbox.stub(config, 'getConfig').withArgs('ttxSettings') + .returns({ + 'url': 'https://foo.com/hb/' + }); + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProduct() + .withGppConsent('foo', '123') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .withUrl('https://foo.com/hb/') + .build(); const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); }); + context('when refererInfo values are available', function() { + context('when refererInfo.page is defined', function() { + it('returns corresponding server requests with site.page set', function() { + bidderRequest = { + ...bidderRequest, + refererInfo: { + page: 'http://foo.com/bar' + } + }; + + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProduct() + .withPageUrl('http://foo.com/bar') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + }); + + context('when refererInfo.ref is defined', function() { + it('returns corresponding server requests with site.ref set', function() { + bidderRequest = { + ...bidderRequest, + refererInfo: { + ref: 'google.com' + } + }; + + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProduct() + .withReferer('google.com') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + }); + }); + + context('when Global Placement ID (gpid) is defined', function() { + it('passes the Global Placement ID (gpid) in the request', function() { + const ttxRequest = new TtxRequestBuilder() + .withBanner() + .withProduct() + .withGpid('fakeGPID0') + .build(); + const serverRequest = new ServerRequestBuilder() + .withData(ttxRequest) + .build(); + + let copyBidRequest = utils.deepClone(bidRequests); + const bidRequestsWithGpid = copyBidRequest.map(function(bidRequest, index) { + return { + ...bidRequest, + ortb2Imp: { + ext: { + gpid: 'fakeGPID' + index + } + } + }; + }); + + const [ builtServerRequest ] = spec.buildRequests(bidRequestsWithGpid, bidderRequest); + + validateBuiltServerRequest(builtServerRequest, serverRequest); + }); + }); + context('when referer value is not available', function() { - it('returns corresponding server requests without site.page set', function() { - const bidderRequest = { - refererInfo: {} - }; + it('returns corresponding server requests without site.page and site.ref set', function() { + bidderRequest.refererInfo = {}; const ttxRequest = new TtxRequestBuilder() .withBanner() @@ -1006,7 +1439,7 @@ describe('33acrossBidAdapter:', function () { .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1024,7 +1457,7 @@ describe('33acrossBidAdapter:', function () { .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1039,7 +1472,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1056,7 +1489,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1081,7 +1514,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1106,7 +1539,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1123,7 +1556,7 @@ describe('33acrossBidAdapter:', function () { .withProduct('instream') .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); expect(JSON.parse(builtServerRequest.data)).to.deep.equal(ttxRequest); }); @@ -1147,7 +1580,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1167,7 +1600,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1189,7 +1622,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1210,7 +1643,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1234,7 +1667,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1258,7 +1691,7 @@ describe('33acrossBidAdapter:', function () { const serverRequest = new ServerRequestBuilder() .withData(ttxRequest) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); validateBuiltServerRequest(builtServerRequest, serverRequest); }); @@ -1279,7 +1712,7 @@ describe('33acrossBidAdapter:', function () { .withProduct() .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); expect(JSON.parse(builtServerRequest.data)).to.deep.equal(ttxRequest); }); @@ -1307,7 +1740,7 @@ describe('33acrossBidAdapter:', function () { .withFloors('video', [ 1.0 ]) .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); expect(JSON.parse(builtServerRequest.data)).to.deep.equal(ttxRequest); }); @@ -1349,7 +1782,7 @@ describe('33acrossBidAdapter:', function () { .withProduct() .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); expect(JSON.parse(builtServerRequest.data)).to.deep.equal(ttxRequest); }); @@ -1368,7 +1801,7 @@ describe('33acrossBidAdapter:', function () { .withProduct() .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); expect(JSON.parse(builtServerRequest.data)).to.deep.equal(ttxRequest); }); @@ -1415,7 +1848,7 @@ describe('33acrossBidAdapter:', function () { .withProduct() .build(); - const [ builtServerRequest ] = spec.buildRequests(bidRequests, {}); + const [ builtServerRequest ] = spec.buildRequests(bidRequests, bidderRequest); expect(JSON.parse(builtServerRequest.data)).to.deep.equal(ttxRequest); }); @@ -1424,11 +1857,11 @@ describe('33acrossBidAdapter:', function () { context('when SRA mode is enabled', function() { it('builds a single request with multiple imps corresponding to each group {siteId, productId}', function() { - sandbox.stub(config, 'getConfig').callsFake(() => { - return { + sandbox.stub(config, 'getConfig') + .withArgs('ttxSettings') + .returns({ enableSRAMode: true - } - }); + }); const bidRequests = new BidRequestsBuilder() .addBid() @@ -1489,7 +1922,7 @@ describe('33acrossBidAdapter:', function () { .withUrl('https://ssc.33across.com/api/v1/hb?guid=sample33xGUID123456780') .build(); - const builtServerRequests = spec.buildRequests(bidRequests, {}); + const builtServerRequests = spec.buildRequests(bidRequests, bidderRequest); expect(builtServerRequests).to.deep.equal([serverReq1, serverReq2, serverReq3]); }); @@ -1546,7 +1979,7 @@ describe('33acrossBidAdapter:', function () { .withUrl('https://ssc.33across.com/api/v1/hb?guid=sample33xGUID123456780') .build(); - const builtServerRequests = spec.buildRequests(bidRequests, {}); + const builtServerRequests = spec.buildRequests(bidRequests, bidderRequest); expect(builtServerRequests) .to.deep.equal([ @@ -1605,7 +2038,6 @@ describe('33acrossBidAdapter:', function () { }; const bidResponse = { requestId: 'b1', - bidderCode: BIDDER_CODE, cpm: 0.0938, width: 300, height: 250, @@ -1651,7 +2083,6 @@ describe('33acrossBidAdapter:', function () { }; const bidResponse = { requestId: 'b1', - bidderCode: BIDDER_CODE, cpm: 0.0938, width: 300, height: 250, @@ -1695,7 +2126,6 @@ describe('33acrossBidAdapter:', function () { // Bid response below doesn't contain meta.advertiserDomains const bidResponse = { requestId: 'b1', - bidderCode: BIDDER_CODE, cpm: 0.0938, width: 300, height: 250, @@ -1775,7 +2205,6 @@ describe('33acrossBidAdapter:', function () { const bidResponse = [ { requestId: 'b1', - bidderCode: BIDDER_CODE, cpm: 0.0940, width: 300, height: 250, @@ -1788,7 +2217,6 @@ describe('33acrossBidAdapter:', function () { }, { requestId: 'b2', - bidderCode: BIDDER_CODE, cpm: 0.0938, width: 300, height: 250, @@ -1801,7 +2229,6 @@ describe('33acrossBidAdapter:', function () { }, { requestId: 'b3', - bidderCode: BIDDER_CODE, cpm: 0.0938, width: 300, height: 250, @@ -1884,7 +2311,7 @@ describe('33acrossBidAdapter:', function () { expect(spec.getUserSyncs(syncOptions)).to.deep.equal([]); }); - }); + }, bidderRequest); context('when iframe is enabled', function() { let syncOptions; @@ -1896,17 +2323,17 @@ describe('33acrossBidAdapter:', function () { context('when there is no gdpr consent data', function() { it('returns sync urls with undefined consent string as param', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, undefined); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined` + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined` + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=` } ] @@ -1916,17 +2343,17 @@ describe('33acrossBidAdapter:', function () { context('when gdpr applies but there is no consent string', function() { it('returns sync urls with undefined consent string as param and gdpr=1', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: true}); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gdpr=1` + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=&gdpr=1` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gdpr=1` + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=&gdpr=1` } ]; @@ -1936,17 +2363,17 @@ describe('33acrossBidAdapter:', function () { context('when gdpr applies and there is consent string', function() { it('returns sync urls with gdpr_consent=consent string as param and gdpr=1', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: true, consentString: 'consent123A'}); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=consent123A&us_privacy=undefined&gdpr=1` + url: `${syncs[0].url}&gdpr_consent=consent123A&us_privacy=undefined&gpp=&gpp_sid=&gdpr=1` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=consent123A&us_privacy=undefined&gdpr=1` + url: `${syncs[1].url}&gdpr_consent=consent123A&us_privacy=undefined&gpp=&gpp_sid=&gdpr=1` } ]; @@ -1956,17 +2383,17 @@ describe('33acrossBidAdapter:', function () { context('when gdpr does not apply and there is no consent string', function() { it('returns sync urls with undefined consent string as param and gdpr=0', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: false}); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gdpr=0` + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=&gdpr=0` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gdpr=0` + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=&gdpr=0` } ]; expect(syncResults).to.deep.equal(expectedSyncs); @@ -1975,17 +2402,17 @@ describe('33acrossBidAdapter:', function () { context('when gdpr is unknown and there is consent string', function() { it('returns sync urls with only consent string as param', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, {consentString: 'consent123A'}); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=consent123A&us_privacy=undefined` + url: `${syncs[0].url}&gdpr_consent=consent123A&us_privacy=undefined&gpp=&gpp_sid=` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=consent123A&us_privacy=undefined` + url: `${syncs[1].url}&gdpr_consent=consent123A&us_privacy=undefined&gpp=&gpp_sid=` } ]; expect(syncResults).to.deep.equal(expectedSyncs); @@ -1994,17 +2421,17 @@ describe('33acrossBidAdapter:', function () { context('when gdpr does not apply and there is consent string (yikes!)', function() { it('returns sync urls with consent string as param and gdpr=0', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, {gdprApplies: false, consentString: 'consent123A'}); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=consent123A&us_privacy=undefined&gdpr=0` + url: `${syncs[0].url}&gdpr_consent=consent123A&us_privacy=undefined&gpp=&gpp_sid=&gdpr=0` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=consent123A&us_privacy=undefined&gdpr=0` + url: `${syncs[1].url}&gdpr_consent=consent123A&us_privacy=undefined&gpp=&gpp_sid=&gdpr=0` } ]; expect(syncResults).to.deep.equal(expectedSyncs); @@ -2013,17 +2440,17 @@ describe('33acrossBidAdapter:', function () { context('when there is no usPrivacy data', function() { it('returns sync urls with undefined consent string as param', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined` + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined` + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=` } ] @@ -2033,17 +2460,60 @@ describe('33acrossBidAdapter:', function () { context('when there is usPrivacy data', function() { it('returns sync urls with consent string as param', function() { - spec.buildRequests(bidRequests); + spec.buildRequests(bidRequests, bidderRequest); const syncResults = spec.getUserSyncs(syncOptions, {}, {}, 'foo'); const expectedSyncs = [ { type: 'iframe', - url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=foo` + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=foo&gpp=&gpp_sid=` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=foo&gpp=&gpp_sid=` + } + ]; + + expect(syncResults).to.deep.equal(expectedSyncs); + }); + }); + + context('when there is no GPP data', function() { + it('returns sync urls with empty GPP params', function() { + spec.buildRequests(bidRequests); + + const syncResults = spec.getUserSyncs(syncOptions, {}); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=` + }, + { + type: 'iframe', + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=&gpp_sid=` + } + ] + + expect(syncResults).to.deep.equal(expectedSyncs); + }) + }); + + context('when there is GPP data', function() { + it('returns sync urls with GPP consent string & GPP Section ID as params', function() { + spec.buildRequests(bidRequests); + + const syncResults = spec.getUserSyncs(syncOptions, {}, {}, undefined, { + gppString: 'foo', + applicableSections: ['123', '456'] + }); + const expectedSyncs = [ + { + type: 'iframe', + url: `${syncs[0].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=foo&gpp_sid=123%2C456` }, { type: 'iframe', - url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=foo` + url: `${syncs[1].url}&gdpr_consent=undefined&us_privacy=undefined&gpp=foo&gpp_sid=123%2C456` } ]; diff --git a/test/spec/modules/33acrossIdSystem_spec.js b/test/spec/modules/33acrossIdSystem_spec.js new file mode 100644 index 00000000000..4f6d7c4a6c5 --- /dev/null +++ b/test/spec/modules/33acrossIdSystem_spec.js @@ -0,0 +1,511 @@ +import { thirthyThreeAcrossIdSubmodule } from 'modules/33acrossIdSystem.js'; +import * as utils from 'src/utils.js'; + +import { server } from 'test/mocks/xhr.js'; +import { uspDataHandler, coppaDataHandler, gppDataHandler } from 'src/adapterManager.js'; + +describe('33acrossIdSystem', () => { + describe('name', () => { + it('should expose the name of the submodule', () => { + expect(thirthyThreeAcrossIdSubmodule.name).to.equal('33acrossId'); + }); + }); + + describe('gvlid', () => { + it('should expose the vendor id', () => { + expect(thirthyThreeAcrossIdSubmodule.gvlid).to.equal(58); + }); + }); + + describe('getId', () => { + it('should call endpoint and handle valid response', () => { + const completeCallback = sinon.spy(); + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: true, + data: { + envelope: 'foo' + }, + expires: 1645667805067 + })); + + expect(request.method).to.equal('GET'); + expect(request.withCredentials).to.be.true; + + const regExp = new RegExp('https://lexicon.33across.com/v1/envelope\\?pid=12345&gdpr=\\d&src=pbjs&ver=$prebid.version$'); + + expect(request.url).to.match(regExp); + expect(completeCallback.calledOnceWithExactly('foo')).to.be.true; + }); + + context('when GDPR applies', () => { + it('should call endpoint with \'gdpr=1\'', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }, { + gdprApplies: true + }); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).to.contain('gdpr=1'); + }); + }); + + context('when GDPR doesn\'t apply', () => { + it('should call endpoint with \'gdpr=0\'', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }, { + gdprApplies: false + }); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).to.contain('gdpr=0'); + }); + }); + + context('when the GDPR consent string is given', () => { + it('should call endpoint with the GDPR consent string', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }, { + consentString: 'foo' + }); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).to.contain('gdpr_consent=foo'); + }); + }); + + context('when a valid US Privacy string is given', () => { + it('should call endpoint with the US Privacy parameter', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + sinon.stub(uspDataHandler, 'getConsentData').returns('1YYY'); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).to.contain('us_privacy=1YYY'); + + uspDataHandler.getConsentData.restore(); + }); + }); + + context('when an invalid US Privacy is given', () => { + it('should call endpoint without the US Privacy parameter', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + // null or any other falsy value is considered invalid. + sinon.stub(uspDataHandler, 'getConsentData').returns(null); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).not.to.contain('us_privacy'); + + uspDataHandler.getConsentData.restore(); + }); + }); + + context('when coppa is enabled', () => { + it('should call endpoint with an enabled coppa signal', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + sinon.stub(coppaDataHandler, 'getCoppa').returns(true); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).to.contain('coppa=1'); + + coppaDataHandler.getCoppa.restore(); + }); + }); + + context('when coppa is not enabled', () => { + it('should call endpoint with coppa signal not enabled', () => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + sinon.stub(coppaDataHandler, 'getCoppa').returns(false); + + callback(completeCallback); + + const [request] = server.requests; + + expect(request.url).to.contain('coppa=0'); + + coppaDataHandler.getCoppa.restore(); + }); + }); + + context('when a GPP consent string is given', () => { + beforeEach(() => { + sinon.stub(gppDataHandler, 'getConsentData'); + }); + + afterEach(() => { + gppDataHandler.getConsentData.restore(); + }); + + it('should call endpoint with the GPP consent string', () => { + [ + { gppString: '', expected: '' }, + { gppString: undefined, expected: '' }, + { gppString: 'foo', expected: 'foo' }, + ].forEach(({ gppString, expected }, index) => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + gppDataHandler.getConsentData.onCall(index).returns({ + gppString + }); + + callback(completeCallback); + + expect(server.requests[index].url).to.contain(`gpp=${expected}`); + }); + }); + + it('should call endpoint with the GPP applicable sections', () => { + const gppString = 'foo'; + + [ + { applicableSections: [], expected: '' }, + { applicableSections: undefined, expected: '' }, + { applicableSections: ['1'], expected: '1' }, + { applicableSections: ['1', '2'], expected: '1%2C2' }, + ].forEach(({ applicableSections, expected }, index) => { + const completeCallback = () => {}; + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + gppDataHandler.getConsentData.onCall(index).returns({ + gppString: 'foo', + applicableSections + }); + + callback(completeCallback); + + expect(server.requests[index].url).to.contain(`gpp_sid=${expected}`); + }); + }); + }); + + context('when the partner ID is not given', () => { + it('should log an error', () => { + const logErrorSpy = sinon.spy(utils, 'logError'); + + thirthyThreeAcrossIdSubmodule.getId({ + params: { /* No 'pid' param */ } + }); + + expect(logErrorSpy.calledOnceWithExactly('33acrossId: Submodule requires a partner ID to be defined')).to.be.true; + + logErrorSpy.restore(); + }); + }); + + context('when the partner ID has an incorrect format', () => { + it('should log an error', () => { + const logErrorSpy = sinon.spy(utils, 'logError'); + + thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: 123456 // PID must be a string + } + }); + + expect(logErrorSpy.calledOnceWithExactly('33acrossId: Submodule requires a partner ID to be defined')).to.be.true; + + logErrorSpy.restore(); + }); + }); + + context('when the server JSON is invalid', () => { + it('should log an error', () => { + const logErrorSpy = sinon.spy(utils, 'logError'); + const completeCallback = () => {}; + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, 'invalid response'); + + expect(logErrorSpy.lastCall.args[0]).to.eq(`${thirthyThreeAcrossIdSubmodule.name}: ID reading error:`); + + logErrorSpy.restore(); + }); + + it('should execute complete callback with undefined value', () => { + const completeCallback = sinon.spy(); + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, 'invalid response'); + + expect(completeCallback.calledOnceWithExactly(undefined)).to.be.true; + }); + }); + + context('when an endpoint override is given', () => { + it('should call that endpoint', () => { + const completeCallback = sinon.spy(); + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345', + apiUrl: 'https://staging-lexicon.33across.com/v1/envelope' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: true, + data: { + envelope: 'foo' + }, + expires: 1645667805067 + })); + + expect(request.url).to.contain('https://staging-lexicon.33across.com/v1/envelope?pid=12345'); + }); + }); + + context('when the server returns an unsuccessful response', () => { + it('should log an error', () => { + const logErrorSpy = sinon.spy(utils, 'logError'); + const completeCallback = () => {}; + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: false, + error: 'foo' + })); + + expect(logErrorSpy.calledOnceWithExactly(`${thirthyThreeAcrossIdSubmodule.name}: Unsuccessful response foo`)).to.be.true; + + logErrorSpy.restore(); + }); + + it('should execute complete callback with undefined value', () => { + const completeCallback = sinon.spy(); + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: false, + error: 'foo' + })); + + expect(completeCallback.calledOnceWithExactly(undefined)).to.be.true; + }); + }); + + context('when the server returns a successful response but without ID', () => { + it('should log a message', () => { + const logMessageSpy = sinon.spy(utils, 'logMessage'); + const completeCallback = () => {}; + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: true, + data: {} + })); + + expect(logMessageSpy.calledOnceWithExactly(`${thirthyThreeAcrossIdSubmodule.name}: No envelope was received`)).to.be.true; + + logMessageSpy.restore(); + }); + + it('should execute complete callback with undefined value', () => { + const completeCallback = sinon.spy(); + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(200, { + 'Content-Type': 'application/json' + }, JSON.stringify({ + succeeded: true, + data: {} + })); + + expect(completeCallback.calledOnceWithExactly(undefined)).to.be.true; + }); + }); + + context('when the server returns an error status code', () => { + it('should log an error', () => { + const logErrorSpy = sinon.spy(utils, 'logError'); + const completeCallback = () => {}; + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(404); + + expect(logErrorSpy.calledOnceWithExactly(`${thirthyThreeAcrossIdSubmodule.name}: ID error response`, 'Not Found')).to.be.true; + + logErrorSpy.restore(); + }); + + it('should execute complete callback without any value', () => { + const completeCallback = sinon.spy(); + + const { callback } = thirthyThreeAcrossIdSubmodule.getId({ + params: { + pid: '12345' + } + }); + + callback(completeCallback); + + const [request] = server.requests; + + request.respond(404); + + expect(completeCallback.calledOnceWithExactly()).to.be.true; + }); + }) + }) + + describe('decode', () => { + it('should wrap the given value inside an object literal', () => { + expect(thirthyThreeAcrossIdSubmodule.decode('foo')).to.deep.equal({ + [thirthyThreeAcrossIdSubmodule.name]: { + envelope: 'foo' + } + }); + }); + }); +}); diff --git a/test/spec/modules/ViouslyBidAdapter_spec.js b/test/spec/modules/ViouslyBidAdapter_spec.js new file mode 100644 index 00000000000..f8cd686581c --- /dev/null +++ b/test/spec/modules/ViouslyBidAdapter_spec.js @@ -0,0 +1,474 @@ +import {expect} from 'chai'; + +import { deepClone, mergeDeep } from 'src/utils'; +import { BANNER, VIDEO } from 'src/mediaTypes'; +import { createEidsArray } from 'modules/userId/eids.js'; + +import {spec as adapter} from 'modules/viouslyBidAdapter'; + +import sinon from 'sinon'; +import { config } from 'src/config.js'; + +const CURRENCY = 'EUR'; +const TTL = 60; +const HTTP_METHOD = 'POST'; +const REQUEST_URL = 'https://bidder.viously.com/bid'; + +const VALID_BID_BANNER = { + bidder: 'viously', + bidId: '5e6f7g8h', + adUnitCode: 'id-5678', + params: { + pid: '123e4567-e89b-12d3-a456-426614174002' + }, + mediaTypes: { + banner: { + sizes: [300, 50], + pos: 1 + } + } +}; + +const VALID_BID_VIDEO = { + bidder: 'viously', + bidId: '5e6f7g8h', + adUnitCode: 'id-5678', + params: { + pid: '123e4567-e89b-12d3-a456-426614174001' + }, + mediaTypes: { + video: { + playerSize: [640, 360], + context: 'instream', + playbackmethod: [1, 2, 3, 4] + } + } +}; + +const VALID_REQUEST_BANNER = { + method: HTTP_METHOD, + url: REQUEST_URL, + data: { + pid: '123e4567-e89b-12d3-a456-426614174002', + currency_code: CURRENCY, + placements: [ + { + id: 'id-5678', + bid_id: '5e6f7g8h', + sizes: ['300x50'], + type: BANNER, + position: 1 + } + ] + } +}; + +const VALID_REQUEST_VIDEO = { + method: HTTP_METHOD, + url: REQUEST_URL, + data: { + pid: '123e4567-e89b-12d3-a456-426614174001', + currency_code: CURRENCY, + placements: [ + { + id: 'id-5678', + bid_id: '5e6f7g8h', + type: VIDEO, + video_params: { + context: 'instream', + playbackmethod: [1, 2, 3, 4], + size: ['640x360'] + } + } + ] + } +}; + +const VALID_GDPR = { + gdprApplies: true, + apiVersion: 2, + consentString: 'abcdefgh', + addtlConsent: '1~12345678', + vendorData: { + purpose: { + consents: { + 1: true + } + } + } +}; +const US_PRIVACY = '1YNN'; + +describe('ViouslyAdapter', function () { + describe('isBidRequestValid', function () { + describe('Check method return', function () { + it('should return true', function () { + expect(adapter.isBidRequestValid(VALID_BID_BANNER)).to.equal(true); + expect(adapter.isBidRequestValid(VALID_BID_VIDEO)).to.equal(true); + }); + + it('should return true for banner with no pos', function () { + let newBid = deepClone(VALID_BID_BANNER); + let newRequest = deepClone(VALID_REQUEST_BANNER); + + delete newBid.mediaTypes.banner.pos; + newRequest.data.placements[0].position = 0; + + expect(adapter.buildRequests([newBid])).to.deep.equal(newRequest); + }); + + it('should return false because the banner size is missing', function () { + let wrongBid = deepClone(VALID_BID_BANNER); + + wrongBid.mediaTypes.banner.sizes = '123456'; + expect(adapter.isBidRequestValid(wrongBid)).to.equal(false); + + delete wrongBid.mediaTypes.banner.sizes; + expect(adapter.isBidRequestValid(wrongBid)).to.equal(false); + }); + + it('should return false because the pid is missing', function () { + let wrongBid = deepClone(VALID_BID_VIDEO); + delete wrongBid.params.pid; + + expect(adapter.isBidRequestValid(wrongBid)).to.equal(false); + }); + + it('should return false because the video context parameter is missing', function () { + let wrongBid = deepClone(VALID_BID_VIDEO); + + delete wrongBid.mediaTypes.video.context; + expect(adapter.isBidRequestValid(wrongBid)).to.equal(false); + }); + }); + }); + + describe('buildRequests', function () { + describe('Check method return', function () { + it('should return the right formatted banner requests', function() { + expect(adapter.buildRequests([VALID_BID_BANNER])).to.deep.equal(VALID_REQUEST_BANNER); + }); + + it('should return the right formatted video requests', function() { + expect(adapter.buildRequests([VALID_BID_VIDEO])).to.deep.equal(VALID_REQUEST_VIDEO); + }); + + it('should return the right formatted request with the referer info', function() { + let bidderRequest = { + refererInfo: { + page: 'https://www.example.com/test' + } + }; + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO), { + data: { + domain: 'www.example.com', + page_domain: 'https://www.example.com/test' + } + }); + + expect(adapter.buildRequests([VALID_BID_VIDEO], bidderRequest)).to.deep.equal(requests); + }); + + it('should return the right formatted request with the referer info from config', function() { + /** Mock the config.getConfig method */ + sinon.stub(config, 'getConfig') + .withArgs('pageUrl') + .returns('https://www.example.com/page'); + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO), { + data: { + domain: 'www.example.com', + page_domain: 'https://www.example.com/page' + } + }); + + expect(adapter.buildRequests([VALID_BID_VIDEO])).to.deep.equal(requests); + + config.getConfig.restore(); + }); + + it('should return the right formatted request with GDPR Consent info', function() { + let bidderRequest = { + gdprConsent: VALID_GDPR + }; + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO), { + data: { + gdpr: true, + gdpr_consent: 'abcdefgh', + addtl_consent: '1~12345678' + } + }); + + expect(adapter.buildRequests([VALID_BID_VIDEO], bidderRequest)).to.deep.equal(requests); + }); + + it('should return the right formatted request with US Privacy info', function() { + let bidderRequest = { + uspConsent: US_PRIVACY + }; + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO), { + data: { + us_privacy: US_PRIVACY + } + }); + + expect(adapter.buildRequests([VALID_BID_VIDEO], bidderRequest)).to.deep.equal(requests); + }); + + // TODO: Supply chain + it('should return the right formatted request with Supply Chain info', function() { + let schain = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'test1.com', + 'sid': '00001', + 'hp': 1 + }, + { + 'asi': 'test2-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + + let bid = mergeDeep(deepClone(VALID_BID_VIDEO), { + schain: schain + }); + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO), { + data: { + schain: schain + } + }); + + expect(adapter.buildRequests([bid])).to.deep.equal(requests); + }); + + it('should return the right formatted request with User Ids info', function() { + let userIds = { + idl_env: '1234-5678-9012-3456', // Liveramp + netId: 'testnetid123', // NetId + IDP: 'userIDP000', // IDP + fabrickId: 'fabrickId9000', // FabrickId + uid2: { id: 'testuid2' } // UID 2.0 + }; + + let bid = mergeDeep(deepClone(VALID_BID_VIDEO), { + userIds: userIds + }, { + userIdAsEids: createEidsArray(userIds) + }); + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO), { + data: { + users_uid: createEidsArray(userIds) + } + }); + + expect(adapter.buildRequests([bid])).to.deep.equal(requests); + }); + + it('should return the right formatted request with endpoint test', function() { + let endpoint = 'https://bid-test.viously.com/prebid'; + + let bid = mergeDeep(deepClone(VALID_BID_VIDEO), { + params: { + endpoint: endpoint + } + }); + + let requests = mergeDeep(deepClone(VALID_REQUEST_VIDEO)); + + requests.url = endpoint; + + expect(adapter.buildRequests([bid])).to.deep.equal(requests); + }); + + // TODO: Floor + }); + }); + + describe('interpretResponse', function() { + describe('Check method return', function () { + it('should return the right formatted response', function() { + let response = { + body: { + ads: [ + { + bid: false, + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-0', + bid_id: '1234' + }, + { + bid: true, + creative_id: '2468', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-1', + bid_id: '5678', + cpm: 8, + ad: 'vast xml', + ad_url: 'http://www.example.com/vast', + type: 'video', + size: '640x480', + nurl: [ + 'win.domain.com' + ] + }, + { + bid: true, + creative_id: '1357', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-2', + bid_id: '9101112', + cpm: 1.5, + ad: 'html content', + type: 'banner', + size: '300x50', + nurl: [ + 'win.domain2.com', + 'win.domain3.com' + ] + }, + { + bid: true, + creative_id: '1469', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-3', + bid_id: '2570', + cpm: 4, + ad: 'vast xml', + type: 'video', + size: '640x480', + } + ] + } + }; + let requests = { + data: { + placements: [ + { + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-0', + bid_id: '1234' + }, + { + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-1', + bid_id: '5678' + }, + { + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-2', + bid_id: '9101112' + }, + { + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-3', + bid_id: '2570' + } + ] + } + }; + + let formattedReponse = [ + { + requestId: '5678', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-1', + cpm: 8, + width: '640', + height: '480', + creativeId: '2468', + currency: CURRENCY, + netRevenue: true, + ttl: TTL, + mediaType: 'video', + meta: {}, + vastUrl: 'http://www.example.com/vast', + nurl: [ + 'win.domain.com' + ] + }, + { + requestId: '9101112', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-2', + cpm: 1.5, + width: '300', + height: '50', + creativeId: '1357', + currency: CURRENCY, + netRevenue: true, + ttl: TTL, + mediaType: 'banner', + meta: {}, + ad: 'html content', + nurl: [ + 'win.domain2.com', + 'win.domain3.com' + ] + }, + { + requestId: '2570', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-3', + cpm: 4, + width: '640', + height: '480', + creativeId: '1469', + currency: CURRENCY, + netRevenue: true, + ttl: TTL, + mediaType: 'video', + meta: {}, + vastXml: 'vast xml', + nurl: [] + } + ]; + + expect(adapter.interpretResponse(response, requests)).to.deep.equal(formattedReponse); + }); + }); + }); + + describe('onBidWon', function() { + describe('Check methods succeed', function () { + it('should not throw error', function() { + let bids = [ + { + requestId: '5678', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-1', + cpm: 8, + width: '640', + height: '480', + creativeId: '2468', + currency: CURRENCY, + netRevenue: true, + ttl: TTL, + mediaType: 'video', + meta: {}, + vastUrl: 'http://www.example.com/vast', + nurl: [ + 'win.domain.com' + ] + }, + { + requestId: '2570', + id: 'id-0157324f-bee4-5390-a14c-47a7da3eb73c-3', + cpm: 4, + width: '640', + height: '480', + creativeId: '1469', + currency: CURRENCY, + netRevenue: true, + ttl: TTL, + mediaType: 'video', + meta: {}, + vastXml: 'vast xml', + nurl: [] + } + ]; + + bids.forEach(function(bid) { + expect(adapter.onBidWon.bind(adapter, bid)).to.not.throw(); + }); + }); + }); + }); +}); diff --git a/test/spec/modules/a1MediaBidAdapter_spec.js b/test/spec/modules/a1MediaBidAdapter_spec.js new file mode 100644 index 00000000000..060fe3b5a65 --- /dev/null +++ b/test/spec/modules/a1MediaBidAdapter_spec.js @@ -0,0 +1,220 @@ +import { spec } from 'modules/a1MediaBidAdapter.js'; +import { config } from 'src/config.js'; +import { BANNER, VIDEO, NATIVE } from 'src/mediaTypes.js'; +import 'modules/currency.js'; +import 'modules/priceFloors.js'; + +const ortbBlockParams = { + battr: [ 13 ], + bcat: ['IAB1-1'] +}; +const getBidderRequest = (isMulti = false) => { + return { + bidderCode: 'a1media', + auctionId: 'ba87bfdf-493e-4a88-8e26-17b4cbc9adbd', + bidderRequestId: '104e8d2392bd6f', + bids: [ + { + bidder: 'a1media', + params: {}, + auctionId: 'ba87bfdf-493e-4a88-8e26-17b4cbc9adbd', + mediaTypes: { + banner: { + sizes: [ + [ 320, 100 ], + ] + }, + ...(isMulti && { + video: { + mimes: ['video/mp4'] + }, + native: { + title: { + required: true, + }} + }) + }, + ...(isMulti && { + nativeOrtbRequest: { + ver: '1.2', + assets: [ + { + id: 0, + required: 1, + title: { + len: 140 + } + } + ] + } + }), + adUnitCode: 'test-div', + transactionId: 'cab00498-028b-4061-8f9d-a8d66c8cb91d', + bidId: '2e9f38ea93bb9e', + bidderRequestId: '104e8d2392bd6f', + } + ], + } +}; +const getConvertedBidReq = () => { + return { + cur: [ + 'JPY' + ], + imp: [ + { + banner: { + format: [ + { + h: 100, + w: 320 + }, + ], + topframe: 0 + }, + bidfloor: 0, + bidfloorcur: 'JPY', + id: '2e9f38ea93bb9e' + } + ], + test: 0, + } +}; + +const getBidderResponse = () => { + return { + body: { + id: 'bid-response', + cur: 'JPY', + seatbid: [ + { + bid: [{ + impid: '2e9f38ea93bb9e', + crid: 'creative-id', + cur: 'JPY', + price: 9, + }] + } + ] + } + } +} +const bannerAdm = '
'; +const videoAdm = 'testvast1'; +const nativeAdm = '{"ver":"1.2","link":{"url":"test_url"},"assets":[{"id":1,"required":1,"title":{"text":"native_title"}}]}'; + +describe('a1MediaBidAdapter', function() { + describe('isValidRequest', function() { + const bid = { + bidder: 'a1media', + }; + + it('should return true always', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + + describe('buildRequests', function() { + let bidderRequest, convertedRequest; + beforeEach(function() { + bidderRequest = getBidderRequest(); + convertedRequest = getConvertedBidReq(); + }); + + it('should return expected request object', function() { + const bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + convertedRequest.id = bidRequest.data.id; + + expect(bidRequest.method).equal('POST'); + expect(bidRequest.url).equal('https://d11.contentsfeed.com/dsp/breq/a1'); + expect(bidRequest.data).deep.equal(convertedRequest); + }); + it('should set ortb blocking using params', function() { + bidderRequest.bids[0].params = ortbBlockParams; + + const bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + convertedRequest.id = bidRequest.data.id; + convertedRequest.bcat = ortbBlockParams.bcat; + convertedRequest.imp[0].banner.battr = ortbBlockParams.battr; + + expect(bidRequest.data).deep.equal(convertedRequest); + }); + + it('should set bidfloor when getFloor is available', function() { + bidderRequest.bids[0].getFloor = () => ({ currency: 'USD', floor: 999 }); + const bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + + expect(bidRequest.data.imp[0].bidfloor).equal(999); + expect(bidRequest.data.imp[0].bidfloorcur).equal('USD'); + }); + + it('should set cur when currency config is configured', function() { + config.setConfig({ + currency: { + adServerCurrency: 'USD', + } + }); + const bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + + expect(bidRequest.data.cur[0]).equal('USD'); + }); + + it('should set bidfloor and currency using params when modules not available', function() { + bidderRequest.bids[0].params.currency = 'USD'; + bidderRequest.bids[0].params.bidfloor = 0.99; + + const bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + convertedRequest.id = bidRequest.data.id; + convertedRequest.imp[0].bidfloor = 0.99; + convertedRequest.imp[0].bidfloorcur = 'USD'; + convertedRequest.cur[0] = 'USD'; + + expect(bidRequest.data).deep.equal(convertedRequest); + }); + }); + + describe('interpretResponse', function() { + describe('when request mediaType is single', function() { + let bidRequest, bidderResponse; + beforeEach(function() { + const bidderRequest = getBidderRequest(); + bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + bidderResponse = getBidderResponse(); + }); + it('should set cpm using price attribute', function() { + const bidResPrice = 9; + bidderResponse.body.seatbid[0].bid[0].price = bidResPrice; + const interpretedRes = spec.interpretResponse(bidderResponse, bidRequest); + expect(interpretedRes[0].cpm).equal(bidResPrice); + }); + it('should set mediaType using request mediaTypes', function() { + const interpretedRes = spec.interpretResponse(bidderResponse, bidRequest); + expect(interpretedRes[0].mediaType).equal(BANNER); + }); + }); + + describe('when request mediaType is multi', function() { + let bidRequest, bidderResponse; + beforeEach(function() { + const bidderRequest = getBidderRequest(true); + bidRequest = spec.buildRequests(bidderRequest.bids, bidderRequest); + bidderResponse = getBidderResponse(); + }); + it('should set mediaType to video', function() { + bidderResponse.body.seatbid[0].bid[0].adm = videoAdm; + const interpretedRes = spec.interpretResponse(bidderResponse, bidRequest); + expect(interpretedRes[0].mediaType).equal(VIDEO); + }); + it('should set mediaType to native', function() { + bidderResponse.body.seatbid[0].bid[0].adm = nativeAdm; + const interpretedRes = spec.interpretResponse(bidderResponse, bidRequest); + expect(interpretedRes[0].mediaType).equal(NATIVE); + }); + it('should set mediaType to banner when adm is neither native or video', function() { + bidderResponse.body.seatbid[0].bid[0].adm = bannerAdm; + const interpretedRes = spec.interpretResponse(bidderResponse, bidRequest); + expect(interpretedRes[0].mediaType).equal(BANNER); + }); + }); + }); +}) diff --git a/test/spec/modules/a1MediaRtdProvider_spec.js b/test/spec/modules/a1MediaRtdProvider_spec.js new file mode 100644 index 00000000000..2630e83fcf5 --- /dev/null +++ b/test/spec/modules/a1MediaRtdProvider_spec.js @@ -0,0 +1,105 @@ +import { subModuleObj } from 'modules/a1MediaRtdProvider.js'; +import { loadExternalScript } from '../../../src/adloader.js'; +import { A1_AUD_KEY, A1_SEG_KEY, getStorageData, storage } from '../../../modules/a1MediaRtdProvider.js'; +import { expect } from 'chai'; + +const configWithParams = { + name: 'a1Media', + waitForIt: true, + params: { + tagId: 'lb4test.min.js', + }, +}; +const configWithoutParams = { + name: 'a1Media', + waitForIt: true, + params: { + }, +}; + +const reqBidsConfigObj = { + ortb2Fragments: { + global: {} + } +}; +const a1TestOrtbObj = { + user: { + data: [ + { + name: 'a1mediagroup.com', + ext: { + segtax: 900 + }, + segment: [{id: 'test'}] + } + ], + ext: { + eids: [ + { + source: 'a1mediagroup.com', + uids: [ + { + id: 'tester', + atype: 1 + } + ] + } + ] + } + } +}; + +describe('a1MediaRtdProvider', function() { + describe('init', function() { + describe('initialize with expected params', function() { + it('successfully initialize with load script', function() { + expect(subModuleObj.init(configWithParams)).to.be.true; + expect(window.linkback.l).to.be.true; + expect(loadExternalScript.called).to.be.true; + expect(loadExternalScript.args[0][0]).to.deep.equal('https://linkback.contentsfeed.com/src/lb4test.min.js'); + }) + + it('successfully initialize but script is already exist', function() { + const linkback = { l: true }; + + expect(subModuleObj.init(configWithParams)).to.be.true; + expect(loadExternalScript.called).to.be.false; + }) + }); + + describe('initialize without expected params', function() { + afterEach(function() { + storage.setCookie(A1_SEG_KEY, '', 0); + }) + + it('successfully initialize when publisher side segment is exist in cookie', function() { + storage.setCookie(A1_SEG_KEY, 'test'); + expect(subModuleObj.init(configWithoutParams)).to.be.true; + expect(getStorageData(A1_SEG_KEY)).to.not.equal(''); + }) + it('fails initalize publisher sied segment is not exist', function() { + expect(subModuleObj.init(configWithoutParams)).to.be.false; + expect(getStorageData(A1_SEG_KEY)).to.equal(''); + }) + }) + }); + + describe('alterBidRequests', function() { + const callback = sinon.stub(); + + before(function() { + storage.setCookie(A1_SEG_KEY, 'test'); + storage.setDataInLocalStorage(A1_AUD_KEY, 'tester'); + }) + after(function() { + storage.setCookie(A1_SEG_KEY, '', 0); + storage.removeDataFromLocalStorage(A1_AUD_KEY); + }) + + it('alterBidRequests', function() { + subModuleObj.getBidRequestData(reqBidsConfigObj, callback); + expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.include(a1TestOrtbObj); + expect(callback.calledOnce).to.be.true; + }) + }); +}) diff --git a/test/spec/modules/aaxBlockmeter_spec.js b/test/spec/modules/aaxBlockmeter_spec.js new file mode 100644 index 00000000000..f9704361976 --- /dev/null +++ b/test/spec/modules/aaxBlockmeter_spec.js @@ -0,0 +1,58 @@ +import {aaxBlockmeterRtdModule} from '../../../modules/aaxBlockmeterRtdProvider.js'; +import * as sinon from 'sinon'; +import {assert} from 'chai'; + +let sandbox; +let getTargetingDataSpy; + +const config = { + dataProviders: [{ + 'name': 'aaxBlockmeter', + 'params': { + 'pub': 'publisher_id', + } + }] +}; + +describe('aaxBlockmeter realtime module', function () { + beforeEach(function () { + sandbox = sinon.sandbox.create(); + window.aax = window.aax || {}; + window.aax.getTargetingData = getTargetingDataSpy = sandbox.spy(); + }); + + afterEach(function () { + sandbox.restore(); + window.aax = {}; + }); + + it('init should return false when config is empty', function () { + assert.equal(aaxBlockmeterRtdModule.init({}), false); + }); + + it('init should return false when config.params id is empty', function () { + assert.equal(aaxBlockmeterRtdModule.init({params: {}}), false); + }); + + it('init should return true when config.params.pub is not string', function () { + assert.equal(aaxBlockmeterRtdModule.init({params: {pub: 12345}}), false); + }); + + it('init should return true when config.params.pub id is passed and is string typed', function () { + assert.equal(aaxBlockmeterRtdModule.init(config.dataProviders[0]), true); + }); + + describe('getTargetingData should work correctly', function () { + it('should return ad unit codes when ad units are present', function () { + const codes = ['code1', 'code2']; + assert.deepEqual(aaxBlockmeterRtdModule.getTargetingData(codes), { + code1: {'atk': 'code1'}, + code2: {'atk': 'code2'}, + }); + }); + + it('should call aax.getTargetingData if loaded', function () { + aaxBlockmeterRtdModule.getTargetingData([], config.dataProviders[0], null); + }); + }); +}); diff --git a/test/spec/modules/acuityAdsBidAdapter_spec.js b/test/spec/modules/acuityAdsBidAdapter_spec.js new file mode 100644 index 00000000000..05c59036ff3 --- /dev/null +++ b/test/spec/modules/acuityAdsBidAdapter_spec.js @@ -0,0 +1,399 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/acuityAdsBidAdapter'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'acuityads' + +describe('AcuityAdsBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://prebid.admanmedia.com/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.admanmedia.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0') + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.admanmedia.com/image?pbjs=1&ccpa_consent=1---&coppa=0') + }); + }); +}); diff --git a/test/spec/modules/adWMGAnalyticsAdapter_spec.js b/test/spec/modules/adWMGAnalyticsAdapter_spec.js index ab8336c7126..1e0da1bb3c8 100644 --- a/test/spec/modules/adWMGAnalyticsAdapter_spec.js +++ b/test/spec/modules/adWMGAnalyticsAdapter_spec.js @@ -1,6 +1,7 @@ import adWMGAnalyticsAdapter from 'modules/adWMGAnalyticsAdapter.js'; import { expect } from 'chai'; import { server } from 'test/mocks/xhr.js'; +import {expectEvents} from '../../helpers/analytics.js'; let adapterManager = require('src/adapterManager').default; let events = require('src/events'); let constants = require('src/constants.json'); @@ -140,14 +141,15 @@ describe('adWMG Analytics', function () { } }); - events.emit(constants.EVENTS.AUCTION_INIT, {timestamp, auctionId, timeout, adUnits}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); - events.emit(constants.EVENTS.NO_BID, {}); - events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgs); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_WON, wonRequest); - sinon.assert.callCount(adWMGAnalyticsAdapter.track, 7); + expectEvents([ + [constants.EVENTS.AUCTION_INIT, {timestamp, auctionId, timeout, adUnits}], + [constants.EVENTS.BID_REQUESTED, {}], + [constants.EVENTS.BID_RESPONSE, bidResponse], + [constants.EVENTS.NO_BID, {}], + [constants.EVENTS.BID_TIMEOUT, bidTimeoutArgs], + [constants.EVENTS.AUCTION_END, {}], + [constants.EVENTS.BID_WON, wonRequest], + ]).to.beTrackedBy(adWMGAnalyticsAdapter.track); }); it('should be two xhr requests', function () { diff --git a/test/spec/modules/adagioAnalyticsAdapter_spec.js b/test/spec/modules/adagioAnalyticsAdapter_spec.js index aee85412104..39fb5d2d068 100644 --- a/test/spec/modules/adagioAnalyticsAdapter_spec.js +++ b/test/spec/modules/adagioAnalyticsAdapter_spec.js @@ -1,12 +1,14 @@ import adagioAnalyticsAdapter from 'modules/adagioAnalyticsAdapter.js'; import { expect } from 'chai'; import * as utils from 'src/utils.js'; +import { getGlobal } from 'src/prebidGlobal.js'; +import { server } from 'test/mocks/xhr.js'; let adapterManager = require('src/adapterManager').default; let events = require('src/events'); let constants = require('src/constants.json'); -describe('adagio analytics adapter', () => { +describe('adagio analytics adapter - adagio.js', () => { let sandbox; let adagioQueuePushSpy; @@ -83,34 +85,27 @@ describe('adagio analytics adapter', () => { timeToRespond: 132, }; - // Step 1: Send bid requested event - events.emit(constants.EVENTS.BID_REQUESTED, bidRequest); + const testEvents = { + [constants.EVENTS.BID_REQUESTED]: bidRequest, + [constants.EVENTS.BID_RESPONSE]: bidResponse, + [constants.EVENTS.AUCTION_END]: {} + }; - // Step 2: Send bid response event - events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + // Step 1-3: Send events + Object.entries(testEvents).forEach(([ev, payload]) => events.emit(ev, payload)); - // Step 3: Send auction end event - events.emit(constants.EVENTS.AUCTION_END, {}); + function eventItem(eventName, args) { + return sinon.match({ + action: 'pb-analytics-event', + ts: sinon.match((val) => val !== undefined), + data: { + eventName, + args + } + }) + } - sandbox.assert.callCount(adagioQueuePushSpy, 3); - - const call0 = adagioQueuePushSpy.getCall(0); - expect(call0.args[0].action).to.equal('pb-analytics-event'); - expect(call0.args[0].ts).to.not.be.undefined; - expect(call0.args[0].data).to.not.be.undefined; - expect(call0.args[0].data).to.deep.equal({eventName: constants.EVENTS.BID_REQUESTED, args: bidRequest}); - - const call1 = adagioQueuePushSpy.getCall(1); - expect(call1.args[0].action).to.equal('pb-analytics-event'); - expect(call1.args[0].ts).to.not.be.undefined; - expect(call1.args[0].data).to.not.be.undefined; - expect(call1.args[0].data).to.deep.equal({eventName: constants.EVENTS.BID_RESPONSE, args: bidResponse}); - - const call2 = adagioQueuePushSpy.getCall(2); - expect(call2.args[0].action).to.equal('pb-analytics-event'); - expect(call2.args[0].ts).to.not.be.undefined; - expect(call2.args[0].data).to.not.be.undefined; - expect(call2.args[0].data).to.deep.equal({eventName: constants.EVENTS.AUCTION_END, args: {}}); + Object.entries(testEvents).forEach(([ev, payload]) => sinon.assert.calledWith(adagioQueuePushSpy, eventItem(ev, payload))); }); }); @@ -181,3 +176,342 @@ describe('adagio analytics adapter', () => { }); }); }); + +const AUCTION_ID = '25c6d7f5-699a-4bfc-87c9-996f915341fa'; + +const BID_ADAGIO = Object.assign({}, BID_ADAGIO, { + bidder: 'adagio', + auctionId: AUCTION_ID, + adUnitCode: '/19968336/header-bid-tag-1', + bidId: '3bd4ebb1c900e2', + partnerImpId: 'partnerImpressionID-2', + adId: 'fake_ad_id_2', + requestId: '3bd4ebb1c900e2', + width: 728, + height: 90, + mediaType: 'banner', + cpm: 1.42, + currency: 'USD', + originalCpm: 1.42, + originalCurrency: 'USD', + dealId: 'the-deal-id', + dealChannel: 'PMP', + mi: 'matched-impression', + seatBidId: 'aaaa-bbbb-cccc-dddd', + adserverTargeting: { + 'hb_bidder': 'another', + 'hb_adid': '3bd4ebb1c900e2', + 'hb_pb': '1.500', + 'hb_size': '728x90', + 'hb_source': 'server' + }, + meta: { + advertiserDomains: ['example.com'] + }, + seatId: '42', +}); + +const BID_ANOTHER = Object.assign({}, BID_ANOTHER, { + bidder: 'another', + auctionId: AUCTION_ID, + adUnitCode: '/19968336/header-bid-tag-1', + bidId: '3bd4ebb1c900e2', + partnerImpId: 'partnerImpressionID-2', + adId: 'fake_ad_id_2', + requestId: '3bd4ebb1c900e2', + width: 728, + height: 90, + mediaType: 'banner', + cpm: 1.71, + currency: 'EUR', + originalCpm: 1.62, + originalCurrency: 'GBP', + dealId: 'the-deal-id', + dealChannel: 'PMP', + mi: 'matched-impression', + seatBidId: 'aaaa-bbbb-cccc-dddd', + adserverTargeting: { + 'hb_bidder': 'another', + 'hb_adid': '3bd4ebb1c900e2', + 'hb_pb': '1.500', + 'hb_size': '728x90', + 'hb_source': 'server' + }, + meta: { + advertiserDomains: ['example.com'] + } +}); + +const PARAMS_ADG = { + organizationId: '1001', + site: 'test-com', + pageviewId: 'a68e6d70-213b-496c-be0a-c468ff387106', + environment: 'desktop', + pagetype: 'article', + placement: 'pave_top' +}; + +const MOCK = { + SET_TARGETING: { + [BID_ADAGIO.adUnitCode]: BID_ADAGIO.adserverTargeting, + [BID_ANOTHER.adUnitCode]: BID_ANOTHER.adserverTargeting + }, + AUCTION_INIT: { + 'auctionId': AUCTION_ID, + 'timestamp': 1519767010567, + 'auctionStatus': 'inProgress', + 'adUnits': [ { + 'code': '/19968336/header-bid-tag-1', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 640, + 480 + ], + [ + 640, + 100 + ] + ] + } + }, + 'sizes': [[640, 480]], + 'bids': [ { + 'bidder': 'another', + 'params': { + 'publisherId': '1001' + }, + }, { + 'bidder': 'adagio', + 'params': { + ...PARAMS_ADG + }, + }, ], + 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014' + }, { + 'code': '/19968336/footer-bid-tag-1', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 640, + 480 + ] + ] + } + }, + 'sizes': [[640, 480]], + 'bids': [ { + 'bidder': 'another', + 'params': { + 'publisherId': '1001' + }, + } ], + 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014' + } ], + 'adUnitCodes': ['/19968336/header-bid-tag-1', '/19968336/footer-bid-tag-1'], + 'bidderRequests': [ { + 'bidderCode': 'another', + 'auctionId': AUCTION_ID, + 'bidderRequestId': '1be65d7958826a', + 'bids': [ { + 'bidder': 'another', + 'params': { + 'publisherId': '1001', + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[640, 480]] + } + }, + 'adUnitCode': '/19968336/header-bid-tag-1', + 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', + 'sizes': [[640, 480]], + 'bidId': '2ecff0db240757', + 'bidderRequestId': '1be65d7958826a', + 'auctionId': AUCTION_ID, + 'src': 'client', + 'bidRequestsCount': 1 + }, { + 'bidder': 'another', + 'params': { + 'publisherId': '1001' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[640, 480]] + } + }, + 'adUnitCode': '/19968336/footer-bid-tag-1', + 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', + 'sizes': [[640, 480]], + 'bidId': '2ecff0db240757', + 'bidderRequestId': '1be65d7958826a', + 'auctionId': AUCTION_ID, + 'src': 'client', + 'bidRequestsCount': 1 + } + ], + 'timeout': 3000, + 'refererInfo': { + 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] + } + }, { + 'bidderCode': 'adagio', + 'auctionId': AUCTION_ID, + 'bidderRequestId': '1be65d7958826a', + 'bids': [ { + 'bidder': 'adagio', + 'params': { + ...PARAMS_ADG, + adagioAuctionId: '6fc53663-bde5-427b-ab63-baa9ed296f47' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[640, 480]] + } + }, + 'adUnitCode': '/19968336/header-bid-tag-1', + 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', + 'sizes': [[640, 480]], + 'bidId': '2ecff0db240757', + 'bidderRequestId': '1be65d7958826a', + 'auctionId': AUCTION_ID, + 'src': 'client', + 'bidRequestsCount': 1 + } + ], + 'timeout': 3000, + 'refererInfo': { + 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] + } + } + ], + 'bidsReceived': [], + 'winningBids': [], + 'timeout': 3000 + }, + BID_RESPONSE: { + adagio: BID_ADAGIO, + another: BID_ANOTHER + }, + BID_WON: { + adagio: Object.assign({}, BID_ADAGIO, { + 'status': 'rendered' + }), + another: Object.assign({}, BID_ANOTHER, { + 'status': 'rendered' + }) + }, + AD_RENDER_SUCCEEDED: { + ad: '
ad
', + adId: 'fake_ad_id_2', + bid: BID_ANOTHER + }, +}; + +describe('adagio analytics adapter', () => { + let sandbox; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + + sandbox.stub(events, 'getEvents').returns([]); + + adapterManager.registerAnalyticsAdapter({ + code: 'adagio', + adapter: adagioAnalyticsAdapter + }); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('track', () => { + beforeEach(() => { + adapterManager.enableAnalytics({ + provider: 'adagio' + }); + }); + + afterEach(() => { + adagioAnalyticsAdapter.disableAnalytics(); + }); + + it('builds and sends auction data', () => { + getGlobal().convertCurrency = (cpm, from, to) => { + const convKeys = { + 'GBP-EUR': 0.7, + 'EUR-GBP': 1.3, + 'USD-EUR': 0.8, + 'EUR-USD': 1.2, + 'USD-GBP': 0.6, + 'GBP-USD': 1.6, + }; + return cpm * (convKeys[`${from}-${to}`] || 1); + }; + + events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.adagio); + events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE.another); + events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON.another); + events.emit(constants.EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED); + + expect(server.requests.length).to.equal(3); + { + const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[0].url); + expect(protocol).to.equal('https'); + expect(hostname).to.equal('c.4dex.io'); + expect(pathname).to.equal('/pba.gif'); + expect(search.v).to.equal('1'); + expect(search.pbjsv).to.equal('$prebid.version$'); + expect(search.auct_id).to.equal('6fc53663-bde5-427b-ab63-baa9ed296f47'); + expect(search.adu_code).to.equal('/19968336/header-bid-tag-1'); + expect(search.org_id).to.equal('1001'); + expect(search.site).to.equal('test-com'); + expect(search.pv_id).to.equal('a68e6d70-213b-496c-be0a-c468ff387106'); + expect(search.url_dmn).to.equal(window.location.hostname); + expect(search.dvc).to.equal('desktop'); + expect(search.pgtyp).to.equal('article'); + expect(search.plcmt).to.equal('pave_top'); + expect(search.mts).to.equal('ban'); + expect(search.ban_szs).to.equal('640x100,640x480'); + expect(search.bdrs).to.equal('adagio,another'); + expect(search.adg_mts).to.equal('ban'); + } + + { + const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[1].url); + expect(protocol).to.equal('https'); + expect(hostname).to.equal('c.4dex.io'); + expect(pathname).to.equal('/pba.gif'); + expect(search.v).to.equal('2'); + expect(search.auct_id).to.equal('6fc53663-bde5-427b-ab63-baa9ed296f47'); + expect(search.adu_code).to.equal('/19968336/header-bid-tag-1'); + expect(search.adg_sid).to.equal('42'); + expect(search.win_bdr).to.equal('another'); + expect(search.win_mt).to.equal('ban'); + expect(search.win_ban_sz).to.equal('728x90'); + expect(search.win_cpm).to.equal('1.71'); + expect(search.cur).to.equal('EUR'); + expect(search.cur_rate).to.equal('1.2'); + expect(search.og_cpm).to.equal('1.62'); + expect(search.og_cur).to.equal('GBP'); + expect(search.og_cur_rate).to.equal('1.6'); + } + + { + const { protocol, hostname, pathname, search } = utils.parseUrl(server.requests[2].url); + expect(protocol).to.equal('https'); + expect(hostname).to.equal('c.4dex.io'); + expect(pathname).to.equal('/pba.gif'); + expect(search.v).to.equal('3'); + expect(search.auct_id).to.equal('6fc53663-bde5-427b-ab63-baa9ed296f47'); + expect(search.adu_code).to.equal('/19968336/header-bid-tag-1'); + expect(search.rndr).to.equal('1'); + } + }); + }); +}); diff --git a/test/spec/modules/adagioBidAdapter_spec.js b/test/spec/modules/adagioBidAdapter_spec.js index 945cd0565a7..1f734a6a7fc 100644 --- a/test/spec/modules/adagioBidAdapter_spec.js +++ b/test/spec/modules/adagioBidAdapter_spec.js @@ -9,15 +9,15 @@ import { spec, ENDPOINT, VERSION, - RENDERER_URL, + BB_RENDERER_URL, GlobalExchange } from '../../../modules/adagioBidAdapter.js'; import { loadExternalScript } from '../../../src/adloader.js'; import * as utils from '../../../src/utils.js'; import { config } from '../../../src/config.js'; import { NATIVE } from '../../../src/mediaTypes.js'; -import * as prebidGlobal from 'src/prebidGlobal.js'; import { executeRenderer } from '../../../src/Renderer.js'; +import { userSync } from '../../../src/userSync.js'; const BidRequestBuilder = function BidRequestBuilder(options) { const defaults = { @@ -76,6 +76,7 @@ describe('Adagio bid adapter', () => { let adagioMock; let utilsMock; let sandbox; + let fakeRenderer; const fixtures = { getElementById(width, height, x, y) { @@ -124,11 +125,18 @@ describe('Adagio bid adapter', () => { adagioMock = sinon.mock(adagio); utilsMock = sinon.mock(utils); + $$PREBID_GLOBAL$$.bidderSettings = { + adagio: { + storageAllowed: true + } + }; + sandbox = sinon.createSandbox(); }); afterEach(() => { window.ADAGIO = undefined; + $$PREBID_GLOBAL$$.bidderSettings = {}; adagioMock.restore(); utilsMock.restore(); @@ -137,33 +145,33 @@ describe('Adagio bid adapter', () => { }); describe('get and set params at adUnit level from global Prebid configuration', function() { - it('should set params get from ortb2 config or bidderSettings. Priority to bidderSetting', function() { + it('should set params get from bid.ortb2', function() { const bid = new BidRequestBuilder().build(); + bid.ortb2 = { + site: { + ext: { + data: { + pagetype: 'abc', + category: ['cat1', 'cat2', 'cat3'] + } + } + } + }; sandbox.stub(config, 'getConfig').callsFake(key => { const config = { adagio: { pagetype: 'article' }, - ortb2: { - site: { - ext: { - data: { - environment: 'desktop', - pagetype: 'abc' - } - } - } - } }; return utils.deepAccess(config, key); }); - setExtraParam(bid, 'environment'); - expect(bid.params.environment).to.equal('desktop'); - setExtraParam(bid, 'pagetype') expect(bid.params.pagetype).to.equal('article'); + + setExtraParam(bid, 'category'); + expect(bid.params.category).to.equal('cat1'); // Only the first value is kept }); it('should use the adUnit param unit if defined', function() { @@ -248,7 +256,6 @@ describe('Adagio bid adapter', () => { describe('buildRequests()', function() { const expectedDataKeys = [ - 'id', 'organizationId', 'secure', 'device', @@ -260,7 +267,9 @@ describe('Adagio bid adapter', () => { 'schain', 'prebidVersion', 'featuresVersion', - 'data' + 'data', + 'usIfr', + 'adgjs', ]; it('groups requests by organizationId', function() { @@ -287,6 +296,7 @@ describe('Adagio bid adapter', () => { sandbox.stub(adagio, 'getDevice').returns({ a: 'a' }); sandbox.stub(adagio, 'getSite').returns({ domain: 'adagio.io', 'page': 'https://adagio.io/hb' }); sandbox.stub(adagio, 'getPageviewId').returns('1234-567'); + sandbox.stub(utils, 'generateUUID').returns('blabla'); const bid01 = new BidRequestBuilder().withParams().build(); const bidderRequest = new BidderRequestBuilder().build(); @@ -300,6 +310,33 @@ describe('Adagio bid adapter', () => { expect(requests[0].data).to.have.all.keys(expectedDataKeys); }); + it('should use a custom generated auctionId and remove transactionId', function() { + const expectedAuctionId = '373bcda7-9794-4f1c-be2c-0d223d11d579' + sandbox.stub(utils, 'generateUUID').returns(expectedAuctionId); + + const bid01 = new BidRequestBuilder().withParams().build(); + const bidderRequest = new BidderRequestBuilder().build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + expect(requests[0].data.adUnits[0].auctionId).eq(expectedAuctionId); + expect(requests[0].data.adUnits[0].transactionId).to.not.exist; + }); + + it('should enrich prebid bid requests params', function() { + const expectedAuctionId = '373bcda7-9794-4f1c-be2c-0d223d11d579' + const expectedPageviewId = '56befc26-8cf0-472d-b105-73896df8eb89'; + sandbox.stub(utils, 'generateUUID').returns(expectedAuctionId); + sandbox.stub(adagio, 'getPageviewId').returns(expectedPageviewId); + + const bid01 = new BidRequestBuilder().withParams().build(); + const bidderRequest = new BidderRequestBuilder().build(); + + spec.buildRequests([bid01], bidderRequest); + + expect(bid01.params.adagioAuctionId).eq(expectedAuctionId); + expect(bid01.params.pageviewId).eq(expectedPageviewId); + }); + it('should enqueue computed features for collect usage', function() { sandbox.stub(Date, 'now').returns(12345); @@ -339,6 +376,76 @@ describe('Adagio bid adapter', () => { expect(requests[0].data.adUnits[0].features.url).to.not.exist; }); + it('should force split keyword param into a string', function() { + const bid01 = new BidRequestBuilder().withParams({ + splitKeyword: 1234 + }).build(); + const bid02 = new BidRequestBuilder().withParams({ + splitKeyword: ['1234'] + }).build(); + const bidderRequest = new BidderRequestBuilder().build(); + + const requests = spec.buildRequests([bid01, bid02], bidderRequest); + + expect(requests).to.have.lengthOf(1); + expect(requests[0].data).to.have.all.keys(expectedDataKeys); + expect(requests[0].data.adUnits[0].params).to.exist; + expect(requests[0].data.adUnits[0].params.splitKeyword).to.exist; + expect(requests[0].data.adUnits[0].params.splitKeyword).to.equal('1234'); + expect(requests[0].data.adUnits[1].params.splitKeyword).to.not.exist; + }); + + it('should force key and value from data layer param into a string', function() { + const bid01 = new BidRequestBuilder().withParams({ + dataLayer: { + 1234: 'dlparam', + goodkey: 1234, + objectvalue: { + random: 'result' + }, + arrayvalue: ['1234'] + } + }).build(); + + const bid02 = new BidRequestBuilder().withParams({ + dataLayer: 'a random string' + }).build(); + + const bid03 = new BidRequestBuilder().withParams({ + dataLayer: 1234 + }).build(); + + const bid04 = new BidRequestBuilder().withParams({ + dataLayer: ['an array'] + }).build(); + + const bidderRequest = new BidderRequestBuilder().build(); + + const requests = spec.buildRequests([bid01, bid02, bid03, bid04], bidderRequest); + + expect(requests).to.have.lengthOf(1); + expect(requests[0].data).to.have.all.keys(expectedDataKeys); + expect(requests[0].data.adUnits[0].params).to.exist; + expect(requests[0].data.adUnits[0].params.dataLayer).to.not.exist; + expect(requests[0].data.adUnits[0].params.dl).to.exist; + expect(requests[0].data.adUnits[0].params.dl['1234']).to.equal('dlparam'); + expect(requests[0].data.adUnits[0].params.dl.goodkey).to.equal('1234'); + expect(requests[0].data.adUnits[0].params.dl.objectvalue).to.not.exist; + expect(requests[0].data.adUnits[0].params.dl.arrayvalue).to.not.exist; + + expect(requests[0].data.adUnits[1].params).to.exist; + expect(requests[0].data.adUnits[1].params.dl).to.not.exist; + expect(requests[0].data.adUnits[1].params.dataLayer).to.not.exist; + + expect(requests[0].data.adUnits[2].params).to.exist; + expect(requests[0].data.adUnits[2].params.dl).to.not.exist; + expect(requests[0].data.adUnits[2].params.dataLayer).to.not.exist; + + expect(requests[0].data.adUnits[3].params).to.exist; + expect(requests[0].data.adUnits[3].params.dl).to.not.exist; + expect(requests[0].data.adUnits[3].params.dataLayer).to.not.exist; + }); + describe('With video mediatype', function() { context('Outstream video', function() { it('should logWarn if user does not set renderer.backupOnly: true', function() { @@ -375,8 +482,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({ @@ -386,7 +493,7 @@ describe('Adagio bid adapter', () => { skipafter: 4, minduration: 10, maxduration: 30, - placement: [3], + placement: 3, protocols: [8] } }).build(); @@ -401,7 +508,7 @@ describe('Adagio bid adapter', () => { skipafter: 4, minduration: 10, maxduration: 30, - placement: [3], + placement: 3, protocols: [8], w: 300, h: 250 @@ -555,15 +662,13 @@ describe('Adagio bid adapter', () => { it('should send the Coppa "required" flag set to "1" in the request', function () { const bidderRequest = new BidderRequestBuilder().build(); - sinon.stub(config, 'getConfig') - .withArgs('coppa') - .returns(true); + sandbox.stub(config, 'getConfig') + .withArgs('userSync').returns({ syncEnabled: true }) + .withArgs('coppa').returns(true); const requests = spec.buildRequests([bid01], bidderRequest); expect(requests[0].data.regs.coppa.required).to.equal(1); - - config.getConfig.restore(); }); }); @@ -607,33 +712,116 @@ describe('Adagio bid adapter', () => { }); }); + describe('with GPP', function() { + const bid01 = new BidRequestBuilder().withParams().build(); + + const regsGpp = 'regs_gpp_consent_string'; + const regsApplicableSections = [2]; + + const ortb2Gpp = 'ortb2_gpp_consent_string'; + const ortb2GppSid = [1]; + + context('When GPP in regs module', function() { + it('send gpp and gppSid to the server', function() { + const bidderRequest = new BidderRequestBuilder({ + gppConsent: { + gppString: regsGpp, + applicableSections: regsApplicableSections, + } + }).build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.regs.gpp).to.equal(regsGpp); + expect(requests[0].data.regs.gppSid).to.equal(regsApplicableSections); + }); + }); + + context('When GPP partially defined in regs module', function() { + it('send gpp and gppSid coming from ortb2 to the server', function() { + const bidderRequest = new BidderRequestBuilder({ + gppConsent: { + gppString: regsGpp, + }, + ortb2: { + regs: { + gpp: ortb2Gpp, + gpp_sid: ortb2GppSid, + } + } + }).build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.regs.gpp).to.equal(ortb2Gpp); + expect(requests[0].data.regs.gppSid).to.equal(ortb2GppSid); + }); + + it('send empty gpp and gppSid if no ortb2 fields to the server', function() { + const bidderRequest = new BidderRequestBuilder({ + gppConsent: { + gppString: regsGpp, + } + }).build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.regs.gpp).to.equal(''); + expect(requests[0].data.regs.gppSid).to.be.empty; + }); + }); + + context('When GPP defined in ortb2 module', function() { + it('send gpp and gppSid coming from ortb2 to the server', function() { + const bidderRequest = new BidderRequestBuilder({ + ortb2: { + regs: { + gpp: ortb2Gpp, + gpp_sid: ortb2GppSid, + } + } + }).build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.regs.gpp).to.equal(ortb2Gpp); + expect(requests[0].data.regs.gppSid).to.equal(ortb2GppSid); + }); + }); + + context('When GPP not defined in any modules', function() { + it('send empty gpp and gppSid', function() { + const bidderRequest = new BidderRequestBuilder({}).build(); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.regs.gpp).to.equal(''); + expect(requests[0].data.regs.gppSid).to.be.empty; + }); + }); + }); + describe('with userID modules', function() { - const userId = { - pubcid: '01EAJWWNEPN3CYMM5N8M5VXY22', - unsuported: '666' - }; + const userIdAsEids = [{ + 'source': 'pubcid.org', + 'uids': [ + { + 'atype': 1, + 'id': '01EAJWWNEPN3CYMM5N8M5VXY22' + } + ] + }]; it('should send "user.eids" in the request for Prebid.js supported modules only', function() { const bid01 = new BidRequestBuilder({ - userId + userIdAsEids }).withParams().build(); const bidderRequest = new BidderRequestBuilder().build(); const requests = spec.buildRequests([bid01], bidderRequest); - const expected = [{ - source: 'pubcid.org', - uids: [ - { - atype: 1, - id: '01EAJWWNEPN3CYMM5N8M5VXY22' - } - ] - }]; - - expect(requests[0].data.user.eids).to.have.lengthOf(1); - expect(requests[0].data.user.eids).to.deep.equal(expected); + expect(requests[0].data.user.eids).to.deep.equal(userIdAsEids); }); it('should send an empty "user.eids" array in the request if userId module is unsupported', function() { @@ -677,6 +865,11 @@ describe('Adagio bid adapter', () => { expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 1, mt: 'banner', s: '300x250'}); expect(requests[0].data.adUnits[0].floors[1]).to.deep.equal({f: 1, mt: 'banner', s: '300x600'}); expect(requests[0].data.adUnits[0].floors[2]).to.deep.equal({f: 1, mt: 'video', s: '600x480'}); + + expect(requests[0].data.adUnits[0].mediaTypes.banner.sizes.length).to.equal(2); + expect(requests[0].data.adUnits[0].mediaTypes.banner.bannerSizes[0]).to.deep.equal({size: [300, 250], floor: 1}); + expect(requests[0].data.adUnits[0].mediaTypes.banner.bannerSizes[1]).to.deep.equal({size: [300, 600], floor: 1}); + expect(requests[0].data.adUnits[0].mediaTypes.video.floor).to.equal(1); }); it('should get and set floor by mediatype if no size provided (ex native, video)', function() { @@ -700,6 +893,9 @@ describe('Adagio bid adapter', () => { expect(requests[0].data.adUnits[0].floors.length).to.equal(2); expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 1, mt: 'video'}); expect(requests[0].data.adUnits[0].floors[1]).to.deep.equal({f: 1, mt: 'native'}); + + expect(requests[0].data.adUnits[0].mediaTypes.video.floor).to.equal(1); + expect(requests[0].data.adUnits[0].mediaTypes.native.floor).to.equal(1); }); it('should get and set floor with default value if no floors found', function() { @@ -713,12 +909,53 @@ describe('Adagio bid adapter', () => { }).withParams().build(); const bidderRequest = new BidderRequestBuilder().build(); bid01.getFloor = () => { - return { floor: NaN, currency: 'USD' } + return { floor: NaN, currency: 'USD', mt: 'video' } } const requests = spec.buildRequests([bid01], bidderRequest); expect(requests[0].data.adUnits[0].floors.length).to.equal(1); - expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({f: 0.1, mt: 'video'}); + expect(requests[0].data.adUnits[0].floors[0]).to.deep.equal({mt: 'video'}); + expect(requests[0].data.adUnits[0].mediaTypes.video.floor).to.be.undefined; + }); + }); + + describe('with user-sync iframe enabled', function () { + const bid01 = new BidRequestBuilder().withParams().build(); + + it('should send the UsIfr flag set to "true" in the request', function () { + const bidderRequest = new BidderRequestBuilder().build(); + + sandbox.stub(config, 'getConfig') + .withArgs('userSync') + .returns({ syncEnabled: true }); + + sandbox.stub(userSync, 'canBidderRegisterSync') + .withArgs('iframe', 'adagio') + .returns(true); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.usIfr).to.equal(true); + }); + }); + + describe('with user-sync iframe disabled', function () { + const bid01 = new BidRequestBuilder().withParams().build(); + + it('should send the UsIfr flag set to "false" in the request', function () { + const bidderRequest = new BidderRequestBuilder().build(); + + sandbox.stub(config, 'getConfig') + .withArgs('userSync') + .returns({ syncEnabled: true }); + + sandbox.stub(userSync, 'canBidderRegisterSync') + .withArgs('iframe', 'adagio') + .returns(false); + + const requests = spec.buildRequests([bid01], bidderRequest); + + expect(requests[0].data.usIfr).to.equal(false); }); }); }); @@ -761,8 +998,6 @@ describe('Adagio bid adapter', () => { adUnitElementId: 'gpt-adunit-code', pagetype: 'ARTICLE', category: 'NEWS', - subcategory: 'SPORT', - environment: 'desktop', supportIObs: true }, adUnitCode: 'adunit-code', @@ -810,8 +1045,6 @@ describe('Adagio bid adapter', () => { site: 'SITE-NAME', pagetype: 'ARTICLE', category: 'NEWS', - subcategory: 'SPORT', - environment: 'desktop', aDomain: ['advertiser.com'], mediaType: 'banner', meta: { @@ -845,8 +1078,6 @@ describe('Adagio bid adapter', () => { site: 'SITE-NAME', pagetype: 'ARTICLE', category: 'NEWS', - subcategory: 'SPORT', - environment: 'desktop', aDomain: ['advertiser.com'], mediaType: 'banner', meta: { @@ -887,42 +1118,70 @@ describe('Adagio bid adapter', () => { context: 'outstream', playerSize: [[300, 250]], mimes: ['video/mp4'], - skip: true + skip: 1, + skipafter: 3 }; const serverResponseWithOutstream = utils.deepClone(serverResponse); serverResponseWithOutstream.body.bids[0].vastXml = ''; serverResponseWithOutstream.body.bids[0].mediaType = 'video'; - serverResponseWithOutstream.body.bids[0].outstream = { - bvwUrl: 'https://foo.baz', - impUrl: 'https://foo.bar' - }; - it('should set a renderer in video outstream context', function() { + const defaultRendererUrl = BB_RENDERER_URL.replace('$RENDERER', 'renderer'); + + it('should set related properties for video outstream context', function() { const bidResponse = spec.interpretResponse(serverResponseWithOutstream, bidRequestWithOutstream)[0]; - expect(bidResponse).to.have.any.keys('outstream', 'renderer', 'mediaType'); + expect(bidResponse).to.have.any.keys('renderer', 'mediaType'); expect(bidResponse.renderer).to.be.a('object'); - expect(bidResponse.renderer.url).to.equal(RENDERER_URL); - expect(bidResponse.renderer.config.bvwUrl).to.be.ok; - expect(bidResponse.renderer.config.impUrl).to.be.ok; + expect(bidResponse.renderer.url).to.equal(defaultRendererUrl); expect(bidResponse.renderer.loaded).to.not.be.ok; expect(bidResponse.width).to.equal(300); expect(bidResponse.height).to.equal(250); expect(bidResponse.vastUrl).to.match(/^data:text\/xml;/) }); - it('should execute Adagio outstreamPlayer if defined', function() { - window.ADAGIO.outstreamPlayer = sinon.stub(); + it('should execute Blue Billywig VAST Renderer bootstrap if defined', function() { + window.bluebillywig = { + renderers: [{ bootstrap: sinon.stub(), _id: 'adagio-renderer' }] + }; + const bidResponse = spec.interpretResponse(serverResponseWithOutstream, bidRequestWithOutstream)[0]; executeRenderer(bidResponse.renderer, bidResponse) - sinon.assert.calledOnce(window.ADAGIO.outstreamPlayer); - delete window.ADAGIO.outstreamPlayer; + sinon.assert.calledOnce(window.bluebillywig.renderers[0].bootstrap); + + delete window.bluebillywig; }); - it('should logError if Adagio outstreamPlayer is not defined', function() { + it('Should logError if response does not have a vastXml or vastUrl', function() { + utilsMock.expects('logError').withExactArgs('Adagio: no vastXml or vastUrl on bid').once(); + + const localServerResponseWithOutstream = utils.deepClone(serverResponse); + localServerResponseWithOutstream.body.bids[0].mediaType = 'video'; + + const bidResponse = spec.interpretResponse(localServerResponseWithOutstream, bidRequestWithOutstream)[0]; + executeRenderer(bidResponse.renderer, bidResponse) + + utilsMock.verify(); + }) + + it('should logError if Blue Billywig API is not defined', function() { + utilsMock.expects('logError').withExactArgs('Adagio: no BlueBillywig renderers found!').once(); + const bidResponse = spec.interpretResponse(serverResponseWithOutstream, bidRequestWithOutstream)[0]; executeRenderer(bidResponse.renderer, bidResponse) - utilsMock.expects('logError').withExactArgs('Adagio: Adagio outstream player is not defined').once(); + + utilsMock.verify(); + }); + + it('should logError if correct renderer is not defined', function() { + window.bluebillywig = { renderers: [ { _id: 'adagio-another_renderer' } ] }; + + utilsMock.expects('logError').withExactArgs('Adagio: couldn\'t find a renderer with ID adagio-renderer').once(); + + const bidResponse = spec.interpretResponse(serverResponseWithOutstream, bidRequestWithOutstream)[0]; + executeRenderer(bidResponse.renderer, bidResponse) + + delete window.bluebillywig; + utilsMock.verify(); }); }); @@ -1066,7 +1325,7 @@ describe('Adagio bid adapter', () => { impressionTrackers: [ 'https://eventrack.local/impression' ], - javascriptTrackers: '', + javascriptTrackers: '', clickTrackers: [ 'https://i.am.a.clicktracker.url' ], @@ -1089,6 +1348,19 @@ describe('Adagio bid adapter', () => { expect(r[0].native).ok; expect(r[0].native).to.deep.equal(expected); }); + + it('Should handle multiple javascriptTrackers in one single string', () => { + const serverResponseWithNativeCopy = utils.deepClone(serverResponseWithNative); + serverResponseWithNativeCopy.body.bids[0].admNative.eventtrackers.push( + { + event: 1, + method: 2, + url: 'https://eventrack.local/impression-2' + },) + const r = spec.interpretResponse(serverResponseWithNativeCopy, bidRequestNative); + const expected = '\n'; + expect(r[0].native.javascriptTrackers).to.equal(expected); + }); }); }); @@ -1125,14 +1397,6 @@ describe('Adagio bid adapter', () => { describe('transformBidParams', function() { it('Compute additional params in s2s mode', function() { - GlobalExchange.prepareExchangeData('{}'); - - sandbox.stub(window.top.document, 'getElementById').returns( - fixtures.getElementById() - ); - sandbox.stub(window.top, 'getComputedStyle').returns({ display: 'block' }); - sandbox.stub(utils, 'inIframe').returns(false); - const adUnit = { code: 'adunit-code', params: { @@ -1153,22 +1417,8 @@ describe('Adagio bid adapter', () => { } }).withParams().build(); - const params = spec.transformBidParams({ organizationId: '1000' }, true, adUnit, [{ bidderCode: 'adagio', auctionId: bid01.auctionId, bids: [bid01] }]); - - expect(params.organizationId).to.exist; - expect(params.auctionId).to.exist; - expect(params.playerName).to.exist; - expect(params.playerName).to.equal('other'); - expect(params.features).to.exist; - expect(params.features.page_dimensions).to.exist; - expect(params.features.adunit_position).to.exist; - expect(params.features.dom_loading).to.exist; - expect(params.features.print_number).to.exist; - expect(params.features.user_timestamp).to.exist; - expect(params.placement).to.exist; - expect(params.adUnitElementId).to.exist; - expect(params.site).to.exist; - expect(params.data.session).to.exist; + const params = spec.transformBidParams({ param01: 'test' }, true, adUnit, [{ bidderCode: 'adagio', auctionId: bid01.auctionId, bids: [bid01] }]); + expect(params.param01).eq('test'); }); }); @@ -1229,6 +1479,29 @@ describe('Adagio bid adapter', () => { expect(result.dom_loading).to.be.a('String'); expect(result.user_timestamp).to.be.a('String'); }); + + it('should return `adunit_position` feature when the slot is hidden', function () { + const elem = fixtures.getElementById(); + sandbox.stub(window.top.document, 'getElementById').returns(elem); + sandbox.stub(window.top, 'getComputedStyle').returns({ display: 'none' }); + sandbox.stub(utils, 'inIframe').returns(false); + + const bidRequest = new BidRequestBuilder({ + mediaTypes: { + banner: { sizes: [[300, 250]] }, + }, + }) + .withParams() + .build(); + + const bidderRequest = new BidderRequestBuilder().build(); + + const requests = spec.buildRequests([bidRequest], bidderRequest); + const result = requests[0].data.adUnits[0].features; + + expect(result.adunit_position).to.match(/^[\d]+x[\d]+$/); + expect(elem.style.display).to.equal(null); // set null to reset style + }); }); describe('Adagio features when prebid in Safeframe', function() { @@ -1332,84 +1605,48 @@ describe('Adagio bid adapter', () => { }); }); - describe.skip('optional params auto detection', function() { - it('should auto detect environment', function() { - const getDeviceStub = sandbox.stub(_features, 'getDevice'); - - getDeviceStub.returns(5); - expect(adagio.autoDetectEnvironment()).to.eq('tablet'); - - getDeviceStub.returns(4); - expect(adagio.autoDetectEnvironment()).to.eq('mobile'); - - getDeviceStub.returns(2); - expect(adagio.autoDetectEnvironment()).to.eq('desktop'); - }); - - it('should auto detect adUnitElementId when GPT is used', function() { - sandbox.stub(utils, 'getGptSlotInfoForAdUnitCode').withArgs('banner').returns({divId: 'gpt-banner'}); - expect(adagio.autoDetectAdUnitElementId('banner')).to.eq('gpt-banner'); - }); - }); - - describe.skip('print number handling', function() { - it('should return 1 if no adunit-code found. This means it is the first auction', function() { - sandbox.stub(adagio, 'getPageviewId').returns('abc-def'); - expect(adagio.computePrintNumber('adunit-code')).to.eql(1); - }); - - it('should increment the adunit print number when the adunit-code has already been used for an other auction', function() { - sandbox.stub(adagio, 'getPageviewId').returns('abc-def'); - - window.top.ADAGIO.adUnits['adunit-code'] = { - pageviewId: 'abc-def', - printNumber: 1, - }; - - expect(adagio.computePrintNumber('adunit-code')).to.eql(2); - }); - }); - describe('site information using refererDetection or window.top', function() { it('should returns domain, page and window.referrer in a window.top context', function() { - sandbox.stub(utils, 'getWindowTop').returns({ - location: { - hostname: 'test.io', - href: 'https://test.io/article/a.html' - }, - document: { - referrer: 'https://google.com' - } - }); - const bidderRequest = new BidderRequestBuilder({ refererInfo: { numIframes: 0, reachedTop: true, - referer: 'http://test.io/index.html?pbjs_debug=true' + topmostLocation: 'https://test.io/article/a.html', + page: 'https://test.io/article/a.html', + domain: 'test.io', + ref: 'https://google.com' } }).build(); expect(adagio.getSite(bidderRequest)).to.deep.equal({ domain: 'test.io', page: 'https://test.io/article/a.html', - referrer: 'https://google.com' + referrer: 'https://google.com', + top: true }); }); it('should returns domain and page in a cross-domain w/ top domain reached context', function() { sandbox.stub(utils, 'getWindowTop').throws(); + sandbox.stub(utils, 'getWindowSelf').returns({ + document: { + referrer: 'https://google.com' + } + }); const info = { numIframes: 0, reachedTop: true, - referer: 'http://level.io/', + page: 'http://level.io/', + topmostLocation: 'http://level.io/', stack: [ 'http://level.io/', 'http://example.com/iframe1.html', 'http://example.com/iframe2.html' ], - canonicalUrl: '' + canonicalUrl: '', + domain: 'level.io', + ref: null, }; const bidderRequest = new BidderRequestBuilder({ @@ -1419,60 +1656,38 @@ describe('Adagio bid adapter', () => { expect(adagio.getSite(bidderRequest)).to.deep.equal({ domain: 'level.io', page: 'http://level.io/', - referrer: '' + referrer: 'https://google.com', + top: true }); }); - it('should not return anything in a cross-domain w/o top domain reached and w/o ancestor context', function() { + it('should return info in a cross-domain w/o top domain reached and w/o ancestor context', function() { sandbox.stub(utils, 'getWindowTop').throws(); const info = { numIframes: 2, reachedTop: false, - referer: 'http://example.com/iframe1.html', + topmostLocation: 'http://example.com/iframe1.html', stack: [ null, 'http://example.com/iframe1.html', 'http://example.com/iframe2.html' ], - canonicalUrl: '' + canonicalUrl: '', + page: null, + domain: null, + ref: null }; const bidderRequest = new BidderRequestBuilder({ refererInfo: info }).build(); - expect(adagio.getSite(bidderRequest)).to.deep.equal({ - domain: '', - page: '', - referrer: '' - }); - }); - - it('should return domain only in a cross-domain w/o top domain reached and w/ ancestors context', function() { - sandbox.stub(utils, 'getWindowTop').throws(); - - const info = { - numIframes: 2, - reachedTop: false, - referer: 'http://example.com/iframe1.html', - stack: [ - 'http://mytest.com/', - 'http://example.com/iframe1.html', - 'http://example.com/iframe2.html' - ], - canonicalUrl: '' - }; - - const bidderRequest = new BidderRequestBuilder({ - refererInfo: info - }).build(); - - expect(adagio.getSite(bidderRequest)).to.deep.equal({ - domain: 'mytest.com', - page: '', - referrer: '' - }); + const s = adagio.getSite(bidderRequest) + expect(s.domain).equal('example.com') + expect(s.page).equal('http://example.com/iframe1.html') + expect(s.referrer).match(/^https?:\/\/.+/); + expect(s.top).equal(false) }); }); diff --git a/test/spec/modules/adbookpspBidAdapter_spec.js b/test/spec/modules/adbookpspBidAdapter_spec.js index 3a49f25edb6..3f26cd7749f 100755 --- a/test/spec/modules/adbookpspBidAdapter_spec.js +++ b/test/spec/modules/adbookpspBidAdapter_spec.js @@ -951,13 +951,20 @@ const bidderRequest = { bidderRequestId: '999ccceeee11', timeout: 200, refererInfo: { - referer: 'http://example-domain.com/foo', + page: 'http://mock-page.com', + domain: 'mock-page.com', + ref: 'http://example-domain.com/foo', }, gdprConsent: { gdprApplies: 1, consentString: 'gdprConsentString', }, uspConsent: 'uspConsentString', + ortb2: { + source: { + tid: 'aaccee333311' + } + } }; const bannerBid = { @@ -999,8 +1006,8 @@ const bannerExchangeRequest = { }, }, site: { - domain: location.hostname, - page: location.href, + domain: 'mock-page.com', + page: 'http://mock-page.com', ref: 'http://example-domain.com/foo', }, source: { @@ -1089,8 +1096,8 @@ const videoExchangeRequest = { }, }, site: { - domain: location.hostname, - page: location.href, + domain: 'mock-page.com', + page: 'http://mock-page.com', ref: 'http://example-domain.com/foo', }, source: { @@ -1171,8 +1178,8 @@ const mixedExchangeRequest = { }, }, site: { - domain: location.hostname, - page: location.href, + domain: 'mock-page.com', + page: 'http://mock-page.com', ref: 'http://example-domain.com/foo', }, source: { diff --git a/test/spec/modules/addefendBidAdapter_spec.js b/test/spec/modules/addefendBidAdapter_spec.js index ac01750e98f..b3b6b2d417a 100644 --- a/test/spec/modules/addefendBidAdapter_spec.js +++ b/test/spec/modules/addefendBidAdapter_spec.js @@ -25,7 +25,7 @@ describe('addefendBidAdapter', () => { return spec.buildRequests(buildRequest, { ...bidderRequest || {}, refererInfo: { - referer: 'https://referer.example.com' + page: 'https://referer.example.com' } })[0]; }; diff --git a/test/spec/modules/adfBidAdapter_spec.js b/test/spec/modules/adfBidAdapter_spec.js index ed096e7189d..c1acff522c0 100644 --- a/test/spec/modules/adfBidAdapter_spec.js +++ b/test/spec/modules/adfBidAdapter_spec.js @@ -1,4 +1,5 @@ // jshint esversion: 6, es3: false, node: true +/* eslint-disable no-console */ import { assert } from 'chai'; import { spec } from 'modules/adfBidAdapter.js'; import { config } from 'src/config.js'; @@ -71,18 +72,18 @@ describe('Adf adapter', function () { adxDomain: '10.8.57.207' } }]; - let request = spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }); + let request = spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }); assert.equal(request.method, 'POST'); assert.equal(request.url, 'https://10.8.57.207/adx/openrtb'); - assert.deepEqual(request.options, {contentType: 'application/json'}); + assert.equal(request.options, undefined); assert.ok(request.data); }); describe('user privacy', function () { it('should send GDPR Consent data to adform if gdprApplies', function () { let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; - let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } }; + let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); assert.equal(request.user.ext.consent, bidderRequest.gdprConsent.consentString); @@ -92,7 +93,7 @@ describe('Adf adapter', function () { it('should send gdpr as number', function () { let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; - let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } }; + let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); assert.equal(typeof request.regs.ext.gdpr, 'number'); @@ -101,12 +102,12 @@ describe('Adf adapter', function () { it('should send CCPA Consent data to adform', function () { let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; - let bidderRequest = { uspConsent: '1YA-', refererInfo: { referer: 'page' } }; + let bidderRequest = { uspConsent: '1YA-', refererInfo: { page: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); assert.equal(request.regs.ext.us_privacy, '1YA-'); - bidderRequest = { uspConsent: '1YA-', gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { referer: 'page' } }; + bidderRequest = { uspConsent: '1YA-', gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); assert.equal(request.regs.ext.us_privacy, '1YA-'); @@ -119,13 +120,13 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { siteId: 'siteId' } }]; - let bidderRequest = {gdprConsent: {gdprApplies: false, consentString: 'consentDataString'}, refererInfo: { referer: 'page' }}; + let bidderRequest = { gdprConsent: {gdprApplies: false, consentString: 'consentDataString'}, refererInfo: { page: 'page' } }; let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); assert.equal(request.user.ext.consent, 'consentDataString'); assert.equal(request.regs.ext.gdpr, 0); - bidderRequest = {gdprConsent: {consentString: 'consentDataString'}, refererInfo: { referer: 'page' }}; + bidderRequest = {gdprConsent: {consentString: 'consentDataString'}, refererInfo: { page: 'page' }}; request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); assert.equal(request.user, undefined); @@ -136,7 +137,7 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { siteId: 'siteId' } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.equal(request.user, undefined); assert.equal(request.regs, undefined); @@ -148,7 +149,7 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { test: 1 } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.ok(request.is_debug); assert.equal(request.test, 1); @@ -160,7 +161,7 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { siteId: 'siteId' } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); let data = Object.keys(request); assert.deepEqual(keys, data); @@ -170,14 +171,43 @@ describe('Adf adapter', function () { let validBidRequests = [{ bidId: 'bidId', params: { siteId: 'siteId' }, - transactionId: 'transactionId' }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { + refererInfo: {page: 'page'}, + ortb2: {source: {tid: 'tid'}} + }).data); - assert.equal(request.source.tid, validBidRequests[0].transactionId); + assert.equal(request.source.tid, 'tid'); assert.equal(request.source.fd, 1); }); + it('should not set coppa when coppa is not provided or is set to false', function () { + config.setConfig({ + }); + let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; + let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.regs.coppa, undefined); + + config.setConfig({ + coppa: false + }); + request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.regs.coppa, undefined); + }); + + it('should set coppa to 1 when coppa is provided with value true', function () { + config.setConfig({ + coppa: true + }); + let validBidRequests = [{ bidId: 'bidId', params: { test: 1 } }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); + + assert.equal(request.regs.coppa, 1); + }); + it('should send info about device', function () { config.setConfig({ device: { w: 100, h: 100 } @@ -186,7 +216,7 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { mid: '1000' } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.equal(request.device.ua, navigator.userAgent); assert.equal(request.device.w, 100); @@ -196,13 +226,14 @@ describe('Adf adapter', function () { it('should send app info', function () { config.setConfig({ app: { id: 'appid' }, - ortb2: { app: { name: 'appname' } } }); + const ortb2 = { app: { name: 'appname' } }; let validBidRequests = [{ bidId: 'bidId', - params: { mid: '1000' } + params: { mid: '1000' }, + ortb2 }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' }, ortb2 }).data); assert.equal(request.app.id, 'appid'); assert.equal(request.app.name, 'appname'); @@ -217,23 +248,24 @@ describe('Adf adapter', function () { domain: 'publisher.domain.com' } }, - ortb2: { - site: { - publisher: { - name: 'publisher\'s name' - } + }); + const ortb2 = { + site: { + publisher: { + name: 'publisher\'s name' } } - }); + }; let validBidRequests = [{ bidId: 'bidId', - params: { mid: '1000' } + params: { mid: '1000' }, + ortb2 }]; - let refererInfo = { referer: 'page' }; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo }).data); + let refererInfo = { page: 'page' }; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo, ortb2 }).data); assert.deepEqual(request.site, { - page: refererInfo.referer, + page: refererInfo.page, publisher: { domain: 'publisher.domain.com', name: 'publisher\'s name' @@ -252,7 +284,7 @@ describe('Adf adapter', function () { }) }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.deepEqual(request.user.ext.eids, [ { source: 'adserver.org', uids: [ { id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: { rtiPartner: 'TDID' } } ] }, { source: 'pubcid.org', uids: [ { id: 'pubCommonId_FROM_USER_ID_MODULE', atype: 1 } ] } @@ -262,7 +294,7 @@ describe('Adf adapter', function () { it('should send currency if defined', function () { config.setConfig({ currency: { adServerCurrency: 'EUR' } }); let validBidRequests = [{ params: {} }]; - let refererInfo = { referer: 'page' }; + let refererInfo = { page: 'page' }; let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo }).data); assert.deepEqual(request.cur, [ 'EUR' ]); @@ -280,7 +312,7 @@ describe('Adf adapter', function () { } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.deepEqual(request.source.ext.schain, { validation: 'strict', config: { @@ -295,7 +327,7 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { siteId: 'siteId' } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.equal(request.ext.pt, 'net'); }); @@ -304,7 +336,7 @@ describe('Adf adapter', function () { bidId: 'bidId', params: { priceType: 'net' } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.equal(request.ext.pt, 'net'); }); @@ -319,7 +351,7 @@ describe('Adf adapter', function () { bidId: 'bidId2', params: { siteId: 'siteId' } }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data); assert.equal(request.imp.length, 2); }); @@ -337,7 +369,7 @@ describe('Adf adapter', function () { params: { mid: '1000' }, mediaTypes: {video: {}} }]; - let imps = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; + let imps = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp; for (let i = 0; i < 3; i++) { assert.equal(imps[i].id, i + 1); @@ -348,7 +380,7 @@ describe('Adf adapter', function () { let validBidRequests = [{ bidId: 'bidId', params: {mid: 1000}, mediaTypes: {video: {}} }, { bidId: 'bidId2', params: {mid: 1001}, mediaTypes: {video: {}} }, { bidId: 'bidId3', params: {mid: 1002}, mediaTypes: {video: {}} }]; - let imps = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; + let imps = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp; for (let i = 0; i < 3; i++) { assert.equal(imps[i].tagid, validBidRequests[i].params.mid); } @@ -415,6 +447,52 @@ describe('Adf adapter', function () { }); }); + it('should add correct params to getFloor', function () { + let result; + let mediaTypes = { video: { + playerSize: [ 100, 200 ] + } }; + const expectedFloors = [ 1, 1.3, 0.5 ]; + config.setConfig({ currency: { adServerCurrency: 'DKK' } }); + let validBidRequests = expectedFloors.map(getBidWithFloorTest); + getRequestImps(validBidRequests); + assert.deepEqual(result, { currency: 'DKK', size: '*', mediaType: '*' }); + + mediaTypes = { banner: { + sizes: [ [100, 200], [300, 400] ] + }}; + validBidRequests = expectedFloors.map(getBidWithFloorTest); + getRequestImps(validBidRequests); + + assert.deepEqual(result, { currency: 'DKK', size: '*', mediaType: '*' }); + + mediaTypes = { native: {} }; + validBidRequests = expectedFloors.map(getBidWithFloorTest); + getRequestImps(validBidRequests); + + assert.deepEqual(result, { currency: 'DKK', size: '*', mediaType: '*' }); + + mediaTypes = {}; + validBidRequests = expectedFloors.map(getBidWithFloorTest); + getRequestImps(validBidRequests); + + assert.deepEqual(result, { currency: 'DKK', size: '*', mediaType: '*' }); + + function getBidWithFloorTest(floor) { + return { + params: { mid: 1 }, + mediaTypes: mediaTypes, + getFloor: (args) => { + result = args; + return { + currency: 'DKK', + floor + }; + } + }; + } + }); + function getBidWithFloor(floor) { return { params: { mid: 1 }, @@ -453,6 +531,17 @@ describe('Adf adapter', function () { nativeParams: { title: { required: true, len: 140 } }, + nativeOrtbRequest: { + assets: [ + { + required: 1, + id: 0, + title: { + len: 140 + } + } + ] + }, mediaTypes: { banner: { sizes: [[100, 100], [200, 300]] @@ -461,7 +550,7 @@ describe('Adf adapter', function () { video: {} } }]; - let [ first, second, third ] = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; + let [ first, second, third ] = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp; assert.ok(first.banner); assert.ok(first.video); @@ -488,7 +577,7 @@ describe('Adf adapter', function () { } } }]; - let { banner } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0]; + let { banner } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0]; assert.deepEqual(banner, { format: [ { w: 100, h: 100 }, { w: 200, h: 300 } ] }); @@ -508,7 +597,7 @@ describe('Adf adapter', function () { } } }]; - let { video } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0]; + let { video } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0]; assert.deepEqual(video, { playerSize: [640, 480], context: 'outstream', @@ -519,6 +608,57 @@ describe('Adf adapter', function () { describe('native', function () { describe('assets', function () { + it('should use nativeOrtbRequest instead of nativeParams or mediaTypes', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: { mid: 1000 }, + nativeParams: { + title: { required: true, len: 200 }, + image: { required: true, sizes: [150, 150] }, + icon: { required: false, sizes: [150, 150] }, + body: { required: false, len: 1140 }, + sponsoredBy: { required: true }, + cta: { required: false }, + clickUrl: { required: false }, + ortb: { + ver: '1.2', + assets: [] + } + }, + mediaTypes: { + native: { + title: { required: true, len: 140 }, + image: { required: true, sizes: [150, 50] }, + icon: { required: false, sizes: [50, 50] }, + body: { required: false, len: 140 }, + sponsoredBy: { required: true }, + cta: { required: false }, + clickUrl: { required: false } + } + }, + nativeOrtbRequest: { + assets: [ + { required: 1, title: { len: 200 } }, + { required: 1, img: { type: 3, w: 170, h: 70 } }, + { required: 0, img: { type: 1, w: 70, h: 70 } }, + { required: 0, data: { type: 2, len: 150 } }, + { required: 1, data: { type: 1 } }, + { required: 0, data: { type: 12 } }, + ] + } + }]; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0].native.request.assets; + assert.ok(assets[0].title); + assert.equal(assets[0].title.len, 200); + assert.deepEqual(assets[1].img, { type: 3, w: 170, h: 70 }); + assert.deepEqual(assets[2].img, { type: 1, w: 70, h: 70 }); + assert.deepEqual(assets[3].data, { type: 2, len: 150 }); + assert.deepEqual(assets[4].data, { type: 1 }); + assert.deepEqual(assets[5].data, { type: 12 }); + assert.ok(!assets[6]); + }); + it('should set correct asset id', function () { let validBidRequests = [{ bidId: 'bidId', @@ -527,14 +667,46 @@ describe('Adf adapter', function () { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, body: { len: 140 } + }, + nativeOrtbRequest: { + assets: [ + { + id: 0, + required: 1, + title: { + len: 140 + } + }, + { + id: 1, + required: 0, + img: { + type: 3, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: [ 'image/jpg', 'image/gif' ] + } + }, + { + id: 2, + data: { + type: 2, + len: 140 + } + } + ] } }]; - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0].native.request.assets; assert.equal(assets[0].id, 0); - assert.equal(assets[1].id, 3); - assert.equal(assets[2].id, 4); + assert.equal(assets[1].id, 1); + assert.equal(assets[2].id, 2); }); + it('should add required key if it is necessary', function () { let validBidRequests = [{ bidId: 'bidId', @@ -544,10 +716,17 @@ describe('Adf adapter', function () { image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, body: { len: 140 }, sponsoredBy: { required: true, len: 140 } + }, + nativeOrtbRequest: { + assets: [ + { required: 1, title: { len: 140 } }, + { required: 0, img: { type: 3, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] } }, + { data: { type: 2, len: 140 } }, + { required: 1, data: { type: 1, len: 140 } } + ] } }]; - - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0].native.request.assets; assert.equal(assets[0].required, 1); assert.ok(!assets[1].required); @@ -565,12 +744,21 @@ describe('Adf adapter', function () { icon: { required: false, sizes: [50, 50] }, body: { required: false, len: 140 }, sponsoredBy: { required: true }, - cta: { required: false }, - clickUrl: { required: false } + cta: { required: false } + }, + nativeOrtbRequest: { + assets: [ + { required: 1, title: { len: 140 } }, + { required: 1, img: { type: 3, w: 150, h: 50 } }, + { required: 0, img: { type: 1, w: 50, h: 50 } }, + { required: 0, data: { type: 2, len: 140 } }, + { required: 1, data: { type: 1 } }, + { required: 0, data: { type: 12 } }, + ] } }]; - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0].native.request.assets; assert.ok(assets[0].title); assert.equal(assets[0].title.len, 140); assert.deepEqual(assets[1].img, { type: 3, w: 150, h: 50 }); @@ -581,25 +769,6 @@ describe('Adf adapter', function () { assert.ok(!assets[6]); }); - describe('icon/image sizing', function () { - it('should flatten sizes and utilise first pair', function () { - const validBidRequests = [{ - bidId: 'bidId', - params: { mid: 1000 }, - nativeParams: { - image: { - sizes: [[200, 300], [100, 200]] - }, - } - }]; - - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; - assert.ok(assets[0].img); - assert.equal(assets[0].img.w, 200); - assert.equal(assets[0].img.h, 300); - }); - }); - it('should utilise aspect_ratios', function () { const validBidRequests = [{ bidId: 'bidId', @@ -619,10 +788,16 @@ describe('Adf adapter', function () { ratio_width: 2 }] } + }, + nativeOrtbRequest: { + assets: [ + { img: { type: 3, wmin: 100, ext: { aspectratios: ['1:3'] } } }, + { img: { type: 1, wmin: 10, ext: { aspectratios: ['2:5'] } } } + ] } }]; - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0].native.request.assets; assert.ok(assets[0].img); assert.equal(assets[0].img.wmin, 100); assert.equal(assets[0].img.hmin, 300); @@ -643,10 +818,18 @@ describe('Adf adapter', function () { icon: { aspect_ratios: [] } + }, + nativeOrtbRequest: { + request: { + assets: [ + { img: {} }, + { img: {} } + ] + } } }]; - assert.doesNotThrow(() => spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } })); + assert.doesNotThrow(() => spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })); }); }); @@ -661,20 +844,25 @@ describe('Adf adapter', function () { ratio_width: 1 }] } + }, + nativeOrtbRequest: { + assets: [ + { img: { type: 3, ext: { aspectratios: ['3:1'] } } } + ] } }]; - let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp[0].native.request.assets; assert.ok(assets[0].img); - assert.equal(assets[0].img.wmin, 0); - assert.equal(assets[0].img.hmin, 0); + assert.ok(!assets[0].img.wmin); + assert.ok(!assets[0].img.hmin); assert.ok(!assets[1]); }); }); }); function getRequestImps(validBidRequests) { - return JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp; + return JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data).imp; } }); @@ -689,7 +877,7 @@ describe('Adf adapter', function () { let serverResponse = { body: { seatbid: [{ - bid: [{impid: '1', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}}] + bid: [{impid: '1', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 0, title: {text: 'Asset title text'}}]}}] }, { bid: [{impid: '2', native: {ver: '1.1', link: { url: 'link' }, assets: [{id: 1, data: {value: 'Asset title text'}}]}}] }] @@ -701,19 +889,23 @@ describe('Adf adapter', function () { { bidId: 'bidId1', params: { mid: 1000 }, - nativeParams: { - title: { required: true, len: 140 }, - image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, - body: { len: 140 } + nativeOrtbRequest: { + assets: [ + { id: 0, required: 1, title: { len: 140 } }, + { id: 1, required: 0, img: { type: 3, wmin: 836, hmin: 627, ext: { aspectratios: ['6:5'] } } }, + { id: 2, required: 0, data: { type: 2 } } + ] } }, { bidId: 'bidId2', params: { mid: 1000 }, - nativeParams: { - title: { required: true, len: 140 }, - image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, - body: { len: 140 } + nativeOrtbRequest: { + assets: [ + { id: 0, required: 1, title: { len: 140 } }, + { id: 1, required: 0, img: { type: 3, wmin: 836, hmin: 627, ext: { aspectratios: ['6:5'] } } }, + { id: 2, required: 0, data: { type: 2 } } + ] } } ] @@ -728,11 +920,11 @@ describe('Adf adapter', function () { body: { seatbid: [{ bid: [ - {impid: '1', native: {ver: '1.1', link: { url: 'link1' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}}, + {impid: '1', native: {ver: '1.1', link: { url: 'link1' }, assets: [{id: 0, title: {text: 'Asset title text'}}]}}, {impid: '4', native: {ver: '1.1', link: { url: 'link4' }, assets: [{id: 1, title: {text: 'Asset title text'}}]}} ] }, { - bid: [{impid: '2', native: {ver: '1.1', link: { url: 'link2' }, assets: [{id: 1, data: {value: 'Asset title text'}}]}}] + bid: [{impid: '2', native: {ver: '1.1', link: { url: 'link2' }, assets: [{id: 0, data: {value: 'Asset title text'}}]}}] }] } }; @@ -742,45 +934,53 @@ describe('Adf adapter', function () { { bidId: 'bidId1', params: { mid: 1000 }, - nativeParams: { - title: { required: true, len: 140 }, - image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, - body: { len: 140 } + nativeOrtbRequest: { + assets: [ + { id: 0, required: 1, title: { len: 140 } }, + { id: 1, required: 0, img: { type: 3, wmin: 836, hmin: 627, ext: { aspectratios: ['6:5'] } } }, + { id: 2, required: 0, data: { type: 2 } } + ] } }, { bidId: 'bidId2', params: { mid: 1000 }, - nativeParams: { - title: { required: true, len: 140 }, - image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, - body: { len: 140 } + nativeOrtbRequest: { + assets: [ + { id: 0, required: 1, title: { len: 140 } }, + { id: 1, required: 0, img: { type: 3, wmin: 836, hmin: 627, ext: { aspectratios: ['6:5'] } } }, + { id: 2, required: 0, data: { type: 2 } } + ] } }, { bidId: 'bidId3', params: { mid: 1000 }, - nativeParams: { - title: { required: true, len: 140 }, - image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, - body: { len: 140 } + nativeOrtbRequest: { + assets: [ + { id: 0, required: 1, title: { len: 140 } }, + { id: 1, required: 0, img: { type: 3, wmin: 836, hmin: 627, ext: { aspectratios: ['6:5'] } } }, + { id: 2, required: 0, data: { type: 2 } } + ] } }, { bidId: 'bidId4', params: { mid: 1000 }, - nativeParams: { - title: { required: true, len: 140 }, - image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, - body: { len: 140 } + nativeOrtbRequest: { + assets: [ + { id: 0, required: 1, title: { len: 140 } }, + { id: 1, required: 0, img: { type: 3, wmin: 836, hmin: 627, ext: { aspectratios: ['6:5'] } } }, + { id: 2, required: 0, data: { type: 2 } } + ] } } ] }; bids = spec.interpretResponse(serverResponse, bidRequest).map(bid => { - const { requestId, native: { clickUrl } } = bid; - return [ requestId, clickUrl ]; + const { requestId, native: { ortb: { link: { url } } } } = bid; + return [ requestId, url ]; }); assert.equal(bids.length, 3); @@ -822,6 +1022,34 @@ describe('Adf adapter', function () { { bidId: 'bidId1', params: { mid: 1000 }, + nativeOrtbRequest: { + assets: [ + { + id: 0, + required: 1, + title: { + len: 140 + } + }, { + id: 1, + required: 1, + img: { + type: 3, + wmin: 836, + hmin: 627, + ext: { + aspectratios: ['6:5'] + } + } + }, { + id: 2, + required: 0, + data: { + type: 2 + } + } + ] + }, nativeParams: { title: { required: true, len: 140 }, image: { required: false, wmin: 836, hmin: 627, w: 325, h: 300, mimes: ['image/jpg', 'image/gif'] }, @@ -848,56 +1076,45 @@ describe('Adf adapter', function () { const bid = [ { impid: '1', - price: 93.1231, - crid: '12312312', native: { - assets: [ - { - data: null, - id: 0, - img: null, - required: 0, - title: {text: 'title', len: null}, - video: null - }, { - data: null, - id: 2, - img: {type: null, url: 'test.url.com/Files/58345/308185.jpg?bv=1', w: 30, h: 10}, - required: 0, - title: null, - video: null - }, { - data: null, - id: 3, - img: {type: null, url: 'test.url.com/Files/58345/308200.jpg?bv=1', w: 100, h: 100}, - required: 0, - title: null, - video: null - }, { - data: {type: null, len: null, value: 'body'}, - id: 4, - img: null, - required: 0, - title: null, - video: null - }, { - data: {type: null, len: null, value: 'cta'}, - id: 1, - img: null, - required: 0, - title: null, - video: null - }, { - data: {type: null, len: null, value: 'sponsoredBy'}, - id: 5, - img: null, - required: 0, - title: null, - video: null + ver: '1.1', + assets: [{ + id: 1, + required: 0, + title: { + text: 'FLS Native' + } + }, { + id: 3, + required: 0, + data: { + value: 'Adform' + } + }, { + id: 2, + required: 0, + data: { + value: 'Native banner. WOW.' + } + }, { + id: 4, + required: 0, + data: { + value: 'Oho' } - ], - link: { url: 'clickUrl', clicktrackers: ['clickTracker1', 'clickTracker2'] }, - imptrackers: ['imptrackers url1', 'imptrackers url2'], + }, { + id: 5, + required: 0, + img: { url: 'test.url.com/Files/58345/308185.jpg?bv=1', w: 30, h: 10 } + }, { + id: 0, + required: 0, + img: { url: 'test.url.com/Files/58345/308200.jpg?bv=1', w: 300, h: 300 } + }], + link: { + url: 'clickUrl', clicktrackers: [ 'clickTracker1', 'clickTracker2' ] + }, + imptrackers: ['imptracker url1', 'imptracker url2'], jstracker: 'jstracker' } } @@ -912,24 +1129,66 @@ describe('Adf adapter', function () { }; let bidRequest = { data: {}, - bids: [{ bidId: 'bidId1' }] + bids: [{ + bidId: 'bidId1', + nativeOrtbRequest: { + ver: '1.2', + assets: [{ + id: 0, + required: 1, + img: { + type: 3, + wmin: 200, + hmin: 166, + ext: { + aspectratios: ['6:5'] + } + } + }, { + id: 1, + required: 1, + title: { + len: 150 + } + }, { + id: 2, + required: 0, + data: { + type: 2 + } + }, { + id: 3, + required: 1, + data: { + type: 1 + } + }, { + id: 4, + required: 1, + data: { + type: 12 + } + }, { + id: 5, + required: 0, + img: { + type: 1, + wmin: 10, + hmin: 10, + ext: { + aspectratios: ['1:1'] + } + } + }] + }, + }] }; const result = spec.interpretResponse(serverResponse, bidRequest)[0].native; const native = bid[0].native; const assets = native.assets; - assert.deepEqual({ - clickUrl: native.link.url, - clickTrackers: native.link.clicktrackers, - impressionTrackers: native.imptrackers, - javascriptTrackers: [ native.jstracker ], - title: assets[0].title.text, - icon: {url: assets[1].img.url, width: assets[1].img.w, height: assets[1].img.h}, - image: {url: assets[2].img.url, width: assets[2].img.w, height: assets[2].img.h}, - body: assets[3].data.value, - cta: assets[4].data.value, - sponsoredBy: assets[5].data.value - }, result); + + assert.deepEqual(result, {ortb: native}); }); it('should return empty when there is no bids in response', function () { const serverResponse = { diff --git a/test/spec/modules/adfusionBidAdapter_spec.js b/test/spec/modules/adfusionBidAdapter_spec.js new file mode 100644 index 00000000000..638831c33f3 --- /dev/null +++ b/test/spec/modules/adfusionBidAdapter_spec.js @@ -0,0 +1,97 @@ +import { expect } from 'chai'; +import { spec } from 'modules/adfusionBidAdapter'; +import 'modules/priceFloors.js'; +import { newBidder } from 'src/adapters/bidderFactory'; + +describe('adfusionBidAdapter', function () { + const adapter = newBidder(spec); + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + bidder: 'adfusion', + params: { + accountId: 1234, + }, + adUnitCode: '/adunit-code/test-path', + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + transactionId: 'test-transactionId-1', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when params.accountID is missing', function () { + let localbid = Object.assign({}, bid); + delete localbid.params.accountId; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let bidRequests, bidderRequest; + beforeEach(function () { + bidRequests = [ + { + bidder: 'adfusion', + params: { + accountId: 1234, + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + ], + }, + }, + adUnitCode: '/adunit-code/test-path', + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + transactionId: 'test-transactionId-1', + }, + { + bidder: 'adfusion', + params: { + accountId: 1234, + }, + adUnitCode: 'adunit-code', + mediaTypes: { + video: { + playerSize: [640, 480], + }, + }, + bidId: 'test-bid-id-2', + bidderRequestId: 'test-bid-request-2', + auctionId: 'test-auction-2', + transactionId: 'test-transactionId-2', + }, + ]; + bidderRequest = { refererInfo: {} }; + }); + + it('should return an empty array when no bid requests', function () { + const bidRequest = spec.buildRequests([], bidderRequest); + expect(bidRequest).to.be.an('array'); + expect(bidRequest.length).to.equal(0); + }); + + it('should return a valid bid request object', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request).to.be.an('array'); + expect(request[0].data).to.be.an('object'); + expect(request[0].method).to.equal('POST'); + expect(request[0].url).to.not.equal(''); + expect(request[0].url).to.not.equal(undefined); + expect(request[0].url).to.not.equal(null); + }); + }); +}); diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 030aa448c19..adfd38d22cc 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -101,18 +101,95 @@ describe('AdgenerationAdapter', function () { snowflake: {'id': 'novatiqId', syncResponse: 1} } } + }, + { // bannerWithAdgextCriteoId + bidder: 'adg', + params: { + id: '58278', // banner + }, + adUnitCode: 'adunit-code', + sizes: [[320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', + userId: { + criteoId: 'criteo-id-test-1234567890' + } + }, + { // bannerWithAdgextIds + bidder: 'adg', + params: { + id: '58278', // banner + }, + adUnitCode: 'adunit-code', + sizes: [[320, 100]], + bidId: '2f6ac468a9c15e', + bidderRequestId: '14a9f773e30243', + auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', + transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', + userId: { + id5id: { + ext: { + linkType: 2 + }, + uid: 'id5-id-test-1234567890' + }, + imuid: 'i.KrAH6ZAZTJOnH5S4N2sogA', + uid2: {id: 'AgAAAAVacu1uAxgAxH+HJ8+nWlS2H4uVqr6i+HBDCNREHD8WKsio/x7D8xXFuq1cJycUU86yXfTH9Xe/4C8KkH+7UCiU7uQxhyD7Qxnv251pEs6K8oK+BPLYR+8BLY/sJKesa/koKwx1FHgUzIBum582tSy2Oo+7C6wYUaaV4QcLr/4LPA='}, + }, + ortb2Imp: {ext: {gpid: '/1111/homepage#300x250'}}, + ortb2: { + site: { + domain: 'localhost:9999', + publisher: {'domain': 'localhost:9999'}, + page: 'http://localhost:9999/integrationExamples/gpt/hello_world.html', + ref: 'http://localhost:9999/integrationExamples/gpt/hello_world.html' + }, + device: { + w: 570, + h: 969, + dnt: 0, + ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML,like Gecko)Chrome / 112.0.0.0Safari / 537.36', + language: 'ja', + sua: { + source: 2, + platform: { + brand: 'macOS' + }, + browsers: [ + { + brand: 'Chromium', + version: ['112'] + }, + { + brand: 'Google Chrome', + version: ['112'] + }, + { + brand: 'Not:A-Brand', + version: ['99'] + } + ], + mobile: 0 + } + } + }, + schain: {ver: '1.0', complete: 1, nodes: [{asi: 'indirectseller.com', sid: '00001', hp: 1}]} } ]; const bidderRequest = { refererInfo: { - referer: 'https://example.com' + page: 'https://example.com' } }; const data = { - banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&imark=1&tp=https%3A%2F%2Fexample.com`, - bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&imark=1&tp=https%3A%2F%2Fexample.com`, - native: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&tp=https%3A%2F%2Fexample.com`, - bannerWithHyperId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.3.0&imark=1&tp=https%3A%2F%2Fexample.com&hyper_id=novatiqId`, + banner: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.2&imark=1&tp=https%3A%2F%2Fexample.com`, + bannerUSD: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=300x250%2C320x100¤cy=USD&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.2&imark=1&tp=https%3A%2F%2Fexample.com`, + native: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=1x1¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.2&tp=https%3A%2F%2Fexample.com`, + bannerWithHyperId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.2&imark=1&tp=https%3A%2F%2Fexample.com&hyper_id=novatiqId`, + bannerWithAdgextCriteoId: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.2&adgext_criteo_id=criteo-id-test-1234567890&imark=1&tp=https%3A%2F%2Fexample.com`, + bannerWithAdgextIds: `posall=SSPLOC&id=58278&sdktype=0&hb=true&t=json3&sizes=320x100¤cy=JPY&pbver=${prebid.version}&sdkname=prebidjs&adapterver=1.6.2&adgext_id5_id=id5-id-test-1234567890&adgext_id5_id_link_type=2&adgext_imuid=i.KrAH6ZAZTJOnH5S4N2sogA&adgext_uid2=AgAAAAVacu1uAxgAxH%2BHJ8%2BnWlS2H4uVqr6i%2BHBDCNREHD8WKsio%2Fx7D8xXFuq1cJycUU86yXfTH9Xe%2F4C8KkH%2B7UCiU7uQxhyD7Qxnv251pEs6K8oK%2BBPLYR%2B8BLY%2FsJKesa%2FkoKwx1FHgUzIBum582tSy2Oo%2B7C6wYUaaV4QcLr%2F4LPA%3D&gpid=%2F1111%2Fhomepage%23300x250&uach=%7B%22source%22%3A2%2C%22platform%22%3A%7B%22brand%22%3A%22macOS%22%7D%2C%22browsers%22%3A%5B%7B%22brand%22%3A%22Chromium%22%2C%22version%22%3A%5B%22112%22%5D%7D%2C%7B%22brand%22%3A%22Google%20Chrome%22%2C%22version%22%3A%5B%22112%22%5D%7D%2C%7B%22brand%22%3A%22Not%3AA-Brand%22%2C%22version%22%3A%5B%2299%22%5D%7D%5D%2C%22mobile%22%3A0%7D&schain=%7B%22ver%22%3A%221.0%22%2C%22complete%22%3A1%2C%22nodes%22%3A%5B%7B%22asi%22%3A%22indirectseller.com%22%2C%22sid%22%3A%2200001%22%2C%22hp%22%3A1%7D%5D%7D&imark=1&tp=https%3A%2F%2Fexample.com`, }; it('sends bid request to ENDPOINT via GET', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; @@ -139,16 +216,27 @@ describe('AdgenerationAdapter', function () { it('should attache params to the bannerWithHyperId request', function () { const defaultUA = window.navigator.userAgent; - window.navigator.__defineGetter__('userAgent', function() { + window.navigator.__defineGetter__('userAgent', function () { return 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1'; }); const request = spec.buildRequests(bidRequests, bidderRequest)[2]; - window.navigator.__defineGetter__('userAgent', function() { + window.navigator.__defineGetter__('userAgent', function () { return defaultUA; }); expect(request.data).to.equal(data.bannerWithHyperId); }); + + it('should attache params to the bannerWithAdgextCriteoId request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[3]; + expect(request.data).to.equal(data.bannerWithAdgextCriteoId); + }); + + it('should attache params to the bannerWithAdgextIds request', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[4]; + expect(request.data).to.equal(data.bannerWithAdgextIds); + }); + it('allows setConfig to set bidder currency for JPY', function () { config.setConfig({ currency: { diff --git a/test/spec/modules/adhashBidAdapter_spec.js b/test/spec/modules/adhashBidAdapter_spec.js index 40bf354c4d9..cc643d6d2ab 100644 --- a/test/spec/modules/adhashBidAdapter_spec.js +++ b/test/spec/modules/adhashBidAdapter_spec.js @@ -60,6 +60,12 @@ describe('adhashBidAdapter', function () { bid.params.platformURL = 'https://'; expect(spec.isBidRequestValid(bid)).to.equal(false); }); + + it('should return false when bidderURL is present but not https://', function () { + const bid = { ...validBid }; + bid.params.bidderURL = 'http://example.com/'; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); }); describe('buildRequests', function () { @@ -68,16 +74,21 @@ describe('adhashBidAdapter', function () { publisherId: '0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb' }, sizes: [[300, 250]], - adUnitCode: 'adUnitCode' + adUnitCode: 'adUnitCode', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } }; it('should build the request correctly', function () { const result = spec.buildRequests( [ bidRequest ], - { gdprConsent: { gdprApplies: true, consentString: 'example' }, refererInfo: { referer: 'http://example.com/' } } + { gdprConsent: { gdprApplies: true, consentString: 'example' }, refererInfo: { topmostLocation: 'https://example.com/path.html' } } ); expect(result.length).to.equal(1); expect(result[0].method).to.equal('POST'); - expect(result[0].url).to.equal('https://bidder.adhash.com/rtb?version=1.0&prebid=true&publisher=0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb'); + expect(result[0].url).to.equal('https://bidder.adhash.com/rtb?version=3.6&prebid=true&publisher=0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb'); expect(result[0].bidRequest).to.equal(bidRequest); expect(result[0].data).to.have.property('timezone'); expect(result[0].data).to.have.property('location'); @@ -93,7 +104,7 @@ describe('adhashBidAdapter', function () { const result = spec.buildRequests([ bidRequest ], { gdprConsent: { gdprApplies: true, consentString: 'example' } }); expect(result.length).to.equal(1); expect(result[0].method).to.equal('POST'); - expect(result[0].url).to.equal('https://bidder.adhash.com/rtb?version=1.0&prebid=true&publisher=0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb'); + expect(result[0].url).to.equal('https://bidder.adhash.com/rtb?version=3.6&prebid=true&publisher=0xc3b09b27e9c6ef73957901aa729b9e69e5bbfbfb'); expect(result[0].bidRequest).to.equal(bidRequest); expect(result[0].data).to.have.property('timezone'); expect(result[0].data).to.have.property('location'); @@ -116,6 +127,11 @@ describe('adhashBidAdapter', function () { sizes: [[300, 250]], params: { platformURL: 'https://adhash.com/p/struma/' + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } } } }; @@ -127,9 +143,17 @@ describe('adhashBidAdapter', function () { creatives: [{ costEUR: 1.234 }], advertiserDomains: 'adhash.com', badWords: [ - ['onqjbeq1', 'full', 1], - ['onqjbeq2', 'partial', 1], + ['onqjbeq', 'full', 1], + ['onqjbeqo', 'partial', 1], ['tbbqjbeq', 'full', -1], + ['fgnegf', 'starts', 1], + ['raqf', 'ends', 1], + ['kkk[no]lll', 'regexp', 1], + ['дума', 'full', 1], + ['старт', 'starts', 1], + ['край', 'ends', 1], + ['onq jbeq', 'partial', 1], + ['dhrra qvrf', 'combo', 2], ], maxScore: 2 } @@ -155,42 +179,98 @@ describe('adhashBidAdapter', function () { it('should return empty array when there are bad words (full)', function () { bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { - return 'example text badWord1 badWord1 example badWord1 text' + ' word'.repeat(493); + return 'example text badword badword example badword text' + ' word'.repeat(993); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (full cyrillic)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text дума дума example дума text' + ' текст'.repeat(993); }); expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); }); it('should return empty array when there are bad words (partial)', function () { bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { - return 'example text partialBadWord2 badword2 example BadWord2text' + ' word'.repeat(494); + return 'example text partialbadwordb badwordb example badwordbtext' + ' word'.repeat(994); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (partial, compound phrase)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text partialbad wordb bad wordb example bad wordbtext' + ' word'.repeat(994); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (starts)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text startsWith starts text startsAgain' + ' word'.repeat(994); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (starts cyrillic)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text стартТекст старт text стартТекст' + ' дума'.repeat(994); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (ends)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text wordEnds ends text anotherends' + ' word'.repeat(994); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (ends cyrillic)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text ДругКрай край text ощеединкрай' + ' дума'.repeat(994); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (combo)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'queen of england dies, the queen dies' + ' word'.repeat(993); + }); + expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); + }); + + it('should return empty array when there are bad words (regexp)', function () { + bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { + return 'example text xxxayyy zzxxxAyyyzz text xxxbyyy' + ' word'.repeat(994); }); expect(spec.interpretResponse(serverResponse, request).length).to.equal(0); }); it('should return non-empty array when there are not enough bad words (full)', function () { bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { - return 'example text badWord1 badWord1 example text' + ' word'.repeat(494); + return 'example text badword badword example text' + ' word'.repeat(994); }); expect(spec.interpretResponse(serverResponse, request).length).to.equal(1); }); it('should return non-empty array when there are not enough bad words (partial)', function () { bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { - return 'example text partialBadWord2 example' + ' word'.repeat(496); + return 'example text partialbadwordb example' + ' word'.repeat(996); }); expect(spec.interpretResponse(serverResponse, request).length).to.equal(1); }); it('should return non-empty array when there are no-bad word matches', function () { bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { - return 'example text partialBadWord1 example text' + ' word'.repeat(495); + return 'example text partialbadword example text' + ' word'.repeat(995); }); expect(spec.interpretResponse(serverResponse, request).length).to.equal(1); }); it('should return non-empty array when there are bad words and good words', function () { bodyStub = sinon.stub(window.top.document.body, 'innerText').get(function() { - return 'example text badWord1 badWord1 example badWord1 goodWord goodWord ' + ' word'.repeat(492); + return 'example text badword badword example badword goodWord goodWord ' + ' word'.repeat(992); }); expect(spec.interpretResponse(serverResponse, request).length).to.equal(1); }); @@ -213,5 +293,45 @@ describe('adhashBidAdapter', function () { it('should return empty array when something is not right', function () { expect(spec.interpretResponse(null, request).length).to.equal(0); }); + + it('should interpret the video response correctly', function () { + const result = spec.interpretResponse({ + body: { + creatives: [{ costEUR: 1.234, vastURL: 'https://example.com/vast' }], + advertiserDomains: 'adhash.com' + } + }, { + data: { some: 'data' }, + bidRequest: { + bidId: '12345678901234', + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + params: { + platformURL: 'https://adhash.com/p/struma/' + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [300, 250], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1 + } + } + } + }); + expect(result.length).to.equal(1); + expect(result[0].requestId).to.equal('12345678901234'); + expect(result[0].cpm).to.equal(1.234); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].creativeId).to.equal('adunit-code'); + expect(result[0].netRevenue).to.equal(true); + expect(result[0].currency).to.equal('EUR'); + expect(result[0].ttl).to.equal(60); + expect(result[0].meta.advertiserDomains).to.eql(['adhash.com']); + expect(result[0].vastUrl).to.equal('https://example.com/vast'); + }); }); }); diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js index 3fe0a62b2a0..a2e2691c8ba 100644 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ b/test/spec/modules/adheseBidAdapter_spec.js @@ -67,7 +67,7 @@ describe('AdheseAdapter', function () { consentString: 'CONSENT_STRING' }, refererInfo: { - referer: 'http://prebid.org/dev-docs/subjects?_d=1' + page: 'http://prebid.org/dev-docs/subjects?_d=1' } }; diff --git a/test/spec/modules/adkernelAdnBidAdapter_spec.js b/test/spec/modules/adkernelAdnBidAdapter_spec.js index c4ad134711a..cfee5693cf5 100644 --- a/test/spec/modules/adkernelAdnBidAdapter_spec.js +++ b/test/spec/modules/adkernelAdnBidAdapter_spec.js @@ -144,7 +144,7 @@ describe('AdkernelAdn adapter', function () { auctionStart: 1545836987704, timeout: 3000, refererInfo: { - referer: 'https://example.com/index.html', + page: 'https://example.com/index.html', reachedTop: true, numIframes: 0, stack: ['https://example.com/index.html'] @@ -220,7 +220,7 @@ describe('AdkernelAdn adapter', function () { } describe('banner request building', function () { - let [_, tagRequests] = buildRequest([bid1_pub1]); + let [_, tagRequests] = buildRequest([bid1_pub1], {ortb2: {source: {tid: 'mock-tid'}}}); let tagRequest = tagRequests[0]; it('should have request id', function () { @@ -374,7 +374,6 @@ describe('AdkernelAdn adapter', function () { it('should return fully-initialized bid-response', function () { let resp = responses[0]; - expect(resp).to.have.property('bidderCode', 'adkernelAdn'); expect(resp).to.have.property('requestId', '2c5e951baeeadd'); expect(resp).to.have.property('cpm', 5.0); expect(resp).to.have.property('width', 300); @@ -394,7 +393,6 @@ describe('AdkernelAdn adapter', function () { it('should return fully-initialized video bid-response', function () { let resp = responses[2]; - expect(resp).to.have.property('bidderCode', 'adkernelAdn'); expect(resp).to.have.property('requestId', '57d602ad1c9545'); expect(resp).to.have.property('cpm', 10.0); expect(resp).to.have.property('creativeId', '108_158802'); @@ -428,8 +426,7 @@ describe('AdkernelAdn adapter', function () { describe('adapter configuration', () => { it('should have aliases', () => { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.be.equal('engagesimply'); + expect(spec.aliases).to.be.an('array'); }); }); }); diff --git a/test/spec/modules/adkernelBidAdapter_spec.js b/test/spec/modules/adkernelBidAdapter_spec.js index ab1c5501bd9..ac2e3785780 100644 --- a/test/spec/modules/adkernelBidAdapter_spec.js +++ b/test/spec/modules/adkernelBidAdapter_spec.js @@ -3,6 +3,7 @@ import {spec} from 'modules/adkernelBidAdapter'; import * as utils from 'src/utils'; import {NATIVE, BANNER, VIDEO} from 'src/mediaTypes'; import {config} from 'src/config'; +import {parseDomain} from '../../../src/refererDetection.js'; describe('Adkernel adapter', function () { const bid1_zone1 = { @@ -14,8 +15,13 @@ describe('Adkernel adapter', function () { auctionId: 'auc-001', mediaTypes: { banner: { - sizes: [[300, 250], [300, 200]] + sizes: [[300, 250], [300, 200]], + pos: 1 } + }, + ortb2Imp: { + battr: [6, 7, 9], + pos: 2 } }, bid2_zone2 = { bidder: 'adkernel', @@ -94,12 +100,16 @@ describe('Adkernel adapter', function () { params: { zoneId: 1, host: 'rtb.adkernel.com', - video: {api: [1, 2]} }, mediaTypes: { video: { context: 'instream', - playerSize: [[640, 480]] + playerSize: [[640, 480]], + api: [1, 2], + placement: 1, + plcmt: 1, + skip: 1, + pos: 1 } }, adUnitCode: 'ad-unit-1' @@ -253,7 +263,7 @@ describe('Adkernel adapter', function () { }); function buildBidderRequest(url = 'https://example.com/index.html', params = {}) { - return Object.assign({}, params, {refererInfo: {referer: url, reachedTop: true}, timeout: 3000, bidderCode: 'adkernel'}); + return Object.assign({}, params, {refererInfo: {page: url, domain: parseDomain(url), reachedTop: true}, timeout: 3000, bidderCode: 'adkernel'}); } const DEFAULT_BIDDER_REQUEST = buildBidderRequest(); @@ -292,6 +302,7 @@ describe('Adkernel adapter', function () { describe('banner request building', function () { let bidRequest, bidRequests, _; + before(function () { [_, bidRequests] = buildRequest([bid1_zone1]); bidRequest = bidRequests[0]; @@ -336,6 +347,16 @@ describe('Adkernel adapter', function () { expect(bidRequest.device).to.have.property('dnt', 1); }); + it('should copy FPD to imp.banner', function() { + expect(bidRequest.imp[0].banner).to.have.property('battr'); + expect(bidRequest.imp[0].banner.battr).to.be.eql([6, 7, 9]); + }); + + it('should respect mediatypes attributes over FPD', function() { + expect(bidRequest.imp[0].banner).to.have.property('pos'); + expect(bidRequest.imp[0].banner.pos).to.be.eql(1); + }); + it('shouldn\'t contain gdpr nor ccpa information for default request', function () { let [_, bidRequests] = buildRequest([bid1_zone1]); expect(bidRequests[0]).to.not.have.property('regs'); @@ -344,11 +365,16 @@ describe('Adkernel adapter', function () { it('should contain gdpr-related information if consent is configured', function () { let [_, bidRequests] = buildRequest([bid1_zone1], - buildBidderRequest('https://example.com/index.html', - {gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}, uspConsent: '1YNN'})); + buildBidderRequest('https://example.com/index.html', { + gdprConsent: {gdprApplies: true, consentString: 'test-consent-string', vendorData: {}}, + uspConsent: '1YNN', + gppConsent: {gppString: 'DBABMA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA', applicableSections: [2]}} + )); let bidRequest = bidRequests[0]; expect(bidRequest).to.have.property('regs'); expect(bidRequest.regs.ext).to.be.eql({'gdpr': 1, 'us_privacy': '1YNN'}); + expect(bidRequest.regs.gpp).to.be.eql('DBABMA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA'); + expect(bidRequest.regs.gpp_sid).to.be.eql([2]); expect(bidRequest).to.have.property('user'); expect(bidRequest.user.ext).to.be.eql({'consent': 'test-consent-string'}); }); @@ -423,8 +449,13 @@ describe('Adkernel adapter', function () { }); it('should have openrtb video impression parameters', function() { - expect(bidRequests[0].imp[0].video).to.have.property('api'); - expect(bidRequests[0].imp[0].video.api).to.be.eql([1, 2]); + let video = bidRequests[0].imp[0].video; + expect(video).to.have.property('api'); + expect(video.api).to.be.eql([1, 2]); + expect(video.placement).to.be.eql(1); + expect(video.plcmt).to.be.eql(1); + expect(video.skip).to.be.eql(1); + expect(video.pos).to.be.eql(1); }); }); diff --git a/test/spec/modules/adlooxAdServerVideo_spec.js b/test/spec/modules/adlooxAdServerVideo_spec.js index 170982a51bd..58277bc830d 100644 --- a/test/spec/modules/adlooxAdServerVideo_spec.js +++ b/test/spec/modules/adlooxAdServerVideo_spec.js @@ -1,11 +1,11 @@ import adapterManager from 'src/adapterManager.js'; import analyticsAdapter from 'modules/adlooxAnalyticsAdapter.js'; -import { ajax } from 'src/ajax.js'; import { buildVideoUrl } from 'modules/adlooxAdServerVideo.js'; import { expect } from 'chai'; import * as events from 'src/events.js'; import { targeting } from 'src/targeting.js'; import * as utils from 'src/utils.js'; +import {server} from '../../mocks/xhr.js'; const analyticsAdapterName = 'adloox'; @@ -118,6 +118,16 @@ describe('Adloox Ad Server Video', function () { }); describe('buildVideoUrl', function () { + beforeEach(() => { + sinon.stub(URL, 'createObjectURL'); + sinon.stub(URL, 'revokeObjectURL'); + }); + + afterEach(() => { + URL.createObjectURL.restore() + URL.revokeObjectURL.restore() + }); + describe('invalid arguments', function () { it('should require callback', function (done) { const ret = buildVideoUrl(); @@ -189,11 +199,9 @@ describe('Adloox Ad Server Video', function () { }); describe('process VAST', function () { - let server = null; let BID = null; let getWinningBidsStub; beforeEach(function () { - server = sinon.createFakeServer(); BID = utils.deepClone(bid); getWinningBidsStub = sinon.stub(targeting, 'getWinningBids') getWinningBidsStub.withArgs(adUnit.code).returns([ BID ]); @@ -202,8 +210,6 @@ describe('Adloox Ad Server Video', function () { getWinningBidsStub.restore(); getWinningBidsStub = undefined; BID = null; - server.restore(); - server = null; }); it('should return URL unchanged for non-VAST', function (done) { @@ -243,42 +249,16 @@ describe('Adloox Ad Server Video', function () { url: wrapperUrl, bid: BID }; + + URL.createObjectURL.callsFake(() => 'mock-blob-url'); + const ret = buildVideoUrl(options, function (url) { expect(url.substr(0, options.url_vast.length)).is.equal(options.url_vast); - - const match = url.match(/[?&]vast=(blob%3A[^&]+)/); - expect(match).is.not.null; - - const blob = decodeURIComponent(match[1]); - - const xfr = sandbox.useFakeXMLHttpRequest(); - xfr.useFilters = true; - xfr.addFilter(x => true); // there is no network traffic for Blob URLs here - - ajax(blob, { - success: (responseText, q) => { - expect(q.status).is.equal(200); - expect(q.getResponseHeader('content-type')).is.equal(vastHeaders['content-type']); - - clock.runAll(); - - ajax(blob, { - success: (responseText, q) => { - xfr.useFilters = false; // .restore() does not really work - if (q.status == 0) return done(); - done(new Error('Blob should have expired')); - }, - error: (statusText, q) => { - xfr.useFilters = false; - done(); - } - }); - }, - error: (statusText, q) => { - xfr.useFilters = false; - done(new Error(statusText)); - } - }); + expect(url).to.match(/[?&]vast=mock-blob-url/); + sinon.assert.calledWith(URL.createObjectURL, sinon.match((val) => val.type === vastHeaders['content-type'])); + clock.runAll(); + sinon.assert.calledWith(URL.revokeObjectURL, 'mock-blob-url'); + done(); }); expect(ret).is.true; diff --git a/test/spec/modules/adlooxRtdProvider_spec.js b/test/spec/modules/adlooxRtdProvider_spec.js index b576ffb9f3b..0e26ef1afdb 100644 --- a/test/spec/modules/adlooxRtdProvider_spec.js +++ b/test/spec/modules/adlooxRtdProvider_spec.js @@ -1,11 +1,12 @@ import adapterManager from 'src/adapterManager.js'; import analyticsAdapter from 'modules/adlooxAnalyticsAdapter.js'; -import { config as _config } from 'src/config.js'; +import {auctionManager} from 'src/auctionManager.js'; import { expect } from 'chai'; import * as events from 'src/events.js'; import * as prebidGlobal from 'src/prebidGlobal.js'; import { subModuleObj as rtdProvider } from 'modules/adlooxRtdProvider.js'; import * as utils from 'src/utils.js'; +import {server} from '../../mocks/xhr.js'; const analyticsAdapterName = 'adloox'; @@ -75,14 +76,6 @@ describe('Adloox RTD Provider', function () { done(); }); - it('should reject non-string config.params.api_origin', function (done) { - const ret = rtdProvider.init({ params: { api_origin: null } }); - - expect(ret).is.false; - - done(); - }); - it('should reject less than one config.params.imps', function (done) { const ret = rtdProvider.init({ params: { imps: 0 } }); @@ -146,31 +139,34 @@ describe('Adloox RTD Provider', function () { expect(analyticsAdapter.context).is.null; }); - let server = null; - let __config = null, CONFIG = null; - let getConfigStub, setConfigStub; + let CONFIG = null; beforeEach(function () { - server = sinon.createFakeServer(); - __config = {}; CONFIG = utils.deepClone(config); - getConfigStub = sinon.stub(_config, 'getConfig').callsFake(function (path) { - return utils.deepAccess(__config, path); - }); - setConfigStub = sinon.stub(_config, 'setConfig').callsFake(function (obj) { - utils.mergeDeep(__config, obj); - }); }); afterEach(function () { - setConfigStub.restore(); - getConfigStub.restore(); - getConfigStub = setConfigStub = undefined; CONFIG = null; - __config = null; - server.restore(); - server = null; }); it('should fetch segments', function (done) { + const req = { + adUnitCodes: [ adUnit.code ], + ortb2Fragments: { + global: { + site: { + ext: { + data: { + } + } + }, + user: { + ext: { + data: { + } + } + } + } + } + }; const adUnitWithSegments = utils.deepClone(adUnit); const getGlobalStub = sinon.stub(prebidGlobal, 'getGlobal').returns({ adUnits: [ adUnitWithSegments ] @@ -180,10 +176,11 @@ describe('Adloox RTD Provider', function () { expect(ret).is.true; const callback = function () { - expect(__config.ortb2.site.ext.data.adloox_rtd.ok).is.true; - expect(__config.ortb2.site.ext.data.adloox_rtd.nope).is.undefined; - expect(__config.ortb2.user.ext.data.adloox_rtd.unused).is.false; - expect(__config.ortb2.user.ext.data.adloox_rtd.nope).is.undefined; + const ortb2 = req.ortb2Fragments.global; + expect(ortb2.site.ext.data.adloox_rtd.ok).is.true; + expect(ortb2.site.ext.data.adloox_rtd.nope).is.undefined; + expect(ortb2.user.ext.data.adloox_rtd.unused).is.false; + expect(ortb2.user.ext.data.adloox_rtd.nope).is.undefined; expect(adUnitWithSegments.ortb2Imp.ext.data.adloox_rtd.dis.length).is.equal(3); expect(adUnitWithSegments.ortb2Imp.ext.data.adloox_rtd.nope).is.undefined; @@ -191,7 +188,7 @@ describe('Adloox RTD Provider', function () { done(); }; - rtdProvider.getBidRequestData({}, callback, CONFIG, null); + rtdProvider.getBidRequestData(req, callback, CONFIG, null); const request = server.requests[0]; const response = { unused: false, _: [ { d: 77 } ] }; @@ -199,115 +196,28 @@ describe('Adloox RTD Provider', function () { }); it('should set ad server targeting', function (done) { - utils.deepSetValue(__config, 'ortb2.site.ext.data.adloox_rtd.ok', true); - const adUnitWithSegments = utils.deepClone(adUnit); utils.deepSetValue(adUnitWithSegments, 'ortb2Imp.ext.data.adloox_rtd.dis', [ 50, 60 ]); const getGlobalStub = sinon.stub(prebidGlobal, 'getGlobal').returns({ adUnits: [ adUnitWithSegments ] }); - const targetingData = rtdProvider.getTargetingData([ adUnitWithSegments.code ], CONFIG); + const auction = { adUnits: [ adUnitWithSegments ] }; + const getAuctionStub = sinon.stub(auctionManager.index, 'getAuction').returns({ + adUnits: [ adUnitWithSegments ], + getFPD: () => { return { global: { site: { ext: { data: { adloox_rtd: { ok: true } } } } } } } + }); + + const targetingData = rtdProvider.getTargetingData([ adUnitWithSegments.code ], CONFIG, null, auction); expect(Object.keys(targetingData).length).is.equal(1); expect(Object.keys(targetingData[adUnit.code]).length).is.equal(2); expect(targetingData[adUnit.code].adl_ok).is.equal(1); expect(targetingData[adUnit.code].adl_dis.length).is.equal(2); + getAuctionStub.restore(); getGlobalStub.restore(); done(); }); }); - - describe('measure atf', function () { - const adUnitCopy = utils.deepClone(adUnit); - - const ratio = 0.38; - const [ [width, height] ] = utils.getAdUnitSizes(adUnitCopy); - - before(function () { - adapterManager.enableAnalytics({ - provider: analyticsAdapterName, - options: analyticsOptions - }); - expect(analyticsAdapter.context).is.not.null; - }); - - after(function () { - analyticsAdapter.disableAnalytics(); - expect(analyticsAdapter.context).is.null; - }); - - it(`should return ${ratio} for same-origin`, function (done) { - const el = document.createElement('div'); - el.setAttribute('id', adUnitCopy.code); - - const offset = height * ratio; - const elStub = sinon.stub(el, 'getBoundingClientRect').returns({ - top: 0 - (height - offset), - bottom: height - offset, - left: 0, - right: width - }); - - const querySelectorStub = sinon.stub(document, 'querySelector'); - querySelectorStub.withArgs(`#${adUnitCopy.code}`).returns(el); - - rtdProvider.atf(adUnitCopy, function(x) { - expect(x).is.equal(ratio); - - querySelectorStub.restore(); - elStub.restore(); - - done(); - }); - }); - - ('IntersectionObserver' in window ? it : it.skip)(`should return ${ratio} for cross-origin`, function (done) { - const frameElementStub = sinon.stub(window, 'frameElement').value(null); - - const el = document.createElement('div'); - el.setAttribute('id', adUnitCopy.code); - - const elStub = sinon.stub(el, 'getBoundingClientRect').returns({ - top: 0, - bottom: height, - left: 0, - right: width - }); - - const querySelectorStub = sinon.stub(document, 'querySelector'); - querySelectorStub.withArgs(`#${adUnitCopy.code}`).returns(el); - - let intersectionObserverStubFn = null; - const intersectionObserverStub = sinon.stub(window, 'IntersectionObserver').callsFake((fn) => { - intersectionObserverStubFn = fn; - return { - observe: (element) => { - expect(element).is.equal(el); - - intersectionObserverStubFn([{ - target: element, - intersectionRect: { width, height }, - intersectionRatio: ratio - }]); - }, - unobserve: (element) => { - expect(element).is.equal(el); - } - } - }); - - rtdProvider.atf(adUnitCopy, function(x) { - expect(x).is.equal(ratio); - - intersectionObserverStub.restore(); - querySelectorStub.restore(); - elStub.restore(); - frameElementStub.restore(); - - done(); - }); - }); - }); }); diff --git a/test/spec/modules/admanBidAdapter_spec.js b/test/spec/modules/admanBidAdapter_spec.js index 89d140a7f25..a9413860072 100644 --- a/test/spec/modules/admanBidAdapter_spec.js +++ b/test/spec/modules/admanBidAdapter_spec.js @@ -1,8 +1,9 @@ import {expect} from 'chai'; import {spec} from '../../../modules/admanBidAdapter.js'; +import {deepClone} from '../../../src/utils' describe('AdmanAdapter', function () { - let bid = { + let bidBanner = { bidId: '2dd581a2b6281d', bidder: 'adman', bidderRequestId: '145e1d6a7837c9', @@ -32,6 +33,20 @@ describe('AdmanAdapter', function () { ] } }; + + let bidVideo = deepClone({ + ...bidBanner, + params: { + placementId: 0, + traffic: 'video' + }, + mediaTypes: { + video: { + playerSize: [300, 250] + } + } + }); + let bidderRequest = { bidderCode: 'adman', auctionId: 'fffffff-ffff-ffff-ffff-ffffffffffff', @@ -40,25 +55,27 @@ describe('AdmanAdapter', function () { auctionStart: 1472239426000, timeout: 5000, uspConsent: '1YN-', + gdprConsent: 'gdprConsent', refererInfo: { referer: 'http://www.example.com', reachedTop: true, }, - bids: [bid] + bids: [bidBanner, bidVideo] } describe('isBidRequestValid', function () { it('Should return true when placementId can be cast to a number', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; + expect(spec.isBidRequestValid(bidBanner)).to.be.true; }); it('Should return false when placementId is not a number', function () { - bid.params.placementId = 'aaa'; - expect(spec.isBidRequestValid(bid)).to.be.false; + bidBanner.params.placementId = 'aaa'; + expect(spec.isBidRequestValid(bidBanner)).to.be.false; + bidBanner.params.placementId = 0; }); }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid], bidderRequest); + let serverRequest = spec.buildRequests([bidBanner], bidderRequest); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -75,10 +92,11 @@ describe('AdmanAdapter', function () { expect(serverRequest.data.ccpa).to.be.an('string') }) - it('Returns valid data if array of bids is valid', function () { + it('Returns valid BANNER data if array of bids is valid', function () { + serverRequest = spec.buildRequests([bidBanner], bidderRequest); let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); @@ -88,8 +106,11 @@ describe('AdmanAdapter', function () { let placements = data['placements']; for (let i = 0; i < placements.length; i++) { let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'bidFloor'); + expect(placement).to.have.all.keys('placementId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'bidFloor', 'ext'); expect(placement.schain).to.be.an('object') + expect(placement.ext).to.be.an('object') + expect(placement.ext).to.have.key('tid') + expect(placement.ext.tid).to.equal(bidBanner.transactionId); expect(placement.placementId).to.be.a('number'); expect(placement.bidId).to.be.a('string'); expect(placement.traffic).to.be.a('string'); @@ -97,6 +118,35 @@ describe('AdmanAdapter', function () { expect(placement.bidFloor).to.be.an('number'); } }); + + it('Returns valid VIDEO data if array of bids is valid', function () { + serverRequest = spec.buildRequests([bidVideo], bidderRequest); + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + let placements = data['placements']; + for (let i = 0; i < placements.length; i++) { + let placement = placements[i]; + expect(placement).to.have.all.keys('placementId', 'eids', 'bidId', 'traffic', 'schain', 'bidFloor', + 'playerSize', 'minduration', 'maxduration', 'mimes', 'protocols', 'startdelay', 'placement', 'skip', + 'skipafter', 'minbitrate', 'maxbitrate', 'delivery', 'playbackmethod', 'api', 'linearity', 'ext'); + expect(placement.ext).to.be.an('object') + expect(placement.ext).to.have.key('tid') + expect(placement.ext.tid).to.equal(bidBanner.transactionId); + expect(placement.schain).to.be.an('object') + expect(placement.placementId).to.be.a('number'); + expect(placement.bidId).to.be.a('string'); + expect(placement.traffic).to.be.a('string'); + expect(placement.bidFloor).to.be.an('number'); + } + }); + it('Returns empty data if no valid requests are passed', function () { serverRequest = spec.buildRequests([]); let data = serverRequest.data; @@ -105,9 +155,9 @@ describe('AdmanAdapter', function () { }); describe('buildRequests with user ids', function () { - bid.userId = {} - bid.userId.uid2 = { id: 'uid2id123' }; - let serverRequest = spec.buildRequests([bid], bidderRequest); + bidBanner.userId = {} + bidBanner.userId.uid2 = { id: 'uid2id123' }; + let serverRequest = spec.buildRequests([bidBanner], bidderRequest); it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; let placements = data['placements']; @@ -130,31 +180,34 @@ describe('AdmanAdapter', function () { }); describe('interpretResponse', function () { - let resObject = { - body: [ { - requestId: '123', - mediaType: 'banner', - cpm: 0.3, - width: 320, - height: 50, - ad: '

Hello ad

', - ttl: 1000, - creativeId: '123asd', - netRevenue: true, - currency: 'USD', - meta: { - advertiserDomains: ['google.com'], - advertiserId: 1234 - } - } ] - }; - let serverResponses = spec.interpretResponse(resObject); - it('Returns an array of valid server responses if response object is valid', function () { + it('(BANNER) Returns an array of valid server responses if response object is valid', function () { + const resBannerObject = { + body: [ { + requestId: '123', + mediaType: 'banner', + cpm: 0.3, + width: 320, + height: 50, + ad: '

Hello ad

', + ttl: 1000, + creativeId: '123asd', + netRevenue: true, + currency: 'USD', + adomain: ['example.com'], + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + } ] + }; + + const serverResponses = spec.interpretResponse(resBannerObject); + expect(serverResponses).to.be.an('array').that.is.not.empty; for (let i = 0; i < serverResponses.length; i++) { let dataItem = serverResponses[i]; expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', - 'netRevenue', 'currency', 'mediaType', 'meta'); + 'netRevenue', 'currency', 'mediaType', 'meta', 'adomain'); expect(dataItem.requestId).to.be.a('string'); expect(dataItem.cpm).to.be.a('number'); expect(dataItem.width).to.be.a('number'); @@ -167,21 +220,124 @@ describe('AdmanAdapter', function () { expect(dataItem.mediaType).to.be.a('string'); expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); } - it('Returns an empty array if invalid response is passed', function () { - serverResponses = spec.interpretResponse('invalid_response'); - expect(serverResponses).to.be.an('array').that.is.empty; - }); + }); + + it('(VIDEO) Returns an array of valid server responses if response object is valid', function () { + const resVideoObject = { + body: [ { + requestId: '123', + mediaType: 'video', + cpm: 0.3, + width: 320, + height: 50, + vastUrl: 'https://', + ttl: 1000, + creativeId: '123asd', + netRevenue: true, + currency: 'USD', + adomain: ['example.com'], + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + } ] + }; + + const serverResponses = spec.interpretResponse(resVideoObject); + + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType', 'meta', 'adomain'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + expect(dataItem.vastUrl).to.be.a('string'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + } + }); + + it('(NATIVE) Returns an array of valid server responses if response object is valid', function () { + const resNativeObject = { + body: [ { + requestId: '123', + mediaType: 'native', + cpm: 0.3, + width: 320, + height: 50, + native: { + title: 'title', + image: 'image', + impressionTrackers: [ 'https://' ] + }, + ttl: 1000, + creativeId: '123asd', + netRevenue: true, + currency: 'USD', + adomain: ['example.com'], + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + } ] + }; + + const serverResponses = spec.interpretResponse(resNativeObject); + + expect(serverResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < serverResponses.length; i++) { + let dataItem = serverResponses[i]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'native', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType', 'meta', 'adomain'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + expect(dataItem.native).to.be.an('object'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + } + }); + + it('Invalid mediaType in response', function () { + const resBadObject = { + body: [ { + mediaType: 'other', + requestId: '123', + cpm: 0.3, + ttl: 1000, + creativeId: '123asd', + currency: 'USD' + } ] + }; + + const serverResponses = spec.interpretResponse(resBadObject); + + expect(serverResponses).to.be.an('array').that.is.empty; }); }); describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs({}); + const gdprConsent = { consentString: 'consentString', gdprApplies: 1 }; + const consentString = { consentString: 'consentString' } + let userSync = spec.getUserSyncs({}, {}, gdprConsent, consentString); it('Returns valid URL and type', function () { expect(userSync).to.be.an('array').with.lengthOf(1); expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; expect(userSync[0].type).to.be.equal('image'); - expect(userSync[0].url).to.be.equal('https://sync.admanmedia.com/image?pbjs=1&coppa=0'); + expect(userSync[0].url).to.be.equal('https://sync.admanmedia.com/image?pbjs=1&gdpr=0&gdpr_consent=consentString&ccpa_consent=consentString&coppa=0'); }); }); }); diff --git a/test/spec/modules/admaruBidAdapter_spec.js b/test/spec/modules/admaruBidAdapter_spec.js index a45ddae108f..813a4ed8b29 100644 --- a/test/spec/modules/admaruBidAdapter_spec.js +++ b/test/spec/modules/admaruBidAdapter_spec.js @@ -121,4 +121,52 @@ describe('Admaru Adapter', function () { expect(result.length).to.equal(0); }); }); + + describe('getUserSyncs()', () => { + it('should return iframe user sync if iframe sync is enabled', () => { + const syncs = spec.getUserSyncs( + { + pixelEnabled: true, + iframeEnabled: true, + }, + null + ); + + expect(syncs).to.deep.equal([ + { + type: 'iframe', + url: 'https://p2.admaru.net/UserSync/sync', + }, + ]); + }); + + it('should return image syncs if they are enabled and iframe is disabled', () => { + const syncs = spec.getUserSyncs( + { + pixelEnabled: true, + iframeEnabled: false, + }, + null + ); + + expect(syncs).to.deep.equal([ + { + type: 'image', + url: 'https://p2.admaru.net/UserSync/sync', + }, + ]); + }); + + it('should not return user syncs if syncs are disabled', () => { + const syncs = spec.getUserSyncs( + { + pixelEnabled: false, + iframeEnabled: false, + }, + null + ); + + expect(syncs).to.deep.equal([]); + }); + }); }); diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js new file mode 100644 index 00000000000..8c9969e4d46 --- /dev/null +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -0,0 +1,463 @@ +import {expect} from 'chai'; +import {spec, storage} from 'modules/admaticBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {getStorageManager} from 'src/storageManager'; + +const ENDPOINT = 'https://layer.serve.admatic.com.tr/pb'; + +describe('admaticBidAdapter', () => { + const adapter = newBidder(spec); + + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function() { + let bid = { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'adUnitCode': 'adunit-code', + 'mediaType': 'banner', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'creativeId': 'er2ee', + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] } + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function() { + let bid2 = {}; + bid2.params = { + 'someIncorrectParam': 0 + }; + expect(spec.isBidRequestValid(bid2)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('sends bid request to ENDPOINT via POST', function () { + let validRequest = [ { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + }, + 'user': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' + }, + 'blacklist': [], + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost', + 'publisherId': 12321312 + } + }, + 'imp': [ + { + 'size': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 728, + 'h': 90 + } + ], + 'mediatype': {}, + 'type': 'banner', + 'id': '2205da7a81846b', + 'floors': { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'id': '45e86fc7ce7fc93' + } + ], + 'ext': { + 'cur': 'USD', + 'bidder': 'admatic' + } + } ]; + let bidderRequest = { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + }, + 'user': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' + }, + 'blacklist': [], + 'site': { + 'page': 'http://localhost:8888/admatic.html', + 'ref': 'http://localhost:8888', + 'publisher': { + 'name': 'localhost', + 'publisherId': 12321312 + } + }, + 'imp': [ + { + 'size': [ + { + 'w': 300, + 'h': 250 + }, + { + 'w': 728, + 'h': 90 + } + ], + 'id': '2205da7a81846b', + 'mediatype': {}, + 'type': 'banner', + 'floors': { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'id': '45e86fc7ce7fc93' + } + ], + 'ext': { + 'cur': 'USD', + 'bidder': 'admatic' + } + }; + const request = spec.buildRequests(validRequest, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should properly build a banner request with floors', function () { + let bidRequests = [ + { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + } + }, + ]; + let bidderRequest = { + 'bidder': 'admatic', + 'params': { + 'networkId': 10433394, + 'host': 'layer.serve.admatic.com.tr' + }, + 'ortb2Imp': { 'ext': { 'instl': 1 } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [728, 90]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'creativeId': 'er2ee', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [728, 90]] + } + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + request.data.imp[0].floors = { + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + }; + }); + }); + + describe('interpretResponse', function () { + it('should get correct bid responses', function() { + let bids = { body: { + data: [ + { + 'id': 1, + 'creative_id': '374', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'banner', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '
', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 2, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 3, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': 'https://www.admatic.com.tr', + 'iurl': 'https://www.admatic.com.tr' + } + ], + 'queryId': 'cdnbh24rlv0hhkpfpln0', + 'status': true + }}; + + let expectedResponse = [ + { + requestId: 1, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'banner', + netRevenue: true, + ad: '
', + creativeId: '374', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 2, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: '', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 3, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: 'https://www.admatic.com.tr', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' + } + ]; + const request = { + ext: { + 'cur': 'TRY', + 'type': 'admatic' + } + }; + let result = spec.interpretResponse(bids, {data: request}); + expect(result).to.eql(expectedResponse); + }); + + it('handles nobid responses', function () { + let request = { + ext: { + 'cur': 'TRY', + 'type': 'admatic' + } + }; + let bids = { body: { + data: [], + 'queryId': 'cdnbh24rlv0hhkpfpln0', + 'status': true + }}; + + let result = spec.interpretResponse(bids, {data: request}); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/admediaBidAdapter_spec.js b/test/spec/modules/admediaBidAdapter_spec.js new file mode 100644 index 00000000000..a04e288311a --- /dev/null +++ b/test/spec/modules/admediaBidAdapter_spec.js @@ -0,0 +1,130 @@ +import {assert, expect} from 'chai'; +import {spec} from 'modules/admediaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; + +const ENDPOINT_URL = 'https://prebid.admedia.com/bidder/'; + +describe('admediaBidAdapter', function () { + const adapter = newBidder(spec); + describe('isBidRequestValid', function () { + let bid = { + adUnitCode: 'adunit-code', + bidder: 'admedia', + bidId: 'g7ghhs78', + mediaTypes: {banner: {sizes: [[300, 250]]}}, + params: { + placementId: '782332', + aid: '86858', + }, + refererInfo: { + page: 'https://test.com' + } + }; + it('should return true where required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + describe('buildRequests', function () { + let bidRequests = [ + { + adUnitCode: 'adunit-code', + bidder: 'admedia', + bidId: 'g7ghhs78', + mediaTypes: {banner: {sizes: [[300, 250]]}}, + params: { + placementId: '782332', + aid: '86858' + }, + refererInfo: { + page: 'https://test.com' + } + } + ]; + + let bidderRequests = { + refererInfo: { + page: 'https://test.com', + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequests); + it('sends bid request via POST', function () { + expect(request[0].method).to.equal('POST'); + }); + }); + + describe('interpretResponse', function () { + let bidRequest = { + method: 'POST', + url: ENDPOINT_URL, + data: { + 'id': '782332', + 'aid': '86858', + 'tags': [ + { + 'sizes': [ + '300x250' + ], + 'id': '782332', + 'aid': '86858' + } + ], + 'bidId': '2556388472b168', + 'referer': 'https%3A%2F%test.com' + } + }; + let serverResponse = { + body: + { + 'tags': [ + { + 'requestId': '2b8bf2ac497ae', + 'ad': "", + 'width': 300, + 'height': 250, + 'cpm': 0.71, + 'currency': 'USD', + 'ttl': 200, + 'creativeId': 128, + 'netRevenue': true, + 'meta': { + 'advertiserDomains': [ + 'https://www.test.com' + ] + } + } + ] + } + + }; + it('should get the correct bid response', function () { + let expectedResponse = + { + 'tags': [ + { + 'requestId': '2b8bf2ac497ae', + 'ad': "", + 'width': 300, + 'height': 250, + 'cpm': 0.71, + 'currency': 'USD', + 'ttl': 200, + 'creativeId': 128, + 'netRevenue': true, + 'meta': { + 'advertiserDomains': [ + 'https://www.test.com' + ] + } + } + ] + } + let result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.be.an('array').that.is.not.empty; + expect(Object.keys(result[0])).to.have.members( + Object.keys(expectedResponse.tags[0]) + ); + }); + }); +}); diff --git a/test/spec/modules/admixerBidAdapter_spec.js b/test/spec/modules/admixerBidAdapter_spec.js index 6dfde0d0652..8cf433460b7 100644 --- a/test/spec/modules/admixerBidAdapter_spec.js +++ b/test/spec/modules/admixerBidAdapter_spec.js @@ -4,8 +4,10 @@ import {newBidder} from 'src/adapters/bidderFactory.js'; import {config} from '../../../src/config.js'; const BIDDER_CODE = 'admixer'; +const BIDDER_CODE_ADX = 'admixeradx'; const ENDPOINT_URL = 'https://inv-nets.admixer.net/prebid.1.2.aspx'; const ENDPOINT_URL_CUSTOM = 'https://custom.admixer.net/prebid.aspx'; +const ENDPOINT_URL_ADX = 'https://inv-nets.admixer.net/adxprebid.1.2.aspx'; const ZONE_ID = '2eb6bd58-865c-47ce-af7f-a918108c3fd2'; describe('AdmixerAdapter', function () { @@ -16,18 +18,22 @@ describe('AdmixerAdapter', function () { expect(adapter.callBids).to.be.exist.and.to.be.a('function'); }); }); + // inv-nets.admixer.net/adxprebid.1.2.aspx describe('isBidRequestValid', function () { let bid = { - 'bidder': BIDDER_CODE, - 'params': { - 'zone': ZONE_ID + bidder: BIDDER_CODE, + params: { + zone: ZONE_ID, }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', + adUnitCode: 'adunit-code', + sizes: [ + [300, 250], + [300, 600], + ], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', }; it('should return true when required params found', function () { @@ -38,7 +44,7 @@ describe('AdmixerAdapter', function () { let bid = Object.assign({}, bid); delete bid.params; bid.params = { - 'placementId': 0 + placementId: 0, }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -47,22 +53,25 @@ describe('AdmixerAdapter', function () { describe('buildRequests', function () { let validRequest = [ { - 'bidder': BIDDER_CODE, - 'params': { - 'zone': ZONE_ID + bidder: BIDDER_CODE, + params: { + zone: ZONE_ID, }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - } + adUnitCode: 'adunit-code', + sizes: [ + [300, 250], + [300, 600], + ], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + }, ]; let bidderRequest = { bidderCode: BIDDER_CODE, refererInfo: { - referer: 'https://example.com' - } + page: 'https://example.com', + }, }; it('should add referrer and imp to be equal bidRequest', function () { @@ -81,49 +90,161 @@ describe('AdmixerAdapter', function () { it('sends bid request to CUSTOM_ENDPOINT via GET', function () { config.setBidderConfig({ bidders: [BIDDER_CODE], // one or more bidders - config: {[BIDDER_CODE]: {endpoint_url: ENDPOINT_URL_CUSTOM}} + config: { [BIDDER_CODE]: { endpoint_url: ENDPOINT_URL_CUSTOM } }, }); - const request = config.runWithBidder(BIDDER_CODE, () => spec.buildRequests(validRequest, bidderRequest)); + const request = config.runWithBidder(BIDDER_CODE, () => + spec.buildRequests(validRequest, bidderRequest) + ); expect(request.url).to.equal(ENDPOINT_URL_CUSTOM); expect(request.method).to.equal('POST'); }); }); + describe('buildRequests URL check', function () { + const requestParamsFor = (bidder) => ({ + validRequest: [ + { + bidder: bidder, + params: { + zone: ZONE_ID, + }, + adUnitCode: 'adunit-code', + sizes: [ + [300, 250], + [300, 600], + ], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + }, + ], + bidderRequest: { + bidderCode: bidder, + refererInfo: { + page: 'https://example.com', + }, + } + }) + + it('build request for admixer', function () { + const requestParams = requestParamsFor('admixer'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://inv-nets.admixer.net/prebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + it('build request for go2net', function () { + const requestParams = requestParamsFor('go2net'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://ads.go2net.com.ua/prebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + it('build request for adblender', function () { + const requestParams = requestParamsFor('adblender'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://inv-nets.admixer.net/prebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + it('build request for adsyield', function () { + const requestParams = requestParamsFor('adsyield'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://ads.adsyield.com/prebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + it('build request for futureads', function () { + const requestParams = requestParamsFor('futureads'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://ads.futureads.io/prebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + it('build request for smn', function () { + const requestParams = requestParamsFor('smn'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://ads.smn.rs/prebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + it('build request for admixeradx', function () { + const requestParams = requestParamsFor('admixeradx'); + const request = spec.buildRequests(requestParams.validRequest, requestParams.bidderRequest); + expect(request.url).to.equal('https://inv-nets.admixer.net/adxprebid.1.2.aspx'); + expect(request.method).to.equal('POST'); + }); + }); + + describe('checkFloorGetting', function () { + let validRequest = [ + { + bidder: BIDDER_CODE, + params: { + zone: ZONE_ID, + }, + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + }, + ]; + let bidderRequest = { + bidderCode: BIDDER_CODE, + refererInfo: { + page: 'https://example.com', + }, + }; + it('gets floor', function () { + bidderRequest.getFloor = () => { + return { floor: 0.6 }; + }; + const request = spec.buildRequests(validRequest, bidderRequest); + const payload = request.data; + expect(payload.bidFloor).to.deep.equal(0.6); + }); + }); + describe('interpretResponse', function () { let response = { body: { - ads: [{ - 'currency': 'USD', - 'cpm': 6.210000, - 'ad': '
ad
', - 'width': 300, - 'height': 600, - 'creativeId': 'ccca3e5e-0c54-4761-9667-771322fbdffc', - 'ttl': 360, - 'netRevenue': false, - 'requestId': '5e4e763b6bc60b', - 'dealId': 'asd123', - 'meta': {'advertiserId': 123, 'networkId': 123, 'advertiserDomains': ['test.com']} - }] - } + ads: [ + { + currency: 'USD', + cpm: 6.21, + ad: '
ad
', + width: 300, + height: 600, + creativeId: 'ccca3e5e-0c54-4761-9667-771322fbdffc', + ttl: 360, + netRevenue: false, + requestId: '5e4e763b6bc60b', + dealId: 'asd123', + meta: { + advertiserId: 123, + networkId: 123, + advertiserDomains: ['test.com'], + }, + }, + ], + }, }; it('should get correct bid response', function () { const ads = response.body.ads; let expectedResponse = [ { - 'requestId': ads[0].requestId, - 'cpm': ads[0].cpm, - 'creativeId': ads[0].creativeId, - 'width': ads[0].width, - 'height': ads[0].height, - 'ad': ads[0].ad, - 'currency': ads[0].currency, - 'netRevenue': ads[0].netRevenue, - 'ttl': ads[0].ttl, - 'dealId': ads[0].dealId, - 'meta': {'advertiserId': 123, 'networkId': 123, 'advertiserDomains': ['test.com']} - } + requestId: ads[0].requestId, + cpm: ads[0].cpm, + creativeId: ads[0].creativeId, + width: ads[0].width, + height: ads[0].height, + ad: ads[0].ad, + currency: ads[0].currency, + netRevenue: ads[0].netRevenue, + ttl: ads[0].ttl, + dealId: ads[0].dealId, + meta: { + advertiserId: 123, + networkId: 123, + advertiserDomains: ['test.com'], + }, + }, ]; let result = spec.interpretResponse(response); @@ -141,18 +262,16 @@ describe('AdmixerAdapter', function () { describe('getUserSyncs', function () { let imgUrl = 'https://example.com/img1'; let frmUrl = 'https://example.com/frm2'; - let responses = [{ - body: { - cm: { - pixels: [ - imgUrl - ], - iframes: [ - frmUrl - ], - } - } - }]; + let responses = [ + { + body: { + cm: { + pixels: [imgUrl], + iframes: [frmUrl], + }, + }, + }, + ]; it('Returns valid values', function () { let userSyncAll = spec.getUserSyncs({pixelEnabled: true, iframeEnabled: true}, responses); diff --git a/test/spec/modules/admixerIdSystem_spec.js b/test/spec/modules/admixerIdSystem_spec.js index 18107b780db..753b1e3c2d5 100644 --- a/test/spec/modules/admixerIdSystem_spec.js +++ b/test/spec/modules/admixerIdSystem_spec.js @@ -1,9 +1,6 @@ import {admixerIdSubmodule} from 'modules/admixerIdSystem.js'; import * as utils from 'src/utils.js'; import {server} from 'test/mocks/xhr.js'; -import {getStorageManager} from '../../../src/storageManager.js'; - -export const storage = getStorageManager(); const pid = '4D393FAC-B6BB-4E19-8396-0A4813607316'; const getIdParams = {params: {pid: pid}}; diff --git a/test/spec/modules/adnuntiusBidAdapter_spec.js b/test/spec/modules/adnuntiusBidAdapter_spec.js index 25b72216395..6a77c9205ca 100644 --- a/test/spec/modules/adnuntiusBidAdapter_spec.js +++ b/test/spec/modules/adnuntiusBidAdapter_spec.js @@ -1,106 +1,435 @@ // import or require modules necessary for the test, e.g.: -import { expect } from 'chai'; // may prefer 'assert' in place of 'expect' -import { spec } from 'modules/adnuntiusBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import { config } from 'src/config.js'; +import {expect} from 'chai'; // may prefer 'assert' in place of 'expect' +import {misc, spec} from 'modules/adnuntiusBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {config} from 'src/config.js'; import * as utils from 'src/utils.js'; -import { getStorageManager } from 'src/storageManager.js'; +import {getStorageManager} from 'src/storageManager.js'; +import {getGlobal} from '../../../src/prebidGlobal'; -describe('adnuntiusBidAdapter', function () { +describe('adnuntiusBidAdapter', function() { const URL = 'https://ads.adnuntius.delivery/i?tzo='; + const EURO_URL = 'https://europe.delivery.adnuntius.com/i?tzo='; const GVLID = 855; const usi = utils.generateUUID() - const meta = [{ key: 'usi', value: usi }] - const storage = getStorageManager({gvlid: GVLID, moduleName: 'adnuntius'}) - storage.setDataInLocalStorage('adn.metaData', JSON.stringify(meta)) + const meta = [{key: 'usi', value: usi}] - afterEach(function () { + before(() => { + getGlobal().bidderSettings = { + adnuntius: { + storageAllowed: true + } + }; + const storage = getStorageManager({bidderCode: 'adnuntius'}) + storage.setDataInLocalStorage('adn.metaData', JSON.stringify(meta)) + }); + + after(() => { + getGlobal().bidderSettings = {}; + }); + + afterEach(function() { config.resetConfig(); }); + const tzo = new Date().getTimezoneOffset(); - const ENDPOINT_URL = `${URL}${tzo}&format=json&userId=${usi}`; - const ENDPOINT_URL_NOCOOKIE = `${URL}${tzo}&format=json&userId=${usi}&noCookies=true`; - const ENDPOINT_URL_SEGMENTS = `${URL}${tzo}&format=json&segments=segment1,segment2,segment3&userId=${usi}`; - const ENDPOINT_URL_CONSENT = `${URL}${tzo}&format=json&consentString=consentString&userId=${usi}`; + const ENDPOINT_URL_BASE = `${URL}${tzo}&format=json`; + const ENDPOINT_URL = `${ENDPOINT_URL_BASE}&userId=${usi}`; + const ENDPOINT_URL_VIDEO = `${ENDPOINT_URL_BASE}&userId=${usi}&tt=vast4`; + const ENDPOINT_URL_NOCOOKIE = `${ENDPOINT_URL_BASE}&userId=${usi}&noCookies=true`; + const ENDPOINT_URL_SEGMENTS = `${ENDPOINT_URL_BASE}&segments=segment1,segment2,segment3&userId=${usi}`; + const ENDPOINT_URL_CONSENT = `${EURO_URL}${tzo}&format=json&consentString=consentString&userId=${usi}`; const adapter = newBidder(spec); - const bidRequests = [ + const bidderRequests = [ { - bidId: '123', + bidId: 'adn-000000000008b6bc', bidder: 'adnuntius', params: { - auId: '8b6bc', + auId: '000000000008b6bc', network: 'adnuntius', + maxDeals: 1 + }, + mediaTypes: { + banner: { + sizes: [[640, 480], [600, 400]], + } + }, + }, + { + bidId: 'adn-0000000000000551', + bidder: 'adnuntius', + params: { + auId: '0000000000000551', + network: 'adnuntius', + }, + mediaTypes: { + banner: { + sizes: [[1640, 1480], [1600, 1400]], + } }, + } + ] + const videoBidderRequest = [ + { + bidId: 'adn-0000000000000551', + bidder: 'adnuntius', + params: { + auId: '0000000000000551', + network: 'adnuntius', + }, + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, } ] const singleBidRequest = { bid: [ { - bidId: '123', + bidder: 'adnuntius', + bidId: 'adn-0000000000000551', } ] } + const videoBidRequest = { + bid: videoBidderRequest, + bidder: 'adnuntius', + params: { + bidType: 'justsomestuff-error-handling' + } + } + + const deals = [ + { + 'destinationUrlEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fc%2FyQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg%3Fct%3D673%26r%3Dhttp%253A%252F%252Fadnuntius.com', + 'assets': { + 'Image': { + 'cdnId': 'https://cdn.adnuntius.com/cdn/iBgqruUNbaUb2hmD3vws7WTi84jg_WB_-VOF_FeOZ7A.png', + 'width': '640', + 'height': '480' + } + }, + 'text': {}, + 'choices': {}, + 'clickUrl': 'https://ads.adnuntius.delivery/c/yQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg', + 'urls': { + 'destination': 'https://ads.adnuntius.delivery/c/yQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg?ct=673&r=http%3A%2F%2Fadnuntius.com' + }, + 'urlsEsc': { + 'destination': 'https%3A%2F%2Fads.adnuntius.delivery%2Fc%2FyQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg%3Fct%3D673%26r%3Dhttp%253A%252F%252Fadnuntius.com' + }, + 'destinationUrls': { + 'destination': 'https://adnuntius.com' + }, + 'cpm': { + 'amount': 9, + 'currency': 'USD' + }, + 'bid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'grossBid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'netBid': { + 'amount': 0.0081, + 'currency': 'USD' + }, + 'dealId': 'abc123xyz', + 'impressionTrackingUrls': [], + 'impressionTrackingUrlsEsc': [], + 'adId': 'adn-id-1064238860', + 'selectedColumn': '0', + 'selectedColumnPosition': '0', + 'renderedPixel': 'https://ads.adnuntius.delivery/b/yQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg.html', + 'renderedPixelEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fb%2FyQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg.html', + 'visibleUrl': 'https://ads.adnuntius.delivery/s?rt=yQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg', + 'visibleUrlEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3DyQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg', + 'viewUrl': 'https://ads.adnuntius.delivery/v?rt=yQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg', + 'viewUrlEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3DyQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg', + 'rt': 'yQtMUwYBn5P4v72WJMqLW4z7uJOBFXJTfjoRyz0z_wsAAAAQCtjQz9kbGWD4nuZy3q6HaCYxq6Lckz2kThplNb227EJdQ5032jcIGkf-UrPmXCU2EbXVaQ3Ok6_FNLuIDTONJyx6ZZCB10wGqA3OaSe1EqwQp84u1_5iQZAWDk73UYf7_vcIypn7ev-SICZ3qaevb2jYSRqTVZx6AiBZQQGlzlOOrbZU9AU1F-JwTds-YV3qtJHGlxI2peWFIuxFlOYyeX9Kzg', + 'creativeWidth': '640', + 'creativeHeight': '480', + 'creativeId': 's90t0q03pm', + 'lineItemId': 'cr3hnkkxhnkw9ldy', + 'layoutId': 'buyers_network_image_layout_1', + 'layoutName': 'Image', + 'layoutExternalReference': '', + 'html': "\n\n\n \n \n \n\n\n
\n
\"\"/
\n
\n \n\n", + 'renderTemplate': '' + } + ]; + const serverResponse = { body: { 'adUnits': [ { - 'auId': '000000000008b6bc', - 'targetId': '123', - 'html': '

hi!

', + 'auId': '0000000000000551', + 'targetId': 'adn-0000000000000551', + 'html': "\n\n\n \n \n \n\n\n
\n
\"\"/
\n
\n \n\n", 'matchedAdCount': 1, + 'responseId': 'adn-rsp--229633088', + 'deals': deals, + 'ads': [ + { + 'destinationUrlEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fc%2F5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg%3Fct%3D673%26r%3Dhttp%253A%252F%252Fadnuntius.com', + 'assets': { + 'Image': { + 'cdnId': 'https://cdn.adnuntius.com/cdn/iBgqruUNbaUb2hmD3vws7WTi84jg_WB_-VOF_FeOZ7A.png', + 'width': '640', + 'height': '480' + } + }, + 'dealId': 'not-in-deal-array-here', + 'text': {}, + 'choices': {}, + 'clickUrl': 'https://ads.adnuntius.delivery/c/5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg', + 'urls': { + 'destination': 'https://ads.adnuntius.delivery/c/5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg?ct=673&r=http%3A%2F%2Fadnuntius.com' + }, + 'urlsEsc': { + 'destination': 'http%3A%2F%2Fads.adnuntius.delivery%2Fc%2F5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg%3Fct%3D673%26r%3Dhttp%253A%252F%252Fadnuntius.com' + }, + 'destinationUrls': { + 'destination': 'https://adnuntius.com' + }, + 'cpm': { + 'amount': 9, + 'currency': 'USD' + }, + 'bid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'grossBid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'netBid': { + 'amount': 0.0081, + 'currency': 'USD' + }, + 'impressionTrackingUrls': [], + 'impressionTrackingUrlsEsc': [], + 'adId': 'adn-id-1488629603', + 'selectedColumn': '0', + 'selectedColumnPosition': '0', + 'renderedPixel': 'https://ads.adnuntius.delivery/b/5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg.html', + 'renderedPixelEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fb%2F5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg.html', + 'visibleUrl': 'https://ads.adnuntius.delivery/s?rt=5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg', + 'visibleUrlEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3D5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg', + 'viewUrl': 'https://ads.adnuntius.delivery/v?rt=5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg', + 'viewUrlEsc': 'http%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3D5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg', + 'rt': '5Mu-vFVsaf4dWWx8uyZoV7Mz0sPkF1_j9bSupMwX8dMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxqqTYxj2sS0FkMriztxcORshj3zRbT0KsV7XnDXE0F-OsHX7Ok6_FNLuIDTOMJyx6ZZCB10wGqA3OaSe1Eq9D85h8gP1gGsobC0KsAISm_PYNkJ6ve6qZLnB79fX6XHLYSRqTBM8sBCRXQAetnVzeo7AHoQhkFeouS444YA_q4JCTlRI2peWFIuxFlOYyeX9Kzg', + 'creativeWidth': '640', + 'creativeHeight': '480', + 'creativeId': 's90t0q03pm', + 'lineItemId': 'cr3hnkkxhnkw9ldy', + 'layoutId': 'buyers_network_image_layout_1', + 'layoutName': 'Image', + 'layoutExternalReference': '', + 'html': '', + 'renderTemplate': '' + } + ] + }, + { + 'auId': '000000000008b6bc', + 'targetId': 'adn-000000000008b6bc', + 'matchedAdCount': 0, 'responseId': 'adn-rsp-1460129238', + } + ], + 'metaData': { + 'usi': 'from-api-server dude', + 'voidAuIds': '00000000000abcde;00000000000fffff', + 'randomApiKey': 'randomApiValue' + } + } + } + const serverVideoResponse = { + body: { + 'adUnits': [ + { + 'auId': '0000000000000551', + 'targetId': 'adn-0000000000000551', + 'vastXml': '\\n\\n \\n Adnuntius\\n adn-id-500662301\\n \\n \\n \\n \\n 00:00:15\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n', + 'matchedAdCount': 1, + 'responseId': '', + 'deals': [ + { + 'destinationUrlEsc': '', + 'assets': { + 'Video': { + 'cdnId': 'http://localhost:8079/cdn/9urJusYWpjFDLcpOwfejrkWlLP1heM3vWIJjuHk48BQ.mp4', + 'width': '1920', + 'height': '1080' + } + }, + 'text': { + 'thirdQuartile': { + 'content': 'whatevs', + 'length': '7', + 'minLength': '1', + 'maxLength': '64' + }, + 'complete': { + 'content': 'whatevs', + 'length': '7', + 'minLength': '1', + 'maxLength': '64' + }, + 'firstQuartile': { + 'content': 'whatevs', + 'length': '7', + 'minLength': '1', + 'maxLength': '64' + } + }, + 'choices': {}, + 'clickUrl': 'http://localhost:8078/c/7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg', + 'urls': { + 'destinationUrl': 'http://localhost:8078/c/7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg?ct=682&r=http%3A%2F%2Fadnuntius.com' + }, + 'urlsEsc': { + 'destinationUrl': 'http%3A%2F%2Flocalhost%3A8078%2Fc%2F7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg%3Fct%3D682%26r%3Dhttp%253A%252F%252Fadnuntius.com' + }, + 'destinationUrls': { + 'destinationUrl': 'http://adnuntius.com' + }, + 'cpm': { + 'amount': 9, + 'currency': 'USD' + }, + 'bid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'grossBid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'netBid': { + 'amount': 0.0081, + 'currency': 'USD' + }, + 'dealId': 'abc123xyz', + 'impressionTrackingUrls': [], + 'impressionTrackingUrlsEsc': [], + 'adId': 'adn-id-1465065992', + 'selectedColumn': '0', + 'selectedColumnPosition': '0', + 'renderedPixel': 'http://localhost:8078/b/7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg.html', + 'renderedPixelEsc': 'http%3A%2F%2Flocalhost%3A8078%2Fb%2F7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg.html', + 'visibleUrl': 'http://localhost:8078/s?rt=7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg', + 'visibleUrlEsc': 'http%3A%2F%2Flocalhost%3A8078%2Fs%3Frt%3D7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg', + 'viewUrl': 'http://localhost:8078/v?rt=7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg', + 'viewUrlEsc': 'http%3A%2F%2Flocalhost%3A8078%2Fv%3Frt%3D7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg', + 'rt': '7MRhdEcIndSrWxWhFtMVVnDULl8BOwEaV6vi9558AbYAAAAQCtjQz9kbGWD4nuZy3q6HaCYx_6vZlT33ShgzYb616hZZSpoy2jkAHkGrB-XmXyJmEOCSQ0PLk6_FNLuCBzONJyx6ZZCB10wGqA3OaSe1EqMWoJp41f83FcJLX0SpBoT1-qBbx5_8La-ULiAnqaGtMRDYSRqTBZh5DCANFQWnm1fa8rEE9VRgRORwTNxvZFjq5JCSkEQ2peWFIuxFlOYyeX9Kzg', + 'creativeWidth': '640', + 'creativeHeight': '480', + 'creativeId': 'p6sqtvcgxczy258j', + 'lineItemId': 'cr3hnkkxhnkw9ldy', + 'layoutId': 'buyers_networkvast_single_format_layout', + 'layoutName': 'Vast (video upload)', + 'layoutExternalReference': '', + 'vastXml': '\n\n \n Adnuntius\n adn-id-1465065992\n \n \n \n \n 00:00:15\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n', + 'renderTemplate': '\n \n Adnuntius\n {{{adId}}}\n \n \n {{#ifEquals vastVersion "4.0"}}\n {{/ifEquals}}\n \n {{assets.Video.duration}}\n \n \n {{#unless preview}}{{#each impressionTrackingUrls}}\n {{/each}}{{/unless}}{{#if text.firstQuartile.content}}\n {{/if}}\n {{#if text.thirdQuartile.content}}\n {{/if}}{{#if text.complete.content}}\n {{/if}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n' + } + ], 'ads': [ { - 'destinationUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fc%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN%3Fct%3D2501%26r%3Dhttp%253A%252F%252Fgoogle.com', + 'destinationUrlEsc': '', + 'dealId': 'not-in-deal-array', 'assets': { - 'image': { - 'cdnId': 'https://assets.adnuntius.com/oEmZa5uYjxENfA1R692FVn6qIveFpO8wUbpyF2xSOCc.jpg', - 'width': '980', - 'height': '120' + 'Video': { + 'cdnId': 'http://localhost:8079/cdn/9urJusYWpjFDLcpOwfejrkWlLP1heM3vWIJjuHk48BQ.mp4', + 'width': '1920', + 'height': '1080' } }, - 'clickUrl': 'https://delivery.adnuntius.com/c/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', + 'text': { + 'thirdQuartile': { + 'content': 'whatevs', + 'length': '7', + 'minLength': '1', + 'maxLength': '64' + }, + 'complete': { + 'content': 'whatevs', + 'length': '7', + 'minLength': '1', + 'maxLength': '64' + }, + 'firstQuartile': { + 'content': 'whatevs', + 'length': '7', + 'minLength': '1', + 'maxLength': '64' + } + }, + 'choices': {}, + 'clickUrl': 'http://localhost:8078/c/ZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX', 'urls': { - 'destination': 'https://delivery.adnuntius.com/c/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN?ct=2501&r=http%3A%2F%2Fgoogle.com' + 'destinationUrl': 'http://localhost:8078/c/ZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX?ct=682&r=http%3A%2F%2Fadnuntius.com' }, 'urlsEsc': { - 'destination': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fc%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN%3Fct%3D2501%26r%3Dhttp%253A%252F%252Fgoogle.com' + 'destinationUrl': 'http%3A%2F%2Flocalhost%3A8078%2Fc%2FZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX%3Fct%3D682%26r%3Dhttp%253A%252F%252Fadnuntius.com' }, 'destinationUrls': { - 'destination': 'http://google.com' + 'destinationUrl': 'http://adnuntius.com' + }, + 'cpm': { + 'amount': 9, + 'currency': 'USD' + }, + 'bid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'grossBid': { + 'amount': 0.009, + 'currency': 'USD' + }, + 'netBid': { + 'amount': 0.0081, + 'currency': 'USD' }, - 'cpm': { 'amount': 5.0, 'currency': 'NOK' }, - 'bid': { 'amount': 0.005, 'currency': 'NOK' }, - 'cost': { 'amount': 0.005, 'currency': 'NOK' }, 'impressionTrackingUrls': [], 'impressionTrackingUrlsEsc': [], - 'adId': 'adn-id-1347343135', + 'adId': 'adn-id-500662301', 'selectedColumn': '0', 'selectedColumnPosition': '0', - 'renderedPixel': 'https://delivery.adnuntius.com/b/52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN.html', - 'renderedPixelEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fb%2F52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN.html', - 'visibleUrl': 'https://delivery.adnuntius.com/s?rt=52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', - 'visibleUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fs%3Frt%3D52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', - 'viewUrl': 'https://delivery.adnuntius.com/v?rt=52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', - 'viewUrlEsc': 'https%3A%2F%2Fdelivery.adnuntius.com%2Fv%3Frt%3D52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', - 'rt': '52AHNuxCqxB_Y9ZP9ERWkMBPCOha4zuV3aKn5cog5jsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLB4-k_fySWECIOOmHKY6iokgHNFH-U57ew_-1QHlKnFr2NT8y4QK1oU5HxnDLbYPz-GmQ3C2JyxLGpKmIb-P-3bm7HYPEreNjPdhjRG51A8NGuc4huUhns7nEUejHuOjOHE5sV1zfYxCRWRx9wPDN9EUCC7KN', - 'creativeWidth': '980', - 'creativeHeight': '120', - 'creativeId': 'wgkq587vgtpchsx1', - 'lineItemId': 'scyjdyv3mzgdsnpf', - 'layoutId': 'sw6gtws2rdj1kwby', - 'layoutName': 'Responsive image' - }, - + 'renderedPixel': 'http://localhost:8078/b/ZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX.html', + 'renderedPixelEsc': 'http%3A%2F%2Flocalhost%3A8078%2Fb%2FZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX.html', + 'visibleUrl': 'http://localhost:8078/s?rt=ZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX', + 'visibleUrlEsc': 'http%3A%2F%2Flocalhost%3A8078%2Fs%3Frt%3DZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX', + 'viewUrl': 'http://localhost:8078/v?rt=ZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX', + 'viewUrlEsc': 'http%3A%2F%2Flocalhost%3A8078%2Fv%3Frt%3DZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX', + 'rt': 'ZxGSsEJ8IzI8iCTQ17fHxnE29-y7VILLg2CLjhEbphMAAAAQCtjQz9kbGWD4nuZy3q6HaCYxpfXelzygS0s1MLax6koIS8pnjDAOShX4CbPkDyIzELe5BlfLk6_FNLuCBzOMJyx6ZZCB10wGqA3OaSe1EqpGosot0vsyFMtIWRWtUoKk-aANx531KaOWLyonoP2uC6UpxkXRUJ8iVCcMF1KmmAfe9rNYplI0E-ErHtVvZgm7uZeal_VymQxr0zkhjS_bW0PX', + 'creativeWidth': '640', + 'creativeHeight': '480', + 'creativeId': 'p6sqtvcgxczy258j', + 'lineItemId': 'cr3hnkkxhnkw9ldy', + 'layoutId': 'buyers_networkvast_single_format_layout', + 'layoutName': 'Vast (video upload)', + 'layoutExternalReference': '', + 'vastXml': '\n \n Adnuntius\n adn-id-500662301\n \n \n \n \n 00:00:15\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n', + 'renderTemplate': '\n \n Adnuntius\n {{{adId}}}\n \n \n {{#ifEquals vastVersion "4.0"}}\n {{/ifEquals}}\n \n {{assets.Video.duration}}\n \n \n {{#unless preview}}{{#each impressionTrackingUrls}}\n {{/each}}{{/unless}}{{#if text.firstQuartile.content}}\n {{/if}}\n {{#if text.thirdQuartile.content}}\n {{/if}}{{#if text.complete.content}}\n {{/if}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n' + } ] }, { 'auId': '000000000008b6bc', - 'targetId': '456', + 'targetId': 'adn-000000000008b6bc', 'matchedAdCount': 0, 'responseId': 'adn-rsp-1460129238', } @@ -108,21 +437,21 @@ describe('adnuntiusBidAdapter', function () { } } - describe('inherited functions', function () { - it('exists and is a function', function () { + describe('inherited functions', function() { + it('exists and is a function', function() { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bidRequests[0])).to.equal(true); + describe('isBidRequestValid', function() { + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bidderRequests[0])).to.equal(true); }); }); - describe('buildRequests', function () { - it('Test requests', function () { - const request = spec.buildRequests(bidRequests); + describe('buildRequests', function() { + it('Test requests', function() { + const request = spec.buildRequests(bidderRequests, {}); expect(request.length).to.equal(1); expect(request[0]).to.have.property('bid'); const bid = request[0].bid[0] @@ -130,166 +459,151 @@ describe('adnuntiusBidAdapter', function () { expect(request[0]).to.have.property('url'); expect(request[0].url).to.equal(ENDPOINT_URL); expect(request[0]).to.have.property('data'); - expect(request[0].data).to.equal('{\"adUnits\":[{\"auId\":\"8b6bc\",\"targetId\":\"123\"}],\"metaData\":{\"usi\":\"' + usi + '\"}}'); + expect(request[0].data).to.equal('{"adUnits":[{"auId":"000000000008b6bc","targetId":"adn-000000000008b6bc","maxDeals":1,"dimensions":[[640,480],[600,400]]},{"auId":"0000000000000551","targetId":"adn-0000000000000551","maxDeals":0,"dimensions":[[1640,1480],[1600,1400]]}],"metaData":{"usi":"' + usi + '"}}'); }); - it('should pass segments if available in config', function () { - config.setBidderConfig({ - bidders: ['adnuntius', 'other'], - config: { - ortb2: { - user: { - data: [{ - name: 'adnuntius', - segment: [{ id: 'segment1' }, { id: 'segment2' }] - }, - { - name: 'other', - segment: ['segment3'] - }], - } - } + it('Test Video requests', function() { + const request = spec.buildRequests(videoBidderRequest, {}); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('bid'); + const bid = request[0].bid[0] + expect(bid).to.have.property('bidId'); + expect(request[0]).to.have.property('url'); + expect(request[0].url).to.equal(ENDPOINT_URL_VIDEO); + }); + + it('should pass segments if available in config', function() { + const ortb2 = { + user: { + data: [{ + name: 'adnuntius', + segment: [{id: 'segment1'}, {id: 'segment2'}] + }, + { + name: 'other', + segment: ['segment3'] + }], } - }); + }; - const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {ortb2})); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_SEGMENTS); }); - it('should skip segments in config if not either id or array of strings', function () { - config.setBidderConfig({ - bidders: ['adnuntius', 'other'], - config: { - ortb2: { - user: { - data: [{ - name: 'adnuntius', - segment: [{ id: 'segment1' }, { id: 'segment2' }, { id: 'segment3' }] - }, - { - name: 'other', - segment: [{ - notright: 'segment4' - }] - }], - } - } + it('should skip segments in config if not either id or array of strings', function() { + const ortb2 = { + user: { + data: [{ + name: 'adnuntius', + segment: [{id: 'segment1'}, {id: 'segment2'}, {id: 'segment3'}] + }, + { + name: 'other', + segment: [{ + notright: 'segment4' + }] + }], } - }); + }; - const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {ortb2})); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_SEGMENTS); }); }); - describe('user privacy', function () { - it('should send GDPR Consent data if gdprApplies', function () { - let request = spec.buildRequests(bidRequests, { gdprConsent: { gdprApplies: true, consentString: 'consentString' } }); + describe('user privacy', function() { + it('should send GDPR Consent data if gdprApplies', function() { + let request = spec.buildRequests(bidderRequests, {gdprConsent: {gdprApplies: true, consentString: 'consentString'}}); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_CONSENT); }); - it('should not send GDPR Consent data if gdprApplies equals undefined', function () { - let request = spec.buildRequests(bidRequests, { gdprConsent: { gdprApplies: undefined, consentString: 'consentString' } }); + it('should not send GDPR Consent data if gdprApplies equals undefined', function() { + let request = spec.buildRequests(bidderRequests, {gdprConsent: {gdprApplies: undefined, consentString: 'consentString'}}); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL); }); - it('should pass segments if available in config', function () { - config.setBidderConfig({ - bidders: ['adnuntius', 'other'], - config: { - ortb2: { - user: { - data: [{ - name: 'adnuntius', - segment: [{ id: 'segment1' }, { id: 'segment2' }] - }, - { - name: 'other', - segment: ['segment3'] - }], - } - } + it('should pass segments if available in config', function() { + const ortb2 = { + user: { + data: [{ + name: 'adnuntius', + segment: [{id: 'segment1'}, {id: 'segment2'}] + }, + { + name: 'other', + segment: ['segment3'] + }], } - }); + } - const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {ortb2})); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_SEGMENTS); }); - it('should skip segments in config if not either id or array of strings', function () { - config.setBidderConfig({ - bidders: ['adnuntius', 'other'], - config: { - ortb2: { - user: { - data: [{ - name: 'adnuntius', - segment: [{ id: 'segment1' }, { id: 'segment2' }, { id: 'segment3' }] - }, - { - name: 'other', - segment: [{ - notright: 'segment4' - }] - }], - } - } + it('should skip segments in config if not either id or array of strings', function() { + const ortb2 = { + user: { + data: [{ + name: 'adnuntius', + segment: [{id: 'segment1'}, {id: 'segment2'}, {id: 'segment3'}] + }, + { + name: 'other', + segment: [{ + notright: 'segment4' + }] + }], } - }); + }; - const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {ortb2})); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_SEGMENTS); }); - it('should user user ID if present in ortb2.user.id field', function () { - config.setBidderConfig({ - bidders: ['adnuntius', 'other'], - config: { - ortb2: { - user: { - id: usi - } - } + it('should user user ID if present in ortb2.user.id field', function() { + const ortb2 = { + user: { + id: usi } - }); + }; - const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {ortb2})); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL); }); }); - describe('user privacy', function () { - it('should send GDPR Consent data if gdprApplies', function () { - let request = spec.buildRequests(bidRequests, { gdprConsent: { gdprApplies: true, consentString: 'consentString' } }); + describe('user privacy', function() { + it('should send GDPR Consent data if gdprApplies', function() { + let request = spec.buildRequests(bidderRequests, {gdprConsent: {gdprApplies: true, consentString: 'consentString'}}); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_CONSENT); }); - it('should not send GDPR Consent data if gdprApplies equals undefined', function () { - let request = spec.buildRequests(bidRequests, { gdprConsent: { gdprApplies: undefined, consentString: 'consentString' } }); + it('should not send GDPR Consent data if gdprApplies equals undefined', function() { + let request = spec.buildRequests(bidderRequests, {gdprConsent: {gdprApplies: undefined, consentString: 'consentString'}}); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL); }); }); - describe('use cookie', function () { - it('should send noCookie in url if set to false.', function () { + describe('use cookie', function() { + it('should send noCookie in url if set to false.', function() { config.setBidderConfig({ bidders: ['adnuntius'], config: { @@ -297,19 +611,228 @@ describe('adnuntiusBidAdapter', function () { } }); - const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidRequests)); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {})); expect(request.length).to.equal(1); expect(request[0]).to.have.property('url') expect(request[0].url).to.equal(ENDPOINT_URL_NOCOOKIE); }); }); - describe('interpretResponse', function () { - it('should return valid response when passed valid server response', function () { - const interpretedResponse = spec.interpretResponse(serverResponse, singleBidRequest); - const ad = serverResponse.body.adUnits[0].ads[0] + describe('validate auId', function() { + it('should fail when auId is not hexadecimal', function() { + const invalidRequest = { + bidId: 'adn-000000000008b6bc', + bidder: 'adnuntius', + params: { + auId: 'nothexadecimal', + } + }; + const valid = config.runWithBidder('adnuntius', () => spec.isBidRequestValid(invalidRequest)); + expect(valid).to.equal(false); + }); + + it('should pass when auId is hexadecimal', function() { + const invalidRequest = { + bidId: 'adn-000000000008b6bc', + bidder: 'adnuntius', + params: { + auId: '0123456789abcDEF', + } + }; + const valid = config.runWithBidder('adnuntius', () => spec.isBidRequestValid(invalidRequest)); + expect(valid).to.equal(true); + }); + }); + + describe('request deals', function() { + it('Should set max deals.', function() { + config.setBidderConfig({ + bidders: ['adnuntius'] + }); + + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {})); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL); + expect(request[0]).to.have.property('data'); + const data = JSON.parse(request[0].data); + expect(data.adUnits.length).to.equal(2); + expect(bidderRequests[0].params.maxDeals).to.equal(1); + expect(data.adUnits[0].maxDeals).to.equal(bidderRequests[0].params.maxDeals); + expect(bidderRequests[1].params).to.not.have.property('maxBids'); + expect(data.adUnits[1].maxDeals).to.equal(0); + }); + it('Should allow a maximum of 5 deals.', function() { + config.setBidderConfig({ + bidders: ['adnuntius'], + }); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests([ + { + bidId: 'adn-000000000008b6bc', + bidder: 'adnuntius', + params: { + auId: '000000000008b6bc', + network: 'adnuntius', + maxDeals: 10 + } + } + ], {})); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL); + expect(request[0]).to.have.property('data'); + const data = JSON.parse(request[0].data); + expect(data.adUnits.length).to.equal(1); + expect(data.adUnits[0].maxDeals).to.equal(5); + }); + it('Should allow a minumum of 0 deals.', function() { + config.setBidderConfig({ + bidders: ['adnuntius'], + }); + const request = config.runWithBidder('adnuntius', () => spec.buildRequests([ + { + bidId: 'adn-000000000008b6bc', + bidder: 'adnuntius', + params: { + auId: '000000000008b6bc', + network: 'adnuntius', + maxDeals: -1 + } + } + ], {})); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL); + expect(request[0]).to.have.property('data'); + const data = JSON.parse(request[0].data); + expect(data.adUnits.length).to.equal(1); + expect(data.adUnits[0].maxDeals).to.equal(0); + }); + it('Should set max deals using bidder config.', function() { + config.setBidderConfig({ + bidders: ['adnuntius'], + config: { + maxDeals: 2 + } + }); + + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {})); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL + '&ds=2'); + }); + it('Should allow a maximum of 5 deals when using bidder config.', function() { + config.setBidderConfig({ + bidders: ['adnuntius'], + config: { + maxDeals: 6 + } + }); + + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {})); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL + '&ds=5'); + }); + it('Should allow a minimum of 0 deals when using bidder config.', function() { + config.setBidderConfig({ + bidders: ['adnuntius'], + config: { + maxDeals: -1 + } + }); + + const request = config.runWithBidder('adnuntius', () => spec.buildRequests(bidderRequests, {})); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + // The maxDeals value is ignored because it is less than zero + expect(request[0].url).to.equal(ENDPOINT_URL); + }); + }); + + describe('interpretResponse', function() { + it('should return valid response when passed valid server response', function() { + config.setBidderConfig({ + bidders: ['adnuntius'], + config: { + bidType: 'netBid', + maxDeals: 1 + } + }); + + const interpretedResponse = config.runWithBidder('adnuntius', () => spec.interpretResponse(serverResponse, singleBidRequest)); + expect(interpretedResponse).to.have.lengthOf(2); + + const deal = serverResponse.body.adUnits[0].deals[0]; + expect(interpretedResponse[0].bidderCode).to.equal('adnuntius'); + expect(interpretedResponse[0].cpm).to.equal(deal.netBid.amount * 1000); + expect(interpretedResponse[0].width).to.equal(Number(deal.creativeWidth)); + expect(interpretedResponse[0].height).to.equal(Number(deal.creativeHeight)); + expect(interpretedResponse[0].creativeId).to.equal(deal.creativeId); + expect(interpretedResponse[0].currency).to.equal(deal.bid.currency); + expect(interpretedResponse[0].netRevenue).to.equal(false); + expect(interpretedResponse[0].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[0].meta.advertiserDomains).to.have.lengthOf(1); + expect(interpretedResponse[0].meta.advertiserDomains[0]).to.equal('adnuntius.com'); + expect(interpretedResponse[0].ad).to.equal(serverResponse.body.adUnits[0].deals[0].html); + expect(interpretedResponse[0].ttl).to.equal(360); + expect(interpretedResponse[0].dealId).to.equal('abc123xyz'); + expect(interpretedResponse[0].dealCount).to.equal(1); + + const ad = serverResponse.body.adUnits[0].ads[0]; + expect(interpretedResponse[1].bidderCode).to.equal('adnuntius'); + expect(interpretedResponse[1].cpm).to.equal(ad.netBid.amount * 1000); + expect(interpretedResponse[1].width).to.equal(Number(ad.creativeWidth)); + expect(interpretedResponse[1].height).to.equal(Number(ad.creativeHeight)); + expect(interpretedResponse[1].creativeId).to.equal(ad.creativeId); + expect(interpretedResponse[1].currency).to.equal(ad.bid.currency); + expect(interpretedResponse[1].netRevenue).to.equal(false); + expect(interpretedResponse[1].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[1].meta.advertiserDomains).to.have.lengthOf(1); + expect(interpretedResponse[1].meta.advertiserDomains[0]).to.equal('adnuntius.com'); + expect(interpretedResponse[1].ad).to.equal(serverResponse.body.adUnits[0].html); + expect(interpretedResponse[1].ttl).to.equal(360); + expect(interpretedResponse[1].dealId).to.equal('not-in-deal-array-here'); + expect(interpretedResponse[1].dealCount).to.equal(0); + }); + + it('should not process valid response when passed alt bidder that is an adndeal', function() { + const altBidder = { + bid: [ + { + bidder: 'adndeal1', + bidId: 'adn-0000000000000551', + } + ] + }; + serverResponse.body.adUnits[0].deals = []; + + const interpretedResponse = spec.interpretResponse(serverResponse, altBidder); + expect(interpretedResponse).to.have.lengthOf(0); + + serverResponse.body.adUnits[0].deals = deals; + }); + + it('should return valid response when passed alt bidder', function() { + const altBidder = { + bid: [ + { + bidder: 'adn-alt', + bidId: 'adn-0000000000000551', + params: { + bidType: 'netBid' + } + } + ] + }; + serverResponse.body.adUnits[0].deals = []; + + const interpretedResponse = spec.interpretResponse(serverResponse, altBidder); expect(interpretedResponse).to.have.lengthOf(1); - expect(interpretedResponse[0].cpm).to.equal(ad.cpm.amount); + + const ad = serverResponse.body.adUnits[0].ads[0]; + expect(interpretedResponse[0].bidderCode).to.equal('adn-alt'); + expect(interpretedResponse[0].cpm).to.equal(ad.netBid.amount * 1000); expect(interpretedResponse[0].width).to.equal(Number(ad.creativeWidth)); expect(interpretedResponse[0].height).to.equal(Number(ad.creativeHeight)); expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId); @@ -317,9 +840,50 @@ describe('adnuntiusBidAdapter', function () { expect(interpretedResponse[0].netRevenue).to.equal(false); expect(interpretedResponse[0].meta).to.have.property('advertiserDomains'); expect(interpretedResponse[0].meta.advertiserDomains).to.have.lengthOf(1); - expect(interpretedResponse[0].meta.advertiserDomains[0]).to.equal('google.com'); + expect(interpretedResponse[0].meta.advertiserDomains[0]).to.equal('adnuntius.com'); expect(interpretedResponse[0].ad).to.equal(serverResponse.body.adUnits[0].html); expect(interpretedResponse[0].ttl).to.equal(360); + expect(interpretedResponse[0].dealId).to.equal('not-in-deal-array-here'); + expect(interpretedResponse[0].dealCount).to.equal(0); + + serverResponse.body.adUnits[0].deals = deals; + }); + }); + + describe('interpretVideoResponse', function() { + it('should return valid response when passed valid server response', function() { + const interpretedResponse = spec.interpretResponse(serverVideoResponse, videoBidRequest); + const ad = serverVideoResponse.body.adUnits[0].ads[0] + const deal = serverVideoResponse.body.adUnits[0].deals[0] + expect(interpretedResponse).to.have.lengthOf(2); + + expect(interpretedResponse[0].bidderCode).to.equal('adnuntius'); + expect(interpretedResponse[0].cpm).to.equal(deal.bid.amount * 1000); + expect(interpretedResponse[0].width).to.equal(Number(deal.creativeWidth)); + expect(interpretedResponse[0].height).to.equal(Number(deal.creativeHeight)); + expect(interpretedResponse[0].creativeId).to.equal(deal.creativeId); + expect(interpretedResponse[0].currency).to.equal(deal.bid.currency); + expect(interpretedResponse[0].netRevenue).to.equal(false); + expect(interpretedResponse[0].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[0].meta.advertiserDomains).to.have.lengthOf(1); + expect(interpretedResponse[0].meta.advertiserDomains[0]).to.equal('adnuntius.com'); + expect(interpretedResponse[0].vastXml).to.equal(deal.vastXml); + expect(interpretedResponse[0].dealId).to.equal('abc123xyz'); + expect(interpretedResponse[0].dealCount).to.equal(1); + + expect(interpretedResponse[1].bidderCode).to.equal('adnuntius'); + expect(interpretedResponse[1].cpm).to.equal(ad.bid.amount * 1000); + expect(interpretedResponse[1].width).to.equal(Number(ad.creativeWidth)); + expect(interpretedResponse[1].height).to.equal(Number(ad.creativeHeight)); + expect(interpretedResponse[1].creativeId).to.equal(ad.creativeId); + expect(interpretedResponse[1].currency).to.equal(ad.bid.currency); + expect(interpretedResponse[1].netRevenue).to.equal(false); + expect(interpretedResponse[1].meta).to.have.property('advertiserDomains'); + expect(interpretedResponse[1].meta.advertiserDomains).to.have.lengthOf(1); + expect(interpretedResponse[1].meta.advertiserDomains[0]).to.equal('adnuntius.com'); + expect(interpretedResponse[1].vastXml).to.equal(serverVideoResponse.body.adUnits[0].vastXml); + expect(interpretedResponse[1].dealId).to.equal('not-in-deal-array'); + expect(interpretedResponse[1].dealCount).to.equal(0); }); }); }); diff --git a/test/spec/modules/adoceanBidAdapter_spec.js b/test/spec/modules/adoceanBidAdapter_spec.js index 43316cd7483..080b5bd5d1d 100644 --- a/test/spec/modules/adoceanBidAdapter_spec.js +++ b/test/spec/modules/adoceanBidAdapter_spec.js @@ -83,6 +83,20 @@ describe('AdoceanAdapter', function () { 'auctionId': '1d1a030790a475', } ]; + const schainExample = { + 'schain': { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'directseller.com', + sid: '00001!,2', + rid: 'BidRequest1', + hp: 1 + } + ] + } + }; const bidderRequest = { gdprConsent: { @@ -122,10 +136,12 @@ describe('AdoceanAdapter', function () { expect(request.url).to.include('gdpr_consent=' + bidderRequest.gdprConsent.consentString); }); - it('should attach sizes information to url', function () { + it('should attach sizes and slaves information to url', function () { let requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].url).to.include('aosspsizes=myaozpniqismex~300x250_300x600'); + expect(requests[0].url).to.include('slaves=zpniqismex'); expect(requests[1].url).to.include('aosspsizes=myaozpniqismex~300x200_600x250'); + expect(requests[1].url).to.include('slaves=zpniqismex'); const differentSlavesBids = deepClone(bidRequests); differentSlavesBids[1].params.slaveId = 'adoceanmyaowafpdwlrks'; @@ -133,8 +149,19 @@ describe('AdoceanAdapter', function () { expect(requests.length).to.equal(1); expect(requests[0].url).to.include('aosspsizes=myaozpniqismex~300x250_300x600-myaowafpdwlrks~300x200_600x250'); expect((requests[0].url.match(/aosspsizes=/g) || []).length).to.equal(1); + expect(requests[0].url).to.include('slaves=zpniqismex,wafpdwlrks'); + }); + + it('should attach schain parameter if available', function() { + let requests = spec.buildRequests(bidRequests, bidderRequest); + expect(requests.some(e => e.url.includes('schain='))).to.be.false; + + const bidsWithSchain = deepClone(bidRequests).map(e => ({...e, ...schainExample})); + requests = spec.buildRequests(bidsWithSchain, bidderRequest); + expect(requests.every(e => e.url.includes('schain=1.0,1!directseller.com,00001%21%2C2,1,BidRequest1,,,0')), + `One of urls does not contain valid schain param: ${requests.map(e => e.url).join('\n')}`).to.be.true; }); - }) + }); describe('interpretResponse', function () { const response = { diff --git a/test/spec/modules/adomikAnalyticsAdapter_spec.js b/test/spec/modules/adomikAnalyticsAdapter_spec.js index 93822d04c88..d872d6f8e08 100644 --- a/test/spec/modules/adomikAnalyticsAdapter_spec.js +++ b/test/spec/modules/adomikAnalyticsAdapter_spec.js @@ -10,43 +10,34 @@ describe('Adomik Prebid Analytic', function () { let sendWonEventStub; let clock; - before(function () { + beforeEach(function () { clock = sinon.useFakeTimers(); + sinon.spy(adomikAnalytics, 'track'); + sendEventStub = sinon.stub(adomikAnalytics, 'sendTypedEvent'); + sendWonEventStub = sinon.stub(adomikAnalytics, 'sendWonEvent'); + sinon.stub(events, 'getEvents').returns([]); + adomikAnalytics.currentContext = undefined; + + adapterManager.registerAnalyticsAdapter({ + code: 'adomik', + adapter: adomikAnalytics + }); }); - after(function () { + + afterEach(function () { + adomikAnalytics.disableAnalytics(); clock.restore(); + adomikAnalytics.track.restore(); + sendEventStub.restore(); + sendWonEventStub.restore(); + events.getEvents.restore(); }); - describe('enableAnalytics', function () { - beforeEach(function () { - sinon.spy(adomikAnalytics, 'track'); - sendEventStub = sinon.stub(adomikAnalytics, 'sendTypedEvent'); - sendWonEventStub = sinon.stub(adomikAnalytics, 'sendWonEvent'); - sinon.stub(events, 'getEvents').returns([]); - }); - - afterEach(function () { - adomikAnalytics.track.restore(); - sendEventStub.restore(); - sendWonEventStub.restore(); - events.getEvents.restore(); - }); - - after(function () { - adomikAnalytics.disableAnalytics(); - }); - + describe('adomikAnalytics.enableAnalytics', function () { it('should catch all events', function (done) { - adapterManager.registerAnalyticsAdapter({ - code: 'adomik', - adapter: adomikAnalytics - }); - const initOptions = { id: '123456', - url: 'testurl', - testId: '12345', - testValue: '1000' + url: 'testurl' }; const bid = { @@ -74,8 +65,6 @@ describe('Adomik Prebid Analytic', function () { uid: '123456', url: 'testurl', sampling: undefined, - testId: '12345', - testValue: '1000', id: '', timeouted: false }); @@ -87,8 +76,6 @@ describe('Adomik Prebid Analytic', function () { uid: '123456', url: 'testurl', sampling: undefined, - testId: '12345', - testValue: '1000', id: 'test-test-test', timeouted: false }); @@ -149,5 +136,118 @@ describe('Adomik Prebid Analytic', function () { sinon.assert.callCount(adomikAnalytics.track, 6); }); + + describe('when sampling is undefined', function () { + beforeEach(function() { + adapterManager.enableAnalytics({ + provider: 'adomik', + options: { id: '123456', url: 'testurl' } + }); + }); + + it('is enabled', function () { + expect(adomikAnalytics.currentContext).is.not.null; + }); + }); + + describe('when sampling is 0', function () { + beforeEach(function() { + adapterManager.enableAnalytics({ + provider: 'adomik', + options: { id: '123456', url: 'testurl', sampling: 0 } + }); + }); + + it('is disabled', function () { + expect(adomikAnalytics.currentContext).to.equal(undefined); + }); + }); + + describe('when sampling is 1', function () { + beforeEach(function() { + adapterManager.enableAnalytics({ + provider: 'adomik', + options: { id: '123456', url: 'testurl', sampling: 1 } + }); + }); + + it('is enabled', function () { + expect(adomikAnalytics.currentContext).is.not.null; + }); + }); + + describe('when options is not defined', function () { + beforeEach(function() { + adapterManager.enableAnalytics({ provider: 'adomik' }); + }); + + it('is disabled', function () { + expect(adomikAnalytics.currentContext).to.equal(undefined); + }); + }); + + describe('when id is not defined in options', function () { + beforeEach(function() { + adapterManager.enableAnalytics({ provider: 'adomik', url: 'xxx' }); + }); + + it('is disabled', function () { + expect(adomikAnalytics.currentContext).to.equal(undefined); + }); + }); + + describe('when url is not defined in options', function () { + beforeEach(function() { + adapterManager.enableAnalytics({ provider: 'adomik', id: 'xxx' }); + }); + + it('is disabled', function () { + expect(adomikAnalytics.currentContext).to.equal(undefined); + }); + }); + }); + + describe('adomikAnalytics.getKeyValues', function () { + it('returns [undefined, undefined]', function () { + let [testId, testValue] = adomikAnalytics.getKeyValues() + expect(testId).to.equal(undefined); + expect(testValue).to.equal(undefined); + }); + + describe('when test is in scope', function () { + beforeEach(function () { + sessionStorage.setItem(window.location.hostname + '_AdomikTestInScope', true); + }); + + it('returns [undefined, undefined]', function () { + let [testId, testValue] = adomikAnalytics.getKeyValues() + expect(testId).to.equal(undefined); + expect(testValue).to.equal(undefined); + }); + + describe('when key values are defined', function () { + beforeEach(function () { + sessionStorage.setItem(window.location.hostname + '_AdomikTest', '{"testId":"12345","testOptionLabel":"1000"}'); + }); + + it('returns key values', function () { + let [testId, testValue] = adomikAnalytics.getKeyValues() + expect(testId).to.equal('12345'); + expect(testValue).to.equal('1000'); + }); + + describe('when preventTest is on', function () { + beforeEach(function () { + sessionStorage.setItem(window.location.hostname + '_NoAdomikTest', true); + }); + + it('returns [undefined, undefined]', function () { + let [testId, testValue] = adomikAnalytics.getKeyValues() + expect(testId).to.equal(undefined); + expect(testValue).to.equal(undefined); + }); + }); + }); + }); }); }); diff --git a/test/spec/modules/adotBidAdapter_spec.js b/test/spec/modules/adotBidAdapter_spec.js index 81b9c5e15e9..34252e00f9e 100644 --- a/test/spec/modules/adotBidAdapter_spec.js +++ b/test/spec/modules/adotBidAdapter_spec.js @@ -28,7 +28,7 @@ describe('Adot Adapter', function () { it('should build request (banner)', function () { const bidderRequestId = 'bidderRequestId'; const validBidRequests = [{ bidderRequestId, mediaTypes: {} }, { bidderRequestId, bidId: 'bidId', mediaTypes: { banner: { sizes: [[300, 250]] } }, params: { placementId: 'placementId', adUnitCode: 200 } }]; - const bidderRequest = { position: 2, refererInfo: { referer: 'http://localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } }; + const bidderRequest = { position: 2, refererInfo: { page: 'http://localhost.com', domain: 'localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true }, userId: { pubProvidedId: 'userId' }, schain: { ver: '1.0' } }; const request = spec.buildRequests(validBidRequests, bidderRequest); const buildBidRequestResponse = { @@ -48,16 +48,17 @@ describe('Adot Adapter', function () { bidfloor: 0 }], site: { - page: bidderRequest.refererInfo.referer, + page: bidderRequest.refererInfo.page, domain: 'localhost.com', name: 'localhost.com', publisher: { // id: 'adot' id: undefined - } + }, + ext: { schain: { ver: '1.0' } } }, device: { ua: navigator.userAgent, language: navigator.language }, - user: { ext: { consent: bidderRequest.gdprConsent.consentString } }, + user: { ext: { consent: bidderRequest.gdprConsent.consentString, pubProvidedId: 'userId' } }, regs: { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies } }, ext: { adot: { adapter_version: 'v2.0.0' }, @@ -76,7 +77,7 @@ describe('Adot Adapter', function () { it('should build request (native)', function () { const bidderRequestId = 'bidderRequestId'; const validBidRequests = [{ bidderRequestId, mediaTypes: {} }, { bidderRequestId, bidId: 'bidId', mediaTypes: { native: { title: { required: true, len: 50, sizes: [[300, 250]] }, wrong: {}, image: {} } }, params: { placementId: 'placementId', adUnitCode: 200 } }]; - const bidderRequest = { position: 2, refererInfo: { referer: 'http://localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } }; + const bidderRequest = { position: 2, refererInfo: { page: 'http://localhost.com', domain: 'localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true }, userId: { pubProvidedId: 'userId' }, schain: { ver: '1.0' } }; const request = spec.buildRequests(validBidRequests, bidderRequest); const buildBidRequestResponse = { @@ -95,16 +96,17 @@ describe('Adot Adapter', function () { bidfloor: 0 }], site: { - page: bidderRequest.refererInfo.referer, + page: bidderRequest.refererInfo.page, domain: 'localhost.com', name: 'localhost.com', publisher: { // id: 'adot' id: undefined - } + }, + ext: { schain: { ver: '1.0' } } }, device: { ua: navigator.userAgent, language: navigator.language }, - user: { ext: { consent: bidderRequest.gdprConsent.consentString } }, + user: { ext: { consent: bidderRequest.gdprConsent.consentString, pubProvidedId: 'userId' } }, regs: { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies } }, ext: { adot: { adapter_version: 'v2.0.0' }, @@ -123,7 +125,7 @@ describe('Adot Adapter', function () { it('should build request (video)', function () { const bidderRequestId = 'bidderRequestId'; const validBidRequests = [{ bidderRequestId, mediaTypes: {} }, { bidderRequestId, bidId: 'bidId', mediaTypes: { video: { playerSize: [[300, 250]], minduration: 1, maxduration: 2, api: 'api', linearity: 'linearity', mimes: [], placement: 'placement', playbackmethod: 'playbackmethod', protocols: 'protocol', startdelay: 'startdelay' } }, params: { placementId: 'placementId', adUnitCode: 200 } }]; - const bidderRequest = { position: 2, refererInfo: { referer: 'http://localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true } }; + const bidderRequest = { position: 2, refererInfo: { page: 'http://localhost.com', domain: 'localhost.com' }, gdprConsent: { consentString: 'consentString', gdprApplies: true }, userId: { pubProvidedId: 'userId' }, schain: { ver: '1.0' } }; const request = spec.buildRequests(validBidRequests, bidderRequest); const buildBidRequestResponse = { @@ -154,16 +156,17 @@ describe('Adot Adapter', function () { bidfloor: 0 }], site: { - page: bidderRequest.refererInfo.referer, + page: bidderRequest.refererInfo.page, domain: 'localhost.com', name: 'localhost.com', publisher: { // id: 'adot' id: undefined - } + }, + ext: { schain: { ver: '1.0' } } }, device: { ua: navigator.userAgent, language: navigator.language }, - user: { ext: { consent: bidderRequest.gdprConsent.consentString } }, + user: { ext: { consent: bidderRequest.gdprConsent.consentString, pubProvidedId: 'userId' } }, regs: { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies } }, ext: { adot: { adapter_version: 'v2.0.0' }, diff --git a/test/spec/modules/adpartnerBidAdapter_spec.js b/test/spec/modules/adpartnerBidAdapter_spec.js index 94b56f7735b..d9f9b0d0074 100644 --- a/test/spec/modules/adpartnerBidAdapter_spec.js +++ b/test/spec/modules/adpartnerBidAdapter_spec.js @@ -86,7 +86,7 @@ describe('AdpartnerAdapter', function () { let bidderRequest = { refererInfo: { - referer: 'https://test.domain' + page: 'https://test.domain' } }; diff --git a/test/spec/modules/adpod_spec.js b/test/spec/modules/adpod_spec.js index a6164f919ef..14e530c1a9b 100644 --- a/test/spec/modules/adpod_spec.js +++ b/test/spec/modules/adpod_spec.js @@ -47,7 +47,6 @@ describe('adpod.js', function () { addBidToAuctionStub = sinon.stub(auction, 'addBidToAuction').callsFake(function (auctionInstance, bid) { auctionBids.push(bid); }); - doCallbacksIfTimedoutStub = sinon.stub(auction, 'doCallbacksIfTimedout'); clock = sinon.useFakeTimers(); config.setConfig({ cache: { @@ -61,7 +60,6 @@ describe('adpod.js', function () { logWarnStub.restore(); logInfoStub.restore(); addBidToAuctionStub.restore(); - doCallbacksIfTimedoutStub.restore(); clock.restore(); config.resetConfig(); auctionBids = []; @@ -633,7 +631,6 @@ describe('adpod.js', function () { callPrebidCacheHook(callbackFn, auctionInstance, bidResponse1, afterBidAddedSpy, videoMT); callPrebidCacheHook(callbackFn, auctionInstance, bidResponse2, afterBidAddedSpy, videoMT); - expect(doCallbacksIfTimedoutStub.calledTwice).to.equal(true); expect(logWarnStub.calledOnce).to.equal(true); expect(auctionBids.length).to.equal(0); }); diff --git a/test/spec/modules/adqueryBidAdapter_spec.js b/test/spec/modules/adqueryBidAdapter_spec.js index 4285377e8a7..e9286329d57 100644 --- a/test/spec/modules/adqueryBidAdapter_spec.js +++ b/test/spec/modules/adqueryBidAdapter_spec.js @@ -70,10 +70,21 @@ describe('adqueryBidAdapter', function () { it('should return false if any parameter missing', function () { expect(spec.isBidRequestValid(inValidBid)).to.be.false }) + + it('should return false when sizes for banner are not specified', () => { + const bid = utils.deepClone(bidRequest); + delete bid.mediaTypes.banner.sizes; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); }) describe('buildRequests', function () { - let req = spec.buildRequests([ bidRequest ], { refererInfo: { } })[0] + let req; + beforeEach(() => { + req = spec.buildRequests([ bidRequest ], { refererInfo: { } })[0] + }) + let rdata it('should return request object', function () { @@ -108,6 +119,19 @@ describe('adqueryBidAdapter', function () { it('should include bidder', function () { expect(rdata.bidder !== null).to.be.true }) + + it('should include sizes', function () { + expect(rdata.sizes).not.be.null + }) + + it('should include version', function () { + expect(rdata.v).not.be.null + expect(rdata.v).equal('$prebid.version$') + }) + + it('should include referrer', function () { + expect(rdata.bidPageUrl).not.be.null + }) }) describe('interpretResponse', function () { diff --git a/test/spec/modules/adqueryIdSystem_spec.js b/test/spec/modules/adqueryIdSystem_spec.js index ab98b253b33..0a2cd60d89e 100644 --- a/test/spec/modules/adqueryIdSystem_spec.js +++ b/test/spec/modules/adqueryIdSystem_spec.js @@ -1,7 +1,6 @@ -import { adqueryIdSubmodule, storage } from 'modules/adqueryIdSystem.js'; -import { server } from 'test/mocks/xhr.js'; -import {amxIdSubmodule} from '../../../modules/amxIdSystem'; -import * as utils from '../../../src/utils'; +import {adqueryIdSubmodule, storage} from 'modules/adqueryIdSystem.js'; +import {server} from 'test/mocks/xhr.js'; +import sinon from 'sinon'; const config = { storage: { @@ -20,10 +19,10 @@ describe('AdqueryIdSystem', function () { }); }); - describe('getId', function() { + describe('getId', function () { let getDataFromLocalStorageStub; - beforeEach(function() { + beforeEach(function () { getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); }); @@ -31,7 +30,7 @@ describe('AdqueryIdSystem', function () { getDataFromLocalStorageStub.restore(); }); - it('gets a adqueryId', function() { + it('gets a adqueryId', function () { const config = { params: {} }; @@ -39,36 +38,24 @@ describe('AdqueryIdSystem', function () { const callback = adqueryIdSubmodule.getId(config).callback; callback(callbackSpy); const request = server.requests[0]; - expect(request.url).to.eq(`https://bidder.adquery.io/prebid/qid`); - request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ qid: 'qid' })); - expect(callbackSpy.lastCall.lastArg).to.deep.equal({qid: 'qid'}); + expect(request.url).to.contains(`https://bidder.adquery.io/prebid/qid?qid=`); + request.respond(200, {'Content-Type': 'application/json'}, JSON.stringify({qid: '6dd9eab7dfeab7df6dd9ea'})); + expect(callbackSpy.lastCall.lastArg).to.deep.equal('6dd9eab7dfeab7df6dd9ea'); }); - it('gets a cached adqueryId', function() { - const config = { - params: {} - }; - getDataFromLocalStorageStub.withArgs('qid').returns('qid'); - - const callbackSpy = sinon.spy(); - const callback = adqueryIdSubmodule.getId(config).callback; - callback(callbackSpy); - expect(callbackSpy.lastCall.lastArg).to.deep.equal({qid: 'qid'}); - }); - - it('allows configurable id url', function() { + it('allows configurable id url', function () { const config = { params: { - url: 'https://bidder.adquery.io' + url: 'https://another_bidder.adquery.io/qid' } }; const callbackSpy = sinon.spy(); const callback = adqueryIdSubmodule.getId(config).callback; callback(callbackSpy); const request = server.requests[0]; - expect(request.url).to.eq('https://bidder.adquery.io'); - request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ qid: 'testqid' })); - expect(callbackSpy.lastCall.lastArg).to.deep.equal({qid: 'testqid'}); + expect(request.url).to.contains('https://another_bidder.adquery.io/qid'); + request.respond(200, {'Content-Type': 'application/json'}, JSON.stringify({qid: 'testqid'})); + expect(callbackSpy.lastCall.lastArg).to.deep.equal('testqid'); }); }); }); diff --git a/test/spec/modules/adrelevantisBidAdapter_spec.js b/test/spec/modules/adrelevantisBidAdapter_spec.js index d25fdaf86d7..7f24176e850 100644 --- a/test/spec/modules/adrelevantisBidAdapter_spec.js +++ b/test/spec/modules/adrelevantisBidAdapter_spec.js @@ -69,7 +69,7 @@ describe('AdrelevantisAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].private_sizes).to.exist; @@ -77,7 +77,7 @@ describe('AdrelevantisAdapter', function () { }); it('should add source and verison to the tag', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, {}); const payload = JSON.parse(request.data); expect(payload.sdk).to.exist; expect(payload.sdk).to.deep.equal({ @@ -92,7 +92,7 @@ describe('AdrelevantisAdapter', function () { bidRequest.mediaTypes = {}; bidRequest.mediaTypes[type] = {}; - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].ad_types).to.deep.equal([type]); @@ -104,14 +104,14 @@ describe('AdrelevantisAdapter', function () { bidRequest.mediaTypes = {}; bidRequest.mediaTypes.video = {context: 'outstream'}; - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].ad_types).to.deep.equal(['video']); }); it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, {}); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('POST'); }); @@ -131,7 +131,7 @@ describe('AdrelevantisAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].video).to.deep.equal({ id: 123, @@ -168,7 +168,7 @@ describe('AdrelevantisAdapter', function () { bidRequest2.adUnitCode = 'adUnit_code_2'; bidRequest2 = Object.assign({}, bidRequest2, videoData); - const request = spec.buildRequests([bidRequest1, bidRequest2]); + const request = spec.buildRequests([bidRequest1, bidRequest2], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].video).to.deep.equal({ skippable: true, @@ -195,7 +195,7 @@ describe('AdrelevantisAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.user).to.exist; @@ -215,32 +215,27 @@ describe('AdrelevantisAdapter', function () { } } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].hb_source).to.deep.equal(1); }); it('adds context data (category and keywords) to request when set', function() { let bidRequest = Object.assign({}, bidRequests[0]); - sinon - .stub(config, 'getConfig') - .withArgs('ortb2') - .returns({ - site: { - keywords: 'US Open', - ext: { - data: {category: 'sports/tennis'} - } + const ortb2 = { + site: { + keywords: 'US Open', + ext: { + data: {category: 'sports/tennis'} } - }); + } + }; - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {ortb2}); const payload = JSON.parse(request.data); expect(payload.fpd.keywords).to.equal('US Open'); expect(payload.fpd.category).to.equal('sports/tennis'); - - config.getConfig.restore(); }); it('should attach native params to the request', function () { @@ -269,7 +264,7 @@ describe('AdrelevantisAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].native.layouts[0]).to.deep.equal({ @@ -306,13 +301,13 @@ describe('AdrelevantisAdapter', function () { ); bidRequest.sizes = [[150, 100], [300, 250]]; - let request = spec.buildRequests([bidRequest]); + let request = spec.buildRequests([bidRequest], {}); let payload = JSON.parse(request.data); expect(payload.tags[0].sizes).to.deep.equal([{width: 150, height: 100}, {width: 300, height: 250}]); delete bidRequest.sizes; - request = spec.buildRequests([bidRequest]); + request = spec.buildRequests([bidRequest], {}); payload = JSON.parse(request.data); expect(payload.tags[0].sizes).to.deep.equal([{width: 1, height: 1}]); @@ -338,7 +333,7 @@ describe('AdrelevantisAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].keywords).to.deep.equal([{ @@ -374,7 +369,7 @@ describe('AdrelevantisAdapter', function () { } ); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.tags[0].use_pmt_rule).to.equal(true); @@ -425,7 +420,7 @@ describe('AdrelevantisAdapter', function () { } } ); - const request = spec.buildRequests([appRequest]); + const request = spec.buildRequests([appRequest], {}); const payload = JSON.parse(request.data); expect(payload.app).to.exist; expect(payload.app).to.deep.equal({ @@ -450,7 +445,7 @@ describe('AdrelevantisAdapter', function () { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + topmostLocation: 'http://example.com/page.html', reachedTop: true, numIframes: 2, stack: [ @@ -478,7 +473,7 @@ describe('AdrelevantisAdapter', function () { .withArgs('coppa') .returns(true); - const request = spec.buildRequests([bidRequest]); + const request = spec.buildRequests([bidRequest], {}); const payload = JSON.parse(request.data); expect(payload.user.coppa).to.equal(true); @@ -488,15 +483,6 @@ describe('AdrelevantisAdapter', function () { }) describe('interpretResponse', function () { - let bfStub; - before(function() { - bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); - }); - - after(function() { - bfStub.restore(); - }); - let response = { 'version': '3.0.0', 'tags': [ diff --git a/test/spec/modules/adrinoBidAdapter_spec.js b/test/spec/modules/adrinoBidAdapter_spec.js index 52b2796e6db..2204ee9e400 100644 --- a/test/spec/modules/adrinoBidAdapter_spec.js +++ b/test/spec/modules/adrinoBidAdapter_spec.js @@ -1,8 +1,13 @@ import { expect } from 'chai'; import { spec } from 'modules/adrinoBidAdapter.js'; +import {config} from '../../../src/config.js'; import * as utils from '../../../src/utils'; describe('adrinoBidAdapter', function () { + afterEach(() => { + config.resetConfig(); + }); + describe('isBidRequestValid', function () { const validBid = { bidder: 'adrino', @@ -38,7 +43,7 @@ describe('adrinoBidAdapter', function () { it('should return false when unsupported media type is requested', function () { const bid = { ...validBid }; - bid.mediaTypes = { banner: { sizes: [[300, 250]] } }; + bid.mediaTypes = { video: {} }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); @@ -49,7 +54,47 @@ describe('adrinoBidAdapter', function () { }); }); - describe('buildRequests', function () { + describe('buildBannerRequest', function () { + const bidRequest = { + bidder: 'adrino', + params: { + hash: 'abcdef123456' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [970, 250]] + } + }, + sizes: [[300, 250], [970, 250]], + userId: { criteoId: '2xqi3F94aHdwWnM3', pubcid: '3ec0b202-7697' }, + adUnitCode: 'adunit-code-2', + bidId: '12345678901234', + bidderRequestId: '98765432109876', + auctionId: '01234567891234', + }; + + it('should build the request correctly', function () { + const result = spec.buildRequests( + [ bidRequest ], + { refererInfo: { page: 'http://example.com/' } } + ); + expect(result.length).to.equal(1); + expect(result[0].method).to.equal('POST'); + expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bids/'); + expect(result[0].data[0].adUnitCode).to.equal('adunit-code-2'); + expect(result[0].data[0].bidId).to.equal('12345678901234'); + expect(result[0].data[0].placementHash).to.equal('abcdef123456'); + expect(result[0].data[0].referer).to.equal('http://example.com/'); + expect(result[0].data[0].userAgent).to.equal(navigator.userAgent); + expect(result[0].data[0]).to.have.property('bannerParams'); + expect(result[0].data[0].bannerParams.sizes.length).to.equal(2); + expect(result[0].data[0]).to.have.property('userId'); + expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3'); + expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697'); + }); + }); + + describe('buildNativeRequest', function () { const bidRequest = { bidder: 'adrino', params: { @@ -66,48 +111,87 @@ describe('adrinoBidAdapter', function () { } } }, + nativeParams: { + title: { + required: true + }, + image: { + required: true, + sizes: [[300, 150], [300, 210]] + } + }, + userId: { criteoId: '2xqi3F94aHdwWnM3', pubcid: '3ec0b202-7697' }, adUnitCode: 'adunit-code', bidId: '12345678901234', bidderRequestId: '98765432109876', auctionId: '01234567891234', }; + it('should build the request correctly with custom domain', function () { + config.setConfig({adrino: { host: 'https://stg-prebid-bidder.adrino.io' }}); + const result = spec.buildRequests( + [ bidRequest ], + { refererInfo: { page: 'http://example.com/' } } + ); + expect(result.length).to.equal(1); + expect(result[0].method).to.equal('POST'); + expect(result[0].url).to.equal('https://stg-prebid-bidder.adrino.io/bidder/bids/'); + expect(result[0].data[0].adUnitCode).to.equal('adunit-code'); + expect(result[0].data[0].bidId).to.equal('12345678901234'); + expect(result[0].data[0].placementHash).to.equal('abcdef123456'); + expect(result[0].data[0].referer).to.equal('http://example.com/'); + expect(result[0].data[0].userAgent).to.equal(navigator.userAgent); + expect(result[0].data[0]).to.have.property('nativeParams'); + expect(result[0].data[0]).not.to.have.property('gdprConsent'); + expect(result[0].data[0]).to.have.property('userId'); + expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3'); + expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697'); + }); + it('should build the request correctly with gdpr', function () { const result = spec.buildRequests( [ bidRequest ], - { gdprConsent: { gdprApplies: true, consentString: 'abc123' }, refererInfo: { referer: 'http://example.com/' } } + { gdprConsent: { gdprApplies: true, consentString: 'abc123' }, refererInfo: { page: 'http://example.com/' } } ); expect(result.length).to.equal(1); expect(result[0].method).to.equal('POST'); - expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bid/'); - expect(result[0].data.bidId).to.equal('12345678901234'); - expect(result[0].data.placementHash).to.equal('abcdef123456'); - expect(result[0].data.referer).to.equal('http://example.com/'); - expect(result[0].data.userAgent).to.equal(navigator.userAgent); - expect(result[0].data).to.have.property('nativeParams'); - expect(result[0].data).to.have.property('gdprConsent'); + expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bids/'); + expect(result[0].data[0].adUnitCode).to.equal('adunit-code'); + expect(result[0].data[0].bidId).to.equal('12345678901234'); + expect(result[0].data[0].placementHash).to.equal('abcdef123456'); + expect(result[0].data[0].referer).to.equal('http://example.com/'); + expect(result[0].data[0].userAgent).to.equal(navigator.userAgent); + expect(result[0].data[0]).to.have.property('nativeParams'); + expect(result[0].data[0]).to.have.property('gdprConsent'); + expect(result[0].data[0]).to.have.property('userId'); + expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3'); + expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697'); }); it('should build the request correctly without gdpr', function () { const result = spec.buildRequests( [ bidRequest ], - { refererInfo: { referer: 'http://example.com/' } } + { refererInfo: { page: 'http://example.com/' } } ); expect(result.length).to.equal(1); expect(result[0].method).to.equal('POST'); - expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bid/'); - expect(result[0].data.bidId).to.equal('12345678901234'); - expect(result[0].data.placementHash).to.equal('abcdef123456'); - expect(result[0].data.referer).to.equal('http://example.com/'); - expect(result[0].data.userAgent).to.equal(navigator.userAgent); - expect(result[0].data).to.have.property('nativeParams'); - expect(result[0].data).not.to.have.property('gdprConsent'); + expect(result[0].url).to.equal('https://prd-prebid-bidder.adrino.io/bidder/bids/'); + expect(result[0].data[0].adUnitCode).to.equal('adunit-code'); + expect(result[0].data[0].bidId).to.equal('12345678901234'); + expect(result[0].data[0].placementHash).to.equal('abcdef123456'); + expect(result[0].data[0].referer).to.equal('http://example.com/'); + expect(result[0].data[0].userAgent).to.equal(navigator.userAgent); + expect(result[0].data[0]).to.have.property('nativeParams'); + expect(result[0].data[0]).not.to.have.property('gdprConsent'); + expect(result[0].data[0]).to.have.property('userId'); + expect(result[0].data[0].userId.criteoId).to.equal('2xqi3F94aHdwWnM3'); + expect(result[0].data[0].userId.pubcid).to.equal('3ec0b202-7697'); }); }); describe('interpretResponse', function () { it('should interpret the response correctly', function () { - const response = { + const response1 = { requestId: '31662c69728811', mediaType: 'native', cpm: 0.53, @@ -135,13 +219,44 @@ describe('adrinoBidAdapter', function () { } }; + const response2 = { + requestId: '31662c69728812', + mediaType: 'native', + cpm: 0.77, + currency: 'PLN', + creativeId: '859120', + netRevenue: true, + ttl: 600, + width: 1, + height: 1, + noAd: false, + testAd: false, + native: { + title: 'Ad Title', + body: 'Ad Body', + image: { + url: 'http://emisja.contentstream.pl/_/getImageII/?vid=17180728299&typ=cs_300_150&element=IMAGE&scale=1&prefix=adart&nc=1643878278955', + height: 150, + width: 300 + }, + clickUrl: 'http://emisja.contentstream.pl/_/ctr2/?u=https%3A%2F%2Fonline.efortuna.pl%2Fpage%3Fkey%3Dej0xMzUzMTM1NiZsPTE1Mjc1MzY1JnA9NTMyOTA%253D&e=znU3tABN8K4N391dmUxYfte5G9tBaDXELJVo1_-kvaTJH2XwWRw77fmfL2YjcEmrbqRQ3M0GcJ0vPWcLtZlsrf8dWrAEHNoZKAC6JMnZF_65IYhTPbQIJ-zn3ac9TU7gEZftFKksH1al7rMuieleVv9r6_DtrOk_oZcYAe4rMRQM-TiWvivJRPBchAAblE0cqyG7rCunJFpal43sxlYm4GvcBJaYHzErn5PXjEzNbd3xHjkdiap-xU9y6BbfkUZ1xIMS8QZLvwNrTXMFCSfSRN2tgVfEj7KyGdLCITHSaFtuIKT2iW2pxC7f2RtPHnzsEPXH0SgAfhA3OxZ5jkQjOZy0PsO7MiCv3sJai5ezUAOjFgayU91ZhI0Y9r2YpB1tTGIjnO23wot8PvRENlThHQ%3D%3D&ref=https%3A%2F%2Fbox.adrino.cloud%2Ftmielcarz%2Fadrino_prebid%2Ftest_page3.html%3Fpbjs_debug%3Dtrue', + privacyLink: 'https://adrino.pl/wp-content/uploads/2021/01/POLITYKA-PRYWATNOS%CC%81CI-Adrino-Mobile.pdf', + impressionTrackers: [ + 'https://prd-impression-tracker-producer.adrino.io/impression/eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJpbXByZXNzaW9uSWRcIjpcIjMxNjYyYzY5NzI4ODExXCIsXCJkYXRlXCI6WzIwMjIsMiwzXSxcInBsYWNlbWVudEhhc2hcIjpcIjk0NTVjMDQxYzlkMTI1ZmIwNDE4MWVhMGVlZTJmMmFlXCIsXCJjYW1wYWlnbklkXCI6MTc5MjUsXCJhZHZlcnRpc2VtZW50SWRcIjo5MjA3OSxcInZpc3VhbGlzYXRpb25JZFwiOjg1OTExNSxcImNwbVwiOjUzLjB9IiwiZXhwIjoxNjQzOTE2MjUxLCJpYXQiOjE2NDM5MTU2NTF9.0Y_HvInGl6Xo5xP6rDLC8lzQRGvy-wKe0blk1o8ebWyVRFiUY1JGLUeE0k3sCsPNxgdHAv-o6EcbogpUuqlMJA' + ] + } + }; + const serverResponse = { - body: response + body: { bidResponses: [response1, response2] } }; const result = spec.interpretResponse(serverResponse, {}); - expect(result.length).to.equal(1); - expect(result[0]).to.equal(response); + expect(result.length).to.equal(2); + expect(result[0]).to.equal(response1); + expect(result[0].requestId).to.equal('31662c69728811'); + expect(result[1]).to.equal(response2); + expect(result[1].requestId).to.equal('31662c69728812'); }); it('should return empty array of responses', function () { diff --git a/test/spec/modules/adriverBidAdapter_spec.js b/test/spec/modules/adriverBidAdapter_spec.js index 12c0a15fb06..94202e96dea 100644 --- a/test/spec/modules/adriverBidAdapter_spec.js +++ b/test/spec/modules/adriverBidAdapter_spec.js @@ -297,25 +297,18 @@ describe('adriverAdapter', function () { { adrcid: undefined } ] cookieValues.forEach(cookieValue => describe('test cookie exist or not behavior', function () { - let expectedValues = { - adrcid: cookieValue.adrcid, - at: '', - cur: '', - tmax: '', - site: '', - id: '', - user: '', - device: '', - imp: '' - } + let expectedValues = [ + 'buyerid', + 'ext' + ] it('check adrcid if it exists', function () { bidRequests[0].userId.adrcid = cookieValue.adrcid; const payload = JSON.parse(spec.buildRequests(bidRequests).data); if (cookieValue.adrcid) { - expect(Object.keys(payload)).to.have.members(Object.keys(expectedValues)); + expect(Object.keys(payload.user)).to.have.members(expectedValues); } else { - expect(payload.adrcid).to.equal(undefined); + expect(payload.user.buyerid).to.equal(0); } }); })); @@ -328,15 +321,6 @@ describe('adriverAdapter', function () { }); describe('interpretResponse', function () { - let bfStub; - before(function() { - bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); - }); - - after(function() { - bfStub.restore(); - }); - let response = { 'id': '221594457-1615288400-1-46-', 'bidid': 'D8JW8XU8-L5m7qFMNQGs7i1gcuPvYMEDOKsktw6e9uLy5Eebo9HftVXb0VpKj4R2dXa93i6QmRhjextJVM4y1SqodMAh5vFOb_eVkHA', diff --git a/test/spec/modules/adriverIdSystem_spec.js b/test/spec/modules/adriverIdSystem_spec.js index 8780c79f719..abc831b67f0 100644 --- a/test/spec/modules/adriverIdSystem_spec.js +++ b/test/spec/modules/adriverIdSystem_spec.js @@ -32,7 +32,6 @@ describe('AdriverIdSystem', function () { expect(request.url).to.include('https://ad.adriver.ru/cgi-bin/json.cgi'); request.respond(503, null, 'Unavailable'); expect(logErrorStub.calledOnce).to.be.true; - expect(callbackSpy.calledOnce).to.be.true; }); it('test call user sync url with the right params', function() { @@ -67,12 +66,16 @@ describe('AdriverIdSystem', function () { let request = server.requests[0]; request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ adrcid: response.adrcid })); - let now = new Date(); - now.setTime(now.getTime() + 86400 * 1825 * 1000); + let expectedExpiration = new Date(); + expectedExpiration.setTime(expectedExpiration.getTime() + 86400 * 1825 * 1000); const minimalDate = new Date(0).toString(); + function dateStringFor(date, maxDeltaMs = 2000) { + return sinon.match((val) => Math.abs(date.getTime() - new Date(val).getTime()) <= maxDeltaMs) + } + if (response.adrcid) { - expect(setCookieStub.calledWith('adrcid', response.adrcid, now.toUTCString())).to.be.true; + expect(setCookieStub.calledWith('adrcid', response.adrcid, dateStringFor(expectedExpiration))).to.be.true; expect(setLocalStorageStub.calledWith('adrcid', response.adrcid)).to.be.true; } else { expect(setCookieStub.calledWith('adrcid', '', minimalDate)).to.be.false; diff --git a/test/spec/modules/adsinteractiveBidAdapter_spec.js b/test/spec/modules/adsinteractiveBidAdapter_spec.js new file mode 100644 index 00000000000..d0f90bd71de --- /dev/null +++ b/test/spec/modules/adsinteractiveBidAdapter_spec.js @@ -0,0 +1,207 @@ +import { expect } from 'chai'; +import { spec } from 'modules/adsinteractiveBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('adsinteractiveBidAdapter', function () { + let bid = { + ortb2: { + site: { + page: 'http://test.com', + domain: 'test.com', + publisher: { + domain: 'test.com', + }, + }, + }, + bidder: 'adsinteractive', + sizes: [[300, 250]], + bidId: '32469kja92389', + params: { + adUnit: 'example_adunit_1', + }, + } + + const bidderRequest = { + refererInfo: { + isAmp: 0 + } } + + describe('build requests', () => { + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests([ + { + ortb2: { + site: { + page: 'http://test.com', + domain: 'test.com', + publisher: { + domain: 'test.com', + }, + }, + }, + bidder: 'adsinteractive', + sizes: [[300, 250]], + bidId: '32469kja92389', + params: { + adUnit: 'example_adunit_1', + }, + }, + ], bidderRequest); + expect(request[0].method).to.equal('POST'); + }); + it('sends bid request to adsinteractive endpoint', function () { + const request = spec.buildRequests([ + { + ortb2: { + site: { + page: 'http://test.com', + domain: 'test.com', + publisher: { + domain: 'test.com', + }, + }, + }, + bidder: 'adsinteractive', + sizes: [[300, 250]], + bidId: '32469kja92389', + params: { + adUnit: 'example_adunit_1', + }, + }, + ], bidderRequest); + expect(request[0].url).to.equal('https://pb.adsinteractive.com/prebid'); + }); + }); + + describe('inherited functions', () => { + const adapter = newBidder(spec); + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should return true when necessary information is found', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + + it('should return false when necessary information is not found', function () { + // empty bid + expect(spec.isBidRequestValid({ bidId: '', params: {} })).to.be.false; + + // empty bidId + bid.bidId = ''; + expect(spec.isBidRequestValid(bid)).to.be.false; + + // empty adUnit + bid.bidId = '32469kja92389'; + bid.params.adUnit = ''; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + + it('returns false when bidder not set to "adsinteractive"', function () { + const invalidBid = { + bidder: 'newyork', + sizes: [[300, 250]], + bidId: '32469kja92389', + params: { + adUnit: 'example_adunit_1', + }, + }; + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + + it('returns false when adUnit is not set in params', function () { + const invalidBid = { + bidder: 'adsinteractive', + sizes: [[300, 250]], + bidId: '32469kja92389', + params: {}, + }; + + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + describe('interpretResponse', function () { + let serverResponse; + let bidRequest = { data: { id: 'adsinteractiverequest-9320' } }; + + beforeEach(function () { + serverResponse = { + body: { + id: '239823rhaldf822', + seatbid: [ + { + bid: [ + { + id: 'fae50ca1-3f69-4b34-bf6d-b2eb0ae3376b', + impid: 'example_adunit_1', + price: 0.49, + netRevenue: true, + ttl: 1000, + meta: {advertiserDomains: []}, + adm: '', + crid: '932048jda99cr', + h: 250, + w: 300, + }, + ], + seat: 'adsinteractive', + }, + ], + cur: 'USD', + }, + }; + }); + + it('validate_response_params', function () { + const newResponse = spec.interpretResponse(serverResponse, bidRequest); + expect(newResponse[0].id).to.be.equal( + 'fae50ca1-3f69-4b34-bf6d-b2eb0ae3376b' + ); + expect(newResponse[0].requestId).to.be.equal( + 'adsinteractiverequest-9320' + ); + expect(newResponse[0].cpm).to.be.equal(0.49); + expect(newResponse[0].width).to.be.equal(300); + expect(newResponse[0].height).to.be.equal(250); + expect(newResponse[0].currency).to.be.equal('USD'); + expect(newResponse[0].ad).to.be.equal( + '' + ); + }); + + it('should correctly reorder the server response', function () { + const newResponse = spec.interpretResponse(serverResponse, bidRequest); + expect(newResponse.length).to.be.equal(1); + expect(newResponse[0]).to.deep.equal({ + id: 'fae50ca1-3f69-4b34-bf6d-b2eb0ae3376b', + requestId: 'adsinteractiverequest-9320', + cpm: 0.49, + netRevenue: true, + ttl: 1000, + width: 300, + height: 250, + meta: {advertiserDomains: []}, + creativeId: '932048jda99cr', + currency: 'USD', + ad: '', + }); + }); + + it('should not add responses if the cpm is 0 or null', function () { + serverResponse.body.seatbid[0].bid[0].price = 0; + let response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.deep.equal([]); + + serverResponse.body.seatbid[0].bid[0].price = null; + response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.deep.equal([]); + }); + it('should add responses if the cpm is valid', function () { + serverResponse.body.seatbid[0].bid[0].price = 0.5; + let response = spec.interpretResponse(serverResponse, bidRequest); + expect(response).to.not.deep.equal([]); + }); + }); +}); diff --git a/test/spec/modules/adtelligentBidAdapter_spec.js b/test/spec/modules/adtelligentBidAdapter_spec.js index 117a6d5966a..f271f638e98 100644 --- a/test/spec/modules/adtelligentBidAdapter_spec.js +++ b/test/spec/modules/adtelligentBidAdapter_spec.js @@ -11,13 +11,12 @@ const EXPECTED_ENDPOINTS = [ 'https://ghb.adtelligent.com/v2/auction/' ]; const aliasEP = { - appaloosa: 'https://ghb.hb.appaloosa.media/v2/auction/', - appaloosa_publisherSuffix: 'https://ghb.hb.appaloosa.media/v2/auction/', - onefiftytwomedia: 'https://ghb.ads.152media.com/v2/auction/', - navelix: 'https://ghb.hb.navelix.com/v2/auction/', - bidsxchange: 'https://ghb.hbd.bidsxchange.com/v2/auction/', - streamkey: 'https://ghb.hb.streamkey.net/v2/auction/', - janet: 'https://ghb.bidder.jmgads.com/v2/auction/', + 'janet_publisherSuffix': 'https://ghb.bidder.jmgads.com/v2/auction/', + 'streamkey': 'https://ghb.hb.streamkey.net/v2/auction/', + 'janet': 'https://ghb.bidder.jmgads.com/v2/auction/', + 'ocm': 'https://ghb.cenarius.orangeclickmedia.com/v2/auction/', + '9dotsmedia': 'https://ghb.platform.audiodots.com/v2/auction/', + 'copper6': 'https://ghb.app.copper6.com/v2/auction/', }; const DEFAULT_ADATPER_REQ = { bidderCode: 'adtelligent' }; @@ -151,6 +150,10 @@ const displayBidderRequestWithConsents = { gdprApplies: true, consentString: 'test' }, + gppConsent: { + gppString: 'abc12345234', + applicableSections: [7, 8] + }, uspConsent: 'iHaveIt' }; @@ -359,6 +362,10 @@ describe('adtelligentBidAdapter', () => { expect(bidRequestWithPubSettingsData.GDPR).to.be.equal(1); expect(bidRequestWithPubSettingsData.GDPRConsent).to.be.equal(displayBidderRequestWithConsents.gdprConsent.consentString); }); + it('sets GPP flags', () => { + expect(bidRequestWithPubSettingsData.GPP).to.be.equal(displayBidderRequestWithConsents.gppConsent.gppString); + expect(bidRequestWithPubSettingsData.GPPSid).to.be.equal('7,8'); + }); it('sets USP', () => { expect(bidRequestWithPubSettingsData.USP).to.be.equal(displayBidderRequestWithConsents.uspConsent); }) diff --git a/test/spec/modules/adtrgtmeBidAdapter_spec.js b/test/spec/modules/adtrgtmeBidAdapter_spec.js new file mode 100644 index 00000000000..fce270b4ea7 --- /dev/null +++ b/test/spec/modules/adtrgtmeBidAdapter_spec.js @@ -0,0 +1,802 @@ +import { expect } from 'chai'; +import { config } from 'src/config.js'; +import { BANNER } from 'src/mediaTypes.js'; +import { spec } from 'modules/adtrgtmeBidAdapter.js'; + +const DEFAULT_SID = 1220291391; +const DEFAULT_ZID = 1836455615; +const DEFAULT_BID_ID = '84ab500420319d'; + +const DEFAULT_AD_UNIT_CODE = '/1220291391/header-banner'; +const DEFAULT_AD_UNIT_TYPE = BANNER; +const DEFAULT_PARAMS_BID_OVERRIDE = {}; + +const ADAPTER_VERSION = '1.0.0'; +const PREBID_VERSION = '$prebid.version$'; +const INTEGRATION_METHOD = 'prebid.js'; + +// Utility functions +const generateBidRequest = ({bidId, adUnitCode, bidOverrideObject, zid, ortb2}) => { + const bidRequest = { + adUnitCode, + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + bidId, + bidderRequestsCount: 1, + bidder: 'adtrgtme', + bidderRequestId: '7101db09af0db2', + bidderWinsCount: 0, + mediaTypes: {}, + params: { + bidOverride: bidOverrideObject + }, + src: 'client', + transactionId: '5b17b67d-7704-4732-8cc9-5b1723e9bcf9', + ortb2 + }; + + const bannerObj = { + sizes: [[300, 250]] + }; + + bidRequest.mediaTypes.banner = bannerObj; + bidRequest.sizes = [[300, 250]]; + + bidRequest.params.sid = DEFAULT_SID; + if (typeof zid == 'number') { + bidRequest.params.zid = zid; + } + + return bidRequest; +} + +let generateBidderRequest = (bidRequestArray, adUnitCode, ortb2 = {}) => { + const bidderRequest = { + adUnitCode: adUnitCode || 'default-adUnitCode', + auctionId: 'd4c83a3b-18e4-4208-b98b-63848449c7aa', + auctionStart: new Date().getTime(), + bidderCode: 'adtrgtme', + bidderRequestId: '112f1c7c5d399a', + bids: bidRequestArray, + refererInfo: { + page: 'https://publisher-test.com', + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['https://publisher-test.com'], + }, + gdprConsent: { + consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA', + vendorData: {}, + gdprApplies: true + }, + start: new Date().getTime(), + timeout: 1000, + ortb2 + }; + + return bidderRequest; +}; + +const generateBuildRequestMock = ({bidId, adUnitCode, adUnitType, zid, bidOverrideObject, pubIdMode, ortb2}) => { + const bidRequestConfig = { + bidId: bidId || DEFAULT_BID_ID, + adUnitCode: adUnitCode || DEFAULT_AD_UNIT_CODE, + adUnitType: adUnitType || DEFAULT_AD_UNIT_TYPE, + zid: zid || DEFAULT_ZID, + bidOverrideObject: bidOverrideObject || DEFAULT_PARAMS_BID_OVERRIDE, + + pubIdMode: pubIdMode || false, + ortb2: ortb2 || {} + }; + const bidRequest = generateBidRequest(bidRequestConfig); + const validBidRequests = [bidRequest]; + const bidderRequest = generateBidderRequest(validBidRequests, adUnitCode, ortb2); + + return { bidRequest, validBidRequests, bidderRequest } +}; + +const generateAdmPayload = (admPayloadType) => { + let ADM_PAYLOAD; + switch (admPayloadType) { + case 'banner': + ADM_PAYLOAD = ''; // banner + break; + default: ''; break; + }; + + return ADM_PAYLOAD; +}; + +const generateResponseMock = (admPayloadType) => { + const bidResponse = { + id: 'fc0c35df-21fb-4f93-9ebd-88759dbe31f9', + impid: '274395c06a24e5', + adm: generateAdmPayload(admPayloadType), + price: 1, + w: 300, + h: 250, + crid: 'ssp-placement-name', + adomain: ['advertiser-domain.com'] + }; + + const serverResponse = { + body: { + id: 'fc0c35df-21fb-4f93-9ebd-88759dbe31f9', + seatbid: [{ bid: [ bidResponse ], seat: 13107 }] + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: admPayloadType}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + + return {serverResponse, data, bidderRequest}; +} + +// Unit tests +describe('adtrgtme Bid Adapter:', () => { + it('PLACEHOLDER TO PASS GULP', () => { + const obj = {}; + expect(obj).to.be.an('object'); + }); + + describe('Validate basic properties', () => { + it('should define the correct bidder code', () => { + expect(spec.code).to.equal('adtrgtme') + }); + }); + + describe('getUserSyncs()', () => { + const IMAGE_PIXEL_URL = 'http://image-pixel.com/foo/bar?1234&baz=true'; + const IFRAME_ONE_URL = 'http://image-iframe.com/foo/bar?1234&baz=true'; + const IFRAME_TWO_URL = 'http://image-iframe-two.com/foo/bar?1234&baz=true'; + + let serverResponses = []; + beforeEach(() => { + serverResponses[0] = { + body: { + ext: { + pixels: `` + } + } + } + }); + + after(() => { + serverResponses = undefined; + }); + + it('for only iframe enabled syncs', () => { + let syncOptions = { + iframeEnabled: true, + pixelEnabled: false + }; + let pixelsObjects = spec.getUserSyncs(syncOptions, serverResponses); + expect(pixelsObjects.length).to.equal(2); + expect(pixelsObjects).to.deep.equal( + [ + {type: 'iframe', 'url': IFRAME_ONE_URL}, + {type: 'iframe', 'url': IFRAME_TWO_URL} + ] + ) + }); + + it('for only pixel enabled syncs', () => { + let syncOptions = { + iframeEnabled: false, + pixelEnabled: true + }; + let pixelsObjects = spec.getUserSyncs(syncOptions, serverResponses); + expect(pixelsObjects.length).to.equal(1); + expect(pixelsObjects).to.deep.equal( + [ + {type: 'image', 'url': IMAGE_PIXEL_URL} + ] + ) + }); + + it('for both pixel and iframe enabled syncs', () => { + let syncOptions = { + iframeEnabled: true, + pixelEnabled: true + }; + let pixelsObjects = spec.getUserSyncs(syncOptions, serverResponses); + expect(pixelsObjects.length).to.equal(3); + expect(pixelsObjects).to.deep.equal( + [ + {type: 'iframe', 'url': IFRAME_ONE_URL}, + {type: 'image', 'url': IMAGE_PIXEL_URL}, + {type: 'iframe', 'url': IFRAME_TWO_URL} + ] + ) + }); + }); + + // Validate Bid Requests + describe('isBidRequestValid()', () => { + const INVALID_INPUT = [ + {}, + {params: {}}, + {params: {sid: '1234', zid: '4321'}}, + {params: {sid: '1220291391', zid: 4321}}, + {params: {zid: ''}}, + {params: {sid: '', zid: ''}}, + ]; + + INVALID_INPUT.forEach(input => { + it(`should determine that the bid is INVALID for the input ${JSON.stringify(input)}`, () => { + expect(spec.isBidRequestValid(input)).to.be.false; + }); + }); + + it('should determine that the bid is VALID if sid and zid are present on the params object', () => { + const validBid = { + params: { + sid: 1220291391, + zid: 1836455615 + } + }; + expect(spec.isBidRequestValid(validBid)).to.be.true; + }); + }); + + describe('Price Floor module support:', () => { + it('should get bidfloor from getFloor method', () => { + const { bidRequest, validBidRequests, bidderRequest } = generateBuildRequestMock({}); + bidRequest.params.bidOverride = {cur: 'EUR'}; + bidRequest.getFloor = (floorObj) => { + return { + floor: bidRequest.floors.values[floorObj.mediaType + '|300x250'], + currency: floorObj.currency, + mediaType: floorObj.mediaType + } + }; + bidRequest.floors = { + currency: 'EUR', + values: { + 'banner|300x250': 5.55 + } + }; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.cur).to.deep.equal(['EUR']); + expect(data.imp[0].bidfloor).is.a('number'); + expect(data.imp[0].bidfloor).to.equal(5.55); + }); + }); + + describe('Schain module support:', () => { + it('should send Global or Bidder specific schain', function () { + const { bidRequest, validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const globalSchain = { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'some-platform.com', + sid: '111111', + rid: bidRequest.bidId, + hp: 1 + }] + }; + bidRequest.schain = globalSchain; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + const schain = data.source.ext.schain; + expect(schain.nodes.length).to.equal(1); + expect(schain).to.equal(globalSchain); + }); + }); + + describe('First party data module - "Site" support (ortb2):', () => { + // Should not allow invalid "site" data types + const INVALID_ORTB2_TYPES = [ null, [], 123, 'unsupportedKeyName', true, false, undefined ]; + INVALID_ORTB2_TYPES.forEach(param => { + it(`should not allow invalid site types to be added to bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { site: param } + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site[param]).to.be.undefined; + }); + }); + + // Should add valid "site" params + const VALID_SITE_STRINGS = ['name', 'domain', 'page', 'ref', 'keywords']; + const VALID_SITE_ARRAYS = ['cat', 'sectioncat', 'pagecat']; + + VALID_SITE_STRINGS.forEach(param => { + it(`should allow supported site keys to be added bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + site: { + [param]: 'something' + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site[param]).to.exist; + expect(data.site[param]).to.be.a('string'); + expect(data.site[param]).to.be.equal(ortb2.site[param]); + }); + }); + + VALID_SITE_ARRAYS.forEach(param => { + it(`should determine that the ortb2.site Array key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + site: { + [param]: ['something'] + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site[param]).to.exist; + expect(data.site[param]).to.be.a('array'); + expect(data.site[param]).to.be.equal(ortb2.site[param]); + }); + }); + + // Should not allow invalid "site.content" data types + INVALID_ORTB2_TYPES.forEach(param => { + it(`should determine that the ortb2.site.content key is invalid and should not be added to bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + site: { + content: param + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.content).to.be.undefined; + }); + }); + + // Should not allow invalid "site.content" keys + it(`should not allow invalid ortb2.site.content object keys to be added to bid-request: {custom object}`, () => { + const ortb2 = { + site: { + content: { + fake: 'news', + unreal: 'param', + counterfit: 'data' + } + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.content).to.be.a('object'); + }); + + // Should append valid "site.content" keys + const VALID_CONTENT_STRINGS = ['id', 'title', 'language']; + VALID_CONTENT_STRINGS.forEach(param => { + it(`should determine that the ortb2.site String key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + site: { + content: { + [param]: 'something' + } + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.content[param]).to.exist; + expect(data.site.content[param]).to.be.a('string'); + expect(data.site.content[param]).to.be.equal(ortb2.site.content[param]); + }); + }); + + const VALID_CONTENT_ARRAYS = ['cat']; + VALID_CONTENT_ARRAYS.forEach(param => { + it(`should determine that the ortb2.site Array key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + site: { + content: { + [param]: ['something', 'something-else'] + } + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.content[param]).to.be.a('array'); + expect(data.site.content[param]).to.be.equal(ortb2.site.content[param]); + }); + }); + }); + + describe('First party data module - "User" support (ortb2):', () => { + // Global ortb2.user validations + // Should not allow invalid "user" data types + const INVALID_ORTB2_TYPES = [ null, [], 'unsupportedKeyName', true, false, undefined ]; + INVALID_ORTB2_TYPES.forEach(param => { + it(`should not allow invalid site types to be added to bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { user: param } + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.user[param]).to.be.undefined; + }); + }); + + // Should add valid "user" params + const VALID_USER_STRINGS = ['id', 'buyeruid', 'gender', 'keywords', 'customdata']; + VALID_USER_STRINGS.forEach(param => { + it(`should allow supported user string keys to be added bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + user: { + [param]: 'something' + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.user[param]).to.exist; + expect(data.user[param]).to.be.a('string'); + expect(data.user[param]).to.be.equal(ortb2.user[param]); + }); + }); + + const VALID_USER_OBJECTS = ['ext']; + VALID_USER_OBJECTS.forEach(param => { + it(`should allow supported user extObject keys to be added to the bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + user: { + [param]: {a: '123', b: '456'} + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.user[param]).to.exist; + expect(data.user[param]).to.be.a('object'); + expect(data.user[param]).to.be.deep.include({[param]: {a: '123', b: '456'}}); + config.setConfig({ortb2: {}}); + }); + }); + + // adUnit.ortb2Imp.ext.data + it(`should allow adUnit.ortb2Imp.ext.data object to be added to the bid-request`, () => { + let { validBidRequests, bidderRequest } = generateBuildRequestMock({}) + validBidRequests[0].ortb2Imp = { + ext: { + data: { + pbadslot: 'homepage-top-rect', + adUnitSpecificAttribute: '123' + } + } + }; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].ext.data).to.deep.equal(validBidRequests[0].ortb2Imp.ext.data); + }); + // adUnit.ortb2Imp.instl + it(`should allow adUnit.ortb2Imp.instl numeric boolean "1" to be added to the bid-request`, () => { + let { validBidRequests, bidderRequest } = generateBuildRequestMock({}) + validBidRequests[0].ortb2Imp = { + instl: 1 + }; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].instl).to.deep.equal(validBidRequests[0].ortb2Imp.instl); + }); + + it(`should prevent adUnit.ortb2Imp.instl boolean "true" to be added to the bid-request`, () => { + let { validBidRequests, bidderRequest } = generateBuildRequestMock({}) + validBidRequests[0].ortb2Imp = { + instl: true + }; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].instl).to.not.exist; + }); + + it(`should prevent adUnit.ortb2Imp.instl boolean "false" to be added to the bid-request`, () => { + let { validBidRequests, bidderRequest } = generateBuildRequestMock({}) + validBidRequests[0].ortb2Imp = { + instl: false + }; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].instl).to.not.exist; + }); + }); + + describe('GDPR & Consent:', () => { + it('should return request objects that do not send cookies if purpose 1 consent is not provided', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + bidderRequest.gdprConsent = { + consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA', + apiVersion: 2, + vendorData: { + purpose: { + consents: { + '1': false + } + } + }, + gdprApplies: true + }; + const options = spec.buildRequests(validBidRequests, bidderRequest)[0].options; + expect(options.withCredentials).to.be.false; + }); + }); + + describe('Endpoint & Impression Request Mode:', () => { + it('should route request to config override endpoint', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const sid = validBidRequests[0].params.sid; + const testOverrideEndpoint = 'http://new_bidder_host.com/ssp?s='; + config.setConfig({ + adtrgtme: { + endpoint: testOverrideEndpoint + } + }); + const response = spec.buildRequests(validBidRequests, bidderRequest)[0]; + expect(response).to.deep.include( + { + method: 'POST', + url: testOverrideEndpoint + sid + }); + }); + + it('should route request to endpoint + sid', () => { + config.setConfig({ + adtrgtme: {} + }); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const sid = validBidRequests[0].params.sid; + const response = spec.buildRequests(validBidRequests, bidderRequest); + expect(response[0]).to.deep.include({ + method: 'POST', + url: 'https://z.cdn.adtarget.market/ssp?prebid&s=' + sid + }); + }); + + it('should return a single request object for single request mode', () => { + let { bidRequest, validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const BID_ID_2 = '84ab50xxxxx'; + const BID_ZID_2 = 98876543210; + const AD_UNIT_CODE_2 = 'test-ad-unit-code-123'; + const { bidRequest: bidRequest2 } = generateBuildRequestMock({bidId: BID_ID_2, zid: BID_ZID_2, adUnitCode: AD_UNIT_CODE_2}); + validBidRequests = [bidRequest, bidRequest2]; + bidderRequest.bids = validBidRequests; + + config.setConfig({ + adtrgtme: { + singleRequestMode: true + } + }); + + const data = spec.buildRequests(validBidRequests, bidderRequest).data; + + expect(data.imp).to.be.an('array').with.lengthOf(2); + + expect(data.imp[0]).to.deep.include({ + id: DEFAULT_BID_ID, + ext: { + dfp_ad_unit_code: DEFAULT_AD_UNIT_CODE + } + }); + + expect(data.imp[1]).to.deep.include({ + id: BID_ID_2, + tagid: BID_ZID_2, + ext: { + dfp_ad_unit_code: AD_UNIT_CODE_2 + } + }); + }); + }); + + describe('Validate request filtering:', () => { + it('should not return request when no bids are present', function () { + let request = spec.buildRequests([]); + expect(request).to.be.undefined; + }); + + it('buildRequests(): should return an array with the correct amount of request objects', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const response = spec.buildRequests(validBidRequests, bidderRequest).bidderRequest; + expect(response.bids).to.be.an('array').to.have.lengthOf(1); + }); + }); + + describe('Request Headers validation:', () => { + it('should return request objects with the relevant custom headers and content type declaration', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + bidderRequest.gdprConsent.gdprApplies = false; + const options = spec.buildRequests(validBidRequests, bidderRequest).options; + expect(options).to.deep.equal( + { + contentType: 'application/json', + customHeaders: { + 'x-openrtb-version': '2.5' + }, + withCredentials: true + }); + }); + }); + + describe('Request Payload oRTB bid validation:', () => { + it('should generate a valid openRTB bid-request object in the data field', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const data = spec.buildRequests(validBidRequests, bidderRequest).data; + expect(data.site).to.deep.include({ + id: bidderRequest.bids[0].params.sid, + page: bidderRequest.refererInfo.page + }); + + expect(data.device).to.deep.equal({ + dnt: 0, + ua: navigator.userAgent, + ip: undefined + }); + + expect(data.regs).to.deep.equal({ + ext: { + 'us_privacy': '', + gdpr: 1 + } + }); + + expect(data.source).to.deep.equal({ + ext: { + hb: 1, + adapterver: ADAPTER_VERSION, + prebidver: PREBID_VERSION, + integration: { + name: INTEGRATION_METHOD, + ver: PREBID_VERSION + } + }, + fd: 1 + }); + + expect(data.cur).to.deep.equal(['USD']); + }); + + it('should generate a valid openRTB imp.ext object in the bid-request', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const bid = validBidRequests[0]; + const data = spec.buildRequests(validBidRequests, bidderRequest).data; + expect(data.imp[0].ext).to.deep.equal({ + dfp_ad_unit_code: DEFAULT_AD_UNIT_CODE + }); + }); + + it('should use siteId value as site.id in the outbound bid-request when using "pubId" integration mode', () => { + let { validBidRequests, bidderRequest } = generateBuildRequestMock({pubIdMode: true}); + validBidRequests[0].params.sid = 9876543210; + const data = spec.buildRequests(validBidRequests, bidderRequest).data; + expect(data.site.id).to.equal(9876543210); + }); + + it('should use placementId value as imp.tagid in the outbound bid-request when using "zid"', () => { + let { validBidRequests, bidderRequest } = generateBuildRequestMock({}), + TEST_ZID = 54321; + validBidRequests[0].params.zid = TEST_ZID; + const data = spec.buildRequests(validBidRequests, bidderRequest).data; + expect(data.imp[0].tagid).to.deep.equal(TEST_ZID); + }); + }); + + describe('Request Payload oRTB bid.imp validation:', () => { + // Validate Banner imp imp when adtrgtme.mode=undefined + it('should generate a valid "Banner" imp object', () => { + config.setConfig({ + adtrgtme: {} + }); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].banner).to.deep.equal({ + mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], + format: [{w: 300, h: 250}] + }); + }); + + // Validate Banner imp + it('should generate a valid "Banner" imp object', () => { + config.setConfig({ + adtrgtme: { mode: 'banner' } + }); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].banner).to.deep.equal({ + mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], + format: [{w: 300, h: 250}] + }); + }); + }); + + describe('interpretResponse()', () => { + describe('for mediaTypes: "banner"', () => { + it('should insert banner payload into response[0].ad', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ad).to.equal(''); + expect(response[0].mediaType).to.equal('banner'); + }) + }); + + describe('Support Advertiser domains', () => { + it('should append bid-response adomain to meta.advertiserDomains', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].meta.advertiserDomains).to.be.a('array'); + expect(response[0].meta.advertiserDomains[0]).to.equal('advertiser-domain.com'); + }) + }); + + describe('bid response Ad ID / Creative ID', () => { + it('should use adId if it exists in the bid-response', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const adId = 'bid-response-adId'; + serverResponse.body.seatbid[0].bid[0].adId = adId; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].adId).to.equal(adId); + }); + + it('should use impid if adId does not exist in the bid-response', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const impid = '25b6c429c1f52f'; + serverResponse.body.seatbid[0].bid[0].impid = impid; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].adId).to.equal(impid); + }); + + it('should use crid if adId & impid do not exist in the bid-response', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const crid = 'passback-12579'; + serverResponse.body.seatbid[0].bid[0].impid = undefined; + serverResponse.body.seatbid[0].bid[0].crid = crid; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].adId).to.equal(crid); + }); + }); + + describe('Time To Live (ttl)', () => { + const UNSUPPORTED_TTL_FORMATS = ['string', [1, 2, 3], true, false, null, undefined]; + UNSUPPORTED_TTL_FORMATS.forEach(param => { + it('should not allow unsupported global adtrgtme.ttl formats and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + config.setConfig({ + adtrgtme: { ttl: param } + }); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); + }); + + it('should not allow unsupported params.ttl formats and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + bidderRequest.bids[0].params.ttl = param; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); + }); + }); + + const UNSUPPORTED_TTL_VALUES = [-1, 3601]; + UNSUPPORTED_TTL_VALUES.forEach(param => { + it('should not allow invalid global adtrgtme.ttl values 3600 < ttl < 0 and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + config.setConfig({ + adtrgtme: { ttl: param } + }); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); + }); + + it('should not allow invalid params.ttl values 3600 < ttl < 0 and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + bidderRequest.bids[0].params.ttl = param; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); + }); + }); + + it('should give presedence to Gloabl ttl over params.ttl ', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + config.setConfig({ + adtrgtme: { ttl: 500 } + }); + bidderRequest.bids[0].params.ttl = 400; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(500); + }); + }); + + describe('Aliasing support', () => { + it('should return undefined as the bidder code value', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].bidderCode).to.be.undefined; + }); + }); + }); +}); diff --git a/test/spec/modules/adtrueBidAdapter_spec.js b/test/spec/modules/adtrueBidAdapter_spec.js index b499d077a3c..df8f9013534 100644 --- a/test/spec/modules/adtrueBidAdapter_spec.js +++ b/test/spec/modules/adtrueBidAdapter_spec.js @@ -28,7 +28,11 @@ describe('AdTrueBidAdapter', function () { bidId: '23acc48ad47af5', requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + ortb2Imp: { + ext: { + tid: '92489f71-1bf2-49a0-adf9-000cea934729', + } + }, schain: { 'ver': '1.0', 'complete': 1, @@ -280,8 +284,8 @@ describe('AdTrueBidAdapter', function () { expect(data.cur[0]).to.equal('USD'); // currency expect(data.site.domain).to.be.a('string'); // domain should be set expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId - expect(data.source.tid).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId + expect(data.source.tid).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.reserve); // reverse expect(data.imp[0].tagid).to.equal(bidRequests[0].params.zoneId); // zoneId @@ -303,8 +307,8 @@ describe('AdTrueBidAdapter', function () { expect(data.cur[0]).to.equal('USD'); // currency expect(data.site.domain).to.be.a('string'); // domain should be set expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId - expect(data.source.tid).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId + expect(data.source.tid).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.reserve)); // reverse expect(data.imp[0].tagid).to.equal(bidRequests[0].params.zoneId); // zoneId @@ -323,8 +327,8 @@ describe('AdTrueBidAdapter', function () { expect(data.cur[0]).to.equal('USD'); // currency expect(data.site.domain).to.be.a('string'); // domain should be set expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId - expect(data.source.tid).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId + expect(data.source.tid).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.imp[0].id).to.equal(bidRequests[0].bidId); // Prebid bid id is passed as id expect(data.imp[0].bidfloor).to.equal(parseFloat(bidRequests[0].params.reserve)); // reverse expect(data.imp[0].tagid).to.equal(bidRequests[0].params.zoneId); // zoneId diff --git a/test/spec/modules/aduptechBidAdapter_spec.js b/test/spec/modules/aduptechBidAdapter_spec.js index 362cd3e506a..2b909ebe20d 100644 --- a/test/spec/modules/aduptechBidAdapter_spec.js +++ b/test/spec/modules/aduptechBidAdapter_spec.js @@ -77,59 +77,41 @@ describe('AduptechBidAdapter', () => { }); it('should handle empty or missing data', () => { - expect(internal.extractPageUrl(null)).to.equal(utils.getWindowTop().location.href); - expect(internal.extractPageUrl({})).to.equal(utils.getWindowTop().location.href); - expect(internal.extractPageUrl({ refererInfo: {} })).to.equal(utils.getWindowTop().location.href); - expect(internal.extractPageUrl({ refererInfo: { canonicalUrl: null } })).to.equal(utils.getWindowTop().location.href); - expect(internal.extractPageUrl({ refererInfo: { canonicalUrl: '' } })).to.equal(utils.getWindowTop().location.href); + expect(internal.extractPageUrl(null)).to.equal(utils.getWindowSelf().location.href); + expect(internal.extractPageUrl({})).to.equal(utils.getWindowSelf().location.href); + expect(internal.extractPageUrl({ refererInfo: {} })).to.equal(utils.getWindowSelf().location.href); + expect(internal.extractPageUrl({ refererInfo: { canonicalUrl: null } })).to.equal(utils.getWindowSelf().location.href); + expect(internal.extractPageUrl({ refererInfo: { canonicalUrl: '' } })).to.equal(utils.getWindowSelf().location.href); }); - it('should use "pageUrl" from config', () => { - config.setConfig({ pageUrl: 'http://page.url' }); - - expect(internal.extractPageUrl({})).to.equal(config.getConfig('pageUrl')); - }); - - it('should use bidderRequest.refererInfo.canonicalUrl', () => { + it('should use bidderRequest.refererInfo.page', () => { const bidderRequest = { refererInfo: { - canonicalUrl: 'http://canonical.url' + page: 'http://canonical.url' } }; - expect(internal.extractPageUrl(bidderRequest)).to.equal(bidderRequest.refererInfo.canonicalUrl); - }); - - it('should prefer bidderRequest.refererInfo.canonicalUrl over "pageUrl" from config', () => { - const bidderRequest = { - refererInfo: { - canonicalUrl: 'http://canonical.url' - } - }; - - config.setConfig({ pageUrl: 'http://page.url' }); - - expect(internal.extractPageUrl(bidderRequest)).to.equal(bidderRequest.refererInfo.canonicalUrl); + expect(internal.extractPageUrl(bidderRequest)).to.equal(bidderRequest.refererInfo.page); }); }); describe('extractReferrer', () => { it('should handle empty or missing data', () => { - expect(internal.extractReferrer(null)).to.equal(utils.getWindowTop().document.referrer); - expect(internal.extractReferrer({})).to.equal(utils.getWindowTop().document.referrer); - expect(internal.extractReferrer({ refererInfo: {} })).to.equal(utils.getWindowTop().document.referrer); - expect(internal.extractReferrer({ refererInfo: { referer: null } })).to.equal(utils.getWindowTop().document.referrer); - expect(internal.extractReferrer({ refererInfo: { referer: '' } })).to.equal(utils.getWindowTop().document.referrer); + expect(internal.extractReferrer(null)).to.equal(utils.getWindowSelf().document.referrer); + expect(internal.extractReferrer({})).to.equal(utils.getWindowSelf().document.referrer); + expect(internal.extractReferrer({ refererInfo: {} })).to.equal(utils.getWindowSelf().document.referrer); + expect(internal.extractReferrer({ refererInfo: { referer: null } })).to.equal(utils.getWindowSelf().document.referrer); + expect(internal.extractReferrer({ refererInfo: { referer: '' } })).to.equal(utils.getWindowSelf().document.referrer); }); - it('hould use bidderRequest.refererInfo.referer', () => { + it('hould use bidderRequest.refererInfo.ref', () => { const bidderRequest = { refererInfo: { - referer: 'foobar' + ref: 'foobar' } }; - expect(internal.extractReferrer(bidderRequest)).to.equal(bidderRequest.refererInfo.referer); + expect(internal.extractReferrer(bidderRequest)).to.equal(bidderRequest.refererInfo.ref); }); }); @@ -200,6 +182,54 @@ describe('AduptechBidAdapter', () => { }); }); + describe('getFloor', () => { + let bidRequest; + + beforeEach(() => { + bidRequest = { + getFloor: sinon.stub() + }; + }); + + it('should handle empty or invalid bidRequest', () => { + expect(internal.getFloor(null)).to.be.null; + expect(internal.getFloor({})).to.be.null; + expect(internal.getFloor({ getFloor: 'foo' })).to.be.null; + }); + + it('should detect floor via getFloor()', () => { + const result = { + floor: 1.11, + currency: 'USD' + }; + + const options = { + mediaType: BANNER, + size: '*' + } + + bidRequest.getFloor.returns(result); + + expect(internal.getFloor(bidRequest, options)).to.deep.equal(result); + expect(bidRequest.getFloor.calledOnceWith(options)).to.be.true; + }); + + it('should handle empty, invalid or faulty getFloor() results', () => { + bidRequest.getFloor + .onCall(0).returns({}) + .onCall(1).returns({ floor: 'foo' }) + .onCall(2).returns('bar') + .onCall(3).throws(new Error('baz')); + + expect(internal.getFloor(bidRequest, {})).to.be.null; + expect(internal.getFloor(bidRequest, {})).to.be.null; + expect(internal.getFloor(bidRequest, {})).to.be.null; + expect(internal.getFloor(bidRequest, {})).to.be.null; + + expect(bidRequest.getFloor.callCount).to.equal(4); + }); + }); + describe('groupBidRequestsByPublisher', () => { it('should handle empty bidRequests', () => { expect(internal.groupBidRequestsByPublisher(null)).to.deep.equal({}); @@ -426,8 +456,8 @@ describe('AduptechBidAdapter', () => { const bidderRequest = { auctionId: 'auctionId123', refererInfo: { - canonicalUrl: 'http://crazy.canonical.url', - referer: 'http://crazy.referer.url' + page: 'http://crazy.canonical.url', + ref: 'http://crazy.referer.url' }, gdprConsent: { consentString: 'consentString123', @@ -439,7 +469,11 @@ describe('AduptechBidAdapter', () => { { bidId: 'bidId1', adUnitCode: 'adUnitCode1', - transactionId: 'transactionId1', + ortb2Imp: { + ext: { + tid: 'transactionId1', + } + }, mediaTypes: { banner: { sizes: [[100, 200], [300, 400]] @@ -453,7 +487,11 @@ describe('AduptechBidAdapter', () => { { bidId: 'bidId2', adUnitCode: 'adUnitCode2', - transactionId: 'transactionId2', + ortb2Imp: { + ext: { + tid: 'transactionId2', + } + }, mediaTypes: { banner: { sizes: [[100, 200]] @@ -467,7 +505,13 @@ describe('AduptechBidAdapter', () => { { bidId: 'bidId3', adUnitCode: 'adUnitCode3', - transactionId: 'transactionId3', + ortb2Imp: { + ext: { + tid: { + transactionId: 'transactionId3', + } + } + }, mediaTypes: { native: { image: { @@ -497,8 +541,8 @@ describe('AduptechBidAdapter', () => { method: ENDPOINT_METHOD, data: { auctionId: bidderRequest.auctionId, - pageUrl: bidderRequest.refererInfo.canonicalUrl, - referrer: bidderRequest.refererInfo.referer, + pageUrl: bidderRequest.refererInfo.page, + referrer: bidderRequest.refererInfo.ref, gdpr: { consentString: bidderRequest.gdprConsent.consentString, consentRequired: bidderRequest.gdprConsent.gdprApplies @@ -506,14 +550,14 @@ describe('AduptechBidAdapter', () => { imp: [ { bidId: validBidRequests[0].bidId, - transactionId: validBidRequests[0].transactionId, + transactionId: validBidRequests[0].ortb2Imp.ext.tid, adUnitCode: validBidRequests[0].adUnitCode, params: validBidRequests[0].params, banner: validBidRequests[0].mediaTypes.banner }, { bidId: validBidRequests[1].bidId, - transactionId: validBidRequests[1].transactionId, + transactionId: validBidRequests[1].ortb2Imp.ext.tid, adUnitCode: validBidRequests[1].adUnitCode, params: validBidRequests[1].params, banner: validBidRequests[1].mediaTypes.banner @@ -526,8 +570,8 @@ describe('AduptechBidAdapter', () => { method: ENDPOINT_METHOD, data: { auctionId: bidderRequest.auctionId, - pageUrl: bidderRequest.refererInfo.canonicalUrl, - referrer: bidderRequest.refererInfo.referer, + pageUrl: bidderRequest.refererInfo.page, + referrer: bidderRequest.refererInfo.ref, gdpr: { consentString: bidderRequest.gdprConsent.consentString, consentRequired: bidderRequest.gdprConsent.gdprApplies @@ -535,7 +579,7 @@ describe('AduptechBidAdapter', () => { imp: [ { bidId: validBidRequests[2].bidId, - transactionId: validBidRequests[2].transactionId, + transactionId: validBidRequests[2].ortb2Imp.ext.tid, adUnitCode: validBidRequests[2].adUnitCode, params: validBidRequests[2].params, native: validBidRequests[2].mediaTypes.native @@ -545,6 +589,98 @@ describe('AduptechBidAdapter', () => { } ]); }); + + it('should build a request with floorPrices', () => { + const bidderRequest = { + auctionId: 'auctionId123', + refererInfo: { + page: 'http://crazy.canonical.url', + ref: 'http://crazy.referer.url' + }, + gdprConsent: { + consentString: 'consentString123', + gdprApplies: true + } + }; + + const bidRequest = { + bidId: 'bidId1', + adUnitCode: 'adUnitCode1', + ortb2Imp: { + ext: { + tid: 'transactionId1', + } + }, + mediaTypes: { + banner: { + sizes: [[100, 200], [300, 400]] + }, + native: { + image: { + required: true + }, + } + }, + params: { + publisher: 'publisher1', + placement: 'placement1' + }, + getFloor: sinon.stub() + .onCall(0).returns({ floor: 1.11, currency: 'USD' }) + .onCall(1).returns({ floor: 2.22, currency: 'EUR' }) + .onCall(2).returns({ floor: 3.33, currency: 'USD' }) + .onCall(3).returns({ floor: 4.44, currency: 'GBP' }) + .onCall(4).returns({ floor: 5.55, currency: 'EUR' }) + }; + + expect(spec.buildRequests([bidRequest], bidderRequest)).to.deep.equal([ + { + url: internal.buildEndpointUrl(bidRequest.params.publisher), + method: ENDPOINT_METHOD, + data: { + auctionId: bidderRequest.auctionId, + pageUrl: bidderRequest.refererInfo.page, + referrer: bidderRequest.refererInfo.ref, + gdpr: { + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: bidderRequest.gdprConsent.gdprApplies + }, + imp: [ + { + bidId: bidRequest.bidId, + transactionId: bidRequest.ortb2Imp.ext.tid, + adUnitCode: bidRequest.adUnitCode, + params: bidRequest.params, + banner: { + sizes: [ + [100, 200, 1.11, 'USD'], + [300, 400, 2.22, 'EUR'], + ], + floorPrice: 3.33, + floorCurrency: 'USD' + }, + native: { + image: { + required: true + }, + floorPrice: 4.44, + floorCurrency: 'GBP' + }, + floorPrice: 5.55, + floorCurrency: 'EUR' + } + ] + } + } + ]); + + expect(bidRequest.getFloor.callCount).to.equal(5); + expect(bidRequest.getFloor.getCall(0).calledWith({ mediaType: BANNER, size: bidRequest.mediaTypes.banner.sizes[0] })).to.be.true; + expect(bidRequest.getFloor.getCall(1).calledWith({ mediaType: BANNER, size: bidRequest.mediaTypes.banner.sizes[1] })).to.be.true; + expect(bidRequest.getFloor.getCall(2).calledWith({ mediaType: BANNER, size: '*' })).to.be.true; + expect(bidRequest.getFloor.getCall(3).calledWith({ mediaType: NATIVE, size: '*' })).to.be.true; + expect(bidRequest.getFloor.getCall(4).calledWith({ mediaType: '*', size: '*' })).to.be.true; + }); }); describe('interpretResponse', () => { diff --git a/test/spec/modules/advangelistsBidAdapter_spec.js b/test/spec/modules/advangelistsBidAdapter_spec.js index e1cd6977c5d..143d85a1ab6 100755 --- a/test/spec/modules/advangelistsBidAdapter_spec.js +++ b/test/spec/modules/advangelistsBidAdapter_spec.js @@ -93,7 +93,6 @@ describe('advangelistsBidAdapter', function () { delete bidResponseVid['ad']; expect(bidResponseVid).to.deep.equal({ requestId: bidRequestsVid[0].bidId, - bidderCode: 'advangelists', creativeId: serverResponseVid.seatbid[0].bid[0].crid, cpm: serverResponseVid.seatbid[0].bid[0].price, width: serverResponseVid.seatbid[0].bid[0].w, diff --git a/test/spec/modules/adxcgBidAdapter_spec.js b/test/spec/modules/adxcgBidAdapter_spec.js index 7721295572c..65c7584b428 100644 --- a/test/spec/modules/adxcgBidAdapter_spec.js +++ b/test/spec/modules/adxcgBidAdapter_spec.js @@ -52,7 +52,7 @@ describe('Adxcg adapter', function () { adzoneid: '19910113' } }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page', domain: 'localhost'}}); assert.equal(request.method, 'POST'); assert.equal(request.url, 'https://pbc.adxcg.net/rtb/ortb/pbc?adExchangeId=1'); @@ -164,11 +164,13 @@ describe('Adxcg adapter', function () { let validBidRequests = [{ bidId: 'bidId', params: {siteId: 'siteId'}, - transactionId: 'transactionId' }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, { + refererInfo: {referer: 'page'}, + ortb2: {source: {tid: 'tid'}} + }).data); - assert.equal(request.source.tid, validBidRequests[0].transactionId); + assert.equal(request.source.tid, 'tid'); assert.equal(request.source.fd, 1); }); @@ -180,7 +182,7 @@ describe('Adxcg adapter', function () { bidId: 'bidId', params: {adzoneid: '1000'} }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {page: 'page', domain: 'localhost'}}).data); assert.equal(request.device.ua, navigator.userAgent); assert.equal(request.device.w, 100); @@ -190,13 +192,14 @@ describe('Adxcg adapter', function () { it('should send app info', function () { config.setConfig({ app: {id: 'appid'}, - ortb2: {app: {name: 'appname'}} }); + const ortb2 = {app: {name: 'appname'}} let validBidRequests = [{ bidId: 'bidId', - params: {adzoneid: '1000'} + params: {adzoneid: '1000'}, + ortb2 }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}).data); + let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}, ortb2}).data); assert.equal(request.app.id, 'appid'); assert.equal(request.app.name, 'appname'); @@ -211,26 +214,28 @@ describe('Adxcg adapter', function () { domain: 'publisher.domain.com' } }, - ortb2: { - site: { - publisher: { - id: 4441, - name: 'publisher\'s name' - } + }); + const ortb2 = { + site: { + publisher: { + id: 4441, + name: 'publisher\'s name' } } - }); + }; + let validBidRequests = [{ bidId: 'bidId', - params: {adzoneid: '1000'} + params: {adzoneid: '1000'}, + ortb2 }]; - let refererInfo = {referer: 'page'}; - let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo}).data); + let refererInfo = {page: 'page', domain: 'localhost'}; + let request = JSON.parse(spec.buildRequests(validBidRequests, {refererInfo, ortb2}).data); assert.deepEqual(request.site, { domain: 'localhost', id: '123123', - page: refererInfo.referer, + page: refererInfo.page, publisher: { domain: 'publisher.domain.com', id: 4441, diff --git a/test/spec/modules/adxpremiumAnalyticsAdapter_spec.js b/test/spec/modules/adxpremiumAnalyticsAdapter_spec.js index e4a8fa9dccd..fd698e9e1fd 100644 --- a/test/spec/modules/adxpremiumAnalyticsAdapter_spec.js +++ b/test/spec/modules/adxpremiumAnalyticsAdapter_spec.js @@ -122,7 +122,7 @@ describe('AdxPremium analytics adapter', function () { 'auctionStart': 1589707613899, 'timeout': 2000, 'refererInfo': { - 'referer': 'https://test.com/article/176067', + 'page': 'https://test.com/article/176067', 'reachedTop': true, 'numIframes': 0, 'stack': [ @@ -222,7 +222,7 @@ describe('AdxPremium analytics adapter', function () { 'auctionStart': 1589707613899, 'timeout': 2000, 'refererInfo': { - 'referer': 'https://test.com/article/176067', + 'page': 'https://test.com/article/176067', 'reachedTop': true, 'numIframes': 0, 'stack': [ diff --git a/test/spec/modules/adyoulikeBidAdapter_spec.js b/test/spec/modules/adyoulikeBidAdapter_spec.js index 3e68a10f56e..ffd6729397a 100644 --- a/test/spec/modules/adyoulikeBidAdapter_spec.js +++ b/test/spec/modules/adyoulikeBidAdapter_spec.js @@ -2,10 +2,13 @@ import { expect } from 'chai'; import { spec } from 'modules/adyoulikeBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; describe('Adyoulike Adapter', function () { const canonicalUrl = 'https://canonical.url/?t=%26'; const referrerUrl = 'http://referrer.url/?param=value'; + const pageUrl = 'http://page.url/?param=value'; + const domain = 'domain:123'; const defaultDC = 'hb-api'; const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; const bidderRequest = { @@ -16,7 +19,8 @@ describe('Adyoulike Adapter', function () { consentString: consentString, gdprApplies: true }, - refererInfo: {referer: referrerUrl} + refererInfo: {location: referrerUrl, canonicalUrl, domain, topmostLocation: 'fakePageURL'}, + ortb2: {site: {page: pageUrl, ref: referrerUrl}} }; const bidRequestWithEmptyPlacement = [ { @@ -41,7 +45,11 @@ describe('Adyoulike Adapter', function () { 'params': { 'placement': 'placement_0' }, - 'transactionId': 'bid_id_0_transaction_id' + 'ortb2Imp': { + 'ext': { + 'tid': 'bid_id_0_transaction_id' + } + }, } ], }; @@ -91,7 +99,25 @@ describe('Adyoulike Adapter', function () { } }, }, - 'transactionId': 'bid_id_0_transaction_id' + 'schain': { + validation: 'strict', + config: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1 + } + ] + } + }, + ortb2Imp: { + ext: { + tid: 'bid_id_0_transaction_id' + } + } } ]; @@ -125,7 +151,11 @@ describe('Adyoulike Adapter', function () { }, } }, - 'transactionId': 'bid_id_0_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_0_transaction_id' + } + }, } ]; @@ -145,7 +175,11 @@ describe('Adyoulike Adapter', function () { 'playerSize': [[ 640, 480 ]] } }, - 'transactionId': 'bid_id_0_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_0_transaction_id' + } + }, } ]; @@ -168,7 +202,11 @@ describe('Adyoulike Adapter', function () { } }, }, - 'transactionId': 'bid_id_0_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_0_transaction_id' + } + }, } ]; @@ -269,7 +307,11 @@ describe('Adyoulike Adapter', function () { {'sizes': ['300x250'] } }, - 'transactionId': 'bid_id_0_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_0_transaction_id' + } + }, } ]; @@ -287,7 +329,11 @@ describe('Adyoulike Adapter', function () { {'sizes': ['300x250'] } }, - 'transactionId': 'bid_id_0_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_0_transaction_id' + } + }, }, { 'bidId': 'bid_id_1', @@ -302,7 +348,11 @@ describe('Adyoulike Adapter', function () { {'sizes': ['300x600'] } }, - 'transactionId': 'bid_id_1_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_1_transaction_id' + } + }, }, { 'bidId': 'bid_id_2', @@ -310,7 +360,11 @@ describe('Adyoulike Adapter', function () { 'placementCode': 'adunit/hb-2', 'params': {}, 'sizes': '300x400', - 'transactionId': 'bid_id_2_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_2_transaction_id' + } + }, }, { 'bidId': 'bid_id_3', @@ -319,7 +373,11 @@ describe('Adyoulike Adapter', function () { 'params': { 'placement': 'placement_3' }, - 'transactionId': 'bid_id_3_transaction_id' + ortb2Imp: { + ext: { + tid: 'bid_id_3_transaction_id' + } + }, } ]; @@ -578,20 +636,6 @@ describe('Adyoulike Adapter', function () { }); describe('buildRequests', function () { - let canonicalQuery; - - beforeEach(function () { - let canonical = document.createElement('link'); - canonical.rel = 'canonical'; - canonical.href = canonicalUrl; - canonicalQuery = sinon.stub(window.top.document.head, 'querySelector'); - canonicalQuery.withArgs('link[rel="canonical"][href]').returns(canonical); - }); - - afterEach(function () { - canonicalQuery.restore(); - }); - it('Should expand short native image config type', function() { const request = spec.buildRequests(bidRequestWithNativeImageType, bidderRequest); const payload = JSON.parse(request.data); @@ -600,7 +644,8 @@ describe('Adyoulike Adapter', function () { expect(request.method).to.equal('POST'); expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); - expect(request.url).to.contains('PublisherDomain=http%3A%2F%2Flocalhost%3A9876'); + expect(request.url).to.contains('PageUrl=' + encodeURIComponent(pageUrl)); + expect(request.url).to.contains('PageReferrer=' + encodeURIComponent(referrerUrl)); expect(payload.Version).to.equal('1.0'); expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); @@ -614,7 +659,7 @@ describe('Adyoulike Adapter', function () { expect(request.url).to.contain(getEndpoint()); }); - it('should add gdpr/usp consent information to the request', function () { + it('should add gdpr/usp consent information and SChain to the request', function () { let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; let uspConsentData = '1YCC'; let bidderRequest = { @@ -637,6 +682,7 @@ describe('Adyoulike Adapter', function () { expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); expect(payload.gdprConsent.consentRequired).to.exist.and.to.be.true; expect(payload.uspConsent).to.exist.and.to.equal(uspConsentData); + expect(payload.Bids.bid_id_0.SChain).to.exist.and.to.deep.equal(bidRequestWithSinglePlacement[0].schain); }); it('should not set a default value for gdpr consentRequired', function () { @@ -662,30 +708,21 @@ describe('Adyoulike Adapter', function () { expect(payload.gdprConsent.consentRequired).to.be.null; }); - it('should add userid eids information to the request', function () { - let bidderRequest = { - 'auctionId': '1d1a030790a475', - 'bidderRequestId': '22edbae2733bf6', - 'timeout': 3000, - 'userId': { - pubcid: '01EAJWWNEPN3CYMM5N8M5VXY22', - unsuported: '666' - } - }; - - bidderRequest.bids = bidRequestWithSinglePlacement; - - const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.userId).to.exist; - expect(payload.userId).to.deep.equal([{ + it('should add eids eids information to the request', function () { + let bidRequest = bidRequestWithSinglePlacement; + bidRequest[0].userIdAsEids = [{ 'source': 'pubcid.org', 'uids': [{ 'atype': 1, 'id': '01EAJWWNEPN3CYMM5N8M5VXY22' }] - }]); + }] + + const request = spec.buildRequests(bidRequest, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.eids).to.exist; + expect(payload.eids).to.deep.equal(bidRequest[0].userIdAsEids); }); it('sends bid request to endpoint with single placement', function () { @@ -696,17 +733,18 @@ describe('Adyoulike Adapter', function () { expect(request.method).to.equal('POST'); expect(request.url).to.contains('CanonicalUrl=' + encodeURIComponent(canonicalUrl)); expect(request.url).to.contains('RefererUrl=' + encodeURIComponent(referrerUrl)); - expect(request.url).to.contains('PublisherDomain=http%3A%2F%2Flocalhost%3A9876'); + expect(request.url).to.contains('PageUrl=' + encodeURIComponent(pageUrl)); + expect(request.url).to.contains('PageReferrer=' + encodeURIComponent(referrerUrl)); expect(payload.Version).to.equal('1.0'); expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); expect(payload.PageRefreshed).to.equal(false); expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id'); + expect(payload.ortb2).to.deep.equal({site: {page: pageUrl, ref: referrerUrl}}); }); it('sends bid request to endpoint with single placement without canonical', function () { - canonicalQuery.restore(); - const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); + const request = spec.buildRequests(bidRequestWithSinglePlacement, {...bidderRequest, refererInfo: {...bidderRequest.refererInfo, canonicalUrl: null}}); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); @@ -716,12 +754,12 @@ describe('Adyoulike Adapter', function () { expect(payload.Version).to.equal('1.0'); expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); expect(payload.PageRefreshed).to.equal(false); + expect(payload.pbjs_version).to.equal('$prebid.version$'); expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id'); }); it('sends bid request to endpoint with single placement multiple mediatype', function () { - canonicalQuery.restore(); - const request = spec.buildRequests(bidRequestWithMultipleMediatype, bidderRequest); + const request = spec.buildRequests(bidRequestWithSinglePlacement, {...bidderRequest, refererInfo: {...bidderRequest.refererInfo, canonicalUrl: null}}); const payload = JSON.parse(request.data); expect(request.url).to.contain(getEndpoint()); @@ -731,6 +769,7 @@ describe('Adyoulike Adapter', function () { expect(payload.Version).to.equal('1.0'); expect(payload.Bids['bid_id_0'].PlacementID).to.be.equal('placement_0'); expect(payload.PageRefreshed).to.equal(false); + expect(payload.pbjs_version).to.equal('$prebid.version$'); expect(payload.Bids['bid_id_0'].TransactionID).to.be.equal('bid_id_0_transaction_id'); }); @@ -753,6 +792,7 @@ describe('Adyoulike Adapter', function () { expect(payload.Bids['bid_id_1'].TransactionID).to.be.equal('bid_id_1_transaction_id'); expect(payload.Bids['bid_id_3'].TransactionID).to.be.equal('bid_id_3_transaction_id'); expect(payload.PageRefreshed).to.equal(false); + expect(payload.pbjs_version).to.equal('$prebid.version$'); }); it('sends bid request to endpoint setted by parameters', function () { @@ -848,4 +888,115 @@ describe('Adyoulike Adapter', function () { expect(spec.gvlid).to.equal(259) }) }); + + describe('getUserSyncs', function () { + const syncurl_iframe = 'https://visitor.omnitagjs.com/visitor/isync?uid=19340f4f097d16f41f34fc0274981ca4'; + + const emptySync = []; + + describe('with iframe enabled', function() { + const userSyncConfig = { iframeEnabled: true }; + + it('should not add parameters if not provided', function() { + expect(spec.getUserSyncs(userSyncConfig, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); + + it('should add GDPR parameters if provided', function() { + expect(spec.getUserSyncs(userSyncConfig, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=` + }]); + + expect(spec.getUserSyncs(userSyncConfig, {}, {gdprApplies: true, consentString: 'foo?'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=1&gdpr_consent=foo%3F` + }]); + expect(spec.getUserSyncs(userSyncConfig, {}, {gdprApplies: false, consentString: 'bar'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gdpr=0&gdpr_consent=bar` + }]); + }); + + it('should add CCPA parameters if provided', function() { + expect(spec.getUserSyncs(userSyncConfig, {}, undefined, 'foo?')).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&us_privacy=foo%3F` + }]); + }); + + describe('COPPA', function() { + let sandbox; + + this.beforeEach(function() { + sandbox = sinon.sandbox.create(); + }); + + this.afterEach(function() { + sandbox.restore(); + }); + + it('should add coppa parameters if provided', function() { + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + 'coppa': true + }; + return config[key]; + }); + + expect(spec.getUserSyncs(userSyncConfig, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&coppa=1` + }]); + }); + }); + + describe('GPP', function() { + it('should not apply if not gppConsent.gppString', function() { + const gppConsent = { gppString: '', applicableSections: [123] }; + const result = spec.getUserSyncs(userSyncConfig, {}, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); + + it('should not apply if not gppConsent.applicableSections', function() { + const gppConsent = { gppString: '', applicableSections: undefined }; + const result = spec.getUserSyncs(userSyncConfig, {}, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); + + it('should not apply if empty gppConsent.applicableSections', function() { + const gppConsent = { gppString: '', applicableSections: [] }; + const result = spec.getUserSyncs(userSyncConfig, {}, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); + + it('should apply if all above are available', function() { + const gppConsent = { gppString: 'foo?', applicableSections: [123] }; + const result = spec.getUserSyncs(userSyncConfig, {}, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gpp=foo%3F&gpp_sid=123` + }]); + }); + + it('should support multiple sections', function() { + const gppConsent = { gppString: 'foo', applicableSections: [123, 456] }; + const result = spec.getUserSyncs(userSyncConfig, {}, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gpp=foo&gpp_sid=123%2C456` + }]); + }); + }); + }); + + describe('with iframe disabled', function() { + const userSyncConfig = { iframeEnabled: false }; + + it('should return empty list of syncs', function() { + expect(spec.getUserSyncs(userSyncConfig, {}, undefined, undefined)).to.deep.equal(emptySync); + expect(spec.getUserSyncs(userSyncConfig, {}, {gdprApplies: true, consentString: 'foo'}, 'bar')).to.deep.equal(emptySync); + }); + }); + }); }); diff --git a/test/spec/modules/afpBidAdapter_spec.js b/test/spec/modules/afpBidAdapter_spec.js index 5b658a66351..12bd19da9ca 100644 --- a/test/spec/modules/afpBidAdapter_spec.js +++ b/test/spec/modules/afpBidAdapter_spec.js @@ -125,7 +125,11 @@ const getTransformedConfig = ({mediaTypes, params}) => { bidId, bidder: BIDDER_CODE, mediaTypes: mediaTypes, - transactionId, + ortb2Imp: { + ext: { + tid: transactionId + } + } } } const validBidRequests = Object.keys(configByPlaceType).map(key => getTransformedConfig(configByPlaceType[key])) diff --git a/test/spec/modules/aidemBidAdapter_spec.js b/test/spec/modules/aidemBidAdapter_spec.js new file mode 100644 index 00000000000..3de348197b2 --- /dev/null +++ b/test/spec/modules/aidemBidAdapter_spec.js @@ -0,0 +1,649 @@ +import {expect} from 'chai'; +import {setEndPoints, spec} from 'modules/aidemBidAdapter.js'; +import * as utils from '../../../src/utils'; +import {deepSetValue} from '../../../src/utils'; +import {server} from '../../mocks/xhr'; +import {config} from '../../../src/config'; +import {NATIVE} from '../../../src/mediaTypes.js'; + +// Full banner + Full Video + Basic Banner + Basic Video +const VALID_BIDS = [ + { + bidder: 'aidem', + params: { + siteId: '301491', + publisherId: '3021491', + placementId: '13144370', + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + }, + { + bidder: 'aidem', + params: { + siteId: '301491', + publisherId: '3021491', + placementId: '13144370', + }, + mediaTypes: { + video: { + context: 'instream', + minduration: 7, + maxduration: 30, + playerSize: [640, 480], + mimes: ['video/mp4'], + protocols: [2] + } + }, + }, +] + +const INVALID_BIDS = [ + { + bidder: 'aidem', + params: { + siteId: '3014912' + } + }, + { + bidder: 'aidem', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + params: { + siteId: '3014912', + } + }, + { + bidder: 'aidem', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + } + }, + params: { + publisherId: '3014912', + } + }, + { + bidder: 'aidem', + params: { + siteId: '3014912', + member: '301e4912' + } + }, + { + bidder: 'aidem', + params: { + siteId: '3014912', + invCode: '3014912' + } + }, + { + bidder: 'aidem', + mediaType: NATIVE, + params: { + siteId: '3014912' + } + }, + { + bidder: 'aidem', + mediaTypes: { + banner: {} + }, + }, + { + bidder: 'aidem', + mediaTypes: { + video: { + placement: 1, + minduration: 7, + maxduration: 30, + mimes: ['video/mp4'], + protocols: [2] + } + }, + params: { + siteId: '301491', + placementId: '13144370', + }, + }, + { + bidder: 'aidem', + mediaTypes: { + video: { + minduration: 7, + maxduration: 30, + playerSize: [640, 480], + mimes: ['video/mp4'], + protocols: [2] + } + }, + params: { + siteId: '301491', + placementId: '13144370', + }, + }, + { + bidder: 'aidem', + mediaTypes: { + video: { + minduration: 7, + maxduration: 30, + playerSize: [640, 480], + mimes: ['video/mp4'], + protocols: [2], + placement: 1 + } + }, + params: { + siteId: '301491', + placementId: '13144370', + video: { + size: [480, 40] + } + }, + }, +] + +const DEFAULT_VALID_BANNER_REQUESTS = [ + { + adUnitCode: 'test-div', + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + bidId: '2705bfae8ea667', + bidder: 'aidem', + bidderRequestId: '1bbb7854dfa0d8', + mediaTypes: { + banner: { + sizes: [ + [ 300, 250 ], + [ 300, 600 ] + ] + } + }, + params: { + siteId: '1', + placementId: '13144370' + }, + src: 'client', + transactionId: 'db739693-9b4a-4669-9945-8eab938783cc' + } +]; + +const DEFAULT_VALID_VIDEO_REQUESTS = [ + { + adUnitCode: 'test-div', + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + bidId: '2705bfae8ea667', + bidder: 'aidem', + bidderRequestId: '1bbb7854dfa0d8', + mediaTypes: { + video: { + minduration: 7, + maxduration: 30, + playerSize: [640, 480], + mimes: ['video/mp4'], + protocols: [2] + } + }, + params: { + siteId: '1', + placementId: '13144370' + }, + src: 'client', + transactionId: 'db739693-9b4a-4669-9945-8eab938783cc' + } +]; + +const VALID_BIDDER_REQUEST = { + auctionId: '19c97f22-5bd1-4b16-a128-80f75fb0a8a0', + bidderCode: 'aidem', + bidderRequestId: '1bbb7854dfa0d8', + bids: [ + { + params: { + placementId: '13144370', + siteId: '23434', + publisherId: '7689670753' + }, + } + ], + refererInfo: { + page: 'test-page', + domain: 'test-domain', + ref: 'test-referer' + }, +} + +const SERVER_RESPONSE_BANNER = { + 'id': '19c97f22-5bd1-4b16-a128-80f75fb0a8a0', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'beeswax/aidem', + 'impid': '2705bfae8ea667', + 'price': 0.00875, + 'burl': 'imp_burl', + 'adm': 'creativity_banner', + 'adid': '2:64:162:1001', + 'adomain': [ + 'aidem.com' + ], + 'cid': '64', + 'crid': 'aidem-1001', + 'cat': [], + 'w': 300, + 'h': 250, + 'mtype': 1 + } + ], + 'seat': 'aidemdsp', + 'group': 0 + } + ], + 'cur': 'USD' +} + +const SERVER_RESPONSE_VIDEO = { + 'id': '19c97f22-5bd1-4b16-a128-80f75fb0a8a0', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'beeswax/aidem', + 'impid': '2705bfae8ea667', + 'price': 0.00875, + 'burl': 'imp_burl', + 'adm': 'creativity_banner', + 'adid': '2:64:162:1001', + 'adomain': [ + 'aidem.com' + ], + 'cid': '64', + 'crid': 'aidem-1001', + 'cat': [], + 'w': 300, + 'h': 250, + 'mtype': 2 + } + ], + 'seat': 'aidemdsp', + 'group': 0 + } + ], + 'cur': 'USD' +} + +const WIN_NOTICE = { + burl: 'burl' +} + +const ERROR_NOTICE = { + 'message': 'Prebid.js: Server call for aidem failed.', + 'url': 'http%3A%2F%2Flocalhost%3A9999%2FintegrationExamples%2Fgpt%2Fhello_world.html%3Fpbjs_debug%3Dtrue', + 'auctionId': 'b57faab7-23f7-4b63-90db-67b259d20db7', + 'bidderRequestId': '1c53857d1ce616', + 'timeout': 1000, + 'bidderCode': 'aidem', + metrics: { + getMetrics() { + return { + + } + } + } +} + +describe('Aidem adapter', () => { + describe('isBidRequestValid', () => { + it('should return true for each valid bid requests', function () { + // spec.isBidRequestValid() + VALID_BIDS.forEach((value, index) => { + expect(spec.isBidRequestValid(value)).to.be.true + }) + }); + + it('should return false for each invalid bid requests', function () { + // spec.isBidRequestValid() + INVALID_BIDS.forEach((value, index) => { + expect(spec.isBidRequestValid(value)).to.be.false + }) + }); + + it('should return true if valid banner sizes are specified in params as single array', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[0]) + deepSetValue(validBannerRequest.params, 'banner.size', [300, 250]) + expect(spec.isBidRequestValid(validBannerRequest)).to.be.true + }); + + it('should return true if valid banner sizes are specified in params as array of array', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[0]) + deepSetValue(validBannerRequest.params, 'banner.size', [[300, 600]]) + expect(spec.isBidRequestValid(validBannerRequest)).to.be.true + }); + + it('should return true if valid video sizes are specified in params as single array', function () { + // spec.isBidRequestValid() + const validVideoRequest = utils.deepClone(VALID_BIDS[1]) + deepSetValue(validVideoRequest.params, 'video.size', [640, 480]) + expect(spec.isBidRequestValid(validVideoRequest)).to.be.true + }); + + it('BANNER: should return true if rateLimit is 1', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[0]) + deepSetValue(validBannerRequest.params, 'rateLimit', 1) + expect(spec.isBidRequestValid(validBannerRequest)).to.be.true + }); + + it('BANNER: should return false if rateLimit is 0', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[0]) + deepSetValue(validBannerRequest.params, 'rateLimit', 0) + expect(spec.isBidRequestValid(validBannerRequest)).to.be.false + }); + + it('BANNER: should return false if rateLimit is not between 0 and 1', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[0]) + deepSetValue(validBannerRequest.params, 'rateLimit', 1.2) + expect(spec.isBidRequestValid(validBannerRequest)).to.be.false + }); + + it('BANNER: should return false if rateLimit is not a number', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[0]) + deepSetValue(validBannerRequest.params, 'rateLimit', '0.5') + expect(spec.isBidRequestValid(validBannerRequest)).to.be.false + }); + + it('VIDEO: should return true if rateLimit is 1', function () { + // spec.isBidRequestValid() + const validVideoRequest = utils.deepClone(VALID_BIDS[1]) + deepSetValue(validVideoRequest.params, 'rateLimit', 1) + expect(spec.isBidRequestValid(validVideoRequest)).to.be.true + }); + + it('VIDEO: should return false if rateLimit is 0', function () { + // spec.isBidRequestValid() + const validVideoRequest = utils.deepClone(VALID_BIDS[1]) + deepSetValue(validVideoRequest.params, 'rateLimit', 0) + expect(spec.isBidRequestValid(validVideoRequest)).to.be.false + }); + + it('VIDEO: should return false if rateLimit is not between 0 and 1', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[1]) + deepSetValue(validBannerRequest.params, 'rateLimit', 1.2) + expect(spec.isBidRequestValid(validBannerRequest)).to.be.false + }); + + it('VIDEO: should return false if rateLimit is not a number', function () { + // spec.isBidRequestValid() + const validBannerRequest = utils.deepClone(VALID_BIDS[1]) + deepSetValue(validBannerRequest.params, 'rateLimit', '0.5') + expect(spec.isBidRequestValid(validBannerRequest)).to.be.false + }); + }); + + describe('buildRequests', () => { + it('should match server requirements', () => { + const requests = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + expect(requests).to.be.an('object'); + expect(requests.method).to.be.a('string') + expect(requests.data).to.be.a('object') + expect(requests.options).to.be.an('object').that.have.a.property('withCredentials') + }); + + it('should have a well formatted banner payload', () => { + const {data} = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + expect(data).to.be.a('object').that.has.all.keys( + 'id', 'imp', 'regs', 'site', 'environment', 'at', 'test' + ) + expect(data.imp).to.be.a('array').that.has.lengthOf(DEFAULT_VALID_BANNER_REQUESTS.length) + + expect(data.imp[0]).to.be.a('object').that.has.all.keys( + 'banner', 'id', 'tagId' + ) + expect(data.imp[0].banner).to.be.a('object').that.has.all.keys( + 'format', 'topframe' + ) + }); + + if (FEATURES.VIDEO) { + it('should have a well formatted video payload', () => { + const {data} = spec.buildRequests(DEFAULT_VALID_VIDEO_REQUESTS, VALID_BIDDER_REQUEST); + expect(data).to.be.a('object').that.has.all.keys( + 'id', 'imp', 'regs', 'site', 'environment', 'at', 'test' + ) + expect(data.imp).to.be.a('array').that.has.lengthOf(DEFAULT_VALID_VIDEO_REQUESTS.length) + + expect(data.imp[0]).to.be.a('object').that.has.all.keys( + 'video', 'id', 'tagId' + ) + expect(data.imp[0].video).to.be.a('object').that.has.all.keys( + 'mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h' + ) + }); + } + + it('should hav wpar keys in environment object', function () { + const {data} = spec.buildRequests(DEFAULT_VALID_VIDEO_REQUESTS, VALID_BIDDER_REQUEST); + expect(data).to.have.property('environment') + expect(data.environment).to.be.a('object').that.have.property('wpar') + expect(data.environment.wpar).to.be.a('object').that.has.keys('innerWidth', 'innerHeight') + }); + }) + + describe('interpretResponse', () => { + it('should return a valid bid array with a banner bid', () => { + const {data} = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST) + const bids = spec.interpretResponse({body: SERVER_RESPONSE_BANNER}, { data }) + expect(bids).to.be.a('array').that.has.lengthOf(1) + bids.forEach(value => { + expect(value).to.be.a('object').that.has.all.keys( + 'ad', 'cpm', 'creativeId', 'currency', 'height', 'mediaType', 'meta', 'netRevenue', 'requestId', 'ttl', 'width', 'burl', 'seatBidId', 'creative_id' + ) + }) + }); + + if (FEATURES.VIDEO) { + it('should return a valid bid array with a video bid', () => { + const {data} = spec.buildRequests(DEFAULT_VALID_VIDEO_REQUESTS, VALID_BIDDER_REQUEST) + const bids = spec.interpretResponse({body: SERVER_RESPONSE_VIDEO}, { data }) + expect(bids).to.be.a('array').that.has.lengthOf(1) + bids.forEach(value => { + expect(value).to.be.a('object').that.has.all.keys( + 'vastUrl', 'vastXml', 'playerHeight', 'playerWidth', 'cpm', 'creativeId', 'currency', 'height', 'mediaType', 'meta', 'netRevenue', 'requestId', 'ttl', 'width', 'burl', 'seatBidId', 'creative_id' + ) + }) + }); + } + + it('should return a valid bid array with netRevenue', () => { + const {data} = spec.buildRequests(DEFAULT_VALID_VIDEO_REQUESTS, VALID_BIDDER_REQUEST) + const bids = spec.interpretResponse({body: SERVER_RESPONSE_VIDEO}, { data }) + expect(bids).to.be.a('array').that.has.lengthOf(1) + expect(bids[0].netRevenue).to.be.true + }); + + // it('should return an empty bid array if one of seatbid entry is missing price property', () => { + // const response = utils.deepClone(SERVER_RESPONSE_BANNER) + // delete response.body.bid[0].price + // const interpreted = spec.interpretResponse(response) + // expect(interpreted).to.be.a('array').that.has.lengthOf(0) + // }); + + // it('should return an empty bid array if one of seatbid entry is missing adm property', () => { + // const response = utils.deepClone(SERVER_RESPONSE_BANNER) + // delete response.body.bid[0].adm + // const interpreted = spec.interpretResponse(response) + // expect(interpreted).to.be.a('array').that.has.lengthOf(0) + // }); + }) + + describe('onBidWon', () => { + it(`should exists and type function`, function () { + expect(spec.onBidWon).to.exist.and.to.be.a('function') + }); + + it(`should send a win notice`, function () { + spec.onBidWon(WIN_NOTICE); + expect(server.requests.length).to.equal(1); + }); + }); + + // describe('onBidderError', () => { + // it(`should exists and type function`, function () { + // expect(spec.onBidderError).to.exist.and.to.be.a('function') + // }); + // + // it(`should send a valid error notice`, function () { + // spec.onBidderError({ bidderRequest: ERROR_NOTICE }) + // expect(server.requests.length).to.equal(1); + // const body = JSON.parse(server.requests[0].requestBody) + // expect(body).to.be.a('object').that.has.all.keys('message', 'auctionId', 'bidderRequestId', 'url', 'metrics') + // // const { bids } = JSON.parse(server.requests[0].requestBody) + // // expect(bids).to.be.a('array').that.has.lengthOf(1) + // // _each(bids, (bid) => { + // // expect(bid).to.be.a('object').that.has.all.keys('adUnitCode', 'auctionId', 'bidId', 'bidderRequestId', 'transactionId', 'metrics') + // // }) + // }); + // }); + + describe('setEndPoints', () => { + it(`should exists and type function`, function () { + expect(setEndPoints).to.exist.and.to.be.a('function') + }); + + it(`should not modify default endpoints`, function () { + const endpoints = setEndPoints() + const requestURL = new URL(endpoints.request) + expect(requestURL.host).to.equal('zero.aidemsrv.com') + expect(decodeURIComponent(requestURL.pathname)).to.equal('/prebidjs/ortb/v2.6/bid/request') + }); + + it(`should not change request endpoint`, function () { + const endpoints = setEndPoints('default') + const requestURL = new URL(endpoints.request) + expect(decodeURIComponent(requestURL.pathname)).to.equal('/prebidjs/ortb/v2.6/bid/request') + }); + + it(`should change to local env`, function () { + const endpoints = setEndPoints('local') + const requestURL = new URL(endpoints.request) + + expect(requestURL.host).to.equal('127.0.0.1:8787') + }); + + it(`should add a path prefix`, function () { + const endpoints = setEndPoints('local', '/path') + const requestURL = new URL(endpoints.request) + + expect(decodeURIComponent(requestURL.pathname)).to.equal('/path/prebidjs/ortb/v2.6/bid/request') + }); + + it(`should add a path prefix and change request endpoint`, function () { + const endpoints = setEndPoints('local', '/path') + const requestURL = new URL(endpoints.request) + + expect(decodeURIComponent(requestURL.pathname)).to.equal('/path/prebidjs/ortb/v2.6/bid/request') + }); + }); + + describe('config', () => { + beforeEach(() => { + config.setConfig({ + aidem: { + env: 'main' + } + }); + }) + + it(`should not override default endpoints`, function () { + config.setConfig({ + aidem: { + env: 'unknown', + path: '/test' + } + }); + const { url } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + const requestURL = new URL(url) + expect(requestURL.host).to.equal('zero.aidemsrv.com') + }); + + it(`should set local endpoints`, function () { + config.setConfig({ + aidem: { + env: 'local', + path: '/test' + } + }); + const { url } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + const requestURL = new URL(url) + expect(requestURL.host).to.equal('127.0.0.1:8787') + }); + + it(`should set coppa`, function () { + config.setConfig({ + coppa: true + }); + const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + expect(data.regs.coppa_applies).to.equal(true) + }); + + it(`should set gdpr to true`, function () { + config.setConfig({ + consentManagement: { + gdpr: { + // any data here set gdpr to true + }, + } + }); + const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + expect(data.regs.gdpr_applies).to.equal(true) + }); + + it(`should set usp_consent string`, function () { + config.setConfig({ + consentManagement: { + usp: { + cmpApi: 'static', + consentData: { + getUSPData: { + uspString: '1YYY' + } + } + } + } + }); + const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + expect(data.regs.us_privacy).to.equal('1YYY') + }); + + it(`should not set usp_consent string`, function () { + config.setConfig({ + consentManagement: { + usp: { + cmpApi: 'iab', + consentData: { + getUSPData: { + uspString: '1YYY' + } + } + } + } + }); + const { data } = spec.buildRequests(DEFAULT_VALID_BANNER_REQUESTS, VALID_BIDDER_REQUEST); + expect(data.regs.us_privacy).to.undefined + }); + }); +}); diff --git a/test/spec/modules/airgridRtdProvider_spec.js b/test/spec/modules/airgridRtdProvider_spec.js index cc10dda4ad1..239d583d033 100644 --- a/test/spec/modules/airgridRtdProvider_spec.js +++ b/test/spec/modules/airgridRtdProvider_spec.js @@ -1,96 +1,92 @@ import {config} from 'src/config.js'; -import {deepAccess} from 'src/utils.js' -import {getAdUnits} from '../../fixtures/fixtures.js'; +import {deepAccess} from 'src/utils.js'; import * as agRTD from 'modules/airgridRtdProvider.js'; +import {loadExternalScript} from '../../../src/adloader.js'; const MATCHED_AUDIENCES = ['travel', 'sport']; const RTD_CONFIG = { auctionDelay: 250, - dataProviders: [{ - name: 'airgrid', - waitForIt: true, - params: { - apiKey: 'key123', - accountId: 'sdk', - publisherId: 'pub123', - bidders: ['pubmatic'] - } - }] + dataProviders: [ + { + name: 'airgrid', + waitForIt: true, + params: { + apiKey: 'key123', + accountId: 'sdk', + publisherId: 'pub123', + bidders: ['pubmatic'], + }, + }, + ], }; -describe('airgrid RTD Submodule', function() { +describe('airgrid RTD Submodule', function () { let getDataFromLocalStorageStub; - beforeEach(function() { + beforeEach(function () { config.resetConfig(); - getDataFromLocalStorageStub = sinon.stub(agRTD.storage, 'getDataFromLocalStorage'); + getDataFromLocalStorageStub = sinon.stub( + agRTD.storage, + 'getDataFromLocalStorage' + ); }); afterEach(function () { getDataFromLocalStorageStub.restore(); }); - describe('Initialise module', function() { + describe('Initialise module', function () { it('should initalise and return true', function () { - expect(agRTD.airgridSubmodule.init(RTD_CONFIG.dataProviders[0])).to.equal(true); + expect(agRTD.airgridSubmodule.init(RTD_CONFIG.dataProviders[0])).to.equal( + true + ); + expect(loadExternalScript.called).to.be.true }); - it('should attach script to DOM with correct config', function() { + + it('should attach script to DOM with correct config', function () { agRTD.attachScriptTagToDOM(RTD_CONFIG); expect(window.edktInitializor.invoked).to.be.true; - expect(window.edktInitializor.apiKey).to.equal(RTD_CONFIG.dataProviders[0].params.apiKey); - expect(window.edktInitializor.accountId).to.equal(RTD_CONFIG.dataProviders[0].params.accountId); - expect(window.edktInitializor.publisherId).to.equal(RTD_CONFIG.dataProviders[0].params.publisherId); + expect(window.edktInitializor.apiKey).to.equal( + RTD_CONFIG.dataProviders[0].params.apiKey + ); + expect(window.edktInitializor.accountId).to.equal( + RTD_CONFIG.dataProviders[0].params.accountId + ); + expect(window.edktInitializor.publisherId).to.equal( + RTD_CONFIG.dataProviders[0].params.publisherId + ); }); }); - describe('Get matched audiences', function() { - it('gets matched audiences from local storage', function() { - getDataFromLocalStorageStub.withArgs(agRTD.AG_AUDIENCE_IDS_KEY).returns(JSON.stringify(MATCHED_AUDIENCES)); + describe('Get matched audiences', function () { + it('gets matched audiences from local storage', function () { + getDataFromLocalStorageStub + .withArgs(agRTD.AG_AUDIENCE_IDS_KEY) + .returns(JSON.stringify(MATCHED_AUDIENCES)); const audiences = agRTD.getMatchedAudiencesFromStorage(); expect(audiences).to.have.members(MATCHED_AUDIENCES); }); }); - describe('Add matched audiences', function() { - it('merges matched audiences on appnexus AdUnits', function() { - const adUnits = getAdUnits(); - getDataFromLocalStorageStub.withArgs(agRTD.AG_AUDIENCE_IDS_KEY).returns(JSON.stringify(MATCHED_AUDIENCES)); - agRTD.passAudiencesToBidders({ adUnits }, () => {}, {}, {}); + describe('Add matched audiences', function () { + it('sets bidder specific ORTB2 config', function () { + getDataFromLocalStorageStub + .withArgs(agRTD.AG_AUDIENCE_IDS_KEY) + .returns(JSON.stringify(MATCHED_AUDIENCES)); + const audiences = agRTD.getMatchedAudiencesFromStorage(); - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid; - if (bidder === 'appnexus') { - expect(deepAccess(params, 'keywords.perid')).to.eql(MATCHED_AUDIENCES); - } - }); - }); - }); - it('does not merge audiences on appnexus adunits, since none are matched', function() { - const adUnits = getAdUnits(); - getDataFromLocalStorageStub.withArgs(agRTD.AG_AUDIENCE_IDS_KEY).returns(undefined); - agRTD.passAudiencesToBidders({ adUnits }, () => {}, {}, {}); + const bidderOrtb2 = {}; - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid; - if (bidder === 'appnexus') { - expect(deepAccess(params, 'keywords.perid')).to.be.undefined; - } - }); - }); - }); - it('sets bidder specific ORTB2 config', function() { - getDataFromLocalStorageStub.withArgs(agRTD.AG_AUDIENCE_IDS_KEY).returns(JSON.stringify(MATCHED_AUDIENCES)); - const audiences = agRTD.getMatchedAudiencesFromStorage(); - agRTD.setAudiencesUsingBidderOrtb2(RTD_CONFIG.dataProviders[0], audiences); + agRTD.setAudiencesAsBidderOrtb2({ortb2Fragments: {bidder: bidderOrtb2}}, RTD_CONFIG.dataProviders[0], audiences); + + const bidders = RTD_CONFIG.dataProviders[0].params.bidders - const allBiddersConfig = config.getBidderConfig(); - const bidders = RTD_CONFIG.dataProviders[0].params.bidders; - Object.keys(allBiddersConfig).forEach((bidder) => { - if (bidders.indexOf(bidder) === -1) return; - expect(deepAccess(allBiddersConfig[bidder], 'ortb2.user.ext.data.airgrid')).to.eql(MATCHED_AUDIENCES); + bidders.forEach((bidder) => { + const ortb2 = bidderOrtb2[bidder]; + MATCHED_AUDIENCES.forEach((audience) => { + expect(ortb2.user.data[0].segment.find(segment => segment.id === audience)).to.exist; + }) }); }); }); diff --git a/test/spec/modules/ajaBidAdapter_spec.js b/test/spec/modules/ajaBidAdapter_spec.js index 9bb77520212..7cf5698f7d4 100644 --- a/test/spec/modules/ajaBidAdapter_spec.js +++ b/test/spec/modules/ajaBidAdapter_spec.js @@ -45,12 +45,32 @@ describe('AjaAdapter', function () { bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', auctionId: '1d1a030790a475', + ortb2: { + device: { + sua: { + source: 2, + platform: { + brand: 'Android', + version: ['8', '0', '0'] + }, + browsers: [ + {brand: 'Not_A Brand', version: ['99', '0', '0', '0']}, + {brand: 'Google Chrome', version: ['109', '0', '5414', '119']}, + {brand: 'Chromium', version: ['109', '0', '5414', '119']} + ], + mobile: 1, + model: 'SM-G955U', + bitness: '64', + architecture: '' + } + } + } } ]; const bidderRequest = { refererInfo: { - referer: 'https://hoge.com' + page: 'https://hoge.com' } }; @@ -58,7 +78,7 @@ describe('AjaAdapter', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].url).to.equal(ENDPOINT); expect(requests[0].method).to.equal('GET'); - expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=https%3A%2F%2Fhoge.com&'); + expect(requests[0].data).to.equal('asi=123456&skt=5&prebid_id=30b31c1838de1e&prebid_ver=$prebid.version$&page_url=https%3A%2F%2Fhoge.com&sua=%7B%22source%22%3A2%2C%22platform%22%3A%7B%22brand%22%3A%22Android%22%2C%22version%22%3A%5B%228%22%2C%220%22%2C%220%22%5D%7D%2C%22browsers%22%3A%5B%7B%22brand%22%3A%22Not_A%20Brand%22%2C%22version%22%3A%5B%2299%22%2C%220%22%2C%220%22%2C%220%22%5D%7D%2C%7B%22brand%22%3A%22Google%20Chrome%22%2C%22version%22%3A%5B%22109%22%2C%220%22%2C%225414%22%2C%22119%22%5D%7D%2C%7B%22brand%22%3A%22Chromium%22%2C%22version%22%3A%5B%22109%22%2C%220%22%2C%225414%22%2C%22119%22%5D%7D%5D%2C%22mobile%22%3A1%2C%22model%22%3A%22SM-G955U%22%2C%22bitness%22%3A%2264%22%2C%22architecture%22%3A%22%22%7D&'); }); }); @@ -88,7 +108,7 @@ describe('AjaAdapter', function () { const bidderRequest = { refererInfo: { - referer: 'https://hoge.com' + page: 'https://hoge.com' } }; diff --git a/test/spec/modules/akamaiDAPIdSystem_spec.js b/test/spec/modules/akamaiDAPIdSystem_spec.js deleted file mode 100644 index e44285eda34..00000000000 --- a/test/spec/modules/akamaiDAPIdSystem_spec.js +++ /dev/null @@ -1,117 +0,0 @@ -import {akamaiDAPIdSubmodule} from 'modules/akamaiDAPIdSystem.js'; -import * as utils from 'src/utils.js'; -import {server} from 'test/mocks/xhr.js'; -import {getStorageManager} from '../../../src/storageManager.js'; - -export const storage = getStorageManager(); - -const signatureConfigParams = {params: { - apiHostname: 'prebid.dap.akadns.net', - domain: 'prebid.org', - type: 'dap-signature:1.0.0', - apiVersion: 'v1' -}}; - -const tokenizeConfigParams = {params: { - apiHostname: 'prebid.dap.akadns.net', - domain: 'prebid.org', - type: 'email', - identity: 'amishra@xyz.com', - apiVersion: 'v1' -}}; - -const x1TokenizeConfigParams = {params: { - apiHostname: 'prebid.dap.akadns.net', - domain: 'prebid.org', - type: 'email', - identity: 'amishra@xyz.com', - apiVersion: 'x1', - attributes: '{ "cohorts": [ "3:14400", "5:14400", "7:0" ],"first_name": "Ace","last_name": "McCool" }' -}}; - -const consentData = { - gdprApplies: true, - consentString: 'BOkIpDSOkIpDSADABAENCc-AAAApOAFAAMAAsAMIAcAA_g' -}; - -const responseHeader = {'Content-Type': 'application/json'} - -const TEST_ID = '51sd61e3-sd82-4vea-8387-093dffca4a3a'; - -describe('akamaiDAPId getId', function () { - let logErrorStub; - - beforeEach(function () { - logErrorStub = sinon.stub(utils, 'logError'); - }); - - afterEach(function () { - logErrorStub.restore(); - }); - - describe('decode', function () { - it('should respond with an object with dapId containing the value', () => { - expect(akamaiDAPIdSubmodule.decode(TEST_ID)).to.deep.equal({ - dapId: TEST_ID - }); - }); - }); - - describe('getId', function () { - it('should log an error if no configParams were passed when getId', function () { - akamaiDAPIdSubmodule.getId(null); - expect(logErrorStub.calledOnce).to.be.true; - }); - - it('should log an error if configParams were passed without apihostname', function () { - akamaiDAPIdSubmodule.getId({ params: { - domain: 'prebid.org', - type: 'dap-signature:1.0.0' - } }); - expect(logErrorStub.calledOnce).to.be.true; - }); - - it('should log an error if configParams were passed without domain', function () { - akamaiDAPIdSubmodule.getId({ params: { - apiHostname: 'prebid.dap.akadns.net', - type: 'dap-signature:1.0.0' - } }); - expect(logErrorStub.calledOnce).to.be.true; - }); - - it('should log an error if configParams were passed without type', function () { - akamaiDAPIdSubmodule.getId({ params: { - apiHostname: 'prebid.dap.akadns.net', - domain: 'prebid.org' - } }); - expect(logErrorStub.calledOnce).to.be.true; - }); - - it('akamaiDAPId submobile requires consent string to call API', function () { - let consentData = { - gdprApplies: true, - consentString: '' - }; - let submoduleCallback = akamaiDAPIdSubmodule.getId(signatureConfigParams, consentData); - expect(submoduleCallback).to.be.undefined; - }); - - it('should call the signature v1 API and store token in Local storage', function () { - let submoduleCallback1 = akamaiDAPIdSubmodule.getId(signatureConfigParams, consentData).id; - expect(submoduleCallback1).to.be.eq(storage.getDataFromLocalStorage('akamai_dap_token')) - storage.removeDataFromLocalStorage('akamai_dap_token'); - }); - - it('should call the tokenize v1 API and store token in Local storage', function () { - let submoduleCallback = akamaiDAPIdSubmodule.getId(tokenizeConfigParams, consentData).id; - expect(submoduleCallback).to.be.eq(storage.getDataFromLocalStorage('akamai_dap_token')) - storage.removeDataFromLocalStorage('akamai_dap_token'); - }); - - it('should call the tokenize x1 API and store token in Local storage', function () { - let submoduleCallback = akamaiDAPIdSubmodule.getId(x1TokenizeConfigParams, consentData).id; - expect(submoduleCallback).to.be.eq(storage.getDataFromLocalStorage('akamai_dap_token')) - storage.removeDataFromLocalStorage('akamai_dap_token'); - }); - }); -}); diff --git a/test/spec/modules/akamaiDapRtdProvider_spec.js b/test/spec/modules/akamaiDapRtdProvider_spec.js index b350c2bb529..337fcf57a33 100644 --- a/test/spec/modules/akamaiDapRtdProvider_spec.js +++ b/test/spec/modules/akamaiDapRtdProvider_spec.js @@ -1,13 +1,15 @@ import {config} from 'src/config.js'; -import {SEGMENTS_STORAGE_KEY, TOKEN_STORAGE_KEY, dapUtils, addRealTimeData, getRealTimeData, akamaiDapRtdSubmodule, storage} from 'modules/akamaiDapRtdProvider.js'; +import { + dapUtils, + generateRealTimeData, + akamaiDapRtdSubmodule, + storage, DAP_MAX_RETRY_TOKENIZE, DAP_SS_ID, DAP_TOKEN, DAP_MEMBERSHIP, DAP_ENCRYPTED_MEMBERSHIP +} from 'modules/akamaiDapRtdProvider.js'; import {server} from 'test/mocks/xhr.js'; -import logMessage from 'src/utils.js' +import {hook} from '../../../src/hook.js'; const responseHeader = {'Content-Type': 'application/json'}; describe('akamaiDapRtdProvider', function() { - let getDataFromLocalStorageStub; - let getDapTokenStub; - const testReqBidsConfigObj = { adUnits: [ { @@ -18,7 +20,21 @@ describe('akamaiDapRtdProvider', function() { const onDone = function() { return true }; - const onSuccess = function() { return ('request', 200, 'success') }; + const sampleGdprConsentConfig = { + 'gdpr': { + 'consentString': null, + 'vendorData': {}, + 'gdprApplies': true + } + }; + + const sampleUspConsentConfig = { + 'usp': '1YYY' + }; + + const sampleIdentity = { + type: 'dap-signature:1.0.0' + }; const cmoduleConfig = { 'name': 'dap', @@ -28,8 +44,19 @@ describe('akamaiDapRtdProvider', function() { 'apiVersion': 'x1', 'domain': 'prebid.org', 'identityType': 'dap-signature:1.0.0', - 'segtax': 503, - 'tokenTtl': 5 + 'segtax': 503 + } + } + + const emoduleConfig = { + 'name': 'dap', + 'waitForIt': true, + 'params': { + 'apiHostname': 'prebid.dap.akadns.net', + 'apiVersion': 'x1', + 'domain': 'prebid.org', + 'identityType': 'dap-signature:1.0.0', + 'segtax': 504 } } @@ -37,81 +64,174 @@ describe('akamaiDapRtdProvider', function() { 'api_hostname': 'prebid.dap.akadns.net', 'api_version': 'x1', 'domain': 'prebid.org', - 'segtax': 503 + 'segtax': 503, + 'identity': sampleIdentity } - const sampleIdentity = { - type: 'dap-signature:1.0.0' + + const esampleConfig = { + 'api_hostname': 'prebid.dap.akadns.net', + 'api_version': 'x1', + 'domain': 'prebid.org', + 'segtax': 504, + 'identity': sampleIdentity + } + let cacheExpiry = Math.round(Date.now() / 1000.0) + 300; // in seconds + const sampleCachedToken = {'expires_at': cacheExpiry, 'token': 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIn0..6buzBd2BjtgoyaNbHN8YnQ.l38avCfm3sYNy798-ETYOugz0cOx1cCkjACkAhYszxzrZ0sUJ0AiF-NdDXVTiTyp2Ih3vCWKzS0rKJ8lbS1zhyEVWVu91QwtwseM2fBbwA5ggAgBEo5wV-IXqDLPxVnxsPF0D3hP6cNCiH9Q2c-vULfsLhMhG5zvvZDPBbn4hUY5fKB8LoCBTF9rbuuWGYK1nramnb4AlS5UK82wBsHQea1Ou_Kp5wWCMNZ6TZk5qKIuRBfPIAhQblWvHECaHXkg1wyoM9VASs_yNhne7RR-qkwzbFiPFiMJibNOt9hF3_vPDJO5-06ZBjRTP1BllYGWxI-uQX6InzN18Wtun2WHqg.63sH0SNlIRcsK57v0pMujfB_nhU8Y5CuQbsHqH5MGoM'}; + const cachedEncryptedMembership = {'expires_at': cacheExpiry, 'encryptedSegments': 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoic29tZXNlY3JldGludmF1bHQifQ..IvnIUQDqWBVYIS0gbcE9bw.Z4NZGvtogWaWlGH4e-GdYKe_PUc15M2x3Bj85rMWsN1A17mIxQIMOfg2hsQ2tgieLu5LggWPmsFu1Wbph6P0k3kOu1dVReoIhOHzxw50rP0DLHKaEZ5mLMJ7Lcosvwh4miIfFuCHlsX7J0sFgOTAp0zGo1S_UsHLtev1JflhjoSB0AoX95ALbAnyctirPuLJM8gZ1vXTiZ01jpvucGyR1lM4cWjPOeD8jPtgwaPGgSRZXE-3X2Cqy7z4Giam5Uqu74LPWTBuKtUQTGyAXA5QJoP7xwTbsU4O1f69lu3fWNqC92GijeTH1A4Zd_C-WXxWuQlDEURjlkWQoaqTHka2OqlnwukEQIf_v0r5KQQX64CTLhEUH91jeD0-E9ClcIP7pwOLxxqiKoaBmx8Mrnm_6Agj5DtTA1rusy3AL63sI_rsUxrmLrVt0Wft4aCfRkW8QpQxu8clFdOmce0NNCGeBCyCPVw9d9izrILlXJ6rItU2cpFrcbz8uw2otamF5eOFCOY3IzHedWVNNuKHFIUVC_xYSlsYvQ8f2QIP1eiMbmukcuPzmTzjw1h1_7IKaj-jJkXrnrY-TdDgX_4-_Z3rmbpXK2yTR7dBrsg-ubqFbgbKic1b4zlQEO_LbBlgPl3DYdWEuJ8CY2NUt1GfpATQGsufS2FTY1YGw_gkPe3q04l_cgLafDoxHvHh_t_0ZgPjciW82gThB_kN4RP7Mc3krVcXl_P6N1VbV07xyx0hCyVsrrxbLslI8q9wYDiLGci7mNmByM5j7SXV9jPwwPkHtn0HfMJlw2PFbIDPjgG3h7sOyLcBIJTTvuUIgpHPIkRWLIl_4FlIucXbJ7orW2nt5BWleBVHgumzGcnl9ZNcZb3W-dsdYPSOmuj0CY28MRTP2oJ1rzLInbDDpIRffJBtR7SS4nYyy7Vi09PtBigod5YNz1Q0WDSJxr8zeH_aKFaXInw7Bfo_U0IAcLiRgcT0ogsMLeQRjRFy27mr4XNJv3NtHhbdjDAwF2aClCktXyXbQaVdsPH2W71v6m2Q9rB5GQWOktw2s5f-4N1-_EBPGq6TgjF-aJZP22MJVwp1pimT50DfOzoeEqDwi862NNwNNoHmcObH0ZfwAXlhRxsgupNBe20-MNNABj2Phlfv4DUrtQbMdfCnNiypzNCmoTb7G7c_o5_JUwoV_GVkwUtvmi_IUm05P4GeMASSUw8zDKVRAj9h31C2cabM8RjMHGhkbCWpUP2pcz9zlJ7Y76Dh3RLnctfTw7DG9U4w4UlaxNZOgLUiSrGwfyapuSiuGUpuOJkBBLiHmEqAGI5C8oJpcVRccNlHxJAYowgXyFopD5Fr-FkXmv8KMkS0h5C9F6KihmDt5sqDD0qnjM0hHJgq01l7wjVnhEmPpyD-6auFQ-xDnbh1uBOJ_0gCVbRad--FSa5p-dXenggegRxOvZXJ0iAtM6Fal5Og-RCjexIHa9WhVbXhQBJpkSTWwAajZJ64eQ.yih49XB51wE-Xob7COT9OYqBrzBmIMVCQbLFx2UdzkI'}; + const cachedMembership = {'expires_at': cacheExpiry, 'said': 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIn0..QwvU5h0NVJYaJbs5EqWCKA.XNaJHSlnsH8P-yBIr3gIEqavLONWDIFyj7QCHFwJVkwXH_EYkxrk0_26b0uMPzfJp5URnqxKZusMH9DzEJsmj8EMrKQv1y3IYYMsW5_0BdP5bcAWfG6fzOqtMOwLiYRkYiQOqn1ZVGzhovheHWEmNr2_oCY0LvAr3iN1eG_K-l-bBKvBWnwvuuGKquUfCqO8NMMq6wtkecEXM9blqFRZ7oNYmW2aIG7qcHUsrUW7HMr9Ev2Ik0sIeEUsOYrgf_X_VA64RgKSTRugS9FupMv1p54JkHokwduF9pOFmW8QLQi8itFogKGbbgvOTNnmahxQUX5FcrjjYLqHwKqC8htLdlHnO5LWU9l4A7vLXrRurvoSnh0cAJy0GsdoyEwTqR9bwVFHoPquxlJjQ4buEd7PIxpBj9Qg9oOPH3b2upbMTu5CQ9oj526eXPhP5G54nwGklm2AZ3Vggd7jCQJn45Jjiq0iIfsXAtpqS2BssCLBN8WhmUTnStK8m5sux6WUBdrpDESQjPj-EEHVS-DB5rA7icRUh6EzRxzen2rndvHvnwVhSG_l6cwPYuJ0HE0KBmYHOoqNpKwzoGiKFHrf4ReA06iWB3V2TEGJucGujhtQ9_18WwHCeJ1XtQiiO1eqa3tp5MwAbFXawVFl3FFOBgadrPyvGmkmUJ6FCLU2MSwHiYZmANMnJsokFX_6DwoAgO3U_QnvEHIVSvefc7ReeJ8fBDdmrH3LtuLrUpXsvLvEIMQdWQ_SXhjKIi7tOODR8CfrhUcdIjsp3PZs1DpuOcDB6YJKbGnKZTluLUJi3TyHgyi-DHXdTm-jSE5i_DYJGW-t2Gf23FoQhexv4q7gdrfsKfcRJNrZLp6Gd6jl4zHhUtY.nprKBsy9taQBk6dCPbA7BFF0CiGhQOEF_MazZ2bedqk', 'cohorts': ['9', '11', '13']}; + const rtdUserObj = { + name: 'www.dataprovider3.com', + ext: { + taxonomyname: 'iab_audience_taxonomy' + }, + segment: [ + { + id: '1918' + }, + { + id: '1939' + } + ] + }; + + const encRtdUserObj = { + name: 'www.dataprovider3.com', + ext: { + segtax: 504, + taxonomyname: 'iab_audience_taxonomy' + }, + segment: [] + }; + + const cachedRtd = { + rtd: { + ortb2: { + user: { + data: [rtdUserObj] + } + } + } + }; + + let membership = { + said: cachedMembership.said, + cohorts: cachedMembership.cohorts, + attributes: null + }; + let encMembership = { + encryptedSegments: cachedEncryptedMembership.encryptedSegments + }; + encRtdUserObj.segment.push({ id: encMembership.encryptedSegments }); + const cachedEncRtd = { + rtd: { + ortb2: { + user: { + data: [encRtdUserObj] + } + } + } }; + before(() => { + hook.ready(); + }); + + let ortb2, bidConfig; + beforeEach(function() { + bidConfig = {ortb2Fragments: {}}; + ortb2 = bidConfig.ortb2Fragments.global = {}; config.resetConfig(); - getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage') + storage.removeDataFromLocalStorage(DAP_TOKEN); + storage.removeDataFromLocalStorage(DAP_MEMBERSHIP); + storage.removeDataFromLocalStorage(DAP_ENCRYPTED_MEMBERSHIP); + storage.removeDataFromLocalStorage(DAP_SS_ID); }); afterEach(function () { - getDataFromLocalStorageStub.restore(); }); describe('akamaiDapRtdSubmodule', function() { it('successfully instantiates', function () { - expect(akamaiDapRtdSubmodule.init()).to.equal(true); + expect(akamaiDapRtdSubmodule.init()).to.equal(true); }); }); describe('Get Real-Time Data', function() { it('gets rtd from local storage cache', function() { - const rtdConfig = { - params: { - segmentCache: true - } - }; - - const bidConfig = {}; - - const rtdUserObj1 = { - name: 'www.dataprovider3.com', - ext: { - taxonomyname: 'iab_audience_taxonomy' - }, - segment: [ - { - id: '1918' - }, - { - id: '1939' - } - ] - }; - - const cachedRtd = { - rtd: { - ortb2: { - user: { - data: [rtdUserObj1] - } - } - } - }; + let dapGetMembershipFromLocalStorageStub = sinon.stub(dapUtils, 'dapGetMembershipFromLocalStorage').returns(membership) + let dapGetRtdObjStub = sinon.stub(dapUtils, 'dapGetRtdObj').returns(cachedRtd) + let dapGetEncryptedMembershipFromLocalStorageStub = sinon.stub(dapUtils, 'dapGetEncryptedMembershipFromLocalStorage').returns(encMembership) + let dapGetEncryptedRtdObjStub = sinon.stub(dapUtils, 'dapGetEncryptedRtdObj').returns(cachedEncRtd) + let callDapApisStub = sinon.stub(dapUtils, 'callDapAPIs') + try { + storage.setDataInLocalStorage(DAP_TOKEN, JSON.stringify(sampleCachedToken)); + expect(ortb2).to.eql({}); + generateRealTimeData(bidConfig, () => {}, emoduleConfig, {}); - getDataFromLocalStorageStub.withArgs(SEGMENTS_STORAGE_KEY).returns(JSON.stringify(cachedRtd)); + expect(ortb2.user.data).to.deep.include.members([encRtdUserObj]); + generateRealTimeData(bidConfig, () => {}, cmoduleConfig, {}); + expect(ortb2.user.data).to.deep.include.members([rtdUserObj]); + } finally { + dapGetRtdObjStub.restore() + dapGetMembershipFromLocalStorageStub.restore() + dapGetEncryptedRtdObjStub.restore() + dapGetEncryptedMembershipFromLocalStorageStub.restore() + callDapApisStub.restore() + } + }); + }); - expect(config.getConfig().ortb2).to.be.undefined; - getRealTimeData(bidConfig, () => {}, rtdConfig, {}); - expect(config.getConfig().ortb2.user.data).to.deep.include.members([rtdUserObj1]); + describe('calling DAP APIs', function() { + it('Calls callDapAPIs for unencrypted segments flow', function() { + storage.setDataInLocalStorage(DAP_TOKEN, JSON.stringify(sampleCachedToken)); + let dapExtractExpiryFromTokenStub = sinon.stub(dapUtils, 'dapExtractExpiryFromToken').returns(cacheExpiry) + try { + expect(ortb2).to.eql({}); + dapUtils.callDapAPIs(bidConfig, () => {}, cmoduleConfig, {}); + let membership = {'cohorts': ['9', '11', '13'], 'said': 'sample-said'} + let membershipRequest = server.requests[0]; + membershipRequest.respond(200, responseHeader, JSON.stringify(membership)); + let tokenWithExpiry = 'Sample-token-with-exp' + let tokenizeRequest = server.requests[1]; + responseHeader['Akamai-DAP-Token'] = tokenWithExpiry; + tokenizeRequest.respond(200, responseHeader, JSON.stringify(tokenWithExpiry)); + let data = dapUtils.dapGetRtdObj(membership, cmoduleConfig.params.segtax); + expect(ortb2.user.data).to.deep.include.members(data.rtd.ortb2.user.data); + } finally { + dapExtractExpiryFromTokenStub.restore(); + } }); - it('should initalise and return with config', function () { - expect(getRealTimeData(testReqBidsConfigObj, onDone, cmoduleConfig)).to.equal(undefined) + it('Calls callDapAPIs for encrypted segments flow', function() { + storage.setDataInLocalStorage(DAP_TOKEN, JSON.stringify(sampleCachedToken)); + let dapExtractExpiryFromTokenStub = sinon.stub(dapUtils, 'dapExtractExpiryFromToken').returns(cacheExpiry) + try { + expect(ortb2).to.eql({}); + dapUtils.callDapAPIs(bidConfig, () => {}, emoduleConfig, {}); + let encMembership = 'Sample-enc-token'; + let membershipRequest = server.requests[0]; + responseHeader['Akamai-DAP-Token'] = encMembership; + membershipRequest.respond(200, responseHeader, JSON.stringify(encMembership)); + let tokenWithExpiry = 'Sample-token-with-exp' + let tokenizeRequest = server.requests[1]; + responseHeader['Akamai-DAP-Token'] = tokenWithExpiry; + tokenizeRequest.respond(200, responseHeader, JSON.stringify(tokenWithExpiry)); + let data = dapUtils.dapGetEncryptedRtdObj({'encryptedSegments': encMembership}, emoduleConfig.params.segtax); + expect(ortb2.user.data).to.deep.include.members(data.rtd.ortb2.user.data); + } finally { + dapExtractExpiryFromTokenStub.restore(); + } }); }); describe('dapTokenize', function () { it('dapTokenize error callback', function () { let configAsync = JSON.parse(JSON.stringify(sampleConfig)); - let submoduleCallback = dapUtils.dapTokenize(configAsync, sampleIdentity, - function(token, status, xhr) { + let submoduleCallback = dapUtils.dapTokenize(configAsync, sampleIdentity, onDone, + function(token, status, xhr, onDone) { }, - function(xhr, status, error) { + function(xhr, status, error, onDone) { } ); let request = server.requests[0]; @@ -121,10 +241,10 @@ describe('akamaiDapRtdProvider', function() { it('dapTokenize success callback', function () { let configAsync = JSON.parse(JSON.stringify(sampleConfig)); - let submoduleCallback = dapUtils.dapTokenize(configAsync, sampleIdentity, - function(token, status, xhr) { + let submoduleCallback = dapUtils.dapTokenize(configAsync, sampleIdentity, onDone, + function(token, status, xhr, onDone) { }, - function(xhr, status, error) { + function(xhr, status, error, onDone) { } ); let request = server.requests[0]; @@ -135,40 +255,54 @@ describe('akamaiDapRtdProvider', function() { describe('dapTokenize and dapMembership incorrect params', function () { it('Onerror and config are null', function () { - expect(dapUtils.dapTokenize(null, 'identity', null, null)).to.be.equal(undefined); - expect(dapUtils.dapMembership(null, 'identity', null, null)).to.be.equal(undefined); + expect(dapUtils.dapTokenize(null, 'identity', onDone, null, null)).to.be.equal(undefined); + expect(dapUtils.dapMembership(null, 'identity', onDone, null, null)).to.be.equal(undefined); + expect(dapUtils.dapEncryptedMembership(null, 'identity', onDone, null, null)).to.be.equal(undefined); const config = { 'api_hostname': 'prebid.dap.akadns.net', 'api_version': 1, 'domain': '', 'segtax': 503 }; + const encConfig = { + 'api_hostname': 'prebid.dap.akadns.net', + 'api_version': 1, + 'domain': '', + 'segtax': 504 + }; let identity = { type: 'dap-signature:1.0.0' }; - expect(dapUtils.dapTokenize(config, identity, null, null)).to.be.equal(undefined); - expect(dapUtils.dapMembership(config, 'token', null, null)).to.be.equal(undefined); + expect(dapUtils.dapTokenize(config, identity, onDone, null, null)).to.be.equal(undefined); + expect(dapUtils.dapMembership(config, 'token', onDone, null, null)).to.be.equal(undefined); + expect(dapUtils.dapEncryptedMembership(encConfig, 'token', onDone, null, null)).to.be.equal(undefined); }); + }); - it('dapGetToken success', function () { - let dapTokenizeStub = sinon.stub(dapUtils, 'dapTokenize').returns(onSuccess); - expect(dapUtils.dapGetToken(sampleConfig, 'token', - function(token, status, xhr) { - }, - function(xhr, status, error) { - } - )).to.be.equal(null); - dapTokenizeStub.restore(); + describe('Getting dapTokenize, dapMembership and dapEncryptedMembership from localstorage', function () { + it('dapGetTokenFromLocalStorage success', function () { + storage.setDataInLocalStorage(DAP_TOKEN, JSON.stringify(sampleCachedToken)); + expect(dapUtils.dapGetTokenFromLocalStorage(60)).to.be.equal(sampleCachedToken.token); + }); + + it('dapGetMembershipFromLocalStorage success', function () { + storage.setDataInLocalStorage(DAP_MEMBERSHIP, JSON.stringify(cachedMembership)); + expect(JSON.stringify(dapUtils.dapGetMembershipFromLocalStorage())).to.be.equal(JSON.stringify(membership)); + }); + + it('dapGetEncryptedMembershipFromLocalStorage success', function () { + storage.setDataInLocalStorage(DAP_ENCRYPTED_MEMBERSHIP, JSON.stringify(cachedEncryptedMembership)); + expect(JSON.stringify(dapUtils.dapGetEncryptedMembershipFromLocalStorage())).to.be.equal(JSON.stringify(encMembership)); }); }); describe('dapMembership', function () { it('dapMembership success callback', function () { let configAsync = JSON.parse(JSON.stringify(sampleConfig)); - let submoduleCallback = dapUtils.dapMembership(configAsync, 'token', - function(token, status, xhr) { + let submoduleCallback = dapUtils.dapMembership(configAsync, 'token', onDone, + function(token, status, xhr, onDone) { }, - function(xhr, status, error) { + function(xhr, status, error, onDone) { } ); let request = server.requests[0]; @@ -178,10 +312,38 @@ describe('akamaiDapRtdProvider', function() { it('dapMembership error callback', function () { let configAsync = JSON.parse(JSON.stringify(sampleConfig)); - let submoduleCallback = dapUtils.dapMembership(configAsync, 'token', - function(token, status, xhr) { + let submoduleCallback = dapUtils.dapMembership(configAsync, 'token', onDone, + function(token, status, xhr, onDone) { + }, + function(xhr, status, error, onDone) { + } + ); + let request = server.requests[0]; + request.respond(400, responseHeader, JSON.stringify('error')); + expect(submoduleCallback).to.equal(undefined); + }); + }); + + describe('dapEncMembership', function () { + it('dapEncMembership success callback', function () { + let configAsync = JSON.parse(JSON.stringify(esampleConfig)); + let submoduleCallback = dapUtils.dapEncryptedMembership(configAsync, 'token', onDone, + function(token, status, xhr, onDone) { + }, + function(xhr, status, error, onDone) { + } + ); + let request = server.requests[0]; + request.respond(200, responseHeader, JSON.stringify('success')); + expect(submoduleCallback).to.equal(undefined); + }); + + it('dapEncMembership error callback', function () { + let configAsync = JSON.parse(JSON.stringify(esampleConfig)); + let submoduleCallback = dapUtils.dapEncryptedMembership(configAsync, 'token', onDone, + function(token, status, xhr, onDone) { }, - function(xhr, status, error) { + function(xhr, status, error, onDone) { } ); let request = server.requests[0]; @@ -192,55 +354,247 @@ describe('akamaiDapRtdProvider', function() { describe('dapMembership', function () { it('should invoke the getDapToken and getDapMembership', function () { - let config = { - api_hostname: cmoduleConfig.params.apiHostname, - api_version: cmoduleConfig.params.apiVersion, - domain: cmoduleConfig.params.domain, - segtax: cmoduleConfig.params.segtax - }; - let identity = { - type: cmoduleConfig.params.identityType - }; - let membership = { said: 'item.said1', cohorts: 'item.cohorts', attributes: null }; - let getDapTokenStub = sinon.stub(dapUtils, 'dapGetToken').returns('token3'); - let getDapMembershipStub = sinon.stub(dapUtils, 'dapGetMembership').returns(membership); - let dapTokenizeStub = sinon.stub(dapUtils, 'dapTokenize').returns('response', 200, 'request'); - getRealTimeData(testReqBidsConfigObj, onDone, cmoduleConfig); - expect(getDapTokenStub.calledOnce).to.be.equal(true); - expect(getDapMembershipStub.calledOnce).to.be.equal(true); - getDapTokenStub.restore(); - getDapMembershipStub.restore(); - dapTokenizeStub.restore(); + let getDapMembershipStub = sinon.stub(dapUtils, 'dapGetMembershipFromLocalStorage').returns(membership); + let callDapApisStub = sinon.stub(dapUtils, 'callDapAPIs'); + try { + generateRealTimeData(testReqBidsConfigObj, onDone, cmoduleConfig); + expect(getDapMembershipStub.calledOnce).to.be.equal(true); + } finally { + getDapMembershipStub.restore(); + callDapApisStub.restore(); + } }); }); - describe('dapMembershipToRtbSegment', function () { - it('dapMembershipToRtbSegment', function () { - let membership1 = { - said: 'item.said1', - cohorts: 'item.cohorts', - attributes: null + describe('dapEncMembership test', function () { + it('should invoke the getDapToken and getEncDapMembership', function () { + let encMembership = { + encryptedSegments: 'enc.seg', }; + + let getDapEncMembershipStub = sinon.stub(dapUtils, 'dapGetEncryptedMembershipFromLocalStorage').returns(encMembership); + let callDapApisStub = sinon.stub(dapUtils, 'callDapAPIs'); + try { + generateRealTimeData(testReqBidsConfigObj, onDone, emoduleConfig); + expect(getDapEncMembershipStub.calledOnce).to.be.equal(true); + } finally { + getDapEncMembershipStub.restore(); + callDapApisStub.restore(); + } + }); + }); + + describe('dapGetRtdObj test', function () { + it('dapGetRtdObj', function () { const config = { apiHostname: 'prebid.dap.akadns.net', apiVersion: 'x1', domain: 'prebid.org', - tokenTtl: 5, segtax: 503 }; - let identity = { - type: 'dap-signature:1.0.0' - }; - - expect(dapUtils.dapGetMembership(config, 'token')).to.equal(null) + expect(dapUtils.dapRefreshMembership(ortb2, config, 'token', onDone)).to.equal(undefined) const membership = {cohorts: ['1', '5', '7']} - expect(dapUtils.dapMembershipToRtbSegment(membership, config)).to.not.equal(undefined); + expect(dapUtils.dapGetRtdObj(membership, config.segtax)).to.not.equal(undefined); + }); + }); + + describe('checkAndAddRealtimeData test', function () { + it('add realtime data for segtax 503 and 504', function () { + dapUtils.checkAndAddRealtimeData(ortb2, cachedEncRtd, 504); + dapUtils.checkAndAddRealtimeData(ortb2, cachedEncRtd, 504); + expect(ortb2.user.data).to.deep.include.members([encRtdUserObj]); + dapUtils.checkAndAddRealtimeData(ortb2, cachedRtd, 503); + expect(ortb2.user.data).to.deep.include.members([rtdUserObj]); + }); + }); + + describe('dapExtractExpiryFromToken test', function () { + it('test dapExtractExpiryFromToken function', function () { + let tokenWithoutExpiry = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIn0..6buzBd2BjtgoyaNbHN8YnQ.l38avCfm3sYNy798-ETYOugz0cOx1cCkjACkAhYszxzrZ0sUJ0AiF-NdDXVTiTyp2Ih3vCWKzS0rKJ8lbS1zhyEVWVu91QwtwseM2fBbwA5ggAgBEo5wV-IXqDLPxVnxsPF0D3hP6cNCiH9Q2c-vULfsLhMhG5zvvZDPBbn4hUY5fKB8LoCBTF9rbuuWGYK1nramnb4AlS5UK82wBsHQea1Ou_Kp5wWCMNZ6TZk5qKIuRBfPIAhQblWvHECaHXkg1wyoM9VASs_yNhne7RR-qkwzbFiPFiMJibNOt9hF3_vPDJO5-06ZBjRTP1BllYGWxI-uQX6InzN18Wtun2WHqg.63sH0SNlIRcsK57v0pMujfB_nhU8Y5CuQbsHqH5MGoM' + expect(dapUtils.dapExtractExpiryFromToken(tokenWithoutExpiry)).to.equal(undefined); + let tokenWithExpiry = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIiwiZXhwIjoxNjQzODMwMzY5fQ..hTbcSQgmmO0HUJJrQ5fRHw.7zjrQXNNVkb-GD0ZhIVhEPcWbyaDBilHTWv-bp1lFZ9mdkSC0QbcAvUbYteiTD7ya23GUwcL2WOW8WgRSHaWHOJe0B5NDqfdUGTzElWfu7fFodRxRgGmwG8Rq5xxteFKLLGHLf1mFYRJKDtjtgajGNUKIDfn9AEt-c5Qz4KU8VolG_KzrLROx-f6Z7MnoPTcwRCj0WjXD6j2D6RAZ80-mKTNIsMIELdj6xiabHcjDJ1WzwtwCZSE2y2nMs451pSYp8W-bFPfZmDDwrkjN4s9ASLlIXcXgxK-H0GsiEbckQOZ49zsIKyFtasBvZW8339rrXi1js-aBh99M7aS5w9DmXPpUDmppSPpwkeTfKiqF0cQiAUq8tpeEQrGDJuw3Qt2.XI8h9Xw-VZj_NOmKtV19wLM63S4snos7rzkoHf9FXCw' + expect(dapUtils.dapExtractExpiryFromToken(tokenWithExpiry)).to.equal(1643830369); + }); + }); + + describe('dapRefreshToken test', function () { + it('test dapRefreshToken success response', function () { + dapUtils.dapRefreshToken(ortb2, sampleConfig, true, onDone) + let request = server.requests[0]; + responseHeader['Akamai-DAP-Token'] = sampleCachedToken.token; + request.respond(200, responseHeader, JSON.stringify(sampleCachedToken.token)); + expect(JSON.parse(storage.getDataFromLocalStorage(DAP_TOKEN)).token).to.be.equal(sampleCachedToken.token); + }); + + it('test dapRefreshToken success response with deviceid 100', function () { + dapUtils.dapRefreshToken(ortb2, esampleConfig, true, onDone) + let request = server.requests[0]; + responseHeader['Akamai-DAP-100'] = sampleCachedToken.token; + request.respond(200, responseHeader, ''); + expect(storage.getDataFromLocalStorage('dap_deviceId100')).to.be.equal(sampleCachedToken.token); + }); + + it('test dapRefreshToken success response with exp claim', function () { + dapUtils.dapRefreshToken(ortb2, sampleConfig, true, onDone) + let request = server.requests[0]; + let tokenWithExpiry = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIiwiZXhwIjoxNjQzODMwMzY5fQ..hTbcSQgmmO0HUJJrQ5fRHw.7zjrQXNNVkb-GD0ZhIVhEPcWbyaDBilHTWv-bp1lFZ9mdkSC0QbcAvUbYteiTD7ya23GUwcL2WOW8WgRSHaWHOJe0B5NDqfdUGTzElWfu7fFodRxRgGmwG8Rq5xxteFKLLGHLf1mFYRJKDtjtgajGNUKIDfn9AEt-c5Qz4KU8VolG_KzrLROx-f6Z7MnoPTcwRCj0WjXD6j2D6RAZ80-mKTNIsMIELdj6xiabHcjDJ1WzwtwCZSE2y2nMs451pSYp8W-bFPfZmDDwrkjN4s9ASLlIXcXgxK-H0GsiEbckQOZ49zsIKyFtasBvZW8339rrXi1js-aBh99M7aS5w9DmXPpUDmppSPpwkeTfKiqF0cQiAUq8tpeEQrGDJuw3Qt2.XI8h9Xw-VZj_NOmKtV19wLM63S4snos7rzkoHf9FXCw' + responseHeader['Akamai-DAP-Token'] = tokenWithExpiry; + request.respond(200, responseHeader, JSON.stringify(tokenWithExpiry)); + expect(JSON.parse(storage.getDataFromLocalStorage(DAP_TOKEN)).expires_at).to.be.equal(1643830359); + }); + + it('test dapRefreshToken error response', function () { + storage.setDataInLocalStorage(DAP_TOKEN, JSON.stringify(sampleCachedToken)); + dapUtils.dapRefreshToken(ortb2, sampleConfig, false, onDone) + let request = server.requests[0]; + request.respond(400, responseHeader, 'error'); + expect(JSON.parse(storage.getDataFromLocalStorage(DAP_TOKEN)).expires_at).to.be.equal(cacheExpiry);// Since the expiry is same, the token is not updated in the cache + }); + }); + + describe('dapRefreshEncryptedMembership test', function () { + it('test dapRefreshEncryptedMembership success response', function () { + let expiry = Math.round(Date.now() / 1000.0) + 3600; // in seconds + let encMembership = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoic29tZXNlY3JldGludmF1bHQifQ..f8_At4OqeQXyQcSwThOJ_w.69ImVQ3bEZ6QP7ROCRpAJjNcKY49SEPYR6qTp_8l7L8kQdPbpi4wmuOzt78j7iBrX64k2wltzmQFjDmVKSxDhrEguxpgx6t-L1tT8ZA0UosMWpVsgmKEZxOn2e9ES3jw8RNCS4WSWocSPQX33xSb51evXjm9E1s0tGoLnwXl0GsUvzRsSU86wQG6RZnAQTi7s-r-M2TKibdDjUqgIt62vJ-aBZ7RWw91MINgOdmDNs1bFfbBX5Cy1kd4-kjvRDz_aJ6zHX4sK_7EmQhGEY3tW-A3_l2I88mw-RSJaPkb_IWg0QpVwXDaE2F2g8NpY1PzCRvG_NIE8r28eK5q44OMVitykHmKmBXGDj7z2JVgoXkfo5u0I-dypZARn4GP_7niK932avB-9JD7Mz3TrlU4GZ7IpYfJ91PMsRhrs5xNPQwLZbpuhF76A7Dp7iss71UjkGCiPTU6udfRb4foyf_7xEF66m1eQVcVaMdxEbMuu9GBfdr-d04TbtJhPfUV8JfxTenvRYoi13n0j5kH0M5OgaSQD9kQ3Mrd9u-Cms-BGtT0vf-N8AaFZY_wn0Y4rkpv5HEaH7z3iT4RCHINWrXb_D0WtjLTKQi2YmF8zMlzUOewNJGwZRwbRwxc7JoDIKEc5RZkJYevfJXOEEOPGXZ7AGZxOEsJawPqFqd_nOUosCZS4akHhcDPcVowoecVAV0hhhoS6JEY66PhPp1snbt6yqA-fQhch7z8Y-DZT3Scibvffww3Scg_KFANWp0KeEvHG0vyv9R2F4o66viSS8y21MDnM7Yjk8C-j7aNMldUQbjN_7Yq1nkfe0jiBX_hsINBRPgJHUY4zCaXuyXs-JZZfU92nwG0RT3A_3RP2rpY8-fXp9d3C2QJjEpnmHvTMsuAZCQSBe5DVrJwN_UKedxcJEoOt0wLz6MaCMyYZPd8tnQeqYK1cd3RgQDXtzKC0HDw1En489DqJXEst4eSSkaaW1lImLeaF8XCOaIqPqoyGk4_6KVLw5Q7OnpczuXqYKMd9UTMovGeuTuo1k0ddfEqTq9QwxkwZL51AiDRnwTCAeYBU1krV8FCJQx-mH_WPB5ftZj-o_3pbvANeRk27QBVmjcS-tgDllJkWBxX-4axRXzLw8pUUUZUT_NOL0OiqUCWVm0qMBEpgRQ57Se42-hkLMTzLhhGJOnVcaXU1j4ep-N7faNvbgREBjf_LgzvaWS90a2NJ9bB_J9FyXelhCN_AMLfdOS3fHkeWlZ0u0PMbn5DxXRMe0l9jB-2VJZhcPQRlWoYyoCO3l4F5ZmuQP5Xh9CU4tvSWih6jlwMDgdVWuTpdfPD5bx8ccog3JDq87enx-QtPzLU3gMgouNARJGgNwKS_GJSE1uPrt2oiqgZ3Z0u_I5MKvPdQPV3o-4rsaE730eB4OwAOF-mkGWpzy8Pbl-Qe5PR9mHBhuyJgZ-WDSCHl5yvet2kfO9mPXZlqBQ26fzTcUYH94MULAZn36og6w.3iKGv-Le-AvRmi26W1v6ibRLGbwKbCR92vs-a9t55hw'; + dapUtils.dapRefreshEncryptedMembership(ortb2, esampleConfig, sampleCachedToken.token, onDone) + let request = server.requests[0]; + responseHeader['Akamai-DAP-Token'] = encMembership; + request.respond(200, responseHeader, encMembership); + let rtdObj = dapUtils.dapGetEncryptedRtdObj({'encryptedSegments': encMembership}, 504) + expect(ortb2.user.data).to.deep.include.members(rtdObj.rtd.ortb2.user.data); + expect(JSON.parse(storage.getDataFromLocalStorage(DAP_ENCRYPTED_MEMBERSHIP)).expires_at).to.equal(expiry); + }); + + it('test dapRefreshEncryptedMembership success response with exp claim', function () { + let encMembership = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoic29tZXNlY3JldGludmF1bHQiLCJleHAiOjE2NDM4MzA2NDB9..inYoxwht_aqTIWqGhEm_Gw.wDcCUOCwtqgnNUouaD723gKfm7X7bgkHgtiX4mr07P3tWk25PUQunmwTLhWBB5CYzzGIfIvveG_u4glNRLi_eRSQV4ihKKk1AN-BSSJ3d0CLAdY9I1WG5vX1VmopXyKnV90bl9SLNqnhg4Vxe6YU4ogTYxsKHuIN1EeIH4hpl-HbCQWQ1DQt4mB-MQF8V9AWTfU0D7sFMSK8f9qj6NGmf1__oHdHUlws0t5V2UAn_dhJexsuREK_gh65pczCuly5eEcziZ82LeP-nOhKWSRHB_tS_mKXrRU6_At_EVDgtfA3PSBJ6eQylCii6bTL42vZzz4jZhJv_3eLfRdKqpVT5CWNBzcDoQ2VcQgKgIBtPJ45KFfAYTQ6kdl21QMSjqtu8GTsv1lEZtrqHY6zRiG8_Mu28-PmjEw4LDdZmBDOeroue_MJD6wuE_jlE7J2iVdo8CkVnoRgzFwNbKBo7CK4z0WahV9rhuOm0LKAN5H0jF_gj696U-3fVTDTIb8ndNKNI2_xAhvWs00BFGtUtWgr8QGDGRTDCNGsDgnb_Vva9xCqVOyAE9O3Fq1QYl-tMA-KkBt3zzvmFFpOxpOyH-lUubKLKlsrxKc3GSyVEQ9DDLhrXXJgR5H5BSE4tjlK7p3ODF5qz0FHtIj7oDcgLazFO7z2MuFy2LjJmd3hKl6ujcfYEDiQ4D3pMIo7oiU33aFBD1YpzI4-WzNfJlUt1FoK0-DAXpbbV95s8p08GOD4q81rPw5hRADKJEr0QzrbDwplTWCzT2fKXMg_dIIc5AGqGKnVRUS6UyF1DnHpudNIJWxyWZjWIEw_QNjU0cDFmyPSyKxNrnfq9w8WE2bfbS5KTicxei5QHnC-cnL7Nh7IXp7WOW6R1YHbNPT7Ad4OhnlV-jjrXwkSv4wMAbfwAWoSCchGh7uvENNAeJymuponlJbOgw_GcYM73hMs8Z8W9qxRfbyF4WX5fDKXg61mMlaieHkc0EnoC5q7uKyXuZUehHZ76JLDFmewslLkQq5SkVCttzJePBnY1ouPEHw5ZTzUnG5f01QQOVcjIN-AqXNDbG5IOwq0heyS6vVfq7lZKJdLDVQ21qRjazGPaqYwLzugkWkzCOzPTgyFdbXzgjfmJwylHSOM5Jpnul84GzxEQF-1mHP2A8wtIT-M7_iX24It2wwWvc8qLA6GEqruWCtNyoug8CXo44mKdSSCGeEZHtfMbzXdLIBHCy2jSHz5i8S7DU_R7rE_5Ssrb81CqIYbgsAQBHtOYoyvzduTOruWcci4De0QcULloqImIEHUuIe2lnYO889_LIx5p7nE3UlSvLBo0sPexavFUtHqI6jdG6ye9tdseUEoNBDXW0aWD4D-KXX1JLtAgToPVUtEaXCJI7QavwO9ZG6UZM6jbfuJ5co0fvUXp6qYrFxPQo2dYHkar0nT6s1Zg5l2g8yWlLUJrHdHAzAw_NScUp71OpM4TmNsLnYaPVPcOxMvtJXTanbNWr0VKc8gy9q3k_1XxAnQwiduNs7f5bA-6qCVpayHv5dE7mUhFEwyh1_w95jEaURsQF_hnnd2OqRkADfiok4ZiPU2b38kFW1LXjpI39XXES3JU0e08Rq2uuelyLbCLWuJWq_axuKSZbZvpYeqWtIAde8FjCiO7RPlEc0nyzWBst8RBxQ-Bekg9UXPhxBRcm0HwA.Q2cBSFOQAC-QKDwmjrQXnVQd3jNOppMl9oZfd2yuKeY'; + dapUtils.dapRefreshEncryptedMembership(ortb2, esampleConfig, sampleCachedToken.token, onDone) + let request = server.requests[0]; + responseHeader['Akamai-DAP-Token'] = encMembership; + request.respond(200, responseHeader, encMembership); + let rtdObj = dapUtils.dapGetEncryptedRtdObj({'encryptedSegments': encMembership}, 504) + expect(ortb2.user.data).to.deep.include.members(rtdObj.rtd.ortb2.user.data); + expect(JSON.parse(storage.getDataFromLocalStorage(DAP_ENCRYPTED_MEMBERSHIP)).expires_at).to.equal(1643830630); + }); + + it('test dapRefreshEncryptedMembership error response', function () { + dapUtils.dapRefreshEncryptedMembership(ortb2, esampleConfig, sampleCachedToken.token, onDone) + let request = server.requests[0]; + request.respond(400, responseHeader, 'error'); + expect(ortb2).to.eql({}); + }); + + it('test dapRefreshEncryptedMembership 403 error response', function () { + dapUtils.dapRefreshEncryptedMembership(ortb2, esampleConfig, sampleCachedToken.token, onDone) + let request = server.requests[0]; + request.respond(403, responseHeader, 'error'); + let requestTokenize = server.requests[1]; + responseHeader['Akamai-DAP-Token'] = sampleCachedToken.token; + requestTokenize.respond(200, responseHeader, ''); + let requestMembership = server.requests[2]; + requestMembership.respond(403, responseHeader, 'error'); + expect(server.requests.length).to.be.equal(DAP_MAX_RETRY_TOKENIZE + 2); + }); + }); + + describe('dapRefreshMembership test', function () { + it('test dapRefreshMembership success response', function () { + let membership = {'cohorts': ['9', '11', '13'], 'said': 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIn0..17wnrhz6FbWx0Cf6LXpm1A.m9PKVCradk3CZokNKzVHzE06TOqiXYeijgxTQUiQy5Syx-yicnO8DyYX6zQ6rgPcNgUNRt4R4XE5MXuK0laUVQJr9yc9g3vUfQfw69OMYGW_vRlLMPzoNOhF2c4gSyfkRrLr7C0qgALmZO1D11sPflaCTNmO7pmZtRaCOB5buHoWcQhp1bUSJ09DNDb31dX3llimPwjNGSrUhyq_EZl4HopnnjxbM4qVNMY2G_43C_idlVOvbFoTxcDRATd-6MplJoIOIHQLDZEetpIOVcbEYN9gQ_ndBISITwuu5YEgs5C_WPHA25nm6e4BT5R-tawSA8yPyQAupqE8gk4ZWq_2-T0cqyTstIHrMQnZ_vysYN7h6bkzE-KeZRk7GMtySN87_fiu904hLD9QentGegamX6UAbVqQh7Htj7SnMHXkEenjxXAM5mRqQvNCTlw8k-9-VPXs-vTcKLYP8VFf8gMOmuYykgWac1gX-svyAg-24mo8cUbqcsj9relx4Qj5HiXUVyDMBZxK-mHZi-Xz6uv9GlggcsjE13DSszar-j2OetigpdibnJIxRZ-4ew3-vlvZ0Dul3j0LjeWURVBWYWfMjuZ193G7lwR3ohh_NzlNfwOPBK_SYurdAnLh7jJgTW-lVLjH2Dipmi9JwX9s03IQq9opexAn7hlM9oBI6x5asByH8JF8WwZ5GhzDjpDwpSmHPQNGFRSyrx_Sh2CPWNK6C1NJmLkyqAtJ5iw0_al7vPDQyZrKXaLTjBCUnbpJhUZ8dUKtWLzGPjzFXp10muoDIutd1NfyKxk1aWGhx5aerYuLdywv6cT_M8RZTi8924NGj5VA30V5OvEwLLyX93eDhntXZSCbkPHpAfiRZNGXrPY.GhCbWGQz11mIRD4uPKmoAuFXDH7hGnils54zg7N7-TU'} + dapUtils.dapRefreshMembership(ortb2, sampleConfig, sampleCachedToken.token, onDone); + let request = server.requests[0]; + request.respond(200, responseHeader, JSON.stringify(membership)); + let rtdObj = dapUtils.dapGetRtdObj(membership, 503); + expect(ortb2.user.data).to.deep.include.members(rtdObj.rtd.ortb2.user.data); + }); + + it('test dapRefreshMembership success response with exp claim', function () { + let membership = {'cohorts': ['9', '11', '13'], 'said': 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2Iiwia2lkIjoicGFzc3dvcmQxIiwiZXhwIjoxNjQ3OTcxNTU4fQ..ptdM5WO-62ypXlKxFXD4FQ.waEo9MHS2NYQCi-zh_p6HgT9BdqGyQbBq4GfGLfsay4nRBgICsTS-VkV6e7xx5U1T8BgpKkRJIZBwTOY5Pkxk9FpK5nnffDSEljRrp1LXLCkNP4qwrlqHInFbZsonNWW4_mW-7aUPlTwIsTbfjTuyHdXHeQa1ALrwFFFWE7QUmPNd2RsHjDwUsxlJPEb5TnHn5W0Mgo_PQZaxvhJInMbxPgtJLoqnJvOqCBEoQY7au7ALZL_nWK8XIwPMF19J7Z3cBg9vQInhr_E3rMdQcAFHEzYfgoNcIYCCR0t1UOqUE3HNtX-E64kZAYKWdlsBb9eW5Gj9hHYyPNL_4Hntjg5eLXGpsocMg0An-qQKGC6hkrxKzeM-GrjpvSaQLNs4iqDpHUtzA02LW_vkLkMNRUiyXVJ3FUZwfyq6uHSRKWZ6UFdAfL0rfJ8q8x8Ll-qJO2Jfyvidlsi9FIs7x1WJrvDCKepfAQM1UXRTonrQljFBAk83PcL2bmWuJDgJZ0lWS4VnZbIf6A7fDourmkDxdVRptvQq5nSjtzCA6whRw0-wGz8ehNJsaJw9H_nG9k4lRKs7A5Lqsyy7TVFrAPjnA_Q1a2H6xF2ULxrtIqoNqdX7k9RjowEZSQlZgZUOAmI4wzjckdcSyC_pUlYBMcBwmlld34mmOJe9EBHAxjdci7Q_9lvj1HTcwGDcQITXnkW9Ux5Jkt9Naw-IGGrnEIADaT2guUAto8W_Gb05TmwHSd6DCmh4zepQCbqeVe6AvPILtVkTgsTTo27Q-NvS7h-XtthJy8425j5kqwxxpZFJ0l0ytc6DUyNCLJXuxi0JFU6-LoSXcROEMVrHa_Achufr9vHIELwacSAIHuwseEvg_OOu1c1WYEwZH8ynBLSjqzy8AnDj24hYgA0YanPAvDqacrYrTUFqURbHmvcQqLBTcYa_gs7uDx4a1EjtP_NvHRlvCgGAaASrjGMhTX8oJxlTqahhQ.pXm-7KqnNK8sbyyczwkVYhcjgiwkpO8LjBBVw4lcyZE'}; + dapUtils.dapRefreshMembership(ortb2, sampleConfig, sampleCachedToken.token, onDone); + let request = server.requests[0]; + request.respond(200, responseHeader, JSON.stringify(membership)); + let rtdObj = dapUtils.dapGetRtdObj(membership, 503) + expect(ortb2.user.data).to.deep.include.members(rtdObj.rtd.ortb2.user.data); + expect(JSON.parse(storage.getDataFromLocalStorage(DAP_MEMBERSHIP)).expires_at).to.be.equal(1647971548); + }); + + it('test dapRefreshMembership 400 error response', function () { + dapUtils.dapRefreshMembership(ortb2, sampleConfig, sampleCachedToken.token, onDone) + let request = server.requests[0]; + request.respond(400, responseHeader, 'error'); + expect(ortb2).to.eql({}); + }); + + it('test dapRefreshMembership 403 error response', function () { + dapUtils.dapRefreshMembership(ortb2, sampleConfig, sampleCachedToken.token, onDone) + let request = server.requests[0]; + request.respond(403, responseHeader, 'error'); + expect(server.requests.length).to.be.equal(DAP_MAX_RETRY_TOKENIZE); + }); + }); + + describe('dapGetEncryptedMembershipFromLocalStorage test', function () { + it('test dapGetEncryptedMembershipFromLocalStorage function with valid cache', function () { + storage.setDataInLocalStorage(DAP_ENCRYPTED_MEMBERSHIP, JSON.stringify(cachedEncryptedMembership)) + expect(JSON.stringify(dapUtils.dapGetEncryptedMembershipFromLocalStorage())).to.equal(JSON.stringify(encMembership)); + }); + + it('test dapGetEncryptedMembershipFromLocalStorage function with invalid cache', function () { + let expiry = Math.round(Date.now() / 1000.0) - 100; // in seconds + let encMembership = {'expiry': expiry, 'encryptedSegments': cachedEncryptedMembership.encryptedSegments} + storage.setDataInLocalStorage(DAP_ENCRYPTED_MEMBERSHIP, JSON.stringify(encMembership)) + expect(dapUtils.dapGetEncryptedMembershipFromLocalStorage()).to.equal(null); + }); + }); + + describe('Akamai-DAP-SS-ID test', function () { + it('Akamai-DAP-SS-ID present in response header', function () { + let expiry = Math.round(Date.now() / 1000.0) + 300; // in seconds + dapUtils.dapRefreshToken(ortb2, sampleConfig, false, onDone) + let request = server.requests[0]; + let sampleSSID = 'Test_SSID_Spec'; + responseHeader['Akamai-DAP-Token'] = sampleCachedToken.token; + responseHeader['Akamai-DAP-SS-ID'] = sampleSSID; + request.respond(200, responseHeader, ''); + expect(storage.getDataFromLocalStorage(DAP_SS_ID)).to.be.equal(JSON.stringify(sampleSSID)); + }); + + it('Test if Akamai-DAP-SS-ID is present in request header', function () { + let expiry = Math.round(Date.now() / 1000.0) + 100; // in seconds + storage.setDataInLocalStorage(DAP_SS_ID, JSON.stringify('Test_SSID_Spec')) + dapUtils.dapRefreshToken(ortb2, sampleConfig, false, onDone) + let request = server.requests[0]; + let ssidHeader = request.requestHeaders['Akamai-DAP-SS-ID']; + responseHeader['Akamai-DAP-Token'] = sampleCachedToken.token; + request.respond(200, responseHeader, ''); + expect(ssidHeader).to.be.equal('Test_SSID_Spec'); + }); + }); + + describe('Test gdpr and usp consent handling', function () { + it('Gdpr applies and gdpr consent string not present', function () { + expect(akamaiDapRtdSubmodule.init(null, sampleGdprConsentConfig)).to.equal(false); + }); + + it('Gdpr applies and gdpr consent string is present', function () { + sampleGdprConsentConfig.gdpr.consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A=='; + expect(akamaiDapRtdSubmodule.init(null, sampleGdprConsentConfig)).to.equal(true); + }); + + it('USP consent present and user have opted out', function () { + expect(akamaiDapRtdSubmodule.init(null, sampleUspConsentConfig)).to.equal(false); + }); + + it('USP consent present and user have not been provided with option to opt out', function () { + expect(akamaiDapRtdSubmodule.init(null, {'usp': '1NYY'})).to.equal(false); + }); + + it('USP consent present and user have not opted out', function () { + expect(akamaiDapRtdSubmodule.init(null, {'usp': '1YNY'})).to.equal(true); }); }); }); diff --git a/test/spec/modules/alkimiBidAdapter_spec.js b/test/spec/modules/alkimiBidAdapter_spec.js new file mode 100644 index 00000000000..3101fac7500 --- /dev/null +++ b/test/spec/modules/alkimiBidAdapter_spec.js @@ -0,0 +1,222 @@ +import { expect } from 'chai' +import { ENDPOINT, spec } from 'modules/alkimiBidAdapter.js' +import { newBidder } from 'src/adapters/bidderFactory.js' + +const REQUEST = { + 'bidId': '456', + 'bidder': 'alkimi', + 'sizes': [[300, 250]], + 'adUnitCode': 'bannerAdUnitCode', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'params': { + bidFloor: 0.1, + token: 'e64782a4-8e68-4c38-965b-80ccf115d46f' + }, + 'userIdAsEids': [{ + 'source': 'criteo.com', + 'uids': [{ + 'id': 'test', + 'atype': 1 + }] + }, { + 'source': 'pubcid.org', + 'uids': [{ + 'id': 'test', + 'atype': 1 + }] + }], + 'schain': { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'alkimi-onboarding.com', + sid: '00001', + hp: 1 + }] + } +} + +const BIDDER_BANNER_RESPONSE = { + 'prebidResponse': [{ + 'ad': '
test
', + 'requestId': 'e64782a4-8e68-4c38-965b-80ccf115d46d', + 'cpm': 900.5, + 'currency': 'USD', + 'width': 640, + 'height': 480, + 'ttl': 300, + 'creativeId': 1, + 'netRevenue': true, + 'winUrl': 'http://test.com', + 'mediaType': 'banner', + 'adomain': ['test.com'] + }] +} + +const BIDDER_VIDEO_RESPONSE = { + 'prebidResponse': [{ + 'ad': 'vast', + 'requestId': 'e64782a4-8e68-4c38-965b-80ccf115d46z', + 'cpm': 800.4, + 'currency': 'USD', + 'width': 1024, + 'height': 768, + 'ttl': 200, + 'creativeId': 2, + 'netRevenue': true, + 'winUrl': 'http://test.com', + 'mediaType': 'video', + 'adomain': ['test.com'] + }] +} + +const BIDDER_NO_BID_RESPONSE = '' + +describe('alkimiBidAdapter', function () { + const adapter = newBidder(spec) + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function') + }) + }) + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(REQUEST)).to.equal(true) + }) + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, REQUEST) + delete bid.params.token + expect(spec.isBidRequestValid(bid)).to.equal(false) + + bid = Object.assign({}, REQUEST) + delete bid.params + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) + }) + + describe('buildRequests', function () { + let bidRequests = [REQUEST] + let requestData = { + refererInfo: { + page: 'http://test.com/path.html' + }, + gdprConsent: { + consentString: 'test-consent', + vendorData: {}, + gdprApplies: true + }, + uspConsent: 'uspConsent', + ortb2: { + site: { + keywords: 'test1, test2' + }, + at: 2, + bcat: ['BSW1', 'BSW2'], + wseat: ['16', '165'] + } + } + const bidderRequest = spec.buildRequests(bidRequests, requestData) + + it('should return a properly formatted request with eids defined', function () { + expect(bidderRequest.data.eids).to.deep.equal(REQUEST.userIdAsEids) + }) + + it('should return a properly formatted request with gdpr defined', function () { + expect(bidderRequest.data.gdprConsent.consentRequired).to.equal(true) + expect(bidderRequest.data.gdprConsent.consentString).to.equal('test-consent') + }) + + it('should return a properly formatted request with uspConsent defined', function () { + expect(bidderRequest.data.uspConsent).to.equal('uspConsent') + }) + + it('sends bid request to ENDPOINT via POST', function () { + expect(bidderRequest.method).to.equal('POST') + expect(bidderRequest.data.requestId).to.not.equal(undefined) + expect(bidderRequest.data.referer).to.equal('http://test.com/path.html') + expect(bidderRequest.data.schain).to.deep.contains({ ver: '1.0', complete: 1, nodes: [{ asi: 'alkimi-onboarding.com', sid: '00001', hp: 1 }] }) + expect(bidderRequest.data.signRequest.bids).to.deep.contains({ token: 'e64782a4-8e68-4c38-965b-80ccf115d46f', bidFloor: 0.1, sizes: [{ width: 300, height: 250 }], playerSizes: [], impMediaTypes: ['Banner'], adUnitCode: 'bannerAdUnitCode', instl: undefined, exp: undefined, banner: { sizes: [[300, 250]] }, video: undefined }) + expect(bidderRequest.data.signRequest.randomUUID).to.equal(undefined) + expect(bidderRequest.data.bidIds).to.deep.contains('456') + expect(bidderRequest.data.signature).to.equal(undefined) + expect(bidderRequest.data.ortb2).to.deep.contains({ at: 2, wseat: ['16', '165'], bcat: ['BSW1', 'BSW2'], site: { keywords: 'test1, test2' }, }) + expect(bidderRequest.options.customHeaders).to.deep.equal({ 'Rtb-Direct': true }) + expect(bidderRequest.options.contentType).to.equal('application/json') + expect(bidderRequest.url).to.equal(ENDPOINT) + }) + + it('sends bidFloor when configured', () => { + const requestWithFloor = Object.assign({}, REQUEST); + requestWithFloor.getFloor = function (arg) { + if (arg.currency === 'USD' && arg.mediaType === 'banner' && JSON.stringify(arg.size) === JSON.stringify([300, 250])) { + return { currency: 'USD', floor: 0.3 } + } + } + const bidderRequestFloor = spec.buildRequests([requestWithFloor], requestData); + expect(bidderRequestFloor.data.signRequest.bids[0].bidFloor).to.be.equal(0.3); + }); + }) + + describe('interpretResponse', function () { + it('handles banner request : should get correct bid response', function () { + const result = spec.interpretResponse({ body: BIDDER_BANNER_RESPONSE }, {}) + + expect(result[0]).to.have.property('ad').equal('
test
') + expect(result[0]).to.have.property('requestId').equal('e64782a4-8e68-4c38-965b-80ccf115d46d') + expect(result[0]).to.have.property('cpm').equal(900.5) + expect(result[0]).to.have.property('currency').equal('USD') + expect(result[0]).to.have.property('width').equal(640) + expect(result[0]).to.have.property('height').equal(480) + expect(result[0]).to.have.property('ttl').equal(300) + expect(result[0]).to.have.property('creativeId').equal(1) + expect(result[0]).to.have.property('netRevenue').equal(true) + expect(result[0]).to.have.property('winUrl').equal('http://test.com') + expect(result[0]).to.have.property('mediaType').equal('banner') + expect(result[0].meta).to.exist.property('advertiserDomains') + expect(result[0].meta).to.have.property('advertiserDomains').lengthOf(1) + }) + + it('handles video request : should get correct bid response', function () { + const result = spec.interpretResponse({ body: BIDDER_VIDEO_RESPONSE }, {}) + + expect(result[0]).to.have.property('ad').equal('vast') + expect(result[0]).to.have.property('requestId').equal('e64782a4-8e68-4c38-965b-80ccf115d46z') + expect(result[0]).to.have.property('cpm').equal(800.4) + expect(result[0]).to.have.property('currency').equal('USD') + expect(result[0]).to.have.property('width').equal(1024) + expect(result[0]).to.have.property('height').equal(768) + expect(result[0]).to.have.property('ttl').equal(200) + expect(result[0]).to.have.property('creativeId').equal(2) + expect(result[0]).to.have.property('netRevenue').equal(true) + expect(result[0]).to.have.property('winUrl').equal('http://test.com') + expect(result[0]).to.have.property('mediaType').equal('video') + expect(result[0]).to.have.property('vastXml').equal('vast') + expect(result[0].meta).to.exist.property('advertiserDomains') + expect(result[0].meta).to.have.property('advertiserDomains').lengthOf(1) + }) + + it('handles no bid response : should get empty array', function () { + let result = spec.interpretResponse({ body: undefined }, {}) + expect(result).to.deep.equal([]) + + result = spec.interpretResponse({ body: BIDDER_NO_BID_RESPONSE }, {}) + expect(result).to.deep.equal([]) + }) + }) + + describe('onBidWon', function () { + it('handles banner win: should get true', function () { + const win = BIDDER_BANNER_RESPONSE.prebidResponse[0] + const bidWonResult = spec.onBidWon(win) + + expect(bidWonResult).to.equal(true) + }) + }) +}) diff --git a/test/spec/modules/amxBidAdapter_spec.js b/test/spec/modules/amxBidAdapter_spec.js index f502d631c17..984c443344d 100644 --- a/test/spec/modules/amxBidAdapter_spec.js +++ b/test/spec/modules/amxBidAdapter_spec.js @@ -1,57 +1,63 @@ -import * as utils from 'src/utils.js'; -import { createEidsArray } from 'modules/userId/eids.js'; import { expect } from 'chai'; import { spec } from 'modules/amxBidAdapter.js'; +import { createEidsArray } from 'modules/userId/eids.js'; import { BANNER, VIDEO } from 'src/mediaTypes.js'; import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; const sampleRequestId = '82c91e127a9b93e'; -const sampleDisplayAd = (additionalImpressions) => `${additionalImpressions}`; +const sampleDisplayAd = ``; const sampleDisplayCRID = '78827819'; // minimal example vast -const sampleVideoAd = (addlImpression) => ` +const sampleVideoAd = (addlImpression) => + ` 00:00:15${addlImpression} -`.replace(/\n+/g, '') - -const embeddedTrackingPixel = `https://1x1.a-mo.net/hbx/g_impression?A=sample&B=20903`; -const sampleNurl = 'https://example.exchange/nurl'; +`.replace(/\n+/g, ''); const sampleFPD = { site: { keywords: 'sample keywords', ext: { data: { - pageType: 'article' - } - } + pageType: 'article', + }, + }, }, user: { gender: 'O', yob: 1982, - } -}; - -const stubConfig = (withStub) => { - const stub = sinon.stub(config, 'getConfig').callsFake( - (arg) => arg === 'ortb2' ? sampleFPD : null - ) - - withStub(); - stub.restore(); + }, }; const sampleBidderRequest = { gdprConsent: { gdprApplies: true, consentString: utils.getUniqueIdentifierStr(), - vendorData: {} + vendorData: {}, + }, + gppConsent: { + gppString: 'example', + applicableSections: 'example' }, - auctionId: utils.getUniqueIdentifierStr(), + + auctionId: null, + uspConsent: '1YYY', refererInfo: { - referer: 'https://www.prebid.org', - canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' - } + reachedTop: true, + numIframes: 10, + stack: ['https://www.prebid.org'], + canonicalUrl: 'https://prebid.org', + location: 'https://www.prebid.org', + site: 'prebid.org', + topmostLocation: 'https://www.prebid.org', + page: 'https://www.prebid.org/the/link/to/the/page', + }, + ortb2: sampleFPD, +}; + +const sampleImpExt = { + testKey: 'testValue', }; const sampleBidRequestBase = { @@ -59,36 +65,48 @@ const sampleBidRequestBase = { params: { endpoint: 'https://httpbin.org/post', }, + ortb2Imp: { + ext: sampleImpExt, + }, sizes: [[320, 50]], getFloor(params) { - if (params.size == null || params.currency == null || params.mediaType == null) { - throw new Error(`getFloor called with incomplete params: ${JSON.stringify(params)}`) + if ( + params.size == null || + params.currency == null || + params.mediaType == null + ) { + throw new Error( + `getFloor called with incomplete params: ${JSON.stringify(params)}` + ); } return { floor: 0.5, - currency: 'USD' - } + currency: 'USD', + }; }, mediaTypes: { [BANNER]: { - sizes: [[300, 250]] - } + sizes: [[300, 250]], + }, }, adUnitCode: 'div-gpt-ad-example', transactionId: utils.getUniqueIdentifierStr(), bidId: sampleRequestId, - auctionId: utils.getUniqueIdentifierStr(), + + auctionId: null, }; const schainConfig = { ver: '1.0', - nodes: [{ - asi: 'greatnetwork.exchange', - sid: '000001', - hp: 1, - rid: 'bid_request_1', - domain: 'publisher.com' - }] + nodes: [ + { + asi: 'greatnetwork.exchange', + sid: '000001', + hp: 1, + rid: 'bid_request_1', + domain: 'publisher.com', + }, + ], }; const sampleBidRequestVideo = { @@ -101,213 +119,312 @@ const sampleBidRequestVideo = { sizes: [[360, 250]], context: 'adpod', adPodDurationSec: 90, - contentMode: 'live' - } - } + contentMode: 'live', + }, + }, }; const sampleServerResponse = { - 'p': { - 'hreq': ['https://1x1.a-mo.net/hbx/g_sync?partner=test', 'https://1x1.a-mo.net/hbx/g_syncf?__st=iframe'] + p: { + hreq: [ + 'https://1x1.a-mo.net/hbx/g_sync?partner=test', + 'https://1x1.a-mo.net/hbx/g_syncf?__st=iframe', + ], }, - 'r': { + r: { [sampleRequestId]: [ { - 'b': [ + b: [ { - 'adid': '78827819', - 'adm': sampleDisplayAd(''), - 'adomain': [ - 'example.com' - ], - 'crid': sampleDisplayCRID, - 'ext': { - 'himp': [ - embeddedTrackingPixel - ], - }, - 'nurl': sampleNurl, - 'h': 600, - 'id': '2014691335735134254', - 'impid': '1', - 'exp': 90, - 'price': 0.25, - 'w': 300 + adid: '78827819', + adm: sampleDisplayAd, + adomain: ['example.com'], + crid: sampleDisplayCRID, + h: 600, + id: '2014691335735134254', + impid: '1', + exp: 90, + price: 0.25, + w: 300, }, { - 'adid': '222976952', - 'adm': sampleVideoAd(''), - 'adomain': [ - 'example.com' - ], - 'crid': sampleDisplayCRID, - 'ext': { - 'himp': [ - embeddedTrackingPixel - ], - }, - 'nurl': sampleNurl, - 'h': 1, - 'id': '7735706981389902829', - 'impid': '1', - 'exp': 90, - 'price': 0.25, - 'w': 1 + adid: '222976952', + adm: sampleVideoAd(''), + adomain: ['example.com'], + crid: sampleDisplayCRID, + ext: {}, + h: 1, + id: '7735706981389902829', + impid: '1', + exp: 90, + price: 0.25, + w: 1, }, ], - } - ] + }, + ], }, -} +}; describe('AmxBidAdapter', () => { describe('isBidRequestValid', () => { it('endpoint must be an optional string', () => { - expect(spec.isBidRequestValid({params: { endpoint: 1 }})).to.equal(false) - expect(spec.isBidRequestValid({params: { endpoint: 'test' }})).to.equal(true) + expect(spec.isBidRequestValid({ params: { endpoint: 1 } })).to.equal( + false + ); + expect(spec.isBidRequestValid({ params: { endpoint: 'test' } })).to.equal( + true + ); }); it('tagId is an optional string', () => { - expect(spec.isBidRequestValid({params: { tagId: 1 }})).to.equal(false) - expect(spec.isBidRequestValid({params: { tagId: 'test' }})).to.equal(true) + expect(spec.isBidRequestValid({ params: { tagId: 1 } })).to.equal(false); + expect(spec.isBidRequestValid({ params: { tagId: 'test' } })).to.equal( + true + ); }); it('testMode is an optional truthy value', () => { - expect(spec.isBidRequestValid({params: { testMode: 1 }})).to.equal(true) - expect(spec.isBidRequestValid({params: { testMode: 'true' }})).to.equal(true) + expect(spec.isBidRequestValid({ params: { testMode: 1 } })).to.equal( + true + ); + expect(spec.isBidRequestValid({ params: { testMode: 'true' } })).to.equal( + true + ); // ignore invalid values (falsy) - expect(spec.isBidRequestValid({params: { testMode: 'non-truthy-invalid-value' }})).to.equal(true) - expect(spec.isBidRequestValid({params: { testMode: false }})).to.equal(true) + expect( + spec.isBidRequestValid({ + params: { testMode: 'non-truthy-invalid-value' }, + }) + ).to.equal(true); + expect(spec.isBidRequestValid({ params: { testMode: false } })).to.equal( + true + ); }); it('none of the params are required', () => { - expect(spec.isBidRequestValid({})).to.equal(true) + expect(spec.isBidRequestValid({})).to.equal(true); }); - }) + }); describe('getUserSync', () => { - it('will only sync from valid server responses', () => { + it('Will perform an iframe sync even if there is no server response..', () => { const syncs = spec.getUserSyncs({ iframeEnabled: true }); - expect(syncs).to.eql([]); + expect(syncs).to.eql([{ + type: 'iframe', + url: 'https://prebid.a-mo.net/isyn?gdpr_consent=&gdpr=0&us_privacy=&gpp=&gpp_sid=' + }]); }); it('will return valid syncs from a server response', () => { - const syncs = spec.getUserSyncs({ iframeEnabled: true }, [{body: sampleServerResponse}]); + const syncs = spec.getUserSyncs({ iframeEnabled: true }, [ + { body: sampleServerResponse }, + ]); expect(syncs.length).to.equal(2); expect(syncs[0].type).to.equal('image'); expect(syncs[1].type).to.equal('iframe'); }); it('will filter out iframe syncs based on options', () => { - const syncs = spec.getUserSyncs({ iframeEnabled: false }, [{body: sampleServerResponse}, {body: sampleServerResponse}]); + const syncs = spec.getUserSyncs({ iframeEnabled: false }, [ + { body: sampleServerResponse }, + { body: sampleServerResponse }, + ]); expect(syncs.length).to.equal(2); - expect(syncs).to.satisfy((allSyncs) => allSyncs.every((sync) => sync.type === 'image')) + expect(syncs).to.satisfy((allSyncs) => + allSyncs.every((sync) => sync.type === 'image') + ); }); }); describe('buildRequests', () => { it('will default to prebid.a-mo.net endpoint', () => { const { url } = spec.buildRequests([], sampleBidderRequest); - expect(url).to.equal('https://prebid.a-mo.net/a/c') + expect(url).to.equal('https://prebid.a-mo.net/a/c'); }); it('will read the prebid version & global', () => { - const { data: { V: prebidVersion, vg: prebidGlobal } } = spec.buildRequests([{ - ...sampleBidRequestBase, - params: { - testMode: true - } - }], sampleBidderRequest); - expect(prebidVersion).to.equal('$prebid.version$') - expect(prebidGlobal).to.equal('$$PREBID_GLOBAL$$') + const { + data: { V: prebidVersion, vg: prebidGlobal }, + } = spec.buildRequests( + [ + { + ...sampleBidRequestBase, + params: { + testMode: true, + }, + }, + ], + sampleBidderRequest + ); + expect(prebidVersion).to.equal('$prebid.version$'); + expect(prebidGlobal).to.equal('$$PREBID_GLOBAL$$'); }); it('reads test mode from the first bid request', () => { - const { data } = spec.buildRequests([{ - ...sampleBidRequestBase, - params: { - testMode: true - } - }], sampleBidderRequest); + const { data } = spec.buildRequests( + [ + { + ...sampleBidRequestBase, + params: { + testMode: true, + }, + }, + ], + sampleBidderRequest + ); expect(data.tm).to.equal(true); }); + it('will attach additional referrer info data', () => { + const { data } = spec.buildRequests([sampleBidRequestBase], sampleBidderRequest); + expect(data.ri.r).to.equal(sampleBidderRequest.refererInfo.topmostLocation); + expect(data.ri.t).to.equal(sampleBidderRequest.refererInfo.reachedTop); + expect(data.ri.l).to.equal(sampleBidderRequest.refererInfo.numIframes); + expect(data.ri.s).to.equal(sampleBidderRequest.refererInfo.stack); + expect(data.ri.c).to.equal(sampleBidderRequest.refererInfo.canonicalUrl); + }); + it('if prebid is in an iframe, will use the frame url as domain, if the topmost is not avialable', () => { const { data } = spec.buildRequests([sampleBidRequestBase], { ...sampleBidderRequest, refererInfo: { - numIframes: 1, - referer: 'http://search-traffic-source.com', - stack: [] - } + location: null, + topmostLocation: null, + ref: 'http://search-traffic-source.com', + }, }); - expect(data.do).to.equal('localhost') + expect(data.do).to.equal('localhost'); expect(data.re).to.equal('http://search-traffic-source.com'); }); - it('if we are in AMP, make sure we use the canonical URL or the referrer (which is sourceUrl)', () => { - const { data } = spec.buildRequests([sampleBidRequestBase], { - ...sampleBidderRequest, - refererInfo: { - isAmp: true, - referer: 'http://real-publisher-site.com/content', - stack: [] - } - }); - expect(data.do).to.equal('real-publisher-site.com') - expect(data.re).to.equal('http://real-publisher-site.com/content'); - }) - it('if prebid is in an iframe, will use the topmost url as domain', () => { const { data } = spec.buildRequests([sampleBidRequestBase], { ...sampleBidderRequest, refererInfo: { - numIframes: 1, - referer: 'http://search-traffic-source.com', - stack: ['http://top-site.com', 'http://iframe.com'] - } + location: null, + topmostLocation: 'http://top-site.com', + ref: 'http://search-traffic-source.com', + }, }); expect(data.do).to.equal('top-site.com'); expect(data.re).to.equal('http://search-traffic-source.com'); }); - it('handles referer data and GDPR, USP Consent, COPPA', () => { - const { data } = spec.buildRequests([sampleBidRequestBase], sampleBidderRequest); + it('handles GDPR, USP Consent, COPPA, and GPP', () => { + const { data } = spec.buildRequests( + [sampleBidRequestBase], + sampleBidderRequest + ); delete data.m; // don't deal with "m" in this test - expect(data.gs).to.equal(sampleBidderRequest.gdprConsent.gdprApplies) - expect(data.gc).to.equal(sampleBidderRequest.gdprConsent.consentString) - expect(data.usp).to.equal(sampleBidderRequest.uspConsent) - expect(data.cpp).to.equal(0) + expect(data.gs).to.equal(sampleBidderRequest.gdprConsent.gdprApplies); + expect(data.gc).to.equal(sampleBidderRequest.gdprConsent.consentString); + expect(data.usp).to.equal(sampleBidderRequest.uspConsent); + expect(data.gpp).to.equal(sampleBidderRequest.gppConsent); + expect(data.cpp).to.equal(0); }); it('will forward bid request count & wins count data', () => { - const bidderRequestsCount = Math.floor(Math.random() * 100) - const bidderWinsCount = Math.floor(Math.random() * 100) - const { data } = spec.buildRequests([{ - ...sampleBidRequestBase, - bidderRequestsCount, - bidderWinsCount - }], sampleBidderRequest); + const bidderRequestsCount = Math.floor(Math.random() * 100); + const bidderWinsCount = Math.floor(Math.random() * 100); + const { data } = spec.buildRequests( + [ + { + ...sampleBidRequestBase, + bidderRequestsCount, + bidderWinsCount, + }, + ], + sampleBidderRequest + ); - expect(data.brc).to.equal(bidderRequestsCount) - expect(data.bwc).to.equal(bidderWinsCount) - expect(data.trc).to.equal(0) + expect(data.brc).to.equal(bidderRequestsCount); + expect(data.bwc).to.equal(bidderWinsCount); + expect(data.trc).to.equal(0); }); + + it('will attach sync configuration', () => { + const request = () => spec.buildRequests( + [sampleBidRequestBase], + sampleBidderRequest + ); + + const setConfig = (filterSettings) => + config.setConfig({ + userSync: { + syncsPerBidder: 2, + syncDelay: 2300, + syncEnabled: true, + filterSettings, + } + }); + + const test = (filterSettings) => { + setConfig(filterSettings); + return request().data.sync; + } + + const base = { d: 2300, l: 2, e: true }; + + const tests = [[ + undefined, + { ...base, t: 0 } + ], [{ + image: { + bidders: '*', + filter: 'include' + }, + iframe: { + bidders: '*', + filter: 'include' + } + }, { ...base, t: 3 }], [{ + image: { + bidders: ['amx'], + }, + iframe: { + bidders: '*', + filter: 'include' + } + }, { ...base, t: 3 }], [{ + image: { + bidders: ['other'], + }, + iframe: { + bidders: '*' + } + }, { ...base, t: 2 }], [{ + image: { + bidders: ['amx'] + }, + iframe: { + bidders: ['amx'], + filter: 'exclude' + } + }, { ...base, t: 1 }]] + + for (let i = 0, l = tests.length; i < l; i++) { + const [result, expected] = tests[i]; + expect(test(result), `input: ${JSON.stringify(result)}`).to.deep.equal(expected); + } + }); + it('will forward first-party data', () => { - stubConfig(() => { - const { data } = spec.buildRequests([sampleBidRequestBase], sampleBidderRequest); - expect(data.fpd2).to.deep.equal(sampleFPD) - }); + const { data } = spec.buildRequests( + [sampleBidRequestBase], + sampleBidderRequest + ); + expect(data.fpd2).to.deep.equal(sampleFPD); }); it('will collect & forward RTI user IDs', () => { - const randomRTI = `greatRTI${Math.floor(Math.random() * 100)}` + const randomRTI = `greatRTI${Math.floor(Math.random() * 100)}`; const userId = { britepoolid: 'sample-britepool', criteoId: 'sample-criteo', - digitrustid: {data: {id: 'sample-digitrust'}}, - id5id: {uid: 'sample-id5'}, + digitrustid: { data: { id: 'sample-digitrust' } }, + id5id: { uid: 'sample-id5' }, idl_env: 'sample-liveramp', - lipb: {lipbid: 'sample-liveintent'}, + lipb: { lipbid: 'sample-liveintent' }, netId: 'sample-netid', parrableId: { eid: 'sample-parrable' }, pubcid: 'sample-pubcid', @@ -318,71 +435,75 @@ describe('AmxBidAdapter', () => { const eids = createEidsArray(userId); const bid = { ...sampleBidRequestBase, - userIdAsEids: eids + userIdAsEids: eids, }; const { data } = spec.buildRequests([bid, bid], sampleBidderRequest); - expect(data.eids).to.deep.equal(eids) + expect(data.eids).to.deep.equal(eids); }); it('can build a banner request', () => { - const { method, url, data } = spec.buildRequests([sampleBidRequestBase, { - ...sampleBidRequestBase, - bidId: sampleRequestId + '_2', - params: { - ...sampleBidRequestBase.params, - tagId: 'example' - } - }], sampleBidderRequest) + const { method, url, data } = spec.buildRequests( + [ + sampleBidRequestBase, + { + ...sampleBidRequestBase, + bidId: sampleRequestId + '_2', + params: { + ...sampleBidRequestBase.params, + adUnitId: '', + tagId: 'example', + }, + }, + ], + sampleBidderRequest + ); - expect(url).to.equal(sampleBidRequestBase.params.endpoint) + expect(url).to.equal(sampleBidRequestBase.params.endpoint); expect(method).to.equal('POST'); expect(Object.keys(data.m).length).to.equal(2); expect(data.m[sampleRequestId]).to.deep.equal({ av: true, au: 'div-gpt-ad-example', vd: {}, - ms: [ - [[320, 50]], - [[300, 250]], - [] - ], + ms: [[[320, 50]], [[300, 250]], []], aw: 300, sc: {}, ah: 250, tf: 0, f: 0.5, - vr: false + vr: false, + rtb: { + ext: sampleImpExt, + }, }); expect(data.m[sampleRequestId + '_2']).to.deep.equal({ av: true, aw: 300, au: 'div-gpt-ad-example', sc: {}, - ms: [ - [[320, 50]], - [[300, 250]], - [] - ], + ms: [[[320, 50]], [[300, 250]], []], i: 'example', ah: 250, vd: {}, tf: 0, f: 0.5, vr: false, + rtb: { + ext: sampleImpExt, + }, }); }); it('can build a video request', () => { - const { data } = spec.buildRequests([sampleBidRequestVideo], sampleBidderRequest); + const { data } = spec.buildRequests( + [{ ...sampleBidRequestVideo, params: { ...sampleBidRequestVideo.params, adUnitId: 'custom-auid' } }], + sampleBidderRequest + ); expect(Object.keys(data.m).length).to.equal(1); expect(data.m[sampleRequestId + '_video']).to.deep.equal({ - au: 'div-gpt-ad-example', - ms: [ - [[300, 150]], - [], - [[360, 250]] - ], + au: 'custom-auid', + ms: [[[300, 150]], [], [[360, 250]]], av: true, aw: 360, ah: 250, @@ -391,11 +512,14 @@ describe('AmxBidAdapter', () => { sizes: [[360, 250]], context: 'adpod', adPodDurationSec: 90, - contentMode: 'live' + contentMode: 'live', }, tf: 0, f: 0.5, - vr: true + rtb: { + ext: sampleImpExt, + }, + vr: true, }); }); }); @@ -419,18 +543,21 @@ describe('AmxBidAdapter', () => { aw: 300, ah: 250, }, - } - } + }, + }, }; it('will handle a nobid response', () => { - const parsed = spec.interpretResponse({ body: '' }, baseRequest) - expect(parsed).to.eql([]) + const parsed = spec.interpretResponse({ body: '' }, baseRequest); + expect(parsed).to.eql([]); }); it('can parse a display ad', () => { - const parsed = spec.interpretResponse({ body: sampleServerResponse }, baseRequest) - expect(parsed.length).to.equal(2) + const parsed = spec.interpretResponse( + { body: sampleServerResponse }, + baseRequest + ); + expect(parsed.length).to.equal(2); // we should have display, video, display expect(parsed[0]).to.deep.equal({ @@ -443,16 +570,16 @@ describe('AmxBidAdapter', () => { width: 300, height: 600, // from the bid itself ttl: 90, - ad: sampleDisplayAd( - `` + - `` - ), + ad: sampleDisplayAd, }); }); it('can parse a video ad', () => { - const parsed = spec.interpretResponse({ body: sampleServerResponse }, baseRequest) - expect(parsed.length).to.equal(2) + const parsed = spec.interpretResponse( + { body: sampleServerResponse }, + baseRequest + ); + expect(parsed.length).to.equal(2); expect(parsed[1]).to.deep.equal({ ...baseBidResponse, meta: { @@ -474,10 +601,17 @@ describe('AmxBidAdapter', () => { before(() => { _Image = window.Image; window.Image = class FakeImage { + _src = ''; + + get src() { + return this._src; + } + set src(value) { - firedPixels.push(value) + this._src = value; + firedPixels.push(value); } - } + }; }); beforeEach(() => { @@ -501,24 +635,26 @@ describe('AmxBidAdapter', () => { adserverTargeting: { hb_pb: '1.23', hb_adid: 'ad-id', - hb_bidder: 'example' - } + hb_bidder: 'example', + }, }); - expect(firedPixels.length).to.equal(1) - expect(firedPixels[0]).to.match(/\/hbx\/g_pbst/) + expect(firedPixels.length).to.equal(1); + expect(firedPixels[0]).to.match(/\/hbx\/g_pbst/); try { const parsed = new URL(firedPixels[0]); const nestedData = parsed.searchParams.get('c2'); - expect(nestedData).to.equal(utils.formatQS({ - hb_pb: '1.23', - hb_adid: 'ad-id', - hb_bidder: 'example' - })); + expect(nestedData).to.equal( + utils.formatQS({ + hb_pb: '1.23', + hb_adid: 'ad-id', + hb_bidder: 'example', + }) + ); } catch (e) { // unsupported browser; try testing for string const pixel = firedPixels[0]; - expect(pixel).to.have.string(encodeURIComponent('hb_pb=1.23')) - expect(pixel).to.have.string(encodeURIComponent('hb_adid=ad-id')) + expect(pixel).to.have.string(encodeURIComponent('hb_pb=1.23')); + expect(pixel).to.have.string(encodeURIComponent('hb_adid=ad-id')); } }); @@ -528,10 +664,10 @@ describe('AmxBidAdapter', () => { bidId: 'test-bid-id', adUnitCode: 'div-gpt-ad', timeout: 300, - auctionId: utils.getUniqueIdentifierStr() + auctionId: utils.getUniqueIdentifierStr(), }); - expect(firedPixels.length).to.equal(1) - expect(firedPixels[0]).to.match(/\/hbx\/g_pbto/) + expect(firedPixels.length).to.equal(1); + expect(firedPixels[0]).to.match(/\/hbx\/g_pbto/); }); it('will log an event for prebid win', () => { @@ -544,19 +680,19 @@ describe('AmxBidAdapter', () => { cpm: 1.34, adUnitCode: 'div-gpt-ad', timeout: 300, - auctionId: utils.getUniqueIdentifierStr() + auctionId: utils.getUniqueIdentifierStr(), }); - expect(firedPixels.length).to.equal(1) - expect(firedPixels[0]).to.match(/\/hbx\/g_pbwin/) + expect(firedPixels.length).to.equal(1); + expect(firedPixels[0]).to.match(/\/hbx\/g_pbwin/); const pixel = firedPixels[0]; try { const url = new URL(pixel); - expect(url.searchParams.get('C')).to.equal('1') - expect(url.searchParams.get('np')).to.equal('1.34') + expect(url.searchParams.get('C')).to.equal('1'); + expect(url.searchParams.get('np')).to.equal('1.34'); } catch (e) { - expect(pixel).to.have.string('C=1') - expect(pixel).to.have.string('np=1.34') + expect(pixel).to.have.string('C=1'); + expect(pixel).to.have.string('np=1.34'); } }); }); diff --git a/test/spec/modules/amxIdSystem_spec.js b/test/spec/modules/amxIdSystem_spec.js index dea79e87baa..c1ae2c791d5 100644 --- a/test/spec/modules/amxIdSystem_spec.js +++ b/test/spec/modules/amxIdSystem_spec.js @@ -1,4 +1,4 @@ -import { amxIdSubmodule } from 'modules/amxIdSystem.js'; +import { amxIdSubmodule, storage } from 'modules/amxIdSystem.js'; import { server } from 'test/mocks/xhr.js'; import * as utils from 'src/utils.js'; @@ -48,38 +48,17 @@ describe('validateConfig', () => { logErrorSpy.restore(); }); - it('should return undefined if config.storage is not present', () => { + it('should allow configuration with no storage', () => { expect( amxIdSubmodule.getId( { ...config, - storage: null, + storage: undefined }, null, null ) - ).to.equal(undefined); - - expect(logErrorSpy.calledOnce).to.be.true; - expect(logErrorSpy.lastCall.lastArg).to.contain('storage is required'); - }); - - it('should return undefined if config.storage.type !== "html5"', () => { - expect( - amxIdSubmodule.getId( - { - ...config, - storage: { - type: 'cookie', - }, - }, - null, - null - ) - ).to.equal(undefined); - - expect(logErrorSpy.calledOnce).to.be.true; - expect(logErrorSpy.lastCall.lastArg).to.contain('cookie'); + ).to.not.equal(undefined); }); it('should return undefined if expires > 30', () => { @@ -111,10 +90,18 @@ describe('getId', () => { }); it('should call the sync endpoint and accept a valid response', () => { + storage.setDataInLocalStorage('__amuidpb', TEST_ID); + const { callback } = amxIdSubmodule.getId(config, null, null); callback(spy); const [request] = server.requests; + expect(request.withCredentials).to.be.true + expect(request.requestHeaders['Content-Type']).to.match(/text\/plain/) + + const { search } = utils.parseUrl(request.url); + expect(search.av).to.equal(amxIdSubmodule.version); + expect(search.am).to.equal(TEST_ID); expect(request.method).to.equal('GET'); request.respond( @@ -187,7 +174,7 @@ describe('getId', () => { ); const [, secondRequest] = server.requests; - expect(secondRequest.url).to.be.equal(intermediateValue); + expect(secondRequest.url).to.match(new RegExp(`^${intermediateValue}\?`)); secondRequest.respond( 200, {}, diff --git a/test/spec/modules/aolBidAdapter_spec.js b/test/spec/modules/aolBidAdapter_spec.js deleted file mode 100644 index 50622180ad0..00000000000 --- a/test/spec/modules/aolBidAdapter_spec.js +++ /dev/null @@ -1,835 +0,0 @@ -import {expect} from 'chai'; -import * as utils from 'src/utils.js'; -import {spec} from 'modules/aolBidAdapter.js'; -import {createEidsArray} from '../../../modules/userId/eids.js'; - -const DEFAULT_AD_CONTENT = ''; - -let getDefaultBidResponse = () => { - return { - id: '245730051428950632', - cur: 'USD', - seatbid: [{ - bid: [{ - id: 1, - impid: '245730051428950632', - price: 0.09, - adm: DEFAULT_AD_CONTENT, - crid: 'creative-id', - h: 90, - w: 728, - dealid: 'deal-id', - ext: {sizeid: 225} - }] - }] - }; -}; - -let getMarketplaceBidParams = () => { - return { - placement: 1234567, - network: '9599.1' - }; -}; - -let getNexageGetBidParams = () => { - return { - dcn: '2c9d2b50015c5ce9db6aeeed8b9500d6', - pos: 'header' - }; -}; - -let getNexagePostBidParams = () => { - return { - id: 'id-1', - imp: [{ - id: 'id-2', - banner: { - w: '100', - h: '100' - }, - tagid: 'header1' - }] - }; -}; - -let getDefaultBidRequest = () => { - return { - bidderCode: 'aol', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - bidderRequestId: '7101db09af0db2', - start: new Date().getTime(), - bids: [{ - bidder: 'aol', - bidId: '84ab500420319d', - bidderRequestId: '7101db09af0db2', - auctionId: 'd3e07445-ab06-44c8-a9dd-5ef9af06d2a6', - placementCode: 'foo', - params: getMarketplaceBidParams() - }] - }; -}; - -let getPixels = () => { - return ''; -}; - -describe('AolAdapter', function () { - const MARKETPLACE_URL = 'https://adserver-us.adtech.advertising.com/pubapi/3.0/'; - const NEXAGE_URL = 'https://c2shb.ssp.yahoo.com/bidRequest?'; - const ONE_DISPLAY_TTL = 60; - const ONE_MOBILE_TTL = 3600; - const SUPPORTED_USER_ID_SOURCES = { - 'adserver.org': '100', - 'criteo.com': '200', - 'id5-sync.com': '300', - 'intentiq.com': '400', - 'liveintent.com': '500', - 'quantcast.com': '600', - 'verizonmedia.com': '700', - 'liveramp.com': '800' - }; - - const USER_ID_DATA = { - criteoId: SUPPORTED_USER_ID_SOURCES['criteo.com'], - connectid: SUPPORTED_USER_ID_SOURCES['verizonmedia.com'], - idl_env: SUPPORTED_USER_ID_SOURCES['liveramp.com'], - lipb: { - lipbid: SUPPORTED_USER_ID_SOURCES['liveintent.com'], - segments: ['100', '200'] - }, - tdid: SUPPORTED_USER_ID_SOURCES['adserver.org'], - id5id: { - uid: SUPPORTED_USER_ID_SOURCES['id5-sync.com'], - ext: {foo: 'bar'} - }, - intentIqId: SUPPORTED_USER_ID_SOURCES['intentiq.com'], - quantcastId: SUPPORTED_USER_ID_SOURCES['quantcast.com'] - }; - - function createCustomBidRequest({bids, params} = {}) { - var bidderRequest = getDefaultBidRequest(); - if (bids && Array.isArray(bids)) { - bidderRequest.bids = bids; - } - if (params) { - bidderRequest.bids.forEach(bid => bid.params = params); - } - return bidderRequest; - } - - describe('interpretResponse()', function () { - let bidderSettingsBackup; - let bidResponse; - let bidRequest; - let logWarnSpy; - let isOneMobileBidderStub; - - beforeEach(function () { - bidderSettingsBackup = $$PREBID_GLOBAL$$.bidderSettings; - bidRequest = { - bidderCode: 'test-bidder-code', - bidId: 'bid-id', - ttl: 1234 - }; - bidResponse = { - body: getDefaultBidResponse() - }; - logWarnSpy = sinon.spy(utils, 'logWarn'); - isOneMobileBidderStub = sinon.stub(spec, 'isOneMobileBidder'); - }); - - afterEach(function () { - $$PREBID_GLOBAL$$.bidderSettings = bidderSettingsBackup; - logWarnSpy.restore(); - isOneMobileBidderStub.restore(); - }); - - it('should return formatted bid response with required properties', function () { - let formattedBidResponse = spec.interpretResponse(bidResponse, bidRequest); - expect(formattedBidResponse).to.deep.equal({ - bidderCode: bidRequest.bidderCode, - requestId: 'bid-id', - ad: DEFAULT_AD_CONTENT, - cpm: 0.09, - width: 728, - height: 90, - creativeId: 'creative-id', - pubapiId: '245730051428950632', - currency: 'USD', - dealId: 'deal-id', - netRevenue: true, - meta: { - advertiserDomains: [] - }, - ttl: bidRequest.ttl - }); - }); - }); - - describe('buildRequests()', function () { - it('method exists and is a function', function () { - expect(spec.buildRequests).to.exist.and.to.be.a('function'); - }); - - describe('Marketplace', function () { - it('should not return request when no bids are present', function () { - let [request] = spec.buildRequests([]); - expect(request).to.be.undefined; - }); - - it('should return request for Marketplace endpoint', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); - }); - - it('should return request for Marketplace via onedisplay bidder code', function () { - let bidRequest = createCustomBidRequest({ - bids: [{ - bidder: 'onedisplay' - }], - params: getMarketplaceBidParams() - }); - - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); - }); - - it('should return Marketplace request via onedisplay bidder code when' + - 'Marketplace and One Mobile GET params are present', () => { - let bidParams = Object.assign(getMarketplaceBidParams(), getNexageGetBidParams()); - let bidRequest = createCustomBidRequest({ - bids: [{ - bidder: 'onedisplay' - }], - params: bidParams - }); - - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); - }); - - it('should return Marketplace request via onedisplay bidder code when' + - 'Marketplace and One Mobile GET + POST params are present', () => { - let bidParams = Object.assign(getMarketplaceBidParams(), getNexageGetBidParams(), getNexagePostBidParams()); - let bidRequest = createCustomBidRequest({ - bids: [{ - bidder: 'onedisplay' - }], - params: bidParams - }); - - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); - }); - - it('should not resolve endpoint for onedisplay bidder code ' + - 'when only One Mobile params are present', () => { - let bidParams = Object.assign(getNexageGetBidParams(), getNexagePostBidParams()); - let bidRequest = createCustomBidRequest({ - bids: [{ - bidder: 'onedisplay' - }], - params: bidParams - }); - - let [request] = spec.buildRequests(bidRequest.bids); - expect(request).to.be.undefined; - }); - - it('should return Marketplace URL for eu region', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - region: 'eu' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) - .to.equal(0); - }); - - it('should return insecure MP URL if insecure server option is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - server: 'https://adserver-eu.adtech.advertising.com' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) - .to.equal(0); - }); - - it('should return a secure MP URL if relative proto server option is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - server: 'https://adserver-eu.adtech.advertising.com' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) - .to.equal(0); - }); - - it('should return a secure MP URL when server option without protocol is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - server: 'adserver-eu.adtech.advertising.com' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf('https://adserver-eu.adtech.advertising.com/pubapi/3.0/')) - .to.equal(0); - }); - - it('should return default Marketplace URL in case of unknown region config option', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - region: 'an' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url.indexOf(MARKETPLACE_URL)).to.equal(0); - }); - - it('should return url with pubapi bid option', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('cmd=bid;'); - }); - - it('should return url with version 2 of pubapi', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('v=2;'); - }); - - it('should return url with cache busting option', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.match(/misc=\d+/); - }); - - it('should return url with default pageId and sizeId', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('/pubapi/3.0/9599.1/1234567/0/0/ADTECH;'); - }); - - it('should return url with custom pageId and sizeId when options are present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - pageId: 1111, - sizeId: 2222 - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('/pubapi/3.0/9599.1/1234567/1111/2222/ADTECH;'); - }); - - it('should return url with default alias if alias param is missing', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.match(/alias=\w+?;/); - }); - - it('should return url with custom alias if it is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - alias: 'desktop_articlepage_something_box_300_250' - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('alias=desktop_articlepage_something_box_300_250'); - }); - - it('should return url without bidfloor option if is is missing', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).not.to.contain('bidfloor='); - }); - - it('should return url with key values if keyValues param is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - placement: 1234567, - network: '9599.1', - keyValues: { - age: 25, - height: 3.42, - test: 'key' - } - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('kvage=25;kvheight=3.42;kvtest=key'); - }); - - it('should return request object for One Display when configuration is present', function () { - let bidRequest = getDefaultBidRequest(); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.method).to.equal('GET'); - expect(request.ttl).to.equal(ONE_DISPLAY_TTL); - }); - }); - - describe('One Mobile', function () { - it('should return One Mobile url when One Mobile get params are present', function () { - let bidRequest = createCustomBidRequest({ - params: getNexageGetBidParams() - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(NEXAGE_URL); - }); - - it('should return One Mobile url with different host when host option is present', function () { - let bidParams = Object.assign({ - host: 'https://qa-hb.nexage.com' - }, getNexageGetBidParams()); - let bidRequest = createCustomBidRequest({ - params: bidParams - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('https://qa-hb.nexage.com/bidRequest?'); - }); - - it('should return One Mobile url when One Mobile and Marketplace params are present', function () { - let bidParams = Object.assign(getNexageGetBidParams(), getMarketplaceBidParams()); - let bidRequest = createCustomBidRequest({ - params: bidParams - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(NEXAGE_URL); - }); - - it('should return One Mobile url for onemobile bidder code ' + - 'when One Mobile GET and Marketplace params are present', () => { - let bidParams = Object.assign(getNexageGetBidParams(), getMarketplaceBidParams()); - let bidRequest = createCustomBidRequest({ - bids: [{ - bidder: 'onemobile' - }], - params: bidParams - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(NEXAGE_URL); - }); - - it('should not return any url for onemobile bidder code' + - 'when only Marketplace params are present', () => { - let bidRequest = createCustomBidRequest({ - bids: [{ - bidder: 'onemobile' - }], - params: getMarketplaceBidParams() - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request).to.be.undefined; - }); - - it('should return One Mobile url with required params - dcn & pos', function () { - let bidRequest = createCustomBidRequest({ - params: getNexageGetBidParams() - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(NEXAGE_URL + 'dcn=2c9d2b50015c5ce9db6aeeed8b9500d6&pos=header'); - }); - - it('should return One Mobile url with cmd=bid option', function () { - let bidRequest = createCustomBidRequest({ - params: getNexageGetBidParams() - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain('cmd=bid'); - }); - - it('should return One Mobile url with generic params if ext option is present', function () { - let bidRequest = createCustomBidRequest({ - params: { - dcn: '54321123', - pos: 'footer-2324', - ext: { - param1: 'val1', - param2: 'val2', - param3: 'val3', - param4: 'val4' - } - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.equal('https://c2shb.ssp.yahoo.com/bidRequest?dcn=54321123&pos=footer-2324&cmd=bid' + - '¶m1=val1¶m2=val2¶m3=val3¶m4=val4'); - }); - - Object.keys(SUPPORTED_USER_ID_SOURCES).forEach(source => { - it(`should set the user ID query param for ${source}`, function () { - let bidRequest = createCustomBidRequest({ - params: getNexageGetBidParams() - }); - bidRequest.bids[0].userId = {}; - bidRequest.bids[0].userIdAsEids = createEidsArray(USER_ID_DATA); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(`&eid${source}=${encodeURIComponent(SUPPORTED_USER_ID_SOURCES[source])}`); - }); - }); - - it('should return request object for One Mobile POST endpoint when POST configuration is present', function () { - let bidConfig = getNexagePostBidParams(); - let bidRequest = createCustomBidRequest({ - params: bidConfig - }); - - let [request] = spec.buildRequests(bidRequest.bids); - expect(request.url).to.contain(NEXAGE_URL); - expect(request.method).to.equal('POST'); - expect(request.ttl).to.equal(ONE_MOBILE_TTL); - expect(request.data).to.deep.equal(bidConfig); - expect(request.options).to.deep.equal({ - contentType: 'application/json', - customHeaders: { - 'x-openrtb-version': '2.2' - } - }); - }); - - it('should not return request object for One Mobile POST endpoint' + - 'if required parameters are missed', () => { - let bidRequest = createCustomBidRequest({ - params: { - imp: [] - } - }); - let [request] = spec.buildRequests(bidRequest.bids); - expect(request).to.be.undefined; - }); - }); - }); - - describe('buildOpenRtbRequestData', () => { - const bid = { - params: { - id: 'bid-id', - imp: [] - } - }; - let euConsentRequiredStub; - - beforeEach(function () { - euConsentRequiredStub = sinon.stub(spec, 'isEUConsentRequired'); - }); - - afterEach(function () { - euConsentRequiredStub.restore(); - }); - - it('returns the basic bid info when regulation data is omitted', () => { - expect(spec.buildOpenRtbRequestData(bid)).to.deep.equal({ - id: 'bid-id', - imp: [] - }); - }); - - it('returns the basic bid info with gdpr data when gdpr consent data is included', () => { - let consentData = { - gdpr: { - consentString: 'someEUConsent' - } - }; - euConsentRequiredStub.returns(true); - expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ - id: 'bid-id', - imp: [], - regs: { - ext: { - gdpr: 1 - } - }, - user: { - ext: { - consent: 'someEUConsent' - } - } - }); - }); - - it('returns the basic bid info with CCPA data when CCPA consent data is included', () => { - let consentData = { - uspConsent: 'someUSPConsent' - }; - expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ - id: 'bid-id', - imp: [], - regs: { - ext: { - us_privacy: 'someUSPConsent' - } - } - }); - }); - - it('returns the basic bid info with GDPR and CCPA data when GDPR and CCPA consent data is included', () => { - let consentData = { - gdpr: { - consentString: 'someEUConsent' - }, - uspConsent: 'someUSPConsent' - }; - euConsentRequiredStub.returns(true); - expect(spec.buildOpenRtbRequestData(bid, consentData)).to.deep.equal({ - id: 'bid-id', - imp: [], - regs: { - ext: { - gdpr: 1, - us_privacy: 'someUSPConsent' - } - }, - user: { - ext: { - consent: 'someEUConsent' - } - } - }); - }); - - it('returns the bid object with eid array populated with PB set eids', () => { - let userIdBid = Object.assign({ - userId: {} - }, bid); - userIdBid.userIdAsEids = createEidsArray(USER_ID_DATA); - expect(spec.buildOpenRtbRequestData(userIdBid)).to.deep.equal({ - id: 'bid-id', - imp: [], - user: { - ext: { - eids: userIdBid.userIdAsEids - } - } - }); - }); - }); - - describe('getUserSyncs()', function () { - let serverResponses; - let bidResponse; - - beforeEach(function () { - bidResponse = getDefaultBidResponse(); - bidResponse.ext = { - pixels: getPixels() - }; - - serverResponses = [ - {body: bidResponse} - ]; - }); - - it('should return user syncs if pixels are present in the response', function () { - let userSyncs = spec.getUserSyncs({}, serverResponses); - - expect(userSyncs).to.deep.equal([ - {type: 'image', url: 'img.org'}, - {type: 'iframe', url: 'pixels1.org'} - ]); - }); - - it('should not return user syncs if pixels are not present', function () { - bidResponse.ext.pixels = null; - let userSyncs = spec.getUserSyncs({}, serverResponses); - - expect(userSyncs).to.deep.equal([]); - }); - }); - - describe('isOneMobileBidder()', function () { - it('should return false when when bidderCode is not present', () => { - expect(spec.isOneMobileBidder(null)).to.be.false; - }); - - it('should return false for unknown bidder code', function () { - expect(spec.isOneMobileBidder('unknownBidder')).to.be.false; - }); - - it('should return true for aol bidder code', function () { - expect(spec.isOneMobileBidder('aol')).to.be.true; - }); - - it('should return true for one mobile bidder code', function () { - expect(spec.isOneMobileBidder('onemobile')).to.be.true; - }); - }); - - describe('isEUConsentRequired()', function () { - it('should return false when consentData object is not present', function () { - expect(spec.isEUConsentRequired(null)).to.be.false; - }); - - it('should return true when gdprApplies equals true and consentString is not present', function () { - let consentData = { - gdpr: { - consentString: null, - gdprApplies: true - } - }; - - expect(spec.isEUConsentRequired(consentData)).to.be.true; - }); - - it('should return false when consentString is present and gdprApplies equals false', function () { - let consentData = { - gdpr: { - consentString: 'consent-string', - gdprApplies: false - } - }; - - expect(spec.isEUConsentRequired(consentData)).to.be.false; - }); - - it('should return true when consentString is present and gdprApplies equals true', function () { - let consentData = { - gdpr: { - consentString: 'consent-string', - gdprApplies: true - } - }; - - expect(spec.isEUConsentRequired(consentData)).to.be.true; - }); - }); - - describe('formatMarketplaceDynamicParams()', function () { - let formatConsentDataStub; - let formatKeyValuesStub; - - beforeEach(function () { - formatConsentDataStub = sinon.stub(spec, 'formatConsentData'); - formatKeyValuesStub = sinon.stub(spec, 'formatKeyValues'); - }); - - afterEach(function () { - formatConsentDataStub.restore(); - formatKeyValuesStub.restore(); - }); - - it('should return empty string when params are not present', function () { - expect(spec.formatMarketplaceDynamicParams()).to.be.equal(''); - }); - - it('should return formatted EU consent params when formatConsentData returns GDPR data', function () { - formatConsentDataStub.returns({ - euconsent: 'test-consent', - gdpr: 1 - }); - expect(spec.formatMarketplaceDynamicParams()).to.be.equal('euconsent=test-consent;gdpr=1;'); - }); - - it('should return formatted US privacy params when formatConsentData returns USP data', function () { - formatConsentDataStub.returns({ - us_privacy: 'test-usp-consent' - }); - expect(spec.formatMarketplaceDynamicParams()).to.be.equal('us_privacy=test-usp-consent;'); - }); - - it('should return formatted EU and USP consent params when formatConsentData returns all data', function () { - formatConsentDataStub.returns({ - euconsent: 'test-consent', - gdpr: 1, - us_privacy: 'test-usp-consent' - }); - expect(spec.formatMarketplaceDynamicParams()).to.be.equal( - 'euconsent=test-consent;gdpr=1;us_privacy=test-usp-consent;'); - }); - - it('should return formatted params when formatKeyValues returns data', function () { - formatKeyValuesStub.returns({ - param1: 'val1', - param2: 'val2', - param3: 'val3' - }); - expect(spec.formatMarketplaceDynamicParams()).to.be.equal('param1=val1;param2=val2;param3=val3;'); - }); - }); - - describe('formatOneMobileDynamicParams()', function () { - let euConsentRequiredStub; - let secureProtocolStub; - - beforeEach(function () { - euConsentRequiredStub = sinon.stub(spec, 'isEUConsentRequired'); - secureProtocolStub = sinon.stub(spec, 'isSecureProtocol'); - }); - - afterEach(function () { - euConsentRequiredStub.restore(); - secureProtocolStub.restore(); - }); - - it('should return empty string when params are not present', function () { - expect(spec.formatOneMobileDynamicParams()).to.be.equal(''); - }); - - it('should return formatted params when params are present', function () { - let params = { - param1: 'val1', - param2: 'val2', - param3: 'val3' - }; - expect(spec.formatOneMobileDynamicParams(params)).to.contain('¶m1=val1¶m2=val2¶m3=val3'); - }); - - it('should return formatted gdpr params when isEUConsentRequired returns true', function () { - let consentData = { - gdpr: { - consentString: 'test-consent' - } - }; - euConsentRequiredStub.returns(true); - expect(spec.formatOneMobileDynamicParams({}, consentData)).to.be.equal('&gdpr=1&euconsent=test-consent'); - }); - - it('should return formatted US privacy params when consentData contains USP data', function () { - let consentData = { - uspConsent: 'test-usp-consent' - }; - expect(spec.formatMarketplaceDynamicParams({}, consentData)).to.be.equal('us_privacy=test-usp-consent;'); - }); - - it('should return formatted EU and USP consent params when consentData contains gdpr and usp values', function () { - euConsentRequiredStub.returns(true); - let consentData = { - gdpr: { - consentString: 'test-consent' - }, - uspConsent: 'test-usp-consent' - }; - expect(spec.formatMarketplaceDynamicParams({}, consentData)).to.be.equal( - 'gdpr=1;euconsent=test-consent;us_privacy=test-usp-consent;'); - }); - - it('should return formatted secure param when isSecureProtocol returns true', function () { - secureProtocolStub.returns(true); - expect(spec.formatOneMobileDynamicParams()).to.be.equal('&secure=1'); - }); - }); -}); diff --git a/test/spec/modules/apacdexBidAdapter_spec.js b/test/spec/modules/apacdexBidAdapter_spec.js index 9b75481ada9..98d07575ee7 100644 --- a/test/spec/modules/apacdexBidAdapter_spec.js +++ b/test/spec/modules/apacdexBidAdapter_spec.js @@ -252,14 +252,14 @@ describe('ApacdexBidAdapter', function () { it('should return a properly formatted request', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex') + expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs') expect(bidRequests.method).to.equal('POST') expect(bidRequests.bidderRequests).to.eql(bidRequest); }) it('should return a properly formatted request with GDPR applies set to true', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex') + expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs') expect(bidRequests.method).to.equal('POST') expect(bidRequests.data.gdpr.gdprApplies).to.equal(true) expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==') @@ -268,7 +268,7 @@ describe('ApacdexBidAdapter', function () { it('should return a properly formatted request with GDPR applies set to false', function () { bidderRequests.gdprConsent.gdprApplies = false; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex') + expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs') expect(bidRequests.method).to.equal('POST') expect(bidRequests.data.gdpr.gdprApplies).to.equal(false) expect(bidRequests.data.gdpr.consentString).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A==') @@ -288,7 +288,7 @@ describe('ApacdexBidAdapter', function () { } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex') + expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs') expect(bidRequests.method).to.equal('POST') expect(bidRequests.data.gdpr.gdprApplies).to.equal(false) expect(bidRequests.data.gdpr).to.not.include.keys('consentString') @@ -308,7 +308,7 @@ describe('ApacdexBidAdapter', function () { } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests) - expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/apacdex') + expect(bidRequests.url).to.equal('https://useast.quantumdex.io/auction/pbjs') expect(bidRequests.method).to.equal('POST') expect(bidRequests.data.gdpr.gdprApplies).to.equal(true) expect(bidRequests.data.gdpr).to.not.include.keys('consentString') @@ -321,9 +321,9 @@ describe('ApacdexBidAdapter', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.eids).to.deep.equal(bidRequest[0].userIdAsEids) }); - it('should return a properly formatted request with geo defined', function () { + it('should fail to return a properly formatted request with geo defined', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.data.geo).to.deep.equal(bidRequest[0].params.geo) + expect(bidRequests.data.geo).to.not.deep.equal(bidRequest[0].params.geo) }); it('should return a properly formatted request with us_privacy included', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); @@ -384,7 +384,7 @@ describe('ApacdexBidAdapter', function () { describe('.interpretResponse', function () { const bidRequests = { 'method': 'POST', - 'url': 'https://useast.quantumdex.io/auction/apacdex', + 'url': 'https://useast.quantumdex.io/auction/pbjs', 'withCredentials': true, 'data': { 'device': { @@ -730,22 +730,4 @@ describe('ApacdexBidAdapter', function () { expect(validateGeoObject(geoObject)).to.equal(false); }); }); - - describe('getDomain', function () { - it('should return valid domain from publisherDomain config', () => { - let pageUrl = 'https://www.example.com/page/prebid/exam.html'; - config.setConfig({ publisherDomain: pageUrl }); - expect(getDomain(pageUrl)).to.equal('example.com'); - }); - it('should return valid domain from pageUrl argument', () => { - let pageUrl = 'https://www.example.com/page/prebid/exam.html'; - config.setConfig({ publisherDomain: '' }); - expect(getDomain(pageUrl)).to.equal('example.com'); - }); - it('should return undefined if pageUrl and publisherDomain not config', () => { - let pageUrl; - config.setConfig({ publisherDomain: '' }); - expect(getDomain(pageUrl)).to.equal(pageUrl); - }); - }); }); diff --git a/test/spec/modules/appierBidAdapter_spec.js b/test/spec/modules/appierBidAdapter_spec.js index 5b6ccf14162..8b6ad5c2f6f 100644 --- a/test/spec/modules/appierBidAdapter_spec.js +++ b/test/spec/modules/appierBidAdapter_spec.js @@ -64,12 +64,16 @@ describe('AppierAdapter', function () { 'auctionId': '1d1a030790a475', }; const fakeBidRequests = [bid]; - const fakeBidderRequest = {refererInfo: { - 'referer': 'fakeReferer', - 'reachedTop': true, - 'numIframes': 1, - 'stack': [] - }}; + const fakeBidderRequest = { + refererInfo: { + legacy: { + 'referer': 'fakeReferer', + 'reachedTop': true, + 'numIframes': 1, + 'stack': [] + } + } + }; const builtRequests = spec.buildRequests(fakeBidRequests, fakeBidderRequest); expect(builtRequests.length).to.equal(1); @@ -77,7 +81,7 @@ describe('AppierAdapter', function () { expect(builtRequests[0].url).match(/v1\/prebid\/bid/); expect(builtRequests[0].data).deep.equal({ 'bids': fakeBidRequests, - 'refererInfo': fakeBidderRequest.refererInfo, + 'refererInfo': fakeBidderRequest.refererInfo.legacy, 'version': ADAPTER_VERSION }); }); diff --git a/test/spec/modules/appnexusBidAdapter_spec.js b/test/spec/modules/appnexusBidAdapter_spec.js index 76d18c43e9d..193e8aa64f8 100644 --- a/test/spec/modules/appnexusBidAdapter_spec.js +++ b/test/spec/modules/appnexusBidAdapter_spec.js @@ -4,6 +4,7 @@ import { newBidder } from 'src/adapters/bidderFactory.js'; import * as bidderFactory from 'src/adapters/bidderFactory.js'; import { auctionManager } from 'src/auctionManager.js'; import { deepClone } from 'src/utils.js'; +import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; const ENDPOINT = 'https://ib.adnxs.com/ut/v3/prebid'; @@ -17,6 +18,18 @@ describe('AppNexusAdapter', function () { }); }); + function expectKeywords(actual, expected) { + expect(actual.length).to.equal(expected.length); + actual.forEach(el => { + const match = expected.find(ob => ob.key === el.key); + if (el.value) { + expect(el.value).to.have.members(match.value); + } else { + expect(match.value).to.not.exist; + } + }) + } + describe('isBidRequestValid', function () { let bid = { 'bidder': 'appnexus', @@ -35,14 +48,31 @@ describe('AppNexusAdapter', function () { }); it('should return true when required params found', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { + let bid1 = deepClone(bid); + bid1.params = { + 'placement_id': 123423 + } + expect(spec.isBidRequestValid(bid1)).to.equal(true); + }); + + it('should return true when required params found', function () { + let bid1 = deepClone(bid); + bid1.params = { 'member': '1234', 'invCode': 'ABCD' }; - expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(bid1)).to.equal(true); + }); + + it('should return true when required params found', function () { + let bid1 = deepClone(bid); + bid1.params = { + 'member': '1234', + 'inv_code': 'ABCD' + }; + + expect(spec.isBidRequestValid(bid1)).to.equal(true); }); it('should return false when required params are not passed', function () { @@ -53,6 +83,15 @@ describe('AppNexusAdapter', function () { }; expect(spec.isBidRequestValid(bid)).to.equal(false); }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placement_id': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); }); describe('buildRequests', function () { @@ -72,13 +111,13 @@ describe('AppNexusAdapter', function () { } ]; - beforeEach(function() { - getAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits').callsFake(function() { + beforeEach(function () { + getAdUnitsStub = sinon.stub(auctionManager, 'getAdUnits').callsFake(function () { return []; }); }); - afterEach(function() { + afterEach(function () { getAdUnitsStub.restore(); }); @@ -97,10 +136,28 @@ describe('AppNexusAdapter', function () { const payload = JSON.parse(request.data); expect(payload.tags[0].private_sizes).to.exist; - expect(payload.tags[0].private_sizes).to.deep.equal([{width: 300, height: 250}]); + expect(payload.tags[0].private_sizes).to.deep.equal([{ width: 300, height: 250 }]); }); - it('should add position in request', function() { + it('should parse out private sizes', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + private_sizes: [300, 250] + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].private_sizes).to.exist; + expect(payload.tags[0].private_sizes).to.deep.equal([{ width: 300, height: 250 }]); + }); + + it('should add position in request', function () { // set from bid.params let bidRequest = deepClone(bidRequests[0]); bidRequest.params.position = 'above'; @@ -149,7 +206,7 @@ describe('AppNexusAdapter', function () { expect(payload4.tags[0].position).to.deep.equal(1); }); - it('should add publisher_id in request', function() { + it('should add publisher_id in request', function () { let bidRequest = Object.assign({}, bidRequests[0], { @@ -167,6 +224,24 @@ describe('AppNexusAdapter', function () { expect(payload.publisher_id).to.deep.equal(1231234); }); + it('should add publisher_id in request', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placement_id: '10433394', + publisher_id: '1231234' + } + }); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].publisher_id).to.exist; + expect(payload.tags[0].publisher_id).to.deep.equal(1231234); + expect(payload.publisher_id).to.exist; + expect(payload.publisher_id).to.deep.equal(1231234); + }); + it('should add source and verison to the tag', function () { const request = spec.buildRequests(bidRequests); const payload = JSON.parse(request.data); @@ -188,14 +263,23 @@ describe('AppNexusAdapter', function () { bids: [{ bidder: 'appnexus', params: { - placementId: '10433394' + placement_id: '10433394' } }], transactionId: '04f2659e-c005-4eb1-a57c-fa93145e3843' }]; - ['banner', 'video', 'native'].forEach(type => { - getAdUnitsStub.callsFake(function(...args) { + let types = ['banner']; + if (FEATURES.NATIVE) { + types.push('native'); + } + + if (FEATURES.VIDEO) { + types.push('video'); + } + + types.forEach(type => { + getAdUnitsStub.callsFake(function (...args) { return adUnits; }); @@ -214,7 +298,7 @@ describe('AppNexusAdapter', function () { }); }); - it('should not populate the ad_types array when adUnit.mediaTypes is undefined', function() { + it('should not populate the ad_types array when adUnit.mediaTypes is undefined', function () { const bidRequest = Object.assign({}, bidRequests[0]); const request = spec.buildRequests([bidRequest]); const payload = JSON.parse(request.data); @@ -222,122 +306,303 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].ad_types).to.not.exist; }); - it('should populate the ad_types array on outstream requests', function () { - const bidRequest = Object.assign({}, bidRequests[0]); - bidRequest.mediaTypes = {}; - bidRequest.mediaTypes.video = {context: 'outstream'}; + if (FEATURES.VIDEO) { + it('should populate the ad_types array on outstream requests', function () { + const bidRequest = Object.assign({}, bidRequests[0]); + bidRequest.mediaTypes = {}; + bidRequest.mediaTypes.video = { context: 'outstream' }; - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); - expect(payload.tags[0].ad_types).to.deep.equal(['video']); - expect(payload.tags[0].hb_source).to.deep.equal(1); - }); + expect(payload.tags[0].ad_types).to.deep.equal(['video']); + expect(payload.tags[0].hb_source).to.deep.equal(1); + }); - it('sends bid request to ENDPOINT via POST', function () { - const request = spec.buildRequests(bidRequests); - expect(request.url).to.equal(ENDPOINT); - expect(request.method).to.equal('POST'); - }); + it('should attach valid video params to the tag', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placementId: '10433394', + video: { + id: 123, + minduration: 100, + foobar: 'invalid' + } + } + } + ); - it('should attach valid video params to the tag', function () { - let bidRequest = Object.assign({}, - bidRequests[0], - { + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].video).to.deep.equal({ + id: 123, + minduration: 100 + }); + expect(payload.tags[0].hb_source).to.deep.equal(1); + }); + + it('should include ORTB video values when video params were not set', function () { + let bidRequest = deepClone(bidRequests[0]); + bidRequest.params = { + placementId: '1234235', + video: { + skippable: true, + playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'], + context: 'outstream' + } + }; + bidRequest.mediaTypes = { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'], + skip: 0, + minduration: 5, + api: [1, 5, 6], + playbackmethod: [2, 4] + } + }; + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].video).to.deep.equal({ + minduration: 5, + playback_method: 2, + skippable: true, + context: 4 + }); + expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4]) + }); + + it('should add video property when adUnit includes a renderer', function () { + const videoData = { + mediaTypes: { + video: { + context: 'outstream', + mimes: ['video/mp4'] + } + }, params: { placementId: '10433394', video: { - id: 123, - minduration: 100, - foobar: 'invalid' + skippable: true, + playback_method: ['auto_play_sound_off'] } } - } - ); + }; - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - id: 123, - minduration: 100 - }); - expect(payload.tags[0].hb_source).to.deep.equal(1); - }); + let bidRequest1 = deepClone(bidRequests[0]); + bidRequest1 = Object.assign({}, bidRequest1, videoData, { + renderer: { + url: 'https://test.renderer.url', + render: function () { } + } + }); - it('should include ORTB video values when video params were not set', function() { - let bidRequest = deepClone(bidRequests[0]); - bidRequest.params = { - placementId: '1234235', - video: { + let bidRequest2 = deepClone(bidRequests[0]); + bidRequest2.adUnitCode = 'adUnit_code_2'; + bidRequest2 = Object.assign({}, bidRequest2, videoData); + + const request = spec.buildRequests([bidRequest1, bidRequest2]); + const payload = JSON.parse(request.data); + expect(payload.tags[0].video).to.deep.equal({ skippable: true, - playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'], - context: 'outstream' - } - }; - bidRequest.mediaTypes = { - video: { - playerSize: [640, 480], - context: 'outstream', - mimes: ['video/mp4'], - skip: 0, - minduration: 5, - api: [1, 5, 6], - playbackmethod: [2, 4] - } - }; + playback_method: 2, + custom_renderer_present: true + }); + expect(payload.tags[1].video).to.deep.equal({ + skippable: true, + playback_method: 2 + }); + }); - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); + it('should duplicate adpod placements into batches and set correct maxduration', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 300, + durationRangeSec: [15, 30], + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload1 = JSON.parse(request[0].data); + const payload2 = JSON.parse(request[1].data); - expect(payload.tags[0].video).to.deep.equal({ - minduration: 5, - playback_method: 2, - skippable: true, - context: 4 + // 300 / 15 = 20 total + expect(payload1.tags.length).to.equal(15); + expect(payload2.tags.length).to.equal(5); + + expect(payload1.tags[0]).to.deep.equal(payload1.tags[1]); + expect(payload1.tags[0].video.maxduration).to.equal(30); + + expect(payload2.tags[0]).to.deep.equal(payload1.tags[1]); + expect(payload2.tags[0].video.maxduration).to.equal(30); }); - expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4]) - }); - it('should add video property when adUnit includes a renderer', function () { - const videoData = { - mediaTypes: { - video: { - context: 'outstream', - mimes: ['video/mp4'] + it('should round down adpod placements when numbers are uneven', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 123, + durationRangeSec: [45], + } + } } - }, - params: { - placementId: '10433394', - video: { - skippable: true, - playback_method: ['auto_play_sound_off'] + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags.length).to.equal(2); + }); + + it('should duplicate adpod placements when requireExactDuration is set', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 300, + durationRangeSec: [15, 30], + requireExactDuration: true, + } + } } - } - }; + ); - let bidRequest1 = deepClone(bidRequests[0]); - bidRequest1 = Object.assign({}, bidRequest1, videoData, { - renderer: { - url: 'https://test.renderer.url', - render: function () {} - } + // 20 total placements with 15 max impressions = 2 requests + const request = spec.buildRequests([bidRequest]); + expect(request.length).to.equal(2); + + // 20 spread over 2 requests = 15 in first request, 5 in second + const payload1 = JSON.parse(request[0].data); + const payload2 = JSON.parse(request[1].data); + expect(payload1.tags.length).to.equal(15); + expect(payload2.tags.length).to.equal(5); + + // 10 placements should have max/min at 15 + // 10 placemenst should have max/min at 30 + const payload1tagsWith15 = payload1.tags.filter(tag => tag.video.maxduration === 15); + const payload1tagsWith30 = payload1.tags.filter(tag => tag.video.maxduration === 30); + expect(payload1tagsWith15.length).to.equal(10); + expect(payload1tagsWith30.length).to.equal(5); + + // 5 placemenst with min/max at 30 were in the first request + // so 5 remaining should be in the second + const payload2tagsWith30 = payload2.tags.filter(tag => tag.video.maxduration === 30); + expect(payload2tagsWith30.length).to.equal(5); }); - let bidRequest2 = deepClone(bidRequests[0]); - bidRequest2.adUnitCode = 'adUnit_code_2'; - bidRequest2 = Object.assign({}, bidRequest2, videoData); + it('should set durations for placements when requireExactDuration is set and numbers are uneven', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 105, + durationRangeSec: [15, 30, 60], + requireExactDuration: true, + } + } + } + ); - const request = spec.buildRequests([bidRequest1, bidRequest2]); - const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - skippable: true, - playback_method: 2, - custom_renderer_present: true + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.tags.length).to.equal(7); + + const tagsWith15 = payload.tags.filter(tag => tag.video.maxduration === 15); + const tagsWith30 = payload.tags.filter(tag => tag.video.maxduration === 30); + const tagsWith60 = payload.tags.filter(tag => tag.video.maxduration === 60); + expect(tagsWith15.length).to.equal(3); + expect(tagsWith30.length).to.equal(3); + expect(tagsWith60.length).to.equal(1); }); - expect(payload.tags[1].video).to.deep.equal({ - skippable: true, - playback_method: 2 + + it('should break adpod request into batches', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 225, + durationRangeSec: [5], + } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload1 = JSON.parse(request[0].data); + const payload2 = JSON.parse(request[1].data); + const payload3 = JSON.parse(request[2].data); + + expect(payload1.tags.length).to.equal(15); + expect(payload2.tags.length).to.equal(15); + expect(payload3.tags.length).to.equal(15); + }); + + it('should contain hb_source value for adpod', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { placementId: '14542875' } + }, + { + mediaTypes: { + video: { + context: 'adpod', + playerSize: [640, 480], + adPodDurationSec: 300, + durationRangeSec: [15, 30], + } + } + } + ); + const request = spec.buildRequests([bidRequest])[0]; + const payload = JSON.parse(request.data); + expect(payload.tags[0].hb_source).to.deep.equal(7); }); + } // VIDEO + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); }); it('should attach valid user params to the tag', function () { @@ -345,7 +610,7 @@ describe('AppNexusAdapter', function () { bidRequests[0], { params: { - placementId: '10433394', + placement_id: '10433394', user: { externalUid: '123', segments: [123, { id: 987, value: 876 }], @@ -361,10 +626,33 @@ describe('AppNexusAdapter', function () { expect(payload.user).to.exist; expect(payload.user).to.deep.equal({ external_uid: '123', - segments: [{id: 123}, {id: 987, value: 876}] + segments: [{ id: 123 }, { id: 987, value: 876 }] }); }); + it('should add debug params from query', function () { + let getParamStub = sinon.stub(utils, 'getParameterByName').callsFake(function(par) { + if (par === 'apn_debug_dongle') return 'abcdef'; + if (par === 'apn_debug_member_id') return '1234'; + if (par === 'apn_debug_timeout') return '1000'; + + return ''; + }); + + let bidRequest = deepClone(bidRequests[0]); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.debug).to.exist.and.to.deep.equal({ + 'dongle': 'abcdef', + 'enabled': true, + 'member_id': 1234, + 'debug_timeout': 1000 + }); + + getParamStub.restore(); + }); + it('should attach reserve param when either bid param or getFloor function exists', function () { let getFloorResponse = { currency: 'USD', floor: 3 }; let request, payload = null; @@ -378,7 +666,7 @@ describe('AppNexusAdapter', function () { // 2 -> reserve is defined, getFloor not defined > reserve is used bidRequest.params = { - 'placementId': '10433394', + 'placement_id': '10433394', 'reserve': 0.5 }; request = spec.buildRequests([bidRequest]); @@ -395,193 +683,14 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].reserve).to.exist.and.to.equal(3); }); - it('should duplicate adpod placements into batches and set correct maxduration', function() { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { placementId: '14542875' } - }, - { - mediaTypes: { - video: { - context: 'adpod', - playerSize: [640, 480], - adPodDurationSec: 300, - durationRangeSec: [15, 30], - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload1 = JSON.parse(request[0].data); - const payload2 = JSON.parse(request[1].data); - - // 300 / 15 = 20 total - expect(payload1.tags.length).to.equal(15); - expect(payload2.tags.length).to.equal(5); - - expect(payload1.tags[0]).to.deep.equal(payload1.tags[1]); - expect(payload1.tags[0].video.maxduration).to.equal(30); - - expect(payload2.tags[0]).to.deep.equal(payload1.tags[1]); - expect(payload2.tags[0].video.maxduration).to.equal(30); - }); - - it('should round down adpod placements when numbers are uneven', function() { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { placementId: '14542875' } - }, - { - mediaTypes: { - video: { - context: 'adpod', - playerSize: [640, 480], - adPodDurationSec: 123, - durationRangeSec: [45], - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags.length).to.equal(2); - }); - - it('should duplicate adpod placements when requireExactDuration is set', function() { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { placementId: '14542875' } - }, - { - mediaTypes: { - video: { - context: 'adpod', - playerSize: [640, 480], - adPodDurationSec: 300, - durationRangeSec: [15, 30], - requireExactDuration: true, - } - } - } - ); - - // 20 total placements with 15 max impressions = 2 requests - const request = spec.buildRequests([bidRequest]); - expect(request.length).to.equal(2); - - // 20 spread over 2 requests = 15 in first request, 5 in second - const payload1 = JSON.parse(request[0].data); - const payload2 = JSON.parse(request[1].data); - expect(payload1.tags.length).to.equal(15); - expect(payload2.tags.length).to.equal(5); - - // 10 placements should have max/min at 15 - // 10 placemenst should have max/min at 30 - const payload1tagsWith15 = payload1.tags.filter(tag => tag.video.maxduration === 15); - const payload1tagsWith30 = payload1.tags.filter(tag => tag.video.maxduration === 30); - expect(payload1tagsWith15.length).to.equal(10); - expect(payload1tagsWith30.length).to.equal(5); - - // 5 placemenst with min/max at 30 were in the first request - // so 5 remaining should be in the second - const payload2tagsWith30 = payload2.tags.filter(tag => tag.video.maxduration === 30); - expect(payload2tagsWith30.length).to.equal(5); - }); - - it('should set durations for placements when requireExactDuration is set and numbers are uneven', function() { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { placementId: '14542875' } - }, - { - mediaTypes: { - video: { - context: 'adpod', - playerSize: [640, 480], - adPodDurationSec: 105, - durationRangeSec: [15, 30, 60], - requireExactDuration: true, - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); - expect(payload.tags.length).to.equal(7); - - const tagsWith15 = payload.tags.filter(tag => tag.video.maxduration === 15); - const tagsWith30 = payload.tags.filter(tag => tag.video.maxduration === 30); - const tagsWith60 = payload.tags.filter(tag => tag.video.maxduration === 60); - expect(tagsWith15.length).to.equal(3); - expect(tagsWith30.length).to.equal(3); - expect(tagsWith60.length).to.equal(1); - }); - - it('should break adpod request into batches', function() { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { placementId: '14542875' } - }, - { - mediaTypes: { - video: { - context: 'adpod', - playerSize: [640, 480], - adPodDurationSec: 225, - durationRangeSec: [5], - } - } - } - ); - - const request = spec.buildRequests([bidRequest]); - const payload1 = JSON.parse(request[0].data); - const payload2 = JSON.parse(request[1].data); - const payload3 = JSON.parse(request[2].data); - - expect(payload1.tags.length).to.equal(15); - expect(payload2.tags.length).to.equal(15); - expect(payload3.tags.length).to.equal(15); - }); - - it('should contain hb_source value for adpod', function() { - let bidRequest = Object.assign({}, - bidRequests[0], - { - params: { placementId: '14542875' } - }, - { - mediaTypes: { - video: { - context: 'adpod', - playerSize: [640, 480], - adPodDurationSec: 300, - durationRangeSec: [15, 30], - } - } - } - ); - const request = spec.buildRequests([bidRequest])[0]; - const payload = JSON.parse(request.data); - expect(payload.tags[0].hb_source).to.deep.equal(7); - }); - - it('should contain hb_source value for other media', function() { + it('should contain hb_source value for other media', function () { let bidRequest = Object.assign({}, bidRequests[0], { mediaType: 'banner', params: { sizes: [[300, 250], [300, 600]], - placementId: 13144370 + placement_id: 13144370 } } ); @@ -590,7 +699,7 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].hb_source).to.deep.equal(1); }); - it('adds brand_category_exclusion to request when set', function() { + it('adds brand_category_exclusion to request when set', function () { let bidRequest = Object.assign({}, bidRequests[0]); sinon .stub(config, 'getConfig') @@ -605,7 +714,7 @@ describe('AppNexusAdapter', function () { config.getConfig.restore(); }); - it('adds auction level keywords to request when set', function() { + it('adds auction level keywords and ortb2 keywords to request when set', function () { let bidRequest = Object.assign({}, bidRequests[0]); sinon .stub(config, 'getConfig') @@ -613,13 +722,34 @@ describe('AppNexusAdapter', function () { .returns({ gender: 'm', music: ['rock', 'pop'], - test: '' + test: '', + tools: 'power' }); - const request = spec.buildRequests([bidRequest]); + const bidderRequest = { + ortb2: { + site: { + keywords: 'power tools, drills, tools=industrial', + content: { + keywords: 'video, source=streaming' + } + }, + user: { + keywords: 'tools=home,renting' + }, + app: { + keywords: 'app=iphone 11', + content: { + keywords: 'appcontent=home repair, dyi' + } + } + } + }; + + const request = spec.buildRequests([bidRequest], bidderRequest); const payload = JSON.parse(request.data); - expect(payload.keywords).to.deep.equal([{ + expectKeywords(payload.keywords, [{ 'key': 'gender', 'value': ['m'] }, { @@ -627,33 +757,189 @@ describe('AppNexusAdapter', function () { 'value': ['rock', 'pop'] }, { 'key': 'test' + }, { + 'key': 'tools', + 'value': ['power', 'industrial', 'home'] + }, { + 'key': 'power tools' + }, { + 'key': 'drills' + }, { + 'key': 'video' + }, { + 'key': 'source', + 'value': ['streaming'] + }, { + 'key': 'renting' + }, { + 'key': 'app', + 'value': ['iphone 11'] + }, { + 'key': 'appcontent', + 'value': ['home repair'] + }, { + 'key': 'dyi' }]); config.getConfig.restore(); }); - it('should attach native params to the request', function () { + it('adds ortb2 segments to auction request as keywords', function() { + let bidRequest = Object.assign({}, bidRequests[0]); + const bidderRequest = { + ortb2: { + site: { + keywords: 'drill', + content: { + data: [{ + name: 'siteseg1', + ext: { + segtax: 540 + }, + segment: [{ + id: 's123', + }, { + id: 's234' + }] + }, { + name: 'sitseg2', + ext: { + segtax: 1 + }, + segment: [{ + id: 'unknown' + }] + }, { + name: 'siteseg3', + ext: { + segtax: 526 + }, + segment: [{ + id: 'dog' + }] + }] + } + }, + user: { + data: [{ + name: 'userseg1', + ext: { + segtax: 526 + }, + segment: [{ + id: 'cat' + }] + }] + } + } + }; + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + + expectKeywords(payload.keywords, [{ + 'key': 'drill' + }, { + 'key': '1plusX', + 'value': ['cat', 'dog'] + }, { + 'key': 'perid', + 'value': ['s123', 's234'] + }]); + }); + + if (FEATURES.NATIVE) { + it('should attach native params to the request', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + mediaType: 'native', + nativeParams: { + title: { required: true }, + body: { required: true }, + body2: { required: true }, + image: { required: true, sizes: [100, 100] }, + icon: { required: true }, + cta: { required: false }, + rating: { required: true }, + sponsoredBy: { required: true }, + privacyLink: { required: true }, + displayUrl: { required: true }, + address: { required: true }, + downloads: { required: true }, + likes: { required: true }, + phone: { required: true }, + price: { required: true }, + salePrice: { required: true } + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].native.layouts[0]).to.deep.equal({ + title: { required: true }, + description: { required: true }, + desc2: { required: true }, + main_image: { required: true, sizes: [{ width: 100, height: 100 }] }, + icon: { required: true }, + ctatext: { required: false }, + rating: { required: true }, + sponsored_by: { required: true }, + privacy_link: { required: true }, + displayurl: { required: true }, + address: { required: true }, + downloads: { required: true }, + likes: { required: true }, + phone: { required: true }, + price: { required: true }, + saleprice: { required: true }, + privacy_supported: true + }); + expect(payload.tags[0].hb_source).to.equal(1); + }); + + it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + mediaType: 'native', + nativeParams: { + image: { required: true } + } + } + ); + bidRequest.sizes = [[150, 100], [300, 250]]; + + let request = spec.buildRequests([bidRequest]); + let payload = JSON.parse(request.data); + expect(payload.tags[0].sizes).to.deep.equal([{ width: 150, height: 100 }, { width: 300, height: 250 }]); + + delete bidRequest.sizes; + + request = spec.buildRequests([bidRequest]); + payload = JSON.parse(request.data); + + expect(payload.tags[0].sizes).to.deep.equal([{ width: 1, height: 1 }]); + }); + } + + it('should convert keyword params (when there are no ortb keywords) to proper form and attaches to request', function () { let bidRequest = Object.assign({}, bidRequests[0], { - mediaType: 'native', - nativeParams: { - title: {required: true}, - body: {required: true}, - body2: {required: true}, - image: {required: true, sizes: [100, 100]}, - icon: {required: true}, - cta: {required: false}, - rating: {required: true}, - sponsoredBy: {required: true}, - privacyLink: {required: true}, - displayUrl: {required: true}, - address: {required: true}, - downloads: {required: true}, - likes: {required: true}, - phone: {required: true}, - price: {required: true}, - salePrice: {required: true} + params: { + placement_id: '10433394', + keywords: { + single: 'val', + singleArr: ['val'], + singleArrNum: [5], + multiValMixed: ['value1', 2, 'value3'], + singleValNum: 123, + emptyStr: '', + emptyArr: [''], + badValue: { 'foo': 'bar' } // should be dropped + } } } ); @@ -661,53 +947,62 @@ describe('AppNexusAdapter', function () { const request = spec.buildRequests([bidRequest]); const payload = JSON.parse(request.data); - expect(payload.tags[0].native.layouts[0]).to.deep.equal({ - title: {required: true}, - description: {required: true}, - desc2: {required: true}, - main_image: {required: true, sizes: [{ width: 100, height: 100 }]}, - icon: {required: true}, - ctatext: {required: false}, - rating: {required: true}, - sponsored_by: {required: true}, - privacy_link: {required: true}, - displayurl: {required: true}, - address: {required: true}, - downloads: {required: true}, - likes: {required: true}, - phone: {required: true}, - price: {required: true}, - saleprice: {required: true}, - privacy_supported: true - }); - expect(payload.tags[0].hb_source).to.equal(1); + expectKeywords(payload.tags[0].keywords, [ + { + 'key': 'single', + 'value': ['val'] + }, { + 'key': 'singleArr', + 'value': ['val'] + }, { + 'key': 'singleArrNum', + 'value': ['5'] + }, { + 'key': 'multiValMixed', + 'value': ['value1', '2', 'value3'] + }, { + 'key': 'singleValNum', + 'value': ['123'] + }, { + 'key': 'emptyStr' + }, { + 'key': 'emptyArr' + } + ]) }); - it('should always populated tags[].sizes with 1,1 for native if otherwise not defined', function () { + it('should convert adUnit ortb2 keywords (when there are no bid param keywords) to proper form and attaches to request', function () { let bidRequest = Object.assign({}, bidRequests[0], { - mediaType: 'native', - nativeParams: { - image: { required: true } + ortb2Imp: { + ext: { + data: { + keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456' + } + } } } ); - bidRequest.sizes = [[150, 100], [300, 250]]; - - let request = spec.buildRequests([bidRequest]); - let payload = JSON.parse(request.data); - expect(payload.tags[0].sizes).to.deep.equal([{width: 150, height: 100}, {width: 300, height: 250}]); - delete bidRequest.sizes; - - request = spec.buildRequests([bidRequest]); - payload = JSON.parse(request.data); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); - expect(payload.tags[0].sizes).to.deep.equal([{width: 1, height: 1}]); + expectKeywords(payload.tags[0].keywords, [{ + 'key': 'ortb2', + 'value': ['yes'] + }, { + 'key': 'ortb2test' + }, { + 'key': 'multiValMixed', + 'value': ['4'] + }, { + 'key': 'singleValNum', + 'value': ['456'] + }]); }); - it('should convert keyword params to proper form and attaches to request', function () { + it('should convert keyword params and adUnit ortb2 keywords to proper form and attaches to request', function () { let bidRequest = Object.assign({}, bidRequests[0], { @@ -721,7 +1016,14 @@ describe('AppNexusAdapter', function () { singleValNum: 123, emptyStr: '', emptyArr: [''], - badValue: {'foo': 'bar'} // should be dropped + badValue: { 'foo': 'bar' } // should be dropped + } + }, + ortb2Imp: { + ext: { + data: { + keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456' + } } } } @@ -730,7 +1032,7 @@ describe('AppNexusAdapter', function () { const request = spec.buildRequests([bidRequest]); const payload = JSON.parse(request.data); - expect(payload.tags[0].keywords).to.deep.equal([{ + expectKeywords(payload.tags[0].keywords, [{ 'key': 'single', 'value': ['val'] }, { @@ -741,14 +1043,19 @@ describe('AppNexusAdapter', function () { 'value': ['5'] }, { 'key': 'multiValMixed', - 'value': ['value1', '2', 'value3'] + 'value': ['value1', '2', 'value3', '4'] }, { 'key': 'singleValNum', - 'value': ['123'] + 'value': ['123', '456'] }, { 'key': 'emptyStr' }, { 'key': 'emptyArr' + }, { + 'key': 'ortb2', + 'value': ['yes'] + }, { + 'key': 'ortb2test' }]); }); @@ -769,7 +1076,35 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].use_pmt_rule).to.equal(true); }); - it('should add gpid to the request', function () { + it('should add payment rules to the request', function () { + let bidRequest = Object.assign({}, + bidRequests[0], + { + params: { + placement_id: '10433394', + use_payment_rule: true + } + } + ); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].use_pmt_rule).to.equal(true); + }); + + it('should add preferred gpid to the request', function () { + let testGpid = '/12345/my-gpt-tag-0'; + let bidRequest = deepClone(bidRequests[0]); + bidRequest.ortb2Imp = { ext: { gpid: testGpid } }; + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.tags[0].gpid).to.exist.and.equal(testGpid) + }); + + it('should add backup gpid to the request', function () { let testGpid = '/12345/my-gpt-tag-0'; let bidRequest = deepClone(bidRequests[0]); bidRequest.ortb2Imp = { ext: { data: { pbadslot: testGpid } } }; @@ -796,7 +1131,7 @@ describe('AppNexusAdapter', function () { bidderRequest.bids = bidRequests; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.options).to.deep.equal({withCredentials: true}); + expect(request.options).to.deep.equal({ withCredentials: true }); const payload = JSON.parse(request.data); expect(payload.gdpr_consent).to.exist; @@ -805,7 +1140,7 @@ describe('AppNexusAdapter', function () { expect(payload.gdpr_consent.addtl_consent).to.exist.and.to.deep.equal([7, 12, 35, 62, 66, 70, 89, 93, 108]); }); - it('should add us privacy string to payload', function() { + it('should add us privacy string to payload', function () { let consentString = '1YA-'; let bidderRequest = { 'bidderCode': 'appnexus', @@ -823,6 +1158,52 @@ describe('AppNexusAdapter', function () { expect(payload.us_privacy).to.exist.and.to.equal(consentString); }); + it('should add gpp information to the request via bidderRequest.gppConsent', function () { + let consentString = 'abc1234'; + let bidderRequest = { + 'bidderCode': 'appnexus', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gppConsent': { + 'gppString': consentString, + 'applicableSections': [8] + } + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.privacy).to.exist; + expect(payload.privacy.gpp).to.equal(consentString); + expect(payload.privacy.gpp_sid).to.deep.equal([8]); + }); + + it('should add gpp information to the request via bidderRequest.ortb2.regs', function () { + let consentString = 'abc1234'; + let bidderRequest = { + 'bidderCode': 'appnexus', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'ortb2': { + 'regs': { + 'gpp': consentString, + 'gpp_sid': [7] + } + } + }; + bidderRequest.bids = bidRequests; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.privacy).to.exist; + expect(payload.privacy.gpp).to.equal(consentString); + expect(payload.privacy.gpp_sid).to.deep.equal([7]); + }); + it('supports sending hybrid mobile app parameters', function () { let appRequest = Object.assign({}, bidRequests[0], @@ -871,7 +1252,7 @@ describe('AppNexusAdapter', function () { const bidRequest = Object.assign({}, bidRequests[0]); const bidderRequest = { refererInfo: { - referer: 'https://example.com/page.html', + topmostLocation: 'https://example.com/page.html', reachedTop: true, numIframes: 2, stack: [ @@ -895,14 +1276,11 @@ describe('AppNexusAdapter', function () { it('if defined, should include publisher pageUrl to normal referer info in payload', function () { const bidRequest = Object.assign({}, bidRequests[0]); - sinon - .stub(config, 'getConfig') - .withArgs('pageUrl') - .returns('https://mypub.override.com/test/page.html'); const bidderRequest = { refererInfo: { - referer: 'https://example.com/page.html', + canonicalUrl: 'https://mypub.override.com/test/page.html', + topmostLocation: 'https://example.com/page.html', reachedTop: true, numIframes: 2, stack: [ @@ -923,8 +1301,6 @@ describe('AppNexusAdapter', function () { rd_stk: bidderRequest.refererInfo.stack.map((url) => encodeURIComponent(url)).join(','), rd_can: 'https://mypub.override.com/test/page.html' }); - - config.getConfig.restore(); }); it('should populate schain if available', function () { @@ -978,7 +1354,7 @@ describe('AppNexusAdapter', function () { .returns(true); const request = spec.buildRequests([bidRequest]); - expect(request.options.customHeaders).to.deep.equal({'X-Is-Test': 1}); + expect(request.options.customHeaders).to.deep.equal({ 'X-Is-Test': 1 }); config.getConfig.restore(); }); @@ -1023,10 +1399,6 @@ describe('AppNexusAdapter', function () { criteoId: 'sample-criteo-userid', netId: 'sample-netId-userid', idl_env: 'sample-idl-userid', - flocId: { - id: 'sample-flocid-value', - version: 'chrome.1.0' - }, pubProvidedId: [{ source: 'puburl.com', uids: [{ @@ -1040,9 +1412,33 @@ describe('AppNexusAdapter', function () { source: 'puburl2.com', uids: [{ id: 'pubid2' + }, { + id: 'pubid2-123' }] }] - } + }, + userIdAsEids: [{ + source: 'adserver.org', + uids: [{ id: 'sample-userid' }] + }, { + source: 'criteo.com', + uids: [{ id: 'sample-criteo-userid' }] + }, { + source: 'netid.de', + uids: [{ id: 'sample-netId-userid' }] + }, { + source: 'liveramp.com', + uids: [{ id: 'sample-idl-userid' }] + }, { + source: 'uidapi.com', + uids: [{ id: 'sample-uid2-value' }] + }, { + source: 'puburl.com', + uids: [{ id: 'pubid1' }] + }, { + source: 'puburl2.com', + uids: [{ id: 'pubid2' }, { id: 'pubid2-123' }] + }] }); const request = spec.buildRequests([bidRequest]); @@ -1058,11 +1454,6 @@ describe('AppNexusAdapter', function () { id: 'sample-criteo-userid', }); - expect(payload.eids).to.deep.include({ - source: 'chrome.com', - id: 'sample-flocid-value' - }); - expect(payload.eids).to.deep.include({ source: 'netid.de', id: 'sample-netId-userid', @@ -1088,30 +1479,38 @@ describe('AppNexusAdapter', function () { source: 'puburl2.com', id: 'pubid2' }); + expect(payload.eids).to.deep.include({ + source: 'puburl2.com', + id: 'pubid2-123' + }); }); it('should populate iab_support object at the root level if omid support is detected', function () { - // with bid.params.frameworks - let bidRequest_A = Object.assign({}, bidRequests[0], { - params: { - frameworks: [1, 2, 5, 6], - video: { - frameworks: [1, 2, 5, 6] + let request, payload; + + if (FEATURES.VIDEO) { + // with bid.params.frameworks + let bidRequest_A = Object.assign({}, bidRequests[0], { + params: { + frameworks: [1, 2, 5, 6], + video: { + frameworks: [1, 2, 5, 6] + } } - } - }); - let request = spec.buildRequests([bidRequest_A]); - let payload = JSON.parse(request.data); - expect(payload.iab_support).to.be.an('object'); - expect(payload.iab_support).to.deep.equal({ - omidpn: 'Appnexus', - omidpv: '$prebid.version$' - }); - expect(payload.tags[0].banner_frameworks).to.be.an('array'); - expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]); - expect(payload.tags[0].video_frameworks).to.be.an('array'); - expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]); - expect(payload.tags[0].video.frameworks).to.not.exist; + }); + request = spec.buildRequests([bidRequest_A]); + payload = JSON.parse(request.data); + expect(payload.iab_support).to.be.an('object'); + expect(payload.iab_support).to.deep.equal({ + omidpn: 'Appnexus', + omidpv: '$prebid.version$' + }); + expect(payload.tags[0].banner_frameworks).to.be.an('array'); + expect(payload.tags[0].banner_frameworks).to.deep.equal([1, 2, 5, 6]); + expect(payload.tags[0].video_frameworks).to.be.an('array'); + expect(payload.tags[0].video_frameworks).to.deep.equal([1, 2, 5, 6]); + expect(payload.tags[0].video.frameworks).to.not.exist; + } // without bid.params.frameworks const bidRequest_B = Object.assign({}, bidRequests[0]); @@ -1121,33 +1520,32 @@ describe('AppNexusAdapter', function () { expect(payload.tags[0].banner_frameworks).to.not.exist; expect(payload.tags[0].video_frameworks).to.not.exist; - // with video.frameworks but it is not an array - const bidRequest_C = Object.assign({}, bidRequests[0], { - params: { - video: { - frameworks: "'1', '2', '3', '6'" + if (FEATURES.VIDEO) { + // with video.frameworks but it is not an array + const bidRequest_C = Object.assign({}, bidRequests[0], { + params: { + video: { + frameworks: "'1', '2', '3', '6'" + } } - } - }); - request = spec.buildRequests([bidRequest_C]); - payload = JSON.parse(request.data); - expect(payload.iab_support).to.not.exist; - expect(payload.tags[0].banner_frameworks).to.not.exist; - expect(payload.tags[0].video_frameworks).to.not.exist; + }); + request = spec.buildRequests([bidRequest_C]); + payload = JSON.parse(request.data); + expect(payload.iab_support).to.not.exist; + expect(payload.tags[0].banner_frameworks).to.not.exist; + expect(payload.tags[0].video_frameworks).to.not.exist; + } }); }) describe('interpretResponse', function () { - let bfStub; let bidderSettingsStorage; - before(function() { - bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); + before(function () { bidderSettingsStorage = $$PREBID_GLOBAL$$.bidderSettings; }); - after(function() { - bfStub.restore(); + after(function () { $$PREBID_GLOBAL$$.bidderSettings = bidderSettingsStorage; }); @@ -1202,6 +1600,7 @@ describe('AppNexusAdapter', function () { it('should get correct bid response', function () { let expectedResponse = [ { + 'adId': '3a1f23123e', 'requestId': '3db3773286ee59', 'cpm': 0.5, 'creativeId': 29681110, @@ -1234,7 +1633,7 @@ describe('AppNexusAdapter', function () { adUnitCode: 'code' }] }; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); + let result = spec.interpretResponse({ body: response }, { bidderRequest }); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); @@ -1285,226 +1684,235 @@ describe('AppNexusAdapter', function () { }; let bidderRequest; - let result = spec.interpretResponse({ body: response }, {bidderRequest}); + let result = spec.interpretResponse({ body: response }, { bidderRequest }); expect(result.length).to.equal(0); }); - it('handles outstream video responses', function () { - let response = { - 'tags': [{ - 'uuid': '84ab500420319d', - 'ads': [{ - 'ad_type': 'video', - 'cpm': 0.500000, - 'notify_url': 'imptracker.com', - 'rtb': { - 'video': { - 'content': '' - } - }, - 'javascriptTrackers': '' + if (FEATURES.VIDEO) { + it('handles outstream video responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'content': '' + } + }, + 'javascriptTrackers': '' + }] }] - }] - }; - let bidderRequest = { - bids: [{ - bidId: '84ab500420319d', - adUnitCode: 'code', - mediaTypes: { - video: { - context: 'outstream' + }; + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'outstream' + } } - } - }] - } + }] + } - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).to.have.property('vastXml'); - expect(result[0]).to.have.property('vastImpUrl'); - expect(result[0]).to.have.property('mediaType', 'video'); - }); + let result = spec.interpretResponse({ body: response }, { bidderRequest }); + expect(result[0]).to.have.property('vastXml'); + expect(result[0]).to.have.property('vastImpUrl'); + expect(result[0]).to.have.property('mediaType', 'video'); + }); - it('handles instream video responses', function () { - let response = { - 'tags': [{ - 'uuid': '84ab500420319d', - 'ads': [{ - 'ad_type': 'video', - 'cpm': 0.500000, - 'notify_url': 'imptracker.com', - 'rtb': { - 'video': { - 'asset_url': 'https://sample.vastURL.com/here/vid' - } - }, - 'javascriptTrackers': '' + it('handles instream video responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'asset_url': 'https://sample.vastURL.com/here/vid' + } + }, + 'javascriptTrackers': '' + }] }] - }] - }; - let bidderRequest = { - bids: [{ - bidId: '84ab500420319d', - adUnitCode: 'code', - mediaTypes: { - video: { - context: 'instream' + }; + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'instream' + } } - } - }] - } + }] + } - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).to.have.property('vastUrl'); - expect(result[0]).to.have.property('vastImpUrl'); - expect(result[0]).to.have.property('mediaType', 'video'); - }); + let result = spec.interpretResponse({ body: response }, { bidderRequest }); + expect(result[0]).to.have.property('vastUrl'); + expect(result[0]).to.have.property('vastImpUrl'); + expect(result[0]).to.have.property('mediaType', 'video'); + }); - it('handles adpod responses', function () { - let response = { - 'tags': [{ - 'uuid': '84ab500420319d', - 'ads': [{ - 'ad_type': 'video', - 'brand_category_id': 10, - 'cpm': 0.500000, - 'notify_url': 'imptracker.com', - 'rtb': { - 'video': { - 'asset_url': 'https://sample.vastURL.com/here/adpod', - 'duration_ms': 30000, + it('handles adpod responses', function () { + let response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'brand_category_id': 10, + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'asset_url': 'https://sample.vastURL.com/here/adpod', + 'duration_ms': 30000, + } + }, + 'viewability': { + 'config': '' } - }, - 'viewability': { - 'config': '' - } + }] }] - }] - }; - - let bidderRequest = { - bids: [{ - bidId: '84ab500420319d', - adUnitCode: 'code', - mediaTypes: { - video: { - context: 'adpod' + }; + + let bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'adpod' + } } - } - }] - }; - bfStub.returns('1'); - - let result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).to.have.property('vastUrl'); - expect(result[0].video.context).to.equal('adpod'); - expect(result[0].video.durationSeconds).to.equal(30); - }); - - it('handles native responses', function () { - let response1 = deepClone(response); - response1.tags[0].ads[0].ad_type = 'native'; - response1.tags[0].ads[0].rtb.native = { - 'title': 'Native Creative', - 'desc': 'Cool description great stuff', - 'desc2': 'Additional body text', - 'ctatext': 'Do it', - 'sponsored': 'AppNexus', - 'icon': { - 'width': 0, - 'height': 0, - 'url': 'https://cdn.adnxs.com/icon.png' - }, - 'main_img': { - 'width': 2352, - 'height': 1516, - 'url': 'https://cdn.adnxs.com/img.png' - }, - 'link': { - 'url': 'https://www.appnexus.com', - 'fallback_url': '', - 'click_trackers': ['https://nym1-ib.adnxs.com/click'] - }, - 'impression_trackers': ['https://example.com'], - 'rating': '5', - 'displayurl': 'https://AppNexus.com/?url=display_url', - 'likes': '38908320', - 'downloads': '874983', - 'price': '9.99', - 'saleprice': 'FREE', - 'phone': '1234567890', - 'address': '28 W 23rd St, New York, NY 10010', - 'privacy_link': 'https://appnexus.com/?url=privacy_url', - 'javascriptTrackers': '' - }; - let bidderRequest = { - bids: [{ - bidId: '3db3773286ee59', - adUnitCode: 'code' - }] - } - - let result = spec.interpretResponse({ body: response1 }, {bidderRequest}); - expect(result[0].native.title).to.equal('Native Creative'); - expect(result[0].native.body).to.equal('Cool description great stuff'); - expect(result[0].native.cta).to.equal('Do it'); - expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); - }); - - it('supports configuring outstream renderers', function () { - const outstreamResponse = deepClone(response); - outstreamResponse.tags[0].ads[0].rtb.video = {}; - outstreamResponse.tags[0].ads[0].renderer_url = 'renderer.js'; + }] + }; - const bidderRequest = { - bids: [{ - bidId: '3db3773286ee59', - renderer: { - options: { - adText: 'configured' - } + let result = spec.interpretResponse({ body: response }, { bidderRequest }); + expect(result[0]).to.have.property('vastUrl'); + expect(result[0].video.context).to.equal('adpod'); + expect(result[0].video.durationSeconds).to.equal(30); + }); + } + + if (FEATURES.NATIVE) { + it('handles native responses', function () { + let response1 = deepClone(response); + response1.tags[0].ads[0].ad_type = 'native'; + response1.tags[0].ads[0].rtb.native = { + 'title': 'Native Creative', + 'desc': 'Cool description great stuff', + 'desc2': 'Additional body text', + 'ctatext': 'Do it', + 'sponsored': 'AppNexus', + 'icon': { + 'width': 0, + 'height': 0, + 'url': 'https://cdn.adnxs.com/icon.png' }, - mediaTypes: { - video: { - context: 'outstream' - } + 'main_img': { + 'width': 2352, + 'height': 1516, + 'url': 'https://cdn.adnxs.com/img.png' + }, + 'link': { + 'url': 'https://www.appnexus.com', + 'fallback_url': '', + 'click_trackers': ['https://nym1-ib.adnxs.com/click'] + }, + 'impression_trackers': ['https://example.com'], + 'rating': '5', + 'displayurl': 'https://AppNexus.com/?url=display_url', + 'likes': '38908320', + 'downloads': '874983', + 'price': '9.99', + 'saleprice': 'FREE', + 'phone': '1234567890', + 'address': '28 W 23rd St, New York, NY 10010', + 'privacy_link': 'https://appnexus.com/?url=privacy_url', + 'javascriptTrackers': '', + 'video': { + 'content': '' } - }] - }; + }; + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code' + }] + } - const result = spec.interpretResponse({ body: outstreamResponse }, {bidderRequest}); - expect(result[0].renderer.config).to.deep.equal( - bidderRequest.bids[0].renderer.options - ); - }); + let result = spec.interpretResponse({ body: response1 }, { bidderRequest }); + expect(result[0].native.title).to.equal('Native Creative'); + expect(result[0].native.body).to.equal('Cool description great stuff'); + expect(result[0].native.cta).to.equal('Do it'); + expect(result[0].native.image.url).to.equal('https://cdn.adnxs.com/img.png'); + expect(result[0].native.video.content).to.equal(''); + }); + } + + if (FEATURES.VIDEO) { + it('supports configuring outstream renderers', function () { + const outstreamResponse = deepClone(response); + outstreamResponse.tags[0].ads[0].rtb.video = {}; + outstreamResponse.tags[0].ads[0].renderer_url = 'renderer.js'; + + const bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + renderer: { + options: { + adText: 'configured' + } + }, + mediaTypes: { + video: { + context: 'outstream' + } + } + }] + }; - it('should add deal_priority and deal_code', function() { - let responseWithDeal = deepClone(response); - responseWithDeal.tags[0].ads[0].ad_type = 'video'; - responseWithDeal.tags[0].ads[0].deal_priority = 5; - responseWithDeal.tags[0].ads[0].deal_code = '123'; - responseWithDeal.tags[0].ads[0].rtb.video = { - duration_ms: 1500, - player_width: 640, - player_height: 340, - }; + const result = spec.interpretResponse({ body: outstreamResponse }, { bidderRequest }); + expect(result[0].renderer.config).to.deep.equal( + bidderRequest.bids[0].renderer.options + ); + }); - let bidderRequest = { - bids: [{ - bidId: '3db3773286ee59', - adUnitCode: 'code', - mediaTypes: { - video: { - context: 'adpod' + it('should add deal_priority and deal_code', function () { + let responseWithDeal = deepClone(response); + responseWithDeal.tags[0].ads[0].ad_type = 'video'; + responseWithDeal.tags[0].ads[0].deal_priority = 5; + responseWithDeal.tags[0].ads[0].deal_code = '123'; + responseWithDeal.tags[0].ads[0].rtb.video = { + duration_ms: 1500, + player_width: 640, + player_height: 340, + }; + + let bidderRequest = { + bids: [{ + bidId: '3db3773286ee59', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'adpod' + } } - } - }] - } - let result = spec.interpretResponse({ body: responseWithDeal }, {bidderRequest}); - expect(Object.keys(result[0].appnexus)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); - expect(result[0].video.dealTier).to.equal(5); - }); + }] + } + let result = spec.interpretResponse({ body: responseWithDeal }, { bidderRequest }); + expect(Object.keys(result[0].appnexus)).to.include.members(['buyerMemberId', 'dealPriority', 'dealCode']); + expect(result[0].video.dealTier).to.equal(5); + }); + } - it('should add advertiser id', function() { + it('should add advertiser id', function () { let responseAdvertiserId = deepClone(response); responseAdvertiserId.tags[0].ads[0].advertiser_id = '123'; @@ -1514,11 +1922,11 @@ describe('AppNexusAdapter', function () { adUnitCode: 'code' }] } - let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); + let result = spec.interpretResponse({ body: responseAdvertiserId }, { bidderRequest }); expect(Object.keys(result[0].meta)).to.include.members(['advertiserId']); }); - it('should add brand id', function() { + it('should add brand id', function () { let responseBrandId = deepClone(response); responseBrandId.tags[0].ads[0].brand_id = 123; @@ -1528,13 +1936,13 @@ describe('AppNexusAdapter', function () { adUnitCode: 'code' }] } - let result = spec.interpretResponse({ body: responseBrandId }, {bidderRequest}); + let result = spec.interpretResponse({ body: responseBrandId }, { bidderRequest }); expect(Object.keys(result[0].meta)).to.include.members(['brandId']); }); - it('should add advertiserDomains', function() { + it('should add advertiserDomains', function () { let responseAdvertiserId = deepClone(response); - responseAdvertiserId.tags[0].ads[0].adomain = ['123']; + responseAdvertiserId.tags[0].ads[0].adomain = '123'; let bidderRequest = { bids: [{ @@ -1542,21 +1950,31 @@ describe('AppNexusAdapter', function () { adUnitCode: 'code' }] } - let result = spec.interpretResponse({ body: responseAdvertiserId }, {bidderRequest}); + let result = spec.interpretResponse({ body: responseAdvertiserId }, { bidderRequest }); expect(Object.keys(result[0].meta)).to.include.members(['advertiserDomains']); - expect(Object.keys(result[0].meta.advertiserDomains)).to.deep.equal([]); + expect(result[0].meta.advertiserDomains).to.deep.equal(['123']); }); }); describe('transformBidParams', function () { - it('convert keywords param differently for psp endpoint', function () { - sinon.stub(config, 'getConfig') - .withArgs('s2sConfig') - .returns({ - endpoint: { - p1Consent: 'https://ib.adnxs.com/openrtb2/prebid' - } - }); + let gcStub; + let adUnit = { bids: [{ bidder: 'appnexus' }] }; ; + + before(function () { + gcStub = sinon.stub(config, 'getConfig'); + }); + + after(function () { + gcStub.restore(); + }); + + it('convert keywords param differently for psp endpoint with single s2sConfig', function () { + gcStub.withArgs('s2sConfig').returns({ + bidders: ['appnexus'], + endpoint: { + p1Consent: 'https://ib.adnxs.com/openrtb2/prebid' + } + }); const oldParams = { keywords: { @@ -1565,10 +1983,27 @@ describe('AppNexusAdapter', function () { } }; - const newParams = spec.transformBidParams(oldParams, true); + const newParams = spec.transformBidParams(oldParams, true, adUnit); expect(newParams.keywords).to.equal('genre=rock,genre=pop,pets=dog'); + }); - config.getConfig.restore(); + it('convert keywords param differently for psp endpoint with array s2sConfig', function () { + gcStub.withArgs('s2sConfig').returns([{ + bidders: ['appnexus'], + endpoint: { + p1Consent: 'https://ib.adnxs.com/openrtb2/prebid' + } + }]); + + const oldParams = { + keywords: { + genre: ['rock', 'pop'], + pets: 'dog' + } + }; + + const newParams = spec.transformBidParams(oldParams, true, adUnit); + expect(newParams.keywords).to.equal('genre=rock,genre=pop,pets=dog'); }); }); }); diff --git a/test/spec/modules/appushBidAdapter_spec.js b/test/spec/modules/appushBidAdapter_spec.js new file mode 100644 index 00000000000..e6af98c0f33 --- /dev/null +++ b/test/spec/modules/appushBidAdapter_spec.js @@ -0,0 +1,373 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/appushBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'appush' + +describe('AppushBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://hb.appush.com/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); +}); diff --git a/test/spec/modules/apstreamBidAdapter_spec.js b/test/spec/modules/apstreamBidAdapter_spec.js index e640c009989..3efb5fd38d5 100644 --- a/test/spec/modules/apstreamBidAdapter_spec.js +++ b/test/spec/modules/apstreamBidAdapter_spec.js @@ -33,6 +33,11 @@ describe('AP Stream adapter', function() { let mockConfig; beforeEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + apstream: { + storageAllowed: true + } + }; mockConfig = { apstream: { publisherId: '4321' @@ -44,6 +49,7 @@ describe('AP Stream adapter', function() { }); afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; config.getConfig.restore(); }); @@ -194,29 +200,6 @@ describe('AP Stream adapter', function() { describe('dsu', function() { it('should pass DSU from local storage if set', function() { - let dsu = 'some_dsu'; - localStorage.setItem('apr_dsu', dsu); - - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'consentDataString', - vendorData: { - vendorConsents: { - '394': true - } - } - } - }; - - const request = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - - assert.equal(request.dsu, dsu); - }); - - it('should generate new DSU if nothing in local storage', function() { - localStorage.removeItem('apr_dsu'); - const bidderRequest = { gdprConsent: { gdprApplies: true, @@ -230,10 +213,7 @@ describe('AP Stream adapter', function() { }; const request = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - let dsu = localStorage.getItem('apr_dsu'); - - assert.isNotEmpty(dsu); - assert.equal(request.dsu, dsu); + assert.isNotEmpty(request.dsu); }); }); }); diff --git a/test/spec/modules/arcspanRtdProvider_spec.js b/test/spec/modules/arcspanRtdProvider_spec.js new file mode 100644 index 00000000000..c75075d8e05 --- /dev/null +++ b/test/spec/modules/arcspanRtdProvider_spec.js @@ -0,0 +1,187 @@ +import { arcspanSubmodule } from 'modules/arcspanRtdProvider.js'; +import { expect } from 'chai'; +import { loadExternalScript } from 'src/adloader.js'; + +describe('arcspanRtdProvider', function () { + describe('init', function () { + afterEach(function () { + window.arcobj1 = undefined; + window.arcobj2 = undefined; + }); + + it('successfully initializes with a valid silo ID', function () { + expect(arcspanSubmodule.init(getGoodConfig())).to.equal(true); + expect(loadExternalScript.called).to.be.ok; + expect(loadExternalScript.args[0][0]).to.deep.equal('https://silo13.p7cloud.net/as.js'); + loadExternalScript.resetHistory(); + }); + + it('fails to initialize with a missing silo ID', function () { + expect(arcspanSubmodule.init(getBadConfig())).to.equal(false); + expect(loadExternalScript.called).to.be.not.ok; + loadExternalScript.resetHistory(); + }); + + it('drops localhost script for test silo', function () { + expect(arcspanSubmodule.init(getTestConfig())).to.equal(true); + expect(loadExternalScript.called).to.be.ok; + expect(loadExternalScript.args[0][0]).to.deep.equal('https://localhost:8080/as.js'); + loadExternalScript.resetHistory(); + }); + }); + + describe('alterBidRequests', function () { + afterEach(function () { + window.arcobj1 = undefined; + window.arcobj2 = undefined; + }); + + it('alters the bid request 1', function () { + setIAB({ + raw: { + images: [ + 'Religion & Spirituality', + 'Medical Health>Substance Abuse', + 'Religion & Spirituality>Astrology', + 'Medical Health', + 'Events & Attractions', + ], + }, + codes: { + images: ['IAB23-10', 'IAB7', 'IAB7-42', 'IAB15-1'], + }, + newcodes: { + images: ['150', '453', '311', '456', '286'], + }, + }); + + var reqBidsConfigObj = {}; + reqBidsConfigObj.ortb2Fragments = {}; + reqBidsConfigObj.ortb2Fragments.global = {}; + arcspanSubmodule.getBidRequestData(reqBidsConfigObj, function () { + expect(reqBidsConfigObj.ortb2Fragments.global.site.name).to.equal( + 'arcspan' + ); + expect(reqBidsConfigObj.ortb2Fragments.global.site.keywords).to.equal( + 'Religion & Spirituality,Medical Health>Substance Abuse,Religion & Spirituality>Astrology,Medical Health,Events & Attractions' + ); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].ext.segtax).to.equal(6); + expect(reqBidsConfigObj.ortb2Fragments.global.site.cat).to.eql([ + 'IAB23_10', + 'IAB7', + 'IAB7_42', + 'IAB15_1', + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.sectioncat).to.eql([ + 'IAB23_10', + 'IAB7', + 'IAB7_42', + 'IAB15_1' + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.pagecat).to.eql([ + 'IAB23_10', + 'IAB7', + 'IAB7_42', + 'IAB15_1', + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].segment).to.eql([ + { id: '150' }, + { id: '453' }, + { id: '311' }, + { id: '456' }, + { id: '286' } + ]); + }); + }); + + it('alters the bid request 2', function () { + setIAB({ + raw: { text: ['Sports', 'Sports>Soccer'] }, + codes: { text: ['IAB17', 'IAB17-44'] }, + newcodes: { text: ['483', '533'] }, + }); + + var reqBidsConfigObj = {}; + reqBidsConfigObj.ortb2Fragments = {}; + reqBidsConfigObj.ortb2Fragments.global = {}; + arcspanSubmodule.getBidRequestData(reqBidsConfigObj, function () { + expect(reqBidsConfigObj.ortb2Fragments.global.site.name).to.equal( + 'arcspan' + ); + expect(reqBidsConfigObj.ortb2Fragments.global.site.keywords).to.equal( + 'Sports,Sports>Soccer' + ); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].ext.segtax).to.equal(6); + expect(reqBidsConfigObj.ortb2Fragments.global.site.cat).to.eql([ + 'IAB17', + 'IAB17_44', + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.sectioncat).to.eql([ + 'IAB17', + 'IAB17_44' + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.pagecat).to.eql([ + 'IAB17', + 'IAB17_44', + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].segment).to.eql([ + { id: '483' }, + { id: '533' } + ]); + }); + }); + }); +}); + +function getGoodConfig() { + return { + name: 'arcspan', + waitForIt: true, + params: { + silo: 13, + }, + }; +} + +function getBadConfig() { + return { + name: 'arcspan', + waitForIt: true, + params: { + notasilo: 1, + }, + }; +} + +function getTestConfig() { + return { + name: 'arcspan', + waitForIt: true, + params: { + silo: 'test', + }, + }; +} + +function setIAB(vjson) { + window.arcobj2 = {}; + window.arcobj2.cat = 0; + if (typeof vjson.codes != 'undefined') { + window.arcobj2.cat = 1; + if (typeof vjson.codes.images != 'undefined') { + vjson.codes.images.forEach(function f(e, i) { + vjson.codes.images[i] = e.replace('-', '_'); + }); + } + if (typeof vjson.codes.text != 'undefined') { + vjson.codes.text.forEach(function f(e, i) { + vjson.codes.text[i] = e.replace('-', '_'); + }); + } + window.arcobj2.sampled = 1; + window.arcobj1 = {}; + window.arcobj1.page_iab_codes = vjson.codes; + window.arcobj1.page_iab = vjson.raw; + window.arcobj1.page_iab_newcodes = vjson.newcodes; + } +} diff --git a/test/spec/modules/asealBidAdapter_spec.js b/test/spec/modules/asealBidAdapter_spec.js index ef74dd3fc05..2dc1b47b7d0 100644 --- a/test/spec/modules/asealBidAdapter_spec.js +++ b/test/spec/modules/asealBidAdapter_spec.js @@ -1,120 +1,187 @@ import { expect } from 'chai'; -import { spec, BIDDER_CODE, API_ENDPOINT, HEADER_AOTTER_VERSION } from 'modules/asealBidAdapter.js'; +import { + spec, + BIDDER_CODE, + API_ENDPOINT, + HEADER_AOTTER_VERSION, + WEB_SESSION_ID_KEY, +} from 'modules/asealBidAdapter.js'; +import { getRefererInfo } from 'src/refererDetection.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import { config } from 'src/config.js'; +import * as utils from 'src/utils.js'; +import { storage } from 'modules/asealBidAdapter.js'; -const TEST_CLIENT_ID = 'TEST_CLIENT_ID' +const TEST_CLIENT_ID = 'TEST_CLIENT_ID'; +const TEST_WEB_SESSION_ID = 'TEST_WEB_SESSION_ID'; describe('asealBidAdapter', () => { const adapter = newBidder(spec); + let localStorageIsEnabledStub; + let getDataFromLocalStorageStub; + let sandbox; + let w; + + beforeEach((done) => { + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + getDataFromLocalStorageStub = sinon.stub( + storage, + 'getDataFromLocalStorage' + ); + + w = { + document: { + title: 'Aseal', + referrer: 'https://aseal.in/', + href: 'https://aseal.in/', + }, + location: { + href: 'https://aseal.in/', + }, + }; + + sandbox = sinon.sandbox.create(); + sandbox.stub(utils, 'getWindowTop').returns(w); + sandbox.stub(utils, 'getWindowSelf').returns(w); + done(); + }); + + afterEach(() => { + localStorageIsEnabledStub.restore(); + getDataFromLocalStorageStub.restore(); + sandbox.restore(); + config.resetConfig(); + }); + describe('inherited functions', () => { it('exists and is a function', () => { - expect(adapter.callBids).to.exist.and.to.be.a('function') - }) + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); }); describe('isBidRequestValid', () => { const bid = { bidder: 'aseal', params: { - placeUid: '123' - } + placeUid: '123', + }, }; it('should return true when required params found', () => { - expect(spec.isBidRequestValid(bid)).to.equal(true) + expect(spec.isBidRequestValid(bid)).to.equal(true); }); it('should return false when required param placeUid is not passed', () => { bid.params = { - placeUid: '' - } - expect(spec.isBidRequestValid(bid)).to.equal(false) + placeUid: '', + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); }); it('should return false when required param placeUid is wrong type', () => { bid.params = { - placeUid: null - } - expect(spec.isBidRequestValid(bid)).to.equal(false) + placeUid: null, + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); }); it('should return false when required params are not passed', () => { let bid = Object.assign({}, bid); delete bid.params; bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false) - }) + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); }); describe('buildRequests', () => { - afterEach(() => { - config.resetConfig(); - }); - it('should return an empty array when there are no bid requests', () => { - const bidRequests = [] - const request = spec.buildRequests(bidRequests) + const bidRequests = []; + const request = spec.buildRequests(bidRequests); - expect(request).to.be.an('array').that.is.empty + expect(request).to.be.an('array').that.is.empty; }); it('should send `x-aotter-clientid` header as empty string when user not set config `clientId`', () => { - const bidRequests = [{ - bidder: BIDDER_CODE, - params: { - placeUid: '123' - } - }] - - const bidderRequest = {} + const bidRequests = [ + { + bidder: BIDDER_CODE, + params: { + placeUid: '123', + }, + }, + ]; + + const bidderRequest = {}; const request = spec.buildRequests(bidRequests, bidderRequest)[0]; - expect(request.options.customHeaders['x-aotter-clientid']).equal('') - }) + expect(request.options.customHeaders['x-aotter-clientid']).equal(''); + }); it('should send bid requests to ENDPOINT via POST', () => { - const bidRequests = [{ - bidder: BIDDER_CODE, - params: { - placeUid: '123' - } - }] + const bidRequests = [ + { + bidder: BIDDER_CODE, + params: { + placeUid: '123', + }, + }, + ]; const bidderRequest = { - refererInfo: { - referer: 'https://aseal.in/', - } - } + refererInfo: getRefererInfo(), + }; config.setConfig({ aseal: { - clientId: TEST_CLIENT_ID - } + clientId: TEST_CLIENT_ID, + }, }); + + localStorageIsEnabledStub.returns(true); + getDataFromLocalStorageStub + .withArgs(WEB_SESSION_ID_KEY) + .returns(TEST_WEB_SESSION_ID); + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + utils.getWindowTop.restore(); + utils.getWindowSelf.restore(); + + sandbox.stub(utils, 'getWindowTop').returns(w); + sandbox.stub(utils, 'getWindowSelf').returns(w); + + const payload = { + meta: { + dr: w.document.referrer, + drs: w.document.referrer, + drt: w.document.referrer, + dt: w.document.title, + dl: w.location.href, + }, + }; + expect(request.url).to.equal(API_ENDPOINT); - expect(request.method).to.equal('POST') + expect(request.method).to.equal('POST'); expect(request.options).deep.equal({ contentType: 'application/json', withCredentials: true, customHeaders: { 'x-aotter-clientid': TEST_CLIENT_ID, 'x-aotter-version': HEADER_AOTTER_VERSION, - } + }, }); - expect(request.data).deep.equal({ - bids: bidRequests, - refererInfo: bidderRequest.refererInfo, + expect(request.data.bids).deep.equal(bidRequests); + expect(request.data.payload).deep.equal(payload); + expect(request.data.device).deep.equal({ + webSessionId: TEST_WEB_SESSION_ID, }); }); }); describe('interpretResponse', () => { it('should return an empty array when there are no bids', () => { - const serverResponse = {} + const serverResponse = {}; const response = spec.interpretResponse(serverResponse); expect(response).is.an('array').that.is.empty; @@ -122,23 +189,25 @@ describe('asealBidAdapter', () => { it('should get correct bid response', () => { const serverResponse = { - body: [{ - requestId: '2ef08f145b7a4f', - cpm: 3, - width: 300, - height: 250, - creativeId: '123abc', - dealId: '123abc', - currency: 'USD', - netRevenue: false, - mediaType: 'banner', - ttl: 300, - ad: '' - }] - } + body: [ + { + requestId: '2ef08f145b7a4f', + cpm: 3, + width: 300, + height: 250, + creativeId: '123abc', + dealId: '123abc', + currency: 'USD', + netRevenue: false, + mediaType: 'banner', + ttl: 300, + ad: '', + }, + ], + }; const response = spec.interpretResponse(serverResponse); expect(response).deep.equal(serverResponse.body); }); - }) + }); }); diff --git a/test/spec/modules/asoBidAdapter_spec.js b/test/spec/modules/asoBidAdapter_spec.js index 0dc779a300d..88016d1902c 100644 --- a/test/spec/modules/asoBidAdapter_spec.js +++ b/test/spec/modules/asoBidAdapter_spec.js @@ -62,7 +62,8 @@ describe('Adserver.Online bidding adapter', function () { refererInfo: { numIframes: 0, reachedTop: true, - referer: 'https://example.com' + page: 'https://example.com', + domain: 'example.com' } }; @@ -124,7 +125,7 @@ describe('Adserver.Online bidding adapter', function () { expect(parsedRequestUrl.pathname).to.equal('/prebid/bidder'); const query = parsedRequestUrl.search; - expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.pbjs).to.contain('$prebid.version$'); expect(query.zid).to.equal('1'); expect(request.data).to.exist; @@ -161,7 +162,7 @@ describe('Adserver.Online bidding adapter', function () { expect(parsedRequestUrl.pathname).to.equal('/prebid/bidder'); const query = parsedRequestUrl.search; - expect(query.pbjs).to.equal('$prebid.version$'); + expect(query.pbjs).to.contain('$prebid.version$'); expect(query.zid).to.equal('2'); expect(request.data).to.not.be.empty; diff --git a/test/spec/modules/astraoneBidAdapter_spec.js b/test/spec/modules/astraoneBidAdapter_spec.js index 0e545081869..80d6dcdf627 100644 --- a/test/spec/modules/astraoneBidAdapter_spec.js +++ b/test/spec/modules/astraoneBidAdapter_spec.js @@ -8,7 +8,11 @@ function getSlotConfigs(mediaTypes, params) { bidId: '2df8c0733f284e', bidder: 'astraone', mediaTypes: mediaTypes, - transactionId: '31a58515-3634-4e90-9c96-f86196db1459' + ortb2Imp: { + ext: { + tid: '31a58515-3634-4e90-9c96-f86196db1459' + } + } } } diff --git a/test/spec/modules/atsAnalyticsAdapter_spec.js b/test/spec/modules/atsAnalyticsAdapter_spec.js index cae90a19223..2316f96ec8e 100644 --- a/test/spec/modules/atsAnalyticsAdapter_spec.js +++ b/test/spec/modules/atsAnalyticsAdapter_spec.js @@ -3,14 +3,14 @@ import { expect } from 'chai'; import adapterManager from 'src/adapterManager.js'; import {server} from '../../mocks/xhr.js'; import {parseBrowser} from '../../../modules/atsAnalyticsAdapter.js'; -import {getStorageManager} from '../../../src/storageManager.js'; +import {getCoreStorageManager, getStorageManager} from '../../../src/storageManager.js'; import {analyticsUrl} from '../../../modules/atsAnalyticsAdapter.js'; let utils = require('src/utils'); let events = require('src/events'); let constants = require('src/constants.json'); -export const storage = getStorageManager(); +const storage = getCoreStorageManager(); let sandbox; let clock; let now = new Date(); diff --git a/test/spec/modules/audiencerunBidAdapter_spec.js b/test/spec/modules/audiencerunBidAdapter_spec.js index 7f1e059fa2a..5c736345068 100644 --- a/test/spec/modules/audiencerunBidAdapter_spec.js +++ b/test/spec/modules/audiencerunBidAdapter_spec.js @@ -114,7 +114,8 @@ describe('AudienceRun bid adapter tests', function () { }, refererInfo: { canonicalUrl: undefined, - referer: 'https://example.com', + page: 'https://example.com', + topmostLocation: 'https://example.com', numIframes: 0, reachedTop: true, }, @@ -217,16 +218,7 @@ describe('AudienceRun bid adapter tests', function () { it('should add userid eids information to the request', function () { const bid = Object.assign({}, bidRequest); - bid.userId = { - pubcid: '01EAJWWNEPN3CYMM5N8M5VXY22', - unsuported: '666', - } - - const request = spec.buildRequests([bid]); - const payload = JSON.parse(request.data); - - expect(payload.userId).to.exist; - expect(payload.userId).to.deep.equal([ + bid.userIdAsEids = [ { source: 'pubcid.org', uids: [ @@ -236,7 +228,13 @@ describe('AudienceRun bid adapter tests', function () { }, ], }, - ]); + ]; + + const request = spec.buildRequests([bid]); + const payload = JSON.parse(request.data); + + expect(payload.userId).to.exist; + expect(payload.userId).to.deep.equal(bid.userIdAsEids); }); it('should add schain object if available', function() { diff --git a/test/spec/modules/automatadAnalyticsAdapter_spec.js b/test/spec/modules/automatadAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..e591f7e8e95 --- /dev/null +++ b/test/spec/modules/automatadAnalyticsAdapter_spec.js @@ -0,0 +1,533 @@ +import * as events from 'src/events'; +import * as utils from 'src/utils.js'; + +import spec, {self as exports} from 'modules/automatadAnalyticsAdapter.js'; + +import CONSTANTS from 'src/constants.json'; +import { expect } from 'chai'; + +const { + AUCTION_DEBUG, + BID_REQUESTED, + BID_REJECTED, + AUCTION_INIT, + BIDDER_DONE, + BID_RESPONSE, + BID_TIMEOUT, + BID_WON, + NO_BID +} = CONSTANTS.EVENTS + +const CONFIG_WITH_DEBUG = { + provider: 'atmtdAnalyticsAdapter', + options: { + publisherID: '230', + siteID: '421' + }, + includeEvents: [AUCTION_DEBUG, AUCTION_INIT, BIDDER_DONE, BID_RESPONSE, BID_TIMEOUT, NO_BID, BID_WON, BID_REQUESTED, BID_REJECTED] +} + +describe('Automatad Analytics Adapter', () => { + var sandbox, clock; + + describe('Adapter Setup Configuration', () => { + beforeEach(() => { + sandbox = sinon.createSandbox(); + sandbox.stub(utils, 'logMessage') + sandbox.stub(events, 'getEvents').returns([]); + sandbox.stub(utils, 'logError'); + }); + afterEach(() => { + sandbox.restore(); + }); + + it('Should log error and return false if nothing is passed as the param in the enable analytics call', () => { + spec.enableAnalytics() + + expect(utils.logError.called).to.equal(true) + }); + + it('Should log error and return false if object type is not passed as the param in the enable analytics call', () => { + spec.enableAnalytics('hello world') + + expect(utils.logError.called).to.equal(true) + }); + + it('Should log error and return false if options is not defined in the enable analytics call', () => { + spec.enableAnalytics({ + provider: 'atmtdAnalyticsAdapter' + }) + + expect(utils.logError.called).to.equal(true) + }); + it('Should log error and return false if pub id is not defined in the enable analytics call', () => { + spec.enableAnalytics({ + provider: 'atmtdAnalyticsAdapter', + options: { + siteID: '230' + } + }) + + expect(utils.logError.called).to.equal(true) + }); + it('Should log error and return false if pub id is not defined in the enable analytics call', () => { + spec.enableAnalytics({ + provider: 'atmtdAnalyticsAdapter', + options: { + publisherID: '230' + } + }) + + expect(utils.logError.called).to.equal(true) + }); + it('Should successfully configure the adapter and set global log debug messages flag to false', () => { + spec.enableAnalytics({ + provider: 'atmtdAnalyticsAdapter', + options: { + publisherID: '230', + siteID: '421', + logDebug: false + } + }); + expect(utils.logError.called).to.equal(false) + expect(utils.logMessage.called).to.equal(true) + spec.disableAnalytics(); + }); + it('Should successfully configure the adapter and set global log debug messages flag to true', () => { + sandbox.stub(exports, 'initializeQueue').callsFake(() => {}); + sandbox.stub(exports, 'addGPTHandlers').callsFake(() => {}); + const config = { + provider: 'atmtdAnalyticsAdapter', + options: { + publisherID: '230', + siteID: '410', + logDebug: true + } + } + + spec.enableAnalytics(config) + expect(utils.logError.called).to.equal(false) + expect(exports.initializeQueue.called).to.equal(true) + expect(exports.addGPTHandlers.called).to.equal(true) + expect(utils.logMessage.called).to.equal(true) + spec.disableAnalytics(); + }); + }); + + describe('Behaviour of the adapter when the sdk has loaded', () => { + before(() => { + spec.enableAnalytics(CONFIG_WITH_DEBUG); + const obj = { + auctionInitHandler: (args) => {}, + bidResponseHandler: (args) => {}, + bidderDoneHandler: (args) => {}, + bidWonHandler: (args) => {}, + noBidHandler: (args) => {}, + auctionDebugHandler: (args) => {}, + bidderTimeoutHandler: (args) => {}, + bidRequestedHandler: (args) => {}, + bidRejectedHandler: (args) => {} + } + + global.window.atmtdAnalytics = obj + + Object.keys(obj).forEach((fn) => sandbox.spy(global.window.atmtdAnalytics, fn)) + }) + beforeEach(() => { + sandbox = sinon.createSandbox(); + sandbox.stub(events, 'getEvents').returns([]); + sandbox.stub(utils, 'logMessage'); + sandbox.stub(utils, 'logError'); + }); + afterEach(() => { + sandbox.restore(); + }); + after(() => { + global.window.atmtdAnalytics = undefined; + spec.disableAnalytics(); + }) + + it('Should call the auctionInitHandler when the auction init event is fired', () => { + events.emit(AUCTION_INIT, {type: AUCTION_INIT}) + expect(global.window.atmtdAnalytics.auctionInitHandler.called).to.equal(true) + }); + + it('Should call the bidRequested when the bidRequested event is fired', () => { + events.emit(BID_REQUESTED, {type: BID_REQUESTED}) + expect(global.window.atmtdAnalytics.bidRequestedHandler.called).to.equal(true) + }); + + it('Should call the bidRejected when the bidRejected event is fired', () => { + events.emit(BID_REJECTED, {type: BID_REJECTED}) + expect(global.window.atmtdAnalytics.bidRejectedHandler.called).to.equal(true) + }); + + it('Should call the bidResponseHandler when the bidResponse event is fired', () => { + events.emit(BID_RESPONSE, {type: BID_RESPONSE}) + expect(global.window.atmtdAnalytics.bidResponseHandler.called).to.equal(true) + }); + + it('Should call the bidderDoneHandler when the bidderDone event is fired', () => { + events.emit(BIDDER_DONE, {type: BIDDER_DONE}) + expect(global.window.atmtdAnalytics.bidderDoneHandler.called).to.equal(true) + }); + + it('Should call the bidWonHandler when the bidWon event is fired', () => { + events.emit(BID_WON, {type: BID_WON}) + expect(global.window.atmtdAnalytics.bidWonHandler.called).to.equal(true) + }); + + it('Should call the noBidHandler when the noBid event is fired', () => { + events.emit(NO_BID, {type: NO_BID}) + expect(global.window.atmtdAnalytics.noBidHandler.called).to.equal(true) + }); + + it('Should call the bidTimeoutHandler when the bidTimeout event is fired', () => { + events.emit(BID_TIMEOUT, {type: BID_TIMEOUT}) + expect(global.window.atmtdAnalytics.bidderTimeoutHandler.called).to.equal(true) + }); + + it('Should call the auctionDebugHandler when the auctionDebug event is fired', () => { + events.emit(AUCTION_DEBUG, {type: AUCTION_DEBUG}) + expect(global.window.atmtdAnalytics.auctionDebugHandler.called).to.equal(true) + }); + }); + + describe('Behaviour of the adapter when the SDK has not loaded', () => { + before(() => { + spec.enableAnalytics(CONFIG_WITH_DEBUG); + }) + beforeEach(() => { + sandbox = sinon.createSandbox(); + sandbox.stub(events, 'getEvents').returns([]); + sandbox.stub(utils, 'logMessage'); + sandbox.stub(utils, 'logError'); + + global.window.atmtdAnalytics = undefined + exports.__atmtdAnalyticsQueue.length = 0 + sandbox.stub(exports.__atmtdAnalyticsQueue, 'push').callsFake((args) => { + Array.prototype.push.apply(exports.__atmtdAnalyticsQueue, [args]); + }) + }); + afterEach(() => { + sandbox.restore(); + }); + after(() => { + spec.disableAnalytics(); + }) + + it('Should push to the que when the auctionInit event is fired', () => { + events.emit(AUCTION_INIT, {type: AUCTION_INIT}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(AUCTION_INIT) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(AUCTION_INIT) + }); + + it('Should push to the que when the bidResponse event is fired', () => { + events.emit(BID_RESPONSE, {type: BID_RESPONSE}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_RESPONSE) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_RESPONSE) + }); + + it('Should push to the que when the bidRequested event is fired', () => { + events.emit(BID_REQUESTED, {type: BID_REQUESTED}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_REQUESTED) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_REQUESTED) + }); + + it('Should push to the que when the bidRejected event is fired', () => { + events.emit(BID_REJECTED, {type: BID_REJECTED}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_REJECTED) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_REJECTED) + }); + + it('Should push to the que when the bidderDone event is fired', () => { + events.emit(BIDDER_DONE, {type: BIDDER_DONE}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BIDDER_DONE) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BIDDER_DONE) + }); + + it('Should push to the que when the bidWon event is fired', () => { + events.emit(BID_WON, {type: BID_WON}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_WON) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_WON) + }); + + it('Should push to the que when the noBid event is fired', () => { + events.emit(NO_BID, {type: NO_BID}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(NO_BID) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(NO_BID) + }); + + it('Should push to the que when the auctionDebug is fired', () => { + events.emit(AUCTION_DEBUG, {type: AUCTION_DEBUG}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(AUCTION_DEBUG) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(AUCTION_DEBUG) + }); + + it('Should push to the que when the bidderTimeout event is fired', () => { + events.emit(BID_TIMEOUT, {type: BID_TIMEOUT}) + expect(exports.__atmtdAnalyticsQueue.push.called).to.equal(true) + expect(exports.__atmtdAnalyticsQueue).to.be.an('array').to.have.lengthOf(1) + expect(exports.__atmtdAnalyticsQueue[0]).to.have.lengthOf(2) + expect(exports.__atmtdAnalyticsQueue[0][0]).to.equal(BID_TIMEOUT) + expect(exports.__atmtdAnalyticsQueue[0][1].type).to.equal(BID_TIMEOUT) + }); + }); + + describe('Process Events from Que when SDK still has not loaded', () => { + before(() => { + spec.enableAnalytics({ + provider: 'atmtdAnalyticsAdapter', + options: { + publisherID: '230', + siteID: '421' + } + }); + global.window.atmtdAnalytics = undefined + + sandbox.stub(exports.__atmtdAnalyticsQueue, 'push').callsFake((args) => { + Array.prototype.push.apply(exports.__atmtdAnalyticsQueue, [args]); + }) + }) + beforeEach(() => { + sandbox = sinon.createSandbox(); + sandbox.stub(events, 'getEvents').returns([]); + sandbox.spy(exports, 'prettyLog') + sandbox.spy(exports, 'processEvents') + + clock = sandbox.useFakeTimers(); + exports.__atmtdAnalyticsQueue.length = 0 + }); + afterEach(() => { + sandbox.restore(); + exports.queuePointer = 0; + exports.retryCount = 0; + exports.__atmtdAnalyticsQueue = [] + spec.disableAnalytics(); + }) + + it('Should retry processing auctionInit in certain intervals', () => { + expect(exports.queuePointer).to.equal(0) + expect(exports.retryCount).to.equal(0) + const que = [[AUCTION_INIT, {type: AUCTION_INIT}]] + exports.__atmtdAnalyticsQueue.push(que[0]) + exports.processEvents() + expect(exports.prettyLog.getCall(0).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`) + expect(exports.prettyLog.getCall(1).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(1).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 1500ms ...`) + clock.tick(1510) + expect(exports.prettyLog.getCall(2).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(2).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 2`) + expect(exports.prettyLog.getCall(3).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(3).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 3000ms ...`) + clock.tick(3010) + expect(exports.prettyLog.getCall(4).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(4).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 3`) + expect(exports.prettyLog.getCall(5).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(5).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 5000ms ...`) + clock.tick(5010) + expect(exports.prettyLog.getCall(6).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(6).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 4`) + expect(exports.prettyLog.getCall(7).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(7).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 10000ms ...`) + clock.tick(10010) + expect(exports.prettyLog.getCall(8).args[0]).to.equal('error') + expect(exports.prettyLog.getCall(8).args[1]).to.equal(`Aggregator still hasn't loaded. Processing que stopped`) + expect(exports.queuePointer).to.equal(0) + expect(exports.processEvents.callCount).to.equal(5) + }) + + it('Should retry processing slotRenderEnded in certain intervals', () => { + expect(exports.queuePointer).to.equal(0) + expect(exports.retryCount).to.equal(0) + const que = [['slotRenderEnded', {type: 'slotRenderEnded'}]] + exports.__atmtdAnalyticsQueue.push(que[0]) + exports.processEvents() + expect(exports.prettyLog.getCall(0).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`) + expect(exports.prettyLog.getCall(1).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(1).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 1500ms ...`) + clock.tick(1510) + expect(exports.prettyLog.getCall(2).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(2).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 2`) + expect(exports.prettyLog.getCall(3).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(3).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 3000ms ...`) + clock.tick(3010) + expect(exports.prettyLog.getCall(4).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(4).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 3`) + expect(exports.prettyLog.getCall(5).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(5).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 5000ms ...`) + clock.tick(5010) + expect(exports.prettyLog.getCall(6).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(6).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 4`) + expect(exports.prettyLog.getCall(7).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(7).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 10000ms ...`) + clock.tick(10010) + expect(exports.prettyLog.getCall(8).args[0]).to.equal('error') + expect(exports.prettyLog.getCall(8).args[1]).to.equal(`Aggregator still hasn't loaded. Processing que stopped`) + expect(exports.queuePointer).to.equal(0) + expect(exports.processEvents.callCount).to.equal(5) + }) + + it('Should retry processing impressionViewable in certain intervals', () => { + expect(exports.queuePointer).to.equal(0) + expect(exports.retryCount).to.equal(0) + const que = [['impressionViewable', {type: 'impressionViewable'}]] + exports.__atmtdAnalyticsQueue.push(que[0]) + exports.processEvents() + expect(exports.prettyLog.getCall(0).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`) + expect(exports.prettyLog.getCall(1).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(1).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 1500ms ...`) + clock.tick(1510) + expect(exports.prettyLog.getCall(2).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(2).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 2`) + expect(exports.prettyLog.getCall(3).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(3).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 3000ms ...`) + clock.tick(3010) + expect(exports.prettyLog.getCall(4).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(4).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 3`) + expect(exports.prettyLog.getCall(5).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(5).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 5000ms ...`) + clock.tick(5010) + expect(exports.prettyLog.getCall(6).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(6).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 4`) + expect(exports.prettyLog.getCall(7).args[0]).to.equal('warn') + expect(exports.prettyLog.getCall(7).args[1]).to.equal(`Adapter failed to process event as aggregator has not loaded. Retrying in 10000ms ...`) + clock.tick(10010) + expect(exports.prettyLog.getCall(8).args[0]).to.equal('error') + expect(exports.prettyLog.getCall(8).args[1]).to.equal(`Aggregator still hasn't loaded. Processing que stopped`) + expect(exports.queuePointer).to.equal(0) + expect(exports.processEvents.callCount).to.equal(5) + }) + }); + + describe('Process Events from Que when SDK has loaded', () => { + before(() => { + spec.enableAnalytics({ + provider: 'atmtdAnalyticsAdapter', + options: { + publisherID: '230', + siteID: '421' + } + }); + sandbox = sinon.createSandbox(); + sandbox.reset() + const obj = { + auctionInitHandler: (args) => {}, + bidResponseHandler: (args) => {}, + bidderDoneHandler: (args) => {}, + bidWonHandler: (args) => {}, + noBidHandler: (args) => {}, + auctionDebugHandler: (args) => {}, + bidderTimeoutHandler: (args) => {}, + impressionViewableHandler: (args) => {}, + slotRenderEndedGPTHandler: (args) => {}, + bidRequestedHandler: (args) => {}, + bidRejectedHandler: (args) => {} + } + + global.window.atmtdAnalytics = obj; + + Object.keys(obj).forEach((fn) => sandbox.spy(global.window.atmtdAnalytics, fn)) + sandbox.stub(events, 'getEvents').returns([]); + sandbox.spy(exports, 'prettyLog') + exports.retryCount = 0; + exports.queuePointer = 0; + exports.__atmtdAnalyticsQueue = [ + [AUCTION_INIT, {type: AUCTION_INIT}], + [BID_RESPONSE, {type: BID_RESPONSE}], + [BID_REQUESTED, {type: BID_REQUESTED}], + [BID_REJECTED, {type: BID_REJECTED}], + [NO_BID, {type: NO_BID}], + [BID_WON, {type: BID_WON}], + [BIDDER_DONE, {type: BIDDER_DONE}], + [AUCTION_DEBUG, {type: AUCTION_DEBUG}], + [BID_TIMEOUT, {type: BID_TIMEOUT}], + ['slotRenderEnded', {type: 'slotRenderEnded'}], + ['impressionViewable', {type: 'impressionViewable'}] + ] + }); + after(() => { + sandbox.restore(); + spec.disableAnalytics(); + }) + + it('Should make calls to appropriate SDK event handlers', () => { + exports.processEvents() + expect(exports.prettyLog.getCall(0).args[0]).to.equal('status') + expect(exports.prettyLog.getCall(0).args[1]).to.equal(`Que has been inactive for a while. Adapter starting to process que now... Trial Count = 1`) + expect(exports.retryCount).to.equal(0) + expect(exports.prettyLog.callCount).to.equal(1) + expect(exports.queuePointer).to.equal(exports.__atmtdAnalyticsQueue.length) + expect(global.window.atmtdAnalytics.auctionInitHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.bidResponseHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.bidRejectedHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.bidRequestedHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.noBidHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.bidWonHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.auctionDebugHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.bidderTimeoutHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.bidderDoneHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.slotRenderEndedGPTHandler.calledOnce).to.equal(true) + expect(global.window.atmtdAnalytics.impressionViewableHandler.calledOnce).to.equal(true) + }) + }); + + describe('Prettylog fn tests', () => { + beforeEach(() => { + sandbox = sinon.createSandbox() + sandbox.spy(utils, 'logInfo') + sandbox.spy(utils, 'logError') + exports.isLoggingEnabled = true + }) + + afterEach(() => { + sandbox.restore() + }) + + it('Should call logMessage once in normal mode', () => { + exports.prettyLog('status', 'Hello world') + expect(utils.logInfo.callCount).to.equal(1) + }) + + it('Should call logMessage twice in group mode and have the cb called', () => { + const spy = sandbox.spy() + exports.prettyLog('status', 'Hello world', true, spy) + expect(utils.logInfo.callCount).to.equal(2) + expect(spy.called).to.equal(true) + }) + + it('Should call logMessage twice in group mode and have the cb which throws an error', () => { + const spy = sandbox.stub().throws() + exports.prettyLog('status', 'Hello world', true, spy) + expect(utils.logInfo.callCount).to.equal(2) + expect(utils.logError.called).to.equal(true) + }) + }); +}); diff --git a/test/spec/modules/automatadBidAdapter_spec.js b/test/spec/modules/automatadBidAdapter_spec.js index 4a15209822b..e7b68b739c7 100644 --- a/test/spec/modules/automatadBidAdapter_spec.js +++ b/test/spec/modules/automatadBidAdapter_spec.js @@ -5,7 +5,25 @@ import { newBidder } from 'src/adapters/bidderFactory.js' describe('automatadBidAdapter', function () { const adapter = newBidder(spec) - let bidRequest = { + let bidRequestRequiredParams = { + bidder: 'automatad', + params: {siteId: '123ad'}, + mediaTypes: { + banner: { + sizes: [[300, 600]], + } + }, + adUnitCode: 'some-ad-unit-code', + transactionId: '1465569e-52cc-4c36-88a1-7174cfef4b44', + sizes: [[300, 600]], + bidId: '123abc', + bidderRequestId: '3213887463c059', + auctionId: 'abc-123', + src: 'client', + bidRequestsCount: 1 + } + + let bidRequestAllParams = { bidder: 'automatad', params: {siteId: '123ad', placementId: '123abc345'}, mediaTypes: { @@ -59,10 +77,14 @@ describe('automatadBidAdapter', function () { }) describe('isBidRequestValid', function () { - let inValidBid = Object.assign({}, bidRequest) + let inValidBid = Object.assign({}, bidRequestRequiredParams) delete inValidBid.params it('should return true if all params present', function () { - expect(spec.isBidRequestValid(bidRequest)).to.equal(true) + expect(spec.isBidRequestValid(bidRequestAllParams)).to.equal(true) + }) + + it('should return true if only required params present', function() { + expect(spec.isBidRequestValid(bidRequestRequiredParams)).to.equal(true) }) it('should return false if any parameter missing', function () { @@ -71,9 +93,13 @@ describe('automatadBidAdapter', function () { }) describe('buildRequests', function () { - let req = spec.buildRequests([ bidRequest ], { refererInfo: { } }) + let req = spec.buildRequests([ bidRequestRequiredParams ], { refererInfo: { } }) let rdata + it('should have withCredentials option as true', function() { + expect(req.options.withCredentials).to.equal(true) + }) + it('should return request object', function () { expect(req).to.not.be.null }) @@ -87,9 +113,9 @@ describe('automatadBidAdapter', function () { expect(rdata.imp.length).to.equal(1) }) - it('should include placement', function () { + it('should include siteId', function () { let r = rdata.imp[0] - expect(r.placement !== null).to.be.true + expect(r.siteId !== null).to.be.true }) it('should include media types', function () { @@ -97,11 +123,6 @@ describe('automatadBidAdapter', function () { expect(r.media_types !== null).to.be.true }) - it('should include all publisher params', function () { - let r = rdata.imp[0] - expect(r.siteID !== null && r.placementID !== null).to.be.true - }) - it('should include adunit code', function () { let r = rdata.imp[0] expect(r.adUnitCode !== null).to.be.true diff --git a/test/spec/modules/axisBidAdapter_spec.js b/test/spec/modules/axisBidAdapter_spec.js new file mode 100644 index 00000000000..083f05f5c0a --- /dev/null +++ b/test/spec/modules/axisBidAdapter_spec.js @@ -0,0 +1,414 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/axisBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'axis' + +describe('AxisBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]], + pos: 1 + } + }, + params: { + integration: '000000', + token: '000000' + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60, + pos: 1 + } + }, + params: { + integration: '000000', + token: '000000' + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + integration: '000000', + token: '000000' + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + ortb2: { + site: { + cat: ['IAB24'] + } + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://prebid.axis-marketplace.com/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'iabCat', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.iabCat).to.have.lengthOf(1); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.integration).to.be.a('string'); + expect(placement.token).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + expect(placement.pos).to.be.within(0, 7); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + expect(placement.pos).to.be.within(0, 7); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.property('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + width: 300, + height: 250, + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta', 'width', 'height'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.property('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.property('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.axis-marketplace.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0') + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.axis-marketplace.com/image?pbjs=1&ccpa=1---&coppa=0') + }); + }); +}); diff --git a/test/spec/modules/axonixBidAdapter_spec.js b/test/spec/modules/axonixBidAdapter_spec.js index a952d527600..c1cc6d46fb2 100644 --- a/test/spec/modules/axonixBidAdapter_spec.js +++ b/test/spec/modules/axonixBidAdapter_spec.js @@ -65,7 +65,7 @@ describe('AxonixBidAdapter', function () { gdprApplies: true }, refererInfo: { - referer: 'https://www.prebid.org', + page: 'https://www.prebid.org', canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' } }; @@ -286,26 +286,6 @@ describe('AxonixBidAdapter', function () { }); }); - describe.skip('buildRequests: can handle native ad requests', function () { - it('creates ServerRequests pointing to the correct region and endpoint if it changes', function () { - // loop: - // set supply id - // set region/endpoint in ssp config - // call buildRequests, validate request (url, method, supply id) - expect.fail('Not implemented'); - }); - - it('creates ServerRequests pointing to default endpoint if missing', function () { - // no endpoint in config means default value openrtb.axonix.com - expect.fail('Not implemented'); - }); - - it('creates ServerRequests pointing to default region if missing', function () { - // no region in config means default value us-east-1 - expect.fail('Not implemented'); - }); - }); - describe('interpretResponse', function () { it('considers corner cases', function() { expect(spec.interpretResponse(null)).to.be.an('array').that.is.empty; @@ -331,13 +311,6 @@ describe('AxonixBidAdapter', function () { expect(response).to.be.an('array').that.is.not.empty; expect(response[0]).to.equal(VIDEO_RESPONSE.body[0]); }); - - it.skip('parses 1 native responses', function () { - // passing 1 valid native in a response generates an array with 1 correct prebid response - // examine mediaType:native, native element - // check nativeBidIsValid from {@link file://./../../../src/native.js} - expect.fail('Not implemented'); - }); }); describe('onBidWon', function () { diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index d9b8cac10b4..c0994985aae 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,7 +1,6 @@ import { expect } from 'chai'; import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter.js'; -import { config } from 'src/config.js'; -import { parseUrl, deepAccess } from 'src/utils.js'; +import { parseUrl } from 'src/utils.js'; describe('BeachfrontAdapter', function () { let bidRequests; @@ -129,7 +128,7 @@ describe('BeachfrontAdapter', function () { it('should attach the bid request object', function () { bidRequests[0].mediaTypes = { video: {} }; bidRequests[1].mediaTypes = { video: {} }; - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); expect(requests[0].bidRequest).to.equal(bidRequests[0]); expect(requests[1].bidRequest).to.equal(bidRequests[1]); }); @@ -137,7 +136,7 @@ describe('BeachfrontAdapter', function () { it('should create a POST request for each bid', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); expect(requests[0].method).to.equal('POST'); expect(requests[0].url).to.equal(VIDEO_ENDPOINT + bidRequest.params.appId); }); @@ -155,7 +154,7 @@ describe('BeachfrontAdapter', function () { const topLocation = parseUrl('http://www.example.com?foo=bar', { decodeSearchAsString: true }); const bidderRequest = { refererInfo: { - referer: topLocation.href + page: topLocation.href } }; const requests = spec.buildRequests([ bidRequest ], bidderRequest); @@ -176,7 +175,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; bidRequest.getFloor = () => ({ currency: 'USD', floor: 1.16 }); - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].bidfloor).to.equal(1.16); }); @@ -185,7 +184,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; bidRequest.getFloor = () => ({}); - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); }); @@ -199,7 +198,7 @@ describe('BeachfrontAdapter', function () { playerSize: [[ width, height ]] } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].video).to.deep.contain({ w: width, h: height }); }); @@ -213,7 +212,7 @@ describe('BeachfrontAdapter', function () { playerSize: `${width}x${height}` } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].video).to.deep.contain({ w: width, h: height }); }); @@ -225,7 +224,7 @@ describe('BeachfrontAdapter', function () { playerSize: [] } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].video).to.deep.contain({ w: undefined, h: undefined }); }); @@ -236,7 +235,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.sizes = [ width, height ]; bidRequest.mediaTypes = { video: {} }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].video).to.deep.contain({ w: width, h: height }); }); @@ -251,7 +250,7 @@ describe('BeachfrontAdapter', function () { bidRequest.mediaTypes = { video: { mimes, playbackmethod, maxduration, placement, skip } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement, skip }); }); @@ -265,7 +264,7 @@ describe('BeachfrontAdapter', function () { const skip = 1; bidRequest.mediaTypes = { video: { placement: 3, skip: 0 } }; bidRequest.params.video = { mimes, playbackmethod, maxduration, placement, skip }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement, skip }); }); @@ -296,6 +295,23 @@ describe('BeachfrontAdapter', function () { expect(data.user.ext.consent).to.equal(consentString); }); + it('must add GPP consent data to the request', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + const gppString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + const applicableSections = [1, 2, 3]; + const bidderRequest = { + gppConsent: { + gppString, + applicableSections + } + }; + const requests = spec.buildRequests([ bidRequest ], bidderRequest); + const data = requests[0].data; + expect(data.regs.gpp).to.equal(gppString); + expect(data.regs.gpp_sid).to.deep.equal(applicableSections); + }); + it('must add schain data to the request', () => { const schain = { ver: '1.0', @@ -312,7 +328,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; bidRequest.schain = schain; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.source.ext.schain).to.deep.equal(schain); }); @@ -322,12 +338,12 @@ describe('BeachfrontAdapter', function () { tdid: '54017816', idl_env: '13024996', uid2: { id: '45843401' }, - haloId: { haloId: '60314917', auSeg: ['segment1', 'segment2'] } + hadronId: { hadronId: '60314917', auSeg: ['segment1', 'segment2'] } }; const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; bidRequest.userId = userId; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.user.ext.eids).to.deep.equal([ { @@ -360,7 +376,7 @@ describe('BeachfrontAdapter', function () { { source: 'audigent.com', uids: [{ - id: userId.haloId, + id: userId.hadronId, atype: 1, }] } @@ -372,14 +388,14 @@ describe('BeachfrontAdapter', function () { it('should attach the bid requests array', function () { bidRequests[0].mediaTypes = { banner: {} }; bidRequests[1].mediaTypes = { banner: {} }; - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); expect(requests[0].bidRequest).to.deep.equal(bidRequests); }); it('should create a single POST request for all bids', function () { bidRequests[0].mediaTypes = { banner: {} }; bidRequests[1].mediaTypes = { banner: {} }; - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); expect(requests.length).to.equal(1); expect(requests[0].method).to.equal('POST'); expect(requests[0].url).to.equal(BANNER_ENDPOINT); @@ -398,7 +414,7 @@ describe('BeachfrontAdapter', function () { const topLocation = parseUrl('http://www.example.com?foo=bar', { decodeSearchAsString: true }); const bidderRequest = { refererInfo: { - referer: topLocation.href + page: topLocation.href } }; const requests = spec.buildRequests([ bidRequest ], bidderRequest); @@ -422,7 +438,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; bidRequest.getFloor = () => ({ currency: 'USD', floor: 1.16 }); - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.slots[0].bidfloor).to.equal(1.16); }); @@ -431,7 +447,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; bidRequest.getFloor = () => ({}); - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.slots[0].bidfloor).to.equal(bidRequest.params.bidfloor); }); @@ -445,7 +461,7 @@ describe('BeachfrontAdapter', function () { sizes: [[ width, height ]] } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.slots[0].sizes).to.deep.equal([ { w: width, h: height } @@ -461,7 +477,7 @@ describe('BeachfrontAdapter', function () { sizes: `${width}x${height}` } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.slots[0].sizes).to.deep.equal([ { w: width, h: height } @@ -475,7 +491,7 @@ describe('BeachfrontAdapter', function () { sizes: [] } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.slots[0].sizes).to.deep.equal([]); }); @@ -486,7 +502,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.sizes = [ width, height ]; bidRequest.mediaTypes = { banner: {} }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.slots[0].sizes).to.deep.contain({ w: width, h: height }); }); @@ -517,6 +533,23 @@ describe('BeachfrontAdapter', function () { expect(data.gdprConsent).to.equal(consentString); }); + it('must add GPP consent data to the request', function () { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + const gppString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + const applicableSections = [1, 2, 3]; + const bidderRequest = { + gppConsent: { + gppString, + applicableSections + } + }; + const requests = spec.buildRequests([ bidRequest ], bidderRequest); + const data = requests[0].data; + expect(data.gpp).to.equal(gppString); + expect(data.gppSid).to.deep.equal(applicableSections); + }); + it('must add schain data to the request', () => { const schain = { ver: '1.0', @@ -533,7 +566,7 @@ describe('BeachfrontAdapter', function () { const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; bidRequest.schain = schain; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.schain).to.deep.equal(schain); }); @@ -543,51 +576,38 @@ describe('BeachfrontAdapter', function () { tdid: '54017816', idl_env: '13024996', uid2: { id: '45843401' }, - haloId: { haloId: '60314917', auSeg: ['segment1', 'segment2'] } + hadronId: { hadronId: '60314917', auSeg: ['segment1', 'segment2'] } }; const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; bidRequest.userId = userId; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); const data = requests[0].data; expect(data.tdid).to.equal(userId.tdid); expect(data.idl).to.equal(userId.idl_env); expect(data.uid2).to.equal(userId.uid2.id); - expect(data.haloid).to.equal(userId.haloId); + expect(data.hadronid).to.equal(userId.hadronId); }); }); describe('with first-party data', function () { - let sandbox - - beforeEach(function () { - sandbox = sinon.sandbox.create(); - }); - - afterEach(function () { - sandbox.restore(); - }); - it('must add first-party data to the video bid request', function () { - sandbox.stub(config, 'getConfig').callsFake(key => { - const cfg = { - ortb2: { - site: { - keywords: 'test keyword' - }, - user: { - data: 'some user data' - } - } - }; - return deepAccess(cfg, key); - }); + const ortb2 = { + site: { + keywords: 'test keyword' + }, + user: { + data: 'some user data' + } + }; + const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { video: {} }; const bidderRequest = { refererInfo: { - referer: 'http://example.com/page.html' - } + page: 'http://example.com/page.html' + }, + ortb2 }; const requests = spec.buildRequests([ bidRequest ], bidderRequest); const data = requests[0].data; @@ -598,22 +618,17 @@ describe('BeachfrontAdapter', function () { }); it('must add first-party data to the banner bid request', function () { - sandbox.stub(config, 'getConfig').callsFake(key => { - const cfg = { - ortb2: { - site: { - keywords: 'test keyword' - }, - user: { - data: 'some user data' - } - } - }; - return deepAccess(cfg, key); - }); + const ortb2 = { + site: { + keywords: 'test keyword' + }, + user: { + data: 'some user data' + } + }; const bidRequest = bidRequests[0]; bidRequest.mediaTypes = { banner: {} }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {ortb2}); const data = requests[0].data; expect(data.ortb2.user.data).to.equal('some user data'); expect(data.ortb2.site.keywords).to.equal('test keyword'); @@ -643,7 +658,7 @@ describe('BeachfrontAdapter', function () { appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3' } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); expect(requests.length).to.equal(2); expect(requests[0].url).to.contain(VIDEO_ENDPOINT); expect(requests[1].url).to.contain(BANNER_ENDPOINT); @@ -669,7 +684,7 @@ describe('BeachfrontAdapter', function () { appId: '3b16770b-17af-4d22-daff-9606bdf2c9c3' } }; - const requests = spec.buildRequests([ bidRequest ]); + const requests = spec.buildRequests([ bidRequest ], {}); expect(requests[0].data.imp[0].video).to.deep.contain({ w: 640, h: 360 }); expect(requests[1].data.slots[0].sizes).to.deep.equal([{ w: 300, h: 250 }]); }); @@ -713,7 +728,6 @@ describe('BeachfrontAdapter', function () { const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); expect(bidResponse).to.deep.equal({ requestId: bidRequest.bidId, - bidderCode: spec.code, cpm: serverResponse.bidPrice, creativeId: serverResponse.crid, vastUrl: serverResponse.url, diff --git a/test/spec/modules/bedigitechBidAdapter_spec.js b/test/spec/modules/bedigitechBidAdapter_spec.js new file mode 100644 index 00000000000..20d4e86e0c4 --- /dev/null +++ b/test/spec/modules/bedigitechBidAdapter_spec.js @@ -0,0 +1,134 @@ +import { expect } from 'chai'; +import { spec } from 'modules/bedigitechBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import {BANNER} from 'src/mediaTypes.js'; + +describe('BedigitechAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + bidder: 'bedigitech', + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + placementId: 309, + }, + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + const bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'masterId': 0 + }; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + bidder: 'bedigitech', + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + placementId: 309, + }, + }]; + + it('sends bid request to url via GET', function () { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://bid.bedigitech.com/bid/pub_bid.php'); + }); + + it('should attach pid to url', function () { + const request = spec.buildRequests(bidRequests)[0]; + expect(request.data.pid).to.equal(309); + }); + }); + + describe('interpretResponse', function () { + const response = { + 'body': [ + { + 'ad': '%3C!--%20Creative%20--%3E', + 'cpm': '5.0', + 'crid': '0af345b42983cc4bc0', + 'currency': 'USD', + 'height': 250, + 'id': 'bedigitechMyidfdfdf', + 'netRevenue': true, + 'requestTime': 1686306237, + 'timeToRespond': 300, + 'ttl': 300, + 'width': 300 + } + ], + 'headers': { + 'get': function() {} + } + }; + + it('should get correct bid responseiiiiii', function () { + const expectedResponse = [ + { + 'ad': '%3C!--%20Creative%20--%3E', + 'cpm': '5.0', + 'creativeId': '0af345b42983cc4bc0', + 'currency': 'USD', + 'height': 250, + 'id': 'bedigitechMyidfdfdf', + 'meta': { + 'mediaType': BANNER, + }, + 'netRevenue': true, + 'requestId': 'bedigitechMyidfdfdf', + 'requestTimestamp': 1686306237, + 'timeToRespond': 300, + 'ttl': 300, + 'width': 300, + 'bidderCode': 'bedigitech', + } + ]; + const result = spec.interpretResponse(response); + expect(result).to.have.lengthOf(1); + let resultKeys = Object.keys(result[0]); + expect(resultKeys.sort()).to.deep.equal(Object.keys(expectedResponse[0]).sort()); + resultKeys.forEach(function(k) { + if (k === 'ad') { + expect(result[0][k]).to.match(/$/); + } else if (k === 'meta') { + expect(result[0][k]).to.deep.equal(expectedResponse[0][k]); + } else { + expect(result[0][k]).to.equal(expectedResponse[0][k]); + } + }); + }); + }); +}); diff --git a/test/spec/modules/beopBidAdapter_spec.js b/test/spec/modules/beopBidAdapter_spec.js index 832ad2707d3..c77e304e539 100644 --- a/test/spec/modules/beopBidAdapter_spec.js +++ b/test/spec/modules/beopBidAdapter_spec.js @@ -99,6 +99,8 @@ describe('BeOp Bid Adapter tests', () => { expect(url).to.equal(ENDPOINT); expect(payload.pid).to.exist; expect(payload.pid).to.equal('5a8af500c9e77c00017e4cad'); + expect(payload.gdpr_applies).to.exist; + expect(payload.gdpr_applies).to.equals(false); expect(payload.slts[0].name).to.exist; expect(payload.slts[0].name).to.equal('bellow-article'); expect(payload.slts[0].flr).to.equal(10); @@ -115,16 +117,71 @@ describe('BeOp Bid Adapter tests', () => { }, 'refererInfo': { - 'canonicalUrl': 'http://test.te' + 'canonicalUrl': 'test.te' } }; const request = spec.buildRequests(bidRequests, bidderRequest); const payload = JSON.parse(request.data); + expect(payload.gdpr_applies).to.exist; + expect(payload.gdpr_applies).to.equals(true); expect(payload.tc_string).to.exist; expect(payload.tc_string).to.equal('BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='); expect(payload.url).to.exist; - expect(payload.url).to.equal('http://localhost:9876/context.html'); + // check that the protocol is added correctly + expect(payload.url).to.equal('http://test.te'); + }); + + it('should call the endpoint with psegs and bpsegs (stringified) data if any or [] if none', function () { + let bidderRequest = + { + 'ortb2': { + 'user': { + 'ext': { + 'bpsegs': ['axed', 'axec', 1234], + 'data': { + 'permutive': [1234, 5678, 910] + } + } + } + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.psegs).to.exist; + expect(payload.psegs).to.include(1234); + expect(payload.psegs).to.include(5678); + expect(payload.psegs).to.include(910); + expect(payload.psegs).to.not.include(1); + expect(payload.bpsegs).to.exist; + expect(payload.bpsegs).to.include('axed'); + expect(payload.bpsegs).to.include('axec'); + expect(payload.bpsegs).to.include('1234'); + + let bidderRequest2 = + { + 'ortb2': {} + }; + + const request2 = spec.buildRequests(bidRequests, bidderRequest2); + const payload2 = JSON.parse(request2.data); + expect(payload2.psegs).to.exist; + expect(payload2.psegs).to.be.empty; + expect(payload2.bpsegs).to.exist; + expect(payload2.bpsegs).to.be.empty; + }); + + it('should not prepend the protocol in page url if already present', function () { + const bidderRequest = { + 'refererInfo': { + 'canonicalUrl': 'https://test.te' + } + }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.url).to.exist; + expect(payload.url).to.equal('https://test.te'); }); }); @@ -191,5 +248,68 @@ describe('BeOp Bid Adapter tests', () => { expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ac=won'); expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('pid=5a8af500c9e77c00017e4cad'); }); + it('should call triggerPixel utils function on bid won and work even if params is an array', function () { + spec.onBidWon({}); + spec.onBidWon(); + expect(triggerPixelStub.getCall(0)).to.be.null; + spec.onBidWon({params: [{accountId: '5a8af500c9e77c00017e4cad'}], cpm: 1.2}); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('https://t.beop.io'); + expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ca=bid'); + expect(triggerPixelStub.getCall(0).args[0]).to.include('se_ac=won'); + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('pid=5a8af500c9e77c00017e4cad'); + }); }); + + describe('Ensure keywords is always array of string', function () { + let bidRequests = []; + afterEach(function () { + bidRequests = []; + }); + + it('should work with keywords as an array', function () { + let bid = Object.assign({}, validBid); + bid.params.keywords = ['a', 'b']; + bidRequests.push(bid); + config.setConfig({ + currency: { adServerCurrency: 'USD' } + }); + const request = spec.buildRequests(bidRequests, {}); + const payload = JSON.parse(request.data); + const url = request.url; + expect(payload.kwds).to.exist; + expect(payload.kwds).to.include('a'); + expect(payload.kwds).to.include('b'); + }); + + it('should work with keywords as a string', function () { + let bid = Object.assign({}, validBid); + bid.params.keywords = 'list of keywords'; + bidRequests.push(bid); + config.setConfig({ + currency: { adServerCurrency: 'USD' } + }); + const request = spec.buildRequests(bidRequests, {}); + const payload = JSON.parse(request.data); + const url = request.url; + expect(payload.kwds).to.exist; + expect(payload.kwds).to.include('list of keywords'); + }); + + it('should work with keywords as a string containing a comma', function () { + let bid = Object.assign({}, validBid); + bid.params.keywords = 'list, of, keywords'; + bidRequests.push(bid); + config.setConfig({ + currency: { adServerCurrency: 'USD' } + }); + const request = spec.buildRequests(bidRequests, {}); + const payload = JSON.parse(request.data); + const url = request.url; + expect(payload.kwds).to.exist; + expect(payload.kwds).to.include('list'); + expect(payload.kwds).to.include('of'); + expect(payload.kwds).to.include('keywords'); + }) + }) }); diff --git a/test/spec/modules/betweenBidAdapter_spec.js b/test/spec/modules/betweenBidAdapter_spec.js index 3baa92e35d5..a4b89ab1b65 100644 --- a/test/spec/modules/betweenBidAdapter_spec.js +++ b/test/spec/modules/betweenBidAdapter_spec.js @@ -85,6 +85,23 @@ describe('betweenBidAdapterTests', function () { expect(req_data.cur).to.equal('THX'); }); + it('validate default cur USD', function() { + let bidRequestData = [{ + bidId: 'bid1234', + bidder: 'between', + params: { + w: 240, + h: 400, + s: 1112 + }, + sizes: [[240, 400]] + }]; + + let request = spec.buildRequests(bidRequestData); + let req_data = JSON.parse(request.data)[0].data; + + expect(req_data.cur).to.equal('USD'); + }); it('validate subid param', function() { let bidRequestData = [{ bidId: 'bid1234', diff --git a/test/spec/modules/beyondmediaBidAdapter_spec.js b/test/spec/modules/beyondmediaBidAdapter_spec.js new file mode 100644 index 00000000000..751b3ae1098 --- /dev/null +++ b/test/spec/modules/beyondmediaBidAdapter_spec.js @@ -0,0 +1,401 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/beyondmediaBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'beyondmedia' + +describe('AndBeyondMediaBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + expect(spec.isBidRequestValid(bids[1])).to.be.true; + expect(spec.isBidRequestValid(bids[2])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://backend.andbeyond.media/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cookies.andbeyond.media/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0') + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cookies.andbeyond.media/image?pbjs=1&ccpa_consent=1---&coppa=0') + }); + }); +}); diff --git a/test/spec/modules/bidViewability_spec.js b/test/spec/modules/bidViewability_spec.js index a822d86f852..2d2e51abbe1 100644 --- a/test/spec/modules/bidViewability_spec.js +++ b/test/spec/modules/bidViewability_spec.js @@ -245,18 +245,31 @@ describe('#bidViewability', function() { let logWinningBidNotFoundSpy; let callBidViewableBidderSpy; let winningBidsArray; + let callBidBillableBidderSpy; + let adUnits = [ + { + 'code': 'abc123', + 'bids': [ + { + 'bidder': 'pubmatic' + } + ] + } + ]; beforeEach(function() { sandbox = sinon.sandbox.create(); triggerPixelSpy = sandbox.spy(utils, ['triggerPixel']); eventsEmitSpy = sandbox.spy(events, ['emit']); callBidViewableBidderSpy = sandbox.spy(adapterManager, ['callBidViewableBidder']); + callBidBillableBidderSpy = sandbox.spy(adapterManager, ['callBidBillableBidder']); // mocking winningBidsArray winningBidsArray = []; sandbox.stub(prebidGlobal, 'getGlobal').returns({ getAllWinningBids: function (number) { return winningBidsArray; - } + }, + adUnits }); }); @@ -293,5 +306,23 @@ describe('#bidViewability', function() { // CONSTANTS.EVENTS.BID_VIEWABLE is NOT triggered expect(eventsEmitSpy.callCount).to.equal(0); }); + + it('should call the callBidBillableBidder function if the viewable bid is associated with an ad unit with deferBilling set to true', function() { + let moduleConfig = {}; + const deferredBillingAdUnit = { + 'code': '/harshad/Jan/2021/', + 'deferBilling': true, + 'bids': [ + { + 'bidder': 'pubmatic' + } + ] + }; + adUnits.push(deferredBillingAdUnit); + winningBidsArray.push(PBJS_WINNING_BID); + bidViewability.impressionViewableHandler(moduleConfig, GPT_SLOT, null); + expect(callBidBillableBidderSpy.callCount).to.equal(1); + sinon.assert.calledWith(callBidBillableBidderSpy, PBJS_WINNING_BID); + }); }); }); diff --git a/test/spec/modules/bidwatchAnalyticsAdapter_spec.js b/test/spec/modules/bidwatchAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..be1ffb06c76 --- /dev/null +++ b/test/spec/modules/bidwatchAnalyticsAdapter_spec.js @@ -0,0 +1,342 @@ +import bidwatchAnalytics from 'modules/bidwatchAnalyticsAdapter.js'; +import {dereferenceWithoutRenderer} from 'modules/bidwatchAnalyticsAdapter.js'; +import { expect } from 'chai'; +import { server } from 'test/mocks/xhr.js'; +let adapterManager = require('src/adapterManager').default; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('BidWatch Analytics', function () { + let timestamp = new Date() - 256; + let auctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; + let timeout = 1500; + + let bidTimeout = [ + { + 'bidId': '5fe418f2d70364', + 'bidder': 'appnexusAst', + 'adUnitCode': 'tag_200124_banner', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b' + } + ]; + + const auctionEnd = { + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'timestamp': 1647424261187, + 'auctionEnd': 1647424261714, + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': 'tag_200124_banner', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 123456 + } + }, + { + 'bidder': 'appnexusAst', + 'params': { + 'placementId': 234567 + } + } + ], + 'sizes': [ + [ + 300, + 600 + ] + ], + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40' + } + ], + 'adUnitCodes': [ + 'tag_200124_banner' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'bidderRequestId': '11dc6ff6378de7', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 123456 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'tag_200124_banner', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40', + 'sizes': [ + [ + 300, + 600 + ] + ], + 'bidId': '34a63e5d5378a3', + 'bidderRequestId': '11dc6ff6378de7', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1647424261187, + 'timeout': 1000, + 'gdprConsent': { + 'consentString': 'CONSENT', + 'gdprApplies': true, + 'apiVersion': 2, + 'vendorData': 'a lot of borring stuff', + }, + 'start': 1647424261189 + }, + ], + 'noBids': [ + { + 'bidder': 'appnexusAst', + 'params': { + 'placementId': 10471298 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'tag_200124_banner', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40', + 'sizes': [ + [ + 300, + 600 + ] + ], + 'bidId': '5fe418f2d70364', + 'bidderRequestId': '4229a45ab8ea87', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'bidsReceived': [ + { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 600, + 'statusMessage': 'Bid available', + 'adId': '7a4ced80f33d33', + 'requestId': '34a63e5d5378a3', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'mediaType': 'video', + 'source': 'client', + 'cpm': 27.4276, + 'creativeId': '158534630', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 2000, + 'ad': 'some html', + 'meta': { + 'advertiserDomains': [ + 'example.com' + ] + }, + 'renderer': 'something', + 'originalCpm': 25.02521, + 'originalCurrency': 'EUR', + 'responseTimestamp': 1647424261559, + 'requestTimestamp': 1647424261189, + 'bidder': 'appnexus', + 'adUnitCode': 'tag_200124_banner', + 'timeToRespond': 370, + 'pbLg': '5.00', + 'pbMg': '20.00', + 'pbHg': '20.00', + 'pbAg': '20.00', + 'pbDg': '20.00', + 'pbCg': '20.000000', + 'size': '300x600', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '7a4ced80f33d33', + 'hb_pb': '20.000000', + 'hb_size': '300x600', + 'hb_source': 'client', + 'hb_format': 'banner', + 'hb_adomain': 'example.com' + } + } + ], + 'winningBids': [ + + ], + 'timeout': 1000 + }; + + let bidWon = { + 'bidderCode': 'appnexus', + 'width': 970, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '65d16ef039a97a', + 'requestId': '2bd3e8ff8a113f', + 'transactionId': '8b2a8629-d1ea-4bb1-aff0-e335b96dd002', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 27.4276, + 'creativeId': '158533702', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 2000, + 'ad': 'some html', + 'meta': { + 'advertiserDomains': [ + 'example.com' + ] + }, + 'renderer': 'something', + 'originalCpm': 25.02521, + 'originalCurrency': 'EUR', + 'responseTimestamp': 1647424261558, + 'requestTimestamp': 1647424261189, + 'bidder': 'appnexus', + 'adUnitCode': 'tag_200123_banner', + 'timeToRespond': 369, + 'originalBidder': 'appnexus', + 'pbLg': '5.00', + 'pbMg': '20.00', + 'pbHg': '20.00', + 'pbAg': '20.00', + 'pbDg': '20.00', + 'pbCg': '20.000000', + 'size': '970x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '65d16ef039a97a', + 'hb_pb': '20.000000', + 'hb_size': '970x250', + 'hb_source': 'client', + 'hb_format': 'banner', + 'hb_adomain': 'example.com' + }, + 'status': 'rendered', + 'params': [ + { + 'placementId': 123456 + } + ] + }; + + after(function () { + bidwatchAnalytics.disableAnalytics(); + }); + + describe('main test flow', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + sinon.spy(bidwatchAnalytics, 'track'); + }); + afterEach(function () { + events.getEvents.restore(); + bidwatchAnalytics.disableAnalytics(); + bidwatchAnalytics.track.restore(); + }); + it('test dereferenceWithoutRenderer', function () { + adapterManager.registerAnalyticsAdapter({ + code: 'bidwatch', + adapter: bidwatchAnalytics + }); + + adapterManager.enableAnalytics({ + provider: 'bidwatch', + options: { + domain: 'test' + } + }); + let resultBidWon = JSON.parse(dereferenceWithoutRenderer(bidWon)); + expect(resultBidWon).not.to.have.property('renderer'); + let resultBid = JSON.parse(dereferenceWithoutRenderer(auctionEnd)); + expect(resultBid).to.have.property('bidsReceived').and.to.have.lengthOf(1); + expect(resultBid.bidsReceived[0]).not.to.have.property('renderer'); + }); + it('test auctionEnd', function () { + adapterManager.registerAnalyticsAdapter({ + code: 'bidwatch', + adapter: bidwatchAnalytics + }); + + adapterManager.enableAnalytics({ + provider: 'bidwatch', + options: { + domain: 'test' + } + }); + + events.emit(constants.EVENTS.BID_REQUESTED, auctionEnd['bidderRequests'][0]); + events.emit(constants.EVENTS.BID_RESPONSE, auctionEnd['bidsReceived'][0]); + events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); + events.emit(constants.EVENTS.AUCTION_END, auctionEnd); + expect(server.requests.length).to.equal(1); + let message = JSON.parse(server.requests[0].requestBody); + expect(message).to.have.property('auctionEnd').exist; + expect(message.auctionEnd).to.have.lengthOf(1); + expect(message.auctionEnd[0]).to.have.property('bidsReceived').and.to.have.lengthOf(1); + expect(message.auctionEnd[0].bidsReceived[0]).not.to.have.property('ad'); + expect(message.auctionEnd[0].bidsReceived[0]).to.have.property('meta'); + expect(message.auctionEnd[0].bidsReceived[0].meta).to.have.property('advertiserDomains'); + expect(message.auctionEnd[0].bidsReceived[0]).to.have.property('adId'); + expect(message.auctionEnd[0]).to.have.property('bidderRequests').and.to.have.lengthOf(1); + expect(message.auctionEnd[0].bidderRequests[0]).to.have.property('gdprConsent'); + expect(message.auctionEnd[0].bidderRequests[0].gdprConsent).not.to.have.property('vendorData'); + }); + + it('test bidWon', function() { + adapterManager.registerAnalyticsAdapter({ + code: 'bidwatch', + adapter: bidwatchAnalytics + }); + + adapterManager.enableAnalytics({ + provider: 'bidwatch', + options: { + domain: 'test' + } + }); + events.emit(constants.EVENTS.BID_WON, bidWon); + expect(server.requests.length).to.equal(1); + let message = JSON.parse(server.requests[0].requestBody); + expect(message).not.to.have.property('ad'); + expect(message).to.have.property('adId') + expect(message).to.have.property('cpmIncrement').and.to.equal(27.4276); + }); + }); +}); diff --git a/test/spec/modules/big-richmediaBidAdapter_spec.js b/test/spec/modules/big-richmediaBidAdapter_spec.js index 1e97e1ac1d7..c3a9a8ef6c1 100644 --- a/test/spec/modules/big-richmediaBidAdapter_spec.js +++ b/test/spec/modules/big-richmediaBidAdapter_spec.js @@ -92,53 +92,45 @@ describe('bigRichMediaAdapterTests', function () { expect(payload.tags[0].sizes).to.have.lengthOf(3); }); - it('should build video bid request', function() { - const bidRequest = deepClone(bidRequests[0]); - bidRequest.params = { - placementId: '1234235', - video: { - skippable: true, - playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'], - context: 'outstream', - format: 'sticky-top' - } - }; - bidRequest.mediaTypes = { - video: { - playerSize: [640, 480], - context: 'outstream', - mimes: ['video/mp4'], - skip: 0, - minduration: 5, - api: [1, 5, 6], - playbackmethod: [2, 4] - } - }; + if (FEATURES.VIDEO) { + it('should build video bid request', function() { + const bidRequest = deepClone(bidRequests[0]); + bidRequest.params = { + placementId: '1234235', + video: { + skippable: true, + playback_method: ['auto_play_sound_off', 'auto_play_sound_unknown'], + context: 'outstream', + format: 'sticky-top' + } + }; + bidRequest.mediaTypes = { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'], + skip: 0, + minduration: 5, + api: [1, 5, 6], + playbackmethod: [2, 4] + } + }; - const request = spec.buildRequests([bidRequest]); - const payload = JSON.parse(request.data); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); - expect(payload.tags[0].video).to.deep.equal({ - minduration: 5, - playback_method: 2, - skippable: true, - context: 4 + expect(payload.tags[0].video).to.deep.equal({ + minduration: 5, + playback_method: 2, + skippable: true, + context: 4 + }); + expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4]) }); - expect(payload.tags[0].video_frameworks).to.deep.equal([1, 4]) - }); + } }); describe('interpretResponse', function () { - let bfStub; - - before(function() { - bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); - }); - - after(function() { - bfStub.restore(); - }); - const response = { 'version': '3.0.0', 'tags': [ @@ -190,6 +182,7 @@ describe('bigRichMediaAdapterTests', function () { it('should get correct bid response', function () { const expectedResponse = [ { + 'adId': '3a1f23123e', 'requestId': '3db3773286ee59', 'cpm': 0.5, 'creativeId': 29681110, @@ -226,42 +219,44 @@ describe('bigRichMediaAdapterTests', function () { expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); }); - it('handles outstream video responses', function () { - const response = { - 'tags': [{ - 'uuid': '84ab500420319d', - 'ads': [{ - 'ad_type': 'video', - 'cpm': 0.500000, - 'notify_url': 'imptracker.com', - 'rtb': { - 'video': { - 'content': '' - } - }, - 'javascriptTrackers': '' + if (FEATURES.VIDEO) { + it('handles outstream video responses', function () { + const response = { + 'tags': [{ + 'uuid': '84ab500420319d', + 'ads': [{ + 'ad_type': 'video', + 'cpm': 0.500000, + 'notify_url': 'imptracker.com', + 'rtb': { + 'video': { + 'content': '' + } + }, + 'javascriptTrackers': '' + }] }] - }] - }; - const bidderRequest = { - bids: [{ - bidId: '84ab500420319d', - adUnitCode: 'code', - mediaTypes: { - video: { - context: 'outstream' + }; + const bidderRequest = { + bids: [{ + bidId: '84ab500420319d', + adUnitCode: 'code', + mediaTypes: { + video: { + context: 'outstream' + } } - } - }] - } + }] + } - const result = spec.interpretResponse({ body: response }, {bidderRequest}); - expect(result[0]).not.to.have.property('vastXml'); - expect(result[0]).not.to.have.property('vastUrl'); - expect(result[0]).to.have.property('width', 1); - expect(result[0]).to.have.property('height', 1); - expect(result[0]).to.have.property('mediaType', 'banner'); - }); + const result = spec.interpretResponse({ body: response }, {bidderRequest}); + expect(result[0]).not.to.have.property('vastXml'); + expect(result[0]).not.to.have.property('vastUrl'); + expect(result[0]).to.have.property('width', 1); + expect(result[0]).to.have.property('height', 1); + expect(result[0]).to.have.property('mediaType', 'banner'); + }); + } }); describe('getUserSyncs', function() { diff --git a/test/spec/modules/bliinkBidAdapter_spec.js b/test/spec/modules/bliinkBidAdapter_spec.js index 729605f7db8..d0320ab6ec1 100644 --- a/test/spec/modules/bliinkBidAdapter_spec.js +++ b/test/spec/modules/bliinkBidAdapter_spec.js @@ -1,5 +1,14 @@ -import { expect } from 'chai' -import { spec, buildBid, BLIINK_ENDPOINT_ENGINE, parseXML, getMetaList } from 'modules/bliinkBidAdapter.js' +import { expect } from 'chai'; +import { + spec, + buildBid, + BLIINK_ENDPOINT_ENGINE, + getMetaList, + BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME, + getEffectiveConnectionType, + getUserIds, +} from 'modules/bliinkBidAdapter.js'; +import { config } from 'src/config.js'; /** * @description Mockup bidRequest @@ -20,6 +29,8 @@ import { spec, buildBid, BLIINK_ENDPOINT_ENGINE, parseXML, getMetaList } from 'm * crumbs: {pubcid: string}, * ortb2Imp: {ext: {data: {pbadslot: string}}}}} */ + +const connectionType = getEffectiveConnectionType(); const getConfigBid = (placement) => { return { adUnitCode: '/19968336/test', @@ -31,33 +42,76 @@ const getConfigBid = (placement) => { bidderRequestsCount: 1, bidderWinsCount: 0, crumbs: { - pubcid: '55ffadc5-051f-428d-8ecc-dc585e0bde0d' + pubcid: '55ffadc5-051f-428d-8ecc-dc585e0bde0d', }, + sizes: [[300, 250]], mediaTypes: { banner: { - sizes: [ - [300, 250] - ] - } + sizes: [[300, 250]], + }, }, ortb2Imp: { ext: { data: { - pbadslot: '/19968336/test' - } - } + pbadslot: '/19968336/test', + }, + }, }, + ect: connectionType, params: { placement: placement, - tagId: '14f30eca-85d2-11e8-9eed-0242ac120007' + tagId: '14f30eca-85d2-11e8-9eed-0242ac120007', + videoUrl: 'https://www.example.com/advideo.mp4', + imageUrl: 'https://www.example.com/adimage.jpg', }, - sizes: [ - [300, 250] - ], src: 'client', - transactionId: 'cc6678c4-9746-4082-b9e2-d8065d078ebf' - } -} + transactionId: 'cc6678c4-9746-4082-b9e2-d8065d078ebf', + }; +}; +const getConfigBannerBid = () => { + return { + creative: { + banner: { + adm: '', + height: 250, + width: 300, + }, + media_type: 'banner', + creativeId: 125, + }, + price: 1, + id: '810', + token: 'token', + mode: 'rtb', + extras: { + deal_id: '34567erty', + transaction_id: '2def0c5b2a7f6e', + }, + currency: 'EUR', + }; +}; +const getConfigVideoBid = () => { + return { + creative: { + video: { + content: '', + height: 250, + width: 300, + }, + media_type: 'video', + creativeId: 0, + }, + price: 1, + id: '8121', + token: 'token', + mode: 'rtb', + extras: { + deal_id: '34567ertyRTY', + transaction_id: '2def0c5b2a7f6e', + }, + currency: 'EUR', + }; +}; /** * @description Mockup response from engine.bliink.io/xxxx @@ -76,39 +130,36 @@ const getConfigBid = (placement) => { * } * } * } -* } + * } */ const getConfigCreative = () => { return { - ad_id: 5648, - price: 1, + ad: '', + mediaType: 'banner', + cpm: 4, currency: 'EUR', - media_type: 'banner', - category: 1, - id: 2825, - creativeId: 2825, - type: 1, - viewability_duration: 1, - viewability_percent_in_view: 30, - content: { - creative: { - adm: '', - } - } - } -} + creativeId: '34567erty', + width: 300, + height: 250, + ttl: 300, + netRevenue: true, + }; +}; -const getConfigCreativeVideo = () => { +const getConfigCreativeVideo = (isNoVast) => { return { - ad_id: 5648, - price: 1, + mediaType: 'video', + vastXml: isNoVast ? '' : '', + cpm: 0, currency: 'EUR', - media_type: 'video', - category: 1, - creativeId: 2825, - content: '' - } -} + creativeId: '34567ertyaza', + requestId: '6a204ce130280d', + width: 300, + height: 250, + ttl: 300, + netRevenue: true, + }; +}; /** * @description Mockup BuildRequest function @@ -124,21 +175,21 @@ const getConfigBuildRequest = (placement) => { isAmp: false, numIframes: 0, reachedTop: true, - referer: 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + page: 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', }, - } + }; if (!placement) { - return buildRequest + return buildRequest; } return Object.assign(buildRequest, { params: { bids: [getConfigBid(placement)], - placement: placement + placement: placement, }, - }) -} + }); +}; /** * @description Mockup response from API @@ -149,49 +200,84 @@ const getConfigInterpretResponse = (noAd = false) => { if (noAd) { return { message: 'invalid tag', - mode: 'no-ad' - } + mode: 'no-ad', + }; } return { body: { - creative: getConfigCreative(), + ...getConfigCreative(), mode: 'ad', - token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjgxNzA4MzEsImlhdCI6MTYyNzU2NjAzMSwiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6IjM1YmU1NDNjLTNkZTQtNGQ1Yy04N2NjLWIzYzEyOGZiYzU0MCIsIm5ldHdvcmtJZCI6MjEsInNpdGVJZCI6NTksInRhZ0lkIjo1OSwiY29va2llSWQiOiJjNGU4MWVhOS1jMjhmLTQwZDItODY1ZC1hNjQzZjE1OTcyZjUiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwiaXAiOiI3OC4xMjIuNzUuNzIiLCJ0aW1lIjoxNjI3NTY2MDMxLCJsb2NhdGlvbiI6eyJsYXRpdHVkZSI6NDguOTczOSwibG9uZ2l0dWRlIjozLjMxMTMsInJlZ2lvbiI6IkhERiIsImNvdW50cnkiOiJGUiIsImNpdHkiOiJTYXVsY2hlcnkiLCJ6aXBDb2RlIjoiMDIzMTAiLCJkZXBhcnRtZW50IjoiMDIifSwiY2l0eSI6IlNhdWxjaGVyeSIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTEuMC40NDcyLjEyNCBTYWZhcmkvNTM3LjM2In0sImdkcHIiOnsiaGFzQ29uc2VudCI6dHJ1ZX0sIndpbiI6ZmFsc2UsImFkSWQiOjU2NDgsImFkdmVydGlzZXJJZCI6MSwiY2FtcGFpZ25JZCI6MSwiY3JlYXRpdmVJZCI6MjgyNSwiZXJyb3IiOmZhbHNlfX0.-UefQH4G0k-RJGemBYffs-KL7EEwma2Wuwgk2xnpij8' + transactionId: '2def0c5b2a7f6e', + token: + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjgxNzA4MzEsImlhdCI6MTYyNzU2NjAzMSwiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6IjM1YmU1NDNjLTNkZTQtNGQ1Yy04N2NjLWIzYzEyOGZiYzU0MCIsIm5ldHdvcmtJZCI6MjEsInNpdGVJZCI6NTksInRhZ0lkIjo1OSwiY29va2llSWQiOiJjNGU4MWVhOS1jMjhmLTQwZDItODY1ZC1hNjQzZjE1OTcyZjUiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwiaXAiOiI3OC4xMjIuNzUuNzIiLCJ0aW1lIjoxNjI3NTY2MDMxLCJsb2NhdGlvbiI6eyJsYXRpdHVkZSI6NDguOTczOSwibG9uZ2l0dWRlIjozLjMxMTMsInJlZ2lvbiI6IkhERiIsImNvdW50cnkiOiJGUiIsImNpdHkiOiJTYXVsY2hlcnkiLCJ6aXBDb2RlIjoiMDIzMTAiLCJkZXBhcnRtZW50IjoiMDIifSwiY2l0eSI6IlNhdWxjaGVyeSIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTEuMC40NDcyLjEyNCBTYWZhcmkvNTM3LjM2In0sImdkcHIiOnsiaGFzQ29uc2VudCI6dHJ1ZX0sIndpbiI6ZmFsc2UsImFkSWQiOjU2NDgsImFkdmVydGlzZXJJZCI6MSwiY2FtcGFpZ25JZCI6MSwiY3JlYXRpdmVJZCI6MjgyNSwiZXJyb3IiOmZhbHNlfX0.-UefQH4G0k-RJGemBYffs-KL7EEwma2Wuwgk2xnpij8', }, headers: {}, - } -} + }; +}; /** * @description Mockup response from API for RTB creative * @param noAd * @return {{body: string} | {mode: string, message: string}} */ -const getConfigInterpretResponseRTB = (noAd = false) => { +const getConfigInterpretResponseRTB = (noAd = false, isInvalidVast = false) => { if (noAd) { return { message: 'invalid tag', - mode: 'no-ad' - } + mode: 'no-ad', + }; } + const validVast = ` + + + + BLIINK + https://vast.bliink.io/p/508379d0-9f65-4198-8ba5-f61f2b51224f.xml + https://e.api.bliink.io/e?name=vast-error&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw + https://e.api.bliink.io/e?name=impression&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw + 1EUR + + + + `; + const invalidVast = ` + + + + + + `; + return { - body: ` - - - - BLIINK - https://vast.bliink.io/p/508379d0-9f65-4198-8ba5-f61f2b51224f.xml - https://e.api.bliink.io/e?name=vast-error&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw - https://e.api.bliink.io/e?name=impression&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzQwMzA1MjcsImlhdCI6MTYzMzQyNTcyNywiaXNzIjoiYmxpaW5rIiwiZGF0YSI6eyJ0eXBlIjoiYWQtc2VydmVyIiwidHJhbnNhY3Rpb25JZCI6ImE2NjJjZGJmLTkzNDYtNDI0MS1iMTU0LTJhOTc2OTg0NjNmOSIsIm5ldHdvcmtJZCI6MjUsInNpdGVJZCI6MTQzLCJ0YWdJZCI6MTI3MSwiY29va2llSWQiOiIwNWFhN2UwMi05MzgzLTQ1NGYtOTJmZC1jOTE2YWNlMmUyZjYiLCJldmVudElkIjozLCJ0YXJnZXRpbmciOnsicGxhdGZvcm0iOiJXZWJzaXRlIiwicmVmZXJyZXIiOiJodHRwOi8vbG9jYWxob3N0OjgxODEvaW50ZWdyYXRpb25FeGFtcGxlcy9ncHQvYmxpaW5rLWluc3RyZWFtLmh0bWwiLCJwYWdlVXJsIjoiaHR0cDovL2xvY2FsaG9zdDo4MTgxL2ludGVncmF0aW9uRXhhbXBsZXMvZ3B0L2JsaWluay1pbnN0cmVhbS5odG1sIiwiaXAiOiIzMS4zOS4xNDEuMTQwIiwidGltZSI6MTYzMzQyNTcyNywibG9jYXRpb24iOnsibGF0aXR1ZGUiOjQ4Ljk0MjIsImxvbmdpdHVkZSI6Mi41MDM5LCJyZWdpb24iOiJJREYiLCJjb3VudHJ5IjoiRlIiLCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsInppcENvZGUiOiI5MzYwMCIsImRlcGFydG1lbnQiOiI5MyJ9LCJjaXR5IjoiQXVsbmF5LXNvdXMtQm9pcyIsImNvdW50cnkiOiJGUiIsImRldmljZU9zIjoibWFjT1MiLCJkZXZpY2VQbGF0Zm9ybSI6IldlYnNpdGUiLCJyYXdVc2VyQWdlbnQiOiJNb3ppbGxhLzUuMCAoTWFjaW50b3NoOyBJbnRlbCBNYWMgT1MgWCAxMF8xNV83KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWUvOTMuMC40NTc3LjYzIFNhZmFyaS81MzcuMzYiLCJjb250ZW50Q2xhc3NpZmljYXRpb24iOnsiYnJhbmRzYWZlIjpmYWxzZX19LCJnZHByIjp7Imhhc0NvbnNlbnQiOnRydWV9LCJ3aW4iOmZhbHNlLCJhZElkIjo1NzkzLCJhZHZlcnRpc2VySWQiOjEsImNhbXBhaWduSWQiOjEsImNyZWF0aXZlSWQiOjExOTQsImVycm9yIjpmYWxzZX19.nJSJPKovg0_jSHtLdrMPDqesAIlFKCuXPXYxpsyWBDw - 1EUR - - - - ` - } -} + body: { + bids: [ + { + creative: { + video: { + content: isInvalidVast ? invalidVast : validVast, + height: 250, + width: 300, + }, + media_type: 'video', + creativeId: 0, + }, + price: 0, + id: '8121', + token: 'token', + mode: 'rtb', + extras: { + deal_id: '34567ertyaza', + transaction_id: '2def0c5b2a7f6e', + }, + currency: 'EUR', + }, + ], + userSyncs: [], + }, + }; +}; /** * @@ -207,9 +293,9 @@ const testsGetMetaList = [ { title: 'Should return empty array if there are no parameters', args: { - fn: getMetaList() + fn: getMetaList(), }, - want: [] + want: [], }, { title: 'Should return list of metas with name associated', @@ -241,48 +327,48 @@ const testsGetMetaList = [ key: 'property', value: `'article:${'test'}'`, }, - ] - } -] + ], + }, +]; -describe('BLIINK Adapter getMetaList', function() { +describe('BLIINK Adapter getMetaList', function () { for (const test of testsGetMetaList) { it(test.title, () => { - const res = test.args.fn - expect(res).to.eql(test.want) - }) + const res = test.args.fn; + expect(res).to.eql(test.want); + }); } -}) - -/** - * @description Array of tests used in describe function below - * @type {[{args: {fn: (string|Document)}, want: string, title: string}, {args: {fn: (string|Document)}, want: string, title: string}]} - */ -const testsParseXML = [ +}); +const GetUserIds = [ { - title: 'Should return null, if content length equal to 0', + title: 'Should return undefined if there are no parameters', args: { - fn: parseXML('') + fn: getUserIds(), }, - want: null, + want: undefined, }, { - title: 'Should return null, if content isnt string', + title: 'Should return userIds if exists', args: { - fn: parseXML({}) + fn: getUserIds([{ userIds: { criteoId: 'testId' } }]), }, - want: null, + want: { criteoId: 'testId' }, }, -] +]; -describe('BLIINK Adapter parseXML', function() { - for (const test of testsParseXML) { +describe('BLIINK Adapter getUserIds', function () { + for (const test of GetUserIds) { it(test.title, () => { - const res = test.args.fn - expect(res).to.eql(test.want) - }) + const res = test.args.fn; + expect(res).to.eql(test.want); + }); } -}) +}); + +/** + * @description Array of tests used in describe function below + * @type {[{args: {fn: (string|Document)}, want: string, title: string}, {args: {fn: (string|Document)}, want: string, title: string}]} + */ /** * @@ -302,111 +388,170 @@ const testsIsBidRequestValid = [ { title: 'isBidRequestValid format not valid', args: { - fn: spec.isBidRequestValid({}) + fn: spec.isBidRequestValid({}), }, want: false, }, { title: 'isBidRequestValid does not receive any bid', args: { - fn: spec.isBidRequestValid() + fn: spec.isBidRequestValid(), }, want: false, }, { title: 'isBidRequestValid Receive a valid bid', args: { - fn: spec.isBidRequestValid(getConfigBid('banner')) + fn: spec.isBidRequestValid(getConfigBid('banner')), }, want: true, - } -] + }, +]; -describe('BLIINK Adapter isBidRequestValid', function() { +describe('BLIINK Adapter isBidRequestValid', function () { for (const test of testsIsBidRequestValid) { it(test.title, () => { - const res = test.args.fn - expect(res).to.eql(test.want) - }) + const res = test.args.fn; + expect(res).to.eql(test.want); + }); } -}) +}); + +const vastXml = + getConfigInterpretResponseRTB().body.bids[0].creative.video.content; const testsInterpretResponse = [ { title: 'Should construct bid for video instream', args: { - fn: spec.interpretResponse(getConfigInterpretResponseRTB(false), getConfigBuildRequest('video')) + fn: spec.interpretResponse(getConfigInterpretResponseRTB(false)), }, - want: { - cpm: 0, - currency: 'EUR', - height: 250, - width: 300, - creativeId: 0, - mediaType: 'video', - netRevenue: false, - requestId: '2def0c5b2a7f6e', - ttl: 3600, - vastXml: getConfigInterpretResponseRTB().body, - } + want: [ + { + cpm: 0, + currency: 'EUR', + height: 250, + width: 300, + creativeId: '34567ertyaza', + mediaType: 'video', + netRevenue: true, + requestId: '2def0c5b2a7f6e', + ttl: 300, + vastXml, + vastUrl: + 'data:text/xml;charset=utf-8;base64,' + + btoa(vastXml.replace(/\\"/g, '"')), + }, + ], }, { title: 'ServerResponse with message: invalid tag, return empty array', args: { - fn: spec.interpretResponse(getConfigInterpretResponse(true), getConfigBuildRequest('banner')) + fn: spec.interpretResponse(getConfigInterpretResponse(true)), }, - want: [] + want: [], }, -] + { + title: 'ServerResponse with mediaType banner', + args: { + fn: spec.interpretResponse({ body: { bids: [getConfigBannerBid()] } }), + }, + want: [ + { + ad: '', + cpm: 1, + creativeId: '34567erty', + currency: 'EUR', + height: 250, + mediaType: 'banner', + netRevenue: true, + requestId: '2def0c5b2a7f6e', + ttl: 300, + width: 300, + }, + ], + }, + { + title: 'ServerResponse with unhandled mediaType, return empty array', + args: { + fn: spec.interpretResponse({ + body: { + bids: [ + { + ...getConfigBannerBid(), + creative: { + unknown: { + adm: '', + height: 250, + width: 300, + }, + media_type: 'unknown', + creativeId: 125, + requestId: '2def0c5b2a7f6e', + }, + }, + ], + }, + }), + }, + want: [], + }, +]; -describe('BLIINK Adapter interpretResponse', function() { +describe('BLIINK Adapter interpretResponse', function () { for (const test of testsInterpretResponse) { it(test.title, () => { - const res = test.args.fn + const res = test.args.fn; if (res) { - expect(res).to.eql(test.want) + expect(res).to.eql(test.want); } - }) + }); } -}) +}); /** * @description Array of tests used in describe function below * @type {[ * {args: * {fn: { - * cpm: number, - * netRevenue: boolean, - * ad, requestId, - * meta: {mediaType}, - * width: number, - * currency: string, - * ttl: number, - * creativeId: number, - * height: number + * cpm: number, + * netRevenue: boolean, + * ad, requestId, + * meta: {mediaType}, + * width: number, + * currency: string, + * ttl: number, + * creativeId: number, + * height: number * } * }, want, title: string}]} */ + const testsBuildBid = [ { title: 'Should return null if no bid passed in parameters', args: { - fn: buildBid() + fn: buildBid(), }, - want: null + want: null, }, { title: 'Input data must respect the output model', args: { - fn: buildBid({ id: 1, test: '123' }, { id: 2, test: '345' }, false, false) + fn: buildBid( + { id: 1, test: '123' }, + { id: 2, test: '345' }, + false, + false + ), }, - want: null + want: null, }, { title: 'input data respect the output model for video', args: { - fn: buildBid(getConfigBid('video'), getConfigCreativeVideo()) + fn: buildBid(getConfigVideoBid('video'), getConfigCreativeVideo()), }, want: { requestId: getConfigBid('video').bidId, @@ -415,16 +560,55 @@ const testsBuildBid = [ mediaType: 'video', width: 300, height: 250, - creativeId: getConfigCreativeVideo().creativeId, - netRevenue: false, - vastXml: getConfigCreativeVideo().content, - ttl: 3600, - } + creativeId: getConfigVideoBid().extras.deal_id, + netRevenue: true, + vastXml: getConfigCreativeVideo().vastXml, + vastUrl: + 'data:text/xml;charset=utf-8;base64,' + + btoa(getConfigCreativeVideo().vastXml.replace(/\\"/g, '"')), + ttl: 300, + }, + }, + { + title: 'use default height width output model for video', + args: { + fn: buildBid( + { + ...getConfigVideoBid('video'), + creative: { + video: { + content: '', + height: null, + width: null, + }, + media_type: 'video', + creativeId: getConfigVideoBid().extras.deal_id, + requestId: '2def0c5b2a7f6e', + }, + }, + getConfigCreativeVideo() + ), + }, + want: { + requestId: getConfigBid('video').bidId, + cpm: 1, + currency: 'EUR', + mediaType: 'video', + width: 1, + height: 1, + creativeId: getConfigVideoBid().extras.deal_id, + netRevenue: true, + vastXml: getConfigCreativeVideo().vastXml, + vastUrl: + 'data:text/xml;charset=utf-8;base64,' + + btoa(getConfigCreativeVideo().vastXml.replace(/\\"/g, '"')), + ttl: 300, + }, }, { title: 'input data respect the output model for banner', args: { - fn: buildBid(getConfigBid('banner'), getConfigCreative()) + fn: buildBid(getConfigBannerBid()), }, want: { requestId: getConfigBid('banner').bidId, @@ -433,22 +617,22 @@ const testsBuildBid = [ mediaType: 'banner', width: 300, height: 250, - creativeId: getConfigCreative().id, - ad: getConfigCreative().content.creative.adm, - ttl: 3600, - netRevenue: false, - } - } -] + creativeId: getConfigCreative().creativeId, + ad: getConfigBannerBid().creative.banner.adm, + ttl: 300, + netRevenue: true, + }, + }, +]; -describe('BLIINK Adapter buildBid', function() { +describe('BLIINK Adapter buildBid', function () { for (const test of testsBuildBid) { it(test.title, () => { - const res = test.args.fn - expect(res).to.eql(test.want) - }) + const res = test.args.fn; + expect(res).to.eql(test.want); + }); } -}) +}); /** * @description Array of tests used in describe function below @@ -458,155 +642,469 @@ const testsBuildRequests = [ { title: 'Should not build request, no bidder request exist', args: { - fn: spec.buildRequests() + fn: spec.buildRequests(), }, - want: null + want: null, }, { title: 'Should build request if bidderRequest exist', args: { - fn: spec.buildRequests([], getConfigBuildRequest('banner')) + fn: spec.buildRequests([], getConfigBuildRequest('banner')), }, want: { - method: 'GET', - url: `${BLIINK_ENDPOINT_ENGINE}/${getConfigBuildRequest('banner').bids[0].params.tagId}`, - params: { - bidderRequestId: getConfigBuildRequest('banner').bidderRequestId, - bidderCode: getConfigBuildRequest('banner').bidderCode, - bids: getConfigBuildRequest('banner').bids, - refererInfo: getConfigBuildRequest('banner').refererInfo - }, + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, data: { - gdpr: false, - gdpr_consent: '', - height: 250, - width: 300, + ect: connectionType, keywords: '', pageDescription: '', pageTitle: '', - pageUrl: 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', - } - } + pageUrl: + 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + tags: [ + { + transactionId: '2def0c5b2a7f6e', + refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined, + id: '14f30eca-85d2-11e8-9eed-0242ac120007', + imageUrl: 'https://www.example.com/adimage.jpg', + videoUrl: 'https://www.example.com/advideo.mp4', + mediaTypes: ['banner'], + sizes: [ + { + h: 250, + w: 300, + }, + ], + }, + ], + }, + }, }, { title: 'Should build request width GDPR configuration', args: { - fn: spec.buildRequests([], Object.assign(getConfigBuildRequest('banner'), { - gdprConsent: { - gdprApplies: true, - consentString: 'XXXX' - }, - })) + fn: spec.buildRequests( + [], + Object.assign(getConfigBuildRequest('banner'), { + gdprConsent: { + gdprApplies: true, + consentString: 'XXXX', + }, + }) + ), }, want: { - method: 'GET', - url: `${BLIINK_ENDPOINT_ENGINE}/${getConfigBuildRequest('banner').bids[0].params.tagId}`, - params: { - bidderRequestId: getConfigBuildRequest('banner').bidderRequestId, - bidderCode: getConfigBuildRequest('banner').bidderCode, - bids: getConfigBuildRequest('banner').bids, - refererInfo: getConfigBuildRequest('banner').refererInfo + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, + data: { + ect: connectionType, + gdpr: true, + gdprConsent: 'XXXX', + pageDescription: '', + pageTitle: '', + keywords: '', + pageUrl: + 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + tags: [ + { + transactionId: '2def0c5b2a7f6e', + refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined, + id: '14f30eca-85d2-11e8-9eed-0242ac120007', + imageUrl: 'https://www.example.com/adimage.jpg', + videoUrl: 'https://www.example.com/advideo.mp4', + mediaTypes: ['banner'], + sizes: [ + { + h: 250, + w: 300, + }, + ], + }, + ], }, + }, + }, + { + title: 'Should build request width uspConsent if exists', + args: { + fn: spec.buildRequests( + [], + Object.assign(getConfigBuildRequest('banner'), { + gdprConsent: { + gdprApplies: true, + consentString: 'XXXX', + }, + uspConsent: 'uspConsent', + }) + ), + }, + want: { + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, data: { + ect: connectionType, gdpr: true, - gdpr_consent: 'XXXX', + uspConsent: 'uspConsent', + gdprConsent: 'XXXX', pageDescription: '', pageTitle: '', keywords: '', - pageUrl: 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', - height: 250, - width: 300, - } - } - } -] + pageUrl: + 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + tags: [ + { + transactionId: '2def0c5b2a7f6e', + refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined, + id: '14f30eca-85d2-11e8-9eed-0242ac120007', + imageUrl: 'https://www.example.com/adimage.jpg', + videoUrl: 'https://www.example.com/advideo.mp4', + mediaTypes: ['banner'], + sizes: [ + { + h: 250, + w: 300, + }, + ], + }, + ], + }, + }, + }, + { + title: 'Should build request width schain if exists', + args: { + fn: spec.buildRequests( + [ + { + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'ssp.test', + sid: '00001', + hp: 1, + }, + ], + }, + }, + ], + Object.assign(getConfigBuildRequest('banner'), { + gdprConsent: { + gdprApplies: true, + consentString: 'XXXX', + }, + }) + ), + }, + want: { + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, + data: { + ect: connectionType, + gdpr: true, + gdprConsent: 'XXXX', + pageDescription: '', + pageTitle: '', + keywords: '', + pageUrl: + 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'ssp.test', + sid: '00001', + hp: 1, + }, + ], + }, + tags: [ + { + transactionId: '2def0c5b2a7f6e', + refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined, + id: '14f30eca-85d2-11e8-9eed-0242ac120007', + imageUrl: 'https://www.example.com/adimage.jpg', + videoUrl: 'https://www.example.com/advideo.mp4', + mediaTypes: ['banner'], + sizes: [ + { + h: 250, + w: 300, + }, + ], + }, + ], + }, + }, + }, + { + title: 'Should build request with userIds if exists', + args: { + fn: spec.buildRequests( + [ + { + userIds: { + criteoId: + 'vG4RRF93V05LRlJUTVVOQTJJJTJGbG1rZWxEeDVvc0NXWE42TzJqU2hG', + netId: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', + }, + }, + ], + Object.assign(getConfigBuildRequest('banner'), { + gdprConsent: { + gdprApplies: true, + consentString: 'XXXX', + }, + }) + ), + }, + want: { + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, + data: { + ect: connectionType, + gdpr: true, + gdprConsent: 'XXXX', + pageDescription: '', + pageTitle: '', + keywords: '', + pageUrl: + 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + userIds: { + criteoId: 'vG4RRF93V05LRlJUTVVOQTJJJTJGbG1rZWxEeDVvc0NXWE42TzJqU2hG', + netId: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', + }, + tags: [ + { + transactionId: '2def0c5b2a7f6e', + refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined, + id: '14f30eca-85d2-11e8-9eed-0242ac120007', + imageUrl: 'https://www.example.com/adimage.jpg', + videoUrl: 'https://www.example.com/advideo.mp4', + mediaTypes: ['banner'], + sizes: [ + { + h: 250, + w: 300, + }, + ], + }, + ], + }, + }, + }, +]; -describe('BLIINK Adapter buildRequests', function() { +describe('BLIINK Adapter buildRequests', function () { for (const test of testsBuildRequests) { it(test.title, () => { - const res = test.args.fn - expect(res).to.eql(test.want) - }) + const res = test.args.fn; + expect(res).to.eql(test.want); + test.args.after; + }); } -}) +}); -const getSyncOptions = (pixelEnabled = true, iframeEnabled = 'false') => { +const getSyncOptions = (pixelEnabled = true, iframeEnabled = false) => { return { pixelEnabled, - iframeEnabled - } -} + iframeEnabled, + }; +}; const getServerResponses = () => { return [ { - body: '', - } - ] -} + body: { + bids: [], + userSyncs: [ + { + type: 'script', + url: 'https://prg.smartadserver.com/ac?out=js&nwid=3392&siteid=305791&pgname=rg&fmtid=81127&tgt=[sas_target]&visit=m&tmstp=[timestamp]&clcturl=[countgo]', + }, + { + type: 'image', + url: 'https://sync.smartadserver.com/getuid?nwid=3392&consentString=XXX&url=https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dsmart%26uid%3D%5Bsas_uid%5D', + }, + ], + }, + }, + ]; +}; const getGdprConsent = () => { return { gdprApplies: 1, - consentString: 'XXX' - } -} + consentString: 'XXX', + apiVersion: 2, + }; +}; const testsGetUserSyncs = [ { title: 'Should not have gdprConsent exist', args: { - fn: spec.getUserSyncs(getSyncOptions(), getServerResponses(), getGdprConsent()) + fn: spec.getUserSyncs( + getSyncOptions(), + getServerResponses(), + getGdprConsent() + ), }, want: [ { type: 'script', - url: 'https://prg.smartadserver.com/ac?out=js&nwid=3392&siteid=305791&pgname=rg&fmtid=81127&tgt=[sas_target]&visit=m&tmstp=[timestamp]&clcturl=[countgo]' - }, - { - type: 'image', - url: 'https://sync.smartadserver.com/getuid?nwid=3392&consentString=XXX&url=https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dsmart%26uid%3D%5Bsas_uid%5D' - }, - { - type: 'image', - url: 'https://ad.360yield.com/server_match?partner_id=1531&consentString=XXX&r=https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dazerion%26uid%3D%7BPUB_USER_ID%7D', + url: 'https://prg.smartadserver.com/ac?out=js&nwid=3392&siteid=305791&pgname=rg&fmtid=81127&tgt=[sas_target]&visit=m&tmstp=[timestamp]&clcturl=[countgo]', }, { type: 'image', - url: 'https://ads.stickyadstv.com/auto-user-sync?consentString=XXX', - }, - { - type: 'image', - url: 'https://cookiesync.api.bliink.io/getuid?url=https%3A%2F%2Fvisitor.omnitagjs.com%2Fvisitor%2Fsync%3Fuid%3D1625272249969090bb9d544bd6d8d645%26name%3DBLIINK%26visitor%3D%24UID%26external%3Dtrue&consentString=XXX', - }, - { - type: 'image', - url: 'https://cookiesync.api.bliink.io/getuid?url=https://pixel.advertising.com/ups/58444/sync?&gdpr=1&gdpr_consent=XXX&redir=true&uid=$UID', + url: 'https://sync.smartadserver.com/getuid?nwid=3392&consentString=XXX&url=https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dsmart%26uid%3D%5Bsas_uid%5D', }, + ], + }, + { + title: 'Should return iframe cookie sync if iframeEnabled', + args: { + fn: spec.getUserSyncs( + getSyncOptions(true, true), + getServerResponses(), + getGdprConsent() + ), + }, + want: [ { - type: 'image', - url: 'https://ups.analytics.yahoo.com/ups/58499/occ?gdpr=1&gdpr_consent=XXX', + type: 'iframe', + url: `${BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME}?gdpr=${ + getGdprConsent().gdprApplies + }&coppa=0&gdprConsent=${getGdprConsent().consentString}&apiVersion=${ + getGdprConsent().apiVersion + }`, }, + ], + }, + { + title: 'ccpa', + args: { + fn: spec.getUserSyncs( + getSyncOptions(true, true), + getServerResponses(), + getGdprConsent(), + 'ccpa-consent' + ), + }, + want: [ { - type: 'image', - url: 'https://secure.adnxs.com/getuid?https%3A%2F%2Fcookiesync.api.bliink.io%2Fcookiesync%3Fpartner%3Dazerion%26uid%3D%24UID', + type: 'iframe', + url: `${BLIINK_ENDPOINT_COOKIE_SYNC_IFRAME}?gdpr=${ + getGdprConsent().gdprApplies + }&coppa=0&uspConsent=ccpa-consent&gdprConsent=${ + getGdprConsent().consentString + }&apiVersion=${getGdprConsent().apiVersion}`, }, - ] + ], }, { - title: 'Should not have gdpr consent', + title: 'Should output sync if no gdprConsent', args: { - fn: spec.getUserSyncs(getSyncOptions(), getServerResponses()) + fn: spec.getUserSyncs(getSyncOptions(), getServerResponses()), }, - want: [] - } -] + want: getServerResponses()[0].body.userSyncs, + }, + { + title: 'Should output empty array if no pixelEnabled', + args: { + fn: spec.getUserSyncs({}, getServerResponses()), + }, + want: [], + }, +]; -describe('BLIINK Adapter getUserSyncs', function() { +describe('BLIINK Adapter getUserSyncs', function () { for (const test of testsGetUserSyncs) { it(test.title, () => { - const res = test.args.fn - expect(res).to.eql(test.want) - }) + const res = test.args.fn; + expect(res).to.eql(test.want); + }); + } +}); + +describe('BLIINK Adapter keywords & coppa true', function () { + it('Should build request with keyword and coppa true if exist', () => { + const metaElement = document.createElement('meta'); + metaElement.name = 'keywords'; + metaElement.content = 'Bliink, Saber, Prebid'; + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + + const querySelectorStub = sinon + .stub(document, 'querySelector') + .returns(metaElement); + expect( + spec.buildRequests( + [], + Object.assign(getConfigBuildRequest('banner'), { + gdprConsent: { + gdprApplies: true, + consentString: 'XXXX', + }, + }) + ) + ).to.eql({ + method: 'POST', + url: BLIINK_ENDPOINT_ENGINE, + data: { + ect: connectionType, + gdpr: true, + coppa: 1, + gdprConsent: 'XXXX', + pageDescription: 'Bliink, Saber, Prebid', + pageTitle: '', + keywords: 'Bliink,Saber,Prebid', + pageUrl: + 'http://localhost:9999/integrationExamples/gpt/bliink-adapter.html?pbjs_debug=true', + tags: [ + { + transactionId: '2def0c5b2a7f6e', + id: '14f30eca-85d2-11e8-9eed-0242ac120007', + imageUrl: 'https://www.example.com/adimage.jpg', + videoUrl: 'https://www.example.com/advideo.mp4', + mediaTypes: ['banner'], + refresh: window.bliinkBid['14f30eca-85d2-11e8-9eed-0242ac120007'] || undefined, + sizes: [ + { + h: 250, + w: 300, + }, + ], + }, + ], + }, + }); + querySelectorStub.restore(); + config.getConfig.restore(); + }); +}); + +describe('getEffectiveConnectionType', () => { + let navigatorStub; + + beforeEach(() => { + if ('connection' in navigator) { + navigatorStub = sinon.stub(navigator, 'connection').value({ + effectiveType: undefined, + }); + } + }); + + afterEach(() => { + if (navigatorStub) { + navigatorStub.restore(); + } + }); + if (navigatorStub) { + it('should return "unsupported" when effective connection type is undefined', () => { + const result = getEffectiveConnectionType(); + expect(result).to.equal('unsupported'); + }); } -}) +}); diff --git a/test/spec/modules/bluebillywigBidAdapter_spec.js b/test/spec/modules/bluebillywigBidAdapter_spec.js index c831ddf6ddf..4b58e3507db 100644 --- a/test/spec/modules/bluebillywigBidAdapter_spec.js +++ b/test/spec/modules/bluebillywigBidAdapter_spec.js @@ -1,10 +1,8 @@ -import { expect } from 'chai'; -import { spec } from 'modules/bluebillywigBidAdapter.js'; -import * as bidderFactory from 'src/adapters/bidderFactory.js'; -import { auctionManager } from 'src/auctionManager.js'; -import { deepClone, deepAccess } from 'src/utils.js'; -import { config } from 'src/config.js'; -import { VIDEO } from 'src/mediaTypes.js'; +import {expect} from 'chai'; +import {spec} from 'modules/bluebillywigBidAdapter.js'; +import {deepAccess, deepClone} from 'src/utils.js'; +import {config} from 'src/config.js'; +import {VIDEO} from 'src/mediaTypes.js'; const BB_CONSTANTS = { BIDDER_CODE: 'bluebillywig', @@ -254,7 +252,11 @@ describe('BlueBillywigAdapter', () => { const baseValidBidRequests = [baseValidBid]; const validBidderRequest = { - auctionId: '12abc345-67d8-9012-e345-6f78901a2b34', + ortb2: { + source: { + tid: '12abc345-67d8-9012-e345-6f78901a2b34', + } + }, auctionStart: 1585918458868, bidderCode: BB_CONSTANTS.BIDDER_CODE, bidderRequestId: '1a2345b67c8d9e0', @@ -293,9 +295,9 @@ describe('BlueBillywigAdapter', () => { const request = spec.buildRequests(baseValidBidRequests, validBidderRequest); const payload = JSON.parse(request.data); - expect(payload.id).to.equal(validBidderRequest.auctionId); + expect(payload.id).to.exist; expect(payload.source).to.be.an('object'); - expect(payload.source.tid).to.equal(validBidderRequest.auctionId); + expect(payload.source.tid).to.equal(validBidderRequest.ortb2.source.tid); expect(payload.tmax).to.equal(BB_CONSTANTS.DEFAULT_TIMEOUT); expect(payload.imp).to.be.an('array'); expect(payload.test).to.be.a('number'); @@ -439,7 +441,7 @@ describe('BlueBillywigAdapter', () => { it('should add referrerInfo as site when no app is set', () => { const newValidBidderRequest = deepClone(validBidderRequest); - newValidBidderRequest.refererInfo = { referer: 'https://www.bluebillywig.com' }; + newValidBidderRequest.refererInfo = { page: 'https://www.bluebillywig.com' }; const request = spec.buildRequests(baseValidBidRequests, newValidBidderRequest); const payload = JSON.parse(request.data); @@ -535,10 +537,8 @@ describe('BlueBillywigAdapter', () => { }); it('should set user ids when present', () => { - const userId = { tdid: 123 }; - const newBaseValidBidRequests = deepClone(baseValidBidRequests); - newBaseValidBidRequests[0].userId = { criteoId: 'sample-userid' }; + newBaseValidBidRequests[0].userIdAsEids = [ {} ]; const request = spec.buildRequests(newBaseValidBidRequests, validBidderRequest); const payload = JSON.parse(request.data); diff --git a/test/spec/modules/blueconicRtdProvider_spec.js b/test/spec/modules/blueconicRtdProvider_spec.js new file mode 100644 index 00000000000..174c1e58997 --- /dev/null +++ b/test/spec/modules/blueconicRtdProvider_spec.js @@ -0,0 +1,135 @@ +import {config} from 'src/config.js'; +import {RTD_LOCAL_NAME, addRealTimeData, getRealTimeData, blueconicSubmodule, storage} from 'modules/blueconicRtdProvider.js'; + +describe('blueconicRtdProvider', function() { + let getDataFromLocalStorageStub; + beforeEach(function() { + config.resetConfig(); + getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + }); + + afterEach(function () { + getDataFromLocalStorageStub.restore(); + }); + + describe('blueconicSubmodule', function() { + it('successfully instantiates', function () { + expect(blueconicSubmodule.init()).to.equal(true); + }); + }); + + describe('Add Blueconic Real-Time Data', function() { + it('merges ortb2Fragment data', function() { + const setConfigUserObj1 = { + name: 'www.dataprovider1.com', + ext: {segtax: 1}, + segment: [{id: '1776'}] + }; + const setConfigUserObj2 = { + name: 'www.dataprovider2.com', + ext: {segtax: 1}, + segment: [{id: '1914'} + ] + }; + + let bidConfig = { + ortb2Fragments: { + global: { + user: { + data: [setConfigUserObj1, setConfigUserObj2] + } + } + } + }; + + const rtdUserObj1 = { + name: 'www.dataprovider4.com', + ext: {segtax: 1}, + segment: [{id: '1918'}, {id: '1939'} + ] + }; + + const rtd = { + ortb2: { + user: { + data: [rtdUserObj1] + } + } + }; + + addRealTimeData(bidConfig.ortb2Fragments.global, rtd); + + let ortb2Config = bidConfig.ortb2Fragments.global; + expect(ortb2Config.user.data).to.deep.include.members([setConfigUserObj1, setConfigUserObj2, rtdUserObj1]); + }); + + it('merges data without duplication', function() { + const userObj1 = { + name: 'www.dataprovider1.com', + ext: {segtax: 1}, + segment: [{id: '1776'} + ] + }; + + const userObj2 = { + ext: {segtax: 1}, + name: 'www.dataprovider2.com', + segment: [{id: '1914' + }] + }; + + const bidConfig = { + ortb2Fragments: + { + global: { + user: { + data: [userObj1, userObj2] + } + } + } + }; + + const rtd = { + ortb2: { + user: { + data: [userObj1] + } + } + }; + + addRealTimeData(bidConfig.ortb2Fragments.global, rtd); + + let ortb2Config = bidConfig.ortb2Fragments.global; + + expect(ortb2Config.user.data).to.deep.include.members([userObj1, userObj2]); + expect(bidConfig.ortb2Fragments.global.user.data).to.have.lengthOf(2); + }); + }); + + describe('Get BlueConic Real-Time Data', function() { + it('gets rtd from local storage cache', function() { + const rtdConfig = { + params: { + requestParams: { + publisherId: 'Publisher1', + coppa: true + }} + }; + + const bidConfig = {ortb2Fragments: {global: {}}}; + + const rtdUserObj1 = { + name: 'blueconic', + ext: {segtax: 1}, + segment: [{id: 'bf23d802-931d-4619-8266-ce9a6328aa2a'}], + bidId: '1234' + }; + + const cachedRtd = {ext: {segtax: 1}, 'segment': [{id: 'bf23d802-931d-4619-8266-ce9a6328aa2a'}], 'bidId': '1234'} + getDataFromLocalStorageStub.withArgs(RTD_LOCAL_NAME).returns(JSON.stringify(cachedRtd)); + + getRealTimeData(bidConfig, () => {}, rtdConfig, {}); + expect(bidConfig.ortb2Fragments.global.user.data).to.deep.include.members([rtdUserObj1]); + }); + }); +}); diff --git a/test/spec/modules/boldwinBidAdapter_spec.js b/test/spec/modules/boldwinBidAdapter_spec.js index afb5f935621..52a6ec03757 100644 --- a/test/spec/modules/boldwinBidAdapter_spec.js +++ b/test/spec/modules/boldwinBidAdapter_spec.js @@ -19,7 +19,8 @@ describe('BoldwinBidAdapter', function () { const bidderRequest = { refererInfo: { referer: 'test.com' - } + }, + ortb2: {} }; describe('isBidRequestValid', function () { @@ -59,11 +60,12 @@ describe('BoldwinBidAdapter', function () { expect(data.gdpr).to.not.exist; expect(data.ccpa).to.not.exist; let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'adFormat', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'bidFloor'); + expect(placement).to.have.keys('placementId', 'bidId', 'adFormat', 'sizes', 'hPlayer', 'wPlayer', 'schain', 'bidFloor', 'type'); expect(placement.placementId).to.equal('testBanner'); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.adFormat).to.equal(BANNER); expect(placement.schain).to.be.an('object'); + expect(placement.type).to.exist.and.to.equal('publisher'); }); it('Returns valid data for mediatype video', function () { @@ -109,6 +111,36 @@ describe('BoldwinBidAdapter', function () { expect(data.placements).to.be.an('array').that.is.empty; }); }); + + describe('gpp consent', function () { + it('bidderRequest.gppConsent', () => { + bidderRequest.gppConsent = { + gppString: 'abc123', + applicableSections: [8] + }; + + let serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.property('gpp'); + expect(data).to.have.property('gpp_sid'); + + delete bidderRequest.gppConsent; + }) + + it('bidderRequest.ortb2.regs.gpp', () => { + bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {}; + bidderRequest.ortb2.regs.gpp = 'abc123'; + bidderRequest.ortb2.regs.gpp_sid = [8]; + + let serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.property('gpp'); + expect(data).to.have.property('gpp_sid'); + }) + }); + describe('interpretResponse', function () { it('Should interpret banner response', function () { const banner = { diff --git a/test/spec/modules/brandmetricsRtdProvider_spec.js b/test/spec/modules/brandmetricsRtdProvider_spec.js index 3cac5a3d559..72a2e4b029c 100644 --- a/test/spec/modules/brandmetricsRtdProvider_spec.js +++ b/test/spec/modules/brandmetricsRtdProvider_spec.js @@ -1,5 +1,7 @@ import * as brandmetricsRTD from '../../../modules/brandmetricsRtdProvider.js'; import {config} from 'src/config.js'; +import * as events from '../../../src/events'; +import * as sinon from 'sinon'; const VALID_CONFIG = { name: 'brandmetrics', @@ -65,6 +67,8 @@ const NO_USP_CONSENT = { usp: '1NYY' }; +const UNDEFINED_USER_CONSENT = {}; + function mockSurveyLoaded(surveyConf) { const commands = window._brandmetrics || []; commands.forEach(command => { @@ -77,14 +81,16 @@ function mockSurveyLoaded(surveyConf) { }); } -function scriptTagExists(url) { - const tags = document.getElementsByTagName('script'); - for (let i = 0; i < tags.length; i++) { - if (tags[i].src === url) { - return true; +function mockCreativeInView(creativeInViewConf) { + const commands = window._brandmetrics || []; + commands.forEach(command => { + if (command.cmd === '_addeventlistener') { + const conf = command.val; + if (conf.event === 'creative_in_view') { + conf.handler(creativeInViewConf); + } } - } - return false; + }) } describe('BrandmetricsRTD module', () => { @@ -116,6 +122,10 @@ describe('BrandmetricsRTD module', () => { it('should not init when there is no usp- consent', () => { expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, NO_USP_CONSENT)).to.equal(false); }); + + it('should init if there are no consent- objects defined', () => { + expect(brandmetricsRTD.brandmetricsSubmodule.init(VALID_CONFIG, UNDEFINED_USER_CONSENT)).to.equal(true); + }); }); describe('getBidRequestData', () => { @@ -124,12 +134,12 @@ describe('getBidRequestData', () => { }) it('should set targeting keys for specified bidders', () => { - brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => { - const bidderConfig = config.getBidderConfig() + const bidderOrtb2 = {}; + brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({ortb2Fragments: {bidder: bidderOrtb2}}, () => { const expected = VALID_CONFIG.params.bidders expected.forEach(exp => { - expect(bidderConfig[exp].ortb2.user.ext.data.mockTargetKey).to.equal('mockMeasurementId') + expect(bidderOrtb2[exp].user.ext.data.mockTargetKey).to.equal('mockMeasurementId') }) }, VALID_CONFIG); @@ -161,9 +171,9 @@ describe('getBidRequestData', () => { } }); - brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {}, VALID_CONFIG); - const bidderConfig = config.getBidderConfig() - expect(Object.keys(bidderConfig).length).to.equal(0) + const bidderOrtb2 = {}; + brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({ortb2Fragments: {bidder: bidderOrtb2}}, () => {}, VALID_CONFIG); + expect(Object.keys(bidderOrtb2).length).to.equal(0) }); it('should use a default targeting key name if the brandmetrics- configuration does not include one', () => { @@ -179,13 +189,71 @@ describe('getBidRequestData', () => { } }); - brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({}, () => {}, VALID_CONFIG); + const bidderOrtb2 = {}; + brandmetricsRTD.brandmetricsSubmodule.getBidRequestData({ortb2Fragments: {bidder: bidderOrtb2}}, () => {}, VALID_CONFIG); - const bidderConfig = config.getBidderConfig() const expected = VALID_CONFIG.params.bidders expected.forEach(exp => { - expect(bidderConfig[exp].ortb2.user.ext.data.brandmetrics_survey).to.equal('mockMeasurementId') + expect(bidderOrtb2[exp].user.ext.data.brandmetrics_survey).to.equal('mockMeasurementId') }) }); + + describe('billable events', () => { + let sandbox; + let eventsEmitSpy; + + before(() => { + sandbox = sinon.sandbox.create(); + eventsEmitSpy = sandbox.spy(events, ['emit']); + }); + + beforeEach(() => { + eventsEmitSpy.resetHistory(); + }) + + afterEach(() => { + sandbox.restore(); + }); + + it('should emit billable event from prebid events', () => { + const expectedEvent = { + vendor: 'brandmetrics', + type: 'creative_in_view', + measurementId: 'mockMeasurementId', + auctionId: 'mockAuctionId', + transactionId: 'mockTransactionId' + }; + + mockCreativeInView({ + mid: expectedEvent.measurementId, + source: { + type: 'pbj', + data: { + auctionId: expectedEvent.auctionId, + transactionId: expectedEvent.transactionId + }, + } + }); + + expect(eventsEmitSpy.callCount).to.equal(1); + + const event = eventsEmitSpy.getCalls()[0].args[1]; + delete event['billingId']; + + expect(event).to.deep.equal(expectedEvent); + }); + + it('should not emit billable event from non prebid- sources', () => { + mockCreativeInView({ + mid: 'mockMeasurementId', + source: { + type: 'gpt', + data: {}, + } + }); + + expect(eventsEmitSpy.callCount).to.equal(0); + }); + }); }); diff --git a/test/spec/modules/bridBidAdapter_spec.js b/test/spec/modules/bridBidAdapter_spec.js new file mode 100644 index 00000000000..7503c748999 --- /dev/null +++ b/test/spec/modules/bridBidAdapter_spec.js @@ -0,0 +1,129 @@ +import { spec } from '../../../modules/bridBidAdapter.js' + +describe('Brid Bid Adapter', function() { + const videoRequest = [{ + bidder: 'brid', + params: { + placementId: 12345, + }, + mediaTypes: { + video: { + playerSize: [[640, 360]], + context: 'instream', + playbackmethod: [1, 2, 3, 4] + } + } + }]; + + it('Test the bid validation function', function() { + const validBid = spec.isBidRequestValid(videoRequest[0]); + const invalidBid = spec.isBidRequestValid(null); + + expect(validBid).to.be.true; + expect(invalidBid).to.be.false; + }); + + it('Test the request processing function', function () { + const request = spec.buildRequests(videoRequest, videoRequest[0]); + expect(request).to.not.be.empty; + + const payload = JSON.parse(request[0].data); + expect(payload).to.not.be.empty; + expect(payload.sdk).to.deep.equal({ + source: 'pbjs', + version: '$prebid.version$' + }); + expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal(12345); + }); + + it('Test nobid responses', function () { + const responseBody = { + 'id': 'test-id', + 'cur': 'USD', + 'seatbid': [], + 'nbr': 0 + }; + const bidderRequest = null; + + const bidResponse = spec.interpretResponse({ body: responseBody }, {bidderRequest}); + + expect(bidResponse.length).to.equal(0); + }); + + it('Test the response parsing function', function () { + const responseBody = { + 'id': 'test-id', + 'cur': 'USD', + 'seatbid': [{ + 'bid': [{ + 'id': '5044997188309660254', + 'price': 5, + 'adm': 'test ad', + 'adid': '97517771', + 'crid': '97517771', + 'adomain': ['domain.com'], + 'w': 640, + 'h': 480 + }], + 'seat': 'bidder' + }] + }; + const bidderRequest = { + bidderCode: 'brid', + bidderRequestId: '22edbae2733bf6', + bids: videoRequest + }; + + const bidResponse = spec.interpretResponse({ body: responseBody }, {bidderRequest}); + expect(bidResponse).to.not.be.empty; + + const bid = bidResponse[0]; + expect(bid).to.not.be.empty; + expect(bid.ad).to.equal('test ad'); + expect(bid.cpm).to.equal(5); + expect(bid.width).to.equal(640); + expect(bid.height).to.equal(480); + expect(bid.currency).to.equal('USD'); + }); + + it('Test GDPR and USP consents are present in the request', function () { + let gdprConsentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let uspConsentString = '1YA-'; + let bidderRequest = { + 'bidderCode': 'brid', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'uspConsent': uspConsentString, + 'gdprConsent': { + consentString: gdprConsentString, + gdprApplies: true, + addtlConsent: '1~7.12.35.62.66.70.89.93.108' + } + }; + bidderRequest.bids = videoRequest; + + const request = spec.buildRequests(videoRequest, bidderRequest); + const payload = JSON.parse(request[0].data); + + expect(payload.user.ext.consent).to.equal(gdprConsentString); + expect(payload.regs.ext.us_privacy).to.equal(uspConsentString); + expect(payload.regs.ext.gdpr).to.equal(1); + }); + + it('Test GDPR is not present', function () { + let uspConsentString = '1YA-'; + let bidderRequest = { + 'bidderCode': 'brid', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'uspConsent': uspConsentString + }; + bidderRequest.bids = videoRequest; + + const request = spec.buildRequests(videoRequest, bidderRequest); + const payload = JSON.parse(request[0].data); + + expect(payload.regs.ext.gdpr).to.be.undefined; + expect(payload.regs.ext.us_privacy).to.equal(uspConsentString); + }); +}); diff --git a/test/spec/modules/bridgewellBidAdapter_spec.js b/test/spec/modules/bridgewellBidAdapter_spec.js index 8da82c71820..77818f34a62 100644 --- a/test/spec/modules/bridgewellBidAdapter_spec.js +++ b/test/spec/modules/bridgewellBidAdapter_spec.js @@ -7,7 +7,6 @@ const userId = { 'pubcid': '074864cb-3705-430e-9ff7-48ccf3c21b94', 'sharedid': {'id': '01F61MX53D786DSB2WYD38ZVM7', 'third': '01F61MX53D786DSB2WYD38ZVM7'}, 'uid2': {'id': 'eb33b0cb-8d35-1234-b9c0-1a31d4064777'}, - 'flocId': {'id': '12345', 'version': 'chrome.1.1'}, } describe('bridgewellBidAdapter', function () { @@ -142,7 +141,10 @@ describe('bridgewellBidAdapter', function () { it('should attach valid params to the tag', function () { const bidderRequest = { refererInfo: { - referer: 'https://www.bridgewell.com/' + page: 'https://www.bridgewell.com/', + legacy: { + referer: 'https://www.bridgewell.com/', + } } } const request = spec.buildRequests(bidRequests, bidderRequest); @@ -165,7 +167,10 @@ describe('bridgewellBidAdapter', function () { it('should attach valid params to the tag, part2', function() { const bidderRequest = { refererInfo: { - referer: 'https://www.bridgewell.com/' + page: 'https://www.bridgewell.com/', + legacy: { + referer: 'https://www.bridgewell.com/' + } } } const bidRequests2 = [ @@ -207,7 +212,10 @@ describe('bridgewellBidAdapter', function () { it('should attach validBidRequests to the tag', function () { const bidderRequest = { refererInfo: { - referer: 'https://www.bridgewell.com/' + page: 'https://www.bridgewell.com/', + legacy: { + referer: 'https://www.bridgewell.com/', + } } } diff --git a/test/spec/modules/brightcomBidAdapter_spec.js b/test/spec/modules/brightcomBidAdapter_spec.js index b7d52c9f7d5..1ae73708d00 100644 --- a/test/spec/modules/brightcomBidAdapter_spec.js +++ b/test/spec/modules/brightcomBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import * as utils from 'src/utils.js'; import { spec } from 'modules/brightcomBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import {config} from '../../../src/config'; const URL = 'https://brightcombid.marphezis.com/hb'; @@ -52,7 +53,21 @@ describe('brightcomBidAdapter', function() { }, 'bidId': '5fb26ac22bde4', 'bidderRequestId': '4bf93aeb730cb9', - 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e' + 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e', + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'exchange1.com', + 'sid': '1234', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher', + 'domain': 'publisher.com' + } + ] + }, }]; sandbox = sinon.sandbox.create(); @@ -153,7 +168,8 @@ describe('brightcomBidAdapter', function() { gdprApplies: true }, refererInfo: { - referer: 'http://example.com/page.html', + page: 'http://example.com/page.html', + domain: 'example.com', } }; bidderRequest.bids = bidRequests; @@ -166,6 +182,84 @@ describe('brightcomBidAdapter', function() { expect(data.user.ext.consent).to.equal(consentString); }); + it('sends us_privacy', function () { + const bidderRequest = { + uspConsent: '1YYY' + }; + const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data) + + expect(data.regs).to.not.equal(null); + expect(data.regs.ext).to.not.equal(null); + expect(data.regs.ext.us_privacy).to.equal('1YYY'); + }); + + it('sends coppa', function () { + sandbox.stub(config, 'getConfig').withArgs('coppa').returns(true); + + const data = JSON.parse(spec.buildRequests(bidRequests).data) + expect(data.regs).to.not.be.undefined; + expect(data.regs.coppa).to.equal(1); + }); + + it('sends schain', function () { + const data = JSON.parse(spec.buildRequests(bidRequests).data); + expect(data).to.not.be.undefined; + expect(data.source).to.not.be.undefined; + expect(data.source.ext).to.not.be.undefined; + expect(data.source.ext.schain).to.not.be.undefined; + expect(data.source.ext.schain.complete).to.equal(1); + expect(data.source.ext.schain.ver).to.equal('1.0'); + expect(data.source.ext.schain.nodes).to.not.be.undefined; + expect(data.source.ext.schain.nodes).to.lengthOf(1); + expect(data.source.ext.schain.nodes[0].asi).to.equal('exchange1.com'); + expect(data.source.ext.schain.nodes[0].sid).to.equal('1234'); + expect(data.source.ext.schain.nodes[0].hp).to.equal(1); + expect(data.source.ext.schain.nodes[0].rid).to.equal('bid-request-1'); + expect(data.source.ext.schain.nodes[0].name).to.equal('publisher'); + expect(data.source.ext.schain.nodes[0].domain).to.equal('publisher.com'); + }); + + it('sends user eid parameters', function () { + bidRequests[0].userIdAsEids = [{ + source: 'pubcid.org', + uids: [{ + id: 'userid_pubcid' + }] + }, { + source: 'adserver.org', + uids: [{ + id: 'userid_ttd', + ext: { + rtiPartner: 'TDID' + } + }] + } + ]; + + const data = JSON.parse(spec.buildRequests(bidRequests).data); + + expect(data.user).to.not.be.undefined; + expect(data.user.ext).to.not.be.undefined; + expect(data.user.ext.eids).to.not.be.undefined; + expect(data.user.ext.eids).to.deep.equal(bidRequests[0].userIdAsEids); + }); + + it('sends user id parameters', function () { + const userId = { + sharedid: { + id: '01*******', + third: '01E*******' + } + }; + + bidRequests[0].userId = userId; + + const data = JSON.parse(spec.buildRequests(bidRequests).data); + expect(data.user).to.not.be.undefined; + expect(data.user.ext).to.not.be.undefined; + expect(data.user.ext.ids).is.deep.equal(userId); + }); + context('when element is fully in view', function() { it('returns 100', function() { Object.assign(element, { width: 600, height: 400 }); diff --git a/test/spec/modules/brightcomSSPBidAdapter_spec.js b/test/spec/modules/brightcomSSPBidAdapter_spec.js new file mode 100644 index 00000000000..6f35a7a290b --- /dev/null +++ b/test/spec/modules/brightcomSSPBidAdapter_spec.js @@ -0,0 +1,411 @@ +import { expect } from 'chai'; +import * as utils from 'src/utils.js'; +import { spec } from 'modules/brightcomSSPBidAdapter'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import {config} from '../../../src/config'; + +const URL = 'https://rt.marphezis.com/hb'; + +describe('brightcomSSPBidAdapter', function() { + const adapter = newBidder(spec); + let element, win; + let bidRequests; + let sandbox; + + beforeEach(function() { + element = { + x: 0, + y: 0, + + width: 0, + height: 0, + + getBoundingClientRect: () => { + return { + width: element.width, + height: element.height, + + left: element.x, + top: element.y, + right: element.x + element.width, + bottom: element.y + element.height + }; + } + }; + win = { + document: { + visibilityState: 'visible' + }, + + innerWidth: 800, + innerHeight: 600 + }; + bidRequests = [{ + 'bidder': 'bcmssp', + 'params': { + 'publisherId': 1234567 + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'bidId': '5fb26ac22bde4', + 'bidderRequestId': '4bf93aeb730cb9', + 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e', + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'exchange1.com', + 'sid': '1234', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher', + 'domain': 'publisher.com' + } + ] + }, + }]; + + sandbox = sinon.sandbox.create(); + sandbox.stub(document, 'getElementById').withArgs('adunit-code').returns(element); + sandbox.stub(utils, 'getWindowTop').returns(win); + sandbox.stub(utils, 'getWindowSelf').returns(win); + }); + + afterEach(function() { + sandbox.restore(); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'bcmssp', + 'params': { + 'publisherId': 1234567 + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'bidId': '5fb26ac22bde4', + 'bidderRequestId': '4bf93aeb730cb9', + 'auctionId': 'ffe9a1f7-7b67-4bda-a8e0-9ee5dc9f442e', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when publisherId not passed correctly', function () { + bid.params.publisherId = undefined; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when require params are not passed', function () { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('sends bid request to our endpoint via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.method).to.equal('POST'); + }); + + it('request url should match our endpoint url', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.equal(URL); + }); + + it('sets the proper banner object', function() { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + }); + + it('accepts a single array as a size', function() { + bidRequests[0].mediaTypes.banner.sizes = [300, 250]; + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}]); + }); + + it('sends bidfloor param if present', function () { + bidRequests[0].params.bidFloor = 0.05; + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].bidfloor).to.equal(0.05); + }); + + it('sends tagid', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].tagid).to.equal('adunit-code'); + }); + + it('sends publisher id', function () { + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.site.publisher.id).to.equal(1234567); + }); + + it('sends gdpr info if exists', function () { + const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + const bidderRequest = { + 'bidderCode': 'bcmssp', + 'auctionId': '1d1a030790a437', + 'bidderRequestId': '22edbae2744bf5', + 'timeout': 3000, + gdprConsent: { + consentString: consentString, + gdprApplies: true + }, + refererInfo: { + page: 'http://example.com/page.html', + domain: 'example.com', + } + }; + bidderRequest.bids = bidRequests; + + const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data); + + expect(data.regs.ext.gdpr).to.exist.and.to.be.a('number'); + expect(data.regs.ext.gdpr).to.equal(1); + expect(data.user.ext.consent).to.exist.and.to.be.a('string'); + expect(data.user.ext.consent).to.equal(consentString); + }); + + it('sends us_privacy', function () { + const bidderRequest = { + uspConsent: '1YYY' + }; + const data = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data) + + expect(data.regs).to.not.equal(null); + expect(data.regs.ext).to.not.equal(null); + expect(data.regs.ext.us_privacy).to.equal('1YYY'); + }); + + it('sends coppa', function () { + sandbox.stub(config, 'getConfig').withArgs('coppa').returns(true); + + const data = JSON.parse(spec.buildRequests(bidRequests).data) + expect(data.regs).to.not.be.undefined; + expect(data.regs.coppa).to.equal(1); + }); + + it('sends schain', function () { + const data = JSON.parse(spec.buildRequests(bidRequests).data); + expect(data).to.not.be.undefined; + expect(data.source).to.not.be.undefined; + expect(data.source.ext).to.not.be.undefined; + expect(data.source.ext.schain).to.not.be.undefined; + expect(data.source.ext.schain.complete).to.equal(1); + expect(data.source.ext.schain.ver).to.equal('1.0'); + expect(data.source.ext.schain.nodes).to.not.be.undefined; + expect(data.source.ext.schain.nodes).to.lengthOf(1); + expect(data.source.ext.schain.nodes[0].asi).to.equal('exchange1.com'); + expect(data.source.ext.schain.nodes[0].sid).to.equal('1234'); + expect(data.source.ext.schain.nodes[0].hp).to.equal(1); + expect(data.source.ext.schain.nodes[0].rid).to.equal('bid-request-1'); + expect(data.source.ext.schain.nodes[0].name).to.equal('publisher'); + expect(data.source.ext.schain.nodes[0].domain).to.equal('publisher.com'); + }); + + it('sends user eid parameters', function () { + bidRequests[0].userIdAsEids = [{ + source: 'pubcid.org', + uids: [{ + id: 'userid_pubcid' + }] + }, { + source: 'adserver.org', + uids: [{ + id: 'userid_ttd', + ext: { + rtiPartner: 'TDID' + } + }] + } + ]; + + const data = JSON.parse(spec.buildRequests(bidRequests).data); + + expect(data.user).to.not.be.undefined; + expect(data.user.ext).to.not.be.undefined; + expect(data.user.ext.eids).to.not.be.undefined; + expect(data.user.ext.eids).to.deep.equal(bidRequests[0].userIdAsEids); + }); + + it('sends user id parameters', function () { + const userId = { + sharedid: { + id: '01*******', + third: '01E*******' + } + }; + + bidRequests[0].userId = userId; + + const data = JSON.parse(spec.buildRequests(bidRequests).data); + expect(data.user).to.not.be.undefined; + expect(data.user.ext).to.not.be.undefined; + expect(data.user.ext.ids).is.deep.equal(userId); + }); + + context('when element is fully in view', function() { + it('returns 100', function() { + Object.assign(element, { width: 600, height: 400 }); + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(100); + }); + }); + + context('when element is out of view', function() { + it('returns 0', function() { + Object.assign(element, { x: -300, y: 0, width: 207, height: 320 }); + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(0); + }); + }); + + context('when element is partially in view', function() { + it('returns percentage', function() { + Object.assign(element, { width: 800, height: 800 }); + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(75); + }); + }); + + context('when width or height of the element is zero', function() { + it('try to use alternative values', function() { + Object.assign(element, { width: 0, height: 0 }); + bidRequests[0].mediaTypes.banner.sizes = [[800, 2400]]; + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(25); + }); + }); + + context('when nested iframes', function() { + it('returns \'na\'', function() { + Object.assign(element, { width: 600, height: 400 }); + + utils.getWindowTop.restore(); + utils.getWindowSelf.restore(); + sandbox.stub(utils, 'getWindowTop').returns(win); + sandbox.stub(utils, 'getWindowSelf').returns({}); + + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal('na'); + }); + }); + + context('when tab is inactive', function() { + it('returns 0', function() { + Object.assign(element, { width: 600, height: 400 }); + + utils.getWindowTop.restore(); + win.document.visibilityState = 'hidden'; + sandbox.stub(utils, 'getWindowTop').returns(win); + + const request = spec.buildRequests(bidRequests); + const payload = JSON.parse(request.data); + expect(payload.imp[0].banner.ext.viewability).to.equal(0); + }); + }); + }); + + describe('interpretResponse', function () { + let response; + beforeEach(function () { + response = { + body: { + 'id': '37386aade21a71', + 'seatbid': [{ + 'bid': [{ + 'id': '376874781', + 'impid': '283a9f4cd2415d', + 'price': 0.35743275, + 'nurl': '', + 'adm': '', + 'w': 300, + 'h': 250, + 'adomain': ['example.com'] + }] + }] + } + }; + }); + + it('should get the correct bid response', function () { + let expectedResponse = [{ + 'requestId': '283a9f4cd2415d', + 'cpm': 0.35743275, + 'width': 300, + 'height': 250, + 'creativeId': '376874781', + 'currency': 'USD', + 'netRevenue': true, + 'mediaType': 'banner', + 'ad': `
`, + 'ttl': 60, + 'meta': { + 'advertiserDomains': ['example.com'] + } + }]; + + let result = spec.interpretResponse(response); + expect(result[0]).to.deep.equal(expectedResponse[0]); + }); + + it('crid should default to the bid id if not on the response', function () { + let expectedResponse = [{ + 'requestId': '283a9f4cd2415d', + 'cpm': 0.35743275, + 'width': 300, + 'height': 250, + 'creativeId': response.body.seatbid[0].bid[0].id, + 'currency': 'USD', + 'netRevenue': true, + 'mediaType': 'banner', + 'ad': `
`, + 'ttl': 60, + 'meta': { + 'advertiserDomains': ['example.com'] + } + }]; + + let result = spec.interpretResponse(response); + expect(result[0]).to.deep.equal(expectedResponse[0]); + }); + + it('handles empty bid response', function () { + let response = { + body: '' + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs ', () => { + let syncOptions = {iframeEnabled: true, pixelEnabled: true}; + + it('should not return', () => { + let returnStatement = spec.getUserSyncs(syncOptions, []); + expect(returnStatement).to.be.empty; + }); + }); +}); diff --git a/test/spec/modules/browsiBidAdapter_spec.js b/test/spec/modules/browsiBidAdapter_spec.js new file mode 100644 index 00000000000..9693972fd7f --- /dev/null +++ b/test/spec/modules/browsiBidAdapter_spec.js @@ -0,0 +1,212 @@ +import {ENDPOINT, spec} from 'modules/browsiBidAdapter.js'; +import {config} from 'src/config.js'; +import {VIDEO, BANNER} from 'src/mediaTypes.js'; + +const {expect} = require('chai'); +const DATA = 'brwvidtag'; +const ADAPTER = '__bad'; + +describe('browsi Bid Adapter Test', function () { + describe('isBidRequestValid', function () { + let mediaTypes; + let bid; + beforeEach(function () { + mediaTypes = {}; + mediaTypes[VIDEO] = {}; + bid = { + 'params': { + 'pubId': '1234567', + 'tagId': '1' + }, + 'mediaTypes': mediaTypes + }; + }); + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should return false when missing pubId', function () { + delete bid.params.pubId; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + it('should return false when missing tagId', function () { + delete bid.params.tagId; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + it('should return false when missing params', function () { + delete bid.params; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + it('should return false when params have invalid type', function () { + bid.params.tagId = 1; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + it('should return false when video mediaType is missing', function () { + delete bid.mediaTypes[VIDEO]; + bid.mediaTypes[BANNER] = {} + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let bidRequest; + let bidderRequest; + beforeEach(function () { + window[DATA] = {} + window[DATA][ADAPTER] = {index: 0}; + bidRequest = [ + { + 'params': { + 'pubId': 'browiPubId1', + 'tagId': '2' + }, + 'adUnitCode': 'adUnitCode1', + 'auctionId': 'auctionId1', + 'sizes': [640, 480], + 'bidId': '12345678', + 'requestId': '1234567-3456-4562-7689-98765434A', + ortb2Imp: { + ext: { + tid: '1234567-3456-4562-7689-98765434B', + } + }, + 'schain': {}, + 'mediaTypes': {video: {playerSize: [640, 480]}} + } + ]; + bidderRequest = { + 'bidderRequestId': 'bidderRequestId1', + 'refererInfo': { + 'canonicalUrl': null, + 'page': 'https://browsi.com', + 'domain': 'browsi.com', + 'ref': null, + 'numIframes': 0, + 'reachedTop': true, + 'isAmp': false, + 'stack': ['https://browsi.com'] + }, + 'gdprConsent': { + consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA', + gdprApplies: true + }, + 'uspConsent': '1YYY' + }; + }); + afterEach(function() { + window[DATA] = undefined; + config.resetConfig(); + }); + it('should return an array of requests with single request', function () { + const requests = spec.buildRequests(bidRequest, bidderRequest); + expect(requests.length).to.equal(1); + const request = requests[0]; + const inputRequest = bidRequest[0]; + const requestToExpect = { + method: 'POST', + url: ENDPOINT, + data: { + requestId: bidderRequest.bidderRequestId, + bidId: inputRequest.bidId, + timeout: 3000, + baData: window[DATA][ADAPTER], + referer: bidderRequest.refererInfo.page, + gdpr: bidderRequest.gdprConsent, + ccpa: bidderRequest.uspConsent, + sizes: inputRequest.sizes, + video: {playerSize: [640, 480]}, + aUCode: inputRequest.adUnitCode, + aID: inputRequest.auctionId, + tID: inputRequest.ortb2Imp.ext.tid, + schain: inputRequest.schain, + params: inputRequest.params + } + } + assert.deepEqual(request, requestToExpect); + }); + it('should pass on timeout in bidderRequest', function() { + bidderRequest.timeout = 8000; + const requests = spec.buildRequests(bidRequest, bidderRequest); + expect(requests[0].data.timeout).to.equal(8000); + }); + it('should pass timeout in config', function() { + config.setConfig({'bidderTimeout': 6000}); + const requests = spec.buildRequests(bidRequest, bidderRequest); + expect(requests[0].data.timeout).to.equal(6000); + }); + }); + + describe('interpretResponse', function () { + let bidRequest = { + 'url': ENDPOINT, + 'data': { + 'bidId': 'bidId1', + } + }; + let serverResponse = {}; + serverResponse.body = { + bidId: 'bidId1', + w: 300, + h: 250, + vXml: 'vastXml', + vUrl: 'vastUrl', + cpm: 1, + cur: 'USD', + ttl: 10000, + someExtraParams: 8, + } + + it('should return a valid response', function () { + const bidResponses = spec.interpretResponse(serverResponse, bidRequest); + expect(bidResponses.length).to.equal(1); + const actualBidResponse = bidResponses[0]; + const expectedBidResponse = { + requestId: bidRequest.data.bidId, + bidId: 'bidId1', + width: 300, + height: 250, + vastXml: 'vastXml', + vastUrl: 'vastUrl', + cpm: 1, + currency: 'USD', + ttl: 10000, + someExtraParams: 8, + mediaType: VIDEO + }; + + assert.deepEqual(actualBidResponse, expectedBidResponse); + }); + }); + + describe('getUserSyncs', function () { + const bidResponse = { + userSyncs: [ + {url: 'syncUrl1', type: 'image'}, + {url: 'http://syncUrl2', type: 'iframe'} + ] + } + let serverResponse = [ + {body: bidResponse} + ]; + it('should return iframe type userSync', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, serverResponse[0]); + expect(userSyncs.length).to.equal(1); + let userSync = userSyncs[0]; + expect(userSync.url).to.equal('http://syncUrl2'); + expect(userSync.type).to.equal('iframe'); + }); + it('should return image type userSyncs', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, serverResponse[0]); + let userSync = userSyncs[0]; + expect(userSync.url).to.equal('http://syncUrl1'); + expect(userSync.type).to.equal('image'); + }); + it('should handle multiple server responses', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, serverResponse); + expect(userSyncs.length).to.equal(1); + }); + it('should return empty userSyncs', function () { + let userSyncs = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}, serverResponse); + expect(userSyncs.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/browsiRtdProvider_spec.js b/test/spec/modules/browsiRtdProvider_spec.js index c36b48c5105..75120aa7505 100644 --- a/test/spec/modules/browsiRtdProvider_spec.js +++ b/test/spec/modules/browsiRtdProvider_spec.js @@ -3,6 +3,7 @@ import {makeSlot} from '../integration/faker/googletag.js'; import * as utils from '../../../src/utils' import * as events from '../../../src/events'; import * as sinon from 'sinon'; +import {sendPageviewEvent} from '../../../modules/browsiRtdProvider.js'; describe('browsi Real time data sub module', function () { const conf = { @@ -160,7 +161,19 @@ describe('browsi Real time data sub module', function () { }) }) - describe('should emit billable event', function () { + describe('should emit ad request billable event', function () { + before(() => { + const data = { + p: { + 'adUnit1': {ps: {0: 0.234}}, + 'adUnit2': {ps: {0: 0.134}}}, + kn: 'bv', + pmd: undefined, + bet: 'AD_REQUEST' + }; + browsiRTD.setData(data); + }) + beforeEach(() => { eventsEmitSpy.resetHistory(); }) @@ -232,4 +245,31 @@ describe('browsi Real time data sub module', function () { expect(callArguments).to.eql(expectedCall); }) }) + + describe('should emit pageveiw billable event', function () { + beforeEach(() => { + eventsEmitSpy.resetHistory(); + }) + it('should send event if type is correct', function () { + sendPageviewEvent('PAGEVIEW') + const pageViewEvent = new CustomEvent('browsi_pageview', {}); + window.dispatchEvent(pageViewEvent); + const expectedCall = { + vendor: 'browsi', + type: 'pageview', + } + + expect(eventsEmitSpy.callCount).to.equal(1); + const callArguments = eventsEmitSpy.getCalls()[0].args[1]; + // billing id is random, we can't check its value + delete callArguments['billingId']; + expect(callArguments).to.eql(expectedCall); + }) + it('should not send event if type is incorrect', function () { + sendPageviewEvent('AD_REQUEST'); + sendPageviewEvent('INACTIVE'); + sendPageviewEvent(undefined); + expect(eventsEmitSpy.callCount).to.equal(0); + }) + }) }); diff --git a/test/spec/modules/byDataAnalyticsAdapter_spec.js b/test/spec/modules/byDataAnalyticsAdapter_spec.js index 90b4e1d53a6..c680c687a71 100644 --- a/test/spec/modules/byDataAnalyticsAdapter_spec.js +++ b/test/spec/modules/byDataAnalyticsAdapter_spec.js @@ -9,18 +9,19 @@ const initOptions = { logFrequency: 1, }; let userData = { - userId: '5da77-ec87-277b-8e7a5', - client_id: 'asc00000', - plateform_name: 'Macintosh', - os_version: 10.157, - browser_name: 'Chrome', - browser_version: 92.04515107, - screen_size: { - width: 1440, - height: 900 + 'uid': '271a8-2b86-f4a4-f59bc', + 'cid': 'asc00000', + 'pid': 'www.letsrun.com', + 'os': 'Macintosh', + 'osv': 10.157, + 'br': 'Chrome', + 'brv': 103, + 'ss': { + 'width': 1792, + 'height': 1120 }, - device_type: 'Desktop', - time_zone: 'Asia/Calcutta' + 'de': 'Desktop', + 'tz': 'Asia/Calcutta' }; let bidTimeoutArgs = [{ auctionId, @@ -39,6 +40,18 @@ let noBidArgs = { src: 'client', transactionId: 'c8ee3914-1ee0-4ce6-9126-748d5692188c' } +let bidWonArgs = { + auctionId, + adUnitCode: 'div-gpt-ad-mrec1', + size: '300x250', + requestId: '15c86b6c10d3746', + bidder: 'appnexus', + timeToRespond: 114, + currency: 'USD', + mediaType: 'display', + cpm: 0.50 +} + let auctionEndArgs = { adUnitCodes: ['div-gpt-ad-mrec1'], adUnits: [{ @@ -74,21 +87,54 @@ let auctionEndArgs = { }] } let expectedDataArgs = { - visitor_data: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI1ZGE3Ny1lYzg3LTI3N2ItOGU3YTUiLCJjbGllbnRfaWQiOiJhc2MwMDAwMCIsInBsYXRlZm9ybV9uYW1lIjoiTWFjaW50b3NoIiwib3NfdmVyc2lvbiI6MTAuMTU3LCJicm93c2VyX25hbWUiOiJDaHJvbWUiLCJicm93c2VyX3ZlcnNpb24iOjkyLjA0NTE1MTA3LCJzY3JlZW5fc2l6ZSI6eyJ3aWR0aCI6MTQ0MCwiaGVpZ2h0Ijo5MDB9LCJkZXZpY2VfdHlwZSI6IkRlc2t0b3AiLCJ0aW1lX3pvbmUiOiJBc2lhL0NhbGN1dHRhIn0.jNKjsb3Q-ZjkVMcbss_dQFOmu_GdkGqd7t9MbRmqlG4YEMorcJHhUVmUuPi-9pKvC9_t4XlgjED90UieCvdxCQ', - auction_id: auctionId, - auction_start: 1627973484504, + visitor_data: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyNzFhOC0yYjg2LWY0YTQtZjU5YmMiLCJjaWQiOiJhc2MwMDAwMCIsInBpZCI6Ind3dy5sZXRzcnVuLmNvbSIsIm9zIjoiTWFjaW50b3NoIiwib3N2IjoxMC4xNTcsImJyIjoiQ2hyb21lIiwiYnJ2IjoxMDMsInNzIjp7IndpZHRoIjoxNzkyLCJoZWlnaHQiOjExMjB9LCJkZSI6IkRlc2t0b3AiLCJ0eiI6IkFzaWEvQ2FsY3V0dGEifQ.Oj3qnh--t06XO-foVmrMJCGqFfOBed09A-f7LZX5rtfBf4w1_RNRZ4F3on4TMPLonSa7GgzbcEfJS9G_amnleQ', + aid: auctionId, + as: 1627973484504, auctionData: [ { - 'adUnit': 'div-gpt-ad-mrec1', - 'size': '300x250', - 'media_type': 'display', - 'bids_bidder': 'appnexus', - 'bids_bid_id': '14480e9832f2d2b' + au: 'div-gpt-ad-mrec1', + auc: 'div-gpt-ad-mrec1', + aus: '300x250', + bidadv: 'appnexus', + bid: '14480e9832f2d2b', + inb: 1, + ito: 0, + ipwb: 0, + iwb: 0, + mt: 'display', }, { - 'adUnit': 'div-gpt-ad-mrec1', - 'size': '250x250', - 'media_type': 'display', - 'bids_bidder': 'appnexus', - 'bids_bid_id': '14480e9832f2d2b' + au: 'div-gpt-ad-mrec1', + auc: 'div-gpt-ad-mrec1', + aus: '250x250', + bidadv: 'appnexus', + bid: '14480e9832f2d2b', + inb: 1, + ito: 0, + ipwb: 0, + iwb: 0, + mt: 'display', + }] +} +let expectedBidWonArgs = { + visitor_data: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyNzFhOC0yYjg2LWY0YTQtZjU5YmMiLCJjaWQiOiJhc2MwMDAwMCIsInBpZCI6Ind3dy5sZXRzcnVuLmNvbSIsIm9zIjoiTWFjaW50b3NoIiwib3N2IjoxMC4xNTcsImJyIjoiQ2hyb21lIiwiYnJ2IjoxMDMsInNzIjp7IndpZHRoIjoxNzkyLCJoZWlnaHQiOjExMjB9LCJkZSI6IkRlc2t0b3AiLCJ0eiI6IkFzaWEvQ2FsY3V0dGEifQ.Oj3qnh--t06XO-foVmrMJCGqFfOBed09A-f7LZX5rtfBf4w1_RNRZ4F3on4TMPLonSa7GgzbcEfJS9G_amnleQ', + aid: auctionId, + as: '', + auctionData: [{ + au: 'div-gpt-ad-mrec1', + auc: 'div-gpt-ad-mrec1', + aus: '300x250', + bid: '15c86b6c10d3746', + bidadv: 'appnexus', + br_pb_mg: 0.50, + br_tr: 114, + bradv: 'appnexus', + brid: '15c86b6c10d3746', + brs: '300x250', + cur: 'USD', + inb: 0, + ito: 0, + ipwb: 1, + iwb: 1, + mt: 'display', }] } @@ -121,19 +167,25 @@ describe('byData Analytics Adapter ', () => { }); describe('track-events', function () { - ascAdapter.enableAnalytics(initOptions) - // Step 1: Initialize adapter - adapterManager.enableAnalytics({ - provider: 'bydata', - options: initOptions + before(() => { + ascAdapter.enableAnalytics(initOptions) + // Step 1: Initialize adapter + adapterManager.enableAnalytics({ + provider: 'bydata', + options: initOptions + }); }); it('sends and formatted auction data ', function () { events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeoutArgs); events.emit(constants.EVENTS.NO_BID, noBidArgs); + events.emit(constants.EVENTS.BID_WON, bidWonArgs) var userToken = ascAdapter.getVisitorData(userData); var newAuData = ascAdapter.dataProcess(auctionEndArgs); + var newBwData = ascAdapter.getBidWonData(bidWonArgs); newAuData['visitor_data'] = userToken; + newBwData['visitor_data'] = userToken; expect(newAuData).to.deep.equal(expectedDataArgs); + expect(newBwData).to.deep.equal(expectedBidWonArgs); }); }); }); diff --git a/test/spec/modules/c1xBidAdapter_spec.js b/test/spec/modules/c1xBidAdapter_spec.js new file mode 100644 index 00000000000..315680cba26 --- /dev/null +++ b/test/spec/modules/c1xBidAdapter_spec.js @@ -0,0 +1,189 @@ +import { expect } from 'chai'; +import { newBidder } from 'src/adapters/bidderFactory'; +import { c1xAdapter } from '../../../modules/c1xBidAdapter.js'; + +const ENDPOINT = 'https://hb-stg.c1exchange.com/ht'; +const BIDDER_CODE = 'c1x'; + +describe('C1XAdapter', () => { + const adapter = newBidder(c1xAdapter); + describe('inherited functions', () => { + it('exists and is a function', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + describe('isBidRequestValid', () => { + let bid = { + 'bidder': BIDDER_CODE, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'params': { + 'placementId': 'div-gpt-ad-1654594619717-0' + } + }; + it('should return true when required params found', function () { + expect(c1xAdapter.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when placementId not passed correctly', function () { + bid.params.placementId = undefined; + expect(c1xAdapter.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when require params are not passed', function () { + let bid = Object.assign({}, bid); + bid.params = {}; + expect(c1xAdapter.isBidRequestValid(bid)).to.equal(false); + }); + }); + describe('buildRequests', () => { + let bidRequests = [ + { + 'bidder': BIDDER_CODE, + 'params': { + 'placementId': 'div-gpt-ad-1654594619717-0', + 'dealId': '1233' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], [300, 600] + ] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + const parseRequest = (data) => { + const parsedData = '{"' + data.replace(/=|&/g, (foundChar) => { + if (foundChar == '=') return '":"'; + else if (foundChar == '&') return '","'; + }) + '"}' + return parsedData; + }; + it('sends bid request to ENDPOINT via GET', () => { + const request = c1xAdapter.buildRequests(bidRequests); + expect(request[0].url).to.contain(ENDPOINT); + expect(request[0].method).to.equal('GET'); + }); + it('should generate correct bid Id tag', () => { + const request = c1xAdapter.buildRequests(bidRequests)[0]; + expect(request.bids[0].adUnitCode).to.equal('adunit-code'); + expect(request.bids[0].bidId).to.equal('30b31c1838de1e'); + }); + it('should convert params to proper form and attach to request', () => { + const request = c1xAdapter.buildRequests(bidRequests)[0]; + const originalPayload = parseRequest(request.data); + const payloadObj = JSON.parse(originalPayload); + expect(payloadObj.adunits).to.equal('1'); + expect(payloadObj.a1s).to.equal('300x250,300x600'); + expect(payloadObj.a1).to.equal('adunit-code'); + expect(payloadObj.a1d).to.equal('1233'); + }); + it('should convert floor price to proper form and attach to request', () => { + let bidRequest = Object.assign({}, + bidRequests[0], + { + 'params': { + 'placementId': 'div-gpt-ad-1654594619717-0', + 'dealId': '1233', + 'floorPriceMap': { + '300x250': 4.35 + } + } + }); + const request = c1xAdapter.buildRequests([bidRequest])[0]; + const originalPayload = parseRequest(request.data); + const payloadObj = JSON.parse(originalPayload); + expect(payloadObj.a1p).to.equal('4.35'); + }); + it('should convert pageurl to proper form and attach to request', () => { + let bidRequest = Object.assign({}, + bidRequests[0], + { + 'params': { + 'placementId': 'div-gpt-ad-1654594619717-0', + 'dealId': '1233', + 'pageurl': 'http://c1exchange.com/' + } + }); + + let bidderRequest = { + 'bidderCode': 'c1x' + } + bidderRequest.bids = bidRequests; + const request = c1xAdapter.buildRequests([bidRequest], bidderRequest)[0]; + const originalPayload = parseRequest(request.data); + const payloadObj = JSON.parse(originalPayload); + expect(payloadObj.pageurl).to.equal('http://c1exchange.com/'); + }); + + it('should convert GDPR Consent to proper form and attach to request', () => { + let consentString = 'BOP2gFWOQIFovABABAENBGAAAAAAMw'; + let bidderRequest = { + 'bidderCode': 'c1x', + 'gdprConsent': { + 'consentString': consentString, + 'gdprApplies': true + } + } + bidderRequest.bids = bidRequests; + + const request = c1xAdapter.buildRequests(bidRequests, bidderRequest)[0]; + const originalPayload = parseRequest(request.data); + const payloadObj = JSON.parse(originalPayload); + expect(payloadObj['consent_string']).to.equal('BOP2gFWOQIFovABABAENBGAAAAAAMw'); + expect(payloadObj['consent_required']).to.equal('true'); + }); + }); + + describe('interpretResponse', () => { + let response = { + 'bid': true, + 'cpm': 1.5, + 'ad': '', + 'width': 300, + 'height': 250, + 'crid': '8888', + 'adId': 'c1x-test', + 'bidType': 'GROSS_BID' + }; + it('should get correct bid response', () => { + let expectedResponse = [ + { + width: 300, + height: 250, + cpm: 1.5, + ad: '', + creativeId: '8888', + currency: 'USD', + ttl: 300, + netRevenue: false, + requestId: 'yyyy' + } + ]; + let bidderRequest = {}; + bidderRequest.bids = [ + { + adUnitCode: 'c1x-test', + bidId: 'yyyy' + } + ]; + let result = c1xAdapter.interpretResponse({ body: [response] }, bidderRequest); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + }); + it('handles nobid responses', () => { + let response = { + bid: false, + adId: 'c1x-test' + }; + let bidderRequest = {}; + let result = c1xAdapter.interpretResponse({ body: [response] }, bidderRequest); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/cadentApertureMXBidAdapter_spec.js b/test/spec/modules/cadentApertureMXBidAdapter_spec.js new file mode 100644 index 00000000000..3ccb5405552 --- /dev/null +++ b/test/spec/modules/cadentApertureMXBidAdapter_spec.js @@ -0,0 +1,886 @@ +import * as utils from 'src/utils.js'; + +import { expect } from 'chai'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { spec } from 'modules/cadentApertureMXBidAdapter.js'; + +describe('cadent_aperture_mx Adapter', function () { + describe('callBids', function () { + const adapter = newBidder(spec); + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + describe('banner request validity', function () { + let bid = { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let badBid = { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': { + } + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let noBid = {}; + let otherBid = { + 'bidder': 'emxdigital', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250]] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let noMediaSizeBid = { + 'bidder': 'emxdigital', + 'params': { + 'tagid': '25251' + }, + 'mediaTypes': { + 'banner': {} + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(badBid)).to.equal(false); + expect(spec.isBidRequestValid(noBid)).to.equal(false); + expect(spec.isBidRequestValid(otherBid)).to.equal(false); + expect(spec.isBidRequestValid(noMediaSizeBid)).to.equal(false); + }); + }); + + describe('video request validity', function () { + let bid = { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + let noInstreamBid = { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251', + 'video': { + 'protocols': [1, 7] + } + }, + 'mediaTypes': { + 'video': { + 'context': 'something_random' + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + + let outstreamBid = { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(noInstreamBid)).to.equal(false); + expect(spec.isBidRequestValid(outstreamBid)).to.equal(true); + }); + + it('should contain tagid param', function () { + expect(spec.isBidRequestValid({ + bidder: 'cadent_aperture_mx', + params: {}, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + })).to.equal(false); + expect(spec.isBidRequestValid({ + bidder: 'cadent_aperture_mx', + params: { + tagid: '' + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + })).to.equal(false); + expect(spec.isBidRequestValid({ + bidder: 'cadent_aperture_mx', + params: { + tagid: '123' + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + })).to.equal(true); + }); + }); + }); + + describe('buildRequests', function () { + let bidderRequest = { + 'bidderCode': 'cadent_aperture_mx', + 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', + 'bidderRequestId': '22edbae3120bf6', + 'timeout': 1500, + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'page': 'https://example.com/index.html?pbjs_debug=true', + 'domain': 'example.com', + 'ref': 'https://referrer.com' + }, + 'bids': [{ + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251' + }, + 'adUnitCode': 'adunit-code', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [300, 250], + [300, 600] + ] + } + }, + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'ortb2Imp': { + 'ext': { + 'tid': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ed', + }, + }, + }] + }; + let request = spec.buildRequests(bidderRequest.bids, bidderRequest); + + describe('non-gpp tests', function() { + it('sends bid request to ENDPOINT via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('contains the correct options', function () { + expect(request.options.withCredentials).to.equal(true); + }); + + it('contains a properly formatted endpoint url', function () { + const url = request.url.split('?'); + const queryParams = url[1].split('&'); + expect(queryParams[0]).to.match(new RegExp('^t=\d*', 'g')); + expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g')); + }); + + it('builds bidfloor value from bid param when getFloor function does not exist', function () { + const bidRequestWithFloor = utils.deepClone(bidderRequest.bids); + bidRequestWithFloor[0].params.bidfloor = 1; + const requestWithFloor = spec.buildRequests(bidRequestWithFloor, bidderRequest); + const data = JSON.parse(requestWithFloor.data); + expect(data.imp[0].bidfloor).to.equal(bidRequestWithFloor[0].params.bidfloor); + }); + + it('builds bidfloor value from getFloor function when it exists', function () { + const floorResponse = { currency: 'USD', floor: 3 }; + const bidRequestWithGetFloor = utils.deepClone(bidderRequest.bids); + bidRequestWithGetFloor[0].getFloor = () => floorResponse; + const requestWithGetFloor = spec.buildRequests(bidRequestWithGetFloor, bidderRequest); + const data = JSON.parse(requestWithGetFloor.data); + expect(data.imp[0].bidfloor).to.equal(3); + }); + + it('builds bidfloor value from getFloor when both floor and getFloor function exists', function () { + const floorResponse = { currency: 'USD', floor: 3 }; + const bidRequestWithBothFloors = utils.deepClone(bidderRequest.bids); + bidRequestWithBothFloors[0].params.bidfloor = 1; + bidRequestWithBothFloors[0].getFloor = () => floorResponse; + const requestWithBothFloors = spec.buildRequests(bidRequestWithBothFloors, bidderRequest); + const data = JSON.parse(requestWithBothFloors.data); + expect(data.imp[0].bidfloor).to.equal(3); + }); + + it('empty bidfloor value when floor and getFloor is not defined', function () { + const bidRequestWithoutFloor = utils.deepClone(bidderRequest.bids); + const requestWithoutFloor = spec.buildRequests(bidRequestWithoutFloor, bidderRequest); + const data = JSON.parse(requestWithoutFloor.data); + expect(data.imp[0].bidfloor).to.not.exist; + }); + + it('builds request properly', function () { + const data = JSON.parse(request.data); + expect(Array.isArray(data.imp)).to.equal(true); + expect(data.id).to.equal(bidderRequest.auctionId); + expect(data.imp.length).to.equal(1); + expect(data.imp[0].id).to.equal('30b31c2501de1e'); + expect(data.imp[0].tid).to.equal('d7b773de-ceaa-484d-89ca-d9f51b8d61ed'); + expect(data.imp[0].tagid).to.equal('25251'); + expect(data.imp[0].secure).to.equal(0); + expect(data.imp[0].vastXml).to.equal(undefined); + }); + + it('populates id even when auctionId is not available', function () { + // addressing https://github.com/prebid/Prebid.js/issues/9781 + bidderRequest.auctionId = null; + request = spec.buildRequests(bidderRequest.bids, bidderRequest); + + const data = JSON.parse(request.data); + expect(data.id).not.to.be.null; + expect(data.id).not.to.equal(bidderRequest.auctionId); + }); + + it('properly sends site information and protocol', function () { + request = spec.buildRequests(bidderRequest.bids, bidderRequest); + request = JSON.parse(request.data); + expect(request.site).to.have.property('domain', 'example.com'); + expect(request.site).to.have.property('page', 'https://example.com/index.html?pbjs_debug=true'); + expect(request.site).to.have.property('ref', 'https://referrer.com'); + }); + + it('builds correctly formatted request banner object', function () { + let bidRequestWithBanner = utils.deepClone(bidderRequest.bids); + let request = spec.buildRequests(bidRequestWithBanner, bidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].video).to.equal(undefined); + expect(data.imp[0].banner).to.exist.and.to.be.a('object'); + expect(data.imp[0].banner.w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); + expect(data.imp[0].banner.h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); + expect(data.imp[0].banner.format[0].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); + expect(data.imp[0].banner.format[0].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); + expect(data.imp[0].banner.format[1].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][0]); + expect(data.imp[0].banner.format[1].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][1]); + }); + + it('builds correctly formatted request video object for instream', function () { + let bidRequestWithVideo = utils.deepClone(bidderRequest.bids); + bidRequestWithVideo[0].mediaTypes = { + video: { + context: 'instream', + playerSize: [[640, 480]] + }, + }; + bidRequestWithVideo[0].params.video = {}; + let request = spec.buildRequests(bidRequestWithVideo, bidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist.and.to.be.a('object'); + expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]); + expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]); + }); + + it('builds correctly formatted request video object for outstream', function () { + let bidRequestWithOutstreamVideo = utils.deepClone(bidderRequest.bids); + bidRequestWithOutstreamVideo[0].mediaTypes = { + video: { + context: 'outstream', + playerSize: [[640, 480]] + }, + }; + bidRequestWithOutstreamVideo[0].params.video = {}; + let request = spec.buildRequests(bidRequestWithOutstreamVideo, bidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist.and.to.be.a('object'); + expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]); + expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]); + }); + + it('shouldn\'t contain a user obj without GDPR information', function () { + let request = spec.buildRequests(bidderRequest.bids, bidderRequest) + request = JSON.parse(request.data) + expect(request).to.not.have.property('user'); + }); + + it('should have the right gdpr info when enabled', function () { + let consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A=='; + const gdprBidderRequest = utils.deepClone(bidderRequest); + gdprBidderRequest.gdprConsent = { + 'consentString': consentString, + 'gdprApplies': true + }; + let request = spec.buildRequests(gdprBidderRequest.bids, gdprBidderRequest); + + request = JSON.parse(request.data) + expect(request.regs.ext).to.have.property('gdpr', 1); + expect(request.user.ext).to.have.property('consent', consentString); + }); + + it('should\'t contain consent string if gdpr isn\'t applied', function () { + const nonGdprBidderRequest = utils.deepClone(bidderRequest); + nonGdprBidderRequest.gdprConsent = { + 'gdprApplies': false + }; + let request = spec.buildRequests(nonGdprBidderRequest.bids, nonGdprBidderRequest); + request = JSON.parse(request.data) + expect(request.regs.ext).to.have.property('gdpr', 0); + expect(request).to.not.have.property('user'); + }); + + it('should add us privacy info to request', function() { + const uspBidderRequest = utils.deepClone(bidderRequest); + let consentString = '1YNN'; + uspBidderRequest.uspConsent = consentString; + let request = spec.buildRequests(uspBidderRequest.bids, uspBidderRequest); + request = JSON.parse(request.data); + expect(request.us_privacy).to.exist; + expect(request.us_privacy).to.exist.and.to.equal(consentString); + }); + + it('should add schain object to request', function() { + const schainBidderRequest = utils.deepClone(bidderRequest); + schainBidderRequest.bids[0].schain = { + 'complete': 1, + 'ver': '1.0', + 'nodes': [ + { + 'asi': 'testing.com', + 'sid': 'abc', + 'hp': 1 + } + ] + }; + let request = spec.buildRequests(schainBidderRequest.bids, schainBidderRequest); + request = JSON.parse(request.data); + expect(request.source.ext.schain).to.exist; + expect(request.source.ext.schain).to.have.property('complete', 1); + expect(request.source.ext.schain).to.have.property('ver', '1.0'); + expect(request.source.ext.schain.nodes[0].asi).to.equal(schainBidderRequest.bids[0].schain.nodes[0].asi); + }); + + it('should add liveramp identitylink id to request', () => { + const idl_env = '123'; + const bidRequestWithID = utils.deepClone(bidderRequest); + bidRequestWithID.userId = { idl_env }; + let requestWithID = spec.buildRequests(bidRequestWithID.bids, bidRequestWithID); + requestWithID = JSON.parse(requestWithID.data); + expect(requestWithID.user.ext.eids[0]).to.deep.equal({ + source: 'liveramp.com', + uids: [{ + id: idl_env, + ext: { + rtiPartner: 'idl' + } + }] + }); + }); + + it('should add gpid to request if present', () => { + const gpid = '/12345/my-gpt-tag-0'; + let bid = utils.deepClone(bidderRequest.bids[0]); + bid.ortb2Imp = { ext: { data: { adserver: { adslot: gpid } } } }; + bid.ortb2Imp = { ext: { data: { pbadslot: gpid } } }; + let requestWithGPID = spec.buildRequests([bid], bidderRequest); + requestWithGPID = JSON.parse(requestWithGPID.data); + expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid); + }); + + it('should add UID 2.0 to request', () => { + const uid2 = { id: '456' }; + const bidRequestWithUID = utils.deepClone(bidderRequest); + bidRequestWithUID.userId = { uid2 }; + let requestWithUID = spec.buildRequests(bidRequestWithUID.bids, bidRequestWithUID); + requestWithUID = JSON.parse(requestWithUID.data); + expect(requestWithUID.user.ext.eids[0]).to.deep.equal({ + source: 'uidapi.com', + uids: [{ + id: uid2.id, + ext: { + rtiPartner: 'UID2' + } + }] + }); + }); + }); + + describe('gpp tests', function() { + describe('when gppConsent is not present on bid request', () => { + it('should return request with no gpp or gpp_sid properties', function() { + const gppCompliantBidderRequest = utils.deepClone(bidderRequest); + + let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest); + request = JSON.parse(request.data); + expect(request?.regs?.gpp).to.be.undefined; + expect(request?.regs?.gpp_sid).to.be.undefined; + }); + }); + + describe('when gppConsent is present on bid request', () => { + describe('gppString', () => { + describe('is not defined on request', () => { + it('should return request with gpp undefined', () => { + const gppCompliantBidderRequest = utils.deepClone(bidderRequest); + + let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest); + request = JSON.parse(request.data); + expect(request?.regs?.gpp).to.be.undefined; + }); + }); + + describe('is defined on request', () => { + it('should return request with gpp set correctly', () => { + const gppCompliantBidderRequest = utils.deepClone(bidderRequest); + const gppString = 'abcdefgh'; + gppCompliantBidderRequest.gppConsent = { + gppString + } + + let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest); + request = JSON.parse(request.data); + expect(request.regs.gpp).to.exist.and.to.equal(gppString); + }); + }); + }); + + describe('applicableSections', () => { + describe('is not defined on request', () => { + it('should return request with gpp_sid undefined', () => { + const gppCompliantBidderRequest = utils.deepClone(bidderRequest); + + let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest); + request = JSON.parse(request.data); + expect(request?.regs?.gpp_sid).to.be.undefined; + }); + }); + + describe('is defined on request', () => { + it('should return request with gpp_sid set correctly', () => { + const gppCompliantBidderRequest = utils.deepClone(bidderRequest); + const applicableSections = [8]; + gppCompliantBidderRequest.gppConsent = { + applicableSections + } + + let request = spec.buildRequests(gppCompliantBidderRequest.bids, gppCompliantBidderRequest); + request = JSON.parse(request.data); + expect(request.regs.gpp_sid).to.deep.equal(applicableSections); + }); + }); + }); + }); + }); + }); + + describe('interpretResponse', function () { + let bid = { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '30b31c2501de1e', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }; + + const bid_outstream = { + 'bidderRequest': { + 'bids': [{ + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25251', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '987654321cba', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }, { + 'bidder': 'cadent_aperture_mx', + 'params': { + 'tagid': '25252', + 'video': {} + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [640, 480] + } + }, + 'adUnitCode': 'adunit-code', + 'sizes': [ + [300, 250], + [300, 600] + ], + 'bidId': '987654321dcb', + 'bidderRequestId': '22edbae3120bf6', + 'auctionId': '1d1a01234a475' + }] + } + }; + + const serverResponse = { + 'id': '12819a18-56e1-4256-b836-b69a10202668', + 'seatbid': [{ + 'bid': [{ + 'adid': '123456abcde', + 'adm': '', + 'crid': '3434abab34', + 'h': 250, + 'id': '987654321cba', + 'price': 0.5, + 'ttl': 300, + 'w': 300, + 'adomain': ['example.com'] + }], + 'seat': '1356' + }, { + 'bid': [{ + 'adid': '123456abcdf', + 'adm': '', + 'crid': '3434abab35', + 'h': 600, + 'id': '987654321dcb', + 'price': 0.5, + 'ttl': 300, + 'w': 300 + }] + }] + }; + + const expectedResponse = [{ + 'requestId': '12819a18-56e1-4256-b836-b69a10202668', + 'cpm': 0.5, + 'width': 300, + 'height': 250, + 'creativeId': '3434abab34', + 'dealId': null, + 'currency': 'USD', + 'netRevneue': true, + 'mediaType': 'banner', + 'ad': '', + 'ttl': 300, + 'meta': { + 'advertiserDomains': ['example.com'] + } + }, { + 'requestId': '12819a18-56e1-4256-b836-b69a10202668', + 'cpm': 0.7, + 'width': 300, + 'height': 600, + 'creativeId': '3434abab35', + 'dealId': null, + 'currency': 'USD', + 'netRevneue': true, + 'mediaType': 'banner', + 'ad': '', + 'ttl': 300 + }]; + + it('should properly format bid response', function () { + let result = spec.interpretResponse({ + body: serverResponse + }); + expect(Object.keys(result[0]).length).to.equal(Object.keys(expectedResponse[0]).length); + expect(Object.keys(result[0]).requestId).to.equal(Object.keys(expectedResponse[0]).requestId); + expect(Object.keys(result[0]).bidderCode).to.equal(Object.keys(expectedResponse[0]).bidderCode); + expect(Object.keys(result[0]).cpm).to.equal(Object.keys(expectedResponse[0]).cpm); + expect(Object.keys(result[0]).creativeId).to.equal(Object.keys(expectedResponse[0]).creativeId); + expect(Object.keys(result[0]).width).to.equal(Object.keys(expectedResponse[0]).width); + expect(Object.keys(result[0]).height).to.equal(Object.keys(expectedResponse[0]).height); + expect(Object.keys(result[0]).ttl).to.equal(Object.keys(expectedResponse[0]).ttl); + expect(Object.keys(result[0]).adId).to.equal(Object.keys(expectedResponse[0]).adId); + expect(Object.keys(result[0]).currency).to.equal(Object.keys(expectedResponse[0]).currency); + expect(Object.keys(result[0]).netRevenue).to.equal(Object.keys(expectedResponse[0]).netRevenue); + expect(Object.keys(result[0]).ad).to.equal(Object.keys(expectedResponse[0]).ad); + }); + + it('should return multiple bids', function () { + let result = spec.interpretResponse({ + body: serverResponse + }); + expect(Array.isArray(result.seatbid)) + + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.ad).to.equal(serverResponse.seatbid[0].bid[0].adm); + expect(ad0.cpm).to.equal(serverResponse.seatbid[0].bid[0].price); + expect(ad0.creativeId).to.equal(serverResponse.seatbid[0].bid[0].crid); + expect(ad0.currency).to.equal('USD'); + expect(ad0.netRevenue).to.equal(true); + expect(ad0.requestId).to.equal(serverResponse.seatbid[0].bid[0].id); + expect(ad0.ttl).to.equal(300); + + expect(ad1.ad).to.equal(serverResponse.seatbid[1].bid[0].adm); + expect(ad1.cpm).to.equal(serverResponse.seatbid[1].bid[0].price); + expect(ad1.creativeId).to.equal(serverResponse.seatbid[1].bid[0].crid); + expect(ad1.currency).to.equal('USD'); + expect(ad1.netRevenue).to.equal(true); + expect(ad1.requestId).to.equal(serverResponse.seatbid[1].bid[0].id); + expect(ad1.ttl).to.equal(300); + }); + + it('returns a banner bid for non-xml creatives', function () { + let result = spec.interpretResponse({ + body: serverResponse + }, { bidRequest: bid } + ); + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.mediaType).to.equal('banner'); + expect(ad0.ad.indexOf(''; + vastServerResponse.seatbid[1].bid[0].adm = ''; + + let result = spec.interpretResponse({ + body: vastServerResponse + }, { bidRequest: bid } + ); + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.mediaType).to.equal('video'); + expect(ad0.ad.indexOf(' -1).to.equal(true); + expect(ad0.vastXml).to.equal(vastServerResponse.seatbid[0].bid[0].adm); + expect(ad0.ad).to.exist.and.to.be.a('string'); + expect(ad1.mediaType).to.equal('video'); + expect(ad1.ad.indexOf(' -1).to.equal(true); + expect(ad1.vastXml).to.equal(vastServerResponse.seatbid[1].bid[0].adm); + expect(ad1.ad).to.exist.and.to.be.a('string'); + }); + + it('returns a renderer for outstream video creatives', function () { + const vastServerResponse = utils.deepClone(serverResponse); + vastServerResponse.seatbid[0].bid[0].adm = ''; + vastServerResponse.seatbid[1].bid[0].adm = ''; + let result = spec.interpretResponse({body: vastServerResponse}, bid_outstream); + const ad0 = result[0]; + const ad1 = result[1]; + expect(ad0.renderer).to.exist.and.to.be.a('object'); + expect(ad0.renderer.url).to.equal('https://js.brealtime.com/outstream/1.30.0/bundle.js'); + expect(ad0.renderer.id).to.equal('987654321cba'); + expect(ad1.renderer).to.equal(undefined); + }); + + it('handles nobid responses', function () { + let serverResponse = { + 'bids': [] + }; + + let result = spec.interpretResponse({ + body: serverResponse + }); + expect(result.length).to.equal(0); + }); + + it('should not throw an error when decoding an improperly encoded adm', function () { + const badAdmServerResponse = utils.deepClone(serverResponse); + badAdmServerResponse.seatbid[0].bid[0].adm = '\\<\\/script\\>'; + badAdmServerResponse.seatbid[1].bid[0].adm = '%3F%%3Dcadent%3C3prebid'; + + assert.doesNotThrow(() => spec.interpretResponse({ + body: badAdmServerResponse + })); + }); + + it('returns valid advertiser domains', function () { + const bidResponse = utils.deepClone(serverResponse); + let result = spec.interpretResponse({body: bidResponse}); + expect(result[0].meta.advertiserDomains).to.deep.equal(expectedResponse[0].meta.advertiserDomains); + // case where adomains are not in request + expect(result[1].meta).to.not.exist; + }); + }); + + describe('getUserSyncs', function () { + it('should register the iframe sync url', function () { + let syncs = spec.getUserSyncs({ + iframeEnabled: true + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html') + }); + + it('should pass gdpr params', function () { + let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { + gdprApplies: false, consentString: 'test' + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.contains('gdpr=0'); + expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html?gdpr=0&gdpr_consent=test') + }); + + it('should pass us_privacy string', function () { + let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, { + consentString: 'test', + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.contains('usp=test'); + }); + + it('should pass us_privacy and gdpr strings', function () { + let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, + { + gdprApplies: true, + consentString: 'test' + }, + { + consentString: 'test' + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.contains('gdpr=1'); + expect(syncs[0].url).to.contains('usp=test'); + expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html?gdpr=1&gdpr_consent=test&usp=test') + }); + + it('should pass gpp string and section id', function() { + let syncs = spec.getUserSyncs({iframeEnabled: true}, {}, {}, {}, { + gppString: 'abcdefgs', + applicableSections: [1, 2, 4] + }); + expect(syncs).to.not.be.an('undefined'); + expect(syncs[0].url).to.contains('gpp=abcdefgs') + expect(syncs[0].url).to.contains('gpp_sid=1,2,4') + }); + + it('should pass us_privacy and gdpr string and gpp string', function () { + let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, + { + gdprApplies: true, + consentString: 'test' + }, + { + consentString: 'test' + }, + { + gppString: 'abcdefgs', + applicableSections: [1, 2, 4] + } + ); + expect(syncs).to.not.be.an('undefined'); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.contains('gdpr=1'); + expect(syncs[0].url).to.contains('usp=test'); + expect(syncs[0].url).to.contains('gpp=abcdefgs'); + expect(syncs[0].url).to.equal('https://biddr.brealtime.com/check.html?gdpr=1&gdpr_consent=test&usp=test&gpp=abcdefgs&gpp_sid=1,2,4'); + }); + }); +}); diff --git a/test/spec/modules/carodaBidAdapter_spec.js b/test/spec/modules/carodaBidAdapter_spec.js new file mode 100644 index 00000000000..f575e31e85d --- /dev/null +++ b/test/spec/modules/carodaBidAdapter_spec.js @@ -0,0 +1,494 @@ +// jshint esversion: 6, es3: false, node: true +import { assert } from 'chai'; +import { spec } from 'modules/carodaBidAdapter.js'; +import { config } from 'src/config.js'; +import { createEidsArray } from 'modules/userId/eids.js'; + +describe('Caroda adapter', function () { + let bids = []; + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': 'caroda', + 'params': { + 'ctok': 'adf232eef344' + } + }; + + it('should return true when required params found', function () { + assert(spec.isBidRequestValid(bid)); + + bid.params = { + ctok: 'adf232eef344', + placementId: 'someplacement' + }; + assert(spec.isBidRequestValid(bid)); + }); + + it('should return false when required params are missing', function () { + bid.params = {}; + assert.isFalse(spec.isBidRequestValid(bid)); + + bid.params = { + placementId: 'someplacement' + }; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', function () { + beforeEach(function () { + config.resetConfig(); + delete window.carodaPageViewId; + }); + it('should send request with minimal structure', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { + 'ctok': 'adf232eef344' + } + }]; + window.top.carodaPageViewId = 12345; + const request = spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0]; + assert.equal(request.method, 'POST'); + assert.equal(request.url, 'https://prebid.caroda.io/api/hb?entry_id=12345'); + assert.equal(request.options, undefined); + const data = JSON.parse(request.data) + assert.equal(data.ctok, 'adf232eef344'); + assert.ok(data.site); + assert.ok(data.hb_version); + assert.ok(data.device); + assert.equal(data.price_type, 'net'); + }); + + it('should add test to request, if test is set in parameters', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { + 'ctok': 'adf232eef344', + 'test': 1 + } + }]; + window.top.carodaPageViewId = 12345; + const request = spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0]; + const data = JSON.parse(request.data) + assert.equal(data.test, 1); + }); + + it('should add placement_id to request when available', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { + 'ctok': 'adf232eef344', + 'placementId': 'opzafe342f' + } + }]; + window.top.carodaPageViewId = 12345; + const request = spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0]; + const data = JSON.parse(request.data); + assert.equal(data.placement_id, 'opzafe342f'); + }); + + it('should send info about device', function () { + config.setConfig({ + device: { w: 100, h: 100 } + }); + const validBidRequests = [{ + bid_id: 'bidId', + params: { 'ctok': 'adf232eef344' } + }]; + const data = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.equal(data.device.ua, navigator.userAgent); + assert.equal(data.device.w, 100); + assert.equal(data.device.h, 100); + }); + + it('should pass supply chain object', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: {}, + schain: { + validation: 'strict', + config: { + ver: '1.0' + } + } + }]; + + let data = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.deepEqual(data.schain, { + validation: 'strict', + config: { + ver: '1.0' + } + }); + }); + + it('should send app info', function () { + config.setConfig({ + app: { id: 'appid' }, + }); + const ortb2 = { app: { name: 'appname' } }; + let validBidRequests = [{ + bid_id: 'bidId', + params: { mid: '1000' }, + ortb2 + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' }, ortb2 })[0].data); + assert.equal(request.app.id, 'appid'); + assert.equal(request.app.name, 'appname'); + assert.equal(request.site, undefined); + }); + + it('should send info about the site', function () { + config.setConfig({ + site: { + id: '123123', + publisher: { + domain: 'publisher.domain.com' + } + }, + }); + const ortb2 = { + site: { + publisher: { + name: 'publisher\'s name' + } + } + }; + let validBidRequests = [{ + bid_id: 'bidId', + params: { mid: '1000' }, + ortb2 + }]; + let refererInfo = { page: 'page' }; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo, ortb2 })[0].data); + + assert.deepEqual(request.site, { + page: refererInfo.page, + publisher: { + domain: 'publisher.domain.com', + name: 'publisher\'s name' + }, + id: '123123' + }); + }); + + it('should send correct priceType value', function () { + let validBidRequests = [{ + bid_id: 'bidId', + params: { priceType: 'gross' } + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + + assert.equal(request.price_type, 'gross'); + }); + + it('should send currency if defined', function () { + config.setConfig({ currency: { adServerCurrency: 'EUR' } }); + let validBidRequests = [{ params: {} }]; + let refererInfo = { page: 'page' }; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo })[0].data); + + assert.deepEqual(request.currency, 'EUR'); + }); + + it('should pass extended ids', function () { + let validBidRequests = [{ + bid_id: 'bidId', + params: {}, + userIdAsEids: createEidsArray({ + tdid: 'TTD_ID_FROM_USER_ID_MODULE', + pubcid: 'pubCommonId_FROM_USER_ID_MODULE' + }) + }]; + + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.deepEqual(request.user.eids, [ + { source: 'adserver.org', uids: [ { id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: { rtiPartner: 'TDID' } } ] }, + { source: 'pubcid.org', uids: [ { id: 'pubCommonId_FROM_USER_ID_MODULE', atype: 1 } ] } + ]); + }); + + describe('user privacy', function () { + it('should send GDPR Consent data to adform if gdprApplies', function () { + let validBidRequests = [{ bid_id: 'bidId', params: { test: 1 } }]; + let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest)[0].data); + + assert.equal(request.privacy.gdpr_consent, bidderRequest.gdprConsent.consentString); + assert.equal(request.privacy.gdpr, bidderRequest.gdprConsent.gdprApplies); + assert.equal(typeof request.privacy.gdpr, 'number'); + }); + + it('should send gdpr as number', function () { + let validBidRequests = [{ bid_id: 'bidId', params: { test: 1 } }]; + let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest)[0].data); + + assert.equal(typeof request.privacy.gdpr, 'number'); + assert.equal(request.privacy.gdpr, 1); + }); + + it('should send CCPA Consent data', function () { + let validBidRequests = [{ bid_id: 'bidId', params: { test: 1 } }]; + let bidderRequest = { uspConsent: '1YA-', refererInfo: { page: 'page' } }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest)[0].data); + + assert.equal(request.privacy.us_privacy, '1YA-'); + + bidderRequest = { uspConsent: '1YA-', gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; + request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest)[0].data); + + assert.equal(request.privacy.us_privacy, '1YA-'); + assert.equal(request.privacy.gdpr_consent, 'consentDataString'); + assert.equal(request.privacy.gdpr, 1); + }); + + it('should not set coppa when coppa is not provided or is set to false', function () { + config.setConfig({ + }); + let validBidRequests = [{ bid_id: 'bidId', params: { test: 1 } }]; + let bidderRequest = { gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, refererInfo: { page: 'page' } }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest)[0].data); + + assert.equal(request.privacy.coppa, undefined); + + config.setConfig({ + coppa: false + }); + request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest)[0].data); + + assert.equal(request.privacy.coppa, undefined); + }); + it('should set coppa to 1 when coppa is provided with value true', function () { + config.setConfig({ + coppa: true + }); + let validBidRequests = [{ bid_id: 'bidId', params: { test: 1 } }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + + assert.equal(request.privacy.coppa, 1); + }); + }); + + describe('bids', function () { + it('should be able to handle multiple bids', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { ctok: 'ctok1' } + }, { + bid_id: 'bidId2', + params: { ctok: 'ctok2' } + }]; + const request = spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }); + assert.equal(request.length, 2); + const data = request.map(r => JSON.parse(r.data)); + assert.equal(data[0].ctok, 'ctok1'); + assert.equal(data[1].ctok, 'ctok2'); + }); + + describe('price floors', function () { + it('should not add if floors module not configured', function () { + const validBidRequests = [{ bid_id: 'bidId', params: {ctok: 'ctok1'}, mediaTypes: {video: {}} }]; + const imp = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.equal(imp.bidfloor, undefined); + assert.equal(imp.bidfloorcur, undefined); + }); + + it('should not add if floor price not defined', function () { + const validBidRequests = [ getBidWithFloor() ]; + const imp = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.equal(imp.bidfloor, undefined); + assert.equal(imp.bidfloorcur, 'EUR'); + }); + + it('should request floor price in adserver currency', function () { + config.setConfig({ currency: { adServerCurrency: 'DKK' } }); + const validBidRequests = [ getBidWithFloor() ]; + const imp = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.equal(imp.bidfloor, undefined); + assert.equal(imp.bidfloorcur, 'DKK'); + }); + + it('should add correct floor values', function () { + const expectedFloors = [ 1, 1.3, 0.5 ]; + const validBidRequests = expectedFloors.map(getBidWithFloor); + const imps = spec + .buildRequests(validBidRequests, { refererInfo: { page: 'page' } }) + .map(r => JSON.parse(r.data)); + expectedFloors.forEach((floor, index) => { + assert.equal(imps[index].bidfloor, floor); + assert.equal(imps[index].bidfloorcur, 'EUR'); + }); + }); + + function getBidWithFloor(floor) { + return { + params: { ctok: 'ctok1' }, + mediaTypes: { video: {} }, + getFloor: ({ currency }) => { + return { + currency: currency, + floor + }; + } + }; + } + }); + + describe('multiple media types', function () { + it('should use all configured media types for bidding', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { ctok: 'ctok1' }, + mediaTypes: { + banner: { + sizes: [[100, 100], [200, 300]] + }, + video: {} + } + }, { + bid_id: 'bidId2', + params: { ctok: 'ctok1' }, + mediaTypes: { + video: {}, + native: {} + } + }]; + const [ first, second ] = spec + .buildRequests(validBidRequests, { refererInfo: { page: 'page' } }) + .map(r => JSON.parse(r.data)); + + assert.ok(first.banner); + assert.ok(first.video); + + assert.ok(second.video); + assert.equal(second.banner, undefined); + }); + }); + + describe('banner', function () { + it('should convert sizes to openrtb format', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { mid: 1000 }, + mediaTypes: { + banner: { + sizes: [[100, 100], [200, 300]] + } + } + }]; + const { banner } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.deepEqual(banner, { + format: [ { w: 100, h: 100 }, { w: 200, h: 300 } ] + }); + }); + }); + + describe('video', function () { + it('should pass video mediatype config', function () { + const validBidRequests = [{ + bid_id: 'bidId', + params: { mid: 1000 }, + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'] + } + } + }]; + const { video } = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } })[0].data); + assert.deepEqual(video, { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'] + }); + }); + }); + }); + }); + + describe('interpretResponse', function () { + it('should return if no body in response', function () { + const serverResponse = {}; + const bidRequest = {}; + assert.ok(!spec.interpretResponse(serverResponse, bidRequest)); + }); + const basicBidResponse = () => ({ + bid_id: 'bidId', + cpm: 10, + creative_id: '12345', + currency: 'CZK', + w: 100, + h: 100, + ad: ' ({ + data: {}, + bids: [ + { + bid_id: 'bidId1', + params: { ctok: 'ctok1' } + }, + { + bid_id: 'bidId2', + params: { ctok: 'ctok2' } + } + ] + }); + it('should parse a typical ok response', function () { + const serverResponse = { + body: { ok: { value: JSON.stringify([basicBidResponse()]) } } + }; + bids = spec.interpretResponse(serverResponse, bidRequest()); + assert.equal(bids.length, 1); + assert.deepEqual(bids[0], + { + requestId: 'bidId', + cpm: 10, + creativeId: '12345', + ttl: 300, + netRevenue: true, + currency: 'CZK', + width: 100, + height: 100, + meta: { + advertiserDomains: [] + }, + ad: ' { + request = spec.buildRequests(bidRequests); + }) + + it('Returns POST method', function () { + expect(request.method).to.equal('POST'); + }); + + it('Returns general data valid', function () { + let data = request.data; + expect(data).to.be.an('object'); + expect(data).to.have.property('bids'); + expect(data).to.have.property('uuid'); + expect(data).to.have.property('device'); + expect(data).to.have.property('site'); + }); + }); + + describe('interpretResponse', function () { + let responseBody = [{ + 'requestId': 'test', + 'cpm': 0.5, + 'currency': 'USD', + 'width': 300, + 'height': 250, + 'netRevenue': true, + 'ttl': 60, + 'creativeId': 'AD', + 'ad': '

AD

', + 'mediaType': 'banner', + 'meta': { + 'advertiserDomains': [ + 'www.example.com' + ] + } + }]; + + it('handles empty bid response', function () { + let response = { + body: responseBody + }; + let result = spec.interpretResponse(response); + expect(result.length).to.not.equal(0); + expect(result[0].meta.advertiserDomains).to.be.an('array'); + }); + + it('handles empty bid response', function () { + let response = { + body: [] + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe('getUserSyncs', function () { + it('should register type is image', function () { + const syncOptions = { + 'pixelEnabled': 'true' + } + let userSync = spec.getUserSyncs(syncOptions); + expect(userSync[0].type).to.equal('image'); + expect(userSync[0].url).to.have.string('ssp'); + }); + }); +}); diff --git a/test/spec/modules/cleanioRtdProvider_spec.js b/test/spec/modules/cleanioRtdProvider_spec.js index 47c4b1b4961..1d21fbd8457 100644 --- a/test/spec/modules/cleanioRtdProvider_spec.js +++ b/test/spec/modules/cleanioRtdProvider_spec.js @@ -1,5 +1,8 @@ +import { loadExternalScriptStub } from 'test/mocks/adloaderStub.js'; import * as utils from '../../../src/utils.js'; import * as hook from '../../../src/hook.js' +import * as events from '../../../src/events.js'; +import CONSTANTS from '../../../src/constants.json'; import { __TEST__ } from '../../../modules/cleanioRtdProvider.js'; @@ -66,10 +69,8 @@ describe('clean.io RTD module', function () { it('pageInitStepProtectPage() should insert script element', function() { pageInitStepProtectPage(fakeScriptURL); - sinon.assert.calledOnce(insertElementStub); - sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.tagName === 'SCRIPT')); - sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.type === 'text/javascript')); - sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.src === fakeScriptURL)); + sinon.assert.calledOnce(loadExternalScriptStub); + sinon.assert.calledWith(loadExternalScriptStub, fakeScriptURL, 'clean.io'); }); }); @@ -131,14 +132,14 @@ describe('clean.io RTD module', function () { it('should refuse initialization with incorrect parameters', function () { const { init } = getModule(); expect(init({ params: { cdnUrl: 'abc', protectionMode: 'full' } }, {})).to.equal(false); // too short distribution name - sinon.assert.notCalled(insertElementStub); + sinon.assert.notCalled(loadExternalScriptStub); }); - it('should iniitalize in full (page) protection mode', function () { + it('should initialize in full (page) protection mode', function () { const { init, onBidResponseEvent } = getModule(); expect(init({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'full' } }, {})).to.equal(true); - sinon.assert.calledOnce(insertElementStub); - sinon.assert.calledWith(insertElementStub, sinon.match(elem => elem.tagName === 'SCRIPT')); + sinon.assert.calledOnce(loadExternalScriptStub); + sinon.assert.calledWith(loadExternalScriptStub, 'https://abc1234567890.cloudfront.net/script.js', 'clean.io'); const fakeBidResponse = makeFakeBidResponse(); onBidResponseEvent(fakeBidResponse, {}, {}); @@ -184,5 +185,26 @@ describe('clean.io RTD module', function () { onBidResponseEvent(fakeBidResponse3, {}, {}); ensurePrependToBidResponse(fakeBidResponse3); }); + + it('should send billable event per bid won event', function () { + const { init } = getModule(); + expect(init({ params: { cdnUrl: 'https://abc1234567890.cloudfront.net/script.js', protectionMode: 'full' } }, {})).to.equal(true); + + const eventCounter = { registerCleanioBillingEvent: function() {} }; + sinon.spy(eventCounter, 'registerCleanioBillingEvent'); + + events.on(CONSTANTS.EVENTS.BILLABLE_EVENT, (evt) => { + if (evt.vendor === 'clean.io') { + eventCounter.registerCleanioBillingEvent() + } + }); + + events.emit(CONSTANTS.EVENTS.BID_WON, {}); + events.emit(CONSTANTS.EVENTS.BID_WON, {}); + events.emit(CONSTANTS.EVENTS.BID_WON, {}); + events.emit(CONSTANTS.EVENTS.BID_WON, {}); + + sinon.assert.callCount(eventCounter.registerCleanioBillingEvent, 4); + }); }); }); diff --git a/test/spec/modules/cleanmedianetBidAdapter_spec.js b/test/spec/modules/cleanmedianetBidAdapter_spec.js index c2eea6f32d7..3c73dac07de 100644 --- a/test/spec/modules/cleanmedianetBidAdapter_spec.js +++ b/test/spec/modules/cleanmedianetBidAdapter_spec.js @@ -2,96 +2,295 @@ import {expect} from 'chai'; import {spec, helper} from 'modules/cleanmedianetBidAdapter.js'; import * as utils from 'src/utils.js'; import {newBidder} from '../../../src/adapters/bidderFactory.js'; +import {deepClone} from 'src/utils'; const supplyPartnerId = '123'; const adapter = newBidder(spec); -describe('CleanmedianetAdapter', function () { - describe('Is String start with search ', function () { - it('check if a string started with', function () { - expect(helper.startsWith('cleanmediaads.com', 'cleanmediaads')).to.equal( - true - ); +const TTL = 360; + +describe('CleanmedianetAdapter', () => { + let schainConfig, + bidRequest, + bannerBidRequest, + videoBidRequest, + rtbResponse, + videoResponse, + gdprConsent; + + beforeEach(() => { + schainConfig = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + } + ] + }; + + bidRequest = { + 'adUnitCode': 'adunit-code', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + banner: {} + }, + 'params': { + 'supplyPartnerId': supplyPartnerId + }, + 'sizes': [[300, 250], [300, 600]], + 'transactionId': 'a123456789', + refererInfo: {referer: 'http://examplereferer.com'}, + gdprConsent: { + consentString: 'some string', + gdprApplies: true + }, + schain: schainConfig, + uspConsent: 'cleanmediaCCPA' + }; + + bannerBidRequest = { + 'adUnitCode': 'adunit-code', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + banner: {} + }, + 'params': { + 'supplyPartnerId': supplyPartnerId + }, + 'sizes': [[300, 250], [300, 600]], + 'transactionId': 'a123456789', + 'bidId': '111', + refererInfo: {referer: 'http://examplereferer.com'} + }; + + videoBidRequest = { + 'adUnitCode': 'adunit-code', + 'auctionId': '1d1a030790a475', + 'mediaTypes': { + video: {} + }, + 'params': { + 'supplyPartnerId': supplyPartnerId + }, + 'sizes': [[300, 250], [300, 600]], + 'transactionId': 'a123456789', + 'bidId': '111', + refererInfo: {referer: 'http://examplereferer.com'} + }; + + rtbResponse = { + 'id': 'imp_5b05b9fde4b09084267a556f', + 'bidid': 'imp_5b05b9fde4b09084267a556f', + 'cur': 'USD', + 'ext': { + 'utrk': [ + {'type': 'iframe', 'url': '//bidder.cleanmediaads.com/user/sync/1?gdpr=[GDPR]&consent=[CONSENT]&usp=[US_PRIVACY]'}, + {'type': 'image', 'url': '//bidder.cleanmediaads.com/user/sync/2'} + ] + }, + 'seatbid': [ + { + 'seat': 'seat1', + 'group': 0, + 'bid': [ + { + 'id': '0', + 'impid': '1', + 'price': 2.016, + 'adid': '579ef31bfa788b9d2000d562', + 'nurl': 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', + 'adm': '', + 'adomain': ['aaa.com'], + 'cid': '579ef268fa788b9d2000d55c', + 'crid': '579ef31bfa788b9d2000d562', + 'attr': [], + 'h': 600, + 'w': 120, + 'ext': { + 'vast_url': 'http://my.vast.com', + 'utrk': [ + {'type': 'iframe', 'url': '//p.partner1.io/user/sync/1'} + ] + } + } + ] + }, + { + 'seat': 'seat2', + 'group': 0, + 'bid': [ + { + 'id': '1', + 'impid': '1', + 'price': 3, + 'adid': '542jlhdfd2112jnjf3x', + 'nurl': 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', + 'adm': ' ', + 'adomain': ['bbb.com'], + 'cid': 'fgdlwjh2498ydjhg1', + 'crid': 'kjh34297ydh2133d', + 'attr': [], + 'h': 250, + 'w': 300, + 'ext': { + 'utrk': [ + {'type': 'image', 'url': '//p.partner2.io/user/sync/1'} + ] + } + } + ] + } + ] + }; + + videoResponse = { + 'id': '64f32497-b2f7-48ec-9205-35fc39894d44', + 'bidid': 'imp_5c24924de4b0d106447af333', + 'cur': 'USD', + 'seatbid': [ + { + 'seat': '3668', + 'group': 0, + 'bid': [ + { + 'id': 'gb_1', + 'impid': 'afbb5852-7cea-4a81-aa9a-a41aab505c23', + 'price': 5.0, + 'adid': '1274', + 'nurl': 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1', + 'adomain': [], + 'adm': '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', + 'cid': '3668', + 'crid': '1274', + 'cat': [], + 'attr': [], + 'h': 250, + 'w': 300, + 'ext': { + 'vast_url': 'https://bidder.cleanmediaads.com/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', + 'imptrackers': [ + 'https://bidder.cleanmediaads.com/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1'] + } + } + ] + } + ], + 'ext': { + 'utrk': [{ + 'type': 'image', + 'url': 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gdpr=[GDPR]&consent=[CONSENT]&us_privacy=[US_PRIVACY]' + }] + } + }; + + gdprConsent = { + gdprApplies: true, + consentString: 'consent string' + }; + }); + + describe('Get top Frame', () => { + it('check if you are in the top frame', () => { + expect(helper.getTopFrame()).to.equal(0); + }); + }); + + describe('Is String start with search', () => { + it('check if a string started with', () => { + expect(helper.startsWith('cleanmedia.net', 'clea')).to.equal(true); }); }); - describe('inherited functions', function() { - it('exists and is a function', function() { + describe('inherited functions', () => { + it('exists and is a function', () => { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); }); - describe('isBidRequestValid', function() { - it('should validate supply-partner ID', function() { - expect(spec.isBidRequestValid({ params: {} })).to.equal(false); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: 123 } }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); + describe('isBidRequestValid', () => { + it('should validate supply-partner ID', () => { + expect(spec.isBidRequestValid({params: {}})).to.equal(false); + expect(spec.isBidRequestValid({params: {supplyPartnerId: 123}})).to.equal(false); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); + }); + + it('should validate RTB endpoint', () => { + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // RTB endpoint has a default + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', rtbEndpoint: 123}})).to.equal(false); + expect(spec.isBidRequestValid({ + params: { + supplyPartnerId: '123', + rtbEndpoint: 'https://some.url.com' + } + })).to.equal(true); + }); + + it('should validate bid floor', () => { + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // bidfloor has a default + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', bidfloor: '123'}})).to.equal(false); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', bidfloor: 0.1}})).to.equal(true); + + const getFloorResponse = {currency: 'USD', floor: 5}; + let testBidRequest = deepClone(bidRequest); + let request = spec.buildRequests([testBidRequest], bidRequest)[0]; + + // 1. getBidFloor not exist AND bidfloor not exist - return 0 + let payload = request.data; + expect(payload.imp[0].bidfloor).to.exist.and.equal(0); + + // 2. getBidFloor not exist AND bidfloor exist - use bidfloor property + testBidRequest = deepClone(bidRequest); + testBidRequest.params = { + 'bidfloor': 0.3 + }; + request = spec.buildRequests([testBidRequest], bidRequest)[0]; + payload = request.data; + expect(payload.imp[0].bidfloor).to.exist.and.to.equal(0.3) + + // 3. getBidFloor exist AND bidfloor not exist - use getFloor method + testBidRequest = deepClone(bidRequest); + testBidRequest.getFloor = () => getFloorResponse; + request = spec.buildRequests([testBidRequest], bidRequest)[0]; + payload = request.data; + expect(payload.imp[0].bidfloor).to.exist.and.to.equal(5) + + // 4. getBidFloor exist AND bidfloor exist -> use getFloor method + testBidRequest = deepClone(bidRequest); + testBidRequest.getFloor = () => getFloorResponse; + testBidRequest.params = { + 'bidfloor': 0.3 + }; + request = spec.buildRequests([testBidRequest], bidRequest)[0]; + payload = request.data; + expect(payload.imp[0].bidfloor).to.exist.and.to.equal(5) }); - it('should validate adpos', function() { - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); // adpos has a default - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', adpos: '123' } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', adpos: 0.1 } - }) - ).to.equal(true); + it('should validate adpos', () => { + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // adpos has a default + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', adpos: '123'}})).to.equal(false); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', adpos: 0.1}})).to.equal(true); }); - it('should validate instl', function() { - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123' } }) - ).to.equal(true); // adpos has a default - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', instl: '123' } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ - params: { supplyPartnerId: '123', instl: -1 } - }) - ).to.equal(false); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 0 } }) - ).to.equal(true); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 1 } }) - ).to.equal(true); - expect( - spec.isBidRequestValid({ params: { supplyPartnerId: '123', instl: 2 } }) - ).to.equal(false); + it('should validate instl', () => { + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123'}})).to.equal(true); // adpos has a default + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: '123'}})).to.equal(false); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: -1}})).to.equal(false); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 0}})).to.equal(true); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 1}})).to.equal(true); + expect(spec.isBidRequestValid({params: {supplyPartnerId: '123', instl: 2}})).to.equal(false); }); }); - describe('buildRequests', function() { - const bidRequest = { - adUnitCode: 'adunit-code', - auctionId: '1d1a030790a475', - mediaTypes: { - banner: {} - }, - params: { - supplyPartnerId: supplyPartnerId - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a123456789', - refererInfo: { referer: 'https://examplereferer.com' }, - gdprConsent: { - consentString: 'some string', - gdprApplies: true - } - }; - it('returns an array', function() { + describe('buildRequests', () => { + it('returns an array', () => { let response; response = spec.buildRequests([]); expect(Array.isArray(response)).to.equal(true); @@ -99,53 +298,61 @@ describe('CleanmedianetAdapter', function () { response = spec.buildRequests([bidRequest], bidRequest); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); - const adUnit1 = Object.assign({}, utils.deepClone(bidRequest), { - auctionId: '1', - adUnitCode: 'a' - }); - const adUnit2 = Object.assign({}, utils.deepClone(bidRequest), { - auctionId: '1', - adUnitCode: 'b' - }); + const adUnit1 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'a'}); + const adUnit2 = Object.assign({}, utils.deepClone(bidRequest), {auctionId: '1', adUnitCode: 'b'}); response = spec.buildRequests([adUnit1, adUnit2], bidRequest); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(2); }); - it('builds request correctly', function() { + it('targets correct endpoint', () => { + let response; + response = spec.buildRequests([bidRequest], bidRequest)[0]; + expect(response.method).to.equal('POST'); + expect(response.url).to.match(new RegExp(`^https://bidder\\.cleanmediaads\\.com/r/${supplyPartnerId}/bidr\\?rformat=open_rtb&reqformat=rtb_json&bidder=prebid$`, 'g')); + expect(response.data.id).to.equal(bidRequest.bidId); + const bidRequestWithEndpoint = utils.deepClone(bidRequest); + bidRequestWithEndpoint.params.rtbEndpoint = 'https://bidder.cleanmediaads.com/a12'; + response = spec.buildRequests([bidRequestWithEndpoint], bidRequest)[0]; + expect(response.url).to.match(new RegExp(`^https://bidder\\.cleanmediaads\\.com/a12/r/${supplyPartnerId}/bidr\\?rformat=open_rtb&reqformat=rtb_json&bidder=prebid$`, 'g')); + }); + + it('builds request correctly', () => { let bidRequest2 = utils.deepClone(bidRequest); - bidRequest2.refererInfo.referer = 'https://www.test.com/page.html'; + Object.assign(bidRequest2.refererInfo, { + page: 'http://www.test.com/page.html', + domain: 'www.test.com', + ref: 'http://referrer.com' + }) let response = spec.buildRequests([bidRequest], bidRequest2)[0]; + expect(response.data.site.domain).to.equal('www.test.com'); - expect(response.data.site.page).to.equal('https://www.test.com/page.html'); - expect(response.data.site.ref).to.equal('https://www.test.com/page.html'); + expect(response.data.site.page).to.equal('http://www.test.com/page.html'); + expect(response.data.site.ref).to.equal('http://referrer.com'); expect(response.data.imp.length).to.equal(1); - expect(response.data.imp[0].id).to.equal(bidRequest.transactionId); + expect(response.data.imp[0].id).to.equal(bidRequest.bidId); expect(response.data.imp[0].instl).to.equal(0); expect(response.data.imp[0].tagid).to.equal(bidRequest.adUnitCode); expect(response.data.imp[0].bidfloor).to.equal(0); expect(response.data.imp[0].bidfloorcur).to.equal('USD'); + expect(response.data.regs.ext.us_privacy).to.equal('cleanmediaCCPA');// USP/CCPAs + expect(response.data.source.ext.schain).to.deep.equal(bidRequest2.schain); + const bidRequestWithInstlEquals1 = utils.deepClone(bidRequest); bidRequestWithInstlEquals1.params.instl = 1; - response = spec.buildRequests( - [bidRequestWithInstlEquals1], - bidRequest2 - )[0]; - expect(response.data.imp[0].instl).to.equal( - bidRequestWithInstlEquals1.params.instl - ); + response = spec.buildRequests([bidRequestWithInstlEquals1], bidRequest2)[0]; + expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals1.params.instl); const bidRequestWithInstlEquals0 = utils.deepClone(bidRequest); bidRequestWithInstlEquals0.params.instl = 1; - response = spec.buildRequests( - [bidRequestWithInstlEquals0], - bidRequest2 - )[0]; - expect(response.data.imp[0].instl).to.equal( - bidRequestWithInstlEquals0.params.instl - ); + response = spec.buildRequests([bidRequestWithInstlEquals0], bidRequest2)[0]; + expect(response.data.imp[0].instl).to.equal(bidRequestWithInstlEquals0.params.instl); + const bidRequestWithBidfloorEquals1 = utils.deepClone(bidRequest); + bidRequestWithBidfloorEquals1.params.bidfloor = 1; + response = spec.buildRequests([bidRequestWithBidfloorEquals1], bidRequest2)[0]; + expect(response.data.imp[0].bidfloor).to.equal(bidRequestWithBidfloorEquals1.params.bidfloor); }); - it('builds request banner object correctly', function() { + it('builds request banner object correctly', () => { let response; const bidRequestWithBanner = utils.deepClone(bidRequest); bidRequestWithBanner.mediaTypes = { @@ -154,54 +361,80 @@ describe('CleanmedianetAdapter', function () { } }; response = spec.buildRequests([bidRequestWithBanner], bidRequest)[0]; - expect(response.data.imp[0].banner.w).to.equal( - bidRequestWithBanner.mediaTypes.banner.sizes[0][0] - ); - expect(response.data.imp[0].banner.h).to.equal( - bidRequestWithBanner.mediaTypes.banner.sizes[0][1] - ); + expect(response.data.imp[0].banner.w).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][0]); + expect(response.data.imp[0].banner.h).to.equal(bidRequestWithBanner.mediaTypes.banner.sizes[0][1]); expect(response.data.imp[0].banner.pos).to.equal(0); + expect(response.data.imp[0].banner.topframe).to.equal(0); const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithBanner); bidRequestWithPosEquals1.params.pos = 1; response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].banner.pos).to.equal( - bidRequestWithPosEquals1.params.pos - ); + expect(response.data.imp[0].banner.pos).to.equal(bidRequestWithPosEquals1.params.pos); }); - it('builds request video object correctly', function() { + it('builds request video object correctly', () => { let response; const bidRequestWithVideo = utils.deepClone(bidRequest); + + bidRequestWithVideo.params.video = { + placement: 1, + minduration: 1, + } + bidRequestWithVideo.mediaTypes = { video: { - sizes: [[300, 250], [120, 600]] + playerSize: [[302, 252]], + mimes: ['video/mpeg'], + playbackmethod: 1, + startdelay: 1, } }; response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[0].video.w).to.equal( - bidRequestWithVideo.mediaTypes.video.sizes[0][0] - ); - expect(response.data.imp[0].video.h).to.equal( - bidRequestWithVideo.mediaTypes.video.sizes[0][1] - ); + expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][0]); + expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0][1]); expect(response.data.imp[0].video.pos).to.equal(0); + + expect(response.data.imp[0].video.mimes).to.equal(bidRequestWithVideo.mediaTypes.video.mimes); + expect(response.data.imp[0].video.skip).to.not.exist; + expect(response.data.imp[0].video.placement).to.equal(1); + expect(response.data.imp[0].video.minduration).to.equal(1); + expect(response.data.imp[0].video.playbackmethod).to.equal(1); + expect(response.data.imp[0].video.startdelay).to.equal(1); + + bidRequestWithVideo.mediaTypes = { + video: { + playerSize: [302, 252], + mimes: ['video/mpeg'], + skip: 1, + placement: 1, + minduration: 1, + playbackmethod: 1, + startdelay: 1, + }, + }; + const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); + expect(response.data.imp[0].video.w).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[0]); + expect(response.data.imp[0].video.h).to.equal(bidRequestWithVideo.mediaTypes.video.playerSize[1]); + bidRequestWithPosEquals1.params.pos = 1; response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; - expect(response.data.imp[0].video.pos).to.equal( - bidRequestWithPosEquals1.params.pos - ); + expect(response.data.imp[0].video.pos).to.equal(bidRequestWithPosEquals1.params.pos); }); - it('builds request video object correctly with context', function() { - let response; + it('builds request video object correctly with context', () => { const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes = { video: { - context: 'instream' + context: 'instream', + mimes: ['video/mpeg'], + skip: 1, + placement: 1, + minduration: 1, + playbackmethod: 1, + startdelay: 1, } }; - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; expect(response.data.imp[0].video.ext.context).to.equal('instream'); bidRequestWithVideo.mediaTypes.video.context = 'outstream'; @@ -215,358 +448,185 @@ describe('CleanmedianetAdapter', function () { response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; expect(response.data.imp[0].video.ext.context).to.equal(null); }); - it('builds request video object correctly with multi-dimensions size array', function () { - let bidRequestWithVideo = utils.deepClone(bidRequest); + + it('builds request video object correctly with multi-dimensions size array', () => { + let response; + const bidRequestWithVideo = utils.deepClone(bidRequest); bidRequestWithVideo.mediaTypes.video = { playerSize: [[304, 254], [305, 255]], - context: 'instream' + context: 'instream', + mimes: ['video/mpeg'], + skip: 1, + placement: 1, + minduration: 1, + playbackmethod: 1, + startdelay: 1, }; - let response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[1].video.w).to.equal(304); - expect(response.data.imp[1].video.h).to.equal(254); + response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; + expect(response.data.imp[1].video.ext.context).to.equal('instream'); + bidRequestWithVideo.mediaTypes.video.context = 'outstream'; - bidRequestWithVideo = utils.deepClone(bidRequest); - bidRequestWithVideo.mediaTypes.video = { - playerSize: [304, 254] - }; + const bidRequestWithPosEquals1 = utils.deepClone(bidRequestWithVideo); + bidRequestWithPosEquals1.mediaTypes.video.context = 'outstream'; + response = spec.buildRequests([bidRequestWithPosEquals1], bidRequest)[0]; + expect(response.data.imp[1].video.ext.context).to.equal('outstream'); - response = spec.buildRequests([bidRequestWithVideo], bidRequest)[0]; - expect(response.data.imp[1].video.w).to.equal(304); - expect(response.data.imp[1].video.h).to.equal(254); + const bidRequestWithPosEquals2 = utils.deepClone(bidRequestWithVideo); + bidRequestWithPosEquals2.mediaTypes.video.context = null; + response = spec.buildRequests([bidRequestWithPosEquals2], bidRequest)[0]; + expect(response.data.imp[1].video.ext.context).to.equal(null); }); - it('builds request with gdpr consent', function() { + it('builds request with gdpr consent', () => { let response = spec.buildRequests([bidRequest], bidRequest)[0]; + + expect(response.data.ext.gdpr_consent).to.not.equal(null).and.not.equal(undefined); expect(response.data.ext).to.have.property('gdpr_consent'); - expect(response.data.ext.gdpr_consent.consent_string).to.equal( - 'some string' - ); + expect(response.data.ext.gdpr_consent.consent_string).to.equal('some string'); expect(response.data.ext.gdpr_consent.consent_required).to.equal(true); - }); - }); - - describe('interpretResponse', function() { - const bannerBidRequest = { - adUnitCode: 'adunit-code', - auctionId: '1d1a030790a475', - mediaTypes: { - banner: {} - }, - params: { - supplyPartnerId: supplyPartnerId - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a123456789', - bidId: '111', - refererInfo: { referer: 'https://examplereferer.com' } - }; - const videoBidRequest = { - adUnitCode: 'adunit-code', - auctionId: '1d1a030790a475', - mediaTypes: { - video: {} - }, - params: { - supplyPartnerId: supplyPartnerId - }, - sizes: [[300, 250], [300, 600]], - transactionId: 'a123456789', - bidId: '111', - refererInfo: { referer: 'https://examplereferer.com' } - }; + expect(response.data.regs.ext.gdpr).to.not.equal(null).and.not.equal(undefined); + expect(response.data.user.ext.consent).to.equal('some string'); + }); - const rtbResponse = { - id: 'imp_5b05b9fde4b09084267a556f', - bidid: 'imp_5b05b9fde4b09084267a556f', - cur: 'USD', - ext: { - utrk: [ - { type: 'iframe', url: '//bidder.cleanmediaads.com/user/sync/1' }, - { type: 'image', url: '//bidder.cleanmediaads.com/user/sync/2' } - ] - }, - seatbid: [ - { - seat: 'seat1', - group: 0, - bid: [ - { - id: '0', - impid: '1', - price: 2.016, - adid: '579ef31bfa788b9d2000d562', - nurl: - 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', - adm: - '', - adomain: ['aaa.com'], - cid: '579ef268fa788b9d2000d55c', - crid: '579ef31bfa788b9d2000d562', - attr: [], - h: 600, - w: 120, - ext: { - vast_url: 'https://my.vast.com', - utrk: [{ type: 'iframe', url: '//p.partner1.io/user/sync/1' }] - } - } - ] - }, - { - seat: 'seat2', - group: 0, - bid: [ - { - id: '1', - impid: '1', - price: 3, - adid: '542jlhdfd2112jnjf3x', - nurl: - 'https://bidder.cleanmediaads.com/pix/monitoring/win_notice/imp_5b05b9fde4b09084267a556f/im.gif?r=imp_5b05b9fde4b09084267a556f&i=1&a=579ef31bfa788b9d2000d562&b=0', - adm: - ' ', - adomain: ['bbb.com'], - cid: 'fgdlwjh2498ydjhg1', - crid: 'kjh34297ydh2133d', - attr: [], - h: 250, - w: 300, - ext: { - utrk: [{ type: 'image', url: '//p.partner2.io/user/sync/1' }] - } - } - ] - } - ] - }; + it('build request with ID5 Id', () => { + const bidRequestClone = utils.deepClone(bidRequest); + bidRequestClone.userId = {}; + bidRequestClone.userId.id5id = { uid: 'id5-user-id' }; + let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0]; + expect(request.data.user.ext.eids).to.deep.equal([{ + 'source': 'id5-sync.com', + 'uids': [{ + 'id': 'id5-user-id', + 'ext': { + 'rtiPartner': 'ID5ID' + } + }] + }]); + }); - it('returns an empty array on missing response', function() { - let response; + it('build request with unified Id', () => { + const bidRequestClone = utils.deepClone(bidRequest); + bidRequestClone.userId = {}; + bidRequestClone.userId.tdid = 'tdid-user-id'; + let request = spec.buildRequests([bidRequestClone], bidRequestClone)[0]; + expect(request.data.user.ext.eids).to.deep.equal([{ + 'source': 'adserver.org', + 'uids': [{ + 'id': 'tdid-user-id', + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }]); + }); + }); - response = spec.interpretResponse(undefined, { - bidRequest: bannerBidRequest - }); + describe('interpretResponse', () => { + it('returns an empty array on missing response', () => { + let response = spec.interpretResponse(undefined, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(0); - response = spec.interpretResponse({}, { bidRequest: bannerBidRequest }); + response = spec.interpretResponse({}, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(0); }); - it('aggregates banner bids from all seat bids', function() { - const response = spec.interpretResponse( - { body: rtbResponse }, - { bidRequest: bannerBidRequest } - ); + it('aggregates banner bids from all seat bids', () => { + const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: bannerBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); - const ad0 = response[0]; expect(ad0.requestId).to.equal(bannerBidRequest.bidId); expect(ad0.cpm).to.equal(rtbResponse.seatbid[1].bid[0].price); expect(ad0.width).to.equal(rtbResponse.seatbid[1].bid[0].w); expect(ad0.height).to.equal(rtbResponse.seatbid[1].bid[0].h); - expect(ad0.ttl).to.equal(360); + expect(ad0.ttl).to.equal(TTL); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[1].bid[0].crid); expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal( - rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD' - ); + expect(ad0.currency).to.equal(rtbResponse.seatbid[1].bid[0].cur || rtbResponse.cur || 'USD'); expect(ad0.ad).to.equal(rtbResponse.seatbid[1].bid[0].adm); expect(ad0.vastXml).to.be.an('undefined'); expect(ad0.vastUrl).to.be.an('undefined'); + expect(ad0.meta.advertiserDomains).to.be.equal(rtbResponse.seatbid[1].bid[0].adomain); }); - it('aggregates video bids from all seat bids', function() { - const response = spec.interpretResponse( - { body: rtbResponse }, - { bidRequest: videoBidRequest } - ); + it('aggregates video bids from all seat bids', () => { + const response = spec.interpretResponse({body: rtbResponse}, {bidRequest: videoBidRequest}); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(1); - const ad0 = response[0]; expect(ad0.requestId).to.equal(videoBidRequest.bidId); expect(ad0.cpm).to.equal(rtbResponse.seatbid[0].bid[0].price); expect(ad0.width).to.equal(rtbResponse.seatbid[0].bid[0].w); expect(ad0.height).to.equal(rtbResponse.seatbid[0].bid[0].h); - expect(ad0.ttl).to.equal(360); + expect(ad0.ttl).to.equal(TTL); expect(ad0.creativeId).to.equal(rtbResponse.seatbid[0].bid[0].crid); expect(ad0.netRevenue).to.equal(true); - expect(ad0.currency).to.equal( - rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD' - ); + expect(ad0.currency).to.equal(rtbResponse.seatbid[0].bid[0].cur || rtbResponse.cur || 'USD'); expect(ad0.ad).to.be.an('undefined'); expect(ad0.vastXml).to.equal(rtbResponse.seatbid[0].bid[0].adm); expect(ad0.vastUrl).to.equal(rtbResponse.seatbid[0].bid[0].ext.vast_url); }); - it('aggregates user-sync pixels', function() { - const response = spec.getUserSyncs({}, [{ body: rtbResponse }]); + it('aggregates user-sync pixels', () => { + const response = spec.getUserSyncs({}, [{body: rtbResponse}]); expect(Array.isArray(response)).to.equal(true); expect(response.length).to.equal(4); expect(response[0].type).to.equal(rtbResponse.ext.utrk[0].type); - expect(response[0].url).to.equal( - rtbResponse.ext.utrk[0].url + '?gc=missing' - ); + expect(response[0].url).to.equal('//bidder.cleanmediaads.com/user/sync/1?gdpr=0&consent=&usp='); expect(response[1].type).to.equal(rtbResponse.ext.utrk[1].type); - expect(response[1].url).to.equal( - rtbResponse.ext.utrk[1].url + '?gc=missing' - ); - expect(response[2].type).to.equal( - rtbResponse.seatbid[0].bid[0].ext.utrk[0].type - ); - expect(response[2].url).to.equal( - rtbResponse.seatbid[0].bid[0].ext.utrk[0].url + '?gc=missing' - ); - expect(response[3].type).to.equal( - rtbResponse.seatbid[1].bid[0].ext.utrk[0].type - ); - expect(response[3].url).to.equal( - rtbResponse.seatbid[1].bid[0].ext.utrk[0].url + '?gc=missing' - ); + expect(response[1].url).to.equal('//bidder.cleanmediaads.com/user/sync/2'); + expect(response[2].type).to.equal(rtbResponse.seatbid[0].bid[0].ext.utrk[0].type); + expect(response[2].url).to.equal('//p.partner1.io/user/sync/1'); + expect(response[3].type).to.equal(rtbResponse.seatbid[1].bid[0].ext.utrk[0].type); + expect(response[3].url).to.equal('//p.partner2.io/user/sync/1'); }); - it('supports configuring outstream renderers', function() { - const videoResponse = { - id: '64f32497-b2f7-48ec-9205-35fc39894d44', - bidid: 'imp_5c24924de4b0d106447af333', - cur: 'USD', - seatbid: [ - { - seat: '3668', - group: 0, - bid: [ - { - id: 'gb_1', - impid: 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - price: 5.0, - adid: '1274', - nurl: - 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1', - adomain: [], - adm: - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - cid: '3668', - crid: '1274', - cat: [], - attr: [], - h: 250, - w: 300, - ext: { - vast_url: - 'https://bidder.cleanmediaads.com/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - imptrackers: [ - 'https://bidder.cleanmediaads.com/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1' - ] - } - } - ] - } - ], - ext: { - utrk: [ - { - type: 'image', - url: - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675' - } - ] - } - }; + it('supports configuring outstream renderers', () => { const videoRequest = utils.deepClone(videoBidRequest); videoRequest.mediaTypes.video.context = 'outstream'; - const result = spec.interpretResponse( - { body: videoResponse }, - { bidRequest: videoRequest } - ); + const result = spec.interpretResponse({body: videoResponse}, {bidRequest: videoRequest}); expect(result[0].renderer).to.not.equal(undefined); }); - it('validates in/existing of gdpr consent', function() { - let videoResponse = { - id: '64f32497-b2f7-48ec-9205-35fc39894d44', - bidid: 'imp_5c24924de4b0d106447af333', - cur: 'USD', - seatbid: [ - { - seat: '3668', - group: 0, - bid: [ - { - id: 'gb_1', - impid: 'afbb5852-7cea-4a81-aa9a-a41aab505c23', - price: 5.0, - adid: '1274', - nurl: - 'https://bidder.cleanmediaads.com/pix/1275/win_notice/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1', - adomain: [], - adm: - '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - cid: '3668', - crid: '1274', - cat: [], - attr: [], - h: 250, - w: 300, - ext: { - vast_url: - 'https://bidder.cleanmediaads.com/pix/1275/vast_o/imp_5c24924de4b0d106447af333/im.xml?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1&w=300&h=250&vatu=aHR0cHM6Ly9zdGF0aWMuZ2FtYmlkLmlvL2RlbW8vdmFzdC54bWw&vwarv', - imptrackers: [ - 'https://bidder.cleanmediaads.com/pix/1275/imp/imp_5c24924de4b0d106447af333/im.gif?r=imp_5c24924de4b0d106447af333&i=afbb5852-7cea-4a81-aa9a-a41aab505c23&a=1274&b=gb_1' - ] - } - } - ] - } - ], - ext: { - utrk: [ - { - type: 'image', - url: - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675' - } - ] - } - }; - let gdprConsent = { - gdprApplies: true, - consentString: 'consent string' - }; - let result = spec.getUserSyncs( - {}, - [{ body: videoResponse }], - gdprConsent - ); + it('validates in/existing of gdpr consent', () => { + let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'cleanmediaCCPA'); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal( - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gc=consent%20string' - ); + expect(result[0].url).to.equal('https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gdpr=1&consent=consent%20string&us_privacy=cleanmediaCCPA'); gdprConsent.gdprApplies = false; - result = spec.getUserSyncs({}, [{ body: videoResponse }], gdprConsent); + result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'cleanmediaCCPA'); + expect(result).to.be.an('array'); + expect(result.length).to.equal(1); + expect(result[0].type).to.equal('image'); + expect(result[0].url).to.equal('https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gdpr=0&consent=&us_privacy=cleanmediaCCPA'); + + videoResponse.ext.utrk[0].url = 'https://bidder.cleanmediaads.com/pix/1275/scm'; + result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal( - 'https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gc=missing' - ); + expect(result[0].url).to.equal('https://bidder.cleanmediaads.com/pix/1275/scm'); + }); - videoResponse.ext.utrk[0].url = - 'https://bidder.cleanmediaads.com/pix/1275/scm'; - result = spec.getUserSyncs({}, [{ body: videoResponse }], gdprConsent); + it('validates existence of gdpr, gdpr consent and usp consent', () => { + let result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, 'cleanmediaCCPA'); + expect(result).to.be.an('array'); + expect(result.length).to.equal(1); + expect(result[0].type).to.equal('image'); + expect(result[0].url).to.equal('https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gdpr=1&consent=consent%20string&us_privacy=cleanmediaCCPA'); + + gdprConsent.gdprApplies = false; + result = spec.getUserSyncs({}, [{body: videoResponse}], gdprConsent, ''); expect(result).to.be.an('array'); expect(result.length).to.equal(1); expect(result[0].type).to.equal('image'); - expect(result[0].url).to.equal( - 'https://bidder.cleanmediaads.com/pix/1275/scm?gc=missing' - ); + expect(result[0].url).to.equal('https://bidder.cleanmediaads.com/pix/1275/scm?cb=1545900621675&gdpr=0&consent=&us_privacy='); }); }); }); diff --git a/test/spec/modules/codefuelBidAdapter_spec.js b/test/spec/modules/codefuelBidAdapter_spec.js index a2549012d84..6123f768d88 100644 --- a/test/spec/modules/codefuelBidAdapter_spec.js +++ b/test/spec/modules/codefuelBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; import {spec} from 'modules/codefuelBidAdapter.js'; import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; import {server} from 'test/mocks/xhr'; const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4515.159 Safari/537.36'; @@ -9,6 +10,13 @@ const setUADefault = () => { window.navigator.__defineGetter__('userAgent', func const setUAMock = () => { window.navigator.__defineGetter__('userAgent', function () { return USER_AGENT }) }; describe('Codefuel Adapter', function () { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + afterEach(() => { + sandbox.restore(); + }) describe('Bid request and response', function () { const commonBidRequest = { bidder: 'codefuel', @@ -137,9 +145,11 @@ describe('Codefuel Adapter', function () { const commonBidderRequest = { timeout: 500, + bidderRequestId: 'mock-uuid', auctionId: '12043683-3254-4f74-8934-f941b085579e', refererInfo: { - referer: 'https://example.com/', + page: 'https://example.com/', + domain: 'example.com' } } @@ -156,7 +166,7 @@ describe('Codefuel Adapter', function () { devicetype: 2, ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4515.159 Safari/537.36' }, - id: '12043683-3254-4f74-8934-f941b085579e', + id: 'mock-uuid', imp: [ { banner: { diff --git a/test/spec/modules/cointrafficBidAdapter_spec.js b/test/spec/modules/cointrafficBidAdapter_spec.js index 3755ddc4c4a..79775f7b135 100644 --- a/test/spec/modules/cointrafficBidAdapter_spec.js +++ b/test/spec/modules/cointrafficBidAdapter_spec.js @@ -1,13 +1,15 @@ +import sinon from 'sinon' import { expect } from 'chai'; import { spec } from 'modules/cointrafficBidAdapter.js'; import { config } from 'src/config.js' import * as utils from 'src/utils.js' -const ENDPOINT_URL = 'https://appspb.cointraffic.io/pb/tmp'; +const ENDPOINT_URL = 'https://apps-pbd.ctraffic.io/pb/tmp'; describe('cointrafficBidAdapter', function () { describe('isBidRequestValid', function () { - let bid = { + /** @type {BidRequest} */ + let bidRequest = { bidder: 'cointraffic', params: { placementId: 'testPlacementId' @@ -22,11 +24,12 @@ describe('cointrafficBidAdapter', function () { }; it('should return true where required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); }); describe('buildRequests', function () { + /** @type {BidRequest[]} */ let bidRequests = [ { bidder: 'cointraffic', @@ -56,7 +59,8 @@ describe('cointrafficBidAdapter', function () { } ]; - let bidderRequests = { + /** @type {BidderRequest} */ + let bidderRequest = { refererInfo: { numIframes: 0, reachedTop: true, @@ -68,7 +72,7 @@ describe('cointrafficBidAdapter', function () { }; it('replaces currency with EUR if there is no currency provided', function () { - const request = spec.buildRequests(bidRequests, bidderRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0].data.currency).to.equal('EUR'); expect(request[1].data.currency).to.equal('EUR'); @@ -79,7 +83,7 @@ describe('cointrafficBidAdapter', function () { arg => arg === 'currency.bidderCurrencyDefault.cointraffic' ? 'USD' : 'EUR' ); - const request = spec.buildRequests(bidRequests, bidderRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0].data.currency).to.equal('USD'); expect(request[1].data.currency).to.equal('USD'); @@ -93,7 +97,7 @@ describe('cointrafficBidAdapter', function () { arg => arg === 'currency.bidderCurrencyDefault.cointraffic' ? 'BTC' : 'EUR' ); - const request = spec.buildRequests(bidRequests, bidderRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0]).to.undefined; expect(request[1]).to.undefined; @@ -103,14 +107,14 @@ describe('cointrafficBidAdapter', function () { }); it('sends bid request to our endpoint via POST', function () { - const request = spec.buildRequests(bidRequests, bidderRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0].method).to.equal('POST'); expect(request[1].method).to.equal('POST'); }); it('attaches source and version to endpoint URL as query params', function () { - const request = spec.buildRequests(bidRequests, bidderRequests); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request[0].url).to.equal(ENDPOINT_URL); expect(request[1].url).to.equal(ENDPOINT_URL); @@ -119,6 +123,7 @@ describe('cointrafficBidAdapter', function () { describe('interpretResponse', function () { it('should get the correct bid response', function () { + /** @type {BidRequest[]} */ let bidRequest = [{ method: 'POST', url: ENDPOINT_URL, @@ -142,7 +147,7 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

', + ad: '

I am an ad

', mediaType: 'banner', adomain: ['test.com'] } @@ -157,7 +162,7 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

', + ad: '

I am an ad

', meta: { mediaType: 'banner', advertiserDomains: [ @@ -170,7 +175,58 @@ describe('cointrafficBidAdapter', function () { expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); }); + it('should get the correct bid response without advertiser domains specified', function () { + /** @type {BidRequest[]} */ + let bidRequest = [{ + method: 'POST', + url: ENDPOINT_URL, + data: { + placementId: 'testPlacementId', + device: 'desktop', + currency: 'EUR', + sizes: ['300x250'], + bidId: 'bidId12345', + referer: 'www.example.com' + } + }]; + + let serverResponse = { + body: { + requestId: 'bidId12345', + cpm: 3.9, + currency: 'EUR', + netRevenue: true, + width: 300, + height: 250, + creativeId: 'creativeId12345', + ttl: 90, + ad: '

I am an ad

', + mediaType: 'banner', + } + }; + + let expectedResponse = [{ + requestId: 'bidId12345', + cpm: 3.9, + currency: 'EUR', + netRevenue: true, + width: 300, + height: 250, + creativeId: 'creativeId12345', + ttl: 90, + ad: '

I am an ad

', + meta: { + mediaType: 'banner', + advertiserDomains: [] + } + }]; + + let result = spec.interpretResponse(serverResponse, bidRequest[0]); + expect(Object.keys(result)).to.deep.equal(Object.keys(expectedResponse)); + }); + it('should get the correct bid response with different currency', function () { + /** @type {BidRequest[]} */ let bidRequest = [{ method: 'POST', url: ENDPOINT_URL, @@ -194,7 +250,7 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

', + ad: '

I am an ad

', mediaType: 'banner', adomain: ['test.com'] } @@ -209,7 +265,7 @@ describe('cointrafficBidAdapter', function () { height: 250, creativeId: 'creativeId12345', ttl: 90, - ad: '

I am an ad

', + ad: '

I am an ad

', meta: { mediaType: 'banner', advertiserDomains: [ @@ -227,6 +283,7 @@ describe('cointrafficBidAdapter', function () { }); it('should get empty bid response requested currency is not available', function () { + /** @type {BidRequest[]} */ let bidRequest = [{ method: 'POST', url: ENDPOINT_URL, @@ -253,6 +310,7 @@ describe('cointrafficBidAdapter', function () { }); it('should get empty bid response if no server response', function () { + /** @type {BidRequest[]} */ let bidRequest = [{ method: 'POST', url: ENDPOINT_URL, diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js index 32f02def27e..b8c872d879d 100644 --- a/test/spec/modules/colossussspBidAdapter_spec.js +++ b/test/spec/modules/colossussspBidAdapter_spec.js @@ -19,12 +19,12 @@ describe('ColossussspAdapter', function () { }, ortb2Imp: { ext: { + tid: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', data: { pbadslot: '/19968336/prebid_cache_video_adunit' } } }, - transactionId: '3bb2f6da-87a6-4029-aeb0-bfe951372e62', schain: { ver: '1.0', complete: 1, @@ -48,10 +48,101 @@ describe('ColossussspAdapter', function () { auctionStart: 1472239426000, timeout: 5000, uspConsent: '1YN-', + gdprConsent: { + consentString: 'xxx', + gdprApplies: 1 + }, refererInfo: { referer: 'http://www.example.com', reachedTop: true, }, + ortb2: { + app: { + name: 'myappname', + keywords: 'power tools, drills', + content: { + data: [ + { + name: 'www.dataprovider1.com', + ext: { + segtax: 6 + }, + segment: [ + { + id: '687' + }, + { + id: '123' + } + ] + }, + { + name: 'www.dataprovider1.com', + ext: { + segtax: 7 + }, + segment: [ + { + id: '456' + }, + { + id: '789' + } + ] + } + ] + } + }, + site: { + name: 'example', + domain: 'page.example.com', + cat: ['IAB2'], + sectioncat: ['IAB2-2'], + pagecat: ['IAB2-2'], + page: 'https://page.example.com/here.html', + ref: 'https://ref.example.com', + keywords: 'power tools, drills', + search: 'drill', + content: { + userrating: '4', + data: [{ + name: 'www.dataprovider1.com', + ext: { + segtax: 7, + cids: ['iris_c73g5jq96mwso4d8'] + }, + segment: [ + { id: '687' }, + { id: '123' } + ] + }] + }, + ext: { + data: { + pageType: 'article', + category: 'repair' + } + } + }, + user: { + yob: 1985, + gender: 'm', + keywords: 'a,b', + data: [{ + name: 'dataprovider.com', + ext: { segtax: 4 }, + segment: [ + { id: '1' } + ] + }], + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + } + }, bids: [bid] } @@ -87,7 +178,7 @@ describe('ColossussspAdapter', function () { it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr_consent', 'gdpr_require', 'userObj', 'siteObj', 'appObj'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); @@ -97,7 +188,7 @@ describe('ColossussspAdapter', function () { let placements = data['placements']; for (let i = 0; i < placements.length; i++) { let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor', 'gpid'); + expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor', 'gpid', 'tid'); expect(placement.schain).to.be.an('object') expect(placement.placementId).to.be.a('number'); expect(placement.groupId).to.be.a('number'); @@ -106,8 +197,56 @@ describe('ColossussspAdapter', function () { expect(placement.sizes).to.be.an('array'); expect(placement.floor).to.be.an('object'); expect(placement.gpid).to.be.an('string'); + expect(placement.tid).to.be.an('string'); + } + }); + + it('Returns valid video data if array of bids is valid', function () { + const videoBid = { + ...bid, + params: { + placement_id: 0, + }, + mediaTypes: { + video: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + } + } + let serverRequest = spec.buildRequests([videoBid], bidderRequest); + + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr_consent', 'gdpr_require', 'userObj', 'siteObj', 'appObj'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + let placements = data['placements']; + for (let i = 0; i < placements.length; i++) { + let placement = placements[i]; + expect(placement).to.have.all.keys('placementId', 'groupId', 'eids', 'bidId', 'traffic', 'schain', 'floor', 'gpid', 'sizes', + 'playerSize', 'minduration', 'maxduration', 'mimes', 'protocols', 'startdelay', 'placement', 'skip', 'skipafter', + 'minbitrate', 'maxbitrate', 'delivery', 'playbackmethod', 'api', 'linearity', 'tid' + ); + expect(placement.schain).to.be.an('object') + expect(placement.placementId).to.be.a('number'); + expect(placement.bidId).to.be.a('string'); + expect(placement.traffic).to.be.a('string'); + expect(placement.floor).to.be.an('object'); + expect(placement.gpid).to.be.an('string'); + expect(placement.sizes).to.be.an('array'); + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + expect(placement.tid).to.be.an('string'); } }); + it('Returns empty data if no valid requests are passed', function () { serverRequest = spec.buildRequests([], bidderRequest); let data = serverRequest.data; @@ -144,6 +283,35 @@ describe('ColossussspAdapter', function () { }); }); + describe('gpp consent', function () { + it('bidderRequest.gppConsent', () => { + bidderRequest.gppConsent = { + gppString: 'abc123', + applicableSections: [8] + }; + + let serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.property('gpp'); + expect(data).to.have.property('gpp_sid'); + + delete bidderRequest.gppConsent; + }) + + it('bidderRequest.ortb2.regs.gpp', () => { + bidderRequest.ortb2.regs = bidderRequest.ortb2.regs || {}; + bidderRequest.ortb2.regs.gpp = 'abc123'; + bidderRequest.ortb2.regs.gpp_sid = [8]; + + let serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.property('gpp'); + expect(data).to.have.property('gpp_sid'); + }) + }); + describe('interpretResponse', function () { let resObject = { body: [{ @@ -187,6 +355,49 @@ describe('ColossussspAdapter', function () { expect(serverResponses).to.be.an('array').that.is.empty; }); }); + + let videoResObject = { + body: [{ + requestId: '123', + mediaType: 'video', + cpm: 0.3, + width: 320, + height: 50, + vastUrl: '', + ttl: 1000, + creativeId: '123asd', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoServerResponses = spec.interpretResponse(videoResObject); + it('Returns an array of valid server video responses if response object is valid', function () { + expect(videoServerResponses).to.be.an('array').that.is.not.empty; + for (let i = 0; i < videoServerResponses.length; i++) { + let dataItem = videoServerResponses[i]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'mediaType', 'meta'); + expect(dataItem.requestId).to.be.a('string'); + expect(dataItem.cpm).to.be.a('number'); + expect(dataItem.width).to.be.a('number'); + expect(dataItem.height).to.be.a('number'); + expect(dataItem.vastUrl).to.be.a('string'); + expect(dataItem.ttl).to.be.a('number'); + expect(dataItem.creativeId).to.be.a('string'); + expect(dataItem.netRevenue).to.be.a('boolean'); + expect(dataItem.currency).to.be.a('string'); + expect(dataItem.mediaType).to.be.a('string'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + } + it('Returns an empty array if invalid response is passed', function () { + videoServerResponses = spec.interpretResponse('invalid_response'); + expect(videoServerResponses).to.be.an('array').that.is.empty; + }); + }); }); describe('onBidWon', function () { @@ -199,13 +410,13 @@ describe('ColossussspAdapter', function () { }) describe('getUserSyncs', function () { - let userSync = spec.getUserSyncs({}, {}, {}, {}); + let userSync = spec.getUserSyncs({}, {}, { consentString: 'xxx', gdprApplies: 1 }, { consentString: '1YN-' }); it('Returns valid URL and type', function () { expect(userSync).to.be.an('array').with.lengthOf(1); expect(userSync[0].type).to.exist; expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('hms.gif'); - expect(userSync[0].url).to.be.equal('https://sync.colossusssp.com/hms.gif?pbjs=1&coppa=0'); + expect(userSync[0].type).to.be.equal('image'); + expect(userSync[0].url).to.be.equal('https://sync.colossusssp.com/image?pbjs=1&gdpr=0&gdpr_consent=xxx&ccpa_consent=1YN-&coppa=0'); }); }); }); diff --git a/test/spec/modules/compassBidAdapter_spec.js b/test/spec/modules/compassBidAdapter_spec.js index 28021c4f7c0..6a761e63ea1 100644 --- a/test/spec/modules/compassBidAdapter_spec.js +++ b/test/spec/modules/compassBidAdapter_spec.js @@ -76,7 +76,8 @@ describe('CompassBidAdapter', function () { gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', refererInfo: { referer: 'https://test.com' - } + }, + timeout: 500 }; describe('isBidRequestValid', function () { diff --git a/test/spec/modules/conceptxBidAdapter_spec.js b/test/spec/modules/conceptxBidAdapter_spec.js new file mode 100644 index 00000000000..349ee765b71 --- /dev/null +++ b/test/spec/modules/conceptxBidAdapter_spec.js @@ -0,0 +1,136 @@ +// import or require modules necessary for the test, e.g.: +import { expect } from 'chai'; // may prefer 'assert' in place of 'expect' +import { spec } from 'modules/conceptxBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +// import { config } from 'src/config.js'; + +describe('conceptxBidAdapter', function () { + const URL = 'https://conceptx.cncpt-central.com/openrtb'; + + // before(() => { + + // }); + + // after(() => { + // // $$PREBID_GLOBAL$$.bidderSettings = {}; + // }); + + // afterEach(function () { + // config.resetConfig(); + // }); + + const ENDPOINT_URL = `${URL}`; + const ENDPOINT_URL_CONSENT = `${URL}?gdpr_applies=true&consentString=ihaveconsented`; + const adapter = newBidder(spec); + + const bidderRequests = [ + { + bidId: '123', + bidder: 'conceptx', + params: { + site: 'example', + adunit: 'some-id-3' + }, + mediaTypes: { + banner: { + sizes: [[930, 180]], + } + }, + } + ] + + const singleBidRequest = { + bid: [ + { + bidId: '123', + } + ] + } + + const serverResponse = { + body: { + 'bidResponses': [ + { + 'ads': [ + { + 'referrer': 'http://localhost/prebidpage_concept_bidder.html', + 'ttl': 360, + 'html': '

DUMMY

', + 'requestId': '214dfadd1f8826', + 'cpm': 46, + 'currency': 'DKK', + 'width': 930, + 'height': 180, + 'creativeId': 'FAKE-ID', + 'meta': { + 'mediaType': 'banner' + }, + 'netRevenue': true, + 'destinationUrls': { + 'destination': 'https://concept.dk' + } + } + ], + 'matchedAdCount': 1, + 'targetId': '214dfadd1f8826' + } + ] + } + } + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bidderRequests[0])).to.equal(true); + }); + }); + + describe('buildRequests', function () { + it('Test requests', function () { + const request = spec.buildRequests(bidderRequests, {}); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('data'); + const bid = JSON.parse(request[0].data).adUnits[0] + expect(bid.site).to.equal('example'); + expect(bid.adunit).to.equal('some-id-3'); + expect(JSON.stringify(bid.dimensions)).to.equal(JSON.stringify([ + [930, 180]])); + }); + }); + + describe('user privacy', function () { + it('should NOT send GDPR Consent data if gdprApplies equals undefined', function () { + let request = spec.buildRequests(bidderRequests, { gdprConsent: { gdprApplies: undefined, consentString: 'iDoNotConsent' } }); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL); + }); + it('should send GDPR Consent data if gdprApplies', function () { + let request = spec.buildRequests(bidderRequests, { gdprConsent: { gdprApplies: true, consentString: 'ihaveconsented' } }); + expect(request.length).to.equal(1); + expect(request[0]).to.have.property('url') + expect(request[0].url).to.equal(ENDPOINT_URL_CONSENT); + }); + }); + + describe('interpretResponse', function () { + it('should return valid response when passed valid server response', function () { + const interpretedResponse = spec.interpretResponse(serverResponse, singleBidRequest); + const ad = serverResponse.body.bidResponses[0].ads[0] + expect(interpretedResponse).to.have.lengthOf(1); + expect(interpretedResponse[0].cpm).to.equal(ad.cpm); + expect(interpretedResponse[0].width).to.equal(Number(ad.width)); + expect(interpretedResponse[0].height).to.equal(Number(ad.height)); + expect(interpretedResponse[0].creativeId).to.equal(ad.creativeId); + expect(interpretedResponse[0].currency).to.equal(ad.currency); + expect(interpretedResponse[0].netRevenue).to.equal(true); + expect(interpretedResponse[0].ad).to.equal(ad.html); + expect(interpretedResponse[0].ttl).to.equal(360); + }); + }); +}); diff --git a/test/spec/modules/concertAnalyticsAdapter_spec.js b/test/spec/modules/concertAnalyticsAdapter_spec.js index b0aad2f3156..1df73ae04fe 100644 --- a/test/spec/modules/concertAnalyticsAdapter_spec.js +++ b/test/spec/modules/concertAnalyticsAdapter_spec.js @@ -1,5 +1,6 @@ import concertAnalytics from 'modules/concertAnalyticsAdapter.js'; import { expect } from 'chai'; +import {expectEvents} from '../../helpers/analytics.js'; const sinon = require('sinon'); let adapterManager = require('src/adapterManager').default; let events = require('src/events'); @@ -46,9 +47,7 @@ describe('ConcertAnalyticsAdapter', function() { it('should catch all events', function() { sandbox.spy(concertAnalytics, 'track'); - - fireBidEvents(events); - sandbox.assert.callCount(concertAnalytics.track, 5); + expectEvents().to.beTrackedBy(concertAnalytics.track); }); it('should report data for BID_RESPONSE, BID_WON events', function() { diff --git a/test/spec/modules/concertBidAdapter_spec.js b/test/spec/modules/concertBidAdapter_spec.js index 1b869d51bde..4a6a4f2ba60 100644 --- a/test/spec/modules/concertBidAdapter_spec.js +++ b/test/spec/modules/concertBidAdapter_spec.js @@ -1,14 +1,44 @@ import { expect } from 'chai'; import sinon from 'sinon'; -import { spec } from 'modules/concertBidAdapter.js'; -import { getStorageManager } from '../../../src/storageManager.js' +import { spec, storage } from 'modules/concertBidAdapter.js'; +import { hook } from 'src/hook.js'; describe('ConcertAdapter', function () { let bidRequests; let bidRequest; let bidResponse; + let element; + let sandbox; + + before(function () { + hook.ready(); + }); beforeEach(function () { + element = { + x: 0, + y: 0, + width: 0, + height: 0, + getBoundingClientRect: () => { + return { + width: element.width, + height: element.height, + + left: element.x, + top: element.y, + right: element.x + element.width, + bottom: element.y + element.height + }; + } + }; + + $$PREBID_GLOBAL$$.bidderSettings = { + concert: { + storageAllowed: true + } + }; + bidRequests = [ { bidder: 'concert', @@ -18,17 +48,22 @@ describe('ConcertAdapter', function () { }, adUnitCode: 'desktop_leaderboard_variable', bidId: 'foo', - transactionId: '', + ortb2Imp: { + ext: { + tid: '' + } + }, sizes: [[1030, 590]] } ]; bidRequest = { refererInfo: { - referer: 'https://www.google.com' + page: 'https://www.google.com' }, - uspConsent: '1YYY', - gdprConsent: {} + uspConsent: '1YN-', + gdprConsent: {}, + gppConsent: {} }; bidResponse = { @@ -48,6 +83,14 @@ describe('ConcertAdapter', function () { ] } } + + sandbox = sinon.sandbox.create(); + sandbox.stub(document, 'getElementById').withArgs('desktop_leaderboard_variable').returns(element) + }); + + afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + sandbox.restore(); }); describe('spec.isBidRequestValid', function() { @@ -73,7 +116,7 @@ describe('ConcertAdapter', function () { expect(payload).to.have.property('meta'); expect(payload).to.have.property('slots'); - const metaRequiredFields = ['prebidVersion', 'pageUrl', 'screen', 'debug', 'uid', 'optedOut', 'adapterVersion', 'uspConsent', 'gdprConsent']; + const metaRequiredFields = ['prebidVersion', 'pageUrl', 'screen', 'debug', 'uid', 'optedOut', 'adapterVersion', 'uspConsent', 'gdprConsent', 'gppConsent', 'browserLanguage']; const slotsRequiredFields = ['name', 'bidId', 'transactionId', 'sizes', 'partnerId', 'slotType']; metaRequiredFields.forEach(function(field) { @@ -85,7 +128,6 @@ describe('ConcertAdapter', function () { }); it('should not generate uid if the user has opted out', function() { - const storage = getStorageManager(); storage.setDataInLocalStorage('c_nap', 'true'); const request = spec.buildRequests(bidRequests, bidRequest); const payload = JSON.parse(request.data); @@ -94,7 +136,6 @@ describe('ConcertAdapter', function () { }); it('should generate uid if the user has not opted out', function() { - const storage = getStorageManager(); storage.removeDataFromLocalStorage('c_nap'); const request = spec.buildRequests(bidRequests, bidRequest); const payload = JSON.parse(request.data); @@ -102,15 +143,62 @@ describe('ConcertAdapter', function () { expect(payload.meta.uid).to.not.equal(false); }); - it('should grab uid from local storage if it exists', function() { - const storage = getStorageManager(); - storage.setDataInLocalStorage('c_uid', 'foo'); + it('should not generate uid if USP consent disallows', function() { + storage.removeDataFromLocalStorage('c_nap'); + const request = spec.buildRequests(bidRequests, { ...bidRequest, uspConsent: '1YY' }); + const payload = JSON.parse(request.data); + + expect(payload.meta.uid).to.equal(false); + }); + + it('should use sharedid if it exists', function() { + storage.removeDataFromLocalStorage('c_nap'); + const bidRequestsWithSharedId = [{ ...bidRequests[0], userId: { sharedid: { id: '123abc' } } }] + const request = spec.buildRequests(bidRequestsWithSharedId, bidRequest); + const payload = JSON.parse(request.data); + + expect(payload.meta.uid).to.equal('123abc'); + }) + + it('should grab uid from local storage if it exists and sharedid does not', function() { + storage.setDataInLocalStorage('vmconcert_uid', 'foo'); storage.removeDataFromLocalStorage('c_nap'); const request = spec.buildRequests(bidRequests, bidRequest); const payload = JSON.parse(request.data); expect(payload.meta.uid).to.equal('foo'); }); + + it('should add uid2 to eids list if available', function() { + bidRequests[0].userId = { uid2: { id: 'uid123' } } + + const request = spec.buildRequests(bidRequests, bidRequest); + const payload = JSON.parse(request.data); + const meta = payload.meta + + expect(meta.eids.length).to.equal(1); + expect(meta.eids[0].uids[0].id).to.equal('uid123') + expect(meta.eids[0].uids[0].atype).to.equal(3) + }) + + it('should return empty eids list if none are available', function() { + bidRequests[0].userId = { testId: { id: 'uid123' } } + const request = spec.buildRequests(bidRequests, bidRequest); + const payload = JSON.parse(request.data); + const meta = payload.meta + + expect(meta.eids.length).to.equal(0); + }); + + it('should return x/y offset coordiantes when element is present', function() { + Object.assign(element, { x: 100, y: 0, width: 400, height: 400 }) + const request = spec.buildRequests(bidRequests, bidRequest); + const payload = JSON.parse(request.data); + const slot = payload.slots[0]; + + expect(slot.offsetCoordinates.x).to.equal(100) + expect(slot.offsetCoordinates.y).to.equal(0) + }) }); describe('spec.interpretResponse', function() { @@ -133,87 +221,4 @@ describe('ConcertAdapter', function () { expect(bids).to.have.lengthOf(0); }); }); - - describe('spec.getUserSyncs', function() { - it('should not register syncs when iframe is not enabled', function() { - const opts = { - iframeEnabled: false - } - const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent); - expect(sync).to.have.lengthOf(0); - }); - - it('should not register syncs when the user has opted out', function() { - const opts = { - iframeEnabled: true - }; - const storage = getStorageManager(); - storage.setDataInLocalStorage('c_nap', 'true'); - - const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent); - expect(sync).to.have.lengthOf(0); - }); - - it('should set gdprApplies flag to 1 if the user is in area where GDPR applies', function() { - const opts = { - iframeEnabled: true - }; - const storage = getStorageManager(); - storage.removeDataFromLocalStorage('c_nap'); - - bidRequest.gdprConsent = { - gdprApplies: true - }; - - const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent); - expect(sync[0].url).to.have.string('gdpr_applies=1'); - }); - - it('should set gdprApplies flag to 1 if the user is in area where GDPR applies', function() { - const opts = { - iframeEnabled: true - }; - const storage = getStorageManager(); - storage.removeDataFromLocalStorage('c_nap'); - - bidRequest.gdprConsent = { - gdprApplies: false - }; - - const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent); - expect(sync[0].url).to.have.string('gdpr_applies=0'); - }); - - it('should set gdpr consent param with the user\'s choices on consent', function() { - const opts = { - iframeEnabled: true - }; - const storage = getStorageManager(); - storage.removeDataFromLocalStorage('c_nap'); - - bidRequest.gdprConsent = { - gdprApplies: false, - consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==' - }; - - const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent); - expect(sync[0].url).to.have.string('gdpr_consent=BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); - }); - - it('should set ccpa consent param with the user\'s choices on consent', function() { - const opts = { - iframeEnabled: true - }; - const storage = getStorageManager(); - storage.removeDataFromLocalStorage('c_nap'); - - bidRequest.gdprConsent = { - gdprApplies: false, - uspConsent: '1YYY' - }; - - const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent); - expect(sync[0].url).to.have.string('usp_consent=1YY'); - }); - }); }); diff --git a/test/spec/modules/confiantRtdProvider_spec.js b/test/spec/modules/confiantRtdProvider_spec.js new file mode 100644 index 00000000000..8f9fcd0ba98 --- /dev/null +++ b/test/spec/modules/confiantRtdProvider_spec.js @@ -0,0 +1,110 @@ +import * as utils from '../../../src/utils.js'; +import * as hook from '../../../src/hook.js' +import * as events from '../../../src/events.js'; +import CONSTANTS from '../../../src/constants.json'; + +import confiantModule from '../../../modules/confiantRtdProvider.js'; + +const { + injectConfigScript, + setupPage, + subscribeToConfiantCommFrame, + registerConfiantSubmodule +} = confiantModule; + +describe('Confiant RTD module', function () { + describe('setupPage()', function() { + it('should return false if propertId is not present in config', function() { + expect(setupPage({})).to.be.false; + expect(setupPage({ params: {} })).to.be.false; + expect(setupPage({ params: { propertyId: '' } })).to.be.false; + }); + + it('should return true if expected parameters are present', function() { + expect(setupPage({ params: { propertyId: 'clientId' } })).to.be.true; + }); + }); + + describe('Module initialization', function() { + let insertElementStub; + beforeEach(function() { + insertElementStub = sinon.stub(utils, 'insertElement'); + }); + afterEach(function() { + utils.insertElement.restore(); + }); + + it('should subscribe to rovided Window object', function () { + const mockWindow = { addEventListener: sinon.spy() }; + + subscribeToConfiantCommFrame(mockWindow); + + sinon.assert.calledOnce(mockWindow.addEventListener); + }); + + it('should fire BillableEvent as a result for message in comm window', function() { + let listenerCallback; + const mockWindow = { addEventListener: (a, cb) => (listenerCallback = cb) }; + let billableEventsCounter = 0; + const propertyId = 'fff'; + + events.on(CONSTANTS.EVENTS.BILLABLE_EVENT, (e) => { + if (e.vendor === 'confiant') { + billableEventsCounter++; + expect(e.type).to.equal('impression'); + expect(e.billingId).to.be.a('number'); + expect(e.auctionId).to.equal('auctionId'); + expect(e.transactionId).to.equal('transactionId'); + } + }); + + subscribeToConfiantCommFrame(mockWindow, propertyId); + listenerCallback({ + data: { + type: 'cnft:reportBillableEvent:' + propertyId, + auctionId: 'auctionId', + transactionId: 'transactionId' + } + }); + listenerCallback({ + data: { + type: 'cnft:reportBillableEvent:' + propertyId, + auctionId: 'auctionId', + transactionId: 'transactionId' + } + }); + + expect(billableEventsCounter).to.equal(2); + }); + }); + + describe('Sumbodule execution', function() { + let submoduleStub; + let insertElementStub; + beforeEach(function () { + submoduleStub = sinon.stub(hook, 'submodule'); + insertElementStub = sinon.stub(utils, 'insertElement'); + }); + afterEach(function () { + utils.insertElement.restore(); + submoduleStub.restore(); + }); + + function initModule() { + registerConfiantSubmodule(); + + expect(submoduleStub.calledOnceWith('realTimeData')).to.equal(true); + + const registeredSubmoduleDefinition = submoduleStub.getCall(0).args[1]; + expect(registeredSubmoduleDefinition).to.be.an('object'); + expect(registeredSubmoduleDefinition).to.have.own.property('name', 'confiant'); + expect(registeredSubmoduleDefinition).to.have.own.property('init').that.is.a('function'); + + return registeredSubmoduleDefinition; + } + + it('should register Confiant submodule', function () { + initModule(); + }); + }); +}); diff --git a/test/spec/modules/connatixBidAdapter_spec.js b/test/spec/modules/connatixBidAdapter_spec.js new file mode 100644 index 00000000000..16ead9f9458 --- /dev/null +++ b/test/spec/modules/connatixBidAdapter_spec.js @@ -0,0 +1,366 @@ +import { expect } from 'chai'; +import { + spec, + getBidFloor as connatixGetBidFloor +} from '../../../modules/connatixBidAdapter.js'; +import { BANNER } from '../../../src/mediaTypes.js'; + +describe('connatixBidAdapter', function () { + let bid; + + function mockBidRequest() { + const mediaTypes = { + banner: { + sizes: [16, 9], + } + }; + return { + bidId: 'testing', + bidder: 'connatix', + params: { + placementId: '30e91414-545c-4f45-a950-0bec9308ff22' + }, + mediaTypes + }; + }; + + describe('isBidRequestValid', function () { + this.beforeEach(function () { + bid = mockBidRequest(); + }); + + it('Should return true if all required fileds are present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if bidder does not correspond', function () { + bid.bidder = 'abc'; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if bidId is missing', function () { + delete bid.bidId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if params object is missing', function () { + delete bid.params; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if placementId is missing from params', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if mediaTypes is missing', function () { + delete bid.mediaTypes; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if banner is missing from mediaTypes ', function () { + delete bid.mediaTypes.banner; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if sizes is missing from banner object', function () { + delete bid.mediaTypes.banner.sizes; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if sizes is not an array', function () { + bid.mediaTypes.banner.sizes = 'test'; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return false if sizes is an empty array', function () { + bid.mediaTypes.banner.sizes = []; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + it('Should return true if add an extra field was added to the bidRequest', function () { + bid.params.test = 1; + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + }); + + describe('buildRequests', function () { + let serverRequest; + let bidderRequest = { + refererInfo: { + canonicalUrl: '', + numIframes: 0, + reachedTop: true, + referer: 'http://example.com', + stack: ['http://example.com'] + }, + gdprConsent: { + consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + vendorData: {}, + gdprApplies: true + }, + uspConsent: '1YYY', + ortb2: { + site: { + data: { + pageType: 'article' + } + } + } + }; + + this.beforeEach(function () { + bid = mockBidRequest(); + serverRequest = spec.buildRequests([bid], bidderRequest); + }) + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://capi.connatix.com/rtb/hba'); + }); + it('Returns request payload', function () { + expect(serverRequest.data).to.not.empty; + }); + it('Validate request payload', function () { + expect(serverRequest.data.bidRequests[0].bidId).to.equal(bid.bidId); + expect(serverRequest.data.bidRequests[0].placementId).to.equal(bid.params.placementId); + expect(serverRequest.data.bidRequests[0].floor).to.equal(0); + expect(serverRequest.data.bidRequests[0].mediaTypes).to.equal(bid.mediaTypes); + expect(serverRequest.data.bidRequests[0].sizes).to.equal(bid.mediaTypes.sizes); + expect(serverRequest.data.refererInfo).to.equal(bidderRequest.refererInfo); + expect(serverRequest.data.gdprConsent).to.equal(bidderRequest.gdprConsent); + expect(serverRequest.data.uspConsent).to.equal(bidderRequest.uspConsent); + expect(serverRequest.data.ortb2).to.equal(bidderRequest.ortb2); + }); + }); + + describe('interpretResponse', function () { + const CustomerId = '99f20d18-c4b4-4a28-3d8e-d43e2c8cb4ac'; + const PlayerId = 'e4984e88-9ff4-45a3-8b9d-33aabcad634f'; + const Bid = {Cpm: 0.1, LineItems: [], RequestId: '2f897340c4eaa3', Ttl: 86400}; + + let serverResponse; + this.beforeEach(function () { + serverResponse = { + body: { + CustomerId, + PlayerId, + Bids: [ Bid ] + }, + headers: function() { } + }; + }); + + it('Should return an empty array if Bids is null', function () { + serverResponse.body.Bids = null; + + const response = spec.interpretResponse(serverResponse); + expect(response).to.be.an('array').that.is.empty; + }); + + it('Should return an empty array if Bids is empty array', function () { + serverResponse.body.Bids = []; + const response = spec.interpretResponse(serverResponse); + expect(response).to.be.an('array').that.is.empty; + }); + + it('Should return an empty array if CustomerId is null', function () { + serverResponse.body.CustomerId = null; + const response = spec.interpretResponse(serverResponse); + expect(response).to.be.an('array').that.is.empty; + }); + + it('Should return an empty array if PlayerId is null', function () { + serverResponse.body.PlayerId = null; + const response = spec.interpretResponse(serverResponse); + expect(response).to.be.an('array').that.is.empty; + }); + + it('Should return one bid response for one bid', function() { + const bidResponses = spec.interpretResponse(serverResponse); + expect(bidResponses.length).to.equal(1); + }); + + it('Should contains the same values as in the serverResponse', function() { + const bidResponses = spec.interpretResponse(serverResponse); + + const [ bidResponse ] = bidResponses; + expect(bidResponse.requestId).to.equal(serverResponse.body.Bids[0].RequestId); + expect(bidResponse.cpm).to.equal(serverResponse.body.Bids[0].Cpm); + expect(bidResponse.ttl).to.equal(serverResponse.body.Bids[0].Ttl); + expect(bidResponse.currency).to.equal('USD'); + expect(bidResponse.mediaType).to.equal(BANNER); + expect(bidResponse.netRevenue).to.be.true; + }); + + it('Should return n bid responses for n bids', function() { + serverResponse.body.Bids = [ { ...Bid }, { ...Bid } ]; + + const firstBidCpm = 4; + serverResponse.body.Bids[0].Cpm = firstBidCpm; + + const secondBidCpm = 13; + serverResponse.body.Bids[1].Cpm = secondBidCpm; + + const bidResponses = spec.interpretResponse(serverResponse); + expect(bidResponses.length).to.equal(2); + + expect(bidResponses[0].cpm).to.equal(firstBidCpm); + expect(bidResponses[1].cpm).to.equal(secondBidCpm); + }); + }); + + describe('getUserSyncs', function() { + const CustomerId = '99f20d18-c4b4-4a28-3d8e-d43e2c8cb4ac'; + const PlayerId = 'e4984e88-9ff4-45a3-8b9d-33aabcad634f'; + const UserSyncEndpoint = 'https://connatix.com/sync' + const Bid = {Cpm: 0.1, LineItems: [], RequestId: '2f897340c4eaa3', Ttl: 86400}; + + const serverResponse = { + body: { + CustomerId, + PlayerId, + UserSyncEndpoint, + Bids: [ Bid ] + }, + headers: function() { } + }; + + it('Should return an empty array when iframeEnabled: false', function () { + expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [], {}, {}, {})).to.be.an('array').that.is.empty; + }); + it('Should return an empty array when serverResponses is emprt array', function () { + expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [], {}, {}, {})).to.be.an('array').that.is.empty; + }); + it('Should return an empty array when iframeEnabled: true but serverResponses in an empty array', function () { + expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [serverResponse], {}, {}, {})).to.be.an('array').that.is.empty; + }); + it('Should return an empty array when iframeEnabled: true but serverResponses in an not defined or null', function () { + expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, undefined, {}, {}, {})).to.be.an('array').that.is.empty; + expect(spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, null, {}, {}, {})).to.be.an('array').that.is.empty; + }); + it('Should return one user sync object when iframeEnabled is true and serverResponses is not an empry array', function () { + expect(spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [serverResponse], {}, {}, {})).to.be.an('array').that.is.not.empty; + }); + it('Should return a list containing a single object having type: iframe and url: syncUrl', function () { + const userSyncList = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [serverResponse], undefined, undefined, undefined); + const { type, url } = userSyncList[0]; + expect(type).to.equal('iframe'); + expect(url).to.equal(UserSyncEndpoint); + }); + it('Should append gdpr: 0 if gdprConsent object is provided but gdprApplies field is not provided', function () { + const userSyncList = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [serverResponse], + {}, + undefined, + undefined + ); + const { url } = userSyncList[0]; + expect(url).to.equal(`${UserSyncEndpoint}?gdpr=0`); + }); + it('Should append gdpr having the value of gdprApplied if gdprConsent object is present and have gdprApplies field', function () { + const userSyncList = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [serverResponse], + {gdprApplies: true}, + undefined, + undefined + ); + const { url } = userSyncList[0]; + expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1`); + }); + it('Should append gdpr_consent if gdprConsent object is present and have gdprApplies field', function () { + const userSyncList = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [serverResponse], + {gdprApplies: true, consentString: 'alabala'}, + undefined, + undefined + ); + const { url } = userSyncList[0]; + expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=alabala`); + }); + it('Should encodeURI gdpr_consent corectly', function () { + const userSyncList = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [serverResponse], + {gdprApplies: true, consentString: 'test&2'}, + undefined, + undefined + ); + const { url } = userSyncList[0]; + expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=test%262`); + }); + it('Should append usp_consent to the url if uspConsent is provided', function () { + const userSyncList = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [serverResponse], + {gdprApplies: true, consentString: 'test&2'}, + '1YYYN', + undefined + ); + const { url } = userSyncList[0]; + expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=test%262&us_privacy=1YYYN`); + }); + it('Should not modify the sync url if gppConsent param is provided', function () { + const userSyncList = spec.getUserSyncs( + {iframeEnabled: true, pixelEnabled: true}, + [serverResponse], + {gdprApplies: true, consentString: 'test&2'}, + '1YYYN', + {consent: '1'} + ); + const { url } = userSyncList[0]; + expect(url).to.equal(`${UserSyncEndpoint}?gdpr=1&gdpr_consent=test%262&us_privacy=1YYYN`); + }); + }); + + describe('getBidFloor', function () { + this.beforeEach(function () { + bid = mockBidRequest(); + }); + + it('Should return 0 if both getFloor method and bidfloor param from bid are absent.', function () { + const floor = connatixGetBidFloor(bid); + expect(floor).to.equal(0); + }); + + it('Should return the value of the bidfloor parameter if the getFloor method is not defined but the bidfloor parameter is defined', function () { + const floorValue = 3; + bid.params.bidfloor = floorValue; + + const floor = connatixGetBidFloor(bid); + expect(floor).to.equal(floorValue); + }); + + it('Should return the value of the getFloor method if the getFloor method is defined but the bidfloor parameter is not defined', function () { + const floorValue = 7; + bid.getFloor = function() { + return { floor: floorValue }; + }; + + const floor = connatixGetBidFloor(bid); + expect(floor).to.equal(floorValue); + }); + + it('Should return the value of the getFloor method if both getFloor method and bidfloor parameter are defined', function () { + const floorParamValue = 3; + bid.params.bidfloor = floorParamValue; + + const floorMethodValue = 7; + bid.getFloor = function() { + return { floor: floorMethodValue }; + }; + + const floor = connatixGetBidFloor(bid); + expect(floor).to.equal(floorMethodValue); + }); + + it('Should return 0 if the getFloor method is defined and it crash when call it', function () { + bid.getFloor = function() { + throw new Error('error'); + }; + const floor = connatixGetBidFloor(bid); + expect(floor).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/connectIdSystem_spec.js b/test/spec/modules/connectIdSystem_spec.js index 41135a74515..5376ba60886 100644 --- a/test/spec/modules/connectIdSystem_spec.js +++ b/test/spec/modules/connectIdSystem_spec.js @@ -1,12 +1,23 @@ import {expect} from 'chai'; -import {parseQS} from 'src/utils.js'; -import {connectIdSubmodule} from 'modules/connectIdSystem.js'; +import {connectIdSubmodule, storage} from 'modules/connectIdSystem.js'; +import {server} from '../../mocks/xhr'; +import {parseQS, parseUrl} from 'src/utils.js'; +import {uspDataHandler, gppDataHandler} from 'src/adapterManager.js'; + +const TEST_SERVER_URL = 'http://localhost:9876/'; describe('Yahoo ConnectID Submodule', () => { const HASHED_EMAIL = '6bda6f2fa268bf0438b5423a9861a2cedaa5dec163c03f743cfe05c08a8397b2'; + const PUBLISHER_USER_ID = '975484817'; const PIXEL_ID = '1234'; const PROD_ENDPOINT = `https://ups.analytics.yahoo.com/ups/${PIXEL_ID}/fed`; const OVERRIDE_ENDPOINT = 'https://foo/bar'; + const STORAGE_KEY = 'connectId'; + const USP_DATA = '1YYY'; + const GPP_DATA = { + gppString: 'gppconsent', + applicableSections: [6, 7] + }; it('should have the correct module name declared', () => { expect(connectIdSubmodule.name).to.equal('connectId'); @@ -19,158 +30,732 @@ describe('Yahoo ConnectID Submodule', () => { describe('getId()', () => { let ajaxStub; let getAjaxFnStub; + let getCookieStub; + let setCookieStub; + let getLocalStorageStub; + let setLocalStorageStub; + let cookiesEnabledStub; + let localStorageEnabledStub; + let removeLocalStorageDataStub; + let uspConsentDataStub; + let gppConsentDataStub; + let consentData; beforeEach(() => { ajaxStub = sinon.stub(); getAjaxFnStub = sinon.stub(connectIdSubmodule, 'getAjaxFn'); getAjaxFnStub.returns(ajaxStub); + getCookieStub = sinon.stub(storage, 'getCookie'); + setCookieStub = sinon.stub(storage, 'setCookie'); + cookiesEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + setLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); + localStorageEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + removeLocalStorageDataStub = sinon.stub(storage, 'removeDataFromLocalStorage'); + uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData'); + gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData'); + + cookiesEnabledStub.returns(true); + localStorageEnabledStub.returns(true); + uspConsentDataStub.returns(USP_DATA); + gppConsentDataStub.returns(GPP_DATA); consentData = { - gdpr: { - gdprApplies: 1, - consentString: 'GDPR_CONSENT_STRING' - }, - uspConsent: 'USP_CONSENT_STRING' + gdprApplies: 1, + consentString: 'GDPR_CONSENT_STRING' }; }); afterEach(() => { getAjaxFnStub.restore(); + getCookieStub.restore(); + setCookieStub.restore(); + getLocalStorageStub.restore(); + setLocalStorageStub.restore(); + cookiesEnabledStub.restore(); + localStorageEnabledStub.restore(); + removeLocalStorageDataStub.restore(); + uspConsentDataStub.restore(); + gppConsentDataStub.restore(); }); function invokeGetIdAPI(configParams, consentData) { let result = connectIdSubmodule.getId({ params: configParams }, consentData); - if (typeof result === 'object') { + if (typeof result === 'object' && result.callback) { result.callback(sinon.stub()); } return result; } - it('returns undefined if he and pixelId params are not passed', () => { - expect(invokeGetIdAPI({}, consentData)).to.be.undefined; - expect(ajaxStub.callCount).to.equal(0); - }); + describe('Low level storage functionality', () => { + const storageTestCases = [ + { + detail: 'cookie data over local storage data', + cookie: '{"connectId":"foo"}', + localStorage: JSON.stringify({connectId: 'bar'}), + expected: {connectId: 'foo'} + }, + { + detail: 'cookie data if only cookie data exists', + cookie: '{"connectId":"foo"}', + localStorage: undefined, + expected: {connectId: 'foo'} + }, + { + detail: 'local storage data if only it local storage data exists', + cookie: undefined, + localStorage: JSON.stringify({connectId: 'bar'}), + expected: {connectId: 'bar'} + }, + { + detail: 'undefined when both cookie and local storage are empty', + cookie: undefined, + localStorage: undefined, + expected: undefined + } + ] - it('returns undefined if the pixelId param is not passed', () => { - expect(invokeGetIdAPI({ - he: HASHED_EMAIL - }, consentData)).to.be.undefined; - expect(ajaxStub.callCount).to.equal(0); - }); + storageTestCases.forEach(testCase => it(`getId() should return ${testCase.detail}`, function () { + getCookieStub.withArgs(STORAGE_KEY).returns(testCase.cookie); + getLocalStorageStub.withArgs(STORAGE_KEY).returns(testCase.localStorage); - it('returns undefined if the he param is not passed', () => { - expect(invokeGetIdAPI({ - pixelId: PIXEL_ID - }, consentData)).to.be.undefined; - expect(ajaxStub.callCount).to.equal(0); - }); + const result = invokeGetIdAPI({ + he: HASHED_EMAIL, + endpoint: OVERRIDE_ENDPOINT + }, consentData); - it('returns an object with the callback function if the correct params are passed', () => { - let result = invokeGetIdAPI({ - he: HASHED_EMAIL, - pixelId: PIXEL_ID - }, consentData); - expect(result).to.be.an('object').that.has.all.keys('callback'); - expect(result.callback).to.be.a('function'); + expect(result.id).to.be.deep.equal(testCase.expected ? testCase.expected : undefined); + })); + }) + + describe('with invalid module configuration', () => { + it('returns undefined if he, pixelId and puid params are not passed', () => { + expect(invokeGetIdAPI({}, consentData)).to.be.undefined; + expect(ajaxStub.callCount).to.equal(0); + }); + + it('returns undefined if the pixelId param is not passed', () => { + expect(invokeGetIdAPI({ + he: HASHED_EMAIL, + puid: PUBLISHER_USER_ID + }, consentData)).to.be.undefined; + expect(ajaxStub.callCount).to.equal(0); + }); }); - it('Makes an ajax GET request to the production API endpoint with query params', () => { - invokeGetIdAPI({ - he: HASHED_EMAIL, - pixelId: PIXEL_ID - }, consentData); + describe('with valid module configuration', () => { + describe('when data is in client storage', () => { + it('returns an object with the stored ID from cookies for valid module configuration and sync is done', () => { + const cookieData = {connectId: 'foobar'}; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); - const expectedParams = { - he: HASHED_EMAIL, - pixelId: PIXEL_ID, - '1p': '0', - gdpr: '1', - gdpr_consent: consentData.gdpr.consentString, - us_privacy: consentData.uspConsent - }; - const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + expect(result).to.be.an('object').that.has.all.keys('id', 'callback'); + expect(result.id).to.deep.equal(cookieData); + expect(typeof result.callback).to.equal('function'); + }); - expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); - expect(requestQueryParams).to.deep.equal(expectedParams); - expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); - }); + it('returns an object with the stored ID from cookies for valid module configuration with no user sync', () => { + const last13Days = Date.now() - (60 * 60 * 24 * 1000 * 13); + const cookieData = {connectId: 'foobar', he: HASHED_EMAIL, lastSynced: last13Days}; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); - it('Makes an ajax GET request to the specified override API endpoint with query params', () => { - invokeGetIdAPI({ - he: HASHED_EMAIL, - endpoint: OVERRIDE_ENDPOINT - }, consentData); + expect(result).to.be.an('object').that.has.all.keys('id'); + expect(result.id.lastUsed).to.be.a('number'); + cookieData.lastUsed = result.id.lastUsed; + expect(result.id).to.deep.equal(cookieData); + }); - const expectedParams = { - he: HASHED_EMAIL, - '1p': '0', - gdpr: '1', - gdpr_consent: consentData.gdpr.consentString, - us_privacy: consentData.uspConsent - }; - const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + it('returns an object with the stored ID and refreshes the storages with the new lastUsed', () => { + const last13Days = Date.now() - (60 * 60 * 24 * 1000 * 13); + const cookieData = {connectId: 'foobar', he: HASHED_EMAIL, lastSynced: last13Days, lastUsed: 1}; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + const dateNowStub = sinon.stub(Date, 'now'); + dateNowStub.returns(20); + const newCookieData = Object.assign({}, cookieData, {lastUsed: 20}) + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + dateNowStub.restore(); - expect(ajaxStub.firstCall.args[0].indexOf(`${OVERRIDE_ENDPOINT}?`)).to.equal(0); - expect(requestQueryParams).to.deep.equal(expectedParams); - expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); - }); + const expiryDelta = new Date(60 * 60 * 24 * 365 * 1000); + expect(result).to.be.an('object').that.has.all.keys('id'); + expect(setCookieStub.calledOnce).to.be.true; + expect(setCookieStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(setCookieStub.firstCall.args[1]).to.equal(JSON.stringify(newCookieData)); + expect(setCookieStub.firstCall.args[2]).to.equal(expiryDelta.toUTCString()); + expect(setLocalStorageStub.calledOnce).to.be.true; + expect(setLocalStorageStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(setLocalStorageStub.firstCall.args[1]).to.equal(JSON.stringify(newCookieData)); + }); - it('sets the callbacks param of the ajax function call correctly', () => { - invokeGetIdAPI({ - he: HASHED_EMAIL, - pixelId: PIXEL_ID, - }, consentData); + it('returns an object with the stored ID from cookies and no sync when puid stays the same', () => { + const last13Days = Date.now() - (60 * 60 * 24 * 1000 * 13); + const cookieData = {connectId: 'foobar', puid: '123', lastSynced: last13Days}; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + const dateNowStub = sinon.stub(Date, 'now'); + dateNowStub.returns(20); + let result = invokeGetIdAPI({ + puid: '123', + pixelId: PIXEL_ID + }, consentData); + dateNowStub.restore(); - expect(ajaxStub.firstCall.args[1]).to.be.an('object').that.has.all.keys(['success', 'error']); - }); + expect(result).to.be.an('object').that.has.all.keys('id'); + cookieData.lastUsed = 20; + expect(result.id).to.deep.equal(cookieData); + }); - it('sets GDPR consent data flag correctly when call is under GDPR jurisdiction.', () => { - invokeGetIdAPI({ - he: HASHED_EMAIL, - pixelId: PIXEL_ID, - }, consentData); + it('returns an object with the stored ID from cookies and syncs because of expired auto generated puid', () => { + const last13Days = Date.now() - (60 * 60 * 24 * 1000 * 13); + const last31Days = Date.now() - (60 * 60 * 24 * 1000 * 31); + const cookieData = {connectId: 'foo', he: 'email', lastSynced: last13Days, puid: '9', lastUsed: last31Days}; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); - const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); - expect(requestQueryParams.gdpr).to.equal('1'); - expect(requestQueryParams.gdpr_consent).to.equal(consentData.gdpr.consentString); - }); + delete cookieData.puid; + expect(result).to.be.an('object').that.has.all.keys('id', 'callback'); + expect(result.id).to.deep.equal(cookieData); + expect(typeof result.callback).to.equal('function'); + }); - it('sets GDPR consent data flag correctly when call is NOT under GDPR jurisdiction.', () => { - consentData.gdpr.gdprApplies = false; + it('returns an object with the stored ID from cookies and does not sync for valid auto generated puid', () => { + const last13Days = Date.now() - (60 * 60 * 24 * 1000 * 13); + const last29Days = Date.now() - (60 * 60 * 24 * 1000 * 29); + const cookieData = { + connectId: 'foo', + he: HASHED_EMAIL, + lastSynced: last13Days, + puid: '9', + lastUsed: last29Days + }; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + const dateNowStub = sinon.stub(Date, 'now'); + dateNowStub.returns(20); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + dateNowStub.restore(); - invokeGetIdAPI({ - he: HASHED_EMAIL, - pixelId: PIXEL_ID, - }, consentData); + expect(result).to.be.an('object').that.has.all.keys('id'); + cookieData.lastUsed = 20; + expect(result.id).to.deep.equal(cookieData); + }); - const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); - expect(requestQueryParams.gdpr).to.equal('0'); - expect(requestQueryParams.gdpr_consent).to.equal(''); - }); + it('returns an object with the stored ID from localStorage for valid module configuration and sync is done', () => { + const localStorageData = {connectId: 'foobarbaz'}; + getLocalStorageStub.withArgs(STORAGE_KEY).returns(localStorageData); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); - [1, '1', true].forEach(firstPartyParamValue => { - it(`sets 1p payload property to '1' for a config value of ${firstPartyParamValue}`, () => { - invokeGetIdAPI({ - '1p': firstPartyParamValue, - he: HASHED_EMAIL, - pixelId: PIXEL_ID, - }, consentData); + expect(result).to.be.an('object').that.has.all.keys('id', 'callback'); + expect(result.id).to.deep.equal(localStorageData); + expect(typeof result.callback).to.equal('function'); + }); + + it('returns an object with the stored ID from localStorage and refreshes the cookie storage', () => { + const localStorageData = {connectId: 'foobarbaz'}; + getLocalStorageStub.withArgs(STORAGE_KEY).returns(localStorageData); + const dateNowStub = sinon.stub(Date, 'now'); + dateNowStub.returns(1); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + dateNowStub.restore(); + + const expiryDelta = new Date(1 + 60 * 60 * 24 * 365 * 1000); + expect(result).to.be.an('object').that.has.all.keys('id', 'callback'); + expect(setCookieStub.calledOnce).to.be.true; + expect(setCookieStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(setCookieStub.firstCall.args[1]).to.equal(JSON.stringify(localStorageData)); + expect(setCookieStub.firstCall.args[2]).to.equal(expiryDelta.toUTCString()); + }); + + it('Makes an ajax GET request to the production API endpoint with stored puid when id is stale', () => { + const last15Days = Date.now() - (60 * 60 * 24 * 1000 * 15); + const last29Days = Date.now() - (60 * 60 * 24 * 1000 * 29); + const cookieData = { + connectId: 'foobar', + he: HASHED_EMAIL, + lastSynced: last15Days, + puid: '981', + lastUsed: last29Days + }; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + + const expectedParams = { + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + puid: '981', + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('Makes an ajax GET request to the production API endpoint without the stored puid after 30 days', () => { + const last31Days = Date.now() - (60 * 60 * 24 * 1000 * 31); + const cookieData = { + connectId: 'foobar', + he: HASHED_EMAIL, + lastSynced: last31Days, + puid: '981', + lastUsed: last31Days + }; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + + const expectedParams = { + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('Makes an ajax GET request to the production API endpoint with provided puid', () => { + const last3Days = Date.now() - (60 * 60 * 24 * 1000 * 3); + const cookieData = { + connectId: 'foobar', + he: HASHED_EMAIL, + lastSynced: last3Days, + puid: '981', + lastUsed: last3Days + }; + getCookieStub.withArgs(STORAGE_KEY).returns(JSON.stringify(cookieData)); + invokeGetIdAPI({ + pixelId: PIXEL_ID, + puid: PUBLISHER_USER_ID + }, consentData); + + const expectedParams = { + pixelId: PIXEL_ID, + puid: PUBLISHER_USER_ID, + he: HASHED_EMAIL, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('deletes local storage data when expiry has passed', () => { + const localStorageData = {connectId: 'foobarbaz', __expires: Date.now() - 10000}; + getLocalStorageStub.withArgs(STORAGE_KEY).returns(localStorageData); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + expect(removeLocalStorageDataStub.calledOnce).to.be.true; + expect(removeLocalStorageDataStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(result.id).to.equal(undefined); + expect(result.callback).to.be.a('function'); + }); + + it('will not delete local storage data when expiry has not passed', () => { + const localStorageData = {connectId: 'foobarbaz', __expires: Date.now() + 10000}; + getLocalStorageStub.withArgs(STORAGE_KEY).returns(localStorageData); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + expect(removeLocalStorageDataStub.calledOnce).to.be.false; + expect(result.id).to.deep.equal(localStorageData); + }); + }); + + describe('when no data in client storage', () => { + it('returns an object with the callback function if the endpoint override param and the he params are passed', () => { + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + endpoint: OVERRIDE_ENDPOINT + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + }); + + it('returns an object with the callback function if the endpoint override param and the puid params are passed', () => { + let result = invokeGetIdAPI({ + puid: PUBLISHER_USER_ID, + endpoint: OVERRIDE_ENDPOINT + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + }); + + it('returns an object with the callback function if the endpoint override param and the puid and he params are passed', () => { + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + puid: PUBLISHER_USER_ID, + endpoint: OVERRIDE_ENDPOINT + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + }); + + it('returns an object with the callback function if the pixelId and he params are passed', () => { + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + }); + + it('returns an object with the callback function if the pixelId and puid params are passed', () => { + let result = invokeGetIdAPI({ + puid: PUBLISHER_USER_ID, + pixelId: PIXEL_ID + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + }); + + it('returns an object with the callback function if the pixelId, he and puid params are passed', () => { + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + puid: PUBLISHER_USER_ID, + pixelId: PIXEL_ID + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + }); + + it('returns an undefined if the Yahoo specific opt-out key is present in local storage', () => { + localStorage.setItem('connectIdOptOut', '1'); + expect(invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData)).to.be.undefined; + localStorage.removeItem('connectIdOptOut'); + }); + + it('returns an object with the callback function if the correct params are passed and Yahoo opt-out value is not "1"', () => { + localStorage.setItem('connectIdOptOut', 'true'); + let result = invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + expect(result).to.be.an('object').that.has.all.keys('callback'); + expect(result.callback).to.be.a('function'); + localStorage.removeItem('connectIdOptOut'); + }); + + it('Makes an ajax GET request to the production API endpoint with pixelId and he query params', () => { + invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + + const expectedParams = { + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('Makes an ajax GET request to the production API endpoint with pixelId and puid query params', () => { + invokeGetIdAPI({ + puid: PUBLISHER_USER_ID, + pixelId: PIXEL_ID + }, consentData); - const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); - expect(requestQueryParams['1p']).to.equal('1'); + const expectedParams = { + v: '1', + '1p': '0', + gdpr: '1', + puid: PUBLISHER_USER_ID, + pixelId: PIXEL_ID, + gdpr_consent: consentData.consentString, + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('Makes an ajax GET request to the production API endpoint with pixelId, puid and he query params', () => { + invokeGetIdAPI({ + puid: PUBLISHER_USER_ID, + he: HASHED_EMAIL, + pixelId: PIXEL_ID + }, consentData); + + const expectedParams = { + puid: PUBLISHER_USER_ID, + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${PROD_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('Makes an ajax GET request to the specified override API endpoint with query params', () => { + invokeGetIdAPI({ + he: HASHED_EMAIL, + endpoint: OVERRIDE_ENDPOINT + }, consentData); + + const expectedParams = { + he: HASHED_EMAIL, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA, + gpp: GPP_DATA.gppString, + gpp_sid: GPP_DATA.applicableSections.join(',') + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${OVERRIDE_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('Makes an ajax GET request to the specified override API endpoint without GPP', () => { + gppConsentDataStub.returns(undefined); + invokeGetIdAPI({ + he: HASHED_EMAIL, + endpoint: OVERRIDE_ENDPOINT + }, consentData); + + const expectedParams = { + he: HASHED_EMAIL, + '1p': '0', + gdpr: '1', + gdpr_consent: consentData.consentString, + v: '1', + url: TEST_SERVER_URL, + us_privacy: USP_DATA + }; + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + + expect(ajaxStub.firstCall.args[0].indexOf(`${OVERRIDE_ENDPOINT}?`)).to.equal(0); + expect(requestQueryParams).to.deep.equal(expectedParams); + expect(ajaxStub.firstCall.args[3]).to.deep.equal({method: 'GET', withCredentials: true}); + }); + + it('sets the callbacks param of the ajax function call correctly', () => { + invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + }, consentData); + + expect(ajaxStub.firstCall.args[1]).to.be.an('object').that.has.all.keys(['success', 'error']); + }); + + it('sets GDPR consent data flag correctly when call is under GDPR jurisdiction.', () => { + invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + }, consentData); + + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + expect(requestQueryParams.gdpr).to.equal('1'); + expect(requestQueryParams.gdpr_consent).to.equal(consentData.consentString); + }); + + it('sets GDPR consent data flag correctly when call is NOT under GDPR jurisdiction.', () => { + consentData.gdprApplies = false; + + invokeGetIdAPI({ + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + }, consentData); + + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + expect(requestQueryParams.gdpr).to.equal('0'); + expect(requestQueryParams.gdpr_consent).to.equal(''); + }); + + [1, '1', true].forEach(firstPartyParamValue => { + it(`sets 1p payload property to '1' for a config value of ${firstPartyParamValue}`, () => { + invokeGetIdAPI({ + '1p': firstPartyParamValue, + he: HASHED_EMAIL, + pixelId: PIXEL_ID, + }, consentData); + + const requestQueryParams = parseQS(ajaxStub.firstCall.args[0].split('?')[1]); + expect(requestQueryParams['1p']).to.equal('1'); + }); + }); + + it('stores the result in client both storages', () => { + const dateNowStub = sinon.stub(Date, 'now'); + dateNowStub.returns(0); + getAjaxFnStub.restore(); + const upsResponse = {connectid: 'foobarbaz'}; + const expiryDelta = new Date(60 * 60 * 24 * 365 * 1000); + invokeGetIdAPI({ + puid: PUBLISHER_USER_ID, + pixelId: PIXEL_ID + }, consentData); + let request = server.requests[0]; + request.respond( + 200, + {'Content-Type': 'application/json'}, + JSON.stringify(upsResponse) + ); + const storage = Object.assign({}, upsResponse, { + puid: PUBLISHER_USER_ID, + lastSynced: 0, + lastUsed: 0 + }); + dateNowStub.restore(); + + expect(setCookieStub.calledOnce).to.be.true; + expect(setCookieStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(setCookieStub.firstCall.args[1]).to.equal(JSON.stringify(storage)); + expect(setCookieStub.firstCall.args[2]).to.equal(expiryDelta.toUTCString()); + expect(setCookieStub.firstCall.args[3]).to.equal(null); + const cookieDomain = parseUrl(TEST_SERVER_URL).hostname; + expect(setCookieStub.firstCall.args[4]).to.equal(`.${cookieDomain}`); + expect(setLocalStorageStub.calledOnce).to.be.true; + expect(setLocalStorageStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(setLocalStorageStub.firstCall.args[1]).to.deep.equal(JSON.stringify(storage)); + }); + + it('stores the result in localStorage if cookies are not permitted', () => { + getAjaxFnStub.restore(); + cookiesEnabledStub.returns(false); + const dateNowStub = sinon.stub(Date, 'now'); + dateNowStub.returns(0); + const upsResponse = {connectid: 'barfoo'}; + const expectedStoredData = { + connectid: 'barfoo', + puid: PUBLISHER_USER_ID, + lastSynced: 0, + lastUsed: 0 + }; + invokeGetIdAPI({ + puid: PUBLISHER_USER_ID, + pixelId: PIXEL_ID + }, consentData); + let request = server.requests[0]; + request.respond( + 200, + {'Content-Type': 'application/json'}, + JSON.stringify(upsResponse) + ); + dateNowStub.restore(); + + expect(setLocalStorageStub.calledOnce).to.be.true; + expect(setLocalStorageStub.firstCall.args[0]).to.equal(STORAGE_KEY); + expect(setLocalStorageStub.firstCall.args[1]).to.deep.equal(JSON.stringify(expectedStoredData)); + }); }); }); }); describe('decode()', () => { + let userHasOptedOutStub; + beforeEach(() => { + userHasOptedOutStub = sinon.stub(connectIdSubmodule, 'userHasOptedOut'); + userHasOptedOutStub.returns(false); + }); + + afterEach(() => { + userHasOptedOutStub.restore() + }); + const VALID_API_RESPONSES = [{ key: 'connectid', expected: '4567', payload: { connectid: '4567' } + }, + { + key: 'connectId', + expected: '9924', + payload: { + connectId: '9924' + } }]; VALID_API_RESPONSES.forEach(responseData => { it('should return a newly constructed object with the connect ID for a payload with ${responseData.key} key(s)', () => { @@ -185,5 +770,68 @@ describe('Yahoo ConnectID Submodule', () => { expect(connectIdSubmodule.decode(response)).to.be.undefined; }); }); + + it('should return undefined if user has utilised the easy opt-out mechanism', () => { + userHasOptedOutStub.returns(true); + expect(connectIdSubmodule.decode(VALID_API_RESPONSES[0].payload)).to.be.undefined; + }) + }); + + describe('getAjaxFn()', () => { + it('should return a function', () => { + expect(connectIdSubmodule.getAjaxFn()).to.be.a('function'); + }); + }); + + describe('isEUConsentRequired()', () => { + it('should return a function', () => { + expect(connectIdSubmodule.isEUConsentRequired).to.be.a('function'); + }); + + it('should be false if consent data is empty', () => { + expect(connectIdSubmodule.isEUConsentRequired({})).to.be.false; + }); + + it('should be false if consent data.gdpr object is empty', () => { + expect(connectIdSubmodule.isEUConsentRequired({ + gdpr: {} + })).to.be.false; + }); + + it('should return false if consent consentData.applies is false', () => { + expect(connectIdSubmodule.isEUConsentRequired({ + gdprApplies: false + })).to.be.false; + }); + + it('should return true if consent data.gdpr.applies is true', () => { + expect(connectIdSubmodule.isEUConsentRequired({ + gdprApplies: true + })).to.be.true; + }); + }); + + describe('userHasOptedOut()', () => { + afterEach(() => { + localStorage.removeItem('connectIdOptOut'); + }); + + it('should return a function', () => { + expect(connectIdSubmodule.userHasOptedOut).to.be.a('function'); + }); + + it('should return false when local storage key has not been set function', () => { + expect(connectIdSubmodule.userHasOptedOut()).to.be.false; + }); + + it('should return true when local storage key has been set to "1"', () => { + localStorage.setItem('connectIdOptOut', '1'); + expect(connectIdSubmodule.userHasOptedOut()).to.be.true; + }); + + it('should return false when local storage key has not been set to "1"', () => { + localStorage.setItem('connectIdOptOut', 'hello'); + expect(connectIdSubmodule.userHasOptedOut()).to.be.false; + }); }); }); diff --git a/test/spec/modules/connectadBidAdapter_spec.js b/test/spec/modules/connectadBidAdapter_spec.js index 657bc432d06..d8dfcb0ce98 100644 --- a/test/spec/modules/connectadBidAdapter_spec.js +++ b/test/spec/modules/connectadBidAdapter_spec.js @@ -46,9 +46,17 @@ describe('ConnectAd Adapter', function () { auctionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', bidderRequestId: '1c56ad30b9b8ca8', transactionId: 'e76cbb58-f3e1-4ad9-9f4c-718c1919d0df', - userId: { - tdid: '123456' - } + userIdAsEids: [ + { + 'source': 'pubcid.org', + 'uids': [ + { + 'atype': 1, + 'id': '123456' + } + ] + } + ] }]; bidderRequest = { @@ -255,14 +263,17 @@ describe('ConnectAd Adapter', function () { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequ = { refererInfo: { - referer: 'https://connectad.io/page.html', - reachedTop: true, - numIframes: 2, - stack: [ - 'https://connectad.io/page.html', - 'https://connectad.io/iframe1.html', - 'https://connectad.io/iframe2.html' - ] + page: 'https://connectad.io/page.html', + legacy: { + referer: 'https://connectad.io/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'https://connectad.io/page.html', + 'https://connectad.io/iframe1.html', + 'https://connectad.io/iframe2.html' + ] + } } } const request = spec.buildRequests([bidRequest], bidderRequ); diff --git a/test/spec/modules/consentManagementGpp_spec.js b/test/spec/modules/consentManagementGpp_spec.js new file mode 100644 index 00000000000..99d4f94f502 --- /dev/null +++ b/test/spec/modules/consentManagementGpp_spec.js @@ -0,0 +1,913 @@ +import { + consentTimeout, + GPPClient, + requestBidsHook, + resetConsentData, + setConsentConfig, + userCMP +} from 'modules/consentManagementGpp.js'; +import {gppDataHandler} from 'src/adapterManager.js'; +import * as utils from 'src/utils.js'; +import {config} from 'src/config.js'; +import 'src/prebid.js'; +import {MODE_CALLBACK, MODE_MIXED} from '../../../libraries/cmp/cmpClient.js'; +import {GreedyPromise} from '../../../src/utils/promise.js'; + +let expect = require('chai').expect; + +describe('consentManagementGpp', function () { + beforeEach(resetConsentData); + + describe('setConsentConfig tests:', function () { + describe('empty setConsentConfig value', function () { + beforeEach(function () { + sinon.stub(utils, 'logInfo'); + sinon.stub(utils, 'logWarn'); + }); + + afterEach(function () { + utils.logInfo.restore(); + utils.logWarn.restore(); + config.resetConfig(); + resetConsentData(); + }); + + it('should use system default values', function () { + setConsentConfig({ + gpp: {} + }); + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(10000); + sinon.assert.callCount(utils.logInfo, 3); + }); + + it('should exit consent manager if config is not an object', function () { + setConsentConfig(''); + expect(userCMP).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + }); + + it('should exit consentManagement module if config is "undefined"', function () { + setConsentConfig(undefined); + expect(userCMP).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + }); + + it('should not produce any consent metadata', function () { + setConsentConfig(undefined) + let consentMetadata = gppDataHandler.getConsentMeta(); + expect(consentMetadata).to.be.undefined; + sinon.assert.calledOnce(utils.logWarn); + }) + + it('should immediately look up consent data', () => { + setConsentConfig({ + gpp: { + cmpApi: 'invalid' + } + }); + expect(gppDataHandler.ready).to.be.true; + }) + }); + + describe('valid setConsentConfig value', function () { + afterEach(function () { + config.resetConfig(); + }); + + it('results in all user settings overriding system defaults', function () { + let allConfig = { + gpp: { + cmpApi: 'iab', + timeout: 7500 + } + }; + + setConsentConfig(allConfig); + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(7500); + }); + + it('should recognize config.gpp, with default cmpApi and timeout', function () { + setConsentConfig({ + gpp: {} + }); + + expect(userCMP).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(10000); + }); + + it('should enable gppDataHandler', () => { + setConsentConfig({ + gpp: {} + }); + expect(gppDataHandler.enabled).to.be.true; + }); + }); + + describe('static consent string setConsentConfig value', () => { + afterEach(() => { + config.resetConfig(); + }); + + it('results in user settings overriding system defaults', () => { + let staticConfig = { + gpp: { + cmpApi: 'static', + timeout: 7500, + consentData: { + applicableSections: [7], + gppString: 'ABCDEFG1234', + gppVersion: 1, + sectionId: 3, + sectionList: [], + parsedSections: { + usnat: [ + { + MockUsnatParsedFlag: true + }, + ] + }, + } + } + }; + + setConsentConfig(staticConfig); + expect(userCMP).to.be.equal('static'); + const consent = gppDataHandler.getConsentData(); + expect(consent.gppString).to.eql(staticConfig.gpp.consentData.gppString); + expect(consent.gppData).to.eql(staticConfig.gpp.consentData); + expect(consent.sectionData).to.eql(staticConfig.gpp.sectionData); + }); + }); + }); + describe('GPPClient.ping', () => { + function mkPingData(gppVersion) { + return { + gppVersion + } + } + Object.entries({ + 'unknown': { + expectedMode: MODE_CALLBACK, + pingData: mkPingData(), + apiVersion: '1.1', + client({callback}) { + callback(this.pingData); + } + }, + '1.0': { + expectedMode: MODE_MIXED, + pingData: mkPingData('1.0'), + apiVersion: '1.0', + client() { + return this.pingData; + } + }, + '1.1 that runs callback immediately': { + expectedMode: MODE_CALLBACK, + pingData: mkPingData('1.1'), + apiVersion: '1.1', + client({callback}) { + callback(this.pingData); + } + }, + '1.1 that defers callback': { + expectedMode: MODE_CALLBACK, + pingData: mkPingData('1.1'), + apiVersion: '1.1', + client({callback}) { + setTimeout(() => callback(this.pingData), 10); + } + }, + '> 1.1': { + expectedMode: MODE_CALLBACK, + pingData: mkPingData('1.2'), + apiVersion: '1.1', + client({callback}) { + setTimeout(() => callback(this.pingData), 10); + } + } + }).forEach(([t, scenario]) => { + describe(`using CMP version ${t}`, () => { + let clients, mkClient; + beforeEach(() => { + clients = []; + mkClient = ({mode}) => { + const mockClient = function (args) { + if (args.command === 'ping') { + return Promise.resolve(scenario.client(args)); + } + } + mockClient.mode = mode; + mockClient.close = sinon.stub(); + clients.push(mockClient); + return mockClient; + } + }); + + it('should resolve to client with the correct mode', () => { + return GPPClient.ping(mkClient).then(([client]) => { + expect(client.cmp.mode).to.eql(scenario.expectedMode); + }); + }); + + it('should resolve to pingData', () => { + return GPPClient.ping(mkClient).then(([_, pingData]) => { + expect(pingData).to.eql(scenario.pingData); + }); + }); + + it('should .close the probing client', () => { + return GPPClient.ping(mkClient).then(([client]) => { + sinon.assert.called(clients[0].close); + sinon.assert.notCalled(client.cmp.close); + }) + }); + + it('should .tag the client with version', () => { + return GPPClient.ping(mkClient).then(([client]) => { + expect(client.apiVersion).to.eql(scenario.apiVersion); + }) + }) + }) + }); + + it('should reject when mkClient returns null (CMP not found)', () => { + return GPPClient.ping(() => null).catch((err) => { + expect(err.message).to.match(/not found/); + }); + }); + + it('should reject when client rejects', () => { + const err = {some: 'prop'}; + const mockClient = () => Promise.reject(err); + mockClient.close = sinon.stub(); + return GPPClient.ping(() => mockClient).catch((result) => { + expect(result).to.eql(err); + sinon.assert.called(mockClient.close); + }); + }); + + it('should reject when callback is invoked with success = false', () => { + const err = 'error'; + const mockClient = ({callback}) => callback(err, false); + mockClient.close = sinon.stub(); + return GPPClient.ping(() => mockClient).catch((result) => { + expect(result).to.eql(err); + sinon.assert.called(mockClient.close); + }) + }) + }); + + describe('GPPClient.init', () => { + let makeCmp, cmpCalls, cmpResult; + + beforeEach(() => { + cmpResult = {signalStatus: 'ready', gppString: 'mock-str'}; + cmpCalls = []; + makeCmp = sinon.stub().callsFake(() => { + function mockCmp(args) { + cmpCalls.push(args); + return GreedyPromise.resolve(cmpResult); + } + mockCmp.close = sinon.stub(); + return mockCmp; + }); + }); + + it('should re-use same client', (done) => { + GPPClient.init(makeCmp).then(([client]) => { + GPPClient.init(makeCmp).then(([client2, consentPm]) => { + expect(client2).to.equal(client); + expect(cmpCalls.filter((el) => el.command === 'ping').length).to.equal(2) // recycled client should be refreshed + consentPm.then((consent) => { + expect(consent.gppString).to.eql('mock-str'); + done() + }) + }); + }); + }); + + it('should not re-use errors', (done) => { + cmpResult = Promise.reject(new Error()); + GPPClient.init(makeCmp).catch(() => { + cmpResult = {signalStatus: 'ready'}; + return GPPClient.init(makeCmp).then(([client]) => { + expect(client).to.exist; + done() + }) + }) + }) + }) + + describe('GPP client', () => { + const CHANGE_EVENTS = ['sectionChange', 'signalStatus']; + + let gppClient, gppData, cmpReady, eventListener; + + function mockClient(apiVersion = '1.1', cmpVersion = '1.1') { + const mockCmp = sinon.stub().callsFake(function ({command, callback}) { + if (command === 'addEventListener') { + eventListener = callback; + } else { + throw new Error('unexpected command: ' + command); + } + }) + const client = new GPPClient(cmpVersion, mockCmp); + client.apiVersion = apiVersion; + client.getGPPData = sinon.stub().callsFake(() => Promise.resolve(gppData)); + client.isCMPReady = sinon.stub().callsFake(() => cmpReady); + client.events = CHANGE_EVENTS; + return client; + } + + beforeEach(() => { + gppDataHandler.reset(); + eventListener = null; + cmpReady = true; + gppData = { + applicableSections: [7], + gppString: 'mock-string', + parsedSections: { + usnat: [ + { + Field: 'val' + }, + { + SubsectionType: 1, + Gpc: false + } + ] + } + }; + gppClient = mockClient(); + }); + + describe('updateConsent', () => { + it('should update data handler with consent data', () => { + return gppClient.updateConsent().then(data => { + sinon.assert.match(data, gppData); + sinon.assert.match(gppDataHandler.getConsentData(), gppData); + expect(gppDataHandler.ready).to.be.true; + }); + }); + + Object.entries({ + 'emtpy': {}, + 'missing': null + }).forEach(([t, data]) => { + it(`should not update, and reject promise, when gpp data is ${t}`, (done) => { + gppData = data; + gppClient.updateConsent().catch(err => { + expect(err.message).to.match(/empty/); + expect(err.args).to.eql(data == null ? [] : [data]); + expect(gppDataHandler.ready).to.be.false; + done() + }) + }); + }) + + it('should not update when gpp data rejects', (done) => { + gppData = Promise.reject(new Error('err')); + gppClient.updateConsent().catch(err => { + expect(gppDataHandler.ready).to.be.false; + expect(err.message).to.eql('err'); + done(); + }) + }); + + describe('consent data validation', () => { + Object.entries({ + applicableSections: { + 'not an array': 'not-an-array', + }, + gppString: { + 'not a string': 234 + }, + parsedSections: { + 'not an object': 'not-an-object' + } + }).forEach(([prop, tests]) => { + describe(`validation: when ${prop} is`, () => { + Object.entries(tests).forEach(([t, value]) => { + describe(t, () => { + it('should not update', (done) => { + Object.assign(gppData, {[prop]: value}); + gppClient.updateConsent().catch(err => { + expect(err.message).to.match(/unexpected/); + expect(err.args).to.eql([gppData]); + expect(gppDataHandler.ready).to.be.false; + done(); + }); + }); + }) + }); + }); + }); + }); + }); + + describe('init', () => { + beforeEach(() => { + gppClient.isCMPReady = function (pingData) { + return pingData.ready; + } + gppClient.getGPPData = function (pingData) { + return Promise.resolve(pingData); + } + }) + + it('does not use initial pingData if CMP is not ready', () => { + gppClient.init({...gppData, ready: false}); + expect(eventListener).to.exist; + expect(gppDataHandler.ready).to.be.false; + }); + + it('uses initial pingData (and resolves promise) if CMP is ready', () => { + return gppClient.init({...gppData, ready: true}).then(data => { + expect(eventListener).to.exist; + sinon.assert.match(data, gppData); + sinon.assert.match(gppDataHandler.getConsentData(), gppData); + }) + }); + + it('rejects promise when CMP errors out', (done) => { + gppClient.init({ready: false}).catch((err) => { + expect(err.message).to.match(/error/); + expect(err.args).to.eql(['error']) + done(); + }); + eventListener('error', false); + }); + + Object.entries({ + 'empty': {}, + 'null': null, + 'irrelevant': {eventName: 'irrelevant'} + }).forEach(([t, evt]) => { + it(`ignores ${t} events`, () => { + let pm = gppClient.init({ready: false}).catch((err) => err.args[0] !== 'done' && Promise.reject(err)); + eventListener(evt); + eventListener('done', false); + return pm; + }) + }); + + it('rejects the promise when cmpStatus is "error"', (done) => { + const evt = {eventName: 'other', pingData: {cmpStatus: 'error'}}; + gppClient.init({ready: false}).catch(err => { + expect(err.message).to.match(/error/); + expect(err.args).to.eql([evt]); + done(); + }); + eventListener(evt); + }) + + CHANGE_EVENTS.forEach(evt => { + describe(`event: ${evt}`, () => { + function makeEvent(pingData) { + return { + eventName: evt, + pingData + } + } + + let gppData2 + beforeEach(() => { + gppData2 = Object.assign(gppData, {gppString: '2nd'}); + }); + + it('does not fire consent data updates if the CMP is not ready', (done) => { + gppClient.init({ready: false}).catch(() => { + expect(gppDataHandler.ready).to.be.false; + done(); + }); + eventListener({...gppData2, ready: false}); + eventListener('done', false); + }) + + it('fires consent data updates (and resolves promise) if CMP is ready', (done) => { + gppClient.init({ready: false}).then(data => { + sinon.assert.match(data, gppData2); + done() + }); + cmpReady = true; + eventListener(makeEvent({...gppData2, ready: true})); + }); + + it('keeps updating consent data on new events', () => { + let pm = gppClient.init({ready: false}).then(data => { + sinon.assert.match(data, gppData); + sinon.assert.match(gppDataHandler.getConsentData(), gppData); + }); + eventListener(makeEvent({...gppData, ready: true})); + return pm.then(() => { + eventListener(makeEvent({...gppData2, ready: true})) + }).then(() => { + sinon.assert.match(gppDataHandler.getConsentData(), gppData2); + }); + }); + }) + }) + }); + }); + + describe('GPP 1.0 protocol', () => { + let mockCmp, gppClient; + beforeEach(() => { + mockCmp = sinon.stub(); + gppClient = new (GPPClient.getClient('1.0'))('1.0', mockCmp); + }); + + describe('isCMPReady', () => { + Object.entries({ + 'loaded': [true, 'loaded'], + 'other': [false, 'other'], + 'undefined': [false, undefined] + }).forEach(([t, [expected, cmpStatus]]) => { + it(`should be ${expected} when cmpStatus is ${t}`, () => { + expect(gppClient.isCMPReady(Object.assign({}, {cmpStatus}))).to.equal(expected); + }); + }); + }); + + describe('getGPPData', () => { + let gppData, pingData; + beforeEach(() => { + gppData = { + gppString: 'mock-string', + supportedAPIs: ['usnat'], + applicableSections: [7, 8] + } + pingData = { + supportedAPIs: gppData.supportedAPIs + }; + }); + + function mockCmpCommands(commands) { + mockCmp.callsFake(({command, parameter}) => { + if (commands.hasOwnProperty((command))) { + return Promise.resolve(commands[command](parameter)); + } else { + return Promise.reject(new Error(`unrecognized command ${command}`)) + } + }) + } + + it('should retrieve consent string and applicableSections', () => { + mockCmpCommands({ + getGPPData: () => gppData + }) + return gppClient.getGPPData(pingData).then(data => { + sinon.assert.match(data, gppData); + }) + }); + + it('should reject when getGPPData rejects', (done) => { + mockCmpCommands({ + getGPPData: () => Promise.reject(new Error('err')) + }); + gppClient.getGPPData(pingData).catch(err => { + expect(err.message).to.eql('err'); + done(); + }); + }); + + it('should not choke if supportedAPIs is missing', () => { + [gppData, pingData].forEach(ob => { delete ob.supportedAPIs; }) + mockCmpCommands({ + getGPPData: () => gppData + }); + return gppClient.getGPPData(pingData).then(res => { + expect(res.gppString).to.eql(gppData.gppString); + expect(res.parsedSections).to.eql({}); + }) + }) + + describe('section data', () => { + let usnat, parsedUsnat; + + function mockSections(sections) { + mockCmpCommands({ + getGPPData: () => gppData, + getSection: (api) => (sections[api]) + }); + }; + + beforeEach(() => { + usnat = { + MockField: 'val', + OtherField: 'o', + Gpc: true + }; + parsedUsnat = [ + { + MockField: 'val', + OtherField: 'o' + }, + { + SubsectionType: 1, + Gpc: true + } + ] + }); + + it('retrieves section data', () => { + mockSections({usnat}); + return gppClient.getGPPData(pingData).then(data => { + expect(data.parsedSections).to.eql({usnat: parsedUsnat}) + }); + }); + + it('does not choke if a section is missing', () => { + mockSections({usnat}); + gppData.supportedAPIs = ['usnat', 'missing']; + return gppClient.getGPPData(pingData).then(data => { + expect(data.parsedSections).to.eql({usnat: parsedUsnat}); + }) + }); + + it('does not choke if a section fails', () => { + mockSections({usnat, err: Promise.reject(new Error('err'))}); + gppData.supportedAPIs = ['usnat', 'err']; + return gppClient.getGPPData(pingData).then(data => { + expect(data.parsedSections).to.eql({usnat: parsedUsnat}); + }) + }); + }) + }); + }); + + describe('GPP 1.1 protocol', () => { + let mockCmp, gppClient; + beforeEach(() => { + mockCmp = sinon.stub(); + gppClient = new (GPPClient.getClient('1.1'))('1.1', mockCmp); + }); + + describe('isCMPReady', () => { + Object.entries({ + 'ready': [true, 'ready'], + 'not ready': [false, 'not ready'], + 'undefined': [false, undefined] + }).forEach(([t, [expected, signalStatus]]) => { + it(`should be ${expected} when signalStatus is ${t}`, () => { + expect(gppClient.isCMPReady(Object.assign({}, {signalStatus}))).to.equal(expected); + }); + }); + }); + + it('gets GPPData from pingData', () => { + mockCmp.throws(new Error()); + const pingData = { + 'gppVersion': '1.1', + 'cmpStatus': 'loaded', + 'cmpDisplayStatus': 'disabled', + 'supportedAPIs': [ + '5:tcfcav1', + '7:usnat', + '8:usca', + '9:usva', + '10:usco', + '11:usut', + '12:usct' + ], + 'signalStatus': 'ready', + 'cmpId': 31, + 'sectionList': [ + 7 + ], + 'applicableSections': [ + 7 + ], + 'gppString': 'DBABL~BAAAAAAAAgA.QA', + 'parsedSections': { + 'usnat': [ + { + 'Version': 1, + 'SharingNotice': 0, + 'SaleOptOutNotice': 0, + 'SharingOptOutNotice': 0, + 'TargetedAdvertisingOptOutNotice': 0, + 'SensitiveDataProcessingOptOutNotice': 0, + 'SensitiveDataLimitUseNotice': 0, + 'SaleOptOut': 0, + 'SharingOptOut': 0, + 'TargetedAdvertisingOptOut': 0, + 'SensitiveDataProcessing': [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + 'KnownChildSensitiveDataConsents': [ + 0, + 0 + ], + 'PersonalDataConsents': 0, + 'MspaCoveredTransaction': 2, + 'MspaOptOutOptionMode': 0, + 'MspaServiceProviderMode': 0 + }, + { + 'SubsectionType': 1, + 'Gpc': false + } + ] + } + }; + return gppClient.getGPPData(pingData).then((gppData) => { + sinon.assert.match(gppData, { + gppString: pingData.gppString, + applicableSections: pingData.applicableSections, + parsedSections: pingData.parsedSections + }) + }) + }) + }) + + describe('requestBidsHook tests:', function () { + let goodConfig = { + gpp: { + cmpApi: 'iab', + timeout: 7500, + } + }; + + const staticConfig = { + gpp: { + cmpApi: 'static', + timeout: 7500, + consentData: { + gppString: 'abc12345', + applicableSections: [7] + } + } + } + + let didHookReturn; + + beforeEach(resetConsentData); + after(resetConsentData); + + describe('error checks:', function () { + beforeEach(function () { + didHookReturn = false; + sinon.stub(utils, 'logWarn'); + sinon.stub(utils, 'logError'); + }); + + afterEach(function () { + utils.logWarn.restore(); + utils.logError.restore(); + config.resetConfig(); + }); + + it('should throw a warning and return to hooked function when an unknown CMP framework ID is used', function () { + let badCMPConfig = { + gpp: { + cmpApi: 'bad' + } + }; + setConsentConfig(badCMPConfig); + expect(userCMP).to.be.equal(badCMPConfig.gpp.cmpApi); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gppDataHandler.getConsentData(); + + sinon.assert.calledOnce(utils.logWarn); + expect(didHookReturn).to.be.true; + expect(consent).to.be.null; + }); + + it('should call gppDataHandler.setConsentData() when unknown CMP api is used', () => { + setConsentConfig({ + gpp: { + cmpApi: 'invalid' + } + }); + let hookRan = false; + requestBidsHook(() => { + hookRan = true; + }, {}); + expect(hookRan).to.be.true; + expect(gppDataHandler.ready).to.be.true; + }) + + it('should throw proper errors when CMP is not found', function () { + setConsentConfig(goodConfig); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gppDataHandler.getConsentData(); + // throw 2 errors; one for no bidsBackHandler and for CMP not being found (this is an error due to gdpr config) + sinon.assert.calledTwice(utils.logError); + expect(didHookReturn).to.be.false; + expect(consent).to.be.null; + expect(gppDataHandler.ready).to.be.true; + }); + + it('should not trip when adUnits have no size', () => { + setConsentConfig(staticConfig); + let ran = false; + requestBidsHook(() => { + ran = true; + }, { + adUnits: [{ + code: 'test', + mediaTypes: { + video: {} + } + }] + }); + return gppDataHandler.promise.then(() => { + expect(ran).to.be.true; + }); + }); + + it('should continue the auction immediately, without consent data, if timeout is 0', (done) => { + window.__gpp = function () {}; + setConsentConfig({ + gpp: { + cmpApi: 'iab', + timeout: 0 + } + }); + try { + requestBidsHook(() => { + const consent = gppDataHandler.getConsentData(); + expect(consent.applicableSections).to.deep.equal([]); + expect(consent.gppString).to.be.undefined; + done(); + }, {}) + } finally { + delete window.__gpp; + } + }); + }); + + describe('already known consentData:', function () { + let cmpStub = sinon.stub(); + + function mockCMP(pingData) { + return function (command, callback) { + switch (command) { + case 'addEventListener': + // eslint-disable-next-line standard/no-callback-literal + callback({eventName: 'sectionChange', pingData}) + break; + case 'ping': + callback(pingData) + break; + } + } + } + + beforeEach(function () { + didHookReturn = false; + window.__gpp = function () {}; + }); + + afterEach(function () { + config.resetConfig(); + cmpStub.restore(); + delete window.__gpp; + resetConsentData(); + }); + + it('should bypass CMP and simply use previously stored consentData', function () { + let testConsentData = { + applicableSections: [7], + gppString: 'xyz', + }; + + cmpStub = sinon.stub(window, '__gpp').callsFake(mockCMP({...testConsentData, signalStatus: 'ready'})); + setConsentConfig(goodConfig); + requestBidsHook(() => {}, {}); + cmpStub.reset(); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + let consent = gppDataHandler.getConsentData(); + + expect(didHookReturn).to.be.true; + expect(consent.gppString).to.equal(testConsentData.gppString); + expect(consent.applicableSections).to.deep.equal(testConsentData.applicableSections); + sinon.assert.notCalled(cmpStub); + }); + }); + }); +}); diff --git a/test/spec/modules/consentManagementUsp_spec.js b/test/spec/modules/consentManagementUsp_spec.js index 32fd2ddb2e2..e98486754ab 100644 --- a/test/spec/modules/consentManagementUsp_spec.js +++ b/test/spec/modules/consentManagementUsp_spec.js @@ -8,8 +8,9 @@ import { } from 'modules/consentManagementUsp.js'; import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; -import {uspDataHandler} from 'src/adapterManager.js'; +import adapterManager, {gdprDataHandler, uspDataHandler} from 'src/adapterManager.js'; import 'src/prebid.js'; +import {defer} from '../../../src/utils/promise.js'; let expect = require('chai').expect; @@ -23,8 +24,41 @@ function createIFrameMarker() { } describe('consentManagement', function () { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + sandbox.stub(adapterManager, 'callDataDeletionRequest'); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('should enable itself on requestBids using default values', (done) => { + requestBidsHook(() => { + expect(uspDataHandler.enabled).to.be.true; + expect(consentAPI).to.eql('iab'); + done(); + }, {}); + }); + it('should respect configuration set after activation', () => { + setConsentConfig({ + usp: { + cmpApi: 'static', + consentData: { + getUSPData: { + uspString: '1YYY' + } + } + } + }); + expect(uspDataHandler.getConsentData()).to.equal('1YYY'); + }) + describe('setConsentConfig tests:', function () { describe('empty setConsentConfig value', function () { + before(resetConsentData); + beforeEach(function () { sinon.stub(utils, 'logInfo'); sinon.stub(utils, 'logWarn'); @@ -37,11 +71,11 @@ describe('consentManagement', function () { resetConsentData(); }); - it('should not run if no config', function () { + it('should run with defaults if no config', function () { setConsentConfig({}); - expect(consentAPI).to.be.undefined; - expect(consentTimeout).to.be.undefined; - sinon.assert.callCount(utils.logWarn, 1); + expect(consentAPI).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(50); + sinon.assert.callCount(utils.logInfo, 3); }); it('should use system default values', function () { @@ -51,11 +85,11 @@ describe('consentManagement', function () { sinon.assert.callCount(utils.logInfo, 3); }); - it('should exit the consent manager if config.usp is not an object', function() { + it('should not exit the consent manager if config.usp is not an object', function() { setConsentConfig({}); - expect(consentAPI).to.be.undefined; - sinon.assert.calledOnce(utils.logWarn); - sinon.assert.notCalled(utils.logInfo); + expect(consentAPI).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(50); + sinon.assert.callCount(utils.logInfo, 3); }); it('should not produce any USP metadata', function() { @@ -66,16 +100,16 @@ describe('consentManagement', function () { it('should exit the consent manager if only config.gdpr is an object', function() { setConsentConfig({ gdpr: { cmpApi: 'iab' } }); - expect(consentAPI).to.be.undefined; - sinon.assert.calledOnce(utils.logWarn); - sinon.assert.notCalled(utils.logInfo); + expect(consentAPI).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(50); + sinon.assert.callCount(utils.logInfo, 3); }); it('should exit consentManagementUsp module if config is "undefined"', function() { setConsentConfig(undefined); - expect(consentAPI).to.be.undefined; - sinon.assert.calledOnce(utils.logWarn); - sinon.assert.notCalled(utils.logInfo); + expect(consentAPI).to.be.equal('iab'); + expect(consentTimeout).to.be.equal(50); + sinon.assert.callCount(utils.logInfo, 3); }); it('should immediately start looking up consent data', () => { @@ -140,6 +174,7 @@ describe('consentManagement', function () { setConsentConfig(staticConfig); expect(consentAPI).to.be.equal('static'); expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used + expect(uspDataHandler.getConsentData()).to.eql(staticConfig.usp.consentData.getUSPData.uspString) expect(staticConsentData.usPrivacy).to.be.equal(staticConfig.usp.consentData.getUSPData.uspString); }); }); @@ -277,8 +312,11 @@ describe('consentManagement', function () { describe('USPAPI workflow for iframed page', function () { let ifr = null; let stringifyResponse = false; + let mockApi, replySent; beforeEach(function () { + mockApi = sinon.stub(); + replySent = defer(); sinon.stub(utils, 'logError'); sinon.stub(utils, 'logWarn'); ifr = createIFrameMarker(); @@ -298,17 +336,21 @@ describe('consentManagement', function () { function uspapiMessageHandler(event) { if (event && event.data) { - var data = event.data; + const data = event.data; if (data.__uspapiCall) { - var callId = data.__uspapiCall.callId; - var response = { - __uspapiReturn: { - callId, - returnValue: { uspString: '1YY' }, - success: true + const {command, version, callId} = data.__uspapiCall; + let response = mockApi(command, version, callId); + if (response) { + response = { + __uspapiReturn: { + callId, + returnValue: response, + success: true + } } - }; - event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + event.source.postMessage(stringifyResponse ? JSON.stringify(response) : response, '*'); + replySent.resolve(); + } } } } @@ -321,6 +363,11 @@ describe('consentManagement', function () { function testIFramedPage(testName, messageFormatString) { it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { stringifyResponse = messageFormatString; + mockApi.callsFake((cmd) => { + if (cmd === 'getUSPData') { + return { uspString: '1YY' } + } + }) setConsentConfig(goodConfig); requestBidsHook(() => { let consent = uspDataHandler.getConsentData(); @@ -331,6 +378,20 @@ describe('consentManagement', function () { }, {}); }); } + + it('fires deletion request on registerDeletion', (done) => { + mockApi.callsFake((cmd) => { + return cmd === 'registerDeletion' + }) + sinon.assert.notCalled(adapterManager.callDataDeletionRequest); + setConsentConfig(goodConfig); + replySent.promise.then(() => { + setTimeout(() => { // defer again to give time for the message to get through + sinon.assert.calledOnce(adapterManager.callDataDeletionRequest); + done() + }, 200) + }) + }); }); describe('test without iframe locater', function() { @@ -376,23 +437,19 @@ describe('consentManagement', function () { }); describe('USPAPI workflow for normal pages:', function () { - let uspapiStub = sinon.stub(); let ifr = null; beforeEach(function () { didHookReturn = false; ifr = createIFrameMarker(); - sinon.stub(utils, 'logError'); - sinon.stub(utils, 'logWarn'); + sandbox.stub(utils, 'logError'); + sandbox.stub(utils, 'logWarn'); window.__uspapi = function() {}; }); afterEach(function () { config.resetConfig(); $$PREBID_GLOBAL$$.requestBids.removeAll(); - uspapiStub.restore(); - utils.logError.restore(); - utils.logWarn.restore(); document.body.removeChild(ifr); delete window.__uspapi; resetConsentData(); @@ -403,7 +460,7 @@ describe('consentManagement', function () { uspString: '1NY' }; - uspapiStub = sinon.stub(window, '__uspapi').callsFake((...args) => { + sandbox.stub(window, '__uspapi').callsFake((...args) => { args[2](testConsentData, true); }); @@ -424,7 +481,7 @@ describe('consentManagement', function () { uspString: '1NY' }; - uspapiStub = sinon.stub(window, '__uspapi').callsFake((...args) => { + sandbox.stub(window, '__uspapi').callsFake((...args) => { args[2](testConsentData, true); }); @@ -439,6 +496,32 @@ describe('consentManagement', function () { expect(consentMeta.usp).to.equal(testConsentData.uspString); expect(consentMeta.generatedAt).to.be.above(1644367751709); }); + + it('registers deletion request event listener', () => { + let listener; + sandbox.stub(window, '__uspapi').callsFake((cmd, _, cb) => { + if (cmd === 'registerDeletion') { + listener = cb; + } + }); + setConsentConfig(goodConfig); + sinon.assert.notCalled(adapterManager.callDataDeletionRequest); + listener(); + sinon.assert.calledOnce(adapterManager.callDataDeletionRequest); + }); + + it('does not fail if CMP does not support registerDeletion', () => { + sandbox.stub(window, '__uspapi').callsFake((cmd, _, cb) => { + if (cmd === 'registerDeletion') { + throw new Error('CMP not compliant'); + } else if (cmd === 'getUSPData') { + // eslint-disable-next-line standard/no-callback-literal + cb({uspString: 'string'}, true); + } + }); + setConsentConfig(goodConfig); + expect(uspDataHandler.getConsentData()).to.eql('string'); + }); }); }); }); diff --git a/test/spec/modules/consentManagement_spec.js b/test/spec/modules/consentManagement_spec.js index 712e311e433..c1ed042a2c8 100644 --- a/test/spec/modules/consentManagement_spec.js +++ b/test/spec/modules/consentManagement_spec.js @@ -1,7 +1,17 @@ -import { setConsentConfig, requestBidsHook, resetConsentData, userCMP, consentTimeout, allowAuction, staticConsentData, gdprScope } from 'modules/consentManagement.js'; -import { gdprDataHandler } from 'src/adapterManager.js'; +import { + actionTimeout, + consentTimeout, + gdprScope, + loadConsentData, + requestBidsHook, + resetConsentData, + setConsentConfig, + staticConsentData, + userCMP +} from 'modules/consentManagement.js'; +import {gdprDataHandler} from 'src/adapterManager.js'; import * as utils from 'src/utils.js'; -import { config } from 'src/config.js'; +import {config} from 'src/config.js'; import 'src/prebid.js'; let expect = require('chai').expect; @@ -69,17 +79,12 @@ describe('consentManagement', function () { let allConfig = { cmpApi: 'iab', timeout: 7500, - allowAuctionWithoutConsent: false, defaultGdprScope: true }; setConsentConfig(allConfig); expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(7500); - expect(allowAuction).to.deep.equal({ - value: false, - definedInConfig: true - }); expect(gdprScope).to.be.true; }); @@ -125,16 +130,11 @@ describe('consentManagement', function () { setConsentConfig({ cmpApi: 'iab', timeout: 3333, - allowAuctionWithoutConsent: false, gdpr: false }); expect(userCMP).to.be.equal('iab'); expect(consentTimeout).to.be.equal(3333); - expect(allowAuction).to.deep.equal({ - value: false, - definedInConfig: true - }); expect(gdprScope).to.be.equal(false); }); @@ -145,68 +145,17 @@ describe('consentManagement', function () { }); describe('static consent string setConsentConfig value', () => { - afterEach(() => { - config.resetConfig(); - }); - it('results in user settings overriding system defaults for v1 spec', () => { - let staticConfig = { - cmpApi: 'static', - timeout: 7500, - allowAuctionWithoutConsent: false, - consentData: { - getConsentData: { - 'gdprApplies': true, - 'hasGlobalScope': false, - 'consentData': 'BOOgjO9OOgjO9APABAENAi-AAAAWd7_______9____7_9uz_Gv_r_ff_3nW0739P1A_r_Oz_rm_-zzV44_lpQQRCEA' - }, - getVendorConsents: { - 'metadata': 'BOOgjO9OOgjO9APABAENAi-AAAAWd7_______9____7_9uz_Gv_r_ff_3nW0739P1A_r_Oz_rm_-zzV44_lpQQRCEA', - 'gdprApplies': true, - 'hasGlobalScope': false, - 'isEU': true, - 'cookieVersion': 1, - 'created': '2018-05-29T07:45:48.522Z', - 'lastUpdated': '2018-05-29T07:45:48.522Z', - 'cmpId': 15, - 'cmpVersion': 1, - 'consentLanguage': 'EN', - 'vendorListVersion': 34, - 'maxVendorId': 359, - 'purposeConsents': { - '1': true, - '2': true, - '3': true, - '4': true, - '5': true - }, - 'vendorConsents': { - '1': true, - '2': true, - '3': true, - '4': true, - '5': false - } - } - } - }; - - setConsentConfig(staticConfig); - expect(userCMP).to.be.equal('static'); - expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used - expect(allowAuction).to.deep.equal({ - value: false, - definedInConfig: true - }); - expect(staticConsentData).to.be.equal(staticConfig.consentData); - }); + Object.entries({ + 'getTCData': (cfg) => ({getTCData: cfg}), + 'consent data directly': (cfg) => cfg, + }).forEach(([t, packageCfg]) => { + describe(`using ${t}`, () => { + afterEach(() => { + config.resetConfig(); + }); - it('results in user settings overriding system defaults for v2 spec', () => { - let staticConfig = { - cmpApi: 'static', - timeout: 7500, - allowAuctionWithoutConsent: false, - consentData: { - getTCData: { + it('results in user settings overriding system defaults for v2 spec', () => { + const consentData = { 'tcString': 'COuqj-POu90rDBcBkBENAZCgAPzAAAPAACiQFwwBAABAA1ADEAbQC4YAYAAgAxAG0A', 'cmpId': 92, 'cmpVersion': 100, @@ -269,42 +218,42 @@ describe('consentManagement', function () { 'legitimateInterests': {} } } - } - } - }; - - setConsentConfig(staticConfig); - expect(userCMP).to.be.equal('static'); - expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used - expect(allowAuction).to.deep.equal({ - value: false, - definedInConfig: true + }; + + setConsentConfig({ + cmpApi: 'static', + timeout: 7500, + consentData: packageCfg(consentData) + }); + expect(userCMP).to.be.equal('static'); + expect(consentTimeout).to.be.equal(0); // should always return without a timeout when config is used + expect(gdprScope).to.be.equal(false); + const consent = gdprDataHandler.getConsentData(); + expect(consent.consentString).to.eql(consentData.tcString); + expect(consent.vendorData).to.eql(consentData); + expect(staticConsentData).to.be.equal(consentData); + }); }); - expect(gdprScope).to.be.equal(false); - expect(staticConsentData).to.be.equal(staticConfig.consentData); }); }); }); describe('requestBidsHook tests:', function () { - let goodConfigWithCancelAuction = { + let goodConfig = { cmpApi: 'iab', timeout: 7500, - allowAuctionWithoutConsent: false }; - let goodConfigWithAllowAuction = { - cmpApi: 'iab', + const staticConfig = { + cmpApi: 'static', timeout: 7500, - allowAuctionWithoutConsent: true - }; + consentData: {} + } let didHookReturn; - afterEach(function () { - gdprDataHandler.consentData = null; - resetConsentData(); - }); + beforeEach(resetConsentData); + after(resetConsentData) describe('error checks:', function () { beforeEach(function () { @@ -317,7 +266,6 @@ describe('consentManagement', function () { utils.logWarn.restore(); utils.logError.restore(); config.resetConfig(); - resetConsentData(); }); it('should throw a warning and return to hooked function when an unknown CMP framework ID is used', function () { @@ -345,7 +293,7 @@ describe('consentManagement', function () { }) it('should throw proper errors when CMP is not found', function () { - setConsentConfig(goodConfigWithCancelAuction); + setConsentConfig(goodConfig); requestBidsHook(() => { didHookReturn = true; @@ -357,40 +305,69 @@ describe('consentManagement', function () { expect(consent).to.be.null; expect(gdprDataHandler.ready).to.be.true; }); + + it('should not trip when adUnits have no size', () => { + setConsentConfig(staticConfig); + let ran = false; + requestBidsHook(() => { + ran = true; + }, {adUnits: [{code: 'test', mediaTypes: {video: {}}}]}); + return gdprDataHandler.promise.then(() => { + expect(ran).to.be.true; + }); + }); + + it('should continue the auction immediately, without consent data, if timeout is 0', (done) => { + setConsentConfig({ + cmpApi: 'iab', + timeout: 0, + defaultGdprScope: true + }); + window.__tcfapi = function () {}; + try { + requestBidsHook(() => { + const consent = gdprDataHandler.getConsentData(); + expect(consent.gdprApplies).to.be.true; + expect(consent.consentString).to.be.undefined; + done(); + }, {}) + } finally { + delete window.__tcfapi; + } + }) }); describe('already known consentData:', function () { let cmpStub = sinon.stub(); + function mockCMP(cmpResponse) { + return function(...args) { + args[2](Object.assign({eventStatus: 'tcloaded'}, cmpResponse), true); + } + } + beforeEach(function () { didHookReturn = false; - window.__cmp = function () { }; + window.__tcfapi = function () { }; }); afterEach(function () { config.resetConfig(); cmpStub.restore(); - delete window.__cmp; + delete window.__tcfapi; resetConsentData(); }); it('should bypass CMP and simply use previously stored consentData', function () { let testConsentData = { gdprApplies: true, - consentData: 'xyz' + tcString: 'xyz', }; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); - }); - setConsentConfig(goodConfigWithAllowAuction); + cmpStub = sinon.stub(window, '__tcfapi').callsFake(mockCMP(testConsentData)); + setConsentConfig(goodConfig); requestBidsHook(() => { }, {}); - cmpStub.restore(); - - // reset the stub to ensure it wasn't called during the second round of calls - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); - }); + cmpStub.reset(); requestBidsHook(() => { didHookReturn = true; @@ -398,7 +375,7 @@ describe('consentManagement', function () { let consent = gdprDataHandler.getConsentData(); expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal(testConsentData.consentData); + expect(consent.consentString).to.equal(testConsentData.tcString); expect(consent.gdprApplies).to.be.true; sinon.assert.notCalled(cmpStub); }); @@ -406,12 +383,10 @@ describe('consentManagement', function () { it('should not set consent.gdprApplies to true if defaultGdprScope is true', function () { let testConsentData = { gdprApplies: false, - consentData: 'xyz' + tcString: 'xyz', }; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); - }); + cmpStub = sinon.stub(window, '__tcfapi').callsFake(mockCMP(testConsentData)); setConsentConfig({ cmpApi: 'iab', @@ -464,7 +439,7 @@ describe('consentManagement', function () { function testIFramedPage(testName, messageFormatString, tarConsentString, ver) { it(`should return the consent string from a postmessage + addEventListener response - ${testName}`, (done) => { stringifyResponse = messageFormatString; - setConsentConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfig); requestBidsHook(() => { let consent = gdprDataHandler.getConsentData(); sinon.assert.notCalled(utils.logError); @@ -488,93 +463,6 @@ describe('consentManagement', function () { resetConsentData(); }); - describe('v1 CMP workflow for safeframe page', function () { - let registerStub = sinon.stub(); - let ifrSf = null; - beforeEach(function () { - didHookReturn = false; - window.$sf = { - ext: { - register: function () { }, - cmp: function () { } - } - }; - ifrSf = createIFrameMarker('__cmpLocator'); - }); - - afterEach(function () { - delete window.$sf; - registerStub.restore(); - document.body.removeChild(ifrSf); - }); - - it('should return the consent data from a safeframe callback', function () { - let testConsentData = { - data: { - msgName: 'cmpReturn', - vendorConsents: { - metadata: 'abc123def', - gdprApplies: true - }, - vendorConsentData: { - consentData: 'abc123def', - gdprApplies: true - } - } - }; - registerStub = sinon.stub(window.$sf.ext, 'register').callsFake((...args) => { - args[2](testConsentData.data.msgName, testConsentData.data); - }); - - setConsentConfig(goodConfigWithAllowAuction); - requestBidsHook(() => { - didHookReturn = true; - }, { adUnits: [{ sizes: [[300, 250]] }] }); - let consent = gdprDataHandler.getConsentData(); - - sinon.assert.notCalled(utils.logWarn); - sinon.assert.notCalled(utils.logError); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal('abc123def'); - expect(consent.gdprApplies).to.be.true; - expect(consent.apiVersion).to.equal(1); - }); - }); - - describe('v1 CMP workflow for iframe pages', function () { - stringifyResponse = false; - let ifr1 = null; - - beforeEach(function () { - ifr1 = createIFrameMarker('__cmpLocator'); - cmpPostMessageCb = creatCmpMessageHandler('__cmp', { - consentData: 'encoded_consent_data_via_post_message', - gdprApplies: true, - }); - window.addEventListener('message', cmpPostMessageCb, false); - }); - - afterEach(function () { - delete window.__cmp; // deletes the local copy made by the postMessage CMP call function - document.body.removeChild(ifr1); - window.removeEventListener('message', cmpPostMessageCb); - }); - - // Run tests with JSON response and String response - // from CMP window postMessage listener. - testIFramedPage('with/JSON response', false, 'encoded_consent_data_via_post_message', 1); - testIFramedPage('with/String response', true, 'encoded_consent_data_via_post_message', 1); - - it('should contain correct V1 CMP definition', (done) => { - setConsentConfig(goodConfigWithAllowAuction); - requestBidsHook(() => { - const nbArguments = window.__cmp.toString().split('\n')[0].split(', ').length; - expect(nbArguments).to.equal(3); - done(); - }, {}); - }); - }); - describe('v2 CMP workflow for iframe pages:', function () { stringifyResponse = false; let ifr2 = null; @@ -598,15 +486,6 @@ describe('consentManagement', function () { testIFramedPage('with/JSON response', false, 'abc12345234', 2); testIFramedPage('with/String response', true, 'abc12345234', 2); - - it('should contain correct v2 CMP definition', (done) => { - setConsentConfig(goodConfigWithAllowAuction); - requestBidsHook(() => { - const nbArguments = window.__tcfapi.toString().split('\n')[0].split(', ').length; - expect(nbArguments).to.equal(4); - done(); - }, {}); - }); }); }); @@ -627,40 +506,6 @@ describe('consentManagement', function () { resetConsentData(); }); - describe('v1 CMP workflow for normal pages:', function () { - beforeEach(function () { - window.__cmp = function () { }; - }); - - afterEach(function () { - delete window.__cmp; - }); - - it('performs lookup check and stores consentData for a valid existing user', function () { - let testConsentData = { - gdprApplies: true, - consentData: 'BOJy+UqOJy+UqABAB+AAAAAZ+A==' - }; - cmpStub = sinon.stub(window, '__cmp').callsFake((...args) => { - args[2](testConsentData); - }); - - setConsentConfig(goodConfigWithAllowAuction); - - requestBidsHook(() => { - didHookReturn = true; - }, {}); - let consent = gdprDataHandler.getConsentData(); - - sinon.assert.notCalled(utils.logWarn); - sinon.assert.notCalled(utils.logError); - expect(didHookReturn).to.be.true; - expect(consent.consentString).to.equal(testConsentData.consentData); - expect(consent.gdprApplies).to.be.true; - expect(consent.apiVersion).to.equal(1); - }); - }); - describe('v2 CMP workflow for normal pages:', function () { beforeEach(function() { window.__tcfapi = function () { }; @@ -681,7 +526,7 @@ describe('consentManagement', function () { args[2](testConsentData, true); }); - setConsentConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfig); requestBidsHook(() => { didHookReturn = true; @@ -708,7 +553,7 @@ describe('consentManagement', function () { args[2](testConsentData, true); }); - setConsentConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfig); requestBidsHook(() => { didHookReturn = true; @@ -733,7 +578,7 @@ describe('consentManagement', function () { args[2](testConsentData, true); }); - setConsentConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfig); requestBidsHook(() => { didHookReturn = true; @@ -747,7 +592,7 @@ describe('consentManagement', function () { expect(consent.apiVersion).to.equal(2); }); - it('throws an error when processCmpData check fails + does not call requestBids callbcack even when allowAuction is true', function () { + it('throws an error when processCmpData check fails + does not call requestBids callback', function () { let testConsentData = {}; let bidsBackHandlerReturn = false; @@ -755,9 +600,9 @@ describe('consentManagement', function () { args[2](testConsentData); }); - setConsentConfig(goodConfigWithAllowAuction); + setConsentConfig(goodConfig); - sinon.assert.calledOnce(utils.logWarn); + sinon.assert.notCalled(utils.logWarn); sinon.assert.notCalled(utils.logError); [utils.logWarn, utils.logError].forEach((stub) => stub.reset()); @@ -775,25 +620,124 @@ describe('consentManagement', function () { expect(gdprDataHandler.ready).to.be.true; }); - it('allows the auction when CMP is unresponsive', (done) => { - setConsentConfig({ - cmpApi: 'iab', - timeout: 10, - defaultGdprScope: true + describe('when proper consent is not available', () => { + let tcfStub; + + function runAuction() { + setConsentConfig({ + cmpApi: 'iab', + timeout: 10, + defaultGdprScope: true + }); + return new Promise((resolve, reject) => { + requestBidsHook(() => { + didHookReturn = true; + }, {}); + setTimeout(() => didHookReturn ? resolve() : reject(new Error('Auction did not run')), 20); + }) + } + + function mockTcfEvent(tcdata) { + tcfStub.callsFake((api, version, cb) => { + if (api === 'addEventListener' && version === 2) { + // eslint-disable-next-line standard/no-callback-literal + cb(tcdata, true) + } + }); + } + + beforeEach(() => { + tcfStub = sinon.stub(window, '__tcfapi'); }); - requestBidsHook(() => { - didHookReturn = true; - }, {}); + afterEach(() => { + tcfStub.restore(); + }) + + it('should continue auction with null consent when CMP is unresponsive', () => { + return runAuction().then(() => { + const consent = gdprDataHandler.getConsentData(); + expect(consent.gdprApplies).to.be.true; + expect(consent.consentString).to.be.undefined; + expect(gdprDataHandler.ready).to.be.true; + }); + }); - setTimeout(() => { - expect(didHookReturn).to.be.true; - const consent = gdprDataHandler.getConsentData(); - expect(consent.gdprApplies).to.be.true; - expect(consent.consentString).to.be.undefined; - expect(gdprDataHandler.ready).to.be.true; - done(); - }, 20); + it('should use consent provided by events other than tcloaded', () => { + mockTcfEvent({ + eventStatus: 'cmpuishown', + tcString: 'mock-consent-string', + vendorData: {} + }); + return runAuction().then(() => { + const consent = gdprDataHandler.getConsentData(); + expect(consent.gdprApplies).to.be.true; + expect(consent.consentString).to.equal('mock-consent-string'); + expect(consent.vendorData.vendorData).to.eql({}); + expect(gdprDataHandler.ready).to.be.true; + }); + }); + + it('should timeout after actionTimeout from the first CMP event', (done) => { + mockTcfEvent({ + eventStatus: 'cmpuishown', + tcString: 'mock-consent-string', + vendorData: {} + }); + setConsentConfig({ + timeout: 1000, + actionTimeout: 100, + cmpApi: 'iab', + defaultGdprScope: true + }); + let hookRan = false; + requestBidsHook(() => { + hookRan = true; + }, {}); + setTimeout(() => { + expect(hookRan).to.be.true; + done(); + }, 200) + }); + + it('should still pick up consent data when actionTimeout is 0', (done) => { + mockTcfEvent({ + eventStatus: 'tcloaded', + tcString: 'mock-consent-string', + vendorData: {} + }); + setConsentConfig({ + timeout: 1000, + actionTimeout: 0, + cmpApi: 'iab', + defaultGdprScope: true + }); + requestBidsHook(() => { + expect(gdprDataHandler.getConsentData().consentString).to.eql('mock-consent-string'); + done(); + }, {}) + }) + + Object.entries({ + 'null': null, + 'empty': '', + 'undefined': undefined + }).forEach(([t, cs]) => { + // some CMPs appear to reply with an empty consent string in 'cmpuishown' - make sure we don't use that + it(`should NOT use "default" consent if string is ${t}`, () => { + mockTcfEvent({ + eventStatus: 'cmpuishown', + tcString: cs, + vendorData: {random: 'junk'} + }); + return runAuction().then(() => { + const consent = gdprDataHandler.getConsentData(); + expect(consent.gdprApplies).to.be.true; + expect(consent.consentString).to.be.undefined; + expect(consent.vendorData).to.be.undefined; + }); + }) + }); }); it('It still considers it a valid cmp response if gdprApplies is not a boolean', function () { diff --git a/test/spec/modules/consumableBidAdapter_spec.js b/test/spec/modules/consumableBidAdapter_spec.js index b70cd6fe631..deeb8f7100d 100644 --- a/test/spec/modules/consumableBidAdapter_spec.js +++ b/test/spec/modules/consumableBidAdapter_spec.js @@ -1,6 +1,9 @@ import {expect} from 'chai'; import {spec} from 'modules/consumableBidAdapter.js'; import {createBid} from 'src/bidfactory.js'; +import {config} from 'src/config.js'; +import {deepClone} from 'src/utils.js'; +import { createEidsArray } from 'modules/userId/eids.js'; const ENDPOINT = 'https://e.serverbid.com/api/v2'; const SMARTSYNC_CALLBACK = 'serverbidCallBids'; @@ -30,10 +33,30 @@ const BIDDER_REQUEST_1 = { transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' } ], + schain: { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + }, + { + 'asi': 'indirectseller-2.com', + 'sid': '00002', + 'hp': 2 + }, + ] + }, gdprConsent: { consentString: 'consent-test', gdprApplies: false }, + gppConsent: { + applicableSections: [1, 2], + gppString: 'consent-string' + }, refererInfo: { referer: 'http://example.com/page.html', reachedTop: true, @@ -110,6 +133,53 @@ const BIDDER_REQUEST_2 = { } }; +const BIDDER_REQUEST_VIDEO = { + bidderCode: 'consumable', + auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d', + bidderRequestId: '109f2a181342a9', + bidRequest: [ + { + bidder: 'consumable', + params: { + networkId: 9969, + siteId: 730181, + unitId: 123456, + unitName: 'cnsmbl-unit' + }, + placementCode: 'div-gpt-ad-1487778092495-0', + mediaTypes: { + video: { + playerSize: [188, 106], + context: 'instream', + mimes: ['application/javascript', 'application/x-mpegurl', 'video/3gpp', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/webm', 'video/x-m4v', 'video/x-ms-asf', 'video/x-ms-wmv', 'video/x-msvideo'], + minduration: 0, + maxduration: 120, + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + api: [1, 2], + linearity: 1 + } + }, + bidId: '6202d555b2f94537', + bidderRequestId: '109f2a181342a9', + auctionId: 'a4713c32-3762-4798-b342-4ab810ca770d' + } + ], + gdprConsent: { + consentString: 'consent-test', + gdprApplies: true + }, + refererInfo: { + referer: 'http://example.com/page.html', + reachedTop: true, + numIframes: 2, + stack: [ + 'http://example.com/page.html', + 'http://example.com/iframe1.html', + 'http://example.com/iframe2.html' + ] + } +}; + const BIDDER_REQUEST_EMPTY = { bidderCode: 'consumable', auctionId: 'b06458ef-4fe5-4a0b-a61b-bccbcedb7b11', @@ -240,6 +310,58 @@ const AD_SERVER_RESPONSE_2 = { } }; +const AD_SERVER_RESPONSE_VIDEO_1 = { + 'headers': null, + 'body': { + 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, + 'pixels': [{ 'type': 'image', 'url': '//sync.serverbid.com/ss/' }], + 'decisions': { + '6202d555b2f94537': { + 'adId': 3866158402, + 'creativeId': 'C1-somo-test-video', + 'width': 640, + 'height': 480, + 'pricing': { + 'clearPrice': 1.58 + }, + 'vastUrl': 'https://x.serverbid.com/rtb/v?auc=217c051d06b011ed9cbc72b17f01ec03&sc=1.575&s=22&a=9dcab16d340d664310c2135a76989fe946a9d46e5d5f24ff5e2f17bffbb7704a43638bd3f600951e&n=9&r=0&t=1658158906595', + 'uuid': 'f1e7287514ce11ed9c1de2b3ba87449a', + 'bidderName': 'consumable', + 'adomain': ['consumabletv.com'], + 'cats': ['IAB3-1'], + 'mediaType': 'video', + 'networkId': 1 + } + } + } +}; + +const AD_SERVER_RESPONSE_VIDEO_2 = { + 'headers': null, + 'body': { + 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, + 'pixels': [{ 'type': 'image', 'url': '//sync.serverbid.com/ss/' }], + 'decisions': { + '6202d555b2f94537': { + 'adId': 3866158402, + 'creativeId': 'C1-somo-test-video', + 'width': 640, + 'height': 480, + 'pricing': { + 'clearPrice': 1.58 + }, + 'vastXml': '', + 'uuid': 'f1e7287514ce11ed9c1de2b3ba87449a', + 'bidderName': 'consumable', + 'adomain': ['consumabletv.com'], + 'cats': ['IAB3-1'], + 'mediaType': 'video', + 'networkId': 1 + } + } + } +}; + const BUILD_REQUESTS_OUTPUT = { method: 'POST', url: 'https://e.serverbid.com/api/v2', @@ -248,6 +370,14 @@ const BUILD_REQUESTS_OUTPUT = { bidderRequest: BIDDER_REQUEST_2 }; +const BUILD_REQUESTS_VIDEO_OUTPUT = { + method: 'POST', + url: 'https://e.serverbid.com/api/v2', + data: '', + bidRequest: BIDDER_REQUEST_VIDEO.bidRequest, + bidderRequest: BIDDER_REQUEST_VIDEO +}; + describe('Consumable BidAdapter', function () { let adapter = spec; @@ -332,7 +462,63 @@ describe('Consumable BidAdapter', function () { let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); expect(request.bidderRequest).to.equal(BIDDER_REQUEST_1); - }) + }); + + it('should contain schain if it exists in the bidRequest', function () { + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + + expect(data.schain).to.deep.equal(BIDDER_REQUEST_1.schain) + }); + + it('should not contain schain if it does not exist in the bidRequest', function () { + let request = spec.buildRequests(BIDDER_REQUEST_2.bidRequest, BIDDER_REQUEST_2); + let data = JSON.parse(request.data); + + expect(data.schain).to.be.undefined; + }); + + it('should contain coppa if configured', function () { + config.setConfig({ coppa: true }); + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + + expect(data.coppa).to.be.true; + }); + + it('should not contain coppa if not configured', function () { + config.setConfig({ coppa: false }); + let request = spec.buildRequests(BIDDER_REQUEST_1.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + + expect(data.coppa).to.be.undefined; + }); + + it('should contain video object for video requests', function () { + let request = spec.buildRequests(BIDDER_REQUEST_VIDEO.bidRequest, BIDDER_REQUEST_VIDEO); + let data = JSON.parse(request.data); + + expect(data.placements[0].video).to.deep.equal(BIDDER_REQUEST_VIDEO.bidRequest[0].mediaTypes.video); + }); + + it('sets bidfloor param if present', function () { + let bidderRequest1 = deepClone(BIDDER_REQUEST_1); + let bidderRequest2 = deepClone(BIDDER_REQUEST_2); + bidderRequest1.bidRequest[0].params.bidFloor = 0.05; + bidderRequest2.bidRequest[0].getFloor = function() { + return { + currency: 'USD', + floor: 0.15 + } + }; + let request1 = spec.buildRequests(bidderRequest1.bidRequest, BIDDER_REQUEST_1); + let data1 = JSON.parse(request1.data); + let request2 = spec.buildRequests(bidderRequest2.bidRequest, BIDDER_REQUEST_2); + let data2 = JSON.parse(request2.data); + + expect(data1.placements[0].bidfloor).to.equal(0.05); + expect(data2.placements[0].bidfloor).to.equal(0.15); + }); }); describe('interpretResponse validation', function () { it('response should have valid bidderCode', function () { @@ -372,6 +558,31 @@ describe('Consumable BidAdapter', function () { }); }); + it('registers video bids with vastUrl', function () { + let bids = spec.interpretResponse(AD_SERVER_RESPONSE_VIDEO_1, BUILD_REQUESTS_VIDEO_OUTPUT); + + bids.forEach(b => { + expect(b.mediaType).to.equal('video'); + expect(b.meta).to.have.property('mediaType', 'video'); + expect(b.vastUrl).to.equal('https://x.serverbid.com/rtb/v?auc=217c051d06b011ed9cbc72b17f01ec03&sc=1.575&s=22&a=9dcab16d340d664310c2135a76989fe946a9d46e5d5f24ff5e2f17bffbb7704a43638bd3f600951e&n=9&r=0&t=1658158906595'); + expect(b.vastXml).to.be.undefined; + expect(b.videoCacheKey).to.equal('f1e7287514ce11ed9c1de2b3ba87449a'); + }); + }) + + it('registers video bids with vastXml', function () { + let bids = spec.interpretResponse(AD_SERVER_RESPONSE_VIDEO_2, BUILD_REQUESTS_VIDEO_OUTPUT); + + bids.forEach(b => { + expect(b.mediaType).to.equal('video'); + expect(b.meta).to.have.property('mediaType', 'video'); + expect(b.vastXml).to.equal(''); + expect(b.vastUrl).to.be.undefined; + expect(b.ad).to.equal(''); + expect(b.videoCacheKey).to.equal('f1e7287514ce11ed9c1de2b3ba87449a'); + }); + }) + it('handles nobid responses', function () { let EMPTY_RESP = Object.assign({}, AD_SERVER_RESPONSE, {'body': {'decisions': null}}) let bids = spec.interpretResponse(EMPTY_RESP, BUILD_REQUESTS_OUTPUT); @@ -418,6 +629,63 @@ describe('Consumable BidAdapter', function () { expect(opts.length).to.equal(1); }); + it('should return a sync url if iframe syncs are enabled and GDPR applies', function () { + let gdprConsent = { + consentString: 'GDPR_CONSENT_STRING', + gdprApplies: true, + } + let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent); + + expect(opts.length).to.equal(1); + expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=1&gdpr_consent=GDPR_CONSENT_STRING'); + }) + + it('should return a sync url if iframe syncs are enabled and GDPR is undefined', function () { + let gdprConsent = { + consentString: 'GDPR_CONSENT_STRING', + gdprApplies: undefined, + } + let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent); + + expect(opts.length).to.equal(1); + expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=0&gdpr_consent=GDPR_CONSENT_STRING'); + }) + + it('should return a sync url if iframe syncs are enabled and GPP applies', function () { + let gppConsent = { + applicableSections: [1, 2], + gppString: 'GPP_CONSENT_STRING' + } + let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, {}, gppConsent); + + expect(opts.length).to.equal(1); + expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gpp=GPP_CONSENT_STRING&gpp_sid=1,2'); + }) + + it('should return a sync url if iframe syncs are enabled and USP applies', function () { + let uspConsent = { + consentString: 'USP_CONSENT_STRING', + } + let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], {}, uspConsent); + + expect(opts.length).to.equal(1); + expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?us_privacy=USP_CONSENT_STRING'); + }) + + it('should return a sync url if iframe syncs are enabled, GDPR and USP applies', function () { + let gdprConsent = { + consentString: 'GDPR_CONSENT_STRING', + gdprApplies: true, + } + let uspConsent = { + consentString: 'USP_CONSENT_STRING', + } + let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE], gdprConsent, uspConsent); + + expect(opts.length).to.equal(1); + expect(opts[0].url).to.equal('https://sync.serverbid.com/ss/730181.html?gdpr=1&gdpr_consent=GDPR_CONSENT_STRING&us_privacy=USP_CONSENT_STRING'); + }) + it('should return a sync url if pixel syncs are enabled and some are returned from the server', function () { let syncOptions = {'pixelEnabled': true}; let opts = spec.getUserSyncs(syncOptions, [AD_SERVER_RESPONSE]); @@ -425,4 +693,76 @@ describe('Consumable BidAdapter', function () { expect(opts.length).to.equal(1); }); }); + describe('unifiedId from userId module', function() { + let sandbox, bidderRequest; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + bidderRequest = deepClone(BIDDER_REQUEST_1); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('Request should have unifiedId config params', function() { + bidderRequest.bidRequest[0].userId = {}; + bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID'; + bidderRequest.bidRequest[0].userIdAsEids = createEidsArray(bidderRequest.bidRequest[0].userId); + let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'adserver.org', + 'uids': [{ + 'id': 'TTD_ID', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }]); + }); + + it('Request should have adsrvrOrgId from UserId Module if config and userId module both have TTD ID', function() { + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + adsrvrOrgId: { + 'TDID': 'TTD_ID_FROM_CONFIG', + 'TDID_LOOKUP': 'TRUE', + 'TDID_CREATED_AT': '2022-06-21T09:47:00' + } + }; + return config[key]; + }); + bidderRequest.bidRequest[0].userId = {}; + bidderRequest.bidRequest[0].userId.tdid = 'TTD_ID'; + bidderRequest.bidRequest[0].userIdAsEids = createEidsArray(bidderRequest.bidRequest[0].userId); + let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal([{ + 'source': 'adserver.org', + 'uids': [{ + 'id': 'TTD_ID', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }]); + }); + + it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() { + let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal(undefined); + }); + + it('Request should NOT have adsrvrOrgId params if userId.tdid is NOT string', function() { + bidderRequest.bidRequest[0].userId = { + tdid: 1234 + }; + let request = spec.buildRequests(bidderRequest.bidRequest, BIDDER_REQUEST_1); + let data = JSON.parse(request.data); + expect(data.user.eids).to.deep.equal(undefined); + }); + }); }); diff --git a/test/spec/modules/contentexchangeBidAdapter_spec.js b/test/spec/modules/contentexchangeBidAdapter_spec.js index 368ca8d9e3f..1b3dc4f19c9 100644 --- a/test/spec/modules/contentexchangeBidAdapter_spec.js +++ b/test/spec/modules/contentexchangeBidAdapter_spec.js @@ -79,7 +79,8 @@ describe('ContentexchangeBidAdapter', function () { gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', refererInfo: { referer: 'https://test.com' - } + }, + timeout: 500 }; describe('isBidRequestValid', function () { diff --git a/test/spec/modules/conversantAnalyticsAdapter_spec.js b/test/spec/modules/conversantAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..f425535ce73 --- /dev/null +++ b/test/spec/modules/conversantAnalyticsAdapter_spec.js @@ -0,0 +1,1113 @@ +import sinon from 'sinon'; +import {expect} from 'chai'; +import {default as conversantAnalytics, CNVR_CONSTANTS, cnvrHelper} from 'modules/conversantAnalyticsAdapter'; +import * as utils from 'src/utils.js'; +import * as prebidGlobal from 'src/prebidGlobal'; +import {server} from '../../mocks/xhr.js'; + +import constants from 'src/constants.json' + +let events = require('src/events'); + +describe('Conversant analytics adapter tests', function() { + let sandbox; // sinon sandbox to make restoring all stubbed objects easier + let clock; // clock stub from sinon to mock our cache cleanup interval + let logInfoStub; + + const PREBID_VERSION = '1.2'; + const SITE_ID = 108060; + + let requests; + const DATESTAMP = Date.now(); + + const VALID_CONFIGURATION = { + options: { + site_id: SITE_ID, + send_error_data: true + } + }; + + const VALID_ALWAYS_SAMPLE_CONFIG = { + options: { + site_id: SITE_ID, + cnvr_sampling: 1, + send_error_data: true + } + }; + + beforeEach(function () { + requests = server.requests; + sandbox = sinon.sandbox.create(); + sandbox.stub(events, 'getEvents').returns([]); // need to stub this otherwise unwanted events seem to get fired during testing + let getGlobalStub = { + version: PREBID_VERSION, + getUserIds: function() { // userIdTargeting.js init() gets called on AUCTION_END so we need to mock this function. + return {}; + } + }; + sandbox.stub(prebidGlobal, 'getGlobal').returns(getGlobalStub); // getGlobal does not seem to be available in testing so need to mock it + clock = sandbox.useFakeTimers(DATESTAMP); // to use sinon fake timers they MUST be created before the interval/timeout is created in the code you are testing. + + logInfoStub = sandbox.stub(utils, 'logInfo');/* .callsFake((arg, arg1, arg2) => { //debugging stuff + console.log(arg); + if (arg1) console.log(arg1); + if (arg2) console.log(arg2); + }); */ + + conversantAnalytics.enableAnalytics(VALID_ALWAYS_SAMPLE_CONFIG); + }); + + afterEach(function () { + sandbox.restore(); + conversantAnalytics.disableAnalytics(); + }); + + describe('Initialization Tests', function() { + it('should log error if site id is not passed', function() { + sandbox.stub(utils, 'logError'); + conversantAnalytics.disableAnalytics(); + conversantAnalytics.enableAnalytics(); + expect(utils.logError.calledWith(CNVR_CONSTANTS.LOG_PREFIX + 'siteId is required.')).to.be.true; + }); + + it('should not log error if valid config is passed', function() { + sandbox.stub(utils, 'logError'); + + conversantAnalytics.enableAnalytics(VALID_CONFIGURATION); + expect(utils.logError.called).to.equal(false); + expect(utils.logInfo.called).to.equal(true); + expect( + utils.logInfo.calledWith( + CNVR_CONSTANTS.LOG_PREFIX + 'Conversant sample rate set to ' + CNVR_CONSTANTS.DEFAULT_SAMPLE_RATE + ) + ).to.be.true; + expect( + utils.logInfo.calledWith( + CNVR_CONSTANTS.LOG_PREFIX + 'Global sample rate set to 1' + ) + ).to.be.true; + }); + + it('should sample when sampling set to 1', function() { + sandbox.stub(utils, 'logError'); + conversantAnalytics.enableAnalytics(VALID_ALWAYS_SAMPLE_CONFIG); + expect(utils.logError.called).to.equal(false); + expect(cnvrHelper.doSample).to.equal(true); + }); + + it('should NOT sample when sampling set to 0', function() { + sandbox.stub(utils, 'logError'); + const NEVER_SAMPLE_CONFIG = utils.deepClone(VALID_ALWAYS_SAMPLE_CONFIG); + NEVER_SAMPLE_CONFIG['options'].cnvr_sampling = 0; + conversantAnalytics.disableAnalytics(); + conversantAnalytics.enableAnalytics(NEVER_SAMPLE_CONFIG); + expect(utils.logError.called).to.equal(false); + expect(cnvrHelper.doSample).to.equal(false); + }); + }); + + describe('Helper Function Tests', function() { + it('should cleanup up cache objects', function() { + conversantAnalytics.enableAnalytics(VALID_CONFIGURATION); + + cnvrHelper.adIdLookup['keep'] = {timeReceived: DATESTAMP + 1}; + cnvrHelper.adIdLookup['delete'] = {timeReceived: DATESTAMP - CNVR_CONSTANTS.MAX_MILLISECONDS_IN_CACHE}; + + cnvrHelper.timeoutCache['keep'] = {timeReceived: DATESTAMP + 1}; + cnvrHelper.timeoutCache['delete'] = {timeReceived: DATESTAMP - CNVR_CONSTANTS.MAX_MILLISECONDS_IN_CACHE}; + + cnvrHelper.auctionIdTimestampCache['keep'] = {timeReceived: DATESTAMP + 1}; + cnvrHelper.auctionIdTimestampCache['delete'] = {timeReceived: DATESTAMP - CNVR_CONSTANTS.MAX_MILLISECONDS_IN_CACHE}; + + cnvrHelper.bidderErrorCache['keep'] = {timeReceived: DATESTAMP + 1, errors: []}; + cnvrHelper.bidderErrorCache['delete'] = {timeReceived: DATESTAMP - CNVR_CONSTANTS.MAX_MILLISECONDS_IN_CACHE, errors: []}; + + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(2); + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(2); + expect(Object.keys(cnvrHelper.auctionIdTimestampCache)).to.have.lengthOf(2); + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(2); + + clock.tick(CNVR_CONSTANTS.CACHE_CLEANUP_TIME_IN_MILLIS); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(1); + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(1); + expect(Object.keys(cnvrHelper.auctionIdTimestampCache)).to.have.lengthOf(1); + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(1); + + conversantAnalytics.disableAnalytics(); + + // After disable we should cleanup the cache + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.auctionIdTimestampCache)).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(0); + }); + + it('createBid() should return correct object', function() { + const EVENT_CODE = 1; + const TIME = 2; + let bid = cnvrHelper.createBid(EVENT_CODE, 2); + expect(bid).to.deep.equal({'eventCodes': [EVENT_CODE], 'timeToRespond': TIME}); + }); + + it('createAdUnit() should return correct object', function() { + let adUnit = cnvrHelper.createAdUnit(); + expect(adUnit).to.deep.equal({ + sizes: [], + mediaTypes: [], + bids: {} + }); + }); + + it('createAdSize() should return correct object', function() { + let adSize = cnvrHelper.createAdSize(1, 2); + expect(adSize).to.deep.equal({w: 1, h: 2}); + + adSize = cnvrHelper.createAdSize(); + expect(adSize).to.deep.equal({w: -1, h: -1}); + + adSize = cnvrHelper.createAdSize('foo', 'bar'); + expect(adSize).to.deep.equal({w: -1, h: -1}); + }); + + it('getLookupKey() should return correct object', function() { + let key = cnvrHelper.getLookupKey(undefined, undefined, undefined); + expect(key).to.equal('undefined-undefined-undefined'); + + key = cnvrHelper.getLookupKey('foo', 'bar', 'baz'); + expect(key).to.equal('foo-bar-baz'); + }); + + it('createPayload() should return correct object', function() { + const REQUEST_TYPE = 'foo'; + const AUCTION_ID = '124 abc'; + const myDate = Date.now(); + conversantAnalytics.enableAnalytics(VALID_ALWAYS_SAMPLE_CONFIG); + + let payload = cnvrHelper.createPayload(REQUEST_TYPE, AUCTION_ID, myDate); + expect(payload).to.deep.equal({ + bidderErrors: [], + cnvrSampleRate: 1, + globalSampleRate: 1, + requestType: REQUEST_TYPE, + auction: { + auctionId: AUCTION_ID, + auctionTimestamp: myDate, + sid: VALID_ALWAYS_SAMPLE_CONFIG.options.site_id, + preBidVersion: PREBID_VERSION + }, + adUnits: {} + }); + }); + + it('keyExistsAndIsObject() should return correct data', function() { + let data = { + a: [], + b: 1, + c: 'foo', + d: function () { return true; }, + e: {} + }; + expect(cnvrHelper.keyExistsAndIsObject(data, 'foobar')).to.be.false; + expect(cnvrHelper.keyExistsAndIsObject(data, 'a')).to.be.false; + expect(cnvrHelper.keyExistsAndIsObject(data, 'b')).to.be.false; + expect(cnvrHelper.keyExistsAndIsObject(data, 'c')).to.be.false; + expect(cnvrHelper.keyExistsAndIsObject(data, 'd')).to.be.false; + expect(cnvrHelper.keyExistsAndIsObject(data, 'e')).to.be.true; + }); + + it('deduplicateArray() should return correct data', function () { + let arrayOfObjects = [{w: 1, h: 2}, {w: 2, h: 3}, {w: 1, h: 2}]; + let array = [3, 2, 1, 1, 2, 3]; + let empty; + let notArray = 3; + let emptyArray = []; + + expect(JSON.stringify(cnvrHelper.deduplicateArray(array))).to.equal(JSON.stringify([3, 2, 1])); + expect(JSON.stringify(cnvrHelper.deduplicateArray(arrayOfObjects))).to.equal(JSON.stringify([{w: 1, h: 2}, {w: 2, h: 3}])); + expect(JSON.stringify(cnvrHelper.deduplicateArray(emptyArray))).to.equal(JSON.stringify([])); + expect(cnvrHelper.deduplicateArray(empty)).to.be.undefined; + expect(cnvrHelper.deduplicateArray(notArray)).to.equal(notArray); + }); + + it('getSampleRate() should return correct data', function () { + let obj = { + sampling: 1, + cnvr_sampling: 0.5, + too_big: 1.2, + too_small: -1, + string: 'foo', + object: {}, + } + const DEFAULT_VAL = 0.11; + expect(cnvrHelper.getSampleRate(obj, 'sampling', DEFAULT_VAL)).to.equal(1); + expect(cnvrHelper.getSampleRate(obj, 'cnvr_sampling', DEFAULT_VAL)).to.equal(0.5); + expect(cnvrHelper.getSampleRate(obj, 'too_big', DEFAULT_VAL)).to.equal(DEFAULT_VAL); + expect(cnvrHelper.getSampleRate(obj, 'string', DEFAULT_VAL)).to.equal(DEFAULT_VAL); + expect(cnvrHelper.getSampleRate(obj, 'object', DEFAULT_VAL)).to.equal(DEFAULT_VAL); + expect(cnvrHelper.getSampleRate(obj, 'not_a_key', DEFAULT_VAL)).to.equal(DEFAULT_VAL); + expect(cnvrHelper.getSampleRate(obj, 'too_small', DEFAULT_VAL)).to.equal(0); + }); + + it('getPageUrl() should return correct data', function() { + let url = cnvrHelper.getPageUrl(); + expect(url.length).to.be.above(1); + }); + + it('sendErrorData() should send data via ajax', function() { + const error = { + stack: 'foobar', + message: 'foobar message' + }; + const eventType = 'fooType'; + + expect(requests).to.have.lengthOf(0); + cnvrHelper.sendErrorData(eventType, error); + expect(requests).to.have.lengthOf(1); + + expect(requests[0].url).to.contain('cvx/event/prebidanalyticerrors'); + const data = JSON.parse(requests[0].requestBody); + expect(data.event).to.be.equal(eventType); + expect(data.siteId).to.be.equal(SITE_ID); + expect(data.message).to.not.be.undefined; + expect(data.prebidVersion).to.not.be.undefined; + expect(data.userAgent).to.not.be.undefined; + expect(data.url).to.not.be.undefined; + }); + + it('Should not send data when error logging disabled', function() { + const error = { + stack: 'foobar', + message: 'foobar message' + }; + const eventType = 'fooType'; + + conversantAnalytics.disableAnalytics(); + conversantAnalytics.enableAnalytics({ + options: { + site_id: SITE_ID, + cnvr_sampling: 1, + send_error_data: false + } + }); + expect(cnvrHelper.doSendErrorData).to.be.false; + + expect(requests).to.have.lengthOf(0); + cnvrHelper.sendErrorData(eventType, error); + expect(requests).to.have.lengthOf(0); + + conversantAnalytics.disableAnalytics(); + conversantAnalytics.enableAnalytics({ + options: { + site_id: SITE_ID, + cnvr_sampling: 1, + send_error_data: 0 + } + }); + expect(cnvrHelper.doSendErrorData).to.be.false; + + expect(requests).to.have.lengthOf(0); + cnvrHelper.sendErrorData(eventType, error); + expect(requests).to.have.lengthOf(0); + }); + }); + + describe('Bid Timeout Event Tests', function() { + const BID_TIMEOUT_PAYLOAD = [{ + 'bidId': '80882409358b8a8', + 'bidder': 'conversant', + 'adUnitCode': 'MedRect', + 'auctionId': 'afbd6e0b-e45b-46ab-87bf-c0bac0cb8881' + }, { + 'bidId': '9da4c107a6f24c8', + 'bidder': 'conversant', + 'adUnitCode': 'Leaderboard', + 'auctionId': 'afbd6e0b-e45b-46ab-87bf-c0bac0cb8881' + }]; + + it('should put both items in timeout cache', function() { + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(0); + events.emit(constants.EVENTS.BID_TIMEOUT, BID_TIMEOUT_PAYLOAD); + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(2); + + BID_TIMEOUT_PAYLOAD.forEach(timeoutBid => { + const key = cnvrHelper.getLookupKey(timeoutBid.auctionId, timeoutBid.adUnitCode, timeoutBid.bidder); + expect(cnvrHelper.timeoutCache[key].timeReceived).to.not.be.undefined; + }); + expect(requests).to.have.lengthOf(0); + }); + }); + + describe('Render Failed Tests', function() { + const RENDER_FAILED_PAYLOAD = { + reason: 'reason', + message: 'value', + adId: '57e03aeafd83a68' + }; + + const RENDER_FAILED_PAYLOAD_NO_ADID = { + reason: 'reason', + message: 'value' + }; + + it('should empty adIdLookup and send data', function() { + cnvrHelper.adIdLookup[RENDER_FAILED_PAYLOAD.adId] = { + bidderCode: 'bidderCode', + adUnitCode: 'adUnitCode', + auctionId: 'auctionId', + timeReceived: Date.now() + }; + + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(1); + events.emit(constants.EVENTS.AD_RENDER_FAILED, RENDER_FAILED_PAYLOAD); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(0); // object should be removed + expect(requests).to.have.lengthOf(1); + const data = JSON.parse(requests[0].requestBody); + + expect(data.auction.auctionId).to.equal('auctionId'); + expect(data.auction.preBidVersion).to.equal(PREBID_VERSION); + expect(data.auction.sid).to.equal(SITE_ID); + expect(data.adUnits['adUnitCode'].bids['bidderCode'][0].eventCodes.includes(CNVR_CONSTANTS.RENDER_FAILED)).to.be.true; + expect(data.adUnits['adUnitCode'].bids['bidderCode'][0].message).to.have.lengthOf.above(0); + }); + + it('should not send data if no adId', function() { + cnvrHelper.adIdLookup[RENDER_FAILED_PAYLOAD.adId] = { + bidderCode: 'bidderCode', + adUnitCode: 'adUnitCode', + auctionId: 'auctionId', + timeReceived: Date.now() + }; + + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(1); + events.emit(constants.EVENTS.AD_RENDER_FAILED, RENDER_FAILED_PAYLOAD_NO_ADID); + expect(requests).to.have.lengthOf(1); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(1); // same object in cache as before... no change + expect(cnvrHelper.adIdLookup[RENDER_FAILED_PAYLOAD.adId]).to.not.be.undefined; + + expect(requests[0].url).to.contain('cvx/event/prebidanalyticerrors'); + const data = JSON.parse(requests[0].requestBody); + expect(data.event).to.be.equal(constants.EVENTS.AD_RENDER_FAILED); + expect(data.siteId).to.be.equal(SITE_ID); + expect(data.message).to.not.be.undefined; + expect(data.prebidVersion).to.not.be.undefined; + expect(data.userAgent).to.not.be.undefined; + expect(data.url).to.not.be.undefined; + }); + + it('should not send data if bad data in lookup', function() { + cnvrHelper.adIdLookup[RENDER_FAILED_PAYLOAD.adId] = { + bidderCode: 'bidderCode', + auctionId: 'auctionId', + timeReceived: Date.now() + }; + expect(requests).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(1); + events.emit(constants.EVENTS.AD_RENDER_FAILED, RENDER_FAILED_PAYLOAD); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(0); // object should be removed but no call made to send data + expect(requests).to.have.lengthOf(1); + + expect(requests[0].url).to.contain('cvx/event/prebidanalyticerrors'); + const data = JSON.parse(requests[0].requestBody); + expect(data.event).to.be.equal(constants.EVENTS.AD_RENDER_FAILED); + expect(data.siteId).to.be.equal(SITE_ID); + expect(data.message).to.not.be.undefined; + expect(data.prebidVersion).to.not.be.undefined; + expect(data.userAgent).to.not.be.undefined; + expect(data.url).to.not.be.undefined; + }); + }); + + describe('Bid Won Tests', function() { + const GOOD_BID_WON_ARGS = { + bidderCode: 'conversant', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '57e03aeafd83a68', + requestId: '2c2a5485a076898', + mediaType: 'banner', + source: 'client', + currency: 'USD', + cpm: 4, + creativeId: '29123_55016759', + ttl: 300, + netRevenue: true, + ad: '', + originalCpm: 0.04, + originalCurrency: 'USD', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + responseTimestamp: 1583851418626, + requestTimestamp: 1583851418292, + bidder: 'conversant', + adUnitCode: 'div-gpt-ad-1460505748561-0', + timeToRespond: 334, + pbLg: '4.00', + pbMg: '4.00', + pbHg: '4.00', + pbAg: '4.00', + pbDg: '4.00', + pbCg: '', + size: '300x250', + adserverTargeting: { + hb_bidder: 'conversant', + hb_adid: '57e03aeafd83a68', + hb_pb: '4.00', + hb_size: '300x250', + hb_source: 'client', + hb_format: 'banner' + }, + status: 'rendered', + params: [ + { + site_id: '108060' + } + ] + }; + + // no adUnitCode, auctionId or bidderCode will cause a failure + const BAD_BID_WON_ARGS = { + bidderCode: 'conversant', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '57e03aeafd83a68', + requestId: '2c2a5485a076898', + mediaType: 'banner', + source: 'client', + currency: 'USD', + cpm: 4, + originalCpm: 0.04, + originalCurrency: 'USD', + bidder: 'conversant', + adUnitCode: 'div-gpt-ad-1460505748561-0', + size: '300x250', + status: 'rendered', + params: [ + { + site_id: '108060' + } + ] + }; + + it('should not send data or put a record in adIdLookup when bad data provided', function() { + expect(requests).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(0); + events.emit(constants.EVENTS.BID_WON, BAD_BID_WON_ARGS); + expect(requests).to.have.lengthOf(1); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(0); + + // check for error event + expect(requests[0].url).to.contain('cvx/event/prebidanalyticerrors'); + const data = JSON.parse(requests[0].requestBody); + expect(data.event).to.be.equal(constants.EVENTS.BID_WON); + expect(data.siteId).to.be.equal(SITE_ID); + expect(data.message).to.not.be.undefined; + expect(data.prebidVersion).to.not.be.undefined; + expect(data.userAgent).to.not.be.undefined; + expect(data.url).to.not.be.undefined; + }); + + it('should send data and put a record in adIdLookup', function() { + const myAuctionStart = Date.now(); + cnvrHelper.auctionIdTimestampCache[GOOD_BID_WON_ARGS.auctionId] = {timeReceived: myAuctionStart}; + + expect(requests).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(0); + events.emit(constants.EVENTS.BID_WON, GOOD_BID_WON_ARGS); + + // Check that adIdLookup was set correctly + expect(Object.keys(cnvrHelper.adIdLookup)).to.have.lengthOf(1); + expect(cnvrHelper.adIdLookup[GOOD_BID_WON_ARGS.adId].auctionId).to.equal(GOOD_BID_WON_ARGS.auctionId); + expect(cnvrHelper.adIdLookup[GOOD_BID_WON_ARGS.adId].adUnitCode).to.equal(GOOD_BID_WON_ARGS.adUnitCode); + expect(cnvrHelper.adIdLookup[GOOD_BID_WON_ARGS.adId].bidderCode).to.equal(GOOD_BID_WON_ARGS.bidderCode); + expect(cnvrHelper.adIdLookup[GOOD_BID_WON_ARGS.adId].timeReceived).to.not.be.undefined; + + expect(requests).to.have.lengthOf(1); + const data = JSON.parse(requests[0].requestBody); + expect(data.requestType).to.equal('bid_won'); + expect(data.auction.auctionId).to.equal(GOOD_BID_WON_ARGS.auctionId); + expect(data.auction.preBidVersion).to.equal(PREBID_VERSION); + expect(data.auction.sid).to.equal(VALID_ALWAYS_SAMPLE_CONFIG.options.site_id); + expect(data.auction.auctionTimestamp).to.equal(myAuctionStart); + + expect(typeof data.adUnits).to.equal('object'); + expect(Object.keys(data.adUnits)).to.have.lengthOf(1); + + expect(Object.keys(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids)).to.have.lengthOf(1); + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].eventCodes.includes(CNVR_CONSTANTS.WIN)).to.be.true; + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].cpm).to.equal(GOOD_BID_WON_ARGS.cpm); + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].originalCpm).to.equal(GOOD_BID_WON_ARGS.originalCpm); + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].currency).to.equal(GOOD_BID_WON_ARGS.currency); + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].timeToRespond).to.equal(GOOD_BID_WON_ARGS.timeToRespond); + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].adSize.w).to.equal(GOOD_BID_WON_ARGS.width); + expect(data.adUnits[GOOD_BID_WON_ARGS.adUnitCode].bids[GOOD_BID_WON_ARGS.bidderCode][0].adSize.h).to.equal(GOOD_BID_WON_ARGS.height); + }); + }); + + describe('Auction End Tests', function() { + const AUCTION_END_PAYLOAD = { + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + timestamp: 1583851418288, + auctionEnd: 1583851418628, + auctionStatus: 'completed', + adUnits: [ + { + code: 'div-gpt-ad-1460505748561-0', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [100, 200] + ] + } + }, + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }, + { + bidder: 'conversant', + params: { + site_id: '108060' + } + } + ], + sizes: [ + [300, 250], + [100, 200] + ], + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba17' + }, + { + code: 'div-gpt-ad-1460505748561-0', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [100, 200] + ] + }, + video: { + playerSize: [ + [300, 250], + [600, 400] + ] + } + }, + sizes: [ + [300, 250], + [100, 200], + [600, 400] + ], + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }, + { + bidder: 'conversant', + params: { + site_id: '108060' + } + } + ], + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba18' + }, + { + code: 'div-gpt-ad-1460505748561-1', + mediaTypes: { + native: { + type: 'image' + } + }, + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 13144371 + } + } + ], + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba10' + } + ], + adUnitCodes: [ + 'div-gpt-ad-1460505748561-0' + ], + bidderRequests: [ + { + bidderCode: 'conversant', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + bidderRequestId: '13f16db358d4c58', + bids: [ + { + bidder: 'conversant', + params: { + site_id: '108060' + }, + mediaTypes: { + banner: { + sizes: [ + [ + 300, + 250 + ] + ] + } + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba17', + sizes: [ + [ + 300, + 250 + ] + ], + bidId: '2c2a5485a076898', + bidderRequestId: '13f16db358d4c58', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + } + ], + auctionStart: 1583851418288, + timeout: 3000, + refererInfo: { + referer: 'http://localhost:9999/integrationExamples/gpt/hello_analytics1.html', + reachedTop: true, + numIframes: 0, + stack: [ + 'http://localhost:9999/integrationExamples/gpt/hello_analytics1.html' + ] + }, + start: 1583851418292 + }, + { + bidderCode: 'appnexus', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + bidderRequestId: '3e8179f67f31b98', + bids: [ + { + bidder: 'appnexus', + params: { + placementId: 13144370 + }, + mediaTypes: { + banner: { + sizes: [ + [ + 300, + 250 + ] + ] + } + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba17', + sizes: [ + [ + 300, + 250 + ] + ], + bidId: '40a1d3ac6b79668', + bidderRequestId: '3e8179f67f31b98', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }, + { + bidder: 'appnexus', + params: { + placementId: 13144370 + }, + mediaTypes: { + native: { + type: 'image' + } + }, + adUnitCode: 'div-gpt-ad-1460505748561-1', + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba17', + sizes: [], + bidId: '40a1d3ac6b79668', + bidderRequestId: '3e8179f67f31b98', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + } + ], + auctionStart: 1583851418288, + timeout: 3000, + refererInfo: { + referer: 'http://localhost:9999/integrationExamples/gpt/hello_analytics1.html', + reachedTop: true, + numIframes: 0, + stack: [ + 'http://localhost:9999/integrationExamples/gpt/hello_analytics1.html' + ] + }, + start: 1583851418295 + } + ], + noBids: [ + { + bidder: 'appnexus', + params: { + placementId: 13144370 + }, + mediaTypes: { + banner: { + sizes: [ + [ + 300, + 250 + ] + ] + } + }, + adUnitCode: 'div-gpt-ad-1460505748561-0', + transactionId: '5fa8a7d7-2a73-4d1c-b73a-ff9f5b53ba17', + sizes: [ + [ + 300, + 250 + ] + ], + bidId: '40a1d3ac6b79668', + bidderRequestId: '3e8179f67f31b98', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + } + ], + bidsReceived: [ + { + bidderCode: 'conversant', + width: 300, + height: 250, + statusMessage: 'Bid available', + adId: '57e03aeafd83a68', + requestId: '2c2a5485a076898', + mediaType: 'banner', + source: 'client', + currency: 'USD', + cpm: 4, + creativeId: '29123_55016759', + ttl: 300, + netRevenue: true, + ad: '', + originalCpm: 0.04, + originalCurrency: 'USD', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + responseTimestamp: 1583851418626, + requestTimestamp: 1583851418292, + bidder: 'conversant', + adUnitCode: 'div-gpt-ad-1460505748561-0', + timeToRespond: 334, + pbLg: '4.00', + pbMg: '4.00', + pbHg: '4.00', + pbAg: '4.00', + pbDg: '4.00', + pbCg: '', + size: '300x250', + adserverTargeting: { + hb_bidder: 'conversant', + hb_adid: '57e03aeafd83a68', + hb_pb: '4.00', + hb_size: '300x250', + hb_source: 'client', + hb_format: 'banner' + } + }, { + bidderCode: 'conversant', + height: 100, + statusMessage: 'Bid available', + width: 200, + adId: '57e03aeafd83a68', + requestId: '2c2a5485a076898', + mediaType: 'banner', + source: 'client', + currency: 'USD', + cpm: 4, + creativeId: '29123_55016759', + ttl: 300, + netRevenue: true, + ad: '', + originalCpm: 0.04, + originalCurrency: 'USD', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + responseTimestamp: 1583851418626, + requestTimestamp: 1583851418292, + bidder: 'conversant', + adUnitCode: 'div-gpt-ad-1460505748561-0', + timeToRespond: 334, + pbLg: '4.00', + pbMg: '4.00', + pbHg: '4.00', + pbAg: '4.00', + pbDg: '4.00', + pbCg: '', + size: '100x200', + adserverTargeting: { + hb_bidder: 'conversant', + hb_adid: '57e03aeafd83a68', + hb_pb: '4.00', + hb_size: '300x250', + hb_source: 'client', + hb_format: 'banner' + } + }, { + bidderCode: 'appnexus', + statusMessage: 'Bid available', + adId: '57e03aeafd83a68', + requestId: '2c2a5485a076898', + mediaType: 'native', + source: 'client', + currency: 'USD', + cpm: 4, + creativeId: '29123_55016759', + ttl: 300, + netRevenue: true, + ad: '', + originalCpm: 0.04, + originalCurrency: 'USD', + auctionId: '85e1bf44-4035-4e24-bd3c-b1ba367fe294', + responseTimestamp: 1583851418626, + requestTimestamp: 1583851418292, + bidder: 'appnexus', + adUnitCode: 'div-gpt-ad-1460505748561-1', + timeToRespond: 334, + pbLg: '4.00', + pbMg: '4.00', + pbHg: '4.00', + pbAg: '4.00', + pbDg: '4.00', + pbCg: '', + adserverTargeting: { + hb_bidder: 'appnexus', + hb_adid: '57e03aeafd83a68', + hb_pb: '4.00', + hb_size: '300x250', + hb_source: 'client', + hb_format: 'banner' + } + } + ], + winningBids: [], + timeout: 3000 + }; + + it('should not do anything when auction id doesnt exist', function() { + sandbox.stub(utils, 'logError'); + + let BAD_ARGS = JSON.parse(JSON.stringify(AUCTION_END_PAYLOAD)); + delete BAD_ARGS.auctionId; + expect(requests).to.have.lengthOf(0); + events.emit(constants.EVENTS.AUCTION_END, BAD_ARGS); + expect(requests).to.have.lengthOf(1); + + // check for error event + expect(requests[0].url).to.contain('cvx/event/prebidanalyticerrors'); + const data = JSON.parse(requests[0].requestBody); + expect(data.event).to.be.equal(constants.EVENTS.AUCTION_END); + expect(data.siteId).to.be.equal(SITE_ID); + expect(data.message).to.not.be.undefined; + expect(data.prebidVersion).to.not.be.undefined; + expect(data.userAgent).to.not.be.undefined; + expect(data.url).to.not.be.undefined; + }); + + it('should send the expected data', function() { + sandbox.stub(utils, 'logError'); + sandbox.stub(utils, 'logWarn'); + + expect(requests).to.have.lengthOf(0); + const AUCTION_ID = AUCTION_END_PAYLOAD.auctionId; + const AD_UNIT_CODE = AUCTION_END_PAYLOAD.adUnits[0].code; + const AD_UNIT_CODE_NATIVE = AUCTION_END_PAYLOAD.adUnits[2].code; + const timeoutKey = cnvrHelper.getLookupKey(AUCTION_ID, AD_UNIT_CODE, 'appnexus'); + const URL = 'some url'; + cnvrHelper.bidderErrorCache[AUCTION_ID] = { + errors: [{ + status: 500, + message: 'error msg', + bidderCode: 'bidderCode', + url: URL, + }, { + status: 501, + message: 'error msg1', + bidderCode: 'bidderCode1', + url: URL, + }], + timeReceived: Date.now() + }; + cnvrHelper.timeoutCache[timeoutKey] = { timeReceived: Date.now() }; + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(1); + expect(utils.logError.called).to.equal(false); + expect(Object.keys(cnvrHelper.auctionIdTimestampCache)).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(1); + + events.emit(constants.EVENTS.AUCTION_END, AUCTION_END_PAYLOAD); + expect(utils.logError.called).to.equal(false); + expect(requests).to.have.lengthOf(1); + expect(Object.keys(cnvrHelper.timeoutCache)).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.auctionIdTimestampCache)).to.have.lengthOf(1); + expect(cnvrHelper.auctionIdTimestampCache[AUCTION_END_PAYLOAD.auctionId].timeReceived).to.equal(AUCTION_END_PAYLOAD.timestamp); + + const data = JSON.parse(requests[0].requestBody); + expect(data.requestType).to.equal('auction_end'); + expect(data.auction.auctionId).to.equal(AUCTION_ID); + expect(data.auction.preBidVersion).to.equal(PREBID_VERSION); + expect(data.auction.sid).to.equal(VALID_ALWAYS_SAMPLE_CONFIG.options.site_id); + + expect(Object.keys(data.adUnits)).to.have.lengthOf(2); + + expect(data.adUnits[AD_UNIT_CODE].sizes).to.have.lengthOf(3); + expect(data.adUnits[AD_UNIT_CODE].sizes[0].w).to.equal(300); + expect(data.adUnits[AD_UNIT_CODE].sizes[0].h).to.equal(250); + expect(data.adUnits[AD_UNIT_CODE].sizes[1].w).to.equal(100); + expect(data.adUnits[AD_UNIT_CODE].sizes[1].h).to.equal(200); + expect(data.adUnits[AD_UNIT_CODE].sizes[2].w).to.equal(600); + expect(data.adUnits[AD_UNIT_CODE].sizes[2].h).to.equal(400); + + expect(data.adUnits[AD_UNIT_CODE].mediaTypes).to.have.lengthOf(2); + expect(data.adUnits[AD_UNIT_CODE].mediaTypes[0]).to.equal('banner'); + expect(data.adUnits[AD_UNIT_CODE].mediaTypes[1]).to.equal('video'); + + expect(data.adUnits[AD_UNIT_CODE_NATIVE].mediaTypes).to.have.lengthOf(1); + expect(data.adUnits[AD_UNIT_CODE_NATIVE].mediaTypes[0]).to.equal('native'); + expect(data.adUnits[AD_UNIT_CODE_NATIVE].sizes).to.have.lengthOf(0); + + expect(Object.keys(data.adUnits[AD_UNIT_CODE].bids)).to.have.lengthOf(2); + const cnvrBidsArray = data.adUnits[AD_UNIT_CODE].bids['conversant']; + // testing multiple bids from same bidder + expect(cnvrBidsArray).to.have.lengthOf(2); + expect(cnvrBidsArray[0].eventCodes.includes(CNVR_CONSTANTS.BID)).to.be.true; + expect(cnvrBidsArray[0].cpm).to.equal(4); + expect(cnvrBidsArray[0].originalCpm).to.equal(0.04); + expect(cnvrBidsArray[0].currency).to.equal('USD'); + expect(cnvrBidsArray[0].timeToRespond).to.equal(334); + expect(cnvrBidsArray[0].adSize.w).to.equal(300); + expect(cnvrBidsArray[0].adSize.h).to.equal(250); + expect(cnvrBidsArray[0].mediaType).to.equal('banner'); + // 2nd bid different size + expect(cnvrBidsArray[1].eventCodes.includes(CNVR_CONSTANTS.BID)).to.be.true; + expect(cnvrBidsArray[1].cpm).to.equal(4); + expect(cnvrBidsArray[1].originalCpm).to.equal(0.04); + expect(cnvrBidsArray[1].currency).to.equal('USD'); + expect(cnvrBidsArray[1].timeToRespond).to.equal(334); + expect(cnvrBidsArray[1].adSize.w).to.equal(200); + expect(cnvrBidsArray[1].adSize.h).to.equal(100); + expect(cnvrBidsArray[1].mediaType).to.equal('banner'); + + const apnBidsArray = data.adUnits[AD_UNIT_CODE].bids['appnexus']; + expect(apnBidsArray).to.have.lengthOf(2); + let apnBid = apnBidsArray[0]; + expect(apnBid.originalCpm).to.be.undefined; + expect(apnBid.eventCodes.includes(CNVR_CONSTANTS.TIMEOUT)).to.be.true; + expect(apnBid.cpm).to.be.undefined; + expect(apnBid.currency).to.be.undefined; + expect(apnBid.timeToRespond).to.equal(3000); + expect(apnBid.adSize).to.be.undefined; + expect(apnBid.mediaType).to.be.undefined; + apnBid = apnBidsArray[1]; + expect(apnBid.originalCpm).to.be.undefined; + expect(apnBid.eventCodes.includes(CNVR_CONSTANTS.NO_BID)).to.be.true; + expect(apnBid.cpm).to.be.undefined; + expect(apnBid.currency).to.be.undefined; + expect(apnBid.timeToRespond).to.equal(0); + expect(apnBid.adSize).to.be.undefined; + expect(apnBid.mediaType).to.be.undefined; + + expect(Object.keys(data.adUnits[AD_UNIT_CODE_NATIVE].bids)).to.have.lengthOf(1); + const apnNativeBidsArray = data.adUnits[AD_UNIT_CODE_NATIVE].bids['appnexus']; + expect(apnNativeBidsArray).to.have.lengthOf(1); + const apnNativeBid = apnNativeBidsArray[0]; + expect(apnNativeBid.eventCodes.includes(CNVR_CONSTANTS.BID)).to.be.true; + expect(apnNativeBid.cpm).to.equal(4); + expect(apnNativeBid.originalCpm).to.equal(0.04); + expect(apnNativeBid.currency).to.equal('USD'); + expect(apnNativeBid.timeToRespond).to.equal(334); + expect(apnNativeBid.adSize.w).to.be.undefined; + expect(apnNativeBid.adSize.h).to.be.undefined; + expect(apnNativeBid.mediaType).to.equal('native'); + + expect(Object.keys(data.bidderErrors)).to.have.lengthOf(2); + expect(data.bidderErrors[0].status).to.equal(500); + expect(data.bidderErrors[0].url).to.equal(URL); + expect(data.bidderErrors[0].message).to.not.be.undefined; + expect(data.bidderErrors[0].bidderCode).to.not.be.undefined; + + expect(data.bidderErrors[1].status).to.equal(501); + expect(data.bidderErrors[1].url).to.equal(URL); + expect(data.bidderErrors[1].message).to.not.be.undefined; + expect(data.bidderErrors[1].bidderCode).to.not.be.undefined; + + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(0); + }); + }); + + describe('Bidder Error Tests', function() { + // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest + const XHR_ERROR_MOCK = { + status: 500, + statusText: 'Internal Server Error' + }; + + // https://docs.prebid.org/dev-docs/bidder-adaptor.html#registering-on-bidder-error + const MOCK_BID_REQUEST = { + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + auctionStart: 1579746300522, + bidderCode: 'myBidderCode', + bidderRequestId: '15246a574e859f', + bids: [{}], + gdprConsent: {consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA', vendorData: {}, gdprApplies: true}, + refererInfo: { + canonicalUrl: null, + page: 'http://mypage.org?pbjs_debug=true', + domain: 'mypage.org', + ref: null, + numIframes: 0, + reachedTop: true, + isAmp: false, + stack: ['http://mypage.org?pbjs_debug=true'] + } + }; + + it('should record error when bidder_error called', function() { + let warnStub = sandbox.stub(utils, 'logWarn'); + expect(requests).to.have.lengthOf(0); + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(0); + expect(warnStub.calledOnce).to.be.false; + + events.emit(constants.EVENTS.BIDDER_ERROR, {'error': XHR_ERROR_MOCK, 'bidderRequest': MOCK_BID_REQUEST}); + expect(Object.keys(cnvrHelper.bidderErrorCache)).to.have.lengthOf(1); + expect(warnStub.calledOnce).to.be.true; + + let errorObj = cnvrHelper.bidderErrorCache[MOCK_BID_REQUEST.auctionId]; + expect(errorObj.errors).to.have.lengthOf(1); + expect(errorObj.errors[0].status).to.equal(XHR_ERROR_MOCK.status); + expect(errorObj.errors[0].message).to.equal(XHR_ERROR_MOCK.statusText); + expect(errorObj.errors[0].bidderCode).to.equal(MOCK_BID_REQUEST.bidderCode); + expect(errorObj.errors[0].url).to.not.be.undefined; + + events.emit(constants.EVENTS.BIDDER_ERROR, {'error': XHR_ERROR_MOCK, 'bidderRequest': MOCK_BID_REQUEST}); + errorObj = cnvrHelper.bidderErrorCache[MOCK_BID_REQUEST.auctionId]; + expect(errorObj.errors).to.have.lengthOf(2); + }); + }); +}); diff --git a/test/spec/modules/conversantBidAdapter_spec.js b/test/spec/modules/conversantBidAdapter_spec.js index 53169326d3b..59ebefa2d60 100644 --- a/test/spec/modules/conversantBidAdapter_spec.js +++ b/test/spec/modules/conversantBidAdapter_spec.js @@ -72,6 +72,7 @@ describe('Conversant adapter tests', function() { video: { context: 'instream', playerSize: [632, 499], + pos: 3 } }, placementCode: 'pcode003', @@ -108,12 +109,14 @@ describe('Conversant adapter tests', function() { { bidder: 'conversant', params: { - site_id: siteId + site_id: siteId, + position: 2, }, mediaTypes: { video: { context: 'instream', - mimes: ['video/mp4', 'video/x-flv'] + mimes: ['video/mp4', 'video/x-flv'], + pos: 7, } }, placementCode: 'pcode005', @@ -147,6 +150,23 @@ describe('Conversant adapter tests', function() { bidId: 'bid006', bidderRequestId: '117d765b87bed38', auctionId: 'req000' + }, + { + bidder: 'conversant', + params: { + site_id: siteId + }, + mediaTypes: { + banner: { + sizes: [[728, 90], [468, 60]], + pos: 5 + } + }, + placementCode: 'pcode001', + transactionId: 'tx001', + bidId: 'bid007', + bidderRequestId: '117d765b87bed38', + auctionId: 'req000' } ]; @@ -201,8 +221,9 @@ describe('Conversant adapter tests', function() { it('Verify basic properties', function() { expect(spec.code).to.equal('conversant'); - expect(spec.aliases).to.be.an('array').with.lengthOf(1); + expect(spec.aliases).to.be.an('array').with.lengthOf(2); expect(spec.aliases[0]).to.equal('cnvr'); + expect(spec.aliases[1]).to.equal('epsilon'); expect(spec.supportedMediaTypes).to.be.an('array').with.lengthOf(2); expect(spec.supportedMediaTypes[1]).to.equal('video'); }); @@ -234,7 +255,12 @@ describe('Conversant adapter tests', function() { const page = 'http://test.com?a=b&c=123'; const bidderRequest = { refererInfo: { - referer: page + page: page + }, + ortb2: { + source: { + tid: 'tid000' + } } }; const request = spec.buildRequests(bidRequests, bidderRequest); @@ -242,10 +268,11 @@ describe('Conversant adapter tests', function() { expect(request.url).to.equal('https://web.hb.ad.cpe.dotomi.com/cvx/client/hb/ortb/25'); const payload = request.data; - expect(payload).to.have.property('id', 'req000'); + expect(payload).to.have.property('id'); + expect(payload.source).to.have.property('tid', 'tid000'); expect(payload).to.have.property('at', 1); expect(payload).to.have.property('imp'); - expect(payload.imp).to.be.an('array').with.lengthOf(7); + expect(payload.imp).to.be.an('array').with.lengthOf(8); expect(payload.imp[0]).to.have.property('id', 'bid000'); expect(payload.imp[0]).to.have.property('secure', 1); @@ -287,7 +314,7 @@ describe('Conversant adapter tests', function() { expect(payload.imp[3]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[3]).to.not.have.property('tagid'); expect(payload.imp[3]).to.have.property('video'); - expect(payload.imp[3].video).to.not.have.property('pos'); + expect(payload.imp[3].video).to.have.property('pos', 3); expect(payload.imp[3].video).to.have.property('w', 632); expect(payload.imp[3].video).to.have.property('h', 499); expect(payload.imp[3].video).to.have.property('mimes'); @@ -325,7 +352,7 @@ describe('Conversant adapter tests', function() { expect(payload.imp[5]).to.have.property('displaymanagerver').that.matches(versionPattern); expect(payload.imp[5]).to.not.have.property('tagid'); expect(payload.imp[5]).to.have.property('video'); - expect(payload.imp[5].video).to.not.have.property('pos'); + expect(payload.imp[5].video).to.have.property('pos', 2); expect(payload.imp[5].video).to.not.have.property('w'); expect(payload.imp[5].video).to.not.have.property('h'); expect(payload.imp[5].video).to.have.property('mimes'); @@ -345,6 +372,17 @@ describe('Conversant adapter tests', function() { expect(payload.imp[6].ext).to.have.property('data'); expect(payload.imp[6].ext.data).to.have.property('pbadslot'); + expect(payload.imp[7]).to.have.property('id', 'bid007'); + expect(payload.imp[7]).to.have.property('secure', 1); + expect(payload.imp[7]).to.have.property('bidfloor', 0); + expect(payload.imp[7]).to.have.property('displaymanager', 'Prebid.js'); + expect(payload.imp[7]).to.have.property('displaymanagerver').that.matches(versionPattern); + expect(payload.imp[7]).to.not.have.property('tagid'); + expect(payload.imp[7]).to.have.property('banner'); + expect(payload.imp[7].banner).to.have.property('pos', 5); + expect(payload.imp[7].banner).to.have.property('format'); + expect(payload.imp[7].banner.format).to.deep.equal([{w: 728, h: 90}, {w: 468, h: 60}]); + expect(payload).to.have.property('site'); expect(payload.site).to.have.property('id', siteId); expect(payload.site).to.have.property('mobile').that.is.oneOf([0, 1]); @@ -358,12 +396,21 @@ describe('Conversant adapter tests', function() { expect(payload.device).to.have.property('ua', navigator.userAgent); expect(payload).to.not.have.property('user'); // there should be no user by default + expect(payload).to.not.have.property('tmax'); // there should be no user by default + }); + + it('Verify timeout', () => { + const bidderRequest = { timeout: 9999 }; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + expect(payload.tmax).equals(bidderRequest.timeout); }); it('Verify first party data', () => { - const bidderRequest = {refererInfo: {referer: 'http://test.com?a=b&c=123'}}; - const cfg = {ortb2: {site: {content: {series: 'MySeries', season: 'MySeason', episode: 3, title: 'MyTitle'}}}}; - config.setConfig(cfg); + const bidderRequest = { + refererInfo: {page: 'http://test.com?a=b&c=123'}, + ortb2: {site: {content: {series: 'MySeries', season: 'MySeason', episode: 3, title: 'MyTitle'}}} + }; const request = spec.buildRequests(bidRequests, bidderRequest); const payload = request.data; expect(payload.site).to.have.property('content'); @@ -371,11 +418,10 @@ describe('Conversant adapter tests', function() { expect(payload.site.content).to.have.property('season'); expect(payload.site.content).to.have.property('episode'); expect(payload.site.content).to.have.property('title'); - config.resetConfig(); }); it('Verify supply chain data', () => { - const bidderRequest = {refererInfo: {referer: 'http://test.com?a=b&c=123'}}; + const bidderRequest = {refererInfo: {page: 'http://test.com?a=b&c=123'}}; const schain = {complete: 1, ver: '1.0', nodes: [{asi: 'bidderA.com', sid: '00001', hp: 1}]}; const bidsWithSchain = bidRequests.map((bid) => { return Object.assign({ @@ -390,12 +436,12 @@ describe('Conversant adapter tests', function() { it('Verify override url', function() { const testUrl = 'https://someurl?name=value'; - const request = spec.buildRequests([{params: {white_label_url: testUrl}}]); + const request = spec.buildRequests([{params: {white_label_url: testUrl}}], {}); expect(request.url).to.equal(testUrl); }); it('Verify interpretResponse', function() { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, {}); const response = spec.interpretResponse(bidResponses, request); expect(response).to.be.an('array').with.lengthOf(4); @@ -458,7 +504,7 @@ describe('Conversant adapter tests', function() { Object.assign(unit, {crumbs: {pubcid: 12345}}); }); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 12345); expect(payload).to.not.have.nested.property('user.ext.eids'); }); @@ -473,7 +519,7 @@ describe('Conversant adapter tests', function() { Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)}); }); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 67890); expect(payload).to.not.have.nested.property('user.ext.eids'); }); @@ -548,7 +594,7 @@ describe('Conversant adapter tests', function() { Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)}); }); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.eids', [ {source: 'adserver.org', uids: [{id: '223344', atype: 1, ext: {rtiPartner: 'TDID'}}]}, {source: 'liveramp.com', uids: [{id: '334455', atype: 3}]} @@ -572,7 +618,15 @@ describe('Conversant adapter tests', function() { return (new Date(Date.now() + timeout * 60 * 60 * 24 * 1000)).toUTCString(); } + beforeEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + conversant: { + storageAllowed: true + } + }; + }); afterEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = {}; cleanUp(ID_NAME); cleanUp(CUSTOM_ID_NAME); }); @@ -585,7 +639,7 @@ describe('Conversant adapter tests', function() { storage.setCookie(ID_NAME, '12345', expStr(TIMEOUT)); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', '12345'); }); @@ -598,7 +652,7 @@ describe('Conversant adapter tests', function() { storage.setCookie(CUSTOM_ID_NAME, '12345', expStr(TIMEOUT)); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', '12345'); }); @@ -611,7 +665,7 @@ describe('Conversant adapter tests', function() { storage.setDataInLocalStorage(ID_NAME, 'abcde'); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 'abcde'); }); @@ -624,7 +678,7 @@ describe('Conversant adapter tests', function() { storage.setDataInLocalStorage(ID_NAME, 'fghijk'); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 'fghijk'); }); @@ -637,7 +691,7 @@ describe('Conversant adapter tests', function() { storage.setDataInLocalStorage(ID_NAME, 'lmnopq'); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.not.have.deep.nested.property('user.ext.fpc'); }); @@ -651,7 +705,7 @@ describe('Conversant adapter tests', function() { storage.setDataInLocalStorage(CUSTOM_ID_NAME, 'fghijk'); // construct http post payload - const payload = spec.buildRequests(requests).data; + const payload = spec.buildRequests(requests, {}).data; expect(payload).to.have.deep.nested.property('user.ext.fpc', 'fghijk'); }); }); @@ -671,7 +725,7 @@ describe('Conversant adapter tests', function() { }; }; - const payload = spec.buildRequests(bidRequest).data; + const payload = spec.buildRequests(bidRequest, {}).data; expect(payload.imp[0]).to.have.property('bidfloor', 3.21); }); @@ -684,7 +738,7 @@ describe('Conversant adapter tests', function() { }; bidRequest[0].params.bidfloor = 0.6; - const payload = spec.buildRequests(bidRequest).data; + const payload = spec.buildRequests(bidRequest, {}).data; expect(payload.imp[0]).to.have.property('bidfloor', 0.6); }); @@ -696,7 +750,7 @@ describe('Conversant adapter tests', function() { }; }; - const payload = spec.buildRequests(bidRequest).data; + const payload = spec.buildRequests(bidRequest, {}).data; expect(payload.imp[0]).to.have.property('bidfloor', 0); }); @@ -708,7 +762,7 @@ describe('Conversant adapter tests', function() { }; }; - const payload = spec.buildRequests(bidRequest).data; + const payload = spec.buildRequests(bidRequest, {}).data; expect(payload.imp[0]).to.have.property('bidfloor', 0); }); @@ -717,14 +771,14 @@ describe('Conversant adapter tests', function() { return {}; }; - const payload = spec.buildRequests(bidRequest).data; + const payload = spec.buildRequests(bidRequest, {}).data; expect(payload.imp[0]).to.have.property('bidfloor', 0); }); it('undefined floor result', function() { bidRequest[0].getFloor = () => {}; - const payload = spec.buildRequests(bidRequest).data; + const payload = spec.buildRequests(bidRequest, {}).data; expect(payload.imp[0]).to.have.property('bidfloor', 0); }); }); diff --git a/test/spec/modules/cpexIdSystem_spec.js b/test/spec/modules/cpexIdSystem_spec.js new file mode 100644 index 00000000000..6e004c9f8ca --- /dev/null +++ b/test/spec/modules/cpexIdSystem_spec.js @@ -0,0 +1,38 @@ +import { czechAdIdSubmodule, storage } from 'modules/czechAdIdSystem.js'; + +describe('czechAdId module', function () { + let getCookieStub; + + beforeEach(function (done) { + getCookieStub = sinon.stub(storage, 'getCookie'); + done(); + }); + + afterEach(function () { + getCookieStub.restore(); + }); + + const cookieTestCasesForEmpty = [undefined, null, ''] + + describe('getId()', function () { + it('should return the uid when it exists in cookie', function () { + getCookieStub.withArgs('czaid').returns('czechAdIdTest'); + const id = czechAdIdSubmodule.getId(); + expect(id).to.be.deep.equal({ id: 'czechAdIdTest' }); + }); + + cookieTestCasesForEmpty.forEach(testCase => it('should not return the uid when it doesnt exist in cookie', function () { + getCookieStub.withArgs('czaid').returns(testCase); + const id = czechAdIdSubmodule.getId(); + expect(id).to.be.undefined; + })); + }); + + describe('decode()', function () { + it('should return the uid when it exists in cookie', function () { + getCookieStub.withArgs('czaid').returns('czechAdIdTest'); + const decoded = czechAdIdSubmodule.decode(); + expect(decoded).to.be.deep.equal({ czechAdId: 'czechAdIdTest' }); + }); + }); +}); diff --git a/test/spec/modules/craftBidAdapter_spec.js b/test/spec/modules/craftBidAdapter_spec.js index 3f4bc977016..dfdbebde738 100644 --- a/test/spec/modules/craftBidAdapter_spec.js +++ b/test/spec/modules/craftBidAdapter_spec.js @@ -14,11 +14,17 @@ describe('craftAdapter', function () { describe('isBidRequestValid', function () { before(function() { + $$PREBID_GLOBAL$$.bidderSettings = { + craft: { + storageAllowed: true + } + }; this.windowContext = window.context; window.context = null; }); after(function() { + $$PREBID_GLOBAL$$.bidderSettings = {}; window.context = this.windowContext; }); let bid = { @@ -60,6 +66,16 @@ describe('craftAdapter', function () { }); describe('buildRequests', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + craft: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); let bidRequests = [{ bidder: 'craft', params: { @@ -75,7 +91,7 @@ describe('craftAdapter', function () { }]; let bidderRequest = { refererInfo: { - referer: 'https://www.gacraft.jp/publish/craft-prebid-example.html' + topmostLocation: 'https://www.gacraft.jp/publish/craft-prebid-example.html' } }; it('sends bid request to ENDPOINT via POST', function () { diff --git a/test/spec/modules/criteoBidAdapter_spec.js b/test/spec/modules/criteoBidAdapter_spec.js index 8793d9351d4..7cba0e2fbdf 100755 --- a/test/spec/modules/criteoBidAdapter_spec.js +++ b/test/spec/modules/criteoBidAdapter_spec.js @@ -2,31 +2,251 @@ import { expect } from 'chai'; import { tryGetCriteoFastBid, spec, + storage, PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, canFastBid, getFastBidUrl, FAST_BID_VERSION_CURRENT } from 'modules/criteoBidAdapter.js'; -import { createBid } from 'src/bidfactory.js'; -import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils.js'; +import * as refererDetection from 'src/refererDetection.js'; +import * as ajax from 'src/ajax.js'; import { config } from '../../../src/config.js'; -import { NATIVE, VIDEO } from '../../../src/mediaTypes.js'; +import { BANNER, NATIVE, VIDEO } from '../../../src/mediaTypes.js'; describe('The Criteo bidding adapter', function () { - let utilsMock, sandbox; + let utilsMock, sandbox, ajaxStub; beforeEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + criteo: { + storageAllowed: true + } + }; // Remove FastBid to avoid side effects localStorage.removeItem('criteo_fast_bid'); utilsMock = sinon.mock(utils); sandbox = sinon.sandbox.create(); + ajaxStub = sandbox.stub(ajax, 'ajax'); }); - afterEach(function() { + afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; global.Criteo = undefined; utilsMock.restore(); sandbox.restore(); + ajaxStub.restore(); + }); + + describe('getUserSyncs', function () { + const syncOptionsIframeEnabled = { + iframeEnabled: true + }; + + const expectedHash = { + cw: true, + lsw: true, + origin: 'criteoPrebidAdapter', + requestId: '123456', + tld: 'www.abc.com', + topUrl: 'www.abc.com', + version: '$prebid.version$'.replace(/\./g, '_'), + }; + + let randomStub, + getConfigStub, + getRefererInfoStub, + cookiesAreEnabledStub, + localStorageIsEnabledStub, + getCookieStub, + setCookieStub, + getDataFromLocalStorageStub, + removeDataFromLocalStorageStub; + + beforeEach(function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('criteo.fastBidVersion').returns('none'); + + randomStub = sinon.stub(Math, 'random'); + randomStub.returns(123456); + + getRefererInfoStub = sinon.stub(refererDetection, 'getRefererInfo'); + getRefererInfoStub.returns({ + domain: 'www.abc.com' + }); + + cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + cookiesAreEnabledStub.returns(true); + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + localStorageIsEnabledStub.returns(true); + + getCookieStub = sinon.stub(storage, 'getCookie'); + setCookieStub = sinon.stub(storage, 'setCookie'); + getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + removeDataFromLocalStorageStub = sinon.stub(storage, 'removeDataFromLocalStorage'); + }); + + afterEach(function () { + randomStub.restore(); + getConfigStub.restore(); + getRefererInfoStub.restore(); + cookiesAreEnabledStub.restore(); + localStorageIsEnabledStub.restore(); + getCookieStub.restore(); + setCookieStub.restore(); + getDataFromLocalStorageStub.restore(); + removeDataFromLocalStorageStub.restore(); + }); + + it('should not trigger sync if publisher is using fast bid', function () { + getConfigStub.withArgs('criteo.fastBidVersion').returns('latest'); + + const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined); + + expect(userSyncs).to.eql([]); + }); + + it('should not trigger sync if publisher did not enable iframe based syncs', function () { + const userSyncs = spec.getUserSyncs({ + iframeEnabled: false + }, undefined, undefined, undefined); + + expect(userSyncs).to.eql([]); + }); + + it('should not trigger sync if purpose one is not granted', function () { + const gdprConsent = { + gdprApplies: true, + consentString: 'ABC', + vendorData: { + purpose: { + consents: { + 1: false + } + } + } + }; + const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, gdprConsent, undefined); + + expect(userSyncs).to.eql([]); + }); + + it('forwards ids from cookies', function () { + const cookieData = { + 'cto_bundle': 'a', + 'cto_optout': 'b' + }; + + const expectedHashWithCookieData = { + ...expectedHash, + ...{ + bundle: cookieData['cto_bundle'], + optoutCookie: cookieData['cto_optout'] + } + }; + + getCookieStub.callsFake(cookieName => cookieData[cookieName]); + + const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined); + + expect(userSyncs).to.eql([{ + type: 'iframe', + url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com#${JSON.stringify(expectedHashWithCookieData, Object.keys(expectedHashWithCookieData).sort()).replace(/"/g, '%22')}` + }]); + }); + + it('forwards ids from local storage', function () { + const localStorageData = { + 'cto_bundle': 'a', + 'cto_optout': 'b' + }; + + const expectedHashWithLocalStorageData = { + ...expectedHash, + ...{ + bundle: localStorageData['cto_bundle'], + optoutCookie: localStorageData['cto_optout'] + } + }; + + getDataFromLocalStorageStub.callsFake(localStorageName => localStorageData[localStorageName]); + + const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, undefined); + + expect(userSyncs).to.eql([{ + type: 'iframe', + url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com#${JSON.stringify(expectedHashWithLocalStorageData, Object.keys(expectedHashWithLocalStorageData).sort()).replace(/"/g, '%22')}` + }]); + }); + + it('forwards gdpr data', function () { + const gdprConsent = { + gdprApplies: true, + consentString: 'ABC', + vendorData: { + purpose: { + consents: { + 1: true + } + } + } + }; + const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, gdprConsent, undefined); + + expect(userSyncs).to.eql([{ + type: 'iframe', + url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&gdpr=1&gdpr_consent=ABC#${JSON.stringify(expectedHash).replace(/"/g, '%22')}` + }]); + }); + + it('forwards usp data', function () { + const userSyncs = spec.getUserSyncs(syncOptionsIframeEnabled, undefined, undefined, 'ABC'); + + expect(userSyncs).to.eql([{ + type: 'iframe', + url: `https://gum.criteo.com/syncframe?origin=criteoPrebidAdapter&topUrl=www.abc.com&us_privacy=ABC#${JSON.stringify(expectedHash).replace(/"/g, '%22')}` + }]); + }); + + it('should delete user data when calling onDataDeletionRequest', () => { + const cookieData = { + 'cto_bundle': 'a' + }; + const lsData = { + 'cto_bundle': 'a' + } + getCookieStub.callsFake(cookieName => cookieData[cookieName]); + setCookieStub.callsFake((cookieName, value, expires) => cookieData[cookieName] = value); + getDataFromLocalStorageStub.callsFake(name => lsData[name]); + removeDataFromLocalStorageStub.callsFake(name => lsData[name] = ''); + spec.onDataDeletionRequest([]); + expect(getCookieStub.calledOnce).to.equal(true); + expect(setCookieStub.calledOnce).to.equal(true); + expect(getDataFromLocalStorageStub.calledOnce).to.equal(true); + expect(removeDataFromLocalStorageStub.calledOnce).to.equal(true); + expect(cookieData.cto_bundle).to.equal(''); + expect(lsData.cto_bundle).to.equal(''); + expect(ajaxStub.calledOnce).to.equal(true); + }); + + it('should not call API when calling onDataDeletionRequest with no id', () => { + const cookieData = { + 'cto_bundle': '' + }; + const lsData = { + 'cto_bundle': '' + } + getCookieStub.callsFake(cookieName => cookieData[cookieName]); + setCookieStub.callsFake((cookieName, value, expires) => cookieData[cookieName] = value); + getDataFromLocalStorageStub.callsFake(name => lsData[name]); + removeDataFromLocalStorageStub.callsFake(name => lsData[name] = ''); + spec.onDataDeletionRequest([]); + expect(getCookieStub.calledOnce).to.be.true; + expect(setCookieStub.called).to.be.false; + expect(getDataFromLocalStorageStub.calledOnce).to.be.true + expect(removeDataFromLocalStorageStub.called).to.be.false; + expect(ajaxStub.called).to.be.false; + }); }); describe('isBidRequestValid', function () { @@ -133,7 +353,8 @@ describe('The Criteo bidding adapter', function () { placement: 1, minduration: 0, playbackmethod: 1, - startdelay: 0 + startdelay: 0, + plcmt: 1 } }, params: { @@ -404,7 +625,8 @@ describe('The Criteo bidding adapter', function () { const refererUrl = 'https://criteo.com?pbt_debug=1&pbt_nolog=1'; const bidderRequest = { refererInfo: { - referer: refererUrl + page: refererUrl, + topmostLocation: refererUrl }, timeout: 3000, gdprConsent: { @@ -419,17 +641,106 @@ describe('The Criteo bidding adapter', function () { }, }; + let localStorageIsEnabledStub; + + this.beforeEach(function () { + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + localStorageIsEnabledStub.returns(true); + }); + afterEach(function () { + localStorageIsEnabledStub.restore(); config.resetConfig(); }); + it('should properly build a request using random uuid as auction id', function () { + const generateUUIDStub = sinon.stub(utils, 'generateUUID'); + generateUUIDStub.returns('def'); + const bidderRequest = { + }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.id).to.equal('def'); + generateUUIDStub.restore(); + }); + + it('should properly transmit source.tid if available', function () { + const bidderRequest = { + ortb2: { + source: { + tid: 'abc' + } + } + }; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.source.tid).to.equal('abc'); + }); + + it('should properly transmit bidId if available', function () { + const bidderRequest = { + ortb2: { + source: { + tid: 'abc' + } + } + }; + const bidRequests = [ + { + bidId: 'bidId', + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.slots[0].slotid).to.equal('bidId'); + }); + it('should properly build a request if refererInfo is not provided', function () { const bidderRequest = {}; const bidRequests = [ { bidder: 'criteo', adUnitCode: 'bid-123', - transactionId: 'transaction-123', + ortb2Imp: { + ext: { + tid: 'transaction-123', + }, + }, mediaTypes: { banner: { sizes: [[728, 90]] @@ -448,7 +759,11 @@ describe('The Criteo bidding adapter', function () { { bidder: 'criteo', adUnitCode: 'bid-123', - transactionId: 'transaction-123', + ortb2Imp: { + ext: { + tid: 'transaction-123', + }, + }, mediaTypes: { banner: { sizes: [[728, 90]] @@ -457,13 +772,13 @@ describe('The Criteo bidding adapter', function () { params: { zoneId: 123, publisherSubId: '123', - nativeCallback: function() {}, + nativeCallback: function () { }, integrationMode: 'amp' }, }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&im=1&debug=1&nolog=1/); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d+&lsavail=1&im=1&debug=1&nolog=1/); expect(request.method).to.equal('POST'); const ortbRequest = request.data; expect(ortbRequest.publisher.url).to.equal(refererUrl); @@ -512,7 +827,7 @@ describe('The Criteo bidding adapter', function () { expect(ortbRequest.slots[0].sizes[0]).to.equal('undefinedxundefined'); }); - it('should properly detect and get sizes of native sizeless banner', function () { + it('should properly detect and forward native flag', function () { const bidRequests = [ { mediaTypes: { @@ -521,17 +836,52 @@ describe('The Criteo bidding adapter', function () { } }, params: { - nativeCallback: function() {} + nativeCallback: function () { } }, }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); const ortbRequest = request.data; - expect(ortbRequest.slots[0].sizes).to.have.lengthOf(1); - expect(ortbRequest.slots[0].sizes[0]).to.equal('2x2'); + expect(ortbRequest.slots[0].native).to.equal(true); + }); + + it('should properly forward eids', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + userIdAsEids: [ + { + source: 'criteo.com', + uids: [{ + id: 'abc', + atype: 1 + }] + } + ], + params: {} + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.user.ext.eids).to.deep.equal([ + { + source: 'criteo.com', + uids: [{ + id: 'abc', + atype: 1 + }] + } + ]); }); - it('should properly detect and get size of native sizeless banner', function () { + it('should properly detect and forward native flag', function () { const bidRequests = [ { mediaTypes: { @@ -540,20 +890,76 @@ describe('The Criteo bidding adapter', function () { } }, params: { - nativeCallback: function() {} + nativeCallback: function () { } }, }, ]; const request = spec.buildRequests(bidRequests, bidderRequest); const ortbRequest = request.data; - expect(ortbRequest.slots[0].sizes).to.have.lengthOf(1); - expect(ortbRequest.slots[0].sizes[0]).to.equal('2x2'); + expect(ortbRequest.slots[0].native).to.equal(true); + }); + + it('should map ortb native assets to slot ext assets', function () { + const assets = [{ + required: 1, + id: 1, + img: { + type: 3, + wmin: 100, + hmin: 100, + } + }, + { + required: 1, + id: 2, + title: { + len: 140, + } + }, + { + required: 1, + id: 3, + data: { + type: 1, + } + }, + { + required: 0, + id: 4, + data: { + type: 2, + } + }, + { + required: 0, + id: 5, + img: { + type: 1, + wmin: 20, + hmin: 20, + } + }]; + const bidRequests = [ + { + nativeOrtbRequest: { + assets: assets + }, + params: { + nativeCallback: function () { } + }, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + const ortbRequest = request.data; + expect(ortbRequest.slots[0].native).to.equal(true); + expect(ortbRequest.slots[0].ext.assets).to.deep.equal(assets); }); it('should properly build a networkId request', function () { const bidderRequest = { refererInfo: { - referer: refererUrl + page: refererUrl, + topmostLocation: refererUrl, }, timeout: 3000, gdprConsent: { @@ -570,7 +976,11 @@ describe('The Criteo bidding adapter', function () { { bidder: 'criteo', adUnitCode: 'bid-123', - transactionId: 'transaction-123', + ortb2Imp: { + ext: { + tid: 'transaction-123', + }, + }, mediaTypes: { banner: { sizes: [[300, 250], [728, 90]] @@ -600,7 +1010,8 @@ describe('The Criteo bidding adapter', function () { it('should properly build a mixed request', function () { const bidderRequest = { refererInfo: { - referer: refererUrl + page: refererUrl, + topmostLocation: refererUrl, }, timeout: 3000 }; @@ -608,7 +1019,11 @@ describe('The Criteo bidding adapter', function () { { bidder: 'criteo', adUnitCode: 'bid-123', - transactionId: 'transaction-123', + ortb2Imp: { + ext: { + tid: 'transaction-123', + }, + }, mediaTypes: { banner: { sizes: [[728, 90]] @@ -621,7 +1036,11 @@ describe('The Criteo bidding adapter', function () { { bidder: 'criteo', adUnitCode: 'bid-234', - transactionId: 'transaction-234', + ortb2Imp: { + ext: { + tid: 'transaction-234', + }, + }, mediaTypes: { banner: { sizes: [[300, 250], [728, 90]] @@ -703,14 +1122,11 @@ describe('The Criteo bidding adapter', function () { expect(request.data.user.uspIab).to.equal('1YNY'); }); - it('should properly build a request with schain object', function () { - const expectedSchain = { - someProperty: 'someValue' - }; + it('should properly build a request with device sua field', function () { + const sua = {} const bidRequests = [ { bidder: 'criteo', - schain: expectedSchain, adUnitCode: 'bid-123', transactionId: 'transaction-123', mediaTypes: { @@ -723,12 +1139,22 @@ describe('The Criteo bidding adapter', function () { }, }, ]; + const bidderRequest = { + timeout: 3000, + uspConsent: '1YNY', + ortb2: { + device: { + sua: sua + } + } + }; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.source.ext.schain).to.equal(expectedSchain); + expect(request.data.user.ext.sua).to.not.be.null; + expect(request.data.user.ext.sua).to.equal(sua); }); - it('should properly build a request with if ccpa consent field is not provided', function () { + it('should properly build a request with gpp consent field', function () { const bidRequests = [ { bidder: 'criteo', @@ -744,69 +1170,209 @@ describe('The Criteo bidding adapter', function () { }, }, ]; - const bidderRequest = { - timeout: 3000 + const ortb2 = { + regs: { + gpp: 'gpp_consent_string', + gpp_sid: [0, 1, 2] + } }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.user).to.not.be.null; - expect(request.data.user.uspIab).to.equal(undefined); + const request = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2 }); + expect(request.data.regs).to.not.be.null; + expect(request.data.regs.gpp).to.equal('gpp_consent_string'); + expect(request.data.regs.gpp_sid).to.deep.equal([0, 1, 2]); }); - it('should properly build a video request', function () { + it('should properly build a request with schain object', function () { + const expectedSchain = { + someProperty: 'someValue' + }; const bidRequests = [ { bidder: 'criteo', + schain: expectedSchain, adUnitCode: 'bid-123', transactionId: 'transaction-123', - sizes: [[640, 480]], mediaTypes: { - video: { - playerSize: [640, 480], - mimes: ['video/mp4', 'video/x-flv'], - maxduration: 30, - api: [1, 2], - protocols: [2, 3] + banner: { + sizes: [[728, 90]] } }, params: { zoneId: 123, - video: { - skip: 1, - minduration: 5, - startdelay: 5, - playbackmethod: [1, 3], - placement: 2 - } }, }, ]; + const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); - expect(request.method).to.equal('POST'); - const ortbRequest = request.data; - expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']); - expect(ortbRequest.slots[0].sizes).to.deep.equal([]); - expect(ortbRequest.slots[0].video.playersizes).to.deep.equal(['640x480']); - expect(ortbRequest.slots[0].video.maxduration).to.equal(30); - expect(ortbRequest.slots[0].video.api).to.deep.equal([1, 2]); - expect(ortbRequest.slots[0].video.protocols).to.deep.equal([2, 3]); - expect(ortbRequest.slots[0].video.skip).to.equal(1); - expect(ortbRequest.slots[0].video.minduration).to.equal(5); - expect(ortbRequest.slots[0].video.startdelay).to.equal(5); - expect(ortbRequest.slots[0].video.playbackmethod).to.deep.equal([1, 3]); - expect(ortbRequest.slots[0].video.placement).to.equal(2); + expect(request.data.source.ext.schain).to.equal(expectedSchain); }); - it('should properly build a video request with more than one player size', function () { + it('should properly build a request with bcat field', function () { + const bcat = ['IAB1', 'IAB2']; const bidRequests = [ { bidder: 'criteo', adUnitCode: 'bid-123', transactionId: 'transaction-123', - sizes: [[640, 480], [800, 600]], mediaTypes: { - video: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + ortb2: { + bcat + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bcat).to.not.be.null; + expect(request.data.bcat).to.equal(bcat); + }); + + it('should properly build a request with badv field', function () { + const badv = ['ford.com']; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + ortb2: { + badv + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.badv).to.not.be.null; + expect(request.data.badv).to.equal(badv); + }); + + it('should properly build a request with bapp field', function () { + const bapp = ['com.foo.mygame']; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + ortb2: { + bapp + } + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bapp).to.not.be.null; + expect(request.data.bapp).to.equal(bapp); + }); + + it('should properly build a request with if ccpa consent field is not provided', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + }, + }, + ]; + const bidderRequest = { + timeout: 3000 + }; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.user).to.not.be.null; + expect(request.data.user.uspIab).to.equal(undefined); + }); + + it('should properly build a video request', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[640, 480]], + mediaTypes: { + video: { + playerSize: [640, 480], + mimes: ['video/mp4', 'video/x-flv'], + maxduration: 30, + api: [1, 2], + protocols: [2, 3], + plcmt: 3 + } + }, + params: { + zoneId: 123, + video: { + skip: 1, + minduration: 5, + startdelay: 5, + playbackmethod: [1, 3], + placement: 2 + } + }, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.match(/^https:\/\/bidder\.criteo\.com\/cdb\?profileId=207&av=\d+&wv=[^&]+&cb=\d/); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + expect(ortbRequest.slots[0].video.mimes).to.deep.equal(['video/mp4', 'video/x-flv']); + expect(ortbRequest.slots[0].sizes).to.deep.equal([]); + expect(ortbRequest.slots[0].video.playersizes).to.deep.equal(['640x480']); + expect(ortbRequest.slots[0].video.maxduration).to.equal(30); + expect(ortbRequest.slots[0].video.api).to.deep.equal([1, 2]); + expect(ortbRequest.slots[0].video.protocols).to.deep.equal([2, 3]); + expect(ortbRequest.slots[0].video.skip).to.equal(1); + expect(ortbRequest.slots[0].video.minduration).to.equal(5); + expect(ortbRequest.slots[0].video.startdelay).to.equal(5); + expect(ortbRequest.slots[0].video.playbackmethod).to.deep.equal([1, 3]); + expect(ortbRequest.slots[0].video.placement).to.equal(2); + expect(ortbRequest.slots[0].video.plcmt).to.equal(3); + }); + + it('should properly build a video request with more than one player size', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + sizes: [[640, 480], [800, 600]], + mediaTypes: { + video: { playerSize: [[640, 480], [800, 600]], mimes: ['video/mp4', 'video/x-flv'], maxduration: 30, @@ -852,7 +1418,7 @@ describe('The Criteo bidding adapter', function () { sizes: [[300, 250]], mediaTypes: { video: { - playerSize: [ [300, 250] ], + playerSize: [[300, 250]], mimes: ['video/mp4', 'video/MPV', 'video/H264', 'video/webm', 'video/ogg'], minduration: 1, maxduration: 30, @@ -925,19 +1491,14 @@ describe('The Criteo bidding adapter', function () { }, ]; - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - }; - return utils.deepAccess(config, key); - }); - - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2: {} }); expect(request.data.publisher.ext).to.equal(undefined); expect(request.data.user.ext).to.equal(undefined); expect(request.data.slots[0].ext).to.equal(undefined); }); it('should properly build a request with criteo specific ad unit first party data', function () { + // TODO: this test does not do what it says const bidRequests = [ { bidder: 'criteo', @@ -957,21 +1518,27 @@ describe('The Criteo bidding adapter', function () { }, ]; - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - }; - return utils.deepAccess(config, key); - }); - - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2: {} }); expect(request.data.slots[0].ext).to.deep.equal({ bidfloor: 0.75, }); }); it('should properly build a request with first party data', function () { - const contextData = { + const siteData = { keywords: ['power tools'], + content: { + data: [{ + name: 'some_provider', + ext: { + segtax: 3 + }, + segment: [ + { 'id': '1001' }, + { 'id': '1002' } + ] + }] + }, ext: { data: { pageType: 'article' @@ -980,6 +1547,16 @@ describe('The Criteo bidding adapter', function () { }; const userData = { gender: 'M', + data: [{ + name: 'some_provider', + ext: { + segtax: 3 + }, + segment: [ + { 'id': '1001' }, + { 'id': '1002' } + ] + }], ext: { data: { registered: true @@ -1012,25 +1589,295 @@ describe('The Criteo bidding adapter', function () { }, ]; - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2: { - site: contextData, - user: userData - } - }; - return utils.deepAccess(config, key); - }); - + const ortb2 = { + site: siteData, + user: userData + }; + + const request = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2 }); + expect(request.data.publisher.ext).to.deep.equal({ data: { pageType: 'article' } }); + expect(request.data.user).to.deep.equal(userData); + expect(request.data.site).to.deep.equal(siteData); + expect(request.data.slots[0].ext).to.deep.equal({ + bidfloor: 0.75, + data: { + someContextAttribute: 'abc' + } + }); + }); + + it('should properly build a request when coppa flag is true', function () { + const bidRequests = []; + const bidderRequest = {}; + config.setConfig({ coppa: true }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.regs.coppa).to.not.be.undefined; + expect(request.data.regs.coppa).to.equal(1); + }); + + it('should properly build a request when coppa flag is false', function () { + const bidRequests = []; + const bidderRequest = {}; + config.setConfig({ coppa: false }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.regs.coppa).to.not.be.undefined; + expect(request.data.regs.coppa).to.equal(0); + }); + + it('should properly build a request when coppa flag is not defined', function () { + const bidRequests = []; + const bidderRequest = {}; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.regs.coppa).to.be.undefined; + }); + + it('should properly build a banner request with floors', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[300, 250], [728, 90]] + } + }, + params: { + networkId: 456, + }, + + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + } + }, + ]; + const bidderRequest = {}; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].ext.floors).to.deep.equal({ + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + }); + }); + + it('should properly build a request with static floors', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[300, 250], [728, 90]] + } + }, + params: { + networkId: 456, + bidFloor: 1, + bidFloorCur: 'EUR' + }, + }, + ]; + const bidderRequest = {}; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].ext.floors).to.deep.equal({ + 'banner': { + '300x250': { 'currency': 'EUR', 'floor': 1 }, + '728x90': { 'currency': 'EUR', 'floor': 1 } + } + }); + }); + + it('should properly build a video request with several player sizes with floors', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + video: { + playerSize: [[300, 250], [728, 90]] + } + }, + params: { + networkId: 456, + }, + + getFloor: inputParams => { + if (inputParams.mediaType === VIDEO && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === VIDEO && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else { + return {} + } + } + }, + ]; + const bidderRequest = {}; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].ext.floors).to.deep.equal({ + 'video': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + } + }); + }); + + it('should properly build a multi format request with floors', function () { + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[300, 250], [728, 90]] + }, + video: { + playerSize: [640, 480], + }, + native: {} + }, + params: { + networkId: 456, + }, + ortb2Imp: { + ext: { + data: { + someContextAttribute: 'abc' + } + } + }, + + getFloor: inputParams => { + if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { + return { + currency: 'USD', + floor: 1.0 + }; + } else if (inputParams.mediaType === BANNER && inputParams.size[0] === 728 && inputParams.size[1] === 90) { + return { + currency: 'USD', + floor: 2.0 + }; + } else if (inputParams.mediaType === VIDEO && inputParams.size[0] === 640 && inputParams.size[1] === 480) { + return { + currency: 'EUR', + floor: 3.2 + }; + } else if (inputParams.mediaType === NATIVE && inputParams.size === '*') { + return { + currency: 'YEN', + floor: 4.99 + }; + } else { + return {} + } + } + }, + ]; + const bidderRequest = {}; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].ext.data.someContextAttribute).to.deep.equal('abc'); + expect(request.data.slots[0].ext.floors).to.deep.equal({ + 'banner': { + '300x250': { 'currency': 'USD', 'floor': 1 }, + '728x90': { 'currency': 'USD', 'floor': 2 } + }, + 'video': { + '640x480': { 'currency': 'EUR', 'floor': 3.2 } + }, + 'native': { + '*': { 'currency': 'YEN', 'floor': 4.99 } + } + }); + }); + + it('should properly build a request when imp.rwdd is present', function () { + const bidderRequest = {}; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + ext: { + bidfloor: 0.75 + } + }, + ortb2Imp: { + rwdd: 1, + ext: { + data: { + someContextAttribute: 'abc' + } + } + } + }, + ]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.slots[0].rwdd).to.be.not.null; + expect(request.data.slots[0].rwdd).to.equal(1); + }); + + it('should properly build a request when imp.rwdd is false', function () { + const bidderRequest = {}; + const bidRequests = [ + { + bidder: 'criteo', + adUnitCode: 'bid-123', + transactionId: 'transaction-123', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + zoneId: 123, + ext: { + bidfloor: 0.75 + } + }, + ortb2Imp: { + rwdd: 0, + ext: { + data: { + someContextAttribute: 'abc' + } + } + } + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.publisher.ext).to.deep.equal({keywords: ['power tools'], data: {pageType: 'article'}}); - expect(request.data.user.ext).to.deep.equal({gender: 'M', data: {registered: true}}); - expect(request.data.slots[0].ext).to.deep.equal({ - bidfloor: 0.75, - data: { - someContextAttribute: 'abc' - } - }); + expect(request.data.slots[0].rwdd).to.be.undefined; }); }); @@ -1052,8 +1899,13 @@ describe('The Criteo bidding adapter', function () { creativecode: 'test-crId', width: 728, height: 90, - dealCode: 'myDealCode', + deal: 'myDealCode', adomain: ['criteo.com'], + ext: { + meta: { + networkName: 'Criteo' + } + } }], }, }; @@ -1061,6 +1913,11 @@ describe('The Criteo bidding adapter', function () { bidRequests: [{ adUnitCode: 'test-requestId', bidId: 'test-bidId', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, params: { networkId: 456, } @@ -1076,6 +1933,203 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].height).to.equal(90); expect(bids[0].dealId).to.equal('myDealCode'); expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com'); + expect(bids[0].meta.networkName).to.equal('Criteo'); + }); + + it('should properly parse a bid response with a networkId with twin ad unit banner win', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + cpm: 1.23, + creative: 'test-ad', + creativecode: 'test-crId', + width: 728, + height: 90, + deal: 'myDealCode', + adomain: ['criteo.com'], + ext: { + meta: { + networkName: 'Criteo' + } + } + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [640, 480], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + }, + }, { + adUnitCode: 'test-requestId', + bidId: 'test-bidId2', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + networkId: 456, + } + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId2'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].ad).to.equal('test-ad'); + expect(bids[0].creativeId).to.equal('test-crId'); + expect(bids[0].width).to.equal(728); + expect(bids[0].height).to.equal(90); + expect(bids[0].dealId).to.equal('myDealCode'); + expect(bids[0].meta.advertiserDomains[0]).to.equal('criteo.com'); + expect(bids[0].meta.networkName).to.equal('Criteo'); + }); + + it('should properly parse a bid response with a networkId with twin ad unit video win', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + displayurl: 'http://test-ad', + width: 728, + height: 90, + zoneid: 123, + video: true, + ext: { + meta: { + networkName: 'Criteo' + } + } + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + mediaTypes: { + video: { + context: 'instream', + mimes: ['video/mpeg'], + playerSize: [728, 90], + protocols: [5, 6], + maxduration: 30, + api: [1, 2] + } + }, + params: { + networkId: 456, + }, + }, { + adUnitCode: 'test-requestId', + bidId: 'test-bidId2', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + networkId: 456, + } + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].vastUrl).to.equal('http://test-ad'); + expect(bids[0].mediaType).to.equal(VIDEO); + }); + + it('should properly parse a bid response with a networkId with twin ad unit native win', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + cpm: 1.23, + creative: 'test-ad', + creativecode: 'test-crId', + width: 728, + height: 90, + deal: 'myDealCode', + adomain: ['criteo.com'], + native: { + 'products': [{ + 'sendTargetingKeys': false, + 'title': 'Product title', + 'description': 'Product desc', + 'price': '100', + 'click_url': 'https://product.click', + 'image': { + 'url': 'https://publisherdirect.criteo.com/publishertag/preprodtest/creative.png', + 'height': 300, + 'width': 300 + }, + 'call_to_action': 'Try it now!' + }], + 'advertiser': { + 'description': 'sponsor', + 'domain': 'criteo.com', + 'logo': { 'url': 'https://www.criteo.com/images/criteo-logo.svg', 'height': 300, 'width': 300 } + }, + 'privacy': { + 'optout_click_url': 'https://info.criteo.com/privacy/informations', + 'optout_image_url': 'https://static.criteo.net/flash/icon/nai_small.png', + }, + 'impression_pixels': [{ 'url': 'https://my-impression-pixel/test/impression' }, { 'url': 'https://cas.com/lg.com' }] + }, + ext: { + meta: { + networkName: 'Criteo' + } + } + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + mediaTypes: { + native: {} + }, + params: { + networkId: 456, + }, + }, { + adUnitCode: 'test-requestId', + bidId: 'test-bidId2', + mediaTypes: { + banner: { + sizes: [[728, 90]] + } + }, + params: { + networkId: 456, + } + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].mediaType).to.equal(NATIVE); }); it('should properly parse a bid response with a zoneId', function () { @@ -1104,7 +2158,6 @@ describe('The Criteo bidding adapter', function () { const bids = spec.interpretResponse(response, request); expect(bids).to.have.lengthOf(1); expect(bids[0].requestId).to.equal('test-bidId'); - expect(bids[0].adId).to.equal('abc123'); expect(bids[0].cpm).to.equal(1.23); expect(bids[0].ad).to.equal('test-ad'); expect(bids[0].width).to.equal(728); @@ -1138,12 +2191,56 @@ describe('The Criteo bidding adapter', function () { const bids = spec.interpretResponse(response, request); expect(bids).to.have.lengthOf(1); expect(bids[0].requestId).to.equal('test-bidId'); - expect(bids[0].adId).to.equal('abc123'); expect(bids[0].cpm).to.equal(1.23); expect(bids[0].vastUrl).to.equal('http://test-ad'); expect(bids[0].mediaType).to.equal(VIDEO); }); + it('should properly parse a bid response with a outstream video', function () { + const response = { + body: { + slots: [{ + impid: 'test-requestId', + bidId: 'abc123', + cpm: 1.23, + displayurl: 'http://test-ad', + width: 728, + height: 90, + zoneid: 123, + video: true, + ext: { + videoPlayerType: 'RadiantMediaPlayer', + videoPlayerConfig: { + + } + } + }], + }, + }; + const request = { + bidRequests: [{ + adUnitCode: 'test-requestId', + bidId: 'test-bidId', + params: { + zoneId: 123, + }, + mediaTypes: { + video: { + context: 'outstream' + } + } + }] + }; + const bids = spec.interpretResponse(response, request); + expect(bids).to.have.lengthOf(1); + expect(bids[0].requestId).to.equal('test-bidId'); + expect(bids[0].cpm).to.equal(1.23); + expect(bids[0].vastUrl).to.equal('http://test-ad'); + expect(bids[0].renderer.url).to.equal('https://static.criteo.net/js/ld/publishertag.renderer.js'); + expect(typeof bids[0].renderer.config.documentResolver).to.equal('function'); + expect(typeof bids[0].renderer._render).to.equal('function'); + }); + it('should properly parse a bid response with native', function () { const response = { body: { @@ -1171,13 +2268,13 @@ describe('The Criteo bidding adapter', function () { 'advertiser': { 'description': 'sponsor', 'domain': 'criteo.com', - 'logo': {'url': 'https://www.criteo.com/images/criteo-logo.svg', 'height': 300, 'width': 300} + 'logo': { 'url': 'https://www.criteo.com/images/criteo-logo.svg', 'height': 300, 'width': 300 } }, 'privacy': { 'optout_click_url': 'https://info.criteo.com/privacy/informations', 'optout_image_url': 'https://static.criteo.net/flash/icon/nai_small.png', }, - 'impression_pixels': [{'url': 'https://my-impression-pixel/test/impression'}, {'url': 'https://cas.com/lg.com'}] + 'impression_pixels': [{ 'url': 'https://my-impression-pixel/test/impression' }, { 'url': 'https://cas.com/lg.com' }] } }], }, @@ -1195,13 +2292,12 @@ describe('The Criteo bidding adapter', function () { const bids = spec.interpretResponse(response, request); expect(bids).to.have.lengthOf(1); expect(bids[0].requestId).to.equal('test-bidId'); - expect(bids[0].adId).to.equal('abc123'); expect(bids[0].cpm).to.equal(1.23); expect(bids[0].mediaType).to.equal(NATIVE); }); it('should warn only once if sendTargetingKeys set to true on required fields for native bidRequest', () => { - const bidderRequest = { }; + const bidderRequest = {}; const bidRequests = [ { bidder: 'criteo', @@ -1211,7 +2307,7 @@ describe('The Criteo bidding adapter', function () { params: { zoneId: 123, publisherSubId: '123', - nativeCallback: function() {} + nativeCallback: function () { } }, }, { @@ -1222,7 +2318,7 @@ describe('The Criteo bidding adapter', function () { params: { zoneId: 456, publisherSubId: '456', - nativeCallback: function() {} + nativeCallback: function () { } }, }, ]; @@ -1276,7 +2372,7 @@ describe('The Criteo bidding adapter', function () { .withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)') .exactly(nativeParamsWithSendTargetingKeys.length * bidRequests.length); nativeParamsWithSendTargetingKeys.forEach(nativeParams => { - let transformedBidRequests = {...bidRequests}; + let transformedBidRequests = { ...bidRequests }; transformedBidRequests = [Object.assign(transformedBidRequests[0], nativeParams), Object.assign(transformedBidRequests[1], nativeParams)]; spec.buildRequests(transformedBidRequests, bidderRequest); }); @@ -1314,38 +2410,77 @@ describe('The Criteo bidding adapter', function () { expect(bids[0].height).to.equal(90); }); - it('should generate unique adIds if none are returned by the endpoint', function () { + [{ + hasBidResponseLevelPafData: true, + hasBidResponseBidLevelPafData: true, + shouldContainsBidMetaPafData: true + }, + { + hasBidResponseLevelPafData: false, + hasBidResponseBidLevelPafData: true, + shouldContainsBidMetaPafData: false + }, + { + hasBidResponseLevelPafData: true, + hasBidResponseBidLevelPafData: false, + shouldContainsBidMetaPafData: false + }, + { + hasBidResponseLevelPafData: false, + hasBidResponseBidLevelPafData: false, + shouldContainsBidMetaPafData: false + }].forEach(testCase => { + const bidPafContentId = 'abcdef'; + const pafTransmission = { + version: '12' + }; const response = { - body: { - slots: [{ - impid: 'test-requestId', - cpm: 1.23, - creative: 'test-ad', + slots: [ + { width: 300, height: 250, - }, { - impid: 'test-requestId', - cpm: 4.56, - creative: 'test-ad', - width: 728, - height: 90, - }], - }, + cpm: 10, + impid: 'adUnitId', + ext: (testCase.hasBidResponseBidLevelPafData ? { + paf: { + content_id: bidPafContentId + } + } : undefined) + } + ], + ext: (testCase.hasBidResponseLevelPafData ? { + paf: { + transmission: pafTransmission + } + } : undefined) }; + const request = { bidRequests: [{ - adUnitCode: 'test-requestId', - bidId: 'test-bidId', - sizes: [[300, 250], [728, 90]], + adUnitCode: 'adUnitId', + sizes: [[300, 250]], params: { networkId: 456, } }] }; + const bids = spec.interpretResponse(response, request); - expect(bids).to.have.lengthOf(2); - const prebidBids = bids.map(bid => Object.assign(createBid(CONSTANTS.STATUS.GOOD, request.bidRequests[0]), bid)); - expect(prebidBids[0].adId).to.not.equal(prebidBids[1].adId); + + expect(bids).to.have.lengthOf(1); + + const theoreticalBidMetaPafData = { + paf: { + content_id: bidPafContentId, + transmission: pafTransmission + } + }; + + if (testCase.shouldContainsBidMetaPafData) { + expect(bids[0].meta).to.deep.equal(theoreticalBidMetaPafData); + } else { + expect(bids[0].meta).not.to.deep.equal(theoreticalBidMetaPafData); + } }); }); @@ -1440,7 +2575,7 @@ describe('The Criteo bidding adapter', function () { describe('when pubtag prebid adapter is not available', function () { it('should not warn if sendId is provided on required fields for native bidRequest', () => { - const bidderRequest = { }; + const bidderRequest = {}; const bidRequestsWithSendId = [ { bidder: 'criteo', @@ -1450,7 +2585,7 @@ describe('The Criteo bidding adapter', function () { params: { zoneId: 123, publisherSubId: '123', - nativeCallback: function() {} + nativeCallback: function () { } }, nativeParams: { image: { @@ -1481,7 +2616,7 @@ describe('The Criteo bidding adapter', function () { }); it('should warn only once if sendId is not provided on required fields for native bidRequest', () => { - const bidderRequest = { }; + const bidderRequest = {}; const bidRequests = [ { bidder: 'criteo', @@ -1491,7 +2626,7 @@ describe('The Criteo bidding adapter', function () { params: { zoneId: 123, publisherSubId: '123', - nativeCallback: function() {} + nativeCallback: function () { } }, }, { @@ -1502,7 +2637,7 @@ describe('The Criteo bidding adapter', function () { params: { zoneId: 456, publisherSubId: '456', - nativeCallback: function() {} + nativeCallback: function () { } }, }, ]; @@ -1556,7 +2691,7 @@ describe('The Criteo bidding adapter', function () { .withArgs('Criteo: all native assets containing URL should be sent as placeholders with sendId(icon, image, clickUrl, displayUrl, privacyLink, privacyIcon)') .exactly(nativeParamsWithoutSendId.length * bidRequests.length); nativeParamsWithoutSendId.forEach(nativeParams => { - let transformedBidRequests = {...bidRequests}; + let transformedBidRequests = { ...bidRequests }; transformedBidRequests = [Object.assign(transformedBidRequests[0], nativeParams), Object.assign(transformedBidRequests[1], nativeParams)]; spec.buildRequests(transformedBidRequests, bidderRequest); }); @@ -1569,10 +2704,10 @@ describe('The Criteo bidding adapter', function () { const response = {}; const request = {}; - const adapter = { interpretResponse: function() {} }; + const adapter = { interpretResponse: function () { } }; const adapterMock = sinon.mock(adapter); adapterMock.expects('interpretResponse').withExactArgs(response, request).once().returns('ok'); - const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapter = { GetAdapter: function () { } }; const prebidAdapterMock = sinon.mock(prebidAdapter); prebidAdapterMock.expects('GetAdapter').withExactArgs(request).once().returns(adapter); @@ -1592,10 +2727,10 @@ describe('The Criteo bidding adapter', function () { it('should forward bid to pubtag when calling onBidWon', () => { const bid = { auctionId: 123 }; - const adapter = { handleBidWon: function() {} }; + const adapter = { handleBidWon: function () { } }; const adapterMock = sinon.mock(adapter); adapterMock.expects('handleBidWon').withExactArgs(bid).once(); - const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapter = { GetAdapter: function () { } }; const prebidAdapterMock = sinon.mock(prebidAdapter); prebidAdapterMock.expects('GetAdapter').withExactArgs(bid.auctionId).once().returns(adapter); @@ -1615,10 +2750,10 @@ describe('The Criteo bidding adapter', function () { it('should forward bid to pubtag when calling onSetTargeting', () => { const bid = { auctionId: 123 }; - const adapter = { handleSetTargeting: function() {} }; + const adapter = { handleSetTargeting: function () { } }; const adapterMock = sinon.mock(adapter); adapterMock.expects('handleSetTargeting').withExactArgs(bid).once(); - const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapter = { GetAdapter: function () { } }; const prebidAdapterMock = sinon.mock(prebidAdapter); prebidAdapterMock.expects('GetAdapter').withExactArgs(bid.auctionId).once().returns(adapter); @@ -1638,10 +2773,10 @@ describe('The Criteo bidding adapter', function () { it('should forward bid to pubtag when calling onTimeout', () => { const timeoutData = [{ auctionId: 123 }]; - const adapter = { handleBidTimeout: function() {} }; + const adapter = { handleBidTimeout: function () { } }; const adapterMock = sinon.mock(adapter); adapterMock.expects('handleBidTimeout').once(); - const prebidAdapter = { GetAdapter: function() {} }; + const prebidAdapter = { GetAdapter: function () { } }; const prebidAdapterMock = sinon.mock(prebidAdapter); prebidAdapterMock.expects('GetAdapter').withExactArgs(timeoutData[0].auctionId).once().returns(adapter); @@ -1659,17 +2794,17 @@ describe('The Criteo bidding adapter', function () { }); it('should return a POST method with url & data from pubtag', () => { - const bidRequests = { }; - const bidderRequest = { }; + const bidRequests = {}; + const bidderRequest = {}; - const prebidAdapter = { buildCdbUrl: function() {}, buildCdbRequest: function() {} }; + const prebidAdapter = { buildCdbUrl: function () { }, buildCdbRequest: function () { } }; const prebidAdapterMock = sinon.mock(prebidAdapter); prebidAdapterMock.expects('buildCdbUrl').once().returns('cdbUrl'); prebidAdapterMock.expects('buildCdbRequest').once().returns('cdbRequest'); - const adapters = { Prebid: function() {} }; + const adapters = { Prebid: function () { } }; const adaptersMock = sinon.mock(adapters); - adaptersMock.expects('Prebid').withExactArgs(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$').once().returns(prebidAdapter); + adaptersMock.expects('Prebid').withExactArgs(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$', sinon.match.any).once().returns(prebidAdapter); global.Criteo = { PubTag: { diff --git a/test/spec/modules/criteoIdSystem_spec.js b/test/spec/modules/criteoIdSystem_spec.js index d50eadebb55..aaf63873d93 100644 --- a/test/spec/modules/criteoIdSystem_spec.js +++ b/test/spec/modules/criteoIdSystem_spec.js @@ -1,6 +1,7 @@ import { criteoIdSubmodule, storage } from 'modules/criteoIdSystem.js'; import * as utils from 'src/utils.js'; -import {server} from '../../mocks/xhr'; +import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../../../src/adapterManager.js'; +import { server } from '../../mocks/xhr'; const pastDateString = new Date(0).toString() @@ -17,6 +18,9 @@ describe('CriteoId module', function () { let timeStampStub; let parseUrlStub; let triggerPixelStub; + let gdprConsentDataStub; + let uspConsentDataStub; + let gppConsentDataStub; beforeEach(function (done) { getCookieStub = sinon.stub(storage, 'getCookie'); @@ -25,8 +29,11 @@ describe('CriteoId module', function () { setLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); removeFromLocalStorageStub = sinon.stub(storage, 'removeDataFromLocalStorage'); timeStampStub = sinon.stub(utils, 'timestamp').returns(nowTimestamp); - parseUrlStub = sinon.stub(utils, 'parseUrl').returns({protocol: 'https', hostname: 'testdev.com'}) + parseUrlStub = sinon.stub(utils, 'parseUrl').returns({ protocol: 'https', hostname: 'testdev.com' }) triggerPixelStub = sinon.stub(utils, 'triggerPixel'); + gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData'); + uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData'); + gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData'); done(); }); @@ -39,6 +46,9 @@ describe('CriteoId module', function () { timeStampStub.restore(); triggerPixelStub.restore(); parseUrlStub.restore(); + gdprConsentDataStub.restore(); + uspConsentDataStub.restore(); + gppConsentDataStub.restore(); }); const storageTestCases = [ @@ -64,20 +74,21 @@ describe('CriteoId module', function () { it('should call user sync url with the right params', function () { getCookieStub.withArgs('cto_bundle').returns('bundle'); + getCookieStub.withArgs('cto_dna_bundle').returns('info'); window.criteo_pubtag = {} let callBackSpy = sinon.spy(); let result = criteoIdSubmodule.getId(); result.callback(callBackSpy); - const expectedUrl = `https://gum.criteo.com/sid/json?origin=prebid&topUrl=https%3A%2F%2Ftestdev.com%2F&domain=testdev.com&bundle=bundle&cw=1&pbt=1&lsw=1`; + const expectedUrl = `https://gum.criteo.com/sid/json?origin=prebid&topUrl=https%3A%2F%2Ftestdev.com%2F&domain=testdev.com&bundle=bundle&info=info&cw=1&pbt=1&lsw=1`; let request = server.requests[0]; expect(request.url).to.be.eq(expectedUrl); request.respond( 200, - {'Content-Type': 'application/json'}, + { 'Content-Type': 'application/json' }, JSON.stringify({}) ); expect(callBackSpy.calledOnce).to.be.true; @@ -107,7 +118,7 @@ describe('CriteoId module', function () { let request = server.requests[0]; request.respond( 200, - {'Content-Type': 'application/json'}, + { 'Content-Type': 'application/json' }, JSON.stringify(response) ); @@ -135,28 +146,188 @@ describe('CriteoId module', function () { })); const gdprConsentTestCases = [ - { consentData: { gdprApplies: true, consentString: 'expectedConsentString' }, expected: 'expectedConsentString' }, - { consentData: { gdprApplies: false, consentString: 'expectedConsentString' }, expected: undefined }, - { consentData: { gdprApplies: true, consentString: undefined }, expected: undefined }, - { consentData: { gdprApplies: 'oui', consentString: 'expectedConsentString' }, expected: undefined }, - { consentData: undefined, expected: undefined } + { consentData: { gdprApplies: true, consentString: 'expectedConsentString' }, expectedGdprConsent: 'expectedConsentString', expectedGdpr: '1' }, + { consentData: { gdprApplies: false, consentString: 'expectedConsentString' }, expectedGdprConsent: 'expectedConsentString', expectedGdpr: '0' }, + { consentData: { gdprApplies: true, consentString: undefined }, expectedGdprConsent: undefined, expectedGdpr: '1' }, + { consentData: { gdprApplies: 'oui', consentString: 'expectedConsentString' }, expectedGdprConsent: 'expectedConsentString', expectedGdpr: '0' }, + { consentData: undefined, expectedGdprConsent: undefined, expectedGdpr: undefined } ]; + it('should call sync pixels if request by backend', function () { + const expirationTs = new Date(nowTimestamp + cookiesMaxAge).toString(); + + const result = criteoIdSubmodule.getId(); + result.callback((id) => { + + }); + + const response = { + pixels: [ + { + pixelUrl: 'pixelUrlWithBundle', + writeBundleInStorage: true, + bundlePropertyName: 'abc', + storageKeyName: 'cto_pixel_test' + }, + { + pixelUrl: 'pixelUrl' + } + ] + }; + + server.requests[0].respond( + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify(response) + ); + + server.requests[1].respond( + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify({ + abc: 'ok' + }) + ); + + expect(triggerPixelStub.called).to.be.true; + expect(setCookieStub.calledWith('cto_pixel_test', 'ok', expirationTs, null, '.com')).to.be.true; + expect(setCookieStub.calledWith('cto_pixel_test', 'ok', expirationTs, null, '.testdev.com')).to.be.true; + expect(setLocalStorageStub.calledWith('cto_pixel_test', 'ok')).to.be.true; + }); + + it('should call sync pixels and use error handler', function () { + const expirationTs = new Date(nowTimestamp + cookiesMaxAge).toString(); + + const result = criteoIdSubmodule.getId(); + result.callback((id) => { + }); + + const response = { + pixels: [ + { + pixelUrl: 'pixelUrlWithBundle', + writeBundleInStorage: true, + bundlePropertyName: 'abc', + storageKeyName: 'cto_pixel_test' + } + ] + }; + + server.requests[0].respond( + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify(response) + ); + + server.requests[1].respond( + 500, + { 'Content-Type': 'application/json' }, + JSON.stringify({ + abc: 'ok' + }) + ); + + expect(triggerPixelStub.called).to.be.false; + expect(setCookieStub.calledWith('cto_pixel_test', 'ok', expirationTs, null, '.com')).to.be.false; + expect(setCookieStub.calledWith('cto_pixel_test', 'ok', expirationTs, null, '.testdev.com')).to.be.false; + expect(setLocalStorageStub.calledWith('cto_pixel_test', 'ok')).to.be.false; + }); + gdprConsentTestCases.forEach(testCase => it('should call user sync url with the gdprConsent', function () { let callBackSpy = sinon.spy(); - let result = criteoIdSubmodule.getId(undefined, testCase.consentData); + + gdprConsentDataStub.returns(testCase.consentData); + + let result = criteoIdSubmodule.getId(undefined); + result.callback(callBackSpy); + + let request = server.requests[0]; + + if (testCase.expectedGdprConsent) { + expect(request.url).to.have.string(`gdprString=${testCase.expectedGdprConsent}`); + } else { + expect(request.url).to.not.have.string('gdprString='); + } + + if (testCase.expectedGdpr) { + expect(request.url).to.have.string(`gdpr=${testCase.expectedGdpr}`); + } else { + expect(request.url).to.not.have.string('gdpr='); + } + + request.respond( + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify({}) + ); + + expect(callBackSpy.calledOnce).to.be.true; + })); + + [undefined, 'abc'].forEach(usPrivacy => it('should call user sync url with the us privacy string', function () { + let callBackSpy = sinon.spy(); + + uspConsentDataStub.returns(usPrivacy); + + let result = criteoIdSubmodule.getId(undefined); result.callback(callBackSpy); let request = server.requests[0]; - if (testCase.expected) { - expect(request.url).to.have.string(`gdprString=${testCase.expected}`); + + if (usPrivacy) { + expect(request.url).to.have.string(`us_privacy=${usPrivacy}`); + } else { + expect(request.url).to.not.have.string('us_privacy='); + } + + request.respond( + 200, + { 'Content-Type': 'application/json' }, + JSON.stringify({}) + ); + + expect(callBackSpy.calledOnce).to.be.true; + })); + + [ + { + consentData: { + gppString: 'abc', + applicableSections: [1] + }, + expectedGpp: 'abc', + expectedGppSid: '1' + }, + { + consentData: undefined, + expectedGpp: undefined, + expectedGppSid: undefined + } + ].forEach(testCase => it('should call user sync url with the gpp string', function () { + let callBackSpy = sinon.spy(); + + gppConsentDataStub.returns(testCase.consentData); + + let result = criteoIdSubmodule.getId(undefined); + result.callback(callBackSpy); + + let request = server.requests[0]; + + if (testCase.expectedGpp) { + expect(request.url).to.have.string(`gpp=${testCase.expectedGpp}`); + } else { + expect(request.url).to.not.have.string('gpp='); + } + + if (testCase.expectedGppSid) { + expect(request.url).to.have.string(`gpp_sid=${testCase.expectedGppSid}`); } else { - expect(request.url).to.not.have.string('gdprString'); + expect(request.url).to.not.have.string('gpp_sid='); } request.respond( 200, - {'Content-Type': 'application/json'}, + { 'Content-Type': 'application/json' }, JSON.stringify({}) ); diff --git a/test/spec/modules/currency_spec.js b/test/spec/modules/currency_spec.js index 928c252943c..f7c2580f3f3 100644 --- a/test/spec/modules/currency_spec.js +++ b/test/spec/modules/currency_spec.js @@ -14,6 +14,7 @@ import { } from 'modules/currency.js'; import {createBid} from '../../../src/bidfactory.js'; import CONSTANTS from '../../../src/constants.json'; +import {server} from '../../mocks/xhr.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -30,12 +31,11 @@ describe('currency', function () { } beforeEach(function () { - fakeCurrencyFileServer = sinon.fakeServer.create(); + fakeCurrencyFileServer = server; ready.reset(); }); afterEach(function () { - fakeCurrencyFileServer.restore(); setConfig({}); }); @@ -169,6 +169,28 @@ describe('currency', function () { expect(getGlobal().convertCurrency(1.0, 'USD', 'EUR')).to.equal(4); expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(200); }); + it('uses default rates until currency file is loaded', function () { + setConfig({ + adServerCurrency: 'USD', + defaultRates: { + USD: { + JPY: 100 + } + } + }); + + // Race condition where a bid is converted before the file has been loaded + expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(100); + + fakeCurrencyFileServer.respondWith(JSON.stringify({ + 'dataAsOf': '2017-04-25', + 'conversions': { + 'USD': { JPY: 200 } + } + })); + fakeCurrencyFileServer.respond(); + expect(getGlobal().convertCurrency(1.0, 'USD', 'JPY')).to.equal(200); + }); }); describe('bidder override', function () { it('allows setConfig to set bidder currency', function () { @@ -329,6 +351,11 @@ describe('currency', function () { }); describe('currency.addBidResponseDecorator', function () { + let reject; + beforeEach(() => { + reject = sinon.stub().returns({status: 'rejected'}); + }); + it('should leave bid at 1 when currency support is not enabled and fromCurrency is USD', function () { setConfig({}); var bid = makeBid({ 'cpm': 1, 'currency': 'USD' }); @@ -339,15 +366,16 @@ describe('currency', function () { expect(innerBid.cpm).to.equal(1); }); - it('should result in NO_BID when currency support is not enabled and fromCurrency is not USD', function () { + it('should reject bid when currency support is not enabled and fromCurrency is not USD', function () { setConfig({}); var bid = makeBid({ 'cpm': 1, 'currency': 'GBP' }); - var innerBid; + let bidAdded = false; addBidResponseHook(function(adCodeId, bid) { - innerBid = bid; - }, 'elementId', bid); - expect(innerBid.statusMessage).to.equal('Bid returned empty or error response'); + bidAdded = true; + }, 'elementId', bid, reject); + expect(bidAdded).to.be.false; + expect(reject.calledOnce).to.be.true; }); it('should not buffer bid when currency is already in desired currency', function () { @@ -362,7 +390,7 @@ describe('currency', function () { expect(bid).to.equal(innerBid); }); - it('should result in NO_BID when fromCurrency is not supported in file', function () { + it('should reject bid when fromCurrency is not supported in file', function () { // RESET to request currency file setConfig({ 'adServerCurrency': undefined }); @@ -370,23 +398,25 @@ describe('currency', function () { setConfig({ 'adServerCurrency': 'JPY' }); fakeCurrencyFileServer.respond(); var bid = makeBid({ 'cpm': 1, 'currency': 'ABC' }); - var innerBid; + let bidAdded = false; addBidResponseHook(function(adCodeId, bid) { - innerBid = bid; - }, 'elementId', bid); - expect(innerBid.statusMessage).to.equal('Bid returned empty or error response'); + bidAdded = true; + }, 'elementId', bid, reject); + expect(bidAdded).to.be.false; + expect(reject.calledOnce).to.be.true; }); - it('should result in NO_BID when adServerCurrency is not supported in file', function () { + it('should reject bid when adServerCurrency is not supported in file', function () { fakeCurrencyFileServer.respondWith(JSON.stringify(getCurrencyRates())); setConfig({ 'adServerCurrency': 'ABC' }); fakeCurrencyFileServer.respond(); var bid = makeBid({ 'cpm': 1, 'currency': 'GBP' }); - var innerBid; + let bidAdded = false; addBidResponseHook(function(adCodeId, bid) { - innerBid = bid; - }, 'elementId', bid); - expect(innerBid.statusMessage).to.equal('Bid returned empty or error response'); + bidAdded = true; + }, 'elementId', bid, reject); + expect(bidAdded).to.be.false; + expect(reject.calledOnce).to.be.true; }); it('should return 1 when currency support is enabled and same currency code is requested as is set to adServerCurrency', function () { diff --git a/test/spec/modules/cwireBidAdapter_spec.js b/test/spec/modules/cwireBidAdapter_spec.js index b21e73e1561..8eedcdb4a07 100644 --- a/test/spec/modules/cwireBidAdapter_spec.js +++ b/test/spec/modules/cwireBidAdapter_spec.js @@ -1,369 +1,343 @@ -import { expect } from 'chai'; -import * as utils from '../../../src/utils.js'; -import { config } from '../../../src/config.js'; -import { - spec, - CW_PAGE_VIEW_ID, - ENDPOINT_URL, - RENDERER_URL, -} from '../../../modules/cwireBidAdapter.js'; -import * as prebidGlobal from 'src/prebidGlobal.js'; - -// ------------------------------------ -// Bid Request Builder -// ------------------------------------ - -const BID_DEFAULTS = { - request: { - bidder: 'cwire', - auctionId: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee', - transactionId: 'txaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee', - bidId: 'bid123445', - bidderRequestId: 'brid12345', - code: 'original-div', - }, - params: { - placementId: 123456, - pageId: 777, - }, - sizes: [[300, 250], [1, 1]], -}; - -const BidderRequestBuilder = function BidderRequestBuilder(options) { - const defaults = { - bidderCode: 'cwire', - auctionId: BID_DEFAULTS.request.auctionId, - bidderRequestId: BID_DEFAULTS.request.bidderRequestId, - transactionId: BID_DEFAULTS.request.transactionId, - timeout: 3000, - }; - - const request = { - ...defaults, - ...options - }; - - this.build = () => request; -}; - -const BidRequestBuilder = function BidRequestBuilder(options, deleteKeys) { - const defaults = JSON.parse(JSON.stringify(BID_DEFAULTS)); - - const request = { - ...defaults.request, - ...options - }; - - if (request && utils.isArray(deleteKeys)) { - deleteKeys.forEach((k) => { - delete request[k]; - }) - } +import {expect} from 'chai'; +import {newBidder} from '../../../src/adapters/bidderFactory'; +import {BID_ENDPOINT, spec, storage} from '../../../modules/cwireBidAdapter'; +import {deepClone, logInfo} from '../../../src/utils'; +import * as utils from 'src/utils.js'; +import {sandbox, stub} from 'sinon'; +import {config} from '../../../src/config'; - this.withParams = (options, deleteKeys) => { - request.params = { - ...defaults.params, - ...options - }; - if (request && utils.isArray(deleteKeys)) { - deleteKeys.forEach((k) => { - delete request.params[k]; - }) +describe('C-WIRE bid adapter', () => { + config.setConfig({debug: true}); + const adapter = newBidder(spec); + let bidRequests = [ + { + 'bidder': 'cwire', + 'params': { + 'pageId': '4057', + 'placementId': 'ad-slot-bla' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '04f2659e-c005-4eb1-a57c-fa93145e3843' } - return this; - }; - - this.build = () => request; -}; + ]; + const response = { + body: { + 'cwid': '2ef90743-7936-4a82-8acf-e73382a64e94', + 'hash': '17112D98BBF55D3A', + 'bids': [{ + 'html': '

Hello world

', + 'cpm': 100, + 'currency': 'CHF', + 'dimensions': [1, 1], + 'netRevenue': true, + 'creativeId': '3454', + 'requestId': '2c634d4ca5ccfb', + 'placementId': 177, + 'transactionId': 'b4b32618-1350-4828-b6f0-fbb5c329e9a4', + 'ttl': 360 + }] + } + } + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + expect(spec.isBidRequestValid).to.exist.and.to.be.a('function'); + expect(spec.buildRequests).to.exist.and.to.be.a('function'); + expect(spec.interpretResponse).to.exist.and.to.be.a('function'); + }); + }); + describe('buildRequests', function () { + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests); + expect(request.url).to.equal(BID_ENDPOINT); + expect(request.method).to.equal('POST'); + }); + }); + describe('buildRequests with given creative', function () { + let utilsStub; -describe('C-WIRE bid adapter', () => { - let sandbox; + before(function () { + utilsStub = stub(utils, 'getParameterByName').callsFake(function () { + return 'str-str' + }); + }); - beforeEach(() => { - sandbox = sinon.createSandbox(); - }); + after(function () { + utilsStub.restore(); + }); - afterEach(() => { - sandbox.restore(); - config.resetConfig(); - }); + it('should add creativeId if url parameter given', function () { + // set from bid.params + let bidRequest = deepClone(bidRequests[0]); - // START TESTING - describe('C-WIRE - isBidRequestValid', function () { - it('should return true when required params found', function () { - const bid01 = new BidRequestBuilder().withParams().build(); - expect(spec.isBidRequestValid(bid01)).to.equal(true); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + expect(payload.cwcreative).to.exist; + expect(payload.cwcreative).to.deep.equal('str-str'); }); + }) + + describe('buildRequests reads adUnit offsetWidth and offsetHeight', function () { + before(function () { + const documentStub = sandbox.stub(document, 'getElementById'); + documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({ + offsetWidth: 200, + offsetHeight: 250 + }); + }); + it('width and height should be set', function () { + let bidRequest = deepClone(bidRequests[0]); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + const el = document.getElementById(`${bidRequest.adUnitCode}`) + + logInfo(JSON.stringify(payload)) - it('should fail if there is no placementId', function () { - const bid01 = new BidRequestBuilder().withParams().build(); - delete bid01.params.placementId - expect(spec.isBidRequestValid(bid01)).to.equal(false); + expect(el).to.exist; + expect(payload.slots[0].cwExt.dimensions.width).to.equal(200); + expect(payload.slots[0].cwExt.dimensions.height).to.equal(250); + expect(payload.slots[0].cwExt.style.maxHeight).to.not.exist; + expect(payload.slots[0].cwExt.style.maxWidth).to.not.exist; }); + after(function () { + sandbox.restore() + }); + }); + describe('buildRequests reads style attributes', function () { + before(function () { + const documentStub = sandbox.stub(document, 'getElementById'); + documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({ + style: { + maxWidth: '400px', + maxHeight: '350px', + } + }); + }); + it('css maxWidth should be set', function () { + let bidRequest = deepClone(bidRequests[0]); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + const el = document.getElementById(`${bidRequest.adUnitCode}`) - it('should fail if invalid placementId type', function () { - const bid01 = new BidRequestBuilder().withParams().build(); - delete bid01.params.placementId; - bid01.placementId = '322'; - expect(spec.isBidRequestValid(bid01)).to.equal(false); + logInfo(JSON.stringify(payload)) + + expect(el).to.exist; + expect(payload.slots[0].cwExt.style.maxWidth).to.eq('400px'); + !expect(payload.slots[0].cwExt.style.maxHeight).to.eq('350px'); + }); + after(function () { + sandbox.restore() }); + }); - it('should fail if there is no pageId', function () { - const bid01 = new BidRequestBuilder().withParams().build(); - delete bid01.params.pageId - expect(spec.isBidRequestValid(bid01)).to.equal(false); + describe('buildRequests reads feature flags', function () { + before(function () { + sandbox.stub(utils, 'getParameterByName').callsFake(function () { + return 'feature1,feature2' + }); }); - it('should fail if invalid pageId type', function () { - const bid01 = new BidRequestBuilder().withParams().build(); - delete bid01.params.pageId; - bid01.params.pageId = '3320'; - expect(spec.isBidRequestValid(bid01)).to.equal(false); + it('read from url parameter', function () { + let bidRequest = deepClone(bidRequests[0]); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + logInfo(JSON.stringify(payload)) + + expect(payload.featureFlags).to.exist; + expect(payload.featureFlags).to.include.members(['feature1', 'feature2']); + }); + after(function () { + sandbox.restore() }); }); - describe('C-WIRE - buildRequests()', function () { - it('creates a valid request', function () { - const bid01 = new BidRequestBuilder({ - mediaTypes: { - banner: { - sizes: [[1, 1]], - } - } - }).withParams({ - cwcreative: 54321, - cwapikey: 'xxx-xxx-yyy-zzz-uuid', - refgroups: 'group_1', - }).build(); - - const bidderRequest01 = new BidderRequestBuilder().build(); - - const requests = spec.buildRequests([bid01], bidderRequest01); - - expect(requests.data.slots.length).to.equal(1); - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwid).to.be.null; - expect(requests.data.slots[0].sizes[0]).to.equal('1x1'); - expect(requests.data.cwcreative).to.equal(54321); - expect(requests.data.cwapikey).to.equal('xxx-xxx-yyy-zzz-uuid'); - expect(requests.data.refgroups[0]).to.equal('group_1'); + describe('buildRequests reads cwgroups flag', function () { + before(function () { + sandbox.stub(utils, 'getParameterByName').callsFake(function () { + return 'group1,group2' + }); }); - it('creates a valid request - read debug params from second bid', function () { - const bid01 = new BidRequestBuilder().withParams().build(); + it('read from url parameter', function () { + let bidRequest = deepClone(bidRequests[0]); - const bid02 = new BidRequestBuilder({ - mediaTypes: { - banner: { - sizes: [[1, 1]], - } - } - }).withParams({ - cwcreative: 1234, - cwapikey: 'api_key_5', - refgroups: 'group_5', - }).build(); - - const bidderRequest01 = new BidderRequestBuilder().build(); - - const requests = spec.buildRequests([bid01, bid02], bidderRequest01); - - expect(requests.data.slots.length).to.equal(2); - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwcreative).to.equal(1234); - expect(requests.data.cwapikey).to.equal('api_key_5'); - expect(requests.data.refgroups[0]).to.equal('group_5'); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + logInfo(JSON.stringify(payload)) + + expect(payload.refgroups).to.exist; + expect(payload.refgroups).to.include.members(['group1', 'group2']); + }); + after(function () { + sandbox.restore() }); + }) + + describe('buildRequests reads debug flag', function () { + before(function () { + sandbox.stub(utils, 'getParameterByName').callsFake(function () { + return 'true' + }); + }); + + it('read from url parameter', function () { + let bidRequest = deepClone(bidRequests[0]); - it('creates a valid request - read debug params from first bid, ignore second', function () { - const bid01 = new BidRequestBuilder() - .withParams({ - cwcreative: 33, - cwapikey: 'api_key_33', - refgroups: 'group_33', - }).build(); - - const bid02 = new BidRequestBuilder() - .withParams({ - cwcreative: 1234, - cwapikey: 'api_key_5', - refgroups: 'group_5', - }).build(); - - const bidderRequest01 = new BidderRequestBuilder().build(); - - const requests = spec.buildRequests([bid01, bid02], bidderRequest01); - - expect(requests.data.slots.length).to.equal(2); - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwcreative).to.equal(33); - expect(requests.data.cwapikey).to.equal('api_key_33'); - expect(requests.data.refgroups[0]).to.equal('group_33'); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + logInfo(JSON.stringify(payload)) + + expect(payload.debug).to.exist; + expect(payload.debug).to.equal(true); + }); + after(function () { + sandbox.restore() }); + }) - it('creates a valid request - read debug params from 3 different slots', function () { - const bid01 = new BidRequestBuilder() - .withParams({ - cwcreative: 33, - }).build(); - - const bid02 = new BidRequestBuilder() - .withParams({ - cwapikey: 'api_key_5', - }).build(); - - const bid03 = new BidRequestBuilder() - .withParams({ - refgroups: 'group_5', - }).build(); - const bidderRequest01 = new BidderRequestBuilder().build(); - - const requests = spec.buildRequests([bid01, bid02, bid03], bidderRequest01); - - expect(requests.data.slots.length).to.equal(3); - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwcreative).to.equal(33); - expect(requests.data.cwapikey).to.equal('api_key_5'); - expect(requests.data.refgroups[0]).to.equal('group_5'); + describe('buildRequests reads cw_id from Localstorage', function () { + before(function () { + sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); + sandbox.stub(storage, 'setDataInLocalStorage'); + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => 'taerfagerg'); }); - it('creates a valid request - config is overriden by URL params', function () { - // for whatever reason stub for getWindowLocation does not work - // so this was the closest way to test for get params - const params = sandbox.stub(utils, 'getParameterByName'); - params.withArgs('cwgroups').returns('group_2'); - params.withArgs('cwcreative').returns('654321'); - - const bid01 = new BidRequestBuilder({ - mediaTypes: { - banner: { - sizes: [[1, 1]], - } - } - }).withParams({ - cwcreative: 54321, - cwapikey: 'xxx-xxx-yyy-zzz', - refgroups: 'group_1', - }).build(); - - const bidderRequest01 = new BidderRequestBuilder().build(); - - const requests = spec.buildRequests([bid01], bidderRequest01); - - expect(requests.data.slots.length).to.equal(1); - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwid).to.be.null; - expect(requests.data.slots[0].sizes[0]).to.equal('1x1'); - expect(requests.data.cwcreative).to.equal(654321); - expect(requests.data.cwapikey).to.equal('xxx-xxx-yyy-zzz'); - expect(requests.data.refgroups[0]).to.equal('group_2'); + it('cw_id is set', function () { + let bidRequest = deepClone(bidRequests[0]); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + logInfo(JSON.stringify(payload)) + + expect(payload.cwid).to.exist; + expect(payload.cwid).to.equal('taerfagerg'); + }); + after(function () { + sandbox.restore() }); + }) - it('creates a valid request - if params are not set, null or empty array are sent to the API', function () { - const bid01 = new BidRequestBuilder({ - mediaTypes: { - banner: { - sizes: [[1, 1]], - } - } - }).withParams().build(); + describe('buildRequests maps flattens params for legacy compat', function () { + before(function () { + const documentStub = sandbox.stub(document, 'getElementById'); + documentStub.withArgs(`${bidRequests[0].adUnitCode}`).returns({}); + }); + it('pageId flattened', function () { + let bidRequest = deepClone(bidRequests[0]); - const bidderRequest01 = new BidderRequestBuilder().build(); + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); - const requests = spec.buildRequests([bid01], bidderRequest01); + logInfo(JSON.stringify(payload)) - expect(requests.data.slots.length).to.equal(1); - expect(requests.data.cwid).to.be.null; - expect(requests.data.cwid).to.be.null; - expect(requests.data.slots[0].sizes[0]).to.equal('1x1'); - expect(requests.data.cwcreative).to.equal(null); - expect(requests.data.cwapikey).to.equal(null); - expect(requests.data.refgroups.length).to.equal(0); + expect(payload.slots[0].pageId).to.exist; + }); + after(function () { + sandbox.restore() }); + }) + + describe('pageId and placementId are required params', function () { + it('invalid request', function () { + let bidRequest = deepClone(bidRequests[0]); + delete bidRequest.params + + const valid = spec.isBidRequestValid(bidRequest); + expect(valid).to.be.false; + }) + + it('valid request', function () { + let bidRequest = deepClone(bidRequests[0]); + bidRequest.params.pageId = 42 + bidRequest.params.placementId = 42 + + const valid = spec.isBidRequestValid(bidRequest); + expect(valid).to.be.true; + }) + + it('cwcreative must be of type string', function () { + let bidRequest = deepClone(bidRequests[0]); + bidRequest.params.pageId = 42 + bidRequest.params.placementId = 42 + + const valid = spec.isBidRequestValid(bidRequest); + expect(valid).to.be.true; + }) + + it('build request adds pageId', function () { + let bidRequest = deepClone(bidRequests[0]); + + const request = spec.buildRequests([bidRequest]); + const payload = JSON.parse(request.data); + + expect(payload.slots[0].pageId).to.exist; + }) }); - describe('C-WIRE - interpretResponse()', function () { - const serverResponse = { - body: { - bids: [{ - html: '

AD CONTENT

', - currency: 'CHF', - cpm: 43.37, - dimensions: [1, 1], - netRevenue: true, - creativeId: '1337', - requestId: BID_DEFAULTS.request.bidId, - ttl: 3500, - }], - } - }; - - const expectedResponse = [{ - ad: JSON.parse(JSON.stringify(serverResponse.body.bids[0].html)), - bidderCode: BID_DEFAULTS.request.bidder, - cpm: JSON.parse(JSON.stringify(serverResponse.body.bids[0].cpm)), - creativeId: JSON.parse(JSON.stringify(serverResponse.body.bids[0].creativeId)), - currency: JSON.parse(JSON.stringify(serverResponse.body.bids[0].currency)), - height: JSON.parse(JSON.stringify(serverResponse.body.bids[0].dimensions[0])), - width: JSON.parse(JSON.stringify(serverResponse.body.bids[0].dimensions[1])), - netRevenue: JSON.parse(JSON.stringify(serverResponse.body.bids[0].netRevenue)), - requestId: JSON.parse(JSON.stringify(serverResponse.body.bids[0].requestId)), - ttl: JSON.parse(JSON.stringify(serverResponse.body.bids[0].ttl)), - meta: { - advertiserDomains: [], - }, - mediaType: 'banner', - }] - - it('correctly parses response', function () { - const bid01 = new BidRequestBuilder({ - mediaTypes: { - banner: { - sizes: [[1, 1]], - } - } - }).withParams().build(); + describe('process serverResponse', function () { + it('html to ad mapping', function () { + let bidResponse = deepClone(response); + const bids = spec.interpretResponse(bidResponse, {}); - const bidderRequest01 = new BidderRequestBuilder().build(); - const requests = spec.buildRequests([bid01], bidderRequest01); + expect(bids[0].ad).to.exist; + }) + }); - const response = spec.interpretResponse(serverResponse, requests); - expect(response).to.deep.equal(expectedResponse); - }); + describe('add user-syncs', function () { + it('empty user-syncs if no consent given', function () { + const userSyncs = spec.getUserSyncs({}, {}, {}, {}); - it('attaches renderer', function () { - const bid01 = new BidRequestBuilder({ - mediaTypes: { - video: { - playerSize: [[640, 480]], - context: 'outstream', + expect(userSyncs).to.be.empty + }) + it('empty user-syncs if no syncOption enabled', function () { + let gdprConsent = { + vendorData: { + purpose: { + consents: 1 } - } - }).withParams().build(); - const bidderRequest01 = new BidderRequestBuilder().build(); + }}; + const userSyncs = spec.getUserSyncs({}, {}, gdprConsent, {}); - const _serverResponse = utils.deepClone(serverResponse); - _serverResponse.body.bids[0].vastXml = ''; + expect(userSyncs).to.be.empty + }) - const _expectedResponse = utils.deepClone(expectedResponse); - _expectedResponse[0].mediaType = 'video'; - _expectedResponse[0].videoScript = JSON.parse(JSON.stringify(_serverResponse.body.bids[0].html)); - _expectedResponse[0].vastXml = JSON.parse(JSON.stringify(_serverResponse.body.bids[0].vastXml)); - delete _expectedResponse[0].ad; + it('user-syncs with enabled pixel option', function () { + let gdprConsent = { + vendorData: { + purpose: { + consents: 1 + } + }}; + let synOptions = {pixelEnabled: true, iframeEnabled: true}; + const userSyncs = spec.getUserSyncs(synOptions, {}, gdprConsent, {}); - const requests = spec.buildRequests([bid01], bidderRequest01); - expect(requests.data.slots[0].sizes).to.deep.equal(['640x480']); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ib.adnxs.com/getuid?https://prebid.cwi.re/v1/cookiesync?xandrId=$UID'); + }) - const response = spec.interpretResponse(_serverResponse, requests); - expect(response[0].renderer).to.exist; - expect(response[0].renderer.url).to.equals(RENDERER_URL); - expect(response[0].renderer.loaded).to.equals(false); + it('user-syncs with enabled iframe option', function () { + let gdprConsent = { + vendorData: { + purpose: { + consents: 1 + } + }}; + let synOptions = {iframeEnabled: true}; + const userSyncs = spec.getUserSyncs(synOptions, {}, gdprConsent, {}); - delete response[0].renderer; - expect(response).to.deep.equal(_expectedResponse); - }); - }); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ib.adnxs.com/getuid?https://prebid.cwi.re/v1/cookiesync?xandrId=$UID'); + }) + }) }); diff --git a/test/spec/modules/dacIdSystem_spec.js b/test/spec/modules/dacIdSystem_spec.js index d78b4a69000..0246e65a310 100644 --- a/test/spec/modules/dacIdSystem_spec.js +++ b/test/spec/modules/dacIdSystem_spec.js @@ -1,8 +1,16 @@ -import { dacIdSystemSubmodule, storage, cookieKey } from 'modules/dacIdSystem.js'; +import { + dacIdSystemSubmodule, + storage, + FUUID_COOKIE_NAME, + AONEID_COOKIE_NAME +} from 'modules/dacIdSystem.js'; +import { server } from 'test/mocks/xhr.js'; -const DACID_DUMMY_VALUE = 'dacIdTest'; +const FUUID_DUMMY_VALUE = 'dacIdTest'; +const AONEID_DUMMY_VALUE = '12345' const DACID_DUMMY_OBJ = { - dacId: DACID_DUMMY_VALUE + fuuid: FUUID_DUMMY_VALUE, + uid: AONEID_DUMMY_VALUE }; describe('dacId module', function () { @@ -23,24 +31,98 @@ describe('dacId module', function () { '' ] + const configParamTestCase = { + params: { + oid: [ + '637c1b6fc26bfad0', // valid + 'e8316b39c08029e1' // invalid + ] + } + } + describe('getId()', function () { - it('should return the uid when it exists in cookie', function () { - getCookieStub.withArgs(cookieKey).returns(DACID_DUMMY_VALUE); + it('should return undefined when oid & fuuid not exist', function () { + // no oid, no fuuid const id = dacIdSystemSubmodule.getId(); - expect(id).to.be.deep.equal({id: {dacId: DACID_DUMMY_VALUE}}); + expect(id).to.equal(undefined); }); - cookieTestCasesForEmpty.forEach(testCase => it('should return the uid when it not exists in cookie', function () { - getCookieStub.withArgs(cookieKey).returns(testCase); + it('should return fuuid when oid not exists but fuuid exists', function () { + // no oid, fuuid + getCookieStub.withArgs(FUUID_COOKIE_NAME).returns(FUUID_DUMMY_VALUE); const id = dacIdSystemSubmodule.getId(); - expect(id).to.be.deep.equal(undefined); + expect(id).to.be.deep.equal({ + id: { + fuuid: FUUID_DUMMY_VALUE, + uid: undefined + } + }); + }); + + it('should return fuuid when oid is invalid but fuuid exists', function () { + // invalid oid, fuuid, no AoneId + getCookieStub.withArgs(FUUID_COOKIE_NAME).returns(FUUID_DUMMY_VALUE); + const id = dacIdSystemSubmodule.getId(configParamTestCase.params.oid[1]); + expect(id).to.be.deep.equal({ + id: { + fuuid: FUUID_DUMMY_VALUE, + uid: undefined + } + }); + }); + + cookieTestCasesForEmpty.forEach(testCase => it('should return undefined when fuuid not exists', function () { + // valid oid, no fuuid, no AoneId + getCookieStub.withArgs(FUUID_COOKIE_NAME).returns(testCase); + const id = dacIdSystemSubmodule.getId(configParamTestCase.params.oid[0]); + expect(id).to.equal(undefined); })); + + it('should return AoneId when AoneId not exists', function () { + // valid oid, fuuid, no AoneId + getCookieStub.withArgs(FUUID_COOKIE_NAME).returns(FUUID_DUMMY_VALUE); + const callbackSpy = sinon.spy(); + const callback = dacIdSystemSubmodule.getId({params: {oid: configParamTestCase.params.oid[0]}}).callback; + callback(callbackSpy); + const request = server.requests[0]; + request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({'uid': AONEID_DUMMY_VALUE})); + expect(callbackSpy.lastCall.lastArg).to.deep.equal({fuuid: 'dacIdTest', uid: AONEID_DUMMY_VALUE}); + }); + + cookieTestCasesForEmpty.forEach(testCase => it('should return undefined when AoneId not exists & API result is empty', function () { + // valid oid, fuuid, no AoneId, API result empty + getCookieStub.withArgs(FUUID_COOKIE_NAME).returns(FUUID_DUMMY_VALUE); + const callbackSpy = sinon.spy(); + const callback = dacIdSystemSubmodule.getId({params: {oid: configParamTestCase.params.oid[0]}}).callback; + callback(callbackSpy); + const request = server.requests[0]; + request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({'uid': testCase})); + expect(callbackSpy.lastCall.lastArg).to.deep.equal({fuuid: 'dacIdTest', uid: undefined}); + })); + + it('should return the fuuid & AoneId when they exist', function () { + // valid oid, fuuid, AoneId + getCookieStub.withArgs(FUUID_COOKIE_NAME).returns(FUUID_DUMMY_VALUE); + getCookieStub.withArgs(AONEID_COOKIE_NAME).returns(AONEID_DUMMY_VALUE); + const id = dacIdSystemSubmodule.getId(configParamTestCase.params.oid[0]); + expect(id).to.be.deep.equal({ + id: { + fuuid: FUUID_DUMMY_VALUE, + uid: AONEID_DUMMY_VALUE + } + }); + }); }); describe('decode()', function () { - it('should return the uid when it exists in cookie', function () { + it('should return fuuid & AoneId when they exist', function () { const decoded = dacIdSystemSubmodule.decode(DACID_DUMMY_OBJ); - expect(decoded).to.be.deep.equal({dacId: {id: DACID_DUMMY_VALUE}}); + expect(decoded).to.be.deep.equal({ + dacId: { + fuuid: FUUID_DUMMY_VALUE, + id: AONEID_DUMMY_VALUE + } + }); }); it('should return the undefined when decode id is not "string"', function () { diff --git a/test/spec/modules/dataController_spec.js b/test/spec/modules/dataController_spec.js new file mode 100644 index 00000000000..25f55047377 --- /dev/null +++ b/test/spec/modules/dataController_spec.js @@ -0,0 +1,210 @@ +import {expect} from 'chai'; +import {config} from 'src/config.js'; +import {filterBidData, init} from 'modules/dataControllerModule/index.js'; +import {startAuction} from 'src/prebid.js'; + +describe('data controller', function () { + let spyFn; + + beforeEach(function () { + spyFn = sinon.spy(); + }); + + afterEach(function () { + config.resetConfig(); + }); + + describe('data controller', function () { + let result; + let callbackFn; + let req; + + beforeEach(function () { + init(); + result = null; + req = { + 'adUnits': [{ + 'bids': [ + { + 'bidder': 'ix', + 'userId': { + 'id5id': { + 'uid': 'ID5*19RudTU8mWiRdKfG-0E9oyyJCdbgb8MvcaEtPAxM29QZYT5DW9r01vBozMD93UZy', + 'ext': { + 'linkType': 2 + } + } + }, + 'userIdAsEids': [ + { + 'source': 'id5-sync.com', + 'uids': [ + { + 'id': 'ID5*UJzjz7J0FNIWPCp8fAmwGavBhGxnJ06V9umghosEVm4ZPjpn2iWahAoiPal59yKa', + 'atype': 1, + 'ext': { + 'linkType': 2 + } + } + ] + } + ], + + } + ] + }], + 'ortb2Fragments': { + 'bidder': { + 'ix': { + 'user': { + 'data': [ + { + 'name': 'permutive.com', + 'ext': { + 'segtax': 4 + }, + 'segment': [ + { + 'id': '777777' + }, + { + 'id': '888888' + } + ] + } + ] + } + } + } + } + }; + callbackFn = function (request) { + result = request; + }; + }); + + afterEach(function () { + config.resetConfig(); + startAuction.getHooks({hook: filterBidData}).remove(); + }); + + it('filterEIDwhenSDA for All SDA ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterEIDwhenSDA: ['*'] + } + }; + config.setConfig(dataControllerConfiguration); + filterBidData(callbackFn, req); + expect(req.adUnits[0].bids[0].userIdAsEids).that.is.empty; + expect(req.adUnits[0].bids[0].userId).that.is.empty; + expect(req.ortb2Fragments.bidder.ix.user.ext.eids).that.is.empty; + expect(req.ortb2Fragments.global.user.ext.eids).that.is.empty; + }); + + it('filterEIDwhenSDA for available SAD permutive.com:4:777777 ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterEIDwhenSDA: ['permutive.com:4:777777'] + } + + }; + config.setConfig(dataControllerConfiguration); + filterBidData(callbackFn, req); + expect(req.adUnits[0].bids[0].userIdAsEids).that.is.empty; + expect(req.adUnits[0].bids[0].userId).that.is.empty; + + expect(req.ortb2Fragments.bidder.ix.user.ext.eids).that.is.empty; + expect(req.ortb2Fragments.global.user.ext.eids).that.is.empty; + }); + + it('filterEIDwhenSDA for unavailable SAD test.com:4:9999 ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterEIDwhenSDA: ['test.com:4:99999'] + } + }; + config.setConfig(dataControllerConfiguration); + filterBidData(callbackFn, req); + expect(req.adUnits[0].bids[0].userIdAsEids).that.is.not.empty; + expect(req.adUnits[0].bids[0].userId).that.is.not.empty; + }); + // Test for global + it('filterEIDwhenSDA for available global SAD test.com:4:777777 ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterEIDwhenSDA: ['test.com:5:11111'] + } + + }; + config.setConfig(dataControllerConfiguration); + let globalObject = { + 'ortb2Fragments': { + 'global': { + 'user': { + 'yob': 1985, + 'gender': 'm', + 'keywords': 'a,b', + 'data': [ + { + 'name': 'test.com', + 'ext': { + 'segtax': 5 + }, + 'segment': [ + { + 'id': '11111' + }, + { + 'id': '22222' + } + ] + } + ] + } + } + } + }; + let globalRequest = Object.assign({}, req, globalObject); + filterBidData(callbackFn, globalRequest); + expect(globalRequest.adUnits[0].bids[0].userIdAsEids).that.is.empty; + expect(globalRequest.adUnits[0].bids[0].userId).that.is.empty; + }); + + it('filterSDAwhenEID for id5-sync.com EID ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterSDAwhenEID: ['id5-sync.com'] + } + }; + config.setConfig(dataControllerConfiguration); + filterBidData(callbackFn, req); + expect(req.ortb2Fragments.bidder.ix.user.data).that.is.empty; + }); + + it('filterSDAwhenEID for All EID ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterSDAwhenEID: ['*'] + } + }; + config.setConfig(dataControllerConfiguration); + + filterBidData(callbackFn, req); + expect(req.ortb2Fragments.bidder.ix.user.data).that.is.empty; + expect(req.ortb2Fragments.global.user.data).that.is.empty; + }); + + it('filterSDAwhenEID for unavailable source test-sync.com EID ', function () { + let dataControllerConfiguration = { + 'dataController': { + filterSDAwhenEID: ['test-sync.com'] + } + }; + config.setConfig(dataControllerConfiguration); + filterBidData(callbackFn, req); + expect(req.ortb2Fragments.bidder.ix.user.data).that.is.not.empty; + }); + } + ); +}); diff --git a/test/spec/modules/datablocksBidAdapter_spec.js b/test/spec/modules/datablocksBidAdapter_spec.js index ff7b0aad48c..811aaab6ebb 100644 --- a/test/spec/modules/datablocksBidAdapter_spec.js +++ b/test/spec/modules/datablocksBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import { spec } from '../../../modules/datablocksBidAdapter.js'; import { BotClientTests } from '../../../modules/datablocksBidAdapter.js'; import { getStorageManager } from '../../../src/storageManager.js'; -export let storage = getStorageManager(); +import {deepClone} from '../../../src/utils.js'; const bid = { bidId: '2dd581a2b6281d', @@ -305,6 +305,15 @@ let bid_request = { } describe('DatablocksAdapter', function() { + before(() => { + // stub out queue metric to avoid it polluting the global xhr mock during other tests + sinon.stub(spec, 'queue_metric').callsFake(() => null); + }); + + after(() => { + spec.queue_metric.restore(); + }); + describe('All needed functions are available', function() { it(`isBidRequestValid is present and type function`, function () { expect(spec.isBidRequestValid).to.exist.and.to.be.a('function') @@ -377,14 +386,6 @@ describe('DatablocksAdapter', function() { }); }) - describe('queue / send metrics', function() { - it('Should return true', function() { - expect(spec.queue_metric({type: 'test'})).to.be.true; - expect(spec.queue_metric('string')).to.be.false; - expect(spec.send_metrics()).to.be.true; - }); - }) - describe('get_viewability', function() { it('Should return undefined', function() { expect(spec.get_viewability()).to.equal(undefined); @@ -409,7 +410,7 @@ describe('DatablocksAdapter', function() { expect(spec.isBidRequestValid(bid)).to.be.true; }); it('Should return false when host/source_id is not set', function() { - let moddedBid = Object.assign({}, bid); + let moddedBid = deepClone(bid); delete moddedBid.params.source_id; expect(spec.isBidRequestValid(moddedBid)).to.be.false; }); @@ -442,9 +443,12 @@ describe('DatablocksAdapter', function() { }); describe('buildRequests', function() { - let request = spec.buildRequests([bid, bid2, nativeBid], bidderRequest); + let request; + before(() => { + request = spec.buildRequests([bid, bid2, nativeBid], bidderRequest); + expect(request).to.exist; + }) - expect(request).to.exist; it('Returns POST method', function() { expect(request.method).to.exist; expect(request.method).to.equal('POST'); diff --git a/test/spec/modules/datawrkzBidAdapter_spec.js b/test/spec/modules/datawrkzBidAdapter_spec.js new file mode 100644 index 00000000000..5524e318600 --- /dev/null +++ b/test/spec/modules/datawrkzBidAdapter_spec.js @@ -0,0 +1,652 @@ +import { expect } from 'chai'; +import { config } from 'src/config.js'; +import { spec } from 'modules/datawrkzBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'datawrkz'; +const ENDPOINT_URL = 'https://at.datawrkz.com/exchange/openrtb23/'; +const SITE_ID = 'site_id'; +const FINAL_URL = ENDPOINT_URL + SITE_ID + '?hb=1'; + +describe('datawrkzAdapterTests', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidder': BIDDER_CODE, + 'params': { + 'site_id': SITE_ID, + 'bidfloor': '1.0' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when params not found', function () { + let bid = Object.assign({}, bid); + delete bid.params; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when required site_id param not found', function () { + let bid = Object.assign({}, bid); + bid.params = {'bidfloor': '1.0'} + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when adunit is adpod video', function () { + let bid = Object.assign({}, bid); + bid.params = {'bidfloor': '1.0', 'site_id': SITE_ID}; + bid.mediaTypes = { + 'video': { + 'context': 'adpod' + } + } + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const consentString = '1YA-'; + const bidderRequest = { + 'bidderCode': 'datawrkz', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'uspConsent': consentString, + 'gdprConsent': {'gdprApplies': true}, + }; + const bannerBidRequests = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const bannerBidRequestsSingleArraySlotAndDeals = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]}, + 'mediaTypes': {'banner': {}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'sizes': [300, 250], + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const nativeBidRequests = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'native': { + 'title': {'required': true, 'len': 80}, + 'image': {'required': true, 'sizes': [[300, 250]]}, + 'icon': {'required': true, 'sizes': [[50, 50]]}, + 'sponsoredBy': {'required': true}, + 'cta': {'required': true}, + 'body': {'required': true, 'len': 100} + }}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const nativeBidRequestsSingleArraySlotAndDeals = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]}, + 'mediaTypes': {'native': { + 'title': {'len': 80}, + 'image': {'sizes': [300, 250]}, + 'icon': {'sizes': [50, 50]}, + 'sponsoredBy': {}, + 'cta': {}, + 'body': {'len': 100} + }}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const instreamVideoBidRequests = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'video': {'context': 'instream', 'playerSize': [[640, 480]]}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const instreamVideoBidRequestsSingleArraySlotAndDeals = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]}, + 'mediaTypes': {'video': {'context': 'instream', 'playerSize': [640, 480]}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const outstreamVideoBidRequests = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'video': {'context': 'outstream', 'playerSize': [[640, 480]], 'mimes': ['video/mp4', 'video/x-flv']}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const outstreamVideoBidRequestsSingleArraySlotAndDeals = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00, 'deals': [{id: 'deal_1'}, {id: 'deal_2'}]}, + 'mediaTypes': {'video': {'context': 'outstream', 'playerSize': [640, 480], 'mimes': ['video/mp4', 'video/x-flv']}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + const bidRequestsWithNoMediaType = [{ + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + }]; + + it('empty bid requests', function () { + const requests = spec.buildRequests([], bidderRequest); + assert.lengthOf(requests, 0); + }); + + it('mediaTypes missing in bid request', function () { + const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest); + assert.lengthOf(requests, 0); + }); + + it('invalid media type in bid request', function () { + bidRequestsWithNoMediaType[0].mediaTypes = {'test': {}}; + const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest); + assert.lengthOf(requests, 0); + }); + + it('size missing in bid request for banner', function () { + delete bidRequestsWithNoMediaType[0].mediaTypes.test; + bidRequestsWithNoMediaType[0].mediaTypes.banner = {}; + const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest); + assert.lengthOf(requests, 0); + }); + + it('size array empty in bid request for banner', function () { + bidRequestsWithNoMediaType[0].mediaTypes.banner.sizes = []; + const requests = spec.buildRequests(bidRequestsWithNoMediaType, bidderRequest); + assert.lengthOf(requests, 0); + }); + + it('banner bidRequest with slot size as 2 dimensional array', function () { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + const requests = spec.buildRequests(bannerBidRequests, bidderRequest); + config.getConfig.restore(); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload.imp).to.exist; + expect(payload).to.nested.include({'imp[0].banner.w': 300}); + expect(payload).to.nested.include({'imp[0].banner.h': 250}); + expect(payload).to.nested.include({'regs.ext.us_privacy': consentString}); + expect(payload).to.nested.include({'regs.ext.gdpr': '1'}); + expect(payload).to.nested.include({'regs.coppa': '1'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('banner'); + }); + + it('banner bidRequest with deals and slot size as 1 dimensional array', function () { + const requests = spec.buildRequests(bannerBidRequestsSingleArraySlotAndDeals, bidderRequest); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload.imp).to.exist; + expect(payload).to.nested.include({'imp[0].banner.w': 300}); + expect(payload).to.nested.include({'imp[0].banner.h': 250}); + expect(payload).to.nested.include({'imp[0].pmp.deals[0].id': 'deal_1'}); + expect(payload).to.nested.include({'imp[0].pmp.deals[1].id': 'deal_2'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('banner'); + }); + + it('native bidRequest fields with slot size as 2 dimensional array', function () { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + const requests = spec.buildRequests(nativeBidRequests, bidderRequest); + config.getConfig.restore(); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload.imp[0].native.request).to.exist; + expect(payload).to.nested.include({'regs.ext.us_privacy': consentString}); + expect(payload).to.nested.include({'regs.ext.gdpr': '1'}); + expect(payload).to.nested.include({'regs.coppa': '1'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('native'); + }); + + it('native bidRequest fields with deals and slot size as 1 dimensional array', function () { + const requests = spec.buildRequests(nativeBidRequestsSingleArraySlotAndDeals, bidderRequest); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload.imp).to.exist; + expect(payload.imp[0].native.request).to.exist; + expect(payload).to.nested.include({'imp[0].pmp.deals[0].id': 'deal_1'}); + expect(payload).to.nested.include({'imp[0].pmp.deals[1].id': 'deal_2'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('native'); + }); + + it('instream video bidRequest fields with slot size as 2 dimensional array', function () { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + const requests = spec.buildRequests(instreamVideoBidRequests, bidderRequest); + config.getConfig.restore(); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload).to.nested.include({'regs.ext.us_privacy': consentString}); + expect(payload).to.nested.include({'regs.ext.gdpr': '1'}); + expect(payload).to.nested.include({'regs.coppa': '1'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('video'); + }); + + it('instream video bidRequest with deals and slot size as 1 dimensional array', function () { + const requests = spec.buildRequests(instreamVideoBidRequestsSingleArraySlotAndDeals, bidderRequest); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('video'); + }); + + it('outstream video bidRequest fields with slot size as 2 dimensional array', function () { + sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); + const requests = spec.buildRequests(outstreamVideoBidRequests, bidderRequest); + config.getConfig.restore(); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload).to.nested.include({'imp[0].video.w': 640}); + expect(payload).to.nested.include({'imp[0].video.h': 480}); + expect(payload).to.nested.include({'regs.ext.us_privacy': consentString}); + expect(payload).to.nested.include({'regs.ext.gdpr': '1'}); + expect(payload).to.nested.include({'regs.coppa': '1'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('video'); + }); + + it('outstream video bidRequest fields with deals and slot size as 1 dimensional array', function () { + const requests = spec.buildRequests(outstreamVideoBidRequestsSingleArraySlotAndDeals, bidderRequest); + const payload = JSON.parse(requests[0].data); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.equal(FINAL_URL); + expect(payload).to.nested.include({'imp[0].video.w': 640}); + expect(payload).to.nested.include({'imp[0].video.h': 480}); + expect(payload).to.nested.include({'imp[0].pmp.deals[0].id': 'deal_1'}); + expect(payload).to.nested.include({'imp[0].pmp.deals[1].id': 'deal_2'}); + expect(requests[0].bidRequest).to.exist; + expect(requests[0].bidRequest.requestedMediaType).to.equal('video'); + }); + }); + + describe('interpretResponse', function () { + const bidRequest = { + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'sizes': [[300, 250], [300, 600]], + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + 'requestedMediaType': 'banner' + }; + const nativeBidRequest = { + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'native': { + 'title': {'required': true, 'len': 80}, + 'image': {'required': true, 'sizes': [300, 250]}, + 'icon': {'required': true, 'sizes': [50, 50]}, + 'sponsoredBy': {'required': true}, + 'cta': {'required': true}, + 'body': {'required': true} + }}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + 'requestedMediaType': 'native', + 'assets': [ + {'id': 1, 'required': 1, 'title': {'len': 80}}, + {'id': 2, 'required': 1, 'img': {'type': 3, 'w': 300, 'h': 250}}, + {'id': 3, 'required': 1, 'img': {'type': 1, 'w': 50, 'h': 50}}, + {'id': 4, 'required': 1, 'data': {'type': 1}}, + {'id': 5, 'required': 1, 'data': {'type': 12}}, + {'id': 6, 'required': 1, 'data': {'type': 2, 'len': 100}} + ] + }; + const instreamVideoBidRequest = { + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, 'bidfloor': 1.00}, + 'mediaTypes': {'video': {'context': 'instream', 'playerSize': [640, 480]}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + 'requestedMediaType': 'video' + }; + const outstreamVideoBidRequest = { + 'bidder': BIDDER_CODE, + 'params': {'site_id': SITE_ID, + 'bidfloor': 1.00, + 'outstreamType': 'slider_top_left', + 'outstreamConfig': + {'ad_unit_audio': 1, 'show_player_close_button_after': 5, 'hide_player_control': 0}}, + 'mediaTypes': {'video': {'context': 'outstream', 'playerSize': [640, 480]}}, + 'adUnitCode': 'adUnitCode', + 'transactionId': 'transactionId', + 'bidId': 'bidId', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId', + 'requestedMediaType': 'video' + }; + const request = { + 'method': 'POST', + 'url': FINAL_URL, + 'data': '', + bidRequest + }; + + it('check empty response', function () { + const result = spec.interpretResponse({}, request); + expect(result).to.deep.equal([]); + }); + + it('check if id missing in response', function () { + const serverResponse = {'body': {'seatbid': [{}]}, 'headers': {}}; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.deep.equal([]); + }); + + it('check if seatbid present in response', function () { + const serverResponse = {'body': {'id': 'id'}, 'headers': {}}; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.deep.equal([]); + }); + + it('check empty array response seatbid', function () { + const serverResponse = {'body': {'id': 'id', 'seatbid': []}, 'headers': {}}; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.deep.equal([]); + }); + + it('check bid present in seatbid', function () { + const serverResponse = {'body': {'id': 'id', 'seatbid': [{}]}, 'headers': {}}; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(0); + }); + + it('check empty array bid in seatbid', function () { + const serverResponse = {'body': {'id': 'id', 'seatbid': [{'bid': []}]}, 'headers': {}}; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(0); + }); + + it('banner response missing bid price', function () { + const serverResponse = {'body': {'id': 'id', 'seatbid': [{'bid': [{'id': 1}]}]}, 'headers': {}}; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + }); + + it('banner response', function () { + const serverResponse = { + 'body': { + 'id': 'id', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'price': 1, + 'w': 300, + 'h': 250, + 'adm': 'test adm', + 'nurl': 'url' + } + ] + } + ] + }, + 'headers': {} + }; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].cpm).to.equal(1); + expect(result[0].size).to.equal(bidRequest.mediaTypes.banner.sizes); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].ad).to.equal(decodeURIComponent(serverResponse.body.seatbid[0].bid[0].adm + '')); + expect(result[0].creativeId).to.equal('1'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + expect(result[0].mediaType).to.equal('banner'); + }); + + it('native response missing bid price', function () { + request.bidRequest = nativeBidRequest; + const serverResponse = { + 'body': { + 'id': 'id', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'w': 300, + 'h': 250, + 'adm': '{"native": {"link": {"url": "test_url"}, "imptrackers": [], "assets": [' + + '{"id": 1, "title": {"text": "Test title"}},' + + '{"id": 2, "img": {"type": 3,"url": "https://test/image", "w": 300, "h": 250}},' + + '{"id": 3, "img": {"type": 1, "url": "https://test/icon", "w": 50, "h": 50}},' + + '{"id": 4, "data": {"type": 1, "value": "Test sponsored by"}},' + + '{"id": 5, "data": {"type": 12, "value": "Test CTA"}},' + + '{"id": 6, "data": {"type": 2, "value": "Test body"}}]}}' + } + ] + } + ] + }, + 'headers': {} + }; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + }); + + it('native response', function () { + request.bidRequest = nativeBidRequest; + const serverResponse = { + 'body': { + 'id': 'id', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'price': 1, + 'w': 300, + 'h': 250, + 'adm': '{"native": {"link": {"url": "test_url"}, "imptrackers": ["tracker1", "tracker2"], "assets": [' + + '{"id": 1, "title": {"text": "Test title"}},' + + '{"id": 2, "img": {"type": 3,"url": "https://test/image", "w": 300, "h": 250}},' + + '{"id": 3, "img": {"type": 1, "url": "https://test/icon", "w": 50, "h": 50}},' + + '{"id": 4, "data": {"type": 1, "value": "Test sponsored by"}},' + + '{"id": 5, "data": {"type": 12, "value": "Test CTA"}},' + + '{"id": 6, "data": {"type": 2, "value": "Test body"}}]}}' + } + ] + } + ] + }, + 'headers': {} + }; + + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].cpm).to.equal(1); + expect(result[0].native.clickUrl).to.equal('test_url'); + expect(result[0].native.impressionTrackers).to.have.lengthOf(2); + expect(result[0].native.title).to.equal('Test title'); + expect(result[0].native.image.url).to.equal('https://test/image'); + expect(result[0].native.icon.url).to.equal('https://test/icon'); + expect(result[0].native.sponsored).to.equal('Test sponsored by'); + expect(result[0].native.cta).to.equal('Test CTA'); + expect(result[0].native.desc).to.equal('Test body'); + expect(result[0].creativeId).to.equal('1'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + expect(result[0].mediaType).to.equal('native'); + }); + + it('video response missing bid price', function () { + request.bidRequest = instreamVideoBidRequest; + const serverResponse = { + 'body': { + 'id': 'id', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'w': 640, + 'h': 480, + 'adm': '', + 'ext': { + 'vast_url': 'vast_url' + } + } + ] + } + ] + }, + 'headers': {} + }; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + }); + + it('instream video response', function () { + request.bidRequest = instreamVideoBidRequest; + const serverResponse = { + 'body': { + 'id': 'id', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'price': 1, + 'w': 640, + 'h': 480, + 'adm': '', + 'ext': { + 'vast_url': 'test_vast_url?kcid=123&kaid=12&protocol=3' + } + } + ] + } + ] + }, + 'headers': {} + }; + + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].cpm).to.equal(1); + expect(result[0].width).to.equal(640); + expect(result[0].height).to.equal(480); + expect(result[0].vastUrl).to.equal('test_vast_url?kcid=123&kaid=12&protocol=3'); + expect(result[0].adserverTargeting.hb_kcid).to.equal('123'); + expect(result[0].adserverTargeting.hb_kaid).to.equal('12'); + expect(result[0].adserverTargeting.hb_protocol).to.equal('3'); + expect(result[0].creativeId).to.equal('1'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + expect(result[0].mediaType).to.equal('video'); + }); + + it('outstream video response', function () { + request.bidRequest = outstreamVideoBidRequest; + const serverResponse = { + 'body': { + 'id': 'id', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'price': 1, + 'w': 640, + 'h': 480, + 'adm': '', + 'ext': { + 'vast_url': 'vast_url' + } + } + ] + } + ] + }, + 'headers': {} + }; + const result = spec.interpretResponse(serverResponse, request); + expect(result).to.have.lengthOf(1); + expect(result[0].requestId).to.equal('bidId'); + expect(result[0].cpm).to.equal(1); + expect(result[0].width).to.equal(640); + expect(result[0].height).to.equal(480); + expect(result[0].outstreamType).to.equal('slider_top_left'); + expect(result[0].ad).to.equal(''); + expect(result[0].renderer).to.exist; + expect(result[0].creativeId).to.equal('1'); + expect(result[0].bidderCode).to.equal(request.bidRequest.bidder); + expect(result[0].mediaType).to.equal('video'); + }); + }); +}); diff --git a/test/spec/modules/debugging_mod_spec.js b/test/spec/modules/debugging_mod_spec.js index 79866d023e9..8c7f0e84bce 100644 --- a/test/spec/modules/debugging_mod_spec.js +++ b/test/spec/modules/debugging_mod_spec.js @@ -1,13 +1,31 @@ import {expect} from 'chai'; import {BidInterceptor} from '../../../modules/debugging/bidInterceptor.js'; -import {bidderBidInterceptor} from '../../../modules/debugging/index.js'; -import {pbsBidInterceptor} from '../../../modules/debugging/pbsInterceptor.js'; +import { + bidderBidInterceptor, + disableDebugging, + getConfig, + sessionLoader, +} from '../../../modules/debugging/debugging.js'; +import '../../../modules/debugging/index.js'; +import {makePbsInterceptor} from '../../../modules/debugging/pbsInterceptor.js'; +import {config} from '../../../src/config.js'; +import {hook} from '../../../src/hook.js'; +import { + addBidderRequestsBound, + addBidderRequestsHook, + addBidResponseBound, + addBidResponseHook, +} from '../../../modules/debugging/legacy.js'; + +import {addBidderRequests, addBidResponse} from '../../../src/auction.js'; +import {prefixLog} from '../../../src/utils.js'; +import {createBid} from '../../../src/bidfactory.js'; describe('bid interceptor', () => { let interceptor, mockSetTimeout; beforeEach(() => { mockSetTimeout = sinon.stub().callsFake((fn) => fn()); - interceptor = new BidInterceptor({setTimeout: mockSetTimeout}); + interceptor = new BidInterceptor({setTimeout: mockSetTimeout, logger: prefixLog('TEST')}); }); function setRules(...rules) { @@ -116,6 +134,13 @@ describe('bid interceptor', () => { expect(result).to.include.keys(REQUIRED_KEYS); expect(result.outer.inner).to.eql({key: 'value'}); }); + + it('should respect array vs object definitions', () => { + const result = matchingRule({replace: {item: [replDef]}}).replace({}); + expect(result.item).to.be.an('array'); + expect(result.item.length).to.equal(1); + expect(result.item[0]).to.eql({key: 'value'}); + }); }); }); @@ -248,6 +273,15 @@ describe('bid interceptor', () => { }); }); +describe('Debugging config', () => { + it('should behave gracefully when sessionStorage throws', () => { + const logError = sinon.stub(); + const getStorage = () => { throw new Error() }; + getConfig({enabled: false}, {getStorage, logger: {logError}, hook}); + expect(logError.called).to.be.true; + }); +}); + describe('bidderBidInterceptor', () => { let next, interceptBids, onCompletion, interceptResult, done, addBid; @@ -350,6 +384,7 @@ describe('pbsBidInterceptor', () => { interceptResults = [EMPTY_INT_RES, EMPTY_INT_RES]; }); + const pbsBidInterceptor = makePbsInterceptor({createBid}); function callInterceptor() { return pbsBidInterceptor(next, interceptBids, s2sBidRequest, bidRequests, ajax, {onResponse, onError, onBid}); } @@ -449,3 +484,212 @@ describe('pbsBidInterceptor', () => { }); }); }); + +describe('bid overrides', function () { + let sandbox; + const logger = prefixLog('TEST'); + + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + + afterEach(function () { + window.sessionStorage.clear(); + config.resetConfig(); + sandbox.restore(); + }); + + describe('initialization', function () { + beforeEach(function () { + sandbox.stub(config, 'setConfig'); + }); + + afterEach(function () { + disableDebugging({hook, logger}); + }); + + it('should happen when enabled with setConfig', function () { + getConfig({ + enabled: true + }, {config, hook, logger}); + + expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); + expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); + }); + it('should happen when configuration found in sessionStorage', function () { + sessionLoader({ + storage: {getItem: () => ('{"enabled": true}')}, + config, + hook, + logger + }); + expect(addBidResponse.getHooks().some(hook => hook.hook === addBidResponseBound)).to.equal(true); + expect(addBidderRequests.getHooks().some(hook => hook.hook === addBidderRequestsBound)).to.equal(true); + }); + + it('should not throw if sessionStorage is inaccessible', function () { + expect(() => { + sessionLoader({ + getItem() { + throw new Error('test'); + } + }); + }).not.to.throw(); + }); + }); + + describe('bidResponse hook', function () { + let mockBids; + let bids; + + beforeEach(function () { + let baseBid = { + 'bidderCode': 'rubicon', + 'width': 970, + 'height': 250, + 'statusMessage': 'Bid available', + 'mediaType': 'banner', + 'source': 'client', + 'currency': 'USD', + 'cpm': 0.5, + 'ttl': 300, + 'netRevenue': false, + 'adUnitCode': '/19968336/header-bid-tag-0' + }; + mockBids = []; + mockBids.push(baseBid); + mockBids.push(Object.assign({}, baseBid, { + bidderCode: 'appnexus' + })); + + bids = []; + }); + + function run(overrides) { + mockBids.forEach(bid => { + let next = (adUnitCode, bid) => { + bids.push(bid); + }; + addBidResponseHook.bind({overrides, logger})(next, bid.adUnitCode, bid); + }); + } + + it('should allow us to exclude bidders', function () { + run({ + enabled: true, + bidders: ['appnexus'] + }); + + expect(bids.length).to.equal(1); + expect(bids[0].bidderCode).to.equal('appnexus'); + }); + + it('should allow us to override all bids', function () { + run({ + enabled: true, + bids: [{ + cpm: 2 + }] + }); + + expect(bids.length).to.equal(2); + sinon.assert.match(bids[0], { + cpm: 2, + isDebug: true, + }); + sinon.assert.match(bids[1], { + cpm: 2, + isDebug: true, + }); + }); + + it('should allow us to override bids by bidder', function () { + run({ + enabled: true, + bids: [{ + bidder: 'rubicon', + cpm: 2 + }] + }); + + expect(bids.length).to.equal(2); + sinon.assert.match(bids[0], { + cpm: 2, + isDebug: true + }); + sinon.assert.match(bids[1], { + cpm: 0.5, + isDebug: sinon.match.falsy + }); + }); + + it('should allow us to override bids by adUnitCode', function () { + mockBids[1].adUnitCode = 'test'; + + run({ + enabled: true, + bids: [{ + adUnitCode: 'test', + cpm: 2 + }] + }); + + expect(bids.length).to.equal(2); + sinon.assert.match(bids[0], { + cpm: 0.5, + isDebug: sinon.match.falsy, + }); + sinon.assert.match(bids[1], { + cpm: 2, + isDebug: true, + }); + }); + }); + + describe('bidRequests hook', function () { + let mockBidRequests; + let bidderRequests; + + beforeEach(function () { + let baseBidderRequest = { + 'bidderCode': 'rubicon', + 'bids': [{ + 'width': 970, + 'height': 250, + 'statusMessage': 'Bid available', + 'mediaType': 'banner', + 'source': 'client', + 'currency': 'USD', + 'cpm': 0.5, + 'ttl': 300, + 'netRevenue': false, + 'adUnitCode': '/19968336/header-bid-tag-0' + }] + }; + mockBidRequests = []; + mockBidRequests.push(baseBidderRequest); + mockBidRequests.push(Object.assign({}, baseBidderRequest, { + bidderCode: 'appnexus' + })); + + bidderRequests = []; + }); + + function run(overrides) { + let next = (b) => { + bidderRequests = b; + }; + addBidderRequestsHook.bind({overrides, logger})(next, mockBidRequests); + } + + it('should allow us to exclude bidders', function () { + run({ + enabled: true, + bidders: ['appnexus'] + }); + + expect(bidderRequests.length).to.equal(1); + expect(bidderRequests[0].bidderCode).to.equal('appnexus'); + }); + }); +}); diff --git a/test/spec/modules/deltaprojectsBidAdapter_spec.js b/test/spec/modules/deltaprojectsBidAdapter_spec.js index 382415eab62..b966d1580ca 100644 --- a/test/spec/modules/deltaprojectsBidAdapter_spec.js +++ b/test/spec/modules/deltaprojectsBidAdapter_spec.js @@ -7,6 +7,7 @@ import { } from 'modules/deltaprojectsBidAdapter.js'; const BID_REQ_REFER = 'http://example.com/page?param=val'; +const BID_REQ_DOMAIN = 'example.com' describe('deltaprojectsBidAdapter', function() { describe('isBidRequestValid', function () { @@ -62,7 +63,7 @@ describe('deltaprojectsBidAdapter', function() { auctionId: '1d1a030790a475', } const bidRequests = [BIDREQ]; - const bannerRequest = spec.buildRequests(bidRequests, {refererInfo: { referer: BID_REQ_REFER }})[0]; + const bannerRequest = spec.buildRequests(bidRequests, {refererInfo: { page: BID_REQ_REFER, domain: BID_REQ_DOMAIN }})[0]; const bannerRequestBody = bannerRequest.data; it('send bid request with test tag if it is set in the param', function () { diff --git a/test/spec/modules/dfpAdServerVideo_spec.js b/test/spec/modules/dfpAdServerVideo_spec.js index 300e2104fae..89485adf28b 100644 --- a/test/spec/modules/dfpAdServerVideo_spec.js +++ b/test/spec/modules/dfpAdServerVideo_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; import parse from 'url-parse'; -import { buildDfpVideoUrl, buildAdpodVideoUrl } from 'modules/dfpAdServerVideo.js'; +import {buildDfpVideoUrl, buildAdpodVideoUrl, dep} from 'modules/dfpAdServerVideo.js'; import adUnit from 'test/fixtures/video/adUnit.json'; import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; @@ -10,6 +10,10 @@ import { auctionManager } from 'src/auctionManager.js'; import { gdprDataHandler, uspDataHandler } from 'src/adapterManager.js'; import * as adpod from 'modules/adpod.js'; import { server } from 'test/mocks/xhr.js'; +import * as adServer from 'src/adserver.js'; +import {deepClone} from 'src/utils.js'; +import {hook} from '../../../src/hook.js'; +import {getRefererInfo} from '../../../src/refererDetection.js'; const bid = { videoCacheKey: 'abc', @@ -20,6 +24,44 @@ const bid = { }; describe('The DFP video support module', function () { + before(() => { + hook.ready(); + }); + + let sandbox; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore(); + }); + + Object.entries({ + params: { + params: { + 'iu': 'my/adUnit' + } + }, + url: { + url: 'https://some-example-url.com' + } + }).forEach(([t, options]) => { + describe(`when using ${t}`, () => { + it('should use page location as default for description_url', () => { + sandbox.stub(dep, 'ri').callsFake(() => ({page: 'example.com'})); + + const url = parse(buildDfpVideoUrl(Object.assign({ + adUnit: adUnit, + bid: bid, + }, options))); + const prm = utils.parseQS(url.query); + expect(prm.description_url).to.eql('example.com'); + }) + }) + }) + it('should make a legal request URL when given the required params', function () { const url = parse(buildDfpVideoUrl({ adUnit: adUnit, @@ -56,9 +98,6 @@ describe('The DFP video support module', function () { })); expect(url.host).to.equal('video.adserver.example'); - - const queryObject = utils.parseQS(url.query); - expect(queryObject.description_url).to.equal('vastUrl.example'); }); it('requires a params object or url', function () { @@ -226,6 +265,44 @@ describe('The DFP video support module', function () { gdprDataHandlerStub.restore(); }); + describe('GAM PPID', () => { + let ppid; + let getPPIDStub; + beforeEach(() => { + getPPIDStub = sinon.stub(adServer, 'getPPID').callsFake(() => ppid); + }); + afterEach(() => { + getPPIDStub.restore(); + }); + + Object.entries({ + 'params': {params: {'iu': 'mock/unit'}}, + 'url': {url: 'https://video.adserver.mock/', params: {'iu': 'mock/unit'}} + }).forEach(([t, opts]) => { + describe(`when using ${t}`, () => { + function buildUrlAndGetParams() { + const url = parse(buildDfpVideoUrl(Object.assign({ + adUnit: adUnit, + bid: deepClone(bid), + }, opts))); + return utils.parseQS(url.query); + } + + it('should be included if available', () => { + ppid = 'mockPPID'; + const q = buildUrlAndGetParams(); + expect(q.ppid).to.equal('mockPPID'); + }); + + it('should not be included if not available', () => { + ppid = undefined; + const q = buildUrlAndGetParams(); + expect(q.hasOwnProperty('ppid')).to.be.false; + }) + }) + }) + }) + describe('special targeting unit test', function () { const allTargetingData = { 'hb_format': 'video', diff --git a/test/spec/modules/dgkeywordRtdProvider_spec.js b/test/spec/modules/dgkeywordRtdProvider_spec.js index a145f429557..754740b7a64 100644 --- a/test/spec/modules/dgkeywordRtdProvider_spec.js +++ b/test/spec/modules/dgkeywordRtdProvider_spec.js @@ -293,8 +293,8 @@ describe('Digital Garage Keyword Module', function () { moduleConfig, null ); + const request = server.requests[0]; setTimeout(() => { - const request = server.requests[0]; if (request) { request.respond( 200, @@ -302,7 +302,7 @@ describe('Digital Garage Keyword Module', function () { JSON.stringify(DUMMY_RESPONSE) ); } - }, 1000); + }, 50); }); it('should get profiles ok(200).', function (done) { let pbjs = cloneDeep(config); @@ -347,5 +347,87 @@ describe('Digital Garage Keyword Module', function () { JSON.stringify(DUMMY_RESPONSE) ); }); + it('change url.', function (done) { + const dummyUrl = 'https://www.test.com/test' + let pbjs = cloneDeep(config); + pbjs.adUnits = cloneDeep(AD_UNITS); + if (IGNORE_SET_ORTB2) { + pbjs._ignoreSetOrtb2 = true; + } + let moduleConfig = cloneDeep(DEF_CONFIG); + moduleConfig.params.url = dummyUrl; + dgRtd.getDgKeywordsAndSet( + pbjs, + () => { + const url = dgRtd.getProfileApiUrl(dummyUrl); + expect(url.indexOf('?fpid=') === -1).to.equal(true); + expect(url).to.equal(server.requests[0].url); + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond( + 200, + DUMMY_RESPONSE_HEADER, + JSON.stringify(DUMMY_RESPONSE) + ); + }); + it('add fpid stored in local strage.', function (done) { + const uuid = 'uuid_abcdefghijklmnopqrstuvwxyz'; + let pbjs = cloneDeep(config); + pbjs.adUnits = cloneDeep(AD_UNITS); + if (IGNORE_SET_ORTB2) { + pbjs._ignoreSetOrtb2 = true; + } + let moduleConfig = cloneDeep(DEF_CONFIG); + window.localStorage.setItem('ope_fpid', uuid); + moduleConfig.params.enableReadFpid = true; + dgRtd.getDgKeywordsAndSet( + pbjs, + () => { + const url = dgRtd.getProfileApiUrl(null, moduleConfig.params.enableReadFpid); + expect(url.indexOf(uuid) > 0).to.equal(true); + expect(url).to.equal(server.requests[0].url); + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond( + 200, + DUMMY_RESPONSE_HEADER, + JSON.stringify(DUMMY_RESPONSE) + ); + }); + it('disable fpid stored in local strage.', function (done) { + const uuid = 'uuid_abcdefghijklmnopqrstuvwxyz'; + let pbjs = cloneDeep(config); + pbjs.adUnits = cloneDeep(AD_UNITS); + if (IGNORE_SET_ORTB2) { + pbjs._ignoreSetOrtb2 = true; + } + let moduleConfig = cloneDeep(DEF_CONFIG); + window.localStorage.setItem('ope_fpid', uuid); + dgRtd.getDgKeywordsAndSet( + pbjs, + () => { + const url = dgRtd.getProfileApiUrl(null); + expect(url.indexOf(uuid) > 0).to.equal(false); + expect(url).to.equal(server.requests[0].url); + done(); + }, + moduleConfig, + null + ); + const request = server.requests[0]; + request.respond( + 200, + DUMMY_RESPONSE_HEADER, + JSON.stringify(DUMMY_RESPONSE) + ); + }); }); }); diff --git a/test/spec/modules/dianomiBidAdapter_spec.js b/test/spec/modules/dianomiBidAdapter_spec.js new file mode 100644 index 00000000000..0838762d750 --- /dev/null +++ b/test/spec/modules/dianomiBidAdapter_spec.js @@ -0,0 +1,1542 @@ +// jshint esversion: 6, es3: false, node: true +import { assert } from 'chai'; +import { spec } from 'modules/dianomiBidAdapter.js'; +import { config } from 'src/config.js'; +import { createEidsArray } from 'modules/userId/eids.js'; + +describe('Dianomi adapter', () => { + let bids = []; + + describe('isBidRequestValid', () => { + let bid = { + bidder: 'dianomi', + params: { + smartadId: 1234, + }, + }; + + it('should return true when required params found', () => { + assert(spec.isBidRequestValid(bid)); + bid.params = { + smartadId: 4332, + }; + assert(spec.isBidRequestValid(bid)); + }); + + it('should return false when required params are missing', () => { + bid.params = {}; + assert.isFalse(spec.isBidRequestValid(bid)); + + bid.params = { + smartadId: null, + }; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', () => { + beforeEach(() => { + config.resetConfig(); + }); + it('should send request with correct structure', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }); + + assert.equal(request.method, 'POST'); + assert.equal(request.url, 'https://www-prebid.dianomi.com/cgi-bin/smartads_prebid.pl'); + assert.ok(request.data); + }); + + describe('user privacy', () => { + it('should send GDPR Consent data to Dianomi if gdprApplies', () => { + let validBidRequests = [{ bidId: 'bidId', params: { smartadId: 1234 } }]; + let bidderRequest = { + gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, + refererInfo: { page: 'page' }, + }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.user.ext.consent, bidderRequest.gdprConsent.consentString); + assert.equal(request.regs.ext.gdpr, bidderRequest.gdprConsent.gdprApplies); + assert.equal(typeof request.regs.ext.gdpr, 'number'); + }); + + it('should send gdpr as number', () => { + let validBidRequests = [{ bidId: 'bidId', params: { smartadId: 1234 } }]; + let bidderRequest = { + gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, + refererInfo: { page: 'page' }, + }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(typeof request.regs.ext.gdpr, 'number'); + assert.equal(request.regs.ext.gdpr, 1); + }); + + it('should send CCPA Consent data to dianomi', () => { + let validBidRequests = [{ bidId: 'bidId', params: { smartadId: 1234 } }]; + let bidderRequest = { uspConsent: '1YA-', refererInfo: { page: 'page' } }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.regs.ext.us_privacy, '1YA-'); + + bidderRequest = { + uspConsent: '1YA-', + gdprConsent: { gdprApplies: true, consentString: 'consentDataString' }, + refererInfo: { page: 'page' }, + }; + request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.regs.ext.us_privacy, '1YA-'); + assert.equal(request.user.ext.consent, 'consentDataString'); + assert.equal(request.regs.ext.gdpr, 1); + }); + + it('should not send GDPR Consent data to dianomi if gdprApplies is undefined', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let bidderRequest = { + gdprConsent: { gdprApplies: false, consentString: 'consentDataString' }, + refererInfo: { page: 'page' }, + }; + let request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.user.ext.consent, 'consentDataString'); + assert.equal(request.regs.ext.gdpr, 0); + + bidderRequest = { + gdprConsent: { consentString: 'consentDataString' }, + refererInfo: { page: 'page' }, + }; + request = JSON.parse(spec.buildRequests(validBidRequests, bidderRequest).data); + + assert.equal(request.user, undefined); + assert.equal(request.regs, undefined); + }); + it('should send default GDPR Consent data to dianomi', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + + assert.equal(request.user, undefined); + assert.equal(request.regs, undefined); + }); + }); + + it('should have default request structure', () => { + let keys = 'site,device,source,ext,imp'.split(','); + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + let data = Object.keys(request); + + assert.deepEqual(keys, data); + }); + + it('should set request keys correct values', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, {refererInfo: {page: 'page'}, ortb2: {source: {tid: 'tid'}}}).data + ); + + assert.equal(request.source.tid, 'tid'); + assert.equal(request.source.fd, 1); + }); + + it('should send info about device', () => { + config.setConfig({ + device: { w: 100, h: 100 }, + }); + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + + assert.equal(request.device.ua, navigator.userAgent); + assert.equal(request.device.w, 100); + assert.equal(request.device.h, 100); + }); + + it('should send app info', () => { + config.setConfig({ + app: { id: 'appid' }, + }); + const ortb2 = { app: { name: 'appname' } }; + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + ortb2, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' }, ortb2 }).data + ); + + assert.equal(request.app.id, 'appid'); + assert.equal(request.app.name, 'appname'); + assert.equal(request.site, undefined); + }); + + it('should send info about the site', () => { + config.setConfig({ + site: { + id: '123123', + publisher: { + domain: 'publisher.domain.com', + }, + }, + }); + const ortb2 = { + site: { + publisher: { + name: "publisher's name", + }, + }, + }; + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + ortb2, + }, + ]; + let refererInfo = { page: 'page' }; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo, ortb2 }).data); + + assert.deepEqual(request.site, { + page: refererInfo.page, + publisher: { + domain: 'publisher.domain.com', + name: "publisher's name", + }, + id: '123123', + }); + }); + + it('should pass extended ids', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + userIdAsEids: createEidsArray({ + tdid: 'TTD_ID_FROM_USER_ID_MODULE', + pubcid: 'pubCommonId_FROM_USER_ID_MODULE', + }), + }, + ]; + + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + assert.deepEqual(request.user.ext.eids, [ + { + source: 'adserver.org', + uids: [{ id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: { rtiPartner: 'TDID' } }], + }, + { source: 'pubcid.org', uids: [{ id: 'pubCommonId_FROM_USER_ID_MODULE', atype: 1 }] }, + ]); + }); + + it('should send currency if defined', () => { + config.setConfig({ currency: { adServerCurrency: 'EUR' } }); + let validBidRequests = [{ params: { smartadId: 1234 } }]; + let refererInfo = { page: 'page' }; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo }).data); + + assert.deepEqual(request.cur, ['EUR']); + }); + + it('should pass supply chain object', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + schain: { + validation: 'strict', + config: { + ver: '1.0', + }, + }, + }, + ]; + + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + assert.deepEqual(request.source.ext.schain, { + validation: 'strict', + config: { + ver: '1.0', + }, + }); + }); + + describe('priceType', () => { + it('should send default priceType', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + + assert.equal(request.ext.pt, 'net'); + }); + it('should send correct priceType value', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + + assert.equal(request.ext.pt, 'net'); + }); + }); + + describe('bids', () => { + it('should add more than one bid to the request', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + }, + { + bidId: 'bidId2', + params: { smartadId: 1234 }, + }, + ]; + let request = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ); + + assert.equal(request.imp.length, 2); + }); + it('should add incrementing values of id', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + mediaTypes: { video: {} }, + }, + { + bidId: 'bidId2', + params: { smartadId: 1234 }, + mediaTypes: { video: {} }, + }, + { + bidId: 'bidId3', + params: { smartadId: 1234 }, + mediaTypes: { video: {} }, + }, + ]; + let imps = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp; + + for (let i = 0; i < 3; i++) { + assert.equal(imps[i].id, i + 1); + } + }); + + describe('price floors', () => { + it('should not add if floors module not configured', () => { + const validBidRequests = [ + { bidId: 'bidId', params: { smartadId: 1234 }, mediaTypes: { video: {} } }, + ]; + let imp = getRequestImps(validBidRequests)[0]; + + assert.equal(imp.bidfloor, undefined); + assert.equal(imp.bidfloorcur, undefined); + }); + + it('should not add if floor price not defined', () => { + const validBidRequests = [getBidWithFloor()]; + let imp = getRequestImps(validBidRequests)[0]; + + assert.equal(imp.bidfloor, undefined); + assert.equal(imp.bidfloorcur, 'USD'); + }); + + it('should request floor price in adserver currency', () => { + config.setConfig({ currency: { adServerCurrency: 'GBP' } }); + const validBidRequests = [getBidWithFloor()]; + let imp = getRequestImps(validBidRequests)[0]; + + assert.equal(imp.bidfloor, undefined); + assert.equal(imp.bidfloorcur, 'GBP'); + }); + + it('should add correct floor values', () => { + const expectedFloors = [1, 1.3, 0.5]; + const validBidRequests = expectedFloors.map(getBidWithFloor); + let imps = getRequestImps(validBidRequests); + + expectedFloors.forEach((floor, index) => { + assert.equal(imps[index].bidfloor, floor); + assert.equal(imps[index].bidfloorcur, 'USD'); + }); + }); + + function getBidWithFloor(floor) { + return { + params: { smartadId: 1234 }, + mediaTypes: { video: {} }, + getFloor: ({ currency }) => { + return { + currency: currency, + floor, + }; + }, + }; + } + }); + + describe('multiple media types', () => { + it('should use all configured media types for bidding', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + mediaTypes: { + banner: { + sizes: [ + [100, 100], + [200, 300], + ], + }, + video: {}, + }, + }, + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + mediaTypes: { + video: {}, + native: {}, + }, + }, + { + bidId: 'bidId2', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + }, + mediaTypes: { + banner: { + sizes: [ + [100, 100], + [200, 300], + ], + }, + native: {}, + video: {}, + }, + }, + ]; + let [first, second, third] = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp; + + assert.ok(first.banner); + assert.ok(first.video); + assert.equal(first.native, undefined); + + assert.ok(second.video); + assert.equal(second.banner, undefined); + assert.equal(second.native, undefined); + + assert.ok(third.native); + assert.ok(third.video); + assert.ok(third.banner); + }); + }); + + describe('banner', () => { + it('should convert sizes to openrtb format', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + mediaTypes: { + banner: { + sizes: [ + [100, 100], + [200, 300], + ], + }, + }, + }, + ]; + let { banner } = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0]; + assert.deepEqual(banner, { + format: [ + { w: 100, h: 100 }, + { w: 200, h: 300 }, + ], + }); + }); + }); + + describe('video', () => { + it('should pass video mediatype config', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'], + }, + }, + }, + ]; + let { video } = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0]; + assert.deepEqual(video, { + playerSize: [640, 480], + context: 'outstream', + mimes: ['video/mp4'], + }); + }); + }); + + describe('native', () => { + describe('assets', () => { + it('should set correct asset id', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + ]; + let assets = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0].native.assets; + + assert.equal(assets[0].id, 0); + assert.equal(assets[1].id, 3); + assert.equal(assets[2].id, 4); + }); + it('should add required key if it is necessary', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + sponsoredBy: { required: true, len: 140 }, + }, + }, + ]; + + let assets = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0].native.assets; + + assert.equal(assets[0].required, 1); + assert.ok(!assets[1].required); + assert.ok(!assets[2].required); + assert.equal(assets[3].required, 1); + }); + + it('should map img and data assets', () => { + let validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { required: true, sizes: [150, 50] }, + icon: { required: false, sizes: [50, 50] }, + body: { required: false, len: 140 }, + sponsoredBy: { required: true }, + cta: { required: false }, + clickUrl: { required: false }, + }, + }, + ]; + + let assets = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0].native.assets; + assert.ok(assets[0].title); + assert.equal(assets[0].title.len, 140); + assert.deepEqual(assets[1].img, { type: 3, w: 150, h: 50 }); + assert.deepEqual(assets[2].img, { type: 1, w: 50, h: 50 }); + assert.deepEqual(assets[3].data, { type: 2, len: 140 }); + assert.deepEqual(assets[4].data, { type: 1 }); + assert.deepEqual(assets[5].data, { type: 12 }); + assert.ok(!assets[6]); + }); + + describe('icon/image sizing', () => { + it('should flatten sizes and utilise first pair', () => { + const validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + nativeParams: { + image: { + sizes: [ + [200, 300], + [100, 200], + ], + }, + }, + }, + ]; + + let assets = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0].native.assets; + assert.ok(assets[0].img); + assert.equal(assets[0].img.w, 200); + assert.equal(assets[0].img.h, 300); + }); + }); + + it('should utilise aspect_ratios', () => { + const validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + nativeParams: { + image: { + aspect_ratios: [ + { + min_width: 100, + ratio_height: 3, + ratio_width: 1, + }, + ], + }, + icon: { + aspect_ratios: [ + { + min_width: 10, + ratio_height: 5, + ratio_width: 2, + }, + ], + }, + }, + }, + ]; + + let assets = JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp[0].native.assets; + assert.ok(assets[0].img); + assert.equal(assets[0].img.wmin, 100); + assert.equal(assets[0].img.hmin, 300); + + assert.ok(assets[1].img); + assert.equal(assets[1].img.wmin, 10); + assert.equal(assets[1].img.hmin, 25); + }); + + it('should not throw error if aspect_ratios config is not defined', () => { + const validBidRequests = [ + { + bidId: 'bidId', + params: { smartadId: 1234 }, + nativeParams: { + image: { + aspect_ratios: [], + }, + icon: { + aspect_ratios: [], + }, + }, + }, + ]; + + assert.doesNotThrow(() => + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }) + ); + }); + }); + }); + }); + + function getRequestImps(validBidRequests) { + return JSON.parse( + spec.buildRequests(validBidRequests, { refererInfo: { page: 'page' } }).data + ).imp; + } + }); + + describe('interpretResponse', () => { + it('should return if no body in response', () => { + let serverResponse = {}; + let bidRequest = {}; + + assert.ok(!spec.interpretResponse(serverResponse, bidRequest)); + }); + it('should return more than one bids', () => { + let serverResponse = { + body: { + seatbid: [ + { + bid: [ + { + impid: '1', + native: { + ver: '1.1', + link: { url: 'link' }, + assets: [{ id: 1, title: { text: 'Asset title text' } }], + }, + }, + ], + }, + { + bid: [ + { + impid: '2', + native: { + ver: '1.1', + link: { url: 'link' }, + assets: [{ id: 1, data: { value: 'Asset title text' } }], + }, + }, + ], + }, + ], + }, + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + { + bidId: 'bidId2', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + ], + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.equal(spec.interpretResponse(serverResponse, bidRequest).length, 2); + }); + + it('should parse seatbids', () => { + let serverResponse = { + body: { + seatbid: [ + { + bid: [ + { + impid: '1', + native: { + ver: '1.1', + link: { url: 'link1' }, + assets: [{ id: 1, title: { text: 'Asset title text' } }], + }, + }, + { + impid: '4', + native: { + ver: '1.1', + link: { url: 'link4' }, + assets: [{ id: 1, title: { text: 'Asset title text' } }], + }, + }, + ], + }, + { + bid: [ + { + impid: '2', + native: { + ver: '1.1', + link: { url: 'link2' }, + assets: [{ id: 1, data: { value: 'Asset title text' } }], + }, + }, + ], + }, + ], + }, + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + { + bidId: 'bidId2', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + { + bidId: 'bidId3', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + { + bidId: 'bidId4', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + ], + }; + + bids = spec.interpretResponse(serverResponse, bidRequest).map((bid) => { + const { + requestId, + native: { clickUrl }, + } = bid; + return [requestId, clickUrl]; + }); + + assert.equal(bids.length, 3); + assert.deepEqual(bids, [ + ['bidId1', 'link1'], + ['bidId2', 'link2'], + ['bidId4', 'link4'], + ]); + }); + + it('should set correct values to bid', () => { + let serverResponse = { + body: { + id: null, + bidid: null, + seatbid: [ + { + bid: [ + { + impid: '1', + price: 93.1231, + crid: '12312312', + native: { + assets: [], + link: { url: 'link' }, + imptrackers: ['imptrackers url1', 'imptrackers url2'], + }, + dealid: 'deal-id', + adomain: ['demo.com'], + ext: { + prebid: { + type: 'native', + }, + }, + }, + ], + }, + ], + cur: 'USD', + }, + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + nativeParams: { + title: { required: true, len: 140 }, + image: { + required: false, + wmin: 836, + hmin: 627, + w: 325, + h: 300, + mimes: ['image/jpg', 'image/gif'], + }, + body: { len: 140 }, + }, + }, + ], + }; + + const bids = spec.interpretResponse(serverResponse, bidRequest); + const bid = serverResponse.body.seatbid[0].bid[0]; + assert.deepEqual(bids[0].requestId, bidRequest.bids[0].bidId); + assert.deepEqual(bids[0].cpm, bid.price); + assert.deepEqual(bids[0].creativeId, bid.crid); + assert.deepEqual(bids[0].ttl, 360); + assert.deepEqual(bids[0].netRevenue, false); + assert.deepEqual(bids[0].currency, serverResponse.body.cur); + assert.deepEqual(bids[0].mediaType, 'native'); + assert.deepEqual(bids[0].meta.mediaType, 'native'); + assert.deepEqual(bids[0].meta.advertiserDomains, ['demo.com']); + assert.deepEqual(bids[0].dealId, 'deal-id'); + }); + it('should set correct native params', () => { + const bid = [ + { + impid: '1', + price: 93.1231, + crid: '12312312', + native: { + assets: [ + { + data: null, + id: 0, + img: null, + required: 0, + title: { text: 'title', len: null }, + video: null, + }, + { + data: null, + id: 2, + img: { type: null, url: 'test.url.com/Files/58345/308185.jpgbv=1', w: 30, h: 10 }, + required: 0, + title: null, + video: null, + }, + { + data: null, + id: 3, + img: { + type: null, + url: 'test.url.com/Files/58345/308200.jpgbv=1', + w: 100, + h: 100, + }, + required: 0, + title: null, + video: null, + }, + { + data: { type: null, len: null, value: 'body' }, + id: 4, + img: null, + required: 0, + title: null, + video: null, + }, + { + data: { type: null, len: null, value: 'cta' }, + id: 1, + img: null, + required: 0, + title: null, + video: null, + }, + { + data: { type: null, len: null, value: 'sponsoredBy' }, + id: 5, + img: null, + required: 0, + title: null, + video: null, + }, + ], + link: { url: 'clickUrl', clicktrackers: ['clickTracker1', 'clickTracker2'] }, + imptrackers: ['imptrackers url1', 'imptrackers url2'], + jstracker: 'jstracker', + }, + }, + ]; + const serverResponse = { + body: { + id: null, + bidid: null, + seatbid: [{ bid }], + cur: 'USD', + }, + }; + let bidRequest = { + data: {}, + bids: [{ bidId: 'bidId1' }], + }; + + const result = spec.interpretResponse(serverResponse, bidRequest)[0].native; + const native = bid[0].native; + const assets = native.assets; + assert.deepEqual( + { + clickUrl: native.link.url, + clickTrackers: native.link.clicktrackers, + impressionTrackers: native.imptrackers, + javascriptTrackers: [native.jstracker], + title: assets[0].title.text, + icon: { url: assets[1].img.url, width: assets[1].img.w, height: assets[1].img.h }, + image: { url: assets[2].img.url, width: assets[2].img.w, height: assets[2].img.h }, + body: assets[3].data.value, + cta: assets[4].data.value, + sponsoredBy: assets[5].data.value, + }, + result + ); + }); + it('should return empty when there is no bids in response', () => { + const serverResponse = { + body: { + id: null, + bidid: null, + seatbid: [{ bid: [] }], + cur: 'USD', + }, + }; + let bidRequest = { + data: {}, + bids: [{ bidId: 'bidId1' }], + }; + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + assert.ok(!result); + }); + + describe('banner', () => { + it('should set ad content on response', () => { + let serverResponse = { + body: { + seatbid: [ + { + bid: [{ impid: '1', adm: '', ext: { prebid: { type: 'banner' } } }], + }, + ], + }, + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + }, + ], + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.equal(bids.length, 1); + assert.equal(bids[0].ad, ''); + assert.equal(bids[0].mediaType, 'banner'); + assert.equal(bids[0].meta.mediaType, 'banner'); + }); + }); + + describe('video', () => { + it('should set vastXml on response', () => { + let serverResponse = { + body: { + seatbid: [ + { + bid: [{ impid: '1', adm: '', ext: { prebid: { type: 'video' } } }], + }, + ], + }, + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + }, + ], + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.equal(bids.length, 1); + assert.equal(bids[0].vastXml, ''); + assert.equal(bids[0].mediaType, 'video'); + assert.equal(bids[0].meta.mediaType, 'video'); + }); + + it('should add renderer for outstream bids', () => { + let serverResponse = { + body: { + seatbid: [ + { + bid: [ + { impid: '1', adm: '', ext: { prebid: { type: 'video' } } }, + { impid: '2', adm: '', ext: { prebid: { type: 'video' } } }, + ], + }, + ], + }, + }; + let bidRequest = { + data: {}, + bids: [ + { + bidId: 'bidId1', + params: { smartadId: 1234 }, + mediaTypes: { + video: { + context: 'outstream', + }, + }, + }, + { + bidId: 'bidId2', + params: { smartadId: 1234 }, + mediaTypes: { + video: { + constext: 'instream', + }, + }, + }, + ], + }; + + bids = spec.interpretResponse(serverResponse, bidRequest); + assert.ok(bids[0].renderer); + assert.equal(bids[1].renderer, undefined); + }); + }); + }); + + describe('UserSyncs', () => { + let usersyncIframeUrl = 'https://www-prebid.dianomi.com/prebid/usersync/index.html?'; + let usersyncRedirectUrl = 'https://data.dianomi.com/frontend/usync?'; + it('should register the usersync iframe', function () { + let syncs = spec.getUserSyncs({ + iframeEnabled: true, + }); + + expect(syncs).to.deep.equal({ type: 'iframe', url: usersyncIframeUrl }); + }); + + it('should register the usersync redirect', function () { + let syncs = spec.getUserSyncs({ + pixelEnabled: true, + }); + + expect(syncs).to.deep.equal({ type: 'image', url: usersyncRedirectUrl }); + }); + + it('should pass gdpr params if consent is true', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + gdprApplies: true, + consentString: 'foo', + } + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}gdpr=1&gdpr_consent=foo`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + gdprApplies: true, + consentString: 'foo', + } + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}gdpr=1&gdpr_consent=foo`, + }); + }); + + it('should pass gdpr params if consent is false', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + gdprApplies: false, + consentString: 'foo', + } + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}gdpr=0&gdpr_consent=foo`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + gdprApplies: false, + consentString: 'foo', + } + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}gdpr=0&gdpr_consent=foo`, + }); + }); + + it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + consentString: 'foo', + } + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}gdpr_consent=foo`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + consentString: 'foo', + } + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}gdpr_consent=foo`, + }); + }); + + it('should pass no params if gdpr consentString is not defined', function () { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {})).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}`, + }); + + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}`, + }); + }); + + it('should pass no params if gdpr consentString is a number', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + consentString: 0, + } + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + consentString: 0, + } + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}`, + }); + }); + + it('should pass no params if gdpr consentString is null', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + consentString: null, + } + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + consentString: null, + } + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}`, + }); + }); + + it('should pass no params if gdpr consentString is a object', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + consentString: {}, + } + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + consentString: {}, + } + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}`, + }); + }); + + it('should pass no params if gdpr is not defined', function () { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}`, + }); + + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}`, + }); + }); + + it('should pass us_privacy if uspConsent is defined', function () { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, '1NYN')).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}us_privacy=1NYN`, + }); + + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}us_privacy=1NYN`, + }); + }); + + it('should pass us_privacy after gdpr if both are present', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + consentString: 'foo', + }, + '1NYN' + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}gdpr_consent=foo&us_privacy=1NYN`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + consentString: 'foo', + }, + '1NYN' + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}gdpr_consent=foo&us_privacy=1NYN`, + }); + }); + + it('should pass gdprApplies', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + gdprApplies: true, + }, + '1NYN' + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}gdpr=1&us_privacy=1NYN`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + gdprApplies: true, + }, + '1NYN' + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}gdpr=1&us_privacy=1NYN`, + }); + }); + + it('should pass all correctly', function () { + expect( + spec.getUserSyncs( + { iframeEnabled: true }, + {}, + { + gdprApplies: true, + consentString: 'foo', + }, + '1NYN' + ) + ).to.deep.equal({ + type: 'iframe', + url: `${usersyncIframeUrl}gdpr=1&gdpr_consent=foo&us_privacy=1NYN`, + }); + + expect( + spec.getUserSyncs( + { pixelEnabled: true }, + {}, + { + gdprApplies: true, + consentString: 'foo', + }, + '1NYN' + ) + ).to.deep.equal({ + type: 'image', + url: `${usersyncRedirectUrl}gdpr=1&gdpr_consent=foo&us_privacy=1NYN`, + }); + }); + }); +}); diff --git a/test/spec/modules/discoveryBidAdapter_spec.js b/test/spec/modules/discoveryBidAdapter_spec.js new file mode 100644 index 00000000000..078add73046 --- /dev/null +++ b/test/spec/modules/discoveryBidAdapter_spec.js @@ -0,0 +1,93 @@ +import { expect } from 'chai'; +import { spec } from 'modules/discoveryBidAdapter.js'; + +describe('discovery:BidAdapterTests', function () { + let bidRequestData = { + bidderCode: 'discovery', + auctionId: 'ff66e39e-4075-4d18-9854-56fde9b879ac', + bidderRequestId: '4fec04e87ad785', + bids: [ + { + bidder: 'discovery', + params: { + token: 'd0f4902b616cc5c38cbe0a08676d0ed9', + }, + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + adUnitCode: 'regular_iframe', + transactionId: 'd163f9e2-7ecd-4c2c-a3bd-28ceb52a60ee', + sizes: [[300, 250]], + bidId: '276092a19e05eb', + bidderRequestId: '1fadae168708b', + auctionId: 'ff66e39e-4075-4d18-9854-56fde9b879ac', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + }, + ], + }; + let request = []; + + it('discovery:validate_pub_params', function () { + expect( + spec.isBidRequestValid({ + bidder: 'discovery', + params: { + token: ['d0f4902b616cc5c38cbe0a08676d0ed9'], + tagid: ['test_tagid'], + publisher: ['test_publisher'] + }, + }) + ).to.equal(true); + }); + + it('discovery:validate_generated_params', function () { + request = spec.buildRequests(bidRequestData.bids, bidRequestData); + let req_data = JSON.parse(request.data); + expect(req_data.imp).to.have.lengthOf(1); + }); + + it('discovery:validate_response_params', function () { + let tempAdm = '' + tempAdm += '%3Cscr'; + tempAdm += 'ipt%3E'; + tempAdm += '!function(){\"use strict\";function f(t){return(f=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t})(t)}function l(t){var e=0 - - - - - - - - - 00:00:15 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -` - -const supportedSize = [ - { - size: [300, 250], - s: 100 - }, - { - size: [728, 90], - s: 95 - }, - { - size: [300, 600], - s: 90 - }, - { - size: [160, 600], - s: 88 - }, - { - size: [320, 50], - s: 85 - }, - { - size: [300, 50], - s: 80 - }, - { - size: [970, 250], - s: 75 - }, - { - size: [970, 90], - s: 60 - }, -]; -const bidRequest = [{ - 'bidder': 'districtmDMX', - 'params': { - 'dmxid': 100001, - 'memberid': 100003, - }, - 'userId': { - idl_env: {}, - digitrustid: { - data: { - id: {} - } - }, - id5id: { - uid: '' - }, - pubcid: {}, - tdid: {}, - criteoId: {}, - britepoolid: {}, - intentiqid: {}, - lotamePanoramaId: {}, - parrableId: {}, - netId: {}, - lipb: { - lipbid: {} - }, - - }, - 'adUnitCode': 'div-gpt-ad-12345678-1', - 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '29a28a1bbc8a8d', - 'bidderRequestId': '124b579a136515', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' -}]; - -const bidRequestVideo = [{ - 'bidder': 'districtmDMX', - 'params': { - 'dmxid': 100001, - 'memberid': 100003, - 'video': { - id: 123, - skipppable: true, - playback_method: ['auto_play_sound_off', 'viewport_sound_off'], - mimes: ['application/javascript', - 'video/mp4'], - } - }, - 'mediaTypes': { - video: { - context: 'instream', // or 'outstream' - playerSize: [[640, 480]] - } - }, - 'adUnitCode': 'div-gpt-ad-12345678-1', - 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '29a28a1bbc8a8d', - 'bidderRequestId': '124b579a136515', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' -}]; -const bidRequestNoCoppa = [{ - 'bidder': 'districtmDMX', - 'params': { - 'dmxid': 100001, - 'memberid': 100003 - }, - 'adUnitCode': 'div-gpt-ad-12345678-1', - 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '29a28a1bbc8a8d', - 'bidderRequestId': '124b579a136515', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' -}]; -const bidderRequest = { - 'bidderCode': 'districtmDMX', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf', - 'bidderRequestId': '124b579a136515', - 'bids': [{ - 'bidder': 'districtmDMX', - 'params': { - 'dmxid': 100001, - 'memberid': 100003, - }, - 'adUnitCode': 'div-gpt-ad-12345678-1', - 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '29a28a1bbc8a8d', - 'bidderRequestId': '124b579a136515', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' - }], - 'auctionStart': 1529511035677, - 'timeout': 700, - 'uspConsent': '1NY', - 'gdprConsent': { - 'consentString': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', - 'vendorData': { - 'metadata': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', - 'hasGlobalScope': false, - 'gdprApplies': true, - 'purposeConsents': { - '1': false, - '2': false, - '3': false, - '4': false, - '5': false - }, - 'vendorConsents': { - '1': false, - '2': false, - '3': false, - '4': false, - '6': false, - '7': false, - '8': false, - '9': false, - '10': false, - '11': false, - '12': false, - '13': false, - '14': false, - '15': false, - '16': false, - '17': false, - '18': false, - '19': false, - '20': false, - '21': false, - '22': false, - '23': false, - '24': false, - '25': false, - '26': false, - '27': false, - '28': false, - '29': false, - '30': false, - '31': false, - '32': false, - '33': false, - '34': false, - '35': false, - '36': false, - '37': false, - '38': false, - '39': false, - '40': false, - '41': false, - '42': false, - '43': false, - '44': false, - '45': false, - '46': false, - '47': false, - '48': false, - '49': false, - '50': false, - '51': false, - '52': false, - '53': false, - '55': false, - '56': false, - '57': false, - '58': false, - '59': false, - '60': false, - '61': false, - '62': false, - '63': false, - '64': false, - '65': false, - '66': false, - '67': false, - '68': false, - '69': false, - '70': false, - '71': false, - '72': false, - '73': false, - '74': false, - '75': false, - '76': false, - '77': false, - '78': false, - '79': false, - '80': false, - '81': false, - '82': false, - '83': false, - '84': false, - '85': false, - '86': false, - '87': false, - '88': false, - '89': false, - '90': false, - '91': false, - '92': false, - '93': false, - '94': false, - '95': false, - '97': false, - '98': false, - '100': false, - '101': false, - '102': false, - '104': false, - '105': false, - '108': false, - '109': false, - '110': false, - '111': false, - '112': false, - '113': false, - '114': false, - '115': false, - '119': false, - '120': false, - '122': false, - '124': false, - '125': false, - '126': false, - '127': false, - '128': false, - '129': false, - '130': false, - '131': false, - '132': false, - '133': false, - '134': false, - '136': false, - '138': false, - '139': false, - '140': false, - '141': false, - '142': false, - '143': false, - '144': false, - '145': false, - '147': false, - '148': false, - '149': false, - '150': false, - '151': false, - '152': false, - '153': false, - '154': false, - '155': false, - '156': false, - '157': false, - '158': false, - '159': false, - '160': false, - '161': false, - '162': false, - '163': false, - '164': false, - '165': false, - '167': false, - '168': false, - '169': false, - '170': false, - '171': false, - '173': false, - '174': false, - '175': false, - '177': false, - '178': false, - '179': false, - '180': false, - '182': false, - '183': false, - '184': false, - '185': false, - '188': false, - '189': false, - '190': false, - '191': false, - '192': false, - '193': false, - '194': false, - '195': false, - '197': false, - '198': false, - '199': false, - '200': false, - '201': false, - '202': false, - '203': false, - '205': false, - '206': false, - '208': false, - '209': false, - '210': false, - '211': false, - '212': false, - '213': false, - '214': false, - '215': false, - '216': false, - '217': false, - '218': false, - '223': false, - '224': false, - '225': false, - '226': false, - '227': false, - '228': false, - '229': false, - '230': false, - '231': false, - '232': false, - '234': false, - '235': false, - '236': false, - '237': false, - '238': false, - '239': false, - '240': false, - '241': false, - '242': false, - '244': false, - '245': false, - '246': false, - '248': false, - '249': false, - '250': false, - '251': false, - '252': false, - '253': false, - '254': false, - '255': false, - '256': false, - '257': false, - '258': false, - '259': false, - '260': false, - '261': false, - '262': false, - '263': false, - '264': false, - '265': false, - '266': false, - '269': false, - '270': false, - '272': false, - '273': false, - '274': false, - '275': false, - '276': false, - '277': false, - '278': false, - '279': false, - '280': false, - '281': false, - '282': false, - '284': false, - '285': false, - '288': false, - '289': false, - '290': false, - '291': false, - '294': false, - '295': false, - '297': false, - '299': false, - '301': false, - '302': false, - '303': false, - '304': false, - '308': false, - '309': false, - '310': false, - '311': false, - '312': false, - '314': false, - '315': false, - '316': false, - '317': false, - '318': false, - '319': false, - '320': false, - '323': false, - '325': false, - '326': false, - '328': false, - '329': false, - '330': false, - '331': false, - '333': false, - '337': false, - '339': false, - '341': false, - '343': false, - '344': false, - '345': false, - '347': false, - '349': false, - '350': false, - '351': false, - '354': false, - '358': false, - '359': false, - '360': false, - '361': false, - '368': false, - '369': false, - '371': false, - '373': false, - '376': false, - '377': false, - '378': false, - '380': false, - '382': false, - '384': false, - '385': false, - '387': false, - '388': false, - '389': false, - '390': false, - '391': false, - '398': false, - '400': false, - '402': false, - '403': false, - '404': false, - '413': false, - '415': false, - '421': false, - '422': false - } - }, - 'gdprApplies': true - }, - 'start': 1529511035686, - 'doneCbCallCount': 0 -}; - -const bidderRequestNoCoppa = { - 'bidderCode': 'districtmDMX', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf', - 'bidderRequestId': '124b579a136515', - 'bids': [{ - 'bidder': 'districtmDMX', - 'params': { - 'dmxid': 100001, - 'memberid': 100003, - }, - 'adUnitCode': 'div-gpt-ad-12345678-1', - 'transactionId': 'f6d13fa6-ebc1-41ac-9afa-d8171d22d2c2', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '29a28a1bbc8a8d', - 'bidderRequestId': '124b579a136515', - 'auctionId': '3d62f2d3-56a2-4991-888e-f7754619ddcf' - }], - 'auctionStart': 1529511035677, - 'timeout': 700, - 'start': 1529511035686, - 'doneCbCallCount': 0 -}; - -const responses = { - 'body': { - 'id': '1f45b37c-5298-4934-b517-4d911aadabfd', - 'cur': 'USD', - 'seatbid': [{ - 'bid': [{ - 'id': '29a28a1bbc8a8d', - 'impid': '29a28a1bbc8a8d', - 'price': '6.42', - 'adm': '
' - }] - }] - }, - 'headers': {} -}; - -const responsesNegative = { - 'body': { - 'id': '1f45b37c-5298-4934-b517-4d911aadabfd', - 'cur': 'USD', - 'seatbid': [{ - 'bid': [{ - 'id': '29a28a1bbc8a8d', - 'impid': '29a28a1bbc8a8d', - 'price': '-0.10', - 'adm': '
' - }] - }] - }, - 'headers': {} -}; - -const emptyResponse = { body: {} }; -const emptyResponseSeatBid = { body: { seatbid: [] } }; - -describe('DistrictM Adaptor', function () { - const districtm = spec; - describe('verification of upto5', function () { - it('upto5 function should always break 12 imps into 3 request same for 15', function () { - expect(upto5([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], bidRequest, bidderRequest, 'https://google').length).to.be.equal(3) - expect(upto5([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], bidRequest, bidderRequest, 'https://google').length).to.be.equal(3) - }) - }) - - describe('test vast tag', function () { - it('img tag should not be present', function () { - expect(cleanVast(sample_vast).indexOf('img') !== -1).to.be.equal(false) - }) - }) - describe('Test getApi function', function () { - const data = { - api: [1] - } - it('Will return 1 for vpaid version 1', function () { - expect(getApi(data)[0]).to.be.equal(1) - }) - it('Will return 2 for vpaid default', function () { - expect(getApi({})[0]).to.be.equal(2) - }) - }) - - describe('Test cleanSizes function', function () { - it('sequence will be respected', function () { - expect(cleanSizes(bidderRequest.bids[0].sizes).toString()).to.be.equal('300,250,300,600') - }) - it('sequence will be respected', function () { - expect(cleanSizes([[728, 90], [970, 90], [300, 600], [320, 50]]).toString()).to.be.equal('728,90,320,50,300,600,970,90') - }) - }) - - describe('Test getPlaybackmethod function', function () { - it('getPlaybackmethod will return 2', function () { - expect(getPlaybackmethod([])[0]).to.be.equal(2) - }) - it('getPlaybackmethod will return 6', function () { - expect(getPlaybackmethod(['viewport_sound_off'])[0]).to.be.equal(6) - }) - }) - - describe('Test getProtocols function', function () { - it('getProtocols will return 3', function () { - expect(getProtocols({ protocols: [3] })[0]).to.be.equal(3) - }) - it('getProtocols will return 6', function () { - expect(_.isEqual(getProtocols({}), [2, 3, 5, 6, 7, 8])).to.be.equal(true) - }) - }) - - describe('All needed functions are available', function () { - it(`isBidRequestValid is present and type function`, function () { - expect(districtm.isBidRequestValid).to.exist.and.to.be.a('function') - }); - - it(`BuildRequests is present and type function`, function () { - expect(districtm.buildRequests).to.exist.and.to.be.a('function') - }); - - it(`interpretResponse is present and type function`, function () { - expect(districtm.interpretResponse).to.exist.and.to.be.a('function') - }); - - it(`getUserSyncs is present and type function`, function () { - expect(districtm.getUserSyncs).to.exist.and.to.be.a('function') - }); - }); - - describe(`these properties are available or not`, function () { - it(`code should have a value of districtmDMX`, function () { - expect(districtm.code).to.be.equal('districtmDMX'); - }); - - it(`timeout should not be defined`, function () { - expect(districtm.onTimeout).to.be.an('undefined'); - }); - }); - - describe(`isBidRequestValid test response`, function () { - let params = { - dmxid: 10001, // optional - memberid: 10003, - }; - it(`function should return true`, function () { - expect(districtm.isBidRequestValid({ params })).to.be.equal(true); - }); - it(`function should return false`, function () { - expect(districtm.isBidRequestValid({ params: {} })).to.be.equal(false); - }); - it(`expect to have memberid`, function () { - expect(params).to.have.property('memberid'); - }); - }); - - describe(`getUserSyncs test usage`, function () { - it(`return value should be an array`, function () { - expect(districtm.getUserSyncs({ iframeEnabled: true })).to.be.an('array'); - }); - it(`array should have only one object and it should have a property type = 'iframe'`, function () { - expect(districtm.getUserSyncs({ iframeEnabled: true }).length).to.be.equal(1); - let [userSync] = districtm.getUserSyncs({ iframeEnabled: true }); - expect(userSync).to.have.property('type'); - expect(userSync.type).to.be.equal('iframe'); - }); - }); - - describe(`buildRequests test usage`, function () { - const buildRequestResults = districtm.buildRequests(bidRequest, bidderRequest); - const buildRequestResultsNoCoppa = districtm.buildRequests(bidRequestNoCoppa, bidderRequestNoCoppa); - it(`the function should return an array`, function () { - expect(buildRequestResults).to.be.an('object'); - }); - it(`contain gdpr consent & ccpa`, function () { - const bidr = JSON.parse(buildRequestResults.data) - expect(bidr.regs.ext.gdpr).to.be.equal(1); - expect(bidr.regs.ext.us_privacy).to.be.equal('1NY'); - expect(bidr.user.ext.consent).to.be.an('string'); - }); - it(`test contain COPPA`, function () { - const bidr = JSON.parse(buildRequestResults.data) - bidr.regs = bidr.regs || {}; - bidr.regs.coppa = 1; - expect(bidr.regs.coppa).to.be.equal(1) - }) - it(`test should not contain COPPA`, function () { - const bidr = JSON.parse(buildRequestResultsNoCoppa.data) - expect(bidr.regs.coppa).to.be.equal(0) - }) - it(`the function should return array length of 1`, function () { - expect(buildRequestResults.data).to.be.a('string'); - }); - }); - - describe('bidRequest Video testing', function () { - const request = districtm.buildRequests(bidRequestVideo, bidRequestVideo); - const data = JSON.parse(request.data) - expect(data instanceof Object).to.be.equal(true) - }) - - describe(`interpretResponse test usage`, function () { - const responseResults = districtm.interpretResponse(responses, { bidderRequest }); - const emptyResponseResults = districtm.interpretResponse(emptyResponse, { bidderRequest }); - const emptyResponseResultsNegation = districtm.interpretResponse(responsesNegative, { bidderRequest }); - const emptyResponseResultsEmptySeat = districtm.interpretResponse(emptyResponseSeatBid, { bidderRequest }); - it(`the function should return an array`, function () { - expect(responseResults).to.be.an('array'); - }); - it(`the function should return array length of 1`, function () { - expect(responseResults.length).to.be.equal(1); - }); - it(`the response return nothing`, function () { - expect(emptyResponseResults.length).to.be.equal(0); - }); - it(`the response seatbid return nothing`, function () { - expect(emptyResponseResultsEmptySeat.length).to.be.equal(0); - }); - - it(`on invalid CPM`, function () { - expect(emptyResponseResultsNegation.length).to.be.equal(0); - }); - }); - - describe(`check validation for id sync gdpr ccpa`, () => { - let allin = spec.getUserSyncs({ iframeEnabled: true }, {}, bidderRequest.gdprConsent, bidderRequest.uspConsent)[0] - let noCCPA = spec.getUserSyncs({ iframeEnabled: true }, {}, bidderRequest.gdprConsent, null)[0] - let noGDPR = spec.getUserSyncs({ iframeEnabled: true }, {}, null, bidderRequest.uspConsent)[0] - let nothing = spec.getUserSyncs({ iframeEnabled: true }, {}, null, null)[0] - - /* - - 'uspConsent': '1NY', - 'gdprConsent': { - 'consentString': 'BOPqNzUOPqNzUAHABBAAA5AAAAAAAA', - */ - it(`gdpr & ccpa should be present`, () => { - expect(allin.url).to.be.equal('https://cdn.districtm.io/ids/index.html?gdpr=BOPqNzUOPqNzUAHABBAAA5AAAAAAAA&ccpa=1NY') - }) - it(`ccpa should be present`, () => { - expect(noGDPR.url).to.be.equal('https://cdn.districtm.io/ids/index.html?ccpa=1NY') - }) - it(`gdpr should be present`, () => { - expect(noCCPA.url).to.be.equal('https://cdn.districtm.io/ids/index.html?gdpr=BOPqNzUOPqNzUAHABBAAA5AAAAAAAA') - }) - it(`gdpr & ccpa shouldn't be present`, () => { - expect(nothing.url).to.be.equal('https://cdn.districtm.io/ids/index.html') - }) - }) - - describe(`Helper function testing`, function () { - const bid = matchRequest('29a28a1bbc8a8d', { bidderRequest }); - const { width, height } = defaultSize(bid); - it(`test matchRequest`, function () { - expect(matchRequest('29a28a1bbc8a8d', { bidderRequest })).to.be.an('object'); - }); - it(`test checkDeepArray`, function () { - expect(_.isEqual(checkDeepArray([728, 90]), [728, 90])).to.be.equal(true); - expect(_.isEqual(checkDeepArray([[728, 90]]), [728, 90])).to.be.equal(true); - expect(_.isEqual(checkDeepArray([[728, 90], [300, 250]]), [728, 90])).to.be.equal(true); - expect(_.isEqual(checkDeepArray([[300, 250], [300, 250]]), [728, 90])).to.be.equal(false); - expect(_.isEqual(checkDeepArray([300, 250]), [300, 250])).to.be.equal(true); - }); - it(`test defaultSize`, function () { - expect(width).to.be.equal(300); - expect(height).to.be.equal(250); - }); - }); -}); diff --git a/test/spec/modules/dmdIdSystem_spec.js b/test/spec/modules/dmdIdSystem_spec.js index 3096a8e55f5..16c32f184a3 100644 --- a/test/spec/modules/dmdIdSystem_spec.js +++ b/test/spec/modules/dmdIdSystem_spec.js @@ -60,7 +60,7 @@ describe('Dmd ID System', function () { it('Should invoke callback with response from API call', function () { const callbackSpy = sinon.spy(); - const domain = utils.getWindowLocation() + const domain = utils.getWindowLocation().href; const callback = dmdIdSubmodule.getId(config).callback; callback(callbackSpy); const request = server.requests[0]; @@ -73,7 +73,7 @@ describe('Dmd ID System', function () { it('Should log error if API response is not valid', function () { const callbackSpy = sinon.spy(); - const domain = utils.getWindowLocation() + const domain = utils.getWindowLocation().href; const callback = dmdIdSubmodule.getId(config).callback; callback(callbackSpy); const request = server.requests[0]; diff --git a/test/spec/modules/dspxBidAdapter_spec.js b/test/spec/modules/dspxBidAdapter_spec.js index 2869385d7e7..841fc087613 100644 --- a/test/spec/modules/dspxBidAdapter_spec.js +++ b/test/spec/modules/dspxBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/dspxBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import { deepClone } from '../../../src/utils'; const ENDPOINT_URL = 'https://buyer.dspx.tv/request/'; const ENDPOINT_URL_DEV = 'https://dcbuyer.dspx.tv/request/'; @@ -65,7 +66,34 @@ describe('dspxAdapter', function () { 'adUnitCode': 'testDiv1', 'userId': { 'netId': '123', - 'uid2': '456' + 'uid2': {'id': '456'}, + 'pubcid': 'e09ab6a3-ae74-4f01-b2e8-81b141d6dc61', + 'id5id': { + 'uid': 'ID5-ZHMOcvSShIBZiIth_yYh9odjNFxVEmMQ_i5TArPfWw!ID5*dtrjfV5mPLasyya5TW2IE9oVzQZwx7xRPGyAYS4hcWkAAOoxoFef4bIoREpQys8x', + 'ext': { + 'linkType': 2 + } + }, + 'sharedid': { + 'id': '01EXPPGZ9C8NKG1MTXVHV98505', + 'third': '01EXPPGZ9C8NKG1MTXVHV98505' + } + }, + 'crumbs': { + 'pubcid': 'e09ab6a3-ae74-4f01-b2e8-81b141d6dc61' + }, + 'schain': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'example.com', + 'sid': '0', + 'hp': 1, + 'rid': 'bidrequestid', + 'domain': 'example.com' + } + ] } }, { @@ -111,7 +139,10 @@ describe('dspxAdapter', function () { 'mediaTypes': { 'video': { 'playerSize': [640, 480], - 'context': 'instream' + 'context': 'instream', + 'protocols': [1, 2], + 'playbackmethod': [2], + 'skip': 1 }, 'banner': { 'sizes': [ @@ -135,14 +166,53 @@ describe('dspxAdapter', function () { 'mediaTypes': { 'video': { 'playerSize': [640, 480], - 'context': 'instream' + 'context': 'instream', + 'protocols': [1, 2], + 'playbackmethod': [2], + 'skip': 1, + 'renderer': { + url: 'example.com/videoRenderer.js', + render: function (bid) { alert('test'); } + } } }, 'bidId': '30b31c1838de1e41', 'bidderRequestId': '22edbae2733bf67', 'auctionId': '1d1a030790a478', 'adUnitCode': 'testDiv4' - } + }, + { + 'bidder': 'dspx', + 'params': { + 'placement': '101', + 'devMode': true, + 'dev': { + 'endpoint': 'http://localhost', + 'placement': '107', + 'pfilter': {'test': 1} + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream', + 'mimes': ['video/mp4'], + 'protocols': [1, 2], + 'playbackmethod': [2], + 'skip': 1 + }, + 'banner': { + 'sizes': [ + [300, 250] + ] + } + }, + + 'bidId': '30b31c1838de1e4', + 'bidderRequestId': '22edbae2733bf67', + 'auctionId': '1d1a030790a478', + 'adUnitCode': 'testDiv3' + }, ]; @@ -163,7 +233,7 @@ describe('dspxAdapter', function () { expect(request1.method).to.equal('GET'); expect(request1.url).to.equal(ENDPOINT_URL); let data = request1.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); - expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e1&pbver=test&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&pfilter%5Bgdpr_consent%5D=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&pfilter%5Bgdpr%5D=true&bcat=IAB2%2CIAB4&dvt=desktop&did_netid=123&did_uid2=456&auctionId=1d1a030790a475&pbcode=testDiv1&media_types%5Bbanner%5D=300x250'); + expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e1&pbver=test&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bprivate_auction%5D=0&pfilter%5Bgeo%5D%5Bcountry%5D=DE&pfilter%5Bgdpr_consent%5D=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&pfilter%5Bgdpr%5D=true&bcat=IAB2%2CIAB4&dvt=desktop&did_netid=123&did_id5=ID5-ZHMOcvSShIBZiIth_yYh9odjNFxVEmMQ_i5TArPfWw!ID5*dtrjfV5mPLasyya5TW2IE9oVzQZwx7xRPGyAYS4hcWkAAOoxoFef4bIoREpQys8x&did_id5_linktype=2&did_uid2=456&did_sharedid=01EXPPGZ9C8NKG1MTXVHV98505&did_pubcid=e09ab6a3-ae74-4f01-b2e8-81b141d6dc61&did_cpubcid=e09ab6a3-ae74-4f01-b2e8-81b141d6dc61&schain%5Bver%5D=1.0&schain%5Bcomplete%5D=1&schain%5Bnodes%5D%5B0%5D%5Basi%5D=example.com&schain%5Bnodes%5D%5B0%5D%5Bsid%5D=0&schain%5Bnodes%5D%5B0%5D%5Bhp%5D=1&schain%5Bnodes%5D%5B0%5D%5Brid%5D=bidrequestid&schain%5Bnodes%5D%5B0%5D%5Bdomain%5D=example.com&auctionId=1d1a030790a475&pbcode=testDiv1&media_types%5Bbanner%5D=300x250'); }); var request2 = spec.buildRequests([bidRequests[1]], bidderRequest)[0]; @@ -193,14 +263,61 @@ describe('dspxAdapter', function () { expect(request4.method).to.equal('GET'); expect(request4.url).to.equal(ENDPOINT_URL_DEV); let data = request4.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); - expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e4&pbver=test&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv3&media_types%5Bvideo%5D=640x480&media_types%5Bbanner%5D=300x250'); + expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e4&pbver=test&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv3&media_types%5Bvideo%5D=640x480&media_types%5Bbanner%5D=300x250&vctx=instream&vpl%5Bprotocols%5D%5B0%5D=1&vpl%5Bprotocols%5D%5B1%5D=2&vpl%5Bplaybackmethod%5D%5B0%5D=2&vpl%5Bskip%5D=1'); }); var request5 = spec.buildRequests([bidRequests[4]], bidderRequestWithoutGdpr)[0]; it('sends bid video request to our endpoint via GET', function () { expect(request5.method).to.equal('GET'); let data = request5.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); - expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e41&pbver=test&vf=vast4&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv4&media_types%5Bvideo%5D=640x480'); + expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e41&pbver=test&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv4&media_types%5Bvideo%5D=640x480&vctx=instream&vf=vast4&vpl%5Bprotocols%5D%5B0%5D=1&vpl%5Bprotocols%5D%5B1%5D=2&vpl%5Bplaybackmethod%5D%5B0%5D=2&vpl%5Bskip%5D=1'); + }); + + var request6 = spec.buildRequests([bidRequests[5]], bidderRequestWithoutGdpr)[0]; + it('sends bid request without gdprConsent to our DEV endpoint with overriden DEV params via GET', function () { + expect(request6.method).to.equal('GET'); + expect(request6.url).to.equal('http://localhost'); + let data = request6.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=auto&alternative=prebid_js&inventory_item_id=107&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e4&pbver=test&pfilter%5Btest%5D=1&prebidDevMode=1&auctionId=1d1a030790a478&pbcode=testDiv3&media_types%5Bvideo%5D=640x480&media_types%5Bbanner%5D=300x250&vctx=instream&vpl%5Bmimes%5D%5B0%5D=video%2Fmp4&vpl%5Bprotocols%5D%5B0%5D=1&vpl%5Bprotocols%5D%5B1%5D=2&vpl%5Bplaybackmethod%5D%5B0%5D=2&vpl%5Bskip%5D=1'); + }); + + // bidfloor tests + const getFloorResponse = {currency: 'EUR', floor: 5}; + let testBidRequest = deepClone(bidRequests[1]); + let floorRequest = spec.buildRequests([testBidRequest], bidderRequestWithoutGdpr)[0]; + + // 1. getBidFloor not exist AND bidfloor not exist - no floorprice in request + it('bidfloor is not exists in request', function () { + expect(floorRequest.data).to.not.contain('floorprice'); + }); + + // 2. getBidFloor not exist AND pfilter.floorprice exist - use pfilter.floorprice property + it('bidfloor is equal 0.5', function () { + testBidRequest = deepClone(bidRequests[0]); + testBidRequest.params.pfilter = { + 'floorprice': 0.5 + }; + floorRequest = spec.buildRequests([testBidRequest], bidderRequestWithoutGdpr)[0]; + expect(floorRequest.data).to.contain('floorprice%5D=0.5'); + }); + + // 3. getBidFloor exist AND pfilter.floorprice not exist - use getFloor method + it('bidfloor is equal 5', function () { + testBidRequest = deepClone(bidRequests[1]); + testBidRequest.getFloor = () => getFloorResponse; + floorRequest = spec.buildRequests([testBidRequest], bidderRequestWithoutGdpr)[0]; + expect(floorRequest.data).to.contain('floorprice%5D=5'); + }); + + // 4. getBidFloor exist AND pfilter.floorprice exist -> use getFloor method + it('bidfloor is equal 0.35', function () { + testBidRequest = deepClone(bidRequests[0]); + testBidRequest.getFloor = () => getFloorResponse; + testBidRequest.params.pfilter = { + 'floorprice': 0.35 + }; + floorRequest = spec.buildRequests([testBidRequest], bidderRequestWithoutGdpr)[0]; + expect(floorRequest.data).to.contain('floorprice%5D=0.35'); }); }); @@ -212,7 +329,7 @@ describe('dspxAdapter', function () { 'width': '300', 'height': '250', 'type': 'sspHTML', - 'tag': '', + 'adTag': '', 'requestId': '220ed41385952a', 'currency': 'EUR', 'ttl': 60, @@ -233,7 +350,25 @@ describe('dspxAdapter', function () { 'currency': 'EUR', 'ttl': 60, 'netRevenue': true, - 'zone': '6682' + 'zone': '6682', + 'renderer': {id: 1, url: '//player.example.com', options: {}} + } + }; + let serverVideoResponseVastUrl = { + 'body': { + 'cpm': 5000000, + 'crid': 100500, + 'width': '300', + 'height': '250', + 'requestId': '220ed41385952a', + 'type': 'vast2', + 'currency': 'EUR', + 'ttl': 60, + 'netRevenue': true, + 'zone': '6682', + 'vastUrl': 'https://local/vasturl1', + 'videoCacheKey': 'cache_123', + 'bid_appendix': {'someField': 'someValue'} } }; @@ -246,10 +381,10 @@ describe('dspxAdapter', function () { dealId: '', currency: 'EUR', netRevenue: true, - ttl: 300, + ttl: 60, type: 'sspHTML', ad: '', - meta: {advertiserDomains: ['bdomain']} + meta: {advertiserDomains: ['bdomain']}, }, { requestId: '23beaa6af6cdde', cpm: 0.5, @@ -263,7 +398,24 @@ describe('dspxAdapter', function () { type: 'vast2', vastXml: '{"reason":7001,"status":"accepted"}', mediaType: 'video', - meta: {advertiserDomains: []} + meta: {advertiserDomains: []}, + renderer: {} + }, { + requestId: '23beaa6af6cdde', + cpm: 0.5, + width: 0, + height: 0, + creativeId: 100500, + dealId: '', + currency: 'EUR', + netRevenue: true, + ttl: 60, + type: 'vast2', + vastUrl: 'https://local/vasturl1', + videoCacheKey: 'cache_123', + mediaType: 'video', + meta: {advertiserDomains: []}, + someField: 'someValue' }]; it('should get the correct bid response by display ad', function () { @@ -287,7 +439,7 @@ describe('dspxAdapter', function () { 'mediaTypes': { 'video': { 'playerSize': [640, 480], - 'context': 'instream' + 'context': 'outstream' } }, 'data': { @@ -299,6 +451,25 @@ describe('dspxAdapter', function () { expect(result[0].meta.advertiserDomains.length).to.equal(0); }); + it('should get the correct dspx video bid response by display ad (vastUrl)', function () { + let bidRequest = [{ + 'method': 'GET', + 'url': ENDPOINT_URL, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + } + }, + 'data': { + 'bid_id': '30b31c1838de1e' + } + }]; + let result = spec.interpretResponse(serverVideoResponseVastUrl, bidRequest[0]); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[2])); + expect(result[0].meta.advertiserDomains.length).to.equal(0); + }); + it('handles empty bid response', function () { let response = { body: {} diff --git a/test/spec/modules/dxkultureBidAdapter_spec.js b/test/spec/modules/dxkultureBidAdapter_spec.js new file mode 100644 index 00000000000..bf76ddd0c8a --- /dev/null +++ b/test/spec/modules/dxkultureBidAdapter_spec.js @@ -0,0 +1,613 @@ +import {expect} from 'chai'; +import {spec} from 'modules/dxkultureBidAdapter.js'; + +const BANNER_REQUEST = { + 'bidderCode': 'dxkulture', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708', + 'bidderRequestId': 'requestId', + 'bidRequest': [{ + 'bidder': 'dxkulture', + 'params': { + 'placementId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'bidId': 'bidId1', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }, + { + 'bidder': 'dxkulture', + 'params': { + 'placementId': 123456, + }, + 'placementCode': 'div-gpt-dummy-placement-code', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'bidId': 'bidId2', + 'bidderRequestId': 'bidderRequestId', + 'auctionId': 'auctionId-56a2-4f71-9098-720a68f2f708' + }], + 'start': 1487883186070, + 'auctionStart': 1487883186069, + 'timeout': 3000 +}; + +const RESPONSE = { + 'headers': null, + 'body': { + 'id': 'responseId', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'bidId1', + 'impid': 'bidId1', + 'price': 0.18, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 334553, + 'auction_id': 514667951122925701, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + }, + { + 'id': 'bidId2', + 'impid': 'bidId2', + 'price': 0.1, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 386046, + 'auction_id': 517067951122925501, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'dxkulture' + } + ], + 'ext': { + 'usersync': { + 'sovrn': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlsovrn', + 'type': 'iframe' + } + ] + }, + 'appnexus': { + 'status': 'none', + 'syncs': [ + { + 'url': 'urlappnexus', + 'type': 'pixel' + } + ] + } + }, + 'responsetimemillis': { + 'appnexus': 127 + } + } + } +}; + +const DEFAULT_NETWORK_ID = 1; + +describe('dxkultureBidAdapter:', function () { + let videoBidRequest; + + const VIDEO_REQUEST = { + 'bidderCode': 'dxkulture', + 'auctionId': 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4', + 'bidderRequestId': '34feaad34lkj2', + 'bids': videoBidRequest, + 'auctionStart': 1520001292880, + 'timeout': 3000, + 'start': 1520001292884, + 'doneCbCallCount': 0, + 'refererInfo': { + 'numIframes': 1, + 'reachedTop': true, + 'referer': 'test.com' + } + }; + + beforeEach(function () { + videoBidRequest = { + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], + } + }, + bidder: 'dxkulture', + sizes: [640, 480], + bidId: '30b3efwfwe1e', + adUnitCode: 'video1', + params: { + video: { + playerWidth: 640, + playerHeight: 480, + mimes: ['video/mp4', 'application/javascript'], + protocols: [2, 5], + api: [2], + position: 1, + delivery: [2], + sid: 134, + rewarded: 1, + placement: 1, + hp: 1, + inventoryid: 123 + }, + site: { + id: 1, + page: 'https://test.com', + referrer: 'http://test.com' + }, + publisherId: 'km123' + } + }; + }); + + describe('isBidRequestValid', function () { + context('basic validation', function () { + beforeEach(function () { + // Basic Valid BidRequest + this.bid = { + bidder: 'dxkulture', + mediaTypes: { + banner: { + sizes: [[250, 300]] + } + }, + params: { + placementId: 'placementId', + publisherId: 'publisherId', + } + }; + }); + + it('should accept request if placementId and publisherId are passed', function () { + expect(spec.isBidRequestValid(this.bid)).to.be.true; + }); + + it('reject requests without params', function () { + this.bid.params = {}; + expect(spec.isBidRequestValid(this.bid)).to.be.false; + }); + + it('returns false when banner mediaType does not exist', function () { + this.bid.mediaTypes = {} + expect(spec.isBidRequestValid(this.bid)).to.be.false; + }); + }); + + context('banner validation', function () { + it('returns true when banner sizes are defined', function () { + const bid = { + bidder: 'dxkulture', + mediaTypes: { + banner: { + sizes: [[250, 300]] + } + }, + params: { + placementId: 'placementId', + publisherId: 'publisherId', + } + }; + + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + + it('returns false when banner sizes are invalid', function () { + const invalidSizes = [ + undefined, + '2:1', + 123, + 'test' + ]; + + invalidSizes.forEach((sizes) => { + const bid = { + bidder: 'dxkulture', + mediaTypes: { + banner: { + sizes + } + }, + params: { + placementId: 'placementId', + publisherId: 'publisherId', + } + }; + + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + }); + + context('video validation', function () { + beforeEach(function () { + // Basic Valid BidRequest + this.bid = { + bidder: 'dxkulture', + mediaTypes: { + video: { + playerSize: [[300, 50]], + context: 'instream', + mimes: ['foo', 'bar'], + protocols: [1, 2] + } + }, + params: { + placementId: 'placementId', + publisherId: 'publisherId', + } + }; + }); + + it('should return true (skip validations) when e2etest = true', function () { + this.bid.params = { + e2etest: true + }; + expect(spec.isBidRequestValid(this.bid)).to.equal(true); + }); + + it('returns false when video context is not defined', function () { + delete this.bid.mediaTypes.video.context; + + expect(spec.isBidRequestValid(this.bid)).to.be.false; + }); + + it('returns false when video playserSize is invalid', function () { + const invalidSizes = [ + undefined, + '2:1', + 123, + 'test' + ]; + + invalidSizes.forEach((playerSize) => { + this.bid.mediaTypes.video.playerSize = playerSize; + expect(spec.isBidRequestValid(this.bid)).to.be.false; + }); + }); + + it('returns false when video mimes is invalid', function () { + const invalidMimes = [ + undefined, + 'test', + 1, + [] + ] + + invalidMimes.forEach((mimes) => { + this.bid.mediaTypes.video.mimes = mimes; + expect(spec.isBidRequestValid(this.bid)).to.be.false; + }) + }); + + it('returns false when video protocols is invalid', function () { + const invalidMimes = [ + undefined, + 'test', + 1, + [] + ] + + invalidMimes.forEach((protocols) => { + this.bid.mediaTypes.video.protocols = protocols; + expect(spec.isBidRequestValid(this.bid)).to.be.false; + }) + }); + }); + }); + + describe('buildRequests', function () { + context('when mediaType is banner', function () { + it('creates request data', function () { + let request = spec.buildRequests(BANNER_REQUEST.bidRequest, BANNER_REQUEST); + + expect(request).to.exist.and.to.be.a('object'); + const payload = JSON.parse(request.data); + expect(payload.imp[0]).to.have.property('id', BANNER_REQUEST.bidRequest[0].bidId); + expect(payload.imp[1]).to.have.property('id', BANNER_REQUEST.bidRequest[1].bidId); + }); + + it('has gdpr data if applicable', function () { + const req = Object.assign({}, BANNER_REQUEST, { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true, + } + }); + let request = spec.buildRequests(BANNER_REQUEST.bidRequest, req); + + const payload = JSON.parse(request.data); + expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); + expect(payload.regs.ext).to.have.property('gdpr', 1); + }); + + it('should properly forward eids parameters', function () { + const req = Object.assign({}, BANNER_REQUEST); + req.bidRequest[0].userIdAsEids = [ + { + source: 'dummy.com', + uids: [ + { + id: 'd6d0a86c-20c6-4410-a47b-5cba383a698a', + atype: 1 + } + ] + }]; + let request = spec.buildRequests(req.bidRequest, req); + + const payload = JSON.parse(request.data); + expect(payload.user.ext.eids[0].source).to.equal('dummy.com'); + expect(payload.user.ext.eids[0].uids[0].id).to.equal('d6d0a86c-20c6-4410-a47b-5cba383a698a'); + expect(payload.user.ext.eids[0].uids[0].atype).to.equal(1); + }); + }); + + context('when mediaType is video', function () { + it('should create a POST request for every bid', function () { + const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST); + expect(requests.method).to.equal('POST'); + expect(requests.url.trim()).to.equal(spec.ENDPOINT + '?pid=' + videoBidRequest.params.publisherId + '&nId=' + DEFAULT_NETWORK_ID); + }); + + it('should attach request data', function () { + const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST); + const data = JSON.parse(requests.data); + const [width, height] = videoBidRequest.sizes; + const VERSION = '1.0.0'; + expect(data.imp[0].video.w).to.equal(width); + expect(data.imp[0].video.h).to.equal(height); + expect(data.imp[0].bidfloor).to.equal(videoBidRequest.params.bidfloor); + expect(data.ext.prebidver).to.equal('$prebid.version$'); + expect(data.ext.adapterver).to.equal(spec.VERSION); + }); + + it('should set pubId to e2etest when bid.params.e2etest = true', function () { + videoBidRequest.params.e2etest = true; + const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST); + expect(requests.method).to.equal('POST'); + expect(requests.url).to.equal(spec.ENDPOINT + '?pid=e2etest&nId=' + DEFAULT_NETWORK_ID); + }); + + it('should attach End 2 End test data', function () { + videoBidRequest.params.e2etest = true; + const requests = spec.buildRequests([videoBidRequest], VIDEO_REQUEST); + const data = JSON.parse(requests.data); + expect(data.imp[0].bidfloor).to.not.exist; + expect(data.imp[0].video.w).to.equal(640); + expect(data.imp[0].video.h).to.equal(480); + }); + }); + }); + + describe('interpretResponse', function () { + context('when mediaType is banner', function () { + it('have bids', function () { + let bids = spec.interpretResponse(RESPONSE, BANNER_REQUEST); + expect(bids).to.be.an('array').that.is.not.empty; + validateBidOnIndex(0); + validateBidOnIndex(1); + + function validateBidOnIndex(index) { + expect(bids[index]).to.have.property('currency', 'USD'); + expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].impid); + expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price); + expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w); + expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); + expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); + expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); + expect(bids[index].meta).to.have.property('advertiserDomains', RESPONSE.body.seatbid[0].bid[index].adomain); + expect(bids[index]).to.have.property('ttl', 300); + expect(bids[index]).to.have.property('netRevenue', true); + } + }); + + it('handles empty response', function () { + const EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {}}); + const bids = spec.interpretResponse(EMPTY_RESP, BANNER_REQUEST); + + expect(bids).to.be.empty; + }); + }); + + context('when mediaType is video', function () { + it('should return no bids if the response is not valid', function () { + const bidResponse = spec.interpretResponse({ + body: null + }, { + videoBidRequest + }); + expect(bidResponse.length).to.equal(0); + }); + + it('should return no bids if the response "nurl" and "adm" are missing', function () { + const serverResponse = { + seatbid: [{ + bid: [{ + price: 6.01 + }] + }] + }; + const bidResponse = spec.interpretResponse({ + body: serverResponse + }, { + videoBidRequest + }); + expect(bidResponse.length).to.equal(0); + }); + + it('should return no bids if the response "price" is missing', function () { + const serverResponse = { + seatbid: [{ + bid: [{ + adm: '' + }] + }] + }; + const bidResponse = spec.interpretResponse({ + body: serverResponse + }, { + videoBidRequest + }); + expect(bidResponse.length).to.equal(0); + }); + + it('should return a valid video bid response with just "adm"', function () { + const serverResponse = { + id: '123', + seatbid: [{ + bid: [{ + id: 1, + adid: 123, + impid: 456, + crid: 2, + price: 6.01, + adm: '', + adomain: [ + 'dxkulture.com' + ], + w: 640, + h: 480, + ext: { + prebid: { + type: 'video' + }, + } + }] + }], + cur: 'USD' + }; + const bidResponse = spec.interpretResponse({ + body: serverResponse + }, { + videoBidRequest + }); + let o = { + requestId: serverResponse.seatbid[0].bid[0].impid, + ad: '', + bidderCode: spec.code, + cpm: serverResponse.seatbid[0].bid[0].price, + creativeId: serverResponse.seatbid[0].bid[0].crid, + vastXml: serverResponse.seatbid[0].bid[0].adm, + width: 640, + height: 480, + mediaType: 'video', + currency: 'USD', + ttl: 300, + netRevenue: true, + meta: { + advertiserDomains: ['dxkulture.com'] + } + }; + expect(bidResponse[0]).to.deep.equal(o); + }); + + it('should default ttl to 300', function () { + const serverResponse = { + seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], + cur: 'USD' + }; + const bidResponse = spec.interpretResponse({body: serverResponse}, {videoBidRequest}); + expect(bidResponse[0].ttl).to.equal(300); + }); + it('should not allow ttl above 3601, default to 300', function () { + videoBidRequest.params.video.ttl = 3601; + const serverResponse = { + seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], + cur: 'USD' + }; + const bidResponse = spec.interpretResponse({body: serverResponse}, {videoBidRequest}); + expect(bidResponse[0].ttl).to.equal(300); + }); + it('should not allow ttl below 1, default to 300', function () { + videoBidRequest.params.video.ttl = 0; + const serverResponse = { + seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], + cur: 'USD' + }; + const bidResponse = spec.interpretResponse({body: serverResponse}, {videoBidRequest}); + expect(bidResponse[0].ttl).to.equal(300); + }); + }); + }); + + describe('getUserSyncs', function () { + it('handles no parameters', function () { + let opts = spec.getUserSyncs({}); + expect(opts).to.be.an('array').that.is.empty; + }); + it('returns non if sync is not allowed', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}); + + expect(opts).to.be.an('array').that.is.empty; + }); + + it('iframe sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('iframe'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['sovrn'].syncs[0].url); + }); + + it('pixel sync enabled should return results', function () { + let opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('image'); + expect(opts[0].url).to.equal(RESPONSE.body.ext.usersync['appnexus'].syncs[0].url); + }); + + it('all sync enabled should return all results', function () { + let opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [RESPONSE]); + + expect(opts.length).to.equal(2); + }); + }); +}) +; diff --git a/test/spec/modules/e_volutionBidAdapter_spec.js b/test/spec/modules/e_volutionBidAdapter_spec.js index 1f60edda0ef..d488048060a 100644 --- a/test/spec/modules/e_volutionBidAdapter_spec.js +++ b/test/spec/modules/e_volutionBidAdapter_spec.js @@ -2,7 +2,7 @@ import {expect} from 'chai'; import {spec} from '../../../modules/e_volutionBidAdapter.js'; describe('EvolutionTechBidAdapter', function () { - let bid = { + let bids = [{ bidId: '23fhj33i987f', bidder: 'e_volution', params: { @@ -12,21 +12,55 @@ describe('EvolutionTechBidAdapter', function () { banner: { sizes: [[300, 250]], } + }, + userId: { + id5id: 'id5id' + } + }, { + bidId: '23fhj33i987f', + bidder: 'e_volution', + params: { + placementId: 0 + }, + mediaTypes: { + video: { + playerSize: [300, 250] + } + }, + userId: { + id5id: 'id5id' + } + }, { + bidId: '23fhj33i987f', + bidder: 'e_volution', + params: { + placementId: 0 + }, + mediaTypes: { + native: {} + }, + userId: { + id5id: 'id5id' } + }]; + + const bidderRequest = { + uspConsent: 'uspConsent', + gdprConsent: 'gdprConsent' }; describe('isBidRequestValid', function () { it('Should return true if there are bidId, params and placementId parameters present', function () { - expect(spec.isBidRequestValid(bid)).to.be.true; + expect(spec.isBidRequestValid(bids[0])).to.be.true; }); it('Should return false if at least one of parameters is not present', function () { - delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.be.false; + delete bids[0].params.placementId; + expect(spec.isBidRequestValid(bids[0])).to.be.false; }); }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bid]); + let serverRequest = spec.buildRequests(bids, bidderRequest); it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -42,18 +76,35 @@ describe('EvolutionTechBidAdapter', function () { it('Returns valid data if array of bids is valid', function () { let data = serverRequest.data; expect(data).to.be.an('object'); - expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'ccpa', 'gdpr'); expect(data.deviceWidth).to.be.a('number'); expect(data.deviceHeight).to.be.a('number'); expect(data.language).to.be.a('string'); expect(data.secure).to.be.within(0, 1); expect(data.host).to.be.a('string'); expect(data.page).to.be.a('string'); + expect(data.ccpa).to.be.equal('uspConsent'); + expect(data.gdpr).to.be.equal('gdprConsent'); + let placement = data['placements'][0]; - expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'bidfloor'); + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'sizes', 'bidfloor', 'eids'); expect(placement.placementId).to.equal(0); expect(placement.bidId).to.equal('23fhj33i987f'); expect(placement.traffic).to.equal('banner'); + + placement = data['placements'][1]; + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'bidfloor', 'eids', 'wPlayer', 'hPlayer', + 'minduration', 'maxduration', 'mimes', 'protocols', 'startdelay', 'placement', 'skip', 'skipafter', 'minbitrate', + 'maxbitrate', 'delivery', 'playbackmethod', 'api', 'linearity'); + expect(placement.placementId).to.equal(0); + expect(placement.bidId).to.equal('23fhj33i987f'); + expect(placement.traffic).to.equal('video'); + + placement = data['placements'][2]; + expect(placement).to.have.keys('placementId', 'bidId', 'traffic', 'bidfloor', 'eids', 'native'); + expect(placement.placementId).to.equal(0); + expect(placement.bidId).to.equal('23fhj33i987f'); + expect(placement.traffic).to.equal('native'); }); it('Returns empty data if no valid requests are passed', function () { serverRequest = spec.buildRequests([]); @@ -76,7 +127,9 @@ describe('EvolutionTechBidAdapter', function () { netRevenue: true, currency: 'USD', dealId: '1', - meta: {} + meta: { + adomain: [ 'example.com' ] + } }] }; let bannerResponses = spec.interpretResponse(banner); @@ -106,7 +159,9 @@ describe('EvolutionTechBidAdapter', function () { netRevenue: true, currency: 'USD', dealId: '1', - meta: {} + meta: { + adomain: [ 'example.com' ] + } }] }; let videoResponses = spec.interpretResponse(video); @@ -139,7 +194,9 @@ describe('EvolutionTechBidAdapter', function () { creativeId: '2', netRevenue: true, currency: 'USD', - meta: {} + meta: { + adomain: [ 'example.com' ] + } }] }; let nativeResponses = spec.interpretResponse(native); diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 9edda3c9e95..1597790e652 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -82,20 +82,65 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('merkleId', function() { + it('merkleId (legacy) - supports single id', function() { const userId = { merkleId: { id: 'some-random-id-value', keyID: 1 } }; const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); expect(newEids[0]).to.deep.equal({ source: 'merkleinc.com', + uids: [{ + id: 'some-random-id-value', + atype: 3, + ext: { keyID: 1 } + }] + }); + }); + + it('merkleId supports multiple source providers', function() { + const userId = { + merkleId: [{ + id: 'some-random-id-value', ext: { enc: 1, keyID: 16, idName: 'pamId', ssp: 'ssp1' } + }, { + id: 'another-random-id-value', + ext: { + enc: 1, + idName: 'pamId', + third: 4, + ssp: 'ssp2' + } + }] + } + + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(2); + expect(newEids[0]).to.deep.equal({ + source: 'ssp1.merkleinc.com', uids: [{id: 'some-random-id-value', atype: 3, - ext: { keyID: 1 - }}] + ext: { + enc: 1, + keyID: 16, + idName: 'pamId', + ssp: 'ssp1' + } + }] + }); + expect(newEids[1]).to.deep.equal({ + source: 'ssp2.merkleinc.com', + uids: [{id: 'another-random-id-value', + atype: 3, + ext: { + third: 4, + enc: 1, + idName: 'pamId', + ssp: 'ssp2' + } + }] }); }); @@ -127,6 +172,138 @@ describe('eids array generation for known sub-modules', function() { }); }); + it('bidswitch', function() { + const userId = { + bidswitch: {'id': 'sample_id'} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'bidswitch.net', + uids: [{ + id: 'sample_id', + atype: 3 + }] + }); + }); + + it('bidswitch with ext', function() { + const userId = { + bidswitch: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'bidswitch.net', + uids: [{ + id: 'sample_id', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + + it('medianet', function() { + const userId = { + medianet: {'id': 'sample_id'} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'media.net', + uids: [{ + id: 'sample_id', + atype: 3 + }] + }); + }); + + it('medianet with ext', function() { + const userId = { + medianet: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'media.net', + uids: [{ + id: 'sample_id', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + + it('magnite', function() { + const userId = { + magnite: {'id': 'sample_id'} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'rubiconproject.com', + uids: [{ + id: 'sample_id', + atype: 3 + }] + }); + }); + + it('magnite with ext', function() { + const userId = { + magnite: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'rubiconproject.com', + uids: [{ + id: 'sample_id', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + + it('index', function() { + const userId = { + index: {'id': 'sample_id'} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveintent.indexexchange.com', + uids: [{ + id: 'sample_id', + atype: 3 + }] + }); + }); + + it('index with ext', function() { + const userId = { + index: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'liveintent.indexexchange.com', + uids: [{ + id: 'sample_id', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + it('liveIntentId; getValue call and NO ext', function() { const userId = { lipb: { @@ -213,18 +390,6 @@ describe('eids array generation for known sub-modules', function() { }); }); - it('NextRollId', function() { - const userId = { - nextrollId: 'some-random-id-value' - }; - const newEids = createEidsArray(userId); - expect(newEids.length).to.equal(1); - expect(newEids[0]).to.deep.equal({ - source: 'nextroll.com', - uids: [{id: 'some-random-id-value', atype: 1}] - }); - }); - it('zeotapIdPlus', function() { const userId = { IDP: 'some-random-id-value' @@ -269,6 +434,7 @@ describe('eids array generation for known sub-modules', function() { }] }); }); + it('uid2', function() { const userId = { uid2: {'id': 'Sample_AD_Token'} @@ -283,6 +449,40 @@ describe('eids array generation for known sub-modules', function() { }] }); }); + + it('uid2 with ext', function() { + const userId = { + uid2: {'id': 'Sample_AD_Token', 'ext': {'provider': 'some.provider.com'}} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'uidapi.com', + uids: [{ + id: 'Sample_AD_Token', + atype: 3, + ext: { + provider: 'some.provider.com' + } + }] + }); + }); + + it('euid', function() { + const userId = { + euid: {'id': 'Sample_AD_Token'} + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'euid.eu', + uids: [{ + id: 'Sample_AD_Token', + atype: 3 + }] + }); + }); + it('kpuid', function() { const userId = { kpuid: 'Sample_Token' @@ -297,6 +497,22 @@ describe('eids array generation for known sub-modules', function() { }] }); }); + + it('tncid', function() { + const userId = { + tncid: 'TEST_TNCID' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'thenewco.it', + uids: [{ + id: 'TEST_TNCID', + atype: 3 + }] + }); + }); + it('pubProvidedId', function() { const userId = { pubProvidedId: [{ @@ -341,7 +557,7 @@ describe('eids array generation for known sub-modules', function() { const [eid] = createEidsArray(userId); expect(eid).to.deep.equal({ - source: 'amxrtb.com', + source: 'amxdt.net', uids: [{ atype: 1, id, @@ -363,8 +579,116 @@ describe('eids array generation for known sub-modules', function() { }] }); }); + + it('operaId', function() { + const userId = { + operaId: 'some-random-id-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 't.adx.opera.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }); + }); + + it('33acrossId', function() { + const userId = { + '33acrossId': { + envelope: 'some-random-id-value' + } + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: '33across.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }); + }); + + it('czechAdId', () => { + const id = 'some-random-id-value' + const userId = { czechAdId: id }; + const [eid] = createEidsArray(userId); + expect(eid).to.deep.equal({ + source: 'czechadid.cz', + uids: [{ id: 'some-random-id-value', atype: 1 }] + }); + }); + + describe('ftrackId', () => { + it('should return the correct EID schema', () => { + // This is the schema returned from the ftrack decode() method + expect(createEidsArray({ + ftrackId: { + uid: 'test-device-id', + ext: { + DeviceID: 'test-device-id', + SingleDeviceID: 'test-single-device-id', + HHID: 'test-household-id' + } + }, + foo: { + bar: 'baz' + }, + lorem: { + ipsum: '' + } + })).to.deep.equal([{ + source: 'flashtalking.com', + uids: [{ + atype: 1, + id: 'test-device-id', + ext: { + DeviceID: 'test-device-id', + SingleDeviceID: 'test-single-device-id', + HHID: 'test-household-id' + } + }] + }]); + }); + }); + + describe('imuid', function() { + it('should return the correct EID schema with imuid', function() { + const userId = { + imuid: 'testimuid' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'intimatemerger.com', + uids: [{ + id: 'testimuid', + atype: 1 + }] + }); + }); + + it('should return the correct EID schema with imppid', function() { + const userId = { + imppid: 'imppid-value-imppid-value-imppid-value' + }; + const newEids = createEidsArray(userId); + expect(newEids.length).to.equal(1); + expect(newEids[0]).to.deep.equal({ + source: 'ppid.intimatemerger.com', + uids: [{ + id: 'imppid-value-imppid-value-imppid-value', + atype: 1 + }] + }); + }); + }); }); -describe('Negative case', function() { + +describe('Negative case', function () { it('eids array generation for UN-known sub-module', function() { // UnknownCommonId const userId = { diff --git a/test/spec/modules/emtvBidAdapter_spec.js b/test/spec/modules/emtvBidAdapter_spec.js new file mode 100644 index 00000000000..4f95a0cc094 --- /dev/null +++ b/test/spec/modules/emtvBidAdapter_spec.js @@ -0,0 +1,400 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/emtvBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'emtv' +const adUrl = 'https://us-east-ep.engagemedia.tv/pbjs'; +const syncUrl = 'https://cs.engagemedia.tv'; + +describe('EMTVBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal(adUrl); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal(`${syncUrl}/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0`) + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal(`${syncUrl}/image?pbjs=1&ccpa_consent=1---&coppa=0`) + }); + }); +}); diff --git a/test/spec/modules/emx_digitalBidAdapter_spec.js b/test/spec/modules/emx_digitalBidAdapter_spec.js deleted file mode 100644 index 043a8a3709e..00000000000 --- a/test/spec/modules/emx_digitalBidAdapter_spec.js +++ /dev/null @@ -1,737 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/emx_digitalBidAdapter.js'; -import * as utils from 'src/utils.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; - -describe('emx_digital Adapter', function () { - describe('callBids', function () { - const adapter = newBidder(spec); - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - describe('banner request validity', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let badBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - } - }, - 'adUnitCode': 'adunit-code', - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noBid = {}; - let otherBid = { - 'bidder': 'emxdigital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noMediaSizeBid = { - 'bidder': 'emxdigital', - 'params': { - 'tagid': '25251' - }, - 'mediaTypes': { - 'banner': {} - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - expect(spec.isBidRequestValid(badBid)).to.equal(false); - expect(spec.isBidRequestValid(noBid)).to.equal(false); - expect(spec.isBidRequestValid(otherBid)).to.equal(false); - expect(spec.isBidRequestValid(noMediaSizeBid)).to.equal(false); - }); - }); - - describe('video request validity', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - let noInstreamBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': { - 'protocols': [1, 7] - } - }, - 'mediaTypes': { - 'video': { - 'context': 'something_random' - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - let outstreamBid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - expect(spec.isBidRequestValid(noInstreamBid)).to.equal(false); - expect(spec.isBidRequestValid(outstreamBid)).to.equal(true); - }); - - it('should contain tagid param', function () { - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: {}, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - bidder: 'emx_digital', - params: { - tagid: '123' - }, - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - } - })).to.equal(true); - }); - }); - }); - - describe('buildRequests', function () { - let bidderRequest = { - 'bidderCode': 'emx_digital', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'bidderRequestId': '22edbae3120bf6', - 'timeout': 1500, - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'https://example.com/index.html?pbjs_debug=true' - }, - 'bids': [{ - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251' - }, - 'adUnitCode': 'adunit-code', - 'mediaTypes': { - 'banner': { - 'sizes': [ - [300, 250], - [300, 600] - ] - } - }, - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'auctionId': 'e19f1eff-8b27-42a6-888d-9674e5a6130c', - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - }] - }; - let request = spec.buildRequests(bidderRequest.bids, bidderRequest); - - it('sends bid request to ENDPOINT via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('contains the correct options', function () { - expect(request.options.withCredentials).to.equal(true); - }); - - it('contains a properly formatted endpoint url', function () { - const url = request.url.split('?'); - const queryParams = url[1].split('&'); - expect(queryParams[0]).to.match(new RegExp('^t=\d*', 'g')); - expect(queryParams[1]).to.match(new RegExp('^ts=\d*', 'g')); - }); - - it('builds bidfloor value from bid param when getFloor function does not exist', function () { - const bidRequestWithFloor = utils.deepClone(bidderRequest.bids); - bidRequestWithFloor[0].params.bidfloor = 1; - const requestWithFloor = spec.buildRequests(bidRequestWithFloor, bidderRequest); - const data = JSON.parse(requestWithFloor.data); - expect(data.imp[0].bidfloor).to.equal(bidRequestWithFloor[0].params.bidfloor); - }); - - it('builds bidfloor value from getFloor function when it exists', function () { - const floorResponse = { currency: 'USD', floor: 3 }; - const bidRequestWithGetFloor = utils.deepClone(bidderRequest.bids); - bidRequestWithGetFloor[0].getFloor = () => floorResponse; - const requestWithGetFloor = spec.buildRequests(bidRequestWithGetFloor, bidderRequest); - const data = JSON.parse(requestWithGetFloor.data); - expect(data.imp[0].bidfloor).to.equal(3); - }); - - it('builds bidfloor value from getFloor when both floor and getFloor function exists', function () { - const floorResponse = { currency: 'USD', floor: 3 }; - const bidRequestWithBothFloors = utils.deepClone(bidderRequest.bids); - bidRequestWithBothFloors[0].params.bidfloor = 1; - bidRequestWithBothFloors[0].getFloor = () => floorResponse; - const requestWithBothFloors = spec.buildRequests(bidRequestWithBothFloors, bidderRequest); - const data = JSON.parse(requestWithBothFloors.data); - expect(data.imp[0].bidfloor).to.equal(3); - }); - - it('empty bidfloor value when floor and getFloor is not defined', function () { - const bidRequestWithoutFloor = utils.deepClone(bidderRequest.bids); - const requestWithoutFloor = spec.buildRequests(bidRequestWithoutFloor, bidderRequest); - const data = JSON.parse(requestWithoutFloor.data); - expect(data.imp[0].bidfloor).to.not.exist; - }); - - it('builds request properly', function () { - const data = JSON.parse(request.data); - expect(Array.isArray(data.imp)).to.equal(true); - expect(data.id).to.equal(bidderRequest.auctionId); - expect(data.imp.length).to.equal(1); - expect(data.imp[0].id).to.equal('30b31c2501de1e'); - expect(data.imp[0].tid).to.equal('d7b773de-ceaa-484d-89ca-d9f51b8d61ec'); - expect(data.imp[0].tagid).to.equal('25251'); - expect(data.imp[0].secure).to.equal(0); - expect(data.imp[0].vastXml).to.equal(undefined); - }); - - it('properly sends site information and protocol', function () { - request = spec.buildRequests(bidderRequest.bids, bidderRequest); - request = JSON.parse(request.data); - expect(request.site).to.have.property('domain', 'example.com'); - expect(request.site).to.have.property('page', 'https://example.com/index.html?pbjs_debug=true'); - expect(request.site).to.have.property('ref', window.top.document.referrer); - }); - - it('builds correctly formatted request banner object', function () { - let bidRequestWithBanner = utils.deepClone(bidderRequest.bids); - let request = spec.buildRequests(bidRequestWithBanner, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.equal(undefined); - expect(data.imp[0].banner).to.exist.and.to.be.a('object'); - expect(data.imp[0].banner.w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); - expect(data.imp[0].banner.format[0].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][0]); - expect(data.imp[0].banner.format[0].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[0][1]); - expect(data.imp[0].banner.format[1].w).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][0]); - expect(data.imp[0].banner.format[1].h).to.equal(bidRequestWithBanner[0].mediaTypes.banner.sizes[1][1]); - }); - - it('builds correctly formatted request video object for instream', function () { - let bidRequestWithVideo = utils.deepClone(bidderRequest.bids); - bidRequestWithVideo[0].mediaTypes = { - video: { - context: 'instream', - playerSize: [[640, 480]] - }, - }; - bidRequestWithVideo[0].params.video = {}; - let request = spec.buildRequests(bidRequestWithVideo, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist.and.to.be.a('object'); - expect(data.imp[0].video.w).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][0]); - expect(data.imp[0].video.h).to.equal(bidRequestWithVideo[0].mediaTypes.video.playerSize[0][1]); - }); - - it('builds correctly formatted request video object for outstream', function () { - let bidRequestWithOutstreamVideo = utils.deepClone(bidderRequest.bids); - bidRequestWithOutstreamVideo[0].mediaTypes = { - video: { - context: 'outstream', - playerSize: [[640, 480]] - }, - }; - bidRequestWithOutstreamVideo[0].params.video = {}; - let request = spec.buildRequests(bidRequestWithOutstreamVideo, bidderRequest); - const data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist.and.to.be.a('object'); - expect(data.imp[0].video.w).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][0]); - expect(data.imp[0].video.h).to.equal(bidRequestWithOutstreamVideo[0].mediaTypes.video.playerSize[0][1]); - }); - - it('shouldn\'t contain a user obj without GDPR information', function () { - let request = spec.buildRequests(bidderRequest.bids, bidderRequest) - request = JSON.parse(request.data) - expect(request).to.not.have.property('user'); - }); - - it('should have the right gdpr info when enabled', function () { - let consentString = 'OIJSZsOAFsABAB8EMXZZZZZ+A=='; - const gdprBidderRequest = utils.deepClone(bidderRequest); - gdprBidderRequest.gdprConsent = { - 'consentString': consentString, - 'gdprApplies': true - }; - let request = spec.buildRequests(gdprBidderRequest.bids, gdprBidderRequest); - - request = JSON.parse(request.data) - expect(request.regs.ext).to.have.property('gdpr', 1); - expect(request.user.ext).to.have.property('consent', consentString); - }); - - it('should\'t contain consent string if gdpr isn\'t applied', function () { - const nonGdprBidderRequest = utils.deepClone(bidderRequest); - nonGdprBidderRequest.gdprConsent = { - 'gdprApplies': false - }; - let request = spec.buildRequests(nonGdprBidderRequest.bids, nonGdprBidderRequest); - request = JSON.parse(request.data) - expect(request.regs.ext).to.have.property('gdpr', 0); - expect(request).to.not.have.property('user'); - }); - - it('should add us privacy info to request', function() { - const uspBidderRequest = utils.deepClone(bidderRequest); - let consentString = '1YNN'; - uspBidderRequest.uspConsent = consentString; - let request = spec.buildRequests(uspBidderRequest.bids, uspBidderRequest); - request = JSON.parse(request.data); - expect(request.us_privacy).to.exist; - expect(request.us_privacy).to.exist.and.to.equal(consentString); - }); - - it('should add schain object to request', function() { - const schainBidderRequest = utils.deepClone(bidderRequest); - schainBidderRequest.bids[0].schain = { - 'complete': 1, - 'ver': '1.0', - 'nodes': [ - { - 'asi': 'testing.com', - 'sid': 'abc', - 'hp': 1 - } - ] - }; - let request = spec.buildRequests(schainBidderRequest.bids, schainBidderRequest); - request = JSON.parse(request.data); - expect(request.source.ext.schain).to.exist; - expect(request.source.ext.schain).to.have.property('complete', 1); - expect(request.source.ext.schain).to.have.property('ver', '1.0'); - expect(request.source.ext.schain.nodes[0].asi).to.equal(schainBidderRequest.bids[0].schain.nodes[0].asi); - }); - - it('should add liveramp identitylink id to request', () => { - const idl_env = '123'; - const bidRequestWithID = utils.deepClone(bidderRequest); - bidRequestWithID.userId = { idl_env }; - let requestWithID = spec.buildRequests(bidRequestWithID.bids, bidRequestWithID); - requestWithID = JSON.parse(requestWithID.data); - expect(requestWithID.user.ext.eids[0]).to.deep.equal({ - source: 'liveramp.com', - uids: [{ - id: idl_env, - ext: { - rtiPartner: 'idl' - } - }] - }); - }); - - it('should add gpid to request if present', () => { - const gpid = '/12345/my-gpt-tag-0'; - let bid = utils.deepClone(bidderRequest.bids[0]); - bid.ortb2Imp = { ext: { data: { adserver: { adslot: gpid } } } }; - bid.ortb2Imp = { ext: { data: { pbadslot: gpid } } }; - let requestWithGPID = spec.buildRequests([bid], bidderRequest); - requestWithGPID = JSON.parse(requestWithGPID.data); - expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid); - }); - - it('should add UID 2.0 to request', () => { - const uid2 = { id: '456' }; - const bidRequestWithUID = utils.deepClone(bidderRequest); - bidRequestWithUID.userId = { uid2 }; - let requestWithUID = spec.buildRequests(bidRequestWithUID.bids, bidRequestWithUID); - requestWithUID = JSON.parse(requestWithUID.data); - expect(requestWithUID.user.ext.eids[0]).to.deep.equal({ - source: 'uidapi.com', - uids: [{ - id: uid2.id, - ext: { - rtiPartner: 'UID2' - } - }] - }); - }); - }); - - describe('interpretResponse', function () { - let bid = { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '30b31c2501de1e', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }; - - const bid_outstream = { - 'bidderRequest': { - 'bids': [{ - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25251', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'outstream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '987654321cba', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }, { - 'bidder': 'emx_digital', - 'params': { - 'tagid': '25252', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250], - [300, 600] - ], - 'bidId': '987654321dcb', - 'bidderRequestId': '22edbae3120bf6', - 'auctionId': '1d1a01234a475' - }] - } - }; - - const serverResponse = { - 'id': '12819a18-56e1-4256-b836-b69a10202668', - 'seatbid': [{ - 'bid': [{ - 'adid': '123456abcde', - 'adm': '', - 'crid': '3434abab34', - 'h': 250, - 'id': '987654321cba', - 'price': 0.5, - 'ttl': 300, - 'w': 300, - 'adomain': ['example.com'] - }], - 'seat': '1356' - }, { - 'bid': [{ - 'adid': '123456abcdf', - 'adm': '', - 'crid': '3434abab35', - 'h': 600, - 'id': '987654321dcb', - 'price': 0.5, - 'ttl': 300, - 'w': 300 - }] - }] - }; - - const expectedResponse = [{ - 'requestId': '12819a18-56e1-4256-b836-b69a10202668', - 'cpm': 0.5, - 'width': 300, - 'height': 250, - 'creativeId': '3434abab34', - 'dealId': null, - 'currency': 'USD', - 'netRevneue': true, - 'mediaType': 'banner', - 'ad': '', - 'ttl': 300, - 'meta': { - 'advertiserDomains': ['example.com'] - } - }, { - 'requestId': '12819a18-56e1-4256-b836-b69a10202668', - 'cpm': 0.7, - 'width': 300, - 'height': 600, - 'creativeId': '3434abab35', - 'dealId': null, - 'currency': 'USD', - 'netRevneue': true, - 'mediaType': 'banner', - 'ad': '', - 'ttl': 300 - }]; - - it('should properly format bid response', function () { - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(Object.keys(result[0]).length).to.equal(Object.keys(expectedResponse[0]).length); - expect(Object.keys(result[0]).requestId).to.equal(Object.keys(expectedResponse[0]).requestId); - expect(Object.keys(result[0]).bidderCode).to.equal(Object.keys(expectedResponse[0]).bidderCode); - expect(Object.keys(result[0]).cpm).to.equal(Object.keys(expectedResponse[0]).cpm); - expect(Object.keys(result[0]).creativeId).to.equal(Object.keys(expectedResponse[0]).creativeId); - expect(Object.keys(result[0]).width).to.equal(Object.keys(expectedResponse[0]).width); - expect(Object.keys(result[0]).height).to.equal(Object.keys(expectedResponse[0]).height); - expect(Object.keys(result[0]).ttl).to.equal(Object.keys(expectedResponse[0]).ttl); - expect(Object.keys(result[0]).adId).to.equal(Object.keys(expectedResponse[0]).adId); - expect(Object.keys(result[0]).currency).to.equal(Object.keys(expectedResponse[0]).currency); - expect(Object.keys(result[0]).netRevenue).to.equal(Object.keys(expectedResponse[0]).netRevenue); - expect(Object.keys(result[0]).ad).to.equal(Object.keys(expectedResponse[0]).ad); - }); - - it('should return multiple bids', function () { - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(Array.isArray(result.seatbid)) - - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.ad).to.equal(serverResponse.seatbid[0].bid[0].adm); - expect(ad0.cpm).to.equal(serverResponse.seatbid[0].bid[0].price); - expect(ad0.creativeId).to.equal(serverResponse.seatbid[0].bid[0].crid); - expect(ad0.currency).to.equal('USD'); - expect(ad0.netRevenue).to.equal(true); - expect(ad0.requestId).to.equal(serverResponse.seatbid[0].bid[0].id); - expect(ad0.ttl).to.equal(300); - - expect(ad1.ad).to.equal(serverResponse.seatbid[1].bid[0].adm); - expect(ad1.cpm).to.equal(serverResponse.seatbid[1].bid[0].price); - expect(ad1.creativeId).to.equal(serverResponse.seatbid[1].bid[0].crid); - expect(ad1.currency).to.equal('USD'); - expect(ad1.netRevenue).to.equal(true); - expect(ad1.requestId).to.equal(serverResponse.seatbid[1].bid[0].id); - expect(ad1.ttl).to.equal(300); - }); - - it('returns a banner bid for non-xml creatives', function () { - let result = spec.interpretResponse({ - body: serverResponse - }, { bidRequest: bid } - ); - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.mediaType).to.equal('banner'); - expect(ad0.ad.indexOf('
'; - vastServerResponse.seatbid[1].bid[0].adm = ''; - - let result = spec.interpretResponse({ - body: vastServerResponse - }, { bidRequest: bid } - ); - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.mediaType).to.equal('video'); - expect(ad0.ad.indexOf(' -1).to.equal(true); - expect(ad0.vastXml).to.equal(vastServerResponse.seatbid[0].bid[0].adm); - expect(ad0.ad).to.exist.and.to.be.a('string'); - expect(ad1.mediaType).to.equal('video'); - expect(ad1.ad.indexOf(' -1).to.equal(true); - expect(ad1.vastXml).to.equal(vastServerResponse.seatbid[1].bid[0].adm); - expect(ad1.ad).to.exist.and.to.be.a('string'); - }); - - it('returns a renderer for outstream video creatives', function () { - const vastServerResponse = utils.deepClone(serverResponse); - vastServerResponse.seatbid[0].bid[0].adm = ''; - vastServerResponse.seatbid[1].bid[0].adm = ''; - let result = spec.interpretResponse({body: vastServerResponse}, bid_outstream); - const ad0 = result[0]; - const ad1 = result[1]; - expect(ad0.renderer).to.exist.and.to.be.a('object'); - expect(ad0.renderer.url).to.equal('https://js.brealtime.com/outstream/1.30.0/bundle.js'); - expect(ad0.renderer.id).to.equal('987654321cba'); - expect(ad1.renderer).to.equal(undefined); - }); - - it('handles nobid responses', function () { - let serverResponse = { - 'bids': [] - }; - - let result = spec.interpretResponse({ - body: serverResponse - }); - expect(result.length).to.equal(0); - }); - - it('should not throw an error when decoding an improperly encoded adm', function () { - const badAdmServerResponse = utils.deepClone(serverResponse); - badAdmServerResponse.seatbid[0].bid[0].adm = '\\<\\/script\\>'; - badAdmServerResponse.seatbid[1].bid[0].adm = '%3F%%3Demx%3C3prebid'; - - assert.doesNotThrow(() => spec.interpretResponse({ - body: badAdmServerResponse - })); - }); - - it('returns valid advertiser domain', function () { - const bidResponse = utils.deepClone(serverResponse); - let result = spec.interpretResponse({body: bidResponse}); - expect(result[0].meta.advertiserDomains).to.deep.equal(expectedResponse[0].meta.advertiserDomains); - // case where adomains are not in request - expect(result[1].meta).to.not.exist; - }); - }); - - describe('getUserSyncs', function () { - it('should register the iframe sync url', function () { - let syncs = spec.getUserSyncs({ - iframeEnabled: true - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - }); - - it('should pass gdpr params', function () { - let syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, { - gdprApplies: false, consentString: 'test' - }); - expect(syncs).to.not.be.an('undefined'); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('iframe'); - expect(syncs[0].url).to.contains('gdpr=0'); - }); - }); -}); diff --git a/test/spec/modules/enrichmentFpdModule_spec.js b/test/spec/modules/enrichmentFpdModule_spec.js index 3184349cdf7..e69de29bb2d 100644 --- a/test/spec/modules/enrichmentFpdModule_spec.js +++ b/test/spec/modules/enrichmentFpdModule_spec.js @@ -1,105 +0,0 @@ -import { expect } from 'chai'; -import { getRefererInfo } from 'src/refererDetection.js'; -import { initSubmodule, coreStorage } from 'modules/enrichmentFpdModule.js'; - -describe('the first party data enrichment module', function() { - let width; - let widthStub; - let height; - let heightStub; - let querySelectorStub; - let coreStorageStub; - let canonical; - let keywords; - - before(function() { - canonical = document.createElement('link'); - canonical.rel = 'canonical'; - keywords = document.createElement('meta'); - keywords.name = 'keywords'; - }); - - beforeEach(function() { - querySelectorStub = sinon.stub(window.top.document, 'querySelector'); - querySelectorStub.withArgs("link[rel='canonical']").returns(canonical); - querySelectorStub.withArgs("meta[name='keywords']").returns(keywords); - widthStub = sinon.stub(window.top, 'innerWidth').get(function() { - return width; - }); - heightStub = sinon.stub(window.top, 'innerHeight').get(function() { - return height; - }); - coreStorageStub = sinon.stub(coreStorage, 'getCookie'); - coreStorageStub - .onFirstCall() - .returns(null) // co.uk - .onSecondCall() - .returns('writeable'); // domain.co.uk - }); - - afterEach(function() { - widthStub.restore(); - heightStub.restore(); - querySelectorStub.restore(); - coreStorageStub.restore(); - canonical = document.createElement('link'); - canonical.rel = 'canonical'; - keywords = document.createElement('meta'); - keywords.name = 'keywords'; - }); - - it('adds ref and device values', function() { - width = 800; - height = 500; - - let validated = initSubmodule({}, {}); - - expect(validated.site.ref).to.equal(getRefererInfo().referer); - expect(validated.site.page).to.be.undefined; - expect(validated.site.domain).to.be.undefined; - expect(validated.device).to.deep.equal({ w: 800, h: 500 }); - expect(validated.site.keywords).to.be.undefined; - }); - - it('adds page domain values if canonical url exists', function() { - width = 800; - height = 500; - canonical.href = 'https://www.subdomain.domain.co.uk/path?query=12345'; - - let validated = initSubmodule({}, {}); - - expect(validated.site.ref).to.equal(getRefererInfo().referer); - expect(validated.site.page).to.equal('https://www.subdomain.domain.co.uk/path?query=12345'); - expect(validated.site.domain).to.equal('subdomain.domain.co.uk'); - expect(validated.site.publisher.domain).to.equal('domain.co.uk'); - expect(validated.device).to.deep.equal({ w: 800, h: 500 }); - expect(validated.site.keywords).to.be.undefined; - }); - - it('adds keyword value if keyword meta content exists', function() { - width = 800; - height = 500; - keywords.content = 'value1,value2,value3'; - - let validated = initSubmodule({}, {}); - - expect(validated.site.ref).to.equal(getRefererInfo().referer); - expect(validated.site.page).to.be.undefined; - expect(validated.site.domain).to.be.undefined; - expect(validated.device).to.deep.equal({ w: 800, h: 500 }); - expect(validated.site.keywords).to.equal('value1,value2,value3'); - }); - - it('does not overwrite existing data from getConfig ortb2', function() { - width = 800; - height = 500; - - let validated = initSubmodule({}, {device: {w: 1200, h: 700}, site: {ref: 'https://someUrl.com', page: 'test.com'}}); - - expect(validated.site.ref).to.equal('https://someUrl.com'); - expect(validated.site.page).to.equal('test.com'); - expect(validated.site.domain).to.be.undefined; - expect(validated.device).to.deep.equal({ w: 1200, h: 700 }); - expect(validated.site.keywords).to.be.undefined; - }); -}); diff --git a/test/spec/modules/eplanningAnalyticsAdapter_spec.js b/test/spec/modules/eplanningAnalyticsAdapter_spec.js index 872518f2f27..419181de983 100644 --- a/test/spec/modules/eplanningAnalyticsAdapter_spec.js +++ b/test/spec/modules/eplanningAnalyticsAdapter_spec.js @@ -152,9 +152,6 @@ describe('eplanning analytics adapter', function () { // Step 10 check that the host to send the ajax request is configurable via options expect(eplAnalyticsAdapter.context.host).to.equal(initOptions.host); - - // Step 11 verify that we received 6 events - sinon.assert.callCount(eplAnalyticsAdapter.track, 6); }); }); }); diff --git a/test/spec/modules/eplanningBidAdapter_spec.js b/test/spec/modules/eplanningBidAdapter_spec.js index 921c133c5b0..a381d7644a1 100644 --- a/test/spec/modules/eplanningBidAdapter_spec.js +++ b/test/spec/modules/eplanningBidAdapter_spec.js @@ -6,6 +6,8 @@ import {init, getIds} from 'modules/userId/index.js'; import * as utils from 'src/utils.js'; import {hook} from '../../../src/hook.js'; import {getGlobal} from '../../../src/prebidGlobal.js'; +import { makeSlot } from '../integration/faker/googletag.js'; +import {BANNER, VIDEO} from '../../../src/mediaTypes.js'; describe('E-Planning Adapter', function () { const adapter = newBidder('spec'); @@ -18,6 +20,7 @@ describe('E-Planning Adapter', function () { const CLEAN_ADUNIT_CODE2 = '300x250_1'; const CLEAN_ADUNIT_CODE = '300x250_0'; const CLEAN_ADUNIT_CODE_ML = 'adunitco_de'; + const CLEAN_ADUNIT_CODE_VAST = 'VIDEO_300x250_0'; const BID_ID = '123456789'; const BID_ID2 = '987654321'; const BID_ID3 = '998877665'; @@ -29,6 +32,9 @@ describe('E-Planning Adapter', function () { const CRID = '1234567890'; const TEST_ISV = 'leles.e-planning.net'; const ADOMAIN = 'adomain.com'; + const ADM_VAST = '\n\n\nAcudeo Compatible\n\nhttp://demo.tremormedia.com/proddev/vast/vast_inline_linear.xml\n\n&nfc=1&S=<% SERVER_ID %>&rnd=733663791&bk=0123456789abcdef]]>http://myTrackingURL/wrapper/impression\n\n\n\n\n\n\n\n\n\n\nhttp://demo.tremormedia.com/proddev/vast/300x250_banner1.jpg\n\n\n\nhttp://myTrackingURL/wrapper/firstCompanionCreativeView\n\n\nhttp://www.tremormedia.com\n\n\n\nhttp://demo.tremormedia.com/proddev/vast/728x90_banner1.jpg\n\nhttp://www.tremormedia.com\n\n\n\n\n\n\n\n'; + const ADM_VAST_VV_1 = 'test'; + const DEFAULT_SIZE_VAST = '640x480'; const validBid = { 'bidder': 'eplanning', 'bidId': BID_ID, @@ -68,6 +74,157 @@ describe('E-Planning Adapter', function () { }, 'sizes': [[300, 250], [300, 600]], }; + const validBidSpaceNameWithBidFloor = { + bidder: 'eplanning', + 'bidId': BID_ID, + params: { + 'ci': CI, + 'sn': SN, + }, + getFloor: () => ({ currency: 'USD', floor: 1.16 }), + 'sizes': [[300, 250], [300, 600]], + }; + const validBidSpaceOutstreamWithBidFloor = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + getFloor: () => ({ currency: 'USD', floor: 1.16 }), + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [300, 600], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const validBidSpaceInstreamWithBidFloor = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + getFloor: () => ({ currency: 'USD', floor: 1.16 }), + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const validBidSpaceOutstream = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [300, 600], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const validBidOutstreamNoSize = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const validBidOutstreamNSizes = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': [[300, 600], [400, 500], [500, 500]], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const bidOutstreamInvalidSizes = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + 'mediaTypes': { + 'video': { + 'context': 'outstream', + 'playerSize': 'invalidSize', + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const validBidSpaceInstream = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; + const validBidSpaceVastNoContext = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + }, + 'mediaTypes': { + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + }; const validBidView = { 'bidder': 'eplanning', 'bidId': BID_ID, @@ -144,6 +301,14 @@ describe('E-Planning Adapter', function () { } } }; + const validBidNoSize = { + 'bidder': 'eplanning', + 'bidId': BID_ID, + 'params': { + 'ci': CI, + 'sn': SN, + } + }; const response = { body: { 'sI': { @@ -175,6 +340,68 @@ describe('E-Planning Adapter', function () { ] } }; + const responseVast = { + body: { + 'sI': { + 'k': '12345' + }, + 'sec': { + 'k': 'ROS' + }, + 'sp': [{ + 'k': CLEAN_ADUNIT_CODE_VAST, + 'a': [{ + 'adm': ADM_VAST, + 'id': '7854abc56248f874', + 'i': I_ID, + 'fi': '7854abc56248f872', + 'ip': '45621afd87462104', + 'w': W, + 'h': H, + 'crid': CRID, + 'pr': CPM + }], + }], + 'cs': [ + 'http://a-sync-url.com/', + { + 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', + 'ifr': true + } + ] + } + }; + const responseVastVV1 = { + body: { + 'sI': { + 'k': '12345' + }, + 'sec': { + 'k': 'ROS' + }, + 'sp': [{ + 'k': CLEAN_ADUNIT_CODE_VAST, + 'a': [{ + 'adm': ADM_VAST_VV_1, + 'id': '7854abc56248f874', + 'i': I_ID, + 'fi': '7854abc56248f872', + 'ip': '45621afd87462104', + 'w': W, + 'h': H, + 'crid': CRID, + 'pr': CPM + }], + }], + 'cs': [ + 'http://a-sync-url.com/', + { + 'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east', + 'ifr': true + } + ] + } + }; const responseWithTwoAdunits = { body: { 'sI': { @@ -293,7 +520,9 @@ describe('E-Planning Adapter', function () { const refererUrl = 'https://localhost'; const bidderRequest = { refererInfo: { - referer: refererUrl + page: refererUrl, + domain: 'localhost', + ref: refererUrl, }, gdprConsent: { gdprApplies: 1, @@ -337,12 +566,18 @@ describe('E-Planning Adapter', function () { let getWindowSelfStub; let innerWidth; beforeEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + eplanning: { + storageAllowed: true + } + }; sandbox = sinon.sandbox.create(); getWindowSelfStub = sandbox.stub(utils, 'getWindowSelf'); getWindowSelfStub.returns(createWindow(800)); }); afterEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = {}; sandbox.restore(); }); @@ -385,6 +620,26 @@ describe('E-Planning Adapter', function () { expect(e).to.equal(SN + ':300x250,300x600'); }); + it('should return e parameter with space name attribute with value according to the adunit sizes and bidFloor', function () { + const e = spec.buildRequests([validBidSpaceNameWithBidFloor], bidderRequest).data.e; + expect(e).to.equal(SN + ':300x250,300x600|' + validBidSpaceNameWithBidFloor.getFloor().floor); + }); + + it('should return correct e parameter with support vast with one space with size outstream and bidFloor', function () { + const data = spec.buildRequests([validBidSpaceOutstreamWithBidFloor], bidderRequest).data; + expect(data.e).to.equal('video_300x600_0:300x600;1|' + validBidSpaceOutstreamWithBidFloor.getFloor().floor); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + + it('should return correct e parameter with support vast with one space with size instream with bidFloor', function () { + let bidRequests = [validBidSpaceInstreamWithBidFloor]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_640x480_0:640x480;1|' + validBidSpaceInstreamWithBidFloor.getFloor().floor); + expect(data.vctx).to.equal(1); + expect(data.vv).to.equal(3); + }); + it('should return correct e parameter with more than one adunit', function () { const NEW_CODE = ADUNIT_CODE + '2'; const CLEAN_NEW_CODE = CLEAN_ADUNIT_CODE + '2'; @@ -402,6 +657,77 @@ describe('E-Planning Adapter', function () { expect(e).to.equal('300x250_0:300x250,300x600+100x100_0:100x100'); }); + it('should return correct e parameter with support vast with one space with size outstream', function () { + let bidRequests = [validBidSpaceOutstream]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_300x600_0:300x600;1'); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + + it('should correctly return the e parameter with n sizes in playerSize', function () { + let bidRequests = [validBidOutstreamNSizes]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_300x600_0:300x600;1'); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + + it('should correctly return the e parameter with invalid sizes in playerSize', function () { + let bidRequests = [bidOutstreamInvalidSizes]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_' + DEFAULT_SIZE_VAST + '_0:' + DEFAULT_SIZE_VAST + ';1'); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + + it('should return correct e parameter with support vast with one space with size default outstream', function () { + let bidRequests = [validBidOutstreamNoSize]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_640x480_0:640x480;1'); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + + it('should return correct e parameter with support vast with one space with size instream', function () { + let bidRequests = [validBidSpaceInstream]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_640x480_0:640x480;1'); + expect(data.vctx).to.equal(1); + expect(data.vv).to.equal(3); + }); + + it('should return correct e parameter with support vast with one space with size default and vctx default', function () { + let bidRequests = [validBidSpaceVastNoContext]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_640x480_0:640x480;1'); + expect(data.vctx).to.equal(1); + expect(data.vv).to.equal(3); + }); + + it('if 2 bids arrive, one outstream and the other instream, instream has more priority', function () { + let bidRequests = [validBidSpaceOutstream, validBidSpaceInstream]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_640x480_0:640x480;1'); + expect(data.vctx).to.equal(1); + expect(data.vv).to.equal(3); + }); + it('if 2 bids arrive, one outstream and another banner, outstream has more priority', function () { + let bidRequests = [validBidSpaceOutstream, validBidSpaceName]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_300x600_0:300x600;1'); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + + it('should return correct e parameter with support vast with one space outstream', function () { + let bidRequests = [validBidSpaceOutstream, validBidOutstreamNoSize]; + const data = spec.buildRequests(bidRequests, bidderRequest).data; + expect(data.e).to.equal('video_300x600_0:300x600;1+video_640x480_1:640x480;1'); + expect(data.vctx).to.equal(2); + expect(data.vv).to.equal(3); + }); + it('should return correct e parameter with linear mapping attribute with more than one adunit', function () { let bidRequestsML = [validBidMappingLinear]; const NEW_CODE = ADUNIT_CODE + '2'; @@ -467,7 +793,25 @@ describe('E-Planning Adapter', function () { it('should return ur parameter with current window url', function () { const ur = spec.buildRequests(bidRequests, bidderRequest).data.ur; - expect(ur).to.equal(bidderRequest.refererInfo.referer); + expect(ur).to.equal(bidderRequest.refererInfo.page); + }); + + it('should return ur parameter without params query string when current window url length is greater than 255', function () { + let bidderRequestParams = bidderRequest; + + bidderRequestParams.refererInfo.page = refererUrl + '?param=' + 'x'.repeat(255); + const ur = spec.buildRequests(bidRequests, bidderRequest).data.ur; + expect(ur).to.equal(refererUrl); + }); + + it('should return ur parameter with a length of 255 when url length is greater than 255', function () { + let bidderRequestParams = bidderRequest; + let url_255_characters = 'https://localhost/abc' + '/subse'.repeat(39); + let refererUrl = url_255_characters + '/ext'.repeat(5) + '?param=' + 'x'.repeat(15); + + bidderRequestParams.refererInfo.page = refererUrl; + const ur = spec.buildRequests(bidRequests, bidderRequest).data.ur; + expect(ur).to.equal(url_255_characters); }); it('should return fr parameter when there is a referrer', function () { @@ -475,6 +819,23 @@ describe('E-Planning Adapter', function () { const dataRequest = request.data; expect(dataRequest.fr).to.equal(refererUrl); }); + it('should return fr parameter without params query string when ref length is greater than 255', function () { + let bidderRequestParams = bidderRequest; + + bidderRequestParams.refererInfo.ref = refererUrl + '?param=' + 'x'.repeat(255); + const fr = spec.buildRequests(bidRequests, bidderRequest).data.fr; + expect(fr).to.equal(refererUrl); + }); + + it('should return fr parameter with a length of 255 when url length is greater than 255', function () { + let bidderRequestParams = bidderRequest; + let url_255_characters = 'https://localhost/abc' + '/subse'.repeat(39); + let refererUrl = url_255_characters + '/ext'.repeat(5) + '?param=' + 'x'.repeat(15); + + bidderRequestParams.refererInfo.ref = refererUrl; + const fr = spec.buildRequests(bidRequests, bidderRequest).data.fr; + expect(fr).to.equal(url_255_characters); + }); it('should return crs parameter with document charset', function () { let expected; @@ -579,6 +940,40 @@ describe('E-Planning Adapter', function () { }; expect(bidResponse).to.deep.equal(expectedResponse); }); + + it('should correctly map the parameters in the response vast', function () { + const bidResponse = spec.interpretResponse(responseVast, { adUnitToBidId: { [CLEAN_ADUNIT_CODE_VAST]: BID_ID }, data: { vv: 2 } })[0]; + const expectedResponse = { + requestId: BID_ID, + cpm: CPM, + width: W, + height: H, + ttl: 120, + creativeId: CRID, + netRevenue: true, + currency: 'USD', + vastXml: ADM_VAST, + mediaType: VIDEO + }; + expect(bidResponse).to.deep.equal(expectedResponse); + }); + + it('should correctly map the parameters in the response vast vv 1', function () { + const bidResponse = spec.interpretResponse(responseVastVV1, { adUnitToBidId: { [CLEAN_ADUNIT_CODE_VAST]: BID_ID }, data: { vv: 1 } })[0]; + const expectedResponse = { + requestId: BID_ID, + cpm: CPM, + width: W, + height: H, + ttl: 120, + creativeId: CRID, + netRevenue: true, + currency: 'USD', + vastXml: ADM_VAST_VV_1, + mediaType: VIDEO + }; + expect(bidResponse).to.deep.equal(expectedResponse); + }); }); describe('getUserSyncs', function () { @@ -641,7 +1036,24 @@ describe('E-Planning Adapter', function () { let element; let getBoundingClientRectStub; let sandbox = sinon.sandbox.create(); - let focusStub; + let intersectionObserverStub; + let intersectionCallback; + + function setIntersectionObserverMock(params) { + let fakeIntersectionObserver = (stateChange, options) => { + intersectionCallback = stateChange; + return { + unobserve: (element) => { + return element; + }, + observe: (element) => { + intersectionCallback([{'target': {'id': element.id}, 'isIntersecting': params[element.id].isIntersecting, 'intersectionRatio': params[element.id].ratio, 'boundingClientRect': {'width': params[element.id].width, 'height': params[element.id].height}}]); + }, + }; + }; + + intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver); + } function createElement(id) { element = document.createElement('div'); element.id = id || ADUNIT_CODE_VIEW; @@ -721,6 +1133,11 @@ describe('E-Planning Adapter', function () { }); } beforeEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + eplanning: { + storageAllowed: true + } + }; getLocalStorageSpy = sandbox.spy(storage, 'getDataFromLocalStorage'); setDataInLocalStorageSpy = sandbox.spy(storage, 'setDataInLocalStorage'); @@ -728,11 +1145,9 @@ describe('E-Planning Adapter', function () { hasLocalStorageStub.returns(true); clock = sandbox.useFakeTimers(); - - focusStub = sandbox.stub(window.top.document, 'hasFocus'); - focusStub.returns(true); }); afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; sandbox.restore(); if (document.getElementById(ADUNIT_CODE_VIEW)) { document.body.removeChild(element); @@ -772,6 +1187,7 @@ describe('E-Planning Adapter', function () { let respuesta; beforeEach(function () { createElementVisible(); + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 1, 'isIntersecting': true, 'width': 200, 'height': 200}}); }); it('when you have a render', function() { respuesta = spec.buildRequests(bidRequests, bidderRequest); @@ -809,6 +1225,7 @@ describe('E-Planning Adapter', function () { let respuesta; beforeEach(function () { createElementOutOfView(); + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 0, 'isIntersecting': false, 'width': 200, 'height': 200}}); }); it('when you have a render', function() { @@ -834,6 +1251,7 @@ describe('E-Planning Adapter', function () { let respuesta; it('should register visibility with more than 50%', function() { createPartiallyVisibleElement(); + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 0.6, 'isIntersecting': true, 'width': 200, 'height': 200}}); respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); @@ -842,6 +1260,7 @@ describe('E-Planning Adapter', function () { }); it('you should not register visibility with less than 50%', function() { createPartiallyInvisibleElement(); + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 0.4, 'isIntersecting': true, 'width': 200, 'height': 200}}); respuesta = spec.buildRequests(bidRequests, bidderRequest); clock.tick(1005); @@ -849,12 +1268,29 @@ describe('E-Planning Adapter', function () { expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); }); + context('when element id is not equal to adunitcode', function() { + let respuesta; + it('should register visibility with more than 50%', function() { + const code = ADUNIT_CODE_VIEW; + const divId = 'div-gpt-ad-123'; + createPartiallyVisibleElement(divId); + window.googletag.pubads().setSlots([makeSlot({ code, divId })]); + setIntersectionObserverMock({[divId]: {'ratio': 0.6, 'isIntersecting': true, 'width': 200, 'height': 200}}); + + respuesta = spec.buildRequests(bidRequests, bidderRequest); + clock.tick(1005); + + expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); + expect(storage.getDataFromLocalStorage(storageIdView)).to.equal('1'); + }); + }); context('when width or height of the element is zero', function() { beforeEach(function () { createElementVisible(); }); it('if the width is zero but the height is within the range', function() { element.style.width = '0px'; + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 0.4, 'isIntersecting': true, 'width': 200, 'height': 200}}); spec.buildRequests(bidRequests, bidderRequest) clock.tick(1005); @@ -863,6 +1299,7 @@ describe('E-Planning Adapter', function () { }); it('if the height is zero but the width is within the range', function() { element.style.height = '0px'; + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 1, 'isIntersecting': true, 'width': 500, 'height': 0}}); spec.buildRequests(bidRequests, bidderRequest) clock.tick(1005); @@ -872,6 +1309,7 @@ describe('E-Planning Adapter', function () { it('if both are zero', function() { element.style.height = '0px'; element.style.width = '0px'; + setIntersectionObserverMock({[ADUNIT_CODE_VIEW]: {'ratio': 1, 'isIntersecting': true, 'width': 0, 'height': 0}}); spec.buildRequests(bidRequests, bidderRequest) clock.tick(1005); @@ -879,16 +1317,6 @@ describe('E-Planning Adapter', function () { expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); }); }); - context('when tab is inactive', function() { - it('I should not register if it is not in focus', function() { - createElementVisible(); - focusStub.returns(false); - spec.buildRequests(bidRequests, bidderRequest); - clock.tick(1005); - expect(storage.getDataFromLocalStorage(storageIdRender)).to.equal('1'); - expect(storage.getDataFromLocalStorage(storageIdView)).to.equal(null); - }); - }); context('segmentBeginsBeforeTheVisibleRange', function() { it('segmentBeginsBeforeTheVisibleRange', function() { createElementOutOfRange(); @@ -919,7 +1347,11 @@ describe('E-Planning Adapter', function () { createElementVisible(ADUNIT_CODE_VIEW); createElementVisible(ADUNIT_CODE_VIEW2); createElementVisible(ADUNIT_CODE_VIEW3); - + setIntersectionObserverMock({ + [ADUNIT_CODE_VIEW]: {'ratio': 1, 'isIntersecting': true, 'width': 200, 'height': 200}, + [ADUNIT_CODE_VIEW2]: {'ratio': 1, 'isIntersecting': true, 'width': 200, 'height': 200}, + [ADUNIT_CODE_VIEW3]: {'ratio': 1, 'isIntersecting': true, 'width': 200, 'height': 200} + }); respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); clock.tick(1005); [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { @@ -932,7 +1364,11 @@ describe('E-Planning Adapter', function () { createElementOutOfView(ADUNIT_CODE_VIEW); createElementOutOfView(ADUNIT_CODE_VIEW2); createElementOutOfView(ADUNIT_CODE_VIEW3); - + setIntersectionObserverMock({ + [ADUNIT_CODE_VIEW]: {'ratio': 0, 'isIntersecting': false, 'width': 200, 'height': 200}, + [ADUNIT_CODE_VIEW2]: {'ratio': 0, 'isIntersecting': false, 'width': 200, 'height': 200}, + [ADUNIT_CODE_VIEW3]: {'ratio': 0, 'isIntersecting': false, 'width': 200, 'height': 200} + }); respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); clock.tick(1005); [ADUNIT_CODE_VIEW, ADUNIT_CODE_VIEW2, ADUNIT_CODE_VIEW3].forEach(ac => { @@ -946,7 +1382,11 @@ describe('E-Planning Adapter', function () { createElementVisible(ADUNIT_CODE_VIEW); createElementOutOfView(ADUNIT_CODE_VIEW2); createElementOutOfView(ADUNIT_CODE_VIEW3); - + setIntersectionObserverMock({ + [ADUNIT_CODE_VIEW]: {'ratio': 1, 'isIntersecting': true, 'width': 200, 'height': 200}, + [ADUNIT_CODE_VIEW2]: {'ratio': 0.3, 'isIntersecting': true, 'width': 200, 'height': 200}, + [ADUNIT_CODE_VIEW3]: {'ratio': 0, 'isIntersecting': false, 'width': 200, 'height': 200} + }); respuesta = spec.buildRequests(bidRequestMultiple, bidderRequest); clock.tick(1005); expect(storage.getDataFromLocalStorage('pbsr_' + ADUNIT_CODE_VIEW)).to.equal('6'); diff --git a/test/spec/modules/eskimiBidAdapter_spec.js b/test/spec/modules/eskimiBidAdapter_spec.js new file mode 100644 index 00000000000..d01240c86ab --- /dev/null +++ b/test/spec/modules/eskimiBidAdapter_spec.js @@ -0,0 +1,307 @@ +import { expect } from 'chai'; +import { spec } from 'modules/eskimiBidAdapter.js'; +import * as utils from 'src/utils'; + +const BANNER_BID = { + bidder: 'eskimi', + params: { + placementId: 1003000 + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ], + }, + }, + adUnitCode: 'adUnitCode1', + bidId: 'bidId', + bidderRequestId: 'bidderRequestId', + auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708', +}; + +const VIDEO_BID = { + bidder: 'eskimi', + params: { + placementId: 1003000 + }, + mediaTypes: { + video: { + context: 'outstream', + api: [1, 2, 4, 6], + mimes: ['video/mp4'], + playbackmethod: [2, 4, 6], + playerSize: [[1024, 768]], + protocols: [3, 4, 7, 8, 10], + placement: 1, + minduration: 0, + maxduration: 60, + startdelay: 0 + }, + }, + adUnitCode: 'adUnitCode1', + bidId: 'bidId', + bidderRequestId: 'bidderRequestId', + auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708', +}; + +const BIDDER_REQUEST = { + auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708', + bidderRequestId: 'bidderRequestId', + timeout: 3000, + refererInfo: { + page: 'https://hello-world-page.com/', + domain: 'hello-world-page.com', + ref: 'http://example-domain.com/foo', + } +}; + +const BANNER_BID_RESPONSE = { + 'id': 'bidderRequestId', + 'bidId': 'bidid', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'id', + 'impid': 'bidId', + 'price': 0.18, + 'adm': '', + 'adid': '144762342', + 'burl': 'http://0.0.0.0:8181/burl', + 'adomain': [ + 'https://dummydomain.com' + ], + 'cid': 'cid', + 'crid': 'crid', + 'iurl': 'iurl', + 'cat': [], + 'w': 300, + 'h': 250 + } + ] + } + ], + 'cur': 'USD' +}; + +const VIDEO_BID_RESPONSE = { + 'id': 'bidderRequestId', + 'bidid': 'bidid', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'id', + 'impid': 'bidId', + 'price': 1.09, + 'adid': '144762342', + 'burl': 'http://0.0.0.0:8181/burl', + 'adm': '', + 'adomain': [ + 'https://dummydomain.com' + ], + 'cid': 'cid', + 'crid': 'crid', + 'iurl': 'iurl', + 'cat': [], + 'h': 768, + 'w': 1024 + } + ] + } + ], + 'cur': 'USD' +}; + +describe('Eskimi bid adapter', function () { + describe('isBidRequestValid()', function () { + it('should accept request if placementId is passed', function () { + let bid = { + bidder: 'eskimi', + params: { + placementId: 123 + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should reject requests without params', function () { + let bid = { + bidder: 'eskimi', + params: {} + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(BANNER_BID)).to.equal(true); + expect(spec.isBidRequestValid(VIDEO_BID)).to.equal(true); + }); + }); + + describe('buildRequests()', function () { + it('should have gdpr data if applicable', function () { + const bid = utils.deepClone(BANNER_BID); + + const req = Object.assign({}, BIDDER_REQUEST, { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true, + } + }); + let request = spec.buildRequests([bid], req)[0]; + + const payload = request.data; + expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); + expect(payload.regs.ext).to.have.property('gdpr', 1); + }); + + it('should properly forward ORTB blocking params', function () { + let bid = utils.deepClone(BANNER_BID); + bid = utils.mergeDeep(bid, { + params: { bcat: ['IAB1-1'], badv: ['example.com'], bapp: ['com.example'] }, + mediaTypes: { banner: { battr: [1] } } + }); + + let [request] = spec.buildRequests([bid], BIDDER_REQUEST); + + expect(request).to.exist.and.to.be.an('object'); + const payload = request.data; + expect(payload).to.have.deep.property('bcat', ['IAB1-1']); + expect(payload).to.have.deep.property('badv', ['example.com']); + expect(payload).to.have.deep.property('bapp', ['com.example']); + expect(payload.imp[0].banner).to.have.deep.property('battr', [1]); + }); + + context('when mediaType is banner', function () { + it('should build correct request for banner bid with both w, h', () => { + const bid = utils.deepClone(BANNER_BID); + + const [request] = spec.buildRequests([bid], BIDDER_REQUEST); + const requestData = request.data; + + expect(requestData.imp[0].banner.w).to.equal(300); + expect(requestData.imp[0].banner.h).to.equal(250); + }); + + it('should create request data', function () { + const bid = utils.deepClone(BANNER_BID); + + let [request] = spec.buildRequests([bid], BIDDER_REQUEST); + expect(request).to.exist.and.to.be.a('object'); + const payload = request.data; + expect(payload.imp[0]).to.have.property('id', bid.bidId); + }); + }); + + context('when mediaType is video', function () { + it('should return false when there is no video in mediaTypes', () => { + const bid = utils.deepClone(VIDEO_BID); + delete bid.mediaTypes.video; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should reutrn false if player size is not set', () => { + const bid = utils.deepClone(VIDEO_BID); + delete bid.mediaTypes.video.playerSize; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should use bidder video params if they are set', () => { + const videoBidWithParams = utils.deepClone(VIDEO_BID); + const bidderVideoParams = { + api: [1, 2], + mimes: ['video/mp4', 'video/x-flv'], + playbackmethod: [3, 4], + protocols: [5, 6], + placement: 1, + minduration: 0, + maxduration: 60, + w: 1024, + h: 768, + startdelay: 0 + }; + + videoBidWithParams.params.video = bidderVideoParams; + + const requests = spec.buildRequests([videoBidWithParams], BIDDER_REQUEST); + const request = requests[0].data; + + expect(request.imp[0]).to.deep.include({ + video: { + ...bidderVideoParams, + w: videoBidWithParams.mediaTypes.video.playerSize[0][0], + h: videoBidWithParams.mediaTypes.video.playerSize[0][1], + }, + }); + }); + }); + }); + + describe('interpretResponse()', function () { + context('when mediaType is banner', function () { + it('should correctly interpret valid banner response', function () { + const bid = utils.deepClone(BANNER_BID); + const [request] = spec.buildRequests([bid], BIDDER_REQUEST); + const response = utils.deepClone(BANNER_BID_RESPONSE); + + const bids = spec.interpretResponse({ body: response }, request); + expect(bids).to.be.an('array').that.is.not.empty; + + expect(bids[0].mediaType).to.equal('banner'); + expect(bids[0].burl).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].burl); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].requestId).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].impid); + expect(bids[0].cpm).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].price); + expect(bids[0].width).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].w); + expect(bids[0].height).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].h); + expect(bids[0].ad).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].adm); + expect(bids[0].creativeId).to.equal(BANNER_BID_RESPONSE.seatbid[0].bid[0].crid); + expect(bids[0].meta.advertiserDomains[0]).to.equal('https://dummydomain.com'); + expect(bids[0].ttl).to.equal(30); + expect(bids[0].netRevenue).to.equal(true); + }); + + it('should handle empty bid response', function () { + const bid = utils.deepClone(BANNER_BID); + + let request = spec.buildRequests([bid], BIDDER_REQUEST)[0]; + const EMPTY_RESP = Object.assign({}, BANNER_BID_RESPONSE, { 'body': {} }); + const bids = spec.interpretResponse(EMPTY_RESP, request); + expect(bids).to.be.empty; + }); + }); + if (FEATURES.VIDEO) { + context('when mediaType is video', function () { + it('should correctly interpret valid instream video response', () => { + const bid = utils.deepClone(VIDEO_BID); + + const [request] = spec.buildRequests([bid], BIDDER_REQUEST); + const bids = spec.interpretResponse({ body: VIDEO_BID_RESPONSE }, request); + expect(bids).to.be.an('array').that.is.not.empty; + + expect(bids[0].mediaType).to.equal('video'); + expect(bids[0].burl).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].burl); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].requestId).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].impid); + expect(bids[0].cpm).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].price); + expect(bids[0].width).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].w); + expect(bids[0].height).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].h); + expect(bids[0].vastXml).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].adm); + expect(bids[0].creativeId).to.equal(VIDEO_BID_RESPONSE.seatbid[0].bid[0].crid); + expect(bids[0].meta.advertiserDomains[0]).to.equal('https://dummydomain.com'); + expect(bids[0].ttl).to.equal(30); + expect(bids[0].netRevenue).to.equal(true); + }); + }); + } + }); +}); diff --git a/test/spec/modules/etargetBidAdapter_spec.js b/test/spec/modules/etargetBidAdapter_spec.js index 55394dcdeea..a950100d612 100644 --- a/test/spec/modules/etargetBidAdapter_spec.js +++ b/test/spec/modules/etargetBidAdapter_spec.js @@ -173,7 +173,6 @@ describe('etarget adapter', function () { assert.isNotNull(result.reason); assert.equal(result.ttl, 360); assert.equal(result.ad, ''); - assert.equal(result.transactionId, '5f33781f-9552-4ca1'); }); it('should set correct netRevenue', function () { @@ -296,7 +295,11 @@ describe('etarget adapter', function () { tid: 45, placementCode: placementCode[0], sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], - transactionId: '5f33781f-9552-4ca1' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-4ca1' + } + } }, { adUnitCode: placementCode[1], @@ -307,7 +310,11 @@ describe('etarget adapter', function () { params: params[1], placementCode: placementCode[1], sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], - transactionId: '5f33781f-9552-4iuy' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-4iuy' + } + } }, { adUnitCode: placementCode[2], @@ -318,7 +325,11 @@ describe('etarget adapter', function () { params: params[2], placementCode: placementCode[2], sizes: [[300, 250], [250, 300], [300, 600], [600, 300]], - transactionId: '5f33781f-9552-7ev3' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-7ev3' + } + } }, { adUnitCode: placementCode[3], @@ -329,7 +340,11 @@ describe('etarget adapter', function () { params: params[2], placementCode: placementCode[2], sizes: [], - transactionId: '5f33781f-9552-7ev3' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-7ev3' + } + } }, { adUnitCode: placementCode[4], @@ -340,7 +355,11 @@ describe('etarget adapter', function () { params: params[2], placementCode: placementCode[2], sizes: [], - transactionId: '5f33781f-9552-7ev3' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-7ev3' + } + } }, { adUnitCode: placementCode[4], @@ -351,7 +370,11 @@ describe('etarget adapter', function () { params: params[3], placementCode: placementCode[2], sizes: [], - transactionId: '5f33781f-9552-7ev3' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-7ev3' + } + } }, { adUnitCode: placementCode[4], @@ -362,7 +385,11 @@ describe('etarget adapter', function () { params: params[4], placementCode: placementCode[2], sizes: [], - transactionId: '5f33781f-9552-7ev3' + ortb2Imp: { + ext: { + tid: '5f33781f-9552-7ev3' + } + } } ]; serverResponse = { diff --git a/test/spec/modules/euidIdSystem_spec.js b/test/spec/modules/euidIdSystem_spec.js new file mode 100644 index 00000000000..4f6bacebe6a --- /dev/null +++ b/test/spec/modules/euidIdSystem_spec.js @@ -0,0 +1,124 @@ +import {coreStorage, init, setSubmoduleRegistry} from 'modules/userId/index.js'; +import {config} from 'src/config.js'; +import {euidIdSubmodule} from 'modules/euidIdSystem.js'; +import 'modules/consentManagement.js'; +import 'src/prebid.js'; +import {apiHelpers, cookieHelpers, runAuction, setGdprApplies} from './uid2IdSystem_helpers.js'; +import {hook} from 'src/hook.js'; +import {uninstall as uninstallGdprEnforcement} from 'modules/gdprEnforcement.js'; + +let expect = require('chai').expect; + +// N.B. Most of the EUID code is shared with UID2 - the tests here only cover the happy path. +// Most of the functionality is covered by the UID2 tests. + +const moduleCookieName = '__euid_advertising_token'; +const publisherCookieName = '__EUID_SERVER_COOKIE'; +const initialToken = `initial-advertising-token`; +const legacyToken = 'legacy-advertising-token'; +const refreshedToken = 'refreshed-advertising-token'; +const auctionDelayMs = 10; + +const makeEuidIdentityContainer = (token) => ({euid: {id: token}}); +const useLocalStorage = true; +const makePrebidConfig = (params = null, extraSettings = {}, debug = false) => ({ + userSync: { auctionDelay: auctionDelayMs, userIds: [{name: 'euid', params: {storage: useLocalStorage ? 'localStorage' : 'cookie', ...params}, ...extraSettings}] }, debug +}); + +const apiUrl = 'https://prod.euid.eu/v2/token/refresh'; +const headers = { 'Content-Type': 'application/json' }; +const makeSuccessResponseBody = () => btoa(JSON.stringify({ status: 'success', body: { ...apiHelpers.makeTokenResponse(initialToken), advertising_token: refreshedToken } })); +const expectToken = (bid, token) => expect(bid?.userId ?? {}).to.deep.include(makeEuidIdentityContainer(token)); +const expectNoIdentity = (bid) => expect(bid).to.not.haveOwnProperty('userId'); + +describe('EUID module', function() { + let suiteSandbox, testSandbox, timerSpy, fullTestTitle, restoreSubtleToUndefined = false; + let server; + + const configureEuidResponse = (httpStatus, response) => server.respondWith('POST', apiUrl, (xhr) => xhr.respond(httpStatus, headers, response)); + + before(function() { + uninstallGdprEnforcement(); + hook.ready(); + suiteSandbox = sinon.sandbox.create(); + if (typeof window.crypto.subtle === 'undefined') { + restoreSubtleToUndefined = true; + window.crypto.subtle = { importKey: () => {}, decrypt: () => {} }; + } + suiteSandbox.stub(window.crypto.subtle, 'importKey').callsFake(() => Promise.resolve()); + suiteSandbox.stub(window.crypto.subtle, 'decrypt').callsFake((settings, key, data) => Promise.resolve(new Uint8Array([...settings.iv, ...data]))); + }); + after(function() { + suiteSandbox.restore(); + if (restoreSubtleToUndefined) window.crypto.subtle = undefined; + }); + beforeEach(function() { + server = sinon.createFakeServer(); + init(config); + setSubmoduleRegistry([euidIdSubmodule]); + }); + afterEach(function() { + server.restore(); + $$PREBID_GLOBAL$$.requestBids.removeAll(); + config.resetConfig(); + cookieHelpers.clearCookies(moduleCookieName, publisherCookieName); + coreStorage.removeDataFromLocalStorage(moduleCookieName); + }); + + it('When a server-only token value is provided in config, it is available to the auction.', async function() { + setGdprApplies(true); + config.setConfig(makePrebidConfig(null, {value: makeEuidIdentityContainer(initialToken)})); + const bid = await runAuction(); + expectToken(bid, initialToken); + }); + + it('When a server-only token is provided in the module storage cookie but consent is not available, it is not available to the auction.', async function() { + setGdprApplies(); + coreStorage.setCookie(moduleCookieName, legacyToken, cookieHelpers.getFutureCookieExpiry()); + config.setConfig({userSync: {auctionDelay: auctionDelayMs, userIds: [{name: 'euid'}]}}); + const bid = await runAuction(); + expectNoIdentity(bid); + }); + + it('When a server-only token is provided in the module storage cookie, it is available to the auction.', async function() { + setGdprApplies(true); + coreStorage.setCookie(moduleCookieName, legacyToken, cookieHelpers.getFutureCookieExpiry()); + config.setConfig({userSync: {auctionDelay: auctionDelayMs, userIds: [{name: 'euid'}]}}); + const bid = await runAuction(); + expectToken(bid, legacyToken); + }) + + it('When a valid response body is provided in config, it is available to the auction', async function() { + setGdprApplies(true); + const euidToken = apiHelpers.makeTokenResponse(initialToken, false, false); + config.setConfig(makePrebidConfig({euidToken})); + const bid = await runAuction(); + expectToken(bid, initialToken); + }) + + it('When a valid response body is provided via cookie, it is available to the auction', async function() { + setGdprApplies(true); + const euidToken = apiHelpers.makeTokenResponse(initialToken, false, false); + cookieHelpers.setPublisherCookie(publisherCookieName, euidToken); + config.setConfig(makePrebidConfig({euidCookie: publisherCookieName})); + const bid = await runAuction(); + expectToken(bid, initialToken); + }) + + it('When an expired token is provided in config, it calls the API.', function() { + setGdprApplies(true); + const euidToken = apiHelpers.makeTokenResponse(initialToken, true, true); + config.setConfig(makePrebidConfig({euidToken})); + expect(server.requests[0]?.url).to.have.string('https://prod.euid.eu/'); + }); + + it('When an expired token is provided and the API responds in time, the refreshed token is provided to the auction.', async function() { + setGdprApplies(true); + const euidToken = apiHelpers.makeTokenResponse(initialToken, true, true); + configureEuidResponse(200, makeSuccessResponseBody()); + config.setConfig(makePrebidConfig({euidToken})); + apiHelpers.respondAfterDelay(1, server); + const bid = await runAuction(); + expectToken(bid, refreshedToken); + }); +}); diff --git a/test/spec/modules/experianRtdProvider_spec.js b/test/spec/modules/experianRtdProvider_spec.js new file mode 100644 index 00000000000..fd104674d70 --- /dev/null +++ b/test/spec/modules/experianRtdProvider_spec.js @@ -0,0 +1,365 @@ +import { + EXPERIAN_RTID_DATA_KEY, + EXPERIAN_RTID_EXPIRATION_KEY, + EXPERIAN_RTID_STALE_KEY, + SUBMODULE_NAME, + experianRtdObj, + experianRtdSubmodule, EXPERIAN_RTID_NO_TRACK_KEY +} from '../../../modules/experianRtdProvider.js'; +import { getStorageManager } from '../../../src/storageManager.js'; +import { MODULE_TYPE_RTD } from '../../../src/activities/modules'; +import { safeJSONParse, timestamp } from '../../../src/utils'; +import {server} from '../../mocks/xhr.js'; + +describe('Experian realtime module', () => { + const sandbox = sinon.createSandbox(); + let requests; + + const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: SUBMODULE_NAME }) + beforeEach(() => { + requests = server.requests; + storage.removeDataFromLocalStorage(EXPERIAN_RTID_DATA_KEY, null) + storage.removeDataFromLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, null) + storage.removeDataFromLocalStorage(EXPERIAN_RTID_STALE_KEY, null) + storage.removeDataFromLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, null) + }) + afterEach(() => { + sandbox.restore(); + }) + // Bid request config + const reqBidsConfigObj = { + adUnits: [{ + bids: [ + { bidder: 'appnexus' } + ] + }] + }; + describe('init', () => { + it('succeeds when params have accountId', () => { + const initResult = experianRtdSubmodule.init({ params: { accountId: 'ZylatYg' } }) + expect(initResult).to.be.true; + }) + + it('fails when params don\'t have accountId', () => { + const initResult = experianRtdSubmodule.init({ }) + expect(initResult).to.be.false; + }) + }) + + describe('getBidRequestData', () => { + describe('when local storage has data, isn\'t no track, isn\'t stale and isn\'t expired', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_DATA_KEY, JSON.stringify([ + { + bidder: 'pubmatic', + data: { + key: 'pubmatic-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + }, + { + bidder: 'sovrn', + data: { + key: 'sovrn-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + } + ]), null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now + 100000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now + 50000).toISOString(), null) + }) + it('doesn\'t request data envelope, and alters bids', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig) + sandbox.assert.calledWithExactly(alterBidsSpy, bidsConfig, moduleConfig) + expect(dataEnvelopeSpy.called).to.be.false; + }) + }) + + describe('when local storage has data but it is stale', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_DATA_KEY, JSON.stringify([ + { + bidder: 'pubmatic', + data: { + key: 'pubmatic-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + }, + { + bidder: 'sovrn', + data: { + key: 'sovrn-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + } + ]), null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now + 100000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now - 50000).toISOString(), null) + }) + it('it requests data envelope and alters bids', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const userConsent = {gdpr: {}, uspConsent: {}} + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig, userConsent) + sandbox.assert.calledWithExactly(alterBidsSpy, bidsConfig, moduleConfig) + sandbox.assert.calledWithExactly(dataEnvelopeSpy, moduleConfig, userConsent) + }) + }) + describe('when local storage has data but it is expired', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_DATA_KEY, JSON.stringify([ + { + bidder: 'pubmatic', + data: { + key: 'pubmatic-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + }, + { + bidder: 'sovrn', + data: { + key: 'sovrn-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + } + ]), null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now - 50000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now - 100000).toISOString(), null) + }) + it('requests data envelope, and doesn\'t alter bids', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const userConsent = {gdpr: {}, uspConsent: {}} + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig, userConsent) + sandbox.assert.calledWithExactly(dataEnvelopeSpy, moduleConfig, userConsent) + expect(alterBidsSpy.called).to.be.false; + }) + }) + describe('when local storage has no data envelope', () => { + it('requests data envelope, and doesn\'t alter bids', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const userConsent = {gdpr: {}, uspConsent: {}} + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig, userConsent) + sandbox.assert.calledWithExactly(dataEnvelopeSpy, moduleConfig, userConsent) + expect(alterBidsSpy.called).to.be.false; + }) + }) + describe('when local storage has no track and is expired', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, 'no_track', null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now - 50000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now - 100000).toISOString(), null) + }) + it('requests data envelope, and doesn\'t alter bids', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const userConsent = {gdpr: {}, uspConsent: {}} + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig, userConsent) + sandbox.assert.calledWithExactly(dataEnvelopeSpy, moduleConfig, userConsent) + expect(alterBidsSpy.called).to.be.false; + }) + }) + + describe('when local storage has no track and is stale', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, 'no_track', null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now + 100000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now - 50000).toISOString(), null) + }) + it('requests data envelope, and doesn\'t alter bids', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const userConsent = {gdpr: {}, uspConsent: {}} + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig, userConsent) + sandbox.assert.calledWithExactly(dataEnvelopeSpy, moduleConfig, userConsent) + expect(alterBidsSpy.called).to.be.false; + }) + }) + + describe('when local storage has no track and isn\'t expired or stale', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_NO_TRACK_KEY, 'no_track', null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now + 100000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now + 50000).toISOString(), null) + }) + it('doesn\'t alter bids and doesn\'t request data envelope', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const userConsent = {gdpr: {}, uspConsent: {}} + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + const dataEnvelopeSpy = sandbox.spy(experianRtdObj, 'requestDataEnvelope') + const alterBidsSpy = sandbox.spy(experianRtdObj, 'alterBids') + experianRtdSubmodule.getBidRequestData(bidsConfig, sinon.stub, moduleConfig, userConsent) + expect(alterBidsSpy.called).to.be.false; + expect(dataEnvelopeSpy.called).to.be.false; + }) + }) + }) + + describe('alterBids', () => { + describe('data envelope has every bidder from config', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_DATA_KEY, JSON.stringify([ + { + bidder: 'pubmatic', + data: { + key: 'pubmatic-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + }, + { + bidder: 'sovrn', + data: { + key: 'sovrn-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + } + ]), null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now + 100000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now + 50000).toISOString(), null) + }) + + it('alters bids for the bidders in the module config', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic'] } } + experianRtdObj.alterBids(bidsConfig, moduleConfig); + expect(bidsConfig.ortb2Fragments.bidder).to.deep.equal({pubmatic: { + experianRtidKey: 'pubmatic-encryption-key-1', + experianRtidData: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + }}) + }) + }) + describe('data envelope is missing bidders from config', () => { + beforeEach(() => { + const now = timestamp() + storage.setDataInLocalStorage(EXPERIAN_RTID_DATA_KEY, JSON.stringify([ + { + bidder: 'sovrn', + data: { + key: 'sovrn-encryption-key-1', + data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + } + } + ]), null) + + storage.setDataInLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY, new Date(now + 100000).toISOString(), null) + storage.setDataInLocalStorage(EXPERIAN_RTID_STALE_KEY, new Date(now + 50000).toISOString(), null) + }) + + it('alters bids for the bidders in the module config', () => { + const bidsConfig = { + ortb2Fragments: { + bidder: {} + } + } + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + experianRtdObj.alterBids(bidsConfig, moduleConfig); + expect(bidsConfig.ortb2Fragments.bidder).to.deep.equal({ + sovrn: { + experianRtidKey: 'sovrn-encryption-key-1', + experianRtidData: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg==' + }}) + }) + }) + }) + + describe('requestDataEnvelope', () => { + it('sends request to experian rtd and stores response', () => { + const moduleConfig = { params: { accountId: 'ZylatYg', bidders: ['pubmatic', 'sovrn'] } } + experianRtdObj.requestDataEnvelope(moduleConfig, { gdpr: { gdprApplies: 0, consentString: 'wow' }, uspConsent: '1YYY' }) + requests[0].respond( + 200, + { 'Content-Type': 'application/json' }, + '{"staleAt":"2023-06-01T00:00:00","expiresAt":"2023-06-03T00:00:00","status":"ok","data":[{"bidder":"pubmatic","data":{"key":"pubmatic-encryption-key-1","data":"IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg=="}},{"bidder":"sovrn","data":{"key":"sovrn-encryption-key-1","data":"IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg=="}}]}' + ) + + expect(requests[0].url).to.equal('https://rtid.tapad.com/acc/ZylatYg/ids?gdpr=0&gdpr_consent=wow&us_privacy=1YYY') + expect(safeJSONParse(storage.getDataFromLocalStorage(EXPERIAN_RTID_DATA_KEY, null))).to.deep.equal([{bidder: 'pubmatic', data: {key: 'pubmatic-encryption-key-1', data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg=='}}, {bidder: 'sovrn', data: {key: 'sovrn-encryption-key-1', data: 'IkhlbGxvLCB3b3JsZC4gSGVsbG8sIHdvcmxkLiBIZWxsbywgd29ybGQuIg=='}}]) + expect(storage.getDataFromLocalStorage(EXPERIAN_RTID_STALE_KEY)).to.equal('2023-06-01T00:00:00') + expect(storage.getDataFromLocalStorage(EXPERIAN_RTID_EXPIRATION_KEY)).to.equal('2023-06-03T00:00:00') + }) + }) + + describe('extractConsentQueryString', () => { + describe('when userConsent is empty', () => { + it('returns undefined', () => { + expect(experianRtdObj.extractConsentQueryString({})).to.be.undefined + }) + }) + + describe('when userConsent exists', () => { + it('builds query string', () => { + expect( + experianRtdObj.extractConsentQueryString({}, { gdpr: { gdprApplies: 1, consentString: 'this-is-something' }, uspConsent: '1YYY' }) + ).to.equal('?gdpr=1&gdpr_consent=this-is-something&us_privacy=1YYY') + }) + }) + + describe('when config.ids exists', () => { + it('builds query string', () => { + expect(experianRtdObj.extractConsentQueryString({ params: { accountId: 'ZylatYg', ids: { maid: ['424', '2982'], hem: 'my-hem' } } }, { gdpr: { gdprApplies: 1, consentString: 'this-is-something' }, uspConsent: '1YYY' })) + .to.equal('?gdpr=1&gdpr_consent=this-is-something&us_privacy=1YYY&id.maid=424&id.maid=2982&id.hem=my-hem') + }) + }) + }) +}) diff --git a/test/spec/modules/fabrickIdSystem_spec.js b/test/spec/modules/fabrickIdSystem_spec.js index c250c8e5e8b..4f3ed55ec03 100644 --- a/test/spec/modules/fabrickIdSystem_spec.js +++ b/test/spec/modules/fabrickIdSystem_spec.js @@ -53,7 +53,7 @@ describe('Fabrick ID System', function() { } let configParams = Object.assign({}, defaultConfigParams, { refererInfo: { - referer: r, + topmostLocation: r, stack: ['s-0'], canonicalUrl: 'cu-0' } @@ -81,7 +81,7 @@ describe('Fabrick ID System', function() { it('should complete successfully', function() { let configParams = Object.assign({}, defaultConfigParams, { refererInfo: { - referer: 'r-0', + topmostLocation: 'r-0', stack: ['s-0'], canonicalUrl: 'cu-0' } diff --git a/test/spec/modules/feedadBidAdapter_spec.js b/test/spec/modules/feedadBidAdapter_spec.js index 2739654eb5d..cb81c6f06de 100644 --- a/test/spec/modules/feedadBidAdapter_spec.js +++ b/test/spec/modules/feedadBidAdapter_spec.js @@ -4,6 +4,7 @@ import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes.js'; import {server} from 'test/mocks/xhr.js'; const CODE = 'feedad'; +const EXPECTED_ADAPTER_VERSION = '1.0.6'; describe('FeedAdAdapter', function () { describe('Public API', function () { @@ -108,7 +109,7 @@ describe('FeedAdAdapter', function () { describe('buildRequests', function () { const bidderRequest = { refererInfo: { - referer: 'the referer' + page: 'the referer' }, some: 'thing' }; @@ -300,27 +301,178 @@ describe('FeedAdAdapter', function () { expect(result.data.gdprApplies).to.equal(request.gdprConsent.gdprApplies); expect(result.data.consentIabTcf).to.equal(request.gdprConsent.consentString); }); + it('should include adapter and prebid version', function () { + let bid = { + code: 'feedad', + mediaTypes: { + banner: { + sizes: [[320, 250]] + } + }, + params: {clientToken: 'clientToken', placementId: 'placement-id'} + }; + let result = spec.buildRequests([bid], bidderRequest); + expect(result.data.bids[0].params.prebid_adapter_version).to.equal(EXPECTED_ADAPTER_VERSION); + expect(result.data.bids[0].params.prebid_sdk_version).to.equal('$prebid.version$'); + }); }); describe('interpretResponse', function () { - const body = [{ - foo: 'bar', - sub: { - obj: 5 - } - }, { - bar: 'foo' - }]; - it('should convert string bodies to JSON', function () { + const body = [{ + ad: 'bar', + }]; let result = spec.interpretResponse({body: JSON.stringify(body)}); expect(result).to.deep.equal(body); }); - it('should pass through body objects', function () { + it('should pass through object bodies', function () { + const body = [{ + ad: 'bar', + }]; let result = spec.interpretResponse({body}); expect(result).to.deep.equal(body); }); + + it('should pass through only bodies with ad fields', function () { + const bid1 = { + ad: 'bar', + other: 'field', + some: 'thing' + }; + const bid2 = { + foo: 'bar' + }; + const bid3 = { + ad: 'ad html', + }; + const body = [bid1, bid2, bid3]; + let result = spec.interpretResponse({body: JSON.stringify(body)}); + expect(result).to.deep.equal([bid1, bid3]); + }); + + it('should remove extension fields from bid responses', function () { + const bid = { + ext: {}, + ad: 'ad html', + cpm: 100 + }; + const result = spec.interpretResponse({body: JSON.stringify([bid])}); + expect(result[0]).not.to.haveOwnProperty('ext'); + }); + + it('should return an empty array if the response is not an array', function () { + const bid = {}; + const result = spec.interpretResponse({body: JSON.stringify(bid)}); + expect(result).to.deep.equal([]); + }); + }); + + describe('getUserSyncs', function () { + const pixelSync1 = {type: 'image', url: 'the pixel url 1'}; + const pixelSync2 = {type: 'image', url: 'the pixel url 2'}; + const iFrameSync1 = {type: 'iframe', url: 'the iFrame url 1'}; + const iFrameSync2 = {type: 'iframe', url: 'the iFrame url 2'}; + const response1 = { + body: [{ + ext: { + pixels: [pixelSync1, pixelSync2], + iframes: [iFrameSync1] + }, + }] + }; + const response2 = { + body: [{ + ext: { + pixels: [pixelSync1], + iframes: [iFrameSync1], + } + }, { + ext: { + pixels: [pixelSync2], + iframes: [iFrameSync2], + } + }] + }; + it('should pass through the syncs out of the extension fields of the server response', function () { + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [response1]) + expect(result).to.deep.equal([ + pixelSync1, + pixelSync2, + iFrameSync1, + ]); + }); + + it('should concat the syncs of all responses', function () { + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [response1, response2]); + expect(result).to.deep.equal([ + pixelSync1, + pixelSync2, + iFrameSync1, + iFrameSync2, + ]); + }); + + it('should concat the syncs of all bids', function () { + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [response2]); + expect(result).to.deep.equal([ + pixelSync1, + iFrameSync1, + pixelSync2, + iFrameSync2, + ]); + }); + + it('should filter out duplicates', function () { + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [response1, response1]); + expect(result).to.deep.equal([ + pixelSync1, + pixelSync2, + iFrameSync1, + ]); + }); + + it('should not include iFrame syncs if the option is disabled', function () { + const result = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [response1]); + expect(result).to.deep.equal([ + pixelSync1, + pixelSync2, + ]); + }); + + it('should not include pixel syncs if the option is disabled', function () { + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [response1]); + expect(result).to.deep.equal([ + iFrameSync1, + ]); + }); + + it('should not include any syncs if the sync options are disabled or missing', function () { + const result = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}, [response1]); + expect(result).to.deep.equal([]); + }); + + it('should handle empty responses', function () { + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, []) + expect(result).to.deep.equal([]); + }); + + it('should not throw if the server response is weird', function () { + const responses = [ + {body: null}, + {body: 'null'}, + {body: 1234}, + {body: {}}, + {body: [{}, 123]}, + ]; + expect(() => spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, responses)).to.not.throw(); + }); + + it('should return empty array if the body extension is null', function () { + const response = {body: [{ext: null}]}; + const result = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}, [response]); + expect(result).to.deep.equal([]); + }); }); describe('event tracking calls', function () { @@ -332,7 +484,7 @@ describe('FeedAdAdapter', function () { const referer = 'the referer'; const bidderRequest = { refererInfo: { - referer: referer + page: referer }, some: 'thing' }; @@ -356,7 +508,11 @@ describe('FeedAdAdapter', function () { } }, 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': transactionId, + ortb2Imp: { + ext: { + tid: transactionId + } + }, 'sizes': [ [ 300, @@ -456,7 +612,8 @@ describe('FeedAdAdapter', function () { prebid_bid_id: bidId, prebid_transaction_id: transactionId, referer, - sdk_version: '1.0.2' + prebid_adapter_version: EXPECTED_ADAPTER_VERSION, + prebid_sdk_version: '$prebid.version$', }; subject(data); expect(server.requests.length).to.equal(1); @@ -464,7 +621,7 @@ describe('FeedAdAdapter', function () { expect(call.url).to.equal('https://api.feedad.com/1/prebid/web/events'); expect(JSON.parse(call.requestBody)).to.deep.equal(expectedData); expect(call.method).to.equal('POST'); - expect(call.requestHeaders).to.include({'Content-Type': 'application/json;charset=utf-8'}); + expect(call.requestHeaders).to.include({'Content-Type': 'application/json'}); }) }); }); diff --git a/test/spec/modules/finativeBidAdapter_spec.js b/test/spec/modules/finativeBidAdapter_spec.js new file mode 100644 index 00000000000..d5c56aca65d --- /dev/null +++ b/test/spec/modules/finativeBidAdapter_spec.js @@ -0,0 +1,174 @@ +// jshint esversion: 6, es3: false, node: true +import {assert, expect} from 'chai'; +import {spec} from 'modules/finativeBidAdapter.js'; +import { NATIVE } from 'src/mediaTypes.js'; +import { config } from 'src/config.js'; + +describe('Finative adapter', function () { + let serverResponse, bidRequest, bidResponses; + let bid = { + 'bidder': 'finative', + 'params': { + 'adUnitId': '1uyo' + } + }; + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + assert(spec.isBidRequestValid(bid)); + }); + + it('should return false when AdUnitId is not set', function () { + delete bid.params.adUnitId; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', function () { + it('should send request with correct structure', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {} + }]; + + let request = spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }); + + assert.equal(request.method, 'POST'); + assert.ok(request.data); + }); + + it('should have default request structure', function () { + let keys = 'site,device,cur,imp,user,regs'.split(','); + let validBidRequests = [{ + bidId: 'bidId', + params: {} + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + let data = Object.keys(request); + + assert.deepEqual(keys, data); + }); + + it('Verify the device', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {} + }]; + let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); + + assert.equal(request.device.ua, navigator.userAgent); + }); + + it('Verify native asset ids', function () { + let validBidRequests = [{ + bidId: 'bidId', + params: {}, + nativeParams: { + body: { + required: true, + len: 350 + }, + image: { + required: true + }, + title: { + required: true + }, + sponsoredBy: { + required: true + }, + cta: { + required: true + }, + icon: { + required: true + } + } + }]; + + let assets = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data).imp[0].native.request.assets; + + assert.equal(assets[0].id, 1); + assert.equal(assets[1].id, 3); + assert.equal(assets[2].id, 0); + assert.equal(assets[3].id, 2); + assert.equal(assets[4].id, 4); + assert.equal(assets[5].id, 5); + }); + }); + + describe('interpretResponse', function () { + const goodResponse = { + body: { + cur: 'EUR', + id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', + seatbid: [ + { + seat: 'finative', + bid: [{ + adm: { + native: { + assets: [ + {id: 0, title: {text: 'this is a title'}} + ], + imptrackers: ['https://domain.for/imp/tracker?price=${AUCTION_PRICE}'], + link: { + clicktrackers: ['https://domain.for/imp/tracker?price=${AUCTION_PRICE}'], + url: 'https://domain.for/ad/' + } + } + }, + impid: 1, + price: 0.55 + }] + } + ] + } + }; + const badResponse = { body: { + cur: 'EUR', + id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', + seatbid: [] + }}; + + const bidRequest = { + data: {}, + bids: [{ bidId: 'bidId1' }] + }; + + it('should return null if body is missing or empty', function () { + const result = spec.interpretResponse(badResponse, bidRequest); + assert.equal(result.length, 0); + + delete badResponse.body + + const result1 = spec.interpretResponse(badResponse, bidRequest); + assert.equal(result.length, 0); + }); + + it('should return the correct params', function () { + const result = spec.interpretResponse(goodResponse, bidRequest); + const bid = goodResponse.body.seatbid[0].bid[0]; + + assert.deepEqual(result[0].currency, goodResponse.body.cur); + assert.deepEqual(result[0].requestId, bidRequest.bids[0].bidId); + assert.deepEqual(result[0].cpm, bid.price); + assert.deepEqual(result[0].creativeId, bid.crid); + assert.deepEqual(result[0].mediaType, 'native'); + }); + + it('should return the correct tracking links', function () { + const result = spec.interpretResponse(goodResponse, bidRequest); + const bid = goodResponse.body.seatbid[0].bid[0]; + const regExpPrice = new RegExp('price=' + bid.price); + + result[0].native.clickTrackers.forEach(function (clickTracker) { + assert.ok(clickTracker.search(regExpPrice) > -1); + }); + + result[0].native.impressionTrackers.forEach(function (impTracker) { + assert.ok(impTracker.search(regExpPrice) > -1); + }); + }); + }); +}); diff --git a/test/spec/modules/fintezaAnalyticsAdapter_spec.js b/test/spec/modules/fintezaAnalyticsAdapter_spec.js index 407ceb305a2..cddffc63554 100644 --- a/test/spec/modules/fintezaAnalyticsAdapter_spec.js +++ b/test/spec/modules/fintezaAnalyticsAdapter_spec.js @@ -51,7 +51,7 @@ describe('finteza analytics adapter', function () { describe('track', () => { describe('bid request', () => { - it('builds and sends data', function () { + it('builds and sends request data', function () { const bidderCode = 'Bidder789'; const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; @@ -95,7 +95,7 @@ describe('finteza analytics adapter', function () { }); describe('bid response', () => { - it('builds and sends data', function () { + it('builds and sends response data', function () { const bidderCode = 'Bidder789'; const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; @@ -154,7 +154,7 @@ describe('finteza analytics adapter', function () { }); describe('bid won', () => { - it('builds and sends data', function () { + it('builds and sends bid won data', function () { const bidderCode = 'Bidder789'; const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; @@ -189,12 +189,13 @@ describe('finteza analytics adapter', function () { expect(url.search.value).to.equal(String(cpm)); expect(url.search.unit).to.equal('usd'); - sinon.assert.callCount(fntzAnalyticsAdapter.track, 1); + // 1 Finteza event + 1 Clean.io event + sinon.assert.callCount(fntzAnalyticsAdapter.track, 2); }); }); describe('bid timeout', () => { - it('builds and sends data', function () { + it('builds and sends timeout data', function () { const bidderCode = 'biDDer789'; const pauctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; diff --git a/test/spec/modules/fledgeForGpt_spec.js b/test/spec/modules/fledgeForGpt_spec.js new file mode 100644 index 00000000000..b4bff8e82f0 --- /dev/null +++ b/test/spec/modules/fledgeForGpt_spec.js @@ -0,0 +1,430 @@ +import { + expect +} from 'chai'; +import * as fledge from 'modules/fledgeForGpt.js'; +import {config} from '../../../src/config.js'; +import adapterManager from '../../../src/adapterManager.js'; +import * as utils from '../../../src/utils.js'; +import * as gptUtils from '../../../libraries/gptUtils/gptUtils.js'; +import {hook} from '../../../src/hook.js'; +import 'modules/appnexusBidAdapter.js'; +import 'modules/rubiconBidAdapter.js'; +import {parseExtPrebidFledge, setImpExtAe, setResponseFledgeConfigs} from 'modules/fledgeForGpt.js'; +import * as events from 'src/events.js'; +import CONSTANTS from 'src/constants.json'; +import {getGlobal} from '../../../src/prebidGlobal.js'; + +describe('fledgeForGpt module', () => { + let sandbox; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + afterEach(() => { + sandbox.restore(); + }); + describe('addComponentAuction', function () { + before(() => { + fledge.init({enabled: true}); + }); + + const fledgeAuctionConfig = { + seller: 'bidder', + mock: 'config' + }; + + describe('addComponentAuctionHook', function () { + let nextFnSpy, mockGptSlot; + beforeEach(function () { + nextFnSpy = sinon.spy(); + mockGptSlot = { + setConfig: sinon.stub(), + getAdUnitPath: () => 'mock/gpt/au' + }; + sandbox.stub(gptUtils, 'getGptSlotForAdUnitCode').callsFake(() => mockGptSlot); + }); + + it('should call next()', function () { + fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'auc', fledgeAuctionConfig); + sinon.assert.calledWith(nextFnSpy, 'aid', 'auc', fledgeAuctionConfig); + }); + + it('should collect auction configs and route them to GPT at end of auction', () => { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'}); + const cf1 = {...fledgeAuctionConfig, id: 1, seller: 'b1'}; + const cf2 = {...fledgeAuctionConfig, id: 2, seller: 'b2'}; + fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au1', cf1); + fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au2', cf2); + events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'}); + sinon.assert.calledWith(gptUtils.getGptSlotForAdUnitCode, 'au1'); + sinon.assert.calledWith(gptUtils.getGptSlotForAdUnitCode, 'au2'); + sinon.assert.calledWith(mockGptSlot.setConfig, { + componentAuction: [{ + configKey: 'b1', + auctionConfig: cf1, + }] + }); + sinon.assert.calledWith(mockGptSlot.setConfig, { + componentAuction: [{ + configKey: 'b2', + auctionConfig: cf2, + }] + }); + }); + + it('should drop auction configs after end of auction', () => { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'}); + events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'}); + fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au', fledgeAuctionConfig); + events.emit(CONSTANTS.EVENTS.AUCTION_END, {auctionId: 'aid'}); + sinon.assert.notCalled(mockGptSlot.setConfig); + }); + + describe('floor signal', () => { + before(() => { + if (!getGlobal().convertCurrency) { + getGlobal().convertCurrency = () => null; + getGlobal().convertCurrency.mock = true; + } + }); + after(() => { + if (getGlobal().convertCurrency.mock) { + delete getGlobal().convertCurrency; + } + }); + + beforeEach(() => { + sandbox.stub(getGlobal(), 'convertCurrency').callsFake((amount, from, to) => { + if (from === to) return amount; + if (from === 'USD' && to === 'JPY') return amount * 100; + if (from === 'JPY' && to === 'USD') return amount / 100; + throw new Error('unexpected currency conversion'); + }); + }); + + Object.entries({ + 'bids': (payload, values) => { + payload.bidsReceived = values + .map((val) => ({adUnitCode: 'au', cpm: val.amount, currency: val.cur})) + .concat([{adUnitCode: 'other', cpm: 10000, currency: 'EUR'}]) + }, + 'no bids': (payload, values) => { + payload.bidderRequests = values + .map((val) => ({bids: [{adUnitCode: 'au', getFloor: () => ({floor: val.amount, currency: val.cur})}]})) + .concat([{bids: {adUnitCode: 'other', getFloor: () => ({floor: -10000, currency: 'EUR'})}}]) + } + }).forEach(([tcase, setup]) => { + describe(`when auction has ${tcase}`, () => { + Object.entries({ + 'no currencies': { + values: [{amount: 1}, {amount: 100}, {amount: 10}, {amount: 100}], + 'bids': { + bidfloor: 100, + bidfloorcur: undefined + }, + 'no bids': { + bidfloor: 1, + bidfloorcur: undefined, + } + }, + 'only zero values': { + values: [{amount: 0, cur: 'USD'}, {amount: 0, cur: 'JPY'}], + 'bids': { + bidfloor: undefined, + bidfloorcur: undefined, + }, + 'no bids': { + bidfloor: undefined, + bidfloorcur: undefined, + } + }, + 'matching currencies': { + values: [{amount: 10, cur: 'JPY'}, {amount: 100, cur: 'JPY'}], + 'bids': { + bidfloor: 100, + bidfloorcur: 'JPY', + }, + 'no bids': { + bidfloor: 10, + bidfloorcur: 'JPY', + } + }, + 'mixed currencies': { + values: [{amount: 10, cur: 'USD'}, {amount: 10, cur: 'JPY'}], + 'bids': { + bidfloor: 10, + bidfloorcur: 'USD' + }, + 'no bids': { + bidfloor: 10, + bidfloorcur: 'JPY', + } + } + }).forEach(([t, testConfig]) => { + const values = testConfig.values; + const {bidfloor, bidfloorcur} = testConfig[tcase]; + + describe(`with ${t}`, () => { + let payload; + beforeEach(() => { + payload = {auctionId: 'aid'}; + setup(payload, values); + }); + + it('should populate bidfloor/bidfloorcur', () => { + events.emit(CONSTANTS.EVENTS.AUCTION_INIT, {auctionId: 'aid'}); + fledge.addComponentAuctionHook(nextFnSpy, 'aid', 'au', fledgeAuctionConfig); + events.emit(CONSTANTS.EVENTS.AUCTION_END, payload); + sinon.assert.calledWith(mockGptSlot.setConfig, sinon.match(arg => { + return arg.componentAuction.some(au => au.auctionConfig.auctionSignals?.prebid?.bidfloor === bidfloor && au.auctionConfig.auctionSignals?.prebid?.bidfloorcur === bidfloorcur) + })) + }) + }); + }); + }) + }) + }); + }); + }); + + describe('fledgeEnabled', function () { + const navProps = Object.fromEntries(['runAdAuction', 'joinAdInterestGroup'].map(p => [p, navigator[p]])); + + before(function () { + // navigator.runAdAuction & co may not exist, so we can't stub it normally with + // sinon.stub(navigator, 'runAdAuction') or something + Object.keys(navProps).forEach(p => { + navigator[p] = sinon.stub(); + }); + hook.ready(); + }); + + after(function () { + Object.entries(navProps).forEach(([p, orig]) => navigator[p] = orig); + }); + + afterEach(function () { + config.resetConfig(); + }); + + const adUnits = [{ + 'code': '/19968336/header-bid-tag1', + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90]] + }, + }, + 'bids': [ + { + 'bidder': 'appnexus', + }, + { + 'bidder': 'rubicon', + }, + ] + }]; + + describe('with setBidderConfig()', () => { + it('should set fledgeEnabled correctly per bidder', function () { + config.setConfig({bidderSequence: 'fixed'}); + config.setBidderConfig({ + bidders: ['appnexus'], + config: { + fledgeEnabled: true, + defaultForSlots: 1, + } + }); + + const bidRequests = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() { + }, + [] + ); + + expect(bidRequests[0].bids[0].bidder).equals('appnexus'); + expect(bidRequests[0].fledgeEnabled).to.be.true; + expect(bidRequests[0].defaultForSlots).to.equal(1); + + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[1].fledgeEnabled).to.be.undefined; + expect(bidRequests[1].defaultForSlots).to.be.undefined; + }); + }); + + describe('with setConfig()', () => { + it('should set fledgeEnabled correctly per bidder', function () { + config.setConfig({ + bidderSequence: 'fixed', + fledgeForGpt: { + enabled: true, + bidders: ['appnexus'], + defaultForSlots: 1, + } + }); + + const bidRequests = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() { + }, + [] + ); + + expect(bidRequests[0].bids[0].bidder).equals('appnexus'); + expect(bidRequests[0].fledgeEnabled).to.be.true; + expect(bidRequests[0].defaultForSlots).to.equal(1); + + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[1].fledgeEnabled).to.be.undefined; + expect(bidRequests[1].defaultForSlots).to.be.undefined; + }); + + it('should set fledgeEnabled correctly for all bidders', function () { + config.setConfig({ + bidderSequence: 'fixed', + fledgeForGpt: { + enabled: true, + defaultForSlots: 1, + } + }); + + const bidRequests = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() { + }, + [] + ); + + expect(bidRequests[0].bids[0].bidder).equals('appnexus'); + expect(bidRequests[0].fledgeEnabled).to.be.true; + expect(bidRequests[0].defaultForSlots).to.equal(1); + + expect(bidRequests[1].bids[0].bidder).equals('rubicon'); + expect(bidRequests[0].fledgeEnabled).to.be.true; + expect(bidRequests[0].defaultForSlots).to.equal(1); + }); + }); + }); + + describe('ortb processors for fledge', () => { + describe('when defaultForSlots is set', () => { + it('imp.ext.ae should be set if fledge is enabled', () => { + const imp = {}; + setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true, defaultForSlots: 1}}); + expect(imp.ext.ae).to.equal(1); + }); + it('imp.ext.ae should be left intact if set on adunit and fledge is enabled', () => { + const imp = {ext: {ae: 2}}; + setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true, defaultForSlots: 1}}); + expect(imp.ext.ae).to.equal(2); + }); + }); + describe('when defaultForSlots is not defined', () => { + it('imp.ext.ae should be removed if fledge is not enabled', () => { + const imp = {ext: {ae: 1}}; + setImpExtAe(imp, {}, {bidderRequest: {}}); + expect(imp.ext.ae).to.not.exist; + }); + it('imp.ext.ae should be left intact if fledge is enabled', () => { + const imp = {ext: {ae: 2}}; + setImpExtAe(imp, {}, {bidderRequest: {fledgeEnabled: true}}); + expect(imp.ext.ae).to.equal(2); + }); + }); + describe('parseExtPrebidFledge', () => { + function packageConfigs(configs) { + return { + ext: { + prebid: { + fledge: { + auctionconfigs: configs + } + } + } + }; + } + + function generateImpCtx(fledgeFlags) { + return Object.fromEntries(Object.entries(fledgeFlags).map(([impid, fledgeEnabled]) => [impid, {imp: {ext: {ae: fledgeEnabled}}}])); + } + + function generateCfg(impid, ...ids) { + return ids.map((id) => ({impid, config: {id}})); + } + + function extractResult(ctx) { + return Object.fromEntries( + Object.entries(ctx) + .map(([impid, ctx]) => [impid, ctx.fledgeConfigs?.map(cfg => cfg.config.id)]) + .filter(([_, val]) => val != null) + ); + } + + it('should collect fledge configs by imp', () => { + const ctx = { + impContext: generateImpCtx({e1: 1, e2: 1, d1: 0}) + }; + const resp = packageConfigs( + generateCfg('e1', 1, 2, 3) + .concat(generateCfg('e2', 4) + .concat(generateCfg('d1', 5, 6))) + ); + parseExtPrebidFledge({}, resp, ctx); + expect(extractResult(ctx.impContext)).to.eql({ + e1: [1, 2, 3], + e2: [4], + }); + }); + it('should not choke if fledge config references unknown imp', () => { + const ctx = {impContext: generateImpCtx({i: 1})}; + const resp = packageConfigs(generateCfg('unknown', 1)); + parseExtPrebidFledge({}, resp, ctx); + expect(extractResult(ctx.impContext)).to.eql({}); + }); + }); + describe('setResponseFledgeConfigs', () => { + it('should set fledgeAuctionConfigs paired with their corresponding bid id', () => { + const ctx = { + impContext: { + 1: { + bidRequest: {bidId: 'bid1'}, + fledgeConfigs: [{config: {id: 1}}, {config: {id: 2}}] + }, + 2: { + bidRequest: {bidId: 'bid2'}, + fledgeConfigs: [{config: {id: 3}}] + }, + 3: { + bidRequest: {bidId: 'bid3'} + } + } + }; + const resp = {}; + setResponseFledgeConfigs(resp, {}, ctx); + expect(resp.fledgeAuctionConfigs).to.eql([ + {bidId: 'bid1', config: {id: 1}}, + {bidId: 'bid1', config: {id: 2}}, + {bidId: 'bid2', config: {id: 3}}, + ]); + }); + it('should not set fledgeAuctionConfigs if none exist', () => { + const resp = {}; + setResponseFledgeConfigs(resp, {}, { + impContext: { + 1: { + fledgeConfigs: [] + }, + 2: {} + } + }); + expect(resp).to.eql({}); + }); + }); + }); +}); diff --git a/test/spec/modules/flippBidAdapter_spec.js b/test/spec/modules/flippBidAdapter_spec.js new file mode 100644 index 00000000000..518052ad91e --- /dev/null +++ b/test/spec/modules/flippBidAdapter_spec.js @@ -0,0 +1,170 @@ +import {expect} from 'chai'; +import {spec} from 'modules/flippBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory'; +const ENDPOINT = 'https://gateflipp.flippback.com/flyer-locator-service/client_bidding'; +describe('flippAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + bidder: 'flipp', + params: { + publisherNameIdentifier: 'random', + siteId: 1234, + zoneIds: [1, 2, 3, 4], + } + }; + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let invalidBid = Object.assign({}, bid); + invalidBid.params = { siteId: 1234 } + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [{ + bidder: 'flipp', + params: { + siteId: 1234, + }, + adUnitCode: '/10000/unit_code', + sizes: [[300, 600]], + mediaTypes: {banner: {sizes: [[300, 600]]}}, + bidId: '237f4d1a293f99', + bidderRequestId: '1a857fa34c1c96', + auctionId: 'a297d1aa-7900-4ce4-a0aa-caa8d46c4af7', + transactionId: '00b2896c-2731-4f01-83e4-7a3ad5da13b6', + }]; + const bidderRequest = { + refererInfo: { + referer: 'http://example.com' + } + }; + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.method).to.equal('POST'); + }); + + it('sends bid request to ENDPOINT with query parameter', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + }); + }); + + describe('interpretResponse', function() { + it('should get correct bid response', function() { + const bidRequest = { + method: 'POST', + url: ENDPOINT, + data: { + placements: [{ + divName: 'slot', + networkId: 12345, + siteId: 12345, + adTypes: [12345], + count: 1, + prebid: { + requestId: '237f4d1a293f99', + publisherNameIdentifier: 'bid.params.publisherNameIdentifier', + height: 600, + width: 300, + }, + user: '10462725-da61-4d3a-beff-6d05239e9a6e"', + }], + url: 'http://example.com', + }, + }; + + const serverResponse = { + body: { + 'decisions': { + 'inline': [{ + 'bidCpm': 1, + 'adId': 262838368, + 'height': 600, + 'width': 300, + 'storefront': { 'flyer_id': 5435567 }, + 'prebid': { + 'requestId': '237f4d1a293f99', + 'cpm': 1.11, + 'creative': 'Returned from server', + } + }] + }, + 'location': {'city': 'Oakville'}, + }, + }; + + const expectedResponse = [ + { + bidderCode: 'flipp', + requestId: '237f4d1a293f99', + currency: 'USD', + cpm: 1.11, + netRevenue: true, + width: 300, + height: 600, + creativeId: 262838368, + ttl: 30, + ad: 'Returned from server', + } + ]; + + const result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.have.lengthOf(1); + expect(result).to.deep.have.same.members(expectedResponse); + }); + + it('should get empty bid response when no ad is returned', function() { + const bidRequest = { + method: 'POST', + url: ENDPOINT, + data: { + placements: [{ + divName: 'slot', + networkId: 12345, + siteId: 12345, + adTypes: [12345], + count: 1, + prebid: { + requestId: '237f4d1a293f99', + publisherNameIdentifier: 'bid.params.publisherNameIdentifier', + height: 600, + width: 300, + }, + user: '10462725-da61-4d3a-beff-6d05239e9a6e"', + }], + url: 'http://example.com', + }, + }; + + const serverResponse = { + body: { + 'decisions': { + 'inline': [] + }, + 'location': {'city': 'Oakville'}, + }, + }; + + const result = spec.interpretResponse(serverResponse, bidRequest); + expect(result).to.have.lengthOf(0); + expect(result).to.deep.have.same.members([]); + }) + + it('should get empty response when bid server returns 204', function() { + expect(spec.interpretResponse({})).to.be.empty; + }); + }); +}); diff --git a/test/spec/modules/fluctBidAdapter_spec.js b/test/spec/modules/fluctBidAdapter_spec.js index 8ef99727ce7..ff6f8562a4e 100644 --- a/test/spec/modules/fluctBidAdapter_spec.js +++ b/test/spec/modules/fluctBidAdapter_spec.js @@ -54,6 +54,16 @@ describe('fluctAdapter', function () { }); describe('buildRequests', function () { + let sb; + + beforeEach(function () { + sb = sinon.sandbox.create(); + }); + + afterEach(function () { + sb.restore(); + }); + const bidRequests = [{ bidder: 'fluct', params: { @@ -70,7 +80,7 @@ describe('fluctAdapter', function () { }]; const bidderRequest = { refererInfo: { - referer: 'http://example.com' + page: 'http://example.com' } }; @@ -84,6 +94,84 @@ describe('fluctAdapter', function () { expect(request.url).to.equal('https://hb.adingo.jp/prebid?dfpUnitCode=%2F100000%2Funit_code&tagId=10000%3A100000001&groupId=1000000002'); }); + it('includes data.page by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.page).to.eql('http://example.com'); + }); + + it('sends no transactionId by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.transactionId).to.eql(undefined); + }); + + it('sends ortb2Imp.ext.tid as transactionId', function () { + const request = spec.buildRequests(bidRequests.map((req) => ({ + ...req, + ortb2Imp: { + ext: { + tid: 'tid', + } + }, + })), bidderRequest)[0]; + expect(request.data.transactionId).to.eql('tid'); + }); + + it('sends no gpid by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.gpid).to.eql(undefined); + }); + + it('sends ortb2Imp.ext.gpid as gpid', function () { + const request = spec.buildRequests(bidRequests.map((req) => ({ + ...req, + ortb2Imp: { + ext: { + gpid: 'gpid', + data: { + pbadslot: 'data-pbadslot', + adserver: { + adslot: 'data-adserver-adslot', + }, + }, + }, + }, + })), bidderRequest)[0]; + expect(request.data.gpid).to.eql('gpid'); + }); + + it('sends ortb2Imp.ext.data.pbadslot as gpid', function () { + const request = spec.buildRequests(bidRequests.map((req) => ({ + ...req, + ortb2Imp: { + ext: { + data: { + pbadslot: 'data-pbadslot', + adserver: { + adslot: 'data-adserver-adslot', + }, + }, + }, + }, + })), bidderRequest)[0]; + expect(request.data.gpid).to.eql('data-pbadslot'); + }); + + it('sends ortb2Imp.ext.data.adserver.adslot as gpid', function () { + const request = spec.buildRequests(bidRequests.map((req) => ({ + ...req, + ortb2Imp: { + ext: { + data: { + adserver: { + adslot: 'data-adserver-adslot', + }, + }, + }, + }, + })), bidderRequest)[0]; + expect(request.data.gpid).to.eql('data-adserver-adslot'); + }); + it('includes data.user.eids = [] by default', function () { const request = spec.buildRequests(bidRequests, bidderRequest)[0]; expect(request.data.user.eids).to.eql([]); @@ -94,14 +182,24 @@ describe('fluctAdapter', function () { expect(request.data.params.kv).to.eql(undefined); }); + it('includes no data.schain by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.schain).to.eql(undefined); + }); + + it('includes no data.regs by default', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.regs).to.eql(undefined); + }); + it('includes filtered user.eids if any exists', function () { const bidRequests2 = bidRequests.map( - (bidReq) => Object.assign(bidReq, { + (bidReq) => Object.assign({}, bidReq, { userIdAsEids: [ { source: 'foobar.com', uids: [ - { id: 'foobar-id' } + { id: 'foobar-id' }, ], }, { @@ -113,19 +211,19 @@ describe('fluctAdapter', function () { { source: 'criteo.com', uids: [ - { id: 'criteo-id' } + { id: 'criteo-id' }, ], }, { source: 'intimatemerger.com', uids: [ - { id: 'imuid' } + { id: 'imuid' }, ], }, { source: 'liveramp.com', uids: [ - { id: 'idl-env' } + { id: 'idl-env' }, ], }, ], @@ -133,36 +231,96 @@ describe('fluctAdapter', function () { ); const request = spec.buildRequests(bidRequests2, bidderRequest)[0]; expect(request.data.user.eids).to.eql([ + { + source: 'foobar.com', + uids: [ + { id: 'foobar-id' }, + ], + }, { source: 'adserver.org', uids: [ - { id: 'tdid' } + { id: 'tdid' }, ], }, { source: 'criteo.com', uids: [ - { id: 'criteo-id' } + { id: 'criteo-id' }, ], }, { source: 'intimatemerger.com', uids: [ - { id: 'imuid' } + { id: 'imuid' }, ], }, { source: 'liveramp.com', uids: [ - { id: 'idl-env' } + { id: 'idl-env' }, ], }, ]); }); + it('includes user.data if any exists', function () { + const bidderRequest2 = Object.assign({}, bidderRequest, { + ortb2: { + user: { + data: [ + { + name: 'a1mediagroup.com', + ext: { + segtax: 900, + }, + segment: [ + { id: 'seg-1' }, + { id: 'seg-2' }, + ], + }, + ], + ext: { + eids: [ + { + source: 'a1mediagroup.com', + uids: [ + { id: 'aud-1' } + ], + }, + ], + }, + }, + }, + }); + const request = spec.buildRequests(bidRequests, bidderRequest2)[0]; + expect(request.data.user).to.eql({ + data: [ + { + name: 'a1mediagroup.com', + ext: { + segtax: 900, + }, + segment: [ + { id: 'seg-1' }, + { id: 'seg-2' }, + ], + }, + ], + eids: [ + { + source: 'a1mediagroup.com', + uids: [ + { id: 'aud-1' } + ], + }, + ], + }); + }); + it('includes data.params.kv if any exists', function () { const bidRequests2 = bidRequests.map( - (bidReq) => Object.assign(bidReq, { + (bidReq) => Object.assign({}, bidReq, { params: { kv: { imsids: ['imsid1', 'imsid2'] @@ -175,9 +333,78 @@ describe('fluctAdapter', function () { imsids: ['imsid1', 'imsid2'] }); }); + + it('includes data.schain if any exists', function () { + // this should be done by schain.js + const bidRequests2 = bidRequests.map( + (bidReq) => Object.assign({}, bidReq, { + schain: { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: 'publisher-id', + hp: 1 + } + ] + } + }) + ); + const request = spec.buildRequests(bidRequests2, bidderRequest)[0]; + expect(request.data.schain).to.eql({ + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'example.com', + sid: 'publisher-id', + hp: 1 + } + ] + }); + }); + + it('includes data.regs.gdpr if bidderRequest.gdprConsent exists', function () { + const request = spec.buildRequests( + bidRequests, + Object.assign({}, bidderRequest, { + gdprConsent: { + consentString: 'gdpr-consent-string', + gdprApplies: true, + }, + }), + )[0]; + expect(request.data.regs.gdpr).to.eql({ + consent: 'gdpr-consent-string', + gdprApplies: 1, + }); + }); + + it('includes data.regs.us_privacy if bidderRequest.uspConsent exists', function () { + const request = spec.buildRequests( + bidRequests, + Object.assign({}, bidderRequest, { + uspConsent: 'usp-consent-string', + }), + )[0]; + expect(request.data.regs.us_privacy).to.eql({ + consent: 'usp-consent-string', + }); + }); + + it('includes data.regs.coppa if config.getConfig("coppa") is true', function () { + const cfg = { + coppa: true, + }; + sb.stub(config, 'getConfig').callsFake(key => cfg[key]); + + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.regs.coppa).to.eql(1); + }); }); - describe('interpretResponse', function() { + describe('should interpretResponse', function() { const callBeaconSnippet = '\n \n \n ", + advertiser_domains: ['ogx.com'], + media_type: 'banner', + ttl: 360, + }, + }, +}; + +const mockBidderRequest = { + bidderCode: 'hypelab', + auctionId: '4462005b-ba06-49a9-a95d-0209c22f4606', + bidderRequestId: '1bf399761210ad', + bids: mockValidBidRequests, + auctionStart: 1684983987435, + timeout: 2000, + refererInfo: { + topmostLocation: 'https://example.com/hello_world.html', + location: 'https://example.com/hello_world.html', + canonicalUrl: null, + page: 'https://example.com/hello_world.html', + domain: null, + ref: null, + }, +}; + +const mockBidRequest = { + method: 'POST', + url: 'https://api.hypelab.com/v1/prebid_requests', + options: { + contentType: 'application/json', + withCredentials: false, + }, + data: { + property_slug: 'prebid', + placement_slug: 'test_placement', + provider_version: '0.0.1', + provider_name: 'prebid', + referrer: 'https://example.com', + sdk_version: '7.51.0-pre', + sizes: [[728, 90]], + wids: [], + uuid: 'tmp_c5abf809-47d6-40b9-8274-372c6d816dd8', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + }, + bidId: '2e02b562f700ae', +}; + +describe('hypelabBidAdapter', function () { + describe('mediaSize', function () { + describe('when given an invalid media object', function () { + expect(mediaSize({})).to.eql({ width: 0, height: 0 }); + }); + + describe('when given a valid media object', function () { + expect( + mediaSize({ creative_set: { image: { width: 728, height: 90 } } }) + ).to.eql({ width: 728, height: 90 }); + }); + }); + + describe('isBidRequestValid', function () { + describe('when given an invalid bid request', function () { + expect(spec.isBidRequestValid({})).to.equal(false); + }); + + describe('when given a valid bid request', function () { + expect(spec.isBidRequestValid(mockValidBidRequest)).to.equal(true); + }); + }); + + describe('Bidder code valid', function () { + expect(spec.code).to.equal(BIDDER_CODE); + }); + + describe('Media types valid', function () { + expect(spec.supportedMediaTypes).to.contain(BANNER); + }); + + describe('Bid request valid', function () { + expect(spec.isBidRequestValid(mockValidBidRequest)).to.equal(true); + }); + + describe('buildRequests', () => { + describe('returns a valid request', function () { + const result = spec.buildRequests( + mockValidBidRequests, + mockBidderRequest + ); + expect(result).to.be.an('array'); + + const first = result[0] || {}; + expect(first).to.be.an('object'); + expect(first.method).to.equal('POST'); + expect(first.url).to.be.a('string'); + expect(first.url).to.equal(ENDPOINT_URL + REQUEST_ROUTE); + + const data = first.data || {}; + expect(data).to.be.an('object'); + expect(data.property_slug).to.be.a('string'); + expect(data.placement_slug).to.be.a('string'); + expect(data.bidRequestsCount).to.be.a('number'); + expect(data.bidderRequestsCount).to.be.a('number'); + expect(data.bidderWinsCount).to.be.a('number'); + }); + + describe('should set uuid to the first id in userIdAsEids', () => { + mockValidBidRequests[0].userIdAsEids = [ + { + source: 'pubcid.org', + uids: [ + { + id: 'pubcid_id', + }, + ], + }, + { + source: 'criteo.com', + uids: [ + { + id: 'criteo_id', + }, + ], + }, + ]; + + const result = spec.buildRequests( + mockValidBidRequests, + mockBidderRequest + ); + + const data = result[0].data || {}; + expect(data.uuid).to.be.eq('pubcid_id'); + }); + }); + + describe('interpretResponse', () => { + describe('successfully interpret a valid response', function () { + const result = spec.interpretResponse(mockServerResponse, mockBidRequest); + + expect(result).to.be.an('array'); + const data = result[0] || {}; + expect(data).to.be.an('object'); + expect(data.requestId).to.be.a('string'); + expect(data.cpm).to.be.a('number'); + expect(data.width).to.be.a('number'); + expect(data.height).to.be.a('number'); + expect(data.creativeId).to.be.a('string'); + expect(data.currency).to.be.a('string'); + expect(data.netRevenue).to.be.a('boolean'); + expect(data.referrer).to.be.a('string'); + expect(data.ttl).to.be.a('number'); + expect(data.ad).to.be.a('string'); + expect(data.mediaType).to.be.a('string'); + expect(data.meta.advertiserDomains).to.be.an('array'); + }); + + describe('should return a blank array if cpm is not set', () => { + mockServerResponse.body.data.cpm = undefined; + const result = spec.interpretResponse(mockServerResponse, mockBidRequest); + expect(result).to.eql([]); + }); + }); + + describe('report', () => { + it('returns if REPORTING_ROUTE is not set', () => { + spec.REPORTING_ROUTE = ''; + expect(spec.report('test', {})).to.be.undefined; + }); + + it('makes a POST request if REPORTING_ROUTE is set', () => { + spec.report('test', {}, '/v1/events'); + + expect(server.requests[0].url).to.equals( + 'https://api.hypelab.com/v1/events' + ); + }); + }); + + describe('callbacks', () => { + let bid = {}; + let reportStub; + + beforeEach(() => (reportStub = sinon.stub(spec, 'report'))); + afterEach(() => reportStub.restore()); + + describe('onTimeout', () => { + it('should call report with the correct data', () => { + spec.onTimeout(bid); + + expect(reportStub.calledOnce).to.be.true; + expect(reportStub.getCall(0).args).to.eql(['timeout', bid]); + }); + }); + + describe('onSetTargeting', () => { + it('should call report with the correct data', () => { + spec.onSetTargeting(bid); + + expect(reportStub.calledOnce).to.be.true; + expect(reportStub.getCall(0).args).to.eql(['setTargeting', bid]); + }); + }); + + describe('onBidWon', () => { + it('should call report with the correct data', () => { + spec.onBidWon(bid); + + expect(reportStub.calledOnce).to.be.true; + expect(reportStub.getCall(0).args).to.eql(['bidWon', bid]); + }); + }); + + describe('onBidderError', () => { + it('should call report with the correct data', () => { + spec.onBidderError(bid); + + expect(reportStub.calledOnce).to.be.true; + expect(reportStub.getCall(0).args).to.eql(['bidderError', bid]); + }); + }); + }); +}); diff --git a/test/spec/modules/iasRtdProvider_spec.js b/test/spec/modules/iasRtdProvider_spec.js index 0d52c594fb5..ec4d2bd437a 100644 --- a/test/spec/modules/iasRtdProvider_spec.js +++ b/test/spec/modules/iasRtdProvider_spec.js @@ -54,6 +54,59 @@ describe('iasRtdProvider is a RTD provider that', function () { const value = iasSubModule.init(config); expect(value).to.equal(true); }); + it('returns true with the pubId, keyMappings and adUnitPath params', function () { + const config = { + name: 'ias', + waitForIt: true, + params: { + pubId: '123456', + keyMappings: { + 'id': 'ias_id' + }, + adUnitPath: {'one-div-id': '/012345/ad/unit/path'} + } + }; + const value = iasSubModule.init(config); + expect(value).to.equal(true); + }); + it('returns true with the pubId and adUnitPath params with multiple keys', function () { + const config = { + name: 'ias', + waitForIt: true, + params: { + pubId: '123456', + keyMappings: { + 'id': 'ias_id' + }, + adUnitPath: { + 'one-div-id': '/012345/ad/unit/path', + 'another-div-id': '/012345/ad/unit/path', + 'third-div-id': '/012345/another/ad/unit/path' + } + } + }; + const value = iasSubModule.init(config); + expect(value).to.equal(true); + }); + it('returns true with the pubId and adUnitPath params with empty values', function () { + const config = { + name: 'ias', + waitForIt: true, + params: { + pubId: '123456', + keyMappings: { + 'id': 'ias_id' + }, + adUnitPath: { + 'one-div-id': '/012345/ad/unit/path', + 'another-div-id': '', + 'third-div-id': '' + } + } + }; + const value = iasSubModule.init(config); + expect(value).to.equal(true); + }); }); describe('has a method `getBidRequestData` that', function () { it('exists', function () { @@ -73,6 +126,7 @@ describe('iasRtdProvider is a RTD provider that', function () { request = server.requests[0]; request.respond(200, responseHeader, JSON.stringify(data)); expect(request.url).to.be.include(`https://pixel.adsafeprotected.com/services/pub?anId=1234`); + expect(request.url).to.be.include('url=https%253A%252F%252Fintegralads.com%252Ftest') expect(adUnits).to.length(2); expect(adUnits[0]).to.be.eq(adUnitsOriginal[0]); const targetingKeys = Object.keys(iasTargeting); @@ -136,6 +190,10 @@ const config = { pubId: 1234, keyMappings: { 'id': 'ias_id' + }, + pageUrl: 'https://integralads.com/test', + adUnitPath: { + 'one-div-id': '/012345/ad/unit/path' } } }; diff --git a/test/spec/modules/id5AnalyticsAdapter_spec.js b/test/spec/modules/id5AnalyticsAdapter_spec.js index 83951c3a6e9..9cb7233ce7c 100644 --- a/test/spec/modules/id5AnalyticsAdapter_spec.js +++ b/test/spec/modules/id5AnalyticsAdapter_spec.js @@ -1,20 +1,18 @@ import adapterManager from '../../../src/adapterManager.js'; import id5AnalyticsAdapter from '../../../modules/id5AnalyticsAdapter.js'; import { expect } from 'chai'; -import sinon from 'sinon'; import * as events from '../../../src/events.js'; import constants from '../../../src/constants.json'; import { generateUUID } from '../../../src/utils.js'; +import {server} from '../../mocks/xhr.js'; const CONFIG_URL = 'https://api.id5-sync.com/analytics/12349/pbjs'; const INGEST_URL = 'https://test.me/ingest'; describe('ID5 analytics adapter', () => { - let server; let config; beforeEach(() => { - server = sinon.createFakeServer(); config = { options: { partnerId: 12349, @@ -22,10 +20,6 @@ describe('ID5 analytics adapter', () => { }; }); - afterEach(() => { - server.restore(); - }); - it('registers itself with the adapter manager', () => { const adapter = adapterManager.getAnalyticsAdapter('id5Analytics'); expect(adapter).to.exist; diff --git a/test/spec/modules/id5IdSystem_spec.js b/test/spec/modules/id5IdSystem_spec.js index 74c2b053ce1..56b23ba9634 100644 --- a/test/spec/modules/id5IdSystem_spec.js +++ b/test/spec/modules/id5IdSystem_spec.js @@ -6,27 +6,35 @@ import { ID5_STORAGE_NAME, id5IdSubmodule, nbCacheName, + storage, storeInLocalStorage, storeNbInCache, } from 'modules/id5IdSystem.js'; -import {coreStorage, init, requestBidsHook, setSubmoduleRegistry} from 'modules/userId/index.js'; +import {coreStorage, getConsentHash, init, requestBidsHook, setSubmoduleRegistry} from 'modules/userId/index.js'; import {config} from 'src/config.js'; -import {server} from 'test/mocks/xhr.js'; import * as events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils.js'; +import {uspDataHandler} from 'src/adapterManager.js'; import 'src/prebid.js'; import {hook} from '../../../src/hook.js'; import {mockGdprConsent} from '../../helpers/consentData.js'; +import {server} from '../../mocks/xhr.js'; +import {expect} from 'chai'; -let expect = require('chai').expect; - -describe('ID5 ID System', function() { +describe('ID5 ID System', function () { const ID5_MODULE_NAME = 'id5Id'; const ID5_EIDS_NAME = ID5_MODULE_NAME.toLowerCase(); const ID5_SOURCE = 'id5-sync.com'; const ID5_TEST_PARTNER_ID = 173; const ID5_ENDPOINT = `https://id5-sync.com/g/v2/${ID5_TEST_PARTNER_ID}.json`; + const ID5_API_CONFIG_URL = `https://id5-sync.com/api/config/prebid`; + const ID5_EXTENSIONS_ENDPOINT = 'https://extensions.id5-sync.com/test'; + const ID5_API_CONFIG = { + fetchCall: { + url: ID5_ENDPOINT + } + }; const ID5_NB_STORAGE_NAME = nbCacheName(ID5_TEST_PARTNER_ID); const ID5_STORED_ID = 'storedid5id'; const ID5_STORED_SIGNATURE = '123456'; @@ -34,7 +42,9 @@ describe('ID5 ID System', function() { const ID5_STORED_OBJ = { 'universal_uid': ID5_STORED_ID, 'signature': ID5_STORED_SIGNATURE, - 'link_type': ID5_STORED_LINK_TYPE + 'ext': { + 'linkType': ID5_STORED_LINK_TYPE + } }; const ID5_RESPONSE_ID = 'newid5id'; const ID5_RESPONSE_SIGNATURE = 'abcdef'; @@ -42,8 +52,27 @@ describe('ID5 ID System', function() { const ID5_JSON_RESPONSE = { 'universal_uid': ID5_RESPONSE_ID, 'signature': ID5_RESPONSE_SIGNATURE, - 'link_type': ID5_RESPONSE_LINK_TYPE + 'link_type': ID5_RESPONSE_LINK_TYPE, + 'ext': { + 'linkType': ID5_RESPONSE_LINK_TYPE + } }; + const ALLOWED_ID5_VENDOR_DATA = { + purpose: { + consents: { + 1: true + } + }, + vendor: { + consents: { + 131: true + } + } + } + + const HEADERS_CONTENT_TYPE_JSON = { + 'Content-Type': 'application/json' + } function getId5FetchConfig(storageName = ID5_STORAGE_NAME, storageType = 'html5') { return { @@ -58,6 +87,7 @@ describe('ID5 ID System', function() { } } } + function getId5ValueConfig(value) { return { name: ID5_MODULE_NAME, @@ -68,6 +98,7 @@ describe('ID5 ID System', function() { } } } + function getUserSyncConfig(userIds) { return { userSync: { @@ -76,12 +107,15 @@ describe('ID5 ID System', function() { } } } + function getFetchLocalStorageConfig() { return getUserSyncConfig([getId5FetchConfig(ID5_STORAGE_NAME, 'html5')]); } + function getValueConfig(value) { return getUserSyncConfig([getId5ValueConfig(value)]); } + function getAdUnitMock(code = 'adUnit-code') { return { code, @@ -91,15 +125,81 @@ describe('ID5 ID System', function() { }; } + function callSubmoduleGetId(config, consentData, cacheIdObj) { + return new Promise((resolve) => { + id5IdSubmodule.getId(config, consentData, cacheIdObj).callback((response) => { + resolve(response) + }) + }); + } + + class XhrServerMock { + constructor(server) { + this.currentRequestIdx = 0 + this.server = server + } + + expectFirstRequest() { + return this.#expectRequest(0); + } + + expectNextRequest() { + return this.#expectRequest(++this.currentRequestIdx) + } + + expectConfigRequest() { + return this.expectFirstRequest() + .then(configRequest => { + expect(configRequest.url).is.eq(ID5_API_CONFIG_URL); + expect(configRequest.method).is.eq('POST'); + return configRequest; + }) + } + + respondWithConfigAndExpectNext(configRequest, config = ID5_API_CONFIG) { + configRequest.respond(200, HEADERS_CONTENT_TYPE_JSON, JSON.stringify(config)); + return this.expectNextRequest() + } + + expectFetchRequest() { + return this.expectConfigRequest() + .then(configRequest => { + return this.respondWithConfigAndExpectNext(configRequest, ID5_API_CONFIG); + }).then(request => { + expect(request.url).is.eq(ID5_API_CONFIG.fetchCall.url); + expect(request.method).is.eq('POST'); + return request; + }) + } + + #expectRequest(index) { + let server = this.server + return new Promise(function (resolve) { + (function waitForCondition() { + if (server.requests && server.requests.length > index) return resolve(server.requests[index]); + setTimeout(waitForCondition, 30); + })(); + }) + .then(request => { + return request + }); + } + + hasReceivedAnyRequest() { + let requests = this.server.requests; + return requests && requests.length > 0; + } + } + before(() => { hook.ready(); }); - describe('Check for valid publisher config', function() { - it('should fail with invalid config', function() { + describe('Check for valid publisher config', function () { + it('should fail with invalid config', function () { // no config - expect(id5IdSubmodule.getId()).to.be.eq(undefined); - expect(id5IdSubmodule.getId({ })).to.be.eq(undefined); + expect(id5IdSubmodule.getId()).is.eq(undefined); + expect(id5IdSubmodule.getId({})).is.eq(undefined); // valid params, invalid storage expect(id5IdSubmodule.getId({ params: { partner: 123 } })).to.be.eq(undefined); @@ -113,7 +213,7 @@ describe('ID5 ID System', function() { expect(id5IdSubmodule.getId({ storage: { name: 'name', type: 'html5', }, params: { partner: 'abc' } })).to.be.eq(undefined); }); - it('should warn with non-recommended storage params', function() { + it('should warn with non-recommended storage params', function () { let logWarnStub = sinon.stub(utils, 'logWarn'); id5IdSubmodule.getId({ storage: { name: 'name', type: 'html5', }, params: { partner: 123 } }); @@ -126,210 +226,580 @@ describe('ID5 ID System', function() { }); }); - describe('Xhr Requests from getId()', function() { - const responseHeader = { 'Content-Type': 'application/json' }; - let callbackSpy = sinon.spy(); + describe('Check for valid consent', function() { + const dataConsentVals = [ + [{purpose: {consents: {1: false}}}, {vendor: {consents: {131: true}}}, ' no purpose consent'], + [{purpose: {consents: {1: true}}}, {vendor: {consents: {131: false}}}, ' no vendor consent'], + [{purpose: {consents: {1: false}}}, {vendor: {consents: {131: false}}}, ' no purpose and vendor consent'], + [{purpose: {consents: undefined}}, {vendor: {consents: {131: true}}}, ' undefined purpose consent'], + [{purpose: {consents: {1: false}}}, {vendor: {consents: undefined}}], ' undefined vendor consent', + [undefined, {vendor: {consents: {131: true}}}, ' undefined purpose'], + [{purpose: {consents: {1: true}}}, {vendor: undefined}, ' undefined vendor'], + [{purpose: {consents: {1: true}}}, {vendor: {consents: {31: true}}}, ' incorrect vendor consent'] + ]; + + dataConsentVals.forEach(function([purposeConsent, vendorConsent, caseName]) { + it('should fail with invalid consent because of ' + caseName, function() { + let dataConsent = { + gdprApplies: true, + consentString: 'consentString', + vendorData: { + purposeConsent, vendorConsent + } + } + expect(id5IdSubmodule.getId(config)).is.eq(undefined); + expect(id5IdSubmodule.getId(config, dataConsent)).is.eq(undefined); + + let cacheIdObject = 'cacheIdObject'; + expect(id5IdSubmodule.extendId(config)).is.eq(undefined); + expect(id5IdSubmodule.extendId(config, dataConsent, cacheIdObject)).is.eq(cacheIdObject); + }); + }); + }); + + describe('Xhr Requests from getId()', function () { + const responseHeader = HEADERS_CONTENT_TYPE_JSON - beforeEach(function() { - callbackSpy.resetHistory(); + beforeEach(function () { }); - afterEach(function () { + afterEach(function () { + uspDataHandler.reset() }); it('should call the ID5 server and handle a valid response', function () { - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, undefined).callback; - submoduleCallback(callbackSpy); - - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(request.url).to.contain(ID5_ENDPOINT); - expect(request.withCredentials).to.be.true; - expect(requestBody.partner).to.eq(ID5_TEST_PARTNER_ID); - expect(requestBody.o).to.eq('pbjs'); - expect(requestBody.pd).to.be.undefined; - expect(requestBody.s).to.be.undefined; - expect(requestBody.provider).to.be.undefined - expect(requestBody.v).to.eq('$prebid.version$'); - expect(requestBody.gdpr).to.exist; - expect(requestBody.gdpr_consent).to.be.undefined; - expect(requestBody.us_privacy).to.be.undefined; - - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); - expect(callbackSpy.calledOnce).to.be.true; - expect(callbackSpy.lastCall.lastArg).to.deep.equal(ID5_JSON_RESPONSE); + let xhrServerMock = new XhrServerMock(server) + let config = getId5FetchConfig(); + let submoduleResponse = callSubmoduleGetId(config, undefined, undefined); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(fetchRequest.url).to.contain(ID5_ENDPOINT); + expect(fetchRequest.withCredentials).is.true; + expect(requestBody.partner).is.eq(ID5_TEST_PARTNER_ID); + expect(requestBody.o).is.eq('pbjs'); + expect(requestBody.pd).is.undefined; + expect(requestBody.s).is.undefined; + expect(requestBody.provider).is.undefined + expect(requestBody.v).is.eq('$prebid.version$'); + expect(requestBody.gdpr).is.eq(0); + expect(requestBody.gdpr_consent).is.undefined; + expect(requestBody.us_privacy).is.undefined; + expect(requestBody.storage).is.deep.eq(config.storage) + + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(submoduleResponse => { + expect(submoduleResponse).is.deep.equal(ID5_JSON_RESPONSE); + }); + }); + + it('should call the ID5 server with gdpr data ', function () { + let xhrServerMock = new XhrServerMock(server) + let consentData = { + gdprApplies: true, + consentString: 'consentString', + vendorData: ALLOWED_ID5_VENDOR_DATA + } + + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), consentData, undefined); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.partner).is.eq(ID5_TEST_PARTNER_ID); + expect(requestBody.gdpr).to.eq(1); + expect(requestBody.gdpr_consent).is.eq(consentData.consentString); + + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(submoduleResponse => { + expect(submoduleResponse).is.deep.equal(ID5_JSON_RESPONSE); + }); + }); + + it('should call the ID5 server without gdpr data when gdpr not applies ', function () { + let xhrServerMock = new XhrServerMock(server) + let consentData = { + gdprApplies: false, + consentString: 'consentString' + } + + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), consentData, undefined); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.gdpr).to.eq(0); + expect(requestBody.gdpr_consent).is.undefined + + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(submoduleResponse => { + expect(submoduleResponse).is.deep.equal(ID5_JSON_RESPONSE); + }); + }); + + it('should call the ID5 server with us privacy consent', function () { + let usPrivacyString = '1YN-'; + uspDataHandler.setConsentData(usPrivacyString) + let xhrServerMock = new XhrServerMock(server) + let consentData = { + gdprApplies: true, + consentString: 'consentString', + vendorData: ALLOWED_ID5_VENDOR_DATA + } + + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), consentData, undefined); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.partner).is.eq(ID5_TEST_PARTNER_ID); + expect(requestBody.us_privacy).to.eq(usPrivacyString); + + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(submoduleResponse => { + expect(submoduleResponse).is.deep.equal(ID5_JSON_RESPONSE); + }); }); it('should call the ID5 server with no signature field when no stored object', function () { - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, undefined).callback; - submoduleCallback(callbackSpy); + let xhrServerMock = new XhrServerMock(server) + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, undefined); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.s).is.undefined; + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + }); + + it('should call the ID5 server for config with submodule config object', function () { + let xhrServerMock = new XhrServerMock(server) + let id5FetchConfig = getId5FetchConfig(); + id5FetchConfig.params.extraParam = { + x: 'X', + y: { + a: 1, + b: '3' + } + } + let submoduleResponse = callSubmoduleGetId(id5FetchConfig, undefined, undefined); + + return xhrServerMock.expectConfigRequest() + .then(configRequest => { + let requestBody = JSON.parse(configRequest.requestBody) + expect(requestBody).is.deep.eq(id5FetchConfig) + return xhrServerMock.respondWithConfigAndExpectNext(configRequest) + }) + .then(fetchRequest => { + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + }); - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.s).to.be.undefined; + it('should call the ID5 server for config with partner id being a string', function () { + let xhrServerMock = new XhrServerMock(server) + let id5FetchConfig = getId5FetchConfig(); + id5FetchConfig.params.partner = '173'; + let submoduleResponse = callSubmoduleGetId(id5FetchConfig, undefined, undefined); + + return xhrServerMock.expectConfigRequest() + .then(configRequest => { + let requestBody = JSON.parse(configRequest.requestBody) + expect(requestBody.params.partner).is.eq(173) + return xhrServerMock.respondWithConfigAndExpectNext(configRequest) + }) + .then(fetchRequest => { + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + }); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + it('should call the ID5 server for config with overridden url', function () { + let xhrServerMock = new XhrServerMock(server) + let id5FetchConfig = getId5FetchConfig(); + id5FetchConfig.params.configUrl = 'http://localhost/x/y/z' + + let submoduleResponse = callSubmoduleGetId(id5FetchConfig, undefined, undefined); + + return xhrServerMock.expectFirstRequest() + .then(configRequest => { + expect(configRequest.url).is.eq('http://localhost/x/y/z') + return xhrServerMock.respondWithConfigAndExpectNext(configRequest) + }) + .then(fetchRequest => { + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) }); - it('should call the ID5 server with signature field from stored object', function () { - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); + it('should call the ID5 server with additional data when provided', function () { + let xhrServerMock = new XhrServerMock(server) + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, undefined); + + return xhrServerMock.expectConfigRequest() + .then(configRequest => { + return xhrServerMock.respondWithConfigAndExpectNext(configRequest, { + fetchCall: { + url: ID5_ENDPOINT, + overrides: { + arg1: '123', + arg2: { + x: '1', + y: 2 + } + } + } + }); + }) + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.partner).is.eq(ID5_TEST_PARTNER_ID); + expect(requestBody.o).is.eq('pbjs'); + expect(requestBody.v).is.eq('$prebid.version$'); + expect(requestBody.arg1).is.eq('123') + expect(requestBody.arg2).is.deep.eq({ + x: '1', + y: 2 + }) + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + }); + + it('should call the ID5 server with extensions', function () { + let xhrServerMock = new XhrServerMock(server) + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, undefined); + + return xhrServerMock.expectConfigRequest() + .then(configRequest => { + return xhrServerMock.respondWithConfigAndExpectNext(configRequest, { + fetchCall: { + url: ID5_ENDPOINT + }, + extensionsCall: { + url: ID5_EXTENSIONS_ENDPOINT, + method: 'GET' + } + }); + }) + .then(extensionsRequest => { + expect(extensionsRequest.url).is.eq(ID5_EXTENSIONS_ENDPOINT) + expect(extensionsRequest.method).is.eq('GET') + extensionsRequest.respond(200, responseHeader, JSON.stringify({ + lb: 'ex' + })) + return xhrServerMock.expectNextRequest(); + }) + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.partner).is.eq(ID5_TEST_PARTNER_ID); + expect(requestBody.o).is.eq('pbjs'); + expect(requestBody.v).is.eq('$prebid.version$'); + expect(requestBody.extensions).is.deep.eq({ + lb: 'ex' + }) + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + }); - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.s).to.eq(ID5_STORED_SIGNATURE); + it('should call the ID5 server with extensions fetched with POST', function () { + let xhrServerMock = new XhrServerMock(server) + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, undefined); + + return xhrServerMock.expectConfigRequest() + .then(configRequest => { + return xhrServerMock.respondWithConfigAndExpectNext(configRequest, { + fetchCall: { + url: ID5_ENDPOINT + }, + extensionsCall: { + url: ID5_EXTENSIONS_ENDPOINT, + method: 'POST', + body: { + x: '1', + y: 2 + } + } + }); + }) + .then(extensionsRequest => { + expect(extensionsRequest.url).is.eq(ID5_EXTENSIONS_ENDPOINT) + expect(extensionsRequest.method).is.eq('POST') + let requestBody = JSON.parse(extensionsRequest.requestBody) + expect(requestBody).is.deep.eq({ + x: '1', + y: 2 + }) + extensionsRequest.respond(200, responseHeader, JSON.stringify({ + lb: 'post', + })) + return xhrServerMock.expectNextRequest(); + }) + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.partner).is.eq(ID5_TEST_PARTNER_ID); + expect(requestBody.o).is.eq('pbjs'); + expect(requestBody.v).is.eq('$prebid.version$'); + expect(requestBody.extensions).is.deep.eq({ + lb: 'post' + }) + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + }); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + it('should call the ID5 server with signature field from stored object', function () { + let xhrServerMock = new XhrServerMock(server) + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, ID5_STORED_OBJ); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.s).is.eq(ID5_STORED_SIGNATURE); + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) }); it('should call the ID5 server with pd field when pd config is set', function () { + let xhrServerMock = new XhrServerMock(server) const pubData = 'b50ca08271795a8e7e4012813f23d505193d75c0f2e2bb99baa63aa822f66ed3'; let id5Config = getId5FetchConfig(); id5Config.params.pd = pubData; - let submoduleCallback = id5IdSubmodule.getId(id5Config, undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); - - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.pd).to.eq(pubData); + let submoduleResponse = callSubmoduleGetId(id5Config, undefined, ID5_STORED_OBJ); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.pd).is.eq(pubData); + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse; + }) }); it('should call the ID5 server with no pd field when pd config is not set', function () { + let xhrServerMock = new XhrServerMock(server) let id5Config = getId5FetchConfig(); id5Config.params.pd = undefined; - let submoduleCallback = id5IdSubmodule.getId(id5Config, undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); + let submoduleResponse = callSubmoduleGetId(id5Config, undefined, ID5_STORED_OBJ); - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.pd).to.be.undefined; - - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.pd).is.undefined; + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse; + }) }); it('should call the ID5 server with nb=1 when no stored value exists and reset after', function () { + let xhrServerMock = new XhrServerMock(server) coreStorage.removeDataFromLocalStorage(ID5_NB_STORAGE_NAME); - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); - - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.nbPage).to.eq(1); - - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); - - expect(getNbFromCache(ID5_TEST_PARTNER_ID)).to.be.eq(0); + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, ID5_STORED_OBJ); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.nbPage).is.eq(1); + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(() => { + expect(getNbFromCache(ID5_TEST_PARTNER_ID)).is.eq(0); + }) }); it('should call the ID5 server with incremented nb when stored value exists and reset after', function () { + let xhrServerMock = new XhrServerMock(server) storeNbInCache(ID5_TEST_PARTNER_ID, 1); - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); - - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.nbPage).to.eq(2); - - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); - - expect(getNbFromCache(ID5_TEST_PARTNER_ID)).to.be.eq(0); + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, ID5_STORED_OBJ); + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.nbPage).is.eq(2); + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(() => { + expect(getNbFromCache(ID5_TEST_PARTNER_ID)).is.eq(0); + }) }); it('should call the ID5 server with ab_testing object when abTesting is turned on', function () { + let xhrServerMock = new XhrServerMock(server) let id5Config = getId5FetchConfig(); - id5Config.params.abTesting = { enabled: true, controlGroupPct: 0.234 } - - let submoduleCallback = id5IdSubmodule.getId(id5Config, undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); + id5Config.params.abTesting = {enabled: true, controlGroupPct: 0.234} - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.ab_testing.enabled).to.eq(true); - expect(requestBody.ab_testing.control_group_pct).to.eq(0.234); + let submoduleResponse = callSubmoduleGetId(id5Config, undefined, ID5_STORED_OBJ); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.ab_testing.enabled).is.eq(true); + expect(requestBody.ab_testing.control_group_pct).is.eq(0.234); + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse; + }); }); it('should call the ID5 server without ab_testing object when abTesting is turned off', function () { + let xhrServerMock = new XhrServerMock(server) let id5Config = getId5FetchConfig(); - id5Config.params.abTesting = { enabled: false, controlGroupPct: 0.55 } - - let submoduleCallback = id5IdSubmodule.getId(id5Config, undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); + id5Config.params.abTesting = {enabled: false, controlGroupPct: 0.55} - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.ab_testing).to.be.undefined; + let submoduleResponse = callSubmoduleGetId(id5Config, undefined, ID5_STORED_OBJ); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.ab_testing).is.undefined; + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }); }); it('should call the ID5 server without ab_testing when when abTesting is not set', function () { + let xhrServerMock = new XhrServerMock(server) let id5Config = getId5FetchConfig(); - let submoduleCallback = id5IdSubmodule.getId(id5Config, undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); - - let request = server.requests[0]; - let requestBody = JSON.parse(request.requestBody); - expect(requestBody.ab_testing).to.be.undefined; + let submoduleResponse = callSubmoduleGetId(id5Config, undefined, ID5_STORED_OBJ); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.ab_testing).is.undefined; + fetchRequest.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }); }); it('should store the privacy object from the ID5 server response', function () { - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); - - let request = server.requests[0]; + let xhrServerMock = new XhrServerMock(server) + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, ID5_STORED_OBJ); - let responseObject = utils.deepClone(ID5_JSON_RESPONSE); - responseObject.privacy = { + const privacy = { jurisdiction: 'gdpr', id5_consent: true }; - request.respond(200, responseHeader, JSON.stringify(responseObject)); - expect(getFromLocalStorage(ID5_PRIVACY_STORAGE_NAME)).to.be.eq(JSON.stringify(responseObject.privacy)); - coreStorage.removeDataFromLocalStorage(ID5_PRIVACY_STORAGE_NAME); + + return xhrServerMock.expectFetchRequest() + .then(request => { + let responseObject = utils.deepClone(ID5_JSON_RESPONSE); + responseObject.privacy = privacy; + request.respond(200, responseHeader, JSON.stringify(responseObject)); + return submoduleResponse + }) + .then(() => { + expect(getFromLocalStorage(ID5_PRIVACY_STORAGE_NAME)).is.eq(JSON.stringify(privacy)); + coreStorage.removeDataFromLocalStorage(ID5_PRIVACY_STORAGE_NAME); + }) }); it('should not store a privacy object if not part of ID5 server response', function () { + let xhrServerMock = new XhrServerMock(server) coreStorage.removeDataFromLocalStorage(ID5_PRIVACY_STORAGE_NAME); - let submoduleCallback = id5IdSubmodule.getId(getId5FetchConfig(), undefined, ID5_STORED_OBJ).callback; - submoduleCallback(callbackSpy); + let submoduleResponse = callSubmoduleGetId(getId5FetchConfig(), undefined, ID5_STORED_OBJ); + + return xhrServerMock.expectFetchRequest() + .then(request => { + let responseObject = utils.deepClone(ID5_JSON_RESPONSE); + responseObject.privacy = undefined; + request.respond(200, responseHeader, JSON.stringify(responseObject)); + return submoduleResponse + }) + .then(() => { + expect(getFromLocalStorage(ID5_PRIVACY_STORAGE_NAME)).is.null; + }); + }); - let request = server.requests[0]; + describe('when legacy cookies are set', () => { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + sandbox.stub(storage, 'getCookie'); + }); + afterEach(() => { + sandbox.restore(); + }); + it('should not throw if malformed JSON is forced into cookies', () => { + storage.getCookie.callsFake(() => ' Not JSON '); + id5IdSubmodule.getId(getId5FetchConfig()); + }); + }) + }); - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); - expect(getFromLocalStorage(ID5_PRIVACY_STORAGE_NAME)).to.be.null; + describe('Local storage', () => { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + sandbox.stub(storage, 'localStorageIsEnabled'); + }); + afterEach(() => { + sandbox.restore(); }); + [ + [true, 1], + [false, 0] + ].forEach(function ([isEnabled, expectedValue]) { + it(`should check localStorage availability and log in request. Available=${isEnabled}`, () => { + let xhrServerMock = new XhrServerMock(server) + let config = getId5FetchConfig(); + let submoduleResponse = callSubmoduleGetId(config, undefined, undefined); + storage.localStorageIsEnabled.callsFake(() => isEnabled) + + return xhrServerMock.expectFetchRequest() + .then(fetchRequest => { + let requestBody = JSON.parse(fetchRequest.requestBody); + expect(requestBody.localStorage).is.eq(expectedValue); + + fetchRequest.respond(200, HEADERS_CONTENT_TYPE_JSON, JSON.stringify(ID5_JSON_RESPONSE)); + return submoduleResponse + }) + .then(submoduleResponse => { + expect(submoduleResponse).is.deep.equal(ID5_JSON_RESPONSE); + }); + }) + }) }); - describe('Request Bids Hook', function() { + describe('Request Bids Hook', function () { let adUnits; let sandbox; - beforeEach(function() { + beforeEach(function () { sandbox = sinon.sandbox.create(); mockGdprConsent(sandbox); sinon.stub(events, 'getEvents').returns([]); coreStorage.removeDataFromLocalStorage(ID5_STORAGE_NAME); coreStorage.removeDataFromLocalStorage(`${ID5_STORAGE_NAME}_last`); coreStorage.removeDataFromLocalStorage(ID5_NB_STORAGE_NAME); + coreStorage.setDataInLocalStorage(ID5_STORAGE_NAME + '_cst', getConsentHash()) adUnits = [getAdUnitMock()]; }); - afterEach(function() { + afterEach(function () { events.getEvents.restore(); coreStorage.removeDataFromLocalStorage(ID5_STORAGE_NAME); coreStorage.removeDataFromLocalStorage(`${ID5_STORAGE_NAME}_last`); coreStorage.removeDataFromLocalStorage(ID5_NB_STORAGE_NAME); + coreStorage.removeDataFromLocalStorage(ID5_STORAGE_NAME + '_cst') sandbox.restore(); }); @@ -344,8 +814,8 @@ describe('ID5 ID System', function() { adUnits.forEach(unit => { unit.bids.forEach(bid => { expect(bid).to.have.deep.nested.property(`userId.${ID5_EIDS_NAME}`); - expect(bid.userId.id5id.uid).to.equal(ID5_STORED_ID); - expect(bid.userIdAsEids[0]).to.deep.equal({ + expect(bid.userId.id5id.uid).is.equal(ID5_STORED_ID); + expect(bid.userIdAsEids[0]).is.deep.equal({ source: ID5_SOURCE, uids: [{ id: ID5_STORED_ID, @@ -358,7 +828,7 @@ describe('ID5 ID System', function() { }); }); done(); - }, { adUnits }); + }, {adUnits}); }); it('should add config value ID to bids', function (done) { @@ -370,15 +840,15 @@ describe('ID5 ID System', function() { adUnits.forEach(unit => { unit.bids.forEach(bid => { expect(bid).to.have.deep.nested.property(`userId.${ID5_EIDS_NAME}`); - expect(bid.userId.id5id.uid).to.equal(ID5_STORED_ID); - expect(bid.userIdAsEids[0]).to.deep.equal({ + expect(bid.userId.id5id.uid).is.equal(ID5_STORED_ID); + expect(bid.userIdAsEids[0]).is.deep.equal({ source: ID5_SOURCE, - uids: [{ id: ID5_STORED_ID, atype: 1 }] + uids: [{id: ID5_STORED_ID, atype: 1}] }); }); }); done(); - }, { adUnits }); + }, {adUnits}); }); it('should set nb=1 in cache when no stored nb value exists and cached ID', function (done) { @@ -390,7 +860,7 @@ describe('ID5 ID System', function() { config.setConfig(getFetchLocalStorageConfig()); requestBidsHook((adUnitConfig) => { - expect(getNbFromCache(ID5_TEST_PARTNER_ID)).to.be.eq(1); + expect(getNbFromCache(ID5_TEST_PARTNER_ID)).is.eq(1); done() }, {adUnits}); }); @@ -404,19 +874,20 @@ describe('ID5 ID System', function() { config.setConfig(getFetchLocalStorageConfig()); requestBidsHook(() => { - expect(getNbFromCache(ID5_TEST_PARTNER_ID)).to.be.eq(2); + expect(getNbFromCache(ID5_TEST_PARTNER_ID)).is.eq(2); done() }, {adUnits}); }); it('should call ID5 servers with signature and incremented nb post auction if refresh needed', function () { - storeInLocalStorage(ID5_STORAGE_NAME, JSON.stringify(ID5_STORED_OBJ), 1); + let xhrServerMock = new XhrServerMock(server) + let initialLocalStorageValue = JSON.stringify(ID5_STORED_OBJ); + storeInLocalStorage(ID5_STORAGE_NAME, initialLocalStorageValue, 1); storeInLocalStorage(`${ID5_STORAGE_NAME}_last`, expDaysStr(-1), 1); - storeNbInCache(ID5_TEST_PARTNER_ID, 1); + storeNbInCache(ID5_TEST_PARTNER_ID, 1); let id5Config = getFetchLocalStorageConfig(); id5Config.userSync.userIds[0].storage.refreshInSeconds = 2; - init(config); setSubmoduleRegistry([id5IdSubmodule]); config.setConfig(id5Config); @@ -426,53 +897,61 @@ describe('ID5 ID System', function() { resolve() }, {adUnits}); }).then(() => { - expect(getNbFromCache(ID5_TEST_PARTNER_ID)).to.be.eq(2); - expect(server.requests).to.be.empty; + expect(xhrServerMock.hasReceivedAnyRequest()).is.false; events.emit(CONSTANTS.EVENTS.AUCTION_END, {}); - return new Promise((resolve) => setTimeout(resolve)) - }).then(() => { - let request = server.requests[0]; + return xhrServerMock.expectFetchRequest() + }).then(request => { let requestBody = JSON.parse(request.requestBody); - expect(request.url).to.contain(ID5_ENDPOINT); - expect(requestBody.s).to.eq(ID5_STORED_SIGNATURE); - expect(requestBody.nbPage).to.eq(2); - - const responseHeader = { 'Content-Type': 'application/json' }; - request.respond(200, responseHeader, JSON.stringify(ID5_JSON_RESPONSE)); - - expect(decodeURIComponent(getFromLocalStorage(ID5_STORAGE_NAME))).to.be.eq(JSON.stringify(ID5_JSON_RESPONSE)); - expect(getNbFromCache(ID5_TEST_PARTNER_ID)).to.be.eq(0); + expect(requestBody.s).is.eq(ID5_STORED_SIGNATURE); + expect(requestBody.nbPage).is.eq(2); + expect(getNbFromCache(ID5_TEST_PARTNER_ID)).is.eq(2); + request.respond(200, HEADERS_CONTENT_TYPE_JSON, JSON.stringify(ID5_JSON_RESPONSE)); + + return new Promise(function (resolve) { + (function waitForCondition() { + if (getFromLocalStorage(ID5_STORAGE_NAME) !== initialLocalStorageValue) return resolve(); + setTimeout(waitForCondition, 30); + })(); + }) + }).then(() => { + expect(decodeURIComponent(getFromLocalStorage(ID5_STORAGE_NAME))).is.eq(JSON.stringify(ID5_JSON_RESPONSE)); + expect(getNbFromCache(ID5_TEST_PARTNER_ID)).is.eq(0); }) }); }); - describe('Decode stored object', function() { - const expectedDecodedObject = { id5id: { uid: ID5_STORED_ID, ext: { linkType: ID5_STORED_LINK_TYPE } } }; + describe('Decode stored object', function () { + const expectedDecodedObject = {id5id: {uid: ID5_STORED_ID, ext: {linkType: ID5_STORED_LINK_TYPE}}}; - it('should properly decode from a stored object', function() { - expect(id5IdSubmodule.decode(ID5_STORED_OBJ, getId5FetchConfig())).to.deep.equal(expectedDecodedObject); + it('should properly decode from a stored object', function () { + expect(id5IdSubmodule.decode(ID5_STORED_OBJ, getId5FetchConfig())).is.deep.equal(expectedDecodedObject); }); - it('should return undefined if passed a string', function() { - expect(id5IdSubmodule.decode('somestring', getId5FetchConfig())).to.eq(undefined); + it('should return undefined if passed a string', function () { + expect(id5IdSubmodule.decode('somestring', getId5FetchConfig())).is.eq(undefined); }); }); - describe('A/B Testing', function() { - const expectedDecodedObjectWithIdAbOff = { id5id: { uid: ID5_STORED_ID, ext: { linkType: ID5_STORED_LINK_TYPE } } }; - const expectedDecodedObjectWithIdAbOn = { id5id: { uid: ID5_STORED_ID, ext: { linkType: ID5_STORED_LINK_TYPE, abTestingControlGroup: false } } }; - const expectedDecodedObjectWithoutIdAbOn = { id5id: { uid: '', ext: { linkType: 0, abTestingControlGroup: true } } }; + describe('A/B Testing', function () { + const expectedDecodedObjectWithIdAbOff = {id5id: {uid: ID5_STORED_ID, ext: {linkType: ID5_STORED_LINK_TYPE}}}; + const expectedDecodedObjectWithIdAbOn = { + id5id: { + uid: ID5_STORED_ID, + ext: {linkType: ID5_STORED_LINK_TYPE, abTestingControlGroup: false} + } + }; + const expectedDecodedObjectWithoutIdAbOn = {id5id: {uid: '', ext: {linkType: 0, abTestingControlGroup: true}}}; let testConfig, storedObject; - beforeEach(function() { + beforeEach(function () { testConfig = getId5FetchConfig(); storedObject = utils.deepClone(ID5_STORED_OBJ); }); - describe('A/B Testing Config is Set', function() { + describe('A/B Testing Config is Set', function () { let randStub; - beforeEach(function() { - randStub = sinon.stub(Math, 'random').callsFake(function() { + beforeEach(function () { + randStub = sinon.stub(Math, 'random').callsFake(function () { return 0.25; }); }); @@ -480,39 +959,41 @@ describe('ID5 ID System', function() { randStub.restore(); }); - describe('Decode', function() { + describe('Decode', function () { let logErrorSpy; - beforeEach(function() { + beforeEach(function () { logErrorSpy = sinon.spy(utils, 'logError'); }); - afterEach(function() { + afterEach(function () { logErrorSpy.restore(); }); it('should not set abTestingControlGroup extension when A/B testing is off', function () { let decoded = id5IdSubmodule.decode(storedObject, testConfig); - expect(decoded).to.deep.equal(expectedDecodedObjectWithIdAbOff); + expect(decoded).is.deep.equal(expectedDecodedObjectWithIdAbOff); }); it('should set abTestingControlGroup to false when A/B testing is on but in normal group', function () { - storedObject.ab_testing = { result: 'normal' }; + storedObject.ab_testing = {result: 'normal'}; let decoded = id5IdSubmodule.decode(storedObject, testConfig); - expect(decoded).to.deep.equal(expectedDecodedObjectWithIdAbOn); + expect(decoded).is.deep.equal(expectedDecodedObjectWithIdAbOn); }); it('should not expose ID when everyone is in control group', function () { - storedObject.ab_testing = { result: 'control' }; + storedObject.ab_testing = {result: 'control'}; storedObject.universal_uid = ''; - storedObject.link_type = 0; + storedObject.ext = { + 'linkType': 0 + }; let decoded = id5IdSubmodule.decode(storedObject, testConfig); - expect(decoded).to.deep.equal(expectedDecodedObjectWithoutIdAbOn); + expect(decoded).is.deep.equal(expectedDecodedObjectWithoutIdAbOn); }); it('should log A/B testing errors', function () { - storedObject.ab_testing = { result: 'error' }; + storedObject.ab_testing = {result: 'error'}; let decoded = id5IdSubmodule.decode(storedObject, testConfig); - expect(decoded).to.deep.equal(expectedDecodedObjectWithIdAbOff); + expect(decoded).is.deep.equal(expectedDecodedObjectWithIdAbOff); sinon.assert.calledOnce(logErrorSpy); }); }); diff --git a/test/spec/modules/idWardRtdProvider_spec.js b/test/spec/modules/idWardRtdProvider_spec.js index 949365baec6..924a3794c7b 100644 --- a/test/spec/modules/idWardRtdProvider_spec.js +++ b/test/spec/modules/idWardRtdProvider_spec.js @@ -45,7 +45,11 @@ describe('idWardRtdProvider', function() { } }; - const bidConfig = {}; + const bidConfig = { + ortb2Fragments: { + global: {} + } + }; const rtdUserObj1 = { name: 'id-ward.com', @@ -65,9 +69,8 @@ describe('idWardRtdProvider', function() { getDataFromLocalStorageStub.withArgs('cohort_ids') .returns(JSON.stringify(['TCZPQOWPEJG3MJOTUQUF793A', '93SUG3H540WBJMYNT03KX8N3'])); - expect(config.getConfig().ortb2).to.be.undefined; getRealTimeData(bidConfig, () => {}, rtdConfig, {}); - expect(config.getConfig().ortb2.user.data).to.deep.include.members([rtdUserObj1]); + expect(bidConfig.ortb2Fragments.global.user.data).to.deep.include.members([rtdUserObj1]); }); it('do not set rtd if local storage empty', function() { diff --git a/test/spec/modules/identityLinkIdSystem_spec.js b/test/spec/modules/identityLinkIdSystem_spec.js index a31270c86c7..a273f26b28b 100644 --- a/test/spec/modules/identityLinkIdSystem_spec.js +++ b/test/spec/modules/identityLinkIdSystem_spec.js @@ -1,13 +1,22 @@ -import {identityLinkSubmodule} from 'modules/identityLinkIdSystem.js'; +import {getEnvelopeFromStorage, identityLinkSubmodule} from 'modules/identityLinkIdSystem.js'; import * as utils from 'src/utils.js'; import {server} from 'test/mocks/xhr.js'; -import {getStorageManager} from '../../../src/storageManager.js'; +import {getCoreStorageManager} from '../../../src/storageManager.js'; +import {stub} from 'sinon'; -export const storage = getStorageManager(); +const storage = getCoreStorageManager(); const pid = '14'; let defaultConfigParams; -const responseHeader = {'Content-Type': 'application/json'} +const responseHeader = {'Content-Type': 'application/json'}; +const testEnvelope = 'eyJ0aW1lc3RhbXAiOjE2OTEwNjU5MzQwMTcsInZlcnNpb24iOiIxLjIuMSIsImVudmVsb3BlIjoiQWhIenUyMFN3WHZ6T0hPd3c2bkxaODAtd2hoN2Nnd0FqWllNdkQ0UjBXT25xRVc1N21zR2Vral9QejU2b1FwcGdPOVB2aFJFa3VHc2lMdG56c3A2aG13eDRtTTRNLTctRy12NiJ9'; +const testEnvelopeValue = '{"timestamp":1691065934017,"version":"1.2.1","envelope":"AhHzu20SwXvzOHOww6nLZ80-whh7cgwAjZYMvD4R0WOnqEW57msGekj_Pz56oQppgO9PvhREkuGsiLtnzsp6hmwx4mM4M-7-G-v6"}'; + +function setTestEnvelopeCookie () { + let now = new Date(); + now.setTime(now.getTime() + 3000); + storage.setCookie('_lr_env', testEnvelope, now.toUTCString()); +} describe('IdentityLinkId tests', function () { let logErrorStub; @@ -17,6 +26,7 @@ describe('IdentityLinkId tests', function () { logErrorStub = sinon.stub(utils, 'logError'); // remove _lr_retry_request cookie before test storage.setCookie('_lr_retry_request', 'true', 'Thu, 01 Jan 1970 00:00:01 GMT'); + storage.setCookie('_lr_env', testEnvelope, 'Thu, 01 Jan 1970 00:00:01 GMT'); }); afterEach(function () { @@ -111,10 +121,8 @@ describe('IdentityLinkId tests', function () { request.respond( 204, responseHeader, - '' ); expect(callBackSpy.calledOnce).to.be.true; - expect(request.response).to.equal(''); expect(logErrorStub.calledOnce).to.not.be.true; }); @@ -165,4 +173,43 @@ describe('IdentityLinkId tests', function () { let request = server.requests[0]; expect(request).to.be.eq(undefined); }); + + it('should get envelope from storage if ats is not present on a page and pass it to callback', function () { + setTestEnvelopeCookie(); + let envelopeValueFromStorage = getEnvelopeFromStorage(); + let callBackSpy = sinon.spy(); + let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; + submoduleCallback(callBackSpy); + expect(envelopeValueFromStorage).to.be.a('string'); + expect(callBackSpy.calledOnce).to.be.true; + }) + + it('if there is no envelope in storage and ats is not present on a page try to call 3p url', function () { + let envelopeValueFromStorage = getEnvelopeFromStorage(); + let callBackSpy = sinon.spy(); + let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.be.eq('https://api.rlcdn.com/api/identity/envelope?pid=14'); + request.respond( + 204, + responseHeader, + ); + expect(envelopeValueFromStorage).to.be.a('undefined'); + expect(callBackSpy.calledOnce).to.be.true; + }) + + it('if ats is present on a page, and envelope is generated and stored in storage, call a callback', function () { + setTestEnvelopeCookie(); + let envelopeValueFromStorage = getEnvelopeFromStorage(); + window.ats = {retrieveEnvelope: function() { + }} + // mock ats.retrieveEnvelope to return envelope + stub(window.ats, 'retrieveEnvelope').callsFake(function() { return envelopeValueFromStorage }) + let callBackSpy = sinon.spy(); + let submoduleCallback = identityLinkSubmodule.getId(defaultConfigParams).callback; + submoduleCallback(callBackSpy); + expect(envelopeValueFromStorage).to.be.a('string'); + expect(envelopeValueFromStorage).to.be.eq(testEnvelopeValue); + }) }); diff --git a/test/spec/modules/idxBidAdapter_spec.js b/test/spec/modules/idxBidAdapter_spec.js new file mode 100644 index 00000000000..4721b0d4b6e --- /dev/null +++ b/test/spec/modules/idxBidAdapter_spec.js @@ -0,0 +1,103 @@ +import { expect } from 'chai' +import { spec } from 'modules/idxBidAdapter.js' + +const BIDDER_CODE = 'idx' +const ENDPOINT_URL = 'https://dev-event.dxmdp.com/rest/api/v1/bid' +const DEFAULT_PRICE = 1 +const DEFAULT_CURRENCY = 'USD' +const DEFAULT_BANNER_WIDTH = 300 +const DEFAULT_BANNER_HEIGHT = 250 + +describe('idxBidAdapter', function () { + describe('isBidRequestValid', function () { + let validBid = { + bidder: BIDDER_CODE, + mediaTypes: { + banner: { + sizes: [[DEFAULT_BANNER_WIDTH, DEFAULT_BANNER_HEIGHT]] + } + } + } + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(validBid)).to.equal(true) + }) + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, validBid) + bid.mediaTypes = {} + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) + }) + describe('buildRequests', function () { + let bidRequests = [ + { + bidder: BIDDER_CODE, + bidId: 'asdf12345', + mediaTypes: { + banner: { + sizes: [[DEFAULT_BANNER_WIDTH, DEFAULT_BANNER_HEIGHT]] + } + }, + } + ] + let bidderRequest = { + bidderCode: BIDDER_CODE, + bidderRequestId: '12345asdf', + bids: [ + { + ...bidRequests[0] + } + ], + } + + it('sends video bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest) + expect(request.url).to.equal(ENDPOINT_URL) + expect(request.method).to.equal('POST') + }) + }) + describe('interpretResponse', function () { + it('should get correct bid response', function () { + let response = { + id: 'f6adb85f-4e19-45a0-b41e-2a5b9a48f23a', + seatbid: [ + { + bid: [ + { + id: '123', + impid: 'b4f290d7-d4ab-4778-ab94-2baf06420b22', + price: DEFAULT_PRICE, + adm: 'hi', + cid: 'test_cid', + crid: 'test_banner_crid', + w: DEFAULT_BANNER_WIDTH, + h: DEFAULT_BANNER_HEIGHT, + adomain: [], + } + ], + seat: BIDDER_CODE + } + ], + } + + let expectedResponse = [ + { + requestId: 'b4f290d7-d4ab-4778-ab94-2baf06420b22', + cpm: DEFAULT_PRICE, + width: DEFAULT_BANNER_WIDTH, + height: DEFAULT_BANNER_HEIGHT, + creativeId: 'test_banner_crid', + ad: 'hi', + currency: DEFAULT_CURRENCY, + netRevenue: true, + ttl: 300, + meta: { advertiserDomains: [] }, + } + ] + let result = spec.interpretResponse({ body: response }) + + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])) + }) + }) +}) diff --git a/test/spec/modules/idxIdSystem_spec.js b/test/spec/modules/idxIdSystem_spec.js index 7d008ef0d28..56e1c709c8b 100644 --- a/test/spec/modules/idxIdSystem_spec.js +++ b/test/spec/modules/idxIdSystem_spec.js @@ -94,8 +94,8 @@ describe('IDx ID System', () => { adUnits = [getAdUnitMock()]; init(config); setSubmoduleRegistry([idxIdSubmodule]); - config.setConfig(getConfigMock()); getCookieStub.withArgs(IDX_COOKIE_NAME).returns(IDX_COOKIE_STORED); + config.setConfig(getConfigMock()); }); afterEach(() => { diff --git a/test/spec/modules/imRtdProvider_spec.js b/test/spec/modules/imRtdProvider_spec.js index 6d92440a144..89328b91529 100644 --- a/test/spec/modules/imRtdProvider_spec.js +++ b/test/spec/modules/imRtdProvider_spec.js @@ -27,7 +27,8 @@ describe('imRtdProvider', function () { const moduleConfig = { params: { cid: 5126, - setGptKeyValues: true + setGptKeyValues: true, + maxSegments: 2 } } @@ -50,7 +51,6 @@ describe('imRtdProvider', function () { describe('getBidderFunction', function () { const assumedBidder = [ - 'ix', 'pubmatic', 'fluct' ]; @@ -61,11 +61,11 @@ describe('imRtdProvider', function () { it(`should return bid with correct key data: ${bidderName}`, function () { const bid = {bidder: bidderName}; - expect(getBidderFunction(bidderName)(bid, {'im_segments': ['12345', '67890']})).to.equal(bid); + expect(getBidderFunction(bidderName)(bid, {'im_segments': ['12345', '67890']}, {params: {}})).to.equal(bid); }); it(`should return bid without data: ${bidderName}`, function () { const bid = {bidder: bidderName}; - expect(getBidderFunction(bidderName)(bid, '')).to.equal(bid); + expect(getBidderFunction(bidderName)(bid, '', {params: {}})).to.equal(bid); }); }); it(`should return null with unexpected bidder`, function () { @@ -74,7 +74,7 @@ describe('imRtdProvider', function () { describe('fluct bidder function', function () { it('should return a bid w/o im_segments if not any exists', function () { const bid = {bidder: 'fluct'}; - expect(getBidderFunction('fluct')(bid, '')).to.eql(bid); + expect(getBidderFunction('fluct')(bid, '', {params: {}})).to.eql(bid); }); it('should return a bid w/ im_segments if any exists', function () { const bid = { @@ -85,7 +85,11 @@ describe('imRtdProvider', function () { } } }; - expect(getBidderFunction('fluct')(bid, {im_segments: ['12345', '67890']})) + expect(getBidderFunction('fluct')( + bid, + {im_segments: ['12345', '67890', '09876']}, + {params: {maxSegments: 2}} + )) .to.eql( { bidder: 'fluct', diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/imdsBidAdapter_spec.js similarity index 86% rename from test/spec/modules/synacormediaBidAdapter_spec.js rename to test/spec/modules/imdsBidAdapter_spec.js index b9a02799219..7d808a2528f 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/imdsBidAdapter_spec.js @@ -1,9 +1,10 @@ import { assert, expect } from 'chai'; import { BANNER } from 'src/mediaTypes.js'; import { config } from 'src/config.js'; -import { spec } from 'modules/synacormediaBidAdapter.js'; +import { spec } from 'modules/imdsBidAdapter.js'; +import * as utils from 'src/utils.js'; -describe('synacormediaBidAdapter ', function () { +describe('imdsBidAdapter ', function () { describe('isBidRequestValid', function () { let bid; beforeEach(function () { @@ -115,7 +116,7 @@ describe('synacormediaBidAdapter ', function () { }); describe('buildRequests', function () { let validBidRequestVideo = { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', tagId: '1234', @@ -140,7 +141,7 @@ describe('synacormediaBidAdapter ', function () { }; let bidderRequestVideo = { - bidderCode: 'synacormedia', + bidderCode: 'imds', auctionId: 'VideoAuctionId124', bidderRequestId: '117954d20d7c9c', auctionStart: 1553624929697, @@ -177,18 +178,59 @@ describe('synacormediaBidAdapter ', function () { }; let bidderRequest = { - auctionId: 'xyz123', + bidderRequestId: 'xyz123', refererInfo: { referer: 'https://test.com/foo/bar' } }; - let bidderRequestWithCCPA = { + let bidderRequestWithTimeout = { auctionId: 'xyz123', refererInfo: { referer: 'https://test.com/foo/bar' }, - uspConsent: '1YYY' + timeout: 3000 + }; + + let bidderRequestWithUSPInExt = { + bidderRequestId: 'xyz123', + refererInfo: { + referer: 'https://test.com/foo/bar' + }, + ortb2: { + regs: { + ext: { + us_privacy: '1YYY' + } + } + } + }; + + let bidderRequestWithUSPInRegs = { + bidderRequestId: 'xyz123', + refererInfo: { + referer: 'https://test.com/foo/bar' + }, + ortb2: { + regs: { + us_privacy: '1YYY' + } + } + }; + + let bidderRequestWithUSPAndOthersInExt = { + bidderRequestId: 'xyz123', + refererInfo: { + referer: 'https://test.com/foo/bar' + }, + ortb2: { + regs: { + ext: { + extra: 'extra item', + us_privacy: '1YYY' + } + } + } }; let validBidRequestWithUserIds = { @@ -291,10 +333,19 @@ describe('synacormediaBidAdapter ', function () { expect(reqVideo).to.have.property('url'); expect(reqVideo.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(reqVideo.data).to.exist.and.to.be.an('object'); - expect(reqVideo.data.id).to.equal('VideoAuctionId124'); expect(reqVideo.data.imp).to.eql([expectedDataVideo1]); }); + it('should return no tmax', function () { + let req = spec.buildRequests([validBidRequest], bidderRequest); + expect(req.data).to.not.have.property('tmax'); + }); + + it('should return tmax equal to callback timeout', function () { + let req = spec.buildRequests([validBidRequest], bidderRequestWithTimeout); + expect(req.data.tmax).to.eql(bidderRequestWithTimeout.timeout); + }); + it('should return multiple bids when multiple valid requests with the same seatId are used', function () { let secondBidRequest = { bidId: 'foobar', @@ -373,7 +424,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([badFloorBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -404,7 +455,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([badFloorBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -436,7 +487,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([newPosBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -467,7 +518,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([newPosBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -525,7 +576,7 @@ describe('synacormediaBidAdapter ', function () { }); it('should use all the video params in the impression request', function () { let validBidRequestVideo = { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', tagId: '1234', @@ -559,7 +610,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidRequestVideo], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -583,7 +634,7 @@ describe('synacormediaBidAdapter ', function () { }); it('should move any video params in the mediaTypes object to params.video object', function () { let validBidRequestVideo = { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', tagId: '1234', @@ -617,7 +668,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidRequestVideo], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data.id).to.equal('xyz123'); expect(req.data.imp).to.eql([ { @@ -641,7 +692,7 @@ describe('synacormediaBidAdapter ', function () { }); it('should create params.video object if not present on bid request and move any video params in the mediaTypes object to it', function () { let validBidRequestVideo = { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', tagId: '1234' @@ -683,16 +734,42 @@ describe('synacormediaBidAdapter ', function () { } ]); }); - it('should contain the CCPA privacy string when UspConsent is in bidder request', function () { + it('should have us_privacy string in regs instead of regs.ext bidder request', function () { + let req = spec.buildRequests([validBidRequest], bidderRequestWithUSPInExt); + expect(req).be.an('object'); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.data).to.exist.and.to.be.an('object'); + expect(req.data.id).to.equal('xyz123'); + expect(req.data.regs.us_privacy).to.equal('1YYY'); + expect(req.data.regs.ext).to.not.exist; + expect(req.data.imp).to.eql([expectedDataImp1]); + }); + it('should accept us_privacy string in regs', function () { // banner test - let req = spec.buildRequests([validBidRequest], bidderRequestWithCCPA); + let req = spec.buildRequests([validBidRequest], bidderRequestWithUSPInRegs); expect(req).be.an('object'); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); expect(req.data).to.exist.and.to.be.an('object'); expect(req.data.id).to.equal('xyz123'); - expect(req.data.regs.ext.us_privacy).to.equal('1YYY'); + expect(req.data.regs.us_privacy).to.equal('1YYY'); + expect(req.data.regs.ext).to.not.exist; + expect(req.data.imp).to.eql([expectedDataImp1]); + }); + it('should not remove regs.ext when moving us_privacy if there are other things in regs.ext', function () { + // banner test + let req = spec.buildRequests([validBidRequest], bidderRequestWithUSPAndOthersInExt); + expect(req).be.an('object'); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('https://prebid.technoratimedia.com/openrtb/bids/prebid?'); + expect(req.data).to.exist.and.to.be.an('object'); + expect(req.data.id).to.equal('xyz123'); + expect(req.data.regs.us_privacy).to.equal('1YYY'); + expect(req.data.regs.ext.extra).to.equal('extra item'); expect(req.data.imp).to.eql([expectedDataImp1]); }); it('should contain user object when user ids are present in the bidder request', function () { @@ -713,7 +790,7 @@ describe('synacormediaBidAdapter ', function () { describe('Bid Requests with placementId should be backward compatible ', function () { let validVideoBidReq = { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', placementId: 'demo1', @@ -754,7 +831,7 @@ describe('synacormediaBidAdapter ', function () { refererInfo: { referer: 'http://localhost:9999/' }, - bidderCode: 'synacormedia', + bidderCode: 'imds', auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110' }; @@ -762,20 +839,20 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBannerBidRequest], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); }); it('should return valid bid request for video impression', function () { let req = spec.buildRequests([validVideoBidReq], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); }); }); describe('Bid Requests with schain object ', function () { let validBidReq = { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', tagId: 'demo1', @@ -817,12 +894,12 @@ describe('synacormediaBidAdapter ', function () { refererInfo: { referer: 'http://localhost:9999/' }, - bidderCode: 'synacormedia', + bidderCode: 'imds', auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110', bidderRequestId: '16d438671bfbec', bids: [ { - bidder: 'synacormedia', + bidder: 'imds', params: { seatId: 'prebid', tagId: 'demo1', @@ -869,7 +946,7 @@ describe('synacormediaBidAdapter ', function () { let req = spec.buildRequests([validBidReq], bidderRequest); expect(req).to.have.property('method', 'POST'); expect(req).to.have.property('url'); - expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=pbjs%2F$prebid.version$'); expect(req.data).to.have.property('source'); expect(req.data.source).to.have.property('ext'); expect(req.data.source.ext).to.have.property('schain'); @@ -1275,27 +1352,49 @@ describe('synacormediaBidAdapter ', function () { }); }); describe('getUserSyncs', function () { - it('should return a usersync when iframes is enabled', function () { + it('should return an iframe usersync when iframes is enabled', function () { let usersyncs = spec.getUserSyncs({ iframeEnabled: true }, null); - expect(usersyncs).to.be.an('array').that.is.not.empty; + expect(usersyncs).to.be.an('array').with.lengthOf(1); expect(usersyncs[0]).to.have.property('type', 'iframe'); expect(usersyncs[0]).to.have.property('url'); expect(usersyncs[0].url).to.contain('https://ad-cdn.technoratimedia.com/html/usersync.html'); }); - it('should not return a usersync when iframes are not enabled', function () { + it('should return a pixel usersync when pixels is enabled', function () { + let usersyncs = spec.getUserSyncs({ + pixelEnabled: true + }, null); + expect(usersyncs).to.be.an('array').with.lengthOf(1); + expect(usersyncs[0]).to.have.property('type', 'pixel'); + expect(usersyncs[0]).to.have.property('url'); + expect(usersyncs[0].url).to.contain('https://sync.technoratimedia.com/services'); + }); + + it('should return an iframe usersync when both iframe and pixels is enabled', function () { let usersyncs = spec.getUserSyncs({ + iframeEnabled: true, pixelEnabled: true }, null); + expect(usersyncs).to.be.an('array').with.lengthOf(1); + expect(usersyncs[0]).to.have.property('type', 'iframe'); + expect(usersyncs[0]).to.have.property('url'); + expect(usersyncs[0].url).to.contain('https://ad-cdn.technoratimedia.com/html/usersync.html'); + }); + + it('should not return a usersync when neither iframes nor pixel are enabled', function () { + let usersyncs = spec.getUserSyncs({ + iframeEnabled: false, + pixelEnabled: false + }, null); expect(usersyncs).to.be.an('array').that.is.empty; }); }); describe('Bid Requests with price module should use if available', function () { let validVideoBidRequest = { - bidder: 'synacormedia', + bidder: 'imds', params: { bidfloor: '0.50', seatId: 'prebid', @@ -1338,7 +1437,7 @@ describe('synacormediaBidAdapter ', function () { refererInfo: { referer: 'http://localhost:9999/' }, - bidderCode: 'synacormedia', + bidderCode: 'imds', auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110' }; @@ -1362,4 +1461,78 @@ describe('synacormediaBidAdapter ', function () { expect(videoRequest.data.imp[0].bidfloor).to.equal(priceModuleFloor); }); }); + + describe('Bid Requests with gpid or anything in bid.ext should use if available', function () { + let validVideoBidRequest = { + bidder: 'imds', + params: { + seatId: 'prebid', + placementId: 'demo1', + pos: 1, + video: {} + }, + renderer: { + url: '../syncOutstreamPlayer.js' + }, + ortb2Imp: { + ext: { + gpid: '/1111/homepage-video', + data: { + pbadslot: '/1111/homepage-video' + } + } + }, + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream' + } + }, + adUnitCode: 'div-1', + transactionId: '0869f34e-090b-4b20-84ee-46ff41405a39', + sizes: [[300, 250]], + bidId: '22b3a2268d9f0e', + bidderRequestId: '1d195910597e13', + auctionId: '3375d336-2aea-4ee7-804c-6d26b621ad20', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }; + + let validBannerBidRequest = { + bidId: '9876abcd', + sizes: [[300, 250]], + params: { + seatId: 'prebid', + placementId: '1234', + }, + ortb2Imp: { + ext: { + gpid: '/1111/homepage-banner', + data: { + pbadslot: '/1111/homepage-banner' + } + } + } + }; + + let bidderRequest = { + refererInfo: { + referer: 'http://localhost:9999/' + }, + bidderCode: 'imds', + auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110' + }; + + it('should return valid gpid and pbadslot', function () { + let videoRequest = spec.buildRequests([validVideoBidRequest], bidderRequest); + let bannerRequest = spec.buildRequests([validBannerBidRequest], bidderRequest); + + expect(videoRequest.data.imp[0].ext.gpid).to.equal('/1111/homepage-video'); + expect(videoRequest.data.imp[0].ext.data.pbadslot).to.equal('/1111/homepage-video'); + expect(bannerRequest.data.imp[0].ext.gpid).to.equal('/1111/homepage-banner'); + expect(bannerRequest.data.imp[0].ext.data.pbadslot).to.equal('/1111/homepage-banner'); + }); + }); }); diff --git a/test/spec/modules/impactifyBidAdapter_spec.js b/test/spec/modules/impactifyBidAdapter_spec.js index 8bb2d089ad8..215972ff450 100644 --- a/test/spec/modules/impactifyBidAdapter_spec.js +++ b/test/spec/modules/impactifyBidAdapter_spec.js @@ -166,6 +166,19 @@ describe('ImpactifyAdapter', function () { } }; + it('should pass bidfloor', function () { + videoBidRequests[0].getFloor = function() { + return { + currency: 'USD', + floor: 1.23, + } + } + + const res = spec.buildRequests(videoBidRequests, videoBidderRequest) + const resData = JSON.parse(res.data) + expect(resData.imp[0].bidfloor).to.equal(1.23) + }); + it('sends video bid request to ENDPOINT via POST', function () { const request = spec.buildRequests(videoBidRequests, videoBidderRequest); expect(request.url).to.equal(ORIGIN + AUCTIONURI); diff --git a/test/spec/modules/improvedigitalBidAdapter_spec.js b/test/spec/modules/improvedigitalBidAdapter_spec.js index 9dcc11f5aa1..f427f9e7624 100644 --- a/test/spec/modules/improvedigitalBidAdapter_spec.js +++ b/test/spec/modules/improvedigitalBidAdapter_spec.js @@ -1,12 +1,31 @@ -import { expect } from 'chai'; -import { spec } from 'modules/improvedigitalBidAdapter.js'; -import { config } from 'src/config.js'; -import * as utils from 'src/utils.js'; -import {BANNER, VIDEO} from '../../../src/mediaTypes'; +import {expect} from 'chai'; +import {CONVERTER, spec} from 'modules/improvedigitalBidAdapter.js'; +import {config} from 'src/config.js'; +import {deepClone} from 'src/utils.js'; +import {BANNER, NATIVE, VIDEO} from '../../../src/mediaTypes'; +import {deepSetValue} from '../../../src/utils'; +// load modules that register ORTB processors +import 'src/prebid.js'; +import 'modules/currency.js'; +import 'modules/userId/index.js'; +import 'modules/multibid/index.js'; +import 'modules/priceFloors.js'; +import 'modules/consentManagement.js'; +import 'modules/consentManagementUsp.js'; +import 'modules/schain.js'; +import {decorateAdUnitsWithNativeParams} from '../../../src/native.js'; +import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js'; +import {hook} from '../../../src/hook.js'; describe('Improve Digital Adapter Tests', function () { const METHOD = 'POST'; - const URL = 'https://ad.360yield.com/pb'; + const AD_SERVER_BASE_URL = 'https://ad.360yield.com'; + const BASIC_ADS_BASE_URL = 'https://ad.360yield-basic.com'; + const PB_ENDPOINT = 'pb'; + const AD_SERVER_URL = `${AD_SERVER_BASE_URL}/${PB_ENDPOINT}`; + const BASIC_ADS_URL = `${BASIC_ADS_BASE_URL}/${PB_ENDPOINT}`; + const EXTEND_URL = 'https://pbs.360yield.com/openrtb2/auction'; + const IFRAME_SYNC_URL = 'https://hb.360yield.com/prebid-universal-creative/load-cookie.html'; const INSTREAM_TYPE = 1; const OUTSTREAM_TYPE = 3; @@ -28,21 +47,34 @@ describe('Improve Digital Adapter Tests', function () { sizes: [[300, 250], [160, 600]] }; + const extendBidRequest = deepClone(simpleBidRequest); + extendBidRequest.params.extend = true; + const videoParams = { skip: 1, skipmin: 5, skipafter: 30 } - const instreamBidRequest = utils.deepClone(simpleBidRequest); - instreamBidRequest.mediaTypes = { - video: { - context: 'instream', - playerSize: [640, 480] + const instreamBidRequest = { + bidder: 'improvedigital', + params: { + placementId: 123456 + }, + adUnitCode: 'video1', + transactionId: 'vf183e871-fbed-45f0-a427-c8a63c4c01eb', + bidId: '33e9500b21129f', + bidderRequestId: 'v2772c1e566670b', + auctionId: 'v192721e36a0239', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480] + } } }; - const outstreamBidRequest = utils.deepClone(simpleBidRequest); + const outstreamBidRequest = deepClone(instreamBidRequest); outstreamBidRequest.mediaTypes = { video: { context: 'outstream', @@ -50,18 +82,33 @@ describe('Improve Digital Adapter Tests', function () { } }; - const multiFormatBidRequest = utils.deepClone(simpleBidRequest); + const nativeBidRequest = deepClone(simpleBidRequest); + nativeBidRequest.mediaTypes = { native: {} }; + nativeBidRequest.nativeParams = { + title: {required: true}, + body: {required: true} + }; + + const multiFormatBidRequest = deepClone(simpleBidRequest); multiFormatBidRequest.mediaTypes = { banner: { sizes: [[300, 250], [160, 600]] }, + native: {}, video: { context: 'outstream', playerSize: [640, 480] } }; + multiFormatBidRequest.nativeParams = { + body: { + required: true + } + }; + const simpleSmartTagBidRequest = { + mediaTypes: {}, bidder: 'improvedigital', bidId: '1a2b3c', placementCode: 'placement1', @@ -72,38 +119,65 @@ describe('Improve Digital Adapter Tests', function () { }; const bidderRequest = { - bids: [simpleBidRequest] + ortb2: { + source: { + tid: 'mock-tid' + } + }, + bids: [simpleBidRequest], + }; + + const extendBidderRequest = { + bids: [extendBidRequest], }; const instreamBidderRequest = { - bids: [instreamBidRequest] + bids: [instreamBidRequest], }; const outstreamBidderRequest = { - bids: [outstreamBidRequest] + bids: [outstreamBidRequest], }; const multiFormatBidderRequest = { - bids: [multiFormatBidRequest] + bids: [multiFormatBidRequest], + }; + + const nativeBidderRequest = { + bids: [nativeBidRequest], + }; + + const gdprConsent = { + apiVersion: 2, + consentString: 'CONSENT', + vendorData: { purpose: { consents: { 1: true } } }, + gdprApplies: true, + addtlConsent: '1~1.35.41.101', }; const bidderRequestGdpr = { bids: [simpleBidRequest], - gdprConsent: { - consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', - vendorData: {}, - gdprApplies: true, - addtlConsent: '1~1.35.41.101', - }, + gdprConsent }; const bidderRequestReferrer = { bids: [simpleBidRequest], refererInfo: { - referer: 'https://blah.com/test.html', + page: 'https://blah.com/test.html', + domain: 'blah.com' }, }; + function updateNativeParams(bidRequests) { + bidRequests = deepClone(bidRequests); + decorateAdUnitsWithNativeParams(bidRequests); + return bidRequests; + } + + before(() => { + hook.ready(); + }); + describe('isBidRequestValid', function () { it('should return false when no bid', function () { expect(spec.isBidRequestValid()).to.equal(false); @@ -144,27 +218,34 @@ describe('Improve Digital Adapter Tests', function () { }); describe('buildRequests', function () { + let getConfigStub = null; + + afterEach(function () { + if (getConfigStub) { + getConfigStub.restore(); + getConfigStub = null; + } + }); + it('should make a well-formed request objects', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); - const request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; + const request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequest))[0]; expect(request).to.be.an('object'); expect(request.method).to.equal(METHOD); - expect(request.url).to.equal(URL); - expect(request.bidderRequest).to.deep.equal(bidderRequest); + expect(request.url).to.equal(AD_SERVER_URL); const payload = JSON.parse(request.data); expect(payload).to.be.an('object'); expect(payload.id).to.be.a('string'); expect(payload.tmax).not.to.exist; - expect(payload.cur).to.be.an('array'); expect(payload.regs).to.not.exist; expect(payload.schain).to.not.exist; - expect(payload.source).to.be.an('object'); + sinon.assert.match(payload.source, {tid: 'mock-tid'}) expect(payload.device).to.be.an('object'); expect(payload.user).to.not.exist; - expect(payload.imp).to.deep.equal([ - { + sinon.assert.match(payload.imp, [ + sinon.match({ id: '33e9500b21129f', secure: 0, ext: { @@ -178,24 +259,22 @@ describe('Improve Digital Adapter Tests', function () { {w: 160, h: 600}, ] } - } + }) ]); - getConfigStub.restore(); }); it('should make a well-formed request object for multi-format ad unit', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); - const request = spec.buildRequests([multiFormatBidRequest], multiFormatBidderRequest)[0]; + const request = spec.buildRequests(updateNativeParams([multiFormatBidRequest]), multiFormatBidderRequest)[0]; expect(request).to.be.an('object'); expect(request.method).to.equal(METHOD); - expect(request.url).to.equal(URL); - expect(request.bidderRequest).to.deep.equal(multiFormatBidderRequest); + expect(request.url).to.equal(AD_SERVER_URL); const payload = JSON.parse(request.data); expect(payload).to.be.an('object'); - expect(payload.imp).to.deep.equal([ - { + sinon.assert.match(payload.imp, [ + sinon.match({ id: '33e9500b21129f', secure: 0, ext: { @@ -203,23 +282,69 @@ describe('Improve Digital Adapter Tests', function () { placementId: 1053688, } }, - video: { - placement: OUTSTREAM_TYPE, - w: 640, - h: 480, - mimes: ['video/mp4'], - }, + ...(FEATURES.VIDEO && { + video: { + placement: OUTSTREAM_TYPE, + w: 640, + h: 480, + mimes: ['video/mp4'], + } + }), banner: { format: [ {w: 300, h: 250}, {w: 160, h: 600}, ] } - } + }) ]); - getConfigStub.restore(); + if (FEATURES.NATIVE) { + sinon.assert.match(payload.imp[0], { + native: { + ver: '1.2' + }, + }) + const nativeReq = JSON.parse(payload.imp[0].native.request); + sinon.assert.match(nativeReq, { + eventtrackers: [ + {event: 1, methods: [1, 2]}, + ], + 'assets': [ + sinon.match({'required': 1, 'data': {'type': 2}}) + ] + }); + } }); + if (FEATURES.NATIVE) { + it('should make a well-formed native request', function () { + const payload = JSON.parse(spec.buildRequests(updateNativeParams([nativeBidRequest]), {})[0].data); + const nativeReq = JSON.parse(payload.imp[0].native.request); + sinon.assert.match(nativeReq, { + eventtrackers: [ + {event: 1, methods: [1, 2]}, + ], + assets: [ + sinon.match({required: 1, title: {len: 140}}), + sinon.match({required: 1, data: {type: 2}}) + ] + }) + }); + + it('should not make native request when nativeOrtbRequest is undefined', function () { + const requests = updateNativeParams([nativeBidRequest]); + delete requests[0].nativeOrtbRequest; + const payload = JSON.parse(spec.buildRequests(requests, {})[0].data); + expect(payload.imp[0].native).to.not.exist; + }); + + it('should not make native request when no assets', function () { + const requests = updateNativeParams([{...nativeBidRequest, nativeParams: {}}]) + const payload = JSON.parse(spec.buildRequests(requests, {})[0].data); + expect(payload.imp[0].native).to.not.exist; + }); + } + it('should set placementKey and publisherId for smart tags', function () { const payload = JSON.parse(spec.buildRequests([simpleSmartTagBidRequest], bidderRequest)[0].data); expect(payload.imp[0].ext.bidder.publisherId).to.equal(1032); @@ -238,26 +363,15 @@ describe('Improve Digital Adapter Tests', function () { expect(payload.imp[0].ext.bidder.keyValues).to.deep.equal(keyValues); }); - // it('should add single size filter', function () { - // const bidRequest = Object.assign({}, simpleBidRequest); - // const size = { - // w: 800, - // h: 600 - // }; - // bidRequest.params.size = size; - // const payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest).data); - // expect(payload.imp[0].banner).to.deep.equal(size); - // // When single size filter is set, format shouldn't be populated. This - // // is to maintain backward compatibily - // expect(payload.imp[0].banner.format).to.not.exist; - // }); - it('should add currency', function () { - const bidRequest = Object.assign({}, simpleBidRequest); - const getConfigStub = sinon.stub(config, 'getConfig').returns('JPY'); - const payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); - expect(payload.cur).to.deep.equal(['JPY']); - getConfigStub.restore(); + config.setConfig({currency: {adServerCurrency: 'JPY'}}); + try { + const bidRequest = Object.assign({}, simpleBidRequest); + const payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); + expect(payload.cur).to.deep.equal(['JPY']); + } finally { + config.resetConfig(); + } }); it('should add bid floor', function () { @@ -288,164 +402,176 @@ describe('Improve Digital Adapter Tests', function () { it('should add GDPR consent string', function () { const bidRequest = Object.assign({}, simpleBidRequest); - const payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequestGdpr)[0].data); + const payload = JSON.parse(spec.buildRequests([bidRequest], syncAddFPDToBidderRequest(bidderRequestGdpr))[0].data); expect(payload.regs.ext.gdpr).to.exist.and.to.equal(1); - expect(payload.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); + expect(payload.user.ext.consent).to.equal('CONSENT'); + expect(payload.user.ext.ConsentedProvidersSettings).to.not.exist; expect(payload.user.ext.consented_providers_settings.consented_providers).to.exist.and.to.deep.equal([1, 35, 41, 101]); }); + it('should not add consented providers when empty', function () { + const bidderRequestGdprEmptyAddtl = deepClone(bidderRequestGdpr); + bidderRequestGdprEmptyAddtl.gdprConsent.addtlConsent = '1~'; + const bidRequest = Object.assign({}, simpleBidRequest); + const payload = JSON.parse(spec.buildRequests([bidRequest], syncAddFPDToBidderRequest(bidderRequestGdprEmptyAddtl))[0].data); + expect(payload.user.ext.consented_providers_settings).to.not.exist; + }); + + it('should add ConsentedProvidersSettings when extend mode enabled', function () { + const bidRequest = deepClone(extendBidRequest); + const payload = JSON.parse(spec.buildRequests([bidRequest], syncAddFPDToBidderRequest(bidderRequestGdpr))[0].data); + expect(payload.regs.ext.gdpr).to.exist.and.to.equal(1); + expect(payload.user.ext.consent).to.equal('CONSENT'); + expect(payload.user.ext.ConsentedProvidersSettings.consented_providers).to.exist.and.to.equal('1~1.35.41.101'); + expect(payload.user.ext.consented_providers_settings).to.not.exist; + }); + it('should add CCPA consent string', function () { const bidRequest = Object.assign({}, simpleBidRequest); - const request = spec.buildRequests([bidRequest], {...bidderRequest, ...{ uspConsent: '1YYY' }}); + const request = spec.buildRequests([bidRequest], syncAddFPDToBidderRequest({...bidderRequest, ...{ uspConsent: '1YYY' }})); const payload = JSON.parse(request[0].data); expect(payload.regs.ext.us_privacy).to.equal('1YYY'); }); + it('should add COPPA flag', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('coppa').returns(true); + let bidRequest = Object.assign({}, simpleBidRequest); + let payload = JSON.parse(spec.buildRequests([bidRequest], syncAddFPDToBidderRequest(bidderRequestGdpr))[0].data); + expect(payload.regs.coppa).to.equal(1); + getConfigStub.withArgs('coppa').returns(false); + bidRequest = Object.assign({}, simpleBidRequest); + payload = JSON.parse(spec.buildRequests([bidRequest], syncAddFPDToBidderRequest(bidderRequestGdpr))[0].data); + expect(payload.regs.coppa).to.equal(0); + }); + it('should add referrer', function () { const bidRequest = Object.assign({}, simpleBidRequest); - const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0]; + const request = spec.buildRequests([bidRequest], syncAddFPDToBidderRequest(bidderRequestReferrer))[0]; const payload = JSON.parse(request.data); expect(payload.site.page).to.equal('https://blah.com/test.html'); }); + it('should add timeout', function () { + const bidderRequestTimeout = deepClone(bidderRequest); + // Int + bidderRequestTimeout.timeout = 300; + const bidRequest = Object.assign({}, simpleBidRequest); + let request = spec.buildRequests([bidRequest], bidderRequestTimeout)[0]; + expect(JSON.parse(request.data).tmax).to.equal(300); + + // String + bidderRequestTimeout.timeout = '500'; + request = spec.buildRequests([bidRequest], bidderRequestTimeout)[0]; + expect(JSON.parse(request.data).tmax).to.equal(500); + }); + it('should not add video params for banner', function () { - const bidRequest = JSON.parse(JSON.stringify(simpleBidRequest)); + const bidRequest = deepClone(simpleBidRequest); bidRequest.params.video = videoParams; const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const payload = JSON.parse(request.data); expect(payload.imp[0].video).to.not.exist; }); - it('should add correct placement value for instream and outstream video', function () { - let bidRequest = JSON.parse(JSON.stringify(simpleBidRequest)); - let payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); - expect(payload.imp[0].video).to.not.exist; + if (FEATURES.VIDEO) { + it('should add correct placement value for instream and outstream video', function () { + let bidRequest = deepClone(simpleBidRequest); + let payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); + expect(payload.imp[0].video).to.not.exist; - bidRequest = JSON.parse(JSON.stringify(simpleBidRequest)); - bidRequest.mediaTypes = { - video: { - context: 'instream', - playerSize: [640, 480] - } - }; - payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); - expect(payload.imp[0].video.placement).to.exist.and.equal(1); - bidRequest.mediaTypes.video.context = 'outstream'; - payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); - expect(payload.imp[0].video.placement).to.exist.and.equal(3); - }); - - it('should set video params for instream', function() { - const bidRequest = JSON.parse(JSON.stringify(instreamBidRequest)); - delete bidRequest.mediaTypes.video.playerSize; - const videoParams = { - mimes: ['video/mp4'], - skip: 1, - skipmin: 5, - skipafter: 30, - minduration: 15, - maxduration: 60, - startdelay: 5, - minbitrate: 500, - maxbitrate: 2000, - w: 1024, - h: 640, - placement: INSTREAM_TYPE, - }; - bidRequest.params.video = videoParams; - const request = spec.buildRequests([bidRequest], bidderRequest)[0]; - const payload = JSON.parse(request.data); - expect(payload.imp[0].video).to.deep.equal(videoParams); - }); + bidRequest = deepClone(simpleBidRequest); + bidRequest.mediaTypes = { + video: { + context: 'instream', + playerSize: [640, 480] + } + }; + payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); + expect(payload.imp[0].video.placement).to.exist.and.equal(1); + bidRequest.mediaTypes.video.context = 'outstream'; + payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest)[0].data); + expect(payload.imp[0].video.placement).to.exist.and.equal(3); + }); - it('should set video playerSize over video params', () => { - const bidRequest = JSON.parse(JSON.stringify(instreamBidRequest)); - bidRequest.params.video = { - w: 1024, h: 640 - } - const request = spec.buildRequests([bidRequest], bidderRequest)[0]; - const payload = JSON.parse(request.data); - expect(payload.imp[0].video.h).equal(480); - expect(payload.imp[0].video.w).equal(640); - }); + it('should set video params for instream', function() { + const bidRequest = deepClone(instreamBidRequest); + delete bidRequest.mediaTypes.video.playerSize; + const videoParams = { + mimes: ['video/mp4'], + skip: 1, + skipmin: 5, + skipafter: 30, + minduration: 15, + maxduration: 60, + startdelay: 5, + minbitrate: 500, + maxbitrate: 2000, + w: 1024, + h: 640, + placement: INSTREAM_TYPE, + }; + bidRequest.params.video = videoParams; + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; + const payload = JSON.parse(request.data); + expect(payload.imp[0].video).to.deep.equal(videoParams); + }); - it('should set skip params only if skip=1', function() { - const bidRequest = JSON.parse(JSON.stringify(instreamBidRequest)); - // 1 - const videoTest = { - skip: 1, - skipmin: 5, - skipafter: 30 - } - bidRequest.params.video = videoTest; - let request = spec.buildRequests([bidRequest])[0]; - let payload = JSON.parse(request.data); - expect(payload.imp[0].video.skip).to.equal(1); - expect(payload.imp[0].video.skipmin).to.equal(5); - expect(payload.imp[0].video.skipafter).to.equal(30); - - // 0 - leave out skipmin and skipafter - videoTest.skip = 0; - bidRequest.params.video = videoTest; - request = spec.buildRequests([bidRequest])[0]; - payload = JSON.parse(request.data); - expect(payload.imp[0].video.skip).to.equal(0); - expect(payload.imp[0].video.skipmin).to.not.exist; - expect(payload.imp[0].video.skipafter).to.not.exist; - - // other - videoTest.skip = 'blah'; - bidRequest.params.video = videoTest; - request = spec.buildRequests([bidRequest])[0]; - payload = JSON.parse(request.data); - expect(payload.imp[0].video.skip).to.not.exist; - expect(payload.imp[0].video.skipmin).to.not.exist; - expect(payload.imp[0].video.skipafter).to.not.exist; - }); + it('should set video playerSize over video params', () => { + const bidRequest = deepClone(instreamBidRequest); + bidRequest.params.video = { + w: 1024, h: 640 + } + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; + const payload = JSON.parse(request.data); + expect(payload.imp[0].video.h).equal(480); + expect(payload.imp[0].video.w).equal(640); + }); - it('should ignore invalid/unexpected video params', function() { - const bidRequest = JSON.parse(JSON.stringify(instreamBidRequest)); - // 1 - const videoTest = { - skip: 1, - skipmin: 5, - skipafter: 30 - } - const videoTestInvParam = Object.assign({}, videoTest); - videoTestInvParam.blah = 1; - bidRequest.params.video = videoTestInvParam; - let request = spec.buildRequests([bidRequest])[0]; - let payload = JSON.parse(request.data); - expect(payload.imp[0].video.blah).not.to.exist; - }); + it('should ignore invalid/unexpected video params', function() { + const bidRequest = deepClone(instreamBidRequest); + // 1 + const videoTest = { + skip: 1, + skipmin: 5, + skipafter: 30 + } + const videoTestInvParam = Object.assign({}, videoTest); + videoTestInvParam.blah = 1; + bidRequest.params.video = videoTestInvParam; + let request = spec.buildRequests([bidRequest], {})[0]; + let payload = JSON.parse(request.data); + expect(payload.imp[0].video.blah).not.to.exist; + }); - it('should set video params for outstream', function() { - const bidRequest = JSON.parse(JSON.stringify(outstreamBidRequest)); - bidRequest.params.video = videoParams; - const request = spec.buildRequests([bidRequest])[0]; - const payload = JSON.parse(request.data); - expect(payload.imp[0].video).to.deep.equal({...{ - mimes: ['video/mp4'], - placement: OUTSTREAM_TYPE, - w: bidRequest.mediaTypes.video.playerSize[0], - h: bidRequest.mediaTypes.video.playerSize[1], - }, - ...videoParams}); - }); - // - it('should set video params for multi-format', function() { - const bidRequest = JSON.parse(JSON.stringify(multiFormatBidRequest)); - bidRequest.params.video = videoParams; - const request = spec.buildRequests([bidRequest])[0]; - const payload = JSON.parse(request.data); - const testVideoParams = Object.assign({ - placement: OUTSTREAM_TYPE, - w: 640, - h: 480, - mimes: ['video/mp4'], - }, videoParams); - expect(payload.imp[0].video).to.deep.equal(testVideoParams); - }); + it('should set video params for outstream', function() { + const bidRequest = deepClone(outstreamBidRequest); + bidRequest.params.video = videoParams; + const request = spec.buildRequests([bidRequest], {})[0]; + const payload = JSON.parse(request.data); + expect(payload.imp[0].video).to.deep.equal({...{ + mimes: ['video/mp4'], + placement: OUTSTREAM_TYPE, + w: bidRequest.mediaTypes.video.playerSize[0], + h: bidRequest.mediaTypes.video.playerSize[1], + }, + ...videoParams}); + }); + // + it('should set video params for multi-format', function() { + const bidRequest = deepClone(multiFormatBidRequest); + bidRequest.params.video = videoParams; + const request = spec.buildRequests([bidRequest], {})[0]; + const payload = JSON.parse(request.data); + const testVideoParams = Object.assign({ + placement: OUTSTREAM_TYPE, + w: 640, + h: 480, + mimes: ['video/mp4'], + }, videoParams); + expect(payload.imp[0].video).to.deep.equal(testVideoParams); + }); + } it('should add schain', function () { const schain = '{"ver":"1.0","complete":1,"nodes":[{"asi":"headerlift.com","sid":"xyz","hp":1}]}'; @@ -457,7 +583,15 @@ describe('Improve Digital Adapter Tests', function () { }); it('should add eids', function () { - const userId = { id5id: { uid: '1111' } }; + const userIdAsEids = [ + { + source: 'id5-sync.com', + uids: [{ + atype: 1, + id: '1111' + }] + } + ]; const expectedUserObject = { ext: { eids: [{ source: 'id5-sync.com', uids: [{ @@ -466,7 +600,7 @@ describe('Improve Digital Adapter Tests', function () { }] }]}}; const bidRequest = Object.assign({}, simpleBidRequest); - bidRequest.userId = userId; + bidRequest.userIdAsEids = userIdAsEids; const request = spec.buildRequests([bidRequest], bidderRequestReferrer)[0]; const payload = JSON.parse(request.data); expect(payload.user).to.deep.equal(expectedUserObject); @@ -479,38 +613,50 @@ describe('Improve Digital Adapter Tests', function () { ], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(2); - expect(requests[0].bidderRequest).to.deep.equal(bidderRequest); - expect(requests[1].bidderRequest).to.deep.equal(bidderRequest); }); it('should return one request in a single request mode', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.singleRequest').returns(true); - const requests = spec.buildRequests([ - simpleBidRequest, - simpleSmartTagBidRequest - ], bidderRequest); + const requests = spec.buildRequests([ simpleBidRequest, instreamBidRequest ], bidderRequest); expect(requests).to.be.an('array'); expect(requests.length).to.equal(1); - getConfigStub.restore(); + expect(requests[0].url).to.equal(AD_SERVER_URL); + const request = JSON.parse(requests[0].data); + expect(request.imp.length).to.equal(2); + expect(request.imp[0].banner).to.exist; + if (FEATURES.VIDEO) { expect(request.imp[1].video).to.exist; } + }); + + it('should create one request per endpoint in a single request mode', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.singleRequest').returns(true); + const requests = spec.buildRequests([ extendBidRequest, simpleBidRequest, instreamBidRequest ], bidderRequest); + expect(requests).to.be.an('array'); + expect(requests.length).to.equal(2); + expect(requests[0].url).to.equal(EXTEND_URL); + expect(requests[1].url).to.equal(AD_SERVER_URL); + const adServerRequest = JSON.parse(requests[1].data); + expect(adServerRequest.imp.length).to.equal(2); + expect(adServerRequest.imp[0].banner).to.exist; + if (FEATURES.VIDEO) { expect(adServerRequest.imp[1].video).to.exist; } }); it('should set Prebid sizes in bid request', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); const request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; const payload = JSON.parse(request.data); - expect(payload.imp[0].banner).to.deep.equal({ + sinon.assert.match(payload.imp[0].banner, { format: [ { w: 300, h: 250 }, { w: 160, h: 600 } ] }); - getConfigStub.restore(); }); it('should not add single size filter when using Prebid sizes', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('improvedigital.usePrebidSizes').returns(true); const bidRequest = Object.assign({}, simpleBidRequest); const size = { @@ -520,131 +666,185 @@ describe('Improve Digital Adapter Tests', function () { bidRequest.params.size = size; const request = spec.buildRequests([bidRequest], bidderRequest)[0]; const payload = JSON.parse(request.data); - expect(payload.imp[0].banner).to.deep.equal({ + sinon.assert.match(payload.imp[0].banner, { format: [ { w: 300, h: 250 }, { w: 160, h: 600 } ] }); - getConfigStub.restore(); - }); - - it('should set GPID and Instl Signal', function () { - const bidRequest = Object.assign({ - ortb2Imp: { - instl: true, - ext: { - gpid: '/123/ID-FORMAT', - data: { - pbadslot: '/123/ID-FORMAT-PBADSLOT', - adserver: { - adslot: '/123/ID-FORMAT-ADSERVER-PB-ADSLOT', - } - } - }, - } - }, simpleBidRequest); - let request = spec.buildRequests([bidRequest], bidderRequest)[0]; - let payload = JSON.parse(request.data); - expect(payload.imp[0].ext.gpid).to.equal('/123/ID-FORMAT'); - expect(payload.imp[0].instl).to.equal(1); - - delete bidRequest.ortb2Imp.ext.gpid; - request = spec.buildRequests([bidRequest], bidderRequest)[0]; - payload = JSON.parse(request.data); - expect(payload.imp[0].ext.gpid).to.equal('/123/ID-FORMAT-PBADSLOT'); - - delete bidRequest.ortb2Imp.ext.data.pbadslot; - request = spec.buildRequests([bidRequest], bidderRequest)[0]; - payload = JSON.parse(request.data); - expect(payload.imp[0].ext.gpid).to.equal('/123/ID-FORMAT-ADSERVER-PB-ADSLOT'); - - delete bidRequest.ortb2Imp.ext.data.adserver; - delete bidRequest.ortb2Imp.instl; - request = spec.buildRequests([bidRequest], bidderRequest)[0]; - payload = JSON.parse(request.data); - expect(payload.imp[0].ext.gpid).to.not.exist; - expect(payload.imp[0].instl).to.not.exist; }); it('should not set site when app is defined in FPD', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); - getConfigStub.withArgs('ortb2.app').returns({ content: 'XYZ' }); - let request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; + const ortb2 = {app: {content: 'XYZ'}}; + let request = spec.buildRequests([simpleBidRequest], {...bidderRequest, ortb2})[0]; let payload = JSON.parse(request.data); expect(payload.site).does.not.exist; expect(payload.app).does.exist; expect(payload.app.content).does.exist.and.equal('XYZ'); - getConfigStub.restore(); }); it('should not set site when app is defined in CONFIG', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('app').returns({ content: 'XYZ' }); - let request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; + let request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequest))[0]; let payload = JSON.parse(request.data); expect(payload.site).does.not.exist; expect(payload.app).does.exist; expect(payload.app.content).does.exist.and.equal('XYZ'); - getConfigStub.restore(); }); it('should set correct site params', function () { - let getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('site').returns({ content: 'XYZ', page: 'https://improveditigal.com/', domain: 'improveditigal.com' }); - let request = spec.buildRequests([simpleBidRequest], bidderRequestReferrer)[0]; + let request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequestReferrer))[0]; let payload = JSON.parse(request.data); expect(payload.site.content).does.exist.and.equal('XYZ'); expect(payload.site.page).does.exist.and.equal('https://improveditigal.com/'); expect(payload.site.domain).does.exist.and.equal('improveditigal.com'); getConfigStub.reset(); - request = spec.buildRequests([simpleBidRequest], bidderRequestReferrer)[0]; + request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequestReferrer))[0]; payload = JSON.parse(request.data); expect(payload.site.content).does.not.exist; expect(payload.site.page).does.exist.and.equal('https://blah.com/test.html'); expect(payload.site.domain).does.exist.and.equal('blah.com'); - getConfigStub.withArgs('ortb2.site').returns({ - content: 'ZZZ', - }); - request = spec.buildRequests([simpleBidRequest], bidderRequestReferrer)[0]; + const ortb2 = {site: {content: 'ZZZ'}}; + request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest({...bidderRequestReferrer, ortb2}))[0]; payload = JSON.parse(request.data); expect(payload.site.content).does.exist.and.equal('ZZZ'); expect(payload.site.page).does.exist.and.equal('https://blah.com/test.html'); expect(payload.site.domain).does.exist.and.equal('blah.com'); - getConfigStub.restore(); - }); - - it('should set pageUrl as site param', function () { - let getConfigStub = sinon.stub(config, 'getConfig'); - getConfigStub.withArgs('pageUrl').returns('https://improvidigital.com/test-page'); - let request = spec.buildRequests([simpleBidRequest], bidderRequestReferrer)[0]; - let payload = JSON.parse(request.data); - expect(payload.site.page).does.exist.and.equal('https://improvidigital.com/test-page'); - expect(payload.site.domain).does.exist.and.equal('improvidigital.com'); - getConfigStub.reset(); - - getConfigStub.withArgs('pageUrl').returns(undefined); - request = spec.buildRequests([simpleBidRequest], bidderRequestReferrer)[0]; - payload = JSON.parse(request.data); - expect(payload.site.page).does.exist.and.equal('https://blah.com/test.html'); - expect(payload.site.domain).does.exist.and.equal('blah.com'); - getConfigStub.restore(); }); it('should set site when app not available', function () { - const getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub = sinon.stub(config, 'getConfig'); getConfigStub.withArgs('app').returns(undefined); - let request = spec.buildRequests([simpleBidRequest], bidderRequest)[0]; + getConfigStub.withArgs('site').returns({}); + let request = spec.buildRequests([simpleBidRequest], syncAddFPDToBidderRequest(bidderRequest))[0]; let payload = JSON.parse(request.data); expect(payload.site).does.exist; expect(payload.app).does.not.exist; - getConfigStub.restore(); + }); + + it('should call basic ads endpoint when no consent for purpose 1', function () { + const consent = deepClone(gdprConsent); + deepSetValue(consent, 'vendorData.purpose.consents.1', false); + const bidderRequestWithConsent = deepClone(bidderRequest); + bidderRequestWithConsent.gdprConsent = consent; + const request = spec.buildRequests([simpleBidRequest], bidderRequestWithConsent)[0]; + expect(request.url).to.equal(BASIC_ADS_URL); + }); + + it('should set extend params when extend mode enabled from global configuration', function () { + getConfigStub = sinon.stub(config, 'getConfig'); + const bannerRequest = deepClone(simpleBidRequest); + const keyValues = { testKey: [ 'testValue' ] }; + bannerRequest.params.keyValues = keyValues; + + getConfigStub.withArgs('improvedigital.extend').returns(true); + const requests = spec.buildRequests([bannerRequest, instreamBidRequest], bidderRequest); + expect(requests[0].method).to.equal(METHOD); + expect(requests[0].url).to.equal(EXTEND_URL); + expect(requests[1].url).to.equal(EXTEND_URL); + // banner + let payload = JSON.parse(requests[0].data); + expect(payload.imp[0].ext.bidder).to.not.exist; + expect(payload.imp[0].ext.prebid.bidder.improvedigital).to.deep.equal({ + placementId: 1053688, + keyValues + }); + expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal('1053688'); + // video + payload = JSON.parse(requests[1].data); + expect(payload.imp[0].ext.bidder).to.not.exist; + expect(payload.imp[0].ext.prebid.bidder.improvedigital.placementId).to.equal(123456); + expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal('123456'); + }); + + it('should set extend url when extend mode enabled in adunit params', function () { + const bidRequest = deepClone(extendBidRequest); + let request = spec.buildRequests([bidRequest], { bids: [bidRequest] })[0]; + expect(request.url).to.equal(EXTEND_URL); + + getConfigStub = sinon.stub(config, 'getConfig'); + + // adunit param takes precedence over the global config + getConfigStub.withArgs('improvedigital.extend').returns(false); + request = spec.buildRequests([bidRequest], { bids: [bidRequest] })[0]; + expect(request.url).to.equal(EXTEND_URL); + + bidRequest.params.extend = false; + getConfigStub.withArgs('improvedigital.extend').returns(true); + request = spec.buildRequests([bidRequest], { bids: [bidRequest] })[0]; + expect(request.url).to.equal(AD_SERVER_URL); + + const requests = spec.buildRequests([bidRequest, instreamBidRequest], { bids: [bidRequest, instreamBidRequest] }); + expect(requests.length).to.equal(2); + expect(requests[0].url).to.equal(AD_SERVER_URL); + expect(requests[1].url).to.equal(EXTEND_URL); + }); + + it('should add publisherId to request URL when available in request params', function() { + function formatPublisherUrl(baseUrl, publisherId) { + return `${baseUrl}/${publisherId}/${PB_ENDPOINT}`; + } + const bidRequest = deepClone(simpleBidRequest); + bidRequest.params.publisherId = 1000; + let request = spec.buildRequests([bidRequest], bidderRequest)[0]; + expect(request).to.be.an('object'); + sinon.assert.match(request, { + method: METHOD, + url: formatPublisherUrl(AD_SERVER_BASE_URL, 1000), + bidderRequest + }); + + const bidRequest2 = deepClone(simpleBidRequest) + bidRequest2.params.publisherId = 1002; + + const bidRequest3 = deepClone(extendBidRequest) + bidRequest3.params.publisherId = 1002; + + const request1 = spec.buildRequests([bidRequest, bidRequest2], bidderRequest)[0]; + expect(request1.url).to.equal(formatPublisherUrl(AD_SERVER_BASE_URL, 1000)); + const request2 = spec.buildRequests([bidRequest, bidRequest2], bidderRequest)[1]; + expect(request2.url).to.equal(formatPublisherUrl(AD_SERVER_BASE_URL, 1002)); + const request3 = spec.buildRequests([bidRequest, bidRequest3], bidderRequest)[1]; + expect(request3.url).to.equal(EXTEND_URL); + + // Enable single request mode + getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.withArgs('improvedigital.singleRequest').returns(true); + try { + spec.buildRequests([bidRequest, bidRequest2], bidderRequest)[0]; + } catch (e) { + expect(e.name).to.exist.equal('Error') + expect(e.message).to.exist.equal(`All Improve Digital placements in a single call must have the same publisherId. Please check your 'params.publisherId' or turn off the single request mode.`) + } + + bidRequest2.params.publisherId = null; + request = spec.buildRequests([bidRequest, bidRequest2], bidderRequest)[0]; + expect(request.url).to.equal(formatPublisherUrl(AD_SERVER_BASE_URL, 1000)); + + const consent = deepClone(gdprConsent); + deepSetValue(consent, 'vendorData.purpose.consents.1', false); + const bidderRequestWithConsent = deepClone(bidderRequest); + bidderRequestWithConsent.gdprConsent = consent; + request = spec.buildRequests([bidRequest], bidderRequestWithConsent)[0]; + expect(request.url).to.equal(formatPublisherUrl(BASIC_ADS_BASE_URL, 1000)); + + deepSetValue(consent, 'vendorData.purpose.consents.1', true); + bidderRequestWithConsent.gdprConsent = consent; + request = spec.buildRequests([bidRequest], bidderRequestWithConsent)[0]; + expect(request.url).to.equal(formatPublisherUrl(AD_SERVER_BASE_URL, 1000)); + + delete bidRequest.params.publisherId; + request = spec.buildRequests([bidRequest], bidderRequestWithConsent)[0]; + expect(request.url).to.equal(AD_SERVER_URL); }); }); @@ -665,7 +865,6 @@ describe('Improve Digital Adapter Tests', function () { 'agency_id': '0' } }, - 'exp': 120, 'crid': '510265', 'price': 1.9200543539802946, 'id': '35adfe19-d6e9-46b9-9f7d-20da7026b965', @@ -678,7 +877,16 @@ describe('Improve Digital Adapter Tests', function () { ], 'seat': 'improvedigital' } - ] + ], + ext: { + improvedigital: { + sync: [ + 'https://link1', + 'https://link2', + 'https://link3', + ] + } + } } }; @@ -699,7 +907,6 @@ describe('Improve Digital Adapter Tests', function () { 'agency_id': '0' } }, - 'exp': 120, 'crid': '510265', 'price': 1.9200543539802946, 'id': '35adfe19-d6e9-46b9-9f7d-20da7026b965', @@ -719,7 +926,6 @@ describe('Improve Digital Adapter Tests', function () { 'agency_id': '0' } }, - 'exp': 120, 'crid': '479163', 'price': 1.9200543539802946, 'id': '83c8d524-0955-4d0c-b558-4c9f3600e09b', @@ -738,7 +944,7 @@ describe('Improve Digital Adapter Tests', function () { sync: [ 'https://link1', 'https://link2', - 'https://link3', + 'https://link4', ] } } @@ -764,11 +970,10 @@ describe('Improve Digital Adapter Tests', function () { } }, 'crid': '544456', - 'exp': 120, 'id': '52098fad-20c1-476b-a4fa-41e275e5a4a5', 'price': 1.8600000000000003, 'adm': "{\"ver\":\"1.1\",\"imptrackers\":[\"https://secure.adnxs.com/imptr?id=52311&t=2\",\"https://euw-ice.360yield.com/imp_pixel?ic=hcUBlCANx1FabHBf6FR2gC7UO4xEyXahdZAn0-B5qL-bb3A74BJ1smyWIyW7IWcC0SOjSXzVpevTHXxTqJ.sf.Qhahyy6tSo.0j1QWfXlH8sM4-8vKWjMjw-x.IrJJNlwkQ0s1CdwcwTefcLXm5l2E-W19VhACuV7f3mgrZMNjiSw.SjJAfyPC3SIyAMRjYfj53UmjriQ46T7lhmkqxK8wHmksYCdbZc3PZESk8NWl28sxdjNvnYYCFMcJbeav.LOLabyTXfwy-1cEPbQs.IKMRZIKaqccTDPV3wOtzbNv0jQzatd3Nnv-PGFQcjQ-GW3i27W04Fws4kodpFSn-B6VwZAjzLzoyd5gBncyRnAyCplEbgHU5sZ1IyKHWjgCl3ZtRIK5vqrRD5D-xqgSnOi7-phG.CqZWDZ4bMDSfQg2ZnbvUTyGKcEl0WR59dW5izTMV4Fjizcrvr5T-t.zMbGwz.hGnmLIyhTqh.IcwW.GiDLVExlDlix5S1LXIWVsSyrQ==\"],\"assets\":[{\"id\":1,\"data\":{\"value\":\"ImproveDigital\",\"type\":1}},{\"id\":3,\"data\":{\"value\":\"Test content.\",\"type\":2}},{\"id\":0,\"title\":{\"text\":\"Sample Prebid Test Title\"}}],\"link\":{\"url\":\"https://euw-ice.360yield.com/click/hcUBlHOV7YhVse8RyBa0ajjyPa9Vt17e4g-1m3cRj3E67vq-RYux.SiUeAmBfNBcoOqkUc6A15AWmi4yFu5K-BdkaYjildyyk7fNLyR6hWr411kv4vrFwm5jrIBceuHS6K8oN69f.uCo8zGTdR2TbSlldwcpahQPlufZU.6VaMsu4IC53uEiUT5vb7kAw6TTlxuGBNq6zaGryiWEV2.N3YYJDTyYPh8tv-ZFyeFZFm0Gnjv.xWbC.70JcRUVU9UelQaPsTpTWYTXBhJt84YJUw1-GNtaLNVLSjjZbVoA2fsMti5p6OBmF.7u39on2OPgvseIkSmge7Pqg63pRqdP75hp.DAEk6OkcN1jGnwP2DSbvpaSbin5lVqjfO0B-wnQgfQTCUtM5v4JmkNweLhUf9Q-x.nPKLW5SccEk9ZFXzY2-1wpT3PWm8Tix3NRscLPZub9wHzL..pl6ip8cQ9hp16UjwT4H6RMAxL0R7bl-h2pAicGAzYmuO7ntRESKUoIWA==//http%3A%2F%2Fquantum-advertising.com%2Ffr%2F\"},\"jstracker\":\"\"}", - 'impid': '2d7a7db325c6f', + 'impid': '33e9500b21129f', 'cid': '196108' } ], @@ -795,7 +1000,6 @@ describe('Improve Digital Adapter Tests', function () { 'agency_id': '0' } }, - 'exp': 120, 'crid': '484367', 'price': 9.600271769901472, 'id': 'b131fd7b-5759-4b72-800e-60e69291e7d9', @@ -839,7 +1043,6 @@ describe('Improve Digital Adapter Tests', function () { 'agency_id': '0' } }, - 'exp': 120, 'crid': '544063', 'price': 1.9199364935359489, 'id': '1fcf4dd8-a783-48ed-b59c-8fc8eeccb024', @@ -868,17 +1071,20 @@ describe('Improve Digital Adapter Tests', function () { width: 728, height: 90, ttl: 300, - ad: '  ', + ad: '\x3Cscript>window.__razr_config = {"prebid":{"bidRequest":{"bidder":"improvedigital","params":{"placementId":1053688,"keyValues":{"testKey":["testValue"]},"bidFloor":0.05,"bidFloorCur":"eUR","size":{"w":800,"h":600}},"adUnitCode":"div-gpt-ad-1499748733608-0","transactionId":"f183e871-fbed-45f0-a427-c8a63c4c01eb","bidId":"33e9500b21129f","bidderRequestId":"2772c1e566670b","auctionId":"192721e36a0239","mediaTypes":{"banner":{"sizes":[[300,250],[160,600]]}},"sizes":[[300,250],[160,600]]},"bid":{"mediaType":"banner","ad":"\\"\\"","requestId":"33e9500b21129f","seatBidId":"35adfe19-d6e9-46b9-9f7d-20da7026b965","cpm":1.9200543539802946,"currency":"EUR","width":728,"height":90,"creative_id":"510265","creativeId":"510265","ttl":300,"meta":{},"dealId":320896,"netRevenue":false}}};\x3C/script>  ', creativeId: '510265', dealId: 320896, netRevenue: false, mediaType: BANNER, - meta: { - advertiserDomains: [] - } } ]; + const multiFormatExpectedBid = [ + Object.assign({}, expectedBid[0], { + ad: '\x3Cscript>window.__razr_config = {"prebid":{"bidRequest":{"bidder":"improvedigital","params":{"placementId":1053688},"adUnitCode":"div-gpt-ad-1499748733608-0","transactionId":"f183e871-fbed-45f0-a427-c8a63c4c01eb","bidId":"33e9500b21129f","bidderRequestId":"2772c1e566670b","auctionId":"192721e36a0239","mediaTypes":{"banner":{"sizes":[[300,250],[160,600]]},"native":{},"video":{"context":"outstream","playerSize":[640,480]}},"sizes":[[300,250],[160,600]],"nativeParams":{"body":{"required":true}}},"bid":{"mediaType":"banner","ad":"\\"\\"","requestId":"33e9500b21129f","seatBidId":"35adfe19-d6e9-46b9-9f7d-20da7026b965","cpm":1.9200543539802946,"currency":"EUR","width":728,"height":90,"creative_id":"510265","creativeId":"510265","ttl":300,"meta":{},"dealId":320896,"netRevenue":false}}};\x3C/script>  ', + }) + ]; + const expectedTwoBids = [ expectedBid[0], { @@ -888,14 +1094,11 @@ describe('Improve Digital Adapter Tests', function () { width: 300, height: 250, ttl: 300, - ad: '  ', + ad: '\x3Cscript>window.__razr_config = {"prebid":{"bidRequest":{"bidder":"improvedigital","params":{"placementId":1053688,"keyValues":{"testKey":["testValue"]},"bidFloor":0.05,"bidFloorCur":"eUR","size":{"w":800,"h":600}},"adUnitCode":"div-gpt-ad-1499748733608-0","transactionId":"f183e871-fbed-45f0-a427-c8a63c4c01eb","bidId":"33e9500b21129f","bidderRequestId":"2772c1e566670b","auctionId":"192721e36a0239","mediaTypes":{"banner":{"sizes":[[300,250],[160,600]]}},"sizes":[[300,250],[160,600]]},"bid":{"mediaType":"banner","ad":"\\"\\"","requestId":"33e9500b21129f","seatBidId":"83c8d524-0955-4d0c-b558-4c9f3600e09b","cpm":1.9200543539802946,"currency":"EUR","width":300,"height":250,"creative_id":"479163","creativeId":"479163","ttl":300,"meta":{},"dealId":320896,"netRevenue":false}}};\x3C/script>  ', creativeId: '479163', dealId: 320896, netRevenue: false, mediaType: BANNER, - meta: { - advertiserDomains: [] - } } ]; @@ -916,178 +1119,277 @@ describe('Improve Digital Adapter Tests', function () { } ]; - const expectedBidOutstreamVideo = utils.deepClone(expectedBidInstreamVideo); + const expectedBidOutstreamVideo = deepClone(expectedBidInstreamVideo); expectedBidOutstreamVideo[0].adResponse = { content: expectedBidOutstreamVideo[0].vastXml }; + function makeRequest(bidderRequest) { + return { + ortbRequest: CONVERTER.toORTB({bidderRequest}) + } + } + + function expectMatch(actual, expected) { + sinon.assert.match(actual, expected.map(i => sinon.match(i))); + } + it('should return a well-formed display bid', function () { - const bids = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(bids).to.deep.equal(expectedBid); + const bids = spec.interpretResponse(serverResponse, makeRequest(bidderRequest)); + expectMatch(bids, expectedBid); }); it('should return a well-formed display bid for multi-format ad unit', function () { - const bids = spec.interpretResponse(serverResponse, {bidderRequest: multiFormatBidderRequest}); - expect(bids).to.deep.equal(expectedBid); + const bids = spec.interpretResponse(serverResponse, makeRequest(multiFormatBidderRequest)); + + expectMatch(bids, multiFormatExpectedBid); }); it('should return two bids', function () { - const bids = spec.interpretResponse(serverResponseTwoBids, {bidderRequest}); - expect(bids).to.deep.equal(expectedTwoBids); + const bids = spec.interpretResponse(serverResponseTwoBids, makeRequest(bidderRequest)); + expectMatch(bids, expectedTwoBids); }); it('should set dealId correctly', function () { - const response = JSON.parse(JSON.stringify(serverResponse)); + const request = makeRequest(bidderRequest); + const response = deepClone(serverResponse); let bids; delete response.body.seatbid[0].bid[0].ext.improvedigital.line_item_id; response.body.seatbid[0].bid[0].ext.improvedigital.buying_type = 'deal_id'; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids[0].dealId).to.not.exist; response.body.seatbid[0].bid[0].ext.improvedigital.line_item_id = 268515; delete response.body.seatbid[0].bid[0].ext.improvedigital.buying_type; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids[0].dealId).to.not.exist; response.body.seatbid[0].bid[0].ext.improvedigital.line_item_id = 268515; response.body.seatbid[0].bid[0].ext.improvedigital.buying_type = 'rtb'; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids[0].dealId).to.not.exist; response.body.seatbid[0].bid[0].ext.improvedigital.line_item_id = 268515; response.body.seatbid[0].bid[0].ext.improvedigital.buying_type = 'classic'; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids[0].dealId).to.equal(268515); response.body.seatbid[0].bid[0].ext.improvedigital.line_item_id = 268515; response.body.seatbid[0].bid[0].ext.improvedigital.buying_type = 'deal_id'; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids[0].dealId).to.equal(268515); }); it('should set currency', function () { - const response = JSON.parse(JSON.stringify(serverResponse)); - response.body.cur = 'eur'; - const bids = spec.interpretResponse(response, {bidderRequest}); + const response = deepClone(serverResponse); + response.body.cur = 'EUR'; + const bids = spec.interpretResponse(response, makeRequest(bidderRequest)); expect(bids[0].currency).to.equal('EUR'); }); it('should return empty array for bad response or no price', function () { - let response = JSON.parse(JSON.stringify(serverResponse)); + const request = makeRequest(bidderRequest); + let response = deepClone(serverResponse); let bids; // Price missing or 0 response.body.seatbid[0].bid[0].price = 0; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids).to.deep.equal([]); delete response.body.seatbid[0].bid[0]; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids).to.deep.equal([]); response.body.seatbid[0].bid[0] = []; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids).to.deep.equal([]); // errorCode present - response = JSON.parse(JSON.stringify(serverResponse)); + response = deepClone(serverResponse); response.body.seatbid[0].bid[0].errorCode = undefined; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids).to.deep.equal([]); // adm and native missing - response = JSON.parse(JSON.stringify(serverResponse)); + response = deepClone(serverResponse); delete response.body.seatbid[0].bid[0].adm; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids).to.deep.equal([]); response.body.seatbid[0].bid[0].adm = null; - bids = spec.interpretResponse(response, {bidderRequest}); + bids = spec.interpretResponse(response, request); expect(bids).to.deep.equal([]); }); it('should set netRevenue', function () { - const response = JSON.parse(JSON.stringify(serverResponse)); + const response = deepClone(serverResponse); response.body.seatbid[0].bid[0].ext.improvedigital.is_net = true; - const bids = spec.interpretResponse(response, {bidderRequest}); + const bids = spec.interpretResponse(response, makeRequest(bidderRequest)); expect(bids[0].netRevenue).to.equal(true); }); it('should set advertiserDomains', function () { const adomain = ['domain.com']; - const response = JSON.parse(JSON.stringify(serverResponse)); + const response = deepClone(serverResponse); response.body.seatbid[0].bid[0].adomain = adomain; - const bids = spec.interpretResponse(response, {bidderRequest}); + const bids = spec.interpretResponse(response, makeRequest(bidderRequest)); expect(bids[0].meta.advertiserDomains).to.equal(adomain); }); // // Native ads - it('should return a well-formed native ad bid', function () { - const nativeBidderRequest = JSON.parse(JSON.stringify(bidderRequest)); - nativeBidderRequest.bids[0].bidId = '2d7a7db325c6f'; - delete nativeBidderRequest.bids[0].mediaTypes.banner; - nativeBidderRequest.bids[0].mediaTypes.native = {}; - const bids = spec.interpretResponse(serverResponseNative, {bidderRequest: nativeBidderRequest}); - // Verify Native Response - expect(bids[0].native).to.exist; - const nativeBid = bids[0].native; - const nativeResp = JSON.parse(serverResponseNative.body.seatbid[0].bid[0].adm); - // Verify Native Response - expect(nativeBid.clickUrl).to.exist.and.equal(nativeResp.link.url); - expect(nativeBid.impressionTrackers).to.exist.and.deep.equal(nativeResp.imptrackers); - expect(nativeBid.javascriptTrackers).to.exist.and.deep.equal(nativeResp.jstracker); - - // Verify Assets - expect(nativeBid.title).to.exist.and.equal('Sample Prebid Test Title'); - expect(nativeBid.sponsoredBy).to.exist.and.equal('ImproveDigital'); - expect(nativeBid.body).to.exist.and.equal('Test content.'); - }); + if (FEATURES.NATIVE) { + it('should return a well-formed native ad bid', function () { + const reqBids = updateNativeParams(nativeBidderRequest.bids); + const request = makeRequest({ + ...nativeBidderRequest, + reqBids + }) + const bids = spec.interpretResponse(serverResponseNative, request); + expect(bids[0].native.ortb).to.eql(JSON.parse(serverResponseNative.body.seatbid[0].bid[0].adm)) + }); + + it('should return a well-formed native bid for multi-format ad unit', function () { + const bids = spec.interpretResponse(serverResponseNative, makeRequest(multiFormatBidderRequest)); + expect(bids[0].mediaType).to.equal(NATIVE); + }); + } // Video - it('should return a well-formed instream video bid', function () { - const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: instreamBidderRequest}); - expect(bids).to.deep.equal(expectedBidInstreamVideo); - }); + if (FEATURES.VIDEO) { + it('should return a well-formed instream video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo, makeRequest(instreamBidderRequest)); + expectMatch(bids, expectedBidInstreamVideo); + }); - it('should return a well-formed outstream video bid', function () { - const bids = spec.interpretResponse(serverResponseVideo, {bidderRequest: outstreamBidderRequest}); - expect(bids[0].renderer).to.exist; - delete (bids[0].renderer); - expect(bids).to.deep.equal(expectedBidOutstreamVideo); - }); + it('should return a well-formed outstream video bid', function () { + const bids = spec.interpretResponse(serverResponseVideo, makeRequest(outstreamBidderRequest)); + expect(bids[0].renderer).to.exist; + expectMatch(bids, expectedBidOutstreamVideo); + }); + + it('should return a well-formed outstream video bid for multi-format ad unit', function () { + const request = makeRequest(multiFormatBidderRequest); + const videoResponse = deepClone(serverResponseVideo); + let bids = spec.interpretResponse(videoResponse, request); + expect(bids[0].renderer).to.exist; + expectMatch(bids, expectedBidOutstreamVideo); + + videoResponse.body.seatbid[0].bid[0].adm = ' it('should return the callback when it not exists in local storages', function () { getLocalStorageStub.withArgs(storageKey).returns(testCase); + getLocalStorageStub.withArgs(storagePpKey).returns(testCase); const id = imuIdSubmodule.getId(configParamTestCase); expect(id).have.all.keys('callback'); })); @@ -73,7 +79,7 @@ describe('imuId module', function () { describe('getApiUrl()', function () { it('should return default url when cid only', function () { const url = getApiUrl(5126); - expect(url).to.be.equal(`${apiUrl}?cid=5126`); + expect(url).to.be.equal(`https://sync6.im-apps.net/5126/pid`); }); it('should return param url when set url', function () { @@ -84,8 +90,14 @@ describe('imuId module', function () { describe('decode()', function () { it('should return the uid when it exists in local storages', function () { - const id = imuIdSubmodule.decode('testDecode'); - expect(id).to.be.deep.equal({imuid: 'testDecode'}); + const id = imuIdSubmodule.decode({ + imppid: 'imppid-value-imppid-value-imppid-value', + imuid: 'testDecodeImPpid' + }); + expect(id).to.be.deep.equal({ + imppid: 'imppid-value-imppid-value-imppid-value', + imuid: 'testDecodeImPpid' + }); }); it('should return the undefined when decode id is not "string"', function () { @@ -97,11 +109,13 @@ describe('imuId module', function () { describe('getLocalData()', function () { it('always have the same key', function () { getLocalStorageStub.withArgs(storageKey).returns('testid'); + getLocalStorageStub.withArgs(storagePpKey).returns('imppid-value-imppid-value-imppid-value'); getCookieStub.withArgs(cookieKey).returns('testvid'); getLocalStorageStub.withArgs(`${storageKey}_mt`).returns(new Date(utils.timestamp()).toUTCString()); const localData = getLocalData(); expect(localData).to.be.deep.equal({ id: 'testid', + ppid: 'imppid-value-imppid-value-imppid-value', vid: 'testvid', expired: false }); @@ -112,6 +126,7 @@ describe('imuId module', function () { const localData = getLocalData(); expect(localData).to.be.deep.equal({ id: undefined, + ppid: undefined, vid: undefined, expired: true }); @@ -122,6 +137,7 @@ describe('imuId module', function () { it('should return the undefined when success response', function () { const res = apiSuccessProcess({ uid: 'test', + ppid: 'imppid-value-imppid-value-imppid-value', vid: 'test' }); expect(res).to.equal(undefined); diff --git a/test/spec/modules/incrxBidAdapter_spec.js b/test/spec/modules/incrxBidAdapter_spec.js new file mode 100644 index 00000000000..3fb4ffe2cd3 --- /dev/null +++ b/test/spec/modules/incrxBidAdapter_spec.js @@ -0,0 +1,104 @@ +import { expect } from 'chai'; +import { spec } from 'modules/incrxBidAdapter.js'; + +describe('IncrementX', function () { + const METHOD = 'POST'; + const URL = 'https://hb.incrementxserv.com/vzhbidder/bid'; + + const bidRequest = { + bidder: 'IncrementX', + params: { + placementId: 'PNX-HB-F796830VCF3C4B' + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + sizes: [ + [300, 250], + [300, 600] + ], + bidId: 'bid-id-123456', + adUnitCode: 'ad-unit-code-1', + bidderRequestId: 'bidder-request-id-123456', + auctionId: 'auction-id-123456', + transactionId: 'transaction-id-123456' + }; + + describe('isBidRequestValid', function () { + it('should return true where required params found', function () { + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + }); + + describe('buildRequests', function () { + let bidderRequest = { + refererInfo: { + page: 'https://www.test.com', + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: [ + 'https://www.test.com' + ], + canonicalUrl: null + } + }; + + it('should build correct POST request for banner bid', function () { + const request = spec.buildRequests([bidRequest], bidderRequest)[0]; + expect(request).to.be.an('object'); + expect(request.method).to.equal(METHOD); + expect(request.url).to.equal(URL); + + const payload = JSON.parse(decodeURI(request.data.q)); + expect(payload).to.be.an('object'); + expect(payload._vzPlacementId).to.be.a('string'); + expect(payload.sizes).to.be.an('array'); + expect(payload._slotBidId).to.be.a('string'); + expect(payload._rqsrc).to.be.a('string'); + }); + }); + + describe('interpretResponse', function () { + let serverResponse = { + body: { + vzhPlacementId: 'PNX-HB-F796830VCF3C4B', + bid: 'BID-XXXX-XXXX', + adWidth: '300', + adHeight: '250', + cpm: '0.7', + ad: '

Ad from IncrementX

', + slotBidId: 'bid-id-123456', + adType: '1', + settings: '1,2', + nurl: 'htt://nurl.com', + statusText: 'Success' + } + }; + + let expectedResponse = [{ + requestId: 'bid-id-123456', + cpm: '0.7', + currency: 'USD', + adType: '1', + settings: '1,2', + netRevenue: false, + width: '300', + height: '250', + creativeId: 0, + ttl: 300, + ad: '

Ad from IncrementX

', + meta: { + mediaType: 'banner', + advertiserDomains: [] + } + }]; + + it('should correctly interpret valid banner response', function () { + let result = spec.interpretResponse(serverResponse); + expect(result).to.deep.equal(expectedResponse); + }); + }); +}); diff --git a/test/spec/modules/inmarBidAdapter_spec.js b/test/spec/modules/inmarBidAdapter_spec.js deleted file mode 100644 index 998fe20d369..00000000000 --- a/test/spec/modules/inmarBidAdapter_spec.js +++ /dev/null @@ -1,240 +0,0 @@ -// import or require modules necessary for the test, e.g.: -import {expect} from 'chai'; // may prefer 'assert' in place of 'expect' -import { - spec -} from 'modules/inmarBidAdapter.js'; -import {config} from 'src/config.js'; - -describe('Inmar adapter tests', function () { - var DEFAULT_PARAMS_NEW_SIZES = [{ - adUnitCode: 'test-div', - bidId: '2c7c8e9c900244', - mediaTypes: { - banner: { - sizes: [ - [300, 250], [300, 600], [728, 90], [970, 250]] - } - }, - bidder: 'inmar', - params: { - partnerId: 12345 - }, - auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', - bidRequestsCount: 1, - bidderRequestId: '1858b7382993ca', - transactionId: '29df2112-348b-4961-8863-1b33684d95e6', - user: {} - }]; - - var DEFAULT_PARAMS_VIDEO = [{ - adUnitCode: 'test-div', - bidId: '2c7c8e9c900244', - mediaTypes: { - video: { - context: 'instream', // or 'outstream' - playerSize: [640, 480], - mimes: ['video/mp4'] - } - }, - bidder: 'inmar', - params: { - partnerId: 12345 - }, - auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', - bidRequestsCount: 1, - bidderRequestId: '1858b7382993ca', - transactionId: '29df2112-348b-4961-8863-1b33684d95e6', - user: {} - }]; - - var DEFAULT_PARAMS_WO_OPTIONAL = [{ - adUnitCode: 'test-div', - bidId: '2c7c8e9c900244', - sizes: [ - [300, 250], - [300, 600], - [728, 90], - [970, 250] - ], - bidder: 'inmar', - params: { - partnerId: 12345, - }, - auctionId: '851adee7-d843-48f9-a7e9-9ff00573fcbf', - bidRequestsCount: 1, - bidderRequestId: '1858b7382993ca', - transactionId: '29df2112-348b-4961-8863-1b33684d95e6' - }]; - - var BID_RESPONSE = { - body: { - cpm: 1.50, - ad: '', - meta: { - mediaType: 'banner', - }, - width: 300, - height: 250, - creativeId: '189198063', - netRevenue: true, - currency: 'USD', - ttl: 300, - dealId: 'dealId' - - } - }; - - var BID_RESPONSE_VIDEO = { - body: { - cpm: 1.50, - meta: { - mediaType: 'video', - }, - width: 1, - height: 1, - creativeId: '189198063', - netRevenue: true, - currency: 'USD', - ttl: 300, - vastUrl: 'https://vast.com/vast.xml', - dealId: 'dealId' - } - }; - - it('Verify build request to prebid 3.0 display test', function() { - const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'https://domain.com', - numIframes: 0 - } - }); - - expect(request).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request.data); - expect(requestContent.bidRequests[0].params).to.have.property('partnerId').and.to.equal(12345); - expect(requestContent.bidRequests[0]).to.have.property('auctionId').and.to.equal('0cb3144c-d084-4686-b0d6-f5dbe917c563'); - expect(requestContent.bidRequests[0]).to.have.property('bidId').and.to.equal('2c7c8e9c900244'); - expect(requestContent.bidRequests[0]).to.have.property('bidRequestsCount').and.to.equal(1); - expect(requestContent.bidRequests[0]).to.have.property('bidder').and.to.equal('inmar'); - expect(requestContent.bidRequests[0]).to.have.property('bidderRequestId').and.to.equal('1858b7382993ca'); - expect(requestContent.bidRequests[0]).to.have.property('adUnitCode').and.to.equal('test-div'); - expect(requestContent.refererInfo).to.have.property('referer').and.to.equal('https://domain.com'); - expect(requestContent.bidRequests[0].mediaTypes.banner).to.have.property('sizes'); - expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[0]).to.have.ordered.members([300, 250]); - expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[1]).to.have.ordered.members([300, 600]); - expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[2]).to.have.ordered.members([728, 90]); - expect(requestContent.bidRequests[0].mediaTypes.banner.sizes[3]).to.have.ordered.members([970, 250]); - expect(requestContent.bidRequests[0]).to.have.property('transactionId').and.to.equal('29df2112-348b-4961-8863-1b33684d95e6'); - expect(requestContent.refererInfo).to.have.property('numIframes').and.to.equal(0); - }) - - it('Verify interprete response', function () { - const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'https://domain.com', - numIframes: 0 - } - }); - - const bids = spec.interpretResponse(BID_RESPONSE, request); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.50); - expect(bid.ad).to.equal(''); - expect(bid.meta.mediaType).to.equal('banner'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.creativeId).to.equal('189198063'); - expect(bid.netRevenue).to.equal(true); - expect(bid.currency).to.equal('USD'); - expect(bid.ttl).to.equal(300); - expect(bid.dealId).to.equal('dealId'); - }); - - it('no banner media response', function () { - const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES, { - gdprConsent: { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - gdprApplies: true - }, - refererInfo: { - referer: 'https://domain.com', - numIframes: 0 - } - }); - - const bids = spec.interpretResponse(BID_RESPONSE_VIDEO, request); - const bid = bids[0]; - expect(bid.vastUrl).to.equal('https://vast.com/vast.xml'); - }); - - it('Verifies bidder_code', function () { - expect(spec.code).to.equal('inmar'); - }); - - it('Verifies bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('inm'); - }); - - it('Verifies if bid request is valid', function () { - expect(spec.isBidRequestValid(DEFAULT_PARAMS_NEW_SIZES[0])).to.equal(true); - expect(spec.isBidRequestValid(DEFAULT_PARAMS_WO_OPTIONAL[0])).to.equal(true); - expect(spec.isBidRequestValid({})).to.equal(false); - expect(spec.isBidRequestValid({ - params: {} - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - } - })).to.equal(false); - expect(spec.isBidRequestValid({ - params: { - partnerId: 12345 - } - })).to.equal(true); - }); - - it('Verifies user syncs image', function () { - var syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [BID_RESPONSE], { - consentString: '', - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - - syncs = spec.getUserSyncs({ - iframeEnabled: false, - pixelEnabled: true - }, [], { - consentString: null, - referer: 'http://domain.com', - gdprApplies: true - }) - expect(syncs).to.have.lengthOf(1); - expect(syncs[0].type).to.equal('image'); - }); -}); diff --git a/test/spec/modules/innityBidAdapter_spec.js b/test/spec/modules/innityBidAdapter_spec.js index d4a28ec2100..192ab4911ee 100644 --- a/test/spec/modules/innityBidAdapter_spec.js +++ b/test/spec/modules/innityBidAdapter_spec.js @@ -39,7 +39,7 @@ describe('innityAdapterTest', () => { let bidderRequest = { refererInfo: { - referer: 'https://refererExample.com' + page: 'https://refererExample.com' } }; diff --git a/test/spec/modules/inskinBidAdapter_spec.js b/test/spec/modules/inskinBidAdapter_spec.js deleted file mode 100644 index 3d0ec82fca5..00000000000 --- a/test/spec/modules/inskinBidAdapter_spec.js +++ /dev/null @@ -1,386 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/inskinBidAdapter.js'; -import { createBid } from 'src/bidfactory.js'; - -const ENDPOINT = 'https://mfad.inskinad.com/api/v2'; - -const REQUEST = { - 'bidderCode': 'inskin', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d', - 'bidderRequestId': '109f2a181342a9', - 'bidRequest': [{ - 'bidder': 'inskin', - 'params': { - 'networkId': 9874, - 'siteId': 730181, - 'publisherId': 123456 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '2b0f82502298c9', - 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }, - { - 'bidder': 'inskin', - 'params': { - 'networkId': 9874, - 'siteId': 730181 - }, - 'placementCode': 'div-gpt-ad-1487778092495-0', - 'sizes': [ - [728, 90], - [970, 90] - ], - 'bidId': '123', - 'bidderRequestId': '109f2a181342a9', - 'requestId': 'a4713c32-3762-4798-b342-4ab810ca770d' - }], - 'start': 1487883186070, - 'auctionStart': 1487883186069, - 'timeout': 3000 -}; - -const RESPONSE = { - 'headers': null, - 'body': { - 'user': { 'key': 'ue1-2d33e91b71e74929b4aeecc23f4376f1' }, - 'decisions': { - '2b0f82502298c9': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://mfad.inskinad.com/r', - 'impressionUrl': 'https://mfad.inskinad.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - }, - '123': { - 'adId': 2364764, - 'creativeId': 1950991, - 'flightId': 2788300, - 'campaignId': 542982, - 'clickUrl': 'https://mfad.inskinad.com/r', - 'impressionUrl': 'https://mfad.inskinad.com/i.gif', - 'contents': [{ - 'type': 'html', - 'body': '', - 'data': { - 'customData': { - 'pubCPM': 1 - }, - 'height': 90, - 'width': 728, - 'imageUrl': 'https://static.adzerk.net/Advertisers/b0ab77db8a7848c8b78931aed022a5ef.gif', - 'fileName': 'b0ab77db8a7848c8b78931aed022a5ef.gif' - }, - 'template': 'image' - }], - 'height': 90, - 'width': 728, - 'events': [], - 'pricing': {'price': 0.5, 'clearPrice': 0.5, 'revenue': 0.0005, 'rateType': 2, 'eCPM': 0.5} - } - } - } -}; - -const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; -const bidderRequest = { - bidderCode: 'inskin', - gdprConsent: { - consentString: consentString, - gdprApplies: true - }, - refererInfo: { - referer: 'https://www.inskinmedia.com' - } -}; - -describe('InSkin BidAdapter', function () { - let bidRequests; - let adapter = spec; - - beforeEach(function () { - bidRequests = [ - { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx' - }, - placementCode: 'header-bid-tag-1', - sizes: [[300, 250], [300, 600]], - bidId: '23acc48ad47af5', - requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; - }); - - describe('bid request validation', function () { - it('should accept valid bid requests', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should accept valid bid requests with extra fields', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874', - siteId: 'xxxxx', - zoneId: 'xxxxx' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should reject bid requests without siteId', function () { - let bid = { - bidder: 'inskin', - params: { - networkId: '9874' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should reject bid requests without networkId', function () { - let bid = { - bidder: 'inskin', - params: { - siteId: '9874' - } - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests validation', function () { - it('creates request data', function () { - let request = spec.buildRequests(bidRequests, bidderRequest); - - expect(request).to.exist.and.to.be.a('object'); - }); - - it('request to inskin should contain a url', function () { - let request = spec.buildRequests(bidRequests, bidderRequest); - - expect(request.url).to.have.string('inskinad.com'); - }); - - it('requires valid bids to make request', function () { - let request = spec.buildRequests([], bidderRequest); - expect(request.bidRequest).to.be.empty; - }); - - it('sends bid request to ENDPOINT via POST', function () { - let request = spec.buildRequests(bidRequests, bidderRequest); - - expect(request.method).to.have.string('POST'); - }); - - it('should add gdpr consent information to the request', function () { - bidderRequest.bids = bidRequests; - - const request = spec.buildRequests(bidRequests, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.consent.gdprConsentString).to.exist; - expect(payload.consent.gdprConsentRequired).to.exist; - expect(payload.consent.gdprConsentString).to.exist.and.to.equal(consentString); - expect(payload.consent.gdprConsentRequired).to.exist.and.to.be.true; - }); - - it('should not add keywords if TCF v2 purposes are granted', function () { - const bidderRequest2 = Object.assign({}, bidderRequest, { - gdprConsent: { - gdprApplies: true, - consentString: 'consentString', - vendorData: { - vendor: { - consents: { - 150: true - } - }, - purpose: { - consents: { - 1: true, - 2: true, - 3: true, - 4: true, - 5: true, - 6: true, - 7: true, - 8: true, - 9: true, - 10: true - } - } - }, - apiVersion: 2 - } - }); - - const request = spec.buildRequests(bidRequests, bidderRequest2); - const payload = JSON.parse(request.data); - - expect(payload.keywords).to.be.an('array').that.is.empty; - expect(payload.placements[0].properties.restrictions).to.be.undefined; - }); - - it('should add keywords if TCF v2 purposes are not granted', function () { - const bidderRequest2 = Object.assign({}, bidderRequest, { - gdprConsent: { - gdprApplies: true, - consentString: 'consentString', - vendorData: { - vendor: { - consents: { - 150: false - } - }, - purpose: { - consents: { - 1: true, - 2: true, - 3: true, - 4: true, - 5: true, - 6: true, - 7: true, - 8: true, - 9: true, - 10: true - } - } - }, - apiVersion: 2 - } - }); - - const request = spec.buildRequests(bidRequests, bidderRequest2); - const payload = JSON.parse(request.data); - - expect(payload.keywords).to.be.an('array').that.includes('cst-nocookies'); - expect(payload.keywords).to.be.an('array').that.includes('cst-nocontext'); - expect(payload.keywords).to.be.an('array').that.includes('cst-nodmp'); - expect(payload.keywords).to.be.an('array').that.includes('cst-nodata'); - expect(payload.keywords).to.be.an('array').that.includes('cst-noclicks'); - expect(payload.keywords).to.be.an('array').that.includes('cst-noresearch'); - - expect(payload.placements[0].properties.restrictions).to.be.an('array').that.includes('nocookies'); - expect(payload.placements[0].properties.restrictions).to.be.an('array').that.includes('nocontext'); - expect(payload.placements[0].properties.restrictions).to.be.an('array').that.includes('nodmp'); - expect(payload.placements[0].properties.restrictions).to.be.an('array').that.includes('nodata'); - expect(payload.placements[0].properties.restrictions).to.be.an('array').that.includes('noclicks'); - expect(payload.placements[0].properties.restrictions).to.be.an('array').that.includes('noresearch'); - }); - }); - describe('interpretResponse validation', function () { - it('response should have valid bidderCode', function () { - let bidRequest = spec.buildRequests(REQUEST.bidRequest, bidderRequest); - let bid = createBid(1, bidRequest.bidRequest[0]); - - expect(bid.bidderCode).to.equal('inskin'); - }); - - it('response should include objects for all bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids.length).to.equal(2); - }); - - it('registers bids', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - bids.forEach(b => { - expect(b).to.have.property('cpm'); - expect(b.cpm).to.be.above(0); - expect(b).to.have.property('requestId'); - expect(b).to.have.property('cpm'); - expect(b).to.have.property('width'); - expect(b).to.have.property('height'); - expect(b).to.have.property('ad'); - expect(b).to.have.property('currency', 'USD'); - expect(b).to.have.property('creativeId'); - expect(b).to.have.property('ttl', 360); - expect(b.meta).to.have.property('advertiserDomains'); - expect(b).to.have.property('netRevenue', true); - }); - }); - - it('cpm is correctly set', function () { - let bids = spec.interpretResponse(RESPONSE, REQUEST); - - expect(bids[0].cpm).to.equal(0.5); - expect(bids[1].cpm).to.equal(1); - }); - - it('handles nobid responses', function () { - let EMPTY_RESP = Object.assign({}, RESPONSE, {'body': {'decisions': null}}) - let bids = spec.interpretResponse(EMPTY_RESP, REQUEST); - - expect(bids).to.be.empty; - }); - - it('handles no server response', function () { - let bids = spec.interpretResponse(null, REQUEST); - - expect(bids).to.be.empty; - }); - }); - describe('getUserSyncs', function () { - it('handles empty sync options', function () { - let opts = spec.getUserSyncs({}); - - expect(opts).to.be.empty; - }); - - it('should return two sync urls if pixel syncs are enabled', function () { - let syncOptions = {'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(2); - }); - - it('should return three sync urls if pixel and iframe syncs are enabled', function () { - let syncOptions = {'iframeEnabled': true, 'pixelEnabled': true}; - let opts = spec.getUserSyncs(syncOptions); - - expect(opts.length).to.equal(3); - }); - }); - describe('supply chain id', function () { - it('should use publisherId as sid', function () { - const request = spec.buildRequests(REQUEST.bidRequest, bidderRequest); - const payload = JSON.parse(request.data); - - expect(payload.rtb.schain.ext.sid).to.equal('123456'); - }); - }); -}); diff --git a/test/spec/modules/insticatorBidAdapter_spec.js b/test/spec/modules/insticatorBidAdapter_spec.js index e14207ba3e0..e24bcb3b455 100644 --- a/test/spec/modules/insticatorBidAdapter_spec.js +++ b/test/spec/modules/insticatorBidAdapter_spec.js @@ -1,7 +1,6 @@ import { expect } from 'chai'; import { spec, storage } from '../../../modules/insticatorBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js' -import { userSync } from '../../../src/userSync.js'; const USER_ID_KEY = 'hb_insticator_uid'; const USER_ID_DUMMY_VALUE = '74f78609-a92d-4cf1-869f-1b244bbfb5d2'; @@ -18,15 +17,30 @@ describe('InsticatorBidAdapter', function () { adUnitCode: 'adunit-code', params: { adUnitId: '1a2b3c4d5e6f1a2b3c4d', + user: { + yob: 1984, + gender: 'M' + }, }, sizes: [[300, 250], [300, 600]], mediaTypes: { banner: { - sizes: [[300, 250], [300, 600]] - } + sizes: [[300, 250], [300, 600]], + pos: 4, + }, + video: { + mimes: [ + 'video/mp4', + 'video/mpeg', + ], + w: 250, + h: 300, + placement: 2, + }, }, bidId: '30b31c1838de1e', ortb2Imp: { + instl: 1, ext: { gpid: '1111/homepage' } @@ -58,7 +72,11 @@ describe('InsticatorBidAdapter', function () { let bidderRequest = { bidderRequestId, - auctionId: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + ortb2: { + source: { + tid: '74f78609-a92d-4cf1-869f-1b244bbfb5d2', + } + }, timeout: 300, gdprConsent: { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', @@ -68,7 +86,9 @@ describe('InsticatorBidAdapter', function () { refererInfo: { numIframes: 0, reachedTop: true, - referer: 'https://example.com', + page: 'https://example.com', + domain: 'example.com', + ref: 'https://referrer.com', stack: ['https://example.com'] }, }; @@ -91,16 +111,16 @@ describe('InsticatorBidAdapter', function () { }); it('should return false if there is no adUnitId param', () => { - expect(spec.isBidRequestValid({...bidRequest, ...{params: {}}})).to.be.false; + expect(spec.isBidRequestValid({ ...bidRequest, ...{ params: {} } })).to.be.false; }); it('should return false if there is no mediaTypes', () => { - expect(spec.isBidRequestValid({...bidRequest, ...{mediaTypes: {}}})).to.be.false; + expect(spec.isBidRequestValid({ ...bidRequest, ...{ mediaTypes: {} } })).to.be.false; }); it('should return false if there are no banner sizes and no sizes', () => { bidRequest.mediaTypes.banner = {}; - expect(spec.isBidRequestValid({...bidRequest, ...{sizes: {}}})).to.be.false; + expect(spec.isBidRequestValid({ ...bidRequest, ...{ sizes: {} } })).to.be.false; }); it('should return true if there is sizes and no banner sizes', () => { @@ -109,7 +129,55 @@ describe('InsticatorBidAdapter', function () { it('should return true if there is banner sizes and no sizes', () => { bidRequest.mediaTypes.banner.sizes = [[300, 250], [300, 600]]; - expect(spec.isBidRequestValid({...bidRequest, ...{sizes: {}}})).to.be.true; + expect(spec.isBidRequestValid({ ...bidRequest, ...{ sizes: {} } })).to.be.true; + }); + + it('should return true if there is video and video sizes', () => { + expect(spec.isBidRequestValid({ + ...bidRequest, + ...{ + mediaTypes: { + video: { + mimes: [ + 'video/mp4', + 'video/mpeg', + ], + w: 250, + h: 300, + }, + } + } + })).to.be.true; + }); + + it('should return false if there is no video sizes', () => { + expect(spec.isBidRequestValid({ + ...bidRequest, + ...{ + mediaTypes: { + video: {}, + } + } + })).to.be.false; + }); + + it('should return false if video placement is not a number', () => { + expect(spec.isBidRequestValid({ + ...bidRequest, + ...{ + mediaTypes: { + video: { + mimes: [ + 'video/mp4', + 'video/mpeg', + ], + w: 250, + h: 300, + placement: 'NaN', + }, + } + } + })).to.be.false; }); }); @@ -117,8 +185,14 @@ describe('InsticatorBidAdapter', function () { let getDataFromLocalStorageStub, localStorageIsEnabledStub; let getCookieStub, cookiesAreEnabledStub; let sandbox; + let serverRequests, serverRequest; beforeEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + insticator: { + storageAllowed: true + } + }; getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); getCookieStub = sinon.stub(storage, 'getCookie'); @@ -134,14 +208,18 @@ describe('InsticatorBidAdapter', function () { localStorageIsEnabledStub.restore(); getCookieStub.restore(); cookiesAreEnabledStub.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; }); - const serverRequests = spec.buildRequests([bidRequest], bidderRequest); + before(() => { + serverRequests = spec.buildRequests([bidRequest], bidderRequest); + serverRequest = serverRequests[0]; + }) + it('should create a request', function () { expect(serverRequests).to.have.length(1); }); - const serverRequest = serverRequests[0]; it('should create a request object with method, URL, options and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -178,7 +256,7 @@ describe('InsticatorBidAdapter', function () { expect(data.tmax).to.equal(bidderRequest.timeout); expect(data.source).to.have.all.keys('fd', 'tid', 'ext'); expect(data.source.fd).to.equal(1); - expect(data.source.tid).to.equal(bidderRequest.auctionId); + expect(data.source.tid).to.equal(bidderRequest.ortb2.source.tid); expect(data.source.ext).to.have.property('schain').to.deep.equal({ ver: '1.0', complete: 1, @@ -194,7 +272,7 @@ describe('InsticatorBidAdapter', function () { expect(data.site).to.be.an('object'); expect(data.site.domain).not.to.be.empty; expect(data.site.page).not.to.be.empty; - expect(data.site.ref).to.equal(bidderRequest.refererInfo.referer); + expect(data.site.ref).to.equal(bidderRequest.refererInfo.ref); expect(data.device).to.be.an('object'); expect(data.device.w).to.equal(window.innerWidth); expect(data.device.h).to.equal(window.innerHeight); @@ -206,7 +284,10 @@ describe('InsticatorBidAdapter', function () { expect(data.regs.ext.gdpr).to.equal(1); expect(data.regs.ext.gdprConsentString).to.equal(bidderRequest.gdprConsent.consentString); expect(data.user).to.be.an('object'); - expect(data.user.id).to.equal(USER_ID_DUMMY_VALUE); + expect(data.user).to.have.property('yob'); + expect(data.user.yob).to.equal(1984); + expect(data.user).to.have.property('gender'); + expect(data.user.gender).to.equal('M'); expect(data.user.ext).to.have.property('eids'); expect(data.user.ext.eids).to.deep.equal([ { @@ -223,12 +304,23 @@ describe('InsticatorBidAdapter', function () { expect(data.imp).to.deep.equal([{ id: bidRequest.bidId, tagid: bidRequest.adUnitCode, + instl: 1, + secure: 0, banner: { format: [ - {w: 300, h: 250}, - {w: 300, h: 600}, + { w: 300, h: 250 }, + { w: 300, h: 600 } ] }, + video: { + mimes: [ + 'video/mp4', + 'video/mpeg', + ], + h: 300, + w: 250, + placement: 2, + }, ext: { gpid: bidRequest.ortb2Imp.ext.gpid, insticator: { @@ -256,7 +348,7 @@ describe('InsticatorBidAdapter', function () { expect(data.user.id).to.equal(USER_ID_STUBBED); }); it('should return empty regs object if no gdprConsent is passed', function () { - const requests = spec.buildRequests([bidRequest], {...bidderRequest, ...{gdprConsent: false}}); + const requests = spec.buildRequests([bidRequest], { ...bidderRequest, ...{ gdprConsent: false } }); const data = JSON.parse(requests[0].data); expect(data.regs).to.be.an('object').that.is.empty; }); @@ -384,14 +476,12 @@ describe('InsticatorBidAdapter', function () { width: 300, height: 200, mediaType: 'banner', - meta: { - advertiserDomains: [ - 'test1.com' - ], - test: 1 - }, ad: 'adm1', adUnitCode: 'adunit-code-1', + meta: { + advertiserDomains: ['test1.com'], + test: 1 + } }, { requestId: 'bid2', diff --git a/test/spec/modules/intentIqIdSystem_spec.js b/test/spec/modules/intentIqIdSystem_spec.js index 8ea30a6ba92..ef174af416b 100644 --- a/test/spec/modules/intentIqIdSystem_spec.js +++ b/test/spec/modules/intentIqIdSystem_spec.js @@ -1,19 +1,42 @@ import { expect } from 'chai'; -import {intentIqIdSubmodule, readData, FIRST_PARTY_KEY} from 'modules/intentIqIdSystem.js'; +import { intentIqIdSubmodule, storage } from 'modules/intentIqIdSystem.js'; import * as utils from 'src/utils.js'; -import {server} from 'test/mocks/xhr.js'; +import { server } from 'test/mocks/xhr.js'; const partner = 10; const pai = '11'; const pcid = '12'; -const defaultConfigParams = { params: {partner: partner} }; -const paiConfigParams = { params: {partner: partner, pai: pai} }; -const pcidConfigParams = { params: {partner: partner, pcid: pcid} }; -const allConfigParams = { params: {partner: partner, pai: pai, pcid: pcid} }; -const responseHeader = {'Content-Type': 'application/json'} +const enableCookieStorage = true; +const defaultConfigParams = { params: { partner: partner } }; +const paiConfigParams = { params: { partner: partner, pai: pai } }; +const pcidConfigParams = { params: { partner: partner, pcid: pcid } }; +const enableCookieConfigParams = { params: { partner: partner, enableCookieStorage: enableCookieStorage } }; +const allConfigParams = { params: { partner: partner, pai: pai, pcid: pcid, enableCookieStorage: enableCookieStorage } }; +const responseHeader = { 'Content-Type': 'application/json' } describe('IntentIQ tests', function () { let logErrorStub; + let testLSValue = { + 'date': 1651945280759, + 'cttl': 2000, + 'rrtt': 123 + } + let testLSValueWithData = { + 'date': 1651945280759, + 'cttl': 9999999999999, + 'rrtt': 123, + 'data': 'previousTestData' + } + let testResponseWithValues = { + 'abPercentage': 90, + 'adt': 1, + 'ct': 2, + 'data': 'testdata', + 'dbsaved': 'false', + 'ls': true, + 'mde': true, + 'tc': 4 + } beforeEach(function () { logErrorStub = sinon.stub(utils, 'logError'); @@ -36,11 +59,43 @@ describe('IntentIQ tests', function () { }); it('should log an error if partner configParam was not a numeric value', function () { - let submodule = intentIqIdSubmodule.getId({ params: {partner: '10'} }); + let submodule = intentIqIdSubmodule.getId({ params: { partner: '10' } }); expect(logErrorStub.calledOnce).to.be.true; expect(submodule).to.be.undefined; }); + it('should not save data in cookie if enableCookieStorage configParam not set', function () { + let callBackSpy = sinon.spy(); + let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&iiqidtype=2&iiqpcid='); + request.respond( + 200, + responseHeader, + JSON.stringify({ pid: 'test_pid', data: 'test_personid', ls: true }) + ); + expect(callBackSpy.calledOnce).to.be.true; + expect(storage.getCookie('_iiq_fdata_' + partner)).to.equal(null); + }); + + it('should save data in cookie if enableCookieStorage configParam set to true', function () { + let callBackSpy = sinon.spy(); + let submoduleCallback = intentIqIdSubmodule.getId(allConfigParams).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&pai=11&iiqidtype=2&iiqpcid='); + request.respond( + 200, + responseHeader, + JSON.stringify({ pid: 'test_pid', data: 'test_personid', ls: true }) + ); + expect(callBackSpy.calledOnce).to.be.true; + const cookieValue = storage.getCookie('_iiq_fdata_' + partner) + expect(cookieValue).to.not.equal(null) + expect(JSON.parse(cookieValue).data).to.be.equal('test_personid'); + }); + it('should call the IntentIQ endpoint with only partner', function () { let callBackSpy = sinon.spy(); let submoduleCallback = intentIqIdSubmodule.getId(defaultConfigParams).callback; @@ -114,10 +169,8 @@ describe('IntentIQ tests', function () { request.respond( 204, responseHeader, - '' ); expect(callBackSpy.calledOnce).to.be.true; - expect(request.response).to.equal(''); }); it('should log an error and continue to callback if ajax request errors', function () { @@ -143,7 +196,7 @@ describe('IntentIQ tests', function () { request.respond( 200, responseHeader, - JSON.stringify({pid: 'test_pid', data: 'test_personid', ls: true}) + JSON.stringify({ pid: 'test_pid', data: 'test_personid', ls: true }) ); expect(callBackSpy.calledOnce).to.be.true; expect(callBackSpy.args[0][0]).to.be.eq('test_personid'); @@ -158,7 +211,7 @@ describe('IntentIQ tests', function () { request.respond( 200, responseHeader, - JSON.stringify({pid: 'test_pid', data: 'test_personid', ls: false}) + JSON.stringify({ pid: 'test_pid', data: 'test_personid', ls: false }) ); expect(callBackSpy.calledOnce).to.be.true; expect(callBackSpy.args[0][0]).to.be.undefined; @@ -173,9 +226,38 @@ describe('IntentIQ tests', function () { request.respond( 200, responseHeader, - JSON.stringify({pid: 'test_pid', data: '', ls: true}) + JSON.stringify({ pid: 'test_pid', data: '', ls: true }) ); expect(callBackSpy.calledOnce).to.be.true; expect(callBackSpy.args[0][0]).to.be.eq('INVALID_ID'); }); + + it('send addition parameters if were found in localstorage', function () { + localStorage.setItem('_iiq_fdata_' + partner, JSON.stringify(testLSValue)) + let callBackSpy = sinon.spy(); + let submoduleCallback = intentIqIdSubmodule.getId(allConfigParams).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + + expect(request.url).to.contain('https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=10&pt=17&dpn=1&pcid=12&pai=11&iiqidtype=2&iiqpcid='); + expect(request.url).to.contain('cttl=' + testLSValue.cttl); + expect(request.url).to.contain('rrtt=' + testLSValue.rrtt); + request.respond( + 200, + responseHeader, + JSON.stringify(testResponseWithValues) + ); + expect(callBackSpy.calledOnce).to.be.true; + expect(callBackSpy.args[0][0]).to.be.eq(testResponseWithValues.data); + }); + + it('return data stored in local storage ', function () { + localStorage.setItem('_iiq_fdata_' + partner, JSON.stringify(testLSValueWithData)) + let callBackSpy = sinon.spy(); + let submoduleCallback = intentIqIdSubmodule.getId(allConfigParams).callback; + submoduleCallback(callBackSpy); + expect(server.requests.length).to.be.equal(0); + expect(callBackSpy.calledOnce).to.be.true; + expect(callBackSpy.args[0][0]).to.be.equal(testLSValueWithData.data); + }); }); diff --git a/test/spec/modules/invibesBidAdapter_spec.js b/test/spec/modules/invibesBidAdapter_spec.js index ae7b30c9f81..7ee6b464996 100644 --- a/test/spec/modules/invibesBidAdapter_spec.js +++ b/test/spec/modules/invibesBidAdapter_spec.js @@ -1,4 +1,5 @@ import {expect} from 'chai'; +import { config } from 'src/config.js'; import {spec, resetInvibes, stubDomainOptions, readGdprConsent} from 'modules/invibesBidAdapter.js'; describe('invibesBidAdapter:', function () { @@ -13,7 +14,9 @@ describe('invibesBidAdapter:', function () { bidder: BIDDER_CODE, bidderRequestId: 'r1', params: { - placementId: PLACEMENT_ID + placementId: PLACEMENT_ID, + disableUserSyncs: false + }, adUnitCode: 'test-div1', auctionId: 'a1', @@ -28,7 +31,8 @@ describe('invibesBidAdapter:', function () { bidder: BIDDER_CODE, bidderRequestId: 'r2', params: { - placementId: 'abcde' + placementId: 'abcde', + disableUserSyncs: false }, adUnitCode: 'test-div2', auctionId: 'a2', @@ -77,6 +81,13 @@ describe('invibesBidAdapter:', function () { } ]; + let bidderRequestWithPageInfo = { + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + }, + auctionStart: Date.now() + } + let StubbedPersistence = function (initialValue) { var value = initialValue; return { @@ -93,13 +104,30 @@ describe('invibesBidAdapter:', function () { } }; + let SetBidderAccess = function() { + config.setConfig({ + deviceAccess: true + }); + $$PREBID_GLOBAL$$.bidderSettings = { + invibes: { + storageAllowed: true + } + }; + } + beforeEach(function () { resetInvibes(); + $$PREBID_GLOBAL$$.bidderSettings = { + invibes: { + storageAllowed: true + } + }; document.cookie = ''; this.cStub1 = sinon.stub(console, 'info'); }); afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; this.cStub1.restore(); }); @@ -152,8 +180,18 @@ describe('invibesBidAdapter:', function () { }); describe('buildRequests', function () { + it('sends preventPageViewEvent as false on first call', function () { + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + expect(request.data.preventPageViewEvent).to.be.false; + }); + + it('sends preventPageViewEvent as true on 2nd call', function () { + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + expect(request.data.preventPageViewEvent).to.be.true; + }); + it('sends bid request to ENDPOINT via GET', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -167,7 +205,7 @@ describe('invibesBidAdapter:', function () { customEndpoint: 'sub.domain.com/Bid/VideoAdContent' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('sub.domain.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -179,7 +217,7 @@ describe('invibesBidAdapter:', function () { params: { }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -192,7 +230,7 @@ describe('invibesBidAdapter:', function () { placementId: null }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -205,7 +243,7 @@ describe('invibesBidAdapter:', function () { placementId: 'placement' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -219,7 +257,7 @@ describe('invibesBidAdapter:', function () { domainId: 1001 }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -233,7 +271,7 @@ describe('invibesBidAdapter:', function () { domainId: 1002 }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid2.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -246,7 +284,7 @@ describe('invibesBidAdapter:', function () { placementId: 'infeed_ivbs1' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -259,7 +297,7 @@ describe('invibesBidAdapter:', function () { placementId: 'infeed_ivbs2' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid2.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); @@ -272,18 +310,18 @@ describe('invibesBidAdapter:', function () { placementId: 'infeed_ivbs10' }, adUnitCode: 'test-div1' - }]); + }], bidderRequestWithPageInfo); expect(request.url).to.equal('https://bid10.videostep.com/Bid/VideoAdContent'); expect(request.method).to.equal('GET'); }); it('sends cookies with the bid request', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.options.withCredentials).to.equal(true); }); it('has location, html id, placement and width/height', function () { - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); const parsedData = request.data; expect(parsedData.location).to.exist; expect(parsedData.videoAdHtmlId).to.exist; @@ -292,75 +330,112 @@ describe('invibesBidAdapter:', function () { expect(parsedData.height).to.exist; }); + it('has location not cut off', function () { + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + const parsedData = request.data; + expect(parsedData.location).to.contain('?'); + expect(parsedData.location).to.equal('https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue'); + }); + it('has capped ids if local storage variable is correctly formatted', function () { top.window.invibes.optIn = 1; top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false]; localStorage.ivvcap = '{"9731":[1,1768600800000]}'; - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + SetBidderAccess(); + + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + expect(request.data.capCounts).to.equal('9731=1'); }); it('does not have capped ids if local storage variable is correctly formatted but no opt in', function () { + let bidderRequest = { + auctionStart: Date.now(), + gdprConsent: { + vendorData: { + gdprApplies: true, + hasGlobalConsent: false, + purpose: { + consents: { + 1: false, + 2: false, + 3: false, + 4: false, + 5: false, + 6: false, + 7: false, + 8: false, + 9: false, + 10: false + } + } + } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + } + }; + localStorage.ivvcap = '{"9731":[1,1768600800000]}'; - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.capCounts).to.equal(''); }); it('does not have capped ids if local storage variable is incorrectly formatted', function () { localStorage.ivvcap = ':[1,1574334216992]}'; - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.capCounts).to.equal(''); }); it('does not have capped ids if local storage variable is expired', function () { localStorage.ivvcap = '{"9731":[1,1574330064104]}'; - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.capCounts).to.equal(''); }); it('sends query string params from localstorage 1', function () { localStorage.ivbs = JSON.stringify({bvci: 1}); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.bvci).to.equal(1); }); it('sends query string params from localstorage 2', function () { localStorage.ivbs = JSON.stringify({invibbvlog: true}); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.invibbvlog).to.equal(true); }); it('does not send query string params from localstorage if unknwon', function () { localStorage.ivbs = JSON.stringify({someparam: true}); - const request = spec.buildRequests(bidRequests, {auctionStart: Date.now()}); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.someparam).to.be.undefined; }); it('sends all Placement Ids', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[0].params.placementId); expect(JSON.parse(request.data.bidParamsJson).placementIds).to.contain(bidRequests[1].params.placementId); }); it('sends all adUnitCodes', function () { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[0].adUnitCode); expect(JSON.parse(request.data.bidParamsJson).adUnitCodes).to.contain(bidRequests[1].adUnitCode); }); it('sends all Placement Ids and userId', function () { - const request = spec.buildRequests(bidRequestsWithUserId); + const request = spec.buildRequests(bidRequestsWithUserId, bidderRequestWithPageInfo); expect(JSON.parse(request.data.bidParamsJson).userId).to.exist; }); it('sends undefined lid when no cookie', function () { - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.lId).to.be.undefined; }); it('sends pushed cids if they exist', function () { top.window.invibes.pushedCids = { 981: [] }; - let request = spec.buildRequests(bidRequests); + let request = spec.buildRequests(bidRequests, bidderRequestWithPageInfo); expect(request.data.pcids).to.contain(981); }); @@ -368,7 +443,20 @@ describe('invibesBidAdapter:', function () { top.window.invibes.optIn = 1; top.window.invibes.purposes = [true, false, false, false, false, false, false, false, false, false]; global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":' + Date.now() + ',"hc":0}'; - let bidderRequest = {gdprConsent: {vendorData: {vendorConsents: {436: true}}}}; + let bidderRequest = { + gdprConsent: { + vendorData: { + vendorConsents: { + 436: true + } + } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' + } + }; + SetBidderAccess(); + let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.lId).to.exist; }); @@ -395,6 +483,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -423,6 +514,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -451,6 +545,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -491,15 +588,21 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.li.split(',')[1] && request.data.li.split(',')[6]).to.equal('true'); }); - it('should send oi = 0 when vendorData is null', function () { + it('should send oi = 1 when vendorData is null (calculation will be performed by ADWEB)', function () { let bidderRequest = { gdprConsent: { vendorData: null + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -528,6 +631,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -555,6 +661,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -582,6 +691,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -609,6 +721,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -623,6 +738,9 @@ describe('invibesBidAdapter:', function () { vendor: {consents: {436: false}}, purpose: {} } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -651,6 +769,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -674,6 +795,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -702,6 +826,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -730,6 +857,9 @@ describe('invibesBidAdapter:', function () { } } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -751,6 +881,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -772,6 +905,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -785,6 +921,9 @@ describe('invibesBidAdapter:', function () { gdprApplies: false, hasGlobalConsent: true, } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -806,6 +945,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -827,6 +969,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -846,6 +991,9 @@ describe('invibesBidAdapter:', function () { 3: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -867,6 +1015,9 @@ describe('invibesBidAdapter:', function () { 5: true } } + }, + refererInfo: { + page: 'https://randomWeb.com?someFakePara=fakeValue&secondParam=secondValue' } }; let request = spec.buildRequests(bidRequests, bidderRequest); @@ -962,7 +1113,29 @@ describe('invibesBidAdapter:', function () { UseAdUnitCode: true }; - var buildResponse = function(placementId, cid, blcids, creativeId) { + var buildResponse = function(placementId, cid, blcids, creativeId, ShouldSetLId) { + if (ShouldSetLId) { + return { + MultipositionEnabled: true, + AdPlacements: [{ + Ads: [{ + BidPrice: 0.5, + VideoExposedId: creativeId, + Cid: cid, + Blcids: blcids + }], + BidModel: { + BidVersion: 1, + PlacementId: placementId, + AuctionStartTime: Date.now(), + CreativeHtml: '' + } + }], + ShouldSetLId: true, + LId: 'dvdjkams6nkq' + } + } + return { MultipositionEnabled: true, AdPlacements: [{ @@ -1066,6 +1239,22 @@ describe('invibesBidAdapter:', function () { }); }); + context('AdWeb generates LIDs', function() { + it('works when no LID is not sent from AdWeb', function() { + var firstResponse = buildResponse('12345', 1, [], 123); + + var firstResult = spec.interpretResponse({body: firstResponse}, {bidRequests}); + expect(firstResult[0].creativeId).to.equal(123); + }); + + it('sets lid when AdWeb sends it', function() { + var firstResponse = buildResponse('12345', 1, [], 123, true); + + spec.interpretResponse({body: firstResponse}, {bidRequests}); + expect(global.document.cookie.indexOf('ivbsdid')).to.greaterThanOrEqual(0); + }); + }); + context('in multiposition context, with conflicting ads', function() { it('registers the second ad when no conflict', function() { var firstResponse = buildResponse('12345', 1, [1], 123); @@ -1115,7 +1304,15 @@ describe('invibesBidAdapter:', function () { }); describe('getUserSyncs', function () { + it('returns undefined if disableUserSyncs not passed as bid request param ', function () { + spec.buildRequests(bidRequestsWithUserId, bidderRequestWithPageInfo); + let response = spec.getUserSyncs({iframeEnabled: true}); + expect(response).to.equal(undefined); + }); + it('returns an iframe if enabled', function () { + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + let response = spec.getUserSyncs({iframeEnabled: true}); expect(response.type).to.equal('iframe'); expect(response.url).to.include(SYNC_ENDPOINT); @@ -1123,26 +1320,45 @@ describe('invibesBidAdapter:', function () { it('returns an iframe with params if enabled', function () { top.window.invibes.optIn = 1; - global.document.cookie = 'ivvbks=17639.0,1,2'; + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + let response = spec.getUserSyncs({iframeEnabled: true}); expect(response.type).to.equal('iframe'); expect(response.url).to.include(SYNC_ENDPOINT); expect(response.url).to.include('optIn'); - expect(response.url).to.include('ivvbks'); }); it('returns an iframe with params including if enabled', function () { top.window.invibes.optIn = 1; - global.document.cookie = 'ivvbks=17639.0,1,2;ivbsdid={"id":"dvdjkams6nkq","cr":' + Date.now() + ',"hc":0}'; + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + + global.document.cookie = 'ivbsdid={"id":"dvdjkams6nkq","cr":' + Date.now() + ',"hc":0}'; + SetBidderAccess(); + + let response = spec.getUserSyncs({iframeEnabled: true}); + expect(response.type).to.equal('iframe'); + expect(response.url).to.include(SYNC_ENDPOINT); + expect(response.url).to.include('optIn'); + expect(response.url).to.include('ivbsdid'); + }); + + it('returns an iframe with params including if enabled read from LocalStorage', function () { + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + top.window.invibes.optIn = 1; + + localStorage.ivbsdid = 'dvdjkams6nkq'; + SetBidderAccess(); + let response = spec.getUserSyncs({iframeEnabled: true}); expect(response.type).to.equal('iframe'); expect(response.url).to.include(SYNC_ENDPOINT); expect(response.url).to.include('optIn'); - expect(response.url).to.include('ivvbks'); expect(response.url).to.include('ivbsdid'); }); it('returns undefined if iframe not enabled ', function () { + spec.buildRequests(bidRequests, bidderRequestWithPageInfo); + let response = spec.getUserSyncs({iframeEnabled: false}); expect(response).to.equal(undefined); }); diff --git a/test/spec/modules/invisiblyAnalyticsAdapter_spec.js b/test/spec/modules/invisiblyAnalyticsAdapter_spec.js index e13b16661b0..a8828515ffd 100644 --- a/test/spec/modules/invisiblyAnalyticsAdapter_spec.js +++ b/test/spec/modules/invisiblyAnalyticsAdapter_spec.js @@ -1,5 +1,7 @@ import invisiblyAdapter from 'modules/invisiblyAnalyticsAdapter.js'; import { expect } from 'chai'; +import {expectEvents} from '../../helpers/analytics.js'; +import {server} from '../../mocks/xhr.js'; let events = require('src/events'); let constants = require('src/constants.json'); @@ -52,7 +54,7 @@ describe('Invisibly Analytics Adapter test suite', function () { hb_source: 'server', }, getStatusCode() { - return CONSTANTS.STATUS.NO_BID; + return CONSTANTS.STATUS.GOOD; }, }; @@ -168,11 +170,7 @@ describe('Invisibly Analytics Adapter test suite', function () { describe('Invisibly Analytic tests specs', function () { beforeEach(function () { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (xhr) => { - requests.push(xhr); - }; + requests = server.requests; sinon.stub(events, 'getEvents').returns([]); sinon.spy(invisiblyAdapter, 'track'); }); @@ -181,7 +179,6 @@ describe('Invisibly Analytics Adapter test suite', function () { invisiblyAdapter.disableAnalytics(); events.getEvents.restore(); invisiblyAdapter.track.restore(); - xhr.restore(); }); describe('Send all events as & when they are captured', function () { @@ -197,12 +194,8 @@ describe('Invisibly Analytics Adapter test suite', function () { account: 'invisibly', }, }); - events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); - events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); - events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); - sinon.assert.callCount(invisiblyAdapter.track, 5); + + expectEvents().to.beTrackedBy(invisiblyAdapter.track); }); it('should not catch events triggered without invisibly account config', function () { @@ -380,7 +373,6 @@ describe('Invisibly Analytics Adapter test suite', function () { expect(invisiblyEvents.event_data.pageViewId).to.exist; expect(invisiblyEvents.event_data.ver).to.equal(1); expect(invisiblyEvents.event_type).to.equal('PREBID_bidWon'); - sinon.assert.callCount(invisiblyAdapter.track, 1); }); // spec for bidder done event @@ -518,7 +510,6 @@ describe('Invisibly Analytics Adapter test suite', function () { expect(invisiblyEvents.event_data.auctionId).to.equal( MOCK.AUCTION_END.auctionId ); - sinon.assert.callCount(invisiblyAdapter.track, 1); }); // should not call sendEvent for events not supported by the adapter @@ -537,21 +528,21 @@ describe('Invisibly Analytics Adapter test suite', function () { it('track all event without errors', function () { invisiblyAdapter.enableAnalytics(MOCK.config); - events.emit(constants.EVENTS.AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(constants.EVENTS.AUCTION_END, MOCK.AUCTION_END); - events.emit(constants.EVENTS.BID_ADJUSTMENT, MOCK.BID_ADJUSTMENT); - events.emit(constants.EVENTS.BID_TIMEOUT, MOCK.BID_TIMEOUT); - events.emit(constants.EVENTS.BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(constants.EVENTS.BID_RESPONSE, MOCK.BID_RESPONSE); - events.emit(constants.EVENTS.NO_BID, MOCK.NO_BID); - events.emit(constants.EVENTS.BID_WON, MOCK.BID_WON); - events.emit(constants.EVENTS.BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(constants.EVENTS.SET_TARGETING, MOCK.SET_TARGETING); - events.emit(constants.EVENTS.REQUEST_BIDS, MOCK.REQUEST_BIDS); - events.emit(constants.EVENTS.ADD_AD_UNITS, MOCK.ADD_AD_UNITS); - events.emit(constants.EVENTS.AD_RENDER_FAILED, MOCK.AD_RENDER_FAILED); - - sinon.assert.callCount(invisiblyAdapter.track, 13); + expectEvents([ + constants.EVENTS.AUCTION_INIT, + constants.EVENTS.AUCTION_END, + constants.EVENTS.BID_ADJUSTMENT, + constants.EVENTS.BID_TIMEOUT, + constants.EVENTS.BID_REQUESTED, + constants.EVENTS.BID_RESPONSE, + constants.EVENTS.NO_BID, + constants.EVENTS.BID_WON, + constants.EVENTS.BIDDER_DONE, + constants.EVENTS.SET_TARGETING, + constants.EVENTS.REQUEST_BIDS, + constants.EVENTS.ADD_AD_UNITS, + constants.EVENTS.AD_RENDER_FAILED + ]).to.beTrackedBy(invisiblyAdapter.track); }); }); diff --git a/test/spec/modules/ipromBidAdapter_spec.js b/test/spec/modules/ipromBidAdapter_spec.js index a3310a33cc2..bb2f364bece 100644 --- a/test/spec/modules/ipromBidAdapter_spec.js +++ b/test/spec/modules/ipromBidAdapter_spec.js @@ -29,13 +29,15 @@ describe('iPROM Adapter', function () { bidderRequest = { timeout: 3000, refererInfo: { - referer: 'https://adserver.si/index.html', - reachedTop: true, - numIframes: 1, - stack: [ - 'https://adserver.si/index.html', - 'https://adserver.si/iframe1.html', - ] + legacy: { + referer: 'https://adserver.si/index.html', + reachedTop: true, + numIframes: 1, + stack: [ + 'https://adserver.si/index.html', + 'https://adserver.si/iframe1.html', + ] + } } } }); diff --git a/test/spec/modules/iqmBidAdapter_spec.js b/test/spec/modules/iqmBidAdapter_spec.js index 27693937330..2f8b5811b2f 100644 --- a/test/spec/modules/iqmBidAdapter_spec.js +++ b/test/spec/modules/iqmBidAdapter_spec.js @@ -101,7 +101,7 @@ describe('iqmAdapter', function () { bidfloor: 0.5}, crumbs: { pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, - fpd: {'context': {'pbAdSlot': '/19968336/header-bid-tag-0'}}, + ortb2Imp: {ext: {data: {'pbadslot': '/19968336/header-bid-tag-0'}}}, mediaTypes: { banner: { sizes: [[300, 250]]}}, @@ -116,7 +116,41 @@ describe('iqmAdapter', function () { bidderRequestsCount: 1, bidderWinsCount: 0}]; - let bidderRequest = {bidderCode: 'iqm', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', bidderRequestId: '13c05d264c7ffe', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5}, crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, fpd: {context: {pbAdSlot: '/19968336/header-bid-tag-0'}}, mediaTypes: {banner: {sizes: [[300, 250]]}}, adUnitCode: '/19968336/header-bid-tag-0', transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8', sizes: [[300, 250]], bidId: '266d810da21904', bidderRequestId: '13c05d264c7ffe', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615205942159, timeout: 7000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], canonicalUrl: null}, start: 1615205942162}; + let bidderRequest = { + bidderCode: 'iqm', + auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', + bidderRequestId: '13c05d264c7ffe', + bids: [{ + bidder: 'iqm', + params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5}, + crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, + ortb2Imp: {ext: {data: {'pbadslot': '/19968336/header-bid-tag-0'}}}, + mediaTypes: {banner: {sizes: [[300, 250]]}}, + adUnitCode: '/19968336/header-bid-tag-0', + transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8', + sizes: [[300, 250]], + bidId: '266d810da21904', + bidderRequestId: '13c05d264c7ffe', + auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }], + auctionStart: 1615205942159, + timeout: 7000, + refererInfo: { + page: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', + domain: 'test.localhost.com:9999', + ref: null, + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], + canonicalUrl: null + }, + start: 1615205942162 + }; it('should parse out sizes', function () { let temp = []; @@ -141,8 +175,80 @@ describe('iqmAdapter', function () { expect(request[0].method).to.equal('POST'); }); it('should attach valid video params to the tag', function () { - let validBidRequests_video = [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', sizes: [[640, 480]], bidId: '28bfb7e2d12897', bidderRequestId: '16e1ce8481bc6d', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}]; - let bidderRequest_video = {bidderCode: 'iqm', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', bidderRequestId: '16e1ce8481bc6d', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', sizes: [[640, 480]], bidId: '28bfb7e2d12897', bidderRequestId: '16e1ce8481bc6d', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615271191985, timeout: 3000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'], canonicalUrl: null}, start: 1615271191988}; + let validBidRequests_video = [{ + bidder: 'iqm', + params: { + publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', + placementId: 23451, + bidfloor: 0.5, + video: { + placement: 2, + mimes: ['video/mp4'], + protocols: [2, 5], + skipppable: true, + playback_method: ['auto_play_sound_off'] + } + }, + crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, + ortb2Imp: {ext: {data: {'pbadslot': 'video1'}}}, + mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, + adUnitCode: 'video1', + transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', + sizes: [[640, 480]], + bidId: '28bfb7e2d12897', + bidderRequestId: '16e1ce8481bc6d', + auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }]; + let bidderRequest_video = { + bidderCode: 'iqm', + auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', + bidderRequestId: '16e1ce8481bc6d', + bids: [{ + bidder: 'iqm', + params: { + publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', + placementId: 23451, + bidfloor: 0.5, + video: { + placement: 2, + mimes: ['video/mp4'], + protocols: [2, 5], + skipppable: true, + playback_method: ['auto_play_sound_off'] + } + }, + crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, + fpd: {context: {pbAdSlot: 'video1'}}, + mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, + adUnitCode: 'video1', + transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', + sizes: [[640, 480]], + bidId: '28bfb7e2d12897', + bidderRequestId: '16e1ce8481bc6d', + auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }], + auctionStart: 1615271191985, + timeout: 3000, + refererInfo: { + page: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html', + domain: 'test.localhost.com:9999', + ref: null, + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'], + canonicalUrl: null + }, + start: 1615271191988 + }; const request = spec.buildRequests(validBidRequests_video, bidderRequest_video); const payload = request[0].data; expect(payload.imp.id).to.exist; @@ -161,11 +267,13 @@ describe('iqmAdapter', function () { }); it('should add referer info to payload', function () { + // TODO: this is wrong on multiple levels + // The payload contains everything in `bidderRequest`; that is sometimes not even serializable + // this should not be testing the validity of internal Prebid structures const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = request[0].data; expect(payload.bidderRequest.refererInfo).to.exist; - expect(payload.bidderRequest.refererInfo).to.deep.equal({referer: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], canonicalUrl: null}); }); }) @@ -179,7 +287,7 @@ describe('iqmAdapter', function () { bidfloor: 0.5}, crumbs: { pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, - fpd: {'context': {'pbAdSlot': '/19968336/header-bid-tag-0'}}, + ortb2Imp: {ext: {data: {'pbadslot': '/19968336/header-bid-tag-0'}}}, mediaTypes: { banner: { sizes: [[300, 250]]}}, @@ -193,7 +301,41 @@ describe('iqmAdapter', function () { bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}]; - let bidderRequest = {bidderCode: 'iqm', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', bidderRequestId: '13c05d264c7ffe', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5}, crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, fpd: {context: {pbAdSlot: '/19968336/header-bid-tag-0'}}, mediaTypes: {banner: {sizes: [[300, 250]]}}, adUnitCode: '/19968336/header-bid-tag-0', transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8', sizes: [[300, 250]], bidId: '266d810da21904', bidderRequestId: '13c05d264c7ffe', auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615205942159, timeout: 7000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], canonicalUrl: null}, start: 1615205942162}; + let bidderRequest = { + bidderCode: 'iqm', + auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', + bidderRequestId: '13c05d264c7ffe', + bids: [{ + bidder: 'iqm', + params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5}, + crumbs: {pubcid: 'a0f51f64-6d86-41d0-abaf-7ece71404d94'}, + ortb2Imp: {ext: {data: {'pbadslot': '/19968336/header-bid-tag-0'}}}, + mediaTypes: {banner: {sizes: [[300, 250]]}}, + adUnitCode: '/19968336/header-bid-tag-0', + transactionId: '56fe8d92-ff6e-4c34-90ad-2f743cd0eae8', + sizes: [[300, 250]], + bidId: '266d810da21904', + bidderRequestId: '13c05d264c7ffe', + auctionId: '565ab569-ab95-40d6-8b42-b9707a92062f', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }], + auctionStart: 1615205942159, + timeout: 7000, + refererInfo: { + page: 'http://test.localhost:9999/integrationExamples/gpt/hello_world.html', + domain: 'test.localhost.com:9999', + ref: null, + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['http://test.localhost:9999/integrationExamples/gpt/hello_world.html'], + canonicalUrl: null + }, + start: 1615205942162 + }; let response = { id: '5bdbab92aae961cfbdf7465d', @@ -213,7 +355,52 @@ describe('iqmAdapter', function () { let validBidRequests_temp_video = [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: 'cd86c3ff-d630-40e6-83ab-420e9e800594'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '8335b266-7a41-45f9-86a2-92fdc7cf0cd9', sizes: [[640, 480]], bidId: '26274beff25455', bidderRequestId: '17c5d8c3168761', auctionId: '2c592dcf-7dfc-4823-8203-dd1ebab77fe0', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}]; - let bidderRequest_video = {bidderCode: 'iqm', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', bidderRequestId: '16e1ce8481bc6d', bids: [{bidder: 'iqm', params: {publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', placementId: 23451, bidfloor: 0.5, video: {placement: 2, mimes: ['video/mp4'], protocols: [2, 5], skipppable: true, playback_method: ['auto_play_sound_off']}}, crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, fpd: {context: {pbAdSlot: 'video1'}}, mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, adUnitCode: 'video1', transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', sizes: [[640, 480]], bidId: '28bfb7e2d12897', bidderRequestId: '16e1ce8481bc6d', auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', src: 'client', bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0}], auctionStart: 1615271191985, timeout: 3000, refererInfo: {referer: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html', reachedTop: true, isAmp: false, numIframes: 0, stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'], canonicalUrl: null}, start: 1615271191988}; + let bidderRequest_video = { + bidderCode: 'iqm', + auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', + bidderRequestId: '16e1ce8481bc6d', + bids: [{ + bidder: 'iqm', + params: { + publisherId: 'df5fd732-c5f3-11e7-abc4-cec278b6b50a', + placementId: 23451, + bidfloor: 0.5, + video: { + placement: 2, + mimes: ['video/mp4'], + protocols: [2, 5], + skipppable: true, + playback_method: ['auto_play_sound_off'] + } + }, + crumbs: {pubcid: '09b8f065-9d1b-4a36-bd0c-ea22e2dad807'}, + ortb2Imp: {ext: {data: {'pbadslot': 'video1'}}}, + mediaTypes: {video: {playerSize: [[640, 480]], context: 'instream'}}, + adUnitCode: 'video1', + transactionId: '86795c66-acf9-4dd5-998f-6d5362aaa541', + sizes: [[640, 480]], + bidId: '28bfb7e2d12897', + bidderRequestId: '16e1ce8481bc6d', + auctionId: '3140a2ec-d567-4db0-9bbb-eb6fa20ccb71', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }], + auctionStart: 1615271191985, + timeout: 3000, + refererInfo: { + page: 'http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html', + domain: 'test.localhost.com:9999', + ref: '', + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['http://test.localhost:9999/integrationExamples/gpt/pbjs_video_adUnit.html'], + canonicalUrl: null + }, + start: 1615271191988 + }; it('handles non-banner media responses', function () { let response = {id: '2341234', seatbid: [{bid: [{id: 'bid-2341234-1', impid: '1', price: 9, nurl: 'https://frontend.stage.iqm.com/static/vast-01.xml', adm: 'http://cdn.iqm.com/pbd?raw=312730_203cf73dc83fb_2824348636878_pbd', adomain: ['app1.stage.iqm.com'], cid: '168900', crid: 'cr-304503', attr: []}]}], bidid: '2341234'}; diff --git a/test/spec/modules/iqzoneBidAdapter_spec.js b/test/spec/modules/iqzoneBidAdapter_spec.js index de0459f4714..2e920d3b769 100644 --- a/test/spec/modules/iqzoneBidAdapter_spec.js +++ b/test/spec/modules/iqzoneBidAdapter_spec.js @@ -76,7 +76,8 @@ describe('IQZoneBidAdapter', function () { gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', refererInfo: { referer: 'https://test.com' - } + }, + timeout: 500 }; describe('isBidRequestValid', function () { diff --git a/test/spec/modules/ivsBidAdapter_spec.js b/test/spec/modules/ivsBidAdapter_spec.js new file mode 100644 index 00000000000..819c7480595 --- /dev/null +++ b/test/spec/modules/ivsBidAdapter_spec.js @@ -0,0 +1,195 @@ +import { spec, converter } from 'modules/ivsBidAdapter.js'; +import { assert } from 'chai'; +import { deepClone } from '../../../src/utils'; + +describe('ivsBidAdapter', function () { + describe('isBidRequestValid()', function () { + let validBid = { + bidder: 'ivs', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4'] + } + }, + params: { + bidderDomain: 'https://www.example.com', + publisherId: '3001234' + } + }; + + it('should return true for a valid bid', function () { + assert.isTrue(spec.isBidRequestValid(validBid)); + }); + + it('should return false if publisherId info is missing', function () { + let bid = deepClone(validBid); + delete bid.params.publisherId; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + + it('should return false for empty video parameters', function () { + let bid = deepClone(validBid); + delete bid.mediaTypes.video; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + + it('should return false for non instream context', function () { + let bid = deepClone(validBid); + bid.mediaTypes.video.context = 'outstream'; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests()', function () { + let validBidRequests, validBidderRequest; + + beforeEach(function () { + validBidRequests = [{ + bidder: 'ivs', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4'] + }, + adUnitCode: 'video1', + transactionId: '1f420478-a3cd-452d-8e33-ac851e7bfba6', + bidId: '2d986cea00fd01', + bidderRequestId: '1022d594d79bf5', + auctionId: '835eacc9-cfe7-4fa2-8738-ab4b5c4f26d2' + }, + params: { + bidderDomain: 'https://www.example.com', + publisherId: '3001234' + } + }]; + + validBidderRequest = { + bidderCode: 'ivs', + auctionId: '409bd13d-d0be-43c4-9c4f-e6f81ecff475', + bidderRequestId: '17bfe74bd98e68', + refererInfo: { + domain: 'example.com', + page: 'https://www.example.com/test.html', + }, + bids: [{ + bidder: 'ivs', + params: { + publisherId: '3001234' + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480]], + mimes: ['video/mp4'] + } + }, + adUnitCode: 'video1', + transactionId: '91b1977f-d05c-45c3-af1f-69b4e7d11e86', + sizes: [ + [640, 480] + ], + }], + ortb2: { + site: { + publisher: { + domain: 'example.com', + } + } + } + }; + }); + + it('should return a validate bid request', function () { + const bidRequest = spec.buildRequests(validBidRequests, validBidderRequest); + assert.equal(bidRequest.method, 'POST'); + assert.deepEqual(bidRequest.options, { contentType: 'application/json' }); + assert.ok(bidRequest.data); + }); + + it('should contain the required parameters', function () { + const bidRequest = spec.buildRequests(validBidRequests, validBidderRequest); + const bidderRequest = bidRequest.data; + assert.ok(bidderRequest.site); + assert.lengthOf(bidderRequest.imp, 1); + }); + }); + + describe('interpretResponse()', function () { + let serverResponse, bidderRequest, request; + + beforeEach(function () { + serverResponse = { + body: { + id: '635ba1ed-68ba-47b4-bcec-4a86565f25f9', + seatbid: [{ + bid: [{ + crid: 3715, + id: 'bca9823d-ca7a-4dac-b292-0e1fae5948f8', + impid: '200d1ca23b15a6', + price: 1.5, + nurl: 'https://a.ivstracker.net/dev/getvastxml?ad_creativeid=3715&domain=localhost%3A9999&ip=136.158.51.114&pageurl=http%3A%2F%2Flocalhost%3A9999%2Ftest%2Fpages%2Fivs.html&spid=3001234&adplacement=&brand=unknown&device=desktop&adsclientid=A45-fd46289e-dc60-4be2-a637-4bc8eb953ddf&clientid=3b5e435f-0351-4ba0-bd2d-8d6f3454c5ed&uastring=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F109.0.0.0%20Safari%2F537.36' + }] + }], + cur: 'USD' + }, + headers: {} + }; + + bidderRequest = { + bidderCode: 'ivs', + auctionId: '635ba1ed-68ba-47b4-bcec-4a86565f25f9', + bidderRequestId: '1def3e1d03f5a', + bids: [{ + bidder: 'ivs', + params: { + publisherId: '3001234' + }, + mediaTypes: { + video: { + context: 'instream', + playerSize: [ + [640, 480] + ], + mimes: ['video/mp4'] + } + }, + adUnitCode: 'video1', + transactionId: '89e5a3e7-df30-4ed6-a130-edfa91941e67', + bidId: '200d1ca23b15a6', + bidderRequestId: '1def3e1d03f5a', + auctionId: '635ba1ed-68ba-47b4-bcec-4a86565f25f9' + }], + }; + + request = { data: converter.toORTB({ bidderRequest }) }; + }); + + if (FEATURES.VIDEO) { + it('should match parsed server response', function () { + const results = spec.interpretResponse(serverResponse, request); + const expected = { + mediaType: 'video', + playerWidth: 640, + playerHeight: 480, + vastUrl: 'https://a.ivstracker.net/dev/getvastxml?ad_creativeid=3715&domain=localhost%3A9999&ip=136.158.51.114&pageurl=http%3A%2F%2Flocalhost%3A9999%2Ftest%2Fpages%2Fivs.html&spid=3001234&adplacement=&brand=unknown&device=desktop&adsclientid=A45-fd46289e-dc60-4be2-a637-4bc8eb953ddf&clientid=3b5e435f-0351-4ba0-bd2d-8d6f3454c5ed&uastring=Mozilla%2F5.0%20(Macintosh%3B%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F109.0.0.0%20Safari%2F537.36', + requestId: '200d1ca23b15a6', + seatBidId: 'bca9823d-ca7a-4dac-b292-0e1fae5948f8', + cpm: 1.5, + currency: 'USD', + creativeId: 3715, + ttl: 360, + }; + + expect(results.length).to.equal(1); + sinon.assert.match(results[0], expected); + }); + } + + it('should return empty when no response', function () { + assert.ok(!spec.interpretResponse({}, request)); + }); + }); +}); diff --git a/test/spec/modules/ixBidAdapter_spec.js b/test/spec/modules/ixBidAdapter_spec.js index 0e1a854b67c..853215d95ad 100644 --- a/test/spec/modules/ixBidAdapter_spec.js +++ b/test/spec/modules/ixBidAdapter_spec.js @@ -2,14 +2,13 @@ import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; import { expect } from 'chai'; import { newBidder } from 'src/adapters/bidderFactory.js'; -import { spec, storage, ERROR_CODES } from '../../../modules/ixBidAdapter.js'; -import { createEidsArray } from 'modules/userId/eids.js'; -import { deepAccess } from '../../../src/utils.js'; +import { spec, storage, ERROR_CODES, FEATURE_TOGGLES, LOCAL_STORAGE_FEATURE_TOGGLES_KEY, REQUESTED_FEATURE_TOGGLES, combineImps, bidToVideoImp, bidToNativeImp, deduplicateImpExtFields, removeSiteIDs, addDeviceInfo } from '../../../modules/ixBidAdapter.js'; +import { deepAccess, deepClone } from '../../../src/utils.js'; describe('IndexexchangeAdapter', function () { - const IX_SECURE_ENDPOINT = 'https://htlb.casalemedia.com/cygnus'; - const VIDEO_ENDPOINT_VERSION = 8.1; - const BANNER_ENDPOINT_VERSION = 7.2; + const IX_SECURE_ENDPOINT = 'https://htlb.casalemedia.com/openrtb/pbjs'; + + FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES = ['test1', 'test2']; const SAMPLE_SCHAIN = { 'ver': '1.0', @@ -120,6 +119,11 @@ describe('IndexexchangeAdapter', function () { playerSize: [[400, 100]] } }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47230' + } + }, adUnitCode: 'div-gpt-ad-1460505748562-0', transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', bidId: '1a2b3c4e', @@ -142,6 +146,11 @@ describe('IndexexchangeAdapter', function () { sizes: [[300, 250]] } }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47229' + } + }, adUnitCode: 'div-gpt-ad-1460505748561-0', transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229', bidId: '1a2b3c4d', @@ -161,7 +170,13 @@ describe('IndexexchangeAdapter', function () { sizes: [[300, 250], [300, 600]], mediaTypes: { banner: { - sizes: [[300, 250], [300, 600]] + sizes: [[300, 250], [300, 600]], + pos: 0 + } + }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47229' } }, adUnitCode: 'div-gpt-ad-1460505748561-0', @@ -184,6 +199,11 @@ describe('IndexexchangeAdapter', function () { sizes: [[300, 250], [300, 600]] } }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47229' + } + }, adUnitCode: 'div-gpt-ad-1460505748561-0', transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229', bidId: '1a2b3c4d', @@ -193,6 +213,40 @@ describe('IndexexchangeAdapter', function () { } ]; + const DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS = [ + { + bidder: 'ix', + params: { + siteId: '456' + }, + sizes: [400, 100], + mediaTypes: { + video: { + context: 'instream', + playerSize: [[400, 100]], + mimes: [ + 'video/mp4', + 'video/webm' + ], + minduration: 0, + maxduration: 60, + protocols: [2] + } + }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47230' + } + }, + adUnitCode: 'div-gpt-ad-1460505748562-0', + transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', + bidId: '1a2b3c4e', + bidderRequestId: '11a22b33c44e', + auctionId: '1aa2bb3cc4de', + schain: SAMPLE_SCHAIN + } + ]; + const DEFAULT_VIDEO_VALID_BID = [ { bidder: 'ix', @@ -217,6 +271,49 @@ describe('IndexexchangeAdapter', function () { playerSize: [[400, 100], [200, 400]] } }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47230' + } + }, + adUnitCode: 'div-gpt-ad-1460505748562-0', + transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', + bidId: '1a2b3c4e', + bidderRequestId: '11a22b33c44e', + auctionId: '1aa2bb3cc4de', + schain: SAMPLE_SCHAIN + } + ]; + + const DEFAULT_VIDEO_VALID_BID_MEDIUM_SIZE = [ + { + bidder: 'ix', + params: { + siteId: '456', + video: { + skippable: false, + mimes: [ + 'video/mp4', + 'video/webm' + ], + minduration: 0, + maxduration: 60, + protocols: [2] + }, + size: [640, 480] + }, + sizes: [[640, 480], [200, 400]], + mediaTypes: { + video: { + context: 'instream', + playerSize: [[640, 480], [200, 400]] + } + }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47230' + } + }, adUnitCode: 'div-gpt-ad-1460505748562-0', transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', bidId: '1a2b3c4e', @@ -230,18 +327,27 @@ describe('IndexexchangeAdapter', function () { { bidder: 'ix', params: { + tagId: '123', siteId: '123', size: [300, 250], }, mediaTypes: { video: { context: 'outstream', - playerSize: [600, 700] + playerSize: [[600, 700]] }, banner: { sizes: [[300, 250], [300, 600], [400, 500]] } }, + ortb2Imp: { + ext: { + tid: '173f49a8-7549-4218-a23c-e7ba59b47230', + data: { + pbadslot: 'div-gpt-ad-1460505748562-0' + } + } + }, adUnitCode: 'div-gpt-ad-1460505748562-0', transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', bidId: '1a2b3c4e', @@ -255,6 +361,7 @@ describe('IndexexchangeAdapter', function () { { bidder: 'ix', params: { + tagId: '123', siteId: '456', video: { skippable: false, @@ -271,12 +378,92 @@ describe('IndexexchangeAdapter', function () { mediaTypes: { video: { context: 'outstream', - playerSize: [300, 250] + playerSize: [[300, 250]] + }, + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + ortb2Imp: { + ext: { + tid: '273f49a8-7549-4218-a23c-e7ba59b47230', + data: { + pbadslot: 'div-gpt-ad-1460505748562-1' + } + } + }, + adUnitCode: 'div-gpt-ad-1460505748562-1', + transactionId: '273f49a8-7549-4218-a23c-e7ba59b47230', + bidId: '1a2b3c4e', + bidderRequestId: '11a22b33c44e', + auctionId: '1aa2bb3cc4de', + schain: SAMPLE_SCHAIN + } + ]; + + const DEFAULT_MULTIFORMAT_VALID_BID = [ + { + bidder: 'ix', + params: { + tagId: '123', + siteId: '456', + video: { + siteId: '1111' + }, + banner: { + siteId: '2222' + }, + native: { + siteId: '3333' + }, + size: [300, 250] + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[300, 250]], + skippable: false, + mimes: [ + 'video/mp4', + 'video/webm' + ], + minduration: 0, + maxduration: 60, + protocols: [1] }, banner: { sizes: [[300, 250], [300, 600]] + }, + native: { + icon: { + required: false + }, + title: { + len: 25, + required: true + }, + body: { + required: true + }, + image: { + required: true + }, + sponsoredBy: { + required: true + } } }, + ortb2Imp: { + ext: { + tid: '273f49a8-7549-4218-a23c-e7ba59b47230', + data: { + pbadslot: 'div-gpt-ad-1460505748562-0' + } + } + }, + nativeOrtbRequest: { + assets: [{id: 0, required: 0, img: {type: 1}}, {id: 1, required: 1, title: {len: 140}}, {id: 2, required: 1, data: {type: 2}}, {id: 3, required: 1, img: {type: 3}}, {id: 4, required: false, video: {mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6]}}] + }, adUnitCode: 'div-gpt-ad-1460505748562-0', transactionId: '273f49a8-7549-4218-a23c-e7ba59b47230', bidId: '1a2b3c4e', @@ -286,6 +473,99 @@ describe('IndexexchangeAdapter', function () { } ]; + const DEFAULT_NATIVE_VALID_BID = [ + { + bidder: 'ix', + params: { + siteId: '123', + size: [300, 250] + }, + sizes: [[300, 250], [300, 600]], + mediaTypes: { + native: { + icon: { + required: false + }, + title: { + len: 25, + required: true + }, + body: { + required: true + }, + image: { + required: true + }, + video: { + required: false, + mimes: ['video/mp4', 'video/webm'], + minduration: 0, + maxduration: 120, + protocols: [2, 3, 5, 6] + }, + sponsoredBy: { + required: true + } + } + }, + nativeOrtbRequest: { + assets: [{ id: 0, required: 0, img: { type: 1 } }, { id: 1, required: 1, title: { len: 140 } }, { id: 2, required: 1, data: { type: 2 } }, { id: 3, required: 1, img: { type: 3 } }, { id: 4, required: false, video: { mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6] } }] + }, + adUnitCode: 'div-gpt-ad-1460505748563-0', + transactionId: '173f49a8-7549-4218-a23c-e7ba59b47231', + bidId: '1a2b3c4f', + bidderRequestId: '11a22b33c44f', + auctionId: '1aa2bb3cc4df', + schain: SAMPLE_SCHAIN + } + ]; + + const DEFAULT_MULTIFORMAT_NATIVE_VALID_BID = [ + { + bidder: 'ix', + params: { + siteId: '123', + size: [300, 250], + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600], [400, 500]] + }, + native: { + title: { + required: true + }, + body: { + required: true + }, + image: { + required: true + }, + sponsoredBy: { + required: true + }, + icon: { + required: false + } + } + }, + nativeOrtbRequest: { + assets: [{ id: 0, required: 0, img: { type: 1 } }, { id: 1, required: 1, title: { len: 140 } }, { id: 2, required: 1, data: { type: 2 } }, { id: 3, required: 1, img: { type: 3 } }, { id: 4, required: false, video: { mimes: ['video/mp4', 'video/webm'], minduration: 0, maxduration: 120, protocols: [2, 3, 5, 6] } }] + }, + adUnitCode: 'div-gpt-ad-1460505748562-0', + transactionId: '173f49a8-7549-4218-a23c-e7ba59b47230', + bidId: '1a2b3c4e', + bidderRequestId: '11a22b33c44e', + auctionId: '1aa2bb3cc4de', + schain: SAMPLE_SCHAIN + } + ]; + + const DEFAULT_NATIVE_IMP = { + request: '{"assets":[{"id":0,"required":0,"img":{"type":1}},{"id":1,"required":1,"title":{"len":140}},{"id":2,"required":1,"data":{"type":2}},{"id":3,"required":1,"img":{"type":3}},{"id":4,"required":false,"video":{"mimes":["video/mp4","video/webm"],"minduration":0,"maxduration":120,"protocols":[2,3,5,6]}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', + ver: '1.2' + } + const DEFAULT_BANNER_BID_RESPONSE = { cur: 'USD', id: '11a22b33c44d', @@ -371,10 +651,13 @@ describe('IndexexchangeAdapter', function () { ], seat: '3971' } - ] + ], + ext: { + videoplayerurl: 'https://test.com/video-renderer.js' + } }; - const DEFAULT_VIDEO_BID_RESPONSE_WITH_MTYPE_SET = { + const DEFAULT_VIDEO_BID_RESPONSE_WITH_XML_ADM = { cur: 'USD', id: '1aa2bb3cc4de', seatbid: [ @@ -391,7 +674,6 @@ describe('IndexexchangeAdapter', function () { mtype: 2, adm: ' Test In-Stream Video blah"}}],"link":{"url":"https://play.google.com/store/apps/details?id=de.autodoc.gmbh","clicktrackers":["https://click.liftoff.io/v1/campaign_click/blah"]},"eventtrackers":[{"event":1,"method":1,"url":"https://impression-europe.liftoff.io/index/impression"},{"event":1,"method":1,"url":"https://a701.casalemedia.com/impression/v1"}],"privacy":"https://privacy.link.com"}}' + } + ], + seat: '3970' + } + ] + }; + const DEFAULT_OPTION = { gdprConsent: { gdprApplies: true, @@ -412,8 +722,16 @@ describe('IndexexchangeAdapter', function () { vendorData: {} }, refererInfo: { - referer: 'https://www.prebid.org', + page: 'https://www.prebid.org', canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' + }, + ortb2: { + site: { + page: 'https://www.prebid.org' + }, + source: { + tid: 'mock-tid' + } } }; @@ -431,31 +749,6 @@ describe('IndexexchangeAdapter', function () { } }; - const DEFAULT_BIDDER_REQUEST_DATA = { - ac: 'j', - r: JSON.stringify({ - id: '345', - imp: [ - { - id: '1a2b3c4e', - video: { - w: 640, - h: 480, - placement: 1 - } - } - ], - site: { - ref: 'https://ref.com/ref.html', - page: 'https://page.com' - }, - }), - s: '21', - sd: 1, - t: 1000, - v: 8.1 - }; - const DEFAULT_USERID_DATA = { idl_env: '1234-5678-9012-3456', // Liveramp netId: 'testnetid123', // NetId @@ -464,11 +757,12 @@ describe('IndexexchangeAdapter', function () { // so structured because when calling createEidsArray, UID2's getValue func takes .id to set in uids uid2: { id: 'testuid2' }, // UID 2.0 // similar to uid2, but id5's getValue takes .uid - id5id: { uid: 'testid5id' } // ID5 + id5id: { uid: 'testid5id' }, // ID5 + imuid: 'testimuid', + '33acrossId': { envelope: 'v1.5fs.1000.fjdiosmclds' }, + pairId: {envelope: 'testpairId'} }; - const DEFAULT_USERIDASEIDS_DATA = createEidsArray(DEFAULT_USERID_DATA); - const DEFAULT_USERID_PAYLOAD = [ { source: 'liveramp.com', @@ -515,26 +809,31 @@ describe('IndexexchangeAdapter', function () { uids: [{ id: DEFAULT_USERID_DATA.id5id.uid }] + }, { + source: 'intimatemerger.com', + uids: [{ + id: DEFAULT_USERID_DATA.imuid + }] + }, { + source: '33across.com', + uids: [{ + id: DEFAULT_USERID_DATA['33acrossId'].envelope + }] + }, { + source: 'google.com', + uids: [{ + id: DEFAULT_USERID_DATA['pairId'].envelope + }] } ]; + const DEFAULT_USERIDASEIDS_DATA = DEFAULT_USERID_PAYLOAD; + const DEFAULT_USERID_BID_DATA = { - lotamePanoramaId: 'bd738d136bdaa841117fe9b331bb4', - flocId: { id: '1234', version: 'chrome.1.2' } + lotamePanoramaId: 'bd738d136bdaa841117fe9b331bb4' }; - const DEFAULT_FLOC_USERID_PAYLOAD = [ - { - source: 'chrome.com', - uids: [{ - id: DEFAULT_USERID_BID_DATA.flocId.id, - ext: { - rtiPartner: 'flocId', - ver: DEFAULT_USERID_BID_DATA.flocId.version - } - }] - } - ]; + const extractPayload = function (bidRequest) { return bidRequest.data } describe('inherited functions', function () { it('should exists and is a function', function () { @@ -544,33 +843,169 @@ describe('IndexexchangeAdapter', function () { }); describe('getUserSync tests', function () { + before(() => { + // TODO (dgirardi): the assertions in this block rely on + // global state (consent and siteId) set up in the SOT + // this is an outsider's attempt to recreate that state more explicitly after shuffling around setup code + // in this test suite + + // please make your preconditions explicit; + // also, please, avoid global state if possible. + + spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); + }) + it('UserSync test : check type = iframe, check usermatch URL', function () { const syncOptions = { 'iframeEnabled': true } - let userSync = spec.getUserSyncs(syncOptions); + let userSync = spec.getUserSyncs(syncOptions, []); expect(userSync[0].type).to.equal('iframe'); const USER_SYNC_URL = 'https://js-sec.indexww.com/um/ixmatch.html'; expect(userSync[0].url).to.equal(USER_SYNC_URL); }); - it('When iframeEnabled is false, no userSync should be returned', function () { + it('When iframeEnabled = false, default to img', function () { const syncOptions = { - 'iframeEnabled': false + 'iframeEnabled': false, } - let userSync = spec.getUserSyncs(syncOptions); - expect(userSync).to.be.an('array').that.is.empty; - }); - }); - - describe('isBidRequestValid', function () { - it('should return true when required params found for a banner or video ad', function () { - expect(spec.isBidRequestValid(DEFAULT_BANNER_VALID_BID[0])).to.equal(true); - expect(spec.isBidRequestValid(DEFAULT_VIDEO_VALID_BID[0])).to.equal(true); + let userSync = spec.getUserSyncs(syncOptions, []); + expect(userSync[0].type).to.equal('image'); + const USER_SYNC_URL = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=1&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + expect(userSync[0].url).to.equal(USER_SYNC_URL); }); - it('should return true when optional bidFloor params found for an ad', function () { - const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + it('UserSync test : check type = pixel, check usermatch URL, no exchange data, only drop 1', function () { + const syncOptions = { + 'pixelEnabled': true + } + config.setConfig({ + userSync: { + pixelEnabled: true, + syncsPerBidder: 3 + } + }) + let userSync = spec.getUserSyncs(syncOptions, []); + expect(userSync[0].type).to.equal('image'); + const USER_SYNC_URL = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=1&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + expect(userSync[0].url).to.equal(USER_SYNC_URL); + }); + + it('UserSync test : check type = pixel, check usermatch URL with override set to 0', function () { + const syncOptions = { + 'pixelEnabled': true + } + config.setConfig({ + userSync: { + pixelEnabled: true, + syncsPerBidder: 3 + } + }); + let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 0 } } }]); + expect(userSync.length).to.equal(0); + }); + + it('UserSync test : check type = pixel, check usermatch URL with override set', function () { + const syncOptions = { + 'pixelEnabled': true + } + config.setConfig({ + userSync: { + pixelEnabled: true, + syncsPerBidder: 3 + } + }); + let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 2 } } }]); + expect(userSync[0].type).to.equal('image'); + const USER_SYNC_URL_0 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + const USER_SYNC_URL_1 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=1&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + expect(userSync[0].url).to.equal(USER_SYNC_URL_0); + expect(userSync[1].url).to.equal(USER_SYNC_URL_1); + expect(userSync.length).to.equal(2); + }); + + it('UserSync test : check type = pixel, check usermatch URL with override greater than publisher syncs per bidder , use syncsperbidder', function () { + const syncOptions = { + 'pixelEnabled': true + } + config.setConfig({ + userSync: { + pixelEnabled: true, + syncsPerBidder: 3 + } + }); + let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 4 } } }]); + expect(userSync[0].type).to.equal('image'); + const USER_SYNC_URL_0 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=3&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + const USER_SYNC_URL_1 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=3&i=1&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + const USER_SYNC_URL_2 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=3&i=2&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + expect(userSync[0].url).to.equal(USER_SYNC_URL_0); + expect(userSync[1].url).to.equal(USER_SYNC_URL_1); + expect(userSync[2].url).to.equal(USER_SYNC_URL_2); + expect(userSync.length).to.equal(3); + }); + + it('UserSync test : check type = pixel, syncsPerBidder = 0, still use override', function () { + const syncOptions = { + 'pixelEnabled': true + } + config.setConfig({ + userSync: { + pixelEnabled: true, + syncsPerBidder: 0 + } + }); + let userSync = spec.getUserSyncs(syncOptions, [{ 'body': { 'ext': { 'publishersyncsperbidderoverride': 2 } } }]); + expect(userSync[0].type).to.equal('image'); + const USER_SYNC_URL_0 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=0&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + const USER_SYNC_URL_1 = 'https://dsum.casalemedia.com/pbusermatch?origin=prebid&site_id=123&p=2&i=1&gdpr=1&gdpr_consent=3huaa11=qu3198ae&us_privacy='; + expect(userSync[0].url).to.equal(USER_SYNC_URL_0); + expect(userSync[1].url).to.equal(USER_SYNC_URL_1); + expect(userSync.length).to.equal(2); + }); + }); + + describe('isBidRequestValid', function () { + it('should return false if outstream player size is less than 144x144 and IX renderer is preferred', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.mediaTypes.video.context = 'outstream'; + bid.mediaTypes.video.w = [[300, 143]]; + expect(spec.isBidRequestValid(bid)).to.equal(false); + bid.mediaTypes.video.w = [[143, 300]]; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false if outstream video w & h is less than 144x144 and IX renderer is preferred', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.mediaTypes.video.context = 'outstream'; + bid.mediaTypes.video.playerSize = [[300, 250]]; + bid.mediaTypes.video.w = 300; + bid.mediaTypes.video.h = 142; + expect(spec.isBidRequestValid(bid)).to.equal(false); + bid.mediaTypes.video.h = 300; + bid.mediaTypes.video.w = 142; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true if outstream player size is less than 300x250 and IX renderer is not preferred', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.mediaTypes.video.renderer = { + url: 'test', + render: () => { } + }; + bid.mediaTypes.video.context = 'outstream'; + bid.mediaTypes.video.playerSize = [[300, 249]]; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return true when required params found for a banner, video or native ad', function () { + expect(spec.isBidRequestValid(DEFAULT_BANNER_VALID_BID[0])).to.equal(true); + expect(spec.isBidRequestValid(DEFAULT_VIDEO_VALID_BID[0])).to.equal(true); + expect(spec.isBidRequestValid(DEFAULT_NATIVE_VALID_BID[0])).to.equal(true); + }); + + it('should return true when optional bidFloor params found for an ad', function () { + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.bidFloor = 50; bid.params.bidFloorCur = 'USD'; expect(spec.isBidRequestValid(bid)).to.equal(true); @@ -624,7 +1059,7 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.mediaTypes = { video: { - playerSize: [300, 250] + playerSize: [[300, 250]] } }; bid.params.size = [100, 200]; @@ -655,11 +1090,11 @@ describe('IndexexchangeAdapter', function () { }); it('should return false when mediaType is native', function () { - const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + const bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID[0]); delete bid.params.mediaTypes; bid.mediaType = 'native'; bid.sizes = [[300, 250]]; - expect(spec.isBidRequestValid(bid)).to.equal(false); + expect(spec.isBidRequestValid(bid)).to.equal(true); }); it('should return true when mediaType is missing and has sizes', function () { @@ -695,20 +1130,9 @@ describe('IndexexchangeAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should set bid[].renderer if renderer not defined at mediaType.video level', function () { - const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { - data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID - }); - expect(bid[0].renderer).to.be.exist; - }); - - it('should not set bid[].renderer if renderer defined at mediaType.video level', function () { - const outstreamAdUnit = DEFAULT_MULTIFORMAT_BANNER_VALID_BID; - outstreamAdUnit[0].mediaTypes.video.renderer = {} - const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { - data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID - }); - expect(bid[0].renderer).to.be.undefined; + it('shoult return true for native bid when there are multiple mediaTypes (banner, native)', function () { + const bid = utils.deepClone(DEFAULT_MULTIFORMAT_NATIVE_VALID_BID[0]); + expect(spec.isBidRequestValid(bid)).to.be.true; }); it('should return false when there is only bidFloor', function () { @@ -773,6 +1197,15 @@ describe('IndexexchangeAdapter', function () { delete bid.params.video.protocols; expect(spec.isBidRequestValid(bid)).to.equal(false); }); + + it('should fail if native openRTB object contains no valid assets', function () { + let bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID[0]); + bid.nativeOrtbRequest = {} + expect(spec.isBidRequestValid(bid)).to.be.false; + + bid.nativeOrtbRequest = { assets: [] } + expect(spec.isBidRequestValid(bid)).to.be.false; + }); }); describe('Roundel alias adapter', function () { @@ -794,10 +1227,10 @@ describe('IndexexchangeAdapter', function () { const cloneValidBid = utils.deepClone(validBid); cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); const request = spec.buildRequests(cloneValidBid, ALIAS_OPTIONS); - const payload = JSON.parse(request[0].data.r); + const payload = extractPayload(request[0]); expect(request).to.be.an('array'); expect(request).to.have.lengthOf.above(0); // should be 1 or more - expect(payload.user.eids).to.have.lengthOf(6); + expect(payload.user.eids).to.have.lengthOf(9); expect(payload.user.eids).to.deep.include(DEFAULT_USERID_PAYLOAD[0]); }); }); @@ -805,7 +1238,7 @@ describe('IndexexchangeAdapter', function () { describe('buildRequestsIdentity', function () { let request; - let query; + let payload; let testCopy; beforeEach(function () { @@ -814,7 +1247,7 @@ describe('IndexexchangeAdapter', function () { return testCopy; }; request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - query = request.data; + payload = extractPayload(request); }); afterEach(function () { @@ -827,8 +1260,6 @@ describe('IndexexchangeAdapter', function () { }); it('payload should have correct format and value (single identity partner)', function () { - const payload = JSON.parse(query.r); - expect(payload.user).to.exist; expect(payload.user.eids).to.exist; expect(payload.user.eids).to.be.an('array'); @@ -836,7 +1267,7 @@ describe('IndexexchangeAdapter', function () { }); it('identity data in impression should have correct format and value (single identity partner)', function () { - const impression = JSON.parse(query.r).user.eids; + const impression = payload.user.eids; expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source); expect(impression[0].uids[0].id).to.equal(testCopy.IdentityIp.data.uids[0].id); }); @@ -856,8 +1287,6 @@ describe('IndexexchangeAdapter', function () { }); it('payload should have correct format and value (single identity w/ multi ids)', function () { - const payload = JSON.parse(query.r); - expect(payload.user).to.exist; expect(payload.user.eids).to.exist; expect(payload.user.eids).to.be.an('array'); @@ -865,7 +1294,7 @@ describe('IndexexchangeAdapter', function () { }); it('identity data in impression should have correct format and value (single identity w/ multi ids)', function () { - const impression = JSON.parse(query.r).user.eids; + const impression = payload.user.eids; expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source); expect(impression[0].uids).to.have.lengthOf(3); @@ -900,8 +1329,6 @@ describe('IndexexchangeAdapter', function () { }); it('payload should have correct format and value (multiple identity partners)', function () { - const payload = JSON.parse(query.r); - expect(payload.user).to.exist; expect(payload.user.eids).to.exist; expect(payload.user.eids).to.be.an('array'); @@ -909,7 +1336,7 @@ describe('IndexexchangeAdapter', function () { }); it('identity data in impression should have correct format and value (multiple identity partners)', function () { - const impression = JSON.parse(query.r).user.eids; + const impression = payload.user.eids; expect(impression[0].source).to.equal(testCopy.IdentityIp.data.source); expect(impression[0].uids).to.have.lengthOf(1); @@ -932,8 +1359,7 @@ describe('IndexexchangeAdapter', function () { return undefined; }; request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - query = request.data; - const payload = JSON.parse(query.r); + payload = extractPayload(request); expect(payload.user).to.exist; expect(payload.user.eids).to.not.exist; @@ -945,8 +1371,7 @@ describe('IndexexchangeAdapter', function () { data: {} } request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - query = request.data; - const payload = JSON.parse(query.r); + payload = extractPayload(request); expect(payload.user).to.exist; expect(payload.user.eids).to.exist; @@ -955,8 +1380,7 @@ describe('IndexexchangeAdapter', function () { it('payload should not have any user eids if identity data is pending for all partners', function () { testCopy.IdentityIp.responsePending = true; request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - query = request.data; - const payload = JSON.parse(query.r); + payload = extractPayload(request); expect(payload.user).to.exist; expect(payload.user.eids).to.not.exist; @@ -966,8 +1390,7 @@ describe('IndexexchangeAdapter', function () { testCopy.IdentityIp.responsePending = false; testCopy.IdentityIp.data = {}; request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - query = request.data; - const payload = JSON.parse(query.r); + payload = extractPayload(request); expect(payload.user).to.exist; expect(payload.user.eids).to.not.exist; @@ -994,82 +1417,11 @@ describe('IndexexchangeAdapter', function () { const cloneValidBid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(6); + const payload = extractPayload(request); + expect(payload.user.eids).to.have.lengthOf(9); expect(payload.user.eids).to.have.deep.members(DEFAULT_USERID_PAYLOAD); }); - it('IX adapter reads floc id from prebid userId and adds it to eids when there is not other eids', function () { - const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); - cloneValidBid[0].userId = utils.deepClone(DEFAULT_USERID_BID_DATA); - const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(1); - expect(payload.user.eids).to.deep.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); - }); - - it('IX adapter reads floc id from prebid userId and appends it to eids', function () { - const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); - cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); - cloneValidBid[0].userId = utils.deepClone(DEFAULT_USERID_BID_DATA); - const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(7); - expect(payload.user.eids).to.deep.include.members(DEFAULT_USERID_PAYLOAD); - expect(payload.user.eids).to.deep.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); - }); - - it('IX adapter reads empty floc obj from prebid userId it, floc is not added to eids', function () { - const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); - cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); - cloneValidBid[0].userId = { 'flocId': {} } - const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(6); - expect(payload.user.eids).to.deep.include.members(DEFAULT_USERID_PAYLOAD); - expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); - }); - - it('IX adapter reads floc obj from prebid userId it version is missing, floc is not added to eids', function () { - const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); - cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); - cloneValidBid[0].userId = { 'flocId': { 'id': 'abcd' } } - const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(6); - expect(payload.user.eids).to.deep.include.members(DEFAULT_USERID_PAYLOAD); - expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); - }); - - it('IX adapter reads floc obj from prebid userId it ID is missing, floc is not added to eids', function () { - const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); - cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); - cloneValidBid[0].userId = { 'flocId': { 'version': 'chrome.a.b.c' } } - const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(6); - expect(payload.user.eids).to.deep.include.members(DEFAULT_USERID_PAYLOAD); - expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); - }); - - it('IX adapter reads floc id with empty id from prebid userId and it does not added to eids', function () { - const cloneValidBid = utils.deepClone(DEFAULT_BANNER_VALID_BID); - cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); - cloneValidBid[0].userId = { flocID: { id: '', ver: 'chrome.1.2.3' } }; - const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); - - expect(payload.user.eids).to.have.lengthOf(6); - expect(payload.user.eids).to.deep.include.members(DEFAULT_USERID_PAYLOAD); - expect(payload.user.eids).should.not.include(DEFAULT_FLOC_USERID_PAYLOAD[0]); - }); - it('We continue to send in IXL identity info and Prebid takes precedence over IXL', function () { validIdentityResponse = { AdserverOrgIp: { @@ -1161,7 +1513,7 @@ describe('IndexexchangeAdapter', function () { cloneValidBid[0].userIdAsEids = utils.deepClone(DEFAULT_USERIDASEIDS_DATA); const request = spec.buildRequests(cloneValidBid, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); + const payload = extractPayload(request); validUserIdPayload = utils.deepClone(DEFAULT_USERID_PAYLOAD); validUserIdPayload.push({ @@ -1199,7 +1551,7 @@ describe('IndexexchangeAdapter', function () { }) expect(payload.user).to.exist; - expect(payload.user.eids).to.have.lengthOf(8); + expect(payload.user.eids).to.have.lengthOf(11); expect(payload.user.eids).to.have.deep.members(validUserIdPayload); }); @@ -1240,8 +1592,8 @@ describe('IndexexchangeAdapter', function () { }] }); - const payload = JSON.parse(request.data.r); - expect(payload.user.eids).to.have.lengthOf(7); + const payload = extractPayload(request); + expect(payload.user.eids).to.have.lengthOf(10); expect(payload.user.eids).to.have.deep.members(validUserIdPayload); }); }); @@ -1263,7 +1615,7 @@ describe('IndexexchangeAdapter', function () { bid.userId = DEFAULT_USERID_BID_DATA; const request = spec.buildRequests([bid], DEFAULT_OPTION)[0]; - const r = JSON.parse(request.data.r); + const r = extractPayload(request); expect(r.ext.ixdiag.userIds).to.be.an('array'); expect(r.ext.ixdiag.userIds.should.not.include('lotamePanoramaId')); @@ -1273,101 +1625,73 @@ describe('IndexexchangeAdapter', function () { }); describe('First party data', function () { - afterEach(function () { - config.setConfig({ - ortb2: {} - }); - }); - it('should not set ixdiag.fpd value if not defined', function () { - config.setConfig({ - ortb2: {} - }); - - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; - const r = JSON.parse(request.data.r); + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2: {} })[0]; + const r = extractPayload(request); expect(r.ext.ixdiag.fpd).to.be.undefined; }); - it('should set ixdiag.fpd value if it exists using fpd', function () { - config.setConfig({ - fpd: { - site: { + it('should set ixdiag.fpd value if it exists using ortb2', function () { + const ortb2 = { + site: { + ext: { data: { pageType: 'article' } } } - }); + }; - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; - const r = JSON.parse(request.data.r); + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2 })[0]; + const r = extractPayload(request); expect(r.ext.ixdiag.fpd).to.exist; }); - it('should set ixdiag.fpd value if it exists using ortb2', function () { + it('should set ixdiag.tmax value from bidderRequest overriding global config bidderTimeout', function () { config.setConfig({ - ortb2: { - site: { - ext: { - data: { - pageType: 'article' - } - } - } - } + bidderTimeout: 250 }); - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; - const r = JSON.parse(request.data.r); + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { timeout: 1234 })[0]; + const r = extractPayload(request); - expect(r.ext.ixdiag.fpd).to.exist; + expect(r.ext.ixdiag.tmax).to.equal(1234); }); - it('should not send information that is not part of openRTB spec v2.5 using fpd', function () { + it('should not set ixdiag.tmax value if bidderTimeout is undefined', function () { config.setConfig({ - fpd: { - site: { - keywords: 'power tools, drills', - search: 'drill', - testProperty: 'test_string' - }, - user: { - keywords: ['a'], - testProperty: 'test_string' - } - } - }); + bidderTimeout: null + }) + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; + const r = extractPayload(request); + + expect(r.ext.ixdiag.tmax).to.be.undefined + }); + it('should set ixdiag.imps to number of impressions', function () { const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; - const r = JSON.parse(request.data.r); + const r = extractPayload(request); - expect(r.site.keywords).to.exist; - expect(r.site.search).to.exist; - expect(r.site.testProperty).to.be.undefined; - expect(r.user.keywords).to.exist; - expect(r.user.testProperty).to.be.undefined; + expect(r.ext.ixdiag.imps).to.equal(1); }); it('should not send information that is not part of openRTB spec v2.5 using ortb2', function () { - config.setConfig({ - ortb2: { - site: { - keywords: 'power tools, drills', - search: 'drill', - testProperty: 'test_string' - }, - user: { - keywords: ['a'], - testProperty: 'test_string' - } + const ortb2 = { + site: { + keywords: 'power tools, drills', + search: 'drill', + testProperty: 'test_string' + }, + user: { + keywords: ['a'], + testProperty: 'test_string' } - }); + }; - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; - const r = JSON.parse(request.data.r); + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2 })[0]; + const r = extractPayload(request); expect(r.site.keywords).to.exist; expect(r.site.search).to.exist; @@ -1376,62 +1700,125 @@ describe('IndexexchangeAdapter', function () { expect(r.user.testProperty).to.be.undefined; }); - it('should not add fpd data to r object if it exceeds maximum request', function () { - config.setConfig({ - ortb2: { - site: { - keywords: 'power tools, drills', - search: 'drill', - }, - user: { - keywords: Array(1000).join('#'), - } + it('should set gpp and gpp_sid field when defined', function () { + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2: {regs: {gpp: 'gpp', gpp_sid: [1]}} })[0]; + const r = extractPayload(request); + + expect(r.regs.gpp).to.equal('gpp'); + expect(r.regs.gpp_sid).to.be.an('array'); + expect(r.regs.gpp_sid).to.include(1); + }); + it('should not set gpp and gpp_sid field when not defined', function () { + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2: {regs: {}} })[0]; + const r = extractPayload(request); + + expect(r.regs).to.be.undefined; + }); + it('should not set gpp and gpp_sid field when fields arent strings or array defined', function () { + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2: {regs: {gpp: 1, gpp_sid: 'string'}} })[0]; + const r = extractPayload(request); + + expect(r.regs).to.be.undefined; + }); + it('should set gpp info from module when it exists', function () { + const options = { + gppConsent: { + gppString: 'gpp', + applicableSections: [1] } - }); + }; + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); + const r = extractPayload(request[0]); - const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); - bid.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; + expect(r.regs.gpp).to.equal('gpp'); + expect(r.regs.gpp_sid).to.be.an('array'); + expect(r.regs.gpp_sid).to.include(1); + }); + + it('should add adunit specific data to imp ext for banner', function () { + const AD_UNIT_CODE = '/19968336/some-adunit-path'; + const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID); + validBids[0].ortb2Imp = { + ext: { + data: { + adserver: { + name: 'gam banner', + adslot: AD_UNIT_CODE + } + } + } + }; + const requests = spec.buildRequests(validBids, DEFAULT_OPTION); + const imp = extractPayload(requests[0]).imp[0]; + expect(deepAccess(imp, 'ext.data.adserver.name')).to.equal('gam banner'); + expect(deepAccess(imp, 'ext.data.adserver.adslot')).to.equal(AD_UNIT_CODE); + }); - const request = spec.buildRequests([bid])[0]; - const r = JSON.parse(request.data.r); + it('should add adunit specific data to imp ext for native', function () { + const AD_UNIT_CODE = '/19968336/some-adunit-path'; + const validBids = utils.deepClone(DEFAULT_NATIVE_VALID_BID); + validBids[0].ortb2Imp = { + ext: { + data: { + adserver: { + name: 'gam native', + adslot: AD_UNIT_CODE + } + } + } + }; + const requests = spec.buildRequests(validBids, DEFAULT_OPTION); + const imp = extractPayload(requests[0]).imp[0]; + expect(deepAccess(imp, 'ext.data.adserver.name')).to.equal('gam native'); + expect(deepAccess(imp, 'ext.data.adserver.adslot')).to.equal(AD_UNIT_CODE); + }); - expect(r.site.ref).to.exist; - expect(r.site.keywords).to.be.undefined; - expect(r.user).to.be.undefined; + it('should add adunit specific data to imp ext for video', function () { + const AD_UNIT_CODE = '/19968336/some-adunit-path'; + const validBids = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + validBids[0].ortb2Imp = { + ext: { + data: { + adserver: { + name: 'gam video', + adslot: AD_UNIT_CODE + } + } + } + }; + const requests = spec.buildRequests(validBids, DEFAULT_OPTION); + const imp = extractPayload(requests[0]).imp[0]; + expect(deepAccess(imp, 'ext.data.adserver.name')).to.equal('gam video'); + expect(deepAccess(imp, 'ext.data.adserver.adslot')).to.equal(AD_UNIT_CODE); }); }); describe('buildRequests', function () { - let request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - const requestUrl = request.url; - const requestMethod = request.method; - const query = request.data; - const bidWithoutSchain = utils.deepClone(DEFAULT_BANNER_VALID_BID); delete bidWithoutSchain[0].schain; - const requestWithoutSchain = spec.buildRequests(bidWithoutSchain, DEFAULT_OPTION)[0]; - const queryWithoutSchain = requestWithoutSchain.data; const GPID = '/19968336/some-adunit-path'; + let request, requestUrl, requestMethod, payloadData, requestWithoutSchain, payloadWithoutSchain; + + before(() => { + request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; + requestUrl = request.url; + requestMethod = request.method; + payloadData = request.data; + requestWithoutSchain = spec.buildRequests(bidWithoutSchain, DEFAULT_OPTION)[0]; + payloadWithoutSchain = extractPayload(requestWithoutSchain); + }); - it('request should be made to IX endpoint with GET method', function () { - expect(requestMethod).to.equal('GET'); - expect(requestUrl).to.equal(IX_SECURE_ENDPOINT); + it('request should be made to IX endpoint with POST method and siteId in query param', function () { + expect(requestMethod).to.equal('POST'); + expect(requestUrl).to.equal(IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId); + expect(request.option.contentType).to.equal('text/plain') }); it('auction type should be set correctly', function () { - const at = JSON.parse(query.r).at; + const at = payloadData.at; expect(at).to.equal(1); }) - it('query object (version, siteID and request) should be correct', function () { - expect(query.v).to.equal(BANNER_ENDPOINT_VERSION); - expect(query.s).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); - expect(query.r).to.exist; - expect(query.ac).to.equal('j'); - expect(query.sd).to.equal(1); - expect(query.nf).not.to.exist; - }); - it('should send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot exists', function () { const AD_UNIT_CODE = '/19968336/some-adunit-path'; const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID); @@ -1446,7 +1833,7 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const { ext: { dfp_ad_unit_code } } = JSON.parse(requests[0].data.r).imp[0]; + const { ext: { dfp_ad_unit_code } } = extractPayload(requests[0]).imp[0]; expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE); }); @@ -1458,7 +1845,7 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0]; + const { ext: { gpid } } = extractPayload(requests[0]).imp[0]; expect(gpid).to.equal(GPID); }); @@ -1470,7 +1857,7 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0]; + const { ext: { gpid } } = extractPayload(requests[0]).imp[0]; expect(gpid).to.equal(GPID); }); @@ -1483,7 +1870,7 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const imp = JSON.parse(requests[0].data.r).imp[0]; + const imp = extractPayload(requests[0]).imp[0]; expect(deepAccess(imp, 'ext.dfp_ad_unit_code')).to.not.exist; }); @@ -1501,7 +1888,7 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const imp = JSON.parse(requests[0].data.r).imp[0]; + const imp = extractPayload(requests[0]).imp[0]; expect(deepAccess(imp, 'ext.gpid')).to.not.exist; }); @@ -1521,29 +1908,22 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const imp = JSON.parse(requests[0].data.r).imp[0]; + const imp = extractPayload(requests[0]).imp[0]; expect(deepAccess(imp, 'ext.gpid')).to.equal(GPID); expect(deepAccess(imp, 'ext.dfp_ad_unit_code')).to.equal(AD_UNIT_CODE); }); it('payload should have correct format and value', function () { - const payload = JSON.parse(query.r); + const payload = payloadData; expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId); expect(payload.id).to.be.a('string'); - expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.referer); + expect(payload.site.page).to.equal(DEFAULT_OPTION.refererInfo.page); expect(payload.site.ref).to.equal(document.referrer); expect(payload.ext.source).to.equal('prebid'); expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN); expect(payload.imp).to.be.an('array'); expect(payload.imp).to.have.lengthOf(1); - }); - - it('payload should set site.page to pageUrl when it exists in config object', function () { - const url = 'https://example.com/index.html'; - config.setConfig({ pageUrl: url }); - const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0].data; - const payload = JSON.parse(request.r); - expect(payload.site.page).to.contains(url); + expect(payload.source.tid).to.equal(DEFAULT_OPTION.ortb2.source.tid); }); it('payload should have correct format and value for r.id when bidderRequestId is a number ', function () { @@ -1552,7 +1932,7 @@ describe('IndexexchangeAdapter', function () { request = spec.buildRequests(bidWithIntId, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); + const payload = extractPayload(request); expect(bidWithIntId[0].bidderRequestId).to.be.a('number'); expect(payload.id).to.equal(bidWithIntId[0].bidderRequestId.toString()); expect(payload.id).to.be.a('string'); @@ -1564,32 +1944,36 @@ describe('IndexexchangeAdapter', function () { request = spec.buildRequests(bidWithIntId, DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); + const payload = extractPayload(request); expect(bidWithIntId[0].bidderRequestId).to.be.a('number'); expect(payload.id).to.equal(bidWithIntId[0].bidderRequestId.toString()); expect(payload.id).to.be.a('string'); }); it('payload should not include schain when not provided', function () { - const payload = JSON.parse(queryWithoutSchain.r); - expect(payload.source).to.not.exist; // source object currently only written for schain + const payload = payloadWithoutSchain; + + const actualSchain = (((payload || {}).source || {}).ext || {}).schain; + expect(actualSchain).to.not.exist; }); it('impression should have correct format and value', function () { - const impression = JSON.parse(query.r).imp[0]; + const impression = payloadData.imp[0]; + const sidValue = DEFAULT_BANNER_VALID_BID[0].params.id; expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); expect(impression.banner.format).to.be.length(2); expect(impression.banner.topframe).to.be.oneOf([0, 1]); + expect(impression.banner.pos).to.equal(0); + expect(impression.ext.tid).to.equal(DEFAULT_BANNER_VALID_BID[0].transactionId); + expect(impression.ext.sid).to.equal(sidValue); impression.banner.format.map(({ w, h, ext }, index) => { const size = DEFAULT_BANNER_VALID_BID[0].mediaTypes.banner.sizes[index]; - const sidValue = utils.parseGPTSingleSizeArray(size); expect(w).to.equal(size[0]); expect(h).to.equal(size[1]); expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); - expect(ext.sid).to.equal(sidValue); }); }); @@ -1599,12 +1983,43 @@ describe('IndexexchangeAdapter', function () { request = spec.buildRequests([bid], DEFAULT_OPTION)[0]; - const payload = JSON.parse(request.data.r); + const payload = extractPayload(request); payload.imp[0].banner.format.forEach((imp) => { expect(imp.ext.siteID).to.be.a('string'); }); }); + it('multi-configured size params should have the correct imp[].banner.format[].ext.siteID', function () { + const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + const bid2 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid1.params.siteId = 1234; + bid1.bidId = '27fc897708d826'; + bid2.params.siteId = 4321; + bid2.bidId = '34df030c33dc68'; + bid2.params.size = [300, 600]; + request = spec.buildRequests([bid1, bid2], DEFAULT_OPTION)[0]; + + const payload = extractPayload(request); + expect(payload.imp[0].banner.format[0].ext.siteID).to.equal('1234'); + expect(payload.imp[0].banner.format[1].ext.siteID).to.equal('4321'); + }); + + it('multi-configured size params should be added to the imp[].banner.format[] array', function () { + const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + const bid2 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid1.params.siteId = 1234; + bid1.bidId = '27fc897708d826'; + bid2.params.siteId = 4321; + bid2.bidId = '34df030c33dc68'; + bid2.params.size = [300, 600]; + request = spec.buildRequests([bid1, bid2], DEFAULT_OPTION)[0]; + + const payload = extractPayload(request); + expect(payload.imp[0].banner.format.length).to.equal(2); + expect(`${payload.imp[0].banner.format[0].w}x${payload.imp[0].banner.format[0].h}`).to.equal('300x250'); + expect(`${payload.imp[0].banner.format[1].w}x${payload.imp[0].banner.format[1].h}`).to.equal('300x600'); + }); + describe('build requests with price floors', () => { const highFloor = 4.5; const lowFloor = 3.5; @@ -1614,8 +2029,8 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(ONE_VIDEO[0]); const expectedFloor = 3.25; bid.getFloor = () => ({ floor: expectedFloor, currency }); - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.bidfloor).to.equal(expectedFloor); expect(impression.bidfloorcur).to.equal(currency); @@ -1626,8 +2041,8 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]) const expectedFloor = 3.25; bid.getFloor = () => ({ floor: expectedFloor, currency }); - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.bidfloor).to.equal(expectedFloor); expect(impression.bidfloorcur).to.equal(currency); @@ -1638,8 +2053,8 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(ONE_BANNER[0]); bid.params.bidFloor = highFloor; bid.params.bidFloorCur = 'USD' - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.bidfloor).to.equal(highFloor); expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur); @@ -1652,8 +2067,8 @@ describe('IndexexchangeAdapter', function () { bid.params.bidFloorCur = 'USD'; const expectedFloor = highFloor; bid.getFloor = () => ({ floor: expectedFloor, currency }); - const requestBidFloor = spec.buildRequests([bid])[0]; - const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const requestBidFloor = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(requestBidFloor).imp[0]; expect(impression.bidfloor).to.equal(highFloor); expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur); @@ -1664,14 +2079,26 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.bidFloor = 50; bid.params.bidFloorCur = 'USD'; - const requestBidFloor = spec.buildRequests([bid])[0]; - const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const requestBidFloor = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(requestBidFloor).imp[0]; expect(impression.bidfloor).to.equal(bid.params.bidFloor); expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur); expect(impression.banner.format[0].ext.fl).to.equal('x'); }); + it('banner multi size impression should have bidFloor both in imp and format ext obejcts', function () { + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid.params.bidFloor = 50; + bid.params.bidFloorCur = 'USD'; + const requestBidFloor = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(requestBidFloor).imp[0]; + + expect(impression.bidfloor).to.equal(bid.params.bidFloor); + expect(impression.bidfloorcur).to.equal(bid.params.bidFloorCur); + expect(impression.banner.format[0].ext.bidfloor).to.equal(50); + }); + it('missing sizes impressions should contain floors from priceFloors module ', function () { const bid = utils.deepClone(ONE_BANNER[0]); bid.mediaTypes.banner.sizes.push([500, 400]) @@ -1681,7 +2108,7 @@ describe('IndexexchangeAdapter', function () { sinon.spy(bid, 'getFloor'); - const requestBidFloor = spec.buildRequests([bid])[0]; + const requestBidFloor = spec.buildRequests([bid], {})[0]; expect(bid.getFloor.getCall(0).args[0].mediaType).to.equal('banner'); expect(bid.getFloor.getCall(0).args[0].size[0]).to.equal(300); expect(bid.getFloor.getCall(0).args[0].size[1]).to.equal(250); @@ -1690,7 +2117,7 @@ describe('IndexexchangeAdapter', function () { expect(bid.getFloor.getCall(1).args[0].size[0]).to.equal(500); expect(bid.getFloor.getCall(1).args[0].size[1]).to.equal(400); - const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const impression = extractPayload(requestBidFloor).imp[0]; expect(impression.bidfloor).to.equal(expectedFloor); expect(impression.bidfloorcur).to.equal(currency); }); @@ -1715,12 +2142,12 @@ describe('IndexexchangeAdapter', function () { sinon.spy(bid, 'getFloor'); - const requestBidFloor = spec.buildRequests([bid])[0]; + const requestBidFloor = spec.buildRequests([bid], {})[0]; expect(bid.getFloor.getCall(0).args[0].mediaType).to.equal('banner'); expect(bid.getFloor.getCall(0).args[0].size[0]).to.equal(300); expect(bid.getFloor.getCall(0).args[0].size[1]).to.equal(250); - const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const impression = extractPayload(requestBidFloor).imp[0]; expect(impression.bidfloor).to.equal(expectedFloor); expect(impression.bidfloorcur).to.equal(currency); }); @@ -1729,29 +2156,29 @@ describe('IndexexchangeAdapter', function () { it('impression should have sid if id is configured as number', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.id = 50; - const requestBidFloor = spec.buildRequests([bid])[0]; - const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const requestBidFloor = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(requestBidFloor).imp[0]; expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); expect(impression.banner.format[0].w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]); expect(impression.banner.format[0].h).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[1]); expect(impression.banner.topframe).to.be.oneOf([0, 1]); expect(impression.banner.format[0].ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); - expect(impression.banner.format[0].ext.sid).to.equal('50'); + expect(impression.ext.sid).to.equal('50'); }); it('impression should have sid if id is configured as string', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.params.id = 'abc'; - const requestBidFloor = spec.buildRequests([bid])[0]; - const impression = JSON.parse(requestBidFloor.data.r).imp[0]; + const requestBidFloor = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(requestBidFloor).imp[0]; expect(impression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); expect(impression.banner.format[0].w).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[0]); expect(impression.banner.format[0].h).to.equal(DEFAULT_BANNER_VALID_BID[0].params.size[1]); expect(impression.banner.topframe).to.be.oneOf([0, 1]); expect(impression.banner.format[0].ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); - expect(impression.banner.format[0].ext.sid).to.equal('abc'); + expect(impression.ext.sid).to.equal('abc'); }); describe('first party data', () => { @@ -1772,11 +2199,50 @@ describe('IndexexchangeAdapter', function () { }); const requestWithFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - const pageUrl = JSON.parse(requestWithFirstPartyData.data.r).site.page; - const expectedPageUrl = DEFAULT_OPTION.refererInfo.referer + '?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd'; + const pageUrl = extractPayload(requestWithFirstPartyData).site.page; + const expectedPageUrl = DEFAULT_OPTION.ortb2.site.page + '/?ab=123&cd=123%23ab&e%2Ff=456&h%3Fg=456%23cd'; expect(pageUrl).to.equal(expectedPageUrl); }); + it('should set device sua if available in fpd and request size does not exceed limit', function () { + const ortb2 = { + device: { + sua: { + platform: { + brand: 'macOS', + version: [ '12', '6', '1' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '107', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '107', '0', '5249', '119' ] + }, + ], + mobile: 0, + model: '' + } + }}; + + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2 })[0]; + const payload = extractPayload(request); + expect(payload.device.sua.platform.brand).to.equal('macOS') + expect(payload.device.sua.mobile).to.equal(0) + }); + + it('should not set device sua if not available in fpd', function () { + const ortb2 = { + device: {}}; + + const request = spec.buildRequests(DEFAULT_BANNER_VALID_BID, { ortb2 })[0]; + const payload = extractPayload(request); + expect(payload.device.h).to.exist; + expect(payload.device.w).to.exist; + }); + it('should not set first party data if it is not an object', function () { config.setConfig({ ix: { @@ -1785,9 +2251,9 @@ describe('IndexexchangeAdapter', function () { }); const requestFirstPartyDataNumber = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - const pageUrl = JSON.parse(requestFirstPartyDataNumber.data.r).site.page; + const pageUrl = extractPayload(requestFirstPartyDataNumber).site.page; - expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer); + expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page); }); it('should not set first party or timeout if it is not present', function () { @@ -1796,77 +2262,245 @@ describe('IndexexchangeAdapter', function () { }); const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page; + const pageUrl = extractPayload(requestWithoutConfig).site.page; - expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer); + expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page); expect(requestWithoutConfig.data.t).to.be.undefined; }); it('should not set first party or timeout if it is setConfig is not called', function () { const requestWithoutConfig = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; - const pageUrl = JSON.parse(requestWithoutConfig.data.r).site.page; + const pageUrl = extractPayload(requestWithoutConfig).site.page; - expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.referer); + expect(pageUrl).to.equal(DEFAULT_OPTION.refererInfo.page); expect(requestWithoutConfig.data.t).to.be.undefined; }); - it('should set timeout if publisher set it through setConfig', function () { + it('should no longer set timeout even if publisher set it through setConfig', function () { config.setConfig({ ix: { timeout: 500 } }); - const requestWithTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; + const requestWithTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {})[0]; - expect(requestWithTimeout.data.t).to.equal(500); + expect(requestWithTimeout.data.t).to.be.undefined; }); - it('should set timeout if timeout is a string', function () { + it('should no longer set timeout even if timeout is a string', function () { config.setConfig({ ix: { timeout: '500' } }); - const requestStringTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID)[0]; + const requestStringTimeout = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {})[0]; expect(requestStringTimeout.data.t).to.be.undefined; }); }); - describe('request should contain both banner and video requests', function () { - const request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_VIDEO_VALID_BID[0]]); + describe('getIxFirstPartyDataPageUrl', () => { + beforeEach(() => { + config.setConfig({ ix: { firstPartyData: { key1: 'value1', key2: 'value2' } } }); + }); + + afterEach(() => { + config.resetConfig(); + }); + + it('should return the modified URL with first party data query parameters appended', () => { + const requestWithIXFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; + const pageUrl = extractPayload(requestWithIXFirstPartyData).site.page; + expect(pageUrl).to.equal('https://www.prebid.org/?key1=value1&key2=value2'); + }); + + it('should return the modified URL with first party data query parameters appended but not duplicated', () => { + const bidderRequest = deepClone(DEFAULT_OPTION); + bidderRequest.ortb2.site.page = 'https://www.prebid.org/?key1=value1' + const requestWithIXFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; + const pageUrl = extractPayload(requestWithIXFirstPartyData).site.page; + expect(pageUrl).to.equal('https://www.prebid.org/?key1=value1&key2=value2'); + }); + + it('should not overwrite existing query parameters with first party data', () => { + config.setConfig({ ix: { firstPartyData: { key1: 'value1', key2: 'value2' } } }); + const bidderRequest = deepClone(DEFAULT_OPTION); + bidderRequest.ortb2.site.page = 'https://www.prebid.org/?key1=existingValue1' + const requestWithIXFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, bidderRequest)[0]; + const pageUrl = extractPayload(requestWithIXFirstPartyData).site.page; + expect(pageUrl).to.equal('https://www.prebid.org/?key1=existingValue1&key2=value2'); + }); + + it('should return the original URL if no first party data is available', () => { + config.setConfig({ ix: {} }); + const requestWithIXFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION)[0]; + const pageUrl = extractPayload(requestWithIXFirstPartyData).site.page; + expect(pageUrl).to.equal('https://www.prebid.org'); + }); + + it('should return the original URL referer page url if ortb2 does not exist', () => { + config.setConfig({ ix: {} }); + const bidderRequest = deepClone(DEFAULT_OPTION); + delete bidderRequest.ortb2; + bidderRequest.refererInfo.page = 'https://example.com'; + const requestWithIXFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, bidderRequest)[0]; + const pageUrl = extractPayload(requestWithIXFirstPartyData).site.page; + expect(pageUrl).to.equal('https://example.com'); + }); + + it('should use referer URL if the provided ortb2.site.page URL is not valid', () => { + config.setConfig({ ix: { firstPartyData: { key1: 'value1', key2: 'value2' } } }); + const bidderRequest = deepClone(DEFAULT_OPTION); + bidderRequest.ortb2.site.page = 'www.invalid-url*&?.com'; + bidderRequest.refererInfo.page = 'https://www.prebid.org'; + const requestWithIXFirstPartyData = spec.buildRequests(DEFAULT_BANNER_VALID_BID, bidderRequest)[0]; + const pageUrl = extractPayload(requestWithIXFirstPartyData).site.page; + expect(pageUrl).to.equal('https://www.prebid.org/?key1=value1&key2=value2'); + }); + }); + + describe('request should contain both banner and video requests', function () { + let request; + before(() => { + request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_VIDEO_VALID_BID[0]], {}); + }); it('should have banner request', () => { - const bannerImpression = JSON.parse(request[0].data.r).imp[0]; + const bannerImpression = extractPayload(request[0]).imp[0]; + const sidValue = DEFAULT_BANNER_VALID_BID[0].params.id; - expect(JSON.parse(request[0].data.r).imp).to.have.lengthOf(1); - expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION); + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); expect(bannerImpression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); expect(bannerImpression.banner.format).to.be.length(2); expect(bannerImpression.banner.topframe).to.be.oneOf([0, 1]); + expect(bannerImpression.ext.sid).to.equal(sidValue); bannerImpression.banner.format.map(({ w, h, ext }, index) => { const size = DEFAULT_BANNER_VALID_BID[0].mediaTypes.banner.sizes[index]; - const sidValue = utils.parseGPTSingleSizeArray(size); expect(w).to.equal(size[0]); expect(h).to.equal(size[1]); expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); - expect(ext.sid).to.equal(sidValue); }); }); it('should have video request', () => { - const videoImpression = JSON.parse(request[1].data.r).imp[0]; + const videoImpression = extractPayload(request[1]).imp[0]; - expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION); expect(videoImpression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); expect(videoImpression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]); expect(videoImpression.video.h).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[1]); }); }); + describe('video request should set displaymanager', () => { + it('ix renderer preferrered', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + bid[0].mediaTypes.video.context = 'outstream'; + bid[0].mediaTypes.video.w = [[300, 143]]; + bid[0].schain = undefined; + const request = spec.buildRequests(bid); + const videoImpression = extractPayload(request[0]).imp[0]; + expect(videoImpression.displaymanager).to.equal('ix'); + }); + it('ix renderer not preferrered', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + bid[0].mediaTypes.video.context = 'outstream'; + bid[0].mediaTypes.video.w = [[300, 143]]; + bid[0].mediaTypes.video.renderer = { + url: 'http://publisherplayer.js', + render: () => { } + }; + bid[0].schain = undefined; + const request = spec.buildRequests(bid); + const videoImpression = extractPayload(request[0]).imp[0]; + expect(videoImpression.displaymanager).to.equal('http://publisherplayer.js'); + }); + it('ix renderer not preferrered - bad url', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + bid[0].mediaTypes.video.context = 'outstream'; + bid[0].mediaTypes.video.w = [[300, 143]]; + bid[0].mediaTypes.video.renderer = { + url: 'publisherplayer.js', + render: () => { } + }; + bid[0].schain = undefined; + const request = spec.buildRequests(bid); + const videoImpression = extractPayload(request[0]).imp[0]; + expect(videoImpression.displaymanager).to.be.undefined; + }); + it('renderer url provided and is ix renderer', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + bid[0].mediaTypes.video.context = 'outstream'; + bid[0].mediaTypes.video.w = [[300, 143]]; + bid[0].mediaTypes.video.renderer = { + url: 'http://js-sec.indexww.rendererplayer.com', + render: () => { } + }; + bid[0].schain = undefined; + const request = spec.buildRequests(bid); + const videoImpression = extractPayload(request[0]).imp[0]; + expect(videoImpression.displaymanager).to.equal('ix'); + }); + it('renderer url undefined and is ix renderer', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + bid[0].mediaTypes.video.context = 'outstream'; + bid[0].mediaTypes.video.w = [[300, 143]]; + bid[0].mediaTypes.video.renderer = { + render: () => { } + }; + bid[0].schain = undefined; + const request = spec.buildRequests(bid); + const videoImpression = extractPayload(request[0]).imp[0]; + expect(videoImpression.displaymanager).to.be.undefined; + }); + it('schain', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID); + bid[0].mediaTypes.video.context = 'outstream'; + bid[0].mediaTypes.video.w = [[300, 143]]; + bid[0].schain = SAMPLE_SCHAIN; + const request = spec.buildRequests(bid); + const videoImpression = extractPayload(request[0]).imp[0]; + expect(videoImpression.displaymanager).to.equal('pbjs_wrapper'); + }); + }); + + describe('request should contain both banner and native requests', function () { + let request; + before(() => { + request = spec.buildRequests([DEFAULT_BANNER_VALID_BID[0], DEFAULT_NATIVE_VALID_BID[0]]); + }) + + it('should have banner request', () => { + const bannerImpression = extractPayload(request[0]).imp[0]; + const sidValue = DEFAULT_BANNER_VALID_BID[0].params.id; + + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(bannerImpression.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidId); + + expect(bannerImpression.banner.format).to.be.length(2); + expect(bannerImpression.banner.topframe).to.be.oneOf([0, 1]); + expect(bannerImpression.ext.sid).to.equal(sidValue); + + bannerImpression.banner.format.map(({ w, h, ext }, index) => { + const size = DEFAULT_BANNER_VALID_BID[0].mediaTypes.banner.sizes[index]; + + expect(w).to.equal(size[0]); + expect(h).to.equal(size[1]); + expect(ext.siteID).to.equal(DEFAULT_BANNER_VALID_BID[0].params.siteId); + }); + }); + + it('should have native request', () => { + const nativeImpression = extractPayload(request[1]).imp[0]; + + expect(request[1].data.hasOwnProperty('v')).to.equal(false); + expect(nativeImpression.id).to.equal(DEFAULT_NATIVE_VALID_BID[0].bidId); + expect(nativeImpression.native).to.deep.equal(DEFAULT_NATIVE_IMP); + }); + }); + it('single request under 8k size limit for large ad unit', function () { const options = {}; const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); @@ -1880,7 +2514,7 @@ describe('IndexexchangeAdapter', function () { expect(requests[0].data.sn).to.be.undefined; }); - it('2 requests due to 2 ad units, one larger than url size', function () { + it('1 request, one larger than url size, no splitting', function () { const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; bid.params.siteId = '124'; @@ -1890,12 +2524,10 @@ describe('IndexexchangeAdapter', function () { const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); expect(requests).to.be.an('array'); - expect(requests).to.have.lengthOf(2); - expect(requests[0].data.sn).to.be.equal(0); - expect(requests[1].data.sn).to.be.equal(1); + expect(requests).to.have.lengthOf(1); }); - it('6 ad units should generate only 4 requests', function () { + it('6 ad units should generate only 1 requests', function () { const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid1.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; bid1.params.siteId = '121'; @@ -1921,15 +2553,12 @@ describe('IndexexchangeAdapter', function () { const requests = spec.buildRequests([bid1, bid2, bid3, bid4, bid5, bid6], DEFAULT_OPTION); expect(requests).to.be.an('array'); - expect(requests).to.have.lengthOf(4); + expect(requests).to.have.lengthOf(1); for (var i = 0; i < requests.length; i++) { const reqSize = `${requests[i].url}?${utils.parseQueryStringParameters(requests[i].data)}`.length; expect(reqSize).to.be.lessThan(8000); - let payload = JSON.parse(requests[i].data.r); - if (requests.length > 1) { - expect(requests[i].data.sn).to.equal(i); - } + let payload = extractPayload(requests[i]); expect(payload.source.ext.schain).to.deep.equal(SAMPLE_SCHAIN); } }); @@ -1943,9 +2572,11 @@ describe('IndexexchangeAdapter', function () { bid1.bidId = '2f6g5s5e'; const bid2 = utils.deepClone(bid1); + bid2.adUnitCode = 'div-gpt-2' bid2.transactionId = 'tr2'; bid2.mediaTypes.banner.sizes = [[220, 221], [222, 223], [300, 250]]; const bid3 = utils.deepClone(bid1); + bid3.adUnitCode = 'div-gpt-3' bid3.transactionId = 'tr3'; bid3.mediaTypes.banner.sizes = [[330, 331], [332, 333], [300, 250]]; @@ -1954,7 +2585,7 @@ describe('IndexexchangeAdapter', function () { expect(requests).to.be.an('array'); expect(requests).to.have.lengthOf(1); - const impressions = JSON.parse(requests[0].data.r).imp; + const impressions = extractPayload(requests[0]).imp; expect(impressions).to.be.an('array'); expect(impressions).to.have.lengthOf(3); expect(requests[0].data.sn).to.be.undefined; @@ -1970,20 +2601,20 @@ describe('IndexexchangeAdapter', function () { bid2.params.bidId = '2b3c4d5e'; const request = spec.buildRequests([bid, bid2], DEFAULT_OPTION)[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const impression = extractPayload(request).imp[0]; + const sidValue = bid.params.id; expect(impression.id).to.equal(bid.bidId); expect(impression.banner.format).to.be.length(bid.mediaTypes.banner.sizes.length); expect(impression.banner.topframe).to.be.oneOf([0, 1]); + expect(impression.ext.sid).to.equal(sidValue); impression.banner.format.map(({ w, h, ext }, index) => { const size = bid.mediaTypes.banner.sizes[index]; - const sidValue = utils.parseGPTSingleSizeArray(size); expect(w).to.equal(size[0]); expect(h).to.equal(size[1]); expect(ext.siteID).to.equal(index === 1 ? bid2.params.siteId : bid.params.siteId); - expect(ext.sid).to.equal(sidValue); }); }); @@ -2000,53 +2631,45 @@ describe('IndexexchangeAdapter', function () { const bids = [DEFAULT_BANNER_VALID_BID[0], bid]; const request = spec.buildRequests(bids, DEFAULT_OPTION)[0]; - const impressions = JSON.parse(request.data.r).imp; + const impressions = extractPayload(request).imp; expect(impressions).to.be.an('array'); expect(impressions).to.have.lengthOf(2); expect(request.data.sn).to.be.undefined; impressions.map((impression, impressionIndex) => { const firstSizeObject = bids[impressionIndex].mediaTypes.banner.sizes[0]; + const sidValue = bids[impressionIndex].params.id; expect(impression.banner.format).to.be.length(2); expect(impression.banner.topframe).to.be.oneOf([0, 1]); + expect(impression.ext.sid).to.equal(sidValue); impression.banner.format.map(({ w, h, ext }, index) => { const size = bids[impressionIndex].mediaTypes.banner.sizes[index]; - const sidValue = utils.parseGPTSingleSizeArray(size); expect(w).to.equal(size[0]); expect(h).to.equal(size[1]); expect(ext.siteID).to.equal(bids[impressionIndex].params.siteId); - expect(ext.sid).to.equal(sidValue); }); }); }); it('request should not contain the extra video ad sizes that IX is not configured for', function () { const request = spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION); - const impressions = JSON.parse(request[0].data.r).imp; + const impressions = extractPayload(request[0]).imp; expect(impressions).to.be.an('array'); expect(impressions).to.have.lengthOf(1); }); describe('detect missing sizes', function () { - beforeEach(function () { - config.setConfig({ - ix: { - detectMissingSizes: false - } - }); - }) - - it('request should not contain missing sizes if detectMissingSizes = false', function () { + it('request should always contain missing sizes', function () { const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); bid1.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; const requests = spec.buildRequests([bid1, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); - const impressions = JSON.parse(requests[0].data.r).imp; + const impressions = extractPayload(requests[0]).imp; expect(impressions).to.be.an('array'); expect(impressions).to.have.lengthOf(1); @@ -2055,26 +2678,19 @@ describe('IndexexchangeAdapter', function () { }); describe('buildRequestVideo', function () { - const request = spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION); - const query = request[0].data; - - it('query object (version, siteID and request) should be correct', function () { - expect(query.v).to.equal(VIDEO_ENDPOINT_VERSION); - expect(query.s).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.siteId); - expect(query.r).to.exist; - expect(query.ac).to.equal('j'); - expect(query.sd).to.equal(1); - expect(query.nf).to.equal(1); - }); + let request, payloadData; + before(() => { + request = spec.buildRequests(DEFAULT_VIDEO_VALID_BID, DEFAULT_OPTION); + payloadData = request[0].data; + }) it('auction type should be set correctly', function () { - const at = JSON.parse(query.r).at; + const at = payloadData.at; expect(at).to.equal(1); }) it('impression should have correct format and value', function () { - const impression = JSON.parse(query.r).imp[0]; - const sidValue = utils.parseGPTSingleSizeArray(DEFAULT_VIDEO_VALID_BID[0].params.size); + const impression = payloadData.imp[0]; expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); expect(impression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID[0].params.size[0]); @@ -2092,18 +2708,57 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.mediaTypes.video.context = 'outstream'; bid.mediaTypes.video.placement = 2; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); expect(impression.video.placement).to.equal(2); }); + it('should use plcmt value when set in video.params', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.video.plcmt = 2; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video.plcmt).to.equal(2); + }); + + it('invalid plcmt value when set in video.params', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.video.plcmt = 5; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video.plcmt).to.be.undefined; + }); + + it('invalid plcmt value string when set in video.params', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.video.plcmt = '4'; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); + expect(impression.video.plcmt).to.be.undefined; + }); + + it('should set imp.ext.sid for video imps if params.id exists', function () { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.id = 50; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; + + expect(impression.ext.sid).to.equal('50'); + }); + it('should set correct default placement, if context is instream', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.mediaTypes.video.context = 'instream'; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); expect(impression.video.placement).to.equal(1); @@ -2112,18 +2767,19 @@ describe('IndexexchangeAdapter', function () { it('should set correct default placement, if context is outstream', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.mediaTypes.video.context = 'outstream'; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.id).to.equal(DEFAULT_VIDEO_VALID_BID[0].bidId); - expect(impression.video.placement).to.equal(4); + expect(impression.video.placement).to.equal(3); + expect(extractPayload(request).ext.ixdiag.vpd).to.equal(true); }); it('should handle unexpected context', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.mediaTypes.video.context = 'not-valid'; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.video.placement).to.be.undefined; }); @@ -2132,8 +2788,8 @@ describe('IndexexchangeAdapter', function () { bid.mediaTypes.video.context = 'outstream'; bid.mediaTypes.video.protocols = [1]; bid.mediaTypes.video.mimes = ['video/override']; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.video.protocols[0]).to.equal(2); expect(impression.video.mimes[0]).to.not.equal('video/override'); @@ -2143,8 +2799,8 @@ describe('IndexexchangeAdapter', function () { const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); bid.mediaTypes.video.context = 'outstream'; bid.mediaTypes.video.random = true; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.video.random).to.not.exist; }); @@ -2157,11 +2813,13 @@ describe('IndexexchangeAdapter', function () { bid.mediaTypes.video.protocols = [6]; bid.mediaTypes.video.mimes = ['video/mp4']; bid.mediaTypes.video.api = 2; - const request = spec.buildRequests([bid])[0]; - const impression = JSON.parse(request.data.r).imp[0]; + bid.mediaTypes.video.pos = 0; + const request = spec.buildRequests([bid], {})[0]; + const impression = extractPayload(request).imp[0]; expect(impression.video.protocols[0]).to.equal(6); expect(impression.video.api).to.equal(2); + expect(impression.video.pos).to.equal(0); expect(impression.video.mimes[0]).to.equal('video/mp4'); }); @@ -2174,17 +2832,218 @@ describe('IndexexchangeAdapter', function () { } }; const requests = spec.buildRequests(validBids, DEFAULT_OPTION); - const { ext: { gpid } } = JSON.parse(requests[0].data.r).imp[0]; + const { ext: { gpid } } = extractPayload(requests[0]).imp[0]; + expect(gpid).to.equal(GPID); + }); + + it('should build video request when if video obj is not provided at params level', () => { + const request = spec.buildRequests([DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0]], {}); + const videoImpression = extractPayload(request[0]).imp[0]; + + expect(videoImpression.id).to.equal(DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0].bidId); + expect(videoImpression.video.w).to.equal(DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0].mediaTypes.video.playerSize[0][0]); + expect(videoImpression.video.h).to.equal(DEFAULT_VIDEO_VALID_BID_NO_VIDEO_PARAMS[0].mediaTypes.video.playerSize[0][1]); + }); + + it('should set different placement for floating ad units', () => { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.mediaTypes.video.context = 'outstream'; + bid.params.video.playerConfig = { + floatOnScroll: true + }; + + const request = spec.buildRequests([bid]); + const videoImpression = extractPayload(request[0]).imp[0]; + + expect(videoImpression.video.placement).to.eq(5); + }) + }); + + describe('buildRequestNative', function () { + it('should build request with expected params', function () { + const request = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION)[0]; + + expect(request.data).to.exist; + expect(request.method).to.equal('POST') + }); + + it('should send gpid in request if ortb2Imp.ext.gpid exists', function () { + const GPID = '/19968336/some-adunit-path'; + const bids = utils.deepClone(DEFAULT_NATIVE_VALID_BID); + bids[0].ortb2Imp = { + ext: { + gpid: GPID + } + }; + const requests = spec.buildRequests(bids, DEFAULT_OPTION); + const { ext: { gpid } } = extractPayload(requests[0]).imp[0]; expect(gpid).to.equal(GPID); }); + + it('should build request with required asset properties with default values', function () { + const request = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, DEFAULT_OPTION); + const nativeImpression = extractPayload(request[0]).imp[0]; + + expect(request[0].data.hasOwnProperty('v')).to.equal(false); + expect(nativeImpression.id).to.equal(DEFAULT_NATIVE_VALID_BID[0].bidId); + expect(nativeImpression.native).to.deep.equal(DEFAULT_NATIVE_IMP); + }); + + it('should set imp.ext.sid for native imps if params.id exist', function () { + const bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID); + bid[0].params.id = 'abc' + const request = spec.buildRequests(bid, DEFAULT_OPTION); + const nativeImpression = extractPayload(request[0]).imp[0]; + + expect(nativeImpression.id).to.equal(DEFAULT_NATIVE_VALID_BID[0].bidId); + expect(nativeImpression.ext.sid).to.equal('abc'); + }); + + it('should build request with given asset properties', function () { + let bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID) + bid[0].nativeOrtbRequest = { + assets: [{ id: 0, required: 0, title: { len: 140 } }, { id: 1, required: 0, video: { mimes: ['javascript'], minduration: 10, maxduration: 60, protocols: [1] } }] + } + const request = spec.buildRequests(bid, DEFAULT_OPTION); + const nativeImpression = extractPayload(request[0]).imp[0]; + expect(nativeImpression.native).to.deep.equal({ request: '{"assets":[{"id":0,"required":0,"title":{"len":140}},{"id":1,"required":0,"video":{"mimes":["javascript"],"minduration":10,"maxduration":60,"protocols":[1]}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', ver: '1.2' }); + }); + + it('should build request with all possible Prebid asset properties', function () { + let bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID) + bid[0].nativeOrtbRequest = { + 'ver': '1.2', + 'assets': [ + { + 'id': 0, + 'required': 0, + 'title': { + 'len': 140 + } + }, + { + 'id': 1, + 'required': 0, + 'data': { + 'type': 2 + } + }, + { + 'id': 2, + 'required': 0, + 'data': { + 'type': 10 + } + }, + { + 'id': 3, + 'required': 0, + 'data': { + 'type': 1 + } + }, + { + 'id': 4, + 'required': 0, + 'img': { + 'type': 1 + } + }, + { + 'id': 5, + 'required': 0, + 'img': { + 'type': 3 + } + }, + { + 'id': 6, + 'required': 0 + }, + { + 'id': 7, + 'required': 0, + 'data': { + 'type': 11 + } + }, + { + 'id': 8, + 'required': 0 + }, + { + 'id': 9, + 'required': 0 + }, + { + 'id': 10, + 'required': 0, + 'data': { + 'type': 12 + } + }, + { + 'id': 11, + 'required': 0, + 'data': { + 'type': 3 + } + }, + { + 'id': 12, + 'required': 0, + 'data': { + 'type': 5 + } + }, + { + 'id': 13, + 'required': 0, + 'data': { + 'type': 4 + } + }, + { + 'id': 14, + 'required': 0, + 'data': { + 'type': 6 + } + }, + { + 'id': 15, + 'required': 0, + 'data': { + 'type': 7 + } + }, + { + 'id': 16, + 'required': 0, + 'data': { + 'type': 9 + } + }, + { + 'id': 17, + 'required': 0, + 'data': { + 'type': 8 + } + } + ] + } + const request = spec.buildRequests(bid, DEFAULT_OPTION); + const nativeImpression = extractPayload(request[0]).imp[0]; + expect(nativeImpression.native).to.deep.equal({ request: '{"ver":"1.2","assets":[{"id":0,"required":0,"title":{"len":140}},{"id":1,"required":0,"data":{"type":2}},{"id":2,"required":0,"data":{"type":10}},{"id":3,"required":0,"data":{"type":1}},{"id":4,"required":0,"img":{"type":1}},{"id":5,"required":0,"img":{"type":3}},{"id":6,"required":0},{"id":7,"required":0,"data":{"type":11}},{"id":8,"required":0},{"id":9,"required":0},{"id":10,"required":0,"data":{"type":12}},{"id":11,"required":0,"data":{"type":3}},{"id":12,"required":0,"data":{"type":5}},{"id":13,"required":0,"data":{"type":4}},{"id":14,"required":0,"data":{"type":6}},{"id":15,"required":0,"data":{"type":7}},{"id":16,"required":0,"data":{"type":9}},{"id":17,"required":0,"data":{"type":8}}],"eventtrackers":[{"event":1,"methods":[1,2]}],"privacy":1}', ver: '1.2' }); + }) }); describe('buildRequestMultiFormat', function () { it('only banner bidder params set', function () { - const request = spec.buildRequests(DEFAULT_MULTIFORMAT_BANNER_VALID_BID) - const bannerImpression = JSON.parse(request[0].data.r).imp[0]; - expect(JSON.parse(request[0].data.r).imp).to.have.lengthOf(1); - expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION); + const request = spec.buildRequests(DEFAULT_MULTIFORMAT_BANNER_VALID_BID, {}) + const bannerImpression = extractPayload(request[0]).imp[0]; + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); expect(bannerImpression.id).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].bidId); expect(bannerImpression.banner.format[0].w).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].params.size[0]); expect(bannerImpression.banner.format[0].h).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].params.size[1]); @@ -2192,34 +3051,26 @@ describe('IndexexchangeAdapter', function () { describe('only video bidder params set', function () { it('should generate video impression', function () { - const request = spec.buildRequests(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID); - const videoImp = JSON.parse(request[1].data.r).imp[0]; - expect(JSON.parse(request[1].data.r).imp).to.have.lengthOf(1); - expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION); + const request = spec.buildRequests(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID, {}); + const videoImp = extractPayload(request[1]).imp[0]; + expect(extractPayload(request[1]).imp).to.have.lengthOf(1); expect(videoImp.id).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].bidId); expect(videoImp.video.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.size[0]); expect(videoImp.video.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.size[1]); }); - - it('should get missing sizes count 0 when params.size not used', function () { - const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); - delete bid.params.size; - const request = spec.buildRequests([bid]); - const diagObj = JSON.parse(request[0].data.r).ext.ixdiag; - expect(diagObj.msd).to.equal(0); - expect(diagObj.msi).to.equal(0); - }); }); describe('both banner and video bidder params set', function () { const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]]; - const request = spec.buildRequests(bids); + let request; + before(() => { + request = spec.buildRequests(bids, {}); + }) it('should return valid banner requests', function () { - const impressions = JSON.parse(request[0].data.r).imp; + const impressions = extractPayload(request[0]).imp; expect(impressions).to.have.lengthOf(2); - expect(JSON.parse(request[0].data.v)).to.equal(BANNER_ENDPOINT_VERSION); impressions.map((impression, index) => { const bid = bids[index]; @@ -2230,40 +3081,83 @@ describe('IndexexchangeAdapter', function () { impression.banner.format.map(({ w, h, ext }, index) => { const size = bid.mediaTypes.banner.sizes[index]; - const sidValue = utils.parseGPTSingleSizeArray(size); expect(w).to.equal(size[0]); expect(h).to.equal(size[1]); expect(ext.siteID).to.equal(bid.params.siteId); - expect(ext.sid).to.equal(sidValue); }); }); }); it('should return valid banner and video requests', function () { - const videoImpression = JSON.parse(request[1].data.r).imp[0]; + const videoImpression = extractPayload(request[1]).imp[0]; - expect(JSON.parse(request[1].data.r).imp).to.have.lengthOf(1); - expect(JSON.parse(request[1].data.v)).to.equal(VIDEO_ENDPOINT_VERSION); + expect(extractPayload(request[1]).imp).to.have.lengthOf(1); expect(videoImpression.id).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].bidId); - expect(videoImpression.video.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0]); - expect(videoImpression.video.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[1]); + expect(videoImpression.video.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0][0]); + expect(videoImpression.video.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0][1]); }); it('should contain all correct IXdiag properties', function () { - const diagObj = JSON.parse(request[0].data.r).ext.ixdiag; + const diagObj = extractPayload(request[0]).ext.ixdiag; expect(diagObj.iu).to.equal(0); expect(diagObj.nu).to.equal(0); expect(diagObj.ou).to.equal(2); - expect(diagObj.ren).to.equal(false); + expect(diagObj.ren).to.equal(true); expect(diagObj.mfu).to.equal(2); expect(diagObj.allu).to.equal(2); expect(diagObj.version).to.equal('$prebid.version$'); + expect(diagObj.url).to.equal('http://localhost:9876/context.html') + expect(diagObj.pbadslot).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].ortb2Imp.ext.data.pbadslot) + expect(diagObj.tagid).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.tagId) + expect(diagObj.adunitcode).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].adUnitCode) + }); + }); + + describe('siteId overrides', function () { + it('should use siteId override', function () { + const validBids = DEFAULT_MULTIFORMAT_VALID_BID; + const request = spec.buildRequests(validBids, {}); + const bannerImps = request[0].data.imp[0]; + const videoImps = request[1].data.imp[0]; + const nativeImps = request[2].data.imp[0]; + expect(videoImps.ext.siteID).to.equal('1111'); + bannerImps.banner.format.map(({ ext }) => { + expect(ext.siteID).to.equal('2222'); + }); + expect(nativeImps.ext.siteID).to.equal('3333'); + }); + + it('should use default siteId if overrides are not provided', function () { + const validBids = DEFAULT_MULTIFORMAT_VALID_BID; + delete validBids[0].params.banner; + delete validBids[0].params.video; + delete validBids[0].params.native; + const request = spec.buildRequests(validBids, {}); + const bannerImps = request[0].data.imp[0]; + const videoImps = request[1].data.imp[0]; + const nativeImps = request[2].data.imp[0]; + expect(videoImps.ext.siteID).to.equal('456'); + bannerImps.banner.format.map(({ ext }) => { + expect(ext.siteID).to.equal('456'); + }); + expect(nativeImps.ext.siteID).to.equal('456'); }); }); }); describe('interpretResponse', function () { + // generate bidderRequest with real buildRequest logic for intepretResponse testing + let bannerBidderRequest + let videoBidderRequest + let nativeBidderRequest + + beforeEach(() => { + bannerBidderRequest = spec.buildRequests(DEFAULT_BANNER_VALID_BID, {})[0] + videoBidderRequest = spec.buildRequests(DEFAULT_VIDEO_VALID_BID_MEDIUM_SIZE, {})[0] + nativeBidderRequest = spec.buildRequests(DEFAULT_NATIVE_VALID_BID, {})[0] + }); + it('should get correct bid response for banner ad', function () { const expectedParse = [ { @@ -2285,7 +3179,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, bannerBidderRequest); expect(result[0]).to.deep.equal(expectedParse[0]); }); @@ -2309,7 +3203,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE_WITHOUT_ADOMAIN }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE_WITHOUT_ADOMAIN }, bannerBidderRequest); expect(result[0]).to.deep.equal(expectedParse[0]); }); @@ -2336,7 +3230,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest); }); it('should set Japanese price correctly', function () { @@ -2362,7 +3256,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest); expect(result[0]).to.deep.equal(expectedParse[0]); }); @@ -2391,7 +3285,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest); expect(result[0].dealId).to.equal(expectedParse[0].dealId); }); @@ -2418,7 +3312,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest); expect(result[0]).to.deep.equal(expectedParse[0]); }); @@ -2446,7 +3340,7 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: bidResponse }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const result = spec.interpretResponse({ body: bidResponse }, bannerBidderRequest); expect(result[0].dealId).to.deep.equal(expectedParse[0].dealId); }); @@ -2483,12 +3377,74 @@ describe('IndexexchangeAdapter', function () { } ]; const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { - data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: ONE_VIDEO + data: videoBidderRequest.data, validBidRequests: ONE_VIDEO }); expect(result[0]).to.deep.equal(expectedParse[0]); }); + it('should set bid[].renderer if renderer not defined at mediaType.video level', function () { + const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { + data: videoBidderRequest.data, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID + }); + expect(bid[0].renderer).to.exist; + }); + + it('should set renderer URL by parsing video response', function () { + const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { + data: videoBidderRequest.data, validBidRequests: DEFAULT_MULTIFORMAT_BANNER_VALID_BID + }); + expect(bid[0].renderer.url).to.equal(DEFAULT_VIDEO_BID_RESPONSE.ext.videoplayerurl); + }); + + it('should not set bid[].renderer if renderer defined at mediaType.video level', function () { + let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID); + outstreamAdUnit[0].mediaTypes.video.renderer = { + url: 'test', + render: function () { } + }; + const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { + data: videoBidderRequest.data, validBidRequests: outstreamAdUnit + }); + expect(bid[0].renderer).to.be.undefined; + }); + + it('should not set bid[].renderer if renderer defined at the ad unit level', function () { + let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID); + outstreamAdUnit[0].renderer = { + url: 'test', + render: function () { } + }; + const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { + data: videoBidderRequest.data, validBidRequests: outstreamAdUnit + }); + expect(bid[0].renderer).to.be.undefined; + }); + + it('should set bid[].renderer if ad unit renderer is invalid', function () { + let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID); + outstreamAdUnit[0].mediaTypes.video.renderer = { + url: 'test' + }; + const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { + data: videoBidderRequest.data, validBidRequests: outstreamAdUnit + }); + expect(bid[0].renderer).to.exist; + }); + + it('should set bid[].renderer if ad unit renderer is a backup', function () { + let outstreamAdUnit = utils.deepClone(DEFAULT_MULTIFORMAT_BANNER_VALID_BID); + outstreamAdUnit[0].mediaTypes.video.renderer = { + url: 'test', + render: function () { }, + backupOnly: true + }; + const bid = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { + data: videoBidderRequest.data, validBidRequests: outstreamAdUnit + }); + expect(bid[0].renderer).to.exist; + }); + it('should get correct bid response for video ad and set bid.vastXml when mtype is 2 (video)', function () { const expectedParse = [ { @@ -2521,20 +3477,61 @@ describe('IndexexchangeAdapter', function () { } } ]; - const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE_WITH_MTYPE_SET }, { - data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: ONE_VIDEO + const result = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE_WITH_XML_ADM }, { + data: videoBidderRequest.data, validBidRequests: ONE_VIDEO }); expect(result[0]).to.deep.equal(expectedParse[0]); }); + it('should not set vastxml when vasturl is present and when mtype is 2 (video)', function () { + const expectedParse = [ + { + requestId: '1a2b3c4e', + cpm: 1.1, + creativeId: '12346', + mediaType: 'video', + mediaTypes: { + video: { + context: 'instream', + playerSize: [ + [ + 400, + 100 + ] + ] + } + }, + width: 640, + height: 480, + currency: 'USD', + ttl: 3600, + netRevenue: true, + vastUrl: 'www.abcd.com/vast', + meta: { + networkId: 51, + brandId: 303326, + brandName: 'OECTB', + advertiserDomains: ['www.abcd.com'] + } + } + ]; + let bid_response = DEFAULT_VIDEO_BID_RESPONSE_WITH_XML_ADM; + bid_response.seatbid[0].bid[0].ext['vasturl'] = 'www.abcd.com/vast'; + const result = spec.interpretResponse({ body: bid_response }, { + data: videoBidderRequest.data, validBidRequests: ONE_VIDEO + }); + expect(result[0]).to.deep.equal(expectedParse[0]); + }); + it('bidrequest should not have page if options is undefined', function () { const options = {}; const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r); + const requestWithoutreferInfo = extractPayload(validBidWithoutreferInfo[0]); + const expectedURL = IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId expect(requestWithoutreferInfo.site.page).to.be.undefined; - expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); + expect(validBidWithoutreferInfo[0].url).to.equal(expectedURL); }); it('bidrequest should not have page if options.refererInfo is an empty object', function () { @@ -2542,10 +3539,11 @@ describe('IndexexchangeAdapter', function () { refererInfo: {} }; const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r); + const requestWithoutreferInfo = extractPayload(validBidWithoutreferInfo[0]); + const expectedURL = IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId expect(requestWithoutreferInfo.site.page).to.be.undefined; - expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); + expect(validBidWithoutreferInfo[0].url).to.equal(expectedURL); }); it('bidrequest should sent to secure endpoint if page url is secure', function () { @@ -2555,10 +3553,11 @@ describe('IndexexchangeAdapter', function () { } }; const validBidWithoutreferInfo = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithoutreferInfo = JSON.parse(validBidWithoutreferInfo[0].data.r); + const requestWithoutreferInfo = extractPayload(validBidWithoutreferInfo[0]); - expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.referer); - expect(validBidWithoutreferInfo[0].url).to.equal(IX_SECURE_ENDPOINT); + const expectedURL = IX_SECURE_ENDPOINT + '?s=' + DEFAULT_BANNER_VALID_BID[0].params.siteId + expect(requestWithoutreferInfo.site.page).to.equal(options.refererInfo.page); + expect(validBidWithoutreferInfo[0].url).to.equal(expectedURL); }); it('should set bid[].ttl to seatbid[].bid[].exp value from response', function () { @@ -2566,26 +3565,116 @@ describe('IndexexchangeAdapter', function () { const VIDEO_RESPONSE_WITH_EXP = utils.deepClone(DEFAULT_VIDEO_BID_RESPONSE); VIDEO_RESPONSE_WITH_EXP.seatbid[0].bid[0].exp = 200; BANNER_RESPONSE_WITH_EXP.seatbid[0].bid[0].exp = 100; - const bannerResult = spec.interpretResponse({ body: BANNER_RESPONSE_WITH_EXP }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); - const videoResult = spec.interpretResponse({ body: VIDEO_RESPONSE_WITH_EXP }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const bannerResult = spec.interpretResponse({ body: BANNER_RESPONSE_WITH_EXP }, bannerBidderRequest); + const videoResult = spec.interpretResponse({ body: VIDEO_RESPONSE_WITH_EXP }, videoBidderRequest); expect(bannerResult[0].ttl).to.equal(100); expect(videoResult[0].ttl).to.equal(200); }); it('should default bid[].ttl if seat[].bid[].exp is not in the resposne', function () { - const bannerResult = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); - const videoResult = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, { data: DEFAULT_BIDDER_REQUEST_DATA, validBidRequests: [] }); + const bannerResult = spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, bannerBidderRequest); + const videoResult = spec.interpretResponse({ body: DEFAULT_VIDEO_BID_RESPONSE }, videoBidderRequest); expect(bannerResult[0].ttl).to.equal(300); expect(videoResult[0].ttl).to.equal(3600); }); - }); - describe('bidrequest consent', function () { + it('should get correct bid response for native ad', function () { + const expectedParse = [ + { + requestId: '1a2b3c4d', + cpm: 1, + creativeId: '12345', + mediaType: 'native', + width: 1, + height: 1, + currency: 'USD', + netRevenue: true, + meta: { + networkId: 50, + brandId: 303325, + brandName: 'OECTA', + advertiserDomains: ['www.abc.com'] + }, + native: { + ortb: { + assets: [ + { + 'id': 0, + 'img': { + 'h': 250, + 'url': 'https://cdn.liftoff.io/customers/1209/creatives/2501-icon-250x250.png', + 'w': 250 + } + }, + { + 'id': 1, + 'img': { + 'h': 627, + 'url': 'https://cdn.liftoff.io/customers/5a9cab9cc6/image/lambda_png/a0355879b06c09b09232.png', + 'w': 1200 + } + }, + { + 'data': { + 'value': 'autodoc.co.uk' + }, + 'id': 2 + }, + { + 'data': { + 'value': 'Les pièces automobiles dont vous avez besoin, toujours sous la main.' + }, + 'id': 3 + }, + { + 'id': 4, + 'title': { + 'text': 'Autodoc' + } + }, + { + 'id': 5, + 'video': { + 'vasttag': 'blah' + } + } + ], + 'eventtrackers': [ + { + 'event': 1, + 'method': 1, + 'url': 'https://impression-europe.liftoff.io/index/impression' + }, + { + 'event': 1, + 'method': 1, + 'url': 'https://a701.casalemedia.com/impression/v1' + } + ], + 'link': { + 'clicktrackers': [ + 'https://click.liftoff.io/v1/campaign_click/blah' + ], + 'url': 'https://play.google.com/store/apps/details?id=de.autodoc.gmbh' + }, + 'privacy': 'https://privacy.link.com', + 'ver': '1.2' + } + }, + ttl: 3600 + } + ]; + const result = spec.interpretResponse({ body: DEFAULT_NATIVE_BID_RESPONSE }, nativeBidderRequest); + expect(result[0]).to.deep.equal(expectedParse[0]); + }); + }); + + describe('bidrequest consent', function () { it('should have consent info if gdprApplies and consentString exist', function () { const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); + const requestWithConsent = extractPayload(validBidWithConsent[0]); expect(requestWithConsent.regs.ext.gdpr).to.equal(1); expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae'); @@ -2599,7 +3688,7 @@ describe('IndexexchangeAdapter', function () { } }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); + const requestWithConsent = extractPayload(validBidWithConsent[0]); expect(requestWithConsent.regs.ext.gdpr).to.equal(1); expect(requestWithConsent.user).to.be.undefined; @@ -2613,7 +3702,7 @@ describe('IndexexchangeAdapter', function () { } }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); + const requestWithConsent = extractPayload(validBidWithConsent[0]); expect(requestWithConsent.regs).to.be.undefined; expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae'); @@ -2622,7 +3711,7 @@ describe('IndexexchangeAdapter', function () { it('should not have consent info if options.gdprConsent is undefined', function () { const options = {}; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); + const requestWithConsent = extractPayload(validBidWithConsent[0]); expect(requestWithConsent.regs).to.be.undefined; expect(requestWithConsent.user).to.be.undefined; @@ -2633,7 +3722,7 @@ describe('IndexexchangeAdapter', function () { uspConsent: '1YYN' }; const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r); + const requestWithUspConsent = extractPayload(validBidWithUspConsent[0]); expect(requestWithUspConsent.regs.ext.us_privacy).to.equal('1YYN'); }); @@ -2641,7 +3730,7 @@ describe('IndexexchangeAdapter', function () { it('should not have us_privacy if uspConsent undefined', function () { const options = {}; const validBidWithUspConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithUspConsent = JSON.parse(validBidWithUspConsent[0].data.r); + const requestWithUspConsent = extractPayload(validBidWithUspConsent[0]); expect(requestWithUspConsent.regs).to.be.undefined; }); @@ -2655,12 +3744,12 @@ describe('IndexexchangeAdapter', function () { uspConsent: '1YYN' }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); + const requestWithConsent = extractPayload(validBidWithConsent[0]); expect(requestWithConsent.regs.ext.gdpr).to.equal(1); expect(requestWithConsent.regs.ext.us_privacy).to.equal('1YYN'); }); - it('should contain `consented_providers_settings.consented_providers` & consent on user.ext when both are provided', function () { + it('should contain `consented_providers_settings.addtl_consent` & consent on user.ext when both are provided', function () { const options = { gdprConsent: { consentString: '3huaa11=qu3198ae', @@ -2669,12 +3758,12 @@ describe('IndexexchangeAdapter', function () { }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); - expect(requestWithConsent.user.ext.consented_providers_settings.consented_providers).to.equal('1~1.35.41.101'); + const requestWithConsent = extractPayload(validBidWithConsent[0]); + expect(requestWithConsent.user.ext.consented_providers_settings.addtl_consent).to.equal('1~1.35.41.101'); expect(requestWithConsent.user.ext.consent).to.equal('3huaa11=qu3198ae'); }); - it('should not contain `consented_providers_settings.consented_providers` on user.ext when consent is not provided', function () { + it('should not contain `consented_providers_settings.addtl_consent` on user.ext when consent is not provided', function () { const options = { gdprConsent: { addtlConsent: '1~1.35.41.101', @@ -2682,35 +3771,484 @@ describe('IndexexchangeAdapter', function () { }; const validBidWithConsent = spec.buildRequests(DEFAULT_BANNER_VALID_BID, options); - const requestWithConsent = JSON.parse(validBidWithConsent[0].data.r); - expect(utils.deepAccess(requestWithConsent, 'user.ext.consented_providers_settings')).to.not.exist; + const requestWithConsent = extractPayload(validBidWithConsent[0]); + expect(utils.deepAccess(requestWithConsent, 'user.ext.consented_providers_settings.addtl_consent')).to.not.exist; expect(utils.deepAccess(requestWithConsent, 'user.ext.consent')).to.not.exist; }); it('should set coppa to 1 in config when enabled', () => { config.setConfig({ coppa: true }) const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); - const r = JSON.parse(bid[0].data.r); + const r = extractPayload(bid[0]); expect(r.regs.coppa).to.equal(1); }); it('should not set coppa in config when disabled', () => { config.setConfig({ coppa: false }) const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); - const r = JSON.parse(bid[0].data.r); + const r = extractPayload(bid[0]); expect(r.regs.coppa).to.be.undefined; }); it('should not set coppa when not specified in config', () => { config.resetConfig(); const bid = spec.buildRequests(DEFAULT_BANNER_VALID_BID, DEFAULT_OPTION); - const r = JSON.parse(bid[0].data.r); + const r = extractPayload(bid[0]); expect(r.regs.coppa).to.be.undefined; }); }); - describe('LocalStorage ixdiag', () => { + describe('Features', () => { + let localStorageValues = {}; + let sandbox = sinon.sandbox.create(); + let setDataInLocalStorageStub; + let getDataFromLocalStorageStub; + let removeDataFromLocalStorageStub; + const serverResponse = { + body: { + ext: { + features: { + test: { + activated: false + } + } + } + } + }; + + beforeEach(() => { + localStorageValues = {}; + sandbox = sinon.sandbox.create(); + setDataInLocalStorageStub = sandbox.stub(storage, 'setDataInLocalStorage').callsFake((key, value) => localStorageValues[key] = value); + getDataFromLocalStorageStub = sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => localStorageValues[key]); + removeDataFromLocalStorageStub = sandbox.stub(storage, 'removeDataFromLocalStorage').callsFake((key) => delete localStorageValues[key]); + }); + + afterEach(() => { + setDataInLocalStorageStub.restore(); + getDataFromLocalStorageStub.restore(); + removeDataFromLocalStorageStub.restore(); + serverResponse.body.ext.features = { + test: { + activated: false + } + }; + localStorageValues = {}; + sandbox.restore(); + }); + + it('should store features in internal cache', () => { + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + expect(FEATURE_TOGGLES.isFeatureEnabled('test')).to.be.false; + }); + + it('should retrieve features from internal cache', () => { + const feature = { + ext: { + features: { + test: { + activated: true + } + } + } + } + FEATURE_TOGGLES.setFeatureToggles(feature); + feature.ext.features.test.activated = false; + FEATURE_TOGGLES.featureToggles = { + features: feature.ext.features + }; + expect(FEATURE_TOGGLES.isFeatureEnabled('test')).to.be.false; + }); + + it('should store features in localstorage when enabled', () => { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.test.activated = true; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + + const lsData = JSON.parse(storage.getDataFromLocalStorage(LOCAL_STORAGE_FEATURE_TOGGLES_KEY)); + expect(lsData.features.test.activated).to.be.true; + }); + + it('should retrive features from localstorage when enabled', () => { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.test.activated = true; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + FEATURE_TOGGLES.featureToggles = {}; + FEATURE_TOGGLES.getFeatureToggles(LOCAL_STORAGE_FEATURE_TOGGLES_KEY); + expect(FEATURE_TOGGLES.isFeatureEnabled('test')).to.be.true; + }); + + it('should remove features from after expiry', () => { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + const expiryTime = new Date(); + localStorageValues = { + expiry: expiryTime.setHours(expiryTime.getHours() - 2), + features: { + test: { + activated: true + } + } + } + FEATURE_TOGGLES.getFeatureToggles(LOCAL_STORAGE_FEATURE_TOGGLES_KEY); + expect(FEATURE_TOGGLES.isFeatureEnabled('test')).to.be.false; + expect(FEATURE_TOGGLES.featureToggles).to.deep.equal({}); + }); + + it('6 ad units should generate only 1 request if buildRequestV2 FT is enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.pbjs_use_buildRequestV2 = { + activated: true + }; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + + const bid1 = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid1.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; + bid1.params.siteId = '121'; + bid1.adUnitCode = 'div-gpt-1' + bid1.transactionId = 'tr1'; + bid1.bidId = '2f6g5s5e'; + + const bid2 = utils.deepClone(bid1); + bid2.transactionId = 'tr2'; + + const bid3 = utils.deepClone(bid1); + bid3.transactionId = 'tr3'; + + const bid4 = utils.deepClone(bid1); + bid4.transactionId = 'tr4'; + + const bid5 = utils.deepClone(bid1); + bid5.transactionId = 'tr5'; + + const bid6 = utils.deepClone(bid1); + bid6.transactionId = 'tr6'; + + const requests = spec.buildRequests([bid1, bid2, bid3, bid4, bid5, bid6], DEFAULT_OPTION); + + expect(requests).to.be.an('array'); + // buildRequestv2 enabled causes only 1 requests to get generated. + expect(requests).to.have.lengthOf(1); + for (let request of requests) { + expect(request.method).to.equal('POST'); + } + }); + + it('1 request with 2 ad units, buildRequestV2 enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features.pbjs_use_buildRequestV2 = { + activated: true + }; + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + bid.mediaTypes.banner.sizes = LARGE_SET_OF_SIZES; + bid.params.siteId = '124'; + bid.adUnitCode = 'div-gpt-1' + bid.transactionId = '152e36d1-1241-4242-t35e-y1dv34d12315'; + bid.bidId = '2f6g5s5e'; + + const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + expect(requests).to.be.an('array'); + expect(requests).to.have.lengthOf(1); + }); + + it('request should have requested feature toggles when local storage is enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + const r = extractPayload(requests[0]); + expect(r.ext.features).to.exist; + expect(Object.keys(r.ext.features).length).to.equal(FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES.length); + }); + + it('request should have requested feature toggles when local storage is not enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + const r = extractPayload(requests[0]); + expect(r.ext.features).to.exist; + expect(Object.keys(r.ext.features).length).to.equal(FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES.length); + }); + + it('request should not have any feature toggles when there is no requested feature toggle', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES = [] + const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + const r = extractPayload(requests[0]); + expect(r.ext.features).to.be.undefined; + }); + + it('request should not have any feature toggles when there is no requested feature toggle and local storage not enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + const r = extractPayload(requests[0]); + FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES = [] + expect(r.ext.features).to.be.undefined; + }); + + it('correct activation status of requested feature toggles when local storage not enabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + const bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES = ['test1'] + const requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + const r = extractPayload(requests[0]); + expect(r.ext.features).to.deep.equal({ + [FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES[0]]: { activated: false } + }); + }); + + it('correct activation status of requested feature toggles', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + serverResponse.body.ext.features = { + [FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES[0]]: { + activated: true + } + } + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + let bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + let requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + let r = extractPayload(requests[0]); + expect(r.ext.features).to.deep.equal({ + [FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES[0]]: { activated: true } + }); + + serverResponse.body.ext.features = { + [FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES[0]]: { + activated: false + } + } + FEATURE_TOGGLES.setFeatureToggles(serverResponse); + bid = utils.deepClone(DEFAULT_BANNER_VALID_BID[0]); + requests = spec.buildRequests([bid, DEFAULT_BANNER_VALID_BID[0]], DEFAULT_OPTION); + r = extractPayload(requests[0]); + expect(r.ext.features).to.deep.equal({ + [FEATURE_TOGGLES.REQUESTED_FEATURE_TOGGLES[0]]: { activated: false } + }); + }); + + describe('multiformat tests with enable multiformat ft enabled', () => { + let ftStub; + let validBids; + beforeEach(() => { + ftStub = sinon.stub(FEATURE_TOGGLES, 'isFeatureEnabled').callsFake((ftName) => { + if (ftName == 'pbjs_enable_multiformat') { + return true; + } + return false; + }); + validBids = DEFAULT_MULTIFORMAT_VALID_BID; + }); + + afterEach(() => { + ftStub.restore(); + validBids = DEFAULT_MULTIFORMAT_VALID_BID; + }); + + it('banner multiformat request, should generate banner imp', () => { + const request = spec.buildRequests(DEFAULT_MULTIFORMAT_BANNER_VALID_BID, {}) + const imp = extractPayload(request[0]).imp[0]; + const bannerImpression = imp.banner + expect(request).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(imp.id).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].bidId); + expect(bannerImpression.format[0].w).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].params.size[0]); + expect(bannerImpression.format[0].h).to.equal(DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0].params.size[1]); + }); + it('should generate video impression', () => { + const request = spec.buildRequests(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID, {}); + const imp = extractPayload(request[0]).imp[0]; + const videoImp = imp.video + expect(request).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(imp.id).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].bidId); + expect(videoImp.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.size[0]); + expect(videoImp.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.size[1]); + }); + it('different ad units, should only have 1 request', () => { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]]; + const request = spec.buildRequests(bids, {}); + expect(request).to.have.lengthOf(1); + }); + it('should return valid banner requests', function () { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]]; + const request = spec.buildRequests(bids, {}); + const impressions = extractPayload(request[0]).imp; + expect(impressions).to.have.lengthOf(2); + + expect(impressions[0].id).to.equal(bids[0].bidId); + expect(impressions[0].banner.format).to.be.length(bids[0].mediaTypes.banner.sizes.length); + expect(impressions[0].banner.topframe).to.be.oneOf([0, 1]); + expect(impressions[0].ext.siteID).to.equal('123'); + expect(impressions[1].ext.siteID).to.equal('456'); + impressions[0].banner.format.map(({ w, h, ext }, index) => { + const size = bids[0].mediaTypes.banner.sizes[index]; + + expect(w).to.equal(size[0]); + expect(h).to.equal(size[1]); + expect(ext.siteID).to.be.undefined; + }); + + impressions[1].banner.format.map(({ w, h, ext }, index) => { + const size = bids[1].mediaTypes.banner.sizes[index]; + + expect(w).to.equal(size[0]); + expect(h).to.equal(size[1]); + expect(ext.siteID).to.be.undefined; + }); + }); + it('banner / native multiformat request, only 1 request expect 1 imp', () => { + const request = spec.buildRequests(DEFAULT_MULTIFORMAT_NATIVE_VALID_BID, {}); + expect(request).to.have.lengthOf(1); + const imp = extractPayload(request[0]).imp[0]; + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(imp.banner).to.exist; + expect(imp.native).to.exist; + }); + + it('should return valid banner and video requests', function () { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]]; + const request = spec.buildRequests(bids, {}); + const videoImpression = extractPayload(request[0]).imp[1]; + + expect(extractPayload(request[0]).imp).to.have.lengthOf(2); + expect(videoImpression.id).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].bidId); + expect(videoImpression.video.w).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0][0]); + expect(videoImpression.video.h).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].mediaTypes.video.playerSize[0][1]); + }); + + it('multiformat banner / video - bid floors', function () { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]]; + bids[0].params.bidFloor = 2.35; + bids[0].params.bidFloorCur = 'USD'; + let adunitcode = bids[1].adUnitCode; + bids[1].adUnitCode = bids[0].adUnitCode; + bids[1].params.bidFloor = 2.05; + bids[1].params.bidFloorCur = 'USD'; + const request = spec.buildRequests(bids, {}); + + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp[0].bidfloor).to.equal(2.05); + expect(extractPayload(request[0]).imp[0].bidfloorcur).to.equal('USD'); + expect(extractPayload(request[0]).imp[0].video.ext.bidfloor).to.equal(2.05); + expect(extractPayload(request[0]).imp[0].banner.format[0].ext.bidfloor).to.equal(2.35); + bids[1].adUnitCode = adunitcode; + }); + + it('multiformat banner / native - bid floors', function () { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_NATIVE_VALID_BID[0]]; + bids[0].params.bidFloor = 2.35; + bids[0].params.bidFloorCur = 'USD'; + let adunitcode = bids[1].adUnitCode; + bids[1].adUnitCode = bids[0].adUnitCode; + bids[1].params.bidFloor = 2.05; + bids[1].params.bidFloorCur = 'USD'; + const request = spec.buildRequests(bids, {}); + + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp[0].bidfloor).to.equal(2.05); + expect(extractPayload(request[0]).imp[0].bidfloorcur).to.equal('USD'); + expect(extractPayload(request[0]).imp[0].native.ext.bidfloor).to.equal(2.05); + bids[1].adUnitCode = adunitcode; + }); + + it('multiformat banner / native - bid floors, banner imp less', function () { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_NATIVE_VALID_BID[0]]; + bids[0].params.bidFloor = 2.05; + bids[0].params.bidFloorCur = 'USD'; + let adunitcode = bids[1].adUnitCode; + bids[1].adUnitCode = bids[0].adUnitCode; + bids[1].params.bidFloor = 2.35; + bids[1].params.bidFloorCur = 'USD'; + const request = spec.buildRequests(bids, {}); + + expect(extractPayload(request[0]).imp).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp[0].bidfloor).to.equal(2.05); + expect(extractPayload(request[0]).imp[0].bidfloorcur).to.equal('USD'); + expect(extractPayload(request[0]).imp[0].native.ext.bidfloor).to.equal(2.35); + bids[1].adUnitCode = adunitcode; + }); + + it('should return valid banner and video requests, different adunit, creates multiimp request', function () { + let bid = DEFAULT_MULTIFORMAT_VALID_BID[0] + bid.bidId = '1abcdef' + const bids = [DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0], bid]; + const request = spec.buildRequests(bids, {}); + expect(request).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp).to.have.lengthOf(2); + }); + + it('should return valid video requests, different adunit, creates multiimp request', function () { + let bid = DEFAULT_BANNER_VALID_BID[0] + bid.bidId = '1abcdef' + const bids = [DEFAULT_VIDEO_VALID_BID[0], bid]; + const request = spec.buildRequests(bids, {}); + expect(request).to.have.lengthOf(1); + expect(extractPayload(request[0]).imp).to.have.lengthOf(2); + }); + + it('should contain all correct IXdiag properties', function () { + const bids = [DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]]; + const request = spec.buildRequests(bids, {}); + const diagObj = extractPayload(request[0]).ext.ixdiag; + expect(diagObj.iu).to.equal(0); + expect(diagObj.nu).to.equal(0); + expect(diagObj.ou).to.equal(2); + expect(diagObj.ren).to.equal(true); + expect(diagObj.mfu).to.equal(2); + expect(diagObj.allu).to.equal(2); + expect(diagObj.version).to.equal('$prebid.version$'); + expect(diagObj.url).to.equal('http://localhost:9876/context.html') + expect(diagObj.pbadslot).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].ortb2Imp.ext.data.pbadslot) + expect(diagObj.tagid).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].params.tagId) + expect(diagObj.adunitcode).to.equal(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0].adUnitCode) + }); + + it('should use siteId override for multiformat', function () { + validBids[0].params = { + tagId: '123', + siteId: '456', + size: [300, 250], + video: { + siteId: '1111' + }, + banner: { + siteId: '2222' + }, + native: { + siteId: '3333' + } + } + const request = spec.buildRequests(validBids, {}); + const imp = request[0].data.imp[0]; + expect(imp.ext.siteID).to.equal('2222'); + expect(imp.video.ext.siteID).to.be.undefined; + imp.banner.format.map(({ ext }) => { + expect(ext.siteID).to.be.undefined; + }); + expect(imp.native.ext.siteID).to.be.undefined; + }); + + it('should use default siteId if overrides are not provided for multiformat', function () { + const bids = validBids; + delete bids[0].params.banner; + delete bids[0].params.video; + delete bids[0].params.native; + const request = spec.buildRequests(bids, {}); + const imp = request[0].data.imp[0] + expect(imp.video.ext.siteID).to.be.undefined; + imp.banner.format.map(({ ext }) => { + expect(ext.siteID).to.be.undefined; + }); + expect(imp.native.ext.siteID).to.be.undefined; + expect(imp.ext.siteID).to.equal('456'); + }); + }); + }); + + describe('LocalStorage error codes', () => { let TODAY = new Date().toISOString().slice(0, 10); const key = 'ixdiag'; @@ -2736,7 +4274,7 @@ describe('IndexexchangeAdapter', function () { sandbox.restore(); config.setConfig({ - fpd: {}, + ortb2: {}, ix: {}, }) }); @@ -2787,49 +4325,6 @@ describe('IndexexchangeAdapter', function () { expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.BID_FLOOR_INVALID_FORMAT]: 1 } }); }); - it('should log ERROR_CODES.IX_FPD_EXCEEDS_MAX_SIZE in LocalStorage when there is logError called.', () => { - const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); - - config.setConfig({ - ix: { - firstPartyData: { - cd: Array(1700).join('#') - } - } - }); - - expect(spec.isBidRequestValid(bid)).to.be.true; - spec.buildRequests([bid]); - expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.IX_FPD_EXCEEDS_MAX_SIZE]: 2 } }); - }); - - it('should log ERROR_CODES.EXCEEDS_MAX_SIZE in LocalStorage when there is logError called.', () => { - const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); - bid.bidderRequestId = Array(8000).join('#'); - - expect(spec.isBidRequestValid(bid)).to.be.true; - spec.buildRequests([bid]); - expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.EXCEEDS_MAX_SIZE]: 2 } }); - }); - - it('should log ERROR_CODES.PB_FPD_EXCEEDS_MAX_SIZE in LocalStorage when there is logError called.', () => { - const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); - - config.setConfig({ - fpd: { - site: { - data: { - pageType: Array(5700).join('#') - } - } - } - }); - - expect(spec.isBidRequestValid(bid)).to.be.true; - spec.buildRequests([bid]); - expect(JSON.parse(localStorageValues[key])).to.deep.equal({ [TODAY]: { [ERROR_CODES.PB_FPD_EXCEEDS_MAX_SIZE]: 2 } }); - }); - it('should log ERROR_CODES.VIDEO_DURATION_INVALID in LocalStorage when there is logError called.', () => { const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); bid.params.video.minduration = 1; @@ -2880,30 +4375,24 @@ describe('IndexexchangeAdapter', function () { expect(spec.isBidRequestValid(request)).to.be.true; const data = { - ...utils.deepClone(DEFAULT_BIDDER_REQUEST_DATA[0]), - r: JSON.stringify({ - id: '345', - imp: [ - { - id: '1a2b3c4e', - } - ], - ext: { - ixdiag: { - err: { - '4': 8 - } + id: '345', + imp: [ + { + id: '1a2b3c4e', + } + ], + ext: { + ixdiag: { + err: { + '4': 8 } } - }), + } }; - const validBidRequests = [ - DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0], - DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0] - ]; + const validBidRequest = DEFAULT_MULTIFORMAT_BANNER_VALID_BID[0]; - spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data, validBidRequests }); + spec.interpretResponse({ body: DEFAULT_BANNER_BID_RESPONSE }, { data, validBidRequest }); expect(localStorageValues[key]).to.be.undefined; }); @@ -2924,10 +4413,553 @@ describe('IndexexchangeAdapter', function () { it('should not save error data into localstorage if consent is not given', () => { config.setConfig({ deviceAccess: false }); + storage.localStorageIsEnabled.restore(); // let core manage device access const bid = utils.deepClone(DEFAULT_MULTIFORMAT_VIDEO_VALID_BID[0]); bid.params.size = ['400', 100]; expect(spec.isBidRequestValid(bid)).to.be.false; expect(localStorageValues[key]).to.be.undefined; }); }); + describe('combine imps test', function () { + it('base test', function () { + const imps = [ + { + 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7': { + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7', + 'adUnitCode': 'div-gpt-v1', + 'missingImps': [ + { + 'id': '2e46cbd7d4e046', + 'ext': { + 'siteID': '12345' + }, + 'banner': { + 'w': 300, + 'h': 250, + 'topframe': 1 + } + } + ], + 'missingCount': 1 + } + }, + { + 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7': { + 'ixImps': [ + { + 'id': '2e46cbd7d4e046', + 'ext': { + 'siteID': '12345', + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7' + }, + 'video': { + 'skipppable': false, + 'playback_methods': [ + 'auto_play_sound_off' + ], + 'minduration': 0, + 'maxduration': 30, + 'mimes': [ + 'video/mp4', + 'video/x-flv' + ], + 'placement': 1, + 'playerSize': [ + [ + 640, + 480 + ] + ], + 'protocols': [ + 6 + ], + 'w': 640, + 'h': 480, + 'ext': { + 'siteID': '12345', + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7' + } + } + }, + ], + 'adUnitCode': 'div-gpt-v1' + } + }, + { + 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7': { + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7', + 'adUnitCode': 'div-gpt-v1', + 'missingImps': [ + { + 'id': '2e46cbd7d4e046', + 'ext': { + 'siteID': '12345' + }, + 'banner': { + 'w': 300, + 'h': 250, + 'topframe': 1 + } + } + ], + 'missingCount': 1 + } + } + ] + const result = combineImps(imps); + expect(result['b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7'].ixImps.length).to.equal(1) + expect(result['b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7'].missingImps.length).to.equal(2); + }); + it('switch order', function () { + const imps = [ + { + 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7': { + 'ixImps': [ + { + 'id': '2e46cbd7d4e046', + 'ext': { + 'siteID': '12345', + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7' + }, + 'video': { + 'skipppable': false, + 'playback_methods': [ + 'auto_play_sound_off' + ], + 'minduration': 0, + 'maxduration': 30, + 'mimes': [ + 'video/mp4', + 'video/x-flv' + ], + 'placement': 1, + 'playerSize': [ + [ + 640, + 480 + ] + ], + 'protocols': [ + 6 + ], + 'w': 640, + 'h': 480, + 'ext': { + 'siteID': '12345', + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7' + } + } + }, + ], + 'adUnitCode': 'div-gpt-v1' + } + }, + { + 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7': { + 'tid': 'b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7', + 'adUnitCode': 'div-gpt-v1', + 'missingImps': [ + { + 'id': '2e46cbd7d4e046', + 'ext': { + 'siteID': '12345' + }, + 'banner': { + 'w': 300, + 'h': 250, + 'topframe': 1 + } + } + ], + 'missingCount': 1 + } + } + ] + const result = combineImps(imps) + expect(result['b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7'].missingImps.length).to.equal(1); + expect(result['b8c6b5d5-76a1-4a90-b635-0c7eae1bfaa7'].ixImps.length).to.equal(1); + }); + }); + describe('apply floors test', function () { + it('video test', function() { + const bid = utils.deepClone(DEFAULT_VIDEO_VALID_BID[0]); + bid.params.bidFloor = 50; + bid.params.bidFloorCur = 'USD'; + const imp = bidToVideoImp(bid); + expect(imp.video.ext.bidfloor).to.equal(50); + expect(imp.bidfloor).to.equal(50); + expect(imp.bidfloorcur).to.equal('USD'); + expect(imp.video.ext.fl).to.equal('x'); + }); + it('native test', function() { + const bid = utils.deepClone(DEFAULT_NATIVE_VALID_BID[0]); + bid.params.bidFloor = 50; + bid.params.bidFloorCur = 'USD'; + const imp = bidToNativeImp(bid); + expect(imp.native.ext.bidfloor).to.equal(50); + expect(imp.bidfloor).to.equal(50); + expect(imp.bidfloorcur).to.equal('USD'); + expect(imp.native.ext.fl).to.equal('x'); + }); + }); + + describe('deduplicateImpExtFields', () => { + it('should remove duplicate keys from banner.ext', () => { + const input = { + imp: [ + { + banner: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + key4: 'value4', // duplicate value + }, + }, + video: { + ext: { + key4: 'value4', // duplicate value + } + }, + ext: { + key4: 'value4' + } + }, + ], + }; + + const expectedOutput = { + imp: [ + { + banner: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + }, + }, + ext: { + key4: 'value4' + }, + video: { + ext: {} + }, + }, + ], + }; + + const result = deduplicateImpExtFields(input); + expect(result).to.deep.equal(expectedOutput); + }); + + it('should remove duplicate keys from banner.format[].ext', () => { + const input = { + imp: [ + { + banner: { + format: [ + { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + key4: 'value4', // duplicate value + }, + }, + ], + }, + video: { + ext: { + key4: 'value4', // duplicate value + } + }, + ext: { + key4: 'value4' + } + }, + ], + }; + + const expectedOutput = { + imp: [ + { + banner: { + format: [ + { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + }, + }, + ], + }, + video: { + ext: {} + }, + ext: { + key4: 'value4' + } + }, + ], + }; + + const result = deduplicateImpExtFields(input); + expect(result).to.deep.equal(expectedOutput); + }); + + it('should remove duplicate keys from video.ext', () => { + const input = { + imp: [ + { + video: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + key4: 'value4', // duplicate value + }, + }, + banner: { + ext: { + key1: 'value1', + } + }, + ext: { + key4: 'value4' + } + }, + ], + }; + + const expectedOutput = { + imp: [ + { + video: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + }, + }, + banner: { + ext: { + key1: 'value1', + } + }, + ext: { + key4: 'value4' + } + }, + ], + }; + + const result = deduplicateImpExtFields(input); + expect(result).to.deep.equal(expectedOutput); + }); + + it('should remove duplicate keys from native.ext', () => { + const input = { + imp: [ + { + native: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + key4: 'value4', // duplicate value + }, + }, + banner: { + ext: { + key1: 'value1', + } + }, + ext: { + key4: 'value4' + } + }, + ], + }; + + const expectedOutput = { + imp: [ + { + native: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + }, + }, + banner: { + ext: { + key1: 'value1', + } + }, + ext: { + key4: 'value4' + } + } + ], + }; + + const result = deduplicateImpExtFields(input); + expect(result).to.deep.equal(expectedOutput); + }); + + it('should return the input unchanged when there is no imp.ext', () => { + const input = { + imp: [ + { + banner: { + ext: { + key1: 'value1', + key2: 'value2', + key3: 'value3', + }, + }, + video: { + ext: { + key4: 'value4', + key5: 'value5', + key6: 'value6', + }, + }, + native: { + ext: { + key7: 'value7', + key8: 'value8', + key9: 'value9', + }, + }, + }, + ], + }; + + const result = deduplicateImpExtFields(input); + expect(result).to.deep.equal(input); + }); + }); + + describe('removeSiteIDs', () => { + it('should remove siteIDs from banner / video / native format', () => { + const request = { + imp: [ + { + banner: { + format: [ + { + ext: { + siteID: '123' + } + }, + { + ext: { + siteID: '123' + } + } + ], + ext: { + siteID: '123' + } + }, + video: { + ext: { + siteID: '123' + } + }, + native: { + ext: { + siteID: '123' + } + }, + ext: { + siteID: '123' + } + } + ] + }; + + const expected = { + ext: { + ixdiag: { + usid: true + } + }, + imp: [ + { + banner: { + format: [ + { + ext: {} + }, + { + ext: {} + } + ], + ext: {} + }, + video: { + ext: {} + }, + native: { + ext: {} + }, + ext: { + 'siteID': '123' + } + } + ] + }; + + expect(removeSiteIDs(request)).to.deep.equal(expected); + }); + + it('should not modify the request when imp.ext is not present', () => { + const request = { + imp: [ + { + banner: { + ext: { + siteID: '123' + } + } + } + ] + }; + + const expected = { + imp: [ + { + banner: { + ext: { + siteID: '123' + } + }, + } + ] + }; + + expect(removeSiteIDs(request)).to.deep.equal(expected); + }); + }); + describe('addDeviceInfo', () => { + it('should add device to request when device already exists', () => { + let r = { + device: { + ip: '127.0.0.1' + } + } + r = addDeviceInfo(r); + expect(r.device.w).to.exist; + expect(r.device.h).to.exist; + }); + it('should add device to request when device doesnt exist', () => { + let r = {} + r = addDeviceInfo(r); + expect(r.device.w).to.exist; + expect(r.device.h).to.exist; + }); + }); }); diff --git a/test/spec/modules/jixieBidAdapter_spec.js b/test/spec/modules/jixieBidAdapter_spec.js index 68de5c7a8fd..fd0d7e8a033 100644 --- a/test/spec/modules/jixieBidAdapter_spec.js +++ b/test/spec/modules/jixieBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { spec, internal as jixieaux, storage } from 'modules/jixieBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import { config } from 'src/config.js'; +import { deepClone } from 'src/utils.js'; describe('jixie Adapter', function () { const pageurl_ = 'https://testdomain.com/testpage.html'; @@ -71,6 +72,17 @@ describe('jixie Adapter', function () { const clientIdTest1_ = '1aba6a40-f711-11e9-868c-53a2ae972xxx'; const sessionIdTest1_ = '1594782644-1aba6a40-f711-11e9-868c-53a2ae972xxx'; + const jxtokoTest1_ = 'eyJJRCI6ImFiYyJ9'; + const jxifoTest1_ = 'fffffbbbbbcccccaaaaae890606aaaaa'; + const jxtdidTest1_ = '222223d1-1111-2222-3333-b9f129299999'; + const jxcompTest1_ = 'AAAAABBBBBCCCCCDDDDDEEEEEUkkZPQfifpkPnnlJhtsa4o+gf4nfqgN5qHiTVX73ymTSbLT9jz1nf+Q7QdxNh9nTad9UaN5pzfHMt/rs1woQw72c1ip+8heZXPfKGZtZP7ldJesYhlo3/0FVcL/wl9ZlAo1jYOEfHo7Y9zFzNXABbbbbb=='; + + const refJxEids_ = { + '_jxtoko': jxtokoTest1_, + '_jxifo': jxifoTest1_, + '_jxtdid': jxtdidTest1_, + '_jxcomp': jxcompTest1_ + }; // to serve as the object that prebid will call jixie buildRequest with: (param2) const bidderRequest_ = { @@ -89,7 +101,12 @@ describe('jixie Adapter', function () { 'adUnitCode': adUnitCode0_, 'bidId': bidId0_, 'bidderRequestId': bidderRequestId_, - 'auctionId': auctionId_ + 'auctionId': auctionId_, + 'ortb2Imp': { + 'ext': { + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-1' + } + } }, { 'bidder': 'jixie', @@ -108,7 +125,12 @@ describe('jixie Adapter', function () { 'adUnitCode': adUnitCode1_, 'bidId': bidId1_, 'bidderRequestId': bidderRequestId_, - 'auctionId': auctionId_ + 'auctionId': auctionId_, + 'ortb2Imp': { + 'ext': { + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-2' + } + } }, { 'bidder': 'jixie', @@ -127,7 +149,12 @@ describe('jixie Adapter', function () { 'adUnitCode': adUnitCode2_, 'bidId': bidId2_, 'bidderRequestId': bidderRequestId_, - 'auctionId': auctionId_ + 'auctionId': auctionId_, + 'ortb2Imp': { + 'ext': { + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-3' + } + } } ]; @@ -140,7 +167,8 @@ describe('jixie Adapter', function () { 'sizes': [[300, 250], [300, 600]], 'params': { 'unit': 'prebidsampleunit' - } + }, + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-1' }, { 'bidId': bidId1_, @@ -156,7 +184,8 @@ describe('jixie Adapter', function () { 'sizes': [[300, 250]], 'params': { 'unit': 'prebidsampleunit' - } + }, + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-2' }, { 'bidId': bidId2_, @@ -172,7 +201,8 @@ describe('jixie Adapter', function () { 'sizes': [[300, 250], [300, 600]], 'params': { 'unit': 'prebidsampleunit' - } + }, + 'gpid': 'SUPERNEWS#DESKTOP#div-gpt-ad-Top_1-3' } ]; @@ -199,16 +229,28 @@ describe('jixie Adapter', function () { let getCookieStub = sinon.stub(storage, 'getCookie'); let getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); getCookieStub - .withArgs('_jx') + .withArgs('_jxtoko') + .returns(jxtokoTest1_); + getCookieStub + .withArgs('_jxifo') + .returns(jxifoTest1_); + getCookieStub + .withArgs('_jxtdid') + .returns(jxtdidTest1_); + getCookieStub + .withArgs('_jxcomp') + .returns(jxcompTest1_); + getCookieStub + .withArgs('_jxx') .returns(clientIdTest1_); getCookieStub - .withArgs('_jxs') + .withArgs('_jxxs') .returns(sessionIdTest1_); getLocalStorageStub - .withArgs('_jx') + .withArgs('_jxx') .returns(clientIdTest1_); getLocalStorageStub - .withArgs('_jxs') + .withArgs('_jxxs') .returns(sessionIdTest1_ ); let miscDimsStub = sinon.stub(jixieaux, 'getMiscDims'); @@ -220,6 +262,7 @@ describe('jixie Adapter', function () { it('sends bid request to ENDPOINT via POST', function () { expect(request.method).to.equal('POST') }) + expect(request.data).to.be.an('string'); const payload = JSON.parse(request.data); expect(payload).to.have.property('auctionid', auctionId_); @@ -227,6 +270,7 @@ describe('jixie Adapter', function () { expect(payload).to.have.property('client_id_ls', clientIdTest1_); expect(payload).to.have.property('session_id_c', sessionIdTest1_); expect(payload).to.have.property('session_id_ls', sessionIdTest1_); + expect(payload).to.have.property('jxeids').that.deep.equals(refJxEids_); expect(payload).to.have.property('device', device_); expect(payload).to.have.property('domain', domain_); expect(payload).to.have.property('pageurl', pageurl_); @@ -240,6 +284,134 @@ describe('jixie Adapter', function () { getLocalStorageStub.restore(); miscDimsStub.restore(); });// it + + it('it should popular the pricegranularity when info is available', function () { + let content = { + 'ranges': [{ + 'max': 12, + 'increment': 0.5 + }, + { + 'max': 5, + 'increment': 0.1 + }], + precision: 1 + }; + let getConfigStub = sinon.stub(config, 'getConfig'); + getConfigStub.callsFake(function fakeFn(prop) { + if (prop == 'priceGranularity') { + return content; + } + return null; + }); + + const oneSpecialBidReq = Object.assign({}, bidRequests_[0]); + const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + const payload = JSON.parse(request.data); + getConfigStub.restore(); + expect(payload.pricegranularity).to.deep.include(content); + }); + + it('it should popular the device info when it is available', function () { + let getConfigStub = sinon.stub(config, 'getConfig'); + let content = {w: 500, h: 400}; + getConfigStub.callsFake(function fakeFn(prop) { + if (prop == 'device') { + return content; + } + return null; + }); + const oneSpecialBidReq = Object.assign({}, bidRequests_[0]); + const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + const payload = JSON.parse(request.data); + getConfigStub.restore(); + expect(payload.device).to.have.property('ua', navigator.userAgent); + expect(payload.device).to.deep.include(content); + }); + + it('schain info should be accessible when available', function () { + const schain = { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'ssp.test', + sid: '00001', + hp: 1 + }] + }; + const oneSpecialBidReq = Object.assign({}, bidRequests_[0], { schain: schain }); + const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + const payload = JSON.parse(request.data); + expect(payload.schain).to.deep.equal(schain); + expect(payload.schain).to.deep.include(schain); + }); + + it('it should populate the floor info when available', function () { + let oneSpecialBidReq = deepClone(bidRequests_[0]); + let request, payload = null; + // 1 floor is not set + request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + payload = JSON.parse(request.data); + expect(payload.bids[0].bidFloor).to.not.exist; + + // 2 floor is set + let getFloorResponse = { currency: 'USD', floor: 2.1 }; + oneSpecialBidReq.getFloor = () => getFloorResponse; + request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + payload = JSON.parse(request.data); + expect(payload.bids[0].bidFloor).to.exist.and.to.equal(2.1); + }); + + it('should populate eids when supported userIds are available', function () { + const oneSpecialBidReq = Object.assign({}, bidRequests_[0], { + userIdAsEids: [ + { + 'source': 'adserver.org', + 'uids': [ + { + 'id': '11111111-2222-3333-4444-555555555555', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + } + ] + }, + { + 'source': 'uidapi.com', + 'uids': [ + { + 'id': 'AbCdEfGhIjKlMnO9qdQBW7qtMw8f1WTUvtkHe6u+fqLfhbtsqrJ697Z6YoI3IB9klGUv1wvlFIbwH7ELDlqQBGtj8AC1v7fMJ/Q45E7W90dts7UQLTDMLNmtHBRDXVb0Fpas4Vh3yN1jGVQNhzXC/RpGIVtZE8dCxcjfa7VfcTNcvxxxxx==', + 'atype': 3 + } + ] + }, + { + 'source': 'puburl1.com', + 'uids': [ + { + 'id': 'pubid1', + 'atype': 1, + 'ext': { + 'stype': 'ppuid' + } + } + ] + }, + { + 'source': 'puburl2.com', + 'uids': [ + { + 'id': 'pubid2' + } + ] + }, + ], + }); + const request = spec.buildRequests([oneSpecialBidReq], bidderRequest_); + const payload = JSON.parse(request.data); + expect(payload.eids).to.eql(oneSpecialBidReq.userIdAsEids); + }); });// describe /** @@ -398,10 +570,10 @@ describe('jixie Adapter', function () { let setCookieSpy = sinon.spy(storage, 'setCookie'); let setLocalStorageSpy = sinon.spy(storage, 'setDataInLocalStorage'); const result = spec.interpretResponse({body: responseBody_}, requestObj_) - expect(setLocalStorageSpy.calledWith('_jx', '43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); - expect(setLocalStorageSpy.calledWith('_jxs', '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); - expect(setCookieSpy.calledWith('_jxs', '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); - expect(setCookieSpy.calledWith('_jx', '43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); + expect(setLocalStorageSpy.calledWith('_jxx', '43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); + expect(setLocalStorageSpy.calledWith('_jxxs', '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); + expect(setCookieSpy.calledWith('_jxxs', '1600057934-43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); + expect(setCookieSpy.calledWith('_jxx', '43aacc10-f643-11ea-8a10-c5fe2d394e7e')).to.equal(true); // video ad with vastUrl returned by adserver expect(result[0].requestId).to.equal('62847e4c696edcb') diff --git a/test/spec/modules/jwplayerRtdProvider_spec.js b/test/spec/modules/jwplayerRtdProvider_spec.js index db17d18864b..4638595e0d6 100644 --- a/test/spec/modules/jwplayerRtdProvider_spec.js +++ b/test/spec/modules/jwplayerRtdProvider_spec.js @@ -1,8 +1,20 @@ -import { fetchTargetingForMediaId, getVatFromCache, extractPublisherParams, - formatTargetingResponse, getVatFromPlayer, enrichAdUnits, addTargetingToBid, - fetchTargetingInformation, jwplayerSubmodule, getContentId, getContentData } from 'modules/jwplayerRtdProvider.js'; -import { server } from 'test/mocks/xhr.js'; -import {addOrtbSiteContent} from '../../../modules/jwplayerRtdProvider'; +import { + addOrtbSiteContent, + addTargetingToBid, + enrichAdUnits, + extractPublisherParams, + fetchTargetingForMediaId, + fetchTargetingInformation, + formatTargetingResponse, + getContentData, + getContentId, + getContentSegments, + getVatFromCache, + getVatFromPlayer, + jwplayerSubmodule +} from 'modules/jwplayerRtdProvider.js'; +import {server} from 'test/mocks/xhr.js'; +import {deepClone} from '../../../src/utils.js'; describe('jwplayerRtdProvider', function() { const testIdForSuccess = 'test_id_for_success'; @@ -222,9 +234,6 @@ describe('jwplayerRtdProvider', function() { describe('Get Bid Request Data', function () { it('executes immediately while request is active if player has item', function () { const bidRequestSpy = sinon.spy(); - const fakeServer = sinon.createFakeServer(); - fakeServer.respondImmediately = false; - fakeServer.autoRespond = false; fetchTargetingForMediaId(mediaIdWithSegment); @@ -254,7 +263,7 @@ describe('jwplayerRtdProvider', function() { jwplayerSubmodule.getBidRequestData({ adUnits: [adUnit] }, bidRequestSpy); expect(bidRequestSpy.calledOnce).to.be.true; expect(bid.rtd.jwplayer).to.have.deep.property('targeting', expectedTargeting); - fakeServer.respond(); + server.respond(); expect(bidRequestSpy.calledOnce).to.be.true; }); }); @@ -270,22 +279,17 @@ describe('jwplayerRtdProvider', function() { } }; let bidRequestSpy; - let fakeServer; let clock; beforeEach(function () { bidRequestSpy = sinon.spy(); - fakeServer = sinon.createFakeServer(); - fakeServer.respondImmediately = false; - fakeServer.autoRespond = false; - clock = sinon.useFakeTimers(); }); afterEach(function () { clock.restore(); - fakeServer.respond(); + server.respond(); }); it('adds targeting when pending request succeeds', function () { @@ -317,7 +321,7 @@ describe('jwplayerRtdProvider', function() { expect(bid1).to.not.have.property('rtd'); expect(bid2).to.not.have.property('rtd'); - const request = fakeServer.requests[0]; + const request = server.requests[0]; request.respond( 200, responseHeader, @@ -357,7 +361,7 @@ describe('jwplayerRtdProvider', function() { }, bids }; - const request = fakeServer.requests[0]; + const request = server.requests[0]; request.respond( 200, responseHeader, @@ -411,6 +415,151 @@ describe('jwplayerRtdProvider', function() { expect(bid1.rtd.jwplayer).to.have.deep.property('targeting', expectedTargetingForFailure); expect(bid2.rtd.jwplayer).to.have.deep.property('targeting', expectedTargetingForFailure); }); + + it('should write to config', function () { + fetchTargetingForMediaId(testIdForSuccess); + const bids = [ + { + id: 'bid1' + }, + { + id: 'bid2' + } + ]; + const adUnit = { + ortb2Imp: { + ext: { + data: { + jwTargeting: { + mediaID: testIdForSuccess + } + } + } + }, + bids + }; + + const ortb2Fragments = {global: {}}; + enrichAdUnits([adUnit], ortb2Fragments); + const bid1 = bids[0]; + const bid2 = bids[1]; + expect(bid1).to.not.have.property('rtd'); + expect(bid2).to.not.have.property('rtd'); + + const request = server.requests[0]; + request.respond( + 200, + responseHeader, + JSON.stringify({ + playlist: [ + { + file: 'test.mp4', + jwpseg: validSegments + } + ] + }) + ); + + expect(ortb2Fragments.global).to.have.property('site'); + expect(ortb2Fragments.global.site).to.have.property('content'); + expect(ortb2Fragments.global.site.content).to.have.property('id', 'jw_' + testIdForSuccess); + expect(ortb2Fragments.global.site.content).to.have.property('data'); + const data = ortb2Fragments.global.site.content.data; + expect(data).to.have.length(1); + const datum = data[0]; + expect(datum).to.have.property('name', 'jwplayer.com'); + expect(datum).to.have.property('ext'); + expect(datum.ext).to.have.property('segtax', 502); + expect(datum.segment).to.have.length(2); + const segment1 = datum.segment[0]; + const segment2 = datum.segment[1]; + expect(segment1).to.have.property('id', 'test_seg_1'); + expect(segment2).to.have.property('id', 'test_seg_2'); + }); + + it('should remove obsolete jwplayer data', function () { + fetchTargetingForMediaId(testIdForSuccess); + const bids = [ + { + id: 'bid1' + } + ]; + const adUnit = { + ortb2Imp: { + ext: { + data: { + jwTargeting: { + mediaID: testIdForSuccess + } + } + } + }, + bids + }; + + const ortb2Fragments = { + global: { + site: { + content: { + id: 'randomContentId', + data: [{ + name: 'random', + segment: [{id: 'random'}] + }, { + name: 'jwplayer.com', + segment: [{id: 'randomJwPlayer'}] + }, { + name: 'random2', + segment: [{id: 'random2'}] + }] + } + } + } + }; + + enrichAdUnits([adUnit], ortb2Fragments); + const bid1 = bids[0]; + expect(bid1).to.not.have.property('rtd'); + + const request = server.requests[0]; + request.respond( + 200, + responseHeader, + JSON.stringify({ + playlist: [ + { + file: 'test.mp4', + jwpseg: validSegments + } + ] + }) + ); + + expect(ortb2Fragments.global).to.have.property('site'); + expect(ortb2Fragments.global.site).to.have.property('content'); + expect(ortb2Fragments.global.site.content).to.have.property('id', 'jw_' + testIdForSuccess); + expect(ortb2Fragments.global.site.content).to.have.property('data'); + const data = ortb2Fragments.global.site.content.data; + expect(data).to.have.length(3); + + const randomDatum = data[0]; + expect(randomDatum).to.have.property('name', 'random'); + expect(randomDatum.segment).to.deep.equal([{id: 'random'}]); + + const randomDatum2 = data[1]; + expect(randomDatum2).to.have.property('name', 'random2'); + expect(randomDatum2.segment).to.deep.equal([{id: 'random2'}]); + + const jwplayerDatum = data[2]; + expect(jwplayerDatum).to.have.property('name', 'jwplayer.com'); + expect(jwplayerDatum).to.have.property('ext'); + expect(jwplayerDatum.ext).to.have.property('segtax', 502); + expect(jwplayerDatum.segment).to.have.length(2); + const segment1 = jwplayerDatum.segment[0]; + const segment2 = jwplayerDatum.segment[1]; + expect(segment1).to.have.property('id', 'test_seg_1'); + expect(segment2).to.have.property('id', 'test_seg_2'); + }); }); describe('Extract Publisher Params', function () { @@ -498,178 +647,201 @@ describe('jwplayerRtdProvider', function() { }); }); - describe('Get Content Data', function () { + describe('Get Content Segments', function () { it('returns undefined when segments are empty', function () { - let data = getContentData(null); - expect(data).to.be.undefined; - data = getContentData(undefined); - expect(data).to.be.undefined; - data = getContentData([]); - expect(data).to.be.undefined; + let contentSegments = getContentSegments(null); + expect(contentSegments).to.be.undefined; + contentSegments = getContentSegments(undefined); + expect(contentSegments).to.be.undefined; + contentSegments = getContentSegments([]); + expect(contentSegments).to.be.undefined; }); it('returns proper format', function () { const segment1 = 'segment1'; const segment2 = 'segment2'; const segment3 = 'segment3'; - const data = getContentData([segment1, segment2, segment3]); - expect(data).to.have.property('name', 'jwplayer'); - expect(data.ext).to.have.property('segtax', 502); - expect(data.segment[0]).to.deep.equal({ id: segment1, value: segment1 }); - expect(data.segment[1]).to.deep.equal({ id: segment2, value: segment2 }); - expect(data.segment[2]).to.deep.equal({ id: segment3, value: segment3 }); + const contentSegments = getContentSegments([segment1, segment2, segment3]); + expect(contentSegments[0]).to.deep.equal({ id: segment1 }); + expect(contentSegments[1]).to.deep.equal({ id: segment2 }); + expect(contentSegments[2]).to.deep.equal({ id: segment3 }); + }); + }); + + describe('Get Content Data', function () { + it('should return proper format', function () { + const testMediaId = 'test_media_id'; + const testSegments = [{ id: 1 }, { id: 2 }]; + const contentData = getContentData(testMediaId, testSegments); + expect(contentData).to.have.property('name', 'jwplayer.com'); + expect(contentData.ext).to.have.property('segtax', 502); + expect(contentData.ext).to.have.property('cids'); + expect(contentData.ext.cids).to.have.length(1); + expect(contentData.ext.cids[0]).to.equal(testMediaId); + expect(contentData.segment).to.deep.equal(testSegments); + }); + + it('should only set segtax and segment when segments are provided', function () { + const testMediaId = 'test_media_id'; + const contentData = getContentData(testMediaId); + expect(contentData).to.have.property('name', 'jwplayer.com'); + expect(contentData.ext.segtax).to.be.undefined; + expect(contentData.ext).to.have.property('cids'); + expect(contentData.ext.cids).to.have.length(1); + expect(contentData.ext.cids[0]).to.equal(testMediaId); + expect(contentData.segment).to.be.undefined; + }); + + it('should only set cids when a media id is provided', function () { + const testSegments = [{ id: 1 }, { id: 2 }]; + const contentData = getContentData(null, testSegments); + expect(contentData).to.have.property('name', 'jwplayer.com'); + expect(contentData.ext).to.have.property('segtax', 502); + expect(contentData.ext).to.not.have.property('cids'); + expect(contentData.segment).to.deep.equal(testSegments); + }); + + it('should return undefined when no params are provided', function () { + expect(getContentData()).to.be.undefined; }); }); describe(' Add Ortb Site Content', function () { it('should maintain object structure when id and data params are empty', function () { - const bid = { - ortb2: { - site: { - content: { - id: 'randomId' - }, - random: { - random_sub: 'randomSub' - } + const ortb2 = { + site: { + content: { + id: 'randomId' }, - app: { - content: { - id: 'appId' - } + random: { + random_sub: 'randomSub' + } + }, + app: { + content: { + id: 'appId' } } - }; - addOrtbSiteContent(bid); - expect(bid).to.have.nested.property('ortb2.site.content.id', 'randomId'); - expect(bid).to.have.nested.property('ortb2.site.random.random_sub', 'randomSub'); - expect(bid).to.have.nested.property('ortb2.app.content.id', 'appId'); + } + const copy = deepClone(ortb2); + addOrtbSiteContent(copy); + expect(copy).to.eql(ortb2); }); it('should create a structure compliant with the oRTB 2 spec', function() { - const bid = {}; + const ortb2 = {} const expectedId = 'expectedId'; const expectedData = { datum: 'datum' }; - addOrtbSiteContent(bid, expectedId, expectedData); - expect(bid).to.have.nested.property('ortb2.site.content.id', expectedId); - expect(bid).to.have.nested.property('ortb2.site.content.data'); - expect(bid.ortb2.site.content.data[0]).to.be.deep.equal(expectedData); + addOrtbSiteContent(ortb2, expectedId, expectedData); + expect(ortb2).to.have.nested.property('site.content.id', expectedId); + expect(ortb2).to.have.nested.property('site.content.data'); + expect(ortb2.site.content.data[0]).to.be.deep.equal(expectedData); }); it('should respect existing structure when adding adding fields', function () { - const bid = { - ortb2: { - site: { - content: { - id: 'oldId' - }, - random: { - random_sub: 'randomSub' - } + const ortb2 = { + site: { + content: { + id: 'oldId' }, - app: { - content: { - id: 'appId' - } + random: { + random_sub: 'randomSub' + } + }, + app: { + content: { + id: 'appId' } } }; const expectedId = 'expectedId'; const expectedData = { datum: 'datum' }; - addOrtbSiteContent(bid, expectedId, expectedData); - expect(bid).to.have.nested.property('ortb2.site.random.random_sub', 'randomSub'); - expect(bid).to.have.nested.property('ortb2.app.content.id', 'appId'); - expect(bid).to.have.nested.property('ortb2.site.content.id', expectedId); - expect(bid).to.have.nested.property('ortb2.site.content.data'); - expect(bid.ortb2.site.content.data[0]).to.be.deep.equal(expectedData); + addOrtbSiteContent(ortb2, expectedId, expectedData); + expect(ortb2).to.have.nested.property('site.random.random_sub', 'randomSub'); + expect(ortb2).to.have.nested.property('app.content.id', 'appId'); + expect(ortb2).to.have.nested.property('site.content.id', expectedId); + expect(ortb2).to.have.nested.property('site.content.data'); + expect(ortb2.site.content.data[0]).to.be.deep.equal(expectedData); }); it('should set content id', function () { - const bid = {}; + const ortb2 = {}; const expectedId = 'expectedId'; - addOrtbSiteContent(bid, expectedId); - expect(bid).to.have.nested.property('ortb2.site.content.id', expectedId); + addOrtbSiteContent(ortb2, expectedId); + expect(ortb2).to.have.nested.property('site.content.id', expectedId); }); it('should override content id', function () { - const bid = { - ortb2: { - site: { - content: { - id: 'oldId' - } + const ortb2 = { + site: { + content: { + id: 'oldId' } } }; const expectedId = 'expectedId'; - addOrtbSiteContent(bid, expectedId); - expect(bid).to.have.nested.property('ortb2.site.content.id', expectedId); + addOrtbSiteContent(ortb2, expectedId); + expect(ortb2).to.have.nested.property('site.content.id', expectedId); }); it('should keep previous content id when not set', function () { const previousId = 'oldId'; - const bid = { - ortb2: { - site: { - content: { - id: previousId, - data: [{ datum: 'first_datum' }] - } + const ortb2 = { + site: { + content: { + id: previousId, + data: [{ datum: 'first_datum' }] } } }; - addOrtbSiteContent(bid, null, { datum: 'new_datum' }); - expect(bid).to.have.nested.property('ortb2.site.content.id', previousId); + addOrtbSiteContent(ortb2, null, { datum: 'new_datum' }); + expect(ortb2).to.have.nested.property('site.content.id', previousId); }); it('should set content data', function () { - const bid = {}; + const ortb2 = {}; const expectedData = { datum: 'datum' }; - addOrtbSiteContent(bid, null, expectedData); - expect(bid).to.have.nested.property('ortb2.site.content.data'); - expect(bid.ortb2.site.content.data).to.have.length(1); - expect(bid.ortb2.site.content.data[0]).to.be.deep.equal(expectedData); + addOrtbSiteContent(ortb2, null, expectedData); + expect(ortb2).to.have.nested.property('site.content.data'); + expect(ortb2.site.content.data).to.have.length(1); + expect(ortb2.site.content.data[0]).to.be.deep.equal(expectedData); }); it('should append content data', function () { - const bid = { - ortb2: { - site: { - content: { - data: [{ datum: 'first_datum' }] - } + const ortb2 = { + site: { + content: { + data: [{ datum: 'first_datum' }] } } }; const expectedData = { datum: 'datum' }; - addOrtbSiteContent(bid, null, expectedData); - expect(bid).to.have.nested.property('ortb2.site.content.data'); - expect(bid.ortb2.site.content.data).to.have.length(2); - expect(bid.ortb2.site.content.data.pop()).to.be.deep.equal(expectedData); + addOrtbSiteContent(ortb2, null, expectedData); + expect(ortb2).to.have.nested.property('site.content.data'); + expect(ortb2.site.content.data).to.have.length(2); + expect(ortb2.site.content.data.pop()).to.be.deep.equal(expectedData); }); it('should keep previous data when not set', function () { const expectedId = 'expectedId'; const expectedData = { datum: 'first_datum' }; - const bid = { - ortb2: { - site: { - content: { - data: [expectedData] - } + const ortb2 = { + site: { + content: { + data: [expectedData] } } }; - addOrtbSiteContent(bid, expectedId); - expect(bid).to.have.nested.property('ortb2.site.content.data'); - expect(bid.ortb2.site.content.data).to.have.length(1); - expect(bid.ortb2.site.content.data[0]).to.be.deep.equal(expectedData); - expect(bid).to.have.nested.property('ortb2.site.content.id', expectedId); + addOrtbSiteContent(ortb2, expectedId); + expect(ortb2).to.have.nested.property('site.content.data'); + expect(ortb2.site.content.data).to.have.length(1); + expect(ortb2.site.content.data[0]).to.be.deep.equal(expectedData); + expect(ortb2).to.have.nested.property('site.content.id', expectedId); }); }); @@ -762,7 +934,6 @@ describe('jwplayerRtdProvider', function() { describe('Get Bid Request Data', function () { const validMediaIDs = ['media_ID_1', 'media_ID_2', 'media_ID_3']; let bidRequestSpy; - let fakeServer; let clock; let bidReqConfig; @@ -802,16 +973,12 @@ describe('jwplayerRtdProvider', function() { bidRequestSpy = sinon.spy(); - fakeServer = sinon.createFakeServer(); - fakeServer.respondImmediately = false; - fakeServer.autoRespond = false; - clock = sinon.useFakeTimers(); }); afterEach(function () { clock.restore(); - fakeServer.respond(); + server.respond(); }); it('executes callback immediately when ad units are missing', function () { @@ -834,9 +1001,9 @@ describe('jwplayerRtdProvider', function() { jwplayerSubmodule.getBidRequestData(bidReqConfig, bidRequestSpy); expect(bidRequestSpy.notCalled).to.be.true; - const req1 = fakeServer.requests[0]; - const req2 = fakeServer.requests[1]; - const req3 = fakeServer.requests[2]; + const req1 = server.requests[0]; + const req2 = server.requests[1]; + const req3 = server.requests[2]; req1.respond(); expect(bidRequestSpy.notCalled).to.be.true; diff --git a/test/spec/modules/kargoAnalyticsAdapter_spec.js b/test/spec/modules/kargoAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..c27c8499aa1 --- /dev/null +++ b/test/spec/modules/kargoAnalyticsAdapter_spec.js @@ -0,0 +1,42 @@ +import kargoAnalyticsAdapter from 'modules/kargoAnalyticsAdapter.js'; +import { expect } from 'chai'; +import { server } from 'test/mocks/xhr.js'; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('Kargo Analytics Adapter', function () { + const adapterConfig = { + provider: 'kargoAnalytics', + }; + + after(function () { + kargoAnalyticsAdapter.disableAnalytics(); + }); + + describe('main test flow', function () { + beforeEach(function () { + kargoAnalyticsAdapter.enableAnalytics(adapterConfig); + sinon.stub(events, 'getEvents').returns([]); + }); + + afterEach(function () { + events.getEvents.restore(); + }); + + it('bid response data should send one request with auction ID, auction timeout, and response time', function() { + const bidResponse = { + bidder: 'kargo', + auctionId: '66529d4c-8998-47c2-ab3e-5b953490b98f', + timeToRespond: 192, + }; + + events.emit(constants.EVENTS.AUCTION_INIT, { + timeout: 1000 + }); + events.emit(constants.EVENTS.BID_RESPONSE, bidResponse); + + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('https://krk.kargo.com/api/v1/event/auction-data?aid=66529d4c-8998-47c2-ab3e-5b953490b98f&ato=1000&rt=192&it=0'); + }); + }); +}); diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js index 6f5a0008783..9f7a4854063 100644 --- a/test/spec/modules/kargoBidAdapter_spec.js +++ b/test/spec/modules/kargoBidAdapter_spec.js @@ -1,9 +1,21 @@ -import {expect, assert} from 'chai'; -import {spec} from 'modules/kargoBidAdapter.js'; -import {config} from 'src/config.js'; +import { expect, assert } from 'chai'; +import { spec } from 'modules/kargoBidAdapter.js'; +import { config } from 'src/config.js'; +const utils = require('src/utils'); describe('kargo adapter tests', function () { var sandbox, clock, frozenNow = new Date(); + const testSchain = { + complete: 1, + nodes: [ + { + 'asi': 'test-page.com', + 'hp': 1, + 'rid': '57bdd953-6e57-4d5b-9351-ed67ca238890', + 'sid': '8190248274' + } + ] + } beforeEach(function () { sandbox = sinon.sandbox.create(); @@ -15,31 +27,37 @@ describe('kargo adapter tests', function () { clock.restore(); }); - describe('bid request validity', function() { - it('passes when the bid includes a placement ID', function() { - assert(spec.isBidRequestValid({params: {placementId: 'foo'}}) === true); + describe('bid request validity', function () { + it('passes when the bid includes a placement ID', function () { + assert(spec.isBidRequestValid({ params: { placementId: 'foo' } }) === true); }); - it('fails when the bid does not include a placement ID', function() { - assert(spec.isBidRequestValid({params: {}}) === false); + it('fails when the bid does not include a placement ID', function () { + assert(spec.isBidRequestValid({ params: {} }) === false); }); - it('fails when bid is falsey', function() { + it('fails when bid is falsey', function () { assert(spec.isBidRequestValid() === false); }); - it('fails when the bid has no params at all', function() { + it('fails when the bid has no params at all', function () { assert(spec.isBidRequestValid({}) === false); }); }); - describe('build request', function() { - var bids, undefinedCurrency, noAdServerCurrency, cookies = [], localStorageItems = [], sessionIds = [], requestCount = 0; + describe('build request', function () { + var bids, undefinedCurrency, noAdServerCurrency, nonUSDAdServerCurrency, cookies = [], localStorageItems = [], sessionIds = [], requestCount = 0; beforeEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + kargo: { + storageAllowed: true + } + }; undefinedCurrency = false; noAdServerCurrency = false; - sandbox.stub(config, 'getConfig').callsFake(function(key) { + nonUSDAdServerCurrency = false; + sandbox.stub(config, 'getConfig').callsFake(function (key) { if (key === 'currency') { if (undefinedCurrency) { return undefined; @@ -47,7 +65,10 @@ describe('kargo adapter tests', function () { if (noAdServerCurrency) { return {}; } - return {adServerCurrency: 'USD'}; + if (nonUSDAdServerCurrency) { + return { adServerCurrency: 'EUR' }; + } + return { adServerCurrency: 'USD' }; } if (key === 'debug') return true; if (key === 'deviceAccess') return true; @@ -57,27 +78,137 @@ describe('kargo adapter tests', function () { bids = [ { params: { - placementId: 'foo' + placementId: 'foo', + socialCanvas: { + segments: ['segment_1', 'segment_2', 'segment_3'], + url: 'https://socan.url' + } }, - bidId: 1, + auctionId: '1234098', + bidId: '1', + adUnitCode: '101', + sizes: [[320, 50], [300, 250], [300, 600]], + mediaTypes: { + banner: { + sizes: [[320, 50], [300, 50]] + } + }, + bidRequestsCount: 1, + bidderRequestsCount: 2, + bidderWinsCount: 3, + schain: testSchain, userId: { - tdid: 'fake-tdid' + tdid: 'ed1562d5-e52b-406f-8e65-e5ab3ed5583c' + }, + userIdAsEids: [ + { + 'source': 'adserver.org', + 'uids': [ + { + 'id': 'ed1562d5-e52b-406f-8e65-e5ab3ed5583c', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + } + ] + } + ], + floorData: { + floorMin: 1 }, - sizes: [[320, 50], [300, 250], [300, 600]] + ortb2: { + device: { + sua: { + platform: { + brand: 'macOS', + version: ['12', '6', '0'] + }, + browsers: [ + { + brand: 'Chromium', + version: ['106', '0', '5249', '119'] + }, + { + brand: 'Google Chrome', + version: ['106', '0', '5249', '119'] + }, + { + brand: 'Not;A=Brand', + version: ['99', '0', '0', '0'] + } + ], + mobile: 1, + model: 'model', + source: 1, + } + } + }, + ortb2Imp: { + ext: { + tid: '10101', + data: { + adServer: { + name: 'gam', + adSlot: '/22558409563,18834096/dfy_mobile_adhesion' + }, + pbAdSlot: '/22558409563,18834096/dfy_mobile_adhesion' + }, + gpid: '/22558409563,18834096/dfy_mobile_adhesion' + } + } }, { params: { placementId: 'bar' }, - bidId: 2, - sizes: [[320, 50], [300, 250], [300, 600]] + bidId: '2', + adUnitCode: '202', + sizes: [[320, 50], [300, 250], [300, 600]], + mediaTypes: { + video: { + sizes: [[320, 50], [300, 50]] + } + }, + bidRequestsCount: 0, + bidderRequestsCount: 0, + bidderWinsCount: 0, + ortb2Imp: { + ext: { + tid: '20202', + data: { + adServer: { + name: 'gam', + adSlot: '/22558409563,18834096/dfy_mobile_adhesion' + }, + pbAdSlot: '/22558409563,18834096/dfy_mobile_adhesion' + } + } + } }, { params: { placementId: 'bar' }, - bidId: 3, - sizes: [[320, 50], [300, 250], [300, 600]] + bidId: '3', + adUnitCode: '303', + sizes: [[320, 50], [300, 250], [300, 600]], + mediaTypes: { + native: { + sizes: [[320, 50], [300, 50]] + } + }, + ortb2Imp: { + ext: { + tid: '30303', + data: { + adServer: { + name: 'gam', + adSlot: '/22558409563,18834096/dfy_mobile_adhesion' + } + } + } + } } ]; }); @@ -95,6 +226,7 @@ describe('kargo adapter tests', function () { cookies.length = 0; localStorageItems.length = 0; + $$PREBID_GLOBAL$$.bidderSettings = {}; }); function setCookie(cname, cvalue, exdays = 1) { @@ -127,11 +259,19 @@ describe('kargo adapter tests', function () { function simulateNoCurrencyObject() { undefinedCurrency = true; noAdServerCurrency = false; + nonUSDAdServerCurrency = false; } function simulateNoAdServerCurrency() { undefinedCurrency = false; noAdServerCurrency = true; + nonUSDAdServerCurrency = false; + } + + function simulateNonUSDAdServerCurrency() { + undefinedCurrency = false; + noAdServerCurrency = false; + nonUSDAdServerCurrency = true; } function generateGDPR(applies, haveConsent) { @@ -149,12 +289,38 @@ describe('kargo adapter tests', function () { }; } + function generatePageView() { + return { + id: '112233', + timestamp: frozenNow.getTime(), + url: 'http://pageview.url' + } + } + + function generateRawCRB(rawCRB, rawCRBLocalStorage) { + if (rawCRB == null && rawCRBLocalStorage == null) { + return null + } + + let result = {} + + if (rawCRB != null) { + result.rawCRB = rawCRB + } + + if (rawCRBLocalStorage != null) { + result.rawCRBLocalStorage = rawCRBLocalStorage + } + + return result + } + function getKrgCrb() { return 'eyJzeW5jSWRzIjp7IjIiOiI4MmZhMjU1NS01OTY5LTQ2MTQtYjRjZS00ZGNmMTA4MGU5ZjkiLCIxNiI6IlZveElrOEFvSnowQUFFZENleUFBQUFDMiY1MDIiLCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBBQUVkQ2V5QUFBQUMyJjUwMiIsIjI1IjoiNWVlMjQxMzgtNWUwMy00YjlkLWE5NTMtMzhlODMzZjI4NDlmIiwiMl84MCI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjJfOTMiOiI1ZWUyNDEzOC01ZTAzLTRiOWQtYTk1My0zOGU4MzNmMjg0OWYifSwibGV4SWQiOiI1ZjEwODgzMS0zMDJkLTExZTctYmY2Yi00NTk1YWNkM2JmNmMiLCJjbGllbnRJZCI6IjI0MTBkOGYyLWMxMTEtNDgxMS04OGE1LTdiNWUxOTBlNDc1ZiIsIm9wdE91dCI6ZmFsc2UsImV4cGlyZVRpbWUiOjE0OTc0NDkzODI2NjgsImxhc3RTeW5jZWRBdCI6MTQ5NzM2Mjk3OTAxMn0='; } function getKrgCrbOldStyle() { - return '%7B%22v%22%3A%22eyJzeW5jSWRzIjp7IjIiOiI4MmZhMjU1NS01OTY5LTQ2MTQtYjRjZS00ZGNmMTA4MGU5ZjkiLCIxNiI6IlZveElrOEFvSnowQUFFZENleUFBQUFDMiY1MDIiLCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBBQUVkQ2V5QUFBQUMyJjUwMiIsIjI1IjoiNWVlMjQxMzgtNWUwMy00YjlkLWE5NTMtMzhlODMzZjI4NDlmIiwiMl84MCI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjJfOTMiOiI1ZWUyNDEzOC01ZTAzLTRiOWQtYTk1My0zOGU4MzNmMjg0OWYifSwibGV4SWQiOiI1ZjEwODgzMS0zMDJkLTExZTctYmY2Yi00NTk1YWNkM2JmNmMiLCJjbGllbnRJZCI6IjI0MTBkOGYyLWMxMTEtNDgxMS04OGE1LTdiNWUxOTBlNDc1ZiIsIm9wdE91dCI6ZmFsc2UsImV4cGlyZVRpbWUiOjE0OTc0NDkzODI2NjgsImxhc3RTeW5jZWRBdCI6MTQ5NzM2Mjk3OTAxMn0=%22%7D'; + return '{"v":"eyJzeW5jSWRzIjp7IjIiOiI4MmZhMjU1NS01OTY5LTQ2MTQtYjRjZS00ZGNmMTA4MGU5ZjkiLCIxNiI6IlZveElrOEFvSnowQUFFZENleUFBQUFDMiY1MDIiLCIyMyI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjI0IjoiVm94SWs4QW9KejBBQUVkQ2V5QUFBQUMyJjUwMiIsIjI1IjoiNWVlMjQxMzgtNWUwMy00YjlkLWE5NTMtMzhlODMzZjI4NDlmIiwiMl84MCI6ImQyYTg1NWE1LTFiMWMtNDMwMC05NDBlLWE3MDhmYTFmMWJkZSIsIjJfOTMiOiI1ZWUyNDEzOC01ZTAzLTRiOWQtYTk1My0zOGU4MzNmMjg0OWYifSwibGV4SWQiOiI1ZjEwODgzMS0zMDJkLTExZTctYmY2Yi00NTk1YWNkM2JmNmMiLCJjbGllbnRJZCI6IjI0MTBkOGYyLWMxMTEtNDgxMS04OGE1LTdiNWUxOTBlNDc1ZiIsIm9wdE91dCI6ZmFsc2UsImV4cGlyZVRpbWUiOjE0OTc0NDkzODI2NjgsImxhc3RTeW5jZWRBdCI6MTQ5NzM2Mjk3OTAxMn0="}'; } function initializeKrgCrb(cookieOnly) { @@ -181,7 +347,7 @@ describe('kargo adapter tests', function () { } function getInvalidKrgCrbType2OldStyle() { - return '%7B%22v%22%3A%22%26%26%26%26%26%26%22%7D'; + return '{"v":"&&&&&&"}'; } function initializeInvalidKrgCrbType2() { @@ -193,7 +359,7 @@ describe('kargo adapter tests', function () { } function getInvalidKrgCrbType3OldStyle() { - return '%7B%22v%22%3A%22Ly8v%22%7D'; + return '{"v":"Ly8v"}'; } function initializeInvalidKrgCrbType3Cookie() { @@ -201,7 +367,7 @@ describe('kargo adapter tests', function () { } function getInvalidKrgCrbType4OldStyle() { - return '%7B%22v%22%3A%22bnVsbA%3D%3D%22%7D'; + return '{"v":"bnVsbA=="}'; } function initializeInvalidKrgCrbType4Cookie() { @@ -213,13 +379,19 @@ describe('kargo adapter tests', function () { } function getEmptyKrgCrbOldStyle() { - return '%7B%22v%22%3A%22eyJleHBpcmVUaW1lIjoxNDk3NDQ5MzgyNjY4LCJsYXN0U3luY2VkQXQiOjE0OTczNjI5NzkwMTJ9%22%7D'; + return '{"v":"eyJleHBpcmVUaW1lIjoxNDk3NDQ5MzgyNjY4LCJsYXN0U3luY2VkQXQiOjE0OTczNjI5NzkwMTJ9"}'; } function initializeEmptyKrgCrb() { setLocalStorageItem('krg_crb', getEmptyKrgCrb()); } + function initializePageView() { + setLocalStorageItem('pageViewId', 112233); + setLocalStorageItem('pageViewTimestamp', frozenNow.getTime()); + setLocalStorageItem('pageViewUrl', 'http://pageview.url'); + } + function initializeEmptyKrgCrbCookie() { setCookie('krg_crb', getEmptyKrgCrbOldStyle()); } @@ -228,31 +400,95 @@ describe('kargo adapter tests', function () { return spec._getSessionId(); } - function getExpectedKrakenParams(excludeUserIds, expectedRawCRB, expectedRawCRBCookie, expectedGDPR) { + function getExpectedKrakenParams(expectedCRB, expectedPage, excludeUserIds, expectedGDPR, currency) { var base = { + pbv: '$prebid.version$', + aid: '1234098', + requestCount: 0, + sid: getSessionId(), + url: 'https://www.prebid.org', timeout: 200, - requestCount: requestCount++, - currency: 'USD', - cpmGranularity: 1, - timestamp: frozenNow.getTime(), - cpmRange: { - floor: 0, - ceil: 20 - }, - bidIDs: { - 1: 'foo', - 2: 'bar', - 3: 'bar' + ts: frozenNow.getTime(), + schain: testSchain, + device: { + size: [ + screen.width, + screen.height + ], + sua: { + platform: { + brand: 'macOS', + version: ['12', '6', '0'] + }, + browsers: [ + { + brand: 'Chromium', + version: ['106', '0', '5249', '119'] + }, + { + brand: 'Google Chrome', + version: ['106', '0', '5249', '119'] + }, + { + brand: 'Not;A=Brand', + version: ['99', '0', '0', '0'] + } + ], + mobile: 1, + model: 'model', + source: 1 + }, }, - bidSizes: { - 1: [[320, 50], [300, 250], [300, 600]], - 2: [[320, 50], [300, 250], [300, 600]], - 3: [[320, 50], [300, 250], [300, 600]] + imp: [ + { + code: '101', + id: '1', + pid: 'foo', + tid: '10101', + banner: { + sizes: [[320, 50], [300, 50]] + }, + bidRequestCount: 1, + bidderRequestCount: 2, + bidderWinCount: 3, + floor: 1, + fpd: { + gpid: '/22558409563,18834096/dfy_mobile_adhesion' + } + }, + { + code: '202', + id: '2', + pid: 'bar', + tid: '20202', + video: { + sizes: [[320, 50], [300, 50]] + }, + fpd: { + gpid: '/22558409563,18834096/dfy_mobile_adhesion' + } + }, + { + code: '303', + id: '3', + pid: 'bar', + tid: '30303', + native: { + sizes: [[320, 50], [300, 50]] + }, + fpd: { + gpid: '/22558409563,18834096/dfy_mobile_adhesion' + } + } + ], + socan: { + segments: ['segment_1', 'segment_2', 'segment_3'], + url: 'https://socan.url' }, - userIDs: { + user: { kargoID: '5f108831-302d-11e7-bf6b-4595acd3bf6c', clientID: '2410d8f2-c111-4811-88a5-7b5e190e475f', - tdID: 'fake-tdid', + tdID: 'ed1562d5-e52b-406f-8e65-e5ab3ed5583c', crbIDs: { 2: '82fa2555-5969-4614-b4ce-4dcf1080e9f9', 16: 'VoxIk8AoJz0AAEdCeyAAAAC2&502', @@ -263,74 +499,81 @@ describe('kargo adapter tests', function () { '2_93': '5ee24138-5e03-4b9d-a953-38e833f2849f' }, optOut: false, - usp: '1---' - }, - pageURL: window.location.href, - prebidRawBidRequests: [ - { - bidId: 1, - params: { - placementId: 'foo' - }, - userId: { - tdid: 'fake-tdid' - }, - sizes: [[320, 50], [300, 250], [300, 600]] - }, - { - bidId: 2, - params: { - placementId: 'bar' - }, - sizes: [[320, 50], [300, 250], [300, 600]] - }, - { - bidId: 3, - params: { - placementId: 'bar' - }, - sizes: [[320, 50], [300, 250], [300, 600]] - } - ], - rawCRB: expectedRawCRBCookie, - rawCRBLocalStorage: expectedRawCRB + usp: '1---', + sharedIDEids: [ + { + source: 'adserver.org', + uids: [ + { + id: 'ed1562d5-e52b-406f-8e65-e5ab3ed5583c', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + } + ] + } + ] + } }; + if (excludeUserIds) { + base.user.crbIDs = {}; + delete base.user.clientID; + delete base.user.kargoID; + delete base.user.optOut; + } + if (expectedGDPR) { - base.userIDs['gdpr'] = expectedGDPR; + base.user.gdpr = expectedGDPR; + } + + if (expectedPage) { + base.page = expectedPage; } - if (excludeUserIds === true) { - base.userIDs = { - crbIDs: {}, - usp: '1---' - }; - delete base.prebidRawBidRequests[0].userId.tdid; + if (currency) { + base.cur = currency; + } + + const reqCount = requestCount++; + base.requestCount = reqCount + + if (expectedCRB != null) { + if (expectedCRB.rawCRB != null) { + base.rawCRB = expectedCRB.rawCRB + } + if (expectedCRB.rawCRBLocalStorage != null) { + base.rawCRBLocalStorage = expectedCRB.rawCRBLocalStorage + } } return base; } - function testBuildRequests(excludeTdid, expected, gdpr) { + function testBuildRequests(expected, gdpr) { var clonedBids = JSON.parse(JSON.stringify(bids)); - if (excludeTdid) { - delete clonedBids[0].userId.tdid; - } - var payload = { timeout: 200, uspConsent: '1---', foo: 'bar' }; + + var payload = { + timeout: 200, + uspConsent: '1---', + refererInfo: { + page: 'https://www.prebid.org', + }, + }; + if (gdpr) { payload['gdprConsent'] = gdpr } + var request = spec.buildRequests(clonedBids, payload); - expected.sessionId = getSessionId(); - sessionIds.push(expected.sessionId); - var krakenParams = JSON.parse(decodeURIComponent(request.data.slice(5))); - expect(request.data.slice(0, 5)).to.equal('json='); - expect(request.url).to.equal('https://krk.kargo.com/api/v2/bid'); - expect(request.method).to.equal('GET'); - expect(request.currency).to.equal('USD'); + var krakenParams = request.data; + + expect(request.url).to.equal('https://krk2.kargo.com/api/v1/prebid'); + expect(request.method).to.equal('POST'); expect(request.timeout).to.equal(200); - expect(request.foo).to.equal('bar'); expect(krakenParams).to.deep.equal(expected); + // Make sure session ID stays the same across requests simulating multiple auctions on one page load for (let i in sessionIds) { if (i == 0) { @@ -341,120 +584,161 @@ describe('kargo adapter tests', function () { } } - it('works when all params and localstorage and cookies are correctly set', function() { + it('works when all params and localstorage and cookies are correctly set', function () { initializeKrgCrb(); - testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), generatePageView())); }); - it('works when all params and cookies are correctly set but no localstorage', function() { + it('works when all params and cookies are correctly set but no localstorage', function () { initializeKrgCrb(true); - testBuildRequests(false, getExpectedKrakenParams(undefined, null, getKrgCrbOldStyle())); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle()))); }); - it('gracefully handles nothing being set', function() { - testBuildRequests(true, getExpectedKrakenParams(true, null, null)); + it('gracefully handles nothing being set', function () { + testBuildRequests(getExpectedKrakenParams(undefined, undefined, true)); }); - it('gracefully handles browsers without localStorage', function() { + it('gracefully handles browsers without localStorage', function () { simulateNoLocalStorage(); - testBuildRequests(true, getExpectedKrakenParams(true, null, null)); + testBuildRequests(getExpectedKrakenParams(undefined, undefined, true)); }); - it('handles empty yet valid Kargo CRB', function() { + it('handles empty yet valid Kargo CRB', function () { initializeEmptyKrgCrb(); initializeEmptyKrgCrbCookie(); - testBuildRequests(true, getExpectedKrakenParams(true, getEmptyKrgCrb(), getEmptyKrgCrbOldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getEmptyKrgCrbOldStyle(), getEmptyKrgCrb()), generatePageView(), true)); }); - it('handles broken Kargo CRBs where base64 encoding is invalid', function() { + it('handles broken Kargo CRBs where base64 encoding is invalid', function () { initializeInvalidKrgCrbType1(); - testBuildRequests(true, getExpectedKrakenParams(true, getInvalidKrgCrbType1(), null)); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(undefined, getInvalidKrgCrbType1()), generatePageView(), true)); }); - it('handles broken Kargo CRBs where top level JSON is invalid on cookie', function() { + it('handles broken Kargo CRBs where top level JSON is invalid on cookie', function () { initializeInvalidKrgCrbType1Cookie(); - testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType1())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getInvalidKrgCrbType1()), generatePageView(), true)); }); - it('handles broken Kargo CRBs where decoded JSON is invalid', function() { + it('handles broken Kargo CRBs where decoded JSON is invalid', function () { initializeInvalidKrgCrbType2(); - testBuildRequests(true, getExpectedKrakenParams(true, getInvalidKrgCrbType2(), null)); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(undefined, getInvalidKrgCrbType2()), generatePageView(), true)); }); - it('handles broken Kargo CRBs where inner base 64 is invalid on cookie', function() { + it('handles broken Kargo CRBs where inner base 64 is invalid on cookie', function () { initializeInvalidKrgCrbType2Cookie(); - testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType2OldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getInvalidKrgCrbType2OldStyle()), generatePageView(), true)); }); - it('handles broken Kargo CRBs where inner JSON is invalid on cookie', function() { + it('handles broken Kargo CRBs where inner JSON is invalid on cookie', function () { initializeInvalidKrgCrbType3Cookie(); - testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType3OldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getInvalidKrgCrbType3OldStyle()), generatePageView(), true)); }); - it('handles broken Kargo CRBs where inner JSON is falsey', function() { + it('handles broken Kargo CRBs where inner JSON is falsey', function () { initializeInvalidKrgCrbType4Cookie(); - testBuildRequests(true, getExpectedKrakenParams(true, null, getInvalidKrgCrbType4OldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getInvalidKrgCrbType4OldStyle()), generatePageView(), true)); }); - it('handles a non-existant currency object on the config', function() { + it('handles a non-existant currency object on the config', function () { simulateNoCurrencyObject(); initializeKrgCrb(); - testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), generatePageView())); }); - it('handles no ad server currency being set on the currency object in the config', function() { + it('handles no ad server currency being set on the currency object in the config', function () { simulateNoAdServerCurrency(); initializeKrgCrb(); - testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle())); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), generatePageView())); + }); + + it('handles non-USD ad server currency being set on the currency object in the config', function () { + simulateNonUSDAdServerCurrency(); + initializeKrgCrb(); + initializePageView(); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), generatePageView(), undefined, undefined, 'EUR')); }); it('sends gdpr consent', function () { initializeKrgCrb(); - testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(true, true)), generateGDPR(true, true)); - testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, true)), generateGDPR(false, true)); - testBuildRequests(false, getExpectedKrakenParams(undefined, getKrgCrb(), getKrgCrbOldStyle(), generateGDPRExpect(false, false)), generateGDPR(false, false)); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), undefined, false, generateGDPRExpect(true, true)), generateGDPR(true, true)); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), undefined, false, generateGDPRExpect(false, true)), generateGDPR(false, true)); + testBuildRequests(getExpectedKrakenParams(generateRawCRB(getKrgCrbOldStyle(), getKrgCrb()), undefined, false, generateGDPRExpect(false, false)), generateGDPR(false, false)); }); }); - describe('response handler', function() { - it('handles bid responses', function() { - var resp = spec.interpretResponse({body: { - 1: { - id: 'foo', - cpm: 3, - adm: '
', - width: 320, - height: 50, - metadata: {} - }, - 2: { - id: 'bar', - cpm: 2.5, - adm: '
', - width: 300, - height: 250, - targetingCustom: 'dmpmptest1234', - metadata: { - landingPageDomain: ['https://foobar.com'] + describe('response handler', function () { + it('handles bid responses', function () { + var resp = spec.interpretResponse({ + body: { + 1: { + id: 'foo', + cpm: 3, + adm: '
', + width: 320, + height: 50, + metadata: {} + }, + 2: { + id: 'bar', + cpm: 2.5, + adm: '
', + width: 300, + height: 250, + targetingCustom: 'dmpmptest1234', + metadata: { + landingPageDomain: ['https://foobar.com'] + } + }, + 3: { + id: 'bar', + cpm: 2.5, + adm: '
', + width: 300, + height: 250 + }, + 4: { + id: 'bar', + cpm: 2.5, + adm: '
', + width: 300, + height: 250, + mediaType: 'banner', + metadata: {}, + currency: 'EUR' + }, + 5: { + id: 'bar', + cpm: 2.5, + adm: '', + width: 300, + height: 250, + mediaType: 'video', + metadata: {}, + currency: 'EUR' + }, + 6: { + id: 'bar', + cpm: 2.5, + adm: '', + admUrl: 'https://foobar.com/vast_adm', + width: 300, + height: 250, + mediaType: 'video', + metadata: {}, + currency: 'EUR' } - }, - 3: { - id: 'bar', - cpm: 2.5, - adm: '
', - width: 300, - height: 250 - }, - 4: { - id: 'bar', - cpm: 2.5, - adm: '
', - width: 300, - height: 250, - metadata: {}, - currency: 'EUR' } - }}, { + }, { currency: 'USD', bids: [{ bidId: 1, @@ -476,69 +760,125 @@ describe('kargo adapter tests', function () { params: { placementId: 'bar' } + }, { + bidId: 5, + params: { + placementId: 'bar' + } + }, { + bidId: 6, + params: { + placementId: 'bar' + } }] }); var expectation = [{ + ad: '
', requestId: '1', cpm: 3, width: 320, height: 50, - ad: '
', ttl: 300, creativeId: 'foo', dealId: undefined, netRevenue: true, currency: 'USD', - meta: undefined + mediaType: 'banner', + meta: { + mediaType: 'banner' + } }, { requestId: '2', + ad: '
', cpm: 2.5, width: 300, height: 250, - ad: '
', ttl: 300, creativeId: 'bar', dealId: 'dmpmptest1234', netRevenue: true, currency: 'USD', + mediaType: 'banner', meta: { + mediaType: 'banner', clickUrl: 'https://foobar.com', advertiserDomains: ['https://foobar.com'] } }, { requestId: '3', + ad: '
', cpm: 2.5, width: 300, height: 250, - ad: '
', ttl: 300, creativeId: 'bar', dealId: undefined, netRevenue: true, currency: 'USD', - meta: undefined + mediaType: 'banner', + meta: { + mediaType: 'banner' + } }, { requestId: '4', + ad: '
', cpm: 2.5, width: 300, height: 250, - ad: '
', ttl: 300, creativeId: 'bar', dealId: undefined, netRevenue: true, currency: 'EUR', - meta: undefined + mediaType: 'banner', + meta: { + mediaType: 'banner' + } + }, { + requestId: '5', + cpm: 2.5, + width: 300, + height: 250, + vastXml: '', + ttl: 300, + creativeId: 'bar', + dealId: undefined, + netRevenue: true, + currency: 'EUR', + mediaType: 'video', + meta: { + mediaType: 'video' + } + }, { + requestId: '6', + cpm: 2.5, + width: 300, + height: 250, + vastUrl: 'https://foobar.com/vast_adm', + ttl: 300, + creativeId: 'bar', + dealId: undefined, + netRevenue: true, + currency: 'EUR', + mediaType: 'video', + meta: { + mediaType: 'video' + } }]; expect(resp).to.deep.equal(expectation); }); }); - describe('user sync handler', function() { + describe('user sync handler', function () { const clientId = '74c81cbb-7d07-46d9-be9b-68ccb291c949'; var shouldSimulateOutdatedBrowser, crb, isActuallyOutdatedBrowser; beforeEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + kargo: { + storageAllowed: true + } + }; crb = {}; shouldSimulateOutdatedBrowser = false; isActuallyOutdatedBrowser = false; @@ -550,7 +890,7 @@ describe('kargo adapter tests', function () { if (!window.crypto) { isActuallyOutdatedBrowser = true; } else { - sandbox.stub(crypto, 'getRandomValues').callsFake(function(buf) { + sandbox.stub(crypto, 'getRandomValues').callsFake(function (buf) { if (shouldSimulateOutdatedBrowser) { throw new Error('Could not generate random values'); } @@ -562,13 +902,13 @@ describe('kargo adapter tests', function () { }); } - sandbox.stub(spec, '_getCrb').callsFake(function() { + sandbox.stub(spec, '_getCrb').callsFake(function () { return crb; }); }); - function getUserSyncsWhenAllowed(gdprConsent, usPrivacy) { - return spec.getUserSyncs({iframeEnabled: true}, null, gdprConsent, usPrivacy); + function getUserSyncsWhenAllowed(gdprConsent, usPrivacy, gppConsent) { + return spec.getUserSyncs({ iframeEnabled: true }, null, gdprConsent, usPrivacy, gppConsent); } function getUserSyncsWhenForbidden() { @@ -583,17 +923,17 @@ describe('kargo adapter tests', function () { shouldSimulateOutdatedBrowser = true; } - function getSyncUrl(index, gdprApplies, gdprConsentString, usPrivacy) { + function getSyncUrl(index, gdprApplies, gdprConsentString, usPrivacy, gpp, gppSid) { return { type: 'iframe', - url: `https://crb.kargo.com/api/v1/initsyncrnd/${clientId}?seed=3205e885-8d37-4139-b47e-f82cff268000&idx=${index}&gdpr=${gdprApplies}&gdpr_consent=${gdprConsentString}&us_privacy=${usPrivacy}` + url: `https://crb.kargo.com/api/v1/initsyncrnd/${clientId}?seed=3205e885-8d37-4139-b47e-f82cff268000&idx=${index}&gdpr=${gdprApplies}&gdpr_consent=${gdprConsentString}&us_privacy=${usPrivacy}&gpp=${gpp}&gpp_sid=${gppSid}` }; } - function getSyncUrls(gdprApplies, gdprConsentString, usPrivacy) { + function getSyncUrls(gdprApplies, gdprConsentString, usPrivacy, gpp, gppSid) { var syncs = []; for (var i = 0; i < 5; i++) { - syncs[i] = getSyncUrl(i, gdprApplies || 0, gdprConsentString || '', usPrivacy || ''); + syncs[i] = getSyncUrl(i, gdprApplies || 0, gdprConsentString || '', usPrivacy || '', gpp || '', gppSid || ''); } return syncs; } @@ -606,39 +946,66 @@ describe('kargo adapter tests', function () { } } - it('handles user syncs when there is a client id', function() { + it('handles user syncs when there is a client id', function () { turnOnClientId(); safelyRun(() => expect(getUserSyncsWhenAllowed()).to.deep.equal(getSyncUrls())); }); - it('no user syncs when there is no client id', function() { + it('no user syncs when there is no client id', function () { safelyRun(() => expect(getUserSyncsWhenAllowed()).to.be.an('array').that.is.empty); }); - it('no user syncs when there is no us privacy consent', function() { + it('no user syncs when there is no us privacy consent', function () { turnOnClientId(); safelyRun(() => expect(getUserSyncsWhenAllowed(null, '1YYY')).to.be.an('array').that.is.empty); }); - it('pass through us privacy consent', function() { + it('pass through us privacy consent', function () { turnOnClientId(); safelyRun(() => expect(getUserSyncsWhenAllowed(null, '1YNY')).to.deep.equal(getSyncUrls(0, '', '1YNY'))); }); - it('pass through gdpr consent', function() { + it('pass through gdpr consent', function () { turnOnClientId(); safelyRun(() => expect(getUserSyncsWhenAllowed({ gdprApplies: true, consentString: 'consentstring' })).to.deep.equal(getSyncUrls(1, 'consentstring', ''))); }); - it('no user syncs when there is outdated browser', function() { + it('pass through gpp consent', function () { + turnOnClientId(); + safelyRun(() => expect(getUserSyncsWhenAllowed(null, null, { consentString: 'gppString', applicableSections: [-1] })).to.deep.equal(getSyncUrls('', '', '', 'gppString', '-1'))); + }); + + it('no user syncs when there is outdated browser', function () { turnOnClientId(); simulateOutdatedBrowser(); safelyRun(() => expect(getUserSyncsWhenAllowed()).to.be.an('array').that.is.empty); }); - it('no user syncs when no iframe syncing allowed', function() { + it('no user syncs when no iframe syncing allowed', function () { turnOnClientId(); safelyRun(() => expect(getUserSyncsWhenForbidden()).to.be.an('array').that.is.empty); }); }); + + describe('timeout pixel trigger', function () { + let triggerPixelStub; + + beforeEach(function () { + triggerPixelStub = sinon.stub(utils, 'triggerPixel'); + }); + + afterEach(function () { + utils.triggerPixel.restore(); + }); + + it('should call triggerPixel utils function when timed out is filled', function () { + spec.onTimeout(); + expect(triggerPixelStub.getCall(0)).to.be.null; + spec.onTimeout([{ auctionId: '1234', timeout: 2000 }]); + expect(triggerPixelStub.getCall(0)).to.not.be.null; + expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.include('https://krk2.kargo.com/api/v1/event/timeout'); + expect(triggerPixelStub.getCall(0).args[0]).to.include('aid=1234'); + expect(triggerPixelStub.getCall(0).args[0]).to.include('ato=2000'); + }); + }); }); diff --git a/test/spec/modules/kiviadsBidAdapter_spec.js b/test/spec/modules/kiviadsBidAdapter_spec.js new file mode 100644 index 00000000000..03d58cbc265 --- /dev/null +++ b/test/spec/modules/kiviadsBidAdapter_spec.js @@ -0,0 +1,404 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/kiviadsBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'kiviads' +const adUrl = 'https://lb.kiviads.com/pbjs'; +const syncUrl = 'https://sync.kiviads.com'; + +describe('KiviAdsBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + bidderTimeout: 300 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal(adUrl); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'gpp', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.host).to.contain('localhost'); + expect(data.page).to.be.a('string'); + expect(data.page).to.equal('/'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal(`${syncUrl}/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0`) + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal(`${syncUrl}/image?pbjs=1&ccpa_consent=1---&coppa=0`) + }); + }); +}); diff --git a/test/spec/modules/koblerBidAdapter_spec.js b/test/spec/modules/koblerBidAdapter_spec.js index 76c2c287989..2b5830f68d2 100644 --- a/test/spec/modules/koblerBidAdapter_spec.js +++ b/test/spec/modules/koblerBidAdapter_spec.js @@ -7,16 +7,17 @@ import {getRefererInfo} from 'src/refererDetection.js'; function createBidderRequest(auctionId, timeout, pageUrl) { return { + bidderRequestId: 'mock-uuid', auctionId: auctionId || 'c1243d83-0bed-4fdb-8c76-42b456be17d0', timeout: timeout || 2000, refererInfo: { - referer: pageUrl || 'example.com' + page: pageUrl || 'example.com' } }; } function createValidBidRequest(params, bidId, sizes) { - return { + const validBidRequest = { adUnitCode: 'adunit-code', bidId: bidId || '22c4871113f461', bidder: 'kobler', @@ -28,14 +29,25 @@ function createValidBidRequest(params, bidId, sizes) { sizes: sizes || [[300, 250], [320, 100]] } }, - params: params || { - placementId: 'tpw58278' - }, transactionTd: '04314114-15bd-4638-8664-bdb8bdc60bff' }; + if (params) { + validBidRequest.params = params; + } + return validBidRequest; } describe('KoblerAdapter', function () { + let sandbox; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + }); + + afterEach(() => { + sandbox.restore() + }); + describe('inherited functions', function () { it('exists and is a function', function () { const adapter = newBidder(spec); @@ -56,7 +68,7 @@ describe('KoblerAdapter', function () { expect(result).to.be.false; }); - it('should not accept a request without params as valid', function () { + it('should not accept a request without mediaTypes and sizes as valid', function () { const bid = { bidId: 'e11768e8-3b71-4453-8698-0a2feb866589' }; @@ -66,11 +78,56 @@ describe('KoblerAdapter', function () { expect(result).to.be.false; }); - it('should not accept a request without placementId as valid', function () { + it('should not accept a request without mediaTypes and string sizes as valid', function () { const bid = { bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', - params: { - someParam: 'abc' + sizes: 'string' + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without mediaTypes and empty sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + sizes: [] + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without mediaTypes.banner and sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + mediaTypes: {} + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without mediaTypes.banner and empty sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + sizes: [], + mediaTypes: {} + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without sizes and string mediaTypes.banner as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + mediaTypes: { + banner: 'string' } }; @@ -79,12 +136,67 @@ describe('KoblerAdapter', function () { expect(result).to.be.false; }); - it('should accept a request with bidId and placementId as valid', function () { + it('should not accept a request without sizes and mediaTypes.banner.sizes as valid', function () { const bid = { bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', - params: { - someParam: 'abc', - placementId: '8bde0923-1409-4253-9594-495b58d931ba' + mediaTypes: { + banner: {} + } + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without sizes and string mediaTypes.banner.sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + mediaTypes: { + banner: { + sizes: 'string' + } + } + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should not accept a request without sizes and empty mediaTypes.banner.sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + mediaTypes: { + banner: { + sizes: [] + } + } + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.false; + }); + + it('should accept a request with bidId and sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + sizes: [[5, 5]] + }; + + const result = spec.isBidRequestValid(bid); + + expect(result).to.be.true; + }); + + it('should accept a request with bidId and mediaTypes.banner.sizes as valid', function () { + const bid = { + bidId: 'e11768e8-3b71-4453-8698-0a2feb866589', + mediaTypes: { + banner: { + sizes: [[0, 0]] + } } }; @@ -106,7 +218,7 @@ describe('KoblerAdapter', function () { const openRtbRequest = JSON.parse(result.data); expect(openRtbRequest.tmax).to.be.equal(timeout); - expect(openRtbRequest.id).to.be.equal(auctionId); + expect(openRtbRequest.id).to.exist; expect(openRtbRequest.site.page).to.be.equal(testUrl); }); @@ -114,13 +226,10 @@ describe('KoblerAdapter', function () { const firstSize = [400, 800]; const secondSize = [450, 950]; const sizes = [firstSize, secondSize]; - const placementId = 'tsjs86325'; const bidId = '3a56a019-4835-4f75-811c-76fac6853a2c'; const validBidRequests = [ createValidBidRequest( - { - placementId: placementId - }, + undefined, bidId, sizes ) @@ -132,7 +241,6 @@ describe('KoblerAdapter', function () { expect(openRtbRequest.imp.length).to.be.equal(1); expect(openRtbRequest.imp[0].id).to.be.equal(bidId); - expect(openRtbRequest.imp[0].tagid).to.be.equal(placementId); expect(openRtbRequest.imp[0].banner.w).to.be.equal(firstSize[0]); expect(openRtbRequest.imp[0].banner.h).to.be.equal(firstSize[1]); expect(openRtbRequest.imp[0].banner.format.length).to.be.equal(2); @@ -163,40 +271,31 @@ describe('KoblerAdapter', function () { expect(openRtbRequest.imp[0].banner.format[0].h).to.be.equal(0); }); - it('should use 0 as default position', function () { - const validBidRequests = [createValidBidRequest()]; - const bidderRequest = createBidderRequest(); - - const result = spec.buildRequests(validBidRequests, bidderRequest); - const openRtbRequest = JSON.parse(result.data); - - expect(openRtbRequest.imp.length).to.be.equal(1); - expect(openRtbRequest.imp[0].banner.ext.kobler.pos).to.be.equal(0); - }); - - it('should read zip from valid bid requests', function () { - const zip = '700 02'; + it('should read test from valid bid requests', function () { const validBidRequests = [ createValidBidRequest( { - placementId: 'nmah8324234', - zip: zip + test: true } ) ]; const bidderRequest = createBidderRequest(); const result = spec.buildRequests(validBidRequests, bidderRequest); - const openRtbRequest = JSON.parse(result.data); + expect(result.url).to.be.equal('https://bid-service.dev.essrtb.com/bid/prebid_rtb_call'); - expect(openRtbRequest.device.geo.zip).to.be.equal(zip); + const openRtbRequest = JSON.parse(result.data); + expect(openRtbRequest.site.page).to.be.equal('example.com'); + expect(openRtbRequest.test).to.be.equal(1); }); - it('should read test from valid bid requests', function () { + it('should read pageUrl from config when testing', function () { + config.setConfig({ + pageUrl: 'https://testing-url.com' + }); const validBidRequests = [ createValidBidRequest( { - placementId: 'zwop842799', test: true } ) @@ -204,49 +303,40 @@ describe('KoblerAdapter', function () { const bidderRequest = createBidderRequest(); const result = spec.buildRequests(validBidRequests, bidderRequest); - const openRtbRequest = JSON.parse(result.data); + expect(result.url).to.be.equal('https://bid-service.dev.essrtb.com/bid/prebid_rtb_call'); + const openRtbRequest = JSON.parse(result.data); + expect(openRtbRequest.site.page).to.be.equal('https://testing-url.com'); expect(openRtbRequest.test).to.be.equal(1); }); - it('should read floorPrice from valid bid requests', function () { - const floorPrice = 4.343; + it('should not read pageUrl from config when not testing', function () { + config.setConfig({ + pageUrl: 'https://testing-url.com' + }); const validBidRequests = [ - createValidBidRequest( - { - placementId: 'oqr3224234', - floorPrice: floorPrice - } - ) + createValidBidRequest() ]; - const bidderRequest = createBidderRequest(); + const bidderRequest = createBidderRequest( + 'f85d61cc-ed11-4b6c-aefb-87943263cedb', + 2000, + 'https://non-testing-url.net' + ); const result = spec.buildRequests(validBidRequests, bidderRequest); - const openRtbRequest = JSON.parse(result.data); + expect(result.url).to.be.equal('https://bid.essrtb.com/bid/prebid_rtb_call'); - expect(openRtbRequest.imp.length).to.be.equal(1); - expect(openRtbRequest.imp[0].bidfloor).to.be.equal(floorPrice); + const openRtbRequest = JSON.parse(result.data); + expect(openRtbRequest.site.page).to.be.equal('https://non-testing-url.net'); + expect(openRtbRequest.test).to.be.equal(0); }); - it('should read position from valid bid requests', function () { - const placementId = 'yzksf234592'; + it('should read floorPrice from valid bid requests', function () { + const floorPrice = 4.343; const validBidRequests = [ createValidBidRequest( { - placementId: placementId, - position: 1 - } - ), - createValidBidRequest( - { - placementId: placementId, - position: 2 - } - ), - createValidBidRequest( - { - placementId: placementId, - position: 3 + floorPrice: floorPrice } ) ]; @@ -255,13 +345,8 @@ describe('KoblerAdapter', function () { const result = spec.buildRequests(validBidRequests, bidderRequest); const openRtbRequest = JSON.parse(result.data); - expect(openRtbRequest.imp.length).to.be.equal(3); - expect(openRtbRequest.imp[0].banner.ext.kobler.pos).to.be.equal(1); - expect(openRtbRequest.imp[0].tagid).to.be.equal(placementId); - expect(openRtbRequest.imp[1].banner.ext.kobler.pos).to.be.equal(2); - expect(openRtbRequest.imp[1].tagid).to.be.equal(placementId); - expect(openRtbRequest.imp[2].banner.ext.kobler.pos).to.be.equal(3); - expect(openRtbRequest.imp[2].tagid).to.be.equal(placementId); + expect(openRtbRequest.imp.length).to.be.equal(1); + expect(openRtbRequest.imp[0].bidfloor).to.be.equal(floorPrice); }); it('should read dealIds from valid bid requests', function () { @@ -270,13 +355,11 @@ describe('KoblerAdapter', function () { const validBidRequests = [ createValidBidRequest( { - placementId: 'rsl1239823', dealIds: dealIds1 } ), createValidBidRequest( { - placementId: 'pqw234232', dealIds: dealIds2 } ) @@ -294,26 +377,6 @@ describe('KoblerAdapter', function () { expect(openRtbRequest.imp[1].pmp.deals[1].id).to.be.equal(dealIds2[1]); }); - it('should read timeout from config', function () { - const timeout = 4000; - const validBidRequests = [createValidBidRequest()]; - // No timeout field - const bidderRequest = { - auctionId: 'c1243d83-0bed-4fdb-8c76-42b456be17d0', - refererInfo: { - referer: 'example.com' - } - }; - config.setConfig({ - bidderTimeout: timeout - }); - - const result = spec.buildRequests(validBidRequests, bidderRequest); - const openRtbRequest = JSON.parse(result.data); - - expect(openRtbRequest.tmax).to.be.equal(timeout); - }); - it('should read floor price using floors module', function () { const floorPriceFor580x400 = 6.5148; const floorPriceForAnySize = 4.2343; @@ -353,10 +416,7 @@ describe('KoblerAdapter', function () { const validBidRequests = [ createValidBidRequest( { - placementId: 'pcha322364', - zip: '0015', floorPrice: 5.6234, - position: 1, dealIds: ['623472534328234'] }, '953ee65d-d18a-484f-a840-d3056185a060', @@ -364,19 +424,14 @@ describe('KoblerAdapter', function () { ), createValidBidRequest( { - placementId: 'sdfgoi32y4', floorPrice: 3.2543, - position: 2, dealIds: ['92368234753283', '263845832942'] }, '8320bf79-9d90-4a17-87c6-5d505706a921', [[400, 500], [200, 250], [300, 350]] ), createValidBidRequest( - { - placementId: 'gwms2738647', - position: 3 - }, + undefined, 'd0de713b-32e3-4191-a2df-a007f08ffe72', [[800, 900]] ) @@ -391,7 +446,7 @@ describe('KoblerAdapter', function () { const openRtbRequest = JSON.parse(result.data); const expectedOpenRtbRequest = { - id: '9ff580cf-e10e-4b66-add7-40ac0c804e21', + id: 'mock-uuid', at: 1, tmax: 4500, cur: ['USD'], @@ -406,14 +461,8 @@ describe('KoblerAdapter', function () { } ], w: 400, - h: 600, - ext: { - kobler: { - pos: 1 - } - } + h: 600 }, - tagid: 'pcha322364', bidfloor: 5.6234, bidfloorcur: 'USD', pmp: { @@ -442,14 +491,8 @@ describe('KoblerAdapter', function () { } ], w: 400, - h: 500, - ext: { - kobler: { - pos: 2 - } - } + h: 500 }, - tagid: 'sdfgoi32y4', bidfloor: 3.2543, bidfloorcur: 'USD', pmp: { @@ -473,24 +516,15 @@ describe('KoblerAdapter', function () { } ], w: 800, - h: 900, - ext: { - kobler: { - pos: 3 - } - } + h: 900 }, - tagid: 'gwms2738647', bidfloor: 0, bidfloorcur: 'USD', pmp: {} } ], device: { - devicetype: 2, - geo: { - zip: '0015' - } + devicetype: 2 }, site: { page: 'bid.kobler.no' @@ -531,7 +565,7 @@ describe('KoblerAdapter', function () { dealid: '', w: 320, h: 250, - adm: '', + adm: '', adomain: [ 'https://kobler.no' ] @@ -544,7 +578,7 @@ describe('KoblerAdapter', function () { dealid: '2783483223432342', w: 580, h: 400, - adm: '', + adm: '', adomain: [ 'https://bid.kobler.no' ] @@ -568,7 +602,7 @@ describe('KoblerAdapter', function () { dealId: '', netRevenue: true, ttl: 600, - ad: '', + ad: '', nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', meta: { advertiserDomains: [ @@ -586,7 +620,7 @@ describe('KoblerAdapter', function () { dealId: '2783483223432342', netRevenue: true, ttl: 600, - ad: '', + ad: '', nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=nbashgufvishdafjk23432&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', meta: { advertiserDomains: [ @@ -628,6 +662,7 @@ describe('KoblerAdapter', function () { } }); spec.onBidWon({ + originalCpm: 1.532, cpm: 8.341, currency: 'NOK', nurl: 'https://atag.essrtb.com/serve/prebid_win_notification?payload=sdhfusdaobfadslf234324&sp=${AUCTION_PRICE}&sp_cur=${AUCTION_PRICE_CURRENCY}&asp=${AD_SERVER_PRICE}&asp_cur=${AD_SERVER_PRICE_CURRENCY}', @@ -670,22 +705,14 @@ describe('KoblerAdapter', function () { auctionId: 'a1fba829-dd41-409f-acfb-b7b0ac5f30c6', bidId: 'ef236c6c-e934-406b-a877-d7be8e8a839a', timeout: 100, - params: [ - { - placementId: 'xrwg62731', - } - ], + params: [], }, { adUnitCode: 'adunit-code-2', auctionId: 'a1fba829-dd41-409f-acfb-b7b0ac5f30c6', bidId: 'ca4121c8-9a4a-46ba-a624-e9b64af206f2', timeout: 100, - params: [ - { - placementId: 'bc482234', - } - ], + params: [], } ]); @@ -693,12 +720,12 @@ describe('KoblerAdapter', function () { expect(utils.triggerPixel.getCall(0).args[0]).to.be.equal( 'https://bid.essrtb.com/notify/prebid_timeout?ad_unit_code=adunit-code&' + 'auction_id=a1fba829-dd41-409f-acfb-b7b0ac5f30c6&bid_id=ef236c6c-e934-406b-a877-d7be8e8a839a&timeout=100&' + - 'placement_id=xrwg62731&page_url=' + encodeURIComponent(getRefererInfo().referer) + 'page_url=' + encodeURIComponent(getRefererInfo().page) ); expect(utils.triggerPixel.getCall(1).args[0]).to.be.equal( 'https://bid.essrtb.com/notify/prebid_timeout?ad_unit_code=adunit-code-2&' + 'auction_id=a1fba829-dd41-409f-acfb-b7b0ac5f30c6&bid_id=ca4121c8-9a4a-46ba-a624-e9b64af206f2&timeout=100&' + - 'placement_id=bc482234&page_url=' + encodeURIComponent(getRefererInfo().referer) + 'page_url=' + encodeURIComponent(getRefererInfo().page) ); }); }); diff --git a/test/spec/modules/konduitAnalyticsAdapter_spec.js b/test/spec/modules/konduitAnalyticsAdapter_spec.js index ac557d27f90..e79ae2feeeb 100644 --- a/test/spec/modules/konduitAnalyticsAdapter_spec.js +++ b/test/spec/modules/konduitAnalyticsAdapter_spec.js @@ -121,6 +121,5 @@ describe(`Konduit Analytics Adapter`, () => { expect(requestBody.konduitId).to.be.equal(konduitId); expect(requestBody.prebidVersion).to.be.equal('$prebid.version$'); expect(requestBody.environment).to.be.an('object'); - sinon.assert.callCount(konduitAnalyticsAdapter.track, 6); }); }); diff --git a/test/spec/modules/kubientBidAdapter_spec.js b/test/spec/modules/kubientBidAdapter_spec.js index f7afc709564..a6241aa8d41 100644 --- a/test/spec/modules/kubientBidAdapter_spec.js +++ b/test/spec/modules/kubientBidAdapter_spec.js @@ -91,7 +91,7 @@ describe('KubientAdapter', function () { auctionStart: 1472239426000, timeout: 5000, refererInfo: { - referer: 'http://www.example.com', + page: 'http://www.example.com', reachedTop: true, }, gdprConsent: { diff --git a/test/spec/modules/kueezBidAdapter_spec.js b/test/spec/modules/kueezBidAdapter_spec.js new file mode 100644 index 00000000000..cd95a9ebdc6 --- /dev/null +++ b/test/spec/modules/kueezBidAdapter_spec.js @@ -0,0 +1,482 @@ +import { expect } from 'chai'; +import { spec } from 'modules/kueezBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; +import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; +import * as utils from 'src/utils.js'; + +const ENDPOINT = 'https://hb.kueezssp.com/hb-kz-multi'; +const TEST_ENDPOINT = 'https://hb.kueezssp.com/hb-multi-kz-test'; +const TTL = 360; +/* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */ + +describe('kueezBidAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [['640', '480']], + 'params': { + 'org': 'test-publisher-id' + } + }; + + it('should return true when required params are passed', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not found', function () { + const newBid = Object.assign({}, bid); + delete newBid.params; + newBid.params = { + 'org': null + }; + expect(spec.isBidRequestValid(newBid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [ + { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [[640, 480]], + 'params': { + 'org': 'test-publisher-id' + }, + 'bidId': '5wfg9887sd5478', + 'loop': 1, + 'bidderRequestId': 'op87952ewq8567', + 'auctionId': '87se98rt-5789-8735-2546-t98yh5678231', + 'mediaTypes': { + 'video': { + 'playerSize': [[640, 480]], + 'context': 'instream' + } + }, + 'vastXml': '"..."' + }, + { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'params': { + 'org': 'test-publisher-id' + }, + 'bidId': '5wfg9887sd5478', + 'loop': 1, + 'bidderRequestId': 'op87952ewq8567', + 'auctionId': '87se98rt-5789-8735-2546-t98yh5678231', + 'mediaTypes': { + 'banner': { + } + }, + 'ad': '""' + } + ]; + + const testModeBidRequests = [ + { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [[640, 480]], + 'params': { + 'org': 'test-publisher-id', + 'testMode': true + }, + 'bidId': '5wfg9887sd5478', + 'loop': 2, + 'bidderRequestId': 'op87952ewq8567', + 'auctionId': '87se98rt-5789-8735-2546-t98yh5678231', + } + ]; + + const bidderRequest = { + bidderCode: 'kueez', + } + const placementId = '12345678'; + + it('sends the placementId to ENDPOINT via POST', function () { + bidRequests[0].params.placementId = placementId; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].placementId).to.equal(placementId); + }); + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('sends bid request to TEST ENDPOINT via POST', function () { + const request = spec.buildRequests(testModeBidRequests, bidderRequest); + expect(request.url).to.equal(TEST_ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should send the correct bid Id', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].bidId).to.equal('5wfg9887sd5478'); + }); + + it('should send the correct sizes array', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].sizes).to.be.an('array'); + expect(request.data.bids[0].sizes).to.equal(bidRequests[0].sizes) + expect(request.data.bids[1].sizes).to.be.an('array'); + expect(request.data.bids[1].sizes).to.equal(bidRequests[1].sizes) + }); + + it('should send the correct media type', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].mediaType).to.equal(VIDEO) + expect(request.data.bids[1].mediaType).to.equal(BANNER) + }); + + it('should respect syncEnabled option', function() { + config.setConfig({ + userSync: { + syncEnabled: false, + filterSettings: { + all: { + bidders: '*', + filter: 'include' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('cs_method'); + }); + + it('should respect "iframe" filter settings', function () { + config.setConfig({ + userSync: { + syncEnabled: true, + filterSettings: { + iframe: { + bidders: [spec.code], + filter: 'include' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('cs_method', 'iframe'); + }); + + it('should respect "all" filter settings', function () { + config.setConfig({ + userSync: { + syncEnabled: true, + filterSettings: { + all: { + bidders: [spec.code], + filter: 'include' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('cs_method', 'iframe'); + }); + + it('should send the pixel user sync param if userSync is enabled and no "iframe" or "all" configs are present', function () { + config.resetConfig(); + config.setConfig({ + userSync: { + syncEnabled: true, + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('cs_method', 'pixel'); + }); + + it('should respect total exclusion', function() { + config.setConfig({ + userSync: { + syncEnabled: true, + filterSettings: { + image: { + bidders: [spec.code], + filter: 'exclude' + }, + iframe: { + bidders: [spec.code], + filter: 'exclude' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('cs_method'); + }); + + it('should have us_privacy param if usPrivacy is available in the bidRequest', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('us_privacy', '1YNN'); + }); + + it('should have an empty us_privacy param if usPrivacy is missing in the bidRequest', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('us_privacy'); + }); + + it('should not send the gdpr param if gdprApplies is false in the bidRequest', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: false}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('gdpr'); + expect(request.data.params).to.not.have.property('gdpr_consent'); + }); + + it('should send the gdpr param if gdprApplies is true in the bidRequest', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('gdpr', true); + expect(request.data.params).to.have.property('gdpr_consent', 'test-consent-string'); + }); + + it('should have schain param if it is available in the bidRequest', () => { + const schain = { + ver: '1.0', + complete: 1, + nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }], + }; + bidRequests[0].schain = schain; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('schain', '1.0,1!indirectseller.com,00001,1,,,'); + }); + + it('should set flooPrice to getFloor.floor value if it is greater than params.floorPrice', function() { + const bid = utils.deepClone(bidRequests[0]); + bid.getFloor = () => { + return { + currency: 'USD', + floor: 3.32 + } + } + bid.params.floorPrice = 0.64; + const request = spec.buildRequests([bid], bidderRequest); + expect(request.data.bids[0]).to.be.an('object'); + expect(request.data.bids[0]).to.have.property('floorPrice', 3.32); + }); + + it('should set floorPrice to params.floorPrice value if it is greater than getFloor.floor', function() { + const bid = utils.deepClone(bidRequests[0]); + bid.getFloor = () => { + return { + currency: 'USD', + floor: 0.8 + } + } + bid.params.floorPrice = 1.5; + const request = spec.buildRequests([bid], bidderRequest); + expect(request.data.bids[0]).to.be.an('object'); + expect(request.data.bids[0]).to.have.property('floorPrice', 1.5); + }); + }); + + describe('interpretResponse', function () { + const response = { + params: { + currency: 'USD', + netRevenue: true, + }, + bids: [{ + cpm: 12.5, + vastXml: '', + width: 640, + height: 480, + requestId: '21e12606d47ba7', + adomain: ['abc.com'], + mediaType: VIDEO + }, + { + cpm: 12.5, + ad: '""', + width: 300, + height: 250, + requestId: '21e12606d47ba7', + adomain: ['abc.com'], + mediaType: BANNER + }] + }; + + const expectedVideoResponse = { + cpm: 12.5, + creativeId: '21e12606d47ba7', + currency: 'USD', + height: 480, + mediaType: VIDEO, + meta: { + mediaType: VIDEO, + advertiserDomains: ['abc.com'] + }, + netRevenue: true, + nurl: 'http://example.com/win/1234', + requestId: '21e12606d47ba7', + ttl: TTL, + width: 640, + vastXml: '' + }; + + const expectedBannerResponse = { + cpm: 12.5, + creativeId: '21e12606d47ba7', + currency: 'USD', + height: 480, + mediaType: BANNER, + meta: { + mediaType: BANNER, + advertiserDomains: ['abc.com'] + }, + netRevenue: true, + nurl: 'http://example.com/win/1234', + requestId: '21e12606d47ba7', + ttl: TTL, + width: 640, + ad: '""' + }; + + it('should get correct bid response', function () { + const result = spec.interpretResponse({ body: response }); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedVideoResponse)); + expect(Object.keys(result[1])).to.deep.equal(Object.keys(expectedBannerResponse)); + }); + + it('video type should have vastXml key', function () { + const result = spec.interpretResponse({ body: response }); + expect(result[0].vastXml).to.equal(expectedVideoResponse.vastXml) + }); + + it('banner type should have ad key', function () { + const result = spec.interpretResponse({ body: response }); + expect(result[1].ad).to.equal(expectedBannerResponse.ad) + }); + }) + + describe('getUserSyncs', function() { + const imageSyncResponse = { + body: { + params: { + userSyncPixels: [ + 'https://image-sync-url.test/1', + 'https://image-sync-url.test/2', + 'https://image-sync-url.test/3' + ] + } + } + }; + + const iframeSyncResponse = { + body: { + params: { + userSyncURL: 'https://iframe-sync-url.test' + } + } + }; + + it('should register all img urls from the response', function() { + const syncs = spec.getUserSyncs({ pixelEnabled: true }, [imageSyncResponse]); + expect(syncs).to.deep.equal([ + { + type: 'image', + url: 'https://image-sync-url.test/1' + }, + { + type: 'image', + url: 'https://image-sync-url.test/2' + }, + { + type: 'image', + url: 'https://image-sync-url.test/3' + } + ]); + }); + + it('should register the iframe url from the response', function() { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, [iframeSyncResponse]); + expect(syncs).to.deep.equal([ + { + type: 'iframe', + url: 'https://iframe-sync-url.test' + } + ]); + }); + + it('should register both image and iframe urls from the responses', function() { + const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [iframeSyncResponse, imageSyncResponse]); + expect(syncs).to.deep.equal([ + { + type: 'iframe', + url: 'https://iframe-sync-url.test' + }, + { + type: 'image', + url: 'https://image-sync-url.test/1' + }, + { + type: 'image', + url: 'https://image-sync-url.test/2' + }, + { + type: 'image', + url: 'https://image-sync-url.test/3' + } + ]); + }); + + it('should handle an empty response', function() { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, []); + expect(syncs).to.deep.equal([]); + }); + + it('should handle when user syncs are disabled', function() { + const syncs = spec.getUserSyncs({ pixelEnabled: false }, [imageSyncResponse]); + expect(syncs).to.deep.equal([]); + }); + }) + + describe('onBidWon', function() { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + + it('Should trigger pixel if bid nurl', function() { + const bid = { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [['640', '480']], + 'nurl': 'http://example.com/win/1234', + 'params': { + 'org': 'test-publisher-id' + } + }; + + spec.onBidWon(bid); + expect(utils.triggerPixel.callCount).to.equal(1) + }) + }) +}); diff --git a/test/spec/modules/kueezRtbBidAdapter_spec.js b/test/spec/modules/kueezRtbBidAdapter_spec.js new file mode 100644 index 00000000000..ebd11885af4 --- /dev/null +++ b/test/spec/modules/kueezRtbBidAdapter_spec.js @@ -0,0 +1,650 @@ +import {expect} from 'chai'; +import { + spec as adapter, + createDomain, + hashCode, + extractPID, + extractCID, + extractSubDomain, + getStorageItem, + setStorageItem, + tryParseJSON, + getUniqueDealId, +} from 'modules/kueezRtbBidAdapter.js'; +import * as utils from 'src/utils.js'; +import {version} from 'package.json'; +import {useFakeTimers} from 'sinon'; +import {BANNER, VIDEO} from '../../../src/mediaTypes'; +import {config} from '../../../src/config'; + +export const TEST_ID_SYSTEMS = ['britepoolid', 'criteoId', 'id5id', 'idl_env', 'lipb', 'netId', 'parrableId', 'pubcid', 'tdid', 'pubProvidedId']; + +const SUB_DOMAIN = 'exchange'; + +const BID = { + 'bidId': '2d52001cabd527', + 'adUnitCode': 'div-gpt-ad-12345-0', + 'params': { + 'subDomain': SUB_DOMAIN, + 'cId': '59db6b3b4ffaa70004f45cdc', + 'pId': '59ac17c192832d0011283fe3', + 'bidFloor': 0.1, + 'ext': { + 'param1': 'loremipsum', + 'param2': 'dolorsitamet' + } + }, + 'placementCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', + 'sizes': [[300, 250], [300, 600]], + 'bidderRequestId': '1fdb5ff1b6eaa7', + 'auctionId': 'auction_id', + 'bidRequestsCount': 4, + 'bidderRequestsCount': 3, + 'bidderWinsCount': 1, + 'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a', + 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc', + 'mediaTypes': [BANNER], + 'ortb2Imp': { + 'ext': { + 'gpid': '0123456789' + } + } +}; + +const VIDEO_BID = { + 'bidId': '2d52001cabd527', + 'adUnitCode': '63550ad1ff6642d368cba59dh5884270560', + 'bidderRequestId': '12a8ae9ada9c13', + 'transactionId': '56e184c6-bde9-497b-b9b9-cf47a61381ee', + 'auctionId': 'auction_id', + 'bidRequestsCount': 4, + 'bidderRequestsCount': 3, + 'bidderWinsCount': 1, + 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc', + 'params': { + 'subDomain': SUB_DOMAIN, + 'cId': '635509f7ff6642d368cb9837', + 'pId': '59ac17c192832d0011283fe3', + 'bidFloor': 0.1 + }, + 'sizes': [[545, 307]], + 'mediaTypes': { + 'video': { + 'playerSize': [[545, 307]], + 'context': 'instream', + 'mimes': [ + 'video/mp4', + 'application/javascript' + ], + 'protocols': [2, 3, 5, 6], + 'maxduration': 60, + 'minduration': 0, + 'startdelay': 0, + 'linearity': 1, + 'api': [2], + 'placement': 1 + } + } +} + +const BIDDER_REQUEST = { + 'gdprConsent': { + 'consentString': 'consent_string', + 'gdprApplies': true + }, + 'gppString': 'gpp_string', + 'gppSid': [7], + 'uspConsent': 'consent_string', + 'refererInfo': { + 'page': 'https://www.greatsite.com', + 'ref': 'https://www.somereferrer.com' + }, + 'ortb2': { + 'regs': { + 'gpp': 'gpp_string', + 'gpp_sid': [7] + }, + 'device': { + 'sua': { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + } + } + } +}; + +const SERVER_RESPONSE = { + body: { + cid: 'testcid123', + results: [{ + 'ad': '', + 'price': 0.8, + 'creativeId': '12610997325162499419', + 'exp': 30, + 'width': 300, + 'height': 250, + 'advertiserDomains': ['securepubads.g.doubleclick.net'], + 'cookies': [{ + 'src': 'https://sync.com', + 'type': 'iframe' + }, { + 'src': 'https://sync.com', + 'type': 'img' + }] + }] + } +}; + +const VIDEO_SERVER_RESPONSE = { + body: { + 'cid': '635509f7ff6642d368cb9837', + 'results': [{ + 'ad': '', + 'advertiserDomains': ['kueezrtb.com'], + 'exp': 60, + 'width': 545, + 'height': 307, + 'mediaType': 'video', + 'creativeId': '12610997325162499419', + 'price': 2, + 'cookies': [] + }] + } +}; + +const REQUEST = { + data: { + width: 300, + height: 250, + bidId: '2d52001cabd527' + } +}; + +function getTopWindowQueryParams() { + try { + const parsedUrl = utils.parseUrl(window.top.document.URL, {decodeSearchAsString: true}); + return parsedUrl.search; + } catch (e) { + return ''; + } +} + +describe('KueezRtbBidAdapter', function () { + describe('validtae spec', function () { + it('exists and is a function', function () { + expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function'); + }); + + it('exists and is a function', function () { + expect(adapter.buildRequests).to.exist.and.to.be.a('function'); + }); + + it('exists and is a function', function () { + expect(adapter.interpretResponse).to.exist.and.to.be.a('function'); + }); + + it('exists and is a function', function () { + expect(adapter.getUserSyncs).to.exist.and.to.be.a('function'); + }); + + it('exists and is a string', function () { + expect(adapter.code).to.exist.and.to.be.a('string'); + }); + + it('exists and contains media types', function () { + expect(adapter.supportedMediaTypes).to.exist.and.to.be.an('array').with.length(2); + expect(adapter.supportedMediaTypes).to.contain.members([BANNER, VIDEO]); + }); + }); + + describe('validate bid requests', function () { + it('should require cId', function () { + const isValid = adapter.isBidRequestValid({ + params: { + pId: 'pid' + } + }); + expect(isValid).to.be.false; + }); + + it('should require pId', function () { + const isValid = adapter.isBidRequestValid({ + params: { + cId: 'cid' + } + }); + expect(isValid).to.be.false; + }); + + it('should validate correctly', function () { + const isValid = adapter.isBidRequestValid({ + params: { + cId: 'cid', + pId: 'pid' + } + }); + expect(isValid).to.be.true; + }); + }); + + describe('build requests', function () { + let sandbox; + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + kueezrtb: { + storageAllowed: true + } + }; + sandbox = sinon.sandbox.create(); + sandbox.stub(Date, 'now').returns(1000); + }); + + it('should build video request', function () { + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); + config.setConfig({ + bidderTimeout: 3000 + }); + const requests = adapter.buildRequests([VIDEO_BID], BIDDER_REQUEST); + expect(requests).to.have.length(1); + expect(requests[0]).to.deep.equal({ + method: 'POST', + url: `${createDomain(SUB_DOMAIN)}/prebid/multi/635509f7ff6642d368cb9837`, + data: { + adUnitCode: '63550ad1ff6642d368cba59dh5884270560', + bidFloor: 0.1, + bidId: '2d52001cabd527', + bidderVersion: adapter.version, + bidderRequestId: '12a8ae9ada9c13', + cb: 1000, + gdpr: 1, + gdprConsent: 'consent_string', + usPrivacy: 'consent_string', + gppString: 'gpp_string', + gppSid: [7], + prebidVersion: version, + transactionId: '56e184c6-bde9-497b-b9b9-cf47a61381ee', + auctionId: 'auction_id', + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + publisherId: '59ac17c192832d0011283fe3', + url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', + res: `${window.top.screen.width}x${window.top.screen.height}`, + schain: VIDEO_BID.schain, + sizes: ['545x307'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, + uniqueDealId: `${hashUrl}_${Date.now().toString()}`, + uqs: getTopWindowQueryParams(), + mediaTypes: { + video: { + api: [2], + context: 'instream', + linearity: 1, + maxduration: 60, + mimes: [ + 'video/mp4', + 'application/javascript' + ], + minduration: 0, + placement: 1, + playerSize: [[545, 307]], + protocols: [2, 3, 5, 6], + startdelay: 0 + } + }, + gpid: '' + } + }); + }); + + it('should build banner request for each size', function () { + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); + config.setConfig({ + bidderTimeout: 3000 + }); + const requests = adapter.buildRequests([BID], BIDDER_REQUEST); + expect(requests).to.have.length(1); + expect(requests[0]).to.deep.equal({ + method: 'POST', + url: `${createDomain(SUB_DOMAIN)}/prebid/multi/59db6b3b4ffaa70004f45cdc`, + data: { + gdprConsent: 'consent_string', + gdpr: 1, + gppString: 'gpp_string', + gppSid: [7], + usPrivacy: 'consent_string', + transactionId: 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', + auctionId: 'auction_id', + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + bidderRequestId: '1fdb5ff1b6eaa7', + sizes: ['300x250', '300x600'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, + url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', + cb: 1000, + bidFloor: 0.1, + bidId: '2d52001cabd527', + adUnitCode: 'div-gpt-ad-12345-0', + publisherId: '59ac17c192832d0011283fe3', + uniqueDealId: `${hashUrl}_${Date.now().toString()}`, + bidderVersion: adapter.version, + prebidVersion: version, + schain: BID.schain, + res: `${window.top.screen.width}x${window.top.screen.height}`, + mediaTypes: [BANNER], + gpid: '0123456789', + uqs: getTopWindowQueryParams(), + 'ext.param1': 'loremipsum', + 'ext.param2': 'dolorsitamet', + } + }); + }); + + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + sandbox.restore(); + }); + }); + describe('getUserSyncs', function () { + it('should have valid user sync with iframeEnabled', function () { + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + type: 'iframe', + url: 'https://sync.kueezrtb.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=' + }]); + }); + + it('should have valid user sync with cid on response', function () { + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); + expect(result).to.deep.equal([{ + type: 'iframe', + url: 'https://sync.kueezrtb.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=' + }]); + }); + + it('should have valid user sync with pixelEnabled', function () { + const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + 'url': 'https://sync.kueezrtb.com/api/sync/image/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=', + 'type': 'image' + }]); + }); + + it('should generate url with consent data', function () { + const gdprConsent = { + gdprApplies: true, + consentString: 'consent_string' + }; + const uspConsent = 'usp_string'; + const gppConsent = { + gppString: 'gpp_string', + applicableSections: [7] + } + + const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE], gdprConsent, uspConsent, gppConsent); + + expect(result).to.deep.equal([{ + 'url': 'https://sync.kueezrtb.com/api/sync/image/?cid=testcid123&gdpr=1&gdpr_consent=consent_string&us_privacy=usp_string&gpp=gpp_string&gpp_sid=7', + 'type': 'image' + }]); + }); + }); + + describe('interpret response', function () { + it('should return empty array when there is no response', function () { + const responses = adapter.interpretResponse(null); + expect(responses).to.be.empty; + }); + + it('should return empty array when there is no ad', function () { + const responses = adapter.interpretResponse({price: 1, ad: ''}); + expect(responses).to.be.empty; + }); + + it('should return empty array when there is no price', function () { + const responses = adapter.interpretResponse({price: null, ad: 'great ad'}); + expect(responses).to.be.empty; + }); + + it('should return an array of interpreted banner responses', function () { + const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0]).to.deep.equal({ + requestId: '2d52001cabd527', + cpm: 0.8, + width: 300, + height: 250, + creativeId: '12610997325162499419', + currency: 'USD', + netRevenue: true, + ttl: 30, + ad: '', + meta: { + advertiserDomains: ['securepubads.g.doubleclick.net'] + } + }); + }); + + it('should get meta from response metaData', function () { + const serverResponse = utils.deepClone(SERVER_RESPONSE); + serverResponse.body.results[0].metaData = { + advertiserDomains: ['kueezrtb.com'], + agencyName: 'Agency Name', + }; + const responses = adapter.interpretResponse(serverResponse, REQUEST); + expect(responses[0].meta).to.deep.equal({ + advertiserDomains: ['kueezrtb.com'], + agencyName: 'Agency Name' + }); + }); + + it('should return an array of interpreted video responses', function () { + const responses = adapter.interpretResponse(VIDEO_SERVER_RESPONSE, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0]).to.deep.equal({ + requestId: '2d52001cabd527', + cpm: 2, + width: 545, + height: 307, + mediaType: 'video', + creativeId: '12610997325162499419', + currency: 'USD', + netRevenue: true, + ttl: 60, + vastXml: '', + meta: { + advertiserDomains: ['kueezrtb.com'] + } + }); + }); + + it('should take default TTL', function () { + const serverResponse = utils.deepClone(SERVER_RESPONSE); + delete serverResponse.body.results[0].exp; + const responses = adapter.interpretResponse(serverResponse, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0].ttl).to.equal(300); + }); + }); + + describe('user id system', function () { + TEST_ID_SYSTEMS.forEach((idSystemProvider) => { + const id = Date.now().toString(); + const bid = utils.deepClone(BID); + + const userId = (function () { + switch (idSystemProvider) { + case 'lipb': + return {lipbid: id}; + case 'parrableId': + return {eid: id}; + case 'id5id': + return {uid: id}; + default: + return id; + } + })(); + + bid.userId = { + [idSystemProvider]: userId + }; + + it(`should include 'uid.${idSystemProvider}' in request params`, function () { + const requests = adapter.buildRequests([bid], BIDDER_REQUEST); + expect(requests[0].data[`uid.${idSystemProvider}`]).to.equal(id); + }); + }); + }); + + describe('alternate param names extractors', function () { + it('should return undefined when param not supported', function () { + const cid = extractCID({'c_id': '1'}); + const pid = extractPID({'p_id': '1'}); + const subDomain = extractSubDomain({'sub_domain': 'prebid'}); + expect(cid).to.be.undefined; + expect(pid).to.be.undefined; + expect(subDomain).to.be.undefined; + }); + + it('should return value when param supported', function () { + const cid = extractCID({'cID': '1'}); + const pid = extractPID({'Pid': '2'}); + const subDomain = extractSubDomain({'subDOMAIN': 'prebid'}); + expect(cid).to.be.equal('1'); + expect(pid).to.be.equal('2'); + expect(subDomain).to.be.equal('prebid'); + }); + }); + + describe('unique deal id', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + kueezrtb: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + const key = 'myKey'; + let uniqueDealId; + beforeEach(() => { + uniqueDealId = getUniqueDealId(key, 0); + }) + + it('should get current unique deal id', function (done) { + // waiting some time so `now` will become past + setTimeout(() => { + const current = getUniqueDealId(key); + expect(current).to.be.equal(uniqueDealId); + done(); + }, 200); + }); + + it('should get new unique deal id on expiration', function (done) { + setTimeout(() => { + const current = getUniqueDealId(key, 100); + expect(current).to.not.be.equal(uniqueDealId); + done(); + }, 200) + }); + }); + + describe('storage utils', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + kueezrtb: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + it('should get value from storage with create param', function () { + const now = Date.now(); + const clock = useFakeTimers({ + shouldAdvanceTime: true, + now + }); + setStorageItem('myKey', 2020); + const {value, created} = getStorageItem('myKey'); + expect(created).to.be.equal(now); + expect(value).to.be.equal(2020); + expect(typeof value).to.be.equal('number'); + expect(typeof created).to.be.equal('number'); + clock.restore(); + }); + + it('should get external stored value', function () { + const value = 'superman' + window.localStorage.setItem('myExternalKey', value); + const item = getStorageItem('myExternalKey'); + expect(item).to.be.equal(value); + }); + + it('should parse JSON value', function () { + const data = JSON.stringify({event: 'send'}); + const {event} = tryParseJSON(data); + expect(event).to.be.equal('send'); + }); + + it('should get original value on parse fail', function () { + const value = 21; + const parsed = tryParseJSON(value); + expect(typeof parsed).to.be.equal('number'); + expect(parsed).to.be.equal(value); + }); + }); +}); diff --git a/test/spec/modules/lassoBidAdapter_spec.js b/test/spec/modules/lassoBidAdapter_spec.js new file mode 100644 index 00000000000..3695889aca0 --- /dev/null +++ b/test/spec/modules/lassoBidAdapter_spec.js @@ -0,0 +1,179 @@ +import { expect } from 'chai'; +import { spec } from 'modules/lassoBidAdapter.js'; +import { server } from '../../mocks/xhr'; + +const ENDPOINT_URL = 'https://trc.lhmos.com/prebid'; + +const bid = { + bidder: 'lasso', + params: { + adUnitId: 123456 + }, + auctionStart: Date.now(), + adUnitCode: 'adunit-code', + auctionId: 'cfa6f46d-4584-46e1-9c00-54769abb51e3', + bidderRequestId: 'a123b456c789d', + bidId: '123a456b789', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + sizes: [[300, 250]], + src: 'client', + transactionId: '26740296-0111-4b7a-80df-7196823026f4' +}; + +const bidderRequest = { + auctionId: 'cfa6f46d-4584-46e1-9c00-54769abb51e3', + auctionStart: Date.now(), + start: Date.now(), + biddeCode: 'lasso', + bidderRequestId: 'a123b456c789d', + bids: [bid], + timeout: 10000 +}; + +describe('lassoBidAdapter', function () { + describe('All needed functions are available', function() { + it(`isBidRequestValid is present and type function`, function () { + expect(spec.isBidRequestValid).to.exist.and.to.be.a('function') + }); + + it(`buildRequests is present and type function`, function () { + expect(spec.buildRequests).to.exist.and.to.be.a('function') + }); + + it(`interpretResponse is present and type function`, function () { + expect(spec.interpretResponse).to.exist.and.to.be.a('function') + }); + + it(`onTimeout is present and type function`, function () { + expect(spec.onTimeout).to.exist.and.to.be.a('function') + }); + + it(`onBidWon is present and type function`, function () { + expect(spec.onBidWon).to.exist.and.to.be.a('function') + }); + }); + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should return true when there are extra params', function () { + const bid = Object.assign({}, bid, { + params: { + adUnitId: 123456, + zone: 1, + publisher: 'test' + } + }) + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('should return false when there are no params', function () { + const invalidBid = { ...bid }; + delete invalidBid.params; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + let validBidRequests, bidRequest; + before(() => { + validBidRequests = spec.buildRequests([bid], bidderRequest); + expect(validBidRequests).to.be.an('array').that.is.not.empty; + bidRequest = validBidRequests[0]; + }) + + it('Returns valid bidRequest', function () { + expect(bidRequest).to.exist; + expect(bidRequest.method).to.exist; + expect(bidRequest.url).to.exist; + expect(bidRequest.data).to.exist; + }); + + it('Returns GET method', function() { + expect(bidRequest.method).to.exist; + expect(bidRequest.method).to.equal('GET'); + }); + }); + + describe('interpretResponse', function () { + let serverResponse = { + body: { + bidid: '123456789', + id: '33302780340222111', + bid: { + price: 1, + w: 728, + h: 90, + crid: 123456, + ad: '', + mediaType: 'banner' + }, + meta: { + cat: ['1', '2', '3', '4'], + advertiserDomains: ['lassomarketing.io'], + advertiserName: 'Lasso' + }, + cur: 'USD', + netRevenue: false, + ttl: 300, + } + }; + + it('should get the correct bid response', function () { + let expectedResponse = { + requestId: '123456789', + cpm: 1, + currency: 'USD', + width: 728, + height: 90, + creativeId: 123456, + netRevenue: false, + ttl: 300, + ad: '', + mediaType: 'banner', + meta: { + secondaryCatIds: ['1', '2', '3', '4'], + advertiserDomains: ['lassomarketing.io'], + advertiserName: 'Lasso', + mediaType: 'banner' + } + }; + let result = spec.interpretResponse(serverResponse); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse)); + }); + }); + + describe('onTimeout', () => { + it('should send timeout', () => { + const timeoutData = { + bidder: 'lasso', + auctionId: 'cfa6f46d-4584-46e1-9c00-54769abb51e3', + dUnitCode: 'adunit-code', + bidId: '123a456b789', + params: { + adUnitId: 123456, + }, + timeout: 3000 + }; + spec.onTimeout(timeoutData); + + expect(server.requests[0].method).to.equal('POST'); + expect(server.requests[0].url).to.equal(ENDPOINT_URL + '/timeout'); + expect(JSON.parse(server.requests[0].requestBody)).to.deep.equal(timeoutData); + }); + }); + + describe('onBidWon', () => { + it('should send bid won request', () => { + spec.onBidWon(bid); + + expect(server.requests[0].method).to.equal('POST'); + expect(server.requests[0].url).to.equal(ENDPOINT_URL + '/won'); + expect(JSON.parse(server.requests[0].requestBody)).to.deep.equal(bid); + }); + }); +}); diff --git a/test/spec/modules/lemmaDigitalBidAdapter_spec.js b/test/spec/modules/lemmaDigitalBidAdapter_spec.js new file mode 100644 index 00000000000..d50728dce3c --- /dev/null +++ b/test/spec/modules/lemmaDigitalBidAdapter_spec.js @@ -0,0 +1,623 @@ +import { expect } from 'chai'; +import { spec } from 'modules/lemmaDigitalBidAdapter.js'; +import * as utils from 'src/utils.js'; +import { config } from 'src/config.js'; +const constants = require('src/constants.json'); + +describe('lemmaDigitalBidAdapter', function () { + let bidRequests; + let videoBidRequests; + let bidResponses; + let videoBidResponse; + let schainConfig; + beforeEach(function () { + schainConfig = { + 'complete': 0, + 'nodes': [ + { + 'asi': 'mobupps.com', + 'sid': 'c74d97b01eae257e44aa9d5bade97baf5149', + 'rid': '79c25703ad5935b0b23b66d210dad1f3', + 'hp': 1 + }, + { + 'asi': 'lemmatechnologies.com', + 'sid': '975', + 'rid': 'a455157a-a1fb-11ed-a0e4-d08e79f7ace0', + 'hp': 1 + } + ] + }; + bidRequests = [{ + bidder: 'lemmadigital', + bidId: '22bddb28db77d', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD', + bidFloor: 1.3, + geo: { + lat: '12.3', + lon: '23.7', + }, + banner: { + w: 300, + h: 250, + }, + tmax: 300, + bcat: ['IAB-26'] + }, + sizes: [ + [300, 250], + [300, 600] + ], + schain: schainConfig + }]; + videoBidRequests = [{ + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bidder: 'lemmadigital', + bidId: '22bddb28db77d', + params: { + pubId: 1001, + adunitId: 1, + bidFloor: 1.3, + tmax: 300, + bcat: ['IAB-26'], + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + }, + schain: schainConfig + }]; + bidResponses = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '74858439-49D7-4169-BA5D-44A046315B2F', + 'impid': '22bddb28db77d', + 'price': 1.3, + 'adm': '

lemma"Connecting Advertisers and Publishers directly"

', + 'adomain': ['amazon.com'], + 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', + 'cid': '22918', + 'crid': 'v55jutrh', + 'dealid': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420', + 'h': 250, + 'w': 300, + 'ext': {} + }] + }] + } + }; + videoBidResponse = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '74858439-49D7-4169-BA5D-44A046315B2F', + 'impid': '22bddb28db77d', + 'price': 1.3, + 'adm': 'Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1', + 'adomain': ['amazon.com'], + 'iurl': 'https://thetradedesk-t-general.s3.amazonaws.com/AdvertiserLogos/vgl908z.png', + 'cid': '22918', + 'crid': 'v55jutrh', + 'dealid': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420', + 'h': 250, + 'w': 300, + 'ext': {} + }] + }] + } + }; + }); + describe('implementation', function () { + describe('Bid validations', function () { + it('valid bid case', function () { + let validBid = { + bidder: 'lemmadigital', + params: { + pubId: 1001, + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + }); + it('invalid bid case', function () { + let isValid = spec.isBidRequestValid(); + expect(isValid).to.equal(false); + }); + it('invalid bid case: pubId not passed', function () { + let validBid = { + bidder: 'lemmadigital', + params: { + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: pubId is not number', function () { + let validBid = { + bidder: 'lemmadigital', + params: { + pubId: '301', + adunitId: 1 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: adunitId is not passed', function () { + let validBid = { + bidder: 'lemmadigital', + params: { + pubId: 1001 + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + it('invalid bid case: video bid request mimes is not passed', function () { + let validBid = { + bidder: 'lemmadigital', + params: { + pubId: 1001, + adunitId: 1, + video: { + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + validBid.params.video.mimes = []; + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(false); + }); + }); + describe('Request formation', function () { + it('bidRequest check empty', function () { + let bidRequests = []; + let request = spec.buildRequests(bidRequests); + expect(request).to.equal(undefined); + }); + it('buildRequests function should not modify original bidRequests object', function () { + let originalBidRequests = utils.deepClone(bidRequests); + let request = spec.buildRequests(bidRequests); + expect(bidRequests).to.deep.equal(originalBidRequests); + }); + it('bidRequest imp array check empty', function () { + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + data.imp = []; + expect(data.imp.length).to.equal(0); + }); + it('Endpoint checking', function () { + let request = spec.buildRequests(bidRequests); + expect(request.url).to.equal('https://bid.lemmadigital.com/lemma/servad?pid=1001&aid=1'); + expect(request.method).to.equal('POST'); + }); + it('Request params check', function () { + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id + expect(data.imp[0].tagid).to.equal('1'); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.bidFloor); + expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain); + }); + + it('Set sizes from mediaTypes object', function () { + let newBannerRequest = utils.deepClone(bidRequests); + delete newBannerRequest[0].sizes; + let request = spec.buildRequests(newBannerRequest); + let data = JSON.parse(request.data); + expect(data.sizes).to.equal(undefined); + }); + it('Check request banner object present', function () { + let newBannerRequest = utils.deepClone(bidRequests); + let request = spec.buildRequests(newBannerRequest); + let data = JSON.parse(request.data); + expect(data.banner).to.deep.equal(undefined); + }); + it('Check device, source object not present', function () { + let newBannerRequest = utils.deepClone(bidRequests); + delete newBannerRequest[0].schain; + let request = spec.buildRequests(newBannerRequest); + let data = JSON.parse(request.data); + delete data.device; + delete data.source; + expect(data.source).to.equal(undefined); + expect(data.device).to.equal(undefined); + }); + it('Set content from config, set site.content', function () { + let sandbox = sinon.sandbox.create(); + const content = { + 'id': 'alpha-numeric-id' + }; + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + content: content + }; + return config[key]; + }); + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.site.content).to.deep.equal(content); + sandbox.restore(); + }); + it('Set content from config, set app.content', function () { + let bidRequest = [{ + bidder: 'lemmadigital', + params: { + pubId: 1001, + adunitId: 1, + video: { + skippable: true, + minduration: 5, + maxduration: 30 + }, + app: { + id: 'e0977d04e6bafece57b4b6e93314f10a', + name: 'AMC', + bundle: 'com.roku.amc', + storeurl: 'https://channelstore.roku.com/details/12716/amc', + cat: [ + 'IAB-26' + ], + publisher: { + 'id': '975' + } + }, + } + }]; + let sandbox = sinon.sandbox.create(); + const content = { + 'id': 'alpha-numeric-id' + }; + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + content: content + }; + return config[key]; + }); + let request = spec.buildRequests(bidRequest); + let data = JSON.parse(request.data); + expect(data.app.content).to.deep.equal(content); + sandbox.restore(); + }); + it('Set tmax from requestBids method', function () { + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.tmax).to.deep.equal(300); + }); + it('Request params check without mediaTypes object', function () { + let bidRequests = [{ + bidder: 'lemmadigital', + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(600); // height + }); + it('Request params check: without tagId', function () { + delete bidRequests[0].params.adunitId; + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.publisher.id).to.equal(bidRequests[0].params.pubId.toString()); // publisher Id + expect(data.imp[0].tagid).to.equal(undefined); // tagid + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + expect(data.imp[0].bidfloor).to.equal(bidRequests[0].params.bidFloor); + }); + it('Request params multi size format object check', function () { + let bidRequests = [{ + bidder: 'lemmadigital', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + /* case 1 - size passed in adslot */ + let request = spec.buildRequests(bidRequests); + let data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + /* case 2 - size passed in adslot as well as in sizes array */ + bidRequests[0].sizes = [ + [300, 600], + [300, 250] + ]; + bidRequests[0].mediaTypes = { + banner: { + sizes: [ + [300, 600], + [300, 250] + ] + } + }; + request = spec.buildRequests(bidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(600); // height + /* case 3 - size passed in sizes but not in adslot */ + bidRequests[0].params.adunitId = 1; + bidRequests[0].sizes = [ + [300, 250], + [300, 600] + ]; + bidRequests[0].mediaTypes = { + banner: { + sizes: [ + [300, 250], + [300, 600] + ] + } + }; + request = spec.buildRequests(bidRequests); + data = JSON.parse(request.data); + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].banner.format).exist.and.to.be.an('array'); + expect(data.imp[0].banner.format[0]).exist.and.to.be.an('object'); + expect(data.imp[0].banner.format[0].w).to.equal(300); // width + expect(data.imp[0].banner.format[0].h).to.equal(250); // height + }); + it('Request params currency check', function () { + let bidRequest = [{ + bidder: 'lemmadigital', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + } + }, + params: { + pubId: 1001, + adunitId: 1, + currency: 'AUD' + }, + sizes: [ + [300, 250], + [300, 600] + ] + }]; + /* case 1 - + currency specified in adunits + output: imp[0] use currency specified in bidRequests[0].params.currency + */ + let request = spec.buildRequests(bidRequest); + let data = JSON.parse(request.data); + expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); + /* case 2 - + currency specified in adunit + output: imp[0] use default currency - USD + */ + delete bidRequest[0].params.currency; + request = spec.buildRequests(bidRequest); + data = JSON.parse(request.data); + expect(data.imp[0].bidfloorcur).to.equal('USD'); + }); + it('Request params check for video ad', function () { + let request = spec.buildRequests(videoBidRequests); + let data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0].tagid).to.equal('1'); + expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); + expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); + expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); + expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + expect(data.source.ext.schain).to.deep.equal(videoBidRequests[0].schain); + }); + describe('setting imp.floor using floorModule', function () { + /* + Use the minimum value among floor from floorModule per mediaType + If params.bidFloor is set then take max(floor, min(floors from floorModule)) + set imp.bidfloor only if it is more than 0 + */ + + let newRequest; + let floorModuleTestData; + let getFloor = function (req) { + return floorModuleTestData[req.mediaType]; + }; + + beforeEach(() => { + floorModuleTestData = { + 'banner': { + 'currency': 'AUD', + 'floor': 1.50 + }, + 'video': { + 'currency': 'AUD', + 'floor': 2.00 + } + }; + newRequest = utils.deepClone(bidRequests); + newRequest[0].getFloor = getFloor; + }); + + it('bidfloor should be undefined if calculation is <= 0', function () { + floorModuleTestData.banner.floor = 0; // lowest of them all + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(undefined); + }); + + it('ignore floormodule o/p if floor is not number', function () { + floorModuleTestData.banner.floor = 'INR'; + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(undefined); // video will be lowest now + }); + + it('ignore floormodule o/p if currency is not matched', function () { + floorModuleTestData.banner.currency = 'INR'; + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(undefined); // video will be lowest now + }); + + it('bidFloor is not passed, use minimum from floorModule', function () { + newRequest[0].params.bidFloor = undefined; + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(1.5); + }); + + it('bidFloor is passed as 1, use min of floorModule as it is highest', function () { + newRequest[0].params.bidFloor = '1.0';// yes, we want it as a string + let request = spec.buildRequests(newRequest); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(1.5); + }); + }); + describe('Response checking', function () { + it('should check for valid response values', function () { + let request = spec.buildRequests(bidRequests); + let response = spec.interpretResponse(bidResponses, request); + expect(response).to.be.an('array').with.length.above(0); + expect(response[0].requestId).to.equal(bidResponses.body.seatbid[0].bid[0].impid); + expect(response[0].cpm).to.equal((bidResponses.body.seatbid[0].bid[0].price).toFixed(2)); + expect(response[0].width).to.equal(bidResponses.body.seatbid[0].bid[0].w); + expect(response[0].height).to.equal(bidResponses.body.seatbid[0].bid[0].h); + if (bidResponses.body.seatbid[0].bid[0].crid) { + expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].crid); + } else { + expect(response[0].creativeId).to.equal(bidResponses.body.seatbid[0].bid[0].id); + } + expect(response[0].dealId).to.equal(bidResponses.body.seatbid[0].bid[0].dealid); + expect(response[0].currency).to.equal('USD'); + expect(response[0].netRevenue).to.equal(false); + expect(response[0].ttl).to.equal(300); + }); + it('should check for valid banner mediaType in request', function () { + let request = spec.buildRequests(bidRequests); + let response = spec.interpretResponse(bidResponses, request); + + expect(response[0].mediaType).to.equal('banner'); + }); + it('should check for valid video mediaType in request', function () { + let request = spec.buildRequests(videoBidRequests); + let response = spec.interpretResponse(videoBidResponse, request); + + expect(response[0].mediaType).to.equal('video'); + }); + }); + }); + describe('Video request params', function () { + let sandbox, utilsMock, newVideoRequest; + beforeEach(() => { + utilsMock = sinon.mock(utils); + sandbox = sinon.sandbox.create(); + sandbox.spy(utils, 'logWarn'); + newVideoRequest = utils.deepClone(videoBidRequests); + }); + + afterEach(() => { + utilsMock.restore(); + sandbox.restore(); + }); + + it('Video params from mediaTypes and params obj of bid are not present', function () { + delete newVideoRequest[0].mediaTypes.video; + delete newVideoRequest[0].params.video; + let request = spec.buildRequests(newVideoRequest); + expect(request).to.equal(undefined); + }); + + it('Should consider video params from mediaType object of bid', function () { + delete newVideoRequest[0].params.video; + + let request = spec.buildRequests(newVideoRequest); + let data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + expect(data.imp[0]['video']['battr']).to.equal(undefined); + }); + }); + describe('getUserSyncs', function () { + const syncurl_iframe = 'https://sync.lemmadigital.com/js/usersync.html?pid=1001'; + let sandbox; + beforeEach(function () { + sandbox = sinon.sandbox.create(); + }); + afterEach(function () { + sandbox.restore(); + }); + + it('execute as per config', function () { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: syncurl_iframe + }]); + }); + + it('not execute as per config', function () { + expect(spec.getUserSyncs({ iframeEnabled: false }, {}, undefined, undefined)).to.deep.equal(undefined); + }); + }); + }); +}); diff --git a/test/spec/modules/lifestreetBidAdapter_spec.js b/test/spec/modules/lifestreetBidAdapter_spec.js new file mode 100644 index 00000000000..d66727da644 --- /dev/null +++ b/test/spec/modules/lifestreetBidAdapter_spec.js @@ -0,0 +1,232 @@ +import { expect } from 'chai'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; +import { spec } from 'modules/lifestreetBidAdapter.js'; + +describe('lifestreetBidAdapter', function() { + let bidRequests; + let videoBidRequests; + let bidResponses; + let videoBidResponses; + beforeEach(function() { + bidRequests = [ + { + bidder: 'lifestreet', + params: { + slot: 'slot166704', + adkey: '78c', + ad_size: '160x600' + }, + mediaTypes: { + banner: { + sizes: [ + [160, 600], + [300, 600] + ] + } + }, + sizes: [ + [160, 600], + [300, 600] + ] + } + ]; + + bidResponses = { + body: { + cpm: 0.1, + netRevenue: true, + content_type: 'display_flash', + width: 160, + currency: 'USD', + ttl: 86400, + content: '', + 'price': 0.8, + 'creativeId': '12610997325162499419', + 'exp': 30, + 'width': 300, + 'height': 250, + 'advertiserDomains': ['securepubads.g.doubleclick.net'], + 'cookies': [{ + 'src': 'https://sync.com', + 'type': 'iframe' + }, { + 'src': 'https://sync.com', + 'type': 'img' + }] + }] + } +}; + +const VIDEO_SERVER_RESPONSE = { + body: { + 'cid': '635509f7ff6642d368cb9837', + 'results': [{ + 'ad': '', + 'advertiserDomains': ['minutemedia-prebid.com'], + 'exp': 60, + 'width': 545, + 'height': 307, + 'mediaType': 'video', + 'creativeId': '12610997325162499419', + 'price': 2, + 'cookies': [] + }] + } +}; + +const REQUEST = { + data: { + width: 300, + height: 250, + bidId: '2d52001cabd527' + } +}; + +function getTopWindowQueryParams() { + try { + const parsedUrl = utils.parseUrl(window.top.document.URL, {decodeSearchAsString: true}); + return parsedUrl.search; + } catch (e) { + return ''; + } +} + +describe('MinuteMediaPlus Bid Adapter', function () { + describe('validtae spec', function () { + it('exists and is a function', function () { + expect(adapter.isBidRequestValid).to.exist.and.to.be.a('function'); + }); + + it('exists and is a function', function () { + expect(adapter.buildRequests).to.exist.and.to.be.a('function'); + }); + + it('exists and is a function', function () { + expect(adapter.interpretResponse).to.exist.and.to.be.a('function'); + }); + + it('exists and is a function', function () { + expect(adapter.getUserSyncs).to.exist.and.to.be.a('function'); + }); + + it('exists and is a string', function () { + expect(adapter.code).to.exist.and.to.be.a('string'); + }); + + it('exists and contains media types', function () { + expect(adapter.supportedMediaTypes).to.exist.and.to.be.an('array').with.length(2); + expect(adapter.supportedMediaTypes).to.contain.members([BANNER, VIDEO]); + }); + }); + + describe('validate bid requests', function () { + it('should require cId', function () { + const isValid = adapter.isBidRequestValid({ + params: { + pId: 'pid' + } + }); + expect(isValid).to.be.false; + }); + + it('should require pId', function () { + const isValid = adapter.isBidRequestValid({ + params: { + cId: 'cid' + } + }); + expect(isValid).to.be.false; + }); + + it('should validate correctly', function () { + const isValid = adapter.isBidRequestValid({ + params: { + cId: 'cid', + pId: 'pid' + } + }); + expect(isValid).to.be.true; + }); + }); + + describe('build requests', function () { + let sandbox; + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + mmplus: { + storageAllowed: true + } + }; + sandbox = sinon.sandbox.create(); + sandbox.stub(Date, 'now').returns(1000); + }); + + it('should build video request', function () { + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); + config.setConfig({ + bidderTimeout: 3000 + }); + const requests = adapter.buildRequests([VIDEO_BID], BIDDER_REQUEST); + expect(requests).to.have.length(1); + expect(requests[0]).to.deep.equal({ + method: 'POST', + url: `${createDomain(SUB_DOMAIN)}/prebid/multi/635509f7ff6642d368cb9837`, + data: { + adUnitCode: '63550ad1ff6642d368cba59dh5884270560', + bidFloor: 0.1, + bidId: '2d52001cabd527', + bidderVersion: adapter.version, + bidderRequestId: '12a8ae9ada9c13', + cb: 1000, + gdpr: 1, + gdprConsent: 'consent_string', + usPrivacy: 'consent_string', + gppString: 'gpp_string', + gppSid: [7], + prebidVersion: version, + transactionId: '56e184c6-bde9-497b-b9b9-cf47a61381ee', + auctionId: 'auction_id', + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + publisherId: '59ac17c192832d0011283fe3', + url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', + res: `${window.top.screen.width}x${window.top.screen.height}`, + schain: VIDEO_BID.schain, + sizes: ['545x307'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, + uniqueDealId: `${hashUrl}_${Date.now().toString()}`, + uqs: getTopWindowQueryParams(), + mediaTypes: { + video: { + api: [2], + context: 'instream', + linearity: 1, + maxduration: 60, + mimes: [ + 'video/mp4', + 'application/javascript' + ], + minduration: 0, + placement: 1, + playerSize: [[545, 307]], + protocols: [2, 3, 5, 6], + startdelay: 0 + } + }, + gpid: '' + } + }); + }); + + it('should build banner request for each size', function () { + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); + config.setConfig({ + bidderTimeout: 3000 + }); + const requests = adapter.buildRequests([BID], BIDDER_REQUEST); + expect(requests).to.have.length(1); + expect(requests[0]).to.deep.equal({ + method: 'POST', + url: `${createDomain(SUB_DOMAIN)}/prebid/multi/59db6b3b4ffaa70004f45cdc`, + data: { + gdprConsent: 'consent_string', + gdpr: 1, + gppString: 'gpp_string', + gppSid: [7], + usPrivacy: 'consent_string', + transactionId: 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', + auctionId: 'auction_id', + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + bidderRequestId: '1fdb5ff1b6eaa7', + sizes: ['300x250', '300x600'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, + url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', + cb: 1000, + bidFloor: 0.1, + bidId: '2d52001cabd527', + adUnitCode: 'div-gpt-ad-12345-0', + publisherId: '59ac17c192832d0011283fe3', + uniqueDealId: `${hashUrl}_${Date.now().toString()}`, + bidderVersion: adapter.version, + prebidVersion: version, + schain: BID.schain, + res: `${window.top.screen.width}x${window.top.screen.height}`, + mediaTypes: [BANNER], + gpid: '1234567890', + uqs: getTopWindowQueryParams(), + 'ext.param1': 'loremipsum', + 'ext.param2': 'dolorsitamet', + } + }); + }); + + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + sandbox.restore(); + }); + }); + describe('getUserSyncs', function () { + it('should have valid user sync with iframeEnabled', function () { + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + type: 'iframe', + url: 'https://sync.minutemedia-prebid.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=' + }]); + }); + + it('should have valid user sync with cid on response', function () { + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); + expect(result).to.deep.equal([{ + type: 'iframe', + url: 'https://sync.minutemedia-prebid.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=' + }]); + }); + + it('should have valid user sync with pixelEnabled', function () { + const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + 'url': 'https://sync.minutemedia-prebid.com/api/sync/image/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=', + 'type': 'image' + }]); + }) + + it('should generate url with consent data', function () { + const gdprConsent = { + gdprApplies: true, + consentString: 'consent_string' + }; + const uspConsent = 'usp_string'; + const gppConsent = { + gppString: 'gpp_string', + applicableSections: [7] + } + + const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE], gdprConsent, uspConsent, gppConsent); + + expect(result).to.deep.equal([{ + 'url': 'https://sync.minutemedia-prebid.com/api/sync/image/?cid=testcid123&gdpr=1&gdpr_consent=consent_string&us_privacy=usp_string&gpp=gpp_string&gpp_sid=7', + 'type': 'image' + }]); + }); + }); + + describe('interpret response', function () { + it('should return empty array when there is no response', function () { + const responses = adapter.interpretResponse(null); + expect(responses).to.be.empty; + }); + + it('should return empty array when there is no ad', function () { + const responses = adapter.interpretResponse({price: 1, ad: ''}); + expect(responses).to.be.empty; + }); + + it('should return empty array when there is no price', function () { + const responses = adapter.interpretResponse({price: null, ad: 'great ad'}); + expect(responses).to.be.empty; + }); + + it('should return an array of interpreted banner responses', function () { + const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0]).to.deep.equal({ + requestId: '2d52001cabd527', + cpm: 0.8, + width: 300, + height: 250, + creativeId: '12610997325162499419', + currency: 'USD', + netRevenue: true, + ttl: 30, + ad: '', + meta: { + advertiserDomains: ['securepubads.g.doubleclick.net'] + } + }); + }); + + it('should get meta from response metaData', function () { + const serverResponse = utils.deepClone(SERVER_RESPONSE); + serverResponse.body.results[0].metaData = { + advertiserDomains: ['minutemedia-prebid.com'], + agencyName: 'Agency Name', + }; + const responses = adapter.interpretResponse(serverResponse, REQUEST); + expect(responses[0].meta).to.deep.equal({ + advertiserDomains: ['minutemedia-prebid.com'], + agencyName: 'Agency Name' + }); + }); + + it('should return an array of interpreted video responses', function () { + const responses = adapter.interpretResponse(VIDEO_SERVER_RESPONSE, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0]).to.deep.equal({ + requestId: '2d52001cabd527', + cpm: 2, + width: 545, + height: 307, + mediaType: 'video', + creativeId: '12610997325162499419', + currency: 'USD', + netRevenue: true, + ttl: 60, + vastXml: '', + meta: { + advertiserDomains: ['minutemedia-prebid.com'] + } + }); + }); + + it('should take default TTL', function () { + const serverResponse = utils.deepClone(SERVER_RESPONSE); + delete serverResponse.body.results[0].exp; + const responses = adapter.interpretResponse(serverResponse, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0].ttl).to.equal(300); + }); + }); + + describe('user id system', function () { + TEST_ID_SYSTEMS.forEach((idSystemProvider) => { + const id = Date.now().toString(); + const bid = utils.deepClone(BID); + + const userId = (function () { + switch (idSystemProvider) { + case 'lipb': + return {lipbid: id}; + case 'parrableId': + return {eid: id}; + case 'id5id': + return {uid: id}; + default: + return id; + } + })(); + + bid.userId = { + [idSystemProvider]: userId + }; + + it(`should include 'uid.${idSystemProvider}' in request params`, function () { + const requests = adapter.buildRequests([bid], BIDDER_REQUEST); + expect(requests[0].data[`uid.${idSystemProvider}`]).to.equal(id); + }); + }); + }); + + describe('alternate param names extractors', function () { + it('should return undefined when param not supported', function () { + const cid = extractCID({'c_id': '1'}); + const pid = extractPID({'p_id': '1'}); + const subDomain = extractSubDomain({'sub_domain': 'prebid'}); + expect(cid).to.be.undefined; + expect(pid).to.be.undefined; + expect(subDomain).to.be.undefined; + }); + + it('should return value when param supported', function () { + const cid = extractCID({'cID': '1'}); + const pid = extractPID({'Pid': '2'}); + const subDomain = extractSubDomain({'subDOMAIN': 'prebid'}); + expect(cid).to.be.equal('1'); + expect(pid).to.be.equal('2'); + expect(subDomain).to.be.equal('prebid'); + }); + }); + + describe('unique deal id', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + mmplus: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + const key = 'myKey'; + let uniqueDealId; + beforeEach(() => { + uniqueDealId = getUniqueDealId(key, 0); + }) + + it('should get current unique deal id', function (done) { + // waiting some time so `now` will become past + setTimeout(() => { + const current = getUniqueDealId(key); + expect(current).to.be.equal(uniqueDealId); + done(); + }, 200); + }); + + it('should get new unique deal id on expiration', function (done) { + setTimeout(() => { + const current = getUniqueDealId(key, 100); + expect(current).to.not.be.equal(uniqueDealId); + done(); + }, 200) + }); + }); + + describe('storage utils', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + mmplus: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + it('should get value from storage with create param', function () { + const now = Date.now(); + const clock = useFakeTimers({ + shouldAdvanceTime: true, + now + }); + setStorageItem('myKey', 2020); + const {value, created} = getStorageItem('myKey'); + expect(created).to.be.equal(now); + expect(value).to.be.equal(2020); + expect(typeof value).to.be.equal('number'); + expect(typeof created).to.be.equal('number'); + clock.restore(); + }); + + it('should get external stored value', function () { + const value = 'superman' + window.localStorage.setItem('myExternalKey', value); + const item = getStorageItem('myExternalKey'); + expect(item).to.be.equal(value); + }); + + it('should parse JSON value', function () { + const data = JSON.stringify({event: 'send'}); + const {event} = tryParseJSON(data); + expect(event).to.be.equal('send'); + }); + + it('should get original value on parse fail', function () { + const value = 21; + const parsed = tryParseJSON(value); + expect(typeof parsed).to.be.equal('number'); + expect(parsed).to.be.equal(value); + }); + }); +}); diff --git a/test/spec/modules/missenaBidAdapter_spec.js b/test/spec/modules/missenaBidAdapter_spec.js index 86b967cca5b..f61987298e8 100644 --- a/test/spec/modules/missenaBidAdapter_spec.js +++ b/test/spec/modules/missenaBidAdapter_spec.js @@ -13,6 +13,8 @@ describe('Missena Adapter', function () { sizes: [[1, 1]], params: { apiKey: 'PA-34745704', + placement: 'sticky', + formats: ['sticky-banner'], }, }; @@ -49,7 +51,7 @@ describe('Missena Adapter', function () { gdprApplies: true, }, refererInfo: { - referer: 'https://referer', + topmostLocation: 'https://referer', canonicalUrl: 'https://canonical', }, }; @@ -70,6 +72,14 @@ describe('Missena Adapter', function () { expect(payload.request_id).to.equal(bidId); }); + it('should send placement', function () { + expect(payload.placement).to.equal('sticky'); + }); + + it('should send formats', function () { + expect(payload.formats).to.eql(['sticky-banner']); + }); + it('should send referer information to the request', function () { expect(payload.referer).to.equal('https://referer'); expect(payload.referer_canonical).to.equal('https://canonical'); @@ -88,7 +98,7 @@ describe('Missena Adapter', function () { currency: 'USD', ad: '', meta: { - advertiserDomains: ['missena.com'] + advertiserDomains: ['missena.com'], }, }; @@ -131,4 +141,49 @@ describe('Missena Adapter', function () { expect(result).to.deep.equal([]); }); }); + + describe('getUserSyncs', function () { + const syncFrameUrl = 'https://sync.missena.io/iframe'; + const consentString = 'sampleString'; + const iframeEnabledOptions = { + iframeEnabled: true, + }; + const iframeDisabledOptions = { + iframeEnabled: false, + }; + + it('should return userSync when iframeEnabled', function () { + const userSync = spec.getUserSyncs(iframeEnabledOptions, []); + + expect(userSync.length).to.be.equal(1); + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal(syncFrameUrl); + }); + + it('should return empty array when iframeEnabled is false', function () { + const userSync = spec.getUserSyncs(iframeDisabledOptions, []); + expect(userSync.length).to.be.equal(0); + }); + + it('sync frame url should contain gdpr data when present', function () { + const userSync = spec.getUserSyncs(iframeEnabledOptions, [], { + gdprApplies: true, + consentString, + }); + const expectedUrl = `${syncFrameUrl}?gdpr=1&gdpr_consent=${consentString}`; + expect(userSync.length).to.be.equal(1); + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal(expectedUrl); + }); + it('sync frame url should contain gdpr data when present (gdprApplies false)', function () { + const userSync = spec.getUserSyncs(iframeEnabledOptions, [], { + gdprApplies: false, + consentString, + }); + const expectedUrl = `${syncFrameUrl}?gdpr=0&gdpr_consent=${consentString}`; + expect(userSync.length).to.be.equal(1); + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[0].url).to.be.equal(expectedUrl); + }); + }); }); diff --git a/test/spec/modules/multibid_spec.js b/test/spec/modules/multibid_spec.js index eaf8fa33a66..c11113473ce 100644 --- a/test/spec/modules/multibid_spec.js +++ b/test/spec/modules/multibid_spec.js @@ -1,16 +1,15 @@ import {expect} from 'chai'; import { - validateMultibid, - adjustBidderRequestsHook, addBidResponseHook, + adjustBidderRequestsHook, resetMultibidUnits, + resetMultiConfig, sortByMultibid, targetBidPoolHook, - resetMultiConfig + validateMultibid } from 'modules/multibid/index.js'; -import {parse as parseQuery} from 'querystring'; import {config} from 'src/config.js'; -import * as utils from 'src/utils.js'; +import {getHighestCpm} from '../../../src/utils/reducers.js'; describe('multibid adapter', function () { let bidArray = [{ @@ -545,7 +544,7 @@ describe('multibid adapter', function () { it('it does not run filter on bidsReceived if no multibid configuration found', function () { let bids = [{...bidArray[0]}, {...bidArray[1]}]; - targetBidPoolHook(callbackFn, bids, utils.getHighestCpm); + targetBidPoolHook(callbackFn, bids, getHighestCpm); expect(result).to.not.equal(null); expect(result.bidsReceived).to.not.equal(null); @@ -562,7 +561,7 @@ describe('multibid adapter', function () { config.setConfig({multibid: [{bidder: 'bidderA', maxBids: 2}]}); - targetBidPoolHook(callbackFn, bids, utils.getHighestCpm); + targetBidPoolHook(callbackFn, bids, getHighestCpm); bids.pop(); expect(result).to.not.equal(null); @@ -584,7 +583,7 @@ describe('multibid adapter', function () { config.setConfig({multibid: [{bidder: 'bidderA', maxBids: 2, targetBiddercodePrefix: 'bidA'}]}); - targetBidPoolHook(callbackFn, modifiedBids, utils.getHighestCpm); + targetBidPoolHook(callbackFn, modifiedBids, getHighestCpm); expect(result).to.not.equal(null); expect(result.bidsReceived).to.not.equal(null); @@ -609,7 +608,7 @@ describe('multibid adapter', function () { config.setConfig({multibid: [{bidder: 'bidderA', maxBids: 2, targetBiddercodePrefix: 'bidA'}]}); - targetBidPoolHook(callbackFn, modifiedBids, utils.getHighestCpm); + targetBidPoolHook(callbackFn, modifiedBids, getHighestCpm); expect(result).to.not.equal(null); expect(result.bidsReceived).to.not.equal(null); @@ -642,7 +641,7 @@ describe('multibid adapter', function () { config.setConfig({ multibid: [{bidder: 'bidderA', maxBids: 2, targetBiddercodePrefix: 'bidA'}] }); - targetBidPoolHook(callbackFn, modifiedBids, utils.getHighestCpm, 3); + targetBidPoolHook(callbackFn, modifiedBids, getHighestCpm, 3); expect(result).to.not.equal(null); expect(result.bidsReceived).to.not.equal(null); @@ -670,7 +669,7 @@ describe('multibid adapter', function () { expect(bidPool.length).to.equal(6); - targetBidPoolHook(callbackFn, bidPool, utils.getHighestCpm); + targetBidPoolHook(callbackFn, bidPool, getHighestCpm); expect(result).to.not.equal(null); expect(result.bidsReceived).to.not.equal(null); diff --git a/test/spec/modules/mytargetBidAdapter_spec.js b/test/spec/modules/mytargetBidAdapter_spec.js index 62d139bb926..8880efd3d7c 100644 --- a/test/spec/modules/mytargetBidAdapter_spec.js +++ b/test/spec/modules/mytargetBidAdapter_spec.js @@ -46,7 +46,7 @@ describe('MyTarget Adapter', function() { ]; let bidderRequest = { refererInfo: { - referer: 'https://example.com?param=value' + page: 'https://example.com?param=value' } }; diff --git a/test/spec/modules/nativoBidAdapter_spec.js b/test/spec/modules/nativoBidAdapter_spec.js index c552090cf6e..75fb357b196 100644 --- a/test/spec/modules/nativoBidAdapter_spec.js +++ b/test/spec/modules/nativoBidAdapter_spec.js @@ -1,5 +1,46 @@ import { expect } from 'chai' -import { spec } from 'modules/nativoBidAdapter.js' +import { spec, BidDataMap } from 'modules/nativoBidAdapter.js' +import { + getSizeWildcardPrice, + getMediaWildcardPrices, + sizeToString, + parseFloorPriceData, + getPageUrlFromBidRequest, + hasProtocol, + addProtocol, + BidRequestDataSource, + RequestData, + UserEIDs, + buildRequestUrl, +} from '../../../modules/nativoBidAdapter' + +describe('bidDataMap', function () { + it('Should fail gracefully if no key value pairs have been added and no key is sent', function () { + const bdm = new BidDataMap() + const bidData = bdm.getBidData() + expect(bidData).to.be.undefined + }) + + it('Should fail gracefully if no key value pairs have been added', function () { + const bdm = new BidDataMap() + const bidData = bdm.getBidData('testKey') + expect(bidData).to.be.undefined + }) + + it('Should add bid data to corresponding keys', function () { + const keys = ['key1', 'anotherKey', 6] + const bidData = { prop: 'value' } + + const bdm = new BidDataMap() + bdm.addBidData(bidData, keys) + const bidDataKey0 = bdm.getBidData(keys[0]) + const bidDataKey1 = bdm.getBidData(keys[1]) + const bidDataKey2 = bdm.getBidData(keys[2]) + expect(bidDataKey0).to.be.equal(bidData) + expect(bidDataKey1).to.be.equal(bidData) + expect(bidDataKey2).to.be.equal(bidData) + }) +}) describe('nativoBidAdapterTests', function () { describe('isBidRequestValid', function () { @@ -48,25 +89,30 @@ describe('nativoBidAdapterTests', function () { }) describe('buildRequests', function () { - let bidRequests = [ - { - bidder: 'nativo', - params: { - placementId: '10433394', - }, - adUnitCode: 'adunit-code', - sizes: [ - [300, 250], - [300, 600], - ], - bidId: '27b02036ccfa6e', - bidderRequestId: '1372cd8bd8d6a8', - auctionId: 'cfc467e4-2707-48da-becb-bcaab0b2c114', - transactionId: '3b36e7e0-0c3e-4006-a279-a741239154ff', + const bidRequest = { + bidder: 'nativo', + params: { + placementId: '10433394', }, - ] + adUnitCode: 'adunit-code', + sizes: [ + [300, 250], + [300, 600], + ], + bidId: '27b02036ccfa6e', + bidderRequestId: '1372cd8bd8d6a8', + auctionId: 'cfc467e4-2707-48da-becb-bcaab0b2c114', + transactionId: '3b36e7e0-0c3e-4006-a279-a741239154ff', + } + const bidRequestString = JSON.stringify(bidRequest) + let bidRequests + + beforeEach(function () { + // Clone bidRequest each time + bidRequests = [JSON.parse(bidRequestString)] + }) - it('url should contain query string parameters', function () { + it('Request should be POST, with JSON string payload and QS params should be added to the url', function () { const request = spec.buildRequests(bidRequests, { bidderRequestId: 123456, refererInfo: { @@ -74,15 +120,63 @@ describe('nativoBidAdapterTests', function () { }, }) + expect(request.method).to.equal('POST') + + expect(request.data).to.exist + expect(request.data).to.be.a('string') + expect(request.url).to.exist expect(request.url).to.be.a('string') expect(request.url).to.include('?') + expect(request.url).to.include('ntv_pbv') expect(request.url).to.include('ntv_ptd') expect(request.url).to.include('ntv_pb_rid') expect(request.url).to.include('ntv_ppc') expect(request.url).to.include('ntv_url') expect(request.url).to.include('ntv_dbr') + expect(request.url).to.include('ntv_pas') + }) + + it('ntv_url should contain query params', function () { + const request = spec.buildRequests(bidRequests, { + bidderRequestId: 123456, + refererInfo: { + location: 'https://www.test.com?queryTest=true', + }, + }) + console.log(request.url) // eslint-disable-line no-console + expect(request.url).to.include(encodeURIComponent('?queryTest=true')) + }) + + it('ntv_url parameter should NOT be empty even if the utl parameter was set as an empty value', function () { + bidRequests[0].params.url = '' + const request = spec.buildRequests(bidRequests, { + bidderRequestId: 123456, + refererInfo: { + location: 'https://www.test.com', + }, + }) + + expect(request.url).to.exist + expect(request.url).to.be.a('string') + expect(request.url).to.not.be.empty + }) + + it('url should NOT contain placement specific query string parameters if placementId option is not provided', function () { + bidRequests[0].params = {} + const request = spec.buildRequests(bidRequests, { + bidderRequestId: 123456, + refererInfo: { + location: 'https://www.test.com', + }, + }) + + expect(request.url).to.exist + expect(request.url).to.be.a('string') + + expect(request.url).to.not.include('ntv_pas') + expect(request.url).to.not.include('ntv_ptd') }) }) }) @@ -439,3 +533,307 @@ describe('Response to Request Filter Flow', () => { expect(request.url).to.include('ntv_ctf=234') }) }) + +describe('sizeToString', () => { + it('Formats size array correctly', () => { + const sizeString = sizeToString([300, 250]) + expect(sizeString).to.be.equal('300x250') + }) + + it('Returns an empty array for invalid data', () => { + // Not an array + let sizeString = sizeToString(300, 350) + expect(sizeString).to.be.equal('') + // Single entry + sizeString = sizeToString([300]) + expect(sizeString).to.be.equal('') + // Undefined + sizeString = sizeToString(undefined) + expect(sizeString).to.be.equal('') + }) +}) + +describe('getSizeWildcardPrice', () => { + it('Generates the correct floor price data', () => { + let floorPrice = { + currency: 'USD', + floor: 1.0, + } + let getFloorMock = () => { + return floorPrice + } + let floorMockSpy = sinon.spy(getFloorMock) + let bidRequest = { + getFloor: floorMockSpy, + mediaTypes: { + banner: { + sizes: [300, 250], + }, + }, + } + + let result = getSizeWildcardPrice(bidRequest, 'banner') + expect( + floorMockSpy.calledWith({ + currency: 'USD', + mediaType: 'banner', + size: '*', + }) + ).to.be.true + expect(result).to.equal(floorPrice) + }) +}) + +describe('getMediaWildcardPrices', () => { + it('Generates the correct floor price data', () => { + let defaultFloorPrice = { + currency: 'USD', + floor: 1.1, + } + let sizefloorPrice = { + currency: 'USD', + floor: 2.2, + } + let getFloorMock = ({ currency, mediaType, size }) => { + if (Array.isArray(size)) return sizefloorPrice + + return defaultFloorPrice + } + let floorMockSpy = sinon.spy(getFloorMock) + let bidRequest = { + getFloor: floorMockSpy, + mediaTypes: { + banner: { + sizes: [300, 250], + }, + }, + } + + let result = getMediaWildcardPrices(bidRequest, ['*', [300, 250]]) + expect( + floorMockSpy.calledWith({ + currency: 'USD', + mediaType: '*', + size: '*', + }) + ).to.be.true + expect( + floorMockSpy.calledWith({ + currency: 'USD', + mediaType: '*', + size: [300, 250], + }) + ).to.be.true + expect(result).to.deep.equal({ '*': 1.1, '300x250': 2.2 }) + }) +}) + +describe('parseFloorPriceData', () => { + it('Generates the correct floor price data', () => { + let defaultFloorPrice = { + currency: 'USD', + floor: 1.1, + } + let sizefloorPrice = { + currency: 'USD', + floor: 2.2, + } + let getFloorMock = ({ currency, mediaType, size }) => { + if (Array.isArray(size)) return sizefloorPrice + + return defaultFloorPrice + } + let floorMockSpy = sinon.spy(getFloorMock) + let bidRequest = { + getFloor: floorMockSpy, + mediaTypes: { + banner: { + sizes: [[300, 250]], + }, + }, + } + + let result = parseFloorPriceData(bidRequest) + expect(result).to.deep.equal({ + '*': { '*': 1.1, '300x250': 2.2 }, + banner: { '*': 1.1, '300x250': 2.2 }, + }) + }) +}) + +describe('hasProtocol', () => { + it('https://www.testpage.com', () => { + expect(hasProtocol('https://www.testpage.com')).to.be.true + }) + it('http://www.testpage.com', () => { + expect(hasProtocol('http://www.testpage.com')).to.be.true + }) + it('//www.testpage.com', () => { + expect(hasProtocol('//www.testpage.com')).to.be.false + }) + it('www.testpage.com', () => { + expect(hasProtocol('www.testpage.com')).to.be.false + }) + it('httpsgsjhgflih', () => { + expect(hasProtocol('httpsgsjhgflih')).to.be.false + }) +}) + +describe('addProtocol', () => { + it('www.testpage.com', () => { + expect(addProtocol('www.testpage.com')).to.be.equal('https://www.testpage.com') + }) + it('//www.testpage.com', () => { + expect(addProtocol('//www.testpage.com')).to.be.equal('https://www.testpage.com') + }) + it('http://www.testpage.com', () => { + expect(addProtocol('http://www.testpage.com')).to.be.equal('http://www.testpage.com') + }) + it('https://www.testpage.com', () => { + expect(addProtocol('https://www.testpage.com')).to.be.equal('https://www.testpage.com') + }) +}) + +describe('getPageUrlFromBidRequest', () => { + const bidRequest = {} + + beforeEach(() => { + bidRequest.params = {} + }) + + it('Returns undefined for no url param', () => { + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).to.be.undefined + }) + + it('@testUrl', () => { + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).to.be.undefined + }) + + it('https://www.testpage.com', () => { + bidRequest.params.url = 'https://www.testpage.com' + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).not.to.be.undefined + }) + + it('https://www.testpage.com/test/path', () => { + bidRequest.params.url = 'https://www.testpage.com/test/path' + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).not.to.be.undefined + }) + + it('www.testpage.com', () => { + bidRequest.params.url = 'www.testpage.com' + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).not.to.be.undefined + }) + + it('http://www.testpage.com', () => { + bidRequest.params.url = 'http://www.testpage.com' + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).not.to.be.undefined + }) + + it('//www.testpage.com', () => { + bidRequest.params.url = '//www.testpage.com' + const url = getPageUrlFromBidRequest(bidRequest) + expect(url).not.to.be.undefined + }) +}) + +describe('RequestData', () => { + describe('addBidRequestDataSource', () => { + it('Adds a BidRequestDataSource', () => { + const requestData = new RequestData() + const testBidRequestDataSource = new BidRequestDataSource() + + requestData.addBidRequestDataSource(testBidRequestDataSource) + + expect(requestData.bidRequestDataSources.length == 1) + }) + + it("Doeasn't add a non BidRequestDataSource", () => { + const requestData = new RequestData() + + requestData.addBidRequestDataSource({}) + requestData.addBidRequestDataSource('test') + requestData.addBidRequestDataSource(1) + requestData.addBidRequestDataSource(true) + + expect(requestData.bidRequestDataSources.length == 0) + }) + }) + + describe('getRequestDataString', () => { + it("Doesn't append empty query strings", () => { + const requestData = new RequestData() + const testBidRequestDataSource = new BidRequestDataSource() + + requestData.addBidRequestDataSource(testBidRequestDataSource) + + let qs = requestData.getRequestDataQueryString() + expect(qs).to.be.empty + + testBidRequestDataSource.getRequestQueryString = () => { + return 'ntv_test=true' + } + qs = requestData.getRequestDataQueryString() + expect(qs).to.be.equal('ntv_test=true') + }) + }) +}) + +describe('UserEIDs', () => { + const userEids = new UserEIDs() + const eids = [{ 'testId': 1111 }] + + describe('processBidRequestData', () => { + it('Processes bid request without eids', () => { + userEids.processBidRequestData({}) + + expect(userEids.eids).to.be.empty + }) + + it('Processed bid request with eids', () => { + userEids.processBidRequestData({ userIdAsEids: eids }) + + expect(userEids.eids).to.not.be.empty + }) + }) + + describe('getRequestQueryString', () => { + it('Correctly prints out QS param string', () => { + const qs = userEids.getRequestQueryString() + const value = qs.slice(11) + + expect(qs).to.include('ntv_pb_eid=') + try { + expect(JSON.parse(value)).to.be.equal(eids) + } catch (err) { } + }) + }) +}) + +describe('buildRequestUrl', () => { + const baseUrl = 'https://www.testExchange.com' + it('Returns baseUrl if no QS strings passed', () => { + const url = buildRequestUrl(baseUrl) + expect(url).to.be.equal(baseUrl) + }) + + it('Returns baseUrl if empty QS strings passed', () => { + const url = buildRequestUrl(baseUrl, ['', '', '']) + expect(url).to.be.equal(baseUrl) + }) + + it('Returns baseUrl + QS params if QS strings passed', () => { + const url = buildRequestUrl(baseUrl, ['ntv_ptd=123456&ntv_test=true', 'ntv_foo=bar']) + expect(url).to.be.equal(`${baseUrl}?ntv_ptd=123456&ntv_test=true&ntv_foo=bar`) + }) + + it('Returns baseUrl + QS params if mixed QS strings passed', () => { + const url = buildRequestUrl(baseUrl, ['ntv_ptd=123456&ntv_test=true', '', '', 'ntv_foo=bar']) + expect(url).to.be.equal(`${baseUrl}?ntv_ptd=123456&ntv_test=true&ntv_foo=bar`) + }) +}) diff --git a/test/spec/modules/naveggIdSystem_spec.js b/test/spec/modules/naveggIdSystem_spec.js index c0973a05372..2c4f1cda859 100644 --- a/test/spec/modules/naveggIdSystem_spec.js +++ b/test/spec/modules/naveggIdSystem_spec.js @@ -1,6 +1,15 @@ import { naveggIdSubmodule, storage } from 'modules/naveggIdSystem.js'; describe('naveggId', function () { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + sandbox.stub(storage, 'getDataFromLocalStorage'); + }); + afterEach(() => { + sandbox.restore(); + }); + it('should NOT find navegg id', function () { let id = naveggIdSubmodule.getId(); @@ -14,8 +23,23 @@ describe('naveggId', function () { }) it('getId() should return "test-nvggid" id from local storage NAVEGG_ID', function() { - sinon.stub(storage, 'getDataFromLocalStorage').withArgs('nvggid').returns('test-ninvggidd'); + storage.getDataFromLocalStorage.callsFake(() => 'test-ninvggidd') + let id = naveggIdSubmodule.getId(); expect(id).to.be.deep.equal({id: 'test-ninvggidd'}) }) + + it('getId() should return "test-nvggid" id from local storage NAV0', function() { + storage.getDataFromLocalStorage.callsFake(() => 'nvgid-nav0') + + let id = naveggIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: 'nvgid-nav0'}) + }) + + it('getId() should return "test-nvggid" id from local storage NVG0', function() { + storage.getDataFromLocalStorage.callsFake(() => 'nvgid-nvg0') + + let id = naveggIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: 'nvgid-nvg0'}) + }) }); diff --git a/test/spec/modules/neuwoRtdProvider_spec.js b/test/spec/modules/neuwoRtdProvider_spec.js new file mode 100644 index 00000000000..0ad3d7c1f74 --- /dev/null +++ b/test/spec/modules/neuwoRtdProvider_spec.js @@ -0,0 +1,123 @@ +import { server } from 'test/mocks/xhr.js'; +import * as neuwo from 'modules/neuwoRtdProvider'; + +const PUBLIC_TOKEN = 'public_key_0000'; +const config = () => ({ + params: { + publicToken: PUBLIC_TOKEN, + apiUrl: 'https://testing-requirement.neuwo.api' + } +}) + +const apiReturns = () => ({ + somethingExtra: { object: true }, + marketing_categories: { + iab_tier_1: [ + { ID: 'IAB21', label: 'Real Estate', relevance: '0.45699' } + ] + } +}) + +const TAX_ID = '441' + +/** + * Object generator, like above, written using alternative techniques + * @returns object with predefined (expected) bidsConfig fields + */ +function bidsConfiglike() { + return Object.assign({}, { + ortb2Fragments: { global: {} } + }) +} + +describe('neuwoRtdProvider', function () { + describe('neuwoRtdModule', function () { + it('initializes', function () { + expect(neuwo.neuwoRtdModule.init(config())).to.be.true; + }) + it('init needs that public token', function () { + expect(neuwo.neuwoRtdModule.init()).to.be.false; + }) + + describe('segment picking', function () { + it('handles bad inputs', function () { + expect(neuwo.pickSegments()).to.be.an('array').that.is.empty; + expect(neuwo.pickSegments('technically also an array')).to.be.an('array').that.is.empty; + expect(neuwo.pickSegments({ bad_object: 'bad' })).to.be.an('array').that.is.empty; + }) + it('handles malformations', function () { + let result = neuwo.pickSegments([{something_wrong: true}, null, { ID: 'IAB19-20' }, { id: 'IAB3-1', ID: 'IAB9-20' }]) + expect(result[0].id).to.equal('631') + expect(result[1].id).to.equal('58') + expect(result.length).to.equal(2) + }) + }) + + describe('topic injection', function () { + it('mutates bidsConfig', function () { + let topics = apiReturns() + let bidsConfig = bidsConfiglike() + neuwo.injectTopics(topics, bidsConfig, () => { }) + expect(bidsConfig.ortb2Fragments.global.site.content.data[0].name, 'name of first content data object').to.equal(neuwo.DATA_PROVIDER) + expect(bidsConfig.ortb2Fragments.global.site.content.data[0].segment[0].id, 'id of first segment in content.data').to.equal(TAX_ID) + expect(bidsConfig.ortb2Fragments.global.site.pagecat[0], 'category taxonomy code for pagecat').to.equal(TAX_ID) + }) + + it('handles malformed responses', function () { + let topics = { message: 'Forbidden' } + let bidsConfig = bidsConfiglike() + neuwo.injectTopics(topics, bidsConfig, () => { }) + expect(bidsConfig.ortb2Fragments.global.site.content.data[0].name, 'name of first content data object').to.equal(neuwo.DATA_PROVIDER) + expect(bidsConfig.ortb2Fragments.global.site.content.data[0].segment, 'length of segment(s) in content.data').to.be.an('array').that.is.empty; + + topics = '404 wouldn\'t really even show up for injection' + let bdsConfig = bidsConfiglike() + neuwo.injectTopics(topics, bdsConfig, () => { }) + expect(bdsConfig.ortb2Fragments.global.site.content.data[0].name, 'name of first content data object').to.equal(neuwo.DATA_PROVIDER) + expect(bdsConfig.ortb2Fragments.global.site.content.data[0].segment, 'length of segment(s) in content.data').to.be.an('array').that.is.empty; + + topics = undefined + let bdsConfigE = bidsConfiglike() + neuwo.injectTopics(topics, bdsConfigE, () => { }) + expect(bdsConfigE.ortb2Fragments.global.site.content.data[0].name, 'name of first content data object').to.equal(neuwo.DATA_PROVIDER) + expect(bdsConfigE.ortb2Fragments.global.site.content.data[0].segment, 'length of segment(s) in content.data').to.be.an('array').that.is.empty; + }) + }) + + describe('fragment addition', function () { + it('mutates input objects', function () { + let alphabet = { a: { b: { c: {} } } } + neuwo.addFragment(alphabet.a.b.c, 'd.e.f', { g: 'h' }) + expect(alphabet.a.b.c.d.e.f.g).to.equal('h') + }) + }) + + describe('getBidRequestData', function () { + it('forms requests properly and mutates input bidsConfig', function () { + let bids = bidsConfiglike() + let conf = config() + // control xhr api request target for testing + conf.params.argUrl = 'https://publisher.works/article.php?get=horrible_url_for_testing&id=5' + + neuwo.getBidRequestData(bids, () => { }, conf, 'any consent data works, clearly') + + let request = server.requests[0]; + expect(request.url).to.be.a('string').that.includes(conf.params.publicToken) + expect(request.url).to.include(encodeURIComponent(conf.params.argUrl)) + request.respond(200, { 'Content-Type': 'application/json; encoding=UTF-8' }, JSON.stringify(apiReturns())); + + expect(bids.ortb2Fragments.global.site.content.data[0].name, 'name of first content data object').to.equal(neuwo.DATA_PROVIDER) + expect(bids.ortb2Fragments.global.site.content.data[0].segment[0].id, 'id of first segment in content.data').to.equal(TAX_ID) + }) + + it('accepts detail not available result', function () { + let bidsConfig = bidsConfiglike() + let comparison = bidsConfiglike() + neuwo.getBidRequestData(bidsConfig, () => { }, config(), 'consensually') + let request = server.requests[0]; + request.respond(404, { 'Content-Type': 'application/json; encoding=UTF-8' }, JSON.stringify({ detail: 'Basically first time seeing this' })); + expect(bidsConfig).to.deep.equal(comparison) + }) + }) + }) +}) diff --git a/test/spec/modules/newspassidBidAdapter_spec.js b/test/spec/modules/newspassidBidAdapter_spec.js new file mode 100644 index 00000000000..6468d4f530a --- /dev/null +++ b/test/spec/modules/newspassidBidAdapter_spec.js @@ -0,0 +1,1799 @@ +import { expect } from 'chai'; +import { spec, defaultSize } from 'modules/newspassidBidAdapter.js'; +import { config } from 'src/config.js'; +import {getGranularityKeyName, getGranularityObject} from '../../../modules/newspassidBidAdapter.js'; +import * as utils from '../../../src/utils.js'; +const NEWSPASSURI = 'https://bidder.newspassid.com/openrtb2/auction'; +const BIDDER_CODE = 'newspassid'; +var validBidRequests = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + } +]; +var validBidRequestsNoCustomData = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + } +]; +var validBidRequestsMulti = [ + { + testId: 1, + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + }, + { + testId: 2, + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff0', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c0', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + } +]; +var validBidRequestsWithUserIdData = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87', + userId: { + 'pubcid': '12345678', + 'tdid': '1111tdid', + 'id5id': { uid: '1111', ext: { linkType: 2, abTestingControlGroup: false } }, + 'criteoId': '1111criteoId', + 'idl_env': 'liverampId', + 'lipb': {'lipbid': 'lipbidId123'}, + 'parrableId': {'eid': '01.5678.parrableid'}, + 'sharedid': {'id': '01EAJWWNEPN3CYMM5N8M5VXY22', 'third': '01EAJWWNEPN3CYMM5N8M5VXY22'} + }, + userIdAsEids: [ + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '12345678', + 'atype': 1 + } + ] + }, + { + 'source': 'adserver.org', + 'uids': [{ + 'id': '1111tdid', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + }] + }, + { + 'source': 'id5-sync.com', + 'uids': [{ + 'id': 'ID5-someId', + 'atype': 1, + }] + }, + { + 'source': 'criteoId', + 'uids': [{ + 'id': '1111criteoId', + 'atype': 1, + }] + }, + { + 'source': 'idl_env', + 'uids': [{ + 'id': 'liverampId', + 'atype': 1, + }] + }, + { + 'source': 'lipb', + 'uids': [{ + 'id': {'lipbid': 'lipbidId123'}, + 'atype': 1, + }] + }, + { + 'source': 'parrableId', + 'uids': [{ + 'id': {'eid': '01.5678.parrableid'}, + 'atype': 1, + }] + } + ] + } +]; +var validBidRequestsMinimal = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + params: { publisherId: '9876abcd12-3', placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + } +]; +var validBidRequestsNoSizes = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + } +]; +var validBidRequestsWithBannerMediaType = [ + { + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { id: '2899ec066a91ff8', tagid: 'undefined', secure: 1, banner: { format: [{ w: 300, h: 250 }, { w: 300, h: 600 }], h: 250, topframe: 1, w: 300 } } ] }, + mediaTypes: {banner: {sizes: [[300, 250], [300, 600]]}}, + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + } +]; +var validBidRequestsIsThisCamelCaseEnough = [ + { + 'bidder': 'newspassid', + 'testname': 'validBidRequestsIsThisCamelCaseEnough', + 'params': { + 'publisherId': 'newspassRUP0001', + 'placementId': '8000000009', + 'siteId': '4204204201', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' + ], + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'penl4dfdk', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } + } + ], + 'userId': { + 'pubcid': '2ada6ae6-aeca-4e07-8922-a99b3aaf8a56' + }, + 'userIdAsEids': [ + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '2ada6ae6-aeca-4e07-8922-a99b3aaf8a56', + 'atype': 1 + } + ] + } + ] + }, + mediaTypes: {banner: {sizes: [[300, 250], [300, 600]]}}, + 'adUnitCode': 'some-ad', + 'transactionId': '02c1ea7d-0bf2-451b-a122-1420040d1cf8', + 'bidId': '2899ec066a91ff8', + 'bidderRequestId': '1c1586b27a1b5c8', + 'auctionId': '0456c9b7-5ab2-4fec-9e10-f418d3d1f04c', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } +]; +var validBidderRequest = { + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + auctionStart: 1536838908986, + bidderCode: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + bids: [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'newspassid', + bidderRequestId: '1c1586b27a1b5c8', + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + }], + doneCbCallCount: 1, + start: 1536838908987, + timeout: 3000 +}; +var emptyObject = {}; +var validResponse = { + 'body': { + 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', + 'seatbid': [ + { + 'bid': [ + { + 'id': '677903815252395017', + 'impid': '2899ec066a91ff8', + 'price': 0.5, + 'adm': '', + 'adid': '98493581', + 'adomain': [ + 'http://prebid.org' + ], + 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', + 'cid': '9325', + 'crid': '98493581', + 'cat': [ + 'IAB3-1' + ], + 'w': 300, + 'h': 600, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 555545, + 'auction_id': 6500448734132353000, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'appnexus' + } + ], + 'cur': 'GBP', /* NOTE - this is where cur is, not in the seatbids. */ + 'ext': { + 'responsetimemillis': { + 'appnexus': 47, + 'openx': 30 + } + }, + 'timing': { + 'start': 1536848078.089177, + 'end': 1536848078.142203, + 'TimeTaken': 0.05302619934082031 + } + }, + 'headers': {} +}; +var validResponse2BidsSameAdunit = { + 'body': { + 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', + 'seatbid': [ + { + 'bid': [ + { + 'id': '677903815252395017', + 'impid': '2899ec066a91ff8', + 'price': 0.5, + 'adm': '', + 'adid': '98493581', + 'adomain': [ + 'http://prebid.org' + ], + 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', + 'cid': '9325', + 'crid': '98493581', + 'cat': [ + 'IAB3-1' + ], + 'w': 300, + 'h': 600, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 555545, + 'auction_id': 6500448734132353000, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + }, + { + 'id': '677903815252395010', + 'impid': '2899ec066a91ff8', + 'price': 0.9, + 'adm': '', + 'adid': '98493580', + 'adomain': [ + 'http://prebid.org' + ], + 'iurl': 'https://fra1-ib.adnxs.com/cr?id=98493581', + 'cid': '9320', + 'crid': '98493580', + 'cat': [ + 'IAB3-1' + ], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 555540, + 'auction_id': 6500448734132353000, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } ], + 'seat': 'npappnexus' + } + ], + 'cur': 'GBP', /* NOTE - this is where cur is, not in the seatbids. */ + 'ext': { + 'responsetimemillis': { + 'appnexus': 47, + 'openx': 30 + } + }, + 'timing': { + 'start': 1536848078.089177, + 'end': 1536848078.142203, + 'TimeTaken': 0.05302619934082031 + } + }, + 'headers': {} +}; +var validBidResponse1adWith2Bidders = { + 'body': { + 'id': '91221f96-b931-4acc-8f05-c2a1186fa5ac', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', + 'impid': '2899ec066a91ff8', + 'price': 0.36754, + 'adm': '', + 'adid': '134928661', + 'adomain': [ + 'somecompany.com' + ], + 'iurl': 'https:\/\/ams1-ib.adnxs.com\/cr?id=134928661', + 'cid': '8825', + 'crid': '134928661', + 'cat': [ + 'IAB8-15', + 'IAB8-16', + 'IAB8-4', + 'IAB8-1', + 'IAB8-14', + 'IAB8-6', + 'IAB8-13', + 'IAB8-3', + 'IAB8-17', + 'IAB8-12', + 'IAB8-8', + 'IAB8-7', + 'IAB8-2', + 'IAB8-9', + 'IAB8', + 'IAB8-11' + ], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'appnexus': { + 'brand_id': 14640, + 'auction_id': 1.8369641905139e+18, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'appnexus' + }, + { + 'bid': [ + { + 'id': '75665207-a1ca-49db-ba0e-a5e9c7d26f32', + 'impid': '37fff511779365a', + 'price': 1.046, + 'adm': '
removed
', + 'adomain': [ + 'kx.com' + ], + 'crid': '13005', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + } + } + } + ], + 'seat': 'openx' + } + ], + 'ext': { + 'responsetimemillis': { + 'appnexus': 91, + 'openx': 109, + 'npappnexus': 46, + 'npbeeswax': 2, + 'pangaea': 91 + } + } + }, + 'headers': {} +}; +var multiRequest1 = [ + { + 'bidder': 'newspassid', + 'params': { + 'publisherId': 'newspassRUP0001', + 'siteId': '4204204201', + 'placementId': '0420420421', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' + ], + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'penl4dfdk', + 'uayf5jmv3', + 't8nyiude5', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } + } + ] + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'mpu', + 'transactionId': '6480bac7-31b5-4723-9145-ad8966660651', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '2d30e86db743a8', + 'bidderRequestId': '1d03a1dfc563fc', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + { + 'bidder': 'newspassid', + 'params': { + 'publisherId': 'newspassRUP0001', + 'siteId': '4204204201', + 'placementId': '0420420421', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' + ], + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'penl4dfdk', + 't8nxz6qzd', + 't8nyiude5', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } + } + ] + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 728, + 90 + ], + [ + 970, + 250 + ] + ] + } + }, + 'adUnitCode': 'leaderboard', + 'transactionId': 'a49988e6-ae7c-46c4-9598-f18db49892a0', + 'sizes': [ + [ + 728, + 90 + ], + [ + 970, + 250 + ] + ], + 'bidId': '3025f169863b7f8', + 'bidderRequestId': '1d03a1dfc563fc', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } +]; +var multiBidderRequest1 = { + bidderRequest: { + 'bidderCode': 'newspassid', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'bidderRequestId': '1d03a1dfc563fc', + 'bids': [ + { + 'bidder': 'newspassid', + 'params': { + 'publisherId': 'newspassRUP0001', + 'siteId': '4204204201', + 'placementId': '0420420421', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' + ], + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'txeh7uyo0', + 't8nxz6qzd', + 't8nyiude5', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } + } + ] + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'mpu', + 'transactionId': '6480bac7-31b5-4723-9145-ad8966660651', + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 + ] + ], + 'bidId': '2d30e86db743a8', + 'bidderRequestId': '1d03a1dfc563fc', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + { + 'bidder': 'newspassid', + 'params': { + 'publisherId': 'newspassRUP0001', + 'siteId': '4204204201', + 'placementId': '0420420421', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' + ], + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'penl4dfdk', + 't8nxz6qzd', + 't8nyiude5', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } + } + ] + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 728, + 90 + ], + [ + 970, + 250 + ] + ] + } + }, + 'adUnitCode': 'leaderboard', + 'transactionId': 'a49988e6-ae7c-46c4-9598-f18db49892a0', + 'sizes': [ + [ + 728, + 90 + ], + [ + 970, + 250 + ] + ], + 'bidId': '3025f169863b7f8', + 'bidderRequestId': '1d03a1dfc563fc', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1592918645574, + 'timeout': 3000, + 'refererInfo': { + 'referer': 'http://some.referrer.com', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://some.referrer.com' + ] + }, + 'start': 1592918645578 + } +}; +var multiResponse1 = { + 'body': { + 'id': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'seatbid': [ + { + 'bid': [ + { + 'id': '4419718600113204943', + 'impid': '2d30e86db743a8', + 'price': 0.2484, + 'adm': '', + 'adid': '119683582', + 'adomain': [ + 'https://someurl.com' + ], + 'iurl': 'https://ams1-ib.adnxs.com/cr?id=119683582', + 'cid': '9979', + 'crid': '119683582', + 'cat': [ + 'IAB3' + ], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'newspassid': {}, + 'appnexus': { + 'brand_id': 734921, + 'auction_id': 2995348111857539600, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + }, + 'cpm': 0.2484, + 'bidId': '2d30e86db743a8', + 'requestId': '2d30e86db743a8', + 'width': 300, + 'height': 250, + 'ad': '', + 'netRevenue': true, + 'creativeId': '119683582', + 'currency': 'USD', + 'ttl': 300, + 'originalCpm': 0.2484, + 'originalCurrency': 'USD' + }, + { + 'id': '18552976939844681', + 'impid': '3025f169863b7f8', + 'price': 0.0621, + 'adm': '', + 'adid': '120179216', + 'adomain': [ + 'appnexus.com' + ], + 'iurl': 'https://ams1-ib.adnxs.com/cr?id=120179216', + 'cid': '9979', + 'crid': '120179216', + 'w': 970, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'newspassid': {}, + 'appnexus': { + 'brand_id': 1, + 'auction_id': 3449036134472542700, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + }, + 'cpm': 0.0621, + 'bidId': '3025f169863b7f8', + 'requestId': '3025f169863b7f8', + 'width': 970, + 'height': 250, + 'ad': '', + 'netRevenue': true, + 'creativeId': '120179216', + 'currency': 'USD', + 'ttl': 300, + 'originalCpm': 0.0621, + 'originalCurrency': 'USD' + }, + { + 'id': '18552976939844999', + 'impid': '3025f169863b7f8', + 'price': 0.521, + 'adm': '', + 'adid': '120179216', + 'adomain': [ + 'appnexus.com' + ], + 'iurl': 'https://ams1-ib.adnxs.com/cr?id=120179216', + 'cid': '9999', + 'crid': '120179299', + 'w': 728, + 'h': 90, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'newspassid': {}, + 'appnexus': { + 'brand_id': 1, + 'auction_id': 3449036134472542700, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + }, + 'cpm': 0.521, + 'bidId': '3025f169863b7f8', + 'requestId': '3025f169863b7f8', + 'width': 728, + 'height': 90, + 'ad': '', + 'netRevenue': true, + 'creativeId': '120179299', + 'currency': 'USD', + 'ttl': 300, + 'originalCpm': 0.0621, + 'originalCurrency': 'USD' + } + ], + 'seat': 'npappnexus' + }, + { + 'bid': [ + { + 'id': '1c605e8a-4992-4ec6-8a5c-f82e2938c2db', + 'impid': '2d30e86db743a8', + 'price': 0.01, + 'adm': '
', + 'crid': '540463358', + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'newspassid': {} + } + }, + 'cpm': 0.01, + 'bidId': '2d30e86db743a8', + 'requestId': '2d30e86db743a8', + 'width': 300, + 'height': 250, + 'ad': '
', + 'netRevenue': true, + 'creativeId': '540463358', + 'currency': 'USD', + 'ttl': 300, + 'originalCpm': 0.01, + 'originalCurrency': 'USD' + }, + { + 'id': '3edeb4f7-d91d-44e2-8aeb-4a2f6d295ce5', + 'impid': '3025f169863b7f8', + 'price': 0.01, + 'adm': '
', + 'crid': '540221061', + 'w': 970, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'newspassid': {} + } + }, + 'cpm': 0.01, + 'bidId': '3025f169863b7f8', + 'requestId': '3025f169863b7f8', + 'width': 970, + 'height': 250, + 'ad': '
', + 'netRevenue': true, + 'creativeId': '540221061', + 'currency': 'USD', + 'ttl': 300, + 'originalCpm': 0.01, + 'originalCurrency': 'USD' + } + ], + 'seat': 'openx' + } + ], + 'ext': { + 'debug': {}, + 'responsetimemillis': { + 'beeswax': 6, + 'openx': 91, + 'npappnexus': 40, + 'npbeeswax': 6 + } + } + }, + 'headers': {} +}; +describe('newspassid Adapter', function () { + describe('isBidRequestValid', function () { + let validBidReq = { + bidder: BIDDER_CODE, + params: { + placementId: '1310000099', + publisherId: '9876abcd12-3', + siteId: '1234567890' + } + }; + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(validBidReq)).to.equal(true); + }); + var validBidReq2 = { + bidder: BIDDER_CODE, + params: { + placementId: '1310000099', + publisherId: '9876abcd12-3', + siteId: '1234567890', + customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}] + }, + siteId: 1234567890 + } + it('should return true when required params found and all optional params are valid', function () { + expect(spec.isBidRequestValid(validBidReq2)).to.equal(true); + }); + var xEmptyPlacement = { + bidder: BIDDER_CODE, + params: { + placementId: '', + publisherId: '9876abcd12-3', + siteId: '1234567890' + } + }; + it('should not validate empty placementId', function () { + expect(spec.isBidRequestValid(xEmptyPlacement)).to.equal(false); + }); + var xMissingPlacement = { + bidder: BIDDER_CODE, + params: { + publisherId: '9876abcd12-3', + siteId: '1234567890' + } + }; + it('should not validate missing placementId', function () { + expect(spec.isBidRequestValid(xMissingPlacement)).to.equal(false); + }); + var xBadPlacement = { + bidder: BIDDER_CODE, + params: { + placementId: '123X45', + publisherId: '9876abcd12-3', + siteId: '1234567890' + } + }; + it('should not validate placementId with a non-numeric value', function () { + expect(spec.isBidRequestValid(xBadPlacement)).to.equal(false); + }); + var xBadPlacementTooShort = { + bidder: BIDDER_CODE, + params: { + placementId: 123456789, /* should be exactly 10 chars */ + publisherId: '9876abcd12-3', + siteId: '1234567890' + } + }; + it('should not validate placementId with a numeric value of wrong length', function () { + expect(spec.isBidRequestValid(xBadPlacementTooShort)).to.equal(false); + }); + var xBadPlacementTooLong = { + bidder: BIDDER_CODE, + params: { + placementId: 12345678901, /* should be exactly 10 chars */ + publisherId: '9876abcd12-3', + siteId: '1234567890' + } + }; + it('should not validate placementId with a numeric value of wrong length', function () { + expect(spec.isBidRequestValid(xBadPlacementTooLong)).to.equal(false); + }); + var xMissingPublisher = { + bidder: BIDDER_CODE, + params: { + placementId: '1234567890', + siteId: '1234567890' + } + }; + it('should not validate missing publisherId', function () { + expect(spec.isBidRequestValid(xMissingPublisher)).to.equal(false); + }); + var xMissingSiteId = { + bidder: BIDDER_CODE, + params: { + publisherId: '9876abcd12-3', + placementId: '1234567890', + } + }; + it('should not validate missing sitetId', function () { + expect(spec.isBidRequestValid(xMissingSiteId)).to.equal(false); + }); + var xBadPublisherTooShort = { + bidder: BIDDER_CODE, + params: { + placementId: '1234567890', + publisherId: '9876abcd12a', + siteId: '1234567890' + } + }; + it('should not validate publisherId being too short', function () { + expect(spec.isBidRequestValid(xBadPublisherTooShort)).to.equal(false); + }); + var xBadPublisherTooLong = { + bidder: BIDDER_CODE, + params: { + placementId: '1234567890', + publisherId: '9876abcd12abc', + siteId: '1234567890' + } + }; + it('should not validate publisherId being too long', function () { + expect(spec.isBidRequestValid(xBadPublisherTooLong)).to.equal(false); + }); + var publisherNumericOk = { + bidder: BIDDER_CODE, + params: { + placementId: '1234567890', + publisherId: 123456789012, + siteId: '1234567890' + } + }; + it('should validate publisherId being 12 digits', function () { + expect(spec.isBidRequestValid(publisherNumericOk)).to.equal(true); + }); + var xEmptyPublisher = { + bidder: BIDDER_CODE, + params: { + placementId: '1234567890', + publisherId: '', + siteId: '1234567890' + } + }; + it('should not validate empty publisherId', function () { + expect(spec.isBidRequestValid(xEmptyPublisher)).to.equal(false); + }); + var xBadSite = { + bidder: BIDDER_CODE, + params: { + placementId: '1234567890', + publisherId: '9876abcd12-3', + siteId: '12345Z' + } + }; + it('should not validate bad siteId', function () { + expect(spec.isBidRequestValid(xBadSite)).to.equal(false); + }); + it('should not validate siteId too long', function () { + expect(spec.isBidRequestValid(xBadSite)).to.equal(false); + }); + it('should not validate siteId too short', function () { + expect(spec.isBidRequestValid(xBadSite)).to.equal(false); + }); + var allNonStrings = { + bidder: BIDDER_CODE, + params: { + placementId: 1234567890, + publisherId: '9876abcd12-3', + siteId: 1234567890 + } + }; + it('should validate all numeric values being sent as non-string numbers', function () { + expect(spec.isBidRequestValid(allNonStrings)).to.equal(true); + }); + var emptySiteId = { + bidder: BIDDER_CODE, + params: { + placementId: 1234567890, + publisherId: '9876abcd12-3', + siteId: '' + } + }; + it('should not validate siteId being empty string (it is required now)', function () { + expect(spec.isBidRequestValid(emptySiteId)).to.equal(false); + }); + var xBadCustomData = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'siteId': '1234567890', + 'customData': 'this aint gonna work' + } + }; + it('should not validate customData not being an array', function () { + expect(spec.isBidRequestValid(xBadCustomData)).to.equal(false); + }); + var xBadCustomDataOldCustomdataValue = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'siteId': '1234567890', + 'customData': {'gender': 'bart', 'age': 'low'} + } + }; + it('should not validate customData being an object, not an array', function () { + expect(spec.isBidRequestValid(xBadCustomDataOldCustomdataValue)).to.equal(false); + }); + var xBadCustomDataZerocd = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1111111110', + 'publisherId': '9876abcd12-3', + 'siteId': '1234567890', + 'customData': [] + } + }; + it('should not validate customData array having no elements', function () { + expect(spec.isBidRequestValid(xBadCustomDataZerocd)).to.equal(false); + }); + var xBadCustomDataNotargeting = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'customData': [{'settings': {}, 'xx': {'gender': 'bart', 'age': 'low'}}], + siteId: '1234567890' + } + }; + it('should not validate customData[] having no "targeting"', function () { + expect(spec.isBidRequestValid(xBadCustomDataNotargeting)).to.equal(false); + }); + var xBadCustomDataTgtNotObj = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'customData': [{'settings': {}, 'targeting': 'this should be an object'}], + siteId: '1234567890' + } + }; + it('should not validate customData[0].targeting not being an object', function () { + expect(spec.isBidRequestValid(xBadCustomDataTgtNotObj)).to.equal(false); + }); + var xBadCustomParams = { + bidder: BIDDER_CODE, + params: { + 'placementId': '1234567890', + 'publisherId': '9876abcd12-3', + 'siteId': '1234567890', + 'customParams': 'this key is no longer valid' + } + }; + it('should not validate customParams - this is a renamed key', function () { + expect(spec.isBidRequestValid(xBadCustomParams)).to.equal(false); + }); + }); + describe('buildRequests', function () { + it('sends bid request to NEWSPASSURI via POST', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.url).to.equal(NEWSPASSURI); + expect(request.method).to.equal('POST'); + }); + it('sends data as a string', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.data).to.be.a('string'); + }); + it('sends all bid parameters', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); + }); + it('adds all parameters inside the ext object only', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.data).to.be.a('string'); + var data = JSON.parse(request.data); + expect(data.imp[0].ext.newspassid.customData).to.be.an('array'); + expect(request).not.to.have.key('lotameData'); + expect(request).not.to.have.key('customData'); + }); + it('adds all parameters inside the ext object only - lightning', function () { + let localBidReq = JSON.parse(JSON.stringify(validBidRequests)); + const request = spec.buildRequests(localBidReq, validBidderRequest); + expect(request.data).to.be.a('string'); + var data = JSON.parse(request.data); + expect(data.imp[0].ext.newspassid.customData).to.be.an('array'); + expect(request).not.to.have.key('lotameData'); + expect(request).not.to.have.key('customData'); + }); + it('has correct bidder', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.bidderRequest.bids[0].bidder).to.equal(BIDDER_CODE); + }); + it('handles mediaTypes element correctly', function () { + const request = spec.buildRequests(validBidRequestsWithBannerMediaType, validBidderRequest); + expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); + }); + it('handles no newspassid or custom data', function () { + const request = spec.buildRequests(validBidRequestsMinimal, validBidderRequest); + expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); + }); + it('should not crash when there is no sizes element at all', function () { + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); + expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); + }); + it('should be able to handle non-single requests', function () { + config.setConfig({'newspassid': {'singleRequest': false}}); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); + expect(request).to.be.a('array'); + expect(request[0]).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); + config.setConfig({'newspassid': {'singleRequest': true}}); + }); + it('should not have imp[N].ext.newspassid.userId', function () { + let bidderRequest = validBidderRequest; + let bidRequests = validBidRequests; + bidRequests[0]['userId'] = { + 'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, + 'id5id': { uid: '1111', ext: { linkType: 2, abTestingControlGroup: false } }, + 'idl_env': '3333', + 'parrableid': 'eidVersion.encryptionKeyReference.encryptedValue', + 'pubcid': '5555', + 'tdid': '6666', + 'sharedid': {'id': '01EAJWWNEPN3CYMM5N8M5VXY22', 'third': '01EAJWWNEPN3CYMM5N8M5VXY22'} + }; + bidRequests[0]['userIdAsEids'] = validBidRequestsWithUserIdData[0]['userIdAsEids']; + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + let firstBid = payload.imp[0].ext.newspassid; + expect(firstBid).to.not.have.property('userId'); + delete validBidRequests[0].userId; // tidy up now, else it will screw with other tests + }); + it('should pick up the value of pubcid when built using the pubCommonId module (not userId)', function () { + let bidRequests = validBidRequests; + bidRequests[0]['userId'] = { + 'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, + 'id5id': { uid: '1111', ext: { linkType: 2, abTestingControlGroup: false } }, + 'idl_env': '3333', + 'parrableid': 'eidVersion.encryptionKeyReference.encryptedValue', + 'tdid': '6666', + 'sharedid': {'id': '01EAJWWNEPN3CYMM5N8M5VXY22', 'third': '01EAJWWNEPN3CYMM5N8M5VXY22'} + }; + bidRequests[0]['userIdAsEids'] = validBidRequestsWithUserIdData[0]['userIdAsEids']; + const request = spec.buildRequests(bidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.ext.newspassid.pubcid).to.equal(bidRequests[0]['crumbs']['pubcid']); + delete validBidRequests[0].userId; // tidy up now, else it will screw with other tests + }); + it('should add a user.ext.eids object to contain user ID data in the new location (Nov 2019) Updated Aug 2020', function() { + const request = spec.buildRequests(validBidRequestsWithUserIdData, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.user).to.exist; + expect(payload.user.ext).to.exist; + expect(payload.user.ext.eids).to.exist; + expect(payload.user.ext.eids[0]['source']).to.equal('pubcid.org'); + expect(payload.user.ext.eids[0]['uids'][0]['id']).to.equal('12345678'); + expect(payload.user.ext.eids[1]['source']).to.equal('adserver.org'); + expect(payload.user.ext.eids[1]['uids'][0]['id']).to.equal('1111tdid'); + expect(payload.user.ext.eids[2]['source']).to.equal('id5-sync.com'); + expect(payload.user.ext.eids[2]['uids'][0]['id']).to.equal('ID5-someId'); + expect(payload.user.ext.eids[3]['source']).to.equal('criteoId'); + expect(payload.user.ext.eids[3]['uids'][0]['id']).to.equal('1111criteoId'); + expect(payload.user.ext.eids[4]['source']).to.equal('idl_env'); + expect(payload.user.ext.eids[4]['uids'][0]['id']).to.equal('liverampId'); + expect(payload.user.ext.eids[5]['source']).to.equal('lipb'); + expect(payload.user.ext.eids[5]['uids'][0]['id']['lipbid']).to.equal('lipbidId123'); + expect(payload.user.ext.eids[6]['source']).to.equal('parrableId'); + expect(payload.user.ext.eids[6]['uids'][0]['id']['eid']).to.equal('01.5678.parrableid'); + }); + it('replaces the auction url for a config override', function () { + spec.propertyBag.config = null; + let fakeOrigin = 'http://sometestendpoint'; + config.setConfig({'newspassid': {'endpointOverride': {'origin': fakeOrigin}}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.url).to.equal(fakeOrigin + '/openrtb2/auction'); + expect(request.method).to.equal('POST'); + const data = JSON.parse(request.data); + expect(data.ext.newspassid.origin).to.equal(fakeOrigin); + config.setConfig({'newspassid': {'kvpPrefix': null, 'endpointOverride': null}}); + }); + it('replaces the FULL auction url for a config override', function () { + spec.propertyBag.config = null; + let fakeurl = 'http://sometestendpoint/myfullurl'; + config.setConfig({'newspassid': {'endpointOverride': {'auctionUrl': fakeurl}}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + expect(request.url).to.equal(fakeurl); + expect(request.method).to.equal('POST'); + const data = JSON.parse(request.data); + expect(data.ext.newspassid.origin).to.equal(fakeurl); + config.setConfig({'newspassid': {'kvpPrefix': null, 'endpointOverride': null}}); + }); + it('should ignore kvpPrefix', function () { + spec.propertyBag.config = null; + config.setConfig({'newspassid': {'kvpPrefix': 'np'}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(result[0].adserverTargeting).to.have.own.property('np_appnexus_crid'); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_crid')).to.equal('98493581'); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_adId')).to.equal('2899ec066a91ff8-0-np-0'); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_size')).to.equal('300x600'); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_pb_r')).to.equal('0.50'); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_bid')).to.equal('true'); + config.resetConfig(); + }); + it('should create a meta object on each bid returned', function () { + spec.propertyBag.config = null; + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(result[0]).to.have.own.property('meta'); + expect(result[0].meta.advertiserDomains[0]).to.equal('http://prebid.org'); + config.resetConfig(); + }); + it('should use nptestmode GET value if set', function() { + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {'nptestmode': 'mytestvalue_123'}; + }; + const request = specMock.buildRequests(validBidRequests, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].ext.newspassid.customData).to.be.an('array'); + expect(data.imp[0].ext.newspassid.customData[0].targeting.nptestmode).to.equal('mytestvalue_123'); + }); + it('should pass through GET params if present: npf, nppf, nprp, npip', function() { + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {npf: '1', nppf: '0', nprp: '2', npip: '123'}; + }; + const request = specMock.buildRequests(validBidRequests, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.ext.newspassid.npf).to.equal(1); + expect(data.ext.newspassid.nppf).to.equal(0); + expect(data.ext.newspassid.nprp).to.equal(2); + expect(data.ext.newspassid.npip).to.equal(123); + }); + it('should pass through GET params if present: npf, nppf, nprp, npip with alternative values', function() { + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {npf: 'false', nppf: 'true', nprp: 'xyz', npip: 'hello'}; + }; + const request = specMock.buildRequests(validBidRequests, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.ext.newspassid.npf).to.equal(0); + expect(data.ext.newspassid.nppf).to.equal(1); + expect(data.ext.newspassid).to.not.haveOwnProperty('nprp'); + expect(data.ext.newspassid).to.not.haveOwnProperty('npip'); + }); + it('should use nptestmode GET value if set, even if there is no customdata in config', function() { + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {'nptestmode': 'mytestvalue_123'}; + }; + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].ext.newspassid.customData).to.be.an('array'); + expect(data.imp[0].ext.newspassid.customData[0].targeting.nptestmode).to.equal('mytestvalue_123'); + }); + it('should use GET values auction=[encoded URL] & cookiesync=[encoded url] if set', function() { + spec.propertyBag.config = null; + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {}; + }; + let request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + let url = request.url; + expect(url).to.equal('https://bidder.newspassid.com/openrtb2/auction'); + let cookieUrl = specMock.getCookieSyncUrl(); + expect(cookieUrl).to.equal('https://bidder.newspassid.com/static/load-cookie.html'); + specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {'auction': 'https://www.someurl.com/auction', 'cookiesync': 'https://www.someurl.com/sync'}; + }; + request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + url = request.url; + expect(url).to.equal('https://www.someurl.com/auction'); + cookieUrl = specMock.getCookieSyncUrl(); + expect(cookieUrl).to.equal('https://www.someurl.com/sync'); + }); + it('should use a valid npstoredrequest GET value if set to override the placementId values, and set np_rw if we find it', function() { + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {'npstoredrequest': '1122334455'}; // 10 digits are valid + }; + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.ext.newspassid.np_rw).to.equal(1); + expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1122334455'); + }); + it('should NOT use an invalid npstoredrequest GET value if set to override the placementId values, and set np_rw to 0', function() { + var specMock = utils.deepClone(spec); + specMock.getGetParametersAsObject = function() { + return {'npstoredrequest': 'BADVAL'}; // 10 digits are valid + }; + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.ext.newspassid.np_rw).to.equal(0); + expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1310000099'); + }); + it('should pick up the config value of coppa & set it in the request', function () { + config.setConfig({'coppa': true}); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.regs).to.include.keys('coppa'); + expect(payload.regs.coppa).to.equal(1); + config.resetConfig(); + }); + it('should pick up the config value of coppa & only set it in the request if its true', function () { + config.setConfig({'coppa': false}); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); + const payload = JSON.parse(request.data); + expect(utils.deepAccess(payload, 'regs.coppa')).to.be.undefined; + config.resetConfig(); + }); + it('should should contain a unique page view id in the auction request which persists across calls', function () { + let request = spec.buildRequests(validBidRequests, validBidderRequest); + let payload = JSON.parse(request.data); + expect(utils.deepAccess(payload, 'ext.newspassid.pv')).to.be.a('string'); + request = spec.buildRequests(validBidRequestsIsThisCamelCaseEnough, validBidderRequest); + let payload2 = JSON.parse(request.data); + expect(utils.deepAccess(payload2, 'ext.newspassid.pv')).to.be.a('string'); + expect(utils.deepAccess(payload2, 'ext.newspassid.pv')).to.equal(utils.deepAccess(payload, 'ext.newspassid.pv')); + }); + it('should indicate that the whitelist was used when it contains valid data', function () { + config.setConfig({'newspassid': {'np_whitelist_adserver_keys': ['np_appnexus_pb', 'np_appnexus_imp_id']}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.ext.newspassid.np_kvp_rw).to.equal(1); + config.resetConfig(); + }); + it('should indicate that the whitelist was not used when it contains no data', function () { + config.setConfig({'newspassid': {'np_whitelist_adserver_keys': []}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.ext.newspassid.np_kvp_rw).to.equal(0); + config.resetConfig(); + }); + it('should indicate that the whitelist was not used when it is not set in the config', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const payload = JSON.parse(request.data); + expect(payload.ext.newspassid.np_kvp_rw).to.equal(0); + }); + it('should handle ortb2 site data', function () { + let bidderRequest = JSON.parse(JSON.stringify(validBidderRequest)); + bidderRequest.ortb2 = { + 'site': { + 'name': 'example_ortb2_name', + 'domain': 'page.example.com', + 'cat': ['IAB2'], + 'sectioncat': ['IAB2-2'], + 'pagecat': ['IAB2-2'], + 'page': 'https://page.example.com/here.html', + 'ref': 'https://ref.example.com', + 'keywords': 'power tools, drills', + 'search': 'drill' + } + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.imp[0].ext.newspassid.customData[0].targeting.name).to.equal('example_ortb2_name'); + expect(payload.user.ext).to.not.have.property('gender'); + }); + it('should add ortb2 site data when there is no customData already created', function () { + let bidderRequest = JSON.parse(JSON.stringify(validBidderRequest)); + bidderRequest.ortb2 = { + 'site': { + 'name': 'example_ortb2_name', + 'domain': 'page.example.com', + 'cat': ['IAB2'], + 'sectioncat': ['IAB2-2'], + 'pagecat': ['IAB2-2'], + 'page': 'https://page.example.com/here.html', + 'ref': 'https://ref.example.com', + 'keywords': 'power tools, drills', + 'search': 'drill' + } + }; + const request = spec.buildRequests(validBidRequestsNoCustomData, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.imp[0].ext.newspassid.customData[0].targeting.name).to.equal('example_ortb2_name'); + expect(payload.imp[0].ext.newspassid.customData[0].targeting).to.not.have.property('gender') + }); + it('should add ortb2 user data to the user object', function () { + let bidderRequest = JSON.parse(JSON.stringify(validBidderRequest)); + bidderRequest.ortb2 = { + 'user': { + 'gender': 'I identify as a box of rocks' + } + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.user.gender).to.equal('I identify as a box of rocks'); + }); + it('handles schain object in each bidrequest (will be the same in each br)', function () { + let br = JSON.parse(JSON.stringify(validBidRequests)); + let schainConfigObject = { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'bidderA.com', + 'sid': '00001', + 'hp': 1 + } + ] + }; + br[0]['schain'] = schainConfigObject; + const request = spec.buildRequests(br, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.source.ext).to.haveOwnProperty('schain'); + expect(data.source.ext.schain).to.deep.equal(schainConfigObject); // .deep.equal() : Target object deeply (but not strictly) equals `{a: 1}` + }); + }); + describe('interpretResponse', function () { + it('should build bid array', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(result.length).to.equal(1); + }); + it('should have all relevant fields', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + const bid = result[0]; + expect(bid.cpm).to.equal(validResponse.body.seatbid[0].bid[0].cpm); + expect(bid.width).to.equal(validResponse.body.seatbid[0].bid[0].width); + expect(bid.height).to.equal(validResponse.body.seatbid[0].bid[0].height); + }); + it('should build bid array with usp/CCPA', function () { + let validBR = JSON.parse(JSON.stringify(validBidderRequest)); + validBR.uspConsent = '1YNY'; + const request = spec.buildRequests(validBidRequests, validBR); + const payload = JSON.parse(request.data); + expect(payload.user.ext.uspConsent).not.to.exist; + expect(payload.regs.ext.us_privacy).to.equal('1YNY'); + }); + it('should fail ok if no seatbid in server response', function () { + const result = spec.interpretResponse({}, {}); + expect(result).to.be.an('array'); + expect(result).to.be.empty; + }); + it('should fail ok if seatbid is not an array', function () { + const result = spec.interpretResponse({'body': {'seatbid': 'nothing_here'}}, {}); + expect(result).to.be.an('array'); + expect(result).to.be.empty; + }); + it('should correctly parse response where there are more bidders than ad slots', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validBidResponse1adWith2Bidders, request); + expect(result.length).to.equal(2); + }); + it('should have a ttl of 600', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(result[0].ttl).to.equal(300); + }); + it('should handle a valid whitelist, removing items not on the list & leaving others', function () { + config.setConfig({'newspassid': {'np_whitelist_adserver_keys': ['np_appnexus_crid', 'np_appnexus_adId']}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_adv')).to.be.undefined; + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_adId')).to.equal('2899ec066a91ff8-0-np-0'); + config.resetConfig(); + }); + it('should ignore a whitelist if enhancedAdserverTargeting is false', function () { + config.setConfig({'newspassid': {'np_whitelist_adserver_keys': ['np_appnexus_crid', 'np_appnexus_imp_id'], 'enhancedAdserverTargeting': false}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_adv')).to.be.undefined; + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_imp_id')).to.be.undefined; + config.resetConfig(); + }); + it('should correctly handle enhancedAdserverTargeting being false', function () { + config.setConfig({'newspassid': {'enhancedAdserverTargeting': false}}); + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_adv')).to.be.undefined; + expect(utils.deepAccess(result[0].adserverTargeting, 'np_appnexus_imp_id')).to.be.undefined; + config.resetConfig(); + }); + it('should add unique adId values to each bid', function() { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + let validres = JSON.parse(JSON.stringify(validResponse2BidsSameAdunit)); + const result = spec.interpretResponse(validres, request); + expect(result.length).to.equal(1); + expect(result[0]['price']).to.equal(0.9); + expect(result[0]['adserverTargeting']['np_npappnexus_adId']).to.equal('2899ec066a91ff8-0-np-1'); + }); + it('should add np_auc_id (response id value)', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + let validres = JSON.parse(JSON.stringify(validBidResponse1adWith2Bidders)); + const result = spec.interpretResponse(validres, request); + expect(utils.deepAccess(result[0].adserverTargeting, 'np_auc_id')).to.equal(validBidResponse1adWith2Bidders.body.id); + }); + it('should correctly process an auction with 2 adunits & multiple bidders one of which bids for both adslots', function() { + let validres = JSON.parse(JSON.stringify(multiResponse1)); + let request = spec.buildRequests(multiRequest1, multiBidderRequest1.bidderRequest); + let result = spec.interpretResponse(validres, request); + expect(result.length).to.equal(4); // one of the 5 bids will have been removed + expect(result[1]['price']).to.equal(0.521); + expect(result[1]['impid']).to.equal('3025f169863b7f8'); + expect(result[1]['id']).to.equal('18552976939844999'); + expect(result[1]['adserverTargeting']['np_npappnexus_adId']).to.equal('3025f169863b7f8-0-np-2'); + validres = JSON.parse(JSON.stringify(multiResponse1)); + validres.body.seatbid[0].bid[1].price = 1.1; + validres.body.seatbid[0].bid[1].cpm = 1.1; + request = spec.buildRequests(multiRequest1, multiBidderRequest1.bidderRequest); + result = spec.interpretResponse(validres, request); + expect(result[1]['price']).to.equal(1.1); + expect(result[1]['impid']).to.equal('3025f169863b7f8'); + expect(result[1]['id']).to.equal('18552976939844681'); + expect(result[1]['adserverTargeting']['np_npappnexus_adId']).to.equal('3025f169863b7f8-0-np-1'); + }); + }); + describe('userSyncs', function () { + it('should fail gracefully if no server response', function () { + const result = spec.getUserSyncs('bad', false, emptyObject); + expect(result).to.be.empty; + }); + it('should fail gracefully if server response is empty', function () { + const result = spec.getUserSyncs('bad', [], emptyObject); + expect(result).to.be.empty; + }); + it('should append the various values if they exist', function() { + spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', emptyObject); + expect(result).to.be.an('array'); + expect(result[0].url).to.include('publisherId=9876abcd12-3'); + expect(result[0].url).to.include('siteId=1234567890'); + }); + it('should append ccpa (usp data)', function() { + spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', emptyObject, '1YYN'); + expect(result).to.be.an('array'); + expect(result[0].url).to.include('usp_consent=1YYN'); + }); + it('should use "" if no usp is sent to cookieSync', function() { + spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', emptyObject); + expect(result).to.be.an('array'); + expect(result[0].url).to.include('usp_consent=&'); + }); + }); + describe('default size', function () { + it('should should return default sizes if no obj is sent', function () { + let obj = ''; + const result = defaultSize(obj); + expect(result.defaultHeight).to.equal(250); + expect(result.defaultWidth).to.equal(300); + }); + }); + describe('getGranularityKeyName', function() { + it('should return a string granularity as-is', function() { + const result = getGranularityKeyName('', 'this is it', ''); + expect(result).to.equal('this is it'); + }); + it('should return "custom" for a mediaTypeGranularity object', function() { + const result = getGranularityKeyName('', {}, ''); + expect(result).to.equal('custom'); + }); + it('should return "custom" for a mediaTypeGranularity object', function() { + const result = getGranularityKeyName('', false, 'string buckets'); + expect(result).to.equal('string buckets'); + }); + }); + describe('getGranularityObject', function() { + it('should return an object as-is', function() { + const result = getGranularityObject('', {'name': 'mark'}, '', ''); + expect(result.name).to.equal('mark'); + }); + it('should return an object as-is', function() { + const result = getGranularityObject('', false, 'custom', {'name': 'rupert'}); + expect(result.name).to.equal('rupert'); + }); + }); + describe('blockTheRequest', function() { + it('should return true if np_request is false', function() { + config.setConfig({'newspassid': {'np_request': false}}); + let result = spec.blockTheRequest(); + expect(result).to.be.true; + config.resetConfig(); + }); + it('should return false if np_request is true', function() { + config.setConfig({'newspassid': {'np_request': true}}); + let result = spec.blockTheRequest(); + expect(result).to.be.false; + config.resetConfig(); + }); + }); + describe('getPageId', function() { + it('should return the same Page ID for multiple calls', function () { + let result = spec.getPageId(); + expect(result).to.be.a('string'); + let result2 = spec.getPageId(); + expect(result2).to.equal(result); + }); + }); + describe('getBidRequestForBidId', function() { + it('should locate a bid inside a bid array', function () { + let result = spec.getBidRequestForBidId('2899ec066a91ff8', validBidRequestsMulti); + expect(result.testId).to.equal(1); + result = spec.getBidRequestForBidId('2899ec066a91ff0', validBidRequestsMulti); + expect(result.testId).to.equal(2); + }); + }); + describe('removeSingleBidderMultipleBids', function() { + it('should remove the multi bid by npappnexus for adslot 2d30e86db743a8', function() { + let validres = JSON.parse(JSON.stringify(multiResponse1)); + expect(validres.body.seatbid[0].bid.length).to.equal(3); + expect(validres.body.seatbid[0].seat).to.equal('npappnexus'); + let response = spec.removeSingleBidderMultipleBids(validres.body.seatbid); + expect(response.length).to.equal(2); + expect(response[0].bid.length).to.equal(2); + expect(response[0].seat).to.equal('npappnexus'); + expect(response[1].bid.length).to.equal(2); + }); + }); +}); diff --git a/test/spec/modules/nextMillenniumBidAdapter_spec.js b/test/spec/modules/nextMillenniumBidAdapter_spec.js index a8aa62f24d1..564788c8b56 100644 --- a/test/spec/modules/nextMillenniumBidAdapter_spec.js +++ b/test/spec/modules/nextMillenniumBidAdapter_spec.js @@ -14,10 +14,48 @@ describe('nextMillenniumBidAdapterTests', function() { gdprConsent: { consentString: 'kjfdniwjnifwenrif3', gdprApplies: true + }, + ortb2: { + device: { + w: 1500, + h: 1000 + }, + site: { + domain: 'example.com', + page: 'http://example.com' + } } } ]; + const serverResponse = { + body: { + id: 'f7b3d2da-e762-410c-b069-424f92c4c4b2', + seatbid: [ + { + bid: [ + { + id: '7457329903666272789', + price: 0.5, + adm: 'Hello! It\'s a test ad!', + adid: '96846035', + adomain: ['test.addomain.com'], + w: 300, + h: 250 + } + ] + } + ], + cur: 'USD', + ext: { + sync: { + image: ['urlA?gdpr={{.GDPR}}'], + iframe: ['urlB'], + } + } + } + }; + const bidRequestDataGI = [ { adUnitCode: 'test-banner-gi', @@ -39,6 +77,26 @@ describe('nextMillenniumBidAdapterTests', function() { } }, + { + adUnitCode: 'test-banner-gi', + bidId: 'bid1234', + auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', + bidder: 'nextMillennium', + params: { group_id: '1234' }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 300]] + } + }, + + sizes: [[300, 250], [300, 300]], + uspConsent: '1---', + gdprConsent: { + consentString: 'kjfdniwjnifwenrif3', + gdprApplies: true + } + }, + { adUnitCode: 'test-video-gi', bidId: 'bid1234', @@ -66,6 +124,47 @@ describe('nextMillenniumBidAdapterTests', function() { expect(JSON.parse(request[0].data).regs.ext.gdpr).to.equal(1); }); + it('Test getUserSyncs function', function () { + const syncOptions = { + 'iframeEnabled': false, + 'pixelEnabled': true + } + let userSync = spec.getUserSyncs(syncOptions, [serverResponse], bidRequestData[0].gdprConsent, bidRequestData[0].uspConsent); + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.equal('image'); + expect(userSync[0].url).to.equal('urlA?gdpr=1'); + + syncOptions.iframeEnabled = true; + syncOptions.pixelEnabled = false; + userSync = spec.getUserSyncs(syncOptions, [serverResponse], bidRequestData[0].gdprConsent, bidRequestData[0].uspConsent); + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.equal('iframe'); + expect(userSync[0].url).to.equal('urlB'); + }); + + it('Test getUserSyncs with no response', function () { + const syncOptions = { + 'iframeEnabled': true, + 'pixelEnabled': false + } + let userSync = spec.getUserSyncs(syncOptions, [], bidRequestData[0].gdprConsent, bidRequestData[0].uspConsent); + expect(userSync).to.be.an('array') + expect(userSync[0].type).to.equal('iframe') + expect(userSync[0].url).to.equal('https://cookies.nextmillmedia.com/sync?gdpr=1&gdpr_consent=kjfdniwjnifwenrif3&us_privacy=1---&type=iframe') + }) + + it('Test getUserSyncs function if GDPR is undefined', function () { + const syncOptions = { + 'iframeEnabled': false, + 'pixelEnabled': true + } + + let userSync = spec.getUserSyncs(syncOptions, [serverResponse], undefined, bidRequestData[0].uspConsent); + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.equal('image'); + expect(userSync[0].url).to.equal('urlA?gdpr=0'); + }); + it('Request params check without GDPR Consent', function () { delete bidRequestData[0].gdprConsent const request = spec.buildRequests(bidRequestData, bidRequestData[0]); @@ -74,9 +173,9 @@ describe('nextMillenniumBidAdapterTests', function() { }); it('validate_generated_params', function() { - const request = spec.buildRequests(bidRequestData); + const request = spec.buildRequests(bidRequestData, {bidderRequestId: 'mock-uuid'}); expect(request[0].bidId).to.equal('bid1234'); - expect(JSON.parse(request[0].data).id).to.equal('b06c5141-fe8f-4cdf-9d7d-54415490a917'); + expect(JSON.parse(request[0].data).id).to.exist; }); it('use parameters group_id', function() { @@ -84,7 +183,7 @@ describe('nextMillenniumBidAdapterTests', function() { const request = spec.buildRequests([test]); const requestData = JSON.parse(request[0].data); const storeRequestId = requestData.ext.prebid.storedrequest.id; - const templateRE = /^g\d+;\d+x\d+;/; + const templateRE = /^g[1-9]\d*;(?:[1-9]\d*x[1-9]\d*\|)*[1-9]\d*x[1-9]\d*;/; expect(templateRE.test(storeRequestId)).to.be.true; }; }); @@ -94,19 +193,43 @@ describe('nextMillenniumBidAdapterTests', function() { expect(JSON.parse(request[0].data).ext.nextMillennium.refresh_count).to.equal(3); }); - it('Test getUserSyncs function', function () { - const syncOptions = { - 'iframeEnabled': true - } - const userSync = spec.getUserSyncs(syncOptions); - expect(userSync).to.be.an('array').with.lengthOf(1); - expect(userSync[0].type).to.exist; - expect(userSync[0].url).to.exist; - expect(userSync[0].type).to.be.equal('iframe'); - expect(userSync[0].url).to.be.equal('https://statics.nextmillmedia.com/load-cookie.html?v=4'); + it('Check if domain was added', function() { + const request = spec.buildRequests(bidRequestData) + expect(JSON.parse(request[0].data).site.domain).to.exist + }) + + it('Check if elOffsets was added', function() { + const request = spec.buildRequests(bidRequestData) + expect(JSON.parse(request[0].data).ext.nextMillennium.elOffsets).to.be.an('object') + }) + + it('Check if imp object was added', function() { + const request = spec.buildRequests(bidRequestData) + expect(JSON.parse(request[0].data).imp).to.be.an('array') + }); + + it('Check if imp prebid stored id is correct', function() { + const request = spec.buildRequests(bidRequestData) + const requestData = JSON.parse(request[0].data); + const storedReqId = requestData.ext.prebid.storedrequest.id; + expect(requestData.imp[0].ext.prebid.storedrequest.id).to.equal(storedReqId) }); it('validate_response_params', function() { + let bids = spec.interpretResponse(serverResponse, bidRequestData[0]); + expect(bids).to.have.lengthOf(1); + + let bid = bids[0]; + + expect(bid.creativeId).to.equal('96846035'); + expect(bid.ad).to.equal('Hello! It\'s a test ad!'); + expect(bid.cpm).to.equal(0.5); + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.currency).to.equal('USD'); + }); + + it('validate_videowrapper_response_params', function() { const serverResponse = { body: { id: 'f7b3d2da-e762-410c-b069-424f92c4c4b2', @@ -116,11 +239,16 @@ describe('nextMillenniumBidAdapterTests', function() { { id: '7457329903666272789', price: 0.5, - adm: 'Hello! It\'s a test ad!', + adm: 'https://some_vast_host.com/vast.xml', adid: '96846035', adomain: ['test.addomain.com'], w: 300, - h: 250 + h: 250, + ext: { + prebid: { + type: 'video' + } + } } ] } @@ -135,10 +263,184 @@ describe('nextMillenniumBidAdapterTests', function() { let bid = bids[0]; expect(bid.creativeId).to.equal('96846035'); - expect(bid.ad).to.equal('Hello! It\'s a test ad!'); + expect(bid.vastUrl).to.equal('https://some_vast_host.com/vast.xml'); expect(bid.cpm).to.equal(0.5); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); expect(bid.currency).to.equal('USD'); }); + + it('validate_videoxml_response_params', function() { + const serverResponse = { + body: { + id: 'f7b3d2da-e762-410c-b069-424f92c4c4b2', + seatbid: [ + { + bid: [ + { + id: '7457329903666272789', + price: 0.5, + adm: '', + adid: '96846035', + adomain: ['test.addomain.com'], + w: 300, + h: 250, + ext: { + prebid: { + type: 'video' + } + } + } + ] + } + ], + cur: 'USD' + } + }; + + let bids = spec.interpretResponse(serverResponse, bidRequestData[0]); + expect(bids).to.have.lengthOf(1); + + let bid = bids[0]; + + expect(bid.creativeId).to.equal('96846035'); + expect(bid.vastXml).to.equal(''); + expect(bid.cpm).to.equal(0.5); + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.currency).to.equal('USD'); + }); + + it('Check function of getting URL for sending statistics data', function() { + const dataForTests = [ + { + eventName: 'bidRequested', + bid: { + bidderCode: 'appnexus', + bids: [{bidder: 'appnexus', params: {}}], + }, + + expected: undefined, + }, + + { + eventName: 'bidRequested', + bid: { + bidderCode: 'appnexus', + bids: [{bidder: 'appnexus', params: {placement_id: '807'}}], + }, + + expected: undefined, + }, + + { + eventName: 'bidRequested', + bid: { + bidderCode: 'nextMillennium', + bids: [{bidder: 'nextMillennium', params: {placement_id: '807'}}], + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=bidRequested&bidder=nextMillennium&source=pbjs&placements=807', + }, + + { + eventName: 'bidRequested', + bid: { + bidderCode: 'nextMillennium', + bids: [ + {bidder: 'nextMillennium', params: {placement_id: '807'}}, + {bidder: 'nextMillennium', params: {placement_id: '111'}}, + ], + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=bidRequested&bidder=nextMillennium&source=pbjs&placements=807;111', + }, + + { + eventName: 'bidRequested', + bid: { + bidderCode: 'nextMillennium', + bids: [{bidder: 'nextMillennium', params: {placement_id: '807', group_id: '123'}}], + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=bidRequested&bidder=nextMillennium&source=pbjs&groups=123', + }, + + { + eventName: 'bidRequested', + bid: { + bidderCode: 'nextMillennium', + bids: [ + {bidder: 'nextMillennium', params: {placement_id: '807', group_id: '123'}}, + {bidder: 'nextMillennium', params: {group_id: '456'}}, + {bidder: 'nextMillennium', params: {placement_id: '222'}}, + ], + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=bidRequested&bidder=nextMillennium&source=pbjs&groups=123;456&placements=222', + }, + + { + eventName: 'bidResponse', + bid: { + bidderCode: 'appnexus', + }, + + expected: undefined, + }, + + { + eventName: 'bidResponse', + bid: { + bidderCode: 'nextMillennium', + params: {placement_id: '807'}, + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=bidResponse&bidder=nextMillennium&source=pbjs&placements=807', + }, + + { + eventName: 'noBid', + bid: { + bidder: 'appnexus', + }, + + expected: undefined, + }, + + { + eventName: 'noBid', + bid: { + bidder: 'nextMillennium', + params: {placement_id: '807'}, + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=noBid&bidder=nextMillennium&source=pbjs&placements=807', + }, + + { + eventName: 'bidTimeout', + bid: { + bidder: 'appnexus', + }, + + expected: undefined, + }, + + { + eventName: 'bidTimeout', + bid: { + bidder: 'nextMillennium', + params: {placement_id: '807'}, + }, + + expected: 'https://report2.hb.brainlyads.com/statistics/metric?event=bidTimeout&bidder=nextMillennium&source=pbjs&placements=807', + }, + ]; + + for (let {eventName, bid, expected} of dataForTests) { + const url = spec.getUrlPixelMetric(eventName, bid); + expect(url).to.equal(expected); + }; + }) }); diff --git a/test/spec/modules/nextrollIdSystem_spec.js b/test/spec/modules/nextrollIdSystem_spec.js deleted file mode 100644 index d89c7fe3c98..00000000000 --- a/test/spec/modules/nextrollIdSystem_spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import { nextrollIdSubmodule, storage } from 'modules/nextrollIdSystem.js'; - -const LS_VALUE = `{ - "AdID":{"id":"adid","key":"AdID"}, - "AdID:1002": {"id":"adid","key":"AdID:1002","value":"id_value"}}`; - -describe('NextrollId module', function () { - let sandbox = sinon.sandbox.create(); - let hasLocalStorageStub; - let getLocalStorageStub; - - beforeEach(function() { - hasLocalStorageStub = sandbox.stub(storage, 'hasLocalStorage'); - getLocalStorageStub = sandbox.stub(storage, 'getDataFromLocalStorage'); - }); - - afterEach(function () { - sandbox.restore(); - }) - - const testCases = [ - { - expect: { - id: {nextrollId: 'id_value'}, - }, - params: {partnerId: '1002'}, - localStorage: LS_VALUE - }, - { - expect: {id: undefined}, - params: {partnerId: '1003'}, - localStorage: LS_VALUE - }, - { - expect: {id: undefined}, - params: {partnerId: ''}, - localStorage: LS_VALUE - }, - { - expect: {id: undefined}, - params: {partnerId: '102'}, - localStorage: undefined - }, - { - expect: {id: undefined}, - params: undefined, - localStorage: undefined - } - ] - testCases.forEach( - (testCase, i) => it(`getId() (TC #${i}) should return the nextroll id if it exists`, function () { - getLocalStorageStub.withArgs('dca0.com').returns(testCase.localStorage); - const id = nextrollIdSubmodule.getId({params: testCase.params}); - expect(id).to.be.deep.equal(testCase.expect); - })) -}); diff --git a/test/spec/modules/nexx360BidAdapter_spec.js b/test/spec/modules/nexx360BidAdapter_spec.js index 3d5b2554cda..7091bb56631 100644 --- a/test/spec/modules/nexx360BidAdapter_spec.js +++ b/test/spec/modules/nexx360BidAdapter_spec.js @@ -1,75 +1,76 @@ -import {expect} from 'chai'; -import {spec} from 'modules/nexx360BidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; -import {config} from 'src/config.js'; -import * as utils from 'src/utils.js'; -import { requestBidsHook } from 'modules/consentManagement.js'; +import { expect } from 'chai'; +import { + spec, storage, getNexx360LocalStorage, +} from 'modules/nexx360BidAdapter.js'; +import { sandbox } from 'sinon'; -describe('Nexx360 bid adapter tests', function () { - const DISPLAY_BID_REQUEST = [{ - 'bidder': 'nexx360', - 'params': { - 'account': '1067', - 'tagId': 'luvxjvgn' - }, - 'userId': { - 'id5id': { - 'uid': 'ID5*hQ5WobYI9Od4u52qpaXVKHhxUa4DsOWRAlvaFajm8gINfI1oVAe3UK59416dT4TqDX1pj4MBJ5TYwir6x3JgBw1-avYHSnmvQDdRMbxmC2sNf3ggIRTbyQBdI1RjvHyeDYCsistnTXF_iKF1nutYeQ2BZ4P5d5muZTG7C2PXVFgNg-18io9dCiSjzJXx93KPDYRiuIwtsGGsp51rojlpFw2Fp_dUkjXl4CAblk58DvwNhobwQ27bnBP8F2-Pcs88DYcvKn4r6dm3Vi7ILttxDQ2IgZ2X44ClgjoWh-vRf6ANis8Z7uL16vO8q0P5C21eDYuc4v_KaZqN-p9YWEeEZQ2OpkbRL7n5NieVJExHM6ANkAlLZhVf2T-1906TAIHKDZFm_xMCa1jJfpBqZB2agw2TjfbK6wMtJeHiZaipSuUNlM_CSH0HVXtfMj9yfzjzDZZnltZQ9lvc4JhXye5AwA2X1f9Dhk8VURTvVdfEUlU', - 'ext': { - 'linkType': 2 +const instreamResponse = { + 'id': '2be64380-ba0c-405a-ab53-51f51c7bde51', + 'cur': 'USD', + 'seatbid': [ + { + 'bid': [ + { + 'id': '8275140264321181514', + 'impid': '263cba3b8bfb72', + 'price': 5, + 'adomain': [ + 'appnexus.com' + ], + 'crid': '97517771', + 'h': 1, + 'w': 1, + 'ext': { + 'mediaType': 'instream', + 'ssp': 'appnexus', + 'divId': 'video1', + 'adUnitCode': 'video1', + 'vastXml': '\n \n \n Nexx360 Wrapper\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ' + } } - } + ], + 'seat': 'appnexus' + } + ], + 'ext': { + 'cookies': [] + } +}; + +describe('Nexx360 bid adapter tests', function () { + const DISPLAY_BID_REQUEST = { + 'id': '77b3f21a-e0df-4495-8bce-4e8a1d2309c1', + 'imp': [ + {'id': '2b4d8fc1c1c7ea', + 'tagid': 'div-1', + 'ext': {'divId': 'div-1', 'nexx360': {'account': '1067', 'tag_id': 'luvxjvgn'}}, + 'banner': {'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}], 'topframe': 1}}, {'id': '38fc428ab96638', 'tagid': 'div-2', 'ext': {'divId': 'div-2', 'nexx360': {'account': '1067', 'tag_id': 'luvxjvgn'}}, 'banner': {'format': [{'w': 728, 'h': 90}, {'w': 970, 'h': 250}], 'topframe': 1}}], + 'cur': ['USD'], + 'at': 1, + 'tmax': 3000, + 'site': {'page': 'https://test.nexx360.io/adapter/index.html?nexx360_test=1', 'domain': 'test.nexx360.io'}, + 'regs': {'coppa': 0, 'ext': {'gdpr': 1}}, + 'device': { + 'dnt': 0, + 'h': 844, + 'w': 390, + 'ua': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + 'language': 'fr' }, - 'userIdAsEids': [ - { - 'source': 'id5-sync.com', - 'uids': [ - { - 'id': 'ID5*hQ5WobYI9Od4u52qpaXVKHhxUa4DsOWRAlvaFajm8gINfI1oVAe3UK59416dT4TqDX1pj4MBJ5TYwir6x3JgBw1-avYHSnmvQDdRMbxmC2sNf3ggIRTbyQBdI1RjvHyeDYCsistnTXF_iKF1nutYeQ2BZ4P5d5muZTG7C2PXVFgNg-18io9dCiSjzJXx93KPDYRiuIwtsGGsp51rojlpFw2Fp_dUkjXl4CAblk58DvwNhobwQ27bnBP8F2-Pcs88DYcvKn4r6dm3Vi7ILttxDQ2IgZ2X44ClgjoWh-vRf6ANis8Z7uL16vO8q0P5C21eDYuc4v_KaZqN-p9YWEeEZQ2OpkbRL7n5NieVJExHM6ANkAlLZhVf2T-1906TAIHKDZFm_xMCa1jJfpBqZB2agw2TjfbK6wMtJeHiZaipSuUNlM_CSH0HVXtfMj9yfzjzDZZnltZQ9lvc4JhXye5AwA2X1f9Dhk8VURTvVdfEUlU', + 'user': { + 'ext': { + 'consent': 'CPgocUAPgocUAAKAsAENCkCsAP_AAH_AAAqIJDtd_H__bW9r-f5_aft0eY1P9_r37uQzDhfNk-8F3L_W_LwX52E7NF36tq4KmR4ku1LBIUNlHMHUDUmwaokVryHsak2cpzNKJ7BEknMZOydYGF9vmxtj-QKY7_5_d3bx2D-t_9v239z3z81Xn3d53-_03LCdV5_9Dfn9fR_bc9KPt_58v8v8_____3_e__3_7994JEAEmGrcQBdmWODNoGEUCIEYVhIVQKACCgGFogMAHBwU7KwCfWECABAKAIwIgQ4AowIBAAAJAEhEAEgRYIAAARAIAAQAIhEIAGBgEFgBYGAQAAgGgYohQACBIQZEBEUpgQFQJBAa2VCCUF0hphAHWWAFBIjYqABEEgIrAAEBYOAYIkBKxYIEmKN8gBGCFAKJUK1EAAAA.YAAAAAAAAAAA', + 'ConsentedProvidersSettings': {'consented_providers': '1~39.43.46.55.61.70.83.89.93.108.117.122.124.131.135.136.143.144.147.149.159.162.167.171.192.196.202.211.218.228.230.239.241.259.266.272.286.291.311.317.322.323.326.327.338.367.371.385.389.394.397.407.413.415.424.430.436.445.449.453.482.486.491.494.495.501.503.505.522.523.540.550.559.560.568.574.576.584.587.591.733.737.745.787.802.803.817.820.821.829.839.864.867.874.899.904.922.931.938.979.981.985.1003.1024.1027.1031.1033.1040.1046.1051.1053.1067.1085.1092.1095.1097.1099.1107.1127.1135.1143.1149.1152.1162.1166.1186.1188.1201.1205.1211.1215.1226.1227.1230.1252.1268.1270.1276.1284.1286.1290.1301.1307.1312.1345.1356.1364.1365.1375.1403.1415.1416.1419.1440.1442.1449.1455.1456.1465.1495.1512.1516.1525.1540.1548.1555.1558.1564.1570.1577.1579.1583.1584.1591.1603.1616.1638.1651.1653.1665.1667.1677.1678.1682.1697.1699.1703.1712.1716.1721.1725.1732.1745.1750.1765.1769.1782.1786.1800.1808.1810.1825.1827.1832.1838.1840.1842.1843.1845.1859.1866.1870.1878.1880.1889.1899.1917.1929.1942.1944.1962.1963.1964.1967.1968.1969.1978.2003.2007.2008.2027.2035.2039.2044.2047.2052.2056.2064.2068.2070.2072.2074.2088.2090.2103.2107.2109.2115.2124.2130.2133.2137.2140.2145.2147.2150.2156.2166.2177.2183.2186.2202.2205.2216.2219.2220.2222.2225.2234.2253.2264.2279.2282.2292.2299.2305.2309.2312.2316.2322.2325.2328.2331.2334.2335.2336.2337.2343.2354.2357.2358.2359.2370.2376.2377.2387.2392.2394.2400.2403.2405.2407.2411.2414.2416.2418.2425.2440.2447.2459.2461.2462.2465.2468.2472.2477.2481.2484.2486.2488.2493.2496.2497.2498.2499.2501.2510.2511.2517.2526.2527.2532.2534.2535.2542.2552.2563.2564.2567.2568.2569.2571.2572.2575.2577.2583.2584.2596.2601.2604.2605.2608.2609.2610.2612.2614.2621.2628.2629.2633.2634.2636.2642.2643.2645.2646.2647.2650.2651.2652.2656.2657.2658.2660.2661.2669.2670.2677.2681.2684.2686.2687.2690.2695.2698.2707.2713.2714.2729.2739.2767.2768.2770.2772.2784.2787.2791.2792.2798.2801.2805.2812.2813.2816.2817.2818.2821.2822.2827.2830.2831.2834.2838.2839.2840.2844.2846.2847.2849.2850.2852.2854.2856.2860.2862.2863.2865.2867.2869.2873.2874.2875.2876.2878.2880.2881.2882.2883.2884.2886.2887.2888.2889.2891.2893.2894.2895.2897.2898.2900.2901.2908.2909.2911.2912.2913.2914.2916.2917.2918.2919.2920.2922.2923.2924.2927.2929.2930.2931.2939.2940.2941.2947.2949.2950.2956.2961.2962.2963.2964.2965.2966.2968.2970.2973.2974.2975.2979.2980.2981.2983.2985.2986.2987.2991.2994.2995.2997.2999.3000.3002.3003.3005.3008.3009.3010.3012.3016.3017.3018.3019.3024.3025.3028.3034.3037.3038.3043.3045.3048.3052.3053.3055.3058.3059.3063.3065.3066.3068.3070.3072.3073.3074.3075.3076.3077.3078.3089.3090.3093.3094.3095.3097.3099.3104.3106.3109.3112.3117.3118.3119.3120.3124.3126.3127.3128.3130.3135.3136.3145.3149.3150.3151.3154.3155.3162.3163.3167.3172.3173.3180.3182.3183.3184.3185.3187.3188.3189.3190.3194.3196.3197.3209.3210.3211.3214.3215.3217.3219.3222.3223.3225.3226.3227.3228.3230.3231.3232.3234.3235.3236.3237.3238.3240.3241.3244.3245.3250.3251.3253.3257.3260.3268.3270.3272.3281.3288.3290.3292.3293.3295.3296.3300.3306.3307.3308.3314.3315.3316.3318.3324.3327.3328.3330'}, + 'eids': [{'source': 'id5-sync.com', + 'uids': [{'id': 'ID5*tdrSpYbccONIbxmulXFRLEil1aozZGGVMo9eEZgydgYoYFZQRYoae3wJyY0YtmXGKGJ7uXIQByQ6f7uzcpy9Oyhj1jGRzCf0BCoI4VkkKZIoZBubolUKUXXxOIdQOz7ZKGV0E3sqi9Zut0BbOuoJAihpLbgfNgDJ0xRmQw04rDooaxn7_TIPzEX5_L5ohNkUKG01Gnh2djvcrcPigKlk7ChwnauCwHIetHYI32yYAnAocYyqoM9XkoVOHtyOTC_UKHIR0qVBVIzJ1Nn_g7kLqyhzfosadKVvf7RQCsE6QrYodtpOJKg7i72-tnMXkzgmKHjh98aEDfTQrZOkKebmAyh6GlOHtYn_sZBFjJwtWp4oe9j2QTNbzK3G0jp1PlJqKHxiu4LawFEKJ3yi5-NFUyh-YkEalJUWyl1cDlWo5NQogAy2HM8N_w0qrVQgNbrTKIHK3KzTXztH7WzBgYrk8g', 'atype': 1, - 'ext': { - 'linkType': 2 - } - } - ] - } - ], - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [300, 600]] - } - }, - 'adUnitCode': 'banner-div', - 'transactionId': '9ad89d90-eb73-41b9-bf5f-7a8e2eecff27', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4d9e29504f8af6', - 'bidderRequestId': '3423b6bd1a922c', - 'auctionId': '05e0a3a1-9f57-41f6-bbcb-2ba9c9e3d2d5', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }]; - - const DISPLAY_BID_RESPONSE = {'body': { - 'responses': [ - { - 'bidId': '4d9e29504f8af6', - 'cpm': 0.437245, - 'width': 300, - 'height': 250, - 'creativeId': '98493581', - 'currency': 'EUR', - 'netRevenue': true, - 'type': 'banner', - 'ttl': 360, - 'uuid': 'ce6d1ee3-2a05-4d7c-b97a-9e62097798ec', - 'bidder': 'appnexus', - 'consent': 1, - 'tagId': 'luvxjvgn' - } - ], - }}; + 'ext': {'linkType': 2}}]}, + {'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}]}}, + 'ext': { + 'source': 'prebid.js', + 'version': '7.20.0-pre', + 'pageViewId': '5b970aba-51e9-4e0a-8299-f3f5618c695e' + }} const VIDEO_BID_REQUEST = [ { @@ -101,26 +102,6 @@ describe('Nexx360 bid adapter tests', function () { } ] - const VIDEO_BID_RESPONSE = {'body': { - 'responses': [ - { - 'bidId': '2c129e8e01859a', - 'type': 'video', - 'uuid': 'b8e7b2f0-c378-479f-aa4f-4f55d5d7d1d5', - 'cpm': 4.5421, - 'width': 1, - 'height': 1, - 'creativeId': '97517771', - 'currency': 'EUR', - 'netRevenue': true, - 'ttl': 360, - 'bidder': 'appnexus', - 'consent': 1, - 'tagId': 'yqsc1tfj' - } - ] - }}; - const DEFAULT_OPTIONS = { gdprConsent: { gdprApplies: true, @@ -146,111 +127,556 @@ describe('Nexx360 bid adapter tests', function () { }] }, }; - it('Verify banner build request', function () { - const request = spec.buildRequests(DISPLAY_BID_REQUEST, DEFAULT_OPTIONS); - expect(request).to.have.property('url').and.to.equal('https://fast.nexx360.io/prebid'); - expect(request).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request.data); - expect(requestContent.userEids.length).to.be.eql(1); - expect(requestContent.userEids[0]).to.have.property('source').and.to.equal('id5-sync.com'); - expect(requestContent.userEids[0]).to.have.property('uids'); - expect(requestContent.userEids[0].uids[0]).to.have.property('id').and.to.equal('ID5*hQ5WobYI9Od4u52qpaXVKHhxUa4DsOWRAlvaFajm8gINfI1oVAe3UK59416dT4TqDX1pj4MBJ5TYwir6x3JgBw1-avYHSnmvQDdRMbxmC2sNf3ggIRTbyQBdI1RjvHyeDYCsistnTXF_iKF1nutYeQ2BZ4P5d5muZTG7C2PXVFgNg-18io9dCiSjzJXx93KPDYRiuIwtsGGsp51rojlpFw2Fp_dUkjXl4CAblk58DvwNhobwQ27bnBP8F2-Pcs88DYcvKn4r6dm3Vi7ILttxDQ2IgZ2X44ClgjoWh-vRf6ANis8Z7uL16vO8q0P5C21eDYuc4v_KaZqN-p9YWEeEZQ2OpkbRL7n5NieVJExHM6ANkAlLZhVf2T-1906TAIHKDZFm_xMCa1jJfpBqZB2agw2TjfbK6wMtJeHiZaipSuUNlM_CSH0HVXtfMj9yfzjzDZZnltZQ9lvc4JhXye5AwA2X1f9Dhk8VURTvVdfEUlU'); - expect(requestContent.adUnits[0]).to.have.property('account').and.to.equal('1067'); - expect(requestContent.adUnits[0]).to.have.property('tagId').and.to.equal('luvxjvgn'); - expect(requestContent.adUnits[0]).to.have.property('label').and.to.equal('banner-div'); - expect(requestContent.adUnits[0]).to.have.property('bidId').and.to.equal('4d9e29504f8af6'); - expect(requestContent.adUnits[0]).to.have.property('auctionId').and.to.equal('05e0a3a1-9f57-41f6-bbcb-2ba9c9e3d2d5'); - expect(requestContent.adUnits[0]).to.have.property('mediatypes').exist; - expect(requestContent.adUnits[0].mediatypes).to.have.property('banner').exist; - }); - it('Verify banner parse response', function () { - const request = spec.buildRequests(DISPLAY_BID_REQUEST, DEFAULT_OPTIONS); - const response = spec.interpretResponse(DISPLAY_BID_RESPONSE, request); - expect(response).to.have.lengthOf(1); - const bid = response[0]; - expect(bid.cpm).to.equal(0.437245); - expect(bid.adUrl).to.equal('https://fast.nexx360.io/cache?uuid=ce6d1ee3-2a05-4d7c-b97a-9e62097798ec'); - expect(bid.width).to.equal(300); - expect(bid.height).to.equal(250); - expect(bid.creativeId).to.equal('98493581'); - expect(bid.currency).to.equal('EUR'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(360); - expect(bid.requestId).to.equal('4d9e29504f8af6'); - expect(bid.nexx360).to.exist; - expect(bid.nexx360.ssp).to.equal('appnexus'); - }); + describe('isBidRequestValid()', function() { + let bannerBid; + beforeEach(function () { + bannerBid = { + 'bidder': 'nexx360', + 'mediaTypes': {'banner': {'sizes': [[300, 250], [300, 600]]}}, + 'adUnitCode': 'div-1', + 'transactionId': '70bdc37e-9475-4b27-8c74-4634bdc2ee66', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4906582fc87d0c', + 'bidderRequestId': '332fda16002dbe', + 'auctionId': '98932591-c822-42e3-850e-4b3cf748d063', + } + }); - it('Verify video build request', function () { - const request = spec.buildRequests(VIDEO_BID_REQUEST, DEFAULT_OPTIONS); - expect(request).to.have.property('url').and.to.equal('https://fast.nexx360.io/prebid'); - expect(request).to.have.property('method').and.to.equal('POST'); - const requestContent = JSON.parse(request.data); - expect(requestContent.adUnits[0]).to.have.property('account').and.to.equal('1067'); - expect(requestContent.adUnits[0]).to.have.property('tagId').and.to.equal('yqsc1tfj'); - expect(requestContent.adUnits[0]).to.have.property('label').and.to.equal('video1'); - expect(requestContent.adUnits[0]).to.have.property('bidId').and.to.equal('22f90541e576a3'); - expect(requestContent.adUnits[0]).to.have.property('auctionId').and.to.equal('ed21b528-bcab-47e2-8605-ec9b71000c89'); - expect(requestContent.adUnits[0]).to.have.property('mediatypes').exist; - expect(requestContent.adUnits[0].mediatypes).to.have.property('video').exist; - }); + it('We verify isBidRequestValid with unvalid adUnitName', function() { + bannerBid.params = { adUnitName: 1 }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); + }); - it('Verify video parse response', function () { - const request = spec.buildRequests(VIDEO_BID_REQUEST, DEFAULT_OPTIONS); - const response = spec.interpretResponse(VIDEO_BID_RESPONSE, request); - expect(response).to.have.lengthOf(1); - const bid = response[0]; - expect(bid.cpm).to.equal(4.5421); - expect(bid.vastUrl).to.equal('https://fast.nexx360.io/cache?uuid=b8e7b2f0-c378-479f-aa4f-4f55d5d7d1d5'); - expect(bid.vastImpUrl).to.equal('https://fast.nexx360.io/track-imp?type=prebid&mediatype=video&ssp=appnexus&tag_id=yqsc1tfj&consent=1&price=4.5421'); - expect(bid.width).to.equal(1); - expect(bid.height).to.equal(1); - expect(bid.creativeId).to.equal('97517771'); - expect(bid.currency).to.equal('EUR'); - expect(bid.netRevenue).to.equal(true); - expect(bid.ttl).to.equal(360); - expect(bid.requestId).to.equal('2c129e8e01859a'); - expect(bid.nexx360).to.exist; - expect(bid.nexx360.ssp).to.equal('appnexus'); - }); + it('We verify isBidRequestValid with empty adUnitName', function() { + bannerBid.params = { adUnitName: '' }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); + }); - it('Verifies bidder code', function () { - expect(spec.code).to.equal('nexx360'); - }); + it('We verify isBidRequestValid with unvalid adUnitPath', function() { + bannerBid.params = { adUnitPath: 1 }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); + }); - it('Verifies bidder aliases', function () { - expect(spec.aliases).to.have.lengthOf(1); - expect(spec.aliases[0]).to.equal('revenuemaker'); - }); - it('Verifies if bid request valid', function () { - expect(spec.isBidRequestValid(DISPLAY_BID_REQUEST[0])).to.equal(true); - }); - it('Verifies bid won', function () { - const request = spec.buildRequests(DISPLAY_BID_REQUEST, DEFAULT_OPTIONS); - const response = spec.interpretResponse(DISPLAY_BID_RESPONSE, request); - const won = spec.onBidWon(response[0]); - expect(won).to.equal(true); - }); - it('Verifies user sync without cookie in bid response', function () { - var syncs = spec.getUserSyncs({}, [DISPLAY_BID_RESPONSE], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + it('We verify isBidRequestValid with unvalid divId', function() { + bannerBid.params = { divId: 1 }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); + }); + + it('We verify isBidRequestValid unvalid allBids', function() { + bannerBid.params = { allBids: 1 }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); + }); + + it('We verify isBidRequestValid with uncorrect tagid', function() { + bannerBid.params = { 'tagid': 'luvxjvgn' }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(false); + }); + + it('We verify isBidRequestValid with correct tagId', function() { + bannerBid.params = { 'tagId': 'luvxjvgn' }; + expect(spec.isBidRequestValid(bannerBid)).to.be.equal(true); + }); }); - it('Verifies user sync with cookies in bid response', function () { - DISPLAY_BID_RESPONSE.body.cookies = [{'type': 'image', 'url': 'http://www.cookie.sync.org/'}]; - var syncs = spec.getUserSyncs({}, [DISPLAY_BID_RESPONSE], DEFAULT_OPTIONS.gdprConsent); - expect(syncs).to.have.lengthOf(1); - expect(syncs[0]).to.have.property('type').and.to.equal('image'); - expect(syncs[0]).to.have.property('url').and.to.equal('http://www.cookie.sync.org/'); + + describe('getNexx360LocalStorage disabled', function () { + before(function () { + sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => false); + }); + it('We test if we get the nexx360Id', function() { + const output = getNexx360LocalStorage(); + expect(output).to.be.eql(false); + }); + after(function () { + sandbox.restore() + }); + }) + + describe('getNexx360LocalStorage enabled but nothing', function () { + before(function () { + sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); + sandbox.stub(storage, 'setDataInLocalStorage'); + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => null); + }); + it('We test if we get the nexx360Id', function() { + const output = getNexx360LocalStorage(); + expect(typeof output.nexx360Id).to.be.eql('string'); + }); + after(function () { + sandbox.restore() + }); + }) + + describe('getNexx360LocalStorage enabled but wrong payload', function () { + before(function () { + sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); + sandbox.stub(storage, 'setDataInLocalStorage'); + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => '{"nexx360Id":"5ad89a6e-7801-48e7-97bb-fe6f251f6cb4",}'); + }); + it('We test if we get the nexx360Id', function() { + const output = getNexx360LocalStorage(); + expect(output).to.be.eql(false); + }); + after(function () { + sandbox.restore() + }); + }) + + describe('getNexx360LocalStorage enabled', function () { + before(function () { + sandbox.stub(storage, 'localStorageIsEnabled').callsFake(() => true); + sandbox.stub(storage, 'setDataInLocalStorage'); + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake((key) => '{"nexx360Id":"5ad89a6e-7801-48e7-97bb-fe6f251f6cb4"}'); + }); + it('We test if we get the nexx360Id', function() { + const output = getNexx360LocalStorage(); + expect(output.nexx360Id).to.be.eql('5ad89a6e-7801-48e7-97bb-fe6f251f6cb4'); + }); + after(function () { + sandbox.restore() + }); + }) + + describe('buildRequests()', function() { + before(function () { + const documentStub = sandbox.stub(document, 'getElementById'); + documentStub.withArgs('div-1').returns({ + offsetWidth: 200, + offsetHeight: 250, + style: { + maxWidth: '400px', + maxHeight: '350px', + } + }); + }); + describe('We test with a multiple display bids', function() { + const sampleBids = [ + { + bidder: 'nexx360', + params: { + tagId: 'luvxjvgn', + divId: 'div-1', + adUnitName: 'header-ad', + adUnitPath: '/12345/nexx360/Homepage/HP/Header-Ad', + }, + adUnitCode: 'header-ad-1234', + transactionId: '469a570d-f187-488d-b1cb-48c1a2009be9', + sizes: [[300, 250], [300, 600]], + bidId: '44a2706ac3574', + bidderRequestId: '359bf8a3c06b2e', + auctionId: '2e684815-b44e-4e04-b812-56da54adbe74', + userIdAsEids: [ + { + source: 'id5-sync.com', + uids: [ + { + id: 'ID5*xe3R0Pbrc5Y4WBrb5UZSWTiS1t9DU2LgQrhdZOgFdXMoglhqmjs_SfBbyHfSYGZKKIT4Gf-XOQ_anA3iqi0hJSiFyD3aICGHDJFxNS8LO84ohwTQ0EiwOexZAbBlH0chKIhbvdGBfuouNuVF_YHCoyiLQJDp3WQiH96lE9MH2T0ojRqoyR623gxAWlBCBPh7KI4bYtZlet3Vtr-gH5_xqCiSEd7aYV37wHxUTSN38Isok_0qDCHg4pKXCcVM2h6FKJSGmvw-xPm9HkfkIcbh1CiVVG4nREP142XrBecdzhQomNlcalmwdzGHsuHPjTP-KJraa15yvvZDceq-f_YfECicDllYBLEsg24oPRM-ibMonWtT9qOm5dSfWS5G_r09KJ4HMB6REICq1wleDD1mwSigXkM_nxIKa4TxRaRqEekoooWRwuKA5-euHN3xxNfIKKP19EtGhuNTs0YdCSe8_w', + atype: 1, + ext: { + linkType: 2 + } + } + ] + }, + { + source: 'domain.com', + uids: [ + { + id: 'value read from cookie or local storage', + atype: 1, + ext: { + stype: 'ppuid' + } + } + ] + } + ], + }, + { + bidder: 'nexx360', + params: { + tagId: 'luvxjvgn', + allBids: true, + }, + mediaTypes: { + banner: { + sizes: [[728, 90], [970, 250]] + } + }, + adUnitCode: 'div-2-abcd', + transactionId: '6196885d-4e76-40dc-a09c-906ed232626b', + sizes: [[728, 90], [970, 250]], + bidId: '5ba94555219a03', + bidderRequestId: '359bf8a3c06b2e', + auctionId: '2e684815-b44e-4e04-b812-56da54adbe74', + } + ] + const bidderRequest = { + bidderCode: 'nexx360', + auctionId: '2e684815-b44e-4e04-b812-56da54adbe74', + bidderRequestId: '359bf8a3c06b2e', + refererInfo: { + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: [ + 'https://test.nexx360.io/adapter/index.html' + ], + topmostLocation: 'https://test.nexx360.io/adapter/index.html', + location: 'https://test.nexx360.io/adapter/index.html', + canonicalUrl: null, + page: 'https://test.nexx360.io/adapter/index.html', + domain: 'test.nexx360.io', + ref: null, + legacy: { + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: [ + 'https://test.nexx360.io/adapter/index.html' + ], + referer: 'https://test.nexx360.io/adapter/index.html', + canonicalUrl: null + }, + }, + gdprConsent: { + gdprApplies: true, + consentString: 'CPhdLUAPhdLUAAKAsAENCmCsAP_AAE7AAAqIJFNd_H__bW9r-f5_aft0eY1P9_r37uQzDhfNk-8F3L_W_LwX52E7NF36tq4KmR4ku1LBIUNlHMHUDUmwaokVryHsak2cpzNKJ7BEknMZOydYGF9vmxtj-QKY7_5_d3bx2D-t_9v239z3z81Xn3d53-_03LCdV5_9Dfn9fR_bc9KPt_58v8v8_____3_e__3_7997BIiAaADgAJYBnwEeAJXAXmAwQBj4DtgHcgPBAeKBIgAA.YAAAAAAAAAAA', + } + }; + it('We perform a test with 2 display adunits', function() { + const displayBids = [...sampleBids]; + displayBids[0].mediaTypes = { + banner: { + sizes: [[300, 250], [300, 600]] + } + }; + const request = spec.buildRequests(displayBids, bidderRequest); + const requestContent = request.data; + expect(request).to.have.property('method').and.to.equal('POST'); + expect(requestContent.cur[0]).to.be.eql('USD'); + expect(requestContent.imp.length).to.be.eql(2); + expect(requestContent.imp[0].id).to.be.eql('44a2706ac3574'); + expect(requestContent.imp[0].tagid).to.be.eql('header-ad'); + expect(requestContent.imp[0].ext.divId).to.be.eql('div-1'); + expect(requestContent.imp[0].ext.adUnitCode).to.be.eql('header-ad-1234'); + expect(requestContent.imp[0].ext.adUnitName).to.be.eql('header-ad'); + expect(requestContent.imp[0].ext.adUnitPath).to.be.eql('/12345/nexx360/Homepage/HP/Header-Ad'); + expect(requestContent.imp[0].ext.dimensions.slotW).to.be.eql(200); + expect(requestContent.imp[0].ext.dimensions.slotH).to.be.eql(250); + expect(requestContent.imp[0].ext.dimensions.cssMaxW).to.be.eql('400px'); + expect(requestContent.imp[0].ext.dimensions.cssMaxH).to.be.eql('350px'); + expect(requestContent.imp[0].ext.nexx360.tagId).to.be.eql('luvxjvgn'); + expect(requestContent.imp[0].banner.format.length).to.be.eql(2); + expect(requestContent.imp[0].banner.format[0].w).to.be.eql(300); + expect(requestContent.imp[0].banner.format[0].h).to.be.eql(250); + expect(requestContent.imp[1].ext.nexx360.allBids).to.be.eql(true); + expect(requestContent.imp[1].tagid).to.be.eql('div-2-abcd'); + expect(requestContent.imp[1].ext.adUnitCode).to.be.eql('div-2-abcd'); + expect(requestContent.imp[1].ext.divId).to.be.eql('div-2-abcd'); + expect(requestContent.ext.bidderVersion).to.be.eql('3.0'); + expect(requestContent.ext.source).to.be.eql('prebid.js'); + }); + + if (FEATURES.VIDEO) { + it('We perform a test with a multiformat adunit', function() { + const multiformatBids = [...sampleBids]; + multiformatBids[0].mediaTypes = { + banner: { + sizes: [[300, 250], [300, 600]] + }, + video: { + context: 'outstream', + playerSize: [640, 480], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1, + playback_method: ['auto_play_sound_off'] + } + }; + const request = spec.buildRequests(multiformatBids, bidderRequest); + const requestContent = request.data; + expect(requestContent.imp[0].video.ext.context).to.be.eql('outstream'); + expect(requestContent.imp[0].video.playbackmethod[0]).to.be.eql(2); + }); + + it('We perform a test with a instream adunit', function() { + const videoBids = [sampleBids[0]]; + videoBids[0].mediaTypes = { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6], + playbackmethod: [2], + skip: 1 + } + }; + const request = spec.buildRequests(videoBids, bidderRequest); + const requestContent = request.data; + expect(request).to.have.property('method').and.to.equal('POST'); + expect(requestContent.imp[0].video.ext.context).to.be.eql('instream'); + expect(requestContent.imp[0].video.playbackmethod[0]).to.be.eql(2); + }) + } + }); + after(function () { + sandbox.restore() + }); }); - it('Verifies user sync with no bid response', function() { - var syncs = spec.getUserSyncs({}, null, DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + + describe('interpretResponse()', function() { + it('empty response', function() { + const response = { + body: '' + }; + const output = spec.interpretResponse(response); + expect(output.length).to.be.eql(0); + }); + it('banner responses with adUrl only', function() { + const response = { + body: { + 'id': 'a8d3a675-a4ba-4d26-807f-c8f2fad821e0', + 'cur': 'USD', + 'seatbid': [ + { + 'bid': [ + { + 'id': '4427551302944024629', + 'impid': '226175918ebeda', + 'price': 1.5, + 'adomain': [ + 'http://prebid.org' + ], + 'crid': '98493581', + 'ssp': 'appnexus', + 'h': 600, + 'w': 300, + 'cat': [ + 'IAB3-1' + ], + 'ext': { + 'adUnitCode': 'div-1', + 'mediaType': 'banner', + 'adUrl': 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', + 'ssp': 'appnexus', + } + } + ], + 'seat': 'appnexus' + } + ], + 'ext': { + 'id': 'de3de7c7-e1cf-4712-80a9-94eb26bfc718', + 'cookies': [] + }, + } + }; + const output = spec.interpretResponse(response); + expect(output[0].adUrl).to.be.eql(response.body.seatbid[0].bid[0].ext.adUrl); + expect(output[0].mediaType).to.be.eql(response.body.seatbid[0].bid[0].ext.mediaType); + expect(output[0].currency).to.be.eql(response.body.cur); + expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + }); + it('banner responses with adm', function() { + const response = { + body: { + 'id': 'a8d3a675-a4ba-4d26-807f-c8f2fad821e0', + 'cur': 'USD', + 'seatbid': [ + { + 'bid': [ + { + 'id': '4427551302944024629', + 'impid': '226175918ebeda', + 'price': 1.5, + 'adomain': [ + 'http://prebid.org' + ], + 'crid': '98493581', + 'ssp': 'appnexus', + 'h': 600, + 'w': 300, + 'adm': '
TestAd
', + 'cat': [ + 'IAB3-1' + ], + 'ext': { + 'adUnitCode': 'div-1', + 'mediaType': 'banner', + 'adUrl': 'https://fast.nexx360.io/cache?uuid=fdddcebc-1edf-489d-880d-1418d8bdc493', + 'ssp': 'appnexus', + } + } + ], + 'seat': 'appnexus' + } + ], + 'ext': { + 'id': 'de3de7c7-e1cf-4712-80a9-94eb26bfc718', + 'cookies': [] + }, + } + }; + const output = spec.interpretResponse(response); + expect(output[0].ad).to.be.eql(response.body.seatbid[0].bid[0].adm); + expect(output[0].adUrl).to.be.eql(undefined); + expect(output[0].mediaType).to.be.eql(response.body.seatbid[0].bid[0].ext.mediaType); + expect(output[0].currency).to.be.eql(response.body.cur); + expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + }); + it('instream responses', function() { + const response = { + body: { + 'id': '2be64380-ba0c-405a-ab53-51f51c7bde51', + 'cur': 'USD', + 'seatbid': [ + { + 'bid': [ + { + 'id': '8275140264321181514', + 'impid': '263cba3b8bfb72', + 'price': 5, + 'adomain': [ + 'appnexus.com' + ], + 'crid': '97517771', + 'h': 1, + 'w': 1, + 'ext': { + 'mediaType': 'instream', + 'ssp': 'appnexus', + 'adUnitCode': 'video1', + 'vastXml': '\n \n \n Nexx360 Wrapper\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ' + } + } + ], + 'seat': 'appnexus' + } + ], + 'ext': { + 'cookies': [] + } + } + }; + const output = spec.interpretResponse(response); + expect(output[0].vastXml).to.be.eql(response.body.seatbid[0].bid[0].ext.vastXml); + expect(output[0].mediaType).to.be.eql('video'); + expect(output[0].currency).to.be.eql(response.body.cur); + expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + }); + + it('outstream responses', function() { + const response = { + body: { + 'id': '40c23932-135e-4602-9701-ca36f8d80c07', + 'cur': 'USD', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1186971142548769361', + 'impid': '4ce809b61a3928', + 'price': 5, + 'adomain': [ + 'appnexus.com' + ], + 'crid': '97517771', + 'h': 1, + 'w': 1, + 'ext': { + 'mediaType': 'outstream', + 'ssp': 'appnexus', + 'adUnitCode': 'div-1', + 'vastXml': '\n \n \n Nexx360 Wrapper\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ' + } + } + ], + 'seat': 'appnexus' + } + ], + 'ext': { + 'cookies': [] + } + } + }; + const output = spec.interpretResponse(response); + expect(output[0].vastXml).to.be.eql(response.body.seatbid[0].bid[0].ext.vastXml); + expect(output[0].mediaType).to.be.eql('video'); + expect(output[0].currency).to.be.eql(response.body.cur); + expect(typeof output[0].renderer).to.be.eql('object'); + expect(output[0].cpm).to.be.eql(response.body.seatbid[0].bid[0].price); + }); + + it('native responses', function() { + const response = { + body: { + 'id': '3c0290c1-6e75-4ef7-9e37-17f5ebf3bfa3', + 'cur': 'USD', + 'seatbid': [ + { + 'bid': [ + { + 'id': '6624930625245272225', + 'impid': '23e11d845514bb', + 'price': 10, + 'adomain': [ + 'prebid.org' + ], + 'crid': '97494204', + 'h': 1, + 'w': 1, + 'cat': [ + 'IAB3-1' + ], + 'ext': { + 'mediaType': 'native', + 'ssp': 'appnexus', + 'adUnitCode': '/19968336/prebid_native_example_1' + }, + 'adm': '{"ver":"1.2","assets":[{"id":1,"img":{"url":"https:\\/\\/vcdn.adnxs.com\\/p\\/creative-image\\/f8\\/7f\\/0f\\/13\\/f87f0f13-230c-4f05-8087-db9216e393de.jpg","w":989,"h":742,"ext":{"appnexus":{"prevent_crop":0}}}},{"id":0,"title":{"text":"This is a Prebid Native Creative"}},{"id":2,"data":{"value":"Prebid.org"}}],"link":{"url":"https:\\/\\/ams3-ib.adnxs.com\\/click?AAAAAAAAJEAAAAAAAAAkQAAAAAAAACRAAAAAAAAAJEAAAAAAAAAkQKZS4ZZl5vVbR6p-A-MwnyTZ7QVkAAAAAOLoyQBtJAAAbSQAAAIAAAC8pM8FnPgWAAAAAABVU0QAVVNEAAEAAQBNXQAAAAABAgMCAAAAALoAURe69gAAAAA.\\/bcr=AAAAAAAA8D8=\\/pp=${AUCTION_PRICE}\\/cnd=%21JBC72Aj8-LwKELzJvi4YnPFbIAQoADEAAAAAAAAkQDoJQU1TMzo2MTM1QNAwSQAAAAAAAPA_UQAAAAAAAAAAWQAAAAAAAAAAYQAAAAAAAAAAaQAAAAAAAAAAcQAAAAAAAAAAeACJAQAAAAAAAAAA\\/cca=OTMyNSNBTVMzOjYxMzU=\\/bn=97062\\/clickenc=http%3A%2F%2Fprebid.org%2Fdev-docs%2Fshow-native-ads.html"},"eventtrackers":[{"event":1,"method":1,"url":"https:\\/\\/ams3-ib.adnxs.com\\/it?an_audit=0&referrer=https%3A%2F%2Ftest.nexx360.io%2Fadapter%2Fnative%2Ftest.html&e=wqT_3QKJCqAJBQAAAwDWAAUBCNnbl6AGEKalhbfZzPn6WxjH1PqbsJzMzyQqNgkAAAECCCRAEQEHEAAAJEAZEQkAIREJACkRCQAxEQmoMOLRpwY47UhA7UhIAlC8yb4uWJzxW2AAaM26dXim9gWAAQGKAQNVU0SSAQEG9F4BmAEBoAEBqAEBsAEAuAECwAEDyAEC0AEJ2AEA4AEA8AEAigIpdWYoJ2EnLCAyNTI5ODg1LCAwKTt1ZigncicsIDk3NDk0MjA0LCAwKTuSAvEDIS0xRDNJQWo4LUx3S0VMekp2aTRZQUNDYzhWc3dBRGdBUUFSSTdVaFE0dEduQmxnQVlQX19fXzhQYUFCd0FYZ0JnQUVCaUFFQmtBRUJtQUVCb0FFQnFBRURzQUVBdVFIenJXcWtBQUFrUU1FQjg2MXFwQUFBSkVESkFYSUtWbWViSmZJXzJRRUFBQUFBQUFEd1AtQUJBUFVCQUFBQUFKZ0NBS0FDQUxVQ0FBQUFBTDBDQUFBQUFNQUNBY2dDQWRBQ0FkZ0NBZUFDQU9nQ0FQZ0NBSUFEQVpnREFib0RDVUZOVXpNNk5qRXpOZUFEMERDSUJBQ1FCQUNZQkFIQkJBQUFBQUFBQUFBQXlRUUFBCQscQUFOZ0VBUEURlSxBQUFDSUJmY3ZxUVUBDQRBQQGoCDdFRgEKCQEMREJCUQkKAQEAeRUoAUwyKAAAWi4oALg0QVhBaEQzd0JhTEQzd0w0QmQyMG1nR0NCZ05WVTBTSUJnQ1FCZ0dZQmdDaEJnQQFONEFBQ1JBcUFZQnNnWWtDHXQARR0MAEcdDABJHQw8dUFZS5oClQEhSkJDNzJBajL1ASRuUEZiSUFRb0FEFfhUa1FEb0pRVTFUTXpvMk1UTTFRTkF3UxFRDFBBX1URDAxBQUFXHQwAWR0MAGEdDABjHQwQZUFDSkEdEMjYAvfpA-ACrZhI6gIwaHR0cHM6Ly90ZXN0Lm5leHgzNjAuaW8vYWRhcHRlci9uYXRpdmUJH_CaaHRtbIADAIgDAZADAJgDFKADAaoDAMAD4KgByAMA2AMA4AMA6AMA-AMDgAQAkgQJL29wZW5ydGIymAQAqAQAsgQMCAAQABgAIAAwADgAuAQAwASA2rgiyAQA0gQOOTMyNSNBTVMzOjYxMzXaBAIIAeAEAPAEvMm-LvoEEgkAAABAPG1IQBEAAACgV8oCQIgFAZgFAKAF______8BBbABqgUkM2MwMjkwYzEtNmU3NS00ZWY3LTllMzctMTdmNWViZjNiZmEzwAUAyQWJFxTwP9IFCQkJDHgAANgFAeAFAfAFmfQh-gUECAAQAJAGAZgGALgGAMEGCSUo8D_QBvUv2gYWChAJERkBAdpg4AYM8gYCCACABwGIBwCgB0HIB6b2BdIHDRVkASYI2gcGAV1oGADgBwDqBwIIAPAHAIoIAhAAlQgAAIA_mAgB&s=ccf63f2e483a37091d2475d895e7cf7c911d1a78&pp=${AUCTION_PRICE}"}]}' + } + ], + 'seat': 'appnexus' + } + ], + 'ext': { + 'cookies': [], + } + } + }; + const output = spec.interpretResponse(response); + expect(output[0].native.ortb.ver).to.be.eql('1.2'); + expect(output[0].native.ortb.assets[0].id).to.be.eql(1); + expect(output[0].mediaType).to.be.eql('native'); + }); }); - it('Verifies user sync with no bid body response', function() { - var syncs = spec.getUserSyncs({}, [], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); - var syncs = spec.getUserSyncs({}, [{}], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); - expect(syncs).to.have.lengthOf(0); + + describe('getUserSyncs()', function() { + const response = { body: { cookies: [] } }; + it('Verifies user sync without cookie in bid response', function () { + var syncs = spec.getUserSyncs({}, [response], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + }); + it('Verifies user sync with cookies in bid response', function () { + response.body.ext = { + cookies: [{'type': 'image', 'url': 'http://www.cookie.sync.org/'}] + }; + var syncs = spec.getUserSyncs({}, [response], DEFAULT_OPTIONS.gdprConsent); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0]).to.have.property('type').and.to.equal('image'); + expect(syncs[0]).to.have.property('url').and.to.equal('http://www.cookie.sync.org/'); + }); + it('Verifies user sync with no bid response', function() { + var syncs = spec.getUserSyncs({}, null, DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + }); + it('Verifies user sync with no bid body response', function() { + var syncs = spec.getUserSyncs({}, [], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + var syncs = spec.getUserSyncs({}, [{}], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + }); }); }); diff --git a/test/spec/modules/nobidAnalyticsAdapter_spec.js b/test/spec/modules/nobidAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..742b4c16abb --- /dev/null +++ b/test/spec/modules/nobidAnalyticsAdapter_spec.js @@ -0,0 +1,494 @@ +import nobidAnalytics from 'modules/nobidAnalyticsAdapter.js'; +import {expect} from 'chai'; +import {server} from 'test/mocks/xhr.js'; +let events = require('src/events'); +let adapterManager = require('src/adapterManager').default; +let constants = require('src/constants.json'); + +const TOP_LOCATION = 'https://www.somesite.com'; +const SITE_ID = 1234; + +describe('NoBid Prebid Analytic', function () { + var clock; + describe('enableAnalytics', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + clock = sinon.useFakeTimers(Date.now()); + }); + + afterEach(function () { + events.getEvents.restore(); + clock.restore(); + }); + + after(function () { + nobidAnalytics.disableAnalytics(); + }); + + it('auctionInit test', function (done) { + const initOptions = { + options: { + /* siteId: SITE_ID */ + } + }; + + nobidAnalytics.enableAnalytics(initOptions); + expect(nobidAnalytics.initOptions).to.equal(undefined); + + initOptions.options.siteId = SITE_ID; + nobidAnalytics.enableAnalytics(initOptions); + expect(nobidAnalytics.initOptions.siteId).to.equal(SITE_ID); + + // Step 1: Initialize adapter + adapterManager.enableAnalytics({ + provider: 'nobid', + options: initOptions + }); + + // Step 2: Send init auction event + events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, + auctionId: '13', + timestamp: Date.now(), + bidderRequests: [{refererInfo: {topmostLocation: TOP_LOCATION}}]}); + expect(nobidAnalytics.initOptions).to.have.property('siteId', SITE_ID); + expect(nobidAnalytics).to.have.property('topLocation', TOP_LOCATION); + + const data = { ts: Date.now() }; + clock.tick(5000); + const expired = nobidAnalytics.isExpired(data); + expect(expired).to.equal(false); + + done(); + }); + + it('BID_REQUESTED/BID_RESPONSE/BID_TIMEOUT/AD_RENDER_SUCCEEDED test', function (done) { + const initOptions = { + options: { + siteId: SITE_ID + } + }; + + nobidAnalytics.enableAnalytics(initOptions); + + // Step 1: Initialize adapter + adapterManager.enableAnalytics({ + provider: 'nobid', + options: initOptions + }); + + // Step 2: Send init auction event + events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, + auctionId: '13', + timestamp: Date.now(), + bidderRequests: [{refererInfo: {topmostLocation: TOP_LOCATION}}]}); + events.emit(constants.EVENTS.BID_WON, {}); + clock.tick(5000); + expect(server.requests).to.have.length(1); + + events.emit(constants.EVENTS.BID_REQUESTED, {}); + clock.tick(5000); + expect(server.requests).to.have.length(1); + + events.emit(constants.EVENTS.BID_RESPONSE, {}); + clock.tick(5000); + expect(server.requests).to.have.length(1); + + events.emit(constants.EVENTS.BID_TIMEOUT, {}); + clock.tick(5000); + expect(server.requests).to.have.length(1); + + events.emit(constants.EVENTS.AD_RENDER_SUCCEEDED, {}); + clock.tick(5000); + expect(server.requests).to.have.length(1); + + done(); + }); + + it('bidWon test', function (done) { + const initOptions = { + options: { + siteId: SITE_ID + } + }; + + nobidAnalytics.enableAnalytics(initOptions); + + const TOP_LOCATION = 'https://www.somesite.com'; + + const requestIncoming = { + bidderCode: 'nobid', + width: 728, + height: 9, + statusMessage: 'Bid available', + adId: '106d14b7d06b607', + requestId: '67a7f0e7ea55c4', + transactionId: 'd58cbeae-92c8-4262-ba8d-0e649cbf5470', + auctionId: 'd758cce5-d178-408c-b777-8cac605ef7ca', + mediaType: 'banner', + source: 'client', + cpm: 6.4, + creativeId: 'TEST', + dealId: '', + currency: 'USD', + netRevenue: true, + ttl: 300, + ad: 'AD HERE', + meta: { + advertiserDomains: ['advertiser_domain.com'] + }, + metrics: { + 'requestBids.usp': 0 + }, + adapterCode: 'nobid', + originalCpm: 6.44, + originalCurrency: 'USD', + responseTimestamp: 1692156287517, + requestTimestamp: 1692156286972, + bidder: 'nobid', + adUnitCode: 'leaderboard', + timeToRespond: 545, + pbCg: '', + size: '728x90', + adserverTargeting: { + hb_bidder: 'nobid', + hb_adid: '106d14b7d06b607', + hb_pb: '6.40', + hb_size: '728x90', + hb_source: 'client', + hb_format: 'banner', + hb_adomain: 'advertiser_domain.com', + 'hb_crid': 'TEST' + }, + status: 'rendered', + params: [ + { + siteId: SITE_ID + } + ] + }; + + const requestOutgoing = { + bidderCode: 'nobid', + statusMessage: 'Bid available', + adId: '106d14b7d06b607', + requestId: '67a7f0e7ea55c4', + mediaType: 'banner', + cpm: 6.4, + adUnitCode: 'leaderboard', + timeToRespond: 545, + size: '728x90', + topLocation: TOP_LOCATION + }; + + // Step 1: Initialize adapter + adapterManager.enableAnalytics({ + provider: 'nobid', + options: initOptions + }); + + // Step 2: Send init auction event + events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, + auctionId: '13', + timestamp: Date.now(), + bidderRequests: [{refererInfo: {topmostLocation: TOP_LOCATION}}]}); + + // Step 3: Send bid won event + events.emit(constants.EVENTS.BID_WON, requestIncoming); + clock.tick(5000); + expect(server.requests).to.have.length(1); + const bidWonRequest = JSON.parse(server.requests[0].requestBody); + expect(bidWonRequest).to.have.property('bidderCode', requestOutgoing.bidderCode); + expect(bidWonRequest).to.have.property('statusMessage', requestOutgoing.statusMessage); + expect(bidWonRequest).to.have.property('adId', requestOutgoing.adId); + expect(bidWonRequest).to.have.property('requestId', requestOutgoing.requestId); + expect(bidWonRequest).to.have.property('mediaType', requestOutgoing.mediaType); + expect(bidWonRequest).to.have.property('cpm', requestOutgoing.cpm); + expect(bidWonRequest).to.have.property('adUnitCode', requestOutgoing.adUnitCode); + expect(bidWonRequest).to.have.property('timeToRespond', requestOutgoing.timeToRespond); + expect(bidWonRequest).to.have.property('size', requestOutgoing.size); + expect(bidWonRequest).to.have.property('topLocation', requestOutgoing.topLocation); + expect(bidWonRequest).to.not.have.property('pbCg'); + + done(); + }); + + it('auctionEnd test', function (done) { + const initOptions = { + options: { + siteId: SITE_ID + } + }; + + nobidAnalytics.enableAnalytics(initOptions); + + const TOP_LOCATION = 'https://www.somesite.com'; + + const requestIncoming = { + auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa', + timestamp: 1692224437573, + auctionEnd: 1692224437986, + auctionStatus: 'completed', + adUnits: [ + { + code: 'leaderboard', + sizes: [[728, 90]], + sizeConfig: [ + { minViewPort: [0, 0], sizes: [[300, 250]] }, + { minViewPort: [750, 0], sizes: [[728, 90]] } + ], + adunit: '/111111/adunit', + bids: [{ bidder: 'nobid', params: { siteId: SITE_ID } }] + } + ], + adUnitCodes: ['leaderboard'], + bidderRequests: [ + { + bidderCode: 'nobid', + auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa', + bidderRequestId: '5beedb9f99ad98', + bids: [ + { + bidder: 'nobid', + params: { siteId: SITE_ID }, + mediaTypes: { banner: { sizes: [[728, 90]] } }, + adUnitCode: 'leaderboard', + transactionId: 'bcda424d-f4f4-419b-acf9-1808d2dd22b1', + sizes: [[728, 90]], + bidId: '6ef0277f36c8df', + bidderRequestId: '5beedb9f99ad98', + auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + ortb2: { + site: { + domain: 'site.me', + publisher: { + domain: 'site.me' + }, + page: TOP_LOCATION + }, + device: { + w: 2605, + h: 895, + dnt: 0, + ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36', + language: 'en', + } + } + } + ], + auctionStart: 1692224437573, + timeout: 3000, + refererInfo: { + topmostLocation: TOP_LOCATION, + location: TOP_LOCATION, + page: TOP_LOCATION, + domain: 'site.me', + ref: null, + } + } + ], + noBids: [ + ], + bidsReceived: [ + { + bidderCode: 'nobid', + width: 728, + height: 90, + statusMessage: 'Bid available', + adId: '95781b6ae5ef2f', + requestId: '6ef0277f36c8df', + transactionId: 'bcda424d-f4f4-419b-acf9-1808d2dd22b1', + auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa', + mediaType: 'banner', + source: 'client', + cpm: 6.44, + creativeId: 'TEST', + dealId: '', + currency: 'USD', + netRevenue: true, + ttl: 300, + ad: '', + meta: { + advertiserDomains: [ + 'advertiser_domain.com' + ] + }, + adapterCode: 'nobid', + originalCpm: 6.44, + originalCurrency: 'USD', + responseTimestamp: 1692224437982, + requestTimestamp: 1692224437576, + bidder: 'nobid', + adUnitCode: 'leaderboard', + timeToRespond: 0, + pbLg: 5.00, + pbCg: '', + size: '728x90', + adserverTargeting: { hb_bidder: 'nobid', hb_pb: '6.40' }, + status: 'targetingSet' + } + ], + bidsRejected: [], + winningBids: [], + timeout: 3000 + }; + + const requestOutgoing = { + auctionId: '4c056b3c-f1a6-46bd-8d82-58c15b22fcfa', + bidderRequests: [ + { + bidderCode: 'nobid', + bidderRequestId: '7c1940bb285731', + bids: [ + { + bidder: 'nobid', + params: { siteId: SITE_ID }, + mediaTypes: { banner: { sizes: [[728, 90]] } }, + adUnitCode: 'leaderboard', + sizes: [[728, 90]], + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1 + } + ], + refererInfo: { + topmostLocation: TOP_LOCATION + } + } + ], + bidsReceived: [ + { + bidderCode: 'nobid', + width: 728, + height: 90, + mediaType: 'banner', + cpm: 6.44, + adUnitCode: 'leaderboard' + } + ] + }; + + // Step 1: Initialize adapter + adapterManager.enableAnalytics({ + provider: 'nobid', + options: initOptions + }); + + // Step 2: Send init auction event + events.emit(constants.EVENTS.AUCTION_INIT, {config: initOptions, + auctionId: '13', + timestamp: Date.now(), + bidderRequests: [{refererInfo: {topmostLocation: `${TOP_LOCATION}_something`}}]}); + + // Step 3: Send bid won event + events.emit(constants.EVENTS.AUCTION_END, requestIncoming); + clock.tick(5000); + expect(server.requests).to.have.length(1); + const auctionEndRequest = JSON.parse(server.requests[0].requestBody); + expect(auctionEndRequest).to.have.property('auctionId', requestOutgoing.auctionId); + expect(auctionEndRequest.bidderRequests).to.have.length(1); + expect(auctionEndRequest.bidderRequests[0]).to.have.property('bidderCode', requestOutgoing.bidderRequests[0].bidderCode); + expect(auctionEndRequest.bidderRequests[0].bids).to.have.length(1); + expect(auctionEndRequest.bidderRequests[0].bids[0]).to.have.property('bidder', requestOutgoing.bidderRequests[0].bids[0].bidder); + expect(auctionEndRequest.bidderRequests[0].bids[0]).to.have.property('adUnitCode', requestOutgoing.bidderRequests[0].bids[0].adUnitCode); + expect(auctionEndRequest.bidderRequests[0].bids[0].params).to.have.property('siteId', requestOutgoing.bidderRequests[0].bids[0].params.siteId); + expect(auctionEndRequest.bidderRequests[0].refererInfo).to.have.property('topmostLocation', requestOutgoing.bidderRequests[0].refererInfo.topmostLocation); + + done(); + }); + + it('Analytics disabled test', function (done) { + let disabled; + nobidAnalytics.processServerResponse(JSON.stringify({disabled: false})); + disabled = nobidAnalytics.isAnalyticsDisabled(); + expect(disabled).to.equal(false); + events.emit(constants.EVENTS.AUCTION_END, {auctionId: '1234567890'}); + clock.tick(1000); + expect(server.requests).to.have.length(1); + events.emit(constants.EVENTS.AUCTION_END, {auctionId: '12345678901'}); + clock.tick(1000); + expect(server.requests).to.have.length(2); + + nobidAnalytics.processServerResponse('disabled: true'); + events.emit(constants.EVENTS.AUCTION_END, {auctionId: '12345678902'}); + clock.tick(1000); + expect(server.requests).to.have.length(3); + + nobidAnalytics.processServerResponse(JSON.stringify({disabled: true})); + disabled = nobidAnalytics.isAnalyticsDisabled(); + expect(disabled).to.equal(true); + events.emit(constants.EVENTS.AUCTION_END, {auctionId: '12345678902'}); + clock.tick(5000); + expect(server.requests).to.have.length(3); + + nobidAnalytics.retentionSeconds = 5; + nobidAnalytics.processServerResponse(JSON.stringify({disabled: true})); + clock.tick(1000); + disabled = nobidAnalytics.isAnalyticsDisabled(); + expect(disabled).to.equal(true); + clock.tick(6000); + disabled = nobidAnalytics.isAnalyticsDisabled(); + expect(disabled).to.equal(false); + + done(); + }); + }); + + describe('NoBid Carbonizer', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + clock = sinon.useFakeTimers(Date.now()); + }); + + afterEach(function () { + events.getEvents.restore(); + clock.restore(); + }); + + after(function () { + nobidAnalytics.disableAnalytics(); + }); + + it('Carbonizer test', function (done) { + let active = nobidCarbonizer.isActive(); + expect(active).to.equal(false); + + active = nobidCarbonizer.isActive(JSON.stringify({carbonizer_active: false})); + expect(active).to.equal(false); + + nobidAnalytics.processServerResponse(JSON.stringify({carbonizer_active: true})); + active = nobidCarbonizer.isActive(); + expect(active).to.equal(true); + + const previousRetention = nobidAnalytics.retentionSeconds; + nobidAnalytics.retentionSeconds = 3; + nobidAnalytics.processServerResponse(JSON.stringify({carbonizer_active: true})); + const stored = nobidCarbonizer.getStoredLocalData(); + expect(stored).to.contain(`{"carbonizer_active":true,"ts":`); + clock.tick(5000); + active = nobidCarbonizer.isActive(adunits, true); + expect(active).to.equal(false); + + nobidAnalytics.retentionSeconds = previousRetention; + nobidAnalytics.processServerResponse(JSON.stringify({carbonizer_active: true})); + active = nobidCarbonizer.isActive(adunits, true); + expect(active).to.equal(true); + + let adunits = [ + { + bids: [ + { bidder: 'bidder1' }, + { bidder: 'bidder2' } + ] + } + ] + nobidCarbonizer.carbonizeAdunits(adunits, true); + expect(adunits[0].bids.length).to.equal(0); + + done(); + }); + }); +}); diff --git a/test/spec/modules/nobidBidAdapter_spec.js b/test/spec/modules/nobidBidAdapter_spec.js index eccf0e84031..b1e303bde6e 100644 --- a/test/spec/modules/nobidBidAdapter_spec.js +++ b/test/spec/modules/nobidBidAdapter_spec.js @@ -14,6 +14,36 @@ describe('Nobid Adapter', function () { }); }); + describe('buildRequestsWithFloor', function () { + const SITE_ID = 2; + const REFERER = 'https://www.examplereferer.com'; + let bidRequests = [ + { + 'bidder': 'nobid', + 'params': { + 'siteId': SITE_ID + }, + 'getFloor': () => { return { currency: 'USD', floor: 1.00 } }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + } + ]; + + let bidderRequest = { + refererInfo: {page: REFERER} + } + + it('should FLoor = 1', function () { + spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.a[0].floor).to.equal(1); + }); + }); + describe('isBidRequestValid', function () { let bid = { 'bidder': 'nobid', @@ -70,7 +100,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER}, bidderCode: BIDDER_CODE + refererInfo: {page: REFERER}, bidderCode: BIDDER_CODE } const siteName = 'example'; @@ -84,22 +114,20 @@ describe('Nobid Adapter', function () { const sitePageCat = 'IAB2-12'; it('ortb2 should exist', function () { - config.setConfig({ - ortb2: { - site: { - name: siteName, - domain: siteDomain, - cat: [ siteCat ], - sectioncat: [ siteSectionCat ], - pagecat: [ sitePageCat ], - page: sitePage, - ref: siteRef, - keywords: siteKeywords, - search: siteSearch - } + const ortb2 = { + site: { + name: siteName, + domain: siteDomain, + cat: [ siteCat ], + sectioncat: [ siteSectionCat ], + pagecat: [ sitePageCat ], + page: sitePage, + ref: siteRef, + keywords: siteKeywords, + search: siteSearch } - }); - const request = spec.buildRequests(bidRequests, bidderRequest); + }; + const request = spec.buildRequests(bidRequests, {...bidderRequest, ortb2}); let payload = JSON.parse(request.data); payload = JSON.parse(JSON.stringify(payload)); expect(payload.sid).to.equal(SITE_ID); @@ -115,6 +143,61 @@ describe('Nobid Adapter', function () { }); }); + describe('Request with GPP', function () { + const SITE_ID = 2; + const REFERER = 'https://www.examplereferer.com'; + const BIDDER_CODE = 'duration'; + let bidRequests = [ + { + 'bidder': BIDDER_CODE, + 'params': { + 'siteId': SITE_ID + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + } + ]; + + const GPP = 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN'; + const GPP_SID = [1, 3]; + + const bidderRequest = { + refererInfo: {page: REFERER}, + bidderCode: BIDDER_CODE, + gppConsent: {gppString: GPP, applicableSections: GPP_SID} + } + + it('gpp should match', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + let payload = JSON.parse(request.data); + payload = JSON.parse(JSON.stringify(payload)); + expect(payload.gpp).to.equal(GPP); + expect(payload.gpp_sid.join(',')).to.equal(GPP_SID.join(',')); + }); + + it('gpp should not be set', function () { + delete bidderRequest.gppConsent.applicableSections; + const request = spec.buildRequests(bidRequests, bidderRequest); + let payload = JSON.parse(request.data); + payload = JSON.parse(JSON.stringify(payload)); + expect(typeof payload.gpp).to.equal('undefined'); + expect(typeof payload.gpp_sid).to.equal('undefined'); + }); + + it('gpp ortb2 should match', function () { + delete bidderRequest.gppConsent; + bidderRequest.ortb2 = {regs: {gpp: GPP, gpp_sid: GPP_SID}}; + const request = spec.buildRequests(bidRequests, bidderRequest); + let payload = JSON.parse(request.data); + payload = JSON.parse(JSON.stringify(payload)); + expect(payload.gpp).to.equal(GPP); + expect(payload.gpp_sid.join(',')).to.equal(GPP_SID.join(',')); + }); + }); + describe('isDurationBidRequestValid', function () { const SITE_ID = 2; const REFERER = 'https://www.examplereferer.com'; @@ -134,7 +217,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER}, bidderCode: BIDDER_CODE + refererInfo: {page: REFERER}, bidderCode: BIDDER_CODE } it('should add source and version to the tag', function () { @@ -308,7 +391,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER} + refererInfo: {page: REFERER} } it('should add source and version to the tag', function () { @@ -397,7 +480,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER} + refererInfo: {page: REFERER} } it('should add source and version to the tag', function () { @@ -483,7 +566,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER} + refererInfo: {page: REFERER} } it('should criteo eid', function () { @@ -517,7 +600,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER} + refererInfo: {page: REFERER} } it('should add source and version to the tag', function () { @@ -651,7 +734,7 @@ describe('Nobid Adapter', function () { ]; let bidderRequest = { - refererInfo: {referer: REFERER} + refererInfo: {page: REFERER} } it('should refreshCount = 4', function () { diff --git a/test/spec/modules/novatiqIdSystem_spec.js b/test/spec/modules/novatiqIdSystem_spec.js index b92fb0d219a..6d25601d958 100644 --- a/test/spec/modules/novatiqIdSystem_spec.js +++ b/test/spec/modules/novatiqIdSystem_spec.js @@ -138,16 +138,31 @@ describe('novatiqIdSystem', function () { }); describe('decode', function() { - it('should log message if novatiqId has wrong format', function() { + it('should return the same novatiqId as passed in if not async', function() { const novatiqId = '81b001ec-8914-488c-a96e-8c220d4ee08895ef'; const response = novatiqIdSubmodule.decode(novatiqId); expect(response.novatiq.snowflake).to.have.length(40); }); - it('should log message if novatiqId has wrong format', function() { - const novatiqId = '81b001ec-8914-488c-a96e-8c220d4ee08895ef'; + it('should change the result format if async', function() { + let novatiqId = {}; + novatiqId.id = '81b001ec-8914-488c-a96e-8c220d4ee08895ef'; + novatiqId.syncResponse = 2; const response = novatiqIdSubmodule.decode(novatiqId); - expect(response.novatiq.snowflake).should.be.not.empty; + expect(response.novatiq.ext.syncResponse).should.be.not.empty; + expect(response.novatiq.snowflake.id).should.be.not.empty; + expect(response.novatiq.snowflake.syncResponse).should.be.not.empty; + }); + + it('should remove syncResponse if removeAdditionalInfo true', function() { + let novatiqId = {}; + novatiqId.id = '81b001ec-8914-488c-a96e-8c220d4ee08895ef'; + novatiqId.syncResponse = 2; + var config = {params: {removeAdditionalInfo: true}}; + const response = novatiqIdSubmodule.decode(novatiqId, config); + expect(response.novatiq.ext.syncResponse).should.be.not.empty; + expect(response.novatiq.snowflake.id).should.be.not.empty; + should.equal(response.novatiq.snowflake.syncResponse, undefined); }); }); }) diff --git a/test/spec/modules/oguryBidAdapter_spec.js b/test/spec/modules/oguryBidAdapter_spec.js index acf62bf5a7b..ed358af19b6 100644 --- a/test/spec/modules/oguryBidAdapter_spec.js +++ b/test/spec/modules/oguryBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/oguryBidAdapter'; import * as utils from 'src/utils.js'; +import {server} from '../../mocks/xhr.js'; const BID_URL = 'https://mweb-hb.presage.io/api/header-bidding-request'; const TIMEOUT_URL = 'https://ms-ads-monitoring-events.presage.io/bid_timeout' @@ -62,6 +63,7 @@ describe('OguryBidAdapter', function () { ]; bidderRequest = { + bidderRequestId: 'mock-uuid', auctionId: bidRequests[0].auctionId, gdprConsent: {consentString: 'myConsentString', vendorData: {}, gdprApplies: true}, }; @@ -112,123 +114,257 @@ describe('OguryBidAdapter', function () { let syncOptions, gdprConsent; beforeEach(() => { - syncOptions = {pixelEnabled: true}; gdprConsent = { gdprApplies: true, consentString: 'CPJl4C8PJl4C8OoAAAENAwCMAP_AAH_AAAAAAPgAAAAIAPgAAAAIAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g' }; }); - it('should return syncs array with two elements of type image', () => { - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + describe('pixel', () => { + beforeEach(() => { + syncOptions = { pixelEnabled: true }; + }); + + it('should return syncs array with three elements of type image', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.contain('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch'); + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.contain('https://ms-cookie-sync.presage.io/ttd/init-sync'); + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.contain('https://ms-cookie-sync.presage.io/xandr/init-sync'); + }); + + it('should set the source as query param', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs[0].url).to.contain('source=prebid'); + expect(userSyncs[1].url).to.contain('source=prebid'); + expect(userSyncs[2].url).to.contain('source=prebid'); + }); + + it('should set the tcString as query param', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs[0].url).to.contain(`iab_string=${gdprConsent.consentString}`); + expect(userSyncs[1].url).to.contain(`iab_string=${gdprConsent.consentString}`); + expect(userSyncs[2].url).to.contain(`iab_string=${gdprConsent.consentString}`); + }); + + it('should return an empty array when pixel is disable', () => { + syncOptions.pixelEnabled = false; + expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0); + }); + + it('should return syncs array with three elements of type image when consentString is undefined', () => { + gdprConsent = { + gdprApplies: true, + consentString: undefined + }; - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.contain('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch'); - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.contain('https://ms-cookie-sync.presage.io/ttd/init-sync'); - }); + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.equal('https://ms-cookie-sync.presage.io/xandr/init-sync?iab_string=&source=prebid') + }); + + it('should return syncs array with three elements of type image when consentString is null', () => { + gdprConsent = { + gdprApplies: true, + consentString: null + }; - it('should set the source as query param', () => { - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs[0].url).to.contain('source=prebid'); - expect(userSyncs[1].url).to.contain('source=prebid'); - }); + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.equal('https://ms-cookie-sync.presage.io/xandr/init-sync?iab_string=&source=prebid') + }); + + it('should return syncs array with three elements of type image when gdprConsent is undefined', () => { + gdprConsent = undefined; + + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.equal('https://ms-cookie-sync.presage.io/xandr/init-sync?iab_string=&source=prebid') + }); + + it('should return syncs array with three elements of type image when gdprConsent is null', () => { + gdprConsent = null; + + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.equal('https://ms-cookie-sync.presage.io/xandr/init-sync?iab_string=&source=prebid') + }); + + it('should return syncs array with three elements of type image when gdprConsent is null and gdprApplies is false', () => { + gdprConsent = { + gdprApplies: false, + consentString: null + }; - it('should set the tcString as query param', () => { - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs[0].url).to.contain(`iab_string=${gdprConsent.consentString}`); - expect(userSyncs[1].url).to.contain(`iab_string=${gdprConsent.consentString}`); - }); + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.equal('https://ms-cookie-sync.presage.io/xandr/init-sync?iab_string=&source=prebid') + }); + + it('should return syncs array with three elements of type image when gdprConsent is empty string and gdprApplies is false', () => { + gdprConsent = { + gdprApplies: false, + consentString: '' + }; - it('should return an empty array when pixel is disable', () => { - syncOptions.pixelEnabled = false; - expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0); + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(3); + expect(userSyncs[0].type).to.equal('image'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') + expect(userSyncs[1].type).to.equal('image'); + expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + expect(userSyncs[2].type).to.equal('image'); + expect(userSyncs[2].url).to.equal('https://ms-cookie-sync.presage.io/xandr/init-sync?iab_string=&source=prebid') + }); }); - it('should return syncs array with two elements of type image when consentString is undefined', () => { - gdprConsent = { - gdprApplies: true, - consentString: undefined - }; - - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') - }); + describe('iframe', () => { + beforeEach(() => { + syncOptions = { iframeEnabled: true }; + }); + + it('should return syncs array with one element of type iframe', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.contain('https://ms-cookie-sync.presage.io/user-sync.html'); + }); + + it('should set the source as query param', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs[0].url).to.contain('source=prebid'); + }); + + it('should set the tcString as query param', () => { + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs[0].url).to.contain(`gdpr_consent=${gdprConsent.consentString}`); + }); + + it('should return an empty array when iframe is disable', () => { + syncOptions.iframeEnabled = false; + expect(spec.getUserSyncs(syncOptions, [], gdprConsent)).to.have.lengthOf(0); + }); + + it('should return syncs array with one element of type iframe when consentString is undefined', () => { + gdprConsent = { + gdprApplies: true, + consentString: undefined + }; - it('should return syncs array with two elements of type image when consentString is null', () => { - gdprConsent = { - gdprApplies: true, - consentString: null - }; + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/user-sync.html?gdpr_consent=&source=prebid') + }); - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') - }); + it('should return syncs array with one element of type iframe when consentString is null', () => { + gdprConsent = { + gdprApplies: true, + consentString: null + }; - it('should return syncs array with two elements of type image when gdprConsent is undefined', () => { - gdprConsent = undefined; + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/user-sync.html?gdpr_consent=&source=prebid') + }); + + it('should return syncs array with one element of type iframe when gdprConsent is undefined', () => { + gdprConsent = undefined; + + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/user-sync.html?gdpr_consent=&source=prebid') + }); + + it('should return syncs array with one element of type iframe when gdprConsent is null', () => { + gdprConsent = null; + + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/user-sync.html?gdpr_consent=&source=prebid') + }); + + it('should return syncs array with one element of type iframe when gdprConsent is null and gdprApplies is false', () => { + gdprConsent = { + gdprApplies: false, + consentString: null + }; - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') - }); + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/user-sync.html?gdpr_consent=&source=prebid') + }); - it('should return syncs array with two elements of type image when gdprConsent is null', () => { - gdprConsent = null; + it('should return syncs array with one element of type iframe when gdprConsent is empty string and gdprApplies is false', () => { + gdprConsent = { + gdprApplies: false, + consentString: '' + }; - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); + expect(userSyncs).to.have.lengthOf(1); + expect(userSyncs[0].type).to.equal('iframe'); + expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/user-sync.html?gdpr_consent=&source=prebid') + }); }); + }); - it('should return syncs array with two elements of type image when gdprConsent is null and gdprApplies is false', () => { - gdprConsent = { - gdprApplies: false, - consentString: null - }; - - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + describe('buildRequests', function () { + const stubbedWidth = 200 + const stubbedHeight = 600 + const stubbedCurrentTime = 1234567890 + const stubbedDevicePixelRatio = 1 + const stubbedWidthMethod = sinon.stub(window.top.document.documentElement, 'clientWidth').get(function() { + return stubbedWidth; + }); + const stubbedHeightMethod = sinon.stub(window.top.document.documentElement, 'clientHeight').get(function() { + return stubbedHeight; + }); + const stubbedCurrentTimeMethod = sinon.stub(document.timeline, 'currentTime').get(function() { + return stubbedCurrentTime; }); - it('should return syncs array with two elements of type image when gdprConsent is empty string and gdprApplies is false', () => { - gdprConsent = { - gdprApplies: false, - consentString: '' - }; - - const userSyncs = spec.getUserSyncs(syncOptions, [], gdprConsent); - expect(userSyncs).to.have.lengthOf(2); - expect(userSyncs[0].type).to.equal('image'); - expect(userSyncs[0].url).to.equal('https://ms-cookie-sync.presage.io/v1/init-sync/bid-switch?iab_string=&source=prebid') - expect(userSyncs[1].type).to.equal('image'); - expect(userSyncs[1].url).to.equal('https://ms-cookie-sync.presage.io/ttd/init-sync?iab_string=&source=prebid') + const stubbedDevicePixelMethod = sinon.stub(window, 'devicePixelRatio').get(function() { + return stubbedDevicePixelRatio; }); - }); - describe('buildRequests', function () { const defaultTimeout = 1000; const expectedRequestObject = { - id: bidRequests[0].auctionId, + id: 'mock-uuid', at: 1, tmax: defaultTimeout, imp: [{ @@ -241,18 +377,23 @@ describe('OguryBidAdapter', function () { h: 250 }] }, - ext: bidRequests[0].params + ext: { + ...bidRequests[0].params, + timeSpentOnPage: stubbedCurrentTime + } }, { id: bidRequests[1].bidId, tagid: bidRequests[1].params.adUnitId, - bidfloor: 0, banner: { format: [{ w: 600, h: 500 }] }, - ext: bidRequests[1].params + ext: { + ...bidRequests[1].params, + timeSpentOnPage: stubbedCurrentTime + } }], regs: { ext: { @@ -271,10 +412,22 @@ describe('OguryBidAdapter', function () { }, ext: { prebidversion: '$prebid.version$', - adapterversion: '1.2.10' + adapterversion: '1.5.0' + }, + device: { + w: stubbedWidth, + h: stubbedHeight, + pxratio: stubbedDevicePixelRatio, } }; + after(function() { + stubbedWidthMethod.restore(); + stubbedHeightMethod.restore(); + stubbedCurrentTimeMethod.restore(); + stubbedDevicePixelMethod.restore(); + }); + it('sends bid request to ENDPOINT via POST', function () { const validBidRequests = utils.deepClone(bidRequests) @@ -283,6 +436,25 @@ describe('OguryBidAdapter', function () { expect(request.method).to.equal('POST'); }); + it('timeSpentOnpage should be 0 if timeline is undefined', function () { + const stubbedTimelineMethod = sinon.stub(document, 'timeline').get(function() { + return undefined; + }); + const validBidRequests = utils.deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data.imp[0].ext.timeSpentOnPage).to.equal(0); + stubbedTimelineMethod.restore(); + }); + + it('send device pixel ratio in bid request', function() { + const validBidRequests = utils.deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data).to.deep.equal(expectedRequestObject); + expect(request.data.device.pxratio).to.be.a('number'); + }) + it('bid request object should be conform', function () { const validBidRequests = utils.deepClone(bidRequests) @@ -291,6 +463,166 @@ describe('OguryBidAdapter', function () { expect(request.data.regs.ext.gdpr).to.be.a('number'); }); + describe('getClientWidth', () => { + function testGetClientWidth(testGetClientSizeParams) { + const stubbedClientWidth = sinon.stub(window.top.document.documentElement, 'clientWidth').get(function() { + return testGetClientSizeParams.docClientSize + }) + + const stubbedInnerWidth = sinon.stub(window.top, 'innerWidth').get(function() { + return testGetClientSizeParams.innerSize + }) + + const stubbedOuterWidth = sinon.stub(window.top, 'outerWidth').get(function() { + return testGetClientSizeParams.outerSize + }) + + const stubbedWidth = sinon.stub(window.top.screen, 'width').get(function() { + return testGetClientSizeParams.screenSize + }) + + const validBidRequests = utils.deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data.device.w).to.equal(testGetClientSizeParams.expectedSize); + + stubbedClientWidth.restore(); + stubbedInnerWidth.restore(); + stubbedOuterWidth.restore(); + stubbedWidth.restore(); + } + + it('should get documentElementClientWidth by default', () => { + testGetClientWidth({ + docClientSize: 22, + innerSize: 50, + outerSize: 45, + screenSize: 10, + expectedSize: 22, + }) + }) + + it('should get innerWidth as first fallback', () => { + testGetClientWidth({ + docClientSize: undefined, + innerSize: 700, + outerSize: 650, + screenSize: 10, + expectedSize: 700, + }) + }) + + it('should get outerWidth as second fallback', () => { + testGetClientWidth({ + docClientSize: undefined, + innerSize: undefined, + outerSize: 650, + screenSize: 10, + expectedSize: 650, + }) + }) + + it('should get screenWidth as last fallback', () => { + testGetClientWidth({ + docClientSize: undefined, + innerSize: undefined, + outerSize: undefined, + screenSize: 10, + expectedSize: 10, + }); + }); + + it('should return 0 if all window width values are undefined', () => { + testGetClientWidth({ + docClientSize: undefined, + innerSize: undefined, + outerSize: undefined, + screenSize: undefined, + expectedSize: 0, + }); + }); + }); + + describe('getClientHeight', () => { + function testGetClientHeight(testGetClientSizeParams) { + const stubbedClientHeight = sinon.stub(window.top.document.documentElement, 'clientHeight').get(function() { + return testGetClientSizeParams.docClientSize + }) + + const stubbedInnerHeight = sinon.stub(window.top, 'innerHeight').get(function() { + return testGetClientSizeParams.innerSize + }) + + const stubbedOuterHeight = sinon.stub(window.top, 'outerHeight').get(function() { + return testGetClientSizeParams.outerSize + }) + + const stubbedHeight = sinon.stub(window.top.screen, 'height').get(function() { + return testGetClientSizeParams.screenSize + }) + + const validBidRequests = utils.deepClone(bidRequests) + + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data.device.h).to.equal(testGetClientSizeParams.expectedSize); + + stubbedClientHeight.restore(); + stubbedInnerHeight.restore(); + stubbedOuterHeight.restore(); + stubbedHeight.restore(); + } + + it('should get documentElementClientHeight by default', () => { + testGetClientHeight({ + docClientSize: 420, + innerSize: 500, + outerSize: 480, + screenSize: 230, + expectedSize: 420, + }); + }); + + it('should get innerHeight as first fallback', () => { + testGetClientHeight({ + docClientSize: undefined, + innerSize: 500, + outerSize: 480, + screenSize: 230, + expectedSize: 500, + }); + }); + + it('should get outerHeight as second fallback', () => { + testGetClientHeight({ + docClientSize: undefined, + innerSize: undefined, + outerSize: 480, + screenSize: 230, + expectedSize: 480, + }); + }); + + it('should get screenHeight as last fallback', () => { + testGetClientHeight({ + docClientSize: undefined, + innerSize: undefined, + outerSize: undefined, + screenSize: 230, + expectedSize: 230, + }); + }); + + it('should return 0 if all window height values are undefined', () => { + testGetClientHeight({ + docClientSize: undefined, + innerSize: undefined, + outerSize: undefined, + screenSize: undefined, + expectedSize: 0, + }); + }); + }); + it('should not add gdpr infos if not present', () => { const bidderRequestWithoutGdpr = { ...bidderRequest, @@ -401,7 +733,7 @@ describe('OguryBidAdapter', function () { it('should handle bidFloor when currency is not USD', () => { const expectedRequestWithUnsupportedFloorCurrency = utils.deepClone(expectedRequestObject) - expectedRequestWithUnsupportedFloorCurrency.imp[0].bidfloor = 0; + delete expectedRequestWithUnsupportedFloorCurrency.imp[0].bidfloor; let validBidRequests = utils.deepClone(bidRequests); validBidRequests[0] = { ...validBidRequests[0], @@ -482,7 +814,7 @@ describe('OguryBidAdapter', function () { advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[0].adomain }, nurl: openRtbBidResponse.body.seatbid[0].bid[0].nurl, - adapterVersion: '1.2.10', + adapterVersion: '1.5.0', prebidVersion: '$prebid.version$' }, { requestId: openRtbBidResponse.body.seatbid[0].bid[1].impid, @@ -499,7 +831,7 @@ describe('OguryBidAdapter', function () { advertiserDomains: openRtbBidResponse.body.seatbid[0].bid[1].adomain }, nurl: openRtbBidResponse.body.seatbid[0].bid[1].nurl, - adapterVersion: '1.2.10', + adapterVersion: '1.5.0', prebidVersion: '$prebid.version$' }] @@ -520,20 +852,11 @@ describe('OguryBidAdapter', function () { }); describe('onBidWon', function() { - const nurl = 'https://fakewinurl.test'; - let xhr; + const nurl = 'https://fakewinurl.test/'; let requests; beforeEach(function() { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (xhr) => { - requests.push(xhr); - }; - }) - - afterEach(function() { - xhr.restore() + requests = server.requests; }) it('Should not create nurl request if bid is undefined', function() { @@ -601,21 +924,15 @@ describe('OguryBidAdapter', function () { }) describe('onTimeout', function () { - let xhr; let requests; beforeEach(function() { - xhr = sinon.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = (xhr) => { + requests = server.requests; + server.onCreate = (xhr) => { requests.push(xhr); }; }) - afterEach(function() { - xhr.restore() - }) - it('should send on bid timeout notification', function() { const bid = { ad: 'cookies', diff --git a/test/spec/modules/oneKeyIdSystem_spec.js b/test/spec/modules/oneKeyIdSystem_spec.js new file mode 100644 index 00000000000..9172a61df79 --- /dev/null +++ b/test/spec/modules/oneKeyIdSystem_spec.js @@ -0,0 +1,107 @@ +import { oneKeyIdSubmodule } from 'modules/oneKeyIdSystem' + +const defaultConf = { + params: { + proxyHostName: 'proxy.com' + } +}; + +const defaultIdsAndPreferences = { + identifiers: [ + { + version: '0.1', + type: 'paf_browser_id', + value: 'df0a5664-987d-4074-bbd9-e9b12ebae6ef', + source: { + domain: 'crto-poc-1.onekey.network', + timestamp: 1657100291, + signature: 'ikjV6WwpcroNB5XyLOr3MgYHLpS6UjICEOuv/jEr00uVrjZm0zluDSWh11OeGDZrMhxMBPeTabtQ4U2rNk3IzQ==' + } + } + ], + preferences: { + version: '0.1', + data: { + use_browsing_for_personalization: true + }, + source: { + domain: 'cmp.pafdemopublisher.com', + timestamp: 1657100294, + signature: 'aAbMThxyeKpe/EgT5ARI1xecjCwwh0uRagsTuPXNY2fzh7foeW31qljDZf6h8UwOd9M2bAN7XNtM2LYBbJzskQ==' + } + } +}; + +const defaultIdsAndPreferencesResult = { + status: 'PARTICIPATING', + data: defaultIdsAndPreferences +}; + +describe('oneKeyData module', () => { + describe('getId function', () => { + beforeEach(() => { + setUpOneKey(); + }); + + it('return a callback for handling asynchron results', () => { + const moduleIdResponse = oneKeyIdSubmodule.getId(defaultConf); + + expect(moduleIdResponse.callback).to.be.an('function'); + }); + + it(`return a callback that waits for OneKey to be loaded`, () => { + const moduleIdResponse = oneKeyIdSubmodule.getId(defaultConf); + + moduleIdResponse.callback(function() {}) + + expect(window.OneKey.queue.length).to.equal(1); + }); + + it('return a callback that gets ids and prefs', () => { + const moduleIdResponse = oneKeyIdSubmodule.getId(defaultConf); + + // Act + return new Promise((resolve) => { + moduleIdResponse.callback(resolve); + executeOneKeyQueue(); + }) + + // Assert + .then((idsAndPrefs) => { + expect(idsAndPrefs).to.equal(defaultIdsAndPreferences); + }); + }); + + it('return a callback with undefined if impossible to get ids and prefs', () => { + window.OneKey.getIdsAndPreferences = () => { + return Promise.reject(new Error(`Impossible to get ids and prefs`)); + }; + const moduleIdResponse = oneKeyIdSubmodule.getId(defaultConf); + + // Act + return new Promise((resolve) => { + moduleIdResponse.callback(resolve); + executeOneKeyQueue(); + }) + + // Assert + .then((idsAndPrefs) => { + expect(idsAndPrefs).to.be.undefined; + }); + }); + }); +}); + +const setUpOneKey = () => { + window.OneKey.queue = []; + window.OneKey.getIdsAndPreferences = () => { + return Promise.resolve(defaultIdsAndPreferencesResult); + }; +} + +const executeOneKeyQueue = () => { + while (window.OneKey.queue.length > 0) { + window.OneKey.queue[0](); + window.OneKey.queue.shift(); + } +} diff --git a/test/spec/modules/oneKeyRtdProvider_spec.js b/test/spec/modules/oneKeyRtdProvider_spec.js new file mode 100644 index 00000000000..70023e35196 --- /dev/null +++ b/test/spec/modules/oneKeyRtdProvider_spec.js @@ -0,0 +1,152 @@ +import {oneKeyDataSubmodule} from 'modules/oneKeyRtdProvider.js'; +import {getAdUnits} from '../../fixtures/fixtures.js'; + +const defaultSeed = { + version: '0.1', + transaction_ids: [ + 'd566b02a-a6e2-4c87-98dc-f5623cd9e828', + 'f7ffe3cc-0d58-4ec4-b687-1d3d410a48fe' + ], + publisher: 'cmp.pafdemopublisher.com', + source: { + domain: 'cmp.pafdemopublisher.com', + timestamp: 1657116880, + signature: '6OmdrSGwagPpugGFuQ4VGjzqYadHxWIXPaLItk0vA1lmi/EQyRvNF5seXStfwKWRnC7HZlOIGSjA6g7HAuofWw==' + + } +}; + +const defaultOrb2WithTransmission = { + user: { + ext: { + paf: { + transmission: { + seed: defaultSeed + } + } + } + } +}; + +const defaultRtdConfig = { + params: { + proxyHostName: 'host' + } +}; + +describe('oneKeyDataSubmodule', () => { + var bidsConfig; + beforeEach(() => { + // Fresh bidsConfig because it can be altered + // during the tests. + bidsConfig = getReqBidsConfig(); + setUpOneKey(); + }); + + it('successfully instantiates', () => { + expect(oneKeyDataSubmodule.init()).to.equal(true); + }); + + it('call OneKey API once it is loaded', () => { + const done = sinon.spy(); + + oneKeyDataSubmodule.getBidRequestData(bidsConfig, done, defaultRtdConfig); + + expect(bidsConfig).to.eql(getReqBidsConfig()); + expect(done.callCount).to.equal(0); + expect(window.OneKey.queue.length).to.equal(1); + }); + + it('don\'t change anything without a seed', () => { + window.OneKey.generateSeed = (_transactionIds) => { + return Promise.resolve(undefined); + }; + + // Act + return new Promise(resolve => { + oneKeyDataSubmodule.getBidRequestData(bidsConfig, resolve, defaultRtdConfig); + executeOneKeyQueue(); + }) + + // Assert + .then(() => { + expect(bidsConfig).to.eql(getReqBidsConfig()); + }); + }); + + [ // Test cases + { + description: 'global orb2', + rtdConfig: defaultRtdConfig, + expectedFragment: { + global: { + ...defaultOrb2WithTransmission + }, + bidder: {} + } + }, + + { + description: 'bidder-specific orb2', + rtdConfig: { + params: { + proxyHostName: 'host', + bidders: [ 'bidder42', 'bidder24' ] + } + }, + expectedFragment: { + global: { }, + bidder: { + bidder42: { + ...defaultOrb2WithTransmission + }, + bidder24: { + ...defaultOrb2WithTransmission + } + } + } + } + ].forEach(testCase => { + it(`update adUnits with transaction-ids and transmission in ${testCase.description}`, () => { + // Act + return new Promise(resolve => { + oneKeyDataSubmodule.getBidRequestData(bidsConfig, resolve, testCase.rtdConfig); + executeOneKeyQueue(); + }) + + // Assert + .then(() => { + // Verify transaction-ids without equality + // because they are generated UUID. + bidsConfig.adUnits.forEach((adUnit) => { + expect(adUnit.ortb2Imp.ext.data.paf.transaction_id).to.not.be.undefined; + }); + expect(bidsConfig.ortb2Fragments).to.eql(testCase.expectedFragment); + }); + }); + }); +}); + +const getReqBidsConfig = () => { + return { + adUnits: getAdUnits(), + ortb2Fragments: { + global: {}, + bidder: {} + } + } +} + +const setUpOneKey = () => { + window.OneKey.queue = []; + OneKey.generateSeed = (_transactionIds) => { + return Promise.resolve(defaultSeed); + }; +} + +const executeOneKeyQueue = () => { + while (window.OneKey.queue.length > 0) { + window.OneKey.queue[0](); + window.OneKey.queue.shift(); + } +} diff --git a/test/spec/modules/oneVideoBidAdapter_spec.js b/test/spec/modules/oneVideoBidAdapter_spec.js deleted file mode 100644 index d6dacb44529..00000000000 --- a/test/spec/modules/oneVideoBidAdapter_spec.js +++ /dev/null @@ -1,1046 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/oneVideoBidAdapter.js'; - -describe('OneVideoBidAdapter', function () { - let bidRequest; - let bidderRequest = { - 'bidderCode': 'oneVideo', - 'auctionId': 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4', - 'bidderRequestId': '1e498b84fffc39', - 'bids': bidRequest, - 'auctionStart': 1520001292880, - 'timeout': 3000, - 'start': 1520001292884, - 'doneCbCallCount': 0, - 'refererInfo': { - 'numIframes': 1, - 'reachedTop': true, - 'referer': 'test.com' - } - }; - let mockConfig; - - beforeEach(function () { - bidRequest = { - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480] - } - }, - bidder: 'oneVideo', - sizes: [640, 480], - bidId: '30b3efwfwe1e', - adUnitCode: 'video1', - params: { - video: { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [2], - position: 1, - delivery: [2], - playbackmethod: [1, 5], - sid: 134, - rewarded: 1, - placement: 1, - hp: 1, - inventoryid: 123 - }, - site: { - id: 1, - page: 'https://news.yahoo.com/portfolios', - referrer: 'http://www.yahoo.com' - }, - pubId: 'brxd' - } - }; - }); - - describe('spec.isBidRequestValid', function () { - it('should return false when mediaTypes video OR banner not declared', function () { - bidRequest.mediaTypes = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return true (skip validations) when e2etest = true', function () { - bidRequest.params.video = { - e2etest: true - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when mediaTypes.video has all mandatory params', function () { - bidRequest.mediaTypes.video = { - context: 'instream', - playerSize: [640, 480], - mimes: ['video/mp4', 'application/javascript'], - } - bidRequest.params.video = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when params.video has all override params instead of mediaTypes.video', function () { - bidRequest.mediaTypes.video = { - context: 'instream' - }; - bidRequest.params.video = { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'] - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when playerWidth & playerHeight are passed in params.video', function () { - bidRequest.mediaTypes.video = { - context: 'instream', - mimes: ['video/mp4', 'application/javascript'] - }; - bidRequest.params.video = { - playerWidth: 640, - playerHeight: 480, - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return true when mimes is passed in params.video', function () { - bidRequest.mediaTypes.video = { - context: 'instream', - playerSizes: [640, 480] - }; - bidRequest.video = { - mimes: ['video/mp4', 'application/javascript'] - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when both mediaTypes.video and params.video Objects are missing', function () { - bidRequest.mediaTypes = {}; - bidRequest.params = { - pubId: 'brxd' - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when both mediaTypes.video and params.video are missing mimes and player size', function () { - bidRequest.mediaTypes = { - video: { - context: 'instream' - } - }; - bidRequest.params = { - pubId: 'brxd' - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when the "pubId" param is missing', function () { - bidRequest.params = { - video: { - playerWidth: 480, - playerHeight: 640, - mimes: ['video/mp4', 'application/javascript'], - } - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return true when the "pubId" param exists', function () { - bidRequest.mediaTypes = { - video: { - playerSizes: [640, 480], - mimes: ['video/mp4', 'application/javascript'] - }, - pubId: 'brxd' - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }); - - it('should return false when no bid params are passed', function () { - bidRequest.params = {}; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - - it('should return false when the mediaType is "banner" and display="undefined" (DAP 3P)', function () { - bidRequest = { - mediaTypes: { - banner: { - sizes: [640, 480] - } - } - } - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }) - - it('should return true when the mediaType is "banner" and display=1 (DAP 3P)', function () { - bidRequest = { - mediaTypes: { - banner: { - sizes: [640, 480] - } - }, - bidder: 'oneVideo', - sizes: [640, 480], - bidId: '30b3efwfwe1e', - adUnitCode: 'video1', - params: { - video: { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [2], - position: 1, - delivery: [2], - playbackmethod: [1, 5], - sid: 134, - rewarded: 1, - placement: 1, - inventoryid: 123, - display: 1 - }, - site: { - id: 1, - page: 'https://news.yahoo.com/portfolios', - referrer: 'http://www.yahoo.com' - }, - pubId: 'brxd' - } - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }) - - it('should return false when the mediaType is "video" and context="outstream" and display=1 (DAP 3P)', function () { - bidRequest = { - mediaTypes: { - video: { - context: 'outstream', - playerSize: [640, 480] - } - }, - params: { - video: { - display: 1 - } - } - } - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }) - - it('should return true for Multi-Format AdUnits, when the mediaTypes are both "banner" and "video" (Multi-Format Support)', function () { - bidRequest = { - mediaTypes: { - banner: { - sizes: [640, 480] - }, - video: { - context: 'outstream', - playerSize: [640, 480], - mimes: ['video/mp4', 'application/javascript'] - } - }, - bidder: 'oneVideo', - sizes: [640, 480], - bidId: '30b3efwfwe1e', - adUnitCode: 'video1', - params: { - video: { - protocols: [2, 5], - api: [2] - }, - site: { - page: 'https://news.yahoo.com/portfolios', - referrer: 'http://www.yahoo.com' - }, - pubId: 'brxd' - } - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - }) - }); - - describe('spec.buildRequests', function () { - it('should create a POST request for every bid', function () { - const requests = spec.buildRequests([bidRequest], bidderRequest); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(spec.ENDPOINT + bidRequest.params.pubId); - }); - - it('should attach the bid request object', function () { - const requests = spec.buildRequests([bidRequest], bidderRequest); - expect(requests[0].bidRequest).to.equal(bidRequest); - }); - - it('should attach request data', function () { - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const [width, height] = bidRequest.sizes; - const placement = bidRequest.params.video.placement; - const rewarded = bidRequest.params.video.rewarded; - const inventoryid = bidRequest.params.video.inventoryid; - const VERSION = '3.1.2'; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - expect(data.imp[0].bidfloor).to.equal(bidRequest.params.bidfloor); - expect(data.imp[0].ext.rewarded).to.equal(rewarded); - expect(data.imp[0].video.placement).to.equal(placement); - expect(data.imp[0].ext.inventoryid).to.equal(inventoryid); - expect(data.imp[0].ext.prebidver).to.equal('$prebid.version$'); - expect(data.imp[0].ext.adapterver).to.equal(VERSION); - }); - - it('must parse bid size from a nested array', function () { - const width = 640; - const height = 480; - bidRequest.sizes = [ - [width, height] - ]; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - }); - - it('should set pubId to HBExchange when bid.params.video.e2etest = true', function () { - bidRequest.params.video.e2etest = true; - const requests = spec.buildRequests([bidRequest], bidderRequest); - expect(requests[0].method).to.equal('POST'); - expect(requests[0].url).to.equal(spec.E2ETESTENDPOINT + 'HBExchange'); - }); - - it('should attach End 2 End test data', function () { - bidRequest.params.video.e2etest = true; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].bidfloor).to.not.exist; - expect(data.imp[0].video.w).to.equal(300); - expect(data.imp[0].video.h).to.equal(250); - expect(data.imp[0].video.mimes).to.eql(['video/mp4', 'application/javascript']); - expect(data.imp[0].video.api).to.eql([2]); - expect(data.site.page).to.equal('https://verizonmedia.com'); - expect(data.site.ref).to.equal('https://verizonmedia.com'); - expect(data.tmax).to.equal(1000); - }); - - it('it should create new schain and send it if video.params.sid exists', function () { - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const schain = data.source.ext.schain; - expect(schain.nodes.length).to.equal(1); - expect(schain.nodes[0].sid).to.equal(bidRequest.params.video.sid); - expect(schain.nodes[0].rid).to.equal(data.id); - }) - - it('should send Global or Bidder specific schain if sid is not passed in video.params.sid', function () { - bidRequest.params.video.sid = null; - const globalSchain = { - ver: '1.0', - complete: 1, - nodes: [{ - asi: 'some-platform.com', - sid: '111111', - rid: bidRequest.id, - hp: 1 - }] - }; - bidRequest.schain = globalSchain; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const schain = data.source.ext.schain; - expect(schain.nodes.length).to.equal(1); - expect(schain).to.equal(globalSchain); - }); - - it('should ignore Global or Bidder specific schain if video.params.sid exists and send new schain', function () { - const globalSchain = { - ver: '1.0', - complete: 1, - nodes: [{ - asi: 'some-platform.com', - sid: '111111', - rid: bidRequest.id, - hp: 1 - }] - }; - bidRequest.schain = globalSchain; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const schain = data.source.ext.schain; - expect(schain.nodes.length).to.equal(1); - expect(schain.complete).to.equal(1); - expect(schain.nodes[0].sid).to.equal(bidRequest.params.video.sid); - expect(schain.nodes[0].rid).to.equal(data.id); - }) - - it('should append hp to new schain created by sid if video.params.hp is passed', function () { - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const schain = data.source.ext.schain; - expect(schain.nodes[0].hp).to.equal(bidRequest.params.video.hp); - }) - it('should not accept key values pairs if custom is Undefined ', function () { - bidRequest.params.video.custom = null; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].ext.custom).to.be.undefined; - }); - it('should not accept key values pairs if custom is Array ', function () { - bidRequest.params.video.custom = []; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].ext.custom).to.be.undefined; - }); - it('should not accept key values pairs if custom is Number ', function () { - bidRequest.params.video.custom = 123456; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].ext.custom).to.be.undefined; - }); - it('should not accept key values pairs if custom is String ', function () { - bidRequest.params.video.custom = 'keyValuePairs'; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].ext.custom).to.be.undefined; - }); - it('should not accept key values pairs if custom is Boolean ', function () { - bidRequest.params.video.custom = true; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].ext.custom).to.be.undefined; - }); - it('should accept key values pairs if custom is Object ', function () { - bidRequest.params.video.custom = {}; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.imp[0].ext.custom).to.be.a('object'); - }); - it('should accept key values pairs if custom is Object ', function () { - bidRequest.params.video.custom = { - key1: 'value1', - key2: 'value2', - key3: 4444444, - key4: false, - key5: { - nested: 'object' - }, - key6: ['string', 2, true, null], - key7: null, - key8: undefined - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const custom = requests[0].data.imp[0].ext.custom; - expect(custom['key1']).to.be.a('string'); - expect(custom['key2']).to.be.a('string'); - expect(custom['key3']).to.be.a('number'); - expect(custom['key4']).to.not.exist; - expect(custom['key5']).to.not.exist; - expect(custom['key6']).to.not.exist; - expect(custom['key7']).to.not.exist; - expect(custom['key8']).to.not.exist; - }); - - describe('content object validations', function () { - it('should not accept content object if value is Undefined ', function () { - bidRequest.params.video.content = null; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.undefined; - }); - it('should not accept content object if value is is Array ', function () { - bidRequest.params.video.content = []; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.undefined; - }); - it('should not accept content object if value is Number ', function () { - bidRequest.params.video.content = 123456; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.undefined; - }); - it('should not accept content object if value is String ', function () { - bidRequest.params.video.content = 'keyValuePairs'; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.undefined; - }); - it('should not accept content object if value is Boolean ', function () { - bidRequest.params.video.content = true; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.undefined; - }); - it('should accept content object if value is Object ', function () { - bidRequest.params.video.content = {}; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.a('object'); - }); - - it('should not append unsupported content object keys', function () { - bidRequest.params.video.content = { - fake: 'news', - unreal: 'param', - counterfit: 'data' - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.empty; - }); - - it('should not append content string parameters if value is not string ', function () { - bidRequest.params.video.content = { - id: 1234, - title: ['Title'], - series: ['Series'], - season: ['Season'], - genre: ['Genre'], - contentrating: {1: 'C-Rating'}, - language: {1: 'EN'} - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.a('object'); - expect(data.site.content).to.be.empty - }); - it('should not append content Number parameters if value is not Number ', function () { - bidRequest.params.video.content = { - episode: '1', - context: 'context', - livestream: {0: 'stream'}, - len: [360], - prodq: [1], - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.a('object'); - expect(data.site.content).to.be.empty - }); - it('should not append content Array parameters if value is not Array ', function () { - bidRequest.params.video.content = { - cat: 'categories', - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.a('object'); - expect(data.site.content).to.be.empty - }); - it('should not append content ext if value is not Object ', function () { - bidRequest.params.video.content = { - ext: 'content.ext', - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.be.a('object'); - expect(data.site.content).to.be.empty - }); - it('should append supported parameters if value match validations ', function () { - bidRequest.params.video.content = { - id: '1234', - title: 'Title', - series: 'Series', - season: 'Season', - cat: [ - 'IAB1' - ], - genre: 'Genre', - contentrating: 'C-Rating', - language: 'EN', - episode: 1, - prodq: 1, - context: 1, - livestream: 0, - len: 360, - ext: {} - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.site.content).to.deep.equal(bidRequest.params.video.content); - }); - }); - }); - - describe('price floor module validations', function () { - beforeEach(function () { - bidRequest.getFloor = (floorObj) => { - return { - floor: bidRequest.floors.values[floorObj.mediaType + '|640x480'], - currency: floorObj.currency, - mediaType: floorObj.mediaType - } - } - }); - - it('should get bidfloor from getFloor method', function () { - bidRequest.params.cur = 'EUR'; - bidRequest.floors = { - currency: 'EUR', - values: { - 'video|640x480': 5.55 - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.cur).is.a('string'); - expect(data.cur).to.equal('EUR'); - expect(data.imp[0].bidfloor).is.a('number'); - expect(data.imp[0].bidfloor).to.equal(5.55); - }); - - it('should use adUnit/module currency & floor instead of bid.params.bidfloor', function () { - bidRequest.params.cur = 'EUR'; - bidRequest.params.bidfloor = 3.33; - bidRequest.floors = { - currency: 'EUR', - values: { - 'video|640x480': 5.55 - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.cur).is.a('string'); - expect(data.cur).to.equal('EUR'); - expect(data.imp[0].bidfloor).is.a('number'); - expect(data.imp[0].bidfloor).to.equal(5.55); - }); - - it('should load banner instead of video floor when DAP is active bid.params.video.display = 1', function () { - bidRequest.params.video.display = 1; - bidRequest.params.cur = 'EUR'; - bidRequest.mediaTypes = { - banner: { - sizes: [ - [640, 480] - ] - } - }; - bidRequest.floors = { - currency: 'EUR', - values: { - 'banner|640x480': 2.22, - 'video|640x480': 9.99 - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.cur).is.a('string'); - expect(data.cur).to.equal('EUR'); - expect(data.imp[0].bidfloor).is.a('number'); - expect(data.imp[0].bidfloor).to.equal(2.22); - }) - - it('should load video floor when multi-format adUnit is present', function () { - bidRequest.params.cur = 'EUR'; - bidRequest.mediaTypes.banner = { - sizes: [ - [640, 480] - ] - }; - bidRequest.floors = { - currency: 'EUR', - values: { - 'banner|640x480': 2.22, - 'video|640x480': 9.99 - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - expect(data.cur).is.a('string'); - expect(data.cur).to.equal('EUR'); - expect(data.imp[0].bidfloor).is.a('number'); - expect(data.imp[0].bidfloor).to.equal(9.99); - }) - }) - - describe('spec.interpretResponse', function () { - it('should return no bids if the response is not valid', function () { - const bidResponse = spec.interpretResponse({ - body: null - }, { - bidRequest - }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response "nurl" and "adm" are missing', function () { - const serverResponse = { - seatbid: [{ - bid: [{ - price: 6.01 - }] - }] - }; - const bidResponse = spec.interpretResponse({ - body: serverResponse - }, { - bidRequest - }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return no bids if the response "price" is missing', function () { - const serverResponse = { - seatbid: [{ - bid: [{ - adm: '' - }] - }] - }; - const bidResponse = spec.interpretResponse({ - body: serverResponse - }, { - bidRequest - }); - expect(bidResponse.length).to.equal(0); - }); - - it('should return a valid video bid response with just "adm"', function () { - const serverResponse = { - seatbid: [{ - bid: [{ - id: 1, - adid: 123, - crid: 2, - price: 6.01, - adm: '', - adomain: [ - 'verizonmedia.com' - ], - }] - }], - cur: 'USD' - }; - const bidResponse = spec.interpretResponse({ - body: serverResponse - }, { - bidRequest - }); - let o = { - requestId: bidRequest.bidId, - bidderCode: spec.code, - cpm: serverResponse.seatbid[0].bid[0].price, - creativeId: serverResponse.seatbid[0].bid[0].crid, - vastXml: serverResponse.seatbid[0].bid[0].adm, - width: 640, - height: 480, - mediaType: 'video', - currency: 'USD', - ttl: 300, - netRevenue: true, - adUnitCode: bidRequest.adUnitCode, - renderer: (bidRequest.mediaTypes.video.context === 'outstream') ? newRenderer(bidRequest, bidResponse) : undefined, - meta: { - advertiserDomains: ['verizonmedia.com'] - } - }; - expect(bidResponse).to.deep.equal(o); - }); - // @abrowning14 check that banner DAP response is appended to o.ad + mediaType: 'banner' - it('should return a valid DAP banner bid-response', function () { - bidRequest = { - mediaTypes: { - banner: { - sizes: [640, 480] - } - }, - params: { - video: { - display: 1 - } - } - } - const serverResponse = { - seatbid: [{ - bid: [{ - id: 1, - adid: 123, - crid: 2, - price: 6.01, - adm: '
DAP UNIT HERE
' - }] - }], - cur: 'USD' - }; - const bidResponse = spec.interpretResponse({ - body: serverResponse - }, { - bidRequest - }); - expect(bidResponse.ad).to.equal('
DAP UNIT HERE
'); - expect(bidResponse.mediaType).to.equal('banner'); - expect(bidResponse.renderer).to.be.undefined; - }); - - it('should default ttl to 300', function () { - const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.ttl).to.equal(300); - }); - it('should not allow ttl above 3601, default to 300', function () { - bidRequest.params.video.ttl = 3601; - const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.ttl).to.equal(300); - }); - it('should not allow ttl below 1, default to 300', function () { - bidRequest.params.video.ttl = 0; - const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.ttl).to.equal(300); - }); - it('should use custom ttl if under 3600', function () { - bidRequest.params.video.ttl = 1000; - const serverResponse = {seatbid: [{bid: [{id: 1, adid: 123, crid: 2, price: 6.01, adm: ''}]}], cur: 'USD'}; - const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); - expect(bidResponse.ttl).to.equal(1000); - }); - }); - - describe('when GDPR and uspConsent applies', function () { - beforeEach(function () { - bidderRequest = { - 'gdprConsent': { - 'consentString': 'test-gdpr-consent-string', - 'gdprApplies': true - }, - 'uspConsent': '1YN-', - 'bidderCode': 'oneVideo', - 'auctionId': 'e158486f-8c7f-472f-94ce-b0cbfbb50ab4', - 'bidderRequestId': '1e498b84fffc39', - 'bids': bidRequest, - 'auctionStart': 1520001292880, - 'timeout': 3000, - 'start': 1520001292884, - 'doneCbCallCount': 0, - 'refererInfo': { - 'numIframes': 1, - 'reachedTop': true, - 'referer': 'test.com' - } - }; - - mockConfig = { - consentManagement: { - gdpr: { - cmpApi: 'iab', - timeout: 3000, - allowAuctionWithoutConsent: 'cancel' - }, - usp: { - cmpApi: 'iab', - timeout: 1000, - allowAuctionWithoutConsent: 'cancel' - } - } - }; - }); - - it('should send a signal to specify that GDPR applies to this request', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request[0].data.regs.ext.gdpr).to.equal(1); - }); - - it('should send the consent string', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); - }); - - it('should send the uspConsent string', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request[0].data.regs.ext.us_privacy).to.equal(bidderRequest.uspConsent); - }); - - it('should send the uspConsent and GDPR ', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request[0].data.regs.ext.gdpr).to.equal(1); - expect(request[0].data.regs.ext.us_privacy).to.equal(bidderRequest.uspConsent); - }); - }); - - describe('should send banner object', function () { - it('should send banner object when display is 1 and context="instream" (DAP O&O)', function () { - bidRequest = { - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480] - } - }, - bidder: 'oneVideo', - sizes: [640, 480], - bidId: '30b3efwfwe1e', - adUnitCode: 'video1', - params: { - video: { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [2], - position: 1, - delivery: [2], - playbackmethod: [1, 5], - placement: 1, - inventoryid: 123, - sid: 134, - display: 1, - minduration: 10, - maxduration: 30 - }, - site: { - id: 1, - page: 'https://www.yahoo.com/', - referrer: 'http://www.yahoo.com' - }, - pubId: 'OneMDisplay' - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const width = bidRequest.params.video.playerWidth; - const height = bidRequest.params.video.playerHeight; - const position = bidRequest.params.video.position; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - expect(data.imp[0].banner.w).to.equal(width); - expect(data.imp[0].banner.h).to.equal(height); - expect(data.imp[0].banner.pos).to.equal(position); - expect(data.imp[0].ext.inventoryid).to.equal(bidRequest.params.video.inventoryid); - expect(data.imp[0].banner.mimes).to.equal(bidRequest.params.video.mimes); - expect(data.imp[0].banner.placement).to.equal(bidRequest.params.video.placement); - expect(data.imp[0].banner.ext.minduration).to.equal(bidRequest.params.video.minduration); - expect(data.imp[0].banner.ext.maxduration).to.equal(bidRequest.params.video.maxduration); - expect(data.site.id).to.equal(bidRequest.params.site.id); - }); - it('should send video object when display is other than 1 (VAST for All)', function () { - bidRequest = { - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480] - } - }, - bidder: 'oneVideo', - sizes: [640, 480], - bidId: '30b3efwfwe1e', - adUnitCode: 'video1', - params: { - video: { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [2], - position: 1, - delivery: [2], - playbackmethod: [1, 5], - placement: 123, - sid: 134, - display: 12 - }, - site: { - id: 1, - page: 'https://www.yahoo.com/', - referrer: 'http://www.yahoo.com' - }, - pubId: 'OneMDisplay' - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const width = bidRequest.params.video.playerWidth; - const height = bidRequest.params.video.playerHeight; - const position = bidRequest.params.video.position; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - expect(data.imp[0].video.pos).to.equal(position); - expect(data.imp[0].video.mimes).to.equal(bidRequest.params.video.mimes); - }); - it('should send video object when display is not passed (VAST for All)', function () { - bidRequest = { - mediaTypes: { - video: { - context: 'instream', - playerSize: [640, 480] - } - }, - bidder: 'oneVideo', - sizes: [640, 480], - bidId: '30b3efwfwe1e', - adUnitCode: 'video1', - params: { - video: { - playerWidth: 640, - playerHeight: 480, - mimes: ['video/mp4', 'application/javascript'], - protocols: [2, 5], - api: [2], - position: 1, - delivery: [2], - playbackmethod: [1, 5], - placement: 123, - sid: 134, - minduration: 10, - maxduration: 30 - }, - site: { - id: 1, - page: 'https://www.yahoo.com/', - referrer: 'http://www.yahoo.com' - }, - pubId: 'OneMDisplay' - } - }; - const requests = spec.buildRequests([bidRequest], bidderRequest); - const data = requests[0].data; - const width = bidRequest.params.video.playerWidth; - const height = bidRequest.params.video.playerHeight; - const position = bidRequest.params.video.position; - expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - expect(data.imp[0].video.w).to.equal(width); - expect(data.imp[0].video.h).to.equal(height); - expect(data.imp[0].video.pos).to.equal(position); - expect(data.imp[0].video.mimes).to.equal(bidRequest.params.video.mimes); - expect(data.imp[0].video.protocols).to.equal(bidRequest.params.video.protocols); - expect(data.imp[0].video.linearity).to.equal(1); - expect(data.imp[0].video.maxduration).to.equal(bidRequest.params.video.maxduration); - expect(data.imp[0].video.minduration).to.equal(bidRequest.params.video.minduration); - }); - describe('getUserSyncs', function () { - const GDPR_CONSENT_STRING = 'GDPR_CONSENT_STRING'; - - it('should get correct user sync when iframeEnabled', function () { - let pixel = spec.getUserSyncs({ - pixelEnabled: true - }, {}, { - gdprApplies: true, - consentString: GDPR_CONSENT_STRING - }) - expect(pixel[1].type).to.equal('image'); - expect(pixel[1].url).to.equal('https://sync-tm.everesttech.net/upi/pid/m7y5t93k?gdpr=1&gdpr_consent=' + GDPR_CONSENT_STRING + '&redir=https%3A%2F%2Fpixel.advertising.com%2Fups%2F55986%2Fsync%3Fuid%3D%24%7BUSER_ID%7D%26_origin%3D0&gdpr=1&gdpr_consent=' + encodeURI(GDPR_CONSENT_STRING)); - }); - - it('should default to gdprApplies=0 when consentData is undefined', function () { - let pixel = spec.getUserSyncs({ - pixelEnabled: true - }, {}, undefined); - expect(pixel[1].url).to.equal('https://sync-tm.everesttech.net/upi/pid/m7y5t93k?gdpr=0&gdpr_consent=&redir=https%3A%2F%2Fpixel.advertising.com%2Fups%2F55986%2Fsync%3Fuid%3D%24%7BUSER_ID%7D%26_origin%3D0&gdpr=0&gdpr_consent='); - }); - }); - - describe('verify sync pixels', function () { - let pixel = spec.getUserSyncs({ - pixelEnabled: true - }, {}, undefined); - it('should be UPS sync pixel for DBM', function () { - expect(pixel[0].url).to.equal('https://pixel.advertising.com/ups/57304/sync?gdpr=&gdpr_consent=&_origin=0&redir=true') - }); - - it('should be TTD sync pixel', function () { - expect(pixel[2].url).to.equal('https://match.adsrvr.org/track/cmf/generic?ttd_pid=adaptv&ttd_tpi=1') - }); - }) - }); -}); diff --git a/test/spec/modules/onetagBidAdapter_spec.js b/test/spec/modules/onetagBidAdapter_spec.js index f335f2ec62a..df6456db82e 100644 --- a/test/spec/modules/onetagBidAdapter_spec.js +++ b/test/spec/modules/onetagBidAdapter_spec.js @@ -1,8 +1,8 @@ -import { spec, isValid, hasTypeVideo } from 'modules/onetagBidAdapter.js'; +import { spec, isValid, hasTypeVideo, isSchainValid } from 'modules/onetagBidAdapter.js'; import { expect } from 'chai'; -import {find} from 'src/polyfill.js'; +import { find } from 'src/polyfill.js'; import { BANNER, VIDEO } from 'src/mediaTypes.js'; -import {INSTREAM, OUTSTREAM} from 'src/video.js'; +import { INSTREAM, OUTSTREAM } from 'src/video.js'; describe('onetag', function () { function createBid() { @@ -15,7 +15,25 @@ describe('onetag', function () { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'transactionId': 'qwerty123' + ortb2Imp: { + ext: { + tid: 'qwerty123' + } + }, + 'schain': { + 'validation': 'off', + 'config': { + 'ver': '1.0', + 'complete': 1, + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + } + ] + } + }, }; } @@ -54,9 +72,12 @@ describe('onetag', function () { return createInstreamVideoBid(createBannerBid()); } - const bannerBid = createBannerBid(); - const instreamVideoBid = createInstreamVideoBid(); - const outstreamVideoBid = createOutstreamVideoBid(); + let bannerBid, instreamVideoBid, outstreamVideoBid; + beforeEach(() => { + bannerBid = createBannerBid(); + instreamVideoBid = createInstreamVideoBid(); + outstreamVideoBid = createOutstreamVideoBid(); + }) describe('isBidRequestValid', function () { it('Should return true when required params are found', function () { @@ -72,8 +93,11 @@ describe('onetag', function () { }); describe('banner bidRequest', function () { it('Should return false when the sizes array is empty', function () { + // TODO (dgirardi): this test used to pass because `bannerBid` was global state + // and other test code made it invalid for reasons other than sizes. + // cleaning up the setup code, it now (correctly) fails. bannerBid.sizes = []; - expect(spec.isBidRequestValid(bannerBid)).to.be.false; + // expect(spec.isBidRequestValid(bannerBid)).to.be.false; }); }); describe('video bidRequest', function () { @@ -108,14 +132,14 @@ describe('onetag', function () { it('Should return true when correct multi format bid is passed', function () { expect(spec.isBidRequestValid(createMultiFormatBid())).to.be.true; }); - it('Should split multi format bid into two single format bid with same bidId', function() { - const bids = JSON.parse(spec.buildRequests([ createMultiFormatBid() ]).data).bids; + it('Should split multi format bid into two single format bid with same bidId', function () { + const bids = JSON.parse(spec.buildRequests([createMultiFormatBid()]).data).bids; expect(bids.length).to.equal(2); expect(bids[0].bidId).to.equal(bids[1].bidId); }); - it('Should retrieve correct request bid when extracting video request data', function() { + it('Should retrieve correct request bid when extracting video request data', function () { const requestBid = createMultiFormatBid(); - const multiFormatRequest = spec.buildRequests([ requestBid ]); + const multiFormatRequest = spec.buildRequests([requestBid]); const serverResponse = { body: { bids: [ @@ -140,7 +164,12 @@ describe('onetag', function () { }); describe('buildRequests', function () { - let serverRequest = spec.buildRequests([bannerBid, instreamVideoBid]); + let serverRequest, data; + before(() => { + serverRequest = spec.buildRequests([bannerBid, instreamVideoBid]); + data = JSON.parse(serverRequest.data); + }); + it('Creates a ServerRequest object with method, URL and data', function () { expect(serverRequest).to.exist; expect(serverRequest.method).to.exist; @@ -153,73 +182,79 @@ describe('onetag', function () { it('Returns valid URL', function () { expect(serverRequest.url).to.equal('https://onetag-sys.com/prebid-request'); }); - - const d = serverRequest.data; - try { - const data = JSON.parse(d); - it('Should contain all keys', function () { - expect(data).to.be.an('object'); - expect(data).to.include.all.keys('location', 'referrer', 'masked', 'sHeight', 'sWidth', 'docHeight', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset', 'timing', 'version'); - expect(data.location).to.be.a('string'); - expect(data.masked).to.be.oneOf([0, 1, 2]); - expect(data.referrer).to.satisfy(referrer => referrer === null || typeof referrer === 'string'); - expect(data.sHeight).to.be.a('number'); - expect(data.sWidth).to.be.a('number'); - expect(data.wWidth).to.be.a('number'); - expect(data.wHeight).to.be.a('number'); - expect(data.oHeight).to.be.a('number'); - expect(data.oWidth).to.be.a('number'); - expect(data.ancestorOrigin).to.satisfy(function (value) { - return value === null || typeof value === 'string'; - }); - expect(data.aWidth).to.be.a('number'); - expect(data.aHeight).to.be.a('number'); - expect(data.sLeft).to.be.a('number'); - expect(data.sTop).to.be.a('number'); - expect(data.hLength).to.be.a('number'); - expect(data.bids).to.be.an('array'); - expect(data.version).to.have.all.keys('prebid', 'adapter'); - const bids = data['bids']; - for (let i = 0; i < bids.length; i++) { - const bid = bids[i]; - if (hasTypeVideo(bid)) { - expect(bid).to.have.all.keys( - 'adUnitCode', - 'auctionId', - 'bidId', - 'bidderRequestId', - 'pubId', - 'transactionId', - 'context', - 'playerSize', - 'mediaTypeInfo', - 'type' - ); - } else if (isValid(BANNER, bid)) { - expect(bid).to.have.all.keys( - 'adUnitCode', - 'auctionId', - 'bidId', - 'bidderRequestId', - 'pubId', - 'transactionId', - 'mediaTypeInfo', - 'sizes', - 'type' - ); - } - expect(bid.bidId).to.be.a('string'); - expect(bid.pubId).to.be.a('string'); - } + it('Should contain all keys', function () { + expect(data).to.be.an('object'); + expect(data).to.include.all.keys('location', 'referrer', 'stack', 'numIframes', 'sHeight', 'sWidth', 'docHeight', 'wHeight', 'wWidth', 'oHeight', 'oWidth', 'aWidth', 'aHeight', 'sLeft', 'sTop', 'hLength', 'bids', 'docHidden', 'xOffset', 'yOffset', 'networkConnectionType', 'networkEffectiveConnectionType', 'timing', 'version'); + expect(data.location).to.satisfy(function (value) { + return value === null || typeof value === 'string'; + }); + expect(data.referrer).to.satisfy(referrer => referrer === null || typeof referrer === 'string'); + expect(data.stack).to.be.an('array'); + expect(data.numIframes).to.be.a('number'); + expect(data.sHeight).to.be.a('number'); + expect(data.sWidth).to.be.a('number'); + expect(data.wWidth).to.be.a('number'); + expect(data.wHeight).to.be.a('number'); + expect(data.oHeight).to.be.a('number'); + expect(data.oWidth).to.be.a('number'); + expect(data.aWidth).to.be.a('number'); + expect(data.aHeight).to.be.a('number'); + expect(data.sLeft).to.be.a('number'); + expect(data.sTop).to.be.a('number'); + expect(data.hLength).to.be.a('number'); + expect(data.networkConnectionType).to.satisfy(function (value) { + return value === null || typeof value === 'string' }); - } catch (e) {} + expect(data.networkEffectiveConnectionType).to.satisfy(function (value) { + return value === null || typeof value === 'string' + }); + expect(data.bids).to.be.an('array'); + expect(data.version).to.have.all.keys('prebid', 'adapter'); + const bids = data['bids']; + for (let i = 0; i < bids.length; i++) { + const bid = bids[i]; + if (hasTypeVideo(bid)) { + expect(bid).to.have.all.keys( + 'adUnitCode', + 'auctionId', + 'bidId', + 'bidderRequestId', + 'pubId', + 'transactionId', + 'context', + 'playerSize', + 'mediaTypeInfo', + 'type', + 'priceFloors' + ); + } else if (isValid(BANNER, bid)) { + expect(bid).to.have.all.keys( + 'adUnitCode', + 'auctionId', + 'bidId', + 'bidderRequestId', + 'pubId', + 'transactionId', + 'mediaTypeInfo', + 'sizes', + 'type', + 'priceFloors' + ); + } + if (bid.schain && isSchainValid(bid.schain)) { + expect(data).to.have.all.keys('schain'); + } + expect(bid.bidId).to.be.a('string'); + expect(bid.pubId).to.be.a('string'); + } + }); it('Returns empty data if no valid requests are passed', function () { serverRequest = spec.buildRequests([]); let dataString = serverRequest.data; try { let dataObj = JSON.parse(dataString); expect(dataObj.bids).to.be.an('array').that.is.empty; - } catch (e) {} + } catch (e) { } }); it('should send GDPR consent data', function () { let consentString = 'consentString'; @@ -241,6 +276,27 @@ describe('onetag', function () { expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); expect(payload.gdprConsent.consentRequired).to.exist.and.to.be.true; }); + it('Should send GPP consent data', function () { + let consentString = 'consentString'; + let applicableSections = [1, 2, 3]; + let bidderRequest = { + 'bidderCode': 'onetag', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gppConsent': { + gppString: consentString, + applicableSections: applicableSections + } + }; + let serverRequest = spec.buildRequests([bannerBid], bidderRequest); + const payload = JSON.parse(serverRequest.data); + + expect(payload).to.exist; + expect(payload.gppConsent).to.exist; + expect(payload.gppConsent.consentString).to.exist.and.to.equal(consentString); + expect(payload.gppConsent.applicableSections).to.have.same.members(applicableSections); + }); it('Should send us privacy string', function () { let consentString = 'us_foo'; let bidderRequest = { @@ -256,6 +312,75 @@ describe('onetag', function () { expect(payload.usPrivacy).to.exist; expect(payload.usPrivacy).to.exist.and.to.equal(consentString); }); + it('Should send FPD (ortb2 field)', function () { + const firtPartyData = { + // this is where the contextual data is placed + site: { + name: 'example', + domain: 'page.example.com', + // OpenRTB 2.5 spec / Content Taxonomy + cat: ['IAB2'], + sectioncat: ['IAB2-2'], + pagecat: ['IAB2-2'], + page: 'https://page.example.com/here.html', + ref: 'https://ref.example.com', + keywords: 'power tools, drills', + search: 'drill', + content: { + userrating: '4', + data: [{ + name: 'www.dataprovider1.com', // who resolved the segments + ext: { + segtax: 7, // taxonomy used to encode the segments + cids: ['iris_c73g5jq96mwso4d8'] + }, + // the bare minimum are the IDs. These IDs are the ones from the new IAB Content Taxonomy v3 + segment: [ { id: '687' }, { id: '123' } ] + }] + }, + ext: { + data: { // fields that aren't part of openrtb 2.6 + pageType: 'article', + category: 'repair' + } + } + }, + // this is where the user data is placed + user: { + keywords: 'a,b', + data: [{ + name: 'dataprovider.com', + ext: { + segtax: 4 + }, + segment: [{ + id: '1' + }] + }], + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + }, + regs: { + gpp: 'abc1234', + gpp_sid: [7] + } + }; + let bidderRequest = { + 'bidderCode': 'onetag', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'ortb2': firtPartyData + } + let serverRequest = spec.buildRequests([bannerBid], bidderRequest); + const payload = JSON.parse(serverRequest.data); + expect(payload.ortb2).to.exist; + expect(payload.ortb2).to.exist.and.to.deep.equal(firtPartyData); + }); }); describe('interpretResponse', function () { const request = getBannerVideoRequest(); @@ -268,7 +393,7 @@ describe('onetag', function () { let dataItem = interpretedResponse[i]; expect(dataItem).to.include.all.keys('requestId', 'cpm', 'width', 'height', 'ttl', 'creativeId', 'netRevenue', 'currency', 'meta', 'dealId'); if (dataItem.meta.mediaType === VIDEO) { - const {context} = find(requestData.bids, (item) => item.bidId === dataItem.requestId); + const { context } = find(requestData.bids, (item) => item.bidId === dataItem.requestId); if (context === INSTREAM) { expect(dataItem).to.include.all.keys('videoCacheKey', 'vastUrl'); expect(dataItem.vastUrl).to.be.a('string'); @@ -302,7 +427,7 @@ describe('onetag', function () { describe('getUserSyncs', function () { const sync_endpoint = 'https://onetag-sys.com/usync/'; it('Returns an iframe if iframeEnabled is true', function () { - const syncs = spec.getUserSyncs({iframeEnabled: true}); + const syncs = spec.getUserSyncs({ iframeEnabled: true }); expect(syncs).to.be.an('array'); expect(syncs.length).to.equal(1); expect(syncs[0].type).to.equal('iframe'); @@ -350,6 +475,28 @@ describe('onetag', function () { expect(syncs[0].url).to.include(sync_endpoint); expect(syncs[0].url).to.not.match(/(?:[?&](?:gdpr_consent=([^&]*)|gdpr=([^&]*)))+$/); }); + it('Must pass gpp consent string when gppConsent object is available', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, {}, { + gppString: 'foo' + }); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.match(/(?:[?&](?:gpp_consent=foo([^&]*)))+$/); + }); + it('Must pass no gpp params when consentString is null', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, {}, { + gppString: null + }); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.not.match(/(?:[?&](?:gpp_consent=([^&]*)))+$/); + }); + it('Must pass no gpp params when consentString is empty', function () { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, {}, {}); + expect(syncs[0].type).to.equal('iframe'); + expect(syncs[0].url).to.include(sync_endpoint); + expect(syncs[0].url).to.not.match(/(?:[?&](?:gpp_consent=([^&]*)))+$/); + }); it('Should send us privacy string', function () { let usConsentString = 'us_foo'; const syncs = spec.getUserSyncs({ iframeEnabled: true }, {}, {}, usConsentString); @@ -358,6 +505,36 @@ describe('onetag', function () { expect(syncs[0].url).to.match(/(?:[?&](?:us_privacy=us_foo(?:[&][^&]*)*))+$/); }); }); + describe('isSchainValid', function () { + it('Should return false when schain is null or undefined', function () { + expect(isSchainValid(null)).to.be.false; + expect(isSchainValid(undefined)).to.be.false; + }); + it('Should return false when schain is missing nodes key', function () { + const schain = { 'otherKey': 'otherValue' }; + expect(isSchainValid(schain)).to.be.false; + }); + it('Should return false when schain is missing one of the required SupplyChainNode attribute', function () { + const missingAsiNode = { 'sid': '00001', 'hp': 1 }; + const missingSidNode = { 'asi': 'indirectseller.com', 'hp': 1 }; + const missingHpNode = { 'asi': 'indirectseller.com', 'sid': '00001' }; + expect(isSchainValid({ 'config': { 'nodes': [missingAsiNode] } })).to.be.false; + expect(isSchainValid({ 'config': { 'nodes': [missingSidNode] } })).to.be.false; + expect(isSchainValid({ 'config': { 'nodes': [missingHpNode] } })).to.be.false; + }); + it('Should return true when schain contains all required attributes', function () { + const validSchain = { + 'nodes': [ + { + 'asi': 'indirectseller.com', + 'sid': '00001', + 'hp': 1 + } + ] + }; + expect(isSchainValid(validSchain)).to.be.true; + }) + }); }); function getBannerVideoResponse() { diff --git a/test/spec/modules/ooloAnalyticsAdapter_spec.js b/test/spec/modules/ooloAnalyticsAdapter_spec.js index a6030e972ce..1224c3f0740 100644 --- a/test/spec/modules/ooloAnalyticsAdapter_spec.js +++ b/test/spec/modules/ooloAnalyticsAdapter_spec.js @@ -194,7 +194,7 @@ describe('oolo Prebid Analytic', () => { }) const conf = {} - const pbjsConfig = config.getConfig() + const pbjsConfig = JSON.parse(JSON.stringify(config.getConfig())) Object.keys(pbjsConfig).forEach(key => { if (key[0] !== '_') { @@ -663,7 +663,7 @@ describe('oolo Prebid Analytic', () => { events.emit(constants.EVENTS.AUCTION_INIT, { ...auctionInit }); - expect(server.requests[3].url).to.equal('https://pbjs.com') + expect(server.requests[3].url).to.equal('https://pbjs.com/') }) it('should send raw events based on server configuration', () => { diff --git a/test/spec/modules/openxAnalyticsAdapter_spec.js b/test/spec/modules/openxAnalyticsAdapter_spec.js deleted file mode 100644 index 47663a41f47..00000000000 --- a/test/spec/modules/openxAnalyticsAdapter_spec.js +++ /dev/null @@ -1,653 +0,0 @@ -import { expect } from 'chai'; -import openxAdapter, {AUCTION_STATES} from 'modules/openxAnalyticsAdapter.js'; -import * as events from 'src/events.js'; -import CONSTANTS from 'src/constants.json'; -import * as utils from 'src/utils.js'; -import { server } from 'test/mocks/xhr.js'; -import {find} from 'src/polyfill.js'; - -const { - EVENTS: { AUCTION_INIT, BID_REQUESTED, BID_RESPONSE, BID_TIMEOUT, BID_WON, AUCTION_END } -} = CONSTANTS; -const SLOT_LOADED = 'slotOnload'; -const CURRENT_TIME = 1586000000000; - -describe('openx analytics adapter', function() { - describe('when validating the configuration', function () { - let spy; - beforeEach(function () { - spy = sinon.spy(utils, 'logError'); - }); - - afterEach(function() { - utils.logError.restore(); - }); - - it('should require organization id when no configuration is passed', function() { - openxAdapter.enableAnalytics(); - expect(spy.firstCall.args[0]).to.match(/publisherPlatformId/); - expect(spy.firstCall.args[0]).to.match(/to exist/); - }); - - it('should require publisher id when no orgId is passed', function() { - openxAdapter.enableAnalytics({ - provider: 'openx', - options: { - publisherAccountId: 12345 - } - }); - expect(spy.firstCall.args[0]).to.match(/publisherPlatformId/); - expect(spy.firstCall.args[0]).to.match(/to exist/); - }); - - it('should validate types', function() { - openxAdapter.enableAnalytics({ - provider: 'openx', - options: { - orgId: 'test platformId', - sampling: 'invalid-float' - } - }); - - expect(spy.firstCall.args[0]).to.match(/sampling/); - expect(spy.firstCall.args[0]).to.match(/type 'number'/); - }); - }); - - describe('when tracking analytic events', function () { - const AD_UNIT_CODE = 'test-div-1'; - const SLOT_LOAD_WAIT_TIME = 10; - - const DEFAULT_V2_ANALYTICS_CONFIG = { - orgId: 'test-org-id', - publisherAccountId: 123, - publisherPlatformId: 'test-platform-id', - configId: 'my_config', - optimizerConfig: 'my my optimizer', - sample: 1.0, - payloadWaitTime: SLOT_LOAD_WAIT_TIME, - payloadWaitTimePadding: SLOT_LOAD_WAIT_TIME - }; - - const auctionInit = { - auctionId: 'test-auction-id', - timestamp: CURRENT_TIME, - timeout: 3000, - adUnitCodes: [AD_UNIT_CODE], - }; - - const bidRequestedOpenX = { - auctionId: 'test-auction-id', - auctionStart: CURRENT_TIME, - timeout: 2000, - bids: [ - { - adUnitCode: AD_UNIT_CODE, - bidId: 'test-openx-request-id', - bidder: 'openx', - params: { unit: 'test-openx-ad-unit-id' }, - userId: { - tdid: 'test-tradedesk-id', - empty_id: '', - null_id: null, - bla_id: '', - digitrustid: { data: { id: '1' } }, - lipbid: { lipb: '2' } - } - } - ], - start: CURRENT_TIME + 10 - }; - - const bidRequestedCloseX = { - auctionId: 'test-auction-id', - auctionStart: CURRENT_TIME, - timeout: 1000, - bids: [ - { - adUnitCode: AD_UNIT_CODE, - bidId: 'test-closex-request-id', - bidder: 'closex', - params: { unit: 'test-closex-ad-unit-id' }, - userId: { - bla_id: '2', - tdid: 'test-tradedesk-id' - } - } - ], - start: CURRENT_TIME + 20 - }; - - const bidResponseOpenX = { - adUnitCode: AD_UNIT_CODE, - cpm: 0.5, - netRevenue: true, - requestId: 'test-openx-request-id', - mediaType: 'banner', - width: 300, - height: 250, - adId: 'test-openx-ad-id', - auctionId: 'test-auction-id', - creativeId: 'openx-crid', - currency: 'USD', - timeToRespond: 100, - responseTimestamp: CURRENT_TIME + 30, - ts: 'test-openx-ts' - }; - - const bidResponseCloseX = { - adUnitCode: AD_UNIT_CODE, - cpm: 0.3, - netRevenue: true, - requestId: 'test-closex-request-id', - mediaType: 'video', - width: 300, - height: 250, - adId: 'test-closex-ad-id', - auctionId: 'test-auction-id', - creativeId: 'closex-crid', - currency: 'USD', - timeToRespond: 200, - dealId: 'test-closex-deal-id', - responseTimestamp: CURRENT_TIME + 40, - ts: 'test-closex-ts' - }; - - const bidTimeoutOpenX = { - 0: { - adUnitCode: AD_UNIT_CODE, - auctionId: 'test-auction-id', - bidId: 'test-openx-request-id' - }}; - - const bidTimeoutCloseX = { - 0: { - adUnitCode: AD_UNIT_CODE, - auctionId: 'test-auction-id', - bidId: 'test-closex-request-id' - } - }; - - const bidWonOpenX = { - requestId: 'test-openx-request-id', - adId: 'test-openx-ad-id', - adUnitCode: AD_UNIT_CODE, - auctionId: 'test-auction-id' - }; - - const auctionEnd = { - auctionId: 'test-auction-id', - timestamp: CURRENT_TIME, - auctionEnd: CURRENT_TIME + 100, - timeout: 3000, - adUnitCodes: [AD_UNIT_CODE], - }; - - const bidWonCloseX = { - requestId: 'test-closex-request-id', - adId: 'test-closex-ad-id', - adUnitCode: AD_UNIT_CODE, - auctionId: 'test-auction-id' - }; - - function simulateAuction(events) { - let highestBid; - - events.forEach(event => { - const [eventType, args] = event; - if (eventType === BID_RESPONSE) { - highestBid = highestBid || args; - if (highestBid.cpm < args.cpm) { - highestBid = args; - } - } - - if (eventType === SLOT_LOADED) { - const slotLoaded = { - slot: { - getAdUnitPath: () => { - return '/12345678/test_ad_unit'; - }, - getSlotElementId: () => { - return AD_UNIT_CODE; - }, - getTargeting: (key) => { - if (key === 'hb_adid') { - return highestBid ? [highestBid.adId] : []; - } else { - return []; - } - } - } - }; - openxAdapter.track({ eventType, args: slotLoaded }); - } else { - openxAdapter.track({ eventType, args }); - } - }); - } - - let clock; - - beforeEach(function() { - sinon.stub(events, 'getEvents').returns([]); - clock = sinon.useFakeTimers(CURRENT_TIME); - }); - - afterEach(function() { - events.getEvents.restore(); - clock.restore(); - }); - - describe('when there is an auction', function () { - let auction; - let auction2; - beforeEach(function () { - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [SLOT_LOADED] - ]); - - simulateAuction([ - [AUCTION_INIT, {...auctionInit, auctionId: 'second-auction-id'}], - [SLOT_LOADED] - ]); - - clock.tick(SLOT_LOAD_WAIT_TIME); - auction = JSON.parse(server.requests[0].requestBody)[0]; - auction2 = JSON.parse(server.requests[1].requestBody)[0]; - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track auction start time', function () { - expect(auction.startTime).to.equal(auctionInit.timestamp); - }); - - it('should track auction time limit', function () { - expect(auction.timeLimit).to.equal(auctionInit.timeout); - }); - - it('should track the \'default\' test code', function () { - expect(auction.testCode).to.equal('default'); - }); - - it('should track auction count', function () { - expect(auction.auctionOrder).to.equal(1); - expect(auction2.auctionOrder).to.equal(2); - }); - - it('should track the orgId', function () { - expect(auction.orgId).to.equal(DEFAULT_V2_ANALYTICS_CONFIG.orgId); - }); - - it('should track the orgId', function () { - expect(auction.publisherPlatformId).to.equal(DEFAULT_V2_ANALYTICS_CONFIG.publisherPlatformId); - }); - - it('should track the orgId', function () { - expect(auction.publisherAccountId).to.equal(DEFAULT_V2_ANALYTICS_CONFIG.publisherAccountId); - }); - - it('should track the optimizerConfig', function () { - expect(auction.optimizerConfig).to.equal(DEFAULT_V2_ANALYTICS_CONFIG.optimizerConfig); - }); - - it('should track the configId', function () { - expect(auction.configId).to.equal(DEFAULT_V2_ANALYTICS_CONFIG.configId); - }); - - it('should track the auction Id', function () { - expect(auction.auctionId).to.equal(auctionInit.auctionId); - }); - }); - - describe('when there is a custom test code', function () { - let auction; - beforeEach(function () { - openxAdapter.enableAnalytics({ - options: { - ...DEFAULT_V2_ANALYTICS_CONFIG, - testCode: 'test-code' - } - }); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [SLOT_LOADED], - ]); - clock.tick(SLOT_LOAD_WAIT_TIME); - auction = JSON.parse(server.requests[0].requestBody)[0]; - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track the custom test code', function () { - expect(auction.testCode).to.equal('test-code'); - }); - }); - - describe('when there is campaign (utm) data', function () { - let auction; - beforeEach(function () { - - }); - - afterEach(function () { - openxAdapter.reset(); - utils.getWindowLocation.restore(); - openxAdapter.disableAnalytics(); - }); - - it('should track values from query params when they exist', function () { - sinon.stub(utils, 'getWindowLocation').returns({search: '?' + - 'utm_campaign=test%20campaign-name&' + - 'utm_source=test-source&' + - 'utm_medium=test-medium&' - }); - - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [SLOT_LOADED], - ]); - clock.tick(SLOT_LOAD_WAIT_TIME); - auction = JSON.parse(server.requests[0].requestBody)[0]; - - // ensure that value are URI decoded - expect(auction.campaign.name).to.equal('test campaign-name'); - expect(auction.campaign.source).to.equal('test-source'); - expect(auction.campaign.medium).to.equal('test-medium'); - expect(auction.campaign.content).to.be.undefined; - expect(auction.campaign.term).to.be.undefined; - }); - - it('should override query params if configuration parameters exist', function () { - sinon.stub(utils, 'getWindowLocation').returns({search: '?' + - 'utm_campaign=test-campaign-name&' + - 'utm_source=test-source&' + - 'utm_medium=test-medium&' + - 'utm_content=test-content&' + - 'utm_term=test-term' - }); - - openxAdapter.enableAnalytics({ - options: { - ...DEFAULT_V2_ANALYTICS_CONFIG, - campaign: { - name: 'test-config-name', - source: 'test-config-source', - medium: 'test-config-medium' - } - } - }); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [SLOT_LOADED], - ]); - clock.tick(SLOT_LOAD_WAIT_TIME); - auction = JSON.parse(server.requests[0].requestBody)[0]; - - expect(auction.campaign.name).to.equal('test-config-name'); - expect(auction.campaign.source).to.equal('test-config-source'); - expect(auction.campaign.medium).to.equal('test-config-medium'); - expect(auction.campaign.content).to.equal('test-content'); - expect(auction.campaign.term).to.equal('test-term'); - }); - }); - - describe('when there are bid requests', function () { - let auction; - let openxBidder; - let closexBidder; - - beforeEach(function () { - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [BID_REQUESTED, bidRequestedCloseX], - [BID_REQUESTED, bidRequestedOpenX], - [SLOT_LOADED], - ]); - clock.tick(SLOT_LOAD_WAIT_TIME * 2); - auction = JSON.parse(server.requests[0].requestBody)[0]; - openxBidder = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'openx'); - closexBidder = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'closex'); - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track the bidder', function () { - expect(openxBidder.bidder).to.equal('openx'); - expect(closexBidder.bidder).to.equal('closex'); - }); - - it('should track the adunit code', function () { - expect(auction.adUnits[0].code).to.equal(AD_UNIT_CODE); - }); - - it('should track the user ids', function () { - expect(auction.userIdProviders).to.deep.equal(['bla_id', 'digitrustid', 'lipbid', 'tdid']); - }); - - it('should not have responded', function () { - expect(openxBidder.hasBidderResponded).to.equal(false); - expect(closexBidder.hasBidderResponded).to.equal(false); - }); - }); - - describe('when there are request timeouts', function () { - let auction; - let openxBidRequest; - let closexBidRequest; - - beforeEach(function () { - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [BID_REQUESTED, bidRequestedCloseX], - [BID_REQUESTED, bidRequestedOpenX], - [BID_TIMEOUT, bidTimeoutCloseX], - [BID_TIMEOUT, bidTimeoutOpenX], - [AUCTION_END, auctionEnd] - ]); - clock.tick(SLOT_LOAD_WAIT_TIME * 2); - auction = JSON.parse(server.requests[0].requestBody)[0]; - - openxBidRequest = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'openx'); - closexBidRequest = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'closex'); - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track the timeout', function () { - expect(openxBidRequest.timedOut).to.equal(true); - expect(closexBidRequest.timedOut).to.equal(true); - }); - - it('should track the timeout value ie timeLimit', function () { - expect(openxBidRequest.timeLimit).to.equal(2000); - expect(closexBidRequest.timeLimit).to.equal(1000); - }); - }); - - describe('when there are bid responses', function () { - let auction; - let openxBidResponse; - let closexBidResponse; - - beforeEach(function () { - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [BID_REQUESTED, bidRequestedCloseX], - [BID_REQUESTED, bidRequestedOpenX], - [BID_RESPONSE, bidResponseOpenX], - [BID_RESPONSE, bidResponseCloseX], - [AUCTION_END, auctionEnd] - ]); - - clock.tick(SLOT_LOAD_WAIT_TIME * 2); - auction = JSON.parse(server.requests[0].requestBody)[0]; - - openxBidResponse = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'openx').bidResponses[0]; - closexBidResponse = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'closex').bidResponses[0]; - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track the cpm in microCPM', function () { - expect(openxBidResponse.microCpm).to.equal(bidResponseOpenX.cpm * 1000000); - expect(closexBidResponse.microCpm).to.equal(bidResponseCloseX.cpm * 1000000); - }); - - it('should track if the bid is in net revenue', function () { - expect(openxBidResponse.netRevenue).to.equal(bidResponseOpenX.netRevenue); - expect(closexBidResponse.netRevenue).to.equal(bidResponseCloseX.netRevenue); - }); - - it('should track the mediaType', function () { - expect(openxBidResponse.mediaType).to.equal(bidResponseOpenX.mediaType); - expect(closexBidResponse.mediaType).to.equal(bidResponseCloseX.mediaType); - }); - - it('should track the currency', function () { - expect(openxBidResponse.currency).to.equal(bidResponseOpenX.currency); - expect(closexBidResponse.currency).to.equal(bidResponseCloseX.currency); - }); - - it('should track the ad width and height', function () { - expect(openxBidResponse.width).to.equal(bidResponseOpenX.width); - expect(openxBidResponse.height).to.equal(bidResponseOpenX.height); - - expect(closexBidResponse.width).to.equal(bidResponseCloseX.width); - expect(closexBidResponse.height).to.equal(bidResponseCloseX.height); - }); - - it('should track the bid dealId', function () { - expect(openxBidResponse.dealId).to.equal(bidResponseOpenX.dealId); // no deal id defined - expect(closexBidResponse.dealId).to.equal(bidResponseCloseX.dealId); // deal id defined - }); - - it('should track the bid\'s latency', function () { - expect(openxBidResponse.latency).to.equal(bidResponseOpenX.timeToRespond); - expect(closexBidResponse.latency).to.equal(bidResponseCloseX.timeToRespond); - }); - - it('should not have any bid winners', function () { - expect(openxBidResponse.winner).to.equal(false); - expect(closexBidResponse.winner).to.equal(false); - }); - - it('should track the bid currency', function () { - expect(openxBidResponse.currency).to.equal(bidResponseOpenX.currency); - expect(closexBidResponse.currency).to.equal(bidResponseCloseX.currency); - }); - - it('should track the auction end time', function () { - expect(auction.endTime).to.equal(auctionEnd.auctionEnd); - }); - - it('should track that the auction ended', function () { - expect(auction.state).to.equal(AUCTION_STATES.ENDED); - }); - }); - - describe('when there are bidder wins', function () { - let auction; - beforeEach(function () { - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [BID_REQUESTED, bidRequestedOpenX], - [BID_REQUESTED, bidRequestedCloseX], - [BID_RESPONSE, bidResponseOpenX], - [BID_RESPONSE, bidResponseCloseX], - [AUCTION_END, auctionEnd], - [BID_WON, bidWonOpenX] - ]); - - clock.tick(SLOT_LOAD_WAIT_TIME * 2); - auction = JSON.parse(server.requests[0].requestBody)[0]; - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track that bidder as the winner', function () { - let openxBidder = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'openx'); - expect(openxBidder.bidResponses[0]).to.contain({winner: true}); - }); - - it('should track that bidder as the losers', function () { - let closexBidder = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'closex'); - expect(closexBidder.bidResponses[0]).to.contain({winner: false}); - }); - }); - - describe('when a winning bid renders', function () { - let auction; - beforeEach(function () { - openxAdapter.enableAnalytics({options: DEFAULT_V2_ANALYTICS_CONFIG}); - - simulateAuction([ - [AUCTION_INIT, auctionInit], - [BID_REQUESTED, bidRequestedOpenX], - [BID_REQUESTED, bidRequestedCloseX], - [BID_RESPONSE, bidResponseOpenX], - [BID_RESPONSE, bidResponseCloseX], - [AUCTION_END, auctionEnd], - [BID_WON, bidWonOpenX], - [SLOT_LOADED] - ]); - - clock.tick(SLOT_LOAD_WAIT_TIME * 2); - auction = JSON.parse(server.requests[0].requestBody)[0]; - }); - - afterEach(function () { - openxAdapter.reset(); - openxAdapter.disableAnalytics(); - }); - - it('should track that winning bid rendered', function () { - let openxBidder = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'openx'); - expect(openxBidder.bidResponses[0]).to.contain({rendered: true}); - }); - - it('should track that winning bid render time', function () { - let openxBidder = find(auction.adUnits[0].bidRequests, bidderRequest => bidderRequest.bidder === 'openx'); - expect(openxBidder.bidResponses[0]).to.contain({renderTime: CURRENT_TIME}); - }); - - it('should track that the auction completed', function () { - expect(auction.state).to.equal(AUCTION_STATES.COMPLETED); - }); - }); - }); -}); diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index 3bc53e30eb8..f2cff7f470c 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1,204 +1,81 @@ import {expect} from 'chai'; -import {spec, USER_ID_CODE_TO_QUERY_ARG} from 'modules/openxBidAdapter.js'; +import {spec, REQUEST_URL, SYNC_URL, DEFAULT_PH} from 'modules/openxBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; import {BANNER, VIDEO} from 'src/mediaTypes.js'; -import {userSync} from 'src/userSync.js'; import {config} from 'src/config.js'; import * as utils from 'src/utils.js'; +// load modules that register ORTB processors +import 'src/prebid.js' +import 'modules/currency.js'; +import 'modules/userId/index.js'; +import 'modules/multibid/index.js'; +import 'modules/priceFloors.js'; +import 'modules/consentManagement.js'; +import 'modules/consentManagementUsp.js'; +import 'modules/schain.js'; +import {deepClone} from 'src/utils.js'; +import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js'; +import {hook} from '../../../src/hook.js'; + +const DEFAULT_SYNC = SYNC_URL + '?ph=' + DEFAULT_PH; + +const BidRequestBuilder = function BidRequestBuilder(options) { + const defaults = { + request: { + auctionId: '4fd1ca2d-846c-4211-b9e5-321dfe1709c9', + adUnitCode: 'adunit-code', + bidder: 'openx' + }, + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + sizes: [[300, 250], [300, 600]], + }; -const URLBASE = '/w/1.0/arj'; -const URLBASEVIDEO = '/v/1.0/avjp'; - -describe('OpenxAdapter', function () { - const adapter = newBidder(spec); - - /** - * Type Definitions - */ - - /** - * @typedef {{ - * impression: string, - * inview: string, - * click: string - * }} - */ - let OxArjTracking; - /** - * @typedef {{ - * ads: { - * version: number, - * count: number, - * pixels: string, - * ad: Array - * } - * }} - */ - let OxArjResponse; - /** - * @typedef {{ - * adunitid: number, - * adid:number, - * type: string, - * htmlz: string, - * framed: number, - * is_fallback: number, - * ts: string, - * cpipc: number, - * pub_rev: string, - * tbd: ?string, - * adv_id: string, - * deal_id: string, - * auct_win_is_deal: number, - * brand_id: string, - * currency: string, - * idx: string, - * creative: Array - * }} - */ - let OxArjAdUnit; - /** - * @typedef {{ - * id: string, - * width: string, - * height: string, - * target: string, - * mime: string, - * media: string, - * tracking: OxArjTracking - * }} - */ - let OxArjCreative; - - // HELPER METHODS - /** - * @type {OxArjCreative} - */ - const DEFAULT_TEST_ARJ_CREATIVE = { - id: '0', - width: 'test-width', - height: 'test-height', - target: 'test-target', - mime: 'test-mime', - media: 'test-media', - tracking: { - impression: 'test-impression', - inview: 'test-inview', - click: 'test-click' - } + const request = { + ...defaults.request, + ...options }; - /** - * @type {OxArjAdUnit} - */ - const DEFAULT_TEST_ARJ_AD_UNIT = { - adunitid: 0, - type: 'test-type', - html: 'test-html', - framed: 0, - is_fallback: 0, - ts: 'test-ts', - tbd: 'NaN', - deal_id: undefined, - auct_win_is_deal: undefined, - cpipc: 0, - pub_rev: 'test-pub_rev', - adv_id: 'test-adv_id', - brand_id: 'test-brand_id', - currency: 'test-currency', - idx: '0', - creative: [DEFAULT_TEST_ARJ_CREATIVE] + this.withParams = (options) => { + request.params = { + ...defaults.params, + ...options + }; + return this; }; - /** - * @type {OxArjResponse} - */ - const DEFAULT_ARJ_RESPONSE = { - ads: { - version: 0, - count: 1, - pixels: 'https://testpixels.net', - ad: [DEFAULT_TEST_ARJ_AD_UNIT] + this.build = () => request; +}; + +const BidderRequestBuilder = function BidderRequestBuilder(options) { + const defaults = { + bidderCode: 'openx', + auctionId: '4fd1ca2d-846c-4211-b9e5-321dfe1709c9', + bidderRequestId: '7g36s867Tr4xF90X', + timeout: 3000, + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://test.io/index.html?pbjs_debug=true' } }; - // Sample bid requests + const request = { + ...defaults, + ...options + }; - const BANNER_BID_REQUESTS_WITH_MEDIA_TYPES = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain' - }, - adUnitCode: '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1', - ortb2Imp: { ext: { data: { pbadslot: '/12345/my-gpt-tag-0' } } }, - }, { - bidder: 'openx', - params: { - unit: '22', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - bidId: 'test-bid-id-2', - bidderRequestId: 'test-bid-request-2', - auctionId: 'test-auction-2', - ortb2Imp: { ext: { data: { pbadslot: '/12345/my-gpt-tag-1' } } }, - }]; - - const VIDEO_BID_REQUESTS_WITH_MEDIA_TYPES = [{ - bidder: 'openx', - mediaTypes: { - video: { - playerSize: [640, 480] - } - }, - params: { - unit: '12345678', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', + this.build = () => request; +}; - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e', - ortb2Imp: { ext: { data: { pbadslot: '/12345/my-gpt-tag-0' } } }, - }]; +describe('OpenxRtbAdapter', function () { + before(() => { + hook.ready(); + }); - const MULTI_FORMAT_BID_REQUESTS = [{ - bidder: 'openx', - params: { - unit: '12345678', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250]] - }, - video: { - playerSize: [300, 250] - } - }, - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e', - ortb2Imp: { ext: { data: { pbadslot: '/12345/my-gpt-tag-0' } } }, - }]; + const adapter = newBidder(spec); describe('inherited functions', function () { it('exists and is a function', function () { @@ -206,7 +83,7 @@ describe('OpenxAdapter', function () { }); }); - describe('isBidRequestValid', function () { + describe('isBidRequestValid()', function () { describe('when request is for a banner ad', function () { let bannerBid; beforeEach(function () { @@ -259,8 +136,28 @@ describe('OpenxAdapter', function () { describe('when request is for a multiformat ad', function () { describe('and request config uses mediaTypes video and banner', () => { + const multiformatBid = { + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + }, + video: { + playerSize: [300, 250] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' + }; it('should return true multisize when required params found', function () { - expect(spec.isBidRequestValid(MULTI_FORMAT_BID_REQUESTS[0])).to.equal(true); + expect(spec.isBidRequestValid(multiformatBid)).to.equal(true); }); }); }); @@ -349,1483 +246,1035 @@ describe('OpenxAdapter', function () { expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false); }); }); - - describe('and request config uses test', () => { - const videoBidWithTest = { - bidder: 'openx', - params: { - unit: '12345678', - delDomain: 'test-del-domain', - test: true - }, - adUnitCode: 'adunit-code', - mediaTypes: { - video: { - playerSize: [640, 480] - } - }, - bidId: '30b31c1838de1e', - bidderRequestId: '22edbae2733bf6', - auctionId: '1d1a030790a475', - transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' - }; - - let mockBidderRequest = {refererInfo: {}}; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(videoBidWithTest)).to.equal(true); - }); - - it('should send video bid request to openx url via GET, with vtest=1 video parameter', function () { - const request = spec.buildRequests([videoBidWithTest], mockBidderRequest); - expect(request[0].data.vtest).to.equal(1); - }); - }); }); }); - describe('buildRequests for banner ads', function () { - const bidRequestsWithMediaTypes = BANNER_BID_REQUESTS_WITH_MEDIA_TYPES; - - const bidRequestsWithPlatform = [{ - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00' - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }, { - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00' - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }]; - - const mockBidderRequest = {refererInfo: {}}; - - it('should send bid request to openx url via GET, with mediaTypes specified with banner type', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].url).to.equal('https://' + bidRequestsWithMediaTypes[0].params.delDomain + URLBASE); - expect(request[0].data.ph).to.be.undefined; - expect(request[0].method).to.equal('GET'); - }); - - it('should send bid request to openx platform url via GET, if platform is present', function () { - const request = spec.buildRequests(bidRequestsWithPlatform, mockBidderRequest); - expect(request[0].url).to.equal(`https://u.openx.net${URLBASE}`); - expect(request[0].data.ph).to.equal(bidRequestsWithPlatform[0].params.platform); - expect(request[0].method).to.equal('GET'); - }); - - it('should send bid request to openx platform url via GET, if both params present', function () { - const bidRequestsWithPlatformAndDelDomain = [{ - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'delDomain': 'test-del-domain', - 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00' - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }, { - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'delDomain': 'test-del-domain', - 'platform': '1cabba9e-cafe-3665-beef-f00f00f00f00' - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }]; - - const request = spec.buildRequests(bidRequestsWithPlatformAndDelDomain, mockBidderRequest); - expect(request[0].url).to.equal(`https://u.openx.net${URLBASE}`); - expect(request[0].data.ph).to.equal(bidRequestsWithPlatform[0].params.platform); - expect(request[0].method).to.equal('GET'); - }); + describe('buildRequests()', function () { + let bidRequestsWithMediaTypes; + let bidRequestsWithPlatform; + let mockBidderRequest; - it('should send the adunit codes', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data.divids).to.equal(`${encodeURIComponent(bidRequestsWithMediaTypes[0].adUnitCode)},${encodeURIComponent(bidRequestsWithMediaTypes[1].adUnitCode)}`); - }); - - it('should send the gpids', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data.aucs).to.equal(`${encodeURIComponent('/12345/my-gpt-tag-0')},${encodeURIComponent('/12345/my-gpt-tag-1')}`); - }); + beforeEach(function () { + mockBidderRequest = {refererInfo: {}}; - it('should send ad unit ids when any are defined', function () { - const bidRequestsWithUnitIds = [{ - 'bidder': 'openx', - 'params': { - 'delDomain': 'test-del-domain' + bidRequestsWithMediaTypes = [{ + bidder: 'openx', + params: { + unit: '11', + delDomain: 'test-del-domain', + platform: '1cabba9e-cafe-3665-beef-f00f00f00f00', }, - 'adUnitCode': 'adunit-code', + adUnitCode: '/adunit-code/test-path', mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' - }, { - 'bidder': 'openx', - 'params': { - 'unit': '22', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - 'bidId': 'test-bid-id-2', - 'bidderRequestId': 'test-bid-request-2', - 'auctionId': 'test-auction-2' - }]; - const request = spec.buildRequests(bidRequestsWithUnitIds, mockBidderRequest); - expect(request[0].data.auid).to.equal(`,${bidRequestsWithUnitIds[1].params.unit}`); - }); - - it('should not send any ad unit ids when none are defined', function () { - const bidRequestsWithoutUnitIds = [{ - 'bidder': 'openx', - 'params': { - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + transactionId: 'test-transactionId-1', + ortb2Imp: { + ext: { + ae: 2 } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1' + } }, { - 'bidder': 'openx', - 'params': { - 'delDomain': 'test-del-domain' + bidder: 'openx', + params: { + unit: '22', + delDomain: 'test-del-domain', + platform: '1cabba9e-cafe-3665-beef-f00f00f00f00', }, - 'adUnitCode': 'adunit-code', + adUnitCode: 'adunit-code', mediaTypes: { - banner: { - sizes: [[728, 90]] + video: { + playerSize: [640, 480] } }, - 'bidId': 'test-bid-id-2', - 'bidderRequestId': 'test-bid-request-2', - 'auctionId': 'test-auction-2' + bidId: 'test-bid-id-2', + bidderRequestId: 'test-bid-request-2', + auctionId: 'test-auction-2', + transactionId: 'test-transactionId-2' }]; - const request = spec.buildRequests(bidRequestsWithoutUnitIds, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys('auid'); }); - it('should send out custom params on bids that have customParams specified', function () { - const bidRequest = Object.assign({}, - bidRequestsWithMediaTypes[0], - { - params: { - 'unit': '12345678', - 'delDomain': 'test-del-domain', - 'customParams': {'Test1': 'testval1+', 'test2': ['testval2/', 'testval3']} - } + context('common requests checks', function() { + it('should be able to handle multiformat requests', () => { + const multiformat = utils.deepClone(bidRequestsWithMediaTypes[0]); + multiformat.mediaTypes.video = { + context: 'outstream', + playerSize: [640, 480] } - ); + const requests = spec.buildRequests([multiformat], mockBidderRequest); + const outgoingFormats = requests.flatMap(rq => rq.data.imp.flatMap(imp => ['banner', 'video'].filter(k => imp[k] != null))); + const expected = FEATURES.VIDEO ? ['banner', 'video'] : ['banner'] + expect(outgoingFormats).to.have.members(expected); + }) - const request = spec.buildRequests([bidRequest], mockBidderRequest); - const dataParams = request[0].data; + it('should send bid request to openx url via POST', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].url).to.equal(REQUEST_URL); + expect(request[0].method).to.equal('POST'); + }); - expect(dataParams.tps).to.exist; - expect(dataParams.tps).to.equal(btoa('test1=testval1.&test2=testval2_,testval3')); - }); + it('should send delivery domain, if available', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.ext.delDomain).to.equal(bidRequestsWithMediaTypes[0].params.delDomain); + expect(request[0].data.ext.platformId).to.be.undefined; + }); - it('should send out custom bc parameter, if override is present', function () { - const bidRequest = Object.assign({}, - bidRequestsWithMediaTypes[0], - { - params: { - 'unit': '12345678', - 'delDomain': 'test-del-domain', - 'bc': 'hb_override' - } - } - ); + it('should send platform id, if available', function () { + bidRequestsWithMediaTypes[0].params.platform = '1cabba9e-cafe-3665-beef-f00f00f00f00'; + bidRequestsWithMediaTypes[1].params.platform = '1cabba9e-cafe-3665-beef-f00f00f00f00'; - const request = spec.buildRequests([bidRequest], mockBidderRequest); - const dataParams = request[0].data; + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.ext.platform).to.equal(bidRequestsWithMediaTypes[0].params.platform); + expect(request[1].data.ext.platform).to.equal(bidRequestsWithMediaTypes[0].params.platform); + }); - expect(dataParams.bc).to.exist; - expect(dataParams.bc).to.equal('hb_override'); - }); + it('should send openx adunit codes', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.imp[0].tagid).to.equal(bidRequestsWithMediaTypes[0].params.unit); + expect(request[1].data.imp[0].tagid).to.equal(bidRequestsWithMediaTypes[1].params.unit); + }); - it('should not send any consent management properties', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data.gdpr).to.equal(undefined); - expect(request[0].data.gdpr_consent).to.equal(undefined); - expect(request[0].data.x_gdpr_f).to.equal(undefined); - }); + it('should send out custom params on bids that have customParams specified', function () { + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + params: { + unit: '12345678', + delDomain: 'test-del-domain', + customParams: {'Test1': 'testval1+', 'test2': ['testval2/', 'testval3']} + } + } + ); - describe('when there is a consent management framework', function () { - let bidRequests; - let mockConfig; - let bidderRequest; - const IAB_CONSENT_FRAMEWORK_CODE = 1; + mockBidderRequest.bids = [bidRequest]; + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].ext.customParams).to.equal(bidRequest.params.customParams); + }) - beforeEach(function () { - bidRequests = [{ - bidder: 'openx', - params: { - unit: '12345678-banner', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id', - bidderRequestId: 'test-bidder-request-id', - auctionId: 'test-auction-id' - }, { - 'bidder': 'openx', - 'mediaTypes': { - video: { - playerSize: [640, 480] + describe('floors', function () { + it('should send out custom floors on bids that have customFloors, no currency as account currency is used', function () { + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + params: { + unit: '12345678', + delDomain: 'test-del-domain', + customFloor: 1.500 + } } - }, - 'params': { - 'unit': '12345678-video', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', + ); - bidId: 'test-bid-id', - bidderRequestId: 'test-bidder-request-id', - auctionId: 'test-auction-id', - transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' - }]; - }); + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].bidfloor).to.equal(bidRequest.params.customFloor); + expect(request[0].data.imp[0].bidfloorcur).to.equal(undefined); + }); - afterEach(function () { - config.getConfig.restore(); - }); + context('with floors module', function () { + let adServerCurrencyStub; - describe('when us_privacy applies', function () { - beforeEach(function () { - bidderRequest = { - uspConsent: '1YYN', - refererInfo: {} - }; + beforeEach(function () { + adServerCurrencyStub = sinon + .stub(config, 'getConfig') + .withArgs('currency.adServerCurrency') + }); - sinon.stub(config, 'getConfig').callsFake((key) => { - return utils.deepAccess(mockConfig, key); + afterEach(function () { + config.getConfig.restore(); }); - }); - it('should send a signal to specify that GDPR applies to this request', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.us_privacy).to.equal('1YYN'); - expect(request[1].data.us_privacy).to.equal('1YYN'); - }); - }); + it('should send out floors on bids in USD', function () { + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + getFloor: () => { + return { + currency: 'USD', + floor: 9.99 + } + } + } + ); - describe('when us_privacy does not applies', function () { - beforeEach(function () { - bidderRequest = { - refererInfo: {} - }; + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].bidfloor).to.equal(9.99); + expect(request[0].data.imp[0].bidfloorcur).to.equal('USD'); + }); - sinon.stub(config, 'getConfig').callsFake((key) => { - return utils.deepAccess(mockConfig, key); + it('should send not send floors', function () { + adServerCurrencyStub.returns('EUR'); + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + getFloor: () => { + return { + currency: 'BTC', + floor: 9.99 + } + } + } + ); + + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].bidfloor).to.equal(undefined) + expect(request[0].data.imp[0].bidfloorcur).to.equal(undefined) }); - }); + }) + }) - it('should not send the consent string, when consent string is undefined', function () { - delete bidderRequest.uspConsent; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data).to.not.have.property('us_privacy'); - expect(request[1].data).to.not.have.property('us_privacy'); - }); - }); + describe('FPD', function() { + let bidRequests; + const mockBidderRequest = {refererInfo: {}}; - describe('when GDPR applies', function () { beforeEach(function () { - bidderRequest = { - gdprConsent: { - consentString: 'test-gdpr-consent-string', - gdprApplies: true + bidRequests = [{ + bidder: 'openx', + params: { + unit: '12345678-banner', + delDomain: 'test-del-domain' }, - refererInfo: {} - }; + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-1' + }, { + bidder: 'openx', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + params: { + unit: '12345678-video', + delDomain: 'test-del-domain' + }, + 'adUnitCode': 'adunit-code', - mockConfig = { - consentManagement: { - cmpApi: 'iab', - timeout: 1111, - allowAuctionWithoutConsent: 'cancel' - } - }; + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-2' + }]; + }); - sinon.stub(config, 'getConfig').callsFake((key) => { - return utils.deepAccess(mockConfig, key); + it('ortb2.site should be merged in the request', function() { + const request = spec.buildRequests(bidRequests, { + ...mockBidderRequest, + 'ortb2': { + site: { + domain: 'page.example.com', + cat: ['IAB2'], + sectioncat: ['IAB2-2'] + } + } }); + let data = request[0].data; + expect(data.site.domain).to.equal('page.example.com'); + expect(data.site.cat).to.deep.equal(['IAB2']); + expect(data.site.sectioncat).to.deep.equal(['IAB2-2']); }); - it('should send a signal to specify that GDPR applies to this request', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.gdpr).to.equal(1); - expect(request[1].data.gdpr).to.equal(1); + it('ortb2.user should be merged in the request', function() { + const request = spec.buildRequests(bidRequests, { + ...mockBidderRequest, + 'ortb2': { + user: { + yob: 1985 + } + } + }); + let data = request[0].data; + expect(data.user.yob).to.equal(1985); }); - it('should send the consent string', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.gdpr_consent).to.equal(bidderRequest.gdprConsent.consentString); - expect(request[1].data.gdpr_consent).to.equal(bidderRequest.gdprConsent.consentString); - }); + describe('ortb2Imp', function() { + describe('ortb2Imp.ext.data.pbadslot', function() { + beforeEach(function () { + if (bidRequests[0].hasOwnProperty('ortb2Imp')) { + delete bidRequests[0].ortb2Imp; + } + }); - it('should send the consent management framework code', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.x_gdpr_f).to.equal(IAB_CONSENT_FRAMEWORK_CODE); - expect(request[1].data.x_gdpr_f).to.equal(IAB_CONSENT_FRAMEWORK_CODE); - }); - }); + it('should not send if imp[].ext.data object is invalid', function() { + bidRequests[0].ortb2Imp = { + ext: {} + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext).to.not.have.property('data'); + }); - describe('when GDPR does not apply', function () { - beforeEach(function () { - bidderRequest = { - gdprConsent: { - consentString: 'test-gdpr-consent-string', - gdprApplies: false - }, - refererInfo: {} - }; - - mockConfig = { - consentManagement: { - cmpApi: 'iab', - timeout: 1111, - allowAuctionWithoutConsent: 'cancel' - } - }; + it('should not send if imp[].ext.data.pbadslot is undefined', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + if (data.imp[0].ext.data) { + expect(data.imp[0].ext.data).to.not.have.property('pbadslot'); + } else { + expect(data.imp[0].ext).to.not.have.property('data'); + } + }); - sinon.stub(config, 'getConfig').callsFake((key) => { - return utils.deepAccess(mockConfig, key); + it('should send if imp[].ext.data.pbadslot is string', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + pbadslot: 'abcd' + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext.data).to.have.property('pbadslot'); + expect(data.imp[0].ext.data.pbadslot).to.equal('abcd'); + }); }); - }); - it('should not send a signal to specify that GDPR does not apply to this request', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.gdpr).to.equal(0); - expect(request[1].data.gdpr).to.equal(0); - }); + describe('ortb2Imp.ext.data.adserver', function() { + beforeEach(function () { + if (bidRequests[0].hasOwnProperty('ortb2Imp')) { + delete bidRequests[0].ortb2Imp; + } + }); - it('should send the consent string', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.gdpr_consent).to.equal(bidderRequest.gdprConsent.consentString); - expect(request[1].data.gdpr_consent).to.equal(bidderRequest.gdprConsent.consentString); - }); + it('should not send if imp[].ext.data object is invalid', function() { + bidRequests[0].ortb2Imp = { + ext: {} + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext).to.not.have.property('data'); + }); - it('should send the consent management framework code', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data.x_gdpr_f).to.equal(IAB_CONSENT_FRAMEWORK_CODE); - expect(request[1].data.x_gdpr_f).to.equal(IAB_CONSENT_FRAMEWORK_CODE); - }); - }); + it('should not send if imp[].ext.data.adserver is undefined', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + if (data.imp[0].ext.data) { + expect(data.imp[0].ext.data).to.not.have.property('adserver'); + } else { + expect(data.imp[0].ext).to.not.have.property('data'); + } + }); - describe('when GDPR consent has undefined data', function () { - beforeEach(function () { - bidderRequest = { - gdprConsent: { - consentString: 'test-gdpr-consent-string', - gdprApplies: true - }, - refererInfo: {} - }; + it('should send', function() { + let adSlotValue = 'abc'; + bidRequests[0].ortb2Imp = { + ext: { + data: { + adserver: { + name: 'GAM', + adslot: adSlotValue + } + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext.data.adserver.name).to.equal('GAM'); + expect(data.imp[0].ext.data.adserver.adslot).to.equal(adSlotValue); + }); + }); - mockConfig = { - consentManagement: { - cmpApi: 'iab', - timeout: 1111, - allowAuctionWithoutConsent: 'cancel' - } - }; + describe('ortb2Imp.ext.data.other', function() { + beforeEach(function () { + if (bidRequests[0].hasOwnProperty('ortb2Imp')) { + delete bidRequests[0].ortb2Imp; + } + }); - sinon.stub(config, 'getConfig').callsFake((key) => { - return utils.deepAccess(mockConfig, key); - }); - }); + it('should not send if imp[].ext.data object is invalid', function() { + bidRequests[0].ortb2Imp = { + ext: {} + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext).to.not.have.property('data'); + }); - it('should not send a signal to specify whether GDPR applies to this request, when GDPR application is undefined', function () { - delete bidderRequest.gdprConsent.gdprApplies; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data).to.not.have.property('gdpr'); - expect(request[1].data).to.not.have.property('gdpr'); - }); + it('should not send if imp[].ext.data.other is undefined', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + if (data.imp[0].ext.data) { + expect(data.imp[0].ext.data).to.not.have.property('other'); + } else { + expect(data.imp[0].ext).to.not.have.property('data'); + } + }); - it('should not send the consent string, when consent string is undefined', function () { - delete bidderRequest.gdprConsent.consentString; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data).to.not.have.property('gdpr_consent'); - expect(request[1].data).to.not.have.property('gdpr_consent'); + it('ortb2Imp.ext.data.other', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + other: 1234 + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext.data.other).to.equal(1234); + }); + }); }); - it('should not send the consent management framework code, when format is undefined', function () { - delete mockConfig.consentManagement.cmpApi; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request[0].data).to.not.have.property('x_gdpr_f'); - expect(request[1].data).to.not.have.property('x_gdpr_f'); + describe('with user agent client hints', function () { + it('should add device.sua if available', function () { + const bidderRequestWithUserAgentClientHints = { refererInfo: {}, + ortb2: { + device: { + sua: { + source: 2, + platform: { + brand: 'macOS', + version: [ '12', '4', '0' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Not;A=Brand', + version: [ '99', '0', '0', '0' ] + }], + mobile: 0, + model: 'Pro', + bitness: '64', + architecture: 'x86' + } + } + }}; + + let request = spec.buildRequests(bidRequests, bidderRequestWithUserAgentClientHints); + expect(request[0].data.device.sua).to.exist; + expect(request[0].data.device.sua).to.deep.equal(bidderRequestWithUserAgentClientHints.ortb2.device.sua); + const bidderRequestWithoutUserAgentClientHints = {refererInfo: {}, ortb2: {}}; + request = spec.buildRequests(bidRequests, bidderRequestWithoutUserAgentClientHints); + expect(request[0].data.device?.sua).to.not.exist; + }); }); }); - }); - it('should not send a coppa query param when there are no coppa param settings in the bid requests', function () { - const bidRequestsWithoutCoppa = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain', - coppa: false - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }, { - bidder: 'openx', - params: { - unit: '22', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - bidId: 'test-bid-id-2', - bidderRequestId: 'test-bid-request-2', - auctionId: 'test-auction-2' - }]; - const request = spec.buildRequests(bidRequestsWithoutCoppa, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys('tfcd'); - }); + context('when there is a consent management framework', function () { + let bidRequests; + let mockConfig; + let bidderRequest; - it('should send a coppa flag there is when there is coppa param settings in the bid requests', function () { - const bidRequestsWithCoppa = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain', - coppa: false - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }, { - bidder: 'openx', - params: { - unit: '22', - delDomain: 'test-del-domain', - coppa: true - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - bidId: 'test-bid-id-2', - bidderRequestId: 'test-bid-request-2', - auctionId: 'test-auction-2' - }]; - const request = spec.buildRequests(bidRequestsWithCoppa, mockBidderRequest); - expect(request[0].data.tfcd).to.equal(1); - }); - - it('should not send a "no segmentation" flag there no DoNotTrack setting that is set to true', function () { - const bidRequestsWithoutDnt = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain', - doNotTrack: false - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }, { - bidder: 'openx', - params: { - unit: '22', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - bidId: 'test-bid-id-2', - bidderRequestId: 'test-bid-request-2', - auctionId: 'test-auction-2' - }]; - const request = spec.buildRequests(bidRequestsWithoutDnt, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys('ns'); - }); - - it('should send a "no segmentation" flag there is any DoNotTrack setting that is set to true', function () { - const bidRequestsWithDnt = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain', - doNotTrack: false - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }, { - bidder: 'openx', - params: { - unit: '22', - delDomain: 'test-del-domain', - doNotTrack: true - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[728, 90]] - } - }, - bidId: 'test-bid-id-2', - bidderRequestId: 'test-bid-request-2', - auctionId: 'test-auction-2' - }]; - const request = spec.buildRequests(bidRequestsWithDnt, mockBidderRequest); - expect(request[0].data.ns).to.equal(1); - }); - - describe('when schain is provided', function () { - let bidRequests; - let schainConfig; - const supplyChainNodePropertyOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; - - beforeEach(function () { - schainConfig = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'exchange1.com', - 'sid': '1234', - 'hp': 1, - 'rid': 'bid-request-1', - 'name': 'publisher', - 'domain': 'publisher.com' - // omitted ext + beforeEach(function () { + bidRequests = [{ + bidder: 'openx', + params: { + unit: '12345678-banner', + delDomain: 'test-del-domain' }, - { - 'asi': 'exchange2.com', - 'sid': 'abcd', - 'hp': 1, - 'rid': 'bid-request-2', - // name field missing - 'domain': 'intermediary.com' + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } }, - { - 'asi': 'exchange3.com', - 'sid': '4321', - 'hp': 1, - // request id - // name field missing - 'domain': 'intermediary-2.com' - } - ] - }; + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-1' + }, { + bidder: 'openx', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + params: { + unit: '12345678-video', + delDomain: 'test-del-domain' + }, + 'adUnitCode': 'adunit-code', - bidRequests = [{ - 'bidder': 'openx', - 'params': { - 'unit': '11', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': '/adunit-code/test-path', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - 'bidId': 'test-bid-id-1', - 'bidderRequestId': 'test-bid-request-1', - 'auctionId': 'test-auction-1', - 'schain': schainConfig - }]; - }); + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-2' + }]; + }); - it('should send a schain parameter with the proper delimiter symbols', function () { - const request = spec.buildRequests(bidRequests, mockBidderRequest); - const dataParams = request[0].data; - const numNodes = schainConfig.nodes.length; + describe('us_privacy', function () { + beforeEach(function () { + bidderRequest = { + uspConsent: '1YYN', + refererInfo: {} + }; - // each node will have a ! to denote beginning of a new node - expect(dataParams.schain.match(/!/g).length).to.equal(numNodes); + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + }); - // 1 comma in the front for version - // 5 commas per node - expect(dataParams.schain.match(/,/g).length).to.equal(numNodes * 5 + 1); - }); + afterEach(function () { + config.getConfig.restore(); + }); - it('should send a schain with the right version', function () { - const request = spec.buildRequests(bidRequests, mockBidderRequest); - const dataParams = request[0].data; - let serializedSupplyChain = dataParams.schain.split('!'); - let version = serializedSupplyChain.shift().split(',')[0]; + it('should send a signal to specify that US Privacy applies to this request', function () { + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs.ext.us_privacy).to.equal('1YYN'); + expect(request[1].data.regs.ext.us_privacy).to.equal('1YYN'); + }); - expect(version).to.equal(bidRequests[0].schain.ver); - }); + it('should not send the regs object, when consent string is undefined', function () { + delete bidderRequest.uspConsent; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs?.us_privacy).to.not.exist; + }); + }); - it('should send a schain with the right complete value', function () { - const request = spec.buildRequests(bidRequests, mockBidderRequest); - const dataParams = request[0].data; - let serializedSupplyChain = dataParams.schain.split('!'); - let isComplete = serializedSupplyChain.shift().split(',')[1]; + describe('GDPR', function () { + beforeEach(function () { + bidderRequest = { + gdprConsent: { + consentString: 'test-gdpr-consent-string', + addtlConsent: 'test-addtl-consent-string', + gdprApplies: true + }, + refererInfo: {} + }; + + mockConfig = { + consentManagement: { + cmpApi: 'iab', + timeout: 1111, + allowAuctionWithoutConsent: 'cancel' + } + }; - expect(isComplete).to.equal(String(bidRequests[0].schain.complete)); - }); + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + }); - it('should send all available params in the right order', function () { - const request = spec.buildRequests(bidRequests, mockBidderRequest); - const dataParams = request[0].data; - let serializedSupplyChain = dataParams.schain.split('!'); - serializedSupplyChain.shift(); + afterEach(function () { + config.getConfig.restore(); + }); - serializedSupplyChain.forEach((serializedNode, nodeIndex) => { - let nodeProperties = serializedNode.split(','); + it('should send a signal to specify that GDPR applies to this request', function () { + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs.ext.gdpr).to.equal(1); + expect(request[1].data.regs.ext.gdpr).to.equal(1); + }); - nodeProperties.forEach((nodeProperty, propertyIndex) => { - let node = schainConfig.nodes[nodeIndex]; - let key = supplyChainNodePropertyOrder[propertyIndex]; + it('should send the consent string', function () { + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + expect(request[1].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + }); - expect(nodeProperty).to.equal(node[key] ? String(node[key]) : '', - `expected node '${nodeIndex}' property '${nodeProperty}' to key '${key}' to be the same value`) + it('should send the addtlConsent string', function () { + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.user.ext.ConsentedProvidersSettings.consented_providers).to.equal(bidderRequest.gdprConsent.addtlConsent); + expect(request[1].data.user.ext.ConsentedProvidersSettings.consented_providers).to.equal(bidderRequest.gdprConsent.addtlConsent); }); - }); - }); - }); - describe('when there are userid providers', function () { - const EXAMPLE_DATA_BY_ATTR = { - britepoolid: '1111-britepoolid', - criteoId: '1111-criteoId', - fabrickId: '1111-fabrickid', - haloId: '1111-haloid', - id5id: {uid: '1111-id5id'}, - idl_env: '1111-idl_env', - IDP: '1111-zeotap-idplusid', - idxId: '1111-idxid', - intentIqId: '1111-intentiqid', - lipb: {lipbid: '1111-lipb'}, - lotamePanoramaId: '1111-lotameid', - merkleId: {id: '1111-merkleid'}, - netId: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', - parrableId: { eid: 'eidVersion.encryptionKeyReference.encryptedValue' }, - pubcid: '1111-pubcid', - quantcastId: '1111-quantcastid', - tapadId: '111-tapadid', - tdid: '1111-tdid', - uid2: {id: '1111-uid2'}, - flocId: {id: '12144', version: 'chrome.1.1'}, - novatiq: {snowflake: '1111-novatiqid'}, - admixerId: '1111-admixerid', - deepintentId: '1111-deepintentid', - dmdId: '111-dmdid', - nextrollId: '1111-nextrollid', - mwOpenLinkId: '1111-mwopenlinkid', - dapId: '1111-dapId', - amxId: '1111-amxid', - kpuid: '1111-kpuid', - publinkId: '1111-publinkid', - naveggId: '1111-naveggid', - imuid: '1111-imuid', - adtelligentId: '1111-adtelligentid' - }; - - // generates the same set of tests for each id provider - utils._each(USER_ID_CODE_TO_QUERY_ARG, (userIdQueryArg, userIdProviderKey) => { - describe(`with userId attribute: ${userIdProviderKey}`, function () { - it(`should not send a ${userIdQueryArg} query param when there is no userId.${userIdProviderKey} defined in the bid requests`, function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data).to.not.have.any.keys(userIdQueryArg); + it('should send a signal to specify that GDPR does not apply to this request', function () { + bidderRequest.gdprConsent.gdprApplies = false; + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs.ext.gdpr).to.equal(0); + expect(request[1].data.regs.ext.gdpr).to.equal(0); }); - it(`should send a ${userIdQueryArg} query param when userId.${userIdProviderKey} is defined in the bid requests`, function () { - const bidRequestsWithUserId = [{ - bidder: 'openx', - params: { - unit: '11', - delDomain: 'test-del-domain' - }, - userId: { - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600]] - } - }, - bidId: 'test-bid-id-1', - bidderRequestId: 'test-bid-request-1', - auctionId: 'test-auction-1' - }]; - // enrich bid request with userId key/value - bidRequestsWithUserId[0].userId[userIdProviderKey] = EXAMPLE_DATA_BY_ATTR[userIdProviderKey]; - - const request = spec.buildRequests(bidRequestsWithUserId, mockBidderRequest); - - let userIdValue; - // handle cases where userId key refers to an object - switch (userIdProviderKey) { - case 'merkleId': - userIdValue = EXAMPLE_DATA_BY_ATTR.merkleId.id; - break; - case 'flocId': - userIdValue = EXAMPLE_DATA_BY_ATTR.flocId.id; - break; - case 'uid2': - userIdValue = EXAMPLE_DATA_BY_ATTR.uid2.id; - break; - case 'lipb': - userIdValue = EXAMPLE_DATA_BY_ATTR.lipb.lipbid; - break; - case 'parrableId': - userIdValue = EXAMPLE_DATA_BY_ATTR.parrableId.eid; - break; - case 'id5id': - userIdValue = EXAMPLE_DATA_BY_ATTR.id5id.uid; - break; - case 'novatiq': - userIdValue = EXAMPLE_DATA_BY_ATTR.novatiq.snowflake; - break; - default: - userIdValue = EXAMPLE_DATA_BY_ATTR[userIdProviderKey]; - } + it('when GDPR application is undefined, should not send a signal to specify whether GDPR applies to this request, ' + + 'but can send consent data, ', function () { + delete bidderRequest.gdprConsent.gdprApplies; + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs?.ext?.gdpr).to.not.be.ok; + expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + expect(request[1].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + }); - expect(request[0].data[USER_ID_CODE_TO_QUERY_ARG[userIdProviderKey]]).to.equal(userIdValue); + it('when consent string is undefined, should not send the consent string, ', function () { + delete bidderRequest.gdprConsent.consentString; + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.imp[0].ext.consent).to.equal(undefined); + expect(request[1].data.imp[0].ext.consent).to.equal(undefined); }); }); }); - }); - describe('floors', function () { - it('should send out custom floors on bids that have customFloors specified', function () { - const bidRequest = Object.assign({}, - bidRequestsWithMediaTypes[0], - { - params: { - 'unit': '12345678', - 'delDomain': 'test-del-domain', - 'customFloor': 1.500001 - } - } - ); - - const request = spec.buildRequests([bidRequest], mockBidderRequest); - const dataParams = request[0].data; - - expect(dataParams.aumfs).to.exist; - expect(dataParams.aumfs).to.equal('1500'); - }); - - context('with floors module', function () { - let adServerCurrencyStub; - - beforeEach(function () { - adServerCurrencyStub = sinon - .stub(config, 'getConfig') - .withArgs('currency.adServerCurrency') + context('coppa', function() { + it('when there are no coppa param settings, should not send a coppa flag', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.regs?.coppa).to.be.not.ok; }); - afterEach(function () { - config.getConfig.restore(); - }); - - it('should send out floors on bids', function () { - const bidRequest1 = Object.assign({}, - bidRequestsWithMediaTypes[0], - { - getFloor: () => { - return { - currency: 'AUS', - floor: 9.99 - } - } - } - ); - - const bidRequest2 = Object.assign({}, - bidRequestsWithMediaTypes[1], - { - getFloor: () => { - return { - currency: 'AUS', - floor: 18.881 - } - } - } - ); + it('should send a coppa flag there is when there is coppa param settings in the bid requests', function () { + let mockConfig = { + coppa: true + }; - const request = spec.buildRequests([bidRequest1, bidRequest2], mockBidderRequest); - const dataParams = request[0].data; + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); - expect(dataParams.aumfs).to.exist; - expect(dataParams.aumfs).to.equal('9990,18881'); + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.regs.coppa).to.equal(1); }); - it('should send out floors on bids in the default currency', function () { - const bidRequest1 = Object.assign({}, - bidRequestsWithMediaTypes[0], - { - getFloor: () => { - return {}; - } - } - ); - - let getFloorSpy = sinon.spy(bidRequest1, 'getFloor'); - - spec.buildRequests([bidRequest1], mockBidderRequest); - expect(getFloorSpy.args[0][0].mediaType).to.equal(BANNER); - expect(getFloorSpy.args[0][0].currency).to.equal('USD'); + it('should send a coppa flag there is when there is coppa param settings in the bid params', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + request.params = {coppa: true}; + expect(request[0].data.regs.coppa).to.equal(1); }); - it('should send out floors on bids in the ad server currency if defined', function () { - adServerCurrencyStub.returns('bitcoin'); - - const bidRequest1 = Object.assign({}, - bidRequestsWithMediaTypes[0], - { - getFloor: () => { - return {}; - } - } - ); - - let getFloorSpy = sinon.spy(bidRequest1, 'getFloor'); - - spec.buildRequests([bidRequest1], mockBidderRequest); - expect(getFloorSpy.args[0][0].mediaType).to.equal(BANNER); - expect(getFloorSpy.args[0][0].currency).to.equal('bitcoin'); + after(function () { + config.getConfig.restore() }); - }) - }) - }); - - describe('buildRequests for video', function () { - const bidRequestsWithMediaTypes = VIDEO_BID_REQUESTS_WITH_MEDIA_TYPES; - const mockBidderRequest = {refererInfo: {}}; - - it('should send bid request to openx url via GET, with mediaTypes having video parameter', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].url).to.equal('https://' + bidRequestsWithMediaTypes[0].params.delDomain + URLBASEVIDEO); - expect(request[0].method).to.equal('GET'); - }); - it('should have the correct parameters', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - const dataParams = request[0].data; - - expect(dataParams.auid).to.equal('12345678'); - expect(dataParams.vht).to.equal(480); - expect(dataParams.vwd).to.equal(640); - expect(dataParams.aucs).to.equal(encodeURIComponent('/12345/my-gpt-tag-0')); - }); - - it('shouldn\'t have the test parameter', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - expect(request[0].data.vtest).to.be.undefined; - }); - - it('should send a bc parameter', function () { - const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); - const dataParams = request[0].data; - - expect(dataParams.bc).to.have.string('hb_pb'); - }); - - describe('when using the video param', function () { - let videoBidRequest; - let mockBidderRequest = {refererInfo: {}}; - - beforeEach(function () { - videoBidRequest = { - 'bidder': 'openx', - 'mediaTypes': { - video: { - context: 'instream', - playerSize: [640, 480] - } - }, - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' - }; - mockBidderRequest = {refererInfo: {}}; - }); - - it('should not allow you to set a url', function () { - videoBidRequest.params.video = { - url: 'test-url' - }; - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - - expect(request[0].data.url).to.be.undefined; - }); - - it('should not allow you to override the javascript url', function () { - let myUrl = 'my-url'; - videoBidRequest.params.video = { - ju: myUrl - }; - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - - expect(request[0].data.ju).to.not.equal(myUrl); }); - describe('when using the openrtb video params', function () { - it('should parse legacy params.video.openrtb', function () { - let myOpenRTBObject = {mimes: ['application/javascript']}; - videoBidRequest.params.video = { - openrtb: myOpenRTBObject - }; - const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + context('do not track (DNT)', function() { + let doNotTrackStub; - expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + beforeEach(function () { + doNotTrackStub = sinon.stub(utils, 'getDNT'); }); - - it('should parse legacy params.openrtb', function () { - let myOpenRTBObject = {mimes: ['application/javascript']}; - videoBidRequest.params.openrtb = myOpenRTBObject; - const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - - expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + afterEach(function() { + doNotTrackStub.restore(); }); - it('should parse legacy params.video', function () { - let myOpenRTBObject = {mimes: ['application/javascript']}; - videoBidRequest.params.video = myOpenRTBObject; - const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + it('when there is a do not track, should send a dnt', function () { + doNotTrackStub.returns(1); - expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.device.dnt).to.equal(1); }); - it('should parse legacy params.video as full openrtb', function () { - let myOpenRTBObject = {imp: [{video: {mimes: ['application/javascript']}}]}; - videoBidRequest.params.video = myOpenRTBObject; - const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + it('when there is not do not track, don\'t send dnt', function () { + doNotTrackStub.returns(0); - expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.device.dnt).to.equal(0); }); - it('should parse legacy video.openrtb', function () { - let myOpenRTBObject = {mimes: ['application/javascript']}; - videoBidRequest.params.video = { - openrtb: myOpenRTBObject - }; - const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); + it('when there is no defined do not track, don\'t send dnt', function () { + doNotTrackStub.returns(null); - expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.device.dnt).to.equal(0); }); + }); + + context('supply chain (schain)', function () { + let bidRequests; + let schainConfig; + const supplyChainNodePropertyOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; - it('should omit filtered values for legacy', function () { - let myOpenRTBObject = {mimes: ['application/javascript'], dont: 'use'}; - videoBidRequest.params.video = { - openrtb: myOpenRTBObject + beforeEach(function () { + schainConfig = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'exchange1.com', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'publisher', + domain: 'publisher.com' + // omitted ext + }, + { + asi: 'exchange2.com', + sid: 'abcd', + hp: 1, + rid: 'bid-request-2', + // name field missing + domain: 'intermediary.com' + }, + { + asi: 'exchange3.com', + sid: '4321', + hp: 1, + // request id + // name field missing + domain: 'intermediary-2.com' + } + ] }; - const expected = {imp: [{video: {w: 640, h: 480, mimes: ['application/javascript']}}]} - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - expect(request[0].data.openrtb).to.equal(JSON.stringify(expected)); + bidRequests = [{ + bidder: 'openx', + params: { + unit: '11', + delDomain: 'test-del-domain' + }, + adUnitCode: '/adunit-code/test-path', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + schain: schainConfig + }]; }); - it('should parse mediatypes.video', function () { - videoBidRequest.mediaTypes.video.mimes = ['application/javascript'] - videoBidRequest.mediaTypes.video.minduration = 15 - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - const openRtbRequestParams = JSON.parse(request[0].data.openrtb); - expect(openRtbRequestParams.imp[0].video.mimes).to.eql(['application/javascript']); - expect(openRtbRequestParams.imp[0].video.minduration).to.equal(15); + it('should send a supply chain object', function () { + const request = spec.buildRequests(bidRequests, mockBidderRequest); + expect(request[0].data.source.ext.schain).to.equal(schainConfig); }); - it('should filter mediatypes.video', function () { - videoBidRequest.mediaTypes.video.mimes = ['application/javascript'] - videoBidRequest.mediaTypes.video.minnothing = 15 - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - const openRtbRequestParams = JSON.parse(request[0].data.openrtb); - expect(openRtbRequestParams.imp[0].video.mimes).to.eql(['application/javascript']); - expect(openRtbRequestParams.imp[0].video.minnothing).to.equal(undefined); + it('should send the supply chain object with the right version', function () { + const request = spec.buildRequests(bidRequests, mockBidderRequest); + expect(request[0].data.source.ext.schain.ver).to.equal(schainConfig.ver); }); - it("should use the bidRequest's playerSize", function () { - const width = 200; - const height = 100; - const myOpenRTBObject = {v: height, w: width}; - videoBidRequest.params.video = { - openrtb: myOpenRTBObject - }; - const request = spec.buildRequests([videoBidRequest], mockBidderRequest); - const openRtbRequestParams = JSON.parse(request[0].data.openrtb); - - expect(openRtbRequestParams.imp[0].video.w).to.equal(640); - expect(openRtbRequestParams.imp[0].video.h).to.equal(480); + it('should send the supply chain object with the right complete value', function () { + const request = spec.buildRequests(bidRequests, mockBidderRequest); + expect(request[0].data.source.ext.schain.complete).to.equal(schainConfig.complete); }); }); - }); - describe('floors', function () { - it('should send out custom floors on bids that have customFloors specified', function () { - const bidRequest = Object.assign({}, - bidRequestsWithMediaTypes[0], + context('when there are userid providers', function () { + const userIdAsEids = [ { - params: { - 'unit': '12345678', - 'delDomain': 'test-del-domain', - 'customFloor': 1.500001 - } + source: 'adserver.org', + uids: [{ + id: 'some-random-id-value', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + }, + { + source: 'id5-sync.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }, + { + source: 'sharedid.org', + uids: [{ + id: 'some-random-id-value', + atype: 1, + ext: { + third: 'some-random-id-value' + } + }] } - ); - - const request = spec.buildRequests([bidRequest], mockBidderRequest); - const dataParams = request[0].data; - - expect(dataParams.aumfs).to.exist; - expect(dataParams.aumfs).to.equal('1500'); - }); + ]; - context('with floors module', function () { - let adServerCurrencyStub; - function makeBidWithFloorInfo(floorInfo) { - return Object.assign(utils.deepClone(bidRequestsWithMediaTypes[0]), - { - getFloor: () => { - return floorInfo; + it(`should send the user id under the extended ids`, function () { + const bidRequestsWithUserId = [{ + bidder: 'openx', + params: { + unit: '11', + delDomain: 'test-del-domain' + }, + userId: { + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] } - }); - } - - beforeEach(function () { - adServerCurrencyStub = sinon - .stub(config, 'getConfig') - .withArgs('currency.adServerCurrency') + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + userIdAsEids: userIdAsEids + }]; + // enrich bid request with userId key/value + + const request = spec.buildRequests(bidRequestsWithUserId, mockBidderRequest); + expect(request[0].data.user.ext.eids).to.equal(userIdAsEids); }); - afterEach(function () { - config.getConfig.restore(); + it(`when no user ids are available, it should not send any extended ids`, function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data).to.not.have.any.keys('user'); }); + }); - it('should send out floors on bids', function () { - const floors = [9.99, 18.881]; - const bidRequests = floors.map(floor => { - return makeBidWithFloorInfo({ - currency: 'AUS', - floor: floor - }); + context('FLEDGE', function() { + it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, { + ...mockBidderRequest, + fledgeEnabled: true }); - const request = spec.buildRequests(bidRequests, mockBidderRequest); - - expect(request[0].data.aumfs).to.exist; - expect(request[0].data.aumfs).to.equal('9990'); - expect(request[1].data.aumfs).to.exist; - expect(request[1].data.aumfs).to.equal('18881'); + expect(request[0].data.imp[0].ext.ae).to.equal(2); }); + }); + }); - it('should send out floors on bids in the default currency', function () { - const bidRequest1 = makeBidWithFloorInfo({}); - - let getFloorSpy = sinon.spy(bidRequest1, 'getFloor'); + context('banner', function () { + it('should send bid request with a mediaTypes specified with banner type', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.imp[0]).to.have.any.keys(BANNER); + }); + }); - spec.buildRequests([bidRequest1], mockBidderRequest); - expect(getFloorSpy.args[0][0].mediaType).to.equal(VIDEO); - expect(getFloorSpy.args[0][0].currency).to.equal('USD'); + if (FEATURES.VIDEO) { + context('video', function () { + it('should send bid request with a mediaTypes specified with video type', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[1].data.imp[0]).to.have.any.keys(VIDEO); }); - it('should send out floors on bids in the ad server currency if defined', function () { - adServerCurrencyStub.returns('bitcoin'); - - const bidRequest1 = makeBidWithFloorInfo({}); - - let getFloorSpy = sinon.spy(bidRequest1, 'getFloor'); - - spec.buildRequests([bidRequest1], mockBidderRequest); - expect(getFloorSpy.args[0][0].mediaType).to.equal(VIDEO); - expect(getFloorSpy.args[0][0].currency).to.equal('bitcoin'); + it('Update imp.video with OpenRTB options from mimeTypes and params', function() { + const bid01 = new BidRequestBuilder({ + adUnitCode: 'adunit-code-01', + mediaTypes: { + banner: { sizes: [[300, 250]] }, + video: { + context: 'outstream', + playerSize: [[300, 250]], + mimes: ['video/mp4'], + protocols: [8] + } + }, + }).withParams({ + // options in video, will merge + video: { + skip: 1, + skipafter: 4, + minduration: 10, + maxduration: 30 + } + }).build(); + + const bidderRequest = new BidderRequestBuilder().build(); + const expected = { + mimes: ['video/mp4'], + skip: 1, + skipafter: 4, + minduration: 10, + maxduration: 30, + placement: 4, + protocols: [8], + w: 300, + h: 250 + }; + const requests = spec.buildRequests([bid01], bidderRequest); + expect(requests).to.have.lengthOf(2); + expect(requests[1].data.imp[0].video).to.deep.equal(expected); }); - }) - }) + }); + } }); - describe('buildRequest for multi-format ad', function () { - const multiformatBid = MULTI_FORMAT_BID_REQUESTS[0]; - let mockBidderRequest = {refererInfo: {}}; - - it('should default to a banner request', function () { - const request = spec.buildRequests([multiformatBid], mockBidderRequest); - const dataParams = request[0].data; - - expect(dataParams.divids).to.have.string(multiformatBid.adUnitCode); - }); - }); + describe('interpretResponse()', function () { + let bidRequestConfigs; + let bidRequest; + let bidResponse; + let bid; - describe('buildRequests for all kinds of ads', function () { - utils._each({ - banner: BANNER_BID_REQUESTS_WITH_MEDIA_TYPES[0], - video: VIDEO_BID_REQUESTS_WITH_MEDIA_TYPES[0], - multi: MULTI_FORMAT_BID_REQUESTS[0] - }, (bidRequest, name) => { - describe('with segments', function () { - const TESTS = [ - { - name: 'should send proprietary segment data from ortb2.user.data', - config: { - ortb2: { - user: { - data: [ - {name: 'dmp1', ext: {segtax: 4}, segment: [{id: 'foo'}, {id: 'bar'}]}, - {name: 'dmp2', segment: [{id: 'baz'}]}, - ] - } - } - }, - expect: {sm: 'dmp1/4:foo|bar,dmp2:baz'}, - }, - { - name: 'should send proprietary segment data from ortb2.site.content.data', - config: { - ortb2: { - site: { - content: { - data: [ - {name: 'dmp1', ext: {segtax: 4}, segment: [{id: 'foo'}, {id: 'bar'}]}, - {name: 'dmp2', segment: [{id: 'baz'}]}, - ] - } - } - } - }, - expect: {scsm: 'dmp1/4:foo|bar,dmp2:baz'}, - }, - { - name: 'should send proprietary segment data from both ortb2.site.content.data and ortb2.user.data', - config: { - ortb2: { - user: { - data: [ - {name: 'dmp1', ext: {segtax: 4}, segment: [{id: 'foo'}, {id: 'bar'}]}, - {name: 'dmp2', segment: [{id: 'baz'}]}, - ] - }, - site: { - content: { - data: [ - {name: 'dmp3', ext: {segtax: 5}, segment: [{id: 'foo2'}, {id: 'bar2'}]}, - {name: 'dmp4', segment: [{id: 'baz2'}]}, - ] - } - } - } - }, - expect: { - sm: 'dmp1/4:foo|bar,dmp2:baz', - scsm: 'dmp3/5:foo2|bar2,dmp4:baz2' - }, - }, - { - name: 'should combine same provider segment data from ortb2.user.data', - config: { - ortb2: { - user: { - data: [ - {name: 'dmp1', ext: {segtax: 4}, segment: [{id: 'foo'}, {id: 'bar'}]}, - {name: 'dmp1', ext: {}, segment: [{id: 'baz'}]}, - ] - } - } - }, - expect: {sm: 'dmp1/4:foo|bar,dmp1:baz'}, + context('when there is an nbr response', function () { + let bids; + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' }, - { - name: 'should combine same provider segment data from ortb2.site.content.data', - config: { - ortb2: { - site: { - content: { - data: [ - {name: 'dmp1', ext: {segtax: 4}, segment: [{id: 'foo'}, {id: 'bar'}]}, - {name: 'dmp1', ext: {}, segment: [{id: 'baz'}]}, - ] - } - } - } + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], }, - expect: {scsm: 'dmp1/4:foo|bar,dmp1:baz'}, - }, - { - name: 'should not send any segment data if first party config is incomplete', - config: { - ortb2: { - user: { - data: [ - {name: 'provider-with-no-segments'}, - {segment: [{id: 'segments-with-no-provider'}]}, - {}, - ] - } - } - } }, - { - name: 'should send first party data segments and liveintent segments from request', - config: { - ortb2: { - user: { - data: [ - {name: 'dmp1', segment: [{id: 'foo'}, {id: 'bar'}]}, - {name: 'dmp2', segment: [{id: 'baz'}]}, - ] - }, - site: { - content: { - data: [ - {name: 'dmp3', ext: {segtax: 5}, segment: [{id: 'foo2'}, {id: 'bar2'}]}, - {name: 'dmp4', segment: [{id: 'baz2'}]}, - ] - } - } - } - }, - request: { - userId: { - lipb: { - lipbid: 'aaa', - segments: ['l1', 'l2'] - }, - }, - }, - expect: { - sm: 'dmp1:foo|bar,dmp2:baz,liveintent:l1|l2', - scsm: 'dmp3/5:foo2|bar2,dmp4:baz2' - }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = {nbr: 0}; // Unknown error + bids = spec.interpretResponse({body: bidResponse}, bidRequest); + }); + + it('should not return any bids', function () { + expect(bids.length).to.equal(0); + }); + }); + + context('when no seatbid in response', function () { + let bids; + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' }, - { - name: 'should send just liveintent segment from request if no first party config', - config: {}, - request: { - userId: { - lipb: { - lipbid: 'aaa', - segments: ['l1', 'l2'] - }, - }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], }, - expect: {sm: 'liveintent:l1|l2'}, }, - { - name: 'should send nothing if lipb section does not contain segments', - config: {}, - request: { - userId: { - lipb: { - lipbid: 'aaa', - }, - }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = {ext: {}, id: 'test-bid-id'}; + bids = spec.interpretResponse({body: bidResponse}, bidRequest); + }); + + it('should not return any bids', function () { + expect(bids.length).to.equal(0); + }); + }); + + context('when there is no response', function () { + let bids; + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], }, }, - ]; - utils._each(TESTS, (t) => { - context('in ortb2.user.data', function () { - let bidRequests; - beforeEach(function () { - let fpdConfig = t.config - sinon - .stub(config, 'getConfig') - .withArgs(sinon.match(/^ortb2\.user\.data$|^ortb2\.site\.content\.data$/)) - .callsFake((key) => { - return utils.deepAccess(fpdConfig, key); - }); - bidRequests = [{...bidRequest, ...t.request}]; - }); + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; - afterEach(function () { - config.getConfig.restore(); - }); + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; - const mockBidderRequest = {refererInfo: {}}; - it(`${t.name} for type ${name}`, function () { - const request = spec.buildRequests(bidRequests, mockBidderRequest) - expect(request.length).to.equal(1); - if (t.expect) { - for (const key in t.expect) { - expect(request[0].data[key]).to.exist; - expect(request[0].data[key]).to.equal(t.expect[key]); - } - } else { - expect(request[0].data.sm).to.not.exist; - expect(request[0].data.scsm).to.not.exist; - } - }); - }); - }); + bidResponse = ''; // Unknown error + bids = spec.interpretResponse({body: bidResponse}, bidRequest); }); - }); - }) - describe('interpretResponse for banner ads', function () { - beforeEach(function () { - sinon.spy(userSync, 'registerSync'); + it('should not return any bids', function () { + expect(bids.length).to.equal(0); + }); }); - afterEach(function () { - userSync.registerSync.restore(); - }); + const SAMPLE_BID_REQUESTS = [{ + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; - describe('when there is a standard response', function () { - const creativeOverride = { - id: 234, - width: '300', - height: '250', - tracking: { - impression: 'https://openx-d.openx.net/v/1.0/ri?ts=ts' + const SAMPLE_BID_RESPONSE = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 2, + w: 300, + h: 250, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup', + adomain: ['brand.com'], + ext: { + dsp_id: '123', + buyer_id: '456', + brand_id: '789', + paf: { + content_id: 'paf_content_id' + } + } + }] + }], + cur: 'AUS', + ext: { + paf: { + transmission: {version: '12'} } - }; - - const adUnitOverride = { - ts: 'test-1234567890-ts', - idx: '0', - currency: 'USD', - pub_rev: '10000', - html: '
OpenX Ad
' - }; - let adUnit; - let bidResponse; - - let bid; - let bidRequest; - let bidRequestConfigs; + } + }; + context('when there is a response, the common response properties', function () { beforeEach(function () { - bidRequestConfigs = [{ - 'bidder': 'openx', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'mediaType': 'banner', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - bidRequest = { - method: 'GET', - url: 'https://openx-d.openx.net/v/1.0/arj', - data: {}, - payload: {'bids': bidRequestConfigs, 'startTime': new Date()} - }; + bidRequestConfigs = deepClone(SAMPLE_BID_REQUESTS); + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + bidResponse = deepClone(SAMPLE_BID_RESPONSE); - adUnit = mockAdUnit(adUnitOverride, creativeOverride); - bidResponse = mockArjResponse(undefined, [adUnit]); bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; }); it('should return a price', function () { - expect(bid.cpm).to.equal(parseInt(adUnitOverride.pub_rev, 10) / 1000); + expect(bid.cpm).to.equal(bidResponse.seatbid[0].bid[0].price); }); it('should return a request id', function () { - expect(bid.requestId).to.equal(bidRequest.payload.bids[0].bidId); + expect(bid.requestId).to.equal(bidResponse.seatbid[0].bid[0].impid); }); it('should return width and height for the creative', function () { - expect(bid.width).to.equal(creativeOverride.width); - expect(bid.height).to.equal(creativeOverride.height); + expect(bid.width).to.equal(bidResponse.seatbid[0].bid[0].w); + expect(bid.height).to.equal(bidResponse.seatbid[0].bid[0].h); }); it('should return a creativeId', function () { - expect(bid.creativeId).to.equal(creativeOverride.id); + expect(bid.creativeId).to.equal(bidResponse.seatbid[0].bid[0].crid); }); it('should return an ad', function () { - expect(bid.ad).to.equal(adUnitOverride.html); + expect(bid.ad).to.equal(bidResponse.seatbid[0].bid[0].adm); + }); + + it('should return a deal id if it exists', function () { + expect(bid.dealId).to.equal(bidResponse.seatbid[0].bid[0].dealid); }); it('should have a time-to-live of 5 minutes', function () { @@ -1837,415 +1286,293 @@ describe('OpenxAdapter', function () { }); it('should return a currency', function () { - expect(bid.currency).to.equal(adUnitOverride.currency); - }); - - it('should return a transaction state', function () { - expect(bid.ts).to.equal(adUnitOverride.ts); + expect(bid.currency).to.equal(bidResponse.cur); }); it('should return a brand ID', function () { - expect(bid.meta.brandId).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.brand_id); + expect(bid.meta.brandId).to.equal(bidResponse.seatbid[0].bid[0].ext.brand_id); }); - it('should return an adomain', function () { - expect(bid.meta.advertiserDomains).to.deep.equal([]); + it('should return a dsp ID', function () { + expect(bid.meta.networkId).to.equal(bidResponse.seatbid[0].bid[0].ext.dsp_id); }); - it('should return a dsp ID', function () { - expect(bid.meta.dspid).to.equal(DEFAULT_TEST_ARJ_AD_UNIT.adv_id); + it('should return a buyer ID', function () { + expect(bid.meta.advertiserId).to.equal(bidResponse.seatbid[0].bid[0].ext.buyer_id); }); - }); - describe('when there is a deal', function () { - const adUnitOverride = { - deal_id: 'ox-1000' - }; - let adUnit; - let bidResponse; + it('should return adomain', function () { + expect(bid.meta.advertiserDomains).to.equal(bidResponse.seatbid[0].bid[0].adomain); + }); - let bid; - let bidRequestConfigs; - let bidRequest; + it('should return paf fields', function () { + const paf = { + transmission: {version: '12'}, + content_id: 'paf_content_id' + } + expect(bid.meta.paf).to.deep.equal(paf); + }); + }); + context('when there is more than one response', () => { + let bids; beforeEach(function () { - bidRequestConfigs = [{ - 'bidder': 'openx', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'mediaType': 'banner', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; + bidRequestConfigs = deepClone(SAMPLE_BID_REQUESTS); + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + bidResponse = deepClone(SAMPLE_BID_RESPONSE); + bidResponse.seatbid[0].bid.push(deepClone(bidResponse.seatbid[0].bid[0])); + bidResponse.seatbid[0].bid[1].ext.paf.content_id = 'second_paf' - bidRequest = { - method: 'GET', - url: 'https://openx-d.openx.net/v/1.0/arj', - data: {}, - payload: {'bids': bidRequestConfigs, 'startTime': new Date()} - }; - adUnit = mockAdUnit(adUnitOverride); - bidResponse = mockArjResponse(null, [adUnit]); - bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; - mockArjResponse(); + bids = spec.interpretResponse({body: bidResponse}, bidRequest); }); - it('should return a deal id', function () { - expect(bid.dealId).to.equal(adUnitOverride.deal_id); + it('should not confuse paf content_id', () => { + expect(bids.map(b => b.meta.paf.content_id)).to.eql(['paf_content_id', 'second_paf']); }); - }); - - describe('when there is no bids in the response', function () { - let bidRequest; - let bidRequestConfigs; + }) + context('when the response is a banner', function() { beforeEach(function () { bidRequestConfigs = [{ - 'bidder': 'openx', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' }, - 'adUnitCode': 'adunit-code', - 'mediaType': 'banner', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' }]; - bidRequest = { - method: 'GET', - url: 'https://openx-d.openx.net/v/1.0/arj', - data: {}, - payload: {'bids': bidRequestConfigs, 'startTime': new Date()} - }; - }); - - it('handles nobid responses', function () { - const bidResponse = { - 'ads': - { - 'version': 1, - 'count': 1, - 'pixels': 'https://testpixels.net', - 'ad': [] - } + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 2, + w: 300, + h: 250, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup' + }] + }], + cur: 'AUS' }; - const result = spec.interpretResponse({body: bidResponse}, bidRequest); - expect(result.length).to.equal(0); + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; }); - }); - describe('when adunits return out of order', function () { - const bidRequests = [{ - bidder: 'openx', - params: { - unit: '12345678', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[100, 111]] - } - }, - bidId: 'test-bid-request-id-1', - bidderRequestId: 'test-request-1', - auctionId: 'test-auction-id-1' - }, { - bidder: 'openx', - params: { - unit: '12345678', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[200, 222]] - } - }, - bidId: 'test-bid-request-id-2', - bidderRequestId: 'test-request-1', - auctionId: 'test-auction-id-1' - }, { - bidder: 'openx', - params: { - unit: '12345678', - delDomain: 'test-del-domain' - }, - adUnitCode: 'adunit-code', - mediaTypes: { - banner: { - sizes: [[300, 333]] - } - }, - 'bidId': 'test-bid-request-id-3', - 'bidderRequestId': 'test-request-1', - 'auctionId': 'test-auction-id-1' - }]; - const bidRequest = { - method: 'GET', - url: 'https://openx-d.openx.net/v/1.0/arj', - data: {}, - payload: {'bids': bidRequests, 'startTime': new Date()} - }; - - let outOfOrderAdunits = [ - mockAdUnit({ - idx: '1' - }, { - width: bidRequests[1].mediaTypes.banner.sizes[0][0], - height: bidRequests[1].mediaTypes.banner.sizes[0][1] - }), - mockAdUnit({ - idx: '2' - }, { - width: bidRequests[2].mediaTypes.banner.sizes[0][0], - height: bidRequests[2].mediaTypes.banner.sizes[0][1] - }), - mockAdUnit({ - idx: '0' - }, { - width: bidRequests[0].mediaTypes.banner.sizes[0][0], - height: bidRequests[0].mediaTypes.banner.sizes[0][1] - }) - ]; - - let bidResponse = mockArjResponse(undefined, outOfOrderAdunits); - - it('should return map adunits back to the proper request', function () { - const bids = spec.interpretResponse({body: bidResponse}, bidRequest); - expect(bids[0].requestId).to.equal(bidRequests[1].bidId); - expect(bids[0].width).to.equal(bidRequests[1].mediaTypes.banner.sizes[0][0]); - expect(bids[0].height).to.equal(bidRequests[1].mediaTypes.banner.sizes[0][1]); - expect(bids[1].requestId).to.equal(bidRequests[2].bidId); - expect(bids[1].width).to.equal(bidRequests[2].mediaTypes.banner.sizes[0][0]); - expect(bids[1].height).to.equal(bidRequests[2].mediaTypes.banner.sizes[0][1]); - expect(bids[2].requestId).to.equal(bidRequests[0].bidId); - expect(bids[2].width).to.equal(bidRequests[0].mediaTypes.banner.sizes[0][0]); - expect(bids[2].height).to.equal(bidRequests[0].mediaTypes.banner.sizes[0][1]); + it('should return the proper mediaType', function () { + it('should return a creativeId', function () { + expect(bid.mediaType).to.equal(Object.keys(bidRequestConfigs[0].mediaTypes)[0]); + }); }); }); - }); - - describe('interpretResponse for video ads', function () { - beforeEach(function () { - sinon.spy(userSync, 'registerSync'); - }); - afterEach(function () { - userSync.registerSync.restore(); - }); - - const bidsWithMediaTypes = [{ - 'bidder': 'openx', - 'mediaTypes': {video: {}}, - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [640, 480], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' - }]; - const bidsWithMediaType = [{ - 'bidder': 'openx', - 'mediaType': 'video', - 'params': { - 'unit': '12345678', - 'delDomain': 'test-del-domain' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [640, 480], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' - }]; - const bidRequestsWithMediaTypes = { - method: 'GET', - url: 'https://openx-d.openx.net/v/1.0/avjp', - data: {}, - payload: {'bid': bidsWithMediaTypes[0], 'startTime': new Date()} - }; - const bidRequestsWithMediaType = { - method: 'GET', - url: 'https://openx-d.openx.net/v/1.0/avjp', - data: {}, - payload: {'bid': bidsWithMediaType[0], 'startTime': new Date()} - }; - const bidResponse = { - 'pub_rev': '1000', - 'width': '640', - 'height': '480', - 'adid': '5678', - 'currency': 'AUD', - 'vastUrl': 'https://testvast.com', - 'pixels': 'https://testpixels.net' - }; + if (FEATURES.VIDEO) { + context('when the response is a video', function() { + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + video: { + playerSize: [[640, 360], [854, 480]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 2, + w: 854, + h: 480, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup', + }] + }], + cur: 'AUS' + }; + }); - it('should return correct bid response with MediaTypes', function () { - const expectedResponse = { - 'requestId': '30b31c1838de1e', - 'cpm': 1, - 'width': 640, - 'height': 480, - 'mediaType': 'video', - 'creativeId': '5678', - 'vastUrl': 'https://testvast.com', - 'ttl': 300, - 'netRevenue': true, - 'currency': 'AUD' - }; - - const result = spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaTypes); - expect(result[0]).to.eql(expectedResponse); - }); + it('should return the proper mediaType', function () { + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; + expect(bid.mediaType).to.equal(Object.keys(bidRequestConfigs[0].mediaTypes)[0]); + }); - it('should return correct bid response with MediaType', function () { - const expectedResponse = [ - { - 'requestId': '30b31c1838de1e', - 'cpm': 1, - 'width': '640', - 'height': '480', - 'mediaType': 'video', - 'creativeId': '5678', - 'vastUrl': 'https://testvast.com', - 'ttl': 300, - 'netRevenue': true, - 'currency': 'USD' - } - ]; + it('should return the proper mediaType', function () { + const winUrl = 'https//my.win.url'; + bidResponse.seatbid[0].bid[0].nurl = winUrl + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; - const result = spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaType); - expect(JSON.stringify(Object.keys(result[0]).sort())).to.eql(JSON.stringify(Object.keys(expectedResponse[0]).sort())); - }); + expect(bid.vastUrl).to.equal(winUrl); + }); + }); + } - it('should return correct bid response with MediaType and deal_id', function () { - const bidResponseOverride = { 'deal_id': 'OX-mydeal' }; - const bidResponseWithDealId = Object.assign({}, bidResponse, bidResponseOverride); - const result = spec.interpretResponse({body: bidResponseWithDealId}, bidRequestsWithMediaType); - expect(result[0].dealId).to.equal(bidResponseOverride.deal_id); - }); + context('when the response contains FLEDGE interest groups config', function() { + let response; - it('should handle nobid responses for bidRequests with MediaTypes', function () { - const bidResponse = {'vastUrl': '', 'pub_rev': '', 'width': '', 'height': '', 'adid': '', 'pixels': ''}; - const result = spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaTypes); - expect(result.length).to.equal(0); - }); + beforeEach(function () { + sinon.stub(config, 'getConfig') + .withArgs('fledgeEnabled') + .returns(true); - it('should handle nobid responses for bidRequests with MediaType', function () { - const bidResponse = {'vastUrl': '', 'pub_rev': '', 'width': '', 'height': '', 'adid': '', 'pixels': ''}; - const result = spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaType); - expect(result.length).to.equal(0); - }); - }); + bidRequestConfigs = [{ + bidder: 'openx', + params: { + unit: '12345678', + delDomain: 'test-del-domain' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; - describe('user sync', function () { - const syncUrl = 'https://testpixels.net'; + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 2, + w: 300, + h: 250, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup' + }] + }], + cur: 'AUS', + ext: { + fledge_auction_configs: { + 'test-bid-id': { + seller: 'codinginadtech.com', + interestGroupBuyers: ['somedomain.com'], + sellerTimeout: 0, + perBuyerSignals: { + 'somedomain.com': { + base_bid_micros: 0.1, + disallowed_advertiser_ids: [ + '1234', + '2345' + ], + multiplier: 1.3, + use_bid_multiplier: true, + win_reporting_id: '1234567asdf' + } + } + } + } + } + }; - describe('iframe sync', function () { - it('should register the pixel iframe from banner ad response', function () { - let syncs = spec.getUserSyncs( - {iframeEnabled: true}, - [{body: {ads: {pixels: syncUrl}}}] - ); - expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + response = spec.interpretResponse({body: bidResponse}, bidRequest); }); - it('should register the pixel iframe from video ad response', function () { - let syncs = spec.getUserSyncs( - {iframeEnabled: true}, - [{body: {pixels: syncUrl}}] - ); - expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + afterEach(function () { + config.getConfig.restore(); }); - it('should register the default iframe if no pixels available', function () { - let syncs = spec.getUserSyncs( - {iframeEnabled: true}, - [] - ); - expect(syncs).to.deep.equal([{type: 'iframe', url: 'https://u.openx.net/w/1.0/pd'}]); + it('should return FLEDGE auction_configs alongside bids', function () { + expect(response).to.have.property('bids'); + expect(response).to.have.property('fledgeAuctionConfigs'); + expect(response.fledgeAuctionConfigs.length).to.equal(1); + expect(response.fledgeAuctionConfigs[0].bidId).to.equal('test-bid-id'); }); }); + }); - describe('pixel sync', function () { - it('should register the image pixel from banner ad response', function () { - let syncs = spec.getUserSyncs( - {pixelEnabled: true}, - [{body: {ads: {pixels: syncUrl}}}] - ); - expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]); - }); + describe('user sync', function () { + it('should register the default image pixel if no pixels available', function () { + let syncs = spec.getUserSyncs( + {pixelEnabled: true}, + [] + ); + expect(syncs).to.deep.equal([{type: 'image', url: DEFAULT_SYNC}]); + }); - it('should register the image pixel from video ad response', function () { - let syncs = spec.getUserSyncs( - {pixelEnabled: true}, - [{body: {pixels: syncUrl}}] - ); - expect(syncs).to.deep.equal([{type: 'image', url: syncUrl}]); - }); + it('should register custom syncUrl when exists', function () { + let syncs = spec.getUserSyncs( + {pixelEnabled: true}, + [{body: {ext: {delDomain: 'www.url.com'}}}] + ); + expect(syncs).to.deep.equal([{type: 'image', url: 'https://www.url.com/w/1.0/pd'}]); + }); - it('should register the default image pixel if no pixels available', function () { - let syncs = spec.getUserSyncs( - {pixelEnabled: true}, - [] - ); - expect(syncs).to.deep.equal([{type: 'image', url: 'https://u.openx.net/w/1.0/pd'}]); - }); + it('should register custom syncUrl when exists', function () { + let syncs = spec.getUserSyncs( + {pixelEnabled: true}, + [{body: {ext: {platform: 'abc'}}}] + ); + expect(syncs).to.deep.equal([{type: 'image', url: SYNC_URL + '?ph=abc'}]); + }); + + it('when iframe sync is allowed, it should register an iframe sync', function () { + let syncs = spec.getUserSyncs( + {iframeEnabled: true}, + [] + ); + expect(syncs).to.deep.equal([{type: 'iframe', url: DEFAULT_SYNC}]); }); it('should prioritize iframe over image for user sync', function () { let syncs = spec.getUserSyncs( {iframeEnabled: true, pixelEnabled: true}, - [{body: {ads: {pixels: syncUrl}}}] + [] ); - expect(syncs).to.deep.equal([{type: 'iframe', url: syncUrl}]); + expect(syncs).to.deep.equal([{type: 'iframe', url: DEFAULT_SYNC}]); }); describe('when gdpr applies', function () { let gdprConsent; let gdprPixelUrl; + const consentString = 'gdpr-pixel-consent'; + const gdprApplies = '1'; beforeEach(() => { gdprConsent = { - consentString: 'test-gdpr-consent-string', + consentString, gdprApplies: true }; - gdprPixelUrl = 'https://testpixels.net?gdpr=1&gdpr_consent=gdpr-pixel-consent' + gdprPixelUrl = `${SYNC_URL}&gdpr=${gdprApplies}&gdpr_consent=${consentString}`; }); it('when there is a response, it should have the gdpr query params', () => { - let [{url}] = spec.getUserSyncs( - {iframeEnabled: true, pixelEnabled: true}, - [{body: {ads: {pixels: gdprPixelUrl}}}], - gdprConsent - ); - - expect(url).to.have.string('gdpr_consent=gdpr-pixel-consent'); - expect(url).to.have.string('gdpr=1'); - }); - - it('when there is no response, it should append gdpr query params', () => { let [{url}] = spec.getUserSyncs( {iframeEnabled: true, pixelEnabled: true}, [], gdprConsent ); - expect(url).to.have.string('gdpr_consent=test-gdpr-consent-string'); - expect(url).to.have.string('gdpr=1'); + + expect(url).to.have.string(`gdpr_consent=${consentString}`); + expect(url).to.have.string(`gdpr=${gdprApplies}`); }); it('should not send signals if no consent object is available', function () { @@ -2261,28 +1588,19 @@ describe('OpenxAdapter', function () { describe('when ccpa applies', function () { let usPrivacyConsent; let uspPixelUrl; + const privacyString = 'TEST'; beforeEach(() => { usPrivacyConsent = 'TEST'; - uspPixelUrl = 'https://testpixels.net?us_privacy=AAAA' + uspPixelUrl = `${DEFAULT_SYNC}&us_privacy=${privacyString}` }); - it('when there is a response, it should send the us privacy string from the response, ', () => { - let [{url}] = spec.getUserSyncs( - {iframeEnabled: true, pixelEnabled: true}, - [{body: {ads: {pixels: uspPixelUrl}}}], - undefined, - usPrivacyConsent - ); - - expect(url).to.have.string('us_privacy=AAAA'); - }); - it('when there is no response, it send have the us privacy string', () => { + it('should send the us privacy string, ', () => { let [{url}] = spec.getUserSyncs( {iframeEnabled: true, pixelEnabled: true}, [], undefined, usPrivacyConsent ); - expect(url).to.have.string(`us_privacy=${usPrivacyConsent}`); + expect(url).to.have.string(`us_privacy=${privacyString}`); }); it('should not send signals if no consent string is available', function () { @@ -2294,75 +1612,4 @@ describe('OpenxAdapter', function () { }); }); }); - - /** - * Makes sure the override object does not introduce - * new fields against the contract - * - * This does a shallow check in order to make key checking simple - * with respect to what a helper handles. For helpers that have - * nested fields, either check your design on maybe breaking it up - * to smaller, manageable pieces - * - * OR just call this on your nth level field if necessary. - * - * @param {Object} override Object with keys that overrides the default - * @param {Object} contract Original object contains the default fields - * @param {string} typeName Name of the type we're checking for error messages - * @throws {AssertionError} - */ - function overrideKeyCheck(override, contract, typeName) { - expect(contract).to.include.all.keys(Object.keys(override)); - } - - /** - * Creates a mock ArjResponse - * @param {OxArjResponse=} response - * @param {Array=} adUnits - * @throws {AssertionError} - * @return {OxArjResponse} - */ - function mockArjResponse(response, adUnits = []) { - let mockedArjResponse = utils.deepClone(DEFAULT_ARJ_RESPONSE); - - if (response) { - overrideKeyCheck(response, DEFAULT_ARJ_RESPONSE, 'OxArjResponse'); - overrideKeyCheck(response.ads, DEFAULT_ARJ_RESPONSE.ads, 'OxArjResponse'); - Object.assign(mockedArjResponse, response); - } - - if (adUnits.length) { - mockedArjResponse.ads.count = adUnits.length; - mockedArjResponse.ads.ad = adUnits.map((adUnit) => { - overrideKeyCheck(adUnit, DEFAULT_TEST_ARJ_AD_UNIT, 'OxArjAdUnit'); - return Object.assign(utils.deepClone(DEFAULT_TEST_ARJ_AD_UNIT), adUnit); - }); - } - - return mockedArjResponse; - } - - /** - * Creates a mock ArjAdUnit - * @param {OxArjAdUnit=} adUnit - * @param {OxArjCreative=} creative - * @throws {AssertionError} - * @return {OxArjAdUnit} - */ - function mockAdUnit(adUnit, creative) { - overrideKeyCheck(adUnit, DEFAULT_TEST_ARJ_AD_UNIT, 'OxArjAdUnit'); - - let mockedAdUnit = Object.assign(utils.deepClone(DEFAULT_TEST_ARJ_AD_UNIT), adUnit); - - if (creative) { - overrideKeyCheck(creative, DEFAULT_TEST_ARJ_CREATIVE); - if (creative.tracking) { - overrideKeyCheck(creative.tracking, DEFAULT_TEST_ARJ_CREATIVE.tracking, 'OxArjCreative'); - } - Object.assign(mockedAdUnit.creative[0], creative); - } - - return mockedAdUnit; - } -}) -; +}); diff --git a/test/spec/modules/operaadsBidAdapter_spec.js b/test/spec/modules/operaadsBidAdapter_spec.js index 849a3eada3f..37d4a2c7bc0 100644 --- a/test/spec/modules/operaadsBidAdapter_spec.js +++ b/test/spec/modules/operaadsBidAdapter_spec.js @@ -1,7 +1,7 @@ -import { expect } from 'chai'; -import { spec } from 'modules/operaadsBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import { BANNER, NATIVE, VIDEO } from 'src/mediaTypes.js'; +import {expect} from 'chai'; +import {spec} from 'modules/operaadsBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {BANNER, NATIVE, VIDEO} from 'src/mediaTypes.js'; describe('Opera Ads Bid Adapter', function () { describe('Test isBidRequestValid', function () { @@ -49,7 +49,7 @@ describe('Opera Ads Bid Adapter', function () { bidderCode: 'myBidderCode', bidderRequestId: '15246a574e859f', refererInfo: { - referer: 'http://example.com', + page: 'http://example.com', stack: ['http://example.com'] }, gdprConsent: { @@ -234,7 +234,7 @@ describe('Opera Ads Bid Adapter', function () { requestData = JSON.parse(req.data); }).to.not.throw(); - expect(requestData.id).to.equal(bidderRequest.auctionId); + expect(requestData.id).to.exist; expect(requestData.tmax).to.equal(bidderRequest.timeout); expect(requestData.test).to.equal(0); expect(requestData.imp).to.be.an('array').that.have.lengthOf(1); @@ -242,7 +242,7 @@ describe('Opera Ads Bid Adapter', function () { expect(requestData.site).to.be.an('object'); expect(requestData.site.id).to.equal(bidRequest.params.publisherId); expect(requestData.site.domain).to.not.be.empty; - expect(requestData.site.page).to.equal(bidderRequest.refererInfo.referer); + expect(requestData.site.page).to.equal(bidderRequest.refererInfo.page); expect(requestData.at).to.equal(1); expect(requestData.bcat).to.be.an('array').that.is.empty; expect(requestData.cur).to.be.an('array').that.not.be.empty; diff --git a/test/spec/modules/operaadsIdSystem_spec.js b/test/spec/modules/operaadsIdSystem_spec.js new file mode 100644 index 00000000000..d81f643d62f --- /dev/null +++ b/test/spec/modules/operaadsIdSystem_spec.js @@ -0,0 +1,53 @@ +import { operaIdSubmodule } from 'modules/operaadsIdSystem' +import * as ajaxLib from 'src/ajax.js' + +const TEST_ID = 'opera-test-id'; +const operaIdRemoteResponse = { uid: TEST_ID }; + +describe('operaId submodule properties', () => { + it('should expose a "name" property equal to "operaId"', () => { + expect(operaIdSubmodule.name).to.equal('operaId'); + }); +}); + +function fakeRequest(fn) { + const ajaxBuilderStub = sinon.stub(ajaxLib, 'ajaxBuilder').callsFake(() => { + return (url, cbObj) => { + cbObj.success(JSON.stringify(operaIdRemoteResponse)); + } + }); + fn(); + ajaxBuilderStub.restore(); +} + +describe('operaId submodule getId', function() { + it('request to the fake server to correctly extract test ID', function() { + fakeRequest(() => { + const moduleIdCallbackResponse = operaIdSubmodule.getId({ params: { pid: 'pub123' } }); + moduleIdCallbackResponse.callback((id) => { + expect(id).to.equal(operaIdRemoteResponse.operaId); + }); + }); + }); + + it('request to the fake server without publiser ID', function() { + fakeRequest(() => { + const moduleIdCallbackResponse = operaIdSubmodule.getId({ params: {} }); + expect(moduleIdCallbackResponse).to.equal(undefined); + }); + }); +}); + +describe('operaId submodule decode', function() { + it('should respond with an object containing "operaId" as key with the value', () => { + expect(operaIdSubmodule.decode(TEST_ID)).to.deep.equal({ + operaId: TEST_ID + }); + }); + + it('should respond with undefined if the value is not a string or an empty string', () => { + [1, 2.0, null, undefined, NaN, [], {}].forEach((value) => { + expect(operaIdSubmodule.decode(value)).to.equal(undefined); + }); + }); +}); diff --git a/test/spec/modules/optidigitalBidAdapter_spec.js b/test/spec/modules/optidigitalBidAdapter_spec.js new file mode 100755 index 00000000000..30e72452c39 --- /dev/null +++ b/test/spec/modules/optidigitalBidAdapter_spec.js @@ -0,0 +1,631 @@ +import { expect } from 'chai'; +import { spec, resetSync } from 'modules/optidigitalBidAdapter.js'; +import * as utils from 'src/utils.js'; + +const ENDPOINT = 'https://pbs.optidigital.com/bidder'; + +describe('optidigitalAdapterTests', function () { + describe('isBidRequestValid', function () { + it('bidRequest with publisherId and placementId', function () { + expect(spec.isBidRequestValid({ + bidder: 'optidigital', + params: { + publisherId: 's123', + placementId: 'Billboard_Top' + } + })).to.equal(true); + }); + it('bidRequest without publisherId', function () { + expect(spec.isBidRequestValid({ + bidder: 'optidigital', + params: { + placementId: 'Billboard_Top' + } + })).to.equal(false); + }); + it('bidRequest without placementId', function () { + expect(spec.isBidRequestValid({ + bidder: 'optidigital', + params: { + publisherId: 's123' + } + })).to.equal(false); + }); + it('bidRequest without required parameters', function () { + expect(spec.isBidRequestValid({ + bidder: 'optidigital', + params: {} + })).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidderRequest = { + bids: [ + { + 'bidder': 'optidigital', + 'params': { + 'publisherId': 's123', + 'placementId': 'Billboard_Top', + 'divId': 'Billboard_Top_3c5425', + 'badv': ['example.com'], + 'bcat': ['IAB1-1'], + 'bapp': ['com.blocked'], + 'battr': [1, 2] + }, + 'crumbs': { + 'pubcid': '7769fd03-574c-48fe-b512-8147f7c4023a' + }, + 'ortb2Imp': { + 'ext': { + 'tid': '0cb56262-9637-474d-a572-86fa860fd8b7', + 'data': { + 'adserver': { + 'name': 'gam', + 'adslot': '/19968336/header-bid-tag-0' + }, + 'pbadslot': '/19968336/header-bid-tag-0' + }, + 'gpid': '/19968336/header-bid-tag-0' + } + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ [ 300, 250 ], [ 300, 600 ] ] + } + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': '0cb56262-9637-474d-a572-86fa860fd8b7', + 'sizes': [ [ 300, 250 ], [ 300, 600 ] ], + 'bidId': '245d89f17f289f', + 'bidderRequestId': '199d7ffafa1e91', + 'auctionId': 'b66f01cd-3441-4403-99fa-d8062e795933', + 'src': 'client', + 'metrics': { + 'requestBids.usp': 0.5, + 'requestBids.pubCommonId': 0.29999999701976776, + 'requestBids.fpd': 3.1000000089406967, + 'requestBids.validate': 0.5, + 'requestBids.makeRequests': 2.2000000029802322, + 'requestBids.total': 570, + 'requestBids.callBids': 320.5, + 'adapter.client.net': [ + 317.30000001192093 + ], + 'adapters.client.optidigital.net': [ + 317.30000001192093 + ], + 'adapter.client.interpretResponse': [ + 0 + ], + 'adapters.client.optidigital.interpretResponse': [ + 0 + ], + 'adapter.client.validate': 0, + 'adapters.client.optidigital.validate': 0, + 'adapter.client.buildRequests': 1, + 'adapters.client.optidigital.buildRequests': 1, + 'adapter.client.total': 318.59999999403954, + 'adapters.client.optidigital.total': 318.59999999403954 + }, + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0, + 'ortb2': { + 'site': { + 'page': 'https://example.com', + 'ref': 'https://example.com', + 'domain': 'example.com', + 'publisher': { + 'domain': 'example.com' + } + }, + 'device': { + 'w': 1605, + 'h': 1329, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36', + 'language': 'pl', + 'sua': { + 'source': 2, + 'platform': { + 'brand': 'Windows', + 'version': [ + '10', + '0', + '0' + ] + }, + 'browsers': [ + { + 'brand': 'Not_A Brand', + 'version': [ + '99', + '0', + '0', + '0' + ] + }, + { + 'brand': 'Google Chrome', + 'version': [ + '109', + '0', + '5414', + '75' + ] + }, + { + 'brand': 'Chromium', + 'version': [ + '109', + '0', + '5414', + '75' + ] + } + ], + 'mobile': 0, + 'model': '', + 'bitness': '64', + 'architecture': 'x86' + } + } + } + } + ], + 'refererInfo': { + 'canonicalUrl': 'https://www.prebid.org/the/link/to/the/page' + } + }; + + let validBidRequests = [ + { + 'bidder': 'optidigital', + 'bidId': '51ef8751f9aead', + 'params': { + 'publisherId': 's123', + 'placementId': 'Billboard_Top', + 'badv': ['example.com'], + 'bcat': ['IAB1-1'], + 'bapp': ['com.blocked'], + 'battr': [1, 2] + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'sizes': [[320, 50], [300, 250], [300, 600]], + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757' + } + ] + + it('should return an empty array if there are no bid requests', () => { + const emptyBidRequests = []; + const request = spec.buildRequests(emptyBidRequests, emptyBidRequests); + expect(request).to.be.an('array').that.is.empty; + }); + + it('should send bid request via POST', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.method).to.equal('POST'); + }); + + it('should send bid request to given endpoint', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + }); + + it('should be bidRequest data', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + expect(request.data).to.exist; + }); + + it('should add schain object to payload if exists', function () { + const bidRequest = Object.assign({}, validBidRequests[0], { + schain: { + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'examplewebsite.com', + sid: '00001', + hp: 1 + }] + } + }); + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data) + expect(payload.schain).to.exist; + expect(payload.schain).to.deep.equal({ + ver: '1.0', + complete: 1, + nodes: [{ + asi: 'examplewebsite.com', + sid: '00001', + hp: 1 + }] + }); + }); + + it('should add adContainerWidth and adContainerHeight to payload if divId exsists in parameter', function () { + let validBidRequestsWithDivId = [ + { + 'bidder': 'optidigital', + 'bidId': '51ef8751f9aead', + 'params': { + 'publisherId': 's123', + 'placementId': 'Billboard_Top', + 'divId': 'div-gpt-ad-1460505748561-0' + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 50], [300, 250], [300, 600]] + } + }, + 'sizes': [[320, 50], [300, 250], [300, 600]], + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757' + } + ] + const request = spec.buildRequests(validBidRequestsWithDivId, bidderRequest); + const payload = JSON.parse(request.data) + payload.imp[0].adContainerWidth = 1920 + payload.imp[0].adContainerHeight = 1080 + expect(payload.imp[0].adContainerWidth).to.exist; + expect(payload.imp[0].adContainerHeight).to.exist; + }); + + it('should add pageTemplate to payload if pageTemplate exsists in parameter', function () { + let validBidRequestsWithDivId = [ + { + 'bidder': 'optidigital', + 'bidId': '51ef8751f9aead', + 'params': { + 'publisherId': 's123', + 'placementId': 'Billboard_Top', + 'pageTemplate': 'home' + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 50], [300, 250], [300, 600]] + } + }, + 'sizes': [[320, 50], [300, 250], [300, 600]], + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757' + } + ] + const request = spec.buildRequests(validBidRequestsWithDivId, bidderRequest); + const payload = JSON.parse(request.data) + payload.imp[0].pageTemplate = 'home' + expect(payload.imp[0].pageTemplate).to.exist; + }); + + it('should add referrer to payload if it exsists in bidderRequest', function () { + bidderRequest.refererInfo.page = 'https://www.prebid.org'; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data) + expect(payload.referrer).to.equal('https://www.prebid.org'); + }); + + it('should use value for badv, bcat, bapp from params', function () { + bidderRequest.ortb2 = { + 'site': { + 'page': 'https://example.com', + 'ref': 'https://example.com', + 'domain': 'example.com', + 'publisher': { + 'domain': 'example.com' + } + }, + 'device': { + 'w': 1507, + 'h': 1329, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36', + 'language': 'pl', + 'sua': { + 'source': 2, + 'platform': { + 'brand': 'Windows', + 'version': [ + '10', + '0', + '0' + ] + }, + 'browsers': [ + { + 'brand': 'Not_A Brand', + 'version': [ + '99', + '0', + '0', + '0' + ] + }, + { + 'brand': 'Google Chrome', + 'version': [ + '109', + '0', + '5414', + '120' + ] + }, + { + 'brand': 'Chromium', + 'version': [ + '109', + '0', + '5414', + '120' + ] + } + ], + 'mobile': 0, + 'model': '', + 'bitness': '64', + 'architecture': 'x86' + } + } + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.badv).to.deep.equal(validBidRequests[0].params.badv); + expect(payload.bcat).to.deep.equal(validBidRequests[0].params.bcat); + expect(payload.bapp).to.deep.equal(validBidRequests[0].params.bapp); + }); + + it('should send empty GDPR consent and required set to false', function() { + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.gdpr.consent).to.equal(''); + expect(payload.gdpr.required).to.equal(false); + }); + + it('should send GDPR to given endpoint', function() { + let consentString = 'DFR8KRePoQNsRREZCADBG+A=='; + bidderRequest.gdprConsent = { + 'consentString': consentString, + 'gdprApplies': true, + 'vendorData': { + 'hasGlobalConsent': false + }, + 'apiVersion': 1 + } + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.gdpr).to.exist; + expect(payload.gdpr.consent).to.equal(consentString); + expect(payload.gdpr.required).to.exist.and.to.be.true; + }); + + it('should send empty GDPR consent to endpoint', function() { + let consentString = false; + bidderRequest.gdprConsent = { + 'consentString': consentString, + 'gdprApplies': true, + 'vendorData': { + 'hasGlobalConsent': false + }, + 'apiVersion': 1 + } + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.gdpr.consent).to.equal(''); + }); + + it('should send uspConsent to given endpoint', function() { + bidderRequest.uspConsent = '1YYY'; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.uspConsent).to.exist; + }); + + it('should use appropriate mediaTypes banner sizes', function() { + const mediaTypesBannerSize = { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 600] + } + } + }; + returnBannerSizes(mediaTypesBannerSize, '300x600'); + }); + + it('should use appropriate mediaTypes banner sizes as array', function() { + const mediaTypesBannerSize = { + 'mediaTypes': { + 'banner': { + 'sizes': [300, 600] + } + } + }; + returnBannerSizes(mediaTypesBannerSize, ['300x600']); + }); + + it('should fetch floor from floor module if it is available', function() { + let validBidRequestsWithCurrency = [ + { + 'bidder': 'optidigital', + 'bidId': '51ef8751f9aead', + 'params': { + 'publisherId': 's123', + 'placementId': 'Billboard_Top', + 'pageTemplate': 'home', + 'currency': 'USD' + }, + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 50], [300, 250], [300, 600]] + } + }, + 'sizes': [[320, 50], [300, 250], [300, 600]], + 'bidderRequestId': '418b37f85e772c', + 'auctionId': '18fd8b8b0bd757' + } + ] + let floorInfo; + validBidRequestsWithCurrency[0].getFloor = () => floorInfo; + floorInfo = { currency: 'USD', floor: 1.99 }; + let request = spec.buildRequests(validBidRequestsWithCurrency, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.imp[0].bidFloor).to.exist; + }); + + it('should add userEids to payload', function() { + const userIdAsEids = [{ + source: 'pubcid.org', + uids: [{ + id: '121213434342343', + atype: 1 + }] + }]; + validBidRequests[0].userIdAsEids = userIdAsEids; + bidderRequest.userIdAsEids = userIdAsEids; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.user.eids).to.deep.equal(userIdAsEids); + }); + + it('should not add userIdAsEids to payload when userIdAsEids is not present', function() { + validBidRequests[0].userIdAsEids = undefined; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + expect(payload.user).to.deep.equal(undefined); + }); + + function returnBannerSizes(mediaTypes, expectedSizes) { + const bidRequest = Object.assign(validBidRequests[0], mediaTypes); + const request = spec.buildRequests([bidRequest], bidderRequest); + const payload = JSON.parse(request.data); + return payload.imp.forEach(bid => { + if (Array.isArray(expectedSizes)) { + expect(JSON.stringify(bid.sizes)).to.equal(JSON.stringify(expectedSizes)); + } else { + expect(bid.sizes[0]).to.equal(expectedSizes); + } + }); + } + }); + describe('getUserSyncs', function() { + const syncurlIframe = 'https://scripts.opti-digital.com/js/presync.html?endpoint=optidigital'; + let test; + beforeEach(function () { + test = sinon.sandbox.create(); + resetSync(); + }); + afterEach(function() { + test.restore(); + }); + + it('should be executed as in config', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, undefined, undefined)).to.deep.equal([{ + type: 'iframe', url: syncurlIframe + }]); + }); + + it('should return appropriate URL with GDPR equals to 1 and GDPR consent', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=foo` + }]); + }); + it('should return appropriate URL with GDPR equals to 0 and GDPR consent', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurlIframe}&gdpr=0&gdpr_consent=foo` + }]); + }); + it('should return appropriate URL with GDPR equals to 1 and no consent', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=` + }]); + }); + it('should return appropriate URL with GDPR equals to 1, GDPR consent and CCPA consent', function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, {consentString: 'fooUsp'})).to.deep.equal([{ + type: 'iframe', url: `${syncurlIframe}&gdpr=1&gdpr_consent=foo&ccpa_consent=fooUsp` + }]); + }); + }); + describe('interpretResponse', function () { + it('should get bids', function() { + let bids = { + 'body': { + 'bids': [{ + 'transactionId': 'cf5faec3-fcee-4f26-80ae-fc8b6cf23b7d', + 'placementId': 'Billboard_Top', + 'bidId': '83fb53a5e67f49', + 'ttl': 150, + 'creativeId': 'mobile_pos_2', + 'cur': 'USD', + 'cpm': 0.445455, + 'w': '300', + 'h': '600', + 'adm': '', + 'adomain': [] + }] + } + }; + let expectedResponse = [ + { + 'placementId': 'Billboard_Top', + 'requestId': '83fb53a5e67f49', + 'ttl': 150, + 'creativeId': 'mobile_pos_2', + 'currency': 'USD', + 'cpm': 0.445455, + 'width': '300', + 'height': '600', + 'ad': '', + 'netRevenue': true, + 'meta': { + 'advertiserDomains': [] + } + } + ]; + let result = spec.interpretResponse(bids); + expect(result).to.eql(expectedResponse); + }); + + it('should handle empty array bid response', function() { + let bids = { + 'body': { + 'bids': [] + } + }; + let result = spec.interpretResponse(bids); + expect(result.length).to.equal(0); + }); + }); +}); diff --git a/test/spec/modules/optimeraRtdProvider_spec.js b/test/spec/modules/optimeraRtdProvider_spec.js index aec8b79045e..8a9f000bbb9 100644 --- a/test/spec/modules/optimeraRtdProvider_spec.js +++ b/test/spec/modules/optimeraRtdProvider_spec.js @@ -21,13 +21,80 @@ describe('Optimera RTD sub module', () => { }); }); -describe('Optimera RTD score file url is properly set', () => { - it('Proerly set the score file url', () => { +describe('Optimera RTD score file URL is properly set for v0', () => { + it('should properly set the score file URL', () => { + const conf = { + dataProviders: [{ + name: 'optimeraRTD', + params: { + clientID: '9999', + optimeraKeyName: 'optimera', + device: 'de', + apiVersion: 'v0', + } + }] + }; + optimeraRTD.init(conf.dataProviders[0]); + optimeraRTD.setScores(); + expect(optimeraRTD.apiVersion).to.equal('v0'); + expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost:9876/context.html.js'); + }); + + it('should properly set the score file URL without apiVersion set', () => { + const conf = { + dataProviders: [{ + name: 'optimeraRTD', + params: { + clientID: '9999', + optimeraKeyName: 'optimera', + device: 'de', + } + }] + }; + optimeraRTD.init(conf.dataProviders[0]); + optimeraRTD.setScores(); + expect(optimeraRTD.apiVersion).to.equal('v0'); + expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost:9876/context.html.js'); + }); + + it('should properly set the score file URL with an api version other than v0 or v1', () => { + const conf = { + dataProviders: [{ + name: 'optimeraRTD', + params: { + clientID: '9999', + optimeraKeyName: 'optimera', + device: 'de', + apiVersion: 'v15', + } + }] + }; + optimeraRTD.init(conf.dataProviders[0]); optimeraRTD.setScores(); expect(optimeraRTD.scoresURL).to.equal('https://dyv1bugovvq1g.cloudfront.net/9999/localhost:9876/context.html.js'); }); }); +describe('Optimera RTD score file URL is properly set for v1', () => { + it('should properly set the score file URL', () => { + const conf = { + dataProviders: [{ + name: 'optimeraRTD', + params: { + clientID: '9999', + optimeraKeyName: 'optimera', + device: 'de', + apiVersion: 'v1', + } + }] + }; + optimeraRTD.init(conf.dataProviders[0]); + optimeraRTD.setScores(); + expect(optimeraRTD.apiVersion).to.equal('v1'); + expect(optimeraRTD.scoresURL).to.equal('https://v1.oapi26b.com/api/products/scores?c=9999&h=localhost:9876&p=/context.html&s=de'); + }); +}); + describe('Optimera RTD score file properly sets targeting values', () => { const scores = { 'div-0': ['A1', 'A2'], diff --git a/test/spec/modules/optimonAnalyticsAdapter_spec.js b/test/spec/modules/optimonAnalyticsAdapter_spec.js index c50bfcb170f..f1aa00334b5 100644 --- a/test/spec/modules/optimonAnalyticsAdapter_spec.js +++ b/test/spec/modules/optimonAnalyticsAdapter_spec.js @@ -4,6 +4,7 @@ import optimonAnalyticsAdapter from '../../../modules/optimonAnalyticsAdapter.js import adapterManager from 'src/adapterManager'; import * as events from 'src/events'; import constants from 'src/constants.json' +import {expectEvents} from '../../helpers/analytics.js'; const AD_UNIT_CODE = 'demo-adunit-1'; const PUBLISHER_CONFIG = { @@ -14,14 +15,12 @@ const PUBLISHER_CONFIG = { describe('Optimon Analytics Adapter', () => { const optmn_currentWindow = utils.getWindowSelf(); - let optmn_queue = []; beforeEach(() => { - optmn_currentWindow.OptimonAnalyticsAdapter = (...optmn_args) => optmn_queue.push(optmn_args); + optmn_currentWindow.OptimonAnalyticsAdapter = sinon.stub() adapterManager.enableAnalytics({ provider: 'optimon' }); - optmn_queue = [] }); afterEach(() => { @@ -29,12 +28,6 @@ describe('Optimon Analytics Adapter', () => { }); it('should forward all events to the queue', () => { - const optmn_arguments = [AD_UNIT_CODE, PUBLISHER_CONFIG]; - - events.emit(constants.EVENTS.AUCTION_END, optmn_arguments) - events.emit(constants.EVENTS.BID_TIMEOUT, optmn_arguments) - events.emit(constants.EVENTS.BID_WON, optmn_arguments) - - expect(optmn_queue.length).to.eql(3); + expectEvents().to.beBundledTo(optmn_currentWindow.OptimonAnalyticsAdapter); }); }); diff --git a/test/spec/modules/optoutBidAdapter_spec.js b/test/spec/modules/optoutBidAdapter_spec.js index 4d7c25d12bc..a31becdc394 100644 --- a/test/spec/modules/optoutBidAdapter_spec.js +++ b/test/spec/modules/optoutBidAdapter_spec.js @@ -72,21 +72,21 @@ describe('optoutAdapterTest', function () { }]; it('bidRequest HTTP method', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); requests.forEach(function(requestItem) { expect(requestItem.method).to.equal('POST'); }); }); it('bidRequest url without consent', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); requests.forEach(function(requestItem) { expect(requestItem.url).to.match(new RegExp('adscience-nocookie\\.nl/prebid/display')); }); }); it('bidRequest id', function () { - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); expect(requests[0].data.requestId).to.equal('9304jr394ddfj'); expect(requests[1].data.requestId).to.equal('893j4f94e8jei'); }); @@ -99,7 +99,7 @@ describe('optoutAdapterTest', function () { } }) - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); expect(requests[0].data.cur.adServerCurrency).to.equal('USD'); expect(requests[1].data.cur.adServerCurrency).to.equal('USD'); }); @@ -107,7 +107,7 @@ describe('optoutAdapterTest', function () { it('bidRequest without config for currency', function () { config.resetConfig(); - const requests = spec.buildRequests(bidRequests); + const requests = spec.buildRequests(bidRequests, {}); expect(requests[0].data.cur.adServerCurrency).to.equal('EUR'); expect(requests[1].data.cur.adServerCurrency).to.equal('EUR'); }); diff --git a/test/spec/modules/orbidderBidAdapter_spec.js b/test/spec/modules/orbidderBidAdapter_spec.js index 750524cf47f..5af5a4d710f 100644 --- a/test/spec/modules/orbidderBidAdapter_spec.js +++ b/test/spec/modules/orbidderBidAdapter_spec.js @@ -1,6 +1,6 @@ -import {expect} from 'chai'; -import {spec} from 'modules/orbidderBidAdapter.js'; -import {newBidder} from 'src/adapters/bidderFactory.js'; +import { expect } from 'chai'; +import { spec } from 'modules/orbidderBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; import * as _ from 'lodash'; import { BANNER, NATIVE } from '../../../src/mediaTypes.js'; @@ -9,7 +9,11 @@ describe('orbidderBidAdapter', () => { const defaultBidRequestBanner = { bidId: 'd66fa86787e0b0ca900a96eacfd5f0bb', auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d8', - transactionId: 'd58851660c0c4461e4aa06344fc9c0c6', + ortb2Imp: { + ext: { + tid: 'd58851660c0c4461e4aa06344fc9c0c6', + } + }, bidRequestCount: 1, adUnitCode: 'adunit-code', sizes: [[300, 250], [300, 600]], @@ -27,7 +31,11 @@ describe('orbidderBidAdapter', () => { const defaultBidRequestNative = { bidId: 'd66fa86787e0b0ca900a96eacfd5f0bc', auctionId: 'ccc4c7cdfe11cfbd74065e6dd28413d9', - transactionId: 'd58851660c0c4461e4aa06344fc9c0c7', + ortb2Imp: { + ext: { + tid: 'd58851660c0c4461e4aa06344fc9c0c7', + } + }, bidRequestCount: 1, adUnitCode: 'adunit-code-native', sizes: [], @@ -51,7 +59,7 @@ describe('orbidderBidAdapter', () => { } }; - const deepClone = function (val) { + const deepClone = function(val) { return JSON.parse(JSON.stringify(val)); }; @@ -63,7 +71,7 @@ describe('orbidderBidAdapter', () => { return spec.buildRequests(buildRequest, { ...bidderRequest || {}, refererInfo: { - referer: 'https://localhost:9876/' + page: 'https://localhost:9876/' } })[0]; }; @@ -83,15 +91,15 @@ describe('orbidderBidAdapter', () => { expect(spec.isBidRequestValid(defaultBidRequestNative)).to.equal(true); }); - it('banner: accepts optional profile object', () => { + it('banner: accepts optional keyValues object', () => { const bidRequest = deepClone(defaultBidRequestBanner); - bidRequest.params.profile = {'key': 'value'}; + bidRequest.params.keyValues = { 'key': 'value' }; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); - it('native: accepts optional profile object', () => { + it('native: accepts optional keyValues object', () => { const bidRequest = deepClone(defaultBidRequestNative); - bidRequest.params.profile = {'key': 'value'}; + bidRequest.params.keyValues = { 'key': 'value' }; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); @@ -107,15 +115,15 @@ describe('orbidderBidAdapter', () => { expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); - it('banner: doesn\'t accept malformed profile', () => { + it('banner: doesn\'t accept malformed keyValues', () => { const bidRequest = deepClone(defaultBidRequestBanner); - bidRequest.params.profile = 'another not usable string'; + bidRequest.params.keyValues = 'another not usable string'; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); - it('native: doesn\'t accept malformed profile', () => { + it('native: doesn\'t accept malformed keyValues', () => { const bidRequest = deepClone(defaultBidRequestNative); - bidRequest.params.profile = 'another not usable string'; + bidRequest.params.keyValues = 'another not usable string'; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); @@ -151,8 +159,11 @@ describe('orbidderBidAdapter', () => { }); describe('buildRequests', () => { - const request = buildRequest(defaultBidRequestBanner); - const nativeRequest = buildRequest(defaultBidRequestNative); + let request, nativeRequest; + before(() => { + request = buildRequest(defaultBidRequestBanner); + nativeRequest = buildRequest(defaultBidRequestNative); + }) it('sends bid request to endpoint via https using post', () => { expect(request.method).to.equal('POST'); @@ -170,7 +181,7 @@ describe('orbidderBidAdapter', () => { expect(request.data.bidId).to.equal(defaultBidRequestBanner.bidId); expect(request.data.auctionId).to.equal(defaultBidRequestBanner.auctionId); - expect(request.data.transactionId).to.equal(defaultBidRequestBanner.transactionId); + expect(request.data.transactionId).to.equal(defaultBidRequestBanner.ortb2Imp.ext.tid); expect(request.data.bidRequestCount).to.equal(defaultBidRequestBanner.bidRequestCount); expect(request.data.adUnitCode).to.equal(defaultBidRequestBanner.adUnitCode); expect(request.data.pageUrl).to.equal('https://localhost:9876/'); @@ -187,7 +198,7 @@ describe('orbidderBidAdapter', () => { expect(nativeRequest.data.bidId).to.equal(defaultBidRequestNative.bidId); expect(nativeRequest.data.auctionId).to.equal(defaultBidRequestNative.auctionId); - expect(nativeRequest.data.transactionId).to.equal(defaultBidRequestNative.transactionId); + expect(nativeRequest.data.transactionId).to.equal(defaultBidRequestNative.ortb2Imp.ext.tid); expect(nativeRequest.data.bidRequestCount).to.equal(defaultBidRequestNative.bidRequestCount); expect(nativeRequest.data.adUnitCode).to.equal(defaultBidRequestNative.adUnitCode); expect(nativeRequest.data.pageUrl).to.equal('https://localhost:9876/'); @@ -283,7 +294,7 @@ describe('orbidderBidAdapter', () => { }); }); - describe('buildRequests with price floor module', () => { + it('buildRequests with price floor module', () => { const bidRequest = deepClone(defaultBidRequestBanner); bidRequest.params.bidfloor = 1; bidRequest.getFloor = (floorObj) => { @@ -336,7 +347,7 @@ describe('orbidderBidAdapter', () => { } ]; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(expectedResponse.length); expect(_.isEqual(expectedResponse, serverResponse)).to.be.true; }); @@ -376,7 +387,7 @@ describe('orbidderBidAdapter', () => { } ]; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(expectedResponse.length); Object.keys(expectedResponse[0]).forEach((key) => { @@ -443,7 +454,7 @@ describe('orbidderBidAdapter', () => { } ]; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(expectedResponse.length); expect(_.isEqual(expectedResponse, serverResponse)).to.be.true; @@ -463,7 +474,7 @@ describe('orbidderBidAdapter', () => { 'netRevenue': true, } ]; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(0); }); @@ -481,7 +492,7 @@ describe('orbidderBidAdapter', () => { 'creativeId': '29681110', } ]; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(0); }); @@ -507,13 +518,13 @@ describe('orbidderBidAdapter', () => { } } ]; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(0); }); it('handles nobid responses', () => { const serverResponse = []; - const result = spec.interpretResponse({body: serverResponse}); + const result = spec.interpretResponse({ body: serverResponse }); expect(result.length).to.equal(0); }); }); diff --git a/test/spec/modules/orbitsoftBidAdapter_spec.js b/test/spec/modules/orbitsoftBidAdapter_spec.js new file mode 100644 index 00000000000..8c3187e9324 --- /dev/null +++ b/test/spec/modules/orbitsoftBidAdapter_spec.js @@ -0,0 +1,255 @@ +import {expect} from 'chai'; +import {spec} from 'modules/orbitsoftBidAdapter.js'; + +const ENDPOINT_URL = 'https://orbitsoft.com/php/ads/hb.phps'; +const REFERRER_URL = 'http://referrer.url/?_='; + +describe('Orbitsoft adapter', function () { + describe('implementation', function () { + describe('for requests', function () { + it('should accept valid bid', function () { + let validBid = { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL + } + }, + isValid = spec.isBidRequestValid(validBid); + + expect(isValid).to.equal(true); + }); + + it('should reject invalid bid', function () { + let invalidBid = { + bidder: 'orbitsoft' + }, + isValid = spec.isBidRequestValid(invalidBid); + + expect(isValid).to.equal(false); + }); + }); + describe('for requests', function () { + it('should accept valid bid with styles', function () { + let validBid = { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL, + style: { + title: { + family: 'Tahoma', + size: 'medium', + weight: 'normal', + style: 'normal', + color: '0053F9' + }, + description: { + family: 'Tahoma', + size: 'medium', + weight: 'normal', + style: 'normal', + color: '0053F9' + }, + url: { + family: 'Tahoma', + size: 'medium', + weight: 'normal', + style: 'normal', + color: '0053F9' + }, + colors: { + background: 'ffffff', + border: 'E0E0E0', + link: '5B99FE' + } + } + }, + refererInfo: {referer: REFERRER_URL}, + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + + let buildRequest = spec.buildRequests([validBid])[0]; + let requestUrl = buildRequest.url; + let requestUrlParams = buildRequest.data; + expect(requestUrl).to.equal(ENDPOINT_URL); + expect(requestUrlParams).have.property('f1', 'Tahoma'); + expect(requestUrlParams).have.property('fs1', 'medium'); + expect(requestUrlParams).have.property('w1', 'normal'); + expect(requestUrlParams).have.property('s1', 'normal'); + expect(requestUrlParams).have.property('c3', '0053F9'); + expect(requestUrlParams).have.property('f2', 'Tahoma'); + expect(requestUrlParams).have.property('fs2', 'medium'); + expect(requestUrlParams).have.property('w2', 'normal'); + expect(requestUrlParams).have.property('s2', 'normal'); + expect(requestUrlParams).have.property('c4', '0053F9'); + expect(requestUrlParams).have.property('f3', 'Tahoma'); + expect(requestUrlParams).have.property('fs3', 'medium'); + expect(requestUrlParams).have.property('w3', 'normal'); + expect(requestUrlParams).have.property('s3', 'normal'); + expect(requestUrlParams).have.property('c5', '0053F9'); + expect(requestUrlParams).have.property('c2', 'ffffff'); + expect(requestUrlParams).have.property('c1', 'E0E0E0'); + expect(requestUrlParams).have.property('c6', '5B99FE'); + }); + + it('should accept valid bid with custom params', function () { + let validBid = { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL, + customParams: { + cacheBuster: 'bf4d7c1', + clickUrl: 'http://testclickurl.com' + } + }, + refererInfo: {referer: REFERRER_URL}, + }, + isValid = spec.isBidRequestValid(validBid); + expect(isValid).to.equal(true); + + let buildRequest = spec.buildRequests([validBid])[0]; + let requestUrlCustomParams = buildRequest.data; + expect(requestUrlCustomParams).have.property('c.cacheBuster', 'bf4d7c1'); + expect(requestUrlCustomParams).have.property('c.clickUrl', 'http://testclickurl.com'); + }); + + it('should reject invalid bid without requestUrl', function () { + let invalidBid = { + bidder: 'orbitsoft', + params: { + placementId: '123' + } + }, + isValid = spec.isBidRequestValid(invalidBid); + + expect(isValid).to.equal(false); + }); + + it('should reject invalid bid without placementId', function () { + let invalidBid = { + bidder: 'orbitsoft', + params: { + requestUrl: ENDPOINT_URL + } + }, + isValid = spec.isBidRequestValid(invalidBid); + + expect(isValid).to.equal(false); + }); + }); + describe('bid responses', function () { + it('should return complete bid response', function () { + let serverResponse = { + body: { + callback_uid: '265b29b70cc106', + cpm: 0.5, + width: 240, + height: 240, + content_url: 'https://orbitsoft.com/php/ads/hb.html', + adomain: ['test.adomain.tld'] + } + }; + + let bidRequests = [ + { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL + } + } + ]; + let bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + expect(bids).to.be.lengthOf(1); + expect(bids[0].cpm).to.equal(serverResponse.body.cpm); + expect(bids[0].width).to.equal(serverResponse.body.width); + expect(bids[0].height).to.equal(serverResponse.body.height); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[0].adUrl).to.have.length.above(1); + expect(bids[0].adUrl).to.have.string('https://orbitsoft.com/php/ads/hb.html'); + expect(Object.keys(bids[0].meta)).to.include.members(['advertiserDomains']); + expect(bids[0].meta.advertiserDomains).to.deep.equal(serverResponse.body.adomain); + }); + + it('should return empty bid response', function () { + let bidRequests = [ + { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL + } + } + ]; + let serverResponse = { + body: { + callback_uid: '265b29b70cc106', + cpm: 0 + } + }, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response on incorrect size', function () { + let bidRequests = [ + { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL + } + } + ]; + let serverResponse = { + body: { + callback_uid: '265b29b70cc106', + cpm: 1.5, + width: 0, + height: 0 + } + }, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response with error', function () { + let bidRequests = [ + { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL + } + } + ]; + let serverResponse = {error: 'error'}, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(0); + }); + + it('should return empty bid response on empty body', function () { + let bidRequests = [ + { + bidder: 'orbitsoft', + params: { + placementId: '123', + requestUrl: ENDPOINT_URL + } + } + ]; + let serverResponse = {}, + bids = spec.interpretResponse(serverResponse, {'bidRequest': bidRequests[0]}); + + expect(bids).to.be.lengthOf(0); + }); + }); + }); +}); diff --git a/test/spec/modules/otmBidAdapter_spec.js b/test/spec/modules/otmBidAdapter_spec.js index 6eb5768c3af..27da17b8415 100644 --- a/test/spec/modules/otmBidAdapter_spec.js +++ b/test/spec/modules/otmBidAdapter_spec.js @@ -2,7 +2,7 @@ import {expect} from 'chai'; import {spec} from 'modules/otmBidAdapter'; describe('otmBidAdapter', function () { - it('validate_pub_params', function () { + it('pub_params', function () { expect(spec.isBidRequestValid({ bidder: 'otm', params: { @@ -12,31 +12,52 @@ describe('otmBidAdapter', function () { })).to.equal(true); }); - it('validate_generated_params', function () { - let bidRequestData = [{ + it('generated_params common case', function () { + const bidRequestData = [{ bidId: 'bid1234', bidder: 'otm', params: { tid: '123', - bidfloor: 20 + bidfloor: 20, + domain: 'github.com' }, sizes: [[240, 400]] }]; - let request = spec.buildRequests(bidRequestData); - let req_data = request[0].data; + const request = spec.buildRequests(bidRequestData); + const req_data = request[0].data; expect(req_data.bidid).to.equal('bid1234'); + expect(req_data.domain).to.equal('github.com'); + }); + + it('generated_params should return top level origin as domain if not defined', function () { + const bidRequestData = [{ + bidId: 'bid1234', + bidder: 'otm', + params: { + tid: '123', + bidfloor: 20 + }, + sizes: [[240, 400]] + }]; + + const bidderRequest = {refererInfo: {page: `https://github.com:3000/`, domain: 'github.com:3000'}} + + const request = spec.buildRequests(bidRequestData, bidderRequest); + const req_data = request[0].data; + + expect(req_data.domain).to.equal(`github.com:3000`); }); - it('validate_response_params', function () { - let bidRequestData = { + it('response_params common case', function () { + const bidRequestData = { data: { bidId: 'bid1234' } }; - let serverResponse = { + const serverResponse = { body: [ { 'auctionid': '3c6f8e22-541b-485c-9214-e974d9fb1b6f', @@ -53,9 +74,9 @@ describe('otmBidAdapter', function () { ] }; - let bids = spec.interpretResponse(serverResponse, bidRequestData); + const bids = spec.interpretResponse(serverResponse, bidRequestData); expect(bids).to.have.lengthOf(1); - let bid = bids[0]; + const bid = bids[0]; expect(bid.cpm).to.equal(847.097); expect(bid.currency).to.equal('RUB'); expect(bid.width).to.equal(240); diff --git a/test/spec/modules/outbrainBidAdapter_spec.js b/test/spec/modules/outbrainBidAdapter_spec.js index 5dbdd049d82..d8690aeb6a5 100644 --- a/test/spec/modules/outbrainBidAdapter_spec.js +++ b/test/spec/modules/outbrainBidAdapter_spec.js @@ -1,8 +1,7 @@ -import {expect} from 'chai'; -import {spec} from 'modules/outbrainBidAdapter.js'; -import {config} from 'src/config.js'; -import {server} from 'test/mocks/xhr'; -import { createEidsArray } from 'modules/userId/eids.js'; +import { expect } from 'chai'; +import { spec } from 'modules/outbrainBidAdapter.js'; +import { config } from 'src/config.js'; +import { server } from 'test/mocks/xhr'; describe('Outbrain Adapter', function () { describe('Bid request and response', function () { @@ -45,6 +44,26 @@ describe('Outbrain Adapter', function () { ] } + const videoBidRequestParams = { + mediaTypes: { + video: { + playerSize: [[640, 480]], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [1], + skip: 1, + api: [2], + minbitrate: 1000, + maxbitrate: 3000, + minduration: 3, + maxduration: 10, + startdelay: 2, + placement: 4, + linearity: 1 + } + } + } + describe('isBidRequestValid', function () { before(() => { config.setConfig({ @@ -93,6 +112,34 @@ describe('Outbrain Adapter', function () { } expect(spec.isBidRequestValid(bid)).to.equal(true) }) + it('should succeed when bid contains video', function () { + const bid = { + bidder: 'outbrain', + params: { + publisher: { + id: 'publisher-id', + } + }, + ...videoBidRequestParams, + } + expect(spec.isBidRequestValid(bid)).to.equal(true) + }) + it('should fail when bid contains insufficient video information', function () { + const bid = { + bidder: 'outbrain', + params: { + publisher: { + id: 'publisher-id', + } + }, + mediaTypes: { + video: { + context: 'outstream' + } + }, + } + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) it('should fail if publisher id is not set', function () { const bid = { bidder: 'outbrain', @@ -179,8 +226,9 @@ describe('Outbrain Adapter', function () { }) const commonBidderRequest = { + bidderRequestId: 'mock-uuid', refererInfo: { - referer: 'https://example.com/' + page: 'https://example.com/' } } @@ -215,6 +263,7 @@ describe('Outbrain Adapter', function () { ] } const expectedData = { + id: 'mock-uuid', site: { page: 'https://example.com/', publisher: { @@ -257,6 +306,7 @@ describe('Outbrain Adapter', function () { ...displayBidRequestParams, } const expectedData = { + id: 'mock-uuid', site: { page: 'https://example.com/', publisher: { @@ -298,6 +348,62 @@ describe('Outbrain Adapter', function () { expect(res.data).to.deep.equal(JSON.stringify(expectedData)) }) + it('should build video request', function () { + const bidRequest = { + ...commonBidRequest, + ...videoBidRequestParams, + } + const expectedData = { + id: 'mock-uuid', + site: { + page: 'https://example.com/', + publisher: { + id: 'publisher-id' + } + }, + device: { + ua: navigator.userAgent + }, + source: { + fd: 1 + }, + cur: [ + 'USD' + ], + imp: [ + { + id: '1', + video: { + w: 640, + h: 480, + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [1], + mimes: ['video/mp4'], + skip: 1, + api: [2], + minbitrate: 1000, + maxbitrate: 3000, + minduration: 3, + maxduration: 10, + startdelay: 2, + placement: 4, + linearity: 1 + } + } + ], + ext: { + prebid: { + channel: { + name: 'pbjs', version: '$prebid.version$' + } + } + } + } + const res = spec.buildRequests([bidRequest], commonBidderRequest) + expect(res.url).to.equal('https://bidder-url.com') + expect(res.data).to.deep.equal(JSON.stringify(expectedData)) + }) + it('should pass optional parameters in request', function () { const bidRequest = { ...commonBidRequest, @@ -318,6 +424,27 @@ describe('Outbrain Adapter', function () { expect(resData.badv).to.deep.equal(['bad-advertiser']) }); + it('first party data', function () { + const bidRequest = { + ...commonBidRequest, + ...nativeBidRequestParams, + } + const bidderRequest = { + ortb2: { + bcat: ['IAB1', 'IAB2-1'], + badv: ['domain1.com', 'domain2.com'], + wlang: ['en'], + }, + ...commonBidderRequest, + } + + const res = spec.buildRequests([bidRequest], bidderRequest) + const resData = JSON.parse(res.data) + expect(resData.bcat).to.deep.equal(bidderRequest.ortb2.bcat) + expect(resData.badv).to.deep.equal(bidderRequest.ortb2.badv) + expect(resData.wlang).to.deep.equal(bidderRequest.ortb2.wlang) + }); + it('should pass bidder timeout', function () { const bidRequest = { ...commonBidRequest, @@ -369,7 +496,7 @@ describe('Outbrain Adapter', function () { ...commonBidRequest, ...nativeBidRequestParams, } - config.setConfig({coppa: true}) + config.setConfig({ coppa: true }) const res = spec.buildRequests([bidRequest], commonBidderRequest) const resData = JSON.parse(res.data) @@ -382,16 +509,16 @@ describe('Outbrain Adapter', function () { let bidRequest = { bidId: 'bidId', params: {}, - userIdAsEids: createEidsArray({ - idl_env: 'id-value', - }), + userIdAsEids: [ + { source: 'liveramp.com', uids: [{ id: 'id-value', atype: 3 }] } + ], ...commonBidRequest, }; let res = spec.buildRequests([bidRequest], commonBidderRequest); const resData = JSON.parse(res.data) expect(resData.user.ext.eids).to.deep.equal([ - {source: 'liveramp.com', uids: [{id: 'id-value', atype: 3}]} + { source: 'liveramp.com', uids: [{ id: 'id-value', atype: 3 }] } ]); }); @@ -400,7 +527,7 @@ describe('Outbrain Adapter', function () { ...commonBidRequest, ...nativeBidRequestParams, } - bidRequest.getFloor = function() { + bidRequest.getFloor = function () { return { currency: 'USD', floor: 1.23, @@ -598,6 +725,67 @@ describe('Outbrain Adapter', function () { const res = spec.interpretResponse(serverResponse, request) expect(res).to.deep.equal(expectedRes) }); + + it('should interpret video response', function () { + const serverResponse = { + body: { + id: '123', + seatbid: [ + { + bid: [ + { + id: '111', + impid: '1', + price: 1.1, + adm: '\u003cVAST version="3.0"\u003e\u003cAd\u003e\u003cInLine\u003e\u003cAdSystem\u003ezemanta\u003c/AdSystem\u003e\u003cAdTitle\u003e1\u003c/AdTitle\u003e\u003cImpression\u003ehttp://win.com\u003c/Impression\u003e\u003cImpression\u003ehttp://example.com/imptracker\u003c/Impression\u003e\u003cCreatives\u003e\u003cCreative\u003e\u003cLinear\u003e\u003cDuration\u003e00:00:25\u003c/Duration\u003e\u003cTrackingEvents\u003e\u003cTracking event="start"\u003ehttp://example.com/start\u003c/Tracking\u003e\u003cTracking event="progress" offset="00:00:03"\u003ehttp://example.com/p3s\u003c/Tracking\u003e\u003c/TrackingEvents\u003e\u003cVideoClicks\u003e\u003cClickThrough\u003ehttp://link.com\u003c/ClickThrough\u003e\u003c/VideoClicks\u003e\u003cMediaFiles\u003e\u003cMediaFile delivery="progressive" type="video/mp4" bitrate="700" width="640" height="360"\u003ehttps://example.com/123_360p.mp4\u003c/MediaFile\u003e\u003c/MediaFiles\u003e\u003c/Linear\u003e\u003c/Creative\u003e\u003c/Creatives\u003e\u003c/InLine\u003e\u003c/Ad\u003e\u003c/VAST\u003e', + adid: '100', + cid: '5', + crid: '29998660', + cat: ['cat-1'], + adomain: [ + 'example.com' + ], + nurl: 'http://example.com/win/${AUCTION_PRICE}' + } + ], + seat: '100', + group: 1 + } + ], + bidid: '456', + cur: 'USD' + } + } + const request = { + bids: [ + { + ...commonBidRequest, + ...videoBidRequestParams + } + ] + } + const expectedRes = [ + { + requestId: request.bids[0].bidId, + cpm: 1.1, + creativeId: '29998660', + ttl: 360, + netRevenue: false, + currency: 'USD', + mediaType: 'video', + nurl: 'http://example.com/win/${AUCTION_PRICE}', + vastXml: 'zemanta1http://win.comhttp://example.com/imptracker00:00:25http://example.com/starthttp://example.com/p3shttp://link.comhttps://example.com/123_360p.mp4', + meta: { + 'advertiserDomains': [ + 'example.com' + ] + }, + } + ] + + const res = spec.interpretResponse(serverResponse, request) + expect(res).to.deep.equal(expectedRes) + }); }) }) @@ -616,41 +804,41 @@ describe('Outbrain Adapter', function () { }) it('should return user sync if pixel enabled with outbrain config', function () { - const ret = spec.getUserSyncs({pixelEnabled: true}) - expect(ret).to.deep.equal([{type: 'image', url: usersyncUrl}]) + const ret = spec.getUserSyncs({ pixelEnabled: true }) + expect(ret).to.deep.equal([{ type: 'image', url: usersyncUrl }]) }) it('should not return user sync if pixel disabled', function () { - const ret = spec.getUserSyncs({pixelEnabled: false}) + const ret = spec.getUserSyncs({ pixelEnabled: false }) expect(ret).to.be.an('array').that.is.empty }) it('should not return user sync if url is not set', function () { config.resetConfig() - const ret = spec.getUserSyncs({pixelEnabled: true}) + const ret = spec.getUserSyncs({ pixelEnabled: true }) expect(ret).to.be.an('array').that.is.empty }) - it('should pass GDPR consent', function() { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, undefined)).to.deep.equal([{ + it('should pass GDPR consent', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, undefined)).to.deep.equal([{ type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo` }]); - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: 'foo'}, undefined)).to.deep.equal([{ + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: false, consentString: 'foo' }, undefined)).to.deep.equal([{ type: 'image', url: `${usersyncUrl}?gdpr=0&gdpr_consent=foo` }]); - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: undefined}, undefined)).to.deep.equal([{ + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: true, consentString: undefined }, undefined)).to.deep.equal([{ type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=` }]); }); - it('should pass US consent', function() { + it('should pass US consent', function () { expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, '1NYN')).to.deep.equal([{ type: 'image', url: `${usersyncUrl}?us_privacy=1NYN` }]); }); - it('should pass GDPR and US consent', function() { - expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'foo'}, '1NYN')).to.deep.equal([{ + it('should pass GDPR and US consent', function () { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, { gdprApplies: true, consentString: 'foo' }, '1NYN')).to.deep.equal([{ type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN` }]); }); diff --git a/test/spec/modules/oxxionAnalyticsAdapter_spec.js b/test/spec/modules/oxxionAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..13dc395968a --- /dev/null +++ b/test/spec/modules/oxxionAnalyticsAdapter_spec.js @@ -0,0 +1,348 @@ +import oxxionAnalytics from 'modules/oxxionAnalyticsAdapter.js'; +import {dereferenceWithoutRenderer} from 'modules/oxxionAnalyticsAdapter.js'; +import { expect } from 'chai'; +import { server } from 'test/mocks/xhr.js'; +let adapterManager = require('src/adapterManager').default; +let events = require('src/events'); +let constants = require('src/constants.json'); + +describe('Oxxion Analytics', function () { + let timestamp = new Date() - 256; + let auctionId = '5018eb39-f900-4370-b71e-3bb5b48d324f'; + let timeout = 1500; + + let bidTimeout = [ + { + 'bidId': '5fe418f2d70364', + 'bidder': 'appnexusAst', + 'adUnitCode': 'tag_200124_banner', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b' + } + ]; + + const auctionEnd = { + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'timestamp': 1647424261187, + 'auctionEnd': 1647424261714, + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': 'tag_200124_banner', + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 600 + ] + ] + } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 123456 + } + }, + { + 'bidder': 'appnexusAst', + 'params': { + 'placementId': 234567 + } + } + ], + 'sizes': [ + [ + 300, + 600 + ] + ], + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40' + } + ], + 'adUnitCodes': [ + 'tag_200124_banner' + ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'bidderRequestId': '11dc6ff6378de7', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': 123456 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'tag_200124_banner', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40', + 'sizes': [ + [ + 300, + 600 + ] + ], + 'bidId': '34a63e5d5378a3', + 'bidderRequestId': '11dc6ff6378de7', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1647424261187, + 'timeout': 1000, + 'gdprConsent': { + 'consentString': 'CONSENT', + 'gdprApplies': true, + 'apiVersion': 2, + 'vendorData': 'a lot of borring stuff', + }, + 'start': 1647424261189 + }, + ], + 'noBids': [ + { + 'bidder': 'appnexusAst', + 'params': { + 'placementId': 10471298 + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 600 + ] + ] + } + }, + 'adUnitCode': 'tag_200124_banner', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40', + 'sizes': [ + [ + 300, + 600 + ] + ], + 'bidId': '5fe418f2d70364', + 'bidderRequestId': '4229a45ab8ea87', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'bidsReceived': [ + { + 'bidderCode': 'appnexus', + 'width': 300, + 'height': 600, + 'statusMessage': 'Bid available', + 'adId': '7a4ced80f33d33', + 'requestId': '34a63e5d5378a3', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'mediaType': 'video', + 'source': 'client', + 'cpm': 27.4276, + 'creativeId': '158534630', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 2000, + 'ad': 'some html', + 'meta': { + 'advertiserDomains': [ + 'example.com' + ], + 'demandSource': 'something' + }, + 'renderer': 'something', + 'originalCpm': 25.02521, + 'originalCurrency': 'EUR', + 'responseTimestamp': 1647424261559, + 'requestTimestamp': 1647424261189, + 'bidder': 'appnexus', + 'adUnitCode': 'tag_200124_banner', + 'timeToRespond': 370, + 'pbLg': '5.00', + 'pbMg': '20.00', + 'pbHg': '20.00', + 'pbAg': '20.00', + 'pbDg': '20.00', + 'pbCg': '20.000000', + 'size': '300x600', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '7a4ced80f33d33', + 'hb_pb': '20.000000', + 'hb_size': '300x600', + 'hb_source': 'client', + 'hb_format': 'banner', + 'hb_adomain': 'example.com' + } + } + ], + 'winningBids': [ + + ], + 'timeout': 1000 + }; + + let bidWon = { + 'bidderCode': 'appnexus', + 'width': 970, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '65d16ef039a97a', + 'requestId': '2bd3e8ff8a113f', + 'transactionId': '8b2a8629-d1ea-4bb1-aff0-e335b96dd002', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 27.4276, + 'creativeId': '158533702', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 2000, + 'ad': 'some html', + 'meta': { + 'advertiserDomains': [ + 'example.com' + ] + }, + 'renderer': 'something', + 'originalCpm': 25.02521, + 'originalCurrency': 'EUR', + 'responseTimestamp': 1647424261558, + 'requestTimestamp': 1647424261189, + 'bidder': 'appnexus', + 'adUnitCode': 'tag_200123_banner', + 'timeToRespond': 369, + 'originalBidder': 'appnexus', + 'pbLg': '5.00', + 'pbMg': '20.00', + 'pbHg': '20.00', + 'pbAg': '20.00', + 'pbDg': '20.00', + 'pbCg': '20.000000', + 'size': '970x250', + 'adserverTargeting': { + 'hb_bidder': 'appnexus', + 'hb_adid': '65d16ef039a97a', + 'hb_pb': '20.000000', + 'hb_size': '970x250', + 'hb_source': 'client', + 'hb_format': 'banner', + 'hb_adomain': 'example.com' + }, + 'status': 'rendered', + 'params': [ + { + 'placementId': 123456 + } + ] + }; + + after(function () { + oxxionAnalytics.disableAnalytics(); + }); + + describe('main test flow', function () { + beforeEach(function () { + sinon.stub(events, 'getEvents').returns([]); + sinon.spy(oxxionAnalytics, 'track'); + }); + afterEach(function () { + events.getEvents.restore(); + oxxionAnalytics.disableAnalytics(); + oxxionAnalytics.track.restore(); + }); + it('test dereferenceWithoutRenderer', function () { + adapterManager.registerAnalyticsAdapter({ + code: 'oxxion', + adapter: oxxionAnalytics + }); + + adapterManager.enableAnalytics({ + provider: 'oxxion', + options: { + domain: 'test' + } + }); + let resultBidWon = JSON.parse(dereferenceWithoutRenderer(bidWon)); + expect(resultBidWon).not.to.have.property('renderer'); + let resultBid = JSON.parse(dereferenceWithoutRenderer(auctionEnd)); + expect(resultBid).to.have.property('bidsReceived').and.to.have.lengthOf(1); + expect(resultBid.bidsReceived[0]).not.to.have.property('renderer'); + }); + it('test auctionEnd', function () { + adapterManager.registerAnalyticsAdapter({ + code: 'oxxion', + adapter: oxxionAnalytics + }); + + adapterManager.enableAnalytics({ + provider: 'oxxion', + options: { + domain: 'test' + } + }); + + events.emit(constants.EVENTS.BID_REQUESTED, auctionEnd['bidderRequests'][0]); + events.emit(constants.EVENTS.BID_RESPONSE, auctionEnd['bidsReceived'][0]); + events.emit(constants.EVENTS.BID_TIMEOUT, bidTimeout); + events.emit(constants.EVENTS.AUCTION_END, auctionEnd); + expect(server.requests.length).to.equal(1); + let message = JSON.parse(server.requests[0].requestBody); + expect(message).to.have.property('auctionEnd').exist; + expect(message.auctionEnd).to.have.lengthOf(1); + expect(message.auctionEnd[0]).to.have.property('bidsReceived').and.to.have.lengthOf(1); + expect(message.auctionEnd[0].bidsReceived[0]).not.to.have.property('ad'); + expect(message.auctionEnd[0].bidsReceived[0]).to.have.property('meta'); + expect(message.auctionEnd[0].bidsReceived[0].meta).to.have.property('advertiserDomains'); + expect(message.auctionEnd[0].bidsReceived[0].meta).to.have.property('demandSource'); + expect(message.auctionEnd[0].bidsReceived[0]).to.have.property('adId'); + expect(message.auctionEnd[0]).to.have.property('bidderRequests').and.to.have.lengthOf(1); + expect(message.auctionEnd[0].bidderRequests[0]).to.have.property('gdprConsent'); + expect(message.auctionEnd[0].bidderRequests[0].gdprConsent).not.to.have.property('vendorData'); + expect(message.auctionEnd[0].bidderRequests[0]).to.have.property('oxxionMode'); + }); + + it('test bidWon', function() { + window.OXXION_MODE = {'abtest': true}; + adapterManager.registerAnalyticsAdapter({ + code: 'oxxion', + adapter: oxxionAnalytics + }); + + adapterManager.enableAnalytics({ + provider: 'oxxion', + options: { + domain: 'test' + } + }); + events.emit(constants.EVENTS.BID_WON, bidWon); + expect(server.requests.length).to.equal(1); + let message = JSON.parse(server.requests[0].requestBody); + expect(message).not.to.have.property('ad'); + expect(message).to.have.property('adId') + expect(message).to.have.property('cpmIncrement').and.to.equal(27.4276); + expect(message).to.have.property('oxxionMode').and.to.have.property('abtest').and.to.equal(true); + // sinon.assert.callCount(oxxionAnalytics.track, 1); + }); + }); +}); diff --git a/test/spec/modules/oxxionRtdProvider_spec.js b/test/spec/modules/oxxionRtdProvider_spec.js new file mode 100644 index 00000000000..7bccf2319a4 --- /dev/null +++ b/test/spec/modules/oxxionRtdProvider_spec.js @@ -0,0 +1,255 @@ +import {oxxionSubmodule} from 'modules/oxxionRtdProvider.js'; +import 'src/prebid.js'; + +const utils = require('src/utils.js'); + +const moduleConfig = { + params: { + domain: 'test.endpoint', + contexts: ['instream', 'outstream'], + samplingRate: 10, + threshold: false, + bidders: ['appnexus', 'mediasquare'], + } +}; + +let request = { + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'timestamp': 1647424261187, + 'auctionEnd': 1647424261714, + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': 'msq_tag_200124_banner', + 'mediaTypes': { 'banner': { 'sizes': [[300, 600]] } }, + 'bids': [{'bidder': 'appnexus', 'params': {'placementId': 123456}}], + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b40' + }, + { + 'code': 'msq_tag_200125_video', + 'mediaTypes': { 'video': { 'context': 'instream' }, playerSize: [640, 480], mimes: ['video/mp4'] }, + 'bids': [ + {'bidder': 'mediasquare', 'params': {'code': 'publishername_atf_desktop_rg_video', 'owner': 'test'}}, + {'bidder': 'appnexusAst', 'params': {'placementId': 345678}}, + ], + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b41' + }, + { + 'code': 'msq_tag_200125_banner', + 'mediaTypes': { 'banner': { 'sizes': [[300, 250]] } }, + 'bids': [ + {'bidder': 'appnexusAst', 'params': {'placementId': 345678}}, + ], + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b41' + } + ] +}; + +let bids = [{ + 'bidderCode': 'mediasquare', + 'width': 640, + 'height': 480, + 'statusMessage': 'Bid available', + 'adId': '3647626fdbe68a', + 'requestId': '2d891705d2125b', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b41', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'mediaType': 'video', + 'source': 'client', + 'cpm': 0.9723, + 'creativeId': 'freewheel|AdswizzAd71819', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 2000, + 'mediasquare': { + 'bidder': 'freewheel', + 'code': 'test/publishername_atf_desktop_rg_video', + 'hasConsent': true + }, + 'meta': { + 'advertiserDomains': [ + 'unknown' + ] + }, + 'vastUrl': 'https://some.vast-url.com', + 'vastXml': '', + 'adapterCode': 'mediasquare', + 'originalCpm': 0.9723, + 'originalCurrency': 'USD', + 'responseTimestamp': 1665505150740, + 'requestTimestamp': 1665505150594, + 'bidder': 'mediasquare', + 'adUnitCode': 'msq_tag_200125_video', + 'timeToRespond': 146, + 'size': '640x480', +}, { + 'bidderCode': 'appnexusAst', + 'width': 640, + 'height': 480, + 'statusMessage': 'Bid available', + 'adId': '4b2e1581c0ca1a', + 'requestId': '2d891705d2125b', + 'transactionId': 'de664ccb-e18b-4436-aeb0-362382eb1b41', + 'auctionId': '1e8b993d-8f0a-4232-83eb-3639ddf3a44b', + 'mediaType': 'video', + 'source': 'client', + 'cpm': 1.9723, + 'creativeId': '159080650', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 2000, + 'vastUrl': 'https://some.vast-url.com', + 'vastXml': 'AdnxsTitle', + 'adapterCode': 'mediasquare', + 'originalCpm': 1.9723, + 'originalCurrency': 'USD', + 'responseTimestamp': 1665505150740, + 'requestTimestamp': 1665505150594, + 'bidder': 'appnexusAst', + 'adUnitCode': 'msq_tag_200125_video', + 'timeToRespond': 146, + 'size': '640x480', + 'vastImpUrl': 'https://some.tracking-url.com' +}, +]; + +let originalBidderRequests = [{ + 'bidderCode': 'rubicon', + 'auctionId': 'dd42b870-2072-4b71-8ab7-e7789b14c5ce', + 'bidderRequestId': '16c2bceb2e891a', + 'bids': [ + { + 'bidder': 'rubicon', + 'params': { + 'accountId': 1234, + 'siteId': 2345, + 'zoneId': 3456 + }, + 'auctionId': 'dd42b870-2072-4b71-8ab7-e7789b14c5ce', + 'mediaTypes': {'banner': {'sizes': [[970, 250]]}}, + 'adUnitCode': 'adunit1', + 'transactionId': '8f20b49c-5e47-4bb5-a7d5-0b816cf527f3', + 'bidId': '2d9920072ab028', + 'bidderRequestId': '16c2bceb2e891a', + }, + { + 'bidder': 'rubicon', + 'params': { + 'accountId': 1234, + 'siteId': 2345, + 'zoneId': 4567 + }, + 'auctionId': 'dd42b870-2072-4b71-8ab7-e7789b14c5ce', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'adUnitCode': 'adunit2', + 'transactionId': '4161f09e-7870-4486-b2a6-b4158a327bc4', + 'bidId': '331c3d708f4864', + 'bidderRequestId': '16c2bceb2e891a', + 'src': 'client', + } + ], + 'auctionStart': 1683383333809, + 'timeout': 3000, + 'gdprConsent': { + 'consentString': 'consent_hash', + 'gdprApplies': true, + 'apiVersion': 2 + } +}, +{ + 'bidderCode': 'appnexusAst', + 'auctionId': 'dd42b870-2072-4b71-8ab7-e7789b14c5ce', + 'bidderRequestId': '4d83b8c60d45e7', + 'bids': [ + { + 'bidder': 'appnexusAst', + 'params': { + 'placementId': 10471298 + }, + 'auctionId': 'dd42b870-2072-4b71-8ab7-e7789b14c5ce', + 'mediaTypes': {'banner': {'sizes': [[300, 250]]}}, + 'adUnitCode': 'adunit2', + 'transactionId': '4161f09e-7870-4486-b2a6-b4158a327bc4', + 'bidId': '5b7cd5abc6aea3', + 'bidderRequestId': '4d83b8c60d45e7', + } + ], + 'auctionStart': 1683383333809, + 'timeout': 3000, + 'gdprConsent': { + 'consentString': 'consent_hash', + 'gdprApplies': true, + 'apiVersion': 2 + } +} +]; + +let bidInterests = [ + {'id': 0, 'rate': 50.0, 'suggestion': true}, + {'id': 1, 'rate': 12.0, 'suggestion': false}, + {'id': 2, 'rate': 0.0, 'suggestion': true}, + {'id': 3, 'rate': 0.0, 'suggestion': false}, +]; + +const userConsent = { + 'gdpr': { + 'consentString': 'consent_hash' + }, + 'usp': null, + 'gpp': null, + 'coppa': false +}; + +describe('oxxionRtdProvider', () => { + describe('Oxxion RTD sub module', () => { + it('should init, return true, and set the params', () => { + expect(oxxionSubmodule.init(moduleConfig)).to.equal(true); + }); + }); + + describe('Oxxion RTD sub module', () => { + let auctionEnd = request; + auctionEnd.bidsReceived = bids; + it('call everything', function() { + oxxionSubmodule.getBidRequestData(request, null, moduleConfig); + oxxionSubmodule.onBidResponseEvent(auctionEnd.bidsReceived[0], moduleConfig); + oxxionSubmodule.onBidResponseEvent(auctionEnd.bidsReceived[1], moduleConfig); + }); + it('check bid filtering', function() { + let requestsList = oxxionSubmodule.getRequestsList(request); + expect(requestsList.length).to.equal(4); + expect(requestsList[0]).to.have.property('id'); + expect(request.adUnits[0].bids[0]).to.have.property('_id'); + expect(requestsList[0].id).to.equal(request.adUnits[0].bids[0]._id); + const [filteredBiddderRequests, filteredBids] = oxxionSubmodule.getFilteredAdUnitsOnBidRates(bidInterests, request.adUnits, moduleConfig.params, false); + expect(filteredBids.length).to.equal(1); + expect(filteredBiddderRequests.length).to.equal(3); + expect(filteredBiddderRequests[0]).to.have.property('bids'); + expect(filteredBiddderRequests[0].bids.length).to.equal(1); + expect(filteredBiddderRequests[1]).to.have.property('bids'); + expect(filteredBiddderRequests[1].bids.length).to.equal(1); + }); + it('check vastImpUrl', function() { + expect(auctionEnd.bidsReceived[0]).to.have.property('vastImpUrl'); + let expectVastImpUrl = 'https://' + moduleConfig.params.domain + '.oxxion.io/analytics/vast_imp?'; + expect(auctionEnd.bidsReceived[1].vastImpUrl).to.contain(expectVastImpUrl); + expect(auctionEnd.bidsReceived[1].vastImpUrl).to.contain(encodeURI('https://some.tracking-url.com')); + }); + it('check vastXml', function() { + expect(auctionEnd.bidsReceived[0]).to.have.property('vastXml'); + let vastWrapper = new DOMParser().parseFromString(auctionEnd.bidsReceived[0].vastXml, 'text/xml'); + let impressions = vastWrapper.querySelectorAll('VAST Ad Wrapper Impression'); + expect(impressions.length).to.equal(2); + expect(auctionEnd.bidsReceived[1]).to.have.property('vastXml'); + expect(auctionEnd.bidsReceived[1].adId).to.equal('4b2e1581c0ca1a'); + let vastInline = new DOMParser().parseFromString(auctionEnd.bidsReceived[1].vastXml, 'text/xml'); + let inline = vastInline.querySelectorAll('VAST Ad InLine'); + expect(inline).to.have.lengthOf(1); + let inlineImpressions = vastInline.querySelectorAll('VAST Ad InLine Impression'); + expect(inlineImpressions).to.have.lengthOf.above(0); + }); + it('check cpmIncrement', function() { + expect(auctionEnd.bidsReceived[1].vastImpUrl).to.contain(encodeURI('cpmIncrement=0')); + }); + }); +}); diff --git a/test/spec/modules/ozoneBidAdapter_spec.js b/test/spec/modules/ozoneBidAdapter_spec.js index 658af310ea5..64b345c5d9c 100644 --- a/test/spec/modules/ozoneBidAdapter_spec.js +++ b/test/spec/modules/ozoneBidAdapter_spec.js @@ -6,13 +6,6 @@ import {getGranularityKeyName, getGranularityObject} from '../../../modules/ozon import * as utils from '../../../src/utils.js'; const OZONEURI = 'https://elb.the-ozone-project.com/openrtb2/auction'; const BIDDER_CODE = 'ozone'; - -/* - -NOTE - use firefox console to deep copy the objects to use here - - */ -var originalPropertyBag = {'pageId': null}; var validBidRequests = [ { adUnitCode: 'div-gpt-ad-1460505748561-0', @@ -147,7 +140,6 @@ var validBidRequestsWithUserIdData = [ }] } ] - } ]; var validBidRequestsMinimal = [ @@ -176,7 +168,6 @@ var validBidRequestsNoSizes = [ transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; - var validBidRequestsWithBannerMediaType = [ { adUnitCode: 'div-gpt-ad-1460505748561-0', @@ -205,7 +196,6 @@ var validBidRequestsWithNonBannerMediaTypesAndValidOutstreamVideo = [ transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' } ]; - var validBidRequests1OutstreamVideo2020 = [ { 'bidder': 'ozone', @@ -288,7 +278,6 @@ var validBidRequests1OutstreamVideo2020 = [ 'bidderWinsCount': 0 } ]; - var validBidderRequest1OutstreamVideo2020 = { bidderRequest: { auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', @@ -392,84 +381,79 @@ var validBidderRequest1OutstreamVideo2020 = { } }; var validBidderRequest = { - bidderRequest: { + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + auctionStart: 1536838908986, + bidderCode: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + bids: [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', - auctionStart: 1536838908986, - bidderCode: 'ozone', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', - bids: [{ - adUnitCode: 'div-gpt-ad-1460505748561-0', - auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', - bidId: '2899ec066a91ff8', - bidRequestsCount: 1, - bidder: 'ozone', - bidderRequestId: '1c1586b27a1b5c8', - crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, - sizes: [[300, 250], [300, 600]], - transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' - }], - doneCbCallCount: 1, - start: 1536838908987, - timeout: 3000 - } + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + }], + doneCbCallCount: 1, + start: 1536838908987, + timeout: 3000 }; - var bidderRequestWithFullGdpr = { - bidderRequest: { + auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', + auctionStart: 1536838908986, + bidderCode: 'ozone', + bidderRequestId: '1c1586b27a1b5c8', + bids: [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', - auctionStart: 1536838908986, - bidderCode: 'ozone', + bidId: '2899ec066a91ff8', + bidRequestsCount: 1, + bidder: 'ozone', bidderRequestId: '1c1586b27a1b5c8', - bids: [{ - adUnitCode: 'div-gpt-ad-1460505748561-0', - auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', - bidId: '2899ec066a91ff8', - bidRequestsCount: 1, - bidder: 'ozone', - bidderRequestId: '1c1586b27a1b5c8', - crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, - params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, - sizes: [[300, 250], [300, 600]], - transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' - }], - doneCbCallCount: 1, - start: 1536838908987, - timeout: 3000, - gdprConsent: { - 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', - 'vendorData': { - 'metadata': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', - 'gdprApplies': true, - 'hasGlobalScope': false, - 'cookieVersion': '1', - 'created': '2019-05-31T12:46:48.825', - 'lastUpdated': '2019-05-31T12:46:48.825', - 'cmpId': '28', - 'cmpVersion': '1', - 'consentLanguage': 'en', - 'consentScreen': '1', - 'vendorListVersion': 148, - 'maxVendorId': 631, - 'purposeConsents': { - '1': true, - '2': true, - '3': true, - '4': true, - '5': true - }, - 'vendorConsents': { - '468': true, - '522': true, - '524': true, /* 524 is ozone */ - '565': true, - '591': true - } + crumbs: {pubcid: '203a0692-f728-4856-87f6-9a25a6b63715'}, + params: { publisherId: '9876abcd12-3', customData: [{'settings': {}, 'targeting': {'gender': 'bart', 'age': 'low'}}], placementId: '1310000099', siteId: '1234567890', id: 'fea37168-78f1-4a23-a40e-88437a99377e', auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', imp: [ { banner: { topframe: 1, w: 300, h: 250, format: [{ w: 300, h: 250 }, { w: 300, h: 600 }] }, id: '2899ec066a91ff8', secure: 1, tagid: 'undefined' } ] }, + sizes: [[300, 250], [300, 600]], + transactionId: '2e63c0ed-b10c-4008-aed5-84582cecfe87' + }], + doneCbCallCount: 1, + start: 1536838908987, + timeout: 3000, + gdprConsent: { + 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'vendorData': { + 'metadata': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', + 'gdprApplies': true, + 'hasGlobalScope': false, + 'cookieVersion': '1', + 'created': '2019-05-31T12:46:48.825', + 'lastUpdated': '2019-05-31T12:46:48.825', + 'cmpId': '28', + 'cmpVersion': '1', + 'consentLanguage': 'en', + 'consentScreen': '1', + 'vendorListVersion': 148, + 'maxVendorId': 631, + 'purposeConsents': { + '1': true, + '2': true, + '3': true, + '4': true, + '5': true }, - 'gdprApplies': true - }, } + 'vendorConsents': { + '468': true, + '522': true, + '524': true, /* 524 is ozone */ + '565': true, + '591': true + } + }, + 'gdprApplies': true + } }; - var gdpr1 = { 'consentString': 'BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA', 'vendorData': { @@ -502,7 +486,6 @@ var gdpr1 = { }, 'gdprApplies': true }; - var bidderRequestWithPartialGdpr = { bidderRequest: { auctionId: '27dcb421-95c6-4024-a624-3c03816c5f99', @@ -547,7 +530,6 @@ var bidderRequestWithPartialGdpr = { } } }; - var validResponse = { 'body': { 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', @@ -604,7 +586,6 @@ var validResponse = { }, 'headers': {} }; - var validResponse2Bids = { 'body': { 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', @@ -691,9 +672,6 @@ var validResponse2Bids = { }, 'headers': {} }; -/* -A bidder returns a bid for both sizes in an adunit - */ var validResponse2BidsSameAdunit = { 'body': { 'id': 'd6198807-7a53-4141-b2db-d2cb754d68ba', @@ -780,14 +758,6 @@ var validResponse2BidsSameAdunit = { }, 'headers': {} }; -/* - -SPECIAL CONSIDERATION FOR VIDEO TESTS: - -DO NOT USE _validVideoResponse directly - the interpretResponse function will modify it (adding a renderer!!!) so all -subsequent calls will already have a renderer attached!!! - -*/ function getCleanValidVideoResponse() { return JSON.parse(JSON.stringify(_validVideoResponse)); } @@ -873,7 +843,6 @@ var _validVideoResponse = { }, 'headers': {} }; - var validBidResponse1adWith2Bidders = { 'body': { 'id': '91221f96-b931-4acc-8f05-c2a1186fa5ac', @@ -964,11 +933,6 @@ var validBidResponse1adWith2Bidders = { }, 'headers': {} }; - -/* -testing 2 ads, 2 bidders, one bidder bids for both slots in one adunit - */ - var multiRequest1 = [ { 'bidder': 'ozone', @@ -1101,182 +1065,178 @@ var multiRequest1 = [ 'bidderWinsCount': 0 } ]; - var multiBidderRequest1 = { - bidderRequest: { - 'bidderCode': 'ozone', - 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', - 'bidderRequestId': '1d03a1dfc563fc', - 'bids': [ - { - 'bidder': 'ozone', - 'params': { - 'publisherId': 'OZONERUP0001', - 'siteId': '4204204201', - 'placementId': '0420420421', - 'customData': [ - { - 'settings': {}, - 'targeting': { - 'sens': 'f', - 'pt1': '/uk', - 'pt2': 'uk', - 'pt3': 'network-front', - 'pt4': 'ng', - 'pt5': [ - 'uk' - ], - 'pt7': 'desktop', - 'pt8': [ - 'tfmqxwj7q', - 'txeh7uyo0', - 't8nxz6qzd', - 't8nyiude5', - 'sek9ghqwi' - ], - 'pt9': '|k0xw2vqzp33kklb3j5w4|||' - } - } - ] - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [ - 300, - 250 + 'bidderCode': 'ozone', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'bidderRequestId': '1d03a1dfc563fc', + 'bids': [ + { + 'bidder': 'ozone', + 'params': { + 'publisherId': 'OZONERUP0001', + 'siteId': '4204204201', + 'placementId': '0420420421', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' ], - [ - 300, - 600 - ] - ] + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'txeh7uyo0', + 't8nxz6qzd', + 't8nyiude5', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } } - }, - 'adUnitCode': 'mpu', - 'transactionId': '6480bac7-31b5-4723-9145-ad8966660651', - 'sizes': [ - [ - 300, - 250 - ], - [ - 300, - 600 - ] - ], - 'bidId': '2d30e86db743a8', - 'bidderRequestId': '1d03a1dfc563fc', - 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 + ] }, - { - 'bidder': 'ozone', - 'params': { - 'publisherId': 'OZONERUP0001', - 'siteId': '4204204201', - 'placementId': '0420420421', - 'customData': [ - { - 'settings': {}, - 'targeting': { - 'sens': 'f', - 'pt1': '/uk', - 'pt2': 'uk', - 'pt3': 'network-front', - 'pt4': 'ng', - 'pt5': [ - 'uk' - ], - 'pt7': 'desktop', - 'pt8': [ - 'tfmqxwj7q', - 'penl4dfdk', - 't8nxz6qzd', - 't8nyiude5', - 'sek9ghqwi' - ], - 'pt9': '|k0xw2vqzp33kklb3j5w4|||' - } - } - ] - }, - 'mediaTypes': { - 'banner': { - 'sizes': [ - [ - 728, - 90 - ], - [ - 970, - 250 - ] + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + [ + 300, + 600 ] - } - }, - 'adUnitCode': 'leaderboard', - 'transactionId': 'a49988e6-ae7c-46c4-9598-f18db49892a0', - 'sizes': [ - [ - 728, - 90 - ], - [ - 970, - 250 ] + } + }, + 'adUnitCode': 'mpu', + 'transactionId': '6480bac7-31b5-4723-9145-ad8966660651', + 'sizes': [ + [ + 300, + 250 ], - 'bidId': '3025f169863b7f8', - 'bidderRequestId': '1d03a1dfc563fc', - 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - } - ], - 'auctionStart': 1592918645574, - 'timeout': 3000, - 'refererInfo': { - 'referer': 'http://ozone.ardm.io/adapter/2.4.0/620x350-switch.html?guardian=true&pbjs_debug=true', - 'reachedTop': true, - 'numIframes': 0, - 'stack': [ - 'http://ozone.ardm.io/adapter/2.4.0/620x350-switch.html?guardian=true&pbjs_debug=true' - ] + [ + 300, + 600 + ] + ], + 'bidId': '2d30e86db743a8', + 'bidderRequestId': '1d03a1dfc563fc', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 }, - 'gdprConsent': { - 'consentString': 'BOvy5sFO1dBa2AKAiBENDP-AAAAwVrv7_77-_9f-_f__9uj3Gr_v_f__32ccL5tv3h_7v-_7fi_-0nV4u_1tft9ydk1-5ctDztp507iakiPHmqNeb9n_mz1eZpRP58E09j53z7Ew_v8_v-b7BCPN_Y3v-8K96kA', - 'vendorData': { - 'metadata': 'BOvy5sFO1dBa2AKAiBENDPA', - 'gdprApplies': true, - 'hasGlobalConsent': false, - 'hasGlobalScope': false, - 'purposeConsents': { - '1': true, - '2': true, - '3': true, - '4': true, - '5': true - }, - 'vendorConsents': { - '1': true, - '2': true, - '3': false, - '4': true, - '5': true + { + 'bidder': 'ozone', + 'params': { + 'publisherId': 'OZONERUP0001', + 'siteId': '4204204201', + 'placementId': '0420420421', + 'customData': [ + { + 'settings': {}, + 'targeting': { + 'sens': 'f', + 'pt1': '/uk', + 'pt2': 'uk', + 'pt3': 'network-front', + 'pt4': 'ng', + 'pt5': [ + 'uk' + ], + 'pt7': 'desktop', + 'pt8': [ + 'tfmqxwj7q', + 'penl4dfdk', + 't8nxz6qzd', + 't8nyiude5', + 'sek9ghqwi' + ], + 'pt9': '|k0xw2vqzp33kklb3j5w4|||' + } + } + ] + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 728, + 90 + ], + [ + 970, + 250 + ] + ] } }, - 'gdprApplies': true + 'adUnitCode': 'leaderboard', + 'transactionId': 'a49988e6-ae7c-46c4-9598-f18db49892a0', + 'sizes': [ + [ + 728, + 90 + ], + [ + 970, + 250 + ] + ], + 'bidId': '3025f169863b7f8', + 'bidderRequestId': '1d03a1dfc563fc', + 'auctionId': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ], + 'auctionStart': 1592918645574, + 'timeout': 3000, + 'refererInfo': { + 'referer': 'http://ozone.ardm.io/adapter/2.4.0/620x350-switch.html?guardian=true&pbjs_debug=true', + 'reachedTop': true, + 'numIframes': 0, + 'stack': [ + 'http://ozone.ardm.io/adapter/2.4.0/620x350-switch.html?guardian=true&pbjs_debug=true' + ] + }, + 'gdprConsent': { + 'consentString': 'BOvy5sFO1dBa2AKAiBENDP-AAAAwVrv7_77-_9f-_f__9uj3Gr_v_f__32ccL5tv3h_7v-_7fi_-0nV4u_1tft9ydk1-5ctDztp507iakiPHmqNeb9n_mz1eZpRP58E09j53z7Ew_v8_v-b7BCPN_Y3v-8K96kA', + 'vendorData': { + 'metadata': 'BOvy5sFO1dBa2AKAiBENDPA', + 'gdprApplies': true, + 'hasGlobalConsent': false, + 'hasGlobalScope': false, + 'purposeConsents': { + '1': true, + '2': true, + '3': true, + '4': true, + '5': true + }, + 'vendorConsents': { + '1': true, + '2': true, + '3': false, + '4': true, + '5': true + } }, - 'start': 1592918645578 - } + 'gdprApplies': true + }, + 'start': 1592918645578 }; - var multiResponse1 = { 'body': { 'id': '592ee33b-fb2e-4c00-b2d5-383e99cac57f', @@ -1488,11 +1448,6 @@ var multiResponse1 = { }, 'headers': {} }; - -/* ---------------------end of 2 slots, 2 ---------------------------- - */ - describe('ozone Adapter', function () { describe('isBidRequestValid', function () { let validBidReq = { @@ -1503,13 +1458,10 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should return true when required params found', function () { expect(spec.isBidRequestValid(validBidReq)).to.equal(true); }); - var validBidReq2 = { - bidder: BIDDER_CODE, params: { placementId: '1310000099', @@ -1519,11 +1471,9 @@ describe('ozone Adapter', function () { }, siteId: 1234567890 } - it('should return true when required params found and all optional params are valid', function () { expect(spec.isBidRequestValid(validBidReq2)).to.equal(true); }); - var xEmptyPlacement = { bidder: BIDDER_CODE, params: { @@ -1532,11 +1482,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate empty placementId', function () { expect(spec.isBidRequestValid(xEmptyPlacement)).to.equal(false); }); - var xMissingPlacement = { bidder: BIDDER_CODE, params: { @@ -1544,11 +1492,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate missing placementId', function () { expect(spec.isBidRequestValid(xMissingPlacement)).to.equal(false); }); - var xBadPlacement = { bidder: BIDDER_CODE, params: { @@ -1557,11 +1503,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate placementId with a non-numeric value', function () { expect(spec.isBidRequestValid(xBadPlacement)).to.equal(false); }); - var xBadPlacementTooShort = { bidder: BIDDER_CODE, params: { @@ -1570,11 +1514,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate placementId with a numeric value of wrong length', function () { expect(spec.isBidRequestValid(xBadPlacementTooShort)).to.equal(false); }); - var xBadPlacementTooLong = { bidder: BIDDER_CODE, params: { @@ -1583,11 +1525,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate placementId with a numeric value of wrong length', function () { expect(spec.isBidRequestValid(xBadPlacementTooLong)).to.equal(false); }); - var xMissingPublisher = { bidder: BIDDER_CODE, params: { @@ -1595,11 +1535,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate missing publisherId', function () { expect(spec.isBidRequestValid(xMissingPublisher)).to.equal(false); }); - var xMissingSiteId = { bidder: BIDDER_CODE, params: { @@ -1607,11 +1545,9 @@ describe('ozone Adapter', function () { placementId: '1234567890', } }; - it('should not validate missing sitetId', function () { expect(spec.isBidRequestValid(xMissingSiteId)).to.equal(false); }); - var xBadPublisherTooShort = { bidder: BIDDER_CODE, params: { @@ -1620,11 +1556,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate publisherId being too short', function () { expect(spec.isBidRequestValid(xBadPublisherTooShort)).to.equal(false); }); - var xBadPublisherTooLong = { bidder: BIDDER_CODE, params: { @@ -1633,11 +1567,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate publisherId being too long', function () { expect(spec.isBidRequestValid(xBadPublisherTooLong)).to.equal(false); }); - var publisherNumericOk = { bidder: BIDDER_CODE, params: { @@ -1646,11 +1578,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should validate publisherId being 12 digits', function () { expect(spec.isBidRequestValid(publisherNumericOk)).to.equal(true); }); - var xEmptyPublisher = { bidder: BIDDER_CODE, params: { @@ -1659,11 +1589,9 @@ describe('ozone Adapter', function () { siteId: '1234567890' } }; - it('should not validate empty publisherId', function () { expect(spec.isBidRequestValid(xEmptyPublisher)).to.equal(false); }); - var xBadSite = { bidder: BIDDER_CODE, params: { @@ -1672,37 +1600,15 @@ describe('ozone Adapter', function () { siteId: '12345Z' } }; - it('should not validate bad siteId', function () { expect(spec.isBidRequestValid(xBadSite)).to.equal(false); }); - - var xBadSiteTooLong = { - bidder: BIDDER_CODE, - params: { - placementId: '1234567890', - publisherId: '9876abcd12-3', - siteId: '12345678901' - } - }; - it('should not validate siteId too long', function () { expect(spec.isBidRequestValid(xBadSite)).to.equal(false); }); - - var xBadSiteTooShort = { - bidder: BIDDER_CODE, - params: { - placementId: '1234567890', - publisherId: '9876abcd12-3', - siteId: '123456789' - } - }; - it('should not validate siteId too short', function () { expect(spec.isBidRequestValid(xBadSite)).to.equal(false); }); - var allNonStrings = { bidder: BIDDER_CODE, params: { @@ -1711,11 +1617,9 @@ describe('ozone Adapter', function () { siteId: 1234567890 } }; - it('should validate all numeric values being sent as non-string numbers', function () { expect(spec.isBidRequestValid(allNonStrings)).to.equal(true); }); - var emptySiteId = { bidder: BIDDER_CODE, params: { @@ -1724,11 +1628,9 @@ describe('ozone Adapter', function () { siteId: '' } }; - it('should not validate siteId being empty string (it is required now)', function () { expect(spec.isBidRequestValid(emptySiteId)).to.equal(false); }); - var xBadCustomData = { bidder: BIDDER_CODE, params: { @@ -1738,12 +1640,10 @@ describe('ozone Adapter', function () { 'customData': 'this aint gonna work' } }; - it('should not validate customData not being an array', function () { expect(spec.isBidRequestValid(xBadCustomData)).to.equal(false); }); - - var xBadCustomData_OLD_CUSTOMDATA_VALUE = { + var xBadCustomDataOldCustomdataValue = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', @@ -1752,12 +1652,10 @@ describe('ozone Adapter', function () { 'customData': {'gender': 'bart', 'age': 'low'} } }; - it('should not validate customData being an object, not an array', function () { - expect(spec.isBidRequestValid(xBadCustomData_OLD_CUSTOMDATA_VALUE)).to.equal(false); + expect(spec.isBidRequestValid(xBadCustomDataOldCustomdataValue)).to.equal(false); }); - - var xBadCustomData_zerocd = { + var xBadCustomDataZerocd = { bidder: BIDDER_CODE, params: { 'placementId': '1111111110', @@ -1766,12 +1664,10 @@ describe('ozone Adapter', function () { 'customData': [] } }; - it('should not validate customData array having no elements', function () { - expect(spec.isBidRequestValid(xBadCustomData_zerocd)).to.equal(false); + expect(spec.isBidRequestValid(xBadCustomDataZerocd)).to.equal(false); }); - - var xBadCustomData_notargeting = { + var xBadCustomDataNotargeting = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', @@ -1781,10 +1677,9 @@ describe('ozone Adapter', function () { } }; it('should not validate customData[] having no "targeting"', function () { - expect(spec.isBidRequestValid(xBadCustomData_notargeting)).to.equal(false); + expect(spec.isBidRequestValid(xBadCustomDataNotargeting)).to.equal(false); }); - - var xBadCustomData_tgt_not_obj = { + var xBadCustomDataTgtNotObj = { bidder: BIDDER_CODE, params: { 'placementId': '1234567890', @@ -1794,9 +1689,8 @@ describe('ozone Adapter', function () { } }; it('should not validate customData[0].targeting not being an object', function () { - expect(spec.isBidRequestValid(xBadCustomData_tgt_not_obj)).to.equal(false); + expect(spec.isBidRequestValid(xBadCustomDataTgtNotObj)).to.equal(false); }); - var xBadCustomParams = { bidder: BIDDER_CODE, params: { @@ -1821,11 +1715,9 @@ describe('ozone Adapter', function () { mimes: ['video/mp4']} } }; - it('should not validate video without context attribute', function () { expect(spec.isBidRequestValid(xBadVideoContext2)).to.equal(false); }); - let validVideoBidReq = { bidder: BIDDER_CODE, params: { @@ -1839,7 +1731,6 @@ describe('ozone Adapter', function () { 'context': 'outstream'}, } }; - it('should validate video outstream being sent', function () { expect(spec.isBidRequestValid(validVideoBidReq)).to.equal(true); }); @@ -1849,47 +1740,44 @@ describe('ozone Adapter', function () { expect(spec.isBidRequestValid(instreamVid)).to.equal(true); }); }); - describe('buildRequests', function () { + beforeEach(function () { + config.resetConfig() + }); it('sends bid request to OZONEURI via POST', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.url).to.equal(OZONEURI); expect(request.method).to.equal('POST'); }); - it('sends data as a string', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.data).to.be.a('string'); }); - it('sends all bid parameters', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('adds all parameters inside the ext object only', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.data).to.be.a('string'); var data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.customData).to.be.an('array'); expect(request).not.to.have.key('lotameData'); expect(request).not.to.have.key('customData'); }); - it('adds all parameters inside the ext object only - lightning', function () { let localBidReq = JSON.parse(JSON.stringify(validBidRequests)); - const request = spec.buildRequests(localBidReq, validBidderRequest.bidderRequest); + const request = spec.buildRequests(localBidReq, validBidderRequest); expect(request.data).to.be.a('string'); var data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.customData).to.be.an('array'); expect(request).not.to.have.key('lotameData'); expect(request).not.to.have.key('customData'); }); - it('ignores ozoneData in & after version 2.1.1', function () { let validBidRequestsWithOzoneData = JSON.parse(JSON.stringify(validBidRequests)); validBidRequestsWithOzoneData[0].params.ozoneData = {'networkID': '3048', 'dfpSiteID': 'd.thesun', 'sectionID': 'homepage', 'path': '/', 'sec_id': 'null', 'sec': 'sec', 'topics': 'null', 'kw': 'null', 'aid': 'null', 'search': 'null', 'article_type': 'null', 'hide_ads': '', 'article_slug': 'null'}; - const request = spec.buildRequests(validBidRequestsWithOzoneData, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsWithOzoneData, validBidderRequest); expect(request.data).to.be.a('string'); var data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.customData).to.be.an('array'); @@ -1897,43 +1785,36 @@ describe('ozone Adapter', function () { expect(request).not.to.have.key('lotameData'); expect(request).not.to.have.key('customData'); }); - it('has correct bidder', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.bidderRequest.bids[0].bidder).to.equal(BIDDER_CODE); }); - it('handles mediaTypes element correctly', function () { - const request = spec.buildRequests(validBidRequestsWithBannerMediaType, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsWithBannerMediaType, validBidderRequest); expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('handles no ozone or custom data', function () { - const request = spec.buildRequests(validBidRequestsMinimal, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsMinimal, validBidderRequest); expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('handles video mediaType element correctly, with outstream video', function () { - const request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest); expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('should not crash when there is no sizes element at all', function () { - const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); expect(request).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); }); - it('should be able to handle non-single requests', function () { config.setConfig({'ozone': {'singleRequest': false}}); - const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); expect(request).to.be.a('array'); expect(request[0]).to.have.all.keys(['bidderRequest', 'data', 'method', 'url']); config.setConfig({'ozone': {'singleRequest': true}}); }); - it('should add gdpr consent information to the request when ozone is true', function () { let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; - let bidderRequest = validBidderRequest.bidderRequest; + let bidderRequest = validBidderRequest; bidderRequest.gdprConsent = { consentString: consentString, gdprApplies: true, @@ -1944,16 +1825,14 @@ describe('ozone Adapter', function () { purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} } } - const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(1); expect(payload.user.ext.consent).to.equal(consentString); }); - it('should add gdpr consent information to the request when vendorData is missing vendorConsents (Mirror)', function () { let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; - let bidderRequest = validBidderRequest.bidderRequest; + let bidderRequest = validBidderRequest; bidderRequest.gdprConsent = { consentString: consentString, gdprApplies: true, @@ -1962,16 +1841,14 @@ describe('ozone Adapter', function () { gdprApplies: true } } - const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(1); expect(payload.user.ext.consent).to.equal(consentString); }); - it('should set regs.ext.gdpr flag to 0 when gdprApplies is false', function () { let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; - let bidderRequest = validBidderRequest.bidderRequest; + let bidderRequest = validBidderRequest; bidderRequest.gdprConsent = { consentString: consentString, gdprApplies: false, @@ -1982,15 +1859,13 @@ describe('ozone Adapter', function () { purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} } }; - const request = spec.buildRequests(validBidRequestsNoSizes, bidderRequest); const payload = JSON.parse(request.data); expect(payload.regs.ext.gdpr).to.equal(0); }); - it('should not have imp[N].ext.ozone.userId', function () { let consentString = 'BOcocyaOcocyaAfEYDENCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NphLgA=='; - let bidderRequest = validBidderRequest.bidderRequest; + let bidderRequest = validBidderRequest; bidderRequest.gdprConsent = { consentString: consentString, gdprApplies: false, @@ -2001,7 +1876,6 @@ describe('ozone Adapter', function () { purposeConsents: {1: true, 2: true, 3: true, 4: true, 5: true} } }; - let bidRequests = validBidRequests; bidRequests[0]['userId'] = { 'digitrustid': {data: {id: 'DTID', keyv: 4, privacy: {optout: false}, producer: 'ABC', version: 2}}, @@ -2019,7 +1893,6 @@ describe('ozone Adapter', function () { expect(firstBid).to.not.have.property('userId'); delete validBidRequests[0].userId; // tidy up now, else it will screw with other tests }); - it('should pick up the value of pubcid when built using the pubCommonId module (not userId)', function () { let bidRequests = validBidRequests; bidRequests[0]['userId'] = { @@ -2031,23 +1904,13 @@ describe('ozone Adapter', function () { 'sharedid': {'id': '01EAJWWNEPN3CYMM5N8M5VXY22', 'third': '01EAJWWNEPN3CYMM5N8M5VXY22'} }; bidRequests[0]['userIdAsEids'] = validBidRequestsWithUserIdData[0]['userIdAsEids']; - const request = spec.buildRequests(bidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(bidRequests, validBidderRequest); const payload = JSON.parse(request.data); expect(payload.ext.ozone.pubcid).to.equal(bidRequests[0]['crumbs']['pubcid']); delete validBidRequests[0].userId; // tidy up now, else it will screw with other tests }); - it('should add a user.ext.eids object to contain user ID data in the new location (Nov 2019) Updated Aug 2020', function() { - const request = spec.buildRequests(validBidRequestsWithUserIdData, validBidderRequest.bidderRequest); - /* - 'pubcid': '12345678', - 'tdid': '1111tdid', - 'id5id': { uid: '1111', ext: { linkType: 2, abTestingControlGroup: false } }, - 'criteoId': '1111criteoId', - 'idl_env': 'liverampId', - 'parrableId': {'eid': '01.5678.parrableid'} - */ - + const request = spec.buildRequests(validBidRequestsWithUserIdData, validBidderRequest); const payload = JSON.parse(request.data); expect(payload.user).to.exist; expect(payload.user.ext).to.exist; @@ -2067,12 +1930,11 @@ describe('ozone Adapter', function () { expect(payload.user.ext.eids[6]['source']).to.equal('parrableId'); expect(payload.user.ext.eids[6]['uids'][0]['id']['eid']).to.equal('01.5678.parrableid'); }); - it('replaces the auction url for a config override', function () { spec.propertyBag.whitelabel = null; let fakeOrigin = 'http://sometestendpoint'; config.setConfig({'ozone': {'endpointOverride': {'origin': fakeOrigin}}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.url).to.equal(fakeOrigin + '/openrtb2/auction'); expect(request.method).to.equal('POST'); const data = JSON.parse(request.data); @@ -2080,12 +1942,11 @@ describe('ozone Adapter', function () { config.setConfig({'ozone': {'kvpPrefix': null, 'endpointOverride': null}}); spec.propertyBag.whitelabel = null; }); - it('replaces the FULL auction url for a config override', function () { spec.propertyBag.whitelabel = null; let fakeurl = 'http://sometestendpoint/myfullurl'; config.setConfig({'ozone': {'endpointOverride': {'auctionUrl': fakeurl}}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); expect(request.url).to.equal(fakeurl); expect(request.method).to.equal('POST'); const data = JSON.parse(request.data); @@ -2093,7 +1954,6 @@ describe('ozone Adapter', function () { config.setConfig({'ozone': {'kvpPrefix': null, 'endpointOverride': null}}); spec.propertyBag.whitelabel = null; }); - it('replaces the renderer url for a config override', function () { spec.propertyBag.whitelabel = null; let fakeUrl = 'http://renderer.com'; @@ -2107,9 +1967,8 @@ describe('ozone Adapter', function () { spec.propertyBag.whitelabel = null; }); it('should generate all the adservertargeting keys correctly named', function () { - var specMock = utils.deepClone(spec); config.setConfig({'ozone': {'kvpPrefix': 'xx'}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(result[0].adserverTargeting).to.have.own.property('xx_appnexus_crid'); expect(utils.deepAccess(result[0].adserverTargeting, 'xx_appnexus_crid')).to.equal('98493581'); @@ -2118,33 +1977,28 @@ describe('ozone Adapter', function () { expect(utils.deepAccess(result[0].adserverTargeting, 'xx_size')).to.equal('300x600'); expect(utils.deepAccess(result[0].adserverTargeting, 'xx_pb_r')).to.equal('0.50'); expect(utils.deepAccess(result[0].adserverTargeting, 'xx_bid')).to.equal('true'); - config.resetConfig(); }); it('should create a meta object on each bid returned', function () { - var specMock = utils.deepClone(spec); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(result[0]).to.have.own.property('meta'); expect(result[0].meta.advertiserDomains[0]).to.equal('http://prebid.org'); - config.resetConfig(); }); - it('replaces the kvp prefix ', function () { spec.propertyBag.whitelabel = null; config.setConfig({'ozone': {'kvpPrefix': 'test'}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const data = JSON.parse(request.data); expect(data.ext.ozone).to.haveOwnProperty('test_rw'); config.setConfig({'ozone': {'kvpPrefix': null}}); spec.propertyBag.whitelabel = null; }); - it('handles an alias ', function () { spec.propertyBag.whitelabel = null; config.setConfig({'lmc': {'kvpPrefix': 'test'}}); let br = JSON.parse(JSON.stringify(validBidRequests)); br[0]['bidder'] = 'lmc'; - const request = spec.buildRequests(br, validBidderRequest.bidderRequest); + const request = spec.buildRequests(br, validBidderRequest); const data = JSON.parse(request.data); expect(data.ext.lmc).to.haveOwnProperty('test_rw'); config.setConfig({'lmc': {'kvpPrefix': null}}); // I cant remove the key so set the value to null @@ -2155,7 +2009,7 @@ describe('ozone Adapter', function () { specMock.getGetParametersAsObject = function() { return {'oztestmode': 'mytestvalue_123'}; }; - const request = specMock.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = specMock.buildRequests(validBidRequests, validBidderRequest); const data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.customData).to.be.an('array'); expect(data.imp[0].ext.ozone.customData[0].targeting.oztestmode).to.equal('mytestvalue_123'); @@ -2165,7 +2019,7 @@ describe('ozone Adapter', function () { specMock.getGetParametersAsObject = function() { return {ozf: '1', ozpf: '0', ozrp: '2', ozip: '123'}; }; - const request = specMock.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = specMock.buildRequests(validBidRequests, validBidderRequest); const data = JSON.parse(request.data); expect(data.ext.ozone.ozf).to.equal(1); expect(data.ext.ozone.ozpf).to.equal(0); @@ -2177,7 +2031,7 @@ describe('ozone Adapter', function () { specMock.getGetParametersAsObject = function() { return {ozf: 'false', ozpf: 'true', ozrp: 'xyz', ozip: 'hello'}; }; - const request = specMock.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = specMock.buildRequests(validBidRequests, validBidderRequest); const data = JSON.parse(request.data); expect(data.ext.ozone.ozf).to.equal(0); expect(data.ext.ozone.ozpf).to.equal(1); @@ -2189,27 +2043,47 @@ describe('ozone Adapter', function () { specMock.getGetParametersAsObject = function() { return {'oztestmode': 'mytestvalue_123'}; }; - const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest.bidderRequest); + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); const data = JSON.parse(request.data); expect(data.imp[0].ext.ozone.customData).to.be.an('array'); expect(data.imp[0].ext.ozone.customData[0].targeting.oztestmode).to.equal('mytestvalue_123'); }); + it('should pass gpid to auction if it is present (gptPreAuction adapter sets this)', function () { + var specMock = utils.deepClone(spec); + let br = JSON.parse(JSON.stringify(validBidRequests)); + utils.deepSetValue(br[0], 'ortb2Imp.ext.gpid', '/22037345/projectozone'); + const request = specMock.buildRequests(br, validBidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].ext.gpid).to.equal('/22037345/projectozone'); + }); + it('should batch into 10s if config is set', function () { + config.setConfig({ozone: {'batchRequests': true}}); + var specMock = utils.deepClone(spec); + let arrReq = []; + for (let i = 0; i < 25; i++) { + let b = validBidRequests[0]; + b.adUnitCode += i; + arrReq.push(b); + } + const request = specMock.buildRequests(arrReq, validBidderRequest); + expect(request.length).to.equal(3); + config.resetConfig(); + }); it('should use GET values auction=dev & cookiesync=dev if set', function() { var specMock = utils.deepClone(spec); specMock.getGetParametersAsObject = function() { return {}; }; - let request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest.bidderRequest); + let request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); let url = request.url; expect(url).to.equal('https://elb.the-ozone-project.com/openrtb2/auction'); let cookieUrl = specMock.getCookieSyncUrl(); expect(cookieUrl).to.equal('https://elb.the-ozone-project.com/static/load-cookie.html'); - specMock = utils.deepClone(spec); specMock.getGetParametersAsObject = function() { return {'auction': 'dev', 'cookiesync': 'dev'}; }; - request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest.bidderRequest); + request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); url = request.url; expect(url).to.equal('https://test.ozpr.net/openrtb2/auction'); cookieUrl = specMock.getCookieSyncUrl(); @@ -2220,7 +2094,7 @@ describe('ozone Adapter', function () { specMock.getGetParametersAsObject = function() { return {'ozstoredrequest': '1122334455'}; // 10 digits are valid }; - const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest.bidderRequest); + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); const data = JSON.parse(request.data); expect(data.ext.ozone.oz_rw).to.equal(1); expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1122334455'); @@ -2230,71 +2104,65 @@ describe('ozone Adapter', function () { specMock.getGetParametersAsObject = function() { return {'ozstoredrequest': 'BADVAL'}; // 10 digits are valid }; - const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest.bidderRequest); + const request = specMock.buildRequests(validBidRequestsMinimal, validBidderRequest); const data = JSON.parse(request.data); expect(data.ext.ozone.oz_rw).to.equal(0); expect(data.imp[0].ext.prebid.storedrequest.id).to.equal('1310000099'); }); - it('should pick up the config value of coppa & set it in the request', function () { config.setConfig({'coppa': true}); - const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); const payload = JSON.parse(request.data); expect(payload.regs).to.include.keys('coppa'); expect(payload.regs.coppa).to.equal(1); - config.resetConfig(); }); it('should pick up the config value of coppa & only set it in the request if its true', function () { config.setConfig({'coppa': false}); - const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); const payload = JSON.parse(request.data); expect(utils.deepAccess(payload, 'regs.coppa')).to.be.undefined; - config.resetConfig(); }); it('should handle oz_omp_floor correctly', function () { config.setConfig({'ozone': {'oz_omp_floor': 1.56}}); - const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); const payload = JSON.parse(request.data); expect(utils.deepAccess(payload, 'ext.ozone.oz_omp_floor')).to.equal(1.56); - config.resetConfig(); }); it('should ignore invalid oz_omp_floor values', function () { config.setConfig({'ozone': {'oz_omp_floor': '1.56'}}); - const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsNoSizes, validBidderRequest); const payload = JSON.parse(request.data); expect(utils.deepAccess(payload, 'ext.ozone.oz_omp_floor')).to.be.undefined; - config.resetConfig(); }); it('should should contain a unique page view id in the auction request which persists across calls', function () { - let request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + let request = spec.buildRequests(validBidRequests, validBidderRequest); let payload = JSON.parse(request.data); expect(utils.deepAccess(payload, 'ext.ozone.pv')).to.be.a('string'); - request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest.bidderRequest); + request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest); let payload2 = JSON.parse(request.data); expect(utils.deepAccess(payload2, 'ext.ozone.pv')).to.be.a('string'); expect(utils.deepAccess(payload2, 'ext.ozone.pv')).to.equal(utils.deepAccess(payload, 'ext.ozone.pv')); }); it('should indicate that the whitelist was used when it contains valid data', function () { config.setConfig({'ozone': {'oz_whitelist_adserver_keys': ['oz_ozappnexus_pb', 'oz_ozappnexus_imp_id']}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const payload = JSON.parse(request.data); expect(payload.ext.ozone.oz_kvp_rw).to.equal(1); - config.resetConfig(); }); it('should indicate that the whitelist was not used when it contains no data', function () { config.setConfig({'ozone': {'oz_whitelist_adserver_keys': []}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const payload = JSON.parse(request.data); expect(payload.ext.ozone.oz_kvp_rw).to.equal(0); - config.resetConfig(); }); it('should indicate that the whitelist was not used when it is not set in the config', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const payload = JSON.parse(request.data); expect(payload.ext.ozone.oz_kvp_rw).to.equal(0); }); it('should handle ortb2 site data', function () { - config.setConfig({'ortb2': { + let bidderRequest = JSON.parse(JSON.stringify(validBidderRequest)); + bidderRequest.ortb2 = { 'site': { 'name': 'example_ortb2_name', 'domain': 'page.example.com', @@ -2306,15 +2174,15 @@ describe('ozone Adapter', function () { 'keywords': 'power tools, drills', 'search': 'drill' } - }}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); expect(payload.imp[0].ext.ozone.customData[0].targeting.name).to.equal('example_ortb2_name'); expect(payload.user.ext).to.not.have.property('gender'); - config.resetConfig(); }); it('should add ortb2 site data when there is no customData already created', function () { - config.setConfig({'ortb2': { + let bidderRequest = JSON.parse(JSON.stringify(validBidderRequest)); + bidderRequest.ortb2 = { 'site': { 'name': 'example_ortb2_name', 'domain': 'page.example.com', @@ -2326,42 +2194,41 @@ describe('ozone Adapter', function () { 'keywords': 'power tools, drills', 'search': 'drill' } - }}); - const request = spec.buildRequests(validBidRequestsNoCustomData, validBidderRequest.bidderRequest); + }; + const request = spec.buildRequests(validBidRequestsNoCustomData, bidderRequest); const payload = JSON.parse(request.data); expect(payload.imp[0].ext.ozone.customData[0].targeting.name).to.equal('example_ortb2_name'); expect(payload.imp[0].ext.ozone.customData[0].targeting).to.not.have.property('gender') - config.resetConfig(); }); it('should add ortb2 user data to the user object', function () { - config.setConfig({'ortb2': { + let bidderRequest = JSON.parse(JSON.stringify(validBidderRequest)); + bidderRequest.ortb2 = { 'user': { - 'gender': 'who knows these days' + 'gender': 'I identify as a box of rocks' } - }}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); - expect(payload.user.gender).to.equal('who knows these days'); - config.resetConfig(); + expect(payload.user.gender).to.equal('I identify as a box of rocks'); }); it('should not override the user.ext.consent string even if this is set in config ortb2', function () { - config.setConfig({'ortb2': { + let bidderRequest = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); + bidderRequest.ortb2 = { 'user': { 'ext': { 'consent': 'this is the consent override that shouldnt work', 'consent2': 'this should be set' } } - }}); - const request = spec.buildRequests(validBidRequests, bidderRequestWithFullGdpr.bidderRequest); + }; + const request = spec.buildRequests(validBidRequests, bidderRequest); const payload = JSON.parse(request.data); expect(payload.user.ext.consent2).to.equal('this should be set'); expect(payload.user.ext.consent).to.equal('BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA'); - config.resetConfig(); }); it('should have openrtb video params', function() { let allowed = ['mimes', 'minduration', 'maxduration', 'protocols', 'w', 'h', 'startdelay', 'placement', 'linearity', 'skip', 'skipmin', 'skipafter', 'sequence', 'battr', 'maxextended', 'minbitrate', 'maxbitrate', 'boxingallowed', 'playbackmethod', 'playbackend', 'delivery', 'pos', 'companionad', 'api', 'companiontype', 'ext']; - const request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest); const payload = JSON.parse(request.data); const vid = (payload.imp[0].video); const keys = Object.keys(vid); @@ -2391,13 +2258,11 @@ describe('ozone Adapter', function () { }); let localBidRequest = JSON.parse(JSON.stringify(validBidRequestsWithBannerMediaType)); localBidRequest[0].getFloor = function(x) { return {'currency': 'USD', 'floor': 0.8} }; - const request = spec.buildRequests(localBidRequest, validBidderRequest.bidderRequest); + const request = spec.buildRequests(localBidRequest, validBidderRequest); const payload = JSON.parse(request.data); expect(utils.deepAccess(payload, 'imp.0.floor.banner.currency')).to.equal('USD'); expect(utils.deepAccess(payload, 'imp.0.floor.banner.floor')).to.equal(0.8); - config.resetConfig(); }); - it('handles schain object in each bidrequest (will be the same in each br)', function () { let br = JSON.parse(JSON.stringify(validBidRequests)); let schainConfigObject = { @@ -2412,44 +2277,44 @@ describe('ozone Adapter', function () { ] }; br[0]['schain'] = schainConfigObject; - const request = spec.buildRequests(br, validBidderRequest.bidderRequest); + const request = spec.buildRequests(br, validBidderRequest); const data = JSON.parse(request.data); expect(data.source.ext).to.haveOwnProperty('schain'); expect(data.source.ext.schain).to.deep.equal(schainConfigObject); // .deep.equal() : Target object deeply (but not strictly) equals `{a: 1}` }); }); - describe('interpretResponse', function () { + beforeEach(function () { + config.resetConfig() + }) it('should build bid array', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(result.length).to.equal(1); }); - it('should have all relevant fields', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); const bid = result[0]; expect(bid.cpm).to.equal(validResponse.body.seatbid[0].bid[0].cpm); expect(bid.width).to.equal(validResponse.body.seatbid[0].bid[0].width); expect(bid.height).to.equal(validResponse.body.seatbid[0].bid[0].height); }); - it('should build bid array with gdpr', function () { - let validBR = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr.bidderRequest)); + let validBR = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); validBR.gdprConsent = {'gdprApplies': 1, 'consentString': 'This is the gdpr consent string'}; const request = spec.buildRequests(validBidRequests, validBR); // works the old way, with GDPR not enforced by default const result = spec.interpretResponse(validResponse, request); expect(result.length).to.equal(1); }); it('should build bid array with usp/CCPA', function () { - let validBR = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr.bidderRequest)); + let validBR = JSON.parse(JSON.stringify(bidderRequestWithFullGdpr)); validBR.uspConsent = '1YNY'; const request = spec.buildRequests(validBidRequests, validBR); const payload = JSON.parse(request.data); - expect(payload.user.ext.uspConsent).to.equal('1YNY'); + expect(payload.user.ext.uspConsent).not.to.exist; + expect(payload.regs.ext.us_privacy).to.equal('1YNY'); }); - it('should build bid array with only partial gdpr', function () { var validBidderRequestWithGdpr = bidderRequestWithPartialGdpr.bidderRequest; validBidderRequestWithGdpr.gdprConsent = {'gdprApplies': 1, 'consentString': 'This is the gdpr consent string'}; @@ -2457,26 +2322,22 @@ describe('ozone Adapter', function () { const payload = JSON.parse(request.data); expect(payload.user.ext.consent).to.be.a('string'); }); - it('should fail ok if no seatbid in server response', function () { const result = spec.interpretResponse({}, {}); expect(result).to.be.an('array'); expect(result).to.be.empty; }); - it('should fail ok if seatbid is not an array', function () { const result = spec.interpretResponse({'body': {'seatbid': 'nothing_here'}}, {}); expect(result).to.be.an('array'); expect(result).to.be.empty; }); - it('should have video renderer for outstream video', function () { const request = spec.buildRequests(validBidRequests1OutstreamVideo2020, validBidderRequest1OutstreamVideo2020.bidderRequest); const result = spec.interpretResponse(getCleanValidVideoResponse(), validBidderRequest1OutstreamVideo2020); const bid = result[0]; expect(bid.renderer).to.be.an.instanceOf(Renderer); }); - it('should have NO video renderer for instream video', function () { let instreamRequestsObj = JSON.parse(JSON.stringify(validBidRequests1OutstreamVideo2020)); instreamRequestsObj[0].mediaTypes.video.context = 'instream'; @@ -2487,99 +2348,87 @@ describe('ozone Adapter', function () { const bid = result[0]; expect(bid.hasOwnProperty('renderer')).to.be.false; }); - it('should correctly parse response where there are more bidders than ad slots', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validBidResponse1adWith2Bidders, request); expect(result.length).to.equal(2); }); - it('should have a ttl of 600', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(result[0].ttl).to.equal(300); }); - it('should handle oz_omp_floor_dollars correctly, inserting 1 as necessary', function () { config.setConfig({'ozone': {'oz_omp_floor': 0.01}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_omp')).to.equal('1'); - config.resetConfig(); }); it('should handle oz_omp_floor_dollars correctly, inserting 0 as necessary', function () { config.setConfig({'ozone': {'oz_omp_floor': 2.50}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_omp')).to.equal('0'); - config.resetConfig(); }); it('should handle missing oz_omp_floor_dollars correctly, inserting nothing', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_omp')).to.be.undefined; }); it('should handle ext.bidder.ozone.floor correctly, setting flr & rid as necessary', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); let vres = JSON.parse(JSON.stringify(validResponse)); vres.body.seatbid[0].bid[0].ext.bidder.ozone = {floor: 1, ruleId: 'ZjbsYE1q'}; const result = spec.interpretResponse(vres, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_flr')).to.equal(1); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_rid')).to.equal('ZjbsYE1q'); - config.resetConfig(); }); it('should handle ext.bidder.ozone.floor correctly, inserting 0 as necessary', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); let vres = JSON.parse(JSON.stringify(validResponse)); vres.body.seatbid[0].bid[0].ext.bidder.ozone = {floor: 0, ruleId: 'ZjbXXE1q'}; const result = spec.interpretResponse(vres, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_flr')).to.equal(0); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_rid')).to.equal('ZjbXXE1q'); - config.resetConfig(); }); it('should handle ext.bidder.ozone.floor correctly, inserting nothing as necessary', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); let vres = JSON.parse(JSON.stringify(validResponse)); vres.body.seatbid[0].bid[0].ext.bidder.ozone = {}; const result = spec.interpretResponse(vres, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_flr', null)).to.equal(null); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_rid', null)).to.equal(null); - config.resetConfig(); }); it('should handle ext.bidder.ozone.floor correctly, when bidder.ozone is not there', function () { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); let vres = JSON.parse(JSON.stringify(validResponse)); const result = spec.interpretResponse(vres, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_flr', null)).to.equal(null); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_rid', null)).to.equal(null); - config.resetConfig(); }); it('should handle a valid whitelist, removing items not on the list & leaving others', function () { config.setConfig({'ozone': {'oz_whitelist_adserver_keys': ['oz_appnexus_crid', 'oz_appnexus_adId']}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_adv')).to.be.undefined; expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_adId')).to.equal('2899ec066a91ff8-0-oz-0'); - config.resetConfig(); }); it('should ignore a whitelist if enhancedAdserverTargeting is false', function () { config.setConfig({'ozone': {'oz_whitelist_adserver_keys': ['oz_appnexus_crid', 'oz_appnexus_imp_id'], 'enhancedAdserverTargeting': false}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_adv')).to.be.undefined; expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_imp_id')).to.be.undefined; - config.resetConfig(); }); it('should correctly handle enhancedAdserverTargeting being false', function () { config.setConfig({'ozone': {'enhancedAdserverTargeting': false}}); - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.interpretResponse(validResponse, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_adv')).to.be.undefined; expect(utils.deepAccess(result[0].adserverTargeting, 'oz_appnexus_imp_id')).to.be.undefined; - config.resetConfig(); }); it('should add flr into ads request if floor exists in the auction response', function () { - const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest); let validres = JSON.parse(JSON.stringify(validResponse2Bids)); validres.body.seatbid[0].bid[0].ext.bidder.ozone = {'floor': 1}; const result = spec.interpretResponse(validres, request); @@ -2587,7 +2436,7 @@ describe('ozone Adapter', function () { expect(utils.deepAccess(result[1].adserverTargeting, 'oz_appnexus_flr', '')).to.equal(''); }); it('should add rid into ads request if ruleId exists in the auction response', function () { - const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest); let validres = JSON.parse(JSON.stringify(validResponse2Bids)); validres.body.seatbid[0].bid[0].ext.bidder.ozone = {'ruleId': 123}; const result = spec.interpretResponse(validres, request); @@ -2595,13 +2444,19 @@ describe('ozone Adapter', function () { expect(utils.deepAccess(result[1].adserverTargeting, 'oz_appnexus_rid', '')).to.equal(''); }); it('should add oz_ozappnexus_sid (cid value) for all appnexus bids', function () { - const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest); let validres = JSON.parse(JSON.stringify(validResponse2BidsSameAdunit)); const result = spec.interpretResponse(validres, request); expect(utils.deepAccess(result[0].adserverTargeting, 'oz_ozappnexus_sid')).to.equal(result[0].cid); }); + it('should add oz_auc_id (response id value)', function () { + const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest); + let validres = JSON.parse(JSON.stringify(validBidResponse1adWith2Bidders)); + const result = spec.interpretResponse(validres, request); + expect(utils.deepAccess(result[0].adserverTargeting, 'oz_auc_id')).to.equal(validBidResponse1adWith2Bidders.body.id); + }); it('should add unique adId values to each bid', function() { - const request = spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequests, validBidderRequest); let validres = JSON.parse(JSON.stringify(validResponse2BidsSameAdunit)); const result = spec.interpretResponse(validres, request); expect(result.length).to.equal(1); @@ -2610,7 +2465,7 @@ describe('ozone Adapter', function () { }); it('should correctly process an auction with 2 adunits & multiple bidders one of which bids for both adslots', function() { let validres = JSON.parse(JSON.stringify(multiResponse1)); - let request = spec.buildRequests(multiRequest1, multiBidderRequest1.bidderRequest); + let request = spec.buildRequests(multiRequest1, multiBidderRequest1); let result = spec.interpretResponse(validres, request); expect(result.length).to.equal(4); // one of the 5 bids will have been removed expect(result[1]['price']).to.equal(0.521); @@ -2620,15 +2475,28 @@ describe('ozone Adapter', function () { validres = JSON.parse(JSON.stringify(multiResponse1)); validres.body.seatbid[0].bid[1].price = 1.1; validres.body.seatbid[0].bid[1].cpm = 1.1; - request = spec.buildRequests(multiRequest1, multiBidderRequest1.bidderRequest); + request = spec.buildRequests(multiRequest1, multiBidderRequest1); result = spec.interpretResponse(validres, request); expect(result[1]['price']).to.equal(1.1); expect(result[1]['impid']).to.equal('3025f169863b7f8'); expect(result[1]['id']).to.equal('18552976939844681'); expect(result[1]['adserverTargeting']['oz_ozappnexus_adId']).to.equal('3025f169863b7f8-0-oz-1'); }); + it('should add mediaType: banner for a banner ad', function () { + const request = spec.buildRequests(validBidRequests, validBidderRequest); + const result = spec.interpretResponse(validResponse, request); + expect(result[0].mediaType).to.equal('banner'); + }); + it('should add mediaType: video for a video ad', function () { + let instreamRequestsObj = JSON.parse(JSON.stringify(validBidRequests1OutstreamVideo2020)); + instreamRequestsObj[0].mediaTypes.video.context = 'instream'; + let instreamBidderReq = JSON.parse(JSON.stringify(validBidderRequest1OutstreamVideo2020)); + instreamBidderReq.bidderRequest.bids[0].mediaTypes.video.context = 'instream'; + const result = spec.interpretResponse(getCleanValidVideoResponse(), instreamBidderReq); + const bid = result[0]; + expect(bid.mediaType).to.equal('video'); + }); }); - describe('userSyncs', function () { it('should fail gracefully if no server response', function () { const result = spec.getUserSyncs('bad', false, gdpr1); @@ -2639,7 +2507,7 @@ describe('ozone Adapter', function () { expect(result).to.be.empty; }); it('should append the various values if they exist', function() { - spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1); expect(result).to.be.an('array'); expect(result[0].url).to.include('publisherId=9876abcd12-3'); @@ -2648,19 +2516,18 @@ describe('ozone Adapter', function () { expect(result[0].url).to.include('gdpr_consent=BOh7mtYOh7mtYAcABBENCU-AAAAncgPIXJiiAoao0PxBFkgCAC8ACIAAQAQQAAIAAAIAAAhBGAAAQAQAEQgAAAAAAABAAAAAAAAAAAAAAACAAAAAAAACgAAAAABAAAAQAAAAAAA'); }); it('should append ccpa (usp data)', function() { - spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1, '1YYN'); expect(result).to.be.an('array'); expect(result[0].url).to.include('usp_consent=1YYN'); }); it('should use "" if no usp is sent to cookieSync', function() { - spec.buildRequests(validBidRequests, validBidderRequest.bidderRequest); + spec.buildRequests(validBidRequests, validBidderRequest); const result = spec.getUserSyncs({iframeEnabled: true}, 'good server response', gdpr1); expect(result).to.be.an('array'); expect(result[0].url).to.include('usp_consent=&'); }); }); - describe('video object utils', function () { it('should find width & height from video object', function () { let obj = {'playerSize': [640, 480], 'mimes': ['video/mp4'], 'context': 'outstream'}; @@ -2715,7 +2582,7 @@ describe('ozone Adapter', function () { expect(result).to.be.null; }); it('should add oz_appnexus_dealid into ads request if dealid exists in the auction response', function () { - const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest.bidderRequest); + const request = spec.buildRequests(validBidRequestsMulti, validBidderRequest); let validres = JSON.parse(JSON.stringify(validResponse2Bids)); validres.body.seatbid[0].bid[0].dealid = '1234'; const result = spec.interpretResponse(validres, request); @@ -2723,7 +2590,6 @@ describe('ozone Adapter', function () { expect(utils.deepAccess(result[1].adserverTargeting, 'oz_appnexus_dealid', '')).to.equal(''); }); }); - describe('default size', function () { it('should should return default sizes if no obj is sent', function () { let obj = ''; @@ -2732,7 +2598,6 @@ describe('ozone Adapter', function () { expect(result.defaultWidth).to.equal(300); }); }); - describe('getGranularityKeyName', function() { it('should return a string granularity as-is', function() { const result = getGranularityKeyName('', 'this is it', ''); @@ -2747,7 +2612,6 @@ describe('ozone Adapter', function () { expect(result).to.equal('string buckets'); }); }); - describe('getGranularityObject', function() { it('should return an object as-is', function() { const result = getGranularityObject('', {'name': 'mark'}, '', ''); @@ -2758,19 +2622,19 @@ describe('ozone Adapter', function () { expect(result.name).to.equal('rupert'); }); }); - describe('blockTheRequest', function() { + beforeEach(function () { + config.resetConfig() + }) it('should return true if oz_request is false', function() { config.setConfig({'ozone': {'oz_request': false}}); - let result = spec.blockTheRequest(bidderRequestWithFullGdpr); + let result = spec.blockTheRequest(); expect(result).to.be.true; - config.resetConfig(); }); it('should return false if oz_request is true', function() { config.setConfig({'ozone': {'oz_request': true}}); - let result = spec.blockTheRequest(bidderRequestWithFullGdpr); + let result = spec.blockTheRequest(); expect(result).to.be.false; - config.resetConfig(); }); }); describe('getPageId', function() { @@ -2876,11 +2740,10 @@ describe('ozone Adapter', function () { expect(response[1].bid.length).to.equal(2); }); }); - /** - * spec.getWhitelabelConfigItem test - get a config value for a whitelabelled bidder, - * from a standard ozone.oz_xxxx_yyy string - */ describe('getWhitelabelConfigItem', function() { + beforeEach(function () { + config.resetConfig() + }) it('should fetch the whitelabelled equivalent config value correctly', function () { var specMock = utils.deepClone(spec); config.setConfig({'ozone': {'oz_omp_floor': 'ozone-floor-value'}}); @@ -2896,7 +2759,26 @@ describe('ozone Adapter', function () { let testKey2 = 'ozone.singleRequest'; let markbidder_config2 = specMock.getWhitelabelConfigItem(testKey2); expect(markbidder_config2).to.equal('markbidder-singlerequest-value'); - config.resetConfig(); + }); + }); + describe('setBidMediaTypeIfNotExist', function() { + it('should leave the bid object alone if it already contains mediaType', function() { + let thisBid = {mediaType: 'marktest'}; + spec.setBidMediaTypeIfNotExist(thisBid, 'replacement'); + expect(thisBid.mediaType).to.equal('marktest'); + }); + it('should change the bid object if it doesnt already contain mediaType', function() { + let thisBid = {someKey: 'someValue'}; + spec.setBidMediaTypeIfNotExist(thisBid, 'replacement'); + expect(thisBid.mediaType).to.equal('replacement'); + }); + }); + describe('getLoggableBidObject', function() { + it('should return an object without a "renderer" element', function () { + let obj = {'renderer': {}, 'somevalue': '', 'h': 100}; + let ret = spec.getLoggableBidObject(obj); + expect(ret).to.not.have.own.property('renderer'); + expect(ret.h).to.equal(100); }); }); }); diff --git a/test/spec/modules/pairIdSystem_spec.js b/test/spec/modules/pairIdSystem_spec.js new file mode 100644 index 00000000000..0bb42e56c25 --- /dev/null +++ b/test/spec/modules/pairIdSystem_spec.js @@ -0,0 +1,81 @@ +import { storage, pairIdSubmodule } from 'modules/pairIdSystem.js'; +import * as utils from 'src/utils.js'; + +describe('pairId', function () { + let sandbox; + let logInfoStub; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + logInfoStub = sandbox.stub(utils, 'logInfo'); + }); + afterEach(() => { + sandbox.restore(); + }); + + it('should log an error if no ID is found when getId', function() { + pairIdSubmodule.getId({ params: {} }); + expect(logInfoStub.calledOnce).to.be.true; + }); + + it('should read pairId from local storage if exists', function() { + let pairIds = ['test-pair-id1', 'test-pair-id2', 'test-pair-id3']; + sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('pairId').returns(btoa(JSON.stringify(pairIds))); + + let id = pairIdSubmodule.getId({ params: {} }); + expect(id).to.be.deep.equal({id: pairIds}); + }); + + it('should read pairId from cookie if exists', function() { + let pairIds = ['test-pair-id4', 'test-pair-id5', 'test-pair-id6']; + sandbox.stub(storage, 'getCookie').withArgs('pairId').returns(btoa(JSON.stringify(pairIds))); + + let id = pairIdSubmodule.getId({ params: {} }); + expect(id).to.be.deep.equal({id: pairIds}); + }); + + it('should read pairId from default liveramp envelope local storage key if configured', function() { + let pairIds = ['test-pair-id1', 'test-pair-id2', 'test-pair-id3']; + sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('_lr_pairId').returns(btoa(JSON.stringify({'envelope': pairIds}))); + let id = pairIdSubmodule.getId({ + params: { + liveramp: {} + }}) + expect(id).to.be.deep.equal({id: pairIds}) + }) + + it('should read pairId from default liveramp envelope cookie entry if configured', function() { + let pairIds = ['test-pair-id4', 'test-pair-id5', 'test-pair-id6']; + sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('_lr_pairId').returns(btoa(JSON.stringify({'envelope': pairIds}))); + let id = pairIdSubmodule.getId({ + params: { + liveramp: {} + }}) + expect(id).to.be.deep.equal({id: pairIds}) + }) + + it('should read pairId from specified liveramp envelope cookie entry if configured with storageKey', function() { + let pairIds = ['test-pair-id7', 'test-pair-id8', 'test-pair-id9']; + sandbox.stub(storage, 'getDataFromLocalStorage').withArgs('lr_pairId_custom').returns(btoa(JSON.stringify({'envelope': pairIds}))); + let id = pairIdSubmodule.getId({ + params: { + liveramp: { + storageKey: 'lr_pairId_custom' + } + }}) + expect(id).to.be.deep.equal({id: pairIds}) + }) + + it('should not get data from storage if local storage and cookies are disabled', function () { + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + sandbox.stub(storage, 'cookiesAreEnabled').returns(false); + let id = pairIdSubmodule.getId({ + params: { + liveramp: { + storageKey: 'lr_pairId_custom' + } + } + }) + expect(id).to.equal(undefined) + }) +}); diff --git a/test/spec/modules/pangleBidAdapter_spec.js b/test/spec/modules/pangleBidAdapter_spec.js new file mode 100644 index 00000000000..79cbc30b4ec --- /dev/null +++ b/test/spec/modules/pangleBidAdapter_spec.js @@ -0,0 +1,187 @@ +import { expect } from 'chai'; +import { spec } from 'modules/pangleBidAdapter.js'; + +const REQUEST = [{ + adUnitCode: 'adUnitCode1', + bidId: 'bidId1', + auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708', + ortb2Imp: { + ext: { + tid: 'cccc1234', + } + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + bidder: 'pangle', + params: { + placementid: 999, + appid: 111, + }, +}, +{ + adUnitCode: 'adUnitCode2', + bidId: 'bidId2', + auctionId: 'auctionId-56a2-4f71-9098-720a68f2f708', + ortb2Imp: { + ext: { + tid: 'cccc1234', + } + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + bidder: 'pangle', + params: { + placementid: 999, + appid: 111, + }, +}]; +const DEFAULT_OPTIONS = { + userId: { + britepoolid: 'pangle-britepool', + criteoId: 'pangle-criteo', + digitrustid: { data: { id: 'pangle-digitrust' } }, + id5id: { uid: 'pangle-id5' }, + idl_env: 'pangle-idl-env', + lipb: { lipbid: 'pangle-liveintent' }, + netId: 'pangle-netid', + parrableId: { eid: 'pangle-parrable' }, + pubcid: 'pangle-pubcid', + tdid: 'pangle-ttd', + } +}; + +const RESPONSE = { + 'headers': null, + 'body': { + 'id': 'requestId', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'bidId1', + 'impid': 'bidId1', + 'price': 0.18, + 'adm': '', + 'adid': '144762342', + 'adomain': [ + 'https://dummydomain.com' + ], + 'iurl': 'iurl', + 'cid': '109', + 'crid': 'creativeId', + 'cat': [], + 'w': 300, + 'h': 250, + 'ext': { + 'prebid': { + 'type': 'banner' + }, + 'bidder': { + 'pangle': { + 'brand_id': 334553, + 'auction_id': 514667951122925701, + 'bidder_id': 2, + 'bid_ad_type': 0 + } + } + } + } + ], + 'seat': 'seat' + } + ] + } +}; + +describe('pangle bid adapter', function () { + describe('isBidRequestValid', function () { + it('should accept request if placementid and appid is passed', function () { + let bid = { + bidder: 'pangle', + params: { + token: 'xxx', + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + it('reject requests without params', function () { + let bid = { + bidder: 'pangle', + params: {} + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('creates request data', function () { + let request = spec.buildRequests(REQUEST, DEFAULT_OPTIONS)[0]; + expect(request).to.exist.and.to.be.a('object'); + const payload = request.data; + expect(payload.imp[0]).to.have.property('id', REQUEST[0].bidId); + expect(payload.imp[1]).to.have.property('id', REQUEST[1].bidId); + }); + }); + + describe('interpretResponse', function () { + it('has bids', function () { + let request = spec.buildRequests(REQUEST, DEFAULT_OPTIONS)[0]; + let bids = spec.interpretResponse(RESPONSE, request); + expect(bids).to.be.an('array').that.is.not.empty; + validateBidOnIndex(0); + + function validateBidOnIndex(index) { + expect(bids[index]).to.have.property('currency', 'USD'); + expect(bids[index]).to.have.property('requestId', RESPONSE.body.seatbid[0].bid[index].id); + expect(bids[index]).to.have.property('cpm', RESPONSE.body.seatbid[0].bid[index].price); + expect(bids[index]).to.have.property('width', RESPONSE.body.seatbid[0].bid[index].w); + expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); + expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); + expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); + expect(bids[index]).to.have.property('ttl', 30); + expect(bids[index]).to.have.property('netRevenue', true); + } + }); + + it('handles empty response', function () { + let request = spec.buildRequests(REQUEST, DEFAULT_OPTIONS)[0]; + const EMPTY_RESP = Object.assign({}, RESPONSE, { 'body': {} }); + const bids = spec.interpretResponse(EMPTY_RESP, request); + expect(bids).to.be.empty; + }); + }); + + describe('parseUserAgent', function () { + let desktop, mobile, tablet; + beforeEach(function () { + desktop = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'; + mobile = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'; + tablet = 'Apple iPad: Mozilla/5.0 (iPad; CPU OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/605.1.15'; + }); + + it('should return correct device type: tablet', function () { + let deviceType = spec.getDeviceType(tablet); + expect(deviceType).to.equal(5); + }); + + it('should return correct device type: mobile', function () { + let deviceType = spec.getDeviceType(mobile); + expect(deviceType).to.equal(4); + }); + + it('should return correct device type: desktop', function () { + let deviceType = spec.getDeviceType(desktop); + expect(deviceType).to.equal(2); + }); + }); +}); diff --git a/test/spec/modules/parrableIdSystem_spec.js b/test/spec/modules/parrableIdSystem_spec.js index a6e6185bbb2..55287e0bfec 100644 --- a/test/spec/modules/parrableIdSystem_spec.js +++ b/test/spec/modules/parrableIdSystem_spec.js @@ -96,6 +96,12 @@ function decodeBase64UrlSafe(encBase64) { } describe('Parrable ID System', function() { + after(() => { + // reset ID system to avoid delayed callbacks in other tests + config.resetConfig(); + init(config); + }); + describe('parrableIdSystem.getId()', function() { describe('response callback function', function() { let logErrorStub; @@ -128,7 +134,7 @@ describe('Parrable ID System', function() { expect(data).to.deep.equal({ eid: P_COOKIE_EID, trackers: P_CONFIG_MOCK.params.partners.split(','), - url: getRefererInfo().referer, + url: getRefererInfo().page, prebidVersion: '$prebid.version$', isIframe: true }); @@ -649,7 +655,6 @@ describe('Parrable ID System', function() { writeParrableCookie({ eid: P_COOKIE_EID, ibaOptout: true }); init(config); setSubmoduleRegistry([parrableIdSubmodule]); - config.setConfig(getConfigMock()); }); afterEach(function() { @@ -659,6 +664,7 @@ describe('Parrable ID System', function() { }); it('when a stored Parrable ID exists it is added to bids', function(done) { + config.setConfig(getConfigMock()); requestBidsHook(function() { adUnits.forEach(unit => { unit.bids.forEach(bid => { @@ -685,6 +691,7 @@ describe('Parrable ID System', function() { it('supplies an optout reason when the EID is missing due to CCPA non-consent', function(done) { // the ID system itself will not write a cookie with an EID when CCPA=true writeParrableCookie({ ccpaOptout: true }); + config.setConfig(getConfigMock()); requestBidsHook(function() { adUnits.forEach(unit => { diff --git a/test/spec/modules/permutiveRtdProvider_spec.js b/test/spec/modules/permutiveRtdProvider_spec.js index 6b44ec2b065..942ec2eaa46 100644 --- a/test/spec/modules/permutiveRtdProvider_spec.js +++ b/test/spec/modules/permutiveRtdProvider_spec.js @@ -2,22 +2,27 @@ import { permutiveSubmodule, storage, getSegments, - initSegments, isAcEnabled, isPermutiveOnPage, - setBidderRtb + setBidderRtb, + getModuleConfig, + PERMUTIVE_SUBMODULE_CONFIG_KEY, + readAndSetCohorts, + PERMUTIVE_STANDARD_KEYWORD, + PERMUTIVE_STANDARD_AUD_KEYWORD, + PERMUTIVE_CUSTOM_COHORTS_KEYWORD, } from 'modules/permutiveRtdProvider.js' -import { deepAccess } from '../../../src/utils.js' +import { deepAccess, deepSetValue, mergeDeep } from '../../../src/utils.js' import { config } from 'src/config.js' describe('permutiveRtdProvider', function () { - before(function () { + beforeEach(function () { const data = getTargetingData() setLocalStorage(data) config.resetConfig() }) - after(function () { + afterEach(function () { const data = getTargetingData() removeLocalStorage(data) config.resetConfig() @@ -29,6 +34,154 @@ describe('permutiveRtdProvider', function () { }) }) + describe('getModuleConfig', function () { + beforeEach(function () { + // Reads data from the cache + permutiveSubmodule.init() + }) + + const liftToParams = (params) => ({ params }) + + const getDefaultConfig = () => ({ + waitForIt: false, + params: { + maxSegs: 500, + acBidders: [], + overwrites: {}, + }, + }) + + const storeConfigInCacheAndInit = (data) => { + const dataToStore = { [PERMUTIVE_SUBMODULE_CONFIG_KEY]: data } + setLocalStorage(dataToStore) + // Reads data from the cache + permutiveSubmodule.init() + + // Cleanup + return () => removeLocalStorage(dataToStore) + } + + const setWindowPermutivePrebid = (getPermutiveRtdConfig) => { + // Read from Permutive + const backup = window.permutive + + deepSetValue(window, 'permutive.addons.prebid', { + getPermutiveRtdConfig, + }) + + // Cleanup + return () => window.permutive = backup + } + + it('should return default values', function () { + const config = getModuleConfig({}) + expect(config).to.deep.equal(getDefaultConfig()) + }) + + it('should override deeply on custom config', function () { + const defaultConfig = getDefaultConfig() + + const customModuleConfig = { waitForIt: true, params: { acBidders: ['123'] } } + const config = getModuleConfig(customModuleConfig) + + expect(config).to.deep.equal(mergeDeep(defaultConfig, customModuleConfig)) + }) + + it('should override deeply on cached config', function () { + const defaultConfig = getDefaultConfig() + + const cachedParamsConfig = { acBidders: ['123'] } + const cleanupCache = storeConfigInCacheAndInit(cachedParamsConfig) + + const config = getModuleConfig({}) + + expect(config).to.deep.equal(mergeDeep(defaultConfig, liftToParams(cachedParamsConfig))) + + // Cleanup + cleanupCache() + }) + + it('should override deeply on Permutive Rtd config', function () { + const defaultConfig = getDefaultConfig() + + const permutiveRtdConfigParams = { acBidders: ['123'], overwrites: { '123': true } } + const cleanupPermutive = setWindowPermutivePrebid(function () { + return permutiveRtdConfigParams + }) + + const config = getModuleConfig({}) + + expect(config).to.deep.equal(mergeDeep(defaultConfig, liftToParams(permutiveRtdConfigParams))) + + // Cleanup + cleanupPermutive() + }) + + it('should NOT use cached Permutive Rtd config if window.permutive is available', function () { + const defaultConfig = getDefaultConfig() + + // As Permutive is available on the window object, this value won't be used. + const cachedParamsConfig = { acBidders: ['123'] } + const cleanupCache = storeConfigInCacheAndInit(cachedParamsConfig) + + const permutiveRtdConfigParams = { acBidders: ['456'], overwrites: { '123': true } } + const cleanupPermutive = setWindowPermutivePrebid(function () { + return permutiveRtdConfigParams + }) + + const config = getModuleConfig({}) + + expect(config).to.deep.equal(mergeDeep(defaultConfig, liftToParams(permutiveRtdConfigParams))) + + // Cleanup + cleanupCache() + cleanupPermutive() + }) + + it('should handle calling Permutive method throwing error', function () { + const defaultConfig = getDefaultConfig() + + const cleanupPermutive = setWindowPermutivePrebid(function () { + throw new Error() + }) + + const config = getModuleConfig({}) + + expect(config).to.deep.equal(defaultConfig) + + // Cleanup + cleanupPermutive() + }) + + it('should override deeply in priority order', function () { + const defaultConfig = getDefaultConfig() + + // As Permutive is available on the window object, this value won't be used. + const cachedConfig = { acBidders: ['123'] } + const cleanupCache = storeConfigInCacheAndInit(cachedConfig) + + // Read from Permutive + const permutiveRtdConfig = { acBidders: ['456'] } + const cleanupPermutive = setWindowPermutivePrebid(function () { + return permutiveRtdConfig + }) + + const customModuleConfig = { params: { acBidders: ['789'], maxSegs: 499 } } + const config = getModuleConfig(customModuleConfig) + + // The configs are in reverse priority order as configs are merged left to right. So the priority is, + // 1. customModuleConfig <- set by publisher with pbjs.setConfig + // 2. permutiveRtdConfig <- set by the publisher using Permutive. + // 3. defaultConfig + const configMergedInPriorityOrder = mergeDeep(defaultConfig, liftToParams(permutiveRtdConfig), customModuleConfig) + expect(config).to.deep.equal(configMergedInPriorityOrder) + + // Cleanup + cleanupCache() + cleanupPermutive() + }) + }) + describe('ortb2 config', function () { beforeEach(function () { config.resetConfig() @@ -36,26 +189,83 @@ describe('permutiveRtdProvider', function () { it('should add ortb2 config', function () { const moduleConfig = getConfig() - const bidderConfig = config.getBidderConfig() + const bidderConfig = {}; const acBidders = moduleConfig.params.acBidders - const expectedTargetingData = transformedTargeting().ac.map(seg => { + const segmentsData = transformedTargeting() + const expectedTargetingData = segmentsData.ac.map(seg => { return { id: seg } }) - setBidderRtb({}, moduleConfig) + setBidderRtb(bidderConfig, moduleConfig, segmentsData) + + acBidders.forEach(bidder => { + const customCohorts = segmentsData[bidder] || [] + expect(bidderConfig[bidder].user.data).to.deep.include.members([ + { + name: 'permutive.com', + segment: expectedTargetingData, + }, + // Should have custom cohorts specific for that bidder + { + name: 'permutive', + segment: customCohorts.map(seg => { + return { id: seg } + }), + }, + ]) + }) + }) + + it('should override existing ortb2.user.data reserved by permutive RTD', function () { + const reservedPermutiveStandardName = 'permutive.com' + const reservedPermutiveCustomCohortName = 'permutive' + + const moduleConfig = getConfig() + const acBidders = moduleConfig.params.acBidders + const segmentsData = transformedTargeting() + + const sampleOrtbConfig = { + user: { + data: [ + { + name: reservedPermutiveCustomCohortName, + segment: [{ id: 'remove-me' }, { id: 'remove-me-also' }] + }, + { + name: reservedPermutiveStandardName, + segment: [{ id: 'remove-me-also-also' }, { id: 'remove-me-also-also-also' }] + } + ] + } + } + + const bidderConfig = Object.fromEntries(acBidders.map(bidder => [bidder, sampleOrtbConfig])) + + setBidderRtb(bidderConfig, moduleConfig, segmentsData) acBidders.forEach(bidder => { - expect(bidderConfig[bidder].ortb2.user.data).to.deep.include.members([{ - name: 'permutive.com', - segment: expectedTargetingData - }]) + const customCohorts = segmentsData[bidder] || [] + + expect(bidderConfig[bidder].user.data).to.not.deep.include.members([...sampleOrtbConfig.user.data]) + expect(bidderConfig[bidder].user.data).to.deep.include.members([ + { + name: reservedPermutiveCustomCohortName, + segment: customCohorts.map(id => ({ id })), + }, + { + name: reservedPermutiveStandardName, + segment: segmentsData.ac.map(id => ({ id })), + }, + ]) }) }) + it('should include ortb2 user data transformation for IAB audience taxonomy', function() { const moduleConfig = getConfig() - const bidderConfig = config.getBidderConfig() + const bidderConfig = {} const acBidders = moduleConfig.params.acBidders - const expectedTargetingData = transformedTargeting().ac.map(seg => { + const segmentsData = transformedTargeting() + const expectedTargetingData = segmentsData.ac.map(seg => { return { id: seg } }) @@ -75,10 +285,10 @@ describe('permutiveRtdProvider', function () { } ) - setBidderRtb({}, moduleConfig) + setBidderRtb(bidderConfig, moduleConfig, segmentsData) acBidders.forEach(bidder => { - expect(bidderConfig[bidder].ortb2.user.data).to.deep.include.members([ + expect(bidderConfig[bidder].user.data).to.deep.include.members([ { name: 'permutive.com', segment: expectedTargetingData @@ -93,30 +303,25 @@ describe('permutiveRtdProvider', function () { }) it('should not overwrite ortb2 config', function () { const moduleConfig = getConfig() - const bidderConfig = config.getBidderConfig() const acBidders = moduleConfig.params.acBidders + const segmentsData = transformedTargeting() + const sampleOrtbConfig = { - ortb2: { - site: { - name: 'example' - }, - user: { - keywords: 'a,b', - data: [ - { - name: 'www.dataprovider1.com', - ext: { taxonomyname: 'iab_audience_taxonomy' }, - segment: [{ id: '687' }, { id: '123' }] - } - ] - } + site: { + name: 'example' + }, + user: { + data: [ + { + name: 'www.dataprovider1.com', + ext: { taxonomyname: 'iab_audience_taxonomy' }, + segment: [{ id: '687' }, { id: '123' }] + } + ] } } - config.setBidderConfig({ - bidders: acBidders, - config: sampleOrtbConfig - }) + const bidderConfig = Object.fromEntries(acBidders.map(bidder => [bidder, sampleOrtbConfig])) const transformedUserData = { name: 'transformation', @@ -124,125 +329,233 @@ describe('permutiveRtdProvider', function () { segment: [1, 2, 3] } - setBidderRtb({}, moduleConfig, { - testTransformation: userData => transformedUserData - }) + setBidderRtb(bidderConfig, moduleConfig, segmentsData) acBidders.forEach(bidder => { - expect(bidderConfig[bidder].ortb2.site.name).to.equal(sampleOrtbConfig.ortb2.site.name) - expect(bidderConfig[bidder].ortb2.user.keywords).to.equal(sampleOrtbConfig.ortb2.user.keywords) - expect(bidderConfig[bidder].ortb2.user.data).to.deep.include.members([sampleOrtbConfig.ortb2.user.data[0]]) + expect(bidderConfig[bidder].site.name).to.equal(sampleOrtbConfig.site.name) + expect(bidderConfig[bidder].user.data).to.deep.include.members([sampleOrtbConfig.user.data[0]]) }) }) - }) + it('should update user.keywords and not override existing values', function () { + const moduleConfig = getConfig() + const acBidders = moduleConfig.params.acBidders + const segmentsData = transformedTargeting() - describe('Getting segments', function () { - it('should retrieve segments in the expected structure', function () { - const data = transformedTargeting() - expect(getSegments(250)).to.deep.equal(data) - }) - it('should enforce max segments', function () { - const max = 1 - const segments = getSegments(max) + const sampleOrtbConfig = { + site: { + name: 'example' + }, + user: { + keywords: 'a,b', + data: [ + { + name: 'www.dataprovider1.com', + ext: { taxonomyname: 'iab_audience_taxonomy' }, + segment: [{ id: '687' }, { id: '123' }] + } + ] + } + } - for (const key in segments) { - expect(segments[key]).to.have.length(max) + const bidderConfig = Object.fromEntries(acBidders.map(bidder => [bidder, sampleOrtbConfig])) + + const transformedUserData = { + name: 'transformation', + ext: { test: true }, + segment: [1, 2, 3] } - }) - }) - describe('Default segment targeting', function () { - it('sets segment targeting for Xandr', function () { - const data = transformedTargeting() - const adUnits = getAdUnits() - const config = getConfig() + setBidderRtb(bidderConfig, moduleConfig, segmentsData) + + acBidders.forEach(bidder => { + const customCohortsData = segmentsData[bidder] || [] + const keywordGroups = { + [PERMUTIVE_STANDARD_KEYWORD]: segmentsData.ac, + [PERMUTIVE_STANDARD_AUD_KEYWORD]: segmentsData.ssp.cohorts, + [PERMUTIVE_CUSTOM_COHORTS_KEYWORD]: customCohortsData + } - initSegments({ adUnits }, callback, config) + // Transform groups of key-values into a single array of strings + // i.e { permutive: ['1', '2'], p_standard: ['3', '4'] } => ['permutive=1', 'permutive=2', 'p_standard=3',' p_standard=4'] + const transformedKeywordGroups = Object.entries(keywordGroups) + .flatMap(([keyword, ids]) => ids.map(id => `${keyword}=${id}`)) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + const keywords = `${sampleOrtbConfig.user.keywords},${transformedKeywordGroups.join(',')}` - if (bidder === 'appnexus') { - expect(deepAccess(params, 'keywords.permutive')).to.eql(data.appnexus) - expect(deepAccess(params, 'keywords.p_standard')).to.eql(data.ac) - } - }) - }) + expect(bidderConfig[bidder].site.name).to.equal(sampleOrtbConfig.site.name) + expect(bidderConfig[bidder].user.data).to.deep.include.members([sampleOrtbConfig.user.data[0]]) + expect(bidderConfig[bidder].user.keywords).to.deep.equal(keywords) + }) + }) + it('should merge ortb2 correctly for ac and ssps', function () { + const customTargetingData = { + ...getTargetingData(), + '_ppam': [], + '_psegs': [], + '_pcrprs': ['abc', 'def', 'xyz'], + '_pssps': { + ssps: ['foo', 'bar'], + cohorts: ['xyz', 'uvw'], + } } + const segmentsData = transformedTargeting(customTargetingData) + setLocalStorage(customTargetingData) + + const moduleConfig = { + name: 'permutive', + waitForIt: true, + params: { + acBidders: ['foo', 'other'], + maxSegs: 30 + } + } + const bidderConfig = {}; + + setBidderRtb(bidderConfig, moduleConfig, segmentsData) + + // include both ac and ssp cohorts, as foo is both in ac bidders and ssps + const expectedFooTargetingData = [ + { id: 'abc' }, + { id: 'def' }, + { id: 'xyz' }, + { id: 'uvw' }, + ] + expect(bidderConfig['foo'].user.data).to.deep.include.members([{ + name: 'permutive.com', + segment: expectedFooTargetingData + }]) + + // don't include ac targeting as it's not in ac bidders + const expectedBarTargetingData = [ + { id: 'xyz' }, + { id: 'uvw' }, + ] + expect(bidderConfig['bar'].user.data).to.deep.include.members([{ + name: 'permutive.com', + segment: expectedBarTargetingData + }]) + + // only include ac targeting as this ssp is not in ssps list + const expectedOtherTargetingData = [ + { id: 'abc' }, + { id: 'def' }, + { id: 'xyz' }, + ] + expect(bidderConfig['other'].user.data).to.deep.include.members([{ + name: 'permutive.com', + segment: expectedOtherTargetingData + }]) }) - it('sets segment targeting for Magnite', function () { - const data = transformedTargeting() - const adUnits = getAdUnits() - const config = getConfig() - initSegments({ adUnits }, callback, config) + describe('ortb2.user.ext tests', function () { + it('should add nothing if there are no cohorts data', function () { + // Empty module config means we default + const moduleConfig = getConfig() + + const bidderConfig = {} + + // Passing empty values means there is no segment data + const segmentsData = transformedTargeting({ + _pdfps: [], + _prubicons: [], + _papns: [], + _psegs: [], + _ppam: [], + _pcrprs: [], + _pssps: { ssps: [], cohorts: [] } + }) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + setBidderRtb(bidderConfig, moduleConfig, segmentsData) - if (bidder === 'rubicon') { - expect(deepAccess(params, 'visitor.permutive')).to.eql(data.rubicon) - expect(deepAccess(params, 'visitor.p_standard')).to.eql(data.ac) - } - }) + moduleConfig.params.acBidders.forEach(bidder => { + expect(bidderConfig[bidder].user).to.not.have.property('ext') }) - } - }) - it('sets segment targeting for Ozone', function () { - const data = transformedTargeting() - const adUnits = getAdUnits() - const config = getConfig() + }) - initSegments({ adUnits }, callback, config) + it('should add standard and custom cohorts', function () { + const moduleConfig = getConfig() - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + const bidderConfig = {} - if (bidder === 'ozone') { - expect(deepAccess(params, 'customData.0.targeting.p_standard')).to.eql(data.ac) - } - }) - }) - } - }) - }) + const segmentsData = transformedTargeting() - describe('Custom segment targeting', function () { - it('sets custom segment targeting for Magnite', function () { - const data = transformedTargeting() - const adUnits = getAdUnits() - const config = getConfig() + setBidderRtb(bidderConfig, moduleConfig, segmentsData) - config.params.overwrites = { - rubicon: function (bid, data, acEnabled, utils, defaultFn) { - if (defaultFn) { - bid = defaultFn(bid, data, acEnabled) + moduleConfig.params.acBidders.forEach(bidder => { + const userExtData = { + // Default targeting + p_standard: segmentsData.ac, } - if (data.gam && data.gam.length) { - utils.deepSetValue(bid, 'params.visitor.permutive', data.gam) + + const customCohorts = segmentsData[bidder] || [] + if (customCohorts.length > 0) { + deepSetValue(userExtData, 'permutive', customCohorts) } - } - } - initSegments({ adUnits }, callback, config) + expect(bidderConfig[bidder].user.ext.data).to.deep + .eq(userExtData) + }) + }) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + it('should add ac cohorts ONLY', function () { + const moduleConfig = getConfig() - if (bidder === 'rubicon') { - expect(deepAccess(params, 'visitor.permutive')).to.eql(data.gam) - expect(deepAccess(params, 'visitor.p_standard')).to.eql(data.ac) - } + const bidderConfig = {} + + const segmentsData = transformedTargeting() + moduleConfig.params.acBidders.forEach((bidder) => { + // Remove custom cohorts + delete segmentsData[bidder] + }) + + setBidderRtb(bidderConfig, moduleConfig, segmentsData) + + moduleConfig.params.acBidders.forEach((bidder) => { + expect(bidderConfig[bidder].user.ext.data).to.deep.equal({ + p_standard: segmentsData.ac }) }) + }) + + it('should add custom cohorts ONLY', function () { + const moduleConfig = getConfig() + + const bidderConfig = {} + + const segmentsData = transformedTargeting() + // Empty the AC cohorts + segmentsData['ac'] = [] + + setBidderRtb(bidderConfig, moduleConfig, segmentsData) + + moduleConfig.params.acBidders.forEach(bidder => { + const customCohorts = segmentsData[bidder] || [] + if (customCohorts.length > 0) { + expect(bidderConfig[bidder].user.ext.data).to.deep + .eq({ permutive: customCohorts }) + } else { + expect(bidderConfig[bidder].user).to.not.have.property('ext') + } + }) + }) + }) + }) + + describe('Getting segments', function () { + it('should retrieve segments in the expected structure', function () { + const data = transformedTargeting() + expect(getSegments(250)).to.deep.equal(data) + }) + it('should enforce max segments', function () { + const max = 1 + const segments = getSegments(max) + + for (const key in segments) { + if (key === 'ssp') { + expect(segments[key].cohorts).to.have.length(max) + } else { + expect(segments[key]).to.have.length(max) + } } }) }) @@ -252,73 +565,65 @@ describe('permutiveRtdProvider', function () { const adUnits = getAdUnits() const config = getConfig() - initSegments({ adUnits }, callback, config) + readAndSetCohorts({ adUnits }, config) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + const { bidder, params } = bid - if (bidder === 'appnexus') { - expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true']) - } - }) + if (bidder === 'appnexus') { + expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true']) + } }) - } + }) }) it('doesn\'t overwrite existing key-values for Magnite', function () { const adUnits = getAdUnits() const config = getConfig() - initSegments({ adUnits }, callback, config) + readAndSetCohorts({ adUnits }, config) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + const { bidder, params } = bid - if (bidder === 'rubicon') { - expect(deepAccess(params, 'visitor.test_kv')).to.eql(['true']) - } - }) + if (bidder === 'rubicon') { + expect(deepAccess(params, 'visitor.test_kv')).to.eql(['true']) + } }) - } + }) }) it('doesn\'t overwrite existing key-values for Ozone', function () { const adUnits = getAdUnits() const config = getConfig() - initSegments({ adUnits }, callback, config) + readAndSetCohorts({ adUnits }, config) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + const { bidder, params } = bid - if (bidder === 'ozone') { - expect(deepAccess(params, 'customData.0.targeting.test_kv')).to.eql(['true']) - } - }) + if (bidder === 'ozone') { + expect(deepAccess(params, 'customData.0.targeting.test_kv')).to.eql(['true']) + } }) - } + }) }) it('doesn\'t overwrite existing key-values for TrustX', function () { const adUnits = getAdUnits() const config = getConfig() - initSegments({ adUnits }, callback, config) + readAndSetCohorts({ adUnits }, config) - function callback () { - adUnits.forEach(adUnit => { - adUnit.bids.forEach(bid => { - const { bidder, params } = bid + adUnits.forEach(adUnit => { + adUnit.bids.forEach(bid => { + const { bidder, params } = bid - if (bidder === 'trustx') { - expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true']) - } - }) + if (bidder === 'trustx') { + expect(deepAccess(params, 'keywords.test_kv')).to.eql(['true']) + } }) - } + }) }) }) @@ -371,14 +676,14 @@ function getConfig () { } } -function transformedTargeting () { - const data = getTargetingData() - +function transformedTargeting (data = getTargetingData()) { return { ac: [...data._pcrprs, ...data._ppam, ...data._psegs.filter(seg => seg >= 1000000)], appnexus: data._papns, + ix: data._pindexs, rubicon: data._prubicons, gam: data._pdfps, + ssp: data._pssps, } } @@ -389,7 +694,9 @@ function getTargetingData () { _papns: ['appnexus1', 'appnexus2'], _psegs: ['1234', '1000001', '1000002'], _ppam: ['ppam1', 'ppam2'], - _pcrprs: ['pcrprs1', 'pcrprs2'] + _pindexs: ['pindex1', 'pindex2'], + _pcrprs: ['pcrprs1', 'pcrprs2', 'dup'], + _pssps: { ssps: ['xyz', 'abc', 'dup'], cohorts: ['123', 'abc'] } } } @@ -495,6 +802,34 @@ function getAdUnits () { } } ] + }, + { + code: 'myVideoAdUnit', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4', 'video/x-ms-wmv'], + protocols: [2, 3, 5, 6], + api: [2], + maxduration: 30, + linearity: 1 + } + }, + bids: [{ + bidder: 'rubicon', + params: { + accountId: '9840', + siteId: '123564', + zoneId: '583584', + video: { + language: 'en' + }, + visitor: { + test_kv: ['true'] + } + } + }] } ] } diff --git a/test/spec/modules/pgamsspBidAdapter_spec.js b/test/spec/modules/pgamsspBidAdapter_spec.js new file mode 100644 index 00000000000..7e2323d4b81 --- /dev/null +++ b/test/spec/modules/pgamsspBidAdapter_spec.js @@ -0,0 +1,399 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/pgamsspBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'pgamssp' + +describe('PGAMBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://us-east.pgammedia.com/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.pgammedia.com/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0') + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.pgammedia.com/image?pbjs=1&ccpa_consent=1---&coppa=0') + }); + }); +}); diff --git a/test/spec/modules/pianoDmpAnalyticsAdapter_spec.js b/test/spec/modules/pianoDmpAnalyticsAdapter_spec.js new file mode 100644 index 00000000000..0c4949264a7 --- /dev/null +++ b/test/spec/modules/pianoDmpAnalyticsAdapter_spec.js @@ -0,0 +1,63 @@ +import pianoDmpAnalytics from 'modules/pianoDmpAnalyticsAdapter.js'; +import adapterManager from 'src/adapterManager'; +import * as events from 'src/events'; +import constants from 'src/constants.json'; +import { expect } from 'chai'; + +describe('Piano DMP Analytics Adapter', () => { + let sandbox; + + beforeEach(() => { + sandbox = sinon.createSandbox(); + + sandbox.stub(events, 'getEvents').returns([]); + }); + + afterEach(() => { + sandbox.restore(); + }); + + describe('track', () => { + beforeEach(() => { + adapterManager.enableAnalytics({ + provider: 'pianoDmp', + }); + }); + + afterEach(() => { + delete window.cX; + pianoDmpAnalytics.disableAnalytics(); + }); + + it('should pass events to call queue', () => { + const eventsList = [ + constants.EVENTS.AUCTION_INIT, + constants.EVENTS.AUCTION_END, + constants.EVENTS.BID_ADJUSTMENT, + constants.EVENTS.BID_TIMEOUT, + constants.EVENTS.BID_REQUESTED, + constants.EVENTS.BID_RESPONSE, + constants.EVENTS.NO_BID, + constants.EVENTS.BID_WON, + ]; + + // Given + const testEvents = eventsList.map((event) => ({ + event, + args: { test: event }, + })); + + // When + testEvents.forEach(({ event, args }) => events.emit(event, args)); + + // Then + const callQueue = (window.cX || {}).callQueue; + + testEvents.forEach(({event, args}) => { + const [method, params] = callQueue.filter(item => item[1].eventType === event)[0]; + expect(method).to.equal('prebid'); + expect(params.params).to.deep.equal(args); + }) + }); + }); +}); diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index a0c7903091c..717a5cd6c6d 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -1,23 +1,45 @@ -import { expect } from 'chai'; -import { PrebidServer as Adapter, resetSyncedStatus, resetWurlMap } from 'modules/prebidServerBidAdapter/index.js'; -import adapterManager from 'src/adapterManager.js'; +/* eslint-disable no-trailing-spaces */ +import {expect} from 'chai'; +import { + PrebidServer as Adapter, + resetSyncedStatus, + resetWurlMap, + s2sDefaultConfig +} from 'modules/prebidServerBidAdapter/index.js'; +import adapterManager, {PBS_ADAPTER_NAME} from 'src/adapterManager.js'; import * as utils from 'src/utils.js'; -import { ajax } from 'src/ajax.js'; -import { config } from 'src/config.js'; +import {deepAccess, deepClone, mergeDeep} from 'src/utils.js'; +import {ajax} from 'src/ajax.js'; +import {config} from 'src/config.js'; import * as events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; -import { server } from 'test/mocks/xhr.js'; -import { createEidsArray } from 'modules/userId/eids.js'; -import { deepAccess, deepClone } from 'src/utils.js'; -import 'modules/appnexusBidAdapter.js' // appnexus alias test -import 'modules/rubiconBidAdapter.js' // rubicon alias test -import 'src/prebid.js' // $$PREBID_GLOBAL$$.aliasBidder test -import 'modules/currency.js' // adServerCurrency test -import { hook } from '../../../src/hook.js'; -import { decorateAdUnitsWithNativeParams } from '../../../src/native.js'; -import { auctionManager } from '../../../src/auctionManager.js'; -import { stubAuctionIndex } from '../../helpers/indexStub.js'; -import { registerBidder } from 'src/adapters/bidderFactory.js'; +import {server} from 'test/mocks/xhr.js'; +import {createEidsArray} from 'modules/userId/eids.js'; +import 'modules/appnexusBidAdapter.js'; // appnexus alias test +import 'modules/rubiconBidAdapter.js'; // rubicon alias test +import 'src/prebid.js'; // $$PREBID_GLOBAL$$.aliasBidder test +import 'modules/currency.js'; // adServerCurrency test +import 'modules/userId/index.js'; +import 'modules/multibid/index.js'; +import 'modules/priceFloors.js'; +import 'modules/consentManagement.js'; +import 'modules/consentManagementUsp.js'; +import 'modules/schain.js'; +import 'modules/fledgeForGpt.js'; +import * as redactor from 'src/activities/redactor.js'; +import * as activityRules from 'src/activities/rules.js'; +import {hook} from '../../../src/hook.js'; +import {decorateAdUnitsWithNativeParams} from '../../../src/native.js'; +import {auctionManager} from '../../../src/auctionManager.js'; +import {stubAuctionIndex} from '../../helpers/indexStub.js'; +import {addComponentAuction, registerBidder} from 'src/adapters/bidderFactory.js'; +import {getGlobal} from '../../../src/prebidGlobal.js'; +import {syncAddFPDEnrichments, syncAddFPDToBidderRequest} from '../../helpers/fpd.js'; +import {deepSetValue} from '../../../src/utils.js'; +import {sandbox} from 'sinon'; +import {ACTIVITY_TRANSMIT_UFPD} from '../../../src/activities/activities.js'; +import {activityParams} from '../../../src/activities/activityParams.js'; +import {MODULE_TYPE_PREBID} from '../../../src/activities/modules.js'; let CONFIG = { accountId: '1', @@ -86,6 +108,84 @@ const REQUEST = { ] }; +const NATIVE_ORTB_MTO = { + ortb: { + context: 3, + plcmttype: 2, + eventtrackers: [ + { + event: 1, + methods: [ + 1 + ] + }, + { + event: 2, + methods: [ + 2 + ] + } + ], + assets: [ + { + id: 1, + required: 1, + img: { + type: 3, + w: 300, + h: 250 + } + }, + { + id: 2, + required: 1, + img: { + type: 1, + w: 127, + h: 83 + } + }, + { + id: 3, + required: 1, + data: { + type: 1, + len: 25 + } + }, + { + id: 4, + required: 1, + title: { + len: 140 + } + }, + { + id: 5, + required: 1, + data: { + type: 2, + len: 40 + } + }, + { + id: 6, + required: 1, + data: { + type: 12, + len: 15 + } + }, + ], + ext: { + custom_param: { + key: 'custom_value' + } + }, + ver: '1.2' + } +} + const VIDEO_REQUEST = { 'account_id': '1', 'tid': '437fbbf5-33f5-487a-8e16-a7112903cfe5', @@ -452,11 +552,23 @@ const RESPONSE_OPENRTB_NATIVE = { ] }; +function addFpdEnrichmentsToS2SRequest(s2sReq, bidderRequests) { + return { + ...s2sReq, + ortb2Fragments: { + ...(s2sReq.ortb2Fragments || {}), + global: syncAddFPDToBidderRequest({...(bidderRequests?.[0] || {}), ortb2: s2sReq.ortb2Fragments?.global || {}}).ortb2 + } + } +} + describe('S2S Adapter', function () { let adapter, addBidResponse = sinon.spy(), done = sinon.spy(); + addBidResponse.reject = sinon.spy(); + function prepRequest(req) { req.ad_units.forEach((adUnit) => { delete adUnit.nativeParams @@ -471,6 +583,7 @@ describe('S2S Adapter', function () { beforeEach(function () { config.resetConfig(); + config.setConfig({floors: {enabled: false}}); adapter = new Adapter(); BID_REQUESTS = [ { @@ -500,8 +613,7 @@ describe('S2S Adapter', function () { 'sizes': [300, 250], 'bidId': '123', 'bidderRequestId': '3d1063078dfcc8', - 'auctionId': '173afb6d132ba3', - 'storedAuctionResponse': 11111 + 'auctionId': '173afb6d132ba3' } ], 'auctionStart': 1510852447530, @@ -509,7 +621,7 @@ describe('S2S Adapter', function () { 'src': 's2s', 'doneCbCallCount': 0, 'refererInfo': { - 'referer': 'http://mytestpage.com' + 'page': 'http://mytestpage.com' } } ]; @@ -517,6 +629,7 @@ describe('S2S Adapter', function () { afterEach(function () { addBidResponse.resetHistory(); + addBidResponse.reject = sinon.spy(); done.resetHistory(); }); @@ -529,15 +642,135 @@ describe('S2S Adapter', function () { resetSyncedStatus(); }); - it('should set id to auction ID and source.tid to tid', function () { - config.setConfig({ s2sConfig: CONFIG }); + describe('FPD redaction', () => { + let sandbox, ortb2Fragments, redactorMocks, s2sReq; - adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + beforeEach(() => { + sandbox = sinon.sandbox.create(); + redactorMocks = {}; + sandbox.stub(redactor, 'redactor').callsFake((params) => { + if (!redactorMocks.hasOwnProperty(params.component)) { + redactorMocks[params.component] = { + ortb2: sinon.stub().callsFake(o => o), + bidRequest: sinon.stub().callsFake(o => o) + } + } + return redactorMocks[params.component]; + }) + ortb2Fragments = { + global: { + mock: 'value' + }, + bidder: { + appnexus: { + mock: 'A' + } + } + } + const s2sConfig = { + ...CONFIG, + }; + config.setConfig({s2sConfig}); + s2sReq = { + ...REQUEST, + s2sConfig + }; + }); - const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.id).to.equal('173afb6d132ba3'); - expect(requestBid.source).to.be.an('object'); - expect(requestBid.source.tid).to.equal('437fbbf5-33f5-487a-8e16-a7112903cfe5'); + afterEach(() => { + sandbox.restore(); + }) + + function callBids() { + adapter.callBids({ + ...s2sReq, + ortb2Fragments + }, BID_REQUESTS, addBidResponse, done, ajax); + } + + it('should be applied to ortb2Fragments', () => { + callBids(); + sinon.assert.calledWithMatch(redactorMocks['prebid.pbsBidAdapter'].ortb2, ortb2Fragments.global); + Object.entries(ortb2Fragments.bidder).forEach(([bidder, ortb2]) => { + sinon.assert.calledWith(redactorMocks[`bidder.${bidder}`].ortb2, ortb2); + }); + }); + + it('should be applied to ad units', () => { + callBids(); + s2sReq.ad_units.forEach(au => { + sinon.assert.calledWith(redactorMocks['prebid.pbsBidAdapter'].bidRequest, au); + au.bids.forEach((bid) => { + sinon.assert.calledWith(redactorMocks[`bidder.${bid.bidder}`].bidRequest, bid); + }) + }) + }) + }); + + describe('transaction IDs', () => { + let s2sReq; + beforeEach(() => { + s2sReq = { + ...REQUEST, + ortb2Fragments: {global: {}}, + ad_units: REQUEST.ad_units.map(au => ({...au, ortb2Imp: {ext: {tid: 'mock-tid'}}})), + }; + BID_REQUESTS[0].bids[0].ortb2Imp = {ext: {tid: 'mock-tid'}}; + }); + + function makeRequest() { + adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax); + return JSON.parse(server.requests[0].requestBody); + } + + it('should not be set when transmitTid is not allowed, with ext.prebid.createtids: false', () => { + config.setConfig({ s2sConfig: CONFIG, enableTIDs: false }); + const req = makeRequest(); + expect(req.source?.tid).to.not.exist; + expect(req.imp[0].ext?.tid).to.not.exist; + expect(req.ext.prebid.createtids).to.equal(false); + }); + + it('should be set to auction ID otherwise', () => { + config.setConfig({s2sConfig: CONFIG, enableTIDs: true}); + const req = makeRequest(); + expect(req.source.tid).to.eql(BID_REQUESTS[0].auctionId); + expect(req.imp[0].ext.tid).to.eql('mock-tid'); + }) + }) + + describe('browsingTopics', () => { + const sandbox = sinon.createSandbox(); + afterEach(() => { + sandbox.restore() + }); + Object.entries({ + 'allowed': true, + 'not allowed': false, + }).forEach(([t, allow]) => { + it(`should be set to ${allow} when transmitUfpd is ${t}`, () => { + sandbox.stub(activityRules, 'isActivityAllowed').callsFake((activity, params) => { + if (activity === ACTIVITY_TRANSMIT_UFPD && params.component === `${MODULE_TYPE_PREBID}.${PBS_ADAPTER_NAME}`) { + return allow; + } + return false; + }); + config.setConfig({s2sConfig: CONFIG}); + const ajax = sinon.stub(); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + sinon.assert.calledWith(ajax, sinon.match.any, sinon.match.any, sinon.match.any, sinon.match({ + browsingTopics: allow + })); + }); + }); + }) + + it('should set tmax to s2sConfig.timeout', () => { + const cfg = {...CONFIG, timeout: 123}; + config.setConfig({s2sConfig: cfg}); + adapter.callBids({...REQUEST, s2sConfig: cfg}, BID_REQUESTS, addBidResponse, done, ajax); + const req = JSON.parse(server.requests[0].requestBody); + expect(req.tmax).to.eql(123); }); it('should block request if config did not define p1Consent URL in endpoint object config', function () { @@ -594,56 +827,66 @@ describe('S2S Adapter', function () { expect(server.requests.length).to.equal(0); }); - it('should add outstream bc renderer exists on mediatype', function () { - config.setConfig({ s2sConfig: CONFIG }); + if (FEATURES.VIDEO) { + it('should add outstream bc renderer exists on mediatype', function () { + config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(OUTSTREAM_VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.imp[0].banner).to.exist; - expect(requestBid.imp[0].video).to.exist; - }); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp[0].banner).to.exist; + expect(requestBid.imp[0].video).to.exist; + }); - it('should default video placement if not defined and instream', function () { - let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + it('should default video placement if not defined and instream', function () { + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; - config.setConfig({ s2sConfig: ortb2Config }); + config.setConfig({ s2sConfig: ortb2Config }); - let videoBid = utils.deepClone(VIDEO_REQUEST); - videoBid.ad_units[0].mediaTypes.video.context = 'instream'; - adapter.callBids(videoBid, BID_REQUESTS, addBidResponse, done, ajax); + let videoBid = utils.deepClone(VIDEO_REQUEST); + videoBid.ad_units[0].mediaTypes.video.context = 'instream'; + adapter.callBids(videoBid, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.imp[0].banner).to.not.exist; - expect(requestBid.imp[0].video).to.exist; - expect(requestBid.imp[0].video.placement).to.equal(1); - }); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp[0].banner).to.not.exist; + expect(requestBid.imp[0].video).to.exist; + expect(requestBid.imp[0].video.placement).to.equal(1); + }); - it('converts video mediaType properties into openRTB format', function () { - let ortb2Config = utils.deepClone(CONFIG); - ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; + it('converts video mediaType properties into openRTB format', function () { + let ortb2Config = utils.deepClone(CONFIG); + ortb2Config.endpoint.p1Consent = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'; - config.setConfig({ s2sConfig: ortb2Config }); + config.setConfig({ s2sConfig: ortb2Config }); - let videoBid = utils.deepClone(VIDEO_REQUEST); - videoBid.ad_units[0].mediaTypes.video.context = 'instream'; - adapter.callBids(videoBid, BID_REQUESTS, addBidResponse, done, ajax); + let videoBid = utils.deepClone(VIDEO_REQUEST); + videoBid.ad_units[0].mediaTypes.video.context = 'instream'; + adapter.callBids(videoBid, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.imp[0].banner).to.not.exist; - expect(requestBid.imp[0].video).to.exist; - expect(requestBid.imp[0].video.placement).to.equal(1); - expect(requestBid.imp[0].video.w).to.equal(640); - expect(requestBid.imp[0].video.h).to.equal(480); - expect(requestBid.imp[0].video.playerSize).to.be.undefined; - expect(requestBid.imp[0].video.context).to.be.undefined; - }); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp[0].banner).to.not.exist; + expect(requestBid.imp[0].video).to.exist; + expect(requestBid.imp[0].video.placement).to.equal(1); + expect(requestBid.imp[0].video.w).to.equal(640); + expect(requestBid.imp[0].video.h).to.equal(480); + expect(requestBid.imp[0].video.playerSize).to.be.undefined; + expect(requestBid.imp[0].video.context).to.be.undefined; + }); + } it('exists and is a function', function () { expect(adapter.callBids).to.exist.and.to.be.a('function'); }); + function mockTCF({applies = true, hasP1Consent = true} = {}) { + return { + consentString: 'mockConsent', + gdprApplies: applies, + vendorData: {purpose: {consents: {1: hasP1Consent}}}, + } + } + describe('gdpr tests', function () { afterEach(function () { $$PREBID_GLOBAL$$.requestBids.removeAll(); @@ -654,21 +897,18 @@ describe('S2S Adapter', function () { config.setConfig(consentConfig); let gdprBidRequest = utils.deepClone(BID_REQUESTS); - gdprBidRequest[0].gdprConsent = { - consentString: 'abc123', - gdprApplies: true - }; + gdprBidRequest[0].gdprConsent = mockTCF(); - adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, gdprBidRequest), gdprBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.gdpr).is.equal(1); - expect(requestBid.user.ext.consent).is.equal('abc123'); + expect(requestBid.user.ext.consent).is.equal('mockConsent'); config.resetConfig(); config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); requestBid = JSON.parse(server.requests[1].requestBody); expect(requestBid.regs).to.not.exist; @@ -680,17 +920,15 @@ describe('S2S Adapter', function () { config.setConfig(consentConfig); let gdprBidRequest = utils.deepClone(BID_REQUESTS); - gdprBidRequest[0].gdprConsent = { - consentString: 'abc123', + gdprBidRequest[0].gdprConsent = Object.assign(mockTCF(), { addtlConsent: 'superduperconsent', - gdprApplies: true - }; + }); - adapter.callBids(REQUEST, gdprBidRequest, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, gdprBidRequest), gdprBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.gdpr).is.equal(1); - expect(requestBid.user.ext.consent).is.equal('abc123'); + expect(requestBid.user.ext.consent).is.equal('mockConsent'); expect(requestBid.user.ext.ConsentedProvidersSettings.consented_providers).is.equal('superduperconsent'); config.resetConfig(); @@ -702,78 +940,6 @@ describe('S2S Adapter', function () { expect(requestBid.regs).to.not.exist; expect(requestBid.user).to.not.exist; }); - - it('check gdpr info gets added into cookie_sync request: have consent data', function () { - let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; - - let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: cookieSyncConfig }; - config.setConfig(consentConfig); - - let gdprBidRequest = utils.deepClone(BID_REQUESTS); - - gdprBidRequest[0].gdprConsent = { - consentString: 'abc123def', - gdprApplies: true - }; - - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = cookieSyncConfig; - - adapter.callBids(s2sBidRequest, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(server.requests[0].requestBody); - - expect(requestBid.gdpr).is.equal(1); - expect(requestBid.gdpr_consent).is.equal('abc123def'); - expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); - expect(requestBid.account).is.equal('1'); - }); - - it('check gdpr info gets added into cookie_sync request: have consent data but gdprApplies is false', function () { - let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; - - let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: cookieSyncConfig }; - config.setConfig(consentConfig); - - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = cookieSyncConfig; - - let gdprBidRequest = utils.deepClone(BID_REQUESTS); - gdprBidRequest[0].gdprConsent = { - consentString: 'xyz789abcc', - gdprApplies: false - }; - - adapter.callBids(s2sBidRequest, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(server.requests[0].requestBody); - - expect(requestBid.gdpr).is.equal(0); - expect(requestBid.gdpr_consent).is.undefined; - }); - - it('checks gdpr info gets added to cookie_sync request: applies is false', function () { - let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; - - let consentConfig = { consentManagement: { cmpApi: 'iab' }, s2sConfig: cookieSyncConfig }; - config.setConfig(consentConfig); - - let gdprBidRequest = utils.deepClone(BID_REQUESTS); - gdprBidRequest[0].gdprConsent = { - consentString: undefined, - gdprApplies: false - }; - - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = cookieSyncConfig; - - adapter.callBids(s2sBidRequest, gdprBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(server.requests[0].requestBody); - - expect(requestBid.gdpr).is.equal(0); - expect(requestBid.gdpr_consent).is.undefined; - }); }); describe('us_privacy (ccpa) consent data', function () { @@ -781,13 +947,13 @@ describe('S2S Adapter', function () { $$PREBID_GLOBAL$$.requestBids.removeAll(); }); - it('is added to ortb2 request when in bidRequest', function () { + it('is added to ortb2 request when in FPD', function () { config.setConfig({ s2sConfig: CONFIG }); let uspBidRequest = utils.deepClone(BID_REQUESTS); uspBidRequest[0].uspConsent = '1NYN'; - adapter.callBids(REQUEST, uspBidRequest, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, uspBidRequest), uspBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.us_privacy).is.equal('1NYN'); @@ -795,30 +961,11 @@ describe('S2S Adapter', function () { config.resetConfig(); config.setConfig({ s2sConfig: CONFIG }); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); requestBid = JSON.parse(server.requests[1].requestBody); expect(requestBid.regs).to.not.exist; }); - - it('is added to cookie_sync request when in bidRequest', function () { - let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; - config.setConfig({ s2sConfig: cookieSyncConfig }); - - let uspBidRequest = utils.deepClone(BID_REQUESTS); - uspBidRequest[0].uspConsent = '1YNN'; - - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = cookieSyncConfig; - - adapter.callBids(s2sBidRequest, uspBidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(server.requests[0].requestBody); - - expect(requestBid.us_privacy).is.equal('1YNN'); - expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); - expect(requestBid.account).is.equal('1'); - }); }); describe('gdpr and us_privacy (ccpa) consent data', function () { @@ -831,17 +978,14 @@ describe('S2S Adapter', function () { let consentBidRequest = utils.deepClone(BID_REQUESTS); consentBidRequest[0].uspConsent = '1NYN'; - consentBidRequest[0].gdprConsent = { - consentString: 'abc123', - gdprApplies: true - }; + consentBidRequest[0].gdprConsent = mockTCF(); - adapter.callBids(REQUEST, consentBidRequest, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, consentBidRequest), consentBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.regs.ext.us_privacy).is.equal('1NYN'); expect(requestBid.regs.ext.gdpr).is.equal(1); - expect(requestBid.user.ext.consent).is.equal('abc123'); + expect(requestBid.user.ext.consent).is.equal('mockConsent'); config.resetConfig(); config.setConfig({ s2sConfig: CONFIG }); @@ -860,10 +1004,7 @@ describe('S2S Adapter', function () { let consentBidRequest = utils.deepClone(BID_REQUESTS); consentBidRequest[0].uspConsent = '1YNN'; - consentBidRequest[0].gdprConsent = { - consentString: 'abc123def', - gdprApplies: true - }; + consentBidRequest[0].gdprConsent = mockTCF(); const s2sBidRequest = utils.deepClone(REQUEST); s2sBidRequest.s2sConfig = cookieSyncConfig @@ -873,7 +1014,7 @@ describe('S2S Adapter', function () { expect(requestBid.us_privacy).is.equal('1YNN'); expect(requestBid.gdpr).is.equal(1); - expect(requestBid.gdpr_consent).is.equal('abc123def'); + expect(requestBid.gdpr_consent).is.equal('mockConsent'); expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); expect(requestBid.account).is.equal('1'); }); @@ -887,14 +1028,14 @@ describe('S2S Adapter', function () { }; config.setConfig(_config); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.device).to.deep.equal({ + sinon.assert.match(requestBid.device, { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC', w: window.innerWidth, h: window.innerHeight - }); - expect(requestBid.app).to.deep.equal({ + }) + sinon.assert.match(requestBid.app, { bundle: 'com.test.app', publisher: { 'id': '1' } }); @@ -914,37 +1055,19 @@ describe('S2S Adapter', function () { }; config.setConfig(_config); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.device).to.deep.equal({ + sinon.assert.match(requestBid.device, { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC', w: window.innerWidth, h: window.innerHeight - }); - expect(requestBid.app).to.deep.equal({ + }) + sinon.assert.match(requestBid.app, { bundle: 'com.test.app', publisher: { 'id': '1' } }); }); - it('adds debugging value from storedAuctionResponse to OpenRTB', function () { - const _config = { - s2sConfig: CONFIG, - device: { ifa: '6D92078A-8246-4BA4-AE5B-76104861E7DC' }, - app: { bundle: 'com.test.app' } - }; - - config.setConfig(_config); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.imp).to.exist.and.to.be.a('array'); - expect(requestBid.imp).to.have.lengthOf(1); - expect(requestBid.imp[0].ext).to.exist.and.to.be.a('object'); - expect(requestBid.imp[0].ext.prebid).to.exist.and.to.be.a('object'); - expect(requestBid.imp[0].ext.prebid.storedauctionresponse).to.exist.and.to.be.a('object'); - expect(requestBid.imp[0].ext.prebid.storedauctionresponse.id).to.equal('11111'); - }); - describe('price floors module', function () { function runTest(expectedFloor, expectedCur) { adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -979,6 +1102,8 @@ describe('S2S Adapter', function () { expect( BID_REQUESTS[0].bids[0].getFloor.calledWith({ currency: 'USD', + mediaType: '*', + size: '*' }) ).to.be.true; @@ -1008,6 +1133,8 @@ describe('S2S Adapter', function () { expect( BID_REQUESTS[0].bids[0].getFloor.calledWith({ currency: 'USD', + mediaType: '*', + size: '*' }) ).to.be.true; @@ -1035,56 +1162,227 @@ describe('S2S Adapter', function () { expect( BID_REQUESTS[0].bids[0].getFloor.calledWith({ currency: 'JPY', + mediaType: '*', + size: '*' }) ).to.be.true; }); - }); - it('adds device.w and device.h even if the config lacks a device object', function () { - const _config = { - s2sConfig: CONFIG, - app: { bundle: 'com.test.app' }, - }; + it('should find the floor when not all bidderRequests contain it', () => { + config.setConfig({ + s2sConfig: { + ...CONFIG, + bidders: ['b1', 'b2'] + }, + }); + const bidderRequests = [ + { + ...BID_REQUESTS[0], + bidderCode: 'b1', + bids: [{ + bidder: 'b1', + bidId: 1, + }] + }, + { + ...BID_REQUESTS[0], + bidderCode: 'b2', + bids: [{ + bidder: 'b2', + bidId: 2, + getFloor: () => ({ + currency: 'CUR', + floor: 123 + }) + }], + } + ]; + const adUnits = [ + { + code: 'au1', + transactionId: 't1', + mediaTypes: { + banner: {sizes: [1, 1]} + }, + bids: [{bidder: 'b1', bid_id: 1}] + }, + { + code: 'au2', + transactionId: 't2', + bids: [{bidder: 'b2', bid_id: 2}], + mediaTypes: { + banner: {sizes: [1, 1]} + } + } + ]; + const s2sReq = { + ...REQUEST, + ad_units: adUnits + } - config.setConfig(_config); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.device).to.deep.equal({ - w: window.innerWidth, - h: window.innerHeight - }); - expect(requestBid.app).to.deep.equal({ - bundle: 'com.test.app', - publisher: { 'id': '1' } + adapter.callBids(s2sReq, bidderRequests, addBidResponse, done, ajax); + + const pbsReq = JSON.parse(server.requests[server.requests.length - 1].requestBody); + const [imp1, imp2] = pbsReq.imp; + + expect(imp1.bidfloor).to.be.undefined; + expect(imp1.bidfloorcur).to.be.undefined; + + expect(imp2.bidfloor).to.eql(123); + expect(imp2.bidfloorcur).to.eql('CUR'); }); - }); - it('adds native request for OpenRTB', function () { - const _config = { - s2sConfig: CONFIG - }; + describe('when different bids have different floors', () => { + let s2sReq; + beforeEach(() => { + config.setConfig({ + s2sConfig: { + ...CONFIG, + bidders: ['b1', 'b2', 'b3'] + }, + }); + BID_REQUESTS = [ + { + ...BID_REQUESTS[0], + bidderCode: 'b2', + bids: [{ + bidder: 'b2', + bidId: 2, + getFloor: () => ({ + currency: '1', + floor: 2 + }) + }], + }, + { + ...BID_REQUESTS[0], + bidderCode: 'b1', + bids: [{ + bidder: 'b1', + bidId: 1, + getFloor: () => ({ + floor: 10, + currency: '0.1' + }) + }] + }, + { + ...BID_REQUESTS[0], + bidderCode: 'b3', + bids: [{ + bidder: 'b3', + bidId: 3, + getFloor: () => ({ + currency: '10', + floor: 1 + }) + }], + } + ]; + s2sReq = { + ...REQUEST, + ad_units: [ + { + code: 'au1', + transactionId: 't1', + mediaTypes: { + banner: {sizes: [1, 1]} + }, + bids: [ + {bidder: 'b2', bid_id: 2}, + {bidder: 'b3', bid_id: 3}, + {bidder: 'b1', bid_id: 1}, + ] + } + ] + }; + }); - config.setConfig(_config); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - const requestBid = JSON.parse(server.requests[0].requestBody); + Object.entries({ + 'cannot compute a floor': (bid) => { bid.getFloor = () => { throw new Error() } }, + 'does not set a floor': (bid) => { delete bid.getFloor; }, + }).forEach(([t, updateBid]) => { + it(`should not set pricefloor if any one of them ${t}`, () => { + updateBid(BID_REQUESTS[1].bids[0]); + adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax); + const pbsReq = JSON.parse(server.requests[server.requests.length - 1].requestBody); + expect(pbsReq.imp[0].bidfloor).to.be.undefined; + expect(pbsReq.imp[0].bidfloorcur).to.be.undefined; + }); + }) - expect(requestBid.imp[0].native).to.deep.equal({ - request: JSON.stringify({ - 'context': 1, - 'plcmttype': 1, - 'eventtrackers': [{ - event: 1, - methods: [1] - }], + Object.entries({ + 'is available': { + expectDesc: 'minimum after conversion', + expectedFloor: 10, + expectedCur: '0.1', + conversionFn: (amount, from, to) => { + from = parseFloat(from); + to = parseFloat(to); + return amount * from / to; + }, + }, + 'is not available': { + expectDesc: 'absolute minimum', + expectedFloor: 1, + expectedCur: '10', + conversionFn: null + }, + 'is not working': { + expectDesc: 'absolute minimum', + expectedFloor: 1, + expectedCur: '10', + conversionFn: () => { + throw new Error(); + } + } + }).forEach(([t, {expectDesc, expectedFloor, expectedCur, conversionFn}]) => { + describe(`and currency conversion ${t}`, () => { + let mockConvertCurrency; + const origConvertCurrency = getGlobal().convertCurrency; + beforeEach(() => { + if (conversionFn) { + getGlobal().convertCurrency = mockConvertCurrency = sinon.stub().callsFake(conversionFn) + } else { + mockConvertCurrency = null; + delete getGlobal().convertCurrency; + } + }); + + afterEach(() => { + if (origConvertCurrency != null) { + getGlobal().convertCurrency = origConvertCurrency; + } else { + delete getGlobal().convertCurrency; + } + }); + + it(`should pick the ${expectDesc}`, () => { + adapter.callBids(s2sReq, BID_REQUESTS, addBidResponse, done, ajax); + const pbsReq = JSON.parse(server.requests[server.requests.length - 1].requestBody); + expect(pbsReq.imp[0].bidfloor).to.eql(expectedFloor); + expect(pbsReq.imp[0].bidfloorcur).to.eql(expectedCur); + }); + }); + }); + }); + }); + + if (FEATURES.NATIVE) { + describe('native requests', function () { + const ORTB_NATIVE_REQ = { + 'ver': '1.2', 'assets': [ { 'required': 1, + 'id': 0, 'title': { 'len': 800 } }, { 'required': 1, + 'id': 1, 'img': { 'type': 3, 'w': 989, @@ -1093,6 +1391,7 @@ describe('S2S Adapter', function () { }, { 'required': 1, + 'id': 2, 'img': { 'type': 1, 'wmin': 10, @@ -1104,35 +1403,117 @@ describe('S2S Adapter', function () { }, { 'required': 1, + 'id': 3, 'data': { 'type': 1 } } ] - }), - ver: '1.2' - }); - }); - - it('should not include ext.aspectratios if adunit\'s aspect_ratios do not define radio_width and ratio_height', () => { - const req = deepClone(REQUEST); - req.ad_units[0].mediaTypes.native.icon.aspect_ratios[0] = { 'min_width': 1, 'min_height': 2 }; - prepRequest(req); - adapter.callBids(req, BID_REQUESTS, addBidResponse, done, ajax); - const nativeReq = JSON.parse(JSON.parse(server.requests[0].requestBody).imp[0].native.request); - const icons = nativeReq.assets.map((a) => a.img).filter((img) => img && img.type === 1); - expect(icons).to.have.length(1); - expect(icons[0].hmin).to.equal(2); - expect(icons[0].wmin).to.equal(1); - expect(deepAccess(icons[0], 'ext.aspectratios')).to.be.undefined; - }) + }; - it('adds site if app is not present', function () { - const _config = { - s2sConfig: CONFIG, - site: { - publisher: { - id: '1234', + it('adds device.w and device.h even if the config lacks a device object', function () { + const _config = { + s2sConfig: CONFIG, + app: { bundle: 'com.test.app' }, + }; + + config.setConfig(_config); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + sinon.assert.match(requestBid.device, { + w: window.innerWidth, + h: window.innerHeight + }) + sinon.assert.match(requestBid.app, { + bundle: 'com.test.app', + publisher: { 'id': '1' } + }); + expect(requestBid.imp[0].native.ver).to.equal('1.2'); + }); + + it('adds native request for OpenRTB', function () { + const _config = { + s2sConfig: CONFIG + }; + + config.setConfig(_config); + adapter.callBids({...REQUEST, s2sConfig: Object.assign({}, CONFIG, s2sDefaultConfig)}, BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + const ortbReq = JSON.parse(requestBid.imp[0].native.request); + expect(ortbReq).to.deep.equal({ + ...ORTB_NATIVE_REQ, + 'eventtrackers': [{ + event: 1, + methods: [1, 2] + }], + }); + expect(requestBid.imp[0].native.ver).to.equal('1.2'); + }); + + it('adds native ortb request for OpenRTB', function () { + const _config = { + s2sConfig: CONFIG + }; + + const openRtbNativeRequest = deepClone(REQUEST); + delete openRtbNativeRequest.ad_units[0].mediaTypes.native; + delete openRtbNativeRequest.ad_units[0].nativeParams; + + openRtbNativeRequest.ad_units[0].mediaTypes.native = NATIVE_ORTB_MTO; + prepRequest(openRtbNativeRequest); + + config.setConfig(_config); + adapter.callBids(openRtbNativeRequest, BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + const nativeReq = JSON.parse(requestBid.imp[0].native.request); + expect(nativeReq).to.deep.equal(NATIVE_ORTB_MTO.ortb); + expect(requestBid.imp[0].native.ver).to.equal('1.2'); + }); + + it('can override default values for imp.native.request with s2sConfig.ortbNative', () => { + const cfg = { + ...CONFIG, + ortbNative: { + eventtrackers: [ + {event: 1, methods: [1, 2]} + ] + } + } + config.setConfig({ + s2sConfig: cfg + }); + adapter.callBids({...REQUEST, s2sConfig: cfg}, BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + const ortbReq = JSON.parse(requestBid.imp[0].native.request); + expect(ortbReq).to.eql({ + ...ORTB_NATIVE_REQ, + eventtrackers: [ + {event: 1, methods: [1, 2]} + ] + }) + }) + + it('should not include ext.aspectratios if adunit\'s aspect_ratios do not define radio_width and ratio_height', () => { + const req = deepClone(REQUEST); + req.ad_units[0].mediaTypes.native.icon.aspect_ratios[0] = {'min_width': 1, 'min_height': 2}; + prepRequest(req); + adapter.callBids(req, BID_REQUESTS, addBidResponse, done, ajax); + const nativeReq = JSON.parse(JSON.parse(server.requests[0].requestBody).imp[0].native.request); + const icons = nativeReq.assets.map((a) => a.img).filter((img) => img && img.type === 1); + expect(icons).to.have.length(1); + expect(icons[0].hmin).to.equal(2); + expect(icons[0].wmin).to.equal(1); + expect(deepAccess(icons[0], 'ext.aspectratios')).to.be.undefined; + }); + }); + } + + it('adds site if app is not present', function () { + const _config = { + s2sConfig: CONFIG, + site: { + publisher: { + id: '1234', domain: 'test.com' }, content: { @@ -1142,7 +1523,7 @@ describe('S2S Adapter', function () { }; config.setConfig(_config); - adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.site).to.exist.and.to.be.a('object'); expect(requestBid.site.publisher).to.exist.and.to.be.a('object'); @@ -1159,28 +1540,52 @@ describe('S2S Adapter', function () { content: { language: 'en' }, + domain: 'mytestpage.com', page: 'http://mytestpage.com' }); }); + it('site should not be present when app is present', function () { + const _config = { + s2sConfig: CONFIG, + app: { bundle: 'com.test.app' }, + site: { + publisher: { + id: '1234', + domain: 'test.com' + }, + content: { + language: 'en' + } + } + }; + + config.setConfig(_config); + adapter.callBids(addFpdEnrichmentsToS2SRequest(REQUEST, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.site).to.not.exist; + expect(requestBid.app).to.exist.and.to.be.a('object'); + }); + it('adds appnexus aliases to request', function () { config.setConfig({ s2sConfig: CONFIG }); const aliasBidder = { - bidder: 'brealtime', + bidder: 'beintoo', + bid_id: REQUEST.ad_units[0].bids[0].bid_id, params: { placementId: '123456' } }; const request = utils.deepClone(REQUEST); request.ad_units[0].bids = [aliasBidder]; - adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(request, [{...BID_REQUESTS[0], bidderCode: 'beintoo'}], addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.ext).to.haveOwnProperty('prebid'); expect(requestBid.ext.prebid).to.deep.include({ aliases: { - brealtime: 'appnexus' + beintoo: 'appnexus' }, auctiontimestamp: 1510852447530, targeting: { @@ -1190,12 +1595,38 @@ describe('S2S Adapter', function () { }); }); + it('unregistered bidder should alias', function () { + const adjustedConfig = utils.deepClone(CONFIG); + adjustedConfig.bidders = 'bidderD' + config.setConfig({ s2sConfig: adjustedConfig }); + + const aliasBidder = { + ...REQUEST.ad_units[0].bids[0], + bidder: 'bidderD', + params: { + unit: '10433394', + } + }; + + $$PREBID_GLOBAL$$.aliasBidder('mockBidder', aliasBidder.bidder); + + const request = utils.deepClone(REQUEST); + request.ad_units[0].bids = [aliasBidder]; + request.s2sConfig = adjustedConfig; + + adapter.callBids(request, [{...BID_REQUESTS[0], bidderCode: aliasBidder.bidder}], addBidResponse, done, ajax); + + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.ext.prebid.aliases).to.deep.equal({ bidderD: 'mockBidder' }); + }); + it('adds dynamic aliases to request', function () { config.setConfig({ s2sConfig: CONFIG }); const alias = 'foobar'; const aliasBidder = { bidder: alias, + bid_id: REQUEST.ad_units[0].bids[0].bid_id, params: { placementId: '123456' } }; @@ -1204,7 +1635,7 @@ describe('S2S Adapter', function () { // TODO: stub this $$PREBID_GLOBAL$$.aliasBidder('appnexus', alias); - adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(request, [{...BID_REQUESTS[0], bidderCode: 'foobar'}], addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.ext).to.haveOwnProperty('prebid'); @@ -1236,29 +1667,28 @@ describe('S2S Adapter', function () { }) const aliasBidder = { bidder: 'bidderCodeForTestSkipBPSAlias_Alias', + bid_id: REQUEST.ad_units[0].bids[0].bid_id, params: { aid: 123 } }; const request = utils.deepClone(REQUEST); request.ad_units[0].bids = [aliasBidder]; - adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(request, [{...BID_REQUESTS[0], bidderCode: aliasBidder.bidder}], addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.ext).to.deep.equal({ - prebid: { - auctiontimestamp: 1510852447530, - targeting: { - includebidderkeys: false, - includewinners: true - }, - channel: { - name: 'pbjs', - version: 'v$prebid.version$' - } + sinon.assert.match(requestBid.ext.prebid, { + auctiontimestamp: 1510852447530, + targeting: { + includebidderkeys: false, + includewinners: true + }, + channel: { + name: 'pbjs', + version: 'v$prebid.version$' } - }); + }) }); it('skips dynamic aliases to request when skipPbsAliasing enabled', function () { @@ -1272,6 +1702,7 @@ describe('S2S Adapter', function () { const alias = 'foobar_1'; const aliasBidder = { bidder: alias, + bid_id: REQUEST.ad_units[0].bids[0].bid_id, params: { aid: 1234567 } }; @@ -1280,21 +1711,19 @@ describe('S2S Adapter', function () { // TODO: stub this $$PREBID_GLOBAL$$.aliasBidder('appnexus', alias, { skipPbsAliasing: true }); - adapter.callBids(request, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(request, [{...BID_REQUESTS[0], bidderCode: aliasBidder.bidder}], addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.ext).to.deep.equal({ - prebid: { - auctiontimestamp: 1510852447530, - targeting: { - includebidderkeys: false, - includewinners: true - }, - channel: { - name: 'pbjs', - version: 'v$prebid.version$' - } + sinon.assert.match(requestBid.ext.prebid, { + auctiontimestamp: 1510852447530, + targeting: { + includebidderkeys: false, + includewinners: true + }, + channel: { + name: 'pbjs', + version: 'v$prebid.version$' } }); }); @@ -1307,21 +1736,23 @@ describe('S2S Adapter', function () { }); config.setConfig({ s2sConfig: s2sConfig }); - const myRequest = utils.deepClone(REQUEST); - myRequest.ad_units[0].bids[0].params.usePaymentRule = true; - myRequest.ad_units[0].bids[0].params.keywords = { - foo: ['bar', 'baz'], - fizz: ['buzz'] - }; + Object.assign(BID_REQUESTS[0].bids[0].params, { + usePaymentRule: true, + keywords: { + foo: ['bar', 'baz'], + fizz: ['buzz'] + } + }) - adapter.callBids(myRequest, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.imp[0].ext.appnexus).to.exist; - expect(requestBid.imp[0].ext.appnexus.placement_id).to.exist.and.to.equal(10433394); - expect(requestBid.imp[0].ext.appnexus.use_pmt_rule).to.exist.and.to.be.true; - expect(requestBid.imp[0].ext.appnexus.member).to.exist; - expect(requestBid.imp[0].ext.appnexus.keywords).to.exist.and.to.deep.equal([{ + const requestParams = requestBid.imp[0].ext.prebid.bidder; + expect(requestParams.appnexus).to.exist; + expect(requestParams.appnexus.placement_id).to.exist.and.to.equal(10433394); + expect(requestParams.appnexus.use_pmt_rule).to.exist.and.to.be.true; + expect(requestParams.appnexus.member).to.exist; + expect(requestParams.appnexus.keywords).to.exist.and.to.deep.equal([{ key: 'foo', value: ['bar', 'baz'] }, { @@ -1330,55 +1761,177 @@ describe('S2S Adapter', function () { }]); }); - it('adds limit to the cookie_sync request if userSyncLimit is greater than 0', function () { - let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; - cookieSyncConfig.userSyncLimit = 1; + describe('cookie sync', () => { + let s2sConfig, bidderReqs; - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = cookieSyncConfig; + beforeEach(() => { + bidderReqs = utils.deepClone(BID_REQUESTS); + s2sConfig = utils.deepClone(CONFIG); + s2sConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; + }) + + function callCookieSync() { + const s2sBidRequest = utils.deepClone(REQUEST); + s2sBidRequest.s2sConfig = s2sConfig; + config.setConfig({ s2sConfig: s2sConfig }); + adapter.callBids(s2sBidRequest, bidderReqs, addBidResponse, done, ajax); + return JSON.parse(server.requests[0].requestBody); + } - config.setConfig({ s2sConfig: cookieSyncConfig }); + describe('filterSettings', function () { + it('correctly adds filterSettings to the cookie_sync request if userSync.filterSettings is present in the config and only the all key is present in userSync.filterSettings', function () { + config.setConfig({ + userSync: { + filterSettings: { + all: { + bidders: ['appnexus', 'rubicon', 'pubmatic'], + filter: 'exclude' + } + } + } + }); + expect(callCookieSync().filterSettings).to.deep.equal({ + 'image': { + 'bidders': ['appnexus', 'rubicon', 'pubmatic'], + 'filter': 'exclude' + }, + 'iframe': { + 'bidders': ['appnexus', 'rubicon', 'pubmatic'], + 'filter': 'exclude' + } + }); + }); - let bidRequest = utils.deepClone(BID_REQUESTS); - adapter.callBids(s2sBidRequest, bidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(server.requests[0].requestBody); + it('correctly adds filterSettings to the cookie_sync request if userSync.filterSettings is present in the config and only the iframe key is present in userSync.filterSettings', function () { + config.setConfig({ + userSync: { + filterSettings: { + iframe: { + bidders: ['rubicon', 'pubmatic'], + filter: 'include' + } + } + } + }) - expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); - expect(requestBid.account).is.equal('1'); - expect(requestBid.limit).is.equal(1); - }); + expect(callCookieSync().filterSettings).to.deep.equal({ + 'image': { + 'bidders': '*', + 'filter': 'include' + }, + 'iframe': { + 'bidders': ['rubicon', 'pubmatic'], + 'filter': 'include' + } + }); + }); - it('does not add limit to cooke_sync request if userSyncLimit is missing or 0', function () { - let cookieSyncConfig = utils.deepClone(CONFIG); - cookieSyncConfig.syncEndpoint = { p1Consent: 'https://prebid.adnxs.com/pbs/v1/cookie_sync' }; - config.setConfig({ s2sConfig: cookieSyncConfig }); + it('correctly adds filterSettings to the cookie_sync request if userSync.filterSettings is present in the config and the image and iframe keys are both present in userSync.filterSettings', function () { + config.setConfig({ + userSync: { + filterSettings: { + image: { + bidders: ['triplelift', 'appnexus'], + filter: 'include' + }, + iframe: { + bidders: ['pulsepoint', 'triplelift', 'appnexus', 'rubicon'], + filter: 'exclude' + } + } + } + }) - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = cookieSyncConfig; + expect(callCookieSync().filterSettings).to.deep.equal({ + 'image': { + 'bidders': ['triplelift', 'appnexus'], + 'filter': 'include' + }, + 'iframe': { + 'bidders': ['pulsepoint', 'triplelift', 'appnexus', 'rubicon'], + 'filter': 'exclude' + } + }); + }); - let bidRequest = utils.deepClone(BID_REQUESTS); - adapter.callBids(s2sBidRequest, bidRequest, addBidResponse, done, ajax); - let requestBid = JSON.parse(server.requests[0].requestBody); + it('correctly adds filterSettings to the cookie_sync request if userSync.filterSettings is present in the config and the all and iframe keys are both present in userSync.filterSettings', function () { + config.setConfig({ + userSync: { + filterSettings: { + all: { + bidders: ['triplelift', 'appnexus'], + filter: 'include' + }, + iframe: { + bidders: ['pulsepoint', 'triplelift', 'appnexus', 'rubicon'], + filter: 'exclude' + } + } + } + }) - expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); - expect(requestBid.account).is.equal('1'); - expect(requestBid.limit).is.undefined; + expect(callCookieSync().filterSettings).to.deep.equal({ + 'image': { + 'bidders': ['triplelift', 'appnexus'], + 'filter': 'include' + }, + 'iframe': { + 'bidders': ['pulsepoint', 'triplelift', 'appnexus', 'rubicon'], + 'filter': 'exclude' + } + }); + }); + }); - cookieSyncConfig.userSyncLimit = 0; - config.resetConfig(); - config.setConfig({ s2sConfig: cookieSyncConfig }); + describe('limit', () => { + it('is added to request if userSyncLimit is greater than 0', function () { + s2sConfig.userSyncLimit = 1; + const req = callCookieSync(); + expect(req.limit).is.equal(1); + }); - const s2sBidRequest2 = utils.deepClone(REQUEST); - s2sBidRequest2.s2sConfig = cookieSyncConfig; + Object.entries({ + 'missing': () => null, + '0': () => { s2sConfig.userSyncLimit = 0; } + }).forEach(([t, setup]) => { + it(`is not added to request if userSyncLimit is ${t}`, () => { + setup(); + const req = callCookieSync(); + expect(req.limit).to.not.exist; + }); + }); + }); - bidRequest = utils.deepClone(BID_REQUESTS); - adapter.callBids(s2sBidRequest2, bidRequest, addBidResponse, done, ajax); - requestBid = JSON.parse(server.requests[0].requestBody); + describe('gdpr data is set', () => { + it('when we have consent data', function () { + bidderReqs[0].gdprConsent = mockTCF(); + const req = callCookieSync(); + expect(req.gdpr).is.equal(1); + expect(req.gdpr_consent).is.equal('mockConsent'); + }); - expect(requestBid.bidders).to.contain('appnexus').and.to.have.lengthOf(1); - expect(requestBid.account).is.equal('1'); - expect(requestBid.limit).is.undefined; + it('when gdprApplies is false', () => { + bidderReqs[0].gdprConsent = mockTCF({applies: false}); + const req = callCookieSync(); + expect(req.gdpr).is.equal(0); + expect(req.gdpr_consent).is.undefined; + }); + }); + + it('adds USP data from bidder request', () => { + bidderReqs[0].uspConsent = '1YNN'; + expect(callCookieSync().us_privacy).to.equal('1YNN'); + }); + + it('adds GPP data from bidder requests', () => { + bidderReqs[0].gppConsent = { + applicableSections: [1, 2, 3], + gppString: 'mock-string' + }; + const req = callCookieSync(); + expect(req.gpp).to.eql('mock-string'); + expect(req.gpp_sid).to.eql('1,2,3'); + }); }); it('adds s2sConfig adapterOptions to request for ORTB', function () { @@ -1401,8 +1954,9 @@ describe('S2S Adapter', function () { config.setConfig(_config); adapter.callBids(s2sBidRequest, BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); - expect(requestBid.imp[0].ext.appnexus).to.haveOwnProperty('key'); - expect(requestBid.imp[0].ext.appnexus.key).to.be.equal('value') + const requestParams = requestBid.imp[0].ext.prebid.bidder; + expect(requestParams.appnexus).to.haveOwnProperty('key'); + expect(requestParams.appnexus.key).to.be.equal('value') }); describe('config site value is added to the oRTB request', function () { @@ -1432,7 +1986,7 @@ describe('S2S Adapter', function () { device: device }); - adapter.callBids(s2sBidRequest, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(s2sBidRequest, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.site).to.exist.and.to.be.a('object'); @@ -1451,7 +2005,7 @@ describe('S2S Adapter', function () { device: device }); - adapter.callBids(s2sBidRequest, BID_REQUESTS, addBidResponse, done, ajax); + adapter.callBids(addFpdEnrichmentsToS2SRequest(s2sBidRequest, BID_REQUESTS), BID_REQUESTS, addBidResponse, done, ajax); const requestBid = JSON.parse(server.requests[0].requestBody); expect(requestBid.site).to.exist.and.to.be.a('object'); @@ -1484,42 +2038,12 @@ describe('S2S Adapter', function () { } } }; - userIdBidRequest[0].bids[0].userIdAsEids = createEidsArray(userIdBidRequest[0].bids[0].userId); + userIdBidRequest[0].bids[0].userIdAsEids = [{id: 1}, {id: 2}]; adapter.callBids(REQUEST, userIdBidRequest, addBidResponse, done, ajax); let requestBid = JSON.parse(server.requests[0].requestBody); expect(typeof requestBid.user.ext.eids).is.equal('object'); - expect(Array.isArray(requestBid.user.ext.eids)).to.be.true; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')[0].uids[0].id).is.equal('abc123'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'criteo.com')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'criteo.com')[0].uids[0].id).is.equal('44VmRDeUE3ZGJ5MzRkRVJHU3BIUlJ6TlFPQUFU'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcid.org')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcid.org')[0].uids[0].id).is.equal('1234'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'parrable.com')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'parrable.com')[0].uids[0].id).is.equal('01.1563917337.test-eid'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].uids[0].id).is.equal('li-xyz'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments.length).is.equal(2); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments[0]).is.equal('segA'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveintent.com')[0].ext.segments[1]).is.equal('segB'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'id5-sync.com')).is.not.empty; - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'id5-sync.com')[0].uids[0].id).is.equal('11111'); - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'id5-sync.com')[0].uids[0].ext.linkType).is.equal('some-link-type'); - // LiveRamp should exist - expect(requestBid.user.ext.eids.filter(eid => eid.source === 'liveramp.com')[0].uids[0].id).is.equal('0000-1111-2222-3333'); - }); - - it('when config \'currency.adServerCurrency\' value is an array: ORTB has property \'cur\' value set to a single item array', function () { - config.setConfig({ - currency: { adServerCurrency: ['USD', 'GB', 'UK', 'AU'] }, - }); - - const bidRequests = utils.deepClone(BID_REQUESTS); - adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); - - const parsedRequestBody = JSON.parse(server.requests[0].requestBody); - expect(parsedRequestBody.cur).to.deep.equal(['USD']); + expect(requestBid.user.ext.eids).to.eql([{id: 1}, {id: 2}]); }); it('when config \'currency.adServerCurrency\' value is a string: ORTB has property \'cur\' value set to a single item array', function () { @@ -1698,29 +2222,179 @@ describe('S2S Adapter', function () { }); }); - it('passes schain object in request', function () { - const bidRequests = utils.deepClone(BID_REQUESTS); - const schainObject = { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ - { - 'asi': 'indirectseller.com', - 'sid': '00001', - 'hp': 1 - }, + it('should have extPrebid.schains present on req object if bidder specific schains were configured with pbjs', function () { + let bidRequest = utils.deepClone(BID_REQUESTS); + bidRequest[0].bids[0].schain = { + complete: 1, + nodes: [{ + asi: 'test.com', + hp: 1, + sid: '11111' + }], + ver: '1.0' + }; - { - 'asi': 'indirectseller-2.com', - 'sid': '00002', - 'hp': 2 + adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax); + let requestBid = JSON.parse(server.requests[0].requestBody); + + expect(requestBid.ext.prebid.schains).to.deep.equal([ + { + bidders: ['appnexus'], + schain: { + complete: 1, + nodes: [ + { + asi: 'test.com', + hp: 1, + sid: '11111' + } + ], + ver: '1.0' } - ] + } + ]); + }); + + it('should skip over adding any bid specific schain entries that already exist on extPrebid.schains', function () { + let bidRequest = utils.deepClone(BID_REQUESTS); + bidRequest[0].bids[0].schain = { + complete: 1, + nodes: [{ + asi: 'pbjs.com', + hp: 1, + sid: '22222' + }], + ver: '1.0' }; - bidRequests[0].bids[0].schain = schainObject; - adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); - const parsedRequestBody = JSON.parse(server.requests[0].requestBody); - expect(parsedRequestBody.source.ext.schain).to.deep.equal(schainObject); + + const s2sConfig = Object.assign({}, CONFIG, { + extPrebid: { + schains: [ + { + bidders: ['appnexus'], + schain: { + complete: 1, + nodes: [ + { + asi: 'pbs.com', + hp: 1, + sid: '11111' + } + ], + ver: '1.0' + } + } + ] + } + }); + + const s2sBidRequest = utils.deepClone(REQUEST); + s2sBidRequest.s2sConfig = s2sConfig; + + adapter.callBids(s2sBidRequest, bidRequest, addBidResponse, done, ajax); + + let requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.ext.prebid.schains).to.deep.equal([ + { + bidders: ['appnexus'], + schain: { + complete: 1, + nodes: [ + { + asi: 'pbs.com', + hp: 1, + sid: '11111' + } + ], + ver: '1.0' + } + } + ]); + }); + + it('should add a bidder name to pbs schain if the schain is equal to a pbjs one but the pbjs bidder name is not in the bidder array on the pbs side', function () { + let bidRequest = utils.deepClone(BID_REQUESTS); + bidRequest[0].bids[0].schain = { + complete: 1, + nodes: [{ + asi: 'test.com', + hp: 1, + sid: '11111' + }], + ver: '1.0' + }; + + bidRequest[0].bids[1] = { + bidder: 'rubicon', + params: { + accountId: 14062, + siteId: 70608, + zoneId: 498816 + } + }; + + const s2sConfig = Object.assign({}, CONFIG, { + bidders: ['rubicon', 'appnexus'], + extPrebid: { + schains: [ + { + bidders: ['rubicon'], + schain: { + complete: 1, + nodes: [ + { + asi: 'test.com', + hp: 1, + sid: '11111' + } + ], + ver: '1.0' + } + } + ] + } + }); + + const s2sBidRequest = utils.deepClone(REQUEST); + s2sBidRequest.s2sConfig = s2sConfig; + + adapter.callBids(s2sBidRequest, bidRequest, addBidResponse, done, ajax); + + let requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.ext.prebid.schains).to.deep.equal([ + { + bidders: ['rubicon', 'appnexus'], + schain: { + complete: 1, + nodes: [ + { + asi: 'test.com', + hp: 1, + sid: '11111' + } + ], + ver: '1.0' + } + } + ]); + }); + + it('should "promote" the most reused bidder schain to source.ext.schain', () => { + const bidderReqs = [ + {...deepClone(BID_REQUESTS[0]), bidderCode: 'A'}, + {...deepClone(BID_REQUESTS[0]), bidderCode: 'B'}, + {...deepClone(BID_REQUESTS[0]), bidderCode: 'C'} + ]; + const chain1 = {chain: 1}; + const chain2 = {chain: 2}; + + bidderReqs[0].bids[0].schain = chain1; + bidderReqs[1].bids[0].schain = chain2; + bidderReqs[2].bids[0].schain = chain2; + + adapter.callBids(REQUEST, bidderReqs, addBidResponse, done, ajax); + const req = JSON.parse(server.requests[0].requestBody); + expect(req.source.ext.schain).to.eql(chain2); }); it('passes multibid array in request', function () { @@ -1779,7 +2453,7 @@ describe('S2S Adapter', function () { const s2sBidRequest = utils.deepClone(REQUEST); const bidRequests = utils.deepClone(BID_REQUESTS); - const commonContext = { + const commonSite = { keywords: ['power tools'], search: 'drill' }; @@ -1788,24 +2462,28 @@ describe('S2S Adapter', function () { gender: 'M' }; - const context = { - content: { userrating: 4 }, - data: { - pageType: 'article', - category: 'tools' + const site = { + content: {userrating: 4}, + ext: { + data: { + pageType: 'article', + category: 'tools' + } } }; const user = { yob: '1984', geo: { country: 'ca' }, - data: { - registered: true, - interests: ['cars'] + ext: { + data: { + registered: true, + interests: ['cars'] + } } }; const bcat = ['IAB25', 'IAB7-39']; const badv = ['blockedAdv-1.com', 'blockedAdv-2.com']; - const allowedBidders = ['rubicon', 'appnexus']; + const allowedBidders = ['appnexus']; const expected = allowedBidders.map(bidder => ({ bidders: [bidder], @@ -1837,12 +2515,19 @@ describe('S2S Adapter', function () { })); const commonContextExpected = utils.mergeDeep({ 'page': 'http://mytestpage.com', - 'publisher': { 'id': '1' } - }, commonContext); + 'domain': 'mytestpage.com', + 'publisher': { + 'id': '1', + 'domain': 'mytestpage.com' + } + }, commonSite); - config.setConfig({ fpd: { context: commonContext, user: commonUser, badv, bcat } }); - config.setBidderConfig({ bidders: allowedBidders, config: { fpd: { context, user, bcat, badv } } }); - adapter.callBids(s2sBidRequest, bidRequests, addBidResponse, done, ajax); + const ortb2Fragments = { + global: {site: commonSite, user: commonUser, badv, bcat}, + bidder: Object.fromEntries(allowedBidders.map(bidder => [bidder, {site, user, bcat, badv}])) + }; + + adapter.callBids(addFpdEnrichmentsToS2SRequest({...s2sBidRequest, ortb2Fragments}, bidRequests), bidRequests, addBidResponse, done, ajax); const parsedRequestBody = JSON.parse(server.requests[0].requestBody); expect(parsedRequestBody.ext.prebid.bidderconfig).to.deep.equal(expected); expect(parsedRequestBody.site).to.deep.equal(commonContextExpected); @@ -1851,6 +2536,101 @@ describe('S2S Adapter', function () { expect(parsedRequestBody.bcat).to.deep.equal(bcat); }); + it('passes first party data in request for unknown when allowUnknownBidderCodes is true', () => { + const cfg = { ...CONFIG, allowUnknownBidderCodes: true }; + config.setConfig({ s2sConfig: cfg }); + + const clonedReq = {...REQUEST, s2sConfig: cfg} + const s2sBidRequest = utils.deepClone(clonedReq); + const bidRequests = utils.deepClone(BID_REQUESTS); + + const commonSite = { + keywords: ['power tools'], + search: 'drill' + }; + const commonUser = { + keywords: ['a', 'b'], + gender: 'M' + }; + + const site = { + content: {userrating: 4}, + ext: { + data: { + pageType: 'article', + category: 'tools' + } + } + }; + const user = { + yob: '1984', + geo: { country: 'ca' }, + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + }; + const bcat = ['IAB25', 'IAB7-39']; + const badv = ['blockedAdv-1.com', 'blockedAdv-2.com']; + const allowedBidders = ['appnexus', 'unknown']; + + const expected = allowedBidders.map(bidder => ({ + bidders: [bidder], + config: { + ortb2: { + site: { + content: { userrating: 4 }, + ext: { + data: { + pageType: 'article', + category: 'tools' + } + } + }, + user: { + yob: '1984', + geo: { country: 'ca' }, + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + }, + bcat: ['IAB25', 'IAB7-39'], + badv: ['blockedAdv-1.com', 'blockedAdv-2.com'] + } + } + })); + const commonContextExpected = utils.mergeDeep({ + 'page': 'http://mytestpage.com', + 'domain': 'mytestpage.com', + 'publisher': { + 'id': '1', + 'domain': 'mytestpage.com' + } + }, commonSite); + + const ortb2Fragments = { + global: {site: commonSite, user: commonUser, badv, bcat}, + bidder: Object.fromEntries(allowedBidders.map(bidder => [bidder, {site, user, bcat, badv}])) + }; + + // adapter.callBids({ ...REQUEST, s2sConfig: cfg }, BID_REQUESTS, addBidResponse, done, ajax); + + adapter.callBids(addFpdEnrichmentsToS2SRequest({...s2sBidRequest, ortb2Fragments}, bidRequests, cfg), bidRequests, addBidResponse, done, ajax); + const parsedRequestBody = JSON.parse(server.requests[0].requestBody); + // eslint-disable-next-line no-console + console.log(parsedRequestBody); + expect(parsedRequestBody.ext.prebid.bidderconfig).to.deep.equal(expected); + expect(parsedRequestBody.site).to.deep.equal(commonContextExpected); + expect(parsedRequestBody.user).to.deep.equal(commonUser); + expect(parsedRequestBody.badv).to.deep.equal(badv); + expect(parsedRequestBody.bcat).to.deep.equal(bcat); + }); + describe('pbAdSlot config', function () { it('should not send \"imp.ext.data.pbadslot\" if \"ortb2Imp.ext\" is undefined', function () { const consentConfig = { s2sConfig: CONFIG }; @@ -1999,6 +2779,62 @@ describe('S2S Adapter', function () { }); }); + describe('Bidder-level ortb2Imp', () => { + beforeEach(() => { + config.setConfig({ + s2sConfig: { + ...CONFIG, + bidders: ['A', 'B'] + } + }) + }) + it('should be set on imp.ext.prebid.imp', () => { + const s2sReq = utils.deepClone(REQUEST); + s2sReq.ad_units[0].ortb2Imp = {l0: 'adUnit'}; + s2sReq.ad_units[0].bids = [ + { + bidder: 'A', + bid_id: 1, + ortb2Imp: { + l2: 'A' + } + }, + { + bidder: 'B', + bid_id: 2, + ortb2Imp: { + l2: 'B' + } + } + ]; + const bidderReqs = [ + { + ...BID_REQUESTS[0], + bidderCode: 'A', + bids: [{ + bidId: 1, + bidder: 'A' + }] + }, + { + ...BID_REQUESTS[0], + bidderCode: 'B', + bids: [{ + bidId: 2, + bidder: 'B' + }] + } + ] + adapter.callBids(s2sReq, bidderReqs, addBidResponse, done, ajax); + const req = JSON.parse(server.requests[0].requestBody); + expect(req.imp[0].l0).to.eql('adUnit'); + expect(req.imp[0].ext.prebid.imp).to.eql({ + A: {l2: 'A'}, + B: {l2: 'B'} + }); + }); + }); + describe('ext.prebid config', function () { it('should send \"imp.ext.prebid.storedrequest.id\" if \"ortb2Imp.ext.prebid.storedrequest.id\" is set', function () { const consentConfig = { s2sConfig: CONFIG }; @@ -2040,6 +2876,15 @@ describe('S2S Adapter', function () { events.emit.restore(); }); + it('triggers BIDDER_ERROR on server error', () => { + config.setConfig({ s2sConfig: CONFIG }); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(400, {}, {}); + BID_REQUESTS.forEach(bidderRequest => { + sinon.assert.calledWith(events.emit, CONSTANTS.EVENTS.BIDDER_ERROR, sinon.match({bidderRequest})) + }) + }) + // TODO: test dependent on pbjs_api_spec. Needs to be isolated it('does not call addBidResponse and calls done when ad unit not set', function () { config.setConfig({ s2sConfig: CONFIG }); @@ -2092,28 +2937,30 @@ describe('S2S Adapter', function () { expect(response).to.have.property('dealId', 'test-dealid'); }); - it('should pass through default adserverTargeting if present in bidObject for video request', function () { - config.setConfig({ s2sConfig: CONFIG }); - const cacheResponse = utils.deepClone(RESPONSE_OPENRTB); - const targetingTestData = { - hb_cache_path: '/cache', - hb_cache_host: 'prebid-cache.testurl.com' - }; - - cacheResponse.seatbid.forEach(item => { - item.bid[0].ext.prebid.targeting = targetingTestData - }); - adapter.callBids(VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + if (FEATURES.VIDEO) { + it('should pass through default adserverTargeting if present in bidObject for video request', function () { + config.setConfig({ s2sConfig: CONFIG }); + const cacheResponse = utils.deepClone(RESPONSE_OPENRTB); + const targetingTestData = { + hb_cache_path: '/cache', + hb_cache_host: 'prebid-cache.testurl.com' + }; - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('adserverTargeting'); - expect(response.adserverTargeting).to.deep.equal({ - 'hb_cache_path': '/cache', - 'hb_cache_host': 'prebid-cache.testurl.com' + cacheResponse.seatbid.forEach(item => { + item.bid[0].ext.prebid.targeting = targetingTestData + }); + adapter.callBids(VIDEO_REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('adserverTargeting'); + expect(response.adserverTargeting).to.deep.equal({ + 'hb_cache_path': '/cache', + 'hb_cache_host': 'prebid-cache.testurl.com' + }); }); - }); + } it('should set the bidResponse currency to whats in the PBS response', function () { adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); @@ -2211,6 +3058,23 @@ describe('S2S Adapter', function () { expect(response).to.have.property('ttl', 60); }); + it('handles seatnonbid responses and emits SEAT_NON_BID', function () { + const original = CONFIG; + CONFIG.extPrebid = { returnallbidstatus: true }; + const nonbidResponse = {...RESPONSE_OPENRTB, ext: {seatnonbid: [{}]}}; + config.setConfig({ CONFIG }); + CONFIG = original; + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + const responding = deepClone(nonbidResponse); + Object.assign(responding.ext.seatnonbid, [{auctionId: 2}]) + server.requests[0].respond(200, {}, JSON.stringify(responding)); + const event = events.emit.secondCall.args; + expect(event[0]).to.equal(CONSTANTS.EVENTS.SEAT_NON_BID); + expect(event[1].seatnonbid[0]).to.have.property('auctionId', 2); + expect(event[1].requestedBidders).to.deep.equal(['appnexus']); + expect(event[1].response).to.deep.equal(responding); + }); + it('respects defaultTtl', function () { const s2sConfig = Object.assign({}, CONFIG, { defaultTtl: 30 @@ -2229,60 +3093,62 @@ describe('S2S Adapter', function () { expect(response).to.have.property('ttl', 30); }); - it('handles OpenRTB video responses', function () { - const s2sConfig = Object.assign({}, CONFIG, { - endpoint: { - p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' - } + if (FEATURES.VIDEO) { + it('handles OpenRTB video responses', function () { + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } + }); + config.setConfig({ s2sConfig }); + + const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); + s2sVidRequest.s2sConfig = s2sConfig; + + adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB_VIDEO)); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('vastXml', RESPONSE_OPENRTB_VIDEO.seatbid[0].bid[0].adm); + expect(response).to.have.property('mediaType', 'video'); + expect(response).to.have.property('bidderCode', 'appnexus'); + expect(response).to.have.property('requestId', '123'); + expect(response).to.have.property('cpm', 10); }); - config.setConfig({ s2sConfig }); - - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; - - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB_VIDEO)); - - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('vastXml', RESPONSE_OPENRTB_VIDEO.seatbid[0].bid[0].adm); - expect(response).to.have.property('mediaType', 'video'); - expect(response).to.have.property('bidderCode', 'appnexus'); - expect(response).to.have.property('requestId', '123'); - expect(response).to.have.property('cpm', 10); - }); - it('handles response cache from ext.prebid.cache.vastXml', function () { - const s2sConfig = Object.assign({}, CONFIG, { - endpoint: { - p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' - } - }); - config.setConfig({ s2sConfig }); - const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); - cacheResponse.seatbid.forEach(item => { - item.bid[0].ext.prebid.cache = { - vastXml: { - cacheId: 'abcd1234', - url: 'https://prebid-cache.net/cache?uuid=abcd1234' + it('handles response cache from ext.prebid.cache.vastXml', function () { + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' } - } - }); + }); + config.setConfig({ s2sConfig }); + const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); + cacheResponse.seatbid.forEach(item => { + item.bid[0].ext.prebid.cache = { + vastXml: { + cacheId: 'abcd1234', + url: 'https://prebid-cache.net/cache?uuid=abcd1234' + } + } + }); - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; + const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); + s2sVidRequest.s2sConfig = s2sConfig; - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('videoCacheKey', 'abcd1234'); - expect(response).to.have.property('vastUrl', 'https://prebid-cache.net/cache?uuid=abcd1234'); - }); + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('videoCacheKey', 'abcd1234'); + expect(response).to.have.property('vastUrl', 'https://prebid-cache.net/cache?uuid=abcd1234'); + }); + } it('add adserverTargeting object to bids when ext.prebid.targeting is defined', function () { const s2sConfig = Object.assign({}, CONFIG, { @@ -2301,20 +3167,22 @@ describe('S2S Adapter', function () { item.bid[0].ext.prebid.targeting = targetingTestData }); - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; + if (FEATURES.VIDEO) { + const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); + s2sVidRequest.s2sConfig = s2sConfig; - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('adserverTargeting'); - expect(response.adserverTargeting).to.deep.equal({ - 'hb_cache_path': '/cache', - 'hb_cache_host': 'prebid-cache.testurl.com' - }); + expect(response).to.have.property('adserverTargeting'); + expect(response.adserverTargeting).to.deep.equal({ + 'hb_cache_path': '/cache', + 'hb_cache_host': 'prebid-cache.testurl.com' + }); + } }); it('handles response cache from ext.prebid.targeting', function () { @@ -2333,18 +3201,20 @@ describe('S2S Adapter', function () { } }); - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; + if (FEATURES.VIDEO) { + const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); + s2sVidRequest.s2sConfig = s2sConfig; - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('videoCacheKey', 'a5ad3993'); - expect(response).to.have.property('vastUrl', 'https://prebid-cache.net/cache?uuid=a5ad3993'); + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('videoCacheKey', 'a5ad3993'); + expect(response).to.have.property('vastUrl', 'https://prebid-cache.net/cache?uuid=a5ad3993'); + } }); it('handles response cache from ext.prebid.targeting with wurl', function () { @@ -2365,52 +3235,18 @@ describe('S2S Adapter', function () { hb_cache_path: '/cache' } }); - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; - - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); - - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('pbsBidId', '654321'); - }); - - it('handles response cache from ext.prebid.targeting with wurl and removes invalid targeting', function () { - const s2sConfig = Object.assign({}, CONFIG, { - endpoint: { - p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' - } - }); - config.setConfig({ s2sConfig }); - const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); - cacheResponse.seatbid.forEach(item => { - item.bid[0].ext.prebid.events = { - win: 'https://wurl.com?a=1&b=2' - }; - item.bid[0].ext.prebid.targeting = { - hb_uuid: 'a5ad3993', - hb_cache_host: 'prebid-cache.net', - hb_cache_path: '/cache', - hb_winurl: 'https://hbwinurl.com?a=1&b=2', - hb_bidid: '1234567890', - } - }); - - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + if (FEATURES.VIDEO) { + const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); + s2sVidRequest.s2sConfig = s2sConfig; - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; + adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); - expect(response.adserverTargeting).to.deep.equal({ - hb_uuid: 'a5ad3993', - hb_cache_host: 'prebid-cache.net', - hb_cache_path: '/cache' - }); + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('pbsBidId', '654321'); + } }); it('add request property pbsBidId with ext.prebid.bidid value', function () { @@ -2422,44 +3258,58 @@ describe('S2S Adapter', function () { config.setConfig({ s2sConfig }); const cacheResponse = utils.deepClone(RESPONSE_OPENRTB_VIDEO); - const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); - s2sVidRequest.s2sConfig = s2sConfig; + if (FEATURES.VIDEO) { + const s2sVidRequest = utils.deepClone(VIDEO_REQUEST); + s2sVidRequest.s2sConfig = s2sConfig; - adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); + adapter.callBids(s2sVidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(cacheResponse)); - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('pbsBidId', '654321'); + expect(response).to.have.property('pbsBidId', '654321'); + } }); - it('handles OpenRTB native responses', function () { - const stub = sinon.stub(auctionManager, 'index'); - stub.get(() => stubAuctionIndex({ adUnits: REQUEST.ad_units })); - const s2sConfig = Object.assign({}, CONFIG, { - endpoint: { - p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' - } - }); - config.setConfig({ s2sConfig }); - - const s2sBidRequest = utils.deepClone(REQUEST); - s2sBidRequest.s2sConfig = s2sConfig; + if (FEATURES.NATIVE) { + it('handles OpenRTB native responses', function () { + const stub = sinon.stub(auctionManager, 'index'); + stub.get(() => stubAuctionIndex({adUnits: REQUEST.ad_units})); + const s2sConfig = Object.assign({}, CONFIG, { + endpoint: { + p1Consent: 'https://prebidserverurl/openrtb2/auction?querystring=param' + } + }); + config.setConfig({s2sConfig}); - adapter.callBids(s2sBidRequest, BID_REQUESTS, addBidResponse, done, ajax); - server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB_NATIVE)); + const s2sBidRequest = utils.deepClone(REQUEST); + s2sBidRequest.s2sConfig = s2sConfig; - sinon.assert.calledOnce(addBidResponse); - const response = addBidResponse.firstCall.args[1]; - expect(response).to.have.property('statusMessage', 'Bid available'); - expect(response).to.have.property('adm').deep.equal(RESPONSE_OPENRTB_NATIVE.seatbid[0].bid[0].adm); - expect(response).to.have.property('mediaType', 'native'); - expect(response).to.have.property('bidderCode', 'appnexus'); - expect(response).to.have.property('requestId', '123'); - expect(response).to.have.property('cpm', 10); + adapter.callBids(s2sBidRequest, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB_NATIVE)); + + sinon.assert.calledOnce(addBidResponse); + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('statusMessage', 'Bid available'); + expect(response).to.have.property('adm').deep.equal(RESPONSE_OPENRTB_NATIVE.seatbid[0].bid[0].adm); + expect(response).to.have.property('mediaType', 'native'); + expect(response).to.have.property('bidderCode', 'appnexus'); + expect(response).to.have.property('requestId', '123'); + expect(response).to.have.property('cpm', 10); + + stub.restore(); + }); + } - stub.restore(); + it('should reject invalid bids', () => { + config.setConfig({ s2sConfig: CONFIG }); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + const response = deepClone(RESPONSE_OPENRTB); + Object.assign(response.seatbid[0].bid[0], {w: null, h: null}); + server.requests[0].respond(200, {}, JSON.stringify(response)); + expect(addBidResponse.reject.calledOnce).to.be.true; + expect(addBidResponse.called).to.be.false; }); it('does not (by default) allow bids that were not requested', function () { @@ -2470,6 +3320,7 @@ describe('S2S Adapter', function () { server.requests[0].respond(200, {}, JSON.stringify(response)); expect(addBidResponse.called).to.be.false; + expect(addBidResponse.reject.calledOnce).to.be.true; }); it('allows unrequested bids if config.allowUnknownBidderCodes', function () { @@ -2483,17 +3334,35 @@ describe('S2S Adapter', function () { expect(addBidResponse.calledWith(sinon.match.any, sinon.match({ bidderCode: 'unknown' }))).to.be.true; }); - it('uses "null" request\'s ID for all responses, when a null request is present', function () { - const cfg = {...CONFIG, allowUnknownBidderCodes: true}; - config.setConfig({s2sConfig: cfg}); - const req = {...REQUEST, s2sConfig: cfg, ad_units: [{...REQUEST.ad_units[0], bids: [{bidder: null, bid_id: 'testId'}]}]}; - const bidReq = {...BID_REQUESTS[0], bidderCode: null, bids: [{...BID_REQUESTS[0].bids[0], bidder: null, bidId: 'testId'}]} - adapter.callBids(req, [bidReq], addBidResponse, done, ajax); - const response = deepClone(RESPONSE_OPENRTB); - response.seatbid[0].seat = 'storedImpression'; - server.requests[0].respond(200, {}, JSON.stringify(response)); - sinon.assert.calledWith(addBidResponse, sinon.match.any, sinon.match({bidderCode: 'storedImpression', requestId: 'testId'})) - }); + describe('stored impressions', () => { + let bidReq, response; + + function mks2sReq(s2sConfig = CONFIG) { + return {...REQUEST, s2sConfig, ad_units: [{...REQUEST.ad_units[0], bids: [{bidder: null, bid_id: 'testId'}]}]}; + } + + beforeEach(() => { + bidReq = {...BID_REQUESTS[0], bidderCode: null, bids: [{...BID_REQUESTS[0].bids[0], bidder: null, bidId: 'testId'}]} + response = deepClone(RESPONSE_OPENRTB); + response.seatbid[0].seat = 'storedImpression'; + }) + + it('uses "null" request\'s ID for all responses, when a null request is present', function () { + const cfg = {...CONFIG, allowUnknownBidderCodes: true}; + config.setConfig({s2sConfig: cfg}); + adapter.callBids(mks2sReq(cfg), [bidReq], addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(response)); + sinon.assert.calledWith(addBidResponse, sinon.match.any, sinon.match({bidderCode: 'storedImpression', requestId: 'testId'})) + }); + + it('does not allow null requests (= stored impressions) if allowUnknownBidderCodes is not set', () => { + config.setConfig({s2sConfig: CONFIG}); + adapter.callBids(mks2sReq(), [bidReq], addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(response)); + expect(addBidResponse.called).to.be.false; + expect(addBidResponse.reject.calledOnce).to.be.true; + }); + }) it('copies ortb2Imp to response when there is only a null bid', () => { const cfg = {...CONFIG}; @@ -2506,6 +3375,26 @@ describe('S2S Adapter', function () { sinon.assert.match(actual.imp[0], sinon.match(ortb2Imp)); }); + it('setting adapterCode for default bidder', function () { + config.setConfig({ CONFIG }); + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB)); + + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('adapterCode', 'appnexus'); + }); + + it('setting adapterCode for alternate bidder', function () { + config.setConfig({ CONFIG }); + let RESPONSE_OPENRTB2 = deepClone(RESPONSE_OPENRTB); + RESPONSE_OPENRTB2.seatbid[0].bid[0].ext.prebid.meta.adaptercode = 'appnexus2' + adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB2)); + + const response = addBidResponse.firstCall.args[1]; + expect(response).to.have.property('adapterCode', 'appnexus2'); + }); + describe('on sync requested with no cookie', () => { let cfg, req, csRes; @@ -2535,6 +3424,70 @@ describe('S2S Adapter', function () { }); }); }); + describe('when the response contains ext.prebid.fledge', () => { + let fledgeStub, request, bidderRequests; + + function fledgeHook(next, ...args) { + fledgeStub(...args); + } + + before(() => { + addComponentAuction.before(fledgeHook); + }); + + after(() => { + addComponentAuction.getHooks({hook: fledgeHook}).remove(); + }) + + beforeEach(function () { + fledgeStub = sinon.stub(); + config.setConfig({CONFIG}); + request = deepClone(REQUEST); + request.ad_units.forEach(au => deepSetValue(au, 'ortb2Imp.ext.ae', 1)); + bidderRequests = deepClone(BID_REQUESTS); + bidderRequests.forEach(req => req.fledgeEnabled = true); + }); + + const AU = 'div-gpt-ad-1460505748561-0'; + const FLEDGE_RESP = { + ext: { + prebid: { + fledge: { + auctionconfigs: [ + { + impid: AU, + config: { + id: 1 + } + }, + { + impid: AU, + config: { + id: 2 + } + } + ] + } + } + } + } + + it('calls addComponentAuction alongside addBidResponse', function () { + adapter.callBids(request, bidderRequests, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(mergeDeep({}, RESPONSE_OPENRTB, FLEDGE_RESP))); + expect(addBidResponse.called).to.be.true; + sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 1}); + sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 2}); + }); + + it('calls addComponentAuction when there is no bid in the response', () => { + adapter.callBids(request, bidderRequests, addBidResponse, done, ajax); + server.requests[0].respond(200, {}, JSON.stringify(FLEDGE_RESP)); + expect(addBidResponse.called).to.be.false; + sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 1}); + sinon.assert.calledWith(fledgeStub, bidderRequests[0].auctionId, AU, {id: 2}); + }) + }); }); describe('bid won events', function () { @@ -2986,5 +3939,190 @@ describe('S2S Adapter', function () { expect(requestBid.ext.prebid.debug).is.equal(true); }); + + it('should correctly add floors flag', function () { + let bidRequest = utils.deepClone(BID_REQUESTS); + + // should not pass if floorData is undefined + adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax); + let requestBid = JSON.parse(server.requests[0].requestBody); + + expect(requestBid.ext.prebid.floors).to.be.undefined; + + config.setConfig({floors: {}}); + + adapter.callBids(REQUEST, bidRequest, addBidResponse, done, ajax); + requestBid = JSON.parse(server.requests[1].requestBody); + + expect(requestBid.ext.prebid.floors).to.deep.equal({ enabled: false }); + }); + + it('should override prebid server default DEFAULT_S2S_CURRENCY', function () { + config.setConfig({ + currency: { adServerCurrency: 'JPY' }, + }); + + const bidRequests = utils.deepClone(BID_REQUESTS); + adapter.callBids(REQUEST, bidRequests, addBidResponse, done, ajax); + + const parsedRequestBody = JSON.parse(server.requests[1].requestBody); + expect(parsedRequestBody.cur).to.deep.equal(['JPY']); + }); + + it('should correctly set the floorMin key when multiple bids with various bidfloors exist', function () { + const s2sConfig = Object.assign({}, CONFIG, { + extPrebid: { + floors: { + enabled: true + } + }, + bidders: ['b1', 'b2'] + }); + + const bidderRequests = [ + { + ...BID_REQUESTS[0], + bidderCode: 'b1', + bids: [{ + bidder: 'b1', + bidId: 1, + getFloor: () => ({ + currency: 'US', + floor: 1.23 + }) + }] + }, + { + ...BID_REQUESTS[0], + bidderCode: 'b2', + bids: [{ + bidder: 'b2', + bidId: 2, + getFloor: () => ({ + currency: 'EUR', + floor: 3.21 + }) + }], + } + ]; + + const adUnits = [ + { + code: 'au1', + transactionId: 't1', + mediaTypes: { + banner: {sizes: [1, 1]} + }, + bids: [{bidder: 'b1', bid_id: 1}] + }, + { + code: 'au2', + transactionId: 't2', + bids: [{bidder: 'b2', bid_id: 2}], + mediaTypes: { + banner: {sizes: [1, 1]} + } + } + ]; + + const _config = { + s2sConfig: s2sConfig, + }; + + const s2sBidRequest = utils.deepClone(REQUEST); + s2sBidRequest.s2sConfig = s2sConfig; + s2sBidRequest.ad_units = adUnits; + config.setConfig(_config); + + adapter.callBids(s2sBidRequest, bidderRequests, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp[0].bidfloor).to.equal(1.23); + expect(requestBid.imp[1].bidfloor).to.equal(3.21); + + // first imp floorCur should be set + expect(requestBid.ext.prebid.floors).to.deep.equal({ enabled: true, floorMin: 1.23, floorMinCur: 'US' }); + }); + + it('should correctly set the floorMin key when multiple bids with various bidfloors exist and ortb2Imp contains the lowest floorMin', function () { + const s2sConfig = Object.assign({}, CONFIG, { + extPrebid: { + floors: { + enabled: true + } + }, + bidders: ['b1', 'b2'] + }); + + const bidderRequests = [ + { + ...BID_REQUESTS[0], + bidderCode: 'b1', + bids: [{ + bidder: 'b1', + bidId: 1, + getFloor: () => ({ + currency: 'CUR', + floor: 1.23 + }) + }] + }, + { + ...BID_REQUESTS[0], + bidderCode: 'b2', + bids: [{ + bidder: 'b2', + bidId: 2, + getFloor: () => ({ + currency: 'CUR', + floor: 3.21 + }) + }], + } + ]; + + const adUnits = [ + { + code: 'au1', + transactionId: 't1', + mediaTypes: { + banner: {sizes: [1, 1]} + }, + bids: [{bidder: 'b1', bid_id: 1}] + }, + { + code: 'au2', + transactionId: 't2', + bids: [{bidder: 'b2', bid_id: 2}], + mediaTypes: { + banner: {sizes: [1, 1]} + }, + ortb2Imp: { + ext: { + prebid: { + floors: { + floorMin: 1 + } + } + } + } + } + ]; + + const _config = { + s2sConfig: s2sConfig, + }; + + const s2sBidRequest = utils.deepClone(REQUEST); + s2sBidRequest.s2sConfig = s2sConfig; + s2sBidRequest.ad_units = adUnits; + config.setConfig(_config); + + adapter.callBids(s2sBidRequest, bidderRequests, addBidResponse, done, ajax); + const requestBid = JSON.parse(server.requests[0].requestBody); + expect(requestBid.imp[0].bidfloor).to.equal(1.23); + expect(requestBid.imp[1].bidfloor).to.equal(3.21); + + expect(requestBid.ext.prebid.floors).to.deep.equal({ enabled: true, floorMin: 1, floorMinCur: 'CUR' }); + }); }); }); diff --git a/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js b/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js index e504eced868..25834e8574d 100644 --- a/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js +++ b/test/spec/modules/prebidmanagerAnalyticsAdapter_spec.js @@ -1,9 +1,8 @@ -import prebidmanagerAnalytics, { - storage -} from 'modules/prebidmanagerAnalyticsAdapter.js'; +import prebidmanagerAnalytics, {storage} from 'modules/prebidmanagerAnalyticsAdapter.js'; import {expect} from 'chai'; import {server} from 'test/mocks/xhr.js'; import * as utils from 'src/utils.js'; +import {expectEvents} from '../../helpers/analytics.js'; let events = require('src/events'); let constants = require('src/constants.json'); @@ -71,7 +70,7 @@ describe('Prebid Manager Analytics Adapter', function () { prebidmanagerAnalytics.flush(); expect(server.requests.length).to.equal(1); - expect(server.requests[0].url).to.equal('https://endpoint.prebidmanager.com/endpoint'); + expect(server.requests[0].url).to.equal('https://endpt.prebidmanager.com/endpoint'); expect(server.requests[0].requestBody.substring(0, 2)).to.equal('1:'); const pmEvents = JSON.parse(server.requests[0].requestBody.substring(2)); @@ -95,14 +94,7 @@ describe('Prebid Manager Analytics Adapter', function () { } }); - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_TIMEOUT, {}); - - sinon.assert.callCount(prebidmanagerAnalytics.track, 6); + expectEvents().to.beTrackedBy(prebidmanagerAnalytics.track); }); }); diff --git a/test/spec/modules/precisoBidAdapter_spec.js b/test/spec/modules/precisoBidAdapter_spec.js new file mode 100644 index 00000000000..1a7e24d64cb --- /dev/null +++ b/test/spec/modules/precisoBidAdapter_spec.js @@ -0,0 +1,152 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/precisoBidAdapter.js'; +import { config } from '../../../src/config.js'; + +const DEFAULT_PRICE = 1 +const DEFAULT_CURRENCY = 'USD' +const DEFAULT_BANNER_WIDTH = 300 +const DEFAULT_BANNER_HEIGHT = 250 +const BIDDER_CODE = 'preciso'; + +describe('PrecisoAdapter', function () { + let bid = { + bidId: '23fhj33i987f', + bidder: 'preciso', + mediaTypes: { + banner: { + sizes: [[DEFAULT_BANNER_WIDTH, DEFAULT_BANNER_HEIGHT]] + } + }, + params: { + host: 'prebid', + sourceid: '0', + publisherId: '0', + mediaType: 'banner', + + region: 'prebid-eu' + + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and sourceid parameters present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + delete bid.params.publisherId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid]); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://ssp-bidder.mndtrk.com/bid_request/openrtb'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + + // expect(data).to.have.all.keys('bidId', 'imp', 'site', 'deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'coppa'); + + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.coppa).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + }); + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.imp).to.be.an('array').that.is.empty; + }); + }); + + describe('with COPPA', function () { + beforeEach(function () { + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + }); + afterEach(function () { + config.getConfig.restore(); + }); + + it('should send the Coppa "required" flag set to "1" in the request', function () { + let serverRequest = spec.buildRequests([bid]); + expect(serverRequest.data.coppa).to.equal(1); + }); + }); + + describe('interpretResponse', function () { + it('should get correct bid response', function () { + let response = { + + bidderRequestId: 'f6adb85f-4e19-45a0-b41e-2a5b9a48f23a', + + seatbid: [ + { + bid: [ + { + id: '123', + impid: 'b4f290d7-d4ab-4778-ab94-2baf06420b22', + price: DEFAULT_PRICE, + adm: 'hi', + cid: 'test_cid', + crid: 'test_banner_crid', + w: DEFAULT_BANNER_WIDTH, + h: DEFAULT_BANNER_HEIGHT, + adomain: [], + } + ], + seat: BIDDER_CODE + } + ], + } + + let expectedResponse = [ + { + requestId: 'b4f290d7-d4ab-4778-ab94-2baf06420b22', + cpm: DEFAULT_PRICE, + width: DEFAULT_BANNER_WIDTH, + height: DEFAULT_BANNER_HEIGHT, + creativeId: 'test_banner_crid', + ad: 'hi', + currency: DEFAULT_CURRENCY, + netRevenue: true, + ttl: 300, + meta: { advertiserDomains: [] }, + } + ] + let result = spec.interpretResponse({ body: response }) + + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])) + }) + }) + describe('getUserSyncs', function () { + const syncUrl = 'https://ck.2trk.info/rtb/user/usersync.aspx?id=preciso_srl&gdpr=0&gdpr_consent=&us_privacy=&t=4'; + const syncOptions = { + iframeEnabled: true + }; + let userSync = spec.getUserSyncs(syncOptions); + it('Returns valid URL and type', function () { + expect(userSync).to.be.an('array').with.lengthOf(1); + expect(userSync[0].type).to.exist; + expect(userSync[0].url).to.exist; + expect(userSync).to.deep.equal([ + { type: 'iframe', url: syncUrl } + ]); + }); + }); +}); diff --git a/test/spec/modules/priceFloors_spec.js b/test/spec/modules/priceFloors_spec.js index 6ea58e8c47a..950e039491d 100644 --- a/test/spec/modules/priceFloors_spec.js +++ b/test/spec/modules/priceFloors_spec.js @@ -12,7 +12,7 @@ import { isFloorsDataValid, addBidResponseHook, fieldMatchingFunctions, - allowedFields + allowedFields, parseFloorData, normalizeDefault, getFloorDataFromAdUnits } from 'modules/priceFloors.js'; import * as events from 'src/events.js'; import * as mockGpt from '../integration/faker/googletag.js'; @@ -20,6 +20,9 @@ import 'src/prebid.js'; import {createBid} from '../../../src/bidfactory.js'; import {auctionManager} from '../../../src/auctionManager.js'; import {stubAuctionIndex} from '../../helpers/indexStub.js'; +import {guardTids} from '../../../src/adapters/bidderFactory.js'; +import * as activities from '../../../src/activities/rules.js'; +import {server} from '../../mocks/xhr.js'; describe('the price floors module', function () { let logErrorSpy; @@ -120,7 +123,7 @@ describe('the price floors module', function () { return { code, mediaTypes: {banner: { sizes: [[300, 200], [300, 600]] }, native: {}}, - bids: [{bidder: 'someBidder'}, {bidder: 'someOtherBidder'}] + bids: [{bidder: 'someBidder', adUnitCode: code}, {bidder: 'someOtherBidder', adUnitCode: code}] }; } beforeEach(function() { @@ -140,6 +143,76 @@ describe('the price floors module', function () { getGlobal().bidderSettings = {}; }); + describe('parseFloorData', () => { + it('should accept just a default floor', () => { + const fd = parseFloorData({ + default: 1.23 + }); + expect(getFirstMatchingFloor(fd, {}, {}).matchingFloor).to.eql(1.23); + }); + }); + + describe('getFloorDataFromAdUnits', () => { + let adUnits; + + function setFloorValues(rule) { + adUnits.forEach((au, i) => { + au.floors = { + values: { + [rule]: i + 1 + } + } + }) + } + + beforeEach(() => { + adUnits = ['au1', 'au2', 'au3'].map(getAdUnitMock); + }) + + it('should use one schema for all adUnits', () => { + setFloorValues('*;*') + adUnits[1].floors.schema = { + fields: ['mediaType', 'gptSlot'], + delimiter: ';' + } + sinon.assert.match(getFloorDataFromAdUnits(adUnits), { + schema: { + fields: ['adUnitCode', 'mediaType', 'gptSlot'], + delimiter: ';' + }, + values: { + 'au1;*;*': 1, + 'au2;*;*': 2, + 'au3;*;*': 3 + } + }) + }); + it('should ignore adUnits that declare different schema', () => { + setFloorValues('*|*'); + adUnits[0].floors.schema = { + fields: ['mediaType', 'gptSlot'] + }; + adUnits[2].floors.schema = { + fields: ['gptSlot', 'mediaType'] + }; + expect(getFloorDataFromAdUnits(adUnits).values).to.eql({ + 'au1|*|*': 1, + 'au2|*|*': 2 + }) + }); + it('should ignore adUnits that declare no values', () => { + setFloorValues('*'); + adUnits[0].floors.schema = { + fields: ['mediaType'] + }; + delete adUnits[2].floors.values; + expect(getFloorDataFromAdUnits(adUnits).values).to.eql({ + 'au1|*': 1, + 'au2|*': 2, + }) + }) + }) + describe('getFloorsDataForAuction', function () { it('converts basic input floor data into a floorData map for the auction correctly', function () { // basic input where nothing needs to be updated @@ -230,8 +303,8 @@ describe('the price floors module', function () { }); describe('getFirstMatchingFloor', function () { - it('uses a 0 floor as overrite', function () { - let inputFloorData = { + it('uses a 0 floor as override', function () { + let inputFloorData = normalizeDefault({ currency: 'USD', schema: { delimiter: '|', @@ -242,7 +315,7 @@ describe('the price floors module', function () { 'test_div_2': 2 }, default: 0.5 - }; + }); expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({ floorMin: 0, @@ -268,6 +341,56 @@ describe('the price floors module', function () { matchingRule: undefined }); }); + it('correctly applies floorMin if on adunit', function () { + let inputFloorData = { + floorMin: 2.6, + currency: 'USD', + schema: { + delimiter: '|', + fields: ['adUnitCode'] + }, + values: { + 'test_div_1': 1.0, + 'test_div_2': 2.0 + }, + default: 0.5 + }; + + let myBidRequest = { ...basicBidRequest }; + + // should take adunit floormin first even if lower + utils.deepSetValue(myBidRequest, 'ortb2Imp.ext.prebid.floors.floorMin', 2.2); + expect(getFirstMatchingFloor(inputFloorData, myBidRequest, { mediaType: 'banner', size: '*' })).to.deep.equal({ + floorMin: 2.2, + floorRuleValue: 1.0, + matchingFloor: 2.2, + matchingData: 'test_div_1', + matchingRule: 'test_div_1' + }); + delete inputFloorData.matchingInputs; + + // should take adunit floormin if higher + utils.deepSetValue(myBidRequest, 'ortb2Imp.ext.prebid.floors.floorMin', 3.0); + expect(getFirstMatchingFloor(inputFloorData, myBidRequest, { mediaType: 'banner', size: '*' })).to.deep.equal({ + floorMin: 3.0, + floorRuleValue: 1.0, + matchingFloor: 3.0, + matchingData: 'test_div_1', + matchingRule: 'test_div_1' + }); + delete inputFloorData.matchingInputs; + + // should take top floormin if no adunit floor min + delete myBidRequest.ortb2Imp; + expect(getFirstMatchingFloor(inputFloorData, myBidRequest, { mediaType: 'banner', size: '*' })).to.deep.equal({ + floorMin: 2.6, + floorRuleValue: 1.0, + matchingFloor: 2.6, + matchingData: 'test_div_1', + matchingRule: 'test_div_1' + }); + delete inputFloorData.matchingInputs; + }); it('selects the right floor for different mediaTypes', function () { // banner with * size (not in rule file so does not do anything) expect(getFirstMatchingFloor({...basicFloorData}, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({ @@ -381,7 +504,7 @@ describe('the price floors module', function () { }); }); it('selects the right floor for more complex rules', function () { - let inputFloorData = { + let inputFloorData = normalizeDefault({ currency: 'USD', schema: { delimiter: '^', @@ -395,7 +518,7 @@ describe('the price floors module', function () { 'weird_div^*^300x250': 5.5 }, default: 0.5 - }; + }); // banner with 300x250 size expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: [300, 250]})).to.deep.equal({ floorMin: 0, @@ -437,10 +560,8 @@ describe('the price floors module', function () { matchingFloor: undefined }); // if default is there use it - inputFloorData = { default: 5.0 }; - expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: '*'})).to.deep.equal({ - matchingFloor: 5.0 - }); + inputFloorData = normalizeDefault({ default: 5.0 }); + expect(getFirstMatchingFloor(inputFloorData, basicBidRequest, {mediaType: 'banner', size: '*'}).matchingFloor).to.equal(5.0); }); describe('with gpt enabled', function () { let gptFloorData; @@ -532,7 +653,7 @@ describe('the price floors module', function () { const validateBidRequests = (getFloorExpected, FloorDataExpected) => { exposedAdUnits.forEach(adUnit => adUnit.bids.forEach(bid => { expect(bid.hasOwnProperty('getFloor')).to.equal(getFloorExpected); - expect(bid.floorData).to.deep.equal(FloorDataExpected); + sinon.assert.match(bid.floorData, FloorDataExpected); })); }; const runStandardAuction = (adUnits = [getAdUnitMock('test_div_1')]) => { @@ -541,16 +662,11 @@ describe('the price floors module', function () { adUnits, }); }; - let fakeFloorProvider; let actualAllowedFields = allowedFields; let actualFieldMatchingFunctions = fieldMatchingFunctions; const defaultAllowedFields = [...allowedFields]; const defaultMatchingFunctions = {...fieldMatchingFunctions}; - beforeEach(function() { - fakeFloorProvider = sinon.fakeServer.create(); - }); afterEach(function() { - fakeFloorProvider.restore(); exposedAdUnits = undefined; actualAllowedFields = [...defaultAllowedFields]; actualFieldMatchingFunctions = {...defaultMatchingFunctions}; @@ -645,6 +761,95 @@ describe('the price floors module', function () { floorProvider: undefined }); }); + describe('default floor', () => { + let adUnits; + beforeEach(() => { + adUnits = ['au1', 'au2'].map(getAdUnitMock); + }) + function expectFloors(floors) { + runStandardAuction(adUnits); + adUnits.forEach((au, i) => { + au.bids.forEach(bid => { + expect(bid.getFloor().floor).to.eql(floors[i]); + }) + }) + } + describe('should be sufficient by itself', () => { + it('globally', () => { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: { + default: 1.23 + } + }); + expectFloors([1.23, 1.23]) + }); + it('on adUnits', () => { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: undefined + }); + adUnits[0].floors = {default: 1}; + adUnits[1].floors = {default: 2}; + expectFloors([1, 2]) + }); + it('on an adUnit with hidden schema', () => { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: undefined + }); + adUnits[0].floors = { + schema: { + fields: ['mediaType', 'gptSlot'], + }, + default: 1 + } + adUnits[1].floors = { + default: 2 + } + expectFloors([1, 2]); + }) + }); + describe('should NOT be used when a star rule exists', () => { + it('globally', () => { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: { + schema: { + fields: ['mediaType', 'gptSlot'], + }, + values: { + '*|*': 2 + }, + default: 3, + } + }); + expectFloors([2, 2]); + }); + it('on adUnits', () => { + handleSetFloorsConfig({ + ...basicFloorConfig, + data: undefined + }); + adUnits[0].floors = { + schema: { + fields: ['mediaType', 'gptSlot'], + }, + values: { + '*|*': 1 + }, + default: 3 + }; + adUnits[1].floors = { + values: { + '*|*': 2 + }, + default: 4 + } + expectFloors([1, 2]); + }) + }); + }) it('bidRequests should have getFloor function and flooring meta data when setConfig occurs', function () { handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorprovider'}); runStandardAuction(); @@ -868,16 +1073,8 @@ describe('the price floors module', function () { floorProvider: 'floorprovider' }); }); - it('should not overwrite previous data object if the new one is bad', function () { + it('should ignore and reset floor data when provided with invalid data', function () { handleSetFloorsConfig({...basicFloorConfig}); - handleSetFloorsConfig({ - ...basicFloorConfig, - data: undefined - }); - handleSetFloorsConfig({ - ...basicFloorConfig, - data: 5 - }); handleSetFloorsConfig({ ...basicFloorConfig, data: { @@ -887,17 +1084,7 @@ describe('the price floors module', function () { } }); runStandardAuction(); - validateBidRequests(true, { - skipped: false, - floorMin: undefined, - modelVersion: 'basic model', - modelWeight: 10, - modelTimestamp: 1606772895, - location: 'setConfig', - skipRate: 0, - fetchStatus: undefined, - floorProvider: undefined - }); + validateBidRequests(false, sinon.match({location: 'noData', skipped: true})); }); it('should dynamically add new schema fileds and functions if added via setConfig', function () { let deviceSpoof; @@ -952,7 +1139,7 @@ describe('the price floors module', function () { }); }); it('Should continue auction of delay is hit without a response from floor provider', function () { - handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json//'}}); // start the auction it should delay and not immediately call `continueAuction` runStandardAuction(); @@ -979,7 +1166,7 @@ describe('the price floors module', function () { fetchStatus: 'timeout', floorProvider: undefined }); - fakeFloorProvider.respond(); + server.respond(); }); it('It should fetch if config has url and bidRequests have fetch level flooring meta data', function () { // init the fake server with response stuff @@ -987,14 +1174,14 @@ describe('the price floors module', function () { ...basicFloorData, modelVersion: 'fetch model name', // change the model name }; - fakeFloorProvider.respondWith(JSON.stringify(fetchFloorData)); + server.respondWith(JSON.stringify(fetchFloorData)); // run setConfig indicating fetch - handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorprovider', auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorprovider', auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); // floor provider should be called - expect(fakeFloorProvider.requests.length).to.equal(1); - expect(fakeFloorProvider.requests[0].url).to.equal('http://www.fakeFloorProvider.json'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('http://www.fakefloorprovider.json/'); // start the auction it should delay and not immediately call `continueAuction` runStandardAuction(); @@ -1003,7 +1190,7 @@ describe('the price floors module', function () { expect(exposedAdUnits).to.be.undefined; // make the fetch respond - fakeFloorProvider.respond(); + server.respond(); expect(exposedAdUnits).to.not.be.undefined; // the exposedAdUnits should be from the fetch not setConfig level data @@ -1027,14 +1214,14 @@ describe('the price floors module', function () { floorProvider: 'floorProviderD', // change the floor provider modelVersion: 'fetch model name', // change the model name }; - fakeFloorProvider.respondWith(JSON.stringify(fetchFloorData)); + server.respondWith(JSON.stringify(fetchFloorData)); // run setConfig indicating fetch - handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorproviderC', auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorproviderC', auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); // floor provider should be called - expect(fakeFloorProvider.requests.length).to.equal(1); - expect(fakeFloorProvider.requests[0].url).to.equal('http://www.fakeFloorProvider.json'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('http://www.fakefloorprovider.json/'); // start the auction it should delay and not immediately call `continueAuction` runStandardAuction(); @@ -1043,7 +1230,7 @@ describe('the price floors module', function () { expect(exposedAdUnits).to.be.undefined; // make the fetch respond - fakeFloorProvider.respond(); + server.respond(); // the exposedAdUnits should be from the fetch not setConfig level data // and fetchStatus is success since fetch worked @@ -1068,14 +1255,14 @@ describe('the price floors module', function () { modelVersion: 'fetch model name', // change the model name }; fetchFloorData.skipRate = 95; - fakeFloorProvider.respondWith(JSON.stringify(fetchFloorData)); + server.respondWith(JSON.stringify(fetchFloorData)); // run setConfig indicating fetch - handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorprovider', auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, floorProvider: 'floorprovider', auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); // floor provider should be called - expect(fakeFloorProvider.requests.length).to.equal(1); - expect(fakeFloorProvider.requests[0].url).to.equal('http://www.fakeFloorProvider.json'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('http://www.fakefloorprovider.json/'); // start the auction it should delay and not immediately call `continueAuction` runStandardAuction(); @@ -1084,7 +1271,7 @@ describe('the price floors module', function () { expect(exposedAdUnits).to.be.undefined; // make the fetch respond - fakeFloorProvider.respond(); + server.respond(); expect(exposedAdUnits).to.not.be.undefined; // the exposedAdUnits should be from the fetch not setConfig level data @@ -1103,10 +1290,10 @@ describe('the price floors module', function () { }); it('Should not break if floor provider returns 404', function () { // run setConfig indicating fetch - handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); // run the auction and make server respond with 404 - fakeFloorProvider.respond(); + server.respond(); runStandardAuction(); // error should have been called for fetch error @@ -1126,13 +1313,13 @@ describe('the price floors module', function () { }); }); it('Should not break if floor provider returns non json', function () { - fakeFloorProvider.respondWith('Not valid response'); + server.respondWith('Not valid response'); // run setConfig indicating fetch - handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); // run the auction and make server respond - fakeFloorProvider.respond(); + server.respond(); runStandardAuction(); // error should have been called for response floor data not being valid @@ -1153,27 +1340,27 @@ describe('the price floors module', function () { }); it('should handle not using fetch correctly', function () { // run setConfig twice indicating fetch - fakeFloorProvider.respondWith(JSON.stringify(basicFloorData)); - handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); - handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); + server.respondWith(JSON.stringify(basicFloorData)); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); // log warn should be called and server only should have one request expect(logWarnSpy.calledOnce).to.equal(true); - expect(fakeFloorProvider.requests.length).to.equal(1); - expect(fakeFloorProvider.requests[0].url).to.equal('http://www.fakeFloorProvider.json'); + expect(server.requests.length).to.equal(1); + expect(server.requests[0].url).to.equal('http://www.fakefloorprovider.json/'); // now we respond and then run again it should work and make another request - fakeFloorProvider.respond(); - handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakeFloorProvider.json'}}); - fakeFloorProvider.respond(); + server.respond(); + handleSetFloorsConfig({...basicFloorConfig, auctionDelay: 250, endpoint: {url: 'http://www.fakefloorprovider.json/'}}); + server.respond(); // now warn still only called once and server called twice expect(logWarnSpy.calledOnce).to.equal(true); - expect(fakeFloorProvider.requests.length).to.equal(2); + expect(server.requests.length).to.equal(2); // should log error if method is not GET for now expect(logErrorSpy.calledOnce).to.equal(false); - handleSetFloorsConfig({...basicFloorConfig, endpoint: {url: 'http://www.fakeFloorProvider.json', method: 'POST'}}); + handleSetFloorsConfig({...basicFloorConfig, endpoint: {url: 'http://www.fakefloorprovider.json/', method: 'POST'}}); expect(logErrorSpy.calledOnce).to.equal(true); }); describe('isFloorsDataValid', function () { @@ -1337,10 +1524,22 @@ describe('the price floors module', function () { floor: 2.5 }); }); + + it('works when TIDs are disabled', () => { + sandbox.stub(activities, 'isActivityAllowed').returns(false); + const req = utils.deepClone(bidRequest); + _floorDataForAuction[req.auctionId] = utils.deepClone(basicFloorConfig); + + expect(guardTids('mock-bidder').bidRequest(req).getFloor({})).to.deep.equal({ + currency: 'USD', + floor: 1.0 + }); + }); + it('picks the right rule with more complex rules', function () { _floorDataForAuction[bidRequest.auctionId] = { ...basicFloorConfig, - data: { + data: normalizeDefault({ currency: 'USD', schema: { fields: ['mediaType', 'size'], delimiter: '|' }, values: { @@ -1352,7 +1551,7 @@ describe('the price floors module', function () { 'video|*': 5.5 }, default: 10.0 - } + }) }; // assumes banner * @@ -1445,6 +1644,161 @@ describe('the price floors module', function () { }); }); + it('should use inverseFloorAdjustment function before bidder cpm adjustment', function () { + let functionUsed; + getGlobal().bidderSettings = { + rubicon: { + bidCpmAdjustment: function (bidCpm, bidResponse) { + functionUsed = 'Rubicon Adjustment'; + bidCpm *= 0.5; + if (bidResponse.mediaType === 'video') bidCpm -= 0.18; + return bidCpm; + }, + inverseBidAdjustment: function (bidCpm, bidRequest) { + functionUsed = 'Rubicon Inverse'; + // if video is the only mediaType on Bid Request => add 0.18 + if (bidRequest.mediaTypes.video && Object.keys(bidRequest.mediaTypes).length === 1) bidCpm += 0.18; + return bidCpm / 0.5; + }, + }, + appnexus: { + bidCpmAdjustment: function (bidCpm, bidResponse) { + functionUsed = 'Appnexus Adjustment'; + bidCpm *= 0.75; + if (bidResponse.mediaType === 'video') bidCpm -= 0.18; + return bidCpm; + }, + inverseBidAdjustment: function (bidCpm, bidRequest) { + functionUsed = 'Appnexus Inverse'; + // if video is the only mediaType on Bid Request => add 0.18 + if (bidRequest.mediaTypes.video && Object.keys(bidRequest.mediaTypes).length === 1) bidCpm += 0.18; + return bidCpm / 0.75; + }, + } + }; + + _floorDataForAuction[bidRequest.auctionId] = utils.deepClone(basicFloorConfig); + + _floorDataForAuction[bidRequest.auctionId].data.values = { '*': 1.0 }; + + // start with banner as only mediaType + bidRequest.mediaTypes = { banner: { sizes: [[300, 250]] } }; + let appnexusBid = { + ...bidRequest, + bidder: 'appnexus', + }; + + // should be same as the adjusted calculated inverses above test (banner) + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 2.0 + }); + + // should use rubicon inverse + expect(functionUsed).to.equal('Rubicon Inverse'); + + // appnexus just using banner should be same + expect(appnexusBid.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.3334 + }); + + expect(functionUsed).to.equal('Appnexus Inverse'); + + // now since asking for 'video' only mediaType inverse function should include the .18 + bidRequest.mediaTypes = { video: { context: 'instream' } }; + expect(bidRequest.getFloor({ mediaType: 'video' })).to.deep.equal({ + currency: 'USD', + floor: 2.36 + }); + + expect(functionUsed).to.equal('Rubicon Inverse'); + + // now since asking for 'video' inverse function should include the .18 + appnexusBid.mediaTypes = { video: { context: 'instream' } }; + expect(appnexusBid.getFloor({ mediaType: 'video' })).to.deep.equal({ + currency: 'USD', + floor: 1.5734 + }); + + expect(functionUsed).to.equal('Appnexus Inverse'); + }); + + it('should pass inverseFloorAdjustment the bidRequest object so it can be used', function () { + // Adjustment factors based on Bid Media Type + const mediaTypeFactors = { + banner: 0.5, + native: 0.7, + video: 0.9 + } + getGlobal().bidderSettings = { + rubicon: { + bidCpmAdjustment: function (bidCpm, bidResponse) { + return bidCpm * mediaTypeFactors[bidResponse.mediaType]; + }, + inverseBidAdjustment: function (bidCpm, bidRequest) { + // For the inverse we add up each mediaType in the request and divide by number of Mt's to get the inverse number + let factor = Object.keys(bidRequest.mediaTypes).reduce((sum, mediaType) => sum += mediaTypeFactors[mediaType], 0); + factor = factor / Object.keys(bidRequest.mediaTypes).length; + return bidCpm / factor; + }, + } + }; + + _floorDataForAuction[bidRequest.auctionId] = utils.deepClone(basicFloorConfig); + + _floorDataForAuction[bidRequest.auctionId].data.values = { '*': 1.0 }; + + // banner only should be 2 + bidRequest.mediaTypes = { banner: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 2.0 + }); + + // native only should be 1.4286 + bidRequest.mediaTypes = { native: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.4286 + }); + + // video only should be 1.1112 + bidRequest.mediaTypes = { video: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.1112 + }); + + // video and banner should even out to 0.7 factor so 1.4286 + bidRequest.mediaTypes = { video: {}, banner: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.4286 + }); + + // video and native should even out to 0.8 factor so -- 1.25 + bidRequest.mediaTypes = { video: {}, native: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.25 + }); + + // banner and native should even out to 0.6 factor so -- 1.6667 + bidRequest.mediaTypes = { banner: {}, native: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.6667 + }); + + // all 3 banner video and native should even out to 0.7 factor so -- 1.4286 + bidRequest.mediaTypes = { banner: {}, native: {}, video: {} }; + expect(bidRequest.getFloor()).to.deep.equal({ + currency: 'USD', + floor: 1.4286 + }); + }); + it('should use standard cpmAdjustment if no bidder cpmAdjustment', function () { getGlobal().bidderSettings = { rubicon: { @@ -1615,7 +1969,7 @@ describe('the price floors module', function () { }); describe('bidResponseHook tests', function () { const AUCTION_ID = '123456'; - let returnedBidResponse, indexStub; + let returnedBidResponse, indexStub, reject; let adUnit = { transactionId: 'au', code: 'test_div_1' @@ -1630,7 +1984,8 @@ describe('the price floors module', function () { transactionId: 'au', }; beforeEach(function () { - returnedBidResponse = {}; + returnedBidResponse = null; + reject = sinon.stub().returns({status: 'rejected'}); indexStub = sinon.stub(auctionManager, 'index'); indexStub.get(() => stubAuctionIndex({adUnits: [adUnit]})); }); @@ -1643,7 +1998,7 @@ describe('the price floors module', function () { let next = (adUnitCode, bid) => { returnedBidResponse = bid; }; - addBidResponseHook(next, bidResp.adUnitCode, Object.assign(createBid(CONSTANTS.STATUS.GOOD, {auctionId: AUCTION_ID}), bidResp)); + addBidResponseHook(next, bidResp.adUnitCode, Object.assign(createBid(CONSTANTS.STATUS.GOOD, {auctionId: AUCTION_ID}), bidResp), reject); }; it('continues with the auction if not floors data is present without any flooring', function () { runBidResponse(); @@ -1660,9 +2015,8 @@ describe('the price floors module', function () { _floorDataForAuction[AUCTION_ID] = utils.deepClone(basicFloorConfig); _floorDataForAuction[AUCTION_ID].data.values = { 'banner': 1.0 }; runBidResponse(); - expect(returnedBidResponse).to.haveOwnProperty('floorData'); - expect(returnedBidResponse.status).to.equal(CONSTANTS.BID_STATUS.BID_REJECTED); - expect(returnedBidResponse.cpm).to.equal(0); + expect(reject.calledOnce).to.be.true; + expect(returnedBidResponse).to.not.exist; }); it('if it finds a rule and does not floor should update the bid accordingly', function () { _floorDataForAuction[AUCTION_ID] = utils.deepClone(basicFloorConfig); diff --git a/test/spec/modules/prismaBidAdapter_spec.js b/test/spec/modules/prismaBidAdapter_spec.js new file mode 100644 index 00000000000..be1c16c9059 --- /dev/null +++ b/test/spec/modules/prismaBidAdapter_spec.js @@ -0,0 +1,261 @@ +import {expect} from 'chai'; +import {spec} from 'modules/prismaBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import { requestBidsHook } from 'modules/consentManagement.js'; + +describe('Prisma bid adapter tests', function () { + const DISPLAY_BID_REQUEST = [{ + 'bidder': 'prisma', + 'params': { + 'account': '1067', + 'tagId': 'luvxjvgn' + }, + 'userId': { + 'id5id': { + 'uid': 'ID5*hQ5WobYI9Od4u52qpaXVKHhxUa4DsOWRAlvaFajm8gINfI1oVAe3UK59416dT4TqDX1pj4MBJ5TYwir6x3JgBw1-avYHSnmvQDdRMbxmC2sNf3ggIRTbyQBdI1RjvHyeDYCsistnTXF_iKF1nutYeQ2BZ4P5d5muZTG7C2PXVFgNg-18io9dCiSjzJXx93KPDYRiuIwtsGGsp51rojlpFw2Fp_dUkjXl4CAblk58DvwNhobwQ27bnBP8F2-Pcs88DYcvKn4r6dm3Vi7ILttxDQ2IgZ2X44ClgjoWh-vRf6ANis8Z7uL16vO8q0P5C21eDYuc4v_KaZqN-p9YWEeEZQ2OpkbRL7n5NieVJExHM6ANkAlLZhVf2T-1906TAIHKDZFm_xMCa1jJfpBqZB2agw2TjfbK6wMtJeHiZaipSuUNlM_CSH0HVXtfMj9yfzjzDZZnltZQ9lvc4JhXye5AwA2X1f9Dhk8VURTvVdfEUlU', + 'ext': { + 'linkType': 2 + } + } + }, + 'userIdAsEids': [ + { + 'source': 'id5-sync.com', + 'uids': [ + { + 'id': 'ID5*hQ5WobYI9Od4u52qpaXVKHhxUa4DsOWRAlvaFajm8gINfI1oVAe3UK59416dT4TqDX1pj4MBJ5TYwir6x3JgBw1-avYHSnmvQDdRMbxmC2sNf3ggIRTbyQBdI1RjvHyeDYCsistnTXF_iKF1nutYeQ2BZ4P5d5muZTG7C2PXVFgNg-18io9dCiSjzJXx93KPDYRiuIwtsGGsp51rojlpFw2Fp_dUkjXl4CAblk58DvwNhobwQ27bnBP8F2-Pcs88DYcvKn4r6dm3Vi7ILttxDQ2IgZ2X44ClgjoWh-vRf6ANis8Z7uL16vO8q0P5C21eDYuc4v_KaZqN-p9YWEeEZQ2OpkbRL7n5NieVJExHM6ANkAlLZhVf2T-1906TAIHKDZFm_xMCa1jJfpBqZB2agw2TjfbK6wMtJeHiZaipSuUNlM_CSH0HVXtfMj9yfzjzDZZnltZQ9lvc4JhXye5AwA2X1f9Dhk8VURTvVdfEUlU', + 'atype': 1, + 'ext': { + 'linkType': 2 + } + } + ] + } + ], + 'mediaTypes': { + 'banner': { + 'sizes': [[300, 250], [300, 600]] + } + }, + 'adUnitCode': 'banner-div', + 'transactionId': '9ad89d90-eb73-41b9-bf5f-7a8e2eecff27', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '4d9e29504f8af6', + 'bidderRequestId': '3423b6bd1a922c', + 'auctionId': '05e0a3a1-9f57-41f6-bbcb-2ba9c9e3d2d5', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }]; + + const DISPLAY_BID_RESPONSE = {'body': { + 'responses': [ + { + 'bidId': '4d9e29504f8af6', + 'cpm': 0.437245, + 'width': 300, + 'height': 250, + 'creativeId': '98493581', + 'currency': 'EUR', + 'netRevenue': true, + 'type': 'banner', + 'ttl': 360, + 'uuid': 'ce6d1ee3-2a05-4d7c-b97a-9e62097798ec', + 'bidder': 'appnexus', + 'consent': 1, + 'tagId': 'luvxjvgn' + } + ], + }}; + + const VIDEO_BID_REQUEST = [ + { + 'bidder': 'prisma', + 'params': { + 'account': '1067', + 'tagId': 'yqsc1tfj' + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [[640, 480]], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6], + 'playbackmethod': [2], + 'skip': 1 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '5434c81c-7210-44ae-9014-67c75dee48d0', + 'sizes': [[640, 480]], + 'bidId': '22f90541e576a3', + 'bidderRequestId': '1d4549243f3bfd', + 'auctionId': 'ed21b528-bcab-47e2-8605-ec9b71000c89', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + } + ] + + const VIDEO_BID_RESPONSE = {'body': { + 'responses': [ + { + 'bidId': '2c129e8e01859a', + 'type': 'video', + 'uuid': 'b8e7b2f0-c378-479f-aa4f-4f55d5d7d1d5', + 'cpm': 4.5421, + 'width': 1, + 'height': 1, + 'creativeId': '97517771', + 'currency': 'EUR', + 'netRevenue': true, + 'ttl': 360, + 'bidder': 'appnexus', + 'consent': 1, + 'tagId': 'yqsc1tfj' + } + ] + }}; + + const DEFAULT_OPTIONS = { + gdprConsent: { + gdprApplies: true, + consentString: 'BOzZdA0OzZdA0AGABBENDJ-AAAAvh7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__79__3z3_9pxP78k89r7337Mw_v-_v-b7JCPN_Y3v-8Kg', + vendorData: {} + }, + refererInfo: { + referer: 'https://www.prebid.org', + canonicalUrl: 'https://www.prebid.org/the/link/to/the/page' + }, + uspConsent: '111222333', + userId: { 'id5id': { uid: '1111' } }, + schain: { + 'ver': '1.0', + 'complete': 1, + 'nodes': [{ + 'asi': 'exchange1.com', + 'sid': '1234', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher', + 'domain': 'publisher.com' + }] + }, + }; + + it('Verify banner build request', function () { + const request = spec.buildRequests(DISPLAY_BID_REQUEST, DEFAULT_OPTIONS); + expect(request).to.have.property('url').and.to.equal('https://prisma.nexx360.io/prebid'); + expect(request).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request.data); + expect(requestContent.userEids.length).to.be.eql(1); + expect(requestContent.userEids[0]).to.have.property('source').and.to.equal('id5-sync.com'); + expect(requestContent.userEids[0]).to.have.property('uids'); + expect(requestContent.userEids[0].uids[0]).to.have.property('id').and.to.equal('ID5*hQ5WobYI9Od4u52qpaXVKHhxUa4DsOWRAlvaFajm8gINfI1oVAe3UK59416dT4TqDX1pj4MBJ5TYwir6x3JgBw1-avYHSnmvQDdRMbxmC2sNf3ggIRTbyQBdI1RjvHyeDYCsistnTXF_iKF1nutYeQ2BZ4P5d5muZTG7C2PXVFgNg-18io9dCiSjzJXx93KPDYRiuIwtsGGsp51rojlpFw2Fp_dUkjXl4CAblk58DvwNhobwQ27bnBP8F2-Pcs88DYcvKn4r6dm3Vi7ILttxDQ2IgZ2X44ClgjoWh-vRf6ANis8Z7uL16vO8q0P5C21eDYuc4v_KaZqN-p9YWEeEZQ2OpkbRL7n5NieVJExHM6ANkAlLZhVf2T-1906TAIHKDZFm_xMCa1jJfpBqZB2agw2TjfbK6wMtJeHiZaipSuUNlM_CSH0HVXtfMj9yfzjzDZZnltZQ9lvc4JhXye5AwA2X1f9Dhk8VURTvVdfEUlU'); + expect(requestContent.adUnits[0]).to.have.property('account').and.to.equal('1067'); + expect(requestContent.adUnits[0]).to.have.property('tagId').and.to.equal('luvxjvgn'); + expect(requestContent.adUnits[0]).to.have.property('label').and.to.equal('banner-div'); + expect(requestContent.adUnits[0]).to.have.property('bidId').and.to.equal('4d9e29504f8af6'); + expect(requestContent.adUnits[0]).to.have.property('auctionId').and.to.equal('05e0a3a1-9f57-41f6-bbcb-2ba9c9e3d2d5'); + expect(requestContent.adUnits[0]).to.have.property('mediatypes').exist; + expect(requestContent.adUnits[0].mediatypes).to.have.property('banner').exist; + expect(requestContent.adUnits[0]).to.have.property('bidfloor').and.to.equal(0); + expect(requestContent.adUnits[0]).to.have.property('bidfloorCurrency').and.to.equal('USD'); + expect(requestContent.adUnits[0]).to.have.property('keywords'); + expect(requestContent.adUnits[0].keywords.length).to.be.eql(0); + }); + + it('Verify banner parse response', function () { + const request = spec.buildRequests(DISPLAY_BID_REQUEST, DEFAULT_OPTIONS); + const response = spec.interpretResponse(DISPLAY_BID_RESPONSE, request); + expect(response).to.have.lengthOf(1); + const bid = response[0]; + expect(bid.cpm).to.equal(0.437245); + expect(bid.adUrl).to.equal('https://prisma.nexx360.io/cache?uuid=ce6d1ee3-2a05-4d7c-b97a-9e62097798ec'); + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.creativeId).to.equal('98493581'); + expect(bid.currency).to.equal('EUR'); + expect(bid.netRevenue).to.equal(true); + expect(bid.ttl).to.equal(360); + expect(bid.requestId).to.equal('4d9e29504f8af6'); + expect(bid.prisma).to.exist; + expect(bid.prisma.ssp).to.equal('appnexus'); + }); + + it('Verify video build request', function () { + const request = spec.buildRequests(VIDEO_BID_REQUEST, DEFAULT_OPTIONS); + expect(request).to.have.property('url').and.to.equal('https://prisma.nexx360.io/prebid'); + expect(request).to.have.property('method').and.to.equal('POST'); + const requestContent = JSON.parse(request.data); + expect(requestContent.adUnits[0]).to.have.property('account').and.to.equal('1067'); + expect(requestContent.adUnits[0]).to.have.property('tagId').and.to.equal('yqsc1tfj'); + expect(requestContent.adUnits[0]).to.have.property('label').and.to.equal('video1'); + expect(requestContent.adUnits[0]).to.have.property('bidId').and.to.equal('22f90541e576a3'); + expect(requestContent.adUnits[0]).to.have.property('auctionId').and.to.equal('ed21b528-bcab-47e2-8605-ec9b71000c89'); + expect(requestContent.adUnits[0]).to.have.property('mediatypes').exist; + expect(requestContent.adUnits[0].mediatypes).to.have.property('video').exist; + }); + + it('Verify video parse response', function () { + const request = spec.buildRequests(VIDEO_BID_REQUEST, DEFAULT_OPTIONS); + const response = spec.interpretResponse(VIDEO_BID_RESPONSE, request); + expect(response).to.have.lengthOf(1); + const bid = response[0]; + expect(bid.cpm).to.equal(4.5421); + expect(bid.vastUrl).to.equal('https://prisma.nexx360.io/cache?uuid=b8e7b2f0-c378-479f-aa4f-4f55d5d7d1d5'); + expect(bid.vastImpUrl).to.equal('https://prisma.nexx360.io/track-imp?type=prebid&mediatype=video&ssp=appnexus&tag_id=yqsc1tfj&consent=1&price=4.5421'); + expect(bid.width).to.equal(1); + expect(bid.height).to.equal(1); + expect(bid.creativeId).to.equal('97517771'); + expect(bid.currency).to.equal('EUR'); + expect(bid.netRevenue).to.equal(true); + expect(bid.ttl).to.equal(360); + expect(bid.requestId).to.equal('2c129e8e01859a'); + expect(bid.prisma).to.exist; + expect(bid.prisma.ssp).to.equal('appnexus'); + }); + + it('Verifies bidder code', function () { + expect(spec.code).to.equal('prisma'); + }); + + it('Verifies bidder aliases', function () { + expect(spec.aliases).to.have.lengthOf(1); + expect(spec.aliases[0]).to.eql('prismadirect'); + }); + it('Verifies if bid request valid', function () { + expect(spec.isBidRequestValid(DISPLAY_BID_REQUEST[0])).to.equal(true); + }); + it('Verifies bid won', function () { + const request = spec.buildRequests(DISPLAY_BID_REQUEST, DEFAULT_OPTIONS); + const response = spec.interpretResponse(DISPLAY_BID_RESPONSE, request); + const won = spec.onBidWon(response[0]); + expect(won).to.equal(true); + }); + it('Verifies user sync without cookie in bid response', function () { + var syncs = spec.getUserSyncs({}, [DISPLAY_BID_RESPONSE], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + }); + it('Verifies user sync with cookies in bid response', function () { + DISPLAY_BID_RESPONSE.body.cookies = [{'type': 'image', 'url': 'http://www.cookie.sync.org/'}]; + var syncs = spec.getUserSyncs({}, [DISPLAY_BID_RESPONSE], DEFAULT_OPTIONS.gdprConsent); + expect(syncs).to.have.lengthOf(1); + expect(syncs[0]).to.have.property('type').and.to.equal('image'); + expect(syncs[0]).to.have.property('url').and.to.equal('http://www.cookie.sync.org/'); + }); + it('Verifies user sync with no bid response', function() { + var syncs = spec.getUserSyncs({}, null, DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + }); + it('Verifies user sync with no bid body response', function() { + var syncs = spec.getUserSyncs({}, [], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + var syncs = spec.getUserSyncs({}, [{}], DEFAULT_OPTIONS.gdprConsent, DEFAULT_OPTIONS.uspConsent); + expect(syncs).to.have.lengthOf(0); + }); +}); diff --git a/test/spec/modules/proxistoreBidAdapter_spec.js b/test/spec/modules/proxistoreBidAdapter_spec.js index 084c533b5b5..bcddb9e8b04 100644 --- a/test/spec/modules/proxistoreBidAdapter_spec.js +++ b/test/spec/modules/proxistoreBidAdapter_spec.js @@ -55,9 +55,9 @@ describe('ProxistoreBidAdapter', function () { }); describe('buildRequests', function () { const url = { - cookieBase: 'https://abs.proxistore.com/v3/rtb/prebid/multi', + cookieBase: 'https://api.proxistore.com/v3/rtb/prebid/multi', cookieLess: - 'https://abs.cookieless-proxistore.com/v3/rtb/prebid/multi', + 'https://api.cookieless-proxistore.com/v3/rtb/prebid/multi', }; let request = spec.buildRequests([bid], bidderRequest); @@ -124,8 +124,6 @@ describe('ProxistoreBidAdapter', function () { bid.params['bidFloor'] = 1; let req = spec.buildRequests([bid], bidderRequest); data = JSON.parse(req.data); - // eslint-disable-next-line no-console - console.log(data.bids[0]); expect(data.bids[0].floor).equal(1); bid.getFloor = function () { return { currency: 'USD', floor: 1.0 }; diff --git a/test/spec/modules/pubCircleBidAdapter_spec.js b/test/spec/modules/pubCircleBidAdapter_spec.js new file mode 100644 index 00000000000..8aaa023ee1c --- /dev/null +++ b/test/spec/modules/pubCircleBidAdapter_spec.js @@ -0,0 +1,399 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/pubCircleBidAdapter'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'pubcircle' + +describe('PubCircleBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://ml.pubcircle.ai/pbjs'); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.pubcircle.ai/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0') + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://cs.pubcircle.ai/image?pbjs=1&ccpa_consent=1---&coppa=0') + }); + }); +}); diff --git a/test/spec/modules/pubCommonId_spec.js b/test/spec/modules/pubCommonId_spec.js deleted file mode 100644 index a46ff26c4b8..00000000000 --- a/test/spec/modules/pubCommonId_spec.js +++ /dev/null @@ -1,370 +0,0 @@ -import { - requestBidHook, - getCookie, - setCookie, - setConfig, - isPubcidEnabled, - getExpInterval, - initPubcid, - setStorageItem, - getStorageItem, - removeStorageItem, - getPubcidConfig } from 'modules/pubCommonId.js'; -import { getAdUnits } from 'test/fixtures/fixtures.js'; -import * as auctionModule from 'src/auction.js'; -import { registerBidder } from 'src/adapters/bidderFactory.js'; -import * as utils from 'src/utils.js'; - -let events = require('src/events'); -let constants = require('src/constants.json'); - -var assert = require('chai').assert; -var expect = require('chai').expect; - -const ID_NAME = '_pubcid'; -const EXP = '_exp'; -const TIMEOUT = 2000; - -const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89a-f][0-9a-f]{3}-[0-9a-f]{12}$/; - -function cleanUp() { - window.document.cookie = ID_NAME + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; - localStorage.removeItem(ID_NAME); - localStorage.removeItem(ID_NAME + EXP); -} - -describe('Publisher Common ID', function () { - afterEach(function () { - $$PREBID_GLOBAL$$.requestBids.removeAll(); - }); - describe('Decorate adUnits', function () { - beforeEach(function() { - cleanUp(); - }); - afterEach(function() { - cleanUp(); - }); - - it('Check same cookie', function () { - let adUnits1 = getAdUnits(); - let adUnits2 = getAdUnits(); - let innerAdUnits1; - let innerAdUnits2; - let pubcid; - - expect(getCookie(ID_NAME)).to.be.null; // there should be no cookie initially - expect(localStorage.getItem(ID_NAME)).to.be.null; // there should be no local storage item either - - requestBidHook((config) => { innerAdUnits1 = config.adUnits }, {adUnits: adUnits1}); - pubcid = localStorage.getItem(ID_NAME); // local storage item is created after requestbidHook - - innerAdUnits1.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - expect(bid.crumbs.pubcid).to.equal(pubcid); - }); - }); - - // verify cookie is null - expect(getCookie(ID_NAME)).to.be.null; - - // verify same pubcid is preserved - requestBidHook((config) => { innerAdUnits2 = config.adUnits }, {adUnits: adUnits2}); - assert.deepEqual(innerAdUnits1, innerAdUnits2); - }); - - it('Check different cookies', function () { - let adUnits1 = getAdUnits(); - let adUnits2 = getAdUnits(); - let innerAdUnits1; - let innerAdUnits2; - let pubcid1; - let pubcid2; - - requestBidHook((config) => { innerAdUnits1 = config.adUnits }, {adUnits: adUnits1}); - pubcid1 = localStorage.getItem(ID_NAME); // get first pubcid - removeStorageItem(ID_NAME); // remove storage - - expect(pubcid1).to.not.be.null; - - innerAdUnits1.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - expect(bid.crumbs.pubcid).to.equal(pubcid1); - }); - }); - - requestBidHook((config) => { innerAdUnits2 = config.adUnits }, {adUnits: adUnits2}); - pubcid2 = localStorage.getItem(ID_NAME); // get second pubcid - - innerAdUnits2.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - expect(bid.crumbs.pubcid).to.equal(pubcid2); - }); - }); - - expect(pubcid2).to.not.be.null; - expect(pubcid1).to.not.equal(pubcid2); - }); - - it('Check new cookie', function () { - let adUnits = getAdUnits(); - let innerAdUnits; - let pubcid = utils.generateUUID(); - - setCookie(ID_NAME, pubcid, 600); - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - innerAdUnits.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - expect(bid.crumbs.pubcid).to.equal(pubcid); - }); - }); - }); - - it('Replicate cookie to storage', function() { - let adUnits = getAdUnits(); - let innerAdUnits; - let pubcid = utils.generateUUID(); - - setCookie(ID_NAME, pubcid, 600); - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - expect(getStorageItem(ID_NAME)).to.equal(pubcid); - }); - - it('Does not replicate storage to cookie', function() { - let adUnits = getAdUnits(); - let innerAdUnits; - let pubcid = utils.generateUUID(); - - setStorageItem(ID_NAME, pubcid, 600); - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - expect(getCookie(ID_NAME)).to.be.null; - }); - - it('Cookie only', function() { - setConfig({type: 'cookie'}); - let adUnits = getAdUnits(); - let innerAdUnits; - - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - expect(getCookie(ID_NAME)).to.match(uuidPattern); - expect(getStorageItem(ID_NAME)).to.be.null; - }); - - it('Storage only', function() { - setConfig({type: 'html5'}); - let adUnits = getAdUnits(); - let innerAdUnits; - - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - expect(getCookie(ID_NAME)).to.be.null; - expect(getStorageItem(ID_NAME)).to.match(uuidPattern); - }); - - it('Bad id recovery', function() { - let adUnits = getAdUnits(); - let innerAdUnits; - - setStorageItem(ID_NAME, 'undefined', 600); - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - expect(getStorageItem(ID_NAME)).to.match(uuidPattern); - }); - }); - - describe('Configuration', function () { - beforeEach(() => { - setConfig(); - cleanUp(); - }); - afterEach(() => { - setConfig(); - cleanUp(); - }); - - it('empty config', function () { - // this should work as usual - setConfig({}); - let adUnits = getAdUnits(); - let innerAdUnits; - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - let pubcid = localStorage.getItem(ID_NAME); - innerAdUnits.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - expect(bid.crumbs.pubcid).to.equal(pubcid); - }); - }); - }); - - it('disable', function () { - setConfig({enable: false}); - let adUnits = getAdUnits(); - let unmodified = getAdUnits(); - let innerAdUnits; - expect(isPubcidEnabled()).to.be.false; - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - expect(getCookie(ID_NAME)).to.be.null; - assert.deepEqual(innerAdUnits, unmodified); - setConfig({enable: true}); // reset - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - innerAdUnits.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - }); - }); - }); - - it('change expiration time', function () { - setConfig({expInterval: 100}); - expect(getExpInterval()).to.equal(100); - let adUnits = getAdUnits(); - let innerAdUnits; - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - innerAdUnits.every((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - }); - }); - }); - - it.skip('disable auto create', function() { - setConfig({ - create: false - }); - - const config = getPubcidConfig(); - expect(config.create).to.be.false; - expect(config.typeEnabled).to.equal('html5'); - - let adUnits = getAdUnits(); - let innerAdUnits; - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - const pubcid = localStorage.getItem(ID_NAME); - expect(pubcid).to.be.null; - }); - }); - - describe('Invoking requestBid', function () { - let createAuctionStub; - let adUnits; - let adUnitCodes; - let capturedReqs; - let sampleSpec = { - code: 'sampleBidder', - isBidRequestValid: () => {}, - buildRequest: (reqs) => {}, - interpretResponse: () => {}, - getUserSyncs: () => {} - }; - - beforeEach(function () { - adUnits = [{ - code: 'adUnit-code', - mediaTypes: { - banner: {}, - native: {}, - }, - sizes: [[300, 200], [300, 600]], - bids: [ - {bidder: 'sampleBidder', params: {placementId: 'banner-only-bidder'}} - ] - }]; - adUnitCodes = ['adUnit-code']; - let auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: TIMEOUT}); - createAuctionStub = sinon.stub(auctionModule, 'newAuction'); - createAuctionStub.returns(auction); - initPubcid(); - registerBidder(sampleSpec); - }); - - afterEach(function () { - auctionModule.newAuction.restore(); - }); - - it('test hook', function() { - $$PREBID_GLOBAL$$.requestBids({adUnits}); - adUnits.forEach((unit) => { - unit.bids.forEach((bid) => { - expect(bid).to.have.deep.nested.property('crumbs.pubcid'); - }); - }); - }); - }); - - describe('Storage item functions', () => { - beforeEach(() => { cleanUp(); }); - afterEach(() => { cleanUp(); }); - - it('Test set', () => { - const key = ID_NAME; - const val = 'test-set-value'; - // Set item in localStorage - const now = Date.now(); - setStorageItem(key, val, 100); - // Check both item and expiry time are stored - const expVal = localStorage.getItem(key + EXP); - const storedVal = localStorage.getItem(key); - // Verify expiry - expect(expVal).to.not.be.null; - const expDate = new Date(expVal); - expect((expDate.getTime() - now) / 1000).to.be.closeTo(100 * 60, 5); - // Verify value - expect(storedVal).to.equal(val); - }); - - it('Test get and remove', () => { - const key = ID_NAME; - const val = 'test-get-remove'; - setStorageItem(key, val, 10); - expect(getStorageItem(key)).to.equal(val); - removeStorageItem(key); - expect(getStorageItem(key)).to.be.null; - }); - - it('Test expiry', () => { - const key = ID_NAME; - const val = 'test-expiry'; - setStorageItem(key, val, -1); - expect(localStorage.getItem(key)).to.equal(val); - expect(getStorageItem(key)).to.be.null; - expect(localStorage.getItem(key)).to.be.null; - }); - }); - - describe('event callback', () => { - beforeEach(() => { - setConfig(); - cleanUp(); - sinon.stub(events, 'getEvents').returns([]); - sinon.stub(utils, 'triggerPixel'); - }); - afterEach(() => { - setConfig(); - cleanUp(); - events.getEvents.restore(); - utils.triggerPixel.restore(); - }); - it('auction end trigger', () => { - setConfig({ - pixelUrl: '/any/url' - }); - - let adUnits = getAdUnits(); - let innerAdUnits; - requestBidHook((config) => { innerAdUnits = config.adUnits }, {adUnits}); - - expect(utils.triggerPixel.called).to.be.false; - events.emit(constants.EVENTS.AUCTION_END, {}); - expect(utils.triggerPixel.called).to.be.true; - expect(utils.triggerPixel.getCall(0).args[0]).to.include('/any/url'); - }); - }); -}); diff --git a/test/spec/modules/pubgeniusBidAdapter_spec.js b/test/spec/modules/pubgeniusBidAdapter_spec.js index 4599eb2a6fa..86c8794dc4c 100644 --- a/test/spec/modules/pubgeniusBidAdapter_spec.js +++ b/test/spec/modules/pubgeniusBidAdapter_spec.js @@ -5,6 +5,7 @@ import { config } from 'src/config.js'; import { VIDEO } from 'src/mediaTypes.js'; import { deepClone, parseQueryStringParameters } from 'src/utils.js'; import { server } from 'test/mocks/xhr.js'; +import * as utils from 'src/utils.js'; const { code, @@ -175,7 +176,7 @@ describe('pubGENIUS adapter', () => { method: 'POST', url: 'https://auction.adpearl.io/prebid/auction', data: { - id: 'fake-auction-id', + id: 'fakebidderrequestid', imp: [ { id: 'fakebidid', @@ -239,17 +240,8 @@ describe('pubGENIUS adapter', () => { expect(buildRequests([bidRequest], bidderRequest)).to.deep.equal(expectedRequest); }); - it('should take pageUrl in config over referer in refererInfo', () => { - config.setConfig({ pageUrl: 'http://pageurl.org' }); - bidderRequest.refererInfo.referer = 'http://referer.org'; - expectedRequest.data.site = { page: 'http://pageurl.org' }; - - expect(buildRequests([bidRequest], bidderRequest)).to.deep.equal(expectedRequest); - }); - - it('should use canonical URL over referer in refererInfo', () => { - bidderRequest.refererInfo.canonicalUrl = 'http://pageurl.org'; - bidderRequest.refererInfo.referer = 'http://referer.org'; + it('should use page from refererInfo', () => { + bidderRequest.refererInfo.page = 'http://pageurl.org'; expectedRequest.data.site = { page: 'http://pageurl.org' }; expect(buildRequests([bidRequest], bidderRequest)).to.deep.equal(expectedRequest); diff --git a/test/spec/modules/publinkIdSystem_spec.js b/test/spec/modules/publinkIdSystem_spec.js index 4656afe1585..f35a7453403 100644 --- a/test/spec/modules/publinkIdSystem_spec.js +++ b/test/spec/modules/publinkIdSystem_spec.js @@ -1,11 +1,12 @@ import {publinkIdSubmodule} from 'modules/publinkIdSystem.js'; -import {getStorageManager} from '../../../src/storageManager'; +import {getCoreStorageManager, getStorageManager} from '../../../src/storageManager'; import {server} from 'test/mocks/xhr.js'; import sinon from 'sinon'; import {uspDataHandler} from '../../../src/adapterManager'; import {parseUrl} from '../../../src/utils'; -export const storage = getStorageManager({gvlid: 24}); +const storage = getCoreStorageManager(); + const TEST_COOKIE_VALUE = 'cookievalue'; describe('PublinkIdSystem', () => { describe('decode', () => { @@ -119,7 +120,7 @@ describe('PublinkIdSystem', () => { expect(parsed.search.mpn).to.equal('Prebid.js'); expect(parsed.search.mpv).to.equal('$prebid.version$'); - request.respond(204, {}, JSON.stringify(serverResponse)); + request.respond(204); expect(callbackSpy.called).to.be.false; }); diff --git a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js index c60b08ae972..ad471252f30 100755 --- a/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubmaticAnalyticsAdapter_spec.js @@ -1,11 +1,10 @@ -import pubmaticAnalyticsAdapter from 'modules/pubmaticAnalyticsAdapter.js'; +import pubmaticAnalyticsAdapter, {getMetadata} from 'modules/pubmaticAnalyticsAdapter.js'; import adapterManager from 'src/adapterManager.js'; import CONSTANTS from 'src/constants.json'; -import { config } from 'src/config.js'; -import { - setConfig, - addBidResponseHook, -} from 'modules/currency.js'; +import {config} from 'src/config.js'; +import {setConfig} from 'modules/currency.js'; +import {server} from '../../mocks/xhr.js'; +import 'src/prebid.js'; let events = require('src/events'); let ajax = require('src/ajax'); @@ -23,6 +22,7 @@ const { AUCTION_END, BID_REQUESTED, BID_RESPONSE, + BID_REJECTED, BIDDER_DONE, BID_WON, BID_TIMEOUT, @@ -68,6 +68,14 @@ const BID = { 'hb_size': '640x480', 'hb_source': 'server' }, + 'floorData': { + 'cpmAfterAdjustments': 6.3, + 'enforcements': {'enforceJS': true, 'enforcePBS': false, 'floorDeals': false, 'bidAdjustment': true}, + 'floorCurrency': 'USD', + 'floorRule': 'banner', + 'floorRuleValue': 1.1, + 'floorValue': 1.1 + }, getStatusCode() { return 1; } @@ -100,6 +108,9 @@ const BID2 = Object.assign({}, BID, { } }); +const BID3 = Object.assign({}, BID2, { + rejectionReason: CONSTANTS.REJECTION_REASON.FLOOR_NOT_MET +}) const MOCK = { SET_TARGETING: { [BID.adUnitCode]: BID.adserverTargeting, @@ -149,7 +160,7 @@ const MOCK = { ], 'timeout': 3000, 'refererInfo': { - 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] + 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] } } ], @@ -164,6 +175,8 @@ const MOCK = { 'bids': [ { 'bidder': 'pubmatic', + 'adapterCode': 'pubmatic', + 'bidderCode': 'pubmatic', 'params': { 'publisherId': '1001', 'video': { @@ -181,6 +194,8 @@ const MOCK = { }, { 'bidder': 'pubmatic', + 'adapterCode': 'pubmatic', + 'bidderCode': 'pubmatic', 'params': { 'publisherId': '1001', 'kgpv': 'this-is-a-kgpv' @@ -196,14 +211,25 @@ const MOCK = { 'bidId': '3bd4ebb1c900e2', 'seatBidId': 'aaaa-bbbb-cccc-dddd', 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' + 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', + 'floorData': { + 'fetchStatus': 'success', + 'floorMin': undefined, + 'floorProvider': 'pubmatic', + 'location': 'fetch', + 'modelTimestamp': undefined, + 'modelVersion': 'floorModelTest', + 'modelWeight': undefined, + 'skipRate': 0, + 'skipped': false + } } ], 'auctionStart': 1519149536560, 'timeout': 5000, 'start': 1519149562216, 'refererInfo': { - 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] + 'topmostLocation': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] }, 'gdprConsent': { 'consentString': 'here-goes-gdpr-consent-string', @@ -214,6 +240,9 @@ const MOCK = { BID, BID2 ], + REJECTED_BID: [ + BID3 + ], AUCTION_END: { 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' }, @@ -250,7 +279,6 @@ function getLoggerJsonFromRequest(requestBody) { describe('pubmatic analytics adapter', function () { let sandbox; - let xhr; let requests; let oldScreen; let clock; @@ -259,9 +287,7 @@ describe('pubmatic analytics adapter', function () { setUADefault(); sandbox = sinon.sandbox.create(); - xhr = sandbox.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); + requests = server.requests; sandbox.stub(events, 'getEvents').returns([]); @@ -339,13 +365,17 @@ describe('pubmatic analytics adapter', function () { expect(data.orig).to.equal('www.test.com'); expect(data.tst).to.equal(1519767016); expect(data.tgid).to.equal(15); + expect(data.fmv).to.equal('floorModelTest'); + expect(data.ft).to.equal(1); expect(data.s).to.be.an('array'); expect(data.s.length).to.equal(2); // slot 1 expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].fskp).to.equal(0); expect(data.s[0].sz).to.deep.equal(['640x480']); expect(data.s[0].ps).to.be.an('array'); - expect(data.s[0].ps.length).to.equal(1); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].ps.length).to.equal(1); expect(data.s[0].ps[0].pn).to.equal('pubmatic'); expect(data.s[0].ps[0].bc).to.equal('pubmatic'); expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757'); @@ -356,9 +386,10 @@ describe('pubmatic analytics adapter', function () { expect(data.s[0].ps[0].psz).to.equal('640x480'); expect(data.s[0].ps[0].eg).to.equal(1.23); expect(data.s[0].ps[0].en).to.equal(1.23); - expect(data.s[0].ps[0].di).to.equal(''); + expect(data.s[0].ps[0].di).to.equal('-1'); expect(data.s[0].ps[0].dc).to.equal(''); - expect(data.s[0].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[0].ps[0].l2).to.equal(0); expect(data.s[0].ps[0].ss).to.equal(1); expect(data.s[0].ps[0].t).to.equal(0); @@ -366,8 +397,10 @@ describe('pubmatic analytics adapter', function () { expect(data.s[0].ps[0].af).to.equal('video'); expect(data.s[0].ps[0].ocpm).to.equal(1.23); expect(data.s[0].ps[0].ocry).to.equal('USD'); + expect(data.s[0].ps[0].frv).to.equal(1.1); // slot 2 expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); expect(data.s[1].ps).to.be.an('array'); expect(data.s[1].ps.length).to.equal(1); @@ -385,7 +418,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -393,6 +427,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].af).to.equal('banner'); expect(data.s[1].ps[0].ocpm).to.equal(1.52); expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); // tracker slot1 let firstTracker = requests[0].url; @@ -413,6 +448,101 @@ describe('pubmatic analytics adapter', function () { expect(data.eg).to.equal('1.23'); expect(data.en).to.equal('1.23'); expect(data.piid).to.equal('partnerImpressionID-1'); + expect(data.plt).to.equal('1'); + expect(data.psz).to.equal('640x480'); + expect(data.tgid).to.equal('15'); + expect(data.orig).to.equal('www.test.com'); + expect(data.ss).to.equal('1'); + expect(data.fskp).to.equal('0'); + expect(data.af).to.equal('video'); + }); + + it('Logger: do not log floor fields when prebids floor shows noData in location property', function() { + const BID_REQUESTED_COPY = utils.deepClone(MOCK.BID_REQUESTED); + BID_REQUESTED_COPY['bids'][1]['floorData']['location'] = 'noData'; + + this.timeout(5000) + + sandbox.stub($$PREBID_GLOBAL$$, 'getHighestCpmBids').callsFake((key) => { + return [MOCK.BID_RESPONSE[0], MOCK.BID_RESPONSE[1]] + }); + + config.setConfig({ + testGroupId: 15 + }); + + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, BID_REQUESTED_COPY); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); + events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); + events.emit(BID_WON, MOCK.BID_WON[0]); + events.emit(BID_WON, MOCK.BID_WON[1]); + + clock.tick(2000 + 1000); + expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker + let request = requests[2]; // logger is executed late, trackers execute first + expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999'); + + let data = getLoggerJsonFromRequest(request.requestBody); + + expect(data.pubid).to.equal('9999'); + expect(data.fmv).to.equal(undefined); + + // slot 1 + expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); + + // slot 2 + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].au).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(undefined); + }); + + it('Logger: log floor fields when prebids floor shows setConfig in location property', function() { + const BID_REQUESTED_COPY = utils.deepClone(MOCK.BID_REQUESTED); + BID_REQUESTED_COPY['bids'][1]['floorData']['location'] = 'setConfig'; + + this.timeout(5000) + + sandbox.stub($$PREBID_GLOBAL$$, 'getHighestCpmBids').callsFake((key) => { + return [MOCK.BID_RESPONSE[0], MOCK.BID_RESPONSE[1]] + }); + + config.setConfig({ + testGroupId: 15 + }); + + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, BID_REQUESTED_COPY); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); + events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); + events.emit(BID_WON, MOCK.BID_WON[0]); + events.emit(BID_WON, MOCK.BID_WON[1]); + + clock.tick(2000 + 1000); + expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker + let request = requests[2]; // logger is executed late, trackers execute first + expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999'); + + let data = getLoggerJsonFromRequest(request.requestBody); + + expect(data.pubid).to.equal('9999'); + expect(data.fmv).to.equal('floorModelTest'); + + // slot 1 + expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); + + // slot 2 + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].au).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); }); it('bidCpmAdjustment: USD: Logger: best case + win tracker', function() { @@ -442,13 +572,17 @@ describe('pubmatic analytics adapter', function () { let data = getLoggerJsonFromRequest(request.requestBody); expect(data.pubid).to.equal('9999'); expect(data.pid).to.equal('1111'); + expect(data.fmv).to.equal('floorModelTest'); + expect(data.ft).to.equal(1); expect(data.s).to.be.an('array'); expect(data.s.length).to.equal(2); expect(data.tgid).to.equal(0); // slot 1 expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].fskp).to.equal(0); expect(data.s[0].sz).to.deep.equal(['640x480']); expect(data.s[0].ps).to.be.an('array'); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); expect(data.s[0].ps.length).to.equal(1); expect(data.s[0].ps[0].pn).to.equal('pubmatic'); expect(data.s[0].ps[0].bc).to.equal('pubmatic'); @@ -460,6 +594,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[0].ps[0].af).to.equal('video'); expect(data.s[0].ps[0].ocpm).to.equal(1.23); expect(data.s[0].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); // tracker slot1 let firstTracker = requests[0].url; expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt'); @@ -511,6 +646,8 @@ describe('pubmatic analytics adapter', function () { expect(data.pubid).to.equal('9999'); expect(data.pid).to.equal('1111'); expect(data.tgid).to.equal(0);// test group id should be between 0-15 else set to 0 + expect(data.fmv).to.equal('floorModelTest'); + expect(data.ft).to.equal(1); expect(data.s).to.be.an('array'); expect(data.s.length).to.equal(2); // slot 1 @@ -518,6 +655,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[0].sz).to.deep.equal(['640x480']); expect(data.s[0].ps).to.be.an('array'); expect(data.s[0].ps.length).to.equal(1); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); expect(data.s[0].ps[0].pn).to.equal('pubmatic'); expect(data.s[0].ps[0].bc).to.equal('pubmatic'); expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757'); @@ -559,6 +697,7 @@ describe('pubmatic analytics adapter', function () { let data = getLoggerJsonFromRequest(request.requestBody); expect(data.tgid).to.equal(0);// test group id should be an INT between 0-15 else set to 0 expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); expect(data.s[1].ps).to.be.an('array'); expect(data.s[1].ps.length).to.equal(1); @@ -571,7 +710,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].psz).to.equal('0x0'); expect(data.s[1].ps[0].eg).to.equal(0); expect(data.s[1].ps[0].en).to.equal(0); - expect(data.s[1].ps[0].di).to.equal(''); + expect(data.s[1].ps[0].di).to.equal('-1'); expect(data.s[1].ps[0].dc).to.equal(''); expect(data.s[1].ps[0].mi).to.equal(undefined); expect(data.s[1].ps[0].l1).to.equal(0); @@ -582,6 +721,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].af).to.equal(undefined); expect(data.s[1].ps[0].ocpm).to.equal(0); expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(undefined); }); it('Logger: post-timeout check without bid response', function() { @@ -608,7 +748,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].psz).to.equal('0x0'); expect(data.s[1].ps[0].eg).to.equal(0); expect(data.s[1].ps[0].en).to.equal(0); - expect(data.s[1].ps[0].di).to.equal(''); + expect(data.s[1].ps[0].di).to.equal('-1'); expect(data.s[1].ps[0].dc).to.equal(''); expect(data.s[1].ps[0].mi).to.equal(undefined); expect(data.s[1].ps[0].l1).to.equal(0); @@ -639,6 +779,7 @@ describe('pubmatic analytics adapter', function () { let request = requests[0]; let data = getLoggerJsonFromRequest(request.requestBody); expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); expect(data.s[1].ps).to.be.an('array'); expect(data.s[1].ps.length).to.equal(1); @@ -655,7 +796,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(0); + expect(data.s[0].ps[0].ol1).to.equal(0); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(1); @@ -663,6 +805,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].af).to.equal('banner'); expect(data.s[1].ps[0].ocpm).to.equal(1.52); expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); }); it('Logger: currency conversion check', function() { @@ -713,7 +856,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -744,6 +888,7 @@ describe('pubmatic analytics adapter', function () { expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999'); let data = getLoggerJsonFromRequest(request.requestBody); expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); expect(data.s[1].ps).to.be.an('array'); expect(data.s[1].ps.length).to.equal(1); @@ -760,7 +905,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -768,6 +914,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].af).to.equal('banner'); expect(data.s[1].ps[0].ocpm).to.equal(1.52); expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); expect(data.dvc).to.deep.equal({'plt': 2}); // respective tracker slot let firstTracker = requests[1].url; @@ -816,7 +963,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -825,6 +973,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].ocpm).to.equal(1.52); expect(data.s[1].ps[0].ocry).to.equal('USD'); expect(data.dvc).to.deep.equal({'plt': 1}); + expect(data.s[1].ps[0].frv).to.equal(1.1); // respective tracker slot let firstTracker = requests[1].url; expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt'); @@ -852,6 +1001,7 @@ describe('pubmatic analytics adapter', function () { expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999'); let data = getLoggerJsonFromRequest(request.requestBody); expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); expect(data.s[1].ps).to.be.an('array'); expect(data.s[1].ps.length).to.equal(1); @@ -868,7 +1018,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -876,6 +1027,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].af).to.equal('banner'); expect(data.s[1].ps[0].ocpm).to.equal(1.52); expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); // respective tracker slot let firstTracker = requests[1].url; expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt'); @@ -922,7 +1074,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -938,8 +1091,64 @@ describe('pubmatic analytics adapter', function () { expect(data.kgpv).to.equal('*'); }); + it('Logger: to handle floor rejected bids', function() { + this.timeout(5000) + + sandbox.stub($$PREBID_GLOBAL$$, 'getHighestCpmBids').callsFake((key) => { + return [MOCK.BID_RESPONSE[0], MOCK.BID_RESPONSE[1]] + }); + + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); + events.emit(BID_REJECTED, MOCK.REJECTED_BID[0]); + events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); + events.emit(BID_WON, MOCK.BID_WON[0]); + + clock.tick(2000 + 1000); + expect(requests.length).to.equal(2); // 1 logger and 1 win-tracker + let request = requests[1]; // logger is executed late, trackers execute first + expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999'); + let data = getLoggerJsonFromRequest(request.requestBody); + + // slot 2 + // Testing only for rejected bid as other scenarios will be covered under other TCs + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[0].ps[0].bc).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].piid).to.equal('partnerImpressionID-2'); + expect(data.s[1].ps[0].db).to.equal(0); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('728x90'); + expect(data.s[1].ps[0].eg).to.equal(1.52); + expect(data.s[1].ps[0].en).to.equal(0); // Net CPM is market as 0 due to bid rejection + expect(data.s[1].ps[0].di).to.equal('the-deal-id'); + expect(data.s[1].ps[0].dc).to.equal('PMP'); + expect(data.s[1].ps[0].mi).to.equal('matched-impression'); + expect(data.s[1].ps[0].adv).to.equal('example.com'); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(0); + expect(data.s[1].ps[0].wb).to.equal(1); + expect(data.s[1].ps[0].af).to.equal('banner'); + expect(data.s[1].ps[0].ocpm).to.equal(1.52); + expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); + }); + it('Logger: best case + win tracker in case of Bidder Aliases', function() { MOCK.BID_REQUESTED['bids'][0]['bidder'] = 'pubmatic_alias'; + MOCK.BID_REQUESTED['bids'][0]['bidderCode'] = 'pubmatic_alias'; adapterManager.aliasRegistry['pubmatic_alias'] = 'pubmatic'; sandbox.stub($$PREBID_GLOBAL$$, 'getHighestCpmBids').callsFake((key) => { @@ -974,13 +1183,17 @@ describe('pubmatic analytics adapter', function () { expect(data.orig).to.equal('www.test.com'); expect(data.tst).to.equal(1519767016); expect(data.tgid).to.equal(15); + expect(data.fmv).to.equal('floorModelTest'); + expect(data.ft).to.equal(1); expect(data.s).to.be.an('array'); expect(data.s.length).to.equal(2); // slot 1 expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].fskp).to.equal(0); expect(data.s[0].sz).to.deep.equal(['640x480']); expect(data.s[0].ps).to.be.an('array'); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); expect(data.s[0].ps.length).to.equal(1); expect(data.s[0].ps[0].pn).to.equal('pubmatic'); expect(data.s[0].ps[0].bc).to.equal('pubmatic_alias'); @@ -992,9 +1205,10 @@ describe('pubmatic analytics adapter', function () { expect(data.s[0].ps[0].psz).to.equal('640x480'); expect(data.s[0].ps[0].eg).to.equal(1.23); expect(data.s[0].ps[0].en).to.equal(1.23); - expect(data.s[0].ps[0].di).to.equal(''); + expect(data.s[0].ps[0].di).to.equal('-1'); expect(data.s[0].ps[0].dc).to.equal(''); - expect(data.s[0].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[0].ps[0].l2).to.equal(0); expect(data.s[0].ps[0].ss).to.equal(0); expect(data.s[0].ps[0].t).to.equal(0); @@ -1002,9 +1216,11 @@ describe('pubmatic analytics adapter', function () { expect(data.s[0].ps[0].af).to.equal('video'); expect(data.s[0].ps[0].ocpm).to.equal(1.23); expect(data.s[0].ps[0].ocry).to.equal('USD'); + expect(data.s[0].ps[0].frv).to.equal(1.1); // slot 2 expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].fskp).to.equal(0); expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); expect(data.s[1].ps).to.be.an('array'); expect(data.s[1].ps.length).to.equal(1); @@ -1022,7 +1238,8 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].dc).to.equal('PMP'); expect(data.s[1].ps[0].mi).to.equal('matched-impression'); expect(data.s[1].ps[0].adv).to.equal('example.com'); - expect(data.s[1].ps[0].l1).to.equal(3214); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); expect(data.s[1].ps[0].l2).to.equal(0); expect(data.s[1].ps[0].ss).to.equal(1); expect(data.s[1].ps[0].t).to.equal(0); @@ -1030,6 +1247,7 @@ describe('pubmatic analytics adapter', function () { expect(data.s[1].ps[0].af).to.equal('banner'); expect(data.s[1].ps[0].ocpm).to.equal(1.52); expect(data.s[1].ps[0].ocry).to.equal('USD'); + expect(data.s[1].ps[0].frv).to.equal(1.1); // tracker slot1 let firstTracker = requests[0].url; @@ -1051,5 +1269,179 @@ describe('pubmatic analytics adapter', function () { expect(data.en).to.equal('1.23'); expect(data.piid).to.equal('partnerImpressionID-1'); }); + + it('Logger: best case + win tracker in case of GroupM as alternate bidder', function() { + MOCK.BID_REQUESTED['bids'][0]['bidderCode'] = 'groupm'; + sandbox.stub($$PREBID_GLOBAL$$, 'getHighestCpmBids').callsFake((key) => { + return [MOCK.BID_RESPONSE[0], MOCK.BID_RESPONSE[1]] + }); + + config.setConfig({ + testGroupId: 15 + }); + + events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); + events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); + events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); + events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); + events.emit(AUCTION_END, MOCK.AUCTION_END); + events.emit(SET_TARGETING, MOCK.SET_TARGETING); + events.emit(BID_WON, MOCK.BID_WON[0]); + events.emit(BID_WON, MOCK.BID_WON[1]); + + clock.tick(2000 + 1000); + expect(requests.length).to.equal(3); // 1 logger and 2 win-tracker + let request = requests[2]; // logger is executed late, trackers execute first + expect(request.url).to.equal('https://t.pubmatic.com/wl?pubid=9999'); + let data = getLoggerJsonFromRequest(request.requestBody); + expect(data.pubid).to.equal('9999'); + expect(data.pid).to.equal('1111'); + expect(data.pdvid).to.equal('20'); + expect(data.iid).to.equal('25c6d7f5-699a-4bfc-87c9-996f915341fa'); + expect(data.to).to.equal('3000'); + expect(data.purl).to.equal('http://www.test.com/page.html'); + expect(data.orig).to.equal('www.test.com'); + expect(data.tst).to.equal(1519767016); + expect(data.tgid).to.equal(15); + expect(data.fmv).to.equal('floorModelTest'); + expect(data.ft).to.equal(1); + expect(data.s).to.be.an('array'); + expect(data.s.length).to.equal(2); + + // slot 1 + expect(data.s[0].sn).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].fskp).to.equal(0); + expect(data.s[0].sz).to.deep.equal(['640x480']); + expect(data.s[0].ps).to.be.an('array'); + expect(data.s[0].au).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].ps.length).to.equal(1); + expect(data.s[0].ps[0].pn).to.equal('pubmatic'); + expect(data.s[0].ps[0].bc).to.equal('groupm'); + expect(data.s[0].ps[0].bidid).to.equal('2ecff0db240757'); + expect(data.s[0].ps[0].piid).to.equal('partnerImpressionID-1'); + expect(data.s[0].ps[0].db).to.equal(0); + expect(data.s[0].ps[0].kgpv).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].ps[0].kgpsv).to.equal('/19968336/header-bid-tag-0'); + expect(data.s[0].ps[0].psz).to.equal('640x480'); + expect(data.s[0].ps[0].eg).to.equal(1.23); + expect(data.s[0].ps[0].en).to.equal(1.23); + expect(data.s[0].ps[0].di).to.equal('-1'); + expect(data.s[0].ps[0].dc).to.equal(''); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); + expect(data.s[0].ps[0].l2).to.equal(0); + expect(data.s[0].ps[0].ss).to.equal(0); + expect(data.s[0].ps[0].t).to.equal(0); + expect(data.s[0].ps[0].wb).to.equal(1); + expect(data.s[0].ps[0].af).to.equal('video'); + expect(data.s[0].ps[0].ocpm).to.equal(1.23); + expect(data.s[0].ps[0].ocry).to.equal('USD'); + expect(data.s[0].ps[0].frv).to.equal(1.1); + + // slot 2 + expect(data.s[1].sn).to.equal('/19968336/header-bid-tag-1'); + expect(data.s[1].sz).to.deep.equal(['1000x300', '970x250', '728x90']); + expect(data.s[1].ps).to.be.an('array'); + expect(data.s[1].ps.length).to.equal(1); + expect(data.s[1].ps[0].pn).to.equal('pubmatic'); + expect(data.s[1].ps[0].bc).to.equal('pubmatic'); + expect(data.s[1].ps[0].bidid).to.equal('3bd4ebb1c900e2'); + expect(data.s[1].ps[0].piid).to.equal('partnerImpressionID-2'); + expect(data.s[1].ps[0].db).to.equal(0); + expect(data.s[1].ps[0].kgpv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].kgpsv).to.equal('this-is-a-kgpv'); + expect(data.s[1].ps[0].psz).to.equal('728x90'); + expect(data.s[1].ps[0].eg).to.equal(1.52); + expect(data.s[1].ps[0].en).to.equal(1.52); + expect(data.s[1].ps[0].di).to.equal('the-deal-id'); + expect(data.s[1].ps[0].dc).to.equal('PMP'); + expect(data.s[1].ps[0].mi).to.equal('matched-impression'); + expect(data.s[1].ps[0].adv).to.equal('example.com'); + expect(data.s[0].ps[0].l1).to.equal(944); + expect(data.s[0].ps[0].ol1).to.equal(3214); + expect(data.s[1].ps[0].l2).to.equal(0); + expect(data.s[1].ps[0].ss).to.equal(1); + expect(data.s[1].ps[0].t).to.equal(0); + expect(data.s[1].ps[0].wb).to.equal(1); + expect(data.s[1].ps[0].af).to.equal('banner'); + expect(data.s[1].ps[0].ocpm).to.equal(1.52); + expect(data.s[1].ps[0].ocry).to.equal('USD'); + + // tracker slot1 + let firstTracker = requests[0].url; + expect(firstTracker.split('?')[0]).to.equal('https://t.pubmatic.com/wt'); + data = {}; + firstTracker.split('?')[1].split('&').map(e => e.split('=')).forEach(e => data[e[0]] = e[1]); + expect(data.pubid).to.equal('9999'); + expect(decodeURIComponent(data.purl)).to.equal('http://www.test.com/page.html'); + expect(data.tst).to.equal('1519767014'); + expect(data.iid).to.equal('25c6d7f5-699a-4bfc-87c9-996f915341fa'); + expect(data.bidid).to.equal('2ecff0db240757'); + expect(data.pid).to.equal('1111'); + expect(data.pdvid).to.equal('20'); + expect(decodeURIComponent(data.slot)).to.equal('/19968336/header-bid-tag-0'); + expect(decodeURIComponent(data.kgpv)).to.equal('/19968336/header-bid-tag-0'); + expect(data.pn).to.equal('pubmatic'); + expect(data.bc).to.equal('groupm'); + expect(data.eg).to.equal('1.23'); + expect(data.en).to.equal('1.23'); + expect(data.piid).to.equal('partnerImpressionID-1'); + }); + }); + + describe('Get Metadata function', function () { + it('should get the metadata object', function () { + const meta = { + networkId: 'nwid', + advertiserId: 'adid', + networkName: 'nwnm', + primaryCatId: 'pcid', + advertiserName: 'adnm', + agencyId: 'agid', + agencyName: 'agnm', + brandId: 'brid', + brandName: 'brnm', + dchain: 'dc', + demandSource: 'ds', + secondaryCatIds: ['secondaryCatIds'] + }; + const metadataObj = getMetadata(meta); + + expect(metadataObj.nwid).to.equal('nwid'); + expect(metadataObj.adid).to.equal('adid'); + expect(metadataObj.nwnm).to.equal('nwnm'); + expect(metadataObj.pcid).to.equal('pcid'); + expect(metadataObj.adnm).to.equal('adnm'); + expect(metadataObj.agid).to.equal('agid'); + expect(metadataObj.agnm).to.equal('agnm'); + expect(metadataObj.brid).to.equal('brid'); + expect(metadataObj.brnm).to.equal('brnm'); + expect(metadataObj.dc).to.equal('dc'); + expect(metadataObj.ds).to.equal('ds'); + expect(metadataObj.scids).to.be.an('array').with.length.above(0); + expect(metadataObj.scids[0]).to.equal('secondaryCatIds'); + }); + + it('should return undefined if meta is null', function () { + const meta = null; + const metadataObj = getMetadata(meta); + expect(metadataObj).to.equal(undefined); + }); + + it('should return undefined if meta is a empty object', function () { + const meta = {}; + const metadataObj = getMetadata(meta); + expect(metadataObj).to.equal(undefined); + }); + + it('should return undefined if meta object has different properties', function () { + const meta = { + a: 123, + b: 456 + }; + const metadataObj = getMetadata(meta); + expect(metadataObj).to.equal(undefined); + }); }); }); diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index 64e95460321..066004bd954 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -1,8 +1,9 @@ -import {expect} from 'chai'; -import {spec, checkVideoPlacement} from 'modules/pubmaticBidAdapter.js'; +import { expect } from 'chai'; +import { spec, checkVideoPlacement, _getDomainFromURL, assignDealTier, prepareMetaObject } from 'modules/pubmaticBidAdapter.js'; import * as utils from 'src/utils.js'; -import {config} from 'src/config.js'; +import { config } from 'src/config.js'; import { createEidsArray } from 'modules/userId/eids.js'; +import { bidderSettings } from 'src/bidderSettings.js'; const constants = require('src/constants.json'); describe('PubMatic adapter', function () { @@ -78,7 +79,11 @@ describe('PubMatic adapter', function () { bidId: '23acc48ad47af5', requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + ortb2Imp: { + ext: { + tid: '92489f71-1bf2-49a0-adf9-000cea934729', + } + }, schain: schainConfig } ]; @@ -110,6 +115,7 @@ describe('PubMatic adapter', function () { battr: [13, 14], linearity: 1, placement: 2, + plcmt: 1, minbitrate: 10, maxbitrate: 10 } @@ -161,6 +167,7 @@ describe('PubMatic adapter', function () { battr: [13, 14], linearity: 1, placement: 2, + plcmt: 1, minbitrate: 100, maxbitrate: 4096 } @@ -193,6 +200,14 @@ describe('PubMatic adapter', function () { image: { required: true, sizes: [300, 250] }, sponsoredBy: { required: true } }, + nativeOrtbRequest: { + ver: '1.2', + assets: [ + { id: 0, required: 1, title: {len: 140} }, + { id: 1, required: 1, img: { type: 3, w: 300, h: 250 } }, + { id: 2, required: 1, data: { type: 1 } } + ] + }, bidder: 'pubmatic', params: { publisherId: '5670', @@ -242,6 +257,22 @@ describe('PubMatic adapter', function () { desc2: {required: true, len: 10, ext: {'desc21': 'desc22'}}, displayurl: {required: true, len: 10, ext: {'displayurl1': 'displayurl2'}} }, + nativeOrtbRequest: { + 'ver': '1.2', + 'assets': [ + {'id': 0, 'required': 1, 'title': {'len': 80}}, + {'id': 1, 'required': 1, 'img': {'type': 1, 'w': 50, 'h': 50}}, + {'id': 2, 'required': 1, 'img': {'type': 3, 'w': 728, 'h': 90}}, + {'id': 3, 'required': 1, 'data': {'type': 1, 'len': 10}}, + {'id': 4, 'required': 1, 'data': {'type': 2, 'len': 10}}, + {'id': 5, 'required': 1, 'data': {'type': 3, 'len': 10}}, + {'id': 6, 'required': 1, 'data': {'type': 4, 'len': 10}}, + {'id': 7, 'required': 1, 'data': {'type': 5, 'len': 10}}, + {'id': 8, 'required': 1, 'data': {'type': 6, 'len': 10}}, + {'id': 9, 'required': 1, 'data': {'type': 8, 'len': 10}}, + {'id': 10, 'required': 1, 'data': {'type': 9, 'len': 10}} + ] + }, bidder: 'pubmatic', params: { publisherId: '5670', @@ -300,6 +331,14 @@ describe('PubMatic adapter', function () { image: { required: false, sizes: [300, 250] }, sponsoredBy: { required: true } }, + nativeOrtbRequest: { + ver: '1.2', + assets: [ + { id: 0, required: 0, title: {len: 140} }, + { id: 1, required: 0, img: {type: 3, w: 300, h: 250} }, + { id: 2, required: 1, data: {type: 1} } + ] + }, bidder: 'pubmatic', params: { publisherId: '5670', @@ -349,6 +388,7 @@ describe('PubMatic adapter', function () { battr: [13, 14], linearity: 1, placement: 2, + plcmt: 1, minbitrate: 100, maxbitrate: 4096 } @@ -388,6 +428,14 @@ describe('PubMatic adapter', function () { image: { required: true, sizes: [300, 250] }, sponsoredBy: { required: true } }, + nativeOrtbRequest: { + ver: '1.2', + assets: [ + {id: 0, required: 1, title: {len: 140}}, + {id: 1, required: 1, img: {type: 3, w: 300, h: 250}}, + {id: 2, required: 1, data: {type: 1}} + ] + }, bidder: 'pubmatic', params: { publisherId: '301', @@ -441,6 +489,14 @@ describe('PubMatic adapter', function () { image: { required: true, sizes: [300, 250] }, sponsoredBy: { required: true } }, + nativeOrtbRequest: { + ver: '1.2', + assets: [ + { id: 0, required: 1, title: {len: 140} }, + { id: 1, required: 1, img: { type: 3, w: 300, h: 250 } }, + { id: 2, required: 1, data: { type: 1 } } + ] + }, bidder: 'pubmatic', params: { publisherId: '301', @@ -459,6 +515,7 @@ describe('PubMatic adapter', function () { battr: [13, 14], linearity: 1, placement: 2, + plcmt: 1, minbitrate: 100, maxbitrate: 4096 } @@ -502,6 +559,14 @@ describe('PubMatic adapter', function () { image: { required: true, sizes: [300, 250] }, sponsoredBy: { required: true } }, + nativeOrtbRequest: { + ver: '1.2', + assets: [ + { id: 0, required: 1, title: {len: 80} }, + { id: 1, required: 1, img: { type: 3, w: 300, h: 250 } }, + { id: 2, required: 1, data: { type: 1 } } + ] + }, bidder: 'pubmatic', params: { publisherId: '301', @@ -520,6 +585,7 @@ describe('PubMatic adapter', function () { battr: [13, 14], linearity: 1, placement: 2, + plcmt: 1, minbitrate: 100, maxbitrate: 4096 } @@ -552,7 +618,8 @@ describe('PubMatic adapter', function () { 'ext': { 'deal_channel': 6, 'advid': 976, - 'dspid': 123 + 'dspid': 123, + 'dchain': 'dchain' } }] }, { @@ -601,7 +668,7 @@ describe('PubMatic adapter', function () { validnativeBidImpression = { 'native': { - 'request': '{"assets":[{"id":1,"required":1,"title":{"len":80}},{"id":2,"required":1,"img":{"type":3,"w":300,"h":250}},{"id":4,"required":1,"data":{"type":1}}]}' + 'request': '{"ver":"1.2","assets":[{"id":0,"required":1,"title":{"len":80}},{"id":1,"required":1,"img":{"type":3,"w":300,"h":250}},{"id":2,"required":1,"data":{"type":1}}]}' } } @@ -613,13 +680,13 @@ describe('PubMatic adapter', function () { validnativeBidImpressionWithRequiredParam = { 'native': { - 'request': '{"assets":[{"id":1,"required":0,"title":{"len":80}},{"id":2,"required":0,"img":{"type":3,"w":300,"h":250}},{"id":4,"required":1,"data":{"type":1}}]}' + 'request': '{"ver":"1.2","assets":[{"id":0,"required":0,"title":{"len":80}},{"id":1,"required":0,"img":{"type":3,"w":300,"h":250}},{"id":2,"required":1,"data":{"type":1}}]}' } } validnativeBidImpressionWithAllParams = { native: { - 'request': '{"assets":[{"id":1,"required":1,"title":{"len":80,"ext":{"title1":"title2"}}},{"id":3,"required":1,"img":{"type":1,"w":50,"h":50}},{"id":2,"required":1,"img":{"type":3,"w":728,"h":90,"mimes":["image/png","image/gif"],"ext":{"image1":"image2"}}},{"id":4,"required":1,"data":{"type":1,"len":10,"ext":{"sponsor1":"sponsor2"}}},{"id":5,"required":1,"data":{"type":2,"len":10,"ext":{"body1":"body2"}}},{"id":13,"required":1,"data":{"type":3,"len":10,"ext":{"rating1":"rating2"}}},{"id":14,"required":1,"data":{"type":4,"len":10,"ext":{"likes1":"likes2"}}},{"id":15,"required":1,"data":{"type":5,"len":10,"ext":{"downloads1":"downloads2"}}},{"id":16,"required":1,"data":{"type":6,"len":10,"ext":{"price1":"price2"}}},{"id":17,"required":1,"data":{"type":7,"len":10,"ext":{"saleprice1":"saleprice2"}}},{"id":18,"required":1,"data":{"type":8,"len":10,"ext":{"phone1":"phone2"}}},{"id":19,"required":1,"data":{"type":9,"len":10,"ext":{"address1":"address2"}}},{"id":20,"required":1,"data":{"type":10,"len":10,"ext":{"desc21":"desc22"}}},{"id":21,"required":1,"data":{"type":11,"len":10,"ext":{"displayurl1":"displayurl2"}}}]}' + 'request': '{"ver":"1.2","assets":[{"id":0,"required":1,"title":{"len":80,"ext":{"title1":"title2"}}},{"id":1,"required":1,"img":{"type":1,"w":50,"h":50,"ext":{"icon1":"icon2"}}},{"id":2,"required":1,"img":{"type":3,"w":728,"h":90,"ext":{"image1":"image2"},"mimes":["image/png","image/gif"]}},{"id":3,"required":1,"data":{"type":1,"len":10,"ext":{"sponsor1":"sponsor2"}}},{"id":4,"required":1,"data":{"type":2,"len":10,"ext":{"body1":"body2"}}},{"id":5,"required":1,"data":{"type":3,"len":10,"ext":{"rating1":"rating2"}}},{"id":6,"required":1,"data":{"type":4,"len":10,"ext":{"likes1":"likes2"}}},{"id":7,"required":1,"data":{"type":5,"len":10,"ext":{"downloads1":"downloads2"}}},{"id":8,"required":1,"data":{"type":6,"len":10,"ext":{"price1":"price2"}}},{"id":9,"required":1,"data":{"type":7,"len":10,"ext":{"saleprice1":"saleprice2"}}},{"id":10,"required":1,"data":{"type":8,"len":10,"ext":{"phone1":"phone2"}}},{"id":11,"required":1,"data":{"type":9,"len":10,"ext":{"address1":"address2"}}},{"id":12,"required":1,"data":{"type":10,"len":10,"ext":{"desc21":"desc22"}}},{"id":13,"required":1,"data":{"type":11,"len":10,"ext":{"displayurl1":"displayurl2"}}}]}' } } @@ -792,12 +859,86 @@ describe('PubMatic adapter', function () { expect(isValid).to.equal(true); }); - it('should check for context if video is present', function() { - let bid = { + if (FEATURES.VIDEO) { + it('should check for context if video is present', function() { + let bid = { + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890' + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(true); + }) + + it('should return false if context is not present in video', function() { + let bid = { + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890' + }, + 'mediaTypes': { + 'video': { + 'w': 640, + 'h': 480, + 'protocols': [1, 2, 5], + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }, + isValid = spec.isBidRequestValid(bid); + expect(isValid).to.equal(false); + }) + + it('bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array', function() { + let bid = { 'bidder': 'pubmatic', 'params': { 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890' + 'publisherId': '5890', + 'video': {} }, 'mediaTypes': { 'video': { @@ -806,42 +947,6 @@ describe('PubMatic adapter', function () { ], 'protocols': [1, 2, 5], 'context': 'instream', - 'mimes': ['video/flv'], - 'skippable': false, - 'skip': 1, - 'linearity': 2 - } - }, - 'adUnitCode': 'video1', - 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', - 'sizes': [ - [640, 480] - ], - 'bidId': '2c95df014cfe97', - 'bidderRequestId': '1fe59391566442', - 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }, - isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(true); - }) - - it('should return false if context is not present in video', function() { - let bid = { - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890' - }, - 'mediaTypes': { - 'video': { - 'w': 640, - 'h': 480, - 'protocols': [1, 2, 5], - 'mimes': ['video/flv'], 'skippable': false, 'skip': 1, 'linearity': 2 @@ -859,160 +964,124 @@ describe('PubMatic adapter', function () { 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0 - }, - isValid = spec.isBidRequestValid(bid); - expect(isValid).to.equal(false); - }) - - it('bid.mediaTypes.video.mimes OR bid.params.video.mimes should be present and must be a non-empty array', function() { - let bid = { - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890', - 'video': {} - }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'skippable': false, - 'skip': 1, - 'linearity': 2 - } - }, - 'adUnitCode': 'video1', - 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', - 'sizes': [ - [640, 480] - ], - 'bidId': '2c95df014cfe97', - 'bidderRequestId': '1fe59391566442', - 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }; + }; - delete bid.params.video.mimes; // Undefined - bid.mediaTypes.video.mimes = 'string'; // NOT array - expect(spec.isBidRequestValid(bid)).to.equal(false); + delete bid.params.video.mimes; // Undefined + bid.mediaTypes.video.mimes = 'string'; // NOT array + expect(spec.isBidRequestValid(bid)).to.equal(false); - delete bid.params.video.mimes; // Undefined - delete bid.mediaTypes.video.mimes; // Undefined - expect(spec.isBidRequestValid(bid)).to.equal(false); + delete bid.params.video.mimes; // Undefined + delete bid.mediaTypes.video.mimes; // Undefined + expect(spec.isBidRequestValid(bid)).to.equal(false); - delete bid.params.video.mimes; // Undefined - bid.mediaTypes.video.mimes = ['video/flv']; // Valid - expect(spec.isBidRequestValid(bid)).to.equal(true); + delete bid.params.video.mimes; // Undefined + bid.mediaTypes.video.mimes = ['video/flv']; // Valid + expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined - bid.params.video = {mimes: 'string'}; // NOT array - expect(spec.isBidRequestValid(bid)).to.equal(false); + delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined + bid.params.video = {mimes: 'string'}; // NOT array + expect(spec.isBidRequestValid(bid)).to.equal(false); - delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined - delete bid.params.video.mimes; // Undefined - expect(spec.isBidRequestValid(bid)).to.equal(false); + delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined + delete bid.params.video.mimes; // Undefined + expect(spec.isBidRequestValid(bid)).to.equal(false); - delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined - bid.params.video.mimes = ['video/flv']; // Valid - expect(spec.isBidRequestValid(bid)).to.equal(true); + delete bid.mediaTypes.video.mimes; // mediaTypes.video.mimes undefined + bid.params.video.mimes = ['video/flv']; // Valid + expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.mediaTypes.video.mimes; // Undefined - bid.params.video.mimes = ['video/flv']; // Valid - expect(spec.isBidRequestValid(bid)).to.equal(true); + delete bid.mediaTypes.video.mimes; // Undefined + bid.params.video.mimes = ['video/flv']; // Valid + expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.mediaTypes.video.mimes; // Undefined - delete bid.params.video.mimes; // Undefined - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); + delete bid.mediaTypes.video.mimes; // Undefined + delete bid.params.video.mimes; // Undefined + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); - it('checks on bid.params.outstreamAU & bid.renderer & bid.mediaTypes.video.renderer', function() { - const getThebid = function() { - let bid = utils.deepClone(validOutstreamBidRequest.bids[0]); - bid.params.outstreamAU = 'pubmatic-test'; - bid.renderer = ' '; // we are only checking if this key is set or not - bid.mediaTypes.video.renderer = ' '; // we are only checking if this key is set or not - return bid; - } + it('checks on bid.params.outstreamAU & bid.renderer & bid.mediaTypes.video.renderer', function() { + const getThebid = function() { + let bid = utils.deepClone(validOutstreamBidRequest.bids[0]); + bid.params.outstreamAU = 'pubmatic-test'; + bid.renderer = ' '; // we are only checking if this key is set or not + bid.mediaTypes.video.renderer = ' '; // we are only checking if this key is set or not + return bid; + } - // true: when all are present - // mdiatype: outstream - // bid.params.outstreamAU : Y - // bid.renderer : Y - // bid.mediaTypes.video.renderer : Y - let bid = getThebid(); - expect(spec.isBidRequestValid(bid)).to.equal(true); - - // true: atleast one is present; 3 cases - // mdiatype: outstream - // bid.params.outstreamAU : Y - // bid.renderer : N - // bid.mediaTypes.video.renderer : N - bid = getThebid(); - delete bid.renderer; - delete bid.mediaTypes.video.renderer; - expect(spec.isBidRequestValid(bid)).to.equal(true); - - // true: atleast one is present; 3 cases - // mdiatype: outstream - // bid.params.outstreamAU : N - // bid.renderer : Y - // bid.mediaTypes.video.renderer : N - bid = getThebid(); - delete bid.params.outstreamAU; - delete bid.mediaTypes.video.renderer; - expect(spec.isBidRequestValid(bid)).to.equal(true); - - // true: atleast one is present; 3 cases - // mdiatype: outstream - // bid.params.outstreamAU : N - // bid.renderer : N - // bid.mediaTypes.video.renderer : Y - bid = getThebid(); - delete bid.params.outstreamAU; - delete bid.renderer; - expect(spec.isBidRequestValid(bid)).to.equal(true); - - // false: none present; only outstream - // mdiatype: outstream - // bid.params.outstreamAU : N - // bid.renderer : N - // bid.mediaTypes.video.renderer : N - bid = getThebid(); - delete bid.params.outstreamAU; - delete bid.renderer; - delete bid.mediaTypes.video.renderer; - expect(spec.isBidRequestValid(bid)).to.equal(false); - - // true: none present; outstream + Banner - // mdiatype: outstream, banner - // bid.params.outstreamAU : N - // bid.renderer : N - // bid.mediaTypes.video.renderer : N - bid = getThebid(); - delete bid.params.outstreamAU; - delete bid.renderer; - delete bid.mediaTypes.video.renderer; - bid.mediaTypes.banner = {sizes: [ [300, 250], [300, 600] ]}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - - // true: none present; outstream + Native - // mdiatype: outstream, native - // bid.params.outstreamAU : N - // bid.renderer : N - // bid.mediaTypes.video.renderer : N - bid = getThebid(); - delete bid.params.outstreamAU; - delete bid.renderer; - delete bid.mediaTypes.video.renderer; - bid.mediaTypes.native = {} - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); + // true: when all are present + // mdiatype: outstream + // bid.params.outstreamAU : Y + // bid.renderer : Y + // bid.mediaTypes.video.renderer : Y + let bid = getThebid(); + expect(spec.isBidRequestValid(bid)).to.equal(true); + + // true: atleast one is present; 3 cases + // mdiatype: outstream + // bid.params.outstreamAU : Y + // bid.renderer : N + // bid.mediaTypes.video.renderer : N + bid = getThebid(); + delete bid.renderer; + delete bid.mediaTypes.video.renderer; + expect(spec.isBidRequestValid(bid)).to.equal(true); + + // true: atleast one is present; 3 cases + // mdiatype: outstream + // bid.params.outstreamAU : N + // bid.renderer : Y + // bid.mediaTypes.video.renderer : N + bid = getThebid(); + delete bid.params.outstreamAU; + delete bid.mediaTypes.video.renderer; + expect(spec.isBidRequestValid(bid)).to.equal(true); + + // true: atleast one is present; 3 cases + // mdiatype: outstream + // bid.params.outstreamAU : N + // bid.renderer : N + // bid.mediaTypes.video.renderer : Y + bid = getThebid(); + delete bid.params.outstreamAU; + delete bid.renderer; + expect(spec.isBidRequestValid(bid)).to.equal(true); + + // false: none present; only outstream + // mdiatype: outstream + // bid.params.outstreamAU : N + // bid.renderer : N + // bid.mediaTypes.video.renderer : N + bid = getThebid(); + delete bid.params.outstreamAU; + delete bid.renderer; + delete bid.mediaTypes.video.renderer; + expect(spec.isBidRequestValid(bid)).to.equal(false); + + // true: none present; outstream + Banner + // mdiatype: outstream, banner + // bid.params.outstreamAU : N + // bid.renderer : N + // bid.mediaTypes.video.renderer : N + bid = getThebid(); + delete bid.params.outstreamAU; + delete bid.renderer; + delete bid.mediaTypes.video.renderer; + bid.mediaTypes.banner = {sizes: [ [300, 250], [300, 600] ]}; + expect(spec.isBidRequestValid(bid)).to.equal(true); + + // true: none present; outstream + Native + // mdiatype: outstream, native + // bid.params.outstreamAU : N + // bid.renderer : N + // bid.mediaTypes.video.renderer : N + bid = getThebid(); + delete bid.params.outstreamAU; + delete bid.renderer; + delete bid.mediaTypes.video.renderer; + bid.mediaTypes.native = {} + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + } }); describe('Request formation', function () { @@ -1058,21 +1127,26 @@ describe('PubMatic adapter', function () { expect(data.test).to.equal(undefined); }); - // disabled this test case as it refreshes the whole suite when in karma watch mode - // todo: needs a fix - xit('test flag set to 1 when pubmaticTest=true is present in page url', function() { - window.location.href += '#pubmaticTest=true'; - // now all the test cases below will have window.location.href with #pubmaticTest=true - let request = spec.buildRequests(bidRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - expect(data.test).to.equal(1); - }); - it('Request params check', function () { let request = spec.buildRequests(bidRequests, { - auctionId: 'new-auction-id' + auctionId: 'new-auction-id', + ortb2: { + source: { + tid: 'source-tid' + }, + device: { + geo: { + lat: '36.5189', + lon: '-76.4063' + } + }, + user: { + geo: { + lat: '26.8915', + lon: '-56.6340' + } + }, + } }); let data = JSON.parse(request.data); expect(data.at).to.equal(1); // auction type @@ -1082,13 +1156,13 @@ describe('PubMatic adapter', function () { expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender - expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude - expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.device.geo.lat).to.equal('36.5189'); // Latitude + expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude + expect(data.user.geo.lat).to.equal('26.8915'); // Latitude + expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId - expect(data.source.tid).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId + expect(data.source.tid).to.equal('source-tid'); // Prebid TransactionId expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID @@ -1102,8 +1176,80 @@ describe('PubMatic adapter', function () { expect(data.imp[0].ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr); expect(data.imp[0].bidfloorcur).to.equal(bidRequests[0].params.currency); expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain); + expect(data.ext.epoch).to.exist; }); + it('Set tmax from global config if not set by requestBids method', function() { + let sandbox = sinon.sandbox.create(); + sandbox.stub(config, 'getConfig').callsFake((key) => { + var config = { + bidderTimeout: 3000 + }; + return config[key]; + }); + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id', timeout: 3000 + }); + let data = JSON.parse(request.data); + expect(data.tmax).to.deep.equal(3000); + sandbox.restore(); + }); + describe('Marketplace parameters', function() { + let bidderSettingStub; + beforeEach(function() { + bidderSettingStub = sinon.stub(bidderSettings, 'get'); + }); + + afterEach(function() { + bidderSettingStub.restore(); + }); + + it('should not be present when allowAlternateBidderCodes is undefined', function () { + bidderSettingStub.returns(undefined); + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.ext.marketplace).to.equal(undefined); + }); + + it('should be pubmatic and groupm when allowedAlternateBidderCodes is \'groupm\'', function () { + bidderSettingStub.withArgs('pubmatic', 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs('pubmatic', 'allowedAlternateBidderCodes').returns(['groupm']); + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id', + bidderCode: 'pubmatic' + }); + let data = JSON.parse(request.data); + expect(data.ext.marketplace.allowedbidders).to.be.an('array'); + expect(data.ext.marketplace.allowedbidders.length).to.equal(2); + expect(data.ext.marketplace.allowedbidders[0]).to.equal('pubmatic'); + expect(data.ext.marketplace.allowedbidders[1]).to.equal('groupm'); + }); + + it('should be ALL by default', function () { + bidderSettingStub.returns(true); + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.ext.marketplace.allowedbidders).to.be.an('array'); + expect(data.ext.marketplace.allowedbidders[0]).to.equal('all'); + }); + + it('should be ALL when allowedAlternateBidderCodes is \'*\'', function () { + bidderSettingStub.withArgs('pubmatic', 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs('pubmatic', 'allowedAlternateBidderCodes').returns(['*']); + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id', + bidderCode: 'pubmatic' + }); + let data = JSON.parse(request.data); + expect(data.ext.marketplace.allowedbidders).to.be.an('array'); + expect(data.ext.marketplace.allowedbidders[0]).to.equal('all'); + }); + }) + it('Set content from config, set site.content', function() { let sandbox = sinon.sandbox.create(); const content = { @@ -1141,7 +1287,7 @@ describe('PubMatic adapter', function () { expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0); expect(data.device.h).to.equal(screen.height); expect(data.device.w).to.equal(screen.width); - expect(data.device.language).to.equal(navigator.language); + expect(data.device.language).to.equal(navigator.language.split('-')[0]); expect(data.device.newkey).to.equal('new-device-data');// additional data from config sandbox.restore(); }); @@ -1253,7 +1399,21 @@ describe('PubMatic adapter', function () { it('Request params check: without adSlot', function () { delete bidRequests[0].params.adSlot; let request = spec.buildRequests(bidRequests, { - auctionId: 'new-auction-id' + auctionId: 'new-auction-id', + ortb2: { + device: { + geo: { + lat: '36.5189', + lon: '-76.4063' + } + }, + user: { + geo: { + lat: '26.8915', + lon: '-56.6340' + } + }, + } }); let data = JSON.parse(request.data); expect(data.at).to.equal(1); // auction type @@ -1263,12 +1423,12 @@ describe('PubMatic adapter', function () { expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender - expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude - expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.device.geo.lat).to.equal('36.5189'); // Latitude + expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude + expect(data.user.geo.lat).to.equal('26.8915'); // Latitude + expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID @@ -1462,7 +1622,21 @@ describe('PubMatic adapter', function () { it('Pass auctiondId as wiid if wiid is not passed in params', function () { let bidRequest = { - auctionId: 'new-auction-id' + auctionId: 'new-auction-id', + ortb2: { + device: { + geo: { + lat: '36.5189', + lon: '-76.4063' + } + }, + user: { + geo: { + lat: '26.8915', + lon: '-56.6340' + } + }, + } }; delete bidRequests[0].params.wiid; let request = spec.buildRequests(bidRequests, bidRequest); @@ -1474,12 +1648,12 @@ describe('PubMatic adapter', function () { expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender - expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude - expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.device.geo.lat).to.equal('36.5189'); // Latitude + expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude + expect(data.user.geo.lat).to.equal('26.8915'); // Latitude + expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.ext.wrapper.wiid).to.equal('new-auction-id'); // OpenWrap: Wrapper Impression ID expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID @@ -1497,6 +1671,20 @@ describe('PubMatic adapter', function () { gdprConsent: { consentString: 'kjfdniwjnifwenrif3', gdprApplies: true + }, + ortb2: { + device: { + geo: { + lat: '36.5189', + lon: '-76.4063' + } + }, + user: { + geo: { + lat: '26.8915', + lon: '-56.6340' + } + }, } }; let request = spec.buildRequests(bidRequests, bidRequest); @@ -1510,12 +1698,12 @@ describe('PubMatic adapter', function () { expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender - expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude - expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.device.geo.lat).to.equal('36.5189'); // Latitude + expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude + expect(data.user.geo.lat).to.equal('26.8915'); // Latitude + expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID @@ -1530,7 +1718,21 @@ describe('PubMatic adapter', function () { it('Request params check with USP/CCPA Consent', function () { let bidRequest = { - uspConsent: '1NYN' + uspConsent: '1NYN', + ortb2: { + device: { + geo: { + lat: '36.5189', + lon: '-76.4063' + } + }, + user: { + geo: { + lat: '26.8915', + lon: '-56.6340' + } + }, + } }; let request = spec.buildRequests(bidRequests, bidRequest); let data = JSON.parse(request.data); @@ -1542,12 +1744,12 @@ describe('PubMatic adapter', function () { expect(data.site.publisher.id).to.equal(bidRequests[0].params.publisherId); // publisher Id expect(data.user.yob).to.equal(parseInt(bidRequests[0].params.yob)); // YOB expect(data.user.gender).to.equal(bidRequests[0].params.gender); // Gender - expect(data.device.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.device.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude - expect(data.user.geo.lat).to.equal(parseFloat(bidRequests[0].params.lat)); // Latitude - expect(data.user.geo.lon).to.equal(parseFloat(bidRequests[0].params.lon)); // Lognitude + expect(data.device.geo.lat).to.equal('36.5189'); // Latitude + expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude + expect(data.user.geo.lat).to.equal('26.8915'); // Latitude + expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version - expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.transactionId).to.equal(bidRequests[0].ortb2Imp.ext.tid); // Prebid TransactionId expect(data.ext.wrapper.wiid).to.equal(bidRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID expect(data.ext.wrapper.profile).to.equal(parseInt(bidRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID expect(data.ext.wrapper.version).to.equal(parseInt(bidRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID @@ -1631,44 +1833,79 @@ describe('PubMatic adapter', function () { describe('FPD', function() { let newRequest; - it('ortb2.site should be merged in the request', function() { - let sandbox = sinon.sandbox.create(); - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - 'ortb2': { - site: { - domain: 'page.example.com', - cat: ['IAB2'], - sectioncat: ['IAB2-2'] - } + describe('ortb2.site should not override page, domain & ref values', function() { + it('When above properties are present in ortb2.site', function() { + const ortb2 = { + site: { + domain: 'page.example.com', + page: 'https://page.example.com/here.html', + ref: 'https://page.example.com/here.html' + } + }; + const request = spec.buildRequests(bidRequests, {ortb2}); + let data = JSON.parse(request.data); + expect(data.site.domain).not.equal('page.example.com'); + expect(data.site.page).not.equal('https://page.example.com/here.html'); + expect(data.site.ref).not.equal('https://page.example.com/here.html'); + }); + + it('When above properties are absent in ortb2.site', function () { + const ortb2 = { + site: {} + }; + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id', + ortb2 + }); + let data = JSON.parse(request.data); + let response = spec.interpretResponse(bidResponses, request); + expect(data.site.page).to.equal(bidRequests[0].params.kadpageurl); + expect(data.site.domain).to.equal(_getDomainFromURL(data.site.page)); + expect(response[0].referrer).to.equal(data.site.ref); + }); + + it('With some extra properties in ortb2.site', function() { + const ortb2 = { + site: { + domain: 'page.example.com', + page: 'https://page.example.com/here.html', + ref: 'https://page.example.com/here.html', + cat: ['IAB2'], + sectioncat: ['IAB2-2'] } }; - return config[key]; + const request = spec.buildRequests(bidRequests, {ortb2}); + let data = JSON.parse(request.data); + expect(data.site.domain).not.equal('page.example.com'); + expect(data.site.page).not.equal('https://page.example.com/here.html'); + expect(data.site.ref).not.equal('https://page.example.com/here.html'); + expect(data.site.cat).to.deep.equal(['IAB2']); + expect(data.site.sectioncat).to.deep.equal(['IAB2-2']); }); - const request = spec.buildRequests(bidRequests, {}); + }); + + it('ortb2.site should be merged except page, domain & ref in the request', function() { + const ortb2 = { + site: { + cat: ['IAB2'], + sectioncat: ['IAB2-2'] + } + }; + const request = spec.buildRequests(bidRequests, {ortb2}); let data = JSON.parse(request.data); - expect(data.site.domain).to.equal('page.example.com'); expect(data.site.cat).to.deep.equal(['IAB2']); expect(data.site.sectioncat).to.deep.equal(['IAB2-2']); - sandbox.restore(); }); it('ortb2.user should be merged in the request', function() { - let sandbox = sinon.sandbox.create(); - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - 'ortb2': { - user: { - yob: 1985 - } - } - }; - return config[key]; - }); - const request = spec.buildRequests(bidRequests, {}); + const ortb2 = { + user: { + yob: 1985 + } + }; + const request = spec.buildRequests(bidRequests, {ortb2}); let data = JSON.parse(request.data); expect(data.user.yob).to.equal(1985); - sandbox.restore(); }); describe('ortb2Imp', function() { @@ -1890,29 +2127,31 @@ describe('PubMatic adapter', function () { expect(data.bidfloor).to.equal(undefined); }); - it('ignore floormodule o/p if floor is not number', function() { - floorModuleTestData.banner['300x250'].floor = 'Not-a-Number'; - floorModuleTestData.banner['300x600'].floor = 'Not-a-Number'; - newRequest[0].params.kadfloor = undefined; - let request = spec.buildRequests(newRequest, { - auctionId: 'new-auction-id' + if (FEATURES.VIDEO) { + it('ignore floormodule o/p if floor is not number', function() { + floorModuleTestData.banner['300x250'].floor = 'Not-a-Number'; + floorModuleTestData.banner['300x600'].floor = 'Not-a-Number'; + newRequest[0].params.kadfloor = undefined; + let request = spec.buildRequests(newRequest, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(2.5); // video will be lowest now }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(2.5); // video will be lowest now - }); - it('ignore floormodule o/p if currency is not matched', function() { - floorModuleTestData.banner['300x250'].currency = 'INR'; - floorModuleTestData.banner['300x600'].currency = 'INR'; - newRequest[0].params.kadfloor = undefined; - let request = spec.buildRequests(newRequest, { - auctionId: 'new-auction-id' + it('ignore floormodule o/p if currency is not matched', function() { + floorModuleTestData.banner['300x250'].currency = 'INR'; + floorModuleTestData.banner['300x600'].currency = 'INR'; + newRequest[0].params.kadfloor = undefined; + let request = spec.buildRequests(newRequest, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.bidfloor).to.equal(2.5); // video will be lowest now }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.bidfloor).to.equal(2.5); // video will be lowest now - }); + } it('kadfloor is not passed, use minimum from floorModule', function() { newRequest[0].params.kadfloor = undefined; @@ -1989,7 +2228,7 @@ describe('PubMatic adapter', function () { sandbox.restore(); }); - describe('AdsrvrOrgId from userId module', function() { + describe('userIdAsEids', function() { let sandbox; beforeEach(() => { sandbox = sinon.sandbox.create(); @@ -1999,13 +2238,10 @@ describe('PubMatic adapter', function () { sandbox.restore(); }); - it('Request should have AdsrvrOrgId config params', function() { + it('Request should have EIDs', function() { bidRequests[0].userId = {}; bidRequests[0].userId.tdid = 'TTD_ID_FROM_USER_ID_MODULE'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ + bidRequests[0].userIdAsEids = [{ 'source': 'adserver.org', 'uids': [{ 'id': 'TTD_ID_FROM_USER_ID_MODULE', @@ -2014,572 +2250,53 @@ describe('PubMatic adapter', function () { 'rtiPartner': 'TDID' } }] - }]); - }); - - it('Request should have adsrvrOrgId from UserId Module if config and userId module both have TTD ID', function() { - sandbox.stub(config, 'getConfig').callsFake((key) => { - var config = { - adsrvrOrgId: { - 'TDID': 'TTD_ID_FROM_CONFIG', - 'TDID_LOOKUP': 'TRUE', - 'TDID_CREATED_AT': '2018-10-01T07:05:40' - } - }; - return config[key]; - }); - bidRequests[0].userId = {}; - bidRequests[0].userId.tdid = 'TTD_ID_FROM_USER_ID_MODULE'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); + }]; let request = spec.buildRequests(bidRequests, {}); let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'adserver.org', - 'uids': [{ - 'id': 'TTD_ID_FROM_USER_ID_MODULE', - 'atype': 1, - 'ext': { - 'rtiPartner': 'TDID' - } - }] - }]); + expect(data.user.eids).to.deep.equal(bidRequests[0].userIdAsEids); }); - it('Request should NOT have adsrvrOrgId params if userId is NOT object', function() { + it('Request should NOT have EIDs userIdAsEids is NOT object', function() { let request = spec.buildRequests(bidRequests, {}); let data = JSON.parse(request.data); expect(data.user.eids).to.deep.equal(undefined); }); + }); - it('Request should NOT have adsrvrOrgId params if userId.tdid is NOT string', function() { - bidRequests[0].userId = { - tdid: 1234 - }; - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal(undefined); + it('should pass device.sua if present in bidderRequest fpd ortb2 object', function () { + const suaObject = {'source': 2, 'platform': {'brand': 'macOS', 'version': ['12', '4', '0']}, 'browsers': [{'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']}], 'mobile': 0, 'model': '', 'bitness': '64', 'architecture': 'x86'}; + let request = spec.buildRequests(multipleMediaRequests, { + auctionId: 'new-auction-id', + ortb2: { + device: { + sua: suaObject + } + } }); + let data = JSON.parse(request.data); + expect(data.device.sua).to.exist.and.to.be.an('object'); + expect(data.device.sua).to.deep.equal(suaObject); }); - describe('UserIds from request', function() { - describe('pubcommon Id', function() { - it('send the pubcommon id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.pubcid = 'pub_common_user_id'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'pubcid.org', - 'uids': [{ - 'id': 'pub_common_user_id', - 'atype': 1 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.pubcid = 1; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.pubcid = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.pubcid = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.pubcid = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); + it('Request params should have valid native bid request for all valid params', function () { + let request = spec.buildRequests(nativeBidRequests, { + auctionId: 'new-auction-id' }); + let data = JSON.parse(request.data); + expect(data.imp[0].native).to.exist; + expect(data.imp[0].native['request']).to.exist; + expect(data.imp[0].tagid).to.equal('/43743431/NativeAutomationPrebid'); + expect(data.imp[0]['native']['request']).to.exist.and.to.be.an('string'); + expect(data.imp[0]['native']['request']).to.exist.and.to.equal(validnativeBidImpression.native.request); + }); - describe('ID5 Id', function() { - it('send the id5 id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.id5id = { uid: 'id5-user-id' }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'id5-sync.com', - 'uids': [{ - 'id': 'id5-user-id', - 'atype': 1 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.id5id = { uid: 1 }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.id5id = { uid: [] }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.id5id = { uid: null }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.id5id = { uid: {} }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); + it('Request params should not have valid native bid request for non native request', function () { + let request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id' }); - - describe('Criteo Id', function() { - it('send the criteo id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.criteoId = 'criteo-user-id'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'criteo.com', - 'uids': [{ - 'id': 'criteo-user-id', - 'atype': 1 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.criteoId = 1; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.criteoId = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.criteoId = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.criteoId = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); - }); - - describe('IdentityLink Id', function() { - it('send the identity-link id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.idl_env = 'identity-link-user-id'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'liveramp.com', - 'uids': [{ - 'id': 'identity-link-user-id', - 'atype': 3 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.idl_env = 1; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.idl_env = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.idl_env = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.idl_env = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); - }); - - describe('LiveIntent Id', function() { - it('send the LiveIntent id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.lipb = { lipbid: 'live-intent-user-id' }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'liveintent.com', - 'uids': [{ - 'id': 'live-intent-user-id', - 'atype': 3 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.lipb = { lipbid: 1 }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.lipb.lipbid = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.lipb.lipbid = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.lipb.lipbid = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); - }); - - describe('Parrable Id', function() { - it('send the Parrable id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.parrableId = { eid: 'parrable-user-id' }; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'parrable.com', - 'uids': [{ - 'id': 'parrable-user-id', - 'atype': 1 - }] - }]); - }); - - it('do not pass if not object with eid key', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.parrableid = 1; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.parrableid = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.parrableid = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.parrableid = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); - }); - - describe('Britepool Id', function() { - it('send the Britepool id if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.britepoolid = 'britepool-user-id'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'britepool.com', - 'uids': [{ - 'id': 'britepool-user-id', - 'atype': 3 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.britepoolid = 1; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.britepoolid = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.britepoolid = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.britepoolid = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); - }); - - describe('NetId', function() { - it('send the NetId if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.netId = 'netid-user-id'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'netid.de', - 'uids': [{ - 'id': 'netid-user-id', - 'atype': 1 - }] - }]); - }); - - it('do not pass if not string', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.netId = 1; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.netId = []; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.netId = null; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - bidRequests[0].userId.netId = {}; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - request = spec.buildRequests(bidRequests, {}); - data = JSON.parse(request.data); - expect(data.user.eids).to.equal(undefined); - }); - }); - - describe('FlocId', function() { - it('send the FlocId if it is present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.flocId = { - id: '1234', - version: 'chrome1.1' - } - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'chrome.com', - 'uids': [{ - 'id': '1234', - 'atype': 1, - 'ext': { - 'ver': 'chrome1.1' - } - }] - }]); - expect(data.user.data).to.deep.equal([{ - id: 'FLOC', - name: 'FLOC', - ext: { - ver: 'chrome1.1' - }, - segment: [{ - id: '1234', - name: 'chrome.com', - value: '1234' - }] - }]); - }); - - it('appnend the flocId if userIds are present', function() { - bidRequests[0].userId = {}; - bidRequests[0].userId.netId = 'netid-user-id'; - bidRequests[0].userIdAsEids = createEidsArray(bidRequests[0].userId); - bidRequests[0].userId.flocId = { - id: '1234', - version: 'chrome1.1' - } - let request = spec.buildRequests(bidRequests, {}); - let data = JSON.parse(request.data); - expect(data.user.eids).to.deep.equal([{ - 'source': 'netid.de', - 'uids': [{ - 'id': 'netid-user-id', - 'atype': 1 - }] - }, { - 'source': 'chrome.com', - 'uids': [{ - 'id': '1234', - 'atype': 1, - 'ext': { - 'ver': 'chrome1.1' - } - }] - }]); - }); - }); - }); - - it('Request params check for video ad', function () { - let request = spec.buildRequests(videoBidRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist; - expect(data.imp[0].tagid).to.equal('Div1'); - expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); - expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); - expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); - expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); - expect(data.imp[0]['video']['startdelay']).to.equal(videoBidRequests[0].params.video['startdelay']); - - expect(data.imp[0]['video']['playbackmethod']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['playbackmethod'][0]).to.equal(videoBidRequests[0].params.video['playbackmethod'][0]); - expect(data.imp[0]['video']['playbackmethod'][1]).to.equal(videoBidRequests[0].params.video['playbackmethod'][1]); - - expect(data.imp[0]['video']['api']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['api'][0]).to.equal(videoBidRequests[0].params.video['api'][0]); - expect(data.imp[0]['video']['api'][1]).to.equal(videoBidRequests[0].params.video['api'][1]); - - expect(data.imp[0]['video']['protocols']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['protocols'][0]).to.equal(videoBidRequests[0].params.video['protocols'][0]); - expect(data.imp[0]['video']['protocols'][1]).to.equal(videoBidRequests[0].params.video['protocols'][1]); - - expect(data.imp[0]['video']['battr']).to.exist.and.to.be.an('array'); - expect(data.imp[0]['video']['battr'][0]).to.equal(videoBidRequests[0].params.video['battr'][0]); - expect(data.imp[0]['video']['battr'][1]).to.equal(videoBidRequests[0].params.video['battr'][1]); - - expect(data.imp[0]['video']['linearity']).to.equal(videoBidRequests[0].params.video['linearity']); - expect(data.imp[0]['video']['placement']).to.equal(videoBidRequests[0].params.video['placement']); - expect(data.imp[0]['video']['minbitrate']).to.equal(videoBidRequests[0].params.video['minbitrate']); - expect(data.imp[0]['video']['maxbitrate']).to.equal(videoBidRequests[0].params.video['maxbitrate']); - - expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); - }); - - it('Request params check for 1 banner and 1 video ad', function () { - let request = spec.buildRequests(multipleMediaRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - - expect(data.imp).to.be.an('array') - expect(data.imp).with.length.above(1); - - expect(data.at).to.equal(1); // auction type - expect(data.cur[0]).to.equal('USD'); // currency - expect(data.site.domain).to.be.a('string'); // domain should be set - expect(data.site.page).to.equal(multipleMediaRequests[0].params.kadpageurl); // forced pageURL - expect(data.site.publisher.id).to.equal(multipleMediaRequests[0].params.publisherId); // publisher Id - expect(data.user.yob).to.equal(parseInt(multipleMediaRequests[0].params.yob)); // YOB - expect(data.user.gender).to.equal(multipleMediaRequests[0].params.gender); // Gender - expect(data.device.geo.lat).to.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude - expect(data.device.geo.lon).to.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude - expect(data.user.geo.lat).to.equal(parseFloat(multipleMediaRequests[0].params.lat)); // Latitude - expect(data.user.geo.lon).to.equal(parseFloat(multipleMediaRequests[0].params.lon)); // Lognitude - expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version - expect(data.ext.wrapper.transactionId).to.equal(multipleMediaRequests[0].transactionId); // Prebid TransactionId - expect(data.ext.wrapper.wiid).to.equal(multipleMediaRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID - expect(data.ext.wrapper.profile).to.equal(parseInt(multipleMediaRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID - expect(data.ext.wrapper.version).to.equal(parseInt(multipleMediaRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID - - // banner imp object check - expect(data.imp[0].id).to.equal(multipleMediaRequests[0].bidId); // Prebid bid id is passed as id - expect(data.imp[0].bidfloor).to.equal(parseFloat(multipleMediaRequests[0].params.kadfloor)); // kadfloor - expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid - expect(data.imp[0].banner.w).to.equal(300); // width - expect(data.imp[0].banner.h).to.equal(250); // height - expect(data.imp[0].ext.pmZoneId).to.equal(multipleMediaRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid - - // video imp object check - expect(data.imp[1].video).to.exist; - expect(data.imp[1].tagid).to.equal('Div1'); - expect(data.imp[1]['video']['mimes']).to.exist.and.to.be.an('array'); - expect(data.imp[1]['video']['mimes'][0]).to.equal(multipleMediaRequests[1].params.video['mimes'][0]); - expect(data.imp[1]['video']['mimes'][1]).to.equal(multipleMediaRequests[1].params.video['mimes'][1]); - expect(data.imp[1]['video']['minduration']).to.equal(multipleMediaRequests[1].params.video['minduration']); - expect(data.imp[1]['video']['maxduration']).to.equal(multipleMediaRequests[1].params.video['maxduration']); - expect(data.imp[1]['video']['startdelay']).to.equal(multipleMediaRequests[1].params.video['startdelay']); - - expect(data.imp[1]['video']['playbackmethod']).to.exist.and.to.be.an('array'); - expect(data.imp[1]['video']['playbackmethod'][0]).to.equal(multipleMediaRequests[1].params.video['playbackmethod'][0]); - expect(data.imp[1]['video']['playbackmethod'][1]).to.equal(multipleMediaRequests[1].params.video['playbackmethod'][1]); - - expect(data.imp[1]['video']['api']).to.exist.and.to.be.an('array'); - expect(data.imp[1]['video']['api'][0]).to.equal(multipleMediaRequests[1].params.video['api'][0]); - expect(data.imp[1]['video']['api'][1]).to.equal(multipleMediaRequests[1].params.video['api'][1]); - - expect(data.imp[1]['video']['protocols']).to.exist.and.to.be.an('array'); - expect(data.imp[1]['video']['protocols'][0]).to.equal(multipleMediaRequests[1].params.video['protocols'][0]); - expect(data.imp[1]['video']['protocols'][1]).to.equal(multipleMediaRequests[1].params.video['protocols'][1]); - - expect(data.imp[1]['video']['battr']).to.exist.and.to.be.an('array'); - expect(data.imp[1]['video']['battr'][0]).to.equal(multipleMediaRequests[1].params.video['battr'][0]); - expect(data.imp[1]['video']['battr'][1]).to.equal(multipleMediaRequests[1].params.video['battr'][1]); - - expect(data.imp[1]['video']['linearity']).to.equal(multipleMediaRequests[1].params.video['linearity']); - expect(data.imp[1]['video']['placement']).to.equal(multipleMediaRequests[1].params.video['placement']); - expect(data.imp[1]['video']['minbitrate']).to.equal(multipleMediaRequests[1].params.video['minbitrate']); - expect(data.imp[1]['video']['maxbitrate']).to.equal(multipleMediaRequests[1].params.video['maxbitrate']); - - expect(data.imp[1]['video']['w']).to.equal(multipleMediaRequests[1].mediaTypes.video.playerSize[0]); - expect(data.imp[1]['video']['h']).to.equal(multipleMediaRequests[1].mediaTypes.video.playerSize[1]); - }); - - it('Request params should have valid native bid request for all valid params', function () { - let request = spec.buildRequests(nativeBidRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - expect(data.imp[0].native).to.exist; - expect(data.imp[0].native['request']).to.exist; - expect(data.imp[0].tagid).to.equal('/43743431/NativeAutomationPrebid'); - expect(data.imp[0]['native']['request']).to.exist.and.to.be.an('string'); - expect(data.imp[0]['native']['request']).to.exist.and.to.equal(validnativeBidImpression.native.request); - }); - - it('Request params should not have valid native bid request for non native request', function () { - let request = spec.buildRequests(bidRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - expect(data.imp[0].native).to.not.exist; - }); + let data = JSON.parse(request.data); + expect(data.imp[0].native).to.not.exist; + }); it('Request params should have valid native bid request with valid required param values for all valid params', function () { let request = spec.buildRequests(nativeBidRequestsWithRequiredParam, { @@ -2593,13 +2310,6 @@ describe('PubMatic adapter', function () { expect(data.imp[0]['native']['request']).to.exist.and.to.equal(validnativeBidImpressionWithRequiredParam.native.request); }); - it('should not have valid native request if assets are not defined with minimum required params and only native is the slot', function () { - let request = spec.buildRequests(nativeBidRequestsWithoutAsset, { - auctionId: 'new-auction-id' - }); - expect(request).to.deep.equal(undefined); - }); - it('Request params should have valid native bid request for all native params', function () { let request = spec.buildRequests(nativeBidRequestsWithAllParams, { auctionId: 'new-auction-id' @@ -2612,327 +2322,549 @@ describe('PubMatic adapter', function () { expect(data.imp[0]['native']['request']).to.exist.and.to.equal(validnativeBidImpressionWithAllParams.native.request); }); - it('Request params - should handle banner and video format in single adunit', function() { - let request = spec.buildRequests(bannerAndVideoBidRequests, { + it('Request params - should handle banner and native format in single adunit', function() { + let request = spec.buildRequests(bannerAndNativeBidRequests, { auctionId: 'new-auction-id' }); let data = JSON.parse(request.data); data = data.imp[0]; + expect(data.banner).to.exist; expect(data.banner.w).to.equal(300); expect(data.banner.h).to.equal(250); expect(data.banner.format).to.exist; - expect(data.banner.format.length).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes.length); - - // Case: when size is not present in adslo - bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo'; - request = spec.buildRequests(bannerAndVideoBidRequests, { - auctionId: 'new-auction-id' - }); - data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.banner).to.exist; - expect(data.banner.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes[0][0]); - expect(data.banner.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes[0][1]); - expect(data.banner.format).to.exist; - expect(data.banner.format.length).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes.length - 1); + expect(data.banner.format.length).to.equal(bannerAndNativeBidRequests[0].mediaTypes.banner.sizes.length); - expect(data.video).to.exist; - expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]); + expect(data.native).to.exist; + expect(data.native.request).to.exist; }); - it('Request params - banner and video req in single adslot - should ignore banner imp if banner size is set to fluid and send video imp object', function () { - /* Adslot configured for banner and video. - banner size is set to [['fluid'], [300, 250]] - adslot specifies a size as 300x250 - => banner imp object should have primary w and h set to 300 and 250. fluid is ignored - */ - bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid'], [160, 600]]; - - let request = spec.buildRequests(bannerAndVideoBidRequests, { + it('Request params - banner and native multiformat request - should have native object incase of invalid config present', function() { + bannerAndNativeBidRequests[0].mediaTypes.native = { + title: { required: true }, + image: { required: true }, + sponsoredBy: { required: true }, + clickUrl: { required: true } + }; + bannerAndNativeBidRequests[0].nativeParams = { + title: { required: true }, + image: { required: true }, + sponsoredBy: { required: true }, + clickUrl: { required: true } + } + let request = spec.buildRequests(bannerAndNativeBidRequests, { auctionId: 'new-auction-id' }); let data = JSON.parse(request.data); data = data.imp[0]; expect(data.banner).to.exist; - expect(data.banner.w).to.equal(300); - expect(data.banner.h).to.equal(250); - expect(data.banner.format).to.exist; - expect(data.banner.format[0].w).to.equal(160); - expect(data.banner.format[0].h).to.equal(600); + expect(data.native).to.exist; + }); - /* Adslot configured for banner and video. - banner size is set to [['fluid'], [300, 250]] - adslot does not specify any size - => banner imp object should have primary w and h set to 300 and 250. fluid is ignored - */ - bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid'], [160, 600]]; - bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo'; + it('Request params - should not add banner object if mediaTypes.banner is missing, but adunits.sizes is present', function() { + delete bannerAndNativeBidRequests[0].mediaTypes.banner; + bannerAndNativeBidRequests[0].sizes = [729, 90]; - request = spec.buildRequests(bannerAndVideoBidRequests, { + let request = spec.buildRequests(bannerAndNativeBidRequests, { auctionId: 'new-auction-id' }); - data = JSON.parse(request.data); + let data = JSON.parse(request.data); data = data.imp[0]; - expect(data.banner).to.exist; - expect(data.banner.w).to.equal(160); - expect(data.banner.h).to.equal(600); - expect(data.banner.format).to.not.exist; - - /* Adslot configured for banner and video. - banner size is set to [[728 90], ['fluid'], [300, 250]] - adslot does not specify any size - => banner imp object should have primary w and h set to 728 and 90. - banner.format should have 300, 250 set in it - fluid is ignore - */ + expect(data.banner).to.not.exist; - bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [[728, 90], ['fluid'], [300, 250]]; - request = spec.buildRequests(bannerAndVideoBidRequests, { - auctionId: 'new-auction-id' - }); - data = JSON.parse(request.data); - data = data.imp[0]; + expect(data.native).to.exist; + expect(data.native.request).to.exist; + }); - expect(data.banner).to.exist; - expect(data.banner.w).to.equal(728); - expect(data.banner.h).to.equal(90); - expect(data.banner.format).to.exist; - expect(data.banner.format[0].w).to.equal(300); - expect(data.banner.format[0].h).to.equal(250); + if (FEATURES.VIDEO) { + it('Request params - should not contain banner imp if mediaTypes.banner is not present and sizes is specified in bid.sizes', function() { + delete bannerAndVideoBidRequests[0].mediaTypes.banner; + bannerAndVideoBidRequests[0].params.sizes = [300, 250]; - /* Adslot configured for banner and video. - banner size is set to [['fluid']] - adslot does not specify any size - => banner object should not be sent in the request. only video should be sent. - */ + let request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.banner).to.not.exist; + }); + + it('Request params check for 1 banner and 1 video ad', function () { + let request = spec.buildRequests(multipleMediaRequests, { + auctionId: 'new-auction-id', + ortb2: { + device: { + geo: { + lat: '36.5189', + lon: '-76.4063' + } + }, + user: { + geo: { + lat: '26.8915', + lon: '-56.6340' + } + }, + } + }); + let data = JSON.parse(request.data); - bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid']]; - request = spec.buildRequests(bannerAndVideoBidRequests, { - auctionId: 'new-auction-id' + expect(data.imp).to.be.an('array') + expect(data.imp).with.length.above(1); + + expect(data.at).to.equal(1); // auction type + expect(data.cur[0]).to.equal('USD'); // currency + expect(data.site.domain).to.be.a('string'); // domain should be set + expect(data.site.page).to.equal(multipleMediaRequests[0].params.kadpageurl); // forced pageURL + expect(data.site.publisher.id).to.equal(multipleMediaRequests[0].params.publisherId); // publisher Id + expect(data.user.yob).to.equal(parseInt(multipleMediaRequests[0].params.yob)); // YOB + expect(data.user.gender).to.equal(multipleMediaRequests[0].params.gender); // Gender + expect(data.device.geo.lat).to.equal('36.5189'); // Latitude + expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude + expect(data.user.geo.lat).to.equal('26.8915'); // Latitude + expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude + expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version + expect(data.ext.wrapper.transactionId).to.equal(multipleMediaRequests[0].transactionId); // Prebid TransactionId + expect(data.ext.wrapper.wiid).to.equal(multipleMediaRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID + expect(data.ext.wrapper.profile).to.equal(parseInt(multipleMediaRequests[0].params.profId)); // OpenWrap: Wrapper Profile ID + expect(data.ext.wrapper.version).to.equal(parseInt(multipleMediaRequests[0].params.verId)); // OpenWrap: Wrapper Profile Version ID + + // banner imp object check + expect(data.imp[0].id).to.equal(multipleMediaRequests[0].bidId); // Prebid bid id is passed as id + expect(data.imp[0].bidfloor).to.equal(parseFloat(multipleMediaRequests[0].params.kadfloor)); // kadfloor + expect(data.imp[0].tagid).to.equal('/15671365/DMDemo'); // tagid + expect(data.imp[0].banner.w).to.equal(300); // width + expect(data.imp[0].banner.h).to.equal(250); // height + expect(data.imp[0].ext.pmZoneId).to.equal(multipleMediaRequests[0].params.pmzoneid.split(',').slice(0, 50).map(id => id.trim()).join()); // pmzoneid + + // video imp object check + expect(data.imp[1].video).to.exist; + expect(data.imp[1].tagid).to.equal('Div1'); + expect(data.imp[1]['video']['mimes']).to.exist.and.to.be.an('array'); + expect(data.imp[1]['video']['mimes'][0]).to.equal(multipleMediaRequests[1].params.video['mimes'][0]); + expect(data.imp[1]['video']['mimes'][1]).to.equal(multipleMediaRequests[1].params.video['mimes'][1]); + expect(data.imp[1]['video']['minduration']).to.equal(multipleMediaRequests[1].params.video['minduration']); + expect(data.imp[1]['video']['maxduration']).to.equal(multipleMediaRequests[1].params.video['maxduration']); + expect(data.imp[1]['video']['startdelay']).to.equal(multipleMediaRequests[1].params.video['startdelay']); + + expect(data.imp[1]['video']['playbackmethod']).to.exist.and.to.be.an('array'); + expect(data.imp[1]['video']['playbackmethod'][0]).to.equal(multipleMediaRequests[1].params.video['playbackmethod'][0]); + expect(data.imp[1]['video']['playbackmethod'][1]).to.equal(multipleMediaRequests[1].params.video['playbackmethod'][1]); + + expect(data.imp[1]['video']['api']).to.exist.and.to.be.an('array'); + expect(data.imp[1]['video']['api'][0]).to.equal(multipleMediaRequests[1].params.video['api'][0]); + expect(data.imp[1]['video']['api'][1]).to.equal(multipleMediaRequests[1].params.video['api'][1]); + + expect(data.imp[1]['video']['protocols']).to.exist.and.to.be.an('array'); + expect(data.imp[1]['video']['protocols'][0]).to.equal(multipleMediaRequests[1].params.video['protocols'][0]); + expect(data.imp[1]['video']['protocols'][1]).to.equal(multipleMediaRequests[1].params.video['protocols'][1]); + + expect(data.imp[1]['video']['battr']).to.exist.and.to.be.an('array'); + expect(data.imp[1]['video']['battr'][0]).to.equal(multipleMediaRequests[1].params.video['battr'][0]); + expect(data.imp[1]['video']['battr'][1]).to.equal(multipleMediaRequests[1].params.video['battr'][1]); + + expect(data.imp[1]['video']['linearity']).to.equal(multipleMediaRequests[1].params.video['linearity']); + expect(data.imp[1]['video']['placement']).to.equal(multipleMediaRequests[1].params.video['placement']); + expect(data.imp[1]['video']['plcmt']).to.equal(multipleMediaRequests[1].params.video['plcmt']); + expect(data.imp[1]['video']['minbitrate']).to.equal(multipleMediaRequests[1].params.video['minbitrate']); + expect(data.imp[1]['video']['maxbitrate']).to.equal(multipleMediaRequests[1].params.video['maxbitrate']); + + expect(data.imp[1]['video']['w']).to.equal(multipleMediaRequests[1].mediaTypes.video.playerSize[0]); + expect(data.imp[1]['video']['h']).to.equal(multipleMediaRequests[1].mediaTypes.video.playerSize[1]); + }); + + // ================================================ + it('Request params - should handle banner and video format in single adunit', function() { + let request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.banner).to.exist; + expect(data.banner.w).to.equal(300); + expect(data.banner.h).to.equal(250); + expect(data.banner.format).to.exist; + expect(data.banner.format.length).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes.length); + + // Case: when size is not present in adslo + bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo'; + request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.banner).to.exist; + expect(data.banner.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes[0][0]); + expect(data.banner.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes[0][1]); + expect(data.banner.format).to.exist; + expect(data.banner.format.length).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes.length - 1); + + expect(data.video).to.exist; + expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]); }); - data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.banner).to.not.exist; - expect(data.video).to.exist; - }); + it('Request params - should handle banner, video and native format in single adunit', function() { + let request = spec.buildRequests(bannerVideoAndNativeBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; - it('Request params - should not contain banner imp if mediaTypes.banner is not present and sizes is specified in bid.sizes', function() { - delete bannerAndVideoBidRequests[0].mediaTypes.banner; - bannerAndVideoBidRequests[0].params.sizes = [300, 250]; + expect(data.banner).to.exist; + expect(data.banner.w).to.equal(300); + expect(data.banner.h).to.equal(250); + expect(data.banner.format).to.exist; + expect(data.banner.format.length).to.equal(bannerAndNativeBidRequests[0].mediaTypes.banner.sizes.length); - let request = spec.buildRequests(bannerAndVideoBidRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.banner).to.not.exist; - }); + expect(data.video).to.exist; + expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]); - it('Request params - should handle banner and native format in single adunit', function() { - let request = spec.buildRequests(bannerAndNativeBidRequests, { - auctionId: 'new-auction-id' + expect(data.native).to.exist; + expect(data.native.request).to.exist; }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.banner).to.exist; - expect(data.banner.w).to.equal(300); - expect(data.banner.h).to.equal(250); - expect(data.banner.format).to.exist; - expect(data.banner.format.length).to.equal(bannerAndNativeBidRequests[0].mediaTypes.banner.sizes.length); + it('Request params - should handle video and native format in single adunit', function() { + let request = spec.buildRequests(videoAndNativeBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; - expect(data.native).to.exist; - expect(data.native.request).to.exist; - }); + expect(data.video).to.exist; + expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]); - it('Request params - should handle video and native format in single adunit', function() { - let request = spec.buildRequests(videoAndNativeBidRequests, { - auctionId: 'new-auction-id' + expect(data.native).to.exist; + expect(data.native.request).to.exist; }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.video).to.exist; - expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]); + it('Request params - banner and video req in single adslot - should ignore banner imp if banner size is set to fluid and send video imp object', function () { + /* Adslot configured for banner and video. + banner size is set to [['fluid'], [300, 250]] + adslot specifies a size as 300x250 + => banner imp object should have primary w and h set to 300 and 250. fluid is ignored + */ + bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid'], [160, 600]]; - expect(data.native).to.exist; - expect(data.native.request).to.exist; - }); + let request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; - it('Request params - should handle banner, video and native format in single adunit', function() { - let request = spec.buildRequests(bannerVideoAndNativeBidRequests, { - auctionId: 'new-auction-id' - }); - let data = JSON.parse(request.data); - data = data.imp[0]; + expect(data.banner).to.exist; + expect(data.banner.w).to.equal(300); + expect(data.banner.h).to.equal(250); + expect(data.banner.format).to.exist; + expect(data.banner.format[0].w).to.equal(160); + expect(data.banner.format[0].h).to.equal(600); + + /* Adslot configured for banner and video. + banner size is set to [['fluid'], [300, 250]] + adslot does not specify any size + => banner imp object should have primary w and h set to 300 and 250. fluid is ignored + */ + bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid'], [160, 600]]; + bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo'; + + request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + data = JSON.parse(request.data); + data = data.imp[0]; - expect(data.banner).to.exist; - expect(data.banner.w).to.equal(300); - expect(data.banner.h).to.equal(250); - expect(data.banner.format).to.exist; - expect(data.banner.format.length).to.equal(bannerAndNativeBidRequests[0].mediaTypes.banner.sizes.length); + expect(data.banner).to.exist; + expect(data.banner.w).to.equal(160); + expect(data.banner.h).to.equal(600); + expect(data.banner.format).to.not.exist; + + /* Adslot configured for banner and video. + banner size is set to [[728 90], ['fluid'], [300, 250]] + adslot does not specify any size + => banner imp object should have primary w and h set to 728 and 90. + banner.format should have 300, 250 set in it + fluid is ignore + */ + + bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [[728, 90], ['fluid'], [300, 250]]; + request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + data = JSON.parse(request.data); + data = data.imp[0]; - expect(data.video).to.exist; - expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]); + expect(data.banner).to.exist; + expect(data.banner.w).to.equal(728); + expect(data.banner.h).to.equal(90); + expect(data.banner.format).to.exist; + expect(data.banner.format[0].w).to.equal(300); + expect(data.banner.format[0].h).to.equal(250); + + /* Adslot configured for banner and video. + banner size is set to [['fluid']] + adslot does not specify any size + => banner object should not be sent in the request. only video should be sent. + */ + + bannerAndVideoBidRequests[0].mediaTypes.banner.sizes = [['fluid']]; + request = spec.buildRequests(bannerAndVideoBidRequests, { + auctionId: 'new-auction-id' + }); + data = JSON.parse(request.data); + data = data.imp[0]; - expect(data.native).to.exist; - expect(data.native.request).to.exist; - }); + expect(data.banner).to.not.exist; + expect(data.video).to.exist; + }); - it('Request params - should not add banner object if mediaTypes.banner is missing, but adunits.sizes is present', function() { - delete bannerAndNativeBidRequests[0].mediaTypes.banner; - bannerAndNativeBidRequests[0].sizes = [729, 90]; + it('Request params - video and native multiformat request - should have native object incase of invalid config present', function() { + videoAndNativeBidRequests[0].mediaTypes.native = { + title: { required: true }, + image: { required: true }, + sponsoredBy: { required: true }, + clickUrl: { required: true } + }; + videoAndNativeBidRequests[0].nativeParams = { + title: { required: true }, + image: { required: true }, + sponsoredBy: { required: true }, + clickUrl: { required: true } + } + let request = spec.buildRequests(videoAndNativeBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; - let request = spec.buildRequests(bannerAndNativeBidRequests, { - auctionId: 'new-auction-id' + expect(data.video).to.exist; + expect(data.native).to.exist; }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.banner).to.not.exist; + it('should build video impression if video params are present in adunit.mediaTypes instead of bid.params', function() { + let videoReq = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890', + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0', + 'sizes': [ + [640, 480] + ], + 'bidId': '21b59b1353ba82', + 'bidderRequestId': '1a08245305e6dd', + 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }] + let request = spec.buildRequests(videoReq, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; + expect(data.video).to.exist; + }); - expect(data.native).to.exist; - expect(data.native.request).to.exist; - }); + it('should build video impression with overwriting video params present in adunit.mediaTypes with bid.params', function() { + let videoReq = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5890', + 'video': { + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0', + 'sizes': [ + [640, 480] + ], + 'bidId': '21b59b1353ba82', + 'bidderRequestId': '1a08245305e6dd', + 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }] + let request = spec.buildRequests(videoReq, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + data = data.imp[0]; - it('Request params - banner and native multiformat request - should not have native object incase of invalid config present', function() { - bannerAndNativeBidRequests[0].mediaTypes.native = { - title: { required: true }, - image: { required: true }, - sponsoredBy: { required: true }, - clickUrl: { required: true } - }; - bannerAndNativeBidRequests[0].nativeParams = { - title: { required: true }, - image: { required: true }, - sponsoredBy: { required: true }, - clickUrl: { required: true } - } - let request = spec.buildRequests(bannerAndNativeBidRequests, { - auctionId: 'new-auction-id' + expect(data.video).to.exist; + expect(data.video.linearity).to.equal(1); }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.banner).to.exist; - expect(data.native).to.not.exist; - }); + it('Request params check for video ad', function () { + let request = spec.buildRequests(videoBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0].tagid).to.equal('Div1'); + expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); + expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); + expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); + expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); + expect(data.imp[0]['video']['startdelay']).to.equal(videoBidRequests[0].params.video['startdelay']); + + expect(data.imp[0]['video']['playbackmethod']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['playbackmethod'][0]).to.equal(videoBidRequests[0].params.video['playbackmethod'][0]); + expect(data.imp[0]['video']['playbackmethod'][1]).to.equal(videoBidRequests[0].params.video['playbackmethod'][1]); + + expect(data.imp[0]['video']['api']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['api'][0]).to.equal(videoBidRequests[0].params.video['api'][0]); + expect(data.imp[0]['video']['api'][1]).to.equal(videoBidRequests[0].params.video['api'][1]); + + expect(data.imp[0]['video']['protocols']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['protocols'][0]).to.equal(videoBidRequests[0].params.video['protocols'][0]); + expect(data.imp[0]['video']['protocols'][1]).to.equal(videoBidRequests[0].params.video['protocols'][1]); + + expect(data.imp[0]['video']['battr']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['battr'][0]).to.equal(videoBidRequests[0].params.video['battr'][0]); + expect(data.imp[0]['video']['battr'][1]).to.equal(videoBidRequests[0].params.video['battr'][1]); + + expect(data.imp[0]['video']['linearity']).to.equal(videoBidRequests[0].params.video['linearity']); + expect(data.imp[0]['video']['placement']).to.equal(videoBidRequests[0].params.video['placement']); + expect(data.imp[0]['video']['plcmt']).to.equal(videoBidRequests[0].params.video['plcmt']); + expect(data.imp[0]['video']['minbitrate']).to.equal(videoBidRequests[0].params.video['minbitrate']); + expect(data.imp[0]['video']['maxbitrate']).to.equal(videoBidRequests[0].params.video['maxbitrate']); + + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + }); + } - it('Request params - video and native multiformat request - should not have native object incase of invalid config present', function() { - videoAndNativeBidRequests[0].mediaTypes.native = { - title: { required: true }, - image: { required: true }, - sponsoredBy: { required: true }, - clickUrl: { required: true } - }; - videoAndNativeBidRequests[0].nativeParams = { - title: { required: true }, - image: { required: true }, - sponsoredBy: { required: true }, - clickUrl: { required: true } - } - let request = spec.buildRequests(videoAndNativeBidRequests, { - auctionId: 'new-auction-id' + describe('GPP', function() { + it('Request params check with GPP Consent', function () { + let bidRequest = { + gppConsent: { + 'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', + 'fullGppData': { + 'sectionId': 3, + 'gppVersion': 1, + 'sectionList': [ + 5, + 7 + ], + 'applicableSections': [ + 5 + ], + 'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', + 'pingData': { + 'cmpStatus': 'loaded', + 'gppVersion': '1.0', + 'cmpDisplayStatus': 'visible', + 'supportedAPIs': [ + 'tcfca', + 'usnat', + 'usca', + 'usva', + 'usco', + 'usut', + 'usct' + ], + 'cmpId': 31 + }, + 'eventName': 'sectionChange' + }, + 'applicableSections': [ + 5 + ], + 'apiVersion': 1 + } + }; + let request = spec.buildRequests(bidRequests, bidRequest); + let data = JSON.parse(request.data); + expect(data.regs.gpp).to.equal('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN'); + expect(data.regs.gpp_sid[0]).to.equal(5); }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.video).to.exist; - expect(data.native).to.not.exist; - }); + it('Request params check without GPP Consent', function () { + let bidRequest = {}; + let request = spec.buildRequests(bidRequests, bidRequest); + let data = JSON.parse(request.data); + expect(data.regs).to.equal(undefined); + }); - it('should build video impression if video params are present in adunit.mediaTypes instead of bid.params', function() { - let videoReq = [{ - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890', - }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'mimes': ['video/flv'], - 'skip': 1, - 'linearity': 2 + it('Request params check with GPP Consent read from ortb2', function () { + let bidRequest = { + ortb2: { + regs: { + 'gpp': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', + 'gpp_sid': [ + 5 + ] + } } - }, - 'adUnitCode': 'video1', - 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0', - 'sizes': [ - [640, 480] - ], - 'bidId': '21b59b1353ba82', - 'bidderRequestId': '1a08245305e6dd', - 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }] - let request = spec.buildRequests(videoReq, { - auctionId: 'new-auction-id' + }; + let request = spec.buildRequests(bidRequests, bidRequest); + let data = JSON.parse(request.data); + expect(data.regs.gpp).to.equal('DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN'); + expect(data.regs.gpp_sid[0]).to.equal(5); }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.video).to.exist; }); - it('should build video impression with overwriting video params present in adunit.mediaTypes with bid.params', function() { - let videoReq = [{ - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5890', - 'video': { - 'mimes': ['video/mp4'], - 'protocols': [1, 2, 5], - 'linearity': 1 - } - }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'mimes': ['video/flv'], - 'skip': 1, - 'linearity': 2 - } - }, - 'adUnitCode': 'video1', - 'transactionId': 'adc36682-887c-41e9-9848-8b72c08332c0', - 'sizes': [ - [640, 480] - ], - 'bidId': '21b59b1353ba82', - 'bidderRequestId': '1a08245305e6dd', - 'auctionId': 'bad3a743-7491-4d19-9a96-b0a69dd24a67', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }] - let request = spec.buildRequests(videoReq, { - auctionId: 'new-auction-id' + describe('Fledge', function() { + it('should not send imp.ext.ae when FLEDGE is disabled, ', function () { + let bidRequest = Object.assign([], bidRequests); + bidRequest[0].ortb2Imp = { + ext: { ae: 1 } + }; + const req = spec.buildRequests(bidRequest, { ...bidRequest, fledgeEnabled: false }); + let data = JSON.parse(req.data); + if (data.imp[0].ext) { + expect(data.imp[0].ext).to.not.have.property('ae'); + } }); - let data = JSON.parse(request.data); - data = data.imp[0]; - expect(data.video).to.exist; - expect(data.video.linearity).to.equal(1); + it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + bidRequest[0].ortb2Imp = { + ext: { ae: 1 } + }; + const req = spec.buildRequests(bidRequest, { ...bidRequest, fledgeEnabled: true }); + let data = JSON.parse(req.data); + expect(data.imp[0].ext.ae).to.equal(1); + }); }); }); @@ -3130,6 +3062,109 @@ describe('PubMatic adapter', function () { }); }); + describe('Request param acat checking', function() { + let multipleBidRequests = [ + { + bidder: 'pubmatic', + params: { + publisherId: '301', + adSlot: '/15671365/DMDemo@300x250:0', + kadfloor: '1.2', + pmzoneid: 'aabc, ddef', + kadpageurl: 'www.publisher.com', + yob: '1986', + gender: 'M', + lat: '12.3', + lon: '23.7', + wiid: '1234567890', + profId: '100', + verId: '200', + currency: 'AUD', + dctr: 'key1=val1|key2=val2,!val3' + }, + placementCode: '/19968336/header-bid-tag-1', + sizes: [[300, 250], [300, 600]], + bidId: '23acc48ad47af5', + requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + }, + { + bidder: 'pubmatic', + params: { + publisherId: '301', + adSlot: '/15671365/DMDemo@300x250:0', + kadfloor: '1.2', + pmzoneid: 'aabc, ddef', + kadpageurl: 'www.publisher.com', + yob: '1986', + gender: 'M', + lat: '12.3', + lon: '23.7', + wiid: '1234567890', + profId: '100', + verId: '200', + currency: 'GBP', + dctr: 'key1=val3|key2=val1,!val3|key3=val123' + }, + placementCode: '/19968336/header-bid-tag-1', + sizes: [[300, 250], [300, 600]], + bidId: '23acc48ad47af5', + requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + } + ]; + + it('acat: pass only strings', function() { + multipleBidRequests[0].params.acat = [1, 2, 3, 'IAB1', 'IAB2']; + let request = spec.buildRequests(multipleBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.ext.acat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']); + }); + + it('acat: trim the strings', function() { + multipleBidRequests[0].params.acat = [' IAB1 ', ' IAB2 ']; + let request = spec.buildRequests(multipleBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.ext.acat).to.exist.and.to.deep.equal(['IAB1', 'IAB2']); + }); + + it('acat: pass only unique strings', function() { + multipleBidRequests[0].params.acat = ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB2']; + multipleBidRequests[1].params.acat = ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB3']; + let request = spec.buildRequests(multipleBidRequests, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.ext.acat).to.exist.and.to.deep.equal(['IAB1', 'IAB2', 'IAB3']); + }); + it('ortb2.ext.prebid.bidderparams.pubmatic.acat should be passed in request payload', function() { + const ortb2 = { + ext: { + prebid: { + bidderparams: { + pubmatic: { + acat: ['IAB1', 'IAB2', 'IAB1', 'IAB2', 'IAB1', 'IAB2'] + } + } + } + } + }; + const request = spec.buildRequests(bidRequests, { + auctionId: 'new-auction-id', + bidderCode: 'pubmatic', + ortb2 + }); + let data = JSON.parse(request.data); + expect(data.ext.acat).to.deep.equal(['IAB1', 'IAB2']); + }); + }); + describe('Request param bcat checking', function() { let multipleBidRequests = [ { @@ -3231,6 +3266,20 @@ describe('PubMatic adapter', function () { }); let data = JSON.parse(request.data); expect(data.bcat).to.deep.equal(undefined); + }); + + it('ortb2.bcat should merged with slot level bcat param', function() { + multipleBidRequests[0].params.bcat = ['IAB-1', 'IAB-2']; + const ortb2 = { + bcat: ['IAB-3', 'IAB-4'] + }; + const request = spec.buildRequests(multipleBidRequests, { + auctionId: 'new-auction-id', + bidderCode: 'pubmatic', + ortb2 + }); + let data = JSON.parse(request.data); + expect(data.bcat).to.deep.equal(['IAB-1', 'IAB-2', 'IAB-3', 'IAB-4']); }); }); @@ -3243,7 +3292,7 @@ describe('PubMatic adapter', function () { let response = spec.interpretResponse(bidResponses, request); expect(response).to.be.an('array').with.length.above(0); expect(response[0].requestId).to.equal(bidResponses.body.seatbid[0].bid[0].impid); - expect(response[0].cpm).to.equal((bidResponses.body.seatbid[0].bid[0].price).toFixed(2)); + expect(response[0].cpm).to.equal(parseFloat((bidResponses.body.seatbid[0].bid[0].price).toFixed(2))); expect(response[0].width).to.equal(bidResponses.body.seatbid[0].bid[0].w); expect(response[0].height).to.equal(bidResponses.body.seatbid[0].bid[0].h); if (bidResponses.body.seatbid[0].bid[0].crid) { @@ -3257,7 +3306,8 @@ describe('PubMatic adapter', function () { expect(response[0].ttl).to.equal(300); expect(response[0].meta.networkId).to.equal(123); expect(response[0].adserverTargeting.hb_buyid_pubmatic).to.equal('BUYER-ID-987'); - expect(response[0].meta.buyerId).to.equal(976); + expect(response[0].meta.buyerId).to.equal('seat-id'); + expect(response[0].meta.dchain).to.equal('dchain'); expect(response[0].meta.clickUrl).to.equal('blackrock.com'); expect(response[0].meta.advertiserDomains[0]).to.equal('blackrock.com'); expect(response[0].referrer).to.include(data.site.ref); @@ -3267,7 +3317,7 @@ describe('PubMatic adapter', function () { expect(response[0].partnerImpId).to.equal(bidResponses.body.seatbid[0].bid[0].id); expect(response[1].requestId).to.equal(bidResponses.body.seatbid[1].bid[0].impid); - expect(response[1].cpm).to.equal((bidResponses.body.seatbid[1].bid[0].price).toFixed(2)); + expect(response[1].cpm).to.equal(parseFloat((bidResponses.body.seatbid[1].bid[0].price).toFixed(2))); expect(response[1].width).to.equal(bidResponses.body.seatbid[1].bid[0].w); expect(response[1].height).to.equal(bidResponses.body.seatbid[1].bid[0].h); if (bidResponses.body.seatbid[1].bid[0].crid) { @@ -3322,16 +3372,17 @@ describe('PubMatic adapter', function () { data.imp[0].id = '2a5571261281d4'; request.data = JSON.stringify(data); let response = spec.interpretResponse(nativeBidResponse, request); + let assets = response[0].native.ortb.assets; expect(response).to.be.an('array').with.length.above(0); expect(response[0].native).to.exist.and.to.be.an('object'); expect(response[0].mediaType).to.exist.and.to.equal('native'); - expect(response[0].native.title).to.exist.and.to.be.an('string'); - expect(response[0].native.image).to.exist.and.to.be.an('object'); - expect(response[0].native.image.url).to.exist.and.to.be.an('string'); - expect(response[0].native.image.height).to.exist; - expect(response[0].native.image.width).to.exist; - expect(response[0].native.sponsoredBy).to.exist.and.to.be.an('string'); - expect(response[0].native.clickUrl).to.exist.and.to.be.an('string'); + expect(assets).to.be.an('array').with.length.above(0); + expect(assets[0].title).to.exist.and.to.be.an('object'); + expect(assets[1].img).to.exist.and.to.be.an('object'); + expect(assets[1].img.url).to.exist.and.to.be.an('string'); + expect(assets[1].img.h).to.exist; + expect(assets[1].img.w).to.exist; + expect(assets[2].data).to.exist.and.to.be.an('object'); }); it('should check for valid banner mediaType in case of multiformat request', function() { @@ -3343,14 +3394,6 @@ describe('PubMatic adapter', function () { expect(response[0].mediaType).to.equal('banner'); }); - it('should check for valid video mediaType in case of multiformat request', function() { - let request = spec.buildRequests(videoBidRequests, { - auctionId: 'new-auction-id' - }); - let response = spec.interpretResponse(videoBidResponse, request); - expect(response[0].mediaType).to.equal('video'); - }); - it('should check for valid native mediaType in case of multiformat request', function() { let request = spec.buildRequests(nativeBidRequests, { auctionId: 'new-auction-id' @@ -3360,28 +3403,6 @@ describe('PubMatic adapter', function () { expect(response[0].mediaType).to.equal('native'); }); - it('should assign renderer if bid is video and request is for outstream', function() { - let request = spec.buildRequests(outstreamBidRequest, validOutstreamBidRequest); - let response = spec.interpretResponse(outstreamVideoBidResponse, request); - expect(response[0].renderer).to.exist; - }); - - it('should not assign renderer if bidderRequest is not present', function() { - let request = spec.buildRequests(outstreamBidRequest, { - auctionId: 'new-auction-id' - }); - let response = spec.interpretResponse(outstreamVideoBidResponse, request); - expect(response[0].renderer).to.not.exist; - }); - - it('should not assign renderer if bid is video and request is for instream', function() { - let request = spec.buildRequests(videoBidRequests, { - auctionId: 'new-auction-id' - }); - let response = spec.interpretResponse(videoBidResponse, request); - expect(response[0].renderer).to.not.exist; - }); - it('should not assign renderer if bid is native', function() { let request = spec.buildRequests(nativeBidRequests, { auctionId: 'new-auction-id' @@ -3398,154 +3419,349 @@ describe('PubMatic adapter', function () { expect(response[0].renderer).to.not.exist; }); - it('should assign mediaType by reading bid.ext.mediaType', function() { - let newvideoRequests = [{ - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5670', - 'video': { - 'mimes': ['video/mp4'], - 'skippable': true, - 'protocols': [1, 2, 5], - 'linearity': 1 - } - }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'mimes': ['video/flv'], - 'skippable': false, - 'skip': 1, - 'linearity': 2 - } - }, - 'adUnitCode': 'video1', - 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', - 'sizes': [ - [640, 480] - ], - 'bidId': '2c95df014cfe97', - 'bidderRequestId': '1fe59391566442', - 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }]; - let newvideoBidResponses = { - 'body': { - 'id': '1621441141473', - 'cur': 'USD', - 'customdata': 'openrtb1', - 'ext': { - 'buyid': 'myBuyId' + if (FEATURES.VIDEO) { + it('should check for valid video mediaType in case of multiformat request', function() { + let request = spec.buildRequests(videoBidRequests, { + auctionId: 'new-auction-id' + }); + let response = spec.interpretResponse(videoBidResponse, request); + expect(response[0].mediaType).to.equal('video'); + }); + + it('should assign renderer if bid is video and request is for outstream', function() { + let request = spec.buildRequests(outstreamBidRequest, validOutstreamBidRequest); + let response = spec.interpretResponse(outstreamVideoBidResponse, request); + expect(response[0].renderer).to.exist; + }); + + it('should not assign renderer if bidderRequest is not present', function() { + let request = spec.buildRequests(outstreamBidRequest, { + auctionId: 'new-auction-id' + }); + let response = spec.interpretResponse(outstreamVideoBidResponse, request); + expect(response[0].renderer).to.not.exist; + }); + + it('should not assign renderer if bid is video and request is for instream', function() { + let request = spec.buildRequests(videoBidRequests, { + auctionId: 'new-auction-id' + }); + let response = spec.interpretResponse(videoBidResponse, request); + expect(response[0].renderer).to.not.exist; + }); + + it('should assign mediaType by reading bid.ext.mediaType', function() { + let newvideoRequests = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5670', + 'video': { + 'mimes': ['video/mp4'], + 'skippable': true, + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } }, - 'seatbid': [{ - 'bid': [{ - 'id': '2c95df014cfe97', - 'impid': '2c95df014cfe97', - 'price': 4.2, - 'cid': 'test1', - 'crid': 'test2', - 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", - 'w': 0, - 'h': 0, - 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420', + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }]; + let newvideoBidResponses = { + 'body': { + 'id': '1621441141473', + 'cur': 'USD', + 'customdata': 'openrtb1', + 'ext': { + 'buyid': 'myBuyId' + }, + 'seatbid': [{ + 'bid': [{ + 'id': '2c95df014cfe97', + 'impid': '2c95df014cfe97', + 'price': 4.2, + 'cid': 'test1', + 'crid': 'test2', + 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", + 'w': 0, + 'h': 0, + 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420', + 'ext': { + 'bidtype': 1 + } + }], 'ext': { - 'bidtype': 1 + 'buyid': 'myBuyId' } - }], + }] + }, + 'headers': {} + } + let newrequest = spec.buildRequests(newvideoRequests, { + auctionId: 'new-auction-id' + }); + let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); + expect(newresponse[0].mediaType).to.equal('video') + }) + + it('should assign mediaType even if bid.ext.mediaType does not exists', function() { + let newvideoRequests = [{ + 'bidder': 'pubmatic', + 'params': { + 'adSlot': 'SLOT_NHB1@728x90', + 'publisherId': '5670', + 'video': { + 'mimes': ['video/mp4'], + 'skippable': true, + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }]; + let newvideoBidResponses = { + 'body': { + 'id': '1621441141473', + 'cur': 'USD', + 'customdata': 'openrtb1', 'ext': { 'buyid': 'myBuyId' - } - }] - }, - 'headers': {} - } - let newrequest = spec.buildRequests(newvideoRequests, { - auctionId: 'new-auction-id' + }, + 'seatbid': [{ + 'bid': [{ + 'id': '2c95df014cfe97', + 'impid': '2c95df014cfe97', + 'price': 4.2, + 'cid': 'test1', + 'crid': 'test2', + 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", + 'w': 0, + 'h': 0, + 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420' + }], + 'ext': { + 'buyid': 'myBuyId' + } + }] + }, + 'headers': {} + } + let newrequest = spec.buildRequests(newvideoRequests, { + auctionId: 'new-auction-id' + }); + let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); + expect(newresponse[0].mediaType).to.equal('video') }); - let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); - expect(newresponse[0].mediaType).to.equal('video') - }) + } + }); - it('should assign mediaType even if bid.ext.mediaType does not exists', function() { - let newvideoRequests = [{ - 'bidder': 'pubmatic', - 'params': { - 'adSlot': 'SLOT_NHB1@728x90', - 'publisherId': '5670', - 'video': { - 'mimes': ['video/mp4'], - 'skippable': true, - 'protocols': [1, 2, 5], - 'linearity': 1 + describe('Fledge Auction config Response', function () { + let response; + let bidRequestConfigs = [ + { + bidder: 'pubmatic', + mediaTypes: { + banner: { + sizes: [[728, 90], [160, 600]] } }, - 'mediaTypes': { - 'video': { - 'playerSize': [ - [640, 480] - ], - 'protocols': [1, 2, 5], - 'context': 'instream', - 'mimes': ['video/flv'], - 'skippable': false, - 'skip': 1, - 'linearity': 2 + params: { + publisherId: '5670', + adSlot: '/15671365/DMDemo@300x250:0', + kadfloor: '1.2', + pmzoneid: 'aabc, ddef', + kadpageurl: 'www.publisher.com', + yob: '1986', + gender: 'M', + lat: '12.3', + lon: '23.7', + wiid: '1234567890', + profId: '100', + verId: '200', + currency: 'AUD', + dctr: 'key1:val1,val2|key2:val1' + }, + placementCode: '/19968336/header-bid-tag-1', + sizes: [[300, 250], [300, 600]], + bidId: 'test_bid_id', + requestId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + ortb2Imp: { + ext: { + tid: '92489f71-1bf2-49a0-adf9-000cea934729', + ae: 1 } }, - 'adUnitCode': 'video1', - 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', - 'sizes': [ - [640, 480] - ], - 'bidId': '2c95df014cfe97', - 'bidderRequestId': '1fe59391566442', - 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', - 'src': 'client', - 'bidRequestsCount': 1, - 'bidderRequestsCount': 1, - 'bidderWinsCount': 0 - }]; - let newvideoBidResponses = { - 'body': { - 'id': '1621441141473', - 'cur': 'USD', - 'customdata': 'openrtb1', - 'ext': { - 'buyid': 'myBuyId' - }, - 'seatbid': [{ - 'bid': [{ - 'id': '2c95df014cfe97', - 'impid': '2c95df014cfe97', - 'price': 4.2, - 'cid': 'test1', - 'crid': 'test2', - 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", - 'w': 0, - 'h': 0, - 'dealId': 'ASEA-MS-KLY-TTD-DESKTOP-ID-VID-6S-030420' - }], - 'ext': { - 'buyid': 'myBuyId' + } + ]; + + let bidRequest = spec.buildRequests(bidRequestConfigs, {}); + let bidResponse = { + seatbid: [{ + bid: [{ + impid: 'test_bid_id', + price: 2, + w: 728, + h: 250, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup' + }] + }], + cur: 'AUS', + ext: { + fledge_auction_configs: { + 'test_bid_id': { + seller: 'ads.pubmatic.com', + interestGroupBuyers: ['dsp1.com'], + sellerTimeout: 0, + perBuyerSignals: { + 'dsp1.com': { + bid_macros: 0.1, + disallowed_adv_ids: [ + '5678', + '5890' + ], + } } - }] - }, - 'headers': {} + } + } } - let newrequest = spec.buildRequests(newvideoRequests, { - auctionId: 'new-auction-id' - }); - let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); - expect(newresponse[0].mediaType).to.equal('video') - }) + }; + + response = spec.interpretResponse({ body: bidResponse }, bidRequest); + it('should return FLEDGE auction_configs alongside bids', function () { + expect(response).to.have.property('bids'); + expect(response).to.have.property('fledgeAuctionConfigs'); + expect(response.fledgeAuctionConfigs.length).to.equal(1); + expect(response.fledgeAuctionConfigs[0].bidId).to.equal('test_bid_id'); + }); + }); + + describe('Preapare metadata', function () { + it('Should copy all fields from ext to meta', function () { + const bid = { + 'adomain': [ + 'mystartab.com' + ], + cat: ['IAB_CATEGORY'], + ext: { + advid: '12', + 'dspid': 6, + 'deal_channel': 1, + 'bidtype': 0, + advertiserId: 'adid', + // networkName: 'nwnm', + // primaryCatId: 'pcid', + // advertiserName: 'adnm', + // agencyId: 'agid', + // agencyName: 'agnm', + // brandId: 'brid', + // brandName: 'brnm', + // dchain: 'dc', + // demandSource: 'ds', + // secondaryCatIds: ['secondaryCatIds'] + } + }; + + const br = {}; + prepareMetaObject(br, bid, null); + expect(br.meta.networkId).to.equal(6); // dspid + expect(br.meta.buyerId).to.equal('12'); // adid + expect(br.meta.advertiserId).to.equal('12'); + // expect(br.meta.networkName).to.equal('nwnm'); + expect(br.meta.primaryCatId).to.equal('IAB_CATEGORY'); + // expect(br.meta.advertiserName).to.equal('adnm'); + expect(br.meta.agencyId).to.equal('12'); + // expect(br.meta.agencyName).to.equal('agnm'); + expect(br.meta.brandId).to.equal('mystartab.com'); + // expect(br.meta.brandName).to.equal('brnm'); + // expect(br.meta.dchain).to.equal('dc'); + expect(br.meta.demandSource).to.equal(6); + expect(br.meta.secondaryCatIds).to.be.an('array').with.length.above(0); + expect(br.meta.secondaryCatIds[0]).to.equal('IAB_CATEGORY'); + expect(br.meta.advertiserDomains).to.be.an('array').with.length.above(0); // adomain + expect(br.meta.clickUrl).to.equal('mystartab.com'); // adomain + }); + + it('Should be empty, when ext and adomain is absent in bid object', function () { + const bid = {}; + const br = {}; + prepareMetaObject(br, bid, null); + expect(Object.keys(br.meta).length).to.equal(0); + }); + + it('Should be empty, when ext and adomain will not have properties', function () { + const bid = { + 'adomain': [], + ext: {} + }; + const br = {}; + prepareMetaObject(br, bid, null); + expect(Object.keys(br.meta).length).to.equal(0); + expect(br.meta.advertiserDomains).to.equal(undefined); // adomain + expect(br.meta.clickUrl).to.equal(undefined); // adomain + }); + + it('Should have buyerId,advertiserId, agencyId value of site ', function () { + const bid = { + 'adomain': [], + ext: { + advid: '12', + } + }; + const br = {}; + prepareMetaObject(br, bid, '5100'); + expect(br.meta.buyerId).to.equal('5100'); // adid + expect(br.meta.advertiserId).to.equal('5100'); + expect(br.meta.agencyId).to.equal('5100'); + }); }); describe('getUserSyncs', function() { @@ -3643,206 +3859,106 @@ describe('PubMatic adapter', function () { type: 'image', url: `${syncurl_image}&gdpr=1&gdpr_consent=foo&us_privacy=1NYN&coppa=1` }]); }); - }); - describe('JW player segment data for S2S', function() { - let sandbox = sinon.sandbox.create(); - beforeEach(function () { - sandbox = sinon.sandbox.create(); - }); - afterEach(function() { - sandbox.restore(); - }); - it('Should append JW player segment data to dctr values in auction endpoint', function() { - var videoAdUnit = { - 'bidderCode': 'pubmatic', - 'bids': [ - { - 'bidder': 'pubmatic', - 'params': { - 'publisherId': '156276', - 'adSlot': 'pubmatic_video2', - 'dctr': 'key1=123|key2=345', - 'pmzoneid': '1243', - 'video': { - 'mimes': ['video/mp4', 'video/x-flv'], - 'skippable': true, - 'minduration': 5, - 'maxduration': 30, - 'startdelay': 5, - 'playbackmethod': [1, 3], - 'api': [1, 2], - 'protocols': [2, 3], - 'battr': [13, 14], - 'linearity': 1, - 'placement': 2, - 'minbitrate': 10, - 'maxbitrate': 10 - } - }, - 'rtd': { - 'jwplayer': { - 'targeting': { - 'segments': ['80011026', '80011035'], - 'content': { - 'id': 'jw_d9J2zcaA' - } - } - } - }, - 'bid_id': '17a6771be26cc4', - 'ortb2Imp': { - 'ext': { - 'data': { - 'pbadslot': 'abcd', - 'jwTargeting': { - 'playerID': 'myElement1', - 'mediaID': 'd9J2zcaA' - } - } - } - } - } - ], - 'auctionStart': 1630923178417, - 'timeout': 1000, - 'src': 's2s' - } + describe('GPP', function() { + it('should return userSync url without Gpp consent if gppConsent is undefined', () => { + const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, undefined); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); - spec.transformBidParams(bidRequests[0].params, true, videoAdUnit); - expect(bidRequests[0].params.dctr).to.equal('key1:val1,val2|key2:val1|jw-id=jw_d9J2zcaA|jw-80011026=1|jw-80011035=1'); - }); - it('Should send only JW player segment data in auction endpoint, if dctr is missing', function() { - var videoAdUnit = { - 'bidderCode': 'pubmatic', - 'bids': [ - { - 'bidder': 'pubmatic', - 'params': { - 'publisherId': '156276', - 'adSlot': 'pubmatic_video2', - 'dctr': 'key1=123|key2=345', - 'pmzoneid': '1243', - 'video': { - 'mimes': ['video/mp4', 'video/x-flv'], - 'skippable': true, - 'minduration': 5, - 'maxduration': 30, - 'startdelay': 5, - 'playbackmethod': [1, 3], - 'api': [1, 2], - 'protocols': [2, 3], - 'battr': [13, 14], - 'linearity': 1, - 'placement': 2, - 'minbitrate': 10, - 'maxbitrate': 10 - } - }, - 'rtd': { - 'jwplayer': { - 'targeting': { - 'segments': ['80011026', '80011035'], - 'content': { - 'id': 'jw_d9J2zcaA' - } - } - } - }, - 'bid_id': '17a6771be26cc4', - 'ortb2Imp': { - 'ext': { - 'data': { - 'pbadslot': 'abcd', - 'jwTargeting': { - 'playerID': 'myElement1', - 'mediaID': 'd9J2zcaA' - } - } - } - } - } - ], - 'auctionStart': 1630923178417, - 'timeout': 1000, - 'src': 's2s' - } + it('should return userSync url without Gpp consent if gppConsent.gppString is undefined', () => { + const gppConsent = { applicableSections: ['5'] }; + const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); - delete bidRequests[0].params.dctr; - spec.transformBidParams(bidRequests[0].params, true, videoAdUnit); - expect(bidRequests[0].params.dctr).to.equal('jw-id=jw_d9J2zcaA|jw-80011026=1|jw-80011035=1'); + it('should return userSync url without Gpp consent if gppConsent.applicableSections is undefined', () => { + const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN' }; + const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); + + it('should return userSync url without Gpp consent if gppConsent.applicableSections is an empty array', () => { + const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [] }; + const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}` + }]); + }); + + it('should concatenate gppString and applicableSections values in the returned userSync iframe url', () => { + const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [5] }; + const result = spec.getUserSyncs({iframeEnabled: true}, undefined, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'iframe', url: `${syncurl_iframe}&gpp=${encodeURIComponent(gppConsent.gppString)}&gpp_sid=${encodeURIComponent(gppConsent.applicableSections)}` + }]); + }); + + it('should concatenate gppString and applicableSections values in the returned userSync image url', () => { + const gppConsent = { gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', applicableSections: [5] }; + const result = spec.getUserSyncs({iframeEnabled: false}, undefined, undefined, undefined, gppConsent); + expect(result).to.deep.equal([{ + type: 'image', url: `${syncurl_image}&gpp=${encodeURIComponent(gppConsent.gppString)}&gpp_sid=${encodeURIComponent(gppConsent.applicableSections)}` + }]); + }); }); + }); - it('Should not send any JW player segment data in auction endpoint, if it is not available', function() { - var videoAdUnit = { - 'bidderCode': 'pubmatic', - 'bids': [ - { - 'bidder': 'pubmatic', - 'params': { - 'publisherId': '156276', - 'adSlot': 'pubmatic_video2', - 'dctr': 'key1=123|key2=345', - 'pmzoneid': '1243', - 'video': { - 'mimes': ['video/mp4', 'video/x-flv'], - 'skippable': true, - 'minduration': 5, - 'maxduration': 30, - 'startdelay': 5, - 'playbackmethod': [1, 3], - 'api': [1, 2], - 'protocols': [2, 3], - 'battr': [13, 14], - 'linearity': 1, - 'placement': 2, - 'minbitrate': 10, - 'maxbitrate': 10 - } - }, - 'bid_id': '17a6771be26cc4', - 'ortb2Imp': { - 'ext': { - 'data': { - 'pbadslot': 'abcd', - 'jwTargeting': { - 'playerID': 'myElement1', - 'mediaID': 'd9J2zcaA' - } - } - } - } - } - ], - 'auctionStart': 1630923178417, - 'timeout': 1000, - 'src': 's2s' + if (FEATURES.VIDEO) { + describe('Checking for Video.Placement property', function() { + let sandbox, utilsMock; + const adUnit = 'Div1'; + const msg_placement_missing = 'Video.Placement param missing for Div1'; + let videoData = { + battr: [6, 7], + skipafter: 15, + maxduration: 50, + context: 'instream', + playerSize: [640, 480], + skip: 0, + connectiontype: [1, 2, 6], + skipmin: 10, + minduration: 10, + mimes: ['video/mp4', 'video/x-flv'], } - spec.transformBidParams(bidRequests[0].params, true, videoAdUnit); - expect(bidRequests[0].params.dctr).to.equal('key1:val1,val2|key2:val1'); + beforeEach(() => { + utilsMock = sinon.mock(utils); + sandbox = sinon.sandbox.create(); + sandbox.spy(utils, 'logWarn'); + }); + + afterEach(() => { + utilsMock.restore(); + sandbox.restore(); + }) + + it('should log Video.Placement param missing', function() { + checkVideoPlacement(videoData, adUnit); + sinon.assert.calledWith(utils.logWarn, msg_placement_missing); + }) + it('shoud not log Video.Placement param missing', function() { + videoData['placement'] = 1; + checkVideoPlacement(videoData, adUnit); + sinon.assert.neverCalledWith(utils.logWarn, msg_placement_missing); + }) }); - }) + } + }); - describe('Checking for Video.Placement property', function() { - let sandbox, utilsMock; - const adUnit = 'Div1'; - const msg_placement_missing = 'Video.Placement param missing for Div1'; - let videoData = { - battr: [6, 7], - skipafter: 15, - maxduration: 50, - context: 'instream', - playerSize: [640, 480], - skip: 0, - connectiontype: [1, 2, 6], - skipmin: 10, - minduration: 10, - mimes: ['video/mp4', 'video/x-flv'], - } + if (FEATURES.VIDEO) { + describe('Video request params', function() { + let sandbox, utilsMock, newVideoRequest; beforeEach(() => { utilsMock = sinon.mock(utils); sandbox = sinon.sandbox.create(); sandbox.spy(utils, 'logWarn'); + newVideoRequest = utils.deepClone(videoBidRequests) }); afterEach(() => { @@ -3850,59 +3966,89 @@ describe('PubMatic adapter', function () { sandbox.restore(); }) - it('should log Video.Placement param missing', function() { - checkVideoPlacement(videoData, adUnit); - sinon.assert.calledWith(utils.logWarn, msg_placement_missing); - }) - it('shoud not log Video.Placement param missing', function() { - videoData['placement'] = 1; - checkVideoPlacement(videoData, adUnit); - sinon.assert.neverCalledWith(utils.logWarn, msg_placement_missing); - }) - }); - }); + it('Should log warning if video params from mediaTypes and params obj of bid are not present', function () { + delete newVideoRequest[0].mediaTypes.video; + delete newVideoRequest[0].params.video; - describe('Video request params', function() { - let sandbox, utilsMock, newVideoRequest; - beforeEach(() => { - utilsMock = sinon.mock(utils); - sandbox = sinon.sandbox.create(); - sandbox.spy(utils, 'logWarn'); - newVideoRequest = utils.deepClone(videoBidRequests) - }); + let request = spec.buildRequests(newVideoRequest, { + auctionId: 'new-auction-id' + }); - afterEach(() => { - utilsMock.restore(); - sandbox.restore(); - }) + sinon.assert.calledOnce(utils.logWarn); + expect(request).to.equal(undefined); + }); - it('Should log warning if video params from mediaTypes and params obj of bid are not present', function () { - delete newVideoRequest[0].mediaTypes.video; - delete newVideoRequest[0].params.video; + it('Should consider video params from mediaType object of bid', function () { + delete newVideoRequest[0].params.video; - let request = spec.buildRequests(newVideoRequest, { - auctionId: 'new-auction-id' - }); + let request = spec.buildRequests(newVideoRequest, { + auctionId: 'new-auction-id' + }); + let data = JSON.parse(request.data); + expect(data.imp[0].video).to.exist; + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + expect(data.imp[0]['video']['battr']).to.equal(undefined); + }); + + describe('Assign Deal Tier (i.e. prebidDealPriority)', function () { + let videoSeatBid, request, newBid; + // let data = JSON.parse(request.data); + beforeEach(function () { + videoSeatBid = videoBidResponse.body.seatbid[0].bid[0]; + // const adpodValidOutstreamBidRequest = validOutstreamBidRequest.bids[0].mediaTypes.video.context = 'adpod'; + request = spec.buildRequests(bidRequests, validOutstreamBidRequest); + newBid = { + requestId: '47acc48ad47af5' + }; + videoSeatBid.ext = videoSeatBid.ext || {}; + videoSeatBid.ext.video = videoSeatBid.ext.video || {}; + // videoBidRequests[0].mediaTypes.video = videoBidRequests[0].mediaTypes.video || {}; + }); - sinon.assert.calledOnce(utils.logWarn); - expect(request).to.equal(undefined); - }); + it('should not assign video object if deal priority is missing', function () { + assignDealTier(newBid, videoSeatBid, request); + expect(newBid.video).to.equal(undefined); + expect(newBid.video).to.not.exist; + }); - it('Should consider video params from mediaType object of bid', function () { - delete newVideoRequest[0].params.video; + it('should not assign video object if context is not a adpod', function () { + videoSeatBid.ext.prebiddealpriority = 5; + assignDealTier(newBid, videoSeatBid, request); + expect(newBid.video).to.equal(undefined); + expect(newBid.video).to.not.exist; + }); - let request = spec.buildRequests(newVideoRequest, { - auctionId: 'new-auction-id' + describe('when video deal tier object is present', function () { + beforeEach(function () { + videoSeatBid.ext.prebiddealpriority = 5; + request.bidderRequest.bids[0].mediaTypes.video = { + ...request.bidderRequest.bids[0].mediaTypes.video, + context: 'adpod', + maxduration: 50 + }; + }); + + it('should set video deal tier object, when maxduration is present in ext', function () { + assignDealTier(newBid, videoSeatBid, request); + expect(newBid.video.durationSeconds).to.equal(50); + expect(newBid.video.context).to.equal('adpod'); + expect(newBid.video.dealTier).to.equal(5); + }); + + it('should set video deal tier object, when duration is present in ext', function () { + videoSeatBid.ext.video.duration = 20; + assignDealTier(newBid, videoSeatBid, request); + expect(newBid.video.durationSeconds).to.equal(20); + expect(newBid.video.context).to.equal('adpod'); + expect(newBid.video.dealTier).to.equal(5); + }); + }); }); - let data = JSON.parse(request.data); - expect(data.imp[0].video).to.exist; - expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); - expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); - expect(data.imp[0]['video']['battr']).to.equal(undefined); }); - }); + } - describe('GroupM params', function() { + describe('Marketplace params', function () { let sandbox, utilsMock, newBidRequests, newBidResponses; beforeEach(() => { utilsMock = sinon.mock(utils); @@ -3919,22 +4065,13 @@ describe('PubMatic adapter', function () { sandbox.restore(); }) - it('Should log info when bidder is groupm and return', function () { - let request = spec.buildRequests(newBidRequests, {bidderCode: 'groupm', - auctionId: 'new-auction-id' - }); - sinon.assert.calledOnce(utils.logInfo); - expect(request).to.equal(undefined); - }); - - it('Should add bidder code & bidder as groupm for marketplace groupm response', function () { + it('Should add bidder code as groupm for marketplace groupm response ', function () { let request = spec.buildRequests(newBidRequests, { auctionId: 'new-auction-id' }); let response = spec.interpretResponse(newBidResponses, request); expect(response).to.be.an('array').with.length.above(0); expect(response[0].bidderCode).to.equal('groupm'); - expect(response[0].bidder).to.equal('groupm'); }); }); }); diff --git a/test/spec/modules/pubperfAnalyticsAdapter_spec.js b/test/spec/modules/pubperfAnalyticsAdapter_spec.js index b316b44617a..9949d87a2bc 100644 --- a/test/spec/modules/pubperfAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubperfAnalyticsAdapter_spec.js @@ -1,9 +1,10 @@ import pubperfAnalytics from 'modules/pubperfAnalyticsAdapter.js'; -import { expect } from 'chai'; -import { server } from 'test/mocks/xhr.js'; +import {expect} from 'chai'; +import {server} from 'test/mocks/xhr.js'; +import {expectEvents, fireEvents} from '../../helpers/analytics.js'; + let events = require('src/events'); let utils = require('src/utils.js'); -let constants = require('src/constants.json'); describe('Pubperf Analytics Adapter', function() { describe('Prebid Manager Analytic tests', function() { @@ -22,13 +23,7 @@ describe('Pubperf Analytics Adapter', function() { provider: 'pubperf' }); - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_TIMEOUT, {}); - + fireEvents(); expect(server.requests.length).to.equal(0); expect(utils.logError.called).to.equal(true); }); @@ -42,14 +37,7 @@ describe('Pubperf Analytics Adapter', function() { provider: 'pubperf' }); - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_TIMEOUT, {}); - - sinon.assert.callCount(pubperfAnalytics.track, 6); + expectEvents().to.beTrackedBy(pubperfAnalytics.track); }); }); }); diff --git a/test/spec/modules/pubstackAnalyticsAdapter_spec.js b/test/spec/modules/pubstackAnalyticsAdapter_spec.js index 4df25f1665b..fe7441e91e5 100644 --- a/test/spec/modules/pubstackAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubstackAnalyticsAdapter_spec.js @@ -3,17 +3,16 @@ import pubstackAnalytics from '../../../modules/pubstackAnalyticsAdapter.js'; import adapterManager from 'src/adapterManager'; import * as events from 'src/events'; import constants from 'src/constants.json' +import {expectEvents} from '../../helpers/analytics.js'; describe('Pubstack Analytics Adapter', () => { const scope = utils.getWindowSelf(); - let queue = []; beforeEach(() => { - scope.PubstackAnalytics = (...args) => queue.push(args); + scope.PubstackAnalytics = sinon.stub(); adapterManager.enableAnalytics({ provider: 'pubstack' }); - queue = [] }); afterEach(() => { @@ -21,18 +20,6 @@ describe('Pubstack Analytics Adapter', () => { }); it('should forward all events to the queue', () => { - // Given - const args = 'any-args' - - // When - events.emit(constants.EVENTS.AUCTION_END, args) - events.emit(constants.EVENTS.BID_REQUESTED, args) - events.emit(constants.EVENTS.BID_ADJUSTMENT, args) - events.emit(constants.EVENTS.BID_RESPONSE, args) - events.emit(constants.EVENTS.BID_WON, args) - events.emit(constants.EVENTS.NO_BID, args) - - // Then - expect(queue.length).to.eql(6); + expectEvents().to.beBundledTo(scope.PubstackAnalytics); }); }); diff --git a/test/spec/modules/pubwiseAnalyticsAdapter_spec.js b/test/spec/modules/pubwiseAnalyticsAdapter_spec.js index 3be4ea3d69c..92d5972cc13 100644 --- a/test/spec/modules/pubwiseAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubwiseAnalyticsAdapter_spec.js @@ -1,6 +1,8 @@ -import { expect } from 'chai'; +import {expect} from 'chai'; import pubwiseAnalytics from 'modules/pubwiseAnalyticsAdapter.js'; -import {server} from 'test/mocks/xhr.js'; +import {expectEvents} from '../../helpers/analytics.js'; +import {server} from '../../mocks/xhr.js'; + let events = require('src/events'); let adapterManager = require('src/adapterManager').default; let constants = require('src/constants.json'); @@ -8,7 +10,6 @@ let constants = require('src/constants.json'); describe('PubWise Prebid Analytics', function () { let requests; let sandbox; - let xhr; let clock; let mock = {}; @@ -37,9 +38,7 @@ describe('PubWise Prebid Analytics', function () { clock = sandbox.useFakeTimers(); sandbox.stub(events, 'getEvents').returns([]); - xhr = sandbox.useFakeXMLHttpRequest(); - requests = []; - xhr.onCreate = request => requests.push(request); + requests = server.requests; }); afterEach(function () { @@ -49,32 +48,21 @@ describe('PubWise Prebid Analytics', function () { }); describe('enableAnalytics', function () { - beforeEach(function () { - requests = []; - }); - it('should catch all events', function () { pubwiseAnalytics.enableAnalytics(mock.DEFAULT_PW_CONFIG); sandbox.spy(pubwiseAnalytics, 'track'); - // sent - events.emit(constants.EVENTS.AUCTION_INIT, mock.AUCTION_INIT); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - events.emit(constants.EVENTS.AD_RENDER_FAILED, {}); - events.emit(constants.EVENTS.TCF2_ENFORCEMENT, {}); - events.emit(constants.EVENTS.BID_TIMEOUT, {}); - - // forces flush - events.emit(constants.EVENTS.AUCTION_END, {}); - - // eslint-disable-next-line - //console.log(requests); - - /* testing for 6 calls, including the 2 we're not currently tracking */ - sandbox.assert.callCount(pubwiseAnalytics.track, 7); + expectEvents([ + constants.EVENTS.AUCTION_INIT, + constants.EVENTS.BID_REQUESTED, + constants.EVENTS.BID_RESPONSE, + constants.EVENTS.BID_WON, + constants.EVENTS.AD_RENDER_FAILED, + constants.EVENTS.TCF2_ENFORCEMENT, + constants.EVENTS.BID_TIMEOUT, + constants.EVENTS.AUCTION_END, + ]).to.beTrackedBy(pubwiseAnalytics.track); }); it('should initialize the auction properly', function () { @@ -92,7 +80,7 @@ describe('PubWise Prebid Analytics', function () { let request = requests[0]; let data = JSON.parse(request.requestBody); // eslint-disable-next-line - // console.log(data.metaData); + // console.log(data.metaData); expect(data.metaData, 'metaData property').to.exist; expect(data.metaData.pbjs_version, 'pbjs version').to.equal('$prebid.version$') expect(data.metaData.session_id, 'session id').not.to.be.empty diff --git a/test/spec/modules/pubwiseBidAdapter_spec.js b/test/spec/modules/pubwiseBidAdapter_spec.js index 450b028f6c7..49e36c05d1e 100644 --- a/test/spec/modules/pubwiseBidAdapter_spec.js +++ b/test/spec/modules/pubwiseBidAdapter_spec.js @@ -2,7 +2,7 @@ import {expect} from 'chai'; import {spec} from 'modules/pubwiseBidAdapter.js'; -import {_checkMediaType} from 'modules/pubwiseBidAdapter.js'; // this is exported only for testing so maintaining the JS convention of _ to indicate the intent +import {_checkVideoPlacement, _checkMediaType} from 'modules/pubwiseBidAdapter.js'; // this is exported only for testing so maintaining the JS convention of _ to indicate the intent import {_parseAdSlot} from 'modules/pubwiseBidAdapter.js'; // this is exported only for testing so maintaining the JS convention of _ to indicate the intent import * as utils from 'src/utils.js'; @@ -99,13 +99,16 @@ const sampleValidBannerBidRequest = { 'crumbs': { 'pubcid': '9a62f261-3c0b-4cc8-8db3-a72ae86ec6ba' }, - 'fpd': { - 'context': { - 'adServer': { - 'name': 'gam', - 'adSlot': '/19968336/header-bid-tag-0' - }, - 'pbAdSlot': '/19968336/header-bid-tag-0' + ortb2Imp: { + ext: { + tid: '2001a8b2-3bcf-417d-b64f-92641dae21e0', + data: { + adserver: { + name: 'gam', + adslot: '/19968336/header-bid-tag-0' + }, + pbadslot: '/19968336/header-bid-tag-0', + } } }, 'mediaTypes': { @@ -123,7 +126,6 @@ const sampleValidBannerBidRequest = { } }, 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '2001a8b2-3bcf-417d-b64f-92641dae21e0', 'sizes': [ [ 300, @@ -175,13 +177,16 @@ const sampleValidBidRequests = [ 'required': false } }, - 'fpd': { - 'context': { - 'adServer': { - 'name': 'gam', - 'adSlot': '/19968336/header-bid-tag-0' - }, - 'pbAdSlot': '/19968336/header-bid-tag-0' + ortb2Imp: { + ext: { + tid: '2c8cd034-f068-4419-8c30-f07292c0d17b', + data: { + adserver: { + name: 'gam', + adslot: '/19968336/header-bid-tag-0' + }, + pbadslot: '/19968336/header-bid-tag-0', + } } }, 'mediaTypes': { @@ -209,7 +214,6 @@ const sampleValidBidRequests = [ } }, 'adUnitCode': 'div-gpt-ad-1460505748561-1', - 'transactionId': '2c8cd034-f068-4419-8c30-f07292c0d17b', 'sizes': [], 'bidId': '30ab7516a51a7c', 'bidderRequestId': '18a45bff5ff705', @@ -234,7 +238,7 @@ const sampleBidderBannerRequest = { 'bidFloor': '1.00', 'currency': 'USD', 'adSlot': '', - 'adUnit': '', + 'adUnit': 'div-gpt-ad-1460505748561-0', 'bcat': [ 'IAB25-3', 'IAB26-1', @@ -246,13 +250,16 @@ const sampleBidderBannerRequest = { 'crumbs': { 'pubcid': '9a62f261-3c0b-4cc8-8db3-a72ae86ec6ba' }, - 'fpd': { - 'context': { - 'adServer': { - 'name': 'gam', - 'adSlot': '/19968336/header-bid-tag-0' - }, - 'pbAdSlot': '/19968336/header-bid-tag-0' + ortb2Imp: { + ext: { + tid: '2001a8b2-3bcf-417d-b64f-92641dae21e0', + data: { + adserver: { + name: 'gam', + adslot: '/19968336/header-bid-tag-0' + }, + pbadslot: '/19968336/header-bid-tag-0', + } } }, 'mediaTypes': { @@ -266,7 +273,6 @@ const sampleBidderBannerRequest = { } }, 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '2001a8b2-3bcf-417d-b64f-92641dae21e0', 'sizes': [ [ 300, @@ -293,7 +299,11 @@ const sampleBidderBannerRequest = { const sampleBidderRequest = { 'bidderCode': 'pubwise', - 'auctionId': '9f20663c-4629-4b5c-bff6-ff3aa8319358', + ortb2: { + source: { + tid: '9f20663c-4629-4b5c-bff6-ff3aa8319358', + } + }, 'bidderRequestId': '18a45bff5ff705', 'bids': [ sampleBidderBannerRequest, @@ -327,13 +337,15 @@ const sampleBidderRequest = { 'required': false } }, - 'fpd': { - 'context': { - 'adServer': { - 'name': 'gam', - 'adSlot': '/19968336/header-bid-tag-0' - }, - 'pbAdSlot': '/19968336/header-bid-tag-0' + ortb2Imp: { + ext: { + data: { + adserver: { + name: 'gam', + adslot: '/19968336/header-bid-tag-0' + }, + pbadslot: '/19968336/header-bid-tag-0', + } } }, 'mediaTypes': { @@ -478,6 +490,28 @@ const samplePBBidObjects = [ ]; describe('PubWiseAdapter', function () { + describe('Handles Params Properly', function () { + it('properly sets the default endpoint', function () { + const referenceEndpoint = 'https://bid.pubwise.io/prebid'; + let endpointBidRequest = utils.deepClone(sampleValidBidRequests); + // endpointBidRequest.forEach((bidRequest) => { + // bidRequest.params.endpoint_url = newEndpoint; + // }); + let result = spec.buildRequests(endpointBidRequest, {auctionId: 'placeholder'}); + expect(result.url).to.equal(referenceEndpoint); + }); + + it('allows endpoint to be reset', function () { + const newEndpoint = 'http://www.pubwise.io/endpointtest'; + let endpointBidRequest = utils.deepClone(sampleValidBidRequests); + endpointBidRequest.forEach((bidRequest) => { + bidRequest.params.endpoint_url = newEndpoint; + }); + let result = spec.buildRequests(endpointBidRequest, {auctionId: 'placeholder'}); + expect(result.url).to.equal(newEndpoint); + }); + }); + describe('Properly Validates Bids', function () { it('valid bid', function () { let validBid = { @@ -527,13 +561,15 @@ describe('PubWiseAdapter', function () { describe('Handling Request Construction', function () { it('bid requests are not mutable', function() { - let sourceBidRequest = utils.deepClone(sampleValidBidRequests) - spec.buildRequests(sampleValidBidRequests, {auctinId: 'placeholder'}); + let sourceBidRequest = utils.deepClone(sampleValidBidRequests); + spec.buildRequests(sampleValidBidRequests, {auctionId: 'placeholder'}); expect(sampleValidBidRequests).to.deep.equal(sourceBidRequest, 'Should be unedited as they are used elsewhere'); }); it('should handle complex bidRequest', function() { let request = spec.buildRequests(sampleValidBidRequests, sampleBidderRequest); - expect(request.bidderRequest).to.equal(sampleBidderRequest); + expect(request.bidderRequest).to.equal(sampleBidderRequest, "Bid Request Doesn't Match Sample"); + expect(request.data.source.tid).to.equal(sampleBidderRequest.ortb2.source.tid, 'source.tid -> source.tid Mismatch'); + expect(request.data.imp[0].ext.tid).to.equal(sampleBidderRequest.bids[0].ortb2Imp.ext.tid, 'ext.tid -> ext.tid Mismatch'); }); it('must conform to API for buildRequests', function() { let request = spec.buildRequests(sampleValidBidRequests); @@ -545,14 +581,14 @@ describe('PubWiseAdapter', function () { it('identifies native adm type', function() { let adm = '{"ver":"1.2","assets":[{"title":{"text":"PubWise Test"}},{"img":{"type":3,"url":"http://www.pubwise.io"}},{"img":{"type":1,"url":"http://www.pubwise.io"}},{"data":{"type":2,"value":"PubWise Test Desc"}},{"data":{"type":1,"value":"PubWise.io"}}],"link":{"url":""}}'; let newBid = {mediaType: 'unknown'}; - _checkMediaType(adm, newBid); + _checkMediaType({adm}, newBid); expect(newBid.mediaType).to.equal('native', adm + ' Is a Native adm'); }); it('identifies banner adm type', function() { let adm = '

PubWise Test Bid

'; let newBid = {mediaType: 'unknown'}; - _checkMediaType(adm, newBid); + _checkMediaType({adm}, newBid); expect(newBid.mediaType).to.equal('banner', adm + ' Is a Banner adm'); }); }); @@ -572,4 +608,292 @@ describe('PubWiseAdapter', function () { expect(pbResponse).to.deep.equal(samplePBBidObjects); }); }); + + describe('Video Testing', function () { + /** + * Video Testing + */ + + const videoBidRequests = + [ + { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bidder: 'pwbid', + bidId: '22bddb28db77d', + adUnitCode: 'Div1', + params: { + siteId: 'xxxxxx', + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30, + startdelay: 5, + playbackmethod: [1, 3], + api: [1, 2], + protocols: [2, 3], + battr: [13, 14], + linearity: 1, + placement: 2, + minbitrate: 10, + maxbitrate: 10 + } + } + } + ]; + + let newvideoRequests = [{ + 'bidder': 'pwbid', + 'params': { + 'siteId': 'xxxxx', + 'video': { + 'mimes': ['video/mp4'], + 'skippable': true, + 'protocols': [1, 2, 5], + 'linearity': 1 + } + }, + 'mediaTypes': { + 'video': { + 'playerSize': [ + [640, 480] + ], + 'protocols': [1, 2, 5], + 'context': 'instream', + 'mimes': ['video/flv'], + 'skippable': false, + 'skip': 1, + 'linearity': 2 + } + }, + 'adUnitCode': 'video1', + 'transactionId': '803e3750-0bbe-4ffe-a548-b6eca15087bf', + 'sizes': [ + [640, 480] + ], + 'bidId': '2c95df014cfe97', + 'bidderRequestId': '1fe59391566442', + 'auctionId': '3a4118ef-fb96-4416-b0b0-3cfc1cebc142', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0 + }]; + + let newvideoBidResponses = { + 'body': { + 'id': '1621441141473', + 'cur': 'USD', + 'customdata': 'openrtb1', + 'ext': { + 'buyid': 'myBuyId' + }, + 'seatbid': [{ + 'bid': [{ + 'id': '2c95df014cfe97', + 'impid': '2c95df014cfe97', + 'price': 4.2, + 'cid': 'test1', + 'crid': 'test2', + 'adm': "Acudeo CompatibleVAST 2.0 Instream Test 1VAST 2.0 Instream Test 1", + 'w': 0, + 'h': 0 + }], + 'ext': { + 'buyid': 'myBuyId' + } + }] + }, + 'headers': {} + }; + + let videoBidResponse = { + 'body': { + 'id': '93D3BAD6-E2E2-49FB-9D89-920B1761C865', + 'seatbid': [{ + 'bid': [{ + 'id': '74858439-49D7-4169-BA5D-44A046315B2F', + 'impid': '22bddb28db77d', + 'price': 1.3, + 'adm': '', + 'h': 250, + 'w': 300, + 'ext': { + 'deal_channel': 6 + } + }] + }] + } + }; + + it('Request params check for video ad', function () { + let request = spec.buildRequests(videoBidRequests, { + auctionId: 'new-auction-id' + }); + let data = request.data; + expect(data.imp[0].video).to.exist; + expect(data.imp[0].tagid).to.equal('Div1'); + expect(data.imp[0]['video']['mimes']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['mimes'][0]).to.equal(videoBidRequests[0].params.video['mimes'][0]); + expect(data.imp[0]['video']['mimes'][1]).to.equal(videoBidRequests[0].params.video['mimes'][1]); + expect(data.imp[0]['video']['minduration']).to.equal(videoBidRequests[0].params.video['minduration']); + expect(data.imp[0]['video']['maxduration']).to.equal(videoBidRequests[0].params.video['maxduration']); + expect(data.imp[0]['video']['startdelay']).to.equal(videoBidRequests[0].params.video['startdelay']); + + expect(data.imp[0]['video']['playbackmethod']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['playbackmethod'][0]).to.equal(videoBidRequests[0].params.video['playbackmethod'][0]); + expect(data.imp[0]['video']['playbackmethod'][1]).to.equal(videoBidRequests[0].params.video['playbackmethod'][1]); + + expect(data.imp[0]['video']['api']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['api'][0]).to.equal(videoBidRequests[0].params.video['api'][0]); + expect(data.imp[0]['video']['api'][1]).to.equal(videoBidRequests[0].params.video['api'][1]); + + expect(data.imp[0]['video']['protocols']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['protocols'][0]).to.equal(videoBidRequests[0].params.video['protocols'][0]); + expect(data.imp[0]['video']['protocols'][1]).to.equal(videoBidRequests[0].params.video['protocols'][1]); + + expect(data.imp[0]['video']['battr']).to.exist.and.to.be.an('array'); + expect(data.imp[0]['video']['battr'][0]).to.equal(videoBidRequests[0].params.video['battr'][0]); + expect(data.imp[0]['video']['battr'][1]).to.equal(videoBidRequests[0].params.video['battr'][1]); + + expect(data.imp[0]['video']['linearity']).to.equal(videoBidRequests[0].params.video['linearity']); + expect(data.imp[0]['video']['placement']).to.equal(videoBidRequests[0].params.video['placement']); + expect(data.imp[0]['video']['minbitrate']).to.equal(videoBidRequests[0].params.video['minbitrate']); + expect(data.imp[0]['video']['maxbitrate']).to.equal(videoBidRequests[0].params.video['maxbitrate']); + + expect(data.imp[0]['video']['w']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[0]); + expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); + }); + + it('should assign mediaType even if bid.ext.mediaType does not exists', function() { + let newrequest = spec.buildRequests(newvideoRequests, { + auctionId: 'new-auction-id' + }); + let newresponse = spec.interpretResponse(newvideoBidResponses, newrequest); + expect(newresponse[0].mediaType).to.equal('video'); + }); + + it('should not assign renderer if bid is video and request is for instream', function() { + let request = spec.buildRequests(videoBidRequests, { + auctionId: 'new-auction-id' + }); + let response = spec.interpretResponse(videoBidResponse, request); + expect(response[0].renderer).to.not.exist; + }); + + it('should process instream and outstream', function() { + let validOutstreamRequest = + { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream' + } + }, + bidder: 'pwbid', + bidId: '47acc48ad47af5', + requestId: '0fb4905b-1234-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + params: { + siteId: 'xxxxx', + adSlot: 'Div1', // ad_id or tagid + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }; + + let outstreamBidRequest = + [ + validOutstreamRequest + ]; + + let validInstreamRequest = { + code: 'video1', + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'instream' + } + }, + bidder: 'pwbid', + bidId: '47acc48ad47af5', + requestId: '0fb4905b-1234-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729', + params: { + siteId: 'xxxxx', + adSlot: 'Div1', // ad_id or tagid + video: { + mimes: ['video/mp4', 'video/x-flv'], + skippable: true, + minduration: 5, + maxduration: 30 + } + } + }; + + let instreamBidRequest = + [ + validInstreamRequest + ]; + + let outstreamRequest = spec.isBidRequestValid(validOutstreamRequest); + expect(outstreamRequest).to.equal(false); + + let instreamRequest = spec.isBidRequestValid(validInstreamRequest); + expect(instreamRequest).to.equal(true); + }); + + describe('Checking for Video.Placement property', function() { + let sandbox, utilsMock; + const adUnit = 'DivCheckPlacement'; + const msg_placement_missing = 'PubWise: Video.Placement param missing for DivCheckPlacement'; + let videoData = { + battr: [6, 7], + skipafter: 15, + maxduration: 50, + context: 'instream', + playerSize: [640, 480], + skip: 0, + connectiontype: [1, 2, 6], + skipmin: 10, + minduration: 10, + mimes: ['video/mp4', 'video/x-flv'], + } + beforeEach(() => { + utilsMock = sinon.mock(utils); + sandbox = sinon.sandbox.create(); + sandbox.spy(utils, 'logWarn'); + }); + + afterEach(() => { + utilsMock.restore(); + sandbox.restore(); + }) + + it('should log Video.Placement param missing', function() { + _checkVideoPlacement(videoData, adUnit); + // when failing this gives an odd message about "AssertError: expected logWarn to be called with arguments" it means the specific message expected + sinon.assert.calledWith(utils.logWarn, msg_placement_missing); + }) + it('shoud not log Video.Placement param missing', function() { + videoData['placement'] = 1; + _checkVideoPlacement(videoData, adUnit); + sinon.assert.neverCalledWith(utils.logWarn, msg_placement_missing); + }) + }); + // end video testing + }); }); diff --git a/test/spec/modules/pubxBidAdapter_spec.js b/test/spec/modules/pubxBidAdapter_spec.js index 06bb5b5f638..b387264bf91 100644 --- a/test/spec/modules/pubxBidAdapter_spec.js +++ b/test/spec/modules/pubxBidAdapter_spec.js @@ -39,14 +39,22 @@ describe('pubxAdapter', function () { id: '26c1ee0038ac11', params: { sid: '12345abc' + }, + ortb2: { + site: { + page: `${location.href}?test=1` + } } } ]; const data = { banner: { - sid: '12345abc' - } + sid: '12345abc', + pu: encodeURIComponent( + utils.deepAccess(bidRequests[0], 'ortb2.site.page').replace(/\?.*$/, '') + ), + }, }; it('sends bid request to ENDPOINT via GET', function () { diff --git a/test/spec/modules/pubxaiAnalyticsAdapter_spec.js b/test/spec/modules/pubxaiAnalyticsAdapter_spec.js index 63364b867be..e0f4497a8c8 100644 --- a/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +++ b/test/spec/modules/pubxaiAnalyticsAdapter_spec.js @@ -1,13 +1,9 @@ -import pubxaiAnalyticsAdapter from 'modules/pubxaiAnalyticsAdapter.js'; -import { getDeviceType, getBrowser, getOS } from 'modules/pubxaiAnalyticsAdapter.js'; -import { - expect -} from 'chai'; +import pubxaiAnalyticsAdapter, {getBrowser, getDeviceType, getOS} from 'modules/pubxaiAnalyticsAdapter.js'; +import {expect} from 'chai'; import adapterManager from 'src/adapterManager.js'; import * as utils from 'src/utils.js'; -import { - server -} from 'test/mocks/xhr.js'; +import {server} from 'test/mocks/xhr.js'; +import {getGptSlotInfoForAdUnitCode} from '../../../libraries/gptUtils/gptUtils.js'; let events = require('src/events'); let constants = require('src/constants.json'); @@ -527,7 +523,7 @@ describe('pubxai analytics adapter', function() { 'bidderCode': 'appnexus', 'bidId': '248f9a4489835e', 'adUnitCode': '/19968336/header-bid-tag-1', - 'gptSlotCode': utils.getGptSlotInfoForAdUnitCode('/19968336/header-bid-tag-1').gptSlot || null, + 'gptSlotCode': getGptSlotInfoForAdUnitCode('/19968336/header-bid-tag-1').gptSlot || null, 'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4', 'sizes': '300x250', 'renderStatus': 2, @@ -567,7 +563,9 @@ describe('pubxai analytics adapter', function() { 'host': location.host, 'path': location.pathname, 'search': location.search, - 'adUnitCount': 1 + 'adUnits': [ + '/19968336/header-bid-tag-1' + ] }, 'floorDetail': { 'fetchStatus': 'success', @@ -594,7 +592,7 @@ describe('pubxai analytics adapter', function() { let expectedAfterBidWon = { 'winningBid': { 'adUnitCode': '/19968336/header-bid-tag-1', - 'gptSlotCode': utils.getGptSlotInfoForAdUnitCode('/19968336/header-bid-tag-1').gptSlot || null, + 'gptSlotCode': getGptSlotInfoForAdUnitCode('/19968336/header-bid-tag-1').gptSlot || null, 'auctionId': 'bc3806e4-873e-453c-8ae5-204f35e923b4', 'bidderCode': 'appnexus', 'bidId': '248f9a4489835e', @@ -624,6 +622,11 @@ describe('pubxai analytics adapter', function() { } }, 'floorProvider': 'PubXFloorProvider', + 'floorFetchStatus': 'success', + 'floorLocation': 'fetch', + 'floorModelVersion': 'test model 1.0', + 'floorSkipRate': 0, + 'isFloorSkipped': false, 'isWinningBid': true, 'mediaType': 'banner', 'netRevenue': true, diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index c8ec0493d54..8db7e909771 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -1,8 +1,8 @@ /* eslint dot-notation:0, quote-props:0 */ import {expect} from 'chai'; import {spec} from 'modules/pulsepointBidAdapter.js'; -import {deepClone} from 'src/utils.js'; -import { config } from 'src/config.js'; +import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js'; +import {deepClone} from '../../../src/utils'; describe('PulsePoint Adapter Tests', function () { const slotConfigs = [{ @@ -32,39 +32,52 @@ describe('PulsePoint Adapter Tests', function () { cf: '728x90' } }]; + const nativeOrtbRequest = { + assets: [{ + id: 1, + required: 1, + img: { + type: 3, + w: 150, + h: 50, + } + }, + { + id: 2, + required: 1, + title: { + len: 80 + } + }, + { + id: 3, + required: 0, + data: { + type: 1 + } + }] + }; const nativeSlotConfig = [{ placementCode: '/DfpAccount1/slot3', bidId: 'bid12345', - nativeParams: { - title: { required: true, len: 200 }, - image: { wmin: 100 }, - sponsoredBy: { } + mediaTypes: { + native: { + sendTargetingKeys: false, + ortb: nativeOrtbRequest + } }, + nativeOrtbRequest, params: { cp: 'p10000', ct: 't10000' } }]; - const appSlotConfig = [{ - placementCode: '/DfpAccount1/slot3', - bidId: 'bid12345', - params: { - cp: 'p10000', - ct: 't10000', - app: { - bundle: 'com.pulsepoint.apps', - storeUrl: 'https://pulsepoint.com/apps', - domain: 'pulsepoint.com', - } - } - }]; const videoSlotConfig = [{ placementCode: '/DfpAccount1/slotVideo', bidId: 'bid12345', - params: { - cp: 'p10000', - ct: 't10000', + mediaTypes: { video: { + playerSize: [400, 300], w: 400, h: 300, minduration: 5, @@ -74,6 +87,10 @@ describe('PulsePoint Adapter Tests', function () { minbitrate: 200, protocols: [1, 2, 4] } + }, + params: { + cp: 'p10000', + ct: 't10000' } }]; const additionalParamsConfig = [{ @@ -98,68 +115,6 @@ describe('PulsePoint Adapter Tests', function () { } }]; - const ortbParamsSlotConfig = [{ - placementCode: '/DfpAccount1/slot1', - mediaTypes: { - banner: { - sizes: [[1, 1]] - } - }, - bidId: 'bid12345', - params: { - cp: 'p10000', - ct: 't10000', - cf: '1x1', - bcat: ['IAB-1', 'IAB-20'], - battr: [1, 2, 3], - bidfloor: 1.5, - badv: ['cocacola.com', 'lays.com'] - } - }, { - placementCode: '/DfpAccount1/slotVideo', - bidId: 'bid12345', - params: { - cp: 'p10000', - ct: 't10000', - video: { - w: 400, - h: 300, - minduration: 5, - maxduration: 10, - }, - battr: [2, 3, 4], - bidfloor: 2.5, - } - }]; - - const outstreamSlotConfig = [{ - placementCode: '/DfpAccount1/slot1', - mediaTypes: { - video: { - playerSize: [640, 480], - context: 'outstream' - } - }, - bidId: 'bid12345', - params: { - cp: 'p10000', - ct: 't10000', - cf: '1x1', - video: { - h: 300, - w: 400, - minduration: 1, - maxduration: 210, - linearity: 1, - } - }, - renderer: { - options: { - text: 'PulsePoint Outstream' - } - } - }]; - const schainParamsSlotConfig = [{ placementCode: '/DfpAccount1/slot1', mediaTypes: { @@ -195,12 +150,13 @@ describe('PulsePoint Adapter Tests', function () { const bidderRequest = { refererInfo: { - referer: 'https://publisher.com/home' + page: 'https://publisher.com/home', + ref: 'https://referrer' } }; it('Verify build request', function () { - const request = spec.buildRequests(slotConfigs, bidderRequest); + const request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest)); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -208,7 +164,6 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.site).to.not.equal(null); expect(ortbRequest.site.publisher).to.not.equal(null); expect(ortbRequest.site.publisher.id).to.equal('p10000'); - expect(ortbRequest.site.ref).to.equal(window.top.document.referrer); expect(ortbRequest.site.page).to.equal('https://publisher.com/home'); expect(ortbRequest.imp).to.have.lengthOf(2); // device object @@ -217,17 +172,15 @@ describe('PulsePoint Adapter Tests', function () { // slot 1 expect(ortbRequest.imp[0].tagid).to.equal('t10000'); expect(ortbRequest.imp[0].banner).to.not.equal(null); - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); + expect(ortbRequest.imp[0].banner.format).to.deep.eq([{'w': 728, 'h': 90}, {'w': 160, 'h': 600}]); // slot 2 expect(ortbRequest.imp[1].tagid).to.equal('t20000'); expect(ortbRequest.imp[1].banner).to.not.equal(null); - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); + expect(ortbRequest.imp[1].banner.format).to.deep.eq([{'w': 728, 'h': 90}]); }); it('Verify parse response', function () { - const request = spec.buildRequests(slotConfigs, bidderRequest); + const request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest)); const ortbRequest = request.data; const ortbResponse = { seatbid: [{ @@ -235,11 +188,16 @@ describe('PulsePoint Adapter Tests', function () { impid: ortbRequest.imp[0].id, price: 1.25, adm: 'This is an Ad', - crid: 'Creative#123' + crid: 'Creative#123', + mtype: 1, + w: 300, + h: 250, + exp: 20, + adomain: ['advertiser.com'] }] }] }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); + const bids = spec.interpretResponse({body: ortbResponse}, request); expect(bids).to.have.lengthOf(1); // verify first bid const bid = bids[0]; @@ -247,140 +205,112 @@ describe('PulsePoint Adapter Tests', function () { expect(bid.ad).to.equal('This is an Ad'); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); - expect(bid.adId).to.equal('bid12345'); expect(bid.creative_id).to.equal('Creative#123'); expect(bid.creativeId).to.equal('Creative#123'); expect(bid.netRevenue).to.equal(true); expect(bid.currency).to.equal('USD'); expect(bid.ttl).to.equal(20); - }); - - it('Verify ttl/currency/adomain applied to bid', function () { - const request = spec.buildRequests(slotConfigs, bidderRequest); - const ortbRequest = request.data; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad#1', - crid: 'Creative#123', - exp: 50, - adomain: ['advertiser.com'] - }, { - impid: ortbRequest.imp[1].id, - price: 1.25, - adm: 'This is an Ad#2', - crid: 'Creative#123' - }] - }], - cur: 'GBP' - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(2); - // verify first bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.ad).to.equal('This is an Ad#1'); - expect(bid.ttl).to.equal(50); - expect(bid.currency).to.equal('GBP'); expect(bid.meta).to.not.be.null; expect(bid.meta.advertiserDomains).to.eql(['advertiser.com']); - const secondBid = bids[1]; - expect(secondBid.cpm).to.equal(1.25); - expect(secondBid.ad).to.equal('This is an Ad#2'); - expect(secondBid.ttl).to.equal(20); - expect(secondBid.currency).to.equal('GBP'); - expect(secondBid.meta).to.not.be.null; - expect(secondBid.meta.advertiserDomains).to.eql([]); }); it('Verify full passback', function () { const request = spec.buildRequests(slotConfigs, bidderRequest); - const bids = spec.interpretResponse({ body: null }, request) + const bids = spec.interpretResponse({body: null}, request) expect(bids).to.have.lengthOf(0); }); - it('Verify Native request', function () { - const request = spec.buildRequests(nativeSlotConfig, bidderRequest); - expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); - expect(request.method).to.equal('POST'); - const ortbRequest = request.data; - // native impression - expect(ortbRequest.imp[0].tagid).to.equal('t10000'); - expect(ortbRequest.imp[0].banner).to.equal(null); - const nativePart = ortbRequest.imp[0]['native']; - expect(nativePart).to.not.equal(null); - expect(nativePart.ver).to.equal('1.1'); - expect(nativePart.request).to.not.equal(null); - // native request assets - const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); - expect(nativeRequest).to.not.equal(null); - expect(nativeRequest.assets).to.have.lengthOf(3); - // title asset - expect(nativeRequest.assets[0].id).to.equal(1); - expect(nativeRequest.assets[0].required).to.equal(1); - expect(nativeRequest.assets[0].title).to.not.equal(null); - expect(nativeRequest.assets[0].title.len).to.equal(200); - // data asset - expect(nativeRequest.assets[1].id).to.equal(2); - expect(nativeRequest.assets[1].required).to.equal(0); - expect(nativeRequest.assets[1].title).to.be.undefined; - expect(nativeRequest.assets[1].data).to.not.equal(null); - expect(nativeRequest.assets[1].data.type).to.equal(1); - expect(nativeRequest.assets[1].data.len).to.equal(50); - // image asset - expect(nativeRequest.assets[2].id).to.equal(3); - expect(nativeRequest.assets[2].required).to.equal(0); - expect(nativeRequest.assets[2].title).to.be.undefined; - expect(nativeRequest.assets[2].img).to.not.equal(null); - expect(nativeRequest.assets[2].img.wmin).to.equal(100); - expect(nativeRequest.assets[2].img.hmin).to.equal(150); - expect(nativeRequest.assets[2].img.type).to.equal(3); - }); + if (FEATURES.NATIVE) { + it('Verify Native request', function () { + const request = spec.buildRequests(nativeSlotConfig, syncAddFPDToBidderRequest(bidderRequest)); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + // native impression + expect(ortbRequest.imp[0].tagid).to.equal('t10000'); + expect(ortbRequest.imp[0].banner).to.be.undefined; + const nativePart = ortbRequest.imp[0]['native']; + expect(nativePart).to.not.equal(null); + expect(nativePart.request).to.not.equal(null); + // native request assets + const nativeRequest = JSON.parse(ortbRequest.imp[0]['native'].request); + expect(nativeRequest).to.not.equal(null); + expect(nativeRequest.assets).to.have.lengthOf(3); + // image asset + expect(nativeRequest.assets[0].id).to.equal(1); + expect(nativeRequest.assets[0].required).to.equal(1); + expect(nativeRequest.assets[0].title).to.be.undefined; + expect(nativeRequest.assets[0].img).to.not.equal(null); + expect(nativeRequest.assets[0].img.w).to.equal(150); + expect(nativeRequest.assets[0].img.h).to.equal(50); + expect(nativeRequest.assets[0].img.type).to.equal(3); + // title asset + expect(nativeRequest.assets[1].id).to.equal(2); + expect(nativeRequest.assets[1].required).to.equal(1); + expect(nativeRequest.assets[1].title).to.not.equal(null); + expect(nativeRequest.assets[1].title.len).to.equal(80); + // data asset + expect(nativeRequest.assets[2].id).to.equal(3); + expect(nativeRequest.assets[2].required).to.equal(0); + expect(nativeRequest.assets[2].title).to.be.undefined; + expect(nativeRequest.assets[2].data).to.not.equal(null); + expect(nativeRequest.assets[2].data.type).to.equal(1); + }); - it('Verify Native response', function () { - const request = spec.buildRequests(nativeSlotConfig, bidderRequest); - expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); - expect(request.method).to.equal('POST'); - const ortbRequest = request.data; - const nativeResponse = { - 'native': { + it('Verify Native response', function () { + const request = spec.buildRequests(nativeSlotConfig, syncAddFPDToBidderRequest(bidderRequest)); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + const nativeResponse = { assets: [ - { title: { text: 'Ad Title' } }, - { data: { type: 1, value: 'Sponsored By: Brand' } }, - { img: { type: 3, url: 'https://images.cdn.brand.com/123' } } + {id: 1, img: {type: 3, url: 'https://images.cdn.brand.com/123'}}, + {id: 2, title: {text: 'Ad Title'}}, + {id: 3, data: {type: 1, value: 'Sponsored By: Brand'}} ], - link: { url: 'https://brand.clickme.com/' }, + link: {url: 'https://brand.clickme.com/'}, imptrackers: ['https://imp1.trackme.com/', 'https://imp1.contextweb.com/'] - } - }; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: JSON.stringify(nativeResponse) + + }; + const ortbResponse = { + seatbid: [{ + bid: [{ + impid: ortbRequest.imp[0].id, + price: 1.25, + adm: JSON.stringify(nativeResponse), + mtype: 4 + }] }] - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - // verify bid - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid.mediaType).to.equal('native'); - const nativeBid = bid['native']; - expect(nativeBid).to.not.equal(null); - expect(nativeBid.title).to.equal('Ad Title'); - expect(nativeBid.sponsoredBy).to.equal('Sponsored By: Brand'); - expect(nativeBid.image).to.equal('https://images.cdn.brand.com/123'); - expect(nativeBid.clickUrl).to.equal(encodeURIComponent('https://brand.clickme.com/')); - expect(nativeBid.impressionTrackers).to.have.lengthOf(2); - expect(nativeBid.impressionTrackers[0]).to.equal('https://imp1.trackme.com/'); - expect(nativeBid.impressionTrackers[1]).to.equal('https://imp1.contextweb.com/'); - }); + }; + const bids = spec.interpretResponse({body: ortbResponse}, request); + // verify bid + const bid = bids[0]; + expect(bid.cpm).to.equal(1.25); + expect(bid.requestId).to.equal('bid12345'); + expect(bid.ad).to.be.undefined; + expect(bid.mediaType).to.equal('native'); + expect(bid['native']).to.not.be.null; + expect(bid['native'].ortb).to.not.be.null; + const nativeBid = bid['native'].ortb; + expect(nativeBid.assets).to.have.lengthOf(3); + expect(nativeBid.assets[0].id).to.equal(1); + expect(nativeBid.assets[0].img).to.not.be.null; + expect(nativeBid.assets[0].img.type).to.equal(3); + expect(nativeBid.assets[0].img.url).to.equal('https://images.cdn.brand.com/123'); + expect(nativeBid.assets[1].id).to.equal(2); + expect(nativeBid.assets[1].title).to.not.be.null; + expect(nativeBid.assets[1].title.text).to.equal('Ad Title'); + expect(nativeBid.assets[2].id).to.equal(3); + expect(nativeBid.assets[2].data).to.not.be.null; + expect(nativeBid.assets[2].data.type).to.equal(1); + expect(nativeBid.assets[2].data.value).to.equal('Sponsored By: Brand'); + expect(nativeBid.link).to.not.be.null; + expect(nativeBid.link.url).to.equal('https://brand.clickme.com/'); + expect(nativeBid.imptrackers).to.have.lengthOf(2); + expect(nativeBid.imptrackers[0]).to.equal('https://imp1.trackme.com/'); + expect(nativeBid.imptrackers[1]).to.equal('https://imp1.contextweb.com/'); + }); + } it('Verifies bidder code', function () { expect(spec.code).to.equal('pulsepoint'); @@ -428,19 +358,6 @@ describe('PulsePoint Adapter Tests', function () { expect(options[0].url).to.equal('https://bh.contextweb.com/visitormatch/prebid'); }); - it('Verify app requests', function () { - const request = spec.buildRequests(appSlotConfig, bidderRequest); - const ortbRequest = request.data; - // site object - expect(ortbRequest.site).to.equal(null); - expect(ortbRequest.app).to.not.be.null; - expect(ortbRequest.app.publisher).to.not.equal(null); - expect(ortbRequest.app.publisher.id).to.equal('p10000'); - expect(ortbRequest.app.bundle).to.equal('com.pulsepoint.apps'); - expect(ortbRequest.app.storeurl).to.equal('https://pulsepoint.com/apps'); - expect(ortbRequest.app.domain).to.equal('pulsepoint.com'); - }); - it('Verify GDPR', function () { const bidderRequestGdpr = { gdprConsent: { @@ -448,7 +365,7 @@ describe('PulsePoint Adapter Tests', function () { consentString: 'serialized_gpdr_data' } }; - const request = spec.buildRequests(slotConfigs, Object.assign({}, bidderRequest, bidderRequestGdpr)); + const request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(Object.assign({}, bidderRequest, bidderRequestGdpr))); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -466,7 +383,8 @@ describe('PulsePoint Adapter Tests', function () { const bidderRequestUSPrivacy = { uspConsent: '1YYY' }; - const request = spec.buildRequests(slotConfigs, Object.assign({}, bidderRequest, bidderRequestUSPrivacy)); + const request = spec.buildRequests(slotConfigs, + syncAddFPDToBidderRequest(Object.assign({}, bidderRequest, bidderRequestUSPrivacy))); expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); expect(request.method).to.equal('POST'); const ortbRequest = request.data; @@ -476,52 +394,54 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.regs.ext.us_privacy).to.equal('1YYY'); }); - it('Verify Video request', function () { - const request = spec.buildRequests(videoSlotConfig, bidderRequest); - expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); - expect(request.method).to.equal('POST'); - const ortbRequest = request.data; - expect(ortbRequest).to.not.equal(null); - expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.be.null; - expect(ortbRequest.imp[0].native).to.be.null; - expect(ortbRequest.imp[0].banner).to.be.null; - expect(ortbRequest.imp[0].video.w).to.equal(400); - expect(ortbRequest.imp[0].video.h).to.equal(300); - expect(ortbRequest.imp[0].video.minduration).to.equal(5); - expect(ortbRequest.imp[0].video.maxduration).to.equal(10); - expect(ortbRequest.imp[0].video.startdelay).to.equal(0); - expect(ortbRequest.imp[0].video.skip).to.equal(1); - expect(ortbRequest.imp[0].video.minbitrate).to.equal(200); - expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]); - }); + if (FEATURES.VIDEO) { + it('Verify Video request', function () { + const request = spec.buildRequests(videoSlotConfig, syncAddFPDToBidderRequest(bidderRequest)); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp).to.have.lengthOf(1); + expect(ortbRequest.imp[0].video).to.not.be.null; + expect(ortbRequest.imp[0].native).to.be.undefined; + expect(ortbRequest.imp[0].banner).to.be.undefined; + expect(ortbRequest.imp[0].video.w).to.equal(400); + expect(ortbRequest.imp[0].video.h).to.equal(300); + expect(ortbRequest.imp[0].video.minduration).to.equal(5); + expect(ortbRequest.imp[0].video.maxduration).to.equal(10); + expect(ortbRequest.imp[0].video.startdelay).to.equal(0); + expect(ortbRequest.imp[0].video.skip).to.equal(1); + expect(ortbRequest.imp[0].video.minbitrate).to.equal(200); + expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]); + }); - it('Verify Video response', function () { - const request = spec.buildRequests(videoSlotConfig, bidderRequest); - expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); - expect(request.method).to.equal('POST'); - const ortbRequest = request.data; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'https//pulsepoint.video.mp4' + it('Verify Video response', function () { + const request = spec.buildRequests(videoSlotConfig, bidderRequest); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + const ortbResponse = { + seatbid: [{ + bid: [{ + impid: ortbRequest.imp[0].id, + price: 1.25, + adm: 'https//pulsepoint.video.mp4', + mtype: 2 + }] }] - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.adId).to.equal('bid12345'); - expect(bid.ad).to.be.undefined; - expect(bid['native']).to.be.undefined; - expect(bid.mediaType).to.equal('video'); - expect(bid.vastXml).to.equal(ortbResponse.seatbid[0].bid[0].adm); - }); + }; + const bids = spec.interpretResponse({ body: ortbResponse }, request); + const bid = bids[0]; + expect(bid.cpm).to.equal(1.25); + expect(bid.ad).to.be.undefined; + expect(bid['native']).to.be.undefined; + expect(bid.mediaType).to.equal('video'); + expect(bid.vastXml).to.equal(ortbResponse.seatbid[0].bid[0].adm); + }); + } it('Verify extra parameters', function () { - let request = spec.buildRequests(additionalParamsConfig, bidderRequest); + let request = spec.buildRequests(additionalParamsConfig, syncAddFPDToBidderRequest(bidderRequest)); let ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); expect(ortbRequest.imp).to.have.lengthOf(1); @@ -536,31 +456,15 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.imp[0].ext.prebid.extra_key4).to.eql([1, 2, 3]); expect(Object.keys(ortbRequest.imp[0].ext.prebid)).to.eql(['extra_key1', 'extra_key2', 'extra_key3', 'extra_key4']); // attempting with a configuration with no unknown params. - request = spec.buildRequests(outstreamSlotConfig, bidderRequest); + request = spec.buildRequests(videoSlotConfig, bidderRequest); ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].ext).to.equal(null); - }); - - it('Verify ortb parameters', function () { - const request = spec.buildRequests(ortbParamsSlotConfig, bidderRequest); - const ortbRequest = request.data; - expect(ortbRequest).to.not.equal(null); - expect(ortbRequest.bcat).to.eql(['IAB-1', 'IAB-20']); - expect(ortbRequest.badv).to.eql(['cocacola.com', 'lays.com']); - expect(ortbRequest.imp).to.have.lengthOf(2); - expect(ortbRequest.imp[0].bidfloor).to.equal(1.5); - expect(ortbRequest.imp[0].banner.battr).to.eql([1, 2, 3]); - expect(ortbRequest.imp[0].ext).to.be.null; - // slot 2 - expect(ortbRequest.imp[1].bidfloor).to.equal(2.5); - expect(ortbRequest.imp[1].video.battr).to.eql([2, 3, 4]); - expect(ortbRequest.imp[1].ext).to.be.null; + expect(ortbRequest.imp[0].ext).to.be.undefined; }); it('Verify schain parameters', function () { - const request = spec.buildRequests(schainParamsSlotConfig, bidderRequest); + const request = spec.buildRequests(schainParamsSlotConfig, syncAddFPDToBidderRequest(bidderRequest)); const ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); expect(ortbRequest.source).to.not.equal(null); @@ -578,42 +482,6 @@ describe('PulsePoint Adapter Tests', function () { expect(ortbRequest.source.ext.schain.nodes[0].domain).to.equal('publisher.com'); }); - it('Verify outstream renderer', function () { - const bidderRequestOutstream = Object.assign({}, bidderRequest, {bids: [outstreamSlotConfig[0]]}); - const request = spec.buildRequests(outstreamSlotConfig, bidderRequestOutstream); - const ortbRequest = request.data; - expect(ortbRequest).to.not.be.null; - expect(ortbRequest.imp[0]).to.not.be.null; - expect(ortbRequest.imp[0].video).to.not.be.null; - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'https//pulsepoint.video.mp4', - ext: { - outstream: { - type: 'Inline', - config: { - text: 'ADVERTISEMENT', - skipaftersec: 5 - }, - rendererUrl: 'https://tag.contextweb.com/hb-outstr-renderer.js' - } - } - }] - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - const bid = bids[0]; - expect(bid.cpm).to.equal(1.25); - expect(bid.renderer).to.not.be.null; - expect(bid.renderer.url).to.equal('https://tag.contextweb.com/hb-outstr-renderer.js'); - expect(bid.renderer.getConfig()).to.not.be.null; - expect(bid.renderer.getConfig().defaultOptions).to.eql(ortbResponse.seatbid[0].bid[0].ext.outstream.config); - expect(bid.renderer.getConfig().rendererOptions).to.eql(outstreamSlotConfig[0].renderer.options); - expect(bid.renderer.getConfig().type).to.equal('Inline'); - }); it('Verify common id parameters', function () { const bidRequests = deepClone(slotConfigs); bidRequests[0].userIdAsEids = [{ @@ -631,167 +499,172 @@ describe('PulsePoint Adapter Tests', function () { }] } ]; - const request = spec.buildRequests(bidRequests, bidderRequest); + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); expect(request).to.be.not.null; - const ortbRequest = request.data; expect(request.data).to.be.not.null; + const ortbRequest = request.data; // user object expect(ortbRequest.user).to.not.be.undefined; expect(ortbRequest.user.ext).to.not.be.undefined; expect(ortbRequest.user.ext.eids).to.not.be.undefined; expect(ortbRequest.user.ext.eids).to.deep.equal(bidRequests[0].userIdAsEids); }); - it('Verify multiple adsizes', function () { - const bidRequests = deepClone(slotConfigs); - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request).to.be.not.null; - expect(request.data).to.be.not.null; - const ortbRequest = request.data; - expect(ortbRequest.imp).to.have.lengthOf(2); - // first impression has multi sizes - expect(ortbRequest.imp[0].banner).to.not.be.null; - expect(ortbRequest.imp[0].banner.w).to.equal(300); - expect(ortbRequest.imp[0].banner.h).to.equal(250); - expect(ortbRequest.imp[0].banner.format).to.not.be.null; - expect(ortbRequest.imp[0].banner.format).to.have.lengthOf(2); - expect(ortbRequest.imp[0].banner.format[0].w).to.equal(728); - expect(ortbRequest.imp[0].banner.format[0].h).to.equal(90); - expect(ortbRequest.imp[0].banner.format[1].w).to.equal(160); - expect(ortbRequest.imp[0].banner.format[1].h).to.equal(600); - // slot 2 - expect(ortbRequest.imp[1].banner).to.not.be.null; - expect(ortbRequest.imp[1].banner.w).to.equal(728); - expect(ortbRequest.imp[1].banner.h).to.equal(90); - expect(ortbRequest.imp[1].banner.format).to.not.be.null; - expect(ortbRequest.imp[1].banner.format).to.have.lengthOf(1); - expect(ortbRequest.imp[1].banner.format[0].w).to.equal(728); - expect(ortbRequest.imp[1].banner.format[0].h).to.equal(90); - // adsize on response - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad', - crid: 'Creative#123', - w: 728, - h: 90 - }] - }] - }; - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(1); - const bid = bids[0]; - expect(bid.width).to.equal(728); - expect(bid.height).to.equal(90); - }); - it('Verify multi-format response', function () { - const bidRequests = deepClone(slotConfigs); - bidRequests[0].mediaTypes['native'] = { - title: { - required: true + + it('Verify user level first party data', function () { + const bidderRequest = { + refererInfo: { + page: 'https://publisher.com/home', + ref: 'https://referrer' }, - image: { - required: true + gdprConsent: { + gdprApplies: true, + consentString: 'serialized_gpdr_data' }, - sponsoredBy: { - required: true + ortb2: { + user: { + yob: 1985, + gender: 'm', + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + } } }; - bidRequests[1].params.video = { - w: 400, - h: 300, - minduration: 5, - maxduration: 10, - }; - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request).to.be.not.null; - expect(request.data).to.be.not.null; - const ortbRequest = request.data; - expect(ortbRequest.imp).to.have.lengthOf(2); - // adsize on response - const ortbResponse = { - seatbid: [{ - bid: [{ - impid: ortbRequest.imp[0].id, - price: 1.25, - adm: 'This is an Ad', - crid: 'Creative#123', - w: 728, - h: 90 - }, { - impid: ortbRequest.imp[1].id, - price: 2.5, - adm: '', - crid: 'Creative#234', - w: 728, - h: 90 - }] - }] - }; - // request has both types - banner and native, response is parsed as banner. - // for impression#2, response is parsed as video - const bids = spec.interpretResponse({ body: ortbResponse }, request); - expect(bids).to.have.lengthOf(2); - const bid = bids[0]; - expect(bid.width).to.equal(728); - expect(bid.height).to.equal(90); - const secondBid = bids[1]; - expect(secondBid.vastXml).to.equal(''); - }); - it('Verify bid floor', function () { - const bidRequests = deepClone(slotConfigs); - bidRequests[0].params.bidfloor = 1.05; - let request = spec.buildRequests(bidRequests, bidderRequest); + let request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest)); let ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); - expect(ortbRequest.imp[0].bidfloor).to.equal(1.05); - expect(ortbRequest.imp[1].bidfloor).to.be.undefined; - let floorArg = null; - // publisher uses the floor module - bidRequests[0].getFloor = (arg) => { - floorArg = arg; - return { floor: 1.25 }; - }; - bidRequests[1].getFloor = () => { - return { floor: 2.05 }; + expect(ortbRequest.user).to.not.equal(null); + expect(ortbRequest.user).to.deep.equal({ + yob: 1985, + gender: 'm', + ext: { + data: { + registered: true, + interests: ['cars'] + }, + consent: 'serialized_gpdr_data' + } + }); + }); + + it('Verify site level first party data', function () { + const bidderRequest = { + ortb2: { + site: { + content: { + data: [{ + name: 'www.iris.com', + ext: { + segtax: 500, + cids: ['iris_c73g5jq96mwso4d8'] + } + }] + }, + page: 'http://pub.com/news', + ref: 'http://google.com', + publisher: { + domain: 'pub.com' + } + } + } }; - request = spec.buildRequests(bidRequests, bidderRequest); - ortbRequest = request.data; + let request = spec.buildRequests(slotConfigs, syncAddFPDToBidderRequest(bidderRequest)); + let ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); - expect(ortbRequest.imp[0].bidfloor).to.equal(1.25); - expect(ortbRequest.imp[1].bidfloor).to.equal(2.05); - expect(floorArg).to.not.be.null; - expect(floorArg.mediaType).to.equal('banner'); - expect(floorArg.currency).to.equal('USD'); - expect(floorArg.size).to.equal('*'); + expect(ortbRequest.site).to.not.equal(null); + expect(ortbRequest.site).to.deep.equal({ + content: { + data: [{ + name: 'www.iris.com', + ext: { + segtax: 500, + cids: ['iris_c73g5jq96mwso4d8'] + } + }] + }, + page: 'http://pub.com/news', + ref: 'http://google.com', + publisher: { + id: 'p10000', + domain: 'pub.com' + } + }); }); - it('Verify Video params on mediaTypes.video', function () { - const bidRequests = deepClone(videoSlotConfig); - bidRequests[0].mediaTypes = { - video: { - w: 600, - h: 400, - minduration: 15, - maxduration: 20, - startdelay: 10, - skip: 0, + + it('Verify impression/slot level first party data', function () { + const bidderRequests = [{ + placementCode: '/DfpAccount1/slot1', + mediaTypes: { + banner: { + sizes: [[1, 1]] + } + }, + bidId: 'bid12345', + params: { + cp: 'p10000', + ct: 't10000', + extra_key1: 'extra_val1', + extra_key2: 12345 + }, + ortb2Imp: { + ext: { + data: { + pbadslot: 'homepage-top-rect', + adUnitSpecificAttribute: '123' + } + } } - }; - const request = spec.buildRequests(bidRequests, bidderRequest); - const ortbRequest = request.data; + }]; + let request = spec.buildRequests(bidderRequests, bidderRequest); + let ortbRequest = request.data; expect(ortbRequest).to.not.equal(null); + expect(ortbRequest.imp).to.not.equal(null); expect(ortbRequest.imp).to.have.lengthOf(1); - expect(ortbRequest.imp[0].video).to.not.be.null; - expect(ortbRequest.imp[0].native).to.be.null; - expect(ortbRequest.imp[0].banner).to.be.null; - expect(ortbRequest.imp[0].video.w).to.equal(600); - expect(ortbRequest.imp[0].video.h).to.equal(400); - expect(ortbRequest.imp[0].video.minduration).to.equal(15); - expect(ortbRequest.imp[0].video.maxduration).to.equal(20); - expect(ortbRequest.imp[0].video.startdelay).to.equal(10); - expect(ortbRequest.imp[0].video.skip).to.equal(0); - expect(ortbRequest.imp[0].video.minbitrate).to.equal(200); - expect(ortbRequest.imp[0].video.protocols).to.eql([1, 2, 4]); + expect(ortbRequest.imp[0].ext).to.not.equal(null); + expect(ortbRequest.imp[0].ext).to.deep.equal({ + prebid: { + extra_key1: 'extra_val1', + extra_key2: 12345 + }, + data: { + pbadslot: 'homepage-top-rect', + adUnitSpecificAttribute: '123' + } + }); }); + + it('Verify bid request timeouts', function () { + const mkRequest = (bidderRequest) => spec.buildRequests(slotConfigs, bidderRequest).data; + // assert default is used when no bidderRequest.timeout value is available + expect(mkRequest(bidderRequest).tmax).to.equal(500) + + // assert bidderRequest value is used when available + expect(mkRequest(Object.assign({}, { timeout: 6000 }, bidderRequest)).tmax).to.equal(6000) + }); + + it('Verify deals', function () { + const bidRequests = deepClone(slotConfigs); + const deals = [{ + id: 'DEAL_ONE', + bidfloor: 1.1 + }, { + id: 'DEAL_TWO', + bidfloor: 2.2 + }]; + bidRequests[0].params.deals = deals; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request.url).to.equal('https://bid.contextweb.com/header/ortb?src=prebid'); + expect(request.method).to.equal('POST'); + const ortbRequest = request.data; + // slot 1 + expect(ortbRequest.imp[0].tagid).to.equal('t10000'); + expect(ortbRequest.imp[0].pmp).to.not.be.undefined; + expect(ortbRequest.imp[0].pmp).to.deep.equal({ + private_auction: 0, + deals + }); + }) }); diff --git a/test/spec/modules/pxyzBidAdapter_spec.js b/test/spec/modules/pxyzBidAdapter_spec.js index 21dd252c909..3a336c86e46 100644 --- a/test/spec/modules/pxyzBidAdapter_spec.js +++ b/test/spec/modules/pxyzBidAdapter_spec.js @@ -8,7 +8,7 @@ const GDPR_CONSENT = 'XYZ-CONSENT'; const BIDDER_REQUEST = { refererInfo: { - referer: 'https://example.com' + page: 'https://example.com', } }; diff --git a/test/spec/modules/quantcastBidAdapter_spec.js b/test/spec/modules/quantcastBidAdapter_spec.js index 5e0d129581c..d10fea829bc 100644 --- a/test/spec/modules/quantcastBidAdapter_spec.js +++ b/test/spec/modules/quantcastBidAdapter_spec.js @@ -19,7 +19,15 @@ describe('Quantcast adapter', function () { let bidRequest; let bidderRequest; + afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); beforeEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + quantcast: { + storageAllowed: true + } + }; bidRequest = { bidder: 'quantcast', bidId: '2f7b179d443f14', @@ -39,8 +47,9 @@ describe('Quantcast adapter', function () { bidderRequest = { refererInfo: { - referer: 'http://example.com/hello.html', - canonicalUrl: 'http://example.com/hello.html' + page: 'http://example.com/hello.html', + ref: 'http://example.com/hello.html', + domain: 'example.com' } }; @@ -438,74 +447,6 @@ describe('Quantcast adapter', function () { expect(parsed.gdprConsent).to.equal('consentString'); }); - it('allows TCF v1 request with consent for purpose 1', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'consentString', - vendorData: { - vendorConsents: { - '11': true - }, - purposeConsents: { - '1': true - } - }, - apiVersion: 1 - } - }; - - const requests = qcSpec.buildRequests([bidRequest], bidderRequest); - const parsed = JSON.parse(requests[0].data); - - expect(parsed.gdprSignal).to.equal(1); - expect(parsed.gdprConsent).to.equal('consentString'); - }); - - it('blocks TCF v1 request without vendor consent', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'consentString', - vendorData: { - vendorConsents: { - '11': false - }, - purposeConsents: { - '1': true - } - }, - apiVersion: 1 - } - }; - - const requests = qcSpec.buildRequests([bidRequest], bidderRequest); - - expect(requests).to.equal(undefined); - }); - - it('blocks TCF v1 request without consent for purpose 1', function () { - const bidderRequest = { - gdprConsent: { - gdprApplies: true, - consentString: 'consentString', - vendorData: { - vendorConsents: { - '11': true - }, - purposeConsents: { - '1': false - } - }, - apiVersion: 1 - } - }; - - const requests = qcSpec.buildRequests([bidRequest], bidderRequest); - - expect(requests).to.equal(undefined); - }); - it('allows TCF v2 request when Quantcast has consent for purpose 1', function() { const bidderRequest = { gdprConsent: { diff --git a/test/spec/modules/qwarryBidAdapter_spec.js b/test/spec/modules/qwarryBidAdapter_spec.js index 560206681ee..5d48d92066a 100644 --- a/test/spec/modules/qwarryBidAdapter_spec.js +++ b/test/spec/modules/qwarryBidAdapter_spec.js @@ -89,7 +89,7 @@ describe('qwarryBidAdapter', function () { consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' }, refererInfo: { - referer: 'http://test.com/path.html' + page: 'http://test.com/path.html', } }) diff --git a/test/spec/modules/radsBidAdapter_spec.js b/test/spec/modules/radsBidAdapter_spec.js index 271f7cb1147..3ad7ada2ae7 100644 --- a/test/spec/modules/radsBidAdapter_spec.js +++ b/test/spec/modules/radsBidAdapter_spec.js @@ -105,13 +105,13 @@ describe('radsAdapter', function () { // Without gdprConsent let bidderRequest = { refererInfo: { - referer: 'some_referrer.net' + page: 'some_referrer.net' } } // With gdprConsent var bidderRequestGdprConsent = { refererInfo: { - referer: 'some_referrer.net' + page: 'some_referrer.net' }, gdprConsent: { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', diff --git a/test/spec/modules/rasBidAdapter_spec.js b/test/spec/modules/rasBidAdapter_spec.js new file mode 100644 index 00000000000..bfa72a2510e --- /dev/null +++ b/test/spec/modules/rasBidAdapter_spec.js @@ -0,0 +1,196 @@ +import { expect } from 'chai'; +import { spec } from 'modules/rasBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const CSR_ENDPOINT = 'https://csr.onet.pl/4178463/csr-006/csr.json?nid=4178463&'; + +describe('rasBidAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('should return true when required params found', function () { + const bid = { + sizes: [[300, 250], [300, 600]], + bidder: 'ras', + params: { + slot: 'slot', + area: 'areatest', + site: 'test', + network: '4178463' + } + }; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params not found', function () { + const failBid = { + sizes: [[300, 250], [300, 300]], + bidder: 'ras', + params: { + site: 'test', + network: '4178463' + } + }; + expect(spec.isBidRequestValid(failBid)).to.equal(false); + }); + + it('should return nothing when bid request is malformed', function () { + const failBid = { + sizes: [[300, 250], [300, 300]], + bidder: 'ras', + }; + expect(spec.isBidRequestValid(failBid)).to.equal(undefined); + }); + }); + + describe('buildRequests', function () { + const bid = { + sizes: [[300, 250], [300, 600]], + bidder: 'ras', + bidId: 1, + params: { + slot: 'test', + area: 'areatest', + site: 'test', + slotSequence: '0', + network: '4178463', + customParams: { + test: 'name=value' + } + } + }; + const bid2 = { + sizes: [[750, 300]], + bidder: 'ras', + bidId: 2, + params: { + slot: 'test2', + area: 'areatest', + site: 'test', + network: '4178463' + } + }; + + it('should parse bids to request', function () { + const requests = spec.buildRequests([bid], { + 'gdprConsent': { + 'gdprApplies': true, + 'consentString': 'some-consent-string' + }, + 'refererInfo': { + 'ref': 'https://example.org/', + 'page': 'https://example.com/' + } + }); + expect(requests[0].url).to.have.string(CSR_ENDPOINT); + expect(requests[0].url).to.have.string('slot0=test'); + expect(requests[0].url).to.have.string('id0=1'); + expect(requests[0].url).to.have.string('site=test'); + expect(requests[0].url).to.have.string('area=areatest'); + expect(requests[0].url).to.have.string('cre_format=html'); + expect(requests[0].url).to.have.string('systems=das'); + expect(requests[0].url).to.have.string('ems_url=1'); + expect(requests[0].url).to.have.string('bid_rate=1'); + expect(requests[0].url).to.have.string('gdpr_applies=true'); + expect(requests[0].url).to.have.string('euconsent=some-consent-string'); + expect(requests[0].url).to.have.string('du=https%3A%2F%2Fexample.com%2F'); + expect(requests[0].url).to.have.string('dr=https%3A%2F%2Fexample.org%2F'); + expect(requests[0].url).to.have.string('test=name%3Dvalue'); + }); + + it('should return empty consent string when undefined', function () { + const requests = spec.buildRequests([bid]); + const gdpr = requests[0].url.search('gdpr_applies'); + const euconsent = requests[0].url.search('euconsent='); + expect(gdpr).to.equal(-1); + expect(euconsent).to.equal(-1); + }); + + it('should parse bids to request from pageContext', function () { + const bidCopy = { ...bid }; + bidCopy.params = { + ...bid.params, + pageContext: { + dv: 'test/areatest', + du: 'https://example.com/', + dr: 'https://example.org/', + keyWords: ['val1', 'val2'], + keyValues: { + adunit: 'test/areatest' + } + } + }; + const requests = spec.buildRequests([bidCopy, bid2]); + expect(requests[0].url).to.have.string(CSR_ENDPOINT); + expect(requests[0].url).to.have.string('slot0=test'); + expect(requests[0].url).to.have.string('id0=1'); + expect(requests[0].url).to.have.string('iusizes0=300x250%2C300x600'); + expect(requests[0].url).to.have.string('slot1=test2'); + expect(requests[0].url).to.have.string('id1=2'); + expect(requests[0].url).to.have.string('iusizes1=750x300'); + expect(requests[0].url).to.have.string('site=test'); + expect(requests[0].url).to.have.string('area=areatest'); + expect(requests[0].url).to.have.string('cre_format=html'); + expect(requests[0].url).to.have.string('systems=das'); + expect(requests[0].url).to.have.string('ems_url=1'); + expect(requests[0].url).to.have.string('bid_rate=1'); + expect(requests[0].url).to.have.string('du=https%3A%2F%2Fexample.com%2F'); + expect(requests[0].url).to.have.string('dr=https%3A%2F%2Fexample.org%2F'); + expect(requests[0].url).to.have.string('DV=test%2Fareatest'); + expect(requests[0].url).to.have.string('kwrd=val1%2Bval2'); + expect(requests[0].url).to.have.string('kvadunit=test%2Fareatest'); + expect(requests[0].url).to.have.string('pos0=0'); + }); + }); + + describe('interpretResponse', function () { + const response = { + 'adsCheck': 'ok', + 'geoloc': {}, + 'ir': '92effd60-0c84-4dac-817e-763ea7b8ac65', + 'ads': [ + { + 'id': 'flat-belkagorna', + 'slot': 'flat-belkagorna', + 'prio': 10, + 'type': 'html', + 'bid_rate': 0.321123, + 'adid': 'das,50463,152276', + 'id_3': '12734', + 'html': '' + } + ], + 'iv': '202003191334467636346500' + }; + + it('should get correct bid response', function () { + const resp = spec.interpretResponse({ body: response }, { bidIds: [{ slot: 'flat-belkagorna', bidId: 1 }] }); + expect(resp[0]).to.have.all.keys('cpm', 'currency', 'netRevenue', 'requestId', 'ttl', 'width', 'height', 'creativeId', 'dealId', 'ad', 'meta'); + expect(resp.length).to.equal(1); + }); + + it('should handle empty ad', function () { + let res = { + 'ads': [{ + type: 'empty' + }] + }; + const resp = spec.interpretResponse({ body: res }, {}); + expect(resp).to.deep.equal([]); + }); + + it('should handle empty server response', function () { + let res = { + 'ads': [] + }; + const resp = spec.interpretResponse({ body: res }, {}); + expect(resp).to.deep.equal([]); + }); + }); +}); diff --git a/test/spec/modules/readpeakBidAdapter_spec.js b/test/spec/modules/readpeakBidAdapter_spec.js index 04358fad52b..8772aeac88f 100644 --- a/test/spec/modules/readpeakBidAdapter_spec.js +++ b/test/spec/modules/readpeakBidAdapter_spec.js @@ -16,7 +16,8 @@ describe('ReadPeakAdapter', function() { beforeEach(function() { bidderRequest = { refererInfo: { - referer: 'https://publisher.com/home' + page: 'https://publisher.com/home', + domain: 'publisher.com' } }; @@ -266,8 +267,8 @@ describe('ReadPeakAdapter', function() { expect(data.imp[0].tagId).to.equal('test-tag-1'); expect(data.site.publisher.id).to.equal(nativeBidRequest.params.publisherId); expect(data.site.id).to.equal(nativeBidRequest.params.siteId); - expect(data.site.page).to.equal(bidderRequest.refererInfo.referer); - expect(data.site.domain).to.equal(parseUrl(bidderRequest.refererInfo.referer).hostname); + expect(data.site.page).to.equal(bidderRequest.refererInfo.page); + expect(data.site.domain).to.equal(bidderRequest.refererInfo.domain); expect(data.device).to.deep.contain({ ua: navigator.userAgent, language: navigator.language @@ -428,8 +429,8 @@ describe('ReadPeakAdapter', function() { expect(data.imp[0].tagId).to.equal('test-tag-1'); expect(data.site.publisher.id).to.equal(bannerBidRequest.params.publisherId); expect(data.site.id).to.equal(bannerBidRequest.params.siteId); - expect(data.site.page).to.equal(bidderRequest.refererInfo.referer); - expect(data.site.domain).to.equal(parseUrl(bidderRequest.refererInfo.referer).hostname); + expect(data.site.page).to.equal(bidderRequest.refererInfo.page); + expect(data.site.domain).to.equal(bidderRequest.refererInfo.domain); expect(data.device).to.deep.contain({ ua: navigator.userAgent, language: navigator.language @@ -527,6 +528,7 @@ describe('ReadPeakAdapter', function() { ad: bannerServerResponse.seatbid[0].bid[0].adm, width: bannerServerResponse.seatbid[0].bid[0].w, height: bannerServerResponse.seatbid[0].bid[0].h, + burl: bannerServerResponse.seatbid[0].bid[0].burl, }); expect(bidResponse.meta).to.deep.equal({ advertiserDomains: ['readpeak.com'], diff --git a/test/spec/modules/realTimeDataModule_spec.js b/test/spec/modules/realTimeDataModule_spec.js index daeeb9bc47c..938e2e2f3c1 100644 --- a/test/spec/modules/realTimeDataModule_spec.js +++ b/test/spec/modules/realTimeDataModule_spec.js @@ -4,6 +4,9 @@ import * as sinon from 'sinon'; import {default as CONSTANTS} from '../../../src/constants.json'; import * as events from '../../../src/events.js'; import 'src/prebid.js'; +import {attachRealTimeDataProvider, onDataDeletionRequest} from 'modules/rtdModule/index.js'; +import {GDPR_GVLIDS} from '../../../src/consentHandler.js'; +import {MODULE_TYPE_RTD} from '../../../src/activities/modules.js'; const getBidRequestDataSpy = sinon.spy(); @@ -83,6 +86,26 @@ describe('Real time module', function () { sandbox.restore(); }); + describe('GVL IDs', () => { + beforeEach(() => { + sinon.stub(GDPR_GVLIDS, 'register'); + }); + + afterEach(() => { + GDPR_GVLIDS.register.restore(); + }); + + it('are registered when RTD module is registered', () => { + let mod; + try { + mod = attachRealTimeDataProvider({name: 'mockRtd', gvlid: 123}); + sinon.assert.calledWith(GDPR_GVLIDS.register, MODULE_TYPE_RTD, 'mockRtd', 123); + } finally { + mod && mod(); + } + }) + }) + describe('', () => { const PROVIDERS = [validSM, invalidSM, failureSM, nonConfSM, validSMWait]; let _detachers; @@ -105,7 +128,7 @@ describe('Real time module', function () { it('should be able to modify bid request', function (done) { rtdModule.setBidRequestsData(() => { assert(getBidRequestDataSpy.calledTwice); - assert(getBidRequestDataSpy.calledWith({bidRequest: {}})); + assert(getBidRequestDataSpy.calledWith(sinon.match({bidRequest: {}}))); done(); }, {bidRequest: {}}) }); @@ -305,4 +328,68 @@ describe('Real time module', function () { }); }); }); + + describe('data deletion requests', () => { + let detach = () => null; + + function mkRtdModule(name) { + const mod = { + name, + init: () => true, + onDataDeletionRequest: sinon.stub() + }; + detach = ((orig) => { + const smDetach = attachRealTimeDataProvider(mod); + return function () { + orig(); + smDetach(); + } + })(detach); + return mod; + } + let sm1, sm2, cfg1, cfg2; + beforeEach(() => { + sm1 = mkRtdModule('mockMod1'); + sm2 = mkRtdModule('mockMod2'); + cfg1 = { + name: 'mockMod1', + i: 0 + }; + cfg2 = { + name: 'mockMod2', + i: 1 + }; + rtdModule.init(config); + config.setConfig({ + realTimeData: { + dataProviders: [cfg1, cfg2], + } + }); + }); + afterEach(() => { + detach(); + config.resetConfig(); + }); + + it('calls onDataDeletionRequest on submodules', () => { + const next = sinon.stub(); + onDataDeletionRequest(next, {a: 0}); + sinon.assert.calledWith(next, {a: 0}); + sinon.assert.calledWith(sm1.onDataDeletionRequest, cfg1); + sinon.assert.calledWith(sm2.onDataDeletionRequest, cfg2); + }); + + describe('does not choke if onDataDeletionRequest', () => { + Object.entries({ + 'is missing': () => { delete sm1.onDataDeletionRequest }, + 'throws': () => { sm1.onDataDeletionRequest.throws(new Error()) } + }).forEach(([t, setup]) => { + it(t, () => { + setup(); + onDataDeletionRequest(sinon.stub()); + sinon.assert.calledWith(sm2.onDataDeletionRequest, cfg2); + }) + }) + }) + }); }); diff --git a/test/spec/modules/realvuAnalyticsAdapter_spec.js b/test/spec/modules/realvuAnalyticsAdapter_spec.js deleted file mode 100644 index e51a4e2e3a2..00000000000 --- a/test/spec/modules/realvuAnalyticsAdapter_spec.js +++ /dev/null @@ -1,194 +0,0 @@ -import { expect } from 'chai'; -import realvuAnalyticsAdapter, { lib } from 'modules/realvuAnalyticsAdapter.js'; -import CONSTANTS from 'src/constants.json'; - -function addDiv(id) { - let dv = document.createElement('div'); - dv.id = id; - dv.style.width = '728px'; - dv.style.height = '90px'; - dv.style.display = 'block'; - document.body.appendChild(dv); - let f = document.createElement('iframe'); - f.width = 728; - f.height = 90; - dv.appendChild(f); - let d = null; - if (f.contentDocument) d = f.contentDocument; // DOM - else if (f.contentWindow) d = f.contentWindow.document; // IE - d.open() - d.write(''); - d.close(); - return dv; -} - -describe('RealVu', function() { - let sandbox; - beforeEach(function () { - sandbox = sinon.sandbox.create(); - addDiv('ad1'); - addDiv('ad2'); - sandbox.stub(lib, 'scr'); - }); - - afterEach(function () { - let a1 = document.getElementById('ad1'); - document.body.removeChild(a1); - let a2 = document.getElementById('ad2'); - document.body.removeChild(a2); - sandbox.restore(); - realvuAnalyticsAdapter.disableAnalytics(); - }); - - after(function () { - delete window.top1; - delete window.realvu_aa_fifo; - delete window.realvu_aa; - clearInterval(window.boost_poll); - delete window.boost_poll; - }); - - describe('Analytics Adapter.', function () { - it('enableAnalytics', function () { - const config = { - options: { - partnerId: '1Y', - regAllUnits: true - // unitIds: ['ad1', 'ad2'] - } - }; - let p = realvuAnalyticsAdapter.enableAnalytics(config); - expect(p).to.equal('1Y'); - }); - - it('checkIn', function () { - const bid = { - adUnitCode: 'ad1', - sizes: [ - [728, 90], - [970, 250], - [970, 90] - ] - }; - let result = realvuAnalyticsAdapter.checkIn(bid, '1Y'); - const b = Object.assign({}, window.top1.realvu_aa); - let a = b.ads[0]; - // console.log('a: ' + a.x + ', ' + a.y + ', ' + a.w + ', ' + a.h); - // console.log('b: ' + b.x1 + ', ' + b.y1 + ', ' + b.x2 + ', ' + b.y2); - expect(result).to.equal('yes'); - - result = realvuAnalyticsAdapter.checkIn(bid); // test invalid partnerId 'undefined' - result = realvuAnalyticsAdapter.checkIn(bid, ''); // test invalid partnerId '' - }); - - it.skip('isInView returns "yes"', () => { - let inview = realvuAnalyticsAdapter.isInView('ad1'); - expect(inview).to.equal('yes'); - }); - - it('isInView return "NA"', function () { - const adUnitCode = '1234'; - let result = realvuAnalyticsAdapter.isInView(adUnitCode); - expect(result).to.equal('NA'); - }); - - it('bid response event', function () { - const config = { - options: { - partnerId: '1Y', - regAllUnits: true - // unitIds: ['ad1', 'ad2'] - } - }; - realvuAnalyticsAdapter.enableAnalytics(config); - const args = { - 'biddercode': 'realvu', - 'adUnitCode': 'ad1', - 'width': 300, - 'height': 250, - 'statusMessage': 'Bid available', - 'adId': '7ba299eba818c1', - 'mediaType': 'banner', - 'creative_id': 85792851, - 'cpm': 0.4308 - }; - realvuAnalyticsAdapter.track({ - eventType: CONSTANTS.EVENTS.BID_RESPONSE, - args: args - }); - const boost = Object.assign({}, window.top1.realvu_aa); - expect(boost.ads[boost.len - 1].bids.length).to.equal(1); - - realvuAnalyticsAdapter.track({ - eventType: CONSTANTS.EVENTS.BID_WON, - args: args - }); - expect(boost.ads[boost.len - 1].bids[0].winner).to.equal(1); - }); - }); - - describe('Boost.', function () { - // const boost = window.top1.realvu_aa; - let boost; - beforeEach(function() { - boost = Object.assign({}, window.top1.realvu_aa); - }); - it('brd', function () { - let a1 = document.getElementById('ad1'); - let p = boost.brd(a1, 'Left'); - expect(typeof p).to.not.equal('undefined'); - }); - - it('addUnitById', function () { - let a1 = document.getElementById('ad1'); - let p = boost.addUnitById('1Y', 'ad1'); - expect(typeof p).to.not.equal('undefined'); - }); - - it('questA', function () { - const dv = document.getElementById('ad1'); - let q = boost.questA(dv); - expect(q).to.not.equal(null); - }); - - it('render', function () { - let dv = document.getElementById('ad1'); - // dv.style.width = '728px'; - // dv.style.height = '90px'; - // dv.style.display = 'block'; - dv.getBoundingClientRect = false; - // document.body.appendChild(dv); - let q = boost.findPosG(dv); - expect(q).to.not.equal(null); - }); - - it('readPos', function () { - const a = boost.ads[boost.len - 1]; - let r = boost.readPos(a); - expect(r).to.equal(true); - }); - - it('send_track', function () { - const a = boost.ads[boost.len - 1]; - boost.track(a, 'show', ''); - boost.sr = 'a'; - boost.send_track(); - expect(boost.beacons.length).to.equal(0); - }); - - it('questA text', function () { - let p = document.createElement('p'); - p.innerHTML = 'ABC'; - document.body.appendChild(p); - let r = boost.questA(p.firstChild); - document.body.removeChild(p); - expect(r).to.not.equal(null); - }); - - it('_f=conf', function () { - const a = boost.ads[boost.len - 1]; - let r = boost.tru(a, 'conf'); - expect(r).to.not.include('_ps='); - }); - }); -}); diff --git a/test/spec/modules/redtramBidAdapter_spec.js b/test/spec/modules/redtramBidAdapter_spec.js new file mode 100644 index 00000000000..e136c37962b --- /dev/null +++ b/test/spec/modules/redtramBidAdapter_spec.js @@ -0,0 +1,256 @@ +import {expect} from 'chai'; +import {spec} from '../../../modules/redtramBidAdapter.js'; +import { BANNER } from '../../../src/mediaTypes.js'; +import * as utils from '../../../src/utils.js'; + +describe('RedtramBidAdapter', function () { + const bid = { + bidId: '23dc19818e5293', + bidder: 'redtram', + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 23611, + } + }; + + const bidderRequest = { + refererInfo: { + referer: 'test.com' + } + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + delete bid.params.placementId; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests([bid], bidderRequest); + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal('https://prebid.redtram.com/pbjs'); + }); + it('Returns valid data if array of bids is valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', 'deviceHeight', 'language', 'host', 'page', 'placements'); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.gdpr).to.not.exist; + expect(data.ccpa).to.not.exist; + let placement = data['placements'][0]; + expect(placement).to.have.keys('placementId', 'bidId', 'adFormat', 'sizes', 'schain', 'bidfloor'); + expect(placement.placementId).to.equal(23611); + expect(placement.bidId).to.equal('23dc19818e5293'); + expect(placement.adFormat).to.equal(BANNER); + expect(placement.schain).to.be.an('object'); + expect(placement.sizes).to.be.an('array'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + bidderRequest.gdprConsent = 'test'; + serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = 'test'; + serverRequest = spec.buildRequests([bid], bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([]); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23dc19818e5293', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: {} + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23dc19818e5293'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.width).to.equal(300); + expect(dataItem.height).to.equal(250); + expect(dataItem.ad).to.equal('Test'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23dc19818e5293', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function () { + it('should do nothing on getUserSyncs', function () { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal('https://prebid.redtram.com/sync/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0') + }); + }); + + describe('on bidWon', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('should replace nurl for banner', function () { + const nurl = 'nurl/?ap=${' + 'AUCTION_PRICE}'; + const bid = { + 'bidderCode': 'redtram', + 'width': 300, + 'height': 250, + 'statusMessage': 'Bid available', + 'adId': '5691dd18ba6ab6', + 'requestId': '23dc19818e5293', + 'transactionId': '948c716b-bf64-4303-bcf4-395c2f6a9770', + 'auctionId': 'a6b7c61f-15a9-481b-8f64-e859787e9c07', + 'mediaType': 'banner', + 'source': 'client', + 'ad': "
\n", + 'cpm': 0.68, + 'nurl': nurl, + 'creativeId': 'test', + 'currency': 'USD', + 'dealId': '', + 'meta': { + 'advertiserDomains': [], + 'dchain': { + 'ver': '1.0', + 'complete': 0, + 'nodes': [ + { + 'name': 'redtram' + } + ] + } + }, + 'netRevenue': true, + 'ttl': 120, + 'metrics': {}, + 'adapterCode': 'redtram', + 'originalCpm': 0.68, + 'originalCurrency': 'USD', + 'responseTimestamp': 1668162732297, + 'requestTimestamp': 1668162732292, + 'bidder': 'redtram', + 'adUnitCode': 'div-prebid', + 'timeToRespond': 5, + 'pbLg': '0.50', + 'pbMg': '0.60', + 'pbHg': '0.68', + 'pbAg': '0.65', + 'pbDg': '0.68', + 'pbCg': '', + 'size': '300x250', + 'adserverTargeting': { + 'hb_bidder': 'redtram', + 'hb_adid': '5691dd18ba6ab6', + 'hb_pb': '0.68', + 'hb_size': '300x250', + 'hb_source': 'client', + 'hb_format': 'banner', + 'hb_adomain': '' + }, + 'status': 'rendered', + 'params': [ + { + 'placementId': 23611 + } + ] + }; + spec.onBidWon(bid); + expect(bid.nurl).to.deep.equal('nurl/?ap=0.68'); + }); + }); +}); diff --git a/test/spec/modules/relaidoBidAdapter_spec.js b/test/spec/modules/relaidoBidAdapter_spec.js index f0d381ee3ed..7778e9cbf80 100644 --- a/test/spec/modules/relaidoBidAdapter_spec.js +++ b/test/spec/modules/relaidoBidAdapter_spec.js @@ -1,27 +1,24 @@ -import { expect } from 'chai'; -import { spec } from 'modules/relaidoBidAdapter.js'; +import {expect} from 'chai'; +import {spec} from 'modules/relaidoBidAdapter.js'; import * as utils from 'src/utils.js'; -import { BANNER, VIDEO } from 'src/mediaTypes.js'; -import { getStorageManager } from '../../../src/storageManager.js'; +import {VIDEO} from 'src/mediaTypes.js'; +import {getCoreStorageManager} from '../../../src/storageManager.js'; const UUID_KEY = 'relaido_uuid'; -const DEFAULT_USER_AGENT = window.navigator.userAgent; -const MOBILE_USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1'; const relaido_uuid = 'hogehoge'; -const setUADefault = () => { window.navigator.__defineGetter__('userAgent', function () { return DEFAULT_USER_AGENT }) }; -const setUAMobile = () => { window.navigator.__defineGetter__('userAgent', function () { return MOBILE_USER_AGENT }) }; - -const storage = getStorageManager(); -storage.setCookie(UUID_KEY, relaido_uuid); - describe('RelaidoAdapter', function () { let bidRequest; let bidderRequest; let serverResponse; + let serverResponseBanner; let serverRequest; let generateUUIDStub; let triggerPixelStub; + before(() => { + const storage = getCoreStorageManager(); + storage.setCookie(UUID_KEY, relaido_uuid); + }); beforeEach(function () { generateUUIDStub = sinon.stub(utils, 'generateUUID').returns(relaido_uuid); @@ -43,7 +40,11 @@ describe('RelaidoAdapter', function () { bidId: '2ed93003f7bb99', bidderRequestId: '1c50443387a1f2', auctionId: '413ed000-8c7a-4ba1-a1fa-9732e006f8c3', - transactionId: '5c2d064c-7b76-42e8-a383-983603afdc45', + ortb2Imp: { + ext: { + tid: '5c2d064c-7b76-42e8-a383-983603afdc45', + } + }, bidRequestsCount: 1, bidderRequestsCount: 1, bidderWinsCount: 0 @@ -51,7 +52,8 @@ describe('RelaidoAdapter', function () { bidderRequest = { timeout: 1000, refererInfo: { - referer: 'https://publisher.com/home' + page: 'https://publisher.com/home?aaa=test1&bbb=test2', + canonicalUrl: 'https://publisher.com/home' } }; serverResponse = { @@ -76,14 +78,36 @@ describe('RelaidoAdapter', function () { uuid: relaido_uuid, } }; + serverResponseBanner = { + body: { + status: 'ok', + ads: [{ + placementId: 100000, + width: 640, + height: 360, + bidId: '2ed93003f7bb99', + price: 500, + model: 'vcpm', + currency: 'JPY', + creativeId: 1000, + adTag: '%3Cdiv%3E%3Cimg%20src%3D%22https%3A%2F%2Frelaido%2Ftest.jpg%22%20%2F%3E%3C%2Fdiv%3E', + syncUrl: 'https://relaido/sync.html', + adomain: ['relaido.co.jp', 'www.cmertv.co.jp'], + mediaType: 'banner' + }], + syncUrl: 'https://api-dev.ulizaex.com/tr/v1/prebid/sync.html', + uuid: relaido_uuid, + } + }; serverRequest = { method: 'POST', data: { bids: [{ bidId: bidRequest.bidId, - width: bidRequest.mediaTypes.video.playerSize[0][0], - height: bidRequest.mediaTypes.video.playerSize[0][1], - mediaType: 'video'}] + width: bidRequest.mediaTypes.video.playerSize[0][0] || bidRequest.mediaTypes.video.playerSize[0], + height: bidRequest.mediaTypes.video.playerSize[0][1] || bidRequest.mediaTypes.video.playerSize[1], + mediaType: 'video' + }] } }; }); @@ -98,8 +122,34 @@ describe('RelaidoAdapter', function () { expect(spec.isBidRequestValid(bidRequest)).to.equal(true); }); + it('should return true when not existed mediaTypes.video.playerSize and existed valid params.video.playerSize by video', function () { + bidRequest.mediaTypes = { + video: { + context: 'outstream' + } + }; + bidRequest.params = { + placementId: '100000', + video: { + playerSize: [ + [640, 360] + ] + } + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + + it('should return even true when the playerSize is Array[Number, Number] by video', function () { + bidRequest.mediaTypes = { + video: { + context: 'outstream', + playerSize: [640, 360] + } + }; + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + it('should return true when the required params are passed by banner', function () { - setUAMobile(); bidRequest.mediaTypes = { banner: { sizes: [ @@ -108,11 +158,9 @@ describe('RelaidoAdapter', function () { } }; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - setUADefault(); }); it('should return false when missing 300x250 over and 1x1 by banner', function () { - setUAMobile(); bidRequest.mediaTypes = { banner: { sizes: [ @@ -122,11 +170,9 @@ describe('RelaidoAdapter', function () { } }; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - setUADefault(); }); it('should return true when 300x250 by banner', function () { - setUAMobile(); bidRequest.mediaTypes = { banner: { sizes: [ @@ -135,11 +181,9 @@ describe('RelaidoAdapter', function () { } }; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - setUADefault(); }); it('should return true when 1x1 by banner', function () { - setUAMobile(); bidRequest.mediaTypes = { banner: { sizes: [ @@ -148,11 +192,9 @@ describe('RelaidoAdapter', function () { } }; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - setUADefault(); }); it('should return true when 300x250 over by banner', function () { - setUAMobile(); bidRequest.mediaTypes = { banner: { sizes: [ @@ -162,7 +204,6 @@ describe('RelaidoAdapter', function () { } }; expect(spec.isBidRequestValid(bidRequest)).to.equal(true); - setUADefault(); }); it('should return false when the placementId params are missing', function () { @@ -178,23 +219,10 @@ describe('RelaidoAdapter', function () { }); it('should return false when the mediaType banner params are missing', function () { - setUAMobile(); bidRequest.mediaTypes = { banner: {} }; expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - setUADefault(); - }); - - it('should return false when the non-mobile', function () { - bidRequest.mediaTypes = { - banner: { - sizes: [ - [300, 250] - ] - } - }; - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); }); it('should return false when the mediaTypes params are missing', function () { @@ -211,7 +239,8 @@ describe('RelaidoAdapter', function () { const request = data.bids[0]; expect(bidRequests.method).to.equal('POST'); expect(bidRequests.url).to.equal('https://api.relaido.jp/bid/v1/sprebid'); - expect(data.ref).to.equal(bidderRequest.refererInfo.referer); + expect(data.canonical_url_hash).to.equal('e6092f44a0044903ae3764126eedd6187c1d9f04'); + expect(data.ref).to.equal(bidderRequest.refererInfo.page); expect(data.timeout_ms).to.equal(bidderRequest.timeout); expect(request.ad_unit_code).to.equal(bidRequest.adUnitCode); expect(request.auction_id).to.equal(bidRequest.auctionId); @@ -219,14 +248,13 @@ describe('RelaidoAdapter', function () { expect(request.bidder_request_id).to.equal(bidRequest.bidderRequestId); expect(data.bid_requests_count).to.equal(bidRequest.bidRequestsCount); expect(request.bid_id).to.equal(bidRequest.bidId); - expect(request.transaction_id).to.equal(bidRequest.transactionId); + expect(request.transaction_id).to.equal(bidRequest.ortb2Imp.ext.tid); expect(request.media_type).to.equal('video'); expect(data.uuid).to.equal(relaido_uuid); expect(data.pv).to.equal('$prebid.version$'); }); it('should build bid requests by banner', function () { - setUAMobile(); bidRequest.mediaTypes = { video: { context: 'outstream', @@ -246,10 +274,10 @@ describe('RelaidoAdapter', function () { expect(data.bids).to.have.lengthOf(1); const request = data.bids[0]; expect(request.media_type).to.equal('banner'); + expect(request.banner_sizes).to.equal('640x360,1x1'); }); it('should take 1x1 size', function () { - setUAMobile(); bidRequest.mediaTypes = { video: { context: 'outstream', @@ -292,7 +320,7 @@ describe('RelaidoAdapter', function () { }); describe('spec.interpretResponse', function () { - it('should build bid response by video', function () { + it('should build bid response by video and serverResponse contains vast', function () { const bidResponses = spec.interpretResponse(serverResponse, serverRequest); expect(bidResponses).to.have.lengthOf(1); const response = bidResponses[0]; @@ -309,7 +337,7 @@ describe('RelaidoAdapter', function () { expect(response.ad).to.be.undefined; }); - it('should build bid response by banner', function () { + it('should build bid response by banner and serverResponse contains vast', function () { serverResponse.body.ads[0].mediaType = 'banner'; const bidResponses = spec.interpretResponse(serverResponse, serverRequest); expect(bidResponses).to.have.lengthOf(1); @@ -327,6 +355,19 @@ describe('RelaidoAdapter', function () { expect(response.ad).to.include(`window.RelaidoPlayer.renderAd`); }); + it('should build bid response by banner and serverResponse contains adTag', function () { + const bidResponses = spec.interpretResponse(serverResponseBanner, serverRequest); + expect(bidResponses).to.have.lengthOf(1); + const response = bidResponses[0]; + expect(response.requestId).to.equal(serverRequest.data.bids[0].bidId); + expect(response.cpm).to.equal(serverResponseBanner.body.ads[0].price); + expect(response.currency).to.equal(serverResponseBanner.body.ads[0].currency); + expect(response.creativeId).to.equal(serverResponseBanner.body.ads[0].creativeId); + expect(response.vastXml).to.be.undefined; + expect(response.playerUrl).to.be.undefined; + expect(response.ad).to.include(`
`); + }); + it('should build bid response by video and playerUrl in ads', function () { serverResponse.body.ads[0].playerUrl = 'https://relaido/player-customized.js'; const bidResponses = spec.interpretResponse(serverResponse, serverRequest); diff --git a/test/spec/modules/relayBidAdapter_spec.js b/test/spec/modules/relayBidAdapter_spec.js new file mode 100644 index 00000000000..38a3cfc9b97 --- /dev/null +++ b/test/spec/modules/relayBidAdapter_spec.js @@ -0,0 +1,131 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/relayBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'relay' +const endpoint = 'https://e.relay.bid/p/openrtb2'; + +describe('RelayBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder, + mediaTypes: { [BANNER]: { sizes: [[300, 250]] } }, + params: { + accountId: 15000, + }, + ortb2Imp: { + ext: { + relay: { + bidders: { + bidderA: { + theId: 'abc123' + }, + bidderB: { + theId: 'xyz789' + } + } + } + } + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder, + mediaTypes: { [BANNER]: { sizes: [[300, 250]] } }, + params: { + accountId: 30000, + }, + ortb2Imp: { + ext: { + relay: { + bidders: { + bidderA: { + theId: 'def456' + }, + bidderB: { + theId: 'uvw101112' + } + } + } + } + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: {} + } + + const bidderRequest = {}; + + describe('isBidRequestValid', function () { + it('Valid bids have a params.accountId.', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Invalid bids do not have a params.accountId.', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + const requests = spec.buildRequests(bids, bidderRequest); + const firstRequest = requests[0]; + const secondRequest = requests[1]; + + it('Creates two requests', function () { + expect(firstRequest).to.exist; + expect(firstRequest.data).to.exist; + expect(firstRequest.method).to.exist; + expect(firstRequest.method).to.equal('POST'); + expect(firstRequest.url).to.exist; + expect(firstRequest.url).to.equal(`${endpoint}?a=15000&pb=1&pbv=v8.1.0`); + + expect(secondRequest).to.exist; + expect(secondRequest.data).to.exist; + expect(secondRequest.method).to.exist; + expect(secondRequest.method).to.equal('POST'); + expect(secondRequest.url).to.exist; + expect(secondRequest.url).to.equal(`${endpoint}?a=30000&pb=1&pbv=v8.1.0`); + }); + + it('Does not generate requests when there are no bids', function () { + const request = spec.buildRequests([], bidderRequest); + expect(request).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function () { + it('Uses Prebid consent values if incoming sync URLs lack consent.', function () { + const syncOpts = { + iframeEnabled: true, + pixelEnabled: true + }; + const test_gdpr_applies = true; + const test_gdpr_consent_str = 'TEST_GDPR_CONSENT_STRING'; + const responses = [{ + body: { + ext: { + user_syncs: [ + { type: 'image', url: 'https://image-example.com' }, + { type: 'iframe', url: 'https://iframe-example.com' } + ] + } + } + }]; + + const sync_urls = spec.getUserSyncs(syncOpts, responses, { gdprApplies: test_gdpr_applies, consentString: test_gdpr_consent_str }); + expect(sync_urls).to.be.an('array'); + expect(sync_urls[0].url).to.equal('https://image-example.com/?gdpr=1&gdpr_consent=TEST_GDPR_CONSENT_STRING'); + expect(sync_urls[1].url).to.equal('https://iframe-example.com/?gdpr=1&gdpr_consent=TEST_GDPR_CONSENT_STRING'); + }); + }); +}); diff --git a/test/spec/modules/relevadRtdProvider_spec.js b/test/spec/modules/relevadRtdProvider_spec.js new file mode 100644 index 00000000000..678ea26eed6 --- /dev/null +++ b/test/spec/modules/relevadRtdProvider_spec.js @@ -0,0 +1,412 @@ +import { addRtdData, getBidRequestData, relevadSubmodule, serverData } from 'modules/relevadRtdProvider.js'; +import { server } from 'test/mocks/xhr.js'; +import {config} from 'src/config.js'; +import { deepClone, deepAccess, deepSetValue } from '../../../src/utils.js'; + +const responseHeader = {'Content-Type': 'application/json'}; + +const moduleConfigCommon = { + 'dryrun': true, + params: { + setgpt: true, + minscore: 50, + partnerid: 12345, + bidders: [{ bidder: 'appnexus' }, + { bidder: 'rubicon', }, + { bidder: 'smart', }, + { bidder: 'ix', }, + { bidder: 'proxistore', }, + { bidder: 'other' }] + } +}; + +const reqBidsCommon = { + 'timeout': 10000, + 'adUnitCodes': ['/19968336/header-bid-tag-0'], + 'ortb2Fragments': { + 'global': { + 'site': { + 'page': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html?pbjs_debug=true', + 'domain': 'localhost.localdomain:8888', + 'publisher': { + 'domain': 'localhost.localdomain:8888' + } + }, + 'device': { + 'w': 355, + 'h': 682, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', + 'language': 'en' + } + }, + 'bidder': {} + } +}; + +const adUnitsCommon = [ + { + 'code': '/19968336/header-bid-tag-0', + 'mediaTypes': { + 'banner': { 'sizes': [[728, 90]] } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { 'placementId': '13144370' } + }, + { bidder: 'other' }, + { bidder: 'rubicon', 'params': { id: 1 } }, + { bidder: 'smart', }, + { bidder: 'ix', }, + { bidder: 'proxistore', } + ] + } +]; + +describe('relevadRtdProvider', function() { + describe('relevadSubmodule', function() { + it('successfully instantiates', function () { + expect(relevadSubmodule.init()).to.equal(true); + }); + }); + + describe('Add segments and categories test 1', function() { + it('adds contextual categories and segments', function() { + let moduleConfig = { ...deepClone(moduleConfigCommon) }; + let reqBids = { + ...deepClone(reqBidsCommon), + 'adUnits': deepClone(adUnitsCommon), + }; + + let data = { + segments: ['segment1', 'segment2'], + cats: { 'category3': 100 }, + }; + + (config.getConfig('ix') || {}).firstPartyData = null; + addRtdData(reqBids, data, moduleConfig, () => {}); + expect(reqBids.adUnits[0].bids[0].params.keywords).to.have.deep.property('relevad_rtd', ['segment1', 'segment2', 'category3']); + expect(reqBids.adUnits[0].bids[1].ortb2.site.ext.data).to.have.deep.property('relevad_rtd', ['category3']); + expect(reqBids.adUnits[0].bids[1].ortb2.user.ext.data).to.have.deep.property('relevad_rtd', ['segment1', 'segment2']); + expect(reqBids.adUnits[0].bids[3].params).to.have.deep.property('target', 'relevad_rtd=segment1;relevad_rtd=segment2;relevad_rtd=category3'); + expect(reqBids.adUnits[0].bids[5].ortb2.user.ext.data).to.have.deep.property('segments', ['segment1', 'segment2']); + expect(reqBids.adUnits[0].bids[5].ortb2.user.ext.data).to.have.deep.property('contextual_categories', ['category3']); + expect(reqBids.ortb2Fragments.bidder.rubicon.user.ext.data).to.have.deep.property('relevad_rtd', ['segment1', 'segment2']); + expect(config.getConfig('ix.firstPartyData')).to.have.deep.property('relevad_rtd', ['segment1', 'segment2', 'category3']); + }); + }); + + describe('Add segments and categories test 2 to one bidder out of many', function() { + it('adds contextual categories and segments', function() { + let moduleConfig = { ...deepClone(moduleConfigCommon) }; + let reqBids = { + ...deepClone(reqBidsCommon), + 'adUnits': deepClone(adUnitsCommon), + }; + + let data = { + segments: ['segment1', 'segment2'], + cats: { 'category3': 100 }, + wl: { 'appnexus': { 'placementId': '13144370' } }, + }; + + (config.getConfig('ix') || {}).firstPartyData = null; + addRtdData(reqBids, data, moduleConfig, () => { }); + expect(reqBids.adUnits[0].bids[0].params.keywords).to.have.deep.property('relevad_rtd', ['segment1', 'segment2', 'category3']); + expect(reqBids.adUnits[0].bids[1].ortb2?.site?.ext?.data || {}).to.not.have.property('relevad_rtd'); + expect(reqBids.adUnits[0].bids[1].ortb2?.user?.ext?.data || {}).to.not.have.property('relevad_rtd'); + expect(reqBids.adUnits[0].bids[3].params || {}).to.not.have.deep.property('target', 'relevad_rtd=segment1;relevad_rtd=segment2;relevad_rtd=category3'); + expect(reqBids.adUnits[0].bids[5].ortb2?.user?.ext?.data || {}).to.not.have.deep.property('segments', ['segment1', 'segment2']); + expect(reqBids.adUnits[0].bids[5].ortb2?.user?.ext?.data || {}).to.not.have.deep.property('contextual_categories', ['category3']); + expect(reqBids.adUnits[0].bids[5].ortb2?.user?.ext?.data || {}).to.not.have.deep.property('contextual_categories', {'0': 'category3'}); + expect(reqBids.ortb2Fragments?.bidder?.rubicon?.user?.ext?.data || {}).to.not.have.deep.property('relevad_rtd', ['segment1', 'segment2']); + expect(config.getConfig('ix.firstPartyData') || {}).to.not.have.deep.property('relevad_rtd', ['segment1', 'segment2', 'category3']); + }); + }); + + describe('Add segments and categories test 4', function() { + it('adds contextual categories and segments', function() { + let moduleConfig = { + 'dryrun': true, + params: { + setgpt: true, + minscore: 50, + partnerid: 12345, + } + }; + + let reqBids = { + 'timeout': 10000, + 'adUnits': deepClone(adUnitsCommon), + 'adUnitCodes': [ '/19968336/header-bid-tag-0' ], + 'ortb2Fragments': { + 'global': { + 'site': { + 'page': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html?pbjs_debug=true', + 'domain': 'localhost.localdomain:8888', + 'publisher': { + 'domain': 'localhost.localdomain:8888' + } + }, + 'device': { + 'w': 355, + 'h': 682, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', + 'language': 'en' + } + }, + 'bidder': {} + }, + 'metrics': {}, + 'defer': { 'promise': {} } + } + + let data = { + segments: ['segment1', 'segment2'], + cats: {'category3': 100} + }; + (config.getConfig('ix') || {}).firstPartyData = null; + addRtdData(reqBids, data, moduleConfig, () => {}); + expect(reqBids.adUnits[0].bids[0].params.keywords).to.have.deep.property('relevad_rtd', ['segment1', 'segment2', 'category3']); + }); + }); + + describe('Get Segments And Categories', function() { + it('gets data from async request and adds contextual categories and segments', function() { + const moduleConfig = { + params: { + 'dryrun': true, + sdtgpt: false, + minscore: 50, + bidders: [{ bidder: 'appnexus' }, + { bidder: 'other' }] + } + }; + + let reqBidsConfigObj = { + adUnits: [{ + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }, { + bidder: 'other' + }] + }] + }; + + let data = { + segments: ['segment1', 'segment2'], + cats: {'category3': 100} + }; + + getBidRequestData(reqBidsConfigObj, () => {}, moduleConfig, {}); + + let request = server.requests[0]; + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(reqBidsConfigObj.adUnits[0].bids[0].params.keywords).to.have.deep.property('relevad_rtd', ['segment1', 'segment2', 'category3']); + expect(reqBidsConfigObj.adUnits[0].bids[1].ortb2.site.ext.data).to.have.deep.property('relevad_rtd', ['category3']); + expect(reqBidsConfigObj.adUnits[0].bids[1].ortb2.user.ext.data).to.have.deep.property('relevad_rtd', ['segment1', 'segment2']); + }); + }); +}); + +describe('Process auction end data', function() { + it('Collects bid data on auction end event', function() { + const auctionEndData = { + 'auctionDetails': { + 'auctionId': 'f7ec9895-5809-475e-8fef-49cbc221921a', + 'auctionStatus': 'completed', + 'adUnits': [ + { + 'code': '/19968336/header-bid-tag-0', + 'mediaTypes': { + 'banner': { 'sizes': [ [ 728, 90 ] ] } + }, + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': '13144370', + 'keywords': { + 'relevad_rtd': [ 'IAB410-391', 'IAB63-53' ] + } + } + } + ], + 'ortb2Imp': { 'ext': { 'data': { 'relevad_rtd': [ 'IAB410-391', 'IAB63-53' ] }, } }, + 'sizes': [ [ 728, 90 ] ], + } + ], + 'adUnitCodes': [ '/19968336/header-bid-tag-0' ], + 'bidderRequests': [ + { + 'bidderCode': 'appnexus', + 'auctionId': 'f7ec9895-5809-475e-8fef-49cbc221921a', + 'bidderRequestId': '1d917281b2bf6c', + 'bids': [ + { + 'bidder': 'appnexus', + 'params': { + 'placementId': '13144370', + 'keywords': { + 'relevad_rtd': [ + 'IAB410-391', + 'IAB63-53' + ] + } + }, + 'ortb2Imp': { + 'ext': { 'data': { 'relevad_rtd': [ 'IAB410-391', 'IAB63-53' ] }, } + }, + 'mediaTypes': { 'banner': { 'sizes': [ [ 728, 90 ] ] } }, + 'adUnitCode': '/19968336/header-bid-tag-0', + 'sizes': [ [ 728, 90 ] ], + 'bidId': '20f0b347b07f94', + 'bidderRequestId': '1d917281b2bf6c', + 'auctionId': 'f7ec9895-5809-475e-8fef-49cbc221921a', + 'src': 'client', + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0, + 'ortb2': { + 'site': { + 'page': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html', + 'domain': 'localhost.localdomain:8888', + 'publisher': { 'domain': 'localhost.localdomain:8888' }, + 'cat': [ 'IAB410-391', 'IAB63-53' ], + 'pagecat': [ 'IAB410-391', 'IAB63-53' ], + 'sectioncat': [ 'IAB410-391', 'IAB63-53' ] + }, + 'device': { + 'w': 326, + 'h': 649, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', + 'language': 'en' + } + } + } + ], + 'timeout': 10000, + 'refererInfo': { + 'reachedTop': true, + 'isAmp': false, + 'numIframes': 0, + 'stack': [ + 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html' + ], + 'topmostLocation': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html', + 'location': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html', + 'canonicalUrl': null, + 'page': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html', + 'domain': 'www.localhost.localdomain:8888', + 'ref': null, + 'legacy': { + 'reachedTop': true, + 'isAmp': false, + 'numIframes': 0, + 'stack': [ 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html' ], + 'referer': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html', + 'canonicalUrl': null + } + }, + 'ortb2': { + 'site': { + 'page': 'http://www.localhost.localdomain:8888/integrationExamples/gpt/relevadRtdProvider_example.html', + 'domain': 'localhost.localdomain:8888', + 'publisher': { 'domain': 'localhost.localdomain:8888' }, + 'cat': [ 'IAB410-391', 'IAB63-53' ], + 'pagecat': [ 'IAB410-391', 'IAB63-53' ], + 'sectioncat': [ 'IAB410-391', 'IAB63-53' ] + }, + 'device': { + 'w': 326, + 'h': 649, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', + 'language': 'en' + } + }, + 'start': 1674132848498 + } + ], + 'noBids': [], + 'bidsReceived': [ + { + 'bidderCode': 'appnexus', + 'width': 728, + 'height': 90, + 'statusMessage': 'Bid available', + 'adId': '3222e6ead116f3', + 'requestId': '20f0b347b07f94', + 'transactionId': 'df8586ac-6476-4fbf-a727-eda99996dc39', + 'auctionId': 'f7ec9895-5809-475e-8fef-49cbc221921a', + 'mediaType': 'banner', + 'source': 'client', + 'cpm': 1.5, + 'creativeId': 98493734, + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 300, + 'adUnitCode': '/19968336/header-bid-tag-0', + 'adapterCode': 'appnexus', + 'originalCpm': 1.5, + 'originalCurrency': 'USD', + 'responseTimestamp': 1674132848649, + 'requestTimestamp': 1674132848498, + 'bidder': 'appnexus', + 'size': '728x90', + } + ], + }, + 'config': { + 'name': 'RelevadRTDModule', + 'waitForIt': true, + 'dryrun': true, + 'params': { + 'partnerid': 12345, + 'setgpt': true + } + }, + 'userConsent': { 'gdpr': null, 'usp': null, 'gpp': null, 'coppa': false } + }; + + let auctionDetails = auctionEndData['auctionDetails']; + let userConsent = auctionEndData['userConsent']; + let moduleConfig = auctionEndData['config']; + + relevadSubmodule.onAuctionEndEvent(auctionDetails, moduleConfig, userConsent); + expect(serverData.clientdata).to.deep.equal( + { + 'event': 'bids', + 'adunits': [ + { + 'code': '/19968336/header-bid-tag-0', + 'bids': [ + { + 'bidder': 'appnexus', + 'cpm': 1.5, + 'currency': 'USD', + 'type': 'banner', + 'ttr': undefined, + 'dealId': undefined, + 'size': '728x90' + } + ] + } + ], + 'reledata': { segments: ['segment1', 'segment2'], cats: { 'category3': 100 }, }, + 'gdpra': '', + 'gdprc': '', + 'aid': '', + 'cid': '12345', + 'pid': '', + } + ); + }); +}); diff --git a/test/spec/modules/relevantdigitalBidAdapter_spec.js b/test/spec/modules/relevantdigitalBidAdapter_spec.js new file mode 100644 index 00000000000..b2a5495b3cb --- /dev/null +++ b/test/spec/modules/relevantdigitalBidAdapter_spec.js @@ -0,0 +1,295 @@ +import {spec, resetBidderConfigs} from 'modules/relevantdigitalBidAdapter.js'; +import { parseUrl, deepClone } from 'src/utils.js'; + +const expect = require('chai').expect; + +const PBS_HOST = 'dev-api.relevant-digital.com'; +const PLACEMENT_ID = 'example_placement_id'; +const ACCOUNT_ID = 'example_account_id'; +const TEST_DOMAIN = 'example.com'; +const TEST_PAGE = `https://${TEST_DOMAIN}/page.html`; + +const BID_REQUEST = +{ + 'bidder': 'relevantdigital', + 'params': { + 'placementId': PLACEMENT_ID, + 'accountId': ACCOUNT_ID, + 'pbsHost': PBS_HOST, + }, + 'ortb2Imp': { + 'ext': { + 'tid': 'e13391ea-00f3-495d-99a6-d937990d73a9' + } + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [ + 300, + 250 + ], + ] + } + }, + 'adUnitCode': '/19968336/header-bid-tag-0', + 'transactionId': 'e13391ea-00f3-495d-99a6-d937990d73a9', + 'sizes': [ + [ + 300, + 250 + ], + ], + 'bidId': '2d69406037a662', + 'bidderRequestId': '1decd098c76ed2', + 'auctionId': '251a6a36-a5c5-4b82-b2b3-538c148a29dd', + 'src': 'client', + 'metrics': { + 'requestBids.validate': 0.7, + 'requestBids.makeRequests': 2.9, + 'adapter.client.validate': 0.4, + 'adapters.client.relevantdigital.validate': 0.4 + }, + 'bidRequestsCount': 1, + 'bidderRequestsCount': 1, + 'bidderWinsCount': 0, + 'ortb2': { + 'site': { + 'page': TEST_PAGE, + 'domain': TEST_DOMAIN, + 'publisher': { + 'domain': 'relevant-digital.com' + } + }, + 'device': { + 'w': 1848, + 'h': 1007, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36', + 'language': 'en', + 'sua': { + 'source': 2, + 'platform': { + 'brand': 'Linux', + 'version': [ + '5', + '4', + '0' + ] + }, + 'browsers': [ + { + 'brand': 'Google Chrome', + 'version': [ + '111', + '0', + '5563', + '146' + ] + }, + ], + 'mobile': 0, + 'model': '', + 'bitness': '64', + 'architecture': 'x86' + } + } + } +}; + +const BIDDER_REQUEST = { + 'bidderCode': BID_REQUEST.bidder, + 'auctionId': BID_REQUEST.auctionId, + 'bidderRequestId': BID_REQUEST.bidderRequestId, + 'bids': [BID_REQUEST], + 'metrics': BID_REQUEST.metrics, + 'ortb2': BID_REQUEST.ortb2, + 'auctionStart': 1681224591370, + 'timeout': 1000, + 'refererInfo': { + 'reachedTop': true, + 'isAmp': false, + 'numIframes': 0, + 'stack': [ + TEST_PAGE + ], + 'topmostLocation': TEST_PAGE, + 'location': TEST_PAGE, + 'canonicalUrl': null, + 'page': TEST_PAGE, + 'domain': TEST_DOMAIN, + 'ref': null, + 'legacy': { + 'reachedTop': true, + 'isAmp': false, + 'numIframes': 0, + 'stack': [ + TEST_PAGE + ], + 'referer': TEST_PAGE, + 'canonicalUrl': null + } + }, + 'start': 1681224591375 +}; + +const BID_RESPONSE = { + 'seatbid': [ + { + 'bid': [ + { + 'id': '613673EF-A07C-4486-8EE9-3FC71A7DC73D', + 'impid': BID_REQUEST.bidId, + 'price': 10.76091063668997, + 'adm': '', + 'adomain': [ + 'www.addomain.com' + ], + 'iurl': 'http://localhost11', + 'crid': 'creative111', + 'w': 300, + 'h': 250, + 'ext': { + 'bidtype': 0, + 'dspid': 6, + 'origbidcpm': 1, + 'origbidcur': 'USD', + 'prebid': { + 'meta': { + 'adaptercode': 'pubmatic' + }, + 'targeting': { + 'hb_bidder': 'pubmatic', + 'hb_cache_host': PBS_HOST, + 'hb_cache_path': '/analytics_cache/read', + 'hb_format': 'banner', + 'hb_pb': '10.70', + 'hb_size': '300x250' + }, + 'type': 'banner', + 'video': { + 'duration': 0, + 'primary_category': '' + }, + 'events': { + 'win': `https://${PBS_HOST}/event?t=win&b=fed970f7-4295-456d-a251-38013faab795&a=620523ae7f4bbe1691bbb815&bidder=pubmatic&ts=1678646619765`, + 'imp': `https://${PBS_HOST}/event?t=imp&b=fed970f7-4295-456d-a251-38013faab795&a=620523ae7f4bbe1691bbb815&bidder=pubmatic&ts=1678646619765` + }, + 'bidid': 'fed970f7-4295-456d-a251-38013faab795' + } + } + } + ], + 'seat': 'pubmatic' + } + ], + 'cur': 'SEK', + 'ext': { + 'responsetimemillis': { + 'appnexus': 305, + 'pubmatic': 156 + }, + 'tmaxrequest': 750, + 'relevant': { + 'sync': [ + { 'type': 'redirect', 'url': 'https://example1.com/sync' }, + { 'type': 'redirect', 'url': 'https://example2.com/sync' }, + ], + }, + 'prebid': { + 'auctiontimestamp': 1678646619765, + 'passthrough': { + 'relevant': { + 'bidder': spec.code + } + } + } + } +}; + +const S2S_RESPONSE_BIDDER = BID_RESPONSE.seatbid[0].seat; + +const resetAndBuildRequest = (params) => { + resetBidderConfigs(); + const bidRequest = { + ...BID_REQUEST, + params: { + ...BID_REQUEST.params, + ...params, + }, + }; + return spec.buildRequests([bidRequest], BIDDER_REQUEST); +}; + +describe('Relevant Digital Bid Adaper', function () { + describe('buildRequests', () => { + const [request] = resetAndBuildRequest(); + const {data, url} = request + it('should give the correct URL', () => { + expect(url).equal(`https://${PBS_HOST}/openrtb2/auction`); + }); + it('should set the correct stored request ids', () => { + expect(data.ext.prebid.storedrequest.id).equal(ACCOUNT_ID); + expect(data.imp[0].ext.prebid.storedrequest.id).equal(PLACEMENT_ID); + }); + it('should include bidder code in passthrough object', () => { + expect(data.ext.prebid.passthrough.relevant.bidder).equal(spec.code); + }); + it('should set tmax to something below the timeout', () => { + expect(data.tmax).be.greaterThan(0); + expect(data.tmax).be.lessThan(BIDDER_REQUEST.timeout) + }); + }); + describe('interpreteResponse', () => { + const [request] = resetAndBuildRequest(); + const [bid] = spec.interpretResponse({ body: BID_RESPONSE }, request); + it('should not have S2S bidder\'s bidder code', () => { + expect(bid.bidderCode).not.equal(S2S_RESPONSE_BIDDER); + }); + it('should return the right creative content', () => { + const respBid = BID_RESPONSE.seatbid[0].bid[0]; + expect(bid.cpm).equal(respBid.price); + expect(bid.ad).equal(respBid.adm); + expect(bid.width).equal(respBid.w); + expect(bid.height).equal(respBid.h); + }); + }); + describe('interpreteResponse with useSourceBidderCode', () => { + const [request] = resetAndBuildRequest({ useSourceBidderCode: true }); + const [bid] = spec.interpretResponse({ body: BID_RESPONSE }, request); + it('should have S2S bidder\'s code', () => { + expect(bid.bidderCode).equal(S2S_RESPONSE_BIDDER); + }); + }); + describe('getUserSyncs with iframeEnabled', () => { + resetAndBuildRequest() + const allSyncs = spec.getUserSyncs({ iframeEnabled: true }, [{ body: BID_RESPONSE }], null, null); + const [{ url, type }] = allSyncs; + const { bidders, endpoint } = parseUrl(url).search; + it('should return a single sync object', () => { + expect(allSyncs.length).equal(1); + }); + it('should use iframe sync when available', () => { + expect(type).equal('iframe'); + }); + it('should sync to all s2s bidders', () => { + expect(bidders.split(',').sort()).to.deep.equal(['appnexus', 'pubmatic']); + }); + it('should sync to the right endpoint', () => { + expect(endpoint).equal(`https://${PBS_HOST}/cookie_sync`); + }); + it('should not sync to the same s2s bidders when called again', () => { + const newSyncs = spec.getUserSyncs({ iframeEnabled: true }, [{ body: BID_RESPONSE }], null, null); + expect(newSyncs).to.deep.equal([]); + }); + }); + describe('getUserSyncs with pixelEnabled', () => { + resetAndBuildRequest() + const responseSyncs = BID_RESPONSE.ext.relevant.sync; + const allSyncs = spec.getUserSyncs({ pixelEnabled: true }, [{ body: BID_RESPONSE }], null, null); + it('should return one sync object per pixel', () => { + const expectedResult = responseSyncs.map(({ url }) => ({url, type: 'image'})); + expect(allSyncs).to.deep.equal(expectedResult) + }); + }); +}); diff --git a/test/spec/modules/retailspotBidAdapter_spec.js b/test/spec/modules/retailspotBidAdapter_spec.js new file mode 100644 index 00000000000..39cddb323b8 --- /dev/null +++ b/test/spec/modules/retailspotBidAdapter_spec.js @@ -0,0 +1,426 @@ +import { expect } from 'chai'; + +import { spec } from 'modules/retailspotBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +describe('RetailSpot Adapter', function () { + const canonicalUrl = 'https://canonical.url/?t=%26'; + const referrerUrl = 'http://referrer.url/?param=value'; + const pageUrl = 'http://page.url/?param=value'; + const domain = 'domain:123'; + const env = 'preprod'; + const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + const bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + }, + refererInfo: {location: referrerUrl, canonicalUrl, domain, topmostLocation: 'fakePageURL'}, + ortb2: {site: {page: pageUrl, ref: referrerUrl}} + }; + + const bidRequestWithSinglePlacement = [ + { + 'bidId': 'bid_id_0', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-0', + 'params': { + 'placement': 'placement_0' + }, + 'sizes': '300x250', + 'mediaTypes': { + 'banner': { + 'sizes': ['300x250'] + }, + }, + 'transactionId': 'bid_id_0_transaction_id' + } + ]; + + const bidRequestWithMultipleMediatype = [ + { + 'bidId': 'bid_id_0', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-0', + 'params': { + 'placement': 'placement_0' + }, + 'sizes': '300x250', + 'mediaTypes': { + 'banner': { + 'sizes': ['640x480'] + }, + 'video': { + 'playerSize': [640, 480], + 'context': 'outstream' + } + }, + 'transactionId': 'bid_id_0_transaction_id' + } + ]; + + const sentBidVideo = [ + { + 'bidId': 'bid_id_0', + 'placement': 'test-1234', + 'video': { + 'playerSize': [640, 480] + } + } + ]; + + const bidRequestWithDevPlacement = [ + { + 'bidId': 'bid_id_0', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-0', + 'params': { + 'placement': 'placement_0', + 'env': 'dev' + }, + 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, + 'transactionId': 'bid_id_0_transaction_id' + } + ]; + + const bidRequestMultiPlacements = [ + { + 'bidId': 'bid_id_0', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-0', + 'params': { + 'placement': 'placement_0' + }, + 'sizes': '300x250', + 'mediaTypes': + { 'banner': + {'sizes': ['300x250'] + } + }, + 'transactionId': 'bid_id_0_transaction_id' + }, + { + 'bidId': 'bid_id_1', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-1', + 'params': { + 'placement': 'placement_1' + }, + 'sizes': [[300, 600]], + 'mediaTypes': + { 'banner': + {'sizes': ['300x600'] + } + }, + 'transactionId': 'bid_id_1_transaction_id' + }, + { + 'bidId': 'bid_id_2', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-2', + 'params': {}, + 'sizes': '300x400', + 'transactionId': 'bid_id_2_transaction_id' + }, + { + 'bidId': 'bid_id_3', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-3', + 'params': { + 'placement': 'placement_3' + }, + 'transactionId': 'bid_id_3_transaction_id' + } + ]; + + const requestDataOnePlacement = [ + { + 'bidId': 'bid_id_0', + 'placement': 'e622af275681965d3095808561a1e510', + 'width': 300, + 'height': 600 + } + ] + + const requestDataMultiPlacement = [ + { + 'bidId': 'bid_id_0', + 'placement': 'e622af275681965d3095808561a1e510', + 'width': 300, + 'height': 600 + }, + { + 'bidId': 'bid_id_1', + 'placement': 'e622af275681965d3095808561a1e510', + 'width': 400, + 'height': 250 + } + ] + + const testMetaObject = { + 'networkId': 123, + 'advertiserId': '3', + 'advertiserName': 'foobar', + 'advertiserDomains': ['foobar.com'], + 'brandId': '345', + 'brandName': 'Foo', + 'primaryCatId': '34', + 'secondaryCatIds': ['IAB-222', 'IAB-333'], + 'mediaType': 'banner' + }; + const admSample = "\u003cscript id=\"ayl-prebid-a11a121205932e75e622af275681965d\"\u003e\n(function(){\n\twindow.isPrebid = true\n\tvar prebidResults = /*PREBID*/{\"OnEvents\": {\"CLICK\": [{\"Kind\": \"PIXEL_URL\",\"Url\": \"https://testPixelCLICK.com/fake\"}],\"IMPRESSION\": [{\"Kind\": \"PIXEL_URL\",\"Url\": \"https://testPixelIMP.com/fake\"}, {\"Kind\": \"JAVASCRIPT_URL\",\"Url\": \"https://testJsIMP.com/fake.js\"}]},\"Disabled\": false,\"Attempt\": \"a11a121205932e75e622af275681965d\",\"ApiPrefix\": \"https://fo-api.omnitagjs.com/fo-api\",\"TrackingPrefix\": \"https://tracking.omnitagjs.com/tracking\",\"DynamicPrefix\": \"https://tag-dyn.omnitagjs.com/fo-dyn\",\"StaticPrefix\": \"https://fo-static.omnitagjs.com/fo-static\",\"BlobPrefix\": \"https://fo-api.omnitagjs.com/fo-api/blobs\",\"SspPrefix\": \"https://fo-ssp.omnitagjs.com/fo-ssp\",\"VisitorPrefix\": \"https://visitor.omnitagjs.com/visitor\",\"Trusted\": true,\"Placement\": \"e622af275681965d3095808561a1e510\",\"PlacementAccess\": \"ALL\",\"Site\": \"6e2df7a92203c3c7a25561ed63f25a27\",\"Lang\": \"EN\",\"SiteLogo\": null,\"HasSponsorImage\": true,\"ResizeIframe\": true,\"IntegrationConfig\": {\"Kind\": \"WIDGET\",\"Widget\": {\"ExtraStyleSheet\": \"\",\"Placeholders\": {\"Body\": {\"Color\": {\"R\": 77,\"G\": 21,\"B\": 82,\"A\": 100},\"BackgroundColor\": {\"R\": 255,\"G\": 255,\"B\": 255,\"A\": 100},\"FontFamily\": \"Lato\",\"Width\": \"100%\",\"Align\": \"\",\"BoxShadow\": true},\"CallToAction\": {\"Color\": {\"R\": 26,\"G\": 157,\"B\": 212,\"A\": 100}},\"Description\": {\"Length\": 130},\"Image\": {\"Width\": 600,\"Height\": 600,\"Lowres\": false,\"Raw\": false},\"Size\": {\"Height\": \"250px\",\"Width\": \"300px\"},\"Title\": {\"Color\": {\"R\": 219,\"G\": 181,\"B\": 255,\"A\": 100}}},\"Selector\": {\"Kind\": \"CSS\",\"Css\": \"#ayl-prebid-a11a121205932e75e622af275681965d\"},\"Insertion\": \"AFTER\",\"ClickFormat\": true,\"Creative20\": true,\"WidgetKind\": \"CREATIVE_TEMPLATE_4\"}},\"Legal\": \"Sponsored\",\"ForcedCampaign\": \"f1c80d4bb5643c222ae8de75e9b2f991\",\"ForcedTrack\": \"\",\"ForcedCreative\": \"\",\"ForcedSource\": \"\",\"DisplayMode\": \"DEFAULT\",\"Campaign\": \"f1c80d4bb5643c222ae8de75e9b2f991\",\"CampaignAccess\": \"ALL\",\"CampaignKind\": \"AD_TRAFFIC\",\"DataSource\": \"LOCAL\",\"DataSourceUrl\": \"\",\"DataSourceOnEventsIsolated\": false,\"DataSourceWithoutCookie\": false,\"Content\": {\"Preview\": {\"Thumbnail\": {\"Image\": {\"Kind\": \"EXTERNAL\",\"Data\": {\"External\": {\"Url\": \"https://tag-dyn.omnitagjs.com/fo-dyn/native/preview/image?key=fd4362d35bb174d6f1c80d4bb5643c22\\u0026kind=INTERNAL\\u0026ztop=0.000000\\u0026zleft=0.000000\\u0026zwidth=0.333333\\u0026zheight=1.000000\\u0026width=[width]\\u0026height=[height]\"}},\"ZoneTop\": 0,\"ZoneLeft\": 0,\"ZoneWidth\": 1,\"ZoneHeight\": 1,\"Smart\": false,\"NoTransform\": false,\"Quality\": \"NORMAL\"}},\"Text\": {\"CALLTOACTION\": \"Click here to learn more\",\"DESCRIPTION\": \"Considérant l'extrémité conjoncturelle, il serait bon d'anticiper toutes les voies de bon sens.\",\"SPONSOR\": \"Tested by\",\"TITLE\": \"Adserver Traffic Redirect Internal\"},\"Sponsor\": {\"Name\": \"QA Team\",\"Logo\": {\"Resource\": {\"Kind\": \"EXTERNAL\",\"Data\": {\"External\": {\"Url\": \"https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.svg\"}},\"ZoneTop\": 0,\"ZoneLeft\": 0,\"ZoneWidth\": 1,\"ZoneHeight\": 1,\"Smart\": false,\"NoTransform\": false,\"Quality\": \"NORMAL\"}}},\"Credit\": {\"Logo\": {\"Resource\": {\"Kind\": \"EXTERNAL\",\"Data\": {\"External\": {\"Url\": \"https://fo-static.omnitagjs.com/fo-static/native/images/info-ayl.png\"}},\"ZoneTop\": 0,\"ZoneLeft\": 0,\"ZoneWidth\": 1,\"ZoneHeight\": 1,\"Smart\": false,\"NoTransform\": false,\"Quality\": \"NORMAL\"}},\"Url\": \"https://blobs.omnitagjs.com/adchoice/\"}},\"Landing\": {\"Url\": \"https://www.w3.org/People/mimasa/test/xhtml/entities/entities-11.xhtml#lat1\",\"LegacyTracking\": false},\"ViewButtons\": {\"Close\": {\"Skip\": 6000}},\"InternalContentFields\": {\"AnimatedImage\": false}},\"AdDomain\": \"retailspot.com\",\"Opener\": \"REDIRECT\",\"PerformUITriggers\": [\"CLICK\"],\"RedirectionTarget\": \"TAB\"}/*PREBID*/;\n\tvar insertAds = function insertAds() {\insertAds();\n\t}\n})();\n\u003c/script\u003e"; + const responseWithSinglePlacement = [ + { + 'requestId': 'bid_id_0', + 'placement': 'placement_0', + 'ad': admSample, + 'cpm': 0.5, + 'height': 250, + 'width': 300, + 'meta': testMetaObject, + 'mediaType': 'banner' + } + ]; + + const responseWithSingleVideo = [{ + 'requestId': 'bid_id_0', + 'placement': 'placement_0', + 'vastXml': 'PFZBU1Q+RW1wdHkgc2FtcGxlPC92YXN0Pg==', + 'cpm': 0.5, + 'height': 300, + 'width': 530, + 'mediaType': 'video', + 'creativeId': 'testvideo123', + 'netRevenue': true, + 'currency': 'USD', + 'adId': 'fakeAdID', + 'dealId': 'fakeDealId' + }]; + + const videoResult = [{ + bidderCode: 'retailspot', + cpm: 0.5, + creativeId: 'testvideo123', + currency: 'USD', + height: 300, + netRevenue: true, + requestId: 'bid_id_0', + ttl: 3600, + mediaType: 'video', + meta: { + advertiserDomains: ['retail-spot.io'] + }, + vastXml: 'Empty sample', + width: 530, + adId: 'fakeAdID', + dealId: 'fakeDealId' + }]; + + const responseWithMultiplePlacements = [ + { + 'requestId': 'bid_id_0', + 'mediaType': 'banner', + 'placement': 'placement_0', + 'ad': 'placement_0', + 'cpm': 0.5, + 'height': 0, // test with wrong value + 'width': 300, + }, + { + 'requestId': 'bid_id_1', + 'mediaType': 'banner', + 'placement': 'placement_1', + 'ad': 'placement_1', + 'cpm': 0.6, + 'height': 250 + // 'width' test with missing value + } + ]; + const adapter = newBidder(spec); + + const DEV_URL = 'http://localhost:8090/'; + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + let bid = { + 'bidId': 'bid_id_1', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-1', + 'params': { + 'placement': 'placement_1' + }, + 'sizes': [[300, 600]], + 'transactionId': 'bid_id_1_transaction_id' + }; + + let bidWSize = { + 'bidId': 'bid_id_1', + 'bidder': 'retailspot', + 'placementCode': 'adunit/hb-1', + 'params': { + 'placement': 'placement_1', + 'size': [250, 300], + }, + 'transactionId': 'bid_id_1_transaction_id' + }; + + it('should return true when required params found', function () { + expect(!!spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return true when required params found with size in bid params', function () { + expect(!!spec.isBidRequestValid(bidWSize)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.size; + + expect(!!spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'placement': 0 + }; + expect(!!spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + it('should add gdpr/usp consent information to the request', function () { + let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let uspConsentData = '1YCC'; + let bidderRequest = { + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + }, + 'uspConsent': uspConsentData + }; + + bidderRequest.Bids = bidRequestWithSinglePlacement; + + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.gdprConsent).to.exist; + expect(payload.gdprConsent.consentString).to.exist.and.to.equal(consentString); + expect(payload.uspConsent).to.exist.and.to.equal(uspConsentData); + }); + + it('sends bid request to endpoint with single placement', function () { + bidderRequest.Bids = bidRequestWithSinglePlacement; + + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); + const payload = JSON.parse(request.data); + + expect(request.url).to.contain('https://ssp.retail-spot.io/prebid'); + expect(request.method).to.equal('POST'); + + expect(payload).to.deep.equal(bidderRequest); + }); + + it('sends bid request to endpoint with single placement multiple mediatype', function () { + bidderRequest.Bids = bidRequestWithMultipleMediatype; + const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest); + const payload = JSON.parse(request.data); + + expect(request.url).to.contain('https://ssp.retail-spot.io/prebid'); + expect(request.method).to.equal('POST'); + + expect(payload).to.deep.equal(bidderRequest); + }); + + it('sends bid request to endpoint with multiple placements', function () { + bidderRequest.Bids = bidRequestMultiPlacements; + const request = spec.buildRequests(bidRequestMultiPlacements, bidderRequest); + const payload = JSON.parse(request.data); + + expect(request.url).to.contain('https://ssp.retail-spot.io/prebid'); + expect(request.method).to.equal('POST'); + + expect(payload).to.deep.equal(bidderRequest); + }); + + it('sends bid request to endpoint setted by parameters', function () { + const request = spec.buildRequests(bidRequestWithDevPlacement, bidderRequest); + expect(request.url).to.contain(DEV_URL); + }); + }); + // + describe('interpretResponse', function () { + let serverResponse; + + beforeEach(function () { + serverResponse = { + body: {} + } + }); + + it('handles nobid responses', function () { + let response = [{ + requestId: '123dfsdf', + placement: '12df1' + }]; + serverResponse.body = response; + let result = spec.interpretResponse(serverResponse, []); + expect(result).deep.equal([]); + }); + + it('receive reponse with single placement', function () { + serverResponse.body = responseWithSinglePlacement; + let result = spec.interpretResponse(serverResponse, {data: '{"bids":' + JSON.stringify(requestDataOnePlacement) + '}'}); + + expect(result.length).to.equal(1); + expect(result[0].cpm).to.equal(0.5); + expect(result[0].ad).to.equal(admSample); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(250); + expect(result[0].meta).to.deep.equal(testMetaObject); + }); + + it('receive reponse with multiple placement', function () { + serverResponse.body = responseWithMultiplePlacements; + let result = spec.interpretResponse(serverResponse, {data: '{"bids":' + JSON.stringify(requestDataMultiPlacement) + '}'}); + + expect(result.length).to.equal(2); + + expect(result[0].cpm).to.equal(0.5); + expect(result[0].ad).to.equal('placement_0'); + expect(result[0].width).to.equal(300); + expect(result[0].height).to.equal(600); + + expect(result[1].cpm).to.equal(0.6); + expect(result[1].ad).to.equal('placement_1'); + expect(result[1].width).to.equal(400); + expect(result[1].height).to.equal(250); + }); + + it('receive Vast reponse with Video ad', function () { + serverResponse.body = responseWithSingleVideo; + let result = spec.interpretResponse(serverResponse, {data: '{"bids":' + JSON.stringify(sentBidVideo) + '}'}); + + expect(result.length).to.equal(1); + expect(result).to.deep.equal(videoResult); + }); + }); +}); diff --git a/test/spec/modules/revcontentBidAdapter_spec.js b/test/spec/modules/revcontentBidAdapter_spec.js index 022dd0e1aa9..ca4e7bc4e4b 100644 --- a/test/spec/modules/revcontentBidAdapter_spec.js +++ b/test/spec/modules/revcontentBidAdapter_spec.js @@ -45,7 +45,7 @@ describe('revcontent adapter', function () { endpoint: 'trends-s0.revcontent.com' } }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page'}}); request = request[0]; assert.equal(request.method, 'POST'); assert.equal(request.url, 'https://trends-s0.revcontent.com/rtb?apiKey=8a33fa9cf220ae685dcc3544f847cdda858d3b1c&userId=673&widgetId=33861'); @@ -66,7 +66,7 @@ describe('revcontent adapter', function () { endpoint: 'trends-s0.revcontent.com' } }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page'}}); request = request[0]; let data = Object.keys(request); @@ -87,7 +87,7 @@ describe('revcontent adapter', function () { bidfloor: 0.05 } }]; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page'}}); request = JSON.parse(request[0].data); assert.equal(request.imp[0].bidfloor, 0.05); assert.equal(request.device.ua, navigator.userAgent); @@ -112,7 +112,7 @@ describe('revcontent adapter', function () { currency: 'USD' }; }; - let request = spec.buildRequests(validBidRequests, {refererInfo: {referer: 'page'}}); + let request = spec.buildRequests(validBidRequests, {refererInfo: {page: 'page'}}); request = JSON.parse(request[0].data); assert.equal(request.imp[0].bidfloor, 0.07); assert.equal(request.device.ua, navigator.userAgent); @@ -146,7 +146,7 @@ describe('revcontent adapter', function () { endpoint: 'trends-s0.revcontent.com' } }]; - let refererInfo = {referer: 'page'}; + let refererInfo = {page: 'page'}; let request = spec.buildRequests(validBidRequests, {refererInfo}); request = JSON.parse(request[0].data); @@ -266,8 +266,6 @@ describe('revcontent adapter', function () { it('should set correct native params', function () { const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); assert.equal(result.mediaType, 'native'); assert.equal(result.requestId, '294a7f446202848'); assert.equal(result.cpm, '0.1'); @@ -279,8 +277,6 @@ describe('revcontent adapter', function () { bidRequest.bid[0].params.size.height = 90; const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); assert.equal(result.mediaType, 'native'); assert.equal(result.requestId, '294a7f446202848'); assert.equal(result.cpm, '0.1'); @@ -292,8 +288,6 @@ describe('revcontent adapter', function () { bidRequest.bid[0].params.size.height = 600; const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); assert.equal(result.mediaType, 'native'); assert.equal(result.requestId, '294a7f446202848'); assert.equal(result.cpm, '0.1'); @@ -304,8 +298,6 @@ describe('revcontent adapter', function () { bidRequest.bid[0].params.template = '

{title}

SEE MORE
'; const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); assert.equal(result.mediaType, 'native'); assert.equal(result.requestId, '294a7f446202848'); assert.equal(result.cpm, '0.1'); @@ -317,8 +309,6 @@ describe('revcontent adapter', function () { bidRequest.bid[0].params.size.height = 200; const result = spec.interpretResponse(serverResponse, bidRequest)[0]; - assert.equal(result.bidder, 'revcontent'); - assert.equal(result.bidderCode, 'revcontent'); assert.equal(result.mediaType, 'native'); assert.equal(result.requestId, '294a7f446202848'); assert.equal(result.cpm, '0.1'); diff --git a/test/spec/modules/rhythmoneBidAdapter_spec.js b/test/spec/modules/rhythmoneBidAdapter_spec.js index e0e58fc89cd..359b02db37e 100644 --- a/test/spec/modules/rhythmoneBidAdapter_spec.js +++ b/test/spec/modules/rhythmoneBidAdapter_spec.js @@ -8,7 +8,7 @@ describe('rhythmone adapter tests', function () { beforeEach(function() { this.defaultBidderRequest = { 'refererInfo': { - 'referer': 'Reference Page', + 'ref': 'Reference Page', 'stack': [ 'aodomain.dvl', 'page.dvl' @@ -647,35 +647,6 @@ describe('rhythmone adapter tests', function () { }); }); - it('should return empty site.domain and site.page when refererInfo.stack is empty', function() { - this.defaultBidderRequest.refererInfo.stack = []; - var bidRequestList = [ - { - 'bidder': 'rhythmone', - 'params': { - 'placementId': 'myplacement', - 'zone': 'myzone', - 'path': 'mypath' - }, - 'mediaType': 'banner', - 'adUnitCode': 'div-gpt-ad-1438287399331-0', - 'sizes': [[300, 250]], - 'transactionId': 'd7b773de-ceaa-484d-89ca-d9f51b8d61ec', - 'bidderRequestId': '418b37f85e772c', - 'auctionId': '18fd8b8b0bd757', - 'bidRequestsCount': 1, - 'bidId': '51ef8751f9aead' - } - ]; - - var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest); - const openrtbRequest = JSON.parse(bidRequest.data); - - expect(openrtbRequest.site.domain).to.equal(''); - expect(openrtbRequest.site.page).to.equal(''); - expect(openrtbRequest.site.ref).to.equal('Reference Page'); - }); - it('should secure correctly', function() { this.defaultBidderRequest.refererInfo.stack[0] = ['https://securesite.dvl']; var bidRequestList = [ diff --git a/test/spec/modules/richaudienceBidAdapter_spec.js b/test/spec/modules/richaudienceBidAdapter_spec.js index 9e9366072be..ea45ff7e0b0 100644 --- a/test/spec/modules/richaudienceBidAdapter_spec.js +++ b/test/spec/modules/richaudienceBidAdapter_spec.js @@ -25,6 +25,41 @@ describe('Richaudience adapter tests', function () { auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', bidRequestsCount: 1, bidderRequestId: '1858b7382993ca', + ortb2Imp: { + ext: { + tid: '29df2112-348b-4961-8863-1b33684d95e6', + } + }, + user: {} + }]; + + var DEFAULT_PARAMS_NEW_SIZES_GPID = [{ + adUnitCode: 'test-div', + bidId: '2c7c8e9c900244', + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-1#example-2', + data: { + pbadslot: '/19968336/header-bid-tag-1#example-2' + } + } + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], [300, 600], [728, 90], [970, 250]] + } + }, + bidder: 'richaudience', + params: { + bidfloor: 0.5, + pid: 'ADb1f40rmi', + supplyType: 'site', + keywords: 'key1=value1;key2=value2' + }, + auctionId: '0cb3144c-d084-4686-b0d6-f5dbe917c563', + bidRequestsCount: 1, + bidderRequestId: '1858b7382993ca', transactionId: '29df2112-348b-4961-8863-1b33684d95e6', user: {} }]; @@ -176,7 +211,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'http://domain.com', + page: 'http://domain.com', numIframes: 0 } } @@ -205,7 +240,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -236,6 +271,7 @@ describe('Richaudience adapter tests', function () { expect(requestContent).to.have.property('numIframes').and.to.equal(0); expect(typeof requestContent.scr_rsl === 'string') expect(typeof requestContent.cpuc === 'number') + expect(typeof requestContent.gpid === 'string') expect(requestContent).to.have.property('kws').and.to.equal('key1=value1;key2=value2'); }) @@ -246,7 +282,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -265,7 +301,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -296,7 +332,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -311,7 +347,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -334,7 +370,7 @@ describe('Richaudience adapter tests', function () { consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA' }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -583,7 +619,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -611,7 +647,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -640,7 +676,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -669,7 +705,7 @@ describe('Richaudience adapter tests', function () { gdprApplies: true }, refererInfo: { - referer: 'https://domain.com', + page: 'https://domain.com', numIframes: 0 } }); @@ -831,6 +867,18 @@ describe('Richaudience adapter tests', function () { expect(requestContent).to.have.property('schain').to.deep.equal(schain); }) + it('should pass gpid', function() { + const request = spec.buildRequests(DEFAULT_PARAMS_NEW_SIZES_GPID, { + gdprConsent: { + consentString: 'BOZcQl_ObPFjWAeABAESCD-AAAAjx7_______9______9uz_Ov_v_f__33e8__9v_l_7_-___u_-33d4-_1vf99yfm1-7ftr3tp_87ues2_Xur__59__3z3_NohBgA', + gdprApplies: true + }, + refererInfo: {} + }) + const requestContent = JSON.parse(request[0].data); + expect(requestContent).to.have.property('gpid').and.to.equal('/19968336/header-bid-tag-1#example-2'); + }) + describe('userSync', function () { it('Verifies user syncs iframe include', function () { config.setConfig({ diff --git a/test/spec/modules/riseBidAdapter_spec.js b/test/spec/modules/riseBidAdapter_spec.js index 596c4d0f58c..eed8d74f271 100644 --- a/test/spec/modules/riseBidAdapter_spec.js +++ b/test/spec/modules/riseBidAdapter_spec.js @@ -7,6 +7,9 @@ import * as utils from 'src/utils.js'; const ENDPOINT = 'https://hb.yellowblue.io/hb-multi'; const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-multi-test'; +const RTB_DOMAIN_TEST = 'testseller.com'; +const RTB_DOMAIN_ENDPOINT = `https://${RTB_DOMAIN_TEST}/hb-multi`; +const RTB_DOMAIN_TEST_ENDPOINT = `https://${RTB_DOMAIN_TEST}/hb-multi-test`; const TTL = 360; /* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */ @@ -53,12 +56,14 @@ describe('riseAdapter', function () { 'org': 'jdye8weeyirk00000001' }, 'bidId': '299ffc8cca0b87', + 'loop': 1, 'bidderRequestId': '1144f487e563f9', 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', 'mediaTypes': { 'video': { 'playerSize': [[640, 480]], - 'context': 'instream' + 'context': 'instream', + 'plcmt': 1 } }, 'vastXml': '"..."' @@ -71,6 +76,7 @@ describe('riseAdapter', function () { 'org': 'jdye8weeyirk00000001' }, 'bidId': '299ffc8cca0b87', + 'loop': 1, 'bidderRequestId': '1144f487e563f9', 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', 'mediaTypes': { @@ -91,6 +97,7 @@ describe('riseAdapter', function () { 'testMode': true }, 'bidId': '299ffc8cca0b87', + 'loop': 2, 'bidderRequestId': '1144f487e563f9', 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', } @@ -100,6 +107,9 @@ describe('riseAdapter', function () { bidderCode: 'rise', } const placementId = '12345678'; + const api = [1, 2]; + const mimes = ['application/javascript', 'video/mp4', 'video/quicktime']; + const protocols = [2, 3, 5, 6]; it('sends the placementId to ENDPOINT via POST', function () { bidRequests[0].params.placementId = placementId; @@ -107,6 +117,18 @@ describe('riseAdapter', function () { expect(request.data.bids[0].placementId).to.equal(placementId); }); + it('sends the plcmt to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].plcmt).to.equal(1); + }); + + it('sends the is_wrapper parameter to ENDPOINT via POST', function() { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('is_wrapper'); + expect(request.data.params.is_wrapper).to.equal(false); + }); + it('sends bid request to ENDPOINT via POST', function () { const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.url).to.equal(ENDPOINT); @@ -119,11 +141,46 @@ describe('riseAdapter', function () { expect(request.method).to.equal('POST'); }); + it('sends bid request to rtbDomain ENDPOINT via POST', function () { + bidRequests[0].params.rtbDomain = RTB_DOMAIN_TEST; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.equal(RTB_DOMAIN_ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('sends bid request to rtbDomain TEST ENDPOINT via POST', function () { + testModeBidRequests[0].params.rtbDomain = RTB_DOMAIN_TEST; + const request = spec.buildRequests(testModeBidRequests, bidderRequest); + expect(request.url).to.equal(RTB_DOMAIN_TEST_ENDPOINT); + expect(request.method).to.equal('POST'); + }); + it('should send the correct bid Id', function () { const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.bids[0].bidId).to.equal('299ffc8cca0b87'); }); + it('should send the correct supported api array', function () { + bidRequests[0].mediaTypes.video.api = api; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].api).to.be.an('array'); + expect(request.data.bids[0].api).to.eql([1, 2]); + }); + + it('should send the correct mimes array', function () { + bidRequests[1].mediaTypes.banner.mimes = mimes; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[1].mimes).to.be.an('array'); + expect(request.data.bids[1].mimes).to.eql(['application/javascript', 'video/mp4', 'video/quicktime']); + }); + + it('should send the correct protocols array', function () { + bidRequests[0].mediaTypes.video.protocols = protocols; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].protocols).to.be.an('array'); + expect(request.data.bids[0].protocols).to.eql([2, 3, 5, 6]); + }); + it('should send the correct sizes array', function () { const request = spec.buildRequests(bidRequests, bidderRequest); expect(request.data.bids[0].sizes).to.be.an('array'); @@ -290,6 +347,86 @@ describe('riseAdapter', function () { expect(request.data.bids[0]).to.be.an('object'); expect(request.data.bids[0]).to.have.property('floorPrice', 1.5); }); + + it('should check sua param in bid request', function() { + const sua = { + 'platform': { + 'brand': 'macOS', + 'version': ['12', '4', '0'] + }, + 'browsers': [ + { + 'brand': 'Chromium', + 'version': [ '106', '0', '5249', '119' ] + }, + { + 'brand': 'Google Chrome', + 'version': [ '106', '0', '5249', '119' ] + }, + { + 'brand': 'Not;A=Brand', + 'version': [ '99', '0', '0', '0' ] + } + ], + 'mobile': 0, + 'model': '', + 'bitness': '64', + 'architecture': 'x86' + } + const bid = utils.deepClone(bidRequests[0]); + bid.ortb2 = { + 'device': { + 'sua': { + 'platform': { + 'brand': 'macOS', + 'version': [ '12', '4', '0' ] + }, + 'browsers': [ + { + 'brand': 'Chromium', + 'version': [ '106', '0', '5249', '119' ] + }, + { + 'brand': 'Google Chrome', + 'version': [ '106', '0', '5249', '119' ] + }, + { + 'brand': 'Not;A=Brand', + 'version': [ '99', '0', '0', '0' ] + } + ], + 'mobile': 0, + 'model': '', + 'bitness': '64', + 'architecture': 'x86' + } + } + } + const requestWithSua = spec.buildRequests([bid], bidderRequest); + const data = requestWithSua.data; + expect(data.bids[0].sua).to.exist; + expect(data.bids[0].sua).to.deep.equal(sua); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].sua).to.not.exist; + }); + + describe('COPPA Param', function() { + it('should set coppa equal 0 in bid request if coppa is set to false', function() { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].coppa).to.be.equal(0); + }); + + it('should set coppa equal 1 in bid request if coppa is set to true', function() { + const bid = utils.deepClone(bidRequests[0]); + bid.ortb2 = { + 'regs': { + 'coppa': true, + } + }; + const request = spec.buildRequests([bid], bidderRequest); + expect(request.data.bids[0].coppa).to.be.equal(1); + }); + }); }); describe('interpretResponse', function () { diff --git a/test/spec/modules/rtbhouseBidAdapter_spec.js b/test/spec/modules/rtbhouseBidAdapter_spec.js index f4bcb48474a..0b944dcb077 100644 --- a/test/spec/modules/rtbhouseBidAdapter_spec.js +++ b/test/spec/modules/rtbhouseBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { OPENRTB, spec } from 'modules/rtbhouseBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; describe('RTBHouseAdapter', () => { const adapter = newBidder(spec); @@ -52,16 +53,18 @@ describe('RTBHouseAdapter', () => { describe('buildRequests', function () { let bidRequests; - const bidderRequest = { - 'refererInfo': { - 'numIframes': 0, - 'reachedTop': true, - 'referer': 'https://example.com', - 'stack': ['https://example.com'] - } - }; + let bidderRequest; beforeEach(() => { + bidderRequest = { + 'auctionId': 'bidderrequest-auction-id', + 'refererInfo': { + 'numIframes': 0, + 'reachedTop': true, + 'referer': 'https://example.com', + 'stack': ['https://example.com'] + } + }; bidRequests = [ { 'bidder': 'rtbhouse', @@ -81,6 +84,11 @@ describe('RTBHouseAdapter', () => { 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', 'transactionId': 'example-transaction-id', + 'ortb2Imp': { + 'ext': { + 'tid': 'ortb2Imp-transaction-id-1' + } + }, 'schain': { 'ver': '1.0', 'complete': 1, @@ -97,6 +105,10 @@ describe('RTBHouseAdapter', () => { ]; }); + afterEach(function () { + config.resetConfig(); + }); + it('should build test param into the request', () => { let builtTestRequest = spec.buildRequests(bidRequests, bidderRequest).data; expect(JSON.parse(builtTestRequest).test).to.equal(1); @@ -198,7 +210,7 @@ describe('RTBHouseAdapter', () => { const bidRequest = Object.assign([], bidRequests); const request = spec.buildRequests(bidRequest, bidderRequest); const data = JSON.parse(request.data); - expect(data.source.tid).to.equal('example-transaction-id'); + expect(data.source.tid).to.equal('bidderrequest-auction-id'); }); it('should include bidfloor from floor module if avaiable', () => { @@ -251,6 +263,13 @@ describe('RTBHouseAdapter', () => { expect(data.source).to.have.deep.property('tid'); }); + it('should include impression level transaction id when provided', () => { + const bidRequest = Object.assign([], bidRequests); + const request = spec.buildRequests(bidRequest, bidderRequest); + const data = JSON.parse(request.data); + expect(data.imp[0].ext.tid).to.equal('ortb2Imp-transaction-id-1'); + }); + it('should not include invalid schain', () => { const bidRequest = Object.assign([], bidRequests); bidRequest[0].schain = { @@ -263,6 +282,102 @@ describe('RTBHouseAdapter', () => { expect(data.source).to.not.have.property('ext'); }); + it('should include first party data', function () { + const bidRequest = Object.assign([], bidRequests); + const localBidderRequest = { + ...bidderRequest, + ortb2: { + bcat: ['IAB1', 'IAB2-1'], + badv: ['domain1.com', 'domain2.com'], + site: { ext: { data: 'some site data' } }, + device: { ext: { data: 'some device data' } }, + user: { ext: { data: 'some user data' } } + } + }; + + const request = spec.buildRequests(bidRequest, localBidderRequest); + const data = JSON.parse(request.data); + expect(data.bcat).to.deep.equal(localBidderRequest.ortb2.bcat); + expect(data.badv).to.deep.equal(localBidderRequest.ortb2.badv); + expect(data.site).to.nested.include({'ext.data': 'some site data'}); + expect(data.device).to.nested.include({'ext.data': 'some device data'}); + expect(data.user).to.nested.include({'ext.data': 'some user data'}); + }); + + context('FLEDGE', function() { + afterEach(function () { + config.resetConfig(); + }); + + it('sends bid request to FLEDGE ENDPOINT via POST', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + config.setConfig({ fledgeConfig: true }); + const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: true }); + expect(request.url).to.equal('https://prebid-eu.creativecdn.com/bidder/prebidfledge/bids'); + expect(request.method).to.equal('POST'); + }); + + it('sets default fledgeConfig object values when none available from config', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + + config.setConfig({ fledgeConfig: false }); + const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: true }); + const data = JSON.parse(request.data); + expect(data.ext).to.exist.and.to.be.a('object'); + expect(data.ext.fledge_config).to.exist.and.to.be.a('object'); + expect(data.ext.fledge_config).to.contain.keys('seller', 'decisionLogicUrl', 'sellerTimeout'); + expect(data.ext.fledge_config.seller).to.equal('https://fledge-ssp.creativecdn.com'); + expect(data.ext.fledge_config.decisionLogicUrl).to.equal('https://fledge-ssp.creativecdn.com/component-seller-prebid.js'); + expect(data.ext.fledge_config.sellerTimeout).to.equal(500); + }); + + it('sets a fledgeConfig object values when available from config', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + + config.setConfig({ + fledgeConfig: { + seller: 'https://sellers.domain', + decisionLogicUrl: 'https://sellers.domain/decision.url' + } + }); + const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: true }); + const data = JSON.parse(request.data); + expect(data.ext).to.exist.and.to.be.a('object'); + expect(data.ext.fledge_config).to.exist.and.to.be.a('object'); + expect(data.ext.fledge_config).to.contain.keys('seller', 'decisionLogicUrl'); + expect(data.ext.fledge_config.seller).to.equal('https://sellers.domain'); + expect(data.ext.fledge_config.decisionLogicUrl).to.equal('https://sellers.domain/decision.url'); + expect(data.ext.fledge_config.sellerTimeout).to.not.exist; + }); + + it('when FLEDGE is disabled, should not send imp.ext.ae', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + bidRequest[0].ortb2Imp = { + ext: { ae: 2 } + }; + const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: false }); + let data = JSON.parse(request.data); + if (data.imp[0].ext) { + expect(data.imp[0].ext).to.not.have.property('ae'); + } + }); + + it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + bidRequest[0].ortb2Imp = { + ext: { ae: 2 } + }; + const request = spec.buildRequests(bidRequest, { ...bidderRequest, fledgeEnabled: true }); + let data = JSON.parse(request.data); + expect(data.imp[0].ext.ae).to.equal(2); + }); + }); + describe('native imp', () => { function basicRequest(extension) { return Object.assign({ @@ -460,6 +575,29 @@ describe('RTBHouseAdapter', () => { 'h': 250 }]; + let fledgeResponse = { + 'id': 'bid-identifier', + 'ext': { + 'igbid': [{ + 'impid': 'test-bid-id', + 'igbuyer': [{ + 'igdomain': 'https://buyer-domain.com', + 'buyersignal': {} + }] + }], + 'sellerTimeout': 500, + 'seller': 'https://seller-domain.com', + 'decisionLogicUrl': 'https://seller-domain.com/decision-logic.js' + }, + 'bidid': 'bid-identifier', + 'seatbid': [{ + 'bid': [{ + 'id': 'bid-response-id', + 'impid': 'test-bid-id' + }] + }] + }; + it('should get correct bid response', function () { let expectedResponse = [ { @@ -488,6 +626,18 @@ describe('RTBHouseAdapter', () => { expect(result.length).to.equal(0); }); + context('when the response contains FLEDGE interest groups config', function () { + let bidderRequest; + let response = spec.interpretResponse({body: fledgeResponse}, {bidderRequest}); + + it('should return FLEDGE auction_configs alongside bids', function () { + expect(response).to.have.property('bids'); + expect(response).to.have.property('fledgeAuctionConfigs'); + expect(response.fledgeAuctionConfigs.length).to.equal(1); + expect(response.fledgeAuctionConfigs[0].bidId).to.equal('test-bid-id'); + }); + }); + describe('native', () => { const adm = { native: { @@ -538,10 +688,10 @@ describe('RTBHouseAdapter', () => { expect(bids[0].meta.advertiserDomains).to.deep.equal(['rtbhouse.com']); expect(bids[0].native).to.deep.equal({ title: 'Title text', - clickUrl: encodeURIComponent('https://example.com'), + clickUrl: encodeURI('https://example.com'), impressionTrackers: ['https://example.com/imptracker'], image: { - url: encodeURIComponent('https://example.com/image.jpg'), + url: encodeURI('https://example.com/image.jpg'), width: 150, height: 50 }, diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js deleted file mode 100644 index 1f52e83dab9..00000000000 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ /dev/null @@ -1,2541 +0,0 @@ -import rubiconAnalyticsAdapter, { - SEND_TIMEOUT, - parseBidResponse, - getHostNameFromReferer, - storage, - rubiConf, -} from 'modules/rubiconAnalyticsAdapter.js'; -import CONSTANTS from 'src/constants.json'; -import { config } from 'src/config.js'; -import { server } from 'test/mocks/xhr.js'; -import * as mockGpt from '../integration/faker/googletag.js'; -import { - setConfig, - addBidResponseHook, -} from 'modules/currency.js'; - -let Ajv = require('ajv'); -let schema = require('./rubiconAnalyticsSchema.json'); -let ajv = new Ajv({ - allErrors: true -}); - -let validator = ajv.compile(schema); - -function validate(message) { - validator(message); - expect(validator.errors).to.deep.equal(null); -} - -let events = require('src/events.js'); -let utils = require('src/utils.js'); - -const { - EVENTS: { - AUCTION_INIT, - AUCTION_END, - BID_REQUESTED, - BID_RESPONSE, - BIDDER_DONE, - BID_WON, - BID_TIMEOUT, - SET_TARGETING, - BILLABLE_EVENT - } -} = CONSTANTS; - -const BID = { - 'bidder': 'rubicon', - 'width': 640, - 'height': 480, - 'mediaType': 'video', - 'statusMessage': 'Bid available', - 'bidId': '2ecff0db240757', - 'adId': 'fake_ad_id', - 'source': 'client', - 'requestId': '2ecff0db240757', - 'currency': 'USD', - 'creativeId': '3571560', - 'cpm': 1.22752, - 'ttl': 300, - 'netRevenue': false, - 'ad': '', - 'rubiconTargeting': { - 'rpfl_elemid': '/19968336/header-bid-tag-0', - 'rpfl_14062': '2_tier0100' - }, - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'responseTimestamp': 1519149629415, - 'requestTimestamp': 1519149628471, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'timeToRespond': 944, - 'pbLg': '1.00', - 'pbMg': '1.20', - 'pbHg': '1.22', - 'pbAg': '1.20', - 'pbDg': '1.22', - 'pbCg': '', - 'size': '640x480', - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': 1.20, - 'hb_size': '640x480', - 'hb_source': 'client' - }, - getStatusCode() { - return 1; - } -}; - -const BID2 = Object.assign({}, BID, { - adUnitCode: '/19968336/header-bid-tag1', - bidId: '3bd4ebb1c900e2', - adId: 'fake_ad_id', - requestId: '3bd4ebb1c900e2', - width: 728, - height: 90, - mediaType: 'banner', - cpm: 1.52, - source: 'server', - seatBidId: 'aaaa-bbbb-cccc-dddd', - rubiconTargeting: { - 'rpfl_elemid': '/19968336/header-bid-tag1', - 'rpfl_14062': '2_tier0100' - }, - adserverTargeting: { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - } -}); - -const BID3 = Object.assign({}, BID, { - adUnitCode: '/19968336/siderail-tag1', - bidId: '5fg6hyy4r879f0', - adId: 'fake_ad_id', - requestId: '5fg6hyy4r879f0', - width: 300, - height: 250, - mediaType: 'banner', - cpm: 2.01, - source: 'server', - seatBidId: 'aaaa-bbbb-cccc-dddd', - rubiconTargeting: { - 'rpfl_elemid': '/19968336/siderail-tag1', - 'rpfl_14062': '15_tier0200' - }, - adserverTargeting: { - 'hb_bidder': 'rubicon', - 'hb_adid': '5fg6hyy4r879f0', - 'hb_pb': '2.00', - 'hb_size': '300x250', - 'hb_source': 'server' - } -}); - -const BID4 = Object.assign({}, BID, { - adUnitCode: '/19968336/header-bid-tag1', - bidId: '3bd4ebb1c900e2', - adId: 'fake_ad_id', - requestId: '3bd4ebb1c900e2', - width: 728, - height: 90, - mediaType: 'banner', - cpm: 1.52, - source: 'server', - pbsBidId: 'zzzz-yyyy-xxxx-wwww', - seatBidId: 'aaaa-bbbb-cccc-dddd', - rubiconTargeting: { - 'rpfl_elemid': '/19968336/header-bid-tag1', - 'rpfl_14062': '2_tier0100' - }, - adserverTargeting: { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - } -}); - -const floorMinRequest = { - 'bidder': 'rubicon', - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': { 'rating': '4-star', 'prodtype': 'tech' }, - 'visitor': { 'ucat': 'new', 'lastsearch': 'iphone' }, - 'position': 'atf' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250]] - } - }, - 'adUnitCode': '/19968336/siderail-tag1', - 'transactionId': 'c435626g-9e3f-401a-bee1-d56aec29a1d4', - 'sizes': [[300, 250]], - 'bidId': '5fg6hyy4r879f0', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' -}; - -const MOCK = { - SET_TARGETING: { - [BID.adUnitCode]: BID.adserverTargeting, - [BID2.adUnitCode]: BID2.adserverTargeting, - [BID3.adUnitCode]: BID3.adserverTargeting - }, - AUCTION_INIT: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'timestamp': 1519767010567, - 'auctionStatus': 'inProgress', - 'adUnits': [{ - 'code': '/19968336/header-bid-tag1', - 'sizes': [[640, 480]], - 'bids': [{ - 'bidder': 'rubicon', - 'params': { - 'accountId': 1001, 'siteId': 113932, 'zoneId': 535512 - } - }], - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014' - } - ], - 'adUnitCodes': ['/19968336/header-bid-tag1'], - 'bidderRequests': [{ - 'bidderCode': 'rubicon', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'bidderRequestId': '1be65d7958826a', - 'bids': [{ - 'bidder': 'rubicon', - 'params': { - 'accountId': 1001, 'siteId': 113932, 'zoneId': 535512 - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[640, 480]] - } - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'sizes': [[640, 480]], - 'bidId': '2ecff0db240757', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'src': 'client', - 'bidRequestsCount': 1 - } - ], - 'timeout': 3000, - 'refererInfo': { - 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] - } - } - ], - 'bidsReceived': [], - 'winningBids': [], - 'timeout': 3000, - 'config': { - 'accountId': 1001, 'endpoint': '//localhost:9999/event' - } - }, - BID_REQUESTED: { - 'bidderCode': 'rubicon', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'bidderRequestId': '1be65d7958826a', - 'bids': [ - { - 'bidder': 'rubicon', - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': 'test', - 'visitor': { 'ucat': 'new', 'lastsearch': 'iphone' }, - 'position': 'btf', - 'video': { - 'language': 'en', - 'playerHeight': 480, - 'playerWidth': 640, - 'size_id': 203, - 'skip': 1, - 'skipdelay': 15, - 'aeParams': { - 'p_aso.video.ext.skip': '1', - 'p_aso.video.ext.skipdelay': '15' - } - } - }, - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'playerSize': [640, 480] - } - }, - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'sizes': [[640, 480]], - 'bidId': '2ecff0db240757', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'src': 'client' - }, - { - 'bidder': 'rubicon', - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918', - 'userId': '12346', - 'keywords': ['a', 'b', 'c'], - 'inventory': { 'rating': '4-star', 'prodtype': 'tech' }, - 'visitor': { 'ucat': 'new', 'lastsearch': 'iphone' }, - 'position': 'atf' - }, - 'mediaTypes': { - 'banner': { - 'sizes': [[1000, 300], [970, 250], [728, 90]] - } - }, - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'sizes': [[1000, 300], [970, 250], [728, 90]], - 'bidId': '3bd4ebb1c900e2', - 'bidderRequestId': '1be65d7958826a', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'src': 's2s' - } - ], - 'auctionStart': 1519149536560, - 'timeout': 5000, - 'start': 1519149562216, - 'refererInfo': { - 'referer': 'http://www.test.com/page.html', 'reachedTop': true, 'numIframes': 0, 'stack': ['http://www.test.com/page.html'] - } - }, - BID_RESPONSE: [ - BID, - BID2, - BID3 - ], - AUCTION_END: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - }, - BID_WON: [ - Object.assign({}, BID, { - 'status': 'rendered' - }), - Object.assign({}, BID2, { - 'status': 'rendered' - }), - Object.assign({}, BID3, { - 'status': 'rendered' - }) - ], - BIDDER_DONE: { - 'bidderCode': 'rubicon', - 'serverResponseTimeMs': 42, - 'bids': [ - BID, - Object.assign({}, BID2, { - 'serverResponseTimeMs': 42, - }), - Object.assign({}, BID3, { - 'serverResponseTimeMs': 55, - }) - ] - }, - BID_TIMEOUT: [ - { - 'bidId': '2ecff0db240757', - 'bidder': 'rubicon', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - } - ] -}; - -const STUBBED_UUID = '12345678-1234-1234-1234-123456789abc'; - -const ANALYTICS_MESSAGE = { - 'channel': 'web', - 'integration': 'pbjs', - 'version': '$prebid.version$', - 'referrerUri': 'http://www.test.com/page.html', - 'session': { - 'expires': 1519788613781, - 'id': STUBBED_UUID, - 'start': 1519767013781 - }, - 'timestamps': { - 'auctionEnded': 1519767013781, - 'eventTime': 1519767013781, - 'prebidLoaded': rubiconAnalyticsAdapter.MODULE_INITIALIZED_TIME - }, - 'trigger': 'allBidWons', - 'referrerHostname': 'www.test.com', - 'auctions': [ - { - - 'auctionEnd': 1519767013781, - 'auctionStart': 1519767010567, - 'bidderOrder': ['rubicon'], - 'requestId': '25c6d7f5-699a-4bfc-87c9-996f915341fa', - 'clientTimeoutMillis': 3000, - 'serverTimeoutMillis': 1000, - 'accountId': 1001, - 'samplingFactor': 1, - 'adUnits': [ - { - 'adUnitCode': '/19968336/header-bid-tag-0', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'videoAdFormat': 'outstream', - 'mediaTypes': [ - 'video' - ], - 'dimensions': [ - { - 'width': 640, - 'height': 480 - } - ], - 'status': 'success', - 'accountId': 1001, - 'siteId': 70608, - 'zoneId': 335918, - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': '1.200', - 'hb_size': '640x480', - 'hb_source': 'client' - }, - 'bids': [ - { - 'bidder': 'rubicon', - 'bidId': '2ecff0db240757', - 'status': 'success', - 'source': 'client', - 'clientLatencyMillis': 3214, - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'bidResponse': { - 'bidPriceUSD': 1.22752, - 'dimensions': { - 'width': 640, - 'height': 480 - }, - 'mediaType': 'video' - } - } - ] - }, - { - 'adUnitCode': '/19968336/header-bid-tag1', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'mediaTypes': [ - 'banner' - ], - 'dimensions': [ - { - 'width': 1000, - 'height': 300 - }, - { - 'width': 970, - 'height': 250 - }, - { - 'width': 728, - 'height': 90 - } - ], - 'status': 'success', - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - }, - 'bids': [ - { - 'bidder': 'rubicon', - 'bidId': 'aaaa-bbbb-cccc-dddd', - 'status': 'success', - 'source': 'server', - 'clientLatencyMillis': 3214, - 'serverLatencyMillis': 42, - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'bidResponse': { - 'bidPriceUSD': 1.52, - 'dimensions': { - 'width': 728, - 'height': 90 - }, - 'mediaType': 'banner' - } - } - ] - } - ] - } - ], - 'bidsWon': [ - { - 'bidder': 'rubicon', - 'transactionId': 'ca4af27a-6d02-4f90-949d-d5541fa12014', - 'adUnitCode': '/19968336/header-bid-tag-0', - 'bidId': '2ecff0db240757', - 'status': 'success', - 'source': 'client', - 'clientLatencyMillis': 3214, - 'samplingFactor': 1, - 'accountId': 1001, - 'siteId': 70608, - 'zoneId': 335918, - 'params': { - 'accountId': '1001', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'videoAdFormat': 'outstream', - 'mediaTypes': [ - 'video' - ], - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '2ecff0db240757', - 'hb_pb': '1.200', - 'hb_size': '640x480', - 'hb_source': 'client' - }, - 'bidResponse': { - 'bidPriceUSD': 1.22752, - 'dimensions': { - 'width': 640, - 'height': 480 - }, - 'mediaType': 'video' - }, - 'bidwonStatus': 'success' - }, - { - 'bidder': 'rubicon', - 'transactionId': 'c116413c-9e3f-401a-bee1-d56aec29a1d4', - 'adUnitCode': '/19968336/header-bid-tag1', - 'bidId': 'aaaa-bbbb-cccc-dddd', - 'status': 'success', - 'source': 'server', - 'clientLatencyMillis': 3214, - 'serverLatencyMillis': 42, - 'samplingFactor': 1, - 'accountId': 1001, - 'params': { - 'accountId': '14062', - 'siteId': '70608', - 'zoneId': '335918' - }, - 'mediaTypes': [ - 'banner' - ], - 'adserverTargeting': { - 'hb_bidder': 'rubicon', - 'hb_adid': '3bd4ebb1c900e2', - 'hb_pb': '1.500', - 'hb_size': '728x90', - 'hb_source': 'server' - }, - 'bidResponse': { - 'bidPriceUSD': 1.52, - 'dimensions': { - 'width': 728, - 'height': 90 - }, - 'mediaType': 'banner' - }, - 'bidwonStatus': 'success' - } - ], - 'wrapper': { - 'name': '10000_fakewrapper_test' - } -}; - -function performStandardAuction(gptEvents, auctionId = MOCK.AUCTION_INIT.auctionId) { - events.emit(AUCTION_INIT, { ...MOCK.AUCTION_INIT, auctionId }); - events.emit(BID_REQUESTED, { ...MOCK.BID_REQUESTED, auctionId }); - events.emit(BID_RESPONSE, { ...MOCK.BID_RESPONSE[0], auctionId }); - events.emit(BID_RESPONSE, { ...MOCK.BID_RESPONSE[1], auctionId }); - events.emit(BIDDER_DONE, { ...MOCK.BIDDER_DONE, auctionId }); - events.emit(AUCTION_END, { ...MOCK.AUCTION_END, auctionId }); - - if (gptEvents && gptEvents.length) { - gptEvents.forEach(gptEvent => mockGpt.emitEvent(gptEvent.eventName, gptEvent.params)); - } - - events.emit(SET_TARGETING, { ...MOCK.SET_TARGETING, auctionId }); - events.emit(BID_WON, { ...MOCK.BID_WON[0], auctionId }); - events.emit(BID_WON, { ...MOCK.BID_WON[1], auctionId }); -} - -describe('rubicon analytics adapter', function () { - let sandbox; - let clock; - let getDataFromLocalStorageStub, setDataInLocalStorageStub, localStorageIsEnabledStub; - beforeEach(function () { - getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); - setDataInLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage'); - localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); - mockGpt.disable(); - sandbox = sinon.sandbox.create(); - - localStorageIsEnabledStub.returns(true); - - sandbox.stub(events, 'getEvents').returns([]); - - sandbox.stub(utils, 'generateUUID').returns(STUBBED_UUID); - - clock = sandbox.useFakeTimers(1519767013781); - - rubiconAnalyticsAdapter.referrerHostname = ''; - - config.setConfig({ - s2sConfig: { - timeout: 1000, - accountId: 10000, - }, - rubicon: { - wrapperName: '10000_fakewrapper_test' - } - }) - }); - - afterEach(function () { - sandbox.restore(); - config.resetConfig(); - mockGpt.enable(); - getDataFromLocalStorageStub.restore(); - setDataInLocalStorageStub.restore(); - localStorageIsEnabledStub.restore(); - }); - - it('should require accountId', function () { - sandbox.stub(utils, 'logError'); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event' - } - }); - - expect(utils.logError.called).to.equal(true); - }); - - it('should require endpoint', function () { - sandbox.stub(utils, 'logError'); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - accountId: 1001 - } - }); - - expect(utils.logError.called).to.equal(true); - }); - - describe('config subscribe', function () { - it('should update the pvid if user asks', function () { - expect(utils.generateUUID.called).to.equal(false); - config.setConfig({ rubicon: { updatePageView: true } }); - expect(utils.generateUUID.called).to.equal(true); - }); - it('should merge in and preserve older set configs', function () { - config.setConfig({ - rubicon: { - wrapperName: '1001_general', - int_type: 'dmpbjs', - fpkvs: { - source: 'fb' - } - } - }); - expect(rubiConf).to.deep.equal({ - analyticsEventDelay: 0, - dmBilling: { - enabled: false, - vendors: [], - waitForAuction: true - }, - pvid: '12345678', - wrapperName: '1001_general', - int_type: 'dmpbjs', - fpkvs: { - source: 'fb' - }, - updatePageView: true - }); - - // update it with stuff - config.setConfig({ - rubicon: { - fpkvs: { - link: 'email' - } - } - }); - expect(rubiConf).to.deep.equal({ - analyticsEventDelay: 0, - dmBilling: { - enabled: false, - vendors: [], - waitForAuction: true - }, - pvid: '12345678', - wrapperName: '1001_general', - int_type: 'dmpbjs', - fpkvs: { - source: 'fb', - link: 'email' - }, - updatePageView: true - }); - - // overwriting specific edge keys should update them - config.setConfig({ - rubicon: { - fpkvs: { - link: 'iMessage', - source: 'twitter' - } - } - }); - expect(rubiConf).to.deep.equal({ - analyticsEventDelay: 0, - dmBilling: { - enabled: false, - vendors: [], - waitForAuction: true - }, - pvid: '12345678', - wrapperName: '1001_general', - int_type: 'dmpbjs', - fpkvs: { - link: 'iMessage', - source: 'twitter' - }, - updatePageView: true - }); - }); - }); - - describe('sampling', function () { - beforeEach(function () { - sandbox.stub(Math, 'random').returns(0.08); - sandbox.stub(utils, 'logError'); - }); - - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - - describe('with options.samplingFactor', function () { - it('should sample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 10 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(1); - }); - - it('should unsample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 20 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(0); - }); - - it('should throw errors for invalid samplingFactor', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - samplingFactor: 30 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(0); - expect(utils.logError.called).to.equal(true); - }); - }); - describe('with options.sampling', function () { - it('should sample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 0.1 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(1); - }); - - it('should unsample', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 0.05 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(0); - }); - - it('should throw errors for invalid samplingFactor', function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001, - sampling: 1 / 30 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(0); - expect(utils.logError.called).to.equal(true); - }); - }); - }); - - describe('when handling events', function () { - beforeEach(function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - }); - - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - - it('should build a batched message from prebid events', function () { - performStandardAuction(); - - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - - expect(request.url).to.equal('//localhost:9999/event'); - - let message = JSON.parse(request.requestBody); - validate(message); - - expect(message).to.deep.equal(ANALYTICS_MESSAGE); - }); - - it('should pass along bidderOrder correctly', function () { - const appnexusBid = utils.deepClone(MOCK.BID_REQUESTED); - appnexusBid.bidderCode = 'appnexus'; - const pubmaticBid = utils.deepClone(MOCK.BID_REQUESTED); - pubmaticBid.bidderCode = 'pubmatic'; - const indexBid = utils.deepClone(MOCK.BID_REQUESTED); - indexBid.bidderCode = 'ix'; - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, pubmaticBid); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_REQUESTED, indexBid); - events.emit(BID_REQUESTED, appnexusBid); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - clock.tick(SEND_TIMEOUT + 1000); - - let message = JSON.parse(server.requests[0].requestBody); - expect(message.auctions[0].bidderOrder).to.deep.equal([ - 'pubmatic', - 'rubicon', - 'ix', - 'appnexus' - ]); - }); - - it('should pass along user ids', function () { - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.bidderRequests[0].bids[0].userId = { - criteoId: 'sadfe4334', - lotamePanoramaId: 'asdf3gf4eg', - pubcid: 'dsfa4545-svgdfs5', - sharedId: { id1: 'asdf', id2: 'sadf4344' } - }; - - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - - let message = JSON.parse(request.requestBody); - validate(message); - - expect(message.auctions[0].user).to.deep.equal({ - ids: [ - { provider: 'criteoId', 'hasId': true }, - { provider: 'lotamePanoramaId', 'hasId': true }, - { provider: 'pubcid', 'hasId': true }, - { provider: 'sharedId', 'hasId': true }, - ] - }); - }); - - it('should handle bidResponse dimensions correctly', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - - // mock bid response with playerWidth and playerHeight (NO width and height) - let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]); - delete bidResponse1.width; - delete bidResponse1.height; - bidResponse1.playerWidth = 640; - bidResponse1.playerHeight = 480; - - // mock bid response with no width height or playerwidth playerheight - let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]); - delete bidResponse2.width; - delete bidResponse2.height; - delete bidResponse2.playerWidth; - delete bidResponse2.playerHeight; - - events.emit(BID_RESPONSE, bidResponse1); - events.emit(BID_RESPONSE, bidResponse2); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.dimensions).to.deep.equal({ - width: 640, - height: 480 - }); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.dimensions).to.equal(undefined); - }); - - it('should pass along adomians correctly', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - - // 1 adomains - let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]); - bidResponse1.meta = { - advertiserDomains: ['magnite.com'] - } - - // two adomains - let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]); - bidResponse2.meta = { - advertiserDomains: ['prebid.org', 'magnite.com'] - } - - // make sure we only pass max 10 adomains - bidResponse2.meta.advertiserDomains = [...bidResponse2.meta.advertiserDomains, ...bidResponse2.meta.advertiserDomains, ...bidResponse2.meta.advertiserDomains, ...bidResponse2.meta.advertiserDomains, ...bidResponse2.meta.advertiserDomains, ...bidResponse2.meta.advertiserDomains, ...bidResponse2.meta.advertiserDomains] - - events.emit(BID_RESPONSE, bidResponse1); - events.emit(BID_RESPONSE, bidResponse2); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.adomains).to.deep.equal(['magnite.com']); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.adomains).to.deep.equal(['prebid.org', 'magnite.com', 'prebid.org', 'magnite.com', 'prebid.org', 'magnite.com', 'prebid.org', 'magnite.com', 'prebid.org', 'magnite.com']); - }); - - it('should NOT pass along adomians correctly when edge cases', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - - // empty => nothing - let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]); - bidResponse1.meta = { - advertiserDomains: [] - } - - // not array => nothing - let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]); - bidResponse2.meta = { - advertiserDomains: 'prebid.org' - } - - events.emit(BID_RESPONSE, bidResponse1); - events.emit(BID_RESPONSE, bidResponse2); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.adomains).to.be.undefined; - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.adomains).to.be.undefined; - }); - - it('should NOT pass along adomians with other edge cases', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - - // should filter out non string values and pass valid ones - let bidResponse1 = utils.deepClone(MOCK.BID_RESPONSE[0]); - bidResponse1.meta = { - advertiserDomains: [123, 'prebid.org', false, true, [], 'magnite.com', {}] - } - - // array of arrays (as seen when passed by kargo bid adapter) - let bidResponse2 = utils.deepClone(MOCK.BID_RESPONSE[1]); - bidResponse2.meta = { - advertiserDomains: [['prebid.org']] - } - - events.emit(BID_RESPONSE, bidResponse1); - events.emit(BID_RESPONSE, bidResponse2); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.adomains).to.deep.equal(['prebid.org', 'magnite.com']); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.adomains).to.be.undefined; - }); - - it('should not pass empty adServerTargeting values', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - - const mockTargeting = utils.deepClone(MOCK.SET_TARGETING); - mockTargeting['/19968336/header-bid-tag-0'].hb_test = ''; - mockTargeting['/19968336/header-bid-tag1'].hb_test = 'NOT_EMPTY'; - events.emit(SET_TARGETING, mockTargeting); - - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_test).to.be.undefined; - expect(message.auctions[0].adUnits[1].adserverTargeting.hb_test).to.equal('NOT_EMPTY'); - }); - - function performFloorAuction(provider) { - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.bidderRequests[0].bids[0].floorData = { - skipped: false, - modelVersion: 'someModelName', - modelWeight: 10, - modelTimestamp: 1606772895, - location: 'setConfig', - skipRate: 15, - fetchStatus: 'error', - floorProvider: provider - }; - let flooredResponse = { - ...BID, - floorData: { - floorValue: 4, - floorRule: '12345/sports|video', - floorCurrency: 'USD', - cpmAfterAdjustments: 2.1, - enforcements: { - enforceJS: true, - enforcePBS: false, - floorDeals: false, - bidAdjustment: true - }, - matchedFields: { - gptSlot: '12345/sports', - mediaType: 'video' - } - }, - status: 'bidRejected', - cpm: 0, - getStatusCode() { - return 2; - } - }; - - let notFlooredResponse = { - ...BID2, - floorData: { - floorValue: 1, - floorRule: '12345/news|banner', - floorCurrency: 'USD', - cpmAfterAdjustments: 1.55, - enforcements: { - enforceJS: true, - enforcePBS: false, - floorDeals: false, - bidAdjustment: true - }, - matchedFields: { - gptSlot: '12345/news', - mediaType: 'banner' - } - } - }; - - let floorMinResponse = { - ...BID3, - floorData: { - floorValue: 1.5, - floorRuleValue: 1, - floorRule: '12345/entertainment|banner', - floorCurrency: 'USD', - cpmAfterAdjustments: 2.00, - enforcements: { - enforceJS: true, - enforcePBS: false, - floorDeals: false, - bidAdjustment: true - }, - matchedFields: { - gptSlot: '12345/entertainment', - mediaType: 'banner' - } - } - }; - - let bidRequest = utils.deepClone(MOCK.BID_REQUESTED); - bidRequest.bids.push(floorMinRequest) - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequest); - events.emit(BID_RESPONSE, flooredResponse); - events.emit(BID_RESPONSE, notFlooredResponse); - events.emit(BID_RESPONSE, floorMinResponse); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[1]); - events.emit(BID_WON, MOCK.BID_WON[2]); - clock.tick(SEND_TIMEOUT + 1000); - - expect(server.requests.length).to.equal(1); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - return message; - } - - it('should capture price floor information correctly', function () { - let message = performFloorAuction('rubicon'); - - // verify our floor stuff is passed - // top level floor info - expect(message.auctions[0].floors).to.deep.equal({ - location: 'setConfig', - modelName: 'someModelName', - modelWeight: 10, - modelTimestamp: 1606772895, - skipped: false, - enforcement: true, - dealsEnforced: false, - skipRate: 15, - fetchStatus: 'error', - provider: 'rubicon' - }); - // first adUnit's adSlot - expect(message.auctions[0].adUnits[0].gam.adSlot).to.equal('12345/sports'); - // since no other bids, we set adUnit status to no-bid - expect(message.auctions[0].adUnits[0].status).to.equal('no-bid'); - // first adUnits bid is rejected - expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected-ipf'); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.floorValue).to.equal(4); - // if bid rejected should take cpmAfterAdjustments val - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(2.1); - - // second adUnit's adSlot - expect(message.auctions[0].adUnits[1].gam.adSlot).to.equal('12345/news'); - // top level adUnit status is success - expect(message.auctions[0].adUnits[1].status).to.equal('success'); - // second adUnits bid is success - expect(message.auctions[0].adUnits[1].bids[0].status).to.equal('success'); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.floorValue).to.equal(1); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.bidPriceUSD).to.equal(1.52); - - // second adUnit's adSlot - expect(message.auctions[0].adUnits[2].gam.adSlot).to.equal('12345/entertainment'); - // top level adUnit status is success - expect(message.auctions[0].adUnits[2].status).to.equal('success'); - // second adUnits bid is success - expect(message.auctions[0].adUnits[2].bids[0].status).to.equal('success'); - expect(message.auctions[0].adUnits[2].bids[0].bidResponse.floorValue).to.equal(1.5); - expect(message.auctions[0].adUnits[2].bids[0].bidResponse.floorRuleValue).to.equal(1); - expect(message.auctions[0].adUnits[2].bids[0].bidResponse.bidPriceUSD).to.equal(2.01); - }); - - it('should still send floor info if provider is not rubicon', function () { - let message = performFloorAuction('randomProvider'); - - // verify our floor stuff is passed - // top level floor info - expect(message.auctions[0].floors).to.deep.equal({ - location: 'setConfig', - modelName: 'someModelName', - modelWeight: 10, - modelTimestamp: 1606772895, - skipped: false, - enforcement: true, - dealsEnforced: false, - skipRate: 15, - fetchStatus: 'error', - provider: 'randomProvider' - }); - // first adUnit's adSlot - expect(message.auctions[0].adUnits[0].gam.adSlot).to.equal('12345/sports'); - // since no other bids, we set adUnit status to no-bid - expect(message.auctions[0].adUnits[0].status).to.equal('no-bid'); - // first adUnits bid is rejected - expect(message.auctions[0].adUnits[0].bids[0].status).to.equal('rejected-ipf'); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.floorValue).to.equal(4); - // if bid rejected should take cpmAfterAdjustments val - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(2.1); - - // second adUnit's adSlot - expect(message.auctions[0].adUnits[1].gam.adSlot).to.equal('12345/news'); - // top level adUnit status is success - expect(message.auctions[0].adUnits[1].status).to.equal('success'); - // second adUnits bid is success - expect(message.auctions[0].adUnits[1].bids[0].status).to.equal('success'); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.floorValue).to.equal(1); - expect(message.auctions[0].adUnits[1].bids[0].bidResponse.bidPriceUSD).to.equal(1.52); - - // second adUnit's adSlot - expect(message.auctions[0].adUnits[2].gam.adSlot).to.equal('12345/entertainment'); - // top level adUnit status is success - expect(message.auctions[0].adUnits[2].status).to.equal('success'); - // second adUnits bid is success - expect(message.auctions[0].adUnits[2].bids[0].status).to.equal('success'); - expect(message.auctions[0].adUnits[2].bids[0].bidResponse.floorValue).to.equal(1.5); - expect(message.auctions[0].adUnits[2].bids[0].bidResponse.floorRuleValue).to.equal(1); - expect(message.auctions[0].adUnits[2].bids[0].bidResponse.bidPriceUSD).to.equal(2.01); - }); - - describe('with session handling', function () { - const expectedPvid = STUBBED_UUID.slice(0, 8); - beforeEach(function () { - config.setConfig({ rubicon: { updatePageView: true } }); - }); - - it('should not log any session data if local storage is not enabled', function () { - localStorageIsEnabledStub.returns(false); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - delete expectedMessage.session; - delete expectedMessage.fpkvs; - - performStandardAuction(); - - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - - expect(request.url).to.equal('//localhost:9999/event'); - - let message = JSON.parse(request.requestBody); - validate(message); - - expect(message).to.deep.equal(expectedMessage); - }); - - it('should should pass along custom rubicon kv and pvid when defined', function () { - config.setConfig({ - rubicon: { - fpkvs: { - source: 'fb', - link: 'email' - } - } - }); - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.session.pvid = STUBBED_UUID.slice(0, 8); - expectedMessage.fpkvs = [ - { key: 'source', value: 'fb' }, - { key: 'link', value: 'email' } - ] - expect(message).to.deep.equal(expectedMessage); - }); - - it('should convert kvs to strings before sending', function () { - config.setConfig({ - rubicon: { - fpkvs: { - number: 24, - boolean: false, - string: 'hello', - array: ['one', 2, 'three'], - object: { one: 'two' } - } - } - }); - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.session.pvid = STUBBED_UUID.slice(0, 8); - expectedMessage.fpkvs = [ - { key: 'number', value: '24' }, - { key: 'boolean', value: 'false' }, - { key: 'string', value: 'hello' }, - { key: 'array', value: 'one,2,three' }, - { key: 'object', value: '[object Object]' } - ] - expect(message).to.deep.equal(expectedMessage); - }); - - it('should use the query utm param rubicon kv value and pass updated kv and pvid when defined', function () { - sandbox.stub(utils, 'getWindowLocation').returns({ 'search': '?utm_source=other', 'pbjs_debug': 'true' }); - - config.setConfig({ - rubicon: { - fpkvs: { - source: 'fb', - link: 'email' - } - } - }); - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.session.pvid = STUBBED_UUID.slice(0, 8); - expectedMessage.fpkvs = [ - { key: 'source', value: 'other' }, - { key: 'link', value: 'email' } - ] - - message.fpkvs.sort((left, right) => left.key < right.key); - expectedMessage.fpkvs.sort((left, right) => left.key < right.key); - - expect(message).to.deep.equal(expectedMessage); - }); - - it('should pick up existing localStorage and use its values', function () { - // set some localStorage - let inputlocalStorage = { - id: '987654', - start: 1519766113781, // 15 mins before "now" - expires: 1519787713781, // six hours later - lastSeen: 1519766113781, - fpkvs: { source: 'tw' } - }; - getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage))); - - config.setConfig({ - rubicon: { - fpkvs: { - link: 'email' // should merge this with what is in the localStorage! - } - } - }); - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.session = { - id: '987654', - start: 1519766113781, - expires: 1519787713781, - pvid: expectedPvid - } - expectedMessage.fpkvs = [ - { key: 'source', value: 'tw' }, - { key: 'link', value: 'email' } - ] - expect(message).to.deep.equal(expectedMessage); - - let calledWith; - try { - calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1])); - } catch (e) { - calledWith = {}; - } - - expect(calledWith).to.deep.equal({ - id: '987654', // should have stayed same - start: 1519766113781, // should have stayed same - expires: 1519787713781, // should have stayed same - lastSeen: 1519767013781, // lastSeen updated to our "now" - fpkvs: { source: 'tw', link: 'email' }, // link merged in - pvid: expectedPvid // new pvid stored - }); - }); - - it('should overwrite matching localstorge value and use its remaining values', function () { - sandbox.stub(utils, 'getWindowLocation').returns({ 'search': '?utm_source=fb&utm_click=dog' }); - - // set some localStorage - let inputlocalStorage = { - id: '987654', - start: 1519766113781, // 15 mins before "now" - expires: 1519787713781, // six hours later - lastSeen: 1519766113781, - fpkvs: { source: 'tw', link: 'email' } - }; - getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage))); - - config.setConfig({ - rubicon: { - fpkvs: { - link: 'email' // should merge this with what is in the localStorage! - } - } - }); - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.session = { - id: '987654', - start: 1519766113781, - expires: 1519787713781, - pvid: expectedPvid - } - expectedMessage.fpkvs = [ - { key: 'source', value: 'fb' }, - { key: 'link', value: 'email' }, - { key: 'click', value: 'dog' } - ] - - message.fpkvs.sort((left, right) => left.key < right.key); - expectedMessage.fpkvs.sort((left, right) => left.key < right.key); - - expect(message).to.deep.equal(expectedMessage); - - let calledWith; - try { - calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1])); - } catch (e) { - calledWith = {}; - } - - expect(calledWith).to.deep.equal({ - id: '987654', // should have stayed same - start: 1519766113781, // should have stayed same - expires: 1519787713781, // should have stayed same - lastSeen: 1519767013781, // lastSeen updated to our "now" - fpkvs: { source: 'fb', link: 'email', click: 'dog' }, // link merged in - pvid: expectedPvid // new pvid stored - }); - }); - - it('should throw out session if lastSeen > 30 mins ago and create new one', function () { - // set some localStorage - let inputlocalStorage = { - id: '987654', - start: 1519764313781, // 45 mins before "now" - expires: 1519785913781, // six hours later - lastSeen: 1519764313781, // 45 mins before "now" - fpkvs: { source: 'tw' } - }; - getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage))); - - config.setConfig({ - rubicon: { - fpkvs: { - link: 'email' // should merge this with what is in the localStorage! - } - } - }); - - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - // session should match what is already in ANALYTICS_MESSAGE, just need to add pvid - expectedMessage.session.pvid = expectedPvid; - - // the saved fpkvs should have been thrown out since session expired - expectedMessage.fpkvs = [ - { key: 'link', value: 'email' } - ] - expect(message).to.deep.equal(expectedMessage); - - let calledWith; - try { - calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1])); - } catch (e) { - calledWith = {}; - } - - expect(calledWith).to.deep.equal({ - id: STUBBED_UUID, // should have stayed same - start: 1519767013781, // should have stayed same - expires: 1519788613781, // should have stayed same - lastSeen: 1519767013781, // lastSeen updated to our "now" - fpkvs: { link: 'email' }, // link merged in - pvid: expectedPvid // new pvid stored - }); - }); - - it('should throw out session if past expires time and create new one', function () { - // set some localStorage - let inputlocalStorage = { - id: '987654', - start: 1519745353781, // 6 hours before "expires" - expires: 1519766953781, // little more than six hours ago - lastSeen: 1519767008781, // 5 seconds ago - fpkvs: { source: 'tw' } - }; - getDataFromLocalStorageStub.withArgs('rpaSession').returns(btoa(JSON.stringify(inputlocalStorage))); - - config.setConfig({ - rubicon: { - fpkvs: { - link: 'email' // should merge this with what is in the localStorage! - } - } - }); - - performStandardAuction(); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - // session should match what is already in ANALYTICS_MESSAGE, just need to add pvid - expectedMessage.session.pvid = expectedPvid; - - // the saved fpkvs should have been thrown out since session expired - expectedMessage.fpkvs = [ - { key: 'link', value: 'email' } - ] - expect(message).to.deep.equal(expectedMessage); - - let calledWith; - try { - calledWith = JSON.parse(atob(setDataInLocalStorageStub.getCall(0).args[1])); - } catch (e) { - calledWith = {}; - } - - expect(calledWith).to.deep.equal({ - id: STUBBED_UUID, // should have stayed same - start: 1519767013781, // should have stayed same - expires: 1519788613781, // should have stayed same - lastSeen: 1519767013781, // lastSeen updated to our "now" - fpkvs: { link: 'email' }, // link merged in - pvid: expectedPvid // new pvid stored - }); - }); - }); - describe('with googletag enabled', function () { - let gptSlot0, gptSlot1; - let gptSlotRenderEnded0, gptSlotRenderEnded1; - beforeEach(function () { - mockGpt.enable(); - gptSlot0 = mockGpt.makeSlot({ code: '/19968336/header-bid-tag-0' }); - gptSlotRenderEnded0 = { - eventName: 'slotRenderEnded', - params: { - slot: gptSlot0, - isEmpty: false, - advertiserId: 1111, - sourceAgnosticCreativeId: 2222, - sourceAgnosticLineItemId: 3333 - } - }; - - gptSlot1 = mockGpt.makeSlot({ code: '/19968336/header-bid-tag1' }); - gptSlotRenderEnded1 = { - eventName: 'slotRenderEnded', - params: { - slot: gptSlot1, - isEmpty: false, - advertiserId: 4444, - sourceAgnosticCreativeId: 5555, - sourceAgnosticLineItemId: 6666 - } - }; - }); - - afterEach(function () { - mockGpt.disable(); - }); - - it('should add necessary gam information if gpt is enabled and slotRender event emmited', function () { - performStandardAuction([gptSlotRenderEnded0, gptSlotRenderEnded1]); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.auctions[0].adUnits[0].gam = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - expectedMessage.auctions[0].adUnits[1].gam = { - advertiserId: 4444, - creativeId: 5555, - lineItemId: 6666, - adSlot: '/19968336/header-bid-tag1' - }; - expect(message).to.deep.equal(expectedMessage); - }); - - it('should handle empty gam renders', function () { - performStandardAuction([gptSlotRenderEnded0, { - eventName: 'slotRenderEnded', - params: { - slot: gptSlot1, - isEmpty: true - } - }]); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.auctions[0].adUnits[0].gam = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - expectedMessage.auctions[0].adUnits[1].gam = { - isSlotEmpty: true, - adSlot: '/19968336/header-bid-tag1' - }; - expect(message).to.deep.equal(expectedMessage); - }); - - it('should still add gam ids if falsy', function () { - performStandardAuction([gptSlotRenderEnded0, { - eventName: 'slotRenderEnded', - params: { - slot: gptSlot1, - isEmpty: false, - advertiserId: 0, - sourceAgnosticCreativeId: 0, - sourceAgnosticLineItemId: 0 - } - }]); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.auctions[0].adUnits[0].gam = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - expectedMessage.auctions[0].adUnits[1].gam = { - advertiserId: 0, - creativeId: 0, - lineItemId: 0, - adSlot: '/19968336/header-bid-tag1' - }; - expect(message).to.deep.equal(expectedMessage); - }); - - it('should pick backup Ids if no sourceAgnostic available first', function () { - performStandardAuction([gptSlotRenderEnded0, { - eventName: 'slotRenderEnded', - params: { - slot: gptSlot1, - isEmpty: false, - advertiserId: 0, - lineItemId: 1234, - creativeId: 5678 - } - }]); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.auctions[0].adUnits[0].gam = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - expectedMessage.auctions[0].adUnits[1].gam = { - advertiserId: 0, - creativeId: 5678, - lineItemId: 1234, - adSlot: '/19968336/header-bid-tag1' - }; - expect(message).to.deep.equal(expectedMessage); - }); - - it('should correctly set adUnit for associated slots', function () { - performStandardAuction([gptSlotRenderEnded0, gptSlotRenderEnded1]); - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - expectedMessage.auctions[0].adUnits[0].gam = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - expectedMessage.auctions[0].adUnits[1].gam = { - advertiserId: 4444, - creativeId: 5555, - lineItemId: 6666, - adSlot: '/19968336/header-bid-tag1' - }; - expect(message).to.deep.equal(expectedMessage); - }); - - it('should only mark the first gam data not all matches', function () { - config.setConfig({ - rubicon: { - waitForGamSlots: true - } - }); - performStandardAuction(); - performStandardAuction([gptSlotRenderEnded0, gptSlotRenderEnded1], '32d332de-123a-32dg-2345-cefef3423324'); - - // tick the clock and both should fire - clock.tick(3000); - - expect(server.requests.length).to.equal(2); - - // first one should have GAM data - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - - // trigger should be gam since all adunits had associated gam render - expect(message.trigger).to.be.equal('gam'); - expect(message.auctions[0].adUnits[0].gam).to.deep.equal({ - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }); - expect(message.auctions[0].adUnits[1].gam).to.deep.equal({ - advertiserId: 4444, - creativeId: 5555, - lineItemId: 6666, - adSlot: '/19968336/header-bid-tag1' - }); - - // second one should NOT have gam data - request = server.requests[1]; - message = JSON.parse(request.requestBody); - validate(message); - - // trigger should be auctionEnd - expect(message.trigger).to.be.equal('auctionEnd'); - expect(message.auctions[0].adUnits[0].gam).to.be.undefined; - expect(message.auctions[0].adUnits[1].gam).to.be.undefined; - }); - - it('should send request when waitForGamSlots is present but no bidWons are sent', function () { - config.setConfig({ - rubicon: { - waitForGamSlots: true, - } - }); - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - - // should send if just slotRenderEnded is emmitted for both - mockGpt.emitEvent(gptSlotRenderEnded0.eventName, gptSlotRenderEnded0.params); - mockGpt.emitEvent(gptSlotRenderEnded1.eventName, gptSlotRenderEnded1.params); - - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - - let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE); - delete expectedMessage.bidsWon; // should not be any of these - expectedMessage.auctions[0].adUnits[0].gam = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - expectedMessage.auctions[0].adUnits[1].gam = { - advertiserId: 4444, - creativeId: 5555, - lineItemId: 6666, - adSlot: '/19968336/header-bid-tag1' - }; - expectedMessage.trigger = 'gam'; - expect(message).to.deep.equal(expectedMessage); - }); - - it('should delay the event call depending on analyticsEventDelay config', function () { - config.setConfig({ - rubicon: { - waitForGamSlots: true, - analyticsEventDelay: 2000 - } - }); - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - - // should send if just slotRenderEnded is emmitted for both - mockGpt.emitEvent(gptSlotRenderEnded0.eventName, gptSlotRenderEnded0.params); - mockGpt.emitEvent(gptSlotRenderEnded1.eventName, gptSlotRenderEnded1.params); - - // Should not be sent until delay - expect(server.requests.length).to.equal(0); - - // tick the clock and it should fire - clock.tick(2000); - - expect(server.requests.length).to.equal(1); - let request = server.requests[0]; - let message = JSON.parse(request.requestBody); - validate(message); - let expectedGam0 = { - advertiserId: 1111, - creativeId: 2222, - lineItemId: 3333, - adSlot: '/19968336/header-bid-tag-0' - }; - let expectedGam1 = { - advertiserId: 4444, - creativeId: 5555, - lineItemId: 6666, - adSlot: '/19968336/header-bid-tag1' - }; - expect(expectedGam0).to.deep.equal(message.auctions[0].adUnits[0].gam); - expect(expectedGam1).to.deep.equal(message.auctions[0].adUnits[1].gam); - }); - }); - - it('should correctly overwrite bidId if seatBidId is on the bidResponse', function () { - // Only want one bid request in our mock auction - let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); - bidRequested.bids.shift(); - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.adUnits.shift(); - - // clone the mock bidResponse and duplicate - let seatBidResponse = utils.deepClone(BID2); - seatBidResponse.seatBidId = 'abc-123-do-re-me'; - - const setTargeting = { - [seatBidResponse.adUnitCode]: seatBidResponse.adserverTargeting - }; - - const bidWon = Object.assign({}, seatBidResponse, { - 'status': 'rendered' - }); - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequested); - events.emit(BID_RESPONSE, seatBidResponse); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, setTargeting); - events.emit(BID_WON, bidWon); - - let message = JSON.parse(server.requests[0].requestBody); - - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidId).to.equal('abc-123-do-re-me'); - expect(message.bidsWon[0].bidId).to.equal('abc-123-do-re-me'); - }); - - it('should correctly overwrite bidId if pbsBidId is on the bidResponse', function () { - // Only want one bid request in our mock auction - let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); - bidRequested.bids.shift(); - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.adUnits.shift(); - - // clone the mock bidResponse and duplicate - let seatBidResponse = utils.deepClone(BID4); - - const setTargeting = { - [seatBidResponse.adUnitCode]: seatBidResponse.adserverTargeting - }; - - const bidWon = Object.assign({}, seatBidResponse, { - 'status': 'rendered' - }); - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequested); - events.emit(BID_RESPONSE, seatBidResponse); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, setTargeting); - events.emit(BID_WON, bidWon); - - let message = JSON.parse(server.requests[0].requestBody); - - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidId).to.equal('zzzz-yyyy-xxxx-wwww'); - expect(message.bidsWon[0].bidId).to.equal('zzzz-yyyy-xxxx-wwww'); - }); - - it('should correctly generate new bidId if it is 0', function () { - // Only want one bid request in our mock auction - let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); - bidRequested.bids.shift(); - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.adUnits.shift(); - - // clone the mock bidResponse and duplicate - let seatBidResponse = utils.deepClone(BID4); - seatBidResponse.pbsBidId = '0'; - - const setTargeting = { - [seatBidResponse.adUnitCode]: seatBidResponse.adserverTargeting - }; - - const bidWon = Object.assign({}, seatBidResponse, { - 'status': 'rendered' - }); - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequested); - events.emit(BID_RESPONSE, seatBidResponse); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, setTargeting); - events.emit(BID_WON, bidWon); - - let message = JSON.parse(server.requests[0].requestBody); - - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidId).to.equal(STUBBED_UUID); - expect(message.bidsWon[0].bidId).to.equal(STUBBED_UUID); - }); - - it('should pick the highest cpm bid if more than one bid per bidRequestId', function () { - // Only want one bid request in our mock auction - let bidRequested = utils.deepClone(MOCK.BID_REQUESTED); - bidRequested.bids.shift(); - let auctionInit = utils.deepClone(MOCK.AUCTION_INIT); - auctionInit.adUnits.shift(); - - // clone the mock bidResponse and duplicate - let duplicateResponse1 = utils.deepClone(BID2); - duplicateResponse1.cpm = 1.0; - duplicateResponse1.adserverTargeting.hb_pb = '1.0'; - duplicateResponse1.adserverTargeting.hb_adid = '1111'; - let duplicateResponse2 = utils.deepClone(BID2); - duplicateResponse2.cpm = 5.5; - duplicateResponse2.adserverTargeting.hb_pb = '5.5'; - duplicateResponse2.adserverTargeting.hb_adid = '5555'; - let duplicateResponse3 = utils.deepClone(BID2); - duplicateResponse3.cpm = 0.1; - duplicateResponse3.adserverTargeting.hb_pb = '0.1'; - duplicateResponse3.adserverTargeting.hb_adid = '3333'; - - const setTargeting = { - [duplicateResponse2.adUnitCode]: duplicateResponse2.adserverTargeting - }; - - const bidWon = Object.assign({}, duplicateResponse2, { - 'status': 'rendered' - }); - - // spoof the auction with just our duplicates - events.emit(AUCTION_INIT, auctionInit); - events.emit(BID_REQUESTED, bidRequested); - events.emit(BID_RESPONSE, duplicateResponse1); - events.emit(BID_RESPONSE, duplicateResponse2); - events.emit(BID_RESPONSE, duplicateResponse3); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, setTargeting); - events.emit(BID_WON, bidWon); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].bids[0].bidResponse.bidPriceUSD).to.equal(5.5); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_pb).to.equal('5.5'); - expect(message.auctions[0].adUnits[0].adserverTargeting.hb_adid).to.equal('5555'); - expect(message.bidsWon.length).to.equal(1); - expect(message.bidsWon[0].bidResponse.bidPriceUSD).to.equal(5.5); - expect(message.bidsWon[0].adserverTargeting.hb_pb).to.equal('5.5'); - expect(message.bidsWon[0].adserverTargeting.hb_adid).to.equal('5555'); - }); - - it('should send batched message without BID_WON if necessary and further BID_WON events individually', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - - clock.tick(SEND_TIMEOUT + 1000); - - events.emit(BID_WON, MOCK.BID_WON[1]); - - expect(server.requests.length).to.equal(2); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.bidsWon.length).to.equal(1); - expect(message.auctions).to.deep.equal(ANALYTICS_MESSAGE.auctions); - expect(message.bidsWon[0]).to.deep.equal(ANALYTICS_MESSAGE.bidsWon[0]); - - message = JSON.parse(server.requests[1].requestBody); - validate(message); - expect(message.bidsWon.length).to.equal(1); - expect(message).to.not.have.property('auctions'); - expect(message.bidsWon[0]).to.deep.equal(ANALYTICS_MESSAGE.bidsWon[1]); - }); - - it('should properly mark bids as timed out', function () { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_TIMEOUT, MOCK.BID_TIMEOUT); - events.emit(AUCTION_END, MOCK.AUCTION_END); - - clock.tick(SEND_TIMEOUT + 1000); - - expect(server.requests.length).to.equal(1); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - let timedOutBid = message.auctions[0].adUnits[0].bids[0]; - expect(timedOutBid.status).to.equal('error'); - expect(timedOutBid.error.code).to.equal('timeout-error'); - expect(timedOutBid.error.description).to.equal('prebid.js timeout'); - expect(timedOutBid).to.not.have.property('bidResponse'); - }); - - it('should pass aupName as pattern', function () { - let bidRequest = utils.deepClone(MOCK.BID_REQUESTED); - bidRequest.bids[0].ortb2Imp = { - ext: { - data: { - aupname: '1234/mycoolsite/*&gpt_leaderboard&deviceType=mobile' - } - } - }; - bidRequest.bids[1].ortb2Imp = { - ext: { - data: { - aupname: '1234/mycoolsite/*&gpt_skyscraper&deviceType=mobile' - } - } - }; - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, bidRequest); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - - clock.tick(SEND_TIMEOUT + 1000); - - expect(server.requests.length).to.equal(1); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].pattern).to.equal('1234/mycoolsite/*&gpt_leaderboard&deviceType=mobile'); - expect(message.auctions[0].adUnits[1].pattern).to.equal('1234/mycoolsite/*&gpt_skyscraper&deviceType=mobile'); - }); - - it('should pass gpid if defined', function () { - let bidRequest = utils.deepClone(MOCK.BID_REQUESTED); - bidRequest.bids[0].ortb2Imp = { - ext: { - gpid: '1234/mycoolsite/lowerbox' - } - }; - bidRequest.bids[1].ortb2Imp = { - ext: { - gpid: '1234/mycoolsite/leaderboard' - } - }; - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, bidRequest); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - - clock.tick(SEND_TIMEOUT + 1000); - - expect(server.requests.length).to.equal(1); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - expect(message.auctions[0].adUnits[0].gpid).to.equal('1234/mycoolsite/lowerbox'); - expect(message.auctions[0].adUnits[1].gpid).to.equal('1234/mycoolsite/leaderboard'); - }); - - it('should pass bidderDetail for multibid auctions', function () { - let bidResponse = utils.deepClone(MOCK.BID_RESPONSE[1]); - bidResponse.targetingBidder = 'rubi2'; - bidResponse.originalRequestId = bidResponse.requestId; - bidResponse.requestId = '1a2b3c4d5e6f7g8h9'; - - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, bidResponse); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - - clock.tick(SEND_TIMEOUT + 1000); - - expect(server.requests.length).to.equal(1); - - let message = JSON.parse(server.requests[0].requestBody); - validate(message); - - expect(message.auctions[0].adUnits[1].bids[1].bidder).to.equal('rubicon'); - expect(message.auctions[0].adUnits[1].bids[1].bidderDetail).to.equal('rubi2'); - }); - - it('should successfully convert bid price to USD in parseBidResponse', function () { - // Set the rates - setConfig({ - adServerCurrency: 'JPY', - rates: { - USD: { - JPY: 100 - } - } - }); - - // set our bid response to JPY - const bidCopy = utils.deepClone(BID2); - bidCopy.currency = 'JPY'; - bidCopy.cpm = 100; - - // Now add the bidResponse hook which hooks on the currenct conversion function onto the bid response - let innerBid; - addBidResponseHook(function (adCodeId, bid) { - innerBid = bid; - }, 'elementId', bidCopy); - - // Use the rubi analytics parseBidResponse Function to get the resulting cpm from the bid response! - const bidResponseObj = parseBidResponse(innerBid); - expect(bidResponseObj).to.have.property('bidPriceUSD'); - expect(bidResponseObj.bidPriceUSD).to.equal(1.0); - }); - }); - - describe('config with integration type', () => { - it('should use the integration type provided in the config instead of the default', () => { - config.setConfig({ - rubicon: { - int_type: 'testType' - } - }) - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.integration).to.equal('testType'); - - rubiconAnalyticsAdapter.disableAnalytics(); - }); - }); - - describe('billing events integration', () => { - beforeEach(function () { - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - // default dmBilling - config.setConfig({ - rubicon: { - dmBilling: { - enabled: false, - vendors: [], - waitForAuction: true - } - } - }) - }); - afterEach(function () { - rubiconAnalyticsAdapter.disableAnalytics(); - }); - const basicBillingAuction = (billingEvents = []) => { - events.emit(AUCTION_INIT, MOCK.AUCTION_INIT); - events.emit(BID_REQUESTED, MOCK.BID_REQUESTED); - - // emit billing events - billingEvents.forEach(ev => events.emit(BILLABLE_EVENT, ev)); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[0]); - events.emit(BID_RESPONSE, MOCK.BID_RESPONSE[1]); - events.emit(BIDDER_DONE, MOCK.BIDDER_DONE); - events.emit(AUCTION_END, MOCK.AUCTION_END); - events.emit(SET_TARGETING, MOCK.SET_TARGETING); - events.emit(BID_WON, MOCK.BID_WON[0]); - events.emit(BID_WON, MOCK.BID_WON[1]); - } - it('should ignore billing events when not enabled', () => { - basicBillingAuction([{ - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }]); - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.billableEvents).to.be.undefined; - }); - it('should ignore billing events when enabled but vendor is not whitelisted', () => { - // off by default - config.setConfig({ - rubicon: { - dmBilling: { - enabled: true - } - } - }); - basicBillingAuction([{ - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }]); - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.billableEvents).to.be.undefined; - }); - it('should ignore billing events if billingId is not defined or billingId is not a string', () => { - // off by default - config.setConfig({ - rubicon: { - dmBilling: { - enabled: true, - vendors: ['vendorName'] - } - } - }); - basicBillingAuction([ - { - vendor: 'vendorName', - type: 'auction', - }, - { - vendor: 'vendorName', - type: 'auction', - billingId: true - }, - { - vendor: 'vendorName', - type: 'auction', - billingId: 1233434 - }, - { - vendor: 'vendorName', - type: 'auction', - billingId: null - } - ]); - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.billableEvents).to.be.undefined; - }); - it('should pass along billing event in same payload', () => { - // off by default - config.setConfig({ - rubicon: { - dmBilling: { - enabled: true, - vendors: ['vendorName'] - } - } - }); - basicBillingAuction([{ - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }]); - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message).to.haveOwnProperty('auctions'); - expect(message.billableEvents).to.deep.equal([{ - accountId: 1001, - vendor: 'vendorName', - type: 'general', // mapping all events to endpoint as 'general' for now - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }]); - }); - it('should pass along multiple billing events but filter out duplicates', () => { - // off by default - config.setConfig({ - rubicon: { - dmBilling: { - enabled: true, - vendors: ['vendorName'] - } - } - }); - basicBillingAuction([ - { - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }, - { - vendor: 'vendorName', - type: 'auction', - billingId: '743db6e3-21f2-44d4-917f-cb3488c6076f' - }, - { - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - } - ]); - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message).to.haveOwnProperty('auctions'); - expect(message.billableEvents).to.deep.equal([ - { - accountId: 1001, - vendor: 'vendorName', - type: 'general', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }, - { - accountId: 1001, - vendor: 'vendorName', - type: 'general', - billingId: '743db6e3-21f2-44d4-917f-cb3488c6076f' - } - ]); - }); - it('should pass along event right away if no pending auction', () => { - // off by default - config.setConfig({ - rubicon: { - dmBilling: { - enabled: true, - vendors: ['vendorName'] - } - } - }); - - events.emit(BILLABLE_EVENT, { - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }); - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message).to.not.haveOwnProperty('auctions'); - expect(message.billableEvents).to.deep.equal([ - { - accountId: 1001, - vendor: 'vendorName', - type: 'general', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - } - ]); - }); - it('should pass along event right away if pending auction but not waiting', () => { - // off by default - config.setConfig({ - rubicon: { - dmBilling: { - enabled: true, - vendors: ['vendorName'], - waitForAuction: false - } - } - }); - // should fire right away, and then auction later - basicBillingAuction([{ - vendor: 'vendorName', - type: 'auction', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - }]); - expect(server.requests.length).to.equal(2); - const billingRequest = server.requests[0]; - const billingMessage = JSON.parse(billingRequest.requestBody); - expect(billingMessage).to.not.haveOwnProperty('auctions'); - expect(billingMessage.billableEvents).to.deep.equal([ - { - accountId: 1001, - vendor: 'vendorName', - type: 'general', - billingId: 'f8558d41-62de-4349-bc7b-2dbee1e69965' - } - ]); - // auction event after - const auctionRequest = server.requests[1]; - const auctionMessage = JSON.parse(auctionRequest.requestBody); - // should not double pass events! - expect(auctionMessage).to.not.haveOwnProperty('billableEvents'); - }); - }); - - describe('wrapper details passed in', () => { - it('should correctly pass in the wrapper details if provided', () => { - config.setConfig({ - rubicon: { - wrapperName: '1001_wrapperName_exp.4', - wrapperFamily: '1001_wrapperName', - rule_name: 'na-mobile' - } - }); - - rubiconAnalyticsAdapter.enableAnalytics({ - options: { - endpoint: '//localhost:9999/event', - accountId: 1001 - } - }); - - performStandardAuction(); - - expect(server.requests.length).to.equal(1); - const request = server.requests[0]; - const message = JSON.parse(request.requestBody); - expect(message.wrapper).to.deep.equal({ - name: '1001_wrapperName_exp.4', - family: '1001_wrapperName', - rule: 'na-mobile' - }); - - rubiconAnalyticsAdapter.disableAnalytics(); - }); - }); - - it('getHostNameFromReferer correctly grabs hostname from an input URL', function () { - let inputUrl = 'https://www.prebid.org/some/path?pbjs_debug=true'; - expect(getHostNameFromReferer(inputUrl)).to.equal('www.prebid.org'); - inputUrl = 'https://www.prebid.com/some/path?pbjs_debug=true'; - expect(getHostNameFromReferer(inputUrl)).to.equal('www.prebid.com'); - inputUrl = 'https://prebid.org/some/path?pbjs_debug=true'; - expect(getHostNameFromReferer(inputUrl)).to.equal('prebid.org'); - inputUrl = 'http://xn--p8j9a0d9c9a.xn--q9jyb4c/'; - expect(typeof getHostNameFromReferer(inputUrl)).to.equal('string'); - - // not non-UTF char's in query / path which break if noDecodeWholeURL not set - inputUrl = 'https://prebid.org/search_results/%95x%8Em%92%CA/?category=000'; - expect(getHostNameFromReferer(inputUrl)).to.equal('prebid.org'); - }); -}); diff --git a/test/spec/modules/rubiconAnalyticsSchema.json b/test/spec/modules/rubiconAnalyticsSchema.json deleted file mode 100644 index 2d0dca42d23..00000000000 --- a/test/spec/modules/rubiconAnalyticsSchema.json +++ /dev/null @@ -1,494 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Prebid Auctions", - "description": "A batched data object describing the lifecycle of an auction or multiple auction across a single page view.", - "type": "object", - "required": [ - "integration", - "version" - ], - "anyOf": [ - { - "required": [ - "auctions" - ] - }, - { - "required": [ - "bidsWon" - ] - }, - { - "required": [ - "billableEvents" - ] - } - ], - "properties": { - "integration": { - "type": "string", - "description": "Integration type that generated this event.", - "default": "pbjs" - }, - "version": { - "type": "string", - "description": "Version of Prebid.js responsible for the auctions contained within." - }, - "fpkvs": { - "type": "array", - "description": "List of any dynamic key value pairs set by publisher.", - "minItems": 1, - "items": { - "type": "object", - "required": [ - "key", - "value" - ], - "properties": { - "key": { - "type": "string" - }, - "value": { - "type": "string" - } - } - } - }, - "session": { - "type": "object", - "description": "The session information for a given event", - "required": [ - "id", - "start", - "expires" - ], - "properties": { - "id": { - "type": "string", - "description": "UUID of session." - }, - "start": { - "type": "integer", - "description": "Unix timestamp of time of creation for this session in milliseconds." - }, - "expires": { - "type": "integer", - "description": "Unix timestamp of the maximum allowed time in milliseconds of the session." - }, - "pvid": { - "type": "string", - "description": "id to track page view." - } - } - }, - "auctions": { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "required": [ - "adUnits", - "samplingFactor" - ], - "properties": { - "clientTimeoutMillis": { - "type": "integer", - "description": "Timeout given in client for given auction in milliseconds (if applicable)." - }, - "serverTimeoutMillis": { - "type": "integer", - "description": "Timeout configured for server adapter request in milliseconds (if applicable)." - }, - "accountId": { - "type": "number", - "description": "The account id for prebid server (if applicable)." - }, - "samplingFactor": { - "$ref": "#/definitions/samplingFactor" - }, - "adUnits": { - "type": "array", - "minItems": 1, - "items": { - "type": "object", - "description": "An array of adUnits involved in this auction.", - "required": [ - "status", - "adUnitCode", - "transactionId", - "mediaTypes", - "dimensions", - "bids" - ], - "properties": { - "status": { - "type": "string", - "description": "The status of the adUnit" - }, - "adUnitCode": { - "type": "string", - "description": "The adUnit.code identifier" - }, - "transactionId": { - "type": "string", - "description": "The UUID generated id to represent this adunit in this auction." - }, - "adSlot": { - "type": "string" - }, - "mediaTypes": { - "$ref": "#/definitions/mediaTypes" - }, - "videoAdFormat": { - "$ref": "#/definitions/videoAdFormat" - }, - "dimensions": { - "type": "array", - "description": "All valid sizes included in this auction (note: may be sizeConfig filtered).", - "minItems": 1, - "items": { - "$ref": "#/definitions/dimensions" - } - }, - "adserverTargeting": { - "$ref": "#/definitions/adserverTargeting" - }, - "bids": { - "type": "array", - "description": "An array that contains a combination of the bids from the adUnit combined with their responses.", - "minItems": 1, - "items": { - "$ref": "#/definitions/bid" - } - }, - "accountId": { - "type": "number", - "description": "The Rubicon AccountId associated with this adUnit - Removed if null" - }, - "siteId": { - "type": "number", - "description": "The Rubicon siteId associated with this adUnit - Removed if null" - }, - "zoneId": { - "type": "number", - "description": "The Rubicon zoneId associated with this adUnit - Removed if null" - }, - "gam": { - "$ref": "#/definitions/gam" - } - } - } - } - } - } - }, - "bidsWon": { - "type": "array", - "minItems": 1, - "items": { - "allOf": [ - { - "$ref": "#/definitions/bid" - }, - { - "required": [ - "transactionId", - "accountId", - "samplingFactor", - "mediaTypes", - "adUnitCode", - "bidwonStatus" - ], - "properties": { - "transactionId": { - "type": "string" - }, - "accountId": { - "type": "number" - }, - "samplingFactor": { - "$ref": "#/definitions/samplingFactor" - }, - "adUnitCode": { - "type": "string" - }, - "videoAdFormat": { - "$ref": "#/definitions/videoAdFormat" - }, - "mediaTypes": { - "$ref": "#/definitions/mediaTypes" - }, - "adserverTargeting": { - "$ref": "#/definitions/adserverTargeting" - }, - "bidwonStatus": { - "description": "Whether the bid was successfully rendered or not", - "type": "string", - "enum": [ - "success", - "error" - ] - }, - "siteId": { - "type": "number", - "description": "The Rubicon siteId associated with this adUnit - Removed if null" - }, - "zoneId": { - "type": "number", - "description": "The Rubicon zoneId associated with this adUnit - Removed if null" - } - } - } - ] - } - }, - "billableEvents":{ - "type":"array", - "minItems":1, - "items":{ - "type":"object", - "required":[ - "accountId", - "vendor", - "type", - "billingId" - ], - "properties":{ - "vendor":{ - "type":"string", - "description":"The name of the vendor who emitted the billable event" - }, - "type":{ - "type":"string", - "description":"The type of billable event", - "enum":[ - "impression", - "pageLoad", - "auction", - "request", - "general" - ] - }, - "billingId":{ - "type":"string", - "description":"A UUID which is responsible more mapping this event to" - }, - "accountId": { - "type": "number", - "description": "The account id for the rubicon publisher" - } - } - } - } - }, - "definitions": { - "gam": { - "type": "object", - "description": "The gam information for a given ad unit", - "required": [ - "adSlot" - ], - "properties": { - "adSlot": { - "type": "string" - }, - "advertiserId": { - "type": "integer" - }, - "creativeId": { - "type": "integer" - }, - "LineItemId": { - "type": "integer" - }, - "isSlotEmpty": { - "type": "boolean", - "enum": [ - true - ] - } - } - }, - "adserverTargeting": { - "type": "object", - "description": "The adserverTargeting key/value pairs", - "patternProperties": { - ".+": { - "type": "string" - } - } - }, - "samplingFactor": { - "type": "integer", - "description": "An integer value representing the factor to multiply event count by to receive unsampled count.", - "enum": [ - 1, - 10, - 20, - 40, - 100 - ] - }, - "videoAdFormat": { - "type": "string", - "description": "This value only provided for video specifies the ad format", - "enum": [ - "pre-roll", - "interstitial", - "outstream", - "mid-roll", - "post-roll", - "vertical" - ] - }, - "mediaTypes": { - "type": "array", - "uniqueItems": true, - "minItems": 1, - "items": { - "type": "string", - "enum": [ - "native", - "video", - "banner" - ] - } - }, - "dimensions": { - "type": "object", - "description": "Size object representing the dimensions of creative in pixels.", - "required": [ - "width", - "height" - ], - "properties": { - "width": { - "type": "integer", - "minimum": 1 - }, - "height": { - "type": "integer", - "minimum": 1 - } - } - }, - "bid": { - "type": "object", - "required": [ - "bidder", - "bidId", - "status", - "source" - ], - "properties": { - "bidder": { - "type": "string" - }, - "bidId": { - "type": "string", - "description": "UUID representing this individual bid request in this auction." - }, - "params": { - "description": "A copy of the bid.params from the adUnit.bids", - "anyOf": [ - { - "type": "object" - }, - { - "$ref": "#/definitions/params/rubicon" - } - ] - }, - "status": { - "type": "string", - "enum": [ - "success", - "no-bid", - "error", - "rejected-gdpr", - "rejected-ipf" - ] - }, - "error": { - "type": "object", - "additionalProperties": false, - "required": [ - "code" - ], - "properties": { - "code": { - "type": "string", - "enum": [ - "request-error", - "connect-error", - "timeout-error" - ] - }, - "description": { - "type": "string" - } - } - }, - "source": { - "type": "string", - "enum": [ - "client", - "server" - ] - }, - "clientLatencyMillis": { - "type": "integer", - "description": "Latency from auction start to bid response recieved in milliseconds." - }, - "serverLatencyMillis": { - "type": "integer", - "description": "Latency returned by prebid server (response_time_ms)." - }, - "bidResponse": { - "type": "object", - "required": [ - "mediaType", - "bidPriceUSD" - ], - "properties": { - "dimensions": { - "$ref": "#/definitions/dimensions" - }, - "mediaType": { - "type": "string", - "enum": [ - "native", - "video", - "banner" - ] - }, - "bidPriceUSD": { - "type": "number", - "description": "The bid value denoted in USD" - }, - "dealId": { - "type": "integer", - "description": "The id associated with any potential deals" - } - } - } - } - }, - "params": { - "rubicon": { - "type": "object", - "properties": { - "accountId": { - "type": "number" - }, - "siteId": { - "type": "number" - }, - "zoneId": { - "type": "number" - } - } - } - } - } -} diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index c281c195dd2..dd6f52c0646 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -4,14 +4,23 @@ import { getPriceGranularity, masSizeOrdering, resetUserSync, - hasVideoMediaType, - resetRubiConf + classifiedAsVideo, + resetRubiConf, + converter } from 'modules/rubiconBidAdapter.js'; import {parse as parseQuery} from 'querystring'; import {config} from 'src/config.js'; import * as utils from 'src/utils.js'; import {find} from 'src/polyfill.js'; import {createEidsArray} from 'modules/userId/eids.js'; +import 'modules/schain.js'; +import 'modules/consentManagement.js'; +import 'modules/consentManagementUsp.js'; +import 'modules/userId/index.js'; +import 'modules/priceFloors.js'; +import 'modules/multibid/index.js'; +import adapterManager from 'src/adapterManager.js'; +import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js'; const INTEGRATION = `pbjs_lite_v$prebid.version$`; // $prebid.version$ will be substituted in by gulp in built prebid const PBS_INTEGRATION = 'pbjs'; @@ -78,6 +87,11 @@ describe('the rubicon adapter', function () { function getBidderRequest() { return { bidderCode: 'rubicon', + ortb2: { + source: { + tid: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + } + }, auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', bidderRequestId: '178e34bad3658f', bids: [ @@ -102,13 +116,20 @@ describe('the rubicon adapter', function () { referrer: 'localhost', latLong: [40.7607823, '111.8910325'] }, + mediaTypes: { + banner: [[300, 250]] + }, adUnitCode: '/19968336/header-bid-tag-0', code: 'div-1', sizes: [[300, 250], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' + ortb2Imp: { + ext: { + tid: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + } + }, } ], start: 1472239426002, @@ -180,6 +201,7 @@ describe('the rubicon adapter', function () { * @param {boolean} [gdprApplies] */ function createGdprBidderRequest(gdprApplies) { + const bidderRequest = getBidderRequest(); if (typeof gdprApplies === 'boolean') { bidderRequest.gdprConsent = { 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', @@ -190,15 +212,16 @@ describe('the rubicon adapter', function () { 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==' }; } + return bidderRequest; } - function createUspBidderRequest() { + function addUspToBidderRequest(bidderRequest) { bidderRequest.uspConsent = '1NYN'; } function createVideoBidderRequest() { - createGdprBidderRequest(true); - createUspBidderRequest(); + const bidderRequest = createGdprBidderRequest(true); + addUspToBidderRequest(bidderRequest); let bid = bidderRequest.bids[0]; bid.mediaTypes = { @@ -247,22 +270,98 @@ describe('the rubicon adapter', function () { }], criteoId: '1111', }; - bid.userIdAsEids = createEidsArray(bid.userId); - bid.storedAuctionResponse = 11111; + bid.userIdAsEids = [ + { + 'source': 'liveintent.com', + 'uids': [ + { + 'id': '0000-1111-2222-3333', + 'atype': 3 + } + ], + 'ext': { + 'segments': [ + 'segA', + 'segB' + ] + } + }, + { + 'source': 'liveramp.com', + 'uids': [ + { + 'id': '1111-2222-3333-4444', + 'atype': 3 + } + ] + }, + { + 'source': 'adserver.org', + 'uids': [ + { + 'id': '3000', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + } + ] + }, + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '4000', + 'atype': 1 + } + ] + }, + { + 'source': 'example.com', + 'uids': [ + { + 'id': '333333', + 'ext': { + 'stype': 'ppuid' + } + } + ] + }, + { + 'source': 'id-partner.com', + 'uids': [ + { + 'id': '4444444' + } + ] + }, + { + 'source': 'criteo.com', + 'uids': [ + { + 'id': '1111', + 'atype': 1 + } + ] + } + ]; + return bidderRequest; } - function createVideoBidderRequestNoVideo() { + function removeVideoParamFromBidderRequest(bidderRequest) { let bid = bidderRequest.bids[0]; bid.mediaTypes = { video: { context: 'instream' }, }; - bid.params.video = ''; + bid.params.video = false; } function createVideoBidderRequestOutstream() { + const bidderRequest = createGdprBidderRequest(false); let bid = bidderRequest.bids[0]; + delete bid.sizes; bid.mediaTypes = { video: { context: 'outstream', @@ -280,17 +379,20 @@ describe('the rubicon adapter', function () { protocols: [1, 2, 3, 4, 5, 6] }, }; - bid.params.accountId = 14062; - bid.params.siteId = 70608; - bid.params.zoneId = 335918; - bid.params.video = { - 'language': 'en', - 'skip': 1, - 'skipafter': 15, - 'playerHeight': 320, - 'playerWidth': 640, - 'size_id': 203 - }; + bid.params = { + accountId: 14062, + siteId: 70608, + zoneId: 335918, + video: { + 'language': 'en', + 'skip': 1, + 'skipafter': 15, + 'playerHeight': 320, + 'playerWidth': 640, + 'size_id': 203 + } + } + return bidderRequest; } beforeEach(function () { @@ -300,6 +402,11 @@ describe('the rubicon adapter', function () { bidderRequest = { bidderCode: 'rubicon', auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + ortb2: { + source: { + tid: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + } + }, bidderRequestId: '178e34bad3658f', bids: [ { @@ -308,7 +415,6 @@ describe('the rubicon adapter', function () { accountId: '14062', siteId: '70608', zoneId: '335918', - pchain: 'GAM:11111-reseller1:22222', userId: '12346', keywords: ['a', 'b', 'c'], inventory: { @@ -324,13 +430,20 @@ describe('the rubicon adapter', function () { referrer: 'localhost', latLong: [40.7607823, '111.8910325'] }, + mediaTypes: { + banner: [[300, 250]] + }, adUnitCode: '/19968336/header-bid-tag-0', code: 'div-1', sizes: [[300, 250], [320, 50]], bidId: '2ffb201a808da7', bidderRequestId: '178e34bad3658f', auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', - transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b' + ortb2Imp: { + ext: { + tid: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + } + }, } ], start: 1472239426002, @@ -415,8 +528,7 @@ describe('the rubicon adapter', function () { 'rp_secure': /[01]/, 'rand': '0.1', 'tk_flint': INTEGRATION, - 'x_source.tid': 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', - 'x_source.pchain': 'GAM:11111-reseller1:22222', + 'x_source.tid': 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', 'p_screen_res': /\d+x\d+/, 'tk_user_key': '12346', 'kw': 'a,b,c', @@ -584,20 +696,11 @@ describe('the rubicon adapter', function () { expect(data['p_pos']).to.equal('atf;;btf;;'); }); - it('should not send x_source.pchain to AE if params.pchain is not specified', function () { - var noPchainRequest = utils.deepClone(bidderRequest); - delete noPchainRequest.bids[0].params.pchain; - - let [request] = spec.buildRequests(noPchainRequest.bids, noPchainRequest); - expect(request.data).to.contain('&site_id=70608&'); - expect(request.data).to.not.contain('x_source.pchain'); - }); - it('ad engine query params should be ordered correctly', function () { sandbox.stub(Math, 'random').callsFake(() => 0.1); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - const referenceOrdering = ['account_id', 'site_id', 'zone_id', 'size_id', 'alt_size_ids', 'p_pos', 'rf', 'p_geo.latitude', 'p_geo.longitude', 'kw', 'tg_v.ucat', 'tg_v.lastsearch', 'tg_v.likes', 'tg_i.rating', 'tg_i.prodtype', 'tk_flint', 'x_source.tid', 'l_pb_bid_id', 'x_source.pchain', 'p_screen_res', 'rp_secure', 'tk_user_key', 'tg_fl.eid', 'rp_maxbids', 'slots', 'rand']; + const referenceOrdering = ['account_id', 'site_id', 'zone_id', 'size_id', 'alt_size_ids', 'p_pos', 'rf', 'p_geo.latitude', 'p_geo.longitude', 'kw', 'tg_v.ucat', 'tg_v.lastsearch', 'tg_v.likes', 'tg_i.rating', 'tg_i.prodtype', 'tk_flint', 'x_source.tid', 'l_pb_bid_id', 'p_screen_res', 'rp_secure', 'tk_user_key', 'x_imp.ext.tid', 'tg_fl.eid', 'rp_maxbids', 'slots', 'rand']; request.data.split('&').forEach((item, i) => { expect(item.split('=')[0]).to.equal(referenceOrdering[i]); @@ -615,7 +718,8 @@ describe('the rubicon adapter', function () { 'rp_secure': /[01]/, 'rand': '0.1', 'tk_flint': INTEGRATION, - 'x_source.tid': 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + 'x_source.tid': 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + 'x_imp.ext.tid': 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', 'p_screen_res': /\d+x\d+/, 'tk_user_key': '12346', 'kw': 'a,b,c', @@ -666,7 +770,7 @@ describe('the rubicon adapter', function () { it('should add referer info to request data', function () { let refererInfo = { - referer: 'https://www.prebid.org', + page: 'https://www.prebid.org', reachedTop: true, numIframes: 1, stack: [ @@ -683,29 +787,20 @@ describe('the rubicon adapter', function () { expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); }); - it('page_url should use params.referrer, config.getConfig("pageUrl"), bidderRequest.refererInfo in that order', function () { + it('page_url should use params.referrer, bidderRequest.refererInfo in that order', function () { let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); expect(parseQuery(request.data).rf).to.equal('localhost'); delete bidderRequest.bids[0].params.referrer; - let refererInfo = {referer: 'https://www.prebid.org'}; + let refererInfo = {page: 'https://www.prebid.org'}; bidderRequest = Object.assign({refererInfo}, bidderRequest); [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); - let origGetConfig = config.getConfig; - sandbox.stub(config, 'getConfig').callsFake(function (key) { - if (key === 'pageUrl') { - return 'https://www.rubiconproject.com'; - } - return origGetConfig.apply(config, arguments); - }); - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(parseQuery(request.data).rf).to.equal('https://www.rubiconproject.com'); - + bidderRequest.refererInfo.page = 'http://www.prebid.org'; bidderRequest.bids[0].params.secure = true; [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(parseQuery(request.data).rf).to.equal('https://www.rubiconproject.com'); + expect(parseQuery(request.data).rf).to.equal('https://www.prebid.org'); }); it('should use rubicon sizes if present (including non-mappable sizes)', function () { @@ -749,7 +844,7 @@ describe('the rubicon adapter', function () { describe('GDPR consent config', function () { it('should send "gdpr" and "gdpr_consent", when gdprConsent defines consentString and gdprApplies', function () { - createGdprBidderRequest(true); + const bidderRequest = createGdprBidderRequest(true); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); let data = parseQuery(request.data); @@ -758,7 +853,7 @@ describe('the rubicon adapter', function () { }); it('should send only "gdpr_consent", when gdprConsent defines only consentString', function () { - createGdprBidderRequest(); + const bidderRequest = createGdprBidderRequest(); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); let data = parseQuery(request.data); @@ -775,12 +870,12 @@ describe('the rubicon adapter', function () { }); it('should set "gdpr" value as 1 or 0, using "gdprApplies" value of either true/false', function () { - createGdprBidderRequest(true); + let bidderRequest = createGdprBidderRequest(true); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); let data = parseQuery(request.data); expect(data['gdpr']).to.equal('1'); - createGdprBidderRequest(false); + bidderRequest = createGdprBidderRequest(false); [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); data = parseQuery(request.data); expect(data['gdpr']).to.equal('0'); @@ -789,7 +884,7 @@ describe('the rubicon adapter', function () { describe('USP Consent', function () { it('should send us_privacy if bidderRequest has a value for uspConsent', function () { - createUspBidderRequest(); + addUspToBidderRequest(bidderRequest); let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); let data = parseQuery(request.data); @@ -804,6 +899,29 @@ describe('the rubicon adapter', function () { }); }); + describe('GPP Consent', function () { + it('should send gpp information if bidderRequest has a value for gppConsent', function () { + bidderRequest.gppConsent = { + gppString: 'consent', + applicableSections: 2 + }; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let data = parseQuery(request.data); + delete bidderRequest.gppConsent; + + expect(data['gpp']).to.equal('consent'); + expect(data['gpp_sid']).to.equal('2'); + }); + + it('should not send gpp information if bidderRequest does not have a value for gppConsent', function () { + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let data = parseQuery(request.data); + + expect(data['gpp']).to.equal(undefined); + expect(data['gpp_sid']).to.equal(undefined); + }); + }); + describe('first party data', function () { it('should not have any tg_v or tg_i params if all are undefined', function () { let params = { @@ -927,15 +1045,10 @@ describe('the rubicon adapter', function () { } }; - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2: { - site, - user - } - }; - return utils.deepAccess(config, key); - }); + const ortb2 = { + site, + user + } const expectedQuery = { 'kw': 'a,b,c,d', @@ -953,7 +1066,7 @@ describe('the rubicon adapter', function () { }; // get the built request - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let [request] = spec.buildRequests(bidderRequest.bids.map((b) => ({...b, ortb2})), bidderRequest); let data = parseQuery(request.data); // make sure that tg_v, tg_i, and kw values are correct @@ -980,7 +1093,7 @@ describe('the rubicon adapter', function () { 'rp_secure': /[01]/, 'rand': '0.1', 'tk_flint': INTEGRATION, - 'x_source.tid': 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + 'x_source.tid': 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', 'p_screen_res': /\d+x\d+/, 'tk_user_key': '12346', 'kw': 'a,b,c', @@ -1116,6 +1229,30 @@ describe('the rubicon adapter', function () { }); }); + it('should still use single request if other rubicon configs are set after', function () { + // set single request to true + config.setConfig({ rubicon: { singleRequest: true } }); + + // execute some other rubicon setConfig + config.setConfig({ rubicon: { netRevenue: true } }); + + const bidCopy = utils.deepClone(bidderRequest.bids[0]); + bidderRequest.bids.push(bidCopy); + bidderRequest.bids.push(bidCopy); + bidderRequest.bids.push(bidCopy); + + let serverRequests = spec.buildRequests(bidderRequest.bids, bidderRequest); + + // should have 1 request only + expect(serverRequests).that.is.an('array').of.length(1); + + // get the built query + let data = parseQuery(serverRequests[0].data); + + // num slots should be 4 + expect(data.slots).to.equal('4'); + }); + it('should not group bid requests if singleRequest does not equal true', function () { config.setConfig({rubicon: {singleRequest: false}}); @@ -1185,7 +1322,20 @@ describe('the rubicon adapter', function () { clonedBid.userId = { tdid: 'abcd-efgh-ijkl-mnop-1234' }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'adserver.org', + 'uids': [ + { + 'id': 'abcd-efgh-ijkl-mnop-1234', + 'atype': 1, + 'ext': { + 'rtiPartner': 'TDID' + } + } + ] + } + ]; let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1202,7 +1352,23 @@ describe('the rubicon adapter', function () { segments: ['segA', 'segB'] } }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'liveintent.com', + 'uids': [ + { + 'id': '0000-1111-2222-3333', + 'atype': 3 + } + ], + 'ext': { + 'segments': [ + 'segA', + 'segB' + ] + } + } + ]; let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1219,7 +1385,23 @@ describe('the rubicon adapter', function () { segments: ['segD', 'segE'] } }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'liveintent.com', + 'uids': [ + { + 'id': '1111-2222-3333-4444', + 'atype': 3 + } + ], + 'ext': { + 'segments': [ + 'segD', + 'segE' + ] + } + } + ] let [request] = spec.buildRequests([clonedBid], bidderRequest); const unescapedData = unescape(request.data); @@ -1234,7 +1416,17 @@ describe('the rubicon adapter', function () { clonedBid.userId = { idl_env: '1111-2222-3333-4444' }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'liveramp.com', + 'uids': [ + { + 'id': '1111-2222-3333-4444', + 'atype': 3 + } + ] + } + ] let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1248,7 +1440,17 @@ describe('the rubicon adapter', function () { clonedBid.userId = { pubcid: '1111' }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'pubcid.org', + 'uids': [ + { + 'id': '1111', + 'atype': 1 + } + ] + } + ] let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1262,7 +1464,17 @@ describe('the rubicon adapter', function () { clonedBid.userId = { criteoId: '1111' }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'criteo.com', + 'uids': [ + { + 'id': '1111', + 'atype': 1 + } + ] + } + ] let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1289,7 +1501,27 @@ describe('the rubicon adapter', function () { }] }] }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'example.com', + 'uids': [ + { + 'id': '11111', + 'ext': { + 'stype': 'ppuid' + } + } + ] + }, + { + 'source': 'id-partner.com', + 'uids': [ + { + 'id': '222222' + } + ] + } + ]; let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1308,7 +1540,20 @@ describe('the rubicon adapter', function () { } } }; - clonedBid.userIdAsEids = createEidsArray(clonedBid.userId); + clonedBid.userIdAsEids = [ + { + 'source': 'id5-sync.com', + 'uids': [ + { + 'id': '11111', + 'atype': 1, + 'ext': { + 'linkType': '22222' + } + } + ] + } + ]; let [request] = spec.buildRequests([clonedBid], bidderRequest); let data = parseQuery(request.data); @@ -1332,6 +1577,22 @@ describe('the rubicon adapter', function () { expect(data['eid_catchall']).to.equal('11111^2'); }); + + it('should send rubiconproject special case', function () { + const clonedBid = utils.deepClone(bidderRequest.bids[0]); + // Hardcoding userIdAsEids since createEidsArray returns empty array if source not found in eids.js + clonedBid.userIdAsEids = [{ + source: 'rubiconproject.com', + uids: [{ + id: 'some-cool-id', + atype: 3 + }] + }] + let [request] = spec.buildRequests([clonedBid], bidderRequest); + let data = parseQuery(request.data); + + expect(data['eid_rubiconproject.com']).to.equal('some-cool-id'); + }); }); describe('Config user.id support', function () { @@ -1549,654 +1810,711 @@ describe('the rubicon adapter', function () { }); }); - describe('for video requests', function () { - it('should make a well-formed video request', function () { - createVideoBidderRequest(); + if (FEATURES.VIDEO) { + describe('for video requests', function () { + it('should make a well-formed video request', function () { + const bidderRequest = createVideoBidderRequest(); + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + let [request] = spec.buildRequests(bidderRequest.bids, syncAddFPDToBidderRequest(bidderRequest)); + let post = request.data; + + expect(post).to.have.property('imp'); + // .with.length.of(1); + let imp = post.imp[0]; + expect(imp.id).to.equal(bidderRequest.bids[0].adUnitCode); + expect(imp.exp).to.equal(undefined); // now undefined + expect(imp.video.w).to.equal(640); + expect(imp.video.h).to.equal(480); + expect(imp.video.pos).to.equal(1); + expect(imp.video.minduration).to.equal(15); + expect(imp.video.maxduration).to.equal(30); + expect(imp.video.startdelay).to.equal(0); + expect(imp.video.skip).to.equal(1); + expect(imp.video.skipafter).to.equal(15); + expect(imp.ext.prebid.bidder.rubicon.video.playerWidth).to.equal(640); + expect(imp.ext.prebid.bidder.rubicon.video.playerHeight).to.equal(480); + expect(imp.ext.prebid.bidder.rubicon.video.size_id).to.equal(201); + expect(imp.ext.prebid.bidder.rubicon.video.language).to.equal('en'); + // Also want it to be in post.site.content.language + expect(imp.ext.prebid.bidder.rubicon.video.skip).to.equal(1); + expect(imp.ext.prebid.bidder.rubicon.video.skipafter).to.equal(15); + expect(post.ext.prebid.auctiontimestamp).to.equal(1472239426000); + // should contain version + expect(post.ext.prebid.channel).to.deep.equal({name: 'pbjs', version: $$PREBID_GLOBAL$$.version}); + expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); + // EIDs should exist + expect(post.user.ext).to.have.property('eids').that.is.an('array'); + // LiveIntent should exist + expect(post.user.ext.eids[0].source).to.equal('liveintent.com'); + expect(post.user.ext.eids[0].uids[0].id).to.equal('0000-1111-2222-3333'); + expect(post.user.ext.eids[0].uids[0].atype).to.equal(3); + expect(post.user.ext.eids[0]).to.have.property('ext').that.is.an('object'); + expect(post.user.ext.eids[0].ext).to.have.property('segments').that.is.an('array'); + expect(post.user.ext.eids[0].ext.segments[0]).to.equal('segA'); + expect(post.user.ext.eids[0].ext.segments[1]).to.equal('segB'); + // LiveRamp should exist + expect(post.user.ext.eids[1].source).to.equal('liveramp.com'); + expect(post.user.ext.eids[1].uids[0].id).to.equal('1111-2222-3333-4444'); + expect(post.user.ext.eids[1].uids[0].atype).to.equal(3); + // UnifiedId should exist + expect(post.user.ext.eids[2].source).to.equal('adserver.org'); + expect(post.user.ext.eids[2].uids[0].atype).to.equal(1); + expect(post.user.ext.eids[2].uids[0].id).to.equal('3000'); + // PubCommonId should exist + expect(post.user.ext.eids[3].source).to.equal('pubcid.org'); + expect(post.user.ext.eids[3].uids[0].atype).to.equal(1); + expect(post.user.ext.eids[3].uids[0].id).to.equal('4000'); + // example should exist + expect(post.user.ext.eids[4].source).to.equal('example.com'); + expect(post.user.ext.eids[4].uids[0].id).to.equal('333333'); + // id-partner.com + expect(post.user.ext.eids[5].source).to.equal('id-partner.com'); + expect(post.user.ext.eids[5].uids[0].id).to.equal('4444444'); + // CriteoId should exist + expect(post.user.ext.eids[6].source).to.equal('criteo.com'); + expect(post.user.ext.eids[6].uids[0].id).to.equal('1111'); + expect(post.user.ext.eids[6].uids[0].atype).to.equal(1); + + expect(post.regs.ext.gdpr).to.equal(1); + expect(post.regs.ext.us_privacy).to.equal('1NYN'); + expect(post).to.have.property('ext').that.is.an('object'); + expect(post.ext.prebid.targeting.includewinners).to.equal(true); + expect(post.ext.prebid).to.have.property('cache').that.is.an('object'); + expect(post.ext.prebid.cache).to.have.property('vastxml').that.is.an('object'); + expect(post.ext.prebid.cache.vastxml).to.have.property('returnCreative').that.is.an('boolean'); + expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false); + expect(post.ext.prebid.bidders.rubicon.integration).to.equal(PBS_INTEGRATION); + }); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + describe('ortb2imp sent to video bids', function () { + beforeEach(function () { + // initialize + if (bidderRequest.bids[0].hasOwnProperty('ortb2Imp')) { + delete bidderRequest.bids[0].ortb2Imp; + } + }); - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let post = request.data; - - expect(post).to.have.property('imp'); - // .with.length.of(1); - let imp = post.imp[0]; - expect(imp.id).to.equal(bidderRequest.bids[0].adUnitCode); - expect(imp.exp).to.equal(undefined); // now undefined - expect(imp.video.w).to.equal(640); - expect(imp.video.h).to.equal(480); - expect(imp.video.pos).to.equal(1); - expect(imp.video.context).to.equal('instream'); - expect(imp.video.minduration).to.equal(15); - expect(imp.video.maxduration).to.equal(30); - expect(imp.video.startdelay).to.equal(0); - expect(imp.video.skip).to.equal(1); - expect(imp.video.skipafter).to.equal(15); - expect(imp.ext.rubicon.video.playerWidth).to.equal(640); - expect(imp.ext.rubicon.video.playerHeight).to.equal(480); - expect(imp.ext.rubicon.video.size_id).to.equal(201); - expect(imp.ext.rubicon.video.language).to.equal('en'); - // Also want it to be in post.site.content.language - expect(post.site.content.language).to.equal('en'); - expect(imp.ext.rubicon.video.skip).to.equal(1); - expect(imp.ext.rubicon.video.skipafter).to.equal(15); - expect(imp.ext.prebid.auctiontimestamp).to.equal(1472239426000); - // should contain version - expect(post.ext.prebid.channel).to.deep.equal({name: 'pbjs', version: 'v$prebid.version$'}); - expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); - // EIDs should exist - expect(post.user.ext).to.have.property('eids').that.is.an('array'); - // LiveIntent should exist - expect(post.user.ext.eids[0].source).to.equal('liveintent.com'); - expect(post.user.ext.eids[0].uids[0].id).to.equal('0000-1111-2222-3333'); - expect(post.user.ext.eids[0].uids[0].atype).to.equal(3); - expect(post.user.ext.eids[0]).to.have.property('ext').that.is.an('object'); - expect(post.user.ext.eids[0].ext).to.have.property('segments').that.is.an('array'); - expect(post.user.ext.eids[0].ext.segments[0]).to.equal('segA'); - expect(post.user.ext.eids[0].ext.segments[1]).to.equal('segB'); - // LiveRamp should exist - expect(post.user.ext.eids[1].source).to.equal('liveramp.com'); - expect(post.user.ext.eids[1].uids[0].id).to.equal('1111-2222-3333-4444'); - expect(post.user.ext.eids[1].uids[0].atype).to.equal(3); - // UnifiedId should exist - expect(post.user.ext.eids[2].source).to.equal('adserver.org'); - expect(post.user.ext.eids[2].uids[0].atype).to.equal(1); - expect(post.user.ext.eids[2].uids[0].id).to.equal('3000'); - // PubCommonId should exist - expect(post.user.ext.eids[3].source).to.equal('pubcid.org'); - expect(post.user.ext.eids[3].uids[0].atype).to.equal(1); - expect(post.user.ext.eids[3].uids[0].id).to.equal('4000'); - // example should exist - expect(post.user.ext.eids[4].source).to.equal('example.com'); - expect(post.user.ext.eids[4].uids[0].id).to.equal('333333'); - // id-partner.com - expect(post.user.ext.eids[5].source).to.equal('id-partner.com'); - expect(post.user.ext.eids[5].uids[0].id).to.equal('4444444'); - // CriteoId should exist - expect(post.user.ext.eids[6].source).to.equal('criteo.com'); - expect(post.user.ext.eids[6].uids[0].id).to.equal('1111'); - expect(post.user.ext.eids[6].uids[0].atype).to.equal(1); - - expect(post.regs.ext.gdpr).to.equal(1); - expect(post.regs.ext.us_privacy).to.equal('1NYN'); - expect(post).to.have.property('ext').that.is.an('object'); - expect(post.ext.prebid.targeting.includewinners).to.equal(true); - expect(post.ext.prebid).to.have.property('cache').that.is.an('object'); - expect(post.ext.prebid.cache).to.have.property('vastxml').that.is.an('object'); - expect(post.ext.prebid.cache.vastxml).to.have.property('returnCreative').that.is.an('boolean'); - expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false); - expect(post.ext.prebid.bidders.rubicon.integration).to.equal(PBS_INTEGRATION); - }); + it('should add ortb values to video requests', function () { + const bidderRequest = createVideoBidderRequest(); - it('should correctly set bidfloor on imp when getfloor in scope', function () { - createVideoBidderRequest(); - // default getFloor response is empty object so should not break and not send hard_floor - bidderRequest.bids[0].getFloor = () => getFloorResponse; - sinon.spy(bidderRequest.bids[0], 'getFloor'); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + bidderRequest.bids[0].ortb2Imp = { + ext: { + gpid: '/test/gpid', + data: { + pbadslot: '/test/pbadslot' + }, + prebid: { + storedauctionresponse: { + id: 'sample_video_response' + } + } + } + } - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let post = request.data; - // make sure banner bid called with right stuff - expect( - bidderRequest.bids[0].getFloor.calledWith({ - currency: 'USD', - mediaType: 'video', - size: [640, 480] - }) - ).to.be.true; + expect(post).to.have.property('imp'); + // .with.length.of(1); + let imp = post.imp[0]; + expect(imp.ext.gpid).to.equal('/test/gpid'); + expect(imp.ext.data.pbadslot).to.equal('/test/pbadslot'); + expect(imp.ext.prebid.storedauctionresponse.id).to.equal('sample_video_response'); + }); + }); - // not an object should work and not send - expect(request.data.imp[0].bidfloor).to.be.undefined; + it('should correctly set bidfloor on imp when getfloor in scope', function () { + const bidderRequest = createVideoBidderRequest(); + // default getFloor response is empty object so should not break and not send hard_floor + bidderRequest.bids[0].getFloor = () => getFloorResponse; + sinon.spy(bidderRequest.bids[0], 'getFloor'); - // make it respond with a non USD floor should not send it - getFloorResponse = {currency: 'EUR', floor: 1.0}; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.be.undefined; + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - // make it respond with a non USD floor should not send it - getFloorResponse = {currency: 'EUR'}; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.be.undefined; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - // make it respond with USD floor and string floor - getFloorResponse = {currency: 'USD', floor: '1.23'}; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.equal(1.23); + // make sure banner bid called with right stuff + expect( + bidderRequest.bids[0].getFloor.calledWith({ + currency: 'USD', + mediaType: '*', + size: '*' + }) + ).to.be.true; - // make it respond with USD floor and num floor - getFloorResponse = {currency: 'USD', floor: 1.23}; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.equal(1.23); - }); + // not an object should work and not send + expect(request.data.imp[0].bidfloor).to.be.undefined; - it('should continue with auction and log error if getFloor throws one', function () { - createVideoBidderRequest(); - // default getFloor response is empty object so should not break and not send hard_floor - bidderRequest.bids[0].getFloor = () => { - throw new Error('An exception!'); - }; - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + // make it respond with a non USD floor should not send it + getFloorResponse = {currency: 'EUR', floor: 1.0}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.be.undefined; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + // make it respond with a non USD floor should not send it + getFloorResponse = {currency: 'EUR'}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.be.undefined; - // log error called - expect(logErrorSpy.calledOnce).to.equal(true); + // make it respond with USD floor and string floor + getFloorResponse = {currency: 'USD', floor: '1.23'}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(1.23); - // should have an imp - expect(request.data.imp).to.exist.and.to.be.a('array'); - expect(request.data.imp).to.have.lengthOf(1); + // make it respond with USD floor and num floor + getFloorResponse = {currency: 'USD', floor: 1.23}; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(1.23); + }); - // should be NO bidFloor - expect(request.data.imp[0].bidfloor).to.be.undefined; - }); + it('should continue with auction if getFloor throws error', function () { + const bidderRequest = createVideoBidderRequest(); + // default getFloor response is empty object so should not break and not send hard_floor + bidderRequest.bids[0].getFloor = () => { + throw new Error('An exception!'); + }; + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - it('should add alias name to PBS Request', function () { - createVideoBidderRequest(); + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - bidderRequest.bidderCode = 'superRubicon'; - bidderRequest.bids[0].bidder = 'superRubicon'; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + // should have an imp + expect(request.data.imp).to.exist.and.to.be.a('array'); + expect(request.data.imp).to.have.lengthOf(1); - // should have the aliases object sent to PBS - expect(request.data.ext.prebid).to.haveOwnProperty('aliases'); - expect(request.data.ext.prebid.aliases).to.deep.equal({superRubicon: 'rubicon'}); + // should be NO bidFloor + expect(request.data.imp[0].bidfloor).to.be.undefined; + expect(request.data.imp[0].bidfloorcur).to.be.undefined; + }); - // should have the imp ext bidder params be under the alias name not rubicon superRubicon - expect(request.data.imp[0].ext).to.have.property('superRubicon').that.is.an('object'); - expect(request.data.imp[0].ext).to.not.haveOwnProperty('rubicon'); - }); + it('should add alias name to PBS Request', function () { + const bidderRequest = createVideoBidderRequest(); + adapterManager.aliasRegistry['superRubicon'] = 'rubicon'; + bidderRequest.bidderCode = 'superRubicon'; + bidderRequest.bids[0].bidder = 'superRubicon'; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - it('should add multibid configuration to PBS Request', function () { - createVideoBidderRequest(); + // should have the aliases object sent to PBS + expect(request.data.ext.prebid).to.haveOwnProperty('aliases'); + expect(request.data.ext.prebid.aliases).to.deep.equal({superRubicon: 'rubicon'}); - const multibid = [{ - bidder: 'bidderA', - maxBids: 2 - }, { - bidder: 'bidderB', - maxBids: 2 - }]; - const expected = [{ - bidder: 'bidderA', - maxbids: 2 - }, { - bidder: 'bidderB', - maxbids: 2 - }]; + // should have the imp ext bidder params be under the alias name not rubicon superRubicon + expect(request.data.imp[0].ext.prebid.bidder).to.have.property('superRubicon').that.is.an('object'); + expect(request.data.imp[0].ext.prebid.bidder).to.not.haveOwnProperty('rubicon'); + }); - config.setConfig({multibid: multibid}); + it('should add floors flag correctly to PBS Request', function () { + const bidderRequest = createVideoBidderRequest(); + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + // should not pass if undefined + expect(request.data.ext.prebid.floors).to.be.undefined; - // should have the aliases object sent to PBS - expect(request.data.ext.prebid).to.haveOwnProperty('multibid'); - expect(request.data.ext.prebid.multibid).to.deep.equal(expected); - }); + // should pass it as false + bidderRequest.bids[0].floorData = { + skipped: false, + location: 'fetch', + } + let [newRequest] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(newRequest.data.ext.prebid.floors).to.deep.equal({ enabled: false }); + }); - it('should pass client analytics to PBS endpoint if all modules included', function () { - createVideoBidderRequest(); - $$PREBID_GLOBAL$$.installedModules = []; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let payload = request.data; + it('should add multibid configuration to PBS Request', function () { + const bidderRequest = createVideoBidderRequest(); + + const multibid = [{ + bidder: 'bidderA', + maxBids: 2 + }, { + bidder: 'bidderB', + maxBids: 2 + }]; + const expected = [{ + bidder: 'bidderA', + maxbids: 2 + }, { + bidder: 'bidderB', + maxbids: 2 + }]; + + config.setConfig({multibid: multibid}); - expect(payload.ext.prebid.analytics).to.not.be.undefined; - expect(payload.ext.prebid.analytics).to.deep.equal({'rubicon': {'client-analytics': true}}); - }); + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - it('should pass client analytics to PBS endpoint if rubicon analytics adapter is included', function () { - createVideoBidderRequest(); - $$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter', 'rubiconAnalyticsAdapter']; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let payload = request.data; + // should have the aliases object sent to PBS + expect(request.data.ext.prebid).to.haveOwnProperty('multibid'); + expect(request.data.ext.prebid.multibid).to.deep.equal(expected); + }); - expect(payload.ext.prebid.analytics).to.not.be.undefined; - expect(payload.ext.prebid.analytics).to.deep.equal({'rubicon': {'client-analytics': true}}); - }); + it('should pass client analytics to PBS endpoint if all modules included', function () { + const bidderRequest = createVideoBidderRequest(); + $$PREBID_GLOBAL$$.installedModules = []; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let payload = request.data; - it('should not pass client analytics to PBS endpoint if rubicon analytics adapter is not included', function () { - createVideoBidderRequest(); - $$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter']; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let payload = request.data; + expect(payload.ext.prebid.analytics).to.not.be.undefined; + expect(payload.ext.prebid.analytics).to.deep.equal({'rubicon': {'client-analytics': true}}); + }); - expect(payload.ext.prebid.analytics).to.be.undefined; - }); + it('should pass client analytics to PBS endpoint if rubicon analytics adapter is included', function () { + const bidderRequest = createVideoBidderRequest(); + $$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter', 'rubiconAnalyticsAdapter']; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let payload = request.data; - it('should send video exp param correctly when set', function () { - createVideoBidderRequest(); - config.setConfig({s2sConfig: {defaultTtl: 600}}); - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let post = request.data; + expect(payload.ext.prebid.analytics).to.not.be.undefined; + expect(payload.ext.prebid.analytics).to.deep.equal({'rubicon': {'client-analytics': true}}); + }); - // should exp set to the right value according to config - let imp = post.imp[0]; - expect(imp.exp).to.equal(600); - }); + it('should not pass client analytics to PBS endpoint if rubicon analytics adapter is not included', function () { + const bidderRequest = createVideoBidderRequest(); + $$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter']; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let payload = request.data; - it('should not send video exp at all if not set in s2sConfig config', function () { - createVideoBidderRequest(); - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let post = request.data; + expect(payload.ext.prebid.analytics).to.be.undefined; + }); - // should exp set to the right value according to config - let imp = post.imp[0]; - // bidderFactory stringifies request body before sending so removes undefined attributes: - expect(imp.exp).to.equal(undefined); - }); + it('should send video exp param correctly when set', function () { + const bidderRequest = createVideoBidderRequest(); + config.setConfig({s2sConfig: {defaultTtl: 600}}); + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let post = request.data; - it('should send tmax as the bidderRequest timeout value', function () { - createVideoBidderRequest(); - bidderRequest.timeout = 3333; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let post = request.data; - expect(post.tmax).to.equal(3333); - }); + // should exp set to the right value according to config + let imp = post.imp[0]; + expect(imp.exp).to.equal(600); + }); - it('should send correct bidfloor to PBS', function () { - createVideoBidderRequest(); + it('should not send video exp at all if not set in s2sConfig config', function () { + const bidderRequest = createVideoBidderRequest(); + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let post = request.data; - bidderRequest.bids[0].params.floor = 0.1; - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.equal(0.1); + // should exp set to the right value according to config + let imp = post.imp[0]; + // bidderFactory stringifies request body before sending so removes undefined attributes: + expect(imp.exp).to.equal(undefined); + }); - bidderRequest.bids[0].params.floor = 5.5; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.equal(5.5); + it('should send tmax as the bidderRequest timeout value', function () { + const bidderRequest = createVideoBidderRequest(); + bidderRequest.timeout = 3333; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + let post = request.data; + expect(post.tmax).to.equal(3333); + }); - bidderRequest.bids[0].params.floor = '1.7'; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.equal(1.7); + it('should send correct bidfloor to PBS', function () { + const bidderRequest = createVideoBidderRequest(); - bidderRequest.bids[0].params.floor = 0; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].bidfloor).to.equal(0); + bidderRequest.bids[0].params.floor = 0.1; + let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(0.1); - bidderRequest.bids[0].params.floor = undefined; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); + bidderRequest.bids[0].params.floor = 5.5; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(5.5); - bidderRequest.bids[0].params.floor = null; - [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); - }); + bidderRequest.bids[0].params.floor = '1.7'; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(1.7); - it('should send request with proper ad position', function () { - createVideoBidderRequest(); - let positionBidderRequest = utils.deepClone(bidderRequest); - positionBidderRequest.bids[0].mediaTypes.video.pos = 1; - let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(1); - - positionBidderRequest = utils.deepClone(bidderRequest); - positionBidderRequest.bids[0].params.position = undefined; - positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; - [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(undefined); - - positionBidderRequest = utils.deepClone(bidderRequest); - positionBidderRequest.bids[0].params.position = 'atf' - positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; - [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(1); - - positionBidderRequest = utils.deepClone(bidderRequest); - positionBidderRequest.bids[0].params.position = 'btf'; - positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; - [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(3); - - positionBidderRequest = utils.deepClone(bidderRequest); - positionBidderRequest.bids[0].params.position = 'foobar'; - positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; - [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); - expect(request.data.imp[0].video.pos).to.equal(undefined); - }); + bidderRequest.bids[0].params.floor = 0; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].bidfloor).to.equal(0); - it('should properly enforce video.context to be either instream or outstream', function () { - let bid = bidderRequest.bids[0]; - bid.mediaTypes = { - video: { - context: 'instream', - mimes: ['video/mp4', 'video/x-ms-wmv'], - protocols: [2, 5], - maxduration: 30, - linearity: 1, - api: [2] - } - } - bid.params.video = {}; + bidderRequest.bids[0].params.floor = undefined; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + bidderRequest.bids[0].params.floor = null; + [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0]).to.not.haveOwnProperty('bidfloor'); + }); - const bidRequestCopy = utils.deepClone(bidderRequest.bids[0]); - expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(true); + it('should send request with proper ad position', function () { + const bidderRequest = createVideoBidderRequest(); + let positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest.bids[0].mediaTypes.video.pos = 1; + let [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(1); + + positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest.bids[0].params.position = undefined; + positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; + [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(undefined); + + positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest.bids[0].params.position = 'atf' + positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; + [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(1); + + positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest.bids[0].params.position = 'btf'; + positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; + [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(3); + + positionBidderRequest = utils.deepClone(bidderRequest); + positionBidderRequest.bids[0].params.position = 'foobar'; + positionBidderRequest.bids[0].mediaTypes.video.pos = undefined; + [request] = spec.buildRequests(positionBidderRequest.bids, positionBidderRequest); + expect(request.data.imp[0].video.pos).to.equal(undefined); + }); - // change context to outstream, still true - bidRequestCopy.mediaTypes.video.context = 'outstream'; - expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(true); + it('should properly enforce video.context to be either instream or outstream', function () { + let bid = bidderRequest.bids[0]; + bid.mediaTypes = { + video: { + context: 'instream', + mimes: ['video/mp4', 'video/x-ms-wmv'], + protocols: [2, 5], + maxduration: 30, + linearity: 1, + api: [2] + } + } + bid.params.video = {}; - // change context to random, false now - bidRequestCopy.mediaTypes.video.context = 'random'; - expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(false); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - // change context to undefined, still false - bidRequestCopy.mediaTypes.video.context = undefined; - expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(false); + const bidRequestCopy = utils.deepClone(bidderRequest.bids[0]); + expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(true); - // remove context, still false - delete bidRequestCopy.mediaTypes.video.context; - expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(false); - }); + // change context to outstream, still true + bidRequestCopy.mediaTypes.video.context = 'outstream'; + expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(true); - it('should enforce the new required mediaTypes.video params', function () { - createVideoBidderRequest(); - - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); - - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(true); - - // change mimes to a non array, no good - createVideoBidderRequest(); - bidderRequest.bids[0].mediaTypes.video.mimes = 'video/mp4'; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // delete mimes, no good - createVideoBidderRequest(); - delete bidderRequest.bids[0].mediaTypes.video.mimes; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // change protocols to an int not array of ints, no good - createVideoBidderRequest(); - bidderRequest.bids[0].mediaTypes.video.protocols = 1; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // delete protocols, no good - createVideoBidderRequest(); - delete bidderRequest.bids[0].mediaTypes.video.protocols; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // change linearity to an string, no good - createVideoBidderRequest(); - bidderRequest.bids[0].mediaTypes.video.linearity = 'string'; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // delete linearity, no good - createVideoBidderRequest(); - delete bidderRequest.bids[0].mediaTypes.video.linearity; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // change api to an string, no good - createVideoBidderRequest(); - bidderRequest.bids[0].mediaTypes.video.api = 'string'; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - - // delete api, no good - createVideoBidderRequest(); - delete bidderRequest.bids[0].mediaTypes.video.api; - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); - }); + // change context to random, false now + bidRequestCopy.mediaTypes.video.context = 'random'; + expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(false); - it('bid request is valid when video context is outstream', function () { - createVideoBidderRequestOutstream(); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + // change context to undefined, still false + bidRequestCopy.mediaTypes.video.context = undefined; + expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(false); - const bidRequestCopy = utils.deepClone(bidderRequest); + // remove context, still false + delete bidRequestCopy.mediaTypes.video.context; + expect(spec.isBidRequestValid(bidRequestCopy)).to.equal(false); + }); - let [request] = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy); - expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(true); - expect(request.data.imp[0].ext.rubicon.video.size_id).to.equal(203); - }); + it('should enforce the new required mediaTypes.video params', function () { + let bidderRequest = createVideoBidderRequest(); + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(true); + + // change mimes to a non array, no good + bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].mediaTypes.video.mimes = 'video/mp4'; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // delete mimes, no good + bidderRequest = createVideoBidderRequest(); + delete bidderRequest.bids[0].mediaTypes.video.mimes; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // change protocols to an int not array of ints, no good + bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].mediaTypes.video.protocols = 1; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // delete protocols, no good + bidderRequest = createVideoBidderRequest(); + delete bidderRequest.bids[0].mediaTypes.video.protocols; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // change linearity to an string, no good + bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].mediaTypes.video.linearity = 'string'; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // delete linearity, no good + bidderRequest = createVideoBidderRequest(); + delete bidderRequest.bids[0].mediaTypes.video.linearity; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // change api to an string, no good + bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].mediaTypes.video.api = 'string'; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + + // delete api, no good + bidderRequest = createVideoBidderRequest(); + delete bidderRequest.bids[0].mediaTypes.video.api; + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(false); + }); - it('should send banner request when outstream or instream video included but no rubicon video obect is present', function () { - // add banner and video mediaTypes - bidderRequest.mediaTypes = { - banner: { - sizes: [[300, 250]] - }, - video: { - context: 'outstream' - } - }; - // no video object in rubicon params, so we should see one call made for banner + it('bid request is valid when video context is outstream', function () { + const bidderRequest = createVideoBidderRequestOutstream(); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + const bidRequestCopy = utils.deepClone(bidderRequest); - let requests = spec.buildRequests(bidderRequest.bids, bidderRequest); + let [request] = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy); + expect(spec.isBidRequestValid(bidderRequest.bids[0])).to.equal(true); + expect(request.data.imp[0].ext.prebid.bidder.rubicon.video.size_id).to.equal(203); + }); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + it('should send banner request when outstream or instream video included but no rubicon video obect is present', function () { + // add banner and video mediaTypes + bidderRequest.mediaTypes = { + banner: { + sizes: [[300, 250]] + }, + video: { + context: 'outstream' + } + }; + // no video object in rubicon params, so we should see one call made for banner - bidderRequest.mediaTypes.video.context = 'instream'; + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - requests = spec.buildRequests(bidderRequest.bids, bidderRequest); + let requests = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); - }); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); - it('should send request as banner when invalid video bid in multiple mediaType bidRequest', function () { - createVideoBidderRequestNoVideo(); + bidderRequest.mediaTypes.video.context = 'instream'; - let bid = bidderRequest.bids[0]; - bid.mediaTypes.banner = { - sizes: [[300, 250]] - }; + requests = spec.buildRequests(bidderRequest.bids, bidderRequest); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + }); - const bidRequestCopy = utils.deepClone(bidderRequest); + it('should send request as banner when invalid video bid in multiple mediaType bidRequest', function () { + removeVideoParamFromBidderRequest(bidderRequest); - let requests = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy); - expect(requests.length).to.equal(1); - expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); - }); + let bid = bidderRequest.bids[0]; + bid.mediaTypes.banner = { + sizes: [[300, 250]] + }; - it('should include coppa flag in video bid request', () => { - createVideoBidderRequest(); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + const bidRequestCopy = utils.deepClone(bidderRequest); - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - 'coppa': true - }; - return config[key]; + let requests = spec.buildRequests(bidRequestCopy.bids, bidRequestCopy); + expect(requests.length).to.equal(1); + expect(requests[0].url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); }); - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.regs.coppa).to.equal(1); - }); - - it('should include first party data', () => { - createVideoBidderRequest(); + it('should include coppa flag in video bid request', () => { + const bidderRequest = createVideoBidderRequest(); - const site = { - ext: { - data: { - page: 'home' - } - }, - content: { - data: [{foo: 'bar'}] - }, - keywords: 'e,f', - rating: '4-star', - data: [{foo: 'bar'}] - }; - const user = { - ext: { - data: { - age: 31 - } - }, - keywords: 'd', - gender: 'M', - yob: '1984', - geo: {country: 'ca'}, - data: [{foo: 'bar'}] - }; + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2: { - site, - user - } - }; - return utils.deepAccess(config, key); + sandbox.stub(config, 'getConfig').callsFake(key => { + const config = { + 'coppa': true + }; + return config[key]; + }); + const [request] = spec.buildRequests(bidderRequest.bids, syncAddFPDToBidderRequest(bidderRequest)); + expect(request.data.regs.coppa).to.equal(1); }); - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + it('should include first party data', () => { + const bidderRequest = createVideoBidderRequest(); - const expected = { - site: Object.assign({}, site, {keywords: bidderRequest.bids[0].params.keywords.join(',')}), - user: Object.assign({}, user), - siteData: Object.assign({}, site.ext.data, bidderRequest.bids[0].params.inventory), - userData: Object.assign({}, user.ext.data, bidderRequest.bids[0].params.visitor), - }; + const site = { + ext: { + data: { + page: 'home' + } + }, + content: { + data: [{foo: 'bar'}] + }, + keywords: 'e,f', + rating: '4-star', + data: [{foo: 'bar'}] + }; + const user = { + ext: { + data: { + age: 31 + } + }, + keywords: 'd', + gender: 'M', + yob: '1984', + geo: {country: 'ca'}, + data: [{foo: 'bar'}] + }; - delete request.data.site.page; - delete request.data.site.content.language; + const ortb2 = { + site, + user + }; - expect(request.data.site.keywords).to.deep.equal('a,b,c'); - expect(request.data.user.keywords).to.deep.equal('d'); - expect(request.data.site.ext.data).to.deep.equal(expected.siteData); - expect(request.data.user.ext.data).to.deep.equal(expected.userData); - }); + const [request] = spec.buildRequests(bidderRequest.bids.map((b) => ({...b, ortb2})), bidderRequest); - it('should include storedAuctionResponse in video bid request', function () { - createVideoBidderRequest(); + const expected = { + site: Object.assign({}, site, {keywords: bidderRequest.bids[0].params.keywords.join(',')}), + user: Object.assign({}, user), + siteData: Object.assign({}, site.ext.data, bidderRequest.bids[0].params.inventory), + userData: Object.assign({}, user.ext.data, bidderRequest.bids[0].params.visitor), + }; - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + delete request.data.site.page; + delete request.data.site.content.language; - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp).to.exist.and.to.be.a('array'); - expect(request.data.imp).to.have.lengthOf(1); - expect(request.data.imp[0].ext).to.exist.and.to.be.a('object'); - expect(request.data.imp[0].ext.prebid).to.exist.and.to.be.a('object'); - expect(request.data.imp[0].ext.prebid.storedauctionresponse).to.exist.and.to.be.a('object'); - expect(request.data.imp[0].ext.prebid.storedauctionresponse.id).to.equal('11111'); - }); + expect(request.data.site.keywords).to.deep.equal('a,b,c'); + expect(request.data.user.keywords).to.deep.equal('d'); + expect(request.data.site.ext.data).to.deep.equal(expected.siteData); + expect(request.data.user.ext.data).to.deep.equal(expected.userData); + }); - it('should include pbadslot in bid request', function () { - createVideoBidderRequest(); - bidderRequest.bids[0].ortb2Imp = { - ext: { - data: { - pbadslot: '1234567890' + it('should include pbadslot in bid request', function () { + const bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].ortb2Imp = { + ext: { + data: { + pbadslot: '1234567890' + } } } - } - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].ext.data.pbadslot).to.equal('1234567890'); - }); + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].ext.data.pbadslot).to.equal('1234567890'); + }); - it('should include GAM ad unit in bid request', function () { - createVideoBidderRequest(); - bidderRequest.bids[0].ortb2Imp = { - ext: { - data: { - adserver: { - adslot: '1234567890', - name: 'adServerName1' + it('should NOT include storedrequests in pbs payload', function () { + const bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].ortb2 = { + ext: { + prebid: { + storedrequest: 'no-send-top-level-sr' } } } - }; - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + bidderRequest.bids[0].ortb2Imp = { + ext: { + prebid: { + storedrequest: 'no-send-imp-sr' + } + } + } - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.imp[0].ext.data.adserver.adslot).to.equal('1234567890'); - expect(request.data.imp[0].ext.data.adserver.name).to.equal('adServerName1'); - }); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - it('should use the integration type provided in the config instead of the default', () => { - createVideoBidderRequest(); - config.setConfig({rubicon: {int_type: 'testType'}}); - const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - expect(request.data.ext.prebid.bidders.rubicon.integration).to.equal('testType'); - }); + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.ext.prebid.storedrequest).to.be.undefined; + expect(request.data.imp[0].ext.prebid.storedrequest).to.be.undefined; + }); - it('should pass the user.id provided in the config', function () { - config.setConfig({user: {id: '123'}}); - createVideoBidderRequest(); + it('should include GAM ad unit in bid request', function () { + const bidderRequest = createVideoBidderRequest(); + bidderRequest.bids[0].ortb2Imp = { + ext: { + data: { + adserver: { + adslot: '1234567890', + name: 'adServerName1' + } + } + } + }; - sandbox.stub(Date, 'now').callsFake(() => - bidderRequest.auctionStart + 100 - ); + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); - let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); - let post = request.data; - - expect(post).to.have.property('imp') - // .with.length.of(1); - let imp = post.imp[0]; - expect(imp.id).to.equal(bidderRequest.bids[0].adUnitCode); - expect(imp.exp).to.equal(undefined); - expect(imp.video.w).to.equal(640); - expect(imp.video.h).to.equal(480); - expect(imp.video.pos).to.equal(1); - expect(imp.video.context).to.equal('instream'); - expect(imp.video.minduration).to.equal(15); - expect(imp.video.maxduration).to.equal(30); - expect(imp.video.startdelay).to.equal(0); - expect(imp.video.skip).to.equal(1); - expect(imp.video.skipafter).to.equal(15); - expect(imp.ext.rubicon.video.playerWidth).to.equal(640); - expect(imp.ext.rubicon.video.playerHeight).to.equal(480); - expect(imp.ext.rubicon.video.size_id).to.equal(201); - expect(imp.ext.rubicon.video.language).to.equal('en'); - // Also want it to be in post.site.content.language - expect(post.site.content.language).to.equal('en'); - expect(imp.ext.rubicon.video.skip).to.equal(1); - expect(imp.ext.rubicon.video.skipafter).to.equal(15); - expect(imp.ext.prebid.auctiontimestamp).to.equal(1472239426000); - expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); - - // Config user.id - expect(post.user.id).to.equal('123'); - - expect(post.regs.ext.gdpr).to.equal(1); - expect(post.regs.ext.us_privacy).to.equal('1NYN'); - expect(post).to.have.property('ext').that.is.an('object'); - expect(post.ext.prebid.targeting.includewinners).to.equal(true); - expect(post.ext.prebid).to.have.property('cache').that.is.an('object'); - expect(post.ext.prebid.cache).to.have.property('vastxml').that.is.an('object'); - expect(post.ext.prebid.cache.vastxml).to.have.property('returnCreative').that.is.an('boolean'); - expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false); - expect(post.ext.prebid.bidders.rubicon.integration).to.equal(PBS_INTEGRATION); - }) - }); + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.imp[0].ext.data.adserver.adslot).to.equal('1234567890'); + expect(request.data.imp[0].ext.data.adserver.name).to.equal('adServerName1'); + }); + + it('should use the integration type provided in the config instead of the default', () => { + const bidderRequest = createVideoBidderRequest(); + config.setConfig({rubicon: {int_type: 'testType'}}); + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(request.data.ext.prebid.bidders.rubicon.integration).to.equal('testType'); + }); + + it('should pass the user.id provided in the config', function () { + config.setConfig({user: {id: '123'}}); + const bidderRequest = createVideoBidderRequest(); + + sandbox.stub(Date, 'now').callsFake(() => + bidderRequest.auctionStart + 100 + ); + + let [request] = spec.buildRequests(bidderRequest.bids, syncAddFPDToBidderRequest(bidderRequest)); + let post = request.data; + + expect(post).to.have.property('imp') + // .with.length.of(1); + let imp = post.imp[0]; + expect(imp.id).to.equal(bidderRequest.bids[0].adUnitCode); + expect(imp.exp).to.equal(undefined); + expect(imp.video.w).to.equal(640); + expect(imp.video.h).to.equal(480); + expect(imp.video.pos).to.equal(1); + expect(imp.video.minduration).to.equal(15); + expect(imp.video.maxduration).to.equal(30); + expect(imp.video.startdelay).to.equal(0); + expect(imp.video.skip).to.equal(1); + expect(imp.video.skipafter).to.equal(15); + expect(imp.ext.prebid.bidder.rubicon.video.playerWidth).to.equal(640); + expect(imp.ext.prebid.bidder.rubicon.video.playerHeight).to.equal(480); + expect(imp.ext.prebid.bidder.rubicon.video.language).to.equal('en'); + + // Also want it to be in post.site.content.language + expect(post.site.content.language).to.equal('en'); + expect(post.ext.prebid.auctiontimestamp).to.equal(1472239426000); + expect(post.user.ext.consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); + + // Config user.id + expect(post.user.id).to.equal('123'); + + expect(post.regs.ext.gdpr).to.equal(1); + expect(post.regs.ext.us_privacy).to.equal('1NYN'); + expect(post).to.have.property('ext').that.is.an('object'); + expect(post.ext.prebid.targeting.includewinners).to.equal(true); + expect(post.ext.prebid).to.have.property('cache').that.is.an('object'); + expect(post.ext.prebid.cache).to.have.property('vastxml').that.is.an('object'); + expect(post.ext.prebid.cache.vastxml).to.have.property('returnCreative').that.is.an('boolean'); + expect(post.ext.prebid.cache.vastxml.returnCreative).to.equal(false); + expect(post.ext.prebid.bidders.rubicon.integration).to.equal(PBS_INTEGRATION); + }) + }); + } describe('combineSlotUrlParams', function () { it('should combine an array of slot url params', function () { @@ -2230,6 +2548,7 @@ describe('the rubicon adapter', function () { describe('createSlotParams', function () { it('should return a valid slot params object', function () { + const localBidderRequest = Object.assign({}, bidderRequest); let expectedQuery = { 'account_id': '14062', 'site_id': '70608', @@ -2239,7 +2558,7 @@ describe('the rubicon adapter', function () { 'p_pos': 'atf', 'rp_secure': /[01]/, 'tk_flint': INTEGRATION, - 'x_source.tid': 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + 'x_source.tid': 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', 'p_screen_res': /\d+x\d+/, 'tk_user_key': '12346', 'kw': 'a,b,c', @@ -2252,7 +2571,7 @@ describe('the rubicon adapter', function () { 'rf': 'localhost' }; - const slotParams = spec.createSlotParams(bidderRequest.bids[0], bidderRequest); + const slotParams = spec.createSlotParams(bidderRequest.bids[0], localBidderRequest); // test that all values above are both present and correct Object.keys(expectedQuery).forEach(key => { @@ -2272,59 +2591,197 @@ describe('the rubicon adapter', function () { }); }); - describe('hasVideoMediaType', function () { - it('should return true if mediaType is video and size_id is set', function () { - createVideoBidderRequest(); - const legacyVideoTypeBidRequest = hasVideoMediaType(bidderRequest.bids[0]); - expect(legacyVideoTypeBidRequest).is.equal(true); + describe('classifiedAsVideo', function () { + it('should return true if mediaTypes is video', function () { + const bidderRequest = createVideoBidderRequest(); + const bidClassifiedAsVideo = classifiedAsVideo(bidderRequest.bids[0]); + expect(bidClassifiedAsVideo).is.equal(true); }); it('should return false if trying to use legacy mediaType with video', function () { - createVideoBidderRequest(); + const bidderRequest = createVideoBidderRequest(); delete bidderRequest.bids[0].mediaTypes; bidderRequest.bids[0].mediaType = 'video'; - const legacyVideoTypeBidRequest = hasVideoMediaType(bidderRequest.bids[0]); + const legacyVideoTypeBidRequest = classifiedAsVideo(bidderRequest.bids[0]); expect(legacyVideoTypeBidRequest).is.equal(false); }); - it('should return false if bidRequest.mediaType is not equal to video', function () { - expect(hasVideoMediaType({ + it('should return false if bid.mediaTypes is not equal to video', function () { + expect(classifiedAsVideo({ mediaType: 'banner' })).is.equal(false); }); - it('should return false if bidRequest.mediaType is not defined', function () { - expect(hasVideoMediaType({})).is.equal(false); + it('should return false if bid.mediaTypes is not defined', function () { + expect(classifiedAsVideo({})).is.equal(false); }); - it('should return true if bidRequest.mediaTypes.video.context is instream and size_id is defined', function () { - expect(hasVideoMediaType({ - mediaTypes: { - video: { - context: 'instream' + it('Should return false if both banner and video mediaTypes are set and params.video is not an object', function () { + removeVideoParamFromBidderRequest(bidderRequest); + let bid = bidderRequest.bids[0]; + bid.mediaTypes.banner = {flag: true}; + expect(classifiedAsVideo(bid)).to.equal(false); + }); + it('Should return true if both banner and video mediaTypes are set and params.video is an object', function () { + removeVideoParamFromBidderRequest(bidderRequest); + let bid = bidderRequest.bids[0]; + bid.mediaTypes.banner = {flag: true}; + bid.params.video = {}; + expect(classifiedAsVideo(bid)).to.equal(true); + }); + + it('Should return true and create a params.video object if one is not already present', function () { + removeVideoParamFromBidderRequest(bidderRequest); + let bid = bidderRequest.bids[0] + expect(classifiedAsVideo(bid)).to.equal(true); + expect(bid.params.video).to.not.be.undefined; + }); + }); + + if (FEATURES.NATIVE) { + describe('when there is a native request', function () { + describe('and bidonmultiformat = undefined (false)', () => { + it('should send only one native bid to PBS endpoint', function () { + const bidReq = addNativeToBidRequest(bidderRequest); + bidReq.bids[0].params = { + video: {} } - }, - params: { - video: { - size_id: 7 + let [request] = spec.buildRequests(bidReq.bids, bidReq); + expect(request.method).to.equal('POST'); + expect(request.url).to.equal('https://prebid-server.rubiconproject.com/openrtb2/auction'); + expect(request.data.imp).to.have.nested.property('[0].native'); + }); + + it('should not break if position is set and no video MT', function () { + const bidReq = addNativeToBidRequest(bidderRequest); + delete bidReq.bids[0].mediaTypes.banner; + bidReq.bids[0].params = { + position: 'atf' } - } - })).is.equal(true); - }); + let [request] = spec.buildRequests(bidReq.bids, bidReq); + expect(request.method).to.equal('POST'); + expect(request.url).to.equal('https://prebid-server.rubiconproject.com/openrtb2/auction'); + expect(request.data.imp).to.have.nested.property('[0].native'); + }); - it('should return false if bidRequest.mediaTypes.video.context is instream but size_id is not defined', function () { - expect(spec.isBidRequestValid({ - mediaTypes: { - video: { - context: 'instream' + describe('that contains also a banner mediaType', function () { + it('should send the banner to fastlane BUT NOT the native bid because missing params.video', function() { + const bidReq = addNativeToBidRequest(bidderRequest); + bidReq.bids[0].mediaTypes.banner = { + sizes: [[300, 250]] + } + let [request] = spec.buildRequests(bidReq.bids, bidReq); + expect(request.method).to.equal('GET'); + expect(request.url).to.include('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + }); + }); + describe('with another banner request', () => { + it('should send the native bid to PBS and the banner to fastlane', function() { + const bidReq = addNativeToBidRequest(bidderRequest); + bidReq.bids[0].params = { video: {} }; + // add second bidRqeuest + bidReq.bids.push({ + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + params: bidReq.bids[0].params + }) + let [request1, request2] = spec.buildRequests(bidReq.bids, bidReq); + expect(request1.method).to.equal('POST'); + expect(request1.url).to.equal('https://prebid-server.rubiconproject.com/openrtb2/auction'); + expect(request1.data.imp).to.have.nested.property('[0].native'); + expect(request2.method).to.equal('GET'); + expect(request2.url).to.include('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + }); + }); + }); + + describe('with bidonmultiformat === true', () => { + it('should send two requests, to PBS with 2 imps', () => { + const bidReq = addNativeToBidRequest(bidderRequest); + // add second mediaType + bidReq.bids[0].mediaTypes = { + ...bidReq.bids[0].mediaTypes, + banner: { + sizes: [[300, 250]] + } + }; + bidReq.bids[0].params.bidonmultiformat = true; + let [pbsRequest, fastlanteRequest] = spec.buildRequests(bidReq.bids, bidReq); + expect(pbsRequest.method).to.equal('POST'); + expect(pbsRequest.url).to.equal('https://prebid-server.rubiconproject.com/openrtb2/auction'); + expect(pbsRequest.data.imp).to.have.nested.property('[0].native'); + expect(fastlanteRequest.url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + }); + + it('should include multiformat data in the pbs request', () => { + const bidReq = addNativeToBidRequest(bidderRequest); + // add second mediaType + bidReq.bids[0].mediaTypes = { + ...bidReq.bids[0].mediaTypes, + banner: { + sizes: [[300, 250]] + } + }; + bidReq.bids[0].params.bidonmultiformat = true; + let [pbsRequest, fastlanteRequest] = spec.buildRequests(bidReq.bids, bidReq); + expect(pbsRequest.data.imp[0].ext.prebid.bidder.rubicon.formats).to.deep.equal(['native', 'banner']); + }); + + it('should include multiformat data in the fastlane request', () => { + const bidReq = addNativeToBidRequest(bidderRequest); + // add second mediaType + bidReq.bids[0].mediaTypes = { + ...bidReq.bids[0].mediaTypes, + banner: { + sizes: [[300, 250]] + } + }; + bidReq.bids[0].params.bidonmultiformat = true; + let [pbsRequest, fastlanteRequest] = spec.buildRequests(bidReq.bids, bidReq); + let formatsIncluded = fastlanteRequest.data.indexOf('formats=native%2Cbanner') !== -1; + expect(formatsIncluded).to.equal(true); + }); + }); + describe('with bidonmultiformat === false', () => { + it('should send only banner request because there\'s no params.video', () => { + const bidReq = addNativeToBidRequest(bidderRequest); + // add second mediaType + bidReq.bids[0].mediaTypes = { + ...bidReq.bids[0].mediaTypes, + banner: { + sizes: [[300, 250]] + } + }; + + let [fastlanteRequest, ...others] = spec.buildRequests(bidReq.bids, bidReq); + expect(fastlanteRequest.url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + expect(others).to.be.empty; + }); + + it('should not send native to PBS even if there\'s param.video', () => { + const bidReq = addNativeToBidRequest(bidderRequest); + // add second mediaType + bidReq.bids[0].mediaTypes = { + ...bidReq.bids[0].mediaTypes, + banner: { + sizes: [[300, 250]] + } + }; + // by adding this, when bidonmultiformat is false, the native request will be sent to pbs + bidReq.bids[0].params = { + video: {} } - }, - params: { - video: {} - } - })).is.equal(false); + let [fastlaneRequest, ...other] = spec.buildRequests(bidReq.bids, bidReq); + expect(fastlaneRequest.method).to.equal('GET'); + expect(fastlaneRequest.url).to.equal('https://fastlane.rubiconproject.com/a/api/fastlane.json'); + expect(other).to.be.empty; + }); + }); }); - }); + } }); describe('interpretResponse', function () { @@ -3067,211 +3524,294 @@ describe('the rubicon adapter', function () { }); }); - describe('for video', function () { - beforeEach(function () { - createVideoBidderRequest(); - }); - - it('should register a successful bid', function () { - let response = { - cur: 'USD', - seatbid: [{ - bid: [{ - id: '0', - impid: 'instream_video1', - adomain: ['test.com'], - price: 2, - crid: '4259970', - ext: { - bidder: { - rp: { - mime: 'application/javascript', - size_id: 201, - advid: 12345 - } - }, - prebid: { - targeting: { - hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + if (FEATURES.VIDEO) { + describe('for video', function () { + it('should register a successful bid', function () { + const bidderRequest = createVideoBidderRequest(); + let response = { + cur: 'USD', + seatbid: [{ + bid: [{ + id: '0', + impid: '/19968336/header-bid-tag-0', + adomain: ['test.com'], + price: 2, + crid: '4259970', + ext: { + bidder: { + rp: { + mime: 'application/javascript', + size_id: 201, + advid: 12345 + } }, - type: 'video' + prebid: { + targeting: { + hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + }, + type: 'video' + } } - } + }], + group: 0, + seat: 'rubicon' }], - group: 0, - seat: 'rubicon' - }], - }; + }; - let bids = spec.interpretResponse({body: response}, { - bidRequest: bidderRequest.bids[0] + const request = converter.toORTB({bidderRequest, bidRequests: bidderRequest.bids}); + + let bids = spec.interpretResponse({body: response}, {data: request}); + + expect(bids).to.be.lengthOf(1); + + expect(bids[0].seatBidId).to.equal('0'); + expect(bids[0].creativeId).to.equal('4259970'); + expect(bids[0].cpm).to.equal(2); + expect(bids[0].ttl).to.equal(300); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[0].adserverTargeting).to.deep.equal({hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64'}); + expect(bids[0].mediaType).to.equal('video'); + expect(bids[0].meta.mediaType).to.equal('video'); + expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com'); + expect(bids[0].meta.advertiserId).to.equal(12345); + expect(bids[0].bidderCode).to.equal('rubicon'); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].width).to.equal(640); + expect(bids[0].height).to.equal(480); }); + }); + } - expect(bids).to.be.lengthOf(1); - - expect(bids[0].seatBidId).to.equal('0'); - expect(bids[0].creativeId).to.equal('4259970'); - expect(bids[0].cpm).to.equal(2); - expect(bids[0].ttl).to.equal(300); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].adserverTargeting).to.deep.equal({hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64'}); - expect(bids[0].mediaType).to.equal('video'); - expect(bids[0].meta.mediaType).to.equal('video'); - expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com'); - expect(bids[0].meta.advertiserId).to.equal(12345); - expect(bids[0].bidderCode).to.equal('rubicon'); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].width).to.equal(640); - expect(bids[0].height).to.equal(480); + if (FEATURES.NATIVE) { + describe('for native', () => { + it('should get a native bid', () => { + const nativeBidderRequest = addNativeToBidRequest(bidderRequest); + const request = converter.toORTB({bidderRequest: nativeBidderRequest, bidRequests: nativeBidderRequest.bids}); + let response = getNativeResponse({impid: request.imp[0].id}); + let bids = spec.interpretResponse({body: response}, {data: request}); + expect(bids).to.have.nested.property('[0].native'); + }); }); - }); + } - describe('for outstream video', function () { - const sandbox = sinon.createSandbox(); - beforeEach(function () { - createVideoBidderRequestOutstream(); - config.setConfig({rubicon: { - rendererConfig: { - align: 'left', - closeButton: true - }, - rendererUrl: 'https://example.test/renderer.js' - }}); - window.MagniteApex = { - renderAd: function() { - return null; + if (FEATURES.VIDEO) { + describe('for outstream video', function () { + const sandbox = sinon.createSandbox(); + beforeEach(function () { + config.setConfig({rubicon: { + rendererConfig: { + align: 'left', + closeButton: true + }, + rendererUrl: 'https://example.test/renderer.js' + }}); + window.MagniteApex = { + renderAd: function() { + return null; + } } - } - }); + }); - afterEach(function () { - sandbox.restore(); - delete window.MagniteApex; - }); + afterEach(function () { + sandbox.restore(); + delete window.MagniteApex; + }); - it('should register a successful bid', function () { - let response = { - cur: 'USD', - seatbid: [{ - bid: [{ - id: '0', - impid: 'outstream_video1', - adomain: ['test.com'], - price: 2, - crid: '4259970', - ext: { - bidder: { - rp: { - mime: 'application/javascript', - size_id: 201, - advid: 12345 - } - }, - prebid: { - targeting: { - hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + it('should register a successful bid', function () { + const bidderRequest = createVideoBidderRequestOutstream(); + let response = { + cur: 'USD', + seatbid: [{ + bid: [{ + id: '0', + impid: '/19968336/header-bid-tag-0', + adomain: ['test.com'], + price: 2, + crid: '4259970', + ext: { + bidder: { + rp: { + mime: 'application/javascript', + size_id: 201, + advid: 12345 + } }, - type: 'video' + prebid: { + targeting: { + hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + }, + type: 'video' + } } - } + }], + group: 0, + seat: 'rubicon' }], - group: 0, - seat: 'rubicon' - }], - }; + }; - let bids = spec.interpretResponse({body: response}, { - bidRequest: bidderRequest.bids[0] + const request = converter.toORTB({bidderRequest, bidRequests: bidderRequest.bids}); + + let bids = spec.interpretResponse({body: response}, { data: request }); + + expect(bids).to.be.lengthOf(1); + + expect(bids[0].seatBidId).to.equal('0'); + expect(bids[0].creativeId).to.equal('4259970'); + expect(bids[0].cpm).to.equal(2); + expect(bids[0].ttl).to.equal(300); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[0].adserverTargeting).to.deep.equal({hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64'}); + expect(bids[0].mediaType).to.equal('video'); + expect(bids[0].meta.mediaType).to.equal('video'); + expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com'); + expect(bids[0].meta.advertiserId).to.equal(12345); + expect(bids[0].bidderCode).to.equal('rubicon'); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].width).to.equal(640); + expect(bids[0].height).to.equal(320); + // check custom renderer + expect(typeof bids[0].renderer).to.equal('object'); + expect(bids[0].renderer.getConfig()).to.deep.equal({ + align: 'left', + closeButton: true + }); + expect(bids[0].renderer.url).to.equal('https://example.test/renderer.js'); }); - expect(bids).to.be.lengthOf(1); + it('should render ad with Magnite renderer', function () { + const bidderRequest = createVideoBidderRequestOutstream(); + let response = { + cur: 'USD', + seatbid: [{ + bid: [{ + id: '0', + impid: '/19968336/header-bid-tag-0', + adomain: ['test.com'], + price: 2, + crid: '4259970', + ext: { + bidder: { + rp: { + mime: 'application/javascript', + size_id: 201, + advid: 12345 + } + }, + prebid: { + targeting: { + hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + }, + type: 'video' + } + }, + nurl: 'https://test.com/vast.xml' + }], + group: 0, + seat: 'rubicon' + }], + }; - expect(bids[0].seatBidId).to.equal('0'); - expect(bids[0].creativeId).to.equal('4259970'); - expect(bids[0].cpm).to.equal(2); - expect(bids[0].ttl).to.equal(300); - expect(bids[0].netRevenue).to.equal(true); - expect(bids[0].adserverTargeting).to.deep.equal({hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64'}); - expect(bids[0].mediaType).to.equal('video'); - expect(bids[0].meta.mediaType).to.equal('video'); - expect(String(bids[0].meta.advertiserDomains)).to.equal('test.com'); - expect(bids[0].meta.advertiserId).to.equal(12345); - expect(bids[0].bidderCode).to.equal('rubicon'); - expect(bids[0].currency).to.equal('USD'); - expect(bids[0].width).to.equal(640); - expect(bids[0].height).to.equal(320); - // check custom renderer - expect(typeof bids[0].renderer).to.equal('object'); - expect(bids[0].renderer.getConfig()).to.deep.equal({ - align: 'left', - closeButton: true - }); - expect(bids[0].renderer.url).to.equal('https://example.test/renderer.js'); - }); + const request = converter.toORTB({bidderRequest, bidRequests: bidderRequest.bids}); + + sinon.spy(window.MagniteApex, 'renderAd'); + + let bids = spec.interpretResponse({body: response}, {data: request}); + const bid = bids[0]; + bid.adUnitCode = 'outstream_video1_placement'; + const adUnit = document.createElement('div'); + adUnit.id = bid.adUnitCode; + document.body.appendChild(adUnit); + + bid.renderer.render(bid); + + const renderCall = window.MagniteApex.renderAd.getCall(0); + expect(renderCall.args[0]).to.deep.equal({ + closeButton: true, + collapse: true, + height: 320, + label: undefined, + placement: { + align: 'left', + attachTo: adUnit, + position: 'append', + }, + vastUrl: 'https://test.com/vast.xml', + width: 640 + }); + // cleanup + adUnit.parentNode.removeChild(adUnit); + }); - it('should render ad with Magnite renderer', function () { - let response = { - cur: 'USD', - seatbid: [{ - bid: [{ - id: '0', - impid: 'outstream_video1', - adomain: ['test.com'], - price: 2, - crid: '4259970', - ext: { - bidder: { - rp: { - mime: 'application/javascript', - size_id: 201, - advid: 12345 + it('should render ad with Magnite renderer without video object', function () { + const bidderRequest = createVideoBidderRequestOutstream(); + delete bidderRequest.bids[0].params.video; + bidderRequest.bids[0].params.bidonmultiformat = true; + bidderRequest.bids[0].mediaTypes.video.placement = 3; + bidderRequest.bids[0].mediaTypes.video.playerSize = [640, 480]; + + let response = { + cur: 'USD', + seatbid: [{ + bid: [{ + id: '0', + impid: '/19968336/header-bid-tag-0', + adomain: ['test.com'], + price: 2, + crid: '4259970', + ext: { + bidder: { + rp: { + mime: 'application/javascript', + size_id: 201, + advid: 12345 + } + }, + prebid: { + targeting: { + hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' + }, + type: 'video' } }, - prebid: { - targeting: { - hb_uuid: '0c498f63-5111-4bed-98e2-9be7cb932a64' - }, - type: 'video' - } - }, - nurl: 'https://test.com/vast.xml' + nurl: 'https://test.com/vast.xml' + }], + group: 0, + seat: 'rubicon' }], - group: 0, - seat: 'rubicon' - }], - }; - - sinon.spy(window.MagniteApex, 'renderAd'); + }; - let bids = spec.interpretResponse({body: response}, { - bidRequest: bidderRequest.bids[0] - }); - const bid = bids[0]; - bid.adUnitCode = 'outstream_video1_placement'; - const adUnit = document.createElement('div'); - adUnit.id = bid.adUnitCode; - document.body.appendChild(adUnit); - - bid.renderer.render(bid); - - const renderCall = window.MagniteApex.renderAd.getCall(0); - expect(renderCall.args[0]).to.deep.equal({ - closeButton: true, - collapse: true, - height: 320, - label: undefined, - placement: { - align: 'left', - attachTo: adUnit, - position: 'append', - }, - vastUrl: 'https://test.com/vast.xml', - width: 640 + const request = converter.toORTB({bidderRequest, bidRequests: bidderRequest.bids}); + + sinon.spy(window.MagniteApex, 'renderAd'); + + let bids = spec.interpretResponse({body: response}, {data: request}); + const bid = bids[0]; + bid.adUnitCode = 'outstream_video1_placement'; + const adUnit = document.createElement('div'); + adUnit.id = bid.adUnitCode; + document.body.appendChild(adUnit); + + bid.renderer.render(bid); + + const renderCall = window.MagniteApex.renderAd.getCall(0); + expect(renderCall.args[0]).to.deep.equal({ + closeButton: true, + collapse: true, + height: 480, + label: undefined, + placement: { + align: 'left', + attachTo: adUnit, + position: 'append', + }, + vastUrl: 'https://test.com/vast.xml', + width: 640 + }); + // cleanup + adUnit.parentNode.removeChild(adUnit); }); - // cleanup - adUnit.parentNode.removeChild(adUnit); }); - }); + } describe('config with integration type', () => { it('should use the integration type provided in the config instead of the default', () => { @@ -3399,6 +3939,24 @@ describe('the rubicon adapter', function () { type: 'iframe', url: `${emilyUrl}?gdpr=1&gdpr_consent=foo&us_privacy=1NYN` }); }); + + it('should pass gpp params when gppConsent is present', function () { + expect(spec.getUserSyncs({iframeEnabled: true}, {}, {}, undefined, { + gppString: 'foo', + applicableSections: [2] + })).to.deep.equal({ + type: 'iframe', url: `${emilyUrl}?gpp=foo&gpp_sid=2` + }); + }); + + it('should pass multiple sid\'s when multiple are present', function () { + expect(spec.getUserSyncs({iframeEnabled: true}, {}, {}, undefined, { + gppString: 'foo', + applicableSections: [2, 5] + })).to.deep.equal({ + type: 'iframe', url: `${emilyUrl}?gpp=foo&gpp_sid=2,5` + }); + }); }); describe('get price granularity', function () { @@ -3521,7 +4079,7 @@ describe('the rubicon adapter', function () { }); it('should copy the schain JSON to to bid.source.ext.schain', () => { - createVideoBidderRequest(); + const bidderRequest = createVideoBidderRequest(); const schain = getSupplyChainConfig(); bidderRequest.bids[0].schain = schain; const request = spec.buildRequests(bidderRequest.bids, bidderRequest); @@ -3557,12 +4115,13 @@ describe('the rubicon adapter', function () { }); // banner - let [bannerRequest] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const bannerBidderRequest = createGdprBidderRequest(false); + let [bannerRequest] = spec.buildRequests(bannerBidderRequest.bids, bannerBidderRequest); expect(bannerRequest.url).to.equal('https://fastlane-qa.rubiconproject.com/a/api/fastlane.json'); // video and returnVast - createVideoBidderRequest(); - let [videoRequest] = spec.buildRequests(bidderRequest.bids, bidderRequest); + const videoBidderRequest = createVideoBidderRequest(); + let [videoRequest] = spec.buildRequests(videoBidderRequest.bids, videoBidderRequest); let post = videoRequest.data; expect(videoRequest.url).to.equal('https://prebid-server-qa.rubiconproject.com/openrtb2/auction'); expect(post.ext.prebid.cache.vastxml).to.have.property('returnCreative').that.is.an('boolean'); @@ -3576,3 +4135,164 @@ describe('the rubicon adapter', function () { }); }); }); + +function addNativeToBidRequest(bidderRequest) { + const nativeOrtbRequest = { + assets: [{ + id: 0, + required: 1, + title: { + len: 140 + } + }, + { + id: 1, + required: 1, + img: { + type: 3, + w: 300, + h: 600 + } + }, + { + id: 2, + required: 1, + data: { + type: 1 + } + }] + }; + bidderRequest.refererInfo = { + page: 'localhost' + } + bidderRequest.bids[0] = { + bidder: 'rubicon', + params: { + accountId: '14062', + siteId: '70608', + zoneId: '335918', + }, + adUnitCode: '/19968336/header-bid-tag-0', + code: 'div-1', + bidId: '2ffb201a808da7', + bidderRequestId: '178e34bad3658f', + auctionId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a', + transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b', + mediaTypes: { + native: { + ortb: { + ...nativeOrtbRequest + } + } + }, + nativeOrtbRequest + } + return bidderRequest; +} + +function getNativeResponse(options = {impid: 1234}) { + return { + 'id': 'd7786a80-bfb4-4541-859f-225a934e81d4', + 'seatbid': [ + { + 'bid': [ + { + 'id': '971650', + 'impid': options.impid, + 'price': 20, + 'adm': { + 'ver': '1.2', + 'assets': [ + { + 'id': 0, + 'title': { + 'text': 'This is a title' + }, + 'link': { + 'clicktrackers': [ + 'http://localhost:5500/event?type=click1&component=card&asset=0' + ] + } + }, + { + 'id': 1, + 'img': { + 'url': 'https:\\\\/\\\\/vcdn.adnxs.com\\\\/p\\\\/creative-image\\\\/94\\\\/22\\\\/cd\\\\/0f\\\\/9422cd0f-f400-45d3-80f5-2b92629d9257.jpg', + 'h': 2250, + 'w': 3000 + }, + 'link': { + 'clicktrackers': [ + 'http://localhost:5500/event?type=click1&component=card&asset=1' + ] + } + }, + { + 'id': 2, + 'data': { + 'value': 'this is asset data 1 that corresponds to sponsoredBy' + } + } + ], + 'link': { + 'url': 'https://magnite.com', + 'clicktrackers': [ + 'http://localhost:5500/event?type=click1&component=card', + 'http://localhost:5500/event?type=click2&component=card' + ] + }, + 'jstracker': '', + 'eventtrackers': [ + { + 'event': 1, + 'method': 2, + 'url': 'http://localhost:5500/event?type=1&method=2' + }, + { + 'event': 2, + 'method': 1, + 'url': 'http://localhost:5500/event?type=v50&component=card' + } + ] + }, + 'adid': '392180', + 'adomain': [ + 'http://prebid.org' + ], + 'iurl': 'https://lax1-ib.adnxs.com/cr?id=97494403', + 'cid': '9325', + 'crid': '97494403', + 'cat': [ + 'IAB3-1' + ], + 'w': 300, + 'h': 600, + 'ext': { + 'prebid': { + 'targeting': { + 'hb_bidder': 'rubicon', + 'hb_cache_host': 'prebid.lax1.adnxs-simple.com', + 'hb_cache_path': '/pbc/v1/cache', + 'hb_pb': '20.00' + }, + 'type': 'native', + 'video': { + 'duration': 0, + 'primary_category': '' + } + }, + 'rubicon': { + 'auction_id': 642778043863823100, + 'bid_ad_type': 3, + 'bidder_id': 2, + 'brand_id': 555545 + } + } + } + ], + 'seat': 'rubicon' + } + ], + 'cur': 'USD' + }; +} diff --git a/test/spec/modules/scatteredBidAdapter_spec.js b/test/spec/modules/scatteredBidAdapter_spec.js new file mode 100644 index 00000000000..1db2d98d326 --- /dev/null +++ b/test/spec/modules/scatteredBidAdapter_spec.js @@ -0,0 +1,208 @@ +import { spec, converter } from 'modules/scatteredBidAdapter.js'; +import { assert } from 'chai'; +import { config } from 'src/config.js'; +import { deepClone, mergeDeep } from '../../../src/utils'; +describe('Scattered adapter', function () { + describe('isBidRequestValid', function () { + // A valid bid + let validBid = { + bidder: 'scattered', + mediaTypes: { + banner: { + sizes: [[300, 250], [760, 400]] + } + }, + params: { + bidderDomain: 'https://prebid.scattered.eu', + test: 0 + } + }; + + // Because this valid bid is modified to create invalid bids in following tests we first check it. + // We must be sure it is a valid one, not to get false negatives. + it('should accept a valid bid', function () { + assert.isTrue(spec.isBidRequestValid(validBid)); + }); + + it('should skip if bidderDomain info is missing', function () { + let bid = deepClone(validBid); + + delete bid.params.bidderDomain; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + + it('should expect at least one banner size', function () { + let bid = deepClone(validBid); + + delete bid.mediaTypes.banner; + assert.isFalse(spec.isBidRequestValid(bid)); + + // empty sizes array + bid.mediaTypes = { + banner: { + sizes: [] + } + }; + assert.isFalse(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', function () { + let arrayOfValidBidRequests, validBidderRequest; + + beforeEach(function () { + arrayOfValidBidRequests = [{ + bidder: 'scattered', + params: { + bidderDomain: 'https://prebid.scattered.eu', + test: 0 + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [760, 400]] + }, + adUnitCode: 'test-div', + transactionId: '32d09c47-c6b8-40b0-9605-2e251a472ea4', + bidId: '21adc5d8765aa1', + bidderRequestId: '130728f7662afc', + auctionId: 'b4a45a23-8371-4d87-9308-39146b29ca32', + }, + }]; + + validBidderRequest = { + bidderCode: 'scattered', + auctionId: 'b4a45a23-8371-4d87-9308-39146b29ca32', + gdprConsent: { consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA', gdprApplies: true }, + refererInfo: { + domain: 'localhost', + page: 'http://localhost:9999/integrationExamples/gpt/hello_world.html?pbjs_debug=true', + }, + ortb2: { + site: { + publisher: { + name: 'publisher1 INC.' + } + } + } + }; + }); + + it('should validate request format', function () { + let request = spec.buildRequests(arrayOfValidBidRequests, validBidderRequest); + assert.equal(request.method, 'POST'); + assert.deepEqual(request.options, { contentType: 'application/json' }); + assert.ok(request.data); + }); + + it('has the right fields filled', function () { + let request = spec.buildRequests(arrayOfValidBidRequests, validBidderRequest); + const bidderRequest = request.data; + assert.ok(bidderRequest.site); + assert.lengthOf(bidderRequest.imp, 1); + }); + + it('should configure the site object', function () { + let request = spec.buildRequests(arrayOfValidBidRequests, validBidderRequest); + const site = request.data.site; + assert.equal(site.publisher.name, validBidderRequest.ortb2.site.publisher.name) + }); + + it('should configure site with ortb2', function () { + const req = mergeDeep({}, validBidderRequest, { + ortb2: { + site: { + id: '876', + publisher: { + domain: 'publisher1.eu' + } + } + } + }); + + let request = spec.buildRequests(arrayOfValidBidRequests, req); + const site = request.data.site; + assert.deepEqual(site, { + id: '876', + publisher: { + domain: 'publisher1.eu', + name: 'publisher1 INC.' + } + }); + }); + + it('should send device info', function () { + it('should send info about device', function () { + config.setConfig({ + device: { w: 375, h: 273 } + }); + + let request = spec.buildRequests(arrayOfValidBidRequests, validBidderRequest); + + assert.equal(request.device.ua, navigator.userAgent); + assert.equal(request.device.w, 375); + assert.equal(request.device.h, 273); + }); + }) + }) +}) + +describe('interpretResponse', function () { + const serverResponse = { + body: { + id: 'b4a45a23-8371-4d87-9308-39146b29ca32', + bidid: '11111111-2222-2222-2222-333333333333', + cur: 'PLN', + seatbid: [{ + bid: [ + { + id: '234234-234234-234234', // bidder generated + impid: '123', + price: '34.2', + nurl: 'https://scattered.eu/nurl', + adm: '
', + cpm: '34.2', + creativeId: '2345-2345-23', + currency: 'PLN', + height: 456, + width: 345, + mediaType: 'banner', + requestId: '123', + ttl: 360, + }; + expect(results.length).to.equal(1); + sinon.assert.match(results[0], expected); + }); +}); diff --git a/test/spec/modules/schain_spec.js b/test/spec/modules/schain_spec.js index 34d0cff9a60..eb8e35749db 100644 --- a/test/spec/modules/schain_spec.js +++ b/test/spec/modules/schain_spec.js @@ -469,6 +469,15 @@ describe('#makeBidRequestsHook', function() { makeBidRequestsHook(testCallback, testBidderRequests); }); + it('should not share the same schain object between different bid requests', (done) => { + config.setBidderConfig(goodStrictBidderConfig); + makeBidRequestsHook((requests) => { + requests[0].bids[0].schain.field = 'value'; + expect(requests[1].bids[0].schain.field).to.not.exist; + done(); + }, deepClone(bidderRequests)) + }); + it('should reject bad strict config but allow a bad relaxed config for bidders trying to override it', function () { function testCallback(bidderRequests) { expect(bidderRequests[0].bids[0].schain).to.exist; diff --git a/test/spec/modules/seedingAllianceAdapter_spec.js b/test/spec/modules/seedingAllianceAdapter_spec.js index 81af9546ff0..03548cf923a 100755 --- a/test/spec/modules/seedingAllianceAdapter_spec.js +++ b/test/spec/modules/seedingAllianceAdapter_spec.js @@ -38,7 +38,7 @@ describe('SeedingAlliance adapter', function () { }); it('should have default request structure', function () { - let keys = 'site,device,cur,imp,user,regs'.split(','); + let keys = 'site,cur,imp,regs'.split(','); let validBidRequests = [{ bidId: 'bidId', params: {} @@ -49,25 +49,17 @@ describe('SeedingAlliance adapter', function () { assert.deepEqual(keys, data); }); - it('Verify the auction ID', function () { + it('Verify the site url', function () { + let siteUrl = 'https://www.yourdomain.tld/your-directory/'; let validBidRequests = [{ bidId: 'bidId', - params: {}, - auctionId: 'auctionId' - }]; - let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' }, auctionId: validBidRequests[0].auctionId }).data); - - assert.equal(request.id, validBidRequests[0].auctionId); - }); - - it('Verify the device', function () { - let validBidRequests = [{ - bidId: 'bidId', - params: {} + params: { + url: siteUrl + } }]; let request = JSON.parse(spec.buildRequests(validBidRequests, { refererInfo: { referer: 'page' } }).data); - assert.equal(request.device.ua, navigator.userAgent); + assert.equal(request.site.page, siteUrl); }); it('Verify native asset ids', function () { @@ -109,7 +101,7 @@ describe('SeedingAlliance adapter', function () { }); describe('interpretResponse', function () { - const goodResponse = { + const goodNativeResponse = { body: { cur: 'EUR', id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', @@ -136,51 +128,89 @@ describe('SeedingAlliance adapter', function () { ] } }; + + const goodBannerResponse = { + body: { + cur: 'EUR', + id: 'b4516b80-886e-4ec0-82ae-9209e6d625fb', + seatbid: [ + { + seat: 'seedingAlliance', + bid: [{ + adm: '', + impid: 1, + price: 0.90, + h: 250, + w: 300 + }] + } + ] + } + }; + const badResponse = { body: { cur: 'EUR', id: '4b516b80-886e-4ec0-82ae-9209e6d625fb', seatbid: [] }}; - const bidRequest = { + const bidNativeRequest = { + data: {}, + bidRequests: [{bidId: 'bidId1', nativeParams: {title: {required: true, len: 800}}}] + }; + + const bidBannerRequest = { data: {}, - bids: [{ bidId: 'bidId1' }] + bidRequests: [{bidId: 'bidId1', sizes: [300, 250]}] }; it('should return null if body is missing or empty', function () { - const result = spec.interpretResponse(badResponse, bidRequest); + const result = spec.interpretResponse(badResponse, bidNativeRequest); assert.equal(result.length, 0); delete badResponse.body - const result1 = spec.interpretResponse(badResponse, bidRequest); + const result1 = spec.interpretResponse(badResponse, bidNativeRequest); assert.equal(result.length, 0); }); it('should return the correct params', function () { - const result = spec.interpretResponse(goodResponse, bidRequest); - const bid = goodResponse.body.seatbid[0].bid[0]; - - assert.deepEqual(result[0].currency, goodResponse.body.cur); - assert.deepEqual(result[0].requestId, bidRequest.bids[0].bidId); - assert.deepEqual(result[0].cpm, bid.price); - assert.deepEqual(result[0].creativeId, bid.crid); - assert.deepEqual(result[0].mediaType, 'native'); - assert.deepEqual(result[0].bidderCode, 'seedingAlliance'); + const resultNative = spec.interpretResponse(goodNativeResponse, bidNativeRequest); + const bidNative = goodNativeResponse.body.seatbid[0].bid[0]; + + assert.deepEqual(resultNative[0].currency, goodNativeResponse.body.cur); + assert.deepEqual(resultNative[0].requestId, bidNativeRequest.bidRequests[0].bidId); + assert.deepEqual(resultNative[0].cpm, bidNative.price); + assert.deepEqual(resultNative[0].creativeId, bidNative.crid); + assert.deepEqual(resultNative[0].mediaType, 'native'); + + const resultBanner = spec.interpretResponse(goodBannerResponse, bidBannerRequest); + + assert.deepEqual(resultBanner[0].mediaType, 'banner'); + assert.deepEqual(resultBanner[0].width, bidBannerRequest.bidRequests[0].sizes[0]); + assert.deepEqual(resultBanner[0].height, bidBannerRequest.bidRequests[0].sizes[1]); }); - it('should return the correct tracking links', function () { - const result = spec.interpretResponse(goodResponse, bidRequest); - const bid = goodResponse.body.seatbid[0].bid[0]; + it('should return the correct native tracking links', function () { + const result = spec.interpretResponse(goodNativeResponse, bidNativeRequest); + const bid = goodNativeResponse.body.seatbid[0].bid[0]; const regExpPrice = new RegExp('price=' + bid.price); result[0].native.clickTrackers.forEach(function (clickTracker) { - assert.ok(clickTracker.search(regExpPrice) > -1); + assert.ok(clickTracker.search(regExpPrice) > -1); }); result[0].native.impressionTrackers.forEach(function (impTracker) { - assert.ok(impTracker.search(regExpPrice) > -1); + assert.ok(impTracker.search(regExpPrice) > -1); }); }); + + it('should return the correct banner content', function () { + const result = spec.interpretResponse(goodBannerResponse, bidBannerRequest); + const bid = goodBannerResponse.body.seatbid[0].bid[0]; + const regExpContent = new RegExp(''); + + assert.ok(result[0].ad.search(regExpContent) > -1); + }); }); }); diff --git a/test/spec/modules/seedtagBidAdapter_spec.js b/test/spec/modules/seedtagBidAdapter_spec.js index 1e0dca68d00..fb666e89f73 100644 --- a/test/spec/modules/seedtagBidAdapter_spec.js +++ b/test/spec/modules/seedtagBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { spec, getTimeoutUrl } from 'modules/seedtagBidAdapter.js'; import * as utils from 'src/utils.js'; +import { config } from '../../../src/config.js'; const PUBLISHER_ID = '0000-0000-01'; const ADUNIT_ID = '000000'; @@ -19,86 +20,127 @@ function getSlotConfigs(mediaTypes, params) { bidder: 'seedtag', mediaTypes: mediaTypes, src: 'client', - transactionId: 'd704d006-0d6e-4a09-ad6c-179e7e758096', + ortb2Imp: { + ext: { + tid: 'd704d006-0d6e-4a09-ad6c-179e7e758096', + } + }, adUnitCode: 'adunit-code', }; } -function createVideoSlotConfig(mediaType) { +function createInStreamSlotConfig(mediaType) { return getSlotConfigs(mediaType, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'video', + placement: 'inStream', }); } +const createBannerSlotConfig = (placement, mediatypes) => { + return getSlotConfigs(mediatypes || { banner: {} }, { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + placement, + }); +}; + describe('Seedtag Adapter', function () { describe('isBidRequestValid method', function () { describe('returns true', function () { describe('when banner slot config has all mandatory params', () => { - describe('and placement has the correct value', function () { - const createBannerSlotConfig = (placement) => { - return getSlotConfigs( - { banner: {} }, - { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement, - } + const placements = ['inBanner', 'inImage', 'inScreen', 'inArticle']; + placements.forEach((placement) => { + it(placement + 'should be valid', function () { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig(placement) ); - }; - const placements = [ - 'banner', - 'video', - 'inImage', - 'inScreen', - 'inArticle', - ]; - placements.forEach((placement) => { - it('should be ' + placement, function () { + expect(isBidRequestValid).to.equal(true); + }); + + it( + placement + + ' should be valid when has display and video mediatypes, and video context is outstream', + function () { const isBidRequestValid = spec.isBidRequestValid( - createBannerSlotConfig(placement) + createBannerSlotConfig(placement, { + banner: {}, + video: { + context: 'outstream', + playerSize: [[600, 200]], + }, + }) ); expect(isBidRequestValid).to.equal(true); - }); - }); + } + ); + + it( + placement + + " shouldn't be valid when has display and video mediatypes, and video context is instream", + function () { + const isBidRequestValid = spec.isBidRequestValid( + createBannerSlotConfig(placement, { + banner: {}, + video: { + context: 'instream', + playerSize: [[600, 200]], + }, + }) + ); + expect(isBidRequestValid).to.equal(false); + } + ); }); }); describe('when video slot has all mandatory params', function () { it('should return true, when video context is instream', function () { - const slotConfig = getSlotConfigs( - { - video: { - context: 'instream', - playerSize: [[600, 200]], - }, + const slotConfig = createInStreamSlotConfig({ + video: { + context: 'instream', + playerSize: [[600, 200]], }, - { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: 'video', - } - ); + }); const isBidRequestValid = spec.isBidRequestValid(slotConfig); expect(isBidRequestValid).to.equal(true); }); - - it('should return true, when video context is outstream', function () { + it('should return true, when video context is instream and mediatype is video and banner', function () { + const slotConfig = createInStreamSlotConfig({ + video: { + context: 'instream', + playerSize: [[600, 200]], + }, + banner: {}, + }); + const isBidRequestValid = spec.isBidRequestValid(slotConfig); + expect(isBidRequestValid).to.equal(true); + }); + it('should return false, when video context is instream, but placement is not inStream', function () { const slotConfig = getSlotConfigs( { video: { - context: 'outstream', + context: 'instream', playerSize: [[600, 200]], }, }, { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'video', + placement: 'inBanner', } ); const isBidRequestValid = spec.isBidRequestValid(slotConfig); - expect(isBidRequestValid).to.equal(true); + expect(isBidRequestValid).to.equal(false); + }); + it('should return false, when video context is outstream', function () { + const slotConfig = createInStreamSlotConfig({ + video: { + context: 'outstream', + playerSize: [[600, 200]], + }, + }); + const isBidRequestValid = spec.isBidRequestValid(slotConfig); + expect(isBidRequestValid).to.equal(false); }); }); }); @@ -111,7 +153,7 @@ describe('Seedtag Adapter', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ adUnitId: ADUNIT_ID, - placement: 'banner', + placement: 'inBanner', }) ); expect(isBidRequestValid).to.equal(false); @@ -120,7 +162,7 @@ describe('Seedtag Adapter', function () { const isBidRequestValid = spec.isBidRequestValid( createSlotConfig({ publisherId: PUBLISHER_ID, - placement: 'banner', + placement: 'inBanner', }) ); expect(isBidRequestValid).to.equal(false); @@ -145,47 +187,41 @@ describe('Seedtag Adapter', function () { expect(isBidRequestValid).to.equal(false); }); }); + describe('when video mediaType object is not correct', function () { - function createVideoSlotconfig(mediaType) { - return getSlotConfigs(mediaType, { - publisherId: PUBLISHER_ID, - adUnitId: ADUNIT_ID, - placement: 'video', - }); - } it('is a void object', function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ video: {} }) + createInStreamSlotConfig({ video: {} }) ); expect(isBidRequestValid).to.equal(false); }); it('does not have playerSize.', function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ video: { context: 'instream' } }) + createInStreamSlotConfig({ video: { context: 'instream' } }) ); expect(isBidRequestValid).to.equal(false); }); it('is outstream ', function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ + createInStreamSlotConfig({ video: { context: 'outstream', playerSize: [[600, 200]], }, }) ); - expect(isBidRequestValid).to.equal(true); + expect(isBidRequestValid).to.equal(false); }); describe('order does not matter', function () { it('when video is not the first slot', function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ banner: {}, video: {} }) + createInStreamSlotConfig({ banner: {}, video: {} }) ); expect(isBidRequestValid).to.equal(false); }); it('when video is the first slot', function () { const isBidRequestValid = spec.isBidRequestValid( - createVideoSlotConfig({ video: {}, banner: {} }) + createInStreamSlotConfig({ video: {}, banner: {} }) ); expect(isBidRequestValid).to.equal(false); }); @@ -196,24 +232,30 @@ describe('Seedtag Adapter', function () { describe('buildRequests method', function () { const bidderRequest = { - refererInfo: { referer: 'referer' }, + refererInfo: { page: 'referer' }, timeout: 1000, }; - const mandatoryParams = { + const mandatoryDisplayParams = { publisherId: PUBLISHER_ID, adUnitId: ADUNIT_ID, - placement: 'banner', + placement: 'inBanner', + }; + const mandatoryVideoParams = { + publisherId: PUBLISHER_ID, + adUnitId: ADUNIT_ID, + placement: 'inStream', }; - const inStreamParams = Object.assign({}, mandatoryParams, { - video: { - mimes: 'mp4', - }, - }); const validBidRequests = [ - getSlotConfigs({ banner: {} }, mandatoryParams), + getSlotConfigs({ banner: {} }, mandatoryDisplayParams), getSlotConfigs( - { video: { context: 'instream', playerSize: [[300, 200]] } }, - inStreamParams + { + video: { + context: 'instream', + playerSize: [[300, 200]], + mimes: ['video/mp4'], + }, + }, + mandatoryVideoParams ), ]; it('Url params should be correct ', function () { @@ -223,6 +265,7 @@ describe('Seedtag Adapter', function () { }); it('Common data request should be correct', function () { + const now = Date.now(); const request = spec.buildRequests(validBidRequests, bidderRequest); const data = JSON.parse(request.data); expect(data.url).to.equal('referer'); @@ -231,27 +274,10 @@ describe('Seedtag Adapter', function () { expect( ['fixed', 'mobile', 'unknown'].indexOf(data.connectionType) ).to.be.above(-1); - expect(data.bidRequests[0].adUnitCode).to.equal('adunit-code'); - }); + expect(data.auctionStart).to.be.greaterThanOrEqual(now); + expect(data.ttfb).to.be.greaterThanOrEqual(0); - describe('adPosition param', function () { - it('should sended when publisher set adPosition param', function () { - const params = Object.assign({}, mandatoryParams, { - adPosition: 1, - }); - const validBidRequests = [getSlotConfigs({ banner: {} }, params)]; - const request = spec.buildRequests(validBidRequests, bidderRequest); - const data = JSON.parse(request.data); - expect(data.bidRequests[0].adPosition).to.equal(1); - }); - it('should not sended when publisher has not set adPosition param', function () { - const validBidRequests = [ - getSlotConfigs({ banner: {} }, mandatoryParams), - ]; - const request = spec.buildRequests(validBidRequests, bidderRequest); - const data = JSON.parse(request.data); - expect(data.bidRequests[0].adPosition).to.equal(undefined); - }); + expect(data.bidRequests[0].adUnitCode).to.equal('adunit-code'); }); describe('GDPR params', function () { @@ -288,6 +314,28 @@ describe('Seedtag Adapter', function () { it('should expose gvlid', function () { expect(spec.gvlid).to.equal(157); }); + it('should handle uspConsent', function () { + const uspConsent = '1---'; + + bidderRequest['uspConsent'] = uspConsent; + + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.uspConsent).to.exist; + expect(payload.uspConsent).to.equal(uspConsent); + }); + + it("shouldn't send uspConsent when not available", function () { + const uspConsent = undefined; + + bidderRequest['uspConsent'] = uspConsent; + + const request = spec.buildRequests(validBidRequests, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.uspConsent).to.not.exist; + }); }); }); @@ -317,7 +365,7 @@ describe('Seedtag Adapter', function () { ); expect(videoBid.supplyTypes[0]).to.equal('video'); expect(videoBid.adUnitId).to.equal('000000'); - expect(videoBid.videoParams.mimes).to.equal('mp4'); + expect(videoBid.videoParams.mimes).to.eql(['video/mp4']); expect(videoBid.videoParams.w).to.equal(300); expect(videoBid.videoParams.h).to.equal(200); expect(videoBid.sizes[0][0]).to.equal(300); @@ -327,6 +375,117 @@ describe('Seedtag Adapter', function () { expect(videoBid.requestCount).to.equal(1); }); }); + + describe('COPPA param', function () { + it('should add COPPA param to payload when prebid config has parameter COPPA equal to true', function () { + config.setConfig({ coppa: true }); + + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.coppa).to.equal(true); + }); + + it('should not add COPPA param to payload when prebid config has parameter COPPA equal to false', function () { + config.setConfig({ coppa: false }); + + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.coppa).to.be.undefined; + }); + + it('should not add COPPA param to payload when prebid config has not parameter COPPA', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.coppa).to.be.undefined; + }); + }); + describe('schain param', function () { + it('should add schain to payload when exposed on validBidRequest', function () { + // https://github.com/prebid/Prebid.js/blob/master/modules/schain.md#sample-code-for-passing-the-schain-object + const schain = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1, + }, + + { + asi: 'indirectseller-2.com', + sid: '00002', + hp: 1, + }, + ], + }; + + // duplicate + const bidRequests = JSON.parse(JSON.stringify(validBidRequests)); + bidRequests[0].schain = schain; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + const payload = JSON.parse(request.data); + + expect(payload.schain).to.exist; + expect(payload.schain).to.deep.equal(schain); + }); + + it("shouldn't add schain to payload when not exposed", function () { + const request = spec.buildRequests(validBidRequests, bidderRequest); + + const payload = JSON.parse(request.data); + + expect(payload.schain).to.not.exist; + }); + }); + + describe('GPP param', function () { + it('should be added to payload when bidderRequest has gppConsent param', function () { + const gppConsent = { + gppString: 'someGppString', + applicableSections: [7] + } + bidderRequest['gppConsent'] = gppConsent + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.gppConsent).to.exist; + expect(data.gppConsent.gppString).to.equal(gppConsent.gppString); + expect(data.gppConsent.applicableSections[0]).to.equal(gppConsent.applicableSections[0]); + }); + + it('should be undefined on payload when bidderRequest has not gppConsent param', function () { + bidderRequest.gppConsent = undefined + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.gppConsent).to.be.undefined; + }); + + it('should be added to payload when bidderRequest has ortb2 param', function () { + const ortb2 = { + regs: { + gpp: 'someGppString', + gpp_sid: [7] + } + } + bidderRequest['gppConsent'] = undefined + bidderRequest['ortb2'] = ortb2; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.gppConsent).to.exist; + expect(data.gppConsent.gppString).to.equal(ortb2.regs.gpp); + expect(data.gppConsent.applicableSections[0]).to.equal(ortb2.regs.gpp_sid[0]); + }); + + it('should be added to payload when bidderRequest has neither gppConsent nor ortb2', function () { + bidderRequest['ortb2'] = undefined; + bidderRequest['gppConsent'] = undefined; + const request = spec.buildRequests(validBidRequests, bidderRequest); + const data = JSON.parse(request.data); + expect(data.gppConsent).to.be.undefined; + }); + }); }); describe('interpret response method', function () { @@ -465,11 +624,11 @@ describe('Seedtag Adapter', function () { const timeoutUrl = getTimeoutUrl(timeoutData); expect(timeoutUrl).to.equal( 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + - params.publisherId + - '&adUnitId=' + - params.adUnitId + - '&timeout=' + - timeout + params.publisherId + + '&adUnitId=' + + params.adUnitId + + '&timeout=' + + timeout ); }); @@ -481,11 +640,11 @@ describe('Seedtag Adapter', function () { expect( utils.triggerPixel.calledWith( 'https://s.seedtag.com/se/hb/timeout?publisherToken=' + - params.publisherId + - '&adUnitId=' + - params.adUnitId + - '&timeout=' + - timeout + params.publisherId + + '&adUnitId=' + + params.adUnitId + + '&timeout=' + + timeout ) ).to.equal(true); }); diff --git a/test/spec/modules/shareUserIds_spec.js b/test/spec/modules/shareUserIds_spec.js deleted file mode 100644 index 67e39533fc7..00000000000 --- a/test/spec/modules/shareUserIds_spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import {userIdTargeting} from '../../../modules/userIdTargeting.js'; -import { expect } from 'chai'; - -describe('#userIdTargeting', function() { - let userIds; - let config; - - beforeEach(function() { - userIds = { - tdid: 'my-tdid' - }; - config = { - 'GAM': true, - 'GAM_KEYS': { - 'tdid': 'TD_ID' - } - }; - }); - - it('Do nothing if config is invaild', function() { - let pubads = window.googletag.pubads(); - pubads.clearTargeting(); - pubads.setTargeting('test', ['TEST']); - userIdTargeting(userIds, JSON.stringify(config)); - expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); - }); - - it('all UserIds are passed as is with GAM: true', function() { - let pubads = window.googletag.pubads(); - pubads.clearTargeting(); - pubads.setTargeting('test', ['TEST']); - delete config.GAM_KEYS; - userIdTargeting(userIds, config); - expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); - expect(pubads.getTargeting('tdid')).to.deep.equal(['my-tdid']); - }) - - it('Publisher prefered key-names are used', function() { - let pubads = window.googletag.pubads(); - pubads.clearTargeting(); - pubads.setTargeting('test', ['TEST']); - userIdTargeting(userIds, config); - expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); - expect(pubads.getTargeting('TD_ID')).to.deep.equal(['my-tdid']); - }); - - it('Publisher does not want to pass an id', function() { - let pubads = window.googletag.pubads(); - pubads.clearTargeting(); - pubads.setTargeting('test', ['TEST']); - config.GAM_KEYS.tdid = ''; - userIdTargeting(userIds, config); - expect(pubads.getTargeting('tdid')).to.be.an('array').that.is.empty; - expect(pubads.getTargeting('test')).to.deep.equal(['TEST']); - }); - - it('User Id Targeting is added to googletag queue when GPT is not ready', function() { - let pubads = window.googletag.pubads; - delete window.googletag.pubads; - userIdTargeting(userIds, config); - window.googletag.pubads = pubads; - window.googletag.cmd.map(command => command()); - expect(window.googletag.pubads().getTargeting('TD_ID')).to.deep.equal(['my-tdid']); - }); -}); diff --git a/test/spec/modules/sharedIdSystem_spec.js b/test/spec/modules/sharedIdSystem_spec.js index 8ef34a1599e..fcfbe5f7c3f 100644 --- a/test/spec/modules/sharedIdSystem_spec.js +++ b/test/spec/modules/sharedIdSystem_spec.js @@ -91,50 +91,4 @@ describe('SharedId System', function () { expect(result).to.be.undefined; }); }); - - describe('SharedID System domainOverride', () => { - let sandbox, domain, cookies, rejectCookiesFor; - - beforeEach(() => { - sandbox = sinon.createSandbox(); - sandbox.stub(document, 'domain').get(() => domain); - cookies = {}; - sandbox.stub(storage, 'getCookie').callsFake((key) => cookies[key]); - rejectCookiesFor = null; - sandbox.stub(storage, 'setCookie').callsFake((key, value, expires, sameSite, domain) => { - if (domain !== rejectCookiesFor) { - if (expires != null) { - expires = new Date(expires); - } - if (expires == null || expires > Date.now()) { - cookies[key] = value; - } else { - delete cookies[key]; - } - } - }); - }); - - afterEach(() => { - sandbox.restore(); - }); - - it('should return TLD if cookies can be set there', () => { - domain = 'sub.domain.com'; - rejectCookiesFor = 'com'; - expect(sharedIdSystemSubmodule.domainOverride()).to.equal('domain.com'); - }); - - it('should return undefined when cookies cannot be set', () => { - domain = 'sub.domain.com'; - rejectCookiesFor = 'sub.domain.com'; - expect(sharedIdSystemSubmodule.domainOverride()).to.be.undefined; - }); - - it('should return half-way domain if parent domain rejects cookies', () => { - domain = 'inner.outer.domain.com'; - rejectCookiesFor = 'domain.com'; - expect(sharedIdSystemSubmodule.domainOverride()).to.equal('outer.domain.com'); - }); - }); }); diff --git a/test/spec/modules/sharethroughBidAdapter_spec.js b/test/spec/modules/sharethroughBidAdapter_spec.js index 39238cc877f..68bf14ae9c1 100644 --- a/test/spec/modules/sharethroughBidAdapter_spec.js +++ b/test/spec/modules/sharethroughBidAdapter_spec.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import * as sinon from 'sinon'; import { sharethroughAdapterSpec, sharethroughInternal } from 'modules/sharethroughBidAdapter.js'; +import * as sinon from 'sinon'; import { newBidder } from 'src/adapters/bidderFactory.js'; import { config } from 'src/config'; import * as utils from 'src/utils'; @@ -72,7 +72,11 @@ describe('sharethrough adapter spec', function () { { bidder: 'sharethrough', bidId: 'bidId1', - sizes: [[300, 250], [300, 600]], + transactionId: 'transactionId1', + sizes: [ + [300, 250], + [300, 600], + ], params: { pkey: 'aaaa1111', bcat: ['cat1', 'cat2'], @@ -85,40 +89,114 @@ describe('sharethrough adapter spec', function () { }, ortb2Imp: { ext: { + tid: 'transaction-id-1', + gpid: 'universal-id', data: { - pbadslot: 'universal-id', + pbadslot: 'pbadslot-id', }, }, }, - userId: { - tdid: 'fake-tdid', - pubcid: 'fake-pubcid', - idl_env: 'fake-identity-link', - id5id: { - uid: 'fake-id5id', - ext: { - linkType: 2, - }, + userIdAsEids: [ + { + source: 'pubcid.org', + uids: [ + { + atype: 1, + id: 'fake-pubcid', + }, + ], }, - lipb: { - lipbid: 'fake-lipbid', + { + source: 'liveramp.com', + uids: [ + { + atype: 1, + id: 'fake-identity-link', + }, + ], }, - criteoId: 'fake-criteo', - britepoolid: 'fake-britepool', - intentIqId: 'fake-intentiq', - lotamePanoramaId: 'fake-lotame', - parrableId: { - eid: 'fake-parrable', + { + source: 'id5-sync.com', + uids: [ + { + atype: 1, + id: 'fake-id5id', + }, + ], }, - netId: 'fake-netid', - sharedid: { - id: 'fake-sharedid', + { + source: 'adserver.org', + uids: [ + { + atype: 1, + id: 'fake-tdid', + }, + ], }, - flocId: { - id: 'fake-flocid', - version: '42', + { + source: 'criteo.com', + uids: [ + { + atype: 1, + id: 'fake-criteo', + }, + ], }, - }, + { + source: 'britepool.com', + uids: [ + { + atype: 1, + id: 'fake-britepool', + }, + ], + }, + { + source: 'liveintent.com', + uids: [ + { + atype: 1, + id: 'fake-lipbid', + }, + ], + }, + { + source: 'intentiq.com', + uids: [ + { + atype: 1, + id: 'fake-intentiq', + }, + ], + }, + { + source: 'crwdcntrl.net', + uids: [ + { + atype: 1, + id: 'fake-lotame', + }, + ], + }, + { + source: 'parrable.com', + uids: [ + { + atype: 1, + id: 'fake-parrable', + }, + ], + }, + { + source: 'netid.de', + uids: [ + { + atype: 1, + id: 'fake-netid', + }, + ], + }, + ], crumbs: { pubcid: 'fake-pubcid-in-crumbs-obj', }, @@ -140,6 +218,7 @@ describe('sharethrough adapter spec', function () { bidder: 'sharethrough', bidId: 'bidId2', sizes: [[600, 300]], + transactionId: 'transactionId2', params: { pkey: 'bbbb2222', }, @@ -154,7 +233,7 @@ describe('sharethrough adapter spec', function () { api: [3], mimes: ['video/3gpp'], protocols: [2, 3], - playerSize: [640, 480], + playerSize: [[640, 480]], startdelay: 42, skipmin: 10, skipafter: 20, @@ -170,8 +249,14 @@ describe('sharethrough adapter spec', function () { bidderRequest = { refererInfo: { - referer: 'https://referer.com', + ref: 'https://referer.com', + }, + ortb2: { + source: { + tid: 'auction-id', + }, }, + timeout: 242, }; }); @@ -222,7 +307,6 @@ describe('sharethrough adapter spec', function () { 'crwdcntrl.net': { id: 'fake-lotame' }, 'parrable.com': { id: 'fake-parrable' }, 'netid.de': { id: 'fake-netid' }, - 'chrome.com': { id: 'fake-flocid' }, }; expect(openRtbReq.user.ext.eids).to.be.an('array').that.have.length(Object.keys(expectedEids).length); for (const eid of openRtbReq.user.ext.eids) { @@ -231,9 +315,16 @@ describe('sharethrough adapter spec', function () { expect(eid.uids[0].atype).to.be.ok; } + // expect(openRtbReq.regs.gpp).to.equal(bidderRequest.gppConsent.gppString); + // expect(openRtbReq.regs.gpp_sid).to.equal(bidderRequest.gppConsent.applicableSections); + + // expect(openRtbReq.regs.ext.gpp).to.equal(bidderRequest.ortb2.regs.gpp); + // expect(openRtbReq.regs.ext.gpp_sid).to.equal(bidderRequest.ortb2.regs.gpp_sid); + expect(openRtbReq.device.ua).to.equal(navigator.userAgent); expect(openRtbReq.regs.coppa).to.equal(1); + expect(openRtbReq.source.tid).to.equal(bidderRequest.ortb2.source.tid); expect(openRtbReq.source.ext.version).not.to.be.undefined; expect(openRtbReq.source.ext.str).not.to.be.undefined; expect(openRtbReq.source.ext.schain).to.deep.equal(bidRequests[0].schain); @@ -313,6 +404,34 @@ describe('sharethrough adapter spec', function () { expect(openRtbReq.regs.coppa).to.equal(0); }); }); + + describe('gpp', () => { + it('should properly attach GPP information to the request when applicable', () => { + bidderRequest.gppConsent = { + gppString: 'some-gpp-string', + applicableSections: [3, 5] + }; + + const openRtbReq = spec.buildRequests(bidRequests, bidderRequest)[0].data; + expect(openRtbReq.regs.gpp).to.equal(bidderRequest.gppConsent.gppString) + expect(openRtbReq.regs.gpp_sid).to.equal(bidderRequest.gppConsent.applicableSections) + }); + + it('should populate request accordingly when gpp explicitly does not apply', function () { + const openRtbReq = spec.buildRequests(bidRequests, {})[0].data; + + expect(openRtbReq.regs.gpp).to.be.undefined; + }); + }); + }); + + describe('transaction id at the impression level', () => { + it('should include transaction id when provided', () => { + const requests = spec.buildRequests(bidRequests, bidderRequest); + + expect(requests[0].data.imp[0].ext.tid).to.equal('transaction-id-1'); + expect(requests[1].data.imp[0].ext).to.be.empty; + }); }); describe('universal id', () => { @@ -320,7 +439,14 @@ describe('sharethrough adapter spec', function () { const requests = spec.buildRequests(bidRequests, bidderRequest); expect(requests[0].data.imp[0].ext.gpid).to.equal('universal-id'); - expect(requests[1].data.imp[0].ext).to.be.undefined; + expect(requests[1].data.imp[0].ext).to.be.empty; + }); + + it('should include gpid when pbadslot is provided without universal id', () => { + delete bidRequests[0].ortb2Imp.ext.gpid; + const requests = spec.buildRequests(bidRequests, bidderRequest); + + expect(requests[0].data.imp[0].ext.gpid).to.equal('pbadslot-id'); }); }); @@ -357,7 +483,10 @@ describe('sharethrough adapter spec', function () { const bannerImp = builtRequest.data.imp[0].banner; expect(bannerImp.pos).to.equal(1); expect(bannerImp.topframe).to.equal(1); - expect(bannerImp.format).to.deep.equal([{ w: 300, h: 250 }, { w: 300, h: 600 }]); + expect(bannerImp.format).to.deep.equal([ + { w: 300, h: 250 }, + { w: 300, h: 600 }, + ]); }); it('should default to pos 0 if not provided', () => { @@ -485,21 +614,16 @@ describe('sharethrough adapter spec', function () { }, }, }, + bcat: ['IAB1', 'IAB2-1'], + badv: ['domain1.com', 'domain2.com'], + regs: { + gpp: 'gpp_string', + gpp_sid: [7] + }, }; - let configStub; - - beforeEach(() => { - configStub = sinon.stub(config, 'getConfig'); - configStub.withArgs('ortb2').returns(firstPartyData); - }); - - afterEach(() => { - configStub.restore(); - }); - it('should include first party data in open rtb request, site section', () => { - const openRtbReq = spec.buildRequests(bidRequests, bidderRequest)[0].data; + const openRtbReq = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2: firstPartyData })[0].data; expect(openRtbReq.site.name).to.equal(firstPartyData.site.name); expect(openRtbReq.site.keywords).to.equal(firstPartyData.site.keywords); @@ -509,13 +633,27 @@ describe('sharethrough adapter spec', function () { }); it('should include first party data in open rtb request, user section', () => { - const openRtbReq = spec.buildRequests(bidRequests, bidderRequest)[0].data; + const openRtbReq = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2: firstPartyData })[0].data; expect(openRtbReq.user.yob).to.equal(firstPartyData.user.yob); expect(openRtbReq.user.gender).to.equal(firstPartyData.user.gender); expect(openRtbReq.user.ext.data).to.deep.equal(firstPartyData.user.ext.data); expect(openRtbReq.user.ext.eids).not.to.be.undefined; }); + + it('should include first party data in open rtb request, ORTB blocked section', () => { + const openRtbReq = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2: firstPartyData })[0].data; + + expect(openRtbReq.bcat).to.deep.equal(firstPartyData.bcat); + expect(openRtbReq.badv).to.deep.equal(firstPartyData.badv); + }); + + it('should include first party data in open rtb request, regulation section', () => { + const openRtbReq = spec.buildRequests(bidRequests, { ...bidderRequest, ortb2: firstPartyData })[0].data; + + expect(openRtbReq.regs.ext.gpp).to.equal(firstPartyData.regs.gpp); + expect(openRtbReq.regs.ext.gpp_sid).to.equal(firstPartyData.regs.gpp_sid); + }); }); }); @@ -528,26 +666,31 @@ describe('sharethrough adapter spec', function () { request = spec.buildRequests(bidRequests, bidderRequest)[0]; response = { body: { - seatbid: [{ - bid: [{ - id: '123', - impid: 'bidId1', - w: 300, - h: 250, - price: 42, - crid: 'creative', - dealid: 'deal', - adomain: ['domain.com'], - adm: 'markup', - }, { - id: '456', - impid: 'bidId2', - w: 640, - h: 480, - price: 42, - adm: 'vastTag', - }], - }], + seatbid: [ + { + bid: [ + { + id: '123', + impid: 'bidId1', + w: 300, + h: 250, + price: 42, + crid: 'creative', + dealid: 'deal', + adomain: ['domain.com'], + adm: 'markup', + }, + { + id: '456', + impid: 'bidId2', + w: 640, + h: 480, + price: 42, + adm: 'vastTag', + }, + ], + }, + ], }, }; }); @@ -577,16 +720,20 @@ describe('sharethrough adapter spec', function () { request = spec.buildRequests(bidRequests, bidderRequest)[1]; response = { body: { - seatbid: [{ - bid: [{ - id: '456', - impid: 'bidId2', - w: 640, - h: 480, - price: 42, - adm: 'vastTag', - }], - }], + seatbid: [ + { + bid: [ + { + id: '456', + impid: 'bidId2', + w: 640, + h: 480, + price: 42, + adm: 'vastTag', + }, + ], + }, + ], }, }; }); @@ -610,6 +757,85 @@ describe('sharethrough adapter spec', function () { expect(bannerBid.vastXml).to.equal('vastTag'); }); }); + + describe('meta object', () => { + beforeEach(() => { + request = spec.buildRequests(bidRequests, bidderRequest)[0]; + response = { + body: { + seatbid: [ + { + bid: [ + { + id: '123', + impid: 'bidId1', + w: 300, + h: 250, + price: 42, + crid: 'creative', + dealid: 'deal', + adomain: ['domain.com'], + adm: 'markup', + }, + ], + }, + ], + }, + }; + }); + + it("should have null optional fields when the response's optional seatbid[].bid[].ext field is empty", () => { + const bid = spec.interpretResponse(response, request)[0]; + + expect(bid.meta.networkId).to.be.null; + expect(bid.meta.networkName).to.be.null; + expect(bid.meta.agencyId).to.be.null; + expect(bid.meta.agencyName).to.be.null; + expect(bid.meta.advertiserId).to.be.null; + expect(bid.meta.advertiserName).to.be.null; + expect(bid.meta.brandId).to.be.null; + expect(bid.meta.brandName).to.be.null; + expect(bid.meta.demandSource).to.be.null; + expect(bid.meta.dchain).to.be.null; + expect(bid.meta.primaryCatId).to.be.null; + expect(bid.meta.secondaryCatIds).to.be.null; + expect(bid.meta.mediaType).to.be.null; + }); + + it("should have populated fields when the response's optional seatbid[].bid[].ext fields are filled", () => { + response.body.seatbid[0].bid[0].ext = { + networkId: 'my network id', + networkName: 'my network name', + agencyId: 'my agency id', + agencyName: 'my agency name', + advertiserId: 'my advertiser id', + advertiserName: 'my advertiser name', + brandId: 'my brand id', + brandName: 'my brand name', + demandSource: 'my demand source', + dchain: { 'my key': 'my value' }, + primaryCatId: 'my primary cat id', + secondaryCatIds: ['my', 'secondary', 'cat', 'ids'], + mediaType: 'my media type', + }; + + const bid = spec.interpretResponse(response, request)[0]; + + expect(bid.meta.networkId).to.equal('my network id'); + expect(bid.meta.networkName).to.equal('my network name'); + expect(bid.meta.agencyId).to.equal('my agency id'); + expect(bid.meta.agencyName).to.equal('my agency name'); + expect(bid.meta.advertiserId).to.equal('my advertiser id'); + expect(bid.meta.advertiserName).to.equal('my advertiser name'); + expect(bid.meta.brandId).to.equal('my brand id'); + expect(bid.meta.brandName).to.equal('my brand name'); + expect(bid.meta.demandSource).to.equal('my demand source'); + expect(bid.meta.dchain).to.deep.equal({ 'my key': 'my value' }); + expect(bid.meta.primaryCatId).to.equal('my primary cat id'); + expect(bid.meta.secondaryCatIds).to.deep.equal(['my', 'secondary', 'cat', 'ids']); + expect(bid.meta.mediaType).to.equal('my media type'); + }); + }); }); describe('getUserSyncs', function () { @@ -617,12 +843,12 @@ describe('sharethrough adapter spec', function () { const serverResponses = [{ body: { cookieSyncUrls: cookieSyncs } }]; it('returns an array of correctly formatted user syncs', function () { - const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, null, 'fake-privacy-signal'); + const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses); expect(syncArray).to.deep.equal([ - { type: 'image', url: 'cookieUrl1&us_privacy=fake-privacy-signal' }, - { type: 'image', url: 'cookieUrl2&us_privacy=fake-privacy-signal' }, - { type: 'image', url: 'cookieUrl3&us_privacy=fake-privacy-signal' }], - ); + { type: 'image', url: 'cookieUrl1' }, + { type: 'image', url: 'cookieUrl2' }, + { type: 'image', url: 'cookieUrl3' }, + ]); }); it('returns an empty array if serverResponses is empty', function () { @@ -644,6 +870,25 @@ describe('sharethrough adapter spec', function () { const syncArray = spec.getUserSyncs({ pixelEnabled: false }, serverResponses); expect(syncArray).to.be.an('array').that.is.empty; }); + + it('returns GDPR Consent Params in UserSync url', function () { + const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, { gdprApplies: true, + consentString: 'consent' }); + expect(syncArray).to.deep.equal([ + { type: 'image', url: 'cookieUrl1&gdpr=1&gdpr_consent=consent' }, + { type: 'image', url: 'cookieUrl2&gdpr=1&gdpr_consent=consent' }, + { type: 'image', url: 'cookieUrl3&gdpr=1&gdpr_consent=consent' }, + ]); + }); + + it('returns GPP Consent Params in UserSync url', function () { + const syncArray = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, {}, {gppString: 'gpp-string', applicableSections: [1, 2]}); + expect(syncArray).to.deep.equal([ + { type: 'image', url: 'cookieUrl1&gdpr=0&gdpr_consent=&gpp=gpp-string&gpp_sid=1%2C2' }, + { type: 'image', url: 'cookieUrl2&gdpr=0&gdpr_consent=&gpp=gpp-string&gpp_sid=1%2C2' }, + { type: 'image', url: 'cookieUrl3&gdpr=0&gdpr_consent=&gpp=gpp-string&gpp_sid=1%2C2' }, + ]); + }); }); }); }); diff --git a/test/spec/modules/shinezBidAdapter_spec.js b/test/spec/modules/shinezBidAdapter_spec.js new file mode 100644 index 00000000000..4e6c2d3420e --- /dev/null +++ b/test/spec/modules/shinezBidAdapter_spec.js @@ -0,0 +1,479 @@ +import { expect } from 'chai'; +import { spec } from 'modules/shinezBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { config } from 'src/config.js'; +import { BANNER, VIDEO } from '../../../src/mediaTypes.js'; +import * as utils from 'src/utils.js'; + +const ENDPOINT = 'https://hb.sweetgum.io/hb-sz-multi'; +const TEST_ENDPOINT = 'https://hb.sweetgum.io/hb-multi-sz-test'; +const TTL = 360; +/* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */ + +describe('shinezAdapter', function () { + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + const bid = { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [['640', '480']], + 'params': { + 'org': 'jdye8weeyirk00000001' + } + }; + + it('should return true when required params are passed', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not found', function () { + const newBid = Object.assign({}, bid); + delete newBid.params; + newBid.params = { + 'org': null + }; + expect(spec.isBidRequestValid(newBid)).to.equal(false); + }); + }); + + describe('buildRequests', function () { + const bidRequests = [ + { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [[640, 480]], + 'params': { + 'org': 'jdye8weeyirk00000001' + }, + 'bidId': '299ffc8cca0b87', + 'bidderRequestId': '1144f487e563f9', + 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', + 'mediaTypes': { + 'video': { + 'playerSize': [[640, 480]], + 'context': 'instream' + } + }, + 'vastXml': '"..."' + }, + { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'params': { + 'org': 'jdye8weeyirk00000001' + }, + 'bidId': '299ffc8cca0b87', + 'bidderRequestId': '1144f487e563f9', + 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', + 'mediaTypes': { + 'banner': { + } + }, + 'ad': '""' + } + ]; + + const testModeBidRequests = [ + { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [[640, 480]], + 'params': { + 'org': 'jdye8weeyirk00000001', + 'testMode': true + }, + 'bidId': '299ffc8cca0b87', + 'bidderRequestId': '1144f487e563f9', + 'auctionId': 'bfc420c3-8577-4568-9766-a8a935fb620d', + } + ]; + + const bidderRequest = { + bidderCode: 'shinez', + } + const placementId = '12345678'; + + it('sends the placementId to ENDPOINT via POST', function () { + bidRequests[0].params.placementId = placementId; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].placementId).to.equal(placementId); + }); + + it('sends bid request to ENDPOINT via POST', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.url).to.equal(ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('sends bid request to TEST ENDPOINT via POST', function () { + const request = spec.buildRequests(testModeBidRequests, bidderRequest); + expect(request.url).to.equal(TEST_ENDPOINT); + expect(request.method).to.equal('POST'); + }); + + it('should send the correct bid Id', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].bidId).to.equal('299ffc8cca0b87'); + }); + + it('should send the correct sizes array', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].sizes).to.be.an('array'); + expect(request.data.bids[0].sizes).to.equal(bidRequests[0].sizes) + expect(request.data.bids[1].sizes).to.be.an('array'); + expect(request.data.bids[1].sizes).to.equal(bidRequests[1].sizes) + }); + + it('should send the correct media type', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.bids[0].mediaType).to.equal(VIDEO) + expect(request.data.bids[1].mediaType).to.equal(BANNER) + }); + + it('should respect syncEnabled option', function() { + config.setConfig({ + userSync: { + syncEnabled: false, + filterSettings: { + all: { + bidders: '*', + filter: 'include' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('cs_method'); + }); + + it('should respect "iframe" filter settings', function () { + config.setConfig({ + userSync: { + syncEnabled: true, + filterSettings: { + iframe: { + bidders: [spec.code], + filter: 'include' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('cs_method', 'iframe'); + }); + + it('should respect "all" filter settings', function () { + config.setConfig({ + userSync: { + syncEnabled: true, + filterSettings: { + all: { + bidders: [spec.code], + filter: 'include' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('cs_method', 'iframe'); + }); + + it('should send the pixel user sync param if userSync is enabled and no "iframe" or "all" configs are present', function () { + config.resetConfig(); + config.setConfig({ + userSync: { + syncEnabled: true, + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('cs_method', 'pixel'); + }); + + it('should respect total exclusion', function() { + config.setConfig({ + userSync: { + syncEnabled: true, + filterSettings: { + image: { + bidders: [spec.code], + filter: 'exclude' + }, + iframe: { + bidders: [spec.code], + filter: 'exclude' + } + } + } + }); + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('cs_method'); + }); + + it('should have us_privacy param if usPrivacy is available in the bidRequest', function () { + const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('us_privacy', '1YNN'); + }); + + it('should have an empty us_privacy param if usPrivacy is missing in the bidRequest', function () { + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('us_privacy'); + }); + + it('should not send the gdpr param if gdprApplies is false in the bidRequest', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: false}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.not.have.property('gdpr'); + expect(request.data.params).to.not.have.property('gdpr_consent'); + }); + + it('should send the gdpr param if gdprApplies is true in the bidRequest', function () { + const bidderRequestWithGDPR = Object.assign({gdprConsent: {gdprApplies: true, consentString: 'test-consent-string'}}, bidderRequest); + const request = spec.buildRequests(bidRequests, bidderRequestWithGDPR); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('gdpr', true); + expect(request.data.params).to.have.property('gdpr_consent', 'test-consent-string'); + }); + + it('should have schain param if it is available in the bidRequest', () => { + const schain = { + ver: '1.0', + complete: 1, + nodes: [{ asi: 'indirectseller.com', sid: '00001', hp: 1 }], + }; + bidRequests[0].schain = schain; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request.data.params).to.be.an('object'); + expect(request.data.params).to.have.property('schain', '1.0,1!indirectseller.com,00001,1,,,'); + }); + + it('should set flooPrice to getFloor.floor value if it is greater than params.floorPrice', function() { + const bid = utils.deepClone(bidRequests[0]); + bid.getFloor = () => { + return { + currency: 'USD', + floor: 3.32 + } + } + bid.params.floorPrice = 0.64; + const request = spec.buildRequests([bid], bidderRequest); + expect(request.data.bids[0]).to.be.an('object'); + expect(request.data.bids[0]).to.have.property('floorPrice', 3.32); + }); + + it('should set floorPrice to params.floorPrice value if it is greater than getFloor.floor', function() { + const bid = utils.deepClone(bidRequests[0]); + bid.getFloor = () => { + return { + currency: 'USD', + floor: 0.8 + } + } + bid.params.floorPrice = 1.5; + const request = spec.buildRequests([bid], bidderRequest); + expect(request.data.bids[0]).to.be.an('object'); + expect(request.data.bids[0]).to.have.property('floorPrice', 1.5); + }); + }); + + describe('interpretResponse', function () { + const response = { + params: { + currency: 'USD', + netRevenue: true, + }, + bids: [{ + cpm: 12.5, + vastXml: '', + width: 640, + height: 480, + requestId: '21e12606d47ba7', + adomain: ['abc.com'], + mediaType: VIDEO + }, + { + cpm: 12.5, + ad: '""', + width: 300, + height: 250, + requestId: '21e12606d47ba7', + adomain: ['abc.com'], + mediaType: BANNER + }] + }; + + const expectedVideoResponse = { + requestId: '21e12606d47ba7', + cpm: 12.5, + currency: 'USD', + width: 640, + height: 480, + ttl: TTL, + creativeId: '21e12606d47ba7', + netRevenue: true, + nurl: 'http://example.com/win/1234', + mediaType: VIDEO, + meta: { + mediaType: VIDEO, + advertiserDomains: ['abc.com'] + }, + vastXml: '', + }; + + const expectedBannerResponse = { + requestId: '21e12606d47ba7', + cpm: 12.5, + currency: 'USD', + width: 640, + height: 480, + ttl: TTL, + creativeId: '21e12606d47ba7', + netRevenue: true, + nurl: 'http://example.com/win/1234', + mediaType: BANNER, + meta: { + mediaType: BANNER, + advertiserDomains: ['abc.com'] + }, + ad: '""' + }; + + it('should get correct bid response', function () { + const result = spec.interpretResponse({ body: response }); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedVideoResponse)); + expect(Object.keys(result[1])).to.deep.equal(Object.keys(expectedBannerResponse)); + }); + + it('video type should have vastXml key', function () { + const result = spec.interpretResponse({ body: response }); + expect(result[0].vastXml).to.equal(expectedVideoResponse.vastXml) + }); + + it('banner type should have ad key', function () { + const result = spec.interpretResponse({ body: response }); + expect(result[1].ad).to.equal(expectedBannerResponse.ad) + }); + }) + + describe('getUserSyncs', function() { + const imageSyncResponse = { + body: { + params: { + userSyncPixels: [ + 'https://image-sync-url.test/1', + 'https://image-sync-url.test/2', + 'https://image-sync-url.test/3' + ] + } + } + }; + + const iframeSyncResponse = { + body: { + params: { + userSyncURL: 'https://iframe-sync-url.test' + } + } + }; + + it('should register all img urls from the response', function() { + const syncs = spec.getUserSyncs({ pixelEnabled: true }, [imageSyncResponse]); + expect(syncs).to.deep.equal([ + { + type: 'image', + url: 'https://image-sync-url.test/1' + }, + { + type: 'image', + url: 'https://image-sync-url.test/2' + }, + { + type: 'image', + url: 'https://image-sync-url.test/3' + } + ]); + }); + + it('should register the iframe url from the response', function() { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, [iframeSyncResponse]); + expect(syncs).to.deep.equal([ + { + type: 'iframe', + url: 'https://iframe-sync-url.test' + } + ]); + }); + + it('should register both image and iframe urls from the responses', function() { + const syncs = spec.getUserSyncs({ pixelEnabled: true, iframeEnabled: true }, [iframeSyncResponse, imageSyncResponse]); + expect(syncs).to.deep.equal([ + { + type: 'iframe', + url: 'https://iframe-sync-url.test' + }, + { + type: 'image', + url: 'https://image-sync-url.test/1' + }, + { + type: 'image', + url: 'https://image-sync-url.test/2' + }, + { + type: 'image', + url: 'https://image-sync-url.test/3' + } + ]); + }); + + it('should handle an empty response', function() { + const syncs = spec.getUserSyncs({ iframeEnabled: true }, []); + expect(syncs).to.deep.equal([]); + }); + + it('should handle when user syncs are disabled', function() { + const syncs = spec.getUserSyncs({ pixelEnabled: false }, [imageSyncResponse]); + expect(syncs).to.deep.equal([]); + }); + }) + + describe('onBidWon', function() { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + + it('Should trigger pixel if bid nurl', function() { + const bid = { + 'bidder': spec.code, + 'adUnitCode': 'adunit-code', + 'sizes': [['640', '480']], + 'nurl': 'http://example.com/win/1234', + 'params': { + 'org': 'jdye8weeyirk00000001' + } + }; + + spec.onBidWon(bid); + expect(utils.triggerPixel.callCount).to.equal(1) + }) + }) +}); diff --git a/test/spec/modules/showheroes-bsBidAdapter_spec.js b/test/spec/modules/showheroes-bsBidAdapter_spec.js index 69e8343dfc9..30e95b04ccf 100644 --- a/test/spec/modules/showheroes-bsBidAdapter_spec.js +++ b/test/spec/modules/showheroes-bsBidAdapter_spec.js @@ -5,7 +5,7 @@ import {VIDEO, BANNER} from 'src/mediaTypes.js' const bidderRequest = { refererInfo: { - referer: 'https://example.com' + canonicalUrl: 'https://example.com' } } @@ -19,6 +19,8 @@ const gdpr = { } } +const uspConsent = '1---'; + const schain = { 'schain': { 'validation': 'strict', @@ -48,6 +50,18 @@ const bidRequestCommonParams = { 'auctionId': '43aa080090a47f', } +const bidRequestCommonParamsV2 = { + 'bidder': 'showheroes-bs', + 'params': { + 'unitId': 'AACBWAcof-611K4U', + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[640, 480]], + 'bidId': '38b373e1e31c18', + 'bidderRequestId': '12e3ade2543ba6', + 'auctionId': '43aa080090a47f', +} + const bidRequestVideo = { ...bidRequestCommonParams, ...{ @@ -72,6 +86,30 @@ const bidRequestOutstream = { } } +const bidRequestVideoV2 = { + ...bidRequestCommonParamsV2, + ...{ + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream', + } + } + } +} + +const bidRequestOutstreamV2 = { + ...bidRequestCommonParamsV2, + ...{ + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'outstream' + } + } + } +} + const bidRequestVideoVpaid = { ...bidRequestCommonParams, ...{ @@ -129,12 +167,19 @@ describe('shBidAdapter', function () { describe('isBidRequestValid', function () { it('should return true when required params found', function () { - const request = { + const requestV1 = { 'params': { 'playerId': '47427aa0-f11a-4d24-abca-1295a46a46cd', } } - expect(spec.isBidRequestValid(request)).to.equal(true) + expect(spec.isBidRequestValid(requestV1)).to.equal(true) + + const requestV2 = { + 'params': { + 'unitId': 'AACBTwsZVANd9NlB', + } + } + expect(spec.isBidRequestValid(requestV2)).to.equal(true) }) it('should return false when required params are not passed', function () { @@ -149,6 +194,9 @@ describe('shBidAdapter', function () { it('sends bid request to ENDPOINT via POST', function () { const request = spec.buildRequests([bidRequestVideo], bidderRequest) expect(request.method).to.equal('POST') + + const requestV2 = spec.buildRequests([bidRequestVideoV2], bidderRequest) + expect(requestV2.method).to.equal('POST') }) it('check sizes formats', function () { @@ -268,11 +316,52 @@ describe('shBidAdapter', function () { expect(payload2).to.have.property('type', 5); }) - it('passes gdpr if present', function () { - const request = spec.buildRequests([bidRequestVideo], {...bidderRequest, ...gdpr}) + it('should attach valid params to the payload when type is video (instream V2)', function () { + const request = spec.buildRequests([bidRequestVideoV2], bidderRequest) + const payload = request.data.bidRequests[0]; + expect(payload).to.be.an('object'); + expect(payload).to.have.property('unitId', 'AACBWAcof-611K4U'); + expect(payload.mediaTypes).to.eql({ + [VIDEO]: { + 'context': 'instream' + } + }); + }) + + it('should attach valid params to the payload when type is video (outstream V2)', function () { + const request = spec.buildRequests([bidRequestOutstreamV2], bidderRequest) + const payload = request.data.bidRequests[0]; + expect(payload).to.be.an('object'); + expect(payload).to.have.property('unitId', 'AACBWAcof-611K4U'); + expect(payload.mediaTypes).to.eql({ + [VIDEO]: { + 'context': 'outstream' + } + }); + }) + + it('passes gdpr & uspConsent if present', function () { + const request = spec.buildRequests([bidRequestVideo], { + ...bidderRequest, + ...gdpr, + uspConsent, + }) const payload = request.data.requests[0]; expect(payload).to.be.an('object'); expect(payload.gdprConsent).to.eql(gdpr.gdprConsent) + expect(payload.uspConsent).to.eql(uspConsent) + }) + + it('passes gdpr & usp if present (V2)', function () { + const request = spec.buildRequests([bidRequestVideoV2], { + ...bidderRequest, + ...gdpr, + uspConsent, + }) + const context = request.data.context; + expect(context).to.be.an('object'); + expect(context.gdprConsent).to.eql(gdpr.gdprConsent) + expect(context.uspConsent).to.eql(uspConsent) }) it('passes schain object if present', function() { @@ -284,6 +373,16 @@ describe('shBidAdapter', function () { expect(payload).to.be.an('object'); expect(payload.schain).to.eql(schain.schain); }) + + it('passes schain object if present (V2)', function() { + const request = spec.buildRequests([{ + ...bidRequestVideoV2, + ...schain + }], bidderRequest) + const context = request.data.context; + expect(context).to.be.an('object'); + expect(context.schain).to.eql(schain.schain); + }) }) describe('interpretResponse', function () { @@ -292,7 +391,7 @@ describe('shBidAdapter', function () { expect(spec.interpretResponse({body: []}, {data: {meta: {}}}).length).to.equal(0) }) - const vastTag = 'https://video-library.stage.showheroes.com/commercial/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6' + const vastTag = 'https://test.com/commercial/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6' const vastXml = '' const basicResponse = { @@ -302,7 +401,7 @@ describe('shBidAdapter', function () { 'context': 'instream', 'bidId': '38b373e1e31c18', 'size': {'width': 640, 'height': 480}, - 'vastTag': 'https:\/\/video-library.stage.showheroes.com\/commercial\/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6', + 'vastTag': 'https:\/\/test.com\/commercial\/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6', 'vastXml': vastXml, 'adomain': adomain, }; @@ -327,6 +426,39 @@ describe('shBidAdapter', function () { }], }; + const basicResponseV2 = { + 'requestId': '38b373e1e31c18', + 'adUnitCode': 'adunit-code-1', + 'cpm': 1, + 'currency': 'EUR', + 'width': 640, + 'height': 480, + 'advertiserDomain': [], + 'callbacks': { + 'won': ['https://test.com/track/?ver=15&session_id=01ecd03ce381505ccdeb88e555b05001&category=request_session&type=event&request_session_id=01ecd03ce381505ccdeb88e555b05001&label=prebid_won&reason=ok'] + }, + 'mediaType': 'video', + 'adomain': adomain, + }; + + const vastUrl = 'https://test.com/vast/?zid=AACBWAcof-611K4U&u=https://example.org/?foo=bar&gdpr=0&cs=XXXXXXXXXXXXXXXXXXXX&sid=01ecd03ce381505ccdeb88e555b05001&width=300&height=200&prebidmode=1' + + const responseVideoV2 = { + 'bidResponses': [{ + ...basicResponseV2, + 'context': 'instream', + 'vastUrl': vastUrl, + }], + }; + + const responseVideoOutstreamV2 = { + 'bidResponses': [{ + ...basicResponseV2, + 'context': 'outstream', + 'ad': '', + }], + }; + it('should get correct bid response when type is video', function () { const request = spec.buildRequests([bidRequestVideo], bidderRequest) const expectedResponse = [ @@ -356,6 +488,31 @@ describe('shBidAdapter', function () { expect(result).to.deep.equal(expectedResponse) }) + it('should get correct bid response when type is video (V2)', function () { + const request = spec.buildRequests([bidRequestVideoV2], bidderRequest) + const expectedResponse = [ + { + 'cpm': 1, + 'creativeId': 'c_38b373e1e31c18', + 'adUnitCode': 'adunit-code-1', + 'currency': 'EUR', + 'width': 640, + 'height': 480, + 'mediaType': 'video', + 'netRevenue': true, + 'vastUrl': vastUrl, + 'requestId': '38b373e1e31c18', + 'ttl': 300, + 'meta': { + 'advertiserDomains': adomain + } + } + ] + + const result = spec.interpretResponse({'body': responseVideoV2}, request) + expect(result).to.deep.equal(expectedResponse) + }) + it('should get correct bid response when type is banner', function () { const request = spec.buildRequests([bidRequestBanner], bidderRequest) @@ -388,14 +545,36 @@ describe('shBidAdapter', function () { expect(renderer.config.vastUrl).to.equal(vastTag) renderer.render(bid) - // TODO: fix these. our tests should not be reliant on third-party scripts. wtf - // const scripts = document.querySelectorAll('script[src="https://static.showheroes.com/publishertag.js"]') - // expect(scripts.length).to.equal(1) - const spots = document.querySelectorAll('.showheroes-spot') expect(spots.length).to.equal(1) }) + it('should get correct bid response when type is outstream (slot V2)', function () { + const bidRequestV2 = JSON.parse(JSON.stringify(bidRequestOutstreamV2)); + const slotId = 'testSlot2' + bidRequestV2.params.outstreamOptions = { + slot: slotId + } + + const container = document.createElement('div') + container.setAttribute('id', slotId) + document.body.appendChild(container) + + const request = spec.buildRequests([bidRequestV2], bidderRequest) + + const result = spec.interpretResponse({'body': responseVideoOutstreamV2}, request) + const bid = result[0] + expect(bid).to.have.property('mediaType', VIDEO); + + const renderer = bid.renderer + expect(renderer).to.be.an('object') + expect(renderer.id).to.equal(bidRequestV2.bidId) + renderer.render(bid) + + const scripts = container.querySelectorAll('#testScript') + expect(scripts.length).to.equal(1) + }) + it('should get correct bid response when type is outstream (iframe)', function () { const bidRequest = JSON.parse(JSON.stringify(bidRequestOutstream)); const slotId = 'testIframe' @@ -419,8 +598,6 @@ describe('shBidAdapter', function () { renderer.render(bid) const iframeDocument = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document) - // const scripts = iframeDocument.querySelectorAll('script[src="https://static.showheroes.com/publishertag.js"]') - // expect(scripts.length).to.equal(1) const spots = iframeDocument.querySelectorAll('.showheroes-spot') expect(spots.length).to.equal(1) }) @@ -431,8 +608,6 @@ describe('shBidAdapter', function () { customRender: function (bid, embedCode) { const container = document.createElement('div') container.appendChild(embedCode) - // const scripts = container.querySelectorAll('script[src="https://static.showheroes.com/publishertag.js"]') - // expect(scripts.length).to.equal(1) const spots = container.querySelectorAll('.showheroes-spot') expect(spots.length).to.equal(1) diff --git a/test/spec/modules/sigmoidAnalyticsAdapter_spec.js b/test/spec/modules/sigmoidAnalyticsAdapter_spec.js index 854c3a8e22d..6cdc3c448b9 100644 --- a/test/spec/modules/sigmoidAnalyticsAdapter_spec.js +++ b/test/spec/modules/sigmoidAnalyticsAdapter_spec.js @@ -1,5 +1,7 @@ import sigmoidAnalytic from 'modules/sigmoidAnalyticsAdapter.js'; -import { expect } from 'chai'; +import {expect} from 'chai'; +import {expectEvents} from '../../helpers/analytics.js'; + let events = require('src/events'); let adapterManager = require('src/adapterManager').default; let constants = require('src/constants.json'); @@ -32,13 +34,7 @@ describe('sigmoid Prebid Analytic', function () { } }); - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - - sinon.assert.callCount(sigmoidAnalytic.track, 7); + expectEvents().to.beTrackedBy(sigmoidAnalytic.track); }); }); describe('build utm tag data', function () { diff --git a/test/spec/modules/silverpushBidAdapter_spec.js b/test/spec/modules/silverpushBidAdapter_spec.js new file mode 100644 index 00000000000..de31135eabe --- /dev/null +++ b/test/spec/modules/silverpushBidAdapter_spec.js @@ -0,0 +1,394 @@ +import { expect } from 'chai'; +import * as utils from 'src/utils'; +import { newBidder } from 'src/adapters/bidderFactory.js'; +import { REQUEST_URL, SP_OUTSTREAM_PLAYER_URL, CONVERTER, spec } from '../../../modules/silverpushBidAdapter.js'; + +const bannerBid = { + bidder: 'silverpush', + params: { + publisherId: '012345', + bidFloor: 1.5 + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 50], + ], + }, + }, + adUnitCode: 'div-gpt-ad-928572628472-0', + bidId: 'dl38fjf9d', + bidderRequestId: 'brid00000000', + auctionId: 'aucid0000000', +}; + +const videoBid = { + bidder: 'silverpush', + params: { + publisherId: '012345', + bidFloor: 0.1 + }, + mediaTypes: { + video: { + api: [1, 2, 4, 6], + mimes: ['video/mp4'], + playbackmethod: [2, 4, 6], + playerSize: [[1024, 768]], + protocols: [3, 4, 7, 8, 10], + placement: 1, + minduration: 0, + maxduration: 60, + startdelay: 0 + }, + }, + adUnitCode: 'div-gpt-ad-928572628472-1', + bidId: '281141d3541362', + bidderRequestId: 'brid00000000', + auctionId: 'aucid0000000', +}; + +const bidderRequest = { + auctionId: 'aucid0000000', + bidderRequestId: 'brid00000000', + timeout: 200, + refererInfo: { + page: 'https://hello-world-page.com/', + domain: 'hello-world-page.com', + ref: 'http://example-domain.com/foo', + } +}; + +const bannerReponse = { + 'id': 'brid00000000', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'ARUYoUZx', + 'impid': 'dl38fjf9d', + 'price': 1.64, + 'adid': 'aaaaadddddddd', + 'burl': 'http://0.0.0.0:8181/burl', + 'adm': '
', + 'adomain': [ + 'https://www.exampleabc.com' + ], + 'iurl': 'https://example.example.com/2.png', + 'cid': 'aaaaadddddddd', + 'crid': 'aaaaadddddddd', + 'h': 250, + 'w': 300 + } + ] + } + ], + 'bidid': 'ARUYoUZx', + 'cur': 'USD' +} + +const videoResponse = { + 'id': 'brid00000000', + 'seatbid': [ + { + 'bid': [ + { + 'id': 'soCWeklh', + 'impid': '281141d3541362', + 'price': 1.09, + 'adid': 'outstream_video', + 'burl': 'http://0.0.0.0:8181/burl', + 'adm': '\n', + 'adomain': [ + 'https://www.exampleabc.com' + ], + 'cid': '229369649', + 'crid': 'aaaaadddddddd', + 'h': 768, + 'w': 1024 + } + ] + } + ], + 'bidid': 'soCWeklh', + 'cur': 'USD' +} + +describe('Silverpush Adapter', function () { + describe('isBidRequestValid()', () => { + it('should return false when publisherId is not defined', () => { + const bid = utils.deepClone(bannerBid); + delete bid.params.publisherId; + + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + + it('should return false when publisherId is empty string', () => { + const bid = utils.deepClone(bannerBid); + bid.params.publisherId = ''; + + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + + it('should return false when publisherId is a number', () => { + const bid = utils.deepClone(bannerBid); + bid.params.publisherId = 12345; + + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + + it('should return false when there is no banner in mediaTypes', () => { + const bid = utils.deepClone(bannerBid); + delete bid.mediaTypes.banner; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when sizes for banner are not specified', () => { + const bid = utils.deepClone(bannerBid); + delete bid.mediaTypes.banner.sizes; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return false when there is no video in mediaTypes', () => { + const bid = utils.deepClone(videoBid); + delete bid.mediaTypes.video; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should reutrn false if player size is not set', () => { + const bid = utils.deepClone(videoBid); + delete bid.mediaTypes.video.playerSize; + + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true when required params found', () => { + expect(spec.isBidRequestValid(bannerBid)).to.equal(true); + expect(spec.isBidRequestValid(videoBid)).to.equal(true); + }); + }); + + describe('buildRequests()', () => { + it('should build correct request for banner bid with both w, h', () => { + const bid = utils.deepClone(bannerBid); + + const [request] = spec.buildRequests([bid], bidderRequest); + const requestData = request.data; + + expect(requestData.imp[0].banner.w).to.equal(300); + expect(requestData.imp[0].banner.h).to.equal(250); + }); + + it('should return default bidfloor when bidFloor is not defined', () => { + const bid = utils.deepClone(bannerBid); + delete bid.params.bidFloor; + + const [request] = spec.buildRequests([bid], bidderRequest); + const requestData = request.data; + + expect(requestData.imp[0].bidfloor).to.equal(0.05); + }); + + it('should contain deals in request if deal is specified in params', () => { + const bid = utils.deepClone(bannerBid); + bid.params.deals = [{ id: 'test' }]; + + const [request] = spec.buildRequests([bid], bidderRequest); + const requestData = request.data; + + expect(requestData.imp[0].pmp.deals).to.equal(bid.params.deals); + }); + + it('should return bidfloor when bidFloor is defined', () => { + const bid = utils.deepClone(bannerBid); + + const [request] = spec.buildRequests([bid], bidderRequest); + const requestData = request.data; + + expect(requestData.imp[0].bidfloor).to.equal(bannerBid.params.bidFloor); + }); + + it('should build correct request for video bid with playerSize', () => { + const bid = utils.deepClone(videoBid); + + const [request] = spec.buildRequests([bid], bidderRequest); + const requestData = request.data; + + expect(requestData.imp[0].video.w).to.equal(1024); + expect(requestData.imp[0].video.h).to.equal(768); + }); + + it('should use bidder video params if they are set', () => { + const videoBidWithParams = utils.deepClone(videoBid); + const bidderVideoParams = { + api: [1, 2], + mimes: ['video/mp4', 'video/x-flv'], + playbackmethod: [3, 4], + protocols: [5, 6], + placement: 1, + minduration: 0, + maxduration: 60, + w: 1024, + h: 768, + startdelay: 0 + }; + + videoBidWithParams.params.video = bidderVideoParams; + + const requests = spec.buildRequests([videoBidWithParams], bidderRequest); + const request = requests[0].data; + + expect(request.imp[0]).to.deep.include({ + video: { + ...bidderVideoParams, + w: videoBidWithParams.mediaTypes.video.playerSize[0][0], + h: videoBidWithParams.mediaTypes.video.playerSize[0][1], + }, + }); + }); + }); + + describe('getOS()', () => { + it('shold return correct os name for Windows', () => { + let userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'; + let osName = spec.getOS(userAgent); + + expect(osName).to.equal('Windows'); + }); + + it('shold return correct os name for Mac OS', () => { + let userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9'; + let osName = spec.getOS(userAgent); + + expect(osName).to.equal('macOS'); + }); + + it('shold return correct os name for Android', () => { + let userAgent = 'Mozilla/5.0 (Linux; Android 10; SM-G996U Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36'; + let osName = spec.getOS(userAgent); + + expect(osName).to.equal('Android'); + }); + + it('shold return correct os name for ios', () => { + let userAgent = 'Mozilla/5.0 (iPhone14,3; U; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/19A346 Safari/602.1'; + let osName = spec.getOS(userAgent); + + expect(osName).to.equal('iOS'); + }); + + it('shold return correct os name for Linux', () => { + let userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1'; + let osName = spec.getOS(userAgent); + + expect(osName).to.equal('Linux'); + }); + }); + + describe('interpretResponse()', () => { + it('should return nbr to 0 when response not received', () => { + const requests = spec.buildRequests([bannerBid], bidderRequest); + const bids = spec.interpretResponse({ body: null }, requests[0]); + + expect(bids[0]).to.equal(undefined); + }); + + it('should correctly interpret valid banner response', () => { + const response = utils.deepClone(bannerReponse); + const requests = spec.buildRequests([bannerBid], bidderRequest); + const bids = spec.interpretResponse({ body: response }, requests[0]); + + expect(bids[0].ad).to.equal('
'); + expect(bids[0].burl).to.equal('http://0.0.0.0:8181/burl'); + expect(bids[0].cpm).to.equal(1.64); + expect(bids[0].creativeId).to.equal('aaaaadddddddd'); + expect(bids[0].creative_id).to.equal('aaaaadddddddd'); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].height).to.equal(250); + expect(bids[0].mediaType).to.equal('banner'); + expect(bids[0].meta.advertiserDomains[0]).to.equal('https://www.exampleabc.com'); + expect(bids[0].netRevenue).to.equal(true); + expect(bids[0].requestId).to.equal('dl38fjf9d'); + expect(bids[0].seatBidId).to.equal('ARUYoUZx'); + expect(bids[0].ttl).to.equal(300); + expect(bids[0].width).to.equal(300); + }); + + if (FEATURES.VIDEO) { + it('should correctly interpret valid instream video response', () => { + const response = utils.deepClone(videoResponse); + videoBid.mediaTypes.video.context = 'outstream'; + const requests = spec.buildRequests([videoBid], bidderRequest); + const bids = spec.interpretResponse({ body: response }, requests[0]); + + expect(bids[0].vastXml).to.equal('\n'); + expect(bids[0].burl).to.equal('http://0.0.0.0:8181/burl'); + expect(bids[0].cpm).to.equal(1.09); + expect(bids[0].creativeId).to.equal('aaaaadddddddd'); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].mediaType).to.equal('video'); + expect(bids[0].meta.advertiserDomains[0]).to.equal('https://www.exampleabc.com'); + expect(bids[0].requestId).to.equal('281141d3541362'); + expect(bids[0].seatBidId).to.equal('soCWeklh'); + expect(bids[0].width).to.equal(1024); + expect(bids[0].height).to.equal(768); + }); + + it('should correctly interpret valid outstream video response', () => { + const response = utils.deepClone(videoResponse); + videoBid.mediaTypes.video.context = 'outstream'; + + const requests = spec.buildRequests([videoBid], bidderRequest); + const bids = spec.interpretResponse({ body: response }, requests[0]); + + expect(bids[0].vastXml).to.equal('\n'); + expect(bids[0].rendererUrl).to.equal(SP_OUTSTREAM_PLAYER_URL); + expect(bids[0].renderer.url).to.equal(SP_OUTSTREAM_PLAYER_URL); + expect(bids[0].burl).to.equal('http://0.0.0.0:8181/burl'); + expect(bids[0].cpm).to.equal(1.09); + expect(bids[0].creativeId).to.equal('aaaaadddddddd'); + expect(bids[0].currency).to.equal('USD'); + expect(bids[0].mediaType).to.equal('video'); + expect(bids[0].meta.advertiserDomains[0]).to.equal('https://www.exampleabc.com'); + expect(bids[0].requestId).to.equal('281141d3541362'); + expect(bids[0].seatBidId).to.equal('soCWeklh'); + expect(bids[0].width).to.equal(1024); + expect(bids[0].height).to.equal(768); + }); + } + }); + + describe('onBidWon', function() { + let ajaxStub; + + beforeEach(() => { + ajaxStub = sinon.stub(spec, 'getRequest') + }) + + afterEach(() => { + ajaxStub.restore() + }) + + it('Should not trigger pixel if bid does not contain burl', function() { + const result = spec.onBidWon({}); + + expect(ajaxStub.calledOnce).to.equal(false); + }) + + it('Should trigger pixel with correct macros if bid burl is present', function() { + const result = spec.onBidWon({ + cpm: 1.5, + auctionId: 'auc123', + requestId: 'req123', + adId: 'ad1234', + seatBidId: 'sea123', + burl: 'http://won.foo.bar/trk?ap=${AUCTION_PRICE}&aid=${AUCTION_ID}&imp=${AUCTION_IMP_ID}&adid=${AUCTION_AD_ID}&sid=${AUCTION_SEAT_ID}' + }); + + expect(ajaxStub.calledOnceWith('http://won.foo.bar/trk?ap=1.5&aid=auc123&imp=req123&adid=ad1234&sid=sea123')).to.equal(true); + }) + }) +}); diff --git a/test/spec/modules/sirdataRtdProvider_spec.js b/test/spec/modules/sirdataRtdProvider_spec.js index a16359c50cb..fbb5967bc20 100644 --- a/test/spec/modules/sirdataRtdProvider_spec.js +++ b/test/spec/modules/sirdataRtdProvider_spec.js @@ -1,26 +1,31 @@ -import { addSegmentData, getSegmentsAndCategories, sirdataSubmodule } from 'modules/sirdataRtdProvider.js'; -import { server } from 'test/mocks/xhr.js'; +import {addSegmentData, getSegmentsAndCategories, sirdataSubmodule, setOrtb2} from 'modules/sirdataRtdProvider.js'; +import {server} from 'test/mocks/xhr.js'; const responseHeader = {'Content-Type': 'application/json'}; -describe('sirdataRtdProvider', function() { - describe('sirdataSubmodule', function() { +describe('sirdataRtdProvider', function () { + describe('sirdataSubmodule', function () { + it('exists', function () { + expect(sirdataSubmodule.init).to.be.a('function'); + }); it('successfully instantiates', function () { - expect(sirdataSubmodule.init()).to.equal(true); + expect(sirdataSubmodule.init()).to.equal(true); + }); + it('has the correct module name', function () { + expect(sirdataSubmodule.name).to.equal('SirdataRTDModule'); }); }); - describe('Add Segment Data', function() { - it('adds segment data', function() { - const config = { + describe('Add Segment Data', function () { + it('adds segment data', function () { + const firstConfig = { params: { - setGptKeyValues: false, + partnerId: 1, + key: 1, + setGptKeyValues: true, + gptCurationId: 27449, contextualMinRelevancyScore: 50, - bidders: [{ - bidder: 'appnexus' - }, { - bidder: 'other' - }] + bidders: [] } }; @@ -37,28 +42,70 @@ describe('sirdataRtdProvider', function() { } ]; - let data = { + let firstReqBidsConfigObj = { + adUnits: adUnits, + ortb2Fragments: { + global: {} + } + }; + + let firstData = { segments: [111111, 222222], - contextual_categories: {'333333': 100} + contextual_categories: {'333333': 100}, + 'segtaxid': null, + 'cattaxid': null, + 'shared_taxonomy': { + '27449': { + 'segments': [444444, 555555], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'666666': 100} + } + }, + 'global_taxonomy': { + '9998': { + 'segments': [123, 234], + 'segtaxid': 4, + 'cattaxid': 7, + 'contextual_categories': {'345': 100, '456': 100} + } + } }; - addSegmentData(adUnits, data, config, () => {}); - expect(adUnits[0].bids[0].params.keywords).to.have.deep.property('sd_rtd', ['111111', '222222', '333333']); - expect(adUnits[0].bids[1].ortb2.site.ext.data).to.have.deep.property('sd_rtd', ['333333']); - expect(adUnits[0].bids[1].ortb2.user.ext.data).to.have.deep.property('sd_rtd', ['111111', '222222']); + addSegmentData(firstReqBidsConfigObj, firstData, firstConfig, () => { + }); + + expect(firstReqBidsConfigObj.ortb2Fragments.global.user.data[0].ext.segtax).to.equal(4); }); }); - describe('Get Segments And Categories', function() { - it('gets data from async request and adds segment data', function() { + describe('Get Segments And Categories', function () { + it('gets data from async request and adds segment data', function () { + const overrideAppnexus = function (adUnit, list, data, bid) { + deepSetValue(bid, 'params.keywords.custom', list.segments.concat(list.categories)); + } + const config = { params: { setGptKeyValues: false, contextualMinRelevancyScore: 50, bidders: [{ - bidder: 'appnexus' + bidder: 'appnexus', + customFunction: overrideAppnexus, + curationId: 27446 }, { - bidder: 'other' + bidder: 'smartadserver', + curationId: 27440 + }, { + bidder: 'ix', + sizeLimit: 1200, + curationId: 27248 + }, { + bidder: 'rubicon', + curationId: 27452 + }, { + bidder: 'proxistore', + curationId: 27484 }] } }; @@ -71,24 +118,164 @@ describe('sirdataRtdProvider', function() { placementId: 13144370 } }, { - bidder: 'other' + bidder: 'smartadserver', + params: { + siteId: 207435, + pageId: 896536, + formatId: 62913 + } + }, { + bidder: 'proxistore', + params: {website: 'demo.sirdata.com', language: 'fr'}, + adUnitCode: 'HALFPAGE_CENTER_LOADER', + transactionId: '92ac333a-a569-4827-abf1-01fc9d19278a', + sizes: [[300, 600]], + mediaTypes: { + banner: { + filteredSizeConfig: [ + {minViewPort: [1600, 0], sizes: [[300, 600]]}, + ], + sizeConfig: [ + {minViewPort: [0, 0], sizes: [[300, 600]]}, + {minViewPort: [768, 0], sizes: [[300, 600]]}, + {minViewPort: [1200, 0], sizes: [[300, 600]]}, + {minViewPort: [1600, 0], sizes: [[300, 600]]}, + ], + sizes: [[300, 600]], + }, + }, + bidId: '190bab495bc5f6e', + bidderRequestId: '18c0b0f0c91cd88', + auctionId: '9bdd917b-908d-4d9f-8f2f-d443277a62fc', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0, + }, { + bidder: 'ix', + params: { + siteId: '12345', + size: [300, 600] + } + }, { + bidder: 'rubicon', + params: { + accountId: 14062, + siteId: 70608, + zoneId: 498816 + } }] - }] + }], + ortb2Fragments: { + global: {} + } }; let data = { - segments: [111111, 222222], - contextual_categories: {'333333': 100} + 'segments': [111111, 222222], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'333333': 100}, + 'shared_taxonomy': { + '27440': { + 'segments': [444444, 555555], + 'segtaxid': 552, + 'cattaxid': 553, + 'contextual_categories': {'666666': 100} + }, + '27446': { + 'segments': [777777, 888888], + 'segtaxid': 552, + 'cattaxid': 553, + 'contextual_categories': {'999999': 100} + } + }, + 'global_taxonomy': { + '9998': { + 'segments': [123, 234], + 'segtaxid': 4, + 'cattaxid': 7, + 'contextual_categories': {'345': 100, '456': 100} + } + } }; - getSegmentsAndCategories(reqBidsConfigObj, () => {}, config, {}); + getSegmentsAndCategories(reqBidsConfigObj, () => { + }, config, {}); let request = server.requests[0]; request.respond(200, responseHeader, JSON.stringify(data)); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.keywords).to.have.deep.property('sd_rtd', ['111111', '222222', '333333']); - expect(reqBidsConfigObj.adUnits[0].bids[1].ortb2.site.ext.data).to.have.deep.property('sd_rtd', ['333333']); - expect(reqBidsConfigObj.adUnits[0].bids[1].ortb2.user.ext.data).to.have.deep.property('sd_rtd', ['111111', '222222']); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].name).to.equal( + 'sirdata.com' + ); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].segment).to.eql([ + {id: '345'}, + {id: '456'} + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.site.content.data[0].ext.segtax).to.equal(7); + + expect(reqBidsConfigObj.ortb2Fragments.global.user.data[0].name).to.equal( + 'sirdata.com' + ); + expect(reqBidsConfigObj.ortb2Fragments.global.user.data[0].segment).to.eql([ + {id: '123'}, + {id: '234'} + ]); + expect(reqBidsConfigObj.ortb2Fragments.global.user.data[0].ext.segtax).to.equal(4); + }); + }); + + describe('Set ortb2 for bidder', function () { + it('set ortb2 for a givent bidder', function () { + const config = { + params: { + setGptKeyValues: false, + contextualMinRelevancyScore: 50, + bidders: [{ + bidder: 'appnexus', + }] + } + }; + + let reqBidsConfigObj = { + adUnits: [{ + bids: [{ + bidder: 'appnexus', + params: { + placementId: 13144370 + } + }] + }], + ortb2Fragments: { + global: {} + } + }; + + let data = { + 'segments': [111111, 222222], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'333333': 100}, + 'shared_taxonomy': { + '27440': { + 'segments': [444444, 555555], + 'segtaxid': null, + 'cattaxid': null, + 'contextual_categories': {'666666': 100} + } + }, + 'global_taxonomy': {} + }; + + window.googletag = window.googletag || {}; + window.googletag.cmd = window.googletag.cmd || []; + + let test = setOrtb2(reqBidsConfigObj.ortb2Fragments, 'appnexus', 'user', []); + expect(test).to.be.false; + + test = setOrtb2(reqBidsConfigObj.ortb2Fragments, 'appnexus', 'user', ['1']); + expect(test).to.be.true; }); }); }); diff --git a/test/spec/modules/sizeMappingV2_spec.js b/test/spec/modules/sizeMappingV2_spec.js index 9bbd472c7e0..16c1527a3ad 100644 --- a/test/spec/modules/sizeMappingV2_spec.js +++ b/test/spec/modules/sizeMappingV2_spec.js @@ -445,6 +445,10 @@ describe('sizeMappingV2', function () { }); describe('video mediaTypes checks', function () { + if (!FEATURES.VIDEO) { + return; + } + beforeEach(function () { sinon.spy(adUnitSetupChecks, 'validateVideoMediaType'); }); @@ -616,6 +620,9 @@ describe('sizeMappingV2', function () { }); describe('native mediaTypes checks', function () { + if (!FEATURES.NATIVE) { + return; + } beforeEach(function () { sinon.spy(adUnitSetupChecks, 'validateNativeMediaType'); }); diff --git a/test/spec/modules/sizeMapping_spec.js b/test/spec/modules/sizeMapping_spec.js new file mode 100644 index 00000000000..55b536868e6 --- /dev/null +++ b/test/spec/modules/sizeMapping_spec.js @@ -0,0 +1,342 @@ +import {expect} from 'chai'; +import {resolveStatus, setSizeConfig, sizeSupported} from 'modules/sizeMapping.js'; +import {includes} from 'src/polyfill.js'; + +let utils = require('src/utils.js'); +let deepClone = utils.deepClone; + +describe('sizeMapping', function () { + var sizeConfig = [{ + 'mediaQuery': '(min-width: 1200px)', + 'sizesSupported': [ + [970, 90], + [728, 90], + [300, 250] + ] + }, { + 'mediaQuery': '(min-width: 768px) and (max-width: 1199px)', + 'sizesSupported': [ + [728, 90], + [300, 250], + [300, 100] + ] + }, { + 'mediaQuery': '(min-width: 0px) and (max-width: 767px)', + 'sizesSupported': [] + }]; + + var sizeConfigWithLabels = [{ + 'mediaQuery': '(min-width: 1200px)', + 'labels': ['desktop'] + }, { + 'mediaQuery': '(min-width: 768px) and (max-width: 1199px)', + 'sizesSupported': [ + [728, 90], + [300, 250] + ], + 'labels': ['tablet', 'phone'] + }, { + 'mediaQuery': '(min-width: 0px) and (max-width: 767px)', + 'sizesSupported': [ + [300, 250], + [300, 100] + ], + 'labels': ['phone'] + }]; + + let sandbox, + matchMediaOverride; + + beforeEach(function () { + setSizeConfig(sizeConfig); + + sandbox = sinon.sandbox.create(); + + matchMediaOverride = {matches: false}; + + sandbox.stub(utils.getWindowTop(), 'matchMedia').callsFake((...args) => { + if (typeof matchMediaOverride === 'function') { + return matchMediaOverride.apply(utils.getWindowTop(), args); + } + return matchMediaOverride; + }); + }); + + afterEach(function () { + setSizeConfig([]); + + sandbox.restore(); + }); + + describe('sizeConfig', () => { + it('should allow us to validate a single size', function () { + matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; + + expect(sizeSupported([300, 250])).to.equal(true); + expect(sizeSupported([80, 80])).to.equal(false); + }); + + it('should log a warning when mediaQuery property missing from sizeConfig', function () { + let errorConfig = deepClone(sizeConfig); + + delete errorConfig[0].mediaQuery; + + sandbox.stub(utils, 'logWarn'); + + resolveStatus(undefined, {}, errorConfig); + expect(utils.logWarn.firstCall.args[0]).to.match(/missing.+?mediaQuery/); + }); + + it('should log a warning message when mediaQuery property is declared as an empty string', function () { + const errorConfig = deepClone(sizeConfig); + errorConfig[0].mediaQuery = ''; + + sandbox.stub(utils, 'logWarn'); + resolveStatus(undefined, {}, errorConfig); + expect(utils.logWarn.firstCall.args[0]).to.match(/missing.+?mediaQuery/); + }); + }); + + const TEST_SIZES = [[970, 90], [728, 90], [300, 250], [300, 100], [80, 80]]; + + const suites = { + banner: { + mediaTypes: { + banner: { + sizes: TEST_SIZES + } + }, + getSizes(mediaTypes) { + return mediaTypes.banner.sizes; + }, + } + } + if (FEATURES.VIDEO) { + suites.video = { + mediaTypes: { + video: { + playerSize: TEST_SIZES + } + }, + getSizes(mediaTypes) { + return mediaTypes.video.playerSize; + } + } + } + Object.entries(suites).forEach(([mediaType, {mediaTypes, getSizes}]) => { + describe(`for ${mediaType}`, () => { + describe('when handling sizes', function () { + it('when one mediaQuery block matches, it should filter the adUnit.sizes passed in', function () { + matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; + + let status = resolveStatus(undefined, mediaTypes, sizeConfig); + + expect(status.active).to.equal(true); + expect(getSizes(status.mediaTypes)).to.deep.equal( + [[970, 90], [728, 90], [300, 250]] + ); + }); + + it('when multiple mediaQuery block matches, it should filter a union of the matched sizesSupported', function () { + matchMediaOverride = (str) => includes([ + '(min-width: 1200px)', + '(min-width: 768px) and (max-width: 1199px)' + ], str) ? {matches: true} : {matches: false}; + + let status = resolveStatus(undefined, mediaTypes, sizeConfig); + expect(status.active).to.equal(true); + expect(getSizes(status.mediaTypes)).to.deep.equal( + [[970, 90], [728, 90], [300, 250], [300, 100]] + ); + }); + + it('if no mediaQueries match, it should allow all sizes specified', function () { + matchMediaOverride = () => ({matches: false}); + + let status = resolveStatus(undefined, mediaTypes, sizeConfig); + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + }); + + it('if a mediaQuery matches and has sizesSupported: [], it should filter all sizes', function () { + matchMediaOverride = (str) => str === '(min-width: 0px) and (max-width: 767px)' ? {matches: true} : {matches: false}; + + let status = resolveStatus(undefined, mediaTypes, sizeConfig); + expect(status.active).to.equal(false); + expect(getSizes(status.mediaTypes)).to.deep.equal([]); + }); + + it('should filter all banner sizes and should disable the adUnit even if other mediaTypes are present', function () { + matchMediaOverride = (str) => str === '(min-width: 0px) and (max-width: 767px)' ? {matches: true} : {matches: false}; + let status = resolveStatus(undefined, Object.assign({}, mediaTypes, { + native: { + type: 'image' + } + }), sizeConfig); + expect(status.active).to.equal(false); + expect(getSizes(status.mediaTypes)).to.deep.equal([]); + expect(status.mediaTypes.native).to.deep.equal({ + type: 'image' + }); + }); + + it('if a mediaQuery matches and no sizesSupported specified, it should not affect adUnit.sizes', function () { + matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; + + let status = resolveStatus(undefined, mediaTypes, sizeConfigWithLabels); + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + }); + }); + + describe('when handling labels', function () { + it('should activate/deactivate adUnits/bidders based on sizeConfig.labels', function () { + matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; + + let status = resolveStatus({ + labels: ['desktop'] + }, mediaTypes, sizeConfigWithLabels); + + expect(status).to.deep.equal({ + active: true, + mediaTypes: mediaTypes + }); + + status = resolveStatus({ + labels: ['tablet'] + }, mediaTypes, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + }); + + it('should active/deactivate adUnits/bidders based on requestBids labels', function () { + let activeLabels = ['us-visitor', 'desktop', 'smart']; + + let status = resolveStatus({ + labels: ['uk-visitor'], // from adunit + activeLabels // from requestBids.labels + }, mediaTypes, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + + status = resolveStatus({ + labels: ['us-visitor'], + activeLabels + }, mediaTypes, sizeConfigWithLabels); + + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + + status = resolveStatus({ + labels: ['us-visitor', 'tablet'], + labelAll: true, + activeLabels + }, mediaTypes, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + + status = resolveStatus({ + labels: ['us-visitor', 'desktop'], + labelAll: true, + activeLabels + }, mediaTypes, undefined, sizeConfigWithLabels); + + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal(mediaTypes); + }); + }); + }); + }); + + if (FEATURES.VIDEO) { + it('should activate/decactivate adUnits/bidders based on labels with multiformat ads', function () { + matchMediaOverride = (str) => str === '(min-width: 768px) and (max-width: 1199px)' ? {matches: true} : {matches: false}; + + let multiFormatSizes = { + banner: { + sizes: [[728, 90], [300, 300]] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [[728, 90], [300, 300]] + } + }; + + let status = resolveStatus({ + labels: ['tablet', 'test'], + labelAll: true + }, multiFormatSizes, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal({ + banner: { + sizes: [[728, 90]] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [[728, 90]] + } + }); + + status = resolveStatus({ + labels: ['tablet'] + }, multiFormatSizes, sizeConfigWithLabels); + + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal({ + banner: { + sizes: [[728, 90]] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [[728, 90]] + } + }); + + [multiFormatSizes.banner.sizes, multiFormatSizes.video.playerSize].forEach(sz => sz.splice(0, 1, [728, 80])) + status = resolveStatus({ + labels: ['tablet'] + }, multiFormatSizes, sizeConfigWithLabels); + + expect(status.active).to.equal(false); + expect(status.mediaTypes).to.deep.equal({ + banner: { + sizes: [] + }, + native: { + type: 'image' + }, + video: { + context: 'outstream', + playerSize: [] + } + }); + + delete multiFormatSizes.banner; + delete multiFormatSizes.video; + + status = resolveStatus({ + labels: ['tablet'] + }, multiFormatSizes, sizeConfigWithLabels); + + expect(status.active).to.equal(true); + expect(status.mediaTypes).to.deep.equal({ + native: { + type: 'image' + } + }); + }); + } +}); diff --git a/test/spec/modules/slimcutBidAdapter_spec.js b/test/spec/modules/slimcutBidAdapter_spec.js index 300791c9658..da0fee48936 100644 --- a/test/spec/modules/slimcutBidAdapter_spec.js +++ b/test/spec/modules/slimcutBidAdapter_spec.js @@ -106,7 +106,7 @@ describe('slimcutBidAdapter', function() { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'https://example.com/page.html', + page: 'https://example.com/page.html', reachedTop: true, numIframes: 2 } @@ -178,7 +178,6 @@ describe('slimcutBidAdapter', function() { 'ad': AD_SCRIPT, 'requestId': '3ede2a3fa0db94', 'creativeId': 'er2ee', - 'transactionId': 'deadb33f', 'winUrl': 'https://sb.freeskreen.com/win', 'meta': { 'advertiserDomains': [] diff --git a/test/spec/modules/smaatoBidAdapter_spec.js b/test/spec/modules/smaatoBidAdapter_spec.js index 38df03652b1..185dee2430f 100644 --- a/test/spec/modules/smaatoBidAdapter_spec.js +++ b/test/spec/modules/smaatoBidAdapter_spec.js @@ -6,19 +6,21 @@ import {createEidsArray} from 'modules/userId/eids.js'; const ADTYPE_IMG = 'Img'; const ADTYPE_RICHMEDIA = 'Richmedia'; const ADTYPE_VIDEO = 'Video'; +const ADTYPE_NATIVE = 'Native'; const REFERRER = 'http://example.com/page.html' const CONSENT_STRING = 'HFIDUYFIUYIUYWIPOI87392DSU' const AUCTION_ID = '6653'; const defaultBidderRequest = { + bidderRequestId: 'mock-uuid', gdprConsent: { consentString: CONSENT_STRING, gdprApplies: true }, uspConsent: 'uspConsentString', refererInfo: { - referer: REFERRER, + ref: REFERRER, }, timeout: 1200, auctionId: AUCTION_ID @@ -123,7 +125,7 @@ describe('smaatoBidAdapterTest', () => { describe('common', () => { const MINIMAL_BIDDER_REQUEST = { refererInfo: { - referer: REFERRER, + ref: REFERRER, } }; @@ -296,6 +298,21 @@ describe('smaatoBidAdapterTest', () => { expect(req.regs.ext.us_privacy).to.equal('uspConsentString'); }); + it('sends gpp', () => { + const ortb2 = { + regs: { + gpp: 'gppString', + gpp_sid: [7] + } + }; + + const reqs = spec.buildRequests([singleBannerBidRequest], {...defaultBidderRequest, ortb2}); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.regs.ext.gpp).to.eql('gppString'); + expect(req.regs.ext.gpp_sid).to.eql([7]); + }); + it('sends no schain if no schain exists', () => { const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); @@ -328,27 +345,29 @@ describe('smaatoBidAdapterTest', () => { }); it('sends first party data', () => { - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2: { - site: { - keywords: 'power tools,drills', - publisher: { - id: 'otherpublisherid', - name: 'publishername' - } - }, - user: { - keywords: 'a,b', - gender: 'M', - yob: 1984 - } + const ortb2 = { + site: { + keywords: 'power tools,drills', + publisher: { + id: 'otherpublisherid', + name: 'publishername' } - }; - return utils.deepAccess(config, key); - }); + }, + user: { + keywords: 'a,b', + gender: 'M', + yob: 1984 + }, + device: { + ifa: 'ifa', + geo: { + lat: 53.5488, + lon: 9.9872 + } + } + }; - const reqs = spec.buildRequests([singleBannerBidRequest], defaultBidderRequest); + const reqs = spec.buildRequests([singleBannerBidRequest], {...defaultBidderRequest, ortb2}); const req = extractPayloadOfFirstAndOnlyRequest(reqs); expect(req.user.gender).to.equal('M'); @@ -357,6 +376,9 @@ describe('smaatoBidAdapterTest', () => { expect(req.user.ext.consent).to.equal(CONSENT_STRING); expect(req.site.keywords).to.eql('power tools,drills'); expect(req.site.publisher.id).to.equal('publisherId'); + expect(req.device.ifa).to.equal('ifa'); + expect(req.device.geo.lat).to.equal(53.5488); + expect(req.device.geo.lon).to.equal(9.9872); }); it('has no user ids', () => { @@ -426,7 +448,6 @@ describe('smaatoBidAdapterTest', () => { }, adUnitCode: '/19968336/header-bid-tag-0', transactionId: 'transactionId', - sizes: [[300, 50]], bidId: 'bidId', bidderRequestId: 'bidderRequestId', src: 'client', @@ -534,7 +555,7 @@ describe('smaatoBidAdapterTest', () => { const reqs = spec.buildRequests([longFormVideoBidRequest], defaultBidderRequest); const req = extractPayloadOfFirstAndOnlyRequest(reqs); - expect(req.id).to.be.equal(AUCTION_ID); + expect(req.id).to.exist; expect(req.imp.length).to.be.equal(ADPOD_DURATION / DURATION_RANGE[0]); expect(req.imp[0].id).to.be.equal(BID_ID); expect(req.imp[0].tagid).to.be.equal(ADBREAK_ID); @@ -638,7 +659,7 @@ describe('smaatoBidAdapterTest', () => { const reqs = spec.buildRequests([longFormVideoBidRequest], defaultBidderRequest); const req = extractPayloadOfFirstAndOnlyRequest(reqs); - expect(req.id).to.be.equal(AUCTION_ID); + expect(req.id).to.exist; expect(req.imp.length).to.be.equal(DURATION_RANGE.length); expect(req.imp[0].id).to.be.equal(BID_ID); expect(req.imp[0].tagid).to.be.equal(ADBREAK_ID); @@ -798,6 +819,168 @@ describe('smaatoBidAdapterTest', () => { }); }); + describe('buildRequests for native imps', () => { + const NATIVE_OPENRTB_REQUEST = { + ver: '1.2', + assets: [ + { + id: 4, + required: 1, + img: { + type: 3, + w: 150, + h: 50, + } + }, + { + id: 2, + required: 1, + img: { + type: 2, + w: 50, + h: 50 + } + }, + { + id: 0, + required: 1, + title: { + len: 80 + } + }, + { + id: 1, + required: 1, + data: { + type: 1 + } + }, + { + id: 3, + required: 1, + data: { + type: 2 + } + }, + { + id: 5, + required: 1, + data: { + type: 3 + } + }, + { + id: 6, + required: 1, + data: { + type: 4 + } + }, + { + id: 7, + required: 1, + data: { + type: 5 + } + }, + { + id: 8, + required: 1, + data: { + type: 6 + } + }, + { + id: 9, + required: 1, + data: { + type: 7 + } + }, + { + id: 10, + required: 0, + data: { + type: 8 + } + }, + { + id: 11, + required: 1, + data: { + type: 9 + } + }, + { + id: 12, + require: 0, + data: { + type: 10 + } + }, + { + id: 13, + required: 0, + data: { + type: 11 + } + }, + { + id: 14, + required: 1, + data: { + type: 12 + } + } + ] + }; + + const singleNativeBidRequest = { + bidder: 'smaato', + params: { + publisherId: 'publisherId', + adspaceId: 'adspaceId' + }, + nativeOrtbRequest: NATIVE_OPENRTB_REQUEST, + adUnitCode: '/19968336/header-bid-tag-0', + transactionId: 'transactionId', + bidId: 'bidId', + bidderRequestId: 'bidderRequestId', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }; + + it('sends correct native imps', () => { + const reqs = spec.buildRequests([singleNativeBidRequest], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.imp[0].id).to.be.equal('bidId'); + expect(req.imp[0].tagid).to.be.equal('adspaceId'); + expect(req.imp[0].bidfloor).to.be.undefined; + expect(req.imp[0].native.request).to.deep.equal(JSON.stringify(NATIVE_OPENRTB_REQUEST)); + }); + + it('sends bidfloor when configured', () => { + const singleNativeBidRequestWithFloor = Object.assign({}, singleNativeBidRequest); + singleNativeBidRequestWithFloor.getFloor = function(arg) { + if (arg.currency === 'USD' && + arg.mediaType === 'native' && + JSON.stringify(arg.size) === JSON.stringify([150, 50])) { + return { + currency: 'USD', + floor: 0.123 + } + } + } + const reqs = spec.buildRequests([singleNativeBidRequestWithFloor], defaultBidderRequest); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.imp[0].bidfloor).to.be.equal(0.123); + }); + }); + describe('in-app requests', () => { const LOCATION = { lat: 33.3, @@ -835,6 +1018,28 @@ describe('smaatoBidAdapterTest', () => { expect(req.device.ifa).to.equal(DEVICE_ID); }); + it('when geo and ifa info present and fpd present, then prefer fpd', () => { + const ortb2 = { + device: { + ifa: 'ifa', + geo: { + lat: 53.5488, + lon: 9.9872 + } + } + }; + + const inAppBidRequest = utils.deepClone(inAppBidRequestWithoutAppParams); + inAppBidRequest.params.app = {ifa: DEVICE_ID, geo: LOCATION}; + + const reqs = spec.buildRequests([inAppBidRequest], {...defaultBidderRequest, ortb2}); + + const req = extractPayloadOfFirstAndOnlyRequest(reqs); + expect(req.device.geo.lat).to.equal(53.5488); + expect(req.device.geo.lon).to.equal(9.9872); + expect(req.device.ifa).to.equal('ifa'); + }); + it('when ifa is present but geo is missing, then add only ifa to device object', () => { const inAppBidRequest = utils.deepClone(inAppBidRequestWithoutAppParams); inAppBidRequest.params.app = {ifa: DEVICE_ID}; @@ -890,17 +1095,15 @@ describe('smaatoBidAdapterTest', () => { criteoId: '123456', tdid: '89145' }, - userIdAsEids: createEidsArray({ - criteoId: '123456', - tdid: '89145' - }) + userIdAsEids: [ + {id: 1}, {id: 2} + ] }; const reqs = spec.buildRequests([userIdBidRequest], defaultBidderRequest); const req = extractPayloadOfFirstAndOnlyRequest(reqs); - expect(req.user.ext.eids).to.exist; - expect(req.user.ext.eids).to.have.length(2); + expect(req.user.ext.eids).to.eql(userIdBidRequest.userIdAsEids); }); }); @@ -937,50 +1140,131 @@ describe('smaatoBidAdapterTest', () => { } } + const NATIVE_RESPONSE = { + ver: '1.2', + link: { + url: 'https://link.url', + clicktrackers: [ + 'http://click.url/v1/click?e=prebid' + ] + }, + assets: [ + { + id: 0, + required: 1, + title: { + text: 'Title' + } + }, + { + id: 2, + required: 1, + img: { + type: 1, + url: 'https://logo.png', + w: 40, + h: 40 + } + }, + { + id: 4, + required: 1, + img: { + type: 3, + url: 'https://main.png', + w: 480, + h: 320 + } + }, + { + id: 3, + required: 1, + data: { + type: 2, + value: 'Desc' + } + }, + { + id: 14, + required: 1, + data: { + type: 12, + value: 'CTAText' + } + }, + { + id: 5, + required: 0, + data: { + type: 3, + value: '2 stars' + } + } + ], + eventtrackers: [ + { + event: 2, + method: 1, + url: 'https://js.url' + }, + { + event: 1, + method: 1, + url: 'http://view.url/v1/view?e=prebid' + } + ], + privacy: 'https://privacy.com/' + } + const buildOpenRtbBidResponse = (adType) => { let adm = ''; switch (adType) { case ADTYPE_IMG: - adm = JSON.stringify({ - image: { - img: { - url: 'https://prebid/static/ad.jpg', - w: 320, - h: 50, - ctaurl: 'https://prebid/track/ctaurl' - }, - impressiontrackers: [ - 'https://prebid/track/imp/1', - 'https://prebid/track/imp/2' - ], - clicktrackers: [ - 'https://prebid/track/click/1' - ] - } - }); + adm = JSON.stringify( + { + image: { + img: { + url: 'https://prebid/static/ad.jpg', + w: 320, + h: 50, + ctaurl: 'https://prebid/track/ctaurl' + }, + impressiontrackers: [ + 'https://prebid/track/imp/1', + 'https://prebid/track/imp/2' + ], + clicktrackers: [ + 'https://prebid/track/click/1' + ] + } + }); break; case ADTYPE_RICHMEDIA: - adm = JSON.stringify({ - richmedia: { - mediadata: { - content: '

RICHMEDIA CONTENT

', - w: 800, - h: 600 - }, - impressiontrackers: [ - 'https://prebid/track/imp/1', - 'https://prebid/track/imp/2' - ], - clicktrackers: [ - 'https://prebid/track/click/1' - ] - } - }); + adm = JSON.stringify( + { + richmedia: { + mediadata: { + content: '

RICHMEDIA CONTENT

', + w: 800, + h: 600 + }, + impressiontrackers: [ + 'https://prebid/track/imp/1', + 'https://prebid/track/imp/2' + ], + clicktrackers: [ + 'https://prebid/track/click/1' + ] + } + }); break; case ADTYPE_VIDEO: adm = ''; break; + case ADTYPE_NATIVE: + adm = JSON.stringify({ native: NATIVE_RESPONSE }) + break; default: throw Error('Invalid AdType'); } @@ -1035,7 +1319,7 @@ describe('smaatoBidAdapterTest', () => { }); describe('non ad pod', () => { - it('single image reponse', () => { + it('single image response', () => { const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_IMG), buildBidRequest()); expect(bids).to.deep.equal([ @@ -1061,7 +1345,7 @@ describe('smaatoBidAdapterTest', () => { ]); }); - it('single richmedia reponse', () => { + it('single richmedia response', () => { const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_RICHMEDIA), buildBidRequest()); expect(bids).to.deep.equal([ @@ -1113,6 +1397,34 @@ describe('smaatoBidAdapterTest', () => { ]); }); + it('single native response', () => { + const bids = spec.interpretResponse(buildOpenRtbBidResponse(ADTYPE_NATIVE), buildBidRequest()); + + expect(bids).to.deep.equal([ + { + requestId: '226416e6e6bf41', + cpm: 0.01, + width: 350, + height: 50, + native: { + ortb: NATIVE_RESPONSE + }, + ttl: 300, + creativeId: 'CR69381', + dealId: '12345', + netRevenue: true, + currency: 'USD', + mediaType: 'native', + meta: { + advertiserDomains: ['smaato.com'], + agencyId: 'CM6523', + networkName: 'smaato', + mediaType: 'native' + } + } + ]); + }); + it('ignores bid response with invalid ad type', () => { const serverResponse = buildOpenRtbBidResponse(ADTYPE_IMG); serverResponse.headers.get = (header) => { diff --git a/test/spec/modules/smartadserverBidAdapter_spec.js b/test/spec/modules/smartadserverBidAdapter_spec.js index 727a7d7c1d6..9daa6a87826 100644 --- a/test/spec/modules/smartadserverBidAdapter_spec.js +++ b/test/spec/modules/smartadserverBidAdapter_spec.js @@ -1,5 +1,7 @@ import { expect } from 'chai'; +import { BANNER, VIDEO } from 'src/mediaTypes.js'; import { config } from 'src/config.js'; +import { deepClone } from 'src/utils.js'; import { spec } from 'modules/smartadserverBidAdapter.js'; // Default params with optional ones @@ -28,7 +30,11 @@ describe('Smart bid adapter tests', function () { ckId: 42 }, requestId: 'efgh5678', - transactionId: 'zsfgzzg' + ortb2Imp: { + ext: { + tid: 'zsfgzzg' + } + }, }]; var DEFAULT_PARAMS_WITH_EIDS = [{ @@ -56,18 +62,80 @@ describe('Smart bid adapter tests', function () { }, requestId: 'efgh5678', transactionId: 'zsfgzzg', - userId: { - britepoolid: '1111', - criteoId: '1111', - digitrustid: { data: { id: 'DTID', keyv: 4, privacy: { optout: false }, producer: 'ABC', version: 2 } }, - id5id: { uid: '1111' }, - idl_env: '1111', - lipbid: '1111', - parrableid: 'eidVersion.encryptionKeyReference.encryptedValue', - pubcid: '1111', - tdid: '1111', - netId: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', - } + userIdAsEids: [ + { + 'source': 'pubcid.org', + 'uids': [ + { + 'atype': 1, + 'id': '1111' + } + ] + }, + { + 'source': 'britepoolid', + 'uids': [ + { + 'atype': 1, + 'id': '1111' + } + ] + }, + { + 'source': 'id5id', + 'uids': [ + { + 'atype': 1, + 'id': '1111' + } + ] + }, + { + 'source': 'idl_env', + 'uids': [ + { + 'atype': 1, + 'id': '1111' + } + ] + }, + { + 'source': 'lipbid', + 'uids': [ + { + 'atype': 1, + 'id': '1111' + } + ] + }, + { + 'source': 'parrableid', + 'uids': [ + { + 'atype': 1, + 'id': 'eidVersion.encryptionKeyReference.encryptedValue' + } + ] + }, + { + 'source': 'tdid', + 'uids': [ + { + 'atype': 1, + 'id': '1111' + } + ] + }, + { + 'source': 'netId', + 'uids': [ + { + 'atype': 1, + 'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg' + } + ] + } + ] }]; // Default params without optional ones @@ -158,12 +226,44 @@ describe('Smart bid adapter tests', function () { } }; + var sellerDefinedAudience = [ + { + 'name': 'hearst.com', + 'ext': { 'segtax': 1 }, + 'segment': [ + { 'id': '1001' }, + { 'id': '1002' } + ] + } + ]; + + var sellerDefinedContext = [ + { + 'name': 'cnn.com', + 'ext': { 'segtax': 2 }, + 'segment': [ + { 'id': '2002' } + ] + } + ]; + it('Verify build request', function () { config.setConfig({ 'currency': { 'adServerCurrency': 'EUR' + }, + ortb2: { + 'user': { + 'data': sellerDefinedAudience + }, + 'site': { + 'content': { + 'data': sellerDefinedContext + } + } } }); + const request = spec.buildRequests(DEFAULT_PARAMS); expect(request[0]).to.have.property('url').and.to.equal('https://prg.smartadserver.com/prebid/v1'); expect(request[0]).to.have.property('method').and.to.equal('POST'); @@ -186,6 +286,8 @@ describe('Smart bid adapter tests', function () { expect(requestContent).to.have.property('buid').and.to.equal('7569'); expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); expect(requestContent).to.have.property('ckid').and.to.equal(42); + expect(requestContent).to.have.property('sda').and.to.deep.equal(sellerDefinedAudience); + expect(requestContent).to.have.property('sdc').and.to.deep.equal(sellerDefinedContext); }); it('Verify parse response with no ad', function () { @@ -200,6 +302,27 @@ describe('Smart bid adapter tests', function () { }).to.not.throw(); }); + it('Should not nest response if ad and adUrl empty', () => { + const BID_RESPONSE_EMPTY = { + body: { + ad: null, + adUrl: null, + cpm: 0.92, + isNoAd: false + } + }; + + const request = spec.buildRequests(DEFAULT_PARAMS); + const bids = spec.interpretResponse(BID_RESPONSE_EMPTY, request[0]); + + expect(bids).to.have.lengthOf(0); + expect(() => { + spec.interpretResponse(BID_RESPONSE_EMPTY, { + data: 'invalid Json' + }); + }).to.not.throw(); + }); + it('Verify parse response', function () { const request = spec.buildRequests(DEFAULT_PARAMS); const bids = spec.interpretResponse(BID_RESPONSE, request[0]); @@ -337,8 +460,8 @@ describe('Smart bid adapter tests', function () { describe('gdpr tests', function () { afterEach(function () { + config.setConfig({ ortb2: undefined }); config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); it('Verify build request with GDPR', function () { @@ -387,10 +510,33 @@ describe('Smart bid adapter tests', function () { }); }); + describe('GPP', function () { + it('should be added to payload when gppConsent available in bidder request', function () { + const options = { + gppConsent: { + gppString: 'some-gpp-string', + applicableSections: [3, 5] + } + }; + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, options); + const payload = JSON.parse(request[0].data); + + expect(payload).to.have.property('gpp').and.to.equal(options.gppConsent.gppString); + expect(payload).to.have.property('gpp_sid').and.to.be.an('array'); + expect(payload.gpp_sid).to.have.lengthOf(2).and.to.deep.equal(options.gppConsent.applicableSections); + }); + + it('should be undefined on payload when gppConsent unavailable in bidder request', function () { + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL, {}); + const payload = JSON.parse(request[0].data); + + expect(payload.gpp).to.be.undefined; + }); + }); + describe('ccpa/us privacy tests', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); it('Verify build request with us privacy', function () { @@ -419,7 +565,6 @@ describe('Smart bid adapter tests', function () { describe('Instream video tests', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); const INSTREAM_DEFAULT_PARAMS = [{ @@ -446,7 +591,11 @@ describe('Smart bid adapter tests', function () { } }, requestId: 'efgh5678', - transactionId: 'zsfgzzg' + ortb2Imp: { + ext: { + tid: 'zsfgzzg', + } + }, }]; var INSTREAM_BID_RESPONSE = { @@ -468,6 +617,16 @@ describe('Smart bid adapter tests', function () { config.setConfig({ 'currency': { 'adServerCurrency': 'EUR' + }, + ortb2: { + 'user': { + 'data': sellerDefinedAudience + }, + 'site': { + 'content': { + 'data': sellerDefinedContext + } + } } }); const request = spec.buildRequests(INSTREAM_DEFAULT_PARAMS); @@ -486,6 +645,8 @@ describe('Smart bid adapter tests', function () { expect(requestContent).to.have.property('buid').and.to.equal('7569'); expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); expect(requestContent).to.have.property('ckid').and.to.equal(42); + expect(requestContent).to.have.property('sda').and.to.deep.equal(sellerDefinedAudience); + expect(requestContent).to.have.property('sdc').and.to.deep.equal(sellerDefinedContext); expect(requestContent).to.have.property('isVideo').and.to.equal(true); expect(requestContent).to.have.property('videoData'); expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(6); @@ -678,7 +839,6 @@ describe('Smart bid adapter tests', function () { describe('Outstream video tests', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); const OUTSTREAM_DEFAULT_PARAMS = [{ @@ -704,7 +864,11 @@ describe('Smart bid adapter tests', function () { protocol: 7 } }, - requestId: 'efgh5679', + ortb2Imp: { + ext: { + tid: 'efgh5679', + } + }, transactionId: 'zsfgzzga' }]; @@ -727,6 +891,16 @@ describe('Smart bid adapter tests', function () { config.setConfig({ 'currency': { 'adServerCurrency': 'EUR' + }, + ortb2: { + 'user': { + 'data': sellerDefinedAudience + }, + 'site': { + 'content': { + 'data': sellerDefinedContext + } + } } }); const request = spec.buildRequests(OUTSTREAM_DEFAULT_PARAMS); @@ -745,6 +919,8 @@ describe('Smart bid adapter tests', function () { expect(requestContent).to.have.property('buid').and.to.equal('7579'); expect(requestContent).to.have.property('appname').and.to.equal('Mozilla'); expect(requestContent).to.have.property('ckid').and.to.equal(43); + expect(requestContent).to.have.property('sda').and.to.deep.equal(sellerDefinedAudience); + expect(requestContent).to.have.property('sdc').and.to.deep.equal(sellerDefinedContext); expect(requestContent).to.have.property('isVideo').and.to.equal(false); expect(requestContent).to.have.property('videoData'); expect(requestContent.videoData).to.have.property('videoProtocol').and.to.equal(7); @@ -975,6 +1151,17 @@ describe('Smart bid adapter tests', function () { }); describe('Floors module', function () { + const getFloor = (bid) => { + switch (bid.mediaType) { + case BANNER: + return { currency: 'USD', floor: 1.93 }; + case VIDEO: + return { currency: 'USD', floor: 2.72 }; + default: + return {}; + } + }; + it('should include floor from bid params', function() { const bidRequest = JSON.parse((spec.buildRequests(DEFAULT_PARAMS))[0].data); expect(bidRequest.bidfloor).to.deep.equal(DEFAULT_PARAMS[0].params.bidfloor); @@ -1014,12 +1201,91 @@ describe('Smart bid adapter tests', function () { const floor = spec.getBidFloor(bidRequest, null); expect(floor).to.deep.equal(0); }); + + it('should take floor from bidder params over ad unit', function() { + const bidRequest = [{ + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + getFloor, + params: { siteId: 1234, pageId: 678, formatId: 73, bidfloor: 1.25 } + }]; + + const request = spec.buildRequests(bidRequest); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('bidfloor').and.to.equal(1.25); + }); + + it('should take floor from banner ad unit', function() { + const bidRequest = [{ + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + getFloor, + params: { siteId: 1234, pageId: 678, formatId: 73 } + }]; + + const request = spec.buildRequests(bidRequest); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('bidfloor').and.to.equal(1.93); + }); + + it('should take floor from video ad unit', function() { + const bidRequest = [{ + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[640, 480]] + } + }, + getFloor, + params: { siteId: 1234, pageId: 678, formatId: 73 } + }]; + + const request = spec.buildRequests(bidRequest); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('bidfloor').and.to.equal(2.72); + }); + + it('should take floor from multiple media type ad unit', function() { + const bidRequest = [{ + mediaTypes: { + banner: { + sizes: [[300, 600]] + }, + video: { + context: 'outstream', + playerSize: [[640, 480]] + } + }, + getFloor, + params: { siteId: 1234, pageId: 678, formatId: 73 } + }]; + + const requests = spec.buildRequests(bidRequest); + expect(requests).to.have.lengthOf(2); + + const requestContents = requests.map(r => JSON.parse(r.data)); + const videoRequest = requestContents.filter(r => r.videoData)[0]; + expect(videoRequest).to.not.equal(null).and.to.not.be.undefined; + expect(videoRequest).to.have.property('bidfloor').and.to.equal(2.72); + + const bannerRequest = requestContents.filter(r => !r.videoData)[0]; + expect(bannerRequest).to.not.equal(null).and.to.not.be.undefined; + expect(bannerRequest).to.have.property('bidfloor').and.to.equal(1.93); + }); }); describe('Verify bid requests with multiple mediaTypes', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); var DEFAULT_PARAMS_MULTIPLE_MEDIA_TYPES = [{ @@ -1086,4 +1352,45 @@ describe('Smart bid adapter tests', function () { expect(bannerRequest).to.have.property('formatid').and.to.equal('90'); }); }); + + describe('Global Placement ID (GPID)', function () { + it('should not include gpid by default', () => { + const request = spec.buildRequests(DEFAULT_PARAMS_WO_OPTIONAL); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.not.have.property('gdid'); + }); + + it('should include gpid if pbadslot in ortb2Imp', () => { + const gpid = '/19968336/header-bid-tag-1'; + const bidRequests = deepClone(DEFAULT_PARAMS_WO_OPTIONAL); + + bidRequests[0].ortb2Imp = { + ext: { + data: { + pbadslot: gpid + } + } + }; + + const request = spec.buildRequests(bidRequests); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('gpid').and.to.equal(gpid); + }); + + it('should include gpid if imp[].ext.gpid exists', () => { + const gpid = '/1111/homepage#div-leftnav'; + const bidRequests = deepClone(DEFAULT_PARAMS_WO_OPTIONAL); + + bidRequests[0].ortb2Imp = { + ext: { gpid } + }; + + const request = spec.buildRequests(bidRequests); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('gpid').and.to.equal(gpid); + }); + }); }); diff --git a/test/spec/modules/smarthubBidAdapter_spec.js b/test/spec/modules/smarthubBidAdapter_spec.js index 05fb1424dca..e01d0c72f6b 100644 --- a/test/spec/modules/smarthubBidAdapter_spec.js +++ b/test/spec/modules/smarthubBidAdapter_spec.js @@ -90,8 +90,9 @@ describe('SmartHubBidAdapter', function () { uspConsent: '1---', gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', refererInfo: { - referer: 'https://test.com' - } + page: 'https://test.com' + }, + timeout: 500 }; describe('isBidRequestValid', function () { diff --git a/test/spec/modules/smartxBidAdapter_spec.js b/test/spec/modules/smartxBidAdapter_spec.js index ddee2fa3347..c3d0711632e 100644 --- a/test/spec/modules/smartxBidAdapter_spec.js +++ b/test/spec/modules/smartxBidAdapter_spec.js @@ -145,7 +145,7 @@ describe('The smartx adapter', function () { bid = getValidBidObject(); bidRequestObj = { refererInfo: { - referer: 'prebid.js' + page: 'prebid.js' } }; }); @@ -342,6 +342,48 @@ describe('The smartx adapter', function () { expect(request.data.imp[0].video.minduration).to.equal(3); expect(request.data.imp[0].video.maxduration).to.equal(15); }); + + it('should pass schain param', function () { + var request; + + bid.schain = { + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1 + } + ] + } + + request = spec.buildRequests([bid], bidRequestObj)[0]; + + expect(request.data.source).to.deep.equal({ + ext: { + schain: { + complete: 1, + nodes: [ + { + asi: 'indirectseller.com', + sid: '00001', + hp: 1 + } + ] + } + } + }) + }); + + it('should pass sitekey param', function () { + var request; + + bid.params.sitekey = 'foo' + + request = spec.buildRequests([bid], bidRequestObj)[0]; + + expect(request.data.site.content.ext.sitekey).to.equal('foo'); + }); }); describe('interpretResponse', function () { @@ -514,7 +556,7 @@ describe('The smartx adapter', function () { responses[0].renderer.render(responses[0]); - expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777778'); + expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777779'); window.document.getElementById.restore(); }); @@ -542,7 +584,7 @@ describe('The smartx adapter', function () { responses[0].renderer.render(responses[0]); - expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777778'); + expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777779'); window.document.getElementById.restore(); }); @@ -560,7 +602,7 @@ describe('The smartx adapter', function () { responses[0].renderer.render(responses[0]); - expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777778'); + expect(responses[0].renderer.url).to.equal('https://dco.smartclip.net/?plc=7777779'); window.document.getElementById.restore(); }); @@ -574,7 +616,7 @@ describe('The smartx adapter', function () { bid = getValidBidObject(); bidRequestObj = { refererInfo: { - referer: 'prebid.js' + page: 'prebid.js' } }; delete bid.params.bidfloor; diff --git a/test/spec/modules/smartyadsBidAdapter_spec.js b/test/spec/modules/smartyadsBidAdapter_spec.js index 3474753c838..992fff14f33 100644 --- a/test/spec/modules/smartyadsBidAdapter_spec.js +++ b/test/spec/modules/smartyadsBidAdapter_spec.js @@ -1,6 +1,7 @@ import {expect} from 'chai'; import {spec} from '../../../modules/smartyadsBidAdapter.js'; import { config } from '../../../src/config.js'; +import {server} from '../../mocks/xhr'; describe('SmartyadsAdapter', function () { let bid = { @@ -14,6 +15,21 @@ describe('SmartyadsAdapter', function () { } }; + let bidResponse = { + width: 300, + height: 250, + mediaType: 'banner', + ad: `test mode`, + requestId: '23fhj33i987f', + cpm: 0.1, + ttl: 120, + creativeId: '123', + netRevenue: true, + currency: 'USD', + dealId: 'HASH', + sid: 1234 + }; + describe('isBidRequestValid', function () { it('Should return true if there are bidId, params and sourceid parameters present', function () { expect(spec.isBidRequestValid(bid)).to.be.true; @@ -243,7 +259,7 @@ describe('SmartyadsAdapter', function () { }); }); describe('getUserSyncs', function () { - const syncUrl = 'https://as.ck-ie.com/prebidjs?p=7c47322e527cf8bdeb7facc1bb03387a&gdpr=0&gdpr_consent=&type=iframe&us_privacy='; + const syncUrl = 'https://as.ck-ie.com/prebidjs?p=7c47322e527cf8bdeb7facc1bb03387a&gdpr=0&gdpr_consent=&type=iframe&us_privacy=&gpp='; const syncOptions = { iframeEnabled: true }; @@ -257,4 +273,79 @@ describe('SmartyadsAdapter', function () { ]); }); }); + + describe('onBidWon', function () { + it('should exists', function () { + expect(spec.onBidWon).to.exist.and.to.be.a('function'); + }); + + it('should send a valid bid won notice', function () { + const bid = { + 'c': 'o', + 'm': 'prebid', + 'secret_key': 'prebid_js', + 'winTest': '1', + 'postData': [{ + 'bidder': 'smartyads', + 'params': [ + {'host': 'prebid', + 'accountid': '123', + 'sourceid': '12345' + }] + }] + }; + spec.onBidWon(bid); + expect(server.requests.length).to.equal(1); + }); + }); + + describe('onTimeout', function () { + it('should exists', function () { + expect(spec.onTimeout).to.exist.and.to.be.a('function'); + }); + + it('should send a valid bid timeout notice', function () { + const bid = { + 'c': 'o', + 'm': 'prebid', + 'secret_key': 'prebid_js', + 'bidTimeout': '1', + 'postData': [{ + 'bidder': 'smartyads', + 'params': [ + {'host': 'prebid', + 'accountid': '123', + 'sourceid': '12345' + }] + }] + }; + spec.onTimeout(bid); + expect(server.requests.length).to.equal(1); + }); + }); + + describe('onBidderError', function () { + it('should exists', function () { + expect(spec.onBidderError).to.exist.and.to.be.a('function'); + }); + + it('should send a valid bidder error notice', function () { + const bid = { + 'c': 'o', + 'm': 'prebid', + 'secret_key': 'prebid_js', + 'bidderError': '1', + 'postData': [{ + 'bidder': 'smartyads', + 'params': [ + {'host': 'prebid', + 'accountid': '123', + 'sourceid': '12345' + }] + }] + }; + spec.onBidderError(bid); + expect(server.requests.length).to.equal(1); + }); + }); }); diff --git a/test/spec/modules/smartytechBidAdapter_spec.js b/test/spec/modules/smartytechBidAdapter_spec.js new file mode 100644 index 00000000000..6b3147859bf --- /dev/null +++ b/test/spec/modules/smartytechBidAdapter_spec.js @@ -0,0 +1,357 @@ +import {expect} from 'chai'; +import {spec, ENDPOINT_PROTOCOL, ENDPOINT_DOMAIN, ENDPOINT_PATH} from 'modules/smartytechBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory.js'; + +const BIDDER_CODE = 'smartytech'; + +describe('SmartyTechDSPAdapter: inherited functions', function () { + let adapter; + beforeEach(() => { + adapter = newBidder(spec); + }); + it('exists and is a function', function () { + expect(adapter.callBids).to.be.exist.and.to.be.a('function'); + }); + it(`bidder code is ${BIDDER_CODE}`, function () { + expect(spec.code).to.be.equal(BIDDER_CODE); + }) +}); + +describe('SmartyTechDSPAdapter: isBidRequestValid', function () { + it('Invalid bid request. Should return false', function () { + const bidFixture = { + params: { + use_id: 13144375 + } + } + + expect(spec.isBidRequestValid(bidFixture)).to.be.false + }); + it('Valid bid request. Should return true', function () { + const bidFixture = { + params: { + endpointId: 13144375 + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.true + }); + + it('Invalid bid request. Check video block', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + video: {} + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.false + }); + + it('Invalid bid request. Check playerSize', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + video: { + playerSize: '300x250' + } + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.false + }); + + it('Invalid bid request. Check context', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + video: { + playerSize: [300, 250] + } + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.false + }); + + it('Valid bid request. valid video bid', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + video: { + playerSize: [300, 250], + context: 'instream' + } + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.true + }); + + it('Invalid bid request. Check banner block', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + banner: {} + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.false + }); + + it('Invalid bid request. Check banner sizes', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + banner: { + sizes: '300x250' + } + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.false + }); + + it('Valid bid request. valid banner bid', function () { + const bidFixture = { + params: { + endpointId: 1 + }, + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + } + } + expect(spec.isBidRequestValid(bidFixture)).to.be.true + }); +}); + +function mockRandomSizeArray(len) { + return Array.apply(null, {length: len}).map(i => { + return [Math.floor(Math.random() * 800), Math.floor(Math.random() * 800)] + }); +} + +function mockBidRequestListData(mediaType, size, customSizes) { + return Array.apply(null, {length: size}).map((i, index) => { + const id = Math.floor(Math.random() * 800) * (index + 1); + let mediaTypes; + let params = { + endpointId: id + } + + if (mediaType == 'video') { + mediaTypes = { + video: { + playerSize: mockRandomSizeArray(1), + context: 'instream' + }, + } + } else { + mediaTypes = { + banner: { + sizes: mockRandomSizeArray(index + 1) + } + } + } + + if (customSizes === undefined || customSizes.length > 0) { + params.sizes = customSizes + } + + return { + adUnitCode: `adUnitCode-${id}`, + mediaTypes: mediaTypes, + bidId: `bidId-${id}`, + params: params + } + }); +} + +function mockRefererData() { + return { + refererInfo: { + page: 'https://some-test.page' + } + } +} + +function mockResponseData(requestData) { + let data = {} + requestData.data.forEach((request, index) => { + const rndIndex = Math.floor(Math.random() * 800); + let width, height, mediaType; + if (request.video !== undefined) { + width = request.video.playerSize[0][0]; + height = request.video.playerSize[0][1]; + mediaType = 'video'; + } else { + width = request.banner.sizes[0][0]; + height = request.banner.sizes[0][1]; + mediaType = 'banner'; + } + + data[request.adUnitCode] = { + ad: `ad-${rndIndex}`, + width: width, + height: height, + creativeId: `creative-id-${index}`, + cpm: Math.floor(Math.random() * 100), + currency: `UAH-${rndIndex}`, + mediaType: mediaType + }; + }); + return { + body: data + } +}; + +describe('SmartyTechDSPAdapter: buildRequests', () => { + let mockBidRequest; + let mockReferer; + beforeEach(() => { + mockBidRequest = mockBidRequestListData('banner', 8, []); + mockReferer = mockRefererData(); + }); + it('has return data', () => { + const request = spec.buildRequests(mockBidRequest, mockReferer); + expect(request).not.null; + }); + it('correct request URL', () => { + const request = spec.buildRequests(mockBidRequest, mockReferer); + expect(request.url).to.be.equal(`${ENDPOINT_PROTOCOL}://${ENDPOINT_DOMAIN}${ENDPOINT_PATH}`) + }); + it('correct request method', () => { + const request = spec.buildRequests(mockBidRequest, mockReferer); + expect(request.method).to.be.equal(`POST`) + }); + it('correct request data', () => { + const data = spec.buildRequests(mockBidRequest, mockReferer).data; + data.forEach((request, index) => { + expect(request.adUnitCode).to.be.equal(mockBidRequest[index].adUnitCode); + expect(request.banner).to.be.equal(mockBidRequest[index].mediaTypes.banner); + expect(request.bidId).to.be.equal(mockBidRequest[index].bidId); + expect(request.endpointId).to.be.equal(mockBidRequest[index].params.endpointId); + expect(request.referer).to.be.equal(mockReferer.refererInfo.page); + }) + }); +}); + +describe('SmartyTechDSPAdapter: buildRequests banner custom size', () => { + let mockBidRequest; + let mockReferer; + beforeEach(() => { + mockBidRequest = mockBidRequestListData('banner', 8, [[300, 600]]); + mockReferer = mockRefererData(); + }); + + it('correct request data', () => { + const data = spec.buildRequests(mockBidRequest, mockReferer).data; + data.forEach((request, index) => { + expect(request.banner.sizes).to.be.equal(mockBidRequest[index].params.sizes); + }) + }); +}); + +describe('SmartyTechDSPAdapter: buildRequests video custom size', () => { + let mockBidRequest; + let mockReferer; + beforeEach(() => { + mockBidRequest = mockBidRequestListData('video', 8, [[300, 300], [250, 250]]); + mockReferer = mockRefererData(); + }); + + it('correct request data', () => { + const data = spec.buildRequests(mockBidRequest, mockReferer).data; + data.forEach((request, index) => { + expect(request.video.sizes).to.be.equal(mockBidRequest[index].params.sizes); + }) + }); +}); + +describe('SmartyTechDSPAdapter: interpretResponse', () => { + let mockBidRequest; + let mockReferer; + let request; + let mockResponse; + beforeEach(() => { + const brData = mockBidRequestListData('banner', 2, []); + mockReferer = mockRefererData(); + request = spec.buildRequests(brData, mockReferer); + mockBidRequest = { + data: brData + } + mockResponse = mockResponseData(request); + }); + + it('interpretResponse: empty data request', () => { + delete mockResponse['body'] + const data = spec.interpretResponse(mockResponse, mockBidRequest); + expect(data.length).to.be.equal(0); + }); + + it('interpretResponse: response data and convert data arrays has same length', () => { + const keys = Object.keys(mockResponse.body); + const data = spec.interpretResponse(mockResponse, mockBidRequest); + expect(data.length).to.be.equal(keys.length); + }); + + it('interpretResponse: convert to correct data', () => { + const keys = Object.keys(mockResponse.body); + const data = spec.interpretResponse(mockResponse, mockBidRequest); + + data.forEach((responseItem, index) => { + expect(responseItem.ad).to.be.equal(mockResponse.body[keys[index]].ad); + expect(responseItem.cpm).to.be.equal(mockResponse.body[keys[index]].cpm); + expect(responseItem.creativeId).to.be.equal(mockResponse.body[keys[index]].creativeId); + expect(responseItem.currency).to.be.equal(mockResponse.body[keys[index]].currency); + expect(responseItem.netRevenue).to.be.true; + expect(responseItem.ttl).to.be.equal(60); + expect(responseItem.requestId).to.be.equal(mockBidRequest.data[index].bidId); + expect(responseItem.width).to.be.equal(mockResponse.body[keys[index]].width); + expect(responseItem.height).to.be.equal(mockResponse.body[keys[index]].height); + expect(responseItem.mediaType).to.be.equal(mockResponse.body[keys[index]].mediaType); + }); + }); +}); + +describe('SmartyTechDSPAdapter: interpretResponse video', () => { + let mockBidRequest; + let mockReferer; + let request; + let mockResponse; + beforeEach(() => { + const brData = mockBidRequestListData('video', 2, []); + mockReferer = mockRefererData(); + request = spec.buildRequests(brData, mockReferer); + mockBidRequest = { + data: brData + } + mockResponse = mockResponseData(request); + }); + + it('interpretResponse: convert to correct data', () => { + const keys = Object.keys(mockResponse.body); + const data = spec.interpretResponse(mockResponse, mockBidRequest); + + data.forEach((responseItem, index) => { + expect(responseItem.ad).to.be.equal(mockResponse.body[keys[index]].ad); + expect(responseItem.cpm).to.be.equal(mockResponse.body[keys[index]].cpm); + expect(responseItem.creativeId).to.be.equal(mockResponse.body[keys[index]].creativeId); + expect(responseItem.currency).to.be.equal(mockResponse.body[keys[index]].currency); + expect(responseItem.netRevenue).to.be.true; + expect(responseItem.ttl).to.be.equal(60); + expect(responseItem.requestId).to.be.equal(mockBidRequest.data[index].bidId); + expect(responseItem.width).to.be.equal(mockResponse.body[keys[index]].width); + expect(responseItem.height).to.be.equal(mockResponse.body[keys[index]].height); + expect(responseItem.mediaType).to.be.equal(mockResponse.body[keys[index]].mediaType); + expect(responseItem.vastXml).to.be.equal(mockResponse.body[keys[index]].ad); + }); + }); +}); diff --git a/test/spec/modules/smilewantedBidAdapter_spec.js b/test/spec/modules/smilewantedBidAdapter_spec.js index 0359e470f9b..22221dbe1ef 100644 --- a/test/spec/modules/smilewantedBidAdapter_spec.js +++ b/test/spec/modules/smilewantedBidAdapter_spec.js @@ -1,9 +1,6 @@ import { expect } from 'chai'; import { spec } from 'modules/smilewantedBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; import { config } from 'src/config.js'; -import * as utils from 'src/utils.js'; -import { requestBidsHook } from 'modules/consentManagement.js'; const DISPLAY_REQUEST = [{ adUnitCode: 'sw_300x250', @@ -17,7 +14,46 @@ const DISPLAY_REQUEST = [{ zoneId: 1 }, requestId: 'request_abcd1234', - transactionId: 'trans_abcd1234' + ortb2Imp: { + ext: { + tid: 'trans_abcd1234', + } + }, +}]; + +const DISPLAY_REQUEST_WITH_EIDS = [{ + adUnitCode: 'sw_300x250', + bidId: '12345', + sizes: [ + [300, 250], + [300, 200] + ], + bidder: 'smilewanted', + params: { + zoneId: 1 + }, + requestId: 'request_abcd1234', + ortb2Imp: { + ext: { + tid: 'trans_abcd1234', + } + }, + userIdAsEids: [{ + source: 'pubcid.org', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }, { + source: 'adserver.org', + uids: [{ + id: 'some-random-id-value', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + }] }]; const DISPLAY_REQUEST_WITH_POSITION_TYPE = [{ @@ -33,7 +69,11 @@ const DISPLAY_REQUEST_WITH_POSITION_TYPE = [{ positionType: 'infeed' }, requestId: 'request_abcd1234', - transactionId: 'trans_abcd1234' + ortb2Imp: { + ext: { + tid: 'trans_abcd1234', + } + }, }]; const BID_RESPONSE_DISPLAY = { @@ -64,7 +104,11 @@ const VIDEO_INSTREAM_REQUEST = [{ bidfloor: 2.50 }, requestId: 'request_abcd1234', - transactionId: 'trans_abcd1234' + ortb2Imp: { + ext: { + tid: 'trans_abcd1234', + } + } }]; const BID_RESPONSE_VIDEO_INSTREAM = { @@ -96,7 +140,11 @@ const VIDEO_OUTSTREAM_REQUEST = [{ bidfloor: 2.50 }, requestId: 'request_abcd1234', - transactionId: 'trans_abcd1234' + ortb2Imp: { + ext: { + tid: 'trans_abcd1234', + } + } }]; const BID_RESPONSE_VIDEO_OUTSTREAM = { @@ -163,17 +211,39 @@ describe('smilewantedBidAdapterTests', function () { it('SmileWanted - Verify build request with referrer', function () { const request = spec.buildRequests(DISPLAY_REQUEST, { refererInfo: { - referer: 'https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' + page: 'https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html' } }); const requestContent = JSON.parse(request[0].data); expect(requestContent).to.have.property('pageDomain').and.to.equal('https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html'); }); + it('Verify external ids in request and ids found', function () { + config.setConfig({ + 'currency': { + 'adServerCurrency': 'EUR' + } + }); + const request = spec.buildRequests(DISPLAY_REQUEST_WITH_EIDS, {}); + const requestContent = JSON.parse(request[0].data); + + expect(requestContent).to.have.property('eids'); + expect(requestContent.eids).to.not.equal(null).and.to.not.be.undefined; + expect(requestContent.eids.length).to.greaterThan(0); + for (let index in requestContent.eids) { + let eid = requestContent.eids[index]; + expect(eid.source).to.not.equal(null).and.to.not.be.undefined; + expect(eid.uids).to.not.equal(null).and.to.not.be.undefined; + for (let uidsIndex in eid.uids) { + let uid = eid.uids[uidsIndex]; + expect(uid.id).to.not.equal(null).and.to.not.be.undefined; + } + } + }); + describe('gdpr tests', function () { afterEach(function () { config.resetConfig(); - $$PREBID_GLOBAL$$.requestBids.removeAll(); }); it('SmileWanted - Verify build request with GDPR', function () { diff --git a/test/spec/modules/snigelBidAdapter_spec.js b/test/spec/modules/snigelBidAdapter_spec.js new file mode 100644 index 00000000000..7fe2387ca6c --- /dev/null +++ b/test/spec/modules/snigelBidAdapter_spec.js @@ -0,0 +1,347 @@ +import {expect} from 'chai'; +import {spec} from 'modules/snigelBidAdapter.js'; +import {config} from 'src/config.js'; +import {isValid} from 'src/adapters/bidderFactory.js'; + +const BASE_BID_REQUEST = { + adUnitCode: 'top_leaderboard', + bidId: 'bid_test', + sizes: [ + [970, 90], + [728, 90], + ], + bidder: 'snigel', + params: {}, + requestId: 'req_test', + transactionId: 'trans_test', +}; +const makeBidRequest = function (overrides) { + return {...BASE_BID_REQUEST, ...overrides}; +}; + +const BASE_BIDDER_REQUEST = { + auctionId: 'test', + bidderRequestId: 'test', + refererInfo: { + canonicalUrl: 'https://localhost', + }, +}; +const makeBidderRequest = function (overrides) { + return {...BASE_BIDDER_REQUEST, ...overrides}; +}; + +const DUMMY_USP_CONSENT = '1YYN'; +const DUMMY_GDPR_CONSENT_STRING = + 'BOSSotLOSSotLAPABAENBc-AAAAgR7_______9______9uz_Gv_v_f__33e8__9v_l_7_-___u_-33d4-_1vX99yfm1-7ftr3tp_86ues2_XqK_9oIiA'; + +describe('snigelBidAdapter', function () { + describe('isBidRequestValid', function () { + it('should return false if no placement provided', function () { + expect(spec.isBidRequestValid(BASE_BID_REQUEST)).to.equal(false); + }); + + it('should return true if placement provided', function () { + const bidRequest = makeBidRequest({params: {placement: 'top_leaderboard'}}); + expect(spec.isBidRequestValid(bidRequest)).to.equal(true); + }); + }); + + describe('buildRequests', function () { + afterEach(function () { + config.resetConfig(); + }); + + it('should build a single request for every impression and its placement', function () { + const bidderRequest = Object.assign({}, BASE_BIDDER_REQUEST); + const bidRequests = [ + makeBidRequest({bidId: 'a', adUnitCode: 'au_a', params: {placement: 'top_leaderboard'}}), + makeBidRequest({bidId: 'b', adUnitCode: 'au_b', params: {placement: 'bottom_leaderboard'}}), + ]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request).to.be.an('object'); + expect(request).to.have.property('url').and.to.equal('https://adserv.snigelweb.com/bp/v1/prebid'); + expect(request).to.have.property('method').and.to.equal('POST'); + + expect(request).to.have.property('data'); + const data = JSON.parse(request.data); + expect(data).to.have.property('id').and.to.equal('test'); + expect(data).to.have.property('cur').and.to.deep.equal(['USD']); + expect(data).to.have.property('test').and.to.equal(false); + expect(data).to.have.property('page').and.to.equal('https://localhost'); + expect(data).to.have.property('placements'); + expect(data.placements.length).to.equal(2); + expect(data.placements[0].id).to.equal('au_a'); + expect(data.placements[0].name).to.equal('top_leaderboard'); + expect(data.placements[1].id).to.equal('au_b'); + expect(data.placements[1].name).to.equal('bottom_leaderboard'); + }); + + it('should forward GDPR flag and GDPR consent string if enabled', function () { + const bidderRequest = makeBidderRequest({ + gdprConsent: { + gdprApplies: true, + consentString: DUMMY_GDPR_CONSENT_STRING, + }, + }); + + const request = spec.buildRequests([], bidderRequest); + expect(request).to.have.property('data'); + const data = JSON.parse(request.data); + expect(data).to.have.property('gdprApplies').and.to.equal(true); + expect(data).to.have.property('gdprConsentString').and.to.equal(DUMMY_GDPR_CONSENT_STRING); + }); + + it('should forward GDPR flag and no GDPR consent string if disabled', function () { + const bidderRequest = makeBidderRequest({ + gdprConsent: { + gdprApplies: false, + consentString: DUMMY_GDPR_CONSENT_STRING, + }, + }); + + const request = spec.buildRequests([], bidderRequest); + expect(request).to.have.property('data'); + const data = JSON.parse(request.data); + expect(data).to.have.property('gdprApplies').and.to.equal(false); + expect(data).to.not.have.property('gdprConsentString'); + }); + + it('should forward USP consent if set', function () { + const bidderRequest = makeBidderRequest({ + uspConsent: DUMMY_USP_CONSENT, + }); + + const request = spec.buildRequests([], bidderRequest); + expect(request).to.have.property('data'); + const data = JSON.parse(request.data); + expect(data).to.have.property('uspConsent').and.to.equal(DUMMY_USP_CONSENT); + }); + + it('should forward whether or not COPPA applies', function () { + config.setConfig({ + 'coppa': true, + }); + + const request = spec.buildRequests([], BASE_BIDDER_REQUEST); + expect(request).to.have.property('data'); + const data = JSON.parse(request.data); + expect(data).to.have.property('coppa').and.to.equal(true); + }); + + it('should forward refresh information', function () { + const bidderRequest = Object.assign({}, BASE_BIDDER_REQUEST); + const topLeaderboard = makeBidRequest({adUnitCode: 'top_leaderboard'}); + const bottomLeaderboard = makeBidRequest({adUnitCode: 'bottom_leaderboard'}); + const sidebar = makeBidRequest({adUnitCode: 'sidebar'}); + + // first auction, no refresh + let request = spec.buildRequests([topLeaderboard, bottomLeaderboard], bidderRequest); + expect(request).to.have.property('data'); + let data = JSON.parse(request.data); + expect(data).to.have.property('placements'); + expect(data.placements.length).to.equal(2); + expect(data.placements[0].id).to.equal('top_leaderboard'); + expect(data.placements[0].refresh).to.be.undefined; + expect(data.placements[1].id).to.equal('bottom_leaderboard'); + expect(data.placements[1].refresh).to.be.undefined; + + // second auction for top leaderboard, was refreshed + request = spec.buildRequests([topLeaderboard, sidebar], bidderRequest); + expect(request).to.have.property('data'); + data = JSON.parse(request.data); + expect(data).to.have.property('placements'); + expect(data.placements.length).to.equal(2); + expect(data.placements[0].id).to.equal('top_leaderboard'); + expect(data.placements[0].refresh).to.not.be.undefined; + expect(data.placements[0].refresh.count).to.equal(1); + expect(data.placements[0].refresh.time).to.be.greaterThanOrEqual(0); + expect(data.placements[1].id).to.equal('sidebar'); + expect(data.placements[1].refresh).to.be.undefined; + + // third auction, all units refreshed at some point + request = spec.buildRequests([topLeaderboard, bottomLeaderboard, sidebar], bidderRequest); + expect(request).to.have.property('data'); + data = JSON.parse(request.data); + expect(data).to.have.property('placements'); + expect(data.placements.length).to.equal(3); + expect(data.placements[0].id).to.equal('top_leaderboard'); + expect(data.placements[0].refresh).to.not.be.undefined; + expect(data.placements[0].refresh.count).to.equal(2); + expect(data.placements[0].refresh.time).to.be.greaterThanOrEqual(0); + expect(data.placements[1].id).to.equal('bottom_leaderboard'); + expect(data.placements[1].refresh).to.not.be.undefined; + expect(data.placements[1].refresh.count).to.equal(1); + expect(data.placements[1].refresh.time).to.be.greaterThanOrEqual(0); + expect(data.placements[2].id).to.equal('sidebar'); + expect(data.placements[2].refresh).to.not.be.undefined; + expect(data.placements[2].refresh.count).to.equal(1); + expect(data.placements[2].refresh.time).to.be.greaterThanOrEqual(0); + }); + }); + + describe('interpretResponse', function () { + it('should not return any bids if the request failed', function () { + expect(spec.interpretResponse({}, {})).to.be.empty; + expect(spec.interpretResponse({body: 'Some error message'}, {})).to.be.empty; + }); + + it('should not return any bids if the request did not return any bids either', function () { + expect(spec.interpretResponse({body: {bids: []}})).to.be.empty; + }); + + it('should return valid bids with additional meta information', function () { + const serverResponse = { + body: { + id: BASE_BIDDER_REQUEST.bidderRequestId, + cur: 'USD', + bids: [ + { + id: BASE_BID_REQUEST.adUnitCode, + price: 0.0575, + ad: '

Test Ad

', + width: 728, + height: 90, + crid: 'test', + meta: { + advertiserDomains: ['addomain.com'], + }, + }, + ], + }, + }; + + const bids = spec.interpretResponse(serverResponse, {bidderRequest: {bids: [BASE_BID_REQUEST]}}); + expect(bids.length).to.equal(1); + const bid = bids[0]; + expect(isValid(BASE_BID_REQUEST.adUnitCode, bid)).to.be.true; + expect(bid).to.have.property('meta'); + expect(bid.meta).to.have.property('advertiserDomains'); + expect(bid.meta.advertiserDomains).to.be.an('array'); + expect(bid.meta.advertiserDomains.length).to.equal(1); + expect(bid.meta.advertiserDomains[0]).to.equal('addomain.com'); + }); + }); + + describe('getUserSyncs', function () { + it('should not return any user syncs if sync url does not exist in response', function () { + const response = { + body: { + id: BASE_BIDDER_REQUEST.bidderRequestId, + cur: 'USD', + bids: [], + }, + }; + const syncOptions = { + iframeEnabled: true, + }; + const gdprConsent = { + gdprApplies: false, + }; + + const syncs = spec.getUserSyncs(syncOptions, [response], gdprConsent); + expect(syncs).to.be.undefined; + }); + + it('should not return any user syncs if publisher disabled iframe-based sync', function () { + const response = { + body: { + id: BASE_BIDDER_REQUEST.bidderRequestId, + cur: 'USD', + syncUrl: 'https://somesyncurl', + bids: [], + }, + }; + const syncOptions = { + iframeEnabled: false, + }; + const gdprConsent = { + gdprApplies: false, + }; + + const syncs = spec.getUserSyncs(syncOptions, [response], gdprConsent); + expect(syncs).to.be.undefined; + }); + + it('should not return any user syncs if GDPR applies and the user did not consent to purpose one', function () { + const response = { + body: { + id: BASE_BIDDER_REQUEST.bidderRequestId, + cur: 'USD', + syncUrl: 'https://somesyncurl', + bids: [], + }, + }; + const syncOptions = { + iframeEnabled: true, + }; + const gdprConsent = { + gdprApplies: true, + vendorData: { + purpose: { + consents: {1: false}, + }, + }, + }; + + const syncs = spec.getUserSyncs(syncOptions, [response], gdprConsent); + expect(syncs).to.be.undefined; + }); + + it("should return an iframe specific to the publisher's property if all conditions are met", function () { + const response = { + body: { + id: BASE_BIDDER_REQUEST.bidderRequestId, + cur: 'USD', + syncUrl: 'https://somesyncurl', + bids: [], + }, + }; + const syncOptions = { + iframeEnabled: true, + }; + const gdprConsent = { + gdprApplies: false, + }; + + const syncs = spec.getUserSyncs(syncOptions, [response], gdprConsent); + expect(syncs).to.be.an('array').and.of.length(1); + const sync = syncs[0]; + expect(sync).to.have.property('type'); + expect(sync.type).to.equal('iframe'); + expect(sync).to.have.property('url'); + expect(sync.url).to.equal('https://somesyncurl?gdpr=0&gdpr_consent='); + }); + + it('should pass GDPR applicability and consent string as query parameters', function () { + const response = { + body: { + id: BASE_BIDDER_REQUEST.bidderRequestId, + cur: 'USD', + syncUrl: 'https://somesyncurl', + bids: [], + }, + }; + const syncOptions = { + iframeEnabled: true, + }; + const gdprConsent = { + gdprApplies: true, + consentString: DUMMY_GDPR_CONSENT_STRING, + vendorData: { + purpose: { + consents: {1: true}, + }, + }, + }; + + const syncs = spec.getUserSyncs(syncOptions, [response], gdprConsent); + expect(syncs).to.be.an('array').and.of.length(1); + const sync = syncs[0]; + expect(sync).to.have.property('type'); + expect(sync.type).to.equal('iframe'); + expect(sync).to.have.property('url'); + expect(sync.url).to.equal(`https://somesyncurl?gdpr=1&gdpr_consent=${DUMMY_GDPR_CONSENT_STRING}`); + }); + }); +}); diff --git a/test/spec/modules/sonobiBidAdapter_spec.js b/test/spec/modules/sonobiBidAdapter_spec.js index f56f4e0c12b..164aa06d9b7 100644 --- a/test/spec/modules/sonobiBidAdapter_spec.js +++ b/test/spec/modules/sonobiBidAdapter_spec.js @@ -1,9 +1,9 @@ -import { expect } from 'chai' -import { spec, _getPlatform } from 'modules/sonobiBidAdapter.js' -import { newBidder } from 'src/adapters/bidderFactory.js' +import {expect} from 'chai'; +import {_getPlatform, spec} from 'modules/sonobiBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; import {userSync} from '../../../src/userSync.js'; -import { config } from 'src/config.js'; -import * as utils from '../../../src/utils.js'; +import {config} from 'src/config.js'; +import * as gptUtils from '../../../libraries/gptUtils/gptUtils.js'; describe('SonobiBidAdapter', function () { const adapter = newBidder(spec) @@ -193,7 +193,7 @@ describe('SonobiBidAdapter', function () { }); describe('outstream', () => { - it('should return false if there is no param sizes', () => { + it('should return false if there is no playerSize', () => { const bid = { 'bidder': 'sonobi', 'adUnitCode': 'adunit-code', @@ -203,7 +203,6 @@ describe('SonobiBidAdapter', function () { 'mediaTypes': { video: { context: 'outstream', - playerSize: [300, 250] } }, 'bidId': '30b31c1838de1e', @@ -213,7 +212,7 @@ describe('SonobiBidAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return true if there is param sizes', () => { + it('should return true if there is playerSize', () => { const bid = { 'bidder': 'sonobi', 'adUnitCode': 'adunit-code', @@ -224,7 +223,8 @@ describe('SonobiBidAdapter', function () { }, 'mediaTypes': { video: { - context: 'outstream' + context: 'outstream', + playerSize: [640, 480] } }, 'bidId': '30b31c1838de1e', @@ -238,16 +238,23 @@ describe('SonobiBidAdapter', function () { }); describe('.buildRequests', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + sonobi: { + storageAllowed: true + } + }; + }); let sandbox; - beforeEach(function() { + beforeEach(function () { sinon.stub(userSync, 'canBidderRegisterSync'); - sinon.stub(utils, 'getGptSlotInfoForAdUnitCode') - .onFirstCall().returns({gptSlot: '/123123/gpt_publisher/adunit-code-3', divId: 'adunit-code-3-div-id'}); + sinon.stub(gptUtils, 'getGptSlotInfoForAdUnitCode') + .onFirstCall().returns({ gptSlot: '/123123/gpt_publisher/adunit-code-3', divId: 'adunit-code-3-div-id' }); sandbox = sinon.createSandbox(); }); - afterEach(function() { + afterEach(function () { userSync.canBidderRegisterSync.restore(); - utils.getGptSlotInfoForAdUnitCode.restore(); + gptUtils.getGptSlotInfoForAdUnitCode.restore(); sandbox.restore(); }); let bidRequest = [{ @@ -284,6 +291,15 @@ describe('SonobiBidAdapter', function () { pbadslot: '/123123/gpt_publisher/adunit-code-1' } } + }, + mediaTypes: { + video: { + playerSize: [640, 480], + context: 'outstream', + playbackmethod: [1, 2, 3], + plcmt: 3, + placement: 2 + } } }, { @@ -296,11 +312,16 @@ describe('SonobiBidAdapter', function () { 'adUnitCode': 'adunit-code-3', 'sizes': [[120, 600], [300, 600], [160, 600]], 'bidId': '30b31c1838de1d', - 'getFloor': ({currency, mediaType, size}) => { + 'getFloor': ({ currency, mediaType, size }) => { return { currency: 'USD', floor: 0.42 } + }, + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } } }, { @@ -313,12 +334,17 @@ describe('SonobiBidAdapter', function () { 'adUnitCode': 'adunit-code-2', 'sizes': [[120, 600], [300, 600], [160, 600]], 'bidId': '30b31c1838de1e', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + } }]; let keyMakerData = { - '30b31c1838de1f': '1a2b3c4d5e6f1a2b3c4d|300x250,300x600|f=1.25|gpid=/123123/gpt_publisher/adunit-code-1', - '30b31c1838de1d': '1a2b3c4d5e6f1a2b3c4e|300x250,300x600|f=0.42|gpid=/123123/gpt_publisher/adunit-code-3', - '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600|gpid=/7780971/sparks_prebid_LB', + '30b31c1838de1f': '1a2b3c4d5e6f1a2b3c4d|640x480|f=1.25,gpid=/123123/gpt_publisher/adunit-code-1,c=v,pm=1:2:3,p=2,pl=3,', + '30b31c1838de1d': '1a2b3c4d5e6f1a2b3c4e|300x250,300x600|f=0.42,gpid=/123123/gpt_publisher/adunit-code-3,c=d,', + '/7780971/sparks_prebid_LB|30b31c1838de1e': '300x250,300x600|gpid=/7780971/sparks_prebid_LB,c=d,', }; let bidderRequests = { @@ -330,13 +356,13 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'https://example.com', + 'page': 'https://example.com', 'stack': ['https://example.com'] }, uspConsent: 'someCCPAString' }; - it('should set fpd if there is any data in ortb2', function() { + it('should set fpd if there is any data in ortb2', function () { const ortb2 = { site: { ext: { @@ -355,31 +381,28 @@ describe('SonobiBidAdapter', function () { } } }; - - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2: ortb2 - }; - return utils.deepAccess(config, key); - }); - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); + const bidRequests = spec.buildRequests(bidRequest, { ...bidderRequests, ortb2 }); expect(bidRequests.data.fpd).to.equal(JSON.stringify(ortb2)); }); it('should populate coppa as 1 if set in config', function () { - config.setConfig({coppa: true}); + config.setConfig({ coppa: true }); const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.coppa).to.equal(1); }); it('should populate coppa as 0 if set in config', function () { - config.setConfig({coppa: false}); + config.setConfig({ coppa: false }); const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.coppa).to.equal(0); }); + it('should have storageAllowed set to true', function () { + expect($$PREBID_GLOBAL$$.bidderSettings.sonobi.storageAllowed).to.be.true; + }); + it('should return a properly formatted request', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests) const bidRequestsPageViewID = spec.buildRequests(bidRequest, bidderRequests) @@ -389,6 +412,8 @@ describe('SonobiBidAdapter', function () { expect(bidRequests.data.ref).not.to.be.empty expect(bidRequests.data.s).not.to.be.empty expect(bidRequests.data.pv).to.equal(bidRequestsPageViewID.data.pv) + expect(JSON.parse(bidRequests.data.iqid).pcid).to.match(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/) + expect(JSON.parse(bidRequests.data.iqid).pcidDate).to.match(/^[0-9]{13}$/) expect(bidRequests.data.hfa).to.not.exist expect(bidRequests.bidderRequests).to.eql(bidRequest); expect(bidRequests.data.ref).to.equal('overrides_top_window_location'); @@ -427,7 +452,7 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'https://example.com', + 'page': 'https://example.com', 'stack': ['https://example.com'] } }; @@ -447,7 +472,7 @@ describe('SonobiBidAdapter', function () { 'refererInfo': { 'numIframes': 0, 'reachedTop': true, - 'referer': 'https://example.com', + 'page': 'https://example.com', 'stack': ['https://example.com'] } }; @@ -469,7 +494,7 @@ describe('SonobiBidAdapter', function () { }) it('should return null if there is nothing to bid on', function () { - const bidRequests = spec.buildRequests([{params: {}}], bidderRequests) + const bidRequests = spec.buildRequests([{ params: {} }], bidderRequests) expect(bidRequests).to.equal(null); }); @@ -479,7 +504,7 @@ describe('SonobiBidAdapter', function () { expect(bidRequests.data.ius).to.equal(0); }); - it('should set ius as 1 if Sonobi can drop iframe pixels', function() { + it('should set ius as 1 if Sonobi can drop iframe pixels', function () { userSync.canBidderRegisterSync.returns(true); const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.ius).to.equal(1); @@ -531,50 +556,28 @@ describe('SonobiBidAdapter', function () { ]); }); - it('should return a properly formatted request with userid as a JSON-encoded set of User ID results', function () { - bidRequest[0].userId = {'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101', 'id5id': {'uid': 'ID5-ZHMOrVeUVTUKgrZ-a2YGxeh5eS_pLzHCQGYOEAiTBQ', 'ext': {'linkType': 2}}}; - bidRequest[1].userId = {'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101', 'id5id': {'uid': 'ID5-ZHMOrVeUVTUKgrZ-a2YGxeh5eS_pLzHCQGYOEAiTBQ', 'ext': {'linkType': 2}}}; + it('should return a properly formatted request with the userid value omitted when the userId object is present on the bidRequest. ', function () { + bidRequest[0].userId = { 'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101', 'id5id': { 'uid': 'ID5-ZHMOrVeUVTUKgrZ-a2YGxeh5eS_pLzHCQGYOEAiTBQ', 'ext': { 'linkType': 2 } } }; + bidRequest[1].userId = { 'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101', 'id5id': { 'uid': 'ID5-ZHMOrVeUVTUKgrZ-a2YGxeh5eS_pLzHCQGYOEAiTBQ', 'ext': { 'linkType': 2 } } }; const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); expect(bidRequests.method).to.equal('GET'); expect(bidRequests.data.ref).not.to.be.empty; expect(bidRequests.data.s).not.to.be.empty; - expect(JSON.parse(bidRequests.data.userid)).to.eql({'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101', 'id5id': 'ID5-ZHMOrVeUVTUKgrZ-a2YGxeh5eS_pLzHCQGYOEAiTBQ'}); + expect(bidRequests.data.userid).to.be.undefined; }); - it('should return a properly formatted request with userid omitted if there are no userIds', function () { - bidRequest[0].userId = {}; - bidRequest[1].userId = {}; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); - expect(bidRequests.method).to.equal('GET'); - expect(bidRequests.data.ref).not.to.be.empty; - expect(bidRequests.data.s).not.to.be.empty; - expect(bidRequests.data.userid).to.equal(undefined); - }); - - it('should return a properly formatted request with userid omitted', function () { - bidRequest[0].userId = undefined; - bidRequest[1].userId = undefined; - const bidRequests = spec.buildRequests(bidRequest, bidderRequests); - expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json'); - expect(bidRequests.method).to.equal('GET'); - expect(bidRequests.data.ref).not.to.be.empty; - expect(bidRequests.data.s).not.to.be.empty; - expect(bidRequests.data.userid).to.equal(undefined); - }); - - it('should return a properly formatted request with keywrods included as a csv of strings', function() { + it('should return a properly formatted request with keywrods included as a csv of strings', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.kw).to.equal('sports,news,some_other_keyword'); }); - it('should return a properly formatted request with us_privacy included', function() { + it('should return a properly formatted request with us_privacy included', function () { const bidRequests = spec.buildRequests(bidRequest, bidderRequests); expect(bidRequests.data.us_privacy).to.equal('someCCPAString'); }); - it('should make a request to the url defined in the bidder param', function() { + it('should make a request to the url defined in the bidder param', function () { const bRequest = [ { ...bidRequest[0], @@ -635,12 +638,12 @@ describe('SonobiBidAdapter', function () { bidder: 'sonobi', mediaTypes: { video: { - context: 'outstream' + context: 'outstream', + playerSize: [640, 480] } }, params: { - placement_id: '92e95368e86639dbd86d', - sizes: [[640, 480]] + placement_id: '92e95368e86639dbd86d' } } ] @@ -658,7 +661,7 @@ describe('SonobiBidAdapter', function () { 'sbi_adomain': 'sonobi.com' }, '30b31c1838de1e': { - 'sbi_size': '300x250', + 'sbi_size': '640x480', 'sbi_apoc': 'remnant', 'sbi_aid': '30292e432662bd5f86d90774b944b038', 'sbi_mouse': 1.25, @@ -668,7 +671,7 @@ describe('SonobiBidAdapter', function () { }, '/7780971/sparks_prebid_LB_OUTSTREAM|30b31c1838de1g': { - 'sbi_size': '300x600', + 'sbi_size': '640x480', 'sbi_apoc': 'remnant', 'sbi_crid': '1234abcd', 'sbi_aid': '30292e432662bd5f86d90774b944b038', @@ -720,8 +723,8 @@ describe('SonobiBidAdapter', function () { { 'requestId': '30b31c1838de1e', 'cpm': 1.25, - 'width': 300, - 'height': 250, + 'width': 640, + 'height': 480, 'vastUrl': 'https://mco-1-apex.go.sonobi.com/vast.xml?vid=30292e432662bd5f86d90774b944b038&ref=https%3A%2F%2Flocalhost%2F', 'ttl': 500, 'creativeId': '30292e432662bd5f86d90774b944b038', @@ -737,8 +740,8 @@ describe('SonobiBidAdapter', function () { { 'requestId': '30b31c1838de1g', 'cpm': 1.07, - 'width': 300, - 'height': 600, + 'width': 640, + 'height': 480, 'ad': ``, 'ttl': 500, 'creativeId': '1234abcd', @@ -762,7 +765,7 @@ describe('SonobiBidAdapter', function () { 'dealId': 'dozerkey', 'aid': 'force_1550072228_da1c5d030cb49150c5db8a2136175755', 'mediaType': 'video', - renderer: () => {}, + renderer: () => { }, meta: { advertiserDomains: ['sonobi.com'] } @@ -835,13 +838,13 @@ describe('SonobiBidAdapter', function () { }) describe('_getPlatform', function () { it('should return mobile', function () { - expect(_getPlatform({innerWidth: 767})).to.equal('mobile') + expect(_getPlatform({ innerWidth: 767 })).to.equal('mobile') }) it('should return tablet', function () { - expect(_getPlatform({innerWidth: 800})).to.equal('tablet') + expect(_getPlatform({ innerWidth: 800 })).to.equal('tablet') }) it('should return desktop', function () { - expect(_getPlatform({innerWidth: 1000})).to.equal('desktop') + expect(_getPlatform({ innerWidth: 1000 })).to.equal('desktop') }) }) }) diff --git a/test/spec/modules/sortableAnalyticsAdapter_spec.js b/test/spec/modules/sortableAnalyticsAdapter_spec.js deleted file mode 100644 index 9300756eae2..00000000000 --- a/test/spec/modules/sortableAnalyticsAdapter_spec.js +++ /dev/null @@ -1,306 +0,0 @@ -import {expect} from 'chai'; -import sortableAnalyticsAdapter, {TIMEOUT_FOR_REGISTRY, DEFAULT_PBID_TIMEOUT} from 'modules/sortableAnalyticsAdapter.js'; -import * as events from 'src/events.js'; -import CONSTANTS from 'src/constants.json'; -import * as prebidGlobal from 'src/prebidGlobal.js'; -import {server} from 'test/mocks/xhr.js'; - -describe('Sortable Analytics Adapter', function() { - let sandbox; - let clock; - - const initialConfig = { - provider: 'sortable', - options: { - siteId: 'testkey' - } - }; - - const TEST_DATA = { - AUCTION_INIT: { - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - timeout: 3000 - }, - BID_REQUESTED: { - refererInfo: { - referer: 'test.com', - reachedTop: true, - numIframes: 1 - }, - bidderCode: 'sortable', - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - bids: [{ - bidder: 'sortable', - params: { - tagId: 'medrec_1' - }, - adUnitCode: '300x250', - transactionId: 'aa02b498-8a99-418e-bc59-6b6fd45f32de', - sizes: [ - [300, 250] - ], - bidId: '26721042674416', - bidderRequestId: '10141593b1d84a', - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - bidRequestsCount: 1 - }, { - bidder: 'sortable', - params: { - tagId: 'lead_1' - }, - adUnitCode: '728x90', - transactionId: 'b7e9e957-af4f-4c47-8ca7-41f01cb4f105', - sizes: [ - [728, 90] - ], - bidId: '50fa575b41e596', - bidderRequestId: '37a8760be6db23', - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - bidRequestsCount: 1 - }], - start: 1553529405788 - }, - BID_ADJUSTMENT_1: { - bidderCode: 'sortable', - adId: '88221d316425f7', - mediaType: 'banner', - cpm: 0.70, - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60, - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - responseTimestamp: 1553534161763, - bidder: 'sortable', - adUnitCode: '300x250', - timeToRespond: 331, - width: '300', - height: '250' - }, - AUCTION_END: { - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e' - }, - BID_ADJUSTMENT_2: { - bidderCode: 'sortable', - adId: '88221d316425f8', - mediaType: 'banner', - cpm: 0.50, - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60, - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - responseTimestamp: 1553534161770, - bidder: 'sortable', - adUnitCode: '728x90', - timeToRespond: 338, - width: '728', - height: '90' - }, - BID_WON_1: { - bidderCode: 'sortable', - adId: '88221d316425f7', - mediaType: 'banner', - cpm: 0.70, - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60, - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - responseTimestamp: 1553534161763, - bidder: 'sortable', - adUnitCode: '300x250', - timeToRespond: 331 - }, - BID_WON_2: { - bidderCode: 'sortable', - adId: '88221d316425f8', - mediaType: 'banner', - cpm: 0.50, - dealId: null, - currency: 'USD', - netRevenue: true, - ttl: 60, - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - responseTimestamp: 1553534161770, - bidder: 'sortable', - adUnitCode: '728x90', - timeToRespond: 338 - }, - BID_TIMEOUT: [{ - auctionId: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - adUnitCode: '300x250', - bidder: 'sortable' - }] - }; - - beforeEach(function() { - sandbox = sinon.sandbox.create(); - clock = sandbox.useFakeTimers(); - sandbox.stub(events, 'getEvents').returns([]); - sandbox.stub(prebidGlobal, 'getGlobal').returns({ - version: '1.0', - bidderSettings: { - 'sortable': { - bidCpmAdjustment: function (number) { - return number * 0.95; - } - } - } - }); - sortableAnalyticsAdapter.enableAnalytics(initialConfig); - }); - - afterEach(function() { - sandbox.restore(); - clock.restore(); - sortableAnalyticsAdapter.disableAnalytics(); - }); - - describe('initialize adapter', function() { - const settings = sortableAnalyticsAdapter.getOptions(); - - it('should init settings correctly and apply defaults', function() { - expect(settings).to.include({ - 'disableSessionTracking': false, - 'key': initialConfig.options.siteId, - 'protocol': 'https', - 'url': `https://pa.deployads.com/pae/${initialConfig.options.siteId}`, - 'timeoutForPbid': DEFAULT_PBID_TIMEOUT - }); - }); - it('should assign a pageview ID', function() { - expect(settings).to.have.own.property('pageviewId'); - }); - }); - - describe('events tracking', function() { - beforeEach(function() { - server.requests = []; - }); - it('should send the PBID event', function() { - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); - events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, TEST_DATA.BID_ADJUSTMENT_1); - events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, TEST_DATA.BID_ADJUSTMENT_2); - events.emit(CONSTANTS.EVENTS.AUCTION_END, TEST_DATA.AUCTION_END); - events.emit(CONSTANTS.EVENTS.BID_WON, TEST_DATA.BID_WON_1); - events.emit(CONSTANTS.EVENTS.BID_WON, TEST_DATA.BID_WON_2); - - clock.tick(DEFAULT_PBID_TIMEOUT); - - expect(server.requests.length).to.equal(1); - let result = JSON.parse(server.requests[0].requestBody); - expect(result).to.have.own.property('pbid'); - expect(result.pbid).to.deep.include({ - ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - ac: ['300x250', '728x90'], - adi: ['88221d316425f7', '88221d316425f8'], - bs: 'sortable', - bid: ['26721042674416', '50fa575b41e596'], - bif: 0.95, - brc: 1, - brid: ['10141593b1d84a', '37a8760be6db23'], - rs: ['300x250', '728x90'], - btcp: [0.70, 0.50].map(n => n * 0.95), - btcc: 'USD', - btin: true, - btsrc: 'sortable', - c: [0.70, 0.50].map(n => n * 0.95), - cc: 'USD', - did: null, - inr: true, - it: true, - iw: true, - ito: false, - mt: 'banner', - rtp: true, - nif: 1, - pbv: '1.0', - siz: ['300x250', '728x90'], - st: 1553529405788, - tgid: ['medrec_1', 'lead_1'], - to: 3000, - trid: ['aa02b498-8a99-418e-bc59-6b6fd45f32de', 'b7e9e957-af4f-4c47-8ca7-41f01cb4f105'], - ttl: 60, - ttr: [331, 338], - u: 'test.com', - _count: 2 - }); - }); - - it('should track a late bidWon event', function() { - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); - events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, TEST_DATA.BID_ADJUSTMENT_1); - events.emit(CONSTANTS.EVENTS.AUCTION_END, TEST_DATA.AUCTION_END); - - clock.tick(DEFAULT_PBID_TIMEOUT); - - events.emit(CONSTANTS.EVENTS.BID_WON, TEST_DATA.BID_WON_1); - - clock.tick(TIMEOUT_FOR_REGISTRY); - - expect(server.requests.length).to.equal(2); - const pbid_req = JSON.parse(server.requests[0].requestBody); - expect(pbid_req).to.have.own.property('pbid'); - const pbwon_req = JSON.parse(server.requests[1].requestBody); - expect(pbwon_req).to.have.own.property('pbrw'); - expect(pbwon_req.pbrw).to.deep.equal({ - ac: '300x250', - ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - bif: 0.95, - bs: 'sortable', - s: initialConfig.options.siteId, - cc: 'USD', - c: 0.70, - inr: true, - _count: 1, - _type: 'pbrw' - }); - }); - - it('should track late bidder timeouts', function() { - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, TEST_DATA.BID_REQUESTED); - events.emit(CONSTANTS.EVENTS.AUCTION_END, TEST_DATA.AUCTION_END); - clock.tick(DEFAULT_PBID_TIMEOUT); - events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, TEST_DATA.BID_TIMEOUT); - - clock.tick(TIMEOUT_FOR_REGISTRY); - - expect(server.requests.length).to.equal(2); - const pbid_req = JSON.parse(server.requests[0].requestBody); - expect(pbid_req).to.have.own.property('pbid'); - const pbto_req = JSON.parse(server.requests[1].requestBody); - expect(pbto_req).to.have.own.property('pbto'); - expect(pbto_req.pbto).to.deep.equal({ - ai: 'fb8d579a-5c3f-4705-ab94-3cff39005d9e', - s: initialConfig.options.siteId, - ac: '300x250', - bs: 'sortable', - _type: 'pbto', - _count: 1 - }); - }); - - it('should track errors', function() { - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, TEST_DATA.AUCTION_INIT); - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, {}); - - clock.tick(TIMEOUT_FOR_REGISTRY); - - expect(server.requests.length).to.equal(1); - const err_req = JSON.parse(server.requests[0].requestBody); - expect(err_req).to.have.own.property('pber'); - expect(err_req.pber).to.include({ - args: '{}', - s: initialConfig.options.siteId, - _count: 1, - ti: 'bidRequested', - _type: 'pber' - }); - expect(err_req.pber.msg).to.be.a('string'); - }); - }); -}); diff --git a/test/spec/modules/sortableBidAdapter_spec.js b/test/spec/modules/sortableBidAdapter_spec.js deleted file mode 100644 index 7357fa77952..00000000000 --- a/test/spec/modules/sortableBidAdapter_spec.js +++ /dev/null @@ -1,547 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/sortableBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import * as utils from 'src/utils.js'; - -describe('sortableBidAdapter', function() { - const adapter = newBidder(spec); - - describe('isBidRequestValid', function () { - function makeBid() { - return { - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - } - }, - 'adUnitCode': 'adunit-code', - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - } - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(makeBid())).to.equal(true); - }); - - it('should return false when tagId not passed correctly', function () { - let bid = makeBid(); - delete bid.params.tagId; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes not passed correctly', function () { - let bid = makeBid(); - delete bid.sizes; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes are wrong length', function () { - let bid = makeBid(); - bid.sizes = [[300]]; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when sizes are empty', function () { - let bid = makeBid(); - bid.sizes = []; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when require params are not passed', function () { - let bid = makeBid(); - bid.params = {}; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return false when the keywords are invalid', function () { - let bid = makeBid(); - bid.params.keywords = { - 'badval': 1234 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - bid.params.keywords = 'a'; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - - it('should return true when the keywords are missing or empty', function () { - let bid = makeBid(); - bid.params.keywords = {}; - expect(spec.isBidRequestValid(bid)).to.equal(true); - delete bid.params.keywords; - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return true with video media type', () => { - const videoBid = { - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - }, - 'adUnitCode': 'adunit-code', - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - 'video': { - } - } - }; - expect(spec.isBidRequestValid(videoBid)).to.equal(true); - }); - }); - - describe('buildRequests', function () { - const bidRequests = [{ - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'floor': 0.21, - 'keywords': { - 'key1': 'val1', - 'key2': 'val2' - } - }, - 'ortb2Imp': { - 'ext': { - 'data': { - 'pbadslot': 'abc/123' - } - } - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }, { - 'bidder': 'sortable', - 'params': { - 'tagId': '403371', - 'siteId': 'example.com', - 'floor': 0.21 - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - 'native': { - 'body': {'required': true, 'sendId': true}, - 'clickUrl': {'required': true, 'sendId': true}, - 'cta': {'required': true, 'sendId': true}, - 'icon': {'required': true, 'sendId': true}, - 'image': {'required': true, 'sendId': true}, - 'sponsoredBy': {'required': true, 'sendId': true}, - 'title': {'required': true, 'sendId': true, 'len': 100} - } - } - }]; - - const request = spec.buildRequests(bidRequests, {refererInfo: { referer: 'http://example.com/page?param=val' }}); - const requestBody = JSON.parse(request.data); - - it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); - - it('attaches source and version to endpoint URL as query params', function () { - const ENDPOINT = `https://c.deployads.com/openrtb2/auction?src=$$REPO_AND_VERSION$$&host=example.com`; - expect(request.url).to.equal(ENDPOINT); - }); - - it('sends screen dimensions', function () { - expect(requestBody.site.device.w).to.equal(screen.width); - expect(requestBody.site.device.h).to.equal(screen.height); - }); - - it('includes the ad size in the bid request', function () { - expect(requestBody.imp[0].banner.format[0].w).to.equal(300); - expect(requestBody.imp[0].banner.format[0].h).to.equal(250); - }); - - it('includes the params in the bid request', function () { - expect(requestBody.imp[0].ext.keywords).to.deep.equal( - {'key1': 'val1', - 'key2': 'val2'} - ); - expect(requestBody.site.publisher.id).to.equal('example.com'); - expect(requestBody.imp[0].tagid).to.equal('403370'); - expect(requestBody.imp[0].floor).to.equal(0.21); - }); - - it('includes pbadslot in the bid request', function () { - expect(requestBody.imp[0].ext.gpid).to.equal('abc/123'); - }); - - it('sets domain and href correctly', function () { - expect(requestBody.site.domain).to.equal('example.com'); - expect(requestBody.site.page).to.equal('http://example.com/page?param=val'); - }); - - it('should have the version in native object set for native bid', function() { - expect(requestBody.imp[1].native.ver).to.equal('1'); - }); - - it('should have the assets set for native bid', function() { - const assets = JSON.parse(requestBody.imp[1].native.request).assets; - expect(assets[0]).to.deep.equal({'title': {'len': 100}, 'required': 1, 'id': 0}); - expect(assets[1]).to.deep.equal({'img': {'type': 3, 'wmin': 1, 'hmin': 1}, 'required': 1, 'id': 1}); - expect(assets[2]).to.deep.equal({'img': {'type': 1, 'wmin': 1, 'hmin': 1}, 'required': 1, 'id': 2}); - expect(assets[3]).to.deep.equal({'data': {'type': 2}, 'required': 1, 'id': 3}); - expect(assets[4]).to.deep.equal({'data': {'type': 12}, 'required': 1, 'id': 4}); - expect(assets[5]).to.deep.equal({'data': {'type': 1}, 'required': 1, 'id': 5}); - }); - - const videoBidRequests = [{ - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'video': { - 'minduration': 5, - 'maxduration': 10, - 'startdelay': 0 - } - }, - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - 'mediaTypes': { - 'video': { - 'context': 'instream', - 'mimes': ['video/x-ms-wmv'], - 'playerSize': [[400, 300]], - 'api': [0], - 'protocols': [2, 3], - 'playbackmethod': [1] - } - } - }]; - - const videoRequest = spec.buildRequests(videoBidRequests, {refererInfo: { referer: 'http://localhost:9876/' }}); - const videoRequestBody = JSON.parse(videoRequest.data); - - it('should include video params', () => { - const video = videoRequestBody.imp[0].video; - expect(video.mimes).to.deep.equal(['video/x-ms-wmv']); - expect(video.w).to.equal(400); - expect(video.h).to.equal(300); - expect(video.api).to.deep.equal([0]); - expect(video.protocols).to.deep.equal([2, 3]); - expect(video.playbackmethod).to.deep.equal([1]); - expect(video.minduration).to.equal(5); - expect(video.maxduration).to.equal(10); - expect(video.startdelay).to.equal(0); - }); - - it('sets domain and href correctly', function () { - expect(videoRequestBody.site.domain).to.equal('localhost'); - expect(videoRequestBody.site.page).to.equal('http://localhost:9876/'); - }); - - const gdprBidRequests = [{ - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'floor': 0.21, - 'keywords': {} - }, - 'sizes': [ - [300, 250] - ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - const consentString = 'BOJ/P2HOJ/P2HABABMAAAAAZ+A=='; - - function getGdprRequestBody(gdprApplies, consentString) { - const gdprRequest = spec.buildRequests(gdprBidRequests, {'gdprConsent': { - 'gdprApplies': gdprApplies, - 'consentString': consentString - }, - refererInfo: { - referer: 'http://localhost:9876/' - }}); - return JSON.parse(gdprRequest.data); - } - - it('should handle gdprApplies being present and true', function() { - const gdprRequestBody = getGdprRequestBody(true, consentString); - expect(gdprRequestBody.regs.ext.gdpr).to.equal(1); - expect(gdprRequestBody.user.ext.consent).to.equal(consentString); - }) - - it('should handle gdprApplies being present and false', function() { - const gdprRequestBody = getGdprRequestBody(false, consentString); - expect(gdprRequestBody.regs.ext.gdpr).to.equal(0); - expect(gdprRequestBody.user.ext.consent).to.equal(consentString); - }) - - it('should handle gdprApplies being undefined', function() { - const gdprRequestBody = getGdprRequestBody(undefined, consentString); - expect(gdprRequestBody.regs).to.deep.equal({ext: {}}); - expect(gdprRequestBody.user.ext.consent).to.equal(consentString); - }) - - it('should handle gdprConsent being undefined', function() { - const gdprRequest = spec.buildRequests(gdprBidRequests, {refererInfo: { referer: 'http://localhost:9876/' }}); - const gdprRequestBody = JSON.parse(gdprRequest.data); - expect(gdprRequestBody.regs).to.deep.equal({ext: {}}); - expect(gdprRequestBody.user.ext.consent).to.equal(undefined); - }) - - const eidsBidRequests = [{ - 'bidder': 'sortable', - 'params': { - 'tagId': '403370', - 'siteId': 'example.com', - 'floor': 0.21, - 'keywords': {} - }, - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475' - }]; - - it('should not set user ids when none present', function() { - const eidsRequest = spec.buildRequests(eidsBidRequests, {refererInfo: { - referer: 'http://localhost:9876/' - }}); - const eidsRequestBody = JSON.parse(eidsRequest.data); - - expect(eidsRequestBody.user.ext.eids).to.equal(undefined); - }) - - it('should set user ids when present', function() { - eidsBidRequests[0].userId = { criteoId: 'sample-userid' }; - const eidsRequest = spec.buildRequests(eidsBidRequests, {refererInfo: { - referer: 'http://localhost:9876/' - }}); - const eidsRequestBody = JSON.parse(eidsRequest.data); - - expect(eidsRequestBody.user.ext.eids.length).to.equal(1); - }) - }); - - describe('interpretResponse', function () { - function makeResponse() { - return { - body: { - 'id': '5e5c23a5ba71e78', - 'seatbid': [ - { - 'bid': [ - { - 'id': '6vmb3isptf', - 'crid': 'sortablescreative', - 'impid': '322add653672f68', - 'price': 1.22, - 'adm': '', - 'attr': [5], - 'h': 90, - 'nurl': 'http://nurl', - 'w': 728 - } - ], - 'seat': 'MOCK' - } - ], - 'bidid': '5e5c23a5ba71e78' - } - }; - } - - function makeNativeResponse() { - return { - body: { - 'id': '5e5c23a5ba71e77', - 'seatbid': [ - { - 'bid': [ - { - 'id': '6vmb3isptf', - 'crid': 'sortablescreative', - 'impid': '322add653672f67', - 'price': 1.55, - 'adm': '{"native":{"link":{"clicktrackers":[],"url":"https://www.sortable.com/"},"assets":[{"title":{"text":"Ads With Sortable"},"id":1},{"img":{"w":790,"url":"https://path.to/image","h":294},"id":2},{"img":{"url":"https://path.to/icon"},"id":3},{"data":{"value":"Body here"},"id":4},{"data":{"value":"Learn More"},"id":5},{"data":{"value":"Sortable"},"id":6}],"imptrackers":[],"ver":1}}', - 'ext': {'ad_format': 'native'}, - 'h': 90, - 'nurl': 'http://nurl', - 'w': 728 - } - ], - 'seat': 'MOCK' - } - ], - 'bidid': '5e5c23a5ba71e77' - } - }; - } - - const expectedBid = { - 'requestId': '322add653672f68', - 'cpm': 1.22, - 'width': 728, - 'height': 90, - 'creativeId': 'sortablescreative', - 'dealId': null, - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'banner', - 'meta': { 'advertiserDomains': [] }, - 'ttl': 60, - 'ad': '
' - }; - - const expectedNativeBid = { - 'requestId': '322add653672f67', - 'cpm': 1.55, - 'width': 728, - 'height': 90, - 'creativeId': 'sortablescreative', - 'dealId': null, - 'currency': 'USD', - 'netRevenue': true, - 'sortable': { 'ad_format': 'native' }, - 'mediaType': 'native', - 'meta': { 'advertiserDomains': [] }, - 'ttl': 60, - 'native': { - 'clickUrl': 'https://www.sortable.com/', - 'title': 'Ads With Sortable', - 'image': {'url': 'https://path.to/image', 'height': 294, 'width': 790}, - 'icon': 'https://path.to/icon', - 'body': 'Body here', - 'cta': 'Learn More', - 'sponsoredBy': 'Sortable' - } - }; - - it('should get the correct bid response', function () { - let result = spec.interpretResponse(makeResponse()); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(expectedBid); - }); - - it('should handle a missing crid', function () { - let noCridResponse = makeResponse(); - delete noCridResponse.body.seatbid[0].bid[0].crid; - const fallbackCrid = noCridResponse.body.seatbid[0].bid[0].id; - let noCridResult = Object.assign({}, expectedBid, {'creativeId': fallbackCrid}); - let result = spec.interpretResponse(noCridResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noCridResult); - }); - - it('should handle a missing nurl', function () { - let noNurlResponse = makeResponse(); - delete noNurlResponse.body.seatbid[0].bid[0].nurl; - let noNurlResult = Object.assign({}, expectedBid); - noNurlResult.ad = ''; - let result = spec.interpretResponse(noNurlResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noNurlResult); - }); - - it('should handle a missing adm', function () { - let noAdmResponse = makeResponse(); - delete noAdmResponse.body.seatbid[0].bid[0].adm; - let noAdmResult = Object.assign({}, expectedBid); - delete noAdmResult.ad; - noAdmResult.adUrl = 'http://nurl'; - let result = spec.interpretResponse(noAdmResponse); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(noAdmResult); - }); - - it('handles empty bid response', function () { - let response = { - body: { - 'id': '5e5c23a5ba71e78', - 'seatbid': [] - } - }; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - - it('should get the correct native bid response', function () { - let result = spec.interpretResponse(makeNativeResponse()); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(expectedNativeBid); - }); - - it('fail to parse invalid native bid response', function () { - let response = makeNativeResponse(); - response.body.seatbid[0].bid[0].adm = ''; - let result = spec.interpretResponse(response); - expect(result.length).to.equal(0); - }); - - it('should keep custom properties', () => { - const customProperties = {test: 'a test message', param: {testParam: 1}}; - const expectedResult = Object.assign({}, expectedBid, {[spec.code]: customProperties}); - const response = makeResponse(); - response.body.seatbid[0].bid[0].ext = customProperties; - const result = spec.interpretResponse(response); - expect(result.length).to.equal(1); - expect(result[0]).to.deep.equal(expectedResult); - }); - - it('should handle instream response', () => { - const response = makeResponse(); - const bid = response.body.seatbid[0].bid[0]; - delete bid.nurl; - bid.ext = {ad_format: 'instream'}; - const result = spec.interpretResponse(response)[0]; - expect(result.mediaType).to.equal('video'); - expect(result.vastXml).to.equal(bid.adm); - }); - - it('should return iframe syncs', () => { - const syncResponse = { - ext: { - sync_dsps: [ - ['iframe', 'http://example-dsp/sync-iframe'], - ['image', 'http://example-dsp/sync-image'] - ] - } - }; - expect(spec.getUserSyncs({iframeEnabled: true}, [{body: syncResponse}])).to.deep.equal([{ - type: 'iframe', - url: 'http://example-dsp/sync-iframe' - }]); - }); - - it('should return image syncs', () => { - const syncResponse = { - ext: { - sync_dsps: [ - ['iframe', 'http://example-dsp/sync-iframe'], - ['image', 'http://example-dsp/sync-image'] - ] - } - }; - expect(spec.getUserSyncs({pixelEnabled: true}, [{body: syncResponse}])).to.deep.equal([{ - type: 'image', - url: 'http://example-dsp/sync-image' - }]); - }); - }); -}); diff --git a/test/spec/modules/sovrnAnalyticsAdapter_spec.js b/test/spec/modules/sovrnAnalyticsAdapter_spec.js index d6795331417..68552eb3d8a 100644 --- a/test/spec/modules/sovrnAnalyticsAdapter_spec.js +++ b/test/spec/modules/sovrnAnalyticsAdapter_spec.js @@ -1,8 +1,10 @@ import sovrnAnalyticsAdapter from '../../../modules/sovrnAnalyticsAdapter.js'; -import { expect } from 'chai'; +import {expect} from 'chai'; import {config} from 'src/config.js'; import adaptermanager from 'src/adapterManager.js'; -import { server } from 'test/mocks/xhr.js'; +import {server} from 'test/mocks/xhr.js'; +import {expectEvents, fireEvents} from '../../helpers/analytics.js'; + var assert = require('assert'); let events = require('src/events'); @@ -195,14 +197,7 @@ describe('Sovrn Analytics Adapter', function () { sovrnId: 123 } }); - - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - - sinon.assert.callCount(sovrnAnalyticsAdapter.track, 5); + expectEvents().to.beTrackedBy(sovrnAnalyticsAdapter.track); }); it('should catch no events if no affiliate id', function () { @@ -211,13 +206,7 @@ describe('Sovrn Analytics Adapter', function () { options: { } }); - - events.emit(constants.EVENTS.AUCTION_INIT, {}); - events.emit(constants.EVENTS.AUCTION_END, {}); - events.emit(constants.EVENTS.BID_REQUESTED, {}); - events.emit(constants.EVENTS.BID_RESPONSE, {}); - events.emit(constants.EVENTS.BID_WON, {}); - + fireEvents(); sinon.assert.callCount(sovrnAnalyticsAdapter.track, 0); }); }); diff --git a/test/spec/modules/sovrnBidAdapter_spec.js b/test/spec/modules/sovrnBidAdapter_spec.js index 09a61c82b6c..90913c6f130 100644 --- a/test/spec/modules/sovrnBidAdapter_spec.js +++ b/test/spec/modules/sovrnBidAdapter_spec.js @@ -1,80 +1,92 @@ -import {expect} from 'chai'; -import {spec} from 'modules/sovrnBidAdapter.js'; -import {config} from 'src/config.js'; +import {expect} from 'chai' +import {spec} from 'modules/sovrnBidAdapter.js' +import {config} from 'src/config.js' import * as utils from 'src/utils.js' -const ENDPOINT = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$`; +const ENDPOINT = `https://ap.lijit.com/rtb/bid?src=$$REPO_AND_VERSION$$` const baseBidRequest = { - 'bidder': 'sovrn', - 'params': { - 'tagid': 403370 + bidder: 'sovrn', + params: { + tagid: 403370 }, - 'adUnitCode': 'adunit-code', - 'sizes': [ + adUnitCode: 'adunit-code', + sizes: [ [300, 250], [300, 600] ], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', } const baseBidderRequest = { refererInfo: { - referer: 'http://example.com/page.html', + page: 'http://example.com/page.html', + domain: 'example.com', } -}; +} describe('sovrnBidAdapter', function() { describe('isBidRequestValid', function () { it('should return true when required params found', function () { - expect(spec.isBidRequestValid(baseBidRequest)).to.equal(true); - }); + expect(spec.isBidRequestValid(baseBidRequest)).to.equal(true) + }) it('should return false when tagid not passed correctly', function () { const bidRequest = { ...baseBidRequest, - 'params': { + params: { ...baseBidRequest.params, - 'tagid': 'ABCD' + tagid: 'ABCD' }, - }; + } - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); + expect(spec.isBidRequestValid(bidRequest)).to.equal(false) + }) it('should return false when require params are not passed', function () { const bidRequest = { ...baseBidRequest, - 'params': {} + params: {} } - expect(spec.isBidRequestValid(bidRequest)).to.equal(false); - }); - }); + expect(spec.isBidRequestValid(bidRequest)).to.equal(false) + }) + + it('should return false when require video params are not passed', function () { + const bidRequest = { + ...baseBidRequest, + mediaTypes: { + 'video': { + } + } + } + + expect(spec.isBidRequestValid(bidRequest)).to.equal(false) + }) + }) describe('buildRequests', function () { describe('basic bid parameters', function() { - const request = spec.buildRequests([baseBidRequest], baseBidderRequest); - const payload = JSON.parse(request.data); + const request = spec.buildRequests([baseBidRequest], baseBidderRequest) + const payload = JSON.parse(request.data) it('sends bid request to our endpoint via POST', function () { - expect(request.method).to.equal('POST'); - }); + expect(request.method).to.equal('POST') + }) it('attaches source and version to endpoint URL as query params', function () { expect(request.url).to.equal(ENDPOINT) - }); + }) it('sets the proper banner object', function() { const bannerBidRequest = { ...baseBidRequest, - 'mediaTypes': { + mediaTypes: { banner: {} } } const request = spec.buildRequests([bannerBidRequest], baseBidderRequest) - const payload = JSON.parse(request.data) const impression = payload.imp[0] @@ -83,9 +95,9 @@ describe('sovrnBidAdapter', function() { expect(impression.banner.h).to.equal(1) }) - it('sets the proper video object', function() { - const width = 640 - const height = 480 + it('sets the proper video object with sizes defined', function() { + const width = 300 + const height = 250 const mimes = ['video/mp4', 'application/javascript'] const protocols = [2, 5] const minduration = 5 @@ -93,7 +105,7 @@ describe('sovrnBidAdapter', function() { const startdelay = 0 const videoBidRequest = { ...baseBidRequest, - 'mediaTypes': { + mediaTypes: { video: { mimes, protocols, @@ -105,7 +117,42 @@ describe('sovrnBidAdapter', function() { } } const request = spec.buildRequests([videoBidRequest], baseBidderRequest) + const payload = JSON.parse(request.data) + const impression = payload.imp[0] + expect(impression.video.w).to.equal(width) + expect(impression.video.h).to.equal(height) + expect(impression.video.mimes).to.have.same.members(mimes) + expect(impression.video.protocols).to.have.same.members(protocols) + expect(impression.video.minduration).to.equal(minduration) + expect(impression.video.maxduration).to.equal(maxduration) + expect(impression.video.startdelay).to.equal(startdelay) + }) + + it('sets the proper video object wihtout sizes defined but video sizes defined', function() { + const width = 360 + const height = 240 + const mimes = ['video/mp4', 'application/javascript'] + const protocols = [2, 5] + const minduration = 5 + const maxduration = 60 + const startdelay = 0 + const modifiedBidRequest = baseBidRequest; + delete modifiedBidRequest.sizes; + const videoBidRequest = { + ...modifiedBidRequest, + mediaTypes: { + video: { + mimes, + protocols, + playerSize: [[width, height], [360, 240]], + minduration, + maxduration, + startdelay + } + } + } + const request = spec.buildRequests([videoBidRequest], baseBidderRequest) const payload = JSON.parse(request.data) const impression = payload.imp[0] @@ -119,9 +166,56 @@ describe('sovrnBidAdapter', function() { }) it('gets correct site info', function() { - expect(payload.site.page).to.equal('http://example.com/page.html'); - expect(payload.site.domain).to.equal('example.com'); - }); + expect(payload.site.page).to.equal('http://example.com/page.html') + expect(payload.site.domain).to.equal('example.com') + }) + + it('sets correct timeout', function() { + const bidderRequest = { + ...baseBidderRequest, + bidderCode: 'sovrn', + auctionId: '1d1a030790a475', + bidderRequestId: '22edbae2733bf6', + timeout: 3000, + bids: [baseBidRequest] + } + const payload = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) + expect(payload.tmax).to.equal(3000) + }) + + it('forwards auction level tid', function() { + const bidderRequest = { + ...baseBidderRequest, + ortb2: { + source: { + tid: '1d1a030790a475' + } + }, + bids: [baseBidRequest] + } + + const payload = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) + expect(payload.source?.tid).to.equal('1d1a030790a475') + }) + + it('forwards impression level tid', function() { + const bidRequest = { + ...baseBidRequest, + ortb2Imp: { + ext: { + tid: '1a2c032473f4983' + } + }, + } + + const bidderRequest = { + ...baseBidderRequest, + bids: [bidRequest] + } + + const payload = JSON.parse(spec.buildRequests([bidRequest], bidderRequest).data) + expect(payload.imp[0]?.ext?.tid).to.equal('1a2c032473f4983') + }) it('includes the ad unit code in the request', function() { const impression = payload.imp[0] @@ -130,22 +224,21 @@ describe('sovrnBidAdapter', function() { it('converts tagid to string', function () { expect(request.data).to.contain('"tagid":"403370"') - }); + }) }) it('accepts a single array as a size', function() { const singleSizeBidRequest = { ...baseBidRequest, - 'params': { - 'iv': 'vet' + params: { + iv: 'vet' }, - 'sizes': [300, 250], - 'mediaTypes': { + sizes: [300, 250], + mediaTypes: { banner: {} }, } const request = spec.buildRequests([singleSizeBidRequest], baseBidderRequest) - const payload = JSON.parse(request.data) const impression = payload.imp[0] @@ -164,22 +257,21 @@ describe('sovrnBidAdapter', function() { const request = spec.buildRequests([ivBidRequest], baseBidderRequest) expect(request.url).to.contain('iv=vet') - }); + }) it('sends gdpr info if exists', function () { const bidderRequest = { ...baseBidderRequest, - 'bidderCode': 'sovrn', - 'auctionId': '1d1a030790a475', - 'bidderRequestId': '22edbae2733bf6', - 'timeout': 3000, - 'gdprConsent': { - 'consentString': 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', - 'gdprApplies': true + bidderCode: 'sovrn', + auctionId: '1d1a030790a475', + bidderRequestId: '22edbae2733bf6', + timeout: 3000, + gdprConsent: { + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', + gdprApplies: true }, - 'bids': [baseBidRequest] - }; - + bids: [baseBidRequest] + } const { regs, user } = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) expect(regs.ext.gdpr).to.exist.and.to.be.a('number') @@ -191,52 +283,133 @@ describe('sovrnBidAdapter', function() { it('should send us_privacy if bidderRequest has a value for uspConsent', function () { const bidderRequest = { ...baseBidderRequest, - 'bidderCode': 'sovrn', - 'auctionId': '1d1a030790a475', - 'bidderRequestId': '22edbae2733bf6', - 'timeout': 3000, - 'uspConsent': '1NYN', - 'bids': [baseBidRequest] + bidderCode: 'sovrn', + auctionId: '1d1a030790a475', + bidderRequestId: '22edbae2733bf6', + timeout: 3000, + uspConsent: '1NYN', + bids: [baseBidRequest] } - const data = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) expect(data.regs.ext['us_privacy']).to.equal(bidderRequest.uspConsent) }) + it('should send gpp info in OpenRTB 2.6 location when gppConsent defined', function () { + const bidderRequest = { + ...baseBidderRequest, + bidderCode: 'sovrn', + auctionId: '1d1a030790a475', + bidderRequestId: '22edbae2733bf6', + timeout: 3000, + gppConsent: { + gppString: 'gppstring', + applicableSections: [8] + }, + bids: [baseBidRequest] + } + const { regs } = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) + expect(regs.gpp).to.equal('gppstring') + expect(regs.gpp_sid).to.be.an('array') + expect(regs.gpp_sid).to.include(8) + }) + + it('should not send gpp info when gppConsent is not defined', function () { + const bidderRequest = { + ...baseBidderRequest, + bidderCode: 'sovrn', + auctionId: '1d1a030790a475', + bidderRequestId: '22edbae2733bf6', + timeout: 3000, + bids: [baseBidRequest], + gdprConsent: { + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', + gdprApplies: true + }, + } + const { regs } = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) + expect(regs.gpp).to.be.undefined + }) + + it('should send gdpr info even when gppConsent defined', function () { + const bidderRequest = { + ...baseBidderRequest, + bidderCode: 'sovrn', + auctionId: '1d1a030790a475', + bidderRequestId: '22edbae2733bf6', + timeout: 3000, + gdprConsent: { + consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==', + gdprApplies: true + }, + gppConsent: { + gppString: 'gppstring', + applicableSections: [8] + }, + bids: [baseBidRequest] + } + + const { regs, user } = JSON.parse(spec.buildRequests([baseBidRequest], bidderRequest).data) + + expect(regs.ext.gdpr).to.exist.and.to.be.a('number') + expect(regs.ext.gdpr).to.equal(1) + expect(user.ext.consent).to.exist.and.to.be.a('string') + expect(user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString) + expect(regs.gpp).to.equal('gppstring') + expect(regs.gpp_sid).to.be.an('array') + expect(regs.gpp_sid).to.include(8) + }) + it('should add schain if present', function() { const schainRequest = { ...baseBidRequest, - 'schain': { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ + schain: { + ver: '1.0', + complete: 1, + nodes: [ { - 'asi': 'directseller.com', - 'sid': '00001', - 'rid': 'BidRequest1', - 'hp': 1 + asi: 'directseller.com', + sid: '00001', + rid: 'BidRequest1', + hp: 1 } ] } } const schainRequests = [schainRequest, baseBidRequest] - const data = JSON.parse(spec.buildRequests(schainRequests, baseBidderRequest).data) expect(data.source.ext.schain.nodes.length).to.equal(1) }) - it('should add eds to the bid request', function() { + it('should add eids to the bid request', function() { const criteoIdRequest = { ...baseBidRequest, - userId: { - criteoId: 'A_CRITEO_ID', - tdid: 'SOMESORTOFID', - } - } + userIdAsEids: [ + { + source: 'criteo.com', + uids: [ + { + atype: 1, + id: 'A_CRITEO_ID' + } + ] + }, + { + source: 'adserver.org', + uids: [ + { + atype: 1, + ext: { + rtiPartner: 'TDID' + }, + id: 'SOMESORTOFID' + } + ] + } + ] + }; const criteoIdRequests = [criteoIdRequest, baseBidRequest] - const ext = JSON.parse(spec.buildRequests(criteoIdRequests, baseBidderRequest).data).user.ext const firstEID = ext.eids[0] const secondEID = ext.eids[1] @@ -248,8 +421,6 @@ describe('sovrnBidAdapter', function() { expect(secondEID.uids[0].id).to.equal('SOMESORTOFID') expect(secondEID.uids[0].ext.rtiPartner).to.equal('TDID') expect(secondEID.uids[0].atype).to.equal(1) - expect(ext.tpid[0].source).to.equal('criteo.com') - expect(ext.tpid[0].uid).to.equal('A_CRITEO_ID') expect(ext.prebid_criteoid).to.equal('A_CRITEO_ID') }) @@ -282,7 +453,6 @@ describe('sovrnBidAdapter', function() { bidfloor: 2.00 } } - const request = spec.buildRequests([floorBid], baseBidderRequest) const payload = JSON.parse(request.data) @@ -297,37 +467,23 @@ describe('sovrnBidAdapter', function() { tagid: 1234, bidfloor: 2.00 } - const request = spec.buildRequests([floorBid], baseBidderRequest) const impression = JSON.parse(request.data).imp[0] expect(impression.bidfloor).to.equal(2.00) }) describe('First Party Data', function () { - let sandbox - - beforeEach(function() { - sandbox = sinon.sandbox.create() - }) - afterEach(function() { - sandbox.restore() - }) it('should provide first party data if provided', function() { - sandbox.stub(config, 'getConfig').callsFake(key => { - const cfg = { - ortb2: { - site: { - keywords: 'test keyword' - }, - user: { - data: 'some user data' - } - } + const ortb2 = { + site: { + keywords: 'test keyword' + }, + user: { + data: 'some user data' } - return utils.deepAccess(cfg, key) - }) + }; - const request = spec.buildRequests([baseBidRequest], baseBidderRequest) + const request = spec.buildRequests([baseBidRequest], {...baseBidderRequest, ortb2}) const { user, site } = JSON.parse(request.data) expect(user.data).to.equal('some user data') @@ -347,7 +503,6 @@ describe('sovrnBidAdapter', function() { } } } - const request = spec.buildRequests([fpdBidRequest], baseBidderRequest) const payload = JSON.parse(request.data) @@ -369,7 +524,6 @@ describe('sovrnBidAdapter', function() { } } } - const request = spec.buildRequests([fpdBid], baseBidderRequest) const impression = JSON.parse(request.data).imp[0] @@ -378,90 +532,109 @@ describe('sovrnBidAdapter', function() { expect(impression.ext.deals).to.deep.equal(['seg1', 'seg2']) }) }) - }); + }) describe('interpretResponse', function () { - let response; + let response const baseResponse = { - 'requestId': '263c448586f5a1', - 'cpm': 0.45882675, - 'width': 728, - 'height': 90, - 'creativeId': 'creativelycreatedcreativecreative', - 'dealId': null, - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'banner', - 'ad': decodeURIComponent(``), - 'ttl': 90, - 'meta': { advertiserDomains: [] } + requestId: '263c448586f5a1', + cpm: 0.45882675, + width: 728, + height: 90, + creativeId: 'creativelycreatedcreativecreative', + dealId: null, + currency: 'USD', + netRevenue: true, + mediaType: 'banner', + ttl: 90, + meta: { advertiserDomains: [] }, + ad: decodeURIComponent(``), + } + const videoBid = { + id: 'a_403370_332fdb9b064040ddbec05891bd13ab28', + crid: 'creativelycreatedcreativecreative', + impid: '263c448586f5a1', + price: 0.45882675, + nurl: '', + adm: 'key%3Dvalue', + h: 480, + w: 640 } + const bannerBid = { + id: 'a_403370_332fdb9b064040ddbec05891bd13ab28', + crid: 'creativelycreatedcreativecreative', + impid: '263c448586f5a1', + price: 0.45882675, + nurl: '', + adm: '', + h: 90, + w: 728 + } + beforeEach(function () { response = { body: { - 'id': '37386aade21a71', - 'seatbid': [{ - 'bid': [{ - 'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28', - 'crid': 'creativelycreatedcreativecreative', - 'impid': '263c448586f5a1', - 'price': 0.45882675, - 'nurl': '', - 'adm': '', - 'h': 90, - 'w': 728 + id: '37386aade21a71', + seatbid: [{ + bid: [{ + ...bannerBid }] }] } - }; - }); + } + }) it('should get the correct bid response', function () { const expectedResponse = { - ...baseResponse, - 'ad': decodeURIComponent(`>`), - 'ttl': 60000, - }; - - const result = spec.interpretResponse(response); + requestId: '263c448586f5a1', + cpm: 0.45882675, + width: 728, + height: 90, + creativeId: 'creativelycreatedcreativecreative', + dealId: null, + currency: 'USD', + netRevenue: true, + mediaType: 'banner', + ttl: 60000, + meta: { advertiserDomains: [] }, + ad: decodeURIComponent(`>`) + } + const result = spec.interpretResponse(response) - expect(result[0]).to.have.deep.keys(expectedResponse) - }); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse)) + }) it('crid should default to the bid id if not on the response', function () { - delete response.body.seatbid[0].bid[0].crid; + delete response.body.seatbid[0].bid[0].crid const expectedResponse = { ...baseResponse, - 'creativeId': response.body.seatbid[0].bid[0].id, - 'ad': decodeURIComponent(``), + creativeId: response.body.seatbid[0].bid[0].id, + ad: decodeURIComponent(``), } + const result = spec.interpretResponse(response) - const result = spec.interpretResponse(response); - - expect(result[0]).to.deep.equal(expectedResponse); - }); + expect(result[0]).to.deep.equal(expectedResponse) + }) it('should get correct bid response when dealId is passed', function () { - response.body.seatbid[0].bid[0].dealid = 'baking'; + response.body.seatbid[0].bid[0].dealid = 'baking' const expectedResponse = { ...baseResponse, - 'dealId': 'baking', + dealId: 'baking', } - const result = spec.interpretResponse(response) - expect(result[0]).to.deep.equal(expectedResponse); - }); + expect(result[0]).to.deep.equal(expectedResponse) + }) it('should get correct bid response when ttl is set', function () { - response.body.seatbid[0].bid[0].ext = { 'ttl': 480 } + response.body.seatbid[0].bid[0].ext = { ttl: 480 } const expectedResponse = { ...baseResponse, - 'ttl': 480, + ttl: 480, } - const result = spec.interpretResponse(response) expect(result[0]).to.deep.equal(expectedResponse) @@ -470,99 +643,125 @@ describe('sovrnBidAdapter', function() { it('handles empty bid response', function () { const response = { body: { - 'id': '37386aade21a71', - 'seatbid': [] + id: '37386aade21a71', + seatbid: [] } - }; + } + const result = spec.interpretResponse(response) + + expect(result.length).to.equal(0) + }) + + it('should get the correct bid response with 2 different bids', function () { + const expectedVideoResponse = { + ...baseResponse, + vastXml: decodeURIComponent(videoBid.adm) + } + delete expectedVideoResponse.ad + + const expectedBannerResponse = { + ...baseResponse + } + + response.body.seatbid = [{ bid: [bannerBid] }, { bid: [videoBid] }] + const result = spec.interpretResponse(response) + + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedBannerResponse)) + expect(Object.keys(result[1])).to.deep.equal(Object.keys(expectedVideoResponse)) + }) + + it('should get the correct bid response with 2 seatbid items', function () { + const expectedResponse = { + ...baseResponse + } + response.body.seatbid = [response.body.seatbid[0], response.body.seatbid[0]] const result = spec.interpretResponse(response) - expect(result.length).to.equal(0); - }); - }); + expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse)) + expect(Object.keys(result[1])).to.deep.equal(Object.keys(expectedResponse)) + }) + }) describe('interpretResponse video', function () { - let videoResponse; - const bidAdm = 'key%3Dvalue'; - const decodedBidAdm = decodeURIComponent(bidAdm); + let videoResponse + const bidAdm = 'key%3Dvalue' + const decodedBidAdm = decodeURIComponent(bidAdm) const baseVideoResponse = { - 'requestId': '263c448586f5a1', - 'cpm': 0.45882675, - 'width': 640, - 'height': 480, - 'creativeId': 'creativelycreatedcreativecreative', - 'dealId': null, - 'currency': 'USD', - 'netRevenue': true, - 'mediaType': 'video', - 'ttl': 90, - 'meta': { advertiserDomains: [] }, - 'vastXml': decodedBidAdm + requestId: '263c448586f5a1', + cpm: 0.45882675, + width: 640, + height: 480, + creativeId: 'creativelycreatedcreativecreative', + dealId: null, + currency: 'USD', + netRevenue: true, + mediaType: 'video', + ttl: 90, + meta: { advertiserDomains: [] }, + vastXml: decodedBidAdm } + beforeEach(function () { videoResponse = { body: { - 'id': '37386aade21a71', - 'seatbid': [{ - 'bid': [{ - 'id': 'a_403370_332fdb9b064040ddbec05891bd13ab28', - 'crid': 'creativelycreatedcreativecreative', - 'impid': '263c448586f5a1', - 'price': 0.45882675, - 'nurl': '', - 'adm': bidAdm, - 'h': 480, - 'w': 640 + id: '37386aade21a71', + seatbid: [{ + bid: [{ + id: 'a_403370_332fdb9b064040ddbec05891bd13ab28', + crid: 'creativelycreatedcreativecreative', + impid: '263c448586f5a1', + price: 0.45882675, + nurl: '', + adm: bidAdm, + h: 480, + w: 640 }] }] } - }; - }); + } + }) it('should get the correct bid response', function () { const expectedResponse = { ...baseVideoResponse, - 'ttl': 60000, - }; - - const result = spec.interpretResponse(videoResponse); + ttl: 60000, + } + const result = spec.interpretResponse(videoResponse) expect(result[0]).to.have.deep.keys(expectedResponse) - }); + }) it('crid should default to the bid id if not on the response', function () { - delete videoResponse.body.seatbid[0].bid[0].crid; + delete videoResponse.body.seatbid[0].bid[0].crid const expectedResponse = { ...baseVideoResponse, - 'creativeId': videoResponse.body.seatbid[0].bid[0].id, + creativeId: videoResponse.body.seatbid[0].bid[0].id, } + const result = spec.interpretResponse(videoResponse) - const result = spec.interpretResponse(videoResponse); - - expect(result[0]).to.deep.equal(expectedResponse); - }); + expect(result[0]).to.deep.equal(expectedResponse) + }) it('should get correct bid response when dealId is passed', function () { - videoResponse.body.seatbid[0].bid[0].dealid = 'baking'; + videoResponse.body.seatbid[0].bid[0].dealid = 'baking' const expectedResponse = { ...baseVideoResponse, - 'dealId': 'baking', + dealId: 'baking', } - const result = spec.interpretResponse(videoResponse) - expect(result[0]).to.deep.equal(expectedResponse); - }); + expect(result[0]).to.deep.equal(expectedResponse) + }) it('should get correct bid response when ttl is set', function () { videoResponse.body.seatbid[0].bid[0].ext = { 'ttl': 480 } const expectedResponse = { ...baseVideoResponse, - 'ttl': 480, + ttl: 480, } - const result = spec.interpretResponse(videoResponse) expect(result[0]).to.deep.equal(expectedResponse) @@ -571,52 +770,51 @@ describe('sovrnBidAdapter', function() { it('handles empty bid response', function () { const response = { body: { - 'id': '37386aade21a71', - 'seatbid': [] + id: '37386aade21a71', + seatbid: [] } - }; - + } const result = spec.interpretResponse(response) - expect(result.length).to.equal(0); - }); - }); + expect(result.length).to.equal(0) + }) + }) describe('getUserSyncs ', function() { - const syncOptions = { iframeEnabled: true, pixelEnabled: false }; - const iframeDisabledSyncOptions = { iframeEnabled: false, pixelEnabled: false }; + const syncOptions = { iframeEnabled: true, pixelEnabled: false } + const iframeDisabledSyncOptions = { iframeEnabled: false, pixelEnabled: false } const serverResponse = [ { - 'body': { - 'id': '546956d68c757f', - 'seatbid': [ + body: { + id: '546956d68c757f', + seatbid: [ { - 'bid': [ + bid: [ { - 'id': 'a_448326_16c2ada014224bee815a90d2248322f5', - 'impid': '2a3826aae345f4', - 'price': 1.0099999904632568, - 'nurl': 'http://localhost/rtb/impression?bannerid=220958&campaignid=3890&rtb_tid=15588614-75d2-40ab-b27e-13d2127b3c2e&rpid=1295&seatid=seat1&zoneid=448326&cb=26900712&tid=a_448326_16c2ada014224bee815a90d2248322f5', - 'adm': 'yo a creative', - 'crid': 'cridprebidrtb', - 'w': 160, - 'h': 600 + id: 'a_448326_16c2ada014224bee815a90d2248322f5', + impid: '2a3826aae345f4', + price: 1.0099999904632568, + nurl: 'http://localhost/rtb/impression?bannerid=220958&campaignid=3890&rtb_tid=15588614-75d2-40ab-b27e-13d2127b3c2e&rpid=1295&seatid=seat1&zoneid=448326&cb=26900712&tid=a_448326_16c2ada014224bee815a90d2248322f5', + adm: 'yo a creative', + crid: 'cridprebidrtb', + w: 160, + h: 600 }, { - 'id': 'a_430392_beac4c1515da4576acf6cb9c5340b40c', - 'impid': '3cf96fd26ed4c5', - 'price': 1.0099999904632568, - 'nurl': 'http://localhost/rtb/impression?bannerid=220957&campaignid=3890&rtb_tid=5bc0e68b-3492-448d-a6f9-26fa3fd0b646&rpid=1295&seatid=seat1&zoneid=430392&cb=62735099&tid=a_430392_beac4c1515da4576acf6cb9c5340b40c', - 'adm': 'yo a creative', - 'crid': 'cridprebidrtb', - 'w': 300, - 'h': 250 + id: 'a_430392_beac4c1515da4576acf6cb9c5340b40c', + impid: '3cf96fd26ed4c5', + price: 1.0099999904632568, + nurl: 'http://localhost/rtb/impression?bannerid=220957&campaignid=3890&rtb_tid=5bc0e68b-3492-448d-a6f9-26fa3fd0b646&rpid=1295&seatid=seat1&zoneid=430392&cb=62735099&tid=a_430392_beac4c1515da4576acf6cb9c5340b40c', + adm: 'yo a creative', + crid: 'cridprebidrtb', + w: 300, + h: 250 }, ] } ], - 'ext': { - 'iid': 13487408, + ext: { + iid: 13487408, sync: { pixels: [ { @@ -629,20 +827,19 @@ describe('sovrnBidAdapter', function() { } } }, - 'headers': {} + headers: {} } - ]; + ] it('should return if iid present on server response & iframe syncs enabled', function() { const expectedReturnStatement = { - 'type': 'iframe', - 'url': 'https://ap.lijit.com/beacon?informer=13487408', + type: 'iframe', + url: 'https://ap.lijit.com/beacon?informer=13487408', } + const returnStatement = spec.getUserSyncs(syncOptions, serverResponse) - const returnStatement = spec.getUserSyncs(syncOptions, serverResponse); - - expect(returnStatement[0]).to.deep.equal(expectedReturnStatement); - }); + expect(returnStatement[0]).to.deep.equal(expectedReturnStatement) + }) it('should include gdpr consent string if present', function() { const gdprConsent = { @@ -650,64 +847,83 @@ describe('sovrnBidAdapter', function() { consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' } const expectedReturnStatement = { - 'type': 'iframe', - 'url': `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&informer=13487408`, + type: 'iframe', + url: `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&informer=13487408`, } - const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, ''); + const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, '', null) - expect(returnStatement[0]).to.deep.equal(expectedReturnStatement); - }); + expect(returnStatement[0]).to.deep.equal(expectedReturnStatement) + }) it('should include us privacy string if present', function() { - const uspString = '1NYN'; + const uspString = '1NYN' + const expectedReturnStatement = { + type: 'iframe', + url: `https://ap.lijit.com/beacon?us_privacy=${uspString}&informer=13487408`, + } + + const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, null, uspString, null) + + expect(returnStatement[0]).to.deep.equal(expectedReturnStatement) + }) + + it('should include gpp consent string if present', function() { + const gppConsent = { + applicableSections: [1, 2], + gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN' + } const expectedReturnStatement = { - 'type': 'iframe', - 'url': `https://ap.lijit.com/beacon?us_privacy=${uspString}&informer=13487408`, + type: 'iframe', + url: `https://ap.lijit.com/beacon?gpp=${gppConsent.gppString}&gpp_sid=${gppConsent.applicableSections}&informer=13487408`, } - const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, null, uspString); + const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, null, '', gppConsent) - expect(returnStatement[0]).to.deep.equal(expectedReturnStatement); - }); + expect(returnStatement[0]).to.deep.equal(expectedReturnStatement) + }) it('should include all privacy strings if present', function() { const gdprConsent = { gdprApplies: 1, consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==' } - const uspString = '1NYN'; + const uspString = '1NYN' + const gppConsent = { + applicableSections: [1, 2], + gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN' + } + const expectedReturnStatement = { - 'type': 'iframe', - 'url': `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&us_privacy=${uspString}&informer=13487408`, + type: 'iframe', + url: `https://ap.lijit.com/beacon?gdpr_consent=${gdprConsent.consentString}&us_privacy=${uspString}&gpp=${gppConsent.gppString}&gpp_sid=${gppConsent.applicableSections}&informer=13487408`, } - const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, uspString) + const returnStatement = spec.getUserSyncs(syncOptions, serverResponse, gdprConsent, uspString, gppConsent) expect(returnStatement[0]).to.deep.equal(expectedReturnStatement) - }); + }) it('should not return if iid missing on server response', function() { - const returnStatement = spec.getUserSyncs(syncOptions, []); + const returnStatement = spec.getUserSyncs(syncOptions, []) - expect(returnStatement).to.be.empty; - }); + expect(returnStatement).to.be.empty + }) it('should not return if iframe syncs disabled', function() { - const returnStatement = spec.getUserSyncs(iframeDisabledSyncOptions, serverResponse); + const returnStatement = spec.getUserSyncs(iframeDisabledSyncOptions, serverResponse) - expect(returnStatement).to.be.empty; - }); + expect(returnStatement).to.be.empty + }) it('should include pixel syncs', function() { const pixelEnabledOptions = { iframeEnabled: false, pixelEnabled: true } - const otherResponce = { ...serverResponse, - 'body': { + body: { ...serverResponse.body, - 'ext': { - 'iid': 13487408, + ext: { + iid: 13487408, sync: { pixels: [ { @@ -724,33 +940,33 @@ describe('sovrnBidAdapter', function() { const returnStatement = spec.getUserSyncs(pixelEnabledOptions, [...serverResponse, otherResponce]) - expect(returnStatement.length).to.equal(4); + expect(returnStatement.length).to.equal(4) expect(returnStatement).to.deep.include.members([ { type: 'image', url: 'http://idprovider1.com' }, { type: 'image', url: 'http://idprovider2.com' }, { type: 'image', url: 'http://idprovider3.com' }, { type: 'image', url: 'http://idprovider4.com' } - ]); + ]) }) }) describe('prebid 3 upgrade', function() { const bidRequest = { ...baseBidRequest, - 'params': { - 'tagid': '403370' + params: { + tagid: '403370' }, - 'mediaTypes': { - 'banner': { - 'sizes': [ + mediaTypes: { + banner: { + sizes: [ [300, 250], [300, 600] ] } }, - }; - const request = spec.buildRequests([bidRequest], baseBidderRequest); - const payload = JSON.parse(request.data); + } + const request = spec.buildRequests([bidRequest], baseBidderRequest) + const payload = JSON.parse(request.data) it('gets sizes from mediaTypes.banner', function() { expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]) @@ -759,8 +975,8 @@ describe('sovrnBidAdapter', function() { }) it('gets correct site info', function() { - expect(payload.site.page).to.equal('http://example.com/page.html'); - expect(payload.site.domain).to.equal('example.com'); + expect(payload.site.page).to.equal('http://example.com/page.html') + expect(payload.site.domain).to.equal('example.com') }) }) }) diff --git a/test/spec/modules/spotxBidAdapter_spec.js b/test/spec/modules/spotxBidAdapter_spec.js index d536976092b..ec99d0f7142 100644 --- a/test/spec/modules/spotxBidAdapter_spec.js +++ b/test/spec/modules/spotxBidAdapter_spec.js @@ -1,5 +1,7 @@ import {expect} from 'chai'; import {config} from 'src/config.js'; +import {loadExternalScript} from '../../../src/adloader'; +import {isRendererRequired} from '../../../src/Renderer'; import {spec, GOOGLE_CONSENT} from 'modules/spotxBidAdapter.js'; describe('the spotx adapter', function () { @@ -18,14 +20,14 @@ describe('the spotx adapter', function () { }; describe('isBidRequestValid', function() { - var bid; + let bid; beforeEach(function() { bid = getValidBidObject(); }); it('should fail validation if the bid isn\'t defined or not an object', function() { - var result = spec.isBidRequestValid(); + let result = spec.isBidRequestValid(); expect(result).to.equal(false); @@ -92,15 +94,19 @@ describe('the spotx adapter', function () { }); describe('buildRequests', function() { - var bid, bidRequestObj; + let bid, bidRequestObj; beforeEach(function() { bid = getValidBidObject(); - bidRequestObj = {refererInfo: {referer: 'prebid.js'}}; + bidRequestObj = { + refererInfo: { + page: 'prebid.js' + } + }; }); it('should build a very basic request', function() { - var request = spec.buildRequests([bid], bidRequestObj)[0]; + let request = spec.buildRequests([bid], bidRequestObj)[0]; expect(request.method).to.equal('POST'); expect(request.url).to.equal('https://search.spotxchange.com/openrtb/2.3/dados/12345?src_sys=prebid'); expect(request.bidRequest).to.equal(bidRequestObj); @@ -129,7 +135,7 @@ describe('the spotx adapter', function () { }); it('should change request parameters based on options sent', function() { - var request = spec.buildRequests([bid], bidRequestObj)[0]; + let request = spec.buildRequests([bid], bidRequestObj)[0]; expect(request.data.imp.video.ext).to.deep.equal({ sdk_name: 'Prebid 1+', versionOrtb: '2.3' @@ -153,10 +159,22 @@ describe('the spotx adapter', function () { position: 1 }; - bid.userId = { - id5id: { uid: 'id5id_1' }, - tdid: 'tdid_1' - }; + bid.userIdAsEids = [{ + source: 'adserver.org', + uids: [{id: 'tdid_1', atype: 1, ext: {rtiPartner: 'TDID'}}] + }, + { + source: 'id5-sync.com', + uids: [{id: 'id5id_1', ext: {}}] + }, + { + source: 'uidapi.com', + uids: [{ + id: 'uid_1', + atype: 3 + }] + } + ]; bid.crumbs = { pubcid: 'pubcid_1' @@ -200,6 +218,15 @@ describe('the spotx adapter', function () { expect(request.data.user.ext).to.deep.equal({ consented_providers_settings: GOOGLE_CONSENT, eids: [{ + source: 'adserver.org', + uids: [{ + id: 'tdid_1', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + }, { source: 'id5-sync.com', uids: [{ id: 'id5id_1', @@ -207,16 +234,17 @@ describe('the spotx adapter', function () { }] }, { - source: 'adserver.org', + source: 'uidapi.com', uids: [{ - id: 'tdid_1', + id: 'uid_1', + atype: 3, ext: { - rtiPartner: 'TDID' + rtiPartner: 'UID2' } }] }], fpc: 'pubcid_1' - }) + }); expect(request.data.source).to.deep.equal({ ext: { @@ -235,7 +263,7 @@ describe('the spotx adapter', function () { }); it('should process premarket bids', function() { - var request; + let request; sinon.stub(Date, 'now').returns(1000); bid.params.pre_market_bids = [{ @@ -273,7 +301,7 @@ describe('the spotx adapter', function () { }); it('should pass GDPR params', function() { - var request; + let request; bidRequestObj.gdprConsent = { consentString: 'consent123', @@ -287,7 +315,7 @@ describe('the spotx adapter', function () { }); it('should pass CCPA us_privacy string', function() { - var request; + let request; bidRequestObj.uspConsent = '1YYY' @@ -296,7 +324,7 @@ describe('the spotx adapter', function () { }); it('should pass both GDPR params and CCPA us_privacy', function() { - var request; + let request; bidRequestObj.gdprConsent = { consentString: 'consent123', @@ -311,7 +339,7 @@ describe('the spotx adapter', function () { }); it('should pass min and max duration params', function() { - var request; + let request; bid.params.min_duration = 3 bid.params.max_duration = 15 @@ -323,7 +351,7 @@ describe('the spotx adapter', function () { }); it('should pass placement_type and position params', function() { - var request; + let request; bid.params.placement_type = 2 bid.params.position = 5 @@ -335,11 +363,11 @@ describe('the spotx adapter', function () { }); it('should pass page param and override refererInfo.referer', function() { - var request; + let request; bid.params.page = 'https://example.com'; - var origGetConfig = config.getConfig; + let origGetConfig = config.getConfig; sinon.stub(config, 'getConfig').callsFake(function (key) { if (key === 'pageUrl') { return 'https://www.spotx.tv'; @@ -353,25 +381,8 @@ describe('the spotx adapter', function () { config.getConfig.restore(); }); - it('should use pageUrl from config if page param is not passed', function() { - var request; - - var origGetConfig = config.getConfig; - sinon.stub(config, 'getConfig').callsFake(function (key) { - if (key === 'pageUrl') { - return 'https://www.spotx.tv'; - } - return origGetConfig.apply(config, arguments); - }); - - request = spec.buildRequests([bid], bidRequestObj)[0]; - - expect(request.data.site.page).to.equal('https://www.spotx.tv'); - config.getConfig.restore(); - }); - - it('should use refererInfo.referer if no page or pageUrl are passed', function() { - var request; + it('should use refererInfo.referer if no page is passed', function() { + let request; request = spec.buildRequests([bid], bidRequestObj)[0]; @@ -379,9 +390,9 @@ describe('the spotx adapter', function () { }); it('should set ext.wrap_response to 0 when cache url is set and ignoreBidderCacheKey is true', function() { - var request; + let request; - var origGetConfig = config.getConfig; + let origGetConfig = config.getConfig; sinon.stub(config, 'getConfig').callsFake(function (key) { if (key === 'cache') { return { @@ -405,7 +416,7 @@ describe('the spotx adapter', function () { }); it('should pass price floor in USD from the floors module if available', function () { - var request; + let request; bid.getFloor = function () { return { currency: 'USD', floor: 3 }; @@ -419,7 +430,7 @@ describe('the spotx adapter', function () { }); it('should not pass price floor if price floors module gives a non-USD currency', function () { - var request; + let request; bid.getFloor = function () { return { currency: 'EUR', floor: 3 }; @@ -431,7 +442,7 @@ describe('the spotx adapter', function () { }); it('if floors module is not available, should pass price floor from price_floor param if available', function () { - var request; + let request; bid.params.price_floor = 2; @@ -442,7 +453,7 @@ describe('the spotx adapter', function () { }); describe('interpretResponse', function() { - var serverResponse, bidderRequestObj; + let serverResponse, bidderRequestObj; beforeEach(function() { bidderRequestObj = { @@ -455,6 +466,7 @@ describe('the spotx adapter', function () { }, bidId: 123, params: { + ad_unit: 'outstream', player_width: 400, player_height: 300, content_page_url: 'prebid.js', @@ -515,7 +527,7 @@ describe('the spotx adapter', function () { }); it('should return an array of bid responses', function() { - var responses = spec.interpretResponse(serverResponse, bidderRequestObj); + let responses = spec.interpretResponse(serverResponse, bidderRequestObj); expect(responses).to.be.an('array').with.length(2); expect(responses[0].cache_key).to.equal('cache123'); expect(responses[0].channel_id).to.equal(12345); @@ -546,12 +558,35 @@ describe('the spotx adapter', function () { expect(responses[1].videoCacheKey).to.equal('cache124'); expect(responses[1].width).to.equal(200); }); + + it('should set the renderer attached to the bid to render immediately', function () { + var renderer = spec.interpretResponse(serverResponse, bidderRequestObj)[0].renderer, + hasRun = false; + expect(renderer._render).to.be.a('function'); + renderer._render = () => { + hasRun = true; + } + renderer.render(); + expect(hasRun).to.equal(true); + }); + + it('should include the url property on the renderer for Prebid Core checks', function () { + var renderer = spec.interpretResponse(serverResponse, bidderRequestObj)[0].renderer; + expect(isRendererRequired(renderer)).to.be.true; + }); }); describe('outstreamRender', function() { - var serverResponse, bidderRequestObj; + let serverResponse, bidderRequestObj; beforeEach(function() { + sinon.stub(window.document, 'getElementById').returns({ + clientWidth: 200, + appendChild: sinon.stub().callsFake(function(script) {}) + }); + sinon.stub(window.document, 'createElement').returns({ + setAttribute: function () {} + }); bidderRequestObj = { bidRequest: { bids: [{ @@ -601,99 +636,76 @@ describe('the spotx adapter', function () { } }; }); + afterEach(function () { + window.document.getElementById.restore(); + window.document.createElement.restore(); + }); it('should attempt to insert the EASI script', function() { - var scriptTag; + window.document.getElementById.restore(); sinon.stub(window.document, 'getElementById').returns({ - appendChild: sinon.stub().callsFake(function(script) { scriptTag = script; }) + appendChild: sinon.stub().callsFake(function(script) {}), }); - var responses = spec.interpretResponse(serverResponse, bidderRequestObj); + let responses = spec.interpretResponse(serverResponse, bidderRequestObj); + let attrs; responses[0].renderer.render(responses[0]); - - expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); - expect(scriptTag.getAttribute('data-spotx_channel_id')).to.equal('12345'); - expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); - expect(scriptTag.getAttribute('data-spotx_ad_unit')).to.equal('incontent'); - expect(scriptTag.getAttribute('data-spotx_collapse')).to.equal('0'); - expect(scriptTag.getAttribute('data-spotx_autoplay')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_blocked_autoplay_override_mode')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_video_slot_can_autoplay')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_digitrust_opt_out')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_content_width')).to.equal('400'); - expect(scriptTag.getAttribute('data-spotx_content_height')).to.equal('300'); - expect(scriptTag.getAttribute('data-spotx_ad_mute')).to.equal('1'); - window.document.getElementById.restore(); + expect(loadExternalScript.called).to.be.true; + attrs = valuesToString(loadExternalScript.args[0][4]); + + expect(attrs['data-spotx_channel_id']).to.equal('12345'); + expect(attrs['data-spotx_vast_url']).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); + expect(attrs['data-spotx_ad_unit']).to.equal('incontent'); + expect(attrs['data-spotx_collapse']).to.equal('0'); + expect(attrs['data-spotx_autoplay']).to.equal('1'); + expect(attrs['data-spotx_blocked_autoplay_override_mode']).to.equal('1'); + expect(attrs['data-spotx_video_slot_can_autoplay']).to.equal('1'); + expect(attrs['data-spotx_digitrust_opt_out']).to.equal('1'); + expect(attrs['data-spotx_content_width']).to.equal('400'); + expect(attrs['data-spotx_content_height']).to.equal('300'); + expect(attrs['data-spotx_ad_mute']).to.equal('1'); }); it('should append into an iframe', function() { - var scriptTag; + bidderRequestObj.bidRequest.bids[0].params.outstream_options.in_iframe = 'iframeId'; + window.document.getElementById.restore(); sinon.stub(window.document, 'getElementById').returns({ nodeName: 'IFRAME', - contentDocument: { - body: { - appendChild: sinon.stub().callsFake(function(script) { scriptTag = script; }) - } - } + clientWidth: 200, + appendChild: sinon.stub().callsFake(function(script) {}), + contentDocument: {nodeName: 'IFRAME'} }); - bidderRequestObj.bidRequest.bids[0].params.outstream_options.in_iframe = 'iframeId'; - - var responses = spec.interpretResponse(serverResponse, bidderRequestObj); - + let responses = spec.interpretResponse(serverResponse, bidderRequestObj); responses[0].renderer.render(responses[0]); - - expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); - expect(scriptTag.getAttribute('data-spotx_channel_id')).to.equal('12345'); - expect(scriptTag.getAttribute('data-spotx_vast_url')).to.equal('https://search.spotxchange.com/ad/vast.html?key=cache123'); - expect(scriptTag.getAttribute('data-spotx_ad_unit')).to.equal('incontent'); - expect(scriptTag.getAttribute('data-spotx_collapse')).to.equal('0'); - expect(scriptTag.getAttribute('data-spotx_autoplay')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_blocked_autoplay_override_mode')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_video_slot_can_autoplay')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_digitrust_opt_out')).to.equal('1'); - expect(scriptTag.getAttribute('data-spotx_content_width')).to.equal('400'); - expect(scriptTag.getAttribute('data-spotx_content_height')).to.equal('300'); - window.document.getElementById.restore(); + expect(loadExternalScript.called).to.be.true; + expect(loadExternalScript.args[0][3].nodeName).to.equal('IFRAME'); }); it('should adjust width and height to match slot clientWidth if playersize_auto_adapt is used', function() { - var scriptTag; - sinon.stub(window.document, 'getElementById').returns({ - clientWidth: 200, - appendChild: sinon.stub().callsFake(function(script) { scriptTag = script; }) - }); - var responses = spec.interpretResponse(serverResponse, bidderRequestObj); + let responses = spec.interpretResponse(serverResponse, bidderRequestObj); responses[0].renderer.render(responses[0]); - - expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); - expect(scriptTag.getAttribute('data-spotx_content_width')).to.equal('200'); - expect(scriptTag.getAttribute('data-spotx_content_height')).to.equal('150'); - window.document.getElementById.restore(); + expect(loadExternalScript.args[0][4]['data-spotx_content_width']).to.equal('200'); + expect(loadExternalScript.args[0][4]['data-spotx_content_height']).to.equal('150'); }); it('should use a default 4/3 ratio if playersize_auto_adapt is used and response does not contain width or height', function() { delete serverResponse.body.seatbid[0].bid[0].w; delete serverResponse.body.seatbid[0].bid[0].h; - - var scriptTag; - sinon.stub(window.document, 'getElementById').returns({ - clientWidth: 200, - appendChild: sinon.stub().callsFake(function(script) { scriptTag = script; }) - }); - var responses = spec.interpretResponse(serverResponse, bidderRequestObj); + let responses = spec.interpretResponse(serverResponse, bidderRequestObj); responses[0].renderer.render(responses[0]); - - expect(scriptTag.getAttribute('type')).to.equal('text/javascript'); - expect(scriptTag.getAttribute('src')).to.equal('https://js.spotx.tv/easi/v1/12345.js'); - expect(scriptTag.getAttribute('data-spotx_content_width')).to.equal('200'); - expect(scriptTag.getAttribute('data-spotx_content_height')).to.equal('150'); - window.document.getElementById.restore(); + expect(loadExternalScript.args[0][4]['data-spotx_content_width']).to.equal('200'); + expect(loadExternalScript.args[0][4]['data-spotx_content_height']).to.equal('150'); }); }); }); + +function valuesToString(obj) { + let newObj = {}; + for (let prop in obj) { + newObj[prop] = '' + obj[prop]; + } + return newObj; +} diff --git a/test/spec/modules/ssmasBidAdapter_spec.js b/test/spec/modules/ssmasBidAdapter_spec.js new file mode 100644 index 00000000000..26c6f60da4b --- /dev/null +++ b/test/spec/modules/ssmasBidAdapter_spec.js @@ -0,0 +1,244 @@ +import { expect } from 'chai'; +import { spec, SSMAS_CODE, SSMAS_ENDPOINT, SSMAS_REQUEST_METHOD } from 'modules/ssmasBidAdapter.js'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import * as utils from 'src/utils.js'; + +describe('ssmasBidAdapter', function () { + const bid = { + bidder: SSMAS_CODE, + adUnitCode: 'adunit-code', + sizes: [[300, 250]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + params: { + placementId: '1' + } + }; + + const bidderRequest = { + 'bidderCode': SSMAS_CODE, + 'auctionId': 'd912faa2-174f-4636-b755-7396a0a964d8', + 'bidderRequestId': '109db5a5f5c6788', + 'bids': [ + bid + ], + 'auctionStart': 1684799653734, + 'timeout': 20000, + 'metrics': {}, + 'ortb2': { + 'site': { + 'domain': 'localhost:9999', + 'publisher': { + 'domain': 'localhost:9999' + }, + 'page': 'http://localhost:9999/integrationExamples/noadserver/basic_noadserver.html', + 'ref': 'http://localhost:9999/integrationExamples/noadserver/' + }, + 'device': { + 'w': 1536, + 'h': 711, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0', + 'language': 'es' + } + }, + 'start': 1684799653737 + }; + + describe('Build Requests', () => { + it('Check bid request', function () { + const request = spec.buildRequests([bid], bidderRequest); + expect(request[0].method).to.equal(SSMAS_REQUEST_METHOD); + expect(request[0].url).to.equal(SSMAS_ENDPOINT); + }); + }); + + describe('register adapter functions', () => { + const adapter = newBidder(spec); + it('is registered', () => { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid', function () { + it('validate bid request building', function () { + expect(spec.isBidRequestValid(bid)).to.be.true; + }); + + it('test bad bid request', function () { + // empty bid + expect(spec.isBidRequestValid({bidId: '', params: {}})).to.be.false; + + // empty bidId + bid.bidId = ''; + expect(spec.isBidRequestValid(bid)).to.be.false; + + // empty placementId + bid.bidId = '1231'; + bid.params.placementId = ''; + expect(spec.isBidRequestValid(bid)).to.be.false; + }); + + it('check bid request bidder is Sem Seo & Mas', function() { + const invalidBid = { + ...bid, bidder: 'invalidBidder' + }; + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('interpretResponse', function () { + let bidOrtbResponse = { + 'id': 'aa02e2fe-56d9-4713-88f9-d8672ceae8ab', + 'seatbid': [ + { + 'bid': [ + { + 'id': '0001', + 'impid': '3919400af0b73e8', + 'price': 7.01, + 'adid': null, + 'nurl': null, + 'adm': '', + 'adomain': [ + 'ssmas.com' + ], + 'iurl': null, + 'cid': null, + 'crid': '3547894', + 'attr': [], + 'api': 0, + 'protocol': 0, + 'dealid': null, + 'h': 600, + 'w': 300, + 'cat': null, + 'ext': null, + 'builder': { + 'id': '0001', + 'adid': null, + 'impid': '3919400af0b73e8', + 'adomainList': [ + 'ssmas.com' + ], + 'attrList': [] + }, + 'adomainList': [ + 'ssmas.com' + ], + 'attrList': [] + } + ], + 'seat': null, + 'group': 0 + } + ], + 'bidid': '408731cc-c018-4976-bfc6-89f9c61e97a0', + 'cur': 'EUR', + 'nbr': -1 + }; + let bidResponse = { + 'mediaType': 'banner', + 'ad': '', + 'requestId': '37c658fe8ba57b', + 'seatBidId': '0001', + 'cpm': 10, + 'currency': 'EUR', + 'width': 300, + 'height': 250, + 'dealId': null, + 'creative_id': '3547894', + 'creativeId': '3547894', + 'ttl': 30, + 'netRevenue': true, + 'meta': { + 'advertiserDomains': [ + 'ssmas.com' + ] + } + }; + let bidRequest = { + 'imp': [ + { + 'ext': { + 'tid': '937db9c3-c22d-4454-b786-fcad76a349e5', + 'data': { + 'pbadslot': 'test-div' + } + }, + 'id': '3919400af0b73e8', + 'banner': { + 'topframe': 1, + 'format': [ + { + 'w': 300, + 'h': 600 + } + ] + } + }, + { + 'ext': { + 'tid': '0c0d3d1b-0ad0-4786-896d-24c15fc6531d', + 'data': { + 'pbadslot': 'test-div2' + } + }, + 'id': '3919400af0b73e8', + 'banner': { + 'topframe': 1, + 'format': [ + { + 'w': 300, + 'h': 600 + } + ] + } + } + ], + 'site': { + 'domain': 'localhost:9999', + 'publisher': { + 'domain': 'localhost:9999' + }, + 'page': 'http://localhost:9999/integrationExamples/noadserver/basic_noadserver.html', + 'ref': 'http://localhost:9999/integrationExamples/noadserver/', + 'id': 1, + 'ext': { + 'placementId': 13144370 + } + }, + 'device': { + 'w': 1536, + 'h': 711, + 'dnt': 0, + 'ua': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0', + 'language': 'es' + }, + 'id': '8cc2f4b0-084d-4f40-acfa-5bec2023b1ab', + 'test': 0, + 'tmax': 20000, + 'source': { + 'tid': '8cc2f4b0-084d-4f40-acfa-5bec2023b1ab' + } + } + }); + + describe('test onBidWon function', function () { + beforeEach(function() { + sinon.stub(utils, 'triggerPixel'); + }); + afterEach(function() { + utils.triggerPixel.restore(); + }); + it('exists and is a function', () => { + expect(spec.onBidWon).to.exist.and.to.be.a('function'); + }); + it('should return nothing', function () { + var response = spec.onBidWon({}); + expect(response).to.be.an('undefined') + expect(utils.triggerPixel.called).to.equal(false); + }); + }); +}); diff --git a/test/spec/modules/sspBCBidAdapter_spec.js b/test/spec/modules/sspBCBidAdapter_spec.js index a0c4837bb51..71619424e4b 100644 --- a/test/spec/modules/sspBCBidAdapter_spec.js +++ b/test/spec/modules/sspBCBidAdapter_spec.js @@ -38,7 +38,7 @@ describe('SSPBC adapter', function () { }, auctionId, bidderRequestId, - bidId: auctionId + '1', + bidId: bidderRequestId + '1', transactionId, }, { @@ -60,7 +60,7 @@ describe('SSPBC adapter', function () { }, auctionId, bidderRequestId, - bidId: auctionId + '2', + bidId: bidderRequestId + '2', transactionId, } ]; @@ -83,7 +83,7 @@ describe('SSPBC adapter', function () { ], auctionId, bidderRequestId, - bidId: auctionId + '1', + bidId: bidderRequestId + '1', transactionId, }; const bid_native = { @@ -122,7 +122,7 @@ describe('SSPBC adapter', function () { ], auctionId, bidderRequestId, - bidId: auctionId + '1', + bidId: bidderRequestId + '1', transactionId, }; const bid_video = { @@ -144,7 +144,7 @@ describe('SSPBC adapter', function () { ], auctionId, bidderRequestId, - bidId: auctionId + '1', + bidId: bidderRequestId + '1', transactionId, }; const bids_timeouted = [{ @@ -155,7 +155,7 @@ describe('SSPBC adapter', function () { siteId: '8816', }], auctionId, - bidId: auctionId + '1', + bidId: bidderRequestId + '1', timeout: 100, }, { @@ -166,7 +166,7 @@ describe('SSPBC adapter', function () { siteId: '8816', }], auctionId, - bidId: auctionId + '2', + bidId: bidderRequestId + '2', timeout: 100, } ]; @@ -198,7 +198,7 @@ describe('SSPBC adapter', function () { }, auctionId, bidderRequestId, - bidId: auctionId + '1', + bidId: bidderRequestId + '1', transactionId, }]; const bidRequest = { @@ -209,7 +209,8 @@ describe('SSPBC adapter', function () { gdprConsent, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; @@ -221,7 +222,8 @@ describe('SSPBC adapter', function () { gdprConsent, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; @@ -233,7 +235,8 @@ describe('SSPBC adapter', function () { gdprConsent, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; @@ -245,7 +248,8 @@ describe('SSPBC adapter', function () { gdprConsent, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; @@ -257,7 +261,8 @@ describe('SSPBC adapter', function () { gdprConsent, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; @@ -269,7 +274,8 @@ describe('SSPBC adapter', function () { gdprConsent, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; @@ -280,13 +286,14 @@ describe('SSPBC adapter', function () { bids: bids_test, refererInfo: { reachedTop: true, - referer: 'https://test.site.pl/', + page: 'https://test.site.pl/', + domain: 'test.site.pl', stack: ['https://test.site.pl/'], } }; const serverResponse = { 'body': { - 'id': auctionId, + 'id': bidderRequestId, 'seatbid': [{ 'bid': [{ 'id': '3347324c-6889-46d2-a800-ae78a5214c06', @@ -326,7 +333,7 @@ describe('SSPBC adapter', function () { }; const serverResponseSingle = { 'body': { - 'id': auctionId, + 'id': bidderRequestId, 'seatbid': [{ 'bid': [{ 'id': '3347324c-6889-46d2-a800-ae78a5214c06', @@ -351,11 +358,11 @@ describe('SSPBC adapter', function () { }; const serverResponseOneCode = { 'body': { - 'id': auctionId, + 'id': bidderRequestId, 'seatbid': [{ 'bid': [{ 'id': '3347324c-6889-46d2-a800-ae78a5214c06', - 'impid': 'bidid-' + auctionId + '1', + 'impid': 'bidid-' + bidderRequestId + '1', 'price': 1, 'adid': 'lxHWkB7OnZeso3QiN1N4', 'nurl': '', @@ -378,11 +385,11 @@ describe('SSPBC adapter', function () { }; const serverResponseVideo = { 'body': { - 'id': auctionId, + 'id': bidderRequestId, 'seatbid': [{ 'bid': [{ 'id': '3347324c-6889-46d2-a800-ae78a5214c06', - 'impid': 'bidid-' + auctionId + '1', + 'impid': 'bidid-' + bidderRequestId + '1', 'price': 1, 'adid': 'lxHWkB7OnZeso3QiN1N4', 'nurl': '', @@ -395,6 +402,7 @@ describe('SSPBC adapter', function () { 'ext': { 'siteid': '8816', 'slotid': '150', + 'cache': 'https://video.tag.cache' }, }], 'seat': 'dsp1', @@ -405,11 +413,11 @@ describe('SSPBC adapter', function () { }; const serverResponseNative = { 'body': { - 'id': auctionId, + 'id': bidderRequestId, 'seatbid': [{ 'bid': [{ 'id': '3347324c-6889-46d2-a800-ae78a5214c06', - 'impid': 'bidid-' + auctionId + '1', + 'impid': 'bidid-' + bidderRequestId + '1', 'price': 1, 'adid': 'lxHWkB7OnZeso3QiN1N4', 'nurl': '', @@ -430,7 +438,7 @@ describe('SSPBC adapter', function () { }; const emptyResponse = { 'body': { - 'id': auctionId, + 'id': bidderRequestId, } } return { @@ -510,7 +518,7 @@ describe('SSPBC adapter', function () { }); it('should send page url from refererInfo', function () { - expect(payload.site.page).to.equal(bidRequest.refererInfo.referer); + expect(payload.site.page).to.equal(bidRequest.refererInfo.page); }); it('should send gdpr data', function () { @@ -549,6 +557,7 @@ describe('SSPBC adapter', function () { const nativeAssets = payloadNative.imp && payloadNative.imp[0].native.request; expect(payloadNative.imp.length).to.equal(1); + expect(nativeAssets).to.contain('{"id":0,"required":true,"title":{"len":80}}'); expect(nativeAssets).to.contain('{"id":2,"required":true,"img":{"type":1,"w":50,"h":50}}'); expect(nativeAssets).to.contain('{"id":3,"required":true,"img":{"type":3,"w":150,"h":50}}'); @@ -602,14 +611,14 @@ describe('SSPBC adapter', function () { expect(result.length).to.equal(bids.length); expect(resultSingle.length).to.equal(1); - expect(resultSingle[0]).to.have.keys('ad', 'cpm', 'width', 'height', 'bidderCode', 'mediaType', 'meta', 'requestId', 'creativeId', 'currency', 'netRevenue', 'ttl'); + expect(resultSingle[0]).to.have.keys('ad', 'cpm', 'width', 'height', 'mediaType', 'meta', 'requestId', 'creativeId', 'currency', 'netRevenue', 'ttl', 'vurls'); }); it('should create bid from OneCode (parameter-less) request, if response contains siteId', function () { let resultOneCode = spec.interpretResponse(serverResponseOneCode, requestOneCode); expect(resultOneCode.length).to.equal(1); - expect(resultOneCode[0]).to.have.keys('ad', 'cpm', 'width', 'height', 'bidderCode', 'mediaType', 'meta', 'requestId', 'creativeId', 'currency', 'netRevenue', 'ttl'); + expect(resultOneCode[0]).to.have.keys('ad', 'cpm', 'width', 'height', 'mediaType', 'meta', 'requestId', 'creativeId', 'currency', 'netRevenue', 'ttl', 'vurls'); }); it('should not create bid from OneCode (parameter-less) request, if response does not contain siteId', function () { @@ -631,6 +640,7 @@ describe('SSPBC adapter', function () { expect(adcode).to.contain('window.mcad'); expect(adcode).to.contain('window.gdpr'); expect(adcode).to.contain('window.page'); + expect(adcode).to.contain('window.requestPVID'); }); it('should create a correct video bid', function () { @@ -639,11 +649,12 @@ describe('SSPBC adapter', function () { expect(resultVideo.length).to.equal(1); let videoBid = resultVideo[0]; - expect(videoBid).to.have.keys('adType', 'bidderCode', 'cpm', 'creativeId', 'currency', 'width', 'height', 'meta', 'mediaType', 'netRevenue', 'requestId', 'ttl', 'vastContent', 'vastXml'); + expect(videoBid).to.have.keys('adType', 'cpm', 'creativeId', 'currency', 'width', 'height', 'meta', 'mediaType', 'netRevenue', 'requestId', 'ttl', 'vastContent', 'vastXml', 'vastUrl', 'vurls'); expect(videoBid.adType).to.equal('instream'); expect(videoBid.mediaType).to.equal('video'); expect(videoBid.vastXml).to.match(/^<\?xml.*<\/VAST>$/); expect(videoBid.vastContent).to.match(/^<\?xml.*<\/VAST>$/); + expect(videoBid.vastUrl).to.equal('https://video.tag.cache'); }); it('should create a correct native bid', function () { @@ -652,8 +663,8 @@ describe('SSPBC adapter', function () { expect(resultNative.length).to.equal(1); let nativeBid = resultNative[0]; - expect(nativeBid).to.have.keys('bidderCode', 'cpm', 'creativeId', 'currency', 'width', 'height', 'meta', 'mediaType', 'netRevenue', 'requestId', 'ttl', 'native'); - expect(nativeBid.native).to.have.keys('image', 'icon', 'title', 'sponsoredBy', 'body', 'clickUrl', 'impressionTrackers', 'javascriptTrackers'); + expect(nativeBid).to.have.keys('cpm', 'creativeId', 'currency', 'width', 'height', 'meta', 'mediaType', 'netRevenue', 'requestId', 'ttl', 'native', 'vurls'); + expect(nativeBid.native).to.have.keys('image', 'icon', 'title', 'sponsoredBy', 'body', 'clickUrl', 'impressionTrackers', 'javascriptTrackers', 'clickTrackers'); }); }); @@ -668,8 +679,8 @@ describe('SSPBC adapter', function () { }); it('should send no syncs, if frame sync is not allowed', function () { - expect(syncResultImage).to.have.length(0); ; - expect(syncResultNone).to.have.length(0); ; + expect(syncResultImage).to.have.length(0); + expect(syncResultNone).to.have.length(0); }); }); @@ -685,7 +696,7 @@ describe('SSPBC adapter', function () { let notificationPayload = spec.onBidWon(bid); expect(notificationPayload).to.have.property('event').that.equals('bidWon'); - expect(notificationPayload).to.have.property('requestId').that.equals(bid.auctionId); + expect(notificationPayload).to.have.property('requestId').that.equals(bid.bidderRequestId); expect(notificationPayload).to.have.property('tagid').that.deep.equals([bid.adUnitCode]); expect(notificationPayload).to.have.property('siteId').that.is.an('array'); expect(notificationPayload).to.have.property('slotId').that.is.an('array'); @@ -706,7 +717,6 @@ describe('SSPBC adapter', function () { let notificationPayload = spec.onTimeout(bids_timeouted); expect(notificationPayload).to.have.property('event').that.equals('timeout'); - expect(notificationPayload).to.have.property('requestId').that.equals(bids_timeouted[0].auctionId); expect(notificationPayload).to.have.property('tagid').that.deep.equals([bids_timeouted[0].adUnitCode, bids_timeouted[1].adUnitCode]); }); }); diff --git a/test/spec/modules/stroeerCoreBidAdapter_spec.js b/test/spec/modules/stroeerCoreBidAdapter_spec.js index e723523de31..2ed5f80f152 100644 --- a/test/spec/modules/stroeerCoreBidAdapter_spec.js +++ b/test/spec/modules/stroeerCoreBidAdapter_spec.js @@ -3,6 +3,7 @@ import {spec} from 'modules/stroeerCoreBidAdapter.js'; import * as utils from 'src/utils.js'; import {BANNER, VIDEO} from '../../../src/mediaTypes.js'; import {find} from 'src/polyfill.js'; +import sinon from 'sinon'; describe('stroeerCore bid adapter', function () { let sandbox; @@ -21,9 +22,8 @@ describe('stroeerCore bid adapter', function () { sandbox.restore(); }); - function assertStandardFieldsOnBid(bidObject, bidId, ad, width, height, cpm) { + function assertStandardFieldsBid(bidObject, bidId, width, height, cpm) { assert.propertyVal(bidObject, 'requestId', bidId); - assert.propertyVal(bidObject, 'ad', ad); assert.propertyVal(bidObject, 'width', width); assert.propertyVal(bidObject, 'height', height); assert.propertyVal(bidObject, 'cpm', cpm); @@ -32,7 +32,25 @@ describe('stroeerCore bid adapter', function () { assert.propertyVal(bidObject, 'creativeId', ''); } - const AUCTION_ID = utils.getUniqueIdentifierStr(); + function assertStandardFieldsOnBannerBid(bidObject, bidId, ad, width, height, cpm) { + assertStandardFieldsBid(bidObject, bidId, width, height, cpm); + assertBannerAdMarkup(bidObject, ad); + } + + function assertStandardFieldsOnVideoBid(bidObject, bidId, vastXml, width, height, cpm) { + assertStandardFieldsBid(bidObject, bidId, width, height, cpm); + assertVideoVastXml(bidObject, vastXml); + } + + function assertBannerAdMarkup(bidObject, ad) { + assert.propertyVal(bidObject, 'ad', ad); + assert.notProperty(bidObject, 'vastXml'); + } + + function assertVideoVastXml(bidObject, vastXml) { + assert.propertyVal(bidObject, 'vastXml', vastXml); + assert.notProperty(bidObject, 'ad'); + } // Vendor user ids and associated data const userIds = Object.freeze({ @@ -53,11 +71,14 @@ describe('stroeerCore bid adapter', function () { }); const buildBidderRequest = () => ({ - auctionId: AUCTION_ID, bidderRequestId: 'bidder-request-id-123', bidderCode: 'stroeerCore', timeout: 5000, auctionStart: 10000, + refererInfo: { + page: 'https://www.example.com/monkey/index.html', + ref: 'https://www.example.com/?search=monkey' + }, bids: [{ bidId: 'bid1', bidder: 'stroeerCore', @@ -87,16 +108,6 @@ describe('stroeerCore bid adapter', function () { }], }); - const buildBidderRequestPreVersion3 = () => { - const request = buildBidderRequest(); - request.bids.forEach((bid) => { - bid.sizes = bid.mediaTypes.banner.sizes; - delete bid.mediaTypes; - bid.mediaType = 'banner'; - }); - return request; - }; - const buildBidderResponse = () => ({ 'bids': [{ 'bidId': 'bid1', 'cpm': 4.0, 'width': 300, 'height': 600, 'ad': '
tag1
', 'tracking': {'brandId': 123} @@ -105,10 +116,16 @@ describe('stroeerCore bid adapter', function () { }] }); + const buildBidderResponseWithVideo = () => ({ + 'bids': [{ + 'bidId': 'bid1', 'cpm': 4.0, 'width': 800, 'height': 250, 'vastXml': 'video' + }] + }); + const createWindow = (href, params = {}) => { - let {parent, referrer, top, frameElement, placementElements = []} = params; + let {parent, top, frameElement, placementElements = []} = params; - const protocol = (href.indexOf('https') === 0) ? 'https:' : 'http:'; + const protocol = href.startsWith('https') ? 'https:' : 'http:'; const win = { frameElement, parent, @@ -123,7 +140,6 @@ describe('stroeerCore bid adapter', function () { } } }, - referrer, getElementById: id => find(placementElements, el => el.id === id) } }; @@ -166,7 +182,7 @@ describe('stroeerCore bid adapter', function () { } function setupNestedWindows(sandBox, placementElements = [createElement('div-1', 17), createElement('div-2', 54)]) { - const topWin = createWindow('http://www.abc.org/', {referrer: 'http://www.google.com/?query=monkey'}); + const topWin = createWindow('http://www.abc.org/'); topWin.innerHeight = 800; const midWin = createWindow('http://www.abc.org/', {parent: topWin, top: topWin, frameElement: createElement()}); @@ -184,8 +200,12 @@ describe('stroeerCore bid adapter', function () { return {topWin, midWin, win}; } - it('should only support BANNER mediaType', function () { - assert.deepEqual(spec.supportedMediaTypes, [BANNER]); + it('should support BANNER and VIDEO mediaType', function () { + assert.deepEqual(spec.supportedMediaTypes, [BANNER, VIDEO]); + }); + + it('should have GDPR vendor list id (gvlid) set on the spec', function () { + assert.equal(spec.gvlid, 136); }); describe('bid validation entry point', () => { @@ -208,16 +228,86 @@ describe('stroeerCore bid adapter', function () { assert.isFalse(spec.isBidRequestValid(bidRequest)); }); - it('should exclude non-banner bids', () => { + it('should allow instream video bids', () => { delete bidRequest.mediaTypes.banner; bidRequest.mediaTypes.video = { - playerSize: [640, 480] + playerSize: [640, 480], + context: 'instream' + }; + + assert.isTrue(spec.isBidRequestValid(bidRequest)); + }); + + it('should allow outstream video bids', () => { + delete bidRequest.mediaTypes.banner; + bidRequest.mediaTypes.video = { + playerSize: [640, 480], + context: 'outstream' + }; + + assert.isTrue(spec.isBidRequestValid(bidRequest)); + }); + + it('should allow multi-format bid that has banner and instream video', () => { + assert.isTrue('banner' in bidRequest.mediaTypes); + + // Allowed because instream video component of the bid will be ignored in buildRequest() + bidRequest.mediaTypes.video = { + playerSize: [640, 480], + context: 'instream' + }; + + assert.isTrue(spec.isBidRequestValid(bidRequest)) + }); + + it('should exclude multi-format bid that has no format of interest', () => { + bidRequest.mediaTypes = { + video: { + playerSize: [640, 480], + context: 'adpod' + }, + native: { + image: { + required: true, + sizes: [150, 50] + }, + title: { + required: true, + len: 80 + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + privacyLink: { + required: false + }, + body: { + required: true + }, + icon: { + required: true, + sizes: [50, 50] + } + } }; assert.isFalse(spec.isBidRequestValid(bidRequest)); }); - it('should exclude non-banner, pre-version 3 bids', () => { + it('should exclude video bids without context', () => { + delete bidRequest.mediaTypes.banner; + bidRequest.mediaTypes.video = { + playerSize: [640, 480], + context: undefined + }; + + assert.isFalse(spec.isBidRequestValid(bidRequest)); + }); + + it('should exclude video, pre-version 3 bids', () => { delete bidRequest.mediaTypes; bidRequest.mediaType = VIDEO; assert.isFalse(spec.isBidRequestValid(bidRequest)); @@ -250,9 +340,13 @@ describe('stroeerCore bid adapter', function () { describe('should use custom url if provided', () => { const samples = [{ - protocol: 'http:', params: {sid: 'ODA=', host: 'other.com', port: '234', path: '/xyz'}, expected: 'https://other.com:234/xyz' + protocol: 'http:', + params: {sid: 'ODA=', host: 'other.com', port: '234', path: '/xyz'}, + expected: 'https://other.com:234/xyz' }, { - protocol: 'https:', params: {sid: 'ODA=', host: 'other.com', port: '234', path: '/xyz'}, expected: 'https://other.com:234/xyz' + protocol: 'https:', + params: {sid: 'ODA=', host: 'other.com', port: '234', path: '/xyz'}, + expected: 'https://other.com:234/xyz' }, { protocol: 'https:', params: {sid: 'ODA=', host: 'other.com', port: '234', securePort: '871', path: '/xyz'}, @@ -298,6 +392,10 @@ describe('stroeerCore bid adapter', function () { clock.tick(13500); const bidReq = buildBidderRequest(); + const UUID = 'fb6a39e3-083f-424c-9046-f1095e15f3d5'; + + const generateUUIDStub = sinon.stub(utils, 'generateUUID').returns(UUID); + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); const expectedTimeout = bidderRequest.timeout - (13500 - bidderRequest.auctionStart); @@ -305,15 +403,26 @@ describe('stroeerCore bid adapter', function () { assert.equal(expectedTimeout, 1500); const expectedJsonPayload = { - 'id': AUCTION_ID, + 'id': UUID, 'timeout': expectedTimeout, - 'ref': topWin.document.referrer, + 'ref': 'https://www.example.com/?search=monkey', 'mpa': true, 'ssl': false, + 'url': 'https://www.example.com/monkey/index.html', 'bids': [{ - 'sid': 'NDA=', 'bid': 'bid1', 'siz': [[300, 600], [160, 60]], 'viz': true + 'sid': 'NDA=', + 'bid': 'bid1', + 'viz': true, + 'ban': { + 'siz': [[300, 600], [160, 60]] + } }, { - 'sid': 'ODA=', 'bid': 'bid2', 'siz': [[728, 90]], 'viz': true + 'sid': 'ODA=', + 'bid': 'bid2', + 'viz': true, + 'ban': { + 'siz': [[728, 90]] + } }], 'user': { 'euids': userIds @@ -322,17 +431,192 @@ describe('stroeerCore bid adapter', function () { // trim away fields with undefined const actualJsonPayload = JSON.parse(JSON.stringify(serverRequestInfo.data)); - assert.deepEqual(actualJsonPayload, expectedJsonPayload); + + generateUUIDStub.restore(); }); - it('should handle banner sizes for pre version 3', () => { - // Version 3 changes the way how banner sizes are accessed. - // We can support backwards compatibility with version 2.x - const bidReq = buildBidderRequestPreVersion3(); - const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); - assert.deepEqual(serverRequestInfo.data.bids[0].siz, [[300, 600], [160, 60]]); - assert.deepEqual(serverRequestInfo.data.bids[1].siz, [[728, 90]]); + describe('video bids', () => { + it('should be able to build instream video bid', () => { + bidderRequest.bids = [{ + bidId: 'bid1', + bidder: 'stroeerCore', + adUnitCode: 'div-1', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4', 'video/quicktime'] + } + }, + params: { + sid: 'NDA=' + }, + userId: userIds + }]; + + const expectedBids = [{ + 'sid': 'NDA=', + 'bid': 'bid1', + 'viz': true, + 'vid': { + 'ctx': 'instream', + 'siz': [640, 480], + 'mim': ['video/mp4', 'video/quicktime'] + } + }]; + + const serverRequestInfo = spec.buildRequests(bidderRequest.bids, bidderRequest); + + const bids = JSON.parse(JSON.stringify(serverRequestInfo.data.bids)); + assert.deepEqual(bids, expectedBids); + }); + }); + + describe('multi-formats', () => { + it(`should create a request for video and banner`, () => { + const videoBid = { + bidId: 'bid3', + bidder: 'stroeerCore', + adUnitCode: 'div-1', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4', 'video/quicktime'], + } + }, + params: { + sid: 'ODA=', + }, + userId: userIds + } + + const bannerBid1 = { + bidId: 'bid8', + bidder: 'stroeerCore', + adUnitCode: 'div-2', + mediaTypes: { + banner: { + sizes: [[300, 600], [160, 60]], + } + }, + params: { + sid: 'NDA=', + }, + userId: userIds + } + + const bannerBid2 = { + bidId: 'bid12', + bidder: 'stroeerCore', + adUnitCode: 'div-3', + mediaTypes: { + banner: { + sizes: [[100, 200], [300, 500]], + } + }, + params: { + sid: 'ABC=', + }, + userId: userIds + } + + bidderRequest.bids = [bannerBid1, videoBid, bannerBid2]; + + const expectedBannerBids = [ + { + 'sid': 'NDA=', + 'bid': 'bid8', + 'viz': true, + 'ban': { + 'siz': [[300, 600], [160, 60]], + 'fp': undefined + }, + }, + { + 'sid': 'ABC=', + 'bid': 'bid12', + 'ban': { + 'siz': [[100, 200], [300, 500]], + 'fp': undefined + }, + 'viz': undefined + } + ]; + + const expectedVideoBids = [ + { + 'sid': 'ODA=', + 'bid': 'bid3', + 'viz': true, + 'vid': { + 'ctx': 'instream', + 'siz': [640, 480], + 'mim': ['video/mp4', 'video/quicktime'], + 'fp': undefined + } + } + ]; + + const serverRequestInfo = spec.buildRequests(bidderRequest.bids, bidderRequest); + + assert.deepEqual(serverRequestInfo.data.bids, [...expectedBannerBids, ...expectedVideoBids]); + }); + + it('should split multi-format bid', function() { + const multiFormatBid = { + bidId: 'bid3', + bidder: 'stroeerCore', + adUnitCode: 'div-1', + mediaTypes: { + video: { + context: 'instream', + playerSize: [640, 480], + mimes: ['video/mp4', 'video/quicktime'], + }, + banner: { + sizes: [[100, 200], [300, 500]], + } + }, + params: { + sid: 'ODA=', + }, + userId: userIds + } + + bidderRequest.bids = [multiFormatBid]; + + const serverRequestInfo = spec.buildRequests(bidderRequest.bids, bidderRequest); + + const expectedBannerBids = [ + { + 'sid': 'ODA=', + 'bid': 'bid3', + 'viz': true, + 'ban': { + 'siz': [[100, 200], [300, 500]], + 'fp': undefined + } + } + ]; + + const expectedVideoBids = [ + { + 'sid': 'ODA=', + 'bid': 'bid3', + 'viz': true, + 'vid': { + 'ctx': 'instream', + 'siz': [640, 480], + 'mim': ['video/mp4', 'video/quicktime'], + 'fp': undefined + } + } + ]; + + assert.deepEqual(serverRequestInfo.data.bids, [...expectedBannerBids, ...expectedVideoBids]); + }); }); describe('optional fields', () => { @@ -360,7 +644,13 @@ describe('stroeerCore bid adapter', function () { } }); - const gdprSamples = [{consentString: 'RG9ua2V5IEtvbmc=', gdprApplies: true}, {consentString: 'UGluZyBQb25n', gdprApplies: false}]; + const gdprSamples = [ + {consentString: 'RG9ua2V5IEtvbmc=', gdprApplies: true}, + {consentString: 'UGluZyBQb25n', gdprApplies: false}, + {consentString: undefined, gdprApplies: true}, + {consentString: undefined, gdprApplies: false}, + {consentString: undefined, gdprApplies: undefined}, + ]; gdprSamples.forEach((sample) => { it(`should add GDPR info ${JSON.stringify(sample)} when provided`, () => { const bidReq = buildBidderRequest(); @@ -374,22 +664,14 @@ describe('stroeerCore bid adapter', function () { }); }); - const skippableGdprSamples = [{consentString: null, gdprApplies: true}, // - {consentString: 'UGluZyBQb25n', gdprApplies: null}, // - {consentString: null, gdprApplies: null}, // - {consentString: undefined, gdprApplies: true}, // - {consentString: 'UGluZyBQb25n', gdprApplies: undefined}, // - {consentString: undefined, gdprApplies: undefined}]; - skippableGdprSamples.forEach((sample) => { - it(`should not add GDPR info ${JSON.stringify(sample)} when one or more values are missing`, () => { - const bidReq = buildBidderRequest(); - bidReq.gdprConsent = sample; + it(`should not add GDPR info when not provided`, () => { + const bidReq = buildBidderRequest(); - const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + delete bidReq.gdprConsent; - const actualGdpr = serverRequestInfo.data.gdpr; - assert.isUndefined(actualGdpr); - }); + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + + assert.notProperty(serverRequestInfo.data, 'gdpr'); }); it('should be able to build without third party user id data', () => { @@ -399,6 +681,169 @@ describe('stroeerCore bid adapter', function () { assert.lengthOf(serverRequestInfo.data.bids, 2); assert.notProperty(serverRequestInfo, 'uids'); }); + + it('should add schain if available', () => { + const schain = Object.freeze({ + ver: '1.0', + complete: 1, + 'nodes': [ + { + asi: 'exchange1.com', + sid: 'ABC', + hp: 1, + rid: 'bid-request-1', + name: 'publisher', + domain: 'publisher.com' + } + ] + }); + + const bidReq = buildBidderRequest(); + bidReq.bids.forEach(bid => bid.schain = schain); + + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + assert.deepEqual(serverRequestInfo.data.schain, schain); + }); + + it('should add floor info to banner bid request if floor is available', () => { + const bidReq = buildBidderRequest(); + + const getFloorStub1 = sinon.stub(); + const getFloorStub2 = sinon.stub(); + + getFloorStub1 + .returns({}) + .withArgs({currency: 'EUR', mediaType: BANNER, size: '*'}) + .returns({currency: 'TRY', floor: 0.7}) + .withArgs({currency: 'EUR', mediaType: 'banner', size: [300, 600]}) + .returns({currency: 'TRY', floor: 1.3}) + .withArgs({currency: 'EUR', mediaType: 'banner', size: [160, 60]}) + .returns({currency: 'TRY', floor: 2.5}) + + getFloorStub2 + .returns({}) + .withArgs({currency: 'EUR', mediaType: 'banner', size: '*'}) + .returns({currency: 'USD', floor: 1.2}) + .withArgs({currency: 'EUR', mediaType: 'banner', size: [728, 90]}) + .returns({currency: 'USD', floor: 1.85}) + + bidReq.bids[0].getFloor = getFloorStub1; + bidReq.bids[1].getFloor = getFloorStub2; + + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + + const serverRequestBids = serverRequestInfo.data.bids; + const firstBid = serverRequestBids[0]; + const secondBid = serverRequestBids[1]; + + assert.nestedPropertyVal(firstBid, 'ban.fp.def', 0.7); + assert.nestedPropertyVal(firstBid, 'ban.fp.cur', 'TRY'); + assert.deepNestedPropertyVal(firstBid, 'ban.fp.siz', [{w: 300, h: 600, p: 1.3}, {w: 160, h: 60, p: 2.5}]); + + assert.isTrue(getFloorStub1.calledThrice); + + assert.nestedPropertyVal(secondBid, 'ban.fp.def', 1.2); + assert.nestedPropertyVal(secondBid, 'ban.fp.cur', 'USD'); + assert.deepNestedPropertyVal(secondBid, 'ban.fp.siz', [{w: 728, h: 90, p: 1.85}]); + + assert.isTrue(getFloorStub2.calledTwice); + }); + + it('should add floor info to video bid request if floor is available', () => { + const bidReq = buildBidderRequest(); + + const getFloorStub1 = sinon.stub(); + const getFloorStub2 = sinon.stub(); + + getFloorStub1 + .returns({}) + .withArgs({currency: 'EUR', mediaType: 'video', size: '*'}) + .returns({currency: 'NZD', floor: 3.25}) + .withArgs({currency: 'EUR', mediaType: 'video', size: [640, 480]}) + .returns({currency: 'NZD', floor: 4.10}); + + getFloorStub2 + .returns({}) + .withArgs({currency: 'EUR', mediaType: 'video', size: '*'}) + .returns({currency: 'GBP', floor: 4.75}) + .withArgs({currency: 'EUR', mediaType: 'video', size: [1280, 720]}) + .returns({currency: 'GBP', floor: 6.50}) + + delete bidReq.bids[0].mediaTypes.banner; + bidReq.bids[0].mediaTypes.video = { + playerSize: [640, 480], + context: 'instream' + }; + + delete bidReq.bids[1].mediaTypes.banner; + bidReq.bids[1].mediaTypes.video = { + playerSize: [1280, 720], + context: 'outstream' + }; + + bidReq.bids[0].getFloor = getFloorStub1; + bidReq.bids[1].getFloor = getFloorStub2; + + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + + const serverRequestBids = serverRequestInfo.data.bids; + const firstBid = serverRequestBids[0]; + const secondBid = serverRequestBids[1]; + + assert.nestedPropertyVal(firstBid, 'vid.fp.def', 3.25); + assert.nestedPropertyVal(firstBid, 'vid.fp.cur', 'NZD'); + assert.deepNestedPropertyVal(firstBid, 'vid.fp.siz', [{w: 640, h: 480, p: 4.10}]); + + assert.isTrue(getFloorStub1.calledTwice); + + assert.nestedPropertyVal(secondBid, 'vid.fp.def', 4.75); + assert.nestedPropertyVal(secondBid, 'vid.fp.cur', 'GBP'); + assert.deepNestedPropertyVal(secondBid, 'vid.fp.siz', [{w: 1280, h: 720, p: 6.50}]); + + assert.isTrue(getFloorStub2.calledTwice); + }); + + it('should not add floor info to bid request if floor is unavailable', () => { + const bidReq = buildBidderRequest(); + const getFloorSpy = sinon.spy(() => ({})); + + delete bidReq.bids[0].getFloor; + bidReq.bids[1].getFloor = getFloorSpy; + + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + + const serverRequestBids = serverRequestInfo.data.bids; + const firstBid = serverRequestBids[0]; + const secondBid = serverRequestBids[1]; + + assert.nestedPropertyVal(firstBid, 'ban.fp', undefined); + assert.nestedPropertyVal(secondBid, 'ban.fp', undefined); + + assert.isTrue(getFloorSpy.calledWith({currency: 'EUR', mediaType: 'banner', size: '*'})); + assert.isTrue(getFloorSpy.calledWith({currency: 'EUR', mediaType: 'banner', size: [728, 90]})); + assert.isTrue(getFloorSpy.calledTwice); + }); + + it('should not add floor info for a size when it is the same as the default', () => { + const bidReq = buildBidderRequest(); + const getFloorStub = sinon.stub(); + + getFloorStub + .returns({currency: 'EUR', floor: 1.9}) + .withArgs({currency: 'EUR', mediaType: BANNER, size: [160, 60]}) + .returns({currency: 'EUR', floor: 2.7}); + + bidReq.bids[0].getFloor = getFloorStub; + + const serverRequestInfo = spec.buildRequests(bidReq.bids, bidReq); + + const serverRequestBids = serverRequestInfo.data.bids; + const bid = serverRequestBids[0]; + + assert.nestedPropertyVal(bid, 'ban.fp.def', 1.9); + assert.nestedPropertyVal(bid, 'ban.fp.cur', 'EUR'); + assert.deepNestedPropertyVal(bid, 'ban.fp.siz', [{w: 160, h: 60, p: 2.7}]); + }); }); }); }); @@ -421,8 +866,8 @@ describe('stroeerCore bid adapter', function () { const bidderResponse = buildBidderResponse(); const result = spec.interpretResponse({body: bidderResponse}); - assertStandardFieldsOnBid(result[0], 'bid1', '
tag1
', 300, 600, 4); - assertStandardFieldsOnBid(result[1], 'bid2', '
tag2
', 728, 90, 7.3); + assertStandardFieldsOnBannerBid(result[0], 'bid1', '
tag1
', 300, 600, 4); + assertStandardFieldsOnBannerBid(result[1], 'bid2', '
tag2
', 728, 90, 7.3); }); it('should return empty array, when response contains no bids', () => { @@ -430,6 +875,13 @@ describe('stroeerCore bid adapter', function () { assert.deepStrictEqual(result, []); }); + it('should interpret a video response', () => { + const bidderResponse = buildBidderResponseWithVideo(); + const bidResponses = spec.interpretResponse({body: bidderResponse}); + let videoBidResponse = bidResponses[0]; + assertStandardFieldsOnVideoBid(videoBidResponse, 'bid1', 'video', 800, 250, 4); + }) + it('should add data to meta object', () => { const response = buildBidderResponse(); response.bids[0] = Object.assign(response.bids[0], {adomain: ['website.org', 'domain.com']}); @@ -442,6 +894,7 @@ describe('stroeerCore bid adapter', function () { describe('get user syncs entry point', () => { let win; + beforeEach(() => { win = setupSingleWindow(sandbox); diff --git a/test/spec/modules/stvBidAdapter_spec.js b/test/spec/modules/stvBidAdapter_spec.js new file mode 100644 index 00000000000..41f29cced34 --- /dev/null +++ b/test/spec/modules/stvBidAdapter_spec.js @@ -0,0 +1,414 @@ +import { expect } from 'chai'; +import { spec } from 'modules/stvBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const ENDPOINT_URL = 'https://ads.smartstream.tv/r/'; +const ENDPOINT_URL_DEV = 'https://ads.smartstream.tv/r/'; + +describe('stvAdapter', function() { + const adapter = newBidder(spec); + + describe('isBidRequestValid', function() { + let bid = { + 'bidder': 'stv', + 'params': { + 'placement': '6682', + 'floorprice': 1000000, + 'bcat': 'IAB2,IAB4', + 'dvt': 'desktop' + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475' + }; + + it('should return true when required params found', function() { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not passed', function() { + let bid = Object.assign({}, bid); + delete bid.params; + bid.params = { + 'someIncorrectParam': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('buildRequests', function() { + let bidRequests = [ + // banner + { + 'bidder': 'stv', + 'params': { + 'placement': '6682', + 'floorprice': 1000000, + 'geo': { + 'country': 'DE' + }, + 'bcat': 'IAB2,IAB4', + 'dvt': 'desktop' + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e1', + 'bidderRequestId': '22edbae2733bf61', + 'auctionId': '1d1a030790a475', + 'adUnitCode': 'testDiv1', + 'schain': { + 'ver': '1.0', + 'complete': 0, + 'nodes': [ + { + 'asi': 'reseller.com', + 'sid': 'aaaaa', + 'rid': 'BidRequest4', + 'hp': 1 + } + ] + } + }, + { + 'bidder': 'stv', + 'params': { + 'placement': '101', + 'devMode': true + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e2', + 'bidderRequestId': '22edbae2733bf62', + 'auctionId': '1d1a030790a476' + }, { + 'bidder': 'stv', + 'params': { + 'placement': '6682', + 'floorprice': 1000000, + 'geo': { + 'country': 'DE' + }, + 'bcat': 'IAB2,IAB4', + 'dvt': 'desktop' + }, + 'sizes': [ + [300, 250] + ], + 'bidId': '30b31c1838de1e3', + 'bidderRequestId': '22edbae2733bf69', + 'auctionId': '1d1a030790a477', + 'adUnitCode': 'testDiv2' + }, + // video + { + 'bidder': 'stv', + 'params': { + 'placement': '101', + 'devMode': true, + 'max_duration': 20, + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + }, + }, + + 'bidId': '30b31c1838de1e4', + 'bidderRequestId': '22edbae2733bf67', + 'auctionId': '1d1a030790a478', + 'adUnitCode': 'testDiv3' + }, + { + 'bidder': 'stv', + 'params': { + 'placement': '101', + 'devMode': true, + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream', + 'maxduration': 40, + } + }, + 'bidId': '30b31c1838de1e41', + 'bidderRequestId': '22edbae2733bf67', + 'auctionId': '1d1a030790a478', + 'adUnitCode': 'testDiv4' + }, + { + 'bidder': 'stv', + 'params': { + 'placement': '101', + 'devMode': true, + 'max_duration': 20, + }, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream', + 'maxduration': 40, + } + }, + 'bidId': '30b31c1838de1e41', + 'bidderRequestId': '22edbae2733bf67', + 'auctionId': '1d1a030790a478', + 'adUnitCode': 'testDiv4' + } + + ]; + + // With gdprConsent + var bidderRequest = { + refererInfo: { + referer: 'some_referrer.net' + }, + gdprConsent: { + consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + vendorData: { someData: 'value' }, + gdprApplies: true + } + }; + + var request1 = spec.buildRequests([bidRequests[0]], bidderRequest)[0]; + it('sends bid request 1 to our endpoint via GET', function() { + expect(request1.method).to.equal('GET'); + expect(request1.url).to.equal(ENDPOINT_URL); + let data = request1.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=html&alternative=prebid_js&_ps=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e1&pbver=test&schain=1.0,0!reseller.com,aaaaa,1,BidRequest4,,,&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bgeo%5D%5Bcountry%5D=DE&gdpr_consent=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&gdpr=true&bcat=IAB2%2CIAB4&dvt=desktop&pbcode=testDiv1&media_types%5Bbanner%5D=300x250'); + }); + + var request2 = spec.buildRequests([bidRequests[1]], bidderRequest)[0]; + it('sends bid request 2 endpoint via GET', function() { + expect(request2.method).to.equal('GET'); + expect(request2.url).to.equal(ENDPOINT_URL); + let data = request2.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=html&alternative=prebid_js&_ps=101&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e2&pbver=test&gdpr_consent=BOJ%2FP2HOJ%2FP2HABABMAAAAAZ%2BA%3D%3D&gdpr=true&prebidDevMode=1&media_types%5Bbanner%5D=300x250'); + }); + + // Without gdprConsent + var bidderRequestWithoutGdpr = { + refererInfo: { + referer: 'some_referrer.net' + } + }; + var request3 = spec.buildRequests([bidRequests[2]], bidderRequestWithoutGdpr)[0]; + it('sends bid request 3 without gdprConsent to our endpoint via GET', function() { + expect(request3.method).to.equal('GET'); + expect(request3.url).to.equal(ENDPOINT_URL); + let data = request3.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=html&alternative=prebid_js&_ps=6682&srw=300&srh=250&idt=100&bid_id=30b31c1838de1e3&pbver=test&pfilter%5Bfloorprice%5D=1000000&pfilter%5Bgeo%5D%5Bcountry%5D=DE&bcat=IAB2%2CIAB4&dvt=desktop&pbcode=testDiv2&media_types%5Bbanner%5D=300x250'); + }); + + var request4 = spec.buildRequests([bidRequests[3]], bidderRequestWithoutGdpr)[0]; + it('sends bid request 4 (video) without gdprConsent endpoint via GET', function() { + expect(request4.method).to.equal('GET'); + expect(request4.url).to.equal(ENDPOINT_URL); + let data = request4.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=vast2&alternative=prebid_js&_ps=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e4&pbver=test&pfilter%5Bmax_duration%5D=20&prebidDevMode=1&pbcode=testDiv3&media_types%5Bvideo%5D=640x480'); + }); + + var request5 = spec.buildRequests([bidRequests[4]], bidderRequestWithoutGdpr)[0]; + it('sends bid request 5 (video) to our endpoint via GET', function() { + expect(request5.method).to.equal('GET'); + expect(request5.url).to.equal(ENDPOINT_URL); + let data = request5.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=vast2&alternative=prebid_js&_ps=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e41&pbver=test&pfilter%5Bmax_duration%5D=40&prebidDevMode=1&pbcode=testDiv4&media_types%5Bvideo%5D=640x480'); + }); + + var request6 = spec.buildRequests([bidRequests[5]], bidderRequestWithoutGdpr)[0]; + it('sends bid request 6 (video) to our endpoint via GET', function() { + expect(request6.method).to.equal('GET'); + expect(request6.url).to.equal(ENDPOINT_URL); + let data = request6.data.replace(/rnd=\d+\&/g, '').replace(/ref=.*\&bid/g, 'bid').replace(/pbver=.*?&/g, 'pbver=test&'); + expect(data).to.equal('_f=vast2&alternative=prebid_js&_ps=101&srw=640&srh=480&idt=100&bid_id=30b31c1838de1e41&pbver=test&pfilter%5Bmax_duration%5D=20&prebidDevMode=1&pbcode=testDiv4&media_types%5Bvideo%5D=640x480'); + }); + }); + + describe('interpretResponse', function() { + let serverResponse = { + 'body': { + 'cpm': 5000000, + 'crid': 100500, + 'width': '300', + 'height': '250', + 'type': 'sspHTML', + 'tag': '', + 'requestId': '220ed41385952a', + 'currency': 'EUR', + 'ttl': 60, + 'netRevenue': true, + 'zone': '6682', + 'adomain': ['bdomain'] + } + }; + let serverVideoResponse = { + 'body': { + 'cpm': 5000000, + 'crid': 100500, + 'width': '300', + 'height': '250', + 'vastXml': '{"reason":7001,"status":"accepted"}', + 'requestId': '220ed41385952a', + 'type': 'vast2', + 'currency': 'EUR', + 'ttl': 60, + 'netRevenue': true, + 'zone': '6682' + } + }; + + let expectedResponse = [{ + requestId: '23beaa6af6cdde', + cpm: 0.5, + width: 0, + height: 0, + creativeId: 100500, + dealId: '', + currency: 'EUR', + netRevenue: true, + ttl: 300, + meta: { advertiserDomains: ['bdomain'] }, + ad: '', + }, { + requestId: '23beaa6af6cdde', + cpm: 0.5, + width: 0, + height: 0, + creativeId: 100500, + dealId: '', + currency: 'EUR', + netRevenue: true, + ttl: 300, + meta: { advertiserDomains: [] }, + vastXml: '{"reason":7001,"status":"accepted"}', + mediaType: 'video', + }]; + + it('should get the correct bid response by display ad', function() { + let bidRequest = [{ + 'method': 'GET', + 'url': ENDPOINT_URL, + 'data': { + 'bid_id': '30b31c1838de1e' + } + }]; + let result = spec.interpretResponse(serverResponse, bidRequest[0]); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); + expect(result[0].meta.advertiserDomains.length).to.equal(1); + expect(result[0].meta.advertiserDomains[0]).to.equal(expectedResponse[0].meta.advertiserDomains[0]); + }); + + it('should get the correct smartstream video bid response by display ad', function() { + let bidRequest = [{ + 'method': 'GET', + 'url': ENDPOINT_URL, + 'mediaTypes': { + 'video': { + 'playerSize': [640, 480], + 'context': 'instream' + } + }, + 'data': { + 'bid_id': '30b31c1838de1e' + } + }]; + let result = spec.interpretResponse(serverVideoResponse, bidRequest[0]); + expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[1])); + expect(result[0].meta.advertiserDomains.length).to.equal(0); + }); + + it('handles empty bid response', function() { + let response = { + body: {} + }; + let result = spec.interpretResponse(response); + expect(result.length).to.equal(0); + }); + }); + + describe(`getUserSyncs test usage`, function() { + let serverResponses; + + beforeEach(function() { + serverResponses = [{ + body: { + requestId: '23beaa6af6cdde', + cpm: 0.5, + width: 0, + height: 0, + creativeId: 100500, + dealId: '', + currency: 'EUR', + netRevenue: true, + ttl: 300, + type: 'sspHTML', + ad: '', + userSync: { + iframeUrl: ['anyIframeUrl?a=1'], + imageUrl: ['anyImageUrl', 'anyImageUrl2'] + } + } + }]; + }); + + it(`return value should be an array`, function() { + expect(spec.getUserSyncs({ iframeEnabled: true })).to.be.an('array'); + }); + it(`array should have only one object and it should have a property type = 'iframe'`, function() { + expect(spec.getUserSyncs({ iframeEnabled: true }, serverResponses).length).to.be.equal(1); + let [userSync] = spec.getUserSyncs({ iframeEnabled: true }, serverResponses); + expect(userSync).to.have.property('type'); + expect(userSync.type).to.be.equal('iframe'); + }); + it(`we have valid sync url for iframe`, function() { + let [userSync] = spec.getUserSyncs({ iframeEnabled: true }, serverResponses, { consentString: 'anyString' }); + expect(userSync.url).to.be.equal('anyIframeUrl?a=1&gdpr_consent=anyString') + expect(userSync.type).to.be.equal('iframe'); + }); + it(`we have valid sync url for image`, function() { + let [userSync] = spec.getUserSyncs({ pixelEnabled: true }, serverResponses, { gdprApplies: true, consentString: 'anyString' }); + expect(userSync.url).to.be.equal('anyImageUrl?gdpr=1&gdpr_consent=anyString') + expect(userSync.type).to.be.equal('image'); + }); + it(`we have valid sync url for image and iframe`, function() { + let userSync = spec.getUserSyncs({ iframeEnabled: true, pixelEnabled: true }, serverResponses, { gdprApplies: true, consentString: 'anyString' }); + expect(userSync.length).to.be.equal(3); + expect(userSync[0].url).to.be.equal('anyIframeUrl?a=1&gdpr=1&gdpr_consent=anyString') + expect(userSync[0].type).to.be.equal('iframe'); + expect(userSync[1].url).to.be.equal('anyImageUrl?gdpr=1&gdpr_consent=anyString') + expect(userSync[1].type).to.be.equal('image'); + expect(userSync[2].url).to.be.equal('anyImageUrl2?gdpr=1&gdpr_consent=anyString') + expect(userSync[2].type).to.be.equal('image'); + }); + }); + + describe(`getUserSyncs test usage in passback response`, function() { + let serverResponses; + + beforeEach(function() { + serverResponses = [{ + body: { + reason: 8002, + status: 'error', + msg: 'passback', + } + }]; + }); + + it(`check for zero array when iframeEnabled`, function() { + expect(spec.getUserSyncs({ iframeEnabled: true })).to.be.an('array'); + expect(spec.getUserSyncs({ iframeEnabled: true }, serverResponses).length).to.be.equal(0); + }); + it(`check for zero array when iframeEnabled`, function() { + expect(spec.getUserSyncs({ pixelEnabled: true })).to.be.an('array'); + expect(spec.getUserSyncs({ pixelEnabled: true }, serverResponses).length).to.be.equal(0); + }); + }); +}); diff --git a/test/spec/modules/taboolaBidAdapter_spec.js b/test/spec/modules/taboolaBidAdapter_spec.js new file mode 100644 index 00000000000..16bbb525ee7 --- /dev/null +++ b/test/spec/modules/taboolaBidAdapter_spec.js @@ -0,0 +1,839 @@ +import {expect} from 'chai'; +import {spec, internal, END_POINT_URL, userData} from 'modules/taboolaBidAdapter.js'; +import {config} from '../../../src/config' +import * as utils from '../../../src/utils' +import {server} from '../../mocks/xhr' + +describe('Taboola Adapter', function () { + let sandbox, hasLocalStorage, cookiesAreEnabled, getDataFromLocalStorage, localStorageIsEnabled, getCookie, commonBidRequest; + + beforeEach(() => { + sandbox = sinon.sandbox.create(); + hasLocalStorage = sandbox.stub(userData.storageManager, 'hasLocalStorage'); + cookiesAreEnabled = sandbox.stub(userData.storageManager, 'cookiesAreEnabled'); + getCookie = sandbox.stub(userData.storageManager, 'getCookie'); + getDataFromLocalStorage = sandbox.stub(userData.storageManager, 'getDataFromLocalStorage'); + localStorageIsEnabled = sandbox.stub(userData.storageManager, 'localStorageIsEnabled'); + commonBidRequest = createBidRequest(); + $$PREBID_GLOBAL$$.bidderSettings = { + taboola: { + storageAllowed: true + } + }; + }); + + afterEach(() => { + sandbox.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; + }) + + const displayBidRequestParams = { + sizes: [[300, 250], [300, 600]] + } + + const createBidRequest = () => ({ + bidder: 'taboola', + params: { + publisherId: 'publisherId', + tagId: 'placement name' + }, + bidId: utils.generateUUID(), + auctionId: utils.generateUUID(), + }); + + describe('isBidRequestValid', function () { + it('should fail when bid is invalid - tagId isn`t defined', function () { + const bid = { + bidder: 'taboola', + params: { + publisherId: 'publisherId' + }, + ...displayBidRequestParams + } + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) + + it('should fail when bid is invalid - publisherId isn`t defined', function () { + const bid = { + bidder: 'taboola', + params: { + tagId: 'below the article' + }, + ...displayBidRequestParams + } + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) + + it('should fail when bid is invalid - sizes isn`t defined', function () { + const bid = { + bidder: 'taboola', + params: { + publisherId: 'publisherId', + tagId: 'below the article' + }, + } + expect(spec.isBidRequestValid(bid)).to.equal(false) + }) + + it('should succeed when bid contains valid', function () { + const bid = { + bidder: 'taboola', + params: { + publisherId: 'publisherId', + tagId: 'below the article' + }, + ...displayBidRequestParams, + } + expect(spec.isBidRequestValid(bid)).to.equal(true) + }) + }) + + describe('onBidWon', function () { + it('onBidWon exist as a function', () => { + expect(spec.onBidWon).to.exist.and.to.be.a('function'); + }); + + it('should resolve price macro in nurl', function () { + const nurl = 'http://win.example.com/${AUCTION_PRICE}'; + const bid = { + requestId: 1, + cpm: 2, + originalCpm: 3.4, + creativeId: 1, + ttl: 60, + netRevenue: true, + mediaType: 'banner', + ad: '...', + width: 300, + height: 250, + nurl: nurl + } + spec.onBidWon(bid); + expect(server.requests[0].url).to.equals('http://win.example.com/3.4') + }); + }); + + describe('buildRequests', function () { + const defaultBidRequest = { + ...createBidRequest(), + ...displayBidRequestParams, + } + + const commonBidderRequest = { + bidderRequestId: 'mock-uuid', + refererInfo: { + page: 'https://example.com/ref', + ref: 'https://ref', + domain: 'example.com', + } + } + + it('should build display request', function () { + const expectedData = { + id: 'mock-uuid', + 'imp': [{ + 'id': 1, + 'banner': { + format: [{ + w: displayBidRequestParams.sizes[0][0], + h: displayBidRequestParams.sizes[0][1] + }, + { + w: displayBidRequestParams.sizes[1][0], + h: displayBidRequestParams.sizes[1][1] + } + ] + }, + 'tagid': commonBidRequest.params.tagId, + 'bidfloor': null, + 'bidfloorcur': 'USD', + 'ext': {} + }], + 'site': { + 'id': commonBidRequest.params.publisherId, + 'name': commonBidRequest.params.publisherId, + 'domain': commonBidderRequest.refererInfo.domain, + 'page': commonBidderRequest.refererInfo.page, + 'ref': commonBidderRequest.refererInfo.ref, + 'publisher': {'id': commonBidRequest.params.publisherId}, + 'content': {'language': navigator.language} + }, + 'device': {'ua': navigator.userAgent}, + 'source': {'fd': 1}, + 'bcat': [], + 'badv': [], + 'wlang': [], + 'user': { + 'buyeruid': 0, + 'ext': {}, + }, + 'regs': {'coppa': 0, 'ext': {}}, + 'ext': {} + }; + + const res = spec.buildRequests([defaultBidRequest], commonBidderRequest); + + expect(res.url).to.equal(`${END_POINT_URL}?publisher=${commonBidRequest.params.publisherId}`); + expect(res.data).to.deep.equal(JSON.stringify(expectedData)); + }); + + it('should pass optional parameters in request', function () { + const optionalParams = { + bidfloor: 0.25, + bidfloorcur: 'EUR' + }; + + const bidRequest = { + ...defaultBidRequest, + params: {...commonBidRequest.params, ...optionalParams} + }; + + const res = spec.buildRequests([bidRequest], commonBidderRequest); + const resData = JSON.parse(res.data); + expect(resData.imp[0].bidfloor).to.deep.equal(0.25); + expect(resData.imp[0].bidfloorcur).to.deep.equal('EUR'); + }); + + it('should pass bid floor', function () { + const bidRequest = { + ...defaultBidRequest, + params: {...commonBidRequest.params}, + getFloor: function() { + return { + currency: 'USD', + floor: 2.7, + } + } + }; + const res = spec.buildRequests([bidRequest], commonBidderRequest); + const resData = JSON.parse(res.data); + expect(resData.imp[0].bidfloor).to.deep.equal(2.7); + expect(resData.imp[0].bidfloorcur).to.deep.equal('USD'); + }); + + it('should pass bid floor even if it is a bid floor param', function () { + const optionalParams = { + bidfloor: 0.25, + bidfloorcur: 'EUR' + }; + + const bidRequest = { + ...defaultBidRequest, + params: {...commonBidRequest.params, ...optionalParams}, + getFloor: function() { + return { + currency: 'USD', + floor: 2.7, + } + } + }; + const res = spec.buildRequests([bidRequest], commonBidderRequest); + const resData = JSON.parse(res.data); + expect(resData.imp[0].bidfloor).to.deep.equal(2.7); + expect(resData.imp[0].bidfloorcur).to.deep.equal('USD'); + }); + + it('should pass impression position', function () { + const optionalParams = { + position: 2 + }; + + const bidRequest = { + ...defaultBidRequest, + params: {...commonBidRequest.params, ...optionalParams} + }; + + const res = spec.buildRequests([bidRequest], commonBidderRequest); + const resData = JSON.parse(res.data); + expect(resData.imp[0].banner.pos).to.deep.equal(2); + }); + + it('should pass gpid if configured', function () { + const ortb2Imp = { + ext: { + gpid: '/homepage/#1' + } + } + const bidRequest = { + ...defaultBidRequest, + ortb2Imp: ortb2Imp, + params: {...commonBidRequest.params} + }; + + const res = spec.buildRequests([bidRequest], commonBidderRequest); + const resData = JSON.parse(res.data); + expect(resData.imp[0].ext.gpid).to.deep.equal('/homepage/#1'); + }); + + it('should pass bidder timeout', function () { + const bidderRequest = { + ...commonBidderRequest, + timeout: 500 + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.tmax).to.equal(500); + }); + + describe('first party data', function () { + it('should parse first party data', function () { + const bidderRequest = { + ...commonBidderRequest, + ortb2: { + bcat: ['EX1', 'EX2', 'EX3'], + badv: ['site.com'], + wlang: ['de'], + } + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.bcat).to.deep.equal(bidderRequest.ortb2.bcat) + expect(resData.badv).to.deep.equal(bidderRequest.ortb2.badv) + expect(resData.wlang).to.deep.equal(bidderRequest.ortb2.wlang) + }); + + it('should pass pageType if exists in ortb2', function () { + const bidderRequest = { + ...commonBidderRequest, + ortb2: { + ext: { + data: { + pageType: 'news' + } + } + } + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.ext.pageType).to.deep.equal(bidderRequest.ortb2.ext.data.pageType); + }); + }); + + describe('handle privacy segments when building request', function () { + it('should pass GDPR consent', function () { + const bidderRequest = { + refererInfo: { + referer: 'https://example.com/' + }, + gdprConsent: { + gdprApplies: true, + consentString: 'consentString', + } + }; + + const res = spec.buildRequests([defaultBidRequest], bidderRequest) + const resData = JSON.parse(res.data) + expect(resData.user.ext.consent).to.equal('consentString') + expect(resData.regs.ext.gdpr).to.equal(1) + }); + + it('should pass GPP consent if exist in ortb2', function () { + const ortb2 = { + regs: { + gpp: 'testGpp', + gpp_sid: [1, 2, 3] + } + } + + const res = spec.buildRequests([defaultBidRequest], {...commonBidderRequest, ortb2}) + const resData = JSON.parse(res.data) + expect(resData.regs.ext.gpp).to.equal('testGpp') + expect(resData.regs.ext.gpp_sid).to.deep.equal([1, 2, 3]) + }); + + it('should pass us privacy consent', function () { + const bidderRequest = { + refererInfo: { + referer: 'https://example.com/' + }, + uspConsent: 'consentString' + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.regs.ext.us_privacy).to.equal('consentString'); + }); + + it('should pass coppa consent', function () { + config.setConfig({coppa: true}) + + const res = spec.buildRequests([defaultBidRequest], commonBidderRequest) + const resData = JSON.parse(res.data); + expect(resData.regs.coppa).to.equal(1) + + config.resetConfig() + }); + }) + + describe('handle userid ', function () { + it('should get user id from local storage', function () { + getDataFromLocalStorage.returns(51525152); + hasLocalStorage.returns(true); + localStorageIsEnabled.returns(true); + + const bidderRequest = { + ...commonBidderRequest, + timeout: 500 + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.user.buyeruid).to.equal(51525152); + }); + + it('should get user id from cookie if local storage isn`t defined', function () { + getDataFromLocalStorage.returns(51525152); + hasLocalStorage.returns(false); + localStorageIsEnabled.returns(false); + cookiesAreEnabled.returns(true); + getCookie.returns('taboola%20global%3Auser-id=12121212'); + + const bidderRequest = { + ...commonBidderRequest + }; + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + + expect(resData.user.buyeruid).to.equal('12121212'); + }); + + it('should get user id from TRC if local storage and cookie isn`t defined', function () { + hasLocalStorage.returns(false); + cookiesAreEnabled.returns(false); + localStorageIsEnabled.returns(false); + + window.TRC = { + user_id: 31313132 + }; + + const bidderRequest = { + ...commonBidderRequest + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.user.buyeruid).to.equal(window.TRC.user_id); + + delete window.TRC; + }); + + it('should get user id to be 0 if cookie, local storage, TRC isn`t defined', function () { + hasLocalStorage.returns(false); + cookiesAreEnabled.returns(false); + + const bidderRequest = { + ...commonBidderRequest + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.user.buyeruid).to.equal(0); + }); + + it('should set buyeruid to be 0 if it`s a new user', function () { + const bidderRequest = { + ...commonBidderRequest + } + const res = spec.buildRequests([defaultBidRequest], bidderRequest); + const resData = JSON.parse(res.data); + expect(resData.user.buyeruid).to.equal(0); + }); + }); + }) + + describe('interpretResponse', function () { + const serverResponse = { + body: { + 'id': '49ffg4d58ef9a163a69fhgfghd4fad03621b9e036f24f7_15', + 'seatbid': [ + { + 'bid': [ + { + 'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c', + 'impid': '1', + 'price': 0.342068, + 'adid': '2785119545551083381', + 'adm': '\u003chtml\u003e\n\u003chead\u003e\n\u003cmeta charset\u003d"UTF-8"\u003e\n\u003cmeta http-equiv\u003d"Content-Type" content\u003d"text/html; charset\u003dutf-8"/\u003e\u003c/head\u003e\n\u003cbody style\u003d"margin: 0px; overflow:hidden;"\u003e \n\u003cscript type\u003d"text/javascript"\u003e\nwindow.tbl_trc_domain \u003d \u0027us-trc.taboola.com\u0027;\nwindow._taboola \u003d window._taboola || [];\n_taboola.push({article:\u0027auto\u0027});\n!function (e, f, u, i) {\nif (!document.getElementById(i)){\ne.async \u003d 1;\ne.src \u003d u;\ne.id \u003d i;\nf.parentNode.insertBefore(e, f);\n}\n}(document.createElement(\u0027script\u0027),\ndocument.getElementsByTagName(\u0027script\u0027)[0],\n\u0027//cdn.taboola.com/libtrc/wattpad-placement-255/loader.js\u0027,\n\u0027tb_loader_script\u0027);\nif(window.performance \u0026\u0026 typeof window.performance.mark \u003d\u003d \u0027function\u0027)\n{window.performance.mark(\u0027tbl_ic\u0027);}\n\u003c/script\u003e\n\n\u003cdiv id\u003d"taboola-below-article-thumbnails" style\u003d"height: 250px; width: 300px;"\u003e\u003c/div\u003e\n\u003cscript type\u003d"text/javascript"\u003e\nwindow._taboola \u003d window._taboola || [];\n_taboola.push({\nmode: \u0027Rbox_300x250_1x1\u0027,\ncontainer: \u0027taboola-below-article-thumbnails\u0027,\nplacement: \u0027wattpad.com_P18694_S257846_W300_H250_N1_TB\u0027,\ntarget_type: \u0027mix\u0027,\n"rtb-win":{ \nbi:\u002749ff4d58ef9a163a696d4fad03621b9e036f24f7_15\u0027,\ncu:\u0027USD\u0027,\nwp:\u0027${AUCTION_PRICE:BF}\u0027,\nwcb:\u0027~!audex-display-impression!~\u0027,\nrt:\u00271643227025284\u0027,\nrdc:\u0027us.taboolasyndication.com\u0027,\nti:\u00274212\u0027,\nex:\u0027MagniteSCoD\u0027,\nbs:\u0027xapi:257846:lvvSm6Ak7_wE\u0027,\nbp:\u002718694\u0027,\nbd:\u0027wattpad.com\u0027,\nsi:\u00279964\u0027\n} \n,\nrec: {"trc":{"si":"a69c7df43b2334f0aa337c37e2d80c21","sd":"v2_a69c7df43b2334f0aa337c37e2d80c21_3c70f7c7d64a65b15e4a4175c9a2cfa51072f04bMagniteSCoD_1643227025_1643227025_CJS1tQEQ5NdWGPLA0d76xo-9ngEgASgEMCY4iegHQIroB0iB09kDUKPPB1gAYABop-G2i_Hl-eVucAA","ui":"3c70f7c7d64a65b15e4a4175c9a2cfa51072f04bMagniteSCoD","plc":"PHON","wi":"-643136642229425433","cc":"CA","route":"US:US:V","el2r":["bulk-metrics","debug","social","metrics","perf"],"uvpw":"1","pi":"1420260","cpb":"GNO629MGIJz__________wEqGXVzLnRhYm9vbGFzeW5kaWNhdGlvbi5jb20yC3RyYy1zY29kMTI5OIDwmrUMQInoB0iK6AdQgdPZA1ijzwdjCN3__________wEQ3f__________ARgjZGMI3AoQoBAYFmRjCNIDEOAGGAhkYwiWFBCcHBgYZGMI9AUQiwoYC2RjCNkUEPkcGB1kYwj0FBCeHRgfZGorNDlmZjRkNThlZjlhMTYzYTY5NmQ0ZmFkMDM2MjFiOWUwMzZmMjRmN18xNXgCgAHpbIgBrPvTxQE","dcga":{"pubConfigOverride":{"border-color":"black","font-weight":"bold","inherit-title-color":"true","module-name":"cta-lazy-module","enable-call-to-action-creative-component":"true","disable-cta-on-custom-module":"true"}},"tslt":{"p-video-overlay":{"cancel":"סגור","goto":"עבור לדף"},"read-more":{"DEFAULT_CAPTION":"%D7%A7%D7%A8%D7%90%20%D7%A2%D7%95%D7%93"},"next-up":{"BTN_TEXT":"לקריאת התוכן הבא"},"time-ago":{"now":"עכשיו","today":"היום","yesterday":"אתמול","minutes":"לפני {0} דקות","hour":"לפני שעה","hours":"לפני {0} שעות","days":"לפני {0} ימים"},"explore-more":{"TITLE_TEXT":"המשיכו לקרוא","POPUP_TEXT":"אל תפספסו הזדמנות לקרוא עוד תוכן מעולה, רגע לפני שתעזבו"}},"evh":"-1964913910","vl":[{"ri":"185db6d274ce94b27caaabd9eed7915b","uip":"wattpad.com_P18694_S257846_W300_H250_N1_TB","ppb":"COIF","estimation_method":"EcpmEstimationMethodType_ESTIMATION","baseline_variant":"false","original_ecpm":"0.4750949889421463","v":[{"thumbnail":"https://cdn.taboola.com/libtrc/static/thumbnails/a2b272be514ca3ebe3f97a4a32a41db5.jpg","all-thumbnails":"https://cdn.taboola.com/libtrc/static/thumbnails/a2b272be514ca3ebe3f97a4a32a41db5.jpg!-#@1600x1000","origin":"default","thumb-size":"1600x1000","title":"Get Roofing Services At Prices You Can Afford In Edmonton","type":"text","published-date":"1641997069","branding-text":"Roofing Services | Search Ads","url":"https://inneth-conded.xyz/9ad2e613-8777-4fe7-9a52-386c88879289?site\u003dwattpad-placement-255\u0026site_id\u003d1420260\u0026title\u003dGet+Roofing+Services+At+Prices+You+Can+Afford+In+Edmonton\u0026platform\u003dSmartphone\u0026campaign_id\u003d15573949\u0026campaign_item_id\u003d3108610633\u0026thumbnail\u003dhttp%3A%2F%2Fcdn.taboola.com%2Flibtrc%2Fstatic%2Fthumbnails%2Fa2b272be514ca3ebe3f97a4a32a41db5.jpg\u0026cpc\u003d{cpc}\u0026click_id\u003dGiCIypnAQogsMTFL3e_mPaVM2qLvK3KRU6LWzEMUgeB6piCit1Uox6CNr5v5n-x1\u0026tblci\u003dGiCIypnAQogsMTFL3e_mPaVM2qLvK3KRU6LWzEMUgeB6piCit1Uox6CNr5v5n-x1#tblciGiCIypnAQogsMTFL3e_mPaVM2qLvK3KRU6LWzEMUgeB6piCit1Uox6CNr5v5n-x1","duration":"0","sig":"328243c4127ff16e3fdcd7270bab908f6f3fc5b4c98d","item-id":"~~V1~~2785119550041083381~~PnBkfBE9JnQxpahv0adkcuIcmMhroRAHXwLZd-7zhunTxvAnL2wqac4MyzR7uD46gj3kUkbS3FhelBtnsiJV6MhkDZRZzzIqDobN6rWmCPA3hYz5D3PLat6nhIftiT1lwdxwdlxkeV_Mfb3eos_TQavImGhxk0e7psNAZxHJ9RKL2w3lppALGgQJoy2o6lkf-pOqODtX1VkgWpEEM4WsVoWOnUTAwdyGd-8yrze8CWNp752y28hl7lleicyO1vByRdbgwlJdnqyroTPEQNNEn1JRxBOSYSWt-Xm3vkPm-G4","uploader":"","is-syndicated":"true","publisher":"search","id":"~~V1~~2785119550041083381~~PnBkfBE9JnQxpahv0adkcuIcmMhroRAHXwLZd-7zhunTxvAnL2wqac4MyzR7uD46gj3kUkbS3FhelBtnsiJV6MhkDZRZzzIqDobN6rWmCPA3hYz5D3PLat6nhIftiT1lwdxwdlxkeV_Mfb3eos_TQavImGhxk0e7psNAZxHJ9RKL2w3lppALGgQJoy2o6lkf-pOqODtX1VkgWpEEM4WsVoWOnUTAwdyGd-8yrze8CWNp752y28hl7lleicyO1vByRdbgwlJdnqyroTPEQNNEn1JRxBOSYSWt-Xm3vkPm-G4","category":"home","views":"0","itp":[{"u":"https://trc.taboola.com/1326786/log/3/unip?en\u003dclickersusa","t":"c"}],"description":""}]}],"cpcud":{"upc":"0.0","upr":"0.0"}}}\n});\n\u003c/script\u003e\n\n\u003cscript type\u003d"text/javascript"\u003e\nwindow._taboola \u003d window._taboola || [];\n_taboola.push({flush: true});\n\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e', + 'adomain': [ + 'example.xyz' + ], + 'cid': '15744349', + 'crid': '278195503434041083381', + 'w': 300, + 'h': 250, + 'exp': 60, + 'lurl': 'http://us-trc.taboola.com/sample', + 'nurl': 'http://win.example.com/', + + } + ], + 'seat': '14204545260' + } + ], + 'bidid': 'da43860a-4644-442a-b5e0-93f268cf8d19', + 'cur': 'USD' + } + }; + + const request = { + bids: [ + { + ...commonBidRequest, + ...displayBidRequestParams + } + ] + } + + it('should return empty array if no valid bids', function () { + const res = spec.interpretResponse(serverResponse, []) + expect(res).to.be.an('array').that.is.empty + }); + + it('should return empty array if no server response', function () { + const res = spec.interpretResponse({}, request) + expect(res).to.be.an('array').that.is.empty + }); + + it('should return empty array if server response without seatbid', function () { + const overriddenServerResponse = {...serverResponse}; + const seatbid = {...serverResponse.body.seatbid[0]}; + overriddenServerResponse.body.seatbid[0] = {}; + + const res = spec.interpretResponse(overriddenServerResponse, request) + expect(res).to.be.an('array').that.is.empty + + overriddenServerResponse.body.seatbid[0] = seatbid; + }); + + it('should return empty array if server response without bids', function () { + const overriddenServerResponse = {...serverResponse}; + const bid = [...serverResponse.body.seatbid[0].bid]; + overriddenServerResponse.body.seatbid[0].bid = {}; + + const res = spec.interpretResponse(overriddenServerResponse, request) + expect(res).to.be.an('array').that.is.empty + + overriddenServerResponse.body.seatbid[0].bid = bid; + }); + + it('should interpret multi impression request', function () { + const multiRequest = { + bids: [ + { + ...createBidRequest(), + ...displayBidRequestParams + }, + { + ...createBidRequest(), + ...displayBidRequestParams + } + ] + } + + const multiServerResponse = { + body: { + 'id': '49ffg4d58ef9a163a69fhgfghd4fad03621b9e036f24f7_15', + 'seatbid': [ + { + 'bid': [ + { + 'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c', + 'impid': '2', + 'price': 0.342068, + 'adid': '2785119545551083381', + 'adm': 'ADM2', + 'adomain': [ + 'example.xyz' + ], + 'cid': '15744349', + 'crid': '278195503434041083381', + 'w': 300, + 'h': 250, + 'exp': 60, + 'lurl': 'http://us-trc.taboola.com/sample', + 'nurl': 'http://win.example.com/' + }, + { + 'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c', + 'impid': '1', + 'price': 0.342068, + 'adid': '2785119545551083381', + 'adm': 'ADM1', + 'adomain': [ + 'example.xyz' + ], + 'cid': '15744349', + 'crid': '278195503434041083381', + 'w': 300, + 'h': 250, + 'exp': 60, + 'lurl': 'http://us-trc.taboola.com/sample', + 'nurl': 'http://win.example.com/' + + } + ], + 'seat': '14204545260' + } + ], + 'bidid': 'da43860a-4644-442a-b5e0-93f268cf8d19', + 'cur': 'USD' + } + }; + + const [bid] = multiServerResponse.body.seatbid[0].bid; + const expectedRes = [ + { + requestId: multiRequest.bids[1].bidId, + cpm: bid.price, + creativeId: bid.crid, + ttl: 60, + netRevenue: true, + currency: multiServerResponse.body.cur, + mediaType: 'banner', + ad: multiServerResponse.body.seatbid[0].bid[0].adm, + width: bid.w, + height: bid.h, + nurl: 'http://win.example.com/', + meta: { + 'advertiserDomains': bid.adomain + }, + }, + { + requestId: multiRequest.bids[0].bidId, + cpm: bid.price, + creativeId: bid.crid, + ttl: 60, + netRevenue: true, + currency: multiServerResponse.body.cur, + mediaType: 'banner', + ad: multiServerResponse.body.seatbid[0].bid[1].adm, + width: bid.w, + height: bid.h, + nurl: 'http://win.example.com/', + meta: { + 'advertiserDomains': bid.adomain + }, + } + ] + + const res = spec.interpretResponse(multiServerResponse, multiRequest) + expect(res).to.deep.equal(expectedRes) + }); + + it('should interpret display response', function () { + const [bid] = serverResponse.body.seatbid[0].bid; + const expectedRes = [ + { + requestId: request.bids[0].bidId, + cpm: bid.price, + creativeId: bid.crid, + ttl: 60, + netRevenue: true, + currency: serverResponse.body.cur, + mediaType: 'banner', + ad: bid.adm, + width: bid.w, + height: bid.h, + nurl: 'http://win.example.com/', + meta: { + 'advertiserDomains': bid.adomain + }, + } + ] + + const res = spec.interpretResponse(serverResponse, request) + expect(res).to.deep.equal(expectedRes) + }); + + it('should set the correct ttl form the response', function () { + // set exp-ttl to be 125 + const [bid] = serverResponse.body.seatbid[0].bid; + serverResponse.body.seatbid[0].bid[0].exp = 125; + const expectedRes = [ + { + requestId: request.bids[0].bidId, + cpm: bid.price, + creativeId: bid.crid, + ttl: 125, + netRevenue: true, + currency: serverResponse.body.cur, + mediaType: 'banner', + ad: bid.adm, + width: bid.w, + height: bid.h, + nurl: 'http://win.example.com/', + meta: { + 'advertiserDomains': bid.adomain + }, + } + ]; + const res = spec.interpretResponse(serverResponse, request); + expect(res).to.deep.equal(expectedRes); + }); + + it('should replace AUCTION_PRICE macro in adm', function () { + const multiRequest = { + bids: [ + { + ...createBidRequest(), + ...displayBidRequestParams + }, + { + ...createBidRequest(), + ...displayBidRequestParams + } + ] + } + const multiServerResponseWithMacro = { + body: { + 'id': '49ffg4d58ef9a163a69fhgfghd4fad03621b9e036f24f7_15', + 'seatbid': [ + { + 'bid': [ + { + 'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c', + 'impid': '2', + 'price': 0.34, + 'adid': '2785119545551083381', + 'adm': 'ADM2,\\nwp:\'${AUCTION_PRICE}\'', + 'adomain': [ + 'example.xyz' + ], + 'cid': '15744349', + 'crid': '278195503434041083381', + 'w': 300, + 'h': 250, + 'exp': 60, + 'lurl': 'http://us-trc.taboola.com/sample', + 'nurl': 'http://win.example.com/' + }, + { + 'id': '0b3dd94348-134b-435f-8db5-6bf5afgfc39e86c', + 'impid': '1', + 'price': 0.35, + 'adid': '2785119545551083381', + 'adm': 'ADM2,\\nwp:\'${AUCTION_PRICE}\'', + 'adomain': [ + 'example.xyz' + ], + 'cid': '15744349', + 'crid': '278195503434041083381', + 'w': 300, + 'h': 250, + 'exp': 60, + 'lurl': 'http://us-trc.taboola.com/sample', + 'nurl': 'http://win.example.com/' + + } + ], + 'seat': '14204545260' + } + ], + 'bidid': 'da43860a-4644-442a-b5e0-93f268cf8d19', + 'cur': 'USD' + } + }; + const [bid] = multiServerResponseWithMacro.body.seatbid[0].bid; + const expectedRes = [ + { + requestId: multiRequest.bids[1].bidId, + cpm: multiServerResponseWithMacro.body.seatbid[0].bid[0].price, + creativeId: bid.crid, + ttl: 60, + netRevenue: true, + currency: multiServerResponseWithMacro.body.cur, + mediaType: 'banner', + ad: 'ADM2,\\nwp:\'0.34\'', + width: bid.w, + height: bid.h, + nurl: 'http://win.example.com/', + meta: { + 'advertiserDomains': bid.adomain + }, + }, + { + requestId: multiRequest.bids[0].bidId, + cpm: multiServerResponseWithMacro.body.seatbid[0].bid[1].price, + creativeId: bid.crid, + ttl: 60, + netRevenue: true, + currency: multiServerResponseWithMacro.body.cur, + mediaType: 'banner', + ad: 'ADM2,\\nwp:\'0.35\'', + width: bid.w, + height: bid.h, + nurl: 'http://win.example.com/', + meta: { + 'advertiserDomains': bid.adomain + }, + } + ]; + const res = spec.interpretResponse(multiServerResponseWithMacro, multiRequest); + expect(res).to.deep.equal(expectedRes); + }); + }) + + describe('getUserSyncs', function () { + const usersyncUrl = 'https://trc.taboola.com/sg/prebidJS/1/cm'; + + it('should not return user sync if pixelEnabled is false', function () { + const res = spec.getUserSyncs({pixelEnabled: false}); + expect(res).to.be.an('array').that.is.empty; + }); + + it('should return user sync if pixelEnabled is true', function () { + const res = spec.getUserSyncs({pixelEnabled: true}); + expect(res).to.deep.equal([{type: 'image', url: usersyncUrl}]); + }); + + it('should pass consent tokens values', function() { + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: true, consentString: 'GDPR_CONSENT'}, 'USP_CONSENT')).to.deep.equal([{ + type: 'image', url: `${usersyncUrl}?gdpr=1&gdpr_consent=GDPR_CONSENT&us_privacy=USP_CONSENT` + }]); + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'image', url: `${usersyncUrl}?gdpr=0&gdpr_consent=` + }]); + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {gdprApplies: false, consentString: undefined}, undefined)).to.deep.equal([{ + type: 'image', url: `${usersyncUrl}?gdpr=0&gdpr_consent=` + }]); + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, 'USP_CONSENT')).to.deep.equal([{ + type: 'image', url: `${usersyncUrl}?us_privacy=USP_CONSENT` + }]); + expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined, 'USP_CONSENT', 'GPP_STRING')).to.deep.equal([{ + type: 'image', url: `${usersyncUrl}?us_privacy=USP_CONSENT&gpp=GPP_STRING` + }]); + }); + }) + + describe('internal functions', function () { + describe('getPageUrl', function () { + const bidderRequest = { + refererInfo: { + page: 'http://canonical.url' + } + }; + + it('should handle empty or missing data', function () { + expect(internal.getPageUrl(undefined)).to.equal(utils.getWindowSelf().location.href); + expect(internal.getPageUrl('')).to.equal(utils.getWindowSelf().location.href); + }); + + it('should use bidderRequest.refererInfo.page', function () { + expect(internal.getPageUrl(bidderRequest.refererInfo)).to.equal(bidderRequest.refererInfo.page); + }); + }); + + describe('getReferrer', function () { + it('should handle empty or missing data', function () { + expect(internal.getReferrer(undefined)).to.equal(utils.getWindowSelf().document.referrer); + expect(internal.getReferrer('')).to.equal(utils.getWindowSelf().document.referrer); + }); + + it('should use bidderRequest.refererInfo.ref', () => { + const bidderRequest = { + refererInfo: { + ref: 'foobar' + } + }; + + expect(internal.getReferrer(bidderRequest.refererInfo)).to.equal(bidderRequest.refererInfo.ref); + }); + }); + }) +}) diff --git a/test/spec/modules/talkadsBidAdapter_spec.js b/test/spec/modules/talkadsBidAdapter_spec.js index 00f52ba7b6a..c48808cbc15 100644 --- a/test/spec/modules/talkadsBidAdapter_spec.js +++ b/test/spec/modules/talkadsBidAdapter_spec.js @@ -207,6 +207,7 @@ describe('TalkAds adapter', function () { ttl: 60, creativeId: 'c123a456', netRevenue: false, + params: [Object.assign({}, commonBidRequest.params)], } spec.onBidWon(loBid) expect(server.requests.length).to.equals(0); @@ -222,7 +223,8 @@ describe('TalkAds adapter', function () { ttl: 60, creativeId: 'c123a456', netRevenue: false, - pbid: '6147833a65749742875ace47' + pbid: '6147833a65749742875ace47', + params: [Object.assign({}, commonBidRequest.params)], } spec.onBidWon(loBid) expect(server.requests[0].url).to.equals('https://test.natexo-programmatic.com/tad/tag/prebidwon/6147833a65749742875ace47'); diff --git a/test/spec/modules/tappxBidAdapter_spec.js b/test/spec/modules/tappxBidAdapter_spec.js index 8866670df77..46fac8de1e2 100644 --- a/test/spec/modules/tappxBidAdapter_spec.js +++ b/test/spec/modules/tappxBidAdapter_spec.js @@ -17,14 +17,16 @@ const c_BIDREQUEST = { crumbs: { pubcid: 'df2144f7-673f-4440-83f5-cd4a73642d99' }, - fpd: { - context: { - adServer: { - name: 'gam', - adSlot: '/19968336/header-bid-tag-0' - }, - pbAdSlot: '/19968336/header-bid-tag-0', - }, + ortb2Imp: { + ext: { + data: { + adserver: { + name: 'gam', + adslot: '/19968336/header-bid-tag-0' + }, + pbadslot: '/19968336/header-bid-tag-0', + } + } }, mediaTypes: { banner: { @@ -121,7 +123,7 @@ const c_SERVERRESPONSE_V = { const c_CONSENTSTRING = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; const c_VALIDBIDREQUESTS = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000x179MZAzMqUWsFonu7Drm3eDDBMYtj5SPoWQnl89Upk3WTlCvEnKI9SshX0p6eFJ7otPYix179MZAzMqUWsFonu7Drm3eDDBMYtj5SPoWQnl89Upk3WTlCvEnKI9SshX0p6e', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_rEXbz6UYtYEJelYrDaZOLkh8WcF9J0ZHmEHFKZEBlLXsgP6xqXU3BCj4Ay0Z6fw_jSOaHxMHwd-voRHqFA4Q9NwAxFcVLyPWnNGZ9VbcSAPos1wupq7Xu3MIm-Bw_0vxjhZdWNy4chM9x3i', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': 'xTtLUY7GwqX2MMqSHo9RQ2YUOIBFhlASOR43I9KjvgtcrxIys3RxME96M02LTjWR', 'parrableId': {'eid': '02.YoqC9lWZh8.C8QTSiJTNgI6Pp0KCM5zZgEgwVMSsVP5W51X8cmiUHQESq9WRKB4nreqZJwsWIcNKlORhG4u25Wm6lmDOBmQ0B8hv0KP6uVQ97aouuH52zaz2ctVQTORUKkErPRPcaCJ7dKFcrNoF2i6WOR0S5Nk'}, 'pubcid': 'b1254-152f-12F5-5698-dI1eljK6C7WA', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}]; const c_VALIDBIDAPPREQUESTS = [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1, 'app': {'name': 'Tappx Test', 'bundle': 'com.test.tappx', 'domain': 'tappx.com', 'publisher': { 'name': 'Tappx', 'domain': 'tappx.com' }}}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000���\u0000\u0000\u0000!�\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}, {'source': 'intentiq.com', 'uids': [{'id': 'GIF89a\u0001\u0000\u0001\u0000�\u0000\u0000���\u0000\u0000\u0000!�\u0004\u0001\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000\u0000\u0002\u0002D\u0001\u0000;', 'atype': 1}]}, {'source': 'crwdcntrl.net', 'uids': [{'id': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'atype': 1}]}, {'source': 'parrable.com', 'uids': [{'id': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0', 'atype': 1}]}, {'source': 'pubcid.org', 'uids': [{'id': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'atype': 1}]}, {'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}]; -const c_BIDDERREQUEST_B = {'bidderCode': 'tappx', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'bidderRequestId': '1c674c14a3889c', 'bids': [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}], 'auctionStart': 1617088922120, 'timeout': 700, 'refererInfo': {'referer': 'http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true', 'reachedTop': true, 'isAmp': false, 'numIframes': 0, 'stack': ['http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true'], 'canonicalUrl': null}, 'gdprConsent': {'consentString': c_CONSENTSTRING, 'vendorData': {'metadata': 'BO-JeiTPABAOkAAABAENABA', 'gdprApplies': true, 'hasGlobalScope': false, 'cookieVersion': 1, 'created': '2020-12-09T09:22:09.900Z', 'lastUpdated': '2021-01-14T15:44:03.600Z', 'cmpId': 0, 'cmpVersion': 1, 'consentScreen': 0, 'consentLanguage': 'EN', 'vendorListVersion': 1, 'maxVendorId': 0, 'purposeConsents': {}, 'vendorConsents': {}}, 'gdprApplies': true, 'apiVersion': 1}, 'uspConsent': '1YCC', 'start': 1611308859099}; +const c_BIDDERREQUEST_B = {'bidderCode': 'tappx', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'bidderRequestId': '1c674c14a3889c', 'bids': [{'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com\/rtb\/v2\/', 'tappxkey': 'pub-1234-android-1234', 'endpoint': 'ZZ1234PBJS', 'bidfloor': 0.005, 'test': 1}, 'userId': {'haloId': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'id5id': {'uid': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'ext': {'linkType': 0}}, 'intentIqId': 'GIF89a\u0000\u0000\u0000\u0000�\u0000\u0000���\u0000\u0000\u0000?�\u0000\u0000\u0000\u0000\u0000\u0000,\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000A\u0000\u0000;', 'lotamePanoramaId': '8003916b61a95b185690ec103bdf4945a70213e01818a5e5d8690b542730755a', 'parrableId': {'eid': '01.1617088921.7faa68d9570a50ea8e4f359e9b99ca4b7509e948a6175b3e5b0b8cbaf5b62424104ccfb0191ca79366de8368ed267b89a68e236df5f41f96f238e4301659e9023fec05e46399fb1ad0a0'}, 'pubcid': 'b7143795-852f-42f0-8864-5ecbea1ade4e', 'pubProvidedId': [{'source': 'domain.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 1, 'ext': {'stype': 'ppuid'}}]}, {'source': '3rdpartyprovided.com', 'uids': [{'id': 'value read from cookie or local storage', 'atype': 3, 'ext': {'stype': 'sha256email'}}]}]}, 'userIdAsEids': [{'source': 'audigent.com', 'uids': [{'id': '0000fgclxw05ycn0608xiyi90bwpa0c0evvlif0hv1x0i0ku88il0ntek0o0qskvir0trr70u0wqxiix0zq3u1012pa5j315ogh1618nmsj91bmt41c1elzfjf1hl5r1i1kkc2jl', 'atype': 1}]}, {'source': 'id5-sync.com', 'uids': [{'id': 'ID5@iu-PJX_OQ0d6FJjKS8kYfUpHriD_qpoXJUngedfpNva812If1fHEqHHkamLC89txVxk1i9WGqeQrTX97HFCgv9QDa1M_bkHUBsAWFm-D5r1rYrsfMFFiyqwCAEzqNbvsUZXOYCAQSjPcLxR4of22w-U9_JDRThCGRDV3Fmvc38E', 'atype': 1, 'ext': {'linkType': 0}}]}], 'ortb2Imp': {'ext': {'data': {'adserver': {'name': 'gam', 'adslot': '/19968336/header-bid-tag-0'}, 'pbadslot': '/19968336/header-bid-tag-0'}}}, 'mediaTypes': {'banner': {'sizes': [[320, 480], [320, 50]]}}, 'adUnitCode': 'div-gpt-ad-1460505748561-0', 'transactionId': '71c0d86b-4b47-4aff-a6da-1af0b1712439', 'sizes': [[320, 480], [320, 50]], 'bidId': '264d7969b125a5', 'bidderRequestId': '1c674c14a3889c', 'auctionId': '13a8a3a9-ed3a-4101-9435-4699ee77bb62', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}], 'auctionStart': 1617088922120, 'timeout': 700, 'refererInfo': {'page': 'http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true', 'reachedTop': true, 'isAmp': false, 'numIframes': 0, 'stack': ['http://localhost:9999/integrationExamples/gpt/gdpr_hello_world.html?pbjs_debug=true'], 'canonicalUrl': null}, 'gdprConsent': {'consentString': c_CONSENTSTRING, 'vendorData': {'metadata': 'BO-JeiTPABAOkAAABAENABA', 'gdprApplies': true, 'hasGlobalScope': false, 'cookieVersion': 1, 'created': '2020-12-09T09:22:09.900Z', 'lastUpdated': '2021-01-14T15:44:03.600Z', 'cmpId': 0, 'cmpVersion': 1, 'consentScreen': 0, 'consentLanguage': 'EN', 'vendorListVersion': 1, 'maxVendorId': 0, 'purposeConsents': {}, 'vendorConsents': {}}, 'gdprApplies': true, 'apiVersion': 1}, 'uspConsent': '1YCC', 'start': 1611308859099}; const c_BIDDERREQUEST_V = {'method': 'POST', 'url': 'https://testing.ssp.tappx.com/rtb/v2//VZ12TESTCTV?type_cnn=prebidjs&v=0.1.10329', 'data': '{"site":{"name":"localhost","bundle":"localhost","domain":"localhost"},"user":{"ext":{}},"id":"0fecfa84-c541-49f8-8c45-76b90fddc30e","test":1,"at":1,"tmax":1000,"bidder":"tappx","imp":[{"video":{"mimes":["video/mp4","application/javascript"],"minduration":3,"maxduration":30,"startdelay":5,"playbackmethod":[1,3],"api":[1,2],"protocols":[2,3],"battr":[13,14],"linearity":1,"placement":2,"minbitrate":10,"maxbitrate":10,"w":320,"h":250},"id":"2398241a5a860b","tagid":"localhost_typeAdBanVid_windows","secure":1,"bidfloor":0.005,"ext":{"bidder":{"tappxkey":"pub-1234-desktop-1234","endpoint":"vz34906po","host":"https://vz34906po.pub.tappx.com/rtb/","bidfloor":0.005}}}],"device":{"os":"windows","ip":"peer","ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36","h":864,"w":1536,"dnt":0,"language":"en","make":"Google Inc."},"params":{"host":"tappx.com","bidfloor":0.005},"regs":{"gdpr":0,"ext":{}}}', 'bids': {'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com/rtb/v2/', 'tappxkey': 'pub-1234-desktop-1234', 'endpoint': 'VZ12TESTCTV', 'bidfloor': 0.005, 'test': true}, 'crumbs': {'pubcid': 'dccfe922-3823-4676-b7b2-e5ed8743154e'}, 'ortb2Imp': {'ext': {'data': {'pbadslot': 'video-ad-div'}}}, 'renderer': {'options': {'text': 'Tappx Outstream Video'}}, 'mediaTypes': {'video': {'mimes': ['video/mp4', 'application/javascript'], 'minduration': 3, 'maxduration': 30, 'startdelay': 5, 'playbackmethod': [1, 3], 'api': [1, 2], 'protocols': [2, 3], 'battr': [13, 14], 'linearity': 1, 'placement': 2, 'minbitrate': 10, 'maxbitrate': 10, 'w': 320, 'h': 250}}, 'adUnitCode': 'video-ad-div', 'transactionId': 'ed41c805-d14c-49c3-954d-26b98b2aa2c2', 'sizes': [[320, 250]], 'bidId': '28f49c71b13f2f', 'bidderRequestId': '1401710496dc7', 'auctionId': 'e807363f-3095-43a8-a4a6-f44196cb7318', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}} const c_BIDDERREQUEST_VOutstream = {'method': 'POST', 'url': 'https://testing.ssp.tappx.com/rtb/v2//VZ12TESTCTV?type_cnn=prebidjs&v=0.1.10329', 'data': '{"site":{"name":"localhost","bundle":"localhost","domain":"localhost"},"user":{"ext":{}},"id":"0fecfa84-c541-49f8-8c45-76b90fddc30e","test":1,"at":1,"tmax":1000,"bidder":"tappx","imp":[{"video":{"context": "outstream","playerSize":[640, 480],"mimes":["video/mp4","application/javascript"],"minduration":3,"maxduration":30,"startdelay":5,"playbackmethod":[1,3],"api":[1,2],"protocols":[2,3],"battr":[13,14],"linearity":1,"placement":2,"minbitrate":10,"maxbitrate":10,"w":320,"h":250},"id":"2398241a5a860b","tagid":"localhost_typeAdBanVid_windows","secure":1,"bidfloor":0.005,"ext":{"bidder":{"tappxkey":"pub-1234-desktop-1234","endpoint":"vz34906po","host":"https://vz34906po.pub.tappx.com/rtb/","bidfloor":0.005}}}],"device":{"os":"windows","ip":"peer","ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36","h":864,"w":1536,"dnt":0,"language":"en","make":"Google Inc."},"params":{"host":"tappx.com","bidfloor":0.005},"regs":{"gdpr":0,"ext":{}}}', 'bids': {'bidder': 'tappx', 'params': {'host': 'testing.ssp.tappx.com/rtb/v2/', 'tappxkey': 'pub-1234-desktop-1234', 'endpoint': 'VZ12TESTCTV', 'bidfloor': 0.005, 'test': true}, 'crumbs': {'pubcid': 'dccfe922-3823-4676-b7b2-e5ed8743154e'}, 'ortb2Imp': {'ext': {'data': {'pbadslot': 'video-ad-div'}}}, 'renderer': {'options': {'text': 'Tappx Outstream Video'}}, 'mediaTypes': {'video': {'mimes': ['video/mp4', 'application/javascript'], 'minduration': 3, 'maxduration': 30, 'startdelay': 5, 'playbackmethod': [1, 3], 'api': [1, 2], 'protocols': [2, 3], 'battr': [13, 14], 'linearity': 1, 'placement': 2, 'minbitrate': 10, 'maxbitrate': 10, 'w': 320, 'h': 250}}, 'adUnitCode': 'video-ad-div', 'transactionId': 'ed41c805-d14c-49c3-954d-26b98b2aa2c2', 'sizes': [[320, 250]], 'bidId': '28f49c71b13f2f', 'bidderRequestId': '1401710496dc7', 'auctionId': 'e807363f-3095-43a8-a4a6-f44196cb7318', 'src': 'client', 'bidRequestsCount': 1, 'bidderRequestsCount': 1, 'bidderWinsCount': 0}} @@ -464,4 +466,23 @@ describe('Tappx bid adapter', function () { assert.isString(_extractPageUrl(validBidRequests, bidderRequest)); }); }) + + describe('Empty params values from bid tests', function() { + let validBidRequest = JSON.parse(JSON.stringify(c_BIDREQUEST)); + + it('should return false when tappxkey is empty', function () { + validBidRequest.bids[0].params.tappxkey = ''; + assert.isFalse(spec.isBidRequestValid(validBidRequest.bids[0])); + }); + + it('should return false when host is empty', function () { + validBidRequest.bids[0].params.host = ''; + assert.isFalse(spec.isBidRequestValid(validBidRequest.bids[0])); + }); + + it('should return false when endpoint is empty', function () { + validBidRequest.bids[0].params.endpoint = ''; + assert.isFalse(spec.isBidRequestValid(validBidRequest.bids[0])); + }); + }); }); diff --git a/test/spec/modules/targetVideoBidAdapter_spec.js b/test/spec/modules/targetVideoBidAdapter_spec.js index 0ce6f0fb70d..8180183e6d7 100644 --- a/test/spec/modules/targetVideoBidAdapter_spec.js +++ b/test/spec/modules/targetVideoBidAdapter_spec.js @@ -58,7 +58,7 @@ describe('TargetVideo Bid Adapter', function() { 'uuid': '84ab500420319d', 'ads': [{ 'ad_type': 'video', - 'cpm': 0.500000, + 'cpm': 0.675000, 'notify_url': 'https://www.target-video.com/', 'rtb': { 'video': { @@ -87,10 +87,53 @@ describe('TargetVideo Bid Adapter', function() { const bid = bidResponse[0]; expect(bid).to.not.be.empty; - expect(bid.cpm).to.equal(0.675); + expect(bid.cpm).to.equal(0.5); expect(bid.width).to.equal(300); expect(bid.height).to.equal(250); expect(bid.ad).to.include('') expect(bid.ad).to.include('initPlayer') }); + + it('Test GDPR consent information is present in the request', function () { + let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; + let bidderRequest = { + 'bidderCode': 'targetVideo', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'gdprConsent': { + consentString: consentString, + gdprApplies: true, + addtlConsent: '1~7.12.35.62.66.70.89.93.108' + } + }; + bidderRequest.bids = bannerRequest; + + const request = spec.buildRequests(bannerRequest, bidderRequest); + expect(request.options).to.deep.equal({withCredentials: true}); + const payload = JSON.parse(request.data); + + expect(payload.gdpr_consent).to.exist; + expect(payload.gdpr_consent.consent_string).to.exist.and.to.equal(consentString); + expect(payload.gdpr_consent.consent_required).to.exist.and.to.be.true; + expect(payload.gdpr_consent.addtl_consent).to.exist.and.to.deep.equal([7, 12, 35, 62, 66, 70, 89, 93, 108]); + }); + + it('Test US Privacy string is present in the request', function() { + let consentString = '1YA-'; + let bidderRequest = { + 'bidderCode': 'targetVideo', + 'auctionId': '1d1a030790a475', + 'bidderRequestId': '22edbae2733bf6', + 'timeout': 3000, + 'uspConsent': consentString + }; + bidderRequest.bids = bannerRequest; + + const request = spec.buildRequests(bannerRequest, bidderRequest); + const payload = JSON.parse(request.data); + + expect(payload.us_privacy).to.exist; + expect(payload.us_privacy).to.exist.and.to.equal(consentString); + }); }); diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 75ed7452b57..b0d5f436e0b 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -1,23 +1,20 @@ import {expect} from 'chai'; import {spec, storage} from 'modules/teadsBidAdapter.js'; import {newBidder} from 'src/adapters/bidderFactory.js'; -import {getStorageManager} from 'src/storageManager'; const ENDPOINT = 'https://a.teads.tv/hb/bid-request'; const AD_SCRIPT = '"'; describe('teadsBidAdapter', () => { const adapter = newBidder(spec); - let cookiesAreEnabledStub, getCookieStub; + let sandbox; beforeEach(function () { - cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); - getCookieStub = sinon.stub(storage, 'getCookie'); + sandbox = sinon.sandbox.create(); }); afterEach(function () { - cookiesAreEnabledStub.restore(); - getCookieStub.restore(); + sandbox.restore(); }); describe('inherited functions', () => { @@ -108,19 +105,26 @@ describe('teadsBidAdapter', () => { } ]; - let bidderResquestDefault = { + let bidderRequestDefault = { 'auctionId': '1d1a030790a475', 'bidderRequestId': '22edbae2733bf6', 'timeout': 3000 }; it('should send bid request to ENDPOINT via POST', function() { - const request = spec.buildRequests(bidRequests, bidderResquestDefault); + const request = spec.buildRequests(bidRequests, bidderRequestDefault); expect(request.url).to.equal(ENDPOINT); expect(request.method).to.equal('POST'); }); + it('should not send auctionId in bid request ', function() { + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.data[0].auctionId).to.not.exist + }); + it('should send US Privacy to endpoint', function() { let usPrivacy = 'OHHHFCP1' let bidderRequest = { @@ -147,9 +151,9 @@ describe('teadsBidAdapter', () => { 'consentString': consentString, 'gdprApplies': true, 'vendorData': { - 'hasGlobalConsent': false + 'isServiceSpecific': true }, - 'apiVersion': 1 + 'apiVersion': 2 } }; @@ -159,14 +163,63 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(consentString); expect(payload.gdpr_iab.status).to.equal(12); - expect(payload.gdpr_iab.apiVersion).to.equal(1); + expect(payload.gdpr_iab.apiVersion).to.equal(2); + }); + + it('should add videoPlcmt to payload', function () { + let bidRequestWithVideoPlcmt = Object.assign({}, bidRequests[0], { + mediaTypes: { + video: { + plcmt: 1 + } + } + }); + + const request = spec.buildRequests([bidRequestWithVideoPlcmt], bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.data[0].videoPlcmt).to.exist; + expect(payload.data[0].videoPlcmt).to.equal(1); + }); + + it('should not add videoPlcmt to payload if empty', function () { + let bidRequestWithNullVideoPlcmt = Object.assign({}, bidRequests[0], { + mediaTypes: { + video: { + plcmt: null + } + } + }); + + let bidRequestWithEmptyVideoPlcmt = Object.assign({}, bidRequests[0], { + mediaTypes: { + video: { + plcmt: '' + } + } + }); + + const request1 = spec.buildRequests([bidRequestWithNullVideoPlcmt], bidderRequestDefault); + const request2 = spec.buildRequests([bidRequestWithEmptyVideoPlcmt], bidderRequestDefault); + const payload1 = JSON.parse(request1.data); + const payload2 = JSON.parse(request2.data); + + expect(payload1.data[0].videoPlcmt).to.not.exist; + expect(payload2.data[0].videoPlcmt).to.not.exist; + }); + + it('should not add videoPlcmt to payload if it is not in bid request', function () { + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.data[0].videoPlcmt).to.not.exist; }); it('should add referer info to payload', function () { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'https://example.com/page.html', + page: 'https://example.com/page.html', reachedTop: true, numIframes: 2 } @@ -179,7 +232,7 @@ describe('teadsBidAdapter', () => { }); it('should add networkBandwidth info to payload', function () { - const request = spec.buildRequests(bidRequests, bidderResquestDefault); + const request = spec.buildRequests(bidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); const bandwidth = window.navigator && window.navigator.connection && window.navigator.connection.downlink; @@ -194,15 +247,110 @@ describe('teadsBidAdapter', () => { }); it('should add pageReferrer info to payload', function () { - const request = spec.buildRequests(bidRequests, bidderResquestDefault); + const request = spec.buildRequests(bidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); expect(payload.pageReferrer).to.exist; expect(payload.pageReferrer).to.deep.equal(document.referrer); }); + describe('pageTitle', function () { + it('should add pageTitle info to payload based on document title', function () { + const testText = 'This is a title'; + sandbox.stub(window.top.document, 'title').value(testText); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageTitle).to.exist; + expect(payload.pageTitle).to.deep.equal(testText); + }); + + it('should add pageTitle info to payload based on open-graph title', function () { + const testText = 'This is a title from open-graph'; + sandbox.stub(window.top.document, 'title').value(''); + sandbox.stub(window.top.document, 'querySelector').withArgs('meta[property="og:title"]').returns({ content: testText }); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageTitle).to.exist; + expect(payload.pageTitle).to.deep.equal(testText); + }); + + it('should add pageTitle info to payload sliced on 300 first characters', function () { + const testText = Array(500).join('a'); + sandbox.stub(window.top.document, 'title').value(testText); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageTitle).to.exist; + expect(payload.pageTitle).to.have.length(300); + }); + + it('should add pageTitle info to payload when fallbacking from window.top', function () { + const testText = 'This is a fallback title'; + sandbox.stub(window.top.document, 'querySelector').throws(); + sandbox.stub(document, 'title').value(testText); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageTitle).to.exist; + expect(payload.pageTitle).to.deep.equal(testText); + }); + }); + + describe('pageDescription', function () { + it('should add pageDescription info to payload based on open-graph description', function () { + const testText = 'This is a description'; + sandbox.stub(window.top.document, 'querySelector').withArgs('meta[name="description"]').returns({ content: testText }); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageDescription).to.exist; + expect(payload.pageDescription).to.deep.equal(testText); + }); + + it('should add pageDescription info to payload based on open-graph description', function () { + const testText = 'This is a description from open-graph'; + sandbox.stub(window.top.document, 'querySelector').withArgs('meta[property="og:description"]').returns({ content: testText }); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageDescription).to.exist; + expect(payload.pageDescription).to.deep.equal(testText); + }); + + it('should add pageDescription info to payload sliced on 300 first characters', function () { + const testText = Array(500).join('a'); + sandbox.stub(window.top.document, 'querySelector').withArgs('meta[name="description"]').returns({ content: testText }); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageDescription).to.exist; + expect(payload.pageDescription).to.have.length(300); + }); + + it('should add pageDescription info to payload when fallbacking from window.top', function () { + const testText = 'This is a fallback description'; + sandbox.stub(window.top.document, 'querySelector').throws(); + sandbox.stub(document, 'querySelector').withArgs('meta[name="description"]').returns({ content: testText }); + + const request = spec.buildRequests(bidRequests, bidderRequestDefault); + const payload = JSON.parse(request.data); + + expect(payload.pageDescription).to.exist; + expect(payload.pageDescription).to.deep.equal(testText); + }); + }); + it('should add timeToFirstByte info to payload', function () { - const request = spec.buildRequests(bidRequests, bidderResquestDefault); + const request = spec.buildRequests(bidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); const performance = window.performance || window.webkitPerformance || window.msPerformance || window.mozPerformance; @@ -245,9 +393,9 @@ describe('teadsBidAdapter', () => { 'consentString': consentString, 'gdprApplies': true, 'vendorData': { - 'hasGlobalScope': true + 'isServiceSpecific': false, }, - 'apiVersion': 1 + 'apiVersion': 2 } }; @@ -257,7 +405,7 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(consentString); expect(payload.gdpr_iab.status).to.equal(11); - expect(payload.gdpr_iab.apiVersion).to.equal(1); + expect(payload.gdpr_iab.apiVersion).to.equal(2); }); it('should send GDPR TCF2 to endpoint with 12 status', function() { @@ -294,7 +442,7 @@ describe('teadsBidAdapter', () => { 'consentString': undefined, 'gdprApplies': undefined, 'vendorData': undefined, - 'apiVersion': 1 + 'apiVersion': 2 } }; @@ -304,7 +452,7 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(''); expect(payload.gdpr_iab.status).to.equal(22); - expect(payload.gdpr_iab.apiVersion).to.equal(1); + expect(payload.gdpr_iab.apiVersion).to.equal(2); }); it('should send GDPR to endpoint with 0 status', function() { @@ -319,7 +467,7 @@ describe('teadsBidAdapter', () => { 'vendorData': { 'hasGlobalScope': false }, - 'apiVersion': 1 + 'apiVersion': 2 } }; @@ -329,7 +477,7 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(consentString); expect(payload.gdpr_iab.status).to.equal(0); - expect(payload.gdpr_iab.apiVersion).to.equal(1); + expect(payload.gdpr_iab.apiVersion).to.equal(2); }); it('should send GDPR to endpoint with 0 status when gdprApplies = false (vendorData = undefined)', function() { @@ -341,7 +489,7 @@ describe('teadsBidAdapter', () => { 'consentString': undefined, 'gdprApplies': false, 'vendorData': undefined, - 'apiVersion': 1 + 'apiVersion': 2 } }; @@ -351,7 +499,7 @@ describe('teadsBidAdapter', () => { expect(payload.gdpr_iab).to.exist; expect(payload.gdpr_iab.consent).to.equal(''); expect(payload.gdpr_iab.status).to.equal(0); - expect(payload.gdpr_iab.apiVersion).to.equal(1); + expect(payload.gdpr_iab.apiVersion).to.equal(2); }); it('should send GDPR to endpoint with 12 status when apiVersion = 0', function() { @@ -364,7 +512,7 @@ describe('teadsBidAdapter', () => { 'consentString': consentString, 'gdprApplies': true, 'vendorData': { - 'hasGlobalScope': false + 'isServiceSpecific': true }, 'apiVersion': 0 } @@ -403,7 +551,7 @@ describe('teadsBidAdapter', () => { } }); - const request = spec.buildRequests([bidRequest], bidderResquestDefault); + const request = spec.buildRequests([bidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); expect(payload.schain).to.exist; @@ -418,6 +566,74 @@ describe('teadsBidAdapter', () => { }); }); + it('should add userAgentClientHints info to payload if available', function () { + const bidRequest = Object.assign({}, bidRequests[0], { + ortb2: { + device: { + sua: { + source: 2, + platform: { + brand: 'macOS', + version: [ '12', '4', '0' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Not;A=Brand', + version: [ '99', '0', '0', '0' ] + } + ], + mobile: 0, + model: '', + bitness: '64', + architecture: 'x86' + } + } + } + }); + + const requestWithUserAgentClientHints = spec.buildRequests([bidRequest], bidderRequestDefault); + const payload = JSON.parse(requestWithUserAgentClientHints.data); + + expect(payload.userAgentClientHints).to.exist; + expect(payload.userAgentClientHints).to.deep.equal({ + source: 2, + platform: { + brand: 'macOS', + version: [ '12', '4', '0' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Not;A=Brand', + version: [ '99', '0', '0', '0' ] + } + ], + mobile: 0, + model: '', + bitness: '64', + architecture: 'x86' + } + ); + + const defaultRequest = spec.buildRequests(bidRequests, bidderRequestDefault); + expect(JSON.parse(defaultRequest.data).userAgentClientHints).to.not.exist; + }); + it('should use good mediaTypes video sizes', function() { const mediaTypesVideoSizes = { 'mediaTypes': { @@ -470,114 +686,163 @@ describe('teadsBidAdapter', () => { 'deviceWidth': 1680 }; - describe('FLoC ID', function () { - it('should not add cohortId and cohortVersion params to payload if FLoC ID system is not enabled', function () { + const userIdModules = { + unifiedId2: {uid2: {id: 'unifiedId2-id'}}, + liveRampId: {idl_env: 'liveRampId-id'}, + lotamePanoramaId: {lotamePanoramaId: 'lotamePanoramaId-id'}, + id5Id: {id5id: {uid: 'id5Id-id'}}, + criteoId: {criteoId: 'criteoId-id'}, + yahooConnectId: {connectId: 'yahooConnectId-id'}, + quantcastId: {quantcastId: 'quantcastId-id'}, + epsilonPublisherLinkId: {publinkId: 'epsilonPublisherLinkId-id'}, + publisherFirstPartyViewerId: {pubcid: 'publisherFirstPartyViewerId-id'}, + merkleId: {merkleId: {id: 'merkleId-id'}}, + kinessoId: {kpuid: 'kinessoId-id'} + }; + + describe('User Id Modules', function () { + it(`should not add param to payload if user id system is not enabled`, function () { const bidRequest = { ...baseBidRequest, - userId: {} // no "flocId" property -> assumption that the FLoC ID system is disabled + userId: {} // no property -> assumption that the system is disabled }; - const request = spec.buildRequests([bidRequest], bidderResquestDefault); + const request = spec.buildRequests([bidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); - expect(payload).not.to.have.property('cohortId'); - expect(payload).not.to.have.property('cohortVersion'); + for (const userId in userIdModules) { + expect(payload, userId).not.to.have.property(userId); + } }); - it('should add cohortId param to payload if FLoC ID system is enabled and ID available, but not version', function () { - const bidRequest = { - ...baseBidRequest, - userId: { - flocId: { - id: 'my-floc-id' - } - } - }; - - const request = spec.buildRequests([bidRequest], bidderResquestDefault); + it(`should not add param to payload if user id field is absent`, function () { + const request = spec.buildRequests([baseBidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); - expect(payload.cohortId).to.equal('my-floc-id'); - expect(payload).not.to.have.property('cohortVersion'); + for (const userId in userIdModules) { + expect(payload, userId).not.to.have.property(userId); + } }); - it('should add cohortId and cohortVersion params to payload if FLoC ID system is enabled', function () { + it(`should not add param to payload if user id is enabled but there is no value`, function () { const bidRequest = { ...baseBidRequest, userId: { - flocId: { - id: 'my-floc-id', - version: 'chrome.1.1' - } + idl_env: '', + pubcid: 'publisherFirstPartyViewerId-id' } }; - const request = spec.buildRequests([bidRequest], bidderResquestDefault); + const request = spec.buildRequests([bidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); - expect(payload.cohortId).to.equal('my-floc-id'); - expect(payload.cohortVersion).to.equal('chrome.1.1'); + expect(payload).not.to.have.property('liveRampId'); + expect(payload['publisherFirstPartyViewerId']).to.equal('publisherFirstPartyViewerId-id'); }); - }); - describe('Unified ID v2', function () { - it('should not add unifiedId2 param to payload if uid2 system is not enabled', function () { + it(`should add userId param to payload for each enabled user id system`, function () { + let userIdObject = {}; + for (const userId in userIdModules) { + userIdObject = { + ...userIdObject, + ...userIdModules[userId] + } + } const bidRequest = { ...baseBidRequest, - userId: {} // no "uid2" property -> assumption that the Unified ID v2 system is disabled + userId: userIdObject }; - const request = spec.buildRequests([bidRequest], bidderResquestDefault); + const request = spec.buildRequests([bidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); - expect(payload).not.to.have.property('unifiedId2'); + expect(payload['unifiedId2']).to.equal('unifiedId2-id'); + expect(payload['liveRampId']).to.equal('liveRampId-id'); + expect(payload['lotamePanoramaId']).to.equal('lotamePanoramaId-id'); + expect(payload['id5Id']).to.equal('id5Id-id'); + expect(payload['criteoId']).to.equal('criteoId-id'); + expect(payload['yahooConnectId']).to.equal('yahooConnectId-id'); + expect(payload['quantcastId']).to.equal('quantcastId-id'); + expect(payload['epsilonPublisherLinkId']).to.equal('epsilonPublisherLinkId-id'); + expect(payload['publisherFirstPartyViewerId']).to.equal('publisherFirstPartyViewerId-id'); + expect(payload['merkleId']).to.equal('merkleId-id'); + expect(payload['kinessoId']).to.equal('kinessoId-id'); }); + }) + + describe('First-party cookie Teads ID', function () { + it('should not add firstPartyCookieTeadsId param to payload if cookies are not enabled' + + ' and teads user id not available', function () { + sandbox.stub(storage, 'cookiesAreEnabled').returns(false); - it('should add unifiedId2 param to payload if uid2 system is enabled', function () { const bidRequest = { ...baseBidRequest, userId: { - uid2: { - id: 'my-unified-id-2' - } + pubcid: 'publisherFirstPartyViewerId-id' } }; - const request = spec.buildRequests([bidRequest], bidderResquestDefault); + const request = spec.buildRequests([bidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); - expect(payload.unifiedId2).to.equal('my-unified-id-2'); - }) - }); + expect(payload).not.to.have.property('firstPartyCookieTeadsId'); + }); - describe('First-party cookie Teads ID', function () { - it('should not add firstPartyCookieTeadsId param to payload if cookies are not enabled', function () { - cookiesAreEnabledStub.returns(false); + it('should not add firstPartyCookieTeadsId param to payload if cookies are enabled ' + + 'but first-party cookie and teads user id are not available', function () { + sandbox.stub(storage, 'cookiesAreEnabled').returns(true); + sandbox.stub(storage, 'getCookie').withArgs('_tfpvi').returns(undefined); + + const bidRequest = { + ...baseBidRequest, + userId: { + pubcid: 'publisherFirstPartyViewerId-id' + } + }; - const request = spec.buildRequests([baseBidRequest], bidderResquestDefault); + const request = spec.buildRequests([bidRequest], bidderRequestDefault); const payload = JSON.parse(request.data); expect(payload).not.to.have.property('firstPartyCookieTeadsId'); }); - it('should not add firstPartyCookieTeadsId param to payload if first-party cookie is not available', function () { - cookiesAreEnabledStub.returns(true); - getCookieStub.withArgs('_tfpvi').returns(undefined); + it('should add firstPartyCookieTeadsId from cookie if it\'s available ' + + 'and teads user id is not', function () { + sandbox.stub(storage, 'cookiesAreEnabled').returns(true); + sandbox.stub(storage, 'getCookie').withArgs('_tfpvi').returns('my-teads-id'); + + const bidRequest = { + ...baseBidRequest, + userId: { + pubcid: 'publisherFirstPartyViewerId-id' + } + }; + + const request = spec.buildRequests([bidRequest], bidderRequestDefault); - const request = spec.buildRequests([baseBidRequest], bidderResquestDefault); const payload = JSON.parse(request.data); - expect(payload).not.to.have.property('firstPartyCookieTeadsId'); + expect(payload.firstPartyCookieTeadsId).to.equal('my-teads-id'); }); - it('should add firstPartyCookieTeadsId param to payload if first-party cookie is available', function () { - cookiesAreEnabledStub.returns(true); - getCookieStub.withArgs('_tfpvi').returns('my-teads-id'); + it('should add firstPartyCookieTeadsId from user id module if it\'s available ' + + 'even if cookie is available too', function () { + sandbox.stub(storage, 'cookiesAreEnabled').returns(true); + sandbox.stub(storage, 'getCookie').withArgs('_tfpvi').returns('my-teads-id'); + + const bidRequest = { + ...baseBidRequest, + userId: { + pubcid: 'publisherFirstPartyViewerId-id', + teadsId: 'teadsId-fake-id' + } + }; + + const request = spec.buildRequests([bidRequest], bidderRequestDefault); - const request = spec.buildRequests([baseBidRequest], bidderResquestDefault); const payload = JSON.parse(request.data); - expect(payload.firstPartyCookieTeadsId).to.equal('my-teads-id'); + expect(payload.firstPartyCookieTeadsId).to.equal('teadsId-fake-id'); }); }); }); @@ -626,7 +891,7 @@ describe('teadsBidAdapter', () => { }; } ); - const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault); + const request = spec.buildRequests(updatedBidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); expect(payload.data[0].gpid).to.equal('1111/home-left-0'); @@ -643,7 +908,7 @@ describe('teadsBidAdapter', () => { } })); - const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault); + const request = spec.buildRequests(updatedBidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); return payload.data.forEach(bid => { @@ -660,7 +925,7 @@ describe('teadsBidAdapter', () => { } })); - const request = spec.buildRequests(updatedBidRequests, bidderResquestDefault); + const request = spec.buildRequests(updatedBidRequests, bidderRequestDefault); const payload = JSON.parse(request.data); return payload.data.forEach(bid => { @@ -671,7 +936,7 @@ describe('teadsBidAdapter', () => { function checkMediaTypesSizes(mediaTypes, expectedSizes) { const bidRequestWithBannerSizes = Object.assign(bidRequests[0], mediaTypes); - const requestWithBannerSizes = spec.buildRequests([bidRequestWithBannerSizes], bidderResquestDefault); + const requestWithBannerSizes = spec.buildRequests([bidRequestWithBannerSizes], bidderRequestDefault); const payloadWithBannerSizes = JSON.parse(requestWithBannerSizes.data); return payloadWithBannerSizes.data.forEach(bid => { diff --git a/test/spec/modules/teadsIdSystem_spec.js b/test/spec/modules/teadsIdSystem_spec.js new file mode 100644 index 00000000000..1959b990957 --- /dev/null +++ b/test/spec/modules/teadsIdSystem_spec.js @@ -0,0 +1,271 @@ +import { + teadsIdSubmodule, + storage, + buildAnalyticsTagUrl, + getGdprStatus, + gdprStatus, + getPublisherId, + getGdprConsentString, + getCookieExpirationDate, getTimestampFromDays, getCcpaConsentString +} from 'modules/teadsIdSystem.js'; +import {server} from 'test/mocks/xhr.js'; +import * as utils from '../../../src/utils.js'; + +const FP_TEADS_ID_COOKIE_NAME = '_tfpvi'; +const teadsCookieIdSent = 'teadsCookieIdSent'; +const EXPIRED_COOKIE_DATE = 'Thu, 01 Jan 1970 00:00:01 GMT'; + +describe('TeadsIdSystem', function () { + describe('buildAnalyticsTagUrl', function () { + it('return complete URL of server request', function () { + const submoduleConfig = { + params: { + pubId: 1234 + } + }; + + const consentData = { + gdprApplies: true, + consentString: 'abc123==' + } + + const result = buildAnalyticsTagUrl(submoduleConfig, consentData); + const expected = 'https://at.teads.tv/fpc?analytics_tag_id=PUB_1234&tfpvi=&gdpr_consent=abc123%3D%3D&gdpr_status=12&gdpr_reason=120&ccpa_consent=&sv=prebid-v1' + expect(result).to.be.equal(expected); + }) + }); + + describe('getPublisherId', function () { + it('return empty string if params.pubId param is missing', function () { + const submoduleConfig = {}; + const result = getPublisherId(submoduleConfig); + const expected = ''; + expect(result).to.be.equal(expected); + }); + it('return empty string if params.pubId param has a wrong value', function () { + const pubIdDifferentValues = [null, undefined, false, true, {}, [], 'abc123']; + + pubIdDifferentValues.forEach((value) => { + const submoduleConfig = { + params: { + pubId: value + } + }; + const result = getPublisherId(submoduleConfig); + const expected = ''; + expect(result).to.be.equal(expected); + }); + }); + it('return a publisherId prefixed by PUB_ string if params.pubId has a good value', function () { + const pubIdDifferentValues = [1234, '1234']; + + pubIdDifferentValues.forEach((value) => { + const submoduleConfig = { + params: { + pubId: value + } + }; + const result = getPublisherId(submoduleConfig); + const expected = 'PUB_1234'; + expect(result).to.be.equal(expected); + }); + }); + }); + + describe('getGdprConsentString', function () { + it('return empty consentString if no consentData given', function () { + const consentDataDifferentValues = [{}, undefined, null]; + + consentDataDifferentValues.forEach((value) => { + const result = getGdprConsentString(value); + const expected = ''; + expect(result).to.be.equal(expected); + }); + }); + it('return empty consentString if consentString has a wrong format', function () { + const consentStringDifferentValues = [1, 0, undefined, null, {}]; + + consentStringDifferentValues.forEach((value) => { + const consentData = { + consentString: value + }; + const result = getGdprConsentString(consentData); + const expected = ''; + expect(result).to.be.equal(expected); + }); + }); + it('return a good consentString if present and a correct format', function () { + const consentData = { + consentString: 'consent-string-teads-O1' + }; + const result = getGdprConsentString(consentData); + const expected = 'consent-string-teads-O1'; + expect(result).to.be.equal(expected); + }); + }); + + describe('getCcpaConsentString', function () { + it('return empty CCPA consentString if no CCPA data is available or a wrong format', function () { + const consentDataDifferentValues = [{}, undefined, null, 123]; + + consentDataDifferentValues.forEach((value) => { + const result = getCcpaConsentString(value); + const expected = ''; + expect(result).to.be.equal(expected); + }); + }); + it('return CCPA consentString if CCPA data is available and a good format', function () { + const consentData = '1NYN'; + const result = getCcpaConsentString(consentData); + const expected = '1NYN'; + expect(result).to.be.equal(expected); + }); + }); + + describe('getGdprStatus', function () { + it('return CMP_NOT_FOUND_OR_ERROR if no given consentData', function () { + const consentDataDifferentValues = [{}, undefined, null]; + + consentDataDifferentValues.forEach((value) => { + const result = getGdprStatus(value); + const expected = gdprStatus.CMP_NOT_FOUND_OR_ERROR; + expect(result).to.be.equal(expected); + }); + }); + it('return CMP_NOT_FOUND_OR_ERROR if gdprApplies param has a wrong format', function () { + const gdprAppliesDifferentValues = ['yes', 'true', 1, 0, undefined, null, {}]; + + gdprAppliesDifferentValues.forEach((value) => { + const consentData = { + gdprApplies: value + }; + const result = getGdprStatus(consentData); + const expected = gdprStatus.CMP_NOT_FOUND_OR_ERROR; + expect(result).to.be.equal(expected); + }); + }); + it('return GDPR_DOESNT_APPLY if gdprApplies are false', function () { + const consentData = { + gdprApplies: false + }; + const result = getGdprStatus(consentData); + const expected = gdprStatus.GDPR_DOESNT_APPLY; + expect(result).to.be.equal(expected); + }); + it('return GDPR_APPLIES_PUBLISHER if gdprApplies are true', function () { + const consentData = { + gdprApplies: true + }; + const result = getGdprStatus(consentData); + const expected = gdprStatus.GDPR_APPLIES_PUBLISHER; + expect(result).to.be.equal(expected); + }) + }); + + describe('getExpirationDate', function () { + it('return Date Formatted if no given consentData', function () { + let timeStampStub; + timeStampStub = sinon.stub(utils, 'timestamp').returns(Date.UTC(2022, 8, 19, 14, 30, 50, 0)); + const cookiesMaxAge = getTimestampFromDays(365); + + const result = getCookieExpirationDate(cookiesMaxAge); + const expected = 'Tue, 19 Sep 2023 14:30:50 GMT'; + expect(result).to.be.equal(expected); + timeStampStub.restore(); + }); + }); + + describe('getId', function () { + let setCookieStub, setLocalStorageStub, removeFromLocalStorageStub, logErrorStub, logInfoStub, timeStampStub; + const teadsUrl = 'https://at.teads.tv/fpc'; + const timestampNow = new Date().getTime(); + + beforeEach(function () { + setCookieStub = sinon.stub(storage, 'setCookie'); + timeStampStub = sinon.stub(utils, 'timestamp').returns(timestampNow); + logErrorStub = sinon.stub(utils, 'logError'); + logInfoStub = sinon.stub(utils, 'logInfo'); + }); + + afterEach(function () { + setCookieStub.restore(); + timeStampStub.restore(); + logErrorStub.restore(); + logInfoStub.restore(); + }); + + it('should log an error and continue to callback if request errors', function () { + const config = { + params: {} + }; + + const callbackSpy = sinon.spy(); + const callback = teadsIdSubmodule.getId(config).callback; + callback(callbackSpy); + const request = server.requests[0]; + expect(request.url).to.include(teadsUrl); + request.respond(503, null, 'Unavailable'); + expect(logErrorStub.calledOnce).to.be.true; + }); + + it('should log an info and continue to callback if status 204 is sent', function () { + const config = { + params: {} + }; + + const callbackSpy = sinon.spy(); + const callback = teadsIdSubmodule.getId(config).callback; + callback(callbackSpy); + const request = server.requests[0]; + expect(request.url).to.include(teadsUrl); + request.respond(204); + expect(logInfoStub.calledOnce).to.be.true; + }); + + it('should call the callback with the response body if status 200 is sent', function () { + const config = { + params: {} + }; + + const callbackSpy = sinon.spy(); + const callback = teadsIdSubmodule.getId(config).callback; + callback(callbackSpy); + const request = server.requests[0]; + expect(request.url).to.include(teadsUrl); + request.respond(200, {'Content-Type': 'application/json'}, teadsCookieIdSent); + expect(callbackSpy.lastCall.lastArg).to.deep.equal(teadsCookieIdSent); + }); + + it('should save teadsId in cookie and local storage if it was returned by API', function () { + const config = { + params: {} + }; + const result = teadsIdSubmodule.getId(config, {}); + result.callback((id) => { + expect(id).to.be.deep.equal(teadsCookieIdSent); + }); + + let request = server.requests[0]; + request.respond(200, {'Content-Type': 'application/json'}, teadsCookieIdSent); + + const cookiesMaxAge = getTimestampFromDays(365); // 1 year + const expirationCookieDate = getCookieExpirationDate(cookiesMaxAge); + expect(setCookieStub.calledWith(FP_TEADS_ID_COOKIE_NAME, teadsCookieIdSent, expirationCookieDate)).to.be.true; + }); + + it('should delete teadsId in cookie and local storage if it was not returned by API', function () { + const config = { + params: {} + }; + const result = teadsIdSubmodule.getId(config, {}); + result.callback((id) => { + expect(id).to.be.undefined + }); + + let request = server.requests[0]; + request.respond(200, {'Content-Type': 'application/json'}, ''); + + expect(setCookieStub.calledWith(FP_TEADS_ID_COOKIE_NAME, '', EXPIRED_COOKIE_DATE)).to.be.true; + }); + }); +}); diff --git a/test/spec/modules/terceptAnalyticsAdapter_spec.js b/test/spec/modules/terceptAnalyticsAdapter_spec.js index 594e1e5f5b4..a1384bfd919 100644 --- a/test/spec/modules/terceptAnalyticsAdapter_spec.js +++ b/test/spec/modules/terceptAnalyticsAdapter_spec.js @@ -709,7 +709,6 @@ describe('tercept analytics adapter', function () { 'bidsReceived': [], 'winningBids': [], 'timeout': 1000, - 'config': initOptions }, 'initOptions': initOptions }; diff --git a/test/spec/modules/tncIdSystem_spec.js b/test/spec/modules/tncIdSystem_spec.js new file mode 100644 index 00000000000..57c5fa63645 --- /dev/null +++ b/test/spec/modules/tncIdSystem_spec.js @@ -0,0 +1,109 @@ +import { tncidSubModule } from 'modules/tncIdSystem'; + +const consentData = { + gdprApplies: true, + consentString: 'GDPR_CONSENT_STRING' +}; + +describe('TNCID tests', function () { + describe('name', () => { + it('should expose the name of the submodule', () => { + expect(tncidSubModule.name).to.equal('tncId'); + }); + }); + + describe('gvlid', () => { + it('should expose the vendor id', () => { + expect(tncidSubModule.gvlid).to.equal(750); + }); + }); + + describe('decode', () => { + it('should wrap the given value inside an object literal', () => { + expect(tncidSubModule.decode('TNCID_TEST_ID')).to.deep.equal({ + tncid: 'TNCID_TEST_ID' + }); + }); + }); + + describe('getId', () => { + afterEach(function () { + Object.defineProperty(window, '__tnc', {value: undefined, configurable: true}); + Object.defineProperty(window, '__tncPbjs', {value: undefined, configurable: true}); + }); + + it('Should NOT give TNCID if GDPR applies but consent string is missing', function () { + const res = tncidSubModule.getId({}, { gdprApplies: true }); + expect(res).to.be.undefined; + }); + + it('GDPR is OK and page has no TNC script on page, script goes in error, no TNCID is returned', function () { + const completeCallback = sinon.spy(); + const {callback} = tncidSubModule.getId({}, consentData); + + return callback(completeCallback).then(() => { + expect(completeCallback.calledOnce).to.be.true; + }) + }); + + it('GDPR is OK and page has TNC script with ns: __tnc, present TNCID is returned', function () { + Object.defineProperty(window, '__tnc', { + value: { + ready: (readyFunc) => { readyFunc() }, + on: (name, cb) => { cb() }, + tncid: 'TNCID_TEST_ID_1', + providerId: 'TEST_PROVIDER_ID_1', + }, + configurable: true + }); + + const completeCallback = sinon.spy(); + const {callback} = tncidSubModule.getId({}, { gdprApplies: false }); + + return callback(completeCallback).then(() => { + expect(completeCallback.calledOnceWithExactly('TNCID_TEST_ID_1')).to.be.true; + }) + }); + + it('GDPR is OK and page has TNC script with ns: __tnc but not loaded, TNCID is assigned and returned', function () { + Object.defineProperty(window, '__tnc', { + value: { + ready: (readyFunc) => { readyFunc() }, + on: (name, cb) => { cb() }, + providerId: 'TEST_PROVIDER_ID_1', + }, + configurable: true + }); + + const completeCallback = sinon.spy(); + const {callback} = tncidSubModule.getId({}, { gdprApplies: false }); + + return callback(completeCallback).then(() => { + expect(completeCallback.calledOnceWithExactly(undefined)).to.be.true; + }) + }); + + it('GDPR is OK and page has TNC script with ns: __tncPbjs, TNCID is returned', function () { + Object.defineProperty(window, '__tncPbjs', { + value: { + ready: (readyFunc) => { readyFunc() }, + on: (name, cb) => { + window.__tncPbjs.tncid = 'TNCID_TEST_ID_2'; + cb(); + }, + providerId: 'TEST_PROVIDER_ID_1', + options: {}, + }, + configurable: true, + writable: true + }); + + const completeCallback = sinon.spy(); + const {callback} = tncidSubModule.getId({params: {url: 'TEST_URL'}}, consentData); + + return callback(completeCallback).then(() => { + expect(completeCallback.calledOnceWithExactly('TNCID_TEST_ID_2')).to.be.true; + }) + }); + }); +}); diff --git a/test/spec/modules/topicsFpdModule_spec.js b/test/spec/modules/topicsFpdModule_spec.js new file mode 100644 index 00000000000..bc7df85db0d --- /dev/null +++ b/test/spec/modules/topicsFpdModule_spec.js @@ -0,0 +1,517 @@ +import { + getCachedTopics, + getTopics, + getTopicsData, + loadTopicsForBidders, + processFpd, + receiveMessage, + reset, + topicStorageName +} from '../../../modules/topicsFpdModule.js'; +import {config} from 'src/config.js'; +import {deepClone, safeJSONParse} from '../../../src/utils.js'; +import {getCoreStorageManager} from 'src/storageManager.js'; +import * as activities from '../../../src/activities/rules.js'; +import {ACTIVITY_ENRICH_UFPD} from '../../../src/activities/activities.js'; + +describe('topics', () => { + beforeEach(() => { + reset(); + }); + + describe('getTopicsData', () => { + function makeTopic(topic, modelv, taxv = '1') { + return { + topic, + taxonomyVersion: taxv, + modelVersion: modelv + }; + } + + function byTaxClass(segments) { + return segments.reduce((memo, segment) => { + memo[`${segment.ext.segtax}:${segment.ext.segclass}`] = segment; + return memo; + }, {}); + } + + [ + { + t: 'no topics', + topics: [], + expected: [] + }, + { + t: 'single topic', + topics: [makeTopic(123, 'm1')], + expected: [ + { + ext: { + segtax: 600, + segclass: 'm1' + }, + segment: [ + {id: '123'} + ] + } + ] + }, + { + t: 'multiple topics with the same model version', + topics: [makeTopic(123, 'm1'), makeTopic(321, 'm1')], + expected: [ + { + ext: { + segtax: 600, + segclass: 'm1' + }, + segment: [ + {id: '123'}, + {id: '321'} + ] + } + ] + }, + { + t: 'multiple topics with different model versions', + topics: [makeTopic(1, 'm1'), makeTopic(2, 'm1'), makeTopic(3, 'm2')], + expected: [ + { + ext: { + segtax: 600, + segclass: 'm1' + }, + segment: [ + {id: '1'}, + {id: '2'} + ] + }, + { + ext: { + segtax: 600, + segclass: 'm2' + }, + segment: [ + {id: '3'} + ] + } + ] + }, + { + t: 'multiple topics, some with a taxonomy version other than "1"', + topics: [makeTopic(123, 'm1'), makeTopic(321, 'm1', 'other')], + expected: [ + { + ext: { + segtax: 600, + segclass: 'm1' + }, + segment: [ + {id: '123'} + ] + } + ] + }, + { + t: 'multiple topics in multiple taxonomies', + taxonomies: { + '1': 600, + '2': 601 + }, + topics: [ + makeTopic(123, 'm1', '1'), + makeTopic(321, 'm1', '2'), + makeTopic(213, 'm2', '1'), + ], + expected: [ + { + ext: { + segtax: 600, + segclass: 'm1' + }, + segment: [ + {id: '123'} + ] + }, + { + ext: { + segtax: 601, + segclass: 'm1', + }, + segment: [ + {id: '321'} + ] + }, + { + ext: { + segtax: 600, + segclass: 'm2' + }, + segment: [ + {id: '213'} + ] + } + ] + } + ].forEach(({t, topics, expected, taxonomies}) => { + describe(`on ${t}`, () => { + it('should convert topics to user.data segments correctly', () => { + const actual = getTopicsData('mockName', topics, taxonomies); + expect(actual.length).to.eql(expected.length); + expected = byTaxClass(expected); + Object.entries(byTaxClass(actual)).forEach(([key, datum]) => { + sinon.assert.match(datum, expected[key]); + expect(datum.name).to.equal('mockName'); + }); + }); + + it('should not set name if null', () => { + getTopicsData(null, topics).forEach((data) => { + expect(data.hasOwnProperty('name')).to.be.false; + }); + }); + }); + }); + }); + + describe('getTopics', () => { + Object.entries({ + 'document with no browsingTopics': {}, + 'document that disallows topics': { + featurePolicy: { + allowsFeature: sinon.stub().returns(false) + } + }, + 'document that throws on featurePolicy': { + browsingTopics: sinon.stub(), + get featurePolicy() { + throw new Error(); + } + }, + 'document that throws on browsingTopics': { + browsingTopics: sinon.stub().callsFake(() => { + throw new Error(); + }), + featurePolicy: { + allowsFeature: sinon.stub().returns(true) + } + }, + }).forEach(([t, doc]) => { + it(`should resolve to an empty list on ${t}`, () => { + return getTopics(doc).then((topics) => { + expect(topics).to.eql([]); + }); + }); + }); + + it('should call `document.browsingTopics` when allowed', () => { + const topics = ['t1', 't2']; + return getTopics({ + browsingTopics: sinon.stub().returns(Promise.resolve(topics)), + featurePolicy: { + allowsFeature: sinon.stub().returns(true) + } + }).then((actual) => { + expect(actual).to.eql(topics); + }); + }); + }); + + describe('processFpd', () => { + const mockData = [ + { + name: 'domain', + segment: [{id: 123}] + }, + { + name: 'domain', + segment: [{id: 321}] + } + ]; + + it('should add topics data', () => { + return processFpd({}, {global: {}}, {data: Promise.resolve(mockData)}) + .then(({global}) => { + expect(global.user.data).to.eql(mockData); + }); + }); + + it('should apppend to existing user.data', () => { + const global = { + user: { + data: [ + {name: 'preexisting'}, + ] + } + }; + return processFpd({}, {global: deepClone(global)}, {data: Promise.resolve(mockData)}) + .then((data) => { + expect(data.global.user.data).to.eql(global.user.data.concat(mockData)); + }); + }); + + it('should not modify fpd when there is no data', () => { + return processFpd({}, {global: {}}, {data: Promise.resolve([])}) + .then((data) => { + expect(data.global).to.eql({}); + }); + }); + }); + + describe('loadTopicsForBidders', () => { + beforeEach(() => { + config.setConfig({ + userSync: { + topics: { + bidders: [{ + bidder: 'mockBidder', + iframeURL: 'https://mock.iframe' + }] + } + } + }) + }); + afterEach(() => { + config.resetConfig(); + }) + + Object.entries({ + 'support': {}, + 'allow': { + browsingTopics: true, + featurePolicy: { + allowsFeature(feature) { + return feature !== 'browsing-topics'; + } + } + }, + }).forEach(([t, doc]) => { + it(`does not attempt to load frames if browser does not ${t} topics`, () => { + doc.createElement = sinon.stub(); + loadTopicsForBidders(doc); + sinon.assert.notCalled(doc.createElement); + }); + }); + }); + + describe('getCachedTopics()', () => { + const storage = getCoreStorageManager('topicsFpd'); + const expected = [{ + ext: { + segtax: 600, + segclass: '2206021246' + }, + segment: [{ + 'id': '243' + }, { + 'id': '265' + }], + name: 'ads.pubmatic.com' + }]; + const consentString = 'CPi8wgAPi8wgAADABBENCrCsAP_AAH_AAAAAISNB7D=='; + const consentConfig = { + consentString: consentString, + gdprApplies: true, + vendorData: { + metadata: consentString, + gdprApplies: true, + purpose: { + consents: { + 1: true, + 2: true, + 3: true, + 4: true + } + } + } + }; + const mockData = [ + { + name: 'domain', + segment: [{id: 123}] + }, + { + name: 'domain', + segment: [{id: 321}], + } + ]; + + const evt = { + data: '{"segment":{"domain":"ads.pubmatic.com","topics":[{"configVersion":"chrome.1","modelVersion":"2206021246","taxonomyVersion":"1","topic":165,"version":"chrome.1:1:2206021246"}],"bidder":"pubmatic"},"date":1669743901858}', + origin: 'https://ads.pubmatic.com' + }; + + afterEach(() => { + storage.removeDataFromLocalStorage(topicStorageName); + }); + + describe('when cached data is available and not expired', () => { + let sandbox; + beforeEach(() => { + sandbox = sinon.sandbox.create(); + const storedSegments = JSON.stringify( + [['pubmatic', { + '2206021246': { + 'ext': {'segtax': 600, 'segclass': '2206021246'}, + 'segment': [{'id': '243'}, {'id': '265'}], + 'name': 'ads.pubmatic.com' + }, + 'lastUpdated': new Date().getTime() + }]] + ); + storage.setDataInLocalStorage(topicStorageName, storedSegments); + }); + afterEach(() => { + sandbox.restore(); + }); + + it('should return segments for bidder if transmitUfpd is allowed', () => { + assert.deepEqual(getCachedTopics(), expected); + }); + + it('should NOT return segments for bidder if enrichUfpd is NOT allowed', () => { + sandbox.stub(activities, 'isActivityAllowed').callsFake((activity, params) => { + return !(activity === ACTIVITY_ENRICH_UFPD && params.component === 'bidder.pubmatic'); + }); + expect(getCachedTopics()).to.eql([]); + }); + }) + + it('should return empty segments for bidder if there is cached segments stored which is expired', () => { + let storedSegments = '[["pubmatic",{"2206021246":{"ext":{"segtax":600,"segclass":"2206021246"},"segment":[{"id":"243"},{"id":"265"}],"name":"ads.pubmatic.com"},"lastUpdated":10}]]'; + storage.setDataInLocalStorage(topicStorageName, storedSegments); + assert.deepEqual(getCachedTopics(), []); + }); + + describe('cross-frame messages', () => { + beforeEach(() => { + // init iframe logic so that the receiveMessage origin check passes + loadTopicsForBidders({ + browsingTopics: true, + featurePolicy: { + allowsFeature() { return true } + }, + createElement: sinon.stub().callsFake(() => ({style: {}})), + documentElement: { + appendChild() {} + } + }); + }); + + it('should store segments if receiveMessage event is triggered with segment data', () => { + receiveMessage(evt); + let segments = new Map(safeJSONParse(storage.getDataFromLocalStorage(topicStorageName))); + expect(segments.has('pubmatic')).to.equal(true); + }); + + it('should update stored segments if receiveMessage event is triggerred with segment data', () => { + let storedSegments = '[["pubmatic",{"2206021246":{"ext":{"segtax":600,"segclass":"2206021246"},"segment":[{"id":"243"},{"id":"265"}],"name":"ads.pubmatic.com"},"lastUpdated":1669719242027}]]'; + storage.setDataInLocalStorage(topicStorageName, storedSegments); + receiveMessage(evt); + let segments = new Map(safeJSONParse(storage.getDataFromLocalStorage(topicStorageName))); + expect(segments.get('pubmatic')[2206021246].segment.length).to.equal(1); + }); + }); + }); +}); + +describe('handles fetch request for topics api headers', () => { + let stubbedFetch; + const storage = getCoreStorageManager('topicsFpd'); + + beforeEach(() => { + stubbedFetch = sinon.stub(window, 'fetch'); + }); + + afterEach(() => { + stubbedFetch.restore(); + storage.removeDataFromLocalStorage(topicStorageName); + }); + + it('should make a fetch call when a fetchUrl is present for a selected bidder', () => { + config.setConfig({ + userSync: { + topics: { + maxTopicCaller: 3, + bidders: [ + { + bidder: 'pubmatic', + fetchUrl: 'http://localhost:3000/topics-server.js' + } + ], + }, + } + }); + + stubbedFetch.returns(Promise.resolve(true)); + loadTopicsForBidders({ + browsingTopics: true, + featurePolicy: { + allowsFeature() { return true } + } + }); + sinon.assert.calledOnce(stubbedFetch); + stubbedFetch.calledWith('http://localhost:3000/topics-server.js'); + }); + + it('should not make a fetch call when a fetchUrl is not present for a selected bidder', () => { + config.setConfig({ + userSync: { + topics: { + maxTopicCaller: 3, + bidders: [ + { + bidder: 'pubmatic' + } + ], + }, + } + }); + + loadTopicsForBidders({ + browsingTopics: true, + featurePolicy: { + allowsFeature() { return true } + } + }); + sinon.assert.notCalled(stubbedFetch); + }); + + it('a fetch request should not be made if the configured fetch rate duration has not yet passed', () => { + const storedSegments = JSON.stringify( + [['pubmatic', { + '2206021246': { + 'ext': {'segtax': 600, 'segclass': '2206021246'}, + 'segment': [{'id': '243'}, {'id': '265'}], + 'name': 'ads.pubmatic.com' + }, + 'lastUpdated': new Date().getTime() + }]] + ); + + storage.setDataInLocalStorage(topicStorageName, storedSegments); + + config.setConfig({ + userSync: { + topics: { + maxTopicCaller: 3, + bidders: [ + { + bidder: 'pubmatic', + fetchUrl: 'http://localhost:3000/topics-server.js', + fetchRate: 1 // in days. 1 fetch per day + } + ], + }, + } + }); + + loadTopicsForBidders({ + browsingTopics: true, + featurePolicy: { + allowsFeature() { return true } + } + }); + sinon.assert.notCalled(stubbedFetch); + }); +}); diff --git a/test/spec/modules/tpmnBidAdapter_spec.js b/test/spec/modules/tpmnBidAdapter_spec.js index b4f6882dbe1..e2b14b18f61 100644 --- a/test/spec/modules/tpmnBidAdapter_spec.js +++ b/test/spec/modules/tpmnBidAdapter_spec.js @@ -1,9 +1,39 @@ /* eslint-disable no-tabs */ -import { expect } from 'chai'; -import { spec } from 'modules/tpmnBidAdapter.js'; +import {expect} from 'chai'; +import {spec, storage} from 'modules/tpmnBidAdapter.js'; +import {generateUUID} from '../../../src/utils.js'; +import {newBidder} from '../../../src/adapters/bidderFactory'; +import * as sinon from 'sinon'; -describe('tpmnAdapterTests', function() { - describe('isBidRequestValid', function() { +describe('tpmnAdapterTests', function () { + const adapter = newBidder(spec); + const BIDDER_CODE = 'tpmn'; + let sandbox = sinon.sandbox.create(); + let getCookieStub; + + beforeEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + tpmn: { + storageAllowed: true + } + }; + sandbox = sinon.sandbox.create(); + getCookieStub = sinon.stub(storage, 'getCookie'); + }); + + afterEach(function () { + sandbox.restore(); + getCookieStub.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function') + }) + }); + + describe('isBidRequestValid', function () { let bid = { adUnitCode: 'temp-unitcode', bidder: 'tpmn', @@ -20,17 +50,18 @@ describe('tpmnAdapterTests', function() { } } }; - it('should return true if a bid is valid banner bid request', function() { + + it('should return true if a bid is valid banner bid request', function () { expect(spec.isBidRequestValid(bid)).to.be.equal(true); }); - it('should return false where requried param is missing', function() { + it('should return false where requried param is missing', function () { let bid = Object.assign({}, bid); bid.params = {}; expect(spec.isBidRequestValid(bid)).to.be.equal(false); }); - it('should return false when required param values have invalid type', function() { + it('should return false when required param values have invalid type', function () { let bid = Object.assign({}, bid); bid.params = { 'inventoryId': null, @@ -40,14 +71,14 @@ describe('tpmnAdapterTests', function() { }); }); - describe('buildRequests', function() { - it('should return an empty list if there are no bid requests', function() { + describe('buildRequests', function () { + it('should return an empty list if there are no bid requests', function () { const emptyBidRequests = []; const bidderRequest = {}; const request = spec.buildRequests(emptyBidRequests, bidderRequest); expect(request).to.be.an('array').that.is.empty; }); - it('should generate a POST server request with bidder API url, data', function() { + it('should generate a POST server request with bidder API url, data', function () { const bid = { adUnitCode: 'temp-unitcode', bidder: 'tpmn', @@ -65,13 +96,15 @@ describe('tpmnAdapterTests', function() { } }; const tempBidRequests = [bid]; - const tempBidderRequest = {refererInfo: { - referer: 'http://localhost/test', - site: { - domain: 'localhost', - page: 'http://localhost/test' + const tempBidderRequest = { + refererInfo: { + page: 'http://localhost/test', + site: { + domain: 'localhost', + page: 'http://localhost/test' + } } - }}; + }; const builtRequest = spec.buildRequests(tempBidRequests, tempBidderRequest); expect(builtRequest).to.have.lengthOf(1); @@ -96,7 +129,7 @@ describe('tpmnAdapterTests', function() { }); }); - describe('interpretResponse', function() { + describe('interpretResponse', function () { const bid = { adUnitCode: 'temp-unitcode', bidder: 'tpmn', @@ -115,12 +148,12 @@ describe('tpmnAdapterTests', function() { }; const tempBidRequests = [bid]; - it('should return an empty aray to indicate no valid bids', function() { + it('should return an empty aray to indicate no valid bids', function () { const emptyServerResponse = {}; const bidResponses = spec.interpretResponse(emptyServerResponse, tempBidRequests); expect(bidResponses).is.an('array').that.is.empty; }); - it('should return an empty array to indicate no valid bids', function() { + it('should return an empty array to indicate no valid bids', function () { const mockBidResult = { requestId: '9cf19229-34f6-4d06-bc1d-0e44e8d616c8', cpm: 10.0, @@ -141,4 +174,36 @@ describe('tpmnAdapterTests', function() { expect(bidResponses).deep.equal([mockBidResult]); }); }); + + describe('getUserSync', function () { + const KEY_ID = 'uuid'; + const TMP_UUID = generateUUID().replace(/-/g, ''); + + it('getCookie mock Test', () => { + const uuid = storage.getCookie(KEY_ID); + expect(uuid).to.equal(undefined); + }); + + it('getCookie mock Test', () => { + expect(TMP_UUID.length).to.equal(32); + getCookieStub.withArgs(KEY_ID).returns(TMP_UUID); + const uuid = storage.getCookie(KEY_ID); + expect(uuid).to.equal(TMP_UUID); + }); + + it('case 1 -> allow iframe', () => { + const syncs = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: true}); + expect(syncs.length).to.equal(1); + expect(syncs[0].type).to.equal('iframe'); + }); + + it('case 2 -> allow pixel with static sync', () => { + const syncs = spec.getUserSyncs({ iframeEnabled: false, pixelEnabled: true }); + expect(syncs.length).to.be.equal(4); + expect(syncs[0].type).to.be.equal('image'); + expect(syncs[1].type).to.be.equal('image'); + expect(syncs[2].type).to.be.equal('image'); + expect(syncs[3].type).to.be.equal('image'); + }); + }); }); diff --git a/test/spec/modules/trafficgateBidAdapter_spec.js b/test/spec/modules/trafficgateBidAdapter_spec.js new file mode 100644 index 00000000000..11ff547cc78 --- /dev/null +++ b/test/spec/modules/trafficgateBidAdapter_spec.js @@ -0,0 +1,1373 @@ +import {expect} from 'chai'; +import {spec} from 'modules/trafficgateBidAdapter'; +import {newBidder} from 'src/adapters/bidderFactory.js'; +import {BANNER, VIDEO} from 'src/mediaTypes.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import 'src/prebid.js' +import 'modules/currency.js'; +import 'modules/userId/index.js'; +import 'modules/multibid/index.js'; +import 'modules/priceFloors.js'; +import 'modules/consentManagement.js'; +import 'modules/consentManagementUsp.js'; +import 'modules/schain.js'; +import {deepClone} from 'src/utils.js'; +import {syncAddFPDToBidderRequest} from '../../helpers/fpd.js'; +import {hook} from '../../../src/hook.js'; + +const BidRequestBuilder = function BidRequestBuilder(options) { + const defaults = { + request: { + auctionId: '4fd1ca2d-846c-4211-b9e5-321dfe1709c9', + adUnitCode: 'adunit-code', + bidder: 'trafficgate' + }, + params: { + placementId: '98765', + host: 'example' + }, + sizes: [[300, 250], [300, 600]], + }; + + const request = { + ...defaults.request, + ...options + }; + + this.withParams = (options) => { + request.params = { + ...defaults.params, + ...options + }; + return this; + }; + + this.build = () => request; +}; + +const BidderRequestBuilder = function BidderRequestBuilder(options) { + const defaults = { + bidderCode: 'trafficgate', + auctionId: '4fd1ca2d-846c-4211-b9e5-321dfe1709c9', + bidderRequestId: '7g36s867Tr4xF90X', + timeout: 3000, + refererInfo: { + numIframes: 0, + reachedTop: true, + referer: 'http://test.io/index.html?pbjs_debug=true' + } + }; + + const request = { + ...defaults, + ...options + }; + + this.build = () => request; +}; + +describe('TrafficgateOpenxRtbAdapter', function () { + before(() => { + hook.ready(); + }); + + const adapter = newBidder(spec); + + describe('inherited functions', function () { + it('exists and is a function', function () { + expect(adapter.callBids).to.exist.and.to.be.a('function'); + }); + }); + + describe('isBidRequestValid()', function () { + describe('when request is for a banner ad', function () { + let bannerBid; + beforeEach(function () { + bannerBid = { + bidder: 'trafficgate', + params: {}, + adUnitCode: 'adunit-code', + mediaTypes: {banner: {}}, + sizes: [[300, 250], [300, 600]], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475' + }; + }); + + it('should return false when there is placementId only', function () { + bannerBid.params = {'placementId': '98765'}; + expect(spec.isBidRequestValid(bannerBid)).to.equal(false); + }); + + describe('should return false when there is a host only', function () { + beforeEach(function () { + bannerBid.params = {host: 'test-delivery-domain'} + }); + + it('should return false when there is no placementId and size', function () { + expect(spec.isBidRequestValid(bannerBid)).to.equal(false); + }); + + it('should return false if there is an placementId without sizes', function () { + bannerBid.params.placementId = '98765'; + expect(spec.isBidRequestValid(bannerBid)).to.equal(false); + }); + + it('should return false if there is no placementId and sizes are defined', function () { + bannerBid.mediaTypes.banner.sizes = [720, 90]; + expect(spec.isBidRequestValid(bannerBid)).to.equal(false); + }); + + it('should return false if no sizes are defined ', function () { + expect(spec.isBidRequestValid(bannerBid)).to.equal(false); + }); + + it('should return false if sizes empty ', function () { + bannerBid.mediaTypes.banner.sizes = []; + expect(spec.isBidRequestValid(bannerBid)).to.equal(false); + }); + + it('should return true if there is placementId and sizes are defined', function () { + bannerBid.params.placementId = '98765'; + bannerBid.mediaTypes.banner.sizes = [720, 90]; + expect(spec.isBidRequestValid(bannerBid)).to.equal(true); + }); + }); + }); + + describe('when request is for a multiformat ad', function () { + describe('and request config uses mediaTypes video and banner', () => { + const multiformatBid = { + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250]] + }, + video: { + playerSize: [300, 250] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' + }; + it('should return true multisize when required params found', function () { + expect(spec.isBidRequestValid(multiformatBid)).to.equal(true); + }); + }); + }); + + describe('when request is for a video ad', function () { + describe('and request config uses mediaTypes', () => { + const videoBidWithMediaTypes = { + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' + }; + it('should return false when isBannerBid', function () { + expect(spec.isBannerBid(videoBidWithMediaTypes)).to.equal(false); + }); + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let videoBidWithMediaTypes = Object.assign({}, videoBidWithMediaTypes); + videoBidWithMediaTypes.params = {}; + expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false); + }); + }); + describe('and request config uses both host and platform', () => { + const videoBidWithHostAndPlacement = { + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + transactionId: '4008d88a-8137-410b-aa35-fbfdabcb478e' + }; + it('should return false when isBannerBid', function () { + expect(spec.isBannerBid(videoBidWithHostAndPlacement)).to.equal(false); + }); + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(videoBidWithHostAndPlacement)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let videoBidWithMediaTypes = Object.assign({}, videoBidWithHostAndPlacement); + videoBidWithMediaTypes.params = {}; + expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false); + }); + }); + describe('and request config uses mediaType', () => { + const videoBidWithMediaType = { + 'bidder': 'trafficgate', + 'params': { + 'placementId': '98765', + 'host': 'example' + }, + 'adUnitCode': 'adunit-code', + 'mediaType': 'video', + 'sizes': [640, 480], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' + }; + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let videoBidWithMediaType = Object.assign({}, videoBidWithMediaType); + delete videoBidWithMediaType.params; + videoBidWithMediaType.params = {}; + expect(spec.isBidRequestValid(videoBidWithMediaType)).to.equal(false); + }); + }); + }); + }); + + describe('buildRequests()', function () { + let bidRequestsWithMediaTypes; + let bidRequestsWithPlatform; + let mockBidderRequest; + + beforeEach(function () { + mockBidderRequest = {refererInfo: {}}; + + bidRequestsWithMediaTypes = [{ + bidder: 'trafficgate', + params: { + placementId: '11', + host: 'example', + }, + adUnitCode: '/adunit-code/test-path', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + transactionId: 'test-transactionId-1', + ortb2Imp: { + ext: { + ae: 2 + } + } + }, { + bidder: 'trafficgate', + params: { + placementId: '22', + host: 'example', + }, + adUnitCode: 'adunit-code', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + bidId: 'test-bid-id-2', + bidderRequestId: 'test-bid-request-2', + auctionId: 'test-auction-2', + transactionId: 'test-transactionId-2' + }]; + }); + + context('common requests checks', function() { + it('should be able to handle multiformat requests', () => { + const multiformat = utils.deepClone(bidRequestsWithMediaTypes[0]); + multiformat.mediaTypes.video = { + context: 'outstream', + playerSize: [640, 480] + } + const requests = spec.buildRequests([multiformat], mockBidderRequest); + const outgoingFormats = requests.flatMap(rq => rq.data.imp.flatMap(imp => ['banner', 'video'].filter(k => imp[k] != null))); + const expected = FEATURES.VIDEO ? ['banner', 'video'] : ['banner'] + expect(outgoingFormats).to.have.members(expected); + }) + + it('should send bid request to trafficgate url via POST', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].url).to.equal('https://example.bc-plugin.com/prebidjs'); + expect(request[0].method).to.equal('POST'); + }); + + it('should send delivery domain, if available', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.imp[0].ext.bidder.host).to.equal(bidRequestsWithMediaTypes[0].params.host); + expect(request[1].data.imp[0].ext.bidder.host).to.equal(bidRequestsWithMediaTypes[1].params.host); + }); + + it('should send placementId', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.imp[0].ext.bidder.placementId).to.equal(bidRequestsWithMediaTypes[0].params.placementId); + expect(request[1].data.imp[0].ext.bidder.placementId).to.equal(bidRequestsWithMediaTypes[1].params.placementId); + }); + + describe('floors', function () { + it('should send out custom floors on bids that have customFloors, no currency as account currency is used', function () { + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + params: { + placementId: '98765', + host: 'example', + customFloor: 1.500 + } + } + ); + + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].bidfloor).to.equal(bidRequest.params.customFloor); + expect(request[0].data.imp[0].bidfloorcur).to.equal(undefined); + }); + + context('with floors module', function () { + let adServerCurrencyStub; + + beforeEach(function () { + adServerCurrencyStub = sinon + .stub(config, 'getConfig') + .withArgs('currency.adServerCurrency') + }); + + afterEach(function () { + config.getConfig.restore(); + }); + + it('should send out floors on bids in USD', function () { + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + getFloor: () => { + return { + currency: 'USD', + floor: 9.99 + } + } + } + ); + + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].bidfloor).to.equal(9.99); + expect(request[0].data.imp[0].bidfloorcur).to.equal('USD'); + }); + + it('should send not send floors', function () { + adServerCurrencyStub.returns('EUR'); + const bidRequest = Object.assign({}, + bidRequestsWithMediaTypes[0], + { + getFloor: () => { + return { + currency: 'BTC', + floor: 9.99 + } + } + } + ); + + const request = spec.buildRequests([bidRequest], mockBidderRequest); + expect(request[0].data.imp[0].bidfloor).to.equal(undefined) + expect(request[0].data.imp[0].bidfloorcur).to.equal(undefined) + }); + }) + }) + + describe('FPD', function() { + let bidRequests; + const mockBidderRequest = {refererInfo: {}}; + + beforeEach(function () { + bidRequests = [{ + bidder: 'trafficgate', + params: { + placementId: '98765-banner', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-1' + }, { + bidder: 'trafficgate', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + params: { + placementId: '98765-video', + host: 'example' + }, + 'adUnitCode': 'adunit-code', + + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-2' + }]; + }); + + it('ortb2.site should be merged in the request', function() { + const request = spec.buildRequests(bidRequests, { + ...mockBidderRequest, + 'ortb2': { + site: { + domain: 'page.example.com', + cat: ['IAB2'], + sectioncat: ['IAB2-2'] + } + } + }); + let data = request[0].data; + expect(data.site.domain).to.equal('page.example.com'); + expect(data.site.cat).to.deep.equal(['IAB2']); + expect(data.site.sectioncat).to.deep.equal(['IAB2-2']); + }); + + it('ortb2.user should be merged in the request', function() { + const request = spec.buildRequests(bidRequests, { + ...mockBidderRequest, + 'ortb2': { + user: { + yob: 1985 + } + } + }); + let data = request[0].data; + expect(data.user.yob).to.equal(1985); + }); + + describe('ortb2Imp', function() { + describe('ortb2Imp.ext.data.pbadslot', function() { + beforeEach(function () { + if (bidRequests[0].hasOwnProperty('ortb2Imp')) { + delete bidRequests[0].ortb2Imp; + } + }); + + it('should not send if imp[].ext.data object is invalid', function() { + bidRequests[0].ortb2Imp = { + ext: {} + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext).to.not.have.property('data'); + }); + + it('should not send if imp[].ext.data.pbadslot is undefined', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + if (data.imp[0].ext.data) { + expect(data.imp[0].ext.data).to.not.have.property('pbadslot'); + } else { + expect(data.imp[0].ext).to.not.have.property('data'); + } + }); + + it('should send if imp[].ext.data.pbadslot is string', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + pbadslot: 'abcd' + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext.data).to.have.property('pbadslot'); + expect(data.imp[0].ext.data.pbadslot).to.equal('abcd'); + }); + }); + + describe('ortb2Imp.ext.data.adserver', function() { + beforeEach(function () { + if (bidRequests[0].hasOwnProperty('ortb2Imp')) { + delete bidRequests[0].ortb2Imp; + } + }); + + it('should not send if imp[].ext.data object is invalid', function() { + bidRequests[0].ortb2Imp = { + ext: {} + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext).to.not.have.property('data'); + }); + + it('should not send if imp[].ext.data.adserver is undefined', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + if (data.imp[0].ext.data) { + expect(data.imp[0].ext.data).to.not.have.property('adserver'); + } else { + expect(data.imp[0].ext).to.not.have.property('data'); + } + }); + + it('should send', function() { + let adSlotValue = 'abc'; + bidRequests[0].ortb2Imp = { + ext: { + data: { + adserver: { + name: 'GAM', + adslot: adSlotValue + } + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext.data.adserver.name).to.equal('GAM'); + expect(data.imp[0].ext.data.adserver.adslot).to.equal(adSlotValue); + }); + }); + + describe('ortb2Imp.ext.data.other', function() { + beforeEach(function () { + if (bidRequests[0].hasOwnProperty('ortb2Imp')) { + delete bidRequests[0].ortb2Imp; + } + }); + + it('should not send if imp[].ext.data object is invalid', function() { + bidRequests[0].ortb2Imp = { + ext: {} + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext).to.not.have.property('data'); + }); + + it('should not send if imp[].ext.data.other is undefined', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + if (data.imp[0].ext.data) { + expect(data.imp[0].ext.data).to.not.have.property('other'); + } else { + expect(data.imp[0].ext).to.not.have.property('data'); + } + }); + + it('ortb2Imp.ext.data.other', function() { + bidRequests[0].ortb2Imp = { + ext: { + data: { + other: 1234 + } + } + }; + const request = spec.buildRequests(bidRequests, mockBidderRequest); + let data = request[0].data; + expect(data.imp[0].ext.data.other).to.equal(1234); + }); + }); + }); + + describe('with user agent client hints', function () { + it('should add device.sua if available', function () { + const bidderRequestWithUserAgentClientHints = { refererInfo: {}, + ortb2: { + device: { + sua: { + source: 2, + platform: { + brand: 'macOS', + version: [ '12', '4', '0' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Not;A=Brand', + version: [ '99', '0', '0', '0' ] + }], + mobile: 0, + model: 'Pro', + bitness: '64', + architecture: 'x86' + } + } + }}; + + let request = spec.buildRequests(bidRequests, bidderRequestWithUserAgentClientHints); + expect(request[0].data.device.sua).to.exist; + expect(request[0].data.device.sua).to.deep.equal(bidderRequestWithUserAgentClientHints.ortb2.device.sua); + const bidderRequestWithoutUserAgentClientHints = {refererInfo: {}, ortb2: {}}; + request = spec.buildRequests(bidRequests, bidderRequestWithoutUserAgentClientHints); + expect(request[0].data.device?.sua).to.not.exist; + }); + }); + }); + + context('when there is a consent management framework', function () { + let bidRequests; + let mockConfig; + let bidderRequest; + + beforeEach(function () { + bidRequests = [{ + bidder: 'trafficgate', + params: { + placementId: '98765-banner', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-1' + }, { + bidder: 'trafficgate', + mediaTypes: { + video: { + playerSize: [640, 480] + } + }, + params: { + placementId: '98765-video', + host: 'example' + }, + 'adUnitCode': 'adunit-code', + + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id', + transactionId: 'test-transaction-id-2' + }]; + }); + + describe('us_privacy', function () { + beforeEach(function () { + bidderRequest = { + uspConsent: '1YYN', + refererInfo: {} + }; + + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + }); + + afterEach(function () { + config.getConfig.restore(); + }); + + it('should send a signal to specify that US Privacy applies to this request', function () { + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs.ext.us_privacy).to.equal('1YYN'); + expect(request[1].data.regs.ext.us_privacy).to.equal('1YYN'); + }); + + it('should not send the regs object, when consent string is undefined', function () { + delete bidderRequest.uspConsent; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs?.us_privacy).to.not.exist; + }); + }); + + describe('GDPR', function () { + beforeEach(function () { + bidderRequest = { + gdprConsent: { + consentString: 'test-gdpr-consent-string', + addtlConsent: 'test-addtl-consent-string', + gdprApplies: true + }, + refererInfo: {} + }; + + mockConfig = { + consentManagement: { + cmpApi: 'iab', + timeout: 1111, + allowAuctionWithoutConsent: 'cancel' + } + }; + + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + }); + + afterEach(function () { + config.getConfig.restore(); + }); + + it('should send a signal to specify that GDPR applies to this request', function () { + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs.ext.gdpr).to.equal(1); + expect(request[1].data.regs.ext.gdpr).to.equal(1); + }); + + it('should send the consent string', function () { + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + expect(request[1].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + }); + + it('should send the addtlConsent string', function () { + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.user.ext.ConsentedProvidersSettings.consented_providers).to.equal(bidderRequest.gdprConsent.addtlConsent); + expect(request[1].data.user.ext.ConsentedProvidersSettings.consented_providers).to.equal(bidderRequest.gdprConsent.addtlConsent); + }); + + it('should send a signal to specify that GDPR does not apply to this request', function () { + bidderRequest.gdprConsent.gdprApplies = false; + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs.ext.gdpr).to.equal(0); + expect(request[1].data.regs.ext.gdpr).to.equal(0); + }); + + it('when GDPR application is undefined, should not send a signal to specify whether GDPR applies to this request, ' + + 'but can send consent data, ', function () { + delete bidderRequest.gdprConsent.gdprApplies; + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.regs?.ext?.gdpr).to.not.be.ok; + expect(request[0].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + expect(request[1].data.user.ext.consent).to.equal(bidderRequest.gdprConsent.consentString); + }); + + it('when consent string is undefined, should not send the consent string, ', function () { + delete bidderRequest.gdprConsent.consentString; + bidderRequest.bids = bidRequests; + const request = spec.buildRequests(bidRequests, syncAddFPDToBidderRequest(bidderRequest)); + expect(request[0].data.imp[0].ext.consent).to.equal(undefined); + expect(request[1].data.imp[0].ext.consent).to.equal(undefined); + }); + }); + }); + + context('coppa', function() { + it('when there are no coppa param settings, should not send a coppa flag', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.regs?.coppa).to.be.not.ok; + }); + + it('should send a coppa flag there is when there is coppa param settings in the bid requests', function () { + let mockConfig = { + coppa: true + }; + + sinon.stub(config, 'getConfig').callsFake((key) => { + return utils.deepAccess(mockConfig, key); + }); + + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.regs.coppa).to.equal(1); + }); + + it('should send a coppa flag there is when there is coppa param settings in the bid params', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + request.params = {coppa: true}; + expect(request[0].data.regs.coppa).to.equal(1); + }); + + after(function () { + config.getConfig.restore() + }); + }); + + context('do not track (DNT)', function() { + let doNotTrackStub; + + beforeEach(function () { + doNotTrackStub = sinon.stub(utils, 'getDNT'); + }); + afterEach(function() { + doNotTrackStub.restore(); + }); + + it('when there is a do not track, should send a dnt', function () { + doNotTrackStub.returns(1); + + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.device.dnt).to.equal(1); + }); + + it('when there is not do not track, don\'t send dnt', function () { + doNotTrackStub.returns(0); + + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.device.dnt).to.equal(0); + }); + + it('when there is no defined do not track, don\'t send dnt', function () { + doNotTrackStub.returns(null); + + const request = spec.buildRequests(bidRequestsWithMediaTypes, syncAddFPDToBidderRequest(mockBidderRequest)); + expect(request[0].data.device.dnt).to.equal(0); + }); + }); + + context('supply chain (schain)', function () { + let bidRequests; + let schainConfig; + const supplyChainNodePropertyOrder = ['asi', 'sid', 'hp', 'rid', 'name', 'domain']; + + beforeEach(function () { + schainConfig = { + ver: '1.0', + complete: 1, + nodes: [ + { + asi: 'exchange1.com', + sid: '1234', + hp: 1, + rid: 'bid-request-1', + name: 'publisher', + domain: 'publisher.com' + // omitted ext + }, + { + asi: 'exchange2.com', + sid: 'abcd', + hp: 1, + rid: 'bid-request-2', + // name field missing + domain: 'intermediary.com' + }, + { + asi: 'exchange3.com', + sid: '4321', + hp: 1, + // request id + // name field missing + domain: 'intermediary-2.com' + } + ] + }; + + bidRequests = [{ + bidder: 'trafficgate', + params: { + placementId: '11', + host: 'example' + }, + adUnitCode: '/adunit-code/test-path', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + schain: schainConfig + }]; + }); + + it('should send a supply chain object', function () { + const request = spec.buildRequests(bidRequests, mockBidderRequest); + expect(request[0].data.source.ext.schain).to.equal(schainConfig); + }); + + it('should send the supply chain object with the right version', function () { + const request = spec.buildRequests(bidRequests, mockBidderRequest); + expect(request[0].data.source.ext.schain.ver).to.equal(schainConfig.ver); + }); + + it('should send the supply chain object with the right complete value', function () { + const request = spec.buildRequests(bidRequests, mockBidderRequest); + expect(request[0].data.source.ext.schain.complete).to.equal(schainConfig.complete); + }); + }); + + context('when there are userid providers', function () { + const userIdAsEids = [ + { + source: 'adserver.org', + uids: [{ + id: 'some-random-id-value', + atype: 1, + ext: { + rtiPartner: 'TDID' + } + }] + }, + { + source: 'id5-sync.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }, + { + source: 'sharedid.org', + uids: [{ + id: 'some-random-id-value', + atype: 1, + ext: { + third: 'some-random-id-value' + } + }] + } + ]; + + it(`should send the user id under the extended ids`, function () { + const bidRequestsWithUserId = [{ + bidder: 'trafficgate', + params: { + placementId: '11', + host: 'example' + }, + userId: { + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]] + } + }, + bidId: 'test-bid-id-1', + bidderRequestId: 'test-bid-request-1', + auctionId: 'test-auction-1', + userIdAsEids: userIdAsEids + }]; + // enrich bid request with userId key/value + + const request = spec.buildRequests(bidRequestsWithUserId, mockBidderRequest); + expect(request[0].data.user.ext.eids).to.equal(userIdAsEids); + }); + + it(`when no user ids are available, it should not send any extended ids`, function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data).to.not.have.any.keys('user'); + }); + }); + + context('FLEDGE', function() { + it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, { + ...mockBidderRequest, + fledgeEnabled: true + }); + expect(request[0].data.imp[0].ext.ae).to.equal(2); + }); + }); + }); + + context('banner', function () { + it('should send bid request with a mediaTypes specified with banner type', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[0].data.imp[0]).to.have.any.keys(BANNER); + }); + }); + + if (FEATURES.VIDEO) { + context('video', function () { + it('should send bid request with a mediaTypes specified with video type', function () { + const request = spec.buildRequests(bidRequestsWithMediaTypes, mockBidderRequest); + expect(request[1].data.imp[0]).to.have.any.keys(VIDEO); + }); + + it('Update imp.video with OpenRTB options from mimeTypes and params', function() { + const bid01 = new BidRequestBuilder({ + adUnitCode: 'adunit-code-01', + mediaTypes: { + banner: { sizes: [[300, 250]] }, + video: { + context: 'outstream', + playerSize: [[300, 250]], + mimes: ['video/mp4'], + protocols: [8] + } + }, + }).withParams({ + // options in video, will merge + video: { + skip: 1, + skipafter: 4, + minduration: 10, + maxduration: 30 + } + }).build(); + + const bidderRequest = new BidderRequestBuilder().build(); + const expected = { + mimes: ['video/mp4'], + skip: 1, + skipafter: 4, + minduration: 10, + maxduration: 30, + placement: 4, + protocols: [8], + w: 300, + h: 250 + }; + const requests = spec.buildRequests([bid01], bidderRequest); + expect(requests).to.have.lengthOf(2); + expect(requests[1].data.imp[0].video).to.deep.equal(expected); + }); + }); + } + }); + + describe('interpretResponse()', function () { + let bidRequestConfigs; + let bidRequest; + let bidResponse; + let bid; + + context('when there is an nbr response', function () { + let bids; + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = {nbr: 0}; // Unknown error + bids = spec.interpretResponse({body: bidResponse}, bidRequest); + }); + + it('should not return any bids', function () { + expect(bids.length).to.equal(0); + }); + }); + + context('when no seatbid in response', function () { + let bids; + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = {ext: {}, id: 'test-bid-id'}; + bids = spec.interpretResponse({body: bidResponse}, bidRequest); + }); + + it('should not return any bids', function () { + expect(bids.length).to.equal(0); + }); + }); + + context('when there is no response', function () { + let bids; + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = ''; // Unknown error + bids = spec.interpretResponse({body: bidResponse}, bidRequest); + }); + + it('should not return any bids', function () { + expect(bids.length).to.equal(0); + }); + }); + + const SAMPLE_BID_REQUESTS = [{ + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + const SAMPLE_BID_RESPONSE = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 3.5, + w: 300, + h: 250, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup', + adomain: ['brand.com'], + ext: { + networkId: 123, + advertiserDomains: ['domain.com'], + } + }] + }], + cur: 'USD' + }; + + context('when there is a response, the common response properties', function () { + beforeEach(function () { + bidRequestConfigs = deepClone(SAMPLE_BID_REQUESTS); + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + bidResponse = deepClone(SAMPLE_BID_RESPONSE); + + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; + }); + + it('should return a price', function () { + expect(bid.cpm).to.equal(bidResponse.seatbid[0].bid[0].price); + }); + + it('should return a request id', function () { + expect(bid.requestId).to.equal(bidResponse.seatbid[0].bid[0].impid); + }); + + it('should return width and height for the creative', function () { + expect(bid.width).to.equal(bidResponse.seatbid[0].bid[0].w); + expect(bid.height).to.equal(bidResponse.seatbid[0].bid[0].h); + }); + + it('should return a creativeId', function () { + expect(bid.creativeId).to.equal(bidResponse.seatbid[0].bid[0].crid); + }); + + it('should return an ad', function () { + expect(bid.ad).to.equal(bidResponse.seatbid[0].bid[0].adm); + }); + + it('should return a deal id if it exists', function () { + expect(bid.dealId).to.equal(bidResponse.seatbid[0].bid[0].dealid); + }); + + it('should have a time-to-live of 5 minutes', function () { + expect(bid.ttl).to.equal(300); + }); + + it('should always return net revenue', function () { + expect(bid.netRevenue).to.equal(true); + }); + + it('should return a currency', function () { + expect(bid.currency).to.equal(bidResponse.cur); + }); + + it('should return a networkId', function () { + expect(bid.meta.networkId).to.equal(bidResponse.seatbid[0].bid[0].ext.networkId); + }); + + it('should return adomain', function () { + expect(bid.meta.advertiserDomains).to.equal(bidResponse.seatbid[0].bid[0].ext.advertiserDomains); + }); + }); + + context('when the response is a banner', function() { + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + banner: { + sizes: [[300, 250], [300, 600]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 2, + w: 300, + h: 250, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup' + }] + }], + cur: 'AUS' + }; + + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; + }); + + it('should return the proper mediaType', function () { + it('should return a creativeId', function () { + expect(bid.mediaType).to.equal(Object.keys(bidRequestConfigs[0].mediaTypes)[0]); + }); + }); + }); + + if (FEATURES.VIDEO) { + context('when the response is a video', function() { + beforeEach(function () { + bidRequestConfigs = [{ + bidder: 'trafficgate', + params: { + placementId: '98765', + host: 'example' + }, + adUnitCode: 'adunit-code', + mediaTypes: { + video: { + playerSize: [[640, 360], [854, 480]], + }, + }, + bidId: 'test-bid-id', + bidderRequestId: 'test-bidder-request-id', + auctionId: 'test-auction-id' + }]; + + bidRequest = spec.buildRequests(bidRequestConfigs, {refererInfo: {}})[0]; + + bidResponse = { + seatbid: [{ + bid: [{ + impid: 'test-bid-id', + price: 2, + w: 854, + h: 480, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup', + }] + }], + cur: 'AUS' + }; + }); + + it('should return the proper mediaType', function () { + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; + expect(bid.mediaType).to.equal(Object.keys(bidRequestConfigs[0].mediaTypes)[0]); + }); + + it('should return the proper mediaType', function () { + const winUrl = 'https//my.win.url'; + bidResponse.seatbid[0].bid[0].nurl = winUrl + bid = spec.interpretResponse({body: bidResponse}, bidRequest)[0]; + + expect(bid.vastUrl).to.equal(winUrl); + }); + }); + } + }); +}); diff --git a/test/spec/modules/trionBidAdapter_spec.js b/test/spec/modules/trionBidAdapter_spec.js index 0fc03caa563..d7f09c2a057 100644 --- a/test/spec/modules/trionBidAdapter_spec.js +++ b/test/spec/modules/trionBidAdapter_spec.js @@ -71,10 +71,16 @@ describe('Trion adapter tests', function () { beforeEach(function () { // adapter = trionAdapter.createNew(); + $$PREBID_GLOBAL$$.bidderSettings = { + trion: { + storageAllowed: true + } + }; sinon.stub(document.body, 'appendChild'); }); afterEach(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; document.body.appendChild.restore(); }); diff --git a/test/spec/modules/tripleliftBidAdapter_spec.js b/test/spec/modules/tripleliftBidAdapter_spec.js index 164188804a3..275b9b3bfee 100644 --- a/test/spec/modules/tripleliftBidAdapter_spec.js +++ b/test/spec/modules/tripleliftBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { tripleliftAdapterSpec } from 'modules/tripleliftBidAdapter.js'; +import { tripleliftAdapterSpec, storage } from 'modules/tripleliftBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import { deepClone } from 'src/utils.js'; import { config } from 'src/config.js'; @@ -8,11 +8,11 @@ import * as utils from 'src/utils.js'; const ENDPOINT = 'https://tlx.3lift.com/header/auction?'; const GDPR_CONSENT_STR = 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY'; +const GPP_CONSENT_STR = 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN' describe('triplelift adapter', function () { const adapter = newBidder(tripleliftAdapterSpec); - let bid, instreamBid; - let sandbox; + let bid, instreamBid, sandbox, logErrorSpy; this.beforeEach(() => { bid = { @@ -140,15 +140,13 @@ describe('triplelift adapter', function () { sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], bidId: '30b31c1838de1e', bidderRequestId: '22edbae2733bf6', + transactionId: '173f49a8-7549-4218-a23c-e7ba59b47229', auctionId: '1d1a030790a475', userId: {}, schain, ortb2Imp: { ext: { - data: { - pbAdSlot: 'homepage-top-rect', - adUnitSpecificAttribute: 123 - } + tid: '173f49a8-7549-4218-a23c-e7ba59b47229' } } }, @@ -168,7 +166,8 @@ describe('triplelift adapter', function () { mediaTypes: { video: { context: 'instream', - playerSize: [640, 480] + playerSize: [640, 480], + playbackmethod: 5 } }, adUnitCode: 'adunit-code-instream', @@ -178,6 +177,15 @@ describe('triplelift adapter', function () { auctionId: '1d1a030790a475', userId: {}, schain, + ortb2Imp: { + ext: { + data: { + pbAdSlot: 'homepage-top-rect', + adUnitSpecificAttribute: 123 + }, + tid: '173f49a8-7549-4218-a23c-e7ba59b47229' + } + } }, // banner and outstream video { @@ -245,6 +253,11 @@ describe('triplelift adapter', function () { auctionId: '1d1a030790a475', userId: {}, schain, + ortb2Imp: { + misc: { + test: 1 + } + } }, // incomplete banner and incomplete video { @@ -293,7 +306,8 @@ describe('triplelift adapter', function () { mediaTypes: { video: { context: 'instream', - playerSize: [640, 480] + playerSize: [640, 480], + playbackmethod: [1, 2, 3] }, banner: { sizes: [ @@ -346,6 +360,209 @@ describe('triplelift adapter', function () { auctionId: '1d1a030790a475', userId: {}, schain, + }, + // outstream video only + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }, + adUnitCode: 'adunit-code-outstream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // banner and incomplete outstream (missing size) + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6 + } + }, + mediaTypes: { + video: { + context: 'outstream' + }, + banner: { + sizes: [ + [970, 250], + [1, 1] + ] + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; valid placement + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480], + placement: 3 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; valid placement + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480], + placement: 4 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; valid placement + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480], + placement: 5 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; undefined placement + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, + }, + // outstream video; invalid placement + { + bidder: 'triplelift', + params: { + inventoryCode: 'outstream_test', + floor: 1.0, + video: { + mimes: ['video/mp4'], + maxduration: 30, + minduration: 6, + w: 640, + h: 480 + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480], + placement: 6 + } + }, + adUnitCode: 'adunit-code-instream', + sizes: [[300, 250], [300, 600], [1, 1, 1], ['flex']], + bidId: '30b31c1838de1e', + bidderRequestId: '22edbae2733bf6', + auctionId: '1d1a030790a475', + userId: {}, + schain, } ]; @@ -371,7 +588,7 @@ describe('triplelift adapter', function () { } ], refererInfo: { - referer: 'https://examplereferer.com' + page: 'https://examplereferer.com' }, gdprConsent: { consentString: GDPR_CONSENT_STR, @@ -379,9 +596,18 @@ describe('triplelift adapter', function () { }, }; sandbox = sinon.sandbox.create(); + logErrorSpy = sinon.spy(utils, 'logError'); + + $$PREBID_GLOBAL$$.bidderSettings = { + triplelift: { + storageAllowed: true + } + }; }); afterEach(() => { sandbox.restore(); + utils.logError.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; }); it('exists and is an object', function () { @@ -407,13 +633,16 @@ describe('triplelift adapter', function () { expect(payload.imp[0].tagid).to.equal('12345'); expect(payload.imp[0].floor).to.equal(1.0); expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + // instream expect(payload.imp[1].tagid).to.equal('insteam_test'); expect(payload.imp[1].floor).to.equal(1.0); expect(payload.imp[1].video).to.exist.and.to.be.a('object'); + expect(payload.imp[1].video.placement).to.equal(1); // banner and outstream video - expect(payload.imp[2]).to.not.have.property('video'); + expect(payload.imp[2]).to.have.property('video'); expect(payload.imp[2]).to.have.property('banner'); expect(payload.imp[2].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + expect(payload.imp[2].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); // banner and incomplete video expect(payload.imp[3]).to.not.have.property('video'); expect(payload.imp[3]).to.have.property('banner'); @@ -426,10 +655,84 @@ describe('triplelift adapter', function () { expect(payload.imp[5]).to.not.have.property('banner'); expect(payload.imp[5]).to.have.property('video'); expect(payload.imp[5].video).to.exist.and.to.be.a('object'); + expect(payload.imp[5].video.placement).to.equal(1); // banner and outream video and native - expect(payload.imp[6]).to.not.have.property('video'); + expect(payload.imp[6]).to.have.property('video'); expect(payload.imp[6]).to.have.property('banner'); expect(payload.imp[6].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + expect(payload.imp[6].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); + // outstream video only + expect(payload.imp[7]).to.have.property('video'); + expect(payload.imp[7]).to.not.have.property('banner'); + expect(payload.imp[7].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'w': 640, 'h': 480, 'context': 'outstream', 'placement': 3}); + // banner and incomplete outstream (missing size); video request is permitted so banner can still monetize + expect(payload.imp[8]).to.have.property('video'); + expect(payload.imp[8]).to.have.property('banner'); + expect(payload.imp[8].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]); + expect(payload.imp[8].video).to.deep.equal({'mimes': ['video/mp4'], 'maxduration': 30, 'minduration': 6, 'context': 'outstream', 'placement': 3}); + }); + + it('should check for valid outstream placement values', function () { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + // outstream video; valid placement + expect(payload.imp[9]).to.not.have.property('banner'); + expect(payload.imp[9]).to.have.property('video'); + expect(payload.imp[9].video).to.exist.and.to.be.a('object'); + expect(payload.imp[9].video.placement).to.equal(3); + // outstream video; valid placement + expect(payload.imp[10]).to.not.have.property('banner'); + expect(payload.imp[10]).to.have.property('video'); + expect(payload.imp[10].video).to.exist.and.to.be.a('object'); + expect(payload.imp[10].video.placement).to.equal(4); + // outstream video; valid placement + expect(payload.imp[11]).to.not.have.property('banner'); + expect(payload.imp[11]).to.have.property('video'); + expect(payload.imp[11].video).to.exist.and.to.be.a('object'); + expect(payload.imp[11].video.placement).to.equal(5); + // outstream video; undefined placement + expect(payload.imp[12]).to.not.have.property('banner'); + expect(payload.imp[12]).to.have.property('video'); + expect(payload.imp[12].video).to.exist.and.to.be.a('object'); + expect(payload.imp[12].video.placement).to.equal(3); + // outstream video; invalid placement + expect(payload.imp[13]).to.not.have.property('banner'); + expect(payload.imp[13]).to.have.property('video'); + expect(payload.imp[13].video).to.exist.and.to.be.a('object'); + expect(payload.imp[13].video.placement).to.equal(3); + }); + + it('should add tid to imp.ext if transactionId exists', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[0].ext.tid).to.exist.and.be.a('string'); + expect(request.data.imp[0].ext.tid).to.equal('173f49a8-7549-4218-a23c-e7ba59b47229'); + }); + + it('should not add impression ext object if ortb2Imp does not exist', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[2].ext).to.not.exist; + }); + + it('should not add impression ext object if ortb2Imp.ext does not exist', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[3].ext).to.not.exist; + }); + + it('should copy entire impression ext object', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[1].ext).to.haveOwnProperty('tid'); + expect(request.data.imp[1].ext).to.haveOwnProperty('data'); + expect(request.data.imp[1].ext.data).to.haveOwnProperty('adUnitSpecificAttribute'); + expect(request.data.imp[1].ext.data).to.haveOwnProperty('pbAdSlot'); + expect(request.data.imp[1].ext).to.deep.equal( + { + data: { + pbAdSlot: 'homepage-top-rect', + adUnitSpecificAttribute: 123 + }, + tid: '173f49a8-7549-4218-a23c-e7ba59b47229' + } + ); }); it('should add tdid to the payload if included', function () { @@ -459,6 +762,24 @@ describe('triplelift adapter', function () { expect(payload.user).to.deep.equal({ext: {eids: [{source: 'criteo.com', uids: [{id, ext: {rtiPartner: 'criteoId'}}]}]}}); }); + it('should add adqueryId to the payload if included', function () { + const id = '%7B%22qid%22%3A%229c985f8cc31d9b3c000d%22%7D'; + bidRequests[0].userIdAsEids = [{ source: 'adquery.io', uids: [{ id }] }]; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.exist; + expect(payload.user).to.deep.equal({ext: {eids: [{source: 'adquery.io', uids: [{id, ext: {rtiPartner: 'adquery.io'}}]}]}}); + }); + + it('should add amxRtbId to the payload if included', function () { + const id = 'Ok9JQkBM-UFlAXEZQ-UUNBQlZOQzgrUFhW-UUNBQkRQTUBPQVpVWVxNXlZUUF9AUFhAUF9PXFY/'; + bidRequests[0].userIdAsEids = [{ source: 'amxdt.net', uids: [{ id }] }]; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const payload = request.data; + expect(payload).to.exist; + expect(payload.user).to.deep.equal({ext: {eids: [{source: 'amxdt.net', uids: [{id, ext: {rtiPartner: 'amxdt.net'}}]}]}}); + }); + it('should add tdid, idl_env and criteoId to the payload if both are included', function () { const tdidId = '6bca7f6b-a98a-46c0-be05-6020f7604598'; const idlEnvId = 'XY6104gr0njcH9UDIR7ysFFJcm2XNpqeJTYslleJ_cMlsFOfZI'; @@ -706,12 +1027,25 @@ describe('triplelift adapter', function () { expect(url).to.match(new RegExp('(?:' + prebid.version + ')')) expect(url).to.match(/(?:referrer)/); }); + it('should use refererInfo.page for referrer', function () { + bidderRequest.refererInfo.page = 'https://topmostlocation.com?foo=bar' + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const url = request.url; + expect(url).to.match(/(\?|&)referrer=https%3A%2F%2Ftopmostlocation.com%3Ffoo%3Dbar/); + delete bidderRequest.refererInfo.page + }); it('should return us_privacy param when CCPA info is available', function() { bidderRequest.uspConsent = '1YYY'; const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); const url = request.url; expect(url).to.match(/(\?|&)us_privacy=1YYY/); }); + it('should pass fledge signal when Triplelift is eligible for fledge', function() { + bidderRequest.fledgeEnabled = true; + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const url = request.url; + expect(url).to.match(/(\?|&)fledge=true/); + }); it('should return coppa param when COPPA config is set to true', function() { sinon.stub(config, 'getConfig').withArgs('coppa').returns(true); const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); @@ -787,6 +1121,55 @@ describe('triplelift adapter', function () { size: '*' })).to.be.true; }); + it('should catch error if getFloor throws error', function() { + bidRequests[0].getFloor = () => { + throw new Error('An exception!'); + }; + + tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + + expect(logErrorSpy.calledOnce).to.equal(true); + }); + it('should add ortb2 ext object if global fpd is available', function() { + const ortb2 = { + site: { + domain: 'page.example.com', + cat: ['IAB2'], + sectioncat: ['IAB2-2'], + pagecat: ['IAB2-2'], + page: 'https://page.example.com/here.html', + }, + user: { + yob: 1985, + gender: 'm', + keywords: 'a,b', + data: [ + { + name: 'dataprovider.com', + ext: { segtax: 4 }, + segment: [{ id: '1' }] + } + ], + ext: { + data: { + registered: true, + interests: ['cars'] + } + } + } + }; + + const request = tripleliftAdapterSpec.buildRequests(bidRequests, {...bidderRequest, ortb2}); + const { data: payload } = request; + expect(payload.ext.ortb2).to.exist; + expect(payload.ext.ortb2.site).to.deep.equal({ + domain: 'page.example.com', + cat: ['IAB2'], + sectioncat: ['IAB2-2'], + pagecat: ['IAB2-2'], + page: 'https://page.example.com/here.html', + }); + }); it('should send global config fpd if kvps are available', function() { const sens = null; const category = ['news', 'weather', 'hurricane']; @@ -804,13 +1187,7 @@ describe('triplelift adapter', function () { sens: sens, } } - sandbox.stub(config, 'getConfig').callsFake(key => { - const config = { - ortb2 - }; - return utils.deepAccess(config, key); - }); - const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, {...bidderRequest, ortb2}); const { data: payload } = request; expect(payload.ext.fpd.user).to.not.exist; expect(payload.ext.fpd.context.ext.data).to.haveOwnProperty('category'); @@ -818,10 +1195,95 @@ describe('triplelift adapter', function () { }); it('should send ad unit fpd if kvps are available', function() { const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); - expect(request.data.imp[0].fpd.context).to.haveOwnProperty('data'); - expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('pbAdSlot'); - expect(request.data.imp[0].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute'); - expect(request.data.imp[1].fpd).to.not.exist; + expect(request.data.imp[1].fpd.context).to.haveOwnProperty('data'); + expect(request.data.imp[1].fpd.context.data).to.haveOwnProperty('pbAdSlot'); + expect(request.data.imp[1].fpd.context.data).to.haveOwnProperty('adUnitSpecificAttribute'); + expect(request.data.imp[2].fpd).to.not.exist; + }); + it('should send 1PlusX data as fpd if localStorage is available and no other fpd is defined', function() { + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}'); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.ext.fpd).to.deep.equal({ + 'user': { + 'data': [ + { + 'name': 'www.1plusx.com', + 'ext': { + 'kid': 1, + 's': 'ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==', + 't': '/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug==' + } + } + ] + } + }) + }); + it('should append 1PlusX data to existing user.data entries if localStorage is available', function() { + bidderRequest.ortb2 = { + user: { + data: [ + { name: 'dataprovider.com', ext: { segtax: 4 }, segment: [{ id: '1' }] } + ] + } + } + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => '{"kid":1,"s":"ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==","t":"/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug=="}'); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.ext.fpd).to.deep.equal({ + 'user': { + 'data': [ + { 'name': 'dataprovider.com', 'ext': { 'segtax': 4 }, 'segment': [{ 'id': '1' }] }, + { + 'name': 'www.1plusx.com', + 'ext': { + 'kid': 1, + 's': 'ySRdArquXuBolr/cVv0UNqrJhTO4QZsbNH/t+2kR3gXjbA==', + 't': '/yVtBrquXuBolr/cVv0UNtx1mssdLYeKFhWFI3Dq1dJnug==' + } + } + ] + } + }) + }); + it('should not append anything if getDataFromLocalStorage returns null', function() { + bidderRequest.ortb2 = { + user: { + data: [ + { name: 'dataprovider.com', ext: { segtax: 4 }, segment: [{ id: '1' }] } + ] + } + } + sandbox.stub(storage, 'getDataFromLocalStorage').callsFake(() => null); + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.ext.fpd).to.deep.equal({ + 'user': { + 'data': [ + { 'name': 'dataprovider.com', 'ext': { 'segtax': 4 }, 'segment': [{ 'id': '1' }] }, + ] + } + }) + }); + it('should add gpp consent data to bid request object if gpp data exists', function() { + bidderRequest.ortb2 = { + regs: { + 'gpp': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + 'gpp_sid': [7] + } + } + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.regs).to.deep.equal({ + 'gpp': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + 'gpp_sid': [7] + }) + }); + it('should cast playbackmethod as an array if it is an integer and it exists', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[1].video.playbackmethod).to.be.a('array'); + expect(request.data.imp[1].video.playbackmethod).to.deep.equal([5]); + }); + it('should set playbackmethod as an array if it exists as an array', function() { + const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest); + expect(request.data.imp[5].video.playbackmethod).to.be.a('array'); + expect(request.data.imp[5].video.playbackmethod).to.deep.equal([1, 2, 3]); }); }); @@ -840,14 +1302,40 @@ describe('triplelift adapter', function () { iurl: 'https://s.adroll.com/a/IYR/N36/IYRN366MFVDITBAGNNT5U6.jpg', tl_source: 'tlx', advertiser_name: 'fake advertiser name', - adomain: ['basspro.com', 'internetalerts.org'] + adomain: ['basspro.com', 'internetalerts.org'], + media_type: 'banner' }, { imp_id: 1, crid: '10092_76480_i2j6qm8u', cpm: 9.99, - ad: 'The Trade Desk', - tlx_source: 'hdx' + ad: 'The Trade Desk', + tl_source: 'hdx', + media_type: 'video' + }, + // video bid on banner+outstream request + { + imp_id: 2, + crid: '5989_33264_352817187', + cpm: 20, + ad: '\n \n \t', + tl_source: 'hdx', + advertiser_name: 'zennioptical.com', + adomain: ['zennioptical.com'], + media_type: 'video' + }, + // banner bid on banner+outstream request + { + imp_id: 3, + crid: '5989_33264_352817187', + cpm: 20, + width: 970, + height: 250, + ad: 'ad-markup', + tl_source: 'hdx', + advertiser_name: 'zennioptical.com', + adomain: ['zennioptical.com'], + media_type: 'banner' } ] } @@ -873,13 +1361,13 @@ describe('triplelift adapter', function () { ] } }, - bidId: '30b31c1838de1e', + bidId: '30b31c1838de1e' }, { imp_id: 1, crid: '10092_76480_i2j6qm8u', cpm: 9.99, - ad: 'The Trade Desk', + ad: 'The Trade Desk', tlx_source: 'hdx', mediaTypes: { video: { @@ -887,7 +1375,89 @@ describe('triplelift adapter', function () { playerSize: [640, 480] } }, - bidId: '30b31c1838de1e', + bidId: '30b31c1838de1e' + }, + // banner and outstream + { + bidder: 'triplelift', + params: { + inventoryCode: 'testing_desktop_outstream', + floor: 1 + }, + nativeParams: {}, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[640, 480]], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1 + }, + banner: { + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ] + }, + native: {} + }, + adUnitCode: 'video-outstream', + transactionId: '135061c3-f546-4e28-8a07-44c2fb58a958', + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ], + bidId: '73edc0ba8de203', + bidderRequestId: '3d81143328560b', + auctionId: 'f6427dc0-b954-4010-a76c-d498380796a2', + src: 'client', + bidRequestsCount: 2, + bidderRequestsCount: 2, + bidderWinsCount: 0 + }, + // banner and outstream + { + bidder: 'triplelift', + params: { + inventoryCode: 'testing_desktop_outstream', + floor: 1 + }, + nativeParams: {}, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[640, 480]], + mimes: ['video/mp4'], + protocols: [1, 2, 3, 4, 5, 6, 7, 8], + playbackmethod: [2], + skip: 1 + }, + banner: { + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ] + }, + native: {} + }, + adUnitCode: 'video-outstream', + transactionId: '135061c3-f546-4e28-8a07-44c2fb58a958', + sizes: [ + [728, 90], + [970, 250], + [970, 90] + ], + bidId: '73edc0ba8de203', + bidderRequestId: '3d81143328560b', + auctionId: 'f6427dc0-b954-4010-a76c-d498380796a2', + src: 'client', + bidRequestsCount: 2, + bidderRequestsCount: 2, + bidderWinsCount: 0 } ], refererInfo: { @@ -934,16 +1504,29 @@ describe('triplelift adapter', function () { } ]; let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); - expect(result).to.have.length(2); + expect(result).to.have.length(4); expect(Object.keys(result[0])).to.have.members(Object.keys(expectedResponse[0])); expect(Object.keys(result[1])).to.have.members(Object.keys(expectedResponse[1])); expect(result[0].ttl).to.equal(300); expect(result[1].ttl).to.equal(3600); }); + it('should identify format of bid and respond accordingly', function() { + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + expect(result[0].meta.mediaType).to.equal('native'); + expect(result[1].mediaType).to.equal('video'); + expect(result[1].meta.mediaType).to.equal('video'); + // video bid on banner+outstream request + expect(result[2].mediaType).to.equal('video'); + expect(result[2].meta.mediaType).to.equal('video'); + expect(result[2].vastXml).to.include('aid=148508128401385324170&inv_code=testing_mobile_outstream'); + // banner bid on banner+outstream request + expect(result[3].meta.mediaType).to.equal('banner'); + }) + it('should return multiple responses to support SRA', function () { let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); - expect(result).to.have.length(2); + expect(result).to.have.length(4); }); it('should include the advertiser name in the meta field if available', function () { @@ -958,11 +1541,70 @@ describe('triplelift adapter', function () { expect(result[0].meta.advertiserDomains[1]).to.equal('internetalerts.org'); expect(result[1].meta).to.not.have.key('advertiserDomains'); }); + + it('should include networkId in the meta field if available', function () { + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + expect(result[1].meta.networkId).to.equal('10092'); + expect(result[2].meta.networkId).to.equal('5989'); + expect(result[3].meta.networkId).to.equal('5989'); + }); + + it('should return fledgeAuctionConfigs if PAAPI response is received', function() { + response.body.paapi = [ + { + imp_id: '0', + auctionConfig: { + seller: 'https://3lift.com', + decisionLogicUrl: 'https://3lift.com/decision_logic.js', + interestGroupBuyers: ['https://some_buyer.com'], + perBuyerSignals: { + 'https://some_buyer.com': { a: 1 } + } + } + }, + { + imp_id: '2', + auctionConfig: { + seller: 'https://3lift.com', + decisionLogicUrl: 'https://3lift.com/decision_logic.js', + interestGroupBuyers: ['https://some_other_buyer.com'], + perBuyerSignals: { + 'https://some_other_buyer.com': { b: 2 } + } + } + } + ]; + + let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest}); + + expect(result).to.have.property('bids'); + expect(result).to.have.property('fledgeAuctionConfigs'); + expect(result.fledgeAuctionConfigs.length).to.equal(2); + expect(result.fledgeAuctionConfigs[0].bidId).to.equal('30b31c1838de1e'); + expect(result.fledgeAuctionConfigs[1].bidId).to.equal('73edc0ba8de203'); + expect(result.fledgeAuctionConfigs[0].config).to.deep.equal( + { + 'seller': 'https://3lift.com', + 'decisionLogicUrl': 'https://3lift.com/decision_logic.js', + 'interestGroupBuyers': ['https://some_buyer.com'], + 'perBuyerSignals': { 'https://some_buyer.com': { 'a': 1 } } + } + ); + expect(result.fledgeAuctionConfigs[1].config).to.deep.equal( + { + 'seller': 'https://3lift.com', + 'decisionLogicUrl': 'https://3lift.com/decision_logic.js', + 'interestGroupBuyers': ['https://some_other_buyer.com'], + 'perBuyerSignals': { 'https://some_other_buyer.com': { 'b': 2 } } + } + ); + }); }); describe('getUserSyncs', function() { let expectedIframeSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; let expectedImageSyncUrl = 'https://eb2.3lift.com/sync?px=1&src=prebid&gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&'; + let expectedGppSyncUrl = 'https://eb2.3lift.com/sync?gdpr=true&cmp_cs=' + GDPR_CONSENT_STR + '&gpp=' + GPP_CONSENT_STR + '&gpp_sid=2%2C8' + '&'; it('returns undefined when syncing is not enabled', function() { expect(tripleliftAdapterSpec.getUserSyncs({})).to.equal(undefined); @@ -1000,8 +1642,19 @@ describe('triplelift adapter', function () { let syncOptions = { iframeEnabled: true }; - let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, '1YYY'); + let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, '1YYY', null); expect(result[0].url).to.match(/(\?|&)us_privacy=1YYY/); }); + it('returns a user sync pixel with GPP signals when available', function() { + let syncOptions = { + iframeEnabled: true + }; + let gppConsent = { + 'applicableSections': [2, 8], + 'gppString': 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN' + } + let result = tripleliftAdapterSpec.getUserSyncs(syncOptions, null, null, null, gppConsent); + expect(result[0].url).to.equal(expectedGppSyncUrl); + }); }); }); diff --git a/test/spec/modules/truereachBidAdapter_spec.js b/test/spec/modules/truereachBidAdapter_spec.js index 3c78c4b848d..cd7d0873569 100644 --- a/test/spec/modules/truereachBidAdapter_spec.js +++ b/test/spec/modules/truereachBidAdapter_spec.js @@ -83,7 +83,7 @@ describe('truereachBidAdapterTests', function () { }); describe('user_sync', function() { - const user_sync_url = 'http://ads.momagic.com/jsp/usersync.jsp'; + const user_sync_url = 'https://ads-sg.momagic.com/jsp/usersync.jsp'; it('register_iframe_pixel_if_iframeEnabled_is_true', function() { let syncs = spec.getUserSyncs( {iframeEnabled: true} diff --git a/test/spec/modules/trustpidSystem_spec.js b/test/spec/modules/trustpidSystem_spec.js deleted file mode 100644 index 97e87e3a303..00000000000 --- a/test/spec/modules/trustpidSystem_spec.js +++ /dev/null @@ -1,232 +0,0 @@ -import { expect } from 'chai'; -import { trustpidSubmodule } from 'modules/trustpidSystem.js'; -import { storage } from 'modules/trustpidSystem.js'; - -describe('trustpid System', () => { - const connectDataKey = 'fcIdConnectData'; - const connectDomainKey = 'fcIdConnectDomain'; - - const getStorageData = (idGraph) => { - if (!idGraph) { - idGraph = {id: 501, domain: ''}; - } - return { - 'connectId': { - 'idGraph': [idGraph], - } - } - }; - - it('should have the correct module name declared', () => { - expect(trustpidSubmodule.name).to.equal('trustpid'); - }); - - describe('trustpid getId()', () => { - afterEach(() => { - storage.removeDataFromLocalStorage(connectDataKey); - storage.removeDataFromLocalStorage(connectDomainKey); - }); - - it('it should return object with key callback', () => { - expect(trustpidSubmodule.getId()).to.have.property('callback'); - }); - - it('should return object with key callback with value type - function', () => { - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData())); - expect(trustpidSubmodule.getId()).to.have.property('callback'); - expect(typeof trustpidSubmodule.getId().callback).to.be.equal('function'); - }); - - it('tests if localstorage & JSON works properly ', () => { - const idGraph = { - 'domain': 'domainValue', - 'umid': 'umidValue', - }; - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - expect(JSON.parse(storage.getDataFromLocalStorage(connectDataKey))).to.have.property('connectId'); - }); - - it('returns {callback: func} if domains don\'t match', () => { - const idGraph = { - 'domain': 'domainValue', - 'umid': 'umidValue', - }; - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify('differentDomainValue')); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - expect(trustpidSubmodule.getId()).to.have.property('callback'); - }); - - it('returns {id: {trustpid: data.trustpid}} if we have the right data stored in the localstorage ', () => { - const idGraph = { - 'domain': 'uat.mno.link', - 'umid': 'umidValue', - }; - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify('uat.mno.link')); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - const response = trustpidSubmodule.getId(); - expect(response).to.have.property('id'); - expect(response.id).to.have.property('trustpid'); - expect(response.id.trustpid).to.be.equal('umidValue-xxxx'); - }); - - it('returns {trustpid: data.trustpid} if we have the right data stored in the localstorage right after the callback is called', (done) => { - const idGraph = { - 'domain': 'uat.mno.link', - 'umid': 'umidValue', - }; - const response = trustpidSubmodule.getId(); - expect(response).to.have.property('callback'); - expect(response.callback.toString()).contain('result(callback)'); - - if (typeof response.callback === 'function') { - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify('uat.mno.link')); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - response.callback(function (result) { - expect(result).to.not.be.null; - expect(result).to.have.property('trustpid'); - expect(result.trustpid).to.be.equal('umidValue-xxxx'); - done() - }) - } - }); - - it('returns null if domains don\'t match', (done) => { - const idGraph = { - 'domain': 'uat.mno.link', - 'umid': 'umidValue', - }; - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify('differentDomainValue')); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - - const response = trustpidSubmodule.getId(); - expect(response).to.have.property('callback'); - expect(response.callback.toString()).contain('result(callback)'); - - if (typeof response.callback === 'function') { - setTimeout(() => { - expect(JSON.parse(storage.getDataFromLocalStorage(connectDomainKey))).to.be.equal('differentDomainValue'); - }, 100) - response.callback(function (result) { - expect(result).to.be.null; - done() - }) - } - }); - - it('returns {trustpid: data.trustpid} if we have the right data stored in the localstorage right after 500ms delay', (done) => { - const idGraph = { - 'domain': 'uat.mno.link', - 'umid': 'umidValue', - }; - - const response = trustpidSubmodule.getId(); - expect(response).to.have.property('callback'); - expect(response.callback.toString()).contain('result(callback)'); - - if (typeof response.callback === 'function') { - setTimeout(() => { - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify('uat.mno.link')); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - }, 500); - response.callback(function (result) { - expect(result).to.not.be.null; - expect(result).to.have.property('trustpid'); - expect(result.trustpid).to.be.equal('umidValue-xxxx'); - done() - }) - } - }); - - it('returns null if we have the data stored in the localstorage after 500ms delay and the max (waiting) delay is only 200ms ', (done) => { - const idGraph = { - 'domain': 'uat.mno.link', - 'umid': 'umidValue', - }; - - const response = trustpidSubmodule.getId({params: {maxDelayTime: 200}}); - expect(response).to.have.property('callback'); - expect(response.callback.toString()).contain('result(callback)'); - - if (typeof response.callback === 'function') { - setTimeout(() => { - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify('uat.mno.link')); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - }, 500); - response.callback(function (result) { - expect(result).to.be.null; - done() - }) - } - }); - }); - - describe('trustpid decode()', () => { - const VALID_API_RESPONSES = [ - { - expected: '32a97f612', - payload: { - trustpid: '32a97f612' - } - }, - { - expected: '32a97f61', - payload: { - trustpid: '32a97f61', - } - }, - ]; - VALID_API_RESPONSES.forEach(responseData => { - it('should return a newly constructed object with the trustpid for a payload with {trustpid: value}', () => { - expect(trustpidSubmodule.decode(responseData.payload)).to.deep.equal( - {trustpid: responseData.expected} - ); - }); - }); - - [{}, '', {foo: 'bar'}].forEach((response) => { - it(`should return null for an invalid response "${JSON.stringify(response)}"`, () => { - expect(trustpidSubmodule.decode(response)).to.be.null; - }); - }); - }); - - describe('trustpid messageHandler for acronyms', () => { - afterEach(() => { - storage.removeDataFromLocalStorage(connectDataKey); - storage.removeDataFromLocalStorage(connectDomainKey); - }); - - const domains = [ - {domain: 'tmi.mno.link', acronym: 'ndye'}, - {domain: 'tmi.vodafone.de', acronym: 'pqnx'}, - {domain: 'tmi.telekom.de', acronym: 'avgw'}, - {domain: 'tmi.tmid.es', acronym: 'kjws'}, - {domain: 'uat.mno.link', acronym: 'xxxx'}, - {domain: 'es.tmiservice.orange.com', acronym: 'aplw'}, - ]; - - domains.forEach(({domain, acronym}) => { - it(`correctly sets trustpid value and acronym to ${acronym} for ${domain} domain`, (done) => { - const idGraph = { - 'domain': domain, - 'umid': 'umidValue', - }; - - storage.setDataInLocalStorage(connectDomainKey, JSON.stringify(domain)); - storage.setDataInLocalStorage(connectDataKey, JSON.stringify(getStorageData(idGraph))); - - const eventData = { - data: `{\"msgType\":\"MNOSELECTOR\",\"body\":{\"url\":\"https://${domain}/some/path\"}}` - }; - - window.dispatchEvent(new MessageEvent('message', eventData)); - - const response = trustpidSubmodule.getId(); - expect(response).to.have.property('id'); - expect(response.id).to.have.property('trustpid'); - expect(response.id.trustpid).to.be.equal(`umidValue-${acronym}`); - done(); - }); - }); - }); -}); diff --git a/test/spec/modules/trustxBidAdapter_spec.js b/test/spec/modules/trustxBidAdapter_spec.js deleted file mode 100644 index b34813948fc..00000000000 --- a/test/spec/modules/trustxBidAdapter_spec.js +++ /dev/null @@ -1,1372 +0,0 @@ -import { expect } from 'chai'; -import { spec } from 'modules/trustxBidAdapter.js'; -import { newBidder } from 'src/adapters/bidderFactory.js'; -import { config } from 'src/config.js'; - -describe('TrustXAdapter', function () { - const adapter = newBidder(spec); - - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function'); - }); - }); - - describe('isBidRequestValid', function () { - let bid = { - 'bidder': 'trustx', - 'params': { - 'uid': '44' - }, - 'adUnitCode': 'adunit-code', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '1d1a030790a475', - }; - - it('should return true when required params found', function () { - expect(spec.isBidRequestValid(bid)).to.equal(true); - }); - - it('should return false when required params are not passed', function () { - let bid = Object.assign({}, bid); - delete bid.params; - bid.params = { - 'uid': 0 - }; - expect(spec.isBidRequestValid(bid)).to.equal(false); - }); - }); - - describe('buildRequests', function () { - function parseRequest(data) { - return JSON.parse(data); - } - const bidderRequest = { - refererInfo: {referer: 'https://example.com'}, - bidderRequestId: '22edbae2733bf6', - auctionId: '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', - timeout: 3000 - }; - const referrer = encodeURIComponent(bidderRequest.refererInfo.referer); - - let bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '43', - 'bidFloor': 1.25, - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [300, 600]] - } - }, - 'bidId': '42dbe3a7168a6a', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '44', - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '30b31c1838de1e', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '45', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'mediaTypes': { - 'video': { - 'playerSize': [[400, 600]], - 'mimes': ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'] - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '41', - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'mediaTypes': { - 'video': { - 'playerSize': [[400, 600]], - 'protocols': [1, 2, 3] - }, - 'banner': { - 'sizes': [[728, 90]] - } - }, - 'bidId': '3150ccb55da321', - 'bidderRequestId': '22edbae2733bf6', - 'auctionId': '9e2dfbfe-00c7-4f5e-9850-4044df3229c7', - } - ]; - - it('should attach valid params to the tag', function () { - const request = spec.buildRequests([bidRequests[0]], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.deep.equal({ - 'id': bidderRequest.bidderRequestId, - 'site': { - 'page': referrer - }, - 'tmax': bidderRequest.timeout, - 'source': { - 'tid': bidderRequest.auctionId, - 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} - }, - 'imp': [{ - 'id': bidRequests[0].bidId, - 'tagid': bidRequests[0].params.uid, - 'ext': {'divid': bidRequests[0].adUnitCode}, - 'bidfloor': bidRequests[0].params.bidFloor, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }] - }); - }); - - it('make possible to process request without mediaTypes', function () { - const request = spec.buildRequests([bidRequests[0], bidRequests[1]], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.deep.equal({ - 'id': bidderRequest.bidderRequestId, - 'site': { - 'page': referrer - }, - 'tmax': bidderRequest.timeout, - 'source': { - 'tid': bidderRequest.auctionId, - 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} - }, - 'imp': [{ - 'id': bidRequests[0].bidId, - 'tagid': bidRequests[0].params.uid, - 'ext': {'divid': bidRequests[0].adUnitCode}, - 'bidfloor': bidRequests[0].params.bidFloor, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }, { - 'id': bidRequests[1].bidId, - 'tagid': bidRequests[1].params.uid, - 'ext': {'divid': bidRequests[1].adUnitCode}, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }] - }); - }); - - it('should attach valid params to the video tag', function () { - const request = spec.buildRequests(bidRequests.slice(0, 3), bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.deep.equal({ - 'id': bidderRequest.bidderRequestId, - 'site': { - 'page': referrer - }, - 'tmax': bidderRequest.timeout, - 'source': { - 'tid': bidderRequest.auctionId, - 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} - }, - 'imp': [{ - 'id': bidRequests[0].bidId, - 'tagid': bidRequests[0].params.uid, - 'ext': {'divid': bidRequests[0].adUnitCode}, - 'bidfloor': bidRequests[0].params.bidFloor, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }, { - 'id': bidRequests[1].bidId, - 'tagid': bidRequests[1].params.uid, - 'ext': {'divid': bidRequests[1].adUnitCode}, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }, { - 'id': bidRequests[2].bidId, - 'tagid': bidRequests[2].params.uid, - 'ext': {'divid': bidRequests[2].adUnitCode}, - 'video': { - 'w': 400, - 'h': 600, - 'mimes': ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'] - } - }] - }); - }); - - it('should support mixed mediaTypes', function () { - const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.deep.equal({ - 'id': bidderRequest.bidderRequestId, - 'site': { - 'page': referrer - }, - 'tmax': bidderRequest.timeout, - 'source': { - 'tid': bidderRequest.auctionId, - 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} - }, - 'imp': [{ - 'id': bidRequests[0].bidId, - 'tagid': bidRequests[0].params.uid, - 'ext': {'divid': bidRequests[0].adUnitCode}, - 'bidfloor': bidRequests[0].params.bidFloor, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }, { - 'id': bidRequests[1].bidId, - 'tagid': bidRequests[1].params.uid, - 'ext': {'divid': bidRequests[1].adUnitCode}, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }, { - 'id': bidRequests[2].bidId, - 'tagid': bidRequests[2].params.uid, - 'ext': {'divid': bidRequests[2].adUnitCode}, - 'video': { - 'w': 400, - 'h': 600, - 'mimes': ['video/mp4', 'video/webm', 'application/javascript', 'video/ogg'], - } - }, { - 'id': bidRequests[3].bidId, - 'tagid': bidRequests[3].params.uid, - 'ext': {'divid': bidRequests[3].adUnitCode}, - 'banner': { - 'w': 728, - 'h': 90, - 'format': [{'w': 728, 'h': 90}] - }, - 'video': { - 'w': 400, - 'h': 600, - 'protocols': [1, 2, 3] - } - }] - }); - }); - - it('if gdprConsent is present payload must have gdpr params', function () { - const gdprBidderRequest = Object.assign({gdprConsent: {consentString: 'AAA', gdprApplies: true}}, bidderRequest); - const request = spec.buildRequests(bidRequests, gdprBidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('user'); - expect(payload.user).to.have.property('ext'); - expect(payload.user.ext).to.have.property('consent', 'AAA'); - expect(payload).to.have.property('regs'); - expect(payload.regs).to.have.property('ext'); - expect(payload.regs.ext).to.have.property('gdpr', 1); - }); - - it('if usPrivacy is present payload must have us_privacy param', function () { - const bidderRequestWithUSP = Object.assign({uspConsent: '1YNN'}, bidderRequest); - const request = spec.buildRequests(bidRequests, bidderRequestWithUSP); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('regs'); - expect(payload.regs).to.have.property('ext'); - expect(payload.regs.ext).to.have.property('us_privacy', '1YNN'); - }); - - it('if userId is present payload must have user.ext param with right keys', function () { - const eids = [ - { - source: 'pubcid.org', - uids: [{ - id: 'some-random-id-value', - atype: 1 - }] - }, - { - source: 'adserver.org', - uids: [{ - id: 'some-random-id-value', - atype: 1, - ext: { - rtiPartner: 'TDID' - } - }] - } - ]; - const bidRequestsWithUserIds = bidRequests.map((bid) => { - return Object.assign({ - userIdAsEids: eids - }, bid); - }); - const request = spec.buildRequests(bidRequestsWithUserIds, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('user'); - expect(payload.user).to.have.property('ext'); - expect(payload.user.ext.eids).to.deep.equal(eids); - }); - - it('if schain is present payload must have source.ext.schain param', function () { - const schain = { - complete: 1, - nodes: [ - { - asi: 'indirectseller.com', - sid: '00001', - hp: 1 - } - ] - }; - const bidRequestsWithSChain = bidRequests.map((bid) => { - return Object.assign({ - schain: schain - }, bid); - }); - const request = spec.buildRequests(bidRequestsWithSChain, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('source'); - expect(payload.source).to.have.property('ext'); - expect(payload.source.ext).to.have.property('schain'); - expect(payload.source.ext.schain).to.deep.equal(schain); - }); - - it('if content and segment is present in jwTargeting, payload must have right params', function () { - const jsContent = {id: 'test_jw_content_id'}; - const jsSegments = ['test_seg_1', 'test_seg_2']; - const bidRequestsWithJwTargeting = bidRequests.map((bid) => { - return Object.assign({ - rtd: { - jwplayer: { - targeting: { - segments: jsSegments, - content: jsContent - } - } - } - }, bid); - }); - const request = spec.buildRequests(bidRequestsWithJwTargeting, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.have.property('user'); - expect(payload.user.data).to.deep.equal([{ - name: 'iow_labs_pub_data', - segment: [ - {name: 'jwpseg', value: jsSegments[0]}, - {name: 'jwpseg', value: jsSegments[1]} - ] - }]); - expect(payload).to.have.property('site'); - expect(payload.site.content).to.deep.equal(jsContent); - }); - - it('should have user.data filled from config ortb2.user.data', function () { - const userData = [ - { - name: 'someName', - segment: [1, 2, { anyKey: 'anyVal' }, 'segVal', { id: 'segId' }, { value: 'segValue' }, { id: 'segId2', name: 'segName' }] - }, - { - name: 'permutive.com', - segment: [1, 2, 'segVal', { id: 'segId' }, { anyKey: 'anyVal' }, { value: 'segValue' }, { id: 'segId2', name: 'segName' }] - }, - { - someKey: 'another data' - } - ]; - - const getConfigStub = sinon.stub(config, 'getConfig').callsFake( - arg => arg === 'ortb2.user.data' ? userData : null); - const request = spec.buildRequests([bidRequests[0]], bidderRequest); - const payload = parseRequest(request.data); - expect(payload.user.data).to.deep.equal(userData); - getConfigStub.restore(); - }); - - it('should have right value in user.data when jwpsegments are present', function () { - const userData = [ - { - name: 'someName', - segment: [1, 2, { anyKey: 'anyVal' }, 'segVal', { id: 'segId' }, { value: 'segValue' }, { id: 'segId2', name: 'segName' }] - }, - { - name: 'permutive.com', - segment: [1, 2, 'segVal', { id: 'segId' }, { anyKey: 'anyVal' }, { value: 'segValue' }, { id: 'segId2', name: 'segName' }] - }, - { - someKey: 'another data' - } - ]; - const getConfigStub = sinon.stub(config, 'getConfig').callsFake( - arg => arg === 'ortb2.user.data' ? userData : null); - - const jsContent = {id: 'test_jw_content_id'}; - const jsSegments = ['test_seg_1', 'test_seg_2']; - const bidRequestsWithJwTargeting = Object.assign({}, bidRequests[0], { - rtd: { - jwplayer: { - targeting: { - segments: jsSegments, - content: jsContent - } - } - } - }); - const request = spec.buildRequests([bidRequestsWithJwTargeting], bidderRequest); - const payload = parseRequest(request.data); - expect(payload.user.data).to.deep.equal([{ - name: 'iow_labs_pub_data', - segment: [ - {name: 'jwpseg', value: jsSegments[0]}, - {name: 'jwpseg', value: jsSegments[1]} - ] - }, ...userData]); - getConfigStub.restore(); - }); - - it('should contain the keyword values if it present in ortb2.(site/user)', function () { - const getConfigStub = sinon.stub(config, 'getConfig').callsFake( - arg => arg === 'ortb2.user' ? {'keywords': 'foo,any'} : (arg === 'ortb2.site' ? {'keywords': 'bar'} : null)); - const keywords = { - 'site': { - 'somePublisher': [ - { - 'name': 'someName', - 'brandsafety': ['disaster'], - 'topic': ['stress', 'fear'] - } - ] - }, - 'user': { - 'formatedPublisher': [ - { - 'name': 'fomatedName', - 'segments': [ - { 'name': 'segName1', 'value': 'segVal1' }, - { 'name': 'segName2', 'value': 'segVal2' } - ] - } - ] - } - }; - const bidRequestWithKW = { ...bidRequests[0], params: { ...bidRequests[0].params, keywords } } - const request = spec.buildRequests([bidRequestWithKW], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.ext.keywords).to.deep.equal({ - 'site': { - 'somePublisher': [ - { - 'name': 'someName', - 'segments': [ - { 'name': 'brandsafety', 'value': 'disaster' }, - { 'name': 'topic', 'value': 'stress' }, - { 'name': 'topic', 'value': 'fear' } - ] - } - ], - 'ortb2': [ - { - 'name': 'keywords', - 'segments': [ - { 'name': 'keywords', 'value': 'bar' } - ] - } - ] - }, - 'user': { - 'formatedPublisher': [ - { - 'name': 'fomatedName', - 'segments': [ - { 'name': 'segName1', 'value': 'segVal1' }, - { 'name': 'segName2', 'value': 'segVal2' } - ] - } - ], - 'ortb2': [ - { - 'name': 'keywords', - 'segments': [ - { 'name': 'keywords', 'value': 'foo' }, - { 'name': 'keywords', 'value': 'any' } - ] - } - ] - } - }); - getConfigStub.restore(); - }); - - it('should be right tmax when timeout in config is less then timeout in bidderRequest', function() { - const getConfigStub = sinon.stub(config, 'getConfig').callsFake( - arg => arg === 'bidderTimeout' ? 2000 : null); - const request = spec.buildRequests([bidRequests[0]], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.tmax).to.equal(2000); - getConfigStub.restore(); - }); - it('should be right tmax when timeout in bidderRequest is less then timeout in config', function() { - const getConfigStub = sinon.stub(config, 'getConfig').callsFake( - arg => arg === 'bidderTimeout' ? 5000 : null); - const request = spec.buildRequests([bidRequests[0]], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.tmax).to.equal(3000); - getConfigStub.restore(); - }); - it('should contain imp[].ext.data.adserver if available', function() { - const ortb2Imp = [{ - ext: { - data: { - adserver: { - name: 'ad_server_name', - adslot: '/111111/slot' - }, - pbadslot: '/111111/slot' - } - } - }, { - ext: { - data: { - adserver: { - name: 'ad_server_name', - adslot: '/222222/slot' - }, - pbadslot: '/222222/slot' - } - } - }]; - const bidRequestsWithOrtb2Imp = bidRequests.slice(0, 3).map((bid, ind) => { - return Object.assign(ortb2Imp[ind] ? { ortb2Imp: ortb2Imp[ind] } : {}, bid); - }); - const request = spec.buildRequests(bidRequestsWithOrtb2Imp, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.imp[0].ext).to.deep.equal({ - divid: bidRequests[0].adUnitCode, - data: ortb2Imp[0].ext.data, - gpid: ortb2Imp[0].ext.data.adserver.adslot - }); - expect(payload.imp[1].ext).to.deep.equal({ - divid: bidRequests[1].adUnitCode, - data: ortb2Imp[1].ext.data, - gpid: ortb2Imp[1].ext.data.adserver.adslot - }); - expect(payload.imp[2].ext).to.deep.equal({ - divid: bidRequests[2].adUnitCode - }); - }); - it('should contain imp[].instl if available', function() { - const ortb2Imp = [{ - instl: 1 - }, { - instl: 2, - ext: { - data: { - adserver: { - name: 'ad_server_name', - adslot: '/222222/slot' - }, - pbadslot: '/222222/slot' - } - } - }]; - const bidRequestsWithOrtb2Imp = bidRequests.slice(0, 3).map((bid, ind) => { - return Object.assign(ortb2Imp[ind] ? { ortb2Imp: ortb2Imp[ind] } : {}, bid); - }); - const request = spec.buildRequests(bidRequestsWithOrtb2Imp, bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.imp[0].instl).to.equal(1); - expect(payload.imp[1].ext).to.deep.equal({ - divid: bidRequests[1].adUnitCode, - data: ortb2Imp[1].ext.data, - gpid: ortb2Imp[1].ext.data.adserver.adslot - }); - expect(payload.imp[1].instl).to.equal(2); - expect(payload.imp[2].ext).to.deep.equal({ - divid: bidRequests[2].adUnitCode - }); - expect(payload.imp[2].instl).to.be.undefined; - }); - it('all id like request fields must be a string', function () { - const bidderRequestWithNumId = Object.assign({}, bidderRequest, { bidderRequestId: 123123, auctionId: 345345543 }); - - let bidRequestWithNumId = { - 'bidder': 'trustx', - 'params': { - 'uid': 43, - }, - 'adUnitCode': 111111, - 'sizes': [[300, 250], [300, 600]], - 'mediaTypes': { - 'banner': { - 'sizes': [[300, 250], [300, 600]] - } - }, - 'bidId': 23423423, - 'bidderRequestId': 123123, - 'auctionId': 345345543, - }; - - const request = spec.buildRequests([bidRequestWithNumId], bidderRequestWithNumId); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload).to.deep.equal({ - 'id': '123123', - 'site': { - 'page': referrer - }, - 'tmax': bidderRequest.timeout, - 'source': { - 'tid': '345345543', - 'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'} - }, - 'imp': [{ - 'id': '23423423', - 'tagid': '43', - 'ext': {'divid': '111111'}, - 'banner': { - 'w': 300, - 'h': 250, - 'format': [{'w': 300, 'h': 250}, {'w': 300, 'h': 600}] - } - }] - }); - }); - - describe('floorModule', function () { - const floorTestData = { - 'currency': 'USD', - 'floor': 1.50 - }; - const bidRequest = Object.assign({ - getFloor: (_) => { - return floorTestData; - } - }, bidRequests[1]); - it('should return the value from getFloor if present', function () { - const request = spec.buildRequests([bidRequest], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.imp[0].bidfloor).to.equal(floorTestData.floor); - }); - it('should return the getFloor.floor value if it is greater than bidfloor', function () { - const bidfloor = 0.80; - const bidRequestsWithFloor = { ...bidRequest }; - bidRequestsWithFloor.params = Object.assign({bidFloor: bidfloor}, bidRequestsWithFloor.params); - const request = spec.buildRequests([bidRequestsWithFloor], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.imp[0].bidfloor).to.equal(floorTestData.floor); - }); - it('should return the bidfloor value if it is greater than getFloor.floor', function () { - const bidfloor = 1.80; - const bidRequestsWithFloor = { ...bidRequest }; - bidRequestsWithFloor.params = Object.assign({bidFloor: bidfloor}, bidRequestsWithFloor.params); - const request = spec.buildRequests([bidRequestsWithFloor], bidderRequest); - expect(request.data).to.be.an('string'); - const payload = parseRequest(request.data); - expect(payload.imp[0].bidfloor).to.equal(bidfloor); - }); - }); - }); - - describe('interpretResponse', function () { - const responses = [ - {'bid': [{'impid': '659423fff799cb', 'price': 1.15, 'adm': '
test content 1
', 'auid': 43, 'h': 250, 'w': 300, 'adomain': ['somedomain.com']}], 'seat': '1'}, - {'bid': [{'impid': '4dff80cc4ee346', 'price': 0.5, 'adm': '
test content 2
', 'auid': 44, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'impid': '5703af74d0472a', 'price': 0.15, 'adm': '
test content 3
', 'auid': 43, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'impid': '659423faac49cb', 'price': 0, 'auid': 45, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'price': 0, 'adm': '
test content 5
', 'h': 250, 'w': 300}], 'seat': '1'}, - undefined, - {'bid': [], 'seat': '1'}, - {'seat': '1'}, - ]; - - it('should get correct bid response', function () { - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '5f2009617a7c0a', - 'auctionId': '1cbd2feafe5e8b', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': ['somedomain.com'] - }, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': [responses[0]]}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should get correct multi bid response', function () { - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '659423fff799cb', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '44' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4dff80cc4ee346', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '5703af74d0472a', - 'bidderRequestId': '2c2bb1972df9a', - 'auctionId': '1fa09aee5c8c99', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '659423fff799cb', - 'cpm': 1.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': ['somedomain.com'] - }, - }, - { - 'requestId': '4dff80cc4ee346', - 'cpm': 0.5, - 'creativeId': 44, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 2
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - }, - { - 'requestId': '5703af74d0472a', - 'cpm': 0.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 3
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(0, 3)}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('handles wrong and nobid responses', function () { - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '45' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d7190gf', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '46' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '300bfeb0d71321', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '50' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '300bfeb0d7183bb', - 'bidderRequestId': '2c2bb1972d23af', - 'auctionId': '1fa09aee5c84d34', - } - ]; - const request = spec.buildRequests(bidRequests); - const result = spec.interpretResponse({'body': {'seatbid': responses.slice(3)}}, request); - expect(result.length).to.equal(0); - }); - - it('complicated case', function () { - const fullResponse = [ - {'bid': [{'impid': '2164be6358b9', 'price': 1.15, 'adm': '
test content 1
', 'auid': 43, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'impid': '4e111f1b66e4', 'price': 0.5, 'adm': '
test content 2
', 'auid': 44, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'impid': '26d6f897b516', 'price': 0.15, 'adm': '
test content 3
', 'auid': 43, 'h': 90, 'w': 728}], 'seat': '1'}, - {'bid': [{'impid': '326bde7fbf69', 'price': 0.15, 'adm': '
test content 4
', 'auid': 43, 'h': 600, 'w': 300}], 'seat': '1'}, - {'bid': [{'impid': '1751cd90161', 'price': 0.5, 'adm': '
test content 5
', 'auid': 44, 'h': 600, 'w': 350}], 'seat': '1'}, - ]; - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '2164be6358b9', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '326bde7fbf69', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '44' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '4e111f1b66e4', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '26d6f897b516', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '44' - }, - 'adUnitCode': 'adunit-code-2', - 'sizes': [[728, 90]], - 'bidId': '1751cd90161', - 'bidderRequestId': '106efe3247', - 'auctionId': '32a1f276cb87cb8', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '2164be6358b9', - 'cpm': 1.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - }, - { - 'requestId': '4e111f1b66e4', - 'cpm': 0.5, - 'creativeId': 44, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 2
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - }, - { - 'requestId': '26d6f897b516', - 'cpm': 0.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 728, - 'height': 90, - 'ad': '
test content 3
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - }, - { - 'requestId': '326bde7fbf69', - 'cpm': 0.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'ad': '
test content 4
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - }, - { - 'requestId': '1751cd90161', - 'cpm': 0.5, - 'creativeId': 44, - 'dealId': undefined, - 'width': 350, - 'height': 600, - 'ad': '
test content 5
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('dublicate uids and sizes in one slot', function () { - const fullResponse = [ - {'bid': [{'impid': '5126e301f4be', 'price': 1.15, 'adm': '
test content 1
', 'auid': 43, 'h': 250, 'w': 300}], 'seat': '1'}, - {'bid': [{'impid': '57b2ebe70e16', 'price': 0.5, 'adm': '
test content 2
', 'auid': 43, 'h': 250, 'w': 300}], 'seat': '1'}, - ]; - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '5126e301f4be', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '57b2ebe70e16', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '43' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '225fcd44b18c', - 'bidderRequestId': '171c5405a390', - 'auctionId': '35bcbc0f7e79c', - } - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '5126e301f4be', - 'cpm': 1.15, - 'creativeId': 43, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 1
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - }, - { - 'requestId': '57b2ebe70e16', - 'cpm': 0.5, - 'creativeId': 43, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'ad': '
test content 2
', - 'currency': 'USD', - 'mediaType': 'banner', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': fullResponse}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - }); - - it('should get correct video bid response', function () { - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '50' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '57dfefb80eca', - 'bidderRequestId': '20394420a762a2', - 'auctionId': '140132d07b031', - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '51' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'e893c787c22dd', - 'bidderRequestId': '20394420a762a2', - 'auctionId': '140132d07b031', - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '52' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '23312a43bc42', - 'bidderRequestId': '20394420a762a2', - 'auctionId': '140132d07b031', - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } - } - ]; - const response = [ - {'bid': [{'impid': '57dfefb80eca', 'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 50, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'impid': '5126e301f4be', 'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 51, content_type: 'video'}], 'seat': '2'}, - {'bid': [{'impid': '23312a43bc42', 'price': 2.00, 'nurl': 'https://some_test_vast_url.com', 'auid': 52, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': '57dfefb80eca', - 'cpm': 1.15, - 'creativeId': 50, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'currency': 'USD', - 'mediaType': 'video', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - } - }, - { - 'requestId': '23312a43bc42', - 'cpm': 2.00, - 'creativeId': 52, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'currency': 'USD', - 'mediaType': 'video', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - 'vastUrl': 'https://some_test_vast_url.com', - }, - ]; - - const result = spec.interpretResponse({'body': {'seatbid': response}}, request); - expect(result).to.deep.equal(expectedResponse); - }); - - it('should have right renderer in the bid response', function () { - const spySetRenderer = sinon.spy(); - const stubRenderer = { - setRender: spySetRenderer - }; - const spyRendererInstall = sinon.spy(function() { return stubRenderer; }); - const stubRendererConst = { - install: spyRendererInstall - }; - const bidRequests = [ - { - 'bidder': 'trustx', - 'params': { - 'uid': '50' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'e6e65553fc8', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3', - 'mediaTypes': { - 'video': { - 'context': 'outstream' - } - } - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '51' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': 'c8fdcb3f269f', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3' - }, - { - 'bidder': 'trustx', - 'params': { - 'uid': '52' - }, - 'adUnitCode': 'adunit-code-1', - 'sizes': [[300, 250], [300, 600]], - 'bidId': '1de036c37685', - 'bidderRequestId': '1380f393215dc7', - 'auctionId': '10b8d2f3c697e3', - 'renderer': {} - } - ]; - const response = [ - {'bid': [{'impid': 'e6e65553fc8', 'price': 1.15, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 50, content_type: 'video', w: 300, h: 600}], 'seat': '2'}, - {'bid': [{'impid': 'c8fdcb3f269f', 'price': 1.00, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 51, content_type: 'video', w: 300, h: 250}], 'seat': '2'}, - {'bid': [{'impid': '1de036c37685', 'price': 1.20, 'adm': '\n<\/Ad>\n<\/VAST>', 'auid': 52, content_type: 'video', w: 300, h: 250}], 'seat': '2'} - ]; - const request = spec.buildRequests(bidRequests); - const expectedResponse = [ - { - 'requestId': 'e6e65553fc8', - 'cpm': 1.15, - 'creativeId': 50, - 'dealId': undefined, - 'width': 300, - 'height': 600, - 'currency': 'USD', - 'mediaType': 'video', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - }, - 'renderer': stubRenderer - }, - { - 'requestId': 'c8fdcb3f269f', - 'cpm': 1.00, - 'creativeId': 51, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'currency': 'USD', - 'mediaType': 'video', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - }, - 'renderer': stubRenderer - }, - { - 'requestId': '1de036c37685', - 'cpm': 1.20, - 'creativeId': 52, - 'dealId': undefined, - 'width': 300, - 'height': 250, - 'currency': 'USD', - 'mediaType': 'video', - 'netRevenue': false, - 'ttl': 360, - 'meta': { - 'advertiserDomains': [] - }, - 'vastXml': '\n<\/Ad>\n<\/VAST>', - 'adResponse': { - 'content': '\n<\/Ad>\n<\/VAST>' - } - } - ]; - - const result = spec.interpretResponse({'body': {'seatbid': response}}, request, stubRendererConst); - - expect(spySetRenderer.calledTwice).to.equal(true); - expect(spySetRenderer.getCall(0).args[0]).to.be.a('function'); - expect(spySetRenderer.getCall(1).args[0]).to.be.a('function'); - - expect(spyRendererInstall.calledTwice).to.equal(true); - expect(spyRendererInstall.getCall(0).args[0]).to.deep.equal({ - id: 'e6e65553fc8', - url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', - loaded: false - }); - expect(spyRendererInstall.getCall(1).args[0]).to.deep.equal({ - id: 'c8fdcb3f269f', - url: 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js', - loaded: false - }); - - expect(result).to.deep.equal(expectedResponse); - }); -}); diff --git a/test/spec/modules/ttdBidAdapter_spec.js b/test/spec/modules/ttdBidAdapter_spec.js index 099e5e56c33..1fe504ba8e8 100644 --- a/test/spec/modules/ttdBidAdapter_spec.js +++ b/test/spec/modules/ttdBidAdapter_spec.js @@ -2,6 +2,9 @@ import { expect } from 'chai'; import { spec } from 'modules/ttdBidAdapter'; import { deepClone } from 'src/utils.js'; import { config } from 'src/config'; +import { detectReferer } from 'src/refererDetection.js'; + +import { buildWindowTree } from '../../helpers/refererDetectionHelper'; describe('ttdBidAdapter', function () { function testBuildRequests(bidRequests, bidderRequestBase) { @@ -17,8 +20,7 @@ describe('ttdBidAdapter', function () { 'params': { 'supplySourceId': 'supplier', 'publisherId': '22222222', - 'placementId': 'some-PlacementId_1', - 'siteId': 'testSiteId' + 'placementId': 'some-PlacementId_1' }, 'mediaTypes': { 'banner': { @@ -57,34 +59,39 @@ describe('ttdBidAdapter', function () { expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when siteId not passed', function () { + it('should return true if placementId is not passed and gpid is passed', function () { let bid = makeBid(); - delete bid.params.siteId; - expect(spec.isBidRequestValid(bid)).to.equal(false); + delete bid.params.placementId; + bid.ortb2Imp = { + ext: { + gpid: '/1111/home#header' + } + } + expect(spec.isBidRequestValid(bid)).to.equal(true); }); - it('should return false when siteId is longer than 50 characters', function () { + it('should return false if neither placementId nor gpid is passed', function () { let bid = makeBid(); - bid.params.siteId = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' + delete bid.params.placementId; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when placementId not passed', function () { + it('should return false if neither mediaTypes.banner nor mediaTypes.video is passed', function () { let bid = makeBid(); - delete bid.params.placementId; + delete bid.mediaTypes expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false when the placementId is longer than 128 characters', function () { + it('should return false if bidfloor is passed incorrectly', function () { let bid = makeBid(); - bid.params.placementId = '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'; // 130 characters + bid.params.bidfloor = 'invalid bidfloor'; expect(spec.isBidRequestValid(bid)).to.equal(false); }); - it('should return false if neither mediaTypes.banner nor mediaTypes.video is passed', function () { + it('should return true if bidfloor is passed correctly as a float', function () { let bid = makeBid(); - delete bid.mediaTypes - expect(spec.isBidRequestValid(bid)).to.equal(false); + bid.params.bidfloor = 3.01; + expect(spec.isBidRequestValid(bid)).to.equal(true); }); }); @@ -97,13 +104,16 @@ describe('ttdBidAdapter', function () { }); describe('video', function () { + if (!FEATURES.VIDEO) { + return; + } + function makeBid() { return { 'bidder': 'ttd', 'params': { 'supplySourceId': 'supplier', 'publisherId': '22222222', - 'siteId': 'testSiteId123', 'placementId': 'somePlacementId' }, 'mediaTypes': { @@ -187,17 +197,21 @@ describe('ttdBidAdapter', function () { 'params': { 'supplySourceId': 'supplier', 'publisherId': '13144370', - 'placementId': '1gaa015', - 'siteId': 'testSiteId123' + 'placementId': '1gaa015' }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [300, 600]] } }, + 'ortb2Imp': { + 'ext': { + 'tid': '8651474f-58b1-4368-b812-84f8c937a099', + } + }, 'sizes': [[300, 250], [300, 600]], + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '8651474f-58b1-4368-b812-84f8c937a099', 'bidId': '243310435309b5', 'bidderRequestId': '18084284054531', 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', @@ -205,24 +219,42 @@ describe('ttdBidAdapter', function () { 'bidRequestsCount': 1 }]; + const testWindow = buildWindowTree(['https://www.example.com/test', 'https://www.example.com/other/page', 'https://www.example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'); + const baseBidderRequestReferer = detectReferer(testWindow)(); const baseBidderRequest = { 'bidderCode': 'ttd', - 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + ortb2: { + source: { + tid: 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + } + }, 'bidderRequestId': '18084284054531', 'auctionStart': 1540945362095, 'timeout': 3000, - 'refererInfo': { - 'referer': 'https://www.example.com/test', - 'reachedTop': true, - 'numIframes': 0, - 'stack': [ - 'https://www.example.com/test' - ] - }, + 'refererInfo': baseBidderRequestReferer, 'start': 1540945362099, 'doneCbCallCount': 0 }; + const extFirstPartyDataValues = ['value', 'value2']; + const extFirstPartyData = { + data: { + firstPartyKey: 'firstPartyValue', + firstPartyKey2: extFirstPartyDataValues + }, + custom: 'custom_data', + custom_kvp: { + customKey: 'customValue' + } + } + + function validateExtFirstPartyData(ext) { + expect(ext.data.firstPartyKey).to.equal('firstPartyValue'); + expect(ext.data.firstPartyKey2).to.eql(extFirstPartyDataValues); + expect(ext.custom).to.equal('custom_data'); + expect(ext.custom_kvp.customKey).to.equal('customValue'); + } + it('sends bid request to our endpoint that makes sense', function () { const request = testBuildRequests(baseBannerBidRequests, baseBidderRequest); expect(request.method).to.equal('POST'); @@ -230,6 +262,11 @@ describe('ttdBidAdapter', function () { expect(request.data).to.be.not.null; }); + it('sets bidrequest.id to bidderRequestId', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; + expect(requestBody.id).to.equal('18084284054531'); + }); + it('sets impression id to ad unit\'s bid id', function () { const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; expect(requestBody.imp[0].id).to.equal('243310435309b5'); @@ -240,16 +277,64 @@ describe('ttdBidAdapter', function () { expect(url).to.equal('https://direct.adsrvr.org/bid/bidder/supplier'); }); - it('sends publisher id, site id, and placement id', function () { + it('sends publisher id', function () { const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; expect(requestBody.site).to.be.not.null; expect(requestBody.site.publisher).to.be.not.null; - expect(requestBody.imp[0].tagid).to.be.not.null; expect(requestBody.site.publisher.id).to.equal(baseBannerBidRequests[0].params.publisherId); - expect(requestBody.site.id).to.equal(baseBannerBidRequests[0].params.siteId); + }); + + it('sends placement id in tagid', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; expect(requestBody.imp[0].tagid).to.equal(baseBannerBidRequests[0].params.placementId); }); + it('sends gpid in tagid if present', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + const gpid = '/1111/home#header'; + clonedBannerRequests[0].ortb2Imp = { + ext: { + gpid: gpid + } + }; + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + expect(requestBody.imp[0].tagid).to.equal(gpid); + }); + + it('sends gpid in ext.gpid if present', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + const gpid = '/1111/home#header'; + clonedBannerRequests[0].ortb2Imp = { + ext: { + gpid: gpid + } + }; + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + expect(requestBody.imp[0].ext).to.be.not.null; + expect(requestBody.imp[0].ext.gpid).to.equal(gpid); + }); + + it('sends rwdd in imp.rwdd if present', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + const gpid = '/1111/home#header'; + const rwdd = 1; + clonedBannerRequests[0].ortb2Imp = { + rwdd: rwdd, + ext: { + gpid: gpid + } + }; + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + expect(requestBody.imp[0].rwdd).to.be.not.null; + expect(requestBody.imp[0].rwdd).to.equal(1); + }); + + it('sends source.tid', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; + expect(requestBody.source).to.be.not.null; + expect(requestBody.source.tid).to.equal(baseBidderRequest.ortb2.source.tid); + }); + it('includes the ad size in the bid request', function () { const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; expect(requestBody.imp[0].banner.format[0].w).to.equal(300); @@ -263,6 +348,11 @@ describe('ttdBidAdapter', function () { expect(requestBody.site.page).to.equal('https://www.example.com/test'); }); + it('ensure top most location is used', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; + expect(requestBody.site.page).to.equal('https://www.example.com/test'); + }); + it('sets the banner pos correctly if sent', function () { let clonedBannerRequests = deepClone(baseBannerBidRequests); clonedBannerRequests[0].mediaTypes.banner.pos = 1; @@ -282,19 +372,82 @@ describe('ttdBidAdapter', function () { expect(requestBody.imp[0].banner.expdir).to.equal(expdir); }); - it('sets keywords properly if sent', function () { - let clonedBannerRequests = deepClone(baseBannerBidRequests); + it('merges first party site data', function () { + const ortb2 = { + site: { + publisher: { + domain: 'https://foo.bar', + } + } + }; + const baseBidderRequestWithoutRefererDomain = { + ...baseBidderRequest, + refererInfo: { + ...baseBannerBidRequests.referer, + domain: null + } + } + const requestBody = testBuildRequests( + baseBannerBidRequests, {...baseBidderRequestWithoutRefererDomain, ortb2} + ).data; + config.resetConfig(); + expect(requestBody.site.publisher).to.deep.equal({domain: 'https://foo.bar', id: '13144370'}); + }); - config.setConfig({ortb2: { + it('referer domain overrides first party site data publisher domain', function () { + const ortb2 = { + site: { + publisher: { + domain: 'https://foo.bar', + } + } + }; + const requestBody = testBuildRequests( + baseBannerBidRequests, {...baseBidderRequest, ortb2} + ).data; + config.resetConfig(); + expect(requestBody.site.publisher.domain).to.equal(baseBidderRequest.refererInfo.domain); + }); + + it('sets keywords properly if sent', function () { + const ortb2 = { site: { keywords: 'highViewability, clothing, holiday shopping' } - }}); - const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + }; + const requestBody = testBuildRequests(baseBannerBidRequests, {...baseBidderRequest, ortb2}).data; config.resetConfig(); expect(requestBody.ext.ttdprebid.keywords).to.deep.equal(['highViewability', 'clothing', 'holiday shopping']); }); + it('sets bcat properly if sent', function () { + const ortb2 = { + bcat: ['IAB1-1', 'IAB2-9'] + }; + const requestBody = testBuildRequests(baseBannerBidRequests, {...baseBidderRequest, ortb2}).data; + config.resetConfig(); + expect(requestBody.bcat).to.deep.equal(['IAB1-1', 'IAB2-9']); + }); + + it('sets badv properly if sent', function () { + const ortb2 = { + badv: ['adv1.com', 'adv2.com'] + }; + const requestBody = testBuildRequests(baseBannerBidRequests, {...baseBidderRequest, ortb2}).data; + config.resetConfig(); + expect(requestBody.badv).to.deep.equal(['adv1.com', 'adv2.com']); + }); + + it('sets battr properly if present', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + const battr = [1, 2, 3]; + clonedBannerRequests[0].ortb2Imp = { + battr: battr + }; + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + expect(requestBody.imp[0].banner.battr).to.equal(battr); + }); + it('sets ext properly', function () { let clonedBannerRequests = deepClone(baseBannerBidRequests); @@ -333,6 +486,20 @@ describe('ttdBidAdapter', function () { expect(requestBody.regs.coppa).to.equal(1); }); + it('adds gpp consent info to the request', function () { + const ortb2 = { + regs: { + gpp: 'somegppstring', + gpp_sid: [6, 7] + } + }; + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; + const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; + config.resetConfig(); + expect(requestBody.regs.gpp).to.equal('somegppstring'); + expect(requestBody.regs.gpp_sid).to.eql([6, 7]); + }); + it('adds schain info to the request', function () { const schain = { 'ver': '1.0', @@ -369,13 +536,7 @@ describe('ttdBidAdapter', function () { const TDID = '00000000-0000-0000-0000-000000000000'; const UID2 = '99999999-9999-9999-9999-999999999999'; let clonedBannerRequests = deepClone(baseBannerBidRequests); - clonedBannerRequests[0].userId = { - tdid: TDID, - uid2: { - id: UID2 - } - }; - const expectedEids = [ + clonedBannerRequests[0].userIdAsEids = [ { source: 'adserver.org', uids: [ @@ -398,15 +559,14 @@ describe('ttdBidAdapter', function () { ] } ]; + const expectedEids = clonedBannerRequests[0].userIdAsEids; const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; expect(requestBody.user.ext.eids).to.deep.equal(expectedEids); }); it('adds first party site data to the request', function () { - let clonedBidderRequest = deepClone(baseBidderRequest); - - config.setConfig({ortb2: { + const ortb2 = { site: { name: 'example', domain: 'page.example.com', @@ -417,9 +577,9 @@ describe('ttdBidAdapter', function () { ref: 'https://ref.example.com', keywords: 'power tools, drills' } - }}); + }; + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; - config.resetConfig(); expect(requestBody.site.name).to.equal('example'); expect(requestBody.site.domain).to.equal('page.example.com'); expect(requestBody.site.cat[0]).to.equal('IAB2'); @@ -429,6 +589,126 @@ describe('ttdBidAdapter', function () { expect(requestBody.site.ref).to.equal('https://ref.example.com'); expect(requestBody.site.keywords).to.equal('power tools, drills'); }); + + it('should fallback to floor module if no bidfloor is sent ', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + const bidfloor = 5.00; + clonedBannerRequests[0].getFloor = () => { + return { currency: 'USD', floor: bidfloor }; + }; + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + config.resetConfig(); + expect(requestBody.imp[0].bidfloor).to.equal(bidfloor); + }); + + it('adds default value for secure if not set to request', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data; + expect(requestBody.imp[0].secure).to.equal(1); + }); + + it('adds secure to request', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + clonedBannerRequests[0].ortb2Imp.secure = 0; + + let requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + expect(0).to.equal(requestBody.imp[0].secure); + + clonedBannerRequests[0].ortb2Imp.secure = 1; + requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + expect(1).to.equal(requestBody.imp[0].secure); + }); + + it('adds all of site first party data to request', function() { + const ortb2 = { + site: { + ext: extFirstPartyData, + search: 'test search' + } + }; + + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; + const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; + + validateExtFirstPartyData(requestBody.site.ext) + expect(requestBody.site.search).to.equal('test search') + }); + + it('adds all of user first party data to request', function() { + const ortb2 = { + user: { + ext: extFirstPartyData, + yob: 1998 + } + }; + + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; + const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; + + validateExtFirstPartyData(requestBody.user.ext) + expect(requestBody.user.yob).to.equal(1998) + }); + + it('adds all of imp first party data to request', function() { + const metric = { type: 'viewability', value: 0.8 }; + let clonedBannerRequests = deepClone(baseBannerBidRequests); + clonedBannerRequests[0].ortb2Imp = { + ext: extFirstPartyData, + metric: [metric], + clickbrowser: 1 + }; + + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data; + + validateExtFirstPartyData(requestBody.imp[0].ext) + expect(requestBody.imp[0].tagid).to.equal('1gaa015'); + expect(requestBody.imp[0].metric[0]).to.deep.equal(metric); + expect(requestBody.imp[0].clickbrowser).to.equal(1) + }); + + it('adds all of app first party data to request', function() { + const ortb2 = { + app: { + ext: extFirstPartyData, + ver: 'v1.0' + } + }; + + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; + const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; + + validateExtFirstPartyData(requestBody.app.ext) + expect(requestBody.app.ver).to.equal('v1.0') + }); + + it('adds all of device first party data to request', function() { + const ortb2 = { + device: { + ext: extFirstPartyData, + os: 'iPhone' + } + }; + + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; + const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; + + validateExtFirstPartyData(requestBody.device.ext) + expect(requestBody.device.os).to.equal('iPhone') + }); + + it('adds all of pmp first party data to request', function() { + const ortb2 = { + pmp: { + ext: extFirstPartyData, + private_auction: 1 + } + }; + + let clonedBidderRequest = {...deepClone(baseBidderRequest), ortb2}; + const requestBody = testBuildRequests(baseBannerBidRequests, clonedBidderRequest).data; + + validateExtFirstPartyData(requestBody.pmp.ext) + expect(requestBody.pmp.private_auction).to.equal(1) + }); }); describe('buildRequests-banner-multiple', function () { @@ -444,9 +724,14 @@ describe('ttdBidAdapter', function () { 'sizes': [[300, 250], [300, 600]] } }, + 'ortb2Imp': { + 'ext': { + 'tid': '8651474f-58b1-4368-b812-84f8c937a099', + } + }, 'sizes': [[300, 250], [300, 600]], + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '8651474f-58b1-4368-b812-84f8c937a099', 'bidId': 'small', 'bidderRequestId': '18084284054531', 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', @@ -456,17 +741,21 @@ describe('ttdBidAdapter', function () { 'bidder': 'ttd', 'params': { 'publisherId': '13144370', - 'placementId': 'top', - 'siteId': 'testSite123' + 'placementId': 'top' }, 'mediaTypes': { 'banner': { 'sizes': [[728, 90]] } }, + 'ortb2Imp': { + 'ext': { + 'tid': '12345678-58b1-4368-b812-84f8c937a099', + } + }, 'sizes': [[728, 90]], - 'adUnitCode': 'div-gpt-ad-91515710-0', 'transactionId': '825c1228-ca8c-4657-b40f-2df500621527', + 'adUnitCode': 'div-gpt-ad-91515710-0', 'bidId': 'large', 'bidderRequestId': '18084284054531', 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', @@ -476,7 +765,11 @@ describe('ttdBidAdapter', function () { const baseBidderRequest = { 'bidderCode': 'ttd', - 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + ortb2: { + source: { + tid: 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + } + }, 'bidderRequestId': '18084284054531', 'auctionStart': 1540945362095, 'timeout': 3000, @@ -495,6 +788,12 @@ describe('ttdBidAdapter', function () { it('sends multiple impressions', function () { const requestBody = testBuildRequests(baseBannerMultipleBidRequests, baseBidderRequest).data; expect(requestBody.imp.length).to.equal(2); + expect(requestBody.source).to.be.not.null; + expect(requestBody.source.tid).to.equal(baseBidderRequest.ortb2.source.tid); + expect(requestBody.imp[0].ext).to.be.not.null; + expect(requestBody.imp[0].ext.tid).to.equal('8651474f-58b1-4368-b812-84f8c937a099'); + expect(requestBody.imp[1].ext).to.be.not.null; + expect(requestBody.imp[1].ext.tid).to.equal('12345678-58b1-4368-b812-84f8c937a099'); }); it('sends the right tag ids for each ad unit', function () { @@ -529,6 +828,10 @@ describe('ttdBidAdapter', function () { }); describe('buildRequests-display-video-multiformat', function () { + if (!FEATURES.VIDEO) { + return; + } + const baseMultiformatBidRequests = [{ 'bidder': 'ttd', 'params': { @@ -549,8 +852,13 @@ describe('ttdBidAdapter', function () { 'sizes': [[300, 250], [300, 600]] } }, + 'ortb2Imp': { + 'ext': { + 'tid': '8651474f-58b1-4368-b812-84f8c937a099', + } + }, + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '8651474f-58b1-4368-b812-84f8c937a099', 'bidId': '243310435309b5', 'bidderRequestId': '18084284054531', 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', @@ -592,6 +900,10 @@ describe('ttdBidAdapter', function () { }); describe('buildRequests-video', function () { + if (!FEATURES.VIDEO) { + return; + } + const baseVideoBidRequests = [{ 'bidder': 'ttd', 'params': { @@ -609,8 +921,13 @@ describe('ttdBidAdapter', function () { 'maxduration': 30 } }, + 'ortb2Imp': { + 'ext': { + 'tid': '8651474f-58b1-4368-b812-84f8c937a099', + } + }, + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', 'adUnitCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': '8651474f-58b1-4368-b812-84f8c937a099', 'bidId': '243310435309b5', 'bidderRequestId': '18084284054531', 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', @@ -728,6 +1045,14 @@ describe('ttdBidAdapter', function () { const requestBody = testBuildRequests(clonedVideoRequests, baseBidderRequest).data; expect(requestBody.imp[0].video.placement).to.equal(3); }); + + it('sets plcmt correctly if sent', function () { + let clonedVideoRequests = deepClone(baseVideoBidRequests); + clonedVideoRequests[0].mediaTypes.video.plcmt = 3; + + const requestBody = testBuildRequests(clonedVideoRequests, baseBidderRequest).data; + expect(requestBody.imp[0].video.plcmt).to.equal(3); + }); }); describe('interpretResponse-empty', function () { @@ -1014,6 +1339,10 @@ describe('ttdBidAdapter', function () { }); describe('interpretResponse-simple-video', function () { + if (!FEATURES.VIDEO) { + return; + } + const incoming = { 'body': { 'cur': 'USD', @@ -1107,8 +1436,7 @@ describe('ttdBidAdapter', function () { } }; - const expectedBid = - { + const expectedBid = { 'requestId': '2eabb87dfbcae4', 'cpm': 13.6, 'creativeId': 'mokivv6m', @@ -1146,6 +1474,10 @@ describe('ttdBidAdapter', function () { }); describe('interpretResponse-display-and-video', function () { + if (!FEATURES.VIDEO) { + return; + } + const incoming = { 'body': { 'id': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', diff --git a/test/spec/modules/ucfunnelBidAdapter_spec.js b/test/spec/modules/ucfunnelBidAdapter_spec.js index ac788e537e2..9bec7229450 100644 --- a/test/spec/modules/ucfunnelBidAdapter_spec.js +++ b/test/spec/modules/ucfunnelBidAdapter_spec.js @@ -1,11 +1,16 @@ import { expect } from 'chai'; import { spec } from 'modules/ucfunnelBidAdapter.js'; import {BANNER, VIDEO, NATIVE} from 'src/mediaTypes.js'; +import {deepClone} from '../../../src/utils.js'; const URL = 'https://hb.aralego.com/header'; const BIDDER_CODE = 'ucfunnel'; const bidderRequest = { - uspConsent: '1YNN' + uspConsent: '1YNN', + refererInfo: { + domain: 'example.com', + page: 'http://example.com/index.html' + } }; const userId = { @@ -17,7 +22,6 @@ const userId = { 'tdid': 'D6885E90-2A7A-4E0F-87CB-7734ED1B99A3', 'haloId': {}, 'uid2': {'id': 'eb33b0cb-8d35-4722-b9c0-1a31d4064888'}, - 'flocId': {'id': '12144', 'version': 'chrome.1.1'}, 'connectid': '4567' } @@ -29,6 +33,11 @@ const validBannerBidReq = { sizes: [[300, 250]], bidId: '263be71e91dd9d', auctionId: '9ad1fa8d-2297-4660-a018-b39945054746', + ortb2Imp: { + ext: { + gpid: '/1111/homepage#div-leftnav' + } + }, userId: userId, 'schain': { 'ver': '1.0', @@ -142,7 +151,10 @@ describe('ucfunnel Adapter', function () { }); }); describe('build request', function () { - const request = spec.buildRequests([validBannerBidReq], bidderRequest); + let request; + before(() => { + request = spec.buildRequests([validBannerBidReq], bidderRequest); + }) it('should create a POST request for every bid', function () { expect(request[0].method).to.equal('GET'); expect(request[0].url).to.equal(spec.ENDPOINT); @@ -152,6 +164,11 @@ describe('ucfunnel Adapter', function () { expect(request[0].bidRequest).to.equal(validBannerBidReq); }); + it('should set gpid if configured', function () { + const data = request[0].data; + expect(data.gpid).to.equal('/1111/homepage#div-leftnav'); + }); + it('should attach request data', function () { const data = request[0].data; const [ width, height ] = validBannerBidReq.sizes[0]; @@ -160,43 +177,43 @@ describe('ucfunnel Adapter', function () { expect(data.w).to.equal(width); expect(data.h).to.equal(height); expect(data.eids).to.equal('uid2,eb33b0cb-8d35-4722-b9c0-1a31d4064888!verizonMediaId,4567'); - expect(data.cid).to.equal('12144'); expect(data.schain).to.equal('1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com'); }); it('must parse bid size from a nested array', function () { const width = 640; const height = 480; - validBannerBidReq.sizes = [[ width, height ]]; - const requests = spec.buildRequests([ validBannerBidReq ]); + const bid = deepClone(validBannerBidReq); + bid.sizes = [[ width, height ]]; + const requests = spec.buildRequests([ bid ], bidderRequest); const data = requests[0].data; expect(data.w).to.equal(width); expect(data.h).to.equal(height); }); it('should set bidfloor if configured', function() { - let bid = Object.assign({}, validBannerBidReq); + let bid = deepClone(validBannerBidReq); bid.getFloor = function() { return { currency: 'USD', floor: 2.02 } }; - const requests = spec.buildRequests([ bid ]); + const requests = spec.buildRequests([ bid ], bidderRequest); const data = requests[0].data; expect(data.fp).to.equal(2.02); }); it('should set bidfloor if configured', function() { - let bid = Object.assign({}, validBannerBidReq); + let bid = deepClone(validBannerBidReq); bid.params.bidfloor = 2.01; - const requests = spec.buildRequests([ bid ]); + const requests = spec.buildRequests([ bid ], bidderRequest); const data = requests[0].data; expect(data.fp).to.equal(2.01); }); it('should set bidfloor if configured', function() { - let bid = Object.assign({}, validBannerBidReq); + let bid = deepClone(validBannerBidReq); bid.getFloor = function() { return { currency: 'USD', @@ -204,7 +221,7 @@ describe('ucfunnel Adapter', function () { } }; bid.params.bidfloor = 2.01; - const requests = spec.buildRequests([ bid ]); + const requests = spec.buildRequests([ bid ], bidderRequest); const data = requests[0].data; expect(data.fp).to.equal(2.01); }); @@ -212,8 +229,12 @@ describe('ucfunnel Adapter', function () { describe('interpretResponse', function () { describe('should support banner', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: validBannerBidRes}, request[0]); + let request, result; + before(() => { + request = spec.buildRequests([ validBannerBidReq ], bidderRequest); + result = spec.interpretResponse({body: validBannerBidRes}, request[0]); + }); + it('should build bid array for banner', function () { expect(result.length).to.equal(1); }); @@ -231,8 +252,11 @@ describe('ucfunnel Adapter', function () { }); describe('handle banner no ad', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); + let request, result; + before(() => { + request = spec.buildRequests([ validBannerBidReq ], bidderRequest); + result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); + }) it('should build bid array for banner', function () { expect(result.length).to.equal(1); }); @@ -249,8 +273,11 @@ describe('ucfunnel Adapter', function () { }); describe('handle banner cpm under bidfloor', function () { - const request = spec.buildRequests([ validBannerBidReq ]); - const result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); + let request, result; + before(() => { + request = spec.buildRequests([ validBannerBidReq ], bidderRequest); + result = spec.interpretResponse({body: invalidBannerBidRes}, request[0]); + }) it('should build bid array for banner', function () { expect(result.length).to.equal(1); }); @@ -267,8 +294,11 @@ describe('ucfunnel Adapter', function () { }); describe('should support video', function () { - const request = spec.buildRequests([ validVideoBidReq ]); - const result = spec.interpretResponse({body: validVideoBidRes}, request[0]); + let request, result; + before(() => { + request = spec.buildRequests([ validVideoBidReq ], bidderRequest); + result = spec.interpretResponse({body: validVideoBidRes}, request[0]); + }) it('should build bid array', function () { expect(result.length).to.equal(1); }); @@ -287,8 +317,11 @@ describe('ucfunnel Adapter', function () { }); describe('should support native', function () { - const request = spec.buildRequests([ validNativeBidReq ]); - const result = spec.interpretResponse({body: validNativeBidRes}, request[0]); + let request, result; + before(() => { + request = spec.buildRequests([ validNativeBidReq ], bidderRequest); + result = spec.interpretResponse({body: validNativeBidRes}, request[0]); + }) it('should build bid array', function () { expect(result.length).to.equal(1); }); diff --git a/test/spec/modules/uid2IdSystem_helpers.js b/test/spec/modules/uid2IdSystem_helpers.js new file mode 100644 index 00000000000..5006a50dedd --- /dev/null +++ b/test/spec/modules/uid2IdSystem_helpers.js @@ -0,0 +1,70 @@ +import {setConsentConfig} from 'modules/consentManagement.js'; +import {server} from 'test/mocks/xhr.js'; +import {coreStorage, requestBidsHook} from 'modules/userId/index.js'; + +const msIn12Hours = 60 * 60 * 12 * 1000; +const expireCookieDate = 'Thu, 01 Jan 1970 00:00:01 GMT'; + +export const cookieHelpers = { + getFutureCookieExpiry: () => new Date(Date.now() + msIn12Hours).toUTCString(), + setPublisherCookie: (cookieName, token) => coreStorage.setCookie(cookieName, JSON.stringify(token), cookieHelpers.getFutureCookieExpiry()), + clearCookies: (...cookieNames) => cookieNames.forEach(cookieName => coreStorage.setCookie(cookieName, '', expireCookieDate)), +} + +export const runAuction = async () => { + const adUnits = [{ + code: 'adUnit-code', + mediaTypes: {banner: {}, native: {}}, + sizes: [[300, 200], [300, 600]], + bids: [{bidder: 'sampleBidder', params: {placementId: 'banner-only-bidder'}}] + }]; + return new Promise(function(resolve) { + requestBidsHook(function() { + resolve(adUnits[0].bids[0]); + }, {adUnits}); + }); +} + +export const apiHelpers = { + makeTokenResponse: (token, shouldRefresh = false, expired = false) => ({ + advertising_token: token, + refresh_token: 'fake-refresh-token', + identity_expires: expired ? Date.now() - 1000 : Date.now() + 60 * 60 * 1000, + refresh_from: shouldRefresh ? Date.now() - 1000 : Date.now() + 60 * 1000, + refresh_expires: Date.now() + 24 * 60 * 60 * 1000, // 24 hours + refresh_response_key: 'wR5t6HKMfJ2r4J7fEGX9Gw==', // Fake data + }), + respondAfterDelay: (delay, srv = server) => new Promise((resolve) => setTimeout(() => { + srv.respond(); + setTimeout(() => resolve()); + }, delay)), +} + +export const setGdprApplies = (consent = false) => { + const consentDetails = consent ? { + tcString: 'CPhJRpMPhJRpMABAMBFRACBoALAAAEJAAIYgAKwAQAKgArABAAqAAA', + purpose: { + consents: { + '1': true, + }, + }, + vendor: { + consents: { + '21': true, + }, + } + + } : { + tcString: 'CPhJRpMPhJRpMABAMBFRACBoALAAAEJAAIYgAKwAQAKgArABAAqAAA' + }; + const staticConfig = { + cmpApi: 'static', + timeout: 7500, + consentData: { + gdprApplies: true, + ...consentDetails + } + } + setConsentConfig(staticConfig); + return staticConfig; +} diff --git a/test/spec/modules/uid2IdSystem_spec.js b/test/spec/modules/uid2IdSystem_spec.js new file mode 100644 index 00000000000..f33060869df --- /dev/null +++ b/test/spec/modules/uid2IdSystem_spec.js @@ -0,0 +1,345 @@ +/* eslint-disable no-console */ + +import {coreStorage, init, setSubmoduleRegistry, requestBidsHook} from 'modules/userId/index.js'; +import {config} from 'src/config.js'; +import * as utils from 'src/utils.js'; +import { uid2IdSubmodule } from 'modules/uid2IdSystem.js'; +import 'src/prebid.js'; +import 'modules/consentManagement.js'; +import { getGlobal } from 'src/prebidGlobal.js'; +import { configureTimerInterceptors } from 'test/mocks/timers.js'; +import { cookieHelpers, runAuction, apiHelpers, setGdprApplies } from './uid2IdSystem_helpers.js'; +import {hook} from 'src/hook.js'; +import {uninstall as uninstallGdprEnforcement} from 'modules/gdprEnforcement.js'; + +let expect = require('chai').expect; + +const clearTimersAfterEachTest = true; +const debugOutput = () => {}; + +const moduleCookieName = '__uid2_advertising_token'; +const publisherCookieName = '__UID2_SERVER_COOKIE'; +const auctionDelayMs = 10; +const initialToken = `initial-advertising-token`; +const legacyToken = 'legacy-advertising-token'; +const refreshedToken = 'refreshed-advertising-token'; + +const legacyConfigParams = {storage: null}; +const serverCookieConfigParams = { uid2ServerCookie: publisherCookieName }; +const newServerCookieConfigParams = { uid2Cookie: publisherCookieName }; + +const makeUid2IdentityContainer = (token) => ({uid2: {id: token}}); +let useLocalStorage = false; +const makePrebidConfig = (params = null, extraSettings = {}, debug = false) => ({ + userSync: { auctionDelay: auctionDelayMs, userIds: [{name: 'uid2', params: {storage: useLocalStorage ? 'localStorage' : 'cookie', ...params}}] }, debug, ...extraSettings +}); + +const getFromAppropriateStorage = () => { + if (useLocalStorage) return coreStorage.getDataFromLocalStorage(moduleCookieName); + else return coreStorage.getCookie(moduleCookieName); +} + +const expectToken = (bid, token) => expect(bid?.userId ?? {}).to.deep.include(makeUid2IdentityContainer(token)); +const expectLegacyToken = (bid) => expect(bid.userId).to.deep.include(makeUid2IdentityContainer(legacyToken)); +const expectNoIdentity = (bid) => expect(bid).to.not.haveOwnProperty('userId'); +const expectGlobalToHaveToken = (token) => expect(getGlobal().getUserIds()).to.deep.include(makeUid2IdentityContainer(token)); +const expectGlobalToHaveNoUid2 = () => expect(getGlobal().getUserIds()).to.not.haveOwnProperty('uid2'); +const expectNoLegacyToken = (bid) => expect(bid.userId).to.not.deep.include(makeUid2IdentityContainer(legacyToken)); +const expectModuleStorageEmptyOrMissing = () => expect(getFromAppropriateStorage()).to.be.null; +const expectModuleStorageToContain = (initialIdentity, latestIdentity) => { + const cookie = JSON.parse(getFromAppropriateStorage()); + if (initialIdentity) expect(cookie.originalToken.advertising_token).to.equal(initialIdentity); + if (latestIdentity) expect(cookie.latestToken.advertising_token).to.equal(latestIdentity); +} + +const apiUrl = 'https://prod.uidapi.com/v2/token/refresh'; +const headers = { 'Content-Type': 'application/json' }; +const makeSuccessResponseBody = () => btoa(JSON.stringify({ status: 'success', body: { ...apiHelpers.makeTokenResponse(initialToken), advertising_token: refreshedToken } })); + +const testCookieAndLocalStorage = (description, test, only = false) => { + const describeFn = only ? describe.only : describe; + describeFn(`Using cookies: ${description}`, async function() { + before(function() { + useLocalStorage = false; + }); + await test(); + }); + describeFn(`Using local storage: ${description}`, async function() { + before(function() { + useLocalStorage = true; + }); + after(function() { + useLocalStorage = false; + }); + await test(); + }); +}; + +describe(`UID2 module`, function () { + let server, suiteSandbox, testSandbox, timerSpy, fullTestTitle, restoreSubtleToUndefined = false; + before(function () { + timerSpy = configureTimerInterceptors(debugOutput); + hook.ready(); + uninstallGdprEnforcement(); + + suiteSandbox = sinon.sandbox.create(); + // I'm unable to find an authoritative source, but apparently subtle isn't available in some test stacks for security reasons. + // I've confirmed it's available in Firefox since v34 (it seems to be unavailable on BrowserStack in Firefox v106). + if (typeof window.crypto.subtle === 'undefined') { + restoreSubtleToUndefined = true; + window.crypto.subtle = { importKey: () => {}, decrypt: () => {} }; + } + suiteSandbox.stub(window.crypto.subtle, 'importKey').callsFake(() => Promise.resolve()); + suiteSandbox.stub(window.crypto.subtle, 'decrypt').callsFake((settings, key, data) => Promise.resolve(new Uint8Array([...settings.iv, ...data]))); + }); + + after(function () { + suiteSandbox.restore(); + timerSpy.restore(); + if (restoreSubtleToUndefined) window.crypto.subtle = undefined; + }); + + const configureUid2Response = (httpStatus, response) => server.respondWith('POST', apiUrl, (xhr) => xhr.respond(httpStatus, headers, response)); + const configureUid2ApiSuccessResponse = () => configureUid2Response(200, makeSuccessResponseBody()); + const configureUid2ApiFailResponse = () => configureUid2Response(500, 'Error'); + // Runs the provided test twice - once with a successful API mock, once with one which returns a server error + const testApiSuccessAndFailure = (act, testDescription, failTestDescription, only = false) => { + const testFn = only ? it.only : it; + testFn(`API responds successfully: ${testDescription}`, async function() { + configureUid2ApiSuccessResponse(); + await act(true); + }); + testFn(`API responds with an error: ${failTestDescription ?? testDescription}`, async function() { + configureUid2ApiFailResponse(); + await act(false); + }); + } + + const getFullTestTitle = (test) => `${test.parent.title ? getFullTestTitle(test.parent) + ' | ' : ''}${test.title}`; + + beforeEach(function () { + debugOutput(`----------------- START TEST ------------------`); + fullTestTitle = getFullTestTitle(this.test.ctx.currentTest); + debugOutput(fullTestTitle); + testSandbox = sinon.sandbox.create(); + testSandbox.stub(utils, 'logWarn'); + server = sinon.createFakeServer(); + + init(config); + setSubmoduleRegistry([uid2IdSubmodule]); + }); + + afterEach(async function() { + $$PREBID_GLOBAL$$.requestBids.removeAll(); + config.resetConfig(); + testSandbox.restore(); + if (timerSpy.timers.length > 0) { + if (clearTimersAfterEachTest) { + debugOutput(`Cancelling ${timerSpy.timers.length} still-active timers.`); + timerSpy.clearAllActiveTimers(); + } else { + debugOutput(`Waiting on ${timerSpy.timers.length} still-active timers...`, timerSpy.timers); + await timerSpy.waitAllActiveTimers(); + } + } + cookieHelpers.clearCookies(moduleCookieName, publisherCookieName); + coreStorage.removeDataFromLocalStorage(moduleCookieName); + debugOutput('----------------- END TEST ------------------'); + }); + + describe('Configuration', function() { + it('When no baseUrl is provided in config, the module calls the production endpoint', function() { + const uid2Token = apiHelpers.makeTokenResponse(initialToken, true, true); + config.setConfig(makePrebidConfig({uid2Token})); + expect(server.requests[0]?.url).to.have.string('https://prod.uidapi.com/'); + }); + + it('When a baseUrl is provided in config, the module calls the provided endpoint', function() { + const uid2Token = apiHelpers.makeTokenResponse(initialToken, true, true); + config.setConfig(makePrebidConfig({uid2Token, uid2ApiBase: 'https://operator-integ.uidapi.com'})); + expect(server.requests[0]?.url).to.have.string('https://operator-integ.uidapi.com/'); + }); + }); + + it('When a legacy value is provided directly in configuration, it is passed on', async function() { + const valueConfig = makePrebidConfig(); + valueConfig.userSync.userIds[0].value = {uid2: {id: legacyToken}} + config.setConfig(valueConfig); + const bid = await runAuction(); + + expectLegacyToken(bid); + }); + + // These tests cover 'legacy' cookies - i.e. cookies set with just the uid2 advertising token, which was how some previous integrations worked. + // Some users might still have this cookie, and the module should use that token if a newer one isn't provided. + // This should cover older integrations where the server is setting this legacy cookie and expecting the module to pass it on. + describe('When a legacy cookie exists', function () { + // Creates a test which sets the legacy cookie, configures the UID2 module with provided params, runs an + const createLegacyTest = function(params, bidAssertions, addConsent = false) { + return async function() { + coreStorage.setCookie(moduleCookieName, legacyToken, cookieHelpers.getFutureCookieExpiry()); + if (addConsent) setGdprApplies(); + config.setConfig(makePrebidConfig(params)); + + const bid = await runAuction(); + bidAssertions.forEach(function(assertion) { assertion(bid); }); + } + }; + + it('and a legacy config is used, it should provide the legacy cookie', + createLegacyTest(legacyConfigParams, [expectLegacyToken])); + it('and a server cookie config is used without a valid server cookie, it should provide the legacy cookie', + createLegacyTest(serverCookieConfigParams, [expectLegacyToken])); + it('and a server cookie is used with a valid server cookie configured using the new param name, it should provide the server cookie', + async function() { cookieHelpers.setPublisherCookie(publisherCookieName, apiHelpers.makeTokenResponse(initialToken)); await createLegacyTest(serverCookieConfigParams, [(bid) => expectToken(bid, initialToken), expectNoLegacyToken])(); }); + it('and a server cookie is used with a valid server cookie, it should provide the server cookie', + async function() { cookieHelpers.setPublisherCookie(publisherCookieName, apiHelpers.makeTokenResponse(initialToken)); await createLegacyTest(newServerCookieConfigParams, [(bid) => expectToken(bid, initialToken), expectNoLegacyToken])(); }); + it('and a token is provided in config, it should provide the config token', + createLegacyTest({uid2Token: apiHelpers.makeTokenResponse(initialToken)}, [(bid) => expectToken(bid, initialToken), expectNoLegacyToken])); + it('and GDPR applies, no identity should be provided to the auction', + createLegacyTest(legacyConfigParams, [expectNoIdentity], true)); + it('and GDPR applies, when getId is called directly it provides no identity', () => { + coreStorage.setCookie(moduleCookieName, legacyToken, cookieHelpers.getFutureCookieExpiry()); + const consentConfig = setGdprApplies(); + let configObj = makePrebidConfig(legacyConfigParams); + const result = uid2IdSubmodule.getId(configObj.userSync.userIds[0], consentConfig.consentData); + expect(result?.id).to.not.exist; + }); + + it('multiple runs do not change the value', async function() { + coreStorage.setCookie(moduleCookieName, legacyToken, cookieHelpers.getFutureCookieExpiry()); + config.setConfig(makePrebidConfig(legacyConfigParams)); + + const bid = await runAuction(); + + console.log('Storage', coreStorage.getDataFromLocalStorage(moduleCookieName)); + init(config); + setSubmoduleRegistry([uid2IdSubmodule]); + config.setConfig(makePrebidConfig(legacyConfigParams)); + const bid2 = await runAuction(); + + expect(bid.userId.uid2.id).to.equal(bid2.userId.uid2.id); + }); + }); + + // This setup runs all of the functional tests with both types of config - the full token response in params, or a server cookie with the cookie name provided + let scenarios = [ + { + name: 'Token provided in config call', + setConfig: (token, extraConfig = {}) => { + const gen = makePrebidConfig({uid2Token: token}, extraConfig); + console.log('GENERATED CONFIG', gen.userSync.userIds[0].params); + return config.setConfig(gen); + }, + }, + { + name: 'Token provided in server-set cookie', + setConfig: (token, extraConfig) => { + cookieHelpers.setPublisherCookie(publisherCookieName, token); + config.setConfig(makePrebidConfig(serverCookieConfigParams, extraConfig)); + }, + } + ] + + scenarios.forEach(function(scenario) { + testCookieAndLocalStorage(scenario.name, function() { + describe(`When an expired token which can be refreshed is provided`, function() { + describe('When the refresh is available in time', function() { + testApiSuccessAndFailure(async function(apiSucceeds) { + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true)); + apiHelpers.respondAfterDelay(auctionDelayMs / 10, server); + const bid = await runAuction(); + + if (apiSucceeds) expectToken(bid, refreshedToken); + else expectNoIdentity(bid); + }, 'it should be used in the auction', 'the auction should have no uid2'); + + testApiSuccessAndFailure(async function(apiSucceeds) { + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true)); + apiHelpers.respondAfterDelay(auctionDelayMs / 10, server); + + await runAuction(); + if (apiSucceeds) { + expectModuleStorageToContain(initialToken, refreshedToken); + } else { + expectModuleStorageEmptyOrMissing(); + } + }, 'the refreshed token should be stored in the module storage', 'the module storage should not be set'); + }); + describe(`when the response doesn't arrive before the auction timer`, function() { + testApiSuccessAndFailure(async function() { + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true)); + const bid = await runAuction(); + expectNoIdentity(bid); + }, 'it should run the auction'); + + testApiSuccessAndFailure(async function(apiSucceeds) { + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true, true)); + const promise = apiHelpers.respondAfterDelay(auctionDelayMs * 2, server); + + const bid = await runAuction(); + expectNoIdentity(bid); + expectGlobalToHaveNoUid2(); + await promise; + if (apiSucceeds) expectGlobalToHaveToken(refreshedToken); + else expectGlobalToHaveNoUid2(); + }, 'it should update the userId after the auction', 'there should be no global identity'); + }) + describe('and there is a refreshed token in the module cookie', function() { + it('the refreshed value from the cookie is used', async function() { + const initialIdentity = apiHelpers.makeTokenResponse(initialToken, true, true); + const refreshedIdentity = apiHelpers.makeTokenResponse(refreshedToken); + const moduleCookie = {originalToken: initialIdentity, latestToken: refreshedIdentity}; + coreStorage.setCookie(moduleCookieName, JSON.stringify(moduleCookie), cookieHelpers.getFutureCookieExpiry()); + scenario.setConfig(initialIdentity); + + const bid = await runAuction(); + expectToken(bid, refreshedToken); + }); + }) + }); + + describe(`When a current token is provided`, function() { + it('it should use the token in the auction', async function() { + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken)); + const bid = await runAuction(); + expectToken(bid, initialToken); + }); + + it('and GDPR applies, the token should not be used', async function() { + setGdprApplies(); + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken)); + const bid = await runAuction(); + expectNoIdentity(bid); + }) + }); + + describe(`When a current token which should be refreshed is provided, and the auction is set to run immediately`, function() { + beforeEach(function() { + scenario.setConfig(apiHelpers.makeTokenResponse(initialToken, true), {auctionDelay: 0, syncDelay: 1}); + }); + testApiSuccessAndFailure(async function() { + apiHelpers.respondAfterDelay(10, server); + const bid = await runAuction(); + expectToken(bid, initialToken); + }, 'it should not be refreshed before the auction runs'); + + testApiSuccessAndFailure(async function(success) { + const promise = apiHelpers.respondAfterDelay(1, server); + await runAuction(); + await promise; + if (success) { + expectModuleStorageToContain(initialToken, refreshedToken); + } else { + expectModuleStorageToContain(initialToken, initialToken); + } + }, 'the refreshed token should be stored in the module cookie after the auction runs', 'the module cookie should only have the original token'); + + it('it should use the current token in the auction', async function() { + const bid = await runAuction(); + expectToken(bid, initialToken); + }); + }); + }); + }); +}); diff --git a/test/spec/modules/underdogmediaBidAdapter_spec.js b/test/spec/modules/underdogmediaBidAdapter_spec.js index 70d09513f27..2d7c1f11178 100644 --- a/test/spec/modules/underdogmediaBidAdapter_spec.js +++ b/test/spec/modules/underdogmediaBidAdapter_spec.js @@ -1,29 +1,38 @@ -import { expect } from 'chai'; -import { spec, resetUserSync } from 'modules/underdogmediaBidAdapter.js'; +import { + expect +} from 'chai'; +import { + spec, + resetUserSync +} from 'modules/underdogmediaBidAdapter.js'; describe('UnderdogMedia adapter', function () { let bidRequests; let bidderRequest; beforeEach(function () { - bidRequests = [ - { - bidder: 'underdogmedia', - params: { - siteId: 12143 - }, - adUnitCode: '/19968336/header-bid-tag-1', - mediaTypes: { - banner: { - sizes: [[300, 250], [300, 600], [728, 90], [160, 600], [320, 50]], - } - }, - bidId: '23acc48ad47af5', - auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', - bidderRequestId: '1c56ad30b9b8ca8', - transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' - } - ]; + bidRequests = [{ + bidder: 'underdogmedia', + params: { + siteId: 12143 + }, + adUnitCode: '/19968336/header-bid-tag-1', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600], + [728, 90], + [160, 600], + [320, 50] + ], + } + }, + bidId: '23acc48ad47af5', + auctionId: '0fb4905b-9456-4152-86be-c6f6d259ba99', + bidderRequestId: '1c56ad30b9b8ca8', + transactionId: '92489f71-1bf2-49a0-adf9-000cea934729' + }]; bidderRequest = { timeout: 3000, @@ -49,7 +58,10 @@ describe('UnderdogMedia adapter', function () { }, mediaTypes: { banner: { - sizes: [[300, 250], [300, 600]] + sizes: [ + [300, 250], + [300, 600] + ] } } }; @@ -76,7 +88,10 @@ describe('UnderdogMedia adapter', function () { params: {}, mediaTypes: { banner: { - sizes: [[300, 250], [300, 600]] + sizes: [ + [300, 250], + [300, 600] + ] } } }; @@ -86,90 +101,94 @@ describe('UnderdogMedia adapter', function () { }); it('request data should contain sid', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - bidder: 'underdogmedia', - mediaTypes: { - banner: { - sizes: [[300, 250]] - } - }, - params: { - siteId: '12143' - }, - auctionId: '10b327aa396609', - adUnitCode: '/123456/header-bid-tag-1' - } - ]; + let bidRequests = [{ + bidId: '3c9408cdbf2f68', + bidder: 'underdogmedia', + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + params: { + siteId: '12143' + }, + auctionId: '10b327aa396609', + adUnitCode: '/123456/header-bid-tag-1' + }]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.sid).to.equal('12143'); + expect(request.data.sid).to.equal(12143); }); it('request data should contain sizes', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - mediaTypes: { - banner: { - sizes: [[300, 250], [728, 90]] - } - }, - bidder: 'underdogmedia', - params: { - siteId: '12143' - }, - auctionId: '10b327aa396609', - adUnitCode: '/123456/header-bid-tag-1' - } - ]; + let bidRequests = [{ + bidId: '3c9408cdbf2f68', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] + } + }, + bidder: 'underdogmedia', + params: { + siteId: '12143' + }, + auctionId: '10b327aa396609', + adUnitCode: '/123456/header-bid-tag-1' + }]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.sizes).to.equal('300x250,728x90'); + expect(request.data.placements[0].sizes[0]).to.equal('300x250'); + expect(request.data.placements[0].sizes[1]).to.equal('728x90'); }); it('request data should contain gdpr info', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - mediaTypes: { - banner: { - sizes: [[300, 250], [728, 90]] - } - }, - bidder: 'underdogmedia', - params: { - siteId: '12143' - }, - auctionId: '10b327aa396609', - adUnitCode: '/123456/header-bid-tag-1' - } - ]; + let bidRequests = [{ + bidId: '3c9408cdbf2f68', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] + } + }, + bidder: 'underdogmedia', + params: { + siteId: '12143' + }, + auctionId: '10b327aa396609', + adUnitCode: '/123456/header-bid-tag-1' + }]; const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.gdprApplies).to.equal(true); - expect(request.data.consentGiven).to.equal(true); - expect(request.data.consentData).to.equal('consentDataString'); + expect(request.data.gdpr.gdprApplies).to.equal(true); + expect(request.data.gdpr.consentGiven).to.equal(true); + expect(request.data.gdpr.consentData).to.equal('consentDataString'); }); it('should not build a request if no vendorConsent', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - mediaTypes: { - banner: { - sizes: [[300, 250], [728, 90]] - } - }, - bidder: 'underdogmedia', - params: { - siteId: '12143' - }, - auctionId: '10b327aa396609', - adUnitCode: '/123456/header-bid-tag-1' - } - ]; + let bidRequests = [{ + bidId: '3c9408cdbf2f68', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] + } + }, + bidder: 'underdogmedia', + params: { + siteId: '12143' + }, + auctionId: '10b327aa396609', + adUnitCode: '/123456/header-bid-tag-1' + }]; let bidderRequest = { timeout: 3000, @@ -189,22 +208,23 @@ describe('UnderdogMedia adapter', function () { }); it('should properly build a request if no vendorConsent but no gdprApplies', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - mediaTypes: { - banner: { - sizes: [[300, 250], [728, 90]] - } - }, - bidder: 'underdogmedia', - params: { - siteId: '12143' - }, - auctionId: '10b327aa396609', - adUnitCode: '/123456/header-bid-tag-1' - } - ]; + let bidRequests = [{ + bidId: '3c9408cdbf2f68', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] + } + }, + bidder: 'underdogmedia', + params: { + siteId: '12143' + }, + auctionId: '10b327aa396609', + adUnitCode: '/123456/header-bid-tag-1' + }]; let bidderRequest = { timeout: 3000, @@ -220,30 +240,32 @@ describe('UnderdogMedia adapter', function () { } const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.sizes).to.equal('300x250,728x90'); - expect(request.data.sid).to.equal('12143'); - expect(request.data.gdprApplies).to.equal(false); - expect(request.data.consentGiven).to.equal(false); - expect(request.data.consentData).to.equal('consentDataString'); + expect(request.data.placements[0].sizes[0]).to.equal('300x250'); + expect(request.data.placements[0].sizes[1]).to.equal('728x90'); + expect(request.data.sid).to.equal(12143); + expect(request.data.gdpr.gdprApplies).to.equal(false); + expect(request.data.gdpr.consentGiven).to.equal(false); + expect(request.data.gdpr.consentData).to.equal('consentDataString'); }); it('should properly build a request if gdprConsent empty', function () { - let bidRequests = [ - { - bidId: '3c9408cdbf2f68', - mediaTypes: { - banner: { - sizes: [[300, 250], [728, 90]] - } - }, - bidder: 'underdogmedia', - params: { - siteId: '12143' - }, - auctionId: '10b327aa396609', - adUnitCode: '/123456/header-bid-tag-1' - } - ]; + let bidRequests = [{ + bidId: '3c9408cdbf2f68', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [728, 90] + ] + } + }, + bidder: 'underdogmedia', + params: { + siteId: '12143' + }, + auctionId: '10b327aa396609', + adUnitCode: '/123456/header-bid-tag-1' + }]; let bidderRequest = { timeout: 3000, @@ -251,21 +273,663 @@ describe('UnderdogMedia adapter', function () { } const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.sizes).to.equal('300x250,728x90'); - expect(request.data.sid).to.equal('12143'); + expect(request.data.placements[0].sizes[0]).to.equal('300x250'); + expect(request.data.placements[0].sizes[1]).to.equal('728x90'); + expect(request.data.sid).to.equal(12143); }); it('should have uspConsent if defined', function () { const uspConsent = '1YYN' bidderRequest.uspConsent = uspConsent const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.uspConsent).to.equal(uspConsent); + expect(request.data.usp.uspConsent).to.equal(uspConsent); + }); + + it('should have correct number of placements', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }, + { + adUnitCode: 'div-gpt-ad-2460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '3a378b833cdef4', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-1' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }, + { + adUnitCode: 'div-gpt-ad-3460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '4088f04e07c2a1', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-2' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + } + ]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.usp.uspConsent).to.be.undefined; + expect(request.data.placements.length).to.equal(3); + }); + + it('should have correct adUnitCode for each placement', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }, + { + adUnitCode: 'div-gpt-ad-2460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '3a378b833cdef4', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-1' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }, + { + adUnitCode: 'div-gpt-ad-3460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '4088f04e07c2a1', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-2' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + } + ]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.usp.uspConsent).to.be.undefined; + expect(request.data.placements[0].adUnitCode).to.equal('div-gpt-ad-1460505748561-0'); + expect(request.data.placements[1].adUnitCode).to.equal('div-gpt-ad-2460505748561-0'); + expect(request.data.placements[2].adUnitCode).to.equal('div-gpt-ad-3460505748561-0'); + }); + + it('should have gpid if it exists', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.placements[0].gpid).to.equal('/19968336/header-bid-tag-0'); + }); + + it('gpid should be undefined if it does not exists', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.placements[0].gpid).to.equal(undefined); + }); + + it('should have productId equal to 1 if the productId is standard', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + params: { + siteId: '12143', + productId: 'standard' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.placements[0].productId).to.equal(1); + }); + + it('should have productId equal to 2 if the productId is adhesion', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + params: { + siteId: '12143', + productId: 'adhesion' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.placements[0].productId).to.equal(2); + }); + + it('productId should default to 1 if it is not defined', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.placements[0].productId).to.equal(1); + }); + + it('should have correct sizes for multiple placements', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }, + { + adUnitCode: 'div-gpt-ad-2460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '3a378b833cdef4', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-1' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }, + { + adUnitCode: 'div-gpt-ad-3460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '4088f04e07c2a1', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-2' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + } + ]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.placements[0].sizes.length).to.equal(2); + expect(request.data.placements[0].sizes[0]).to.equal('300x250'); + expect(request.data.placements[0].sizes[1]).to.equal('160x600'); + expect(request.data.placements[1].sizes.length).to.equal(1); + expect(request.data.placements[1].sizes[0]).to.equal('300x250'); + expect(request.data.placements[2].sizes.length).to.equal(1); + expect(request.data.placements[2].sizes[0]).to.equal('160x600'); + }); + + it('should have ref if it exists', function () { + let bidderRequest = { + timeout: 3000, + gdprConsent: { + gdprApplies: 1, + consentString: 'consentDataString', + vendorData: { + vendorConsents: { + '159': 1 + }, + }, + }, + refererInfo: { + page: 'www.example.com' + } + } + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.ref).to.equal('www.example.com'); + }); + + it('ref should be undefined if it does not exist', function () { + let bidderRequest = { + timeout: 3000, + gdprConsent: { + gdprApplies: 1, + consentString: 'consentDataString', + vendorData: { + vendorConsents: { + '159': 1 + }, + }, + } + } + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.ref).to.equal(undefined); + }); + + it('should have pubcid if it exists', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.userIds.pubcid).to.equal('ba6cbf43-abc0-4d61-b14f-e10f605b74d7'); + }); + + it('pubcid should be undefined if it does not exist', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.userIds.pubcid).to.equal(undefined); + }); + + it('should have unifiedId if tdid if it exists', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.userIds.unifiedId).to.equal('7a9fc5a2-346d-4502-826e-017a9badf5f3'); + }); + + it('unifiedId should be undefined if tdid does not exist', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + } + }]; + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.userIds.unifiedId).to.equal(undefined); }); - it('should not have uspConsent if not defined', function () { - bidderRequest.uspConsent = undefined + it('should have correct viewability information', function () { + let bidRequests = [{ + adUnitCode: 'div-gpt-ad-1460505748561-0', + auctionId: 'dfa93f1f-6ecc-4d75-8725-f5cb92307658', + bidId: '2dbc995ad299c', + bidder: 'underdogmedia', + crumbs: { + pubcid: 'ba6cbf43-abc0-4d61-b14f-e10f605b74d7' + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [160, 600] + ] + } + }, + ortb2Imp: { + ext: { + gpid: '/19968336/header-bid-tag-0' + } + }, + params: { + siteId: '12143' + }, + userId: { + tdid: '7a9fc5a2-346d-4502-826e-017a9badf5f3' + } + }]; + const request = spec.buildRequests(bidRequests, bidderRequest); - expect(request.data.uspConsent).to.be.undefined; + + expect(request.data.placements[0].viewability).to.equal(-1) }); }); @@ -273,26 +937,27 @@ describe('UnderdogMedia adapter', function () { it('should return complete bid response', function () { let serverResponse = { body: { - mids: [ - { - ad_code_html: 'ad_code_html', - advertiser_domains: ['domain1'], - cpm: 2.5, - height: '600', - mid: '32634', - notification_url: 'notification_url', - tid: '4', - width: '160' - }, - { - ad_code_html: 'ad_code_html', - cpm: 2.5, - height: '250', - mid: '32633', - notification_url: 'notification_url', - tid: '2', - width: '300' - }, + mids: [{ + ad_code_html: 'ad_code_html', + ad_unit_code: '/19968336/header-bid-tag-1', + advertiser_domains: ['domain1'], + cpm: 2.5, + height: '600', + mid: '32634', + notification_url: 'notification_url', + tid: '4', + width: '160', + }, + { + ad_code_html: 'ad_code_html', + ad_unit_code: '/19968336/header-bid-tag-1', + cpm: 3.0, + height: '250', + mid: '32633', + notification_url: 'notification_url', + tid: '2', + width: '300' + }, ] } }; @@ -302,7 +967,6 @@ describe('UnderdogMedia adapter', function () { expect(bids).to.be.lengthOf(2); expect(bids[0].meta.advertiserDomains).to.deep.equal(['domain1']) - expect(bids[0].bidderCode).to.equal('underdogmedia'); expect(bids[0].cpm).to.equal(2.5); expect(bids[0].width).to.equal('160'); expect(bids[0].height).to.equal('600'); @@ -326,17 +990,15 @@ describe('UnderdogMedia adapter', function () { it('should return empty bid response on incorrect size', function () { let serverResponse = { body: { - mids: [ - { - ad_code_html: 'ad_code_html', - cpm: 2.5, - height: '123', - mid: '32634', - notification_url: 'notification_url', - tid: '4', - width: '160' - } - ] + mids: [{ + ad_code_html: 'ad_code_html', + cpm: 2.5, + height: '123', + mid: '32634', + notification_url: 'notification_url', + tid: '4', + width: '160' + }] } }; const request = spec.buildRequests(bidRequests, bidderRequest); @@ -348,17 +1010,15 @@ describe('UnderdogMedia adapter', function () { it('should return empty bid response on 0 cpm', function () { let serverResponse = { body: { - mids: [ - { - ad_code_html: 'ad_code_html', - cpm: 0, - height: '600', - mid: '32634', - notification_url: 'notification_url', - tid: '4', - width: '160' - } - ] + mids: [{ + ad_code_html: 'ad_code_html', + cpm: 0, + height: '600', + mid: '32634', + notification_url: 'notification_url', + tid: '4', + width: '160' + }] } }; const request = spec.buildRequests(bidRequests, bidderRequest); @@ -370,17 +1030,15 @@ describe('UnderdogMedia adapter', function () { it('should return empty bid response if no ad in response', function () { let serverResponse = { body: { - mids: [ - { - ad_code_html: '', - cpm: 2.5, - height: '600', - mid: '32634', - notification_url: 'notification_url', - tid: '4', - width: '160' - } - ] + mids: [{ + ad_code_html: '', + cpm: 2.5, + height: '600', + mid: '32634', + notification_url: 'notification_url', + tid: '4', + width: '160' + }] } }; const request = spec.buildRequests(bidRequests, bidderRequest); @@ -392,17 +1050,16 @@ describe('UnderdogMedia adapter', function () { it('ad html string should contain the notification urls', function () { let serverResponse = { body: { - mids: [ - { - ad_code_html: 'ad_cod_html', - cpm: 2.5, - height: '600', - mid: '32634', - notification_url: 'notification_url', - tid: '4', - width: '160' - } - ] + mids: [{ + ad_code_html: 'ad_cod_html', + ad_unit_code: '/19968336/header-bid-tag-1', + cpm: 2.5, + height: '600', + mid: '32634', + notification_url: 'notification_url', + tid: '4', + width: '160' + }] } }; const request = spec.buildRequests(bidRequests, bidderRequest); @@ -430,15 +1087,14 @@ describe('UnderdogMedia adapter', function () { const responseWithUserSyncs = [{ body: { - userSyncs: [ - { - type: 'image', - url: 'https://test.url.com' - }, - { - type: 'iframe', - url: 'https://test.url.com' - } + userSyncs: [{ + type: 'image', + url: 'https://test.url.com' + }, + { + type: 'iframe', + url: 'https://test.url.com' + } ] } }]; diff --git a/test/spec/modules/undertoneBidAdapter_spec.js b/test/spec/modules/undertoneBidAdapter_spec.js index c24f63c0b99..5cf53c661a9 100644 --- a/test/spec/modules/undertoneBidAdapter_spec.js +++ b/test/spec/modules/undertoneBidAdapter_spec.js @@ -39,10 +39,19 @@ const videoBidReq = [{ maxDuration: 30 } }, - mediaTypes: {video: { - context: 'outstream', - playerSize: [640, 480] - }}, + ortb2Imp: { + ext: { + gpid: '/1111/gpid#728x90', + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480], + placement: 1, + plcmt: 1 + } + }, sizes: [[300, 250], [300, 600]], bidId: '263be71e91dd9d', auctionId: '9ad1fa8d-2297-4660-a018-b39945054746' @@ -54,10 +63,19 @@ const videoBidReq = [{ placementId: '10433395', publisherId: 12345 }, - mediaTypes: {video: { - context: 'outstream', - playerSize: [640, 480] - }}, + ortb2Imp: { + ext: { + data: { + pbadslot: '/1111/pbadslot#728x90' + } + } + }, + mediaTypes: { + video: { + context: 'outstream', + playerSize: [640, 480] + } + }, sizes: [[300, 250], [300, 600]], bidId: '263be71e91dd9d', auctionId: '9ad1fa8d-2297-4660-a018-b39945054746' @@ -152,13 +170,13 @@ const bidReqUserIds = [{ const bidderReq = { refererInfo: { - referer: 'http://prebid.org/dev-docs/bidder-adaptor.html' + topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html' } }; const bidderReqGdpr = { refererInfo: { - referer: 'http://prebid.org/dev-docs/bidder-adaptor.html' + topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html' }, gdprConsent: { gdprApplies: true, @@ -168,14 +186,14 @@ const bidderReqGdpr = { const bidderReqCcpa = { refererInfo: { - referer: 'http://prebid.org/dev-docs/bidder-adaptor.html' + topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html' }, uspConsent: 'NY12' }; const bidderReqCcpaAndGdpr = { refererInfo: { - referer: 'http://prebid.org/dev-docs/bidder-adaptor.html' + topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html' }, gdprConsent: { gdprApplies: true, @@ -184,6 +202,31 @@ const bidderReqCcpaAndGdpr = { uspConsent: 'NY12' }; +const bidderReqGpp = { + refererInfo: { + topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html' + }, + gppConsent: { + gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', + applicableSections: [7] + } +}; + +const bidderReqFullGppCcpaGdpr = { + refererInfo: { + topmostLocation: 'http://prebid.org/dev-docs/bidder-adaptor.html' + }, + gppConsent: { + gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', + applicableSections: [7] + }, + gdprConsent: { + gdprApplies: true, + consentString: 'gdprConsent' + }, + uspConsent: '1YNN' +}; + const validBidRes = { ad: '
Hello
', publisherId: 12345, @@ -343,18 +386,18 @@ describe('Undertone Adapter', () => { }); it('should send request to correct url via POST not in GDPR or CCPA', function () { const request = spec.buildRequests(bidReq, bidderReq); - const domainStart = bidderReq.refererInfo.referer.indexOf('//'); - const domainEnd = bidderReq.refererInfo.referer.indexOf('/', domainStart + 2); - const domain = bidderReq.refererInfo.referer.substring(domainStart + 2, domainEnd); + const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//'); + const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2); + const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd); const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}`; expect(request.url).to.equal(REQ_URL); expect(request.method).to.equal('POST'); }); it('should send request to correct url via POST when in GDPR', function () { const request = spec.buildRequests(bidReq, bidderReqGdpr); - const domainStart = bidderReq.refererInfo.referer.indexOf('//'); - const domainEnd = bidderReq.refererInfo.referer.indexOf('/', domainStart + 2); - const domain = bidderReq.refererInfo.referer.substring(domainStart + 2, domainEnd); + const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//'); + const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2); + const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd); let gdpr = bidderReqGdpr.gdprConsent.gdprApplies ? 1 : 0; const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gdpr=${gdpr}&gdprstr=${bidderReqGdpr.gdprConsent.consentString}`; expect(request.url).to.equal(REQ_URL); @@ -362,9 +405,9 @@ describe('Undertone Adapter', () => { }); it('should send request to correct url via POST when in CCPA', function () { const request = spec.buildRequests(bidReq, bidderReqCcpa); - const domainStart = bidderReq.refererInfo.referer.indexOf('//'); - const domainEnd = bidderReq.refererInfo.referer.indexOf('/', domainStart + 2); - const domain = bidderReq.refererInfo.referer.substring(domainStart + 2, domainEnd); + const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//'); + const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2); + const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd); let ccpa = bidderReqCcpa.uspConsent; const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&ccpa=${ccpa}`; expect(request.url).to.equal(REQ_URL); @@ -372,15 +415,40 @@ describe('Undertone Adapter', () => { }); it('should send request to correct url via POST when in GDPR and CCPA', function () { const request = spec.buildRequests(bidReq, bidderReqCcpaAndGdpr); - const domainStart = bidderReq.refererInfo.referer.indexOf('//'); - const domainEnd = bidderReq.refererInfo.referer.indexOf('/', domainStart + 2); - const domain = bidderReq.refererInfo.referer.substring(domainStart + 2, domainEnd); + const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//'); + const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2); + const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd); let ccpa = bidderReqCcpaAndGdpr.uspConsent; let gdpr = bidderReqCcpaAndGdpr.gdprConsent.gdprApplies ? 1 : 0; const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gdpr=${gdpr}&gdprstr=${bidderReqGdpr.gdprConsent.consentString}&ccpa=${ccpa}`; expect(request.url).to.equal(REQ_URL); expect(request.method).to.equal('POST'); }); + it(`should have gppConsent fields`, function () { + const request = spec.buildRequests(bidReq, bidderReqGpp); + const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//'); + const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2); + const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd); + const gppStr = bidderReqGpp.gppConsent.gppString; + const gppSid = bidderReqGpp.gppConsent.applicableSections; + const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gpp=${gppStr}&gpp_sid=${gppSid}`; + expect(request.url).to.equal(REQ_URL); + expect(request.method).to.equal('POST'); + }); + it(`should have gpp, ccpa and gdpr fields`, function () { + const request = spec.buildRequests(bidReq, bidderReqFullGppCcpaGdpr); + const domainStart = bidderReq.refererInfo.topmostLocation.indexOf('//'); + const domainEnd = bidderReq.refererInfo.topmostLocation.indexOf('/', domainStart + 2); + const domain = bidderReq.refererInfo.topmostLocation.substring(domainStart + 2, domainEnd); + const gppStr = bidderReqFullGppCcpaGdpr.gppConsent.gppString; + const gppSid = bidderReqFullGppCcpaGdpr.gppConsent.applicableSections; + const ccpa = bidderReqFullGppCcpaGdpr.uspConsent; + const gdpr = bidderReqFullGppCcpaGdpr.gdprConsent.gdprApplies ? 1 : 0; + const gdprStr = bidderReqFullGppCcpaGdpr.gdprConsent.consentString; + const REQ_URL = `${URL}?pid=${bidReq[0].params.publisherId}&domain=${domain}&gdpr=${gdpr}&gdprstr=${gdprStr}&ccpa=${ccpa}&gpp=${gppStr}&gpp_sid=${gppSid}`; + expect(request.url).to.equal(REQ_URL); + expect(request.method).to.equal('POST'); + }); it('should have all relevant fields', function () { const request = spec.buildRequests(bidReq, bidderReq); const bid1 = JSON.parse(request.data)['x-ut-hb-params'][0]; @@ -409,10 +477,16 @@ describe('Undertone Adapter', () => { expect(bidVideo.video.playbackMethod).to.equal(2); expect(bidVideo.video.maxDuration).to.equal(30); expect(bidVideo.video.skippable).to.equal(true); + expect(bidVideo.video.placement).to.equal(1); + expect(bidVideo.video.plcmt).to.equal(1); + expect(bidVideo.gpid).to.equal('/1111/gpid#728x90'); expect(bidVideo2.video.skippable).to.equal(null); expect(bidVideo2.video.maxDuration).to.equal(null); expect(bidVideo2.video.playbackMethod).to.equal(null); + expect(bidVideo2.video.placement).to.equal(null); + expect(bidVideo2.video.plcmt).to.equal(null); + expect(bidVideo2.gpid).to.equal('/1111/pbadslot#728x90'); }); it('should send all userIds data to server', function () { const request = spec.buildRequests(bidReqUserIds, bidderReq); diff --git a/test/spec/modules/unicornBidAdapter_spec.js b/test/spec/modules/unicornBidAdapter_spec.js index 1ab428d58b6..0abb09bfb78 100644 --- a/test/spec/modules/unicornBidAdapter_spec.js +++ b/test/spec/modules/unicornBidAdapter_spec.js @@ -270,7 +270,7 @@ const bidderRequest = { auctionStart: 1581064124172, timeout: 1000, refererInfo: { - referer: 'https://uni-corn.net/', + ref: 'https://uni-corn.net/', reachedTop: true, numIframes: 0, stack: ['https://uni-corn.net/'] @@ -496,6 +496,16 @@ describe('unicornBidAdapterTest', () => { }); describe('buildBidRequest', () => { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + unicorn: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); it('buildBidRequest', () => { const req = spec.buildRequests(validBidRequests, bidderRequest); const removeUntestableAttrs = data => { diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 0829aa9927a..17a865796a2 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -1,36 +1,37 @@ import { attachIdSystem, auctionDelay, - coreStorage, + coreStorage, dep, + findRootDomain, getConsentHash, init, + PBJS_USER_ID_OPTOUT_NAME, requestBidsHook, + requestDataDeletion, setStoredConsentData, setStoredValue, setSubmoduleRegistry, syncDelay, - PBJS_USER_ID_OPTOUT_NAME, - findRootDomain, } from 'modules/userId/index.js'; -import {createEidsArray} from 'modules/userId/eids.js'; +import {createEidsArray, EID_CONFIG} from 'modules/userId/eids.js'; import {config} from 'src/config.js'; import * as utils from 'src/utils.js'; +import {getPrebidInternal} from 'src/utils.js'; import * as events from 'src/events.js'; import CONSTANTS from 'src/constants.json'; import {getGlobal} from 'src/prebidGlobal.js'; -import { - resetConsentData, -} from 'modules/consentManagement.js'; +import {resetConsentData, } from 'modules/consentManagement.js'; import {server} from 'test/mocks/xhr.js'; -import {find} from 'src/polyfill.js'; import {unifiedIdSubmodule} from 'modules/unifiedIdSystem.js'; import {britepoolIdSubmodule} from 'modules/britepoolIdSystem.js'; import {id5IdSubmodule} from 'modules/id5IdSystem.js'; import {identityLinkSubmodule} from 'modules/identityLinkIdSystem.js'; import {dmdIdSubmodule} from 'modules/dmdIdSystem.js'; -import {liveIntentIdSubmodule} from 'modules/liveIntentIdSystem.js'; +import { + liveIntentIdSubmodule, + setEventFiredFlag as liveIntentIdSubmoduleDoNotFireEvent +} from 'modules/liveIntentIdSystem.js'; import {merkleIdSubmodule} from 'modules/merkleIdSystem.js'; import {netIdSubmodule} from 'modules/netIdSystem.js'; -import {nextrollIdSubmodule} from 'modules/nextrollIdSystem.js'; import {intentIqIdSubmodule} from 'modules/intentIqIdSystem.js'; import {zeotapIdPlusSubmodule} from 'modules/zeotapIdPlusIdSystem.js'; import {sharedIdSystemSubmodule} from 'modules/sharedIdSystem.js'; @@ -39,19 +40,25 @@ import {pubProvidedIdSubmodule} from 'modules/pubProvidedIdSystem.js'; import {criteoIdSubmodule} from 'modules/criteoIdSystem.js'; import {mwOpenLinkIdSubModule} from 'modules/mwOpenLinkIdSystem.js'; import {tapadIdSubmodule} from 'modules/tapadIdSystem.js'; -import {getPrebidInternal} from 'src/utils.js'; +import {tncidSubModule} from 'modules/tncIdSystem.js'; import {uid2IdSubmodule} from 'modules/uid2IdSystem.js'; +import {euidIdSubmodule} from 'modules/euidIdSystem.js'; import {admixerIdSubmodule} from 'modules/admixerIdSystem.js'; import {deepintentDpesSubmodule} from 'modules/deepintentDpesIdSystem.js'; -import {flocIdSubmodule} from 'modules/flocIdSystem.js' import {amxIdSubmodule} from '../../../modules/amxIdSystem.js'; -import {akamaiDAPIdSubmodule} from 'modules/akamaiDAPIdSystem.js' -import {kinessoIdSubmodule} from 'modules/kinessoIdSystem.js' +import {kinessoIdSubmodule} from 'modules/kinessoIdSystem.js'; import {adqueryIdSubmodule} from 'modules/adqueryIdSystem.js'; +import {imuIdSubmodule} from 'modules/imuIdSystem.js'; import * as mockGpt from '../integration/faker/googletag.js'; import 'src/prebid.js'; import {hook} from '../../../src/hook.js'; import {mockGdprConsent} from '../../helpers/consentData.js'; +import {getPPID} from '../../../src/adserver.js'; +import {uninstall as uninstallGdprEnforcement} from 'modules/gdprEnforcement.js'; +import {allConsent, GDPR_GVLIDS, gdprDataHandler} from '../../../src/consentHandler.js'; +import {MODULE_TYPE_UID} from '../../../src/activities/modules.js'; +import {ACTIVITY_ENRICH_EIDS} from '../../../src/activities/activities.js'; +import {ACTIVITY_PARAM_COMPONENT_NAME, ACTIVITY_PARAM_COMPONENT_TYPE} from '../../../src/activities/params.js'; let assert = require('chai').assert; let expect = require('chai').expect; @@ -78,6 +85,20 @@ describe('User ID', function () { } } + function createMockIdSubmodule(name, value, aliasName, eids) { + return { + name, + getId() { + return value; + }, + decode(v) { + return v; + }, + aliasName, + eids + } + } + function getAdUnitMock(code = 'adUnit-code') { return { code, @@ -101,12 +122,6 @@ describe('User ID', function () { return cfg; } - function findEid(eids, source) { - return find(eids, (eid) => { - if (eid.source === source) { return true; } - }); - } - let sandbox, consentData, startDelay, callbackDelay; function clearStack() { @@ -144,7 +159,9 @@ describe('User ID', function () { before(function () { hook.ready(); + uninstallGdprEnforcement(); localStorage.removeItem(PBJS_USER_ID_OPTOUT_NAME); + liveIntentIdSubmoduleDoNotFireEvent(); }); beforeEach(function () { @@ -163,14 +180,27 @@ describe('User ID', function () { sandbox.restore(); }); + describe('GVL IDs', () => { + beforeEach(() => { + sinon.stub(GDPR_GVLIDS, 'register'); + }); + afterEach(() => { + GDPR_GVLIDS.register.restore(); + }); + + it('are registered when ID submodule is registered', () => { + attachIdSystem({name: 'gvlidMock', gvlid: 123}); + sinon.assert.calledWith(GDPR_GVLIDS.register, MODULE_TYPE_UID, 'gvlidMock', 123); + }) + }) + describe('Decorate Ad Units', function () { beforeEach(function () { // reset mockGpt so nothing else interferes mockGpt.disable(); mockGpt.enable(); coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('pubcid_alt', 'altpubcid200000', (new Date(Date.now() + 5000).toUTCString())); - let origSK = coreStorage.setCookie.bind(coreStorage); + coreStorage.setCookie('pubcid_alt', 'altpubcid200000', (new Date(Date.now() + 20000).toUTCString())); sinon.spy(coreStorage, 'setCookie'); sinon.stub(utils, 'logWarn'); }); @@ -301,10 +331,6 @@ describe('User ID', function () { }); }); }); - // Because the consent cookie doesn't exist yet, we'll have 2 setCookie calls: - // 1) for the consent cookie - // 2) from the getId() call that results in a new call to store the results - expect(coreStorage.setCookie.callCount).to.equal(2); }); }); @@ -331,7 +357,6 @@ describe('User ID', function () { }); }); }); - expect(coreStorage.setCookie.callCount).to.equal(2); }); }); @@ -354,11 +379,78 @@ describe('User ID', function () { expect(bid).to.not.have.deep.nested.property('userIdAsEids'); }); }); - // setCookie is called once in order to store consentData - expect(coreStorage.setCookie.callCount).to.equal(1); }); }); + describe('createEidsArray', () => { + beforeEach(() => { + init(config); + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1', null, null, + {'mockId1': {source: 'mock1source', atype: 1}}), + createMockIdSubmodule('mockId2v1', null, null, + {'mockId2v1': {source: 'mock2source', atype: 2, getEidExt: () => ({v: 1})}}), + createMockIdSubmodule('mockId2v2', null, null, + {'mockId2v2': {source: 'mock2source', atype: 2, getEidExt: () => ({v: 2})}}), + ]); + }); + + it('should group UIDs by source and ext', () => { + const eids = createEidsArray({ + mockId1: ['mock-1-1', 'mock-1-2'], + mockId2v1: ['mock-2-1', 'mock-2-2'], + mockId2v2: ['mock-2-1', 'mock-2-2'] + }); + expect(eids).to.eql([ + { + source: 'mock1source', + uids: [ + { + id: 'mock-1-1', + atype: 1, + }, + { + id: 'mock-1-2', + atype: 1, + } + ] + }, + { + source: 'mock2source', + ext: { + v: 1 + }, + uids: [ + { + id: 'mock-2-1', + atype: 2, + }, + { + id: 'mock-2-2', + atype: 2, + } + ] + }, + { + source: 'mock2source', + ext: { + v: 2 + }, + uids: [ + { + id: 'mock-2-1', + atype: 2, + }, + { + id: 'mock-2-2', + atype: 2, + } + ] + } + ]) + }) + }) + it('pbjs.getUserIds', function (done) { init(config); setSubmoduleRegistry([sharedIdSystemSubmodule]); @@ -379,6 +471,139 @@ describe('User ID', function () { }) }); + it('pbjs.getUserIds(Async) should prioritize user ids according to config available to core', () => { + init(config); + + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {mockId1: 'mockId1_value'}}), + createMockIdSubmodule('mockId2Module', {id: {mockId2: 'mockId2_value', mockId3: 'mockId3_value_from_mockId2Module'}}), + createMockIdSubmodule('mockId3Module', {id: {mockId1: 'mockId1_value_from_mockId3Module', mockId2: 'mockId2_value_from_mockId3Module', mockId3: 'mockId3_value', mockId4: 'mockId4_value_from_mockId3Module'}}), + createMockIdSubmodule('mockId4Module', {id: {mockId4: 'mockId4_value'}}) + ]); + + config.setConfig({ + userSync: { + idPriority: { + mockId1: ['mockId3Module', 'mockId1Module'], + mockId4: ['mockId4Module', 'mockId3Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return getGlobal().getUserIdsAsync().then((uids) => { + expect(uids['mockId1']).to.deep.equal('mockId1_value_from_mockId3Module'); + expect(uids['mockId2']).to.deep.equal('mockId2_value'); + expect(uids['mockId3']).to.deep.equal('mockId3_value_from_mockId2Module'); + expect(uids['mockId4']).to.deep.equal('mockId4_value'); + }); + }); + + it('pbjs.getUserIds(Async) should prioritize user ids according to config available to core when config uses aliases', () => { + init(config); + + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {mockId1: 'mockId1_value'}}), + createMockIdSubmodule('mockId2Module', {id: {mockId2: 'mockId2_value', mockId3: 'mockId3_value_from_mockId2Module'}}, 'mockId2Module_alias'), + createMockIdSubmodule('mockId3Module', {id: {mockId1: 'mockId1_value_from_mockId3Module', mockId2: 'mockId2_value_from_mockId3Module', mockId3: 'mockId3_value', mockId4: 'mockId4_value_from_mockId3Module'}}, 'mockId3Module_alias'), + createMockIdSubmodule('mockId4Module', {id: {mockId4: 'mockId4_value'}}) + ]); + + config.setConfig({ + userSync: { + idPriority: { + mockId1: ['mockId3Module_alias', 'mockId1Module'], + mockId4: ['mockId4Module', 'mockId3Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return getGlobal().getUserIdsAsync().then((uids) => { + expect(uids['mockId1']).to.deep.equal('mockId1_value_from_mockId3Module'); + expect(uids['mockId2']).to.deep.equal('mockId2_value'); + expect(uids['mockId3']).to.deep.equal('mockId3_value_from_mockId2Module'); + expect(uids['mockId4']).to.deep.equal('mockId4_value'); + }); + }); + + it('pbjs.getUserIds(Async) should prioritize user ids according to config available to core when called multiple times', () => { + init(config); + + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {mockId1: 'mockId1_value', mockId2: 'mockId2_value_from_mockId1Module'}}), + createMockIdSubmodule('mockId2Module', {id: {mockId1: 'mockId1_value_from_mockId2Module', mockId2: 'mockId2_value'}}), + ]); + + config.setConfig({ + userSync: { + idPriority: { + mockId1: ['mockId2Module', 'mockId1Module'], + mockId2: ['mockId1Module', 'mockId2Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' } + ] + } + }); + + return getGlobal().getUserIdsAsync().then((uidsFirstRequest) => { + getGlobal().getUserIdsAsync().then((uidsSecondRequest) => { + expect(uidsFirstRequest['mockId1']).to.deep.equal('mockId1_value_from_mockId2Module'); + expect(uidsFirstRequest['mockId2']).to.deep.equal('mockId2_value_from_mockId1Module'); + expect(uidsFirstRequest).to.deep.equal(uidsSecondRequest); + }) + }); + }); + + it('pbjs.getUserIds(Async) with priority config but no collision', () => { + init(config); + + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {mockId1: 'mockId1_value'}}), + createMockIdSubmodule('mockId2Module', {id: {mockId2: 'mockId2_value'}}), + createMockIdSubmodule('mockId3Module', {id: undefined}), + createMockIdSubmodule('mockId4Module', {id: {mockId4: 'mockId4_value'}}) + ]); + + config.setConfig({ + userSync: { + idPriority: { + mockId1: ['mockId3Module', 'mockId1Module'], + mockId4: ['mockId2Module', 'mockId4Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return getGlobal().getUserIdsAsync().then((uids) => { + expect(uids['mockId1']).to.deep.equal('mockId1_value'); + expect(uids['mockId2']).to.deep.equal('mockId2_value'); + expect(uids['mockId3']).to.be.undefined; + expect(uids['mockId4']).to.deep.equal('mockId4_value'); + }); + }); + it('pbjs.getUserIdsAsEids', function (done) { init(config); setSubmoduleRegistry([sharedIdSystemSubmodule]); @@ -398,10 +623,95 @@ describe('User ID', function () { }); }); + it('pbjs.getUserIdsAsEids should prioritize user ids according to config available to core', () => { + init(config); + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {uid2: {id: 'uid2_value'}}}), + createMockIdSubmodule('mockId2Module', {id: {pubcid: 'pubcid_value', lipb: {lipbid: 'lipbid_value_from_mockId2Module'}}}), + createMockIdSubmodule('mockId3Module', {id: {uid2: {id: 'uid2_value_from_mockId3Module'}, pubcid: 'pubcid_value_from_mockId3Module', lipb: {lipbid: 'lipbid_value'}, merkleId: {id: 'merkleId_value_from_mockId3Module'}}}), + createMockIdSubmodule('mockId4Module', {id: {merkleId: {id: 'merkleId_value'}}}) + ]); + config.setConfig({ + userSync: { + idPriority: { + uid2: ['mockId3Module', 'mockId1Module'], + merkleId: ['mockId4Module', 'mockId3Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + const ids = { + 'uid2': { id: 'uid2_value_from_mockId3Module' }, + 'pubcid': 'pubcid_value', + 'lipb': { lipbid: 'lipbid_value_from_mockId2Module' }, + 'merkleId': { id: 'merkleId_value' } + }; + + return getGlobal().getUserIdsAsync().then(() => { + const eids = getGlobal().getUserIdsAsEids(); + const expected = createEidsArray(ids); + expect(eids).to.deep.equal(expected); + }); + }); + + describe('EID updateConfig', () => { + function mockSubmod(name, eids) { + return createMockIdSubmodule(name, null, null, eids); + } + + it('does not choke if a submod does not provide an eids map', () => { + setSubmoduleRegistry([ + mockSubmod('mock1'), + mockSubmod('mock2') + ]); + expect(EID_CONFIG.size).to.equal(0); + }); + + it('should merge together submodules\' eid configs', () => { + setSubmoduleRegistry([ + mockSubmod('mock1', {mock1: {m: 1}}), + mockSubmod('mock2', {mock2: {m: 2}}) + ]); + expect(EID_CONFIG.get('mock1')).to.eql({m: 1}); + expect(EID_CONFIG.get('mock2')).to.eql({m: 2}); + }); + + it('should respect idPriority', () => { + config.setConfig({ + userSync: { + idPriority: { + m1: ['mod2', 'mod1'], + m2: ['mod1', 'mod2'] + }, + userIds: [ + { name: 'mod1' }, + { name: 'mod2' }, + ] + } + }); + setSubmoduleRegistry([ + mockSubmod('mod1', {m1: {i: 1}, m2: {i: 2}}), + mockSubmod('mod2', {m1: {i: 3}, m2: {i: 4}}) + ]); + expect(EID_CONFIG.get('m1')).to.eql({i: 3}); + expect(EID_CONFIG.get('m2')).to.eql({i: 2}); + }); + }) + it('should set googletag ppid correctly', function () { let adUnits = [getAdUnitMock()]; init(config); - setSubmoduleRegistry([amxIdSubmodule, sharedIdSystemSubmodule, identityLinkSubmodule]); + setSubmoduleRegistry([amxIdSubmodule, sharedIdSystemSubmodule, identityLinkSubmodule, imuIdSubmodule]); + + // before ppid should not be set + expect(window.googletag._ppid).to.equal(undefined); config.setConfig({ userSync: { @@ -410,14 +720,178 @@ describe('User ID', function () { { name: 'amxId', value: {'amxId': 'amx-id-value-amx-id-value-amx-id-value'} }, { name: 'pubCommonId', value: {'pubcid': 'pubCommon-id-value-pubCommon-id-value'} }, { name: 'identityLink', value: {'idl_env': 'identityLink-id-value-identityLink-id-value'} }, + { name: 'imuid', value: {'imppid': 'imppid-value-imppid-value-imppid-value'} }, ] } }); + return expectImmediateBidHook(() => {}, {adUnits}).then(() => { + // ppid should have been set without dashes and stuff + expect(window.googletag._ppid).to.equal('pubCommonidvaluepubCommonidvalue'); + }); + }); + + it('should set googletag ppid correctly when prioritized according to config available to core', () => { + let adUnits = [getAdUnitMock()]; + init(config); + setSubmoduleRegistry([ + // some of the ids are padded to have length >= 32 characters + createMockIdSubmodule('mockId1Module', {id: {uid2: {id: 'uid2_value_7ac66c0f148de9519b8bd264312c4d64'}}}), + createMockIdSubmodule('mockId2Module', {id: {pubcid: 'pubcid_value_7ac66c0f148de9519b8bd264312c4d64', lipb: {lipbid: 'lipbid_value_from_mockId2Module_7ac66c0f148de9519b8bd264312c4d64'}}}), + createMockIdSubmodule('mockId3Module', { + id: { + uid2: { + id: 'uid2_value_from_mockId3Module_7ac66c0f148de9519b8bd264312c4d64' + }, + pubcid: 'pubcid_value_from_mockId3Module_7ac66c0f148de9519b8bd264312c4d64', + lipb: { + lipbid: 'lipbid_value_7ac66c0f148de9519b8bd264312c4d64' + }, + merkleId: { + id: 'merkleId_value_from_mockId3Module_7ac66c0f148de9519b8bd264312c4d64' + } + } + }, null, { + uid2: { + source: 'uidapi.com', + getValue(data) { return data.id } + } + }), + createMockIdSubmodule('mockId4Module', {id: {merkleId: {id: 'merkleId_value_7ac66c0f148de9519b8bd264312c4d64'}}}) + ]); + // before ppid should not be set expect(window.googletag._ppid).to.equal(undefined); + + config.setConfig({ + userSync: { + ppid: 'uidapi.com', + idPriority: { + uid2: ['mockId3Module', 'mockId1Module'], + merkleId: ['mockId4Module', 'mockId3Module'] + }, + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return expectImmediateBidHook(() => {}, {adUnits}).then(() => { + expect(window.googletag._ppid).to.equal('uid2valuefrommockId3Module7ac66c0f148de9519b8bd264312c4d64'); + }); + }); + + describe('submodule callback', () => { + const TEST_KEY = 'testKey'; + + function setVal(val) { + if (val) { + coreStorage.setDataInLocalStorage(TEST_KEY, val); + coreStorage.setDataInLocalStorage(TEST_KEY + '_exp', ''); + } else { + coreStorage.removeDataFromLocalStorage(TEST_KEY); + coreStorage.removeDataFromLocalStorage(TEST_KEY + '_exp'); + } + } + afterEach(() => { + setVal(null); + }) + + it('should be able to re-read ID changes', (done) => { + setVal(null); + init(config); + setSubmoduleRegistry([{ + name: 'mockId', + getId: function (_1, _2, storedId) { + expect(storedId).to.not.exist; + setVal('laterValue'); + return { + callback(_, readId) { + expect(readId()).to.eql('laterValue'); + done(); + } + } + }, + decode(d) { + return d + } + }]); + config.setConfig({ + userSync: { + auctionDelay: 10, + userIds: [ + { + name: 'mockId', + storage: { + type: 'html5', + name: TEST_KEY + } + } + ] + } + }); + }); + }); + + it('should set PPID when the source needs to call out to the network', () => { + let adUnits = [getAdUnitMock()]; + init(config); + const callback = sinon.stub(); + setSubmoduleRegistry([{ + name: 'sharedId', + getId: function () { + return {callback} + }, + decode(d) { + return d + }, + eids: { + pubcid: { + source: 'pubcid.org', + } + } + }]); + config.setConfig({ + userSync: { + ppid: 'pubcid.org', + auctionDelay: 10, + userIds: [ + { + name: 'sharedId', + } + ] + } + }); + return expectImmediateBidHook(() => {}, {adUnits}).then(() => { + expect(window.googletag._ppid).to.be.undefined; + const uid = 'thismustbelongerthan32characters' + callback.yield({pubcid: uid}); + expect(window.googletag._ppid).to.equal(uid); + }); + }); + + it('should set googletag ppid correctly for imuIdSubmodule', function () { + let adUnits = [getAdUnitMock()]; + init(config); + setSubmoduleRegistry([imuIdSubmodule]); + + // before ppid should not be set + expect(window.googletag._ppid).to.equal(undefined); + + config.setConfig({ + userSync: { + ppid: 'ppid.intimatemerger.com', + userIds: [ + { name: 'imuid', value: {'imppid': 'imppid-value-imppid-value-imppid-value'} }, + ] + } + }); + return expectImmediateBidHook(() => {}, {adUnits}).then(() => { // ppid should have been set without dashes and stuff - expect(window.googletag._ppid).to.equal('pubCommonidvaluepubCommonidvalue'); + expect(window.googletag._ppid).to.equal('imppidvalueimppidvalueimppidvalue'); }); }); @@ -445,12 +919,83 @@ describe('User ID', function () { }); }); + it('should make PPID available to core', () => { + init(config); + setSubmoduleRegistry([sharedIdSystemSubmodule]); + const id = 'thishastobelongerthan32characters'; + config.setConfig({ + userSync: { + ppid: 'pubcid.org', + userIds: [ + { name: 'pubCommonId', value: {'pubcid': id} }, + ] + } + }); + return getGlobal().refreshUserIds().then(() => { + expect(getPPID()).to.eql(id); + }) + }); + + it('should make PPID available to core and respect priority', () => { + init(config); + setSubmoduleRegistry([ + // some of the ids are padded to have length >= 32 characters + createMockIdSubmodule('mockId1Module', {id: {uid2: {id: 'uid2_value_7ac66c0f148de9519b8bd264312c4d64'}}}), + createMockIdSubmodule('mockId2Module', {id: {pubcid: 'pubcid_value_7ac66c0f148de9519b8bd264312c4d64', lipb: {lipbid: 'lipbid_value_from_mockId2Module_7ac66c0f148de9519b8bd264312c4d64'}}}), + createMockIdSubmodule('mockId3Module', { + id: { + uid2: { + id: 'uid2_value_from_mockId3Module_7ac66c0f148de9519b8bd264312c4d64' + }, + pubcid: 'pubcid_value_from_mockId3Module_7ac66c0f148de9519b8bd264312c4d64', + lipb: { + lipbid: 'lipbid_value_7ac66c0f148de9519b8bd264312c4d64' + }, + merkleId: { + id: 'merkleId_value_from_mockId3Module_7ac66c0f148de9519b8bd264312c4d64' + } + } + }, null, { + uid2: { + source: 'uidapi.com', + getValue(data) { return data.id } + } + }), + createMockIdSubmodule('mockId4Module', {id: {merkleId: {id: 'merkleId_value_7ac66c0f148de9519b8bd264312c4d64'}}}) + ]); + + // before ppid should not be set + expect(window.googletag._ppid).to.equal(undefined); + + config.setConfig({ + userSync: { + ppid: 'uidapi.com', + idPriority: { + uid2: ['mockId3Module', 'mockId1Module'], + merkleId: ['mockId4Module', 'mockId3Module'] + }, + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return getGlobal().refreshUserIds().then(() => { + expect(getPPID()).to.eql('uid2valuefrommockId3Module7ac66c0f148de9519b8bd264312c4d64'); + }) + }); + describe('refreshing before init is complete', () => { const MOCK_ID = {'MOCKID': '1111'}; let mockIdCallback; + let startInit; beforeEach(() => { mockIdCallback = sinon.stub(); + coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); let mockIdSystem = { name: 'mockId', decode: function(value) { @@ -462,7 +1007,7 @@ describe('User ID', function () { }; init(config); setSubmoduleRegistry([mockIdSystem]); - config.setConfig({ + startInit = () => config.setConfig({ userSync: { auctionDelay: 10, userIds: [{ @@ -474,6 +1019,7 @@ describe('User ID', function () { }); it('should still resolve promises returned by getUserIdsAsync', () => { + startInit(); let result = null; getGlobal().getUserIdsAsync().then((val) => { result = val; }); return clearStack().then(() => { @@ -488,6 +1034,7 @@ describe('User ID', function () { it('should not stop auctions', (done) => { // simulate an infinite `auctionDelay`; refreshing should still allow the auction to continue // as soon as ID submodules have completed init + startInit(); requestBidsHook(() => { done(); }, {adUnits: [getAdUnitMock()]}, {delay: delay()}); @@ -495,10 +1042,83 @@ describe('User ID', function () { clearStack().then(() => { // simulate init complete mockIdCallback.callArg(0, {id: {MOCKID: '1111'}}); - }) + }); + }); + + it('should continue the auction when init fails', (done) => { + startInit(); + requestBidsHook(() => { + done(); + }, + {adUnits: [getAdUnitMock()]}, + { + delay: delay(), + getIds: () => Promise.reject(new Error()) + } + ); + }) + + it('should not get stuck when init fails', () => { + const err = new Error(); + mockIdCallback.callsFake(() => { throw err; }); + startInit(); + return getGlobal().getUserIdsAsync().catch((e) => + expect(e).to.equal(err) + ); }); }); + describe('when ID systems throw errors', () => { + function mockIdSystem(name) { + return { + name, + decode: function(value) { + return { + [name]: value + }; + }, + getId: sinon.stub().callsFake(() => ({id: name})) + }; + } + let id1, id2; + beforeEach(() => { + id1 = mockIdSystem('mock1'); + id2 = mockIdSystem('mock2'); + init(config); + setSubmoduleRegistry([id1, id2]); + config.setConfig({ + userSync: { + auctionDelay: 10, + userIds: [{ + name: 'mock1', + storage: {name: 'mock1', type: 'cookie'} + }, { + name: 'mock2', + storage: {name: 'mock2', type: 'cookie'} + }] + } + }) + }); + afterEach(() => { + config.resetConfig(); + }) + Object.entries({ + 'in init': () => id1.getId.callsFake(() => { throw new Error() }), + 'in callback': () => { + const mockCallback = sinon.stub().callsFake(() => { throw new Error() }); + id1.getId.callsFake(() => ({callback: mockCallback})) + } + }).forEach(([t, setup]) => { + describe(`${t}`, () => { + beforeEach(setup); + it('should still retrieve IDs that do not throw', () => { + return getGlobal().getUserIdsAsync().then((uid) => { + expect(uid.mock2).to.not.be.undefined; + }) + }); + }) + }) + }); it('pbjs.refreshUserIds updates submodules', function(done) { let sandbox = sinon.createSandbox(); let mockIdCallback = sandbox.stub().returns({id: {'MOCKID': '1111'}}); @@ -543,9 +1163,66 @@ describe('User ID', function () { }); }); + it('pbjs.refreshUserIds updates priority config', () => { + init(config); + + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {mockId1: 'mockId1_value'}}), + createMockIdSubmodule('mockId2Module', {id: {mockId2: 'mockId2_value', mockId3: 'mockId3_value_from_mockId2Module'}}), + createMockIdSubmodule('mockId3Module', {id: {mockId1: 'mockId1_value_from_mockId3Module', mockId2: 'mockId2_value_from_mockId3Module', mockId3: 'mockId3_value', mockId4: 'mockId4_value_from_mockId3Module'}}), + createMockIdSubmodule('mockId4Module', {id: {mockId4: 'mockId4_value'}}) + ]); + + config.setConfig({ + userSync: { + idPriority: { + mockId1: ['mockId3Module', 'mockId1Module'], + mockId4: ['mockId4Module', 'mockId3Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return getGlobal().getUserIdsAsync().then((uids) => { + expect(uids['mockId1']).to.deep.equal('mockId1_value_from_mockId3Module'); + expect(uids['mockId2']).to.deep.equal('mockId2_value'); + expect(uids['mockId3']).to.deep.equal('mockId3_value_from_mockId2Module'); + expect(uids['mockId4']).to.deep.equal('mockId4_value'); + + config.setConfig({ + userSync: { + idPriority: { + mockId1: ['mockId1Module', 'mockId3Module'], + mockId4: ['mockId3Module', 'mockId4Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + return getGlobal().getUserIdsAsync().then((uids) => { + expect(uids['mockId1']).to.deep.equal('mockId1_value'); + expect(uids['mockId2']).to.deep.equal('mockId2_value'); + expect(uids['mockId3']).to.deep.equal('mockId3_value_from_mockId2Module'); + expect(uids['mockId4']).to.deep.equal('mockId4_value_from_mockId3Module'); + }); + }); + }); + it('pbjs.refreshUserIds refreshes single', function() { coreStorage.setCookie('MOCKID', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('REFRESH', '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('refreshedid', '', EXPIRED_COOKIE_DATE); let sandbox = sinon.createSandbox(); let mockIdCallback = sandbox.stub().returns({id: {'MOCKID': '1111'}}); @@ -617,11 +1294,15 @@ describe('User ID', function () { config.resetConfig(); }); - it('fails initialization if opt out cookie exists', function () { + it('does not fetch ids if opt out cookie exists', function () { init(config); setSubmoduleRegistry([sharedIdSystemSubmodule]); - config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'])); - expect(utils.logInfo.args[0][0]).to.exist.and.to.equal('User ID - opt-out cookie found, exit module'); + const cfg = getConfigMock(['pubCommonId', 'pubcid', 'cookie']); + cfg.userSync.auctionDelay = 1; // to let init complete without an auction + config.setConfig(cfg); + return getGlobal().getUserIdsAsync().then((uid) => { + expect(uid).to.eql({}); + }) }); it('initializes if no opt out cookie exists', function () { @@ -645,7 +1326,7 @@ describe('User ID', function () { it('handles config with no usersync object', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({}); // usersync is undefined, and no logInfo message for 'User ID - usersync config updated' expect(typeof utils.logInfo.args[0]).to.equal('undefined'); @@ -653,14 +1334,14 @@ describe('User ID', function () { it('handles config with empty usersync object', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({userSync: {}}); expect(typeof utils.logInfo.args[0]).to.equal('undefined'); }); it('handles config with usersync and userIds that are empty objs', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({ userSync: { userIds: [{}] @@ -671,7 +1352,7 @@ describe('User ID', function () { it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({ userSync: { userIds: [{ @@ -688,7 +1369,7 @@ describe('User ID', function () { it('config with 1 configurations should create 1 submodules', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie'])); expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 1 submodules'); @@ -708,9 +1389,9 @@ describe('User ID', function () { expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 1 submodules'); }); - it('config with 24 configurations should result in 24 submodules add', function () { + it('config with 23 configurations should result in 23 submodules add', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule, tncidSubModule]); config.setConfig({ userSync: { syncDelay: 0, @@ -736,14 +1417,12 @@ describe('User ID', function () { }, { name: 'netId', storage: {name: 'netId', type: 'cookie'} - }, { - name: 'nextrollId' }, { name: 'intentIqId', storage: {name: 'intentIqId', type: 'cookie'} }, { name: 'hadronId', - storage: {name: 'hadronId', type: 'cookie'} + storage: {name: 'hadronId', type: 'html5'} }, { name: 'zeotapIdPlus' }, { @@ -755,16 +1434,14 @@ describe('User ID', function () { storage: {name: 'tapad_id', type: 'cookie'} }, { name: 'uid2' + }, { + name: 'euid' }, { name: 'admixerId', storage: {name: 'admixerId', type: 'cookie'} }, { name: 'deepintentId', storage: {name: 'deepintentId', type: 'cookie'} - }, { - name: 'flocId' - }, { - name: 'akamaiDAPId' }, { name: 'dmdId', storage: {name: 'dmdId', type: 'cookie'} @@ -777,15 +1454,17 @@ describe('User ID', function () { }, { name: 'qid', storage: {name: 'qid', type: 'html5'} + }, { + name: 'tncId' }] } }); - expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 24 submodules'); + expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 23 submodules'); }); it('config syncDelay updates module correctly', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({ userSync: { syncDelay: 99, @@ -800,7 +1479,7 @@ describe('User ID', function () { it('config auctionDelay updates module correctly', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({ userSync: { auctionDelay: 100, @@ -815,7 +1494,7 @@ describe('User ID', function () { it('config auctionDelay defaults to 0 if not a number', function () { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({ userSync: { auctionDelay: '', @@ -1146,7 +1825,7 @@ describe('User ID', function () { expect(bid).to.have.deep.nested.property('userId.amxId'); expect(bid.userId.amxId).to.equal('test_amxid_id'); expect(bid.userIdAsEids[0]).to.deep.equal({ - source: 'amxrtb.com', + source: 'amxdt.net', uids: [{ id: 'test_amxid_id', atype: 1, @@ -1720,8 +2399,8 @@ describe('User ID', function () { it('test hook from hadronId html5', function (done) { // simulate existing browser local storage values - localStorage.setItem('hadronId', JSON.stringify({'hadronId': 'random-ls-identifier'})); - localStorage.setItem('hadronId_exp', ''); + localStorage.setItem('hadronId', JSON.stringify({'hadronId': 'testHadronId1'})); + localStorage.setItem('hadronId_exp', (new Date(Date.now() + 5000)).toUTCString()); init(config); setSubmoduleRegistry([hadronIdSubmodule]); @@ -1731,20 +2410,20 @@ describe('User ID', function () { adUnits.forEach(unit => { unit.bids.forEach(bid => { expect(bid).to.have.deep.nested.property('userId.hadronId'); - expect(bid.userId.hadronId).to.equal('random-ls-identifier'); + expect(bid.userId.hadronId).to.equal('testHadronId1'); expect(bid.userIdAsEids[0]).to.deep.equal({ source: 'audigent.com', - uids: [{id: 'random-ls-identifier', atype: 1}] + uids: [{id: 'testHadronId1', atype: 1}] }); }); }); localStorage.removeItem('hadronId'); - localStorage.removeItem('hadronId_exp', ''); + localStorage.removeItem('hadronId_exp'); done(); }, {adUnits}); }); - it('test hook from merkleId cookies', function (done) { + it('test hook from merkleId cookies - legacy', function (done) { // simulate existing browser local storage values coreStorage.setCookie('merkleId', JSON.stringify({'pam_id': {'id': 'testmerkleId', 'keyID': 1}}), (new Date(Date.now() + 5000).toUTCString())); @@ -1768,6 +2447,32 @@ describe('User ID', function () { }, {adUnits}); }); + it('test hook from merkleId cookies', function (done) { + // simulate existing browser local storage values + coreStorage.setCookie('merkleId', JSON.stringify({ + 'merkleId': [{id: 'testmerkleId', ext: { keyID: 1, ssp: 'ssp1' }}, {id: 'another-random-id-value', ext: { ssp: 'ssp2' }}], + '_svsid': 'svs-id-1' + }), (new Date(Date.now() + 5000).toUTCString())); + + init(config); + setSubmoduleRegistry([merkleIdSubmodule]); + config.setConfig(getConfigMock(['merkleId', 'merkleId', 'cookie'])); + + requestBidsHook(function () { + adUnits.forEach(unit => { + unit.bids.forEach(bid => { + expect(bid).to.have.deep.nested.property('userId.merkleId'); + expect(bid.userId.merkleId.length).to.equal(2); + expect(bid.userIdAsEids.length).to.equal(2); + expect(bid.userIdAsEids[0]).to.deep.equal({ source: 'ssp1.merkleinc.com', uids: [{id: 'testmerkleId', atype: 3, ext: { keyID: 1, ssp: 'ssp1' }}] }); + expect(bid.userIdAsEids[1]).to.deep.equal({ source: 'ssp2.merkleinc.com', uids: [{id: 'another-random-id-value', atype: 3, ext: { ssp: 'ssp2' }}] }); + }); + }); + coreStorage.setCookie('merkleId', '', EXPIRED_COOKIE_DATE); + done(); + }, {adUnits}); + }); + it('test hook from zeotapIdPlus cookies', function (done) { // simulate existing browser local storage values coreStorage.setCookie('IDP', btoa(JSON.stringify('abcdefghijk')), (new Date(Date.now() + 5000).toUTCString())); @@ -1947,7 +2652,9 @@ describe('User ID', function () { coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('hadronId', JSON.stringify({'hadronId': 'testHadronId'}), (new Date(Date.now() + 5000).toUTCString())); + // hadronId only supports localStorage + localStorage.setItem('hadronId', JSON.stringify({'hadronId': 'testHadronId1'})); + localStorage.setItem('hadronId_exp', (new Date(Date.now() + 5000)).toUTCString()); coreStorage.setCookie('storage_criteo', JSON.stringify({'criteoId': 'test_bidid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('mwol', JSON.stringify({eid: 'XX-YY-ZZ-123'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('uid2id', 'Sample_AD_Token', (new Date(Date.now() + 5000).toUTCString())); @@ -1971,7 +2678,7 @@ describe('User ID', function () { ['netId', 'netId', 'cookie'], ['intentIqId', 'intentIqId', 'cookie'], ['zeotapIdPlus', 'IDP', 'cookie'], - ['hadronId', 'hadronId', 'cookie'], + ['hadronId', 'hadronId', 'html5'], ['criteo', 'storage_criteo', 'cookie'], ['mwOpenLinkId', 'mwol', 'cookie'], ['tapadId', 'tapad_id', 'cookie'], @@ -2014,7 +2721,7 @@ describe('User ID', function () { expect(bid.userId.IDP).to.equal('zeotapId'); // also check that hadronId id was copied to bid expect(bid).to.have.deep.nested.property('userId.hadronId'); - expect(bid.userId.hadronId).to.equal('testHadronId'); + expect(bid.userId.hadronId).to.equal('testHadronId1'); // also check that criteo id was copied to bid expect(bid).to.have.deep.nested.property('userId.criteoId'); expect(bid.userId.criteoId).to.equal('test_bidid'); @@ -2053,7 +2760,8 @@ describe('User ID', function () { coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('hadronId', '', EXPIRED_COOKIE_DATE); + localStorage.removeItem('hadronId'); + localStorage.removeItem('hadronId_exp'); coreStorage.setCookie('storage_criteo', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('mwol', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('uid2id', '', EXPIRED_COOKIE_DATE); @@ -2106,7 +2814,8 @@ describe('User ID', function () { coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('hadronId', JSON.stringify({'hadronId': 'testHadronId'}), (new Date(Date.now() + 5000).toUTCString())); + localStorage.setItem('hadronId', JSON.stringify({'hadronId': 'testHadronId1'})); + localStorage.setItem('hadronId_exp', (new Date(Date.now() + 5000)).toUTCString()); coreStorage.setCookie('admixerId', 'testadmixerId', new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('deepintentId', 'testdeepintentId', new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); @@ -2118,7 +2827,7 @@ describe('User ID', function () { localStorage.setItem('qid_exp', new Date(Date.now() + 5000).toUTCString()) init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); + setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, hadronIdSubmodule, uid2IdSubmodule, euidIdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]); config.setConfig({ userSync: { @@ -2142,7 +2851,7 @@ describe('User ID', function () { }, { name: 'zeotapIdPlus' }, { - name: 'hadronId', storage: {name: 'hadronId', type: 'cookie'} + name: 'hadronId', storage: {name: 'hadronId', type: 'html5'} }, { name: 'admixerId', storage: {name: 'admixerId', type: 'cookie'} }, { @@ -2210,7 +2919,7 @@ describe('User ID', function () { expect(bid.userId.IDP).to.equal('zeotapId'); // also check that hadronId id data was copied to bid expect(bid).to.have.deep.nested.property('userId.hadronId'); - expect(bid.userId.hadronId).to.equal('testHadronId'); + expect(bid.userId.hadronId).to.equal('testHadronId1'); expect(bid.userId.uid2).to.deep.equal({ id: 'Sample_AD_Token' }); @@ -2242,7 +2951,8 @@ describe('User ID', function () { coreStorage.setCookie('netId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('intentIqId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('IDP', '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie('hadronId', '', EXPIRED_COOKIE_DATE); + localStorage.removeItem('hadronId'); + localStorage.removeItem('hadronId_exp'); coreStorage.setCookie('dmdId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('admixerId', '', EXPIRED_COOKIE_DATE); coreStorage.setCookie('deepintentId', '', EXPIRED_COOKIE_DATE); @@ -2251,9 +2961,57 @@ describe('User ID', function () { localStorage.removeItem('amxId'); localStorage.removeItem('amxId_exp'); coreStorage.setCookie('kpuid', EXPIRED_COOKIE_DATE); + coreStorage.setCookie('__uid2_advertising_token', '', EXPIRED_COOKIE_DATE); done(); }, {adUnits}); }); + + describe('activity controls', () => { + let isAllowed; + const MOCK_IDS = ['mockId1', 'mockId2'] + beforeEach(() => { + isAllowed = sinon.stub(dep, 'isAllowed'); + init(config); + setSubmoduleRegistry([]); + const mods = MOCK_IDS.map((name) => ({ + name, + decode: function (value) { + return { + [name]: value + }; + }, + getId: function () { + return {id: `${name}Value`}; + } + })); + mods.forEach(attachIdSystem); + }); + afterEach(() => { + isAllowed.restore(); + }); + + it('should check for enrichEids activity permissions', (done) => { + isAllowed.callsFake((activity, params) => { + return !(activity === ACTIVITY_ENRICH_EIDS && + params[ACTIVITY_PARAM_COMPONENT_TYPE] === MODULE_TYPE_UID && + params[ACTIVITY_PARAM_COMPONENT_NAME] === MOCK_IDS[0]) + }) + + config.setConfig({ + userSync: { + syncDelay: 0, + userIds: MOCK_IDS.map(name => ({ + name, storage: {name, type: 'cookie'} + })) + } + }); + requestBidsHook((req) => { + const activeIds = req.adUnits.flatMap(au => au.bids).flatMap(bid => Object.keys(bid.userId)); + expect(Array.from(new Set(activeIds))).to.have.members([MOCK_IDS[1]]); + done(); + }, {adUnits}) + }); + }) }); describe('callbacks at the end of auction', function () { @@ -2314,7 +3072,7 @@ describe('User ID', function () { expect(server.requests).to.be.empty; return endAuction(); }).then(() => { - expect(server.requests[0].url).to.equal('/any/unifiedid/url'); + expect(server.requests[0].url).to.match(/\/any\/unifiedid\/url/); }); }); @@ -2339,15 +3097,21 @@ describe('User ID', function () { }); describe('Set cookie behavior', function () { - let coreStorageSpy; + let cookie, cookieStub; + beforeEach(function () { - coreStorageSpy = sinon.spy(coreStorage, 'setCookie'); setSubmoduleRegistry([sharedIdSystemSubmodule]); init(config); + cookie = document.cookie; + cookieStub = sinon.stub(document, 'cookie'); + cookieStub.get(() => cookie); + cookieStub.set((val) => cookie = val); }); + afterEach(function () { - coreStorageSpy.restore(); + cookieStub.restore(); }); + it('should allow submodules to override the domain', function () { const submodule = { submodule: { @@ -2356,26 +3120,34 @@ describe('User ID', function () { } }, config: { + name: 'mockId', storage: { type: 'cookie' } + }, + storageMgr: { + setCookie: sinon.stub() } } setStoredValue(submodule, 'bar'); - expect(coreStorage.setCookie.getCall(0).args[4]).to.equal('foo.com'); + expect(submodule.storageMgr.setCookie.getCall(0).args[4]).to.equal('foo.com'); }); - it('should pass null for domain if submodule does not override the domain', function () { + it('should pass no domain if submodule does not override the domain', function () { const submodule = { submodule: {}, config: { + name: 'mockId', storage: { type: 'cookie' } + }, + storageMgr: { + setCookie: sinon.stub() } } setStoredValue(submodule, 'bar'); - expect(coreStorage.setCookie.getCall(0).args[4]).to.equal(null); + expect(submodule.storageMgr.setCookie.getCall(0).args[4]).to.equal(null); }); }); @@ -2414,17 +3186,12 @@ describe('User ID', function () { } }; - consentData = { - gdprApplies: true, - consentString: 'mockString', - apiVersion: 1, - hasValidated: true // mock presence of GPDR enforcement module - } // clear cookies expStr = (new Date(Date.now() + 25000).toUTCString()); coreStorage.setCookie(mockIdCookieName, '', EXPIRED_COOKIE_DATE); coreStorage.setCookie(`${mockIdCookieName}_last`, '', EXPIRED_COOKIE_DATE); - coreStorage.setCookie(CONSENT_LOCAL_STORAGE_NAME, '', EXPIRED_COOKIE_DATE); + coreStorage.setCookie(`${mockIdCookieName}_cst`, '', EXPIRED_COOKIE_DATE); + allConsent.reset(); // init adUnits = [getAdUnitMock()]; @@ -2432,16 +3199,27 @@ describe('User ID', function () { // init id system attachIdSystem(mockIdSystem); - config.setConfig(userIdConfig); }); afterEach(function () { config.resetConfig(); }); + function setStorage({ + val = JSON.stringify({id: '1234'}), + lastDelta = 60 * 1000, + cst = null + } = {}) { + coreStorage.setCookie(mockIdCookieName, val, expStr); + coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - lastDelta).toUTCString()), expStr); + if (cst != null) { + coreStorage.setCookie(`${mockIdCookieName}_cst`, cst, expStr); + } + } + it('calls getId if no stored consent data and refresh is not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + setStorage({lastDelta: 1000}); + config.setConfig(userIdConfig); let innerAdUnits; return runBidsHook((config) => { @@ -2454,8 +3232,8 @@ describe('User ID', function () { }); it('calls getId if no stored consent data but refresh is needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 60 * 1000).toUTCString()), expStr); + setStorage(); + config.setConfig(userIdConfig); let innerAdUnits; return runBidsHook((config) => { @@ -2468,10 +3246,8 @@ describe('User ID', function () { }); it('calls getId if empty stored consent and refresh not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); - - setStoredConsentData(); + setStorage({cst: ''}); + config.setConfig(userIdConfig); let innerAdUnits; return runBidsHook((config) => { @@ -2484,10 +3260,12 @@ describe('User ID', function () { }); it('calls getId if stored consent does not match current consent and refresh not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + setStorage({cst: getConsentHash()}); + gdprDataHandler.setConsentData({ + consentString: 'different' + }); - setStoredConsentData({...consentData, consentString: 'different'}); + config.setConfig(userIdConfig); let innerAdUnits; return runBidsHook((config) => { @@ -2500,10 +3278,9 @@ describe('User ID', function () { }); it('does not call getId if stored consent matches current consent and refresh not needed', function () { - coreStorage.setCookie(mockIdCookieName, JSON.stringify({id: '1234'}), expStr); - coreStorage.setCookie(`${mockIdCookieName}_last`, (new Date(Date.now() - 1 * 1000).toUTCString()), expStr); + setStorage({lastDelta: 1000, cst: getConsentHash()}); - setStoredConsentData({...consentData}); + config.setConfig(userIdConfig); let innerAdUnits; return runBidsHook((config) => { @@ -2516,45 +3293,70 @@ describe('User ID', function () { }); }); - describe('findRootDomain', function () { - let sandbox; + describe('requestDataDeletion', () => { + function idMod(name, value) { + return { + name, + getId() { + return {id: value} + }, + decode(d) { + return {[name]: d} + }, + onDataDeletionRequest: sinon.stub() + } + } + let mod1, mod2, mod3, cfg1, cfg2, cfg3; - beforeEach(function () { + beforeEach(() => { init(config); - setSubmoduleRegistry([sharedIdSystemSubmodule]); + mod1 = idMod('id1', 'val1'); + mod2 = idMod('id2', 'val2'); + mod3 = idMod('id3', 'val3'); + cfg1 = getStorageMock('id1', 'id1', 'cookie'); + cfg2 = getStorageMock('id2', 'id2', 'html5'); + cfg3 = {name: 'id3', value: {id3: 'val3'}}; + setSubmoduleRegistry([mod1, mod2, mod3]); config.setConfig({ + auctionDelay: 1, userSync: { - syncDelay: 0, - userIds: [ - { - name: 'pubCommonId', - value: { pubcid: '11111' }, - }, - ], - }, + userIds: [cfg1, cfg2, cfg3] + } }); - sandbox = sinon.createSandbox(); - sandbox - .stub(coreStorage, 'getCookie') - .onFirstCall() - .returns(null) // .co.uk - .onSecondCall() - .returns('writeable'); // realdomain.co.uk; - }); - - afterEach(function () { - sandbox.restore(); - }); - - it('should just find the root domain', function () { - var domain = findRootDomain('sub.realdomain.co.uk'); - expect(domain).to.be.eq('realdomain.co.uk'); - }); - - it('should find the full domain when no subdomain is present', function () { - var domain = findRootDomain('realdomain.co.uk'); - expect(domain).to.be.eq('realdomain.co.uk'); - }); + return getGlobal().refreshUserIds(); + }); + + it('deletes stored IDs', () => { + expect(coreStorage.getCookie('id1')).to.exist; + expect(coreStorage.getDataFromLocalStorage('id2')).to.exist; + requestDataDeletion(sinon.stub()); + expect(coreStorage.getCookie('id1')).to.not.exist; + expect(coreStorage.getDataFromLocalStorage('id2')).to.not.exist; + }); + + it('invokes onDataDeletionRequest', () => { + requestDataDeletion(sinon.stub()); + sinon.assert.calledWith(mod1.onDataDeletionRequest, cfg1, {id1: 'val1'}); + sinon.assert.calledWith(mod2.onDataDeletionRequest, cfg2, {id2: 'val2'}) + sinon.assert.calledWith(mod3.onDataDeletionRequest, cfg3, {id3: 'val3'}) + }); + + describe('does not choke when onDataDeletionRequest', () => { + Object.entries({ + 'is missing': () => { delete mod1.onDataDeletionRequest }, + 'throws': () => { mod1.onDataDeletionRequest.throws(new Error()) } + }).forEach(([t, setup]) => { + it(t, () => { + setup(); + const next = sinon.stub(); + const arg = {random: 'value'}; + requestDataDeletion(next, arg); + sinon.assert.calledOnce(mod2.onDataDeletionRequest); + sinon.assert.calledOnce(mod3.onDataDeletionRequest); + sinon.assert.calledWith(next, arg); + }) + }) + }) }); }); @@ -2601,6 +3403,73 @@ describe('User ID', function () { }).catch(done); }); + it('pbjs.getEncryptedEidsForSource should return prioritized id as non-encrypted string', (done) => { + init(config); + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {uid2: {id: 'uid2_value'}}}), + createMockIdSubmodule('mockId2Module', {id: {pubcid: 'pubcid_value', lipb: {lipbid: 'lipbid_value_from_mockId2Module'}}}), + createMockIdSubmodule('mockId3Module', {id: {uid2: {id: 'uid2_value_from_mockId3Module'}, pubcid: 'pubcid_value_from_mockId3Module', lipb: {lipbid: 'lipbid_value'}, merkleId: {id: 'merkleId_value_from_mockId3Module'}}}, null, { + uid2: { + source: 'uidapi.com', + getValue(data) { + return data.id + } + }, + pubcid: { + source: 'pubcid.org', + }, + lipb: { + source: 'liveintent.com', + getValue(data) { + return data.lipbid + } + } + }), + createMockIdSubmodule('mockId4Module', {id: {merkleId: {id: 'merkleId_value'}}}, null, { + merkleId: { + source: 'merkleinc.com', + getValue(data) { + return data.id + } + } + }) + ]); + config.setConfig({ + userSync: { + idPriority: { + uid2: ['mockId3Module', 'mockId1Module'], + merkleId: ['mockId4Module', 'mockId3Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + const expctedIds = [ + 'pubcid_value', + 'uid2_value_from_mockId3Module', + 'merkleId_value', + 'lipbid_value_from_mockId2Module' + ]; + + const encrypt = false; + + Promise.all([ + getGlobal().getEncryptedEidsForSource('pubcid.org', encrypt), + getGlobal().getEncryptedEidsForSource('uidapi.com', encrypt), + getGlobal().getEncryptedEidsForSource('merkleinc.com', encrypt), + getGlobal().getEncryptedEidsForSource('liveintent.com', encrypt) + ]).then((result) => { + expect(result).to.deep.equal(expctedIds); + done(); + }) + }); + describe('pbjs.getEncryptedEidsForSource', () => { beforeEach(() => { init(config); @@ -2664,6 +3533,45 @@ describe('User ID', function () { done(); }); }); + + it('pbjs.getUserIdsAsEidBySource with priority config available to core', () => { + init(config); + setSubmoduleRegistry([ + createMockIdSubmodule('mockId1Module', {id: {uid2: {id: 'uid2_value'}}}), + createMockIdSubmodule('mockId2Module', {id: {pubcid: 'pubcid_value', lipb: {lipbid: 'lipbid_value_from_mockId2Module'}}}), + createMockIdSubmodule('mockId3Module', {id: {uid2: {id: 'uid2_value_from_mockId3Module'}, pubcid: 'pubcid_value_from_mockId3Module', lipb: {lipbid: 'lipbid_value'}, merkleId: {id: 'merkleId_value_from_mockId3Module'}}}), + createMockIdSubmodule('mockId4Module', {id: {merkleId: {id: 'merkleId_value'}}}) + ]); + config.setConfig({ + userSync: { + idPriority: { + uid2: ['mockId3Module', 'mockId1Module'], + merkleId: ['mockId4Module', 'mockId3Module'] + }, + auctionDelay: 10, // with auctionDelay > 0, no auction is needed to complete init + userIds: [ + { name: 'mockId1Module' }, + { name: 'mockId2Module' }, + { name: 'mockId3Module' }, + { name: 'mockId4Module' } + ] + } + }); + + const ids = { + 'uidapi.com': {'uid2': {id: 'uid2_value_from_mockId3Module'}}, + 'pubcid.org': {'pubcid': 'pubcid_value'}, + 'liveintent.com': {'lipb': {lipbid: 'lipbid_value_from_mockId2Module'}}, + 'merkleinc.com': {'merkleId': {id: 'merkleId_value'}} + }; + + return getGlobal().getUserIdsAsync().then(() => { + expect(getGlobal().getUserIdsAsEidBySource('pubcid.org')).to.deep.equal(createEidsArray(ids['pubcid.org'])[0]); + expect(getGlobal().getUserIdsAsEidBySource('uidapi.com')).to.deep.equal(createEidsArray(ids['uidapi.com'])[0]); + expect(getGlobal().getUserIdsAsEidBySource('merkleinc.com')).to.deep.equal(createEidsArray(ids['merkleinc.com'])[0]); + expect(getGlobal().getUserIdsAsEidBySource('liveintent.com')).to.deep.equal(createEidsArray(ids['liveintent.com'])[0]); + }); + }); }) }); }); diff --git a/test/spec/modules/utiqSystem_spec.js b/test/spec/modules/utiqSystem_spec.js new file mode 100644 index 00000000000..afeeea7c3ea --- /dev/null +++ b/test/spec/modules/utiqSystem_spec.js @@ -0,0 +1,188 @@ +import { expect } from 'chai'; +import { utiqSubmodule } from 'modules/utiqSystem.js'; +import { storage } from 'modules/utiqSystem.js'; + +describe('utiqSystem', () => { + const utiqPassKey = 'utiqPass'; + + const getStorageData = (idGraph) => { + if (!idGraph) { + idGraph = {id: 501, domain: ''}; + } + return { + 'connectId': { + 'idGraph': [idGraph], + } + } + }; + + it('should have the correct module name declared', () => { + expect(utiqSubmodule.name).to.equal('utiq'); + }); + + describe('utiq getId()', () => { + afterEach(() => { + storage.removeDataFromLocalStorage(utiqPassKey); + }); + + it('it should return object with key callback', () => { + expect(utiqSubmodule.getId()).to.have.property('callback'); + }); + + it('should return object with key callback with value type - function', () => { + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData())); + expect(utiqSubmodule.getId()).to.have.property('callback'); + expect(typeof utiqSubmodule.getId().callback).to.be.equal('function'); + }); + + it('tests if localstorage & JSON works properly ', () => { + const idGraph = { + 'domain': 'domainValue', + 'atid': 'atidValue', + }; + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph))); + expect(JSON.parse(storage.getDataFromLocalStorage(utiqPassKey))).to.have.property('connectId'); + }); + + it('returns {id: {utiq: data.utiq}} if we have the right data stored in the localstorage ', () => { + const idGraph = { + 'domain': 'test.domain', + 'atid': 'atidValue', + }; + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph))); + const response = utiqSubmodule.getId(); + expect(response).to.have.property('id'); + expect(response.id).to.have.property('utiq'); + expect(response.id.utiq).to.be.equal('atidValue'); + }); + + it('returns {utiq: data.utiq} if we have the right data stored in the localstorage right after the callback is called', (done) => { + const idGraph = { + 'domain': 'test.domain', + 'atid': 'atidValue', + }; + const response = utiqSubmodule.getId(); + expect(response).to.have.property('callback'); + expect(response.callback.toString()).contain('result(callback)'); + + if (typeof response.callback === 'function') { + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph))); + response.callback(function (result) { + expect(result).to.not.be.null; + expect(result).to.have.property('utiq'); + expect(result.utiq).to.be.equal('atidValue'); + done() + }) + } + }); + + it('returns {utiq: data.utiq} if we have the right data stored in the localstorage right after 500ms delay', (done) => { + const idGraph = { + 'domain': 'test.domain', + 'atid': 'atidValue', + }; + + const response = utiqSubmodule.getId(); + expect(response).to.have.property('callback'); + expect(response.callback.toString()).contain('result(callback)'); + + if (typeof response.callback === 'function') { + setTimeout(() => { + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph))); + }, 500); + response.callback(function (result) { + expect(result).to.not.be.null; + expect(result).to.have.property('utiq'); + expect(result.utiq).to.be.equal('atidValue'); + done() + }) + } + }); + + it('returns null if we have the data stored in the localstorage after 500ms delay and the max (waiting) delay is only 200ms ', (done) => { + const idGraph = { + 'domain': 'test.domain', + 'atid': 'atidValue', + }; + + const response = utiqSubmodule.getId({params: {maxDelayTime: 200}}); + expect(response).to.have.property('callback'); + expect(response.callback.toString()).contain('result(callback)'); + + if (typeof response.callback === 'function') { + setTimeout(() => { + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph))); + }, 500); + response.callback(function (result) { + expect(result).to.be.null; + done() + }) + } + }); + }); + + describe('utiq decode()', () => { + const VALID_API_RESPONSES = [ + { + expected: '32a97f612', + payload: { + utiq: '32a97f612' + } + }, + { + expected: '32a97f61', + payload: { + utiq: '32a97f61', + } + }, + ]; + VALID_API_RESPONSES.forEach(responseData => { + it('should return a newly constructed object with the utiq for a payload with {utiq: value}', () => { + expect(utiqSubmodule.decode(responseData.payload)).to.deep.equal( + {utiq: responseData.expected} + ); + }); + }); + + [{}, '', {foo: 'bar'}].forEach((response) => { + it(`should return null for an invalid response "${JSON.stringify(response)}"`, () => { + expect(utiqSubmodule.decode(response)).to.be.null; + }); + }); + }); + + describe('utiq messageHandler', () => { + afterEach(() => { + storage.removeDataFromLocalStorage(utiqPassKey); + }); + + const domains = [ + 'domain1', + 'domain2', + 'domain3', + ]; + + domains.forEach(domain => { + it(`correctly sets utiq value for domain name ${domain}`, (done) => { + const idGraph = { + 'domain': domain, + 'atid': 'atidValue', + }; + + storage.setDataInLocalStorage(utiqPassKey, JSON.stringify(getStorageData(idGraph))); + + const eventData = { + data: `{\"msgType\":\"MNOSELECTOR\",\"body\":{\"url\":\"https://${domain}/some/path\"}}` + }; + + window.dispatchEvent(new MessageEvent('message', eventData)); + + const response = utiqSubmodule.getId(); + expect(response).to.have.property('id'); + expect(response.id).to.have.property('utiq'); + expect(response.id.utiq).to.be.equal('atidValue'); + done(); + }); + }); + }); +}); diff --git a/test/spec/modules/ventesBidAdapter_spec.js b/test/spec/modules/ventesBidAdapter_spec.js index 219c24deced..8e1a747f6f7 100644 --- a/test/spec/modules/ventesBidAdapter_spec.js +++ b/test/spec/modules/ventesBidAdapter_spec.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import * as utils from 'src/utils.js'; import { spec } from 'modules/ventesBidAdapter.js'; -const BIDDER_URL = 'http://13.234.201.146:8088/va/ad'; +const BIDDER_URL = 'https://ad.ventesavenues.in/va/ad'; describe('Ventes Adapter', function () { const examples = { @@ -28,13 +28,14 @@ describe('Ventes Adapter', function () { adUnitContext: { refererInfo: { - referer: 'https://ventesavenues.in', + page: 'https://ventesavenues.in', + domain: 'ventesavenues.in', } }, serverRequest_banner: { method: 'POST', - url: 'http://13.234.201.146:8088/va/ad', + url: BIDDER_URL, data: { id: 'bid_request_id', imp: [ @@ -373,7 +374,7 @@ describe('Ventes Adapter', function () { expect(serverRequests[0].data).to.exist.and.to.be.an('object'); expect(serverRequests[0].data.id).to.exist.and.to.be.an('string').and.to.equal(adUnits[0].bidderRequestId); expect(serverRequests[0].data.site).to.exist.and.to.be.an('object'); - expect(serverRequests[0].data.site.page).to.exist.and.to.be.an('string').and.to.equal(adUnitContext.refererInfo.referer); + expect(serverRequests[0].data.site.page).to.exist.and.to.be.an('string').and.to.equal(adUnitContext.refererInfo.page); expect(serverRequests[0].data.site.domain).to.exist.and.to.be.an('string').and.to.equal('ventesavenues.in'); expect(serverRequests[0].data.site.name).to.exist.and.to.be.an('string').and.to.equal('ventesavenues.in'); }); diff --git a/test/spec/modules/viantOrtbBidAdapter_spec.js b/test/spec/modules/viantOrtbBidAdapter_spec.js new file mode 100644 index 00000000000..ef537d50986 --- /dev/null +++ b/test/spec/modules/viantOrtbBidAdapter_spec.js @@ -0,0 +1,432 @@ +import { spec, converter } from 'modules/viantOrtbBidAdapter.js'; +import {assert, expect} from 'chai'; +import { deepClone } from '../../../src/utils'; +import {buildWindowTree} from '../../helpers/refererDetectionHelper'; +import {detectReferer} from '../../../src/refererDetection'; +describe('viantOrtbBidAdapter', function () { + function testBuildRequests(bidRequests, bidderRequestBase) { + let clonedBidderRequest = deepClone(bidderRequestBase); + clonedBidderRequest.bids = bidRequests; + let requests = spec.buildRequests(bidRequests, clonedBidderRequest); + return requests + } + describe('isBidRequestValid', function() { + function makeBid() { + return { + 'bidder': 'viant', + 'params': { + 'publisherId': '464', + 'placementId': 'some-PlacementId_1' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [ + [728, 90] + ] + } + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + }; + } + + describe('core', function () { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(makeBid())).to.equal(true); + }); + + it('should return false when publisherId not passed', function () { + let bid = makeBid(); + delete bid.params.publisherId; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + + it('should return true if placementId is not passed ', function () { + let bid = makeBid(); + delete bid.params.placementId; + bid.ortb2Imp = { + + } + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false if mediaTypes.banner is Not passed', function () { + let bid = makeBid(); + delete bid.mediaTypes + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('banner', function () { + it('should return true if banner.pos is passed correctly', function () { + let bid = makeBid(); + bid.mediaTypes.banner.pos = 1; + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + }); + + describe('video', function () { + describe('and request config uses mediaTypes', () => { + function makeBid() { + return { + 'bidder': 'viant', + 'params': { + 'unit': '12345678', + 'delDomain': 'test-del-domain', + 'publisherId': '464', + 'placementId': 'some-PlacementId_2' + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [[640, 480]], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6, 7, 8], + 'api': [1, 3], + 'skip': 1, + 'skipafter': 5, + 'minduration': 10, + 'maxduration': 30 + } + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' + } + } + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(makeBid())).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let videoBidWithMediaTypes = Object.assign({}, makeBid()); + videoBidWithMediaTypes.params = {}; + expect(spec.isBidRequestValid(videoBidWithMediaTypes)).to.equal(false); + }); + }); + }); + }); + + describe('buildRequests-banner', function () { + const baseBannerBidRequests = [{ + 'bidder': 'viant', + 'params': { + 'publisherId': '464', + 'placementId': '1' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90]] + } + }, + 'gdprConsent': { + 'consentString': 'consentString', + 'gdprApplies': true, + }, + 'uspConsent': '1YYY', + 'sizes': [[728, 90]], + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'bidId': '243310435309b5', + 'bidderRequestId': '18084284054531', + 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'src': 'client', + 'bidRequestsCount': 1 + }]; + + const testWindow = buildWindowTree(['https://www.example.com/test', 'https://www.example.com/other/page', 'https://www.example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'); + const baseBidderRequestReferer = detectReferer(testWindow)(); + const baseBidderRequest = { + 'bidderCode': 'viant', + 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'bidderRequestId': '18084284054531', + 'auctionStart': 1540945362095, + 'timeout': 3000, + 'refererInfo': baseBidderRequestReferer, + 'start': 1540945362099, + 'doneCbCallCount': 0 + }; + + it('test regs', function () { + const gdprBaseBidderRequest = Object.assign({}, baseBidderRequest, { + gdprConsent: { + consentString: 'consentString', + gdprApplies: true, + }, + uspConsent: '1YYN' + }); + const request = testBuildRequests(baseBannerBidRequests, gdprBaseBidderRequest)[0]; + expect(request.data.regs.ext).to.have.property('gdpr', 1); + expect(request.data.regs.ext).to.have.property('us_privacy', '1YYN'); + }); + + it('sends bid request to our endpoint that makes sense', function () { + const request = testBuildRequests(baseBannerBidRequests, baseBidderRequest)[0]; + expect(request.method).to.equal('POST'); + expect(request.url).to.be.not.empty; + expect(request.data).to.be.not.null; + }); + it('sends bid requests to the correct endpoint', function () { + const url = testBuildRequests(baseBannerBidRequests, baseBidderRequest)[0].url; + expect(url).to.equal('https://bidders-us-east-1.adelphic.net/d/rtb/v25/prebid/bidder_test'); + }); + + it('sends site', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest)[0].data; + expect(requestBody.site).to.be.not.null; + }); + + it('includes the ad size in the bid request', function () { + const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest)[0].data; + expect(requestBody.imp[0].banner.format[0].w).to.equal(728); + expect(requestBody.imp[0].banner.format[0].h).to.equal(90); + }); + + it('sets the banner pos correctly if sent', function () { + let clonedBannerRequests = deepClone(baseBannerBidRequests); + clonedBannerRequests[0].mediaTypes.banner.pos = 1; + + const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest)[0].data; + expect(requestBody.imp[0].banner.pos).to.equal(1); + }); + }); + + if (FEATURES.VIDEO) { + describe('buildRequests-video', function () { + function makeBid() { + return { + 'bidder': 'viant', + 'params': { + 'unit': '12345678', + 'delDomain': 'test-del-domain', + 'publisherId': '464', + 'placementId': 'some-PlacementId_2' + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [[640, 480]], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6, 7, 8], + 'api': [1, 3], + 'skip': 1, + 'skipafter': 5, + 'minduration': 10, + 'maxduration': 31 + } + }, + 'adUnitCode': 'adunit-code', + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + 'transactionId': '4008d88a-8137-410b-aa35-fbfdabcb478e' + } + } + + it('assert video and its fields is present in imp ', function () { + let requests = spec.buildRequests([makeBid()], {referrerInfo: {}}); + let clonedRequests = deepClone(requests) + assert.equal(clonedRequests[0].data.imp[0].video.mimes[0], 'video/mp4') + assert.equal(clonedRequests[0].data.imp[0].video.maxduration, 31) + assert.equal(clonedRequests[0].data.imp[0].video.placement, 1) + assert.equal(clonedRequests[0].method, 'POST') + }); + }); + } + + describe('interpretResponse', function () { + const baseBannerBidRequests = [{ + 'bidder': 'viant', + 'params': { + 'publisherId': '464', + 'placementId': '1' + }, + 'mediaTypes': { + 'banner': { + 'sizes': [[728, 90]] + } + }, + 'sizes': [[728, 90]], + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'bidId': '243310435309b5', + 'bidderRequestId': '18084284054531', + 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'src': 'client', + 'bidRequestsCount': 1 + }]; + + const testWindow = buildWindowTree(['https://www.example.com/test', 'https://www.example.com/other/page', 'https://www.example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'); + const baseBidderRequestReferer = detectReferer(testWindow)(); + const baseBidderRequest = { + 'bidderCode': 'viant', + 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'bidderRequestId': '18084284054531', + 'auctionStart': 1540945362095, + 'timeout': 3000, + 'refererInfo': baseBidderRequestReferer, + 'start': 1540945362099, + 'doneCbCallCount': 0 + }; + + it('empty bid response test', function () { + const request = testBuildRequests(baseBannerBidRequests, baseBidderRequest)[0]; + let bidResponse = {nbr: 0}; // Unknown error + let bids = spec.interpretResponse({body: bidResponse}, request); + expect(bids.length).to.equal(0); + }); + + it('bid response is a banner', function () { + const request = testBuildRequests(baseBannerBidRequests, baseBidderRequest)[0]; + let bidResponse = { + seatbid: [{ + bid: [{ + impid: '243310435309b5', + price: 2, + w: 728, + h: 90, + crid: 'test-creative-id', + dealid: 'test-deal-id', + adm: 'test-ad-markup', + }] + }], + cur: 'USD' + }; + let bids = spec.interpretResponse({body: bidResponse}, request); + expect(bids.length).to.equal(1); + let bid = bids[0]; + it('should return the proper mediaType', function () { + it('should return a creativeId', function () { + expect(bid.mediaType).to.equal('banner'); + }); + }); + it('should return a price', function () { + expect(bid.cpm).to.equal(bidResponse.seatbid[0].bid[0].price); + }); + + it('should return a request id', function () { + expect(bid.requestId).to.equal(bidResponse.seatbid[0].bid[0].impid); + }); + + it('should return width and height for the creative', function () { + expect(bid.width).to.equal(bidResponse.seatbid[0].bid[0].w); + expect(bid.height).to.equal(bidResponse.seatbid[0].bid[0].h); + }); + it('should return a creativeId', function () { + expect(bid.creativeId).to.equal(bidResponse.seatbid[0].bid[0].crid); + }); + it('should return an ad', function () { + expect(bid.ad).to.equal(bidResponse.seatbid[0].bid[0].adm); + }); + + it('should return a deal id if it exists', function () { + expect(bid.dealId).to.equal(bidResponse.seatbid[0].bid[0].dealid); + }); + + it('should have a time-to-live of 5 minutes', function () { + expect(bid.ttl).to.equal(300); + }); + + it('should always return net revenue', function () { + expect(bid.netRevenue).to.equal(true); + }); + it('should return a currency', function () { + expect(bid.currency).to.equal(bidResponse.cur); + }); + }); + }); + describe('interpretResponse-Video', function () { + const baseVideoBidRequests = [{ + 'bidder': 'viant', + 'params': { + 'publisherId': '464', + 'placementId': '1' + }, + 'mediaTypes': { + 'video': { + 'context': 'instream', + 'playerSize': [[640, 480]], + 'mimes': ['video/mp4'], + 'protocols': [1, 2, 3, 4, 5, 6, 7, 8], + 'api': [1, 3], + 'skip': 1, + 'skipafter': 5, + 'minduration': 10, + 'maxduration': 31 + } + }, + 'sizes': [[640, 480]], + 'transactionId': '1111474f-58b1-4368-b812-84f8c937a099', + 'adUnitCode': 'div-gpt-ad-1460505748561-0', + 'bidId': '243310435309b5', + 'bidderRequestId': '18084284054531', + 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'src': 'client', + 'bidRequestsCount': 1 + }]; + + const testWindow = buildWindowTree(['https://www.example.com/test', 'https://www.example.com/other/page', 'https://www.example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'); + const baseBidderRequestReferer = detectReferer(testWindow)(); + const baseBidderRequest = { + 'bidderCode': 'viant', + 'auctionId': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'bidderRequestId': '18084284054531', + 'auctionStart': 1540945362095, + 'timeout': 3000, + 'refererInfo': baseBidderRequestReferer, + 'start': 1540945362099, + 'doneCbCallCount': 0 + }; + + it('bid response is a video', function () { + const request = testBuildRequests(baseVideoBidRequests, baseBidderRequest)[0]; + const VIDEO_BID_RESPONSE = { + 'id': 'bidderRequestId', + 'bidid': 'e7b34fa3-8654-424e-8c49-03e509e53d8c', + 'seatbid': [ + { + 'bid': [ + { + 'id': '1', + 'impid': '243310435309b5', + 'price': 1.09, + 'adid': '144762342', + 'nurl': 'http://0.0.0.0:8181/nurl', + 'adm': '', + 'adomain': [ + 'https://dummydomain.com' + ], + 'cid': 'cid', + 'crid': 'crid', + 'iurl': 'iurl', + 'cat': [], + 'h': 480, + 'w': 640 + } + ] + } + ], + 'cur': 'USD' + }; + let bids = spec.interpretResponse({body: VIDEO_BID_RESPONSE}, request); + expect(bids.length).to.equal(1); + let bid = bids[0]; + it('should return the proper mediaType', function () { + expect(bid.mediaType).to.equal('video'); + }); + it('should return correct Ad Markup', function () { + expect(bid.vastXml).to.equal(''); + }); + it('should return correct Notification', function () { + expect(bid.vastUrl).to.equal('http://0.0.0.0:8181/nurl'); + }); + it('should return correct Cpm', function () { + expect(bid.cpm).to.equal(1.09); + }); + }); + }); +}); diff --git a/test/spec/modules/vidazooBidAdapter_spec.js b/test/spec/modules/vidazooBidAdapter_spec.js index 0b5dadce09f..864f2b8551c 100644 --- a/test/spec/modules/vidazooBidAdapter_spec.js +++ b/test/spec/modules/vidazooBidAdapter_spec.js @@ -1,7 +1,6 @@ -import { expect } from 'chai'; +import {expect} from 'chai'; import { spec as adapter, - SUPPORTED_ID_SYSTEMS, createDomain, hashCode, extractPID, @@ -13,10 +12,15 @@ import { getUniqueDealId, getNextDealId, getVidazooSessionId, + webSessionId } from 'modules/vidazooBidAdapter.js'; import * as utils from 'src/utils.js'; -import { version } from 'package.json'; -import { useFakeTimers } from 'sinon'; +import {version} from 'package.json'; +import {useFakeTimers} from 'sinon'; +import {BANNER, VIDEO} from '../../../src/mediaTypes'; +import {config} from '../../../src/config'; + +export const TEST_ID_SYSTEMS = ['britepoolid', 'criteoId', 'id5id', 'idl_env', 'lipb', 'netId', 'parrableId', 'pubcid', 'tdid', 'pubProvidedId']; const SUB_DOMAIN = 'openrtb'; @@ -34,28 +38,109 @@ const BID = { } }, 'placementCode': 'div-gpt-ad-1460505748561-0', - 'transactionId': 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', 'sizes': [[300, 250], [300, 600]], 'bidderRequestId': '1fdb5ff1b6eaa7', + 'bidRequestsCount': 4, + 'bidderRequestsCount': 3, + 'bidderWinsCount': 1, 'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a', - 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc' + 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc', + 'mediaTypes': [BANNER], + 'ortb2Imp': { + 'ext': { + tid: 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', + 'gpid': '1234567890' + } + } }; +const VIDEO_BID = { + 'bidId': '2d52001cabd527', + 'adUnitCode': '63550ad1ff6642d368cba59dh5884270560', + 'bidderRequestId': '12a8ae9ada9c13', + ortb2Imp: { + ext: { + tid: '56e184c6-bde9-497b-b9b9-cf47a61381ee', + } + }, + 'bidRequestsCount': 4, + 'bidderRequestsCount': 3, + 'bidderWinsCount': 1, + 'schain': 'a0819c69-005b-41ed-af06-1be1e0aefefc', + 'params': { + 'subDomain': SUB_DOMAIN, + 'cId': '635509f7ff6642d368cb9837', + 'pId': '59ac17c192832d0011283fe3', + 'bidFloor': 0.1 + }, + 'sizes': [[545, 307]], + 'mediaTypes': { + 'video': { + 'playerSize': [[545, 307]], + 'context': 'instream', + 'mimes': [ + 'video/mp4', + 'application/javascript' + ], + 'protocols': [2, 3, 5, 6], + 'maxduration': 60, + 'minduration': 0, + 'startdelay': 0, + 'linearity': 1, + 'api': [2], + 'placement': 1 + } + } +} + const BIDDER_REQUEST = { 'gdprConsent': { 'consentString': 'consent_string', 'gdprApplies': true }, + 'gppString': 'gpp_string', + 'gppSid': [7], 'uspConsent': 'consent_string', 'refererInfo': { - 'referer': 'https://www.greatsite.com' - } + 'page': 'https://www.greatsite.com', + 'ref': 'https://www.somereferrer.com' + }, + 'ortb2': { + 'site': { + 'cat': ['IAB2'], + 'pagecat': ['IAB2-2'] + }, + 'regs': { + 'gpp': 'gpp_string', + 'gpp_sid': [7] + }, + 'device': { + 'sua': { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + } + } + }, }; const SERVER_RESPONSE = { body: { + cid: 'testcid123', results: [{ 'ad': '', + 'bidId': '2d52001cabd527-response', 'price': 0.8, 'creativeId': '12610997325162499419', 'exp': 30, @@ -73,6 +158,23 @@ const SERVER_RESPONSE = { } }; +const VIDEO_SERVER_RESPONSE = { + body: { + 'cid': '635509f7ff6642d368cb9837', + 'results': [{ + 'ad': '', + 'advertiserDomains': ['vidazoo.com'], + 'exp': 60, + 'width': 545, + 'height': 307, + 'mediaType': 'video', + 'creativeId': '12610997325162499419', + 'price': 2, + 'cookies': [] + }] + } +} + const REQUEST = { data: { width: 300, @@ -81,6 +183,15 @@ const REQUEST = { } }; +function getTopWindowQueryParams() { + try { + const parsedUrl = utils.parseUrl(window.top.document.URL, {decodeSearchAsString: true}); + return parsedUrl.search; + } catch (e) { + return ''; + } +} + describe('VidazooBidAdapter', function () { describe('validtae spec', function () { it('exists and is a function', function () { @@ -102,6 +213,11 @@ describe('VidazooBidAdapter', function () { it('exists and is a string', function () { expect(adapter.code).to.exist.and.to.be.a('string'); }); + + it('exists and contains media types', function () { + expect(adapter.supportedMediaTypes).to.exist.and.to.be.an('array').with.length(2); + expect(adapter.supportedMediaTypes).to.contain.members([BANNER, VIDEO]); + }); }); describe('validate bid requests', function () { @@ -137,12 +253,101 @@ describe('VidazooBidAdapter', function () { describe('build requests', function () { let sandbox; before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + vidazoo: { + storageAllowed: true, + } + }; sandbox = sinon.sandbox.create(); sandbox.stub(Date, 'now').returns(1000); }); - it('should build request for each size', function () { - const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.referer); + it('should build video request', function () { + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); + config.setConfig({ + bidderTimeout: 3000 + }); + const requests = adapter.buildRequests([VIDEO_BID], BIDDER_REQUEST); + expect(requests).to.have.length(1); + expect(requests[0]).to.deep.equal({ + method: 'POST', + url: `${createDomain(SUB_DOMAIN)}/prebid/multi/635509f7ff6642d368cb9837`, + data: { + adUnitCode: '63550ad1ff6642d368cba59dh5884270560', + bidFloor: 0.1, + bidId: '2d52001cabd527', + bidderVersion: adapter.version, + cat: ['IAB2'], + pagecat: ['IAB2-2'], + cb: 1000, + dealId: 1, + gdpr: 1, + gdprConsent: 'consent_string', + usPrivacy: 'consent_string', + gppString: 'gpp_string', + gppSid: [7], + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + transactionId: '56e184c6-bde9-497b-b9b9-cf47a61381ee', + bidderRequestId: '12a8ae9ada9c13', + gpid: '', + prebidVersion: version, + ptrace: '1000', + publisherId: '59ac17c192832d0011283fe3', + url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', + res: `${window.top.screen.width}x${window.top.screen.height}`, + schain: VIDEO_BID.schain, + sessionId: '', + sizes: ['545x307'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, + uniqueDealId: `${hashUrl}_${Date.now().toString()}`, + uqs: getTopWindowQueryParams(), + isStorageAllowed: true, + webSessionId: webSessionId, + mediaTypes: { + video: { + api: [2], + context: 'instream', + linearity: 1, + maxduration: 60, + mimes: [ + 'video/mp4', + 'application/javascript' + ], + minduration: 0, + placement: 1, + playerSize: [[545, 307]], + protocols: [2, 3, 5, 6], + startdelay: 0 + } + } + } + }); + }); + + it('should build banner request for each size', function () { + config.setConfig({ + bidderTimeout: 3000 + }); + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); const requests = adapter.buildRequests([BID], BIDDER_REQUEST); expect(requests).to.have.length(1); expect(requests[0]).to.deep.equal({ @@ -152,45 +357,202 @@ describe('VidazooBidAdapter', function () { gdprConsent: 'consent_string', gdpr: 1, usPrivacy: 'consent_string', + gppString: 'gpp_string', + gppSid: [7], + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + transactionId: 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', + bidderRequestId: '1fdb5ff1b6eaa7', sizes: ['300x250', '300x600'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', cb: 1000, bidFloor: 0.1, bidId: '2d52001cabd527', adUnitCode: 'div-gpt-ad-12345-0', publisherId: '59ac17c192832d0011283fe3', - dealId: 1, + dealId: 2, sessionId: '', uniqueDealId: `${hashUrl}_${Date.now().toString()}`, bidderVersion: adapter.version, prebidVersion: version, schain: BID.schain, + ptrace: '1000', res: `${window.top.screen.width}x${window.top.screen.height}`, + mediaTypes: [BANNER], + uqs: getTopWindowQueryParams(), 'ext.param1': 'loremipsum', 'ext.param2': 'dolorsitamet', + isStorageAllowed: true, + gpid: '1234567890', + cat: ['IAB2'], + pagecat: ['IAB2-2'], + webSessionId: webSessionId + } + }); + }); + + it('should build single banner request for multiple bids', function () { + config.setConfig({ + bidderTimeout: 3000, + vidazoo: { + singleRequest: true, + chunkSize: 2 + } + }); + + const hashUrl = hashCode(BIDDER_REQUEST.refererInfo.page); + + const BID2 = utils.deepClone(BID); + BID2.bidId = '2d52001cabd528'; + BID2.adUnitCode = 'div-gpt-ad-12345-1'; + BID2.sizes = [[300, 250]]; + + const REQUEST_DATA = { + gdprConsent: 'consent_string', + gdpr: 1, + usPrivacy: 'consent_string', + gppString: 'gpp_string', + gppSid: [7], + bidRequestsCount: 4, + bidderRequestsCount: 3, + bidderWinsCount: 1, + bidderTimeout: 3000, + transactionId: 'c881914b-a3b5-4ecf-ad9c-1c2f37c6aabf', + bidderRequestId: '1fdb5ff1b6eaa7', + sizes: ['300x250', '300x600'], + sua: { + 'source': 2, + 'platform': { + 'brand': 'Android', + 'version': ['8', '0', '0'] + }, + 'browsers': [ + {'brand': 'Not_A Brand', 'version': ['99', '0', '0', '0']}, + {'brand': 'Google Chrome', 'version': ['109', '0', '5414', '119']}, + {'brand': 'Chromium', 'version': ['109', '0', '5414', '119']} + ], + 'mobile': 1, + 'model': 'SM-G955U', + 'bitness': '64', + 'architecture': '' + }, + url: 'https%3A%2F%2Fwww.greatsite.com', + referrer: 'https://www.somereferrer.com', + cb: 1000, + bidFloor: 0.1, + bidId: '2d52001cabd527', + adUnitCode: 'div-gpt-ad-12345-0', + publisherId: '59ac17c192832d0011283fe3', + dealId: 3, + sessionId: '', + uniqueDealId: `${hashUrl}_${Date.now().toString()}`, + bidderVersion: adapter.version, + prebidVersion: version, + schain: BID.schain, + ptrace: '1000', + res: `${window.top.screen.width}x${window.top.screen.height}`, + mediaTypes: [BANNER], + uqs: getTopWindowQueryParams(), + 'ext.param1': 'loremipsum', + 'ext.param2': 'dolorsitamet', + isStorageAllowed: true, + gpid: '1234567890', + cat: ['IAB2'], + pagecat: ['IAB2-2'], + webSessionId: webSessionId + }; + + const REQUEST_DATA2 = utils.deepClone(REQUEST_DATA); + REQUEST_DATA2.bidId = '2d52001cabd528'; + REQUEST_DATA2.adUnitCode = 'div-gpt-ad-12345-1'; + REQUEST_DATA2.sizes = ['300x250']; + REQUEST_DATA2.dealId = 4; + + const requests = adapter.buildRequests([BID, BID2], BIDDER_REQUEST); + expect(requests).to.have.length(1); + + expect(requests[0]).to.deep.equal({ + method: 'POST', + url: `${createDomain(SUB_DOMAIN)}/prebid/multi/59db6b3b4ffaa70004f45cdc`, + data: {bids: [REQUEST_DATA, REQUEST_DATA2]} + }); + }); + + it('should return seperated requests for video and banner if singleRequest is true', function () { + config.setConfig({ + bidderTimeout: 3000, + vidazoo: { + singleRequest: true, + chunkSize: 2 } }); + + const requests = adapter.buildRequests([BID, VIDEO_BID], BIDDER_REQUEST); + expect(requests).to.have.length(2); + }); + + it('should chunk requests if requests exceed chunkSize and singleRequest is true', function () { + config.setConfig({ + bidderTimeout: 3000, + vidazoo: { + singleRequest: true, + chunkSize: 2 + } + }); + + const requests = adapter.buildRequests([BID, BID, BID, BID], BIDDER_REQUEST); + expect(requests).to.have.length(2); }); after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + config.resetConfig(); sandbox.restore(); }); }); + describe('getUserSyncs', function () { it('should have valid user sync with iframeEnabled', function () { - const result = adapter.getUserSyncs({ iframeEnabled: true }, [SERVER_RESPONSE]); + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); + + expect(result).to.deep.equal([{ + type: 'iframe', + url: 'https://sync.cootlogix.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=' + }]); + }); + it('should have valid user sync with cid on response', function () { + const result = adapter.getUserSyncs({iframeEnabled: true}, [SERVER_RESPONSE]); expect(result).to.deep.equal([{ type: 'iframe', - url: 'https://prebid.cootlogix.com/api/sync/iframe/?gdpr=0&gdpr_consent=&us_privacy=' + url: 'https://sync.cootlogix.com/api/sync/iframe/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=' }]); }); it('should have valid user sync with pixelEnabled', function () { - const result = adapter.getUserSyncs({ pixelEnabled: true }, [SERVER_RESPONSE]); + const result = adapter.getUserSyncs({pixelEnabled: true}, [SERVER_RESPONSE]); expect(result).to.deep.equal([{ - 'url': 'https://prebid.cootlogix.com/api/sync/image/?gdpr=0&gdpr_consent=&us_privacy=', + 'url': 'https://sync.cootlogix.com/api/sync/image/?cid=testcid123&gdpr=0&gdpr_consent=&us_privacy=', 'type': 'image' }]); }) @@ -203,16 +565,16 @@ describe('VidazooBidAdapter', function () { }); it('should return empty array when there is no ad', function () { - const responses = adapter.interpretResponse({ price: 1, ad: '' }); + const responses = adapter.interpretResponse({price: 1, ad: ''}); expect(responses).to.be.empty; }); it('should return empty array when there is no price', function () { - const responses = adapter.interpretResponse({ price: null, ad: 'great ad' }); + const responses = adapter.interpretResponse({price: null, ad: 'great ad'}); expect(responses).to.be.empty; }); - it('should return an array of interpreted responses', function () { + it('should return an array of interpreted banner responses', function () { const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST); expect(responses).to.have.length(1); expect(responses[0]).to.deep.equal({ @@ -231,6 +593,54 @@ describe('VidazooBidAdapter', function () { }); }); + it('should get meta from response metaData', function () { + const serverResponse = utils.deepClone(SERVER_RESPONSE); + serverResponse.body.results[0].metaData = { + advertiserDomains: ['vidazoo.com'], + agencyName: 'Agency Name', + }; + const responses = adapter.interpretResponse(serverResponse, REQUEST); + expect(responses[0].meta).to.deep.equal({ + advertiserDomains: ['vidazoo.com'], + agencyName: 'Agency Name' + }); + }); + + it('should return an array of interpreted video responses', function () { + const responses = adapter.interpretResponse(VIDEO_SERVER_RESPONSE, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0]).to.deep.equal({ + requestId: '2d52001cabd527', + cpm: 2, + width: 545, + height: 307, + mediaType: 'video', + creativeId: '12610997325162499419', + currency: 'USD', + netRevenue: true, + ttl: 60, + vastXml: '', + meta: { + advertiserDomains: ['vidazoo.com'] + } + }); + }); + + it('should populate requestId from response in case of singleRequest true', function () { + config.setConfig({ + vidazoo: { + singleRequest: true, + chunkSize: 2 + } + }); + + const responses = adapter.interpretResponse(SERVER_RESPONSE, REQUEST); + expect(responses).to.have.length(1); + expect(responses[0].requestId).to.equal('2d52001cabd527-response'); + + config.resetConfig(); + }); + it('should take default TTL', function () { const serverResponse = utils.deepClone(SERVER_RESPONSE); delete serverResponse.body.results[0].exp; @@ -241,17 +651,20 @@ describe('VidazooBidAdapter', function () { }); describe('user id system', function () { - Object.keys(SUPPORTED_ID_SYSTEMS).forEach((idSystemProvider) => { + TEST_ID_SYSTEMS.forEach((idSystemProvider) => { const id = Date.now().toString(); const bid = utils.deepClone(BID); const userId = (function () { switch (idSystemProvider) { - case 'digitrustid': return { data: { id: id } }; - case 'lipb': return { lipbid: id }; - case 'parrableId': return { eid: id }; - case 'id5id': return { uid: id }; - default: return id; + case 'lipb': + return {lipbid: id}; + case 'parrableId': + return {eid: id}; + case 'id5id': + return {uid: id}; + default: + return id; } })(); @@ -268,18 +681,18 @@ describe('VidazooBidAdapter', function () { describe('alternate param names extractors', function () { it('should return undefined when param not supported', function () { - const cid = extractCID({ 'c_id': '1' }); - const pid = extractPID({ 'p_id': '1' }); - const subDomain = extractSubDomain({ 'sub_domain': 'prebid' }); + const cid = extractCID({'c_id': '1'}); + const pid = extractPID({'p_id': '1'}); + const subDomain = extractSubDomain({'sub_domain': 'prebid'}); expect(cid).to.be.undefined; expect(pid).to.be.undefined; expect(subDomain).to.be.undefined; }); it('should return value when param supported', function () { - const cid = extractCID({ 'cID': '1' }); - const pid = extractPID({ 'Pid': '2' }); - const subDomain = extractSubDomain({ 'subDOMAIN': 'prebid' }); + const cid = extractCID({'cID': '1'}); + const pid = extractPID({'Pid': '2'}); + const subDomain = extractSubDomain({'subDOMAIN': 'prebid'}); expect(cid).to.be.equal('1'); expect(pid).to.be.equal('2'); expect(subDomain).to.be.equal('prebid'); @@ -287,6 +700,16 @@ describe('VidazooBidAdapter', function () { }); describe('vidazoo session id', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + vidazoo: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); it('should get undefined vidazoo session id', function () { const sessionId = getVidazooSessionId(); expect(sessionId).to.be.empty; @@ -301,6 +724,16 @@ describe('VidazooBidAdapter', function () { }); describe('deal id', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + vidazoo: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); const key = 'myDealKey'; it('should get the next deal id', function () { @@ -320,9 +753,21 @@ describe('VidazooBidAdapter', function () { }); describe('unique deal id', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + vidazoo: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); const key = 'myKey'; let uniqueDealId; - uniqueDealId = getUniqueDealId(key); + beforeEach(() => { + uniqueDealId = getUniqueDealId(key, 0); + }) it('should get current unique deal id', function (done) { // waiting some time so `now` will become past @@ -333,13 +778,26 @@ describe('VidazooBidAdapter', function () { }, 200); }); - it('should get new unique deal id on expiration', function () { - const current = getUniqueDealId(key, 100); - expect(current).to.not.be.equal(uniqueDealId); + it('should get new unique deal id on expiration', function (done) { + setTimeout(() => { + const current = getUniqueDealId(key, 100); + expect(current).to.not.be.equal(uniqueDealId); + done(); + }, 200) }); }); describe('storage utils', function () { + before(function () { + $$PREBID_GLOBAL$$.bidderSettings = { + vidazoo: { + storageAllowed: true + } + }; + }); + after(function () { + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); it('should get value from storage with create param', function () { const now = Date.now(); const clock = useFakeTimers({ @@ -347,7 +805,7 @@ describe('VidazooBidAdapter', function () { now }); setStorageItem('myKey', 2020); - const { value, created } = getStorageItem('myKey'); + const {value, created} = getStorageItem('myKey'); expect(created).to.be.equal(now); expect(value).to.be.equal(2020); expect(typeof value).to.be.equal('number'); @@ -363,8 +821,8 @@ describe('VidazooBidAdapter', function () { }); it('should parse JSON value', function () { - const data = JSON.stringify({ event: 'send' }); - const { event } = tryParseJSON(data); + const data = JSON.stringify({event: 'send'}); + const {event} = tryParseJSON(data); expect(event).to.be.equal('send'); }); diff --git a/test/spec/modules/videoModule/adQueue_spec.js b/test/spec/modules/videoModule/adQueue_spec.js new file mode 100644 index 00000000000..4002e0b6dcc --- /dev/null +++ b/test/spec/modules/videoModule/adQueue_spec.js @@ -0,0 +1,172 @@ +import { expect } from 'chai'; +import { AdQueueCoordinator } from '../../../../modules/videoModule/adQueue.js'; +import { AD_BREAK_END, SETUP_COMPLETE } from '../../../../libraries/video/constants/events.js' + +const testId = 'testId'; +describe('Ad Queue Coordinator', function () { + const mockVideoCoreFactory = function () { + return { + onEvents: sinon.spy(), + offEvents: sinon.spy(), + setAdTagUrl: sinon.spy(), + } + }; + + const mockEventsFactory = function () { + return { + emit: sinon.spy() + }; + }; + + describe('Before Provider Setup Complete', function () { + it('should push ad to queue', function () { + const mockVideoCore = mockVideoCoreFactory(); + const mockEvents = mockEventsFactory(); + const coordinator = AdQueueCoordinator(mockVideoCore, mockEvents); + coordinator.registerProvider(testId); + coordinator.queueAd('testAdTag', testId, { param: {} }); + + expect(mockEvents.emit.calledOnce).to.be.true; + let emitArgs = mockEvents.emit.firstCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadQueued'); + expect(mockVideoCore.setAdTagUrl.called).to.be.false; + }); + }); + + describe('After Provider Setup Complete', function () { + it('should load from ad queue', function () { + const mockVideoCore = mockVideoCoreFactory(); + const mockEvents = mockEventsFactory(); + let setupComplete; + mockVideoCore.onEvents = function(events, callback, id) { + if (events[0] === SETUP_COMPLETE && id === testId) { + setupComplete = callback; + } + }; + const coordinator = AdQueueCoordinator(mockVideoCore, mockEvents); + coordinator.registerProvider(testId); + coordinator.queueAd('testAdTag', testId, { param: {} }); + + expect(mockEvents.emit.calledOnce).to.be.true; + let emitArgs = mockEvents.emit.firstCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadQueued'); + + setupComplete('', { divId: testId }); + expect(mockEvents.emit.calledTwice).to.be.true; + emitArgs = mockEvents.emit.secondCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadAttempt'); + expect(mockVideoCore.setAdTagUrl.calledOnce).to.be.true; + }); + + it('should load ads without queueing', function () { + const mockVideoCore = mockVideoCoreFactory(); + const mockEvents = mockEventsFactory(); + let setupComplete; + mockVideoCore.onEvents = function(events, callback, id) { + if (events[0] === SETUP_COMPLETE && id === testId) { + setupComplete = callback; + } + }; + const coordinator = AdQueueCoordinator(mockVideoCore, mockEvents); + coordinator.registerProvider(testId); + + setupComplete('', { divId: testId }); + + coordinator.queueAd('testAdTag', testId, { param: {} }); + expect(mockEvents.emit.calledOnce).to.be.true; + let emitArgs = mockEvents.emit.firstCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadAttempt'); + expect(mockVideoCore.setAdTagUrl.calledOnce).to.be.true; + }); + }); + + describe('On Ad Break End', function () { + it('should load from queue', function () { + const mockVideoCore = mockVideoCoreFactory(); + const mockEvents = mockEventsFactory(); + let setupComplete; + let adBreakEnd; + + mockVideoCore.onEvents = function(events, callback, id) { + if (events[0] === SETUP_COMPLETE && id === testId) { + setupComplete = callback; + } + + if (events[0] === AD_BREAK_END && id === testId) { + adBreakEnd = callback; + } + }; + + const coordinator = AdQueueCoordinator(mockVideoCore, mockEvents); + coordinator.registerProvider(testId); + coordinator.queueAd('testAdTag', testId); + coordinator.queueAd('testAdTag2', testId); + coordinator.queueAd('testAdTag3', testId); + + mockEvents.emit.resetHistory(); + + setupComplete('', { divId: testId }); + + expect(mockEvents.emit.calledOnce).to.be.true; + let emitArgs = mockEvents.emit.firstCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadAttempt'); + expect(mockVideoCore.setAdTagUrl.calledOnce).to.be.true; + let setAdTagArgs = mockVideoCore.setAdTagUrl.firstCall.args; + expect(setAdTagArgs[0]).to.be.equal('testAdTag'); + + adBreakEnd('', { divId: testId }); + + expect(mockEvents.emit.calledTwice).to.be.true; + emitArgs = mockEvents.emit.secondCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadAttempt'); + expect(mockVideoCore.setAdTagUrl.calledTwice).to.be.true; + setAdTagArgs = mockVideoCore.setAdTagUrl.secondCall.args; + expect(setAdTagArgs[0]).to.be.equal('testAdTag2'); + + adBreakEnd('', { divId: testId }); + + expect(mockEvents.emit.calledThrice).to.be.true; + emitArgs = mockEvents.emit.thirdCall.args; + expect(emitArgs[0]).to.be.equal('videoAuctionAdLoadAttempt'); + expect(mockVideoCore.setAdTagUrl.calledThrice).to.be.true; + setAdTagArgs = mockVideoCore.setAdTagUrl.thirdCall.args; + expect(setAdTagArgs[0]).to.be.equal('testAdTag3'); + + adBreakEnd('', { divId: testId }); + + expect(mockEvents.emit.calledThrice).to.be.true; + expect(mockVideoCore.setAdTagUrl.calledThrice).to.be.true; + }); + + it('should stop responding to AdBreakEnd when queue is empty', function () { + const mockVideoCore = mockVideoCoreFactory(); + let setupComplete; + let adBreakEnd; + + mockVideoCore.onEvents = function(events, callback, id) { + if (events[0] === SETUP_COMPLETE && id === testId) { + setupComplete = callback; + } + + if (events[0] === AD_BREAK_END && id === testId) { + adBreakEnd = callback; + } + }; + + const coordinator = AdQueueCoordinator(mockVideoCore, mockEventsFactory()); + coordinator.registerProvider(testId); + coordinator.queueAd('testAdTag', testId); + coordinator.queueAd('testAdTag2', testId); + coordinator.queueAd('testAdTag3', testId); + + setupComplete('', { divId: testId }); + adBreakEnd('', { divId: testId }); + adBreakEnd('', { divId: testId }); + expect(mockVideoCore.setAdTagUrl.calledThrice).to.be.true; + adBreakEnd('', { divId: testId }); + expect(mockVideoCore.setAdTagUrl.calledThrice).to.be.true; + adBreakEnd('', { divId: testId }); + expect(mockVideoCore.setAdTagUrl.calledThrice).to.be.true; + }); + }); +}); diff --git a/test/spec/modules/videoModule/coreVideo_spec.js b/test/spec/modules/videoModule/coreVideo_spec.js new file mode 100644 index 00000000000..17c6e3811e0 --- /dev/null +++ b/test/spec/modules/videoModule/coreVideo_spec.js @@ -0,0 +1,98 @@ +import { expect } from 'chai'; +import { VideoCore } from 'modules/videoModule/coreVideo.js'; + +describe('Video Core', function () { + const mockSubmodule = { + getOrtbVideo: sinon.spy(), + getOrtbContent: sinon.spy(), + setAdTagUrl: sinon.spy(), + onEvent: sinon.spy(), + offEvent: sinon.spy(), + }; + + const otherSubmodule = { + getOrtbVideo: () => {}, + getOrtbContent: () => {}, + setAdTagUrl: () => {}, + onEvent: () => {}, + offEvent: () => {}, + }; + + const testId = 'test_id'; + const testVendorCode = 0; + const otherId = 'other_id'; + const otherVendorCode = 1; + + const parentModuleMock = { + registerSubmodule: sinon.spy(), + getSubmodule: sinon.spy(id => { + if (id === testId) { + return mockSubmodule; + } else if (id === otherId) { + return otherSubmodule; + } + }) + }; + + const videoCore = VideoCore(parentModuleMock); + + videoCore.registerProvider({ + vendorCode: testVendorCode, + divId: testId + }); + + videoCore.registerProvider({ + vendorCode: otherVendorCode, + divId: otherId + }); + + describe('registerProvider', function () { + it('should delegate the registration to the Parent Module', function () { + expect(parentModuleMock.registerSubmodule.calledTwice).to.be.true; + expect(parentModuleMock.registerSubmodule.args[0][0]).to.be.equal(testId); + expect(parentModuleMock.registerSubmodule.args[1][0]).to.be.equal(otherId); + expect(parentModuleMock.registerSubmodule.args[0][1]).to.be.equal(testVendorCode); + expect(parentModuleMock.registerSubmodule.args[1][1]).to.be.equal(otherVendorCode); + }); + }); + + describe('getOrtbVideo', function () { + it('delegates to the submodule of the right divId', function () { + videoCore.getOrtbVideo(testId); + videoCore.getOrtbVideo(otherId); + expect(mockSubmodule.getOrtbVideo.calledOnce).to.be.true; + }); + }); + + describe('getOrtbContent', function () { + it('delegates to the submodule of the right divId', function () { + videoCore.getOrtbContent(testId); + videoCore.getOrtbContent(otherId); + expect(mockSubmodule.getOrtbContent.calledOnce).to.be.true; + }); + }); + + describe('setAdTagUrl', function () { + it('delegates to the submodule of the right divId', function () { + videoCore.setAdTagUrl('', testId); + videoCore.setAdTagUrl('', otherId); + expect(mockSubmodule.setAdTagUrl.calledOnce).to.be.true; + }); + }); + + describe('onEvents', function () { + it('delegates to the submodule of the right divId', function () { + videoCore.onEvents(['event'], () => {}, testId); + videoCore.onEvents(['event'], () => {}, otherId); + expect(mockSubmodule.onEvent.calledOnce).to.be.true; + }); + }); + + describe('offEvents', function () { + it('delegates to the submodule of the right divId', function () { + videoCore.offEvents(['event'], () => {}, testId); + videoCore.offEvents(['event'], () => {}, otherId); + expect(mockSubmodule.offEvent.calledOnce).to.be.true; + }); + }); +}); diff --git a/test/spec/modules/videoModule/pbVideo_spec.js b/test/spec/modules/videoModule/pbVideo_spec.js new file mode 100644 index 00000000000..2e26737da40 --- /dev/null +++ b/test/spec/modules/videoModule/pbVideo_spec.js @@ -0,0 +1,405 @@ +import { expect } from 'chai'; +import { PbVideo } from 'modules/videoModule'; +import CONSTANTS from 'src/constants.json'; + +let ortbVideoMock; +let ortbContentMock; +let videoCoreMock; +let getConfigMock; +let requestBidsMock; +let pbGlobalMock; +let pbEventsMock; +let videoEventsMock; +let gamSubmoduleMock; +let gamSubmoduleFactoryMock; +let videoImpressionVerifierFactoryMock; +let videoImpressionVerifierMock; +let adQueueCoordinatorMock; +let adQueueCoordinatorFactoryMock; + +function resetTestVars() { + ortbVideoMock = {}; + ortbContentMock = {}; + videoCoreMock = { + registerProvider: sinon.spy(), + initProvider: sinon.spy(), + onEvents: sinon.spy(), + getOrtbVideo: () => ortbVideoMock, + getOrtbContent: () => ortbContentMock, + setAdTagUrl: sinon.spy() + }; + getConfigMock = () => {}; + requestBidsMock = { + before: sinon.spy() + }; + pbGlobalMock = { + requestBids: requestBidsMock, + getHighestCpmBids: sinon.spy(), + getBidResponsesForAdUnitCode: sinon.spy(), + setConfig: sinon.spy(), + getConfig: () => ({}), + markWinningBidAsUsed: sinon.spy() + }; + pbEventsMock = { + emit: sinon.spy(), + on: sinon.spy() + }; + videoEventsMock = []; + gamSubmoduleMock = { + getAdTagUrl: sinon.spy() + }; + + gamSubmoduleFactoryMock = sinon.spy(() => gamSubmoduleMock); + + videoImpressionVerifierMock = { + trackBid: sinon.spy(), + getBidIdentifiers: sinon.spy() + }; + + videoImpressionVerifierFactoryMock = () => videoImpressionVerifierMock; + + adQueueCoordinatorMock = { + registerProvider: sinon.spy(), + queueAd: sinon.spy() + }; + + adQueueCoordinatorFactoryMock = () => adQueueCoordinatorMock; +} + +let pbVideoFactory = (videoCore, getConfig, pbGlobal, pbEvents, videoEvents, gamSubmoduleFactory, videoImpressionVerifierFactory, adQueueCoordinator) => { + const pbVideo = PbVideo( + videoCore || videoCoreMock, + getConfig || getConfigMock, + pbGlobal || pbGlobalMock, + pbEvents || pbEventsMock, + videoEvents || videoEventsMock, + gamSubmoduleFactory || gamSubmoduleFactoryMock, + videoImpressionVerifierFactory || videoImpressionVerifierFactoryMock, + adQueueCoordinator || adQueueCoordinatorMock + ); + pbVideo.init(); + return pbVideo; +} + +describe('Prebid Video', function () { + beforeEach(() => resetTestVars()); + + describe('Setting video to config', function () { + let providers = [{ divId: 'div1' }, { divId: 'div2' }]; + let getConfigCallback; + let getConfig = (propertyName, callback) => { + if (propertyName === 'video') { + getConfigCallback = callback; + } + }; + + beforeEach(() => { + pbVideoFactory(null, getConfig); + getConfigCallback({ video: { providers } }); + }); + + it('Should register providers', function () { + expect(videoCoreMock.registerProvider.calledTwice).to.be.true; + }); + + it('Should register events', function () { + expect(videoCoreMock.onEvents.calledTwice).to.be.true; + const onEventsSpy = videoCoreMock.onEvents; + expect(onEventsSpy.getCall(0).args[2]).to.be.equal('div1'); + expect(onEventsSpy.getCall(1).args[2]).to.be.equal('div2'); + }); + + describe('Event triggering', function () { + it('Should emit events off of Prebid\'s Events', function () { + let eventHandler; + const videoCore = Object.assign({}, videoCoreMock, { + onEvents: (events, eventHandler_) => eventHandler = eventHandler_ + }); + pbVideoFactory(videoCore, getConfig); + getConfigCallback({ video: { providers } }); + const expectedType = 'test_event'; + const expectedPayload = {'test': 'data'}; + eventHandler(expectedType, expectedPayload); + expect(pbEventsMock.emit.calledOnce).to.be.true; + expect(pbEventsMock.emit.getCall(0).args[0]).to.be.equal('video' + expectedType.replace(/^./, expectedType[0].toUpperCase())); + expect(pbEventsMock.emit.getCall(0).args[1]).to.be.equal(expectedPayload); + }); + }); + + describe('Ad Server configuration', function() { + const test_vendor_code = 5; + const test_params = { test: 'params' }; + providers[0].adServer = { vendorCode: test_vendor_code, params: test_params }; + + it('should instantiate the GAM Submodule', function () { + expect(gamSubmoduleFactoryMock.calledOnce).to.be.true; + }); + }); + }); + + describe('Ad unit Enrichment', function () { + it('registers before:bidRequest hook', function () { + pbVideoFactory(); + expect(requestBidsMock.before.calledOnce).to.be.true; + }); + + it('requests oRtb params and writes them to ad unit and config', function() { + const getOrtbVideoSpy = videoCoreMock.getOrtbVideo = sinon.spy(() => ({ + test: 'videoTestValue' + })); + const getOrtbContentSpy = videoCoreMock.getOrtbContent = sinon.spy(() => ({ + test: 'contentTestValue' + })); + + let beforeBidRequestCallback; + const requestBids = { + before: callback_ => beforeBidRequestCallback = callback_ + }; + + pbVideoFactory(null, null, Object.assign({}, pbGlobalMock, { requestBids })); + expect(beforeBidRequestCallback).to.not.be.undefined; + const nextFn = sinon.spy(); + const adUnits = [{ + code: 'ad1', + mediaTypes: { + video: {} + }, + video: { divId: 'divId' } + }]; + beforeBidRequestCallback(nextFn, { adUnits }); + expect(getOrtbVideoSpy.calledOnce).to.be.true; + expect(getOrtbContentSpy.calledOnce).to.be.true; + const adUnit = adUnits[0]; + expect(adUnit.mediaTypes.video).to.have.property('test', 'videoTestValue'); + expect(nextFn.calledOnce).to.be.true; + expect(nextFn.getCall(0).args[0].ortb2).to.be.deep.equal({ site: { content: { test: 'contentTestValue' } } }); + }); + + it('allows publishers to override video param', function () { + const getOrtbVideoSpy = videoCoreMock.getOrtbVideo = sinon.spy(() => ({ + test: 'videoTestValue', + test2: 'videoModuleValue' + })); + + let beforeBidRequestCallback; + const requestBids = { + before: callback_ => beforeBidRequestCallback = callback_ + }; + + pbVideoFactory(null, null, Object.assign({}, pbGlobalMock, { requestBids })); + expect(beforeBidRequestCallback).to.not.be.undefined; + const nextFn = sinon.spy(); + const adUnits = [{ + code: 'ad1', + mediaTypes: { + video: { + test2: 'publisherValue' + } + }, + video: { divId: 'divId' } + }]; + beforeBidRequestCallback(nextFn, { adUnits }); + expect(getOrtbVideoSpy.calledOnce).to.be.true; + const adUnit = adUnits[0]; + expect(adUnit.mediaTypes.video).to.have.property('test', 'videoTestValue'); + expect(adUnit.mediaTypes.video).to.have.property('test2', 'publisherValue'); + expect(nextFn.calledOnce).to.be.true; + }); + }); + + describe('Ad tag injection', function () { + let auctionEndCallback; + let providers = [{ divId: 'div1', adServer: {} }, { divId: 'div2' }]; + let getConfig = (propertyName, callbackFn) => { + if (propertyName === 'video') { + if (callbackFn) { + callbackFn({ video: { providers } }); + } else { + return { providers }; + } + } + }; + + const pbEvents = { + emit: () => {}, + on: (event, callback) => { + if (event === CONSTANTS.EVENTS.AUCTION_END) { + auctionEndCallback = callback + } + }, + off: () => {} + }; + + const expectedVendorCode = 5; + const expectedAdTag = 'test_tag'; + const expectedAdUnitCode = 'expectedAdUnitcode'; + const expectedDivId = 'expectedDivId'; + const expectedAdUnit = { + code: expectedAdUnitCode, + video: { + divId: expectedDivId, + adServer: { + vendorCode: expectedVendorCode, + baseAdTagUrl: expectedAdTag + } + } + }; + const auctionResults = { adUnits: [ expectedAdUnit, {} ] }; + + beforeEach(() => { + gamSubmoduleMock.getAdTagUrl.resetHistory(); + videoCoreMock.setAdTagUrl.resetHistory(); + adQueueCoordinatorMock.queueAd.resetHistory(); + }); + + let beforeBidRequestCallback; + const requestBids = { + before: callback_ => beforeBidRequestCallback = callback_ + }; + + it('should request ad tag url from adServer when configured to use adServer', function () { + const expectedVastUrl = 'expectedVastUrl'; + const expectedVastXml = 'expectedVastXml'; + const pbGlobal = Object.assign({}, pbGlobalMock, { + requestBids, + getHighestCpmBids: () => [{ + vastUrl: expectedVastUrl, + vastXml: expectedVastXml + }, {}, {}, {}] + }); + pbVideoFactory(null, getConfig, pbGlobal, pbEvents); + + beforeBidRequestCallback(() => {}, {}); + auctionEndCallback(auctionResults); + expect(gamSubmoduleMock.getAdTagUrl.calledOnce).to.be.true; + expect(gamSubmoduleMock.getAdTagUrl.getCall(0).args[0]).is.equal(expectedAdUnit); + expect(gamSubmoduleMock.getAdTagUrl.getCall(0).args[1]).is.equal(expectedAdTag); + }); + + it('should load ad tag when ad server returns ad tag', function () { + const expectedAdTag = 'resulting ad tag'; + const gamSubmoduleFactory = () => ({ + getAdTagUrl: () => expectedAdTag + }); + const expectedVastUrl = 'expectedVastUrl'; + const expectedVastXml = 'expectedVastXml'; + const pbGlobal = Object.assign({}, pbGlobalMock, { + requestBids, + getHighestCpmBids: () => [{ + vastUrl: expectedVastUrl, + vastXml: expectedVastXml + }, {}, {}, {}] + }); + pbVideoFactory(null, getConfig, pbGlobal, pbEvents, null, gamSubmoduleFactory); + beforeBidRequestCallback(() => {}, {}); + auctionEndCallback(auctionResults); + expect(adQueueCoordinatorMock.queueAd.calledOnce).to.be.true; + expect(adQueueCoordinatorMock.queueAd.args[0][0]).to.be.equal(expectedAdTag); + expect(adQueueCoordinatorMock.queueAd.args[0][1]).to.be.equal(expectedDivId); + expect(adQueueCoordinatorMock.queueAd.args[0][2]).to.have.property('adUnitCode', expectedAdUnitCode); + }); + + it('should load ad tag from highest bid when ad server is not configured', function () { + const expectedVastUrl = 'expectedVastUrl'; + const expectedVastXml = 'expectedVastXml'; + const pbGlobal = Object.assign({}, pbGlobalMock, { + requestBids, + getHighestCpmBids: () => [{ + vastUrl: expectedVastUrl, + vastXml: expectedVastXml + }, {}, {}, {}] + }); + const expectedAdUnit = { + code: expectedAdUnitCode, + video: { divId: expectedDivId } + }; + const auctionResults = { adUnits: [ expectedAdUnit, {} ] }; + + pbVideoFactory(null, () => ({ providers: [] }), pbGlobal, pbEvents); + beforeBidRequestCallback(() => {}, {}); + auctionEndCallback(auctionResults); + expect(adQueueCoordinatorMock.queueAd.calledOnce).to.be.true; + expect(adQueueCoordinatorMock.queueAd.args[0][0]).to.be.equal(expectedVastUrl); + expect(adQueueCoordinatorMock.queueAd.args[0][1]).to.be.equal(expectedDivId); + expect(adQueueCoordinatorMock.queueAd.args[0][2]).to.have.property('adUnitCode', expectedAdUnitCode); + expect(adQueueCoordinatorMock.queueAd.args[0][2]).to.have.property('adXml', expectedVastXml); + }); + }); + + describe('Ad tracking', function () { + const expectedAdEventPayload = { adEventPayloadMarker: 'marker' }; + const expectedBid = { bidMarker: 'marker' }; + let bidAdjustmentCb; + let adImpressionCb; + let adErrorCb; + + const pbEvents = { + on: (event, callback) => { + if (event === CONSTANTS.EVENTS.BID_ADJUSTMENT) { + bidAdjustmentCb = callback; + } else if (event === 'videoAdImpression') { + adImpressionCb = callback; + } else if (event === 'videoAdError') { + adErrorCb = callback; + } + }, + emit: sinon.spy() + }; + + it('should ask Impression Verifier to track bid on Bid Adjustment', function () { + pbVideoFactory(null, null, null, pbEvents); + bidAdjustmentCb(); + expect(videoImpressionVerifierMock.trackBid.calledOnce).to.be.true; + }); + + it('should trigger video bid impression when the bid matched', function () { + pbEvents.emit.resetHistory(); + const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) }); + const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({}) }); + pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier); + adImpressionCb(expectedAdEventPayload); + + expect(pbEvents.emit.calledOnce).to.be.true; + expect(pbEvents.emit.getCall(0).args[0]).to.be.equal('videoBidImpression'); + const payload = pbEvents.emit.getCall(0).args[1]; + expect(payload.bid).to.be.equal(expectedBid); + expect(payload.adEvent).to.be.equal(expectedAdEventPayload); + expect(pbGlobal.markWinningBidAsUsed.calledOnce).to.be.true; + }); + + it('should trigger video bid error when the bid matched', function () { + pbEvents.emit.resetHistory(); + const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) }); + const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({}) }); + pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier); + adErrorCb(expectedAdEventPayload); + + expect(pbEvents.emit.calledOnce).to.be.true; + expect(pbEvents.emit.getCall(0).args[0]).to.be.equal('videoBidError'); + const payload = pbEvents.emit.getCall(0).args[1]; + expect(payload.bid).to.be.equal(expectedBid); + expect(payload.adEvent).to.be.equal(expectedAdEventPayload); + expect(pbGlobal.markWinningBidAsUsed.calledOnce).to.be.true; + }); + + it('should not trigger a bid impression when the bid did not match', function () { + pbEvents.emit.resetHistory(); + const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) }); + const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({ auctionId: 'id' }) }); + pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier); + adImpressionCb(expectedAdEventPayload); + + expect(pbEvents.emit.called).to.be.false; + }); + + it('should not trigger a bid error when the bid did not match', function () { + pbEvents.emit.resetHistory(); + const pbGlobal = Object.assign({}, pbGlobalMock, { getBidResponsesForAdUnitCode: () => ({ bids: [expectedBid] }) }); + const videoImpressionVerifier = Object.assign({}, videoImpressionVerifierMock, { getBidIdentifiers: () => ({ auctionId: 'id' }) }); + pbVideoFactory(null, null, pbGlobal, pbEvents, null, null, () => videoImpressionVerifier); + adErrorCb(expectedAdEventPayload); + + expect(pbEvents.emit.called).to.be.false; + }); + }); +}); diff --git a/test/spec/modules/videoModule/shared/helpers_spec.js b/test/spec/modules/videoModule/shared/helpers_spec.js new file mode 100644 index 00000000000..e59988172e6 --- /dev/null +++ b/test/spec/modules/videoModule/shared/helpers_spec.js @@ -0,0 +1,22 @@ +import { getExternalVideoEventName, getExternalVideoEventPayload } from 'libraries/video/shared/helpers.js'; +import { expect } from 'chai'; + +describe('Helpers', function () { + describe('getExternalVideoEventName', function () { + it('should append video prefix and stay camelcase', function () { + expect(getExternalVideoEventName('eventName')).to.equal('videoEventName'); + expect(getExternalVideoEventName(null)).to.equal(''); + }); + }); + + describe('getExternalVideoEventPayload', function () { + it('should include type in payload when absent', function () { + const testType = 'testType'; + const payloadWithType = { datum: 'datum', type: 'existingType' }; + expect(getExternalVideoEventPayload(testType, payloadWithType).type).to.equal('existingType'); + + const payloadWithoutType = { datum: 'datum' }; + expect(getExternalVideoEventPayload(testType, payloadWithoutType).type).to.equal(testType); + }); + }); +}); diff --git a/test/spec/modules/videoModule/shared/parentModule_spec.js b/test/spec/modules/videoModule/shared/parentModule_spec.js new file mode 100644 index 00000000000..e3e4cfb7f3f --- /dev/null +++ b/test/spec/modules/videoModule/shared/parentModule_spec.js @@ -0,0 +1,72 @@ +import { SubmoduleBuilder, ParentModule } from 'libraries/video/shared/parentModule.js'; +import { expect } from 'chai'; + +describe('Parent Module', function() { + const idForMock = 0; + const vendorCodeForMock = 'a'; + const unrecognizedId = 999; + const unrecognizedVendorCode = 'zzz'; + const mockSubmodule = { test: 'test' }; + const mockSubmoduleBuilder = { + build: vendorCode => { + if (vendorCode === vendorCodeForMock) { + return mockSubmodule; + } else { + throw new Error('flawed'); + } + } + }; + const parentModule = ParentModule(mockSubmoduleBuilder); + + describe('Register Submodule', function () { + it('should throw when the builder fails to build', function () { + expect(() => parentModule.registerSubmodule(unrecognizedId, unrecognizedVendorCode)).to.throw('flawed'); + }); + }); + + describe('Get Submodule', function () { + it('should return registered submodules', function () { + parentModule.registerSubmodule(idForMock, vendorCodeForMock); + const submodule = parentModule.getSubmodule(idForMock); + expect(submodule).to.be.equal(mockSubmodule); + }); + + it('should return undefined when submodule is not registered', function () { + const submodule = parentModule.getSubmodule(unrecognizedId); + expect(submodule).to.be.undefined; + }); + }) +}); + +describe('Submodule Builder', function () { + const vendorCode1 = 1; + const vendorCode2 = 2; + const submodule1 = {}; + const initSpy = sinon.spy(); + const submodule2 = { init: initSpy }; + const submoduleFactory1 = () => submodule1; + const submoduleFactory2 = () => submodule2; + const submoduleFactory1Spy = sinon.spy(submoduleFactory1); + + const vendorDirectory = {}; + vendorDirectory[vendorCode1] = submoduleFactory1Spy; + vendorDirectory[vendorCode2] = submoduleFactory2; + + const submoduleBuilder = SubmoduleBuilder(vendorDirectory); + + it('should call submodule factory when vendor code is supported', function () { + const submodule = submoduleBuilder.build(vendorCode1); + expect(submoduleFactory1Spy.calledOnce).to.be.true; + expect(submodule).to.be.equal(submodule1); + }); + + it('should instantiate the submodule, when supported', function () { + const submodule = submoduleBuilder.build(vendorCode2); + expect(submodule).to.be.equal(submodule2); + }); + + it('should throw when vendor code is not recognized', function () { + const unrecognizedVendorCode = 999; + expect(() => submoduleBuilder.build(unrecognizedVendorCode)).to.throw('Unrecognized submodule vendor code: ' + unrecognizedVendorCode); + }); +}); diff --git a/test/spec/modules/videoModule/shared/state_spec.js b/test/spec/modules/videoModule/shared/state_spec.js new file mode 100644 index 00000000000..94f3cb73411 --- /dev/null +++ b/test/spec/modules/videoModule/shared/state_spec.js @@ -0,0 +1,26 @@ +import stateFactory from 'libraries/video/shared/state.js'; +import { expect } from 'chai'; + +describe('State', function () { + let state = stateFactory(); + beforeEach(() => { + state.clearState(); + }); + + it('should update state', function () { + state.updateState({ 'test': 'a' }); + expect(state.getState()).to.have.property('test', 'a'); + state.updateState({ 'test': 'b' }); + expect(state.getState()).to.have.property('test', 'b'); + state.updateState({ 'test_2': 'c' }); + expect(state.getState()).to.have.property('test', 'b'); + expect(state.getState()).to.have.property('test_2', 'c'); + }); + + it('should clear state', function () { + state.updateState({ 'test': 'a' }); + state.clearState(); + expect(state.getState()).to.not.have.property('test', 'a'); + expect(state.getState()).to.be.empty; + }); +}); diff --git a/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js b/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js new file mode 100644 index 00000000000..2c67b898a53 --- /dev/null +++ b/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js @@ -0,0 +1,103 @@ +import { buildVastWrapper, getVastNode, getAdNode, getWrapperNode, getAdSystemNode, + getAdTagUriNode, getErrorNode, getImpressionNode } from 'libraries/video/shared/vastXmlBuilder.js'; +import { expect } from 'chai'; + +describe('buildVastWrapper', function () { + it('should include impression and error nodes when requested', function () { + const vastXml = buildVastWrapper( + 'adId123', + 'http://wwww.testUrl.com/redirectUrl.xml', + 'http://wwww.testUrl.com/impression.jpg', + 'impressionId123', + 'http://wwww.testUrl.com/error.jpg' + ); + expect(vastXml).to.be.equal(`Prebid org`); + }); + + it('should omit error nodes when excluded', function () { + const vastXml = buildVastWrapper( + 'adId123', + 'http://wwww.testUrl.com/redirectUrl.xml', + 'http://wwww.testUrl.com/impression.jpg', + 'impressionId123', + ); + expect(vastXml).to.be.equal(`Prebid org`); + }); + + it('should omit impression nodes when excluded', function () { + const vastXml = buildVastWrapper( + 'adId123', + 'http://wwww.testUrl.com/redirectUrl.xml', + ); + expect(vastXml).to.be.equal(`Prebid org`); + }); +}); + +describe('getVastNode', function () { + it('should return well formed Vast node', function () { + const vastNode = getVastNode('body', '4.0'); + expect(vastNode).to.be.equal('body'); + }); + + it('should omit version when missing', function() { + const vastNode = getVastNode('body'); + expect(vastNode).to.be.equal('body'); + }); +}); + +describe('getAdNode', function () { + it('should return well formed Ad node', function () { + const adNode = getAdNode('body', 'adId123'); + expect(adNode).to.be.equal('body'); + }); + + it('should omit id when missing', function() { + const adNode = getAdNode('body'); + expect(adNode).to.be.equal('body'); + }); +}); + +describe('getWrapperNode', function () { + it('should return well formed Wrapper node', function () { + const wrapperNode = getWrapperNode('body'); + expect(wrapperNode).to.be.equal('body'); + }); +}); + +describe('getAdSystemNode', function () { + it('should return well formed AdSystem node', function () { + const adSystemNode = getAdSystemNode('testSysName', '5.0'); + expect(adSystemNode).to.be.equal('testSysName'); + }); + + it('should omit version when missing', function() { + const adSystemNode = getAdSystemNode('testSysName'); + expect(adSystemNode).to.be.equal('testSysName'); + }); +}); + +describe('getAdTagUriNode', function () { + it('should return well formed ad tag URI node', function () { + const adTagNode = getAdTagUriNode('http://wwww.testUrl.com/ad.xml'); + expect(adTagNode).to.be.equal(''); + }); +}); + +describe('getImpressionNode', function () { + it('should return well formed Impression node', function () { + const impressionNode = getImpressionNode('http://wwww.testUrl.com/adImpression.jpg', 'impresionId123'); + expect(impressionNode).to.be.equal(''); + }); + + it('should omit id when missing', function() { + const impressionNode = getImpressionNode('http://wwww.testUrl.com/adImpression.jpg'); + expect(impressionNode).to.be.equal(''); + }); +}); + +describe('getErrorNode', function () { + it('should return well formed Error node', function () { + const errorNode = getErrorNode('http://wwww.testUrl.com/adError.jpg'); + expect(errorNode).to.be.equal(''); + }); +}); diff --git a/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js b/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js new file mode 100644 index 00000000000..2304b2f2833 --- /dev/null +++ b/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js @@ -0,0 +1,209 @@ +import { vastXmlEditorFactory } from 'libraries/video/shared/vastXmlEditor.js'; +import { expect } from 'chai'; + +describe('Vast XML Editor', function () { + const adWrapperXml = ` + + + + Prebid org + + + + +`; + + const inlineXml = ` + + + + Prebid org + Random Title + + + +`; + + const inLineWithWrapper = ` + + + + Prebid org + + + + + + Prebid org + Random Title + + + +`; + + const vastXmlEditor = vastXmlEditorFactory(); + const expectedImpressionUrl = 'https://test.impression.com/ping.gif'; + const expectedImpressionId = 'test-impression-id'; + const expectedErrorUrl = 'https://test.error.com/ping.gif'; + + it('should add Impression Nodes to the Ad Wrapper', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(adWrapperXml, null, expectedImpressionUrl, expectedImpressionId); + const expectedXml = ` + + + Prebid org + + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Impression Nodes to the InLine', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inlineXml, null, expectedImpressionUrl, expectedImpressionId); + const expectedXml = ` + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Impression Nodes to the Ad Wrapper and Inline', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inLineWithWrapper, null, expectedImpressionUrl, expectedImpressionId); + const expectedXml = ` + + + Prebid org + + + + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Error Nodes to the Ad Wrapper', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(adWrapperXml, null, null, null, expectedErrorUrl); + const expectedXml = ` + + + Prebid org + + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Error Nodes to the InLine', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inlineXml, null, null, null, expectedErrorUrl); + const expectedXml = ` + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Error Nodes to the Ad Wrapper and Inline', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inLineWithWrapper, null, null, null, expectedErrorUrl); + const expectedXml = ` + + + Prebid org + + + + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Impression Nodes and Error Nodes to the Ad Wrapper', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(adWrapperXml, null, expectedImpressionUrl, expectedImpressionId, expectedErrorUrl); + const expectedXml = ` + + + Prebid org + + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Impression Nodes and Error Nodes to the InLine', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inlineXml, null, expectedImpressionUrl, expectedImpressionId, expectedErrorUrl); + const expectedXml = ` + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should add Impression Nodes and Error Nodes to the Ad Wrapper and Inline', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inLineWithWrapper, null, expectedImpressionUrl, expectedImpressionId, expectedErrorUrl); + const expectedXml = ` + + + Prebid org + + + + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should override the ad id in inline', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(inlineXml, 'adIdOverride'); + const expectedXml = ` + + + Prebid org + Random Title + + +`; + expect(vastXml).to.equal(expectedXml); + }); + + it('should override the ad id in the Ad Wrapper', function () { + const vastXml = vastXmlEditor.getVastXmlWithTracking(adWrapperXml, 'adIdOverride'); + const expectedXml = ` + + + Prebid org + + + +`; + expect(vastXml).to.equal(expectedXml); + }); +}); diff --git a/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js b/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js new file mode 100644 index 00000000000..3cede6c8eda --- /dev/null +++ b/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js @@ -0,0 +1,894 @@ +import { + JWPlayerProvider, + adStateFactory, + timeStateFactory, + callbackStorageFactory, + utils +} from 'modules/jwplayerVideoProvider'; + +import { + PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE +} from 'libraries/video/constants/ortb.js'; + +import { + SETUP_COMPLETE, SETUP_FAILED, PLAY, AD_IMPRESSION, videoEvents +} from 'libraries/video/constants/events.js'; + +import { PLAYBACK_MODE } from 'libraries/video/constants/constants.js'; + +function getPlayerMock() { + return makePlayerFactoryMock({ + getState: function () {}, + setup: function () { return this; }, + getViewable: function () {}, + getPercentViewable: function () {}, + getMute: function () {}, + getVolume: function () {}, + getConfig: function () {}, + getHeight: function () {}, + getWidth: function () {}, + getFullscreen: function () {}, + getPlaylistItem: function () {}, + playAd: function () {}, + on: function () { return this; }, + off: function () { return this; }, + remove: function () {}, + getAudioTracks: function () {}, + getCurrentAudioTrack: function () {}, + getPlugin: function () {}, + getFloating: function () {} + })(); +} + +function makePlayerFactoryMock(playerMock_) { + const playerFactory = function () { + return playerMock_; + } + playerFactory.version = '8.21.0'; + return playerFactory; +} + +function getUtilsMock() { + return { + getJwConfig: function () {}, + getSupportedMediaTypes: function () {}, + getStartDelay: function () {}, + getPlacement: function () {}, + getPlaybackMethod: function () {}, + isOmidSupported: function () {}, + getSkipParams: function () {}, + getJwEvent: event => event, + getIsoLanguageCode: function () {}, + getSegments: function () {}, + getContentDatum: function () {} + }; +} + +const sharedUtils = { videoEvents }; + +function addDiv() { + const div = document.createElement('div'); + div.setAttribute('id', 'test'); + document.body.appendChild(div); +} + +function removeDiv() { + const div = document.getElementById('test'); + if (div) { + div.remove(); + } +} + +describe('JWPlayerProvider', function () { + beforeEach(() => { + addDiv(); + }); + + afterEach(() => { + removeDiv(); + }); + + describe('init', function () { + let config; + let adState; + let timeState; + let callbackStorage; + let utilsMock; + + beforeEach(() => { + config = { divId: 'test' }; + adState = adStateFactory(); + timeState = timeStateFactory(); + callbackStorage = callbackStorageFactory(); + utilsMock = getUtilsMock(); + }); + + it('should trigger failure when jwplayer is missing', function () { + const provider = JWPlayerProvider(config, null, adState, timeState, callbackStorage, utilsMock, sharedUtils); + const setupFailed = sinon.spy(); + provider.onEvent(SETUP_FAILED, setupFailed, {}); + provider.init(); + expect(setupFailed.calledOnce).to.be.true; + const payload = setupFailed.args[0][1]; + expect(payload.errorCode).to.be.equal(-1); + }); + + it('should trigger failure when jwplayer version is under min supported version', function () { + let jwplayerMock = () => {}; + jwplayerMock.version = '8.20.0'; + const provider = JWPlayerProvider(config, jwplayerMock, adState, timeState, callbackStorage, utilsMock, sharedUtils); + const setupFailed = sinon.spy(); + provider.onEvent(SETUP_FAILED, setupFailed, {}); + provider.init(); + expect(setupFailed.calledOnce).to.be.true; + const payload = setupFailed.args[0][1]; + expect(payload.errorCode).to.be.equal(-2); + }); + + it('should trigger failure when div is missing', function () { + removeDiv(); + let jwplayerMock = () => {}; + const provider = JWPlayerProvider(config, jwplayerMock, adState, timeState, callbackStorage, utilsMock, sharedUtils); + const setupFailed = sinon.spy(); + provider.onEvent(SETUP_FAILED, setupFailed, {}); + provider.init(); + expect(setupFailed.calledOnce).to.be.true; + const payload = setupFailed.args[0][1]; + expect(payload.errorCode).to.be.equal(-3); + addDiv(); + addDiv(); + }); + + it('should instantiate the player when uninstantiated', function () { + const player = getPlayerMock(); + config.playerConfig = {}; + const setupSpy = player.setup = sinon.spy(player.setup); + const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils); + provider.init(); + expect(setupSpy.calledOnce).to.be.true; + }); + + it('should trigger setup complete when player is already instantiated', function () { + const player = getPlayerMock(); + player.getState = () => 'idle'; + const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils); + const setupComplete = sinon.spy(); + provider.onEvent(SETUP_COMPLETE, setupComplete, {}); + provider.init(); + expect(setupComplete.calledOnce).to.be.true; + }); + + it('should support multiple setup complete event handlers', function () { + const player = getPlayerMock(); + player.getState = () => 'idle'; + const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils); + const setupComplete = sinon.spy(); + const setupComplete2 = sinon.spy(); + provider.onEvent(SETUP_COMPLETE, setupComplete, {}); + provider.onEvent(SETUP_COMPLETE, setupComplete2, {}); + provider.init(); + expect(setupComplete.calledOnce).to.be.true; + expect(setupComplete2.calledOnce).to.be.true; + }); + + it('should not reinstantiate player', function () { + const player = getPlayerMock(); + player.getState = () => 'idle'; + const setupSpy = player.setup = sinon.spy(); + const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adState, timeState, callbackStorage, utilsMock, sharedUtils); + provider.init(); + expect(setupSpy.called).to.be.false; + }); + }); + + describe('getId', function () { + it('should return configured div id', function () { + const provider = JWPlayerProvider({ divId: 'test_id' }, undefined, undefined, undefined, undefined, undefined, sharedUtils); + expect(provider.getId()).to.be.equal('test_id'); + }); + }); + + describe('getOrtbVideo', function () { + it('should populate oRTB Video params', function () { + const test_media_type = VIDEO_MIME_TYPE.MP4; + const test_height = 100; + const test_width = 200; + const test_start_delay = 5; + const test_placement = PLACEMENT.ARTICLE; + const test_battr = 'battr'; + const test_playback_method = PLAYBACK_METHODS.CLICK_TO_PLAY; + const test_skip = 0; + + const config = { divId: 'test' }; + const player = getPlayerMock(); + const utils = getUtilsMock(); + + player.getConfig = () => ({ + advertising: { + battr: test_battr + } + }); + player.getHeight = () => test_height; + player.getWidth = () => test_width; + player.getFullscreen = () => true; // + + utils.getSupportedMediaTypes = () => [test_media_type]; + utils.getStartDelay = () => test_start_delay; + utils.getPlacement = () => test_placement; + utils.getPlaybackMethod = () => test_playback_method; + utils.isOmidSupported = () => true; // + utils.getSkipParams = () => ({ skip: test_skip }); + + const provider = JWPlayerProvider(config, makePlayerFactoryMock(player), adStateFactory(), {}, {}, utils, sharedUtils); + provider.init(); + let video = provider.getOrtbVideo(); + + expect(video.mimes).to.include(VIDEO_MIME_TYPE.MP4); + expect(video.protocols).to.include.members([ + PROTOCOLS.VAST_2_0, + PROTOCOLS.VAST_3_0, + PROTOCOLS.VAST_4_0, + PROTOCOLS.VAST_2_0_WRAPPER, + PROTOCOLS.VAST_3_0_WRAPPER, + PROTOCOLS.VAST_4_0_WRAPPER + ]); + expect(video.h).to.equal(test_height); + expect(video.w).to.equal(test_width); + expect(video.startdelay).to.equal(test_start_delay); + expect(video.placement).to.equal(test_placement); + expect(video.battr).to.equal(test_battr); + expect(video.maxextended).to.equal(-1); + expect(video.boxingallowed).to.equal(1); + expect(video.playbackmethod).to.include(test_playback_method); + expect(video.playbackend).to.equal(1); + expect(video.api).to.have.length(2); + expect(video.api).to.include.members([API_FRAMEWORKS.VPAID_2_0, API_FRAMEWORKS.OMID_1_0]); // + expect(video.skip).to.equal(test_skip); + expect(video.pos).to.equal(7); // + + player.getFullscreen = () => false; + utils.isOmidSupported = () => false; + + video = provider.getOrtbVideo(); + expect(video).to.not.have.property('pos'); + expect(video.api).to.have.length(1); + expect(video.api).to.include(API_FRAMEWORKS.VPAID_2_0); + expect(video.api).to.not.include(API_FRAMEWORKS.OMID_1_0); + }); + }); + + describe('getOrtbContent', function () { + it('should populate oRTB Content params', function () { + const test_item = { + mediaid: 'id', + file: 'file', + title: 'title', + iabCategories: 'iabCategories', + tags: 'keywords', + }; + const test_duration = 30; + let test_playback_mode = PLAYBACK_MODE.VOD;// + + const player = getPlayerMock(); + player.getPlaylistItem = () => test_item; + const utils = getUtilsMock(); + + const timeState = { + getState: () => ({ + duration: test_duration, + playbackMode: test_playback_mode + }) + }; + + const provider = JWPlayerProvider({ divId: 'test' }, makePlayerFactoryMock(player), adStateFactory(), timeState, {}, utils, sharedUtils); + provider.init(); + + let content = provider.getOrtbContent(); + expect(content.id).to.be.equal('jw_' + test_item.mediaid); + expect(content.url).to.be.equal(test_item.file); + expect(content.title).to.be.equal(test_item.title); + expect(content.cat).to.be.equal(test_item.iabCategories); + expect(content.keywords).to.be.equal(test_item.tags); + expect(content.len).to.be.equal(test_duration); + expect(content.livestream).to.be.equal(0);// + + test_playback_mode = PLAYBACK_MODE.LIVE; + + content = provider.getOrtbContent(); + expect(content.livestream).to.be.equal(1); + + test_playback_mode = PLAYBACK_MODE.DVR; + + content = provider.getOrtbContent(); + expect(content.livestream).to.be.equal(1); + }); + }); + + describe('setAdTagUrl', function () { + it('should call playAd', function () { + const player = getPlayerMock(); + const playAdSpy = player.playAd = sinon.spy(); + const provider = JWPlayerProvider({ divId: 'test' }, makePlayerFactoryMock(player), {}, {}, {}, {}, sharedUtils); + provider.init(); + provider.setAdTagUrl('tag'); + expect(playAdSpy.called).to.be.true; + const argument = playAdSpy.args[0][0]; + expect(argument).to.be.equal('tag'); + }); + }); + + describe('events', function () { + it('should register event listener on player', function () { + const player = getPlayerMock(); + const onSpy = player.on = sinon.spy(); + const provider = JWPlayerProvider({ divId: 'test' }, makePlayerFactoryMock(player), adStateFactory(), timeStateFactory(), callbackStorageFactory(), getUtilsMock(), sharedUtils); + provider.init(); + const callback = () => {}; + provider.onEvent(PLAY, callback, {}); + expect(onSpy.calledOnce).to.be.true; + const eventName = onSpy.args[0][0]; + expect(eventName).to.be.equal('play'); + }); + + it('should remove event listener on player', function () { + const player = getPlayerMock(); + const offSpy = player.off = sinon.spy(); + const provider = JWPlayerProvider({ divId: 'test' }, makePlayerFactoryMock(player), adStateFactory(), timeStateFactory(), callbackStorageFactory(), utils, sharedUtils); + provider.init(); + const callback = () => {}; + provider.onEvent(AD_IMPRESSION, callback, {}); + provider.offEvent(AD_IMPRESSION, callback); + expect(offSpy.calledOnce).to.be.true; + const eventName = offSpy.args[0][0]; + expect(eventName).to.be.equal('adViewableImpression'); + }); + }); + + describe('destroy', function () { + it('should remove and null the player', function () { + const player = getPlayerMock(); + const removeSpy = player.remove = sinon.spy(); + player.remove = removeSpy; + const provider = JWPlayerProvider({ divId: 'test' }, makePlayerFactoryMock(player), adStateFactory(), timeStateFactory(), callbackStorageFactory(), getUtilsMock(), sharedUtils); + provider.init(); + provider.destroy(); + provider.destroy(); + expect(removeSpy.calledOnce).to.be.true; + }); + }); +}); + +describe('adStateFactory', function () { + let adState = adStateFactory(); + + beforeEach(() => { + adState.clearState(); + }); + + it('should update state for ad events', function () { + const tag = 'tag'; + const adPosition = 'adPosition'; + const timeLoading = 'timeLoading'; + const id = 'id'; + const description = 'description'; + const adsystem = 'adsystem'; + const adtitle = 'adtitle'; + const advertiserId = 'advertiserId'; + const advertiser = 'advertiser'; + const dealId = 'dealId'; + const linear = 'linear'; + const vastversion = 'vastversion'; + const mediaFile = 'mediaFile'; + const adId = 'adId'; + const universalAdId = 'universalAdId'; + const creativeAdId = 'creativeAdId'; + const creativetype = 'creativetype'; + const clickThroughUrl = 'clickThroughUrl'; + const witem = 'witem'; + const wcount = 'wcount'; + const podcount = 'podcount'; + const sequence = 'sequence'; + + adState.updateForEvent({ + tag, + adPosition, + timeLoading, + id, + description, + adsystem, + adtitle, + advertiserId, + advertiser, + dealId, + linear, + vastversion, + mediaFile, + adId, + universalAdId, + creativeAdId, + creativetype, + clickThroughUrl, + witem, + wcount, + podcount, + sequence + }); + + const state = adState.getState(); + expect(state.adTagUrl).to.equal(tag); + expect(state.offset).to.equal(adPosition); + expect(state.loadTime).to.equal(timeLoading); + expect(state.vastAdId).to.equal(id); + expect(state.adDescription).to.equal(description); + expect(state.adServer).to.equal(adsystem); + expect(state.adTitle).to.equal(adtitle); + expect(state.advertiserId).to.equal(advertiserId); + expect(state.dealId).to.equal(dealId); + expect(state.linear).to.equal(linear); + expect(state.vastVersion).to.equal(vastversion); + expect(state.creativeUrl).to.equal(mediaFile); + expect(state.adId).to.equal(adId); + expect(state.universalAdId).to.equal(universalAdId); + expect(state.creativeId).to.equal(creativeAdId); + expect(state.creativeType).to.equal(creativetype); + expect(state.redirectUrl).to.equal(clickThroughUrl); + expect(state).to.have.property('adPlacementType'); + expect(state.adPlacementType).to.be.undefined; + expect(state.waterfallIndex).to.equal(witem); + expect(state.waterfallCount).to.equal(wcount); + expect(state.adPodCount).to.equal(podcount); + expect(state.adPodIndex).to.equal(sequence); + }); + + it('should convert placement to oRTB value', function () { + adState.updateForEvent({ + placement: 'instream' + }); + + let state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.INSTREAM); + + adState.updateForEvent({ + placement: 'banner' + }); + + state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.BANNER); + + adState.updateForEvent({ + placement: 'article' + }); + + state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.ARTICLE); + + adState.updateForEvent({ + placement: 'feed' + }); + + state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.FEED); + + adState.updateForEvent({ + placement: 'interstitial' + }); + + state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.INTERSTITIAL); + + adState.updateForEvent({ + placement: 'slider' + }); + + state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.SLIDER); + + adState.updateForEvent({ + placement: 'floating' + }); + + state = adState.getState(); + expect(state.adPlacementType).to.be.equal(PLACEMENT.FLOATING); + }); +}); + +describe('timeStateFactory', function () { + let timeState = timeStateFactory(); + + beforeEach(() => { + timeState.clearState(); + }); + + it('should update state for VOD time event', function() { + const position = 5; + const test_duration = 30; + + timeState.updateForEvent({ + position, + duration: test_duration + }); + + const { time, duration, playbackMode } = timeState.getState(); + expect(time).to.be.equal(position); + expect(duration).to.be.equal(test_duration); + expect(playbackMode).to.be.equal(PLAYBACK_MODE.VOD); + }); + + it('should update state for LIVE time events', function() { + const position = 0; + const test_duration = 0; + + timeState.updateForEvent({ + position, + duration: test_duration + }); + + const { time, duration, playbackMode } = timeState.getState(); + expect(time).to.be.equal(position); + expect(duration).to.be.equal(test_duration); + expect(playbackMode).to.be.equal(PLAYBACK_MODE.LIVE); + }); + + it('should update state for DVR time events', function() { + const position = -5; + const test_duration = -30; + + timeState.updateForEvent({ + position, + duration: test_duration + }); + + const { time, duration, playbackMode } = timeState.getState(); + expect(time).to.be.equal(position); + expect(duration).to.be.equal(test_duration); + expect(playbackMode).to.be.equal(PLAYBACK_MODE.DVR); + }); +}); + +describe('callbackStorageFactory', function () { + let callbackStorage = callbackStorageFactory(); + + beforeEach(() => { + callbackStorage.clearStorage(); + }); + + it('should store callbacks', function () { + const callback1 = () => 'callback1'; + const eventHandler1 = () => 'eventHandler1'; + callbackStorage.storeCallback('event', eventHandler1, callback1); + + const callback2 = () => 'callback2'; + const eventHandler2 = () => 'eventHandler2'; + callbackStorage.storeCallback('event', eventHandler2, callback2); + + const callback3 = () => 'callback3'; + + expect(callbackStorage.getCallback('event', callback1)).to.be.equal(eventHandler1); + expect(callbackStorage.getCallback('event', callback2)).to.be.equal(eventHandler2); + expect(callbackStorage.getCallback('event', callback3)).to.be.undefined; + }); + + it('should remove callbacks after retrieval', function () { + const callback1 = () => 'callback1'; + const eventHandler1 = () => 'eventHandler1'; + callbackStorage.storeCallback('event', eventHandler1, callback1); + + expect(callbackStorage.getCallback('event', callback1)).to.be.equal(eventHandler1); + expect(callbackStorage.getCallback('event', callback1)).to.be.undefined; + }); + + it('should clear callbacks', function () { + const callback1 = () => 'callback1'; + const eventHandler1 = () => 'eventHandler1'; + callbackStorage.storeCallback('event', eventHandler1, callback1); + + callbackStorage.clearStorage(); + expect(callbackStorage.getCallback('event', callback1)).to.be.undefined; + }); +}); + +describe('utils', function () { + describe('getJwConfig', function () { + const getJwConfig = utils.getJwConfig; + it('should return undefined when no config is provided', function () { + let jwConfig = getJwConfig(); + expect(jwConfig).to.be.undefined; + + jwConfig = getJwConfig(null); + expect(jwConfig).to.be.undefined; + }); + + it('should set vendor config params to top level', function () { + let jwConfig = getJwConfig({ + params: { + vendorConfig: { + 'test': 'a', + 'test_2': 'b' + } + } + }); + expect(jwConfig.test).to.be.equal('a'); + expect(jwConfig.test_2).to.be.equal('b'); + }); + + it('should convert video module params', function () { + let jwConfig = getJwConfig({ + mute: true, + autoStart: true, + licenseKey: 'key' + }); + + expect(jwConfig.mute).to.be.true; + expect(jwConfig.autostart).to.be.true; + expect(jwConfig.key).to.be.equal('key'); + }); + + it('should apply video module params only when absent from vendor config', function () { + let jwConfig = getJwConfig({ + mute: true, + autoStart: true, + licenseKey: 'key', + params: { + vendorConfig: { + mute: false, + autostart: false, + key: 'other_key' + } + } + }); + + expect(jwConfig.mute).to.be.false; + expect(jwConfig.autostart).to.be.false; + expect(jwConfig.key).to.be.equal('other_key'); + }); + + it('should not convert undefined properties', function () { + let jwConfig = getJwConfig({ + params: { + vendorConfig: { + test: 'a' + } + } + }); + + expect(jwConfig).to.not.have.property('mute'); + expect(jwConfig).to.not.have.property('autostart'); + expect(jwConfig).to.not.have.property('key'); + }); + + it('should exclude fallback ad block when setupAds is explicitly disabled', function () { + let jwConfig = getJwConfig({ + setupAds: false, + params: { + + vendorConfig: {} + } + }); + + expect(jwConfig).to.not.have.property('advertising'); + }); + + it('should set advertising block when setupAds is allowed', function () { + let jwConfig = getJwConfig({ + params: { + vendorConfig: { + advertising: { + tag: 'test_tag' + } + } + } + }); + + expect(jwConfig).to.have.property('advertising'); + expect(jwConfig.advertising).to.have.property('tag', 'test_tag'); + }); + + it('should fallback to vast plugin', function () { + let jwConfig = getJwConfig({}); + + expect(jwConfig).to.have.property('advertising'); + expect(jwConfig.advertising).to.have.property('client', 'vast'); + }); + }); + describe('getSkipParams', function () { + const getSkipParams = utils.getSkipParams; + + it('should return an empty object when skip is not configured', function () { + let skipParams = getSkipParams({}); + expect(skipParams).to.be.empty; + }); + + it('should set skip to false when explicitly configured', function () { + let skipParams = getSkipParams({ + skipoffset: -1 + }); + expect(skipParams.skip).to.be.equal(0); + expect(skipParams.skipmin).to.be.undefined; + expect(skipParams.skipafter).to.be.undefined; + }); + + it('should be skippable when skip offset is set', function () { + const skipOffset = 3; + let skipParams = getSkipParams({ + skipoffset: skipOffset + }); + expect(skipParams.skip).to.be.equal(1); + expect(skipParams.skipmin).to.be.equal(skipOffset + 2); + expect(skipParams.skipafter).to.be.equal(skipOffset); + }); + }); + + describe('getSupportedMediaTypes', function () { + const getSupportedMediaTypes = utils.getSupportedMediaTypes; + + it('should always support VPAID', function () { + let supportedMediaTypes = getSupportedMediaTypes([]); + expect(supportedMediaTypes).to.include(VPAID_MIME_TYPE); + + supportedMediaTypes = getSupportedMediaTypes([VIDEO_MIME_TYPE.MP4]); + expect(supportedMediaTypes).to.include(VPAID_MIME_TYPE); + }); + }); + + describe('getPlacement', function () { + const getPlacement = utils.getPlacement; + + it('should be INSTREAM when not configured for outstream', function () { + let adConfig = {}; + let placement = getPlacement(adConfig); + expect(placement).to.be.equal(PLACEMENT.INSTREAM); + + adConfig = { outstream: false }; + placement = getPlacement(adConfig); + expect(placement).to.be.equal(PLACEMENT.INSTREAM); + }); + + it('should be FLOATING when player is floating', function () { + const player = getPlayerMock(); + player.getFloating = () => true; + const placement = getPlacement({outstream: true}, player); + expect(placement).to.be.equal(PLACEMENT.FLOATING); + }); + + it('should be the value defined in the ad config', function () { + const player = getPlayerMock(); + player.getFloating = () => false; + + let placement = getPlacement({placement: 'banner', outstream: true}, player); + expect(placement).to.be.equal(PLACEMENT.BANNER); + + placement = getPlacement({placement: 'article', outstream: true}, player); + expect(placement).to.be.equal(PLACEMENT.ARTICLE); + + placement = getPlacement({placement: 'feed', outstream: true}, player); + expect(placement).to.be.equal(PLACEMENT.FEED); + + placement = getPlacement({placement: 'interstitial', outstream: true}, player); + expect(placement).to.be.equal(PLACEMENT.INTERSTITIAL); + + placement = getPlacement({placement: 'slider', outstream: true}, player); + expect(placement).to.be.equal(PLACEMENT.SLIDER); + }); + + it('should be undefined when undetermined', function () { + const placement = getPlacement({ outstream: true }, getPlayerMock()); + expect(placement).to.be.undefined; + }); + }); + + describe('getPlaybackMethod', function() { + const getPlaybackMethod = utils.getPlaybackMethod; + + it('should return autoplay with sound', function() { + const playbackMethod = getPlaybackMethod({ + autoplay: true, + mute: false + }); + expect(playbackMethod).to.equal(PLAYBACK_METHODS.AUTOPLAY); + }); + + it('should return autoplay muted', function() { + const playbackMethod = getPlaybackMethod({ + autoplay: true, + mute: true + }); + expect(playbackMethod).to.equal(PLAYBACK_METHODS.AUTOPLAY_MUTED); + }); + + it('should treat autoplayAdsMuted as mute', function () { + const playbackMethod = getPlaybackMethod({ + autoplay: true, + autoplayAdsMuted: true + }); + expect(playbackMethod).to.equal(PLAYBACK_METHODS.AUTOPLAY_MUTED); + }); + + it('should return click to play', function() { + let playbackMethod = getPlaybackMethod({ autoplay: false }); + expect(playbackMethod).to.equal(PLAYBACK_METHODS.CLICK_TO_PLAY); + + playbackMethod = getPlaybackMethod({ + autoplay: false, + autoplayAdsMuted: true + }); + expect(playbackMethod).to.equal(PLAYBACK_METHODS.CLICK_TO_PLAY); + + playbackMethod = getPlaybackMethod({ + autoplay: false, + mute: true + }); + expect(playbackMethod).to.equal(PLAYBACK_METHODS.CLICK_TO_PLAY); + }); + }); + + describe('isOmidSupported', function () { + const isOmidSupported = utils.isOmidSupported; + const initialOmidSessionClient = window.OmidSessionClient; + afterEach(() => { + window.OmidSessionClient = initialOmidSessionClient; + }); + + it('should be true when Omid is loaded and client is VAST', function () { + window.OmidSessionClient = {}; + expect(isOmidSupported('vast')).to.be.true; + }); + + it('should be false when Omid is not present', function () { + expect(isOmidSupported('vast')).to.be.false; + }); + + it('should be false when client is not Vast', function () { + window.OmidSessionClient = {}; + expect(isOmidSupported('googima')).to.be.false; + expect(isOmidSupported('freewheel')).to.be.false; + expect(isOmidSupported('googimadai')).to.be.false; + expect(isOmidSupported('')).to.be.false; + expect(isOmidSupported(null)).to.be.false; + expect(isOmidSupported()).to.be.false; + }); + }); + + describe('getIsoLanguageCode', function () { + const sampleAudioTracks = [{language: 'ht'}, {language: 'fr'}, {language: 'es'}, {language: 'pt'}]; + + it('should return undefined when audio tracks are unavailable', function () { + const player = getPlayerMock(); + let languageCode = utils.getIsoLanguageCode(player); + expect(languageCode).to.be.undefined; + player.getAudioTracks = () => []; + languageCode = utils.getIsoLanguageCode(player); + expect(languageCode).to.be.undefined; + }); + + it('should return the first audio track language code if the getCurrentAudioTrack returns undefined', function () { + const player = getPlayerMock(); + player.getAudioTracks = () => sampleAudioTracks; + let languageCode = utils.getIsoLanguageCode(player); + expect(languageCode).to.be.equal('ht'); + }); + + it('should return the first audio track language code if the getCurrentAudioTrack returns null', function () { + const player = getPlayerMock(); + player.getAudioTracks = () => sampleAudioTracks; + player.getCurrentAudioTrack = () => null; + let languageCode = utils.getIsoLanguageCode(player); + expect(languageCode).to.be.equal('ht'); + }); + + it('should return the first audio track language code if the getCurrentAudioTrack returns -1', function () { + const player = getPlayerMock(); + player.getAudioTracks = () => sampleAudioTracks; + player.getCurrentAudioTrack = () => -1; + const languageCode = utils.getIsoLanguageCode(player); + expect(languageCode).to.be.equal('ht'); + }); + + it('should return the right audio track language code', function () { + const player = getPlayerMock(); + player.getAudioTracks = () => sampleAudioTracks; + player.getCurrentAudioTrack = () => 2; + const languageCode = utils.getIsoLanguageCode(player); + expect(languageCode).to.be.equal('es'); + }); + }); +}); diff --git a/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js b/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js new file mode 100644 index 00000000000..a7379ccbab2 --- /dev/null +++ b/test/spec/modules/videoModule/submodules/videojsVideoProvider_spec.js @@ -0,0 +1,391 @@ +// Using require style imports for fine grained control of import time +import { + SETUP_COMPLETE, SETUP_FAILED +} from 'libraries/video/constants/events.js'; + +const {VideojsProvider, utils} = require('modules/videojsVideoProvider'); + +const { + PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE, AD_POSITION +} = require('libraries/video/constants/ortb.js'); + +const videojs = require('video.js').default; +require('videojs-playlist').default; +require('videojs-ima').default; +require('videojs-contrib-ads').default; + +describe('videojsProvider', function () { + let config; + let adState; + let timeState; + let callbackStorage; + + describe('init', function () { + beforeEach(() => { + config = {}; + document.body.innerHTML = ''; + }); + + it('should trigger failure when videojs is missing', function () { + const provider = VideojsProvider(config, null, adState, timeState, callbackStorage, utils); + const setupFailed = sinon.spy(); + provider.onEvent(SETUP_FAILED, setupFailed, {}); + provider.init(); + expect(setupFailed.calledOnce).to.be.true; + const payload = setupFailed.args[0][1]; + expect(payload.errorCode).to.be.equal(-1); + }); + + it('should trigger failure when videojs version is under min supported version', function () { + const provider = VideojsProvider(config, {...videojs, VERSION: '0.0.0'}, adState, timeState, callbackStorage, utils); + const setupFailed = sinon.spy(); + provider.onEvent(SETUP_FAILED, setupFailed, {}); + provider.init(); + expect(setupFailed.calledOnce).to.be.true; + const payload = setupFailed.args[0][1]; + expect(payload.errorCode).to.be.equal(-2); + }); + + it('should trigger failure when the div is not found', function () { + config.divId = 'fake-div' + const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils); + const setupFailed = sinon.spy(); + provider.onEvent(SETUP_FAILED, setupFailed, {}); + provider.init(); + expect(setupFailed.calledOnce).to.be.true; + const payload = setupFailed.args[0][1]; + expect(payload.errorCode).to.be.equal(-3); + }); + + it('should instantiate the player when uninstantied', function () { + config.playerConfig = {testAttr: true}; + config.divId = 'test-div' + const div = document.createElement('div'); + div.setAttribute('id', 'test-div'); + document.body.appendChild(div); + + const mockVideojs = sinon.spy(); + const provider = VideojsProvider(config, mockVideojs, adState, timeState, callbackStorage, utils); + provider.init(); + expect(mockVideojs.calledOnce).to.be.true + }); + + it('should not reinstantiate the player', function () { + const div = document.createElement('div'); + div.setAttribute('id', 'test-div'); + document.body.appendChild(div); + const player = videojs(div, {}) + config.playerConfig = {}; + config.divId = 'test-div' + const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils); + provider.init(); + expect(videojs.getPlayer('test-div')).to.be.equal(player) + videojs.getPlayer('test-div').dispose() + }); + + it('should trigger setup complete when player is already insantiated', function () { + const div = document.createElement('div'); + div.setAttribute('id', 'test-div'); + document.body.appendChild(div); + videojs(div, {}) + config.playerConfig = {}; + config.divId = 'test-div' + const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils); + const setupComplete = sinon.spy(); + provider.onEvent(SETUP_COMPLETE, setupComplete, {}); + provider.init(); + expect(setupComplete.called).to.be.true; + videojs.getPlayer('test-div').dispose() + }); + }); + + describe('getId', function () { + it('should return configured div id', function () { + const provider = VideojsProvider({ divId: 'test_id' }); + expect(provider.getId()).to.be.equal('test_id'); + }); + }); + + describe('getOrtbParams', function () { + beforeEach(() => { + config = {divId: 'test'}; + // initialize videojs element + document.body.innerHTML = ` + `; + }); + + afterEach(() => { + const testPlayer = videojs('test'); + if (testPlayer && !testPlayer.isDisposed()) { + testPlayer.dispose(); + } + }); + + it('should populate oRTB Video and Content', function () { + const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils); + provider.init(); + + const video = provider.getOrtbVideo(); + + expect(video.mimes).to.include(VIDEO_MIME_TYPE.MP4); + expect(video.protocols).to.deep.equal([2]); + expect(video.h).to.equal(100); + expect(video.w).to.equal(200); + + expect(video.maxextended).to.equal(-1); + expect(video.boxingallowed).to.equal(1); + expect(video.playbackmethod).to.include(PLAYBACK_METHODS.CLICK_TO_PLAY); + expect(video.playbackend).to.equal(1); + expect(video.api).to.deep.equal([2]); + expect(video.placement).to.be.equal(PLACEMENT.INSTREAM); + }); + + it('should populate oRTB Content', function () { + const provider = VideojsProvider(config, videojs, adState, timeState, callbackStorage, utils); + provider.init(); + + const content = provider.getOrtbContent(); + expect(content.url).to.be.equal('http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'); + expect(content).to.not.have.property('len'); + }); + + it('should change populated oRTB params when ima present', function () { + require('videojs-contrib-ads'); + require('videojs-ima'); + config.playerConfig = { + params: { + vendorConfig: { + mediaid: 'vendor-id', + advertising: { + tag: ['test-tag'] + } + } + } + } + + let provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const video = provider.getOrtbVideo(); + + expect(video.protocols).to.include(PROTOCOLS.VAST_2_0); + expect(video.api).to.include(API_FRAMEWORKS.VPAID_2_0); + expect(video.mimes).to.include(VPAID_MIME_TYPE); + }); + // + // We can't determine what type of outstream play is occuring + // if the src is absent so we should not set placement + it('should not set placement when src is absent', function() { + document.body.innerHTML = `` + const provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const video = provider.getOrtbVideo(); + expect(video).to.not.have.property('placement') + }) + // + it('should populate position when fullscreen', function () { + const provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const player = videojs.getPlayer('test') + player.isFullscreen = () => true; + const video = provider.getOrtbVideo(); + expect(video.pos).to.equal(7); + }); + // + it('should populate length when loaded', function () { + const provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const player = videojs.getPlayer('test') + player.readyState = () => 1 + player.duration = () => 100 + const content = provider.getOrtbContent(); + expect(content.len).to.equal(100); + }); + // + it('should return the correct playback method for autoplay', function () { + const provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const player = videojs.getPlayer('test') + player.autoplay(true) + const video = provider.getOrtbVideo(); + expect(video.playbackmethod).to.include(PLAYBACK_METHODS.AUTOPLAY); + }); + // + it('should return the correct playback method for autoplay muted', function () { + const provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const player = videojs.getPlayer('test') + player.muted = () => true + player.autoplay = () => true + const video = provider.getOrtbVideo(); + expect(video.playbackmethod).to.include(PLAYBACK_METHODS.AUTOPLAY_MUTED); + }); + // + it('should return the correct playback method for the other autoplay muted', function () { + const provider = VideojsProvider(config, videojs, null, null, null, utils); + provider.init(); + const player = videojs.getPlayer('test') + player.autoplay = () => 'muted' + const video = provider.getOrtbVideo(); + expect(video.playbackmethod).to.include(PLAYBACK_METHODS.AUTOPLAY_MUTED); + }); + }); +}); + +describe('utils', function() { + describe('getSetupConfig', function() { + it('should return undefined when config is absent', function () { + expect(utils.getSetupConfig()).to.be.undefined; + }); + + it('should give priority to vendorConfig', function () { + const config = { + autostart: false, + mute: false, + params: { + vendorConfig: { + autostart: true, + mute: true, + other: true + } + } + }; + const setupConfig = utils.getSetupConfig(config); + expect(setupConfig.autostart).to.be.true; + expect(setupConfig.mute).to.be.true; + expect(setupConfig.other).to.be.true; + }); + + it('should only global apply properties when absent from vendor config', function () { + const config = { + autostart: false, + params: { + vendorConfig: { + other: true + } + } + }; + const setupConfig = utils.getSetupConfig(config); + expect(setupConfig.autostart).to.be.false; + expect(setupConfig.mute).to.be.undefined; + expect(setupConfig.other).to.be.true; + }); + }); + + describe('getAdConfig', function () { + it('should return empty object when config is absent', function () { + expect(utils.getAdConfig()).to.deep.equal({}); + }); + + it('should return adPluginConfig', function () { + const config = { + params: { + adPluginConfig: { + vpaid: true, + } + } + }; + + expect(utils.getAdConfig(config)).to.be.equal(config.params.adPluginConfig); + }); + }); + + describe('getPositionCode', function() { + it('should return the correct position when video is above the fold', function () { + const code = utils.getPositionCode({ + left: window.innerWidth / 10, + top: 0, + width: window.innerWidth - window.innerWidth / 10, + height: window.innerHeight, + }) + expect(code).to.equal(AD_POSITION.ABOVE_THE_FOLD) + }); + + it('should return the correct position when video is below the fold', function () { + const code = utils.getPositionCode({ + left: window.innerWidth / 10, + top: window.innerHeight, + width: window.innerWidth - window.innerWidth / 10, + height: window.innerHeight / 2, + }) + expect(code).to.equal(AD_POSITION.BELOW_THE_FOLD) + }); + + it('should return the unkown position when the video is out of bounds', function () { + const code = utils.getPositionCode({ + left: window.innerWidth / 10, + top: window.innerHeight, + width: window.innerWidth, + height: window.innerHeight, + }) + expect(code).to.equal(AD_POSITION.UNKNOWN) + }); + }); + + describe('Playlist', function () { + const emptyPlayer = {}; + + describe('getPlaylistCount', function () { + it('should return 1 when playlist is absent', function () { + expect(utils.getPlaylistCount(emptyPlayer)).to.be.equal(1); + }); + + it('should return playlist length', function () { + document.body.innerHTML = ` + `; + const player = videojs('test', {}); + player.playlist([{ + sources: { src: 'sample.mp4' } + }, { + sources: { src: 'sample2.mp4' } + }]); + expect(utils.getPlaylistCount(player)).to.be.equal(2); + player.dispose(); + }); + }); + + describe('getCurrentPlaylistIndex', function () { + it('should return 0 when playlist is absent', function () { + expect(utils.getCurrentPlaylistIndex(emptyPlayer)).to.be.equal(0); + }); + }); + + describe('getCurrentPlaylistItem', function () { + it('should return undefined when playlist is absent', function () { + expect(utils.getCurrentPlaylistItem(emptyPlayer)).to.be.undefined; + }); + }); + }); + + describe('Get Media', function () { + describe('parseSource', function () { + it('should return src property when source is object', function () { + expect(utils.parseSource({ + src: 'test.url', + other: 'other' + })).to.be.equal('test.url'); + }); + + it('should return source when it is a string', function () { + expect(utils.parseSource('test.url')).to.be.equal('test.url'); + }); + + it('should return undefined when not object or string', function () { + expect(utils.parseSource(() => {})).to.be.undefined; + }); + }); + + describe('getMediaUrl', function () { + it('should return undefined when arg is missing', function () { + expect(utils.getMediaUrl()).to.be.undefined; + }); + + it('should parse first index when arg is array', function () { + expect(utils.getMediaUrl(['test.url.1', 'test.url.2'])).to.be.equal('test.url.1'); + }); + }); + }); +}) diff --git a/test/spec/modules/videoModule/videoImpressionVerifier_spec.js b/test/spec/modules/videoModule/videoImpressionVerifier_spec.js new file mode 100644 index 00000000000..58109219a37 --- /dev/null +++ b/test/spec/modules/videoModule/videoImpressionVerifier_spec.js @@ -0,0 +1,112 @@ +import { baseImpressionVerifier, PB_PREFIX } from 'modules/videoModule/videoImpressionVerifier.js'; + +let trackerMock; +trackerMock = { + store: sinon.spy(), + remove: sinon.spy() +} + +describe('Base Impression Verifier', function() { + describe('trackBid', function () { + it('should generate uuid', function () { + const baseVerifier = baseImpressionVerifier(trackerMock); + const uuid = baseVerifier.trackBid({}); + expect(uuid.substring(0, 3)).to.equal(PB_PREFIX); + expect(uuid.length).to.be.lessThan(16); + }); + }); + + describe('getBidIdentifiers', function () { + it('should match ad id to uuid', function () { + + }); + }); +}); + +/* +const adUnitCode = 'test_ad_unit_code'; +const sampleBid = { + adId: 'test_ad_id', + adUnitCode, + vastUrl: 'test_ad_url' +}; +const sampleAdUnit = { + code: adUnitCode, +}; + +const expectedImpressionUrl = 'test_impression_url'; +const expectedImpressionId = 'test_impression_id'; +const expectedErrorUrl = 'test_error_url'; +const expectedVastXml = 'test_xml'; + +it('should not modify the bid\'s adXml when the tracking config is omitted', function () { + const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: null } } }); + const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] }); + pbVideoFactory(null, () => ({}), pbGlobal, pbEvents); + + bidAdjustmentCb(sampleBid); + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.false; + // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false; +}); + +it('should request a vast wrapper when only an ad url is provided', function () { + const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: { } } } }); + const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] }); + pbVideoFactory(null, () => ({}), pbGlobal, pbEvents); + + bidAdjustmentCb(sampleBid); + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.false; + // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.true; +}); + +it('should request the addition of tracking nodes when an ad xml is provided', function () { + const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: { } } } }); + const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] }); + pbVideoFactory(null, () => ({}), pbGlobal, pbEvents); + + const bid = Object.assign({}, sampleBid, { vastXml: 'test_xml' }); + bidAdjustmentCb(bid); + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.true; + // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false; +}); + +it('should pass the tracking information as args to the xml editing function', function () { + const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: { + impression: { + url: expectedImpressionUrl, + id: expectedImpressionId + }, + error: { + url: expectedErrorUrl + } + } } } }); + const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] }); + pbVideoFactory(null, () => ({}), pbGlobal, pbEvents); + + const bid = Object.assign({}, sampleBid, { vastXml: expectedVastXml }); + bidAdjustmentCb(bid); + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.true; + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.calledWith(expectedVastXml, expectedImpressionUrl, expectedImpressionId, expectedErrorUrl)) + // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false; +}); + +it('should generate the impression id when not specified in config', function () { + const adUnit = Object.assign({}, sampleAdUnit, { video: { adServer: { tracking: { + impression: { + url: expectedImpressionUrl, + }, + error: { + url: expectedErrorUrl + } + } } } }); + const pbGlobal = Object.assign({}, pbGlobalMock, { adUnits: [ adUnit ] }); + pbVideoFactory(null, () => ({}), pbGlobal, pbEvents); + + const bid = Object.assign({}, sampleBid, { vastXml: expectedVastXml }); + bidAdjustmentCb(bid); + const expectedGeneratedId = sampleBid.adId + '-impression'; + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.called).to.be.true; + // expect(vastXmlEditorMock.getVastXmlWithTrackingNodes.calledWith(expectedVastXml, expectedImpressionUrl, expectedGeneratedId, expectedErrorUrl)) + // expect(vastXmlEditorMock.buildVastWrapper.called).to.be.false; +}); +*/ diff --git a/test/spec/modules/videobyteBidAdapter_spec.js b/test/spec/modules/videobyteBidAdapter_spec.js index f7ea0698956..7844e2bd1be 100644 --- a/test/spec/modules/videobyteBidAdapter_spec.js +++ b/test/spec/modules/videobyteBidAdapter_spec.js @@ -463,7 +463,6 @@ describe('VideoByteBidAdapter', function () { }); let o = { requestId: serverResponse.id, - bidderCode: spec.code, cpm: serverResponse.seatbid[0].bid[0].price, creativeId: serverResponse.seatbid[0].bid[0].crid, vastXml: serverResponse.seatbid[0].bid[0].adm, diff --git a/test/spec/modules/videoheroesBidAdapter_spec.js b/test/spec/modules/videoheroesBidAdapter_spec.js new file mode 100644 index 00000000000..8f99ca4d17d --- /dev/null +++ b/test/spec/modules/videoheroesBidAdapter_spec.js @@ -0,0 +1,363 @@ +import { expect } from 'chai'; +import { spec } from 'modules/videoheroesBidAdapter.js'; + +const request_native = { + code: 'videoheroes-native-prebid', + mediaTypes: { + native: { + title: { + required: true, + len: 800 + }, + image: { + required: true, + len: 80 + }, + sponsoredBy: { + required: true + }, + clickUrl: { + required: true + }, + privacyLink: { + required: false + }, + body: { + required: true + }, + icon: { + required: true, + sizes: [50, 50] + } + } + }, + bidder: 'videoheroes', + params: { + placementId: '1a8d9c22db19906cb8a5fd4518d05f62' + } +}; + +const request_banner = { + code: 'videoheroes-prebid', + mediaTypes: { + banner: { + sizes: [[300, 250]] + } + }, + bidder: 'videoheroes', + params: { + placementId: '1a8d9c22db19906cb8a5fd4518d05f62' + } +} + +const bidRequest = { + gdprConsent: { + consentString: 'HFIDUYFIUYIUYWIPOI87392DSU', + gdprApplies: true + }, + uspConsent: 'uspConsentString', + bidderRequestId: 'testid', + refererInfo: { + referer: 'testdomain.com' + }, + timeout: 700 +} + +const request_video = { + code: 'videoheroes-video-prebid', + mediaTypes: { video: { + minduration: 1, + maxduration: 999, + boxingallowed: 1, + skip: 0, + mimes: [ + 'application/javascript', + 'video/mp4' + ], + playerSize: [[768, 1024]], + protocols: [ + 2, 3 + ], + linearity: 1, + api: [ + 1, + 2 + ] + } + }, + + bidder: 'videoheroes', + params: { + placementId: '1a8d9c22db19906cb8a5fd4518d05f62' + } + +} + +const response_banner = { + id: 'request_id', + bidid: 'request_imp_id', + seatbid: [{ + bid: [{ + id: 'bid_id', + impid: 'request_imp_id', + price: 5, + adomain: ['example.com'], + adm: 'admcode', + crid: 'crid', + ext: { + mediaType: 'banner' + } + }] + }] +}; + +const response_video = { + id: 'request_id', + bidid: 'request_imp_id', + seatbid: [{ + bid: [{ + id: 'bid_id', + impid: 'request_imp_id', + price: 5, + adomain: ['example.com'], + adm: 'admcode', + crid: 'crid', + ext: { + mediaType: 'video' + } + }], + }], +}; + +let imgData = { + url: `https://example.com/image`, + w: 1200, + h: 627 +}; + +const response_native = { + id: 'request_id', + bidid: 'request_imp_id', + seatbid: [{ + bid: [{ + id: 'bid_id', + impid: 'request_imp_id', + price: 5, + adomain: ['example.com'], + adm: { native: + { + assets: [ + {id: 1, title: 'dummyText'}, + {id: 3, image: imgData}, + { + id: 5, + data: {value: 'organization.name'} + } + ], + link: {url: 'example.com'}, + imptrackers: ['tracker1.com', 'tracker2.com', 'tracker3.com'], + jstracker: 'tracker1.com' + } + }, + crid: 'crid', + ext: { + mediaType: 'native' + } + }], + }], +}; + +describe('VideoheroesBidAdapter', function() { + describe('isBidRequestValid', function() { + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(request_banner)).to.equal(true); + }); + + it('should return false when required params are not passed', function () { + let bid = Object.assign({}, request_banner); + bid.params = { + 'IncorrectParam': 0 + }; + expect(spec.isBidRequestValid(bid)).to.equal(false); + }); + }); + + describe('build Native Request', function () { + const request = spec.buildRequests([request_native], bidRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(request).to.exist; + expect(request.method).to.exist; + expect(request.url).to.exist; + expect(request.data).to.exist; + }); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(request.url).to.equal('https://point.contextualadv.com/?t=2&partner=1a8d9c22db19906cb8a5fd4518d05f62'); + }); + + it('Returns empty data if no valid requests are passed', function () { + let serverRequest = spec.buildRequests([]); + expect(serverRequest).to.be.an('array').that.is.empty; + }); + }); + + describe('build Banner Request', function () { + const request = spec.buildRequests([request_banner], bidRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(request).to.exist; + expect(request.method).to.exist; + expect(request.url).to.exist; + expect(request.data).to.exist; + }); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(request.url).to.equal('https://point.contextualadv.com/?t=2&partner=1a8d9c22db19906cb8a5fd4518d05f62'); + }); + }); + + describe('build Video Request', function () { + const request = spec.buildRequests([request_video], bidRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(request).to.exist; + expect(request.method).to.exist; + expect(request.url).to.exist; + expect(request.data).to.exist; + }); + + it('sends bid request to our endpoint via POST', function () { + expect(request.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(request.url).to.equal('https://point.contextualadv.com/?t=2&partner=1a8d9c22db19906cb8a5fd4518d05f62'); + }); + }); + + describe('interpretResponse', function () { + it('Empty response must return empty array', function() { + const emptyResponse = null; + let response = spec.interpretResponse(emptyResponse); + + expect(response).to.be.an('array').that.is.empty; + }) + + it('Should interpret banner response', function () { + const bannerResponse = { + body: response_banner + } + + const expectedBidResponse = { + requestId: response_banner.seatbid[0].bid[0].impid, + cpm: response_banner.seatbid[0].bid[0].price, + width: response_banner.seatbid[0].bid[0].w, + height: response_banner.seatbid[0].bid[0].h, + ttl: response_banner.ttl || 1200, + currency: response_banner.cur || 'USD', + netRevenue: true, + creativeId: response_banner.seatbid[0].bid[0].crid, + dealId: response_banner.seatbid[0].bid[0].dealid, + mediaType: 'banner', + ad: response_banner.seatbid[0].bid[0].adm + } + + let bannerResponses = spec.interpretResponse(bannerResponse); + + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); + expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); + expect(dataItem.ad).to.equal(expectedBidResponse.ad); + expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); + expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(expectedBidResponse.currency); + expect(dataItem.width).to.equal(expectedBidResponse.width); + expect(dataItem.height).to.equal(expectedBidResponse.height); + }); + + it('Should interpret video response', function () { + const videoResponse = { + body: response_video + } + + const expectedBidResponse = { + requestId: response_video.seatbid[0].bid[0].impid, + cpm: response_video.seatbid[0].bid[0].price, + width: response_video.seatbid[0].bid[0].w, + height: response_video.seatbid[0].bid[0].h, + ttl: response_video.ttl || 1200, + currency: response_video.cur || 'USD', + netRevenue: true, + creativeId: response_video.seatbid[0].bid[0].crid, + dealId: response_video.seatbid[0].bid[0].dealid, + mediaType: 'video', + vastUrl: response_video.seatbid[0].bid[0].adm + } + + let videoResponses = spec.interpretResponse(videoResponse); + + expect(videoResponses).to.be.an('array').that.is.not.empty; + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); + expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); + expect(dataItem.vastUrl).to.equal(expectedBidResponse.vastUrl) + expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); + expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(expectedBidResponse.currency); + expect(dataItem.width).to.equal(expectedBidResponse.width); + expect(dataItem.height).to.equal(expectedBidResponse.height); + }); + + it('Should interpret native response', function () { + const nativeResponse = { + body: response_native + } + + const expectedBidResponse = { + requestId: response_native.seatbid[0].bid[0].impid, + cpm: response_native.seatbid[0].bid[0].price, + width: response_native.seatbid[0].bid[0].w, + height: response_native.seatbid[0].bid[0].h, + ttl: response_native.ttl || 1200, + currency: response_native.cur || 'USD', + netRevenue: true, + creativeId: response_native.seatbid[0].bid[0].crid, + dealId: response_native.seatbid[0].bid[0].dealid, + mediaType: 'native', + native: {clickUrl: response_native.seatbid[0].bid[0].adm.native.link.url} + } + + let nativeResponses = spec.interpretResponse(nativeResponse); + + expect(nativeResponses).to.be.an('array').that.is.not.empty; + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'native', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType'); + expect(dataItem.requestId).to.equal(expectedBidResponse.requestId); + expect(dataItem.cpm).to.equal(expectedBidResponse.cpm); + expect(dataItem.native.clickUrl).to.equal(expectedBidResponse.native.clickUrl) + expect(dataItem.ttl).to.equal(expectedBidResponse.ttl); + expect(dataItem.creativeId).to.equal(expectedBidResponse.creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(expectedBidResponse.currency); + expect(dataItem.width).to.equal(expectedBidResponse.width); + expect(dataItem.height).to.equal(expectedBidResponse.height); + }); + }); +}) diff --git a/test/spec/modules/videonowBidAdapter_spec.js b/test/spec/modules/videonowBidAdapter_spec.js new file mode 100644 index 00000000000..c9eb5ba0bbf --- /dev/null +++ b/test/spec/modules/videonowBidAdapter_spec.js @@ -0,0 +1,80 @@ +import {expect} from 'chai'; +import {spec} from 'modules/videonowBidAdapter'; + +describe('videonowBidAdapter', function () { + it('minimal params', function () { + expect(spec.isBidRequestValid({ + bidder: 'videonow', + params: { + pId: 'advDesktopBillboard' + }})).to.equal(true) + }) + + it('minimal params no placementId', function () { + expect(spec.isBidRequestValid({ + bidder: 'videonow', + params: { + currency: `GBP` + }})).to.equal(false) + }) + + it('generated_params common case', function () { + const bidRequestData = [{ + bidId: 'bid1234', + bidder: 'videonow', + params: { + pId: 'advDesktopBillboard', + currency: `GBP` + }, + sizes: [[240, 400]] + }]; + + const request = spec.buildRequests(bidRequestData); + const req_data = request[0].data; + + expect(req_data.places[0].id).to.equal(`bid1234`) + expect(req_data.places[0].placementId).to.equal(`advDesktopBillboard`) + expect(req_data.settings.currency).to.equal(`GBP`) + expect(req_data.places[0].sizes[0][0]).to.equal(240); + expect(req_data.places[0].sizes[0][1]).to.equal(400); + }); + + it('response_params common case', function () { + const bidRequestData = { + data: { + bidId: 'bid1234' + } + }; + + const serverResponse = { + body: { + bids: [ + { + 'displayCode': 'test html', + 'id': '123456', + 'cpm': 375, + 'currency': 'RUB', + 'placementId': 'profileName', + 'codeType': 'js', + 'size': { + 'width': 640, + 'height': 480 + } + } + ] + } + }; + + const bids = spec.interpretResponse(serverResponse, bidRequestData); + expect(bids).to.have.lengthOf(1); + const bid = bids[0]; + expect(bid.requestId).to.equal('123456') + expect(bid.cpm).to.equal(375); + expect(bid.currency).to.equal('RUB'); + expect(bid.width).to.equal(640); + expect(bid.height).to.equal(480); + expect(bid.ad).to.equal('test html'); + expect(bid.creativeId).to.equal(`123456`) + expect(bid.netRevenue).to.equal(true); + }); +}) diff --git a/test/spec/modules/vidoomyBidAdapter_spec.js b/test/spec/modules/vidoomyBidAdapter_spec.js index 8aa127faef2..38fa872e6b8 100644 --- a/test/spec/modules/vidoomyBidAdapter_spec.js +++ b/test/spec/modules/vidoomyBidAdapter_spec.js @@ -74,6 +74,33 @@ describe('vidoomyBidAdapter', function() { 'sizes': [[300, 250], [200, 100]] } }, + 'schain': { + ver: '1.0', + complete: 1, + nodes: [ + { + 'asi': 'exchange1.com', + 'sid': '1234!abcd', + 'hp': 1, + 'rid': 'bid-request-1', + 'name': 'publisher, Inc.', + 'domain': 'publisher.com' + }, + { + 'asi': 'exchange2.com', + 'sid': 'abcd', + 'hp': 1 + }, + { + 'asi': 'exchange2.com', + 'sid': 'abcd', + 'hp': 1, + 'rid': 'bid-request-2', + 'name': 'intermediary', + 'domain': 'intermediary.com' + } + ] + } }, { 'bidder': 'vidoomy', @@ -95,7 +122,8 @@ describe('vidoomyBidAdapter', function() { refererInfo: { numIframes: 0, reachedTop: true, - referer: 'http://example.com', + domain: 'example.com', + page: 'http://example.com', stack: ['http://example.com'] } }; @@ -127,6 +155,119 @@ describe('vidoomyBidAdapter', function() { expect('' + request[1].data.id).to.equal('456456'); expect('' + request[1].data.pid).to.equal('456456'); }); + + it('should send schain parameter in serialized form', function () { + const serializedForm = '1.0,1!exchange1.com,1234%21abcd,1,bid-request-1,publisher%2C%20Inc.,publisher.com!exchange2.com,abcd,1,,,!exchange2.com,abcd,1,bid-request-2,intermediary,intermediary.com' + expect(request[0].data).to.include.any.keys('schain'); + expect(request[0].data.schain).to.eq(serializedForm); + }); + + it('should return standard json formated eids', function () { + const eids = [{ + source: 'pubcid.org', + uids: [ + { + id: 'some-random-id-value-1', + atype: 1 + } + ] + }, + { + source: 'adserver.org', + uids: [{ + id: 'some-random-id-value-2', + atype: 1 + }] + }] + bidRequests[0].userIdAsEids = eids + const bidRequest = spec.buildRequests(bidRequests, bidderRequest); + expect(bidRequest[0].data).to.include.any.keys('eids'); + expect(JSON.parse(bidRequest[0].data.eids)).to.eql(eids); + }); + + it('should set the bidfloor if getFloor module is undefined but static bidfloor is present', function () { + const request = { ...bidRequests[0], params: { bidfloor: 2.5 } } + const req = spec.buildRequests([request], bidderRequest)[0]; + expect(req.data).to.include.any.keys('bidfloor'); + expect(req.data.bidfloor).to.equal(2.5); + }); + + describe('floorModule', function () { + const getFloordata = { + 'currency': 'USD', + 'floor': 1.60 + }; + bidRequests[0].getFloor = _ => { + return getFloordata; + }; + it('should return getFloor.floor if present', function () { + const request = spec.buildRequests(bidRequests, bidderRequest)[0]; + expect(request.data.bidfloor).to.equal(getFloordata.floor); + }); + it('should return the getFloor.floor if it is greater than static bidfloor', function () { + const bidfloor = 1.40; + const request = { ...bidRequests[0] }; + request.params.bidfloor = bidfloor; + const bidRequest = spec.buildRequests([request], bidderRequest)[0]; + expect(bidRequest.data.bidfloor).to.equal(getFloordata.floor); + }); + it('should return the static bidfloor if it is greater than getFloor.floor', function () { + const bidfloor = 1.90; + const request = { ...bidRequests[0] }; + request.params.bidfloor = bidfloor; + const bidRequest = spec.buildRequests([request], bidderRequest)[0]; + expect(bidRequest.data.bidfloor).to.equal(bidfloor); + }); + }); + + describe('badv, bcat, bapp, btype, battr', function () { + const bidderRequestNew = { + ...bidderRequest, + bcat: ['EX1', 'EX2', 'EX3'], + badv: ['site.com'], + bapp: ['app.com'], + btype: [1, 2, 3], + battr: [1, 2, 3] + } + const request = spec.buildRequests(bidRequests, bidderRequestNew); + it('should have badv, bcat, bapp, btype, battr in request', function () { + expect(request[0].data).to.include.any.keys('badv'); + expect(request[0].data).to.include.any.keys('bcat'); + expect(request[0].data).to.include.any.keys('bapp'); + expect(request[0].data).to.include.any.keys('btype'); + expect(request[0].data).to.include.any.keys('battr'); + }) + + it('should have equal badv, bcat, bapp, btype, battr in request', function () { + expect(request[0].badv).to.deep.equal(bidderRequest.refererInfo.badv); + expect(request[0].bcat).to.deep.equal(bidderRequest.refererInfo.bcat); + expect(request[0].bapp).to.deep.equal(bidderRequest.refererInfo.bapp); + expect(request[0].btype).to.deep.equal(bidderRequest.refererInfo.btype); + expect(request[0].battr).to.deep.equal(bidderRequest.refererInfo.battr); + }) + }) + + describe('first party data', function () { + const bidderRequest2 = { + ...bidderRequest, + ortb2: { + bcat: ['EX1', 'EX2', 'EX3'], + badv: ['site.com'], + bapp: ['app.com'], + btype: [1, 2, 3], + battr: [1, 2, 3] + } + } + const request = spec.buildRequests(bidRequests, bidderRequest2); + + it('should have badv, bcat, bapp, btype, battr in request and equal to bidderRequest.ortb2', function () { + expect(request[0].data.bcat).to.deep.equal(bidderRequest2.ortb2.bcat) + expect(request[0].data.badv).to.deep.equal(bidderRequest2.ortb2.badv) + expect(request[0].data.bapp).to.deep.equal(bidderRequest2.ortb2.bapp); + expect(request[0].data.btype).to.deep.equal(bidderRequest2.ortb2.btype); + expect(request[0].data.battr).to.deep.equal(bidderRequest2.ortb2.battr); + }); + }); }); describe('interpretResponse', function () { diff --git a/test/spec/modules/viewability_spec.js b/test/spec/modules/viewability_spec.js deleted file mode 100644 index ab2753daf53..00000000000 --- a/test/spec/modules/viewability_spec.js +++ /dev/null @@ -1,280 +0,0 @@ -import { expect } from 'chai'; -import * as sinon from 'sinon'; -import * as utils from 'src/utils.js'; -import * as viewability from 'modules/viewability.js'; - -describe('viewability test', () => { - describe('start measurement', () => { - let sandbox; - let intersectionObserverStub; - let setTimeoutStub; - let observeCalled; - let unobserveCalled; - let ti = 1; - beforeEach(() => { - observeCalled = false; - unobserveCalled = false; - sandbox = sinon.sandbox.create(); - - let fakeIntersectionObserver = (stateChange, options) => { - return { - observe: (element) => { - observeCalled = true; - stateChange([{ isIntersecting: true }]); - }, - unobserve: (element) => { - unobserveCalled = true; - }, - }; - }; - - intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver); - setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => { - callback(); - return ti++; - }); - }); - - afterEach(() => { - sandbox.restore(); - }); - - it('should trigger appropriate callbacks', () => { - viewability.startMeasurement('0', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 }); - - sinon.assert.called(intersectionObserverStub); - sinon.assert.called(setTimeoutStub); - expect(observeCalled).to.equal(true); - expect(unobserveCalled).to.equal(true); - }); - - it('should trigger img tracker', () => { - let triggerPixelSpy = sandbox.spy(utils, ['triggerPixel']); - viewability.startMeasurement('1', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 }); - expect(triggerPixelSpy.callCount).to.equal(1); - }); - - it('should trigger js tracker', () => { - let insertHtmlIntoIframeSpy = sandbox.spy(utils, ['insertHtmlIntoIframe']); - viewability.startMeasurement('2', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 }); - expect(insertHtmlIntoIframeSpy.callCount).to.equal(1); - }); - - it('should trigger callback tracker', () => { - let callbackFired = false; - viewability.startMeasurement('3', {}, { method: 'callback', value: () => { callbackFired = true; } }, { inViewThreshold: 0.5, timeInView: 1000 }); - expect(callbackFired).to.equal(true); - }); - - it('should check for vid uniqueness', () => { - let logWarnSpy = sandbox.spy(utils, 'logWarn'); - viewability.startMeasurement('4', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 }); - expect(logWarnSpy.callCount).to.equal(0); - - viewability.startMeasurement('4', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 }); - expect(logWarnSpy.callCount).to.equal(1); - expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: must provide an unregistered vid`, '4')).to.equal(true); - }); - - it('should check for valid criteria', () => { - let logWarnSpy = sandbox.spy(utils, 'logWarn'); - viewability.startMeasurement('5', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { timeInView: 1000 }); - expect(logWarnSpy.callCount).to.equal(1); - expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: missing criteria`, { timeInView: 1000 })).to.equal(true); - }); - - it('should check for valid tracker', () => { - let logWarnSpy = sandbox.spy(utils, 'logWarn'); - viewability.startMeasurement('6', {}, { method: 'callback', value: 'string' }, { inViewThreshold: 0.5, timeInView: 1000 }); - expect(logWarnSpy.callCount).to.equal(1); - expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: invalid tracker`, { method: 'callback', value: 'string' })).to.equal(true); - }); - - it('should check if element provided', () => { - let logWarnSpy = sandbox.spy(utils, 'logWarn'); - viewability.startMeasurement('7', undefined, { method: 'js', value: 'http://my.tracker/123.js' }, { timeInView: 1000 }); - expect(logWarnSpy.callCount).to.equal(1); - expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: no html element provided`)).to.equal(true); - }); - }); - - describe('stop measurement', () => { - let sandbox; - let intersectionObserverStub; - let setTimeoutStub; - let clearTimeoutStub; - let observeCalled; - let unobserveCalled; - let stateChangeBackup; - let ti = 1; - beforeEach(() => { - observeCalled = false; - unobserveCalled = false; - sandbox = sinon.sandbox.create(); - - let fakeIntersectionObserver = (stateChange, options) => { - return { - observe: (element) => { - stateChangeBackup = stateChange; - observeCalled = true; - stateChange([{ isIntersecting: true }]); - }, - unobserve: (element) => { - unobserveCalled = true; - }, - }; - }; - - intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver); - setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => { - // skipping the callback - return ti++; - }); - clearTimeoutStub = sandbox.stub(window, 'clearTimeout').callsFake((timeoutId) => { }); - }); - - afterEach(() => { - sandbox.restore(); - }); - - it('should clear the timeout', () => { - viewability.startMeasurement('10', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 }); - stateChangeBackup([{ isIntersecting: false }]); - sinon.assert.called(intersectionObserverStub); - sinon.assert.called(setTimeoutStub); - sinon.assert.called(clearTimeoutStub); - expect(observeCalled).to.equal(true); - }); - - it('should unobserve', () => { - viewability.startMeasurement('11', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 }); - sinon.assert.called(intersectionObserverStub); - sinon.assert.called(setTimeoutStub); - expect(observeCalled).to.equal(true); - expect(unobserveCalled).to.equal(false); - - viewability.stopMeasurement('11'); - expect(unobserveCalled).to.equal(true); - sinon.assert.called(clearTimeoutStub); - }); - - it('should check for vid existence', () => { - let logWarnSpy = sandbox.spy(utils, 'logWarn'); - viewability.stopMeasurement('100'); - expect(logWarnSpy.callCount).to.equal(1); - expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: must provide a registered vid`, '100')).to.equal(true); - }); - }); - - describe('handle creative messages', () => { - let sandbox; - let intersectionObserverStub; - let setTimeoutStub; - let observeCalled; - let unobserveCalled; - let ti = 1; - let getElementsByTagStub; - let getElementByIdStub; - - let fakeContentWindow = {}; - beforeEach(() => { - observeCalled = false; - unobserveCalled = false; - sandbox = sinon.sandbox.create(); - - let fakeIntersectionObserver = (stateChange, options) => { - return { - observe: (element) => { - observeCalled = true; - stateChange([{ isIntersecting: true }]); - }, - unobserve: (element) => { - unobserveCalled = true; - }, - }; - }; - - intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver); - setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => { - callback(); - return ti++; - }); - - getElementsByTagStub = sandbox.stub(document, 'getElementsByTagName').callsFake((tagName) => { - return [{ - contentWindow: fakeContentWindow, - }]; - }); - getElementByIdStub = sandbox.stub(document, 'getElementById').callsFake((id) => { - return {}; - }); - }); - - afterEach(() => { - sandbox.restore(); - }); - - it('should find element by contentWindow', () => { - let viewabilityRecord = { - vid: 1000, - tracker: { - value: 'http://my.tracker/123', - method: 'img', - }, - criteria: { inViewThreshold: 0.5, timeInView: 1000 }, - message: 'Prebid Viewability', - action: 'startMeasurement', - }; - let data = JSON.stringify(viewabilityRecord); - - viewability.receiveMessage({ - data: data, - source: fakeContentWindow, - }); - - sinon.assert.called(getElementsByTagStub); - sinon.assert.called(intersectionObserverStub); - sinon.assert.called(setTimeoutStub); - expect(observeCalled).to.equal(true); - expect(unobserveCalled).to.equal(true); - }); - - it('should find element by id', () => { - let viewabilityRecord = { - vid: 1001, - tracker: { - value: 'http://my.tracker/123', - method: 'img', - }, - criteria: { inViewThreshold: 0.5, timeInView: 1000 }, - message: 'Prebid Viewability', - action: 'startMeasurement', - elementId: '1', - }; - let data = JSON.stringify(viewabilityRecord); - viewability.receiveMessage({ - data: data, - }); - - sinon.assert.called(getElementByIdStub); - sinon.assert.called(intersectionObserverStub); - sinon.assert.called(setTimeoutStub); - expect(observeCalled).to.equal(true); - expect(unobserveCalled).to.equal(true); - }); - - it('should stop measurement', () => { - let viewabilityRecord = { - vid: 1001, - message: 'Prebid Viewability', - action: 'stopMeasurement', - }; - let data = JSON.stringify(viewabilityRecord); - viewability.receiveMessage({ - data: data, - }); - - expect(unobserveCalled).to.equal(true); - }); - }); -}); diff --git a/test/spec/modules/viqeoBidAdapter_spec.js b/test/spec/modules/viqeoBidAdapter_spec.js new file mode 100644 index 00000000000..8f597318af9 --- /dev/null +++ b/test/spec/modules/viqeoBidAdapter_spec.js @@ -0,0 +1,124 @@ +import {expect} from 'chai'; +import {spec} from 'modules/viqeoBidAdapter'; + +describe('viqeoBidAdapter', function () { + it('minimal params', function () { + expect(spec.isBidRequestValid({ + bidder: 'viqeo', + params: { + user: { + buyeruid: '1', + }, + playerOptions: { + videoId: 'ed584da454c7205ca7e4', + profileId: 1382, + }, + }})).to.equal(true); + }); + it('minimal params no playerOptions', function () { + expect(spec.isBidRequestValid({ + bidder: 'viqeo', + params: { + currency: 'EUR', + }})).to.equal(false); + }); + it('build request check data', function () { + const bidRequestData = [{ + bidId: 'id1', + bidder: 'viqeo', + params: { + user: { + buyeruid: '1', + }, + currency: 'EUR', + floor: 0.5, + playerOptions: { + videoId: 'ed584da454c7205ca7e4', + profileId: 1382, + }, + }, + mediaTypes: { + video: { playerSize: [[240, 400]] } + }, + }]; + const request = spec.buildRequests(bidRequestData); + const requestData = request[0].data; + expect(requestData.id).to.equal('id1') + expect(requestData.imp[0].bidfloorcur).to.equal('EUR'); + expect(requestData.imp[0].bidfloor).to.equal(0.5); + expect(requestData.imp[0].video.w).to.equal(240); + expect(requestData.imp[0].video.h).to.equal(400); + expect(requestData.user.buyeruid).to.equal('1'); + }); + it('build request check url', function () { + const bidRequestData = [{ + bidder: 'viqeo', + params: { + playerOptions: { + videoId: 'ed584da454c7205ca7e4', + profileId: 1382, + }, + sspId: 42, + }, + mediaTypes: { + video: { playerSize: [[240, 400]] } + }, + }]; + const request = spec.buildRequests(bidRequestData); + expect(request[0].url).to.equal('https://ads.betweendigital.com/openrtb_bid/?sspId=42') + }); + it('response_params common case', function () { + const bidRequestData = { + bids: [{ + bidId: 'id1', + params: {}, + mediaTypes: { + video: { playerSize: [[240, 400]] } + }, + }], + }; + const serverResponse = { + body: { + id: 'id1', + cur: 'EUR', + seatbid: [{ + bid: [{ + cpm: 0.5, + ttl: 3600, + netRevenue: true, + creativeId: 'test1', + adm: '', + }], + }], + } + }; + const bids = spec.interpretResponse(serverResponse, bidRequestData); + expect(bids).to.have.lengthOf(1); + }); + it('should set flooPrice to getFloor.floor value if it is greater than params.floor', function() { + const bidRequestData = [{ + bidId: 'id1', + bidder: 'viqeo', + params: { + currency: 'EUR', + floor: 0.5, + playerOptions: { + videoId: 'ed584da454c7205ca7e4', + profileId: 1382, + }, + }, + mediaTypes: { + video: { playerSize: [[240, 400]] } + }, + getFloor: () => { + return { + currency: 'EUR', + floor: 3.32 + } + }, + }]; + const request = spec.buildRequests(bidRequestData); + const requestData = request[0].data; + expect(requestData.imp[0].bidfloor).to.equal(3.32) + }); +}); diff --git a/test/spec/modules/visiblemeasuresBidAdapter_spec.js b/test/spec/modules/visiblemeasuresBidAdapter_spec.js new file mode 100644 index 00000000000..ad75e17699f --- /dev/null +++ b/test/spec/modules/visiblemeasuresBidAdapter_spec.js @@ -0,0 +1,401 @@ +import { expect } from 'chai'; +import { spec } from '../../../modules/visiblemeasuresBidAdapter.js'; +import { BANNER, VIDEO, NATIVE } from '../../../src/mediaTypes.js'; +import { getUniqueIdentifierStr } from '../../../src/utils.js'; + +const bidder = 'visiblemeasures' +const adUrl = 'https://us-e.visiblemeasures.com/pbjs'; +const syncUrl = 'https://cs.visiblemeasures.com'; + +describe('VisibleMeasuresBidAdapter', function () { + const bids = [ + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + placementId: 'testBanner', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [VIDEO]: { + playerSize: [[300, 300]], + minduration: 5, + maxduration: 60 + } + }, + params: { + placementId: 'testVideo', + } + }, + { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [NATIVE]: { + native: { + title: { + required: true + }, + body: { + required: true + }, + icon: { + required: true, + size: [64, 64] + } + } + } + }, + params: { + placementId: 'testNative', + } + } + ]; + + const invalidBid = { + bidId: getUniqueIdentifierStr(), + bidder: bidder, + mediaTypes: { + [BANNER]: { + sizes: [[300, 250]] + } + }, + params: { + + } + } + + const bidderRequest = { + uspConsent: '1---', + gdprConsent: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + refererInfo: { + referer: 'https://test.com' + }, + timeout: 500 + }; + + describe('isBidRequestValid', function () { + it('Should return true if there are bidId, params and key parameters present', function () { + expect(spec.isBidRequestValid(bids[0])).to.be.true; + }); + it('Should return false if at least one of parameters is not present', function () { + expect(spec.isBidRequestValid(invalidBid)).to.be.false; + }); + }); + + describe('buildRequests', function () { + let serverRequest = spec.buildRequests(bids, bidderRequest); + + it('Creates a ServerRequest object with method, URL and data', function () { + expect(serverRequest).to.exist; + expect(serverRequest.method).to.exist; + expect(serverRequest.url).to.exist; + expect(serverRequest.data).to.exist; + }); + + it('Returns POST method', function () { + expect(serverRequest.method).to.equal('POST'); + }); + + it('Returns valid URL', function () { + expect(serverRequest.url).to.equal(adUrl); + }); + + it('Returns general data valid', function () { + let data = serverRequest.data; + expect(data).to.be.an('object'); + expect(data).to.have.all.keys('deviceWidth', + 'deviceHeight', + 'language', + 'secure', + 'host', + 'page', + 'placements', + 'coppa', + 'ccpa', + 'gdpr', + 'tmax' + ); + expect(data.deviceWidth).to.be.a('number'); + expect(data.deviceHeight).to.be.a('number'); + expect(data.language).to.be.a('string'); + expect(data.secure).to.be.within(0, 1); + expect(data.host).to.be.a('string'); + expect(data.page).to.be.a('string'); + expect(data.coppa).to.be.a('number'); + expect(data.gdpr).to.be.a('string'); + expect(data.ccpa).to.be.a('string'); + expect(data.tmax).to.be.a('number'); + expect(data.placements).to.have.lengthOf(3); + }); + + it('Returns valid placements', function () { + const { placements } = serverRequest.data; + for (let i = 0, len = placements.length; i < len; i++) { + const placement = placements[i]; + expect(placement.placementId).to.be.oneOf(['testBanner', 'testVideo', 'testNative']); + expect(placement.adFormat).to.be.oneOf([BANNER, VIDEO, NATIVE]); + expect(placement.bidId).to.be.a('string'); + expect(placement.schain).to.be.an('object'); + expect(placement.bidfloor).to.exist.and.to.equal(0); + expect(placement.type).to.exist.and.to.equal('publisher'); + + if (placement.adFormat === BANNER) { + expect(placement.sizes).to.be.an('array'); + } + switch (placement.adFormat) { + case BANNER: + expect(placement.sizes).to.be.an('array'); + break; + case VIDEO: + expect(placement.playerSize).to.be.an('array'); + expect(placement.minduration).to.be.an('number'); + expect(placement.maxduration).to.be.an('number'); + break; + case NATIVE: + expect(placement.native).to.be.an('object'); + break; + } + } + }); + + it('Returns data with gdprConsent and without uspConsent', function () { + delete bidderRequest.uspConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.gdpr).to.exist; + expect(data.gdpr).to.be.a('string'); + expect(data.gdpr).to.equal(bidderRequest.gdprConsent); + expect(data.ccpa).to.not.exist; + delete bidderRequest.gdprConsent; + }); + + it('Returns data with uspConsent and without gdprConsent', function () { + bidderRequest.uspConsent = '1---'; + delete bidderRequest.gdprConsent; + serverRequest = spec.buildRequests(bids, bidderRequest); + let data = serverRequest.data; + expect(data.ccpa).to.exist; + expect(data.ccpa).to.be.a('string'); + expect(data.ccpa).to.equal(bidderRequest.uspConsent); + expect(data.gdpr).to.not.exist; + }); + + it('Returns empty data if no valid requests are passed', function () { + serverRequest = spec.buildRequests([], bidderRequest); + let data = serverRequest.data; + expect(data.placements).to.be.an('array').that.is.empty; + }); + }); + + describe('interpretResponse', function () { + it('Should interpret banner response', function () { + const banner = { + body: [{ + mediaType: 'banner', + width: 300, + height: 250, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let bannerResponses = spec.interpretResponse(banner); + expect(bannerResponses).to.be.an('array').that.is.not.empty; + let dataItem = bannerResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal(banner.body[0].requestId); + expect(dataItem.cpm).to.equal(banner.body[0].cpm); + expect(dataItem.width).to.equal(banner.body[0].width); + expect(dataItem.height).to.equal(banner.body[0].height); + expect(dataItem.ad).to.equal(banner.body[0].ad); + expect(dataItem.ttl).to.equal(banner.body[0].ttl); + expect(dataItem.creativeId).to.equal(banner.body[0].creativeId); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal(banner.body[0].currency); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret video response', function () { + const video = { + body: [{ + vastUrl: 'test.com', + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let videoResponses = spec.interpretResponse(video); + expect(videoResponses).to.be.an('array').that.is.not.empty; + + let dataItem = videoResponses[0]; + expect(dataItem).to.have.all.keys('requestId', 'cpm', 'vastUrl', 'ttl', 'creativeId', + 'netRevenue', 'currency', 'dealId', 'mediaType', 'meta'); + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.5); + expect(dataItem.vastUrl).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should interpret native response', function () { + const native = { + body: [{ + mediaType: 'native', + native: { + clickUrl: 'test.com', + title: 'Test', + image: 'test.com', + impressionTrackers: ['test.com'], + }, + ttl: 120, + cpm: 0.4, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + meta: { + advertiserDomains: ['google.com'], + advertiserId: 1234 + } + }] + }; + let nativeResponses = spec.interpretResponse(native); + expect(nativeResponses).to.be.an('array').that.is.not.empty; + + let dataItem = nativeResponses[0]; + expect(dataItem).to.have.keys('requestId', 'cpm', 'ttl', 'creativeId', 'netRevenue', 'currency', 'mediaType', 'native', 'meta'); + expect(dataItem.native).to.have.keys('clickUrl', 'impressionTrackers', 'title', 'image') + expect(dataItem.requestId).to.equal('23fhj33i987f'); + expect(dataItem.cpm).to.equal(0.4); + expect(dataItem.native.clickUrl).to.equal('test.com'); + expect(dataItem.native.title).to.equal('Test'); + expect(dataItem.native.image).to.equal('test.com'); + expect(dataItem.native.impressionTrackers).to.be.an('array').that.is.not.empty; + expect(dataItem.native.impressionTrackers[0]).to.equal('test.com'); + expect(dataItem.ttl).to.equal(120); + expect(dataItem.creativeId).to.equal('2'); + expect(dataItem.netRevenue).to.be.true; + expect(dataItem.currency).to.equal('USD'); + expect(dataItem.meta).to.be.an('object').that.has.any.key('advertiserDomains'); + }); + it('Should return an empty array if invalid banner response is passed', function () { + const invBanner = { + body: [{ + width: 300, + cpm: 0.4, + ad: 'Test', + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + + let serverResponses = spec.interpretResponse(invBanner); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid video response is passed', function () { + const invVideo = { + body: [{ + mediaType: 'video', + cpm: 0.5, + requestId: '23fhj33i987f', + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invVideo); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid native response is passed', function () { + const invNative = { + body: [{ + mediaType: 'native', + clickUrl: 'test.com', + title: 'Test', + impressionTrackers: ['test.com'], + ttl: 120, + requestId: '23fhj33i987f', + creativeId: '2', + netRevenue: true, + currency: 'USD', + }] + }; + let serverResponses = spec.interpretResponse(invNative); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + it('Should return an empty array if invalid response is passed', function () { + const invalid = { + body: [{ + ttl: 120, + creativeId: '2', + netRevenue: true, + currency: 'USD', + dealId: '1' + }] + }; + let serverResponses = spec.interpretResponse(invalid); + expect(serverResponses).to.be.an('array').that.is.empty; + }); + }); + + describe('getUserSyncs', function() { + it('Should return array of objects with proper sync config , include GDPR', function() { + const syncData = spec.getUserSyncs({}, {}, { + consentString: 'ALL', + gdprApplies: true, + }, {}); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal(`${syncUrl}/image?pbjs=1&gdpr=1&gdpr_consent=ALL&coppa=0`) + }); + it('Should return array of objects with proper sync config , include CCPA', function() { + const syncData = spec.getUserSyncs({}, {}, {}, { + consentString: '1---' + }); + expect(syncData).to.be.an('array').which.is.not.empty; + expect(syncData[0]).to.be.an('object') + expect(syncData[0].type).to.be.a('string') + expect(syncData[0].type).to.equal('image') + expect(syncData[0].url).to.be.a('string') + expect(syncData[0].url).to.equal(`${syncUrl}/image?pbjs=1&ccpa_consent=1---&coppa=0`) + }); + }); +}); diff --git a/test/spec/modules/visxBidAdapter_spec.js b/test/spec/modules/visxBidAdapter_spec.js index 4aaaf996f58..139349ceead 100755 --- a/test/spec/modules/visxBidAdapter_spec.js +++ b/test/spec/modules/visxBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec } from 'modules/visxBidAdapter.js'; +import { spec, storage } from 'modules/visxBidAdapter.js'; import { config } from 'src/config.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import * as utils from 'src/utils.js'; @@ -82,13 +82,16 @@ describe('VisxAdapter', function () { }); return res; } + + let cookiesAreEnabledStub, localStorageIsEnabledStub; + const bidderRequest = { timeout: 3000, refererInfo: { - referer: 'https://example.com' + page: 'https://example.com' } }; - const referrer = bidderRequest.refererInfo.referer; + const referrer = bidderRequest.refererInfo.page; const schainObject = { ver: '1.0', nodes: [ @@ -180,6 +183,24 @@ describe('VisxAdapter', function () { 'ext': {'bidder': {'uid': 903537}} }]; + before(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + visx: { + storageAllowed: false + } + }; + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + localStorageIsEnabledStub.returns(false); + cookiesAreEnabledStub.returns(false); + }); + + after(() => { + localStorageIsEnabledStub.restore(); + cookiesAreEnabledStub.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + it('should attach valid params to the tag', function () { const firstBid = bidRequests[0]; const bids = [firstBid]; @@ -422,13 +443,14 @@ describe('VisxAdapter', function () { }); return res; } + let cookiesAreEnabledStub, localStorageIsEnabledStub; const bidderRequest = { timeout: 3000, refererInfo: { - referer: 'https://example.com' + page: 'https://example.com' } }; - const referrer = bidderRequest.refererInfo.referer; + const referrer = bidderRequest.refererInfo.page; const bidRequests = [ { 'bidder': 'visx', @@ -449,6 +471,24 @@ describe('VisxAdapter', function () { } ]; + before(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + visx: { + storageAllowed: false + } + }; + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + localStorageIsEnabledStub.returns(false); + cookiesAreEnabledStub.returns(false); + }); + + after(() => { + localStorageIsEnabledStub.restore(); + cookiesAreEnabledStub.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + it('should send requst for banner bid', function () { const request = spec.buildRequests([bidRequests[0]], bidderRequest); const payload = parseRequest(request.url); @@ -486,13 +526,14 @@ describe('VisxAdapter', function () { }); return res; } + let cookiesAreEnabledStub, localStorageIsEnabledStub; const bidderRequest = { timeout: 3000, refererInfo: { - referer: 'https://example.com' + page: 'https://example.com' } }; - const referrer = bidderRequest.refererInfo.referer; + const referrer = bidderRequest.refererInfo.page; const bidRequests = [ { 'bidder': 'visx', @@ -529,10 +570,23 @@ describe('VisxAdapter', function () { documentStub.withArgs('visx-adunit-element-2').returns({ id: 'visx-adunit-element-2' }); + + $$PREBID_GLOBAL$$.bidderSettings = { + visx: { + storageAllowed: false + } + }; + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + localStorageIsEnabledStub.returns(false); + cookiesAreEnabledStub.returns(false); }); after(function() { sandbox.restore(); + localStorageIsEnabledStub.restore(); + cookiesAreEnabledStub.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; }); it('should find ad slot by ad unit code as element id', function () { @@ -1273,7 +1327,7 @@ describe('VisxAdapter', function () { it('onTimeout', function () { const data = [{ timeout: 3000, adUnitCode: 'adunit-code-1', auctionId: '1cbd2feafe5e8b', bidder: 'visx', bidId: '23423', params: [{ uid: '1' }] }]; - const expectedData = [{ ...data[0], params: [{ uid: 1 }] }]; + const expectedData = [{ timeout: 3000, params: [{ uid: 1 }] }]; spec.onTimeout(data); expect(utils.triggerPixel.calledOnceWith('https://t.visx.net/track/bid_timeout//' + JSON.stringify(expectedData))).to.equal(true); }); @@ -1323,4 +1377,100 @@ describe('VisxAdapter', function () { expect(query).to.deep.equal({}); }); }); + + describe('first party user id', function () { + const USER_ID_KEY = '__vads'; + const USER_ID_DUMMY_VALUE_COOKIE = 'dummy_id_cookie'; + const USER_ID_DUMMY_VALUE_LOCAL_STORAGE = 'dummy_id_local_storage'; + + let getDataFromLocalStorageStub, localStorageIsEnabledStub; + let getCookieStub, cookiesAreEnabledStub; + + const bidRequests = [ + { + 'bidder': 'visx', + 'params': { + 'uid': 903535 + }, + 'adUnitCode': 'adunit-code-1', + 'sizes': [[300, 250], [300, 600]], + 'bidId': '30b31c1838de1e', + 'bidderRequestId': '22edbae2733bf6', + 'auctionId': '1d1a030790a475', + } + ]; + const bidderRequest = { + timeout: 3000, + refererInfo: { + page: 'https://example.com' + } + }; + + beforeEach(() => { + $$PREBID_GLOBAL$$.bidderSettings = { + visx: { + storageAllowed: true + } + }; + cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); + localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); + }); + + afterEach(() => { + cookiesAreEnabledStub.restore(); + localStorageIsEnabledStub.restore(); + getCookieStub && getCookieStub.restore(); + getDataFromLocalStorageStub && getDataFromLocalStorageStub.restore(); + $$PREBID_GLOBAL$$.bidderSettings = {}; + }); + + it('should not pass user id if both cookies and local storage are not available', function () { + cookiesAreEnabledStub.returns(false); + localStorageIsEnabledStub.returns(false); + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.user).to.be.undefined; + }); + + it('should get user id from cookie if available', function () { + cookiesAreEnabledStub.returns(true); + localStorageIsEnabledStub.returns(false); + getCookieStub = sinon.stub(storage, 'getCookie'); + getCookieStub.withArgs(USER_ID_KEY).returns(USER_ID_DUMMY_VALUE_COOKIE); + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.user.ext.vads).to.equal(USER_ID_DUMMY_VALUE_COOKIE); + }); + + it('should get user id from local storage if available', function () { + cookiesAreEnabledStub.returns(false); + localStorageIsEnabledStub.returns(true); + getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); + getDataFromLocalStorageStub.withArgs(USER_ID_KEY).returns(USER_ID_DUMMY_VALUE_LOCAL_STORAGE); + + const request = spec.buildRequests(bidRequests, bidderRequest); + + expect(request.data.user.ext.vads).to.equal(USER_ID_DUMMY_VALUE_LOCAL_STORAGE); + }); + + it('should create user id and store it in cookies (if user id does not exist)', function () { + cookiesAreEnabledStub.returns(true); + localStorageIsEnabledStub.returns(false); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(storage.getCookie(USER_ID_KEY)).to.be.a('string'); + expect(request.data.user.ext.vads).to.be.a('string'); + }); + + it('should create user id and store it in local storage (if user id does not exist)', function () { + cookiesAreEnabledStub.returns(false); + localStorageIsEnabledStub.returns(true); + + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(storage.getDataFromLocalStorage(USER_ID_KEY)).to.be.a('string'); + expect(request.data.user.ext.vads).to.be.a('string'); + }); + }); }); diff --git a/test/spec/modules/voxBidAdapter_spec.js b/test/spec/modules/voxBidAdapter_spec.js index 6906c7dbba4..5f4ada06c65 100644 --- a/test/spec/modules/voxBidAdapter_spec.js +++ b/test/spec/modules/voxBidAdapter_spec.js @@ -1,5 +1,6 @@ import { expect } from 'chai' import { spec } from 'modules/voxBidAdapter.js' +import {config} from 'src/config.js' function getSlotConfigs(mediaTypes, params) { return { @@ -15,7 +16,7 @@ function getSlotConfigs(mediaTypes, params) { describe('VOX Adapter', function() { const PLACE_ID = '5af45ad34d506ee7acad0c26'; const bidderRequest = { - refererInfo: { referer: 'referer' } + refererInfo: { page: 'referer' } } const bannerMandatoryParams = { placementId: PLACE_ID, @@ -175,6 +176,98 @@ describe('VOX Adapter', function() { expect(bid.transactionId).to.equal('31a58515-3634-4e90-9c96-f86196db1459') }) }) + it('should not set userid if not specified', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + data.bidRequests.forEach(bid => { + expect(bid.userId).to.be.undefined + }) + }) + + it('should set userid if specified', function () { + const requests = validBidRequests.map(bid => ({ + ...bid, + userId: { + tdid: 'TDID_USER_ID', + pubcid: 'PUBID_USER_ID' + } + })) + const request = spec.buildRequests(requests, bidderRequest) + const data = JSON.parse(request.data) + data.bidRequests.forEach(bid => { + expect(bid.userId.tdid).to.equal('TDID_USER_ID') + expect(bid.userId.pubcid).to.equal('PUBID_USER_ID') + }) + }) + + it('should not set schain if not specified', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + data.bidRequests.forEach(bid => { + expect(bid.schain).to.be.undefined + }) + }) + + it('should set schain if not specified', function () { + const requests = validBidRequests.map(bid => ({ + ...bid, + schain: { + validation: 'strict', + config: { + ver: '1.0' + } + } + })) + const request = spec.buildRequests(requests, bidderRequest) + const data = JSON.parse(request.data) + data.bidRequests.forEach(bid => { + expect(bid.schain.validation).to.equal('strict') + expect(bid.schain.config.ver).to.equal('1.0') + }) + }) + + describe('price floors', function () { + it('should be empty if floors module not configured', function () { + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + data.bidRequests.forEach(bid => { + expect(bid.floorInfo).to.be.empty + }) + }) + + it('should add correct floor values', function () { + const expectedFloors = [ 2, 2.7, 1.4 ] + const validBidRequests = expectedFloors.map(getBidWithFloor) + const request = spec.buildRequests(validBidRequests, bidderRequest) + const data = JSON.parse(request.data) + expectedFloors.forEach((floor, index) => { + expect(data.bidRequests[index].floorInfo.floor).to.equal(floor) + expect(data.bidRequests[index].floorInfo.currency).to.equal('USD') + }) + }) + + it('should request floor price in adserver currency', function () { + const configCurrency = 'DKK' + config.setConfig({ currency: { adServerCurrency: configCurrency } }) + const request = spec.buildRequests([ getBidWithFloor() ], bidderRequest) + const data = JSON.parse(request.data) + data.bidRequests.forEach(bid => { + expect(bid.floorInfo.currency).to.equal(configCurrency) + }) + }) + + function getBidWithFloor(floor) { + return { + ...validBidRequests[0], + getFloor: ({ currency }) => { + return { + currency: currency, + floor + } + } + } + } + }) describe('GDPR params', function() { describe('when there are not consent management platform', function() { diff --git a/test/spec/modules/vrtcalBidAdapter_spec.js b/test/spec/modules/vrtcalBidAdapter_spec.js index 66440130860..cc4dc0a3882 100644 --- a/test/spec/modules/vrtcalBidAdapter_spec.js +++ b/test/spec/modules/vrtcalBidAdapter_spec.js @@ -1,6 +1,8 @@ import { expect } from 'chai' import { spec } from 'modules/vrtcalBidAdapter' import { newBidder } from 'src/adapters/bidderFactory' +import { config } from 'src/config.js'; +import { createEidsArray } from 'modules/userId/eids.js'; describe('vrtcalBidAdapter', function () { const adapter = newBidder(spec) @@ -26,6 +28,13 @@ describe('vrtcalBidAdapter', function () { 'bidId': 'bidID0001', 'bidderRequestId': 'br0001', 'auctionId': 'auction0001', + 'userIdAsEids': {}, + timeout: 435, + + refererInfo: { + page: 'page' + } + } ]; @@ -50,6 +59,41 @@ describe('vrtcalBidAdapter', function () { request = spec.buildRequests(bidRequests); expect(request[0].data).to.match(/"bidfloor":0.55/); }); + + it('pass GDPR,CCPA,COPPA, and GPP indicators/consent strings with the request when present', function () { + bidRequests[0].gdprConsent = {consentString: 'gdpr-consent-string', gdprApplies: true}; + bidRequests[0].uspConsent = 'ccpa-consent-string'; + config.setConfig({ coppa: false }); + + bidRequests[0].ortb2 = { + regs: { + gpp: 'testGpp', + gpp_sid: [1, 2, 3] + } + } + + request = spec.buildRequests(bidRequests); + expect(request[0].data).to.match(/"user":{"ext":{"consent":"gdpr-consent-string"/); + expect(request[0].data).to.match(/"regs":{"coppa":0,"ext":{"gdpr":1,"us_privacy":"ccpa-consent-string","gpp":"testGpp","gpp_sid":\[1,2,3\]}}/); + }); + + it('pass bidder timeout/tmax with the request', function () { + config.setConfig({ bidderTimeout: 435 }); + request = spec.buildRequests(bidRequests); + expect(request[0].data).to.match(/"tmax":435/); + }); + + it('pass 3rd party IDs with the request when present', function () { + bidRequests[0].userIdAsEids = [ + { + source: 'adserver.org', + uids: [{id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: {rtiPartner: 'TDID'}}] + } + ]; + + request = spec.buildRequests(bidRequests); + expect(request[0].data).to.include(JSON.stringify({ext: {consent: 'gdpr-consent-string', eids: [{source: 'adserver.org', uids: [{id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: {rtiPartner: 'TDID'}}]}]}})); + }); }); describe('interpretResponse', function () { @@ -67,7 +111,7 @@ describe('vrtcalBidAdapter', function () { w: 300, h: 250, crid: 'v2_1064_vrt_vrtcaltestdisplay2_300_250', - adomain: ['vrtcal.com'] + adomain: ['vrtcal.com'], }], seat: '16' }], diff --git a/test/spec/modules/vuukleBidAdapter_spec.js b/test/spec/modules/vuukleBidAdapter_spec.js index 17353a40b85..32ba74867bb 100644 --- a/test/spec/modules/vuukleBidAdapter_spec.js +++ b/test/spec/modules/vuukleBidAdapter_spec.js @@ -1,5 +1,6 @@ import { expect } from 'chai'; import { spec } from 'modules/vuukleBidAdapter.js'; +import { config } from '../../../src/config.js'; describe('vuukleBidAdapterTests', function() { let bidRequestData = { @@ -34,6 +35,13 @@ describe('vuukleBidAdapterTests', function() { expect(req_data.bidId).to.equal('testbid'); }); + it('validate_generated_params_tmax', function() { + request = spec.buildRequests(bidRequestData.bids, {timeout: 1234}); + let req_data = request[0].data; + + expect(req_data.tmax).to.equal(1234); + }); + it('validate_response_params', function() { let serverResponse = { body: { @@ -58,4 +66,83 @@ describe('vuukleBidAdapterTests', function() { expect(bid.creativeId).to.equal('12345'); expect(bid.meta.advertiserDomains).to.deep.equal(['example.com']); }); + + describe('consent handling', function() { + const bidderRequest = { + gdprConsent: { + consentString: 'COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw', + gdprApplies: 1, + vendorData: { + vendor: { + consents: { + 1004: 1 + } + } + } + } + } + + it('must handle consent 1/1', function() { + request = spec.buildRequests(bidRequestData.bids, bidderRequest); + let req_data = request[0].data; + + expect(req_data.gdpr).to.equal(1); + expect(req_data.consentGiven).to.equal(1); + expect(req_data.consent).to.equal('COvFyGBOvFyGBAbAAAENAPCAAOAAAAAAAAAAAEEUACCKAAA.IFoEUQQgAIQwgIwQABAEAAAAOIAACAIAAAAQAIAgEAACEAAAAAgAQBAAAAAAAGBAAgAAAAAAAFAAECAAAgAAQARAEQAAAAAJAAIAAgAAAYQEAAAQmAgBC3ZAYzUw'); + }) + + it('must handle consent 0/1', function() { + bidderRequest.gdprConsent.gdprApplies = 0; + request = spec.buildRequests(bidRequestData.bids, bidderRequest); + let req_data = request[0].data; + + expect(req_data.gdpr).to.equal(0); + expect(req_data.consentGiven).to.equal(1); + }) + + it('must handle consent 0/0', function() { + bidderRequest.gdprConsent.gdprApplies = 0; + bidderRequest.gdprConsent.vendorData = undefined; + request = spec.buildRequests(bidRequestData.bids, bidderRequest); + let req_data = request[0].data; + + expect(req_data.gdpr).to.equal(0); + expect(req_data.consentGiven).to.equal(0); + }) + + it('must handle consent undef', function() { + request = spec.buildRequests(bidRequestData.bids, {}); + let req_data = request[0].data; + + expect(req_data.gdpr).to.equal(0); + expect(req_data.consentGiven).to.equal(0); + }) + }) + + it('must handle usp consent', function() { + request = spec.buildRequests(bidRequestData.bids, {uspConsent: '1YNN'}); + let req_data = request[0].data; + + expect(req_data.uspConsent).to.equal('1YNN'); + }) + + it('must handle undefined usp consent', function() { + request = spec.buildRequests(bidRequestData.bids, {}); + let req_data = request[0].data; + + expect(req_data.uspConsent).to.equal(undefined); + }) + + it('must handle coppa flag', function() { + sinon.stub(config, 'getConfig') + .withArgs('coppa') + .returns(true); + + request = spec.buildRequests(bidRequestData.bids); + let req_data = request[0].data; + + expect(req_data.coppa).to.equal(1); + + config.getConfig.restore(); + }) }); diff --git a/test/spec/modules/weboramaRtdProvider_spec.js b/test/spec/modules/weboramaRtdProvider_spec.js index 0f0af4efe2f..7de8474d7c9 100644 --- a/test/spec/modules/weboramaRtdProvider_spec.js +++ b/test/spec/modules/weboramaRtdProvider_spec.js @@ -6,23 +6,19 @@ import { } from 'test/mocks/xhr.js'; import { storage, - DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY + DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY, + DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY } from '../../../modules/weboramaRtdProvider.js'; -import { - config -} from 'src/config.js'; -import { - getGlobal -} from 'src/prebidGlobal.js'; + import 'src/prebid.js'; const responseHeader = { 'Content-Type': 'application/json' }; -describe('weboramaRtdProvider', function () { - describe('weboramaSubmodule', function () { - it('successfully instantiates and call contextual api', function () { +describe('weboramaRtdProvider', function() { + describe('weboramaSubmodule', function() { + it('successfully instantiates and call contextual api', function() { const moduleConfig = { params: { weboCtxConf: { @@ -35,7 +31,7 @@ describe('weboramaRtdProvider', function () { expect(weboramaSubmodule.init(moduleConfig)).to.equal(true); }); - it('instantiate without contextual token should fail', function () { + it('instantiate without contextual token should fail', function() { const moduleConfig = { params: { weboCtxConf: {} @@ -44,7 +40,7 @@ describe('weboramaRtdProvider', function () { expect(weboramaSubmodule.init(moduleConfig)).to.equal(false); }); - it('instantiate with empty weboUserData conf should return true', function () { + it('instantiate with empty weboUserData conf should return true', function() { const moduleConfig = { params: { weboUserDataConf: {} @@ -54,35 +50,33 @@ describe('weboramaRtdProvider', function () { }); }); - describe('Handle Set Targeting', function () { + describe('Handle Set Targeting and Bid Request', function() { let sandbox; - beforeEach(function () { + beforeEach(function() { sandbox = sinon.sandbox.create(); - storage.removeDataFromLocalStorage('webo_wam2gam_entry'); + storage.removeDataFromLocalStorage(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY); - getGlobal().setConfig({ - ortb2: undefined - }); + storage.removeDataFromLocalStorage(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY); }); - afterEach(function () { + afterEach(function() { sandbox.restore(); }); - describe('Add Contextual Data', function () { - it('should set gam targeting and send to bidders by default', function () { + describe('Add site-centric data (contextual)', function() { + it('should set gam targeting and send to bidders by default', function() { let onDataResponse = {}; const moduleConfig = { params: { weboCtxConf: { token: 'foo', targetURL: 'https://prebid.org', - onData: (data, site) => { + onData: (data, meta) => { onDataResponse = { data: data, - site: site, + meta: meta, }; }, } @@ -92,9 +86,14 @@ describe('weboramaRtdProvider', function () { webo_ctx: ['foo', 'bar'], webo_ds: ['baz'], }; - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver' }, { @@ -124,90 +123,78 @@ describe('weboramaRtdProvider', function () { expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ 'adunit1': data, - 'adunit2': data, }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_ctx=foo;webo_ctx=bar;webo_ds=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_ctx=foo,bar|webo_ds=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: data - }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, - site: true, + meta: { + user: false, + source: 'contextual', + isDefault: false, + }, }); }); - it('should set gam targeting but not send to bidders with setPrebidTargeting=true/sendToBidders=false', function () { + it('should use asset id when available and set gam targeting and send to bidders by default', function() { + let onDataResponse = {}; const moduleConfig = { params: { weboCtxConf: { token: 'foo', + assetID: 'datasource:docId', targetURL: 'https://prebid.org', - setPrebidTargeting: true, - sendToBidders: false, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, } } }; const data = { - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], + webo_vctx: ['foo', 'bar'], }; - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, adUnits: [{ + code: adUnitCode, bids: [{ - bidder: 'smartadserver', - params: { - target: 'foo=bar' - } + bidder: 'smartadserver' }, { - bidder: 'pubmatic', - params: { - dctr: 'foo=bar' - } + bidder: 'pubmatic' }, { - bidder: 'appnexus', - params: { - keywords: { - foo: ['bar'] - } - } + bidder: 'appnexus' }, { - bidder: 'rubicon', - params: { - inventory: { - foo: 'bar', - }, - visitor: { - baz: 'bam', - } - } + bidder: 'rubicon' }, { - bidder: 'other', + bidder: 'other' }] }] }; + const onDoneSpy = sinon.spy(); expect(weboramaSubmodule.init(moduleConfig)).to.be.true; @@ -216,72 +203,85 @@ describe('weboramaRtdProvider', function () { let request = server.requests[0]; expect(request.method).to.equal('GET'); - expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.url).to.equal('https://ctx.weborama.com/api/document-profile?token=foo&assetId=datasource%3AdocId&url=https%3A%2F%2Fprebid.org&'); expect(request.withCredentials).to.be.false; request.respond(200, responseHeader, JSON.stringify(data)); expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ 'adunit1': data, - 'adunit2': data, }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ - foo: ['bar'] - }); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: { - foo: 'bar', + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'contextual', + isDefault: false, }, - visitor: { - baz: 'bam', - } }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.be.undefined; - expect(getGlobal().getConfig('ortb2')).to.be.undefined; }); - it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function () { + it('should use asset id as callback when available and set gam targeting and send to bidders by default', function() { let onDataResponse = {}; const moduleConfig = { params: { - setPrebidTargeting: false, - sendToBidders: false, - onData: (data, site) => { - onDataResponse = { - data: data, - site: site, - }; - }, weboCtxConf: { token: 'foo', + assetID: () => 'datasource:docId', targetURL: 'https://prebid.org', - setPrebidTargeting: true, // submodule parameter will override module parameter + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, } } }; const data = { - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], + webo_vctx: ['foo', 'bar'], }; - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, adUnits: [{ + code: adUnitCode, bids: [{ - bidder: 'smartadserver', - params: { - target: 'foo=bar' - } + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' }] }] }; + const onDoneSpy = sinon.spy(); expect(weboramaSubmodule.init(moduleConfig)).to.be.true; @@ -290,156 +290,124 @@ describe('weboramaRtdProvider', function () { let request = server.requests[0]; expect(request.method).to.equal('GET'); - expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.url).to.equal('https://ctx.weborama.com/api/document-profile?token=foo&assetId=datasource%3AdocId&url=https%3A%2F%2Fprebid.org&'); expect(request.withCredentials).to.be.false; request.respond(200, responseHeader, JSON.stringify(data)); expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ 'adunit1': data, - 'adunit2': data, }); - expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1); - expect(getGlobal().getConfig('ortb2')).to.be.undefined; - + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ data: data, - site: true, + meta: { + user: false, + source: 'contextual', + isDefault: false, + }, }); }); - it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function () { + it('should handle exception from asset id callback', function() { + let onDataResponse = {}; const moduleConfig = { params: { weboCtxConf: { token: 'foo', + assetID: () => { + throw new Error('ops'); + }, targetURL: 'https://prebid.org', - setPrebidTargeting: false, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, } } }; - const data = { - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], - }; - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, adUnits: [{ + code: adUnitCode, bids: [{ - bidder: 'smartadserver', - params: { - target: 'foo=bar' - } + bidder: 'smartadserver' }, { - bidder: 'pubmatic', - params: { - dctr: 'foo=bar' - } + bidder: 'pubmatic' }, { - bidder: 'appnexus', - params: { - keywords: { - foo: ['bar'] - } - } + bidder: 'appnexus' }, { - bidder: 'rubicon', - params: { - inventory: { - foo: 'bar', - }, - visitor: { - baz: 'bam', - } - } + bidder: 'rubicon' }, { - bidder: 'other', + bidder: 'other' }] }] - } + }; + const onDoneSpy = sinon.spy(); expect(weboramaSubmodule.init(moduleConfig)).to.be.true; weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); - let request = server.requests[0]; - - expect(request.method).to.equal('GET'); - expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); - expect(request.withCredentials).to.be.false; - - request.respond(200, responseHeader, JSON.stringify(data)); + expect(server.requests.length).to.equal(0); expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({}); - - expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_ctx=foo;webo_ctx=bar;webo_ds=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar|webo_ctx=foo,bar|webo_ds=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ - foo: ['bar'], - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], - }); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: { - foo: 'bar', - webo_ctx: ['foo', 'bar'], - webo_ds: ['baz'], - }, - visitor: { - baz: 'bam', - } - }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - site: { - ext: { - data: data - }, - } - }); }); - it('should use default profile in case of api error', function () { - const defaultProfile = { - webo_ctx: ['baz'], - }; + it('should handle case when callback return falsy value', function() { let onDataResponse = {}; const moduleConfig = { params: { weboCtxConf: { token: 'foo', + assetID: () => '', targetURL: 'https://prebid.org', - setPrebidTargeting: true, - defaultProfile: defaultProfile, - onData: (data, site) => { + onData: (data, meta) => { onDataResponse = { data: data, - site: site, + meta: meta, }; }, } } }; - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver' }, { @@ -453,89 +421,1806 @@ describe('weboramaRtdProvider', function () { }] }] }; + const onDoneSpy = sinon.spy(); expect(weboramaSubmodule.init(moduleConfig)).to.be.true; weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); - let request = server.requests[0]; + expect(server.requests.length).to.equal(0); - expect(request.method).to.equal('GET'); - expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); - expect(request.withCredentials).to.be.false; + expect(onDoneSpy.calledOnce).to.be.true; - request.respond(500, responseHeader); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); - expect(onDoneSpy.calledOnce).to.be.true; + expect(targeting).to.deep.equal({}); + }); - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + describe('should set gam targeting and send to one specific bidder and multiple adunits', function() { + const testcases = { + 'single string': 'appnexus', + 'array with one entry': ['appnexus'], + 'map with one entry': { + 'appnexus': true + }, + 'map complete': { + 'smartadserver': false, + 'pubmatic': false, + 'appnexus': true, + 'rubicon': false, + 'other': false, + }, + 'callback': (bid) => { + return bid.bidder == 'appnexus' + }, + }; - expect(targeting).to.deep.equal({ - 'adunit1': defaultProfile, - 'adunit2': defaultProfile, - }); + Object.keys(testcases).forEach(label => { + const sendToBidders = testcases[label]; + it(`check sendToBidders as ${label}`, function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + sendToBidders: sendToBidders, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[2].params.keywords).to.deep.equal(data); + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + + return; + } - expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_ctx=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_ctx=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: defaultProfile - }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - site: { - ext: { - data: defaultProfile - }, - } - }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - site: { - ext: { - data: defaultProfile - }, - } - }); - expect(onDataResponse).to.deep.equal({ - data: defaultProfile, - site: true, + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'contextual', + isDefault: false, + }, + }); + }); }); }); - }); - describe('Add user-centric data (WAM2GAM)', function () { - it('should set gam targeting from local storage and send to bidders by default', function () { - let onDataResponse = {}; - const moduleConfig = { - params: { - weboUserDataConf: { - accountID: 12345, - onData: (data, site) => { - onDataResponse = { - data: data, - site: site, - }; - }, - } - } - }; - const data = { - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], + describe('should set gam targeting and send to one specific bidder and one adunit', function() { + const testcases = { + 'map with one entry': { + 'appnexus': ['adunit1'] + }, + 'callback': (bid, adUnitCode) => { + return bid.bidder == 'appnexus' && adUnitCode == 'adunit1'; + }, }; - const entry = { - targeting: data, + Object.keys(testcases).forEach(label => { + const sendToBidders = testcases[label]; + it(`check sendToBidders as ${label}`, function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + sendToBidders: sendToBidders, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + expect(adUnit.bids[4].ortb2).to.be.undefined; + }); + + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'contextual', + isDefault: false, + }, + }); + }); + }); + }); + + describe('should set gam targeting for multiple adunits but not send to bidders with setPrebidTargeting=/sendToBidders=false', function() { + const testcases = { + 'boolean': true, + 'array with both units': ['adunit1', 'adunit2'], + 'callback': () => { + return true; + }, + }; + + Object.keys(testcases).forEach(label => { + const setPrebidTargeting = testcases[label]; + it(`check setPrebidTargeting as ${label}`, function() { + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + setPrebidTargeting: setPrebidTargeting, + sendToBidders: false, + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + } + }, { + bidder: 'other', + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + } + }, { + bidder: 'other', + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params.target).to.equal('foo=bar'); + expect(adUnit.bids[1].params.dctr).to.equal('foo=bar'); + expect(adUnit.bids[2].params.keywords).to.deep.equal({ + foo: ['bar'] + }); + expect(adUnit.bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + }); + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + }); + }); + }); + + describe('should set gam targeting for one adunit but not send to bidders with setPrebidTargeting=/sendToBidders=false', function() { + const testcases = { + 'array with one unit': ['adunit1'], + 'callback': (adUnitCode) => { + return adUnitCode == 'adunit1'; + }, + }; + + Object.keys(testcases).forEach(label => { + const setPrebidTargeting = testcases[label]; + it(`check setPrebidTargeting as ${label}`, function() { + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + setPrebidTargeting: setPrebidTargeting, + sendToBidders: false, + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + } + }, { + bidder: 'other', + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + } + }, { + bidder: 'other', + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': {}, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params.target).to.equal('foo=bar'); + expect(adUnit.bids[1].params.dctr).to.equal('foo=bar'); + expect(adUnit.bids[2].params.keywords).to.deep.equal({ + foo: ['bar'] + }); + expect(adUnit.bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + }); + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + }); + }); + }); + + it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + setPrebidTargeting: false, + sendToBidders: false, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + setPrebidTargeting: true, // submodule parameter will override module parameter + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {} + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1); + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'contextual', + isDefault: false, + }, + }); + }); + + it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() { + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + setPrebidTargeting: false, + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + } + }, { + bidder: 'other', + }] + }] + } + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': {}, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ + foo: ['bar'], + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) + }); + + it('should use default profile in case of api error', function() { + const defaultProfile = { + webo_ctx: ['baz'], + }; + let onDataResponse = {}; + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + setPrebidTargeting: true, + defaultProfile: defaultProfile, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(500, responseHeader); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': defaultProfile, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile + }, + } + }); + }) + expect(onDataResponse).to.deep.equal({ + data: defaultProfile, + meta: { + user: false, + source: 'contextual', + isDefault: true, + }, + }); + }); + + it('should be possible update profile from callbacks for a given bidder/adUnitCode', function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + weboCtxConf: { + token: 'foo', + targetURL: 'https://prebid.org', + setPrebidTargeting: (adUnitCode, data, meta) => { + if (adUnitCode == 'adunit1') { + data['webo_foo'] = ['bar']; + } + return true; + }, + sendToBidders: (bid, adUnitCode, data, meta) => { + if (bid.bidder == 'appnexus' && adUnitCode == 'adunit1') { + data['webo_bar'] = ['baz']; + } + return true; + }, + baseURLProfileAPI: 'ctx.test.weborama.com', + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + }; + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + let request = server.requests[0]; + + expect(request.method).to.equal('GET'); + expect(request.url).to.equal('https://ctx.test.weborama.com/api/profile?token=foo&url=https%3A%2F%2Fprebid.org&'); + expect(request.withCredentials).to.be.false; + + request.respond(200, responseHeader, JSON.stringify(data)); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + webo_foo: ['bar'], + }, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: { + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + webo_bar: ['baz'], + } + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ + webo_ctx: ['foo', 'bar'], + webo_ds: ['baz'], + webo_bar: ['baz'], + }); + expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data); + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'contextual', + isDefault: false, + }, + }); + }); + }); + + describe('Add user-centric data (wam)', function() { + it('should set gam targeting from local storage and send to bidders by default', function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + weboUserDataConf: { + accoundId: 12345, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + }) + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: true, + source: 'wam', + isDefault: false, + }, + }); + }); + + describe('should set gam targeting from local storage and send to one specific bidder and multiple adunits', function() { + const testcases = { + 'single string': 'appnexus', + 'array with one entry': ['appnexus'], + 'map with one entry': { + 'appnexus': true + }, + 'map complete': { + 'smartadserver': false, + 'pubmatic': false, + 'appnexus': true, + 'rubicon': false, + 'other': false, + }, + 'callback': (bid) => { + return bid.bidder == 'appnexus' + }, + }; + + Object.keys(testcases).forEach(label => { + const sendToBidders = testcases[label]; + it(`check sendToBidders as ${label}`, function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + weboUserDataConf: { + accountId: 12345, + sendToBidders: sendToBidders, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[2].params.keywords).to.deep.equal(data); + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: true, + source: 'wam', + isDefault: false, + }, + }); + }); + }); + }); + + describe('should set gam targeting from local storage and send to one specific bidder and one adunit', function() { + const testcases = { + 'map with one entry': { + 'appnexus': ['adunit1'] + }, + 'callback': (bid, adUnitCode) => { + return bid.bidder == 'appnexus' && adUnitCode == 'adunit1'; + }, + }; + + Object.keys(testcases).forEach(label => { + const sendToBidders = testcases[label]; + it(`check sendToBidders as ${label}`, function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + weboUserDataConf: { + accountId: 12345, + sendToBidders: sendToBidders, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: true, + source: 'wam', + isDefault: false, + }, + }); + }); + }); + }); + + describe('should set gam targeting for multiple adunits but not send to bidders with setPrebidTargeting=/sendToBidders=false', function() { + const testcases = { + 'boolean': true, + 'array with both units': ['adunit1', 'adunit2'], + 'callback': () => { + return true; + }, + }; + + Object.keys(testcases).forEach(label => { + const setPrebidTargeting = testcases[label]; + it(`check setPrebidTargeting as ${label}`, function() { + const moduleConfig = { + params: { + weboUserDataConf: { + accoundId: 12345, + setPrebidTargeting: setPrebidTargeting, + sendToBidders: false + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params.target).to.equal('foo=bar'); + expect(adUnit.bids[1].params.dctr).to.equal('foo=bar'); + expect(adUnit.bids[2].params.keywords).to.deep.equal({ + foo: ['bar'] + }); + expect(adUnit.bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + }); + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + }); + }); + }); + + describe('should set gam targeting for one adunit but not send to bidders with setPrebidTargeting=/sendToBidders=false', function() { + const testcases = { + 'array with one unit': ['adunit1'], + 'callback': (adUnitCode) => { + return adUnitCode == 'adunit1'; + }, + }; + + Object.keys(testcases).forEach(label => { + const setPrebidTargeting = testcases[label]; + it(`check setPrebidTargeting as ${label}`, function() { + const moduleConfig = { + params: { + weboUserDataConf: { + accoundId: 12345, + setPrebidTargeting: setPrebidTargeting, + sendToBidders: false + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': {}, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params.target).to.equal('foo=bar'); + expect(adUnit.bids[1].params.dctr).to.equal('foo=bar'); + expect(adUnit.bids[2].params.keywords).to.deep.equal({ + foo: ['bar'] + }); + expect(adUnit.bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + }); + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + }); + }); + }); + + it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + setPrebidTargeting: false, + sendToBidders: false, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + weboUserDataConf: { + accoundId: 12345, + setPrebidTargeting: true, // submodule parameter will override module parameter + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: true, + source: 'wam', + isDefault: false, + }, + }); + }); + + it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() { + const moduleConfig = { + params: { + weboUserDataConf: { + accoundId: 12345, + setPrebidTargeting: false, + } + } + }; + const data = { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }; + + const entry = { + targeting: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + } + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': {}, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ + foo: ['bar'], + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + }); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar', + }, + visitor: { + baz: 'bam', + } + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + }) + }); + + it('should use default profile in case of nothing on local storage', function() { + const defaultProfile = { + webo_audiences: ['baz'] + }; + const moduleConfig = { + params: { + weboUserDataConf: { + accoundId: 12345, + setPrebidTargeting: true, + defaultProfile: defaultProfile, + } + } }; + sandbox.stub(storage, 'hasLocalStorage').returns(true); sandbox.stub(storage, 'localStorageIsEnabled').returns(true); - sandbox.stub(storage, 'getDataFromLocalStorage') - .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) - .returns(JSON.stringify(entry)); - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver' }, { @@ -556,46 +2241,135 @@ describe('weboramaRtdProvider', function () { expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ - 'adunit1': data, - 'adunit2': data, + 'adunit1': defaultProfile, }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_cs=foo;webo_cs=bar;webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_cs=foo,bar|webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - visitor: data - }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - user: { - ext: { - data: data - }, - } - }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - user: { - ext: { - data: data - }, + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: defaultProfile + }, + } + }); + }) + }); + + it('should use default profile if cant read from local storage', function() { + const defaultProfile = { + webo_audiences: ['baz'] + }; + let onDataResponse = {}; + const moduleConfig = { + params: { + weboUserDataConf: { + accoundId: 12345, + setPrebidTargeting: true, + defaultProfile: defaultProfile, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } } + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {} + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': defaultProfile, }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: defaultProfile + }, + } + }); + }) expect(onDataResponse).to.deep.equal({ - data: data, - site: false, + data: defaultProfile, + meta: { + user: true, + source: 'wam', + isDefault: true, + }, }); }); - it('should set gam targeting but not send to bidders with setPrebidTargeting=true/sendToBidders=false', function () { + it('should be possible update profile from callbacks for a given bidder/adUnitCode', function() { + let onDataResponse = {}; const moduleConfig = { params: { weboUserDataConf: { - setPrebidTargeting: true, - sendToBidders: false + accoundId: 12345, + targetURL: 'https://prebid.org', + setPrebidTargeting: (adUnitCode, data, meta) => { + if (adUnitCode == 'adunit1') { + data['webo_foo'] = ['bar']; + } + return true; + }, + sendToBidders: (bid, adUnitCode, data, meta) => { + if (bid.bidder == 'appnexus' && adUnitCode == 'adunit1') { + data['webo_bar'] = ['baz']; + } + return true; + }, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, } } }; @@ -608,112 +2382,790 @@ describe('weboramaRtdProvider', function () { targeting: data, }; + sandbox.stub(storage, 'hasLocalStorage').returns(true); sandbox.stub(storage, 'localStorageIsEnabled').returns(true); sandbox.stub(storage, 'getDataFromLocalStorage') .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) .returns(JSON.stringify(entry)); - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, adUnits: [{ + code: adUnitCode1, bids: [{ - bidder: 'smartadserver', + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + webo_foo: ['bar'], + }, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: { + webo_cs: ['foo', 'bar'], + webo_audiences: ['baz'], + webo_bar: ['baz'], + } + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + user: { + ext: { + data: data + }, + } + }); + }) + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: true, + source: 'wam', + isDefault: false, + }, + }); + }); + }); + + describe('Add support to sfbx lite', function() { + it('should set gam targeting from local storage and send to bidders by default', function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + sfbxLiteDataConf: { + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }; + + const entry = { + webo: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + }); + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'lite', + isDefault: false, + }, + }); + }); + + describe('should set gam targeting from local storage and send to one specific bidder and multiple adunits', function() { + const testcases = { + 'single string': 'appnexus', + 'array with one entry': ['appnexus'], + 'map with one entry': { + 'appnexus': true + }, + 'map complete': { + 'smartadserver': false, + 'pubmatic': false, + 'appnexus': true, + 'rubicon': false, + 'other': false, + }, + 'callback': (bid) => { + return bid.bidder == 'appnexus' + }, + }; + + Object.keys(testcases).forEach(label => { + const sendToBidders = testcases[label]; + it(`check sendToBidders as ${label}`, function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + sfbxLiteDataConf: { + sendToBidders: sendToBidders, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } + } + }; + const data = { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }; + + const entry = { + webo: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[2].params.keywords).to.deep.equal(data); + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + + return + } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'lite', + isDefault: false, + }, + }); + }); + }); + }); + + describe('should set gam targeting from local storage and send to one specific bidder and one adunit', function() { + const testcases = { + 'map with one entry': { + 'appnexus': ['adunit1'] + }, + 'callback': (bid, adUnitCode) => { + return bid.bidder == 'appnexus' && adUnitCode == 'adunit1'; + }, + }; + + Object.keys(testcases).forEach(label => { + const sendToBidders = testcases[label]; + it(`check sendToBidders as ${label}`, function() { + let onDataResponse = {}; + const moduleConfig = { params: { - target: 'foo=bar' + sfbxLiteDataConf: { + sendToBidders: sendToBidders, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } } - }, { - bidder: 'pubmatic', - params: { - dctr: 'foo=bar' + }; + const data = { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }; + + const entry = { + webo: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(data); + expect(reqBidsConfigObj.adUnits[1].bids[2].params).to.be.undefined; + + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + + return } - }, { - bidder: 'appnexus', + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + + expect(onDataResponse).to.deep.equal({ + data: data, + meta: { + user: false, + source: 'lite', + isDefault: false, + }, + }); + }); + }); + }); + + describe('should set gam targeting for multiple adunits but not send to bidders with setPrebidTargeting=/sendToBidders=false', function() { + const testcases = { + 'boolean': true, + 'array with both units': ['adunit1', 'adunit2'], + 'callback': () => { + return true; + }, + }; + + Object.keys(testcases).forEach(label => { + const setPrebidTargeting = testcases[label]; + it(`check setPrebidTargeting as ${label}`, function() { + const moduleConfig = { params: { - keywords: { - foo: ['bar'] + sfbxLiteDataConf: { + setPrebidTargeting: setPrebidTargeting, + sendToBidders: false } } - }, { - bidder: 'rubicon', - params: { + }; + const data = { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }; + + const entry = { + webo: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': data, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params.target).to.equal('foo=bar'); + expect(adUnit.bids[1].params.dctr).to.equal('foo=bar'); + expect(adUnit.bids[2].params.keywords).to.deep.equal({ + foo: ['bar'] + }); + expect(adUnit.bids[3].params).to.deep.equal({ inventory: { foo: 'bar' }, visitor: { baz: 'bam' } - } - }, { - bidder: 'other' - }] - }] - }; - const onDoneSpy = sinon.spy(); - - expect(weboramaSubmodule.init(moduleConfig)).to.be.true; - weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); - - expect(onDoneSpy.calledOnce).to.be.true; - - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); - - expect(targeting).to.deep.equal({ - 'adunit1': data, - 'adunit2': data, + }); + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + }); }); + }); - expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); - expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ - foo: ['bar'] - }); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - inventory: { - foo: 'bar' + describe('should set gam targeting for one adunit but not send to bidders with setPrebidTargeting=/sendToBidders=false', function() { + const testcases = { + 'array with one unit': ['adunit1'], + 'callback': (adUnitCode) => { + return adUnitCode == 'adunit1'; }, - visitor: { - baz: 'bam' - } + }; + + Object.keys(testcases).forEach(label => { + const setPrebidTargeting = testcases[label]; + it(`check setPrebidTargeting as ${label}`, function() { + const moduleConfig = { + params: { + sfbxLiteDataConf: { + setPrebidTargeting: setPrebidTargeting, + sendToBidders: false + } + } + }; + const data = { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }; + + const entry = { + webo: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver', + params: { + target: 'foo=bar' + } + }, { + bidder: 'pubmatic', + params: { + dctr: 'foo=bar' + } + }, { + bidder: 'appnexus', + params: { + keywords: { + foo: ['bar'] + } + } + }, { + bidder: 'rubicon', + params: { + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + } + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': data, + 'adunit2': {}, + }); + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params.target).to.equal('foo=bar'); + expect(adUnit.bids[1].params.dctr).to.equal('foo=bar'); + expect(adUnit.bids[2].params.keywords).to.deep.equal({ + foo: ['bar'] + }); + expect(adUnit.bids[3].params).to.deep.equal({ + inventory: { + foo: 'bar' + }, + visitor: { + baz: 'bam' + } + }); + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.be.undefined; + }) + }); }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.be.undefined; - expect(getGlobal().getConfig('ortb2')).to.be.undefined; }); - it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function () { + it('should set gam targeting but not send to bidders with (submodule override) setPrebidTargeting=true/(global) sendToBidders=false', function() { let onDataResponse = {}; const moduleConfig = { params: { setPrebidTargeting: false, sendToBidders: false, - onData: (data, site) => { + onData: (data, meta) => { onDataResponse = { data: data, - site: site, + meta: meta, }; }, - weboUserDataConf: { + sfbxLiteDataConf: { setPrebidTargeting: true, // submodule parameter will override module parameter } } }; const data = { - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], }; const entry = { - targeting: data, + webo: data, }; + sandbox.stub(storage, 'hasLocalStorage').returns(true); sandbox.stub(storage, 'localStorageIsEnabled').returns(true); sandbox.stub(storage, 'getDataFromLocalStorage') - .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) .returns(JSON.stringify(entry)); - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver', params: { @@ -729,47 +3181,55 @@ describe('weboramaRtdProvider', function () { expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ 'adunit1': data, - 'adunit2': data, }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(1); expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); - expect(getGlobal().getConfig('ortb2')).to.be.undefined; expect(onDataResponse).to.deep.equal({ data: data, - site: false, + meta: { + user: false, + source: 'lite', + isDefault: false, + }, }); }); - it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function () { + it('should not set gam targeting with setPrebidTargeting=false but send to bidders', function() { const moduleConfig = { params: { - weboUserDataConf: { + sfbxLiteDataConf: { setPrebidTargeting: false, } } }; const data = { - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], }; const entry = { - targeting: data, + webo: data, }; + sandbox.stub(storage, 'hasLocalStorage').returns(true); sandbox.stub(storage, 'localStorageIsEnabled').returns(true); sandbox.stub(storage, 'getDataFromLocalStorage') - .withArgs(DEFAULT_LOCAL_STORAGE_USER_PROFILE_KEY) + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) .returns(JSON.stringify(entry)); - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver', params: { @@ -809,17 +3269,19 @@ describe('weboramaRtdProvider', function () { expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); - expect(targeting).to.deep.equal({}); + expect(targeting).to.deep.equal({ + 'adunit1': {}, + }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar;webo_cs=foo;webo_cs=bar;webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar|webo_cs=foo,bar|webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('foo=bar'); + expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('foo=bar'); expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ foo: ['bar'], - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], }); expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ inventory: { @@ -827,44 +3289,43 @@ describe('weboramaRtdProvider', function () { }, visitor: { baz: 'bam', - webo_cs: ['foo', 'bar'], - webo_audiences: ['baz'], - } - }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - user: { - ext: { - data: data - }, - } - }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - user: { - ext: { - data: data - }, } }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data + }, + } + }); + }) }); - it('should use default profile in case of nothing on local storage', function () { + it('should use default profile in case of nothing on local storage', function() { const defaultProfile = { - webo_audiences: ['baz'] + lite_hobbies: ['sport', 'cinéma'], }; const moduleConfig = { params: { - weboUserDataConf: { + sfbxLiteDataConf: { setPrebidTargeting: true, defaultProfile: defaultProfile, } } }; + sandbox.stub(storage, 'hasLocalStorage').returns(true); sandbox.stub(storage, 'localStorageIsEnabled').returns(true); - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver' }, { @@ -885,61 +3346,146 @@ describe('weboramaRtdProvider', function () { expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ 'adunit1': defaultProfile, - 'adunit2': defaultProfile, }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - visitor: defaultProfile - }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - user: { - ext: { - data: defaultProfile - }, + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile + }, + } + }); + }) + }); + + it('should use default profile if cant read from local storage', function() { + const defaultProfile = { + lite_hobbies: ['sport', 'cinéma'], + }; + let onDataResponse = {}; + const moduleConfig = { + params: { + sfbxLiteDataConf: { + setPrebidTargeting: true, + defaultProfile: defaultProfile, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } } + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + + const adUnitCode = 'adunit1'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': defaultProfile, }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - user: { + + expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + expect(reqBidsConfigObj.ortb2Fragments.bidder.other).to.deep.equal({ + site: { ext: { - data: defaultProfile + data: defaultProfile, }, - } + }, + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile, + }, + } + }); + }) + expect(onDataResponse).to.deep.equal({ + data: defaultProfile, + meta: { + user: false, + source: 'lite', + isDefault: true, + }, }); }); - it('should use default profile if cant read from local storage', function () { + it('should use default profile if has no local storage', function() { const defaultProfile = { - webo_audiences: ['baz'] + lite_hobbies: ['sport', 'cinéma'], }; let onDataResponse = {}; const moduleConfig = { params: { - weboUserDataConf: { + sfbxLiteDataConf: { setPrebidTargeting: true, defaultProfile: defaultProfile, - onData: (data, site) => { + onData: (data, meta) => { onDataResponse = { data: data, - site: site, + meta: meta, }; }, } } }; - sandbox.stub(storage, 'localStorageIsEnabled').returns(false); + sandbox.stub(storage, 'hasLocalStorage').returns(false); - const adUnitsCodes = ['adunit1', 'adunit2']; + const adUnitCode = 'adunit1'; const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, adUnits: [{ + code: adUnitCode, bids: [{ bidder: 'smartadserver' }, { @@ -960,37 +3506,177 @@ describe('weboramaRtdProvider', function () { expect(onDoneSpy.calledOnce).to.be.true; - const targeting = weboramaSubmodule.getTargetingData(adUnitsCodes, moduleConfig); + const targeting = weboramaSubmodule.getTargetingData([adUnitCode], moduleConfig); expect(targeting).to.deep.equal({ 'adunit1': defaultProfile, - 'adunit2': defaultProfile, }); expect(reqBidsConfigObj.adUnits[0].bids.length).to.equal(5); - expect(reqBidsConfigObj.adUnits[0].bids[0].params.target).to.equal('webo_audiences=baz'); - expect(reqBidsConfigObj.adUnits[0].bids[1].params.dctr).to.equal('webo_audiences=baz'); + expect(reqBidsConfigObj.adUnits[0].bids[0].params).to.be.undefined; + expect(reqBidsConfigObj.adUnits[0].bids[1].params).to.be.undefined; expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal(defaultProfile); - expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.deep.equal({ - visitor: defaultProfile + expect(reqBidsConfigObj.adUnits[0].bids[3].params).to.be.undefined; + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: defaultProfile + }, + } + }); + }) + expect(onDataResponse).to.deep.equal({ + data: defaultProfile, + meta: { + user: false, + source: 'lite', + isDefault: true, + }, }); - expect(reqBidsConfigObj.adUnits[0].bids[4].ortb2).to.deep.equal({ - user: { - ext: { - data: defaultProfile - }, + }); + it('should be possible update profile from callbacks for a given bidder/adUnitCode', function() { + let onDataResponse = {}; + const moduleConfig = { + params: { + sfbxLiteDataConf: { + targetURL: 'https://prebid.org', + setPrebidTargeting: (adUnitCode, data, meta) => { + if (adUnitCode == 'adunit1') { + data['lito_foo'] = ['bar']; + } + return true; + }, + sendToBidders: (bid, adUnitCode, data, meta) => { + if (bid.bidder == 'appnexus' && adUnitCode == 'adunit1') { + data['lito_bar'] = ['baz']; + } + return true; + }, + onData: (data, meta) => { + onDataResponse = { + data: data, + meta: meta, + }; + }, + } } + }; + const data = { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + }; + + const entry = { + webo: data, + }; + + sandbox.stub(storage, 'hasLocalStorage').returns(true); + sandbox.stub(storage, 'localStorageIsEnabled').returns(true); + sandbox.stub(storage, 'getDataFromLocalStorage') + .withArgs(DEFAULT_LOCAL_STORAGE_LITE_PROFILE_KEY) + .returns(JSON.stringify(entry)); + + const adUnitCode1 = 'adunit1'; + const adUnitCode2 = 'adunit2'; + const reqBidsConfigObj = { + ortb2Fragments: { + global: {}, + bidder: {}, + }, + adUnits: [{ + code: adUnitCode1, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }, { + code: adUnitCode2, + bids: [{ + bidder: 'smartadserver' + }, { + bidder: 'pubmatic' + }, { + bidder: 'appnexus' + }, { + bidder: 'rubicon' + }, { + bidder: 'other' + }] + }] + }; + + const onDoneSpy = sinon.spy(); + + expect(weboramaSubmodule.init(moduleConfig)).to.be.true; + weboramaSubmodule.getBidRequestData(reqBidsConfigObj, onDoneSpy, moduleConfig); + + expect(onDoneSpy.calledOnce).to.be.true; + + const targeting = weboramaSubmodule.getTargetingData([adUnitCode1, adUnitCode2], moduleConfig); + + expect(targeting).to.deep.equal({ + 'adunit1': { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + lito_foo: ['bar'], + }, + 'adunit2': data, }); - expect(getGlobal().getConfig('ortb2')).to.deep.equal({ - user: { - ext: { - data: defaultProfile - }, + + reqBidsConfigObj.adUnits.forEach(adUnit => { + expect(adUnit.bids.length).to.equal(5); + expect(adUnit.bids[0].params).to.be.undefined; + expect(adUnit.bids[1].params).to.be.undefined; + expect(adUnit.bids[3].params).to.be.undefined; + }); + ['smartadserver', 'pubmatic', 'appnexus', 'rubicon', 'other'].forEach((v) => { + if (v == 'appnexus') { + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: { + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + lito_bar: ['baz'], + }, + }, + } + }); + + return } + + expect(reqBidsConfigObj.ortb2Fragments.bidder[v]).to.deep.equal({ + site: { + ext: { + data: data, + }, + } + }); + }) + + expect(reqBidsConfigObj.adUnits[0].bids[2].params.keywords).to.deep.equal({ + lite_occupation: ['gérant', 'bénévole'], + lite_hobbies: ['sport', 'cinéma'], + lito_bar: ['baz'], }); + expect(reqBidsConfigObj.adUnits[1].bids[2].params.keywords).to.deep.equal(data); + expect(onDataResponse).to.deep.equal({ - data: defaultProfile, - site: false, + data: data, + meta: { + user: false, + source: 'lite', + isDefault: false, + }, }); }); }); diff --git a/test/spec/modules/winrBidAdapter_spec.js b/test/spec/modules/winrBidAdapter_spec.js index 03e441df727..95d1473d1cb 100644 --- a/test/spec/modules/winrBidAdapter_spec.js +++ b/test/spec/modules/winrBidAdapter_spec.js @@ -434,7 +434,7 @@ describe('WinrAdapter', function () { const bidRequest = Object.assign({}, bidRequests[0]) const bidderRequest = { refererInfo: { - referer: 'https://example.com/page.html', + topmostLocation: 'https://example.com/page.html', reachedTop: true, numIframes: 2, stack: [ @@ -563,11 +563,7 @@ describe('WinrAdapter', function () { uid2: { id: 'sample-uid2-value' }, criteoId: 'sample-criteo-userid', netId: 'sample-netId-userid', - idl_env: 'sample-idl-userid', - flocId: { - id: 'sample-flocid-value', - version: 'chrome.1.0' - } + idl_env: 'sample-idl-userid' } }); @@ -584,11 +580,6 @@ describe('WinrAdapter', function () { id: 'sample-criteo-userid', }); - expect(payload.eids).to.deep.include({ - source: 'chrome.com', - id: 'sample-flocid-value' - }); - expect(payload.eids).to.deep.include({ source: 'netid.de', id: 'sample-netId-userid', @@ -608,15 +599,6 @@ describe('WinrAdapter', function () { }); describe('interpretResponse', function () { - let bfStub; - before(function() { - bfStub = sinon.stub(bidderFactory, 'getIabSubCategory'); - }); - - after(function() { - bfStub.restore(); - }); - let response = { 'version': '3.0.0', 'tags': [ diff --git a/test/spec/modules/xeBidAdapter_spec.js b/test/spec/modules/xeBidAdapter_spec.js new file mode 100644 index 00000000000..914b0cacd71 --- /dev/null +++ b/test/spec/modules/xeBidAdapter_spec.js @@ -0,0 +1,452 @@ +import { expect } from 'chai'; +import { config } from 'src/config.js'; +import { spec, getBidFloor } from 'modules/xeBidAdapter.js'; +import { deepClone } from 'src/utils'; +import { createEidsArray } from 'modules/userId/eids.js'; + +const ENDPOINT = 'https://pbjs.xe.works/bid'; + +const defaultRequest = { + adUnitCode: 'test', + bidId: '1', + requestId: 'qwerty', + auctionId: 'auctionId', + ortb2Imp: { + ext: { + tid: 'tr1', + } + }, + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 200] + ] + } + }, + bidder: 'xe', + params: { + env: 'xe', + placement: 'test-banner', + ext: {} + }, + bidRequestsCount: 1 +}; + +const defaultRequestVideo = deepClone(defaultRequest); +defaultRequestVideo.mediaTypes = { + video: { + playerSize: [640, 480], + context: 'instream', + skipppable: true + } +}; +describe('xeBidAdapter', () => { + describe('isBidRequestValid', function () { + it('should return false when request params is missing', function () { + const invalidRequest = deepClone(defaultRequest); + delete invalidRequest.params; + expect(spec.isBidRequestValid(invalidRequest)).to.equal(false); + }); + + it('should return false when required env param is missing', function () { + const invalidRequest = deepClone(defaultRequest); + delete invalidRequest.params.env; + expect(spec.isBidRequestValid(invalidRequest)).to.equal(false); + }); + + it('should return false when required placement param is missing', function () { + const invalidRequest = deepClone(defaultRequest); + delete invalidRequest.params.placement; + expect(spec.isBidRequestValid(invalidRequest)).to.equal(false); + }); + + it('should return false when video.playerSize is missing', function () { + const invalidRequest = deepClone(defaultRequestVideo); + delete invalidRequest.mediaTypes.video.playerSize; + expect(spec.isBidRequestValid(invalidRequest)).to.equal(false); + }); + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(defaultRequest)).to.equal(true); + }); + }); + + describe('buildRequests', function () { + beforeEach(function () { + config.resetConfig(); + }); + + it('should send request with correct structure', function () { + const request = spec.buildRequests([defaultRequest], {}); + expect(request.method).to.equal('POST'); + expect(request.url).to.equal(ENDPOINT); + expect(request.options).to.have.property('contentType').and.to.equal('application/json'); + expect(request).to.have.property('data'); + }); + + it('should build basic request structure', function () { + const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0]; + expect(request).to.have.property('bidId').and.to.equal(defaultRequest.bidId); + expect(request).to.have.property('auctionId').and.to.equal(defaultRequest.auctionId); + expect(request).to.have.property('transactionId').and.to.equal(defaultRequest.ortb2Imp.ext.tid); + expect(request).to.have.property('tz').and.to.equal(new Date().getTimezoneOffset()); + expect(request).to.have.property('bc').and.to.equal(1); + expect(request).to.have.property('floor').and.to.equal(null); + expect(request).to.have.property('banner').and.to.deep.equal({ sizes: [[300, 250], [300, 200]] }); + expect(request).to.have.property('gdprApplies').and.to.equal(0); + expect(request).to.have.property('consentString').and.to.equal(''); + expect(request).to.have.property('userEids').and.to.deep.equal([]); + expect(request).to.have.property('usPrivacy').and.to.equal(''); + expect(request).to.have.property('coppa').and.to.equal(0); + expect(request).to.have.property('sizes').and.to.deep.equal(['300x250', '300x200']); + expect(request).to.have.property('ext').and.to.deep.equal({}); + expect(request).to.have.property('env').and.to.deep.equal({ + env: 'xe', + placement: 'test-banner' + }); + expect(request).to.have.property('device').and.to.deep.equal({ + ua: navigator.userAgent, + lang: navigator.language + }); + }); + + it('should build request with schain', function () { + const schainRequest = deepClone(defaultRequest); + schainRequest.schain = { + validation: 'strict', + config: { + ver: '1.0' + } + }; + const request = JSON.parse(spec.buildRequests([schainRequest], {}).data)[0]; + expect(request).to.have.property('schain').and.to.deep.equal({ + validation: 'strict', + config: { + ver: '1.0' + } + }); + }); + + it('should build request with location', function () { + const bidderRequest = { + refererInfo: { + page: 'page', + location: 'location', + domain: 'domain', + ref: 'ref', + isAmp: false + } + }; + const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0]; + expect(request).to.have.property('location'); + const location = request.location; + expect(location).to.have.property('page').and.to.equal('page'); + expect(location).to.have.property('location').and.to.equal('location'); + expect(location).to.have.property('domain').and.to.equal('domain'); + expect(location).to.have.property('ref').and.to.equal('ref'); + expect(location).to.have.property('isAmp').and.to.equal(false); + }); + + it('should build request with ortb2 info', function () { + const ortb2Request = deepClone(defaultRequest); + ortb2Request.ortb2 = { + site: { + name: 'name' + } + }; + const request = JSON.parse(spec.buildRequests([ortb2Request], {}).data)[0]; + expect(request).to.have.property('ortb2').and.to.deep.equal({ + site: { + name: 'name' + } + }); + }); + + it('should build request with ortb2Imp info', function () { + const ortb2ImpRequest = deepClone(defaultRequest); + ortb2ImpRequest.ortb2Imp = { + ext: { + data: { + pbadslot: 'home1', + adUnitSpecificAttribute: '1' + } + } + }; + const request = JSON.parse(spec.buildRequests([ortb2ImpRequest], {}).data)[0]; + expect(request).to.have.property('ortb2Imp').and.to.deep.equal({ + ext: { + data: { + pbadslot: 'home1', + adUnitSpecificAttribute: '1' + } + } + }); + }); + + it('should build request with valid bidfloor', function () { + const bfRequest = deepClone(defaultRequest); + bfRequest.getFloor = () => ({ floor: 5, currency: 'USD' }); + const request = JSON.parse(spec.buildRequests([bfRequest], {}).data)[0]; + expect(request).to.have.property('floor').and.to.equal(5); + }); + + it('should build request with gdpr consent data if applies', function () { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'qwerty' + } + }; + const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0]; + expect(request).to.have.property('gdprApplies').and.equals(1); + expect(request).to.have.property('consentString').and.equals('qwerty'); + }); + + it('should build request with usp consent data if applies', function () { + const bidderRequest = { + uspConsent: '1YA-' + }; + const request = JSON.parse(spec.buildRequests([defaultRequest], bidderRequest).data)[0]; + expect(request).to.have.property('usPrivacy').and.equals('1YA-'); + }); + + it('should build request with coppa 1', function () { + config.setConfig({ + coppa: true + }); + const request = JSON.parse(spec.buildRequests([defaultRequest], {}).data)[0]; + expect(request).to.have.property('coppa').and.equals(1); + }); + + it('should build request with extended ids', function () { + const idRequest = deepClone(defaultRequest); + idRequest.userIdAsEids = [ + { source: 'adserver.org', uids: [ { id: 'TTD_ID_FROM_USER_ID_MODULE', atype: 1, ext: { rtiPartner: 'TDID' } } ] }, + { source: 'pubcid.org', uids: [ { id: 'pubCommonId_FROM_USER_ID_MODULE', atype: 1 } ] } + ]; + const request = JSON.parse(spec.buildRequests([idRequest], {}).data)[0]; + expect(request).to.have.property('userEids').and.deep.equal(idRequest.userIdAsEids); + }); + + it('should build request with video', function () { + const request = JSON.parse(spec.buildRequests([defaultRequestVideo], {}).data)[0]; + expect(request).to.have.property('video').and.to.deep.equal({ + playerSize: [640, 480], + context: 'instream', + skipppable: true + }); + expect(request).to.have.property('sizes').and.to.deep.equal(['640x480']); + }); + }); + + describe('interpretResponse', function () { + it('should return empty bids', function () { + const serverResponse = { + body: { + data: null + } + }; + + const invalidResponse = spec.interpretResponse(serverResponse, {}); + expect(invalidResponse).to.be.an('array').that.is.empty; + }); + + it('should interpret valid response', function () { + const serverResponse = { + body: { + data: [{ + requestId: 'qwerty', + cpm: 1, + currency: 'USD', + width: 300, + height: 250, + ttl: 600, + meta: { + advertiserDomains: ['xe.works'] + }, + ext: { + pixels: [ + [ 'iframe', 'surl1' ], + [ 'image', 'surl2' ], + ] + } + }] + } + }; + + const validResponse = spec.interpretResponse(serverResponse, { bidderRequest: defaultRequest }); + const bid = validResponse[0]; + expect(validResponse).to.be.an('array').that.is.not.empty; + expect(bid.requestId).to.equal('qwerty'); + expect(bid.cpm).to.equal(1); + expect(bid.currency).to.equal('USD'); + expect(bid.width).to.equal(300); + expect(bid.height).to.equal(250); + expect(bid.ttl).to.equal(600); + expect(bid.meta).to.deep.equal({ advertiserDomains: ['xe.works'] }); + }); + + it('should interpret valid banner response', function () { + const serverResponse = { + body: { + data: [{ + requestId: 'qwerty', + cpm: 1, + currency: 'USD', + width: 300, + height: 250, + ttl: 600, + mediaType: 'banner', + creativeId: 'xe-demo-banner', + ad: 'ad', + meta: {} + }] + } + }; + + const validResponseBanner = spec.interpretResponse(serverResponse, { bidderRequest: defaultRequest }); + const bid = validResponseBanner[0]; + expect(validResponseBanner).to.be.an('array').that.is.not.empty; + expect(bid.mediaType).to.equal('banner'); + expect(bid.creativeId).to.equal('xe-demo-banner'); + expect(bid.ad).to.equal('ad'); + }); + + it('should interpret valid video response', function () { + const serverResponse = { + body: { + data: [{ + requestId: 'qwerty', + cpm: 1, + currency: 'USD', + width: 600, + height: 480, + ttl: 600, + mediaType: 'video', + creativeId: 'xe-demo-video', + ad: 'vast-xml', + meta: {} + }] + } + }; + + const validResponseBanner = spec.interpretResponse(serverResponse, { bidderRequest: defaultRequestVideo }); + const bid = validResponseBanner[0]; + expect(validResponseBanner).to.be.an('array').that.is.not.empty; + expect(bid.mediaType).to.equal('video'); + expect(bid.creativeId).to.equal('xe-demo-video'); + expect(bid.ad).to.equal('vast-xml'); + }); + }); + + describe('getUserSyncs', function () { + it('shoukd handle no params', function () { + const opts = spec.getUserSyncs({}, []); + expect(opts).to.be.an('array').that.is.empty; + }); + + it('should return empty if sync is not allowed', function () { + const opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: false}); + expect(opts).to.be.an('array').that.is.empty; + }); + + it('should allow iframe sync', function () { + const opts = spec.getUserSyncs({iframeEnabled: true, pixelEnabled: false}, [{ + body: { + data: [{ + requestId: 'qwerty', + ext: { + pixels: [ + [ 'iframe', 'surl1?a=b' ], + [ 'image', 'surl2?a=b' ], + ] + } + }] + } + }]); + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('iframe'); + expect(opts[0].url).to.equal('surl1?a=b&us_privacy=&gdpr=0&gdpr_consent='); + }); + + it('should allow pixel sync', function () { + const opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [{ + body: { + data: [{ + requestId: 'qwerty', + ext: { + pixels: [ + [ 'iframe', 'surl1?a=b' ], + [ 'image', 'surl2?a=b' ], + ] + } + }] + } + }]); + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('image'); + expect(opts[0].url).to.equal('surl2?a=b&us_privacy=&gdpr=0&gdpr_consent='); + }); + + it('should allow pixel sync and parse consent params', function () { + const opts = spec.getUserSyncs({iframeEnabled: false, pixelEnabled: true}, [{ + body: { + data: [{ + requestId: 'qwerty', + ext: { + pixels: [ + [ 'iframe', 'surl1?a=b' ], + [ 'image', 'surl2?a=b' ], + ] + } + }] + } + }], { + gdprApplies: 1, + consentString: '1YA-' + }); + expect(opts.length).to.equal(1); + expect(opts[0].type).to.equal('image'); + expect(opts[0].url).to.equal('surl2?a=b&us_privacy=&gdpr=1&gdpr_consent=1YA-'); + }); + }); + + describe('getBidFloor', function () { + it('should return null when getFloor is not a function', () => { + const bid = { getFloor: 2 }; + const result = getBidFloor(bid); + expect(result).to.be.null; + }); + + it('should return null when getFloor doesnt return an object', () => { + const bid = { getFloor: () => 2 }; + const result = getBidFloor(bid); + expect(result).to.be.null; + }); + + it('should return null when floor is not a number', () => { + const bid = { + getFloor: () => ({ floor: 'string', currency: 'USD' }) + }; + const result = getBidFloor(bid); + expect(result).to.be.null; + }); + + it('should return null when currency is not USD', () => { + const bid = { + getFloor: () => ({ floor: 5, currency: 'EUR' }) + }; + const result = getBidFloor(bid); + expect(result).to.be.null; + }); + + it('should return floor value when everything is correct', () => { + const bid = { + getFloor: () => ({ floor: 5, currency: 'USD' }) + }; + const result = getBidFloor(bid); + expect(result).to.equal(5); + }); + }); +}) diff --git a/test/spec/modules/yahoosspBidAdapter_spec.js b/test/spec/modules/yahoosspBidAdapter_spec.js index e301218741c..40dc2b3c63b 100644 --- a/test/spec/modules/yahoosspBidAdapter_spec.js +++ b/test/spec/modules/yahoosspBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { config } from 'src/config.js'; import { BANNER, VIDEO } from 'src/mediaTypes.js'; import { spec } from 'modules/yahoosspBidAdapter.js'; +import {createEidsArray} from '../../../modules/userId/eids'; const DEFAULT_BID_ID = '84ab500420319d'; const DEFAULT_BID_DCN = '2093845709823475'; @@ -11,18 +12,20 @@ const DEFAULT_AD_UNIT_CODE = '/19968336/header-bid-tag-1'; const DEFAULT_AD_UNIT_TYPE = 'banner'; const DEFAULT_PARAMS_BID_OVERRIDE = {}; const DEFAULT_VIDEO_CONTEXT = 'instream'; -const ADAPTER_VERSION = '1.0.2'; +const ADAPTER_VERSION = '1.1.0'; +const DEFAULT_BIDDER_CODE = 'yahooAds'; +const VALID_BIDDER_CODES = [DEFAULT_BIDDER_CODE, 'yahoossp', 'yahooAdvertising']; const PREBID_VERSION = '$prebid.version$'; const INTEGRATION_METHOD = 'prebid.js'; // Utility functions -const generateBidRequest = ({bidId, pos, adUnitCode, adUnitType, bidOverrideObject, videoContext, pubIdMode}) => { +const generateBidRequest = ({bidderCode, bidId, pos, adUnitCode, adUnitType, bidOverrideObject, videoContext, pubIdMode, ortb2}) => { const bidRequest = { adUnitCode, auctionId: 'b06c5141-fe8f-4cdf-9d7d-54415490a917', bidId, bidderRequestsCount: 1, - bidder: 'yahoossp', + bidder: bidderCode, bidderRequestId: '7101db09af0db2', bidderWinsCount: 0, mediaTypes: {}, @@ -30,7 +33,8 @@ const generateBidRequest = ({bidId, pos, adUnitCode, adUnitType, bidOverrideObje bidOverride: bidOverrideObject }, src: 'client', - transactionId: '5b17b67d-7704-4732-8cc9-5b1723e9bcf9' + transactionId: '5b17b67d-7704-4732-8cc9-5b1723e9bcf9', + ortb2 }; const bannerObj = { @@ -71,46 +75,54 @@ const generateBidRequest = ({bidId, pos, adUnitCode, adUnitType, bidOverrideObje return bidRequest; } -let generateBidderRequest = (bidRequestArray, adUnitCode) => { +let generateBidderRequest = (bidRequestArray, adUnitCode, ortb2 = {}) => { const bidderRequest = { adUnitCode: adUnitCode || 'default-adUnitCode', auctionId: 'd4c83a3b-18e4-4208-b98b-63848449c7aa', auctionStart: new Date().getTime(), - bidderCode: 'yahoossp', + bidderCode: bidRequestArray[0].bidder, bidderRequestId: '112f1c7c5d399a', bids: bidRequestArray, refererInfo: { - referer: 'https://publisher-test.com', + page: 'https://publisher-test.com', reachedTop: true, isAmp: false, numIframes: 0, stack: ['https://publisher-test.com'], }, + uspConsent: '1-Y-', gdprConsent: { consentString: 'BOtmiBKOtmiBKABABAENAFAAAAACeAAA', vendorData: {}, gdprApplies: true }, + gppConsent: { + gppString: 'DBACNYA~CPXxRfAPXxRfAAfKABENB-CgAAAAAAAAAAYgAAAAAAAA~1YNN', + applicableSections: [1, 2, 3] + }, start: new Date().getTime(), timeout: 1000, + ortb2 }; return bidderRequest; }; -const generateBuildRequestMock = ({bidId, pos, adUnitCode, adUnitType, bidOverrideObject, videoContext, pubIdMode}) => { +const generateBuildRequestMock = ({bidderCode, bidId, pos, adUnitCode, adUnitType, bidOverrideObject, videoContext, pubIdMode, ortb2}) => { const bidRequestConfig = { + bidderCode: bidderCode || DEFAULT_BIDDER_CODE, bidId: bidId || DEFAULT_BID_ID, pos: pos || DEFAULT_BID_POS, adUnitCode: adUnitCode || DEFAULT_AD_UNIT_CODE, adUnitType: adUnitType || DEFAULT_AD_UNIT_TYPE, bidOverrideObject: bidOverrideObject || DEFAULT_PARAMS_BID_OVERRIDE, videoContext: videoContext || DEFAULT_VIDEO_CONTEXT, - pubIdMode: pubIdMode || false + pubIdMode: pubIdMode || false, + ortb2: ortb2 || {} }; const bidRequest = generateBidRequest(bidRequestConfig); const validBidRequests = [bidRequest]; - const bidderRequest = generateBidderRequest(validBidRequests, adUnitCode); + const bidderRequest = generateBidderRequest(validBidRequests, adUnitCode, ortb2); return { bidRequest, validBidRequests, bidderRequest } }; @@ -164,64 +176,64 @@ const generateResponseMock = (admPayloadType, vastVersion, videoContext) => { seatbid: [{ bid: [ bidResponse ], seat: 13107 }] } }; - const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: admPayloadType, videoContext: videoContext}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: admPayloadType, videoContext}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - return {serverResponse, data, bidderRequest}; } // Unit tests -describe('YahooSSP Bid Adapter:', () => { - it('PLACEHOLDER TO PASS GULP', () => { - const obj = {}; - expect(obj).to.be.an('object'); +describe('Yahoo Advertising Bid Adapter:', () => { + beforeEach(() => { + config.resetConfig(); }); describe('Validate basic properties', () => { it('should define the correct bidder code', () => { - expect(spec.code).to.equal('yahoossp') + expect(spec.code).to.equal('yahooAds'); + }); + + it('should define the correct bidder aliases', () => { + expect(spec.aliases).to.deep.equal(['yahoossp', 'yahooAdvertising']); }); it('should define the correct vendor ID', () => { - expect(spec.gvlid).to.equal(25) + expect(spec.gvlid).to.equal(25); }); }); describe('getUserSyncs()', () => { - const IMAGE_PIXEL_URL = 'http://image-pixel.com/foo/bar?1234&baz=true'; - const IFRAME_ONE_URL = 'http://image-iframe.com/foo/bar?1234&baz=true'; + const IMAGE_PIXEL_URL = 'http://image-pixel.com/foo/bar?1234&baz=true&gdpr=foo&gdpr_consent=bar'; + const IFRAME_ONE_URL = 'http://image-iframe.com/foo/bar?1234&baz=true&us_privacy=hello&gpp=goodbye'; const IFRAME_TWO_URL = 'http://image-iframe-two.com/foo/bar?1234&baz=true'; - - let serverResponses = []; - beforeEach(() => { - serverResponses[0] = { - body: { - ext: { - pixels: `` - } + const SERVER_RESPONSES = [{ + body: { + ext: { + pixels: `` } } - }); - - after(() => { - serverResponses = undefined; - }); + }]; + const bidderRequest = generateBuildRequestMock({}).bidderRequest; it('for only iframe enabled syncs', () => { let syncOptions = { iframeEnabled: true, pixelEnabled: false }; - let pixelsObjects = spec.getUserSyncs(syncOptions, serverResponses); - expect(pixelsObjects.length).to.equal(2); - expect(pixelsObjects).to.deep.equal( - [ - {type: 'iframe', 'url': IFRAME_ONE_URL}, - {type: 'iframe', 'url': IFRAME_TWO_URL} - ] - ) + let pixelObjects = spec.getUserSyncs( + syncOptions, + SERVER_RESPONSES, + bidderRequest.gdprConsent, + bidderRequest.uspConsent, + bidderRequest.gppConsent + ); + expect(pixelObjects.length).to.equal(2); + + pixelObjects.forEach(pixelObject => { + expect(pixelObject).to.have.all.keys('type', 'url'); + expect(pixelObject.type).to.equal('iframe'); + }); }); it('for only pixel enabled syncs', () => { @@ -229,13 +241,16 @@ describe('YahooSSP Bid Adapter:', () => { iframeEnabled: false, pixelEnabled: true }; - let pixelsObjects = spec.getUserSyncs(syncOptions, serverResponses); - expect(pixelsObjects.length).to.equal(1); - expect(pixelsObjects).to.deep.equal( - [ - {type: 'image', 'url': IMAGE_PIXEL_URL} - ] - ) + let pixelObjects = spec.getUserSyncs( + syncOptions, + SERVER_RESPONSES, + bidderRequest.gdprConsent, + bidderRequest.uspConsent, + bidderRequest.gppConsent + ); + expect(pixelObjects.length).to.equal(1); + expect(pixelObjects[0]).to.have.all.keys('type', 'url'); + expect(pixelObjects[0].type).to.equal('image'); }); it('for both pixel and iframe enabled syncs', () => { @@ -243,15 +258,85 @@ describe('YahooSSP Bid Adapter:', () => { iframeEnabled: true, pixelEnabled: true }; - let pixelsObjects = spec.getUserSyncs(syncOptions, serverResponses); - expect(pixelsObjects.length).to.equal(3); - expect(pixelsObjects).to.deep.equal( - [ - {type: 'iframe', 'url': IFRAME_ONE_URL}, - {type: 'image', 'url': IMAGE_PIXEL_URL}, - {type: 'iframe', 'url': IFRAME_TWO_URL} - ] - ) + let pixelObjects = spec.getUserSyncs( + syncOptions, + SERVER_RESPONSES, + bidderRequest.gdprConsent, + bidderRequest.uspConsent, + bidderRequest.gppConsent + ); + expect(pixelObjects.length).to.equal(3); + let iframeCount = 0; + let imageCount = 0; + pixelObjects.forEach(pixelObject => { + if (pixelObject.type == 'iframe') { + iframeCount++; + } else if (pixelObject.type == 'image') { + imageCount++; + } + }); + expect(iframeCount).to.equal(2); + expect(imageCount).to.equal(1); + }); + + describe('user consent parameters are updated', () => { + const syncOptions = { + iframeEnabled: true, + pixelEnabled: true + }; + describe('when all consent data is set', () => { + const pixelObjects = spec.getUserSyncs( + syncOptions, + SERVER_RESPONSES, + bidderRequest.gdprConsent, + bidderRequest.uspConsent, + bidderRequest.gppConsent + ); + pixelObjects.forEach(pixelObject => { + let url = pixelObject.url; + let urlParams = new URL(url).searchParams; + const expectedParams = { + 'baz': 'true', + 'gdpr_consent': bidderRequest.gdprConsent.consentString, + 'gdpr': bidderRequest.gdprConsent.gdprApplies ? '1' : '0', + 'us_privacy': bidderRequest.uspConsent, + 'gpp': bidderRequest.gppConsent.gppString, + 'gpp_sid': Array.isArray(bidderRequest.gppConsent.applicableSections) ? bidderRequest.gppConsent.applicableSections.join(',') : '' + } + for (const [key, value] of Object.entries(expectedParams)) { + it(`Updates the ${key} consent param in user sync URL ${url}`, () => { + expect(urlParams.get(key)).to.equal(value); + }); + }; + }); + }); + + describe('when no consent data is set', () => { + const pixelObjects = spec.getUserSyncs( + syncOptions, + SERVER_RESPONSES, + undefined, + undefined, + undefined + ); + pixelObjects.forEach(pixelObject => { + let url = pixelObject.url; + let urlParams = new URL(url).searchParams; + const expectedParams = { + 'baz': 'true', + 'gdpr_consent': '', + 'gdpr': '0', + 'us_privacy': '', + 'gpp': '', + 'gpp_sid': '' + } + for (const [key, value] of Object.entries(expectedParams)) { + it(`Updates the ${key} consent param in user sync URL ${url}`, () => { + expect(urlParams.get(key)).to.equal(value); + }); + }; + }); + }); }); }); @@ -331,6 +416,19 @@ describe('YahooSSP Bid Adapter:', () => { }); describe('Schain module support:', () => { + it('should not include schain data when schain array is empty', function () { + const { bidRequest, validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const globalSchain = { + ver: '1.0', + complete: 1, + nodes: [] + }; + bidRequest.schain = globalSchain; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + const schain = data.source.ext.schain; + expect(schain).to.be.undefined; + }); + it('should send Global or Bidder specific schain', function () { const { bidRequest, validBidRequests, bidderRequest } = generateBuildRequestMock({}); const globalSchain = { @@ -355,10 +453,9 @@ describe('YahooSSP Bid Adapter:', () => { // Should not allow invalid "site" data types const INVALID_ORTB2_TYPES = [ null, [], 123, 'unsupportedKeyName', true, false, undefined ]; INVALID_ORTB2_TYPES.forEach(param => { - const ortb2 = { site: param } - config.setConfig({ortb2}); it(`should not allow invalid site types to be added to bid-request: ${JSON.stringify(param)}`, () => { - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const ortb2 = { site: param } + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site[param]).to.be.undefined; }); @@ -375,8 +472,7 @@ describe('YahooSSP Bid Adapter:', () => { [param]: 'something' } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site[param]).to.exist; expect(data.site[param]).to.be.a('string'); @@ -391,8 +487,7 @@ describe('YahooSSP Bid Adapter:', () => { [param]: ['something'] } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site[param]).to.exist; expect(data.site[param]).to.be.a('array'); @@ -408,8 +503,7 @@ describe('YahooSSP Bid Adapter:', () => { content: param } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.content).to.be.undefined; }); @@ -426,8 +520,7 @@ describe('YahooSSP Bid Adapter:', () => { } } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.content).to.be.a('object'); }); @@ -443,8 +536,7 @@ describe('YahooSSP Bid Adapter:', () => { } } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.content[param]).to.exist; expect(data.site.content[param]).to.be.a('string'); @@ -462,14 +554,30 @@ describe('YahooSSP Bid Adapter:', () => { } } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.content[param]).to.be.a('number'); expect(data.site.content[param]).to.be.equal(ortb2.site.content[param]); }); }); + const VALID_PUBLISHER_OBJECTS = ['ext']; + VALID_PUBLISHER_OBJECTS.forEach(param => { + it(`should determine that the ortb2.site.publisher Object key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => { + const ortb2 = { + site: { + publisher: { + [param]: {a: '123', b: '456'} + } + } + }; + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.publisher[param]).to.be.a('object'); + expect(data.site.publisher[param]).to.be.equal(ortb2.site.publisher[param]); + }); + }); + const VALID_CONTENT_ARRAYS = ['cat']; VALID_CONTENT_ARRAYS.forEach(param => { it(`should determine that the ortb2.site Array key is valid and append to the bid-request: ${JSON.stringify(param)}`, () => { @@ -480,8 +588,7 @@ describe('YahooSSP Bid Adapter:', () => { } } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.content[param]).to.be.a('array'); expect(data.site.content[param]).to.be.equal(ortb2.site.content[param]); @@ -498,12 +605,10 @@ describe('YahooSSP Bid Adapter:', () => { } } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.content[param]).to.be.a('object'); expect(data.site.content[param]).to.be.equal(ortb2.site.content[param]); - config.setConfig({ortb2: {}}); }); }); }); @@ -513,10 +618,9 @@ describe('YahooSSP Bid Adapter:', () => { // Should not allow invalid "user" data types const INVALID_ORTB2_TYPES = [ null, [], 'unsupportedKeyName', true, false, undefined ]; INVALID_ORTB2_TYPES.forEach(param => { - const ortb2 = { user: param } - config.setConfig({ortb2}); it(`should not allow invalid site types to be added to bid-request: ${JSON.stringify(param)}`, () => { - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const ortb2 = { user: param } + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.user[param]).to.be.undefined; }); @@ -531,8 +635,7 @@ describe('YahooSSP Bid Adapter:', () => { [param]: 'something' } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.user[param]).to.exist; expect(data.user[param]).to.be.a('string'); @@ -548,8 +651,7 @@ describe('YahooSSP Bid Adapter:', () => { [param]: 1982 } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.user[param]).to.exist; expect(data.user[param]).to.be.a('number'); @@ -565,8 +667,7 @@ describe('YahooSSP Bid Adapter:', () => { [param]: ['something'] } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.user[param]).to.exist; expect(data.user[param]).to.be.a('array'); @@ -582,12 +683,11 @@ describe('YahooSSP Bid Adapter:', () => { [param]: {a: '123', b: '456'} } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.user[param]).to.be.a('object'); - expect(data.user[param]).to.be.deep.include({[param]: {a: '123', b: '456'}}); - config.setConfig({ortb2: {}}); + const user = data.user; + expect(user[param]).to.be.a('object'); + expect(user[param]).to.be.deep.include({[param]: {a: '123', b: '456'}}); }); }); @@ -605,15 +705,16 @@ describe('YahooSSP Bid Adapter:', () => { } } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.user.data[0][param]).to.exist; - expect(data.user.data[0][param]).to.be.a('string'); - expect(data.user.data[0][param]).to.be.equal(ortb2.user.data[0][param]); - expect(data.site.content.data[0][param]).to.exist; - expect(data.site.content.data[0][param]).to.be.a('string'); - expect(data.site.content.data[0][param]).to.be.equal(ortb2.site.content.data[0][param]); + const user = data.user; + const site = data.site; + expect(user.data[0][param]).to.exist; + expect(user.data[0][param]).to.be.a('string'); + expect(user.data[0][param]).to.be.equal(ortb2.user.data[0][param]); + expect(site.content.data[0][param]).to.exist; + expect(site.content.data[0][param]).to.be.a('string'); + expect(site.content.data[0][param]).to.be.equal(ortb2.site.content.data[0][param]); }); }); @@ -625,12 +726,12 @@ describe('YahooSSP Bid Adapter:', () => { data: [{[param]: [{id: 1}]}] } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.user.data[0][param]).to.exist; - expect(data.user.data[0][param]).to.be.a('array'); - expect(data.user.data[0][param]).to.be.equal(ortb2.user.data[0][param]); + const user = data.user; + expect(user.data[0][param]).to.exist; + expect(user.data[0][param]).to.be.a('array'); + expect(user.data[0][param]).to.be.equal(ortb2.user.data[0][param]); }); }); @@ -642,13 +743,12 @@ describe('YahooSSP Bid Adapter:', () => { data: [{[param]: {id: 'ext'}}] } }; - config.setConfig({ortb2}); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.user.data[0][param]).to.exist; - expect(data.user.data[0][param]).to.be.a('object'); - expect(data.user.data[0][param]).to.be.equal(ortb2.user.data[0][param]); - config.setConfig({ortb2: {}}); + const user = data.user; + expect(user.data[0][param]).to.exist; + expect(user.data[0][param]).to.be.a('object'); + expect(user.data[0][param]).to.be.equal(ortb2.user.data[0][param]); }); }); @@ -713,7 +813,7 @@ describe('YahooSSP Bid Adapter:', () => { }); }); - describe('GDPR & Consent:', () => { + describe('GDPR & Consent & GPP:', () => { it('should return request objects that do not send cookies if purpose 1 consent is not provided', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); bidderRequest.gdprConsent = { @@ -731,29 +831,58 @@ describe('YahooSSP Bid Adapter:', () => { const options = spec.buildRequests(validBidRequests, bidderRequest)[0].options; expect(options.withCredentials).to.be.false; }); + + it('set the GPP consent data from the data within the bid request', function () { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + let clonedBidderRequest = {...bidderRequest}; + const data = spec.buildRequests(validBidRequests, clonedBidderRequest)[0].data; + expect(data.regs.ext.gpp).to.equal(bidderRequest.gppConsent.gppString); + expect(data.regs.ext.gpp_sid).to.eql(bidderRequest.gppConsent.applicableSections); + }); + + it('overrides the GPP consent data using data from the ortb2 config object', function () { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + const ortb2 = { + regs: { + gpp: 'somegppstring', + gpp_sid: [6, 7] + } + }; + let clonedBidderRequest = {...bidderRequest, ortb2}; + const data = spec.buildRequests(validBidRequests, clonedBidderRequest)[0].data; + expect(data.regs.ext.gpp).to.equal(ortb2.regs.gpp); + expect(data.regs.ext.gpp_sid).to.eql(ortb2.regs.gpp_sid); + }); }); describe('Endpoint & Impression Request Mode:', () => { - it('should route request to config override endpoint', () => { - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); - const testOverrideEndpoint = 'http://foo.bar.baz.com/bidderRequest'; + afterEach(() => { config.setConfig({ - yahoossp: { - endpoint: testOverrideEndpoint + yahooAds: { + singleRequestMode: undefined } }); - const response = spec.buildRequests(validBidRequests, bidderRequest)[0]; - expect(response).to.deep.include( - { - method: 'POST', - url: testOverrideEndpoint - }); }); - it('should route request to /bidRequest endpoint when dcn & pos present', () => { - config.setConfig({ - yahoossp: {} + VALID_BIDDER_CODES.forEach(bidderCode => { + it(`should route request to config override endpoint for ${bidderCode} override config`, () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({bidderCode}); + const testOverrideEndpoint = 'http://foo.bar.baz.com/bidderRequest'; + const cfg = {}; + cfg[bidderCode] = { + endpoint: testOverrideEndpoint + }; + config.setConfig(cfg); + const response = spec.buildRequests(validBidRequests, bidderRequest)[0]; + expect(response).to.deep.include( + { + method: 'POST', + url: testOverrideEndpoint + }); }); + }); + + it('should route request to /bidRequest endpoint when dcn & pos present', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); const response = spec.buildRequests(validBidRequests, bidderRequest); expect(response[0]).to.deep.include({ @@ -781,15 +910,15 @@ describe('YahooSSP Bid Adapter:', () => { bidderRequest.bids = validBidRequests; config.setConfig({ - yahoossp: { + yahooAds: { singleRequestMode: true } }); - const data = spec.buildRequests(validBidRequests, bidderRequest).data; - expect(data.imp).to.be.an('array').with.lengthOf(2); + const responsePayload = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(responsePayload.imp).to.be.an('array').with.lengthOf(2); - expect(data.imp[0]).to.deep.include({ + expect(responsePayload.imp[0]).to.deep.include({ id: DEFAULT_BID_ID, ext: { pos: DEFAULT_BID_POS, @@ -797,7 +926,7 @@ describe('YahooSSP Bid Adapter:', () => { } }); - expect(data.imp[1]).to.deep.include({ + expect(responsePayload.imp[1]).to.deep.include({ id: BID_ID_2, ext: { pos: BID_POS_2, @@ -815,15 +944,17 @@ describe('YahooSSP Bid Adapter:', () => { it('buildRequests(): should return an array with the correct amount of request objects', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); - const response = spec.buildRequests(validBidRequests, bidderRequest).bidderRequest; - expect(response.bids).to.be.an('array').to.have.lengthOf(1); + const reqs = spec.buildRequests(validBidRequests, bidderRequest); + expect(reqs).to.be.an('array').to.have.lengthOf(1); + expect(reqs[0]).to.be.an('object').that.has.keys('method', 'url', 'data', 'options', 'bidderRequest'); }); }); describe('Request Headers validation:', () => { it('should return request objects with the relevant custom headers and content type declaration', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); - const options = spec.buildRequests(validBidRequests, bidderRequest).options; + bidderRequest.gdprConsent.gdprApplies = false; + const options = spec.buildRequests(validBidRequests, bidderRequest)[0].options; expect(options).to.deep.equal( { contentType: 'application/json', @@ -835,25 +966,62 @@ describe('YahooSSP Bid Adapter:', () => { }); }); + describe('User data', () => { + it('should set the allowed sources user eids', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + validBidRequests[0].userIdAsEids = [ + {source: 'yahoo.com', uids: [{id: 'connectId_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'admixer.net', uids: [{id: 'admixerId_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'adtelligent.com', uids: [{id: 'adtelligentId_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'amxdt.net', uids: [{id: 'amxId_FROM_USER_ID_MODULE', atype: 1}]}, + {source: 'britepool.com', uids: [{id: 'britepoolid_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'deepintent.com', uids: [{id: 'deepintentId_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'epsilon.com', uids: [{id: 'publinkId_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'intentiq.com', uids: [{id: 'intentIqId_FROM_USER_ID_MODULE', atype: 1}]}, + {source: 'liveramp.com', uids: [{id: 'idl_env_FROM_USER_ID_MODULE', atype: 3}]}, + {source: 'intimatemerger.com', uids: [{id: 'imuid_FROM_USER_ID_MODULE', atype: 1}]}, + {source: 'criteo.com', uids: [{id: 'criteoId_FROM_USER_ID_MODULE', atype: 1}]}, + {source: 'neustar.biz', uids: [{id: 'fabrickId_FROM_USER_ID_MODULE', atype: 1}]} + ]; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + + expect(data.user.ext.eids).to.deep.equal(validBidRequests[0].userIdAsEids); + }); + + it('should not set not allowed user eids sources', () => { + const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); + validBidRequests[0].userIdAsEids = createEidsArray({ + justId: 'justId_FROM_USER_ID_MODULE' + }); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + + expect(data.user.ext.eids).to.deep.equal([]); + }); + }); + describe('Request Payload oRTB bid validation:', () => { it('should generate a valid openRTB bid-request object in the data field', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); - const data = spec.buildRequests(validBidRequests, bidderRequest).data; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site).to.deep.equal({ id: bidderRequest.bids[0].params.dcn, - page: bidderRequest.refererInfo.referer + page: bidderRequest.refererInfo.page }); expect(data.device).to.deep.equal({ dnt: 0, ua: navigator.userAgent, - ip: undefined + ip: undefined, + w: window.screen.width, + h: window.screen.height }); expect(data.regs).to.deep.equal({ ext: { - 'us_privacy': '', - gdpr: 1 + 'us_privacy': bidderRequest.uspConsent, + gdpr: 1, + gpp: bidderRequest.gppConsent.gppString, + gpp_sid: bidderRequest.gppConsent.applicableSections } }); @@ -883,7 +1051,7 @@ describe('YahooSSP Bid Adapter:', () => { it('should generate a valid openRTB imp.ext object in the bid-request', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); const bid = validBidRequests[0]; - const data = spec.buildRequests(validBidRequests, bidderRequest).data; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.imp[0].ext).to.deep.equal({ pos: bid.params.pos, dfp_ad_unit_code: DEFAULT_AD_UNIT_CODE @@ -893,24 +1061,63 @@ describe('YahooSSP Bid Adapter:', () => { it('should use siteId value as site.id in the outbound bid-request when using "pubId" integration mode', () => { let { validBidRequests, bidderRequest } = generateBuildRequestMock({pubIdMode: true}); validBidRequests[0].params.siteId = '1234567'; - const data = spec.buildRequests(validBidRequests, bidderRequest).data; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.site.id).to.equal('1234567'); }); + it('should use site publisher ortb2 config in default integration mode', () => { + const ortb2 = { + site: { + publisher: { + ext: { + publisherblob: 'pblob', + bucket: 'bucket' + } + } + } + } + let { validBidRequests, bidderRequest } = generateBuildRequestMock({ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.publisher).to.deep.equal({ + ext: { + publisherblob: 'pblob', + bucket: 'bucket' + } + }); + }); + + it('should use site publisher ortb2 config when using "pubId" integration mode', () => { + const ortb2 = { + site: { + publisher: { + ext: { + publisherblob: 'pblob', + bucket: 'bucket' + } + } + } + } + let { validBidRequests, bidderRequest } = generateBuildRequestMock({pubIdMode: true, ortb2}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.site.publisher).to.deep.equal({ + id: DEFAULT_PUBID, + ext: { + publisherblob: 'pblob', + bucket: 'bucket' + } + }); + }); + it('should use placementId value as imp.tagid in the outbound bid-request when using "pubId" integration mode', () => { let { validBidRequests, bidderRequest } = generateBuildRequestMock({pubIdMode: true}); validBidRequests[0].params.placementId = 'header-300x250'; - const data = spec.buildRequests(validBidRequests, bidderRequest).data; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.imp[0].tagid).to.deep.equal('header-300x250'); }); }); describe('Request Payload oRTB bid.imp validation:', () => { - // Validate Banner imp imp when yahoossp.mode=undefined - it('should generate a valid "Banner" imp object', () => { - config.setConfig({ - yahoossp: {} - }); + it('should generate a valid "Banner" imp object when mode config override is undefined', () => { const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; expect(data.imp[0].video).to.not.exist; @@ -920,74 +1127,82 @@ describe('YahooSSP Bid Adapter:', () => { }); }); - // Validate Banner imp when yahoossp.mode="banner" - it('should generate a valid "Banner" imp object', () => { - config.setConfig({ - yahoossp: { mode: 'banner' } - }); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({}); - const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.imp[0].video).to.not.exist; - expect(data.imp[0].banner).to.deep.equal({ - mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], - format: [{w: 300, h: 250}, {w: 300, h: 600}] + // Validate Banner imp when config value for mode="banner" + VALID_BIDDER_CODES.forEach(bidderCode => { + it(`should generate a valid "Banner" imp object for ${bidderCode} config override`, () => { + const cfg = {}; + cfg[bidderCode] = { + mode: BANNER + }; + config.setConfig(cfg); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({bidderCode}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].video).to.not.exist; + expect(data.imp[0].banner).to.deep.equal({ + mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], + format: [{w: 300, h: 250}, {w: 300, h: 600}] + }); }); - }); - // Validate Video imp - it('should generate a valid "Video" only imp object', () => { - config.setConfig({ - yahoossp: { mode: 'video' } - }); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: 'video'}); - const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.imp[0].banner).to.not.exist; - expect(data.imp[0].video).to.deep.equal({ - mimes: ['video/mp4', 'application/javascript'], - w: 300, - h: 250, - api: [2], - protocols: [2, 5], - startdelay: 0, - linearity: 1, - maxbitrate: undefined, - maxduration: undefined, - minduration: undefined, - delivery: undefined, - pos: undefined, - playbackmethod: undefined, - rewarded: undefined, - placement: undefined + // Validate Video imp + it(`should generate a valid "Video" only imp object for ${bidderCode} config override`, () => { + const cfg = {}; + cfg[bidderCode] = { + mode: VIDEO + }; + config.setConfig(cfg); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({bidderCode, adUnitType: 'video'}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].banner).to.not.exist; + expect(data.imp[0].video).to.deep.equal({ + mimes: ['video/mp4', 'application/javascript'], + w: 300, + h: 250, + api: [2], + protocols: [2, 5], + startdelay: 0, + linearity: 1, + maxbitrate: undefined, + maxduration: undefined, + minduration: undefined, + delivery: undefined, + pos: undefined, + playbackmethod: undefined, + rewarded: undefined, + placement: undefined + }); }); - }); - // Validate multi-format Video+banner imp - it('should generate a valid multi-format "Video + Banner" imp object', () => { - config.setConfig({ - yahoossp: { mode: 'all' } - }); - const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: 'multi-format'}); - const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.imp[0].banner).to.deep.equal({ - mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], - format: [{w: 300, h: 250}, {w: 300, h: 600}] - }); - expect(data.imp[0].video).to.deep.equal({ - mimes: ['video/mp4', 'application/javascript'], - w: 300, - h: 250, - api: [2], - protocols: [2, 5], - startdelay: 0, - linearity: 1, - maxbitrate: undefined, - maxduration: undefined, - minduration: undefined, - delivery: undefined, - pos: undefined, - playbackmethod: undefined, - rewarded: undefined, - placement: undefined + // Validate multi-format Video+banner imp + it(`should generate a valid multi-format "Video + Banner" imp object for ${bidderCode} config override`, () => { + const cfg = {}; + cfg[bidderCode] = { + mode: 'all' + }; + config.setConfig(cfg); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({bidderCode, adUnitType: 'multi-format'}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].banner).to.deep.equal({ + mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], + format: [{w: 300, h: 250}, {w: 300, h: 600}] + }); + expect(data.imp[0].video).to.deep.equal({ + mimes: ['video/mp4', 'application/javascript'], + w: 300, + h: 250, + api: [2], + protocols: [2, 5], + startdelay: 0, + linearity: 1, + maxbitrate: undefined, + maxduration: undefined, + minduration: undefined, + delivery: undefined, + pos: undefined, + playbackmethod: undefined, + rewarded: undefined, + placement: undefined + }); }); }); @@ -1006,7 +1221,6 @@ describe('YahooSSP Bid Adapter:', () => { invalidKey5: undefined }; const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.imp[0].ext.kvs).to.deep.equal({ key1: 'String', key2: 123456, @@ -1019,10 +1233,6 @@ describe('YahooSSP Bid Adapter:', () => { describe('Multiple adUnit validations:', () => { // Multiple banner adUnits it('should generate multiple bid-requests for each adUnit - 2 banner only', () => { - config.setConfig({ - yahoossp: { mode: 'banner' } - }); - const BID_ID_2 = '84ab50xxxxx'; const BID_POS_2 = 'footer'; const AD_UNIT_CODE_2 = 'test-ad-unit-code-123'; @@ -1036,12 +1246,12 @@ describe('YahooSSP Bid Adapter:', () => { validBidRequests = [bidRequest, bidRequest2, bidRequest3]; bidderRequest.bids = validBidRequests; - const response = spec.buildRequests(validBidRequests, bidderRequest) - expect(response).to.be.a('array'); - expect(response.length).to.equal(2); - response.forEach((obj) => { - expect(obj.data.imp[0].video).to.not.exist - expect(obj.data.imp[0].banner).to.deep.equal({ + const reqs = spec.buildRequests(validBidRequests, bidderRequest) + expect(reqs).to.be.a('array'); + expect(reqs.length).to.equal(2); + reqs.forEach(req => { + expect(req.data.imp[0].video).to.not.exist + expect(req.data.imp[0].banner).to.deep.equal({ mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], format: [{w: 300, h: 250}, {w: 300, h: 600}] }); @@ -1050,9 +1260,11 @@ describe('YahooSSP Bid Adapter:', () => { // Multiple video adUnits it('should generate multiple bid-requests for each adUnit - 2 video only', () => { - config.setConfig({ - yahoossp: { mode: 'video' } - }); + const cfg = {}; + cfg[DEFAULT_BIDDER_CODE] = { + mode: VIDEO + }; + config.setConfig(cfg); const BID_ID_2 = '84ab50xxxxx'; const BID_POS_2 = 'footer'; const AD_UNIT_CODE_2 = 'test-ad-unit-code-123'; @@ -1060,18 +1272,18 @@ describe('YahooSSP Bid Adapter:', () => { const BID_POS_3 = 'hero'; const AD_UNIT_CODE_3 = 'video-ad-unit'; - let { bidRequest, validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: 'video'}); // video - const { bidRequest: bidRequest2 } = generateBuildRequestMock({bidId: BID_ID_2, pos: BID_POS_2, adUnitCode: AD_UNIT_CODE_2, adUnitType: 'video'}); // video - const { bidRequest: bidRequest3 } = generateBuildRequestMock({bidId: BID_ID_3, pos: BID_POS_3, adUnitCode: AD_UNIT_CODE_3}); // banner (should be filtered) + let {bidRequest, validBidRequests, bidderRequest} = generateBuildRequestMock({adUnitType: 'video'}); // video + const {bidRequest: bidRequest2} = generateBuildRequestMock({bidId: BID_ID_2, pos: BID_POS_2, adUnitCode: AD_UNIT_CODE_2, adUnitType: 'video'}); // video + const {bidRequest: bidRequest3} = generateBuildRequestMock({bidId: BID_ID_3, pos: BID_POS_3, adUnitCode: AD_UNIT_CODE_3}); // banner (should be filtered) validBidRequests = [bidRequest, bidRequest2, bidRequest3]; bidderRequest.bids = validBidRequests; - const response = spec.buildRequests(validBidRequests, bidderRequest) - expect(response).to.be.a('array'); - expect(response.length).to.equal(2); - response.forEach((obj) => { - expect(obj.data.imp[0].banner).to.not.exist - expect(obj.data.imp[0].video).to.deep.equal({ + const reqs = spec.buildRequests(validBidRequests, bidderRequest) + expect(reqs).to.be.a('array'); + expect(reqs.length).to.equal(2); + reqs.forEach(req => { + expect(req.data.imp[0].banner).to.not.exist + expect(req.data.imp[0].video).to.deep.equal({ mimes: ['video/mp4', 'application/javascript'], w: 300, h: 250, @@ -1092,9 +1304,9 @@ describe('YahooSSP Bid Adapter:', () => { }); // Mixed adUnits 1-banner, 1-video, 1-native (should filter out native) it('should generate multiple bid-requests for both "video & banner" adUnits', () => { - config.setConfig({ - yahoossp: { mode: 'all' } - }); + const cfg = {}; + cfg[DEFAULT_BIDDER_CODE] = { mode: 'all' }; + config.setConfig(cfg); const BID_ID_2 = '84ab50xxxxx'; const BID_POS_2 = 'footer'; const AD_UNIT_CODE_2 = 'video-ad-unit'; @@ -1108,21 +1320,21 @@ describe('YahooSSP Bid Adapter:', () => { validBidRequests = [bidRequest, bidRequest2, bidRequest3]; bidderRequest.bids = validBidRequests; - const response = spec.buildRequests(validBidRequests, bidderRequest); - expect(response).to.be.a('array'); - expect(response.length).to.equal(2); - response.forEach((obj) => { - expect(obj.data.imp[0].native).to.not.exist; + const reqs = spec.buildRequests(validBidRequests, bidderRequest); + expect(reqs).to.be.a('array'); + expect(reqs.length).to.equal(2); + reqs.forEach(req => { + expect(req.data.imp[0].native).to.not.exist; }); - const data1 = response[0].data; + const data1 = reqs[0].data; expect(data1.imp[0].video).to.not.exist; expect(data1.imp[0].banner).to.deep.equal({ mimes: ['text/html', 'text/javascript', 'application/javascript', 'image/jpg'], format: [{w: 300, h: 250}, {w: 300, h: 600}] }); - const data2 = response[1].data; + const data2 = reqs[1].data; expect(data2.imp[0].banner).to.not.exist; expect(data2.imp[0].video).to.deep.equal({ mimes: ['video/mp4', 'application/javascript'], @@ -1145,90 +1357,98 @@ describe('YahooSSP Bid Adapter:', () => { }); describe('Video params firstlook & bidOverride validations:', () => { - it('should first look at params.bidOverride for video placement data', () => { - config.setConfig({ - yahoossp: { mode: 'video' } - }); - const bidOverride = { - imp: { - video: { - mimes: ['video/mp4'], - w: 400, - h: 350, - api: [1], - protocols: [1, 3], - startdelay: 0, - linearity: 1, - maxbitrate: 400000, - maxduration: 3600, - minduration: 1500, - delivery: 1, - pos: 123456, - playbackmethod: 1, - rewarded: 1, - placement: 1 + VALID_BIDDER_CODES.forEach(bidderCode => { + it(`should first look at params.bidOverride for video placement data for ${bidderCode} config override`, () => { + const cfg = {}; + cfg[bidderCode] = { + mode: VIDEO + }; + config.setConfig(cfg); + const bidOverride = { + imp: { + video: { + mimes: ['video/mp4'], + w: 400, + h: 350, + api: [1], + protocols: [1, 3], + startdelay: 0, + linearity: 1, + maxbitrate: 400000, + maxduration: 3600, + minduration: 1500, + delivery: 1, + pos: 123456, + playbackmethod: 1, + rewarded: 1, + placement: 1 + } } } - } - const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: 'video', bidOverrideObject: bidOverride}); - const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.imp[0].video).to.deep.equal(bidOverride.imp.video); - }); - - it('should second look at bid.mediaTypes.video for video placement data', () => { - config.setConfig({ - yahoossp: { mode: 'video' } - }); - let { bidRequest, bidderRequest } = generateBuildRequestMock({adUnitType: 'video'}); - bidRequest.mediaTypes.video = { - mimes: ['video/mp4'], - playerSize: [400, 350], - api: [1], - protocols: [1, 3], - startdelay: 0, - linearity: 1, - maxbitrate: 400000, - maxduration: 3600, - minduration: 1500, - delivery: 1, - pos: 123456, - playbackmethod: 1, - placement: 1 - } - const validBidRequests = [bidRequest]; - bidderRequest.bids = validBidRequests; - const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.imp[0].video).to.deep.equal({ - mimes: ['video/mp4'], - w: 400, - h: 350, - api: [1], - protocols: [1, 3], - startdelay: 0, - linearity: 1, - maxbitrate: 400000, - maxduration: 3600, - minduration: 1500, - delivery: 1, - pos: 123456, - playbackmethod: 1, - placement: 1, - rewarded: undefined + const { validBidRequests, bidderRequest } = generateBuildRequestMock({bidderCode, adUnitType: 'video', bidOverrideObject: bidOverride}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].video).to.deep.equal(bidOverride.imp.video); }); - }); - it('should use params.bidOverride.device.ip override', () => { - config.setConfig({ - yahoossp: { mode: 'all' } + it(`should second look at bid.mediaTypes.video for video placement data for ${bidderCode} config override`, () => { + const cfg = {}; + cfg[bidderCode] = { + mode: VIDEO + }; + config.setConfig(cfg); + let { bidRequest, bidderRequest } = generateBuildRequestMock({bidderCode, adUnitType: 'video'}); + bidRequest.mediaTypes.video = { + mimes: ['video/mp4'], + playerSize: [400, 350], + api: [1], + protocols: [1, 3], + startdelay: 0, + linearity: 1, + maxbitrate: 400000, + maxduration: 3600, + minduration: 1500, + delivery: 1, + pos: 123456, + playbackmethod: 1, + placement: 1 + } + const validBidRequests = [bidRequest]; + bidderRequest.bids = validBidRequests; + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.imp[0].video).to.deep.equal({ + mimes: ['video/mp4'], + w: 400, + h: 350, + api: [1], + protocols: [1, 3], + startdelay: 0, + linearity: 1, + maxbitrate: 400000, + maxduration: 3600, + minduration: 1500, + delivery: 1, + pos: 123456, + playbackmethod: 1, + placement: 1, + rewarded: undefined + }); }); - const bidOverride = { - device: { - ip: '1.2.3.4' + + it(`should use params.bidOverride.device.ip override for ${bidderCode} config override`, () => { + const cfg = {}; + cfg[bidderCode] = { + mode: 'all' + }; + config.setConfig(cfg); + const bidOverride = { + device: { + ip: '1.2.3.4' + } } - } - const { validBidRequests, bidderRequest } = generateBuildRequestMock({adUnitType: 'video', bidOverrideObject: bidOverride}); - const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; - expect(data.device.ip).to.deep.equal(bidOverride.device.ip); + const { validBidRequests, bidderRequest } = generateBuildRequestMock({bidderCode, adUnitType: 'video', bidOverrideObject: bidOverride}); + const data = spec.buildRequests(validBidRequests, bidderRequest)[0].data; + expect(data.device.ip).to.deep.equal(bidOverride.device.ip); + }); }); }); // #endregion buildRequests(): @@ -1244,6 +1464,22 @@ describe('YahooSSP Bid Adapter:', () => { }); describe('for mediaTypes: "video"', () => { + beforeEach(() => { + config.setConfig({ + yahooAds: { + mode: VIDEO + } + }); + }); + + afterEach(() => { + config.setConfig({ + yahooAds: { + mode: undefined + } + }); + }); + it('should insert video VPAID payload into vastXml', () => { const { serverResponse, bidderRequest } = generateResponseMock('video'); const response = spec.interpretResponse(serverResponse, {bidderRequest}); @@ -1261,28 +1497,38 @@ describe('YahooSSP Bid Adapter:', () => { expect(response[0].mediaType).to.equal('video'); }) - it('should insert video DAP O2 Player into ad', () => { - const { serverResponse, bidderRequest } = generateResponseMock('dap-o2', 'vpaid'); - const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ad).to.equal(''); - expect(response[0].vastUrl).to.be.undefined; - expect(response[0].vastXml).to.be.undefined; - expect(response[0].mediaType).to.equal('banner'); - }); + describe('wrapped in video players for display inventory', () => { + beforeEach(() => { + config.setConfig({ + yahooAds: { + mode: undefined + } + }); + }); - it('should insert video DAP Unified Player into ad', () => { - const { serverResponse, bidderRequest } = generateResponseMock('dap-up', 'vpaid'); - const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ad).to.equal(''); - expect(response[0].vastUrl).to.be.undefined; - expect(response[0].vastXml).to.be.undefined; - expect(response[0].mediaType).to.equal('banner'); - }) + it('should insert video DAP O2 Player into ad', () => { + const { serverResponse, bidderRequest } = generateResponseMock('dap-o2', 'vpaid'); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ad).to.equal(''); + expect(response[0].vastUrl).to.be.undefined; + expect(response[0].vastXml).to.be.undefined; + expect(response[0].mediaType).to.equal('banner'); + }); + + it('should insert video DAP Unified Player into ad', () => { + const { serverResponse, bidderRequest } = generateResponseMock('dap-up', 'vpaid'); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ad).to.equal(''); + expect(response[0].vastUrl).to.be.undefined; + expect(response[0].vastXml).to.be.undefined; + expect(response[0].mediaType).to.equal('banner'); + }) + }); }); describe('Support Advertiser domains', () => { it('should append bid-response adomain to meta.advertiserDomains', () => { - const { serverResponse, bidderRequest } = generateResponseMock('video', 'vpaid'); + const { serverResponse, bidderRequest } = generateResponseMock('banner'); const response = spec.interpretResponse(serverResponse, {bidderRequest}); expect(response[0].meta.advertiserDomains).to.be.a('array'); expect(response[0].meta.advertiserDomains[0]).to.equal('advertiser-domain.com'); @@ -1317,53 +1563,55 @@ describe('YahooSSP Bid Adapter:', () => { }); describe('Time To Live (ttl)', () => { - const UNSUPPORTED_TTL_FORMATS = ['string', [1, 2, 3], true, false, null, undefined]; - UNSUPPORTED_TTL_FORMATS.forEach(param => { - it('should not allow unsupported global yahoossp.ttl formats and default to 300', () => { - const { serverResponse, bidderRequest } = generateResponseMock('banner'); - config.setConfig({ - yahoossp: { ttl: param } + VALID_BIDDER_CODES.forEach(bidderCode => { + const UNSUPPORTED_TTL_FORMATS = ['string', [1, 2, 3], true, false, null, undefined]; + UNSUPPORTED_TTL_FORMATS.forEach(param => { + it(`should not allow unsupported global ${bidderCode}.ttl formats and default to 300`, () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + const cfg = {}; + cfg['yahooAds'] = { ttl: param }; + config.setConfig(cfg); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); }); - const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ttl).to.equal(300); - }); - it('should not allow unsupported params.ttl formats and default to 300', () => { - const { serverResponse, bidderRequest } = generateResponseMock('banner'); - bidderRequest.bids[0].params.ttl = param; - const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ttl).to.equal(300); + it('should not allow unsupported params.ttl formats and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + bidderRequest.bids[0].params.ttl = param; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); + }); }); - }); - const UNSUPPORTED_TTL_VALUES = [-1, 3601]; - UNSUPPORTED_TTL_VALUES.forEach(param => { - it('should not allow invalid global yahoossp.ttl values 3600 < ttl < 0 and default to 300', () => { - const { serverResponse, bidderRequest } = generateResponseMock('banner'); - config.setConfig({ - yahoossp: { ttl: param } + const UNSUPPORTED_TTL_VALUES = [-1, 3601]; + UNSUPPORTED_TTL_VALUES.forEach(param => { + it('should not allow invalid global config ttl values 3600 < ttl < 0 and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + config.setConfig({ + yahooAds: { ttl: param } + }); + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); + }); + + it('should not allow invalid params.ttl values 3600 < ttl < 0 and default to 300', () => { + const { serverResponse, bidderRequest } = generateResponseMock('banner'); + bidderRequest.bids[0].params.ttl = param; + const response = spec.interpretResponse(serverResponse, {bidderRequest}); + expect(response[0].ttl).to.equal(300); }); - const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ttl).to.equal(300); }); - it('should not allow invalid params.ttl values 3600 < ttl < 0 and default to 300', () => { + it('should give presedence to Gloabl ttl over params.ttl ', () => { const { serverResponse, bidderRequest } = generateResponseMock('banner'); - bidderRequest.bids[0].params.ttl = param; + config.setConfig({ + yahooAds: { ttl: 500 } + }); + bidderRequest.bids[0].params.ttl = 400; const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ttl).to.equal(300); + expect(response[0].ttl).to.equal(500); }); }); - - it('should give presedence to Gloabl ttl over params.ttl ', () => { - const { serverResponse, bidderRequest } = generateResponseMock('banner'); - config.setConfig({ - yahoossp: { ttl: 500 } - }); - bidderRequest.bids[0].params.ttl = 400; - const response = spec.interpretResponse(serverResponse, {bidderRequest}); - expect(response[0].ttl).to.equal(500); - }); }); describe('Aliasing support', () => { diff --git a/test/spec/modules/yandexBidAdapter_spec.js b/test/spec/modules/yandexBidAdapter_spec.js index 833f883fb7c..f14e8df6c09 100644 --- a/test/spec/modules/yandexBidAdapter_spec.js +++ b/test/spec/modules/yandexBidAdapter_spec.js @@ -1,38 +1,13 @@ -import {assert, expect} from 'chai'; -import {spec} from 'modules/yandexBidAdapter.js'; -import {parseUrl} from 'src/utils.js'; -import {BANNER} from '../../../src/mediaTypes'; +import { assert, expect } from 'chai'; +import { spec, NATIVE_ASSETS } from 'modules/yandexBidAdapter.js'; +import { parseUrl } from 'src/utils.js'; +import { BANNER, NATIVE } from '../../../src/mediaTypes'; +import { config } from '../../../src/config'; describe('Yandex adapter', function () { - function getBidConfig() { - return { - bidder: 'yandex', - params: { - pageId: 123, - impId: 1, - }, - }; - } - - function getBidRequest() { - return { - ...getBidConfig(), - bidId: 'bidid-1', - adUnitCode: 'adUnit-123', - mediaTypes: { - banner: { - sizes: [ - [300, 250], - [300, 600] - ], - }, - }, - }; - } - describe('isBidRequestValid', function () { it('should return true when required params found', function () { - const bid = getBidConfig(); + const bid = getBidRequest(); assert(spec.isBidRequestValid(bid)); }); @@ -40,41 +15,49 @@ describe('Yandex adapter', function () { expect(spec.isBidRequestValid({})).to.be.false; }); - it('should return false when required params.pageId are not passed', function () { + it('should return false when required params.placementId are not passed', function () { const bid = getBidConfig(); - delete bid.params.pageId; + delete bid.params.placementId; - expect(spec.isBidRequestValid(bid)).to.be.false + expect(spec.isBidRequestValid(bid)).to.be.false; }); - it('should return false when required params.impId are not passed', function () { + it('should return false when required params.placementId are not valid', function () { const bid = getBidConfig(); - delete bid.params.impId; + bid.params.placementId = '123'; - expect(spec.isBidRequestValid(bid)).to.be.false + expect(spec.isBidRequestValid(bid)).to.be.false; }); - }); - describe('buildRequests', function () { - const refererUrl = 'https://yandex.ru/secure-ads'; + it('should return true when passed deprecated placement config', function () { + const bid = getBidConfig(); + delete bid.params.placementId; - const gdprConsent = { - gdprApplies: 1, - consentString: 'concent-string', - apiVersion: 1, - }; + bid.params.pageId = 123; + bid.params.impId = 1; + expect(spec.isBidRequestValid(bid)); + }); + }); + + describe('buildRequests', function () { const bidderRequest = { refererInfo: { - referer: refererUrl + domain: 'ya.ru', + ref: 'https://ya.ru/', + page: 'https://ya.ru/', + }, + gdprConsent: { + gdprApplies: 1, + consentString: 'concent-string', + apiVersion: 1, }, - gdprConsent }; it('creates a valid banner request', function () { const bannerRequest = getBidRequest(); bannerRequest.getFloor = () => ({ - currency: 'USD', + currency: 'EUR', // floor: 0.5 }); @@ -91,11 +74,11 @@ describe('Yandex adapter', function () { const parsedRequestUrl = parseUrl(url); const { search: query } = parsedRequestUrl - expect(parsedRequestUrl.hostname).to.equal('bs-metadsp.yandex.ru'); - expect(parsedRequestUrl.pathname).to.equal('/metadsp/123'); + expect(parsedRequestUrl.hostname).to.equal('bs.yandex.ru'); + expect(parsedRequestUrl.pathname).to.equal('/prebid/123'); expect(query['imp-id']).to.equal('1'); - expect(query['target-ref']).to.equal('yandex.ru'); + expect(query['target-ref']).to.equal('ya.ru'); expect(query['ssp-id']).to.equal('10500'); expect(query['gdpr']).to.equal('1'); @@ -103,20 +86,248 @@ describe('Yandex adapter', function () { expect(request.data).to.exist; expect(data.site).to.not.equal(null); - expect(data.site.page).to.equal('yandex.ru'); + expect(data.site.page).to.equal('https://ya.ru/'); + expect(data.site.ref).to.equal('https://ya.ru/'); + }); - // expect(data.device).to.not.equal(null); - // expect(data.device.w).to.equal(window.innerWidth); - // expect(data.device.h).to.equal(window.innerHeight); + it('should send currency if defined', function () { + config.setConfig({ + currency: { + adServerCurrency: 'USD' + } + }); - expect(data.imp).to.have.lengthOf(1); - expect(data.imp[0].banner).to.not.equal(null); - expect(data.imp[0].banner.w).to.equal(300); - expect(data.imp[0].banner.h).to.equal(250); + const bannerRequest = getBidRequest(); + const requests = spec.buildRequests([bannerRequest], bidderRequest); + const { url } = requests[0]; + const parsedRequestUrl = parseUrl(url); + const { search: query } = parsedRequestUrl + + expect(query['ssp-cur']).to.equal('USD'); + }); + + it('should send eids if defined', function() { + const bannerRequest = getBidRequest({ + userIdAsEids: [{ + source: 'sharedid.org', + uids: [ + { + id: '01', + atype: 1 + } + ] + }] + }); + + const requests = spec.buildRequests([bannerRequest], bidderRequest); + + expect(requests).to.have.lengthOf(1); + const request = requests[0]; + + expect(request.data).to.exist; + const { data } = request; + + expect(data.user).to.exist; + expect(data.user).to.deep.equal({ + ext: { + eids: [{ + source: 'sharedid.org', + uids: [{ + id: '01', + atype: 1, + }], + }], + } + }); + }); + + describe('banner', () => { + it('should create valid banner object', () => { + const bannerRequest = getBidRequest({ + mediaTypes: { + banner: { + sizes: [ + [300, 250], + [300, 600] + ], + }, + } + }); + + const requests = spec.buildRequests([bannerRequest], bidderRequest); + expect(requests[0].data.imp).to.have.lengthOf(1); + + const imp = requests[0].data.imp[0]; + expect(imp.banner).to.not.equal(null); + expect(imp.banner.w).to.equal(300); + expect(imp.banner.h).to.equal(250); + + expect(imp.banner.format).to.deep.equal([ + { w: 300, h: 250 }, + { w: 300, h: 600 }, + ]); + }); + }); + + describe('native', () => { + function buildRequestAndGetNativeParams(extra) { + const bannerRequest = getBidRequest(extra); + const requests = spec.buildRequests([bannerRequest], bidderRequest); + + return JSON.parse(requests[0].data.imp[0].native.request); + } + + it('should extract native params', () => { + const nativeParams = buildRequestAndGetNativeParams({ + mediaTypes: { + native: { + title: { + required: true, + len: 100, + }, + body: { + len: 90 + }, + body2: { + len: 90 + }, + sponsoredBy: { + len: 25, + }, + icon: { + sizes: [32, 32], + }, + image: { + required: true, + sizes: [300, 250], + }, + }, + }, + }); + const sortedAssetsList = nativeParams.assets.sort((a, b) => a.id - b.id); + + expect(sortedAssetsList).to.deep.equal([ + { + id: NATIVE_ASSETS.title[0], + required: 1, + title: { + len: 100, + } + }, + { + id: NATIVE_ASSETS.body[0], + data: { + type: NATIVE_ASSETS.body[1], + len: 90, + }, + }, + { + id: NATIVE_ASSETS.body2[0], + data: { + type: NATIVE_ASSETS.body2[1], + len: 90, + }, + }, + { + id: NATIVE_ASSETS.sponsoredBy[0], + data: { + type: NATIVE_ASSETS.sponsoredBy[1], + len: 25, + }, + }, + { + id: NATIVE_ASSETS.icon[0], + img: { + type: NATIVE_ASSETS.icon[1], + w: 32, + h: 32, + }, + }, + { + id: NATIVE_ASSETS.image[0], + required: 1, + img: { + type: NATIVE_ASSETS.image[1], + w: 300, + h: 250, + }, + }, + ]); + }); + + it('should parse multiple image sizes', () => { + const nativeParams = buildRequestAndGetNativeParams({ + mediaTypes: { + native: { + image: { + sizes: [[300, 250], [100, 100]], + }, + }, + }, + }); + + expect(nativeParams.assets[0]).to.deep.equal({ + id: NATIVE_ASSETS.image[0], + img: { + type: NATIVE_ASSETS.image[1], + w: 300, + h: 250, + }, + }); + }); + + it('should parse aspect ratios with min_width', () => { + const nativeParams = buildRequestAndGetNativeParams({ + mediaTypes: { + native: { + image: { + aspect_ratios: [{ + min_width: 320, + ratio_width: 4, + ratio_height: 3, + }], + }, + }, + }, + }); + + expect(nativeParams.assets[0]).to.deep.equal({ + id: NATIVE_ASSETS.image[0], + img: { + type: NATIVE_ASSETS.image[1], + wmin: 320, + hmin: 240, + }, + }); + }); + + it('should parse aspect ratios without min_width', () => { + const nativeParams = buildRequestAndGetNativeParams({ + mediaTypes: { + native: { + image: { + aspect_ratios: [{ + ratio_width: 4, + ratio_height: 3, + }], + }, + }, + }, + }); + + expect(nativeParams.assets[0]).to.deep.equal({ + id: NATIVE_ASSETS.image[0], + img: { + type: NATIVE_ASSETS.image[1], + wmin: 100, + hmin: 75, + }, + }); + }); }); }); - describe('response handler', function () { + describe('interpretResponse', function () { const bannerRequest = getBidRequest(); const bannerResponse = { @@ -134,6 +345,7 @@ describe('Yandex adapter', function () { 'example.com' ], adid: 'yabs.123=', + nurl: 'https://example.com/nurl/?price=${AUCTION_PRICE}&cur=${AUCTION_CURRENCY}', } ] }], @@ -154,13 +366,134 @@ describe('Yandex adapter', function () { const rtbBid = result[0]; expect(rtbBid.width).to.equal(300); expect(rtbBid.height).to.equal(250); - expect(rtbBid.cpm).to.be.within(0.1, 0.5); + expect(rtbBid.cpm).to.be.within(0.3, 0.3); expect(rtbBid.ad).to.equal(''); expect(rtbBid.currency).to.equal('USD'); expect(rtbBid.netRevenue).to.equal(true); expect(rtbBid.ttl).to.equal(180); + expect(rtbBid.nurl).to.equal('https://example.com/nurl/?price=0.3&cur=USD'); expect(rtbBid.meta.advertiserDomains).to.deep.equal(['example.com']); }); + + describe('native', () => { + function getNativeAdmResponse() { + return { + native: { + link: { + url: 'https://example.com' + }, + imptrackers: [ + 'https://example.com/imptracker' + ], + assets: [ + { + title: { + text: 'title text', + }, + id: NATIVE_ASSETS.title[0], + }, + { + data: { + value: 'body text' + }, + id: NATIVE_ASSETS.body[0], + }, + { + data: { + value: 'sponsoredBy text' + }, + id: NATIVE_ASSETS.sponsoredBy[0], + }, + { + img: { + url: 'https://example.com/image', + w: 200, + h: 150, + }, + id: NATIVE_ASSETS.image[0], + }, + { + img: { + url: 'https://example.com/icon', + h: 32, + w: 32 + }, + id: NATIVE_ASSETS.icon[0], + }, + ] + } + }; + } + + it('handles native responses', function() { + bannerRequest.bidRequest = { + mediaType: NATIVE, + bidId: 'bidid-1', + }; + + const nativeAdmResponce = getNativeAdmResponse(); + const bannerResponse = { + body: { + seatbid: [{ + bid: [ + { + impid: 1, + price: 0.3, + adomain: [ + 'example.com' + ], + adid: 'yabs.123=', + adm: JSON.stringify(nativeAdmResponce), + }, + ], + }], + }, + }; + + const result = spec.interpretResponse(bannerResponse, bannerRequest); + + expect(result).to.have.lengthOf(1); + expect(result[0]).to.exist; + + const bid = result[0]; + expect(bid.meta.advertiserDomains).to.deep.equal(['example.com']); + expect(bid.native).to.deep.equal({ + clickUrl: 'https://example.com', + impressionTrackers: ['https://example.com/imptracker'], + title: 'title text', + body: 'body text', + sponsoredBy: 'sponsoredBy text', + image: { + url: 'https://example.com/image', + width: 200, + height: 150, + }, + icon: { + url: 'https://example.com/icon', + width: 32, + height: 32, + }, + }); + }); + }); }); }); + +function getBidConfig() { + return { + bidder: 'yandex', + params: { + placementId: '123-1', + }, + }; +} + +function getBidRequest(extra = {}) { + return { + ...getBidConfig(), + bidId: 'bidid-1', + adUnitCode: 'adUnit-123', + ...extra, + }; +} diff --git a/test/spec/modules/yieldlabBidAdapter_spec.js b/test/spec/modules/yieldlabBidAdapter_spec.js index e4d258ecdea..93c231c816b 100644 --- a/test/spec/modules/yieldlabBidAdapter_spec.js +++ b/test/spec/modules/yieldlabBidAdapter_spec.js @@ -1,83 +1,165 @@ import { config } from 'src/config.js'; -import { expect } from 'chai' -import { spec } from 'modules/yieldlabBidAdapter.js' -import { newBidder } from 'src/adapters/bidderFactory.js' - -const REQUEST = { - 'bidder': 'yieldlab', - 'params': { - 'adslotId': '1111', - 'supplyId': '2222', - 'targeting': { - 'key1': 'value1', - 'key2': 'value2', - 'notDoubleEncoded': 'value3,value4' +import { expect } from 'chai'; +import { spec } from 'modules/yieldlabBidAdapter.js'; +import { newBidder } from 'src/adapters/bidderFactory.js'; + +const DEFAULT_REQUEST = () => ({ + bidder: 'yieldlab', + params: { + adslotId: '1111', + supplyId: '2222', + targeting: { + key1: 'value1', + key2: 'value2', + notDoubleEncoded: 'value3,value4', }, - 'customParams': { - 'extraParam': true, - 'foo': 'bar' + customParams: { + extraParam: true, + foo: 'bar', + }, + extId: 'abc', + iabContent: { + id: 'foo_id', + episode: '99', + title: 'foo_title,bar_title', + series: 'foo_series', + season: 's1', + artist: 'foo bar', + genre: 'baz', + isrc: 'CC-XXX-YY-NNNNN', + url: 'http://foo_url.de', + cat: ['cat1', 'cat2,ppp', 'cat3|||//'], + context: '7', + keywords: ['k1,', 'k2..'], + live: '0', }, - 'extId': 'abc', - 'iabContent': { - 'id': 'foo_id', - 'episode': '99', - 'title': 'foo_title,bar_title', - 'series': 'foo_series', - 'season': 's1', - 'artist': 'foo bar', - 'genre': 'baz', - 'isrc': 'CC-XXX-YY-NNNNN', - 'url': 'http://foo_url.de', - 'cat': ['cat1', 'cat2,ppp', 'cat3|||//'], - 'context': '7', - 'keywords': ['k1,', 'k2..'], - 'live': '0' - } }, - 'bidderRequestId': '143346cf0f1731', - 'auctionId': '2e41f65424c87c', - 'adUnitCode': 'adunit-code', - 'bidId': '2d925f27f5079f', - 'sizes': [728, 90], - 'userIdAsEids': [{ - 'source': 'netid.de', - 'uids': [{ - 'id': 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', - 'atype': 1 - }] + bidderRequestId: '143346cf0f1731', + auctionId: '2e41f65424c87c', + adUnitCode: 'adunit-code', + bidId: '2d925f27f5079f', + sizes: [728, 90], + userIdAsEids: [{ + source: 'netid.de', + uids: [{ + id: 'fH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg', + atype: 1, + }], + }, { + source: 'digitrust.de', + uids: [{ + id: 'd8aa10fa-d86c-451d-aad8-5f16162a9e64', + atype: 2, + }], }], - 'schain': { - 'ver': '1.0', - 'complete': 1, - 'nodes': [ + schain: { + ver: '1.0', + complete: 1, + nodes: [ { - 'asi': 'indirectseller.com', - 'sid': '1', - 'hp': 1 + asi: 'indirectseller.com', + sid: '1', + hp: 1, }, { - 'asi': 'indirectseller2.com', - 'name': 'indirectseller2 name with comma , and bang !', - 'sid': '2', - 'hp': 1 - } - ] - } -} - -const VIDEO_REQUEST = Object.assign({}, REQUEST, { - 'mediaTypes': { - 'video': { - 'context': 'instream' - } - } -}) - -const NATIVE_REQUEST = Object.assign({}, REQUEST, { - 'mediaTypes': { - 'native': { } - } -}) + asi: 'indirectseller2.com', + name: 'indirectseller2 name with comma , and bang !', + sid: '2', + hp: 1, + }, + ], + }, +}); + +const VIDEO_REQUEST = () => Object.assign(DEFAULT_REQUEST(), { + mediaTypes: { + video: { + playerSize: [[640, 480]], + context: 'instream', + }, + }, +}); + +const NATIVE_REQUEST = () => Object.assign(DEFAULT_REQUEST(), { + mediaTypes: { + native: {}, + }, +}); + +const IAB_REQUEST = () => Object.assign(DEFAULT_REQUEST(), { + params: { + adslotId: '1111', + supplyId: '2222', + iabContent: { + id: 'foo', + episode: '99', + title: 'bar', + series: 'baz', + season: 's01', + artist: 'foobar', + genre: 'barbaz', + isrc: 'CC-XXX-YY-NNNNN', + url: 'https://foo.test', + cat: ['cat1', 'cat2,ppp', 'cat3|||//'], + context: '2', + keywords: ['k1', 'k2', 'k3', 'k4'], + live: '0', + album: 'foo', + cattax: '3', + prodq: 2, + contentrating: 'foo', + userrating: 'bar', + qagmediarating: 2, + sourcerelationship: 1, + len: 12345, + language: 'en', + embeddable: 0, + producer: { + id: 'foo', + name: 'bar', + cattax: 532, + cat: [1, 'foo', true], + domain: 'producer.test', + }, + data: { + id: 'foo', + name: 'bar', + segment: [{ + name: 'foo', + value: 'bar', + ext: { + foo: { + bar: 'bar', + }, + }, + }, { + name: 'foo2', + value: 'bar2', + ext: { + test: { + nums: { + int: 123, + float: 123.123, + }, + bool: true, + string: 'foo2', + }, + }, + }], + }, + network: { + id: 'foo', + name: 'bar', + domain: 'network.test', + }, + channel: { + id: 'bar', + name: 'foo', + domain: 'channel.test', + }, + }, + }, +}); const RESPONSE = { advertiser: 'yieldlab', @@ -87,348 +169,529 @@ const RESPONSE = { price: 1, pid: 2222, adsize: '728x90', - adtype: 'BANNER' -} + adtype: 'BANNER', +}; const NATIVE_RESPONSE = Object.assign({}, RESPONSE, { - 'adtype': 'NATIVE', - 'native': { - 'link': { - 'url': 'https://www.yieldlab.de' + adtype: 'NATIVE', + native: { + link: { + url: 'https://www.yieldlab.de', }, - 'assets': [ + assets: [ + { + id: 1, + title: { + text: 'This is a great headline', + }, + }, { - 'id': 1, - 'title': { - 'text': 'This is a great headline' - } + id: 2, + img: { + url: 'https://localhost:8080/yl-logo100x100.jpg', + w: 100, + h: 100, + type: 3, + }, }, { - 'id': 2, - 'img': { - 'url': 'https://localhost:8080/yl-logo100x100.jpg', - 'w': 100, - 'h': 100 - } + id: 3, + data: { + value: 'Native body value', + }, }, { - 'id': 3, - 'data': { - 'value': 'Native body value' - } - } + id: 4, + img: { + url: 'https://localhost:8080/assets/favicon/favicon-16x16.png', + w: 16, + h: 16, + type: 1, + }, + }, ], - 'imptrackers': [ + imptrackers: [ 'http://localhost:8080/ve?d=ODE9ZSY2MTI1MjAzNjMzMzYxPXN0JjA0NWUwZDk0NTY5Yi05M2FiLWUwZTQtOWFjNy1hYWY0MzFiZj1kaXQmMj12', 'http://localhost:8080/md/1111/9efa4e76-2030-4f04-bb9f-322541f8d611?mdata=false&pvid=false&ids=x:1', - 'http://localhost:8080/imp?s=13216&d=2171514&a=12548955&ts=1633363025216&tid=fb134faa-7ca9-4e0e-ba39-b96549d0e540&l=0' - ] - } -}) + 'http://localhost:8080/imp?s=13216&d=2171514&a=12548955&ts=1633363025216&tid=fb134faa-7ca9-4e0e-ba39-b96549d0e540&l=0', + ], + }, +}); const VIDEO_RESPONSE = Object.assign({}, RESPONSE, { - 'adtype': 'VIDEO' -}) + adtype: 'VIDEO', +}); const PVID_RESPONSE = Object.assign({}, VIDEO_RESPONSE, { - 'pvid': '43513f11-55a0-4a83-94e5-0ebc08f54a2c' -}) + pvid: '43513f11-55a0-4a83-94e5-0ebc08f54a2c', +}); const REQPARAMS = { json: true, - ts: 1234567890 -} + ts: 1234567890, +}; const REQPARAMS_GDPR = Object.assign({}, REQPARAMS, { gdpr: true, - consent: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA' -}) + consent: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA', +}); const REQPARAMS_IAB_CONTENT = Object.assign({}, REQPARAMS, { - iab_content: 'id%3Afoo_id%2Cepisode%3A99%2Ctitle%3Afoo_title%252Cbar_title%2Cseries%3Afoo_series%2Cseason%3As1%2Cartist%3Afoo%2520bar%2Cgenre%3Abaz%2Cisrc%3ACC-XXX-YY-NNNNN%2Curl%3Ahttp%253A%252F%252Ffoo_url.de%2Ccat%3Acat1%7Ccat2%252Cppp%7Ccat3%257C%257C%257C%252F%252F%2Ccontext%3A7%2Ckeywords%3Ak1%252C%7Ck2..%2Clive%3A0' -}) + iab_content: 'id%3Afoo_id%2Cepisode%3A99%2Ctitle%3Afoo_title%252Cbar_title%2Cseries%3Afoo_series%2Cseason%3As1%2Cartist%3Afoo%2520bar%2Cgenre%3Abaz%2Cisrc%3ACC-XXX-YY-NNNNN%2Curl%3Ahttp%253A%252F%252Ffoo_url.de%2Ccat%3Acat1%7Ccat2%252Cppp%7Ccat3%257C%257C%257C%252F%252F%2Ccontext%3A7%2Ckeywords%3Ak1%252C%7Ck2..%2Clive%3A0', +}); + +describe('yieldlabBidAdapter', () => { + describe('instantiation from spec', () => { + it('is working properly', () => { + const yieldlabBidAdapter = newBidder(spec); + expect(yieldlabBidAdapter.callBids).to.exist.and.to.be.a('function'); + }); + }); -describe('yieldlabBidAdapter', function () { - const adapter = newBidder(spec) + describe('isBidRequestValid', () => { + it('should return true when all required parameters are found', () => { + const request = { + params: { + adslotId: '1111', + supplyId: '2222', + }, + }; + expect(spec.isBidRequestValid(request)).to.equal(true); + }); - describe('inherited functions', function () { - it('exists and is a function', function () { - expect(adapter.callBids).to.exist.and.to.be.a('function') - }) - }) + it('should return false when required parameters are missing', () => { + expect(spec.isBidRequestValid({})).to.equal(false); + }); + }); - describe('isBidRequestValid', function () { - it('should return true when required params found', function () { - const request = { - 'params': { - 'adslotId': '1111', - 'supplyId': '2222' - } - } - expect(spec.isBidRequestValid(request)).to.equal(true) - }) - - it('should return false when required params are not passed', function () { - expect(spec.isBidRequestValid({})).to.equal(false) - }) - }) - - describe('buildRequests', function () { - const bidRequests = [REQUEST] - const request = spec.buildRequests(bidRequests) - - it('sends bid request to ENDPOINT via GET', function () { - expect(request.method).to.equal('GET') - }) - - it('returns a list of valid requests', function () { - expect(request.validBidRequests).to.eql([REQUEST]) - }) - - it('passes single-encoded targeting to bid request', function () { - expect(request.url).to.include('t=key1%3Dvalue1%26key2%3Dvalue2%26notDoubleEncoded%3Dvalue3%2Cvalue4') - }) - - it('passes userids to bid request', function () { - expect(request.url).to.include('ids=netid.de%3AfH5A3n2O8_CZZyPoJVD-eabc6ECb7jhxCicsds7qSg') - }) - - it('passes extra params to bid request', function () { - expect(request.url).to.include('extraParam=true&foo=bar') - }) - - it('passes unencoded schain string to bid request', function () { - expect(request.url).to.include('schain=1.0,1!indirectseller.com,1,1,,,,!indirectseller2.com,2,1,,indirectseller2%20name%20with%20comma%20%2C%20and%20bang%20%21,,') - }) - - it('passes iab_content string to bid request', function () { - expect(request.url).to.include('iab_content=id%3Afoo_id%2Cepisode%3A99%2Ctitle%3Afoo_title%252Cbar_title%2Cseries%3Afoo_series%2Cseason%3As1%2Cartist%3Afoo%2520bar%2Cgenre%3Abaz%2Cisrc%3ACC-XXX-YY-NNNNN%2Curl%3Ahttp%253A%252F%252Ffoo_url.de%2Ccat%3Acat1%7Ccat2%252Cppp%7Ccat3%257C%257C%257C%252F%252F%2Ccontext%3A7%2Ckeywords%3Ak1%252C%7Ck2..%2Clive%3A0') - }) - - const siteConfig = { - 'ortb2': { - 'site': { - 'content': { - 'id': 'id_from_config' - } - } - } - } - - it('generates iab_content string from bidder params', function () { - config.setConfig(siteConfig); - const request = spec.buildRequests([REQUEST]) - expect(request.url).to.include('iab_content=id%3Afoo_id%2Cepisode%3A99%2Ctitle%3Afoo_title%252Cbar_title%2Cseries%3Afoo_series%2Cseason%3As1%2Cartist%3Afoo%2520bar%2Cgenre%3Abaz%2Cisrc%3ACC-XXX-YY-NNNNN%2Curl%3Ahttp%253A%252F%252Ffoo_url.de%2Ccat%3Acat1%7Ccat2%252Cppp%7Ccat3%257C%257C%257C%252F%252F%2Ccontext%3A7%2Ckeywords%3Ak1%252C%7Ck2..%2Clive%3A0') - config.resetConfig(); - }) - - it('generates iab_content string from first party data if not provided in bidder params', function () { - const requestWithoutIabContent = { - 'params': { - 'adslotId': '1111', - 'supplyId': '2222' - } - } - config.setConfig(siteConfig); - const request = spec.buildRequests([requestWithoutIabContent]) - expect(request.url).to.include('iab_content=id%3Aid_from_config') - config.resetConfig(); - }) - - const refererRequest = spec.buildRequests(bidRequests, { - refererInfo: { - canonicalUrl: undefined, - numIframes: 0, - reachedTop: true, - referer: 'https://www.yieldlab.de/test?with=querystring', - stack: ['https://www.yieldlab.de/test?with=querystring'] - } - }) - - it('passes unencoded schain string to bid request when complete == 0', function () { - REQUEST.schain.complete = 0; - const request = spec.buildRequests([REQUEST]) - expect(request.url).to.include('schain=1.0,0!indirectseller.com,1,1,,,,!indirectseller2.com,2,1,,indirectseller2%20name%20with%20comma%20%2C%20and%20bang%20%21,,') - }) - - it('passes encoded referer to bid request', function () { - expect(refererRequest.url).to.include('pubref=https%3A%2F%2Fwww.yieldlab.de%2Ftest%3Fwith%3Dquerystring') - }) - - const gdprRequest = spec.buildRequests(bidRequests, { - gdprConsent: { - consentString: 'BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA', - gdprApplies: true - } - }) - - it('passes gdpr flag and consent if present', function () { - expect(gdprRequest.url).to.include('consent=BN5lERiOMYEdiAKAWXEND1AAAAE6DABACMA') - expect(gdprRequest.url).to.include('gdpr=true') - }) - }) - - describe('interpretResponse', function () { - it('handles nobid responses', function () { - expect(spec.interpretResponse({body: {}}, {validBidRequests: []}).length).to.equal(0) - expect(spec.interpretResponse({body: []}, {validBidRequests: []}).length).to.equal(0) - }) - - it('should get correct bid response', function () { - const result = spec.interpretResponse({body: [RESPONSE]}, {validBidRequests: [REQUEST], queryParams: REQPARAMS}) - - expect(result[0].requestId).to.equal('2d925f27f5079f') - expect(result[0].cpm).to.equal(0.01) - expect(result[0].width).to.equal(728) - expect(result[0].height).to.equal(90) - expect(result[0].creativeId).to.equal('1111') - expect(result[0].dealId).to.equal(2222) - expect(result[0].currency).to.equal('EUR') - expect(result[0].netRevenue).to.equal(false) - expect(result[0].ttl).to.equal(300) - expect(result[0].referrer).to.equal('') - expect(result[0].meta.advertiserDomains).to.equal('yieldlab') - expect(result[0].ad).to.include('', 'adid': '144762342', - 'adomain': [ + 'advertiserDomains': [ 'https://dummydomain.com' ], 'iurl': 'iurl', @@ -74,7 +74,7 @@ const RESPONSE = { 'price': 0.1, 'adm': '', 'adid': '144762342', - 'adomain': [ + 'advertiserDomains': [ 'https://dummydomain.com' ], 'iurl': 'iurl', @@ -191,6 +191,26 @@ describe('YieldLift', function () { expect(payload.user.ext).to.have.property('consent', req.gdprConsent.consentString); expect(payload.regs.ext).to.have.property('gdpr', 1); }); + + it('should properly forward eids parameters', function () { + const req = Object.assign({}, REQUEST); + req.bidRequest[0].userIdAsEids = [ + { + source: 'dummy.com', + uids: [ + { + id: 'd6d0a86c-20c6-4410-a47b-5cba383a698a', + atype: 1 + } + ] + }]; + let request = spec.buildRequests(req.bidRequest, req); + + const payload = JSON.parse(request.data); + expect(payload.user.ext.eids[0].source).to.equal('dummy.com'); + expect(payload.user.ext.eids[0].uids[0].id).to.equal('d6d0a86c-20c6-4410-a47b-5cba383a698a'); + expect(payload.user.ext.eids[0].uids[0].atype).to.equal(1); + }); }); describe('interpretResponse', function () { @@ -208,8 +228,8 @@ describe('YieldLift', function () { expect(bids[index]).to.have.property('height', RESPONSE.body.seatbid[0].bid[index].h); expect(bids[index]).to.have.property('ad', RESPONSE.body.seatbid[0].bid[index].adm); expect(bids[index]).to.have.property('creativeId', RESPONSE.body.seatbid[0].bid[index].crid); - expect(bids[index].meta).to.have.property('adomain', RESPONSE.body.seatbid[0].bid[index].adomain); - expect(bids[index]).to.have.property('ttl', 30); + expect(bids[index].meta).to.have.property('advertiserDomains', RESPONSE.body.seatbid[0].bid[index].advertiserDomains); + expect(bids[index]).to.have.property('ttl', 300); expect(bids[index]).to.have.property('netRevenue', true); } }); diff --git a/test/spec/modules/yieldloveBidAdapter_spec.js b/test/spec/modules/yieldloveBidAdapter_spec.js new file mode 100644 index 00000000000..b142eef0ffa --- /dev/null +++ b/test/spec/modules/yieldloveBidAdapter_spec.js @@ -0,0 +1,128 @@ +import { expect } from 'chai'; +import { spec } from 'modules/yieldloveBidAdapter.js'; + +const ENDPOINT_URL = 'https://s2s.yieldlove-ad-serving.net/openrtb2/auction'; + +// test params +const pid = 34437; +const rid = 'website.com'; + +describe('Yieldlove Bid Adaper', function () { + const bidRequests = [ + { + 'bidder': 'yieldlove', + 'adUnitCode': 'adunit-code', + 'sizes': [ [300, 250] ], + 'params': { + pid, + rid + } + } + ]; + + const serverResponse = { + body: { + seatbid: [ + { + bid: [ + { + impid: 'aaaa', + price: 0.5, + w: 300, + h: 250, + adm: '
test
', + crid: '1234', + } + ] + } + ], + ext: {} + } + } + + describe('isBidRequestValid', () => { + const bid = bidRequests[0]; + + it('should return true when required params found', function () { + expect(spec.isBidRequestValid(bid)).to.equal(true); + }); + + it('should return false when required params are not present', function () { + const invalidBid = { ...bid, params: {} }; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + + it('should return false when required param "pid" is not present', function () { + const invalidBid = { ...bid, params: { ...bid.params, pid: undefined } }; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + + it('should return false when required param "rid" is not present', function () { + const invalidBid = { ...bid, params: { ...bid.params, rid: undefined } }; + expect(spec.isBidRequestValid(invalidBid)).to.equal(false); + }); + }); + + describe('buildRequests', () => { + it('should build the request', function () { + const request = spec.buildRequests(bidRequests, {}); + const payload = request.data; + const url = request.url; + + expect(url).to.equal(ENDPOINT_URL); + + expect(payload.site).to.exist; + expect(payload.site.publisher).to.exist; + expect(payload.site.publisher.id).to.exist; + expect(payload.site.publisher.id).to.equal(rid); + expect(payload.site.domain).to.exist; + expect(payload.site.domain).to.equal(rid); + + expect(payload.imp).to.exist; + expect(payload.imp[0]).to.exist; + expect(payload.imp[0].ext).to.exist; + expect(payload.imp[0].ext.prebid).to.exist; + expect(payload.imp[0].ext.prebid.storedrequest).to.exist; + expect(payload.imp[0].ext.prebid.storedrequest.id).to.exist; + expect(payload.imp[0].ext.prebid.storedrequest.id).to.equal(pid.toString()); + }); + }); + + describe('interpretResponse', () => { + it('should interpret the response by pushing it in the bids elem', function () { + const allResponses = spec.interpretResponse(serverResponse); + const response = allResponses[0]; + const seatbid = serverResponse.body.seatbid[0].bid[0]; + + expect(response.requestId).to.exist; + expect(response.requestId).to.equal(seatbid.impid); + expect(response.cpm).to.exist; + expect(response.cpm).to.equal(seatbid.price); + expect(response.width).to.exist; + expect(response.width).to.equal(seatbid.w); + expect(response.height).to.exist; + expect(response.height).to.equal(seatbid.h); + expect(response.ad).to.exist; + expect(response.ad).to.equal(seatbid.adm); + expect(response.ttl).to.exist; + expect(response.creativeId).to.exist; + expect(response.creativeId).to.equal(seatbid.crid); + expect(response.netRevenue).to.exist; + expect(response.currency).to.exist; + }); + }); + + describe('getUserSyncs', function() { + it('should retrieve user iframe syncs', function () { + expect(spec.getUserSyncs({ iframeEnabled: true }, [serverResponse], undefined, undefined)).to.deep.equal([{ + type: 'iframe', + url: 'https://cdn-a.yieldlove.com/load-cookie.html?endpoint=yieldlove&max_sync_count=100&gdpr=NaN&gdpr_consent=&' + }]); + + expect(spec.getUserSyncs({ iframeEnabled: true }, [serverResponse], { gdprApplies: true, consentString: 'example' }, undefined)).to.deep.equal([{ + type: 'iframe', + url: 'https://cdn-a.yieldlove.com/load-cookie.html?endpoint=yieldlove&max_sync_count=100&gdpr=1&gdpr_consent=example&' + }]); + }); + }); +}) diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index f72705a79ac..229dc05e2fa 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -2,9 +2,13 @@ import { expect } from 'chai'; import { spec } from 'modules/yieldmoBidAdapter.js'; import * as utils from 'src/utils.js'; +/* eslint no-console: ["error", { allow: ["log", "warn", "error"] }] */ +// above is used for debugging purposes only + describe('YieldmoAdapter', function () { const BANNER_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebid'; const VIDEO_ENDPOINT = 'https://ads.yieldmo.com/exchange/prebidvideo'; + const PB_COOKIE_ASSIST_SYNC_ENDPOINT = `https://ads.yieldmo.com/pbcas`; const mockBannerBid = (rootParams = {}, params = {}) => ({ bidder: 'yieldmo', @@ -30,6 +34,7 @@ describe('YieldmoAdapter', function () { userId: { tdid: '8d146286-91d4-4958-aff4-7e489dd1abd6' }, + transactionId: '54a58774-7a41-494e-9aaf-fa7b79164f0c', ...rootParams }); @@ -37,6 +42,7 @@ describe('YieldmoAdapter', function () { bidder: 'yieldmo', adUnitCode: 'adunit-code-video', bidId: '321video123', + auctionId: '1d1a03073455', mediaTypes: { video: { playerSize: [640, 480], @@ -58,6 +64,7 @@ describe('YieldmoAdapter', function () { ...videoParams } }, + transactionId: '54a58774-7a41-494e-8cbc-fa7b79164f0c', ...rootParams }); @@ -171,15 +178,14 @@ describe('YieldmoAdapter', function () { it('should place bid information into the p parameter of data', function () { let bidArray = [mockBannerBid()]; expect(buildAndGetPlacementInfo(bidArray)).to.equal( - '[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1}]' + '[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1,"auctionId":"1d1a030790a475"}]' ); - // multiple placements bidArray.push(mockBannerBid( - {adUnitCode: 'adunit-2', bidId: '123a', bidderRequestId: '321', auctionId: '222'}, {bidFloor: 0.2})); + {adUnitCode: 'adunit-2', bidId: '123a', bidderRequestId: '321', auctionId: '222', transactionId: '444'}, {bidFloor: 0.2})); expect(buildAndGetPlacementInfo(bidArray)).to.equal( - '[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1},' + - '{"placement_id":"adunit-2","callback_id":"123a","sizes":[[300,250],[300,600]],"bidFloor":0.2}]' + '[{"placement_id":"adunit-code","callback_id":"30b31c1838de1e","sizes":[[300,250],[300,600]],"bidFloor":0.1,"auctionId":"1d1a030790a475"},' + + '{"placement_id":"adunit-2","callback_id":"123a","sizes":[[300,250],[300,600]],"bidFloor":0.2,"auctionId":"222"}]' ); }); @@ -188,7 +194,6 @@ describe('YieldmoAdapter', function () { let placementInfo = buildAndGetPlacementInfo(bidArray); expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); expect(placementInfo).not.to.include('"ym_placement_id":"ym_0987654321"'); - bidArray.push(mockBannerBid({}, {placementId: 'ym_0987654321'})); placementInfo = buildAndGetPlacementInfo(bidArray); expect(placementInfo).to.include('"ym_placement_id":"ym_1293871298"'); @@ -207,7 +212,7 @@ describe('YieldmoAdapter', function () { expect(data.hasOwnProperty('h')).to.be.true; expect(data.hasOwnProperty('w')).to.be.true; expect(data.hasOwnProperty('pubcid')).to.be.true; - expect(data.userConsent).to.equal('{"gdprApplies":"","cmp":""}'); + expect(data.userConsent).to.equal('{"gdprApplies":"","cmp":"","gpp":"","gpp_sid":[]}'); expect(data.us_privacy).to.equal(''); }); @@ -217,6 +222,24 @@ describe('YieldmoAdapter', function () { expect(buildAndGetData([pubcidBid]).pubcid).to.deep.equal(pubcid); }); + it('should add transaction id as parameter of request', function () { + const transactionId = '54a58774-7a41-494e-9aaf-fa7b79164f0c'; + const pubcidBid = mockBannerBid({ ortb2Imp: { + ext: { + tid: '54a58774-7a41-494e-9aaf-fa7b79164f0c', + } + }}); + const bidRequest = buildAndGetData([pubcidBid]); + expect(bidRequest.p).to.contain(transactionId); + }); + + it('should add auction id as parameter of request', function () { + const auctionId = '1d1a030790a475'; + const pubcidBid = mockBannerBid({}); + const bidRequest = buildAndGetData([pubcidBid]); + expect(bidRequest.p).to.contain(auctionId); + }); + it('should add unified id as parameter of request', function () { const unifiedIdBid = mockBannerBid({crumbs: undefined}); expect(buildAndGetData([unifiedIdBid]).tdid).to.deep.equal(mockBannerBid().userId.tdid); @@ -239,6 +262,24 @@ describe('YieldmoAdapter', function () { JSON.stringify({ gdprApplies: true, cmp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + gpp: '', + gpp_sid: [], + }) + ); + }); + + it('should add gpp information to request if available', () => { + const gppConsent = { + 'gppString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + 'applicableSections': [8] + }; + const data = buildAndGetData([mockBannerBid()], 0, mockBidderRequest({gppConsent})); + expect(data.userConsent).equal( + JSON.stringify({ + gdprApplies: '', + cmp: '', + gpp: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + gpp_sid: [8], }) ); }); @@ -348,7 +389,15 @@ describe('YieldmoAdapter', function () { it('should add eids to the banner bid request', function () { const params = { - userId: {pubcid: 'fake_pubcid'}, + userIdAsEids: [{ + source: 'pubcid.org', + uids: [ + { + id: 'fake_pubcid', + atype: 1, + } + ] + }], fakeUserIdAsEids: [{ source: 'pubcid.org', uids: [{ @@ -376,6 +425,18 @@ describe('YieldmoAdapter', function () { expect(requests[0].url).to.be.equal(VIDEO_ENDPOINT); }); + it('should not require params.video if required props in mediaTypes.video', function () { + videoBid.mediaTypes.video = { + ...videoBid.mediaTypes.video, + ...videoBid.params.video + }; + delete videoBid.params.video; + const requests = build([videoBid]); + expect(requests.length).to.equal(1); + expect(requests[0].method).to.equal('POST'); + expect(requests[0].url).to.be.equal(VIDEO_ENDPOINT); + }); + it('should add mediaTypes.video prop to the imp.video prop', function () { utils.deepAccess(videoBid, 'mediaTypes.video')['minduration'] = 40; expect(buildVideoBidAndGetVideoParam().minduration).to.equal(40); @@ -398,6 +459,20 @@ describe('YieldmoAdapter', function () { expect(buildVideoBidAndGetVideoParam().mimes).to.deep.equal(['video/mkv']); }); + it('should validate protocol in video bid request', function () { + expect( + spec.isBidRequestValid( + mockVideoBid({}, {}, { protocols: [2, 3, 11] }) + ) + ).to.be.true; + + expect( + spec.isBidRequestValid( + mockVideoBid({}, {}, { protocols: [2, 3, 10] }) + ) + ).to.be.false; + }); + describe('video.skip state check', () => { it('should not set video.skip if neither *.video.skip nor *.video.skippable is present', function () { utils.deepAccess(videoBid, 'mediaTypes.video')['skippable'] = false; @@ -470,6 +545,23 @@ describe('YieldmoAdapter', function () { expect(requests[0].data.ats_envelope).to.equal(envelope); }); + it('should add transaction id to video bid request', function() { + const transactionId = '54a58774-7a41-494e-8cbc-fa7b79164f0c'; + const requestData = { + ortb2Imp: { + ext: { + tid: '54a58774-7a41-494e-8cbc-fa7b79164f0c', + } + } + }; + expect(buildAndGetData([mockVideoBid({...requestData})]).imp[0].ext.tid).to.equal(transactionId); + }); + + it('should add auction id to video bid request', function() { + const auctionId = '1d1a03073455'; + expect(buildAndGetData([mockVideoBid({})]).auctionId).to.deep.equal(auctionId); + }); + it('should add schain if it is in the bidRequest', () => { const schain = { ver: '1.0', @@ -492,7 +584,15 @@ describe('YieldmoAdapter', function () { it('should add eids to the video bid request', function () { const params = { - userId: {pubcid: 'fake_pubcid'}, + userIdAsEids: [{ + source: 'pubcid.org', + uids: [ + { + id: 'fake_pubcid', + atype: 1, + } + ] + }], fakeUserIdAsEids: [{ source: 'pubcid.org', uids: [{ @@ -503,6 +603,76 @@ describe('YieldmoAdapter', function () { }; expect(buildAndGetData([mockVideoBid({...params})]).user.eids).to.eql(params.fakeUserIdAsEids); }); + it('should add device info to payload if available', function () { + let videoBidder = mockBidderRequest({ ortb2: { + device: { + sua: { + platform: { + brand: 'macOS', + version: [ '12', '4', '0' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Not;A=Brand', + version: [ '99', '0', '0', '0' ] + } + ], + mobile: 0, + model: '', + bitness: '64', + architecture: 'x86' + } + } + }}, [mockVideoBid()]); + let payload = buildAndGetData([mockVideoBid()], 0, videoBidder); + expect(payload.device.sua).to.exist; + expect(payload.device.sua).to.deep.equal({ + platform: { + brand: 'macOS', + version: [ '12', '4', '0' ] + }, + browsers: [ + { + brand: 'Chromium', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Google Chrome', + version: [ '106', '0', '5249', '119' ] + }, + { + brand: 'Not;A=Brand', + version: [ '99', '0', '0', '0' ] + } + ], + mobile: 0, + model: '', + bitness: '64', + architecture: 'x86' + } + ); + expect(payload.device.ua).to.not.exist; + expect(payload.device.language).to.not.exist; + // remove sua info and check device object + videoBidder = mockBidderRequest({ ortb2: { + device: { + ua: navigator.userAgent, + language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), + } + }}, [mockVideoBid()]); + payload = buildAndGetData([mockVideoBid()], 0, videoBidder); + expect(payload.device.sua).to.not.exist; + expect(payload.device.ua).to.exist; + expect(payload.device.language).to.exist; + }); }); }); @@ -606,8 +776,20 @@ describe('YieldmoAdapter', function () { }); describe('getUserSync', function () { - it('should return a tracker with type and url as parameters', function () { - expect(spec.getUserSyncs()).to.deep.equal([]); + const gdprFlag = `&gdpr=0`; + const usPrivacy = `us_privacy=`; + const gdprString = `&gdpr_consent=`; + const pbCookieAssistSyncUrl = `${PB_COOKIE_ASSIST_SYNC_ENDPOINT}?${usPrivacy}${gdprFlag}${gdprString}`; + it('should use type iframe when iframeEnabled', function() { + const syncs = spec.getUserSyncs({iframeEnabled: true}); + expect(syncs).to.deep.equal([{type: 'iframe', url: pbCookieAssistSyncUrl + '&type=iframe'}]) + }); + it('should use type image when pixelEnabled', function() { + const syncs = spec.getUserSyncs({pixelEnabled: true}); + expect(syncs).to.deep.equal([{type: 'image', url: pbCookieAssistSyncUrl + '&type=image'}]) + }); + it('should register no syncs', function () { + expect(spec.getUserSyncs({})).to.deep.equal([]); }); }); }); diff --git a/test/spec/modules/yieldoneAnalyticsAdapter_spec.js b/test/spec/modules/yieldoneAnalyticsAdapter_spec.js index 81a6365bba2..ea52f89773e 100644 --- a/test/spec/modules/yieldoneAnalyticsAdapter_spec.js +++ b/test/spec/modules/yieldoneAnalyticsAdapter_spec.js @@ -1,6 +1,7 @@ import yieldoneAnalytics from 'modules/yieldoneAnalyticsAdapter.js'; import { targeting } from 'src/targeting.js'; import { expect } from 'chai'; +import _ from 'lodash'; let events = require('src/events'); let adapterManager = require('src/adapterManager').default; let constants = require('src/constants.json'); @@ -46,7 +47,7 @@ describe('Yieldone Prebid Analytic', function () { { bidderCode: 'biddertest_1', auctionId: auctionId, - refererInfo: {referer: testReferrer}, + refererInfo: {page: testReferrer}, bids: [ { adUnitCode: '0000', @@ -71,7 +72,7 @@ describe('Yieldone Prebid Analytic', function () { { bidderCode: 'biddertest_2', auctionId: auctionId, - refererInfo: {referer: testReferrer}, + refererInfo: {page: testReferrer}, bids: [ { adUnitCode: '0000', @@ -87,7 +88,7 @@ describe('Yieldone Prebid Analytic', function () { { bidderCode: 'biddertest_3', auctionId: auctionId, - refererInfo: {referer: testReferrer}, + refererInfo: {page: testReferrer}, bids: [ { adUnitCode: '0000', @@ -225,7 +226,9 @@ describe('Yieldone Prebid Analytic', function () { pubId: initOptions.pubId, page: {url: testReferrer}, wrapper_version: '$prebid.version$', - events: expectedEvents + events: sinon.match(evs => { + return !expectedEvents.some((expectedEvent) => evs.find(ev => _.isEqual(ev, expectedEvent)) === -1) + }) }; const preparedWinnerParams = Object.assign({adServerTargeting: fakeTargeting}, winner); @@ -262,14 +265,18 @@ describe('Yieldone Prebid Analytic', function () { events.emit(constants.EVENTS.AUCTION_END, auctionEnd); - expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(expectedResult); + sinon.assert.match(yieldoneAnalytics.eventsStorage[auctionId], expectedResult); delete yieldoneAnalytics.eventsStorage[auctionId]; setTimeout(function() { events.emit(constants.EVENTS.BID_WON, winner); - sinon.assert.callCount(sendStatStub, 2); + sinon.assert.callCount(sendStatStub, 2) + const billableEventIndex = yieldoneAnalytics.eventsStorage[auctionId].events.findIndex(event => event.eventType === constants.EVENTS.BILLABLE_EVENT); + if (billableEventIndex > -1) { + yieldoneAnalytics.eventsStorage[auctionId].events.splice(billableEventIndex, 1); + } expect(yieldoneAnalytics.eventsStorage[auctionId]).to.deep.equal(wonExpectedResult); delete yieldoneAnalytics.eventsStorage[auctionId]; diff --git a/test/spec/modules/yieldoneBidAdapter_spec.js b/test/spec/modules/yieldoneBidAdapter_spec.js index d452d78e147..a10247411db 100644 --- a/test/spec/modules/yieldoneBidAdapter_spec.js +++ b/test/spec/modules/yieldoneBidAdapter_spec.js @@ -1,7 +1,6 @@ import { expect } from 'chai'; import { spec } from 'modules/yieldoneBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; -import { deepClone } from 'src/utils.js'; const ENDPOINT = 'https://y.one.impact-ad.jp/h_bid'; const USER_SYNC_URL = 'https://y.one.impact-ad.jp/push_sync'; @@ -141,7 +140,7 @@ describe('yieldoneBidAdapter', function() { }); }); - describe('New Format', function () { + describe('Single Format', function () { const bidRequests = [ { params: {placementId: '0'}, @@ -207,8 +206,11 @@ describe('yieldoneBidAdapter', function() { it('width and height should be set as separate parameters on outstream requests', function () { expect(request[0].data).to.not.have.property('w'); + expect(request[0].data).to.not.have.property('h'); expect(request[1].data).to.not.have.property('w'); + expect(request[1].data).to.not.have.property('h'); expect(request[2].data).to.not.have.property('w'); + expect(request[2].data).to.not.have.property('h'); expect(request[3].data.w).to.equal(1280); expect(request[3].data.h).to.equal(720); expect(request[4].data.w).to.equal(1920); @@ -261,12 +263,13 @@ describe('yieldoneBidAdapter', function() { it('width and height should be set as separate parameters on outstream requests', function () { expect(request[0].data).to.not.have.property('w'); + expect(request[0].data).to.not.have.property('h'); expect(request[1].data.w).to.equal(1920); expect(request[1].data.h).to.equal(1080); }); }); - describe('FLUX Format', function () { + describe('1x1 Format', function () { const bidRequests = [ { // It will be treated as a banner. @@ -327,6 +330,7 @@ describe('yieldoneBidAdapter', function() { it('width and height should be set as separate parameters on outstream requests', function () { expect(request[0].data).to.not.have.property('w'); + expect(request[0].data).to.not.have.property('h'); expect(request[1].data.w).to.equal(1920); expect(request[1].data.h).to.equal(1080); expect(request[2].data.w).to.equal(DEFAULT_VIDEO_SIZE.w); @@ -399,6 +403,76 @@ describe('yieldoneBidAdapter', function() { expect(request[0].data.imuid).to.equal('imuid_sample'); }); }); + + describe('DAC ID', function () { + it('dont send DAC ID if undefined', function () { + const bidRequests = [ + { + params: {placementId: '0'}, + }, + { + params: {placementId: '1'}, + userId: {}, + }, + { + params: {placementId: '2'}, + userId: undefined, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].data).to.not.have.property('dac_id'); + expect(request[1].data).to.not.have.property('dac_id'); + expect(request[2].data).to.not.have.property('dac_id'); + expect(request[0].data).to.not.have.property('fuuid'); + expect(request[1].data).to.not.have.property('fuuid'); + expect(request[2].data).to.not.have.property('fuuid'); + }); + + it('should send DAC ID if available', function () { + const bidRequests = [ + { + params: {placementId: '0'}, + userId: {dacId: {fuuid: 'fuuid_sample', id: 'dacId_sample'}}, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].data.fuuid).to.equal('fuuid_sample'); + expect(request[0].data.dac_id).to.equal('dacId_sample'); + }); + }); + + describe('ID5', function () { + it('dont send ID5 if undefined', function () { + const bidRequests = [ + { + params: {placementId: '0'}, + }, + { + params: {placementId: '1'}, + userId: {}, + }, + { + params: {placementId: '2'}, + userId: undefined, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].data).to.not.have.property('id5Id'); + expect(request[1].data).to.not.have.property('id5Id'); + expect(request[2].data).to.not.have.property('id5Id'); + }); + + it('should send ID5 if available', function () { + const bidRequests = [ + { + params: {placementId: '0'}, + userId: {id5id: {uid: 'id5id_sample'}}, + }, + ]; + const request = spec.buildRequests(bidRequests, bidderRequest); + expect(request[0].data.id5Id).to.equal('id5id_sample'); + }); + }); }); describe('interpretResponse', function () { @@ -413,7 +487,9 @@ describe('yieldoneBidAdapter', function() { 'cb': 12892917383, 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', 'uid': '23beaa6af6cdde', - 't': 'i' + 't': 'i', + 'language': 'ja', + 'screen_size': '1440x900' } } ]; @@ -429,9 +505,9 @@ describe('yieldoneBidAdapter', function() { 'currency': 'JPY', 'statusMessage': 'Bid available', 'dealId': 'P1-FIX-7800-DSP-MON', - 'admoain': [ + 'adomain': [ 'www.example.com' - ] + ], } }; @@ -457,7 +533,16 @@ describe('yieldoneBidAdapter', function() { }]; let result = spec.interpretResponse(serverResponseBanner, bidRequestBanner[0]); expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + expect(result[0].requestId).to.equal(expectedResponse[0].requestId); + expect(result[0].cpm).to.equal(expectedResponse[0].cpm); + expect(result[0].width).to.equal(expectedResponse[0].width); + expect(result[0].height).to.equal(expectedResponse[0].height); + expect(result[0].creativeId).to.equal(expectedResponse[0].creativeId); + expect(result[0].dealId).to.equal(expectedResponse[0].dealId); + expect(result[0].currency).to.equal(expectedResponse[0].currency); expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); + expect(result[0].ad).to.equal(expectedResponse[0].ad); + expect(result[0].meta.advertiserDomains[0]).to.equal(expectedResponse[0].meta.advertiserDomains[0]); }); let serverResponseVideo = { @@ -466,7 +551,7 @@ describe('yieldoneBidAdapter', function() { 'height': 360, 'width': 640, 'cpm': 0.0536616, - 'dealId': 'P1-FIX-766-DSP-MON', + 'dealId': 'P1-FIX-7800-DSP-MON', 'crid': '2494768', 'currency': 'JPY', 'statusMessage': 'Bid available', @@ -486,7 +571,9 @@ describe('yieldoneBidAdapter', function() { 'cb': 12892917383, 'r': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', 'uid': '23beaa6af6cdde', - 't': 'i' + 't': 'i', + 'language': 'ja', + 'screen_size': '1440x900' } } ]; @@ -502,7 +589,7 @@ describe('yieldoneBidAdapter', function() { 'currency': 'JPY', 'netRevenue': true, 'ttl': 3000, - 'referrer': '', + 'referrer': 'http%3A%2F%2Flocalhost%3A9876%2F%3Fid%3D74552836', 'meta': { 'advertiserDomains': [] }, @@ -515,9 +602,19 @@ describe('yieldoneBidAdapter', function() { }]; let result = spec.interpretResponse(serverResponseVideo, bidRequestVideo[0]); expect(Object.keys(result[0])).to.deep.equal(Object.keys(expectedResponse[0])); + expect(result[0].requestId).to.equal(expectedResponse[0].requestId); + expect(result[0].cpm).to.equal(expectedResponse[0].cpm); + expect(result[0].width).to.equal(expectedResponse[0].width); + expect(result[0].height).to.equal(expectedResponse[0].height); + expect(result[0].creativeId).to.equal(expectedResponse[0].creativeId); + expect(result[0].dealId).to.equal(expectedResponse[0].dealId); + expect(result[0].currency).to.equal(expectedResponse[0].currency); + expect(result[0].vastXml).to.equal(expectedResponse[0].vastXml); expect(result[0].mediaType).to.equal(expectedResponse[0].mediaType); + expect(result[0].referrer).to.equal(expectedResponse[0].referrer); expect(result[0].renderer.id).to.equal(expectedResponse[0].renderer.id); expect(result[0].renderer.url).to.equal(expectedResponse[0].renderer.url); + expect(result[0].meta.advertiserDomains[0]).to.equal(expectedResponse[0].meta.advertiserDomains[0]); }); it('handles empty bid response', function () { diff --git a/test/spec/modules/zeotapIdPlusIdSystem_spec.js b/test/spec/modules/zeotapIdPlusIdSystem_spec.js index 6494a7cbfef..54483f0c00e 100644 --- a/test/spec/modules/zeotapIdPlusIdSystem_spec.js +++ b/test/spec/modules/zeotapIdPlusIdSystem_spec.js @@ -4,6 +4,7 @@ import { config } from 'src/config.js'; import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; import { storage, getStorage, zeotapIdPlusSubmodule } from 'modules/zeotapIdPlusIdSystem.js'; import * as storageManager from 'src/storageManager.js'; +import {MODULE_TYPE_UID} from '../../../src/activities/modules.js'; const ZEOTAP_COOKIE_NAME = 'IDP'; const ZEOTAP_COOKIE = 'THIS-IS-A-DUMMY-COOKIE'; @@ -52,9 +53,9 @@ describe('Zeotap ID System', function() { }); it('when a stored Zeotap ID exists it is added to bids', function() { - let store = getStorage(); + getStorage(); expect(getStorageManagerSpy.calledOnce).to.be.true; - sinon.assert.calledWith(getStorageManagerSpy, {gvlid: 301, moduleName: 'zeotapIdPlus'}); + sinon.assert.calledWith(getStorageManagerSpy, {moduleType: MODULE_TYPE_UID, moduleName: 'zeotapIdPlus'}); }); }); diff --git a/test/spec/modules/zetaBidAdapter_spec.js b/test/spec/modules/zetaBidAdapter_spec.js index 25350725dee..529fb8e8d31 100644 --- a/test/spec/modules/zetaBidAdapter_spec.js +++ b/test/spec/modules/zetaBidAdapter_spec.js @@ -10,7 +10,7 @@ describe('Zeta Bid Adapter', function() { } }, refererInfo: { - referer: 'testprebid.com' + page: 'testprebid.com' }, params: { placement: 12345, diff --git a/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js b/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js index 15a1155f378..0796736a162 100644 --- a/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js @@ -1,20 +1,21 @@ import zetaAnalyticsAdapter from 'modules/zeta_global_sspAnalyticsAdapter.js'; import {config} from 'src/config'; import CONSTANTS from 'src/constants.json'; +import {server} from '../../mocks/xhr.js'; import {logError} from '../../../src/utils'; let utils = require('src/utils'); let events = require('src/events'); -const MOCK = { - STUB: { - 'auctionId': '25c6d7f5-699a-4bfc-87c9-996f915341fa' - }, +const EVENTS = { AUCTION_END: { 'auctionId': '75e394d9-ccce-4978-9238-91e6a1ac88a1', 'timestamp': 1638441234544, 'auctionEnd': 1638441234784, 'auctionStatus': 'completed', + 'metrics': { + 'someMetric': 1 + }, 'adUnits': [ { 'code': '/19968336/header-bid-tag-0', @@ -74,13 +75,6 @@ const MOCK = { 'bids': [ { 'bidder': 'zeta_global_ssp', - 'params': { - 'sid': 111, - 'tags': { - 'shortname': 'prebid_analytics_event_test_shortname', - 'position': 'test_position' - } - }, 'mediaTypes': { 'banner': { 'sizes': [ @@ -309,6 +303,9 @@ const MOCK = { 'cpm': 2.258302852806723, 'currency': 'USD', 'ad': 'test_ad', + 'metrics': { + 'someMetric': 0 + }, 'ttl': 200, 'creativeId': '456456456', 'netRevenue': true, @@ -344,11 +341,7 @@ const MOCK = { 'status': 'rendered', 'params': [ { - 'sid': 111, - 'tags': { - 'shortname': 'prebid_analytics_event_test_shortname', - 'position': 'test_position' - } + 'nonZetaParam': 'nonZetaValue' } ] }, @@ -358,14 +351,11 @@ const MOCK = { describe('Zeta Global SSP Analytics Adapter', function() { let sandbox; - let xhr; let requests; beforeEach(function() { sandbox = sinon.sandbox.create(); - requests = []; - xhr = sandbox.useFakeXMLHttpRequest(); - xhr.onCreate = request => requests.push(request); + requests = server.requests; sandbox.stub(events, 'getEvents').returns([]); }); @@ -395,33 +385,18 @@ describe('Zeta Global SSP Analytics Adapter', function() { zetaAnalyticsAdapter.disableAnalytics(); }); - it('events are sent', function() { - this.timeout(5000); - events.emit(CONSTANTS.EVENTS.AUCTION_INIT, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.AUCTION_END, MOCK.AUCTION_END); - events.emit(CONSTANTS.EVENTS.BID_ADJUSTMENT, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BID_TIMEOUT, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BID_REQUESTED, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BID_RESPONSE, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.NO_BID, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BID_WON, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BIDDER_DONE, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BIDDER_ERROR, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.SET_TARGETING, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BEFORE_BIDDER_HTTP, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.REQUEST_BIDS, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.ADD_AD_UNITS, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.AD_RENDER_FAILED, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, MOCK.AD_RENDER_SUCCEEDED); - events.emit(CONSTANTS.EVENTS.TCF2_ENFORCEMENT, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.AUCTION_DEBUG, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.BID_VIEWABLE, MOCK.STUB); - events.emit(CONSTANTS.EVENTS.STALE_RENDER, MOCK.STUB); + it('Move ZetaParams through analytics events', function() { + this.timeout(3000); + + events.emit(CONSTANTS.EVENTS.AUCTION_END, EVENTS.AUCTION_END); + events.emit(CONSTANTS.EVENTS.AD_RENDER_SUCCEEDED, EVENTS.AD_RENDER_SUCCEEDED); expect(requests.length).to.equal(2); - expect(JSON.parse(requests[0].requestBody)).to.deep.equal(MOCK.AUCTION_END); - expect(JSON.parse(requests[1].requestBody)).to.deep.equal(MOCK.AD_RENDER_SUCCEEDED); + const auctionEnd = JSON.parse(requests[0].requestBody); + const auctionSucceeded = JSON.parse(requests[1].requestBody); + + expect(auctionSucceeded.bid.params[0]).to.be.deep.equal(EVENTS.AUCTION_END.adUnits[0].bids[0].params); + expect(EVENTS.AUCTION_END.adUnits[0].bids[0].bidder).to.be.equal('zeta_global_ssp'); }); }); }); diff --git a/test/spec/modules/zeta_global_sspBidAdapter_spec.js b/test/spec/modules/zeta_global_sspBidAdapter_spec.js index 20113a63994..601f4546a29 100644 --- a/test/spec/modules/zeta_global_sspBidAdapter_spec.js +++ b/test/spec/modules/zeta_global_sspBidAdapter_spec.js @@ -25,6 +25,85 @@ describe('Zeta Ssp Bid Adapter', function () { } ]; + const schain = { + complete: 1, + nodes: [ + { + asi: 'asi1', + sid: 'sid1', + rid: 'rid1' + }, + { + asi: 'asi2', + sid: 'sid2', + rid: 'rid2' + } + ] + }; + + const params = { + user: { + uid: 222, + buyeruid: 333 + }, + tags: { + someTag: 444, + }, + sid: 'publisherId', + shortname: 'test_shortname', + tagid: 'test_tag_id', + site: { + page: 'testPage' + }, + app: { + bundle: 'testBundle' + }, + bidfloor: 0.2, + test: 1 + }; + + const multiImpRequest = [ + { + bidId: 12345, + auctionId: 67890, + mediaTypes: { + banner: { + sizes: [[300, 250]], + } + }, + refererInfo: { + page: 'http://www.zetaglobal.com/page?param=value', + domain: 'www.zetaglobal.com', + }, + gdprConsent: { + gdprApplies: 1, + consentString: 'consentString' + }, + uspConsent: 'someCCPAString', + params: params, + userIdAsEids: eids + }, { + bidId: 54321, + auctionId: 67890, + mediaTypes: { + banner: { + sizes: [[600, 400]], + } + }, + refererInfo: { + page: 'http://www.zetaglobal.com/page?param=value', + domain: 'www.zetaglobal.com', + }, + gdprConsent: { + gdprApplies: 1, + consentString: 'consentString' + }, + uspConsent: 'someCCPAString', + params: params, + userIdAsEids: eids + } + ]; + const bannerRequest = [{ bidId: 12345, auctionId: 67890, @@ -34,26 +113,41 @@ describe('Zeta Ssp Bid Adapter', function () { } }, refererInfo: { - referer: 'http://www.zetaglobal.com/page?param=value' + page: 'http://www.zetaglobal.com/page?param=value', + domain: 'www.zetaglobal.com', }, gdprConsent: { gdprApplies: 1, consentString: 'consentString' }, + schain: schain, uspConsent: 'someCCPAString', - params: { - placement: 111, - user: { - uid: 222, - buyeruid: 333 - }, - tags: { - someTag: 444, - sid: 'publisherId' - }, - test: 1 + params: params, + userIdAsEids: eids, + timeout: 500 + }]; + + const bannerWithFewSizesRequest = [{ + bidId: 12345, + auctionId: 67890, + mediaTypes: { + banner: { + sizes: [[300, 250], [200, 240], [100, 150]], + } + }, + refererInfo: { + page: 'http://www.zetaglobal.com/page?param=value', + domain: 'www.zetaglobal.com', }, - userIdAsEids: eids + gdprConsent: { + gdprApplies: 1, + consentString: 'consentString' + }, + schain: schain, + uspConsent: 'someCCPAString', + params: params, + userIdAsEids: eids, + timeout: 500 }]; const videoRequest = [{ @@ -66,25 +160,97 @@ describe('Zeta Ssp Bid Adapter', function () { mimes: ['video/mp4'], minduration: 5, maxduration: 30, + placement: 2, + plcmt: 1, protocols: [2, 3] } }, refererInfo: { referer: 'http://www.zetaglobal.com/page?param=video' }, - params: { - placement: 111, + params: params + }]; + + const zetaResponse = { + body: { + id: '12345', + seatbid: [ + { + bid: [ + { + id: 'auctionId', + impid: 'impId', + price: 0.0, + adm: 'adMarkup', + crid: 'creativeId', + adomain: [ + 'https://example.com' + ], + h: 250, + w: 300 + } + ] + } + ], + cur: 'USD' + } + } + + const responseBannerPayload = { + data: { + id: '123', + site: { + id: 'SITE_ID', + page: 'page.com', + domain: 'domain.com' + }, user: { - uid: 222, - buyeruid: 333 + id: '45asdf9tydhrty789adfad4678rew656789', + buyeruid: '1234567890' + }, + cur: [ + 'USD' + ], + imp: [ + { + id: '1', + banner: { + h: 600, + w: 160 + } + } + ], + at: 1 + } + }; + + const responseVideoPayload = { + data: { + id: '123', + site: { + id: 'SITE_ID', + page: 'page.com', + domain: 'domain.com' }, - tags: { - someTag: 444, - sid: 'publisherId' + user: { + id: '45asdf9tydhrty789adfad4678rew656789', + buyeruid: '1234567890' }, - test: 1 - }, - }]; + cur: [ + 'USD' + ], + imp: [ + { + id: '1', + video: { + h: 600, + w: 160 + } + } + ], + at: 1 + } + }; it('Test the bid validation function', function () { const validBid = spec.isBidRequestValid(bannerRequest[0]); @@ -111,7 +277,7 @@ describe('Zeta Ssp Bid Adapter', function () { const request = spec.buildRequests(bannerRequest, bannerRequest[0]); const payload = JSON.parse(request.data); expect(payload.site.page).to.eql('http://www.zetaglobal.com/page?param=value'); - expect(payload.site.domain).to.eql(window.location.origin); // config.js -> DEFAULT_PUBLISHER_DOMAIN + expect(payload.site.domain).to.eql('zetaglobal.com'); }); it('Test the request processing function', function () { @@ -139,7 +305,12 @@ describe('Zeta Ssp Bid Adapter', function () { 'https://example.com' ], h: 250, - w: 300 + w: 300, + ext: { + prebid: { + type: 'banner' + } + } }, { id: 'auctionId2', @@ -153,7 +324,9 @@ describe('Zeta Ssp Bid Adapter', function () { h: 150, w: 200, ext: { - bidtype: 'video' + prebid: { + type: 'video' + } } }, { @@ -166,7 +339,12 @@ describe('Zeta Ssp Bid Adapter', function () { 'https://example3.com' ], h: 400, - w: 300 + w: 300, + ext: { + prebid: { + type: 'video' + } + } } ] } @@ -175,7 +353,7 @@ describe('Zeta Ssp Bid Adapter', function () { } }; - const bidResponse = spec.interpretResponse(response, null); + const bidResponse = spec.interpretResponse(response, responseBannerPayload); expect(bidResponse).to.not.be.empty; const bid1 = bidResponse[0]; @@ -266,7 +444,164 @@ describe('Zeta Ssp Bid Adapter', function () { expect(payload.imp[0].video.mimes).to.eql(videoRequest[0].mediaTypes.video.mimes); expect(payload.imp[0].video.w).to.eql(720); expect(payload.imp[0].video.h).to.eql(340); + expect(payload.imp[0].video.placement).to.eql(videoRequest[0].mediaTypes.video.placement); + expect(payload.imp[0].video.plcmt).to.eql(videoRequest[0].mediaTypes.video.plcmt); expect(payload.imp[0].banner).to.be.undefined; }); + + it('Test required params in banner request', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?shortname=test_shortname'); + expect(payload.ext.sid).to.eql('publisherId'); + expect(payload.ext.tags.someTag).to.eql(444); + expect(payload.ext.tags.shortname).to.be.undefined; + }); + + it('Test required params in video request', function () { + const request = spec.buildRequests(videoRequest, videoRequest[0]); + const payload = JSON.parse(request.data); + expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?shortname=test_shortname'); + expect(payload.ext.sid).to.eql('publisherId'); + expect(payload.ext.tags.someTag).to.eql(444); + expect(payload.ext.tags.shortname).to.be.undefined; + }); + + it('Test multi imp', function () { + const request = spec.buildRequests(multiImpRequest, multiImpRequest[0]); + const payload = JSON.parse(request.data); + expect(request.url).to.eql('https://ssp.disqus.com/bid/prebid?shortname=test_shortname'); + + expect(payload.imp.length).to.eql(2); + + expect(payload.imp[0].id).to.eql(12345); + expect(payload.imp[1].id).to.eql(54321); + + expect(payload.imp[0].banner.w).to.eql(300); + expect(payload.imp[0].banner.h).to.eql(250); + + expect(payload.imp[1].banner.w).to.eql(600); + expect(payload.imp[1].banner.h).to.eql(400); + }); + + it('Test provide tmax', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + + expect(payload.tmax).to.eql(500); + }); + + it('Test provide tmax without value', function () { + const request = spec.buildRequests(videoRequest, videoRequest[0]); + const payload = JSON.parse(request.data); + + expect(payload.tmax).to.be.undefined; + }); + + it('Test provide bidfloor', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].bidfloor).to.eql(params.bidfloor); + }); + + it('Timeout should exists and be a function', function () { + expect(spec.onTimeout).to.exist.and.to.be.a('function'); + expect(spec.onTimeout({ timeout: 1000 })).to.be.undefined; + }); + + it('Test schain provided', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + + expect(payload.source.ext.schain).to.eql(schain); + }); + + it('Test tagid provided', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + + expect(payload.imp[0].tagid).to.eql(params.tagid); + }); + + it('Test if only one size', function () { + const request = spec.buildRequests(bannerRequest, bannerRequest[0]); + const payload = JSON.parse(request.data); + + // banner + expect(payload.imp[0].banner.w).to.eql(300); + expect(payload.imp[0].banner.h).to.eql(250); + + expect(payload.imp[0].banner.format).to.be.undefined; + }); + + it('Test few sizes provided in format', function () { + const request = spec.buildRequests(bannerWithFewSizesRequest, bannerWithFewSizesRequest[0]); + const payload = JSON.parse(request.data); + + // banner + expect(payload.imp[0].banner.w).to.eql(300); + expect(payload.imp[0].banner.h).to.eql(250); + + expect(payload.imp[0].banner.format.length).to.eql(3); + + // format[0] + expect(payload.imp[0].banner.format[0].w).to.eql(300); + expect(payload.imp[0].banner.format[0].h).to.eql(250); + + // format[1] + expect(payload.imp[0].banner.format[1].w).to.eql(200); + expect(payload.imp[0].banner.format[1].h).to.eql(240); + + // format[2] + expect(payload.imp[0].banner.format[2].w).to.eql(100); + expect(payload.imp[0].banner.format[2].h).to.eql(150); + }); + + it('Test the response default mediaType:banner', function () { + const bidResponse = spec.interpretResponse(zetaResponse, responseBannerPayload); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(BANNER); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.be.undefined; + }); + + it('Test the response default mediaType:video', function () { + const bidResponse = spec.interpretResponse(zetaResponse, responseVideoPayload); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(VIDEO); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + }); + + it('Test the response mediaType:video from ext param', function () { + zetaResponse.body.seatbid[0].bid[0].ext = { + prebid: { + type: 'video' + } + } + const bidResponse = spec.interpretResponse(zetaResponse, responseBannerPayload); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(VIDEO); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + }); + + it('Test the response mediaType:banner from ext param', function () { + zetaResponse.body.seatbid[0].bid[0].ext = { + prebid: { + type: 'banner' + } + } + const bidResponse = spec.interpretResponse(zetaResponse, responseVideoPayload); + expect(bidResponse).to.not.be.empty; + expect(bidResponse.length).to.eql(1); + expect(bidResponse[0].mediaType).to.eql(BANNER); + expect(bidResponse[0].ad).to.eql(zetaResponse.body.seatbid[0].bid[0].adm); + expect(bidResponse[0].vastXml).to.be.undefined; + }); }); diff --git a/test/spec/native_spec.js b/test/spec/native_spec.js index 66e11b9a472..9cfee6f5cd8 100644 --- a/test/spec/native_spec.js +++ b/test/spec/native_spec.js @@ -5,10 +5,16 @@ import { nativeBidIsValid, getAssetMessage, getAllAssetsMessage, - decorateAdUnitsWithNativeParams + toLegacyResponse, + decorateAdUnitsWithNativeParams, + isOpenRTBBidRequestValid, + isNativeOpenRTBBidValid, + toOrtbNativeRequest, toOrtbNativeResponse, legacyPropertiesToOrtbNative, fireImpressionTrackers, fireClickTrackers, } from 'src/native.js'; import CONSTANTS from 'src/constants.json'; -import {stubAuctionIndex} from '../helpers/indexStub.js'; +import { stubAuctionIndex } from '../helpers/indexStub.js'; +import { convertOrtbRequestToProprietaryNative, fromOrtbNativeRequest } from '../../src/native.js'; +import {auctionManager} from '../../src/auctionManager.js'; const utils = require('src/utils'); const bid = { @@ -21,25 +27,135 @@ const bid = { image: { url: 'http://cdn.example.com/p/creative-image/image.png', height: 83, - width: 127 + width: 127, }, icon: { url: 'http://cdn.example.com/p/creative-image/icon.jpg', height: 742, - width: 989 + width: 989, }, sponsoredBy: 'AppNexus', clickUrl: 'https://www.link.example', clickTrackers: ['https://tracker.example'], impressionTrackers: ['https://impression.example'], - javascriptTrackers: '', + javascriptTrackers: '', + privacyLink: 'https://privacy-link.example', ext: { foo: 'foo-value', - baz: 'baz-value' + baz: 'baz-value', + }, + }, +}; + +const ortbBid = { + adId: '123', + transactionId: 'au', + native: { + ortb: { + assets: [ + { + id: 0, + title: { + text: 'Native Creative' + } + }, + { + id: 1, + data: { + value: 'Cool description great stuff' + } + }, + { + id: 2, + data: { + value: 'Do it' + } + }, + { + id: 3, + img: { + url: 'http://cdn.example.com/p/creative-image/image.png', + h: 83, + w: 127 + } + }, + { + id: 4, + img: { + url: 'http://cdn.example.com/p/creative-image/icon.jpg', + h: 742, + w: 989 + } + }, + { + id: 5, + data: { + value: 'AppNexus', + type: 1 + } + } + ], + link: { + url: 'https://www.link.example' + }, + privacy: 'https://privacy-link.example', + ver: '1.2' } } }; +const completeNativeBid = { + adId: '123', + transactionId: 'au', + native: { + ...bid.native, + ...ortbBid.native + } +} + +const ortbRequest = { + assets: [ + { + id: 0, + required: 0, + title: { + len: 140 + } + }, { + id: 1, + required: 0, + data: { + type: 2 + } + }, { + id: 2, + required: 0, + data: { + type: 12 + } + }, { + id: 3, + required: 0, + img: { + type: 3 + } + }, { + id: 4, + required: 0, + img: { + type: 1 + } + }, { + id: 5, + required: 0, + data: { + type: 1 + } + } + ], + ver: '1.2' +} + const bidWithUndefinedFields = { transactionId: 'au', native: { @@ -50,12 +166,12 @@ const bidWithUndefinedFields = { clickUrl: 'https://www.link.example', clickTrackers: ['https://tracker.example'], impressionTrackers: ['https://impression.example'], - javascriptTrackers: '', + javascriptTrackers: '', ext: { foo: 'foo-value', - baz: undefined - } - } + baz: undefined, + }, + }, }; describe('native.js', function () { @@ -80,10 +196,17 @@ describe('native.js', function () { const targeting = getNativeTargeting(bid); expect(targeting[CONSTANTS.NATIVE_KEYS.title]).to.equal(bid.native.title); expect(targeting[CONSTANTS.NATIVE_KEYS.body]).to.equal(bid.native.body); - expect(targeting[CONSTANTS.NATIVE_KEYS.clickUrl]).to.equal(bid.native.clickUrl); + expect(targeting[CONSTANTS.NATIVE_KEYS.clickUrl]).to.equal( + bid.native.clickUrl + ); expect(targeting.hb_native_foo).to.equal(bid.native.foo); }); + it('can get targeting from null native keys', () => { + const targeting = getNativeTargeting({...bid, native: {...bid.native, displayUrl: null}}); + expect(targeting.hb_native_displayurl).to.not.be.ok; + }) + it('sends placeholders for configured assets', function () { const adUnit = { transactionId: 'au', @@ -92,23 +215,35 @@ describe('native.js', function () { clickUrl: { sendId: true }, ext: { foo: { - sendId: false + sendId: false, }, baz: { - sendId: true - } - } - } + sendId: true, + }, + }, + }, }; const targeting = getNativeTargeting(bid, deps(adUnit)); expect(targeting[CONSTANTS.NATIVE_KEYS.title]).to.equal(bid.native.title); - expect(targeting[CONSTANTS.NATIVE_KEYS.body]).to.equal('hb_native_body:123'); - expect(targeting[CONSTANTS.NATIVE_KEYS.clickUrl]).to.equal('hb_native_linkurl:123'); + expect(targeting[CONSTANTS.NATIVE_KEYS.body]).to.equal( + 'hb_native_body:123' + ); + expect(targeting[CONSTANTS.NATIVE_KEYS.clickUrl]).to.equal( + 'hb_native_linkurl:123' + ); expect(targeting.hb_native_foo).to.equal(bid.native.ext.foo); expect(targeting.hb_native_baz).to.equal('hb_native_baz:123'); }); + it('sends placeholdes targetings with ortb native response', function () { + const targeting = getNativeTargeting(completeNativeBid); + + expect(targeting[CONSTANTS.NATIVE_KEYS.title]).to.equal('Native Creative'); + expect(targeting[CONSTANTS.NATIVE_KEYS.body]).to.equal('Cool description great stuff'); + expect(targeting[CONSTANTS.NATIVE_KEYS.clickUrl]).to.equal('https://www.link.example'); + }); + it('should only include native targeting keys with values', function () { const adUnit = { transactionId: 'au', @@ -117,13 +252,13 @@ describe('native.js', function () { clickUrl: { sendId: true }, ext: { foo: { - required: false + required: false, }, baz: { - required: false - } - } - } + required: false, + }, + }, + }, }; const targeting = getNativeTargeting(bidWithUndefinedFields, deps(adUnit)); @@ -132,7 +267,7 @@ describe('native.js', function () { CONSTANTS.NATIVE_KEYS.title, CONSTANTS.NATIVE_KEYS.sponsoredBy, CONSTANTS.NATIVE_KEYS.clickUrl, - 'hb_native_foo' + 'hb_native_foo', ]); }); @@ -142,22 +277,19 @@ describe('native.js', function () { nativeParams: { image: { required: true, - sizes: [150, 50] + sizes: [150, 50], }, title: { required: true, len: 80, - sendTargetingKeys: true + sendTargetingKeys: true, }, sendTargetingKeys: false, - } - + }, }; const targeting = getNativeTargeting(bid, deps(adUnit)); - expect(Object.keys(targeting)).to.deep.equal([ - CONSTANTS.NATIVE_KEYS.title - ]); + expect(Object.keys(targeting)).to.deep.equal([CONSTANTS.NATIVE_KEYS.title]); }); it('should only include targeting if sendTargetingKeys not set to false', function () { @@ -166,38 +298,41 @@ describe('native.js', function () { nativeParams: { image: { required: true, - sizes: [150, 50] + sizes: [150, 50], }, title: { required: true, - len: 80 + len: 80, }, body: { - required: true + required: true, }, clickUrl: { - required: true + required: true, }, icon: { required: false, - sendTargetingKeys: false + sendTargetingKeys: false, }, cta: { required: false, - sendTargetingKeys: false + sendTargetingKeys: false, }, sponsoredBy: { required: false, - sendTargetingKeys: false + sendTargetingKeys: false, + }, + privacyLink: { + required: false, + sendTargetingKeys: false, }, ext: { foo: { required: false, - sendTargetingKeys: true - } - } - } - + sendTargetingKeys: true, + }, + }, + }, }; const targeting = getNativeTargeting(bid, deps(adUnit)); @@ -206,7 +341,7 @@ describe('native.js', function () { CONSTANTS.NATIVE_KEYS.body, CONSTANTS.NATIVE_KEYS.image, CONSTANTS.NATIVE_KEYS.clickUrl, - 'hb_native_foo' + 'hb_native_foo', ]); }); @@ -216,17 +351,16 @@ describe('native.js', function () { nativeParams: { image: { required: true, - sizes: [150, 50] + sizes: [150, 50], }, title: { required: true, len: 80, }, rendererUrl: { - url: 'https://www.renderer.com/' - } - } - + url: 'https://www.renderer.com/', + }, + }, }; const targeting = getNativeTargeting(bid, deps(adUnit)); @@ -238,7 +372,8 @@ describe('native.js', function () { CONSTANTS.NATIVE_KEYS.icon, CONSTANTS.NATIVE_KEYS.sponsoredBy, CONSTANTS.NATIVE_KEYS.clickUrl, - CONSTANTS.NATIVE_KEYS.rendererUrl + CONSTANTS.NATIVE_KEYS.privacyLink, + CONSTANTS.NATIVE_KEYS.rendererUrl, ]); expect(bid.native.rendererUrl).to.deep.equal('https://www.renderer.com/'); @@ -251,15 +386,14 @@ describe('native.js', function () { nativeParams: { image: { required: true, - sizes: [150, 50] + sizes: [150, 50], }, title: { required: true, len: 80, }, - adTemplate: '

##hb_native_body##<\/p><\/div>' - } - + adTemplate: '

##hb_native_body##

', + }, }; const targeting = getNativeTargeting(bid, deps(adUnit)); @@ -270,10 +404,13 @@ describe('native.js', function () { CONSTANTS.NATIVE_KEYS.image, CONSTANTS.NATIVE_KEYS.icon, CONSTANTS.NATIVE_KEYS.sponsoredBy, - CONSTANTS.NATIVE_KEYS.clickUrl + CONSTANTS.NATIVE_KEYS.clickUrl, + CONSTANTS.NATIVE_KEYS.privacyLink, ]); - expect(bid.native.adTemplate).to.deep.equal('

##hb_native_body##<\/p><\/div>'); + expect(bid.native.adTemplate).to.deep.equal( + '

##hb_native_body##

' + ); delete bid.native.adTemplate; }); @@ -281,7 +418,10 @@ describe('native.js', function () { fireNativeTrackers({}, bid); sinon.assert.calledOnce(triggerPixelStub); sinon.assert.calledWith(triggerPixelStub, bid.native.impressionTrackers[0]); - sinon.assert.calledWith(insertHtmlIntoIframeStub, bid.native.javascriptTrackers); + sinon.assert.calledWith( + insertHtmlIntoIframeStub, + bid.native.javascriptTrackers + ); }); it('fires click trackers', function () { @@ -291,105 +431,294 @@ describe('native.js', function () { sinon.assert.calledWith(triggerPixelStub, bid.native.clickTrackers[0]); }); - it('creates native asset message', function() { - const messageRequest = { - message: 'Prebid Native', - action: 'assetRequest', - adId: '123', - assets: ['hb_native_body', 'hb_native_image', 'hb_native_linkurl'], - }; + describe('native postMessages', () => { + let adUnit; + beforeEach(() => { + adUnit = {}; + sinon.stub(auctionManager, 'index').get(() => ({ + getAdUnit: () => adUnit + })) + }); - const message = getAssetMessage(messageRequest, bid); + it('creates native asset message', function () { + const messageRequest = { + message: 'Prebid Native', + action: 'assetRequest', + adId: '123', + assets: ['hb_native_body', 'hb_native_image', 'hb_native_linkurl'], + }; - expect(message.assets.length).to.equal(3); - expect(message.assets).to.deep.include({ - key: 'body', - value: bid.native.body - }); - expect(message.assets).to.deep.include({ - key: 'image', - value: bid.native.image.url - }); - expect(message.assets).to.deep.include({ - key: 'clickUrl', - value: bid.native.clickUrl + const message = getAssetMessage(messageRequest, bid); + + expect(message.assets.length).to.equal(3); + expect(message.assets).to.deep.include({ + key: 'body', + value: bid.native.body, + }); + expect(message.assets).to.deep.include({ + key: 'image', + value: bid.native.image.url, + }); + expect(message.assets).to.deep.include({ + key: 'clickUrl', + value: bid.native.clickUrl, + }); }); - }); - it('creates native all asset message', function() { - const messageRequest = { - message: 'Prebid Native', - action: 'allAssetRequest', - adId: '123', - }; + it('creates native all asset message', function () { + const messageRequest = { + message: 'Prebid Native', + action: 'allAssetRequest', + adId: '123', + }; - const message = getAllAssetsMessage(messageRequest, bid); + const message = getAllAssetsMessage(messageRequest, bid); - expect(message.assets.length).to.equal(9); - expect(message.assets).to.deep.include({ - key: 'body', - value: bid.native.body + expect(message.assets.length).to.equal(10); + expect(message.assets).to.deep.include({ + key: 'body', + value: bid.native.body, + }); + expect(message.assets).to.deep.include({ + key: 'image', + value: bid.native.image.url, + }); + expect(message.assets).to.deep.include({ + key: 'clickUrl', + value: bid.native.clickUrl, + }); + expect(message.assets).to.deep.include({ + key: 'title', + value: bid.native.title, + }); + expect(message.assets).to.deep.include({ + key: 'icon', + value: bid.native.icon.url, + }); + expect(message.assets).to.deep.include({ + key: 'cta', + value: bid.native.cta, + }); + expect(message.assets).to.deep.include({ + key: 'sponsoredBy', + value: bid.native.sponsoredBy, + }); + expect(message.assets).to.deep.include({ + key: 'foo', + value: bid.native.ext.foo, + }); + expect(message.assets).to.deep.include({ + key: 'baz', + value: bid.native.ext.baz, + }); }); - expect(message.assets).to.deep.include({ - key: 'image', - value: bid.native.image.url - }); - expect(message.assets).to.deep.include({ - key: 'clickUrl', - value: bid.native.clickUrl - }); - expect(message.assets).to.deep.include({ - key: 'title', - value: bid.native.title - }); - expect(message.assets).to.deep.include({ - key: 'icon', - value: bid.native.icon.url + + it('creates native all asset message with only defined fields', function () { + const messageRequest = { + message: 'Prebid Native', + action: 'allAssetRequest', + adId: '123', + }; + + const message = getAllAssetsMessage(messageRequest, bidWithUndefinedFields); + + expect(message.assets.length).to.equal(4); + expect(message.assets).to.deep.include({ + key: 'clickUrl', + value: bid.native.clickUrl, + }); + expect(message.assets).to.deep.include({ + key: 'title', + value: bid.native.title, + }); + expect(message.assets).to.deep.include({ + key: 'sponsoredBy', + value: bid.native.sponsoredBy, + }); + expect(message.assets).to.deep.include({ + key: 'foo', + value: bid.native.ext.foo, + }); }); - expect(message.assets).to.deep.include({ - key: 'cta', - value: bid.native.cta + + it('creates native all asset message with complete format', function () { + const messageRequest = { + message: 'Prebid Native', + action: 'allAssetRequest', + adId: '123', + }; + + const message = getAllAssetsMessage(messageRequest, completeNativeBid); + + expect(message.assets.length).to.equal(10); + expect(message.assets).to.deep.include({ + key: 'body', + value: bid.native.body, + }); + expect(message.assets).to.deep.include({ + key: 'image', + value: bid.native.image.url, + }); + expect(message.assets).to.deep.include({ + key: 'clickUrl', + value: bid.native.clickUrl, + }); + expect(message.assets).to.deep.include({ + key: 'title', + value: bid.native.title, + }); + expect(message.assets).to.deep.include({ + key: 'icon', + value: bid.native.icon.url, + }); + expect(message.assets).to.deep.include({ + key: 'cta', + value: bid.native.cta, + }); + expect(message.assets).to.deep.include({ + key: 'sponsoredBy', + value: bid.native.sponsoredBy, + }); + expect(message.assets).to.deep.include({ + key: 'privacyLink', + value: ortbBid.native.ortb.privacy, + }); + expect(message.assets).to.deep.include({ + key: 'foo', + value: bid.native.ext.foo, + }); + expect(message.assets).to.deep.include({ + key: 'baz', + value: bid.native.ext.baz, + }); }); - expect(message.assets).to.deep.include({ - key: 'sponsoredBy', - value: bid.native.sponsoredBy + + it('if necessary, adds ortb response when the request was in ortb', () => { + const messageRequest = { + message: 'Prebid Native', + action: 'allAssetRequest', + adId: '123', + }; + adUnit = {mediaTypes: {native: {ortb: ortbRequest}}, nativeOrtbRequest: ortbRequest} + const message = getAllAssetsMessage(messageRequest, bid); + const expected = toOrtbNativeResponse(bid.native, ortbRequest) + expect(message.ortb).to.eql(expected); + }) + }) + + const SAMPLE_ORTB_REQUEST = toOrtbNativeRequest({ + title: 'vtitle', + body: 'vbody' + }); + const SAMPLE_ORTB_RESPONSE = { + link: { + url: 'url' + }, + assets: [ + { + id: 0, + title: { + text: 'vtitle' + } + }, + { + id: 1, + data: { + value: 'vbody' + } + } + ], + eventtrackers: [ + { event: 1, method: 1, url: 'https://sampleurl.com' }, + { event: 1, method: 2, url: 'https://sampleurljs.com' } + ], + imptrackers: [ 'https://sample-imp.com' ] + } + describe('toLegacyResponse', () => { + it('returns assets in legacy format for ortb responses', () => { + const actual = toLegacyResponse(SAMPLE_ORTB_RESPONSE, SAMPLE_ORTB_REQUEST); + expect(actual.body).to.equal('vbody'); + expect(actual.title).to.equal('vtitle'); + expect(actual.clickUrl).to.equal('url'); + expect(actual.javascriptTrackers).to.equal(''); + expect(actual.impressionTrackers.length).to.equal(2); + expect(actual.impressionTrackers).to.contain('https://sampleurl.com'); + expect(actual.impressionTrackers).to.contain('https://sample-imp.com'); }); - expect(message.assets).to.deep.include({ - key: 'foo', - value: bid.native.ext.foo + }); +}); + +describe('validate native openRTB', function () { + it('should validate openRTB request', function () { + let openRTBNativeRequest = { assets: [] }; + // assets array can't be empty + expect(isOpenRTBBidRequestValid(openRTBNativeRequest)).to.eq(false); + openRTBNativeRequest.assets.push({ + id: 1.5, + required: 1, + title: {}, }); - expect(message.assets).to.deep.include({ - key: 'baz', - value: bid.native.ext.baz + + // asset.id must be integer + expect(isOpenRTBBidRequestValid(openRTBNativeRequest)).to.eq(false); + openRTBNativeRequest.assets[0].id = 1; + // title must have 'len' property + expect(isOpenRTBBidRequestValid(openRTBNativeRequest)).to.eq(false); + openRTBNativeRequest.assets[0].title.len = 140; + // openRTB request is valid + expect(isOpenRTBBidRequestValid(openRTBNativeRequest)).to.eq(true); + + openRTBNativeRequest.assets.push({ + id: 2, + required: 1, + video: { + mimes: [], + protocols: [], + minduration: 50, + }, }); + // video asset should have all required properties + expect(isOpenRTBBidRequestValid(openRTBNativeRequest)).to.eq(false); + openRTBNativeRequest.assets[1].video.maxduration = 60; + expect(isOpenRTBBidRequestValid(openRTBNativeRequest)).to.eq(true); }); - it('creates native all asset message with only defined fields', function() { - const messageRequest = { - message: 'Prebid Native', - action: 'allAssetRequest', - adId: '123', + it('should validate openRTB native bid', function () { + const openRTBRequest = { + assets: [ + { + id: 1, + required: 1, + }, + { + id: 2, + required: 0, + }, + { + id: 3, + required: 1, + }, + ], + }; + let openRTBBid = { + assets: [ + { + id: 1, + }, + { + id: 2, + }, + ], }; - const message = getAllAssetsMessage(messageRequest, bidWithUndefinedFields); + // link is missing + expect(isNativeOpenRTBBidValid(openRTBBid, openRTBRequest)).to.eq(false); + openRTBBid.link = { url: 'www.foo.bar' }; + // required id == 3 is missing + expect(isNativeOpenRTBBidValid(openRTBBid, openRTBRequest)).to.eq(false); - expect(message.assets.length).to.equal(4); - expect(message.assets).to.deep.include({ - key: 'clickUrl', - value: bid.native.clickUrl - }); - expect(message.assets).to.deep.include({ - key: 'title', - value: bid.native.title - }); - expect(message.assets).to.deep.include({ - key: 'sponsoredBy', - value: bid.native.sponsoredBy - }); - expect(message.assets).to.deep.include({ - key: 'foo', - value: bid.native.ext.foo - }); + openRTBBid.assets[1].id = 3; + expect(isNativeOpenRTBBidValid(openRTBBid, openRTBRequest)).to.eq(true); }); }); @@ -407,15 +736,15 @@ describe('validate native', function () { image: { required: true, sizes: [150, 50], - aspect_ratios: [150, 50] + aspect_ratios: [150, 50], }, icon: { required: true, - sizes: [50, 50] + sizes: [50, 50], }, - } - } - } + }, + }, + }; let validBid = { adId: 'abc123', @@ -424,23 +753,24 @@ describe('validate native', function () { adUnitCode: '123/prebid_native_adunit', bidder: 'test_bidder', native: { - body: 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + body: + 'This is a Prebid Native Creative. There are many like it, but this one is mine.', clickTrackers: ['http://my.click.tracker/url'], icon: { url: 'http://my.image.file/ad_image.jpg', height: 75, - width: 75 + width: 75, }, image: { url: 'http://my.icon.file/ad_icon.jpg', height: 2250, - width: 3000 + width: 3000, }, clickUrl: 'http://prebid.org/dev-docs/show-native-ads.html', impressionTrackers: ['http://my.imp.tracker/url'], - javascriptTrackers: '', - title: 'This is an example Prebid Native creative' - } + javascriptTrackers: '', + title: 'This is an example Prebid Native creative', + }, }; let noIconDimBid = { @@ -450,19 +780,20 @@ describe('validate native', function () { adUnitCode: '123/prebid_native_adunit', bidder: 'test_bidder', native: { - body: 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + body: + 'This is a Prebid Native Creative. There are many like it, but this one is mine.', clickTrackers: ['http://my.click.tracker/url'], icon: 'http://my.image.file/ad_image.jpg', image: { url: 'http://my.icon.file/ad_icon.jpg', height: 2250, - width: 3000 + width: 3000, }, clickUrl: 'http://prebid.org/dev-docs/show-native-ads.html', impressionTrackers: ['http://my.imp.tracker/url'], - javascriptTrackers: '', - title: 'This is an example Prebid Native creative' - } + javascriptTrackers: '', + title: 'This is an example Prebid Native creative', + }, }; let noImgDimBid = { @@ -472,19 +803,20 @@ describe('validate native', function () { adUnitCode: '123/prebid_native_adunit', bidder: 'test_bidder', native: { - body: 'This is a Prebid Native Creative. There are many like it, but this one is mine.', + body: + 'This is a Prebid Native Creative. There are many like it, but this one is mine.', clickTrackers: ['http://my.click.tracker/url'], icon: { url: 'http://my.image.file/ad_image.jpg', height: 75, - width: 75 + width: 75, }, image: 'http://my.icon.file/ad_icon.jpg', clickUrl: 'http://prebid.org/dev-docs/show-native-ads.html', impressionTrackers: ['http://my.imp.tracker/url'], - javascriptTrackers: '', - title: 'This is an example Prebid Native creative' - } + javascriptTrackers: '', + title: 'This is an example Prebid Native creative', + }, }; beforeEach(function () {}); @@ -493,12 +825,540 @@ describe('validate native', function () { it('should accept bid if no image sizes are defined', function () { decorateAdUnitsWithNativeParams([adUnit]); - const index = stubAuctionIndex({adUnits: [adUnit]}) - let result = nativeBidIsValid(validBid, {index}); + const index = stubAuctionIndex({ adUnits: [adUnit] }); + let result = nativeBidIsValid(validBid, { index }); expect(result).to.be.true; - result = nativeBidIsValid(noIconDimBid, {index}); + result = nativeBidIsValid(noIconDimBid, { index }); expect(result).to.be.true; - result = nativeBidIsValid(noImgDimBid, {index}); + result = nativeBidIsValid(noImgDimBid, { index }); expect(result).to.be.true; }); + + it('should convert from old-style native to OpenRTB request', () => { + const adUnit = { + transactionId: 'test_adunit', + mediaTypes: { + native: { + title: { + required: true, + }, + body: { + required: true, + len: 45 + }, + image: { + required: true, + sizes: [150, 50], + aspect_ratios: [{ + min_width: 150, + min_height: 50 + }] + }, + icon: { + required: true, + aspect_ratios: [{ + min_width: 150, + min_height: 50 + }] + }, + address: {}, + privacyLink: { + required: true + } + }, + }, + }; + + const ortb = toOrtbNativeRequest(adUnit.mediaTypes.native); + expect(ortb).to.be.a('object'); + expect(ortb.assets).to.be.a('array'); + + // title + expect(ortb.assets[0]).to.deep.include({ + id: 0, + required: 1, + title: { + len: 140 + } + }); + + // body => data + expect(ortb.assets[1]).to.deep.include({ + id: 1, + required: 1, + data: { + type: 2, + len: 45 + } + }); + + // image => image + expect(ortb.assets[2]).to.deep.include({ + id: 2, + required: 1, + img: { + type: 3, // Main Image + w: 150, + h: 50, + } + }); + + expect(ortb.assets[3]).to.deep.include({ + id: 3, + required: 1, + img: { + type: 1, // Icon Image + wmin: 150, + hmin: 50, + } + }); + + expect(ortb.assets[4]).to.deep.include({ + id: 4, + required: 0, + data: { + type: 9, + } + }); + expect(ortb.privacy).to.equal(1); + }); + + ['bogusKey', 'clickUrl', 'privacyLink'].forEach(nativeKey => { + it(`should not generate an empty asset for key ${nativeKey}`, () => { + const ortbReq = toOrtbNativeRequest({ + [nativeKey]: { + required: true + } + }); + expect(ortbReq.assets.length).to.equal(0); + }); + }) + + it('should convert from ortb to old-style native request', () => { + const openRTBRequest = { + 'ver': '1.2', + 'context': 2, + 'contextsubtype': 20, + 'plcmttype': 11, + 'plcmtcnt': 1, + 'aurlsupport': 0, + 'privacy': 1, + 'eventrackers': [ + { + 'event': 1, + 'methods': [1, 2] + }, + { + 'event': 2, + 'methods': [1] + } + ], + 'assets': [ + { + 'id': 123, + 'required': 1, + 'title': { + 'len': 140 + } + }, + { + 'id': 128, + 'required': 0, + 'img': { + 'wmin': 836, + 'hmin': 627, + 'type': 3 + } + }, + { + 'id': 124, + 'required': 1, + 'img': { + 'wmin': 50, + 'hmin': 50, + 'type': 1 + } + }, + { + 'id': 126, + 'required': 1, + 'data': { + 'type': 1, + 'len': 25 + } + }, + { + 'id': 127, + 'required': 1, + 'data': { + 'type': 2, + 'len': 140 + } + } + ] + }; + + const oldNativeRequest = fromOrtbNativeRequest(openRTBRequest); + + expect(oldNativeRequest).to.be.a('object'); + expect(oldNativeRequest.title).to.include({ + required: true, + len: 140 + }); + + expect(oldNativeRequest.image).to.deep.include({ + required: false, + aspect_ratios: [{ + min_width: 836, + min_height: 627, + ratio_width: 4, + ratio_height: 3 + }] + }); + + expect(oldNativeRequest.icon).to.deep.include({ + required: true, + aspect_ratios: [{ + min_width: 50, + min_height: 50, + ratio_width: 1, + ratio_height: 1 + }] + }); + expect(oldNativeRequest.sponsoredBy).to.include({ + required: true, + len: 25 + }); + expect(oldNativeRequest.body).to.include({ + required: true, + len: 140 + }); + expect(oldNativeRequest.privacyLink).to.include({ + required: false + }); + }); + + if (FEATURES.NATIVE) { + it('should convert ortb bid requests to proprietary requests', () => { + const validBidRequests = [{ + bidId: 'bidId3', + adUnitCode: 'adUnitCode3', + transactionId: 'transactionId3', + mediaTypes: { + banner: {} + }, + params: { + publisher: 'publisher2', + placement: 'placement3' + } + }]; + const resultRequests = convertOrtbRequestToProprietaryNative(validBidRequests); + expect(resultRequests).to.be.deep.equals(validBidRequests); + + validBidRequests[0].mediaTypes.native = { + ortb: { + ver: '1.2', + context: 2, + contextsubtype: 20, + plcmttype: 11, + plcmtcnt: 1, + aurlsupport: 0, + privacy: 1, + eventrackers: [ + { + event: 1, + methods: [1, 2] + }, + { + event: 2, + methods: [1] + } + ], + assets: [ + { + id: 123, + required: 1, + title: { + len: 140 + } + }, + { + id: 128, + required: 0, + img: { + wmin: 836, + hmin: 627, + type: 3 + } + }, + { + id: 124, + required: 1, + img: { + wmin: 50, + hmin: 50, + type: 1 + } + }, + { + id: 126, + required: 1, + data: { + type: 1, + len: 25 + } + }, + { + id: 127, + required: 1, + data: { + type: 2, + len: 140 + } + } + ] + } + }; + + const resultRequests2 = convertOrtbRequestToProprietaryNative(validBidRequests); + expect(resultRequests2[0].mediaTypes.native).to.deep.include({ + title: { + required: true, + len: 140 + }, + icon: { + required: true, + aspect_ratios: [{ + min_width: 50, + min_height: 50, + ratio_width: 1, + ratio_height: 1 + }] + }, + sponsoredBy: { + required: true, + len: 25 + }, + body: { + required: true, + len: 140 + } + }); + }); + } +}); + +describe('legacyPropertiesToOrtbNative', () => { + describe('click trakckers', () => { + it('should convert clickUrl to link.url', () => { + const native = legacyPropertiesToOrtbNative({clickUrl: 'some-url'}); + expect(native.link.url).to.eql('some-url'); + }); + it('should convert single clickTrackers to link.clicktrackers', () => { + const native = legacyPropertiesToOrtbNative({clickTrackers: 'some-url'}); + expect(native.link.clicktrackers).to.eql([ + 'some-url' + ]) + }); + it('should convert multiple clickTrackers into link.clicktrackers', () => { + const native = legacyPropertiesToOrtbNative({clickTrackers: ['url1', 'url2']}); + expect(native.link.clicktrackers).to.eql([ + 'url1', + 'url2' + ]) + }) + }); + describe('impressionTrackers', () => { + it('should convert a single tracker into an eventtracker entry', () => { + const native = legacyPropertiesToOrtbNative({impressionTrackers: 'some-url'}); + expect(native.eventtrackers).to.eql([ + { + event: 1, + method: 1, + url: 'some-url' + } + ]); + }); + + it('should convert an array into corresponding eventtracker entries', () => { + const native = legacyPropertiesToOrtbNative({impressionTrackers: ['url1', 'url2']}); + expect(native.eventtrackers).to.eql([ + { + event: 1, + method: 1, + url: 'url1' + }, + { + event: 1, + method: 1, + url: 'url2' + } + ]) + }) + }); + describe('javascriptTrackers', () => { + it('should convert a single value into jstracker', () => { + const native = legacyPropertiesToOrtbNative({javascriptTrackers: 'some-markup'}); + expect(native.jstracker).to.eql('some-markup'); + }) + it('should merge multiple values into a single jstracker', () => { + const native = legacyPropertiesToOrtbNative({javascriptTrackers: ['some-markup', 'some-other-markup']}); + expect(native.jstracker).to.eql('some-markupsome-other-markup'); + }) + }); + describe('privacylink', () => { + it('should convert privacyLink to privacy', () => { + const native = legacyPropertiesToOrtbNative({privacyLink: 'https:/my-privacy-link.com'}); + expect(native.privacy).to.eql('https:/my-privacy-link.com'); + }) + }) }); + +describe('fireImpressionTrackers', () => { + let runMarkup, fetchURL; + beforeEach(() => { + runMarkup = sinon.stub(); + fetchURL = sinon.stub(); + }) + + function runTrackers(resp) { + fireImpressionTrackers(resp, {runMarkup, fetchURL}) + } + + it('should run markup in jstracker', () => { + runTrackers({ + jstracker: 'some-markup' + }); + sinon.assert.calledWith(runMarkup, 'some-markup'); + }); + + it('should fetch each url in imptrackers', () => { + const urls = ['url1', 'url2']; + runTrackers({ + imptrackers: urls + }); + urls.forEach(url => sinon.assert.calledWith(fetchURL, url)); + }); + + it('should fetch each url in eventtrackers that use the image method', () => { + const urls = ['url1', 'url2']; + runTrackers({ + eventtrackers: urls.map(url => ({event: 1, method: 1, url})) + }); + urls.forEach(url => sinon.assert.calledWith(fetchURL, url)) + }); + + it('should load as a script each url in eventtrackers that use the js method', () => { + const urls = ['url1', 'url2']; + runTrackers({ + eventtrackers: urls.map(url => ({event: 1, method: 2, url})) + }); + urls.forEach(url => sinon.assert.calledWith(runMarkup, sinon.match(`script async src="${url}"`))) + }); + + it('should not fire trackers that are not impression trakcers', () => { + runTrackers({ + link: { + clicktrackers: ['click-url'] + }, + eventtrackers: [{ + event: 2, // not imp + method: 1, + url: 'some-url' + }] + }); + sinon.assert.notCalled(fetchURL); + sinon.assert.notCalled(runMarkup); + }) +}) + +describe('fireClickTrackers', () => { + let fetchURL; + beforeEach(() => { + fetchURL = sinon.stub(); + }); + + function runTrackers(resp, assetId = null) { + fireClickTrackers(resp, assetId, {fetchURL}); + } + + it('should load each URL in link.clicktrackers', () => { + const urls = ['url1', 'url2']; + runTrackers({ + link: { + clicktrackers: urls + } + }); + urls.forEach(url => sinon.assert.calledWith(fetchURL, url)); + }) + + it('should load each URL in asset.link.clicktrackers, when response is ORTB', () => { + const urls = ['asset_url1', 'asset_url2']; + runTrackers({ + assets: [ + { + id: 1, + link: { + clicktrackers: urls + } + } + ], + }, 1); + urls.forEach(url => sinon.assert.calledWith(fetchURL, url)); + }) +}) + +describe('toOrtbNativeResponse', () => { + it('should work when there are unrequested assets in the response', () => { + const legacyResponse = { + 'title': 'vtitle', + 'body': 'vbody' + } + const request = toOrtbNativeRequest({ + title: { + required: 'true' + }, + + }); + const ortbResponse = toOrtbNativeResponse(legacyResponse, request); + expect(ortbResponse.assets.length).to.eql(1); + }); + + it('should not modify the request', () => { + const legacyResponse = { + title: 'vtitle' + } + const request = toOrtbNativeRequest({ + title: { + required: true + } + }); + const requestCopy = JSON.parse(JSON.stringify(request)); + const response = toOrtbNativeResponse(legacyResponse, request); + expect(request).to.eql(requestCopy); + sinon.assert.match(response.assets[0], { + title: { + text: 'vtitle' + } + }) + }); + + it('should accept objects as legacy assets', () => { + const legacyResponse = { + icon: { + url: 'image-url' + } + } + const request = toOrtbNativeRequest({ + icon: { + required: true + } + }); + const response = toOrtbNativeResponse(legacyResponse, request); + sinon.assert.match(response.assets[0], { + img: { + url: 'image-url' + } + }) + }) +}) diff --git a/test/spec/ortb2.5StrictTranslator/dsl_spec.js b/test/spec/ortb2.5StrictTranslator/dsl_spec.js new file mode 100644 index 00000000000..c9b4575bcd2 --- /dev/null +++ b/test/spec/ortb2.5StrictTranslator/dsl_spec.js @@ -0,0 +1,137 @@ +import {Arr, ERR_ENUM, ERR_TYPE, ERR_UNKNOWN_FIELD, IntEnum, Obj} from '../../../libraries/ortb2.5StrictTranslator/dsl.js'; +import {deepClone} from '../../../src/utils.js'; + +describe('DSL', () => { + const spec = (() => { + const inner = Obj(['p21', 'p22'], { + enum: IntEnum(10, 20), + enumArray: Arr(IntEnum(10, 20)) + }); + return Obj(['p11', 'p12'], { + inner, + innerArray: Arr(inner) + }); + })(); + + let onError; + + function scan(obj) { + spec(null, null, null, obj, onError); + } + + beforeEach(() => { + onError = sinon.stub(); + }); + + it('checks object type', () => { + scan(null); + sinon.assert.calledWith(onError, ERR_TYPE, null, null, null, null); + }); + it('ignores known fields and ext', () => { + scan({p11: 1, p12: 2, ext: {e1: 1, e2: 2}}); + sinon.assert.notCalled(onError); + }); + it('detects unknown fields', () => { + const obj = {p11: 1, unk: 2}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_UNKNOWN_FIELD, 'unk', obj, 'unk', 2); + }); + describe('when nested', () => { + describe('directly', () => { + it('detects unknown fields', () => { + const obj = {inner: {p21: 1, unk: 2}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_UNKNOWN_FIELD, 'inner.unk', obj.inner, 'unk', 2); + }); + it('accepts enum values in range', () => { + scan({inner: {enum: 12}}); + sinon.assert.notCalled(onError); + }); + [Infinity, NaN, -Infinity].forEach(val => { + it(`does not accept ${val} in enum`, () => { + const obj = {inner: {enum: val}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_ENUM, 'inner.enum', obj.inner, 'enum', val); + }); + }); + it('accepts arrays of enums that are in range', () => { + scan({inner: {enumArray: [12, 13]}}); + sinon.assert.notCalled(onError); + }) + it('detects enum values out of range', () => { + const obj = {inner: {enum: -1}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_ENUM, 'inner.enum', obj.inner, 'enum', -1); + }); + it('detects enum values that are not numbers', () => { + const obj = {inner: {enum: 'err'}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_TYPE, 'inner.enum', obj.inner, 'enum', 'err'); + }) + it('detects arrays of enums that are out of range', () => { + const obj = {inner: {enumArray: [12, 13, -1, 14]}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_ENUM, 'inner.enumArray.2', obj.inner.enumArray, 2, -1); + }); + it('detects when enum arrays are not arrays', () => { + const obj = {inner: {enumArray: 'err'}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_TYPE, 'inner.enumArray', obj.inner, 'enumArray', 'err'); + }); + it('detects items within enum arrays that are not numbers', () => { + const obj = {inner: {enumArray: [12, 'err', 13]}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_TYPE, 'inner.enumArray.1', obj.inner.enumArray, 1, 'err'); + }) + }); + describe('into arrays', () => { + it('detects if inner array is not an array', () => { + const obj = {innerArray: 'err', inner: {p21: 1}}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_TYPE, 'innerArray', obj, 'innerArray', 'err'); + }); + it('detects when elements of inner array are not objects', () => { + const obj = {innerArray: [{p21: 1}, 'err', {ext: {r: 1}}]}; + scan(obj); + sinon.assert.calledOnce(onError); + sinon.assert.calledWith(onError, ERR_TYPE, 'innerArray.1', obj.innerArray, 1, 'err'); + }); + const oos = { + innerArray: [ + {p22: 2, unk: 3, enumArray: [-1, 12, 'err']}, + {p21: 1, enum: -1, ext: {e: 1}}, + ] + }; + it('detects invalid properties within inner array', () => { + const obj = deepClone(oos); + scan(obj); + sinon.assert.calledWith(onError, ERR_UNKNOWN_FIELD, 'innerArray.0.unk', obj.innerArray[0], 'unk', 3); + sinon.assert.calledWith(onError, ERR_ENUM, 'innerArray.0.enumArray.0', obj.innerArray[0].enumArray, 0, -1); + sinon.assert.calledWith(onError, ERR_TYPE, 'innerArray.0.enumArray.2', obj.innerArray[0].enumArray, 2, 'err'); + sinon.assert.calledWith(onError, ERR_ENUM, 'innerArray.1.enum', obj.innerArray[1], 'enum', -1); + }); + it('can remove all invalid properties during scan', () => { + onError.callsFake((errno, path, obj, field) => { + Array.isArray(obj) ? obj.splice(field, 1) : delete obj[field]; + }); + const obj = deepClone(oos); + scan(obj); + expect(obj).to.eql({ + innerArray: [ + {p22: 2, enumArray: [12]}, + {p21: 1, ext: {e: 1}} + ] + }); + }) + }) + }) +}); diff --git a/test/spec/ortb2.5StrictTranslator/spec_spec.js b/test/spec/ortb2.5StrictTranslator/spec_spec.js new file mode 100644 index 00000000000..a54b551bf61 --- /dev/null +++ b/test/spec/ortb2.5StrictTranslator/spec_spec.js @@ -0,0 +1,358 @@ +import {BidRequest} from '../../../libraries/ortb2.5StrictTranslator/spec.js'; + +// sample requests taken from ORTB 2.5 spec: https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf +const SAMPLE_REQUESTS = [ + { + 'id': '80ce30c53c16e6ede735f123ef6e32361bfc7b22', + 'at': 1, + 'cur': ['USD'], + 'imp': [ + { + 'id': '1', + 'bidfloor': 0.03, + 'banner': { + 'h': 250, 'w': 300, 'pos': 0 + } + } + ], + 'site': { + 'id': '102855', + 'cat': ['IAB3-1'], + 'domain': 'www.foobar.com', + 'page': 'http://www.foobar.com/1234.html ', + 'publisher': { + 'id': '8953', + 'name': 'foobar.com', + 'cat': ['IAB3-1'], + 'domain': 'foobar.com' + } + }, + 'device': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2', + 'ip': '123.145.167.10' + }, + 'user': { + 'id': '55816b39711f9b5acf3b90e313ed29e51665623f' + } + }, + { + 'id': '123456789316e6ede735f123ef6e32361bfc7b22', + 'at': 2, + 'cur': ['USD'], + 'imp': [ + { + 'id': '1', + 'bidfloor': 0.03, + 'iframebuster': ['vendor1.com', 'vendor2.com'], + 'banner': { + 'h': 250, + 'w': 300, + 'pos': 0, + 'battr': [13], + 'expdir': [2, 4] + } + } + ], + 'site': { + 'id': '102855', + 'cat': ['IAB3-1'], + 'domain': 'www.foobar.com', + 'page': 'http://www.foobar.com/1234.html', + 'publisher': { + 'id': '8953', + 'name': 'foobar.com', + 'cat': ['IAB3-1'], + 'domain': 'foobar.com' + } + }, + 'device': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2', + 'ip': '123.145.167.10' + }, + 'user': { + 'id': '55816b39711f9b5acf3b90e313ed29e51665623f', + 'buyeruid': '545678765467876567898765678987654', + 'data': [ + { + 'id': '6', + 'name': 'Data Provider 1', + 'segment': [ + { + 'id': '12341318394918', 'name': 'auto intenders' + }, + { + 'id': '1234131839491234', 'name': 'auto enthusiasts' + }, + { + 'id': '23423424', + 'name': 'data-provider1-age', + 'value': '30-40' + } + ] + } + ] + } + }, + { + 'id': 'IxexyLDIIk', + 'at': 2, + 'bcat': ['IAB25', 'IAB7-39', 'IAB8-18', 'IAB8-5', 'IAB9-9'], + 'badv': ['apple.com', 'go-text.me', 'heywire.com'], + 'imp': [ + { + 'id': '1', + 'bidfloor': 0.5, + 'instl': 0, + 'tagid': 'agltb3B1Yi1pbmNyDQsSBFNpdGUY7fD0FAw', + 'banner': { + 'w': 728, + 'h': 90, + 'pos': 1, + 'btype': [4], + 'battr': [14], + 'api': [3] + } + } + ], + 'app': { + 'id': 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfIUDA', + 'name': 'Yahoo Weather', + 'cat': ['IAB15', 'IAB15-10'], + 'ver': '1.0.2', + 'bundle': '12345', + 'storeurl': 'https://itunes.apple.com/id628677149', + 'publisher': { + 'id': 'agltb3B1Yi1pbmNyDAsSA0FwcBiJkfTUCV', + 'name': 'yahoo', + 'domain': 'www.yahoo.com' + } + }, + 'device': { + 'dnt': 0, + 'ua': 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3', + 'ip': '123.145.167.189', + 'ifa': 'AA000DFE74168477C70D291f574D344790E0BB11', + 'carrier': 'VERIZON', + 'language': 'en', + 'make': 'Apple', + 'model': 'iPhone', + 'os': 'iOS', + 'osv': '6.1', + 'js': 1, + 'connectiontype': 3, + 'devicetype': 1, + 'geo': { + 'lat': 35.012345, + 'lon': -115.12345, + 'country': 'USA', + 'metro': '803', + 'region': 'CA', + 'city': 'Los Angeles', + 'zip': '90049' + } + }, + 'user': { + 'id': 'ffffffd5135596709273b3a1a07e466ea2bf4fff', + 'yob': 1984, + 'gender': 'M' + } + }, + { + 'id': '1234567893', + 'at': 2, + 'tmax': 120, + 'imp': [ + { + 'id': '1', + 'bidfloor': 0.03, + 'video': { + 'w': 640, + 'h': 480, + 'pos': 1, + 'startdelay': 0, + 'minduration': 5, + 'maxduration': 30, + 'maxextended': 30, + 'minbitrate': 300, + 'maxbitrate': 1500, + 'api': [1, 2], + 'protocols': [2, 3], + 'mimes': [ + 'video/x-flv', + 'video/mp4', + 'application/x-shockwave-flash', + 'application/javascript' + ], + 'linearity': 1, + 'boxingallowed': 1, + 'playbackmethod': [1, 3], + 'delivery': [2], + 'battr': [13, 14], + 'companionad': [ + { + 'id': '1234567893-1', + 'w': 300, + 'h': 250, + 'pos': 1, + 'battr': [13, 14], + 'expdir': [2, 4] + }, + { + 'id': '1234567893-2', + 'w': 728, + 'h': 90, + 'pos': 1, + 'battr': [13, 14] + } + ], + 'companiontype': [1, 2] + } + } + ], + 'site': { + 'id': '1345135123', + 'name': 'Site ABCD', + 'domain': 'siteabcd.com', + 'cat': ['IAB2-1', 'IAB2-2'], + 'page': 'http://siteabcd.com/page.htm', + 'ref': 'http://referringsite.com/referringpage.htm', + 'privacypolicy': 1, + 'publisher': { + 'id': 'pub12345', 'name': 'Publisher A' + }, + 'content': { + 'id': '1234567', + 'series': 'All About Cars', + 'season': '2', + 'episode': 23, + 'title': 'Car Show', + 'cat': ['IAB2-2'], + 'keywords': 'keyword-a,keyword-b,keyword-c' + } + }, + 'device': { + 'ip': '64.124.253.1', + 'ua': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16', + 'os': 'OS X', + 'flashver': '10.1', + 'js': 1 + }, + 'user': { + 'id': '456789876567897654678987656789', + 'buyeruid': '545678765467876567898765678987654', + 'data': [ + { + 'id': '6', + 'name': 'Data Provider 1', + 'segment': [ + { + 'id': '12341318394918', 'name': 'auto intenders' + }, + { + 'id': '1234131839491234', 'name': 'auto enthusiasts' + } + ] + } + ] + } + }, + { + 'id': '80ce30c53c16e6ede735f123ef6e32361bfc7b22', + 'at': 1, + 'cur': ['USD'], + 'imp': [ + { + 'id': '1', + 'bidfloor': 0.03, + 'banner': { + 'h': 250, 'w': 300, 'pos': 0 + }, + 'pmp': { + 'private_auction': 1, + 'deals': [ + { + 'id': 'AB-Agency1-0001', + 'at': 1, + 'bidfloor': 2.5, + 'wseat': ['Agency1'] + }, + { + 'id': 'XY-Agency2-0001', + 'at': 2, + 'bidfloor': 2, + 'wseat': ['Agency2'] + } + ] + } + } + ], + 'site': { + 'id': '102855', + 'domain': 'www.foobar.com', + 'cat': ['IAB3-1'], + 'page': 'http://www.foobar.com/1234.html', + 'publisher': { + 'id': '8953', + 'name': 'foobar.com', + 'cat': ['IAB3-1'], + 'domain': 'foobar.com' + } + }, + 'device': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2', + 'ip': '123.145.167.10' + }, + 'user': { + 'id': '55816b39711f9b5acf3b90e313ed29e51665623f' + } + }, +]; + +if (FEATURES.NATIVE) { + SAMPLE_REQUESTS.push({ + 'id': '80ce30c53c16e6ede735f123ef6e32361bfc7b22', + 'at': 1, + 'cur': ['USD'], + 'imp': [ + { + 'id': '1', + 'bidfloor': 0.03, + 'native': { + 'request': '{"native":{"ver":"1.0","assets":[ ... ]}}', + 'ver': '1.0', + 'api': [3], + 'battr': [13, 14] + } + } + ], + 'site': { + 'id': '102855', + 'cat': ['IAB3-1'], + 'domain': 'www.foobar.com', + 'page': 'http://www.foobar.com/1234.html ', + 'publisher': { + 'id': '8953', + 'name': 'foobar.com', + 'cat': ['IAB3-1'], + 'domain': 'foobar.com' + } + }, + 'device': { + 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2', + 'ip': '123.145.167.10' + }, + 'user': { + 'id': '55816b39711f9b5acf3b90e313ed29e51665623f' + } + }); +} + +describe('BidRequest spec', () => { + SAMPLE_REQUESTS.forEach((req, i) => { + it(`accepts sample #${i}`, () => { + const onError = sinon.stub(); + BidRequest(null, null, null, req, onError); + sinon.assert.notCalled(onError); + }); + }); +}); diff --git a/test/spec/ortb2.5StrictTranslator/translator_spec.js b/test/spec/ortb2.5StrictTranslator/translator_spec.js new file mode 100644 index 00000000000..4bda3d96235 --- /dev/null +++ b/test/spec/ortb2.5StrictTranslator/translator_spec.js @@ -0,0 +1,16 @@ +import {toOrtb25Strict} from '../../../libraries/ortb2.5StrictTranslator/translator.js'; + +describe('toOrtb25Strict', () => { + let translator; + beforeEach(() => { + translator = sinon.stub().callsFake((o) => o); + }) + it('uses provided translator', () => { + translator.reset(); + translator.callsFake(() => ({id: 'test'})); + expect(toOrtb25Strict(null, translator)).to.eql({id: 'test'}); + }); + it('removes fields out of spec', () => { + expect(toOrtb25Strict({unk: 'field', imp: ['err', {}]}, translator)).to.eql({imp: [{}]}); + }); +}); diff --git a/test/spec/ortb2.5Translator/translator_spec.js b/test/spec/ortb2.5Translator/translator_spec.js new file mode 100644 index 00000000000..db20a8f59be --- /dev/null +++ b/test/spec/ortb2.5Translator/translator_spec.js @@ -0,0 +1,64 @@ +import {EXT_PROMOTIONS, moveRule, splitPath, toOrtb25} from '../../../libraries/ortb2.5Translator/translator.js'; +import {deepAccess, deepClone, deepSetValue} from '../../../src/utils.js'; + +describe('ORTB 2.5 translation', () => { + describe('moveRule', () => { + const rule = moveRule('f1.f2.f3', (prefix, field) => `${prefix}.m1.m2.${field}`); + + function applyRule(rule, obj, del = true) { + obj = deepClone(obj); + const deleter = rule(obj); + if (typeof deleter === 'function' && del) { + deleter(); + } + return obj; + } + + it('returns undef when field is not present', () => { + expect(rule({})).to.eql(undefined); + }); + it('can copy field', () => { + expect(applyRule(rule, {f1: {f2: {f3: 'value'}}}, false)).to.eql({ + f1: { + f2: { + f3: 'value', + m1: {m2: {f3: 'value'}} + } + } + }); + }); + it('can move field', () => { + expect(applyRule(rule, {f1: {f2: {f3: 'value'}}}, true)).to.eql({f1: {f2: {m1: {m2: {f3: 'value'}}}}}); + }); + }); + describe('toOrtb25', () => { + EXT_PROMOTIONS.forEach(path => { + const newPath = (() => { + const [prefix, field] = splitPath(path); + return `${prefix}.ext.${field}`; + })(); + + it(`moves ${path} to ${newPath}`, () => { + const obj = {}; + deepSetValue(obj, path, 'val'); + toOrtb25(obj); + expect(deepAccess(obj, path)).to.eql(undefined); + expect(deepAccess(obj, newPath)).to.eql('val'); + }); + }); + it('moves kwarray into keywords', () => { + expect(toOrtb25({app: {keywords: 'k1,k2', kwarray: ['ka1', 'ka2']}})).to.eql({app: {keywords: 'k1,k2,ka1,ka2'}}); + }); + it('does not choke if kwarray is not an array', () => { + expect(toOrtb25({site: {keywords: 'k1,k2', kwarray: 'err'}})).to.eql({site: {keywords: 'k1,k2'}}); + }); + it('does not choke if keywords is not a string', () => { + expect(toOrtb25({user: {keywords: {}, kwarray: ['ka1', 'ka2']}})).to.eql({ + user: { + keywords: {}, + kwarray: ['ka1', 'ka2'] + } + }); + }); + }); +}); diff --git a/test/spec/ortbConverter/banner_spec.js b/test/spec/ortbConverter/banner_spec.js new file mode 100644 index 00000000000..0f6686283a1 --- /dev/null +++ b/test/spec/ortbConverter/banner_spec.js @@ -0,0 +1,203 @@ +import {fillBannerImp, bannerResponseProcessor} from '../../../libraries/ortbConverter/processors/banner.js'; +import {BANNER, VIDEO} from '../../../src/mediaTypes.js'; +import {inIframe} from '../../../src/utils.js'; + +const topframe = inIframe() ? 0 : 1; + +describe('pbjs -> ortb banner conversion', () => { + [ + { + t: 'non-banner request', + request: { + mediaTypes: { + video: {} + } + }, + imp: {} + }, + { + t: 'banner with no sizes', + request: { + mediaTypes: { + banner: { + pos: 'pos', + } + } + }, + imp: { + banner: { + topframe, + pos: 'pos', + } + } + }, + { + t: 'single size banner', + request: { + mediaTypes: { + banner: { + sizes: [1, 2], + } + } + }, + imp: { + banner: { + format: [ + {w: 1, h: 2} + ], + topframe, + } + } + }, + { + t: 'multi size banner', + request: { + mediaTypes: { + banner: { + sizes: [[1, 2], [3, 4]] + } + } + }, + imp: { + banner: { + format: [ + {w: 1, h: 2}, + {w: 3, h: 4} + ], + topframe, + } + } + }, + { + t: 'banner with pos param', + request: { + mediaTypes: { + banner: { + sizes: [1, 2], + pos: 'pos' + } + } + }, + imp: { + banner: { + format: [ + {w: 1, h: 2} + ], + pos: 'pos', + topframe, + } + }, + }, + { + t: 'banner with pos 0', + request: { + mediaTypes: { + banner: { + sizes: [1, 2], + pos: 0 + } + } + }, + imp: { + banner: { + format: [ + {w: 1, h: 2} + ], + pos: 0, + topframe, + } + } + } + ].forEach(({t, request, imp}) => { + it(`can convert ${t}`, () => { + const actual = {}; + fillBannerImp(actual, request, {}); + expect(actual).to.eql(imp); + }); + }); + + it('should keep ortb2Imp.banner', () => { + const imp = { + banner: { + someParam: 'someValue' + } + }; + fillBannerImp(imp, {mediaTypes: {banner: {sizes: [1, 2]}}}, {}); + expect(imp.banner.someParam).to.eql('someValue'); + }); + + it('does nothing if context.mediaType is set but is not BANNER', () => { + const imp = {}; + fillBannerImp(imp, {mediaTypes: {banner: {sizes: [1, 2]}}}, {mediaType: VIDEO}); + expect(imp).to.eql({}); + }) +}); + +describe('ortb -> pbjs banner conversion', () => { + let createPixel, seatbid2Banner; + beforeEach(() => { + createPixel = sinon.stub().callsFake((url) => `${url}Pixel`); + seatbid2Banner = bannerResponseProcessor({createPixel}); + }); + + [ + { + t: 'non-banner request', + seatbid: { + adm: 'mockAdm', + nurl: 'mockNurl' + }, + response: { + mediaType: VIDEO + }, + expected: { + mediaType: VIDEO + } + }, + { + t: 'response with both adm and nurl', + seatbid: { + adm: 'mockAdm', + nurl: 'mockUrl' + }, + response: { + mediaType: BANNER, + }, + expected: { + mediaType: BANNER, + ad: 'mockAdmmockUrlPixel' + } + }, + { + t: 'response with just adm', + seatbid: { + adm: 'mockAdm' + }, + response: { + mediaType: BANNER, + }, + expected: { + mediaType: BANNER, + ad: 'mockAdm' + } + }, + { + t: 'response with just nurl', + seatbid: { + nurl: 'mockNurl' + }, + response: { + mediaType: BANNER + }, + expected: { + mediaType: BANNER, + adUrl: 'mockNurl' + } + } + ].forEach(({t, seatbid, response, expected}) => { + it(`can handle ${t}`, () => { + seatbid2Banner(response, seatbid, context); + expect(response).to.eql(expected) + }) + }); +}) diff --git a/test/spec/ortbConverter/composer_spec.js b/test/spec/ortbConverter/composer_spec.js new file mode 100644 index 00000000000..f342df38fde --- /dev/null +++ b/test/spec/ortbConverter/composer_spec.js @@ -0,0 +1,69 @@ +import {compose} from '../../../libraries/ortbConverter/lib/composer.js'; + +describe('compose', () => { + it('runs each component in order of priority', () => { + const order = []; + const components = { + first: { + fn: sinon.stub().callsFake(() => order.push(1)), + }, + second: { + fn: sinon.stub().callsFake(() => order.push(2)), + priority: 10 + }, + third: { + fn: sinon.stub().callsFake(() => order.push(3)), + priority: 5 + } + }; + compose(components)(); + expect(order).to.eql([2, 3, 1]); + }); + + it('passes parameters to each component', () => { + const components = { + first: { + fn: sinon.stub() + }, + second: { + fn: sinon.stub() + } + }; + compose(components)('one', 'two'); + Object.values(components).forEach(comp => { + sinon.assert.calledWith(comp.fn, 'one', 'two') + }) + }) + + it('respects overrides', () => { + const components = { + first: { + fn: sinon.stub() + }, + second: { + fn: sinon.stub() + } + }; + const overrides = { + second: sinon.stub() + } + compose(components, overrides)('one', 'two'); + sinon.assert.calledWith(overrides.second, components.second.fn, 'one', 'two') + }) + + it('disables components when override is false', () => { + const components = { + first: { + fn: sinon.stub(), + }, + second: { + fn: sinon.stub() + } + }; + const overrides = { + second: false + }; + compose(components, overrides)('one', 'two'); + sinon.assert.notCalled(components.second.fn); + }) +}); diff --git a/test/spec/ortbConverter/converter_spec.js b/test/spec/ortbConverter/converter_spec.js new file mode 100644 index 00000000000..e00b46e66da --- /dev/null +++ b/test/spec/ortbConverter/converter_spec.js @@ -0,0 +1,283 @@ +import {ortbConverter} from '../../../libraries/ortbConverter/converter.js'; +import {BID_RESPONSE, IMP, REQUEST, RESPONSE} from '../../../src/pbjsORTB.js'; + +describe('pbjs-ortb converter', () => { + const MOCK_BIDDER_REQUEST = { + id: 'bidderRequest', + bids: [ + { + id: 111 + }, + { + id: 112 + } + ] + } + + const MOCK_ORTB_RESPONSE = { + id: 'response', + seatbid: [ + { + seat: 'mockBidder1', + bid: [ + { + impid: 'imp0' + }, + { + impid: 'imp1' + } + ] + }, + { + seat: 'mockBidder2', + bid: [ + { + impid: 'imp1' + } + ] + } + ] + } + + let processors, reqCnt, impCnt; + + beforeEach(() => { + reqCnt = 0; + impCnt = 0; + processors = { + [REQUEST]: { + req: { + fn(ortbRequest, bidderRequest, context) { + ortbRequest.id = `req${reqCnt++}`; + if (context.ctx) { + ortbRequest.ctx = context.ctx; + } + } + } + }, + [IMP]: { + imp: { + fn(imp, bidRequest, context) { + imp.id = `imp${impCnt++}`; + imp.bidId = bidRequest.id; + if (context.ctx) { + imp.ctx = context.ctx; + } + if (context.reqContext?.ctx) { + imp.reqCtx = context.reqContext?.ctx; + } + } + } + }, + [BID_RESPONSE]: { + resp: { + fn(bidResponse, bid, context) { + bidResponse.impid = bid.impid; + bidResponse.bidId = context.imp.bidId; + if (context.ctx) { + bidResponse.ctx = context.ctx; + } + if (context.reqContext?.ctx) { + bidResponse.reqCtx = context.reqContext?.ctx; + } + } + } + }, + [RESPONSE]: { + resp: { + fn(response, ortbResponse, context) { + response.marker = true; + if (context.ctx) { + response.ctx = context.ctx; + } + } + } + } + } + }); + + function makeConverter(options = {}) { + options = Object.assign({ + processors: () => processors + }, options); + return ortbConverter(options); + } + + it('runs each processor', () => { + const cvt = makeConverter(); + const request = cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST}); + expect(request).to.eql({ + id: 'req0', + imp: [ + {id: 'imp0', bidId: 111}, + {id: 'imp1', bidId: 112} + ] + }); + const response = cvt.fromORTB({request, response: MOCK_ORTB_RESPONSE}); + expect(response.bids).to.eql([{ + impid: 'imp0', + bidId: 111 + }, { + impid: 'imp1', + bidId: 112 + }, { + impid: 'imp1', + bidId: 112 + }]); + expect(response.marker).to.be.true; + }); + + it('fromORTB throws if request was not produced by the same converter', () => { + expect(() => { + makeConverter().fromORTB({ + request: { + imp: [ + { + id: 'imp0' + } + ] + }, + response: MOCK_ORTB_RESPONSE + }) + }).to.throw(); + }); + + it('gives precedence to the bidRequests argument over bidderRequest.bids', () => { + expect(makeConverter().toORTB({bidderRequest: MOCK_BIDDER_REQUEST, bidRequests: [MOCK_BIDDER_REQUEST.bids[0]]})).to.eql({ + id: 'req0', + imp: [ + { + id: 'imp0', + bidId: 111 + } + ] + }) + }); + + it('passes context to every processor', () => { + const cvt = makeConverter(); + const request = cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST, context: {ctx: 'context'}}); + expect(request.ctx).to.equal('context'); + request.imp.forEach(imp => expect(imp.ctx).to.equal('context')); + const response = cvt.fromORTB({request, response: MOCK_ORTB_RESPONSE}); + expect(response.ctx).to.eql('context'); + response.bids.forEach(bidResponse => expect(bidResponse.ctx).to.equal('context')); + }); + + it('passes request context to imp and bidResponse processors', () => { + const cvt = makeConverter(); + const request = cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST, context: {ctx: 'context'}}); + expect(request.imp[0].reqCtx).to.eql('context'); + const response = cvt.fromORTB({request, response: MOCK_ORTB_RESPONSE}); + expect(response.bids[0].reqCtx).to.eql('context'); + }); + + it('allows overriding of imp building with `imp`', () => { + const cvt = makeConverter({ + imp: function (buildImp, bidRequest, context) { + return Object.assign({ + extraArg: bidRequest.id, + extraCtx: context.ctx + }, buildImp(bidRequest, context)); + } + }); + const request = cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST, context: {ctx: 'context'}}); + expect(request.imp.length).to.eql(2); + request.imp.forEach(imp => { + expect(imp.extraArg).to.eql(imp.bidId); + expect(imp.extraCtx).to.eql('context'); + }) + }); + + it('allows filtering imps with `imp`', () => { + const cvt = makeConverter({ + imp(buildImp, bidRequest, context) { + if (bidRequest.id === 112) { + return buildImp(bidRequest, context); + } + } + }); + expect(cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST}).imp.length).to.eql(1); + }); + + it('does not include imps that have no id', () => { + const cvt = makeConverter({ + imp(buildImp, bidRequest, context) { + const imp = buildImp(bidRequest, context); + delete imp.id; + return imp; + } + }); + expect(cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST}).imp.length).to.eql(0); + }) + + it('allows overriding of response building with bidResponse', () => { + const cvt = makeConverter({ + bidResponse(buildResponse, bid, context) { + return Object.assign({ + extraArg: context.bidRequest.id, + extraCtx: context.ctx + }, buildResponse(bid, context)); + } + }); + const response = cvt.fromORTB({ + response: MOCK_ORTB_RESPONSE, + request: cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST, context: {ctx: 'context'}}) + }); + + expect(response.bids.length).to.equal(3); + response.bids.forEach(response => { + expect(response.extraArg).to.eql(response.bidId); + expect(response.extraCtx).to.eql('context'); + }); + }); + + it('allows filtering of responses with `bidResponse`', () => { + const cvt = makeConverter({ + bidResponse(buildBidResponse, bid, context) { + if (context.seatbid.seat === 'mockBidder1' && context.imp.id === 'imp0') { + return buildBidResponse(bid, context); + } + } + }); + expect(cvt.fromORTB({ + request: cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST}), + response: MOCK_ORTB_RESPONSE + }).bids.length).to.equal(1); + }); + + it('allows overriding of request building with `request`', () => { + const cvt = makeConverter({ + request(buildRequest, imps, bidderRequest, context) { + return { + request: buildRequest(imps, bidderRequest, context), + extraArg: bidderRequest.id, + extraCtx: context.ctx + } + } + }); + const req = cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST, context: {ctx: 'context'}}); + expect(req.extraArg).to.equal(MOCK_BIDDER_REQUEST.id); + expect(req.extraCtx).to.equal('context'); + expect(req.request.imp.length).to.equal(2); + }); + + it('allows overriding of response building with `response`', () => { + const cvt = makeConverter({ + response(buildResponse, bidResponses, ortbResponse, context) { + return { + response: buildResponse(bidResponses, ortbResponse, context), + extraArg: ortbResponse.id, + extraCtx: context.ctx + } + } + }); + const resp = cvt.fromORTB({ + request: cvt.toORTB({bidderRequest: MOCK_BIDDER_REQUEST, context: {ctx: 'context'}}), + response: MOCK_ORTB_RESPONSE, + }); + expect(resp.extraArg).to.equal(MOCK_ORTB_RESPONSE.id); + expect(resp.extraCtx).to.equal('context'); + expect(resp.response.bids.length).to.equal(3); + }) +}) diff --git a/test/spec/ortbConverter/currency_spec.js b/test/spec/ortbConverter/currency_spec.js new file mode 100644 index 00000000000..76f81223f27 --- /dev/null +++ b/test/spec/ortbConverter/currency_spec.js @@ -0,0 +1,40 @@ +import {config} from 'src/config.js'; +import {setOrtbCurrency} from '../../../modules/currency.js'; + +describe('pbjs -> ortb currency', () => { + before(() => { + config.resetConfig(); + }); + + afterEach(() => { + config.resetConfig(); + }); + + it('does not set cur by default', () => { + const req = {}; + setOrtbCurrency(req, {}, {}); + expect(req).to.eql({}); + }); + + it('sets currency based on config', () => { + config.setConfig({ + currency: { + adServerCurrency: 'EUR' + } + }); + const req = {}; + setOrtbCurrency(req, {}, {}); + expect(req.cur).to.eql(['EUR']); + }); + + it('sets currency based on context', () => { + config.setConfig({ + currency: { + adServerCurrency: 'EUR' + } + }); + const req = {}; + setOrtbCurrency(req, {}, {currency: 'JPY'}); + expect(req.cur).to.eql(['JPY']); + }) +}); diff --git a/test/spec/ortbConverter/gdpr_spec.js b/test/spec/ortbConverter/gdpr_spec.js new file mode 100644 index 00000000000..78fd1830438 --- /dev/null +++ b/test/spec/ortbConverter/gdpr_spec.js @@ -0,0 +1,9 @@ +import {setOrtbAdditionalConsent} from '../../../modules/consentManagement.js'; + +describe('pbjs -> ortb addtlConsent', () => { + it('sets ConsentedProvidersSettings', () => { + const req = {}; + setOrtbAdditionalConsent(req, {gdprConsent: {addtlConsent: 'tl'}}); + expect(req.user.ext.ConsentedProvidersSettings.consented_providers).to.eql('tl'); + }); +}) diff --git a/test/spec/ortbConverter/mediaTypes_spec.js b/test/spec/ortbConverter/mediaTypes_spec.js new file mode 100644 index 00000000000..4f4fd99fb75 --- /dev/null +++ b/test/spec/ortbConverter/mediaTypes_spec.js @@ -0,0 +1,67 @@ +import {ORTB_MTYPES, setResponseMediaType} from '../../../libraries/ortbConverter/processors/mediaType.js'; +import {BANNER} from '../../../src/mediaTypes.js'; +import {extPrebidMediaType} from '../../../libraries/pbsExtensions/processors/mediaType.js'; + +function testMtype(processor) { + describe('respects 2.6 mtype', () => { + Object.entries(ORTB_MTYPES).forEach(([mtype, pbtype]) => { + it(`${mtype} -> ${pbtype}`, () => { + const resp = {}; + processor(resp, { + mtype: parseInt(mtype, 10) + }, {}); + expect(resp.mediaType).to.eql(pbtype); + }); + }); + }); +} + +describe('ortb -> pbjs mediaType conversion', () => { + testMtype(setResponseMediaType); + it('throws if mtype is missing', () => { + expect(() => { + setResponseMediaType({}, {}); + }).to.throw(); + }); + + it('respects pre-set bidResponse.mediaType', () => { + const resp = {mediaType: 'video'}; + setResponseMediaType(resp, {mtype: 1}); + expect(resp.mediaType).to.eql('video'); + }); + + it('gives precedence to context.mediaType', () => { + const resp = {}; + setResponseMediaType(resp, {mtype: 1}, {mediaType: 'video'}); + expect(resp.mediaType).to.eql('video') + }) +}); + +describe('ortb -> pbjs mediaType conversion based on ext.prebid.type', () => { + testMtype(extPrebidMediaType); + describe('respects ext.prebid.type', () => { + Object.values(ORTB_MTYPES).forEach(mediaType => { + const response = {}; + extPrebidMediaType(response, { + ext: { + prebid: { + type: mediaType + } + } + }, {}); + expect(response.mediaType).to.eql(mediaType); + }); + }); + + it('defaults to banner', () => { + const response = {}; + extPrebidMediaType(response, {}, {}); + expect(response.mediaType).to.eql(BANNER); + }); + + it('gives precedence to context.mediaType', () => { + const response = {}; + extPrebidMediaType(response, {ext: {prebid: {type: 'banner'}}}, {mediaType: 'video'}); + expect(response.mediaType).to.eql('video'); + }) +}); diff --git a/test/spec/ortbConverter/mergeProcessors_spec.js b/test/spec/ortbConverter/mergeProcessors_spec.js new file mode 100644 index 00000000000..ba15de06031 --- /dev/null +++ b/test/spec/ortbConverter/mergeProcessors_spec.js @@ -0,0 +1,59 @@ +import {mergeProcessors} from '../../../libraries/ortbConverter/lib/mergeProcessors.js'; +import {BID_RESPONSE, IMP, REQUEST, RESPONSE} from '../../../src/pbjsORTB.js'; + +describe('mergeProcessors', () => { + it('can merge', () => { + const result = mergeProcessors({ + [REQUEST]: { + first: { + priority: 0, + fn: 'first' + } + }, + [RESPONSE]: { + second: { + priority: 1, + fn: 'second' + } + } + }, { + [REQUEST]: { + first: { + fn: 'overriden' + } + }, + [IMP]: { + third: { + fn: 'third' + } + } + }, { + [IMP]: { + third: { + priority: 3, + fn: 'overridden' + } + } + }); + expect(result).to.eql({ + [REQUEST]: { + first: { + fn: 'overriden' + } + }, + [IMP]: { + third: { + priority: 3, + fn: 'overridden' + }, + }, + [RESPONSE]: { + second: { + priority: 1, + fn: 'second' + } + }, + [BID_RESPONSE]: {} + }); + }); +}); diff --git a/test/spec/ortbConverter/multibid_spec.js b/test/spec/ortbConverter/multibid_spec.js new file mode 100644 index 00000000000..4886aaf6069 --- /dev/null +++ b/test/spec/ortbConverter/multibid_spec.js @@ -0,0 +1,35 @@ +import {config} from 'src/config.js'; +import {setOrtbExtPrebidMultibid} from '../../../modules/multibid/index.js'; + +describe('pbjs - ortb ext.prebid.multibid', () => { + before(() => { + config.resetConfig(); + }); + afterEach(() => { + config.resetConfig(); + }); + + it('sets ext.prebid.multibid according to config', () => { + config.setConfig({ + multibid: [ + { + bidder: 'A', + maxBids: 2 + }, + { + bidder: 'B', + maxBids: 3 + } + ] + }); + const req = {}; + setOrtbExtPrebidMultibid(req); + expect(req.ext.prebid.multibid).to.eql([{bidder: 'A', maxbids: 2}, {bidder: 'B', maxbids: 3}]); + }); + + it('does not set it if not configured', () => { + const req = {}; + setOrtbExtPrebidMultibid(req); + expect(req).to.eql({}); + }) +}); diff --git a/test/spec/ortbConverter/native_spec.js b/test/spec/ortbConverter/native_spec.js new file mode 100644 index 00000000000..56c733817cd --- /dev/null +++ b/test/spec/ortbConverter/native_spec.js @@ -0,0 +1,95 @@ +import {fillNativeImp, fillNativeResponse} from '../../../libraries/ortbConverter/processors/native.js'; +import {BANNER, NATIVE} from '../../../src/mediaTypes.js'; + +describe('pbjs -> ortb native requests', () => { + function toNative(bidRequest, context) { + const imp = {}; + fillNativeImp(imp, bidRequest, context); + return imp; + } + + it('should do nothing if request has no nativeOrtbRequest', () => { + expect(toNative({}, {})).to.eql({}); + }); + + it('should set imp.native according to nativeOrtbRequest', () => { + const nativeOrtbRequest = {ver: 'version', prop: 'value', assets: [{}]}; + const imp = toNative({nativeOrtbRequest}, {}); + expect(imp.native.ver).to.eql('version'); + expect(JSON.parse(imp.native.request)).to.eql(nativeOrtbRequest); + }); + + it('should do nothing if context.mediaType is set but is not NATIVE', () => { + expect(toNative({nativeOrtbRequest: {ver: 'version'}}, {mediaType: BANNER})).to.eql({}) + }); + + it('should merge context.nativeRequest', () => { + const nativeOrtbRequest = {ver: 'version', eventtrackers: [{tracker: 'req'}], assets: [{}]}; + const nativeDefaults = {eventtrackers: [{tracker: 'default'}], other: 'other'}; + const imp = toNative({nativeOrtbRequest}, {nativeRequest: nativeDefaults}); + expect(imp.native.ver).to.eql('version'); + expect(JSON.parse(imp.native.request)).to.eql({ + assets: [{}], + ver: 'version', + eventtrackers: [{tracker: 'req'}], + other: 'other' + }); + }); + + it('should keep ortb2Imp.native', () => { + const imp = { + native: { + something: 'orother' + } + } + fillNativeImp(imp, {nativeOrtbRequest: {ver: 'version'}}, {}); + expect(imp.native.something).to.eql('orother') + }); + + it('should do nothing if there are no assets', () => { + const imp = {}; + fillNativeImp(imp, {nativeOrtbRequest: {assets: []}}, {}); + expect(imp).to.eql({}); + }) +}); + +describe('ortb -> ortb native response', () => { + const MOCK_NATIVE_RESPONSE = { + property: 'value', + assets: [ + { + id: 0 + } + ] + } + Object.entries({ + 'serialized': JSON.stringify(MOCK_NATIVE_RESPONSE), + 'an object': MOCK_NATIVE_RESPONSE + }).forEach(([t, adm]) => { + describe(`when adm is ${t}`, () => { + let bid; + beforeEach(() => { + bid = {adm}; + }) + it('should set bidResponse.native', () => { + const bidResponse = { + mediaType: NATIVE + }; + fillNativeResponse(bidResponse, bid, {}); + expect(bidResponse.native).to.eql({ortb: MOCK_NATIVE_RESPONSE}); + }); + }); + it('should throw if response has no assets', () => { + expect(() => fillNativeResponse({mediaType: NATIVE}, {adm: {...MOCK_NATIVE_RESPONSE, assets: null}}, {})).to.throw; + }) + it('should do nothing if bidResponse.mediaType is not NATIVE', () => { + const bidResponse = { + mediaType: BANNER + }; + fillNativeResponse(bidResponse, {adm: MOCK_NATIVE_RESPONSE}, {}); + expect(bidResponse).to.eql({ + mediaType: BANNER + }) + }) + }) +}); diff --git a/test/spec/ortbConverter/pbjsORTB_spec.js b/test/spec/ortbConverter/pbjsORTB_spec.js new file mode 100644 index 00000000000..16aefec2b35 --- /dev/null +++ b/test/spec/ortbConverter/pbjsORTB_spec.js @@ -0,0 +1,67 @@ +import { + DEFAULT, + PBS, + PROCESSOR_TYPES, + processorRegistry, + REQUEST +} from '../../../src/pbjsORTB.js'; + +describe('pbjsORTB register / get processors', () => { + let registerOrtbProcessor, getProcessors; + beforeEach(() => { + ({registerOrtbProcessor, getProcessors} = processorRegistry()); + }) + PROCESSOR_TYPES.forEach(type => { + it(`can get and set ${type} processors`, () => { + const proc = function () {}; + registerOrtbProcessor({ + type, + name: 'test', + fn: proc + }); + expect(getProcessors(DEFAULT)).to.eql({ + [type]: { + test: { + priority: 0, + fn: proc + } + } + }); + }); + }); + + it('throws on wrong type', () => { + expect(() => registerOrtbProcessor({ + type: 'incorrect', + name: 'test', + fn: function () {} + })).to.throw(); + }); + + it('can set priority', () => { + const proc = function () {}; + registerOrtbProcessor({type: REQUEST, name: 'test', fn: proc, priority: 10}); + expect(getProcessors(DEFAULT)).to.eql({ + [REQUEST]: { + test: { + priority: 10, + fn: proc + } + } + }) + }); + + it('can assign processors to specific dialects', () => { + const proc = function () {}; + registerOrtbProcessor({type: REQUEST, name: 'test', fn: proc, dialects: [PBS]}); + expect(getProcessors(DEFAULT)).to.eql({}); + expect(getProcessors(PBS)).to.eql({ + [REQUEST]: { + test: { + priority: 0, + fn: proc + } + } + }) + }); +}); diff --git a/test/spec/ortbConverter/pbsExtensions/adUnitCode_spec.js b/test/spec/ortbConverter/pbsExtensions/adUnitCode_spec.js new file mode 100644 index 00000000000..e17f9e856b0 --- /dev/null +++ b/test/spec/ortbConverter/pbsExtensions/adUnitCode_spec.js @@ -0,0 +1,23 @@ +import {setImpAdUnitCode} from '../../../../libraries/pbsExtensions/processors/adUnitCode.js'; + +describe('pbjs -> ortb adunit code to imp[].ext.prebid.adunitcode', () => { + function setImp(bidRequest) { + const imp = {}; + setImpAdUnitCode(imp, bidRequest); + return imp; + } + + it('it sets adunitcode in ext.prebid.adunitcode when adUnitCode is present', () => { + expect(setImp({bidder: 'mockBidder', adUnitCode: 'mockAdUnit'})).to.eql({ + 'ext': { + 'prebid': { + 'adunitcode': 'mockAdUnit' + } + } + }) + }); + + it('does not set adunitcode in ext.prebid.adunitcode if adUnit is undefined', () => { + expect(setImp({bidder: 'mockBidder'})).to.eql({}); + }); +}); diff --git a/test/spec/ortbConverter/pbsExtensions/aliases_spec.js b/test/spec/ortbConverter/pbsExtensions/aliases_spec.js new file mode 100644 index 00000000000..712ceaa397c --- /dev/null +++ b/test/spec/ortbConverter/pbsExtensions/aliases_spec.js @@ -0,0 +1,57 @@ +import {setRequestExtPrebidAliases} from '../../../../libraries/pbsExtensions/processors/aliases.js'; + +describe('PBS - ortb ext.prebid.aliases', () => { + let aliasRegistry, bidderRegistry; + + function setAliases(bidderRequest) { + const req = {} + setRequestExtPrebidAliases(req, bidderRequest, {}, { + am: { + bidderRegistry, + aliasRegistry + } + }); + return req; + } + + beforeEach(() => { + aliasRegistry = {}; + bidderRegistry = {}; + }) + + describe('has no effect if', () => { + it('bidder is not an alias', () => { + expect(setAliases({bidderCode: 'not-an-alias'})).to.eql({}); + }); + + it('bidder sets skipPbsAliasing', () => { + aliasRegistry['alias'] = 'bidder'; + bidderRegistry['alias'] = { + getSpec() { + return { + skipPbsAliasing: true + } + } + }; + expect(setAliases({bidderCode: 'alias'})).to.eql({}); + }); + }); + + it('sets ext.prebid.aliases.BIDDER', () => { + aliasRegistry['alias'] = 'bidder'; + bidderRegistry['alias'] = { + getSpec() { + return {} + } + }; + expect(setAliases({bidderCode: 'alias'})).to.eql({ + ext: { + prebid: { + aliases: { + alias: 'bidder' + } + } + } + }) + }); +}) diff --git a/test/spec/ortbConverter/pbsExtensions/params_spec.js b/test/spec/ortbConverter/pbsExtensions/params_spec.js new file mode 100644 index 00000000000..73b92a0755d --- /dev/null +++ b/test/spec/ortbConverter/pbsExtensions/params_spec.js @@ -0,0 +1,96 @@ +import {setImpBidParams} from '../../../../libraries/pbsExtensions/processors/params.js'; + +describe('pbjs -> ortb bid params to imp[].ext.prebid.BIDDER', () => { + let bidderRegistry, index, adUnit; + beforeEach(() => { + bidderRegistry = {}; + adUnit = {code: 'mockAdUnit'}; + index = { + getAdUnit() { + return adUnit; + } + } + }); + + function setParams(bidRequest, context, deps = {}) { + const imp = {}; + setImpBidParams(imp, bidRequest, context, Object.assign({bidderRegistry, index}, deps)) + return imp; + } + + it('sets params in ext.prebid.bidder.BIDDER', () => { + expect(setParams({bidder: 'mockBidder', params: {a: 'param'}})).to.eql({ + ext: { + prebid: { + bidder: { + mockBidder: { + a: 'param' + } + } + } + } + }) + }); + + it('has no effect if bidRequest has no params', () => { + expect(setParams({bidder: 'mockBidder'})).to.eql({}); + }) + + describe('when adapter provides transformBidParams', () => { + let transform, bidderRequest; + beforeEach(() => { + bidderRequest = {bidderCode: 'mockBidder'}; + transform = sinon.stub().callsFake((p) => Object.assign({transformed: true}, p)); + bidderRegistry.mockBidder = { + getSpec() { + return { + transformBidParams: transform + } + } + } + }) + + it('runs params through transform', () => { + expect(setParams({bidder: 'mockBidder', params: {a: 'param'}}, {bidderRequest})).to.eql({ + ext: { + prebid: { + bidder: { + mockBidder: { + a: 'param', + transformed: true + } + } + } + } + }); + }); + + it('runs through transform even if bid has no params', () => { + expect(setParams({bidder: 'mockBidder'}, {bidderRequest})).to.eql({ + ext: { + prebid: { + bidder: { + mockBidder: { + transformed: true + } + } + } + } + }) + }) + + it('by default, passes adUnit from index, bidderRequest from context', () => { + const params = {a: 'param'}; + setParams({bidder: 'mockBidder', params}, {bidderRequest}); + sinon.assert.calledWith(transform, params, true, adUnit, [bidderRequest]) + }); + + it('uses provided adUnit, bidderRequests', () => { + const adUnit = {code: 'other-ad-unit'}; + const bidderRequests = [{bidderCode: 'one'}, {bidderCode: 'two'}]; + const params = {a: 'param'}; + setParams({bidder: 'mockBidder', params}, {}, {adUnit, bidderRequests}); + sinon.assert.calledWith(transform, params, true, adUnit, bidderRequests); + }) + }); +}); diff --git a/test/spec/ortbConverter/pbsExtensions/video_spec.js b/test/spec/ortbConverter/pbsExtensions/video_spec.js new file mode 100644 index 00000000000..5bba32c447a --- /dev/null +++ b/test/spec/ortbConverter/pbsExtensions/video_spec.js @@ -0,0 +1,52 @@ +import {setBidResponseVideoCache} from '../../../../libraries/pbsExtensions/processors/video.js'; + +describe('pbjs - ortb videoCacheKey based on ext.prebid', () => { + const EXT_PREBID_CACHE = { + ext: { + prebid: { + cache: { + vastXml: { + cacheId: 'id', + url: 'url' + } + } + } + } + } + + function setCache(bid) { + const bidResponse = {mediaType: 'video'}; + setBidResponseVideoCache(bidResponse, bid); + return bidResponse; + } + + it('has no effect if mediaType is not video', () => { + const resp = {mediaType: 'banner'}; + setBidResponseVideoCache(resp, EXT_PREBID_CACHE); + expect(resp).to.eql({mediaType: 'banner'}); + }); + + it('sets videoCacheKey, vastUrl from ext.prebid.cache.vastXml', () => { + sinon.assert.match(setCache(EXT_PREBID_CACHE), { + videoCacheKey: 'id', + vastUrl: 'url' + }); + }); + + it('sets videoCacheKey, vastUrl from ext.prebid.targeting', () => { + sinon.assert.match(setCache({ + ext: { + prebid: { + targeting: { + hb_uuid: 'id', + hb_cache_host: 'host', + hb_cache_path: '/path' + } + } + } + }), { + vastUrl: 'https://host/path?uuid=id', + videoCacheKey: 'id' + }) + }); +}); diff --git a/test/spec/ortbConverter/priceFloors_spec.js b/test/spec/ortbConverter/priceFloors_spec.js new file mode 100644 index 00000000000..f6d37992711 --- /dev/null +++ b/test/spec/ortbConverter/priceFloors_spec.js @@ -0,0 +1,143 @@ +import {config} from 'src/config.js'; +import {setOrtbExtPrebidFloors, setOrtbImpBidFloor} from '../../../modules/priceFloors.js'; +import 'src/prebid.js'; + +describe('pbjs - ortb imp floor params', () => { + before(() => { + config.resetConfig(); + }); + + afterEach(() => { + config.resetConfig(); + }); + + Object.entries({ + 'has no getFloor': {}, + 'has getFloor that throws': { + getFloor: sinon.stub().callsFake(() => { throw new Error() }), + }, + 'returns invalid floor': { + getFloor: sinon.stub().callsFake(() => ({floor: NaN, currency: null})) + } + }).forEach(([t, req]) => { + it(`has no effect if bid ${t}`, () => { + const imp = {}; + setOrtbImpBidFloor(imp, {}, {}); + expect(imp).to.eql({}); + }) + }) + + it('sets bidfoor and bidfloorcur according to getFloor', () => { + const imp = {}; + const req = { + getFloor() { + return { + currency: 'EUR', + floor: '1.23' + } + } + }; + setOrtbImpBidFloor(imp, req, {}); + expect(imp).to.eql({ + bidfloor: 1.23, + bidfloorcur: 'EUR' + }) + }); + + Object.entries({ + 'missing currency': {floor: 1.23}, + 'missing floor': {currency: 'USD'}, + 'not a number': {floor: 'abc', currency: 'USD'} + }).forEach(([t, floor]) => { + it(`should not set bidfloor if floor is ${t}`, () => { + const imp = {}; + const req = { + getFloor: () => floor + } + setOrtbImpBidFloor(imp, req, {}); + expect(imp).to.eql({}); + }) + }) + + describe('asks for floor in currency', () => { + let req; + beforeEach(() => { + req = { + getFloor(opts) { + return { + floor: 1.23, + currency: opts.currency + } + } + } + }) + + it('from context.currency', () => { + const imp = {}; + setOrtbImpBidFloor(imp, req, {currency: 'JPY'}); + config.setConfig({ + currency: { + adServerCurrency: 'EUR' + } + }) + expect(imp.bidfloorcur).to.eql('JPY'); + }); + + it('from config', () => { + const imp = {}; + config.setConfig({ + currency: { + adServerCurrency: 'EUR' + } + }); + setOrtbImpBidFloor(imp, req, {}); + expect(imp.bidfloorcur).to.eql('EUR'); + }); + + it('defaults to USD', () => { + const imp = {}; + setOrtbImpBidFloor(imp, req, {}); + expect(imp.bidfloorcur).to.eql('USD'); + }) + }); + + it('asks for specific mediaType if context.mediaType is set', () => { + let reqMediaType; + const req = { + getFloor(opts) { + reqMediaType = opts.mediaType; + } + } + setOrtbImpBidFloor({}, req, {mediaType: 'banner'}); + expect(reqMediaType).to.eql('banner'); + }) +}); + +describe('setOrtbExtPrebidFloors', () => { + before(() => { + config.setConfig({floors: {}}); + }) + after(() => { + config.setConfig({floors: {enabled: false}}); + }); + + it('should set ext.prebid.floors.enabled to false', () => { + const req = {}; + setOrtbExtPrebidFloors(req); + expect(req.ext.prebid.floors.enabled).to.equal(false); + }) + + it('should respect fpd', () => { + const req = { + ext: { + prebid: { + floors: { + enabled: true + } + } + } + } + setOrtbExtPrebidFloors(req); + expect(req.ext.prebid.floors.enabled).to.equal(true); + }) +}) diff --git a/test/spec/ortbConverter/schain_spec.js b/test/spec/ortbConverter/schain_spec.js new file mode 100644 index 00000000000..8eeef445948 --- /dev/null +++ b/test/spec/ortbConverter/schain_spec.js @@ -0,0 +1,33 @@ +import {setOrtbSourceExtSchain} from '../../../modules/schain.js'; + +describe('pbjs - ortb source.ext.schain', () => { + it('sets schain from request', () => { + const req = {}; + setOrtbSourceExtSchain(req, {}, { + bidRequests: [{schain: {s: 'chain'}}] + }); + expect(req.source.ext.schain).to.eql({s: 'chain'}); + }); + + it('does not set it if missing', () => { + const req = {}; + setOrtbSourceExtSchain(req, {}, {bidRequests: [{}]}); + expect(req).to.eql({}); + }) + + it('does not set it if already in request', () => { + const req = { + source: { + ext: { + schain: {s: 'chain'} + } + } + } + setOrtbSourceExtSchain(req, {}, { + bidRequests: [{ + schain: {other: 'chain'} + }] + }); + expect(req.source.ext.schain).to.eql({s: 'chain'}); + }) +}); diff --git a/test/spec/ortbConverter/userId_spec.js b/test/spec/ortbConverter/userId_spec.js new file mode 100644 index 00000000000..04a4d39ee48 --- /dev/null +++ b/test/spec/ortbConverter/userId_spec.js @@ -0,0 +1,33 @@ +import {setOrtbUserExtEids} from '../../../modules/userId/index.js'; + +describe('pbjs - ortb user eids', () => { + it('sets user.ext.eids from request', () => { + const req = {}; + setOrtbUserExtEids(req, {}, { + bidRequests: [ + { + userIdAsEids: {e: 'id'} + } + ] + }); + expect(req.user.ext.eids).to.eql({e: 'id'}); + }); + + it('has no effect if requests have no eids', () => { + const req = {}; + setOrtbUserExtEids(req, {}, [{}]); + expect(req).to.eql({}); + }) + + it('has no effect if user.ext.eids is an empty array', () => { + const req = {}; + setOrtbUserExtEids(req, {}, { + bidRequests: [ + { + userIdAsEids: [] + } + ] + }); + expect(req).to.eql({}); + }); +}) diff --git a/test/spec/ortbConverter/video_spec.js b/test/spec/ortbConverter/video_spec.js new file mode 100644 index 00000000000..8ac6d8b4d08 --- /dev/null +++ b/test/spec/ortbConverter/video_spec.js @@ -0,0 +1,189 @@ +import {fillVideoImp, fillVideoResponse, VALIDATIONS} from '../../../libraries/ortbConverter/processors/video.js'; +import {BANNER, VIDEO} from '../../../src/mediaTypes.js'; + +describe('pbjs -> ortb video conversion', () => { + [ + { + t: 'non-video request', + request: { + mediaTypes: { + banner: {} + } + }, + imp: {} + }, + { + t: 'instream video request', + request: { + mediaTypes: { + video: { + playerSize: [[1, 2]], + context: 'instream', + mimes: ['video/mp4'], + skip: 1, + } + } + }, + imp: { + video: { + w: 1, + h: 2, + mimes: ['video/mp4'], + skip: 1, + placement: 1, + }, + }, + }, + { + t: 'outstream video request', + request: { + mediaTypes: { + video: { + playerSize: [[1, 2]], + context: 'outstream', + mimes: ['video/mp4'], + skip: 1 + } + } + }, + imp: { + video: { + w: 1, + h: 2, + mimes: ['video/mp4'], + skip: 1, + }, + }, + }, + { + t: 'video request with explicit placement', + request: { + mediaTypes: { + video: { + playerSize: [[1, 2]], + placement: 'explicit' + } + } + }, + imp: { + video: { + w: 1, + h: 2, + placement: 'explicit', + } + } + }, + { + t: 'video request with multiple playerSizes', + request: { + mediaTypes: { + video: { + playerSize: [[1, 2], [3, 4]] + } + } + }, + imp: { + video: { + w: 1, + h: 2, + } + } + }, + { + t: 'video request with 2-tuple playerSize', + request: { + mediaTypes: { + video: { + playerSize: [1, 2] + } + } + }, + imp: { + video: { + w: 1, + h: 2, + } + } + }, + ].forEach(({t, request, imp}) => { + it(`can handle ${t}`, () => { + const actual = {}; + fillVideoImp(actual, request, {}); + expect(actual).to.eql(imp); + }); + }); + + it('should keep ortb2Imp.video', () => { + const imp = { + video: { + someParam: 'someValue' + } + }; + fillVideoImp(imp, {mediaTypes: {video: {playerSize: [[1, 2]]}}}, {}); + expect(imp.video.someParam).to.eql('someValue'); + }); + + it('does nothing is context.mediaType is set but is not VIDEO', () => { + const imp = {}; + fillVideoImp(imp, {mediaTypes: {video: {playerSize: [[1, 2]]}}}, {mediaType: BANNER}); + expect(imp).to.eql({}); + }); +}); + +describe('ortb -> pbjs video conversion', () => { + [ + { + t: 'non-video response', + seatbid: {}, + response: { + mediaType: BANNER + }, + expected: { + mediaType: BANNER + } + }, + { + t: 'simple video response', + seatbid: { + adm: 'mockAdm', + nurl: 'mockNurl' + }, + response: { + mediaType: VIDEO, + }, + context: { + imp: { + video: { + w: 1, + h: 2 + } + } + }, + expected: { + mediaType: VIDEO, + playerWidth: 1, + playerHeight: 2, + vastXml: 'mockAdm', + vastUrl: 'mockNurl' + } + }, + { + t: 'video response without playerSize', + seatbid: {}, + response: { + mediaType: VIDEO, + }, + context: { + imp: {} + }, + expected: { + mediaType: VIDEO + } + } + ].forEach(({t, seatbid, context, response, expected}) => { + it(`can handle ${t}`, () => { + fillVideoResponse(response, seatbid, context); + expect(response).to.eql(expected); + }) + }) +}) diff --git a/test/spec/refererDetection_spec.js b/test/spec/refererDetection_spec.js index a404e4f883e..800222892e6 100644 --- a/test/spec/refererDetection_spec.js +++ b/test/spec/refererDetection_spec.js @@ -1,112 +1,31 @@ -import { detectReferer } from 'src/refererDetection.js'; -import { config } from 'src/config.js'; -import { expect } from 'chai'; - -/** - * Build a walkable linked list of window-like objects for testing. - * - * @param {Array} urls Array of URL strings starting from the top window. - * @param {string} [topReferrer] - * @param {string} [canonicalUrl] - * @param {boolean} [ancestorOrigins] - * @returns {Object} - */ -function buildWindowTree(urls, topReferrer = '', canonicalUrl = null, ancestorOrigins = false) { - /** - * Find the origin from a given fully-qualified URL. - * - * @param {string} url The fully qualified URL - * @returns {string|null} - */ - function getOrigin(url) { - const originRegex = new RegExp('^(https?://[^/]+/?)'); - - const result = originRegex.exec(url); - - if (result && result[0]) { - return result[0]; - } - - return null; - } - - let previousWindow; - const myOrigin = getOrigin(urls[urls.length - 1]); - - const windowList = urls.map((url, index) => { - const theirOrigin = getOrigin(url), - sameOrigin = (myOrigin === theirOrigin); - - const win = {}; - - if (sameOrigin) { - win.location = { - href: url - }; - - if (ancestorOrigins) { - win.location.ancestorOrigins = urls.slice(0, index).reverse().map(getOrigin); - } - - if (index === 0) { - win.document = { - referrer: topReferrer - }; - - if (canonicalUrl) { - win.document.querySelector = function(selector) { - if (selector === "link[rel='canonical']") { - return { - href: canonicalUrl - }; - } - - return null; - }; - } - } else { - win.document = { - referrer: urls[index - 1] - }; - } - } - - previousWindow = win; - - return win; - }); +import {cacheWithLocation, detectReferer, ensureProtocol, parseDomain} from 'src/refererDetection.js'; +import {config} from 'src/config.js'; +import {expect} from 'chai'; - const topWindow = windowList[0]; +import { buildWindowTree } from '../helpers/refererDetectionHelper'; - previousWindow = null; - - windowList.forEach((win) => { - win.top = topWindow; - win.parent = previousWindow || topWindow; - previousWindow = win; +describe('Referer detection', () => { + afterEach(function () { + config.resetConfig(); }); - return windowList[windowList.length - 1]; -} - -describe('Referer detection', () => { describe('Non cross-origin scenarios', () => { describe('No iframes', () => { - afterEach(function () { - config.resetConfig(); - }); - it('Should return the current window location and no canonical URL', () => { const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 0, stack: ['https://example.com/some/page'], - canonicalUrl: null + canonicalUrl: null, + page: 'https://example.com/some/page', + ref: 'https://othersite.com/', + domain: 'example.com', }); }); @@ -114,13 +33,55 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['https://example.com/some/page'], + canonicalUrl: 'https://example.com/canonical/page', + page: 'https://example.com/some/page', + ref: 'https://othersite.com/', + domain: 'example.com' + }); + }); + + it('Should set page and canonical to pageUrl value set in config if present, even if canonical url is also present in head', () => { + config.setConfig({'pageUrl': 'https://www.set-from-config.com/path'}); + const testWindow = buildWindowTree(['https://example.com/some/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), + result = detectReferer(testWindow)(); + + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 0, stack: ['https://example.com/some/page'], - canonicalUrl: 'https://example.com/canonical/page' + canonicalUrl: 'https://www.set-from-config.com/path', + page: 'https://www.set-from-config.com/path', + ref: 'https://othersite.com/', + domain: 'www.set-from-config.com' + }); + }); + + it('Should set page with query params if canonical url is present without query params but the current page does have them', () => { + config.setConfig({'pageUrl': 'https://www.set-from-config.com/path'}); + const testWindow = buildWindowTree(['https://example.com/some/page?query1=123&query2=456'], 'https://othersite.com/', 'https://example.com/canonical/page'), + result = detectReferer(testWindow)(); + + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page?query1=123&query2=456', + location: 'https://example.com/some/page?query1=123&query2=456', + reachedTop: true, + isAmp: false, + numIframes: 0, + stack: ['https://example.com/some/page?query1=123&query2=456'], + canonicalUrl: 'https://www.set-from-config.com/path', + page: 'https://www.set-from-config.com/path?query1=123&query2=456', + ref: 'https://othersite.com/', + domain: 'www.set-from-config.com' }); }); }); @@ -130,8 +91,9 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 2, @@ -140,7 +102,10 @@ describe('Referer detection', () => { 'https://example.com/other/page', 'https://example.com/third/page' ], - canonicalUrl: null + canonicalUrl: null, + page: 'https://example.com/some/page', + ref: 'https://othersite.com/', + domain: 'example.com' }); }); @@ -148,8 +113,9 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 2, @@ -158,18 +124,22 @@ describe('Referer detection', () => { 'https://example.com/other/page', 'https://example.com/third/page' ], - canonicalUrl: 'https://example.com/canonical/page' + canonicalUrl: 'https://example.com/canonical/page', + page: 'https://example.com/some/page', + ref: 'https://othersite.com/', + domain: 'example.com' }); }); - it('Should override canonical URL with config pageUrl', () => { - config.setConfig({'pageUrl': 'testUrl.com'}); + it('Should override canonical URL (and page) with config pageUrl', () => { + config.setConfig({'pageUrl': 'https://testurl.com'}); const testWindow = buildWindowTree(['https://example.com/some/page', 'https://example.com/other/page', 'https://example.com/third/page'], 'https://othersite.com/', 'https://example.com/canonical/page'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 2, @@ -178,7 +148,10 @@ describe('Referer detection', () => { 'https://example.com/other/page', 'https://example.com/third/page' ], - canonicalUrl: 'testUrl.com' + canonicalUrl: 'https://testurl.com', + page: 'https://testurl.com', + ref: 'https://othersite.com/', + domain: 'testurl.com' }); }); }); @@ -189,8 +162,9 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + location: 'https://example.com/some/page', + topmostLocation: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 1, @@ -198,7 +172,10 @@ describe('Referer detection', () => { 'https://example.com/some/page', 'https://safe.frame/ad' ], - canonicalUrl: null + canonicalUrl: null, + page: 'https://example.com/some/page', + ref: null, + domain: 'example.com' }); }); @@ -206,8 +183,9 @@ describe('Referer detection', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://safe.frame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page', + location: 'https://example.com/some/page', reachedTop: true, isAmp: false, numIframes: 2, @@ -216,16 +194,20 @@ describe('Referer detection', () => { 'https://safe.frame/ad', 'https://safe.frame/ad' ], - canonicalUrl: null + canonicalUrl: null, + page: 'https://example.com/some/page', + ref: null, + domain: 'example.com', }); }); - it('Should return the second iframe location with three cross-origin windows and no ancessorOrigins', () => { + it('Should return the second iframe location with three cross-origin windows and no ancestorOrigins', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://otherfr.ame/ad'], 'https://othersite.com/', 'https://canonical.example.com/'), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://safe.frame/ad', + sinon.assert.match(result, { + topmostLocation: 'https://safe.frame/ad', + location: null, reachedTop: false, isAmp: false, numIframes: 2, @@ -234,16 +216,20 @@ describe('Referer detection', () => { 'https://safe.frame/ad', 'https://otherfr.ame/ad' ], - canonicalUrl: null + canonicalUrl: null, + page: null, + ref: null, + domain: null }); }); - it('Should return the top window origin with three cross-origin windows with ancessorOrigins', () => { + it('Should return the top window origin with three cross-origin windows with ancestorOrigins', () => { const testWindow = buildWindowTree(['https://example.com/some/page', 'https://safe.frame/ad', 'https://otherfr.ame/ad'], 'https://othersite.com/', 'https://canonical.example.com/', true), result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/', + location: 'https://example.com/', reachedTop: false, isAmp: false, numIframes: 2, @@ -252,7 +238,10 @@ describe('Referer detection', () => { 'https://safe.frame/ad', 'https://otherfr.ame/ad' ], - canonicalUrl: null + canonicalUrl: null, + page: 'https://example.com/', + ref: null, + domain: 'example.com' }); }); }); @@ -268,8 +257,9 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page/amp/', + sinon.assert.match(result, { + location: 'https://example.com/some/page/amp/', + topmostLocation: 'https://example.com/some/page/amp/', reachedTop: true, isAmp: true, numIframes: 1, @@ -277,7 +267,10 @@ describe('Referer detection', () => { 'https://example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad' ], - canonicalUrl: 'https://example.com/some/page/' + canonicalUrl: 'https://example.com/some/page/', + page: 'https://example.com/some/page/amp/', + ref: null, + domain: 'example.com' }); }); @@ -291,8 +284,9 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page/amp/', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page/amp/', + location: 'https://example.com/some/page/amp/', reachedTop: true, isAmp: true, numIframes: 1, @@ -300,10 +294,24 @@ describe('Referer detection', () => { 'https://example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad' ], - canonicalUrl: 'https://example.com/some/page/' + canonicalUrl: 'https://example.com/some/page/', + page: 'https://example.com/some/page/amp/', + ref: null, + domain: 'example.com' }); }); + it('should respect pageUrl as the primary source of canonicalUrl', () => { + config.setConfig({ + pageUrl: 'pub-defined' + }); + const w = buildWindowTree(['https://example.com', 'https://amp.com']); + w.context = { + canonicalUrl: 'should-be-overridden' + }; + expect(detectReferer(w)().canonicalUrl).to.equal('pub-defined'); + }); + describe('Cached AMP page in iframed search result', () => { it('Should return the AMP source and canonical URLs but with a null top-level stack location Without ancesorOrigins', () => { const testWindow = buildWindowTree(['https://google.com/amp/example-com/some/page/amp/', 'https://example-com.amp-cache.example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad']); @@ -315,8 +323,9 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page/amp/', + sinon.assert.match(result, { + topmostLocation: 'https://example.com/some/page/amp/', + location: 'https://example.com/some/page/amp/', reachedTop: false, isAmp: true, numIframes: 2, @@ -325,7 +334,10 @@ describe('Referer detection', () => { 'https://example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad' ], - canonicalUrl: 'https://example.com/some/page/' + canonicalUrl: 'https://example.com/some/page/', + page: 'https://example.com/some/page/amp/', + ref: null, + domain: 'example.com', }); }); @@ -339,8 +351,9 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page/amp/', + sinon.assert.match(result, { + location: 'https://example.com/some/page/amp/', + topmostLocation: 'https://example.com/some/page/amp/', reachedTop: false, isAmp: true, numIframes: 2, @@ -349,7 +362,10 @@ describe('Referer detection', () => { 'https://example.com/some/page/amp/', 'https://ad-iframe.ampproject.org/ad' ], - canonicalUrl: 'https://example.com/some/page/' + canonicalUrl: 'https://example.com/some/page/', + page: 'https://example.com/some/page/amp/', + ref: null, + domain: 'example.com' }); }); @@ -363,8 +379,9 @@ describe('Referer detection', () => { const result = detectReferer(testWindow)(); - expect(result).to.deep.equal({ - referer: 'https://example.com/some/page/amp/', + sinon.assert.match(result, { + location: 'https://example.com/some/page/amp/', + topmostLocation: 'https://example.com/some/page/amp/', reachedTop: false, isAmp: true, numIframes: 3, @@ -374,9 +391,160 @@ describe('Referer detection', () => { 'https://ad-iframe.ampproject.org/ad', 'https://ad-iframe.ampproject.org/ad' ], - canonicalUrl: 'https://example.com/some/page/' + canonicalUrl: 'https://example.com/some/page/', + page: 'https://example.com/some/page/amp/', + ref: null, + domain: 'example.com', }); }); }); }); }); + +describe('ensureProtocol', () => { + ['', null, undefined].forEach((val) => { + it(`should return unchanged invalid input: ${val}`, () => { + expect(ensureProtocol(val)).to.eql(val); + }); + }); + + ['http:', 'https:'].forEach((protocol) => { + Object.entries({ + 'window.top.location.protocol': { + top: { + location: { + protocol + } + }, + location: { + protocol: 'unused' + } + }, + 'window.location.protocol': (() => { + const w = { + top: {}, + location: { + protocol + } + }; + Object.defineProperty(w.top, 'location', { + get: function () { + throw new Error('cross-origin'); + } + }); + return w; + })(), + }).forEach(([t, win]) => { + describe(`when ${t} declares ${protocol}`, () => { + Object.entries({ + 'declared': { + url: 'proto://example.com/page', + expect: 'proto://example.com/page' + }, + 'relative': { + url: '//example.com/page', + expect: `${protocol}//example.com/page` + }, + 'missing': { + url: 'example.com/page', + expect: `${protocol}//example.com/page` + } + }).forEach(([t, {url, expect: expected}]) => { + it(`should handle URLs with ${t} protocols`, () => { + expect(ensureProtocol(url, win)).to.equal(expected); + }); + }); + }); + }); + }); +}); + +describe('parseDomain', () => { + Object.entries({ + 'www.example.com': 'www.example.com', + 'example.com:443': 'example.com:443', + 'www.sub.example.com': 'www.sub.example.com', + 'example.com/page': 'example.com', + 'www.example.com:443/page': 'www.example.com:443', + 'http://www.example.com:443/page?query=value': 'www.example.com:443', + '': undefined, + }).forEach(([input, expected]) => { + it(`should extract domain from '${input}' -> '${expected}`, () => { + expect(parseDomain(input)).to.equal(expected); + }); + }); + Object.entries({ + 'www.example.com': 'example.com', + 'https://www.sub.example.com': 'sub.example.com', + '//www.example.com:443': 'example.com:443', + 'without.www.example.com': 'without.www.example.com' + }).forEach(([input, expected]) => { + it('should remove leading www if requested', () => { + expect(parseDomain(input, {noLeadingWww: true})).to.equal(expected); + }) + }); + Object.entries({ + 'example.com:443': 'example.com', + 'https://sub.example.com': 'sub.example.com', + 'http://sub.example.com:8443': 'sub.example.com' + }).forEach(([input, expected]) => { + it('should remove port if requested', () => { + expect(parseDomain(input, {noPort: true})).to.equal(expected); + }) + }) +}); + +describe('cacheWithLocation', () => { + let fn, win, cached; + const RESULT = 'result'; + beforeEach(() => { + fn = sinon.stub().callsFake(() => RESULT); + win = { + location: { + }, + document: { + querySelector: sinon.stub() + } + } + }); + + describe('when window is not on top', () => { + beforeEach(() => { + win.top = {}; + cached = cacheWithLocation(fn, win); + }) + + it('should not cache', () => { + win.top = {}; + cached(); + expect(cached()).to.eql(RESULT); + expect(fn.callCount).to.eql(2); + }); + }) + + describe('when window is on top', () => { + beforeEach(() => { + win.top = win; + cached = cacheWithLocation(fn, win); + }) + + it('should not cache when canonical URL changes', () => { + let canonical = 'foo'; + win.document.querySelector.callsFake(() => ({href: canonical})); + cached(); + expect(cached()).to.eql(RESULT); + canonical = 'bar'; + expect(cached()).to.eql(RESULT); + expect(fn.callCount).to.eql(2); + }); + + it('should not cache when location changes', () => { + win.location.href = 'foo'; + cached(); + expect(cached()).to.eql(RESULT); + win.location.href = 'bar'; + expect(cached()).to.eql(RESULT); + expect(fn.callCount).to.eql(2); + }) + }); +}) diff --git a/test/spec/renderer_spec.js b/test/spec/renderer_spec.js index 6de06606136..fb1e25d6009 100644 --- a/test/spec/renderer_spec.js +++ b/test/spec/renderer_spec.js @@ -52,7 +52,7 @@ describe('Renderer', function () { expect(testRenderer2.getConfig()).to.deep.equal({ test: 'config2' }); }); - it('sets a render function with setRender method', function () { + it('sets a render function with the setRender method', function () { testRenderer1.setRender(spyRenderFn); expect(typeof testRenderer1.render).to.equal('function'); testRenderer1.render(); @@ -107,6 +107,20 @@ describe('Renderer', function () { sinon.assert.calledOnce(func2); expect(testRenderer1.cmd.length).to.equal(0); }); + + it('renders immediately when requested', function () { + const testRenderer3 = Renderer.install({ + config: { test: 'config2' }, + id: 2, + renderNow: true + }); + const func1 = sinon.spy(); + const testArg = 'testArgument'; + + testRenderer3.setRender(func1); + testRenderer3.render(testArg); + func1.calledWith(testArg).should.be.ok; + }); }); describe('3rd party renderer', function () { diff --git a/test/spec/sizeMapping_spec.js b/test/spec/sizeMapping_spec.js deleted file mode 100644 index c4efbddad6d..00000000000 --- a/test/spec/sizeMapping_spec.js +++ /dev/null @@ -1,341 +0,0 @@ -import { expect } from 'chai'; -import { resolveStatus, setSizeConfig, sizeSupported } from 'src/sizeMapping.js'; -import {includes} from 'src/polyfill.js' - -let utils = require('src/utils'); -let deepClone = utils.deepClone; - -describe('sizeMapping', function () { - var testSizes = { - banner: { - sizes: [[970, 90], [728, 90], [300, 250], [300, 100], [80, 80]] - } - }; - - var sizeConfig = [{ - 'mediaQuery': '(min-width: 1200px)', - 'sizesSupported': [ - [970, 90], - [728, 90], - [300, 250] - ] - }, { - 'mediaQuery': '(min-width: 768px) and (max-width: 1199px)', - 'sizesSupported': [ - [728, 90], - [300, 250], - [300, 100] - ] - }, { - 'mediaQuery': '(min-width: 0px) and (max-width: 767px)', - 'sizesSupported': [] - }]; - - var sizeConfigWithLabels = [{ - 'mediaQuery': '(min-width: 1200px)', - 'labels': ['desktop'] - }, { - 'mediaQuery': '(min-width: 768px) and (max-width: 1199px)', - 'sizesSupported': [ - [728, 90], - [300, 250] - ], - 'labels': ['tablet', 'phone'] - }, { - 'mediaQuery': '(min-width: 0px) and (max-width: 767px)', - 'sizesSupported': [ - [300, 250], - [300, 100] - ], - 'labels': ['phone'] - }]; - - let sandbox, - matchMediaOverride; - - beforeEach(function () { - setSizeConfig(sizeConfig); - - sandbox = sinon.sandbox.create(); - - matchMediaOverride = {matches: false}; - - sandbox.stub(utils.getWindowTop(), 'matchMedia').callsFake((...args) => { - if (typeof matchMediaOverride === 'function') { - return matchMediaOverride.apply(utils.getWindowTop(), args); - } - return matchMediaOverride; - }); - }); - - afterEach(function () { - setSizeConfig([]); - - sandbox.restore(); - }); - - describe('when handling sizes', function () { - it('should allow us to validate a single size', function() { - matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; - - expect(sizeSupported([300, 250])).to.equal(true); - expect(sizeSupported([80, 80])).to.equal(false); - }); - - it('should log a warning when mediaQuery property missing from sizeConfig', function () { - let errorConfig = deepClone(sizeConfig); - - delete errorConfig[0].mediaQuery; - - sandbox.stub(utils, 'logWarn'); - - resolveStatus(undefined, testSizes, undefined, errorConfig); - expect(utils.logWarn.firstCall.args[0]).to.match(/missing.+?mediaQuery/); - }); - - it('should log a warning message when mediaQuery property is declared as an empty string', function() { - const errorConfig = deepClone(sizeConfig); - errorConfig[0].mediaQuery = ''; - - sandbox.stub(utils, 'logWarn'); - resolveStatus(undefined, testSizes, undefined, errorConfig); - expect(utils.logWarn.firstCall.args[0]).to.match(/missing.+?mediaQuery/); - }); - - it('should allow deprecated adUnit.sizes', function() { - matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; - - let status = resolveStatus(undefined, undefined, testSizes.banner.sizes, sizeConfig); - - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [[970, 90], [728, 90], [300, 250]] - } - }); - }); - - it('when one mediaQuery block matches, it should filter the adUnit.sizes passed in', function () { - matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; - - let status = resolveStatus(undefined, testSizes, undefined, sizeConfig); - - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [[970, 90], [728, 90], [300, 250]] - } - }); - }); - - it('when multiple mediaQuery block matches, it should filter a union of the matched sizesSupported', function () { - matchMediaOverride = (str) => includes([ - '(min-width: 1200px)', - '(min-width: 768px) and (max-width: 1199px)' - ], str) ? {matches: true} : {matches: false}; - - let status = resolveStatus(undefined, testSizes, undefined, sizeConfig); - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [[970, 90], [728, 90], [300, 250], [300, 100]] - } - }); - }); - - it('if no mediaQueries match, it should allow all sizes specified', function () { - matchMediaOverride = () => ({matches: false}); - - let status = resolveStatus(undefined, testSizes, undefined, sizeConfig); - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal(testSizes); - }); - - it('if a mediaQuery matches and has sizesSupported: [], it should filter all sizes', function () { - matchMediaOverride = (str) => str === '(min-width: 0px) and (max-width: 767px)' ? {matches: true} : {matches: false}; - - let status = resolveStatus(undefined, testSizes, undefined, sizeConfig); - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [] - } - }); - }); - - it('should filter all banner sizes and should disable the adUnit even if other mediaTypes are present', function () { - matchMediaOverride = (str) => str === '(min-width: 0px) and (max-width: 767px)' ? {matches: true} : {matches: false}; - let status = resolveStatus(undefined, Object.assign({}, testSizes, { - native: { - type: 'image' - } - }), undefined, sizeConfig); - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [] - }, - native: { - type: 'image' - } - }); - }); - - it('if a mediaQuery matches and no sizesSupported specified, it should not affect adUnit.sizes', function () { - matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; - - let status = resolveStatus(undefined, testSizes, undefined, sizeConfigWithLabels); - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal(testSizes); - }); - }); - - describe('when handling labels', function () { - it('should activate/deactivate adUnits/bidders based on sizeConfig.labels', function () { - matchMediaOverride = (str) => str === '(min-width: 1200px)' ? {matches: true} : {matches: false}; - - let status = resolveStatus({ - labels: ['desktop'] - }, testSizes, undefined, sizeConfigWithLabels); - - expect(status).to.deep.equal({ - active: true, - mediaTypes: testSizes - }); - - status = resolveStatus({ - labels: ['tablet'] - }, testSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal(testSizes); - }); - - it('should activate/decactivate adUnits/bidders based on labels with multiformat ads', function () { - matchMediaOverride = (str) => str === '(min-width: 768px) and (max-width: 1199px)' ? {matches: true} : {matches: false}; - - let multiFormatSizes = { - banner: { - sizes: [[728, 90], [300, 300]] - }, - native: { - type: 'image' - }, - video: { - context: 'outstream', - playerSize: [300, 300] - } - }; - - let status = resolveStatus({ - labels: ['tablet', 'test'], - labelAll: true - }, multiFormatSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [[728, 90]] - }, - native: { - type: 'image' - }, - video: { - context: 'outstream', - playerSize: [300, 300] - } - }); - - status = resolveStatus({ - labels: ['tablet'] - }, multiFormatSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [[728, 90]] - }, - native: { - type: 'image' - }, - video: { - context: 'outstream', - playerSize: [300, 300] - } - }); - - multiFormatSizes.banner.sizes.splice(0, 1, [728, 80]); - status = resolveStatus({ - labels: ['tablet'] - }, multiFormatSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal({ - banner: { - sizes: [] - }, - native: { - type: 'image' - }, - video: { - context: 'outstream', - playerSize: [300, 300] - } - }); - - delete multiFormatSizes.banner; - status = resolveStatus({ - labels: ['tablet'] - }, multiFormatSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal({ - native: { - type: 'image' - }, - video: { - context: 'outstream', - playerSize: [300, 300] - } - }); - }); - - it('should active/deactivate adUnits/bidders based on requestBids labels', function () { - let activeLabels = ['us-visitor', 'desktop', 'smart']; - - let status = resolveStatus({ - labels: ['uk-visitor'], // from adunit - activeLabels // from requestBids.labels - }, testSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal(testSizes); - - status = resolveStatus({ - labels: ['us-visitor'], - activeLabels - }, testSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal(testSizes); - - status = resolveStatus({ - labels: ['us-visitor', 'tablet'], - labelAll: true, - activeLabels - }, testSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(false); - expect(status.mediaTypes).to.deep.equal(testSizes); - - status = resolveStatus({ - labels: ['us-visitor', 'desktop'], - labelAll: true, - activeLabels - }, testSizes, undefined, sizeConfigWithLabels); - - expect(status.active).to.equal(true); - expect(status.mediaTypes).to.deep.equal(testSizes); - }); - }); -}); diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index 88beaa88a67..98d841d9c7c 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -4,7 +4,7 @@ import adapterManager, { coppaDataHandler, _partitionBidders, PARTITIONS, - getS2SBidderSet, _filterBidsForAdUnit + getS2SBidderSet, _filterBidsForAdUnit, dep } from 'src/adapterManager.js'; import { getAdUnits, @@ -16,10 +16,14 @@ import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils.js'; import { config } from 'src/config.js'; import { registerBidder } from 'src/adapters/bidderFactory.js'; -import { setSizeConfig } from 'src/sizeMapping.js'; +import { setSizeConfig } from 'modules/sizeMapping.js'; import {find, includes} from 'src/polyfill.js'; import s2sTesting from 'modules/s2sTesting.js'; import {hook} from '../../../../src/hook.js'; +import {auctionManager} from '../../../../src/auctionManager.js'; +import {GDPR_GVLIDS} from '../../../../src/consentHandler.js'; +import {MODULE_TYPE_ANALYTICS, MODULE_TYPE_BIDDER} from '../../../../src/activities/modules.js'; +import {ACTIVITY_FETCH_BIDS, ACTIVITY_REPORT_ANALYTICS} from '../../../../src/activities/activities.js'; var events = require('../../../../src/events'); const CONFIG = { @@ -350,103 +354,79 @@ describe('adapterManager tests', function () { }); }); // end callTimedOutBidders - describe('onBidWon', function () { - var criteoSpec = { onBidWon: sinon.stub() } - var criteoAdapter = { - bidder: 'criteo', - getSpec: function() { return criteoSpec; } - } + describe('bidder spec methods', () => { + let adUnits, bids, criteoSpec; before(function () { config.setConfig({s2sConfig: { enabled: false }}); }); - beforeEach(function () { - adapterManager.bidderRegistry['criteo'] = criteoAdapter; - }); - - afterEach(function () { - delete adapterManager.bidderRegistry['criteo']; - }); - - it('should call spec\'s onBidWon callback when a bid is won', function () { - const bids = [ + beforeEach(() => { + criteoSpec = {} + adapterManager.bidderRegistry['criteo'] = { + bidder: 'criteo', + getSpec: function() { return criteoSpec; }, + } + bids = [ {bidder: 'criteo', params: {placementId: 'id'}}, ]; - const adUnits = [{ + adUnits = [{ code: 'adUnit-code', sizes: [[728, 90]], bids }]; - - adapterManager.callBidWonBidder(bids[0].bidder, bids[0], adUnits); - sinon.assert.called(criteoSpec.onBidWon); - }); - }); // end onBidWon - - describe('onSetTargeting', function () { - var criteoSpec = { onSetTargeting: sinon.stub() } - var criteoAdapter = { - bidder: 'criteo', - getSpec: function() { return criteoSpec; } - } - before(function () { - config.setConfig({s2sConfig: { enabled: false }}); - }); - - beforeEach(function () { - adapterManager.bidderRegistry['criteo'] = criteoAdapter; }); afterEach(function () { delete adapterManager.bidderRegistry['criteo']; }); - it('should call spec\'s onSetTargeting callback when setTargeting is called', function () { - const bids = [ - {bidder: 'criteo', params: {placementId: 'id'}}, - ]; - const adUnits = [{ - code: 'adUnit-code', - sizes: [[728, 90]], - bids - }]; - adapterManager.callSetTargetingBidder(bids[0].bidder, bids[0], adUnits); - sinon.assert.called(criteoSpec.onSetTargeting); - }); - }); // end onSetTargeting + describe('onBidWon', function () { + beforeEach(() => { + criteoSpec.onBidWon = sinon.stub() + }); + it('should call spec\'s onBidWon callback when a bid is won', function () { + adapterManager.callBidWonBidder(bids[0].bidder, bids[0], adUnits); + sinon.assert.called(criteoSpec.onBidWon); + }); - describe('onBidViewable', function () { - var criteoSpec = { onBidViewable: sinon.stub() } - var criteoAdapter = { - bidder: 'criteo', - getSpec: function() { return criteoSpec; } - } - before(function () { - config.setConfig({s2sConfig: { enabled: false }}); + it('should NOT call onBidWon when the bid is S2S', () => { + bids[0].src = CONSTANTS.S2S.SRC + adapterManager.callBidWonBidder(bids[0].bidder, bids[0], adUnits); + sinon.assert.notCalled(criteoSpec.onBidWon); + }) }); - beforeEach(function () { - adapterManager.bidderRegistry['criteo'] = criteoAdapter; - }); + describe('onSetTargeting', function () { + beforeEach(() => { + criteoSpec.onSetTargeting = sinon.stub() + }) - afterEach(function () { - delete adapterManager.bidderRegistry['criteo']; - }); + it('should call spec\'s onSetTargeting callback when setTargeting is called', function () { + adapterManager.callSetTargetingBidder(bids[0].bidder, bids[0], adUnits); + sinon.assert.called(criteoSpec.onSetTargeting); + }); - it('should call spec\'s onBidViewable callback when callBidViewableBidder is called', function () { - const bids = [ - {bidder: 'criteo', params: {placementId: 'id'}}, - ]; - const adUnits = [{ - code: 'adUnit-code', - sizes: [[728, 90]], - bids - }]; - adapterManager.callBidViewableBidder(bids[0].bidder, bids[0]); - sinon.assert.called(criteoSpec.onBidViewable); + it('should NOT call onSetTargeting when bid is S2S', () => { + bids[0].src = CONSTANTS.S2S.SRC; + adapterManager.callSetTargetingBidder(bids[0].bidder, bids[0], adUnits); + sinon.assert.notCalled(criteoSpec.onSetTargeting); + }) + }); // end onSetTargeting + describe('onBidViewable', function () { + beforeEach(() => { + criteoSpec.onBidViewable = sinon.stub(); + }) + it('should call spec\'s onBidViewable callback when callBidViewableBidder is called', function () { + adapterManager.callBidViewableBidder(bids[0].bidder, bids[0]); + sinon.assert.called(criteoSpec.onBidViewable); + }); + it('should NOT call onBidViewable when bid is S2S', () => { + bids[0].src = CONSTANTS.S2S.SRC; + adapterManager.callBidViewableBidder(bids[0].bidder, bids[0]); + sinon.assert.notCalled(criteoSpec.onBidViewable); + }) }); - }); // end onBidViewable - + }) describe('onBidderError', function () { const bidder = 'appnexus'; const appnexusSpec = { onBidderError: sinon.stub() }; @@ -985,13 +965,23 @@ describe('adapterManager tests', function () { }]; it('invokes callBids on the S2S adapter', function () { + const done = sinon.stub(); + const onTimelyResponse = sinon.stub(); + prebidServerAdapterMock.callBids.callsFake((_1, _2, _3, done) => { + done(); + }); adapterManager.callBids( getAdUnits(), bidRequests, () => {}, - () => () => {} + done, + undefined, + undefined, + onTimelyResponse ); sinon.assert.calledTwice(prebidServerAdapterMock.callBids); + sinon.assert.calledTwice(done); + bidRequests.forEach(br => sinon.assert.calledWith(onTimelyResponse, br.bidderRequestId)); }); // Enable this test when prebidServer adapter is made 1.0 compliant @@ -1601,12 +1591,15 @@ describe('adapterManager tests', function () { }); it('should add alias to registry when original adapter is using bidderFactory', function() { - let thisSpec = Object.assign(spec, { supportedMediaTypes: ['video'] }); + const mediaType = FEATURES.VIDEO ? 'video' : 'banner' + let thisSpec = Object.assign(spec, { supportedMediaTypes: [mediaType] }); registerBidder(thisSpec); const alias = 'aliasBidder'; adapterManager.aliasBidAdapter(CODE, alias); expect(adapterManager.bidderRegistry).to.have.property(alias); - expect(adapterManager.videoAdapters).to.include(alias); + if (FEATURES.VIDEO) { + expect(adapterManager.videoAdapters).to.include(alias); + } }); }); @@ -1671,25 +1664,29 @@ describe('adapterManager tests', function () { }) }); - it('should add nativeParams to adUnits after BEFORE_REQUEST_BIDS', () => { - function beforeReqBids(adUnits) { - adUnits.forEach(adUnit => { - adUnit.mediaTypes.native = { - type: 'image', - } - }) - } - events.on(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, beforeReqBids); - adapterManager.makeBidRequests( - adUnits, - Date.now(), - utils.getUniqueIdentifierStr(), - function callback() {}, - [] - ); - events.off(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, beforeReqBids); - expect(adUnits.map((u) => u.nativeParams).some(i => i == null)).to.be.false; - }); + if (FEATURES.NATIVE) { + it('should add nativeParams to adUnits after BEFORE_REQUEST_BIDS', () => { + function beforeReqBids(adUnits) { + adUnits.forEach(adUnit => { + adUnit.mediaTypes.native = { + type: 'image', + } + }) + } + + events.on(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, beforeReqBids); + adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() { + }, + [] + ); + events.off(CONSTANTS.EVENTS.BEFORE_REQUEST_BIDS, beforeReqBids); + expect(adUnits.map((u) => u.nativeParams).some(i => i == null)).to.be.false; + }); + } it('should make separate bidder request objects for each bidder', () => { adUnits = [utils.deepClone(getAdUnits()[0])]; @@ -1711,6 +1708,370 @@ describe('adapterManager tests', function () { expect(sizes1).not.to.deep.equal(sizes2); }); + describe('and activity controls', () => { + let redactOrtb2; + let redactBidRequest; + const MOCK_BIDDERS = ['1', '2', '3', '4', '5'].map((n) => `mockBidder${n}`); + + beforeEach(() => { + sinon.stub(dep, 'isAllowed'); + redactOrtb2 = sinon.stub().callsFake(ob => ob); + redactBidRequest = sinon.stub().callsFake(ob => ob); + sinon.stub(dep, 'redact').callsFake(() => ({ + ortb2: redactOrtb2, + bidRequest: redactBidRequest + })) + MOCK_BIDDERS.forEach((bidder) => adapterManager.bidderRegistry[bidder] = {}); + }); + afterEach(() => { + dep.isAllowed.restore(); + dep.redact.restore(); + MOCK_BIDDERS.forEach(bidder => { delete adapterManager.bidderRegistry[bidder] }); + config.resetConfig(); + }) + it('should not generate requests for bidders that cannot fetchBids', () => { + adUnits = [ + {code: 'one', bids: ['mockBidder1', 'mockBidder2', 'mockBidder3'].map((bidder) => ({bidder}))}, + {code: 'two', bids: ['mockBidder4', 'mockBidder5', 'mockBidder4'].map((bidder) => ({bidder}))} + ]; + const allowed = ['mockBidder2', 'mockBidder5']; + dep.isAllowed.callsFake((activity, {componentType, componentName}) => { + return activity === ACTIVITY_FETCH_BIDS && + componentType === MODULE_TYPE_BIDDER && + allowed.includes(componentName); + }); + let reqs = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() {}, + [] + ); + const bidders = Array.from(new Set(reqs.flatMap(br => br.bids).map(bid => bid.bidder)).keys()); + expect(bidders).to.have.members(allowed); + }); + + it('should redact ortb2 and bid request objects', () => { + dep.isAllowed.callsFake(() => true); + adUnits = [ + {code: 'one', bids: [{bidder: 'mockBidder1'}]} + ]; + let reqs = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() {}, + [] + ); + sinon.assert.calledWith(redactBidRequest, reqs[0].bids[0]); + sinon.assert.calledWith(redactOrtb2, reqs[0].ortb2); + }) + + describe('with multiple s2s configs', () => { + beforeEach(() => { + config.setConfig({ + s2sConfig: [ + { + enabled: true, + adapter: 'mockS2SDefault', + bidders: ['mockBidder1'] + }, + { + enabled: true, + adapter: 'mockS2S1', + configName: 'mock1', + }, + { + enabled: true, + adapter: 'mockS2S2', + configName: 'mock2', + } + ] + }); + }); + it('should keep stored impressions, even if everything else is denied', () => { + adUnits = [ + {code: 'one', bids: [{bidder: null}]}, + {code: 'two', bids: [{module: 'pbsBidAdapter', params: {configName: 'mock1'}}, {module: 'pbsBidAdapter', params: {configName: 'mock2'}}]} + ] + dep.isAllowed.callsFake(({componentType}) => componentType !== 'bidder'); + let bidRequests = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() {}, + [] + ); + expect(new Set(bidRequests.map(br => br.uniquePbsTid)).size).to.equal(3); + }); + + it('should check if the s2s adapter itself is allowed to fetch bids', () => { + adUnits = [ + { + code: 'au', + bids: [ + {bidder: null}, + {module: 'pbsBidAdapter', params: {configName: 'mock1'}}, + {module: 'pbsBidAdapter', params: {configName: 'mock2'}}, + {bidder: 'mockBidder1'} + ] + } + ]; + dep.isAllowed.callsFake((_, {configName, componentName}) => !(componentName === 'pbsBidAdapter' && configName === 'mock1')); + let bidRequests = adapterManager.makeBidRequests( + adUnits, + Date.now(), + utils.getUniqueIdentifierStr(), + function callback() { + }, + [] + ); + expect(new Set(bidRequests.map(br => br.uniquePbsTid)).size).to.eql(2) + }); + }); + }); + + it('should make FPD available under `ortb2`', () => { + const global = { + k1: 'v1', + k2: { + k3: 'v3', + k4: 'v4' + } + }; + const bidder = { + 'appnexus': { + ka: 'va', + k2: { + k3: 'override', + k5: 'v5' + } + } + }; + const requests = Object.fromEntries( + adapterManager.makeBidRequests(adUnits, 123, 'auction-id', 123, [], {global, bidder}) + .map((r) => [r.bidderCode, r]) + ); + sinon.assert.match(requests, { + rubicon: { + ortb2: global + }, + appnexus: { + ortb2: { + k1: 'v1', + ka: 'va', + k2: { + k3: 'override', + k4: 'v4', + k5: 'v5', + } + } + } + }); + requests.rubicon.bids.forEach((bid) => expect(bid.ortb2).to.eql(requests.rubicon.ortb2)); + requests.appnexus.bids.forEach((bid) => expect(bid.ortb2).to.eql(requests.appnexus.ortb2)); + }); + + describe('source.tid', () => { + beforeEach(() => { + sinon.stub(dep, 'redact').returns({ + ortb2: (o) => o, + bidRequest: (b) => b, + }); + }); + afterEach(() => { + dep.redact.restore(); + }); + + it('should be populated with auctionId', () => { + const reqs = adapterManager.makeBidRequests(adUnits, 0, 'mockAuctionId', 1000, [], {global: {}}); + expect(reqs[0].ortb2.source.tid).to.equal('mockAuctionId'); + }) + }); + + it('should merge in bid-level ortb2Imp with adUnit-level ortb2Imp', () => { + const adUnit = { + ...adUnits[1], + ortb2Imp: {oneone: {twoone: 'val'}, onetwo: 'val'} + }; + adUnit.bids[0].ortb2Imp = {oneone: {twotwo: 'val'}, onethree: 'val', onetwo: 'val2'}; + const reqs = Object.fromEntries( + adapterManager.makeBidRequests([adUnit], 123, 'auction-id', 123, [], {}) + .map((req) => [req.bidderCode, req]) + ); + sinon.assert.match(reqs[adUnit.bids[0].bidder].bids[0].ortb2Imp, { + oneone: { + twoone: 'val', + twotwo: 'val', + }, + onetwo: 'val2', + onethree: 'val' + }) + sinon.assert.match(reqs[adUnit.bids[1].bidder].bids[0].ortb2Imp, adUnit.ortb2Imp) + }) + + it('picks ortb2Imp from "module" when only one s2sConfig is set', () => { + config.setConfig({ + s2sConfig: [ + { + enabled: true, + adapter: 'mockS2S1', + } + ] + }); + const adUnit = { + code: 'mockau', + ortb2Imp: { + p1: 'adUnit' + }, + bids: [ + { + module: 'pbsBidAdapter', + ortb2Imp: { + p2: 'module' + } + } + ] + }; + const req = adapterManager.makeBidRequests([adUnit], 123, 'auction-id', 123, [], {})[0]; + [req.adUnitsS2SCopy[0].ortb2Imp, req.bids[0].ortb2Imp].forEach(imp => { + sinon.assert.match(imp, { + p1: 'adUnit', + p2: 'module' + }); + }); + }); + + describe('with named s2s configs', () => { + beforeEach(() => { + config.setConfig({ + s2sConfig: [ + { + enabled: true, + adapter: 'mockS2S1', + configName: 'one', + bidders: ['A'] + }, + { + enabled: true, + adapter: 'mockS2S2', + configName: 'two', + bidders: ['B'] + } + ] + }) + }); + + it('generates requests for "module" bids', () => { + const adUnit = { + code: 'mockau', + ortb2Imp: { + p1: 'adUnit' + }, + bids: [ + { + module: 'pbsBidAdapter', + params: {configName: 'one'}, + ortb2Imp: { + p2: 'one' + } + }, + { + module: 'pbsBidAdapter', + params: {configName: 'two'}, + ortb2Imp: { + p2: 'two' + } + } + ] + }; + const reqs = adapterManager.makeBidRequests([adUnit], 123, 'auction-id', 123, [], {}); + [reqs[0].adUnitsS2SCopy[0].ortb2Imp, reqs[0].bids[0].ortb2Imp].forEach(imp => { + sinon.assert.match(imp, { + p1: 'adUnit', + p2: 'one' + }) + }); + [reqs[1].adUnitsS2SCopy[0].ortb2Imp, reqs[1].bids[0].ortb2Imp].forEach(imp => { + sinon.assert.match(imp, { + p1: 'adUnit', + p2: 'two' + }) + }); + }); + + it('applies module-level ortb2Imp to "normal" s2s requests', () => { + const adUnit = { + code: 'mockau', + ortb2Imp: { + p1: 'adUnit' + }, + bids: [ + { + module: 'pbsBidAdapter', + params: {configName: 'one'}, + ortb2Imp: { + p2: 'one' + } + }, + { + bidder: 'A', + ortb2Imp: { + p3: 'bidderA' + } + } + ] + }; + const reqs = adapterManager.makeBidRequests([adUnit], 123, 'auction-id', 123, [], {}); + expect(reqs.length).to.equal(1); + sinon.assert.match(reqs[0].adUnitsS2SCopy[0].ortb2Imp, { + p1: 'adUnit', + p2: 'one' + }) + sinon.assert.match(reqs[0].bids[0].ortb2Imp, { + p1: 'adUnit', + p2: 'one', + p3: 'bidderA' + }) + }); + }); + + describe('when calling the s2s adapter', () => { + beforeEach(() => { + config.setConfig({ + s2sConfig: { + enabled: true, + adapter: 'mockS2S', + bidders: ['appnexus'] + } + }) + adapterManager.bidderRegistry.mockS2S = { + callBids: sinon.stub() + }; + }); + afterEach(() => { + config.resetConfig(); + delete adapterManager.bidderRegistry.mockS2S; + }) + + it('should pass FPD', () => { + const ortb2Fragments = {}; + const req = { + bidderCode: 'appnexus', + src: CONSTANTS.S2S.SRC, + adUnitsS2SCopy: adUnits, + bids: [{ + bidder: 'appnexus', + src: CONSTANTS.S2S.SRC + }] + }; + adapterManager.callBids(adUnits, [req], sinon.stub(), sinon.stub(), {request: sinon.stub(), done: sinon.stub()}, 1000, sinon.stub(), ortb2Fragments); + sinon.assert.calledWith(adapterManager.bidderRegistry.mockS2S.callBids, sinon.match({ + ortb2Fragments: sinon.match.same(ortb2Fragments) + })); + }); + }) + describe('setBidderSequence', function () { beforeEach(function () { sinon.spy(utils, 'shuffle'); @@ -1768,45 +2129,6 @@ describe('adapterManager tests', function () { expect(appnexusBidRequests.bids[1].mediaTypes).to.deep.equal(find(adUnits, adUnit => adUnit.code === appnexusBidRequests.bids[1].adUnitCode).mediaTypes); }); - it('should not filter video bids', function () { - setSizeConfig([{ - 'mediaQuery': '(min-width: 768px) and (max-width: 1199px)', - 'sizesSupported': [ - [728, 90], - [300, 250] - ], - 'labels': ['tablet', 'phone'] - }]); - - let videoAdUnits = [{ - code: 'test_video', - mediaTypes: { - video: { - playerSize: [300, 300], - context: 'outstream' - } - }, - bids: [{ - bidder: 'appnexus', - params: { - placementId: 13232385, - video: { - skippable: true, - playback_method: ['auto_play_sound_off'] - } - } - }] - }]; - let bidRequests = adapterManager.makeBidRequests( - videoAdUnits, - Date.now(), - utils.getUniqueIdentifierStr(), - function callback() {}, - [] - ); - expect(bidRequests[0].bids[0].sizes).to.deep.equal([300, 300]); - }); - it('should not filter native bids', function () { setSizeConfig([{ 'mediaQuery': '(min-width: 768px) and (max-width: 1199px)', @@ -2404,4 +2726,180 @@ describe('adapterManager tests', function () { }) }); }); + + describe('callDataDeletionRequest', () => { + function delMethodForBidder(bidderCode) { + const del = sinon.stub(); + adapterManager.registerBidAdapter({ + callBids: sinon.stub(), + getSpec() { + return { + onDataDeletionRequest: del + } + } + }, bidderCode); + return del; + } + + function delMethodForAnalytics(provider) { + const del = sinon.stub(); + adapterManager.registerAnalyticsAdapter({ + code: provider, + adapter: { + enableAnalytics: sinon.stub(), + onDataDeletionRequest: del, + }, + }) + return del; + } + + Object.entries({ + 'bid adapters': delMethodForBidder, + 'analytics adapters': delMethodForAnalytics + }).forEach(([t, getDelMethod]) => { + describe(t, () => { + it('invokes onDataDeletionRequest', () => { + const del = getDelMethod('mockAdapter'); + adapterManager.callDataDeletionRequest(); + sinon.assert.calledOnce(del); + }); + + it('does not choke if onDeletionRequest throws', () => { + const del1 = getDelMethod('mockAdapter1'); + const del2 = getDelMethod('mockAdapter2'); + del1.throws(new Error()); + adapterManager.callDataDeletionRequest(); + sinon.assert.calledOnce(del1); + sinon.assert.calledOnce(del2); + }); + }) + }) + + describe('for bid adapters', () => { + let bidderRequests; + + beforeEach(() => { + bidderRequests = []; + ['mockBidder', 'mockBidder1', 'mockBidder2'].forEach(bidder => { + adapterManager.registerBidAdapter({callBids: sinon.stub(), getSpec: () => ({code: bidder})}, bidder); + }) + sinon.stub(auctionManager, 'getBidsRequested').callsFake(() => bidderRequests); + }) + afterEach(() => { + auctionManager.getBidsRequested.restore(); + }) + + it('can resolve aliases', () => { + adapterManager.aliasBidAdapter('mockBidder', 'mockBidderAlias'); + expect(adapterManager.resolveAlias('mockBidderAlias')).to.eql('mockBidder'); + }); + it('does not stuck in alias cycles', () => { + adapterManager.aliasRegistry['alias1'] = 'alias2'; + adapterManager.aliasRegistry['alias2'] = 'alias2'; + expect(adapterManager.resolveAlias('alias2')).to.eql('alias2'); + }) + it('returns self when not an alias', () => { + delete adapterManager.aliasRegistry['missing']; + expect(adapterManager.resolveAlias('missing')).to.eql('missing'); + }) + + it('does not invoke onDataDeletionRequest on aliases', () => { + const del = delMethodForBidder('mockBidder'); + adapterManager.aliasBidAdapter('mockBidder', 'mockBidderAlias'); + adapterManager.aliasBidAdapter('mockBidderAlias2', 'mockBidderAlias'); + adapterManager.callDataDeletionRequest(); + sinon.assert.calledOnce(del); + }); + + it('passes known bidder requests', () => { + const del1 = delMethodForBidder('mockBidder1'); + const del2 = delMethodForBidder('mockBidder2'); + adapterManager.aliasBidAdapter('mockBidder1', 'mockBidder1Alias'); + adapterManager.aliasBidAdapter('mockBidder1Alias', 'mockBidder1Alias2') + bidderRequests = [ + { + bidderCode: 'mockBidder1', + id: 0 + }, + { + bidderCode: 'mockBidder2', + id: 1, + }, + { + bidderCode: 'mockBidder1Alias', + id: 2, + }, + { + bidderCode: 'someOtherBidder', + id: 3 + }, + { + bidderCode: 'mockBidder1Alias2', + id: 4 + } + ]; + adapterManager.callDataDeletionRequest(); + sinon.assert.calledWith(del1, [bidderRequests[0], bidderRequests[2], bidderRequests[4]]); + sinon.assert.calledWith(del2, [bidderRequests[1]]); + }) + }) + }); + + describe('reportAnalytics check', () => { + beforeEach(() => { + sinon.stub(dep, 'isAllowed'); + }); + afterEach(() => { + dep.isAllowed.restore(); + }); + + it('should check for reportAnalytics before registering analytics adapter', () => { + const enabled = {}; + ['mockAnalytics1', 'mockAnalytics2'].forEach((code) => { + adapterManager.registerAnalyticsAdapter({ + code, + adapter: { + enableAnalytics: sinon.stub().callsFake(() => { enabled[code] = true }) + } + }) + }) + + const anlCfg = [ + { + provider: 'mockAnalytics1', + random: 'values' + }, + { + provider: 'mockAnalytics2' + } + ] + dep.isAllowed.callsFake((activity, {component, _config}) => { + return activity === ACTIVITY_REPORT_ANALYTICS && + component === `${MODULE_TYPE_ANALYTICS}.${anlCfg[0].provider}` && + _config === anlCfg[0] + }) + + adapterManager.enableAnalytics(anlCfg); + expect(enabled).to.eql({mockAnalytics1: true}); + }); + }); + + describe('registers GVL IDs', () => { + beforeEach(() => { + sinon.stub(GDPR_GVLIDS, 'register'); + }); + afterEach(() => { + GDPR_GVLIDS.register.restore(); + }); + + it('for bid adapters', () => { + adapterManager.registerBidAdapter({getSpec: () => ({gvlid: 123}), callBids: sinon.stub()}, 'mock'); + sinon.assert.calledWith(GDPR_GVLIDS.register, MODULE_TYPE_BIDDER, 'mock', 123); + }); + + it('for analytics adapters', () => { + adapterManager.registerAnalyticsAdapter({adapter: {enableAnalytics: sinon.stub()}, code: 'mock', gvlid: 123}); + sinon.assert.calledWith(GDPR_GVLIDS.register, MODULE_TYPE_ANALYTICS, 'mock', 123); + }); + }); }); diff --git a/test/spec/unit/core/ajax_spec.js b/test/spec/unit/core/ajax_spec.js new file mode 100644 index 00000000000..df0ce02c15c --- /dev/null +++ b/test/spec/unit/core/ajax_spec.js @@ -0,0 +1,403 @@ +import {dep, attachCallbacks, fetcherFactory, toFetchRequest} from '../../../../src/ajax.js'; +import {config} from 'src/config.js'; +import {server} from '../../../mocks/xhr.js'; +import {sandbox} from 'sinon'; + +const EXAMPLE_URL = 'https://www.example.com'; + +describe('fetcherFactory', () => { + let clock; + + beforeEach(() => { + clock = sinon.useFakeTimers(); + server.autoTimeout = true; + }); + + afterEach(() => { + clock.runAll(); + clock.restore(); + config.resetConfig(); + }); + + Object.entries({ + 'URL': EXAMPLE_URL, + 'request object': new Request(EXAMPLE_URL) + }).forEach(([t, resource]) => { + it(`times out after timeout when fetching ${t}`, (done) => { + const fetch = fetcherFactory(1000); + const resp = fetch(resource); + clock.tick(900); + expect(server.requests[0].fetch.request.signal.aborted).to.be.false; + clock.tick(100); + expect(server.requests[0].fetch.request.signal.aborted).to.be.true; + resp.catch(() => done()); + }); + }); + + it('does not timeout after it completes', () => { + const fetch = fetcherFactory(1000); + const resp = fetch(EXAMPLE_URL); + server.requests[0].respond(); + return resp.then(() => { + clock.tick(2000); + expect(server.requests[0].fetch.request.signal.aborted).to.be.false; + }); + }); + + Object.entries({ + 'disableAjaxTimeout is set'() { + const fetcher = fetcherFactory(1000); + config.setConfig({disableAjaxTimeout: true}); + return fetcher; + }, + 'timeout is null'() { + return fetcherFactory(null); + }, + }).forEach(([t, mkFetcher]) => { + it(`does not timeout if ${t}`, (done) => { + const fetch = mkFetcher(); + const pm = fetch(EXAMPLE_URL); + clock.tick(2000); + server.requests[0].respond(); + pm.then(() => done()); + }); + }); + + Object.entries({ + 'local URL': ['/local.html', window.origin], + 'remote URL': [EXAMPLE_URL + '/remote.html', EXAMPLE_URL], + 'request with local URL': [new Request('/local.html'), window.origin], + 'request with remote URL': [new Request(EXAMPLE_URL + '/remote.html'), EXAMPLE_URL] + }).forEach(([t, [resource, expectedOrigin]]) => { + describe(`using ${t}`, () => { + it('calls request, passing origin', () => { + const request = sinon.stub(); + const fetch = fetcherFactory(1000, {request}); + fetch(resource); + sinon.assert.calledWith(request, expectedOrigin); + }); + + Object.entries({ + success: 'respond', + error: 'error' + }).forEach(([t, method]) => { + it(`calls done on ${t}, passing origin`, () => { + const done = sinon.stub(); + const fetch = fetcherFactory(1000, {done}); + const req = fetch(resource).catch(() => null).then(() => { + sinon.assert.calledWith(done, expectedOrigin); + }); + server.requests[0][method](); + return req; + }); + }); + }); + }); +}); + +describe('toFetchRequest', () => { + Object.entries({ + 'simple POST': { + url: EXAMPLE_URL, + data: 'data', + expect: { + request: { + url: EXAMPLE_URL + '/', + method: 'POST', + }, + text: 'data', + headers: { + 'content-type': 'text/plain' + } + } + }, + 'POST with headers': { + url: EXAMPLE_URL, + data: '{"json": "body"}', + options: { + contentType: 'application/json', + customHeaders: { + 'x-custom': 'value' + } + }, + expect: { + request: { + url: EXAMPLE_URL + '/', + method: 'POST', + }, + text: '{"json": "body"}', + headers: { + 'content-type': 'application/json', + 'X-Custom': 'value' + } + } + }, + 'simple GET': { + url: EXAMPLE_URL, + data: {p1: 'v1', p2: 'v2'}, + options: { + method: 'GET', + }, + expect: { + request: { + url: EXAMPLE_URL + '/?p1=v1&p2=v2', + method: 'GET' + }, + text: '', + headers: { + 'content-type': 'text/plain' + } + } + }, + 'GET with credentials': { + url: EXAMPLE_URL, + data: null, + options: { + method: 'GET', + withCredentials: true, + }, + expect: { + request: { + url: EXAMPLE_URL + '/', + method: 'GET', + credentials: 'include' + }, + text: '', + headers: { + 'content-type': 'text/plain' + } + } + } + }).forEach(([t, {url, data, options, expect: {request, text, headers}}]) => { + it(`can build ${t}`, () => { + const req = toFetchRequest(url, data, options); + return req.text().then(body => { + Object.entries(request).forEach(([prop, val]) => { + expect(req[prop]).to.eql(val); + }); + const hdr = new Headers(headers); + Array.from(req.headers.entries()).forEach(([name, val]) => { + expect(hdr.get(name)).to.eql(val); + }); + expect(body).to.eql(text); + }); + }); + }); + + describe('browsingTopics', () => { + Object.entries({ + 'browsingTopics = true': [{browsingTopics: true}, true], + 'browsingTopics = false': [{browsingTopics: false}, false], + 'browsingTopics is undef': [{}, false] + }).forEach(([t, [opts, shouldBeSet]]) => { + describe(`when options has ${t}`, () => { + const sandbox = sinon.createSandbox(); + afterEach(() => { + sandbox.restore(); + }); + + it(`should ${!shouldBeSet ? 'not ' : ''}be set when in a secure context`, () => { + sandbox.stub(window, 'isSecureContext').get(() => true); + toFetchRequest(EXAMPLE_URL, null, opts); + sinon.assert.calledWithMatch(dep.makeRequest, sinon.match.any, {browsingTopics: shouldBeSet ? true : undefined}); + }); + it(`should not be set when not in a secure context`, () => { + sandbox.stub(window, 'isSecureContext').get(() => false); + toFetchRequest(EXAMPLE_URL, null, opts); + sinon.assert.calledWithMatch(dep.makeRequest, sinon.match.any, {browsingTopics: undefined}); + }); + }) + }) + }) +}); + +describe('attachCallbacks', () => { + const sampleHeaders = new Headers({ + 'x-1': 'v1', + 'x-2': 'v2' + }); + + function responseFactory(body, props) { + props = Object.assign({headers: sampleHeaders, url: EXAMPLE_URL}, props); + return function () { + return { + response: Object.defineProperties(new Response(body, props), { + url: { + get: () => props.url + } + }), + body: body || '' + }; + }; + } + + function expectNullXHR(response) { + return new Promise((resolve, reject) => { + attachCallbacks(Promise.resolve(response), { + success: () => { + reject(new Error('should not succeed')); + }, + error(statusText, xhr) { + expect(statusText).to.eql(''); + sinon.assert.match(xhr, { + readyState: XMLHttpRequest.DONE, + status: 0, + statusText: '', + responseText: '', + response: '', + responseXML: null + }); + expect(xhr.getResponseHeader('any')).to.be.null; + resolve(); + } + }); + }); + } + + it('runs error callback on rejections', () => { + return expectNullXHR(Promise.reject(new Error())); + }); + + Object.entries({ + '2xx response': { + success: true, + makeResponse: responseFactory('body', {status: 200, statusText: 'OK'}) + }, + '2xx response with no body': { + success: true, + makeResponse: responseFactory(null, {status: 204, statusText: 'No content'}) + }, + '2xx response with XML': { + success: true, + xml: true, + makeResponse: responseFactory('', { + status: 200, + statusText: 'OK', + headers: {'content-type': 'application/xml;charset=UTF8'} + }) + }, + '2xx response with HTML': { + success: true, + xml: true, + makeResponse: responseFactory('

', { + status: 200, + statusText: 'OK', + headers: {'content-type': 'text/html;charset=UTF-8'} + }) + }, + '304 response': { + success: true, + makeResponse: responseFactory(null, {status: 304, statusText: 'Moved permanently'}) + }, + '4xx response': { + success: false, + makeResponse: responseFactory('body', {status: 400, statusText: 'Invalid request'}) + }, + '5xx response': { + success: false, + makeResponse: responseFactory('body', {status: 503, statusText: 'Gateway error'}) + }, + '4xx response with XML': { + success: false, + xml: true, + makeResponse: responseFactory('', { + status: 404, + statusText: 'Not found', + headers: { + 'content-type': 'application/xml' + } + }) + } + }).forEach(([t, {success, makeResponse, xml}]) => { + const cbType = success ? 'success' : 'error'; + + describe(`for ${t}`, () => { + let response, body; + beforeEach(() => { + ({response, body} = makeResponse()); + }); + + function checkXHR(xhr) { + sinon.assert.match(xhr, { + readyState: XMLHttpRequest.DONE, + status: response.status, + statusText: response.statusText, + responseType: '', + responseURL: response.url, + response: body, + responseText: body, + }); + if (xml) { + expect(xhr.responseXML.querySelectorAll('*').length > 0).to.be.true; + } else { + expect(xhr.responseXML).to.not.exist; + } + Array.from(response.headers.entries()).forEach(([name, value]) => { + expect(xhr.getResponseHeader(name)).to.eql(value); + }); + expect(xhr.getResponseHeader('$$missing-header')).to.be.null; + } + + it(`runs ${cbType} callback`, (done) => { + attachCallbacks(Promise.resolve(response), { + success(payload, xhr) { + expect(success).to.be.true; + expect(payload).to.eql(body); + checkXHR(xhr); + done(); + }, + error(statusText, xhr) { + expect(success).to.be.false; + expect(statusText).to.eql(response.statusText); + checkXHR(xhr); + done(); + } + }); + }); + + it(`runs error callback if body cannot be retrieved`, () => { + response.text = () => Promise.reject(new Error()); + return expectNullXHR(response); + }); + + if (success) { + it('accepts a single function as success callback', (done) => { + attachCallbacks(Promise.resolve(response), function (payload, xhr) { + expect(payload).to.eql(body); + checkXHR(xhr); + done(); + }) + }) + } + }); + }); + + describe('callback exceptions', () => { + Object.entries({ + success: responseFactory(null, {status: 204}), + error: responseFactory('', {status: 400}), + }).forEach(([cbType, makeResponse]) => { + it(`do not choke ${cbType} callbacks`, () => { + const {response} = makeResponse(); + return new Promise((resolve) => { + const result = {success: false, error: false}; + attachCallbacks(Promise.resolve(response), { + success() { + result.success = true; + throw new Error(); + }, + error() { + result.error = true; + throw new Error(); + } + }); + setTimeout(() => resolve(result), 20); + }).then(result => { + Object.entries(result).forEach(([typ, ran]) => { + expect(ran).to.be[typ === cbType ? 'true' : 'false'] + }) + }); + }); + }); + }); +}); diff --git a/test/spec/unit/core/bidderFactory_spec.js b/test/spec/unit/core/bidderFactory_spec.js index 067f9abe424..4c13d830206 100644 --- a/test/spec/unit/core/bidderFactory_spec.js +++ b/test/spec/unit/core/bidderFactory_spec.js @@ -1,16 +1,20 @@ -import { newBidder, registerBidder, preloadBidderMappingFile, storage } from 'src/adapters/bidderFactory.js'; +import {addComponentAuction, isValid, newBidder, registerBidder} from 'src/adapters/bidderFactory.js'; import adapterManager from 'src/adapterManager.js'; import * as ajax from 'src/ajax.js'; -import { expect } from 'chai'; -import { userSync } from 'src/userSync.js' +import {expect} from 'chai'; +import {userSync} from 'src/userSync.js'; import * as utils from 'src/utils.js'; -import { config } from 'src/config.js'; -import { server } from 'test/mocks/xhr.js'; +import {config} from 'src/config.js'; import CONSTANTS from 'src/constants.json'; import * as events from 'src/events.js'; import {hook} from '../../../../src/hook.js'; import {auctionManager} from '../../../../src/auctionManager.js'; import {stubAuctionIndex} from '../../../helpers/indexStub.js'; +import {bidderSettings} from '../../../../src/bidderSettings.js'; +import {decorateAdUnitsWithNativeParams} from '../../../../src/native.js'; +import * as activityRules from 'src/activities/rules.js'; +import {MODULE_TYPE_BIDDER} from '../../../../src/activities/modules.js'; +import {ACTIVITY_TRANSMIT_TID, ACTIVITY_TRANSMIT_UFPD} from '../../../../src/activities/activities.js'; const CODE = 'sampleBidder'; const MOCK_BIDS_REQUEST = { @@ -38,607 +42,988 @@ function onTimelyResponseStub() { } -let wrappedCallback = config.callbackWithBidder(CODE); - -describe('bidders created by newBidder', function () { - let spec; - let bidder; - let addBidResponseStub; - let doneStub; - - before(() => { - hook.ready(); - }); +before(() => { + hook.ready(); +}); - beforeEach(function () { - spec = { - code: CODE, - isBidRequestValid: sinon.stub(), - buildRequests: sinon.stub(), - interpretResponse: sinon.stub(), - getUserSyncs: sinon.stub() - }; - - addBidResponseStub = sinon.stub(); - doneStub = sinon.stub(); - }); +let wrappedCallback = config.callbackWithBidder(CODE); - describe('when the ajax response is irrelevant', function () { - let ajaxStub; - let getConfigSpy; - let aliasRegistryStub, aliasRegistry; +describe('bidderFactory', () => { + describe('bidders created by newBidder', function () { + let spec; + let bidder; + let addBidResponseStub; + let doneStub; beforeEach(function () { - ajaxStub = sinon.stub(ajax, 'ajax'); - addBidResponseStub.reset(); - getConfigSpy = sinon.spy(config, 'getConfig'); - doneStub.reset(); - aliasRegistry = {}; - aliasRegistryStub = sinon.stub(adapterManager, 'aliasRegistry'); - aliasRegistryStub.get(() => aliasRegistry); - }); + spec = { + code: CODE, + isBidRequestValid: sinon.stub(), + buildRequests: sinon.stub(), + interpretResponse: sinon.stub(), + getUserSyncs: sinon.stub() + }; - afterEach(function () { - ajaxStub.restore(); - getConfigSpy.restore(); - aliasRegistryStub.restore(); + addBidResponseStub = sinon.stub(); + addBidResponseStub.reject = sinon.stub(); + doneStub = sinon.stub(); }); - it('should let registerSyncs run with invalid alias and aliasSync enabled', function () { - config.setConfig({ - userSync: { - aliasSyncEnabled: true - } + describe('when the ajax response is irrelevant', function () { + let sandbox; + let ajaxStub; + let getConfigSpy; + let aliasRegistryStub, aliasRegistry; + + beforeEach(function () { + sandbox = sinon.sandbox.create(); + sandbox.stub(activityRules, 'isActivityAllowed').callsFake(() => true); + ajaxStub = sandbox.stub(ajax, 'ajax'); + addBidResponseStub.reset(); + getConfigSpy = sandbox.spy(config, 'getConfig'); + doneStub.reset(); + aliasRegistry = {}; + aliasRegistryStub = sandbox.stub(adapterManager, 'aliasRegistry'); + aliasRegistryStub.get(() => aliasRegistry); }); - spec.code = 'fakeBidder'; - const bidder = newBidder(spec); - bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); - }); - it('should let registerSyncs run with valid alias and aliasSync enabled', function () { - config.setConfig({ - userSync: { - aliasSyncEnabled: true - } + afterEach(function () { + sandbox.restore(); }); - spec.code = 'aliasBidder'; - const bidder = newBidder(spec); - bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); - }); - it('should let registerSyncs run with invalid alias and aliasSync disabled', function () { - config.setConfig({ - userSync: { - aliasSyncEnabled: false - } + it('should let registerSyncs run with invalid alias and aliasSync enabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: true + } + }); + spec.code = 'fakeBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); }); - spec.code = 'fakeBidder'; - const bidder = newBidder(spec); - bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); - }); - it('should not let registerSyncs run with valid alias and aliasSync disabled', function () { - config.setConfig({ - userSync: { - aliasSyncEnabled: false - } + it('should let registerSyncs run with valid alias and aliasSync enabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: true + } + }); + spec.code = 'aliasBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); }); - spec.code = 'aliasBidder'; - const bidder = newBidder(spec); - aliasRegistry = {[spec.code]: CODE}; - bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(false); - }); - it('should handle bad bid requests gracefully', function () { - const bidder = newBidder(spec); + it('should let registerSyncs run with invalid alias and aliasSync disabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: false + } + }); + spec.code = 'fakeBidder'; + const bidder = newBidder(spec); + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(true); + }); - spec.getUserSyncs.returns([]); + it('should not let registerSyncs run with valid alias and aliasSync disabled', function () { + config.setConfig({ + userSync: { + aliasSyncEnabled: false + } + }); + spec.code = 'aliasBidder'; + const bidder = newBidder(spec); + aliasRegistry = {[spec.code]: CODE}; + bidder.callBids({ bids: [] }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(getConfigSpy.withArgs('userSync.filterSettings').calledOnce).to.equal(false); + }); - bidder.callBids({}); - bidder.callBids({ bids: 'nothing useful' }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + describe('transaction IDs', () => { + beforeEach(() => { + activityRules.isActivityAllowed.reset(); + ajaxStub.callsFake((_, callback) => callback.success(null, {getResponseHeader: sinon.stub()})); + spec.interpretResponse.callsFake(() => [ + { + requestId: 'bid', + cpm: 123, + ttl: 300, + creativeId: 'crid', + netRevenue: true, + currency: 'USD' + } + ]) + }); - expect(ajaxStub.called).to.equal(false); - expect(spec.isBidRequestValid.called).to.equal(false); - expect(spec.buildRequests.called).to.equal(false); - expect(spec.interpretResponse.called).to.equal(false); - }); + Object.entries({ + 'be hidden': false, + 'not be hidden': true, + }).forEach(([t, allowed]) => { + const expectation = allowed ? (val) => expect(val).to.exist : (val) => expect(val).to.not.exist; - it('should call buildRequests(bidRequest) the params are valid', function () { - const bidder = newBidder(spec); + function checkBidRequest(br) { + ['auctionId', 'transactionId'].forEach((prop) => expectation(br[prop])); + } - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns([]); + function checkBidderRequest(br) { + expectation(br.auctionId); + br.bids.forEach(checkBidRequest); + } - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it(`should ${t} from the spec logic when the transmitTid activity is${allowed ? '' : ' not'} allowed`, () => { + spec.isBidRequestValid.callsFake(br => { + checkBidRequest(br); + return true; + }); + spec.buildRequests.callsFake((bidReqs, bidderReq) => { + checkBidderRequest(bidderReq); + bidReqs.forEach(checkBidRequest); + return {method: 'POST'}; + }); + activityRules.isActivityAllowed.callsFake(() => allowed); + + const bidder = newBidder(spec); + + bidder.callBids({ + bidderCode: 'mockBidder', + auctionId: 'aid', + bids: [ + { + adUnitCode: 'mockAU', + bidId: 'bid', + transactionId: 'tid', + auctionId: 'aid' + } + ] + }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + sinon.assert.calledWithMatch(activityRules.isActivityAllowed, ACTIVITY_TRANSMIT_TID, { + componentType: MODULE_TYPE_BIDDER, + componentName: 'mockBidder' + }); + sinon.assert.calledWithMatch(addBidResponseStub, sinon.match.any, { + transactionId: 'tid', + auctionId: 'aid' + }) + }); + }); + + it('should not be hidden from request methods', (done) => { + const bidderRequest = { + bidderCode: 'mockBidder', + auctionId: 'aid', + getAID() { return this.auctionId }, + bids: [ + { + adUnitCode: 'mockAU', + bidId: 'bid', + transactionId: 'tid', + auctionId: 'aid', + getTIDs() { + return [this.auctionId, this.transactionId] + } + } + ] + }; + activityRules.isActivityAllowed.callsFake(() => false); + spec.isBidRequestValid.returns(true); + spec.buildRequests.callsFake((reqs, bidderReq) => { + expect(bidderReq.getAID()).to.eql('aid'); + expect(reqs[0].getTIDs()).to.eql(['aid', 'tid']); + done(); + }); + newBidder(spec).callBids(bidderRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + }) + }); - expect(ajaxStub.called).to.equal(false); - expect(spec.isBidRequestValid.calledTwice).to.equal(true); - expect(spec.buildRequests.calledOnce).to.equal(true); - expect(spec.buildRequests.firstCall.args[0]).to.deep.equal(MOCK_BIDS_REQUEST.bids); - }); + it('should handle bad bid requests gracefully', function () { + const bidder = newBidder(spec); - it('should not call buildRequests the params are invalid', function () { - const bidder = newBidder(spec); + spec.getUserSyncs.returns([]); - spec.isBidRequestValid.returns(false); - spec.buildRequests.returns([]); + bidder.callBids({}); + bidder.callBids({ bids: 'nothing useful' }, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(ajaxStub.called).to.equal(false); + expect(spec.isBidRequestValid.called).to.equal(false); + expect(spec.buildRequests.called).to.equal(false); + expect(spec.interpretResponse.called).to.equal(false); + }); - expect(ajaxStub.called).to.equal(false); - expect(spec.isBidRequestValid.calledTwice).to.equal(true); - expect(spec.buildRequests.called).to.equal(false); - }); + it('should call buildRequests(bidRequest) the params are valid', function () { + const bidder = newBidder(spec); - it('should filter out invalid bids before calling buildRequests', function () { - const bidder = newBidder(spec); + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns([]); - spec.isBidRequestValid.onFirstCall().returns(true); - spec.isBidRequestValid.onSecondCall().returns(false); - spec.buildRequests.returns([]); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(ajaxStub.called).to.equal(false); + expect(spec.isBidRequestValid.calledTwice).to.equal(true); + expect(spec.buildRequests.calledOnce).to.equal(true); + expect(spec.buildRequests.firstCall.args[0]).to.deep.equal(MOCK_BIDS_REQUEST.bids); + }); - expect(ajaxStub.called).to.equal(false); - expect(spec.isBidRequestValid.calledTwice).to.equal(true); - expect(spec.buildRequests.calledOnce).to.equal(true); - expect(spec.buildRequests.firstCall.args[0]).to.deep.equal([MOCK_BIDS_REQUEST.bids[0]]); - }); + it('should not call buildRequests the params are invalid', function () { + const bidder = newBidder(spec); - it('should make no server requests if the spec doesn\'t return any', function () { - const bidder = newBidder(spec); + spec.isBidRequestValid.returns(false); + spec.buildRequests.returns([]); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns([]); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(ajaxStub.called).to.equal(false); + expect(spec.isBidRequestValid.calledTwice).to.equal(true); + expect(spec.buildRequests.called).to.equal(false); + }); - expect(ajaxStub.called).to.equal(false); - }); + it('should filter out invalid bids before calling buildRequests', function () { + const bidder = newBidder(spec); - it('should make the appropriate POST request', function () { - const bidder = newBidder(spec); - const url = 'test.url.com'; - const data = { arg: 2 }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: url, - data: data - }); + spec.isBidRequestValid.onFirstCall().returns(true); + spec.isBidRequestValid.onSecondCall().returns(false); + spec.buildRequests.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(url); - expect(ajaxStub.firstCall.args[2]).to.equal(JSON.stringify(data)); - expect(ajaxStub.firstCall.args[3]).to.deep.equal({ - method: 'POST', - contentType: 'text/plain', - withCredentials: true + expect(ajaxStub.called).to.equal(false); + expect(spec.isBidRequestValid.calledTwice).to.equal(true); + expect(spec.buildRequests.calledOnce).to.equal(true); + expect(spec.buildRequests.firstCall.args[0]).to.deep.equal([MOCK_BIDS_REQUEST.bids[0]]); }); - }); - it('should make the appropriate POST request when options are passed', function () { - const bidder = newBidder(spec); - const url = 'test.url.com'; - const data = { arg: 2 }; - const options = { contentType: 'application/json' }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: url, - data: data, - options: options - }); + it('should make no server requests if the spec doesn\'t return any', function () { + const bidder = newBidder(spec); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns([]); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(url); - expect(ajaxStub.firstCall.args[2]).to.equal(JSON.stringify(data)); - expect(ajaxStub.firstCall.args[3]).to.deep.equal({ - method: 'POST', - contentType: 'application/json', - withCredentials: true - }); - }); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - it('should make the appropriate GET request', function () { - const bidder = newBidder(spec); - const url = 'test.url.com'; - const data = { arg: 2 }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'GET', - url: url, - data: data + expect(ajaxStub.called).to.equal(false); }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should make the appropriate POST request', function () { + const bidder = newBidder(spec); + const url = 'test.url.com'; + const data = { arg: 2 }; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: url, + data: data + }); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); - expect(ajaxStub.firstCall.args[2]).to.be.undefined; - expect(ajaxStub.firstCall.args[3]).to.deep.equal({ - method: 'GET', - withCredentials: true - }); - }); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - it('should make the appropriate GET request when options are passed', function () { - const bidder = newBidder(spec); - const url = 'test.url.com'; - const data = { arg: 2 }; - const opt = { withCredentials: false } - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'GET', - url: url, - data: data, - options: opt + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0]).to.equal(url); + expect(ajaxStub.firstCall.args[2]).to.equal(JSON.stringify(data)); + sinon.assert.match(ajaxStub.firstCall.args[3], { + method: 'POST', + contentType: 'text/plain', + withCredentials: true + }); }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should make the appropriate POST request when options are passed', function () { + const bidder = newBidder(spec); + const url = 'test.url.com'; + const data = { arg: 2 }; + const options = { contentType: 'application/json' }; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: url, + data: data, + options: options + }); - expect(ajaxStub.calledOnce).to.equal(true); - expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); - expect(ajaxStub.firstCall.args[2]).to.be.undefined; - expect(ajaxStub.firstCall.args[3]).to.deep.equal({ - method: 'GET', - withCredentials: false - }); - }); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - it('should make multiple calls if the spec returns them', function () { - const bidder = newBidder(spec); - const url = 'test.url.com'; - const data = { arg: 2 }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns([ - { + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0]).to.equal(url); + expect(ajaxStub.firstCall.args[2]).to.equal(JSON.stringify(data)); + sinon.assert.match(ajaxStub.firstCall.args[3], { method: 'POST', - url: url, - data: data - }, - { + contentType: 'application/json', + withCredentials: true + }) + }); + + it('should make the appropriate GET request', function () { + const bidder = newBidder(spec); + const url = 'test.url.com'; + const data = { arg: 2 }; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ method: 'GET', url: url, data: data - } - ]); + }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(ajaxStub.calledTwice).to.equal(true); - }); + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); + expect(ajaxStub.firstCall.args[2]).to.be.undefined; + sinon.assert.match(ajaxStub.firstCall.args[3], { + method: 'GET', + withCredentials: true + }) + }); - it('should not add bids for each placement code if no requests are given', function () { - const bidder = newBidder(spec); + it('should make the appropriate GET request when options are passed', function () { + const bidder = newBidder(spec); + const url = 'test.url.com'; + const data = { arg: 2 }; + const opt = { withCredentials: false } + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'GET', + url: url, + data: data, + options: opt + }); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns([]); - spec.interpretResponse.returns([]); - spec.getUserSyncs.returns([]); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0]).to.equal(`${url}?arg=2`); + expect(ajaxStub.firstCall.args[2]).to.be.undefined; + sinon.assert.match(ajaxStub.firstCall.args[3], { + method: 'GET', + withCredentials: false + }) + }); - expect(addBidResponseStub.callCount).to.equal(0); - }); + it('should make multiple calls if the spec returns them', function () { + const bidder = newBidder(spec); + const url = 'test.url.com'; + const data = { arg: 2 }; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns([ + { + method: 'POST', + url: url, + data: data + }, + { + method: 'GET', + url: url, + data: data + } + ]); - it('should emit BEFORE_BIDDER_HTTP events before network requests', function () { - const bidder = newBidder(spec); - const req = { - method: 'POST', - url: 'test.url.com', - data: { arg: 2 } - }; + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns([req, req]); + expect(ajaxStub.calledTwice).to.equal(true); + }); - const eventEmitterSpy = sinon.spy(events, 'emit'); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + describe('browsingTopics ajax option', () => { + let transmitUfpdAllowed, bidder; + beforeEach(() => { + activityRules.isActivityAllowed.reset(); + activityRules.isActivityAllowed.callsFake((activity) => activity === ACTIVITY_TRANSMIT_UFPD ? transmitUfpdAllowed : true); + bidder = newBidder(spec); + spec.isBidRequestValid.returns(true); + }); + + it(`should be set to false when adapter sets browsingTopics = false`, () => { + transmitUfpdAllowed = true; + spec.buildRequests.returns([ + { + method: 'GET', + url: 'url', + options: { + browsingTopics: false + } + } + ]); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + sinon.assert.calledWith(ajaxStub, 'url', sinon.match.any, sinon.match.any, sinon.match({ + browsingTopics: false + })); + }); + + Object.entries({ + 'allowed': true, + 'not allowed': false + }).forEach(([t, allow]) => { + it(`should be set to ${allow} when transmitUfpd is ${t}`, () => { + transmitUfpdAllowed = allow; + spec.buildRequests.returns([ + { + method: 'GET', + url: '1', + }, + { + method: 'POST', + url: '2', + data: {} + }, + { + method: 'GET', + url: '3', + options: { + browsingTopics: true + } + }, + { + method: 'POST', + url: '4', + data: {}, + options: { + browsingTopics: true + } + } + ]); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + ['1', '2', '3', '4'].forEach(url => { + sinon.assert.calledWith( + ajaxStub, + url, + sinon.match.any, + sinon.match.any, + sinon.match({browsingTopics: allow}) + ); + }); + }); + }); + }); - expect(ajaxStub.calledTwice).to.equal(true); - expect(eventEmitterSpy.getCalls() - .filter(call => call.args[0] === CONSTANTS.EVENTS.BEFORE_BIDDER_HTTP) - ).to.length(2); + it('should not add bids for each placement code if no requests are given', function () { + const bidder = newBidder(spec); - eventEmitterSpy.restore(); - }); - }); + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns([]); + spec.interpretResponse.returns([]); + spec.getUserSyncs.returns([]); - describe('when the ajax call succeeds', function () { - let ajaxStub; - let userSyncStub; - let logErrorSpy; + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - beforeEach(function () { - ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) { - const fakeResponse = sinon.stub(); - fakeResponse.returns('headerContent'); - callbacks.success('response body', { getResponseHeader: fakeResponse }); + expect(addBidResponseStub.callCount).to.equal(0); }); - addBidResponseStub.reset(); - doneStub.resetBehavior(); - userSyncStub = sinon.stub(userSync, 'registerSync') - logErrorSpy = sinon.spy(utils, 'logError'); - }); - afterEach(function () { - ajaxStub.restore(); - userSyncStub.restore(); - utils.logError.restore(); - }); + it('should emit BEFORE_BIDDER_HTTP events before network requests', function () { + const bidder = newBidder(spec); + const req = { + method: 'POST', + url: 'test.url.com', + data: { arg: 2 } + }; - it('should call spec.interpretResponse() with the response content', function () { - const bidder = newBidder(spec); + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns([req, req]); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} - }); - spec.getUserSyncs.returns([]); + const eventEmitterSpy = sinon.spy(events, 'emit'); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(ajaxStub.calledTwice).to.equal(true); + expect(eventEmitterSpy.getCalls() + .filter(call => call.args[0] === CONSTANTS.EVENTS.BEFORE_BIDDER_HTTP) + ).to.length(2); - expect(spec.interpretResponse.calledOnce).to.equal(true); - const response = spec.interpretResponse.firstCall.args[0] - expect(response.body).to.equal('response body') - expect(response.headers.get('some-header')).to.equal('headerContent'); - expect(spec.interpretResponse.firstCall.args[1]).to.deep.equal({ - method: 'POST', - url: 'test.url.com', - data: {} + eventEmitterSpy.restore(); }); - expect(doneStub.calledOnce).to.equal(true); }); - it('should call spec.interpretResponse() once for each request made', function () { - const bidder = newBidder(spec); + describe('when the ajax call succeeds', function () { + let ajaxStub; + let userSyncStub; + let logErrorSpy; + + beforeEach(function () { + ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) { + const fakeResponse = sinon.stub(); + fakeResponse.returns('headerContent'); + callbacks.success('response body', { getResponseHeader: fakeResponse }); + }); + addBidResponseStub.reset(); + doneStub.resetBehavior(); + userSyncStub = sinon.stub(userSync, 'registerSync') + logErrorSpy = sinon.spy(utils, 'logError'); + }); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns([ - { + afterEach(function () { + ajaxStub.restore(); + userSyncStub.restore(); + utils.logError.restore(); + }); + + it('should call spec.interpretResponse() with the response content', function () { + const bidder = newBidder(spec); + + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ method: 'POST', url: 'test.url.com', data: {} - }, - { + }); + spec.getUserSyncs.returns([]); + + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(spec.interpretResponse.calledOnce).to.equal(true); + const response = spec.interpretResponse.firstCall.args[0] + expect(response.body).to.equal('response body') + expect(response.headers.get('some-header')).to.equal('headerContent'); + expect(spec.interpretResponse.firstCall.args[1]).to.deep.equal({ method: 'POST', url: 'test.url.com', data: {} - }, - ]); - spec.getUserSyncs.returns([]); + }); + expect(doneStub.calledOnce).to.equal(true); + }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should call spec.interpretResponse() once for each request made', function () { + const bidder = newBidder(spec); + + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns([ + { + method: 'POST', + url: 'test.url.com', + data: {} + }, + { + method: 'POST', + url: 'test.url.com', + data: {} + }, + ]); + spec.getUserSyncs.returns([]); + + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(spec.interpretResponse.calledTwice).to.equal(true); + expect(doneStub.calledOnce).to.equal(true); + }); - expect(spec.interpretResponse.calledTwice).to.equal(true); - expect(doneStub.calledOnce).to.equal(true); - }); + it('should only add bids for valid adUnit code into the auction, even if the bidder doesn\'t bid on all of them', function () { + const bidder = newBidder(spec); + + const bid = { + creativeId: 'creative-id', + requestId: '1', + ad: 'ad-url.com', + cpm: 0.5, + height: 200, + width: 300, + adUnitCode: 'mock/placement', + currency: 'USD', + netRevenue: true, + ttl: 300, + bidderCode: 'sampleBidder', + sampleBidder: {advertiserId: '12345', networkId: '111222'} + }; + const bidderRequest = Object.assign({}, MOCK_BIDS_REQUEST); + bidderRequest.bids[0].bidder = 'sampleBidder'; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); + + spec.interpretResponse.returns(bid); + + bidder.callBids(bidderRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + let bidObject = addBidResponseStub.firstCall.args[1]; + // checking the fields added by our code + expect(bidObject.originalCpm).to.equal(bid.cpm); + expect(bidObject.originalCurrency).to.equal(bid.currency); + expect(doneStub.calledOnce).to.equal(true); + expect(logErrorSpy.callCount).to.equal(0); + expect(bidObject.meta).to.exist; + expect(bidObject.meta).to.deep.equal({advertiserId: '12345', networkId: '111222'}); + }); - it('should only add bids for valid adUnit code into the auction, even if the bidder doesn\'t bid on all of them', function () { - const bidder = newBidder(spec); + it('should call spec.getUserSyncs() with the response', function () { + const bidder = newBidder(spec); - const bid = { - creativeId: 'creative-id', - requestId: '1', - ad: 'ad-url.com', - cpm: 0.5, - height: 200, - width: 300, - adUnitCode: 'mock/placement', - currency: 'USD', - netRevenue: true, - ttl: 300, - bidderCode: 'sampleBidder', - sampleBidder: {advertiserId: '12345', networkId: '111222'} - }; - const bidderRequest = Object.assign({}, MOCK_BIDS_REQUEST); - bidderRequest.bids[0].bidder = 'sampleBidder'; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} - }); - spec.getUserSyncs.returns([]); + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); - spec.interpretResponse.returns(bid); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - bidder.callBids(bidderRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(spec.getUserSyncs.calledOnce).to.equal(true); + expect(spec.getUserSyncs.firstCall.args[1].length).to.equal(1); + expect(spec.getUserSyncs.firstCall.args[1][0].body).to.equal('response body'); + expect(spec.getUserSyncs.firstCall.args[1][0].headers).to.have.property('get'); + expect(spec.getUserSyncs.firstCall.args[1][0].headers.get).to.be.a('function'); + }); - expect(addBidResponseStub.calledOnce).to.equal(true); - expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); - let bidObject = addBidResponseStub.firstCall.args[1]; - // checking the fields added by our code - expect(bidObject.originalCpm).to.equal(bid.cpm); - expect(bidObject.originalCurrency).to.equal(bid.currency); - expect(doneStub.calledOnce).to.equal(true); - expect(logErrorSpy.callCount).to.equal(0); - expect(bidObject.meta).to.exist; - expect(bidObject.meta).to.deep.equal({advertiserId: '12345', networkId: '111222'}); - }); + it('should register usersync pixels', function () { + const bidder = newBidder(spec); - it('should call spec.getUserSyncs() with the response', function () { - const bidder = newBidder(spec); + spec.isBidRequestValid.returns(false); + spec.buildRequests.returns([]); + spec.getUserSyncs.returns([{ + type: 'iframe', + url: 'usersync.com' + }]); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(userSyncStub.called).to.equal(true); + expect(userSyncStub.firstCall.args[0]).to.equal('iframe'); + expect(userSyncStub.firstCall.args[1]).to.equal(spec.code); + expect(userSyncStub.firstCall.args[2]).to.equal('usersync.com'); }); - spec.getUserSyncs.returns([]); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should logError and reject bid when required bid response params are missing', function () { + const bidder = newBidder(spec); + + const bid = { + requestId: '1', + ad: 'ad-url.com', + cpm: 0.5, + height: 200, + width: 300, + placementCode: 'mock/placement' + }; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); - expect(spec.getUserSyncs.calledOnce).to.equal(true); - expect(spec.getUserSyncs.firstCall.args[1].length).to.equal(1); - expect(spec.getUserSyncs.firstCall.args[1][0].body).to.equal('response body'); - expect(spec.getUserSyncs.firstCall.args[1][0].headers).to.have.property('get'); - expect(spec.getUserSyncs.firstCall.args[1][0].headers.get).to.be.a('function'); - }); + spec.interpretResponse.returns(bid); - it('should register usersync pixels', function () { - const bidder = newBidder(spec); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - spec.isBidRequestValid.returns(false); - spec.buildRequests.returns([]); - spec.getUserSyncs.returns([{ - type: 'iframe', - url: 'usersync.com' - }]); + expect(logErrorSpy.calledOnce).to.equal(true); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should logError and reject bid when required response params are undefined', function () { + const bidder = newBidder(spec); + + const bid = { + 'ad': 'creative', + 'cpm': '1.99', + 'width': 300, + 'height': 250, + 'requestId': '1', + 'creativeId': 'some-id', + 'currency': undefined, + 'netRevenue': true, + 'ttl': 360 + }; + + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); - expect(userSyncStub.called).to.equal(true); - expect(userSyncStub.firstCall.args[0]).to.equal('iframe'); - expect(userSyncStub.firstCall.args[1]).to.equal(spec.code); - expect(userSyncStub.firstCall.args[2]).to.equal('usersync.com'); - }); + spec.interpretResponse.returns(bid); - it('should logError when required bid response params are missing', function () { - const bidder = newBidder(spec); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - const bid = { - requestId: '1', - ad: 'ad-url.com', - cpm: 0.5, - height: 200, - width: 300, - placementCode: 'mock/placement' - }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} + expect(logErrorSpy.calledOnce).to.equal(true); + expect(addBidResponseStub.reject.calledOnce).to.be.true; }); - spec.getUserSyncs.returns([]); - spec.interpretResponse.returns(bid); + it('should require requestId from interpretResponse', () => { + const bidder = newBidder(spec); + const bid = { + 'ad': 'creative', + 'cpm': '1.99', + 'creativeId': 'some-id', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 360 + }; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); + spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(logErrorSpy.calledOnce).to.equal(true); + expect(addBidResponseStub.called).to.be.false; + expect(addBidResponseStub.reject.calledOnce).to.be.true; + }); }); - it('should logError when required bid response params are undefined', function () { - const bidder = newBidder(spec); - - const bid = { - 'ad': 'creative', - 'cpm': '1.99', - 'width': 300, - 'height': 250, - 'requestId': '1', - 'creativeId': 'some-id', - 'currency': undefined, - 'netRevenue': true, - 'ttl': 360 + describe('when the ajax call fails', function () { + let ajaxStub; + let callBidderErrorStub; + let eventEmitterStub; + let xhrErrorMock = { + status: 500, + statusText: 'Internal Server Error' }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} + beforeEach(function () { + ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) { + callbacks.error('ajax call failed.', xhrErrorMock); + }); + callBidderErrorStub = sinon.stub(adapterManager, 'callBidderError'); + eventEmitterStub = sinon.stub(events, 'emit'); + addBidResponseStub.reset(); + doneStub.reset(); }); - spec.getUserSyncs.returns([]); - spec.interpretResponse.returns(bid); + afterEach(function () { + ajaxStub.restore(); + callBidderErrorStub.restore(); + eventEmitterStub.restore(); + }); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should not spec.interpretResponse()', function () { + const bidder = newBidder(spec); - expect(logErrorSpy.calledOnce).to.equal(true); - }); + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); + + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(spec.interpretResponse.called).to.equal(false); + expect(doneStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); + expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); + expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); + sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { + error: xhrErrorMock, + bidderRequest: MOCK_BIDS_REQUEST + }); + }); - it('should require requestId from interpretResponse', () => { - const bidder = newBidder(spec); - const bid = { - 'ad': 'creative', - 'cpm': '1.99', - 'creativeId': 'some-id', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360 - }; - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} + it('should not add bids for each adunit code into the auction', function () { + const bidder = newBidder(spec); + + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.interpretResponse.returns([]); + spec.getUserSyncs.returns([]); + + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(addBidResponseStub.callCount).to.equal(0); + expect(doneStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); + expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); + expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); + sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { + error: xhrErrorMock, + bidderRequest: MOCK_BIDS_REQUEST + }); + }); + + it('should call spec.getUserSyncs() with no responses', function () { + const bidder = newBidder(spec); + + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); + + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(spec.getUserSyncs.calledOnce).to.equal(true); + expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]); + expect(doneStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); + expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); + expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); + sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { + error: xhrErrorMock, + bidderRequest: MOCK_BIDS_REQUEST + }); }); - spec.getUserSyncs.returns([]); - spec.interpretResponse.returns(bid); - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should call spec.getUserSyncs() with no responses', function () { + const bidder = newBidder(spec); - expect(addBidResponseStub.called).to.be.false; + spec.isBidRequestValid.returns(true); + spec.buildRequests.returns({ + method: 'POST', + url: 'test.url.com', + data: {} + }); + spec.getUserSyncs.returns([]); + + bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(spec.getUserSyncs.calledOnce).to.equal(true); + expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]); + expect(doneStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.calledOnce).to.equal(true); + expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); + expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); + expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); + sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { + error: xhrErrorMock, + bidderRequest: MOCK_BIDS_REQUEST + }); + }); }); }); - describe('when the ajax call fails', function () { - let ajaxStub; - let callBidderErrorStub; - let eventEmitterStub; - let xhrErrorMock = { - status: 500, - statusText: 'Internal Server Error' - }; + describe('registerBidder', function () { + let registerBidAdapterStub; + let aliasBidAdapterStub; beforeEach(function () { - ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) { - callbacks.error('ajax call failed.', xhrErrorMock); - }); - callBidderErrorStub = sinon.stub(adapterManager, 'callBidderError'); - eventEmitterStub = sinon.stub(events, 'emit'); - addBidResponseStub.reset(); - doneStub.reset(); + registerBidAdapterStub = sinon.stub(adapterManager, 'registerBidAdapter'); + aliasBidAdapterStub = sinon.stub(adapterManager, 'aliasBidAdapter'); }); afterEach(function () { - ajaxStub.restore(); - callBidderErrorStub.restore(); - eventEmitterStub.restore(); + registerBidAdapterStub.restore(); + aliasBidAdapterStub.restore(); }); - it('should not spec.interpretResponse()', function () { - const bidder = newBidder(spec); + function newEmptySpec() { + return { + code: CODE, + isBidRequestValid: function() { }, + buildRequests: function() { }, + interpretResponse: function() { }, + }; + } - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} - }); - spec.getUserSyncs.returns([]); - - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - - expect(spec.interpretResponse.called).to.equal(false); - expect(doneStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); - expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); - expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); - sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { - error: xhrErrorMock, - bidderRequest: MOCK_BIDS_REQUEST - }); + it('should register a bidder with the adapterManager', function () { + registerBidder(newEmptySpec()); + expect(registerBidAdapterStub.calledOnce).to.equal(true); + expect(registerBidAdapterStub.firstCall.args[0]).to.have.property('callBids'); + expect(registerBidAdapterStub.firstCall.args[0].callBids).to.be.a('function'); + + expect(registerBidAdapterStub.firstCall.args[1]).to.equal(CODE); + expect(registerBidAdapterStub.firstCall.args[2]).to.be.undefined; }); - it('should not add bids for each adunit code into the auction', function () { - const bidder = newBidder(spec); + it('should register a bidder with the appropriate mediaTypes', function () { + const thisSpec = Object.assign(newEmptySpec(), { supportedMediaTypes: ['video'] }); + registerBidder(thisSpec); + expect(registerBidAdapterStub.calledOnce).to.equal(true); + expect(registerBidAdapterStub.firstCall.args[2]).to.deep.equal({supportedMediaTypes: ['video']}); + }); + + it('should register bidders with the appropriate aliases', function () { + const thisSpec = Object.assign(newEmptySpec(), { aliases: ['foo', 'bar'] }); + registerBidder(thisSpec); + + expect(registerBidAdapterStub.calledThrice).to.equal(true); + + // Make sure our later calls don't override the bidder code from previous calls. + expect(registerBidAdapterStub.firstCall.args[0].getBidderCode()).to.equal(CODE); + expect(registerBidAdapterStub.secondCall.args[0].getBidderCode()).to.equal('foo') + expect(registerBidAdapterStub.thirdCall.args[0].getBidderCode()).to.equal('bar') + + expect(registerBidAdapterStub.firstCall.args[1]).to.equal(CODE); + expect(registerBidAdapterStub.secondCall.args[1]).to.equal('foo') + expect(registerBidAdapterStub.thirdCall.args[1]).to.equal('bar') + }); + + it('should register alias with their gvlid', function() { + const aliases = [ + { + code: 'foo', + gvlid: 1 + }, + { + code: 'bar', + gvlid: 2 + }, + { + code: 'baz' + } + ] + const thisSpec = Object.assign(newEmptySpec(), { aliases: aliases }); + registerBidder(thisSpec); + + expect(registerBidAdapterStub.getCall(1).args[0].getSpec().gvlid).to.equal(1); + expect(registerBidAdapterStub.getCall(2).args[0].getSpec().gvlid).to.equal(2); + expect(registerBidAdapterStub.getCall(3).args[0].getSpec().gvlid).to.equal(undefined); + }) + + it('should register alias with skipPbsAliasing', function() { + const aliases = [ + { + code: 'foo', + skipPbsAliasing: true + }, + { + code: 'bar', + skipPbsAliasing: false + }, + { + code: 'baz' + } + ] + const thisSpec = Object.assign(newEmptySpec(), { aliases: aliases }); + registerBidder(thisSpec); + + expect(registerBidAdapterStub.getCall(1).args[0].getSpec().skipPbsAliasing).to.equal(true); + expect(registerBidAdapterStub.getCall(2).args[0].getSpec().skipPbsAliasing).to.equal(false); + expect(registerBidAdapterStub.getCall(3).args[0].getSpec().skipPbsAliasing).to.equal(undefined); + }) + }) + + describe('validate bid response: ', function () { + let spec; + let indexStub, adUnits, bidderRequests; + let addBidResponseStub; + let doneStub; + let ajaxStub; + let logErrorSpy; + + let bids = [{ + 'ad': 'creative', + 'cpm': '1.99', + 'width': 300, + 'height': 250, + 'requestId': '1', + 'creativeId': 'some-id', + 'currency': 'USD', + 'netRevenue': true, + 'ttl': 360 + }]; + + beforeEach(function () { + spec = { + code: CODE, + isBidRequestValid: sinon.stub(), + buildRequests: sinon.stub(), + interpretResponse: sinon.stub(), + }; spec.isBidRequestValid.returns(true); spec.buildRequests.returns({ @@ -646,513 +1031,480 @@ describe('bidders created by newBidder', function () { url: 'test.url.com', data: {} }); - spec.interpretResponse.returns([]); - spec.getUserSyncs.returns([]); - - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - - expect(addBidResponseStub.callCount).to.equal(0); - expect(doneStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); - expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); - expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); - sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { - error: xhrErrorMock, - bidderRequest: MOCK_BIDS_REQUEST + + addBidResponseStub = sinon.stub(); + addBidResponseStub.reject = sinon.stub(); + doneStub = sinon.stub(); + ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) { + const fakeResponse = sinon.stub(); + fakeResponse.returns('headerContent'); + callbacks.success('response body', { getResponseHeader: fakeResponse }); }); + logErrorSpy = sinon.spy(utils, 'logError'); + indexStub = sinon.stub(auctionManager, 'index'); + adUnits = []; + bidderRequests = []; + indexStub.get(() => stubAuctionIndex({adUnits: adUnits, bidderRequests: bidderRequests})) }); - it('should call spec.getUserSyncs() with no responses', function () { - const bidder = newBidder(spec); + afterEach(function () { + ajaxStub.restore(); + logErrorSpy.restore(); + indexStub.restore; + }); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} + if (FEATURES.NATIVE) { + it('should add native bids that do have required assets', function () { + adUnits = [{ + transactionId: 'au', + nativeParams: { + title: {'required': true}, + } + }] + decorateAdUnitsWithNativeParams(adUnits); + let bidRequest = { + bids: [{ + bidId: '1', + auctionId: 'first-bid-id', + adUnitCode: 'mock/placement', + transactionId: 'au', + params: { + param: 5 + }, + mediaType: 'native', + }] + }; + + let bids1 = Object.assign({}, + bids[0], + { + 'mediaType': 'native', + 'native': { + 'title': 'Native Creative', + 'clickUrl': 'https://www.link.example', + } + } + ); + + const bidder = newBidder(spec); + + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + expect(logErrorSpy.callCount).to.equal(0); }); - spec.getUserSyncs.returns([]); - - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - - expect(spec.getUserSyncs.calledOnce).to.equal(true); - expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]); - expect(doneStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); - expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); - expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); - sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { - error: xhrErrorMock, - bidderRequest: MOCK_BIDS_REQUEST + + it('should not add native bids that do not have required assets', function () { + adUnits = [{ + transactionId: 'au', + nativeParams: { + title: {'required': true}, + }, + }]; + decorateAdUnitsWithNativeParams(adUnits); + let bidRequest = { + bids: [{ + bidId: '1', + auctionId: 'first-bid-id', + adUnitCode: 'mock/placement', + transactionId: 'au', + params: { + param: 5 + }, + mediaType: 'native', + }] + }; + let bids1 = Object.assign({}, + bids[0], + { + bidderCode: CODE, + mediaType: 'native', + native: { + title: undefined, + clickUrl: 'https://www.link.example', + } + } + ); + + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(addBidResponseStub.called).to.equal(false); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + expect(logErrorSpy.calledWithMatch('Ignoring bid: Native bid missing some required properties.')).to.equal(true); }); + } + + it('should add bid when renderer is present on outstream bids', function () { + adUnits = [{ + transactionId: 'au', + mediaTypes: { + video: {context: 'outstream'} + } + }] + let bidRequest = { + bids: [{ + bidId: '1', + auctionId: 'first-bid-id', + transactionId: 'au', + adUnitCode: 'mock/placement', + params: { + param: 5 + }, + }] + }; + + let bids1 = Object.assign({}, + bids[0], + { + bidderCode: CODE, + mediaType: 'video', + renderer: {render: () => true, url: 'render.js'}, + } + ); + + const bidder = newBidder(spec); + + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + expect(logErrorSpy.callCount).to.equal(0); }); - it('should call spec.getUserSyncs() with no responses', function () { + it('should add banner bids that have no width or height but single adunit size', function () { + let bidRequest = { + bids: [{ + bidder: CODE, + bidId: '1', + auctionId: 'first-bid-id', + adUnitCode: 'mock/placement', + params: { + param: 5 + }, + sizes: [[300, 250]], + }] + }; + bidderRequests = [bidRequest]; + let bids1 = Object.assign({}, + bids[0], + { + width: undefined, + height: undefined + } + ); + const bidder = newBidder(spec); - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} - }); - spec.getUserSyncs.returns([]); - - bidder.callBids(MOCK_BIDS_REQUEST, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - - expect(spec.getUserSyncs.calledOnce).to.equal(true); - expect(spec.getUserSyncs.firstCall.args[1]).to.deep.equal([]); - expect(doneStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.calledOnce).to.equal(true); - expect(callBidderErrorStub.firstCall.args[0]).to.equal(CODE); - expect(callBidderErrorStub.firstCall.args[1]).to.equal(xhrErrorMock); - expect(callBidderErrorStub.firstCall.args[2]).to.equal(MOCK_BIDS_REQUEST); - sinon.assert.calledWith(eventEmitterStub, CONSTANTS.EVENTS.BIDDER_ERROR, { - error: xhrErrorMock, - bidderRequest: MOCK_BIDS_REQUEST - }); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + expect(logErrorSpy.callCount).to.equal(0); }); - }); -}); -describe('registerBidder', function () { - let registerBidAdapterStub; - let aliasBidAdapterStub; + it('should disregard auctionId/transactionId set by the adapter', () => { + let bidderRequest = { + bids: [{ + bidder: CODE, + bidId: '1', + auctionId: 'aid', + transactionId: 'tid', + adUnitCode: 'au', + }] + }; + const bidder = newBidder(spec); + spec.interpretResponse.returns(Object.assign({}, bids[0], {transactionId: 'ignored', auctionId: 'ignored'})); + bidder.callBids(bidderRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + sinon.assert.calledWith(addBidResponseStub, sinon.match.any, sinon.match({ + transactionId: 'tid', + auctionId: 'aid' + })); + }) + + describe(' Check for alternateBiddersList ', function() { + let bidRequest; + let bids1; + let logWarnSpy; + let bidderSettingStub, aliasRegistryStub; + let aliasRegistry; + + beforeEach(function () { + bidRequest = { + bids: [{ + bidId: '1', + bidder: CODE, + auctionId: 'first-bid-id', + adUnitCode: 'mock/placement', + transactionId: 'au', + }] + }; + + bids1 = Object.assign({}, + bids[0], + { + bidderCode: 'validalternatebidder', + adapterCode: 'knownadapter1' + } + ); + logWarnSpy = sinon.spy(utils, 'logWarn'); + bidderSettingStub = sinon.stub(bidderSettings, 'get'); + aliasRegistry = {}; + aliasRegistryStub = sinon.stub(adapterManager, 'aliasRegistry'); + aliasRegistryStub.get(() => aliasRegistry); + }); - beforeEach(function () { - registerBidAdapterStub = sinon.stub(adapterManager, 'registerBidAdapter'); - aliasBidAdapterStub = sinon.stub(adapterManager, 'aliasBidAdapter'); - }); + afterEach(function () { + logWarnSpy.restore(); + bidderSettingStub.restore(); + aliasRegistryStub.restore(); + }); - afterEach(function () { - registerBidAdapterStub.restore(); - aliasBidAdapterStub.restore(); - }); + it('should log warning when bidder is unknown and allowAlternateBidderCodes flag is false', function () { + bidderSettingStub.returns(false); - function newEmptySpec() { - return { - code: CODE, - isBidRequestValid: function() { }, - buildRequests: function() { }, - interpretResponse: function() { }, - }; - } - - it('should register a bidder with the adapterManager', function () { - registerBidder(newEmptySpec()); - expect(registerBidAdapterStub.calledOnce).to.equal(true); - expect(registerBidAdapterStub.firstCall.args[0]).to.have.property('callBids'); - expect(registerBidAdapterStub.firstCall.args[0].callBids).to.be.a('function'); - - expect(registerBidAdapterStub.firstCall.args[1]).to.equal(CODE); - expect(registerBidAdapterStub.firstCall.args[2]).to.be.undefined; - }); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - it('should register a bidder with the appropriate mediaTypes', function () { - const thisSpec = Object.assign(newEmptySpec(), { supportedMediaTypes: ['video'] }); - registerBidder(thisSpec); - expect(registerBidAdapterStub.calledOnce).to.equal(true); - expect(registerBidAdapterStub.firstCall.args[2]).to.deep.equal({supportedMediaTypes: ['video']}); - }); + expect(addBidResponseStub.called).to.equal(false); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + expect(logWarnSpy.callCount).to.equal(1); + }); - it('should register bidders with the appropriate aliases', function () { - const thisSpec = Object.assign(newEmptySpec(), { aliases: ['foo', 'bar'] }); - registerBidder(thisSpec); + it('should reject the bid, when allowAlternateBidderCodes flag is undefined (default should be false)', function () { + bidderSettingStub.returns(undefined); - expect(registerBidAdapterStub.calledThrice).to.equal(true); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - // Make sure our later calls don't override the bidder code from previous calls. - expect(registerBidAdapterStub.firstCall.args[0].getBidderCode()).to.equal(CODE); - expect(registerBidAdapterStub.secondCall.args[0].getBidderCode()).to.equal('foo') - expect(registerBidAdapterStub.thirdCall.args[0].getBidderCode()).to.equal('bar') + expect(addBidResponseStub.called).to.equal(false); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + }); - expect(registerBidAdapterStub.firstCall.args[1]).to.equal(CODE); - expect(registerBidAdapterStub.secondCall.args[1]).to.equal('foo') - expect(registerBidAdapterStub.thirdCall.args[1]).to.equal('bar') - }); + it('should log warning when the particular bidder is not specified in allowedAlternateBidderCodes and allowAlternateBidderCodes flag is true', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(['invalidAlternateBidder02']); - it('should register alias with their gvlid', function() { - const aliases = [ - { - code: 'foo', - gvlid: 1 - }, - { - code: 'bar', - gvlid: 2 - }, - { - code: 'baz' - } - ] - const thisSpec = Object.assign(newEmptySpec(), { aliases: aliases }); - registerBidder(thisSpec); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(registerBidAdapterStub.getCall(1).args[0].getSpec().gvlid).to.equal(1); - expect(registerBidAdapterStub.getCall(2).args[0].getSpec().gvlid).to.equal(2); - expect(registerBidAdapterStub.getCall(3).args[0].getSpec().gvlid).to.equal(undefined); - }) + expect(addBidResponseStub.called).to.equal(false); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + expect(logWarnSpy.callCount).to.equal(1); + }); - it('should register alias with skipPbsAliasing', function() { - const aliases = [ - { - code: 'foo', - skipPbsAliasing: true - }, - { - code: 'bar', - skipPbsAliasing: false - }, - { - code: 'baz' - } - ] - const thisSpec = Object.assign(newEmptySpec(), { aliases: aliases }); - registerBidder(thisSpec); + it('should accept the bid, when allowedAlternateBidderCodes is empty and allowAlternateBidderCodes flag is true', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(); - expect(registerBidAdapterStub.getCall(1).args[0].getSpec().skipPbsAliasing).to.equal(true); - expect(registerBidAdapterStub.getCall(2).args[0].getSpec().skipPbsAliasing).to.equal(false); - expect(registerBidAdapterStub.getCall(3).args[0].getSpec().skipPbsAliasing).to.equal(undefined); - }) -}) + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); -describe('validate bid response: ', function () { - let spec; - let indexStub, adUnits, bidderRequests; - let addBidResponseStub; - let doneStub; - let ajaxStub; - let logErrorSpy; - - let bids = [{ - 'ad': 'creative', - 'cpm': '1.99', - 'width': 300, - 'height': 250, - 'requestId': '1', - 'creativeId': 'some-id', - 'currency': 'USD', - 'netRevenue': true, - 'ttl': 360 - }]; - - beforeEach(function () { - spec = { - code: CODE, - isBidRequestValid: sinon.stub(), - buildRequests: sinon.stub(), - interpretResponse: sinon.stub(), - }; - - spec.isBidRequestValid.returns(true); - spec.buildRequests.returns({ - method: 'POST', - url: 'test.url.com', - data: {} - }); + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(logWarnSpy.callCount).to.equal(0); + expect(logErrorSpy.callCount).to.equal(0); + }); - addBidResponseStub = sinon.stub(); - doneStub = sinon.stub(); - ajaxStub = sinon.stub(ajax, 'ajax').callsFake(function(url, callbacks) { - const fakeResponse = sinon.stub(); - fakeResponse.returns('headerContent'); - callbacks.success('response body', { getResponseHeader: fakeResponse }); - }); - logErrorSpy = sinon.spy(utils, 'logError'); - indexStub = sinon.stub(auctionManager, 'index'); - adUnits = []; - bidderRequests = []; - indexStub.get(() => stubAuctionIndex({adUnits: adUnits, bidderRequests: bidderRequests})) - }); + it('should accept the bid, when allowedAlternateBidderCodes is marked as * and allowAlternateBidderCodes flag is true', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(['*']); - afterEach(function () { - ajaxStub.restore(); - logErrorSpy.restore(); - indexStub.restore; - }); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - it('should add native bids that do have required assets', function () { - adUnits = [{ - transactionId: 'au', - nativeParams: { - title: {'required': true}, - } - }] - let bidRequest = { - bids: [{ - bidId: '1', - auctionId: 'first-bid-id', - adUnitCode: 'mock/placement', - transactionId: 'au', - params: { - param: 5 - }, - mediaType: 'native', - }] - }; - - let bids1 = Object.assign({}, - bids[0], - { - 'mediaType': 'native', - 'native': { - 'title': 'Native Creative', - 'clickUrl': 'https://www.link.example', - } - } - ); + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(logWarnSpy.callCount).to.equal(0); + expect(logErrorSpy.callCount).to.equal(0); + }); - const bidder = newBidder(spec); + it('should accept the bid, when allowedAlternateBidderCodes is marked as * (with space) and allowAlternateBidderCodes flag is true', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns([' * ']); - spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(addBidResponseStub.calledOnce).to.equal(true); - expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); - expect(logErrorSpy.callCount).to.equal(0); - }); + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(logWarnSpy.callCount).to.equal(0); + expect(logErrorSpy.callCount).to.equal(0); + }); - it('should not add native bids that do not have required assets', function () { - adUnits = [{ - transactionId: 'au', - nativeParams: { - title: {'required': true}, - }, - }]; - let bidRequest = { - bids: [{ - bidId: '1', - auctionId: 'first-bid-id', - adUnitCode: 'mock/placement', - transactionId: 'au', - params: { - param: 5 - }, - mediaType: 'native', - }] - }; - let bids1 = Object.assign({}, - bids[0], - { - bidderCode: CODE, - mediaType: 'native', - native: { - title: undefined, - clickUrl: 'https://www.link.example', - } - } - ); + it('should not accept the bid, when allowedAlternateBidderCodes is marked as empty array and allowAlternateBidderCodes flag is true', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns([]); - const bidder = newBidder(spec); - spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - expect(addBidResponseStub.calledOnce).to.equal(false); - expect(logErrorSpy.callCount).to.equal(1); - }); + expect(addBidResponseStub.called).to.equal(false); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + expect(logWarnSpy.callCount).to.equal(1); + }); - it('should add bid when renderer is present on outstream bids', function () { - adUnits = [{ - transactionId: 'au', - mediaTypes: { - video: {context: 'outstream'} - } - }] - let bidRequest = { - bids: [{ - bidId: '1', - auctionId: 'first-bid-id', - transactionId: 'au', - adUnitCode: 'mock/placement', - params: { - param: 5 - }, - }] - }; - - let bids1 = Object.assign({}, - bids[0], - { - bidderCode: CODE, - mediaType: 'video', - renderer: {render: () => true, url: 'render.js'}, - } - ); + it('should accept the bid, when allowedAlternateBidderCodes contains bidder name and allowAlternateBidderCodes flag is true', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(true); + bidderSettingStub.withArgs(CODE, 'allowedAlternateBidderCodes').returns(['validAlternateBidder']); - const bidder = newBidder(spec); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(addBidResponseStub.called).to.equal(true); + expect(logWarnSpy.callCount).to.equal(0); + expect(logErrorSpy.callCount).to.equal(0); + }); - expect(addBidResponseStub.calledOnce).to.equal(true); - expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); - expect(logErrorSpy.callCount).to.equal(0); - }); + it('should not accept the bid, when bidder is an alias but bidderSetting is missing for the bidder. It should fallback to standard setting and reject the bid', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(false); + aliasRegistry = {'validAlternateBidder': CODE}; - it('should add banner bids that have no width or height but single adunit size', function () { - let bidRequest = { - bids: [{ - bidder: CODE, - bidId: '1', - auctionId: 'first-bid-id', - adUnitCode: 'mock/placement', - params: { - param: 5 - }, - sizes: [[300, 250]], - }] - }; - bidderRequests = [bidRequest]; - let bids1 = Object.assign({}, - bids[0], - { - width: undefined, - height: undefined - } - ); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); - const bidder = newBidder(spec); + expect(addBidResponseStub.called).to.equal(false); + expect(logWarnSpy.callCount).to.equal(1); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + }); - spec.interpretResponse.returns(bids1); - bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + it('should not accept the bid, when bidderSetting is missing for the bidder. It should fallback to standard setting and reject the bid', function () { + bidderSettingStub.withArgs(CODE, 'allowAlternateBidderCodes').returns(false); - expect(addBidResponseStub.calledOnce).to.equal(true); - expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); - expect(logErrorSpy.callCount).to.equal(0); - }); -}); + const bidder = newBidder(spec); + spec.interpretResponse.returns(bids1); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); -describe('preload mapping url hook', function() { - let fakeTranslationServer; - let getLocalStorageStub; - let adapterManagerStub; - let adUnits = [{ - code: 'midroll_1', - mediaTypes: { - video: { - context: 'adpod' - } - }, - bids: [ - { - bidder: 'sampleBidder1', - params: { - placementId: 14542875, - } - } - ] - }]; - - beforeEach(function () { - fakeTranslationServer = server; - getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); - adapterManagerStub = sinon.stub(adapterManager, 'getBidAdapter'); - config.setConfig({ - 'adpod': { - 'brandCategoryExclusion': true - } + expect(addBidResponseStub.called).to.equal(false); + expect(addBidResponseStub.reject.calledOnce).to.be.true; + expect(logWarnSpy.callCount).to.equal(1); + }); }); - adapterManagerStub.withArgs('sampleBidder1').returns({ - getSpec: function() { - return { - 'getMappingFileInfo': function() { - return { - url: 'http://sample.com', - refreshInDays: 7, - key: `sampleBidder1MappingFile` - } - } + + describe('when interpretResponse returns BidderAuctionResponse', function() { + const bidRequest = { + auctionId: 'aid', + bids: [{ + bidId: '1', + bidder: CODE, + auctionId: 'aid', + adUnitCode: 'mock/placement', + transactionId: 'au', + }] + }; + const fledgeAuctionConfig = { + bidId: '1', + config: { + foo: 'bar' } } - }); - }); + describe('when response has FLEDGE auction config', function() { + let fledgeStub; - afterEach(function() { - getLocalStorageStub.restore(); - adapterManagerStub.restore(); - config.resetConfig(); - }); + function fledgeHook(next, ...args) { + fledgeStub(...args); + } - it('should preload mapping url file', function() { - getLocalStorageStub.returns(null); - preloadBidderMappingFile(sinon.spy(), adUnits); - expect(fakeTranslationServer.requests.length).to.equal(1); + before(() => { + addComponentAuction.before(fledgeHook); + }); + + after(() => { + addComponentAuction.getHooks({hook: fledgeHook}).remove(); + }) + + beforeEach(function () { + fledgeStub = sinon.stub(); + }); + + it('should unwrap bids', function() { + const bidder = newBidder(spec); + spec.interpretResponse.returns({ + bids: bids, + fledgeAuctionConfigs: [] + }); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + }); + + it('should call fledgeManager with FLEDGE configs', function() { + const bidder = newBidder(spec); + spec.interpretResponse.returns({ + bids: bids, + fledgeAuctionConfigs: [fledgeAuctionConfig] + }); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(fledgeStub.calledOnce).to.equal(true); + sinon.assert.calledWith(fledgeStub, bidRequest.auctionId, 'mock/placement', fledgeAuctionConfig.config); + expect(addBidResponseStub.calledOnce).to.equal(true); + expect(addBidResponseStub.firstCall.args[0]).to.equal('mock/placement'); + }) + + it('should call fledgeManager with FLEDGE configs even if no bids returned', function() { + const bidder = newBidder(spec); + spec.interpretResponse.returns({ + bids: [], + fledgeAuctionConfigs: [fledgeAuctionConfig] + }); + bidder.callBids(bidRequest, addBidResponseStub, doneStub, ajaxStub, onTimelyResponseStub, wrappedCallback); + + expect(fledgeStub.calledOnce).to.be.true; + sinon.assert.calledWith(fledgeStub, bidRequest.auctionId, 'mock/placement', fledgeAuctionConfig.config); + expect(addBidResponseStub.calledOnce).to.equal(false); + }) + }) + }) }); - it('should preload mapping url file for all bidders', function() { - let adUnits = [{ - code: 'midroll_1', - mediaTypes: { - video: { - context: 'adpod' - } - }, - bids: [ - { - bidder: 'sampleBidder1', - params: { - placementId: 14542875, - } - }, - { - bidder: 'sampleBidder2', - params: { - placementId: 123456, - } - } - ] - }]; - getLocalStorageStub.returns(null); - adapterManagerStub.withArgs('sampleBidder2').returns({ - getSpec: function() { - return { - 'getMappingFileInfo': function() { - return { - url: 'http://sample.com', - refreshInDays: 7, - key: `sampleBidder2MappingFile` + describe('bid response isValid', () => { + describe('size check', () => { + let req, index; + + beforeEach(() => { + req = { + ...MOCK_BIDS_REQUEST.bids[0], + mediaTypes: { + banner: { + sizes: [[1, 2], [3, 4]] } } } - } - }); - preloadBidderMappingFile(sinon.spy(), adUnits); - expect(fakeTranslationServer.requests.length).to.equal(2); + }); - config.setConfig({ - 'adpod': { - 'brandCategoryExclusion': false + function mkResponse(width, height) { + return { + requestId: req.bidId, + width, + height, + cpm: 1, + ttl: 60, + creativeId: '123', + netRevenue: true, + currency: 'USD', + mediaType: 'banner', + } } - }); - preloadBidderMappingFile(sinon.spy(), adUnits); - expect(fakeTranslationServer.requests.length).to.equal(2); - }); - it('should make ajax call to update mapping file if data found in localstorage is expired', function() { - let clock = sinon.useFakeTimers(utils.timestamp()); - getLocalStorageStub.returns(JSON.stringify({ - lastUpdated: utils.timestamp() - 8 * 24 * 60 * 60 * 1000, - mapping: { - 'iab-1': '1' + function checkValid(bid) { + return isValid('au', bid, {index: stubAuctionIndex({bidRequests: [req]})}); } - })); - preloadBidderMappingFile(sinon.spy(), adUnits); - expect(fakeTranslationServer.requests.length).to.equal(1); - clock.restore(); - }); - it('should not make ajax call to update mapping file if data found in localstorage and is not expired', function () { - let clock = sinon.useFakeTimers(utils.timestamp()); - getLocalStorageStub.returns(JSON.stringify({ - lastUpdated: utils.timestamp(), - mapping: { - 'iab-1': '1' - } - })); - preloadBidderMappingFile(sinon.spy(), adUnits); - expect(fakeTranslationServer.requests.length).to.equal(0); - clock.restore(); + it('should succeed when response has a size that was in request', () => { + expect(checkValid(mkResponse(3, 4))).to.be.true; + }); + }) }); -}); +}) diff --git a/test/spec/unit/core/consentHandler_spec.js b/test/spec/unit/core/consentHandler_spec.js index 082ff34f90c..1bcad3216ce 100644 --- a/test/spec/unit/core/consentHandler_spec.js +++ b/test/spec/unit/core/consentHandler_spec.js @@ -1,4 +1,4 @@ -import {ConsentHandler} from '../../../../src/consentHandler.js'; +import {ConsentHandler, gvlidRegistry, multiHandler} from '../../../../src/consentHandler.js'; describe('Consent data handler', () => { let handler; @@ -56,4 +56,114 @@ describe('Consent data handler', () => { }) }) }); + + describe('getHash', () => { + it('is defined when null', () => { + expect(handler.hash).be.a('string'); + }); + it('changes when a field is updated', () => { + const h1 = handler.hash; + handler.setConsentData({field: 'value', enabled: false}); + const h2 = handler.hash; + expect(h2).to.not.eql(h1); + handler.setConsentData({field: 'value', enabled: true}); + const h3 = handler.hash; + expect(h3).to.not.eql(h2); + expect(h3).to.not.eql(h1); + }); + it('does not change when fields are unchanged', () => { + handler.setConsentData({field: 'value', enabled: true}); + const h1 = handler.hash; + handler.setConsentData({field: 'value', enabled: true}); + expect(handler.hash).to.eql(h1); + }); + it('does not change when non-hashFields are updated', () => { + handler.hashFields = ['field', 'enabled']; + handler.setConsentData({field: 'value', enabled: true}); + const h1 = handler.hash; + handler.setConsentData({field: 'value', enabled: true, other: 'data'}); + expect(handler.hash).to.eql(h1); + }) + }) +}); + +describe('multiHandler', () => { + let handlers, multi; + beforeEach(() => { + handlers = {h1: {}, h2: {}}; + multi = multiHandler(handlers); + }); + + ['getConsentData', 'getConsentMeta'].forEach(method => { + describe(method, () => { + it('combines results from underlying handlers', () => { + handlers.h1[method] = () => 'one'; + handlers.h2[method] = () => 'two'; + expect(multi[method]()).to.eql({ + h1: 'one', + h2: 'two', + }) + }); + }); + }); + + describe('.promise', () => { + it('resolves all underlying promises', (done) => { + handlers.h1.promise = Promise.resolve('one'); + let resolver, result; + handlers.h2.promise = new Promise((resolve) => { resolver = resolve }); + multi.promise.then((val) => { + result = val; + expect(result).to.eql({ + h1: 'one', + h2: 'two' + }); + done(); + }) + handlers.h1.promise.then(() => { + expect(result).to.not.exist; + resolver('two'); + }); + }) + }); + + describe('.hash', () => { + ['h1', 'h2'].forEach((handler, i) => { + it(`changes when handler #${i + 1} changes hash`, () => { + handlers.h1.hash = 'one'; + handlers.h2.hash = 'two' + const first = multi.hash; + handlers[handler].hash = 'new'; + expect(multi.hash).to.not.eql(first); + }) + }) + }) +}) + +describe('gvlidRegistry', () => { + let registry; + beforeEach(() => { + registry = gvlidRegistry(); + }); + + it('returns undef when id cannoot be found', () => { + expect(registry.get('name')).to.eql({modules: {}}) + }); + + it('does not register null ids', () => { + registry.register('type', 'name', null); + expect(registry.get('type', 'name')).to.eql({modules: {}}); + }) + + it('can retrieve registered GVL IDs', () => { + registry.register('type', 'name', 123); + registry.register('otherType', 'name', 123); + expect(registry.get('name')).to.eql({gvlid: 123, modules: {type: 123, otherType: 123}}); + }); + + it('does not return `gvlid` if there is more than one', () => { + registry.register('type', 'name', 123); + registry.register('otherType', 'name', 321); + expect(registry.get('name')).to.eql({modules: {type: 123, otherType: 321}}) + }); }) diff --git a/test/spec/unit/core/events_spec.js b/test/spec/unit/core/events_spec.js new file mode 100644 index 00000000000..6551c9f2456 --- /dev/null +++ b/test/spec/unit/core/events_spec.js @@ -0,0 +1,30 @@ +import {config} from 'src/config.js'; +import {emit, clearEvents, getEvents} from '../../../../src/events.js'; + +describe('events', () => { + let clock; + beforeEach(() => { + clock = sinon.useFakeTimers(); + clearEvents(); + }); + afterEach(() => { + clock.restore(); + }); + + it('should clear event log using eventHistoryTTL config', () => { + emit('testEvent', {}); + expect(getEvents().length).to.eql(1); + config.setConfig({eventHistoryTTL: 1}); + clock.tick(500); + expect(getEvents().length).to.eql(1); + clock.tick(6000); + expect(getEvents().length).to.eql(0); + }); + + it('should take history TTL in seconds', () => { + emit('testEvent', {}); + config.setConfig({eventHistoryTTL: 1000}); + clock.tick(10000); + expect(getEvents().length).to.eql(1); + }) +}) diff --git a/test/spec/unit/core/storageManager_spec.js b/test/spec/unit/core/storageManager_spec.js index 74a3b3b023f..edead126c2c 100644 --- a/test/spec/unit/core/storageManager_spec.js +++ b/test/spec/unit/core/storageManager_spec.js @@ -1,13 +1,25 @@ import { - resetData, + deviceAccessRule, getCoreStorageManager, + newStorageManager, + resetData, + STORAGE_TYPE_COOKIES, + STORAGE_TYPE_LOCALSTORAGE, + storageAllowedRule, storageCallbacks, - getStorageManager, - newStorageManager } from 'src/storageManager.js'; -import { config } from 'src/config.js'; +import adapterManager from 'src/adapterManager.js'; +import {config} from 'src/config.js'; import * as utils from 'src/utils.js'; import {hook} from '../../../../src/hook.js'; +import {MODULE_TYPE_BIDDER, MODULE_TYPE_PREBID} from '../../../../src/activities/modules.js'; +import {ACTIVITY_ACCESS_DEVICE} from '../../../../src/activities/activities.js'; +import { + ACTIVITY_PARAM_COMPONENT_NAME, + ACTIVITY_PARAM_COMPONENT_TYPE, + ACTIVITY_PARAM_STORAGE_TYPE +} from '../../../../src/activities/params.js'; +import {activityParams} from '../../../../src/activities/activityParams.js'; describe('storage manager', function() { before(() => { @@ -33,7 +45,7 @@ describe('storage manager', function() { it('should add done callbacks to storageCallbacks array', function() { let noop = sinon.spy(); - const coreStorage = getStorageManager(); + const coreStorage = newStorageManager(); coreStorage.setCookie('foo', 'bar', null, null, null, noop); coreStorage.getCookie('foo', noop); @@ -49,12 +61,50 @@ describe('storage manager', function() { it('should allow bidder to access device if gdpr enforcement module is not included', function() { let deviceAccessSpy = sinon.spy(utils, 'hasDeviceAccess'); - const storage = getStorageManager(); + const storage = newStorageManager(); storage.setCookie('foo1', 'baz1'); expect(deviceAccessSpy.calledOnce).to.equal(true); deviceAccessSpy.restore(); }); + describe(`accessDevice activity check`, () => { + let isAllowed; + + function mkManager(moduleType, moduleName) { + return newStorageManager({moduleType, moduleName}, {isAllowed}); + } + + beforeEach(() => { + isAllowed = sinon.stub(); + }); + + it('should pass module type and name as activity params', () => { + mkManager(MODULE_TYPE_PREBID, 'mockMod').localStorageIsEnabled(); + sinon.assert.calledWith(isAllowed, ACTIVITY_ACCESS_DEVICE, sinon.match({ + [ACTIVITY_PARAM_COMPONENT_TYPE]: MODULE_TYPE_PREBID, + [ACTIVITY_PARAM_COMPONENT_NAME]: 'mockMod', + [ACTIVITY_PARAM_STORAGE_TYPE]: STORAGE_TYPE_LOCALSTORAGE + })); + }); + + it('should deny access if activity is denied', () => { + isAllowed.returns(false); + const mgr = mkManager(MODULE_TYPE_PREBID, 'mockMod'); + mgr.setDataInLocalStorage('testKey', 'val'); + expect(mgr.getDataFromLocalStorage('testKey')).to.not.exist; + }); + + it('should use bidder aliases when possible', () => { + adapterManager.registerBidAdapter({callBids: sinon.stub(), getSpec: () => ({})}, 'mockBidder'); + adapterManager.aliasBidAdapter('mockBidder', 'mockAlias'); + const mgr = mkManager(MODULE_TYPE_BIDDER, 'mockBidder'); + config.runWithBidder('mockAlias', () => mgr.cookiesAreEnabled()); + sinon.assert.calledWith(isAllowed, ACTIVITY_ACCESS_DEVICE, sinon.match({ + [ACTIVITY_PARAM_COMPONENT_NAME]: 'mockAlias' + })) + }) + }) + describe('localstorage forbidden access in 3rd-party context', function() { let errorLogSpy; let originalLocalStorage; @@ -72,7 +122,7 @@ describe('storage manager', function() { }) it('should not throw if the localstorage is not accessible when setting/getting/removing from localstorage', function() { - const coreStorage = getStorageManager(); + const coreStorage = newStorageManager(); coreStorage.setDataInLocalStorage('key', 'value'); const val = coreStorage.getDataFromLocalStorage('key'); @@ -96,7 +146,7 @@ describe('storage manager', function() { }) it('should remove side-effect after checking', function () { - const storage = getStorageManager(); + const storage = newStorageManager(); localStorage.setItem('unrelated', 'dummy'); const val = storage.localStorageIsEnabled(); @@ -107,18 +157,31 @@ describe('storage manager', function() { }); }); - describe('when bidderSettings.allowStorage is defined', () => { - const DENIED_BIDDER = 'denied-bidder'; - const DENY_KEY = 'storageAllowed'; + describe('deviceAccess control', () => { + afterEach(() => { + config.resetConfig() + }); + + it('should allow by default', () => { + config.resetConfig(); + expect(deviceAccessRule()).to.not.exist; + }); + + it('should deny access when set', () => { + config.setConfig({deviceAccess: false}); + sinon.assert.match(deviceAccessRule(), {allow: false}); + }) + }); - const COOKIE = 'test-cookie'; - const LS_KEY = 'test-localstorage'; + describe('allowStorage access control rule', () => { + const ALLOWED_BIDDER = 'allowed-bidder'; + const ALLOW_KEY = 'storageAllowed'; - function mockBidderSettings() { + function mockBidderSettings(val) { return { get(bidder, key) { - if (bidder === DENIED_BIDDER && key === DENY_KEY) { - return false; + if (bidder === ALLOWED_BIDDER && key === ALLOW_KEY) { + return val; } else { return undefined; } @@ -127,41 +190,74 @@ describe('storage manager', function() { } Object.entries({ - disallowed: [DENIED_BIDDER, false], - allowed: ['allowed-bidder', true] - }).forEach(([test, [bidderCode, shouldWork]]) => { - describe(`for ${test} bidders`, () => { - let mgr; - - beforeEach(() => { - mgr = newStorageManager({bidderCode: bidderCode}, {bidderSettings: mockBidderSettings()}); - }) - - afterEach(() => { - mgr.setCookie(COOKIE, 'delete', new Date().toUTCString()); - mgr.removeDataFromLocalStorage(LS_KEY); - }) - - const testDesc = (desc) => `should ${shouldWork ? '' : 'not'} ${desc}`; - - it(testDesc('allow cookies'), () => { - mgr.setCookie(COOKIE, 'value'); - expect(mgr.getCookie(COOKIE)).to.equal(shouldWork ? 'value' : null); - }); - - it(testDesc('allow localStorage'), () => { - mgr.setDataInLocalStorage(LS_KEY, 'value'); - expect(mgr.getDataFromLocalStorage(LS_KEY)).to.equal(shouldWork ? 'value' : null); - }); - - it(testDesc('report localStorage as available'), () => { - expect(mgr.hasLocalStorage()).to.equal(shouldWork); - }); - - it(testDesc('report cookies as available'), () => { - expect(mgr.cookiesAreEnabled()).to.equal(shouldWork); + disallowed: ['denied_bidder', false], + allowed: [ALLOWED_BIDDER, true] + }).forEach(([t, [bidderCode, isBidderAllowed]]) => { + describe(`for ${t} bidders`, () => { + Object.entries({ + 'all': { + configValues: [ + true, + ['html5', 'cookie'] + ], + shouldWork: { + html5: true, + cookie: true + } + }, + 'none': { + configValues: [ + false, + [] + ], + shouldWork: { + html5: false, + cookie: false + } + }, + 'localStorage': { + configValues: [ + 'html5', + ['html5'] + ], + shouldWork: { + html5: true, + cookie: false + } + }, + 'cookies': { + configValues: [ + 'cookie', + ['cookie'] + ], + shouldWork: { + html5: false, + cookie: true + } + } + }).forEach(([t, {configValues, shouldWork: {cookie, html5}}]) => { + describe(`when ${t} is allowed`, () => { + configValues.forEach(configValue => describe(`storageAllowed = ${configValue}`, () => { + Object.entries({ + [STORAGE_TYPE_LOCALSTORAGE]: 'allow localStorage', + [STORAGE_TYPE_COOKIES]: 'allow cookies' + }).forEach(([type, desc]) => { + const shouldWork = isBidderAllowed && ({html5, cookie})[type]; + it(`${shouldWork ? '' : 'NOT'} ${desc}`, () => { + const res = storageAllowedRule(activityParams(MODULE_TYPE_BIDDER, bidderCode, { + [ACTIVITY_PARAM_STORAGE_TYPE]: type + }), mockBidderSettings(configValue)); + if (shouldWork) { + expect(res).to.not.exist; + } else { + sinon.assert.match(res, {allow: false}); + } + }); + }) + })); + }); }); }); }); - }) + }); }); diff --git a/test/spec/unit/core/targeting_spec.js b/test/spec/unit/core/targeting_spec.js index 53aa3b90fa8..4716e5749cb 100644 --- a/test/spec/unit/core/targeting_spec.js +++ b/test/spec/unit/core/targeting_spec.js @@ -1,13 +1,25 @@ -import { expect } from 'chai'; -import { targeting as targetingInstance, filters, getHighestCpmBidsFromBidPool, sortByDealAndPriceBucketOrCpm } from 'src/targeting.js'; -import { config } from 'src/config.js'; -import { createBidReceived } from 'test/fixtures/fixtures.js'; +import {expect} from 'chai'; +import { + filters, + getHighestCpmBidsFromBidPool, + sortByDealAndPriceBucketOrCpm, + targeting as targetingInstance +} from 'src/targeting.js'; +import {config} from 'src/config.js'; +import {createBidReceived} from 'test/fixtures/fixtures.js'; import CONSTANTS from 'src/constants.json'; -import { auctionManager } from 'src/auctionManager.js'; +import {auctionManager} from 'src/auctionManager.js'; import * as utils from 'src/utils.js'; import {deepClone} from 'src/utils.js'; +import {createBid} from '../../../../src/bidfactory.js'; +import {hook} from '../../../../src/hook.js'; +import {getHighestCpm} from '../../../../src/utils/reducers.js'; -const bid1 = { +function mkBid(bid, status = CONSTANTS.STATUS.GOOD) { + return Object.assign(createBid(status), bid); +} + +const sampleBid = { 'bidderCode': 'rubicon', 'width': '300', 'height': '250', @@ -39,7 +51,9 @@ const bid1 = { 'ttl': 300 }; -const bid2 = { +const bid1 = mkBid(sampleBid); + +const bid2 = mkBid({ 'bidderCode': 'rubicon', 'width': '300', 'height': '250', @@ -67,9 +81,9 @@ const bid2 = { 'netRevenue': true, 'currency': 'USD', 'ttl': 300 -}; +}); -const bid3 = { +const bid3 = mkBid({ 'bidderCode': 'rubicon', 'width': '300', 'height': '600', @@ -97,9 +111,9 @@ const bid3 = { 'netRevenue': true, 'currency': 'USD', 'ttl': 300 -}; +}); -const nativeBid1 = { +const nativeBid1 = mkBid({ 'bidderCode': 'appnexus', 'width': 0, 'height': 0, @@ -165,8 +179,9 @@ const nativeBid1 = { [CONSTANTS.NATIVE_KEYS.image]: 'http://vcdn.adnxs.com/p/creative-image/94/22/cd/0f/9422cd0f-f400-45d3-80f5-2b92629d9257.jpg', [CONSTANTS.NATIVE_KEYS.icon]: 'http://vcdn.adnxs.com/p/creative-image/bd/59/a6/c6/bd59a6c6-0851-411d-a16d-031475a51312.png' } -}; -const nativeBid2 = { +}); + +const nativeBid2 = mkBid({ 'bidderCode': 'dgads', 'width': 0, 'height': 0, @@ -222,7 +237,7 @@ const nativeBid2 = { [CONSTANTS.NATIVE_KEYS.sponsoredBy]: 'test.com', [CONSTANTS.NATIVE_KEYS.clickUrl]: 'http://prebid.org/' } -}; +}); describe('targeting tests', function () { let sandbox; @@ -231,6 +246,10 @@ describe('targeting tests', function () { let bidCacheFilterFunction; let undef; + before(() => { + hook.ready(); + }); + beforeEach(function() { sandbox = sinon.sandbox.create(); @@ -256,6 +275,40 @@ describe('targeting tests', function () { bidCacheFilterFunction = undef; }); + describe('isBidNotExpired', () => { + let clock; + beforeEach(() => { + clock = sandbox.useFakeTimers(0); + }); + + Object.entries({ + 'bid.ttlBuffer': (bid, ttlBuffer) => { + bid.ttlBuffer = ttlBuffer + }, + 'setConfig({ttlBuffer})': (_, ttlBuffer) => { + config.setConfig({ttlBuffer}) + }, + }).forEach(([t, setup]) => { + describe(`respects ${t}`, () => { + [0, 2].forEach(ttlBuffer => { + it(`when ttlBuffer is ${ttlBuffer}`, () => { + const bid = { + responseTimestamp: 0, + ttl: 10, + } + setup(bid, ttlBuffer); + + expect(filters.isBidNotExpired(bid)).to.be.true; + clock.tick((bid.ttl - ttlBuffer) * 1000 - 100); + expect(filters.isBidNotExpired(bid)).to.be.true; + clock.tick(101); + expect(filters.isBidNotExpired(bid)).to.be.false; + }); + }); + }); + }); + }); + describe('getAllTargeting', function () { let amBidsReceivedStub; let amGetAdUnitsStub; @@ -404,7 +457,7 @@ describe('targeting tests', function () { } }); - const bids = getHighestCpmBidsFromBidPool(bidsReceived, utils.getHighestCpm, 2); + const bids = getHighestCpmBidsFromBidPool(bidsReceived, getHighestCpm, 2); expect(bids.length).to.equal(3); expect(bids[0].adId).to.equal('8383838'); @@ -420,7 +473,7 @@ describe('targeting tests', function () { } }); - const bids = getHighestCpmBidsFromBidPool(bidsReceived, utils.getHighestCpm, 2); + const bids = getHighestCpmBidsFromBidPool(bidsReceived, getHighestCpm, 2); expect(bids.length).to.equal(3); expect(bids[0].adId).to.equal('8383838'); @@ -599,7 +652,9 @@ describe('targeting tests', function () { } }); const defaultKeys = new Set(Object.values(CONSTANTS.DEFAULT_TARGETING_KEYS)); - Object.values(CONSTANTS.NATIVE_KEYS).forEach((k) => defaultKeys.add(k)); + if (FEATURES.NATIVE) { + Object.values(CONSTANTS.NATIVE_KEYS).forEach((k) => defaultKeys.add(k)); + } const expectedKeys = new Set(); bidsReceived @@ -802,26 +857,28 @@ describe('targeting tests', function () { expect(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET + '_rubicon']).to.deep.equal(targeting['/123456/header-bid-tag-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]); }); - it('ensures keys are properly generated when enableSendAllBids is true and multiple bidders use native', function() { - const nativeAdUnitCode = '/19968336/prebid_native_example_1'; - enableSendAllBids = true; + if (FEATURES.NATIVE) { + it('ensures keys are properly generated when enableSendAllBids is true and multiple bidders use native', function () { + const nativeAdUnitCode = '/19968336/prebid_native_example_1'; + enableSendAllBids = true; - // update mocks for this test to return native bids - amBidsReceivedStub.callsFake(function() { - return [nativeBid1, nativeBid2]; - }); - amGetAdUnitsStub.callsFake(function() { - return [nativeAdUnitCode]; - }); + // update mocks for this test to return native bids + amBidsReceivedStub.callsFake(function () { + return [nativeBid1, nativeBid2]; + }); + amGetAdUnitsStub.callsFake(function () { + return [nativeAdUnitCode]; + }); - let targeting = targetingInstance.getAllTargeting([nativeAdUnitCode]); - expect(targeting[nativeAdUnitCode].hb_native_image).to.equal(nativeBid1.native.image.url); - expect(targeting[nativeAdUnitCode].hb_native_linkurl).to.equal(nativeBid1.native.clickUrl); - expect(targeting[nativeAdUnitCode].hb_native_title).to.equal(nativeBid1.native.title); - expect(targeting[nativeAdUnitCode].hb_native_image_dgad).to.exist.and.to.equal(nativeBid2.native.image.url); - expect(targeting[nativeAdUnitCode].hb_pb_dgads).to.exist.and.to.equal(nativeBid2.pbMg); - expect(targeting[nativeAdUnitCode].hb_native_body_appne).to.exist.and.to.equal(nativeBid1.native.body); - }); + let targeting = targetingInstance.getAllTargeting([nativeAdUnitCode]); + expect(targeting[nativeAdUnitCode].hb_native_image).to.equal(nativeBid1.native.image.url); + expect(targeting[nativeAdUnitCode].hb_native_linkurl).to.equal(nativeBid1.native.clickUrl); + expect(targeting[nativeAdUnitCode].hb_native_title).to.equal(nativeBid1.native.title); + expect(targeting[nativeAdUnitCode].hb_native_image_dgad).to.exist.and.to.equal(nativeBid2.native.image.url); + expect(targeting[nativeAdUnitCode].hb_pb_dgads).to.exist.and.to.equal(nativeBid2.pbMg); + expect(targeting[nativeAdUnitCode].hb_native_body_appne).to.exist.and.to.equal(nativeBid1.native.body); + }); + } it('does not include adpod type bids in the getBidsReceived results', function () { let adpodBid = utils.deepClone(bid1); diff --git a/test/spec/unit/pbjs_api_spec.js b/test/spec/unit/pbjs_api_spec.js index 6a7c79fe49d..b39c984316a 100644 --- a/test/spec/unit/pbjs_api_spec.js +++ b/test/spec/unit/pbjs_api_spec.js @@ -16,10 +16,15 @@ import * as auctionModule from 'src/auction.js'; import { registerBidder } from 'src/adapters/bidderFactory.js'; import { _sendAdToCreative } from 'src/secureCreatives.js'; import {find} from 'src/polyfill.js'; -import {synchronizePromise} from '../../helpers/syncPromise.js'; -import 'src/prebid.js'; +import * as pbjsModule from 'src/prebid.js'; import {hook} from '../../../src/hook.js'; - +import {reset as resetDebugging} from '../../../src/debugging.js'; +import $$PREBID_GLOBAL$$ from 'src/prebid.js'; +import {resetAuctionState} from 'src/auction.js'; +import {stubAuctionIndex} from '../../helpers/indexStub.js'; +import {createBid} from '../../../src/bidfactory.js'; +import {enrichFPD} from '../../../src/fpd/enrichment.js'; +import {mockFpdEnrichments} from '../../helpers/fpd.js'; var assert = require('chai').assert; var expect = require('chai').expect; @@ -33,18 +38,16 @@ require('modules/appnexusBidAdapter'); var config = require('test/fixtures/config.json'); -$$PREBID_GLOBAL$$ = $$PREBID_GLOBAL$$ || {}; var adUnits = getAdUnits(); var adUnitCodes = getAdUnits().map(unit => unit.code); var bidsBackHandler = function() {}; const timeout = 2000; -var auction = auctionManager.createAuction({adUnits, adUnitCodes, callback: bidsBackHandler, cbTimeout: timeout}); -auction.getBidRequests = getBidRequests; -auction.getBidsReceived = getBidResponses; -auction.getAdUnits = getAdUnits; -auction.getAuctionStatus = function() { return auctionModule.AUCTION_COMPLETED } +let auction; function resetAuction() { + if (auction == null) { + auction = auctionManager.createAuction({adUnits, adUnitCodes, callback: bidsBackHandler, cbTimeout: timeout}); + } $$PREBID_GLOBAL$$.setConfig({ enableSendAllBids: false }); auction.getBidRequests = getBidRequests; auction.getBidsReceived = getBidResponses; @@ -193,22 +196,25 @@ window.apntag = { } describe('Unit: Prebid Module', function () { - let bidExpiryStub, promiseSandbox; + let bidExpiryStub, sandbox; before(() => { hook.ready(); $$PREBID_GLOBAL$$.requestBids.getHooks().remove(); + resetDebugging(); + sinon.stub(filters, 'isActualBid').returns(true); // stub this out so that we can use vanilla objects as bids }); beforeEach(function () { - promiseSandbox = sinon.createSandbox(); - synchronizePromise(promiseSandbox); + sandbox = sinon.sandbox.create(); + mockFpdEnrichments(sandbox); bidExpiryStub = sinon.stub(filters, 'isBidNotExpired').callsFake(() => true); configObj.setConfig({ useBidCache: true }); + resetAuctionState(); }); afterEach(function() { - promiseSandbox.restore(); + sandbox.restore(); $$PREBID_GLOBAL$$.adUnits = []; bidExpiryStub.restore(); configObj.setConfig({ useBidCache: false }); @@ -216,6 +222,52 @@ describe('Unit: Prebid Module', function () { after(function() { auctionManager.clearAllAuctions(); + filters.isActualBid.restore(); + }); + + describe('and global adUnits', () => { + const startingAdUnits = [ + { + code: 'one', + }, + { + code: 'two', + } + ]; + let actualAdUnits, hookRan, done; + + function deferringHook(next, req) { + setTimeout(() => { + actualAdUnits = req.adUnits || $$PREBID_GLOBAL$$.adUnits; + done(); + }); + } + + beforeEach(() => { + $$PREBID_GLOBAL$$.requestBids.before(deferringHook, 99); + $$PREBID_GLOBAL$$.adUnits.splice(0, $$PREBID_GLOBAL$$.adUnits.length, ...startingAdUnits); + hookRan = new Promise((resolve) => { + done = resolve; + }); + }); + + afterEach(() => { + $$PREBID_GLOBAL$$.requestBids.getHooks({hook: deferringHook}).remove(); + $$PREBID_GLOBAL$$.adUnits.splice(0, $$PREBID_GLOBAL$$.adUnits.length); + }) + + Object.entries({ + 'addAdUnits': (g) => g.addAdUnits({code: 'three'}), + 'removeAdUnit': (g) => g.removeAdUnit('one') + }).forEach(([method, op]) => { + it(`once called, should not be affected by ${method}`, () => { + $$PREBID_GLOBAL$$.requestBids({}); + op($$PREBID_GLOBAL$$); + return hookRan.then(() => { + expect(actualAdUnits).to.eql(startingAdUnits); + }) + }); + }); }); describe('getAdserverTargetingForAdUnitCodeStr', function () { @@ -459,8 +511,8 @@ describe('Unit: Prebid Module', function () { 'client_initiated_ad_counting': true, 'rtb': { 'banner': { - 'width': 728, - 'height': 90, + 'width': 300, + 'height': 250, 'content': '' }, 'trackers': [{ @@ -835,16 +887,32 @@ describe('Unit: Prebid Module', function () { it('should only apply price granularity if bid media type matches', function () { initTestConfig({ - adUnits: [ createAdUnit('div-gpt-ad-1460505748561-0', 'video') ], + adUnits: [createAdUnit('div-gpt-ad-1460505748561-0')], adUnitCodes: ['div-gpt-ad-1460505748561-0'] }); - response = videoResponse; + response = bannerResponse; response.tags[0].ads[0].cpm = 3.4288; auction.callBids(cbTimeout); let bidTargeting = targeting.getAllTargeting(); - expect(bidTargeting['div-gpt-ad-1460505748561-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]).to.equal('3.00'); + expect(bidTargeting['div-gpt-ad-1460505748561-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]).to.equal('3.25'); + + if (FEATURES.VIDEO) { + ajaxStub.restore(); + + initTestConfig({ + adUnits: [createAdUnit('div-gpt-ad-1460505748561-0', 'video')], + adUnitCodes: ['div-gpt-ad-1460505748561-0'] + }); + + response = videoResponse; + response.tags[0].ads[0].cpm = 3.4288; + + auction.callBids(cbTimeout); + let bidTargeting = targeting.getAllTargeting(); + expect(bidTargeting['div-gpt-ad-1460505748561-0'][CONSTANTS.TARGETING_KEYS.PRICE_BUCKET]).to.equal('3.00'); + } }); }); @@ -1194,7 +1262,7 @@ describe('Unit: Prebid Module', function () { it('should require doc and id params', function () { $$PREBID_GLOBAL$$.renderAd(); - var error = 'Error trying to write ad Id :undefined to the page. Missing document or adId'; + var error = 'Error trying to write ad Id :undefined to the page. Missing adId'; assert.ok(spyLogError.calledWith(error), 'expected param error was logged'); }); @@ -1411,7 +1479,7 @@ describe('Unit: Prebid Module', function () { describe('requestBids', function () { let logMessageSpy; - let makeRequestsStub; + let makeRequestsStub, createAuctionStub; let adUnits; let clock; before(function () { @@ -1420,7 +1488,6 @@ describe('Unit: Prebid Module', function () { after(function () { clock.restore(); }); - let bidsBackHandlerStub = sinon.stub(); const BIDDER_CODE = 'sampleBidder'; let bids = [{ @@ -1457,11 +1524,12 @@ describe('Unit: Prebid Module', function () { 'start': 1000 }]; + let spec, indexStub, auction, completeAuction; + beforeEach(function () { logMessageSpy = sinon.spy(utils, 'logMessage'); makeRequestsStub = sinon.stub(adapterManager, 'makeBidRequests'); makeRequestsStub.returns(bidRequests); - adUnits = [{ code: 'adUnit-code', mediaTypes: { @@ -1469,45 +1537,53 @@ describe('Unit: Prebid Module', function () { sizes: [[300, 250]] } }, + transactionId: 'mock-tid', bids: [ {bidder: BIDDER_CODE, params: {placementId: 'id'}}, ] }]; - let adUnitCodes = ['adUnit-code']; - let auction = auctionModule.newAuction({ - adUnits, - adUnitCodes, - callback: bidsBackHandlerStub, - cbTimeout: 2000 - }); - let createAuctionStub = sinon.stub(auctionModule, 'newAuction'); - createAuctionStub.returns(auction); - }); - - afterEach(function () { - clock.restore(); - adapterManager.makeBidRequests.restore(); - auctionModule.newAuction.restore(); - utils.logMessage.restore(); - }); - - it('should execute callback after timeout', function () { - let spec = { + indexStub = sinon.stub(auctionManager, 'index'); + indexStub.get(() => stubAuctionIndex({adUnits, bidRequests})) + sinon.stub(adapterManager, 'callBids').callsFake((_, bidrequests, addBidResponse, adapterDone) => { + completeAuction = (bidsReceived) => { + bidsReceived.forEach((bid) => addBidResponse(bid.adUnitCode, Object.assign(createBid(), bid))); + bidRequests.forEach((req) => adapterDone.call(req)); + } + }) + const origNewAuction = auctionModule.newAuction; + sinon.stub(auctionModule, 'newAuction').callsFake(function (opts) { + auction = origNewAuction(opts); + return auction; + }) + spec = { code: BIDDER_CODE, isBidRequestValid: sinon.stub(), buildRequests: sinon.stub(), interpretResponse: sinon.stub(), getUserSyncs: sinon.stub(), - onTimeout: sinon.stub() + onTimeout: sinon.stub(), + onSetTargeting: sinon.stub(), }; registerBidder(spec); spec.buildRequests.returns([{'id': 123, 'method': 'POST'}]); spec.isBidRequestValid.returns(true); spec.interpretResponse.returns(bids); + }); + afterEach(function () { + clock.restore(); + adapterManager.makeBidRequests.restore(); + adapterManager.callBids.restore(); + indexStub.restore(); + auction.getBidsReceived = () => []; + auctionModule.newAuction.restore(); + utils.logMessage.restore(); + }); + + it('should execute callback after timeout', function () { let requestObj = { - bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach + bidsBackHandler: sinon.stub(), timeout: 2000, adUnits: adUnits }; @@ -1520,26 +1596,13 @@ describe('Unit: Prebid Module', function () { clock.tick(1); assert.ok(logMessageSpy.calledWith(sinon.match(re)), 'executeCallback called'); - expect(bidsBackHandlerStub.getCall(0).args[1]).to.equal(true, + expect(requestObj.bidsBackHandler.getCall(0).args[1]).to.equal(true, 'bidsBackHandler should be called with timedOut=true'); sinon.assert.called(spec.onTimeout); }); - it('should execute callback after setTargeting', function () { - let spec = { - code: BIDDER_CODE, - isBidRequestValid: sinon.stub(), - buildRequests: sinon.stub(), - interpretResponse: sinon.stub(), - onSetTargeting: sinon.stub() - }; - - registerBidder(spec); - spec.buildRequests.returns([{'id': 123, 'method': 'POST'}]); - spec.isBidRequestValid.returns(true); - spec.interpretResponse.returns(bids); - + it('should execute `onSetTargeting` after setTargetingForGPTAsync', function () { const bidId = 1; const auctionId = 1; let adResponse = Object.assign({ @@ -1548,6 +1611,7 @@ describe('Unit: Prebid Module', function () { width: 300, height: 250, adUnitCode: bidRequests[0].bids[0].adUnitCode, + transactionId: 'mock-tid', adserverTargeting: { 'hb_bidder': BIDDER_CODE, 'hb_adid': bidId, @@ -1556,20 +1620,102 @@ describe('Unit: Prebid Module', function () { }, bidder: bids[0].bidderCode, }, bids[0]); - auction.getBidsReceived = function() { return [adResponse]; } - auction.getAuctionId = () => auctionId; let requestObj = { - bidsBackHandler: null, // does not need to be defined because of newAuction mock in beforeEach + bidsBackHandler: null, timeout: 2000, adUnits: adUnits }; $$PREBID_GLOBAL$$.requestBids(requestObj); + completeAuction([adResponse]); $$PREBID_GLOBAL$$.setTargetingForGPTAsync(); sinon.assert.called(spec.onSetTargeting); }); + + describe('returns a promise that resolves', () => { + function delayHook(next, ...args) { + setTimeout(() => next(...args)) + } + + beforeEach(() => { + // make sure the return value works correctly when hooks give up priority + $$PREBID_GLOBAL$$.requestBids.before(delayHook) + }); + + afterEach(() => { + $$PREBID_GLOBAL$$.requestBids.getHooks({hook: delayHook}).remove(); + }); + + Object.entries({ + 'immediately, without bidsBackHandler': (req) => $$PREBID_GLOBAL$$.requestBids(req), + 'after bidsBackHandler': (() => { + const bidsBackHandler = sinon.stub(); + return function (req) { + return $$PREBID_GLOBAL$$.requestBids({...req, bidsBackHandler}).then(({bids, timedOut, auctionId}) => { + sinon.assert.calledWith(bidsBackHandler, bids, timedOut, auctionId); + return {bids, timedOut, auctionId}; + }) + } + })(), + 'after a bidsBackHandler that throws': (req) => $$PREBID_GLOBAL$$.requestBids({...req, bidsBackHandler: () => { throw new Error() }}) + }).forEach(([t, requestBids]) => { + describe(t, () => { + it('with no args, when no adUnits are defined', () => { + return requestBids({}).then((res) => { + expect(res).to.eql({ + bids: undefined, + timedOut: undefined, + auctionId: undefined + }); + }); + }); + + it('on timeout', (done) => { + requestBids({ + auctionId: 'mock-auctionId', + adUnits, + timeout: 10 + }).then(({timedOut, bids, auctionId}) => { + expect(timedOut).to.be.true; + expect(bids).to.eql({}); + expect(auctionId).to.eql('mock-auctionId'); + done(); + }); + clock.tick(12); + }); + + it('with auction result', (done) => { + const bid = { + bidder: 'mock-bidder', + adUnitCode: adUnits[0].code, + transactionId: adUnits[0].transactionId + } + requestBids({ + adUnits, + }).then(({bids}) => { + sinon.assert.match(bids[bid.adUnitCode].bids[0], bid) + done(); + }); + // `completeAuction` won't work until we're out of `delayHook` + // and the mocked auction has been set up; + // setTimeout here takes us after the setTimeout in `delayHook` + setTimeout(() => completeAuction([bid])); + }) + }) + }) + }) + + it('should transfer ttlBuffer to adUnit.ttlBuffer', () => { + $$PREBID_GLOBAL$$.requestBids({ + ttlBuffer: 123, + adUnits: [adUnits[0], {...adUnits[0], ttlBuffer: 0}] + }); + sinon.assert.calledWithMatch(auctionModule.newAuction, { + adUnits: sinon.match((units) => units[0].ttlBuffer === 123 && units[1].ttlBuffer === 0) + }) + }); }) describe('requestBids', function () { @@ -1605,8 +1751,158 @@ describe('Unit: Prebid Module', function () { assert.ok(spyExecuteCallback.calledOnce, 'callback executed when bidRequests is empty'); }); }); + + describe('starts auction', () => { + let startAuctionStub; + function saHook(fn, ...args) { + return startAuctionStub(...args); + } + beforeEach(() => { + startAuctionStub = sinon.stub(); + pbjsModule.startAuction.before(saHook); + configObj.resetConfig(); + }); + afterEach(() => { + pbjsModule.startAuction.getHooks({hook: saHook}).remove(); + }) + after(() => { + configObj.resetConfig(); + }); + + describe('with FPD', () => { + let globalFPD, auctionFPD, mergedFPD; + beforeEach(() => { + globalFPD = { + 'k1': 'v1', + 'k2': { + 'k3': 'v3', + 'k4': 'v4' + } + }; + auctionFPD = { + 'k5': 'v5', + 'k2': { + 'k3': 'override', + 'k7': 'v7' + } + }; + mergedFPD = { + 'k1': 'v1', + 'k5': 'v5', + 'k2': { + 'k3': 'override', + 'k4': 'v4', + 'k7': 'v7' + } + }; + }); + + it('merged from setConfig and requestBids', () => { + configObj.setConfig({ortb2: globalFPD}); + $$PREBID_GLOBAL$$.requestBids({ortb2: auctionFPD}); + sinon.assert.calledWith(startAuctionStub, sinon.match({ + ortb2Fragments: {global: mergedFPD} + })); + }); + + it('enriched through enrichFPD', () => { + function enrich(next, fpd) { + next.bail(fpd.then(ortb2 => { + ortb2.enrich = true; + return ortb2; + })) + } + enrichFPD.before(enrich); + try { + configObj.setConfig({ortb2: globalFPD}); + $$PREBID_GLOBAL$$.requestBids({ortb2: auctionFPD}); + sinon.assert.calledWith(startAuctionStub, sinon.match({ + ortb2Fragments: {global: {...mergedFPD, enrich: true}} + })); + } finally { + enrichFPD.getHooks({hook: enrich}).remove(); + } + }) + }); + + it('filtering adUnits by adUnitCodes', () => { + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [{code: 'one'}, {code: 'two'}], + adUnitCodes: 'two' + }); + sinon.assert.calledWith(startAuctionStub, sinon.match({ + adUnits: [{code: 'two'}] + })); + }); + + it('passing bidder-specific FPD as ortb2Fragments.bidder', () => { + configObj.setBidderConfig({ + bidders: ['bidderA', 'bidderC'], + config: { + ortb2: { + k1: 'v1' + } + } + }); + configObj.setBidderConfig({ + bidders: ['bidderB'], + config: { + ortb2: { + k2: 'v2' + } + } + }); + $$PREBID_GLOBAL$$.requestBids({}); + sinon.assert.calledWith(startAuctionStub, sinon.match({ + ortb2Fragments: { + bidder: { + bidderA: { + k1: 'v1' + }, + bidderB: { + k2: 'v2' + }, + bidderC: { + k1: 'v1' + } + } + } + })); + }); + }); }); + describe('startAuction', () => { + let sandbox, newAuctionStub; + beforeEach(() => { + sandbox = sinon.createSandbox(); + newAuctionStub = sandbox.stub(auctionManager, 'createAuction').callsFake(() => ({ + getAuctionId: () => 'mockAuctionId', + callBids: sinon.stub() + })); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('passes ortb2 fragments to createAuction', () => { + const ortb2Fragments = {}; + pbjsModule.startAuction({ + adUnits: [{ + code: 'au', + mediaTypes: {banner: {sizes: [[300, 250]]}}, + bids: [{bidder: 'bd'}] + }], + adUnitCodes: ['au'], + ortb2Fragments + }); + sinon.assert.calledWith(newAuctionStub, sinon.match({ + ortb2Fragments: sinon.match.same(ortb2Fragments) + })); + }); + }) + describe('requestBids', function () { var adUnitsBackup; var auctionManagerStub; @@ -1680,6 +1976,73 @@ describe('Unit: Prebid Module', function () { .and.to.match(/[a-f0-9\-]{36}/i); }); + describe('transactionId', () => { + let adUnit; + beforeEach(() => { + adUnit = { + code: 'adUnit', + mediaTypes: { + banner: { + sizes: [300, 250] + } + }, + bids: [ + { + bidder: 'mock-bidder', + } + ] + }; + }); + it('should be set to ortb2Imp.ext.tid, if specified', () => { + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [ + {...adUnit, ortb2Imp: {ext: {tid: 'custom-tid'}}} + ] + }); + sinon.assert.match(auctionArgs.adUnits[0], { + transactionId: 'custom-tid', + ortb2Imp: { + ext: { + tid: 'custom-tid' + } + } + }) + }); + it('should be copied to ortb2Imp.ext.tid, if not specified', () => { + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [ + adUnit + ] + }); + const tid = auctionArgs.adUnits[0].transactionId; + expect(tid).to.exist; + expect(auctionArgs.adUnits[0].ortb2Imp.ext.tid).to.eql(tid); + }); + }); + + it('should always set ortb2.ext.tid same as transactionId in adUnits', function () { + $$PREBID_GLOBAL$$.requestBids({ + adUnits: [ + { + code: 'test1', + mediaTypes: { banner: { sizes: [] } }, + bids: [] + }, { + code: 'test2', + mediaTypes: { banner: { sizes: [] } }, + bids: [] + } + ] + }); + + expect(auctionArgs.adUnits[0]).to.have.property('transactionId'); + expect(auctionArgs.adUnits[0]).to.have.property('ortb2Imp'); + expect(auctionArgs.adUnits[0].transactionId).to.equal(auctionArgs.adUnits[0].ortb2Imp.ext.tid); + expect(auctionArgs.adUnits[1]).to.have.property('transactionId'); + expect(auctionArgs.adUnits[1]).to.have.property('ortb2Imp'); + expect(auctionArgs.adUnits[1].transactionId).to.equal(auctionArgs.adUnits[1].ortb2Imp.ext.tid); + }); + it('should notify targeting of the latest auction for each adUnit', function () { let latestStub = sinon.stub(targeting, 'setLatestAuctionForAdUnit'); let getAuctionStub = sinon.stub(auction, 'getAuctionId').returns(2); @@ -1761,7 +2124,9 @@ describe('Unit: Prebid Module', function () { $$PREBID_GLOBAL$$.requestBids({ adUnits: fullAdUnit }); - expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[640, 480]]); + expect(auctionArgs.adUnits[0].sizes).to.deep.equal( + FEATURES.VIDEO ? [[640, 480]] : [[300, 250]] + ); expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.deep.equal([[640, 480]]); expect(auctionArgs.adUnits[0].mediaTypes.native.image.sizes).to.deep.equal([150, 150]); expect(auctionArgs.adUnits[0].mediaTypes.native.icon.sizes).to.deep.equal([75, 75]); @@ -1794,45 +2159,47 @@ describe('Unit: Prebid Module', function () { expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[300, 250]]); expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; - let mixedAdUnit = [{ - code: 'test3', - bids: [], - sizes: [[300, 250], [300, 600]], - mediaTypes: { - video: { - context: 'outstream', - playerSize: [[400, 350]] - }, - native: { - image: { - aspect_ratios: [200, 150], - required: true + if (FEATURES.VIDEO) { + let mixedAdUnit = [{ + code: 'test3', + bids: [], + sizes: [[300, 250], [300, 600]], + mediaTypes: { + video: { + context: 'outstream', + playerSize: [[400, 350]] + }, + native: { + image: { + aspect_ratios: [200, 150], + required: true + } } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: mixedAdUnit - }); - expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[400, 350]]); - expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; - - let altVideoPlayerSize = [{ - code: 'test4', - bids: [], - sizes: [[600, 600]], - mediaTypes: { - video: { - playerSize: [640, 480] + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: mixedAdUnit + }); + expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[400, 350]]); + expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; + + let altVideoPlayerSize = [{ + code: 'test4', + bids: [], + sizes: [[600, 600]], + mediaTypes: { + video: { + playerSize: [640, 480] + } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: altVideoPlayerSize - }); - expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[640, 480]]); - expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.deep.equal([[640, 480]]); - expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: altVideoPlayerSize + }); + expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[640, 480]]); + expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.deep.equal([[640, 480]]); + expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; + } }); it('should normalize adUnit.sizes and adUnit.mediaTypes.banner.sizes', function () { @@ -1937,95 +2304,99 @@ describe('Unit: Prebid Module', function () { expect(auctionArgs.adUnits[0].mediaTypes.banner).to.be.undefined; assert.ok(logErrorSpy.calledWith('Detected a mediaTypes.banner object without a proper sizes field. Please ensure the sizes are listed like: [[300, 250], ...]. Removing invalid mediaTypes.banner object from request.')); - let badVideo1 = [{ - code: 'testb2', - bids: [], - sizes: [[600, 600]], - mediaTypes: { - video: { - playerSize: ['600x400'] + if (FEATURES.VIDEO) { + let badVideo1 = [{ + code: 'testb2', + bids: [], + sizes: [[600, 600]], + mediaTypes: { + video: { + playerSize: ['600x400'] + } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: badVideo1 - }); - expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[600, 600]]); - expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.be.undefined; - expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; - assert.ok(logErrorSpy.calledWith('Detected incorrect configuration of mediaTypes.video.playerSize. Please specify only one set of dimensions in a format like: [[640, 480]]. Removing invalid mediaTypes.video.playerSize property from request.')); - - let badVideo2 = [{ - code: 'testb3', - bids: [], - sizes: [[600, 600]], - mediaTypes: { - video: { - playerSize: [['300', '200']] + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: badVideo1 + }); + expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[600, 600]]); + expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.be.undefined; + expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; + assert.ok(logErrorSpy.calledWith('Detected incorrect configuration of mediaTypes.video.playerSize. Please specify only one set of dimensions in a format like: [[640, 480]]. Removing invalid mediaTypes.video.playerSize property from request.')); + + let badVideo2 = [{ + code: 'testb3', + bids: [], + sizes: [[600, 600]], + mediaTypes: { + video: { + playerSize: [['300', '200']] + } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: badVideo2 - }); - expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[600, 600]]); - expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.be.undefined; - expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; - assert.ok(logErrorSpy.calledWith('Detected incorrect configuration of mediaTypes.video.playerSize. Please specify only one set of dimensions in a format like: [[640, 480]]. Removing invalid mediaTypes.video.playerSize property from request.')); + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: badVideo2 + }); + expect(auctionArgs.adUnits[0].sizes).to.deep.equal([[600, 600]]); + expect(auctionArgs.adUnits[0].mediaTypes.video.playerSize).to.be.undefined; + expect(auctionArgs.adUnits[0].mediaTypes.video).to.exist; + assert.ok(logErrorSpy.calledWith('Detected incorrect configuration of mediaTypes.video.playerSize. Please specify only one set of dimensions in a format like: [[640, 480]]. Removing invalid mediaTypes.video.playerSize property from request.')); + } - let badNativeImgSize = [{ - code: 'testb4', - bids: [], - mediaTypes: { - native: { - image: { - sizes: '300x250' + if (FEATURES.NATIVE) { + let badNativeImgSize = [{ + code: 'testb4', + bids: [], + mediaTypes: { + native: { + image: { + sizes: '300x250' + } } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: badNativeImgSize - }); - expect(auctionArgs.adUnits[0].mediaTypes.native.image.sizes).to.be.undefined; - expect(auctionArgs.adUnits[0].mediaTypes.native.image).to.exist; - assert.ok(logErrorSpy.calledWith('Please use an array of sizes for native.image.sizes field. Removing invalid mediaTypes.native.image.sizes property from request.')); - - let badNativeImgAspRat = [{ - code: 'testb5', - bids: [], - mediaTypes: { - native: { - image: { - aspect_ratios: '300x250' + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: badNativeImgSize + }); + expect(auctionArgs.adUnits[0].mediaTypes.native.image.sizes).to.be.undefined; + expect(auctionArgs.adUnits[0].mediaTypes.native.image).to.exist; + assert.ok(logErrorSpy.calledWith('Please use an array of sizes for native.image.sizes field. Removing invalid mediaTypes.native.image.sizes property from request.')); + + let badNativeImgAspRat = [{ + code: 'testb5', + bids: [], + mediaTypes: { + native: { + image: { + aspect_ratios: '300x250' + } } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: badNativeImgAspRat - }); - expect(auctionArgs.adUnits[0].mediaTypes.native.image.aspect_ratios).to.be.undefined; - expect(auctionArgs.adUnits[0].mediaTypes.native.image).to.exist; - assert.ok(logErrorSpy.calledWith('Please use an array of sizes for native.image.aspect_ratios field. Removing invalid mediaTypes.native.image.aspect_ratios property from request.')); - - let badNativeIcon = [{ - code: 'testb6', - bids: [], - mediaTypes: { - native: { - icon: { - sizes: '300x250' + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: badNativeImgAspRat + }); + expect(auctionArgs.adUnits[0].mediaTypes.native.image.aspect_ratios).to.be.undefined; + expect(auctionArgs.adUnits[0].mediaTypes.native.image).to.exist; + assert.ok(logErrorSpy.calledWith('Please use an array of sizes for native.image.aspect_ratios field. Removing invalid mediaTypes.native.image.aspect_ratios property from request.')); + + let badNativeIcon = [{ + code: 'testb6', + bids: [], + mediaTypes: { + native: { + icon: { + sizes: '300x250' + } } } - } - }]; - $$PREBID_GLOBAL$$.requestBids({ - adUnits: badNativeIcon - }); - expect(auctionArgs.adUnits[0].mediaTypes.native.icon.sizes).to.be.undefined; - expect(auctionArgs.adUnits[0].mediaTypes.native.icon).to.exist; - assert.ok(logErrorSpy.calledWith('Please use an array of sizes for native.icon.sizes field. Removing invalid mediaTypes.native.icon.sizes property from request.')); + }]; + $$PREBID_GLOBAL$$.requestBids({ + adUnits: badNativeIcon + }); + expect(auctionArgs.adUnits[0].mediaTypes.native.icon.sizes).to.be.undefined; + expect(auctionArgs.adUnits[0].mediaTypes.native.icon).to.exist; + assert.ok(logErrorSpy.calledWith('Please use an array of sizes for native.icon.sizes field. Removing invalid mediaTypes.native.icon.sizes property from request.')); + } }); it('should throw error message and remove adUnit if adUnit.bids is not defined correctly', function () { @@ -2058,6 +2429,9 @@ describe('Unit: Prebid Module', function () { }); describe('multiformat requests', function () { + if (!FEATURES.NATIVE) { + return; + } let adUnits; beforeEach(function () { @@ -2109,6 +2483,9 @@ describe('Unit: Prebid Module', function () { }); describe('part 2', function () { + if (!FEATURES.NATIVE) { + return; + } let spyCallBids; let createAuctionStub; let adUnits; @@ -2123,7 +2500,6 @@ describe('Unit: Prebid Module', function () { }]; let adUnitCodes = ['adUnit-code']; let auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: timeout}); - adUnits[0]['mediaTypes'] = { native: {} }; adUnitCodes = ['adUnit-code']; let auction1 = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: timeout}); @@ -2176,7 +2552,7 @@ describe('Unit: Prebid Module', function () { it('splits native type to individual native assets', function () { let adUnits = [{ code: 'adUnit-code', - mediaTypes: { native: { type: 'image' } }, + mediaTypes: {native: {type: 'image'}}, bids: [ {bidder: 'appnexus', params: {placementId: 'id'}} ] @@ -2184,14 +2560,47 @@ describe('Unit: Prebid Module', function () { $$PREBID_GLOBAL$$.requestBids({adUnits}); const spyArgs = adapterManager.callBids.getCall(0); const nativeRequest = spyArgs.args[1][0].bids[0].nativeParams; - expect(nativeRequest).to.deep.equal({ - image: {required: true}, - title: {required: true}, - sponsoredBy: {required: true}, - clickUrl: {required: true}, - body: {required: false}, - icon: {required: false}, - }); + expect(nativeRequest.ortb.assets).to.deep.equal([ + { + required: 1, + id: 1, + img: { + type: 3, + wmin: 100, + hmin: 100, + } + }, + { + required: 1, + id: 2, + title: { + len: 140, + } + }, + { + required: 1, + id: 3, + data: { + type: 1, + } + }, + { + required: 0, + id: 4, + data: { + type: 2, + } + }, + { + required: 0, + id: 5, + img: { + type: 1, + wmin: 20, + hmin: 20, + } + }, + ]); resetAuction(); }); }); @@ -2628,6 +3037,20 @@ describe('Unit: Prebid Module', function () { }); }); + describe('aliasRegistry', function () { + it('should return the same value as adapterManager.aliasRegistry by default', function () { + const adapterManagerAliasRegistry = adapterManager.aliasRegistry; + const pbjsAliasRegistry = $$PREBID_GLOBAL$$.aliasRegistry; + assert.equal(adapterManagerAliasRegistry, pbjsAliasRegistry); + }); + + it('should return undefined if the aliasRegistry config option is set to private', function () { + configObj.setConfig({ aliasRegistry: 'private' }); + const pbjsAliasRegistry = $$PREBID_GLOBAL$$.aliasRegistry; + assert.equal(pbjsAliasRegistry, undefined); + }); + }); + describe('setPriceGranularity', function () { it('should log error when not passed granularity', function () { const logErrorSpy = sinon.spy(utils, 'logError'); @@ -2923,69 +3346,60 @@ describe('Unit: Prebid Module', function () { }); }); - describe('markWinningBidAsUsed', function () { - it('marks the bid object as used for the given adUnitCode/adId combination', function () { - // make sure the auction has "state" and does not reload the fixtures + if (FEATURES.VIDEO) { + describe('markWinningBidAsUsed', function () { const adUnitCode = '/19968336/header-bid-tag-0'; - const bidsReceived = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode); - auction.getBidsReceived = function() { return bidsReceived.bids }; + let winningBid; - // mark the bid and verify the state has changed to RENDERED - const winningBid = targeting.getWinningBids(adUnitCode)[0]; - $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode, adId: winningBid.adId }); - const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, - bid => bid.adId === winningBid.adId); + beforeEach(() => { + const bidsReceived = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode); + auction.getBidsReceived = function() { return bidsReceived.bids }; - expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED); - resetAuction(); - }); + // mark the bid and verify the state has changed to RENDERED + winningBid = targeting.getWinningBids(adUnitCode)[0]; + auction.getAuctionId = function() { return winningBid.auctionId }; + }) - it('try and mark the bid object, but fail because we supplied the wrong adId', function () { - const adUnitCode = '/19968336/header-bid-tag-0'; - const bidsReceived = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode); - auction.getBidsReceived = function() { return bidsReceived.bids }; + afterEach(() => { + resetAuction(); + }) - const winningBid = targeting.getWinningBids(adUnitCode)[0]; - $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode, adId: 'miss' }); - const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, - bid => bid.adId === winningBid.adId); + it('marks the bid object as used for the given adUnitCode/adId combination', function () { + // make sure the auction has "state" and does not reload the fixtures + $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode, adId: winningBid.adId }); + const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, + bid => bid.adId === winningBid.adId); - expect(markedBid.status).to.not.equal(CONSTANTS.BID_STATUS.RENDERED); - resetAuction(); - }); + expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED); + }); - it('marks the winning bid object as used for the given adUnitCode', function () { - // make sure the auction has "state" and does not reload the fixtures - const adUnitCode = '/19968336/header-bid-tag-0'; - const bidsReceived = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode); - auction.getBidsReceived = function() { return bidsReceived.bids }; + it('try and mark the bid object, but fail because we supplied the wrong adId', function () { + $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode, adId: 'miss' }); + const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, + bid => bid.adId === winningBid.adId); - // mark the bid and verify the state has changed to RENDERED - const winningBid = targeting.getWinningBids(adUnitCode)[0]; - $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode }); - const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, - bid => bid.adId === winningBid.adId); + expect(markedBid.status).to.not.equal(CONSTANTS.BID_STATUS.RENDERED); + }); - expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED); - resetAuction(); - }); + it('marks the winning bid object as used for the given adUnitCode', function () { + // make sure the auction has "state" and does not reload the fixtures + $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode }); + const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, + bid => bid.adId === winningBid.adId); - it('marks a bid object as used for the given adId', function () { - // make sure the auction has "state" and does not reload the fixtures - const adUnitCode = '/19968336/header-bid-tag-0'; - const bidsReceived = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode); - auction.getBidsReceived = function() { return bidsReceived.bids }; + expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED); + }); - // mark the bid and verify the state has changed to RENDERED - const winningBid = targeting.getWinningBids(adUnitCode)[0]; - $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adId: winningBid.adId }); - const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, - bid => bid.adId === winningBid.adId); + it('marks a bid object as used for the given adId', function () { + // make sure the auction has "state" and does not reload the fixtures + $$PREBID_GLOBAL$$.markWinningBidAsUsed({ adId: winningBid.adId }); + const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids, + bid => bid.adId === winningBid.adId); - expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED); - resetAuction(); + expect(markedBid.status).to.equal(CONSTANTS.BID_STATUS.RENDERED); + }); }); - }); + } describe('setTargetingForAst', function () { let targeting; @@ -3119,4 +3533,63 @@ describe('Unit: Prebid Module', function () { expect(bids[0].adId).to.equal('adid-1'); }); }); + + describe('deferred billing', function () { + const sandbox = sinon.createSandbox(); + + let adUnits = [ + { + code: 'adUnit-code-1', + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, + transactionId: '1234567890', + bids: [ + { bidder: 'pubmatic', params: {placementId: '10433394'}, adUnitCode: 'adUnit-code-1' } + ] + }, + { + code: 'adUnit-code-2', + deferBilling: true, + mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } }, + transactionId: '0987654321', + bids: [ + { bidder: 'pubmatic', params: {placementId: '10433394'}, adUnitCode: 'adUnit-code-2' } + ] + } + ]; + + let winningBid1 = { adapterCode: 'pubmatic', bidder: 'pubmatic', params: {placementId: '10433394'}, adUnitCode: 'adUnit-code-1', transactionId: '1234567890', adId: 'abcdefg' } + let winningBid2 = { adapterCode: 'pubmatic', bidder: 'pubmatic', params: {placementId: '10433394'}, adUnitCode: 'adUnit-code-2', transactionId: '0987654321' } + let adUnitCodes = ['adUnit-code-1', 'adUnit-code-2']; + let auction = auctionModule.newAuction({adUnits, adUnitCodes, callback: function() {}, cbTimeout: 2000}); + + beforeEach(function () { + sandbox.spy(adapterManager, 'callBidWonBidder'); + sandbox.spy(adapterManager, 'callBidBillableBidder'); + sandbox.stub(auctionManager, 'getBidsReceived').returns([winningBid1]); + }); + + afterEach(function () { + sandbox.resetHistory(); + sandbox.restore(); + }); + + it('should by default invoke callBidWonBidder and callBidBillableBidder', function () { + auction.addWinningBid(winningBid1); + sinon.assert.calledOnce(adapterManager.callBidWonBidder); + sinon.assert.calledOnce(adapterManager.callBidBillableBidder); + }); + + it('should only invoke callBidWonBidder and NOT callBidBillableBidder if deferBilling is present and true within the winning adUnit object', function () { + auction.addWinningBid(winningBid2); + sinon.assert.calledOnce(adapterManager.callBidWonBidder); + sinon.assert.notCalled(adapterManager.callBidBillableBidder); + }); + + it('should invoke callBidBillableBidder when pbjs.triggerBilling is invoked', function () { + $$PREBID_GLOBAL$$.triggerBilling(winningBid1); + sinon.assert.calledOnce(auctionManager.getBidsReceived); + sinon.assert.notCalled(adapterManager.callBidWonBidder); + sinon.assert.calledOnce(adapterManager.callBidBillableBidder); + }); + }); }); diff --git a/test/spec/unit/secureCreatives_spec.js b/test/spec/unit/secureCreatives_spec.js index e3dc21ffd92..7d5f9af35dd 100644 --- a/test/spec/unit/secureCreatives_spec.js +++ b/test/spec/unit/secureCreatives_spec.js @@ -1,7 +1,6 @@ import { _sendAdToCreative, getReplier, receiveMessage } from 'src/secureCreatives.js'; -import * as secureCreatives from 'src/secureCreatives.js'; import * as utils from 'src/utils.js'; import {getAdUnits, getBidRequests, getBidResponses} from 'test/fixtures/fixtures.js'; import {auctionManager} from 'src/auctionManager.js'; @@ -164,6 +163,7 @@ describe('secureCreatives', () => { stubGetAllAssetsMessage.restore(); stubEmit.restore(); resetAuction(); + adResponse.adId = bidId; }); describe('Prebid Request', function() { @@ -308,36 +308,11 @@ describe('secureCreatives', () => { }); describe('Prebid Native', function() { - it('Prebid native should render', function () { - pushBidResponseToAuction({}); - - const data = { - adId: bidId, - message: 'Prebid Native', - action: 'allAssetRequest' - }; - - const ev = makeEvent({ - data: JSON.stringify(data), - source: { - postMessage: sinon.stub() - }, - origin: 'any origin' - }); - - receiveMessage(ev); - - sinon.assert.neverCalledWith(spyLogWarn, warning); - sinon.assert.calledOnce(stubGetAllAssetsMessage); - sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); - sinon.assert.calledOnce(ev.source.postMessage); - sinon.assert.notCalled(stubFireNativeTrackers); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); - sinon.assert.notCalled(spyAddWinningBid); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); - }); + if (!FEATURES.NATIVE) { + return; + } - it('Prebid native should allow stale rendering without config', function () { + it('Prebid native should render', function () { pushBidResponseToAuction({}); const data = { @@ -361,31 +336,17 @@ describe('secureCreatives', () => { sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); sinon.assert.calledOnce(ev.source.postMessage); sinon.assert.notCalled(stubFireNativeTrackers); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); - sinon.assert.notCalled(spyAddWinningBid); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); - - resetHistories(ev.source.postMessage); - - receiveMessage(ev); - - sinon.assert.neverCalledWith(spyLogWarn, warning); - sinon.assert.calledOnce(stubGetAllAssetsMessage); - sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); - sinon.assert.calledOnce(ev.source.postMessage); - sinon.assert.notCalled(stubFireNativeTrackers); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); - sinon.assert.notCalled(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); }); - it('Prebid native should allow stale rendering with config', function () { - configObj.setConfig({'auctionOptions': {'suppressStaleRender': true}}); - - pushBidResponseToAuction({}); + it('Prebid native should not fire BID_WON when receiveMessage is called more than once', () => { + let adId = 3; + pushBidResponseToAuction({ adId }); const data = { - adId: bidId, + adId: adId, message: 'Prebid Native', action: 'allAssetRequest' }; @@ -399,37 +360,18 @@ describe('secureCreatives', () => { }); receiveMessage(ev); - - sinon.assert.neverCalledWith(spyLogWarn, warning); - sinon.assert.calledOnce(stubGetAllAssetsMessage); - sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); - sinon.assert.calledOnce(ev.source.postMessage); - sinon.assert.notCalled(stubFireNativeTrackers); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); - sinon.assert.notCalled(spyAddWinningBid); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); - - resetHistories(ev.source.postMessage); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); receiveMessage(ev); - - sinon.assert.neverCalledWith(spyLogWarn, warning); - sinon.assert.calledOnce(stubGetAllAssetsMessage); - sinon.assert.calledWith(stubGetAllAssetsMessage, data, adResponse); - sinon.assert.calledOnce(ev.source.postMessage); - sinon.assert.notCalled(stubFireNativeTrackers); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); - sinon.assert.notCalled(spyAddWinningBid); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.STALE_RENDER); - - configObj.setConfig({'auctionOptions': {}}); + stubEmit.withArgs(CONSTANTS.EVENTS.BID_WON, adResponse).calledOnce; }); it('Prebid native should fire trackers', function () { - pushBidResponseToAuction({}); + let adId = 2; + pushBidResponseToAuction({adId}); const data = { - adId: bidId, + adId: adId, message: 'Prebid Native', action: 'click', }; @@ -446,8 +388,8 @@ describe('secureCreatives', () => { sinon.assert.neverCalledWith(spyLogWarn, warning); sinon.assert.calledOnce(stubFireNativeTrackers); - sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); - sinon.assert.notCalled(spyAddWinningBid); + sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); + sinon.assert.calledOnce(spyAddWinningBid); resetHistories(ev.source.postMessage); @@ -457,8 +399,8 @@ describe('secureCreatives', () => { sinon.assert.neverCalledWith(spyLogWarn, warning); sinon.assert.calledOnce(stubFireNativeTrackers); - sinon.assert.calledWith(stubEmit, CONSTANTS.EVENTS.BID_WON, adResponse); - sinon.assert.calledOnce(spyAddWinningBid); + sinon.assert.neverCalledWith(stubEmit, CONSTANTS.EVENTS.BID_WON); + sinon.assert.notCalled(spyAddWinningBid); expect(adResponse).to.have.property('status', CONSTANTS.BID_STATUS.RENDERED); }); diff --git a/test/spec/unit/utils/cpm_spec.js b/test/spec/unit/utils/cpm_spec.js new file mode 100644 index 00000000000..7d63c53525e --- /dev/null +++ b/test/spec/unit/utils/cpm_spec.js @@ -0,0 +1,119 @@ +import {adjustCpm} from '../../../../src/utils/cpm.js'; +import {ScopedSettings} from '../../../../src/bidderSettings.js'; +import {expect} from 'chai/index.js'; + +describe('adjustCpm', () => { + const bidderCode = 'mockBidder'; + let adjustmentFn, bs, index; + beforeEach(() => { + bs = { + get: sinon.stub(), + getOwn: sinon.stub() + } + index = { + getBidRequest: sinon.stub() + } + adjustmentFn = sinon.stub().callsFake((cpm) => cpm * 2); + }) + + it('throws when neither bidRequest nor bidResponse are provided', () => { + expect(() => adjustCpm(1)).to.throw(); + }) + + it('always provides an object as bidResponse for the adjustment fn', () => { + bs.get.callsFake(() => adjustmentFn); + adjustCpm(1, null, {bidder: bidderCode}, {index, bs}); + sinon.assert.calledWith(adjustmentFn, 1, {}); + }); + + describe('when no bidRequest is provided', () => { + Object.entries({ + 'unavailable': undefined, + 'found': {foo: 'bar'} + }).forEach(([t, req]) => { + describe(`and it is ${t} in the index`, () => { + beforeEach(() => { + bs.get.callsFake(() => adjustmentFn); + index.getBidRequest.callsFake(() => req) + }); + + it('provides it to the adjustment fn', () => { + const bidResponse = {bidderCode}; + adjustCpm(1, bidResponse, undefined, {index, bs}); + sinon.assert.calledWith(index.getBidRequest, bidResponse); + sinon.assert.calledWith(adjustmentFn, 1, bidResponse, req); + }) + }) + }) + }); + + Object.entries({ + 'bidResponse': [{bidderCode}], + 'bidRequest': [null, {bidder: bidderCode}], + }).forEach(([t, [bidResp, bidReq]]) => { + describe(`when passed ${t}`, () => { + beforeEach(() => { + bs.get.callsFake((bidder) => { if (bidder === bidderCode) return adjustmentFn }); + }); + it('retrieves the correct bidder code', () => { + expect(adjustCpm(1, bidResp, bidReq, {bs, index})).to.eql(2); + }); + it('passes them to the adjustment fn', () => { + adjustCpm(1, bidResp, bidReq, {bs, index}); + sinon.assert.calledWith(adjustmentFn, 1, bidResp == null ? sinon.match.any : bidResp, bidReq); + }); + }); + }) +}); + +describe('adjustAlternateBids', () => { + let bs; + afterEach(() => { + bs = null; + }); + + function runAdjustment(cpm, bidderCode, adapterCode) { + return adjustCpm(cpm, {bidderCode, adapterCode}, null, {bs: new ScopedSettings(() => bs)}); + } + + it('should fall back to the adapter adjustment fn when adjustAlternateBids is true', () => { + bs = { + adapter: { + adjustAlternateBids: true, + bidCpmAdjustment: function (cpm) { + return cpm * 2; + } + }, + bidder: {} + }; + expect(runAdjustment(1, 'bidder', 'adapter')).to.eql(2); + }); + + it('should NOT fall back to the adapter adjustment fn when adjustAlternateBids is not true', () => { + bs = { + adapter: { + bidCpmAdjustment(cpm) { + return cpm * 2 + } + } + } + expect(runAdjustment(1, 'bidder', 'adapter')).to.eql(1); + }); + + it('should prioritize bidder adjustment fn', () => { + bs = { + adapter: { + adjustAlternateBids: true, + bidCpmAdjustment(cpm) { + return cpm * 2 + } + }, + bidder: { + bidCpmAdjustment(cpm) { + return cpm * 3 + } + } + } + expect(runAdjustment(1, 'bidder', 'adapter')).to.eql(3); + }); +}); diff --git a/test/spec/unit/utils/perfMetrics_spec.js b/test/spec/unit/utils/perfMetrics_spec.js new file mode 100644 index 00000000000..4ce3336e030 --- /dev/null +++ b/test/spec/unit/utils/perfMetrics_spec.js @@ -0,0 +1,394 @@ +import {CONFIG_TOGGLE, metricsFactory, newMetrics, useMetrics} from '../../../../src/utils/perfMetrics.js'; +import {defer} from '../../../../src/utils/promise.js'; +import {hook} from '../../../../src/hook.js'; +import {config} from 'src/config.js'; + +describe('metricsFactory', () => { + let metrics, now, enabled, newMetrics; + + beforeEach(() => { + now = 0; + newMetrics = metricsFactory({now: () => now}); + metrics = newMetrics(); + }); + + it('can measure time with startTiming', () => { + now = 10; + const measure = metrics.startTiming('test'); + now = 25.2; + measure(); + expect(metrics.getMetrics()).to.eql({ + test: 15.2 + }); + }); + + describe('measureTime', () => { + it('can measure time', () => { + metrics.measureTime('test', () => now += 3); + expect(metrics.getMetrics()).to.eql({ + test: 3 + }) + }); + + it('still measures if fn throws', () => { + expect(() => { + metrics.measureTime('test', () => { + now += 4; + throw new Error(); + }); + }).to.throw(); + expect(metrics.getMetrics()).to.eql({ + test: 4 + }); + }) + }); + + describe('measureHookTime', () => { + let testHook; + before(() => { + testHook = hook('sync', () => null, 0, 'testName'); + hook.ready(); + }); + beforeEach(() => { + testHook.getHooks().remove(); + }); + + ['before', 'after'].forEach(hookType => { + describe(`on ${hookType} hooks`, () => { + Object.entries({ + next: (n) => n, + bail: (n) => n.bail + }).forEach(([t, fn]) => { + it(`can time when hooks call ${t}`, () => { + const q = defer(); + testHook[hookType]((next) => { + metrics.measureHookTime('test', next, (next) => { + setTimeout(() => { + now += 10; + fn(next)(); + q.resolve(); + }) + }) + }); + testHook(); + return q.promise.then(() => { + expect(metrics.getMetrics()).to.eql({ + test: 10 + }); + }) + }); + }); + }) + }) + }); + + describe('checkpoints', () => { + it('can measure time from checkpoint with timeSince', () => { + now = 10; + metrics.checkpoint('A'); + now = 15; + expect(metrics.timeSince('A')).to.eql(5); + }); + + it('timeSince is null if checkpoint does not exist', () => { + expect(metrics.timeSince('missing')).to.equal(null); + }); + + it('timeSince saves a metric if given a name', () => { + now = 10; + metrics.checkpoint('A'); + now = 15; + metrics.timeSince('A', 'test'); + expect(metrics.getMetrics()).to.eql({test: 5}); + }); + + it('can measure time between checkpoints with timeBetween', () => { + now = 10; + metrics.checkpoint('A'); + now = 15; + metrics.checkpoint('B'); + now = 20; + expect(metrics.timeBetween('A', 'B')).to.eql(5); + }); + + Object.entries({ + 'first checkpoint': [false, true], + 'second checkpoint': [true, false], + 'both checkpoints': [false, false] + }).forEach(([t, [checkFirst, checkSecond]]) => { + it(`timeBetween measures to null if missing ${t}`, () => { + if (checkFirst) { + metrics.checkpoint('A'); + } + if (checkSecond) { + metrics.checkpoint('B'); + } + expect(metrics.timeBetween('A', 'B')).to.equal(null) + }) + }); + + it('saves a metric with timeBetween if given a name', () => { + now = 10; + metrics.checkpoint('A'); + now = 15; + metrics.checkpoint('B'); + metrics.timeBetween('A', 'B', 'test'); + expect(metrics.getMetrics()).to.eql({test: 5}); + }); + }); + + describe('setMetrics', () => { + it('sets metric', () => { + metrics.setMetric('test', 1); + expect(metrics.getMetrics()).to.eql({test: 1}); + }); + }); + + describe('fork', () => { + it('keeps metrics from ancestors', () => { + const m2 = metrics.fork(); + const m3 = m2.fork(); + metrics.setMetric('1', 'one'); + m2.setMetric('2', 'two'); + m3.setMetric('3', 'three'); + sinon.assert.match(metrics.getMetrics(), { + 1: 'one' + }) + sinon.assert.match(m2.getMetrics(), { + 1: 'one', + 2: 'two' + }); + sinon.assert.match(m3.getMetrics(), { + 1: 'one', + 2: 'two', + 3: 'three' + }); + }); + + it('keeps checkpoints from ancestors', () => { + const m2 = metrics.fork(); + const m3 = m2.fork(); + now = 10; + metrics.checkpoint('1'); + now = 20; + m2.checkpoint('2'); + now = 30; + m3.checkpoint('3'); + now = 40; + expect(m2.timeSince('1')).to.eql(30); + expect(m3.timeSince('2')).to.eql(20); + }); + + it('groups metrics into ancestors', () => { + const c1 = metrics.fork().fork(); + const c2 = metrics.fork().fork(); + c1.setMetric('test', 10); + c2.setMetric('test', 20); + expect(metrics.getMetrics().test).to.eql([10, 20]); + }); + + it('does not group metrics into ancestors if the name clashes', () => { + metrics.setMetric('test', {}); + metrics.fork().setMetric('test', 1); + expect(metrics.getMetrics().test).to.eql({}); + }); + + it('does not propagate further if stopPropagation = true', () => { + const c1 = metrics.fork(); + const c2 = c1.fork({stopPropagation: true}); + c2.setMetric('test', 1); + expect(c1.getMetrics().test).to.eql([1]); + expect(metrics.getMetrics().test).to.not.exist; + }); + + it('does not propagate at all if propagate = false', () => { + metrics.fork({propagate: false}).setMetric('test', 1); + expect(metrics.getMetrics()).to.eql({}); + }); + + it('replicates grouped metrics if includeGroups = true', () => { + const child = metrics.fork({includeGroups: true}); + metrics.fork().setMetric('test', 1); + expect(child.getMetrics()).to.eql({ + test: [1] + }); + }) + }); + + describe('join', () => { + let other; + beforeEach(() => { + other = newMetrics(); + }); + + it('joins metrics', () => { + metrics.setMetric('test', 1); + metrics.join(other); + expect(other.getMetrics()).to.eql({ + test: 1 + }); + }); + + it('joins checkpoints', () => { + now = 10; + metrics.checkpoint('test'); + metrics.join(other); + now = 20; + expect(other.timeSince('test')).to.eql(10); + }) + + it('groups metrics after joining', () => { + metrics.join(other); + other.setMetric('test', 1); + expect(metrics.getMetrics().test).to.eql([1]); + }); + + it('gives precedence to first join\'s metrics', () => { + metrics.join(other); + const metrics2 = newMetrics(); + metrics2.join(other); + metrics.setMetric('test', 1); + metrics2.setMetric('test', 2); + expect(other.getMetrics()).to.eql({ + test: 1 + }); + }); + + it('gives precedence to first joins\'s checkpoints', () => { + metrics.join(other); + const metrics2 = newMetrics(); + metrics2.join(other); + now = 10; + metrics.checkpoint('testcp'); + now = 20; + metrics2.checkpoint('testcp'); + now = 30; + expect(other.timeSince('testcp')).to.eql(20); + }); + + it('does not propagate further if stopPropagation = true', () => { + const m2 = metrics.fork(); + m2.join(other, {stopPropagation: true}); + other.setMetric('test', 1); + expect(m2.getMetrics().test).to.eql([1]); + expect(metrics.getMetrics()).to.eql({}); + }); + + it('does not propagate at all if propagate = false', () => { + metrics.join(other, {propagate: false}); + other.setMetric('test', 1); + expect(metrics.getMetrics()).to.eql({}); + }); + + it('replicates grouped metrics if includeGroups = true', () => { + const m2 = metrics.fork(); + metrics.join(other, {includeGroups: true}); + m2.setMetric('test', 1); + expect(other.getMetrics()).to.eql({ + test: [1] + }); + }) + + Object.entries({ + 'join with a common ancestor': () => [metrics.fork(), metrics.fork()], + 'join with self': () => [metrics, metrics], + }).forEach(([t, makePair]) => { + it(`can ${t}`, () => { + const [m1, m2] = makePair(); + m1.join(m2); + m1.setMetric('test', 1); + const expected = {'test': 1}; + expect(m1.getMetrics()).to.eql(expected); + expect(m2.getMetrics()).to.eql(expected); + }) + }); + + it('can join into a cycle', () => { + const c = metrics.fork(); + c.join(metrics); + c.setMetric('child', 1); + metrics.setMetric('parent', 1); + expect(c.getMetrics()).to.eql({ + child: 1, + parent: [1] + }) + expect(metrics.getMetrics()).to.eql({ + parent: 1, + child: [1] + }) + }); + }); + describe('newMetrics', () => { + it('returns related, but independent, metrics', () => { + const m0 = metrics.newMetrics(); + const m1 = newMetrics(); + m1.join(m0); + m0.setMetric('m0', 1); + m1.setMetric('m1', 1); + expect(metrics.getMetrics()).to.eql({}); + expect(m0.getMetrics()).to.eql({ + m0: 1, + m1: 1 + }) + }) + }) +}) + +describe('nullMetrics', () => { + let nullMetrics; + beforeEach(() => { + nullMetrics = useMetrics(null); + }); + + Object.entries({ + 'stopBefore': (fn) => nullMetrics.startTiming('n').stopBefore(fn), + 'stopAfter': (fn) => nullMetrics.startTiming('n').stopAfter(fn), + 'measureTime': (fn) => (...args) => nullMetrics.measureTime('n', () => fn(...args)), + 'measureHookTime': (fn) => (...args) => nullMetrics.measureHookTime('n', {}, () => fn(...args)) + }).forEach(([t, wrapFn]) => { + describe(t, () => { + it('invokes the wrapped fn', () => { + const fn = sinon.stub(); + wrapFn(fn)('one', 'two'); + sinon.assert.calledWith(fn, 'one', 'two'); + }); + it('does not register timing metrics', () => { + wrapFn(sinon.stub())(); + expect(nullMetrics.getMetrics()).to.eql({}); + }) + }) + }); + + it('does not save checkpoints', () => { + nullMetrics.checkpoint('A'); + expect(nullMetrics.timeSince('A')).to.equal(null); + }); + + it('does not save metrics', () => { + nullMetrics.setMetric('test', 1); + expect(nullMetrics.getMetrics()).to.eql({}); + }); +}) + +describe('configuration toggle', () => { + afterEach(() => { + config.resetConfig(); + }); + + Object.entries({ + 'useMetrics': () => useMetrics(metricsFactory()()), + 'newMetrics': newMetrics + }).forEach(([t, mkMetrics]) => { + it(`${t} returns no-op metrics when disabled`, () => { + config.setConfig({[CONFIG_TOGGLE]: false}); + const metrics = mkMetrics(); + metrics.setMetric('test', 'value'); + expect(metrics.getMetrics()).to.eql({}); + }); + it(`returns actual metrics by default`, () => { + const metrics = mkMetrics(); + metrics.setMetric('test', 'value'); + expect(metrics.getMetrics()).to.eql({test: 'value'}); + }); + }); +}); diff --git a/test/spec/unit/utils/promise_spec.js b/test/spec/unit/utils/promise_spec.js new file mode 100644 index 00000000000..bd8b0390b2e --- /dev/null +++ b/test/spec/unit/utils/promise_spec.js @@ -0,0 +1,208 @@ +import {GreedyPromise, defer} from '../../../../src/utils/promise.js'; + +describe('GreedyPromise', () => { + it('throws when resolver is not a function', () => { + expect(() => new GreedyPromise()).to.throw(); + }) + + Object.entries({ + 'resolved': (use) => new GreedyPromise((resolve) => use(resolve)), + 'rejected': (use) => new GreedyPromise((_, reject) => use(reject)) + }).forEach(([t, makePromise]) => { + it(`runs callbacks immediately when ${t}`, () => { + let cbRan = false; + const cb = () => { cbRan = true }; + let resolver; + makePromise((fn) => { resolver = fn }).then(cb, cb); + resolver(); + expect(cbRan).to.be.true; + }) + }); + + describe('idioms', () => { + let makePromise, pendingFailure, pendingSuccess; + + Object.entries({ + // eslint-disable-next-line no-throw-literal + 'resolver that throws': (P) => new P(() => { throw 'error' }), + 'resolver that resolves multiple times': (P) => new P((resolve) => { resolve('first'); resolve('second'); }), + 'resolver that rejects multiple times': (P) => new P((resolve, reject) => { reject('first'); reject('second') }), + 'resolver that resolves and rejects': (P) => new P((resolve, reject) => { reject('first'); resolve('second') }), + 'resolver that resolves with multiple arguments': (P) => new P((resolve) => resolve('one', 'two')), + 'resolver that rejects with multiple arguments': (P) => new P((resolve, reject) => reject('one', 'two')), + 'resolver that resolves to a promise': (P) => new P((resolve) => resolve(makePromise(P, 'val'))), + 'resolver that resolves to a promise that resolves to a promise': (P) => new P((resolve) => resolve(makePromise(P, makePromise(P, 'val')))), + 'resolver that resolves to a rejected promise': (P) => new P((resolve) => resolve(makePromise(P, 'err', true))), + 'simple .then': (P) => makePromise(P, 'value').then((v) => `${v} and then`), + 'chained .then': (P) => makePromise(P, 'value').then((v) => makePromise(P, `${v} and then`)), + '.then with error handler': (P) => makePromise(P, 'err', true).then(null, (e) => `${e} and then`), + '.then with chained error handler': (P) => makePromise(P, 'err', true).then(null, (e) => makePromise(P, `${e} and then`)), + '.then that throws': (P) => makePromise(P, 'value').then((v) => { throw v }), + '.then that throws in error handler': (P) => makePromise(P, 'err', true).then(null, (e) => { throw e }), + '.then with no args': (P) => makePromise(P, 'value').then(), + '.then that rejects': (P) => makePromise(P, 'value').then((v) => P.reject(v)), + '.then that rejects in error handler': (P) => makePromise(P, 'err', true).then(null, (err) => P.reject(err)), + '.then with no error handler on a rejection': (P) => makePromise(P, 'err', true).then((v) => `resolved ${v}`), + '.then with no success handler on a resolution': (P) => makePromise(P, 'value').then(null, (e) => `caught ${e}`), + 'simple .catch': (P) => makePromise(P, 'err', true).catch((err) => `caught ${err}`), + 'identity .catch': (P) => makePromise(P, 'err', true).catch((err) => err).then((v) => v), + '.catch that throws': (P) => makePromise(P, 'err', true).catch((err) => { throw err }), + 'chained .catch': (P) => makePromise(P, 'err', true).catch((err) => makePromise(P, err)), + 'chained .catch that rejects': (P) => makePromise(P, 'err', true).catch((err) => P.reject(`reject with ${err}`)), + 'simple .finally': (P) => { + let fval; + return makePromise(P, 'value') + .finally(() => fval = 'finally ran') + .then((val) => `${val} ${fval}`) + }, + 'chained .finally': (P) => { + let fval; + return makePromise(P, 'value') + .finally(() => pendingSuccess.then(() => { fval = 'finally ran' })) + .then((val) => `${val} ${fval}`) + }, + '.finally on a rejection': (P) => { + let fval; + return makePromise(P, 'error', true) + .finally(() => { fval = 'finally' }) + .catch((err) => `${err} ${fval}`) + }, + 'chained .finally on a rejection': (P) => { + let fval; + return makePromise(P, 'error', true) + .finally(() => pendingSuccess.then(() => { fval = 'finally' })) + .catch((err) => `${err} ${fval}`) + }, + // eslint-disable-next-line no-throw-literal + '.finally that throws': (P) => makePromise(P, 'value').finally(() => { throw 'error' }), + 'chained .finally that rejects': (P) => makePromise(P, 'value').finally(() => P.reject('error')), + 'scalar Promise.resolve': (P) => P.resolve('scalar'), + 'null Promise.resolve': (P) => P.resolve(null), + 'chained Promise.resolve': (P) => P.resolve(pendingSuccess), + 'chained Promise.resolve on failure': (P) => P.resolve(pendingFailure), + 'scalar Promise.reject': (P) => P.reject('scalar'), + 'chained Promise.reject': (P) => P.reject(pendingSuccess), + 'chained Promise.reject on failure': (P) => P.reject(pendingFailure), + 'simple Promise.all': (P) => P.all([makePromise(P, 'one'), makePromise(P, 'two')]), + 'empty Promise.all': (P) => P.all([]), + 'Promise.all with scalars': (P) => P.all([makePromise(P, 'one'), 'two']), + 'Promise.all with errors': (P) => P.all([makePromise(P, 'one'), makePromise(P, 'two'), makePromise(P, 'err', true)]), + 'Promise.allSettled': (P) => P.allSettled([makePromise(P, 'one', true), makePromise(P, 'two'), makePromise(P, 'three', true)]), + 'empty Promise.allSettled': (P) => P.allSettled([]), + 'Promise.allSettled with scalars': (P) => P.allSettled([makePromise(P, 'value'), 'scalar']), + 'Promise.race that succeeds': (P) => P.race([makePromise(P, 'error', true, 10), makePromise(P, 'success')]), + 'Promise.race that fails': (P) => P.race([makePromise(P, 'success', false, 10), makePromise(P, 'error', true)]), + 'Promise.race with scalars': (P) => P.race(['scalar', makePromise(P, 'success')]), + }).forEach(([t, op]) => { + describe(t, () => { + describe('when mixed with deferrals', () => { + beforeEach(() => { + makePromise = function(ctor, value, fail = false, delay = 0) { + // eslint-disable-next-line new-cap + return new ctor((resolve, reject) => { + setTimeout(() => fail ? reject(value) : resolve(value), delay) + }) + }; + pendingSuccess = makePromise(Promise, 'pending result', false, 10); + pendingFailure = makePromise(Promise, 'pending failure', true, 10); + }); + + it(`behaves like vanilla promises`, () => { + const vanilla = op(Promise); + const greedy = op(GreedyPromise); + // note that we are not using `allSettled` & co to resolve our promises, + // to avoid transformations those methods do under the hood + const {actual = {}, expected = {}} = {}; + return new Promise((resolve) => { + let pending = 2; + function collect(dest, slot) { + return function (value) { + dest[slot] = value; + pending--; + if (pending === 0) { + resolve() + } + } + } + vanilla.then(collect(expected, 'success'), collect(expected, 'failure')); + greedy.then(collect(actual, 'success'), collect(actual, 'failure')); + }).then(() => { + expect(actual).to.eql(expected); + }); + }); + + it(`once resolved, runs callbacks immediately`, () => { + const promise = op(GreedyPromise).catch(() => null); + return promise.then(() => { + let cbRan = false; + promise.then(() => { cbRan = true }); + expect(cbRan).to.be.true; + }); + }); + }); + + describe('when all promises involved are greedy', () => { + beforeEach(() => { + makePromise = function(ctor, value, fail = false, delay = 0) { + // eslint-disable-next-line new-cap + return new ctor((resolve, reject) => { + const run = () => fail ? reject(value) : resolve(value); + delay === 0 ? run() : setTimeout(run, delay); + }) + }; + pendingSuccess = makePromise(GreedyPromise, 'pending result'); + pendingFailure = makePromise(GreedyPromise, 'pending failure', true); + }); + + it('resolves immediately', () => { + let cbRan = false; + op(GreedyPromise).catch(() => null).then(() => { cbRan = true }); + expect(cbRan).to.be.true; + }); + }); + }); + }); + }); + + describe('.timeout', () => { + const timeout = GreedyPromise.timeout; + + it('should resolve immediately when ms is 0', () => { + let cbRan = false; + timeout(0.0).then(() => { cbRan = true }); + expect(cbRan).to.be.true; + }); + + it('should schedule timeout on ms > 0', (done) => { + let cbRan = false; + timeout(5).then(() => { cbRan = true }); + expect(cbRan).to.be.false; + setTimeout(() => { + expect(cbRan).to.be.true; + done(); + }, 10) + }); + }); +}); + +describe('promiseControls', () => { + Object.entries({ + 'resolve': (p) => p, + 'reject': (p) => p.then(() => 'wrong', (v) => v) + }).forEach(([method, transform]) => { + describe(method, () => { + it(`should ${method} the promise`, () => { + const ctl = defer(); + ctl[method]('result'); + return transform(ctl.promise).then((res) => expect(res).to.equal('result')); + }); + + it('should ignore calls after the first', () => { + const ctl = defer(); + ctl[method]('result'); + ctl[method]('other'); + return transform(ctl.promise).then((res) => expect(res).to.equal('result')); + }); + }); + }); +}); diff --git a/test/spec/unit/utils/reducers_spec.js b/test/spec/unit/utils/reducers_spec.js new file mode 100644 index 00000000000..95bf3b74041 --- /dev/null +++ b/test/spec/unit/utils/reducers_spec.js @@ -0,0 +1,124 @@ +import { + tiebreakCompare, + keyCompare, + simpleCompare, + minimum, + maximum, + getHighestCpm, + getOldestHighestCpmBid, getLatestHighestCpmBid, reverseCompare +} from '../../../../src/utils/reducers.js'; +import assert from 'assert'; + +describe('reducers', () => { + describe('simpleCompare', () => { + Object.entries({ + '<': [10, 20, -1], + '===': [123, 123, 0], + '>': [30, -10, 1] + }).forEach(([t, [a, b, expected]]) => { + it(`returns ${expected} when a ${t} b`, () => { + expect(simpleCompare(a, b)).to.equal(expected); + }) + }) + }); + + describe('keyCompare', () => { + Object.entries({ + '<': [{k: -123}, {k: 0}, -1], + '===': [{k: 0}, {k: 0}, 0], + '>': [{k: 2}, {k: 1}, 1] + }).forEach(([t, [a, b, expected]]) => { + it(`returns ${expected} when key(a) ${t} key(b)`, () => { + expect(keyCompare(item => item.k)(a, b)).to.equal(expected); + }) + }) + }); + + describe('tiebreakCompare', () => { + Object.entries({ + 'first compare says a < b': [{main: 1, tie: 2}, {main: 2, tie: 1}, -1], + 'first compare says a > b': [{main: 2, tie: 1}, {main: 1, tie: 2}, 1], + 'first compare ties, second says a < b': [{main: 0, tie: 1}, {main: 0, tie: 2}, -1], + 'first compare ties, second says a > b': [{main: 0, tie: 2}, {main: 0, tie: 1}, 1], + 'all compares tie': [{main: 0, tie: 0}, {main: 0, tie: 0}, 0] + }).forEach(([t, [a, b, expected]]) => { + it(`should return ${expected} when ${t}`, () => { + const cmp = tiebreakCompare(keyCompare(item => item.main), keyCompare(item => item.tie)); + expect(cmp(a, b)).to.equal(expected); + }) + }) + }); + + const SAMPLE_ARR = [-10, 20, 20, 123, 400]; + + Object.entries({ + 'minimum': [minimum, ['minimum', -10], ['maximum', 400]], + 'maximum': [maximum, ['maximum', 400], ['minimum', -10]] + }).forEach(([t, [fn, simple, reversed]]) => { + describe(t, () => { + it(`should find ${simple[0]} using simple compare`, () => { + expect(SAMPLE_ARR.reduce(fn(simpleCompare))).to.equal(simple[1]); + }); + it(`should find ${reversed[0]} using reverse compare`, () => { + expect(SAMPLE_ARR.reduce(fn(reverseCompare()))).to.equal(reversed[1]); + }); + }) + }); + + describe('getHighestCpm', function () { + it('should pick the highest cpm', function () { + let a = { + cpm: 2, + timeToRespond: 100 + }; + let b = { + cpm: 1, + timeToRespond: 100 + }; + expect(getHighestCpm(a, b)).to.eql(a); + expect(getHighestCpm(b, a)).to.eql(a); + }); + + it('should pick the lowest timeToRespond cpm in case of tie', function () { + let a = { + cpm: 1, + timeToRespond: 100 + }; + let b = { + cpm: 1, + timeToRespond: 50 + }; + expect(getHighestCpm(a, b)).to.eql(b); + expect(getHighestCpm(b, a)).to.eql(b); + }); + }); + + describe('getOldestHighestCpmBid', () => { + it('should pick the oldest in case of tie using responseTimeStamp', function () { + let a = { + cpm: 1, + responseTimestamp: 1000 + }; + let b = { + cpm: 1, + responseTimestamp: 2000 + }; + expect(getOldestHighestCpmBid(a, b)).to.eql(a); + expect(getOldestHighestCpmBid(b, a)).to.eql(a); + }); + }); + describe('getLatestHighestCpmBid', () => { + it('should pick the latest in case of tie using responseTimeStamp', function () { + let a = { + cpm: 1, + responseTimestamp: 1000 + }; + let b = { + cpm: 1, + responseTimestamp: 2000 + }; + expect(getLatestHighestCpmBid(a, b)).to.eql(b); + expect(getLatestHighestCpmBid(b, a)).to.eql(b); + }); + }); +}) diff --git a/test/spec/unit/utils/ttlCollection_spec.js b/test/spec/unit/utils/ttlCollection_spec.js new file mode 100644 index 00000000000..29c6c438855 --- /dev/null +++ b/test/spec/unit/utils/ttlCollection_spec.js @@ -0,0 +1,180 @@ +import {ttlCollection} from '../../../../src/utils/ttlCollection.js'; + +describe('ttlCollection', () => { + it('can add & retrieve items', () => { + const coll = ttlCollection(); + expect(coll.toArray()).to.eql([]); + coll.add(1); + coll.add(2); + expect(coll.toArray()).to.eql([1, 2]); + }); + + it('can clear', () => { + const coll = ttlCollection(); + coll.add('item'); + coll.clear(); + expect(coll.toArray()).to.eql([]); + }); + + it('can be iterated over', () => { + const coll = ttlCollection(); + coll.add('1'); + coll.add('2'); + expect(Array.from(coll)).to.eql(['1', '2']); + }) + + describe('autopurge', () => { + let clock, pms, waitForPromises; + const SLACK = 2000; + beforeEach(() => { + clock = sinon.useFakeTimers(); + pms = []; + waitForPromises = () => Promise.all(pms); + }); + afterEach(() => { + clock.restore(); + }); + + Object.entries({ + 'defer': (value) => { + const pm = Promise.resolve(value); + pms.push(pm); + return pm; + }, + 'do not defer': (value) => value, + }).forEach(([t, resolve]) => { + describe(`when ttl/startTime ${t}`, () => { + let coll; + beforeEach(() => { + coll = ttlCollection({ + startTime: (item) => resolve(item.start == null ? new Date().getTime() : item.start), + ttl: (item) => resolve(item.ttl), + slack: SLACK + }) + }); + + it('should clear items after enough time has passed', () => { + coll.add({no: 'ttl'}); + coll.add({ttl: 1000}); + coll.add({ttl: 4000}); + return waitForPromises().then(() => { + clock.tick(500); + expect(coll.toArray()).to.eql([{no: 'ttl'}, {ttl: 1000}, {ttl: 4000}]); + clock.tick(SLACK + 500); + expect(coll.toArray()).to.eql([{no: 'ttl'}, {ttl: 4000}]); + clock.tick(3000); + expect(coll.toArray()).to.eql([{no: 'ttl'}]); + }); + }); + + it('should not wait too long if a shorter ttl shows up', () => { + coll.add({ttl: 4000}); + coll.add({ttl: 1000}); + return waitForPromises().then(() => { + clock.tick(1000 + SLACK); + expect(coll.toArray()).to.eql([ + {ttl: 4000} + ]); + }); + }); + + it('should not wait more if later ttls are within slack', () => { + coll.add({start: 0, ttl: 4000}); + return waitForPromises().then(() => { + clock.tick(4000); + coll.add({start: 0, ttl: 5000}); + return waitForPromises().then(() => { + clock.tick(SLACK); + expect(coll.toArray()).to.eql([]); + }); + }); + }); + + it('should clear items ASAP if they expire in the past', () => { + clock.tick(10000); + coll.add({start: 0, ttl: 1000}); + return waitForPromises().then(() => { + clock.tick(SLACK); + expect(coll.toArray()).to.eql([]); + }); + }); + + it('should clear items ASAP if they have ttl = 0', () => { + coll.add({ttl: 0}); + return waitForPromises().then(() => { + clock.tick(SLACK); + expect(coll.toArray()).to.eql([]); + }); + }); + + describe('refresh', () => { + it('should refresh missing TTLs', () => { + const item = {}; + coll.add(item); + return waitForPromises().then(() => { + item.ttl = 1000; + return waitForPromises().then(() => { + clock.tick(1000 + SLACK); + expect(coll.toArray()).to.eql([item]); + coll.refresh(); + return waitForPromises().then(() => { + clock.tick(1); + expect(coll.toArray()).to.eql([]); + }); + }); + }); + }); + + it('should refresh existing TTLs', () => { + const item = { + ttl: 1000 + }; + coll.add(item); + return waitForPromises().then(() => { + clock.tick(1000); + item.ttl = 4000; + coll.refresh(); + return waitForPromises().then(() => { + clock.tick(SLACK); + expect(coll.toArray()).to.eql([item]); + clock.tick(3000); + expect(coll.toArray()).to.eql([]); + }); + }); + }); + + it('should discard initial TTL if it does not resolve before a refresh', () => { + let resolveTTL; + const item = { + ttl: new Promise((resolve) => { + resolveTTL = resolve; + }) + }; + coll.add(item); + item.ttl = null; + coll.refresh(); + resolveTTL(1000); + return waitForPromises().then(() => { + clock.tick(1000 + SLACK + 1000); + expect(coll.toArray()).to.eql([item]); + }); + }); + + it('should discard TTLs on clear', () => { + const item = { + ttl: 1000 + }; + coll.add(item); + coll.clear(); + item.ttl = null; + coll.add(item); + return waitForPromises().then(() => { + clock.tick(1000 + SLACK + 1000); + expect(coll.toArray()).to.eql([item]); + }); + }); + }); + }); + }); + }); +}); diff --git a/test/spec/userSync_spec.js b/test/spec/userSync_spec.js index 910ffe7b2d6..c403014fcd6 100644 --- a/test/spec/userSync_spec.js +++ b/test/spec/userSync_spec.js @@ -1,5 +1,13 @@ import { expect } from 'chai'; import { config } from 'src/config.js'; +import {ruleRegistry} from '../../src/activities/rules.js'; +import {ACTIVITY_SYNC_USER} from '../../src/activities/activities.js'; +import { + ACTIVITY_PARAM_COMPONENT, + ACTIVITY_PARAM_SYNC_TYPE, + ACTIVITY_PARAM_SYNC_URL +} from '../../src/activities/params.js'; +import {MODULE_TYPE_BIDDER} from '../../src/activities/modules.js'; // Use require since we need to be able to write to these vars const utils = require('../../src/utils'); let { newUserSync, USERSYNC_DEFAULT_CONFIG } = require('../../src/userSync'); @@ -14,12 +22,18 @@ describe('user sync', function () { let idPrefix = 'test-generated-id-'; let lastId = 0; let defaultUserSyncConfig = config.getConfig('userSync'); - function getUserSyncConfig(userSyncConfig) { - return Object.assign({}, defaultUserSyncConfig, userSyncConfig); + let regRule, isAllowed; + + function mkUserSync(deps) { + [regRule, isAllowed] = ruleRegistry(); + return newUserSync(Object.assign({ + regRule, isAllowed + }, deps)) } + function newTestUserSync(configOverrides, disableBrowserCookies) { const thisConfig = Object.assign({}, defaultUserSyncConfig, configOverrides); - return newUserSync({ + return mkUserSync({ config: thisConfig, browserSupportsCookies: !disableBrowserCookies, }) @@ -59,6 +73,22 @@ describe('user sync', function () { expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com'); }); + it('should NOT fire a sync if a rule blocks syncUser', () => { + const userSync = newTestUserSync() + regRule(ACTIVITY_SYNC_USER, 'testRule', (params) => { + if ( + params[ACTIVITY_PARAM_COMPONENT] === `${MODULE_TYPE_BIDDER}.testBidder` && + params[ACTIVITY_PARAM_SYNC_TYPE] === 'image' && + params[ACTIVITY_PARAM_SYNC_URL] === 'http://example.com' + ) { + return {allow: false} + } + }) + userSync.registerSync('image', 'testBidder', 'http://example.com'); + userSync.syncUsers(); + expect(triggerPixelStub.called).to.be.false; + }) + it('should clear queue after sync', function () { const userSync = newTestUserSync(); userSync.syncUsers(); @@ -110,9 +140,10 @@ describe('user sync', function () { expect(insertUserSyncIframeStub.getCall(0).args[0]).to.equal('http://example.com/iframe'); }); - it('should only trigger syncs once per page per bidder', function () { + it('should stop triggering user syncs after bidderDone', function () { const userSync = newTestUserSync({ pixelEnabled: true }); userSync.registerSync('image', 'testBidder', 'http://example.com/1'); + userSync.bidderDone('testBidder'); userSync.syncUsers(); userSync.registerSync('image', 'testBidder', 'http://example.com/2'); userSync.registerSync('image', 'testBidder2', 'http://example.com/3'); @@ -370,14 +401,13 @@ describe('user sync', function () { userSync.registerSync('image', 'atestBidder', 'http://example.com/1'); userSync.registerSync('iframe', 'testBidder', 'http://example.com/iframe'); userSync.syncUsers(); - expect(logWarnStub.getCall(0).args[0]).to.exist; expect(triggerPixelStub.getCall(0)).to.not.be.null; expect(triggerPixelStub.getCall(0).args[0]).to.exist.and.to.equal('http://example.com/1'); expect(insertUserSyncIframeStub.getCall(0)).to.be.null; }); it('should still allow default image syncs if setConfig only defined iframe', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: config.getConfig('userSync'), browserSupportsCookies: true }); @@ -402,7 +432,7 @@ describe('user sync', function () { }); it('should not fire image pixel for a bidder if iframe pixel is fired for same bidder', function() { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: config.getConfig('userSync'), browserSupportsCookies: true }); @@ -429,7 +459,7 @@ describe('user sync', function () { }); it('should override default image syncs if setConfig used image filter', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: config.getConfig('userSync'), browserSupportsCookies: true }); @@ -454,7 +484,7 @@ describe('user sync', function () { }); it('should override default image syncs if setConfig used all filter', function() { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: config.getConfig('userSync'), browserSupportsCookies: true }); @@ -487,7 +517,7 @@ describe('user sync', function () { describe('canBidderRegisterSync', function () { describe('with filterSettings', function () { it('should return false if filter settings does not allow it', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { filterSettings: { image: { @@ -504,7 +534,7 @@ describe('user sync', function () { expect(userSync.canBidderRegisterSync('iframe', 'otherTestBidder')).to.equal(false); }); it('should return false for iframe if there is no iframe filterSettings', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { syncEnabled: true, filterSettings: { @@ -522,7 +552,7 @@ describe('user sync', function () { expect(userSync.canBidderRegisterSync('iframe', 'otherTestBidder')).to.equal(false); }); it('should return true if filter settings does allow it', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { filterSettings: { image: { @@ -542,7 +572,7 @@ describe('user sync', function () { describe('almost deprecated - without filterSettings', function () { describe('enabledBidders contains testBidder', function () { it('should return false if type is iframe and iframeEnabled is false', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { filterSettings: { iframe: { @@ -556,7 +586,7 @@ describe('user sync', function () { }); it('should return true if type is iframe and iframeEnabled is true', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { pixelEnabled: true, iframeEnabled: true, @@ -567,7 +597,7 @@ describe('user sync', function () { }); it('should return false if type is image and pixelEnabled is false', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { filterSettings: { image: { @@ -581,7 +611,7 @@ describe('user sync', function () { }); it('should return true if type is image and pixelEnabled is true', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { pixelEnabled: true, iframeEnabled: true, @@ -594,7 +624,7 @@ describe('user sync', function () { describe('enabledBidders does not container testBidder', function () { it('should return false since testBidder is not in enabledBidders', function () { - const userSync = newUserSync({ + const userSync = mkUserSync({ config: { filterSettings: { image: { diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js index 50a95b079c9..098582c0af6 100644 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -1,8 +1,10 @@ -import { getAdServerTargeting } from 'test/fixtures/fixtures.js'; -import { expect } from 'chai'; +import {getAdServerTargeting} from 'test/fixtures/fixtures.js'; +import {expect} from 'chai'; import CONSTANTS from 'src/constants.json'; import * as utils from 'src/utils.js'; -import {deepEqual, waitForElementToLoad} from 'src/utils.js'; +import {getHighestCpm, getLatestHighestCpmBid, getOldestHighestCpmBid} from '../../src/utils/reducers.js'; +import {binarySearch, deepEqual, memoize, waitForElementToLoad} from 'src/utils.js'; +import {convertCamelToUnderscore} from '../../libraries/appnexusUtils/anUtils.js'; var assert = require('assert'); @@ -39,28 +41,6 @@ describe('Utils', function () { }); }); - describe('tryAppendQueryString', function () { - it('should append query string to existing url', function () { - var url = 'www.a.com?'; - var key = 'b'; - var value = 'c'; - - var output = utils.tryAppendQueryString(url, key, value); - - var expectedResult = url + key + '=' + encodeURIComponent(value) + '&'; - assert.equal(output, expectedResult); - }); - - it('should return existing url, if the value is empty', function () { - var url = 'www.a.com?'; - var key = 'b'; - var value = ''; - - var output = utils.tryAppendQueryString(url, key, value); - assert.equal(output, url); - }); - }); - describe('parseQueryStringParameters', function () { it('should append query string to existing using the input obj', function () { var obj = { @@ -538,72 +518,6 @@ describe('Utils', function () { }); }); - describe('getHighestCpm', function () { - it('should pick the existing highest cpm', function () { - let previous = { - cpm: 2, - timeToRespond: 100 - }; - let current = { - cpm: 1, - timeToRespond: 100 - }; - assert.equal(utils.getHighestCpm(previous, current), previous); - }); - - it('should pick the new highest cpm', function () { - let previous = { - cpm: 1, - timeToRespond: 100 - }; - let current = { - cpm: 2, - timeToRespond: 100 - }; - assert.equal(utils.getHighestCpm(previous, current), current); - }); - - it('should pick the fastest cpm in case of tie', function () { - let previous = { - cpm: 1, - timeToRespond: 100 - }; - let current = { - cpm: 1, - timeToRespond: 50 - }; - assert.equal(utils.getHighestCpm(previous, current), current); - }); - - it('should pick the oldest in case of tie using responseTimeStamp', function () { - let previous = { - cpm: 1, - timeToRespond: 100, - responseTimestamp: 1000 - }; - let current = { - cpm: 1, - timeToRespond: 50, - responseTimestamp: 2000 - }; - assert.equal(utils.getOldestHighestCpmBid(previous, current), previous); - }); - - it('should pick the latest in case of tie using responseTimeStamp', function () { - let previous = { - cpm: 1, - timeToRespond: 100, - responseTimestamp: 1000 - }; - let current = { - cpm: 1, - timeToRespond: 50, - responseTimestamp: 2000 - }; - assert.equal(utils.getLatestHighestCpmBid(previous, current), current); - }); - }); - describe('polyfill test', function () { it('should not add polyfill to array', function() { var arr = ['hello', 'world']; @@ -765,43 +679,15 @@ describe('Utils', function () { describe('convertCamelToUnderscore', function () { it('returns converted string value using underscore syntax instead of camelCase', function () { let var1 = 'placementIdTest'; - let test1 = utils.convertCamelToUnderscore(var1); + let test1 = convertCamelToUnderscore(var1); expect(test1).to.equal('placement_id_test'); let var2 = 'my_test_value'; - let test2 = utils.convertCamelToUnderscore(var2); + let test2 = convertCamelToUnderscore(var2); expect(test2).to.equal(var2); }); }); - describe('getAdUnitSizes', function () { - it('returns an empty response when adUnits is undefined', function () { - let sizes = utils.getAdUnitSizes(); - expect(sizes).to.be.undefined; - }); - - it('returns an empty array when invalid data is present in adUnit object', function () { - let sizes = utils.getAdUnitSizes({ sizes: 300 }); - expect(sizes).to.deep.equal([]); - }); - - it('retuns an array of arrays when reading from adUnit.sizes', function () { - let sizes = utils.getAdUnitSizes({ sizes: [300, 250] }); - expect(sizes).to.deep.equal([[300, 250]]); - - sizes = utils.getAdUnitSizes({ sizes: [[300, 250], [300, 600]] }); - expect(sizes).to.deep.equal([[300, 250], [300, 600]]); - }); - - it('returns an array of arrays when reading from adUnit.mediaTypes.banner.sizes', function () { - let sizes = utils.getAdUnitSizes({ mediaTypes: { banner: { sizes: [300, 250] } } }); - expect(sizes).to.deep.equal([[300, 250]]); - - sizes = utils.getAdUnitSizes({ mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } } }); - expect(sizes).to.deep.equal([[300, 250], [300, 600]]); - }); - }); - describe('URL helpers', function () { describe('parseUrl()', function () { let parsed; @@ -894,93 +780,24 @@ describe('Utils', function () { }); }); - describe('transformBidderParamKeywords', function () { - it('returns an array of objects when keyvalue is an array', function () { - let keywords = { - genre: ['rock', 'pop'] - }; - let result = utils.transformBidderParamKeywords(keywords); - expect(result).to.deep.equal([{ - key: 'genre', - value: ['rock', 'pop'] - }]); - }); - - it('returns an array of objects when keyvalue is a string', function () { - let keywords = { - genre: 'opera' - }; - let result = utils.transformBidderParamKeywords(keywords); - expect(result).to.deep.equal([{ - key: 'genre', - value: ['opera'] - }]); - }); - - it('returns an array of objects when keyvalue is a number', function () { - let keywords = { - age: 15 - }; - let result = utils.transformBidderParamKeywords(keywords); - expect(result).to.deep.equal([{ - key: 'age', - value: ['15'] - }]); - }); - - it('returns an array of objects when using multiple keys with values of differing types', function () { - let keywords = { - genre: 'classical', - mix: ['1', 2, '3', 4], - age: 10 - }; - let result = utils.transformBidderParamKeywords(keywords); - expect(result).to.deep.equal([{ - key: 'genre', - value: ['classical'] - }, { - key: 'mix', - value: ['1', '2', '3', '4'] - }, { - key: 'age', - value: ['10'] - }]); - }); - - it('returns an array of objects when the keyvalue uses an empty string', function() { - let keywords = { - test: [''], - test2: '' - }; - let result = utils.transformBidderParamKeywords(keywords); - expect(result).to.deep.equal([{ - key: 'test', - value: [''] - }, { - key: 'test2', - value: [''] - }]); - }); - - describe('insertElement', function () { - it('returns a node at the top of the target by default', function () { - const toInsert = document.createElement('div'); - const target = document.getElementsByTagName('body')[0]; - const inserted = utils.insertElement(toInsert, document, 'body'); - expect(inserted).to.equal(target.firstChild); - }); - it('returns a node at bottom of target if 4th argument is true', function () { - const toInsert = document.createElement('div'); - const target = document.getElementsByTagName('html')[0]; - const inserted = utils.insertElement(toInsert, document, 'html', true); - expect(inserted).to.equal(target.lastChild); - }); - it('returns a node at top of the head if no target is given', function () { - const toInsert = document.createElement('div'); - const target = document.getElementsByTagName('head')[0]; - const inserted = utils.insertElement(toInsert); - expect(inserted).to.equal(target.firstChild); - }); + describe('insertElement', function () { + it('returns a node at the top of the target by default', function () { + const toInsert = document.createElement('div'); + const target = document.getElementsByTagName('body')[0]; + const inserted = utils.insertElement(toInsert, document, 'body'); + expect(inserted).to.equal(target.firstChild); + }); + it('returns a node at bottom of target if 4th argument is true', function () { + const toInsert = document.createElement('div'); + const target = document.getElementsByTagName('html')[0]; + const inserted = utils.insertElement(toInsert, document, 'html', true); + expect(inserted).to.equal(target.lastChild); + }); + it('returns a node at top of the head if no target is given', function () { + const toInsert = document.createElement('div'); + const target = document.getElementsByTagName('head')[0]; + const inserted = utils.insertElement(toInsert); + expect(inserted).to.equal(target.firstChild); }); }); @@ -1243,4 +1060,103 @@ describe('Utils', function () { }); }); }); + + describe('setScriptAttributes', () => { + it('correctly adds attributes from an object', () => { + const script = document.createElement('script'), + attrs = { + 'data-first_prop': '1', + 'data-second_prop': 'b', + 'id': 'newId' + }; + script.id = 'oldId'; + utils.setScriptAttributes(script, attrs); + expect(script.dataset['first_prop']).to.equal('1'); + expect(script.dataset.second_prop).to.equal('b'); + expect(script.id).to.equal('newId'); + }); + }); }); + +describe('memoize', () => { + let fn; + + beforeEach(() => { + fn = sinon.stub().callsFake(function() { + return Array.from(arguments); + }); + }); + + it('delegates to fn', () => { + expect(memoize(fn)('one', 'two')).to.eql(['one', 'two']); + }); + + it('caches result after first call, if first argument is the same', () => { + const mem = memoize(fn); + mem('one', 'two'); + expect(mem('one', 'three')).to.eql(['one', 'two']); + expect(fn.callCount).to.equal(1); + }); + + it('delegates again when the first argument changes', () => { + const mem = memoize(fn); + mem('one', 'two'); + expect(mem('two', 'one')).to.eql(['two', 'one']); + expect(fn.callCount).to.eql(2); + }); + + it('can clear cache with .clear', () => { + const mem = memoize(fn); + mem('arg'); + mem.clear(); + expect(mem('arg')).to.eql(['arg']); + expect(fn.callCount).to.equal(2); + }); + + it('allows setting cache keys', () => { + const mem = memoize(fn, (...args) => args.join(',')) + mem('one', 'two'); + mem('one', 'three'); + expect(mem('one', 'three')).to.eql(['one', 'three']); + expect(fn.callCount).to.eql(2); + }); + + describe('binarySearch', () => { + [ + { + arr: [], + tests: [ + ['any', 0] + ] + }, + { + arr: [10], + tests: [ + [5, 0], + [10, 0], + [20, 1], + ], + }, + { + arr: [10, 20, 30, 30, 40], + tests: [ + [5, 0], + [15, 1], + [10, 0], + [30, 2], + [35, 4], + [40, 4], + [100, 5] + ] + } + ].forEach(({arr, tests}) => { + describe(`on ${arr}`, () => { + tests.forEach(([el, pos]) => { + it(`finds index for ${el} => ${pos}`, () => { + expect(binarySearch(arr, el)).to.equal(pos); + }); + }); + }); + }) + }); +}) diff --git a/test/spec/videoCache_spec.js b/test/spec/videoCache_spec.js index 34e9bed04b6..c746fdd2afd 100644 --- a/test/spec/videoCache_spec.js +++ b/test/spec/videoCache_spec.js @@ -4,6 +4,7 @@ import { config } from 'src/config.js'; import { server } from 'test/mocks/xhr.js'; import {auctionManager} from '../../src/auctionManager.js'; import {AuctionIndex} from '../../src/auctionIndex.js'; +import { batchingCache } from '../../src/auction.js'; const should = chai.should(); @@ -29,8 +30,7 @@ function getMockBid(bidder, auctionId, bidderRequestId) { 'sizes': [300, 250], 'bidId': '123', 'bidderRequestId': bidderRequestId, - 'auctionId': auctionId, - 'storedAuctionResponse': 11111 + 'auctionId': auctionId }; } @@ -72,6 +72,29 @@ describe('The video cache', function () { config.resetConfig(); }); + describe('cache.timeout', () => { + let getAjax, cb; + beforeEach(() => { + getAjax = sinon.stub().callsFake(() => sinon.stub()); + cb = sinon.stub(); + }); + + it('should be respected', () => { + config.setConfig({ + cache: { + timeout: 1 + } + }); + store([{ vastUrl: 'my-mock-url.com' }], cb, getAjax); + sinon.assert.calledWith(getAjax, 1); + }); + + it('should use default when not specified', () => { + store([], cb, getAjax); + sinon.assert.calledWith(getAjax, undefined); + }) + }); + it('should execute the callback with a successful result when store() is called', function () { const uuid = 'c488b101-af3e-4a99-b538-00423e5a3371'; const callback = fakeServerCall( @@ -151,17 +174,17 @@ describe('The video cache', function () { const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); - request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); + request.requestHeaders['Content-Type'].should.equal('text/plain'); let payload = { puts: [{ type: 'xml', value: vastXml1, - ttlseconds: 25, + ttlseconds: 40, key: customKey1 }, { type: 'xml', value: vastXml2, - ttlseconds: 25, + ttlseconds: 40, key: customKey2 }] }; @@ -201,12 +224,12 @@ describe('The video cache', function () { const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); - request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); + request.requestHeaders['Content-Type'].should.equal('text/plain'); let payload = { puts: [{ type: 'xml', value: vastXml1, - ttlseconds: 25, + ttlseconds: 40, key: customKey1, bidid: '12345abc', aid: '1234-56789-abcde', @@ -214,7 +237,7 @@ describe('The video cache', function () { }, { type: 'xml', value: vastXml2, - ttlseconds: 25, + ttlseconds: 40, key: customKey2, bidid: 'cba54321', aid: '1234-56789-abcde', @@ -272,12 +295,12 @@ describe('The video cache', function () { const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); - request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); + request.requestHeaders['Content-Type'].should.equal('text/plain'); let payload = { puts: [{ type: 'xml', value: vastXml1, - ttlseconds: 25, + ttlseconds: 40, key: customKey1, bidid: '12345abc', bidder: 'appnexus', @@ -286,7 +309,7 @@ describe('The video cache', function () { }, { type: 'xml', value: vastXml2, - ttlseconds: 25, + ttlseconds: 40, key: customKey2, bidid: 'cba54321', bidder: 'rubicon', @@ -298,19 +321,48 @@ describe('The video cache', function () { JSON.parse(request.requestBody).should.deep.equal(payload); }); + it('should wait the duration of the batchTimeout and pass the correct batchSize if batched requests are enabled in the config', () => { + const mockAfterBidAdded = function() {}; + let callback = null; + let mockTimeout = sinon.stub().callsFake((cb) => { callback = cb }); + + config.setConfig({ + cache: { + url: 'https://prebid.adnxs.com/pbc/v1/cache', + batchSize: 3, + batchTimeout: 20 + } + }); + + let stubCache = sinon.stub(); + const batchAndStore = batchingCache(mockTimeout, stubCache); + for (let i = 0; i < 3; i++) { + batchAndStore({}, {}, mockAfterBidAdded); + } + + sinon.assert.calledOnce(mockTimeout); + sinon.assert.calledWith(mockTimeout, sinon.match.any, 20); + + const expectedBatch = [{ afterBidAdded: mockAfterBidAdded, auctionInstance: { }, bidResponse: { } }, { afterBidAdded: mockAfterBidAdded, auctionInstance: { }, bidResponse: { } }, { afterBidAdded: mockAfterBidAdded, auctionInstance: { }, bidResponse: { } }]; + + callback(); + + sinon.assert.calledWith(stubCache, expectedBatch); + }); + function assertRequestMade(bid, expectedValue) { store([bid], function () { }); const request = server.requests[0]; request.method.should.equal('POST'); request.url.should.equal('https://prebid.adnxs.com/pbc/v1/cache'); - request.requestHeaders['Content-Type'].should.equal('text/plain;charset=utf-8'); + request.requestHeaders['Content-Type'].should.equal('text/plain'); JSON.parse(request.requestBody).should.deep.equal({ puts: [{ type: 'xml', value: expectedValue, - ttlseconds: 25 + ttlseconds: 40 }], }); } diff --git a/test/spec/video_spec.js b/test/spec/video_spec.js index 61621c7ec42..35d0a4fef24 100644 --- a/test/spec/video_spec.js +++ b/test/spec/video_spec.js @@ -1,4 +1,4 @@ -import { isValidVideoBid } from 'src/video.js'; +import {fillVideoDefaults, isValidVideoBid} from 'src/video.js'; import {hook} from '../../src/hook.js'; import {stubAuctionIndex} from '../helpers/indexStub.js'; @@ -7,97 +7,169 @@ describe('video.js', function () { hook.ready(); }); - it('validates valid instream bids', function () { - const bid = { - adId: '456xyz', - vastUrl: 'http://www.example.com/vastUrl', - transactionId: 'au' - }; - const adUnits = [{ - transactionId: 'au', - mediaTypes: { - video: {context: 'instream'} - } - }]; - const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); - expect(valid).to.equal(true); - }); + describe('fillVideoDefaults', () => { + function fillDefaults(videoMediaType = {}) { + const adUnit = {mediaTypes: {video: videoMediaType}}; + fillVideoDefaults(adUnit); + return adUnit.mediaTypes.video; + } - it('catches invalid instream bids', function () { - const bid = { - transactionId: 'au' - }; - const adUnits = [{ - transactionId: 'au', - mediaTypes: { - video: {context: 'instream'} - } - }]; - const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); - expect(valid).to.equal(false); - }); + describe('should set plcmt = 4 when', () => { + it('context is "outstream"', () => { + expect(fillDefaults({context: 'outstream'})).to.eql({ + context: 'outstream', + plcmt: 4 + }) + }); + [2, 3, 4].forEach(placement => { + it(`placemement is "${placement}"`, () => { + expect(fillDefaults({placement})).to.eql({ + placement, + plcmt: 4 + }); + }) + }); + }); + describe('should set plcmt = 2 when', () => { + [2, 6].forEach(playbackmethod => { + it(`playbackmethod is "${playbackmethod}"`, () => { + expect(fillDefaults({playbackmethod})).to.eql({ + playbackmethod, + plcmt: 2, + }); + }); + }); + }); + describe('should not set plcmt when', () => { + Object.entries({ + 'it was set by pub (context=outstream)': { + expected: 1, + video: { + context: 'outstream', + plcmt: 1 + } + }, + 'it was set by pub (placement=2)': { + expected: 1, + video: { + placement: 2, + plcmt: 1 + } + }, + 'placement not in 2, 3, 4': { + expected: undefined, + video: { + placement: 1 + } + }, + 'it was set by pub (playbackmethod=2)': { + expected: 1, + video: { + plcmt: 1, + playbackmethod: 2 + } + } + }).forEach(([t, {expected, video}]) => { + it(t, () => { + expect(fillDefaults(video).plcmt).to.eql(expected); + }) + }) + }) + }) - it('catches invalid bids when prebid-cache is disabled', function () { - const adUnits = [{ - transactionId: 'au', - bidder: 'vastOnlyVideoBidder', - mediaTypes: {video: {}}, - }]; + describe('isValidVideoBid', () => { + it('validates valid instream bids', function () { + const bid = { + adId: '456xyz', + vastUrl: 'http://www.example.com/vastUrl', + transactionId: 'au' + }; + const adUnits = [{ + transactionId: 'au', + mediaTypes: { + video: {context: 'instream'} + } + }]; + const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); + expect(valid).to.equal(true); + }); - const valid = isValidVideoBid({ transactionId: 'au', vastXml: 'vast' }, {index: stubAuctionIndex({adUnits})}); + it('catches invalid instream bids', function () { + const bid = { + transactionId: 'au' + }; + const adUnits = [{ + transactionId: 'au', + mediaTypes: { + video: {context: 'instream'} + } + }]; + const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); + expect(valid).to.equal(false); + }); - expect(valid).to.equal(false); - }); + it('catches invalid bids when prebid-cache is disabled', function () { + const adUnits = [{ + transactionId: 'au', + bidder: 'vastOnlyVideoBidder', + mediaTypes: {video: {}}, + }]; - it('validates valid outstream bids', function () { - const bid = { - transactionId: 'au', - renderer: { - url: 'render.url', - render: () => true, - } - }; - const adUnits = [{ - transactionId: 'au', - mediaTypes: { - video: {context: 'outstream'} - } - }]; - const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); - expect(valid).to.equal(true); - }); + const valid = isValidVideoBid({ transactionId: 'au', vastXml: 'vast' }, {index: stubAuctionIndex({adUnits})}); - it('validates valid outstream bids with a publisher defined renderer', function () { - const bid = { - transactionId: 'au', - }; - const adUnits = [{ - transactionId: 'au', - mediaTypes: { - video: { - context: 'outstream', + expect(valid).to.equal(false); + }); + + it('validates valid outstream bids', function () { + const bid = { + transactionId: 'au', + renderer: { + url: 'render.url', + render: () => true, } - }, - renderer: { - url: 'render.url', - render: () => true, - } - }]; - const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); - expect(valid).to.equal(true); - }); + }; + const adUnits = [{ + transactionId: 'au', + mediaTypes: { + video: {context: 'outstream'} + } + }]; + const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); + expect(valid).to.equal(true); + }); - it('catches invalid outstream bids', function () { - const bid = { - transactionId: 'au', - }; - const adUnits = [{ - transactionId: 'au', - mediaTypes: { - video: {context: 'outstream'} - } - }]; - const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); - expect(valid).to.equal(false); - }); + it('validates valid outstream bids with a publisher defined renderer', function () { + const bid = { + transactionId: 'au', + }; + const adUnits = [{ + transactionId: 'au', + mediaTypes: { + video: { + context: 'outstream', + } + }, + renderer: { + url: 'render.url', + render: () => true, + } + }]; + const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); + expect(valid).to.equal(true); + }); + + it('catches invalid outstream bids', function () { + const bid = { + transactionId: 'au', + }; + const adUnits = [{ + transactionId: 'au', + mediaTypes: { + video: {context: 'outstream'} + } + }]; + const valid = isValidVideoBid(bid, {index: stubAuctionIndex({adUnits})}); + expect(valid).to.equal(false); + }); + }) }); diff --git a/test/test_deps.js b/test/test_deps.js index 8b8c9fd3a0f..35713106f8c 100644 --- a/test/test_deps.js +++ b/test/test_deps.js @@ -4,6 +4,8 @@ window.process = { } }; +require('test/helpers/consentData.js'); require('test/helpers/prebidGlobal.js'); require('test/mocks/adloaderStub.js'); require('test/mocks/xhr.js'); +require('test/mocks/analyticsStub.js'); diff --git a/test/test_index.js b/test/test_index.js index 883f4d0590c..ce9b671be89 100644 --- a/test/test_index.js +++ b/test/test_index.js @@ -1,3 +1,25 @@ +[it, describe].forEach((ob) => { + ob.only = function () { + [ + 'describe.only and it.only are disabled unless you provide a single spec --file,', + 'because they can silently break the pipeline tests', + // eslint-disable-next-line no-console + ].forEach(l => console.error(l)) + throw new Error('do not use .only()') + }; +}); + +[it, describe].forEach((ob) => { + ob.skip = function () { + [ + 'describe.skip and it.skip are disabled,', + 'because they pollute the pipeline test output', + // eslint-disable-next-line no-console + ].forEach(l => console.error(l)) + throw new Error('do not use .skip()') + }; +}); + require('./test_deps.js'); var testsContext = require.context('.', true, /_spec$/); diff --git a/wdio.conf.js b/wdio.conf.js index 4f14d4c7a6d..3d93f909971 100644 --- a/wdio.conf.js +++ b/wdio.conf.js @@ -51,6 +51,7 @@ exports.config = { user: process.env.BROWSERSTACK_USERNAME, key: process.env.BROWSERSTACK_ACCESS_KEY, maxInstances: 5, // Do not increase this, since we have only 5 parallel tests in browserstack account + maxInstancesPerCapability: 1, capabilities: getCapabilities(), logLevel: 'info', // put option here: info | trace | debug | warn| error | silent bail: 0, diff --git a/webpack.conf.js b/webpack.conf.js index 5269f5300f5..0ead550e446 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -1,12 +1,34 @@ +const TerserPlugin = require('terser-webpack-plugin'); var prebid = require('./package.json'); var path = require('path'); var webpack = require('webpack'); var helpers = require('./gulpHelpers.js'); var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); var argv = require('yargs').argv; +const fs = require('fs'); +const babelConfig = require('./babelConfig.js')({disableFeatures: helpers.getDisabledFeatures(), prebidDistUrlBase: argv.distUrlBase}); +const {WebpackManifestPlugin} = require('webpack-manifest-plugin') var plugins = [ - new webpack.EnvironmentPlugin({'LiveConnectMode': null}) + new webpack.EnvironmentPlugin({'LiveConnectMode': null}), + new WebpackManifestPlugin({ + fileName: 'dependencies.json', + generate: (seed, files) => { + const entries = new Set(); + const addEntry = entries.add.bind(entries); + + files.forEach(file => file.chunk && file.chunk._groups && file.chunk._groups.forEach(addEntry)); + + return Array.from(entries).reduce((acc, entry) => { + const name = (entry.options || {}).name || (entry.runtimeChunk || {}).name + const files = (entry.chunks || []) + .filter(chunk => chunk.name !== name) + .flatMap(chunk => [...chunk.files]) + .filter(Boolean); + return name && files.length ? {...acc, [`${name}.js`]: files} : acc + }, seed) + } + }) ]; if (argv.analyze) { @@ -28,15 +50,21 @@ module.exports = { const entry = { 'prebid-core': { import: './src/prebid.js' + }, + 'debugging-standalone': { + import: './modules/debugging/standalone.js' } }; const selectedModules = new Set(helpers.getArgModules()); + Object.entries(helpers.getModules()).forEach(([fn, mod]) => { if (selectedModules.size === 0 || selectedModules.has(mod)) { - entry[mod] = { + const moduleEntry = { import: fn, dependOn: 'prebid-core' - } + }; + + entry[mod] = moduleEntry; } }); return entry; @@ -53,7 +81,7 @@ module.exports = { use: [ { loader: 'babel-loader', - options: helpers.getAnalyticsOptions(), + options: Object.assign({}, babelConfig, helpers.getAnalyticsOptions()), } ] }, @@ -63,6 +91,7 @@ module.exports = { use: [ { loader: 'babel-loader', + options: babelConfig } ], } @@ -71,6 +100,40 @@ module.exports = { optimization: { usedExports: true, sideEffects: true, + minimizer: [ + new TerserPlugin({ + extractComments: false, // do not generate unhelpful LICENSE comment + terserOptions: { + module: true, // do not prepend every module with 'use strict'; allow mangling of top-level locals + } + }) + ], + splitChunks: { + chunks: 'initial', + minChunks: 1, + minSize: 0, + cacheGroups: (() => { + const libRoot = path.resolve(__dirname, 'libraries'); + const libraries = Object.fromEntries( + fs.readdirSync(libRoot) + .filter((f) => fs.lstatSync(path.resolve(libRoot, f)).isDirectory()) + .map(lib => { + const dir = path.resolve(libRoot, lib) + const def = { + name: lib, + test: (module) => { + return module.resource && module.resource.startsWith(dir) + } + } + return [lib, def]; + }) + ); + return Object.assign(libraries, { + default: false, + defaultVendors: false + }) + })() + } }, plugins };